summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-10-21 14:51:13 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-10-21 14:51:13 +0200
commit5209a846a9157e649fcdcb561f7eaf19c8c0e465 (patch)
treeb0a7e52b5646c8eec182dbc391e7934b6804488c /source4/lib
parent625359b2e266105022309df8985720108ecd6f67 (diff)
parent2ee8d29d22bcb1c350ab59d71b0aee548489bc9c (diff)
downloadsamba-5209a846a9157e649fcdcb561f7eaf19c8c0e465.tar.gz
samba-5209a846a9157e649fcdcb561f7eaf19c8c0e465.tar.bz2
samba-5209a846a9157e649fcdcb561f7eaf19c8c0e465.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba into regsrv
Conflicts: source4/lib/registry/ldb.c source4/rpc_server/winreg/rpc_winreg.c
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/appweb/README6
-rw-r--r--source4/lib/appweb/config.m41
-rw-r--r--source4/lib/appweb/config.mk25
-rw-r--r--source4/lib/appweb/ejs-2.0/.bashrc153
-rw-r--r--source4/lib/appweb/ejs-2.0/.exrc1
-rw-r--r--source4/lib/appweb/ejs-2.0/.ignore57
-rw-r--r--source4/lib/appweb/ejs-2.0/.loginrc218
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/.ignore2
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/Makefile61
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/classes/.ignore1
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/classes/Makefile21
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/classes/ejsArray.c167
-rwxr-xr-xsource4/lib/appweb/ejs-2.0/ejs/classes/ejsDate.c197
-rwxr-xr-xsource4/lib/appweb/ejs-2.0/ejs/classes/ejsError.c140
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/classes/ejsObject.c588
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/classes/ejsStndClasses.c144
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/classes/ejsString.c381
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/classes/ejsXml.c1327
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/ejs.c1378
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/ejs.h849
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/ejsClass.c273
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/ejsCmd.c468
-rwxr-xr-xsource4/lib/appweb/ejs-2.0/ejs/ejsGarbage.c1214
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/ejsLex.c1033
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/ejsParser.c4514
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/ejsVar.c4033
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/ejsVar.h1091
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/lib/event.js141
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/lib/global.js34
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/lib/startup.js15
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/lib/timer.js158
-rwxr-xr-xsource4/lib/appweb/ejs-2.0/ejs/system/.ignore1
-rwxr-xr-xsource4/lib/appweb/ejs-2.0/ejs/system/Makefile27
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/system/README.TXT63
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/system/UNIX/.ignore1
-rwxr-xr-xsource4/lib/appweb/ejs-2.0/ejs/system/UNIX/Makefile21
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsFile.c98
-rwxr-xr-xsource4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsFileSystem.c454
-rwxr-xr-xsource4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsHTTP.c488
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/system/WIN/.ignore1
-rwxr-xr-xsource4/lib/appweb/ejs-2.0/ejs/system/WIN/Makefile21
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsFile.c98
-rwxr-xr-xsource4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsFileSystem.c456
-rwxr-xr-xsource4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsHTTP.c488
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/system/ejsGC.c326
-rwxr-xr-xsource4/lib/appweb/ejs-2.0/ejs/system/ejsGlobal.c785
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/system/ejsSystem.c112
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemApp.c49
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemDebug.c60
-rw-r--r--source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemLog.c163
-rwxr-xr-xsource4/lib/appweb/ejs-2.0/ejs/system/ejsSystemMemory.c174
-rw-r--r--source4/lib/appweb/ejs-2.0/exml/Makefile42
-rw-r--r--source4/lib/appweb/ejs-2.0/exml/exml.h94
-rw-r--r--source4/lib/appweb/ejs-2.0/exml/exmlParser.c752
-rw-r--r--source4/lib/appweb/ejs-2.0/exml/files1
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/Makefile41
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/UNIX/Makefile16
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/UNIX/mprFile.c86
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/UNIX/mprPlatform.c218
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/UNIX/mprTime.c163
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/VXWORKS/Makefile16
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprFile.c85
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprPlatform.c191
-rwxr-xr-xsource4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprTime.c163
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/WIN/Makefile16
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/WIN/mprFile.c123
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/WIN/mprPlatform.c378
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/WIN/mprTime.c192
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/files14
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/mpr.c340
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/mpr.h1027
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/mprAlloc.c1775
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/mprArray.c385
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/mprBuf.c535
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/mprGenFile.c336
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/mprGenTime.c195
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/mprLock.c266
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/mprLog.c602
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/mprOs.h707
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/mprPrintf.c924
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/mprString.c733
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/mprSymbol.c279
-rw-r--r--source4/lib/appweb/ejs-2.0/mpr/mprUnix.h105
-rw-r--r--source4/lib/appweb/ejs/config.h141
-rw-r--r--source4/lib/appweb/ejs/ejs.h136
-rw-r--r--source4/lib/appweb/ejs/ejsInternal.h295
-rw-r--r--source4/lib/appweb/ejs/ejsLex.c923
-rw-r--r--source4/lib/appweb/ejs/ejsLib.c1090
-rw-r--r--source4/lib/appweb/ejs/ejsParser.c2436
-rw-r--r--source4/lib/appweb/ejs/ejsProcs.c704
-rw-r--r--source4/lib/appweb/esp/esp.c1042
-rw-r--r--source4/lib/appweb/esp/esp.h277
-rw-r--r--source4/lib/appweb/esp/espEnv.h128
-rw-r--r--source4/lib/appweb/esp/espProcs.c249
-rw-r--r--source4/lib/appweb/mpr/miniMpr.c522
-rw-r--r--source4/lib/appweb/mpr/miniMpr.h301
-rw-r--r--source4/lib/appweb/mpr/var.c2215
-rw-r--r--source4/lib/appweb/mpr/var.h487
-rw-r--r--source4/lib/charset/charset.h5
-rw-r--r--source4/lib/charset/iconv.c2
-rw-r--r--source4/lib/charset/util_unistr.c17
-rw-r--r--source4/lib/cmdline/credentials.c1
-rw-r--r--source4/lib/cmdline/popt_common.h2
-rw-r--r--source4/lib/com/README9
-rw-r--r--source4/lib/com/classes/simple.c122
-rw-r--r--source4/lib/com/com.h52
-rw-r--r--source4/lib/com/config.mk22
-rw-r--r--source4/lib/com/dcom/dcom.h85
-rw-r--r--source4/lib/com/dcom/main.c710
-rw-r--r--source4/lib/com/dcom/tables.c92
-rw-r--r--source4/lib/com/main.c90
-rw-r--r--source4/lib/com/pycom.c81
-rw-r--r--source4/lib/com/rot.c35
-rw-r--r--source4/lib/com/tables.c109
-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/crypto/arcfour.c91
-rw-r--r--source4/lib/crypto/config.mk18
-rw-r--r--source4/lib/crypto/crc32.c103
-rw-r--r--source4/lib/crypto/crc32.h1
-rw-r--r--source4/lib/crypto/crypto.h37
-rw-r--r--source4/lib/crypto/hmacmd5.c117
-rw-r--r--source4/lib/crypto/hmacmd5.h38
-rw-r--r--source4/lib/crypto/hmacmd5test.c98
-rw-r--r--source4/lib/crypto/hmacsha256.c91
-rw-r--r--source4/lib/crypto/hmacsha256.h38
-rw-r--r--source4/lib/crypto/md4.c176
-rw-r--r--source4/lib/crypto/md4.h1
-rw-r--r--source4/lib/crypto/md4test.c83
-rw-r--r--source4/lib/crypto/md5.c248
-rw-r--r--source4/lib/crypto/md5.h19
-rw-r--r--source4/lib/crypto/md5test.c93
-rw-r--r--source4/lib/crypto/sha256.c253
-rw-r--r--source4/lib/crypto/sha256.h91
-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/events/Makefile.in35
-rwxr-xr-xsource4/lib/events/autogen.sh3
-rw-r--r--source4/lib/events/build_macros.m414
-rw-r--r--source4/lib/events/configure.ac9
-rw-r--r--source4/lib/events/events.i2
-rw-r--r--source4/lib/events/events.mk4
-rw-r--r--source4/lib/events/events.py2
-rw-r--r--source4/lib/events/events_util.c1
-rw-r--r--source4/lib/events/events_wrap.c17
-rw-r--r--source4/lib/events/libevents.m42
-rw-r--r--source4/lib/events/libtalloc.m47
-rw-r--r--source4/lib/events/pkg.m4156
-rw-r--r--source4/lib/gencache/gencache.c375
-rw-r--r--source4/lib/gencache/gencache.h94
-rw-r--r--source4/lib/json/AUTHORS2
-rw-r--r--source4/lib/json/COPYING18
-rw-r--r--source4/lib/json/ChangeLog55
-rw-r--r--source4/lib/json/Doxyfile1153
-rw-r--r--source4/lib/json/INSTALL229
-rw-r--r--source4/lib/json/Makefile.am36
-rw-r--r--source4/lib/json/Makefile.in533
-rw-r--r--source4/lib/json/NEWS1
-rw-r--r--source4/lib/json/README20
-rw-r--r--source4/lib/json/README-WIN32.html61
-rw-r--r--source4/lib/json/README.html36
-rw-r--r--source4/lib/json/aclocal.m47379
-rw-r--r--source4/lib/json/arraylist.c93
-rw-r--r--source4/lib/json/arraylist.h45
-rw-r--r--source4/lib/json/autogen.sh1
-rw-r--r--source4/lib/json/bits.h27
-rwxr-xr-xsource4/lib/json/config.guess1464
-rw-r--r--source4/lib/json/config.h.in117
-rw-r--r--source4/lib/json/config.h.win3294
-rwxr-xr-xsource4/lib/json/config.sub1568
-rwxr-xr-xsource4/lib/json/configure20603
-rw-r--r--source4/lib/json/configure.in33
-rw-r--r--source4/lib/json/debug.c94
-rw-r--r--source4/lib/json/debug.h24
-rwxr-xr-xsource4/lib/json/depcomp421
-rwxr-xr-xsource4/lib/json/install-sh269
-rw-r--r--source4/lib/json/json-c.vcproj179
-rw-r--r--source4/lib/json/json.h31
-rw-r--r--source4/lib/json/json.pc.in11
-rw-r--r--source4/lib/json/json_object.c504
-rw-r--r--source4/lib/json/json_object.h310
-rw-r--r--source4/lib/json/json_object_private.h44
-rw-r--r--source4/lib/json/json_tokener.c465
-rw-r--r--source4/lib/json/json_tokener.h63
-rw-r--r--source4/lib/json/json_util.c121
-rw-r--r--source4/lib/json/json_util.h23
-rw-r--r--source4/lib/json/linkhash.c217
-rw-r--r--source4/lib/json/linkhash.h261
-rw-r--r--source4/lib/json/ltmain.sh6425
-rwxr-xr-xsource4/lib/json/missing334
-rwxr-xr-xsource4/lib/json/mkinstalldirs99
-rw-r--r--source4/lib/json/printbuf.c144
-rw-r--r--source4/lib/json/printbuf.h38
-rw-r--r--source4/lib/json/stamp-h.in1
-rw-r--r--source4/lib/json/test1.c137
-rw-r--r--source4/lib/json/test2.c19
-rw-r--r--source4/lib/ldb/Makefile.in42
-rwxr-xr-xsource4/lib/ldb/autogen.sh9
-rw-r--r--source4/lib/ldb/build_macros.m414
-rw-r--r--source4/lib/ldb/common/ldb.c431
-rw-r--r--source4/lib/ldb/common/ldb_dn.c4
-rw-r--r--source4/lib/ldb/common/ldb_modules.c147
-rw-r--r--source4/lib/ldb/configure.ac4
-rw-r--r--source4/lib/ldb/examples/ldbreader.c5
-rw-r--r--source4/lib/ldb/external/libevents.m49
-rw-r--r--source4/lib/ldb/external/libtalloc.m49
-rw-r--r--source4/lib/ldb/external/libtdb.m49
-rw-r--r--source4/lib/ldb/include/ldb.h162
-rw-r--r--source4/lib/ldb/include/ldb_private.h106
-rw-r--r--source4/lib/ldb/ldb.i381
-rw-r--r--source4/lib/ldb/ldb.mk29
-rw-r--r--source4/lib/ldb/ldb.py31
-rw-r--r--source4/lib/ldb/ldb_ildap/ldb_ildap.c483
-rw-r--r--source4/lib/ldb/ldb_ldap/ldb_ldap.c588
-rw-r--r--source4/lib/ldb/ldb_map/ldb_map.c357
-rw-r--r--source4/lib/ldb/ldb_map/ldb_map.h4
-rw-r--r--source4/lib/ldb/ldb_map/ldb_map_inbound.c754
-rw-r--r--source4/lib/ldb/ldb_map/ldb_map_outbound.c443
-rw-r--r--source4/lib/ldb/ldb_map/ldb_map_private.h90
-rw-r--r--source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c130
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c61
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_search.c155
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c481
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.h16
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c4
-rw-r--r--source4/lib/ldb/ldb_wrap.c993
-rw-r--r--source4/lib/ldb/libldb.m46
-rw-r--r--source4/lib/ldb/modules/asq.c419
-rw-r--r--source4/lib/ldb/modules/operational.c102
-rw-r--r--source4/lib/ldb/modules/paged_results.c493
-rw-r--r--source4/lib/ldb/modules/paged_searches.c359
-rw-r--r--source4/lib/ldb/modules/rdn_name.c300
-rw-r--r--source4/lib/ldb/modules/sort.c369
-rw-r--r--source4/lib/ldb/nssldb/ldb-grp.c20
-rw-r--r--source4/lib/ldb/nssldb/ldb-pwd.c15
-rwxr-xr-xsource4/lib/ldb/tests/python/api.py38
-rwxr-xr-xsource4/lib/ldb/tests/python/ldap.py14
-rw-r--r--source4/lib/ldb/tools/ldbdel.c2
-rw-r--r--source4/lib/ldb/tools/ldbedit.c2
-rw-r--r--source4/lib/ldb/tools/ldbsearch.c76
-rw-r--r--source4/lib/ldb/tools/ldbtest.c4
-rw-r--r--source4/lib/ldb_wrap.c13
-rw-r--r--source4/lib/messaging/messaging.c9
-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/registry/dir.c2
-rw-r--r--source4/lib/registry/interface.c2
-rw-r--r--source4/lib/registry/ldb.c19
-rw-r--r--source4/lib/registry/local.c2
-rw-r--r--source4/lib/registry/patchfile.c146
-rw-r--r--source4/lib/registry/regf.c2
-rw-r--r--source4/lib/registry/registry.h16
-rw-r--r--source4/lib/registry/registry.i2
-rw-r--r--source4/lib/registry/rpc.c268
-rw-r--r--source4/lib/registry/tests/generic.c6
-rw-r--r--source4/lib/registry/tools/regdiff.c2
-rw-r--r--source4/lib/registry/tools/regshell.c28
-rw-r--r--source4/lib/registry/tools/regtree.c23
-rw-r--r--source4/lib/registry/util.c3
-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/samba3/config.mk2
-rw-r--r--source4/lib/samba3/samba3.h190
-rw-r--r--source4/lib/smbreadline/smbreadline.c4
-rw-r--r--source4/lib/socket/interface.c2
-rw-r--r--source4/lib/socket/socket.c2
-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/stream/packet.c2
-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/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.c18
-rw-r--r--source4/lib/tls/tls.c3
-rw-r--r--source4/lib/tls/tlscert.c4
-rw-r--r--source4/lib/torture/torture.c15
-rw-r--r--source4/lib/torture/torture.h4
-rw-r--r--source4/lib/util/Doxyfile24
-rw-r--r--source4/lib/util/asn1.c770
-rw-r--r--source4/lib/util/asn1.h54
-rw-r--r--source4/lib/util/attr.h90
-rw-r--r--source4/lib/util/become_daemon.c93
-rw-r--r--source4/lib/util/byteorder.h231
-rw-r--r--source4/lib/util/capability.c103
-rw-r--r--source4/lib/util/capability.m417
-rw-r--r--source4/lib/util/config.mk71
-rw-r--r--source4/lib/util/data_blob.c232
-rw-r--r--source4/lib/util/data_blob.h123
-rw-r--r--source4/lib/util/debug.c239
-rw-r--r--source4/lib/util/debug.h128
-rw-r--r--source4/lib/util/dlinklist.h113
-rw-r--r--source4/lib/util/dprintf.c111
-rw-r--r--source4/lib/util/fault.c226
-rw-r--r--source4/lib/util/fault.m45
-rw-r--r--source4/lib/util/fsusage.c154
-rw-r--r--source4/lib/util/fsusage.m4190
-rw-r--r--source4/lib/util/genrand.c361
-rw-r--r--source4/lib/util/idtree.c391
-rw-r--r--source4/lib/util/mainpage.dox11
-rw-r--r--source4/lib/util/ms_fnmatch.c223
-rw-r--r--source4/lib/util/mutex.c56
-rw-r--r--source4/lib/util/mutex.h75
-rw-r--r--source4/lib/util/params.c587
-rw-r--r--source4/lib/util/safe_string.h44
-rw-r--r--source4/lib/util/signal.c144
-rw-r--r--source4/lib/util/signal.m41
-rw-r--r--source4/lib/util/system.c90
-rw-r--r--source4/lib/util/tests/file.c97
-rw-r--r--source4/lib/util/tests/genrand.c65
-rw-r--r--source4/lib/util/tests/idtree.c121
-rw-r--r--source4/lib/util/tests/str.c121
-rw-r--r--source4/lib/util/tests/strlist.c103
-rw-r--r--source4/lib/util/time.c622
-rw-r--r--source4/lib/util/time.h232
-rw-r--r--source4/lib/util/time.m49
-rw-r--r--source4/lib/util/unix_privs.c77
-rw-r--r--source4/lib/util/util.c599
-rw-r--r--source4/lib/util/util.h813
-rw-r--r--source4/lib/util/util.m41
-rw-r--r--source4/lib/util/util_file.c404
-rw-r--r--source4/lib/util/util_getent.c283
-rw-r--r--source4/lib/util/util_ldb.c133
-rw-r--r--source4/lib/util/util_ldb.h27
-rw-r--r--source4/lib/util/util_pw.c77
-rw-r--r--source4/lib/util/util_str.c790
-rw-r--r--source4/lib/util/util_strlist.c308
-rw-r--r--source4/lib/util/util_tdb.c546
-rw-r--r--source4/lib/util/wrap_xattr.c120
-rw-r--r--source4/lib/util/wrap_xattr.h12
-rw-r--r--source4/lib/util/xattr.m432
-rw-r--r--source4/lib/util/xfile.c389
-rw-r--r--source4/lib/util/xfile.h99
-rw-r--r--source4/lib/wmi/config.mk69
-rw-r--r--source4/lib/wmi/tools/wmic.c221
-rw-r--r--source4/lib/wmi/tools/wmis.c221
-rw-r--r--source4/lib/wmi/wbemdata.c451
-rw-r--r--source4/lib/wmi/wmi.h48
-rw-r--r--source4/lib/wmi/wmi.i352
-rw-r--r--source4/lib/wmi/wmi.py95
-rw-r--r--source4/lib/wmi/wmi_wrap.c (renamed from source4/lib/tdb/tdb_wrap.c)1539
-rw-r--r--source4/lib/wmi/wmicore.c252
-rw-r--r--source4/lib/zlib.m427
-rw-r--r--source4/lib/zlib/ChangeLog855
-rw-r--r--source4/lib/zlib/FAQ339
-rw-r--r--source4/lib/zlib/INDEX51
-rw-r--r--source4/lib/zlib/Makefile154
-rw-r--r--source4/lib/zlib/Makefile.in154
-rw-r--r--source4/lib/zlib/README125
-rw-r--r--source4/lib/zlib/adler32.c148
-rw-r--r--source4/lib/zlib/algorithm.txt209
-rw-r--r--source4/lib/zlib/amiga/Makefile.pup66
-rw-r--r--source4/lib/zlib/amiga/Makefile.sas65
-rw-r--r--source4/lib/zlib/as400/bndsrc132
-rw-r--r--source4/lib/zlib/as400/compile.clp123
-rw-r--r--source4/lib/zlib/as400/readme.txt111
-rw-r--r--source4/lib/zlib/as400/zlib.inc331
-rw-r--r--source4/lib/zlib/compress.c78
-rw-r--r--source4/lib/zlib/contrib/README.contrib71
-rw-r--r--source4/lib/zlib/contrib/ada/buffer_demo.adb106
-rw-r--r--source4/lib/zlib/contrib/ada/mtest.adb156
-rw-r--r--source4/lib/zlib/contrib/ada/read.adb156
-rw-r--r--source4/lib/zlib/contrib/ada/readme.txt65
-rw-r--r--source4/lib/zlib/contrib/ada/test.adb463
-rw-r--r--source4/lib/zlib/contrib/ada/zlib-streams.adb225
-rw-r--r--source4/lib/zlib/contrib/ada/zlib-streams.ads114
-rw-r--r--source4/lib/zlib/contrib/ada/zlib-thin.adb141
-rw-r--r--source4/lib/zlib/contrib/ada/zlib-thin.ads450
-rw-r--r--source4/lib/zlib/contrib/ada/zlib.adb701
-rw-r--r--source4/lib/zlib/contrib/ada/zlib.ads328
-rw-r--r--source4/lib/zlib/contrib/ada/zlib.gpr20
-rw-r--r--source4/lib/zlib/contrib/asm586/README.58643
-rw-r--r--source4/lib/zlib/contrib/asm586/match.S364
-rw-r--r--source4/lib/zlib/contrib/asm686/README.68634
-rw-r--r--source4/lib/zlib/contrib/asm686/match.S329
-rw-r--r--source4/lib/zlib/contrib/blast/Makefile8
-rw-r--r--source4/lib/zlib/contrib/blast/README4
-rw-r--r--source4/lib/zlib/contrib/blast/blast.c444
-rw-r--r--source4/lib/zlib/contrib/blast/blast.h71
-rw-r--r--source4/lib/zlib/contrib/blast/test.pkbin8 -> 0 bytes
-rw-r--r--source4/lib/zlib/contrib/blast/test.txt1
-rw-r--r--source4/lib/zlib/contrib/delphi/ZLib.pas557
-rw-r--r--source4/lib/zlib/contrib/delphi/ZLibConst.pas11
-rw-r--r--source4/lib/zlib/contrib/delphi/readme.txt76
-rw-r--r--source4/lib/zlib/contrib/delphi/zlibd32.mak93
-rw-r--r--source4/lib/zlib/contrib/dotzlib/DotZLib.build33
-rw-r--r--source4/lib/zlib/contrib/dotzlib/DotZLib.chmbin72728 -> 0 bytes
-rw-r--r--source4/lib/zlib/contrib/dotzlib/DotZLib.sln21
-rw-r--r--source4/lib/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs58
-rw-r--r--source4/lib/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs202
-rw-r--r--source4/lib/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs83
-rw-r--r--source4/lib/zlib/contrib/dotzlib/DotZLib/CodecBase.cs198
-rw-r--r--source4/lib/zlib/contrib/dotzlib/DotZLib/Deflater.cs106
-rw-r--r--source4/lib/zlib/contrib/dotzlib/DotZLib/DotZLib.cs288
-rw-r--r--source4/lib/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj141
-rw-r--r--source4/lib/zlib/contrib/dotzlib/DotZLib/GZipStream.cs301
-rw-r--r--source4/lib/zlib/contrib/dotzlib/DotZLib/Inflater.cs105
-rw-r--r--source4/lib/zlib/contrib/dotzlib/DotZLib/UnitTests.cs274
-rw-r--r--source4/lib/zlib/contrib/dotzlib/LICENSE_1_0.txt23
-rw-r--r--source4/lib/zlib/contrib/dotzlib/readme.txt58
-rw-r--r--source4/lib/zlib/contrib/infback9/README1
-rw-r--r--source4/lib/zlib/contrib/infback9/infback9.c608
-rw-r--r--source4/lib/zlib/contrib/infback9/infback9.h37
-rw-r--r--source4/lib/zlib/contrib/infback9/inffix9.h107
-rw-r--r--source4/lib/zlib/contrib/infback9/inflate9.h47
-rw-r--r--source4/lib/zlib/contrib/infback9/inftree9.c323
-rw-r--r--source4/lib/zlib/contrib/infback9/inftree9.h55
-rw-r--r--source4/lib/zlib/contrib/inflate86/inffas86.c1157
-rw-r--r--source4/lib/zlib/contrib/inflate86/inffast.S1368
-rw-r--r--source4/lib/zlib/contrib/iostream/test.cpp24
-rw-r--r--source4/lib/zlib/contrib/iostream/zfstream.cpp329
-rw-r--r--source4/lib/zlib/contrib/iostream/zfstream.h128
-rw-r--r--source4/lib/zlib/contrib/iostream2/zstream.h307
-rw-r--r--source4/lib/zlib/contrib/iostream2/zstream_test.cpp25
-rw-r--r--source4/lib/zlib/contrib/iostream3/README35
-rw-r--r--source4/lib/zlib/contrib/iostream3/TODO17
-rw-r--r--source4/lib/zlib/contrib/iostream3/test.cc50
-rw-r--r--source4/lib/zlib/contrib/iostream3/zfstream.cc479
-rw-r--r--source4/lib/zlib/contrib/iostream3/zfstream.h466
-rw-r--r--source4/lib/zlib/contrib/masm686/match.asm413
-rw-r--r--source4/lib/zlib/contrib/masmx64/bld_ml64.bat2
-rw-r--r--source4/lib/zlib/contrib/masmx64/gvmat64.asm513
-rw-r--r--source4/lib/zlib/contrib/masmx64/gvmat64.objbin4119 -> 0 bytes
-rw-r--r--source4/lib/zlib/contrib/masmx64/inffas8664.c186
-rw-r--r--source4/lib/zlib/contrib/masmx64/inffasx64.asm392
-rw-r--r--source4/lib/zlib/contrib/masmx64/inffasx64.objbin5913 -> 0 bytes
-rw-r--r--source4/lib/zlib/contrib/masmx64/readme.txt28
-rw-r--r--source4/lib/zlib/contrib/masmx86/bld_ml32.bat2
-rw-r--r--source4/lib/zlib/contrib/masmx86/gvmat32.asm972
-rw-r--r--source4/lib/zlib/contrib/masmx86/gvmat32.objbin10241 -> 0 bytes
-rw-r--r--source4/lib/zlib/contrib/masmx86/gvmat32c.c62
-rw-r--r--source4/lib/zlib/contrib/masmx86/inffas32.asm1083
-rw-r--r--source4/lib/zlib/contrib/masmx86/inffas32.objbin14893 -> 0 bytes
-rwxr-xr-xsource4/lib/zlib/contrib/masmx86/mkasm.bat3
-rw-r--r--source4/lib/zlib/contrib/masmx86/readme.txt21
-rw-r--r--source4/lib/zlib/contrib/minizip/ChangeLogUnzip67
-rw-r--r--source4/lib/zlib/contrib/minizip/Makefile25
-rw-r--r--source4/lib/zlib/contrib/minizip/crypt.h132
-rw-r--r--source4/lib/zlib/contrib/minizip/ioapi.c177
-rw-r--r--source4/lib/zlib/contrib/minizip/ioapi.h75
-rw-r--r--source4/lib/zlib/contrib/minizip/iowin32.c270
-rw-r--r--source4/lib/zlib/contrib/minizip/iowin32.h21
-rw-r--r--source4/lib/zlib/contrib/minizip/miniunz.c585
-rw-r--r--source4/lib/zlib/contrib/minizip/minizip.c420
-rw-r--r--source4/lib/zlib/contrib/minizip/mztools.c281
-rw-r--r--source4/lib/zlib/contrib/minizip/mztools.h31
-rw-r--r--source4/lib/zlib/contrib/minizip/unzip.c1598
-rw-r--r--source4/lib/zlib/contrib/minizip/unzip.h354
-rw-r--r--source4/lib/zlib/contrib/minizip/zip.c1219
-rw-r--r--source4/lib/zlib/contrib/minizip/zip.h235
-rw-r--r--source4/lib/zlib/contrib/pascal/example.pas599
-rw-r--r--source4/lib/zlib/contrib/pascal/readme.txt76
-rw-r--r--source4/lib/zlib/contrib/pascal/zlibd32.mak93
-rw-r--r--source4/lib/zlib/contrib/pascal/zlibpas.pas236
-rw-r--r--source4/lib/zlib/contrib/puff/Makefile8
-rw-r--r--source4/lib/zlib/contrib/puff/README63
-rw-r--r--source4/lib/zlib/contrib/puff/puff.c837
-rw-r--r--source4/lib/zlib/contrib/puff/puff.h31
-rw-r--r--source4/lib/zlib/contrib/puff/zeros.rawbin1213 -> 0 bytes
-rw-r--r--source4/lib/zlib/contrib/testzlib/testzlib.c275
-rw-r--r--source4/lib/zlib/contrib/testzlib/testzlib.txt10
-rw-r--r--source4/lib/zlib/contrib/untgz/Makefile14
-rw-r--r--source4/lib/zlib/contrib/untgz/Makefile.msc17
-rw-r--r--source4/lib/zlib/contrib/untgz/untgz.c674
-rw-r--r--source4/lib/zlib/contrib/vstudio/readme.txt73
-rw-r--r--source4/lib/zlib/contrib/vstudio/vc7/miniunz.vcproj126
-rw-r--r--source4/lib/zlib/contrib/vstudio/vc7/minizip.vcproj126
-rw-r--r--source4/lib/zlib/contrib/vstudio/vc7/testzlib.vcproj126
-rw-r--r--source4/lib/zlib/contrib/vstudio/vc7/zlib.rc32
-rw-r--r--source4/lib/zlib/contrib/vstudio/vc7/zlibstat.vcproj246
-rw-r--r--source4/lib/zlib/contrib/vstudio/vc7/zlibvc.def92
-rw-r--r--source4/lib/zlib/contrib/vstudio/vc7/zlibvc.sln78
-rw-r--r--source4/lib/zlib/contrib/vstudio/vc7/zlibvc.vcproj445
-rw-r--r--source4/lib/zlib/contrib/vstudio/vc8/miniunz.vcproj566
-rw-r--r--source4/lib/zlib/contrib/vstudio/vc8/minizip.vcproj563
-rw-r--r--source4/lib/zlib/contrib/vstudio/vc8/testzlib.vcproj948
-rw-r--r--source4/lib/zlib/contrib/vstudio/vc8/testzlibdll.vcproj567
-rw-r--r--source4/lib/zlib/contrib/vstudio/vc8/zlib.rc32
-rw-r--r--source4/lib/zlib/contrib/vstudio/vc8/zlibstat.vcproj870
-rw-r--r--source4/lib/zlib/contrib/vstudio/vc8/zlibvc.def92
-rw-r--r--source4/lib/zlib/contrib/vstudio/vc8/zlibvc.sln144
-rw-r--r--source4/lib/zlib/contrib/vstudio/vc8/zlibvc.vcproj1219
-rw-r--r--source4/lib/zlib/crc32.c423
-rw-r--r--source4/lib/zlib/crc32.h441
-rw-r--r--source4/lib/zlib/deflate.c1736
-rw-r--r--source4/lib/zlib/deflate.h331
-rw-r--r--source4/lib/zlib/example.c565
-rw-r--r--source4/lib/zlib/examples/README.examples42
-rw-r--r--source4/lib/zlib/examples/fitblk.c233
-rw-r--r--source4/lib/zlib/examples/gun.c693
-rw-r--r--source4/lib/zlib/examples/gzappend.c500
-rw-r--r--source4/lib/zlib/examples/gzjoin.c448
-rw-r--r--source4/lib/zlib/examples/gzlog.c413
-rw-r--r--source4/lib/zlib/examples/gzlog.h58
-rw-r--r--source4/lib/zlib/examples/zlib_how.html523
-rw-r--r--source4/lib/zlib/examples/zpipe.c191
-rw-r--r--source4/lib/zlib/examples/zran.c404
-rw-r--r--source4/lib/zlib/gzio.c1024
-rw-r--r--source4/lib/zlib/infback.c623
-rw-r--r--source4/lib/zlib/inffast.c318
-rw-r--r--source4/lib/zlib/inffast.h11
-rw-r--r--source4/lib/zlib/inffixed.h94
-rw-r--r--source4/lib/zlib/inflate.c1368
-rw-r--r--source4/lib/zlib/inflate.h115
-rw-r--r--source4/lib/zlib/inftrees.c329
-rw-r--r--source4/lib/zlib/inftrees.h55
-rw-r--r--source4/lib/zlib/make_vms.com461
-rw-r--r--source4/lib/zlib/minigzip.c322
-rw-r--r--source4/lib/zlib/msdos/Makefile.bor109
-rw-r--r--source4/lib/zlib/msdos/Makefile.dj2104
-rw-r--r--source4/lib/zlib/msdos/Makefile.emx69
-rw-r--r--source4/lib/zlib/msdos/Makefile.msc106
-rw-r--r--source4/lib/zlib/msdos/Makefile.tc94
-rw-r--r--source4/lib/zlib/old/Makefile.riscos151
-rw-r--r--source4/lib/zlib/old/README3
-rw-r--r--source4/lib/zlib/old/descrip.mms48
-rw-r--r--source4/lib/zlib/old/os2/Makefile.os2136
-rw-r--r--source4/lib/zlib/old/os2/zlib.def51
-rw-r--r--source4/lib/zlib/old/visual-basic.txt160
-rw-r--r--source4/lib/zlib/old/zlib.html971
-rw-r--r--source4/lib/zlib/projects/README.projects41
-rw-r--r--source4/lib/zlib/projects/visualc6/README.txt73
-rw-r--r--source4/lib/zlib/projects/visualc6/example.dsp278
-rw-r--r--source4/lib/zlib/projects/visualc6/minigzip.dsp278
-rw-r--r--source4/lib/zlib/projects/visualc6/zlib.dsp609
-rw-r--r--source4/lib/zlib/projects/visualc6/zlib.dsw59
-rw-r--r--source4/lib/zlib/qnx/package.qpg141
-rw-r--r--source4/lib/zlib/trees.c1219
-rw-r--r--source4/lib/zlib/trees.h128
-rw-r--r--source4/lib/zlib/uncompr.c60
-rw-r--r--source4/lib/zlib/win32/DLL_FAQ.txt397
-rw-r--r--source4/lib/zlib/win32/Makefile.bor107
-rw-r--r--source4/lib/zlib/win32/Makefile.emx69
-rw-r--r--source4/lib/zlib/win32/Makefile.gcc141
-rw-r--r--source4/lib/zlib/win32/Makefile.msc126
-rw-r--r--source4/lib/zlib/win32/VisualC.txt3
-rw-r--r--source4/lib/zlib/win32/zlib.def60
-rw-r--r--source4/lib/zlib/win32/zlib1.rc39
-rw-r--r--source4/lib/zlib/zconf.h335
-rw-r--r--source4/lib/zlib/zconf.in.h332
-rw-r--r--source4/lib/zlib/zlib.h1374
-rw-r--r--source4/lib/zlib/zutil.c318
-rw-r--r--source4/lib/zlib/zutil.h269
684 files changed, 9132 insertions, 202129 deletions
diff --git a/source4/lib/appweb/README b/source4/lib/appweb/README
deleted file mode 100644
index bdc943446b..0000000000
--- a/source4/lib/appweb/README
+++ /dev/null
@@ -1,6 +0,0 @@
-The lib/appweb directory is a partial import of the appweb ejs and esp
-code from http://www.appwebserver.org/
-
-Many thanks to the mbedthis people, and especially Michael O'Brien for
-his assistance in getting this code integrated into Samba4.
-
diff --git a/source4/lib/appweb/config.m4 b/source4/lib/appweb/config.m4
deleted file mode 100644
index 69b4048c4a..0000000000
--- a/source4/lib/appweb/config.m4
+++ /dev/null
@@ -1 +0,0 @@
-AC_CHECK_HEADERS(math.h)
diff --git a/source4/lib/appweb/config.mk b/source4/lib/appweb/config.mk
deleted file mode 100644
index 4d27b69fb5..0000000000
--- a/source4/lib/appweb/config.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-#######################
-# Start SUBSYSTEM MPR
-[SUBSYSTEM::MPR]
-# End SUBSYSTEM MPR
-#######################
-
-MPR_OBJ_FILES = $(addprefix $(appwebsrcdir)/mpr/, miniMpr.o var.o)
-
-#######################
-# Start SUBSYSTEM EJS
-[SUBSYSTEM::EJS]
-PUBLIC_DEPENDENCIES = MPR
-# End SUBSYSTEM EJS
-#######################
-
-EJS_OBJ_FILES = $(addprefix $(appwebsrcdir)/ejs/, ejsLib.o ejsLex.o ejsParser.o ejsProcs.o)
-
-#######################
-# Start SUBSYSTEM ESP
-[SUBSYSTEM::ESP]
-PUBLIC_DEPENDENCIES = EJS
-# End SUBSYSTEM ESP
-#######################
-
-ESP_OBJ_FILES = $(addprefix $(appwebsrcdir)/esp/, esp.o espProcs.o)
diff --git a/source4/lib/appweb/ejs-2.0/.bashrc b/source4/lib/appweb/ejs-2.0/.bashrc
deleted file mode 100644
index c05ee0e6e8..0000000000
--- a/source4/lib/appweb/ejs-2.0/.bashrc
+++ /dev/null
@@ -1,153 +0,0 @@
-#
-# .bashrc -- Login shell startup script for windows using Mbedthis winTools
-#
-# Copyright (c) Mbedthis Software, 2003-2005. All Rights Reserved.
-#
-
-TERM=ansi
-#
-# Set the desired .NET Framework
-#
-# FRAMEWORK=v1.0.3705
-FRAMEWORK=v1.1.4322
-# FRAMEWORK=v2.0.40607
-
-#
-# Set the desired Microsoft C Compiler version
-#
-# PREFERRED_CC=VS2005
-# PREFERRED_CC=VS2003
-# PREFERRED_CC=VS.NET
-PREFERRED_CC=VS6
-
-#
-# Set to 1 if VXWORKS support is required
-#
-# VXWORKS=1
-
-HOME=`pwd`
-if [ ! -x winTools -o ! -x winTools/cygpath.exe ]
-then
- echo "Can't find build tools. Install build tools in $HOME/winTools"
-fi
-
-ROOT=`winTools/cygpath -u $HOMEDRIVE`
-: ${ROOT:=C:/}
-APPWEB_PATH="${HOME}/bin/DEBUG:${HOME}/bin/RELEASE:${HOME}/bin:${HOME}/winTools"
-CDPATH=".:${HOME}:${HOME}/http:${HOME}/http/modules:${HOME}/packages"
-PS1="$ "
-
-export CDPATH INCLUDE LIB LIBPATH PATH PS1 TERM
-
-echo -e "\n\n###################################################"
-echo "Mbedthis AppWeb, Cygwin build tools."
-echo "Using compiler: $PREFERRED_CC, .NET framework: $FRAMEWORK"
-echo -e "###################################################"
-
-################################################################################
-
-#
-# Setup for Visual Studio and SDK
-#
-if [ $PREFERRED_CC == "VS2005" ]
-then
- #
- # Visual Studio .NET 2005 defines.
- #
- CYNET="${ROOT}/Program Files/Microsoft Visual Studio 8"
- DOSNET="C:/Program Files/Microsoft Visual Studio 8"
- PATH="$APPWEB_PATH:$CYNET/Common7/IDE:$CYNET/VC/BIN:$CYNET/VC/VCPackages:$CYNET/Common7/Tools:$CYNET/Common7/Tools/bin:$CYNET/SDK/v2.0/bin:`cygpath -W`/Microsoft.NET/Framework/v2.0.40607:$CYNET/SDK/v2.0/bin:$PATH"
- INCLUDE="$DOSNET/VC/ATLMFC/INCLUDE;$DOSNET/VC/INCLUDE;$DOSNET/VC/PlatformSDK/include;$DOSNET/SDK/v2.0/include;$INCLUDE"
- LIB="$DOSNET/VC/ATLMFC/LIB;$DOSNET/VC/LIB;$DOSNET/VC/PlatformSDK/lib;$DOSNET/SDK/v2.0/lib;$LIB"
- LIBPATH=c:/WINDOWS/Microsoft.NET/Framework/$FRAMEWORK
-fi
-
-if [ $PREFERRED_CC == "VS2003" ]
-then
- #
- # Visual Studio .NET 2003 defines.
- #
- CYNET="${ROOT}/Program Files/Microsoft Visual Studio .NET 2003"
- DOSNET="C:/Program Files/Microsoft Visual Studio .NET 2003"
- PATH="$APPWEB_PATH:$CYNET/Common7/IDE:$CYNET/VC7/BIN:$CYNET/Common7/Tools:$CYNET/Common7/Tools/bin/prerelease:$CYNET/Common7/Tools/bin:$CYNET/FrameworkSDK/bin:${ROOT}/WINDOWS/Microsoft.NET/Framework/$FRAMEWORK:$CYNET/SDK/v1.1/bin:$PATH"
- INCLUDE="$DOSNET/VC7/ATLMFC/INCLUDE;$DOSNET/VC7/INCLUDE;$DOSNET/VC7/PlatformSDK/include/prerelease;$DOSNET/VC7/PlatformSDK/include;$DOSNET/FrameworkSDK/include;$INCLUDE"
- LIB="$DOSNET/VC7/ATLMFC/LIB;$DOSNET/VC7/LIB;$DOSNET/VC7/PlatformSDK/lib/prerelease;$DOSNET/VC7/PlatformSDK/lib;$DOSNET/FrameworkSDK/lib;$LIB"
-fi
-
-
-if [ $PREFERRED_CC == "VS.NET" ]
-then
- #
- # Visual Studio .NET defines.
- #
- CYNET="${ROOT}/Program Files/Microsoft Visual Studio .NET"
- DOSNET="C:/Program Files/Microsoft Visual Studio .NET"
- PATH="$APPWEB_PATH:$CYNET/Common7/IDE:$CYNET/VC7/BIN:$CYNET/Common7/Tools:$CYNET/Common7/Tools/bin/prerelease:$CYNET/Common7/Tools/bin:$CYNET/FrameworkSDK/bin:${ROOT}/WINDOWS/Microsoft.NET/Framework/$FRAMEWORK:$CYNET/SDK/v1.0/bin:$PATH"
- INCLUDE="$DOSNET/VC7/ATLMFC/INCLUDE;$DOSNET/VC7/INCLUDE;$DOSNET/VC7/PlatformSDK/include/prerelease;$DOSNET/VC7/PlatformSDK/include;$DOSNET/FrameworkSDK/include;$INCLUDE"
- LIB="$DOSNET/VC7/ATLMFC/LIB;$DOSNET/VC7/LIB;$DOSNET/VC7/PlatformSDK/lib/prerelease;$DOSNET/VC7/PlatformSDK/lib;$DOSNET/FrameworkSDK/lib;$LIB"
-fi
-
-
-if [ $PREFERRED_CC == "VS6" ]
-then
- # Visual Studio 6 defines.
- #
- CYNET="${ROOT}/Program Files/Microsoft Visual Studio"
- DOSNET="C:/Program Files/Microsoft Visual Studio"
- PATH="$APPWEB_PATH:$CYNET/Common/MSDev98/bin:$CYNET/VC98/BIN:$CYNET/Common/IDE:$CYNET/Common/Tools/WinNT:$CYNET/Common/Tools:$PATH"
- INCLUDE="$DOSNET/VC98/ATLMFC/INCLUDE;$DOSNET/VC98/INCLUDE;$DOSNET/VC98/MFC/INCLUDE;$INCLUDE"
- LIB="$DOSNET/VC98/LIB;$DOSNET/VC98/MFC/LIB;$LIB"
-fi
-
-if [ $VXWORKS ]
-then
- #
- # Required by VxWorks
- #
- WIND_BASE=C:/tornado
- WIND_HOST_TYPE=x86-win32
- WIND_REGISTRY=coalsack
- WIND_LMHOST=coalsack
- BLD_VX_HOST=i386-wrs-vxworks
- VX_TOOLS=`cygpath $WIND_BASE`/host/$WIND_HOST_TYPE
- export WIND_BASE WIND_HOST_TYPE WIND_REGISTRY WIND_LMHOST BLD_VX_HOST
-
- #
- # Use cygwin make and tools by preference
- #
- PATH="$APPWEB_PATH:$VX_TOOLS/bin:$PATH"
-fi
-
-#
-# Make required directories for CYGWIN
-#
-if [ ! -x /bin/bash.exe ]
-then
- DIR=`cygpath -w "$HOME/winTools"`
- echo -e "\nCreating /bin"
- echo Mounting \"${DIR}\" as /bin
- mount -f -b "$DIR" /bin
-fi
-
-if [ ! -x /tmp ]
-then
- mkdir -p tmp
- DIR=`cygpath -w "$HOME/tmp"`
- echo -e "\nCreating /tmp"
- echo Mounting \"${DIR}\" as /tmp
- mount -f -b "$DIR" /tmp
-fi
-echo
-
-################################################################################
-#
-# Do a bit of validation
-#
-type cl 2>/dev/null >/dev/null
-if [ $? -ne 0 ]
-then
- echo "Can't find compiler: cl. Check WIN/bashrc settings for PATH"
-fi
-set -o vi
-
-################################################################################
diff --git a/source4/lib/appweb/ejs-2.0/.exrc b/source4/lib/appweb/ejs-2.0/.exrc
deleted file mode 100644
index dd37846529..0000000000
--- a/source4/lib/appweb/ejs-2.0/.exrc
+++ /dev/null
@@ -1 +0,0 @@
-set ts=4 sw=4
diff --git a/source4/lib/appweb/ejs-2.0/.ignore b/source4/lib/appweb/ejs-2.0/.ignore
deleted file mode 100644
index 866f06c6c1..0000000000
--- a/source4/lib/appweb/ejs-2.0/.ignore
+++ /dev/null
@@ -1,57 +0,0 @@
-*.class
-*.dll
-*.exe
-*.exp
-*.jar
-*.lib
-*.lnk
-*.map
-*.new
-*.old
-*.pdb
-*.res
-*.sln
-*.suo
-*.sym
-*.tmp
-*.sav
-.ICEauthority
-.bash_history
-.changes
-.cvsignore
-.esd_auth
-.fonts.cache-1
-.viminfo
-make.dep
-thumbs.db
-vc70.pdb
-*.ncb
-*.opt
-*.idb
-*.pch
-*.dep
-*.aps
-all
-tmp
-make.vars
-sh.vars
-config.make
-config.h
-config.sh
-configure
-make.os
-.firstBuild
-.viminfo
-.ssh
-_viminfo
-buildConfig.h
-buildConfig.make
-buildConfig.sh
-.ccache
-appWeb.kdev*
-subversion
-.vimrc
-.subversion
-.ignore
-njs
-msvc
diff --git a/source4/lib/appweb/ejs-2.0/.loginrc b/source4/lib/appweb/ejs-2.0/.loginrc
deleted file mode 100644
index 90b76a2ad0..0000000000
--- a/source4/lib/appweb/ejs-2.0/.loginrc
+++ /dev/null
@@ -1,218 +0,0 @@
-#
-# .loginrc -- Michael's login shell startup script (used only for Windows)
-#
-# NOTE: this should not be distributed with releases.
-#
-# Copyright (c) Mbedthis Software, 2003-2005. All Rights Reserved.
-#
-HOME=`pwd`
-
-TERM=ansi
-CYROOT=/cygdrive/c
-JDK="/cygdrive/c/program files/java/jdk1.5.0_07/bin"
-H=$CYROOT
-R=usr/svn/appWeb/main
-CDPATH=".:${H}/usr/svn/appWeb:${H}/${R}/http:${H}/${R}/http/modules:${H}/${R}:${H}/usr/svn/appWeb/releases:${H}/usr/svn/packages:${H}/usr/svn/bling/player/trunk:${H}/usr/svn/bling/player/trunk/src:${H}/usr/svn/bling/player/trunk/appdir:${H}/usr/svn:${H}:${H}/usr/svn:${H}/usr"
-APPWEB_PATH="${H}/${R}/bin/DEBUG:${H}/${R}/bin/RELEASE:${H}/${R}/bin:${H}/usr/bin"
-PATH="${H}/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:$PATH:${H}/tcl/bin:${JDK}"
-
-CLASSPATH="c:/usr/svn/j/ggperf"
-PS1='`cygpath -m $PWD`> '
-SVN_EDITOR=C:/cygwin/bin/vim.exe
-
-umask 022
-
-export TERM CDPATH INCLUDE LIB LIBPATH PATH PS1 SVN_EDITOR MSCL CLASSPATH
-
-################################################################################
-#
-# Set the dev environment PATH and other critical environment variables
-#
-
-# export BLD_ALTERNATE_CONFIG=WIN/buildConfig
-
-#
-# Desired .NET Framework
-#
-# FRAMEWORK=v1.0.3705
-# FRAMEWORK=v1.1.4322
-FRAMEWORK=v2.0.50727
-
-#
-# Desired C Compiler
-#
-# MSCL=VS2005
-# MSCL=VS2003
-# MSCL=VS.NET
-MSCL=VS6
-VXWORKS=1
-
-echo "Using compiler: $MSCL, .NET framework: $FRAMEWORK"
-
-#
-# Setup for Visual Studio and SDK
-#
-if [ $MSCL == "VS2005" ]
-then
- #
- # Visual Studio .NET 2005 defines.
- #
- CYNET="$H/Program Files/Microsoft Visual Studio 8"
- DOSNET="C:/Program Files/Microsoft Visual Studio 8"
- PATH="$APPWEB_PATH:$CYNET/Common7/IDE:$CYNET/VC/BIN:$CYNET/VC/VCPackages:$CYNET/Common7/Tools:$CYNET/Common7/Tools/bin:$CYNET/SDK/v2.0/bin:$CYROOT/WINDOWS/Microsoft.NET/Framework/v2.0.40607:$CYNET/SDK/v2.0/bin:$PATH"
- INCLUDE="$DOSNET/VC/ATLMFC/INCLUDE;$DOSNET/VC/INCLUDE;$DOSNET/VC/PlatformSDK/include;$DOSNET/SDK/v2.0/include;$INCLUDE"
- LIB="$DOSNET/VC/ATLMFC/LIB;$DOSNET/VC/LIB;$DOSNET/VC/PlatformSDK/lib;$DOSNET/SDK/v2.0/lib;$LIB"
- LIBPATH=c:/WINDOWS/Microsoft.NET/Framework/$FRAMEWORK
-
- # MOB -- old
- # PATH="$APPWEB_PATH:$CYNET/Common7/IDE:$CYNET/VC/BIN:$CYNET/Common7/Tools:$CYNET/Common7/Tools/bin/prerelease:$CYNET/Common7/Tools/bin:$CYNET/FrameworkSDK/bin:$H/WINDOWS/Microsoft.NET/Framework/$FRAMEWORK:$PATH"
- # INCLUDE="$DOSNET/VC/ATLMFC/INCLUDE;$DOSNET/VC/INCLUDE;$DOSNET/VC/PlatformSDK/include/prerelease;$DOSNET/VC/PlatformSDK/include;$DOSNET/FrameworkSDK/include;$INCLUDE"
- # LIB="$DOSNET/VC/ATLMFC/LIB;$DOSNET/VC/LIB;$DOSNET/VC/PlatformSDK/lib/prerelease;$DOSNET/VC/PlatformSDK/lib;$DOSNET/FrameworkSDK/lib;$LIB"
-fi
-
-if [ $MSCL == "VS2003" ]
-then
- #
- # Visual Studio .NET 2003 defines.
- #
- CYNET="$H/Program Files/Microsoft Visual Studio .NET 2003"
- DOSNET="C:/Program Files/Microsoft Visual Studio .NET 2003"
- PATH="$APPWEB_PATH:$CYNET/Common7/IDE:$CYNET/VC7/BIN:$CYNET/Common7/Tools:$CYNET/Common7/Tools/bin/prerelease:$CYNET/Common7/Tools/bin:$CYNET/FrameworkSDK/bin:$H/WINDOWS/Microsoft.NET/Framework/$FRAMEWORK:$CYNET/SDK/v1.1/bin:$PATH"
- INCLUDE="$DOSNET/VC7/ATLMFC/INCLUDE;$DOSNET/VC7/INCLUDE;$DOSNET/VC7/PlatformSDK/include/prerelease;$DOSNET/VC7/PlatformSDK/include;$DOSNET/FrameworkSDK/include;$INCLUDE"
- LIB="$DOSNET/VC7/ATLMFC/LIB;$DOSNET/VC7/LIB;$DOSNET/VC7/PlatformSDK/lib/prerelease;$DOSNET/VC7/PlatformSDK/lib;$DOSNET/FrameworkSDK/lib;$LIB"
-fi
-
-
-if [ $MSCL == "VS.NET" ]
-then
- #
- # Visual Studio .NET defines.
- #
- CYNET="$H/Program Files/Microsoft Visual Studio .NET"
- DOSNET="C:/Program Files/Microsoft Visual Studio .NET"
- PATH="$APPWEB_PATH:$CYNET/Common7/IDE:$CYNET/VC7/BIN:$CYNET/Common7/Tools:$CYNET/Common7/Tools/bin/prerelease:$CYNET/Common7/Tools/bin:$CYNET/FrameworkSDK/bin:$H/WINDOWS/Microsoft.NET/Framework/$FRAMEWORK:$CYNET/SDK/v1.0/bin:$PATH"
- INCLUDE="$DOSNET/VC7/ATLMFC/INCLUDE;$DOSNET/VC7/INCLUDE;$DOSNET/VC7/PlatformSDK/include/prerelease;$DOSNET/VC7/PlatformSDK/include;$DOSNET/FrameworkSDK/include;$INCLUDE"
- LIB="$DOSNET/VC7/ATLMFC/LIB;$DOSNET/VC7/LIB;$DOSNET/VC7/PlatformSDK/lib/prerelease;$DOSNET/VC7/PlatformSDK/lib;$DOSNET/FrameworkSDK/lib;$LIB"
-fi
-
-
-if [ $MSCL == "VS6" ]
-then
- # Visual Studio 6 defines.
- #
- CYNET="$H/Program Files/Microsoft Visual Studio"
- DOSNET="C:/Program Files/Microsoft Visual Studio"
- PATH="$APPWEB_PATH:$CYNET/Common/MSDev98/bin:$CYNET/VC98/BIN:$CYNET/Common/IDE:$CYNET/Common/Tools/WinNT:$CYNET/Common/Tools:$PATH"
- # OLD PATH="$APPWEB_PATH:$CYNET/Common/IDE:$CYNET/VC98/BIN:$CYNET/Common/MSDev98/bin:$CYNET/Common/Tools:$CYNET/Common/Tools/bin/prerelease:$CYNET/Common/Tools/bin:$CYNET/FrameworkSDK/bin:$H/WINDOWS/Microsoft.NET/Framework/$FRAMEWORK:$PATH"
- INCLUDE="$DOSNET/VC98/ATLMFC/INCLUDE;$DOSNET/VC98/INCLUDE;$DOSNET/VC98/MFC/INCLUDE;$INCLUDE"
- LIB="$DOSNET/VC98/LIB;$DOSNET/VC98/MFC/LIB;$LIB"
-fi
-
-if [ $VXWORKS ]
-then
- #
- # Required by VxWorks
- #
- WIND_BASE=C:/tornado
- WIND_HOST_TYPE=x86-win32
- WIND_REGISTRY=coalsack
- WIND_LMHOST=coalsack
- BLD_VX_HOST=i386-wrs-vxworks
- export WIND_BASE WIND_HOST_TYPE WIND_REGISTRY WIND_LMHOST BLD_VX_HOST
-
- VX_TOOLS=`cygpath $WIND_BASE`/host/$WIND_HOST_TYPE
- #
- # Use cygwin make and tools by preference
- #
- PATH="$APPWEB_PATH:$PATH:$VX_TOOLS/bin"
-fi
-
-#
-# Make required directories for CYGWIN
-#
-if [ ! -x /bin/bash.exe ]
-then
- DIR=`cygpath -w "$HOME/winTools"`
- echo -e "\nCreating /bin"
- echo Mounting \"${DIR}\" as /bin
- mount -f -b "$DIR" /bin
-fi
-
-if [ ! -x /tmp ]
-then
- mkdir -p tmp
- DIR=`cygpath -w "$HOME/tmp"`
- echo -e "\nCreating /tmp"
- echo Mounting \"${DIR}\" as /tmp
- mount -f -b "$DIR" /tmp
-fi
-echo
-
-
-################################################################################
-#
-# Do a bit of validation (MOB -- extend)
-#
-type cl 2>/dev/null >/dev/null
-if [ $? -ne 0 ]
-then
- echo "Can't find compiler: cl. Check WIN/bashrc settings for PATH"
-fi
-
-################################################################################
-#
-# Some convenient functions
-#
-pvi () {
-
- pattern=$1
- shift
- files=$*
- if [ -z "${files}" ]
- then
- files='*.c *.cpp *.h Makefile *.html *.aspx *.cs'
- fi
- vi -c "/${pattern}" $(grep -l "${pattern}" ${files})
-}
-
-################################################################################
-
-g() {
- pattern=$1
- shift
- files=$*
- if [ -z "${files}" ]
- then
- files=`echo *.c *.cpp *.h Makefile *.html *.aspx *.cs`
- fi
- eval grep "${pattern}" ${files}
-}
-
-################################################################################
-
-usedvi() {
- pvi $1 $HOME/mr/*.c $HOME/mr/*.h $HOME/mr/WIN/*.c $HOME/lib/*/*.c
-}
-
-################################################################################
-
-alias ls='ls -CF $*'
-alias lc='ls -CF $*'
-alias lr='ls -R $*'
-alias xwin='startxwin.sh'
-alias htmlview='"C:/Program Files/Internet Explorer/iexplore.exe" $*'
-set -o vi
-
-if [ `uname -o` = "Cygwin" ]
-then
- alias vim='"C:/Program Files/vim/vim64/vim.exe" $*'
- alias gvim='"C:/Program Files/vim/vim64/gvim.exe" $*'
-fi
-
-brew() {
- "C:/Program Files/BREW SDK v2.1.3/Bin/BREW_Emulator.exe"
-}
-
-js() {
- cscript /nologo $*
-}
diff --git a/source4/lib/appweb/ejs-2.0/ejs/.ignore b/source4/lib/appweb/ejs-2.0/ejs/.ignore
deleted file mode 100644
index 47f4ac63b2..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/.ignore
+++ /dev/null
@@ -1,2 +0,0 @@
-ejs
-future
diff --git a/source4/lib/appweb/ejs-2.0/ejs/Makefile b/source4/lib/appweb/ejs-2.0/ejs/Makefile
deleted file mode 100644
index ea6be8c401..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/Makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-#
-# Makefile for Embedded Javascript (EJS)
-#
-# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
-#
-
-#
-# Ejs may be linked into shared handlers so we must build the objects both
-# shared and static if --shared was specified to configure.
-#
-COMPILE := *.c
-EXPORT_OBJECTS := yes
-PRE_DIRS := classes system db
-MAKE_IFLAGS := -I../mpr -I../exml
-
-include make.dep
-
-ifeq ($(BLD_PRODUCT),ejs)
-POST_DIRS := package
-endif
-
-ifeq ($(BLD_FEATURE_TEST),1)
-POST_DIRS += test
-endif
-
-ifeq ($(BLD_FEATURE_EJS_DB),1)
-LIBS += sqlite
-endif
-
-TARGETS += $(BLD_BIN_DIR)/libejs$(BLD_LIB)
-TARGETS += $(BLD_BIN_DIR)/ejs$(BLD_EXE)
-
-ifeq ($(BLD_FEATURE_EJS),1)
-compileExtra: $(TARGETS)
-endif
-
-$(BLD_BIN_DIR)/libejs$(BLD_LIB): files \
- $(shell BLD_OBJ=$(BLD_OBJ) \; BLD_OBJ_DIR=$(BLD_OBJ_DIR) \; \
- eval echo `cat files`)
- @bld --library $(BLD_BIN_DIR)/libejs \
- --objectsDir $(BLD_OBJ_DIR) --objectList files \
- --libs "exml mpr $(LIBS)"
-
-$(BLD_BIN_DIR)/ejs$(BLD_EXE): $(BLD_BIN_DIR)/libejs$(BLD_LIB) \
- $(BLD_BIN_DIR)/libmpr$(BLD_LIB) \
- $(BLD_BIN_DIR)/libejs$(BLD_LIB) $(FILES)
- @bld --executable $(BLD_BIN_DIR)/ejs$(BLD_EXE) \
- --rpath "$(BLD_PREFIX)/bin" \
- --preferStatic --smartLibs "ejs exml mpr $(LIBS)" \
- --objectsDir $(BLD_OBJ_DIR) \
- --objects "$(BLD_OBJ_DIR)/ejsCmd$(BLD_OBJ)"
-
-cleanExtra:
- @echo "rm -f $(TARGETS)" | $(BLDOUT)
- @rm -f $(TARGETS)
- @rm -f $(BLD_BIN_DIR)/libejs.*
-
-## Local variables:
-## tab-width: 4
-## End:
-## vim: tw=78 sw=4 ts=4
diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/.ignore b/source4/lib/appweb/ejs-2.0/ejs/classes/.ignore
deleted file mode 100644
index fb5a29031e..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/classes/.ignore
+++ /dev/null
@@ -1 +0,0 @@
-.updated
diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/Makefile b/source4/lib/appweb/ejs-2.0/ejs/classes/Makefile
deleted file mode 100644
index ce12bb3829..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/classes/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Makefile to build the EJS Classes
-#
-# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
-#
-
-COMPILE := *.c
-EXPORT_OBJECTS := yes
-MAKE_IFLAGS := -I.. -I../../mpr -I../../exml
-
-include make.dep
-
-compileExtra: .updated
-
-.updated: $(FILES)
- @touch .updated
-
-## Local variables:
-## tab-width: 4
-## End:
-## vim: tw=78 sw=4 ts=4
diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsArray.c b/source4/lib/appweb/ejs-2.0/ejs/classes/ejsArray.c
deleted file mode 100644
index feb64b1aa8..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsArray.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * @file ejsArray.c
- * @brief Array class
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-#if BLD_FEATURE_EJS
-
-/************************************ Code ************************************/
-
-int ejsDefineArrayClass(Ejs *ep)
-{
- if (ejsDefineClass(ep, "Array", "Object", ejsArrayConstructor) == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Routine to create the base array type
- */
-
-EjsVar *ejsCreateArrayInternal(EJS_LOC_DEC(ep, loc), int size)
-{
- EjsProperty *pp;
- EjsVar *obj, *vp;
-
- /* MOB -- need to supply hash size -- max(size, 503)); */
-
- obj = ejsCreateSimpleObjInternal(EJS_LOC_PASS(ep, loc), "Array");
- if (obj == 0) {
- mprAssert(0);
- return obj;
- }
- obj->isArray = 1;
-
- /* MOB -- call constructor here and replace this code */
-
- pp = ejsSetPropertyToInteger(ep, obj, "length", size);
- ejsMakePropertyEnumerable(pp, 0);
-
- vp = ejsGetVarPtr(pp);
- vp->isArrayLength = 1;
-
- return obj;
-}
-
-/******************************************************************************/
-
-EjsVar *ejsAddArrayElt(Ejs *ep, EjsVar *op, EjsVar *element,
- EjsCopyDepth copyDepth)
-{
- EjsProperty *pp;
- EjsVar *vp;
- char idx[16];
- int length;
-
- mprAssert(op->isArray);
-
- length = ejsGetPropertyAsInteger(ep, op, "length");
-
- mprItoa(idx, sizeof(idx), length);
- pp = ejsCreateProperty(ep, op, idx);
- vp = ejsGetVarPtr(pp);
-
- ejsWriteVar(ep, vp, element, copyDepth);
-
- ejsSetPropertyToInteger(ep, op, "length", length + 1);
-
- return vp;
-}
-
-/******************************************************************************/
-/*
- * Constructor
- */
-
-int ejsArrayConstructor(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- EjsProperty *pp;
- EjsVar *vp;
- char idx[16];
- int i, max;
-
- thisObj->isArray = 1;
- max = 0;
-
- if (argc > 0) {
- if (argc == 1 && ejsVarIsNumber(argv[0])) {
- /*
- * x = new Array(size);
- */
- max = (int) ejsVarToInteger(argv[0]);
-
- } else {
- /*
- * x = new Array(element0, element1, ..., elementN):
- */
- max = argc;
- for (i = 0; i < max; i++) {
- mprItoa(idx, sizeof(idx), i);
- pp = ejsCreateSimpleProperty(ep, thisObj, idx);
- vp = ejsGetVarPtr(pp);
- ejsWriteVar(ep, vp, argv[i], EJS_SHALLOW_COPY);
- }
- }
- }
-
- pp = ejsCreateSimpleProperty(ep, thisObj, "length");
- ejsMakePropertyEnumerable(pp, 0);
- vp = ejsGetVarPtr(pp);
- ejsWriteVarAsInteger(ep, vp, max);
- vp->isArrayLength = 1;
-
- return 0;
-}
-
-/******************************************************************************/
-
-#else
-void ejsArrayDummy() {}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_EJS */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsDate.c b/source4/lib/appweb/ejs-2.0/ejs/classes/ejsDate.c
deleted file mode 100755
index 096316a822..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsDate.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * @file ejsStndClasses.c
- * @brief EJS support methods
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-#if BLD_FEATURE_EJS && 0
-
-/******************************************************************************/
-/*
- * Date constructor
-
- *
- * Date();
- * Date(milliseconds);
- * Date(dateString);
- * Date(year, month, date);
- * Date(year, month, date, hour, minute, second);
- */
-
-int ejsDateConstructor(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- return 0;
-}
-
-/******************************************************************************/
-
-static int load(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- const char *fileName;
- XmlState *parser;
- Exml *xp;
- MprFile *file;
-
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsError(ep, EJS_ARG_ERROR, "Bad args. Usage: load(fileName);");
- return -1;
- }
- fileName = argv[0]->string;
-
- /* FUTURE -- not romable
- Need rom code in MPR not MprServices
- */
- file = mprOpen(ep, fileName, O_RDONLY, 0664);
- if (file == 0) {
- ejsError(ep, EJS_IO_ERROR, "Can't open: %s", fileName);
- return -1;
- }
-
- xp = initParser(ep, thisObj, fileName);
- parser = exmlGetParseArg(xp);
-
- exmlSetInputStream(xp, readFileData, (void*) file);
-
- if (exmlParse(xp) < 0) {
- if (! ejsGotException(ep)) {
- ejsError(ep, EJS_IO_ERROR, "Can't parse XML file: %s\nDetails %s",
- fileName, exmlGetErrorMsg(xp));
- }
- termParser(xp);
- mprClose(file);
- return -1;
- }
-
- ejsSetReturnValue(ep, parser->nodeStack[0].obj);
-
- termParser(xp);
- mprClose(file);
-
- return 0;
-}
-
-/******************************************************************************/
-
-int ejsDefineDateClass(Ejs *ep)
-{
- EjsVar *dateClass;
-
- dateClass = ejsDefineClass(ep, "Date", "Object", ejsDateConstructor);
- if (dateClass == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
-
- ejsDefineCMethod(ep, dateClass, "getDate", xxxProc, EJS_NO_LOCAL);
-
- /* Returns "Friday" or 4 ? */
- ejsDefineCMethod(ep, dateClass, "getDay", xxxProc, EJS_NO_LOCAL);
-
- ejsDefineCMethod(ep, dateClass, "getMonth", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "getFullYear", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "getYear", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "getHours", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "getMinutes", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "getSeconds", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "getMilliseconds", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "getTime", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "getTimeZoneOffset", xxxProc, EJS_NO_LOCAL);
-
- ejsDefineCMethod(ep, dateClass, "parse", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "setDate", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "setMonth", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "setFullYear", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "setYear", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "setMinutes", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "setSeconds", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "setMilliseconds", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "setTime", xxxProc, EJS_NO_LOCAL);
-
- ejsDefineCMethod(ep, dateClass, "toString", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "toGMTString", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "toUTCString", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "toLocaleString", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "UTC", xxxProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, dateClass, "valueOf", xxxProc, EJS_NO_LOCAL);
- /*
- UTC: getUTCDate, getUTCDay, getUTCMonth, getUTCFullYear, getUTCHours,
- getUTCMinutes, getUTCSeconds, getUTCMilliseconds
- setUTCDate, setUTCDay, setUTCMonth, setUTCFullYear, setUTCHours,
- setUTCMinutes, setUTCSeconds, setUTCMilliseconds
- */
-
- return ejsObjHasErrors(dateClass) ? MPR_ERR_CANT_INITIALIZE : 0;
-}
-
-/******************************************************************************/
-/*
- Time is since 1970/01/01 GMT
-
- Normal: Fri Feb 10 2006 05:06:44 GMT-0800 (Pacific Standard Time)
- UTC: Sat, 11 Feb 2006 05:06:44 GMT
-
- // Using without New
-
- println(Date());
-
- var myDate = new Date();
- myDate.setFullYear(2010, 0, 14);
-
- var today = new Date();
-
- if (myDate > today) {
- } else {
- }
-
-
- X=Date() should be equivalent to X=(new Date()).toString()
-
- */
-/******************************************************************************/
-
-#else
-void ejsStndClassesDummy() {}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_EJS */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsError.c b/source4/lib/appweb/ejs-2.0/ejs/classes/ejsError.c
deleted file mode 100755
index 99445afc7c..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsError.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * @file ejsError.c
- * @brief Error class
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-#if BLD_FEATURE_EJS
-
-/************************************ Code ************************************/
-/*
- * Parse the args and return the message. Convert non-string args using
- * .toString.
- */
-
-static char *getMessage(Ejs *ep, int argc, EjsVar **argv)
-{
- if (argc == 0) {
- return "";
-
- } else if (argc == 1) {
- if (! ejsVarIsString(argv[0])) {
- if (ejsRunMethod(ep, argv[0], "toString", 0) < 0) {
- return 0;
- }
- return ep->result->string;
-
- } else {
- return argv[0]->string;
- }
-
- } else {
- /* Don't call ejsError here or it will go recursive. */
- return 0;
- }
-}
-
-
-/******************************************************************************/
-/*
- * Error Constructor and also used for constructor for sub classes.
- *
- * Usage: new Error([message])
- */
-
-int ejsErrorCons(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- char *msg, *stack;
-
- msg = getMessage(ep, argc, argv);
- if (msg == 0) {
- return -1;
- }
-
- ejsSetPropertyToString(ep, thisObj, "name", ejsGetBaseClassName(thisObj));
- ejsSetPropertyToString(ep, thisObj, "message", msg);
-
- ejsSetPropertyToUndefined(ep, thisObj, "stack");
-
- stack = ejsFormatStack(ep);
- if (stack) {
- ejsSetPropertyToString(ep, thisObj, "stack", stack);
- mprFree(stack);
- }
-
- if (ejsObjHasErrors(thisObj)) {
- return -1;
- }
-
- return 0;
-}
-
-/******************************************************************************/
-
-int ejsDefineErrorClasses(Ejs *ep)
-{
- if (ejsDefineClass(ep, "Error", "Object", ejsErrorCons) == 0 ||
- ejsDefineClass(ep, "AssertError", "Error", ejsErrorCons) == 0 ||
- ejsDefineClass(ep, "EvalError", "Error", ejsErrorCons) == 0 ||
- ejsDefineClass(ep, "InternalError", "Error", ejsErrorCons) == 0 ||
- ejsDefineClass(ep, "IOError", "Error", ejsErrorCons) == 0 ||
- ejsDefineClass(ep, "MemoryError", "Error", ejsErrorCons) == 0 ||
- ejsDefineClass(ep, "RangeError", "Error", ejsErrorCons) == 0 ||
- ejsDefineClass(ep, "ReferenceError", "Error", ejsErrorCons) == 0 ||
- ejsDefineClass(ep, "SyntaxError", "Error", ejsErrorCons) == 0 ||
- ejsDefineClass(ep, "TypeError", "Error", ejsErrorCons) == 0) {
-
- return MPR_ERR_CANT_INITIALIZE;
- }
- return 0;
-}
-
-/******************************************************************************/
-
-#else
-void ejsErrorDummy() {}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_EJS */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsObject.c b/source4/lib/appweb/ejs-2.0/ejs/classes/ejsObject.c
deleted file mode 100644
index 4f2e23beb2..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsObject.c
+++ /dev/null
@@ -1,588 +0,0 @@
-/*
- * @file ejsObject.c
- * @brief Object class
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-#if BLD_FEATURE_EJS
-
-/****************************** Forward Declarations **************************/
-/*
- * Support routines
- */
-
-static void formatVar(Ejs *ep, MprBuf *bp, EjsVar *vp);
-
-/******************************************************************************/
-/*
- * Routine to create an object of the desired class. Class name may
- * contain "."
- *
- * The created object will be a stand-alone class NOT entered into the
- * properties of any other object. Callers must do this if required. ClassName
- * may contain "." and is interpreted relative to "obj" if supplied.
- *
- * Note: this does not call the constructors for the various objects and base
- * classes.
- */
-
-EjsVar *ejsCreateSimpleObjInternal(EJS_LOC_DEC(ep, loc), const char *className)
-{
- EjsVar *baseClass;
-
- if (className && *className) {
- baseClass = ejsGetClass(ep, 0, className);
- if (baseClass == 0) {
- mprError(ep, MPR_LOC, "Can't find base class %s", className);
- return 0;
- }
- } else {
- baseClass = 0;
- }
-
- return ejsCreateSimpleObjUsingClassInt(EJS_LOC_PASS(ep, loc),
- baseClass);
-}
-
-/******************************************************************************/
-/*
- * Create an object based upon the specified base class object. It will be a
- * stand-alone class not entered into the properties of any other object.
- * Callers must do this if required.
- *
- * Note: this does not call the constructors for the various objects and base
- * classes.
- */
-
-EjsVar *ejsCreateSimpleObjUsingClassInt(EJS_LOC_DEC(ep, loc),
- EjsVar *baseClass)
-{
- EjsVar *vp;
-
- mprAssert(baseClass);
-
- if (baseClass == 0) {
- mprError(ep, MPR_LOC, "Missing base class\n");
- return 0;
- }
-
- vp = ejsCreateObjVarInternal(EJS_LOC_PASS(ep, loc));
- if (vp == 0) {
- return vp;
- }
-
- ejsSetBaseClass(vp, baseClass);
-
- /*
- * This makes all internal method accesses faster
- * NOTE: this code is duplicated in ejsCreateSimpleClass
- */
- mprAssert(vp->objectState);
- vp->objectState->methods = baseClass->objectState->methods;
-
- return vp;
-}
-
-/******************************************************************************/
-
-void ejsSetMethods(Ejs *ep, EjsVar *op)
-{
- op->objectState->methods = ep->global->objectState->methods;
-}
-
-/******************************************************************************/
-/******************************** Internal Methods ****************************/
-/******************************************************************************/
-
-static EjsVar *createObjProperty(Ejs *ep, EjsVar *obj, const char *property)
-{
- return ejsGetVarPtr(ejsCreateSimpleProperty(ep, obj, property));
-}
-
-/******************************************************************************/
-
-static int deleteObjProperty(Ejs *ep, EjsVar *obj, const char *property)
-{
- return ejsDeleteProperty(ep, obj, property);
-}
-
-/******************************************************************************/
-
-static EjsVar *getObjProperty(Ejs *ep, EjsVar *obj, const char *property)
-{
- return ejsGetVarPtr(ejsGetSimpleProperty(ep, obj, property));
-}
-
-/******************************************************************************/
-/*
- * Set the value of a property. Create if it does not exist
- */
-
-static EjsVar *setObjProperty(Ejs *ep, EjsVar *obj, const char *property,
- const EjsVar *value)
-{
- EjsProperty *pp;
- EjsVar *vp;
-
- pp = ejsCreateSimpleProperty(ep, obj, property);
- if (pp == 0) {
- mprAssert(pp);
- return 0;
- }
- vp = ejsGetVarPtr(pp);
- if (ejsWriteVar(ep, vp, value, EJS_SHALLOW_COPY) < 0) {
- mprAssert(0);
- return 0;
- }
- return ejsGetVarPtr(pp);
-}
-
-/******************************************************************************/
-/*********************************** Constructors *****************************/
-/******************************************************************************/
-#if UNUSED
-/*
- * Object constructor. We don't use this for speed. Think very carefully if
- * you add an object constructor.
- */
-
-int ejsObjectConstructor(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- return 0;
-}
-
-#endif
-/******************************************************************************/
-/******************************** Visible Methods *****************************/
-/******************************************************************************/
-
-static int cloneMethod(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- int copyDepth;
-
- copyDepth = EJS_DEEP_COPY;
-
- if (argc == 1 && ejsVarToBoolean(argv[0])) {
- copyDepth = EJS_RECURSIVE_DEEP_COPY;
- }
-
- ejsWriteVar(ep, ep->result, thisObj, copyDepth);
-
- return 0;
-}
-
-/******************************************************************************/
-
-static int toStringMethod(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- MprBuf *bp;
- int saveMaxDepth, saveDepth, saveFlags;
-
- saveMaxDepth = ep->maxDepth;
-
- if (argc >= 1) {
- ep->maxDepth = ejsVarToInteger(argv[0]);
- } else if (ep->maxDepth == 0) {
- ep->maxDepth = MAXINT;
- }
-
- saveFlags = ep->flags;
- if (argc >= 2) {
- if (ejsVarToBoolean(argv[1])) {
- ep->flags |= EJS_FLAGS_ENUM_HIDDEN;
- }
- }
- if (argc == 3) {
- if (ejsVarToBoolean(argv[2])) {
- ep->flags |= EJS_FLAGS_ENUM_BASE;
- }
- }
-
- bp = mprCreateBuf(ep, 0, 0);
-
- saveDepth = ep->depth;
-
- formatVar(ep, bp, thisObj);
-
- ep->depth = saveDepth;
- ep->maxDepth = saveMaxDepth;
-
- mprAddNullToBuf(bp);
-
- ejsWriteVarAsString(ep, ep->result, mprGetBufStart(bp));
- mprFree(bp);
-
- ep->flags = saveFlags;
-
- return 0;
-}
-
-/******************************************************************************/
-
-static int valueOfMethod(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (argc != 0) {
- mprAssert(0);
- return -1;
- }
-
- switch (thisObj->type) {
- default:
- case EJS_TYPE_UNDEFINED:
- case EJS_TYPE_NULL:
- case EJS_TYPE_CMETHOD:
- case EJS_TYPE_OBJECT:
- case EJS_TYPE_METHOD:
- case EJS_TYPE_STRING_CMETHOD:
- ejsWriteVar(ep, ep->result, thisObj, EJS_SHALLOW_COPY);
- break;
-
- case EJS_TYPE_STRING:
- ejsWriteVarAsInteger(ep, ep->result, atoi(thisObj->string));
- break;
-
- case EJS_TYPE_BOOL:
- case EJS_TYPE_INT:
-#if BLD_FEATURE_INT64
- case EJS_TYPE_INT64:
-#endif
-#if BLD_FEATURE_FLOATING_POINT
- case EJS_TYPE_FLOAT:
-#endif
- ejsWriteVar(ep, ep->result, thisObj, EJS_SHALLOW_COPY);
- break;
- }
- return 0;
-}
-
-/******************************************************************************/
-
-static int hashGetAccessor(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsSetReturnValueToInteger(ejs, (int) thisObj->objectState);
- return 0;
-}
-
-/******************************************************************************/
-
-static int classGetAccessor(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (thisObj->objectState == 0 || thisObj->objectState->baseClass == 0) {
- ejsSetReturnValueToString(ejs, "object");
- } else {
- ejsSetReturnValueToString(ejs,
- thisObj->objectState->baseClass->objectState->className);
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Format an object. Called recursively to format properties and contained
- * objects.
- */
-
-static void formatVar(Ejs *ep, MprBuf *bp, EjsVar *vp)
-{
- EjsProperty *pp, *first;
- EjsVar *propVar, *baseClass;
- char *buf, *value;
- int i;
-
- if (vp->type == EJS_TYPE_OBJECT) {
- if (!vp->objectState->visited) {
-
- mprPutStringToBuf(bp, vp->isArray ? "[\n" : "{\n");
-
- ep->depth++;
- vp->objectState->visited = 1;
-
- if (ep->depth <= ep->maxDepth) {
- first = ejsGetFirstProperty(vp, EJS_ENUM_ALL);
-
- if (ep->flags & EJS_FLAGS_ENUM_BASE) {
- baseClass = vp->objectState->baseClass;
- if (baseClass) {
- for (i = 0; i < ep->depth; i++) {
- mprPutStringToBuf(bp, " ");
- }
- mprPutStringToBuf(bp, baseClass->objectState->objName);
- mprPutStringToBuf(bp, ": /* Base Class */ ");
- if (baseClass->objectState == vp->objectState) {
- value = "this";
- } else if (ejsRunMethodCmd(ep, baseClass, "toString",
- "%d", ep->maxDepth) < 0) {
- value = "[object Object]";
- } else {
- mprAssert(ejsVarIsString(ep->result));
- value = ep->result->string;
- }
- mprPutStringToBuf(bp, value);
- if (first) {
- mprPutStringToBuf(bp, ",\n");
- }
- }
- }
-
- pp = first;
- while (pp) {
- if (! pp->dontEnumerate ||
- ep->flags & EJS_FLAGS_ENUM_HIDDEN) {
- for (i = 0; i < ep->depth; i++) {
- mprPutStringToBuf(bp, " ");
- }
-
- if (! vp->isArray) {
- mprPutStringToBuf(bp, pp->name);
- mprPutStringToBuf(bp, ": ");
- }
-
- propVar = ejsGetVarPtr(pp);
- if (propVar->type == EJS_TYPE_OBJECT) {
- if (pp->var.objectState == vp->objectState) {
- value = "this";
- } else if (ejsRunMethodCmd(ep, propVar,
- "toString", "%d", ep->maxDepth) < 0) {
- value = "[object Object]";
- } else {
- mprAssert(ejsVarIsString(ep->result));
- value = ep->result->string;
- }
- mprPutStringToBuf(bp, value);
-
- } else {
- formatVar(ep, bp, &pp->var);
- }
-
- pp = ejsGetNextProperty(pp, EJS_ENUM_ALL);
- if (pp) {
- mprPutStringToBuf(bp, ",\n");
- }
- } else {
- pp = ejsGetNextProperty(pp, EJS_ENUM_ALL);
- }
- }
- }
- vp->objectState->visited = 0;
-
- mprPutCharToBuf(bp, '\n');
-
- ep->depth--;
- for (i = 0; i < ep->depth; i++) {
- mprPutStringToBuf(bp, " ");
- }
- mprPutCharToBuf(bp, vp->isArray ? ']' : '}');
- }
-
- } else if (vp->type == EJS_TYPE_METHOD) {
-
- mprPutStringToBuf(bp, "function (");
- for (i = 0; i < vp->method.args->length; i++) {
- mprPutStringToBuf(bp, vp->method.args->items[i]);
- if ((i + 1) < vp->method.args->length) {
- mprPutStringToBuf(bp, ", ");
- }
- }
- mprPutStringToBuf(bp, ") {");
- mprPutStringToBuf(bp, vp->method.body);
- for (i = 0; i < ep->depth; i++) {
- mprPutStringToBuf(bp, " ");
- }
- mprPutStringToBuf(bp, "}");
-
- } else {
-
- if (vp->type == EJS_TYPE_STRING) {
- mprPutCharToBuf(bp, '\"');
- }
-
- /*
- * We don't use ejsVarToString for arrays, objects and strings.
- * This is because ejsVarToString does not call "obj.toString"
- * and it is not required for strings.
- * MOB - rc
- */
- buf = ejsVarToString(ep, vp);
- mprPutStringToBuf(bp, buf);
-
- if (vp->type == EJS_TYPE_STRING) {
- mprPutCharToBuf(bp, '\"');
- }
- }
-}
-
-/******************************************************************************/
-/*
- * mixin code. Blends code at the "thisObj" level.
- */
-
-static int mixinMethod(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- EjsProperty *pp;
- char *buf;
- int fid, i, rc;
-
- mprAssert(argv);
-
- /*
- * Create a variable scope block set to the current object
- */
- rc = 0;
- fid = ejsSetBlock(ep, thisObj);
-
- for (i = 0; i < argc; i++) {
-
- if (ejsVarIsString(argv[i])) {
- rc = ejsEvalScript(ep, argv[i]->string, 0);
-
- } else if (ejsVarIsObject(argv[i])) {
-
- /* MOB -- OPT. When we have proper scope chains, we should just
- refer to the module and not copy */
- pp = ejsGetFirstProperty(argv[i], EJS_ENUM_ALL);
- while (pp) {
- ejsSetProperty(ep, thisObj, pp->name, ejsGetVarPtr(pp));
- pp = ejsGetNextProperty(pp, EJS_ENUM_ALL);
- }
-
- } else {
- /* MOB - rc */
- buf = ejsVarToString(ep, argv[i]);
- rc = ejsEvalScript(ep, buf, 0);
-
- }
- if (rc < 0) {
- ejsCloseBlock(ep, fid);
- return -1;
- }
- }
- ejsCloseBlock(ep, fid);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Create the object class
- */
-
-int ejsDefineObjectClass(Ejs *ep)
-{
- EjsMethods *methods;
- EjsProperty *objectProp, *protoProp;
- EjsVar *op, *globalClass;
-
- /*
- * Must specially hand-craft the object class as it is the base class
- * of all objects.
- */
- op = ejsCreateObjVar(ep);
- if (op == 0) {
- return MPR_ERR_CANT_CREATE;
- }
- ejsSetClassName(ep, op, "Object");
-
- /*
- * Don't use a constructor for objects for speed
- */
- ejsMakeClassNoConstructor(op);
-
- /*
- * MOB -- should mark properties as public / private and class or instance.
- */
- ejsDefineCMethod(ep, op, "clone", cloneMethod, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, op, "toString", toStringMethod, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, op, "valueOf", valueOfMethod, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, op, "mixin", mixinMethod, EJS_NO_LOCAL);
-
- ejsDefineCAccessors(ep, op, "hash", hashGetAccessor, 0, EJS_NO_LOCAL);
- ejsDefineCAccessors(ep, op, "baseClass", classGetAccessor, 0, EJS_NO_LOCAL);
-
- /*
- * MOB -- make this an accessor
- */
- protoProp = ejsSetProperty(ep, op, "prototype", op);
- if (protoProp == 0) {
- ejsFreeVar(ep, op);
- return MPR_ERR_CANT_CREATE;
- }
-
- /*
- * Setup the internal methods. Most classes will never override these.
- * The XML class will. We rely on talloc to free internal. Use "ep" as
- * the parent as we need "methods" to live while the interpreter lives.
- */
- methods = mprAllocTypeZeroed(ep, EjsMethods);
- op->objectState->methods = methods;
-
- methods->createProperty = createObjProperty;
- methods->deleteProperty = deleteObjProperty;
- methods->getProperty = getObjProperty;
- methods->setProperty = setObjProperty;
-
- objectProp = ejsSetPropertyAndFree(ep, ep->global, "Object", op);
-
- /*
- * Change the global class to use Object's methods
- */
- globalClass = ep->service->globalClass;
- globalClass->objectState->methods = methods;
- globalClass->objectState->baseClass = ejsGetVarPtr(protoProp);
-
- ep->objectClass = ejsGetVarPtr(objectProp);
-
- if (ejsObjHasErrors(ejsGetVarPtr(objectProp))) {
- ejsFreeVar(ep, op);
- return MPR_ERR_CANT_CREATE;
- }
- return 0;
-}
-
-/******************************************************************************/
-
-#else
-void ejsObjectDummy() {}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_EJS */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsStndClasses.c b/source4/lib/appweb/ejs-2.0/ejs/classes/ejsStndClasses.c
deleted file mode 100644
index fd6cda7813..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsStndClasses.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * @file ejsStndClasses.c
- * @brief EJS support methods
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-#if BLD_FEATURE_EJS
-
-/******************************************************************************/
-/******************************* Function Class *******************************/
-/******************************************************************************/
-
-int ejsDefineFunctionClass(Ejs *ep)
-{
- if (ejsDefineClass(ep, "Function", "Object", ejsFunctionConstructor) == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Function constructor
- */
-
-int ejsFunctionConstructor(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- int rc;
-
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsArgError(ep, "Usage: Function(\"function (arg) { script };\");");
- }
-
- rc = ejsEvalScript(ep, argv[0]->string, 0);
-
- /*
- * Note: this will convert the object into a method. It will cease to be
- * an object.
- */
- if (rc == 0 && ejsVarIsMethod(ep->result)) {
- /*
- * Must make thisObj collectable.
- */
- ejsMakeObjPermanent(thisObj, 0);
- ejsMakeObjLive(thisObj, 1);
- mprAssert(ejsObjIsCollectable(thisObj));
- ejsWriteVar(ep, thisObj, ep->result, EJS_SHALLOW_COPY);
- }
- return rc;
-}
-
-/******************************************************************************/
-/******************************* Boolean Class ********************************/
-/******************************************************************************/
-
-int ejsDefineBooleanClass(Ejs *ep)
-{
- if (ejsDefineClass(ep, "Boolean", "Object", ejsBooleanConstructor) == 0){
- return MPR_ERR_CANT_INITIALIZE;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Boolean constructor
- */
-
-int ejsBooleanConstructor(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- return 0;
-}
-
-/******************************************************************************/
-/******************************** Number Class ********************************/
-/******************************************************************************/
-
-int ejsDefineNumberClass(Ejs *ep)
-{
- if (ejsDefineClass(ep, "Number", "Object", ejsNumberConstructor) == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Number constructor
- */
-
-int ejsNumberConstructor(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- return 0;
-}
-
-/******************************************************************************/
-
-#else
-void ejsStndClassesDummy() {}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_EJS */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsString.c b/source4/lib/appweb/ejs-2.0/ejs/classes/ejsString.c
deleted file mode 100644
index 2339650361..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsString.c
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * @file ejsString.c
- * @brief EJScript string class
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-#if BLD_FEATURE_EJS
-/******************************************************************************/
-/*********************************** Constructors *****************************/
-/******************************************************************************/
-/*
- * String constructor.
- */
-
-int ejsStringConstructor(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- char *str;
-
- if (argc == 0) {
- ejsSetReturnValueToString(ejs, "");
-
- } else if (argc == 1) {
- /* MOB -- rc */
- str = ejsVarToString(ejs, argv[0]);
- ejsSetReturnValueToString(ejs, str);
-
- } else {
- ejsArgError(ejs, "usage: String([var])");
- return -1;
- }
-
- return 0;
-}
-
-/******************************************************************************/
-/******************************** Visible Methods *****************************/
-/******************************************************************************/
-/*
- * Return a string containing the character at a given index
- *
- * String string.charAt(Number)
- */
-
-static int charAt(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- EjsNum num;
- char buf[2];
-
- if (argc != 1) {
- ejsArgError(ejs, "usage: charAt(integer)");
- return -1;
- }
-
- num = ejsVarToNumber(argv[0]);
- if (num < 0 || num >= thisObj->length) {
- ejsError(ejs, EJS_RANGE_ERROR, "Bad index");
- return -1;
- }
-
- mprAssert(ejsVarIsString(thisObj));
-
- buf[0] = argv[0]->string[num];
- buf[1] = '\0';
- ejsSetReturnValueToString(ejs, buf);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Return an integer containing the character at a given index
- *
- * Number string.charCodeAt(Number)
- */
-
-static EjsNum charCodeAt(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- EjsNum num;
-
- if (argc != 1) {
- ejsArgError(ejs, "usage: charCodeAt(integer)");
- return -1;
- }
-
- num = ejsVarToNumber(argv[0]);
- if (num < 0 || num >= thisObj->length) {
- ejsError(ejs, EJS_RANGE_ERROR, "Bad index");
- return -1;
- }
- ejsSetReturnValueToNumber(ejs, (EjsNum) argv[0]->string[num]);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Catenate
- *
- * String string.catenate(var, ...)
- */
-
-static int concat(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- int i;
-
- if (argc == 0) {
- ejsArgError(ejs, "usage: concat(String, ...)");
- return -1;
- }
-
- mprAssert(ejsVarIsString(thisObj));
-
- for (i = 0; i < argc; i++) {
- if (ejsStrcat(ejs, thisObj, argv[i]) < 0) {
- ejsMemoryError(ejs);
- return -1;
- }
- }
- ejsSetReturnValue(ejs, thisObj);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Return the position of the first occurance of a substring
- *
- * Number string.indexOf(String subString [, Number start])
- */
-
-static int indexOf(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- char *pat, *s1, *s2, *origin;
- int start, i;
-
- if (argc == 0 || argc > 2) {
- ejsArgError(ejs, "usage: indexOf(String [, Number])");
- return -1;
- }
-
- pat = ejsVarToString(ejs, argv[0]);
-
- if (argc == 2) {
- start = ejsVarToNumber(argv[1]);
- if (start > thisObj->length) {
- start = thisObj->length;
- }
- } else {
- start = 0;
- }
-
- i = start;
- for (origin = &thisObj->string[i]; i < thisObj->length; i++, origin++) {
- s1 = origin;
- for (s2 = pat; *s1 && *s2; s1++, s2++) {
- if (*s1 != *s2) {
- break;
- }
- }
- if (*s2 == '\0') {
- ejsSetReturnValueToNumber(ejs, (EjsNum) (origin - thisObj->string));
- }
- }
-
- ejsSetReturnValueToNumber(ejs, (EjsNum) -1);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Return the position of the last occurance of a substring
- *
- * Number string.lastIndexOf(String subString [, Number start])
- */
-
-static int lastIndexOf(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- char *pat, *s1, *s2, *origin;
- int start;
-
- if (argc == 0 || argc > 2) {
- ejsArgError(ejs, "usage: indexOf(String [, Number])");
- return -1;
- }
-
- pat = ejsVarToString(ejs, argv[0]);
-
- if (argc == 2) {
- start = ejsVarToNumber(argv[1]);
- if (start > thisObj->length) {
- start = thisObj->length;
- }
- } else {
- start = 0;
- }
-
- origin = &thisObj->string[thisObj->length - 1];
- for (; origin >= &thisObj->string[start]; origin--) {
-
- s1 = origin;
- for (s2 = pat; *s1 && *s2; s1++, s2++) {
- if (*s1 != *s2) {
- break;
- }
- }
- if (*s2 == '\0') {
- ejsSetReturnValueToNumber(ejs, (EjsNum) (origin - thisObj->string));
- }
- }
-
- ejsSetReturnValueToNumber(ejs, (EjsNum) -1);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Return a substring
- *
- * Number string.slice(Number start, Number end)
- */
-
-static int slice(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- EjsNum start, end;
-
- if (argc != 2) {
- ejsArgError(ejs, "usage: slice(Number, Number)");
- return -1;
- }
-
- start = ejsVarToNumber(argv[0]);
- end = ejsVarToNumber(argv[1]);
- if (start < 0 || start >= thisObj->length) {
- ejsError(ejs, EJS_RANGE_ERROR, "Bad start index");
- return-1;
- }
- if (end < 0 || end >= thisObj->length) {
- ejsError(ejs, EJS_RANGE_ERROR, "Bad end index");
- return -1;
- }
-
- mprAssert(ejsVarIsString(thisObj));
-
- ejsSetReturnValueToBinaryString(ejs, (uchar*) &thisObj->string[start],
- end - start);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Split a string
- *
- * Number string.split(String delimiter [, Number limit])
- */
-
-static int split(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- EjsVar *array, *vp;
- char *delim, *last, *cp;
- int len, limit, alloc;
-
- if (argc == 0 || argc > 2) {
- ejsArgError(ejs, "usage: split(String [, Number])");
- return -1;
- }
-
- delim = ejsVarToStringEx(ejs, argv[0], &alloc);
-
- limit = ejsVarToNumber(argv[1]);
-
- array = ejsCreateArray(ejs, 0);
-
- len = strlen(delim);
-
- last = thisObj->string;
- for (cp = last; *cp; cp++) {
- if (*cp == *delim && strncmp(cp, delim, len) == 0) {
- if (cp > last) {
- vp = ejsCreateBinaryStringVar(ejs, (uchar*) last, (cp - last));
- ejsAddArrayElt(ejs, array, vp, EJS_SHALLOW_COPY);
- ejsFreeVar(ejs, vp);
- }
- }
- }
-
- ejsSetReturnValue(ejs, array);
- ejsFreeVar(ejs, array);
-
- if (alloc) {
- mprFree(delim);
- }
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Create the object class
- */
-
-int ejsDefineStringClass(Ejs *ejs)
-{
- EjsVar *sc;
-
- sc = ejsDefineClass(ejs, "String", "Object", ejsStringConstructor);
- if (sc == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
-
- ejsDefineCMethod(ejs, sc, "charAt", charAt, EJS_NO_LOCAL);
- ejsDefineCMethod(ejs, sc, "charCodeAt", charCodeAt, EJS_NO_LOCAL);
- ejsDefineCMethod(ejs, sc, "concat", concat, EJS_NO_LOCAL);
- ejsDefineCMethod(ejs, sc, "indexOf", indexOf, EJS_NO_LOCAL);
- ejsDefineCMethod(ejs, sc, "lastIndexOf", lastIndexOf, EJS_NO_LOCAL);
- ejsDefineCMethod(ejs, sc, "slice", slice, EJS_NO_LOCAL);
- ejsDefineCMethod(ejs, sc, "split", split, EJS_NO_LOCAL);
-#if UNUSED
- ejsDefineCMethod(ejs, sc, "match", match, EJS_NO_LOCAL);
- ejsDefineCMethod(ejs, sc, "replace", replace, EJS_NO_LOCAL);
- ejsDefineCMethod(ejs, sc, "search", search, EJS_NO_LOCAL);
- ejsDefineCMethod(ejs, sc, "substring", substring, EJS_NO_LOCAL);
- // MOB bad name
- ejsDefineCMethod(ejs, sc, "substr", substr, EJS_NO_LOCAL);
- ejsDefineCMethod(ejs, sc, "toLowerCase", toLowerCase, EJS_NO_LOCAL);
- ejsDefineCMethod(ejs, sc, "toUpperCase", toUpperCase, EJS_NO_LOCAL);
-
- // Static method
- ejsDefineCMethod(ejs, sc, "fromCharCode", fromCharCode, 0, EJS_NO_LOCAL);
-#endif
-
- if (ejsObjHasErrors(sc)) {
- ejsFreeVar(ejs, sc);
- return MPR_ERR_CANT_CREATE;
- }
- return 0;
-}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_EJS */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsXml.c b/source4/lib/appweb/ejs-2.0/ejs/classes/ejsXml.c
deleted file mode 100644
index a2ef8d1390..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsXml.c
+++ /dev/null
@@ -1,1327 +0,0 @@
-/*
- * @file ejsXml.c
- * @brief E4X XML support
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/************************************ Doc *************************************/
-/*
- * Javascript class definition
- *
- * class XML {
- * public XML();
- * public XML(string xmlString); // "<tag... "
- * public XML(string file); // "file"
- *
- * public void load(string file);
- * public void save(string file);
- * public Array children();
- * public Array attributes();
- * }
- *
- [[Internal Properties / Methods]]
- - prototype - Ptr to class prototype (base class)
- - class - Type of class
- Object.prototype.toString
- - Value -
- - Get(name) - Returns the value
- - Put(name, value) - Sets the value
- - HasProperty(name) - Bool if property exists
- - Delete(name) - Delete property
- - DefaultValue(hint) - Return default primitive (not obj) value
- toString, if result is obj, then call valueOf
- if hint is number, then call valueOf, then toString
- - Construct(arg list) - Constructor
- - Call(arg list) - Function call
- - HasInstance(value) - ??
- - Scope - Frame scope chain
- - Match(string, index) - Regexp match
-
- - Example:
- XML attribute @name
- @*
- *
- var node = new XML("<order/>");
- Operators:
- var prices = order..price;
- var urgentItems = order.item(@level == "rush");
- var itemAttrs = order.item[0].@*; # @ for attributes
- XML Literals
- order.customer.address =
- <address>.....
- <zip>{zipCode}</zip> Where {var} is a JS var
- <tag attribute={prefix}> ... Also for attributes
- </address>
- Omit namespaces
- Example:
- var html = <html/>;
- html.head.title = "My title";
- head.body@bgcolor = "#e4e4e4";
-*/
-
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-#include "exml.h"
-
-/************************************ Data ************************************/
-#if BLD_FEATURE_EJS_E4X
-
-/*
- * Per tag state
- */
-typedef struct XmlTagState {
- EjsVar *obj;
- EjsVar *attributes;
- EjsVar *comments;
-} XmlTagState;
-
-/*
- * Parser state
- */
-typedef struct XmlState {
- Ejs *ep;
- EjsVar *xmlClass;
- EjsVar *xmlListClass;
- XmlTagState nodeStack[E4X_MAX_NODE_DEPTH];
- int topOfStack;
- long inputSize;
- long inputPos;
- const char *inputBuf;
- const char *fileName;
-} XmlState;
-
-/****************************** Forward Declarations **************************/
-/*
- * XML methods
- */
-static int text(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-static int name(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-static int load(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-static int save(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-static int toString(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-static int valueOf(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-
-/* MOB -- temp */
-static int getList(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-static int setText(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-
-#if FUTURE
-static int length(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-static int toXmlString(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-
-static int appendChild(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-static int attributes(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-static int child(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-static int children(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-static int comments(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-static int decendants(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-static int elements(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-static int insertChildAfter(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-static int insertChildBefore(Ejs *ep, EjsVar *thisObj, int argc,
- EjsVar **argv);
-static int replace(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-static int setName(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-static int text(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv);
-#endif
-
-/*
- * Internal methods
- */
-static EjsVar *createXmlProperty(Ejs *ep, EjsVar *obj, const char *property);
-static int deleteXmlProperty(Ejs *ep, EjsVar *obj, const char *property);
-static EjsVar *getXmlProperty(Ejs *ep, EjsVar *obj, const char *property);
-static EjsVar *setXmlProperty(Ejs *ep, EjsVar *obj, const char *property,
- const EjsVar *value);
-static int loadXmlString(Ejs *ep, EjsVar *thisObj, const char *xmlString);
-
-/*
- * XMLList methods
- */
-static EjsVar *createXmlListProperty(Ejs *ep, EjsVar *obj,
- const char *property);
-static int deleteXmlListProperty(Ejs *ep, EjsVar *obj,
- const char *property);
-static EjsVar *getXmlListProperty(Ejs *ep, EjsVar *obj, const char *property);
-static EjsVar *setXmlListProperty(Ejs *ep, EjsVar *obj, const char *property,
- const EjsVar *value);
-
-/*
- * Misc
- */
-static int readFileData(Exml *xp, void *data, char *buf, int size);
-static int readStringData(Exml *xp, void *data, char *buf, int size);
-static int parserHandler(Exml *xp, int state, const char *tagName,
- const char *attName, const char *value);
-static void termParser(Exml *xp);
-static Exml *initParser(Ejs *ep, EjsVar *thisObj, const char *fileName);
-static int getNumElements(EjsVar *obj);
-static int getText(MprBuf *buf, EjsVar *obj);
-static int xmlToString(Ejs *ep, MprBuf *buf, EjsVar *obj, int indentLevel);
-static void indent(MprBuf *bp, int level);
-static char *cleanTagName(char *name);
-
-/******************************************************************************/
-/*
- * Define the E4X classes (XML, XMLList)
- */
-
-int ejsDefineXmlClasses(Ejs *ep)
-{
- EjsMethods *methods;
- EjsVar *xmlClass, *xmlListClass;
-
- /*
- * Create the XML class
- */
- xmlClass = ejsDefineClass(ep, "XML", "Object", ejsXmlConstructor);
- if (xmlClass == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
-
- /*
- * Define the XML class methods
- */
- ejsDefineCMethod(ep, xmlClass, "text", text, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, xmlClass, "name", name, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, xmlClass, "load", load, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, xmlClass, "save", save, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, xmlClass, "toString", toString, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, xmlClass, "valueOf", valueOf, EJS_NO_LOCAL);
-
-/* MOB -- temporary only */
- ejsDefineCMethod(ep, xmlClass, "getList", getList, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, xmlClass, "setText", setText, EJS_NO_LOCAL);
-
- /*
- * Setup the XML internal methods.
- */
- methods = mprAllocTypeZeroed(ep, EjsMethods);
- xmlClass->objectState->methods = methods;
-
- methods->createProperty = createXmlProperty;
- methods->deleteProperty = deleteXmlProperty;
- methods->getProperty = getXmlProperty;
- methods->setProperty = setXmlProperty;
-
- /*
- * Create the XMLList class
- */
- xmlListClass = ejsDefineClass(ep, "XMLList", "Array",
- ejsXmlListConstructor);
-
- /*
- * Define the XMLList class methods
- */
-
- /*
- * Setup the XML internal methods.
- */
- methods = mprAllocTypeZeroed(ep, EjsMethods);
- xmlListClass->objectState->methods = methods;
-
- methods->createProperty = createXmlListProperty;
- methods->deleteProperty = deleteXmlListProperty;
- methods->getProperty = getXmlListProperty;
- methods->setProperty = setXmlListProperty;
-
- /* MOB -- need to complete xmlListClass */
-
- return (ejsObjHasErrors(xmlClass) || ejsObjHasErrors(xmlListClass))
- ? MPR_ERR_CANT_INITIALIZE : 0;
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Routine to create an XML object using a default constructor
- */
-
-EjsVar *ejsCreateXml(Ejs *ep)
-{
- EjsVar *op;
-
- op = ejsCreateSimpleObj(ep, "XML");
- if (op == 0) {
- mprAssert(op);
- return op;
- }
- ejsSetVarName(ep, op, "xmlNode");
-
- /*
- * Invoke class constructors manually (for speed and space)
- */
- if (ejsXmlConstructor(ep, op, 0, 0) < 0) {
- mprFree(op);
- mprAssert(0);
- return 0;
- }
- return op;
-}
-
-/******************************************************************************/
-/*
- * XML constructor
- */
-
-int ejsXmlConstructor(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- EjsVar *vp;
- const char *str;
-
- ejsSetVarFlags(thisObj, EJS_XML_FLAGS_ELEMENT);
-
- if (argc == 1) {
- vp = argv[0];
-
- if (ejsVarIsObject(vp)) {
- /* Convert DOM to XML. Not implemented */;
-
- } else if (ejsVarIsString(vp)) {
- str = vp->string;
- if (str == 0) {
- return 0;
- }
- if (*str == '<') {
- /* XML Literal */
- return loadXmlString(ep, thisObj, str);
-
- } else {
- /* Load from file */
- return load(ep, thisObj, argc, argv);
- }
- } else {
- ejsError(ep, EJS_TYPE_ERROR, "Bad type passed to XML constructor");
- return -1;
- }
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Routine to create an XMLList object
- */
-
-EjsVar *ejsCreateXmlList(Ejs *ep)
-{
- EjsVar *op;
-
- /* Sanity limit for size of hash table */
-
- op = ejsCreateSimpleObj(ep, "XMLList");
- if (op == 0) {
- mprAssert(0);
- return op;
- }
- if (ejsArrayConstructor(ep, op, 0, 0) < 0 ||
- ejsXmlConstructor(ep, op, 0, 0) < 0) {
- mprFree(op);
- mprAssert(0);
- return 0;
- }
- return op;
-}
-
-/******************************************************************************/
-/*
- * XMLList constructor
- */
-
-int ejsXmlListConstructor(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- // ejsSetVarFlags(vp, EJS_XML_FLAGS_ELEMENT);
- return 0;
-}
-
-/******************************************************************************/
-/******************************** Internal Methods ****************************/
-/******************************************************************************/
-
-static EjsVar *createXmlProperty(Ejs *ep, EjsVar *obj, const char *property)
-{
- return ejsGetVarPtr(ejsCreateSimpleProperty(ep, obj, property));
-}
-
-/******************************************************************************/
-
-static int deleteXmlProperty(Ejs *ep, EjsVar *obj, const char *property)
-{
- return ejsDeleteProperty(ep, obj, property);
-}
-
-/******************************************************************************/
-/* MOB -- need ep as an arg */
-static EjsVar *getXmlProperty(Ejs *ep, EjsVar *obj, const char *property)
-{
-#if NEW
- EjsVar *lp;
-
- lp = ejsCreateXmlList(ep);
- if (isdigit(*property)) {
- /* MOB -- where do we store these. Do we need them ? */
- lp->targetObject = obj
- lp->targetProperty = property
- return getXmlListProperty(lp, property);
- }
-
- /* What about a simple elment. Should it not return the text */
-
- if (*property == '@') {
- ap = ejsGetFirstProperty(obj, EJS_ENUM_ALL);
- while (ap) {
- vp = ejsGetVarPtr(ap);
- /* MOB -- are attributes unique ? */
- if (vp->flags & EJS_XML_FLAGS_ATTRIBUTE &&
- strcmp(property, ap->name) == 0) {
- ejsAppendXml(lp, vp);
- }
- ap = ejsGetNexttProperty(ap, EJS_ENUM_ALL);
- }
- } else {
- while (ap) {
- vp = ejsGetVarPtr(ap);
- /* MOB -- are attributes unique ? */
- if (vp->flags & EJS_XML_FLAGS_ELEMENT &&
- strcmp(property, ap->name) == 0) {
- ejsAppendXml(lp, vp);
- }
- ap = ejsGetNexttProperty(ap, EJS_ENUM_ALL);
- }
- }
- return l;
-
- // Must always return XML or XMLList event for comments and attributes
-#endif
- return ejsGetVarPtr(ejsGetSimpleProperty(ep, obj, property));
-}
-
-/******************************************************************************/
-
-static EjsVar *setXmlProperty(Ejs *ep, EjsVar *obj, const char *property,
- const EjsVar *value)
-{
- EjsProperty *pp;
- EjsVar *vp;
-
- pp = ejsCreateSimpleProperty(ep, obj, property);
- if (pp == 0) {
- /* Should never happen */
- mprAssert(pp);
- return 0;
- }
- vp = ejsGetVarPtr(pp);
- if (ejsWriteVar(ep, vp, value, EJS_SHALLOW_COPY) < 0) {
- return 0;
- }
- return ejsGetVarPtr(pp);
-}
-
-/******************************************************************************/
-/*
- NEW
-
-static EjsVar *setXmlProperty(Ejs *ep, EjsVar *op, const char *property,
- EjsVar *value)
-{
-
- if ((value->objectState->baseClass != XML &&
- value->objectState->baseClass != XMLList) ||
- value->string[0] != '<') {
- ejsVarToString(luevalue.toString();
- ejsRunMethod(ep, value, "toString", 0);
- value = ejsDupVar(ep->result);
-
- } else {
- value = ejsDupVar(value);
- }
-
- if (isdigit(*property)) {
- // ERROR -- reserved for future versions
- return 0;
- }
-
- if (*property == '@') {
- if (op->objectState->baseClass == XMLList) {
- if (op->obj.LENGTH_PROPERTY == 0) {
- c = "";
- } else {
- // Catenate all result of toString on all elts in list
- }
- } else {
- c = c.toString();
- }
- // Replace existing attribute of same name or insert
- return;
- }
- for (i = op->obj.LENGTH - 1; i >= 0; i--) {
- // Delete item of same name
- }
- if (not Found) {
- Append new Xml object
- - set [[name]], [[class]] == "element"
- }
-
- mprFree(value);
-}
-
- */
-/******************************************************************************/
-/************************************ Methods *********************************/
-/******************************************************************************/
-
-static int load(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- const char *fileName;
- XmlState *parser;
- Exml *xp;
- MprFile *file;
-
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsError(ep, EJS_ARG_ERROR, "Bad args. Usage: load(fileName);");
- return -1;
- }
- fileName = argv[0]->string;
-
- /* MOB -- not romable
- Need rom code in MPR not MprServices
- */
- file = mprOpen(ep, fileName, O_RDONLY, 0664);
- if (file == 0) {
- ejsError(ep, EJS_IO_ERROR, "Can't open: %s", fileName);
- return -1;
- }
-
- /* MOB -- should we empty thisObj of all existing properties ? */
-
- xp = initParser(ep, thisObj, fileName);
- parser = exmlGetParseArg(xp);
-
- exmlSetInputStream(xp, readFileData, (void*) file);
-
- if (exmlParse(xp) < 0) {
- if (! ejsGotException(ep)) {
- ejsError(ep, EJS_IO_ERROR, "Can't parse XML file: %s\nDetails %s",
- fileName, exmlGetErrorMsg(xp));
- }
- termParser(xp);
- mprClose(file);
- return -1;
- }
-
- ejsSetReturnValue(ep, parser->nodeStack[0].obj);
-
- termParser(xp);
- mprClose(file);
-
- return 0;
-}
-
-/******************************************************************************/
-
-static int loadXmlString(Ejs *ep, EjsVar *thisObj, const char *xmlString)
-{
- XmlState *parser;
- Exml *xp;
-
- xp = initParser(ep, thisObj, "string");
- parser = exmlGetParseArg(xp);
-
- parser->inputBuf = xmlString;
- parser->inputSize = strlen(xmlString);
-
- exmlSetInputStream(xp, readStringData, (void*) 0);
-
- if (exmlParse(xp) < 0) {
- if (! ejsGotException(ep)) {
- ejsError(ep, EJS_IO_ERROR, "Can't parse XML string\nError %s",
- exmlGetErrorMsg(xp));
- }
- termParser(xp);
- return -1;
- }
-
- ejsSetReturnValue(ep, parser->nodeStack[0].obj);
-
- termParser(xp);
-
- return 0;
-}
-
-/******************************************************************************/
-
-static int text(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- EjsVar *vp;
-
- vp = ejsGetVarPtr(ejsGetSimpleProperty(ep, thisObj, E4X_TEXT_PROPERTY));
- if (vp == 0) {
- ejsSetReturnValueToString(ep, "");
- return 0;
- }
- ejsSetReturnValue(ep, vp);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Return the tag name
- */
-
-static int name(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- EjsVar *vp;
-
- vp = ejsGetVarPtr(ejsGetSimpleProperty(ep, thisObj, E4X_TAG_NAME_PROPERTY));
- if (vp == 0) {
- ejsSetReturnValueToString(ep, "");
- return 0;
- }
- ejsSetReturnValue(ep, vp);
-#if UNDEFINED
- char *name;
- /* MOB -- not ideal as we can't guarantee thisObj is a property */
- name = ejsGetPropertyPtr(thisObj)->name;
- if (name == 0) {
- name = "";
- }
- ejsSetReturnValueToString(ep, name);
-#endif
- return 0;
-}
-
-/******************************************************************************/
-/* MOB -- temporary only */
-
-static int setText(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (argc != 1) {
- ejsArgError(ep, "usage: setText(string)");
- }
-
- ejsSetProperty(ep, thisObj, E4X_TEXT_PROPERTY, argv[0]);
- ejsSetReturnValue(ep, argv[0]);
- return 0;
-}
-
-/******************************************************************************/
-
-static Exml *initParser(Ejs *ep, EjsVar *thisObj, const char *fileName)
-{
- XmlState *parser;
- Exml *xp;
-
- xp = exmlOpen(ep, 512, E4X_BUF_MAX);
- mprAssert(xp);
-
- /*
- * Create the parser stack
- */
- parser = mprAllocTypeZeroed(ep, XmlState);
- parser->ep = ep;
- parser->nodeStack[0].obj = thisObj;
- parser->xmlClass = ejsGetClass(ep, 0, "XML");
- parser->xmlListClass = ejsGetClass(ep, 0, "XMLList");
- parser->fileName = fileName;
-
- exmlSetParseArg(xp, parser);
- exmlSetParserHandler(xp, parserHandler);
-
- return xp;
-}
-
-/******************************************************************************/
-
-static void termParser(Exml *xp)
-{
- mprFree(exmlGetParseArg(xp));
- exmlClose(xp);
-}
-
-/******************************************************************************/
-/*
- * XML parsing callback. Called for each elt and attribute/value pair.
- * For speed, we handcraft the object model here rather than calling
- * putXmlProperty.
- *
- * "<!-- txt -->" parseHandler(efd, , EXML_COMMENT);
- * "<elt" parseHandler(efd, , EXML_NEW_ELT);
- * "...att=value" parseHandler(efd, , EXML_NEW_ATT);
- * "<elt ...>" parseHandler(efd, , EXML_ELT_DEFINED);
- * "<elt/>" parseHandler(efd, , EXML_SOLO_ELT_DEFINED);
- * "<elt> ...<" parseHandler(efd, , EXML_ELT_DATA);
- * "...</elt>" parseHandler(efd, , EXML_END_ELT);
- *
- * Note: we recurse on every new nested elt.
- */
-
-static int parserHandler(Exml *xp, int state, const char *tagName,
- const char *attName, const char *value)
-{
- XmlState *parser;
- XmlTagState *tos;
- EjsVar *currentNode, *vp, *tagNode, *parent, *vpx;
- EjsProperty *pp;
- Ejs *ep;
- char *name;
-
- parser = (XmlState*) xp->parseArg;
- ep = parser->ep;
- tos = &parser->nodeStack[parser->topOfStack];
- currentNode = tos->obj;
-
- mprAssert(state >= 0);
- mprAssert(tagName && *tagName);
-
- switch (state) {
- case EXML_PI:
- /*
- * By using a property name with a leading space, we can store
- * non-user-visible processing instructions as regular properties.
- */
- pp = ejsCreateSimpleNonUniqueProperty(ep, currentNode, E4X_PI_PROPERTY);
- ejsMakePropertyEnumerable(pp, 1);
- vp = ejsGetVarPtr(pp);
- ejsWriteVarAsString(ep, vp, value);
- ejsSetVarFlags(vp, EJS_XML_FLAGS_PI);
- break;
-
- case EXML_COMMENT:
- /*
- * By using a property name with a leading space, we can store
- * non- user-visible comments as regular properties.
- */
- pp = ejsCreateSimpleNonUniqueProperty(ep, currentNode,
- E4X_COMMENT_PROPERTY);
- ejsMakePropertyEnumerable(pp, 1);
- vp = ejsGetVarPtr(pp);
- ejsWriteVarAsString(ep, vp, value);
- ejsSetVarFlags(vp, EJS_XML_FLAGS_COMMENT);
- break;
-
- case EXML_NEW_ELT:
- if (parser->topOfStack > E4X_MAX_NODE_DEPTH) {
- ejsError(ep, EJS_IO_ERROR,
- "XML nodes nested too deeply in %s at line %d",
- parser->fileName, exmlGetLineNumber(xp));
- return MPR_ERR_BAD_SYNTAX;
- }
-
- name = mprStrdup(xp, tagName);
- if (name == 0) {
- return MPR_ERR_MEMORY;
- }
-
- if (cleanTagName(name) < 0) {
- ejsError(ep, EJS_TYPE_ERROR, "Bad XML tag name in %s at %d",
- parser->fileName, exmlGetLineNumber(xp));
- mprFree(name);
- return MPR_ERR_BAD_SYNTAX;
- }
-
- pp = ejsCreateSimpleNonUniqueProperty(ep, currentNode, name);
- ejsMakePropertyEnumerable(pp, 1);
-
- tagNode = ejsGetVarPtr(pp);
-
- /* MOB -- OPT */
- vpx = ejsCreateXml(ep);
- vp = ejsWriteVar(ep, tagNode, vpx, EJS_SHALLOW_COPY);
- ejsMakeObjLive(vp, 1);
- ejsFreeVar(ep, vpx);
-
- /* MOB -- return code */
- pp = ejsSetPropertyToString(ep, vp, E4X_TAG_NAME_PROPERTY, name);
- ejsMakePropertyEnumerable(pp, 0);
-
- ejsSetVarFlags(vp, EJS_XML_FLAGS_ELEMENT);
- ejsMakePropertyEnumerable(ejsGetPropertyPtr(vp), 1);
-
- tos = &parser->nodeStack[++(parser->topOfStack)];
- currentNode = tos->obj = vp;
- tos->attributes = 0;
- tos->comments = 0;
- mprFree(name);
- break;
-
- case EXML_NEW_ATT:
- if (mprAllocSprintf(MPR_LOC_ARGS(xp), &name, 0, "@%s", attName) < 0) {
- return MPR_ERR_MEMORY;
- }
- pp = ejsCreateProperty(ep, currentNode, name);
- ejsMakePropertyEnumerable(pp, 1);
-
- vp = ejsGetVarPtr(pp);
- ejsWriteVarAsString(ep, vp, value);
- ejsSetVarFlags(vp, EJS_XML_FLAGS_ATTRIBUTE);
- mprFree(name);
- break;
-
- case EXML_SOLO_ELT_DEFINED:
- parser->topOfStack--;
- mprAssert(parser->topOfStack >= 0);
- tos = &parser->nodeStack[parser->topOfStack];
- break;
-
- case EXML_ELT_DEFINED:
- if (parser->topOfStack > 0) {
- parent = parser->nodeStack[parser->topOfStack - 1].obj;
- ejsSetProperty(ep, currentNode, E4X_PARENT_PROPERTY, parent);
- }
- break;
-
- case EXML_ELT_DATA:
- case EXML_CDATA:
- pp = ejsCreateSimpleNonUniqueProperty(ep, currentNode,
- E4X_TEXT_PROPERTY);
- ejsMakePropertyEnumerable(pp, 1);
- vp = ejsGetVarPtr(pp);
- ejsWriteVarAsString(ep, vp, value);
- ejsSetVarFlags(vp, EJS_XML_FLAGS_TEXT);
- break;
-
- case EXML_END_ELT:
- /*
- * This is the closing element in a pair "<x>...</x>".
- * Pop the stack frame off the elt stack
- */
- parser->topOfStack--;
- mprAssert(parser->topOfStack >= 0);
- tos = &parser->nodeStack[parser->topOfStack];
- break;
-
- default:
- ejsError(ep, EJS_IO_ERROR, "XML error in %s at %d\nDetails %s",
- parser->fileName, exmlGetLineNumber(xp), exmlGetErrorMsg(xp));
- mprAssert(0);
- return MPR_ERR_BAD_SYNTAX;
- }
- return 0;
-}
-
-/******************************************************************************/
-
-static char *cleanTagName(char *name)
-{
- char *cp;
-
- for (cp = name; *cp; cp++) {
- if (*cp == ':') {
- *cp = '_';
- } else if (!isalnum(*cp) && *cp != '_' && *cp != '$' && *cp != '@') {
- return 0;
- }
- }
- return name;
-}
-
-/******************************************************************************/
-
-static int readFileData(Exml *xp, void *data, char *buf, int size)
-{
- mprAssert(xp);
- mprAssert(data);
- mprAssert(buf);
- mprAssert(size > 0);
-
- return mprRead((MprFile*) data, buf, size);
-}
-
-/******************************************************************************/
-
-static int readStringData(Exml *xp, void *data, char *buf, int size)
-{
- XmlState *parser;
- int rc, len;
-
- mprAssert(xp);
- mprAssert(buf);
- mprAssert(size > 0);
-
- parser = (XmlState*) xp->parseArg;
-
- if (parser->inputPos < parser->inputSize) {
- len = min(size, (parser->inputSize - parser->inputPos));
- rc = mprMemcpy(buf, size, &parser->inputBuf[parser->inputPos], len);
- parser->inputPos += len;
- return rc;
- }
- return 0;
-}
-
-/******************************************************************************/
-
-static int save(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- const char *fileName;
- MprBuf *buf;
- MprFile *file;
- int bytes, len;
-
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsError(ep, EJS_ARG_ERROR, "Bad args. Usage: save(fileName);");
- return -1;
- }
- fileName = argv[0]->string;
-
- /* MOB -- not romable
- Need rom code in MPR not MprServices
- */
-
- /*
- * Convert to a string
- */
- buf = mprCreateBuf(ep, E4X_BUF_SIZE, E4X_BUF_MAX);
- if (xmlToString(ep, buf, thisObj, -1) < 0) {
- mprFree(buf);
- return -1;
- }
-
- file = mprOpen(ep, fileName,
- O_CREAT | O_TRUNC | O_WRONLY | O_TEXT, 0664);
- if (file == 0) {
- ejsError(ep, EJS_IO_ERROR, "Can't open: %s, %d", fileName,
- mprGetOsError());
- return -1;
- }
-
- len = mprGetBufLength(buf);
- bytes = mprWrite(file, buf->start, len);
- if (bytes != len) {
- ejsError(ep, EJS_IO_ERROR, "Can't write to: %s", fileName);
- mprClose(file);
- return -1;
- }
- mprWrite(file, "\n", 1);
- mprFree(buf);
-
- mprClose(file);
-
- return 0;
-}
-
-/******************************************************************************/
-
-static int toString(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- MprBuf *buf;
-
- buf = mprCreateBuf(ep, E4X_BUF_SIZE, E4X_BUF_MAX);
-
- if (xmlToString(ep, buf, thisObj, -1) < 0) {
- mprFree(buf);
- return -1;
- }
- ejsWriteVarAsString(ep, ep->result, (char*) buf->start);
-
- mprFree(buf);
-
- return 0;
-}
-
-/******************************************************************************/
-/* MOB -- need to support XMLList */
-
-static int xmlToString(Ejs *ep, MprBuf *buf, EjsVar *obj, int indentLevel)
-{
- EjsProperty *pp;
- EjsVar *vp;
- char *varBuf;
- int endTag, sawElements;
-
- if (indentLevel < 0) {
- mprPutStringToBuf(buf, "<?xml version=\"1.0\"?>");
- }
-
- switch (obj->type) {
- case EJS_TYPE_STRING:
- if (obj->flags & EJS_XML_FLAGS_ATTRIBUTE) {
- mprPutFmtStringToBuf(buf, " %s=\"%s\"",
- &ejsGetPropertyPtr(obj)->name[1], obj->string);
- /* No new line */
-
- } else if (obj->flags & EJS_XML_FLAGS_COMMENT) {
- mprPutCharToBuf(buf, '\n');
- indent(buf, indentLevel);
- mprPutFmtStringToBuf(buf, "<!-- %s -->", obj->string);
-
- } else if (obj->flags & EJS_XML_FLAGS_TEXT) {
- mprPutStringToBuf(buf, obj->string);
-
- } else {
-// indent(buf, indentLevel);
- mprPutStringToBuf(buf, obj->string);
-// mprPutCharToBuf(buf, '\n');
- }
- break;
-
- default:
- /* Primitive types come here */
- indent(buf, indentLevel);
- /* MOB -- rc */
- varBuf = ejsVarToString(ep, obj);
- mprPutStringToBuf(buf, varBuf);
- break;
-
- case EJS_TYPE_OBJECT:
- if (obj->objectState->baseClass == ejsGetClass(ep, 0, "XML")) {
- if (!obj->objectState->visited) {
- obj->objectState->visited = 1;
-
- /* MOB -- opt. Flags would be quicker */
- if (strcmp(ejsGetPropertyPtr(obj)->name,
- E4X_PARENT_PROPERTY) == 0) {
- return 0;
- }
- /*
- * MOB -- short term fix for tags with no body but with
- * attributes
- */
- if (getNumElements(obj) == 0 && 0) {
- /*
- * XML element is simple with no elements, so return just
- * the text.
- */
- if (getText(buf, obj) < 0) {
- ejsError(ep, EJS_IO_ERROR,
- "XML is to big to convert to a string");
- obj->objectState->visited = 0;
- return -1;
- }
-
- } else if (obj->flags & (EJS_XML_FLAGS_ELEMENT)) {
- /*
- * XML object is complex (has elements) so return full XML
- * content.
- */
- mprPutCharToBuf(buf, '\n');
- indent(buf, indentLevel);
-
- /*
- * When called from toString, obj is not a property
- */
- if (indentLevel >= 0) {
- mprPutFmtStringToBuf(buf, "<%s",
- ejsGetPropertyPtr(obj)->name);
- endTag = 0;
-
- } else {
- endTag = 1;
- }
-
- sawElements = 0;
- pp = ejsGetFirstProperty(obj, 0);
- while (pp) {
- vp = ejsGetVarPtr(pp);
-
- if (! (vp->flags & EJS_XML_FLAGS_ATTRIBUTE)) {
- if (endTag == 0) {
- endTag++;
- mprPutStringToBuf(buf, ">");
- }
- }
- if (vp->flags & EJS_XML_FLAGS_ELEMENT) {
- if (strcmp(ejsGetPropertyPtr(vp)->name,
- E4X_PARENT_PROPERTY) != 0) {
- sawElements++;
- }
- }
-
- if (xmlToString(ep, buf, ejsGetVarPtr(pp),
- indentLevel + 1) < 0){
- return -1;
- }
-
- pp = ejsGetNextProperty(pp, 0);
- }
- if (indentLevel >= 0) {
- if (sawElements) {
- mprPutCharToBuf(buf, '\n');
- indent(buf, indentLevel);
- }
- mprPutFmtStringToBuf(buf, "</%s>",
- ejsGetPropertyPtr(obj)->name);
- }
- }
- obj->objectState->visited = 0;
- }
- return 0;
- }
-
- if (obj->objectState->baseClass == ejsGetClass(ep, 0, "XMLList")) {
- indent(buf, indentLevel);
- /* MOB -- TBD */
- return 0;
- }
-
- /*
- * All other objects. Allow other objects to override toString
- */
- if (ejsRunMethod(ep, obj->objectState->baseClass, "toString",
- 0) < 0) {
- return -1;
- }
- if (ejsVarIsString(ep->result)) {
- indent(buf, indentLevel);
- mprPutStringToBuf(buf, obj->string);
- }
- break;
- }
- return 0;
-}
-
-/******************************************************************************/
-
-static void indent(MprBuf *bp, int level)
-{
- int i;
-
- for (i = 0; i < level; i++) {
- mprPutCharToBuf(bp, '\t');
- }
-}
-
-/******************************************************************************/
-
-static int valueOf(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (argc != 0) {
- mprAssert(0);
- return -1;
- }
-
- switch (thisObj->type) {
- default:
- case EJS_TYPE_UNDEFINED:
- case EJS_TYPE_NULL:
- case EJS_TYPE_CMETHOD:
- case EJS_TYPE_OBJECT:
- case EJS_TYPE_METHOD:
- case EJS_TYPE_STRING_CMETHOD:
- ejsWriteVar(ep, ep->result, thisObj, EJS_SHALLOW_COPY);
- break;
-
- case EJS_TYPE_STRING:
- ejsWriteVarAsInteger(ep, ep->result, atoi(thisObj->string));
- break;
-
- case EJS_TYPE_BOOL:
- case EJS_TYPE_INT:
-#if BLD_FEATURE_INT64
- case EJS_TYPE_INT64:
-#endif
-#if BLD_FEATURE_FLOATING_POINT
- case EJS_TYPE_FLOAT:
-#endif
- ejsWriteVar(ep, ep->result, thisObj, EJS_SHALLOW_COPY);
- break;
- }
- return 0;
-}
-
-/******************************************************************************/
-
-static int getList(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- const char *nodeName;
- EjsProperty *pp;
- EjsVar *list, *vp;
-
- if (argc != 1) {
- nodeName = 0;
- } else {
- nodeName = argv[0]->string;
- }
-
- list = ejsCreateArray(ep, 0);
-
- pp = ejsGetFirstProperty(thisObj, EJS_ENUM_ALL);
- while (pp) {
- vp = ejsGetVarPtr(pp);
- if (vp->type == EJS_TYPE_OBJECT) {
- if (strcmp(ejsGetPropertyPtr(vp)->name, E4X_PARENT_PROPERTY) != 0) {
- if (vp->flags & EJS_XML_FLAGS_ELEMENT &&
- (nodeName == 0 || strcmp(nodeName, pp->name) == 0)) {
- ejsAddArrayElt(ep, list, vp, EJS_SHALLOW_COPY);
- }
- }
- }
- pp = ejsGetNextProperty(pp, EJS_ENUM_ALL);
- }
-
- ejsSetReturnValueAndFree(ep, list);
- return 0;
-}
-
-/******************************************************************************/
-
-static int getNumElements(EjsVar *obj)
-{
- EjsProperty *pp;
- int count;
-
- count = 0;
- pp = ejsGetFirstProperty(obj, EJS_ENUM_ALL);
- while (pp) {
- if (ejsGetVarPtr(pp)->flags & EJS_XML_FLAGS_ELEMENT) {
- count++;
- }
- pp = ejsGetNextProperty(pp, EJS_ENUM_ALL);
- }
- return count;
-}
-
-/******************************************************************************/
-/* MOB - This needs to be a public method */
-
-static int getText(MprBuf *buf, EjsVar *obj)
-{
- EjsProperty *pp;
- EjsVar *vp;
-
- pp = ejsGetFirstProperty(obj, EJS_ENUM_ALL);
- while (pp) {
- vp = ejsGetVarPtr(pp);
- if (vp->flags & EJS_XML_FLAGS_TEXT) {
- /* MOB -- should test for overflow */
- mprPutStringToBuf(buf, vp->string);
- }
- pp = ejsGetNextProperty(pp, EJS_ENUM_ALL);
- }
- return 0;
-}
-
-/******************************************************************************/
-/******************************************************************************/
-/******************************** Internal Methods ****************************/
-/******************************************************************************/
-
-static EjsVar *createXmlListProperty(Ejs *ep, EjsVar *obj, const char *property)
-{
- return ejsGetVarPtr(ejsCreateProperty(ep, obj, property));
-}
-
-/******************************************************************************/
-
-static int deleteXmlListProperty(Ejs *ep, EjsVar *obj, const char *property)
-{
- return ejsDeleteProperty(ep, obj, property);
-}
-
-/******************************************************************************/
-
-static EjsVar *getXmlListProperty(Ejs *ep, EjsVar *obj, const char *property)
-{
- // Must always return XML or XMLList event for comments and attributes
- return ejsGetVarPtr(ejsGetSimpleProperty(ep, obj, property));
-}
-
-/******************************************************************************/
-
-static EjsVar *setXmlListProperty(Ejs *ep, EjsVar *obj, const char *property,
- const EjsVar *value)
-{
- EjsProperty *pp;
- EjsVar *vp;
-
- pp = ejsGetSimpleProperty(ep, obj, property);
- if (pp == 0) {
- mprAssert(pp);
- return 0;
- }
- vp = ejsGetVarPtr(pp);
- if (ejsWriteVar(ep, vp, value, EJS_SHALLOW_COPY) < 0){
- mprAssert(0);
- return 0;
- }
- return ejsGetVarPtr(pp);
-}
-
-/******************************************************************************/
-/*
- NEW
-
-static EjsVar *putXmlListProperty(EjsVar *op, const char *property,
- EjsVar *value)
-{
-
- if ((value->objectState->baseClass != XML &&
- value->objectState->baseClass != XMLList) ||
- value->string[0] != '<') {
- c = value.toString();
- } else {
- value = ejsDupVar(value);
- ??
- }
- if (isdigit(*property)) {
- // ERROR
- return 0;
- }
- if (*property == '@') {
- if (op->objectState->baseClass == XMLList) {
- if (op->obj.LENGTH_PROPERTY == 0) {
- c = "";
- } else {
- // Catenate all result of toString on all elts in list
- }
- } else {
- c = c.toString();
- }
- // Replace existing attribute of same name or insert
- return;
- }
- for (i = op->obj.LENGTH - 1; i >= 0; i--) {
- // Delete item of same name
- }
- if (not Found) {
- Append new Xml object
- - set [[name]], [[class]] == "element"
- }
-}
-
- */
-
-/******************************************************************************/
-#else
-void ejs4xDummy() {}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_EJS_E4X */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejs.c b/source4/lib/appweb/ejs-2.0/ejs/ejs.c
deleted file mode 100644
index 0fcc6f0545..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/ejs.c
+++ /dev/null
@@ -1,1378 +0,0 @@
-/*
- * @file ejs.c
- * @brief Embedded JavaScript (EJS)
- * @overview Main module interface logic.
- * @remarks The initialization code must be run single-threaded. Includes:
- * ejsOpen, ejsClose.
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-#if BLD_FEATURE_EJS
-
-/************************************* Code ***********************************/
-/*
- * Initialize the EJS subsystem
- */
-
-EjsService *ejsOpenService(MprCtx ctx)
-{
- EjsService *service;
- Ejs *interp;
-
- service = mprAllocTypeZeroed(ctx, EjsService);
- if (service == 0) {
- mprError(ctx, MPR_LOC, "Can't allocate service memory");
- return 0;
- }
-
- interp = ejsCreateInterp(service, 0, 0, 0, 1);
- if (interp == 0) {
- mprError(ctx, MPR_LOC, "Can't create master interpreter");
- mprFree(service);
- return 0;
- }
- service->master = interp;
-
- /*
- * Restore the default GC settings for the master interpreter.
- * ejsCreateInterp will have initialized them.
- */
- ejsGCInit(interp, EJS_DEFAULT_OBJ_INC, EJS_DEFAULT_PROP_INC,
- EJS_DEFAULT_VAR_INC, EJS_DEFAULT_STR_INC);
-
- /*
- * Save the default interpreter and global class for all to access
- * MOB -- don't store these. Store the service
- */
- mprSetKeyValue(interp, "ejsMaster", interp);
- mprSetKeyValue(interp, "ejsGlobalClass", interp->global);
-
- /*
- * Once the Object class is created, this routine will also make the
- * Global class a subclass of Object.
- */
- if (ejsDefineObjectClass(interp) < 0) {
- mprError(ctx, MPR_LOC, "Can't define EJS object class");
- mprFree(service);
- return 0;
- }
-
- /*
- * Create all the standard classes
- */
- if (ejsDefineStandardClasses(interp) < 0) {
- mprError(ctx, MPR_LOC, "Can't define EJS standard classes");
- mprFree(service);
- return 0;
- }
-
- if (ejsDefineSystemClasses(interp) < 0) {
- mprError(ctx, MPR_LOC, "Can't define EJS system classes");
- mprFree(service);
- return 0;
- }
-
- if (ejsCreateObjectModel(interp) < 0) {
- mprError(ctx, MPR_LOC, "Can't create EJS object model");
- mprFree(service);
- return 0;
- }
-
-#if UNUSED && BLD_FEATURE_ALLOC_STATS
-{
- EjsVar v;
- mprLog(ctx, 0, "Obj %d, Var %d, Prop %d\n", sizeof(EjsObj), sizeof(EjsVar),
- sizeof(EjsProperty));
- mprLog(ctx, 0, "GCLink %d\n", sizeof(EjsGCLink));
- mprLog(ctx, 0, "objectState %d\n", (uint) &v.objectState - (uint) &v);
-}
-#endif
-
- return service;
-}
-
-/******************************************************************************/
-/*
- * Close down the EJS Service
- */
-
-void ejsCloseService(EjsService *sp, bool doStats)
-{
- Ejs *ep;
-
- mprAssert(sp);
-
- ep = sp->master;
- mprAssert(ep);
-
- ejsTermSystemClasses(ep);
-
- if (ep) {
- ejsFreeVar(ep, sp->globalClass);
-
-#if BLD_FEATURE_ALLOC_STATS
- if (doStats) {
- mprLog(sp, 0, "GC Statistics for the Global Interpreter");
- }
-#endif
- ejsDestroyInterp(ep, doStats);
- }
-
- mprRemoveKeyValue(sp, "ejsMaster");
- mprRemoveKeyValue(sp, "ejsGlobalClass");
-
- mprFree(sp);
-}
-
-/******************************************************************************/
-
-Ejs *ejsGetMasterInterp(EjsService *sp)
-{
- return sp->master;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_MULTITHREAD
-
-int ejsSetServiceLocks(EjsService *sp, EjsLockFn lock, EjsUnlockFn unlock,
- void *data)
-{
- mprAssert(sp);
-
- sp->lock = lock;
- sp->unlock = unlock;
- sp->lockData = data;
- return 0;
-}
-
-#endif
-/******************************************************************************/
-/*
- * Create and initialize an EJS interpreter. Interpreters have a global object
- * that has the service global class set as a base class. This way, it
- * inherits all the desired global properties, methods and classes.
- *
- * The primary and alternate handles are provided to C methods depending on
- * the flags provided when the C methods are defined. The global variable
- * (optionally) defines a predefined global variable space.
- */
-
-Ejs *ejsCreateInterp(EjsService *sp, void *primaryHandle, void *altHandle,
- EjsVar *global, bool useOwnSlab)
-{
- EjsProperty *pp;
- EjsVar *baseClass;
- Ejs *ep;
-
- ep = mprAllocTypeZeroed(sp, Ejs);
- if (ep == 0) {
- mprAssert(0);
- return ep;
- }
-
- ep->stkPtr = &ep->stack[EJS_MAX_STACK];
-
- ep->service = sp;
- ep->primaryHandle = primaryHandle;
- ep->altHandle = altHandle;
-
- if (sp->master) {
- ep->objectClass = sp->master->objectClass;
- }
-
- if (useOwnSlab) {
- ep->slabs = (EjsSlab*) mprAllocZeroed(ep, sizeof(EjsSlab) *
- EJS_SLAB_MAX);
- ep->slabAllocContext = ep;
-
- } else {
- ep->slabs = sp->master->slabs;
- ep->slabAllocContext = sp->master;
- ep->flags |= EJS_FLAGS_SHARED_SLAB;
- }
-
- ep->frames = mprCreateItemArray(ep, EJS_INC_FRAMES, EJS_MAX_FRAMES);
- if (ep->frames == 0) {
- mprFree(ep);
- return 0;
- }
-
- ejsGCInit(ep, EJS_OBJ_INC, EJS_PROP_INC, EJS_VAR_INC, EJS_STR_INC);
-
- if (sp->globalClass == 0) {
- /*
- * Only do this for the Global interpreter. Create a global class
- * (prototype) object. This is base class from which all global
- * spaces will inherit.
- */
- sp->globalClass = ejsCreateObjVar(ep);
- if (sp->globalClass == 0) {
- mprFree(ep);
- return 0;
- }
- ejsSetClassName(ep, sp->globalClass, "Global");
- global = sp->globalClass;
- }
-
- if (global) {
- /*
- * The default interpreter uses the Global class as its global
- * space.
- */
- ep->global = ejsDupVar(ep, global, EJS_SHALLOW_COPY);
- if (ep->global == 0) {
- mprFree(ep);
- return 0;
- }
- if (ep->global->objectState != sp->globalClass->objectState) {
- ejsSetBaseClass(ep->global, sp->globalClass);
- }
-
- } else {
- /*
- * Use the global class as our global so we can find the object class
- */
- baseClass = ejsGetClass(ep, sp->globalClass, "Object");
- if (baseClass) {
- ep->global = ejsCreateSimpleObjUsingClass(ep, baseClass);
- if (ep->global == 0) {
- mprFree(ep);
- return 0;
- }
-
- /*
- * Override the base class and set to the master Global class
- */
- ejsSetBaseClass(ep->global, sp->globalClass);
-
- } else {
- ep->global = ejsCreateObjVar(ep);
- }
- }
-
- /*
- * The "global" variable points to the global space
- */
- pp = ejsSetProperty(ep, ep->global, "global", ep->global);
- if (pp == 0) {
- mprFree(ep);
- return 0;
- }
- ejsMakePropertyEnumerable(pp, 0);
-
- /*
- * The "Global" variable points to the Global class
- */
- pp = ejsSetProperty(ep, ep->global, "Global", sp->globalClass);
- if (pp == 0) {
- mprFree(ep);
- return 0;
- }
- ejsMakePropertyEnumerable(pp, 0);
-
- ep->local = ejsDupVar(ep, ep->global, EJS_SHALLOW_COPY);
- if (ep->frames == 0 || ep->global == 0 || ep->local == 0) {
- mprFree(ep);
- return 0;
- }
- ejsSetVarName(ep, ep->local, "topLevelLocal");
-
- if (mprAddItem(ep->frames, ep->global) < 0 ||
- mprAddItem(ep->frames, ep->local) < 0) {
- mprFree(ep);
- return 0;
- }
-
- ep->result = ejsCreateUndefinedVar(ep);
- if (ep->result == 0) {
- mprFree(ep);
- return 0;
- }
-
- return ep;
-}
-
-/******************************************************************************/
-/*
- * Close an EJS interpreter
- */
-
-void ejsDestroyInterp(Ejs *ep, bool doStats)
-{
- ejsCleanInterp(ep, doStats);
-
- mprFree(ep);
-}
-
-/******************************************************************************/
-/*
- * Clean an EJS interpreter of all allocated variables, but DONT destroy.
- * We use this rather than DestroyInterp so we delay freeing the Ejs struct
- * until after the service is closed.
- */
-
-void ejsCleanInterp(Ejs *ep, bool doStats)
-{
- int i;
-
- if (ep->global) {
- ejsDeleteProperty(ep, ep->local, "global");
- ejsDeleteProperty(ep, ep->global, "global");
- ep->global = 0;
- }
- if (ep->local) {
- ejsFreeVar(ep, ep->local);
- ep->local = 0;
- }
- if (ep->global) {
- ejsFreeVar(ep, ep->global);
- ep->global = 0;
- }
- if (ep->result) {
- ejsFreeVar(ep, ep->result);
- ep->result = 0;
- }
- if (ep->castAlloc && ep->castTemp) {
- mprFree(ep->castTemp);
- ep->castTemp = 0;
- }
- if (ep->frames) {
- for (i = ep->frames->length - 1; i >= 0; i--) {
- mprRemoveItemByIndex(ep->frames, i);
- }
- mprFree(ep->frames);
- ep->frames = 0;
- }
-
- if (doStats) {
-
-#if BLD_FEATURE_ALLOC_STATS
- mprLog(ep, 0, " ");
- mprLog(ep, 0, "GC Statistics for Interpreter (0x%X)", (uint) ep);
-#endif
-
- /*
- * Cleanup before printing the alloc report
- */
- ejsSetGCDebugLevel(ep, 3);
- ejsCollectGarbage(ep, -1);
-
-#if BLD_DEBUG
- /*
- * If we are the master, dump objects
- */
- if (ep->service->master == ep) {
- ejsDumpObjects(ep);
- }
-#endif
-
-#if BLD_FEATURE_ALLOC_STATS
- /*
- * Print an alloc report. 1 == do leak report
- */
- ejsPrintAllocReport(ep, 1);
-#endif
-
- } else {
- /*
- * Must collect garbage here incase sharing interpreters with the
- * master. If we don't, the mprFree later in DestroyInterp will free
- * all memory and when the master does GC --> crash.
- */
- ejsCollectGarbage(ep, -1);
- }
-}
-
-/******************************************************************************/
-/*
- * Evaluate an EJS script file. This will evaluate the script at the current
- * context. Ie. if inside a function, declarations will be local.
- */
-
-int ejsEvalFile(Ejs *ep, const char *path, EjsVar *result)
-{
- MprFile *file;
- MprFileInfo info;
- char *script;
- char *saveFileName;
- int rc;
-
- mprAssert(path && *path);
-
- if ((file = mprOpen(ep, path, O_RDONLY | O_BINARY, 0666)) == 0) {
- ejsError(ep, EJS_IO_ERROR, "Can't open %s", path);
- return -1;
- }
-
- if (mprGetFileInfo(ep, path, &info) < 0) {
- ejsError(ep, EJS_IO_ERROR, "Can't get file info for %s", path);
- goto error;
- }
-
- if ((script = (char*) mprAlloc(ep, info.size + 1)) == NULL) {
- ejsError(ep, "MemoryError", "Cant malloc %d", (int) info.size);
- goto error;
- }
-
- if (mprRead(file, script, info.size) != (int) info.size) {
- mprFree(script);
- ejsError(ep, EJS_IO_ERROR, "Error reading %s", path);
- goto error;
- }
- mprClose(file);
- script[info.size] = '\0';
-
- saveFileName = ep->fileName;
- ep->fileName = mprStrdup(ep, path);
-
- rc = ejsEvalScript(ep, script, result);
- mprFree(script);
-
- mprFree(ep->fileName);
- ep->fileName = saveFileName;
-
- return rc;
-
-/*
- * Error return
- */
-error:
- mprClose(file);
- return -1;
-}
-
-/******************************************************************************/
-/*
- * Create a new variable scope block. This pushes the old local frame down
- * the stack and creates a new local variables frame.
- */
-
-int ejsOpenBlock(Ejs *ep)
-{
- EjsProperty *pp;
- int fid;
-
- ep->local = ejsCreateSimpleObj(ep, "Object");
- ejsSetVarName(ep, ep->local, "local");
-
- if (ep->local == 0) {
- ejsMemoryError(ep);
- return -1;
- }
-
- if (ep->frames->length > EJS_MAX_FRAMES && !ep->gotException) {
- ejsError(ep, EJS_RANGE_ERROR, "Recursion too deep: Max depth %d",
- EJS_MAX_FRAMES);
- return -1;
- }
-
- /*
- * Must add to frames before ejsSetProperty which will make the object live
- */
- fid = mprAddItem(ep->frames, ep->local);
- if (fid < 0) {
- ejsMemoryError(ep);
- return -1;
- }
-
- /* Self reference */
- pp = ejsSetProperty(ep, ep->local, "local", ep->local);
- ejsMakePropertyEnumerable(pp, 0);
-
- return fid;
-}
-
-/******************************************************************************/
-/*
- * Set a new variable scope block. This pushes the old local frame down
- * the stack and creates a new local variables frame.
- */
-
-int ejsSetBlock(Ejs *ep, EjsVar *local)
-{
- ep->local = ejsDupVar(ep, local, EJS_SHALLOW_COPY);
- ejsMakeObjPermanent(ep->local, 1);
- return mprAddItem(ep->frames, ep->local);
-}
-
-/******************************************************************************/
-/*
- * Close a variable scope block opened via ejsOpenBlock. Pop back the old
- * local variables frame.
- */
-
-int ejsCloseBlock(Ejs *ep, int fid)
-{
- mprAssert(ep->local >= 0);
- mprAssert(fid >= 0);
-
- mprAssert(ep->local == (EjsVar*) mprGetItem(ep->frames, fid));
-
- if (ep->local) {
- /* Allow GC */
- ejsMakeObjPermanent(ep->local, 0);
- ejsFreeVar(ep, ep->local);
- }
-
- mprRemoveItemByIndex(ep->frames, fid);
-
- ep->local = (EjsVar*) mprGetItem(ep->frames,
- mprGetItemCount(ep->frames) - 1);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Create a new variable scope block and evaluate a script. All frames
- * created during this context will be automatically deleted when complete.
- * vp is optional. i.e. created local variables will be discarded
- * when this routine returns.
- */
-
-int ejsEvalBlock(Ejs *ep, char *script, EjsVar *vp)
-{
- int rc, fid;
-
- mprAssert(script);
-
- fid = ejsOpenBlock(ep);
- if (fid < 0) {
- return fid;
- }
-
- rc = ejsEvalScript(ep, script, vp);
-
- ejsCloseBlock(ep, fid);
-
- return rc;
-}
-
-/******************************************************************************/
-/*
- * Parse and evaluate a EJS. The script is evaluated at the current context.
- * Return the result in *vp. The result is "owned" by EJ and the caller
- * must not free it. Returns -1 on errors and zero for success.
- */
-
-int ejsEvalScript(Ejs *ep, const char *script, EjsVar *vp)
-{
- int state;
-
- ejsClearVar(ep, ep->result);
- ep->gotException = 0;
-
- if (script == 0) {
- return 0;
- }
-
- /*
- * Allocate a new evaluation block, and save the old one
- */
- if (ejsLexOpenScript(ep, script) < 0) {
- return MPR_ERR_MEMORY;
- }
-
- /*
- * Do the actual parsing and evaluation
- */
- ep->scriptStatus = 0;
-
- do {
- state = ejsParse(ep, EJS_STATE_BEGIN, EJS_FLAGS_EXE);
-
- if (state == EJS_STATE_RET) {
- state = EJS_STATE_EOF;
- }
- } while (state != EJS_STATE_EOF && state != EJS_STATE_ERR);
-
- ejsLexCloseScript(ep);
-
- if (state == EJS_STATE_ERR) {
- return -1;
- }
-
- if (vp) {
- /* Caller must not free. */
- *vp = *ep->result;
- }
-
- return ep->scriptStatus;
-}
-
-/******************************************************************************/
-
-void ejsSetFileName(Ejs *ep, const char *fileName)
-{
- mprFree(ep->fileName);
- ep->fileName = mprStrdup(ep, fileName);
-}
-
-/******************************************************************************/
-/*
- * Format the stack backtrace
- */
-
-char *ejsFormatStack(Ejs* ep)
-{
- EjsInput *ip;
- char *errbuf;
- int frame, len;
-
- mprAssert(ep);
-
- ip = ep->input;
-
- errbuf = 0;
-
- len = 0;
- frame = 0;
- while (ip && frame < EJS_MAX_BACKTRACE) {
- char *traceLine, *newErrbuf, *line;
- for (line = ip->line; *line && isspace(*line); line++) {
- ;
- }
- mprAllocSprintf(MPR_LOC_ARGS(ep), &traceLine, MPR_MAX_STRING,
- " [%02d] %s, %s, line %d -> %s\n",
- frame++,
- ip->fileName ? ip->fileName : "script",
- ip->procName ? ip->procName: "global",
- ip->lineNumber, line);
- if (traceLine == 0) {
- break;
- }
- newErrbuf = mprRealloc(ep, errbuf, len + strlen(traceLine) + 1);
- if (newErrbuf == NULL) {
- break;
- }
- errbuf = newErrbuf;
- memcpy(&errbuf[len], traceLine, strlen(traceLine) + 1);
- len += strlen(traceLine);
- mprFree(traceLine);
- ip = ip->next;
- }
- return errbuf;
-}
-
-/******************************************************************************/
-/*
- * Internal use method to set the error message
- *
- * Error, ArgError, AssertError, IOError, MemoryError, RangeError,
- * ReferenceError, SyntaxError, TypeError, MemoryError
- */
-
-void ejsError(Ejs* ep, const char *errorType, const char* fmt, ...)
-{
- va_list fmtArgs;
- EjsVar *error;
- char *msg, *stack;
-
- va_start(fmtArgs, fmt);
- mprAllocVsprintf(MPR_LOC_ARGS(ep), &msg, MPR_MAX_STRING, fmt, fmtArgs);
- va_end(fmtArgs);
-
- /*
- * Create a new Error exception object. If bad error type, default to
- * "Error"
- */
- if (ejsGetClass(ep, 0, errorType) == 0) {
- errorType = "Error";
- }
- ep->gotException = 1;
-
- error = ejsCreateObj(ep, 0, errorType, msg);
- if (error == 0) {
- return;
- }
- mprFree(msg);
-
- stack = ejsFormatStack(ep);
- ejsSetPropertyToString(ep, error, "stack", stack);
- mprFree(stack);
-
- ejsWriteVar(ep, ep->result, error, EJS_SHALLOW_COPY);
- ejsFreeVar(ep, error);
-}
-
-/******************************************************************************/
-
-void ejsSyntaxError(Ejs *ep, const char *msg)
-{
- if (msg == 0) {
- msg = " ";
- }
- ejsError(ep, EJS_SYNTAX_ERROR, msg);
-}
-
-/******************************************************************************/
-
-void ejsMemoryError(Ejs *ep)
-{
- ejsError(ep, EJS_MEMORY_ERROR, "Memory allocation error");
-}
-
-/******************************************************************************/
-
-void ejsArgError(Ejs *ep, const char *msg)
-{
- mprAssert(msg && *msg);
-
- ejsError(ep, EJS_ARG_ERROR, msg);
-}
-
-/******************************************************************************/
-
-void ejsInternalError(Ejs *ep, const char *msg)
-{
- mprAssert(msg && *msg);
-
- ejsError(ep, EJS_INTERNAL_ERROR, msg);
-}
-
-/******************************************************************************/
-/*
- * Public routine to set the error message. Caller MUST NOT free.
- */
-
-char *ejsGetErrorMsg(Ejs *ep)
-{
- EjsVar *error;
- const char *message, *stack, *name;
- char *buf;
-
- error = ep->result;
-
- if (! ejsVarIsObject(error)) {
- name = message = stack = 0;
- } else {
- name = ejsGetPropertyAsString(ep, error, "name");
- message = ejsGetPropertyAsString(ep, error, "message");
- stack = ejsGetPropertyAsString(ep, error, "stack");
- }
- if (name == 0 || message == 0) {
- buf = mprStrdup(ep, "Unspecified execution error\n");
- } else {
- mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0,
- "%s Exception: %s\nStack:\n%s\n",
- name, message, stack ? stack : " " );
- }
- mprFree(ep->errorMsg);
- ep->errorMsg = buf;
- return buf;
-}
-
-/******************************************************************************/
-/*
- * Get the current line number
- */
-
-int ejsGetLineNumber(Ejs *ep)
-{
- if (ep->input == 0) {
- return -1;
- }
- return ep->input->lineNumber;
-}
-
-/******************************************************************************/
-/*
- * Return the local object
- */
-
-EjsVar *ejsGetLocalObj(Ejs *ep)
-{
- return ep->local;
-}
-
-/******************************************************************************/
-/*
- * Return the global object
- */
-
-EjsVar *ejsGetGlobalObj(Ejs *ep)
-{
- return ep->global;
-}
-
-/******************************************************************************/
-/*
- * Set the expression return value
- */
-
-void ejsSetReturnValue(Ejs *ep, EjsVar *vp)
-{
- mprAssert(ep);
- mprAssert(vp);
-
- if (vp == 0) {
- return;
- }
- ejsWriteVar(ep, ep->result, vp, EJS_SHALLOW_COPY);
-}
-
-/******************************************************************************/
-/*
- * Set the expression return value and free the arg.
- */
-
-void ejsSetReturnValueAndFree(Ejs *ep, EjsVar *vp)
-{
- mprAssert(ep);
- mprAssert(vp);
-
- ejsWriteVar(ep, ep->result, vp, EJS_SHALLOW_COPY);
- ejsFreeVar(ep, vp);
-}
-
-/******************************************************************************/
-/*
- * Set the expression return value to a string value.
- */
-
-void ejsSetReturnValueToString(Ejs *ep, const char *value)
-{
- mprAssert(ep);
- mprAssert(value);
-
- ejsWriteVarAsString(ep, ep->result, value);
-}
-
-/******************************************************************************/
-/*
- * Set the expression return value to a binary string value.
- */
-
-void ejsSetReturnValueToBinaryString(Ejs *ep, const uchar *value, int len)
-{
- mprAssert(ep);
- mprAssert(value);
-
- ejsWriteVarAsBinaryString(ep, ep->result, value, len);
-}
-
-/******************************************************************************/
-/*
- * Set the expression return value to a integer value.
- */
-
-void ejsSetReturnValueToInteger(Ejs *ep, int value)
-{
- mprAssert(ep);
-
- ejsWriteVarAsInteger(ep, ep->result, value);
-}
-
-/******************************************************************************/
-/*
- * Set the expression return value to an EjsNum value.
- */
-
-void ejsSetReturnValueToNumber(Ejs *ep, EjsNum value)
-{
- mprAssert(ep);
-
- ejsWriteVarAsNumber(ep, ep->result, value);
-}
-
-/******************************************************************************/
-/*
- * Set the expression return value to a boolean value.
- */
-
-void ejsSetReturnValueToBoolean(Ejs *ep, int value)
-{
- mprAssert(ep);
-
- ejsWriteVarAsBoolean(ep, ep->result, value);
-}
-
-/******************************************************************************/
-/*
- * Set the expression return value to a boolean value.
- */
-
-void ejsSetReturnValueToUndefined(Ejs *ep)
-{
- mprAssert(ep);
-
- ejsWriteVarAsUndefined(ep, ep->result);
-}
-
-/******************************************************************************/
-/*
- * Get the expression return value
- */
-
-EjsVar *ejsGetReturnValue(Ejs *ep)
-{
- mprAssert(ep);
-
- return ep->result;
-}
-
-/******************************************************************************/
-
-void *ejsGetUserData(Ejs *ep)
-{
- mprAssert(ep);
-
- return ep->userData;
-}
-
-/******************************************************************************/
-/*
- * Get a variable given a full variable spec possibly containing "." or "[]".
- */
-
-EjsVar *ejsGetVar(Ejs *ep, const char *fullName)
-{
- mprAssert(ep);
- mprAssert(fullName && *fullName);
-
- return ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 0);
-}
-
-/******************************************************************************/
-/*
- * Get a string var given a full variable spec possibly containing "." or "[]".
- */
-
-const char *ejsGetStr(Ejs *ep, const char *fullName, const char *defaultValue)
-{
- EjsVar *vp;
-
- mprAssert(fullName && *fullName);
-
- vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 0);
- if (vp == 0 || !ejsVarIsString(vp)) {
- return defaultValue;
- }
- /* MOB -- what about VarToStr */
- return vp->string;
-}
-
-/******************************************************************************/
-/*
- * Get an int var given a full variable spec possibly containing "." or "[]".
- */
-
-int ejsGetInt(Ejs *ep, const char *fullName, int defaultValue)
-{
- EjsVar *vp;
-
- mprAssert(ep);
- mprAssert(fullName && *fullName);
-
- vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 0);
- if (vp == 0 || !ejsVarIsInteger(vp)) {
- return defaultValue;
- }
- /* MOB -- should use VarToInt */
- return vp->integer;
-}
-
-/******************************************************************************/
-/*
- * Get an bool var given a full variable spec possibly containing "." or "[]".
- */
-
-int ejsGetBool(Ejs *ep, const char *fullName, int defaultValue)
-{
- EjsVar *vp;
-
- mprAssert(ep);
- mprAssert(fullName && *fullName);
-
- vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 0);
- if (vp == 0 || !ejsVarIsBoolean(vp)) {
- return defaultValue;
- }
- /* MOB -- should use VarToBool */
- return vp->boolean;
-}
-
-/******************************************************************************/
-/*
- * Set a variable that may be an arbitrarily complex object or array reference.
- * Will always define in the top most variable frame.
- */
-
-int ejsSetVar(Ejs *ep, const char *fullName, const EjsVar *value)
-{
- EjsVar *vp;
-
- mprAssert(fullName && *fullName);
-
- vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 1);
- if (vp == 0) {
- return MPR_ERR_CANT_CREATE;
- }
-
- if (ejsWriteVar(ep, vp, value, EJS_SHALLOW_COPY) == 0) {
- return MPR_ERR_CANT_WRITE;
- }
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Set a variable that may be an arbitrarily complex object or array reference.
- * Will always define in the top most variable frame.
- */
-
-int ejsSetStr(Ejs *ep, const char *fullName, const char *value)
-{
- EjsVar *vp;
-
- mprAssert(fullName && *fullName);
-
- vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 1);
- if (vp == 0) {
- return MPR_ERR_CANT_CREATE;
- }
-
- if (ejsWriteVarAsString(ep, vp, value) == 0) {
- return MPR_ERR_CANT_WRITE;
- }
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Set a variable that may be an arbitrarily complex object or array reference.
- * Will always define in the top most variable frame.
- */
-
-int ejsSetInt(Ejs *ep, const char *fullName, int value)
-{
- EjsVar *vp;
-
- mprAssert(fullName && *fullName);
-
- vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 1);
- if (vp == 0) {
- return MPR_ERR_CANT_CREATE;
- }
-
- /* Can't fail */
- ejsWriteVarAsInteger(ep, vp, value);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Set a variable that may be an arbitrarily complex object or array reference.
- * Will always define in the top most variable frame.
- */
-
-int ejsSetBool(Ejs *ep, const char *fullName, bool value)
-{
- EjsVar *vp;
-
- mprAssert(fullName && *fullName);
-
- vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 1);
- if (vp == 0) {
- return MPR_ERR_CANT_CREATE;
- }
-
- /* Can't fail */
- ejsWriteVarAsBoolean(ep, vp, value);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Set a variable that may be an arbitrarily complex object or array reference.
- * Will always define in the top most variable frame. Free the value passed in.
- */
-
-int ejsSetVarAndFree(Ejs *ep, const char *fullName, EjsVar *value)
-{
- EjsVar *vp;
-
- mprAssert(fullName && *fullName);
-
- vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 1);
- if (vp == 0) {
- return MPR_ERR_CANT_CREATE;
- }
-
- if (ejsWriteVar(ep, vp, value, EJS_SHALLOW_COPY) == 0) {
- ejsFreeVar(ep, value);
- return MPR_ERR_CANT_WRITE;
- }
-
- ejsFreeVar(ep, value);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Delete a variable
- */
-
-int ejsDeleteVar(Ejs *ep, const char *fullName)
-{
- EjsVar *vp;
- EjsVar *obj;
- char *propertyName;
-
- vp = ejsFindProperty(ep, &obj, &propertyName, ep->global, ep->local,
- fullName, 0);
- if (vp == 0) {
- return -1;
- }
-
- mprAssert(propertyName);
- mprAssert(propertyName);
-
- return ejsDeleteProperty(ep, obj, propertyName);
-}
-
-/******************************************************************************/
-/*
- * Utility routine to crack JavaScript arguments. Return the number of args
- * seen. This routine only supports %s and %d type args.
- *
- * Typical usage:
- *
- * if (ejsParseArgs(argc, argv, "%s %d", &name, &age) < 2) {
- * // Insufficient args
- * return -1;
- * }
- */
-
-int ejsParseArgs(int argc, char **argv, const char *fmt, ...)
-{
- va_list vargs;
- const char *cp;
- char **sp, *s;
- int *bp, *ip, argn;
-
- va_start(vargs, fmt);
-
- if (argv == 0) {
- return 0;
- }
-
- for (argn = 0, cp = fmt; cp && *cp && argn < argc && argv[argn]; ) {
- if (*cp++ != '%') {
- continue;
- }
-
- s = argv[argn];
- switch (*cp) {
- case 'b':
- bp = va_arg(vargs, int*);
- if (bp) {
- if (strcmp(s, "true") == 0 || s[0] == '1') {
- *bp = 1;
- } else {
- *bp = 0;
- }
- } else {
- *bp = 0;
- }
- break;
-
- case 'd':
- ip = va_arg(vargs, int*);
- *ip = atoi(s);
- break;
-
- case 's':
- sp = va_arg(vargs, char**);
- *sp = s;
- break;
-
- default:
- mprAssert(0);
- }
- argn++;
- }
-
- va_end(vargs);
- return argn;
-}
-
-/******************************************************************************/
-/*
- * Define the standard classes
- */
-
-int ejsDefineStandardClasses(Ejs *master)
-{
- if (ejsDefineArrayClass(master) != 0 ||
- ejsDefineBooleanClass(master) != 0 ||
- ejsDefineErrorClasses(master) != 0 ||
- ejsDefineFunctionClass(master) != 0 ||
- ejsDefineNumberClass(master) != 0 ||
-#if FUTURE
- ejsDefineDateClass(master) != 0 ||
-#endif
-#if BLD_FEATURE_EJS_E4X
- ejsDefineXmlClasses(master) != 0 ||
-#endif
-#if BLD_FEATURE_EJS_DB && NOT_HERE
- ejsDefineDbClasses(master) != 0 ||
-#endif
- ejsDefineStringClass(master) != 0) {
- return MPR_ERR_MEMORY;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Define the EJS System Object Model
- */
-
-int ejsDefineSystemClasses(Ejs *master)
-{
- if (ejsDefineSystemClass(master) != 0 ||
- ejsDefineAppClass(master) != 0 ||
- ejsDefineMemoryClass(master) != 0 ||
- ejsDefineLogClass(master) != 0 ||
- ejsDefineDebugClass(master) != 0 ||
- ejsDefineGCClass(master) != 0 ||
- ejsDefineFileSystemClass(master) != 0 ||
-#if BREW
- ejsDefineFileClass(master) != 0 ||
- ejsDefineHTTPClass(master) != 0 ||
-#endif
- ejsDefineGlobalProperties(master) != 0) {
- return MPR_ERR_MEMORY;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Terminate the system object model and classes
- */
-
-int ejsTermSystemClasses(Ejs *master)
-{
-#if BREW
- ejsTermHTTPClass(master);
-#endif
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Define the EJS object model
- */
-
-int ejsCreateObjectModel(Ejs *ejs)
-{
- EjsProperty *pp;
-
- pp = ejsSetPropertyToNewObj(ejs, ejs->global, "system", "System", 0);
- if (pp == 0) {
- return MPR_ERR_MEMORY;
- }
-
- if (ejsSetPropertyToNewObj(ejs, ejsGetVarPtr(pp), "app", "System.App",
- 0) == 0) {
- return MPR_ERR_MEMORY;
- }
- return 0;
-}
-
-/******************************************************************************/
-
-void ejsTrace(Ejs *ep, const char *fmt, ...)
-{
- va_list args;
- char buf[MPR_MAX_LOG_STRING];
- int len;
-
- va_start(args, fmt);
- len = mprVsprintf(buf, sizeof(buf) - 1, fmt, args);
- va_end(args);
-
- mprLog(ep, 0, buf, len);
-
- va_end(args);
-}
-
-/******************************************************************************/
-
-bool ejsGotException(Ejs *ep)
-{
- return (bool) ep->gotException;
-}
-
-/******************************************************************************/
-
-void ejsSetPrimaryHandle(Ejs *ep, void *primaryHandle)
-{
- mprAssert(ep);
-
- ep->primaryHandle = primaryHandle;
-}
-
-/******************************************************************************/
-
-void ejsSetAlternateHandle(Ejs *ep, void *alternateHandle)
-{
- mprAssert(ep);
-
- ep->altHandle = alternateHandle;
-}
-
-/******************************************************************************/
-
-#else
-void ejsDummy() {}
-
-#endif /* BLD_FEATURE_EJS */
-
-/******************************************************************************/
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejs.h b/source4/lib/appweb/ejs-2.0/ejs/ejs.h
deleted file mode 100644
index a926446524..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/ejs.h
+++ /dev/null
@@ -1,849 +0,0 @@
-/*
- * ejs.h - EJScript Language (ECMAScript) header.
- */
-
-/********************************* Copyright **********************************/
-/*
- * @copy default.g
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved.
- * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#ifndef _h_EJS
-#define _h_EJS 1
-
-#include "mpr.h"
-#include "ejsVar.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/********************************* Prototypes *********************************/
-/*
- * Constants
- */
-#if BLD_FEATURE_SQUEEZE
- #define EJS_GC_WORK_QUOTA 160 /* Allocations required before
- garbage colllection */
-
- #define EJS_PARSE_INCR 256 /* Growth factor */
- #define EJS_MAX_RECURSE 25 /* Sanity for maximum recursion */
- #define EJS_SMALL_OBJ_HASH_SIZE 11 /* Small object hash size */
- #define EJS_LIST_INCR 8 /* Growth increment for lists */
- #define EJS_MAX_BACKTRACE 10 /* Recursion limit for assert */
-
-#else
- #define EJS_GC_WORK_QUOTA 500
-
- #define EJS_PARSE_INCR 1024
- #define EJS_MAX_RECURSE 100
- #define EJS_SMALL_OBJ_HASH_SIZE 11
- #define EJS_LIST_INCR 16
- #define EJS_MAX_BACKTRACE 25
-
-#endif
-
-/*
- * Allocation increments for the default interpreter
- */
-#define EJS_DEFAULT_VAR_INC 8 /* Var allocation increment */
-#define EJS_DEFAULT_PROP_INC 96 /* Property allocation increment */
-#define EJS_DEFAULT_OBJ_INC 24 /* Object allocation increment */
-#define EJS_DEFAULT_STR_INC 64 /* Object allocation increment */
-
-#define EJS_MIN_TIME_FOR_GC 300 /**< Need 1/3 sec for GC */
-#define EJS_GC_MIN_WORK_QUOTA 50 /**< Min to stop thrashing */
-
-/*
- * Allocation increments for all non-default interpreters
- */
-#define EJS_VAR_INC 32
-#define EJS_PROP_INC 64
-#define EJS_OBJ_INC 64
-#define EJS_STR_INC 64
-
-#define EJS_INC_FRAMES 8 /* Frame stack increment */
-#define EJS_MAX_FRAMES 64 /* Max frame stack */
-
-/*
- * Lexical analyser tokens
- */
-#define EJS_TOK_ERR -1 /* Any error */
-#define EJS_TOK_LPAREN 1 /* ( */
-#define EJS_TOK_RPAREN 2 /* ) */
-#define EJS_TOK_IF 3 /* if */
-#define EJS_TOK_ELSE 4 /* else */
-#define EJS_TOK_LBRACE 5 /* { */
-#define EJS_TOK_RBRACE 6 /* } */
-#define EJS_TOK_LOGICAL 7 /* ||, &&, ! */
-#define EJS_TOK_EXPR 8 /* +, -, /, % */
-#define EJS_TOK_SEMI 9 /* ; */
-#define EJS_TOK_LITERAL 10 /* literal string */
-#define EJS_TOK_METHOD_NAME 11 /* methodName( */
-#define EJS_TOK_NEWLINE 12 /* newline white space */
-#define EJS_TOK_ID 13 /* Identifier */
-#define EJS_TOK_EOF 14 /* End of script */
-#define EJS_TOK_COMMA 15 /* Comma */
-#define EJS_TOK_VAR 16 /* var */
-#define EJS_TOK_ASSIGNMENT 17 /* = */
-#define EJS_TOK_FOR 18 /* for */
-#define EJS_TOK_INC_DEC 19 /* ++, -- */
-#define EJS_TOK_RETURN 20 /* return */
-#define EJS_TOK_PERIOD 21 /* . */
-#define EJS_TOK_LBRACKET 22 /* [ */
-#define EJS_TOK_RBRACKET 23 /* ] */
-#define EJS_TOK_NEW 24 /* new */
-#define EJS_TOK_DELETE 25 /* delete */
-#define EJS_TOK_IN 26 /* in */
-#define EJS_TOK_FUNCTION 27 /* function */
-#define EJS_TOK_NUMBER 28 /* Number */
-#define EJS_TOK_CLASS 29 /* class */
-#define EJS_TOK_EXTENDS 30 /* extends */
-#define EJS_TOK_PUBLIC 31 /* public */
-#define EJS_TOK_PRIVATE 32 /* private */
-#define EJS_TOK_PROTECTED 33 /* private */
-#define EJS_TOK_TRY 34 /* try */
-#define EJS_TOK_CATCH 35 /* catch */
-#define EJS_TOK_FINALLY 36 /* finally */
-#define EJS_TOK_THROW 37 /* throw */
-#define EJS_TOK_COLON 38 /* : */
-#define EJS_TOK_GET 39 /* get */
-#define EJS_TOK_SET 40 /* set */
-#define EJS_TOK_MODULE 41 /* module */
-#define EJS_TOK_EACH 42 /* each */
-
-/*
- * Expression operators
- */
-#define EJS_EXPR_LESS 1 /* < */
-#define EJS_EXPR_LESSEQ 2 /* <= */
-#define EJS_EXPR_GREATER 3 /* > */
-#define EJS_EXPR_GREATEREQ 4 /* >= */
-#define EJS_EXPR_EQ 5 /* == */
-#define EJS_EXPR_NOTEQ 6 /* != */
-#define EJS_EXPR_PLUS 7 /* + */
-#define EJS_EXPR_MINUS 8 /* - */
-#define EJS_EXPR_DIV 9 /* / */
-#define EJS_EXPR_MOD 10 /* % */
-#define EJS_EXPR_LSHIFT 11 /* << */
-#define EJS_EXPR_RSHIFT 12 /* >> */
-#define EJS_EXPR_MUL 13 /* * */
-#define EJS_EXPR_ASSIGNMENT 14 /* = */
-#define EJS_EXPR_INC 15 /* ++ */
-#define EJS_EXPR_DEC 16 /* -- */
-#define EJS_EXPR_BOOL_COMP 17 /* ! */
-
-/*
- * Conditional operators
- */
-#define EJS_COND_AND 1 /* && */
-#define EJS_COND_OR 2 /* || */
-#define EJS_COND_NOT 3 /* ! */
-
-/**
- * EJ Parsing States. Error and Return are be negative.
- */
-#define EJS_STATE_ERR -1 /**< Error state */
-#define EJS_STATE_RET -2 /**< Return statement */
-#define EJS_STATE_EOF -3 /**< End of file */
-#define EJS_STATE_COND 2 /* Parsing a conditional stmt */
-#define EJS_STATE_COND_DONE 3
-#define EJS_STATE_RELEXP 4 /* Parsing a relational expr */
-#define EJS_STATE_RELEXP_DONE 5
-#define EJS_STATE_EXPR 6 /* Parsing an expression */
-#define EJS_STATE_EXPR_DONE 7
-#define EJS_STATE_STMT 8 /* Parsing General statement */
-#define EJS_STATE_STMT_DONE 9
-#define EJS_STATE_STMT_BLOCK_DONE 10 /* End of block "}" */
-#define EJS_STATE_ARG_LIST 11 /* Method arg list */
-#define EJS_STATE_ARG_LIST_DONE 12
-#define EJS_STATE_DEC_LIST 16 /* Declaration list */
-#define EJS_STATE_DEC_LIST_DONE 17
-#define EJS_STATE_DEC 18 /* Declaration statement */
-#define EJS_STATE_DEC_DONE 19
-
-#define EJS_STATE_BEGIN EJS_STATE_STMT
-
-/*
- * General parsing flags.
- */
-#define EJS_FLAGS_EXE 0x1 /* Execute statements */
-#define EJS_FLAGS_LOCAL 0x2 /* Get local vars only */
-#define EJS_FLAGS_GLOBAL 0x4 /* Get global vars only */
-#define EJS_FLAGS_CREATE 0x8 /* Create var */
-#define EJS_FLAGS_ASSIGNMENT 0x10 /* In assignment stmt */
-#define EJS_FLAGS_DELETE 0x20 /* Deleting a variable */
-#define EJS_FLAGS_NEW 0x80 /* In a new stmt() */
-#define EJS_FLAGS_EXIT 0x100 /* Must exit */
-#define EJS_FLAGS_LHS 0x200 /* Left-hand-side of assignment */
-#define EJS_FLAGS_FORIN 0x400 /* In "for (v in ..." */
-#define EJS_FLAGS_CLASS_DEC 0x800 /* "class name [extends] name " */
-#define EJS_FLAGS_TRY 0x2000 /* In a try {} block */
-#define EJS_FLAGS_CATCH 0x4000 /* "catch (variable)" */
-#define EJS_FLAGS_DONT_GC 0x8000 /* Don't garbage collect */
-#define EJS_FLAGS_NO_ARGS 0x10000 /* Accessors don't use args */
-#define EJS_FLAGS_ENUM_HIDDEN 0x20000 /* Enumerate hidden fields */
-#define EJS_FLAGS_ENUM_BASE 0x40000 /* Enumerate base classes */
-#define EJS_FLAGS_TRACE_ARGS 0x80000 /* Support for printv */
-#define EJS_FLAGS_SHARED_SLAB 0x100000/* Using a shared slab */
-
-/*
- * Exceptions
- */
-#define EJS_ARG_ERROR "ArgError" /**< Method argument error */
-#define EJS_ASSERT_ERROR "AssertError" /**< Assertion error */
-#define EJS_EVAL_ERROR "EvalError" /**< General evalation error */
-#define EJS_INTERNAL_ERROR "InternalError" /**< Internal error */
-#define EJS_IO_ERROR "IOError" /**< IO or data error */
-#define EJS_MEMORY_ERROR "MemoryError" /**< Memory allocation error */
-#define EJS_RANGE_ERROR "RangeError" /**< Data out of range (div by 0) */
-#define EJS_REFERENCE_ERROR "ReferenceError"/**< Object or property reference */
-#define EJS_SYNTAX_ERROR "SyntaxError" /**< Javascript syntax error */
-#define EJS_TYPE_ERROR "TypeError" /**< Wrong type supplied */
-
-/*
- * E4X
- */
-#if BLD_FEATURE_EJS_E4X
-#if BLD_FEATURE_SQUEEZE
-#define E4X_BUF_SIZE 512 /* Initial buffer size for tokens */
-#define E4X_BUF_MAX (32 * 1024) /* Max size for tokens */
-#define E4X_MAX_NODE_DEPTH 24 /* Max nesting of tags */
-#else
-#define E4X_BUF_SIZE 4096
-#define E4X_BUF_MAX (128 * 1024)
-#define E4X_MAX_NODE_DEPTH 128
-#endif
-
-#define E4X_MAX_ELT_SIZE (E4X_BUF_MAX-1)
-#define E4X_TEXT_PROPERTY "-txt"
-#define E4X_TAG_NAME_PROPERTY "-tag"
-#define E4X_COMMENT_PROPERTY "-com"
-#define E4X_ATTRIBUTES_PROPERTY "-att"
-#define E4X_PI_PROPERTY "-pi"
-#define E4X_PARENT_PROPERTY "-parent"
-#endif
-
-#if BLD_FEATURE_MULTITHREAD
-/**
- * Multithreaded lock function
- */
-typedef void (*EjsLockFn)(void *lockData);
-/**
- * Multithreaded unlock function
- */
-typedef void (*EjsUnlockFn)(void *lockData);
-#endif
-
-/*
- * Token limits
- */
-#define EJS_MAX_LINE 128 /* Maximum input line buffer */
-#define EJS_MAX_TOKEN 640 /* Max input parse token */
-#define EJS_TOKEN_STACK 3 /* Put back token stack */
-
-/*
- * Putback token
- */
-
-typedef struct EjsToken {
- char tokbuf[EJS_MAX_TOKEN];
- int tid; /* Token ID */
-} EjsToken;
-
-/*
- * EJ evaluation block structure
- */
-typedef struct EjsInput {
- EjsToken putBack[EJS_TOKEN_STACK]; /* Put back token stack */
- int putBackIndex; /* Top of stack index */
- char line[EJS_MAX_LINE]; /* Current line */
- char *fileName; /* File or script name */
- int lineLength; /* Current line length */
- int lineNumber; /* Parse line number */
- int lineColumn; /* Column in line */
- struct EjsInput *next; /* Used for backtraces */
- const char *procName; /* Gives name in backtrace */
- const char *script; /* Input script for parsing */
- char *scriptServp; /* Next token in the script */
- int scriptSize; /* Length of script */
- char tokbuf[EJS_MAX_TOKEN]; /* Current token */
- int tid; /* Token ID */
- char *tokEndp; /* Pointer past end of token */
- char *tokServp; /* Pointer to next token char */
- struct EjsInput *nextInput; /* Free list of input structs */
-} EjsInput;
-
-/*
- * Method call structure
- */
-typedef struct EjsProc {
- MprArray *args; /* Args for method */
- EjsVar *fn; /* Method definition */
- char *procName; /* Method name */
-} EjsProc;
-
-
-/**
- * @overview EJScript Service structure
- * @description The EJScript service manages the overall language runtime. It
- * is the factory that creates interpreter instances via ejsCreateInterp.
- * The EJScript service creates a master interpreter that holds the
- * standard language classes and properties. When user interpreters are
- * created, they reference (without copying) the master interpreter to
- * gain access to the standard classes and types.
- * @stability Prototype.
- * @library libejs.
- * @see ejsOpenService, ejsCloseService, ejsCreateInterp, ejsDestoryInterp
- */
-typedef struct EjsService {
- EjsVar *globalClass; /* Global class */
- struct Ejs *master; /* Master Interp inherited by all */
-#if BLD_FEATURE_MULTITHREAD
- EjsLockFn lock;
- EjsUnlockFn unlock;
- void *lockData;
-#endif
-} EjsService;
-
-
-/*
- * Memory statistics
- */
-typedef struct EjsMemStats {
- uint maxMem;
- uint usedMem;
-} EjsMemStats;
-
-
-/*
- * Garbage collection block alignment
- */
-#define EJS_ALLOC_ALIGN(ptr) \
- (((ptr) + sizeof(void*) - 1) & ~(sizeof(void*) - 1))
-
-/*
- * Default GC tune factors
- */
-#define EJS_GC_START_THRESHOLD (32 * 1024)
-
-/*
- * The Garbage collector is a generational collector. It ages blocks and
- * optimizes the mark / sweep algorithm to focus on new and recent blocks
- */
-typedef enum EjsGeneration {
- EJS_GEN_NEW = 0,
- EJS_GEN_RECENT_1 = 1,
- EJS_GEN_RECENT_2 = 2,
- EJS_GEN_OLD = 3,
- EJS_GEN_PERMANENT = 4,
- EJS_GEN_MAX = 5,
-} EjsGeneration;
-
-/*
- * Garbage collector control
- */
-typedef struct EjsGC {
- bool enable;
- bool enableDemandCollect;
- bool enableIdleCollect;
- /*
- * maxMemory should be set to be 95% of the real max memory limit
- */
- uint maxMemory; /* Above this, Throw Memory exception. */
- int workQuota; /* Quota of work before GC */
- int workDone; /* Count of allocations */
- int degraded; /* Have exceeded maxMemory */
-
- /*
- * Debug Levels 0-N (increases verbosity)
- * 1 -- Sweep and collection count
- * 2 -- Trace objects deleted
- * 3 -- Trace objects marked
- * 4 -- Print alloc report when needing a demand allocation
- *
- */
- int debugLevel; /* In debug mode */
- int collecting; /* Running garbage collection */
- uint collectionCount; /* Number of times GC ran */
-#if BLD_DEBUG
- int gcIndent; /* Indent formatting */
- int objectsInUse; /* Objects currently reachable */
- int propertiesInUse; /* Properties currently reachable */
-#endif
-} EjsGC;
-
-/*
- * Slab memory allocation
- */
-typedef struct EjsSlab {
- uint allocIncrement; /* Growth increment in slab */
- uint size; /* Size of allocations */
- EjsGCLink freeList; /* Free list (only next ptr is used) */
- EjsObj *lastRecentBlock; /* Saved for GC age generations phase */
- EjsGCLink allocList[EJS_GEN_MAX]; /* Allocated block list */
-
-#if BLD_FEATURE_ALLOC_STATS
- uint totalAlloc; /* Total count of allocation calls */
- uint freeCount; /* Number of blocks on the slab freelist */
- uint allocCount; /* Number of allocated blocks */
- uint peakAllocated; /* Peak allocated */
- uint peakFree; /* Peak on the free list */
- uint totalReclaimed; /* Total blocks reclaimed on sweeps */
- uint totalSweeps; /* Total sweeps */
-#endif
-} EjsSlab;
-
-
-/**
- * @overview EJ interpreter control structure.
- * @description EJ allocates one control structure per active interpreter.
- * The \ref ejsCreateInterp routine creates the Ejs structure and returns
- * a reference to be used in subsequent EJ API calls.
- * @stability Prototype.
- * @library libejs.
- * @see ejsCreateInterp, ejsDestroyInterp, ejsOpenService
- */
-struct Ejs {
- void *altHandle; /* Alternate callback handle */
- bool castAlloc; /* True if castTemp is allocated */
- char *castTemp; /* Temporary string for casting */
- char *currentClass; /* Current class name */
- EjsVar *currentObj; /* Ptr to current object */
- EjsVar *thisObject; /* Ptr to current "this" */
- EjsProperty *currentProperty; /* Ptr to current property */
- EjsGC gc; /* Garbage collector control */
- char *errorMsg; /* Error message */
- char *fileName; /* File or script name */
- int lineNumber; /* File line number */
- int scriptStatus; /* Status to exit() */
- int flags; /* Flags */
- MprArray *frames; /* List of variable frames */
- EjsVar *global; /* Global object */
- EjsVar *objectClass; /* Object class */
- int gotException; /* Exception thrown */
- EjsInput *input; /* Input evaluation block */
- int depth; /* Recursion depth */
- EjsVar *local; /* Local object */
- int maxDepth; /* Maximum depth for formatting */
- void *primaryHandle; /* primary callback handle */
- EjsProc *proc; /* Current method */
- int recurseCount; /* Recursion counter */
- EjsVar *result; /* Variable result */
- int tid; /* Current token id */
- char *token; /* Pointer to token string */
- EjsVar tokenNumber; /* Parsed number */
- EjsService *service; /* Service object */
- void *userData; /* Method user data */
-
- EjsSlab *slabs; /* Memory allocation slabs */
- MprCtx slabAllocContext; /* Allocation context */
- EjsInput *inputList; /* Free list of input structs */
-
-#if BLD_FEATURE_MULTITHREAD
- EjsLockFn lock; /* Lock method */
- EjsUnlockFn unlock; /* Unlock method */
- void *lockData; /* Lock data argument */
-#endif
-#define EJS_MAX_STACK (10 * 1024)
- char stack[EJS_MAX_STACK]; /* Local variable stack */
- char *stkPtr; /* Local variable stack ptr */
- void *inputMarker; /* Recurse protection */
-};
-
-
-typedef struct EjsModule
-{
- int dummy;
-} EjsModule;
-
-
-/*
- * Method callback when using Alternate handles. GaCompat uses these and
- * passes the web server request structure via the altHandle.
- */
-typedef void *EjsHandle;
-typedef int (*EjsAltCMethod)(Ejs *ejs, EjsHandle altHandle,
- EjsVar *thisObj, int argc, EjsVar **argv);
-typedef int (*EjsAltStringCMethod)(Ejs *ejs, EjsHandle altHandle,
- EjsVar *thisObj, int argc, char **argv);
-
-
-/*
- * API Constants
- */
-#define EJS_USE_OWN_SLAB 1
-
-/******************************** Internal API ********************************/
-/*
- * Ejs Lex
- */
-extern int ejsLexOpenScript(Ejs *ejs, const char *script);
-extern void ejsLexCloseScript(Ejs *ejs);
-extern int ejsInitInputState(EjsInput *ip);
-extern void ejsLexSaveInputState(Ejs *ejs, EjsInput* state);
-extern void ejsLexFreeInputState(Ejs *ejs, EjsInput* state);
-extern void ejsLexRestoreInputState(Ejs *ejs, EjsInput* state);
-extern int ejsLexGetToken(Ejs *ejs, int state);
-extern void ejsLexPutbackToken(Ejs *ejs, int tid, char *string);
-
-/*
- * Parsing
- */
-extern int ejsParse(Ejs *ejs, int state, int flags);
-extern int ejsGetFlags(Ejs *ejs);
-
-/*
- * Create variable scope blocks
- */
-extern int ejsOpenBlock(Ejs *ejs);
-extern int ejsSetBlock(Ejs *ejs, EjsVar *local);
-extern int ejsCloseBlock(Ejs *ejs, int vid);
-extern int ejsEvalBlock(Ejs *ejs, char *script, EjsVar *vp);
-extern void ejsSetFileName(Ejs *ejs, const char *fileName);
-
-/*
- * Class definitions
- */
-extern EjsVar *ejsCreateSimpleClass(Ejs *ejs, EjsVar *baseClass,
- const char *className);
-extern int ejsDefineObjectClass(Ejs *ejs);
-extern int ejsDefineArrayClass(Ejs *ejs);
-extern int ejsDefineBooleanClass(Ejs *ejs);
-extern int ejsDefineErrorClasses(Ejs *ejs);
-extern int ejsDefineFileClass(Ejs *ejs);
-extern int ejsDefineFileSystemClass(Ejs *ejs);
-extern int ejsDefineHTTPClass(Ejs *ejs);
-extern int ejsDefineFunctionClass(Ejs *ejs);
-extern int ejsDefineNumberClass(Ejs *ejs);
-extern int ejsDefineStringClass(Ejs *ejs);
-extern int ejsDefineDateClass(Ejs *ejs);
-extern int ejsDefineStandardClasses(Ejs *ejs);
-
-#if BLD_FEATURE_EJS_E4X
-extern int ejsDefineXmlClasses(Ejs *ejs);
-extern EjsVar *ejsCreateXml(Ejs *ejs);
-#endif
-
-#if BLD_FEATURE_EJS_DB
-extern int ejsDefineDbClasses(Ejs *ejs);
-#endif
-
-/*
- * System class definitions
- */
-extern int ejsDefineSystemClasses(Ejs *ejs);
-extern int ejsDefineSystemClass(Ejs *ejs);
-extern int ejsDefineAppClass(Ejs *ejs);
-extern int ejsDefineDebugClass(Ejs *ejs);
-extern int ejsDefineLogClass(Ejs *ejs);
-extern int ejsDefineMemoryClass(Ejs *ejs);
-extern int ejsDefineGCClass(Ejs *ejs);
-extern int ejsDefineGlobalProperties(Ejs *ejs);
-
-extern int ejsTermSystemClasses(Ejs *ejs);
-extern void ejsTermHTTPClass(Ejs *ejs);
-
-extern int ejsCreateObjectModel(Ejs *ejs);
-
-/*
- * Class constructors
- */
-extern int ejsArrayConstructor(Ejs *ejs, EjsVar *thisObj, int argc,
- EjsVar **argv);
-extern int ejsXmlConstructor(Ejs *ejs, EjsVar *thisObj, int argc,
- EjsVar **argv);
-extern int ejsXmlListConstructor(Ejs *ejs, EjsVar *thisObj, int argc,
- EjsVar **argv);
-extern int ejsBooleanConstructor(Ejs *ejs, EjsVar *thisObj, int argc,
- EjsVar **agv);
-extern int ejsFunctionConstructor(Ejs *ejs, EjsVar *thisObj, int argc,
- EjsVar **agv);
-extern int ejsNumberConstructor(Ejs *ejs, EjsVar *thisObj, int argc,
- EjsVar **argv);
-extern int ejsStringConstructor(Ejs *ejs, EjsVar *thisObj, int argc,
- EjsVar **argv);
-extern int ejsDateConstructor(Ejs *ejs, EjsVar *thisObj,
- int argc, EjsVar **argv);
-
-/*
- * Garbage collection
- */
-extern void ejsGCInit(Ejs *ejs, int objInc, int propInc, int varInc,
- int strInc);
-extern int ejsIsTimeForGC(Ejs *ep, int timeTillNextEvent);
-
-extern bool ejsSetGCDebugLevel(Ejs *ep, int debugLevel);
-extern void ejsSweepAll(Ejs *ep);
-
-extern EjsObj *ejsAllocObj(EJS_LOC_DEC(ejs, loc));
-extern EjsProperty *ejsAllocProperty(EJS_LOC_DEC(ejs, loc));
-extern EjsVar *ejsAllocVar(EJS_LOC_DEC(ejs, loc));
-extern void ejsFree(Ejs *ejs, void *ptr, int slabIndex);
-
-extern int ejsCollectGarbage(Ejs *ejs, int slabIndex);
-extern int ejsIncrementalCollectGarbage(Ejs *ejs);
-
-#if BLD_DEBUG
-extern void ejsDumpObjects(Ejs *ejs);
-#endif
-
-#if BLD_FEATURE_ALLOC_STATS
-extern void ejsPrintAllocReport(Ejs *ejs, bool printLeakReport);
-#endif
-
-extern void ejsCleanInterp(Ejs *ejs, bool doStats);
-extern void ejsSetInternalMethods(Ejs *ejs, EjsVar *op);
-extern void ejsSetPrimaryHandle(Ejs *ep, void *primaryHandle);
-extern void ejsSetAlternateHandle(Ejs *ep, void *alternateHandle);
-extern void *ejsGetUserData(Ejs *ejs);
-
-/*
- * Could possibly make these routines public
- */
-
-extern int ejsSetGCMaxMemory(Ejs *ep, uint maxMemory);
-extern uint ejsGetUsedMemory(Ejs *ejs);
-extern uint ejsGetAllocatedMemory(Ejs *ejs);
-extern uint ejsGetAvailableMemory(Ejs *ejs);
-extern char *ejsFormatStack(Ejs* ep);;
-
-/********************************* Prototypes *********************************/
-#if BLD_FEATURE_MULTITHREAD
-extern int ejsSetServiceLocks(EjsService *sp, EjsLockFn lock,
- EjsUnlockFn unlock, void *data);
-#endif
-
-/*
- * Ejs service and interpreter management
- */
-extern EjsService *ejsOpenService(MprCtx ctx);
-extern void ejsCloseService(EjsService *sp, bool doStats);
-
-extern Ejs *ejsCreateInterp(EjsService *sp, void *primaryHandle,
- void *altHandle, EjsVar *global, bool useOwnSlab);
-extern void ejsDestroyInterp(Ejs *ejs, bool doStats);
-
-extern Ejs *ejsGetMasterInterp(EjsService *sp);
-extern EjsVar *ejsGetGlobalClass(Ejs *ejs);
-
-/*
- * Module support
- */
-extern EjsModule *ejsCreateModule(const char *name, const char *version,
- int (*start)(EjsModule*), int (*stop)(EjsModule*));
-
-/*
- * Native Objects
- */
-
-void ejsSetNativeData(EjsVar *obj, void *data);
-void ejsSetNativeHelpers(Ejs *ejs, EjsVar *nativeClass,
- int (*createInstance)(Ejs *ejs, EjsVar *thisObj, int argc,
- EjsVar **argv),
- void (*disposeInstance)(Ejs *ejs, EjsVar *thisObj),
- bool (*hasProperty)(Ejs *ejs, EjsVar *thisObj, const char *prop),
- int (*deleteProperty)(Ejs *ejs, EjsVar *thisObj, const char *prop),
- int (*getProperty)(Ejs *ejs, EjsVar *thisObj, const char *prop,
- EjsVar *dest),
- int (*setProperty)(Ejs *ejs, EjsVar *thisObj, const char *prop,
- EjsVar *value),
- int (*doOperator)(Ejs *ejs, EjsVar *thisObj, EjsOp *op, EjsVar
- *result, EjsVar *lhs, EjsVar *rhs, int *code)
- );
-
-/*
- * Evaluation methods
- */
-extern int ejsEvalFile(Ejs *ejs, const char *path, EjsVar *result);
-extern int ejsEvalScript(Ejs *ejs, const char *script, EjsVar *result);
-extern int ejsRunMethod(Ejs *ejs, EjsVar *obj,
- const char *methodName, MprArray *args);
-extern int ejsRunMethodCmd(Ejs *ejs, EjsVar *obj,
- const char *methodName, const char *cmdFmt, ...);
-extern EjsVar *ejsGetReturnValue(Ejs *ejs);
-
-extern EjsVar *ejsGetLocalObj(Ejs *ejs);
-extern EjsVar *ejsGetGlobalObj(Ejs *ejs);
-
-/*
- * Define a class in the specified interpreter. If used with the default
- * interpeter, then the class is defined for all interpreters.
- */
-extern EjsVar *ejsDefineClass(Ejs *ejs, const char *className,
- const char *extends, EjsCMethod constructor);
-extern EjsVar *ejsGetClass(Ejs *ejs, EjsVar *parentClass,
- const char *className);
-
-extern const char *ejsGetClassName(EjsVar *obj);
-extern const char *ejsGetBaseClassName(EjsVar *obj);
-
-extern bool ejsIsSubClass(EjsVar *target, EjsVar *baseClass);
-extern EjsVar *ejsGetBaseClass(EjsVar *obj);
-extern void ejsSetBaseClass(EjsVar *obj, EjsVar *baseClass);
-
-
-#define ejsCreateSimpleObj(ejs, className) \
- ejsCreateSimpleObjInternal(EJS_LOC_ARGS(ejs), className)
-extern EjsVar *ejsCreateSimpleObjInternal(EJS_LOC_DEC(ejs, loc),
- const char *className);
-
-#define ejsCreateSimpleObjUsingClass(ejs, baseClass) \
- ejsCreateSimpleObjUsingClassInt(EJS_LOC_ARGS(ejs), \
- baseClass)
-extern EjsVar *ejsCreateSimpleObjUsingClassInt(EJS_LOC_DEC(ejs, loc),
- EjsVar *baseClass);
-
-/*
- * This will create an object and call all required constructors
- */
-extern EjsVar *ejsCreateObj(Ejs *ejs, EjsVar *obj,
- const char *className, const char *constructorArgs);
-
-#define ejsCreateObjUsingArgv(ejs, obj, className, args) \
- ejsCreateObjUsingArgvInternal(EJS_LOC_ARGS(ejs), obj, \
- className, args)
-extern EjsVar *ejsCreateObjUsingArgvInternal(EJS_LOC_DEC(ejs, loc),
- EjsVar *obj, const char *className, MprArray *args);
-
-#define ejsCreateArray(ejs, size) \
- ejsCreateArrayInternal(EJS_LOC_ARGS(ejs), size)
-extern EjsVar *ejsCreateArrayInternal(EJS_LOC_DEC(ejs, loc),
- int size);
-
-/*
- * Array methods. MOB -- need other array methods
- */
-/* MOB -- spell out element */
-extern EjsVar *ejsAddArrayElt(Ejs *ejs, EjsVar *op, EjsVar *element,
- EjsCopyDepth copyDepth);
-/*
- * Required: Array methods
- *
- array = obj.getMethods();
- array = obj.getProperties();
-
- array.property.isPublic();
- array.property.isPrivate();
- array.property.isMethod();
- array.property.isEnumerable();
- array.property.isReadOnly();
- array.property.allowsNonUnique();
- array.property.getParent();
-*/
-
-/* MOB -- should we have an API that takes a EjsCopyDepth */
-extern void ejsSetReturnValue(Ejs *ejs, EjsVar *vp);
-extern void ejsSetReturnValueAndFree(Ejs *ejs, EjsVar *vp);
-extern void ejsSetReturnValueToBoolean(Ejs *ejs, bool value);
-extern void ejsSetReturnValueToBinaryString(Ejs *ejs,
- const uchar *value, int len);
-extern void ejsSetReturnValueToInteger(Ejs *ejs, int value);
-extern void ejsSetReturnValueToNumber(Ejs *ejs, EjsNum value);
-extern void ejsSetReturnValueToString(Ejs *ejs, const char *value);
-extern void ejsSetReturnValueToUndefined(Ejs *ejs);
-
-/*
- * Variable access and control. The fullName arg can contain "[]" and "."
- */
-extern bool ejsGetBool(Ejs *ejs, const char *fullName, bool defaultValue);
-extern int ejsGetInt(Ejs *ejs, const char *fullName, int defaultValue);
-extern const char *ejsGetStr(Ejs *ejs, const char *fullName,
- const char *defaultValue);
-extern EjsVar *ejsGetVar(Ejs *ejs, const char *fullName);
-
-extern int ejsSetBool(Ejs *ejs, const char *fullName, bool value);
-extern int ejsSetInt(Ejs *ejs, const char *fullName, int value);
-extern int ejsSetStr(Ejs *ejs, const char *fullName, const char *value);
-extern int ejsSetVar(Ejs *ejs, const char *fullName, const EjsVar *value);
-extern int ejsSetVarAndFree(Ejs *ejs, const char *fullName, EjsVar *value);
-
-extern int ejsDeleteVar(Ejs *ejs, const char *fullName);
-
-/*
- * Error handling
- */
-extern void ejsError(Ejs *ejs, const char *errorType, const char *fmt,
- ...) PRINTF_ATTRIBUTE(3,4);
-/* MOB -- this should take no arguments */
-extern void ejsArgError(Ejs *ejs, const char *msg);
-extern void ejsInternalError(Ejs *ejs, const char *msg);
-extern void ejsMemoryError(Ejs *ejs);
-extern void ejsSyntaxError(Ejs *ejs, const char *msg);
-
-/*
- * Utility methods
- */
-extern int ejsParseArgs(int argc, char **argv, const char *fmt, ...);
-
-extern void ejsExit(Ejs *ejs, int status);
-extern bool ejsIsExiting(Ejs *ejs);
-extern void ejsClearExiting(Ejs *ejs);
-
-extern bool ejsGotException(Ejs *ejs);
-
-/* MOB -- rename Method to Function */
-extern void ejsFreeMethodArgs(Ejs *ep, MprArray *args);
-extern int ejsStrcat(Ejs *ep, EjsVar *dest, EjsVar *src);
-
-/*
- * Debugging routines
- */
-extern char *ejsGetErrorMsg(Ejs *ejs);
-extern int ejsGetLineNumber(Ejs *ejs);
-extern void ejsTrace(Ejs *ejs, const char *fmt, ...);
-
-/*
- * Multithreaded lock routines
- */
-#if BLD_FEATURE_MULTITHREAD
-#define ejsLock(sp) if (sp->lock) { (sp->lock)(sp->lockData); } else
-#define ejsUnlock(sp) if (sp->unlock) { (sp->unlock)(sp->lockData); } else
-#else
-#define ejsLock(sp)
-#define ejsUnlock(sp)
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* _h_EJS */
-
-/*****************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejsClass.c b/source4/lib/appweb/ejs-2.0/ejs/ejsClass.c
deleted file mode 100644
index 58609adf3f..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/ejsClass.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * @file ejsClass.c
- * @brief EJS class support
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************* Includes ***********************************/
-
-#include "ejs.h"
-
-#if BLD_FEATURE_EJS
-
-/************************************ Code ************************************/
-/*
- * Internal API
- *
- * Routine to create a simple class object. This routine will create a
- * stand-alone class object. Callers must insert this into the relevant
- * "global" object for name resolution. From these class objects, instance
- * objects may be created via the javascript "new" command.
- *
- * Users should use ejsDefineClass
- */
-
-EjsVar *ejsCreateSimpleClass(Ejs *ep, EjsVar *baseClass, const char *className)
-{
- EjsProperty *pp;
- EjsVar *classObj;
-
- /*
- * Create an instance of an Object to act as the static class object
- */
- classObj = ejsCreateSimpleObjUsingClass(ep, baseClass);
- if (classObj == 0) {
- mprAssert(classObj);
- return 0;
- }
- ejsSetClassName(ep, classObj, className);
-
- /*
- * Set the propotype property to point to this class.
- * Note: this is a self reference so the alive bit will not be turned on.
- */
- pp = ejsSetProperty(ep, classObj, "prototype", classObj);
- ejsMakePropertyEnumerable(pp, 0);
-
- return classObj;
-}
-
-/******************************************************************************/
-/*
- * Define a class in the given interpreter. If parentClass is specified, the
- * class is defined in the parent. Otherwise, the class will be defined
- * locally/globally. ClassName and extends are full variable specs
- * (may contain ".")
- */
-
-EjsVar *ejsDefineClass(Ejs *ep, const char *className, const char *extends,
- EjsCMethod constructor)
-{
- EjsVar *parentClass, *classObj, *baseClass, *vp;
- char *name;
- char *cp;
-
- /*
- * If the className is a qualified name (with "."), then get the
- * parent class name.
- */
- name = mprStrdup(ep, className);
- cp = strrchr(name, '.');
- if (cp != 0) {
- *cp++ = '\0';
- className = cp;
- parentClass = ejsFindProperty(ep, 0, 0, ep->global, ep->local, name, 0);
- if (parentClass == 0 || parentClass->type != EJS_TYPE_OBJECT) {
- mprError(ep, MPR_LOC, "Can't find class's parent class %s", name);
- mprFree(name);
- return 0;
- }
-
- } else {
- /*
- * Simple class name without a "." so create the class locally
- * if a local scope exists, otherwise globally.
- */
- parentClass = (ep->local) ? ep->local : ep->global;
- }
-
- if (parentClass == 0) {
- mprError(ep, MPR_LOC, "Can't find parent class");
- mprFree(name);
- return 0;
- }
-
- /* OPT should use function that doesn't parse [] . */
- baseClass = ejsGetClass(ep, 0, extends);
- if (baseClass == 0) {
- mprAssert(baseClass);
- mprFree(name);
- return 0;
- }
-
- classObj = ejsCreateSimpleClass(ep, baseClass, className);
- if (classObj == 0) {
- mprAssert(classObj);
- mprFree(name);
- return 0;
- }
-
- if (constructor) {
- ejsDefineCMethod(ep, classObj, className, constructor, 0);
- }
-
- ejsSetPropertyAndFree(ep, parentClass, className, classObj);
-
- vp = ejsGetPropertyAsVar(ep, parentClass, className);
- mprFree(name);
-
- return vp;
-}
-
-/******************************************************************************/
-/*
- * Find a class and return the property defining the class. ClassName may
- * contain "." and is interpreted relative to obj. Obj is typically some
- * parent object, ep->local or ep->global. If obj is null, then the global
- * space is used.
- */
-
-EjsVar *ejsGetClass(Ejs *ep, EjsVar *obj, const char *className)
-{
- EjsVar *vp;
-
- mprAssert(ep);
-
- /*
- * Search first for a constructor of the name of class
- * global may not be defined yet.
- */
- if (obj) {
- vp = ejsFindProperty(ep, 0, 0, obj, 0, className, 0);
-
- } else {
- mprAssert(ep->global);
- vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, className, 0);
- }
- if (vp == 0 || vp->type != EJS_TYPE_OBJECT) {
- return 0;
- }
-
- /*
- * Return a reference to the prototype (self) reference. This
- * ensures that even if "obj" is deleted, this reference will remain
- * usable.
- */
- return ejsGetPropertyAsVar(ep, vp, "prototype");
-}
-
-/******************************************************************************/
-/*
- * Return the class name of a class or object
- */
-
-const char *ejsGetClassName(EjsVar *vp)
-{
- EjsObj *obj;
-
- mprAssert(vp);
- mprAssert(vp->type == EJS_TYPE_OBJECT);
- mprAssert(vp->objectState->baseClass);
-
- if (vp == 0 || !ejsVarIsObject(vp)) {
- return 0;
- }
- obj = vp->objectState;
-
- return obj->className;
-}
-
-/******************************************************************************/
-/*
- * Return the class name of an objects underlying class
- * If called on an object, it returns the base class.
- * If called on a class, it returns the base class for the class.
- */
-
-const char *ejsGetBaseClassName(EjsVar *vp)
-{
- EjsObj *obj;
-
- mprAssert(vp);
- mprAssert(vp->type == EJS_TYPE_OBJECT);
- mprAssert(vp->objectState->baseClass);
-
- if (vp == 0 || !ejsVarIsObject(vp)) {
- return 0;
- }
- obj = vp->objectState;
- if (obj->baseClass == 0) {
- return 0;
- }
- mprAssert(obj->baseClass->objectState);
-
- return obj->baseClass->objectState->className;
-}
-
-/******************************************************************************/
-
-EjsVar *ejsGetBaseClass(EjsVar *vp)
-{
- if (vp == 0 || !ejsVarIsObject(vp) || vp->objectState == 0) {
- mprAssert(0);
- return 0;
- }
- return vp->objectState->baseClass;
-}
-
-/******************************************************************************/
-
-void ejsSetBaseClass(EjsVar *vp, EjsVar *baseClass)
-{
- if (vp == 0 || !ejsVarIsObject(vp) || vp->objectState == 0) {
- mprAssert(0);
- return;
- }
- vp->objectState->baseClass = baseClass;
-}
-
-/******************************************************************************/
-
-#else
-void ejsProcsDummy() {}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_EJS */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejsCmd.c b/source4/lib/appweb/ejs-2.0/ejs/ejsCmd.c
deleted file mode 100644
index 74b57de4d0..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/ejsCmd.c
+++ /dev/null
@@ -1,468 +0,0 @@
-/*
- * @file ejsCmd.c
- * @brief Embedded JavaScript (EJS) command line program.
- * @overview
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-#if BLD_FEATURE_EJS && !BREW
-
-/************************************ Defines *********************************/
-
-#define EJS_MAX_CMD_LINE (16 * 1024)
-#define EJS_MAX_SCRIPT (4 * 1024 * 1024)
-#define EJS_MAX_RESULT_SIZE (4 * 1024 * 1024)
-#define EJS_PROMPT "ejs> "
-
-/****************************** Forward Declarations **************************/
-
-static int parseFile(EjsService *ejsService, Ejs *ejs, const char *fileName,
- const char *testName, MprFile *testLogFile);
-static int ifConsole();
-
-static int interactiveUse(MprApp *app, Ejs *ejs, FILE *input,
- char *fileName);
-static char *readCmd(MprApp *app, FILE *input);
-
-static int memoryFailure(MprApp *app, uint size, uint total, bool granted);
-
-static int isConsole = 0;
-static int traceCmds = 0;
-static int stats = 0;
-static int verbose = 0;
-
-/************************************ Main ************************************/
-
-int main(int argc, char *argv[])
-{
- MprApp *app;
- const char *programName;
- MprFile *testLogFile;
- EjsService *ejsService;
- Ejs *ejs;
- char *commandLine;
- const char *testName;
- char *argp, *cmd, *testLog;
- int i, rc, nextArg, err, len, firstArg, iterations, debugLevel;
-
- app = mprInit(memoryFailure);
-
- isConsole = ifConsole();
- programName = mprGetBaseName(argv[0]);
- debugLevel = 0;
-
- ejsService = ejsOpenService(app);
- if (ejsService == 0) {
- mprError(app, MPR_LOC, "Can't initialize the EJS service.");
- return -1;
- }
-
- err = 0;
- iterations = 1;
- stats = 0;
- testLog = getenv("TEST_LOG");
- testLogFile = 0;
- testName = 0;
-
- for (nextArg = 1; nextArg < argc; nextArg++) {
- argp = argv[nextArg];
- if (*argp != '-') {
- break;
- }
- if (strcmp(argp, "--debug") == 0) {
- if (nextArg >= argc) {
- err++;
- } else {
- debugLevel = atoi(argv[++nextArg]);
- }
-
- } else if (strcmp(argp, "--stats") == 0) {
- stats++;
-
- } else if (strcmp(argp, "--trace") == 0) {
- traceCmds++;
-
- } else if (strcmp(argp, "--iterations") == 0) {
- if (nextArg >= argc) {
- err++;
- } else {
- iterations = atoi(argv[++nextArg]);
- }
-
- } else if (strcmp(argp, "--log") == 0) {
- /* Get file to log test results to when using ejs as a test shell */
- if (nextArg >= argc) {
- err++;
- } else {
- testLog = argv[++nextArg];
- }
-
- } else if (strcmp(argp, "--testName") == 0) {
- if (nextArg >= argc) {
- err++;
- } else {
- testName = argv[++nextArg];
- }
-
- } else if (strcmp(argp, "-v") == 0) {
- verbose++;
-
- } else if (strcmp(argp, "-vv") == 0) {
- verbose += 2;
-
- } else if (strcmp(argp, "--verbose") == 0) {
- verbose += 2;
-
- } else {
- err++;
- break;
- }
- if (err) {
- mprErrorPrintf(app,
- "Usage: %s [options] files... or\n"
- " %s < file or\n"
- " %s or\n"
- " Switches:\n"
- " --iterations num # Number of iterations to eval file\n"
- " --stats # Output stats on exit\n"
- " --testName name # Set the test name",
- programName, programName, programName);
- return -1;
- }
- }
-
- if (testName) {
- i = 0;
- commandLine = 0;
- len = mprAllocStrcat(MPR_LOC_ARGS(app), &commandLine, 0, " ",
- mprGetBaseName(argv[i++]), NULL);
- for (; i < argc; i++) {
- len = mprReallocStrcat(MPR_LOC_ARGS(app), &commandLine, 0, len,
- " ", argv[i], NULL);
- }
- mprPrintf(app, " %s\n", commandLine);
- }
- if (testLog) {
- testLogFile = mprOpen(app, testLog,
- O_CREAT | O_APPEND | O_WRONLY | O_TEXT, 0664);
- if (testLogFile == 0) {
- mprError(app, MPR_LOC, "Can't open %s", testLog);
- return MPR_ERR_CANT_OPEN;
- }
- mprFprintf(testLogFile, "\n %s\n", commandLine);
- }
-
- ejs = ejsCreateInterp(ejsService, 0, 0, 0, 0);
- if (ejs == 0) {
- mprError(app, MPR_LOC, "Can't create EJS interpreter");
- ejsCloseService(ejsService, stats);
- if (testLogFile) {
- mprClose(testLogFile);
- }
- mprTerm(app, stats);
- exit(-1);
- }
-
- if (debugLevel > 0) {
- ejsSetGCDebugLevel(ejs, debugLevel);
- }
-
- rc = 0;
-
- if (nextArg < argc) {
- /*
- * Process files supplied on the command line
- */
- firstArg = nextArg;
- for (i = 0; i < iterations; i++) {
- for (nextArg = firstArg; nextArg < argc; nextArg++) {
- rc = parseFile(ejsService, ejs, argv[nextArg], testName,
- testLogFile);
- if (rc < 0) {
- return rc;
- }
- }
- }
- if (testName) {
- if (verbose == 1) {
- mprPrintf(app, "\n");
- }
- if (verbose <= 1) {
- mprPrintf(app, " # PASSED all tests for \"%s\"\n", testName);
- }
- }
-
- } else if (! isConsole) {
- /*
- * Read a script from stdin
- */
- cmd = readCmd(app, stdin);
-
- ejsSetFileName(ejs, "stdin");
-
- rc = ejsEvalScript(ejs, cmd, 0);
- if (rc < 0) {
- mprPrintf(app, "ejs: Error: %s\n", ejsGetErrorMsg(ejs));
- }
- mprFree(cmd);
-
- } else {
- /*
- * Interactive use. Read commands from the command line.
- */
- rc = interactiveUse(app, ejs, stdin, "stdin");
- }
-
- /*
- * Cleanup. Do stats if required.
- */
- if (ejs) {
- ejsCleanInterp(ejs, 0);
- ejsCleanInterp(ejs->service->master, 0);
- ejsDestroyInterp(ejs, 0);
- }
-
- ejsCloseService(ejsService, stats);
-
- if (testLogFile) {
- mprClose(testLogFile);
- }
-
- mprTerm(app, stats);
- return rc;
-}
-
-/******************************************************************************/
-
-static int parseFile(EjsService *ejsService, Ejs *ejs, const char *fileName,
- const char *testName, MprFile *testLogFile)
-{
- int rc;
-
- if (testName && verbose == 1) {
- mprPrintf(ejs, ".");
- }
- if (verbose > 1) {
- mprPrintf(ejs, "File: %s\n", fileName);
- }
-
- rc = ejsEvalFile(ejs, fileName, 0);
-
- if (testName) {
- char fileBuf[MPR_MAX_FNAME], *cp;
- mprStrcpy(fileBuf, sizeof(fileBuf), fileName);
- if ((cp = strstr(fileBuf, ".ejs")) != 0) {
- *cp = '\0';
- }
- if (rc == 0) {
- if (verbose > 1) {
- mprPrintf(ejs, " # PASSED test \"%s.%s\"\n", testName,
- fileBuf);
- }
- if (testLogFile) {
- mprFprintf(testLogFile, " # PASSED test \"%s.%s\"\n",
- testName, fileBuf);
- }
-
- } else {
-
- mprPrintf(ejs, "FAILED test \"%s.%s\"\nDetails: %s\n",
- testName, fileBuf, ejsGetErrorMsg(ejs));
-
- if (testLogFile) {
- mprFprintf(testLogFile,
- "FAILED test \"%s.%s\"\nDetails: %s\n",
- testName, fileBuf, ejsGetErrorMsg(ejs));
- }
- }
- } else if (rc < 0) {
- mprPrintf(ejs, "ejs: %sIn file \"%s\"\n",
- ejsGetErrorMsg(ejs), fileName);
- }
- return rc;
-}
-
-/******************************************************************************/
-
-static char *readCmd(MprApp *app, FILE *input)
-{
- char line[EJS_MAX_CMD_LINE];
- char *cmd;
- int len, cmdLen;
-
- cmd = 0;
- cmdLen = 0;
-
- line[sizeof(line) - 1] = '\0';
-
- while (1) {
-
- if (fgets(line, sizeof(line) - 1, input) == NULL) {
- break;
- }
-
- len = strlen(line);
-
- if (line[len - 1] == '\\') {
- line[len - 1] = '\0';
- }
- cmdLen = mprReallocStrcat(MPR_LOC_ARGS(app), &cmd, EJS_MAX_SCRIPT,
- cmdLen, 0, line, NULL);
- }
- return cmd;
-}
-
-/******************************************************************************/
-
-static int interactiveUse(MprApp *app, Ejs *ejs, FILE *input, char *fileName)
-{
- EjsVar result;
- char line[EJS_MAX_CMD_LINE];
- char *cmd, *buf;
- int len, cmdLen, rc;
-
- cmd = 0;
- cmdLen = 0;
-
- line[sizeof(line) - 1] = '\0';
-
- ejsSetFileName(ejs, "console");
-
- while (! ejsIsExiting(ejs)) {
-
- if (isConsole) {
- write(1, EJS_PROMPT, strlen(EJS_PROMPT));
- }
-
- if (fgets(line, sizeof(line) - 1, input) == NULL) {
- break;
- }
-
- len = strlen(line);
- while (len > 0 &&
- (line[len - 1] == '\n' || line[len - 1] == '\r')) {
- len--;
- line[len] = '\0';
- }
-
- if (line[len - 1] == '\\') {
- line[len - 1] = '\0';
- cmdLen = mprReallocStrcat(MPR_LOC_ARGS(app), &cmd, EJS_MAX_SCRIPT,
- cmdLen, 0, line, NULL);
-
- } else {
-
- cmdLen = mprReallocStrcat(MPR_LOC_ARGS(app), &cmd, EJS_MAX_SCRIPT,
- cmdLen, 0, line, NULL);
-
-
- if (traceCmds) {
- mprPrintf(ejs, "# %s\n", cmd);
- }
-
- if (cmd[0] == 0x4 || cmd[0] == 0x26 || strcmp(cmd, "quit") == 0) {
- ejsExit(ejs, 0);
-
- } else if ((rc = ejsEvalScript(ejs, cmd, &result)) < 0) {
-
- mprPrintf(app, "ejs: Error: %s\n", ejsGetErrorMsg(ejs));
-
- if (! isConsole) {
- return rc;
- }
-
- } else {
- if (isConsole || traceCmds) {
- buf = ejsVarToString(ejs, &result);
- mprPrintf(ejs, "%s\n", buf);
- }
- }
- mprFree(cmd);
- cmd = 0;
- cmdLen = 0;
- }
- }
- return 0;
-}
-
-/******************************************************************************/
-
-static int ifConsole()
-{
-#if WIN
- INPUT_RECORD irec[1];
- int records = 0;
-
- if (PeekConsoleInput(GetStdHandle(STD_INPUT_HANDLE), irec, 1,
- &records) != 0) {
- return 1;
- }
-#else
- return isatty(0);
-#endif
- return 0;
-}
-
-/******************************************************************************/
-
-static int memoryFailure(MprApp *app, uint size, uint total, bool granted)
-{
- if (!granted) {
- mprPrintf(app, "Can't allocate memory block of size %d\n", size);
- mprPrintf(app, "Total memory used %d\n", total);
- exit(255);
- }
- mprPrintf(app, "Memory request for %d bytes exceeds memory red-line\n",
- size);
- mprPrintf(app, "Total memory used %d\n", total);
- return 0;
-}
-
-/******************************************************************************/
-
-#else
-void ejsCmdLineDummy() {}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_EJS */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejsGarbage.c b/source4/lib/appweb/ejs-2.0/ejs/ejsGarbage.c
deleted file mode 100755
index 264da05721..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/ejsGarbage.c
+++ /dev/null
@@ -1,1214 +0,0 @@
-/*
- * @file ejsGarbage.c
- * @brief EJS Garbage collector.
- * @overview This implements a generational mark and sweep collection scheme.
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-#if BLD_FEATURE_EJS
-
-/****************************** Forward Declarations **************************/
-
-static void mark(Ejs *ep);
-static void markObjByVar(Ejs *ep, EjsVar *op);
-static void markObj(EjsObj *obj);
-static void markPerm(Ejs *ep, uint gen);
-static int sweep(Ejs *ep, uint gen);
-static EjsGCLink *ejsAlloc(EJS_LOC_DEC(ep, loc), int slabIndex);
-static void ejsGracefulDegrade(Ejs *ep);
-static void resetMarks(Ejs *ep, EjsSlab *slab);
-
-#if FUTURE
-static void ageGenerations(Ejs *ep);
-#endif
-
-#if BLD_DEBUG && (!BREW || BREW_SIMULATOR)
-uint breakAddr;
-#endif
-
-/************************************* Code ***********************************/
-
-void ejsGCInit(Ejs *ep, int objInc, int propInc, int varInc, int strInc)
-{
- EjsSlab *slab;
-
- if (ep->service && ep->service->globalClass) {
- ep->service->globalClass->objectState->gcMarked = 1;
- }
-
- slab = &ep->slabs[EJS_SLAB_OBJ];
- slab->allocIncrement = objInc;
- slab->size = EJS_ALLOC_ALIGN(sizeof(EjsObj));
-
- slab = &ep->slabs[EJS_SLAB_PROPERTY];
- slab->allocIncrement = propInc;
- slab->size = EJS_ALLOC_ALIGN(sizeof(EjsProperty));
-
- slab = &ep->slabs[EJS_SLAB_VAR];
- slab->allocIncrement = varInc;
- slab->size = EJS_ALLOC_ALIGN(sizeof(EjsVar));
-
- /*
- * Initialize GC.
- * Enable GC both idle and demand collections.
- * Set no limits and garbage collect if the slabs are
- * empty and we have used more than the THRESHOLD of ram.
- */
- ep->gc.debugLevel = 0;
- ep->gc.enable = 1;
- ep->gc.enableIdleCollect = 1;
- ep->gc.enableDemandCollect = 1;
- ep->gc.workQuota = EJS_GC_WORK_QUOTA;
- ep->gc.maxMemory = 0;
-}
-
-
-/******************************************************************************/
-#if BLD_FEATURE_ALLOC_STATS
-
-void ejsPrintAllocReport(Ejs *ep, bool printLeakReport)
-{
- EjsSlab *slab;
- char *name;
- int slabIndex, isObj;
-
- for (slabIndex = 0; slabIndex < EJS_SLAB_MAX; slabIndex++) {
- slab = &ep->slabs[slabIndex];
- if (slabIndex == EJS_SLAB_VAR) {
- name = "var";
- } else if (slabIndex == EJS_SLAB_PROPERTY) {
- name = "prop";
- } else {
- name = "obj";
- }
- mprLog(ep, 0, " ");
- mprLog(ep, 0, " GC \"%s\" local slab", name);
- mprLog(ep, 0, " Total blocks %14d",
- slab->allocCount + slab->freeCount);
- mprLog(ep, 0, " Block size %14d", slab->size);
- mprLog(ep, 0, " Slab RAM allocated %14d",
- (slab->allocCount + slab->freeCount) * slab->size);
- mprLog(ep, 0, " Slab RAM in use %14d",
- slab->allocCount * slab->size);
- mprLog(ep, 0, " Blocks in use %14d", slab->allocCount);
- mprLog(ep, 0, " Free blocks %14d", slab->freeCount);
- mprLog(ep, 0, " Peak allocated %14d", slab->peakAllocated);
- mprLog(ep, 0, " Peak free %14d", slab->peakFree);
- mprLog(ep, 0, " Total allocations %14d", slab->totalAlloc);
- mprLog(ep, 0, " Total blocks reclaimed %14d", slab->totalReclaimed);
- mprLog(ep, 0, " Total sweeps %14d", slab->totalSweeps);
- mprLog(ep, 0, " Allocation inc %14d", slab->allocIncrement);
- }
-
- mprLog(ep, 0, " ");
- mprLog(ep, 0, " Total EJS memory in use %10d", ejsGetUsedMemory(ep));
- mprLog(ep, 0, " Total EJS memory allocated %10d",
- ejsGetAllocatedMemory(ep));
-
- if (printLeakReport) {
- mprLog(ep, 0, " ");
- for (slabIndex = 0; slabIndex < EJS_SLAB_MAX; slabIndex++) {
- int size;
-
- slab = &ep->slabs[slabIndex];
-
- isObj = 0;
- mprLog(ep, 0, " ");
- if (slabIndex == EJS_SLAB_VAR) {
- name = "var";
- size = sizeof(EjsVar);
- } else if (slabIndex == EJS_SLAB_PROPERTY) {
- name = "prop";
- size = sizeof(EjsProperty);
- } else {
- name = "obj";
- size = sizeof(EjsObj);
- isObj++;
- }
-#if BLD_FEATURE_ALLOC_LEAK_TRACK
-{
- EjsGCLink *lp;
- EjsObj *obj;
- int count;
-
- mprLog(ep, 0, "EJS Leak Report for \"%s\"", name);
- count = 0;
-
- for (lp = slab->allocList[0].next; lp; lp = lp->next) {
- mprLog(ep, 0, " %-20s %10d", lp->allocatedBy, size);
- if (isObj) {
- obj = (EjsObj*) lp;
- mprLog(ep, 0, " %-20s %10d %s %s",
- lp->allocatedBy, size,
- obj->permanent ? "permanent" : "",
- obj->alive ? "alive" : ""
- );
- } else {
- mprLog(ep, 0, " %-20s %10d", lp->allocatedBy,
- size);
- }
- count++;
- }
- mprLog(ep, 0, " Total blocks %14d", count);
-}
-#endif
- }
- mprLog(ep, 0, " ");
- }
-}
-
-#endif
-/******************************************************************************/
-/*
- * Slab allocator
- */
-
-static EjsGCLink *ejsAlloc(EJS_LOC_DEC(ep, loc), int slabIndex)
-{
- EjsSlab *slab;
- EjsGCLink *block;
- EjsGC *gc;
- uint allocatedMemory;
- int i;
-
- mprStackCheck(ep);
-
- if (slabIndex < 0 || slabIndex >= EJS_SLAB_MAX) {
- mprAssert(0);
- return 0;
- }
-
- /*
- * See if the slab has some free blocks
- */
- slab = &ep->slabs[slabIndex];
- if ((block = slab->freeList.next) == 0) {
-
- allocatedMemory = ejsGetAllocatedMemory(ep);
- gc = &ep->gc;
-
- /*
- * No blocks available. If demand collection is enabled, try
- * to garbage collect first. We collect if we have done a good
- * work quota or we are over the max memory limit.
- */
- if (slabIndex != EJS_SLAB_VAR &&
- ep->gc.enable && ep->gc.enableDemandCollect) {
- if ((ep->gc.workDone > ep->gc.workQuota) ||
- (gc->maxMemory > 0 && allocatedMemory > gc->maxMemory)) {
-
-#if DEBUG_USE_ONLY
- if (ep->gc.debugLevel > 0) {
- mprLog(ep, 0, "Need GC, EJS RAM %d, MPR RAM %d\n",
- allocatedMemory, mprGetAllocatedMemory(ep));
- if (ep->gc.debugLevel > 4) {
- ejsPrintAllocReport(ep, 0);
- }
- }
-#endif
- if (ejsCollectGarbage(ep, slabIndex) == 0) {
- block = slab->freeList.next;
- }
- }
- }
-
- if (block == 0) {
- if (gc->maxMemory > 0 && allocatedMemory > gc->maxMemory) {
- /*
- * We are above the max memory limit. We will fail this
- * memory allocation, but allow subsequent allocations to
- * permit error recovery. We gracefully degrade by setting
- * slab chunk sizes to 1. This minimizes real memory
- * consumption. This allows us to create
- * an exception block to be created by upper layers.
- */
- if (! gc->degraded) {
- ejsGracefulDegrade(ep);
- return 0;
- }
- }
-
- /*
- * Still non available, so allocate more memory for a set of blocks
- * OPT -- should bypass mprAlloc. Need mprMalloc.
- */
- block = mprAlloc(ep->slabAllocContext,
- slab->size * slab->allocIncrement);
- if (block == 0) {
- /*
- * Now we're in trouble. We should really never get here
- * as the graceful degrade will have signaled a memory
- * allocation failure.
- */
- mprAssert(block != 0);
- return 0;
- }
-
- /*
- * Chain all the blocks together onto the slab free list
- */
- for (i = slab->allocIncrement - 1; i >= 0; i--) {
- block->next = slab->freeList.next;
-#if BLD_DEBUG
- block->magic = EJS_MAGIC_FREE;
-#endif
- slab->freeList.next = block;
- block = (EjsGCLink*) ((char*) block + slab->size);
- }
-
- block = slab->freeList.next;
-
-#if BLD_FEATURE_ALLOC_STATS
- slab->freeCount += slab->allocIncrement;
- if (slab->freeCount > slab->peakFree) {
- slab->peakFree = slab->freeCount;
- }
-#endif
- }
- }
-
- /*
- * We use block to point to the user data in the block. We only
- * store the magic number (if debug). No other data is stored in the
- * user block.
- */
-#if BLD_DEBUG
- mprAssert(block->magic == EJS_MAGIC_FREE);
-#endif
-
- /*
- * Remove from the free list
- */
- slab->freeList.next = block->next;
-
- /*
- * Zero block
- */
- memset(block, 0, slab->size);
-
-#if BLD_DEBUG
- block->magic = EJS_MAGIC;
-#endif
-
-#if BLD_FEATURE_ALLOC_STATS
- slab->totalAlloc++;
- if (++slab->allocCount > slab->peakAllocated) {
- slab->peakAllocated = slab->allocCount;
- }
- slab->freeCount--;
-#endif
-
-#if BLD_DEBUG && (!BREW || BREW_SIMULATOR)
- if ((uint) block == breakAddr) {
- mprBreakpoint(MPR_LOC, "Watched Block");
- }
-#endif
- return block;
-}
-
-
-/******************************************************************************/
-
-EjsObj *ejsAllocObj(EJS_LOC_DEC(ep, loc))
-{
- EjsObj *obj;
- EjsSlab *slab;
-
- obj = (EjsObj*) ejsAlloc(EJS_LOC_PASS(ep, loc), EJS_SLAB_OBJ);
-
- /*
- * Add to the allocated block list for the New generation.
- */
- if (obj) {
- slab = &ep->slabs[EJS_SLAB_OBJ];
- obj->gc.next = slab->allocList[EJS_GEN_NEW].next;
-
-#if BLD_FEATURE_ALLOC_LEAK_TRACK
- obj->gc.allocatedBy = loc;
-#endif
-
- obj->ejs = ep;
- slab->allocList[EJS_GEN_NEW].next = (EjsGCLink*) obj;
-
- ep->gc.workDone++;
- }
-
- return obj;
-}
-
-
-/******************************************************************************/
-
-EjsProperty *ejsAllocProperty(EJS_LOC_DEC(ep, loc))
-{
- EjsProperty *prop;
-
- prop = (EjsProperty*) ejsAlloc(EJS_LOC_PASS(ep, loc), EJS_SLAB_PROPERTY);
- mprAssert(prop);
-
- if (prop) {
- prop->var.type = EJS_TYPE_NULL;
- prop->var.isProperty = 1;
-#if BLD_FEATURE_ALLOC_LEAK_TRACK
- prop->var.gc.allocatedBy = loc;
-#endif
- }
- return prop;
-}
-
-
-/******************************************************************************/
-
-EjsVar *ejsAllocVar(EJS_LOC_DEC(ep, loc))
-{
- EjsVar *vp;
-
- vp = (EjsVar*) ejsAlloc(EJS_LOC_PASS(ep, loc), EJS_SLAB_VAR);
- mprAssert(vp);
-
- if (vp) {
-#if BLD_FEATURE_ALLOC_LEAK_TRACK
- EjsSlab *slab;
- vp->gc.allocatedBy = loc;
- slab = &ep->slabs[EJS_SLAB_VAR];
- vp->gc.next = slab->allocList[EJS_GEN_NEW].next;
- slab->allocList[EJS_GEN_NEW].next = (EjsGCLink*) vp;
-#endif
-#if BLD_DEBUG
- vp->propertyName = 0;
-#endif
- }
- return vp;
-}
-
-
-/******************************************************************************/
-/*
- * Return the block back to the relevant slab
- */
-
-void ejsFree(Ejs *ep, void *ptr, int slabIndex)
-{
- EjsSlab *slab;
- EjsGCLink *block;
-
- mprAssert(ep);
- mprAssert(ptr);
-
- if (slabIndex < 0 || slabIndex >= EJS_SLAB_MAX) {
- mprAssert(slabIndex >= 0 && slabIndex < EJS_SLAB_MAX);
- return;
- }
- slab = &ep->slabs[slabIndex];
-
-#if BLD_FEATURE_ALLOC_LEAK_TRACK
- if (slabIndex == EJS_SLAB_VAR) {
- EjsVar *vp, *np, *prev;
-
- /*
- * Remove the block rom the alloc list. WARNING: this is slow
- * and should not be used in production code.
- */
- vp = (EjsVar*) ptr;
- prev = 0;
- for (np = (EjsVar*) slab->allocList[0].next; np;
- np = (EjsVar*) np->gc.next) {
- if (vp == np) {
- if (prev) {
- prev->gc.next = (EjsGCLink*) np->gc.next;
- } else {
- slab->allocList[0].next = (EjsGCLink*) np->gc.next;
- }
- break;
- }
- prev = np;
- }
- if (np == 0) {
- mprAssert(0);
- }
- }
-#endif
-
- /*
- * Insert into the free list. Only use the next ptr
- */
- block = (EjsGCLink*) ptr;
-
-#if BLD_DEBUG
-#if !BREW || BREW_SIMULATOR
- if ((uint) block == breakAddr) {
- mprBreakpoint(MPR_LOC, "Watched Block");
- }
-#endif
- mprAssert(block->magic == EJS_MAGIC);
- block->magic = EJS_MAGIC_FREE;
-#endif
-
- block->next = slab->freeList.next;
- slab->freeList.next = block;
-
-#if BLD_FEATURE_ALLOC_STATS
- slab->allocCount--;
- if (++slab->freeCount >= slab->peakFree) {
- slab->peakFree = slab->freeCount;
- }
- slab->totalReclaimed++;
- if (slabIndex != 2) {
- slabIndex = slabIndex;
- }
-#endif
-}
-
-/******************************************************************************/
-/*
- * Mark an object as being in-use. Traverse all properties for referenced
- * objects and base classes.
- */
-
-static void markObjByVar(Ejs *ep, EjsVar *obj)
-{
- EjsProperty *pp;
- EjsVar *vp, *baseClass;
-
- mprAssert(ep);
- mprAssert(obj);
-
- obj->objectState->gcMarked = 1;
-
-#if BLD_DEBUG
- if (ep->gc.debugLevel >= 3) {
- int indent = min(ep->gc.gcIndent * 2, 32);
- mprLog(ep, 0, "%.*s %-24s %.*s 0x%08X",
- indent, " ",
- obj->propertyName,
- 32 - indent, "................................ ",
- (uint) obj->objectState);
- ep->gc.gcIndent++;
- }
- ep->gc.objectsInUse++;
-#endif
-
- /*
- * Traverse all referenced objects
- * OPT -- optimize by directly accessing the object links and not using
- * ejsGetFirst/NextProperty. Then just examine objects
- * OPT -- first property in global is global. Should optimize this.
- */
- pp = ejsGetFirstProperty(obj, EJS_ENUM_ALL);
- while (pp) {
- vp = ejsGetVarPtr(pp);
- if (vp->type == EJS_TYPE_OBJECT) {
- if (!vp->objectState->gcMarked) {
-#if FUTURE
- /*
- * OPT -- we can use the dirty bit on objects to avoid
- * visiting permanent objects that are clean. If so, don't
- * forget the else case below.
- */
- obj = vp->objectState;
- if ((!obj->alive && !obj->permanent) || obj->dirty)
-#endif
- markObjByVar(ep, vp);
- }
-
- } else {
-#if BLD_DEBUG
- if (ep->gc.debugLevel >= 3) {
- int indent = min(ep->gc.gcIndent * 2, 32);
- mprLog(ep, 0, "%.*s %-24s %.*s %s",
- indent, " ",
- vp->propertyName,
- 32 - indent, "................................ ",
- ejsGetVarTypeAsString(vp));
- }
- ep->gc.propertiesInUse++;
-#endif
- }
- pp = ejsGetNextProperty(pp, EJS_ENUM_ALL);
- }
-
- /*
- * Traverse the base class
- */
- baseClass = obj->objectState->baseClass;
- if (baseClass) {
- mprAssert(baseClass->type == EJS_TYPE_OBJECT);
- mprAssert(baseClass->objectState);
- if (baseClass->objectState) {
- if (! baseClass->objectState->gcMarked) {
- markObjByVar(ep, baseClass);
- }
- }
- }
-#if BLD_DEBUG
- if (ep->gc.debugLevel >= 3) {
- ep->gc.gcIndent--;
- }
-#endif
-}
-
-
-/******************************************************************************/
-/*
- * Mark phase. Examine all variable frames and the return result.
- */
-
-static void mark(Ejs *ep)
-{
- EjsVar *vp;
- int i;
-
-#if BLD_DEBUG
- if (ep->gc.debugLevel >= 3) {
- mprLog(ep, 0, " ");
- mprLog(ep, 0, "GC: Marked Blocks:");
- }
-#endif
-
- if (ep->frames) {
- for (i = 0; i < mprGetItemCount(ep->frames); i++) {
-
- vp = (EjsVar*) mprGetItem(ep->frames, i);
- mprAssert(vp->type == EJS_TYPE_OBJECT);
-
- if (! vp->objectState->gcMarked) {
- markObjByVar(ep, vp);
- }
- }
- }
-
- vp = ep->result;
- if (vp && vp->type == EJS_TYPE_OBJECT && ! vp->objectState->gcMarked) {
- markObjByVar(ep, vp);
- }
-
- vp = ep->currentObj;
- if (vp && vp->type == EJS_TYPE_OBJECT && ! vp->objectState->gcMarked) {
- markObjByVar(ep, vp);
- }
-
- vp = ejsGetVarPtr(ep->currentProperty);
- if (vp && vp->type == EJS_TYPE_OBJECT && ! vp->objectState->gcMarked) {
- markObjByVar(ep, vp);
- }
-
- /*
- * OPT -- we could mark master as "mark permanent" somehow and
- * then we would not need to walk the master objects.
- */
- if (ep->slabAllocContext == ep->service->master) {
- if (ep->service->master->global) {
- markObjByVar(ep, ep->service->master->global);
- }
- }
-
-#if BLD_DEBUG
- if (ep->gc.debugLevel >= 3) {
- mprLog(ep, 0, " ");
- }
-#endif
-}
-
-
-/******************************************************************************/
-#if UNUSED
-
-static void resetMark(EjsVar *obj)
-{
- EjsProperty *pp;
- EjsVar *vp, *baseClass;
-
- obj->objectState->gcMarked = 0;
- obj->objectState->visited = 1;
-
- pp = ejsGetFirstProperty(obj, EJS_ENUM_ALL);
- while (pp) {
- vp = ejsGetVarPtr(pp);
- if (vp->type == EJS_TYPE_OBJECT && !vp->objectState->visited) {
- resetMark(vp);
- }
- pp = ejsGetNextProperty(pp, EJS_ENUM_ALL);
- }
-
- baseClass = obj->objectState->baseClass;
- if (baseClass) {
- mprAssert(baseClass->type == EJS_TYPE_OBJECT);
- mprAssert(baseClass->objectState);
- if (baseClass->objectState) {
- if (! baseClass->objectState->visited) {
- resetMark(baseClass);
- }
- }
- }
- obj->objectState->visited = 0;
-}
-
-/******************************************************************************/
-/*
- * Mark phase. Examine all variable frames and the return result.
- */
-
-static void resetAllMarks(Ejs *ep)
-{
- EjsVar *vp;
- int i;
-
- for (i = 0; i < mprGetItemCount(ep->frames); i++) {
- vp = (EjsVar*) mprGetItem(ep->frames, i);
- resetMark(vp);
- }
-
- if (ep->result && ep->result->type == EJS_TYPE_OBJECT &&
- ! ep->result->objectState->gcMarked) {
- resetMark(ep->result);
- }
-}
-
-#endif
-/******************************************************************************/
-/*
- * Sweep up the garbage
- */
-
-static void resetMarks(Ejs *ep, EjsSlab *slab)
-{
- EjsVar *vp;
- EjsObj *obj;
- int gen, i;
-
- for (gen = EJS_GEN_NEW; gen < EJS_GEN_MAX; gen++) {
- obj = (EjsObj*) slab->allocList[gen].next;
- for (; obj; obj = (EjsObj*) obj->gc.next) {
- obj->gcMarked = 0;
- obj->visited = 0;
- }
- }
-
- if (ep->frames) {
- for (i = 0; i < mprGetItemCount(ep->frames); i++) {
-
- vp = (EjsVar*) mprGetItem(ep->frames, i);
- mprAssert(vp->type == EJS_TYPE_OBJECT);
-
- vp->objectState->gcMarked = 0;
- vp->objectState->visited = 0;
- }
- }
-
- if (ep->result && ep->result->type == EJS_TYPE_OBJECT) {
- ep->result->objectState->gcMarked = 0;
- }
-}
-
-/******************************************************************************/
-/*
- * Mark all permanent and non-alive objects
- */
-
-static void markPerm(Ejs *ep, uint gen)
-{
- EjsSlab *slab;
- EjsObj *obj;
-
- slab = &ep->slabs[EJS_SLAB_OBJ];
-
- for (obj = (EjsObj*) slab->allocList[gen].next; obj; ) {
-
- if (! obj->gcMarked) {
- if (!obj->alive || obj->permanent) {
- markObj(obj);
- }
- }
- obj = (EjsObj*) obj->gc.next;
-
- }
-}
-
-/******************************************************************************/
-
-static void markObj(EjsObj *obj)
-{
- EjsProperty *pp;
- EjsPropLink *lp, *head;
- EjsObj *op;
-
- mprAssert(obj);
-
- obj->gcMarked = 1;
-
- head = &obj->link;
- for (lp = head->next; lp != head; lp = lp->next) {
-
- pp = ejsGetPropertyFromLink(lp);
-
- if (pp->var.type == EJS_TYPE_OBJECT) {
- op = pp->var.objectState;
- if (op != 0 && !op->gcMarked) {
- markObj(op);
- }
- }
- }
-}
-
-/******************************************************************************/
-/*
- * Sweep up the garbage. Return the number of objects freed.
- */
-
-static int sweep(Ejs *ep, uint gen)
-{
- EjsSlab *slab;
- EjsObj *obj, *next, *prev;
- int count;
-
- slab = &ep->slabs[EJS_SLAB_OBJ];
-
- /*
- * Examine allocated objects in the specified generation (only).
- * NOTE: we only sweep object allocated to this interpreter and so
- * we do not sweep any permanent objects in the default interpreter.
- */
- prev = 0;
- count = 0;
- for (obj = (EjsObj*) slab->allocList[gen].next; obj; obj = next) {
-
- next = (EjsObj*) obj->gc.next;
-
-#if BLD_DEBUG && (!BREW || BREW_SIMULATOR)
- if ((uint) obj == breakAddr) {
- mprBreakpoint(MPR_LOC, "Watched Block");
- }
-#endif
-
- /*
- * If object has not been marked inuse and is not a permanent
- * object, then free it.
- */
- if (! obj->gcMarked && obj->alive && !obj->permanent) {
-
-#if BLD_DEBUG
- if (ep->gc.debugLevel >= 2) {
- if (obj->objName) {
- mprLog(ep, 0, "GC: destroy %-18s %10d, %8X",
- obj->objName, (uint) obj, (uint) obj);
- } else {
- mprLog(ep, 0, "GC: destroy UNKNOWN %x", (uint) obj);
- }
- }
-#endif
- if (ejsDestroyObj(ep, obj) < 0) {
- prev = obj;
- obj->gcMarked = 0;
- continue;
- }
-
- if (prev) {
- prev->gc.next = (EjsGCLink*) next;
- } else {
- slab->allocList[gen].next = (EjsGCLink*) next;
- }
- count++;
-
- } else {
- prev = obj;
- /* Reset for next time */
- obj->gcMarked = 0;
- }
- }
-
- if (gen == (EJS_GEN_OLD - 1)) {
- slab->lastRecentBlock = prev;
- }
-#if BLD_FEATURE_ALLOC_STATS
- slab->totalSweeps++;
-#endif
-#if BLD_DEBUG
- if (ep->gc.debugLevel > 0) {
- mprLog(ep, 0, "GC: Sweep freed %d objects", count);
- }
-#endif
- return count;
-}
-
-/******************************************************************************/
-/*
- * Sweep all variables
- */
-
-void ejsSweepAll(Ejs *ep)
-{
- EjsSlab *slab;
- EjsObj *obj, *next, *prev;
- int gen;
-
- slab = &ep->slabs[EJS_SLAB_OBJ];
-
- for (gen = EJS_GEN_NEW; gen < EJS_GEN_MAX; gen++) {
- prev = 0;
- for (obj = (EjsObj*) slab->allocList[gen].next; obj; obj = next) {
- next = (EjsObj*) obj->gc.next;
- ejsDestroyObj(ep, obj);
- }
- break;
- }
-}
-
-/******************************************************************************/
-
-bool ejsObjIsCollectable(EjsVar *vp)
-{
- if (vp == 0 || !ejsVarIsObject(vp)) {
- return 0;
- }
- return (vp->objectState->alive && !vp->objectState->permanent);
-}
-
-/******************************************************************************/
-#if FUTURE
-
-static void ageGenerations(Ejs *ep)
-{
- EjsSlab *slab;
- EjsGCLink *oldList;
- int gen;
-
- slab = &ep->slabs[EJS_SLAB_OBJ];
-
- /*
- * Age all blocks. First append all (old - 1) blocks onto the old
- * alloc list
- */
- oldList = &slab->allocList[EJS_GEN_OLD];
-
- if (slab->lastRecentBlock) {
- slab->lastRecentBlock->gc.next = oldList->next;
- oldList->next = (EjsGCLink*) slab->lastRecentBlock;
- }
-
- /*
- * Now simply copy all allocation lists up one generation
- */
- for (gen = EJS_GEN_OLD - 1; gen > 0; gen--) {
- slab->allocList[gen] = slab->allocList[gen - 1];
- }
- slab->allocList[0].next = 0;
-}
-
-#endif
-/******************************************************************************/
-/*
- * Collect the garbage. This is a mark and sweep over all possible objects.
- * If an object is not referenced, it and all contained properties will be
- * freed. If a slabIndex is provided, the collection halts when a block is
- * available for allocation on that slab.
- *
- * Return 0 if memory is now available after collecting garbage. Otherwise,
- * return MPR_ERR_MEMORY.
- */
-
-int ejsCollectGarbage(Ejs *ep, int slabIndex)
-{
- EjsGeneration gen;
-
- if (ep->flags & EJS_FLAGS_DONT_GC) {
- return -1;
- }
-
- /*
- * Prevent destructors invoking the garbage collector
- */
- if (ep->gc.collecting) {
- return 0;
- }
- ep->gc.collecting = 1;
-
- resetMarks(ep, &ep->slabs[EJS_SLAB_OBJ]);
-
- /*
- * Examine each generation of objects starting with the most recent
- * generation. Stop scanning when we have a free block to use.
- */
- for (gen = EJS_GEN_NEW; gen < EJS_GEN_MAX; gen++) {
-
- if (slabIndex >= 0 && ep->slabs[slabIndex].freeList.next) {
- break;
- }
-
- /*
- * FUTURE OPT. Should mark objects in new generation and those
- * with a dirty bit set in older generations. Don't need to mark
- * entire heap. But how to keep list of dirty objects.
- */
- mark(ep);
- markPerm(ep, gen);
- sweep(ep, gen);
-
- /* FUTURE - not using generations yet */
- break;
- }
-
- /*
- * FUTURE -- not using generations yet.
- *
- * ageGenerations(ep);
- */
-
- ep->gc.workDone = 0;
- ep->gc.collecting = 0;
-
- return (gen < EJS_GEN_MAX) ? 0 : MPR_ERR_MEMORY;
-}
-
-
-/******************************************************************************/
-/*
- * Should be called when the app has been idle for a little while and when it
- * is likely to be idle a bit longer. Call ejsIsTimeForGC to see if this is
- * true. Return the count of objects collected .
- */
-
-int ejsIncrementalCollectGarbage(Ejs *ep)
-{
- int count;
-
- if (ep->gc.collecting) {
- return 0;
- }
-
- ep->gc.collecting = 1;
-
- resetMarks(ep, &ep->slabs[EJS_SLAB_OBJ]);
- mark(ep);
-
- /* Not generational yet */
- count = sweep(ep, EJS_GEN_NEW);
-
- ep->gc.collecting = 0;
- ep->gc.workDone = 0;
-
- return count;
-}
-
-/******************************************************************************/
-#if BLD_DEBUG
-
-void ejsDumpObjects(Ejs *ep)
-{
- int oldDebugLevel;
-
- mprLog(ep, 0, "Dump of objects in use\n");
-
- oldDebugLevel = ep->gc.debugLevel;
-
- ep->gc.debugLevel = 3;
- ep->gc.objectsInUse = 0;
- ep->gc.propertiesInUse = 0;
- ep->gc.collecting = 1;
-
- resetMarks(ep, &ep->slabs[EJS_SLAB_OBJ]);
- mark(ep);
-
- ep->gc.collecting = 0;
- ep->gc.debugLevel = oldDebugLevel;
-
- mprLog(ep, 0, "%d objects and %d properties in use",
- ep->gc.objectsInUse, ep->gc.propertiesInUse);
- mprLog(ep, 0, "%d object bytes, %d property bytes and %d total",
- (int) (ep->gc.objectsInUse * sizeof(EjsObj)),
- (int) (ep->gc.propertiesInUse * sizeof(EjsProperty)),
- (int) ((ep->gc.objectsInUse * sizeof(EjsObj) +
- ep->gc.propertiesInUse * sizeof(EjsProperty))));
-}
-
-#endif
-/******************************************************************************/
-/*
- * Return true if there is time to do a garbage collection and if we will
- * benefit from it.
- */
-
-int ejsIsTimeForGC(Ejs *ep, int timeTillNextEvent)
-{
- EjsGC *gc;
-
- if (timeTillNextEvent < EJS_MIN_TIME_FOR_GC) {
- /*
- * Not enough time to complete a collection
- */
- return 0;
- }
-
- gc = &ep->gc;
-
- /*
- * Return if we haven't done enough work to warrant a collection
- * Trigger a little short of the work quota to try to run GC before
- * a demand allocation requires it.
- */
- if (!gc->enable || !gc->enableIdleCollect ||
- (gc->workDone < (gc->workQuota - EJS_GC_MIN_WORK_QUOTA))) {
- return 0;
- }
-
-#if UNUSED
- mprLog(ep, 0, "Time for GC. Work done %d, time till next event %d",
- gc->workDone, timeTillNextEvent);
-#endif
- return 1;
-}
-
-/******************************************************************************/
-/*
- * Return the amount of memory in use by EJS
- */
-
-uint ejsGetUsedMemory(Ejs *ep)
-{
-#if BLD_FEATURE_ALLOC_STATS
- EjsSlab *slab;
- int i, totalMemory, slabMemory;
-
- totalMemory = 0;
- for (i = 0; i < EJS_SLAB_MAX; i++) {
- slab = &ep->slabs[i];
- slabMemory = slab->allocCount * slab->size;
- totalMemory += slabMemory;
- }
- return totalMemory;
-#else
- return 0;
-#endif
-}
-
-/******************************************************************************/
-/*
- * Return the amount of memory allocated by EJS
- */
-
-uint ejsGetAllocatedMemory(Ejs *ep)
-{
-#if BLD_FEATURE_ALLOC_STATS
- EjsSlab *slab;
- int i, totalMemory, slabMemory;
-
- totalMemory = 0;
- for (i = 0; i < EJS_SLAB_MAX; i++) {
- slab = &ep->slabs[i];
- slabMemory = (slab->allocCount + slab->freeCount) * slab->size;
- totalMemory += slabMemory;
- }
- return totalMemory;
-#else
- return 0;
-#endif
-}
-
-/******************************************************************************/
-/*
- * On a memory allocation failure, go into graceful degrade mode. Set all
- * slab allocation chunk increments to 1 so we can create an exception block
- * to throw.
- */
-
-static void ejsGracefulDegrade(Ejs *ep)
-{
- EjsSlab *slab;
- int i;
-
- mprLog(ep, 1, "WARNING: Memory almost depleted. In graceful degrade mode");
- for (i = 0; i < EJS_SLAB_MAX; i++) {
- slab = &ep->slabs[i];
- slab->allocIncrement = 8;
- }
- ep->gc.degraded = 1;
-}
-
-/******************************************************************************/
-
-int ejsSetGCDebugLevel(Ejs *ep, int debugLevel)
-{
- int old;
-
- old = ep->gc.debugLevel;
- ep->gc.debugLevel = debugLevel;
- return old;
-}
-
-/******************************************************************************/
-
-int ejsSetGCMaxMemory(Ejs *ep, uint maxMemory)
-{
- int old;
-
- old = ep->gc.maxMemory;
- ep->gc.maxMemory = maxMemory;
-
- return old;
-}
-
-/******************************************************************************/
-
-bool ejsBlockInUseInt(EjsVar *vp)
-{
- if (vp) {
-#if BLD_DEBUG
- if (vp->gc.magic != EJS_MAGIC) {
- return 0;
- }
- if (vp->type == EJS_TYPE_OBJECT && vp->objectState &&
- vp->objectState->gc.magic != EJS_MAGIC) {
- return 0;
- }
-#endif
- return 1;
- }
- return 1;
-}
-
-/******************************************************************************/
-#else
-void ejsGarbageDummy() {}
-
-#endif /* BLD_FEATURE_EJS */
-
-/******************************************************************************/
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejsLex.c b/source4/lib/appweb/ejs-2.0/ejs/ejsLex.c
deleted file mode 100644
index fbfee6e4d5..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/ejsLex.c
+++ /dev/null
@@ -1,1033 +0,0 @@
-/*
- * @file ejsLex.c
- * @brief EJS Lexical Analyser
- * @overview EJS lexical analyser. This implementes a lexical analyser
- * for a subset of the JavaScript language.
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default.g
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-#if BLD_FEATURE_EJS
-
-/****************************** Forward Declarations **************************/
-
-static int getLexicalToken(Ejs *ep, int state);
-static int tokenAddChar(Ejs *ep, int c);
-static int inputGetc(Ejs *ep);
-static void inputPutback(Ejs *ep, int c);
-static int charConvert(Ejs *ep, int base, int maxDig);
-static void parseNumber(Ejs *ep, EjsType type);
-
-/************************************* Code ***********************************/
-/*
- * Open a new input script
- */
-
-int ejsLexOpenScript(Ejs *ep, const char *script)
-{
- EjsInput *ip;
-
- mprAssert(ep);
- mprAssert(script);
-
- if ((ip = mprAllocTypeZeroed(ep, EjsInput)) == NULL) {
- return MPR_ERR_MEMORY;
- }
- ip->next = ep->input;
- ep->input = ip;
- ip->procName = ep->proc ? ep->proc->procName : NULL;
- ip->fileName = ep->fileName ? ep->fileName : NULL;
-
-/*
- * Create the parse token buffer and script buffer
- */
- ip->tokServp = ip->tokbuf;
- ip->tokEndp = ip->tokbuf;
-
- ip->script = script;
- ip->scriptSize = strlen(script);
- ip->scriptServp = (char*) ip->script;
-
- ip->lineNumber = 1;
- ip->lineColumn = 0;
-
- ip->putBackIndex = -1;
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Close the input script
- */
-
-void ejsLexCloseScript(Ejs *ep)
-{
- EjsInput *ip;
-
- mprAssert(ep);
-
- ip = ep->input;
- mprAssert(ip);
- ep->input = ip->next;
-
- mprFree(ip);
-}
-
-/******************************************************************************/
-/*
- * Initialize an input state structure
- */
-
-int ejsInitInputState(EjsInput *ip)
-{
- mprAssert(ip);
-
- memset(ip, 0, sizeof(*ip));
- ip->putBackIndex = -1;
-
- return 0;
-}
-/******************************************************************************/
-/*
- * Save the input state
- */
-
-void ejsLexSaveInputState(Ejs *ep, EjsInput *state)
-{
- EjsInput *ip;
- int i;
-
- mprAssert(ep);
-
- ip = ep->input;
- mprAssert(ip);
-
- *state = *ip;
-
- for (i = 0; i <= ip->putBackIndex; i++) {
- mprStrcpy(state->putBack[i].tokbuf, EJS_MAX_TOKEN,
- ip->putBack[i].tokbuf);
- state->putBack[i].tid = ip->putBack[i].tid;
- }
-
- mprStrcpy(state->line, sizeof(state->line), ip->line);
-
- state->lineColumn = ip->lineColumn;
- state->lineNumber = ip->lineNumber;
-}
-
-/******************************************************************************/
-/*
- * Restore the input state
- */
-
-void ejsLexRestoreInputState(Ejs *ep, EjsInput *state)
-{
- EjsInput *ip;
- EjsToken *tp;
- int i;
-
- mprAssert(ep);
- mprAssert(state);
-
- ip = ep->input;
- mprAssert(ip);
-
- mprStrcpy(ip->tokbuf, sizeof(ip->tokbuf), state->tokbuf);
- ip->tokServp = state->tokServp;
- ip->tokEndp = state->tokEndp;
-
- ip->script = state->script;
- ip->scriptServp = state->scriptServp;
- ip->scriptSize = state->scriptSize;
-
- ip->putBackIndex = state->putBackIndex;
- for (i = 0; i <= ip->putBackIndex; i++) {
- tp = &ip->putBack[i];
- tp->tid = state->putBack[i].tid;
- mprStrcpy(tp->tokbuf, sizeof(tp->tokbuf), state->putBack[i].tokbuf);
- }
-
- mprStrcpy(ip->line, sizeof(ip->line), state->line);
-
- ip->lineColumn = state->lineColumn;
- ip->lineNumber = state->lineNumber;
-}
-
-/******************************************************************************/
-/*
- * Free a saved input state
- */
-
-void ejsLexFreeInputState(Ejs *ep, EjsInput *state)
-{
- mprAssert(ep);
- mprAssert(state);
-
- state->putBackIndex = -1;
- state->lineColumn = 0;
-}
-
-/******************************************************************************/
-/*
- * Get the next EJS token
- */
-
-int ejsLexGetToken(Ejs *ep, int state)
-{
- mprAssert(ep);
-
- ep->tid = getLexicalToken(ep, state);
- return ep->tid;
-}
-
-/******************************************************************************/
-
-/*
- * Check for reserved words "if", "else", "var", "for", "delete", "function",
- * "class", "extends", "public", "private", "protected", "try", "catch",
- * "finally", "throw", "return", "get", "set", "this", "module", "each"
- *
- * The "new" and "in" reserved words are handled below. The "true", "false",
- * "null" "typeof" and "undefined" reserved words are handled as global
- * objects.
- *
- * Other reserved words not supported:
- * "break", "case", "continue", "default", "do",
- * "instanceof", "switch", "while", "with"
- *
- * ECMA extensions reserved words (not supported):
- * "abstract", "boolean", "byte", "char", "const",
- * "debugger", "double", "enum", "export",
- * "final", "float", "goto", "implements", "import", "int",
- * "interface", "long", "native", "package",
- * "short", "static", "super", "synchronized", "transient", "volatile"
- *
- * FUTURE -- use a hash lookup
- */
-
-static int checkReservedWord(Ejs *ep, int state, int c, int tid)
-{
- /* FUTURE -- probably should return for all tokens != EJS_TOK_ID */
- /* FUTURE -- Should have a hash for this. MUCH faster. */
-
- if (!isalpha(ep->token[0]) || tid == EJS_TOK_LITERAL) {
- return tid;
- }
- if (state == EJS_STATE_STMT) {
- /* FUTURE OPT -- convert to hash lookup */
- if (strcmp(ep->token, "if") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_IF;
- } else if (strcmp(ep->token, "else") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_ELSE;
- } else if (strcmp(ep->token, "var") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_VAR;
- } else if (strcmp(ep->token, "new") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_NEW;
- } else if (strcmp(ep->token, "for") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_FOR;
- } else if (strcmp(ep->token, "delete") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_DELETE;
- } else if (strcmp(ep->token, "function") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_FUNCTION;
- } else if (strcmp(ep->token, "class") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_CLASS;
- } else if (strcmp(ep->token, "module") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_MODULE;
- } else if (strcmp(ep->token, "extends") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_EXTENDS;
- } else if (strcmp(ep->token, "try") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_TRY;
- } else if (strcmp(ep->token, "catch") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_CATCH;
- } else if (strcmp(ep->token, "finally") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_FINALLY;
- } else if (strcmp(ep->token, "throw") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_THROW;
- } else if (strcmp(ep->token, "public") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_PUBLIC;
- } else if (strcmp(ep->token, "protected") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_PROTECTED;
- } else if (strcmp(ep->token, "private") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_PRIVATE;
- } else if (strcmp(ep->token, "get") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_GET;
- } else if (strcmp(ep->token, "set") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_SET;
- } else if (strcmp(ep->token, "extends") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_EXTENDS;
- } else if (strcmp(ep->token, "try") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_TRY;
- } else if (strcmp(ep->token, "catch") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_CATCH;
- } else if (strcmp(ep->token, "finally") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_FINALLY;
- } else if (strcmp(ep->token, "throw") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_THROW;
- } else if (strcmp(ep->token, "public") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_PUBLIC;
- } else if (strcmp(ep->token, "protected") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_PROTECTED;
- } else if (strcmp(ep->token, "private") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_PRIVATE;
- } else if (strcmp(ep->token, "get") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_GET;
- } else if (strcmp(ep->token, "set") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_SET;
- } else if (strcmp(ep->token, "each") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_EACH;
- } else if (strcmp(ep->token, "return") == 0) {
- if ((c == ';') || (c == '(')) {
- inputPutback(ep, c);
- }
- return EJS_TOK_RETURN;
- }
-
- } else if (state == EJS_STATE_EXPR) {
- if (strcmp(ep->token, "new") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_NEW;
- } else if (strcmp(ep->token, "in") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_IN;
- } else if (strcmp(ep->token, "function") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_FUNCTION;
- }
-
- } else if (state == EJS_STATE_DEC) {
- if (strcmp(ep->token, "extends") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_EXTENDS;
- }
- }
- return tid;
-}
-
-/******************************************************************************/
-/*
- * Get the next EJS token
- */
-
-static int getLexicalToken(Ejs *ep, int state)
-{
- EjsType type;
- EjsInput *ip;
- int done, tid, c, quote, style, idx, isHex;
-
- mprAssert(ep);
- ip = ep->input;
- mprAssert(ip);
-
- ep->tid = -1;
- tid = -1;
- type = BLD_FEATURE_NUM_TYPE_ID;
- isHex = 0;
-
- /*
- * Use a putback tokens first. Don't free strings as caller needs access.
- */
- if (ip->putBackIndex >= 0) {
- idx = ip->putBackIndex;
- tid = ip->putBack[idx].tid;
- ep->token = (char*) ip->putBack[idx].tokbuf;
- tid = checkReservedWord(ep, state, 0, tid);
- ip->putBackIndex--;
- return tid;
- }
- ep->token = ip->tokServp = ip->tokEndp = ip->tokbuf;
- *ip->tokServp = '\0';
-
- if ((c = inputGetc(ep)) < 0) {
- return EJS_TOK_EOF;
- }
-
- /*
- * Main lexical analyser
- */
- for (done = 0; !done; ) {
- switch (c) {
- case -1:
- return EJS_TOK_EOF;
-
- case ' ':
- case '\t':
- case '\r':
- do {
- if ((c = inputGetc(ep)) < 0)
- break;
- } while (c == ' ' || c == '\t' || c == '\r');
- break;
-
- case '\n':
- return EJS_TOK_NEWLINE;
-
- case '(':
- tokenAddChar(ep, c);
- return EJS_TOK_LPAREN;
-
- case ')':
- tokenAddChar(ep, c);
- return EJS_TOK_RPAREN;
-
- case '[':
- tokenAddChar(ep, c);
- return EJS_TOK_LBRACKET;
-
- case ']':
- tokenAddChar(ep, c);
- return EJS_TOK_RBRACKET;
-
- case '.':
- tokenAddChar(ep, c);
- return EJS_TOK_PERIOD;
-
- case '{':
- tokenAddChar(ep, c);
- return EJS_TOK_LBRACE;
-
- case '}':
- tokenAddChar(ep, c);
- return EJS_TOK_RBRACE;
-
- case '+':
- if ((c = inputGetc(ep)) < 0) {
- ejsSyntaxError(ep, 0);
- return EJS_TOK_ERR;
- }
- if (c != '+' ) {
- inputPutback(ep, c);
- tokenAddChar(ep, EJS_EXPR_PLUS);
- return EJS_TOK_EXPR;
- }
- tokenAddChar(ep, EJS_EXPR_INC);
- return EJS_TOK_INC_DEC;
-
- case '-':
- if ((c = inputGetc(ep)) < 0) {
- ejsSyntaxError(ep, 0);
- return EJS_TOK_ERR;
- }
- if (c != '-' ) {
- inputPutback(ep, c);
- tokenAddChar(ep, EJS_EXPR_MINUS);
- return EJS_TOK_EXPR;
- }
- tokenAddChar(ep, EJS_EXPR_DEC);
- return EJS_TOK_INC_DEC;
-
- case '*':
- tokenAddChar(ep, EJS_EXPR_MUL);
- return EJS_TOK_EXPR;
-
- case '%':
- tokenAddChar(ep, EJS_EXPR_MOD);
- return EJS_TOK_EXPR;
-
- case '/':
- /*
- * Handle the division operator and comments
- */
- if ((c = inputGetc(ep)) < 0) {
- ejsSyntaxError(ep, 0);
- return EJS_TOK_ERR;
- }
- if (c != '*' && c != '/') {
- inputPutback(ep, c);
- tokenAddChar(ep, EJS_EXPR_DIV);
- return EJS_TOK_EXPR;
- }
- style = c;
- /*
- * Eat comments. Both C and C++ comment styles are supported.
- */
- while (1) {
- if ((c = inputGetc(ep)) < 0) {
- if (style == '/') {
- return EJS_TOK_EOF;
- }
- ejsSyntaxError(ep, 0);
- return EJS_TOK_ERR;
- }
- if (c == '\n' && style == '/') {
- break;
- } else if (c == '*') {
- c = inputGetc(ep);
- if (style == '/') {
- if (c == '\n') {
- break;
- }
- } else {
- if (c == '/') {
- break;
- }
- }
- }
- }
- /*
- * Continue looking for a token, so get the next character
- */
- if ((c = inputGetc(ep)) < 0) {
- return EJS_TOK_EOF;
- }
- break;
-
- case '<': /* < and <= */
- if ((c = inputGetc(ep)) < 0) {
- ejsSyntaxError(ep, 0);
- return EJS_TOK_ERR;
- }
- if (c == '<') {
- tokenAddChar(ep, EJS_EXPR_LSHIFT);
- return EJS_TOK_EXPR;
- } else if (c == '=') {
- tokenAddChar(ep, EJS_EXPR_LESSEQ);
- return EJS_TOK_EXPR;
- }
- tokenAddChar(ep, EJS_EXPR_LESS);
- inputPutback(ep, c);
- return EJS_TOK_EXPR;
-
- case '>': /* > and >= */
- if ((c = inputGetc(ep)) < 0) {
- ejsSyntaxError(ep, 0);
- return EJS_TOK_ERR;
- }
- if (c == '>') {
- tokenAddChar(ep, EJS_EXPR_RSHIFT);
- return EJS_TOK_EXPR;
- } else if (c == '=') {
- tokenAddChar(ep, EJS_EXPR_GREATEREQ);
- return EJS_TOK_EXPR;
- }
- tokenAddChar(ep, EJS_EXPR_GREATER);
- inputPutback(ep, c);
- return EJS_TOK_EXPR;
-
- case '=': /* "==" */
- if ((c = inputGetc(ep)) < 0) {
- ejsSyntaxError(ep, 0);
- return EJS_TOK_ERR;
- }
- if (c == '=') {
- tokenAddChar(ep, EJS_EXPR_EQ);
- return EJS_TOK_EXPR;
- }
- inputPutback(ep, c);
- return EJS_TOK_ASSIGNMENT;
-
- case '!': /* "!=" or "!"*/
- if ((c = inputGetc(ep)) < 0) {
- ejsSyntaxError(ep, 0);
- return EJS_TOK_ERR;
- }
- if (c == '=') {
- tokenAddChar(ep, EJS_EXPR_NOTEQ);
- return EJS_TOK_EXPR;
- }
- inputPutback(ep, c);
- tokenAddChar(ep, EJS_EXPR_BOOL_COMP);
- return EJS_TOK_EXPR;
-
- case ';':
- tokenAddChar(ep, c);
- return EJS_TOK_SEMI;
-
- case ',':
- tokenAddChar(ep, c);
- return EJS_TOK_COMMA;
-
- case ':':
- tokenAddChar(ep, c);
- return EJS_TOK_COLON;
-
- case '|': /* "||" */
- if ((c = inputGetc(ep)) < 0 || c != '|') {
- ejsSyntaxError(ep, 0);
- return EJS_TOK_ERR;
- }
- tokenAddChar(ep, EJS_COND_OR);
- return EJS_TOK_LOGICAL;
-
- case '&': /* "&&" */
- if ((c = inputGetc(ep)) < 0 || c != '&') {
- ejsSyntaxError(ep, 0);
- return EJS_TOK_ERR;
- }
- tokenAddChar(ep, EJS_COND_AND);
- return EJS_TOK_LOGICAL;
-
- case '\"': /* String quote */
- case '\'':
- quote = c;
- if ((c = inputGetc(ep)) < 0) {
- ejsSyntaxError(ep, 0);
- return EJS_TOK_ERR;
- }
-
- while (c != quote) {
- /*
- * Check for escape sequence characters
- */
- if (c == '\\') {
- c = inputGetc(ep);
-
- if (isdigit(c)) {
- /*
- * Octal support, \101 maps to 65 = 'A'. Put first
- * char back so converter will work properly.
- */
- inputPutback(ep, c);
- c = charConvert(ep, 8, 3);
-
- } else {
- switch (c) {
- case 'n':
- c = '\n'; break;
- case 'b':
- c = '\b'; break;
- case 'f':
- c = '\f'; break;
- case 'r':
- c = '\r'; break;
- case 't':
- c = '\t'; break;
- case 'x':
- /*
- * Hex support, \x41 maps to 65 = 'A'
- */
- c = charConvert(ep, 16, 2);
- break;
- case 'u':
- /*
- * Unicode support, \x0401 maps to 65 = 'A'
- */
- c = charConvert(ep, 16, 2);
- c = c*16 + charConvert(ep, 16, 2);
-
- break;
- case '\'':
- case '\"':
- case '\\':
- break;
- default:
- if (tokenAddChar(ep, '\\') < 0) {
- return EJS_TOK_ERR;
- }
- }
- }
- if (tokenAddChar(ep, c) < 0) {
- return EJS_TOK_ERR;
- }
- } else {
- if (tokenAddChar(ep, c) < 0) {
- return EJS_TOK_ERR;
- }
- }
- if ((c = inputGetc(ep)) < 0) {
- ejsSyntaxError(ep, "Unmatched Quote");
- return EJS_TOK_ERR;
- }
- }
- return EJS_TOK_LITERAL;
-
- case '0':
- if (tokenAddChar(ep, c) < 0) {
- return EJS_TOK_ERR;
- }
- if ((c = inputGetc(ep)) < 0) {
- break;
- }
- if (tolower(c) == 'x') {
- if (tokenAddChar(ep, c) < 0) {
- return EJS_TOK_ERR;
- }
- if ((c = inputGetc(ep)) < 0) {
- break;
- }
- isHex = 1;
- if (! isxdigit(c)) {
- parseNumber(ep, type);
- inputPutback(ep, c);
- return EJS_TOK_NUMBER;
- }
- } else if (! isdigit(c)) {
-#if BLD_FEATURE_FLOATING_POINT
- if (c == '.' || tolower(c) == 'e' || c == '+' || c == '-') {
- /* Fall through */
- type = EJS_TYPE_FLOAT;
- } else
-#endif
- {
- parseNumber(ep, type);
- inputPutback(ep, c);
- return EJS_TOK_NUMBER;
- }
- }
- /* Fall through to get more digits */
-
- case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- if (isHex) {
- do {
- if (tokenAddChar(ep, c) < 0) {
- return EJS_TOK_ERR;
- }
- if ((c = inputGetc(ep)) < 0) {
- break;
- }
- } while (isxdigit(c));
-
- } else {
-#if BLD_FEATURE_FLOATING_POINT
- do {
- if (tokenAddChar(ep, c) < 0) {
- return EJS_TOK_ERR;
- }
- if ((c = inputGetc(ep)) < 0) {
- break;
- }
- c = tolower(c);
- if (c == '.' || c == 'e' || c == 'f') {
- type = EJS_TYPE_FLOAT;
- }
- } while (isdigit(c) || c == '.' || c == 'e' ||
- c == 'f' ||
- ((type == EJS_TYPE_FLOAT) && (c == '+' || c == '-')));
-#else
- do {
- if (tokenAddChar(ep, c) < 0) {
- return EJS_TOK_ERR;
- }
- if ((c = inputGetc(ep)) < 0) {
- break;
- }
- } while (isdigit(c));
-#endif
- }
-
- parseNumber(ep, type);
- inputPutback(ep, c);
- return EJS_TOK_NUMBER;
-
- default:
- /*
- * Identifiers or a function names
- */
- while (1) {
- if (c == '\\') {
- if ((c = inputGetc(ep)) < 0) {
- break;
- }
- if (c == '\n' || c == '\r') {
- break;
- }
- } else if (tokenAddChar(ep, c) < 0) {
- break;
- }
- if ((c = inputGetc(ep)) < 0) {
- break;
- }
- if (!isalnum(c) && c != '$' && c != '_' &&
- c != '\\' && c != '@') {
- break;
- }
- }
- if (*ep->token == '\0') {
- c = inputGetc(ep);
- break;
- }
-
- if (! isalpha((int) *ep->token) && *ep->token != '$' &&
- *ep->token != '_' && *ep->token != '@') {
- ejsError(ep, EJS_SYNTAX_ERROR, "Invalid identifier %s",
- ep->token);
- return EJS_TOK_ERR;
- }
-
- tid = checkReservedWord(ep, state, c, EJS_TOK_ID);
- if (tid != EJS_TOK_ID) {
- return tid;
- }
-
- /*
- * Skip white space after token to find out whether this is
- * a function or not.
- */
- while (c == ' ' || c == '\t' || c == '\r' || c == '\n') {
- if ((c = inputGetc(ep)) < 0)
- break;
- }
-
- tid = EJS_TOK_ID;
- if ((strlen(ep->token) + 1) >= EJS_MAX_ID) {
- ejsError(ep, EJS_SYNTAX_ERROR,
- "Identifier too big. Max is %d letters.", EJS_MAX_ID);
- return EJS_TOK_ERR;
- }
- done++;
- }
- }
-
- /*
- * Putback the last extra character for next time
- */
- inputPutback(ep, c);
- return tid;
-}
-
-/******************************************************************************/
-
-static void parseNumber(Ejs *ep, EjsType type)
-{
- switch (type) {
- case EJS_TYPE_INT:
- ep->tokenNumber.integer = ejsParseInteger(ep->token);
- ep->tokenNumber.type = type;
- break;
-
-#if BLD_FEATURE_FLOATING_POINT
- case EJS_TYPE_FLOAT:
- ep->tokenNumber.floating = atof(ep->token);
- ep->tokenNumber.type = type;
- break;
-#endif
-
-#if BLD_FEATURE_INT64
- case EJS_TYPE_INT64:
- ep->tokenNumber.integer64 = ejsParseInteger64(ep->token);
- ep->tokenNumber.type = type;
- break;
-#endif
- }
-}
-
-/******************************************************************************/
-/*
- * Convert a hex or octal character back to binary, return original char if
- * not a hex digit
- */
-
-static int charConvert(Ejs *ep, int base, int maxDig)
-{
- int i, c, lval, convChar;
-
- lval = 0;
- for (i = 0; i < maxDig; i++) {
- if ((c = inputGetc(ep)) < 0) {
- break;
- }
- /*
- * Initialize to out of range value
- */
- convChar = base;
- if (isdigit(c)) {
- convChar = c - '0';
- } else if (c >= 'a' && c <= 'f') {
- convChar = c - 'a' + 10;
- } else if (c >= 'A' && c <= 'F') {
- convChar = c - 'A' + 10;
- }
- /*
- * If unexpected character then return it to buffer.
- */
- if (convChar >= base) {
- inputPutback(ep, c);
- break;
- }
- lval = (lval * base) + convChar;
- }
- return lval;
-}
-
-/******************************************************************************/
-/*
- * Putback the last token read. Accept at most one push back token.
- */
-
-void ejsLexPutbackToken(Ejs *ep, int tid, char *string)
-{
- EjsInput *ip;
- EjsToken *tp;
- int idx;
-
- mprAssert(ep);
- ip = ep->input;
- mprAssert(ip);
-
- ip->putBackIndex += 1;
-
- mprAssert(ip->putBackIndex < EJS_TOKEN_STACK);
- idx = ip->putBackIndex;
-
- tp = &ip->putBack[idx];
- tp->tid = tid;
-
- mprStrcpy(tp->tokbuf, sizeof(tp->tokbuf), string);
-}
-
-/******************************************************************************/
-/*
- * Add a character to the token buffer
- */
-
-static int tokenAddChar(Ejs *ep, int c)
-{
- EjsInput *ip;
-
- mprAssert(ep);
- ip = ep->input;
- mprAssert(ip);
-
- if (ip->tokEndp >= &ip->tokbuf[sizeof(ip->tokbuf) - 1]) {
- ejsSyntaxError(ep, "Token too big");
- return -1;
- }
- *ip->tokEndp++ = c;
- *ip->tokEndp = '\0';
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Get another input character
- */
-
-static int inputGetc(Ejs *ep)
-{
- EjsInput *ip;
- int c;
-
- mprAssert(ep);
- ip = ep->input;
-
- if (ip->scriptSize <= 0) {
- return -1;
- }
-
- c = (uchar) (*ip->scriptServp++);
- ip->scriptSize--;
-
- /*
- * For debugging, accumulate the line number and the currenly parsed line
- */
- if (c == '\n') {
-#if 0 && BLD_DEBUG
- if (ip->lineColumn > 0) {
- printf("PARSED: %s\n", ip->line);
- }
-#endif
- ip->lineNumber++;
- ip->lineColumn = 0;
- } else if ((ip->lineColumn + 2) < sizeof(ip->line)) {
- ip->line[ip->lineColumn++] = c;
- ip->line[ip->lineColumn] = '\0';
- }
- return c;
-}
-
-/******************************************************************************/
-/*
- * Putback a character onto the input queue
- */
-
-static void inputPutback(Ejs *ep, int c)
-{
- EjsInput *ip;
-
- mprAssert(ep);
-
- if (c > 0) {
- ip = ep->input;
- *--ip->scriptServp = c;
- ip->scriptSize++;
- if (--(ip->lineColumn) < 0) {
- ip->lineColumn = 0;
- }
- mprAssert(ip->line);
- mprAssert(ip->lineColumn >= 0);
- mprAssert(ip->lineColumn < sizeof(ip->line));
- ip->line[ip->lineColumn] = '\0';
- }
-}
-
-/******************************************************************************/
-
-#else
-void ejsLexDummy() {}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_EJS */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejsParser.c b/source4/lib/appweb/ejs-2.0/ejs/ejsParser.c
deleted file mode 100644
index 9fce6d27ee..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/ejsParser.c
+++ /dev/null
@@ -1,4514 +0,0 @@
-/*
- * @file ejsParser.c
- * @brief EJS Parser and Execution
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default.g
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-#if BLD_FEATURE_EJS
-
-/****************************** Forward Declarations **************************/
-
-static int createClass(Ejs *ep, EjsVar *parentClass,
- const char *className, EjsVar *baseClass);
-static int createProperty(Ejs *ep, EjsVar **obj, const char *id,
- int state);
-static int evalCond(Ejs *ep, EjsVar *lhs, int rel, EjsVar *rhs);
-static int evalExpr(Ejs *ep, EjsVar *lhs, int rel, EjsVar *rhs);
-#if BLD_FEATURE_FLOATING_POINT
-static int evalFloatExpr(Ejs *ep, double l, int rel, double r);
-#endif
-static int evalBoolExpr(Ejs *ep, int l, int rel, int r);
-static int evalNumericExpr(Ejs *ep, EjsNum l, int rel, EjsNum r);
-static int evalObjExpr(Ejs *ep, EjsVar *lhs, int rel, EjsVar *rhs) ;
-static int evalStringExpr(Ejs *ep, EjsVar *lhs, int rel, EjsVar *rhs);
-static int evalMethod(Ejs *ep, EjsVar *obj, EjsProc *proc, int flags);
-static EjsProperty *findProperty(Ejs *ep, EjsVar *op, const char *property,
- int flags);
-static EjsVar *pickSpace(Ejs *ep, int state, const char *property, int flags);
-static void freeProc(Ejs *ep, EjsProc *proc);
-static int parseArgs(Ejs *ep, int state, int flags);
-static int parseArrayLiteral(Ejs *ep, int state, int flags, char *id);
-static int parseAssignment(Ejs *ep, int state, int flags, char *id);
-static int parseClass(Ejs *ep, int state, int flags);
-static int parseForInner(Ejs *ep, int state, int flags,
- EjsInput *condScript, EjsInput *incrScript,
- EjsInput *bodyScript, EjsInput *endScript);
-static int parseCond(Ejs *ep, int state, int flags);
-static int parseDeclaration(Ejs *ep, int state, int flags);
-static int parseExpr(Ejs *ep, int state, int flags);
-static int parseFor(Ejs *ep, int state, int flags);
-static int parseRegFor(Ejs *ep, int state, int flags);
-static int parseForIn(Ejs *ep, int state, int flags, int each);
-static int parseId(Ejs *ep, int state, int flags, char **id, int *done);
-static int parseInc(Ejs *ep, int state, int flags);
-static int parseIf(Ejs *ep, int state, int flags, int *done);
-static int parseFunction(Ejs *ep, int state, int flags);
-static int parseMethod(Ejs *ep, int state, int flags, char *id);
-static int parseObjectLiteral(Ejs *ep, int state, int flags, char *id);
-static int parseStmt(Ejs *ep, int state, int flags);
-static int parseThrow(Ejs *ep, int state, int flags);
-static int parseTry(Ejs *ep, int state, int flags);
-static void removeNewlines(Ejs *ep, int state);
-static EjsProperty *searchSpacesForProperty(Ejs *ep, int state, EjsVar *obj,
- char *property, int flags);
-static int assignPropertyValue(Ejs *ep, char *id, int state, EjsVar *value,
- int flags);
-static int updateProperty(Ejs *ep, EjsVar *obj, const char *id, int state,
- EjsVar *value);
-static void updateResult(Ejs *ep, int state, int flags, EjsVar *vp);
-static int getNextNonSpaceToken(Ejs *ep, int state);
-
-static int callConstructor(Ejs *ep, EjsVar *thisObj, EjsVar *baseClass,
- MprArray *args);
-static int callCMethod(Ejs *ep, EjsVar *obj, EjsProc *proc,
- EjsVar *prototype);
-static int callStringCMethod(Ejs *ep, EjsVar *obj, EjsProc *proc,
- EjsVar *prototype);
-static int callMethod(Ejs *ep, EjsVar *obj, EjsProc *proc,
- EjsVar *prototype);
-static int runMethod(Ejs *ep, EjsVar *thisObj, EjsVar *method,
- const char *methodName, MprArray *args);
-
-static EjsInput *getInputStruct(Ejs *ep);
-static void freeInputStruct(Ejs *ep, EjsInput *input);
-
-static void *pushFrame(Ejs *ep, int size);
-static void *popFrame(Ejs *ep, int size);
-
-/************************************* Code ***********************************/
-/*
- * Recursive descent parser for EJS
- */
-
-int ejsParse(Ejs *ep, int state, int flags)
-{
- mprAssert(ep);
-
-#if MOB
- if (mprStackCheck(ep)) {
- char *stack;
- stack = ejsFormatStack(ep);
- mprLog(ep, 0, "\nStack grew : MAX %d\n", mprStackSize(ep));
- mprLog(ep, 0, "Stack\n %s\n", stack);
- mprFree(stack);
- }
-#endif
-
- if (ep->flags & EJS_FLAGS_EXIT) {
- return EJS_STATE_RET;
- }
-
- ep->inputMarker = ep->input->scriptServp;
-
- switch (state) {
- /*
- * Any statement, method arguments or conditional expressions
- */
- case EJS_STATE_STMT:
- state = parseStmt(ep, state, flags);
- if (state != EJS_STATE_STMT_BLOCK_DONE && state != EJS_STATE_STMT_DONE){
- goto err;
- }
- break;
-
- case EJS_STATE_DEC:
- state = parseStmt(ep, state, flags);
- if (state != EJS_STATE_DEC_DONE) {
- goto err;
- }
- break;
-
- case EJS_STATE_EXPR:
- state = parseStmt(ep, state, flags);
- if (state != EJS_STATE_EXPR_DONE) {
- goto err;
- }
- break;
-
- /*
- * Variable declaration list
- */
- case EJS_STATE_DEC_LIST:
- state = parseDeclaration(ep, state, flags);
- if (state != EJS_STATE_DEC_LIST_DONE) {
- goto err;
- }
- break;
-
- /*
- * Method argument string
- */
- case EJS_STATE_ARG_LIST:
- state = parseArgs(ep, state, flags);
- if (state != EJS_STATE_ARG_LIST_DONE) {
- goto err;
- }
- break;
-
- /*
- * Logical condition list (relational operations separated by &&, ||)
- */
- case EJS_STATE_COND:
- state = parseCond(ep, state, flags);
- if (state != EJS_STATE_COND_DONE) {
- goto err;
- }
- break;
-
- /*
- * Expression list
- */
- case EJS_STATE_RELEXP:
- state = parseExpr(ep, state, flags);
- if (state != EJS_STATE_RELEXP_DONE) {
- goto err;
- }
- break;
- }
-
- /*
- * Recursion protection
- */
- if (ep->input->scriptServp == ep->inputMarker) {
- if (ep->recurseCount++ > 20) {
- ejsSyntaxError(ep, "Input syntax error");
- state = EJS_STATE_ERR;
- }
- } else {
- ep->recurseCount = 0;
- }
-
- if (state == EJS_STATE_RET || state == EJS_STATE_EOF) {
- return state;
- }
-
-done:
- return state;
-
-err:
- if (state == EJS_STATE_RET || state == EJS_STATE_EOF) {
- goto done;
- }
- if (state != EJS_STATE_ERR) {
- ejsSyntaxError(ep, 0);
- }
- state = EJS_STATE_ERR;
- goto done;
-}
-
-/******************************************************************************/
-/*
- * Local vars
- */
-
-typedef struct ParseStmt {
- EjsProc *saveProc;
- EjsProperty *pp;
- EjsVar *saveObj, *exception;
- char *str, *id;
- int done, tid, rs, saveObjPerm, expectEndOfStmt;
-} ParseStmt;
-
-/*
- * Parse expression (leftHandSide operator rightHandSide)
- */
-
-
-static int parseStmt(Ejs *ep, int state, int flags)
-{
- ParseStmt *sp;
-
- mprAssert(ep);
-
- if ((sp = pushFrame(ep, sizeof(ParseStmt))) == 0) {
- return EJS_STATE_ERR;
- }
-
- sp->id = 0;
- sp->expectEndOfStmt = 0;
- sp->saveProc = NULL;
-
- ep->currentObj = 0;
- ep->currentProperty = 0;
-
- for (sp->done = 0; !sp->done && state != EJS_STATE_ERR; ) {
- sp->tid = ejsLexGetToken(ep, state);
-
-#if (WIN || BREW_SIMULATOR) && BLD_DEBUG && DISABLED
- /* MOB -- make cross platform */
- _CrtCheckMemory();
-#endif
-
- switch (sp->tid) {
- default:
- ejsLexPutbackToken(ep, sp->tid, ep->token);
- goto done;
-
- case EJS_TOK_EXPR:
- if (state == EJS_STATE_EXPR) {
- ejsLexPutbackToken(ep, EJS_TOK_EXPR, ep->token);
- }
- goto done;
-
- case EJS_TOK_LOGICAL:
- ejsLexPutbackToken(ep, sp->tid, ep->token);
- goto done;
-
- case EJS_TOK_ERR:
- if (state != EJS_STATE_ERR && !ep->gotException) {
- ejsSyntaxError(ep, 0);
- }
- state = EJS_STATE_ERR;
- goto done;
-
- case EJS_TOK_EOF:
- state = EJS_STATE_EOF;
- goto done;
-
- case EJS_TOK_NEWLINE:
- break;
-
- case EJS_TOK_SEMI:
- /*
- * This case is when we discover no statement and just a lone ';'
- */
- if (state != EJS_STATE_STMT) {
- ejsLexPutbackToken(ep, sp->tid, ep->token);
- }
- goto done;
-
- case EJS_TOK_LBRACKET:
- if (flags & EJS_FLAGS_EXE) {
- ep->currentObj = &ep->currentProperty->var;
- if (ep->currentObj != 0 && ep->currentObj->type !=
- EJS_TYPE_OBJECT) {
- ejsError(ep, EJS_REFERENCE_ERROR,
- "Property reference to a non-object type \"%s\"\n",
- sp->id);
- goto err;
- }
- }
-
- sp->saveObj = ep->currentObj;
- sp->saveObjPerm = ejsMakeObjPermanent(sp->saveObj, 1);
-
- sp->rs = ejsParse(ep, EJS_STATE_RELEXP, flags);
-
- ejsMakeObjPermanent(sp->saveObj, sp->saveObjPerm);
- ep->currentObj = sp->saveObj;
-
- if (sp->rs < 0) {
- state = sp->rs;
- goto done;
- }
-
- mprFree(sp->id);
- /* MOB rc */
- sp->str = ejsVarToString(ep, ep->result);
- sp->id = mprStrdup(ep, sp->str);
-
- if (sp->id[0] == '\0') {
- if (flags & EJS_FLAGS_EXE) {
- ejsError(ep, EJS_RANGE_ERROR,
- "[] expression evaluates to the empty string\n");
- goto err;
- }
- } else {
- sp->pp = searchSpacesForProperty(ep, state, ep->currentObj,
- sp->id, flags);
- ep->currentProperty = sp->pp;
- updateResult(ep, state, flags, ejsGetVarPtr(sp->pp));
- }
-
- if ((sp->tid = ejsLexGetToken(ep, state)) != EJS_TOK_RBRACKET) {
- ejsSyntaxError(ep, "Missing ']'");
- goto err;
- }
- break;
-
- case EJS_TOK_PERIOD:
- if (flags & EJS_FLAGS_EXE) {
- if (ep->currentProperty == 0) {
- ejsError(ep, EJS_REFERENCE_ERROR,
- "Undefined object \"%s\"", sp->id);
- goto err;
- }
- }
- ep->currentObj = &ep->currentProperty->var;
- if (flags & EJS_FLAGS_EXE) {
- if (ep->currentObj != 0 && ep->currentObj->type !=
- EJS_TYPE_OBJECT) {
- ejsError(ep, EJS_REFERENCE_ERROR,
- "Property reference to a non-object type \"%s\"\n",
- sp->id);
- goto err;
- }
- }
- if ((sp->tid = ejsLexGetToken(ep, state)) != EJS_TOK_ID) {
- ejsError(ep, EJS_REFERENCE_ERROR, "Bad property after '.': %s",
- ep->token);
- goto err;
- }
- /* Fall through */
-
- case EJS_TOK_ID:
- state = parseId(ep, state, flags, &sp->id, &sp->done);
- if (sp->done && state == EJS_STATE_STMT) {
- sp->expectEndOfStmt = 1;
- }
- break;
-
- case EJS_TOK_ASSIGNMENT:
- sp->tid = ejsLexGetToken(ep, state);
- if (sp->tid == EJS_TOK_LBRACE) {
- /*
- * var = { name: value, name: value, ... }
- */
- if (parseObjectLiteral(ep, state, flags, sp->id) < 0) {
- ejsSyntaxError(ep, "Bad object literal");
- goto err;
- }
-
- } else if (sp->tid == EJS_TOK_LBRACKET) {
- /*
- * var = [ array elements ]
- */
- if (parseArrayLiteral(ep, state, flags, sp->id) < 0) {
- ejsSyntaxError(ep, "Bad array literal");
- goto err;
- }
-
- } else if (sp->tid == EJS_TOK_EXPR &&
- (int) *ep->token == EJS_EXPR_LESS) {
- /*
- * var = <xmlTag> .../</xmlTag>
- */
- ejsSyntaxError(ep, "XML literals are not yet supported");
- goto err;
-
- } else {
- /*
- * var = expression
- */
- ejsLexPutbackToken(ep, sp->tid, ep->token);
- state = parseAssignment(ep, state, flags, sp->id);
- if (state == EJS_STATE_ERR) {
- if (ep->flags & EJS_FLAGS_EXIT) {
- state = EJS_STATE_RET;
- goto done;
- }
- if (!ep->gotException) {
- ejsSyntaxError(ep, 0);
- }
- goto err;
- }
- }
-
- if (flags & EJS_FLAGS_EXE) {
- if (assignPropertyValue(ep, sp->id, state, ep->result,
- flags) < 0) {
- if (ep->gotException == 0) {
- ejsError(ep, EJS_EVAL_ERROR, "Can't set property %s",
- sp->id);
- }
- goto err;
- }
- }
-
- if (state == EJS_STATE_STMT) {
- sp->expectEndOfStmt = 1;
- goto done;
- }
- break;
-
- case EJS_TOK_INC_DEC:
- state = parseInc(ep, state, flags);
- if (state == EJS_STATE_STMT) {
- sp->expectEndOfStmt = 1;
- }
- break;
-
- case EJS_TOK_NEW:
- /* MOB -- could we remove rs and just use state */
- sp->rs = ejsParse(ep, EJS_STATE_EXPR, flags | EJS_FLAGS_NEW);
- if (sp->rs < 0) {
- state = sp->rs;
- goto done;
- }
- break;
-
- case EJS_TOK_DELETE:
- sp->rs = ejsParse(ep, EJS_STATE_EXPR, flags | EJS_FLAGS_DELETE);
- if (sp->rs < 0) {
- state = sp->rs;
- goto done;
- }
- if (flags & EJS_FLAGS_EXE) {
- /* Single place where properties are deleted */
- if (ep->currentObj == 0 || ep->currentProperty == 0) {
- ejsError(ep, EJS_EVAL_ERROR,
- "Can't find property to delete");
- goto err;
- }
- if (ep->currentObj->isArray) {
- ejsSetArrayLength(ep, ep->currentObj, 0,
- ep->currentProperty->name, 0);
- }
- ejsDeleteProperty(ep, ep->currentObj,
- ep->currentProperty->name);
- ep->currentProperty = 0;
- }
- goto done;
-
- case EJS_TOK_FUNCTION:
- /*
- * Parse a function declaration
- */
- state = parseFunction(ep, state, flags);
- goto done;
-
- case EJS_TOK_THROW:
- state = parseThrow(ep, state, flags);
- goto done;
-
- case EJS_TOK_TRY:
- state = parseTry(ep, state, flags);
- goto done;
-
- case EJS_TOK_CLASS:
- case EJS_TOK_MODULE:
- state = parseClass(ep, state, flags);
- goto done;
-
- case EJS_TOK_LITERAL:
- /*
- * Set the result to the string literal
- */
- if (flags & EJS_FLAGS_EXE) {
- ejsWriteVarAsString(ep, ep->result, ep->token);
- ejsSetVarName(ep, ep->result, "");
- }
- if (state == EJS_STATE_STMT) {
- sp->expectEndOfStmt = 1;
- }
- goto done;
-
- case EJS_TOK_NUMBER:
- /*
- * Set the result to the parsed number
- */
- if (flags & EJS_FLAGS_EXE) {
- ejsWriteVar(ep, ep->result, &ep->tokenNumber, 0);
- }
- if (state == EJS_STATE_STMT) {
- sp->expectEndOfStmt = 1;
- }
- goto done;
-
- case EJS_TOK_METHOD_NAME:
- /*
- * parse a method() invocation
- */
- mprAssert(ep->currentObj);
- state = parseMethod(ep, state, flags, sp->id);
- if (state == EJS_STATE_STMT) {
- sp->expectEndOfStmt = 1;
- }
- if (ep->flags & EJS_FLAGS_EXIT) {
- state = EJS_STATE_RET;
- }
- goto done;
-
- case EJS_TOK_IF:
- state = parseIf(ep, state, flags, &sp->done);
- if (state < 0) {
- goto done;
- }
- break;
-
- case EJS_TOK_FOR:
- state = parseFor(ep, state, flags);
- goto done;
-
- case EJS_TOK_VAR:
- if ((sp->rs = ejsParse(ep, EJS_STATE_DEC_LIST, flags)) < 0) {
- state = sp->rs;
- goto done;
- }
- goto done;
-
- case EJS_TOK_COMMA:
- ejsLexPutbackToken(ep, sp->tid, ep->token);
- goto done;
-
- case EJS_TOK_LPAREN:
- if (state == EJS_STATE_EXPR) {
- if ((sp->rs = ejsParse(ep, EJS_STATE_RELEXP, flags)) < 0) {
- state = sp->rs;
- goto done;
- }
- if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) {
- ejsSyntaxError(ep, 0);
- goto err;
- }
- goto done;
-
- } else if (state == EJS_STATE_STMT) {
- ejsLexPutbackToken(ep, EJS_TOK_METHOD_NAME, ep->token);
- }
- break;
-
- case EJS_TOK_RPAREN:
- ejsLexPutbackToken(ep, sp->tid, ep->token);
- goto done;
-
- case EJS_TOK_EXTENDS:
- if (! (flags & EJS_FLAGS_CLASS_DEC)) {
- ejsSyntaxError(ep, 0);
- goto err;
- }
- sp->saveObj = ep->currentObj;
- sp->saveObjPerm = ejsMakeObjPermanent(sp->saveObj, 1);
-
- sp->rs = ejsParse(ep, EJS_STATE_STMT, flags);
- ejsMakeObjPermanent(sp->saveObj, sp->saveObjPerm);
-
- if (sp->rs < 0) {
- state = sp->rs;
- goto done;
- }
-
- if (flags & EJS_FLAGS_EXE) {
- if (createClass(ep, sp->saveObj, sp->id,
- ejsGetVarPtr(ep->currentProperty)) < 0) {
- goto err;
- }
- }
- if (ejsLexGetToken(ep, state) != EJS_TOK_LBRACE) {
- ejsSyntaxError(ep, 0);
- goto err;
- }
- ejsLexPutbackToken(ep, ep->tid, ep->token);
- goto done;
-
- case EJS_TOK_LBRACE:
- if (flags & EJS_FLAGS_CLASS_DEC) {
- if (state == EJS_STATE_DEC) {
- if (flags & EJS_FLAGS_EXE) {
- if (createClass(ep, ep->currentObj, sp->id, 0) < 0) {
- goto err;
- }
- }
- ejsLexPutbackToken(ep, sp->tid, ep->token);
-
- } else if (state == EJS_STATE_STMT) {
- ejsLexPutbackToken(ep, sp->tid, ep->token);
- }
- goto done;
- }
-
- /*
- * This handles any code in braces except "if () {} else {}"
- */
- if (state != EJS_STATE_STMT) {
- ejsSyntaxError(ep, 0);
- goto err;
- }
-
- /*
- * Parse will return EJS_STATE_STMT_BLOCK_DONE when the RBRACE
- * is seen.
- */
- sp->exception = 0;
- do {
- state = ejsParse(ep, EJS_STATE_STMT, flags);
- if (state == EJS_STATE_ERR) {
- /*
- * We need to keep parsing to get to the end of the block
- */
- if (sp->exception == 0) {
- sp->exception = ejsDupVar(ep, ep->result,
- EJS_SHALLOW_COPY);
- if (sp->exception == 0) {
- ejsMemoryError(ep);
- goto err;
- }
- if (sp->exception->type == EJS_TYPE_OBJECT) {
- ejsMakeObjLive(sp->exception, 0);
- mprAssert(sp->exception->objectState->alive == 0);
- }
-
- /*
- * If we're in a try block, we need to keep parsing
- * so we can find the end of the block and the start
- * of the catch block. Otherwise, we are done.
- */
- if (!(flags & EJS_FLAGS_TRY)) {
- break;
- }
- }
- flags &= ~EJS_FLAGS_EXE;
- if (ep->recurseCount > 20) {
- break;
- }
- state = EJS_STATE_STMT_DONE;
- ep->gotException = 0;
- }
-
- } while (state == EJS_STATE_STMT_DONE);
-
- if (sp->exception) {
- ep->gotException = 1;
- ejsWriteVar(ep, ep->result, sp->exception, EJS_SHALLOW_COPY);
-
- /* Eat the closing brace */
- ejsLexGetToken(ep, state);
- ejsFreeVar(ep, sp->exception);
-
- goto err;
- }
- ejsFreeVar(ep, sp->exception);
-
- if (state < 0) {
- goto done;
- }
-
- if (ejsLexGetToken(ep, state) != EJS_TOK_RBRACE) {
- ejsSyntaxError(ep, 0);
- goto err;
- }
- state = EJS_STATE_STMT_DONE;
- goto done;
-
- case EJS_TOK_RBRACE:
- if (state == EJS_STATE_STMT) {
- ejsLexPutbackToken(ep, sp->tid, ep->token);
- state = EJS_STATE_STMT_BLOCK_DONE;
-
- } else if (state == EJS_STATE_EXPR) {
- ejsLexPutbackToken(ep, sp->tid, ep->token);
- state = EJS_STATE_EXPR;
-
- } else {
- ejsSyntaxError(ep, 0);
- state = EJS_STATE_ERR;
- }
- goto done;
-
- case EJS_TOK_RETURN:
- if ((sp->rs = ejsParse(ep, EJS_STATE_RELEXP, flags)) < 0) {
- state = sp->rs;
- goto done;
- }
- if (flags & EJS_FLAGS_EXE) {
- state = EJS_STATE_RET;
- goto done;
- }
- break;
- }
- }
-done:
- mprFree(sp->id);
-
- if (sp->expectEndOfStmt && state >= 0) {
- sp->tid = ejsLexGetToken(ep, state);
- if (sp->tid == EJS_TOK_RBRACE) {
- ejsLexPutbackToken(ep, EJS_TOK_RBRACE, ep->token);
-
- } else if (sp->tid != EJS_TOK_SEMI && sp->tid != EJS_TOK_NEWLINE &&
- sp->tid != EJS_TOK_EOF) {
- ejsSyntaxError(ep, 0);
- state = EJS_STATE_ERR;
-
- } else {
- /*
- * Skip newlines after semi-colon
- */
- removeNewlines(ep, state);
- }
- }
-
- /*
- * Advance the state
- */
- switch (state) {
- case EJS_STATE_STMT:
- case EJS_STATE_STMT_DONE:
- state = EJS_STATE_STMT_DONE;
- break;
-
- case EJS_STATE_DEC:
- case EJS_STATE_DEC_DONE:
- state = EJS_STATE_DEC_DONE;
- break;
-
- case EJS_STATE_EXPR:
- case EJS_STATE_EXPR_DONE:
- state = EJS_STATE_EXPR_DONE;
- break;
-
- case EJS_STATE_STMT_BLOCK_DONE:
- case EJS_STATE_EOF:
- case EJS_STATE_RET:
- break;
-
- default:
- if (state != EJS_STATE_ERR) {
- ejsSyntaxError(ep, 0);
- }
- state = EJS_STATE_ERR;
- }
- popFrame(ep, sizeof(ParseStmt));
- return state;
-
-err:
- state = EJS_STATE_ERR;
- goto done;
-}
-
-/******************************************************************************/
-/*
- * Local vars
- */
-
-typedef struct ParseFor {
- char *initToken;
- int tid, foundVar, initId, each;
-} ParseFor;
-
-/*
- * Parse method arguments
- */
-
-static int parseFor(Ejs *ep, int state, int flags)
-{
- ParseFor *sp;
-
- if ((sp = pushFrame(ep, sizeof(ParseFor))) == 0) {
- return EJS_STATE_ERR;
- }
-
- mprAssert(ep);
-
- if (state != EJS_STATE_STMT) {
- ejsSyntaxError(ep, 0);
- goto err;
- }
-
- if ((sp->tid = ejsLexGetToken(ep, state)) == EJS_TOK_EACH) {
- sp->each = 1;
- sp->tid = ejsLexGetToken(ep, state);
-
- } else {
- sp->each = 0;
- }
-
- if (sp->tid != EJS_TOK_LPAREN) {
- ejsSyntaxError(ep, 0);
- goto err;
- }
-
- /*
- * Need to peek 2-3 tokens ahead and see if this is a
- * for [each] ([var] x in set)
- * or
- * for (init ; whileCond; incr)
- */
- sp->initId = ejsLexGetToken(ep, EJS_STATE_EXPR);
- sp->foundVar = 0;
- if (sp->initId == EJS_TOK_ID && strcmp(ep->token, "var") == 0) {
- sp->foundVar = 1;
- sp->initId = ejsLexGetToken(ep, EJS_STATE_EXPR);
- }
- sp->initToken = mprStrdup(ep, ep->token);
-
- sp->tid = ejsLexGetToken(ep, EJS_STATE_EXPR);
-
- ejsLexPutbackToken(ep, sp->tid, ep->token);
- ejsLexPutbackToken(ep, sp->initId, sp->initToken);
- mprFree(sp->initToken);
-
- if (sp->foundVar) {
- ejsLexPutbackToken(ep, EJS_TOK_ID, "var");
- }
-
- if (sp->tid == EJS_TOK_IN) {
- state = parseForIn(ep, state, flags, sp->each);
-
- } else {
- state = parseRegFor(ep, state, flags);
- }
-
-done:
- popFrame(ep, sizeof(ParseFor));
- return state;
-
-err:
- state = EJS_STATE_ERR;
- goto done;
-}
-
-/******************************************************************************/
-/*
- * Parse method arguments
- */
-
-static int parseArgs(Ejs *ep, int state, int flags)
-{
- EjsVar *vp;
- int tid;
-
- mprAssert(ep);
-
- do {
- /*
- * Peek and see if there are no args
- */
- tid = ejsLexGetToken(ep, state);
- ejsLexPutbackToken(ep, tid, ep->token);
- if (tid == EJS_TOK_RPAREN) {
- break;
- }
-
- /*
- * If this is part of a constructor, must run methods in args normally
- */
- flags &= ~EJS_FLAGS_NEW;
-
- state = ejsParse(ep, EJS_STATE_RELEXP, flags);
- if (state < 0) {
- return state;
- }
- if (flags & EJS_FLAGS_EXE) {
- mprAssert(ep->proc->args);
- vp = ejsDupVar(ep, ep->result, EJS_SHALLOW_COPY);
- if (vp == 0) {
- ejsMemoryError(ep);
- return EJS_STATE_ERR;
- }
- /* MOB */
- if (vp->type == EJS_TYPE_OBJECT) {
- ejsMakeObjLive(vp, 0);
- mprAssert(vp->objectState->alive == 0);
- }
-
- /*
- * Propagate the name
- */
- ejsSetVarName(ep, vp, ep->result->propertyName);
-
- mprAddItem(ep->proc->args, vp);
-
- }
- /*
- * Peek at the next token, continue if more args (ie. comma seen)
- */
- tid = ejsLexGetToken(ep, state);
- if (tid != EJS_TOK_COMMA) {
- ejsLexPutbackToken(ep, tid, ep->token);
- }
- } while (tid == EJS_TOK_COMMA);
-
- if (tid != EJS_TOK_RPAREN && state != EJS_STATE_RELEXP_DONE) {
- ejsSyntaxError(ep, 0);
- return EJS_STATE_ERR;
- }
- return EJS_STATE_ARG_LIST_DONE;
-}
-
-/******************************************************************************/
-/*
- * Local vars
- */
-
-typedef struct ParseAssign {
- EjsProperty *saveProperty;
- EjsVar *saveObj;
- int saveObjPerm, savePropPerm, rc;
-} ParseAssign;
-
-/*
- * Parse an assignment statement
- */
-
-static int parseAssignment(Ejs *ep, int state, int flags, char *id)
-{
- ParseAssign *sp;
-
-
- if (id == 0) {
- if (!ep->gotException) {
- ejsSyntaxError(ep, 0);
- }
- return EJS_STATE_ERR;
- }
-
- if ((sp = pushFrame(ep, sizeof(ParseAssign))) == 0) {
- return EJS_STATE_ERR;
- }
-
- mprAssert(ep->currentObj);
-
- /*
- * Parse the right hand side of the "="
- */
- sp->saveObj = ep->currentObj;
- sp->saveProperty = ep->currentProperty;
-
- sp->saveObjPerm = ejsMakeObjPermanent(sp->saveObj, 1);
- sp->savePropPerm = ejsMakeObjPermanent(ejsGetVarPtr(sp->saveProperty), 1);
-
- sp->rc = ejsParse(ep, EJS_STATE_RELEXP, flags | EJS_FLAGS_ASSIGNMENT);
-
- ejsMakeObjPermanent(sp->saveObj, sp->saveObjPerm);
- ejsMakeObjPermanent(ejsGetVarPtr(sp->saveProperty), sp->savePropPerm);
-
- if (sp->rc < 0) {
- state = EJS_STATE_ERR;
- }
-
- ep->currentObj = sp->saveObj;
- ep->currentProperty = sp->saveProperty;
-
- popFrame(ep, sizeof(ParseAssign));
-
- if (! (flags & EJS_FLAGS_EXE)) {
- return state;
- }
-
- return state;
-}
-
-/******************************************************************************/
-
-static int assignPropertyValue(Ejs *ep, char *id, int state, EjsVar *value,
- int flags)
-{
- EjsProperty *saveProperty;
- EjsVar *saveObj, *obj, *vp;
- char *procName;
- int saveObjPerm, savePropPerm, rc;
-
- mprAssert(flags & EJS_FLAGS_EXE);
-
- if (ep->currentProperty &&
- !ep->currentProperty->var.flags & EJS_GET_ACCESSOR) {
- obj = ep->currentObj;
-
- } else {
- /*
- * Handle any set accessors.
- * FUTURE OPT -- could be faster
- * FUTURE OPT -- coming here even when doing just a set "x = value";
- */
- procName = 0;
- if (mprAllocStrcat(MPR_LOC_ARGS(ep), &procName, EJS_MAX_ID + 5, 0,
- "-set-", id, 0) > 0) {
-
- MprArray *args;
-
- ep->currentProperty = searchSpacesForProperty(ep, state,
- ep->currentObj, procName, flags);
-
- if (ep->currentProperty) {
- args = mprCreateItemArray(ep, EJS_INC_ARGS, EJS_MAX_ARGS);
-
- vp = ejsDupVar(ep, value, EJS_SHALLOW_COPY);
- mprAddItem(args, vp);
- mprAssert(! ejsObjIsCollectable(vp));
-
- saveObj = ep->currentObj;
- saveProperty = ep->currentProperty;
-
- saveObjPerm = ejsMakeObjPermanent(saveObj, 1);
- savePropPerm = ejsMakeObjPermanent(ejsGetVarPtr(saveProperty),
- 1);
-
- /*
- * Invoke the set accessor
- */
- rc = ejsRunMethod(ep, ep->currentObj, procName, args);
- mprFree(procName);
- ejsFreeMethodArgs(ep, args);
-
- ejsMakeObjPermanent(saveObj, saveObjPerm);
- ejsMakeObjPermanent(ejsGetVarPtr(saveProperty), savePropPerm);
-
- ep->currentObj = saveObj;
- ep->currentProperty = saveProperty;
-
- if (rc < 0) {
- return EJS_STATE_ERR;
- }
- return state;
- }
- mprFree(procName);
- }
-
- if (ep->currentProperty == 0) {
- /*
- * MOB -- can we omit this as updateProperty below will create
- */
- if (createProperty(ep, &obj, id, state) < 0) {
- return EJS_STATE_ERR;
- }
- }
- }
-
- if (updateProperty(ep, obj, id, state, value) < 0) {
- return EJS_STATE_ERR;
- }
-
- vp = ejsGetVarPtr(ep->currentProperty);
- if (vp->type == EJS_TYPE_OBJECT) {
- ejsMakeObjLive(vp, 1);
- }
-
- return state;
-}
-
-/******************************************************************************/
-
-static int parseObjectLiteral(Ejs *ep, int state, int flags, char *id)
-{
- EjsProperty *saveProperty;
- EjsVar *saveObj;
- EjsVar *obj;
- char *name;
- int saveObjPerm, savePropPerm, tid;
-
- name = 0;
-
- saveObj = ep->currentObj;
- saveProperty = ep->currentProperty;
-
- saveObjPerm = ejsMakeObjPermanent(saveObj, 1);
- savePropPerm = ejsMakeObjPermanent(ejsGetVarPtr(saveProperty), 1);
-
- if (flags & EJS_FLAGS_EXE) {
- obj = ejsCreateSimpleObj(ep, "Object");
- if (obj == 0) {
- ejsMemoryError(ep);
- goto err;
- }
- mprAssert(! ejsObjIsCollectable(obj));
-
- } else {
- obj = 0;
- }
-
- do {
- tid = getNextNonSpaceToken(ep, state);
- if (tid != EJS_TOK_ID) {
- ejsSyntaxError(ep, 0);
- goto err;
- }
- name = mprStrdup(ep, ep->token);
-
- tid = getNextNonSpaceToken(ep, state);
- if (tid != EJS_TOK_COLON) {
- ejsSyntaxError(ep, 0);
- goto err;
- }
-
- if (flags & EJS_FLAGS_EXE) {
- /* FUTURE OPT -- can we optimize this. We are double accessing id
- with the Put below. Should we be using this or ejsSetProperty
- */
- if (ejsCreatePropertyMethod(ep, obj, name) == 0) {
- ejsMemoryError(ep);
- goto err;
- }
- }
-
- if (ejsParse(ep, EJS_STATE_RELEXP, flags) < 0) {
- goto err;
- }
- if (flags & EJS_FLAGS_EXE) {
- if (ejsSetPropertyMethod(ep, obj, name, ep->result) == 0) {
- ejsMemoryError(ep);
- goto err;
- }
- }
- mprFree(name);
- name = 0;
-
- tid = getNextNonSpaceToken(ep, state);
-
- } while (tid == EJS_TOK_COMMA);
-
- if (tid != EJS_TOK_RBRACE) {
- ejsSyntaxError(ep, 0);
- goto err;
- }
-
- if (flags & EJS_FLAGS_EXE) {
- ejsMakeObjLive(obj, 1);
- ejsWriteVar(ep, ep->result, obj, EJS_SHALLOW_COPY);
- }
-
-done:
- ejsMakeObjPermanent(saveObj, saveObjPerm);
- ejsMakeObjPermanent(ejsGetVarPtr(saveProperty), savePropPerm);
-
- ep->currentObj = saveObj;
- ep->currentProperty = saveProperty;
-
- if (obj) {
- ejsFreeVar(ep, obj);
- }
- return state;
-
-err:
- mprFree(name);
- state = EJS_STATE_ERR;
- goto done;
-}
-
-/******************************************************************************/
-
-static int parseArrayLiteral(Ejs *ep, int state, int flags, char *id)
-{
- EjsProperty *saveProperty;
- EjsVar *saveObj;
- EjsVar *obj;
- int saveObjPerm, savePropPerm, tid;
-
- saveObj = ep->currentObj;
- saveProperty = ep->currentProperty;
-
- saveObjPerm = ejsMakeObjPermanent(saveObj, 1);
- savePropPerm = ejsMakeObjPermanent(ejsGetVarPtr(saveProperty), 1);
-
- if (flags & EJS_FLAGS_EXE) {
- obj = ejsCreateArray(ep, 0);
- if (obj == 0) {
- ejsMemoryError(ep);
- goto err;
- }
- mprAssert(! ejsObjIsCollectable(obj));
-
- } else {
- obj = 0;
- }
-
- do {
- if (ejsParse(ep, EJS_STATE_RELEXP, flags) < 0) {
- goto err;
- }
- if (flags & EJS_FLAGS_EXE) {
- /* MOB _- should this be put[array.length] */
- if (ejsAddArrayElt(ep, obj, ep->result, EJS_SHALLOW_COPY) == 0) {
- goto err;
- }
- }
-
- tid = getNextNonSpaceToken(ep, state);
-
- } while (tid == EJS_TOK_COMMA);
-
- if (tid != EJS_TOK_RBRACKET) {
- ejsSyntaxError(ep, "Missing right bracket");
- goto err;
- }
-
- if (flags & EJS_FLAGS_EXE) {
- ejsMakeObjLive(obj, 1);
- ejsWriteVar(ep, ep->result, obj, EJS_SHALLOW_COPY);
- }
-
-done:
- ejsMakeObjPermanent(saveObj, saveObjPerm);
- ejsMakeObjPermanent(ejsGetVarPtr(saveProperty), savePropPerm);
-
- ep->currentObj = saveObj;
- ep->currentProperty = saveProperty;
-
- ejsFreeVar(ep, obj);
- return state;
-
-err:
- state = EJS_STATE_ERR;
- goto done;
-}
-
-/******************************************************************************/
-/*
- * Create a property.
- */
-
-/*
-MOB -- simplify this. Enforce ep->currentObj to be always set.
-Then we can delete this and just call
-
- ejsCreatePropertyMethod(ep->currentObj, id);
-*/
-//XX
-static int createProperty(Ejs *ep, EjsVar **objp, const char *id, int state)
-{
- EjsVar *obj, *vp;
-
- mprAssert(id && *id);
- mprAssert(objp);
-
- /*
- * Determine the variable scope to use for the property.
- * Standard says: "var x" means declare locally.
- * "x = 2" means declare globally if x is undefined.
- */
- if (ep->currentObj) {
- if (ep->currentObj->type != EJS_TYPE_OBJECT) {
- ejsSyntaxError(ep, "Reference is not an object");
- return EJS_STATE_ERR;
- }
- obj = ep->currentObj;
-
- } else {
- /* MOB -- we should never be doing this here. ep->currentObj should
- always be set already */
- obj = (state == EJS_STATE_DEC) ? ep->local : ep->global;
- }
- mprAssert(obj);
-
- vp = ejsCreatePropertyMethod(ep, obj, id);
- if (vp == 0) {
- if (!ep->gotException) {
- ejsMemoryError(ep);
- }
- return EJS_STATE_ERR;
- }
-
- *objp = obj;
- return state;
-}
-
-/******************************************************************************/
-/*
- * Update a property.
- *
- * Return with ep->currentProperty updated to point to the property.
- */
-
-static int updateProperty(Ejs *ep, EjsVar *obj, const char *id, int state,
- EjsVar *value)
-{
- EjsVar *vp;
-
- /*
- * MOB -- do ready-only check here
- */
- vp = ejsSetPropertyMethod(ep, obj, id, value);
- if (vp == 0) {
- ejsMemoryError(ep);
- return EJS_STATE_ERR;
- }
- ep->currentProperty = ejsGetPropertyPtr(vp);
-
- obj->objectState->dirty = 1;
-
- return state;
-}
-
-/******************************************************************************/
-/*
- * Local vars
- */
-
-typedef struct ParseCond {
- EjsVar lhs, rhs;
- int tid, operator;
-} ParseCond;
-
-/*
- * Parse conditional expression (relational ops separated by ||, &&)
- */
-
-static int parseCond(Ejs *ep, int state, int flags)
-{
- ParseCond *sp;
-
- if ((sp = pushFrame(ep, sizeof(ParseCond))) == 0) {
- return EJS_STATE_ERR;
- }
-
- mprAssert(ep);
-
- if (flags & EJS_FLAGS_EXE) {
- ejsClearVar(ep, ep->result);
- }
-
- sp->lhs.type = sp->rhs.type = EJS_TYPE_UNDEFINED;
- sp->lhs.objectState = sp->rhs.objectState = 0;
- sp->lhs.allocatedData = sp->rhs.allocatedData = 0;
-
- ejsSetVarName(ep, &sp->lhs, "lhs");
- ejsSetVarName(ep, &sp->rhs, "rhs");
-
- sp->operator = 0;
-
- do {
- /*
- * Recurse to handle one side of a conditional. Accumulate the
- * left hand side and the final result in ep->result.
- */
- state = ejsParse(ep, EJS_STATE_RELEXP, flags);
- if (state < 0) {
- break;
- }
-
- if (flags & EJS_FLAGS_EXE) {
- if (sp->operator > 0) {
- /*
- * FUTURE -- does not do precedence
- */
- ejsWriteVar(ep, &sp->rhs, ep->result, EJS_SHALLOW_COPY);
- if (evalCond(ep, &sp->lhs, sp->operator, &sp->rhs) < 0) {
- state = EJS_STATE_ERR;
- break;
- }
- /* Result left in ep->result */
- /* MOB */
- if (sp->lhs.type == EJS_TYPE_OBJECT) {
- mprAssert(sp->lhs.objectState->alive == 0);
- }
- if (sp->rhs.type == EJS_TYPE_OBJECT) {
- mprAssert(sp->rhs.objectState->alive == 0);
- }
- }
- }
-
- sp->tid = ejsLexGetToken(ep, state);
- if (sp->tid == EJS_TOK_LOGICAL) {
- sp->operator = (int) *ep->token;
-
- } else if (sp->tid == EJS_TOK_RPAREN || sp->tid == EJS_TOK_SEMI) {
- ejsLexPutbackToken(ep, sp->tid, ep->token);
- state = EJS_STATE_COND_DONE;
- break;
-
- } else {
- ejsLexPutbackToken(ep, sp->tid, ep->token);
- }
-
- if (flags & EJS_FLAGS_EXE) {
- ejsWriteVar(ep, &sp->lhs, ep->result, EJS_SHALLOW_COPY);
- }
-
- } while (state == EJS_STATE_RELEXP_DONE);
-
- ejsClearVar(ep, &sp->lhs);
- ejsClearVar(ep, &sp->rhs);
-
- popFrame(ep, sizeof(ParseCond));
-
- return state;
-}
-
-/******************************************************************************/
-/*
- * Parse variable declaration list. Declarations can be of the following forms:
- * var x;
- * var x, y, z;
- * var x = 1 + 2 / 3, y = 2 + 4;
- * var x = { property: value, property: value ... };
- * var x = [ property: value, property: value ... ];
- *
- * We set the variable to NULL if there is no associated assignment.
- */
-
-static int parseDeclaration(Ejs *ep, int state, int flags)
-{
- int tid;
-
- mprAssert(ep);
-
- do {
- if ((tid = ejsLexGetToken(ep, state)) != EJS_TOK_ID) {
- ejsSyntaxError(ep, 0);
- return EJS_STATE_ERR;
- }
- ejsLexPutbackToken(ep, tid, ep->token);
-
- /*
- * Parse the entire assignment or simple identifier declaration
- */
- if (ejsParse(ep, EJS_STATE_DEC, flags) != EJS_STATE_DEC_DONE) {
- return EJS_STATE_ERR;
- }
-
- /*
- * Peek at the next token, continue if comma seen
- * Stop on ";" or "in" which is used in a "for (var x in ..."
- */
- tid = ejsLexGetToken(ep, state);
-
- if (tid == EJS_TOK_SEMI) {
- return EJS_STATE_DEC_LIST_DONE;
-
- } else if (tid == EJS_TOK_IN) {
- ejsLexPutbackToken(ep, tid, ep->token);
- return EJS_STATE_DEC_LIST_DONE;
-
- } else if (flags & EJS_FLAGS_CLASS_DEC &&
- (tid == EJS_TOK_LBRACE || tid == EJS_TOK_EXTENDS)) {
- ejsLexPutbackToken(ep, tid, ep->token);
- return EJS_STATE_DEC_LIST_DONE;
-
- } else if (tid == EJS_TOK_RPAREN && flags & EJS_FLAGS_CATCH) {
- ejsLexPutbackToken(ep, tid, ep->token);
- return EJS_STATE_DEC_LIST_DONE;
-
- } else if (tid != EJS_TOK_COMMA) {
- ejsSyntaxError(ep, 0);
- return EJS_STATE_ERR;
- }
-
- } while (tid == EJS_TOK_COMMA);
-
- if (tid != EJS_TOK_SEMI) {
- ejsSyntaxError(ep, 0);
- return EJS_STATE_ERR;
- }
- return EJS_STATE_DEC_LIST_DONE;
-}
-
-/******************************************************************************/
-/*
- * Local vars
- */
-
-typedef struct ParseExpr {
- EjsVar lhs, rhs;
- int rel, tid, unaryMinus;
-} ParseExpr;
-
-/*
- * Parse expression (leftHandSide operator rightHandSide)
- */
-
-static int parseExpr(Ejs *ep, int state, int flags)
-{
- ParseExpr *sp;
-
- mprAssert(ep);
-
- if ((sp = pushFrame(ep, sizeof(ParseExpr))) == 0) {
- return EJS_STATE_ERR;
- }
-
- if (flags & EJS_FLAGS_EXE) {
- ejsClearVar(ep, ep->result);
- }
-
- sp->lhs.type = sp->rhs.type = EJS_TYPE_UNDEFINED;
- sp->lhs.objectState = sp->rhs.objectState = 0;
- sp->lhs.allocatedData = sp->rhs.allocatedData = 0;
-
- ejsSetVarName(ep, &sp->lhs, "lhs");
- ejsSetVarName(ep, &sp->rhs, "rhs");
-
- sp->rel = 0;
- sp->tid = 0;
- sp->unaryMinus = 0;
-
- do {
- /*
- * This loop will handle an entire expression list. We call parse
- * to evalutate each term which returns the result in ep->result.
- */
- if (sp->tid == EJS_TOK_LOGICAL) {
- state = ejsParse(ep, EJS_STATE_RELEXP, flags);
- if (state < 0) {
- break;
- }
- } else {
- sp->tid = ejsLexGetToken(ep, state);
- if (sp->tid == EJS_TOK_EXPR && (int) *ep->token == EJS_EXPR_MINUS) {
- sp->unaryMinus = 1;
-
- } else {
- ejsLexPutbackToken(ep, sp->tid, ep->token);
- }
-
- state = ejsParse(ep, EJS_STATE_EXPR, flags);
- if (state < 0) {
- break;
- }
- }
-
- if (flags & EJS_FLAGS_EXE) {
- if (sp->unaryMinus) {
- switch (ep->result->type) {
- default:
- case EJS_TYPE_UNDEFINED:
- case EJS_TYPE_NULL:
- case EJS_TYPE_STRING_CMETHOD:
- case EJS_TYPE_CMETHOD:
- case EJS_TYPE_METHOD:
- case EJS_TYPE_PTR:
- case EJS_TYPE_OBJECT:
- case EJS_TYPE_STRING:
- case EJS_TYPE_BOOL:
- ejsError(ep, EJS_SYNTAX_ERROR, "Invalid unary minus");
- state = EJS_STATE_ERR;
- break;
-
-#if BLD_FEATURE_FLOATING_POINT
- case EJS_TYPE_FLOAT:
- ep->result->floating = - ep->result->floating;
- break;
-#endif
-
- case EJS_TYPE_INT:
- ep->result->integer = - ep->result->integer;
- break;
-
-#if BLD_FEATURE_INT64
- case EJS_TYPE_INT64:
- ep->result->integer64 = - ep->result->integer64;
- break;
-#endif
- }
- }
- sp->unaryMinus = 0;
-
- if (sp->rel > 0) {
- ejsWriteVar(ep, &sp->rhs, ep->result, EJS_SHALLOW_COPY);
- if (sp->tid == EJS_TOK_LOGICAL) {
- if (evalCond(ep, &sp->lhs, sp->rel, &sp->rhs) < 0) {
- state = EJS_STATE_ERR;
- break;
- }
- } else {
- if (evalExpr(ep, &sp->lhs, sp->rel, &sp->rhs) < 0) {
- state = EJS_STATE_ERR;
- break;
- }
- }
- }
- /* MOB */
- if (sp->lhs.type == EJS_TYPE_OBJECT) {
- ejsMakeObjLive(&sp->lhs, 0);
- mprAssert(sp->lhs.objectState->alive == 0);
- }
- if (sp->rhs.type == EJS_TYPE_OBJECT) {
- ejsMakeObjLive(&sp->rhs, 0);
- mprAssert(sp->rhs.objectState->alive == 0);
- }
- }
-
- if ((sp->tid = ejsLexGetToken(ep, state)) == EJS_TOK_EXPR ||
- sp->tid == EJS_TOK_INC_DEC || sp->tid == EJS_TOK_LOGICAL) {
- sp->rel = (int) *ep->token;
- ejsWriteVar(ep, &sp->lhs, ep->result, EJS_SHALLOW_COPY);
-
- } else {
- ejsLexPutbackToken(ep, sp->tid, ep->token);
- state = EJS_STATE_RELEXP_DONE;
- }
-
- } while (state == EJS_STATE_EXPR_DONE);
-
- ejsClearVar(ep, &sp->lhs);
- ejsClearVar(ep, &sp->rhs);
-
- popFrame(ep, sizeof(ParseExpr));
-
- return state;
-}
-
-/******************************************************************************/
-/*
- * Local vars
- */
-
-typedef struct ParseForIn {
- EjsInput *endScript, *bodyScript;
- EjsProperty *pp, *nextp;
- EjsVar *iteratorVar, *setVar, *vp;
- int forFlags, tid;
-} ParseForIn;
-
-/*
- * Parse the "for ... in" statement. Format for the statement is:
- *
- * for [each] (var varName in expression) {
- * body;
- * }
- */
-
-static int parseForIn(Ejs *ep, int state, int flags, int each)
-{
- ParseForIn *sp;
-
- mprAssert(ep);
-
- if ((sp = pushFrame(ep, sizeof(ParseForIn))) == 0) {
- return EJS_STATE_ERR;
- }
-
- sp->setVar = 0;
- sp->iteratorVar = 0;
- sp->bodyScript = 0;
- sp->endScript = 0;
-
- sp->tid = ejsLexGetToken(ep, state);
- if (sp->tid != EJS_TOK_ID && sp->tid != EJS_TOK_VAR) {
- ejsSyntaxError(ep, 0);
- goto err;
- }
- ejsLexPutbackToken(ep, sp->tid, ep->token);
-
- state = ejsParse(ep, EJS_STATE_EXPR, EJS_FLAGS_FORIN | flags);
- if (state < 0) {
- goto done;
- }
- if (flags & EJS_FLAGS_EXE) {
- if (ep->currentProperty == 0) {
- ejsSyntaxError(ep, 0);
- goto err;
- }
- sp->iteratorVar = &ep->currentProperty->var;
- } else {
- sp->iteratorVar = 0;
- }
-
- if (ejsLexGetToken(ep, state) != EJS_TOK_IN) {
- ejsSyntaxError(ep, 0);
- goto err;
- }
-
- /*
- * Get the set
- */
- sp->tid = ejsLexGetToken(ep, state);
- if (sp->tid != EJS_TOK_ID) {
- ejsSyntaxError(ep, 0);
- goto err;
- }
- ejsLexPutbackToken(ep, sp->tid, ep->token);
-
- state = ejsParse(ep, EJS_STATE_EXPR, flags);
- if (state < 0) {
- goto done;
- }
-
- if ((flags & EJS_FLAGS_EXE) &&
- (ep->result == 0 || ep->result->type == EJS_TYPE_UNDEFINED)) {
- ejsError(ep, EJS_REFERENCE_ERROR, "Can't access array or object");
- goto err;
- }
-
- if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) {
- ejsSyntaxError(ep, 0);
- goto err;
- }
-
- sp->setVar = ejsDupVar(ep, ep->result, EJS_SHALLOW_COPY);
-
- sp->bodyScript = getInputStruct(ep);
-
- /*
- * Parse the body and remember the end of the body script
- */
- sp->forFlags = flags & ~EJS_FLAGS_EXE;
- ejsLexSaveInputState(ep, sp->bodyScript);
-
- state = ejsParse(ep, EJS_STATE_STMT, sp->forFlags);
- if (state < 0) {
- goto done;
- }
-
- sp->endScript = getInputStruct(ep);
- ejsInitInputState(sp->endScript);
- ejsLexSaveInputState(ep, sp->endScript);
-
- /*
- * Enumerate the properties
- */
- if (flags & EJS_FLAGS_EXE) {
- if (sp->setVar->type == EJS_TYPE_OBJECT) {
-
- sp->setVar->objectState->preventDeleteProp = 1;
-
- sp->pp = ejsGetFirstProperty(sp->setVar, 0);
- while (sp->pp) {
- sp->nextp = ejsGetNextProperty(sp->pp, 0);
- if (! sp->pp->dontEnumerate && !sp->pp->delayedDelete) {
- if (each) {
- sp->vp = ejsWriteVar(ep, sp->iteratorVar,
- ejsGetVarPtr(sp->pp), EJS_SHALLOW_COPY);
- } else {
- sp->vp = ejsWriteVarAsString(ep, sp->iteratorVar,
- sp->pp->name);
- }
- if (sp->vp == 0) {
- ejsError(ep, EJS_MEMORY_ERROR,
- "Can't write to variable");
- goto err;
- }
-
- ejsLexRestoreInputState(ep, sp->bodyScript);
-
- state = ejsParse(ep, EJS_STATE_STMT, flags);
-
- if (state < 0) {
- if (sp->setVar->objectState) {
- sp->setVar->objectState->preventDeleteProp = 0;
- }
- goto done;
- }
- }
- sp->pp = sp->nextp;
- }
-
- /*
- * Process delayed deletes
- */
- if (sp->setVar->objectState) {
- sp->setVar->objectState->preventDeleteProp = 0;
- if (sp->setVar->objectState->delayedDeleteProp) {
- sp->pp = ejsGetFirstProperty(sp->setVar, 0);
- while (sp->pp) {
- sp->nextp = ejsGetNextProperty(sp->pp, 0);
- if (sp->pp->delayedDelete) {
- ejsDeleteProperty(ep, sp->setVar, sp->pp->name);
- }
- sp->pp = sp->nextp;
- }
- sp->setVar->objectState->delayedDeleteProp = 0;
- }
- }
-
- } else {
- ejsError(ep, EJS_REFERENCE_ERROR,
- "Variable to iterate over is not an array or object");
- goto err;
- }
- }
-
- ejsLexRestoreInputState(ep, sp->endScript);
-
-done:
- if (sp->endScript) {
- ejsLexFreeInputState(ep, sp->endScript);
- ejsLexFreeInputState(ep, sp->bodyScript);
- }
-
- if (sp->bodyScript) {
- freeInputStruct(ep, sp->bodyScript);
- }
- if (sp->endScript) {
- freeInputStruct(ep, sp->endScript);
- }
-
- if (sp->setVar) {
- ejsFreeVar(ep, sp->setVar);
- }
-
- popFrame(ep, sizeof(ParseForIn));
-
- return state;
-
-err:
- state = EJS_STATE_ERR;
- goto done;
-}
-
-/******************************************************************************/
-/*
- * Parse the for statement. Format for the expression is:
- *
- * for (initial; condition; incr) {
- * body;
- * }
- */
-
-static int parseRegFor(Ejs *ep, int state, int flags)
-{
- EjsInput *condScript, *endScript, *bodyScript, *incrScript;
-
- endScript = getInputStruct(ep);
- bodyScript = getInputStruct(ep);
- incrScript = getInputStruct(ep);
- condScript = getInputStruct(ep);
-
- ejsInitInputState(endScript);
- ejsInitInputState(bodyScript);
- ejsInitInputState(incrScript);
- ejsInitInputState(condScript);
-
- state = parseForInner(ep, state, flags,
- condScript, incrScript, bodyScript, endScript);
-
- ejsLexFreeInputState(ep, condScript);
- ejsLexFreeInputState(ep, incrScript);
- ejsLexFreeInputState(ep, endScript);
- ejsLexFreeInputState(ep, bodyScript);
-
- freeInputStruct(ep, condScript);
- freeInputStruct(ep, incrScript);
- freeInputStruct(ep, endScript);
- freeInputStruct(ep, bodyScript);
-
- return state;
-}
-
-/******************************************************************************/
-
-static int parseForInner(Ejs *ep, int state, int flags, EjsInput *condScript,
- EjsInput *incrScript, EjsInput *bodyScript, EjsInput *endScript)
-{
- int forFlags, cond, rs;
-
- mprAssert(ep);
-
- /*
- * Evaluate the for loop initialization statement
- */
- if ((state = ejsParse(ep, EJS_STATE_STMT, flags)) < 0) {
- return state;
- }
-
- /*
- * The first time through, we save the current input context just prior
- * to each step: prior to the conditional, the loop increment and
- * the loop body.
- */
- ejsLexSaveInputState(ep, condScript);
- if ((rs = ejsParse(ep, EJS_STATE_COND, flags)) < 0) {
- return rs;
- }
-
- cond = (ep->result->boolean != 0);
-
- if (ejsLexGetToken(ep, state) != EJS_TOK_SEMI) {
- ejsSyntaxError(ep, 0);
- return EJS_STATE_ERR;
- }
-
- /*
- * Don't execute the loop increment statement or the body
- * first time.
- */
- forFlags = flags & ~EJS_FLAGS_EXE;
- ejsLexSaveInputState(ep, incrScript);
- if ((rs = ejsParse(ep, EJS_STATE_EXPR, forFlags)) < 0) {
- return rs;
- }
-
- if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) {
- ejsSyntaxError(ep, 0);
- return EJS_STATE_ERR;
- }
-
- /*
- * Parse the body and remember the end of the body script
- */
- ejsLexSaveInputState(ep, bodyScript);
- if ((rs = ejsParse(ep, EJS_STATE_STMT, forFlags)) < 0) {
- return rs;
- }
- ejsLexSaveInputState(ep, endScript);
-
- /*
- * Now actually do the for loop. Note loop has been rotated
- */
- while (cond && (flags & EJS_FLAGS_EXE)) {
- /*
- * Evaluate the body
- */
- ejsLexRestoreInputState(ep, bodyScript);
-
- if ((rs = ejsParse(ep, EJS_STATE_STMT, flags)) < 0) {
- return rs;
- }
-
- /*
- * Evaluate the increment script
- */
- ejsLexRestoreInputState(ep, incrScript);
- if ((rs = ejsParse(ep, EJS_STATE_EXPR, flags)) < 0) {
- return rs;
- }
- /*
- * Evaluate the condition
- */
- ejsLexRestoreInputState(ep, condScript);
- if ((rs = ejsParse(ep, EJS_STATE_COND, flags)) < 0) {
- return 0;
- }
- mprAssert(ep->result->type == EJS_TYPE_BOOL);
- cond = (ep->result->boolean != 0);
- }
-
- ejsLexRestoreInputState(ep, endScript);
-
- return state;
-}
-
-/******************************************************************************/
-/*
- * Create the bare class object
- */
-
-static int createClass(Ejs *ep, EjsVar *obj, const char *className,
- EjsVar *baseClass)
-{
- EjsVar *classObj, *existingClass;
-
- existingClass = ejsGetClass(ep, obj, className);
- if (existingClass) {
- /*
- * We allow partial clases and method redefinition
- * FUTURE -- should prevent this if the class is sealed.
- * DISABLED Error message and return OK.
- */
- /* ejsError(ep, EJS_EVAL_ERROR, "Can't create class %s", className); */
- return 0;
- }
-
- if (baseClass == 0) {
- baseClass = ejsGetClass(ep, ep->service->globalClass, "Object");
- mprAssert(baseClass);
- }
-
- classObj = ejsCreateSimpleClass(ep, baseClass, className);
- if (classObj == 0) {
- ejsMemoryError(ep);
- return -1;
- }
- mprAssert(! ejsObjIsCollectable(classObj));
-
- ep->currentProperty = ejsSetPropertyAndFree(ep, obj, className, classObj);
- mprAssert(ep->currentProperty);
-
- if (ep->currentProperty == 0) {
- return -1;
- }
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Local vars for parseTry
- */
-
-typedef struct ParseTry {
- EjsVar *exception;
- int tid, caught, rs, catchFlags;
-} ParseTry;
-
-/*
- * Parse try block
- *
- * try {}
- */
-
-static int parseTry(Ejs *ep, int state, int flags)
-{
- ParseTry *sp;
-
- if ((sp = pushFrame(ep, sizeof(ParseTry))) == 0) {
- return EJS_STATE_ERR;
- }
-
- mprAssert(ep);
-
- sp->caught = 0;
- sp->exception = 0;
- sp->catchFlags = flags;
-
- /*
- * Execute the code in the try block
- */
- sp->rs = ejsParse(ep, EJS_STATE_STMT, flags | EJS_FLAGS_TRY);
- if (sp->rs < 0) {
- if (sp->rs == EJS_STATE_ERR) {
- sp->exception = ejsDupVar(ep, ep->result, EJS_SHALLOW_COPY);
- if (sp->exception == 0) {
- ejsMemoryError(ep);
- goto err;
- }
- } else {
- state = sp->rs;
- goto done;
- }
-
- } else {
- sp->catchFlags = flags & ~EJS_FLAGS_EXE;
- }
-
- /*
- * On success path or when an exception is caught, we must parse all
- * catch and finally blocks.
- */
- sp->tid = getNextNonSpaceToken(ep, state);
-
- if (sp->tid == EJS_TOK_CATCH) {
-
- ep->gotException = 0;
-
- sp->tid = getNextNonSpaceToken(ep, state);
-
- if (sp->tid == EJS_TOK_LBRACE) {
- /*
- * Unqualified "catch "
- */
- ejsLexPutbackToken(ep, sp->tid, ep->token);
- if (ejsParse(ep, EJS_STATE_STMT, sp->catchFlags) >= 0) {
- sp->caught++;
- }
-
- } else if (sp->tid == EJS_TOK_LPAREN) {
-
- /*
- * Qualified "catch (variable) "
- */
- if ((sp->rs = ejsParse(ep, EJS_STATE_DEC_LIST,
- sp->catchFlags | EJS_FLAGS_CATCH)) < 0) {
- ejsSyntaxError(ep, "Bad catch statement");
- state = sp->rs;
- goto done;
- }
-
- sp->tid = getNextNonSpaceToken(ep, state);
- if (sp->tid != EJS_TOK_RPAREN) {
- ejsSyntaxError(ep, 0);
- goto err;
- }
-
- if (sp->catchFlags & EJS_FLAGS_EXE) {
- if (ep->currentProperty == 0) {
- ejsError(ep, EJS_EVAL_ERROR, "Can't define catch variable");
- goto err;
- }
-
- /*
- * Set the catch variable
- */
- if (ejsWriteVar(ep,
- ejsGetVarPtr(ep->currentProperty), sp->exception,
- EJS_SHALLOW_COPY) == 0) {
- ejsError(ep, EJS_EVAL_ERROR, "Can't update catch variable");
- goto err;
- }
- }
-
- /*
- * Parse the catch block
- */
- if ((sp->rs = ejsParse(ep, EJS_STATE_STMT, sp->catchFlags)) < 0) {
- state = sp->rs;
- goto done;
- }
- sp->caught++;
- ep->gotException = 0;
- }
- sp->tid = getNextNonSpaceToken(ep, state);
- }
-
- /*
- * Parse the finally block
- */
- if (sp->tid == EJS_TOK_FINALLY) {
- if (ejsParse(ep, EJS_STATE_STMT, flags) < 0) {
- goto err;
- }
- } else {
- ejsLexPutbackToken(ep, sp->tid, ep->token);
- }
-
- /*
- * Set the exception value
- */
- if (sp->exception && !sp->caught) {
- ejsWriteVar(ep, ep->result, sp->exception, EJS_SHALLOW_COPY);
- goto err;
- }
-
- state = EJS_STATE_STMT_DONE;
-
-done:
- if (sp->exception) {
- ejsFreeVar(ep, sp->exception);
- }
-
- popFrame(ep, sizeof(ParseTry));
- return state;
-
-
-err:
- state = EJS_STATE_ERR;
- goto done;
-}
-
-/******************************************************************************/
-/*
- * Parse throw statement
- *
- * throw expression
- */
-
-static int parseThrow(Ejs *ep, int state, int flags)
-{
- int rc;
-
- mprAssert(ep);
-
- if ((rc = ejsParse(ep, EJS_STATE_EXPR, flags)) < 0) {
- return rc;
- }
-
-
- if (flags & EJS_FLAGS_EXE) {
- /*
- * We have thrown the exception so set the state to ERR
- */
- ep->gotException = 1;
- return EJS_STATE_ERR;
- }
- return state;
-}
-
-/******************************************************************************/
-/*
- * Parse a class and module declaration
- *
- * class <name> [extends baseClass] {
- * [public | private | ... ] var declarations ...
- * [constructor] function declarations ...
- * }
- *
- * Modules are identical except declared with a "module" instead of
- * "class". Modules cannot be instantiated and are used for mixins.
- *
- */
-
-static int parseClass(Ejs *ep, int state, int flags)
-{
- int originalToken, tid, fid;
-
- mprAssert(ep);
-
- originalToken = ep->tid;
-
- /*
- * Parse "class Name [extends BaseClass]"
- */
- if (ejsParse(ep, EJS_STATE_DEC_LIST, flags | EJS_FLAGS_CLASS_DEC) < 0) {
- return EJS_STATE_ERR;
- }
-
- tid = getNextNonSpaceToken(ep, state);
-
- if (tid != EJS_TOK_LBRACE) {
- return EJS_STATE_ERR;
- }
-
- /*
- * After parsing the class body, ep->local will contain the actual
- * class/module object. So, we save ep->local by creating a new block.
- */
- if (flags & EJS_FLAGS_EXE) {
- fid = ejsSetBlock(ep, ejsGetVarPtr(ep->currentProperty));
- ejsSetVarName(ep, ep->local, ep->currentProperty->name);
-
- } else {
- fid = -1;
- }
-
- /* FUTURE -- should prevent modules from being instantiated */
-
- /*
- * Parse class body
- */
- do {
- state = ejsParse(ep, EJS_STATE_STMT, flags);
- if (state < 0) {
- if (fid >= 0) {
- ejsCloseBlock(ep, fid);
- }
- return state;
- }
- tid = getNextNonSpaceToken(ep, state);
- if (tid == EJS_TOK_RBRACE) {
- break;
- }
- ejsLexPutbackToken(ep, tid, ep->token);
-
- } while (state >= 0);
-
- if (fid >= 0) {
- ejsCloseBlock(ep, fid);
- }
-
- if (tid != EJS_TOK_RBRACE) {
- ejsSyntaxError(ep, 0);
- state = EJS_STATE_ERR;
- }
-
- return state;
-}
-
-/******************************************************************************/
-/*
- * Parse a function declaration
- */
-
-static int parseFunction(Ejs *ep, int state, int flags)
-{
- EjsInput *endScript, *bodyScript;
- EjsProperty *pp;
- EjsVar *func, *funcProp, *currentObj, *vp, *baseClass;
- char *procName;
- int varFlags, len, tid, bodyFlags, innerState;
-
- mprAssert(ep);
-
- func = 0;
- varFlags = 0;
-
- /*
- * method <name>(arg, arg, arg) { body };
- * method name(arg, arg, arg) { body };
- */
-
- tid = ejsLexGetToken(ep, state);
-
- if (tid == EJS_TOK_GET) {
- varFlags |= EJS_GET_ACCESSOR;
- tid = ejsLexGetToken(ep, state);
-
- } else if (tid == EJS_TOK_SET) {
- varFlags |= EJS_SET_ACCESSOR;
- tid = ejsLexGetToken(ep, state);
- }
-
- if (tid == EJS_TOK_ID) {
- if (varFlags & EJS_SET_ACCESSOR) {
-
- if (mprAllocStrcat(MPR_LOC_ARGS(ep), &procName, EJS_MAX_ID + 5,
- 0, "-set-", ep->token, 0) < 0) {
- ejsError(ep, EJS_SYNTAX_ERROR,
- "Name %s is too long", ep->token);
- return EJS_STATE_ERR;
- }
-
- } else {
- procName = mprStrdup(ep, ep->token);
- }
-
- tid = ejsLexGetToken(ep, state);
-
- } else {
- procName = 0;
- }
-
- if (tid != EJS_TOK_LPAREN) {
- mprFree(procName);
- ejsSyntaxError(ep, 0);
- return EJS_STATE_ERR;
- }
-
- /*
- * Hand craft the method value structure.
- */
- if (flags & EJS_FLAGS_EXE) {
- func = ejsCreateMethodVar(ep, 0, 0, 0);
- if (func == 0) {
- mprFree(procName);
- ejsMemoryError(ep);
- return EJS_STATE_ERR;
- }
- func->flags = varFlags;
- }
-
- tid = ejsLexGetToken(ep, state);
- while (tid == EJS_TOK_ID) {
- if (flags & EJS_FLAGS_EXE) {
- mprAddItem(func->method.args,
- mprStrdup(func->method.args, ep->token));
- }
- tid = ejsLexGetToken(ep, state);
- if (tid == EJS_TOK_RPAREN || tid != EJS_TOK_COMMA) {
- break;
- }
- tid = ejsLexGetToken(ep, state);
- }
- if (tid != EJS_TOK_RPAREN) {
- mprFree(procName);
- ejsFreeVar(ep, func);
- ejsSyntaxError(ep, 0);
- return EJS_STATE_ERR;
- }
-
- /* Allow new lines before opening brace */
- do {
- tid = ejsLexGetToken(ep, state);
- } while (tid == EJS_TOK_NEWLINE);
-
- if (tid != EJS_TOK_LBRACE) {
- mprFree(procName);
- ejsFreeVar(ep, func);
- ejsSyntaxError(ep, 0);
- return EJS_STATE_ERR;
- }
-
- /*
- * Register the method name early to allow for recursive
- * method calls (see note in ECMA standard, page 71)
- */
- funcProp = 0;
- if (flags & EJS_FLAGS_EXE && procName) {
- currentObj = pickSpace(ep, 0, procName, flags | EJS_FLAGS_LOCAL);
- pp = ejsSetProperty(ep, currentObj, procName, func);
- if (pp == 0) {
- ejsFreeVar(ep, func);
- ejsMemoryError(ep);
- return EJS_STATE_ERR;
- }
- funcProp = ejsGetVarPtr(pp);
- }
-
-
- bodyScript = getInputStruct(ep);
-
- /*
- * Parse the method body. Turn execute off.
- */
- bodyFlags = flags & ~EJS_FLAGS_EXE;
- ejsLexSaveInputState(ep, bodyScript);
-
- do {
- innerState = ejsParse(ep, EJS_STATE_STMT, bodyFlags);
- } while (innerState == EJS_STATE_STMT_DONE);
-
- tid = ejsLexGetToken(ep, state);
-
- if (innerState != EJS_STATE_STMT_BLOCK_DONE || tid != EJS_TOK_RBRACE) {
- mprFree(procName);
- ejsFreeVar(ep, func);
- ejsLexFreeInputState(ep, bodyScript);
- if (innerState != EJS_STATE_ERR) {
- ejsSyntaxError(ep, 0);
- }
- freeInputStruct(ep, bodyScript);
- return EJS_STATE_ERR;
- }
-
- if (flags & EJS_FLAGS_EXE) {
- endScript = getInputStruct(ep);
- ejsLexSaveInputState(ep, endScript);
-
- /*
- * Save the method body between the starting and ending parse
- * positions. Overwrite the trailing '}' with a null.
- */
- len = endScript->scriptServp - bodyScript->scriptServp;
- func->method.body = mprAlloc(ep, len + 1);
- memcpy(func->method.body, bodyScript->scriptServp, len);
-
- if (len <= 0) {
- func->method.body[0] = '\0';
- } else {
- func->method.body[len - 1] = '\0';
- }
- ejsLexFreeInputState(ep, bodyScript);
- ejsLexFreeInputState(ep, endScript);
- freeInputStruct(ep, endScript);
-
- /*
- * If we are in an assignment, don't register the method name, rather
- * return the method structure in the parser result.
- */
- if (procName) {
- currentObj = pickSpace(ep, 0, procName, flags | EJS_FLAGS_LOCAL);
- pp = ejsSetProperty(ep, currentObj, procName, func);
- if (pp == 0) {
- ejsFreeVar(ep, func);
- ejsMemoryError(ep);
- return EJS_STATE_ERR;
- }
-
- if (currentObj->objectState->className &&
- strcmp(currentObj->objectState->className, procName) == 0) {
- baseClass = currentObj->objectState->baseClass;
- if (baseClass) {
- if (strstr(func->method.body, "super(") != 0) {
- funcProp->callsSuper = 1;
- /*
- * Define super() to point to the baseClass constructor
- */
- vp = ejsGetPropertyAsVar(ep, baseClass,
- baseClass->objectState->className);
- if (vp) {
- mprAssert(vp);
- if (ejsSetProperty(ep, currentObj, "super",
- vp) == 0) {
- ejsFreeVar(ep, func);
- ejsMemoryError(ep);
- return EJS_STATE_ERR;
- }
- }
- }
- }
- }
- }
- /*
- * Always return the function. Try for all stmts to be expressions.
- */
- /* MOB - rc */
- ejsWriteVar(ep, ep->result, func, EJS_SHALLOW_COPY);
- }
- freeInputStruct(ep, bodyScript);
-
- mprFree(procName);
- ejsFreeVar(ep, func);
-
- return state;
-}
-
-/******************************************************************************/
-/*
- * Local vars
- */
-
-typedef struct ParseMethod {
- EjsProc proc, *saveProc;
- EjsVar *saveObj, *newObj;
- int saveObjPerm, rc;
-
-} ParseMethod;
-
-/*
- * Parse a method name and invoke the method. See parseFunction for
- * function declarations.
- */
-
-static int parseMethod(Ejs *ep, int state, int flags, char *id)
-{
- ParseMethod *sp;
-
- if ((sp = pushFrame(ep, sizeof(ParseMethod))) == 0) {
- return EJS_STATE_ERR;
- }
-
- /*
- * Must save any current ep->proc value for the current stack frame
- * to allow for recursive method calls.
- */
- sp->saveProc = (ep->proc) ? ep->proc: 0;
-
- memset(&sp->proc, 0, sizeof(EjsProc));
- sp->proc.procName = mprStrdup(ep, id);
- sp->proc.fn = &ep->currentProperty->var;
- sp->proc.args = mprCreateItemArray(ep, EJS_INC_ARGS, EJS_MAX_ARGS);
- ep->proc = &sp->proc;
-
-#if BLD_DEBUG
- if (strcmp(sp->proc.procName, "printv") == 0) {
- flags |= EJS_FLAGS_TRACE_ARGS;
- }
-#endif
-
- if (flags & EJS_FLAGS_EXE) {
- ejsClearVar(ep, ep->result);
- }
-
- if (! (flags & EJS_FLAGS_NO_ARGS)) {
- sp->saveObj = ep->currentObj;
- sp->saveObjPerm = ejsMakeObjPermanent(sp->saveObj, 1);
- sp->rc = ejsParse(ep, EJS_STATE_ARG_LIST, flags);
- ejsMakeObjPermanent(sp->saveObj, sp->saveObjPerm);
- if (sp->rc < 0) {
- goto err;
- }
- ep->currentObj = sp->saveObj;
- }
-
-#if BLD_DEBUG
- flags &= ~EJS_FLAGS_TRACE_ARGS;
-#endif
-
- /*
- * Evaluate the method if required
- */
- if (flags & EJS_FLAGS_EXE) {
- if (flags & EJS_FLAGS_NEW) {
- sp->newObj = ejsCreateObjUsingArgv(ep, ep->currentObj,
- sp->proc.procName, sp->proc.args);
-
- if (sp->newObj == 0) {
- state = EJS_STATE_ERR;
-
- } else {
- mprAssert(! ejsObjIsCollectable(sp->newObj));
-
- /*
- * Return the newly created object as the result of the
- * command. NOTE: newObj may not be an object!
- */
- /* MOB - rc */
- ejsWriteVar(ep, ep->result, sp->newObj, EJS_SHALLOW_COPY);
- if (ejsVarIsObject(sp->newObj)) {
- ejsMakeObjLive(sp->newObj, 1);
- mprAssert(ejsObjIsCollectable(sp->newObj));
- mprAssert(ejsBlockInUse(sp->newObj));
- }
- ejsFreeVar(ep, sp->newObj);
- }
-
- } else {
-
- if (evalMethod(ep, ep->currentObj, &sp->proc, flags) < 0) {
- /* Methods must call ejsError to set exceptions */
- state = EJS_STATE_ERR;
- }
- }
- }
-
- if (! (flags & EJS_FLAGS_NO_ARGS)) {
- if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) {
- if (state != EJS_STATE_ERR) {
- ejsSyntaxError(ep, 0);
- }
- state = EJS_STATE_ERR;
- }
- }
-
-done:
- freeProc(ep, &sp->proc);
- ep->proc = sp->saveProc;
-
- popFrame(ep, sizeof(ParseMethod));
- return state;
-
-err:
- state = EJS_STATE_ERR;
- goto done;
-}
-
-/******************************************************************************/
-/*
- * Parse an identifier. This is a segment of a fully qualified variable.
- * May come here for an initial identifier or for property names
- * after a "." or "[...]".
- */
-
-static int parseId(Ejs *ep, int state, int flags, char **id, int *done)
-{
- EjsVar *null;
- int tid;
-
- mprFree(*id);
- *id = mprStrdup(ep, ep->token);
-
- if (ep->currentObj == 0) {
- /* First identifier segement */
- ep->currentObj = pickSpace(ep, state, *id, flags);
- }
-
- tid = ejsLexGetToken(ep, state);
- if (tid == EJS_TOK_ASSIGNMENT) {
- flags |= EJS_FLAGS_LHS;
- }
-
- /*
- * Find the referenced variable and store it in currentProperty.
- */
- if (flags & EJS_FLAGS_EXE) {
- ep->currentProperty = searchSpacesForProperty(ep, state,
- ep->currentObj, *id, flags);
-
- /*
- * Handle properties that have been deleted inside an enumeration
- */
- if (ep->currentProperty && ep->currentProperty->delayedDelete) {
- ep->currentProperty = 0;
- }
-
- if (ep->currentProperty &&
- ejsVarIsMethod(&ep->currentProperty->var) &&
- tid != EJS_TOK_LPAREN) {
- if (ep->currentProperty->var.flags & EJS_GET_ACCESSOR) {
- ejsLexPutbackToken(ep, tid, ep->token);
- state = parseMethod(ep, state, flags | EJS_FLAGS_NO_ARGS, *id);
- if (ep->flags & EJS_FLAGS_EXIT) {
- state = EJS_STATE_RET;
- }
- if (state >= 0) {
- ejsSetVarName(ep, ep->result, ep->currentProperty->name);
- }
- return state;
- }
- }
- /*
- * OPT. We should not have to do this always
- */
- updateResult(ep, state, flags, ejsGetVarPtr(ep->currentProperty));
- }
-
- flags &= ~EJS_FLAGS_LHS;
-
- if (tid == EJS_TOK_LPAREN) {
- if (ep->currentProperty == 0 && (flags & EJS_FLAGS_EXE)) {
- ejsError(ep, EJS_REFERENCE_ERROR,
- "Method name not defined \"%s\"", *id);
- return EJS_STATE_ERR;
- }
- ejsLexPutbackToken(ep, EJS_TOK_METHOD_NAME, ep->token);
- return state;
- }
-
- if (tid == EJS_TOK_PERIOD || tid == EJS_TOK_LBRACKET ||
- tid == EJS_TOK_ASSIGNMENT || tid == EJS_TOK_INC_DEC) {
- ejsLexPutbackToken(ep, tid, ep->token);
- return state;
- }
-
- if (flags & EJS_FLAGS_CLASS_DEC) {
- if (tid == EJS_TOK_LBRACE || tid == EJS_TOK_EXTENDS) {
- ejsLexPutbackToken(ep, tid, ep->token);
- return state;
- }
- }
-
- if (flags & EJS_FLAGS_DELETE) {
- if (tid == EJS_TOK_RBRACE) {
- ejsLexPutbackToken(ep, tid, ep->token);
- }
- }
-
- /*
- * Only come here for variable access and declarations.
- * Assignment handled elsewhere.
- */
- if (flags & EJS_FLAGS_EXE) {
- if (state == EJS_STATE_DEC) {
- /*
- * Declare a variable. Standard allows: var x ; var x ;
- */
-#if DISABLED
- if (ep->currentProperty != 0) {
- ejsError(ep, EJS_REFERENCE_ERROR,
- "Variable already defined \"%s\"", *id);
- return EJS_STATE_ERR;
- }
-#endif
- /*
- * Create or overwrite if it already exists
- * Set newly declared variables to the null value.
- */
- null = ejsCreateNullVar(ep);
- ep->currentProperty = ejsSetPropertyAndFree(ep, ep->currentObj,
- *id, null);
- ejsClearVar(ep, ep->result);
-
- } else if (flags & EJS_FLAGS_FORIN) {
- /*
- * This allows "for (x" when x has not yet been defined
- */
- if (ep->currentProperty == 0) {
- /* MOB -- return code */
- ep->currentProperty = ejsCreateProperty(ep,
- ep->currentObj, *id);
- }
-
- } else if (ep->currentProperty == 0) {
-
- if (ep->currentObj && ((ep->currentObj == ep->global ||
- (ep->currentObj == ep->local)))) {
- /*
- * Test against currentObj and not currentObj->objectState
- * as we must allow "i = global.x" and not allow
- * "i = x" where x does not exist.
- */
- ejsError(ep, EJS_REFERENCE_ERROR,
- "Undefined variable \"%s\"", *id);
- return EJS_STATE_ERR;
- }
-
- if (flags & EJS_FLAGS_DELETE) {
- ejsError(ep, EJS_REFERENCE_ERROR,
- "Undefined variable \"%s\"", *id);
- return EJS_STATE_ERR;
- }
- }
- }
- ejsLexPutbackToken(ep, tid, ep->token);
- if (tid == EJS_TOK_RBRACKET || tid == EJS_TOK_COMMA ||
- tid == EJS_TOK_IN) {
- *done = 1;
- }
- return state;
-}
-
-/******************************************************************************/
-/*
- * Local vars
- */
-
-typedef struct ParseIf {
- int ifResult, thenFlags, elseFlags, tid, rs;
-} ParseIf;
-
-/*
- * Parse an "if" statement
- */
-
-static int parseIf(Ejs *ep, int state, int flags, int *done)
-{
- ParseIf *sp;
-
- if ((sp = pushFrame(ep, sizeof(ParseIf))) == 0) {
- return EJS_STATE_ERR;
- }
-
- if (state != EJS_STATE_STMT) {
- goto err;
- }
- if (ejsLexGetToken(ep, state) != EJS_TOK_LPAREN) {
- goto err;
- }
-
- /*
- * Evaluate the entire condition list "(condition)"
- */
- if (ejsParse(ep, EJS_STATE_COND, flags) < 0) {
- goto err;
- }
- if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) {
- goto err;
- }
-
- /*
- * This is the "then" case. We need to always parse both cases and
- * execute only the relevant case.
- */
- sp->ifResult = ejsVarToBoolean(ep->result);
- if (sp->ifResult) {
- sp->thenFlags = flags;
- sp->elseFlags = flags & ~EJS_FLAGS_EXE;
- } else {
- sp->thenFlags = flags & ~EJS_FLAGS_EXE;
- sp->elseFlags = flags;
- }
-
- /*
- * Process the "then" case.
- */
- if ((sp->rs = ejsParse(ep, EJS_STATE_STMT, sp->thenFlags)) < 0) {
- if (! ep->gotException) {
- state = sp->rs;
- goto done;
- }
- }
-
- /*
- * Check to see if there is an "else" case
- */
- removeNewlines(ep, state);
- sp->tid = ejsLexGetToken(ep, state);
- if (sp->tid != EJS_TOK_ELSE) {
- ejsLexPutbackToken(ep, sp->tid, ep->token);
- *done = 1;
- if (ep->gotException) {
- goto err;
- }
- goto done;
- }
-
- /*
- * Process the "else" case.
- */
- state = ejsParse(ep, EJS_STATE_STMT, sp->elseFlags);
-
-done:
- *done = 1;
- if (ep->gotException) {
- state = EJS_STATE_ERR;
- }
- popFrame(ep, sizeof(ParseIf));
- return state;
-
-
-err:
- state = EJS_STATE_ERR;
- goto done;
-}
-
-/******************************************************************************/
-/*
- * Parse a postix "++" or "--" statement
- */
-
-static int parseInc(Ejs *ep, int state, int flags)
-{
- EjsVar *one;
-
- if (! (flags & EJS_FLAGS_EXE)) {
- return state;
- }
-
- if (ep->currentProperty == 0) {
- ejsError(ep, EJS_REFERENCE_ERROR,
- "Undefined variable \"%s\"", ep->token);
- return EJS_STATE_ERR;
- }
- one = ejsCreateIntegerVar(ep, 1);
- if (evalExpr(ep, &ep->currentProperty->var, (int) *ep->token, one) < 0) {
- ejsFreeVar(ep, one);
- return EJS_STATE_ERR;
- }
- if (ejsWriteVar(ep, &ep->currentProperty->var, ep->result,
- EJS_SHALLOW_COPY) < 0) {
- ejsError(ep, EJS_IO_ERROR, "Can't write to variable");
- ejsFreeVar(ep, one);
- return EJS_STATE_ERR;
- }
- ejsFreeVar(ep, one);
- return state;
-}
-
-/******************************************************************************/
-/*
- * Evaluate a condition. Implements &&, ||, !. Returns with a boolean result
- * in ep->result. Returns EJS_STATE_ERR on errors, zero if successful.
- */
-
-static int evalCond(Ejs *ep, EjsVar *lhs, int rel, EjsVar *rhs)
-{
- int l, r, lval;
-
- mprAssert(rel > 0);
-
- l = ejsVarToBoolean(lhs);
- r = ejsVarToBoolean(rhs);
-
- switch (rel) {
- case EJS_COND_AND:
- lval = l && r;
- break;
- case EJS_COND_OR:
- lval = l || r;
- break;
- default:
- ejsError(ep, EJS_SYNTAX_ERROR, "Bad operator %d", rel);
- return -1;
- }
-
- /* MOB - rc */
- ejsWriteVarAsBoolean(ep, ep->result, lval);
- return 0;
-}
-
-
-/******************************************************************************/
-/*
- * return true if this string is a valid number
- */
-
-static int stringIsNumber(const char *s)
-{
- char *endptr = NULL;
-
- if (s == NULL || *s == 0) {
- return 0;
- }
- /* MOB -- not ideal */
-#if BREW
- /* MOB this should check all digits and not just the first. */
- /* Does not support floating point - easy */
-
- if (isdigit(*s) || (*s == '-' && isdigit(s[1]))) {
- return 1;
- }
-#else
- strtod(s, &endptr);
-#endif
- if (endptr != NULL && *endptr == 0) {
- return 1;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Evaluate an operation. Returns with the result in ep->result. Returns -1
- * on errors, otherwise zero is returned.
- */
-
-static int evalExpr(Ejs *ep, EjsVar *lhs, int rel, EjsVar *rhs)
-{
- EjsNum lval;
- char *str;
- int rc;
-
- mprAssert(rel > 0);
- str = 0;
- lval = 0;
-
- /*
- * Type conversion. This is tricky and must be according to the standard.
- * Only numbers (including floats) and strings can be compared. All other
- * types are first converted to numbers by preference and if that fails,
- * to strings.
- *
- * MOB -- should we do "valueOf" here also.
- */
- if (lhs->type == EJS_TYPE_OBJECT &&
- (rhs->type != EJS_TYPE_OBJECT &&
- (rhs->type != EJS_TYPE_UNDEFINED && rhs->type != EJS_TYPE_NULL))) {
- if (ejsVarIsNumber(rhs)) {
- if (ejsRunMethod(ep, lhs, "toValue", 0) == 0) {
- /* MOB - rc */
- ejsWriteVar(ep, lhs, ep->result, EJS_SHALLOW_COPY);
- } else {
- if (ejsRunMethod(ep, lhs, "toString", 0) == 0) {
- /* MOB - rc */
- ejsWriteVar(ep, lhs, ep->result, EJS_SHALLOW_COPY);
- }
- }
-
- } else {
- if (ejsRunMethod(ep, lhs, "toString", 0) == 0) {
- /* MOB - rc */
- ejsWriteVar(ep, lhs, ep->result, EJS_SHALLOW_COPY);
- } else {
- if (ejsRunMethod(ep, lhs, "toValue", 0) == 0) {
- /* MOB - rc */
- ejsWriteVar(ep, lhs, ep->result, EJS_SHALLOW_COPY);
- }
- }
- }
- /* Nothing more can be done */
- }
-
- if (rhs->type == EJS_TYPE_OBJECT &&
- (lhs->type != EJS_TYPE_OBJECT &&
- (lhs->type != EJS_TYPE_UNDEFINED && lhs->type != EJS_TYPE_NULL))) {
- if (ejsVarIsNumber(lhs)) {
- /* If LHS is number, then convert to a value first */
- if (ejsRunMethod(ep, rhs, "toValue", 0) == 0) {
- /* MOB - rc */
- ejsWriteVar(ep, rhs, ep->result, EJS_SHALLOW_COPY);
- } else {
- if (ejsRunMethod(ep, rhs, "toString", 0) == 0) {
- /* MOB - rc */
- ejsWriteVar(ep, rhs, ep->result, EJS_SHALLOW_COPY);
- }
- }
-
- } else {
- /* If LHS is not a number, then convert to a string first */
- if (ejsRunMethod(ep, rhs, "toString", 0) == 0) {
- /* MOB - rc */
- ejsWriteVar(ep, rhs, ep->result, EJS_SHALLOW_COPY);
-
- } else {
- if (ejsRunMethod(ep, rhs, "toValue", 0) == 0) {
- /* MOB - rc */
- ejsWriteVar(ep, rhs, ep->result, EJS_SHALLOW_COPY);
- }
- }
- }
- /* Nothing more can be done */
- }
-
- /*
- * undefined and null are special, in that they don't get promoted when
- * comparing.
- */
- if (rel == EJS_EXPR_EQ || rel == EJS_EXPR_NOTEQ) {
- if (lhs->type == EJS_TYPE_UNDEFINED ||
- rhs->type == EJS_TYPE_UNDEFINED) {
- return evalBoolExpr(ep,
- lhs->type == EJS_TYPE_UNDEFINED,
- rel,
- rhs->type == EJS_TYPE_UNDEFINED);
- }
-
- if (lhs->type == EJS_TYPE_NULL || rhs->type == EJS_TYPE_NULL) {
- return evalBoolExpr(ep,
- lhs->type == EJS_TYPE_NULL,
- rel,
- rhs->type == EJS_TYPE_NULL);
- }
- }
-
- /*
- * From here on, lhs and rhs may contain allocated data (strings), so
- * we must always destroy before overwriting.
- */
-
- /*
- * Only allow a few bool operations. Otherwise convert to number.
- */
- if (lhs->type == EJS_TYPE_BOOL && rhs->type == EJS_TYPE_BOOL &&
- (rel != EJS_EXPR_EQ && rel != EJS_EXPR_NOTEQ &&
- rel != EJS_EXPR_BOOL_COMP)) {
- ejsWriteVarAsNumber(ep, lhs, ejsVarToNumber(lhs));
- }
-
- /*
- * Types do not match, so try to coerce the right operand to match the left
- * But first, try to convert a left operand that is a numeric stored as a
- * string, into a numeric.
- */
- if (lhs->type != rhs->type) {
- if (lhs->type == EJS_TYPE_STRING) {
- if (stringIsNumber(lhs->string)) {
- ejsWriteVarAsNumber(ep, lhs, ejsVarToNumber(lhs));
-
- /* Examine further below */
-
- } else {
- /*
- * Convert the RHS to a string
- * MOB rc
- */
- str = ejsVarToString(ep, rhs);
- ejsWriteVarAsString(ep, rhs, str);
- }
-
-#if BLD_FEATURE_FLOATING_POINT
- } else if (lhs->type == EJS_TYPE_FLOAT) {
- /*
- * Convert rhs to floating
- */
- ejsWriteVarAsFloat(ep, rhs, ejsVarToFloat(rhs));
-
-#endif
-#if BLD_FEATURE_INT64
- } else if (lhs->type == EJS_TYPE_INT64) {
- /*
- * Convert the rhs to 64 bit
- */
- ejsWriteVarAsInteger64(ep, rhs, ejsVarToInteger64(rhs));
-#endif
- } else if (lhs->type == EJS_TYPE_BOOL || lhs->type == EJS_TYPE_INT) {
-
- if (rhs->type == EJS_TYPE_STRING) {
- if (stringIsNumber(rhs->string)) {
- ejsWriteVarAsNumber(ep, rhs, ejsVarToNumber(rhs));
- } else {
- /*
- * Convert to lhs to a string
- */
- str = ejsVarToString(ep, lhs);
- /* MOB -- rc */
- if (str) {
- ejsWriteVarAsString(ep, lhs, str);
- }
- }
-
-#if BLD_FEATURE_FLOATING_POINT
- } else if (rhs->type == EJS_TYPE_FLOAT) {
- /*
- * Convert lhs to floating
- */
- ejsWriteVarAsFloat(ep, lhs, ejsVarToFloat(lhs));
-#endif
-
- } else {
- /*
- * Forcibly convert both operands to numbers
- */
- ejsWriteVarAsNumber(ep, lhs, ejsVarToNumber(lhs));
- ejsWriteVarAsNumber(ep, rhs, ejsVarToNumber(rhs));
- }
- }
- }
-
- /*
- * We have failed to coerce the types to be the same. Special case here
- * for undefined and null. We need to allow comparisions against these
- * special values.
- */
- if (lhs->type == EJS_TYPE_UNDEFINED || lhs->type == EJS_TYPE_NULL) {
- switch (rel) {
- case EJS_EXPR_EQ:
- lval = lhs->type == rhs->type;
- break;
- case EJS_EXPR_NOTEQ:
- lval = lhs->type != rhs->type;
- break;
- case EJS_EXPR_BOOL_COMP:
- lval = ! ejsVarToBoolean(rhs);
- break;
- default:
- ejsWriteVar(ep, ep->result, rhs, EJS_SHALLOW_COPY);
- return 0;
- }
- ejsWriteVarAsBoolean(ep, ep->result, lval);
- return 0;
- }
-
- /*
- * Types are the same here
- */
- switch (lhs->type) {
- default:
- case EJS_TYPE_UNDEFINED:
- case EJS_TYPE_NULL:
- /* Should be handled above */
- mprAssert(0);
- return 0;
-
- case EJS_TYPE_STRING_CMETHOD:
- case EJS_TYPE_CMETHOD:
- case EJS_TYPE_METHOD:
- case EJS_TYPE_PTR:
- ejsWriteVarAsBoolean(ep, ep->result, 0);
- return 0;
-
- case EJS_TYPE_OBJECT:
- rc = evalObjExpr(ep, lhs, rel, rhs);
- break;
-
- case EJS_TYPE_BOOL:
- rc = evalBoolExpr(ep, lhs->boolean, rel, rhs->boolean);
- break;
-
-#if BLD_FEATURE_FLOATING_POINT
- case EJS_TYPE_FLOAT:
- rc = evalFloatExpr(ep, lhs->floating, rel, rhs->floating);
- break;
-#endif
-
- case EJS_TYPE_INT:
- rc = evalNumericExpr(ep, (EjsNum) lhs->integer, rel,
- (EjsNum) rhs->integer);
- break;
-
-#if BLD_FEATURE_INT64
- case EJS_TYPE_INT64:
- rc = evalNumericExpr(ep, (EjsNum) lhs->integer64, rel,
- (EjsNum) rhs->integer64);
- break;
-#endif
-
- case EJS_TYPE_STRING:
- rc = evalStringExpr(ep, lhs, rel, rhs);
- }
-
- /* MOB */
- if (lhs->type == EJS_TYPE_OBJECT) {
- ejsMakeObjLive(lhs, 0);
- mprAssert(lhs->objectState->alive == 0);
- }
- if (rhs->type == EJS_TYPE_OBJECT) {
- ejsMakeObjLive(rhs, 0);
- mprAssert(rhs->objectState->alive == 0);
- }
-
- return rc;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_FLOATING_POINT
-/*
- * Expressions with floating operands
- */
-
-static int evalFloatExpr(Ejs *ep, double l, int rel, double r)
-{
- double lval;
- int logical;
-
- lval = 0;
- logical = 0;
-
- switch (rel) {
- case EJS_EXPR_PLUS:
- lval = l + r;
- break;
- case EJS_EXPR_INC:
- lval = l + 1;
- break;
- case EJS_EXPR_MINUS:
- lval = l - r;
- break;
- case EJS_EXPR_DEC:
- lval = l - 1;
- break;
- case EJS_EXPR_MUL:
- lval = l * r;
- break;
- case EJS_EXPR_DIV:
- lval = l / r;
- break;
- default:
- logical++;
- break;
- }
-
- /*
- * Logical operators
- */
- if (logical) {
-
- switch (rel) {
- case EJS_EXPR_EQ:
- lval = l == r;
- break;
- case EJS_EXPR_NOTEQ:
- lval = l != r;
- break;
- case EJS_EXPR_LESS:
- lval = (l < r) ? 1 : 0;
- break;
- case EJS_EXPR_LESSEQ:
- lval = (l <= r) ? 1 : 0;
- break;
- case EJS_EXPR_GREATER:
- lval = (l > r) ? 1 : 0;
- break;
- case EJS_EXPR_GREATEREQ:
- lval = (l >= r) ? 1 : 0;
- break;
- case EJS_EXPR_BOOL_COMP:
- lval = (r == 0) ? 1 : 0;
- break;
- default:
- ejsError(ep, EJS_SYNTAX_ERROR, "Bad operator %d", rel);
- return -1;
- }
- ejsWriteVarAsBoolean(ep, ep->result, lval != 0);
-
- } else {
- ejsWriteVarAsFloat(ep, ep->result, lval);
- }
- return 0;
-}
-
-#endif /* BLD_FEATURE_FLOATING_POINT */
-/******************************************************************************/
-/*
- * Expressions with object operands
- */
-
-static int evalObjExpr(Ejs *ep, EjsVar *lhs, int rel, EjsVar *rhs)
-{
- int lval;
-
- switch (rel) {
- case EJS_EXPR_EQ:
- lval = lhs->objectState == rhs->objectState;
- break;
- case EJS_EXPR_NOTEQ:
- lval = lhs->objectState != rhs->objectState;
- break;
- default:
- ejsError(ep, EJS_SYNTAX_ERROR, "Bad operator %d", rel);
- return -1;
- }
- ejsWriteVarAsBoolean(ep, ep->result, lval);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Expressions with boolean operands
- */
-
-static int evalBoolExpr(Ejs *ep, int l, int rel, int r)
-{
- int lval;
-
- switch (rel) {
- case EJS_EXPR_EQ:
- lval = l == r;
- break;
- case EJS_EXPR_NOTEQ:
- lval = l != r;
- break;
- case EJS_EXPR_BOOL_COMP:
- lval = (r == 0) ? 1 : 0;
- break;
- default:
- ejsError(ep, EJS_SYNTAX_ERROR, "Bad operator %d", rel);
- return -1;
- }
- ejsWriteVarAsBoolean(ep, ep->result, lval);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Expressions with numeric operands
- */
-
-static int evalNumericExpr(Ejs *ep, EjsNum l, int rel, EjsNum r)
-{
- EjsNum lval;
- int logical;
-
- lval = 0;
- logical = 0;
-
- switch (rel) {
- case EJS_EXPR_PLUS:
- lval = l + r;
- break;
- case EJS_EXPR_INC:
- lval = l + 1;
- break;
- case EJS_EXPR_MINUS:
- lval = l - r;
- break;
- case EJS_EXPR_DEC:
- lval = l - 1;
- break;
- case EJS_EXPR_MUL:
- lval = l * r;
- break;
- case EJS_EXPR_DIV:
- if (r != 0) {
- lval = l / r;
- } else {
- ejsError(ep, EJS_RANGE_ERROR, "Divide by zero");
- return -1;
- }
- break;
- case EJS_EXPR_MOD:
- if (r != 0) {
- lval = l % r;
- } else {
- ejsError(ep, EJS_RANGE_ERROR, "Modulo zero");
- return -1;
- }
- break;
- case EJS_EXPR_LSHIFT:
- lval = l << r;
- break;
- case EJS_EXPR_RSHIFT:
- lval = l >> r;
- break;
-
- default:
- logical++;
- break;
- }
-
- /*
- * Logical operators
- */
- if (logical) {
-
- switch (rel) {
- case EJS_EXPR_EQ:
- lval = l == r;
- break;
- case EJS_EXPR_NOTEQ:
- lval = l != r;
- break;
- case EJS_EXPR_LESS:
- lval = (l < r) ? 1 : 0;
- break;
- case EJS_EXPR_LESSEQ:
- lval = (l <= r) ? 1 : 0;
- break;
- case EJS_EXPR_GREATER:
- lval = (l > r) ? 1 : 0;
- break;
- case EJS_EXPR_GREATEREQ:
- lval = (l >= r) ? 1 : 0;
- break;
- case EJS_EXPR_BOOL_COMP:
- lval = (r == 0) ? 1 : 0;
- break;
- default:
- ejsError(ep, EJS_SYNTAX_ERROR, "Bad operator %d", rel);
- return -1;
- }
- ejsWriteVarAsBoolean(ep, ep->result, lval != 0);
-
- } else {
- ejsWriteVarAsNumber(ep, ep->result, lval);
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Expressions with string operands
- */
-
-static int evalStringExpr(Ejs *ep, EjsVar *lhs, int rel, EjsVar *rhs)
-{
- int lval;
-
- mprAssert(ep);
- mprAssert(lhs);
- mprAssert(rhs);
-
- switch (rel) {
- case EJS_EXPR_LESS:
- lval = strcmp(lhs->string, rhs->string) < 0;
- break;
- case EJS_EXPR_LESSEQ:
- lval = strcmp(lhs->string, rhs->string) <= 0;
- break;
- case EJS_EXPR_GREATER:
- lval = strcmp(lhs->string, rhs->string) > 0;
- break;
- case EJS_EXPR_GREATEREQ:
- lval = strcmp(lhs->string, rhs->string) >= 0;
- break;
- case EJS_EXPR_EQ:
- lval = strcmp(lhs->string, rhs->string) == 0;
- break;
- case EJS_EXPR_NOTEQ:
- lval = strcmp(lhs->string, rhs->string) != 0;
- break;
- case EJS_EXPR_PLUS:
- /*
- * This differs from all the above operations. We append rhs to lhs.
- */
- ejsClearVar(ep, ep->result);
- ejsStrcat(ep, ep->result, lhs);
- ejsStrcat(ep, ep->result, rhs);
- return 0;
-
- case EJS_EXPR_INC:
- case EJS_EXPR_DEC:
- case EJS_EXPR_MINUS:
- case EJS_EXPR_DIV:
- case EJS_EXPR_MOD:
- case EJS_EXPR_LSHIFT:
- case EJS_EXPR_RSHIFT:
- default:
- ejsSyntaxError(ep, "Bad operator");
- return -1;
- }
-
- ejsWriteVarAsBoolean(ep, ep->result, lval);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Evaluate a method. obj is set to the current object if a method is being
- * run.
- */
-
-static int evalMethod(Ejs *ep, EjsVar *obj, EjsProc *proc, int flags)
-{
- EjsProperty *pp;
- EjsVar *saveThis, *prototype;
- int saveThisPerm, rc, fid;
-
- mprAssert(ep);
-
- rc = 0;
- fid = -1;
- saveThis = 0;
- saveThisPerm = 0;
- prototype = proc->fn;
-
- if (prototype == 0) {
- ejsError(ep, EJS_EVAL_ERROR, "Undefined method");
- return EJS_STATE_ERR;
- }
-
- if (prototype->type == EJS_TYPE_OBJECT) {
- prototype = ejsGetPropertyAsVar(ep, prototype, proc->procName);
- }
-
- if (prototype) {
- /*
- * Create a new variable stack frame. ie. new local variables.
- * Some C methods (eg. include) don't create a new local context.
- */
- if (! (prototype->flags & EJS_NO_LOCAL)) {
- fid = ejsOpenBlock(ep);
- if (fid < 0) {
- return EJS_STATE_ERR;
- }
- mprAssert(ejsBlockInUse(ep->local));
-
- pp = ejsSetProperty(ep, ep->local, "this", obj);
- ejsMakePropertyEnumerable(pp, 0);
-
- /*
- * Optimization. Save "this" during this block.
- */
- saveThis = ep->thisObject;
- ep->thisObject = ejsGetVarPtr(pp);
- saveThisPerm = ejsMakeObjPermanent(saveThis, 1);
- }
-
- switch (prototype->type) {
- default:
- mprAssert(0);
- break;
-
- case EJS_TYPE_STRING_CMETHOD:
- rc = callStringCMethod(ep, obj, proc, prototype);
- break;
-
- case EJS_TYPE_CMETHOD:
- rc = callCMethod(ep, obj, proc, prototype);
- break;
-
- case EJS_TYPE_METHOD:
- rc = callMethod(ep, obj, proc, prototype);
- break;
- }
-
- if (fid >= 0) {
- ejsMakeObjPermanent(saveThis, saveThisPerm);
- ep->thisObject = saveThis;
- mprAssert(ejsBlockInUse(ep->local));
- mprAssert(ejsBlockInUse(ep->thisObject));
- ejsCloseBlock(ep, fid);
- }
- }
-
- return rc;
-}
-
-/******************************************************************************/
-/*
- * Create a new object and call all required constructors.
- * obj may be null in which case we look globally for className.
- */
-
-EjsVar *ejsCreateObjUsingArgvInternal(EJS_LOC_DEC(ep, loc), EjsVar *obj,
- const char *className, MprArray *args)
-{
- EjsVar *baseClass, *objectClass, *thisObj;
- int rc;
-
- mprAssert(className && *className);
-
- /*
- * Create a new object of the required class and pass it into the
- * constructor as the "this" local variable.
- */
- baseClass = ejsGetClass(ep, obj, className);
- if (baseClass == 0) {
-
- if (obj && obj->objectState->className &&
- strcmp(obj->objectState->className, className) == 0) {
- /*
- * Handle case where we are calling the constructor inside
- * the class. In this case, obj == baseClass.
- */
- thisObj = ejsCreateSimpleObjUsingClassInt(EJS_LOC_PASS(ep, loc),
- obj);
-
- } else {
-
- /*
- * If the baseClass does not exist, try to create an Object
- * We do this for compatibility with JS 1.5 style new Function.
- * MOB -- but this masks an error if we really need className.
- */
- objectClass = ejsGetClass(ep, 0, "Object");
- thisObj = ejsCreateSimpleObjUsingClassInt(EJS_LOC_PASS(ep, loc),
- objectClass);
- }
-
- } else {
- thisObj = ejsCreateSimpleObjUsingClassInt(EJS_LOC_PASS(ep, loc),
- baseClass);
- }
-
- if (thisObj == 0) {
- ejsMemoryError(ep);
- return 0;
- }
-
- /*
- * Make the object permanent. While currently not alive, the constructor
- * below may make the object alive.
- */
- ejsMakeObjPermanent(thisObj, 1);
- mprAssert(! ejsObjIsCollectable(thisObj));
-
- rc = 0;
- if (baseClass) {
- if (! baseClass->objectState->noConstructor) {
- rc = callConstructor(ep, thisObj, baseClass, args);
- }
- } else {
- /*
- * className is the function name when calling new on functions
- */
- rc = ejsRunMethod(ep, thisObj, className, args);
- }
-
- /*
- * Constructor may change the type to a non-object.
- * Function() does this. Ensure object is not collectable yet.
- */
- if (ejsVarIsObject(thisObj)) {
- ejsMakeObjPermanent(thisObj, 0);
- ejsMakeObjLive(thisObj, 0);
- }
-
- if (rc < 0) {
- if (rc == MPR_ERR_NOT_FOUND) {
- /* No constructor (default) */
- return thisObj;
- }
- if (! (ep->flags & EJS_FLAGS_EXIT)) {
- if (! ep->gotException) {
- ejsMemoryError(ep);
- }
- }
- ejsFreeVar(ep, thisObj);
- return 0;
- }
-
- mprAssert(ejsBlockInUse(thisObj));
-
- return thisObj;
-}
-
-/******************************************************************************/
-/*
- * Local vars
- */
-
-typedef struct CallCons {
- EjsVar *subClassConstructor, *subClass, *method;
-} CallCons;
-
-/*
- * Create a new object and call all required constructors.
- */
-
-static int callConstructor(Ejs *ep, EjsVar *thisObj, EjsVar *baseClass,
- MprArray *args)
-{
- CallCons *sp;
- int state;
-
- if ((sp = pushFrame(ep, sizeof(CallCons))) == 0) {
- return EJS_STATE_ERR;
- }
-
- mprAssert(baseClass);
- mprAssert(baseClass->objectState);
-
- state = 0;
-
- /*
- * method will be null if there is no constructor for this class
- */
- sp->method = ejsGetPropertyAsVar(ep, baseClass,
- baseClass->objectState->className);
-
- if (sp->method == 0 || !ejsVarIsMethod(sp->method) ||
- !sp->method->callsSuper) {
- /*
- * Invoke base class constructors in reverse order (RECURSIVE)
- */
- sp->subClass = baseClass->objectState->baseClass;
- if (sp->subClass) {
-
- /*
- * Note that the Object class does not have a constructor for
- * speed. Construction for the base Object is done via
- * ejsCreateObj above. The code below will invoke constructors
- * in the right order (bottom up) via recursion. MOB -- need to
- * scan for super() MOB -- Bug. Fails poorly if no constructor.
- * Should allows this and invoke a default constructor.
- */
- sp->subClassConstructor = ejsGetPropertyAsVar(ep, sp->subClass,
- sp->subClass->objectState->className);
-
- if (sp->subClassConstructor) {
-
- if (callConstructor(ep, thisObj, sp->subClass, 0) < 0) {
- if (! ep->gotException) {
- ejsMemoryError(ep);
- }
- goto err;
- }
- }
- }
- }
-
- if (sp->method) {
- /*
- * Finally, invoke the constructor for this class itself.
- */
- state = runMethod(ep, thisObj, sp->method,
- baseClass->objectState->className, args);
- }
-
-done:
- popFrame(ep, sizeof(CallCons));
- return state;
-
-err:
- state = EJS_STATE_ERR;
- goto done;
-}
-
-/******************************************************************************/
-/*
- * Create a new object and call all required constructors using string args.
- * MOB -- would be good to parse constructorArgs for "," and break into
- * separate args.
- * Returned object is not yet collectable. Will have alive bit cleared.
- */
-
-EjsVar *ejsCreateObj(Ejs *ep, EjsVar *obj, const char *className,
- const char *constructorArgs)
-{
- MprArray *args;
- EjsVar *newp, *vp;
-
- args = mprCreateItemArray(ep, 0, 0);
- if (args == 0) {
- return 0;
- }
-
- if (constructorArgs && *constructorArgs) {
- vp = ejsCreateStringVarInternal(EJS_LOC_ARGS(ep), constructorArgs);
-
- if (mprAddItem(args, vp) < 0) {
- mprFree(args);
- return 0;
- }
- }
-
- newp = ejsCreateObjUsingArgv(ep, obj, className, args);
-
- ejsFreeMethodArgs(ep, args);
-
- mprAssert(! ejsObjIsCollectable(newp));
- mprAssert(ejsBlockInUse(newp));
-
- return newp;
-}
-
-/******************************************************************************/
-
-static int callStringCMethod(Ejs *ep, EjsVar *obj, EjsProc *proc,
- EjsVar *prototype)
-{
- EjsVar **argValues;
- MprArray *actualArgs;
- char **argBuf, *str;
- int i, rc;
-
- actualArgs = proc->args;
- argValues = (EjsVar**) actualArgs->items;
-
- if (actualArgs->length > 0) {
- argBuf = mprAlloc(ep, actualArgs->length * sizeof(char*));
- for (i = 0; i < actualArgs->length; i++) {
- str = ejsVarToString(ep, argValues[i]);
- /* MOB rc */
- argBuf[i] = mprStrdup(ep, str);
- }
- } else {
- argBuf = 0;
- }
-
- /*
- * Call the method depending on the various handle flags
- */
- ep->userData = prototype->cMethodWithStrings.userData;
- if (prototype->flags & EJS_ALT_HANDLE) {
- /*
- * Used by the AppWeb GaCompat module. The alt handle is set to the
- * web server request struct
- */
- rc = ((EjsAltStringCMethod)
- prototype->cMethodWithStrings.fn)
- (ep, ep->altHandle, obj, actualArgs->length, argBuf);
-
- } else if (prototype->flags & EJS_PRIMARY_HANDLE) {
- /*
- * Used by ESP. The primary handle is set to the esp struct
- */
- rc = (prototype->cMethodWithStrings.fn)(ep->primaryHandle,
- obj, actualArgs->length, argBuf);
-
- } else {
- /*
- * Used EJS for the standard procs
- */
- rc = (prototype->cMethodWithStrings.fn)(ep, obj, actualArgs->length,
- argBuf);
- }
-
- if (actualArgs->length > 0) {
- for (i = 0; i < actualArgs->length; i++) {
- mprFree(argBuf[i]);
- }
- mprFree(argBuf);
- }
- ep->userData = 0;
-
- return rc;
-}
-
-/******************************************************************************/
-
-static int callCMethod(Ejs *ep, EjsVar *obj, EjsProc *proc, EjsVar *prototype)
-{
- EjsVar **argValues;
- MprArray *actualArgs;
- int rc;
-
- actualArgs = proc->args;
- argValues = (EjsVar**) actualArgs->items;
-
- ep->userData = prototype->cMethod.userData;
-
- /*
- * Call the method depending on the various handle flags
- * Sometimes cMethod.fn is NULL if there is no constructor for
- * an object.
- */
- if (prototype->flags & EJS_ALT_HANDLE) {
- /*
- * Use by the GaCompat module. The alt handle is set to the
- * web server request struct
- */
- rc = ((EjsAltCMethod) prototype->cMethod.fn)
- (ep, ep->altHandle, obj, actualArgs->length, argValues);
-
- } else if (prototype->flags & EJS_PRIMARY_HANDLE) {
- /*
- * Used by ESP. The primary handle is set to the esp struct
- */
- rc = (prototype->cMethod.fn)
- (ep->primaryHandle, obj, actualArgs->length, argValues);
-
- } else {
- /*
- * Used EJS for the standard procs
- */
- rc = (prototype->cMethod.fn)(ep, obj, actualArgs->length, argValues);
- }
-
- ep->userData = 0;
-
- return rc;
-}
-
-/******************************************************************************/
-/*
- * Local vars
- */
-
-typedef struct CallMethod {
- MprArray *formalArgs, *actualArgs;
- EjsVar *arguments, *callee, **argValues;
- char **argNames, buf[16];
- int i, argumentsObj;
-} CallMethod;
-
-
-static int callMethod(Ejs *ep, EjsVar *obj, EjsProc *proc, EjsVar *prototype)
-{
- CallMethod *sp;
- int i;
-
- if ((sp = pushFrame(ep, sizeof(CallMethod))) == 0) {
- return EJS_STATE_ERR;
- }
-
- sp->arguments = 0;
- sp->callee = 0;
-
- sp->actualArgs = proc->args;
- sp->argValues = (EjsVar**) sp->actualArgs->items;
- sp->formalArgs = prototype->method.args;
- sp->argNames = (char**) sp->formalArgs->items;
-
- /*
- * Only create arguments and callee if the function actually uses them
- */
- sp->argumentsObj = 0;
- if (strstr(prototype->method.body, "arguments") != 0) {
- sp->argumentsObj++;
-
- /*
- * Create the arguments and callee variables
- * MOB -- should we make real arrays here ? YES
- */
- sp->arguments = ejsCreateSimpleObj(ep, "Object");
- ejsSetVarName(ep, sp->arguments, "arguments");
- mprAssert(! ejsObjIsCollectable(sp->arguments));
-
- sp->callee = ejsCreateSimpleObj(ep, "Object");
- ejsSetVarName(ep, sp->callee, "callee");
- mprAssert(! ejsObjIsCollectable(sp->callee));
-
- /*
- * Overwrite the length property
- */
- ejsSetPropertyToInteger(ep, sp->arguments, "length",
- sp->actualArgs->length);
- ejsSetPropertyToInteger(ep, sp->callee, "length",
- sp->formalArgs->length);
- }
-
- /*
- * Define all the agruments to be set to the actual parameters
- */
- for (i = 0; i < sp->formalArgs->length; i++) {
- if (i >= sp->actualArgs->length) {
- /* MOB -- return code */
- ejsCreateProperty(ep, ep->local, sp->argNames[i]);
-
- } else {
- /* MOB -- return code */
- ejsSetProperty(ep, ep->local, sp->argNames[i], sp->argValues[i]);
- }
- }
-
- if (sp->argumentsObj) {
- for (i = 0; i < sp->actualArgs->length; i++) {
- mprItoa(sp->buf, sizeof(sp->buf), i);
- ejsSetProperty(ep, sp->arguments, sp->buf, sp->argValues[i]);
- }
-
- ejsSetPropertyAndFree(ep, sp->arguments, "callee", sp->callee);
- ejsSetPropertyAndFree(ep, ep->local, "arguments", sp->arguments);
- }
-
- /*
- * Actually run the method
- */
-
- i = ejsEvalScript(ep, prototype->method.body, 0);
-
- popFrame(ep, sizeof(CallMethod));
- return i;
-}
-
-/******************************************************************************/
-/*
- * Run a method. Obj is set to "this" object. MethodName must exist in it
- * or in a sub class.
- */
-
-int ejsRunMethod(Ejs *ep, EjsVar *obj, const char *methodName, MprArray *args)
-{
- EjsProperty *pp;
- EjsProc proc, *saveProc;
- int rc;
-
- mprAssert(obj);
- mprAssert(methodName && *methodName);
-
- pp = ejsGetProperty(ep, obj, methodName);
- if (pp == 0) {
- /* MOB -- this should be all in some common accessor routine */
- pp = ejsGetProperty(ep, ep->local, methodName);
- if (pp == 0) {
- pp = ejsGetProperty(ep, ep->global, methodName);
- if (pp == 0) {
- ejsError(ep, EJS_REFERENCE_ERROR,
- "Undefined method \"%s\"", methodName);
- return MPR_ERR_NOT_FOUND;
- }
- }
- }
-
- saveProc = ep->proc;
- ep->proc = &proc;
-
- memset(&proc, 0, sizeof(EjsProc));
-
- ejsClearVar(ep, ep->result);
-
- /* MOB -- if closures are going to work, we need to have proc be an
- Object and let the GC look after it */
-
- proc.fn = &pp->var;
- if (proc.fn == 0 || proc.fn->type == EJS_TYPE_UNDEFINED) {
- ep->proc = saveProc;
- return MPR_ERR_NOT_FOUND;
- }
-
- proc.procName = mprStrdup(ep, methodName);
- if (args == 0) {
- proc.args = mprCreateItemArray(ep, EJS_INC_ARGS, EJS_MAX_ARGS);
- } else {
- proc.args = args;
- }
-
- rc = evalMethod(ep, obj, &proc, 0);
-
- if (args) {
- proc.args = 0;
- }
- freeProc(ep, &proc);
-
- ep->proc = saveProc;
-
- return rc;
-}
-
-/******************************************************************************/
-/*
- * Run a method. Obj is set to "this" object. MethodName must exist in it
- * or in a sub class.
- */
-
-int ejsRunMethodCmd(Ejs *ep, EjsVar *obj, const char *methodName,
- const char *cmdFmt, ...)
-{
- MprArray *args;
- va_list cmdArgs;
- char *buf, *arg, *cp;
- int rc;
-
- mprAssert(methodName && *methodName);
- mprAssert(cmdFmt && *cmdFmt);
-
- va_start(cmdArgs, cmdFmt);
- mprAllocVsprintf(MPR_LOC_ARGS(ep), &buf, 0, cmdFmt, cmdArgs);
- va_end(cmdArgs);
-
- args = mprCreateItemArray(ep, EJS_INC_ARGS, EJS_MAX_ARGS);
-
- for (arg = cp = buf; cp && *cp; cp++) {
- if (*cp == ',') {
- *cp = 0;
- mprAddItem(args, ejsParseVar(ep, arg, 0));
- arg = cp + 1;
- }
- }
- if (cp > arg) {
- mprAddItem(args, ejsParseVar(ep, arg, 0));
- }
-
- rc = ejsRunMethod(ep, obj, methodName, args);
-
- ejsFreeMethodArgs(ep, args);
- mprFree(buf);
-
- return rc;
-}
-
-/******************************************************************************/
-/*
- * Run a method. Obj is set to "this" object.
- */
-
-static int runMethod(Ejs *ep, EjsVar *thisObj, EjsVar *method,
- const char *methodName, MprArray *args)
-{
- EjsProc proc, *saveProc;
- int rc;
-
- mprAssert(thisObj);
- mprAssert(method);
-
- saveProc = ep->proc;
- ep->proc = &proc;
-
- memset(&proc, 0, sizeof(EjsProc));
-
- ejsClearVar(ep, ep->result);
-
- /* MOB -- if closures are going to work, we need to have proc be an
- Object and let the GC look after it */
-
- proc.fn = method;
- if (proc.fn == 0 || proc.fn->type == EJS_TYPE_UNDEFINED) {
- ep->proc = saveProc;
- return MPR_ERR_NOT_FOUND;
- }
-
- proc.procName = mprStrdup(ep, methodName);
- if (args == 0) {
- proc.args = mprCreateItemArray(ep, EJS_INC_ARGS, EJS_MAX_ARGS);
- } else {
- proc.args = args;
- }
-
- rc = evalMethod(ep, thisObj, &proc, 0);
-
- if (args) {
- proc.args = 0;
- }
- freeProc(ep, &proc);
-
- ep->proc = saveProc;
-
- return rc;
-}
-
-/******************************************************************************/
-/*
- * Find which object contains the property given the current context.
- * We call this when there is no explicit object and the object must be
- * determined by the context.
- */
-
-static EjsVar *pickSpace(Ejs *ep, int state, const char *property, int flags)
-{
- EjsVar *obj;
-
- mprAssert(ep);
- mprAssert(property && *property);
-
- /* MOB - this is ugly and the logic is confused */
-
- if (flags & EJS_FLAGS_GLOBAL) {
- obj = ep->global;
-
- } else if (state == EJS_STATE_DEC || flags & EJS_FLAGS_LOCAL) {
- obj = ep->local;
-
- } else {
- /* First look local, then this and finally global */
-
- if (ejsGetSimpleProperty(ep, ep->local, property)) {
- obj = ep->local;
-
- } else if (ep->thisObject &&
- findProperty(ep, ep->thisObject, property, flags)) {
- obj = ep->thisObject;
-
- } else {
-#if EJS_ECMA_STND
- obj = ep->global;
-#else
- if (flags & EJS_FLAGS_EXE &&
- !findProperty(ep, ep->global, property, flags)) {
- obj = ep->local;
- } else {
- obj = ep->global;
- }
-#endif
- }
- }
- return obj;
-}
-
-/******************************************************************************/
-/*
- * Find an object property given a object and a property name. We
- * intelligently look in the local and global namespaces depending on
- * our state. If not found in local or global, try base classes for method
- * names only. Returns the property or NULL.
- * MOB -- need to rework this API.
- */
-
-static EjsProperty *searchSpacesForProperty(Ejs *ep, int state, EjsVar *obj,
- char *property, int flags)
-{
- EjsProperty *pp;
-
- if (obj) {
- return findProperty(ep, obj, property, flags);
- }
-
- /* MOB -- really should have a search stack */
-
- pp = findProperty(ep, ep->local, property, flags);
- if (pp == 0 && state != EJS_STATE_DEC) {
-
- if (ep->thisObject) {
- pp = findProperty(ep, ep->thisObject, property, flags);
- }
- if (pp == 0) {
- pp = findProperty(ep, ep->global, property, flags);
- }
- }
- return pp;
-}
-
-/******************************************************************************/
-/*
- * Search an object and its base classes to find an object given an object
- * an a property name. If not an assignment (LHS), then follow base classes.
- * Otherwise, just look in the specified object.
- */
-
-static EjsProperty *findProperty(Ejs *ep, EjsVar *op, const char *property,
- int flags)
-{
- /* MOB -- NEW. Remove when EXE fixes are in. */
- if (! (flags & EJS_FLAGS_EXE) && op->type == EJS_TYPE_UNDEFINED) {
- return 0;
- }
-
- if (flags & EJS_FLAGS_LHS) {
- return ejsGetPropertyPtr(ejsGetSimpleProperty(ep, op, property));
-
- } else {
- /*
- * Follow base classes
- */
- return ejsGetPropertyPtr(ejsGetProperty(ep, op, property));
- }
-}
-
-/******************************************************************************/
-/*
- * Update result
- */
-
-static void updateResult(Ejs *ep, int state, int flags, EjsVar *vp)
-{
- if (flags & EJS_FLAGS_EXE && state != EJS_STATE_DEC) {
- ejsClearVar(ep, ep->result);
- if (vp) {
- ejsWriteVar(ep, ep->result, vp, EJS_SHALLOW_COPY);
- ejsSetVarName(ep, ep->result, vp->propertyName);
- }
- }
-}
-
-/******************************************************************************/
-/*
- * Append to the pointer value
- */
-
-int ejsStrcat(Ejs *ep, EjsVar *dest, EjsVar *src)
-{
- char *oldBuf, *buf, *str;
- int oldLen, newLen, len;
-
- mprAssert(dest);
- mprAssert(ejsVarIsString(src));
-
- if (ejsVarIsValid(dest)) {
-
- if (! ejsVarIsString(dest)) {
- /* Bad type for dest */
- return -1;
- }
-
- if (! ejsVarIsString(src)) {
- str = ejsVarToString(ep, src);
- if (str == 0) {
- return -1;
- }
- len = strlen(str);
-
- } else {
- str = src->string;
- len = src->length;
- }
-
- oldBuf = dest->string;
- oldLen = dest->length;
- newLen = oldLen + len + 1;
-
- if (newLen < MPR_SLAB_STR_MAX) {
- buf = oldBuf;
- } else {
- buf = mprRealloc(ep, oldBuf, newLen);
- if (buf == 0) {
- return -1;
- }
- dest->string = buf;
- }
- memcpy(&buf[oldLen], str, len);
- dest->length += len;
-
- } else {
- ejsWriteVarAsString(ep, dest, src->string);
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Exit the script
- */
-
-void ejsExit(Ejs *ep, int status)
-{
- ep->scriptStatus = status;
- ep->flags |= EJS_FLAGS_EXIT;
-}
-
-/******************************************************************************/
-/*
- * Free an argument list
- */
-
-static void freeProc(Ejs *ep, EjsProc *proc)
-{
- if (proc->args) {
- ejsFreeMethodArgs(ep, proc->args);
- }
-
- if (proc->procName) {
- mprFree(proc->procName);
- proc->procName = NULL;
- }
-}
-
-/******************************************************************************/
-
-void ejsFreeMethodArgs(Ejs *ep, MprArray *args)
-{
- int i;
-
- for (i = args->length - 1; i >= 0; i--) {
- ejsFreeVar(ep, args->items[i]);
- mprRemoveItemByIndex(args, i);
- }
- mprFree(args);
-}
-
-/******************************************************************************/
-/*
- * This method removes any new lines. Used for else cases, etc.
- */
-
-static void removeNewlines(Ejs *ep, int state)
-{
- int tid;
-
- do {
- tid = ejsLexGetToken(ep, state);
- } while (tid == EJS_TOK_NEWLINE);
-
- ejsLexPutbackToken(ep, tid, ep->token);
-}
-
-/******************************************************************************/
-
-static int getNextNonSpaceToken(Ejs *ep, int state)
-{
- int tid;
-
- do {
- tid = ejsLexGetToken(ep, state);
- } while (tid == EJS_TOK_NEWLINE);
- return tid;
-}
-
-/******************************************************************************/
-
-int ejsGetFlags(Ejs *ep)
-{
- return ep->flags;
-}
-
-/******************************************************************************/
-
-bool ejsIsExiting(Ejs *ep)
-{
- return (ep->flags & EJS_FLAGS_EXIT) ? 1: 0;
-}
-
-/******************************************************************************/
-
-void ejsClearExiting(Ejs *ep)
-{
- ep->flags &= ~EJS_FLAGS_EXIT;
-}
-
-/******************************************************************************/
-
-static EjsInput *getInputStruct(Ejs *ep)
-{
- EjsInput *input;
-
- if (ep->inputList) {
- input = ep->inputList;
- ep->inputList = input->nextInput;
-
- } else {
- input = mprAlloc(ep, sizeof(EjsInput));
- }
- return input;
-}
-
-/******************************************************************************/
-
-static void freeInputStruct(Ejs *ep, EjsInput *input)
-{
- input->nextInput = ep->inputList;
- ep->inputList = input;
-}
-
-/******************************************************************************/
-
-static void *pushFrame(Ejs *ep, int size)
-{
- /*
- * Grow down stack
- */
- ep->stkPtr -= size;
- if (ep->stkPtr < ep->stack) {
- mprError(ep, MPR_LOC, "Exceeded parse stack");
- return 0;
- }
- return ep->stkPtr;
-}
-
-/******************************************************************************/
-
-static void *popFrame(Ejs *ep, int size)
-{
- ep->stkPtr += size;
- if (ep->stkPtr > &ep->stack[EJS_MAX_STACK]) {
- mprError(ep, MPR_LOC, "Over poped parse stack");
- return 0;
- }
- return ep->stkPtr;
-}
-
-/******************************************************************************/
-#else
-void ejsParserDummy() {}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_EJS */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejsVar.c b/source4/lib/appweb/ejs-2.0/ejs/ejsVar.c
deleted file mode 100644
index 1f8e9266a3..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/ejsVar.c
+++ /dev/null
@@ -1,4033 +0,0 @@
-/**
- * @file ejsVar.c
- * @brief Mbedthis Portable Runtime Universal Variable Type
- */
-
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/******************************* Documentation ********************************/
-
-/*
- * This module is NOT multithreaded.
- *
- * Properties are variables that are stored in an object type variable.
- * Properties can be primitive data types, other objects or methods.
- * Properties are indexed by a character name.
- */
-
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-/***************************** Forward Declarations ***************************/
-
-static EjsProperty *allocProperty(Ejs *ep, EjsVar *op, const char *property,
- int propertyIndex, EjsProperty *last);
-static EjsVar *copyVar(EJS_LOC_DEC(ep, loc), EjsVar *dest,
- const EjsVar *src, EjsCopyDepth copyDepth);
-static EjsObj *createObj(EJS_LOC_DEC(ep, loc));
-static char *getNextVarToken(char **next, char *tokBuf, int tokBufLen);
-static int hash(const char *property);
-static void unlinkProperty(EjsObj *obj, EjsPropLink *propLink);
-static void linkPropertyBefore(EjsObj *obj, EjsPropLink *at,
- EjsPropLink *propLink);
-static int sortAllProperties(Ejs *ep, EjsProperty *p1,
- EjsProperty *p2, const char *propertyName, int order);
-static int sortByProperty(Ejs *ep, EjsProperty *p1, EjsProperty *p2,
- const char *propertyName, int order);
-static int dupString(MPR_LOC_DEC(ctx, loc), uchar **dest,
- const void *src, int nbytes);
-#if UNUSED && KEEP
-static void linkPropertyAfter(EjsObj *obj, EjsPropLink *at,
- EjsPropLink *propLink);
-#endif
-
-static EjsProperty *hashLookup(EjsObj *obj, const char *property,
- int *propertyIndex, EjsProperty **hashTail);
-
-/******************************************************************************/
-/********************************** Var Routines ******************************/
-/******************************************************************************/
-
-EjsType ejsGetVarType(EjsVar *vp)
-{
- mprAssert(vp);
-
- return vp->type;
-}
-
-/******************************************************************************/
-
-void ejsFreeVar(Ejs *ep, EjsVar *vp)
-{
- if (vp) {
- ejsClearVar(ep, vp);
- ejsFree(ep, vp, EJS_SLAB_VAR);
- }
-}
-
-/******************************************************************************/
-#if UNUSED
-/*
- * Clear the value by freeing any allocated data. This will release objects
- * so that later garbage collection can reclaim storage if there are no other
- * object references.
- */
-
-void ejsZeroVar(Ejs *ep, EjsVar *vp)
-{
- vp->type = EJS_TYPE_UNDEFINED;
- vp->objectState = 0;
- vp->method.body = 0;
- vp->method.args = 0;
- vp->callsSuper = 0;
- vp->ptr.destructor = 0;
- vp->allocatedData = 0;
-}
-
-#endif
-/******************************************************************************/
-/*
- * Clear the value by freeing any allocated data. This will release objects
- * so that later garbage collection can reclaim storage if there are no other
- * object references.
- */
-
-void ejsClearVar(Ejs *ep, EjsVar *vp)
-{
- MprArray *argList;
- int i;
-
- mprAssert(vp);
- mprAssert(ep);
-
- if (! vp->allocatedData) {
- vp->type = EJS_TYPE_UNDEFINED;
- return;
- }
- if (vp->type == EJS_TYPE_UNDEFINED) {
- return;
- }
-
- switch (vp->type) {
- default:
- break;
-
- case EJS_TYPE_STRING:
- mprFree(vp->string);
- vp->string = 0;
- break;
-
- case EJS_TYPE_OBJECT:
- /*
- * Set the "alive" bit so that the GC will cleanup if no
- * other references.
- */
- if (vp->objectState) {
- vp->objectState->alive = 1;
- }
- vp->objectState = 0;
- break;
-
- case EJS_TYPE_METHOD:
- argList = vp->method.args;
- /*
- * MOB OPT -- should be able to do just one mprFree(vp->method.args)
- */
- mprFree(vp->method.body);
- if (argList) {
- for (i = 0; i < argList->length; i++) {
- mprFree(argList->items[i]);
- }
- mprFree(vp->method.args);
- }
- vp->method.args = 0;
- vp->method.body = 0;
- vp->callsSuper = 0;
- break;
-
- case EJS_TYPE_PTR:
- if (vp->ptr.destructor) {
- (vp->ptr.destructor)(ep, vp);
- }
- break;
- }
-
- vp->type = EJS_TYPE_UNDEFINED;
- vp->allocatedData = 0;
-}
-
-/******************************************************************************/
-/*
- * Initialize an undefined value.
- */
-
-EjsVar *ejsCreateUndefinedVar(Ejs *ep)
-{
- EjsVar *vp;
-
- mprAssert(ep);
-
- vp = ejsAllocVar(EJS_LOC_ARGS(ep));
- if (vp) {
- vp->type = EJS_TYPE_UNDEFINED;
- }
- return vp;
-}
-
-/******************************************************************************/
-/*
- * Initialize an null value.
- */
-
-EjsVar *ejsCreateNullVar(Ejs *ep)
-{
- EjsVar *vp;
-
- mprAssert(ep);
-
- vp = ejsAllocVar(EJS_LOC_ARGS(ep));
- if (vp) {
- vp->type = EJS_TYPE_NULL;
- }
- return vp;
-}
-
-/******************************************************************************/
-
-EjsVar *ejsCreateBoolVar(Ejs *ep, int value)
-{
- EjsVar *vp;
-
- mprAssert(ep);
-
- vp = ejsAllocVar(EJS_LOC_ARGS(ep));
- if (vp) {
- vp->type = EJS_TYPE_BOOL;
- vp->boolean = value;
- }
- return vp;
-}
-
-/******************************************************************************/
-/*
- * Initialize a C method.
- */
-
-EjsVar *ejsCreateCMethodVar(Ejs *ep, EjsCMethod fn, void *userData, int flags)
-{
- EjsVar *vp;
-
- mprAssert(ep);
-
- vp = ejsAllocVar(EJS_LOC_ARGS(ep));
- if (vp) {
- vp->type = EJS_TYPE_CMETHOD;
- vp->cMethod.fn = fn;
- vp->cMethod.userData = userData;
- vp->flags = flags;
- }
- return vp;
-}
-
-/******************************************************************************/
-/*
- * Initialize a C method.
- */
-
-EjsVar *ejsCreateStringCMethodVar(Ejs *ep, EjsStringCMethod fn,
- void *userData, int flags)
-{
- EjsVar *vp;
-
- mprAssert(ep);
- mprAssert(fn);
-
- vp = ejsAllocVar(EJS_LOC_ARGS(ep));
- if (vp) {
- vp->type = EJS_TYPE_STRING_CMETHOD;
- vp->cMethodWithStrings.fn = fn;
- vp->cMethodWithStrings.userData = userData;
- vp->flags = flags;
- }
- return vp;
-}
-
-/******************************************************************************/
-/*
- * Initialize an opaque pointer.
- */
-
-EjsVar *ejsCreatePtrVar(Ejs *ep, void *ptr, EjsDestructor destructor)
-{
- EjsVar *vp;
-
- mprAssert(ep);
- mprAssert(ptr);
-
- vp = ejsAllocVar(EJS_LOC_ARGS(ep));
- if (vp) {
- vp->type = EJS_TYPE_PTR;
- vp->ptr.userPtr = ptr;
- vp->ptr.destructor = destructor;
- vp->allocatedData = 1;
- }
- return vp;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_FLOATING_POINT
-/*
- * Initialize a floating value.
- */
-
-EjsVar *ejsCreateFloatVar(Ejs *ep, double value)
-{
- EjsVar *vp;
-
- mprAssert(ep);
-
- vp = ejsAllocVar(EJS_LOC_ARGS(ep));
- if (vp) {
- vp->type = EJS_TYPE_FLOAT;
- vp->floating = value;
- }
- return vp;
-}
-
-#endif
-/******************************************************************************/
-/*
- * Initialize an integer value.
- */
-
-EjsVar *ejsCreateIntegerVar(Ejs *ep, int value)
-{
- EjsVar *vp;
-
- mprAssert(ep);
-
- vp = ejsAllocVar(EJS_LOC_ARGS(ep));
- if (vp) {
- vp->type = EJS_TYPE_INT;
- vp->integer = value;
- }
- return vp;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_INT64
-/*
- * Initialize a 64-bit integer value.
- */
-
-EjsVar *ejsCreateInteger64Var(Ejs *ep, int64 value)
-{
- EjsVar *vp;
-
- mprAssert(ep);
-
- vp = ejsAllocVar(EJS_LOC_ARGS(ep));
- if (vp) {
- vp->type = EJS_TYPE_INT64;
- vp->integer64 = value;
- }
- return vp;
-}
-
-#endif /* BLD_FEATURE_INT64 */
-/******************************************************************************/
-/*
- * Initialize an number variable. Type is defined by configure.
- */
-
-EjsVar *ejsCreateNumberVar(Ejs *ep, EjsNum value)
-{
- EjsVar *vp;
-
- mprAssert(ep);
-
- vp = ejsAllocVar(EJS_LOC_ARGS(ep));
- mprAssert(vp);
-
- if (vp) {
- vp->type = BLD_FEATURE_NUM_TYPE_ID;
-#if BLD_FEATURE_NUM_TYPE_ID == EJS_TYPE_INT64
- vp->integer64 = value;
-#elif BLD_FEATURE_NUM_TYPE_ID == EJS_TYPE_FLOAT
- vp->float = value;
-#else
- vp->integer = value;
-#endif
- }
- return vp;
-}
-
-/******************************************************************************/
-/*
- * Initialize a (bare) JavaScript method. args and body can be null.
- */
-
-EjsVar *ejsCreateMethodVar(Ejs *ep, const char *body, MprArray *args, int flags)
-{
- EjsVar *vp;
- int i;
-
- mprAssert(ep);
-
- vp = ejsAllocVar(EJS_LOC_ARGS(ep));
- mprAssert(vp);
-
- if (vp == 0) {
- return 0;
- }
-
- vp->type = EJS_TYPE_METHOD;
-
- vp->allocatedData = 1;
-
- vp->method.args = mprCreateItemArray(ep, EJS_INC_ARGS, EJS_MAX_ARGS);
- if (vp->method.args == 0) {
- mprAssert(vp->method.args);
- ejsFreeVar(ep, vp);
- return 0;
- }
-
- if (args) {
- for (i = 0; i < args->length; i++) {
- mprAddItem(vp->method.args,
- mprStrdup(vp->method.args, mprGetItem(args, i)));
- }
- }
- vp->method.body = mprStrdup(vp->method.args, body);
-
- if (vp->method.body == 0) {
- ejsFreeVar(ep, vp);
- return 0;
- }
- vp->flags = flags;
-
- return vp;
-}
-
-/******************************************************************************/
-/*
- * Initialize an object variable.
- */
-
-EjsVar *ejsCreateObjVarInternal(EJS_LOC_DEC(ep, loc))
-{
- EjsVar *vp;
-
- mprAssert(ep);
-
- vp = ejsAllocVar(EJS_LOC_PASS(ep, loc));
- mprAssert(vp);
-
- if (vp) {
- vp->type = EJS_TYPE_OBJECT;
- vp->objectState = createObj(EJS_LOC_PASS(ep, loc));
- if (vp->objectState == 0) {
- ejsFreeVar(ep, vp);
- return 0;
- }
- vp->allocatedData = 1;
- }
- return vp;
-}
-
-/******************************************************************************/
-/*
- * Initialize a string value.
- */
-
-EjsVar *ejsCreateStringVarInternal(EJS_LOC_DEC(ep, loc), const char *value)
-{
- EjsVar *vp;
-
- mprAssert(ep);
-
- vp = ejsAllocVar(EJS_LOC_PASS(ep, loc));
- mprAssert(vp);
-
- if (vp) {
- vp->type = EJS_TYPE_STRING;
- vp->string = mprStrdupInternal(EJS_LOC_PASS(ep, loc), value);
- if (vp->string == 0) {
- ejsFreeVar(ep, vp);
- return 0;
- }
- vp->length = strlen(vp->string);
- vp->allocatedData = 1;
- }
- return vp;
-}
-
-/******************************************************************************/
-/*
- * Initialize a binary string value.
- */
-
-EjsVar *ejsCreateBinaryStringVar(Ejs *ep, const uchar *value, int len)
-{
- EjsVar *vp;
-
- mprAssert(ep);
-
- vp = ejsAllocVar(EJS_LOC_ARGS(ep));
- if (vp) {
- vp->type = EJS_TYPE_STRING;
- vp->length = dupString(MPR_LOC_ARGS(ep), &vp->ustring, value, len);
- if (vp->length < 0) {
- ejsFreeVar(ep, vp);
- return 0;
- }
- vp->allocatedData = 1;
- }
- return vp;
-}
-
-/******************************************************************************/
-
-void ejsSetClassName(Ejs *ep, EjsVar *vp, const char *name)
-{
- EjsObj *obj;
-
- if (vp == 0 || !ejsVarIsObject(vp) || vp->objectState == 0) {
- mprAssert(0);
- return;
- }
- obj = vp->objectState;
-
- if (obj->className) {
- mprFree(obj->className);
- }
- obj->className = mprStrdup(ep, name);
-}
-
-/******************************************************************************/
-
-EjsVar *ejsDupVarInternal(EJS_LOC_DEC(ep, loc), EjsVar *src,
- EjsCopyDepth copyDepth)
-{
- EjsVar *vp;
-
- vp = ejsAllocVar(EJS_LOC_PASS(ep, loc));
- if (vp == 0) {
- return 0;
- }
-
- vp->type = EJS_TYPE_UNDEFINED;
-
- return copyVar(EJS_LOC_PASS(ep, loc), vp, src, copyDepth);
-}
-
-/******************************************************************************/
-/*
- * Set a var to a new value
- */
-
-EjsVar *ejsWriteVarInternal(EJS_LOC_DEC(ep, loc), EjsVar *dest,
- const EjsVar *src, EjsCopyDepth copyDepth)
-{
- mprAssert(dest);
- mprAssert(src);
-
- return copyVar(EJS_LOC_PASS(ep, loc), dest, src, copyDepth);
-}
-
-/******************************************************************************/
-/*
- * Set a var using a new bool value
- */
-
-EjsVar *ejsWriteVarAsBoolean(Ejs *ep, EjsVar *dest, int value)
-{
- mprAssert(dest);
-
- if (dest->type != EJS_TYPE_UNDEFINED) {
- ejsClearVar(ep, dest);
- }
-
- dest->type = EJS_TYPE_BOOL;
- dest->boolean = value;
- dest->allocatedData = 0;
- dest->flags = 0;
-
- return dest;
-}
-
-/******************************************************************************/
-/*
- * Set a var using a new C Method
- */
-
-EjsVar *ejsWriteVarAsCMethod(Ejs *ep, EjsVar *dest, EjsCMethod fn,
- void *userData, int flags)
-{
- mprAssert(dest);
-
- if (dest->type != EJS_TYPE_UNDEFINED) {
- ejsClearVar(ep, dest);
- }
-
- dest->type = EJS_TYPE_CMETHOD;
- dest->cMethod.fn = fn;
- dest->cMethod.userData = userData;
- dest->flags = flags;
- dest->allocatedData = 0;
-
- return dest;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_FLOATING_POINT
-/*
- * Set a var using a new float value
- */
-
-EjsVar *ejsWriteVarAsFloat(Ejs *ep, EjsVar *dest, double value)
-{
- mprAssert(dest);
-
- if (dest->type != EJS_TYPE_UNDEFINED) {
- ejsClearVar(ep, dest);
- }
-
- dest->type = EJS_TYPE_FLOAT;
- dest->floating = value;
- dest->allocatedData = 0;
- dest->flags = 0;
-
- return dest;
-}
-
-#endif
-/******************************************************************************/
-/*
- * Set a var using a new integer value
- */
-
-EjsVar *ejsWriteVarAsInteger(Ejs *ep, EjsVar *dest, int value)
-{
- mprAssert(dest);
-
- if (dest->type != EJS_TYPE_UNDEFINED) {
- ejsClearVar(ep, dest);
- }
-
- dest->type = EJS_TYPE_INT;
- dest->integer = value;
- dest->allocatedData = 0;
- dest->flags = 0;
-
- return dest;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_INT64
-/*
- * Set a var using a new integer value
- */
-
-EjsVar *ejsWriteVarAsInteger64(Ejs *ep, EjsVar *dest, int64 value)
-{
- mprAssert(dest);
-
- if (dest->type != EJS_TYPE_UNDEFINED) {
- ejsClearVar(ep, dest);
- }
-
- dest->type = EJS_TYPE_INT64;
- dest->integer64 = value;
- dest->allocatedData = 0;
- dest->flags = 0;
-
- return dest;
-}
-
-#endif
-/******************************************************************************/
-/*
- * Set a var using a new Method
- */
-
-EjsVar *ejsWriteVarAsMethod(Ejs *ep, EjsVar *dest, const char *body,
- MprArray *args)
-{
- EjsVar **srcArgs, *arg;
- int i;
-
- mprAssert(ep);
- mprAssert(dest);
- mprAssert(body);
-
- if (dest->type != EJS_TYPE_UNDEFINED) {
- ejsClearVar(ep, dest);
- }
-
- dest->method.args = mprCreateItemArray(ep, EJS_INC_ARGS, EJS_MAX_ARGS);
- if (dest->method.args == 0) {
- return 0;
- }
-
- dest->type = EJS_TYPE_METHOD;
-
- if (args) {
- srcArgs = (EjsVar**) args->items;
- for (i = 0; i < args->length; i++) {
- arg = ejsDupVar(ep, srcArgs[i], EJS_SHALLOW_COPY);
- if (arg == 0) {
- return 0;
- }
- if (mprAddItem(dest->method.args, arg) < 0) {
- return 0;
- }
- }
- }
-
- dest->method.body = mprStrdup(dest->method.args, body);
- if (dest->method.body == 0) {
- return 0;
- }
-
- dest->allocatedData = 1;
- dest->flags = 0;
-
- return dest;
-}
-
-/******************************************************************************/
-/*
- * Set a var to null
- */
-
-EjsVar *ejsWriteVarAsNull(Ejs *ep, EjsVar *dest)
-{
- mprAssert(dest);
-
- if (dest->type != EJS_TYPE_UNDEFINED) {
- ejsClearVar(ep, dest);
- }
-
- dest->type = EJS_TYPE_NULL;
- dest->allocatedData = 0;
- dest->flags = 0;
-
- return dest;
-}
-
-/******************************************************************************/
-/*
- * Set a var using a new number value
- */
-
-EjsVar *ejsWriteVarAsNumber(Ejs *ep, EjsVar *dest, EjsNum value)
-{
- mprAssert(dest);
-
- if (dest->type != EJS_TYPE_UNDEFINED) {
- ejsClearVar(ep, dest);
- }
-
- dest->type = EJS_NUM_VAR;
- dest->ejsNumber = value;
- dest->allocatedData = 0;
- dest->flags = 0;
-
- return dest;
-}
-
-/******************************************************************************/
-/*
- * Set a var using a new C Method
- */
-
-EjsVar *ejsWriteVarAsStringCMethod(Ejs *ep, EjsVar *dest, EjsStringCMethod fn,
- void *userData, int flags)
-{
- mprAssert(dest);
-
- if (dest->type != EJS_TYPE_UNDEFINED) {
- ejsClearVar(ep, dest);
- }
-
- dest->type = EJS_TYPE_CMETHOD;
- dest->cMethodWithStrings.fn = fn;
- dest->cMethodWithStrings.userData = userData;
- dest->flags = flags;
- dest->allocatedData = 0;
-
- return dest;
-}
-
-/******************************************************************************/
-/*
- * Set a var using a new string value
- */
-
-EjsVar *ejsWriteVarAsStringInternal(EJS_LOC_DEC(ep, loc), EjsVar *dest,
- const char *value)
-{
- mprAssert(dest);
- mprAssert(value);
-
- if (dest->type != EJS_TYPE_UNDEFINED) {
- ejsClearVar(ep, dest);
- }
-
- dest->string = mprStrdupInternal(EJS_LOC_PASS(ep, loc), value);
- if (dest->string == 0) {
- return 0;
- }
-
- dest->length = strlen(dest->string);
-
- dest->type = EJS_TYPE_STRING;
- dest->allocatedData = 1;
- dest->flags = 0;
-
- return dest;
-}
-
-/******************************************************************************/
-/*
- * Set a var using a new string value
- */
-
-EjsVar *ejsWriteVarAsBinaryString(Ejs *ep, EjsVar *dest, const uchar *value,
- int len)
-{
- mprAssert(dest);
- mprAssert(value);
-
- ejsClearVar(ep, dest);
-
- if (dest->type != EJS_TYPE_UNDEFINED) {
- ejsClearVar(ep, dest);
- }
-
- dest->length = dupString(MPR_LOC_ARGS(ep), &dest->ustring, value, len);
- if (dest->length < 0) {
- return 0;
- }
-
- dest->type = EJS_TYPE_STRING;
- dest->allocatedData = 1;
- dest->flags = 0;
-
- return dest;
-}
-
-/******************************************************************************/
-/*
- * Set a var to undefined
- */
-
-EjsVar *ejsWriteVarAsUndefined(Ejs *ep, EjsVar *dest)
-{
- mprAssert(dest);
-
- if (dest->type != EJS_TYPE_UNDEFINED) {
- ejsClearVar(ep, dest);
- }
-
- dest->type = EJS_TYPE_UNDEFINED;
- dest->allocatedData = 0;
- dest->flags = 0;
-
- return dest;
-}
-
-/******************************************************************************/
-/*
- * Convert a value to a text based representation of its value
- * If you provide a format, you MUST ensure you know the type.
- * Caller must free the result.
- */
-
-char *ejsFormatVar(Ejs *ep, const char *fmt, EjsVar *vp)
-{
- char *buf, *src, *value, *allocValue;
- uchar *ubuf;
- int len;
-
- buf = 0;
- allocValue = 0;
- value = 0;
-
- switch (vp->type) {
- case EJS_TYPE_UNDEFINED:
- value = "undefined";
- break;
-
- case EJS_TYPE_NULL:
- value = "null";
- break;
-
- case EJS_TYPE_PTR:
- if (fmt == NULL || *fmt == '\0') {
- len = mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0,
- "[Opaque Pointer %p]", vp->ptr.userPtr);
- } else {
- len = mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0, fmt, vp->ptr);
- }
- goto done;
-
- case EJS_TYPE_BOOL:
- value = (vp->boolean) ? "true" : "false";
- break;
-
-#if BLD_FEATURE_FLOATING_POINT
- case EJS_TYPE_FLOAT:
- if (fmt == NULL || *fmt == '\0') {
- fmt = "%f";
- }
- len = mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0, fmt, vp->floating);
- goto done;
-#endif
-
- case EJS_TYPE_INT:
- if (fmt == NULL || *fmt == '\0') {
- fmt = "%d";
- }
- mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0, fmt, vp->integer);
- goto done;
-
-#if BLD_FEATURE_INT64
- case EJS_TYPE_INT64:
- if (fmt == NULL || *fmt == '\0') {
- fmt = "%Ld";
- }
- mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0, fmt, vp->integer64);
- goto done;
-#endif
-
- case EJS_TYPE_CMETHOD:
- value = "[C Method]";
- break;
-
- case EJS_TYPE_STRING_CMETHOD:
- value = "[C StringMethod]";
- break;
-
- case EJS_TYPE_METHOD:
- value = ejsVarToString(ep, vp);
- break;
-
- case EJS_TYPE_OBJECT:
- value = ejsVarToString(ep, vp);
- break;
-
- case EJS_TYPE_STRING:
- src = vp->string;
- mprAssert(src);
-
- if (fmt && *fmt && src) {
- mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0, fmt, src);
-
- } else if (src == NULL) {
- buf = mprStrdup(ep, "null");
-
- } else {
- ubuf = (uchar*) buf;
- if (dupString(MPR_LOC_ARGS(ep), &ubuf, src, vp->length) < 0) {
- return mprStrdup(ep, "");
- }
- buf = (char*) ubuf;
- }
- break;
-
- default:
- mprAssert(0);
- }
-
- if (fmt == NULL || *fmt == '\0') {
- len = mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0, "%s", value);
- } else {
- len = mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0, fmt, value);
- }
-
-done:
- if (allocValue) {
- mprFree(allocValue);
- }
- return buf;
-}
-
-/******************************************************************************/
-/*
- * Convert the variable to a boolean. Only for primitive types.
- */
-
-int ejsVarToBoolean(EjsVar *vp)
-{
- mprAssert(vp);
-
- switch (vp->type) {
- case EJS_TYPE_UNDEFINED:
- case EJS_TYPE_NULL:
- case EJS_TYPE_STRING_CMETHOD:
- case EJS_TYPE_CMETHOD:
- case EJS_TYPE_METHOD:
- return 0;
-
- case EJS_TYPE_OBJECT:
- return (vp->objectState != NULL);
-
- case EJS_TYPE_PTR:
- return (vp->ptr.userPtr != NULL);
-
- case EJS_TYPE_BOOL:
- return vp->boolean;
-
-#if BLD_FEATURE_FLOATING_POINT
- case EJS_TYPE_FLOAT:
- return (vp->floating != 0 && !ejsIsNan(vp->floating));
-#endif
-
- case EJS_TYPE_INT:
- return (vp->integer != 0);
-
-#if BLD_FEATURE_INT64
- case EJS_TYPE_INT64:
- return (vp->integer64 != 0);
-#endif
-
- case EJS_TYPE_STRING:
- return (vp->length > 0);
-#if UNUSED
- if (strcmp(vp->string, "true") == 0 ||
- strcmp(vp->string, "TRUE") == 0) {
- return 1;
-
- } else if (strcmp(vp->string, "false") == 0 ||
- strcmp(vp->string, "FALSE") == 0) {
- return 0;
-
- } else {
- return atoi(vp->string);
- }
-#endif
- }
-
- /* Not reached */
- return 0;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_FLOATING_POINT
-/*
- * Convert the variable to a floating point number. Only for primitive types.
- */
-
-double ejsVarToFloat(EjsVar *vp)
-{
- mprAssert(vp);
-
- switch (vp->type) {
- case EJS_TYPE_UNDEFINED:
- case EJS_TYPE_NULL:
- case EJS_TYPE_STRING_CMETHOD:
- case EJS_TYPE_CMETHOD:
- case EJS_TYPE_METHOD:
- case EJS_TYPE_OBJECT:
- case EJS_TYPE_PTR:
- return 0;
-
- case EJS_TYPE_BOOL:
- return (vp->boolean) ? 1.0 : 0.0;
-
- case EJS_TYPE_FLOAT:
- return vp->floating;
-
- case EJS_TYPE_INT:
- return (double) vp->integer;
-
-#if BLD_FEATURE_INT64
- case EJS_TYPE_INT64:
- return (double) vp->integer64;
-#endif
-
- case EJS_TYPE_STRING:
- if (vp->length == 0) {
- return 0.0;
- } else {
- return atof(vp->string);
- }
- }
-
- /* Not reached */
- return 0;
-}
-
-#endif
-/******************************************************************************/
-/*
- * Convert the variable to an Integer type. Only works for primitive types.
- */
-
-int ejsVarToInteger(EjsVar *vp)
-{
- mprAssert(vp);
-
- switch (vp->type) {
- case EJS_TYPE_UNDEFINED:
- case EJS_TYPE_NULL:
- case EJS_TYPE_STRING_CMETHOD:
- case EJS_TYPE_CMETHOD:
- case EJS_TYPE_METHOD:
- case EJS_TYPE_OBJECT:
- return 0;
-
- case EJS_TYPE_BOOL:
- return (vp->boolean) ? 1 : 0;
-
-#if BLD_FEATURE_FLOATING_POINT
- case EJS_TYPE_FLOAT:
- if (ejsIsNan(vp->floating)) {
- return 0;
- }
- return (int) vp->floating;
-#endif
-
- case EJS_TYPE_INT:
- return vp->integer;
-
-#if BLD_FEATURE_INT64
- case EJS_TYPE_INT64:
- return (int) vp->integer64;
-#endif
-
- case EJS_TYPE_STRING:
- if (vp->length == 0) {
- return 0;
- } else {
- return ejsParseInteger(vp->string);
- }
- }
-
- /* Not reached */
- return 0;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_INT64
-/*
- * Convert the variable to an Integer64 type. Only works for primitive types.
- */
-
-int64 ejsVarToInteger64(EjsVar *vp)
-{
- mprAssert(vp);
-
- switch (vp->type) {
- case EJS_TYPE_UNDEFINED:
- case EJS_TYPE_NULL:
- case EJS_TYPE_STRING_CMETHOD:
- case EJS_TYPE_CMETHOD:
- case EJS_TYPE_METHOD:
- case EJS_TYPE_OBJECT:
- case EJS_TYPE_PTR:
- return 0;
-
- case EJS_TYPE_BOOL:
- return (vp->boolean) ? 1 : 0;
-
-#if BLD_FEATURE_FLOATING_POINT
- case EJS_TYPE_FLOAT:
- if (ejsIsNan(vp->floating)) {
- return 0;
- }
- return (int64) vp->floating;
-#endif
-
- case EJS_TYPE_INT:
- return vp->integer;
-
- case EJS_TYPE_INT64:
- return vp->integer64;
-
- case EJS_TYPE_STRING:
- if (vp->length == 0) {
- return 0;
- } else {
- return ejsParseInteger64(vp->string);
- }
- }
-
- /* Not reached */
- return 0;
-}
-
-#endif /* BLD_FEATURE_INT64 */
-/******************************************************************************/
-/*
- * Convert the variable to a number type. Only works for primitive types.
- */
-
-EjsNum ejsVarToNumber(EjsVar *vp)
-{
-#if BLD_FEATURE_NUM_TYPE_ID == EJS_TYPE_INT64
- return ejsVarToInteger64(vp);
-#elif BLD_FEATURE_NUM_TYPE_ID == EJS_TYPE_FLOAT
- return ejsVarToFloat(vp);
-#else
- return ejsVarToInteger(vp);
-#endif
-}
-
-/******************************************************************************/
-/*
- * Convert a var to a string. Store the result in ep->castTemp. If allocated
- * set ep->castAlloc to TRUE. Caller must NOT free the result.
- */
-
-char *ejsVarToString(Ejs *ep, EjsVar *vp)
-{
- MprBuf *bp;
- char numBuf[16];
- int len, i;
-
- if (ep->castAlloc) {
- mprFree(ep->castTemp);
- }
- ep->castTemp = 0;
- ep->castAlloc = 0;
-
- switch (vp->type) {
- case EJS_TYPE_UNDEFINED:
- ep->castTemp = "undefined";
- break;
-
- case EJS_TYPE_NULL:
- ep->castTemp = "null";
- break;
-
- case EJS_TYPE_PTR:
- len = mprAllocSprintf(MPR_LOC_ARGS(ep), &ep->castTemp, 0,
- "[Opaque Pointer %p]", vp->ptr.userPtr);
- ep->castAlloc = 1;
- break;
-
- case EJS_TYPE_BOOL:
- if (vp->boolean) {
- ep->castTemp = "true";
- } else {
- ep->castTemp = "false";
- }
- break;
-
-#if BLD_FEATURE_FLOATING_POINT
- case EJS_TYPE_FLOAT:
- len = mprAllocSprintf(MPR_LOC_ARGS(ep), &ep->castTemp, 0,
- "%f", vp->floating);
- ep->castAlloc = 1;
- break;
-#endif
-
- case EJS_TYPE_INT:
- mprItoa(numBuf, sizeof(numBuf), vp->integer);
- ep->castTemp = mprStrdup(ep, numBuf);
- ep->castAlloc = 1;
- break;
-
-#if BLD_FEATURE_INT64
- case EJS_TYPE_INT64:
- mprAllocSprintf(MPR_LOC_ARGS(ep), &ep->castTemp, 0,
- "%Ld", vp->integer64);
- ep->castAlloc = 1;
- break;
-#endif
-
- case EJS_TYPE_CMETHOD:
- ep->castTemp = "[C Method]";
- break;
-
- case EJS_TYPE_STRING_CMETHOD:
- ep->castTemp = "[C StringMethod]";
- break;
-
- case EJS_TYPE_METHOD:
- bp = mprCreateBuf(ep, 0, 0);
- mprPutStringToBuf(bp, "function (");
- for (i = 0; i < vp->method.args->length; i++) {
- mprPutStringToBuf(bp, vp->method.args->items[i]);
- if ((i + 1) < vp->method.args->length) {
- mprPutStringToBuf(bp, ", ");
- }
- }
- mprPutStringToBuf(bp, ") {");
- mprPutStringToBuf(bp, vp->method.body);
- mprPutStringToBuf(bp, "}");
- mprAddNullToBuf(bp);
- ep->castTemp = mprStealBuf(ep, bp);
- ep->castAlloc = 1;
- mprFree(bp);
- break;
-
- case EJS_TYPE_OBJECT:
- if (ejsRunMethod(ep, vp, "toString", 0) < 0) {
- return mprStrdup(ep, "[object Object]");
- }
- ep->castTemp = mprStrdup(ep, ep->result->string);
- ep->castAlloc = 1;
- break;
-
- case EJS_TYPE_STRING:
- if (vp->string == 0) {
- ep->castTemp = "null";
- } else {
- ep->castTemp = vp->string;
- }
- break;
-
- default:
- mprAssert(0);
- }
-
- mprAssert(ep->castTemp);
- return ep->castTemp;
-}
-
-/******************************************************************************/
-
-char *ejsVarToStringEx(Ejs *ep, EjsVar *vp, bool *alloc)
-{
- char *str;
-
- mprAssert(alloc);
-
- str = ejsVarToString(ep, vp);
- *alloc = ep->castAlloc;
- ep->castAlloc = 0;
- ep->castTemp = 0;
- return str;
-}
-
-/******************************************************************************/
-/*
- * Parse a string based on formatting instructions and intelligently
- * create a variable.
- *
- * Float format: [+|-]DIGITS][DIGITS][(e|E)[+|-]DIGITS]
- */
-
-EjsVar *ejsParseVar(Ejs *ep, const char *buf, EjsType preferredType)
-{
- EjsType type;
- const char *cp;
- int isHex;
-
- mprAssert(buf);
-
- type = preferredType;
-
- if (preferredType == EJS_TYPE_UNDEFINED) {
- isHex = 0;
- if (*buf == '-' || *buf == '+') {
- type = EJS_NUM_VAR;
-
- } else if (!isdigit((int) *buf)) {
- if (strcmp(buf, "true") == 0 || strcmp(buf, "false") == 0) {
- type = EJS_TYPE_BOOL;
- } else {
- type = EJS_TYPE_STRING;
- }
-
- } else if (isdigit((int) *buf)) {
- type = EJS_NUM_VAR;
- cp = buf;
- if (*cp && tolower(cp[1]) == 'x') {
- cp = &cp[2];
- isHex = 1;
- for (cp = buf; *cp; cp++) {
- if (! isxdigit((int) *cp)) {
- break;
- }
- }
- } else {
-#if BLD_FEATURE_FLOATING_POINT
- /* Could be integer or float */
- for (cp = buf; *cp; cp++) {
- if (! isdigit((int) *cp)) {
- int c = tolower(*cp);
- if (c == '.' || c == 'e' || c == 'f') {
- type = EJS_TYPE_FLOAT;
- break;
- }
- }
- }
-#endif
- }
- }
- }
-
- switch (type) {
- case EJS_TYPE_OBJECT:
- case EJS_TYPE_UNDEFINED:
- case EJS_TYPE_NULL:
- case EJS_TYPE_PTR:
- default:
- break;
-
- case EJS_TYPE_BOOL:
- return ejsCreateBoolVar(ep, ejsParseBoolean(buf));
-
- case EJS_TYPE_INT:
- return ejsCreateIntegerVar(ep, ejsParseInteger(buf));
-
-#if BLD_FEATURE_INT64
- case EJS_TYPE_INT64:
- return ejsCreateInteger64Var(ep, ejsParseInteger64(buf));
-#endif
-
- case EJS_TYPE_STRING:
- if (strcmp(buf, "null") == 0) {
- return ejsCreateNullVar(ep);
-
- } else if (strcmp(buf, "undefined") == 0) {
- return ejsCreateUndefinedVar(ep);
- }
-
- return ejsCreateStringVar(ep, buf);
-
-#if BLD_FEATURE_FLOATING_POINT
- case EJS_TYPE_FLOAT:
- return ejsCreateFloatVar(ep, atof(buf));
-#endif
-
- }
- return ejsCreateUndefinedVar(ep);
-}
-
-/******************************************************************************/
-/*
- * Convert the variable to a number type. Only works for primitive types.
- */
-
-bool ejsParseBoolean(const char *s)
-{
- if (s == 0 || *s == '\0') {
- return 0;
- }
- if (strcmp(s, "false") == 0 || strcmp(s, "FALSE") == 0) {
- return 0;
- }
- return 1;
-}
-
-/******************************************************************************/
-/*
- * Convert the variable to a number type. Only works for primitive types.
- */
-
-EjsNum ejsParseNumber(const char *s)
-{
-#if BLD_FEATURE_NUM_TYPE_ID == EJS_TYPE_INT64
- return ejsParseInteger64(s);
-#elif BLD_FEATURE_NUM_TYPE_ID == EJS_TYPE_FLOAT
- return ejsParseFloat(s);
-#else
- return ejsParseInteger(s);
-#endif
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_INT64
-/*
- * Convert the string buffer to an Integer64.
- */
-
-int64 ejsParseInteger64(const char *str)
-{
- const char *cp;
- int64 num64;
- int radix, c, negative;
-
- mprAssert(str);
-
- cp = str;
- num64 = 0;
- negative = 0;
-
- if (*cp == '-') {
- cp++;
- negative = 1;
- } else if (*cp == '+') {
- cp++;
- }
-
- /*
- * Parse a number. Observe hex and octal prefixes (0x, 0)
- */
- if (*cp != '0') {
- /*
- * Normal numbers (Radix 10)
- */
- while (isdigit((int) *cp)) {
- num64 = (*cp - '0') + (num64 * 10);
- cp++;
- }
- } else {
- cp++;
- if (tolower(*cp) == 'x') {
- cp++;
- radix = 16;
- while (*cp) {
- c = tolower(*cp);
- if (isdigit(c)) {
- num64 = (c - '0') + (num64 * radix);
- } else if (c >= 'a' && c <= 'f') {
- num64 = (c - 'a' + 10) + (num64 * radix);
- } else {
- break;
- }
- cp++;
- }
-
- } else{
- radix = 8;
- while (*cp) {
- c = tolower(*cp);
- if (isdigit(c) && c < '8') {
- num64 = (c - '0') + (num64 * radix);
- } else {
- break;
- }
- cp++;
- }
- }
- }
-
- if (negative) {
- return 0 - num64;
- }
- return num64;
-}
-
-#endif /* BLD_FEATURE_INT64 */
-/******************************************************************************/
-/*
- * Convert the string buffer to an Integer.
- */
-
-int ejsParseInteger(const char *str)
-{
- const char *cp;
- int num;
- int radix, c, negative;
-
- mprAssert(str);
-
- cp = str;
- num = 0;
- negative = 0;
-
- if (*cp == '-') {
- cp++;
- negative = 1;
- } else if (*cp == '+') {
- cp++;
- }
-
- /*
- * Parse a number. Observe hex and octal prefixes (0x, 0)
- */
- if (*cp != '0') {
- /*
- * Normal numbers (Radix 10)
- */
- while (isdigit((int) *cp)) {
- num = (*cp - '0') + (num * 10);
- cp++;
- }
- } else {
- cp++;
- if (tolower(*cp) == 'x') {
- cp++;
- radix = 16;
- while (*cp) {
- c = tolower(*cp);
- if (isdigit(c)) {
- num = (c - '0') + (num * radix);
- } else if (c >= 'a' && c <= 'f') {
- num = (c - 'a' + 10) + (num * radix);
- } else {
- break;
- }
- cp++;
- }
-
- } else{
- radix = 8;
- while (*cp) {
- c = tolower(*cp);
- if (isdigit(c) && c < '8') {
- num = (c - '0') + (num * radix);
- } else {
- break;
- }
- cp++;
- }
- }
- }
-
- if (negative) {
- return 0 - num;
- }
- return num;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_FLOATING_POINT
-/*
- * Convert the string buffer to an Floating.
- */
-
-double ejsParseFloat(const char *str)
-{
- return atof(str);
-}
-
-/******************************************************************************/
-
-int ejsIsNan(double f)
-{
-#if WIN
- return _isnan(f);
-#elif VXWORKS
- /* FUTURE */
- return (0);
-#else
- return (f == FP_NAN);
-#endif
-}
-/******************************************************************************/
-
-int ejsIsInfinite(double f)
-{
-#if WIN
- return !_finite(f);
-#elif VXWORKS
- /* FUTURE */
- return (0);
-#else
- return (f == FP_INFINITE);
-#endif
-}
-
-#endif /* BLD_FEATURE_FLOATING_POINT */
-
-/******************************************************************************/
-/*
- * Single point of control for all assignment to properties.
- *
- * Copy an objects core value (only). This preserves the destination object's
- * name. This implements copy by reference for objects and copy by value for
- * strings and other types. Caller must free dest prior to calling.
- */
-
-static EjsVar *copyVar(EJS_LOC_DEC(ep, loc), EjsVar *dest, const EjsVar *src,
- EjsCopyDepth copyDepth)
-{
- Ejs *ejsContext;
- EjsObj *srcObj;
- EjsProperty *destp;
- const char **srcArgs;
- char *str;
- int i;
-
- mprAssert(dest);
- mprAssert(src);
-
- if (dest == src) {
- return dest;
- }
-
- if (dest->type != EJS_TYPE_UNDEFINED) {
- ejsClearVar(ep, dest);
- }
-
- dest->allocatedData = 0;
-
- switch (src->type) {
- default:
- case EJS_TYPE_UNDEFINED:
- case EJS_TYPE_NULL:
- break;
-
- case EJS_TYPE_BOOL:
- dest->boolean = src->boolean;
- break;
-
- case EJS_TYPE_PTR:
- dest->ptr = src->ptr;
- if (dest->ptr.destructor) {
- dest->allocatedData = 1;
- }
- break;
-
- case EJS_TYPE_STRING_CMETHOD:
- dest->cMethodWithStrings = src->cMethodWithStrings;
- break;
-
- case EJS_TYPE_CMETHOD:
- dest->cMethod = src->cMethod;
- break;
-
-#if BLD_FEATURE_FLOATING_POINT
- case EJS_TYPE_FLOAT:
- dest->floating = src->floating;
- break;
-#endif
-
- case EJS_TYPE_INT:
- dest->integer = src->integer;
- break;
-
-#if BLD_FEATURE_INT64
- case EJS_TYPE_INT64:
- dest->integer64 = src->integer64;
- break;
-#endif
-
- case EJS_TYPE_OBJECT:
- if (copyDepth == EJS_SHALLOW_COPY) {
-
- /*
- * If doing a shallow copy and the src object is from the same
- * interpreter, or we are copying from the master interpreter, or
- * we are using a shared slab, then we can do a shallow copy.
- * Otherwise, we must do a deep copy.
- */
- srcObj = src->objectState;
- if (srcObj->ejs == ep || srcObj->ejs == ep->service->master ||
- (ep->flags & EJS_FLAGS_SHARED_SLAB)) {
- dest->objectState = src->objectState;
- dest->allocatedData = 1;
- break;
- }
- }
-
- /*
- * Doing a deep or recursive deep. Can get here if doing a shallow
- * copy and the object is from another non-master interpeter and not
- * using a shared slab.
- *
- * We must make sure the data is allocated using the right memory
- * context. It must be the same as the destination parent object.
- * Otherwise, when we free the property memory, the parent may
- * have a dangling pointer.
- */
- if (dest->isProperty) {
- destp = ejsGetPropertyPtr(dest);
- if (destp->parentObj == 0) {
- ejsContext = ep;
-
- } else {
- mprAssert(destp->parentObj);
- ejsContext = destp->parentObj->ejs;
- mprAssert(ejsContext);
- }
-
- } else {
- ejsContext = ep;
- }
-
- dest->objectState = createObj(EJS_LOC_PASS(ejsContext, loc));
- if (dest->objectState == 0) {
- /* Memory Error */
- return 0;
- }
-
- dest->objectState->baseClass = src->objectState->baseClass;
- dest->objectState->methods = src->objectState->methods;
- dest->objectState->noConstructor = src->objectState->noConstructor;
- dest->objectState->objName =
- mprStrdup(ejsContext, src->objectState->objName);
-
- if (dest->objectState->objName == 0) {
- return 0;
- }
-
- if (ejsCopyProperties(ep, dest, src, copyDepth) == 0) {
- return 0;
- }
- dest->allocatedData = 1;
- break;
-
- case EJS_TYPE_METHOD:
- dest->method.args = mprCreateItemArray(ep, EJS_INC_ARGS,
- EJS_MAX_ARGS);
- if (dest->method.args == 0) {
- return 0;
- }
- dest->allocatedData = 1;
- if (src->method.args) {
- srcArgs = (const char**) src->method.args->items;
- for (i = 0; i < src->method.args->length; i++) {
- str = mprStrdupInternal(EJS_LOC_PASS(dest->method.args,
- loc), srcArgs[i]);
- if (str == 0) {
- mprFree(dest->method.args);
- dest->method.args = 0;
- return 0;
- }
- if (mprAddItem(dest->method.args, str) < 0) {
- mprFree(dest->method.args);
- dest->method.args = 0;
- return 0;
- }
- }
- }
- dest->method.body = mprStrdup(dest->method.args, src->method.body);
- if (dest->method.body == 0) {
- mprFree(dest->method.args);
- dest->method.args = 0;
- return 0;
- }
- dest->callsSuper = src->callsSuper;
- break;
-
- case EJS_TYPE_STRING:
- dest->length = src->length;
- if (src->string) {
- /* Shallow, deep or recursive deep */
- dest->length = dupString(MPR_LOC_PASS(ep, loc), &dest->ustring,
- src->ustring, src->length);
- if (dest->length < 0) {
- return 0;
- }
- dest->allocatedData = 1;
-
- } else {
- dest->string = src->string;
- dest->allocatedData = 0;
- }
- break;
- }
-
- dest->type = src->type;
- dest->flags = src->flags;
- dest->isArray = src->isArray;
-
- return dest;
-}
-
-/******************************************************************************/
-/*
- * Copy all properies in an object. Must preserve property order
- */
-
-EjsVar *ejsCopyProperties(Ejs *ep, EjsVar *dest, const EjsVar *src,
- EjsCopyDepth copyDepth)
-{
- EjsProperty *srcProp, *destProp, *last, *next;
- int propertyIndex;
-
- srcProp = ejsGetFirstProperty(src, EJS_ENUM_ALL);
- while (srcProp) {
- next = ejsGetNextProperty(srcProp, EJS_ENUM_ALL);
- if (srcProp->visited) {
- srcProp = next;
- continue;
- }
-
- /*
- * This finds the last variable in the hash chain
- * FUTURE OPT. This is slow. If used double link, we could locate the
- * tail more easily.
- */
- destProp = hashLookup(dest->objectState, srcProp->name,
- &propertyIndex, &last);
- mprAssert(destProp == 0);
-
- destProp = allocProperty(ep, dest, srcProp->name, propertyIndex, last);
- if (destProp == 0) {
- mprAssert(destProp);
- return 0;
- }
-
- /*
- * Recursively copy the object. If DEEP_COPY, then we
- * will do a shallow copy of the object contents. If
- * RECURSIVE_DEEP, then we do a deep copy at all levels.
- */
- srcProp->visited = 1;
-
- if (copyVar(EJS_LOC_ARGS(ep), ejsGetVarPtr(destProp),
- ejsGetVarPtr(srcProp),
- (copyDepth == EJS_DEEP_COPY) ? EJS_SHALLOW_COPY : copyDepth)
- == 0) {
- return 0;
- }
- srcProp->visited = 0;
-
- srcProp = next;
- }
- return dest;
-}
-
-/******************************************************************************/
-/********************************** Properties ********************************/
-/******************************************************************************/
-/*
- * Create a property in an object and return a pointer to it. If the property
- * already exists then just return a pointer to it (no error).
- * To test for existance of a property, use GetProperty
- */
-
-static EjsProperty *hashLookup(EjsObj *obj, const char *property,
- int *propertyIndex, EjsProperty **hashTail)
-{
- EjsProperty *prop, *last;
- int index;
-
- mprAssert(obj);
- mprAssert(property);
-
- if (obj == 0 || property == 0 || *property == '\0') {
- mprAssert(0);
- return 0;
- }
-
- /*
- * Find the property in the hash chain if it exists
- */
- index = hash(property);
- prop = obj->propertyHash[index];
- for (last = 0; prop != 0; last = prop, prop = prop->hashNext) {
- if (prop->name[0] == property[0] &&
- strcmp(prop->name, property) == 0) {
- break;
- }
- }
- if (propertyIndex) {
- *propertyIndex = index;
- }
- if (hashTail) {
- *hashTail = last;
- }
-
- return prop;
-}
-
-/******************************************************************************/
-/*
- * Create a property in an object and return a pointer to it. If the property
- * already exists then just return a pointer to it (no error). If the property
- * does not exist, create an undefined variable. To test for existance of a
- * property, use GetProperty.
- */
-
-EjsProperty *ejsCreateSimpleProperty(Ejs *ep, EjsVar *op, const char *property)
-{
- EjsProperty *prop, *last;
- int propertyIndex;
-
- if (op == 0 || op->type != EJS_TYPE_OBJECT || property == 0 ||
- *property == '\0') {
- mprAssert(0);
- return 0;
- }
-
- /*
- * Find the property in the hash chain if it exists
- */
- prop = hashLookup(op->objectState, property, &propertyIndex, &last);
-
- if (prop == 0) {
- /*
- * Create a new property
- */
- prop = allocProperty(ep, op, property, propertyIndex, last);
- if (prop == 0) {
- mprAssert(prop == 0);
- return 0;
- }
- }
- return prop;
-}
-
-/******************************************************************************/
-/*
- * Create a property in an object and return a pointer to it. If the property
- * already exists then just return a pointer to it (no error).
- * To test for existance of a property, use GetProperty
- */
-
-EjsProperty *ejsCreateSimpleNonUniqueProperty(Ejs *ep, EjsVar *op,
- const char *property)
-{
- EjsProperty *prop, *last;
- int propertyIndex;
-
- if (op == 0 || op->type != EJS_TYPE_OBJECT || property == 0 ||
- *property == '\0') {
- mprAssert(0);
- return 0;
- }
-
- /*
- * Find end of chain
- */
- propertyIndex = hash(property);
- prop = op->objectState->propertyHash[propertyIndex];
- for (last = 0; prop != 0; last = prop, prop = prop->hashNext) {
- ;
- }
-
- return allocProperty(ep, op, property, propertyIndex, last);
-}
-
-/******************************************************************************/
-/*
- * Find a property in an object and return a pointer to it.
- * This does NOT traverse base classes.
- */
-
-EjsProperty *ejsGetSimpleProperty(Ejs *ep, EjsVar *op, const char *property)
-{
- mprAssert(op);
- mprAssert(op->type == EJS_TYPE_OBJECT);
- mprAssert(property && *property);
-
- /*
- * This is an internal API. It has very little checking.
- */
- return hashLookup(op->objectState, property, 0, 0);
-}
-
-/******************************************************************************/
-
-/*
- * NOTE: There is no ejsSetSimpleProperty as all the ejsSetProperty routines
- * operate only on the instance and don't follow base classes. ie. there is
- * no simple version required. However, there is a ejsSetBaseProperty routine
- * that will follow base classes and is used to set static properties in base
- * classes
- */
-
-/******************************************************************************/
-/******************************* Property Access ******************************/
-/******************************************************************************/
-/*
- * The property get routines follow base classes and utilize the propery
- * method access routines. The property set routines do not follow base
- * classes. The property ejsSetBase... routines do follow base classes.
- */
-
-/*
- * Find a property in an object and return a pointer to it.
- * This follows base classes.
- */
-
-EjsProperty *ejsGetProperty(Ejs *ep, EjsVar *op, const char *property)
-{
- EjsVar *vp, *newOp;
- int maxBaseClasses = 50;
-
- do {
- if (op->type != EJS_TYPE_OBJECT) {
- mprAssert(op->type == EJS_TYPE_OBJECT);
- return 0;
- }
- mprAssert(op->objectState);
-
- vp = ejsGetPropertyMethod(ep, op, property);
- if (vp != 0) {
- /*
- * Found
- */
- break;
- }
-
- newOp = op->objectState->baseClass;
- if (newOp == 0) {
- if (op->objectState != ep->objectClass->objectState) {
- newOp = ep->objectClass;
- }
- }
- op = newOp;
-
- /*
- * A little bit of sanity checking
- */
- if (--maxBaseClasses <= 0) {
- mprAssert(maxBaseClasses > 0);
- break;
- }
-
- } while (op);
-
- return ejsGetPropertyPtr(vp);
-}
-
-/******************************************************************************/
-/*
- * Get the property's variable. Optionally create if it does not exist.
- */
-
-EjsVar *ejsGetPropertyAsVar(Ejs *ep, EjsVar *vp, const char *property)
-{
- return ejsGetVarPtr(ejsGetProperty(ep, vp, property));
-}
-
-/******************************************************************************/
-/*
- * Get the property's value as a binary string.
- */
-
-const uchar *ejsGetPropertyAsBinaryString(Ejs *ep, EjsVar *obj,
- const char *property, int *length)
-{
- EjsVar *vp;
-
- vp = ejsGetVarPtr(ejsGetProperty(ep, obj, property));
- if (vp == 0 || ejsVarIsUndefined(vp)) {
- return 0;
- }
-
- if (vp->type == EJS_TYPE_STRING) {
- if (length) {
- *length = vp->length;
- }
- return vp->ustring;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Get the property's value as a string.
- */
-
-const char *ejsGetPropertyAsString(Ejs *ep, EjsVar *obj, const char *property)
-{
- EjsVar *vp;
-
- vp = ejsGetVarPtr(ejsGetProperty(ep, obj, property));
- if (vp == 0 || ejsVarIsUndefined(vp)) {
- return 0;
- }
-
- if (vp->type == EJS_TYPE_STRING) {
- return vp->string;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Get the property's value as a number.
- */
-
-BLD_FEATURE_NUM_TYPE ejsGetPropertyAsNumber(Ejs *ep, EjsVar *obj,
- const char *property)
-{
- EjsVar *vp;
-
- vp = ejsGetVarPtr(ejsGetProperty(ep, obj, property));
- if (vp == 0 || ejsVarIsUndefined(vp)) {
- return 0;
- }
-
- return ejsVarToNumber(vp);
-}
-
-/******************************************************************************/
-/*
- * Get the property's value as a integer.
- */
-
-int ejsGetPropertyAsInteger(Ejs *ep, EjsVar *obj, const char *property)
-{
- EjsVar *vp;
-
- vp = ejsGetVarPtr(ejsGetProperty(ep, obj, property));
- if (vp == 0 || ejsVarIsUndefined(vp)) {
- return 0;
- }
-
- return ejsVarToInteger(vp);
-}
-
-/******************************************************************************/
-/*
- * Get the property's value as a boolean.
- */
-
-bool ejsGetPropertyAsBoolean(Ejs *ep, EjsVar *obj, const char *property)
-{
- EjsVar *vp;
-
- vp = ejsGetVarPtr(ejsGetProperty(ep, obj, property));
- if (vp == 0 || ejsVarIsUndefined(vp)) {
- return 0;
- }
-
- return ejsVarToBoolean(vp);
-}
-
-/******************************************************************************/
-/*
- * Get the property's value as a pointer.
- */
-
-void *ejsGetPropertyAsPtr(Ejs *ep, EjsVar *obj, const char *property)
-{
- EjsVar *vp;
-
- vp = ejsGetVarPtr(ejsGetProperty(ep, obj, property));
- if (vp == 0 || ejsVarIsUndefined(vp)) {
- return 0;
- }
- if (vp->type == EJS_TYPE_PTR) {
- return vp->ptr.userPtr;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Create a property in the object. This will override any base class
- * properties.
- *
- * MOB -- need to spell out the difference between ejsSetProperty and
- * ejsCreateProperty.
- */
-
-EjsProperty *ejsCreateProperty(Ejs *ep, EjsVar *obj, const char *property)
-{
- EjsVar *vp;
-
- vp = ejsCreatePropertyMethod(ep, obj, property);
- return ejsGetPropertyPtr(vp);
-}
-
-/******************************************************************************/
-/*
- * Set a property's variable value. Create the property if it does not exist.
- * This routine DOES follow base classes.
- */
-
-EjsProperty *ejsSetBaseProperty(Ejs *ep, EjsVar *op, const char *property,
- const EjsVar *value)
-{
- EjsVar *vp, *newOp;
- int maxBaseClasses = 50;
-
- do {
- if (op->type != EJS_TYPE_OBJECT) {
- mprAssert(op->type == EJS_TYPE_OBJECT);
- return 0;
- }
- mprAssert(op->objectState);
-
- vp = ejsGetPropertyMethod(ep, op, property);
- if (vp != 0) {
- /*
- * Found
- */
- vp = ejsSetPropertyMethod(ep, op, property, value);
- break;
- }
-
- newOp = op->objectState->baseClass;
- if (newOp == 0) {
- if (op->objectState != ep->objectClass->objectState) {
- newOp = ep->objectClass;
- }
- }
- op = newOp;
-
- /*
- * A little bit of sanity checking
- */
- if (--maxBaseClasses <= 0) {
- mprAssert(maxBaseClasses > 0);
- break;
- }
-
- } while (op);
-
- return ejsGetPropertyPtr(vp);
-}
-
-/******************************************************************************/
-/*
- * Set a property's variable value. Create the property if it does not exist.
- * This does NOT follow base classes. Okay when updating instance properties,
- * but not for class (static) properties. This does a shallow copy which
- * will copy references.
- */
-
-EjsProperty *ejsSetProperty(Ejs *ep, EjsVar *obj, const char *property,
- const EjsVar *value)
-{
- EjsVar *vp;
-
- vp = ejsSetPropertyMethod(ep, obj, property, value);
-
- return ejsGetPropertyPtr(vp);
-}
-
-/******************************************************************************/
-/*
- * Set a property's variable value by assigning the given value. The caller
- * must NOT free value as it is assigned directly into the property's value.
- */
-
-EjsProperty *ejsSetPropertyAndFree(Ejs *ep, EjsVar *obj,
- const char *property, EjsVar *value)
-{
- EjsVar *vp;
-
- vp = ejsSetPropertyMethod(ep, obj, property, value);
-
- ejsFree(ep, value, EJS_SLAB_VAR);
-
- return ejsGetPropertyPtr(vp);
-}
-
-/******************************************************************************/
-
-EjsProperty *ejsSetPropertyToCMethod(Ejs *ep, EjsVar *vp, const char *prop,
- EjsCMethod fn, void *userData, int flags)
-{
- EjsVar v;
-
- ejsInitVar(&v, EJS_TYPE_CMETHOD);
- v.cMethod.fn = fn;
- v.cMethod.userData = userData;
- v.flags = flags;
-
- return ejsSetProperty(ep, vp, prop, &v);
-}
-
-/******************************************************************************/
-
-EjsProperty *ejsSetPropertyToBoolean(Ejs *ep, EjsVar *vp, const char *prop,
- int value)
-{
- EjsVar v;
-
- ejsInitVar(&v, EJS_TYPE_BOOL);
- v.boolean = value;
-
- return ejsSetProperty(ep, vp, prop, &v);
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_FLOATING_POINT
-
-EjsProperty *ejsSetPropertyToFloat(Ejs *ep, EjsVar *vp, const char *prop,
- double value)
-{
- EjsVar v;
-
- ejsInitVar(&v, EJS_TYPE_FLOAT);
- v.floating = value;
-
- return ejsSetProperty(ep, vp, prop, &v);
-}
-
-#endif
-/******************************************************************************/
-
-EjsProperty *ejsSetPropertyToInteger(Ejs *ep, EjsVar *vp, const char *prop,
- int value)
-{
- EjsVar v;
-
- ejsInitVar(&v, EJS_TYPE_INT);
- v.integer = value;
-
- return ejsSetProperty(ep, vp, prop, &v);
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_INT64
-
-EjsProperty *ejsSetPropertyToInteger64(Ejs *ep, EjsVar *vp, const char *prop,
- int64 value)
-{
- EjsVar v;
-
- ejsInitVar(&v, EJS_TYPE_INT64);
- v.integer64 = value;
-
- return ejsSetProperty(ep, vp, prop, &v);
-}
-
-#endif
-/******************************************************************************/
-
-EjsProperty *ejsSetPropertyToNull(Ejs *ep, EjsVar *vp, const char *prop)
-{
- EjsVar v;
-
- ejsInitVar(&v, EJS_TYPE_NULL);
-
- return ejsSetProperty(ep, vp, prop, &v);
-}
-
-/******************************************************************************/
-
-EjsProperty *ejsSetPropertyToMethod(Ejs *ep, EjsVar *vp, const char *prop,
- const char *body, MprArray *args, int flags)
-{
- return ejsSetPropertyAndFree(ep, vp, prop,
- ejsCreateMethodVar(ep, body, args, flags));
-}
-
-/******************************************************************************/
-
-EjsProperty *ejsSetPropertyToNumber(Ejs *ep, EjsVar *vp, const char *prop,
- EjsNum value)
-{
- return ejsSetPropertyAndFree(ep, vp, prop, ejsCreateNumberVar(ep, value));
-}
-
-/******************************************************************************/
-
-EjsProperty *ejsSetPropertyToStringCMethod(Ejs *ep, EjsVar *vp,
- const char *prop, EjsStringCMethod fn, void *userData, int flags)
-{
- EjsVar v;
-
- ejsInitVar(&v, EJS_TYPE_STRING_CMETHOD);
- v.cMethodWithStrings.fn = fn;
- v.cMethodWithStrings.userData = userData;
- v.flags = flags;
-
- return ejsSetProperty(ep, vp, prop, &v);
-}
-
-/******************************************************************************/
-
-EjsProperty *ejsSetPropertyToString(Ejs *ep, EjsVar *vp, const char *prop,
- const char *value)
-{
- EjsProperty *pp;
- EjsVar v;
-
- ejsInitVar(&v, EJS_TYPE_STRING);
-
- /* FUTURE OPT */
- v.string = mprStrdupInternal(EJS_LOC_ARGS(ep), value);
- if (v.string == 0) {
- return 0;
- }
- v.length = strlen(v.string);
- v.allocatedData = 1;
-
- pp = ejsSetProperty(ep, vp, prop, &v);
-
- mprFree(v.string);
-
- return pp;
-}
-
-/******************************************************************************/
-
-EjsProperty *ejsSetPropertyToBinaryString(Ejs *ep, EjsVar *vp,
- const char *prop, const uchar *value, int len)
-{
- EjsProperty *pp;
- EjsVar v;
-
- ejsInitVar(&v, EJS_TYPE_STRING);
-
- /* FUTURE OPT */
- v.length = dupString(MPR_LOC_ARGS(ep), &v.ustring, value, len);
- if (v.length < 0) {
- return 0;
- }
- v.allocatedData = 1;
-
- pp = ejsSetProperty(ep, vp, prop, &v);
-
- mprFree(v.ustring);
-
- return pp;
-}
-
-/******************************************************************************/
-
-EjsProperty *ejsSetPropertyToUndefined(Ejs *ep, EjsVar *vp, const char *prop)
-{
- EjsVar v;
-
- ejsInitVar(&v, EJS_TYPE_UNDEFINED);
-
- return ejsSetProperty(ep, vp, prop, &v);
-}
-
-/******************************************************************************/
-
-EjsProperty *ejsSetPropertyToPtr(Ejs *ep, EjsVar *vp, const char *prop,
- void *ptr, EjsDestructor destructor)
-{
- EjsVar v;
-
- ejsInitVar(&v, EJS_TYPE_PTR);
- v.ptr.userPtr = ptr;
- v.ptr.destructor = destructor;
- v.allocatedData = 1;
-
- return ejsSetProperty(ep, vp, prop, &v);
-}
-
-/******************************************************************************/
-
-EjsProperty *ejsSetPropertyToNewObj(Ejs *ep, EjsVar *vp, const char *prop,
- const char *className, MprArray *args)
-{
- return ejsSetPropertyAndFree(ep, vp, prop,
- ejsCreateObjUsingArgv(ep, 0, className, args));
-}
-
-/******************************************************************************/
-
-EjsProperty *ejsSetPropertyToObj(Ejs *ep, EjsVar *op, const char *prop)
-{
- return ejsSetPropertyAndFree(ep, op, prop, ejsCreateObjVar(ep));
-}
-
-/******************************************************************************/
-/*
- * Convenience routines
- */
-
-EjsVar *ejsSetPropertyToObjAsVar(Ejs *ep, EjsVar *op, const char *prop)
-{
- return ejsGetVarPtr(ejsSetPropertyToObj(ep, op, prop));
-}
-
-/******************************************************************************/
-/******************************************************************************/
-/******************************************************************************/
-/******************************************************************************/
-/*
- * Create a script method
- */
-
-EjsProperty *ejsDefineMethod(Ejs *ep, EjsVar *vp, const char *prop,
- const char *body, MprArray *args)
-{
- if (vp == 0) {
- vp = ejsGetGlobalObj(ep);
- }
- return ejsSetPropertyToMethod(ep, vp, prop, body, args, 0);
-}
-
-/******************************************************************************/
-/*
- * Create a C language method
- */
-
-EjsProperty *ejsDefineCMethod(Ejs *ep, EjsVar *vp, const char *prop,
- EjsCMethod fn, int flags)
-{
- if (vp == 0) {
- vp = ejsGetGlobalObj(ep);
- }
- return ejsSetPropertyToCMethod(ep, vp, prop, fn, 0, flags);
-}
-
-/******************************************************************************/
-/*
- * Define accessors
- */
-
-EjsProperty *ejsDefineAccessors(Ejs *ep, EjsVar *vp, const char *prop,
- const char *getBody, const char *setBody)
-{
- EjsProperty *pp;
- MprArray *args;
- char *propName;
-
- if (vp == 0) {
- vp = ejsGetGlobalObj(ep);
- }
-
- if (ejsSetPropertyToMethod(ep, vp, prop, getBody, 0, EJS_GET_ACCESSOR) < 0){
- ejsMemoryError(ep);
- return 0;
- }
-
- /* MOB -- OPT to use SLAB */
- /* MOB -- need to encapsulate this logic */
-
- if (mprAllocStrcat(MPR_LOC_ARGS(ep), &propName, EJS_MAX_ID+5, 0,
- "-set-", prop, NULL) < 0) {
- ejsMemoryError(ep);
- return 0;
- }
-
- args = mprCreateItemArray(ep, EJS_INC_ARGS, EJS_MAX_ARGS);
- mprAddItem(args, mprStrdup(args, "value"));
-
- pp = ejsSetPropertyToMethod(ep, vp, propName, setBody, args,
- EJS_SET_ACCESSOR);
- mprFree(propName);
-
- if (pp == 0) {
- ejsMemoryError(ep);
- return 0;
- }
-
- return pp;
-}
-
-/******************************************************************************/
-/*
- * Define C accessors
- */
-
-EjsProperty *ejsDefineCAccessors(Ejs *ep, EjsVar *vp, const char *prop,
- EjsCMethod getFn, EjsCMethod setFn, int flags)
-{
- EjsProperty *pp;
- char *propName;
-
- if (vp == 0) {
- vp = ejsGetGlobalObj(ep);
- }
- pp = ejsSetPropertyToCMethod(ep, vp, prop, getFn, 0,
- flags | EJS_GET_ACCESSOR);
- if (pp == 0) {
- ejsMemoryError(ep);
- return 0;
- }
-
- /* MOB -- OPT to use SLAB */
- if (mprAllocStrcat(MPR_LOC_ARGS(ep), &propName, EJS_MAX_ID + 5, 0,
- "-set-", prop, NULL) < 0) {
- ejsMemoryError(ep);
- return 0;
- }
- pp = ejsSetPropertyToCMethod(ep, vp, propName, setFn, 0,
- flags | EJS_SET_ACCESSOR);
- mprFree(propName);
-
- if (pp == 0) {
- ejsMemoryError(ep);
- return 0;
- }
- return pp;
-}
-
-/******************************************************************************/
-/*
- * Create a C language method with string arguments
- */
-
-EjsProperty *ejsDefineStringCMethod(Ejs *ep, EjsVar *vp, const char *prop,
- EjsStringCMethod fn, int flags)
-{
- if (vp == 0) {
- vp = ejsGetGlobalObj(ep);
- }
- return ejsSetPropertyToStringCMethod(ep, vp, prop, fn, 0, flags);
-}
-
-/******************************************************************************/
-
-void ejsSetCMethodUserData(EjsVar *obj, void *userData)
-{
- /*
- * This is a little dirty. We rely on the userData being in the same
- * place in the var structure.
- */
- obj->cMethod.userData = userData;
-}
-
-/******************************************************************************/
-
-void ejsSetVarFlags(EjsVar *obj, int flags)
-{
- obj->flags = flags;
-}
-
-/******************************************************************************/
-
-void *ejsGetCMethodUserData(EjsVar *obj)
-{
- return obj->cMethod.userData;
-}
-
-/******************************************************************************/
-
-int ejsGetVarFlags(EjsVar *obj)
-{
- return obj->flags;
-}
-
-/******************************************************************************/
-
-void ejsSetObjDestructor(Ejs *ep, EjsVar *obj, EjsDestructor destructor)
-{
- obj->objectState->destructor = destructor;
-}
-
-/******************************************************************************/
-
-void ejsClearObjDestructor(Ejs *ep, EjsVar *obj)
-{
- obj->objectState->destructor = 0;
-}
-
-/******************************************************************************/
-/*
- * Create a new property
- */
-
-static EjsProperty *allocProperty(Ejs *ep, EjsVar *op, const char *property,
- int propertyIndex, EjsProperty *last)
-{
- EjsProperty *prop;
- EjsObj *obj;
-
- obj = op->objectState;
-
- /*
- * Allocate the property using the memory context of the owning object
- */
- prop = ejsAllocProperty(EJS_LOC_ARGS(obj->ejs));
- if (prop == 0) {
- return 0;
- }
- if (mprStrcpy(prop->name, sizeof(prop->name), property) < 0) {
- ejsError(ep, EJS_REFERENCE_ERROR,
- "Property name %s is too long. Max is %d letters.",
- prop->name, EJS_MAX_ID);
- return 0;
- }
-
- ejsSetVarName(ep, ejsGetVarPtr(prop), &prop->name[0]);
-
- /*
- * Do hash linkage
- */
- if (last) {
- last->hashNext = prop;
- } else {
- obj->propertyHash[propertyIndex] = prop;
- }
-
-#if BLD_DEBUG
- prop->link.propertyName = prop->name;
- prop->link.property = prop;
- prop->link.head = &obj->link;
-#endif
-
- /*
- * Inserting before the dummy head will append to the end
- */
- linkPropertyBefore(obj, &obj->link, &prop->link);
-
- obj->numProperties++;
- prop->parentObj = obj;
- mprAssert(obj->ejs);
-
- return prop;
-}
-
-/******************************************************************************/
-/*
- * Delete a property from this object
- */
-
-int ejsDeleteProperty(Ejs *ep, EjsVar *vp, const char *property)
-{
- EjsProperty *prop, *last;
- EjsObj *obj;
- int propertyIndex;
-
- mprAssert(vp);
- mprAssert(property && *property);
- mprAssert(vp->type == EJS_TYPE_OBJECT);
-
- if (vp->type != EJS_TYPE_OBJECT) {
- mprAssert(vp->type == EJS_TYPE_OBJECT);
- return MPR_ERR_BAD_ARGS;
- }
-
- prop = hashLookup(vp->objectState, property, &propertyIndex, &last);
- if (prop == (EjsProperty*) 0) {
- return MPR_ERR_NOT_FOUND;
- }
- obj = vp->objectState;
-
-#if FUTURE
- if (prop->readonly) {
- mprAssert(! prop->readonly);
- return MPR_ERR_READ_ONLY;
- }
-#endif
-
- /*
- * If doing enumerations, then the object will mark preventDelete to
- * prevent any properties being deleted and thus disturbing the
- * traversal.
- */
- if (obj->preventDeleteProp) {
- obj->delayedDeleteProp = 1;
- prop->delayedDelete = 1;
- return 0;
- }
-
- /*
- * Remove from hash
- */
- if (last) {
- last->hashNext = prop->hashNext;
- } else {
- obj->propertyHash[propertyIndex] = prop->hashNext;
- }
-
- unlinkProperty(obj, &prop->link);
- obj->numProperties--;
-
- /*
- * Free any property data and return to the slab
- */
- if (prop->var.type != EJS_TYPE_OBJECT) {
- ejsClearVar(ep, ejsGetVarPtr(prop));
- }
- ejsFree(ep, prop, EJS_SLAB_PROPERTY);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Remove a property's value from this object. The property is set to
- * undefined.
- */
-
-EjsVar *ejsClearProperty(Ejs *ep, EjsVar *vp, const char *property)
-{
- EjsProperty *prop;
-
- mprAssert(vp);
- mprAssert(property && *property);
- mprAssert(vp->type == EJS_TYPE_OBJECT);
-
- if (vp->type != EJS_TYPE_OBJECT) {
- mprAssert(vp->type == EJS_TYPE_OBJECT);
- return 0;
- }
-
- prop = hashLookup(vp->objectState, property, 0, 0);
- if (prop == (EjsProperty*) 0) {
- return 0;
- }
-#if FUTURE
- if (prop->readonly) {
- mprAssert(! prop->readonly);
- return 0;
- }
-#endif
-
- ejsClearVar(ep, &prop->var);
- return &prop->var;
-}
-
-/******************************************************************************/
-/*
- * Unlink a property from the ordered list of properties
- */
-
-static void unlinkProperty(EjsObj *obj, EjsPropLink *propLink)
-{
- propLink->prev->next = propLink->next;
- propLink->next->prev = propLink->prev;
-}
-
-/******************************************************************************/
-#if UNUSED && KEEP
-/*
- * Insert a link after a specified link.
- */
-
-static void linkPropertyAfter(EjsObj *obj, EjsPropLink *at,
- EjsPropLink *propLink)
-{
- propLink->next = at->next;
- propLink->prev = at;
-
- at->next->prev = propLink;
- at->next = propLink;
-}
-
-#endif
-/******************************************************************************/
-/*
- * Insert a link before a specified link.
- */
-
-static void linkPropertyBefore(EjsObj *obj, EjsPropLink *at,
- EjsPropLink *propLink)
-{
- propLink->prev = at->prev;
- propLink->next = at;
-
- at->prev->next = propLink;
- at->prev = propLink;
-}
-
-/******************************************************************************/
-/*
- * This routine will sort properties in an object. If propertyName is not
- * null, then the properties in op must be objects with a property of the
- * name propertyName. If propertyName is null, then the properties of op
- * are directly sorted. If order is 1, they are sorted in ascending order.
- * If -1, they are sorted in descending order.
- *
- * NOTE: arrays keep their original index values.
- */
-
-void ejsSortProperties(Ejs *ep, EjsVar *op, EjsSortFn fn,
- const char *propertyName, int order)
-{
- EjsProperty *p1, *p2, *tmp;
- EjsPropLink *l1, *l2, *oldL1Spot;
- EjsObj *obj;
-
- obj = op->objectState;
-
- p1 = ejsGetFirstProperty(op, 0);
- while (p1) {
- if (p1->dontEnumerate) {
- p1 = ejsGetNextProperty(p1, 0);
- continue;
- }
-
- p2 = ejsGetFirstProperty(op, 0);
- while (p2 && p2 != p1) {
-
- if (p2->dontEnumerate) {
- p2 = ejsGetNextProperty(p2, 0);
- continue;
- }
-
- if (fn == 0) {
- if (propertyName) {
- fn = sortByProperty;
- } else {
- fn = sortAllProperties;
- }
- }
-
- if (fn(ep, p1, p2, propertyName, order) < 0) {
-
- l1 = &p1->link;
- l2 = &p2->link;
-
- /*
- * Swap the properties without disturbing the hash chains.
- * l1 is always after l2 in the list. Unlink l1 and remember
- * the one after l1.
- */
- oldL1Spot = l1->next;
- unlinkProperty(obj, l1);
-
- /*
- * Manually reinsert l1 by replacing l2 with l1. l2 is out of
- * the chain.
- */
- l2->prev->next = l1;
- l2->next->prev = l1;
- l1->prev = l2->prev;
- l1->next = l2->next;
-
- /*
- * Reinsert l2 before the spot where l1 was.
- */
- linkPropertyBefore(obj, oldL1Spot, l2);
-
- /*
- * Swap the pointers so we continue to traverse correctly
- */
- tmp = p1;
- p1 = p2;
- p2 = tmp;
- }
- p2 = ejsGetNextProperty(p2, 0);
- }
- p1 = ejsGetNextProperty(p1, 0);
- }
-}
-
-/******************************************************************************/
-/*
- * Sort properties. Strings are sorted in ascending ASCII collating sequence
- * Numbers are sorted in increasing numerical order.
- */
-static int sortAllProperties(Ejs *ep, EjsProperty *p1, EjsProperty *p2,
- const char *propertyName, int order)
-{
- EjsVar *v1, *v2;
- char *buf1, *buf2;
- int rc, buf1Alloc;
-
- v1 = ejsGetVarPtr(p1);
- v2 = ejsGetVarPtr(p2);
-
- if (v1->type == v2->type) {
- /* MOB -- should support Numbers */
- if (v1->type == EJS_TYPE_INT) {
- if (v1->integer < v2->integer) {
- return - order;
-
- } else if (v1->integer == v2->integer) {
- return 0;
- }
- return order;
-
-#if BLD_FEATURE_FLOATING_POINT
- } else if (v1->type == EJS_TYPE_FLOAT) {
- if (v1->floating < v2->floating) {
- return - order;
-
- } else if (v1->floating == v2->floating) {
- return 0;
- }
- return order;
-
-#endif
- } else if (v1->type == EJS_TYPE_STRING) {
- /* MOB -- need binary support ? */
- return strcmp(v1->string, v2->string) * order;
-
- } else {
-
- buf1 = ejsVarToStringEx(ep, v1, &buf1Alloc);
- buf2 = ejsVarToString(ep, v2);
-
- rc = strcmp(buf1, buf2);
-
- if (buf1Alloc) {
- mprFree(buf1);
- }
-
- return rc * order;
- }
-
- } else {
- /* Type mismatch in array */
- return 0;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Sort an object by a given property.
- */
-static int sortByProperty(Ejs *ep, EjsProperty *p1, EjsProperty *p2,
- const char *propertyName, int order)
-{
- EjsVar *o1, *o2, *v1, *v2;
- char *buf1, *buf2;
- int rc, buf1Alloc;
-
- o1 = ejsGetVarPtr(p1);
- o2 = ejsGetVarPtr(p2);
-
- if (!ejsVarIsObject(o1) || !ejsVarIsObject(o2)) {
- mprAssert(ejsVarIsObject(o1));
- mprAssert(ejsVarIsObject(o2));
- return 0;
- }
-
- v1 = ejsGetPropertyAsVar(ep, o1, propertyName);
- v2 = ejsGetPropertyAsVar(ep, o2, propertyName);
-
- if (v1 == 0 || v2 == 0) {
- /* Property name not found */
- return 0;
- }
-
- if (v1->type != v2->type) {
- mprAssert(v1->type == v2->type);
- return 0;
- }
-
- if (v1->type == v2->type) {
- /* MOB -- should support Numbers */
- if (v1->type == EJS_TYPE_INT) {
- if (v1->integer < v2->integer) {
- return -order;
-
- } else if (v1->integer == v2->integer) {
- return 0;
- }
- return order;
-
-#if BLD_FEATURE_FLOATING_POINT
- } else if (v1->type == EJS_TYPE_FLOAT) {
- if (v1->floating < v2->floating) {
- return -order;
-
- } else if (v1->floating == v2->floating) {
- return 0;
- }
- return order;
-
-#endif
- } else if (v1->type == EJS_TYPE_STRING) {
- /* MOB -- need binary support ? */
- return strcmp(v1->string, v2->string) * order;
-
- } else {
- buf1 = ejsVarToStringEx(ep, v1, &buf1Alloc);
-
- buf2 = ejsVarToString(ep, v2);
-
- rc = strcmp(buf1, buf2);
-
- if (buf1Alloc) {
- mprFree(buf1);
- }
-
- return rc * order;
- }
-
- } else {
- /* Type mismatch in array */
- return 0;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Set a property's name
- */
-
-void ejsSetPropertyName(EjsProperty *pp, const char *property)
-{
- mprStrcpy(pp->name, sizeof(pp->name), property);
-}
-
-/******************************************************************************/
-
-int ejsMakePropertyEnumerable(EjsProperty *prop, int enumerate)
-{
- int oldValue;
-
- oldValue = prop->dontEnumerate;
- prop->dontEnumerate = !enumerate;
- return oldValue;
-}
-
-/******************************************************************************/
-
-void ejsMakePropertyPrivate(EjsProperty *prop, int isPrivate)
-{
- prop->isPrivate = isPrivate;
-}
-
-/******************************************************************************/
-/*
- * Make a variable read only. Can still be deleted.
- */
-
-void ejsMakePropertyReadOnly(EjsProperty *prop, int readonly)
-{
- prop->readonly = readonly;
-}
-
-/******************************************************************************/
-
-int ejsMakeObjPermanent(EjsVar *vp, int permanent)
-{
- int oldValue;
-
- if (vp && vp->type == EJS_TYPE_OBJECT) {
- oldValue = vp->objectState->permanent;
- vp->objectState->permanent = permanent;
- } else {
- oldValue = 0;
- }
- return oldValue;
-}
-
-/******************************************************************************/
-
-int ejsMakeObjLive(EjsVar *vp, bool alive)
-{
- int oldValue;
-
- oldValue = 0;
- if (vp && vp->type == EJS_TYPE_OBJECT) {
- oldValue = vp->objectState->alive;
- vp->objectState->alive = alive;
- } else {
- oldValue = 0;
- }
- return oldValue;
-}
-
-/******************************************************************************/
-
-void ejsMakeClassNoConstructor(EjsVar *vp)
-{
- mprAssert(vp->type == EJS_TYPE_OBJECT);
-
- if (vp->type == EJS_TYPE_OBJECT) {
- vp->objectState->noConstructor = 1;
- }
-}
-
-/******************************************************************************/
-/*
- * Get the count of properties.
- */
-
-int ejsGetPropertyCount(EjsVar *vp)
-{
- EjsProperty *pp;
- EjsPropLink *lp, *head;
- int count;
-
- mprAssert(vp);
-
- if (vp->type != EJS_TYPE_OBJECT) {
- return 0;
- }
-
- count = 0;
-
- head = &vp->objectState->link;
- for (lp = head->next; lp != head; lp = lp->next) {
- pp = ejsGetPropertyFromLink(lp);
- if (! pp->dontEnumerate) {
- count++;
- }
- }
- return count;
-}
-
-/******************************************************************************/
-/*
- * Get the first property in an object. Used for walking all properties in an
- * object. This will only enumerate properties in this class and not in base
- * classes.
- */
-
-EjsProperty *ejsGetFirstProperty(const EjsVar *op, int flags)
-{
- EjsProperty *pp;
- EjsObj *obj;
- EjsPropLink *head, *lp;
-
- mprAssert(op);
- mprAssert(op->type == EJS_TYPE_OBJECT);
-
- if (op->type != EJS_TYPE_OBJECT) {
- mprAssert(op->type == EJS_TYPE_OBJECT);
- return 0;
- }
- pp = 0;
-
- do {
- obj = op->objectState;
-
- head = &obj->link;
- lp = head->next;
-
- while (lp != head) {
- pp = ejsGetPropertyFromLink(lp);
- if (! pp->dontEnumerate || (flags & EJS_ENUM_HIDDEN)) {
- break;
- }
- lp = lp->next;
- }
- if (lp != head || op->type != EJS_TYPE_OBJECT ||
- !(flags & EJS_ENUM_CLASSES)) {
- break;
- }
-
- op = obj->baseClass;
-
- } while (lp == 0 && op);
-
- return pp;
-}
-
-/******************************************************************************/
-/*
- * Get the next property in sequence. This will only enumerate properties in
- * this class and not in base classes.
- */
-
-EjsProperty *ejsGetNextProperty(EjsProperty *last, int flags)
-{
- EjsProperty *pp;
- EjsObj *obj;
- EjsPropLink *lp, *head;
-
- obj = last->parentObj;
-
- lp = last->link.next;
- head = &obj->link;
- pp = 0;
-
- while (obj) {
- while (lp != head) {
- pp = ejsGetPropertyFromLink(lp);
- if (! pp->dontEnumerate || (flags & EJS_ENUM_HIDDEN)) {
- break;
- }
- lp = lp->next;
- }
- if (lp != head || !(flags & EJS_ENUM_CLASSES)) {
- break;
- }
-
- /*
- * Now iterate over properties in base classes (down the chain)
- */
- if (obj->baseClass == 0) {
- break;
- }
-
- obj = obj->baseClass->objectState;
- if (obj == 0) {
- break;
- }
- }
- return pp;
-}
-
-/******************************************************************************/
-/*
- * Find a variable given a variable name and return the parent object and
- * the variable itself. This routine supports literal variable and property
- * names that may be objects or arrays but may NOT have expressions.
- * Returns -1 on errors or if the variable is not found.
- * FUTURE -- Needs OPT
- */
-
-EjsVar *ejsFindProperty(Ejs *ep, EjsVar **obj, char **property, EjsVar *global,
- EjsVar *local, const char *fullName, int create)
-{
- EjsProperty *currentProp;
- EjsVar *currentObj;
- /* MOB -- WARNING BIG */
- char tokBuf[EJS_MAX_ID], propertyName[EJS_MAX_ID];
- char *token, *next, *cp, *endp;
-
- mprAssert(fullName && *fullName);
-
- currentProp = 0;
- currentObj = 0;
-
- if (global == 0) {
- global = ep->global;
- }
-
- if (obj) {
- *obj = 0;
- }
- if (property) {
- *property = 0;
- }
-
- if (fullName == 0) {
- return 0;
- }
-
- next = (char*) fullName;
- token = getNextVarToken(&next, tokBuf, sizeof(tokBuf));
- mprStrcpy(propertyName, sizeof(propertyName), token);
-
- if (local) {
- currentProp = ejsGetProperty(ep, local, token);
- currentObj = local;
- }
- if (currentProp == 0) {
- currentProp = ejsGetProperty(ep, global, token);
- currentObj = global;
- }
-
- token = getNextVarToken(&next, tokBuf, sizeof(tokBuf));
-
- while (currentObj != 0 && token != 0 && *token) {
-
- if (currentProp == 0) {
- return 0;
- }
- currentObj = &currentProp->var;
- currentProp = 0;
-
- if (*token == '[') {
- token = getNextVarToken(&next, tokBuf, sizeof(tokBuf));
-
- mprStrcpy(propertyName, sizeof(propertyName), token);
- cp = propertyName;
- if (*cp == '\"') {
- cp++;
- if ((endp = strchr(cp, '\"')) != 0) {
- *endp = '\0';
- }
- } else if (*cp == '\'') {
- cp++;
- if ((endp = strchr(cp, '\'')) != 0) {
- *endp = '\0';
- }
- }
-
- currentProp = ejsGetProperty(ep, currentObj, propertyName);
-
- token = getNextVarToken(&next, tokBuf, sizeof(tokBuf));
- if (*token != ']') {
- return 0;
- }
-
- } else if (*token == '.') {
- token = getNextVarToken(&next, tokBuf, sizeof(tokBuf));
- if (!isalpha((int) token[0]) &&
- token[0] != '_' && token[0] != '$') {
- return 0;
- }
-
- mprStrcpy(propertyName, sizeof(propertyName), token);
- currentProp = ejsGetProperty(ep, currentObj, token);
-
- } else {
- currentProp = ejsGetProperty(ep, currentObj, token);
- }
-
- if (next == 0 || *next == '\0') {
- break;
- }
- token = getNextVarToken(&next, tokBuf, sizeof(tokBuf));
- }
-
- if (obj) {
- *obj = currentObj;
- }
-
-
- if (currentProp == 0 && currentObj >= 0 && create) {
- currentProp = ejsCreateSimpleProperty(ep, currentObj, propertyName);
- }
-
- if (property) {
- *property = currentProp->name;
- }
- return ejsGetVarPtr(currentProp);
-}
-
-/******************************************************************************/
-/*
- * Get the next token as part of a variable specification. This will return
- * a pointer to the next token and will return a pointer to the next token
- * (after this one) in "next". The tokBuf holds the parsed token.
- */
-
-static char *getNextVarToken(char **next, char *tokBuf, int tokBufLen)
-{
- char *start, *cp;
- int len;
-
- start = *next;
- while (isspace((int) *start) || *start == '\n' || *start == '\r') {
- start++;
- }
- cp = start;
-
- if (*cp == '.' || *cp == '[' || *cp == ']') {
- cp++;
- } else {
- while (*cp && *cp != '.' && *cp != '[' && *cp != ']' &&
- !isspace((int) *cp) && *cp != '\n' && *cp != '\r') {
- cp++;
- }
- }
- len = mprMemcpy(tokBuf, tokBufLen - 1, start, cp - start);
- tokBuf[len] = '\0';
-
- *next = cp;
- return tokBuf;
-}
-
-/******************************************************************************/
-
-EjsVar *ejsGetGlobalClass(Ejs *ep)
-{
- return ep->global;
-}
-
-/******************************************************************************/
-/*************************** Property Access Methods **************************/
-/******************************************************************************/
-/*
- * Create an undefined property. This routine calls the object method hooks.
- */
-
-/* MOB -- better suffix than "Method" */
-EjsVar *ejsCreatePropertyMethod(Ejs *ep, EjsVar *op, const char *property)
-{
- EjsVar *vp;
-
- mprAssert(ep);
- mprAssert(op);
- mprAssert(property && *property);
-
- if (op == 0) {
- return 0;
- }
-
- mprAssert(op->type == EJS_TYPE_OBJECT);
- mprAssert(op->objectState);
-
- if (op->objectState == 0) {
- return 0;
- }
-
- if (op->objectState->methods == 0) {
- vp = ejsGetVarPtr(ejsCreateSimpleProperty(ep, op, property));
- } else {
- vp = (op->objectState->methods->createProperty)(ep, op, property);
- }
-
- if (vp == 0) {
- mprAssert(vp);
- op->objectState->hasErrors = 1;
- return 0;
- }
-
- /*
- * FUTURE - find a better way.
- */
- if (op->isArray) {
- ejsSetArrayLength(ep, op, property, 0, 0);
- }
- return vp;
-}
-
-/******************************************************************************/
-
-int ejsDeletePropertyMethod(Ejs *ep, EjsVar *op, const char *property)
-{
- int rc;
-
- mprAssert(ep);
- mprAssert(op);
- mprAssert(property && *property);
-
- if (op == 0) {
- return -1;
- }
-
- mprAssert(op->type == EJS_TYPE_OBJECT);
- mprAssert(op->objectState);
-
- if (op->objectState == 0) {
- return -1;
- }
-
- if (op->objectState->methods == 0) {
- rc = ejsDeleteProperty(ep, op, property);
- } else {
- rc = (op->objectState->methods->deleteProperty)(ep, op, property);
- }
-
- if (rc < 0) {
- op->objectState->hasErrors = 1;
- }
-
- op->objectState->dirty = 1;
-
- return rc;
-}
-
-/******************************************************************************/
-/*
- * Set the value of a property. Create if it does not exist
- * If the object has property accessor methods defined, use those.
- */
-
-EjsVar *ejsSetPropertyMethod(Ejs *ep, EjsVar *op, const char *property,
- const EjsVar *value)
-{
- EjsVar *vp;
-
- mprAssert(ep);
- mprAssert(op);
- mprAssert(property && *property);
- mprAssert(value);
-
- if (op == 0) {
- return 0;
- }
-
- mprAssert(op->type == EJS_TYPE_OBJECT);
- mprAssert(op->objectState);
-
- if (op->objectState == 0) {
- return 0;
- }
-
- if (op->objectState->methods == 0) {
- vp = ejsGetVarPtr(ejsCreateSimpleProperty(ep, op, property));
- if (vp && ejsWriteVar(ep, vp, (EjsVar*) value, EJS_SHALLOW_COPY) < 0) {
- mprAssert(0);
- op->objectState->hasErrors = 1;
- return 0;
- }
-
- } else {
- vp = (op->objectState->methods->setProperty)(ep, op, property, value);
- }
-
- if (vp == 0) {
- mprAssert(vp);
- op->objectState->hasErrors = 1;
- return 0;
- }
-
- if (vp->type == EJS_TYPE_OBJECT) {
- /*
- * We make an object alive (and subject to garbage collection) when
- * it is referenced in some other object. If this is undesirable, the
- * caller should make the object permanent while calling this routine
- * and then afterward clear the alive bit by calling ejsMakeObjLive().
- */
- if (op->objectState != vp->objectState) {
- vp->objectState->alive = 1;
- }
-#if BLD_DEBUG
- {
- EjsProperty *pp = ejsGetPropertyPtr(vp);
- ejsSetVarName(ep, vp, &pp->name[0]);
- if (value->propertyName == 0) {
- ejsSetVarName(ep, (EjsVar*) value, &pp->name[0]);
- }
- }
-#endif
- }
-
- /*
- * Trap assignments to array.length. MOB - find a better way.
- */
- if (vp->isArrayLength) {
- ejsSetArrayLength(ep, op, 0, 0, value);
- }
-
- op->objectState->dirty = 1;
-
- return vp;
-}
-
-/******************************************************************************/
-
-EjsVar *ejsGetPropertyMethod(Ejs *ep, EjsVar *op, const char *property)
-{
- mprAssert(ep);
- mprAssert(op);
- mprAssert(property && *property);
-
- if (op == 0) {
- return 0;
- }
-
- mprAssert(op->type == EJS_TYPE_OBJECT);
- mprAssert(op->objectState);
-
- if (op->objectState == 0) {
- return 0;
- }
-
- if (op->objectState->methods == 0) {
- return ejsGetVarPtr(ejsGetSimpleProperty(ep, op, property));
- } else {
- return (op->objectState->methods->getProperty)(ep, op, property);
- }
-}
-
-/******************************************************************************/
-/*************************** Advisory Locking Support *************************/
-/******************************************************************************/
-#if BLD_FEATURE_MULTITHREAD
-
-void ejsLockObj(EjsVar *vp)
-{
- mprAssert(vp);
- mprAssert(vp->type == EJS_TYPE_OBJECT);
- mprAssert(vp->objectState);
-
- if (vp->objectState->mutex == 0) {
- vp->objectState->mutex = mprCreateLock(vp->objectState->ejs);
- }
- mprLock(vp->objectState->mutex);
-}
-
-/******************************************************************************/
-
-void ejsUnlockObj(EjsVar *vp)
-{
- mprAssert(vp);
- mprAssert(vp->type == EJS_TYPE_OBJECT);
- mprAssert(vp->objectState);
-
- if (vp->objectState->mutex) {
- mprUnlock(vp->objectState->mutex);
- }
-}
-
-#endif
-/******************************************************************************/
-/************************** Internal Support Routines *************************/
-/******************************************************************************/
-/*
- * Create an object.
- */
-
-static EjsObj *createObj(EJS_LOC_DEC(ep, loc))
-{
- EjsObj *op;
- EjsPropLink *lp;
-
- op = (EjsObj*) ejsAllocObj(EJS_LOC_PASS(ep, loc));
- if (op == NULL) {
- return 0;
- }
-
- /*
- * The objectState holds the dummy head for the ordered list of properties
- */
- lp = &op->link;
- lp->next = lp->prev = lp;
-
-#if BLD_DEBUG
- /*
- * This makes it much easier to debug the list
- */
- lp->head = lp;
- lp->propertyName = "dummyHead";
-#endif
-
- return op;
-}
-
-/******************************************************************************/
-/*
- * Destroy an object. Called by the garbage collector if there are no more
- * references to an object.
- */
-
-int ejsDestroyObj(Ejs *ep, EjsObj *obj)
-{
- EjsProperty *pp;
- EjsPropLink *lp, *head, *nextLink;
-
- mprAssert(obj);
-
- if (obj->destructor) {
- EjsVar v;
- memset(&v, 0, sizeof(v));
- v.type = EJS_TYPE_OBJECT;
- v.objectState = obj;
- ejsSetVarName(ep, &v, "destructor");
-
-#if BLD_FEATURE_ALLOC_LEAK_TRACK
- v.gc.allocatedBy = "static";
-#endif
-
- if ((obj->destructor)(ep, &v) < 0) {
- return -1;
- }
- }
- mprFree(obj->objName);
- obj->objName = 0;
-
- /*
- * Just for safety. An object may be marked by a GC on the default
- * interpreter. After destroying, it won't be on the free list and so
- * won't be reset.
- */
- obj->gcMarked = 0;
- obj->visited = 0;
-
- head = &obj->link;
- for (lp = head->next; lp != head; lp = nextLink) {
-
- pp = ejsGetPropertyFromLink(lp);
- nextLink = lp->next;
-
- /*
- * We don't unlink as we are destroying all properties.
- * If an object, we don't need to clear either.
- */
- if (pp->var.type != EJS_TYPE_OBJECT) {
- ejsClearVar(ep, ejsGetVarPtr(pp));
- }
- ejsFree(ep, pp, EJS_SLAB_PROPERTY);
- }
-
-#if BLD_FEATURE_MULTITHREAD
- if (obj->mutex) {
- mprDestroyLock(obj->mutex);
- }
-#endif
-
- ejsFree(ep, obj, EJS_SLAB_OBJ);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Fast hash. The history of this algorithm is part of lost computer science
- * folk lore.
- */
-
-static int hash(const char *property)
-{
- uint sum;
-
- mprAssert(property);
-
- sum = 0;
- while (*property) {
- sum += (sum * 33) + *property++;
- }
-
- return sum % EJS_OBJ_HASH_SIZE;
-}
-
-/******************************************************************************/
-/*
- * Set a new length for an array. If create is non-null, then it is the name
- * of a new array index. If delete is set, it is the name of an index being
- * deleted. If setLength is set to a variable, it counts the new length for the
- * array. Note that create and delete are ignored if they are non-integer
- * array indexes (eg. normal properties).
- */
-
-void ejsSetArrayLength(Ejs *ep, EjsVar *obj, const char *create,
- const char *delete, const EjsVar *setLength)
-{
- EjsVar *vp;
- char idx[16];
- int oldSize, newSize, i;
-
- vp = ejsGetPropertyAsVar(ep, obj, "length");
- oldSize = vp->integer;
- newSize = oldSize;
-
- if (create) {
- if (isdigit(*create)) {
- i = atoi(create);
- newSize = max(i + 1, oldSize);
- }
- } else if (delete) {
- if (isdigit(*delete)) {
- i = atoi(delete);
- newSize = (i == (oldSize - 1) ? oldSize - 1 : oldSize);
- }
- } else {
- newSize = setLength->integer;
- }
-
- for (i = newSize; i < oldSize; i++) {
- mprItoa(idx, sizeof(idx), i);
- ejsDeleteProperty(ep, obj, idx);
- }
-
- if (ejsWriteVarAsInteger(ep, vp, newSize) == 0) {
- mprAssert(0);
- }
-}
-
-/******************************************************************************/
-
-void ejsClearObjErrors(EjsVar *vp)
-{
- if (vp == 0 || vp->type != EJS_TYPE_OBJECT || vp->objectState == 0) {
- mprAssert(0);
- return;
- }
- vp->objectState->hasErrors = 0;
-}
-
-/******************************************************************************/
-
-int ejsObjHasErrors(EjsVar *vp)
-{
- if (vp == 0 || vp->type != EJS_TYPE_OBJECT || vp->objectState == 0) {
- mprAssert(0);
- return -1;
- }
- return vp->objectState->hasErrors;
-}
-
-/******************************************************************************/
-
-bool ejsIsObjDirty(EjsVar *vp)
-{
- mprAssert(vp->type == EJS_TYPE_OBJECT && vp->objectState);
-
- if (vp->type == EJS_TYPE_OBJECT && vp->objectState) {
- return vp->objectState->dirty;
- }
- return 0;
-}
-
-/******************************************************************************/
-
-void ejsResetObjDirtyBit(EjsVar *vp)
-{
- mprAssert(vp->type == EJS_TYPE_OBJECT && vp->objectState);
-
- if (vp->type == EJS_TYPE_OBJECT && vp->objectState) {
- vp->objectState->dirty = 0;
- }
-}
-
-/******************************************************************************/
-/*
- * Copy a string. Always null terminate.
- */
-
-static int dupString(MPR_LOC_DEC(ctx, loc), uchar **dest, const void *src,
- int nbytes)
-{
- mprAssert(dest);
- mprAssert(src);
-
- if (nbytes > 0) {
- *dest = mprMemdupInternal(MPR_LOC_PASS(ctx, loc), src, nbytes + 1);
- if (*dest == 0) {
- return MPR_ERR_MEMORY;
- }
-
- } else {
- *dest = (uchar*) mprAlloc(ctx, 1);
- nbytes = 0;
- }
-
- (*dest)[nbytes] = '\0';
-
- return nbytes;
-}
-
-/******************************************************************************/
-
-const char *ejsGetVarTypeAsString(EjsVar *vp)
-{
- switch (vp->type) {
- default:
- case EJS_TYPE_UNDEFINED:
- return "undefined";
- case EJS_TYPE_NULL:
- return "null";
- case EJS_TYPE_BOOL:
- return "bool";
- case EJS_TYPE_CMETHOD:
- return "cmethod";
- case EJS_TYPE_FLOAT:
- return "float";
- case EJS_TYPE_INT:
- return "int";
- case EJS_TYPE_INT64:
- return "int64";
- case EJS_TYPE_OBJECT:
- return "object";
- case EJS_TYPE_METHOD:
- return "method";
- case EJS_TYPE_STRING:
- return "string";
- case EJS_TYPE_STRING_CMETHOD:
- return "string method";
- case EJS_TYPE_PTR:
- return "ptr";
- }
-}
-
-/******************************************************************************/
-
-void *ejsGetVarUserPtr(EjsVar *vp)
-{
- mprAssert(vp);
- mprAssert(vp->type == EJS_TYPE_PTR);
-
- if (!ejsVarIsPtr(vp)) {
- return 0;
- }
- return vp->ptr.userPtr;
-}
-
-/******************************************************************************/
-
-void ejsSetVarUserPtr(EjsVar *vp, void *data)
-{
- mprAssert(vp);
- mprAssert(vp->type == EJS_TYPE_PTR);
-
- vp->ptr.userPtr = data;
-}
-
-/******************************************************************************/
-/*
- * Return TRUE if target is a subclass (or the same class) as baseClass.
- */
-
-bool ejsIsSubClass(EjsVar *target, EjsVar *baseClass)
-{
- do {
- if (target->objectState == baseClass->objectState) {
- return 1;
- }
- target = target->objectState->baseClass;
- } while (target);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejsVar.h b/source4/lib/appweb/ejs-2.0/ejs/ejsVar.h
deleted file mode 100644
index 071665e00b..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/ejsVar.h
+++ /dev/null
@@ -1,1091 +0,0 @@
-/*
- * ejsVar.h -- EJS Universal Variable Type
- */
-
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/*
- * Variables can efficiently store primitive types and can hold references to
- * objects. Objects can store properties which are themselves variables.
- * Properties can be primitive data types, other objects or methods.
- * Properties are indexed by a character name. A variable may store one of
- * the following types:
- *
- * string, integer, integer-64bit, C method, C method with string args,
- * Javascript method, Floating point number, boolean value, Undefined
- * value and the Null value.
- *
- * Variables have names while objects may be referenced by multiple variables.
- * Objects use reference counting for garbage collection.
- *
- * This module is not thread safe for performance and compactness. It relies
- * on upper modules to provide thread synchronization as required. The API
- * provides primitives to get variable/object references or to get copies of
- * variables which will help minimize required lock times.
- */
-
-#ifndef _h_EJS_VAR
-#define _h_EJS_VAR 1
-
-/********************************* Includes ***********************************/
-
-#include "mpr.h"
-
-/********************************** Defines ***********************************/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Defined in ejs.h
- */
-typedef struct Ejs Ejs;
-
-/*
- * Constants
- */
-#if BLD_FEATURE_SQUEEZE
- /**
- * Maximum property or variable name size
- */
- #define EJS_MAX_ID 64
-
- /*
- * EJS_VAR_HASH_SIZE must be less than the size of the bit field
- * propertyIndex in EjsProperty.
- */
- #define EJS_OBJ_HASH_SIZE 13
-
- /**
- * Maximum number of arguments per function call
- */
- #define EJS_MAX_ARGS 32
- #define EJS_INC_ARGS 8 /* Frame stack increment */
-
-#else
- #define EJS_MAX_ID 256
- #define EJS_OBJ_HASH_SIZE 29
- #define EJS_MAX_ARGS 64
- #define EJS_INC_ARGS 8
-#endif
-
-#define EJS_VAR_MAX_RECURSE 5 /* Max object loops */
-
-#if !DOXYGEN
-/*
- * Forward declare types
- */
-struct Ejs;
-struct EjsObj;
-struct EjsProperty;
-struct EjsVar;
-#endif
-
-/**
- * @overview EJ primitive variable type
- * @description EJ primitive variable values are stored in EjsVar structures.
- * The type of the primitive data is described by an EjsType field.
- * EjsVar variable types.
- * @stability Prototype.
- * @library libejs.
- * @see EJS_TYPE_UNDEFINED, EJS_TYPE_NULL, EJS_TYPE_BOOL, EJS_TYPE_CMETHOD,
- * EJS_TYPE_FLOAT, EJS_TYPE_INT, EJS_TYPE_INT64, EJS_TYPE_OBJECT,
- * EJS_TYPE_METHOD, EJS_TYPE_STRING, EJS_TYPE_STRING_CMETHOD, EJS_TYPE_PTR,
- */
-typedef uint EjsType;
-#define EJS_TYPE_UNDEFINED 0 /**< Undefined. No value has been set */
-#define EJS_TYPE_NULL 1 /**< Value defined to be null. */
-#define EJS_TYPE_BOOL 2 /**< Boolean type. */
-#define EJS_TYPE_CMETHOD 3 /**< C method */
-#define EJS_TYPE_FLOAT 4 /**< Floating point number */
-#define EJS_TYPE_INT 5 /**< Integer number */
-#define EJS_TYPE_INT64 6 /**< 64-bit Integer number */
-#define EJS_TYPE_OBJECT 7 /**< Object reference */
-#define EJS_TYPE_METHOD 8 /**< JavaScript method */
-#define EJS_TYPE_STRING 9 /**< String (immutable) */
-#define EJS_TYPE_STRING_CMETHOD 10 /**< C method with string args */
-#define EJS_TYPE_PTR 11 /**< Opaque pointer */
-
-/*
- * Create a type for the default number type
- * Config.h will define the default number type. For example:
- *
- * BLD_FEATURE_NUM_TYPE=int
- * BLD_FEATURE_NUM_TYPE_ID=EJS_TYPE_INT
- */
-
-/**
- * Set to the type used for EJS numeric variables. Will equate to int, int64
- * or double.
- */
-typedef BLD_FEATURE_NUM_TYPE EjsNum;
-
-/**
- * Set to the EJS_TYPE used for EJS numeric variables. Will equate to
- * EJS_TYPE_INT, EJS_TYPE_INT64 or EJS_TYPE_FLOAT.
- */
-#define EJS_NUM_VAR BLD_FEATURE_NUM_TYPE_ID
-#define EJS_TYPE_NUM BLD_FEATURE_NUM_TYPE_ID
-
-/*
- * Return TRUE if a variable is a method type
- */
-#define ejsVarIsMethod(vp) \
- ((vp)->type == EJS_TYPE_METHOD || (vp)->type == EJS_TYPE_STRING_CMETHOD || \
- (vp)->type == EJS_TYPE_CMETHOD)
-
-/*
- * Return TRUE if a variable is a numeric type
- */
-#define ejsVarIsNumber(vp) \
- ((vp)->type == EJS_TYPE_INT || (vp)->type == EJS_TYPE_INT64 || \
- (vp)->type == EJS_TYPE_FLOAT)
-
-/*
- * Return TRUE if a variable is a boolean
- */
-#define ejsVarIsBoolean(vp) \
- ((vp)->type == EJS_TYPE_BOOL)
-
-/*
- * Return TRUE if a variable is an integer type
- */
-#define ejsVarIsInteger(vp) ((vp)->type == EJS_TYPE_INT)
-
-/*
- * Return TRUE if a variable is a string
- */
-#define ejsVarIsString(vp) \
- ((vp)->type == EJS_TYPE_STRING)
-
-/*
- * Return TRUE if a variable is an object
- */
-#define ejsVarIsObject(vp) \
- ((vp)->type == EJS_TYPE_OBJECT)
-
-/*
- * Return TRUE if a variable is a floating number
- */
-#define ejsVarIsFloating(vp) \
- ((vp)->type == EJS_TYPE_FLOAT)
-
-/*
- * Return TRUE if a variable is undefined
- */
-#define ejsVarIsUndefined(var) \
- ((var)->type == EJS_TYPE_UNDEFINED)
-
-/*
- * Return TRUE if a variable is null
- */
-#define ejsVarIsNull(var) \
- ((var)->type == EJS_TYPE_NULL)
-
-/*
- * Return TRUE if a variable is a valid type (not null or undefined)
- */
-#define ejsVarIsValid(var) \
- (((var)->type != EJS_TYPE_NULL) && ((var)->type != EJS_TYPE_UNDEFINED))
-
-/*
- * Return TRUE if a variable is a ptr type
- */
-#define ejsVarIsPtr(vp) \
- ((vp)->type == EJS_TYPE_PTR)
-
-/* MOB -- convert all ep to ejs */
-/**
- * @overview C Method signature
- * @description This is the calling signature for C Methods.
- * @param ejs Ejs reference returned from ejsCreateInterp
- * @param thisObj Reference to the "this" object. (The object containing the
- * method).
- * @param argc Number of arguments.
- * @param argv Array of arguments. Each argument is held in an EjsVar type.
- * @stability Prototype.
- * @library libejs.
- * @see ejsCreateCMethodVar
- */
-typedef int (*EjsCMethod)(struct Ejs *ejs, struct EjsVar *thisObj,
- int argc, struct EjsVar **argv);
-
-/**
- * C Method with string arguments signature
- * @overview C Method with string arguments signature
- * @description This is the calling signature for C Methods.
- * @param ejs Ejs reference returned from ejsCreateInterp
- * @param thisObj Reference to the "this" object (object containing the
- * method.
- * @param argc Number of arguments.
- * @param argv Array of arguments. Each argument is held in an C string
- * pointer.
- * @stability Prototype.
- * @library libejs.
- * @see ejsCreateStringCMethodVar
- */
-typedef int (*EjsStringCMethod)(struct Ejs *ep, struct EjsVar *thisObj,
- int argc, char **argv);
-
-/**
- * Flags for types: EJS_TYPE_CMETHOD, EJS_TYPE_STRING_CMETHOD
- * NOTE: flags == 0 means to use the EJS handle on method callbacks
- */
-/* Use the primary handle on method callbacks */
-#define EJS_PRIMARY_HANDLE 0x1
-
-/* Use the alternate handle on method callbacks */
-#define EJS_ALT_HANDLE 0x2
-
-/** Method should not create a new local variable block */
-#define EJS_NO_LOCAL 0x4
-
-/* Method is a get accessor */
-#define EJS_GET_ACCESSOR 0x8
-
-/* Method is a set accessor */
-#define EJS_SET_ACCESSOR 0x10
-
-/*
- * Flags for E4X (Xml type)
- */
-/* Node is a text node */
-#define EJS_XML_FLAGS_TEXT 0x1
-
-/* Node is a processing instruction */
-#define EJS_XML_FLAGS_PI 0x2
-
-/* Node is a comment */
-#define EJS_XML_FLAGS_COMMENT 0x4
-
-/* Node is an attribute */
-#define EJS_XML_FLAGS_ATTRIBUTE 0x8
-
-/* Node is an element */
-#define EJS_XML_FLAGS_ELEMENT 0x10
-
-/**
- * Copy depth
- * @overview Specifies how an object should be copied
- * @description The EjsCopyDepth type specifies how an object's properties
- * should be copied. Several routines take EjsCopyDepth parameters to
- * control how the properties of an object should be copied. It provides
- * three copy options:
- * @see ejsWriteVar
- */
-typedef enum EjsCopyDepth {
- /**
- * During an object copy, object property references will be copied so
- * that the original object and the copy will share the same reference to
- * a property object. Properties containing primitive types including
- * strings will have their values copied and will not share references.
- */
- EJS_SHALLOW_COPY, /** Copy strings. Copy object references. */
- /*
- * During an object copy, object properties will be replicated so that
- * the original object and the copy will not share references to the same
- * object properties. If the original object's properties are themselves
- * objects, their properties will not be copied. Only their references
- * will be copied. i.e. the deep copy is one level deep.
- */
- EJS_DEEP_COPY, /** Copy strings and copy object contents. */
- /*
- * During an object copy, all object properties will be replicated so that
- * the original object and the copy will not share references to the same
- * object properties. If the original object's properties are themselves
- * objects, their properties will be copied. i.e. the copy is of infinite
- * depth.
- */
- EJS_RECURSIVE_DEEP_COPY /** Copy strings and copy object contents
- recursively (complete copy). */
-} EjsCopyDepth;
-
-
-/*
- * Enumeration flags
- */
-/** Enumerate data properties */
-#define EJS_ENUM_DATA 0x0
-
-/** Enumerate sub classes */
-#define EJS_ENUM_CLASSES 0x1
-
-/** Enumerate non-enumerable properties */
-#define EJS_ENUM_HIDDEN 0x2
-
-/** Enumerate all properties */
-#define EJS_ENUM_ALL (0x3)
-
-/** Magic number when allocated */
-#define EJS_MAGIC 0xe801e2ec
-#define EJS_MAGIC_FREE 0xe701e3ea
-
-
-/*
- * Garbage Collection Linkage. Free list only uses the next pointers.
- */
-typedef struct EjsGCLink {
-#if BLD_DEBUG
- uint magic; /* Magic number */
-#endif
-#if BLD_FEATURE_ALLOC_LEAK_TRACK
- const char *allocatedBy; /* Who allocated this */
-#endif
- struct EjsGCLink *next; /* Next property */
-} EjsGCLink;
-
-
-/**
- * @overview EJS Variable Type
- * @description The EJ language supports an extensive set of primitive types.
- * These variable types can efficiently store primitive data types such as
- * integers, strings, binary string, booleans, floating point numbers,
- * pointer references, and objects. EjsVars are the universal type used by
- * EJ to hold objects, classes and properties.
- * \n\n
- * An EjsVar may store one of the following types:
- * @li Boolean
- * @li Floating point (if supported in this build)
- * @li Integer
- * @li 64 bit integer (if supported in this build)
- * @li String
- * @li Binary string
- * @li C function or C++ method
- * @li C function with string args
- * @li Javascript method
- * @li Object
- * @li Null value.
- * @li Undefined value
- * \n\n
- * Objects can hold object properties which are themselves EJS variables.
- * Properties are hash indexed by the property name and are stored in
- * an ordered sequence. i.e. Order of properties is maintained. Objects may
- * be referenced by multiple variables and they use garbage collection to
- * reclaim memory no longer in use by objects and properties.
- *
- * @warning This module is @e not thread safe for performance and
- * compactness. It relies on upper modules to provide thread
- * synchronization as required. The API provides primitives to get
- * variable/object references or to get copies of variables which should
- * help minimize required lock times.
- * @stability Prototype.
- * @library libejs
- * @see Ejs, EjsProperty, ejsCreateStringVar, ejsFreeVar
- */
-
-typedef struct EjsVar { /* Size 12 bytes */
- /*
- * GC must be first
- */
-#if BLD_DEBUG || BLD_FEATURE_ALLOC_LEAK_TRACK
- EjsGCLink gc; /* Garbage collection links */
-#endif
-
-#if BLD_DEBUG
- const char *propertyName; /* Ptr to property name */
-#endif
-
- /*
- * Union of primitive types. When debugging on Linux, don't use unions
- * as the gdb debugger can't display them.
- */
-#if (!BLD_DEBUG && !VXWORKS) || WIN || BREW_SIMULATOR
- union {
-#endif
- /*
- * For debugging, we order the common types first
- */
- struct EjsObj *objectState; /* Object state information */
- int integer;
- bool boolean;
-
-#if BLD_FEATURE_FLOATING_POINT
- double floating;
-#endif
-#if BLD_FEATURE_INT64
- int64 integer64;
-#endif
-
- struct {
- int length; /* String length (sans null) */
- /*
- * All strings always have a trailing null allocated
- */
- union {
- char *string; /* String */
- uchar *ustring; /* Binary string */
- };
- };
-
- struct { /* Javascript methods */
- MprArray *args; /* Null terminated */
- char *body;
- } method;
-
- struct { /* Method with EjsVar args */
- EjsCMethod fn; /* Method pointer */
- void *userData; /* User data for method */
- } cMethod;
-
- struct { /* Method with string args */
- EjsStringCMethod fn; /* Method pointer */
- void *userData; /* User data for method */
- } cMethodWithStrings;
-
- struct {
- void *userPtr; /* Opaque pointer */
- int (*destructor)(Ejs *ejs, struct EjsVar *vp);
- } ptr;
-
-#if (!BLD_DEBUG && !VXWORKS) || WIN || BREW_SIMULATOR
- };
-#endif
-
- /*
- * Packed bit field (32 bits)
- */
- uint flags : 8; /* Type specific flags */
- EjsType type : 4; /* Selector into union */
- uint stringLen : 4; /* Length of string if inline */
- uint allocatedData : 1; /* Node needs freeing */
- uint isArray : 1; /* Var is an array */
- uint isArrayLength : 1; /* Var is array.length */
- uint callsSuper : 1; /* Method calls super() */
- uint isProperty : 1; /* Part of a property */
- uint reserved : 11; /* Unused */
-
-} EjsVar;
-
-
-/*
- * Linkage for the ordered list of properties
- */
-typedef struct EjsPropLink {
- struct EjsPropLink *next; /* Next property */
- struct EjsPropLink *prev; /* Previous property */
-
- /*
- * To make debugging easier
- */
-#if BLD_DEBUG
- const char *propertyName; /* Pointer to name */
- struct EjsProperty *property; /* Pointer to property */
- struct EjsPropLink *head; /* Dummy head of list */
-#endif
-} EjsPropLink;
-
-
-/**
- * @overview Object Property Type
- * @description The EjsProperty type is used to store all object properties.
- * It contains the property name, property linkage, propery attributes
- * such as public/private, enumerable and readonly settings. It also
- * contains an EjsVar to store the property data value.
- * @stability Prototype.
- * @library libejs
- * @see Ejs, EjsVar
- */
-typedef struct EjsProperty { /* Size 96 bytes in squeeze */
- /*
- * EjsVar must be first. We often take the address of "var" and take
- * advantage of if an EjsProperty is null, then &prop->var will be null
- * also. Be WARNED. External users should use ejsGetVarPtr and
- * ejsGetPropertyPtr to convert between the two.
- */
- EjsVar var; /* Property value */
-
- /* OPT change this to a pointer to the base class property */
- char name[EJS_MAX_ID]; /* Name */
-
- uint visited : 1; /* Has been traversed */
- uint isPrivate : 1; /* Property is private */
- uint isProtected : 1; /* Property is protected */
- uint dontEnumerate : 1; /* Not enumerable */
- uint dontDelete : 1; /* Prevent delete */
- uint readonly : 1; /* Unmodifiable */
- uint allowNonUnique : 1; /* Multiple of same name ok */
- uint delayedDelete : 1;
- uint reserved : 24;
-
- EjsPropLink link; /* Ordered linked list */
- struct EjsProperty *hashNext; /* Hash table linkage */
-
- /* MOB -- is this really required */
- struct EjsObj *parentObj; /* Pointer to parent object */
-
-} EjsProperty;
-
-
-#define EJS_OP_DOT 0x1
-#define EJS_OP_INDEX 0x2
-#define EJS_OP_PLUS 0x3
-#define EJS_OP_MINUS 0x4
-#define EJS_OP_MULTIPLY 0x5
-#define EJS_OP_DIVIDE 0x6
-#define EJS_OP_CALL 0x7
-
-typedef struct EjsOp {
- int opType;
-
-} EjsOp;
-
-/*
- * Propety Access Methods. Used per class.
- * MOB -- rename EjsHelpers
- */
-typedef struct EjsMethods {
-#if FUTURE
- int (*create)(Ejs *ep, EjsVar *thisObj);
- int (*deleteProperty)(Ejs *ep, EjsVar *thisObj, const char *prop);
- EjsVar *(*getProperty)(Ejs *ep, EjsVar *thisObj, const char *prop);
- EjsVar *(*setProperty)(Ejs *ep, EjsVar *thisObj, const char *prop);
- int (*hasProperty)(Ejs *ep, EjsVar *thisObj, const char *prop);
- int (*hasInstance)(Ejs *ep, EjsVar *thisObj, const char *prop);
- int (*operate)(Ejs *ep, EjsVar *thisObj, EjsOp op, EjsVar *result,
- EjsVar *lhs, EjsVar *rhs, int *code);
-#else
-
- EjsVar *(*createProperty)(Ejs *ep, EjsVar *obj, const char *property);
- int (*deleteProperty)(Ejs *ep, EjsVar *obj, const char *property);
- EjsVar *(*getProperty)(Ejs *ep, EjsVar *obj, const char *property);
- EjsVar *(*setProperty)(Ejs *ep, EjsVar *obj, const char *property,
- const EjsVar *value);
- /*
- * Other implemented internal properties in ECMA-262 are:
- *
- * [[Construct]] implemented via EjsVar methods
- * [[Prototype]] implemented via EjsObj->baseClass
- * [[Class]] implemented via EjsObj->baseClass->name
- * [[Value]] Implemented via EjsProperty + EjsVar + EjsObj
- */
-
- /*
- * FUTURE -- not implemented
- */
- int (*canPut)(Ejs *ep, EjsVar *obj, const char *property);
- int (*defaultValue)(Ejs *ep, EjsVar *obj, const char *property,
- const char *hint);
- int (*hasProperty)(Ejs *ep, EjsVar *obj, const char *property);
- EjsVar *(*call)(Ejs *ep, EjsVar *obj, const char *property,
- EjsVar *args);
- int (*hasInstance)(Ejs *ep, EjsVar *obj, const char *property);
- int (*scope)(Ejs *ep, EjsVar *obj, const char *property);
- int (*match)(Ejs *ep, EjsVar *obj, const char *property,
- const char *string, int index);
-#endif
-} EjsMethods;
-
-
-/*
- * Ejs Object Type
- */
-typedef struct EjsObj {
- /*
- * GC must be first
- */
- EjsGCLink gc; /* Garbage collection links */
-
- union {
- char *objName; /* Object name */
- char *className; /* Class name */
- };
-
- struct EjsVar *baseClass; /* Pointer to base class object */
-
- EjsPropLink link; /* Ordered list of properties */
-
- /* OPT -- dynamically allocate this only if required */
- EjsProperty *propertyHash[EJS_OBJ_HASH_SIZE]; /* Hash chains */
-
- /* OPT -- could save this and store off baseClass only */
- EjsMethods *methods; /* Property access methods */
- void *nativeData; /* Native object data */
-
- int (*destructor)(Ejs *ejs, struct EjsVar *vp);
-
- uint numProperties : 16; /* Total count of items */
- uint visited : 1; /* Has been traversed */
- uint gcMarked : 1; /* Node marked in-use by GC */
- uint permanent : 1; /* Permanent object, dont GC */
- uint alive : 1; /* Only GC if alive */
- uint noConstructor : 1; /* Object has no constructor */
- uint dirty : 1; /* Object has been modified */
- uint hasErrors : 1; /* Update error */
- uint preventDeleteProp : 1; /* Don't allow prop deletion */
- uint delayedDeleteProp : 1; /* Delayed delete of props */
- uint reserved : 7; /* Unused */
-
- Ejs *ejs; /* Owning interp */
-
-#if BLD_FEATURE_MULTITHREAD
- MprLock *mutex; /* Advisory mutex lock */
-#endif
-} EjsObj;
-
-
-/*
- * Define a field macro so code an use numbers in a "generic" fashion.
- */
-#if EJS_NUM_VAR == EJS_TYPE_INT || DOXYGEN
-/*
- * Default numeric type
- */
-#define ejsNumber integer
-#endif
-#if EJS_NUM_VAR == EJS_TYPE_INT64
-/* Default numeric type */
-#define ejsNumber integer64
-#endif
-#if EJS_NUM_VAR == EJS_TYPE_FLOAT
-/* Default numeric type */
-#define ejsNumber floating
-#endif
-
-typedef BLD_FEATURE_NUM_TYPE EjsNumber;
-
-/*
- * Memory allocation slabs
- */
-#define EJS_SLAB_OBJ 0
-#define EJS_SLAB_PROPERTY 1
-#define EJS_SLAB_VAR 2
-#define EJS_SLAB_MAX 3
-
-/**
- * Object and pointer property destructory type
- */
-typedef int (*EjsDestructor)(Ejs *ejs, EjsVar *vp);
-
-#if BLD_FEATURE_ALLOC_LEAK_TRACK || DOXYGEN
-/*
- * Line number information args and declarations for ejsAlloc.
- * Use EJS_LOC_ARGS in normal user code.
- * Use EJS_LOC_DEC in declarations.
- * Use EJS_LOC_PASS in layered APIs to pass original line info down.
- */
-#define EJS_LOC_ARGS(ejs) ejs, MPR_LOC
-#define EJS_LOC_DEC(ejs, loc) Ejs *ejs, const char *loc
-#define EJS_LOC_PASS(ejs, loc) ejs, loc
-#else
-#define EJS_LOC_ARGS(ejs) ejs
-#define EJS_LOC_DEC(ejs, loc) Ejs *ejs
-#define EJS_LOC_PASS(ejs, loc) ejs
-#endif
-
-/******************************* Internal Prototypes **************************/
-
-#define ejsInitVar(vp, varType) \
- if (1) { \
- (vp)->type = varType; \
- (vp)->isArray = 0; \
- (vp)->flags = 0; \
- } else
-extern void ejsClearVar(Ejs *ep, EjsVar *vp);
-
-extern int ejsDestroyObj(Ejs *ep, EjsObj *obj);
-extern EjsVar *ejsCreatePropertyMethod(Ejs *ep, EjsVar *obj,
- const char *name);
-extern EjsVar *ejsSetPropertyMethod(Ejs *ep, EjsVar *obj, const char *name,
- const EjsVar *value);
-extern EjsVar *ejsGetPropertyMethod(Ejs *ep, EjsVar *obj, const char *name);
-extern int ejsDeletePropertyMethod(Ejs *ep, EjsVar *obj,
- const char *name);
-extern void ejsSetArrayLength(Ejs *ep, EjsVar *obj, const char *creating,
- const char *deleting, const EjsVar *setLength);
-
-/*
- * At the moment, these are the same routine
- */
-extern void ejsSetClassName(Ejs *ep, EjsVar *obj, const char *name);
-#define ejsSetObjName ejsSetObjName
-
-extern bool ejsIsObjDirty(EjsVar *vp);
-extern void ejsResetObjDirtyBit(EjsVar *vp);
-
-extern int ejsObjHasErrors(EjsVar *vp);
-extern void ejsClearObjErrors(EjsVar *vp);
-
-extern EjsVar *ejsClearProperty(Ejs *ep, EjsVar *obj, const char *prop);
-
-typedef int (*EjsSortFn)(Ejs *ep, EjsProperty *p1, EjsProperty *p2,
- const char *propertyName, int order);
-extern void ejsSortProperties(Ejs *ep, EjsVar *obj, EjsSortFn fn,
- const char *propertyName, int order);
-
-#if BLD_DEBUG
-#define ejsSetVarName(ep, vp, varName) \
- if (1) { \
- (vp)->propertyName = varName; \
- if ((vp)->type == EJS_TYPE_OBJECT && \
- (vp)->objectState && \
- ((vp)->objectState->objName == 0)) { \
- (vp)->objectState->objName = \
- mprStrdup(ep, varName); \
- } \
- } else
-#else
-#define ejsSetVarName(ep, vp, varName)
-#endif
-
-EjsVar *ejsFindProperty(Ejs *ep, EjsVar **obj, char **property,
- EjsVar *global, EjsVar *local, const char *fullName,
- int create);
-
-extern EjsVar *ejsCopyProperties(Ejs *ep, EjsVar *dest,
- const EjsVar *src, EjsCopyDepth copyDepth);
-
-#define EJS_LINK_OFFSET ((uint) (&((EjsProperty*) 0)->link))
-#define ejsGetPropertyFromLink(lp) \
- ((EjsProperty*) ((char*) lp - EJS_LINK_OFFSET))
-
-#define ejsGetObjPtr(vp) ((EjsObj*) vp->objectState)
-
-extern void ejsMakePropertyPrivate(EjsProperty *pp, int isPrivate);
-extern void ejsMakePropertyReadOnly(EjsProperty *pp, int readonly);
-extern void ejsMakePropertyUndeleteable(EjsProperty *pp, int deletable);
-extern int ejsMakeObjLive(EjsVar *vp, bool alive);
-extern void ejsMakeClassNoConstructor(EjsVar *vp);
-
-extern bool ejsBlockInUseInt(EjsVar *vp);
-#if BLD_DEBUG
- #define ejsBlockInUse(vp) ejsBlockInUseInt(vp)
-#else
- #define ejsBlockInUse(vp)
-#endif
-
-/********************************* Prototypes *********************************/
-
-/*
- * Variable constructors and destructors
- */
-extern EjsVar *ejsCreateBinaryStringVar(Ejs *ep, const uchar *value,
- int len);
-extern EjsVar *ejsCreateBoolVar(Ejs *ep, int value);
-extern EjsVar *ejsCreateCMethodVar(Ejs *ep, EjsCMethod fn,
- void *userData, int flags);
-#if BLD_FEATURE_FLOATING_POINT
-extern EjsVar *ejsCreateFloatVar(Ejs *ep, double value);
-#endif
-extern EjsVar *ejsCreateIntegerVar(Ejs *ep, int value);
-#if BLD_FEATURE_INT64
-extern EjsVar *ejsCreateInteger64Var(Ejs *ep, int64 value);
-#endif
-
-extern EjsVar *ejsCreateMethodVar(Ejs *ep, const char *body,
- MprArray *args, int flags);
-extern EjsVar *ejsCreateNullVar(Ejs *ep);
-extern EjsVar *ejsCreateNumberVar(Ejs *ep, EjsNumber value);
-
-#define ejsCreateObjVar(ep) \
- ejsCreateObjVarInternal(EJS_LOC_ARGS(ep))
-extern EjsVar *ejsCreateObjVarInternal(EJS_LOC_DEC(ep, loc));
-
-extern EjsVar *ejsCreatePtrVar(Ejs *ep, void *ptr, EjsDestructor dest);
-
-extern EjsVar *ejsCreateStringCMethodVar(Ejs *ep, EjsStringCMethod fn,
- void *userData, int flags);
-
-#define ejsCreateStringVar(ep, value) \
- ejsCreateStringVarInternal(EJS_LOC_ARGS(ep), value)
-extern EjsVar *ejsCreateStringVarInternal(EJS_LOC_DEC(ep, loc),
- const char *value);
-
-extern EjsVar *ejsCreateUndefinedVar(Ejs *ep);
-
-/* MOB -- naming. Should be Create/Destroy */
-extern void ejsFreeVar(Ejs *ep, EjsVar *vp);
-
-/*
- * Var support routines
- */
-extern int ejsGetVarFlags(EjsVar *vp);
-extern void ejsSetVarFlags(EjsVar *obj, int flags);
-
-extern EjsType ejsGetVarType(EjsVar *vp);
-extern const char *ejsGetVarTypeAsString(EjsVar *vp);
-
-extern void *ejsGetCMethodUserData(EjsVar *obj);
-extern void ejsSetCMethodUserData(EjsVar *obj, void *userData);
-
-extern void *ejsGetVarUserPtr(EjsVar *vp);
-extern void ejsSetVarUserPtr(EjsVar *vp, void *data);
-
-
-/*
- * Variable access and manipulation. These work on standalone objects.
- */
-#define ejsDupVar(ep, src, copyDepth) \
- ejsDupVarInternal(EJS_LOC_ARGS(ep), src, copyDepth)
-extern EjsVar *ejsDupVarInternal(EJS_LOC_DEC(ep, loc), EjsVar *src,
- EjsCopyDepth copyDepth);
-#define ejsWriteVar(ep, dest, src, copyDepth) \
- ejsWriteVarInternal(EJS_LOC_ARGS(ep), dest, src, copyDepth)
-extern EjsVar *ejsWriteVarInternal(EJS_LOC_DEC(ep, loc), EjsVar *dest,
- const EjsVar *src, EjsCopyDepth copyDepth);
-extern EjsVar *ejsWriteVarAsBinaryString(Ejs *ep, EjsVar *dest,
- const uchar *value, int len);
-extern EjsVar *ejsWriteVarAsBoolean(Ejs *ep, EjsVar *dest, bool value);
-extern EjsVar *ejsWriteVarAsCMethod(Ejs *ep, EjsVar *dest, EjsCMethod fn,
- void *userData, int flags);
-#if BLD_FEATURE_FLOATING_POINT
-extern EjsVar *ejsWriteVarAsFloat(Ejs *ep, EjsVar *dest, double value);
-#endif
-extern EjsVar *ejsWriteVarAsInteger(Ejs *ep, EjsVar *dest, int value);
-#if BLD_FEATURE_INT64
-extern EjsVar *ejsWriteVarAsInteger64(Ejs *ep, EjsVar *dest, int64 value);
-#endif
-extern EjsVar *ejsWriteVarAsMethod(Ejs *ep, EjsVar *dest,
- const char *body, MprArray *args);
-extern EjsVar *ejsWriteVarAsNull(Ejs *ep, EjsVar *dest);
-extern EjsVar *ejsWriteVarAsNumber(Ejs *ep, EjsVar *dest, EjsNum value);
-#define ejsWriteVarAsString(ep, dest, value) \
- ejsWriteVarAsStringInternal(EJS_LOC_ARGS(ep), dest, value)
-extern EjsVar *ejsWriteVarAsStringInternal(EJS_LOC_DEC(ep, loc),
- EjsVar *dest, const char *value);
-extern EjsVar *ejsWriteVarAsStringCMethod(Ejs *ep, EjsVar *dest,
- EjsStringCMethod fn, void *userData, int flags);
-extern EjsVar *ejsWriteVarAsUndefined(Ejs *ep, EjsVar *dest);
-
-/*
- * These routines do not convert types
- */
-/* MOB -- make this a fn and pass back the length as an arg */
-#define ejsReadVarAsBinaryString(vp) ((const uchar*) (vp->ustring));
-#define ejsReadVarAsBoolean(vp) (vp->boolean);
-#define ejsReadVarAsCMethod(vp) (vp->cMethod);
-#if BLD_FEATURE_FLOATING_POINT
-#define ejsReadVarAsFloat(vp) (vp->floating);
-#endif
-#define ejsReadVarAsInteger(vp) (vp->integer);
-#if BLD_FEATURE_INT64
-#define ejsReadVarAsInteger64(vp) (vp->int64);
-#endif
-#define ejsReadVarAsString(vp) ((const char*) (vp->string));
-#define ejsReadVarAsStringCMethod(vp) (vp->cMethodWithStrings);
-/* MOB -- remove this fn */
-#define ejsReadVarStringLength(vp) (vp->length);
-
-/*
- * Object property creation routines
- */
-extern EjsProperty *ejsCreateProperty(Ejs *ep, EjsVar *obj, const char *prop);
-extern EjsProperty *ejsCreateSimpleProperty(Ejs *ep, EjsVar *obj,
- const char *prop);
-extern EjsProperty *ejsCreateSimpleNonUniqueProperty(Ejs *ep, EjsVar *obj,
- const char *prop);
-/* MOB -- should be destroy */
-extern int ejsDeleteProperty(Ejs *ep, EjsVar *obj, const char *prop);
-
-
-/*
- * Get property routines
- */
-extern EjsProperty *ejsGetProperty(Ejs *ep, EjsVar *obj, const char *prop);
-extern EjsProperty *ejsGetSimpleProperty(Ejs *ep, EjsVar *obj,
- const char *prop);
-
-extern EjsVar *ejsGetPropertyAsVar(Ejs *ep, EjsVar *obj,
- const char *prop);
-extern int ejsGetPropertyCount(EjsVar *obj);
-
-extern const uchar *ejsGetPropertyAsBinaryString(Ejs *ep, EjsVar *obj,
- const char *prop, int *length);
-extern bool ejsGetPropertyAsBoolean(Ejs *ep, EjsVar *obj,
- const char *prop);
-extern int ejsGetPropertyAsInteger(Ejs *ep, EjsVar *obj,
- const char *prop);
-extern int64 ejsGetPropertyAsInteger64(Ejs *ep, EjsVar *obj,
- const char *prop);
-extern EjsNum ejsGetPropertyAsNumber(Ejs *ep, EjsVar *obj,
- const char *prop);
-extern void *ejsGetPropertyAsPtr(Ejs *ep, EjsVar *obj,
- const char *prop);
-extern const char *ejsGetPropertyAsString(Ejs *ep, EjsVar *obj,
- const char *prop);
-
-/*
- * Object property update routines
- */
-extern EjsProperty *ejsSetBaseProperty(Ejs *ep, EjsVar *obj, const char *prop,
- const EjsVar *value);
-extern EjsProperty *ejsSetProperty(Ejs *ep, EjsVar *obj, const char *prop,
- const EjsVar *value);
-extern EjsProperty *ejsSetPropertyAndFree(Ejs *ep, EjsVar *obj,
- const char *prop, EjsVar *value);
-extern EjsProperty *ejsSetPropertyToBinaryString(Ejs *ep, EjsVar *obj,
- const char *prop, const uchar *value, int len);
-extern EjsProperty *ejsSetPropertyToBoolean(Ejs *ep, EjsVar *obj,
- const char *prop, bool value);
-extern EjsProperty *ejsSetPropertyToCMethod(Ejs *ep, EjsVar *obj,
- const char *prop, EjsCMethod fn, void *userData,
- int flags);
-#if BLD_FEATURE_FLOATING_POINT
-extern EjsProperty *ejsSetPropertyToFloat(Ejs *ep, EjsVar *obj,
- const char *prop, double value);
-#endif
-extern EjsProperty *ejsSetPropertyToInteger(Ejs *ep, EjsVar *obj,
- const char *prop, int value);
-#if BLD_FEATURE_INT64
-extern EjsProperty *ejsSetPropertyToInteger64(Ejs *ep, EjsVar *obj,
- const char *prop, int64 value);
-#endif
-extern EjsProperty *ejsSetPropertyToMethod(Ejs *ep, EjsVar *obj,
- const char *prop, const char *body, MprArray *args,
- int flags);
-extern EjsProperty *ejsSetPropertyToNewObj(Ejs *ep, EjsVar *obj,
- const char *prop, const char *className,
- MprArray *args);
-extern EjsProperty *ejsSetPropertyToNull(Ejs *ep, EjsVar *obj,
- const char *prop);
-extern EjsProperty *ejsSetPropertyToNumber(Ejs *ep, EjsVar *obj,
- const char *prop, EjsNum value);
-extern EjsProperty *ejsSetPropertyToObj(Ejs *ep, EjsVar *obj,
- const char *prop);
-extern EjsProperty *ejsSetPropertyToPtr(Ejs *ep, EjsVar *obj,
- const char *prop, void *ptr, EjsDestructor destructor);
-
-extern EjsProperty *ejsSetPropertyToStringCMethod(Ejs *ep, EjsVar *obj,
- const char *prop, EjsStringCMethod fn,
- void *userData, int flags);
-extern EjsProperty *ejsSetPropertyToString(Ejs *ep, EjsVar *obj,
- const char *prop, const char *value);
-extern EjsProperty *ejsSetPropertyToUndefined(Ejs *ep, EjsVar *obj,
- const char *prop);
-
-
-/* Convenience function */
-extern EjsVar *ejsSetPropertyToObjAsVar(Ejs *ep, EjsVar *obj,
- const char *prop);
-extern void ejsSetObjDestructor(Ejs *ep, EjsVar *obj,
- EjsDestructor destructor);
-extern void ejsClearObjDestructor(Ejs *ep, EjsVar *obj);
-
-/*
- * Enumeration of properties
- * MOB -- should these take an ejs parameter to be consistent
- */
-extern EjsProperty *ejsGetFirstProperty(const EjsVar *obj, int flags);
-extern EjsProperty *ejsGetNextProperty(EjsProperty *last, int flags);
-
-/*
- * Method definition and control.
- */
-extern EjsProperty *ejsDefineMethod(Ejs *ep, EjsVar *obj, const char *prop,
- const char *body, MprArray *args);
-extern EjsProperty *ejsDefineCMethod(Ejs *ep, EjsVar *obj, const char *prop,
- EjsCMethod fn, int flags);
-
-extern EjsProperty *ejsDefineStringCMethod(Ejs *ep, EjsVar *obj,
- const char *prop, EjsStringCMethod fn, int flags);
-
-extern EjsProperty *ejsDefineAccessors(Ejs *ep, EjsVar *obj,
- const char *prop, const char *getBody,
- const char *setBody);
-extern EjsProperty *ejsDefineCAccessors(Ejs *ep, EjsVar *obj,
- const char *prop, EjsCMethod getFn, EjsCMethod setFn,
- int flags);
-
-/*
- * Macro to get the variable value portion of a property
- */
-#define ejsGetVarPtr(pp) (&((pp)->var))
-#define ejsGetPropertyPtr(vp) ((EjsProperty*) vp)
-
-/* MOB -- take ejs to be consistent */
-extern int ejsMakePropertyEnumerable(EjsProperty *pp, bool enumerable);
-extern int ejsMakeObjPermanent(EjsVar *vp, bool permanent);
-
-
-/*
- * Var conversion routines
- * MOB -- should these take an Ejs as first arg for consistency
- */
-extern bool ejsVarToBoolean(EjsVar *vp);
-#if BLD_FEATURE_FLOATING_POINT
-extern double ejsVarToFloat(EjsVar *vp);
-#endif
-extern int ejsVarToInteger(EjsVar *vp);
-#if BLD_FEATURE_INT64
-extern int64 ejsVarToInteger64(EjsVar *vp);
-#endif
-extern EjsNum ejsVarToNumber(EjsVar *vp);
-extern char *ejsVarToString(Ejs *ep, EjsVar *vp);
-extern char *ejsVarToStringEx(Ejs *ep, EjsVar *vp, bool *alloc);
-extern char *ejsFormatVar(Ejs *ep, const char *fmt, EjsVar *vp);
-
-#if BLD_FEATURE_FLOATING_POINT
-extern double ejsParseFloat(const char *str);
-#endif
-/*
- * Parsing and type range checking routines
- */
-extern bool ejsParseBoolean(const char *str);
-extern int ejsParseInteger(const char *str);
-#if BLD_FEATURE_INT64
-extern int64 ejsParseInteger64(const char *str);
-#endif
-extern EjsNum ejsParseNumber(const char *str);
-extern EjsVar *ejsParseVar(Ejs *ep, const char *str, EjsType prefType);
-
-#if BLD_FEATURE_FLOATING_POINT
-extern bool ejsIsInfinite(double f);
-extern bool ejsIsNan(double f);
-#endif
-
-/*
- * Advisory locking support
- */
-#if BLD_FEATURE_MULTITHREAD
-extern void ejsLockObj(EjsVar *vp);
-extern void ejsUnlockObj(EjsVar *vp);
-#endif
-
-/*
- * Just for debugging
- */
-extern bool ejsObjIsCollectable(EjsVar *vp);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*****************************************************************************/
-#endif /* _h_EJS_VAR */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/lib/event.js b/source4/lib/appweb/ejs-2.0/ejs/lib/event.js
deleted file mode 100644
index 283a3ec72f..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/lib/event.js
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * @file event.js
- * @brief Event class
- * @copy Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved.
- *
- * Usage:
- * listener = new System.Listener();
- * listener.onClick = function() {
- * // Any code here
- * }
- * eventTarget.addListener(eventName, listener);
- * or
- * listener = new System.Listener(obj, method);
- * eventTarget.addListener(eventName, listener);
- *
- * To fire events:
- * eventTarget.fire(eventName, new System.Event("My Event"));
- */
-
-/******************************************************************************/
-/*
- * Base event class
- */
-class System.Event
-{
- var type; // keyboard
- var timeStamp;
- var arg;
-
- /* MOB -- constructor should take a type */
- function Event(arg)
- {
- timeStamp = time();
- type = "default";
- this.arg = arg;
- }
-}
-
-/* MOB -- should not be needed */
-Event = System.Event;
-
-class System.Listener
-{
- var obj;
- var method;
-
- function Listener(obj, method)
- {
- if (arguments.length >= 1) {
- this.obj = obj;
- } else {
- this.obj = this;
- }
- if (arguments.length == 2) {
- this.method = method;
- } else {
- this.method = "onEvent";
- }
- }
-}
-/* MOB -- should not be needed */
-Listener = System.Listener;
-
-
-/*
- * The Event target class
- */
-class System.EventTarget
-{
- // Private
- var events; /* Hash of a event names */
-
- function EventTarget()
- {
- events = new Object();
- }
-
- // Public
- function addListener(eventName, listener)
- {
- var listeners = events[eventName];
- if (listeners == undefined) {
- listeners = events[eventName] = new Array();
- }
- if (arguments.length == 2) {
- var method = eventName;
- }
- /* MOB OPT */
- for (var i = 0; i < listeners.length; i++) {
- var l = listeners[i];
- if (l == listener) {
- return;
- }
- }
- listeners[listeners.length] = listener;
- }
-
- function removeListener(eventName, listener)
- {
- var listeners = events[eventName];
-
- if (listeners == undefined) {
- return;
- }
-
- for (var i = 0; i < listeners.length; i++) {
- var l = listeners[i];
- if (l == listener) {
- // MOB -- want listeners.splice here
- // listeners.splice(i, 1);
- for (var j = i; j < (listeners.length - 1); j++) {
- listeners[j] = listeners[j + 1];
- }
- delete listeners[listeners.length - 1];
- i = listeners.length;
- }
- }
- }
-
- function fire(eventName, event)
- {
- var listeners = events[eventName];
-
- if (listeners == undefined) {
- // println("Event.fire(): unknown eventName " + eventName);
- return;
- }
-
- for (var i = listeners.length - 1; i >= 0; i--) {
- var listener = listeners[i];
- var method = listener.obj[listener.method];
- if (method == undefined) {
- throw new EvalError("Undefined method: " + listener.method);
- }
- listener.obj[listener.method](listener, event);
- }
- }
-}
-
-/* MOB -- should not be needed */
-EventTarget = System.EventTarget;
diff --git a/source4/lib/appweb/ejs-2.0/ejs/lib/global.js b/source4/lib/appweb/ejs-2.0/ejs/lib/global.js
deleted file mode 100644
index f2daaa57c0..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/lib/global.js
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * @file global.js
- * @brief Misc global functions
- * @copy Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved.
- */
-
-/******************************************************************************/
-
-function min(a, b)
-{
- if (a < b) {
- return a;
- } else {
- return b;
- }
-}
-
-
-function max(a, b)
-{
- if (a > b) {
- return a;
- } else {
- return b;
- }
-}
-
-function abs(a)
-{
- if (a < 0) {
- return -a;
- }
- return a;
-}
diff --git a/source4/lib/appweb/ejs-2.0/ejs/lib/startup.js b/source4/lib/appweb/ejs-2.0/ejs/lib/startup.js
deleted file mode 100644
index e627a96e04..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/lib/startup.js
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * @file startup.js
- * @brief Embedded JavaScript Startup Code
- * @copy Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved.
- *
- * Invoked automatically on startup.
- */
-
-/******************************************************************************/
-
-// println("Loading startup.js ...");
-
-include("lib/event.js");
-include("lib/global.js");
-include("lib/timer.js");
diff --git a/source4/lib/appweb/ejs-2.0/ejs/lib/timer.js b/source4/lib/appweb/ejs-2.0/ejs/lib/timer.js
deleted file mode 100644
index f4cb8b12ce..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/lib/timer.js
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * @file timer.js
- * @brief Timer class
- * @copy Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved.
- *
- * Usage:
- * timer = new System.Timer("name", period);
- * timer.onTick = function(arg) {
- * // Anything here
- * }
- * timer.start();
- * or
- *
- * timer = new System.Timer("name", period, obj, method);
- * timer.start();
- */
-
-/******************************************************************************/
-
-class System.Timer
-{
- var id;
-
- /* MOB -- really need accessor on period. If user updates period,
- then due must be updated. */
- var period;
- var due;
- var runOnce; // Run timer just once
- var method; // Callback method
- var obj; // Callback object
-
- function Timer(id, period, obj, method)
- {
- this.id = id;
- this.period = period;
- due = time() + period;
-
- if (arguments.length >= 3) {
- this.obj = obj;
- } else {
- this.obj = this;
- }
- if (arguments.length >= 4) {
- this.method = method;
- } else {
- this.method = "onTick";
- }
- }
-
- /* MOB this should be deprecated */
- function reschedule(period)
- {
- /* MOB -- should update the timer service somehow */
- this.period = period;
- }
-
- function run(now)
- {
- if (obj[method] == undefined) {
- trace("Timer cant find timer method " + method);
- due = now + this.period;
- return;
- }
-
- /*
- * Run the timer
- */
- try {
- obj[method](this);
- }
- catch (error) {
- trace("Timer exception: " + error);
- }
-
- if (runOnce) {
- timerService.removeTimer(this);
-
- } else {
- due = now + this.period;
- }
- }
-
- function start()
- {
- if (obj[method] == undefined) {
- throw new Error("Callback method is undefined");
- } else {
- timerService.addTimer(this);
- }
- }
-
- function stop()
- {
- timerService.removeTimer(this);
- }
-
-}
-
-/* MOB -- should not need this */
-Timer = System.Timer;
-
-
-/*
- * Timer service
- */
-class System.TimerService
-{
- var timers;
- var nextDue;
-
- function TimerService()
- {
- timers = new Object();
- nextDue = 0;
- global.timerService = this;
- }
-
- function addTimer(timer)
- {
- timers[timer.id] = timer;
- }
-
- function removeTimer(timer)
- {
- try {
- delete timers[timer.id];
- }
- catch {}
- }
-
- function getIdleTime()
- {
- return nextDue - time();
- }
-
- function runTimers()
- {
- var now = time();
-
- nextDue = 2147483647; /* MOB -- MATH.MAX_INT; */
-
- for each (var timer in timers)
- {
- if (timer.due < now) {
- timer.run(now);
- }
- }
- for each (var timer in timers)
- {
- if (timer.due < nextDue) {
- nextDue = timer.due;
- }
- }
- // println("runTimers leaving with " + (nextDue - now));
- return nextDue - time();
- }
-}
-TimerService = System.TimerService;
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/.ignore b/source4/lib/appweb/ejs-2.0/ejs/system/.ignore
deleted file mode 100755
index fb5a29031e..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/.ignore
+++ /dev/null
@@ -1 +0,0 @@
-.updated
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/Makefile b/source4/lib/appweb/ejs-2.0/ejs/system/Makefile
deleted file mode 100755
index 2d83662655..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Makefile to build the EJS Object Model
-#
-# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
-#
-
-COMPILE := *.c
-EXPORT_OBJECTS := yes
-MAKE_IFLAGS := -I.. -I../../mpr -I../../exml
-
-include make.dep
-
-ifeq ($(BLD_HOST_UNIX),1)
-PRE_DIRS = UNIX
-else
-PRE_DIRS = $(BLD_HOST_OS)
-endif
-
-compileExtra: .updated
-
-.updated: $(FILES)
- @touch .updated
-
-## Local variables:
-## tab-width: 4
-## End:
-## vim: tw=78 sw=4 ts=4
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/README.TXT b/source4/lib/appweb/ejs-2.0/ejs/system/README.TXT
deleted file mode 100644
index a24e0e299c..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/README.TXT
+++ /dev/null
@@ -1,63 +0,0 @@
-Embedded JavaScript System Model
-
-
-- Need args, arg types and exceptions thrown
-- Error classes
-
-class Global
- class System
- class environment
- var
- class GC
- void function run()
- function tune()
- function getUsedMemory() // Should be properties
- function getAllocatedMemory() // Should be properties
-
- var javascript
- var null
- var undefined
- var true
- var false
- var Nan
- var Infinity
-
- function random // Not implemented
- function sleep // Not implemented
- function exit
- function yield // Not implemented
-
- Debug
- isDebugMode
-
- Limits
- isLimitsMode // Not implemented
- stack // Not implemented
- heap // Not implemented
- flash // Not implemented
-
- Memory
- getUsedMemory() // Should be properties
- getAvailableMemory() // Should be properties
- used
- flash // Not implemented
-
- assert()
- breakpoint()
- dirname()
- basename()
- eval()
- exit()
- print()
- println()
- printVars()
- sleep()
- sort()
- time()
- typeof()
- include()
- trace()
- printf() // Not implemented
- sprintf()
-
-
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/.ignore b/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/.ignore
deleted file mode 100644
index fb5a29031e..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/.ignore
+++ /dev/null
@@ -1 +0,0 @@
-.updated
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/Makefile b/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/Makefile
deleted file mode 100755
index 424747052a..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Makefile to build the EJS Object Model for WIN
-#
-# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
-#
-
-COMPILE := *.c
-EXPORT_OBJECTS := yes
-MAKE_IFLAGS := -I../.. -I../../../mpr
-
-include make.dep
-
-compileExtra: .updated
-
-.updated: $(FILES)
- @touch .updated
-
-## Local variables:
-## tab-width: 4
-## End:
-## vim: tw=78 sw=4 ts=4
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsFile.c b/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsFile.c
deleted file mode 100644
index 772303152e..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsFile.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * @file ejsFile.c
- * @brief File class for the EJ System Object Model
- */
-/********************************** Copyright *********************************/
-/*
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-/******************************************************************************/
-/*
- * Default Constructor
- */
-
-/******************************************************************************/
-/************************************ Methods *********************************/
-/******************************************************************************/
-/*
- * function open();
- */
-
-static int openProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsTrace(ep, "File.open()\n");
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function close();
- */
-
-static int closeProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsTrace(ep, "File.close()\n");
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function read();
- */
-
-static int readProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsTrace(ep, "File.read()\n");
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function write();
- */
-
-static int writeProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsTrace(ep, "File.write()\n");
- return 0;
-}
-
-/******************************************************************************/
-/******************************** Initialization ******************************/
-/******************************************************************************/
-
-int ejsDefineFileClass(Ejs *ep)
-{
- EjsVar *fileClass;
-
- fileClass = ejsDefineClass(ep, "File", "Object", 0);
- if (fileClass == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
-
- /*
- * Define the methods
- */
- ejsDefineCMethod(ep, fileClass, "open", openProc, 0);
- ejsDefineCMethod(ep, fileClass, "close", closeProc, 0);
- ejsDefineCMethod(ep, fileClass, "read", readProc, 0);
- ejsDefineCMethod(ep, fileClass, "write", writeProc, 0);
-
- return ejsObjHasErrors(fileClass) ? MPR_ERR_CANT_INITIALIZE: 0;
-}
-
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsFileSystem.c b/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsFileSystem.c
deleted file mode 100755
index 7b39c16e4d..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsFileSystem.c
+++ /dev/null
@@ -1,454 +0,0 @@
-/*
- * @file ejsFileSystem.c
- * @brief FileSystem class for the EJ System Object Model
- * MOB -- this is almost the same as for Windows. Should common up.
- */
-/********************************** Copyright *********************************/
-/*
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-#include <dirent.h>
-
-/******************************************************************************/
-/************************************ Methods *********************************/
-/******************************************************************************/
-/*
- * function void access(string path);
- * MOB - API insufficient. Access for read or write?
- */
-
-static int accessProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- int rc;
-
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: access(path)");
- return -1;
- }
-
- rc = access(argv[0]->string, 04);
-
- ejsSetReturnValueToBoolean(ejs, (rc == 0) ? 1 : 0);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function void mkdir(string path);
- */
-
-static int mkdirProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: mkdir(path)");
- return -1;
- }
-
- if (mprMakeDirPath(ejs, argv[0]->string) < 0) {
- ejsError(ejs, EJS_IO_ERROR, "Cant create directory");
- return -1;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function void rmdir(string path);
- */
-
-static int rmdirProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- int rc;
-
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: mkdir(path)");
- return -1;
- }
-
- rc = mprDeleteDir(ejs, argv[0]->string);
-
- if (rc < 0) {
- ejsError(ejs, EJS_IO_ERROR, "Cant remove directory");
- return -1;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function void dirList(string path, [bool enumDirs]);
- * MOB -- need pattern to match (what about "." and ".." and ".*"
- */
-
-static int dirListProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- DIR *dir;
- struct dirent *dirent;
- char path[MPR_MAX_FNAME];
- EjsVar *array, *vp;
- uchar enumDirs;
-
- if (argc < 1 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: dirList(path)");
- return -1;
- }
- if (argc == 2) {
- enumDirs = ejsVarToBoolean(argv[1]);
- } else {
- enumDirs = 0;
- }
- array = ejsCreateArray(ejs, 0);
- ejsMakeObjPermanent(array, 1);
-
- /*
- * First collect the files
- */
- mprSprintf(path, sizeof(path), "%s/*.*", argv[0]->string);
-
- dir = opendir(path);
- if (dir == 0) {
- ejsError(ejs, EJS_ARG_ERROR, "Can't enumerate dirList(path)");
- return -1;
- }
-
- while ((dirent = readdir(dir)) != 0) {
- if (dirent->d_name[0] == '.') {
- continue;
- }
- if (!enumDirs || (dirent->d_type & DT_DIR)) {
- mprSprintf(path, sizeof(path), "%s/%s", argv[0]->string,
- dirent->d_name);
- vp = ejsCreateStringVar(ejs, path);
- ejsAddArrayElt(ejs, array, vp, EJS_SHALLOW_COPY);
- ejsFreeVar(ejs, vp);
- }
- }
-
- closedir(dir);
-
- ejsSetReturnValue(ejs, array);
- ejsMakeObjPermanent(array, 0);
-
- /*
- * Can free now as the return value holds the reference
- */
- ejsFreeVar(ejs, array);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function void getFreeSpace();
- */
-
-static int getFreeSpaceProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
-#if UNUSED
- MprApp *app;
- uint space;
-
- app = mprGetApp(ejs);
- space = IFILEMGR_GetFreeSpace(app->fileMgr, 0);
- ejsSetReturnValueToInteger(ejs, space);
-#endif
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function void writeFile(string path, var data);
- */
-
-static int writeFileProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- MprFile *file;
- char *data, *buf;
- int bytes, length, rc;
-
- if (argc != 2 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: writeFile(path, var)");
- return -1;
- }
-
- if (ejsVarIsString(argv[1])) {
- data = argv[1]->string;
- length = argv[1]->length;
- buf = 0;
- } else {
- buf = data = ejsVarToString(ejs, argv[1]);
- length = strlen(data);
- }
-
- /*
- * Create fails if already present
- */
- rc = mprDelete(ejs, argv[0]->string);
- file = mprOpen(ejs, argv[0]->string, O_CREAT | O_WRONLY | O_BINARY, 0664);
- if (file == 0) {
- ejsError(ejs, EJS_IO_ERROR, "Cant create %s", argv[0]->string);
- mprFree(buf);
- return -1;
- }
-
- rc = 0;
- bytes = mprWrite(file, data, length);
- if (bytes != length) {
- ejsError(ejs, EJS_IO_ERROR, "Write error to %s", argv[1]->string);
- rc = -1;
- }
-
- mprClose(file);
-
- mprFree(buf);
- return rc;
-}
-
-/******************************************************************************/
-/*
- * function string readFile(string path);
- */
-
-static int readFileProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- MprApp *app;
- MprFile *file;
- MprBuf *buf;
- char *data;
- int bytes, rc;
-
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: readFile(path)");
- return -1;
- }
- buf = mprCreateBuf(ejs, MPR_BUF_INCR, MPR_MAX_BUF);
- if (buf == 0) {
- ejsMemoryError(ejs);
- return -1;
- }
-
- data = mprAlloc(ejs, MPR_BUFSIZE);
- if (buf == 0) {
- mprFree(buf);
- ejsMemoryError(ejs);
- return -1;
- }
-
- app = mprGetApp(ejs);
- file = mprOpen(ejs, argv[0]->string, O_RDONLY, 0664);
- if (file == 0) {
- ejsError(ejs, EJS_IO_ERROR, "Cant open %s", argv[0]->string);
- mprFree(buf);
- return -1;
- }
-
- rc = 0;
- while ((bytes = mprRead(file, data, MPR_BUFSIZE)) > 0) {
- if (mprPutBlockToBuf(buf, data, bytes) != bytes) {
- ejsError(ejs, EJS_IO_ERROR, "Write error to %s", argv[1]->string);
- rc = -1;
- break;
- }
- }
-
- ejsSetReturnValueToBinaryString(ejs, (uchar*) mprGetBufStart(buf),
- mprGetBufLength(buf));
-
- mprClose(file);
- mprFree(data);
- mprFree(buf);
-
- return rc;
-}
-
-/******************************************************************************/
-/*
- * function void remove(string path);
- */
-
-static int removeProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- int rc;
-
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: remove(path)");
- return -1;
- }
-
- rc = unlink(argv[0]->string);
- if (rc < 0) {
- ejsError(ejs, EJS_IO_ERROR, "Cant remove file");
- return -1;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function void rename(string from, string to);
- */
-
-static int renameProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- int rc;
-
- if (argc != 2 || !ejsVarIsString(argv[0]) || !ejsVarIsString(argv[1])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: rename(old, new)");
- return -1;
- }
-
- unlink(argv[1]->string);
- rc = rename(argv[0]->string, argv[1]->string);
- if (rc < 0) {
- ejsError(ejs, EJS_IO_ERROR, "Cant rename file");
- return -1;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function void copy(string old, string new);
- */
-
-static int copyProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- MprFile *from, *to;
- char *buf;
- uint bytes;
- int rc;
-
- if (argc != 2 || !ejsVarIsString(argv[0]) || !ejsVarIsString(argv[1])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: copy(old, new)");
- return -1;
- }
-
- buf = mprAlloc(ejs, MPR_BUFSIZE);
- if (buf == 0) {
- ejsMemoryError(ejs);
- return -1;
- }
-
- from = mprOpen(ejs, argv[0]->string, O_RDONLY | O_BINARY, 0664);
- if (from == 0) {
- ejsError(ejs, EJS_IO_ERROR, "Cant open %s", argv[0]->string);
- mprFree(buf);
- return -1;
- }
-
- to = mprOpen(ejs, argv[1]->string, O_CREAT | O_BINARY, 0664);
- if (to == 0) {
- ejsError(ejs, EJS_IO_ERROR, "Cant create %s", argv[1]->string);
- mprClose(from);
- mprFree(buf);
- return -1;
- }
-
- rc = 0;
- while ((bytes = mprRead(from, buf, MPR_BUFSIZE)) > 0) {
- if (mprWrite(to, buf, bytes) != bytes) {
- ejsError(ejs, EJS_IO_ERROR, "Write error to %s", argv[1]->string);
- rc = -1;
- break;
- }
- }
-
- mprClose(from);
- mprClose(to);
- mprFree(buf);
-
- return rc;
-}
-
-/******************************************************************************/
-/*
- * function FileInfo getFileInfo(string path);
- *
- * MOB -- should create a real class FileInfo
- */
-
-static int getFileInfoProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- MprFileInfo info;
- EjsVar *fileInfo;
- int rc;
-
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: getFileInfo(path)");
- return -1;
- }
-
- fileInfo = ejsCreateObjVar(ejs);
- if (fileInfo == 0) {
- ejsMemoryError(ejs);
- return -1;
- }
- ejsMakeObjPermanent(fileInfo, 1);
-
- rc = mprGetFileInfo(ejs, argv[0]->string, &info);
- if (rc < 0) {
- ejsMakeObjPermanent(fileInfo, 0);
- ejsFreeVar(ejs, fileInfo);
- ejsError(ejs, EJS_IO_ERROR, "Cant get file info for %s",
- argv[0]->string);
- return -1;
- }
-
- ejsSetPropertyToInteger(ejs, fileInfo, "created", info.ctime);
- ejsSetPropertyToInteger(ejs, fileInfo, "length", info.size);
- ejsSetPropertyToBoolean(ejs, fileInfo, "isDir", info.isDir);
-
- ejsSetReturnValue(ejs, fileInfo);
- ejsMakeObjPermanent(fileInfo, 0);
-
- return 0;
-}
-
-/******************************************************************************/
-/******************************** Initialization ******************************/
-/******************************************************************************/
-
-int ejsDefineFileSystemClass(Ejs *ejs)
-{
- EjsVar *fileSystemClass;
-
- fileSystemClass = ejsDefineClass(ejs, "FileSystem", "Object", 0);
- if (fileSystemClass == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
-
- /*
- * Define the methods
- */
- ejsDefineCMethod(ejs, fileSystemClass, "access", accessProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "mkdir", mkdirProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "rmdir", rmdirProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "dirList", dirListProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "writeFile", writeFileProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "readFile", readFileProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "remove", removeProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "rename", renameProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "copy", copyProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "getFileInfo", getFileInfoProc, 0);
-
- // MOB -- should be a property with accessor
- ejsDefineCMethod(ejs, fileSystemClass, "getFreeSpace", getFreeSpaceProc, 0);
-
- return ejsObjHasErrors(fileSystemClass) ? MPR_ERR_CANT_INITIALIZE: 0;
-}
-
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsHTTP.c b/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsHTTP.c
deleted file mode 100755
index 25821f6960..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsHTTP.c
+++ /dev/null
@@ -1,488 +0,0 @@
-/*
- * @file ejsHTTP.c
- * @brief HTTP class for the EJ System Object Model
- */
-/********************************** Copyright *********************************/
-/*
- * Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved.
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-#if UNUSED
-/*********************************** Defines **********************************/
-
-#define EJS_WEB_PROPERTY "-web"
-#define EJS_HTTP_PROPERTY "-http"
-
-#define EJS_HTTP_DISPOSED 550
-
-/*
- * Control structure for one HTTP request structure
- */
-typedef struct HTTPControl {
- Ejs *ejs;
- IWebResp *webResp;
- AEECallback *callback;
- MprBuf *buf;
- EjsVar *thisObj;
- char *url;
- MprTime requestStarted;
- uint timeout;
-} HTTPControl;
-
-/****************************** Forward Declarations **************************/
-
-static void cleanup(HTTPControl *hp);
-static int createWeb(Ejs *ejs, EjsVar *thisObj);
-static void brewCallback(HTTPControl *hp);
-static int httpDestructor(Ejs *ejs, EjsVar *vp);
-static void httpCallback(HTTPControl *hp, int responseCode);
-static int setCallback(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv);
-
-/******************************************************************************/
-/*
- * Constructor
- */
-
-int ejsHTTPConstructor(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (argc != 0 && argc != 2) {
- ejsError(ejs, EJS_ARG_ERROR,
- "Bad usage: HTTP([obj = this, method = onComplete]);");
- return -1;
- }
-
- if (createWeb(ejs, thisObj) < 0) {
- return -1;
- }
-
- setCallback(ejs, thisObj, argc, argv);
- return 0;
-}
-
-/******************************************************************************/
-
-static int createWeb(Ejs *ejs, EjsVar *thisObj)
-{
- MprApp *app;
- void *web;
-
- app = mprGetApp(ejs);
-
- /*
- * Create one instance of IWeb for the entire application. Do it here
- * so only widgets that require HTTP incurr the overhead.
- */
- web = mprGetKeyValue(ejs, "bpWeb");
- if (web == 0) {
- if (ISHELL_CreateInstance(app->shell, AEECLSID_WEB, &web) != SUCCESS) {
- ejsError(ejs, EJS_IO_ERROR, "Can't create IWEB");
- return -1;
- }
- }
- mprSetKeyValue(ejs, "bpWeb", web);
- return 0;
-}
-
-/******************************************************************************/
-/************************************ Methods *********************************/
-/******************************************************************************/
-/*
- * function setCallback(obj, methodString);
- */
-
-static int setCallback(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (argc >= 1) {
- ejsSetProperty(ejs, thisObj, "obj", argv[0]);
- } else {
- ejsSetProperty(ejs, thisObj, "obj", thisObj);
- }
-
- if (argc >= 2) {
- ejsSetProperty(ejs, thisObj, "method", argv[1]);
- } else {
- ejsSetPropertyToString(ejs, thisObj, "method", "onComplete");
- }
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function fetch();
- */
-
-static int fetchProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- HTTPControl *hp;
- EjsProperty *pp;
- MprApp *app;
- IWeb *web;
-
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: fetch(url)");
- return -1;
- }
-
- app = mprGetApp(ejs);
- web = (IWeb*) mprGetKeyValue(ejs, "bpWeb");
-
- /*
- * Web options
- *
- * WEBOPT_USERAGENT (char*) sets user agent
- * WEBOPT_HANDLERDATA (void*)
- * WEBOPT_CONNECTTIMEOUT (uint) msec
- * WEBOPT_CONTENTLENGTH (long)
- * WEBOPT_IDLECONNTIMEOUT (int)
- * WEBOPT_ACTIVEXACTIONST (uint) Number of active requests
- *
- * WEBREQUEST_REDIRECT redirect transparently
- *
- */
-
- hp = mprAllocType(ejs, HTTPControl);
- if (hp == 0) {
- ejsMemoryError(ejs);
- return -1;
- }
-
- hp->ejs = ejs;
- hp->buf = mprCreateBuf(hp, MPR_BUF_INCR, MPR_MAX_BUF);
- if (hp->buf == 0) {
- mprFree(hp);
- ejsMemoryError(ejs);
- return -1;
- }
-
- /*
- * We copy thisObj because we need to preserve both the var and the object.
- * We pass the var to brewCallback and so it must persist. The call to
- * ejsMakeObjPermanent will stop the GC from collecting the object.
- */
- hp->thisObj = ejsDupVar(ejs, thisObj, EJS_SHALLOW_COPY);
- ejsSetVarName(ejs, hp->thisObj, "internalHttp");
-
- /*
- * Must keep a reference to the http object
- */
- ejsMakeObjPermanent(hp->thisObj, 1);
-
- /*
- * Make a property so we can access the HTTPControl structure from other
- * methods.
- */
- pp = ejsSetPropertyToPtr(ejs, thisObj, EJS_HTTP_PROPERTY, hp, 0);
- ejsMakePropertyEnumerable(pp, 0);
- ejsSetObjDestructor(ejs, hp->thisObj, httpDestructor);
-
- hp->url = mprStrdup(hp, argv[0]->string);
-
- hp->timeout = ejsGetPropertyAsInteger(ejs, thisObj, "timeout");
- mprGetTime(hp, &hp->requestStarted);
-
- hp->callback = mprAllocTypeZeroed(hp, AEECallback);
- CALLBACK_Init(hp->callback, brewCallback, hp);
-
- hp->webResp = 0;
- IWEB_GetResponse(web,
- (web, &hp->webResp, hp->callback, hp->url,
- WEBOPT_HANDLERDATA, hp,
- WEBOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)",
- WEBOPT_CONNECTTIMEOUT, hp->timeout,
- WEBOPT_COPYOPTS, TRUE,
- WEBOPT_CONTENTLENGTH, 0,
- WEBOPT_END));
-
- ejsSetPropertyToString(ejs, thisObj, "status", "active");
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Called whenver the http object is deleted.
- */
-
-static int httpDestructor(Ejs *ejs, EjsVar *thisObj)
-{
- HTTPControl *hp;
-
- /*
- * If the httpCallback has run, then this property will not exist
- */
- hp = ejsGetPropertyAsPtr(ejs, thisObj, EJS_HTTP_PROPERTY);
-
- if (hp) {
- cleanup(hp);
- }
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Stop the request immediately without calling the callback
- */
-
-static int stopProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- HTTPControl *hp;
-
- hp = ejsGetPropertyAsPtr(ejs, thisObj, EJS_HTTP_PROPERTY);
-
- if (hp) {
- cleanup(hp);
- }
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Brew HTTP callback. Invoked for any return data.
- */
-
-static void brewCallback(HTTPControl *hp)
-{
- Ejs *ejs;
- EjsVar *thisObj;
- ISource *source;
- WebRespInfo *info;
- char data[MPR_BUF_INCR];
- int bytes;
-
- mprAssert(hp);
- mprAssert(hp->webResp);
-
- info = IWEBRESP_GetInfo(hp->webResp);
-
- if (info == 0) {
- mprAssert(info);
- /* should not happen */
- return;
- }
-
- ejs = hp->ejs;
- thisObj = hp->thisObj;
-
- if (! WEB_ERROR_SUCCEEDED(info->nCode)) {
- ejsSetPropertyToString(ejs, thisObj, "status", "error");
- httpCallback(hp, info->nCode);
- return;
- }
-
- if (hp->timeout) {
- if (mprGetTimeRemaining(hp, hp->requestStarted, hp->timeout) <= 0) {
- ejsSetPropertyToString(ejs, thisObj, "status", "timeout");
- httpCallback(hp, 504);
- return;
- }
- }
-
- /*
- * Normal success
- */
- source = info->pisMessage;
- mprAssert(source);
-
- bytes = ISOURCE_Read(source, data, sizeof(data));
-
- switch (bytes) {
- case ISOURCE_WAIT: // No data yet
- ISOURCE_Readable(source, hp->callback);
- break;
-
- case ISOURCE_ERROR:
- ejsSetPropertyToString(ejs, thisObj, "status", "error");
- httpCallback(hp, info->nCode);
- break;
-
- case ISOURCE_END:
- mprAddNullToBuf(hp->buf);
- ejsSetPropertyToString(ejs, thisObj, "status", "complete");
- httpCallback(hp, info->nCode);
- break;
-
- default:
- if (bytes > 0) {
- if (mprPutBlockToBuf(hp->buf, data, bytes) != bytes) {
- ejsSetPropertyToString(ejs, thisObj, "status", "partialData");
- httpCallback(hp, 500);
- }
- }
- ISOURCE_Readable(source, hp->callback);
- break;
- }
-}
-
-/******************************************************************************/
-/*
- * Invoke the HTTP completion method
- */
-
-static void httpCallback(HTTPControl *hp, int responseCode)
-{
- Ejs *ejs;
- EjsVar *thisObj, *callbackObj;
- MprArray *args;
- char *msg;
- const char *callbackMethod;
-
- mprAssert(hp);
- mprAssert(hp->webResp);
-
- thisObj = hp->thisObj;
- ejs = hp->ejs;
-
- ejsSetPropertyToInteger(ejs, thisObj, "responseCode", responseCode);
- if (mprGetBufLength(hp->buf) > 0) {
- ejsSetPropertyToBinaryString(ejs, thisObj, "responseData",
- mprGetBufStart(hp->buf), mprGetBufLength(hp->buf));
- }
-
- callbackObj = ejsGetPropertyAsVar(ejs, thisObj, "obj");
- callbackMethod = ejsGetPropertyAsString(ejs, thisObj, "method");
-
- if (callbackObj != 0 && callbackMethod != 0) {
-
- args = mprCreateItemArray(ejs, EJS_INC_ARGS, EJS_MAX_ARGS);
- mprAddItem(args, ejsDupVar(ejs, hp->thisObj, EJS_SHALLOW_COPY));
-
- if (ejsRunMethod(ejs, callbackObj, callbackMethod, args) < 0) {
- msg = ejsGetErrorMsg(ejs);
- mprError(ejs, MPR_LOC, "HTTP callback failed. Details: %s", msg);
- }
- ejsFreeMethodArgs(ejs, args);
-
- } else if (ejsRunMethod(ejs, thisObj, "onComplete", 0) < 0) {
- msg = ejsGetErrorMsg(ejs);
- mprError(ejs, MPR_LOC, "HTTP onComplete failed. Details: %s", msg);
- }
-
- cleanup(hp);
-}
-
-/******************************************************************************/
-/*
- * Cleanup
- */
-
-static void cleanup(HTTPControl *hp)
-{
- Ejs *ejs;
- MprApp *app;
- int rc;
-
- mprAssert(hp);
- mprAssert(hp->webResp);
-
- ejs = hp->ejs;
-
- if (hp->webResp) {
- rc = IWEBRESP_Release(hp->webResp);
- // mprAssert(rc == 0);
- hp->webResp = 0;
- }
-
- if (hp->callback) {
- CALLBACK_Cancel(hp->callback);
- mprFree(hp->callback);
- hp->callback = 0;
- }
-
- /*
- * Once the property is deleted, then if the destructor runs, it will
- * notice that the EJS_HTTP_PROPERTY is undefined.
- */
- ejsDeleteProperty(ejs, hp->thisObj, EJS_HTTP_PROPERTY);
-
- /*
- * Allow garbage collection to work on thisObj
- */
- ejsMakeObjPermanent(hp->thisObj, 0);
- ejsFreeVar(ejs, hp->thisObj);
-
- mprFree(hp->buf);
- mprFree(hp->url);
-
- mprFree(hp);
-
- app = mprGetApp(ejs);
-
-
- ISHELL_SendEvent(app->shell, (AEECLSID) app->classId, EVT_USER, 0, 0);
-}
-
-/******************************************************************************/
-/******************************** Initialization ******************************/
-/******************************************************************************/
-
-int ejsDefineHTTPClass(Ejs *ejs)
-{
- EjsVar *httpClass;
-
- httpClass =
- ejsDefineClass(ejs, "HTTP", "Object", ejsHTTPConstructor);
- if (httpClass == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
-
- /*
- * Define the methods
- */
- ejsDefineCMethod(ejs, httpClass, "fetch", fetchProc, 0);
- ejsDefineCMethod(ejs, httpClass, "stop", stopProc, 0);
- ejsDefineCMethod(ejs, httpClass, "setCallback", setCallback, 0);
-
-#if FUTURE
- ejsDefineCMethod(ejs, httpClass, "put", put, 0);
- ejsDefineCMethod(ejs, httpClass, "upload", upload, 0);
- ejsDefineCMethod(ejs, httpClass, "addUploadFile", addUploadFile, 0);
- ejsDefineCMethod(ejs, httpClass, "addPostData", addPostData, 0);
- ejsDefineCMethod(ejs, httpClass, "setUserPassword", setUserPassword, 0);
- ejsDefineCMethod(ejs, httpClass, "addCookie", addCookie, 0);
-#endif
-
- /*
- * Define properties
- */
- ejsSetPropertyToString(ejs, httpClass, "status", "inactive");
-
- /* This default should come from player.xml */
-
- ejsSetPropertyToInteger(ejs, httpClass, "timeout", 30 * 1000);
- ejsSetPropertyToInteger(ejs, httpClass, "responseCode", 0);
-
- return ejsObjHasErrors(httpClass) ? MPR_ERR_CANT_INITIALIZE: 0;
-}
-
-/******************************************************************************/
-
-void ejsTermHTTPClass(Ejs *ejs)
-{
- IWeb *web;
- int rc;
-
- web = (IWeb*) mprGetKeyValue(ejs, "bpWeb");
- if (web) {
- rc = IWEB_Release(web);
- mprAssert(rc == 0);
- }
-}
-
-#endif
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/.ignore b/source4/lib/appweb/ejs-2.0/ejs/system/WIN/.ignore
deleted file mode 100644
index fb5a29031e..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/.ignore
+++ /dev/null
@@ -1 +0,0 @@
-.updated
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/Makefile b/source4/lib/appweb/ejs-2.0/ejs/system/WIN/Makefile
deleted file mode 100755
index 424747052a..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Makefile to build the EJS Object Model for WIN
-#
-# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
-#
-
-COMPILE := *.c
-EXPORT_OBJECTS := yes
-MAKE_IFLAGS := -I../.. -I../../../mpr
-
-include make.dep
-
-compileExtra: .updated
-
-.updated: $(FILES)
- @touch .updated
-
-## Local variables:
-## tab-width: 4
-## End:
-## vim: tw=78 sw=4 ts=4
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsFile.c b/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsFile.c
deleted file mode 100644
index 24c521891e..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsFile.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * @file ejsFile.c
- * @brief File class for the EJScript System Object Model
- */
-/********************************** Copyright *********************************/
-/*
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-/******************************************************************************/
-/*
- * Default Constructor
- */
-
-/******************************************************************************/
-/************************************ Methods *********************************/
-/******************************************************************************/
-/*
- * function open();
- */
-
-static int openProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsTrace(ep, "File.open()\n");
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function close();
- */
-
-static int closeProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsTrace(ep, "File.close()\n");
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function read();
- */
-
-static int readProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsTrace(ep, "File.read()\n");
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function write();
- */
-
-static int writeProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsTrace(ep, "File.write()\n");
- return 0;
-}
-
-/******************************************************************************/
-/******************************** Initialization ******************************/
-/******************************************************************************/
-
-int ejsDefineFileClass(Ejs *ep)
-{
- EjsVar *fileClass;
-
- fileClass = ejsDefineClass(ep, "File", "Object", 0);
- if (fileClass == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
-
- /*
- * Define the methods
- */
- ejsDefineCMethod(ep, fileClass, "open", openProc, 0);
- ejsDefineCMethod(ep, fileClass, "close", closeProc, 0);
- ejsDefineCMethod(ep, fileClass, "read", readProc, 0);
- ejsDefineCMethod(ep, fileClass, "write", writeProc, 0);
-
- return ejsObjHasErrors(fileClass) ? MPR_ERR_CANT_INITIALIZE: 0;
-}
-
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsFileSystem.c b/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsFileSystem.c
deleted file mode 100755
index 66c3b84870..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsFileSystem.c
+++ /dev/null
@@ -1,456 +0,0 @@
-/*
- * @file ejsFileSystem.c
- * @brief FileSystem class for the EJ System Object Model
- */
-/********************************** Copyright *********************************/
-/*
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-/******************************************************************************/
-/*
- * Default Constructor
- */
-
-/******************************************************************************/
-/************************************ Methods *********************************/
-/******************************************************************************/
-/*
- * function void access(string path);
- * MOB - API insufficient. Access for read or write?
- */
-
-static int accessProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- int rc;
-
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: access(path)");
- return -1;
- }
-
- rc = access(argv[0]->string, 04);
-
- ejsSetReturnValueToBoolean(ejs, (rc == 0) ? 1 : 0);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function void mkdir(string path);
- */
-
-static int mkdirProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: mkdir(path)");
- return -1;
- }
-
- if (mprMakeDirPath(ejs, argv[0]->string) < 0) {
- ejsError(ejs, EJS_IO_ERROR, "Cant create directory");
- return -1;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function void rmdir(string path);
- */
-
-static int rmdirProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- int rc;
-
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: mkdir(path)");
- return -1;
- }
-
- rc = mprDeleteDir(ejs, argv[0]->string);
-
- if (rc < 0) {
- ejsError(ejs, EJS_IO_ERROR, "Cant remove directory");
- return -1;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function void dirList(string path, [bool enumDirs]);
- * MOB -- need pattern to match (what about "." and ".." and ".*"
- */
-
-static int dirListProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- WIN32_FIND_DATA findData;
- HANDLE h;
- char path[MPR_MAX_FNAME];
- EjsVar *array, *vp;
- uchar enumDirs;
-
- if (argc < 1 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: dirList(path)");
- return -1;
- }
- if (argc == 2) {
- enumDirs = ejsVarToBoolean(argv[1]);
- } else {
- enumDirs = 0;
- }
- array = ejsCreateArray(ejs, 0);
- ejsMakeObjPermanent(array, 1);
-
- /*
- * First collect the files
- */
- mprSprintf(path, sizeof(path), "%s/*.*", argv[0]->string);
- h = FindFirstFile(path, &findData);
- if (h == INVALID_HANDLE_VALUE) {
- ejsError(ejs, EJS_ARG_ERROR, "Can't enumerate dirList(path)");
- return -1;
- }
-
- do {
- if (findData.cFileName[0] == '.') {
- continue;
- }
- if (!enumDirs ||
- (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
- mprSprintf(path, sizeof(path), "%s/%s", argv[0]->string,
- findData.cFileName);
- vp = ejsCreateStringVar(ejs, path);
- ejsAddArrayElt(ejs, array, vp, EJS_SHALLOW_COPY);
- ejsFreeVar(ejs, vp);
- }
- } while (FindNextFile(h, &findData) != 0);
-
- FindClose(h);
-
- ejsSetReturnValue(ejs, array);
- ejsMakeObjPermanent(array, 0);
-
- /*
- * Can free now as the return value holds the reference
- */
- ejsFreeVar(ejs, array);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function void getFreeSpace();
- */
-
-static int getFreeSpaceProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
-#if UNUSED
- MprApp *app;
- uint space;
-
- app = mprGetApp(ejs);
- space = IFILEMGR_GetFreeSpace(app->fileMgr, 0);
- ejsSetReturnValueToInteger(ejs, space);
-#endif
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function void writeFile(string path, var data);
- */
-
-static int writeFileProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- MprFile *file;
- char *data, *buf;
- int bytes, length, rc;
-
- if (argc != 2 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: writeFile(path, var)");
- return -1;
- }
-
- if (ejsVarIsString(argv[1])) {
- data = argv[1]->string;
- length = argv[1]->length;
- buf = 0;
- } else {
- buf = data = ejsVarToString(ejs, argv[1]);
- length = strlen(data);
- }
-
- /*
- * Create fails if already present
- */
- rc = mprDelete(ejs, argv[0]->string);
- file = mprOpen(ejs, argv[0]->string, O_CREAT | O_WRONLY | O_BINARY, 0664);
- if (file == 0) {
- ejsError(ejs, EJS_IO_ERROR, "Cant create %s", argv[0]->string);
- mprFree(buf);
- return -1;
- }
-
- rc = 0;
- bytes = mprWrite(file, data, length);
- if (bytes != length) {
- ejsError(ejs, EJS_IO_ERROR, "Write error to %s", argv[1]->string);
- rc = -1;
- }
-
- mprClose(file);
-
- mprFree(buf);
- return rc;
-}
-
-/******************************************************************************/
-/*
- * function string readFile(string path);
- */
-
-static int readFileProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- MprApp *app;
- MprFile *file;
- MprBuf *buf;
- char *data;
- int bytes, rc;
-
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: readFile(path)");
- return -1;
- }
- buf = mprCreateBuf(ejs, MPR_BUF_INCR, MPR_MAX_BUF);
- if (buf == 0) {
- ejsMemoryError(ejs);
- return -1;
- }
-
- data = mprAlloc(ejs, MPR_BUFSIZE);
- if (buf == 0) {
- mprFree(buf);
- ejsMemoryError(ejs);
- return -1;
- }
-
- app = mprGetApp(ejs);
- file = mprOpen(ejs, argv[0]->string, O_RDONLY, 0664);
- if (file == 0) {
- ejsError(ejs, EJS_IO_ERROR, "Cant open %s", argv[0]->string);
- mprFree(buf);
- return -1;
- }
-
- rc = 0;
- while ((bytes = mprRead(file, data, MPR_BUFSIZE)) > 0) {
- if (mprPutBlockToBuf(buf, data, bytes) != bytes) {
- ejsError(ejs, EJS_IO_ERROR, "Write error to %s", argv[1]->string);
- rc = -1;
- break;
- }
- }
-
- ejsSetReturnValueToBinaryString(ejs, mprGetBufStart(buf),
- mprGetBufLength(buf));
-
- mprClose(file);
- mprFree(data);
- mprFree(buf);
-
- return rc;
-}
-
-/******************************************************************************/
-/*
- * function void remove(string path);
- */
-
-static int removeProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- int rc;
-
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: remove(path)");
- return -1;
- }
-
- rc = unlink(argv[0]->string);
- if (rc < 0) {
- ejsError(ejs, EJS_IO_ERROR, "Cant remove file");
- return -1;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function void rename(string from, string to);
- */
-
-static int renameProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- int rc;
-
- if (argc != 2 || !ejsVarIsString(argv[0]) || !ejsVarIsString(argv[1])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: rename(old, new)");
- return -1;
- }
-
- unlink(argv[1]->string);
- rc = rename(argv[0]->string, argv[1]->string);
- if (rc < 0) {
- ejsError(ejs, EJS_IO_ERROR, "Cant rename file");
- return -1;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function void copy(string old, string new);
- */
-
-static int copyProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- MprFile *from, *to;
- char *buf;
- int bytes, rc;
-
- if (argc != 2 || !ejsVarIsString(argv[0]) || !ejsVarIsString(argv[1])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: copy(old, new)");
- return -1;
- }
-
- buf = mprAlloc(ejs, MPR_BUFSIZE);
- if (buf == 0) {
- ejsMemoryError(ejs);
- return -1;
- }
-
- from = mprOpen(ejs, argv[0]->string, O_RDONLY | O_BINARY, 0664);
- if (from == 0) {
- ejsError(ejs, EJS_IO_ERROR, "Cant open %s", argv[0]->string);
- mprFree(buf);
- return -1;
- }
-
- to = mprOpen(ejs, argv[1]->string, O_CREAT | O_BINARY, 0664);
- if (to == 0) {
- ejsError(ejs, EJS_IO_ERROR, "Cant create %s", argv[1]->string);
- mprClose(from);
- mprFree(buf);
- return -1;
- }
-
- rc = 0;
- while ((bytes = mprRead(from, buf, MPR_BUFSIZE)) > 0) {
- if (mprWrite(to, buf, bytes) != bytes) {
- ejsError(ejs, EJS_IO_ERROR, "Write error to %s", argv[1]->string);
- rc = -1;
- break;
- }
- }
-
- mprClose(from);
- mprClose(to);
- mprFree(buf);
-
- return rc;
-}
-
-/******************************************************************************/
-/*
- * function FileInfo getFileInfo(string path);
- *
- * MOB -- should create a real class FileInfo
- */
-
-static int getFileInfoProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- MprFileInfo info;
- EjsVar *fileInfo;
- int rc;
-
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: getFileInfo(path)");
- return -1;
- }
-
- fileInfo = ejsCreateObjVar(ejs);
- if (fileInfo == 0) {
- ejsMemoryError(ejs);
- return -1;
- }
- ejsMakeObjPermanent(fileInfo, 1);
-
- rc = mprGetFileInfo(ejs, argv[0]->string, &info);
- if (rc < 0) {
- ejsMakeObjPermanent(fileInfo, 0);
- ejsFreeVar(ejs, fileInfo);
- ejsError(ejs, EJS_IO_ERROR, "Cant get file info for %s",
- argv[0]->string);
- return -1;
- }
-
- ejsSetPropertyToInteger(ejs, fileInfo, "created", info.ctime);
- ejsSetPropertyToInteger(ejs, fileInfo, "length", info.size);
- ejsSetPropertyToBoolean(ejs, fileInfo, "isDir", info.isDir);
-
- ejsSetReturnValue(ejs, fileInfo);
- ejsMakeObjPermanent(fileInfo, 0);
-
- return 0;
-}
-
-/******************************************************************************/
-/******************************** Initialization ******************************/
-/******************************************************************************/
-
-int ejsDefineFileSystemClass(Ejs *ejs)
-{
- EjsVar *fileSystemClass;
-
- fileSystemClass = ejsDefineClass(ejs, "FileSystem", "Object", 0);
- if (fileSystemClass == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
-
- /*
- * Define the methods
- */
- ejsDefineCMethod(ejs, fileSystemClass, "access", accessProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "mkdir", mkdirProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "rmdir", rmdirProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "dirList", dirListProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "writeFile", writeFileProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "readFile", readFileProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "remove", removeProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "rename", renameProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "copy", copyProc, 0);
- ejsDefineCMethod(ejs, fileSystemClass, "getFileInfo", getFileInfoProc, 0);
-
- // MOB -- should be a property with accessor
- ejsDefineCMethod(ejs, fileSystemClass, "getFreeSpace", getFreeSpaceProc, 0);
-
- return ejsObjHasErrors(fileSystemClass) ? MPR_ERR_CANT_INITIALIZE: 0;
-}
-
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsHTTP.c b/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsHTTP.c
deleted file mode 100755
index 25821f6960..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsHTTP.c
+++ /dev/null
@@ -1,488 +0,0 @@
-/*
- * @file ejsHTTP.c
- * @brief HTTP class for the EJ System Object Model
- */
-/********************************** Copyright *********************************/
-/*
- * Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved.
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-#if UNUSED
-/*********************************** Defines **********************************/
-
-#define EJS_WEB_PROPERTY "-web"
-#define EJS_HTTP_PROPERTY "-http"
-
-#define EJS_HTTP_DISPOSED 550
-
-/*
- * Control structure for one HTTP request structure
- */
-typedef struct HTTPControl {
- Ejs *ejs;
- IWebResp *webResp;
- AEECallback *callback;
- MprBuf *buf;
- EjsVar *thisObj;
- char *url;
- MprTime requestStarted;
- uint timeout;
-} HTTPControl;
-
-/****************************** Forward Declarations **************************/
-
-static void cleanup(HTTPControl *hp);
-static int createWeb(Ejs *ejs, EjsVar *thisObj);
-static void brewCallback(HTTPControl *hp);
-static int httpDestructor(Ejs *ejs, EjsVar *vp);
-static void httpCallback(HTTPControl *hp, int responseCode);
-static int setCallback(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv);
-
-/******************************************************************************/
-/*
- * Constructor
- */
-
-int ejsHTTPConstructor(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (argc != 0 && argc != 2) {
- ejsError(ejs, EJS_ARG_ERROR,
- "Bad usage: HTTP([obj = this, method = onComplete]);");
- return -1;
- }
-
- if (createWeb(ejs, thisObj) < 0) {
- return -1;
- }
-
- setCallback(ejs, thisObj, argc, argv);
- return 0;
-}
-
-/******************************************************************************/
-
-static int createWeb(Ejs *ejs, EjsVar *thisObj)
-{
- MprApp *app;
- void *web;
-
- app = mprGetApp(ejs);
-
- /*
- * Create one instance of IWeb for the entire application. Do it here
- * so only widgets that require HTTP incurr the overhead.
- */
- web = mprGetKeyValue(ejs, "bpWeb");
- if (web == 0) {
- if (ISHELL_CreateInstance(app->shell, AEECLSID_WEB, &web) != SUCCESS) {
- ejsError(ejs, EJS_IO_ERROR, "Can't create IWEB");
- return -1;
- }
- }
- mprSetKeyValue(ejs, "bpWeb", web);
- return 0;
-}
-
-/******************************************************************************/
-/************************************ Methods *********************************/
-/******************************************************************************/
-/*
- * function setCallback(obj, methodString);
- */
-
-static int setCallback(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (argc >= 1) {
- ejsSetProperty(ejs, thisObj, "obj", argv[0]);
- } else {
- ejsSetProperty(ejs, thisObj, "obj", thisObj);
- }
-
- if (argc >= 2) {
- ejsSetProperty(ejs, thisObj, "method", argv[1]);
- } else {
- ejsSetPropertyToString(ejs, thisObj, "method", "onComplete");
- }
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function fetch();
- */
-
-static int fetchProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- HTTPControl *hp;
- EjsProperty *pp;
- MprApp *app;
- IWeb *web;
-
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsError(ejs, EJS_ARG_ERROR, "Bad usage: fetch(url)");
- return -1;
- }
-
- app = mprGetApp(ejs);
- web = (IWeb*) mprGetKeyValue(ejs, "bpWeb");
-
- /*
- * Web options
- *
- * WEBOPT_USERAGENT (char*) sets user agent
- * WEBOPT_HANDLERDATA (void*)
- * WEBOPT_CONNECTTIMEOUT (uint) msec
- * WEBOPT_CONTENTLENGTH (long)
- * WEBOPT_IDLECONNTIMEOUT (int)
- * WEBOPT_ACTIVEXACTIONST (uint) Number of active requests
- *
- * WEBREQUEST_REDIRECT redirect transparently
- *
- */
-
- hp = mprAllocType(ejs, HTTPControl);
- if (hp == 0) {
- ejsMemoryError(ejs);
- return -1;
- }
-
- hp->ejs = ejs;
- hp->buf = mprCreateBuf(hp, MPR_BUF_INCR, MPR_MAX_BUF);
- if (hp->buf == 0) {
- mprFree(hp);
- ejsMemoryError(ejs);
- return -1;
- }
-
- /*
- * We copy thisObj because we need to preserve both the var and the object.
- * We pass the var to brewCallback and so it must persist. The call to
- * ejsMakeObjPermanent will stop the GC from collecting the object.
- */
- hp->thisObj = ejsDupVar(ejs, thisObj, EJS_SHALLOW_COPY);
- ejsSetVarName(ejs, hp->thisObj, "internalHttp");
-
- /*
- * Must keep a reference to the http object
- */
- ejsMakeObjPermanent(hp->thisObj, 1);
-
- /*
- * Make a property so we can access the HTTPControl structure from other
- * methods.
- */
- pp = ejsSetPropertyToPtr(ejs, thisObj, EJS_HTTP_PROPERTY, hp, 0);
- ejsMakePropertyEnumerable(pp, 0);
- ejsSetObjDestructor(ejs, hp->thisObj, httpDestructor);
-
- hp->url = mprStrdup(hp, argv[0]->string);
-
- hp->timeout = ejsGetPropertyAsInteger(ejs, thisObj, "timeout");
- mprGetTime(hp, &hp->requestStarted);
-
- hp->callback = mprAllocTypeZeroed(hp, AEECallback);
- CALLBACK_Init(hp->callback, brewCallback, hp);
-
- hp->webResp = 0;
- IWEB_GetResponse(web,
- (web, &hp->webResp, hp->callback, hp->url,
- WEBOPT_HANDLERDATA, hp,
- WEBOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)",
- WEBOPT_CONNECTTIMEOUT, hp->timeout,
- WEBOPT_COPYOPTS, TRUE,
- WEBOPT_CONTENTLENGTH, 0,
- WEBOPT_END));
-
- ejsSetPropertyToString(ejs, thisObj, "status", "active");
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Called whenver the http object is deleted.
- */
-
-static int httpDestructor(Ejs *ejs, EjsVar *thisObj)
-{
- HTTPControl *hp;
-
- /*
- * If the httpCallback has run, then this property will not exist
- */
- hp = ejsGetPropertyAsPtr(ejs, thisObj, EJS_HTTP_PROPERTY);
-
- if (hp) {
- cleanup(hp);
- }
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Stop the request immediately without calling the callback
- */
-
-static int stopProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- HTTPControl *hp;
-
- hp = ejsGetPropertyAsPtr(ejs, thisObj, EJS_HTTP_PROPERTY);
-
- if (hp) {
- cleanup(hp);
- }
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Brew HTTP callback. Invoked for any return data.
- */
-
-static void brewCallback(HTTPControl *hp)
-{
- Ejs *ejs;
- EjsVar *thisObj;
- ISource *source;
- WebRespInfo *info;
- char data[MPR_BUF_INCR];
- int bytes;
-
- mprAssert(hp);
- mprAssert(hp->webResp);
-
- info = IWEBRESP_GetInfo(hp->webResp);
-
- if (info == 0) {
- mprAssert(info);
- /* should not happen */
- return;
- }
-
- ejs = hp->ejs;
- thisObj = hp->thisObj;
-
- if (! WEB_ERROR_SUCCEEDED(info->nCode)) {
- ejsSetPropertyToString(ejs, thisObj, "status", "error");
- httpCallback(hp, info->nCode);
- return;
- }
-
- if (hp->timeout) {
- if (mprGetTimeRemaining(hp, hp->requestStarted, hp->timeout) <= 0) {
- ejsSetPropertyToString(ejs, thisObj, "status", "timeout");
- httpCallback(hp, 504);
- return;
- }
- }
-
- /*
- * Normal success
- */
- source = info->pisMessage;
- mprAssert(source);
-
- bytes = ISOURCE_Read(source, data, sizeof(data));
-
- switch (bytes) {
- case ISOURCE_WAIT: // No data yet
- ISOURCE_Readable(source, hp->callback);
- break;
-
- case ISOURCE_ERROR:
- ejsSetPropertyToString(ejs, thisObj, "status", "error");
- httpCallback(hp, info->nCode);
- break;
-
- case ISOURCE_END:
- mprAddNullToBuf(hp->buf);
- ejsSetPropertyToString(ejs, thisObj, "status", "complete");
- httpCallback(hp, info->nCode);
- break;
-
- default:
- if (bytes > 0) {
- if (mprPutBlockToBuf(hp->buf, data, bytes) != bytes) {
- ejsSetPropertyToString(ejs, thisObj, "status", "partialData");
- httpCallback(hp, 500);
- }
- }
- ISOURCE_Readable(source, hp->callback);
- break;
- }
-}
-
-/******************************************************************************/
-/*
- * Invoke the HTTP completion method
- */
-
-static void httpCallback(HTTPControl *hp, int responseCode)
-{
- Ejs *ejs;
- EjsVar *thisObj, *callbackObj;
- MprArray *args;
- char *msg;
- const char *callbackMethod;
-
- mprAssert(hp);
- mprAssert(hp->webResp);
-
- thisObj = hp->thisObj;
- ejs = hp->ejs;
-
- ejsSetPropertyToInteger(ejs, thisObj, "responseCode", responseCode);
- if (mprGetBufLength(hp->buf) > 0) {
- ejsSetPropertyToBinaryString(ejs, thisObj, "responseData",
- mprGetBufStart(hp->buf), mprGetBufLength(hp->buf));
- }
-
- callbackObj = ejsGetPropertyAsVar(ejs, thisObj, "obj");
- callbackMethod = ejsGetPropertyAsString(ejs, thisObj, "method");
-
- if (callbackObj != 0 && callbackMethod != 0) {
-
- args = mprCreateItemArray(ejs, EJS_INC_ARGS, EJS_MAX_ARGS);
- mprAddItem(args, ejsDupVar(ejs, hp->thisObj, EJS_SHALLOW_COPY));
-
- if (ejsRunMethod(ejs, callbackObj, callbackMethod, args) < 0) {
- msg = ejsGetErrorMsg(ejs);
- mprError(ejs, MPR_LOC, "HTTP callback failed. Details: %s", msg);
- }
- ejsFreeMethodArgs(ejs, args);
-
- } else if (ejsRunMethod(ejs, thisObj, "onComplete", 0) < 0) {
- msg = ejsGetErrorMsg(ejs);
- mprError(ejs, MPR_LOC, "HTTP onComplete failed. Details: %s", msg);
- }
-
- cleanup(hp);
-}
-
-/******************************************************************************/
-/*
- * Cleanup
- */
-
-static void cleanup(HTTPControl *hp)
-{
- Ejs *ejs;
- MprApp *app;
- int rc;
-
- mprAssert(hp);
- mprAssert(hp->webResp);
-
- ejs = hp->ejs;
-
- if (hp->webResp) {
- rc = IWEBRESP_Release(hp->webResp);
- // mprAssert(rc == 0);
- hp->webResp = 0;
- }
-
- if (hp->callback) {
- CALLBACK_Cancel(hp->callback);
- mprFree(hp->callback);
- hp->callback = 0;
- }
-
- /*
- * Once the property is deleted, then if the destructor runs, it will
- * notice that the EJS_HTTP_PROPERTY is undefined.
- */
- ejsDeleteProperty(ejs, hp->thisObj, EJS_HTTP_PROPERTY);
-
- /*
- * Allow garbage collection to work on thisObj
- */
- ejsMakeObjPermanent(hp->thisObj, 0);
- ejsFreeVar(ejs, hp->thisObj);
-
- mprFree(hp->buf);
- mprFree(hp->url);
-
- mprFree(hp);
-
- app = mprGetApp(ejs);
-
-
- ISHELL_SendEvent(app->shell, (AEECLSID) app->classId, EVT_USER, 0, 0);
-}
-
-/******************************************************************************/
-/******************************** Initialization ******************************/
-/******************************************************************************/
-
-int ejsDefineHTTPClass(Ejs *ejs)
-{
- EjsVar *httpClass;
-
- httpClass =
- ejsDefineClass(ejs, "HTTP", "Object", ejsHTTPConstructor);
- if (httpClass == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
-
- /*
- * Define the methods
- */
- ejsDefineCMethod(ejs, httpClass, "fetch", fetchProc, 0);
- ejsDefineCMethod(ejs, httpClass, "stop", stopProc, 0);
- ejsDefineCMethod(ejs, httpClass, "setCallback", setCallback, 0);
-
-#if FUTURE
- ejsDefineCMethod(ejs, httpClass, "put", put, 0);
- ejsDefineCMethod(ejs, httpClass, "upload", upload, 0);
- ejsDefineCMethod(ejs, httpClass, "addUploadFile", addUploadFile, 0);
- ejsDefineCMethod(ejs, httpClass, "addPostData", addPostData, 0);
- ejsDefineCMethod(ejs, httpClass, "setUserPassword", setUserPassword, 0);
- ejsDefineCMethod(ejs, httpClass, "addCookie", addCookie, 0);
-#endif
-
- /*
- * Define properties
- */
- ejsSetPropertyToString(ejs, httpClass, "status", "inactive");
-
- /* This default should come from player.xml */
-
- ejsSetPropertyToInteger(ejs, httpClass, "timeout", 30 * 1000);
- ejsSetPropertyToInteger(ejs, httpClass, "responseCode", 0);
-
- return ejsObjHasErrors(httpClass) ? MPR_ERR_CANT_INITIALIZE: 0;
-}
-
-/******************************************************************************/
-
-void ejsTermHTTPClass(Ejs *ejs)
-{
- IWeb *web;
- int rc;
-
- web = (IWeb*) mprGetKeyValue(ejs, "bpWeb");
- if (web) {
- rc = IWEB_Release(web);
- mprAssert(rc == 0);
- }
-}
-
-#endif
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/ejsGC.c b/source4/lib/appweb/ejs-2.0/ejs/system/ejsGC.c
deleted file mode 100644
index 411975f80e..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/ejsGC.c
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * @file ejsGC.c
- * @brief Garbage collector class for the EJS Object Model
- */
-/********************************** Copyright *********************************/
-/*
- * Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved.
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-/******************************************************************************/
-/************************************ Methods *********************************/
-/******************************************************************************/
-#if (WIN || BREW_SIMULATOR) && BLD_DEBUG
-
-static int checkProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- _CrtCheckMemory();
- return 0;
-}
-
-#endif
-/******************************************************************************/
-
-static int debugProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (argc != 1) {
- ejsError(ep, EJS_ARG_ERROR, "Bad args: debug(debugLevel)");
- return -1;
- }
-
- ejsSetGCDebugLevel(ep, ejsVarToInteger(argv[0]));
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Print stats and dump objects
- */
-
-static int printStatsProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- bool leakStats;
-
- if (argc > 1) {
- leakStats = ejsVarToInteger(argv[0]);
- } else {
- leakStats = 0;
- }
-
-#if BLD_FEATURE_ALLOC_STATS
- ejsPrintAllocReport(ep, 0);
-
- mprPrintAllocReport(mprGetApp(ep), leakStats, 0);
-#endif
-
-#if BLD_DEBUG
- ejsDumpObjects(ep);
-#endif
-
- return 0;
-}
-
-/******************************************************************************/
-
-static int runProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (argc > 1) {
- ejsError(ep, EJS_ARG_ERROR, "Bad args: run([quick])");
- return -1;
- }
-
- if (argc == 1) {
- ejsIncrementalCollectGarbage(ep);
- } else {
- ejsCollectGarbage(ep, -1);
- }
- return 0;
-}
-
-/******************************************************************************/
-
-static int usedMemoryProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsSetReturnValueToInteger(ep, ejsGetUsedMemory(ep));
- return 0;
-}
-
-/******************************************************************************/
-
-static int allocatedMemoryProc(Ejs *ep, EjsVar *thisObj, int argc,
- EjsVar **argv)
-{
-#if BLD_FEATURE_ALLOC_STATS
- ejsSetReturnValueToInteger(ep, ejsGetAllocatedMemory(ep));
-#endif
- return 0;
-}
-
-/******************************************************************************/
-
-static int mprMemoryProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
-#if BLD_FEATURE_ALLOC_STATS
- ejsSetReturnValueToInteger(ep, mprGetAllocatedMemory(ep));
-#endif
- return 0;
-}
-
-/******************************************************************************/
-
-static int peakMprMemoryProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
-#if BLD_FEATURE_ALLOC_STATS
- ejsSetReturnValueToInteger(ep, mprGetPeakAllocatedMemory(ep));
-#endif
- return 0;
-}
-
-/******************************************************************************/
-
-static int getDebugLevel(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsSetReturnValueToInteger(ep, ep->gc.debugLevel);
- return 0;
-}
-
-/******************************************************************************/
-
-static int setDebugLevel(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (argc != 1) {
- ejsArgError(ep, "Bad arguments");
- return -1;
- }
- ep->gc.debugLevel= ejsVarToInteger(argv[0]);
- return 0;
-}
-
-/******************************************************************************/
-
-static int getEnable(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsSetReturnValueToBoolean(ep, ep->gc.enable);
- return 0;
-}
-
-/******************************************************************************/
-
-static int setEnable(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (argc != 1) {
- ejsArgError(ep, "Bad arguments");
- return -1;
- }
- ep->gc.enable= ejsVarToBoolean(argv[0]);
- return 0;
-}
-
-/******************************************************************************/
-
-static int getDemandCollect(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsSetReturnValueToBoolean(ep, ep->gc.enableDemandCollect);
- return 0;
-}
-
-/******************************************************************************/
-
-static int setDemandCollect(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (argc != 1) {
- ejsArgError(ep, "Bad arguments");
- return -1;
- }
- ep->gc.enableDemandCollect = ejsVarToBoolean(argv[0]);
- return 0;
-}
-
-/******************************************************************************/
-
-static int getIdleCollect(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsSetReturnValueToBoolean(ep, ep->gc.enableIdleCollect);
- return 0;
-}
-
-/******************************************************************************/
-
-static int setIdleCollect(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (argc != 1) {
- ejsArgError(ep, "Bad arguments");
- return -1;
- }
- ep->gc.enableIdleCollect = ejsVarToBoolean(argv[0]);
- return 0;
-}
-
-/******************************************************************************/
-
-static int getWorkQuota(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsSetReturnValueToInteger(ep, ep->gc.workQuota);
- return 0;
-}
-
-/******************************************************************************/
-
-static int setWorkQuota(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- int quota;
-
- if (argc != 1) {
- ejsArgError(ep, "Bad arguments");
- return -1;
- }
- quota = ejsVarToInteger(argv[0]);
- if (quota < EJS_GC_MIN_WORK_QUOTA && quota != 0) {
- ejsArgError(ep, "Bad work quota");
- return -1;
- }
-
- ep->gc.workQuota = quota;
- return 0;
-}
-
-/******************************************************************************/
-
-static int getMaxMemory(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsSetReturnValueToInteger(ep, ep->gc.maxMemory);
- return 0;
-}
-
-/******************************************************************************/
-
-static int setMaxMemory(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- int maxMemory;
-
- if (argc != 1) {
- ejsArgError(ep, "Bad arguments");
- return -1;
- }
- maxMemory = ejsVarToInteger(argv[0]);
- if (maxMemory < 0) {
- ejsArgError(ep, "Bad maxMemory");
- return -1;
- }
-
- ep->gc.maxMemory = maxMemory;
- return 0;
-}
-
-/******************************************************************************/
-/******************************** Initialization ******************************/
-/******************************************************************************/
-
-int ejsDefineGCClass(Ejs *ep)
-{
- EjsVar *gcClass;
- int flags;
-
- flags = EJS_NO_LOCAL;
-
- /*
- * NOTE: We create the GC class and define static methods on it. There
- * is no object instance
- */
- gcClass = ejsDefineClass(ep, "System.GC", "Object", 0);
- if (gcClass == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
-
- /*
- * MOB -- convert these to properties with accessors when available
- */
- ejsDefineCMethod(ep, gcClass, "printStats", printStatsProc, flags);
- ejsDefineCMethod(ep, gcClass, "run", runProc, flags);
-
- ejsDefineCMethod(ep, gcClass, "getUsedMemory", usedMemoryProc, flags);
- ejsDefineCMethod(ep, gcClass, "getAllocatedMemory", allocatedMemoryProc,
- flags);
- ejsDefineCMethod(ep, gcClass, "getMprMemory", mprMemoryProc, flags);
- ejsDefineCMethod(ep, gcClass, "getPeakMprMemory", peakMprMemoryProc, flags);
- ejsDefineCMethod(ep, gcClass, "debug", debugProc, flags);
-
-#if (WIN || BREW_SIMULATOR) && BLD_DEBUG
- ejsDefineCMethod(ep, gcClass, "check", checkProc, flags);
-#endif
-
- ejsDefineCAccessors(ep, gcClass, "debugLevel",
- getDebugLevel, setDebugLevel, flags);
-
- ejsDefineCAccessors(ep, gcClass, "enable",
- getEnable, setEnable, flags);
-
- ejsDefineCAccessors(ep, gcClass, "demandCollect",
- getDemandCollect, setDemandCollect, flags);
-
- ejsDefineCAccessors(ep, gcClass, "idleCollect",
- getIdleCollect, setIdleCollect, flags);
-
- ejsDefineCAccessors(ep, gcClass, "workQuota",
- getWorkQuota, setWorkQuota, flags);
-
- ejsDefineCAccessors(ep, gcClass, "maxMemory",
- getMaxMemory, setMaxMemory, flags);
-
- return ejsObjHasErrors(gcClass) ? MPR_ERR_CANT_INITIALIZE : 0;
-}
-
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/ejsGlobal.c b/source4/lib/appweb/ejs-2.0/ejs/system/ejsGlobal.c
deleted file mode 100755
index 6ab8f867e1..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/ejsGlobal.c
+++ /dev/null
@@ -1,785 +0,0 @@
-/*
- * @file ejsGlobal.c
- * @brief EJS support methods
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-#if BLD_FEATURE_EJS
-
-/******************************************************************************/
-/************************************* Code ***********************************/
-/******************************************************************************/
-/*
- * assert(condition)
- */
-
-static int assertProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- int b;
-
- if (argc < 1) {
- ejsError(ep, EJS_ARG_ERROR, "usage: assert(condition)");
- return -1;
- }
- b = ejsVarToBoolean(argv[0]);
- if (b == 0) {
- ejsError(ep, EJS_ASSERT_ERROR, "Assertion failure at line %d",
- ejsGetLineNumber(ep));
- return -1;
- }
- ejsWriteVarAsBoolean(ep, ep->result, b);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * breakpoint(msg)
- */
-
-static int breakpointProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- char *buf;
-
- if (argc < 1) {
- return 0;
- }
- buf = ejsVarToString(ep, argv[0]);
- if (buf) {
- mprBreakpoint(0, buf);
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * basename(path)
- */
-
-static int basenameProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- char *path;
-
- if (argc != 1) {
- ejsError(ep, EJS_ARG_ERROR, "usage: basename(path)");
- return -1;
- }
-
- path = ejsVarToString(ep, argv[0]);
- if (path == 0) {
- return MPR_ERR_MEMORY;
- }
- ejsSetReturnValueToString(ep, mprGetBaseName(path));
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * stripext(path)
- */
-
-static int stripextProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- char *cp, *path, *stripPath;
-
- if (argc != 1) {
- ejsError(ep, EJS_ARG_ERROR, "usage: stripext(path)");
- return -1;
- }
-
- path = ejsVarToString(ep, argv[0]);
- if (path == 0) {
- return MPR_ERR_MEMORY;
- }
- stripPath = mprStrdup(ep, path);
-
- if ((cp = strrchr(stripPath, '.')) != 0) {
- *cp = '\0';
- }
-
- ejsSetReturnValueToString(ep, stripPath);
-
- mprFree(stripPath);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * dirname(path)
- */
-
-static int dirnameProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- char *path;
- char dirname[MPR_MAX_FNAME];
-
- if (argc != 1) {
- ejsError(ep, EJS_ARG_ERROR, "usage: dirname(path)");
- return -1;
- }
-
- path = ejsVarToString(ep, argv[0]);
- if (path == 0) {
- return MPR_ERR_MEMORY;
- }
-
- ejsSetReturnValueToString(ep,
- mprGetDirName(dirname, sizeof(dirname), path));
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * trim(string) -- trim white space
- */
-
-static int trimProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- char *str, *buf, *cp;
-
- if (argc != 1) {
- ejsError(ep, EJS_ARG_ERROR, "usage: trim(string)");
- return -1;
- }
-
- str = ejsVarToString(ep, argv[0]);
- if (str == 0) {
- return MPR_ERR_MEMORY;
- }
- str = buf = mprStrdup(ep, str);
-
- while (isspace(*str)) {
- str++;
- }
- cp = &str[strlen(str) - 1];
- while (cp >= str) {
- if (isspace(*cp)) {
- *cp = '\0';
- } else {
- break;
- }
- cp--;
- }
-
- ejsSetReturnValueToString(ep, str);
-
- mprFree(buf);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Terminate the script
- */
-
-static int exitScript(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- int status;
-
- if (argc != 1) {
- ejsError(ep, EJS_ARG_ERROR, "usage: exit(status)");
- return -1;
- }
- status = (int) ejsVarToInteger(argv[0]);
- ejsExit(ep, status);
-
- ejsWriteVarAsString(ep, ep->result, "");
- return 0;
-}
-
-/******************************************************************************/
-/*
- * include javascript libraries.
- */
-
-static int includeProc(Ejs *ep, EjsVar *thisObj, int argc, char **argv)
-{
- int i;
-
- mprAssert(argv);
-
- for (i = 0; i < argc; i++) {
- if (ejsEvalFile(ep, argv[i], 0) < 0) {
- return -1;
- }
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * include javascript libraries at the global level
- */
-
-static int includeGlobalProc(Ejs *ep, EjsVar *thisObj, int argc, char **argv)
-{
- int fid, i;
-
- mprAssert(argv);
-
- /*
- * Create a new block and set the context to be the global scope
- */
- fid = ejsSetBlock(ep, ep->global);
-
- for (i = 0; i < argc; i++) {
- if (ejsEvalFile(ep, argv[i], 0) < 0) {
- ejsCloseBlock(ep, fid);
- return -1;
- }
- }
- ejsCloseBlock(ep, fid);
- return 0;
-}
-
-/******************************************************************************/
-#if BLD_DEBUG
-/*
- * Print variables to stdout
- */
-
-static int printvProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- EjsVar *vp;
- char *buf;
- int i;
-
- for (i = 0; i < argc; ) {
- vp = argv[i++];
-
- /* mprPrintf(ep, "arg[%d] = ", i); */
-
- buf = ejsVarToString(ep, vp);
-
- if (vp->propertyName == 0 || *vp->propertyName == '\0') {
- mprPrintf(ep, "%s: ", buf);
-
- } else if (i < argc) {
- mprPrintf(ep, "%s = %s, ", vp->propertyName, buf);
- } else {
- mprPrintf(ep, "%s = %s\n", vp->propertyName, buf);
- }
- }
- return 0;
-}
-
-#endif
-/******************************************************************************/
-/*
- * Print the args to stdout
- */
-
-static int printProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- char *buf;
- int i;
-
- for (i = 0; i < argc; i++) {
- buf = ejsVarToString(ep, argv[i]);
- mprPrintf(ep, "%s", buf);
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * println
- */
-
-static int printlnProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- printProc(ep, thisObj, argc, argv);
- mprPrintf(ep, "\n");
- return 0;
-}
-
-/******************************************************************************/
-#if FUTURE
-/*
- * sprintf
- */
-
-static int sprintfProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- va_list ap;
- char *buf;
- void **args;
- int result;
-
- if (argc <= 1) {
- ejsError(ep, EJS_ARG_ERROR, "Usage: sprintf(fmt, [args ...])");
- return -1;
- }
-
- args = mprAlloc(ep, sizeof(void*) * (argc - 1));
- if (args == 0) {
- mprAssert(args);
- return -1;
- }
-
- for (i = 1; i < argc; i++) {
- args[i - 1] = argv[i]);
- }
-
- va_start(ap, fmt);
- *buf = 0;
- result = inner(0, &buf, MPR_MAX_STRING, fmt, args);
- va_end(ap);
-
- ejsSetReturnValueToString(ep, buf);
-
- mprFree(buf);
- return 0;
-}
-
-/******************************************************************************/
-
-inner(const char *fmt, void **args)
-{
- va_list ap;
-
- va_start(ap, fmt);
- *buf = 0;
- mprSprintfCore(ctx, &buf, maxSize, fmt, ap, MPR_PRINTF_ARGV);
- va_end(ap);
-}
-
-#endif
-/******************************************************************************/
-/*
- * sleep
- */
-
-static int sleepProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (argc != 1) {
- ejsError(ep, EJS_ARG_ERROR, "Usage: sleep(milliseconds)");
- return -1;
- }
- mprSleep(ep, ejsVarToInteger(argv[0]));
- return 0;
-}
-
-/******************************************************************************/
-/*
- * sort properties
- * FUTURE -- should have option to sort object based on a given property value
- * ascending or descending
- * Usage: sort(object, order = ascending, property = 0);
- */
-
-static int sortProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- const char *property;
- int error, order;
-
- error = 0;
- property = 0;
-
- /*
- * Default order is increasing
- */
- order = 1;
-
- if (argc < 1 || argc > 3 || !ejsVarIsObject(argv[0])) {
- error++;
- }
-
- if (argc >= 2) {
- order = ejsVarToInteger(argv[1]);
- }
-
- /*
- * If property is not defined, it sorts the properties in the object
- */
- if (argc == 3) {
- if (! ejsVarIsString(argv[2])) {
- error++;
- } else {
- property = argv[2]->string;
- }
- }
-
- if (error) {
- ejsError(ep, EJS_ARG_ERROR, "Usage: sort(object, [order], [property])");
- return -1;
- }
- ejsSortProperties(ep, argv[0], 0, property, order);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Get a time mark
- * MOB -- WARNING: this can overflow. OK on BREW, but other O/Ss it may have
- * overflowed on the first call. It should be renamed.
- * MOB -- replace with proper Date.
- */
-
-static int timeProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- MprTime now;
-
- mprGetTime(ep, &now);
-#if WIN || LINUX || SOLARIS
-{
- /* MOB -- poor hack */
- static MprTime initial;
- if (initial.sec == 0) {
- initial = now;
- }
- now.sec -= initial.sec;
-
- if (initial.msec > now.msec) {
- now.msec = now.msec + 1000 - initial.msec;
- now.sec--;
- } else {
- now.msec -= initial.msec;
- }
-}
-#endif
- /* MOB -- this can overflow */
- ejsSetReturnValueToInteger(ep, now.sec * 1000 + now.msec);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * MOB -- Temporary Get the date (time since Jan 6, 1980 GMT
- */
-
-static int dateProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
-#if BREW
- uint now;
-
- now = GETTIMESECONDS();
- ejsSetReturnValueToInteger(ep, now);
-#endif
- return 0;
-}
-
-/******************************************************************************/
-/*
- * strlen(string)
- */
-
-static int strlenProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- char *buf;
- int len;
-
- if (argc != 1) {
- ejsError(ep, EJS_ARG_ERROR, "Usage: strlen(var)");
- return -1;
- }
-
- len = 0;
- if (! ejsVarIsString(argv[0])) {
- buf = ejsVarToString(ep, argv[0]);
- if (buf) {
- len = strlen(buf);
- }
-
- } else {
- len = argv[0]->length;
- }
-
- ejsSetReturnValueToInteger(ep, len);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * toint(num)
- */
-
-static int tointProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- int i;
-
- if (argc != 1) {
- ejsError(ep, EJS_ARG_ERROR, "Usage: toint(number)");
- return -1;
- }
-
- i = ejsVarToInteger(argv[0]);
-
- ejsSetReturnValueToInteger(ep, i);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * string strstr(string, pat)
- */
-
-static int strstrProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- char *str, *pat;
- char *s;
- int strAlloc;
-
- if (argc != 2) {
- ejsError(ep, EJS_ARG_ERROR, "Usage: strstr(string, pat)");
- return -1;
- }
-
- str = ejsVarToString(ep, argv[0]);
-
- strAlloc = ep->castAlloc;
- ep->castTemp = 0;
-
- pat = ejsVarToString(ep, argv[1]);
-
- s = strstr(str, pat);
-
- if (s == 0) {
- ejsSetReturnValueToUndefined(ep);
- } else {
- ejsSetReturnValueToString(ep, s);
- }
-
- if (strAlloc) {
- mprFree(str);
- }
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Trace
- */
-
-static int traceProc(Ejs *ep, EjsVar *thisObj, int argc, char **argv)
-{
- if (argc == 1) {
- mprLog(ep, 0, "%s", argv[0]);
-
- } else if (argc == 2) {
- mprLog(ep, atoi(argv[0]), "%s", argv[1]);
-
- } else {
- ejsError(ep, EJS_ARG_ERROR, "Usage: trace([level], message)");
- return -1;
- }
- ejsWriteVarAsString(ep, ep->result, "");
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Evaluate a sub-script. It is evaluated in the same variable scope as
- * the calling script / method.
- */
-
-static int evalScriptProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- EjsVar *arg;
- int i;
-
- ejsWriteVarAsUndefined(ep, ep->result);
-
- for (i = 0; i < argc; i++) {
- arg = argv[i];
- if (arg->type != EJS_TYPE_STRING) {
- continue;
- }
- if (ejsEvalScript(ep, arg->string, 0) < 0) {
- return -1;
- }
- }
- /*
- * Return with the value of the last expression
- */
- return 0;
-}
-
-/******************************************************************************/
-
-/* MOB -- need a real datatype returning int, int64, etc */
-
-static int typeofProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- const struct {
- EjsType type;
- const char *name;
- } types[] = {
- { EJS_TYPE_UNDEFINED, "undefined" },
-#if EJS_ECMA_STND
- { EJS_TYPE_NULL, "object" },
-#else
- { EJS_TYPE_NULL, "null" },
-#endif
- { EJS_TYPE_BOOL, "boolean" },
- { EJS_TYPE_CMETHOD, "function" },
- { EJS_TYPE_FLOAT, "number" },
- { EJS_TYPE_INT, "number" },
- { EJS_TYPE_INT64, "number" },
- { EJS_TYPE_OBJECT, "object" },
- { EJS_TYPE_METHOD, "function" },
- { EJS_TYPE_STRING, "string" },
- { EJS_TYPE_STRING_CMETHOD, "function" },
- { EJS_TYPE_PTR, "pointer" }
- };
- const char *type;
- int i;
-
- type = NULL;
- if (argc != 1) {
- ejsError(ep, EJS_ARG_ERROR, "Bad args: typeof(var)");
- return -1;
- }
-
- for (i = 0; i < MPR_ARRAY_SIZE(types); i++) {
- if (argv[0]->type == types[i].type) {
- type = types[i].name;
- break;
- }
- }
- if (type == NULL) {
- mprAssert(type);
- return -1;
- }
-
- ejsSetReturnValueToString(ep, type);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Define the standard properties and methods inherited by all interpreters
- * Obj is set to the global class in the default interpreter. When an
- * interpreter attempts to write to any property, a copy will be written
- * into the interpeters own global space. This is like a "copy-on-write".
- */
-
-int ejsDefineGlobalProperties(Ejs *ep)
-{
- EjsVar *obj;
-
- obj = ep->service->globalClass;
- mprAssert(obj);
-
- ejsSetPropertyToNull(ep, obj, "null");
- ejsSetPropertyToUndefined(ep, obj, "undefined");
- ejsSetPropertyToBoolean(ep, obj, "true", 1);
- ejsSetPropertyToBoolean(ep, obj, "false", 0);
-
-#if BLD_FEATURE_FLOATING_POINT
- {
- /* MOB. Fix. This generates warnings on some systems.
- This is intended. */
- double d = 0.0;
- double e = 0.0;
- ejsSetPropertyToFloat(ep, obj, "NaN", e / d);
-
- d = MAX_FLOAT;
- ejsSetPropertyToFloat(ep, obj, "Infinity", d * d);
- }
-#endif
-
-#if BLD_FEATURE_LEGACY_API
- /*
- * DEPRECATED: 2.0.
- * So that ESP/ASP can ignore "language=javascript" statements
- */
- ejsSetPropertyToInteger(ep, obj, "javascript", 0);
-#endif
-
- /*
- * Extension methods. We go directly to the mpr property APIs for speed.
- * Flags will cause the callbacks to be supplied the Ejs handle.
- */
- ejsDefineCMethod(ep, obj, "assert", assertProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "breakpoint", breakpointProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "basename", basenameProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "dirname", dirnameProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "stripext", stripextProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "trim", trimProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "eval", evalScriptProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "exit", exitScript, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "print", printProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "println", printlnProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "sleep", sleepProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "sort", sortProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "time", timeProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "date", dateProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "strlen", strlenProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "strstr", strstrProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "typeof", typeofProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "toint", tointProc, EJS_NO_LOCAL);
-
- ejsDefineStringCMethod(ep, obj, "include", includeProc, EJS_NO_LOCAL);
- ejsDefineStringCMethod(ep, obj, "includeGlobal", includeGlobalProc,
- EJS_NO_LOCAL);
- ejsDefineStringCMethod(ep, obj, "trace", traceProc, EJS_NO_LOCAL);
-
-#if BLD_DEBUG
- ejsDefineCMethod(ep, obj, "printv", printvProc, EJS_NO_LOCAL);
-#endif
-
-#if FUTURE
- ejsDefineCMethod(ep, obj, "printf", printfProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, obj, "sprintf", sprintfProc, EJS_NO_LOCAL);
-#endif
-
- if (ejsObjHasErrors(obj)) {
- return MPR_ERR_CANT_INITIALIZE;
- }
- return 0;
-}
-
-/******************************************************************************/
-
-#else
-void ejsProcsDummy() {}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_EJS */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystem.c b/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystem.c
deleted file mode 100644
index e035e1c740..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystem.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * @file ejsSystem.c
- * @brief System class for the EJS Object Model
- */
-/********************************** Copyright *********************************/
-/*
- * Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved.
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-/******************************************************************************/
-/************************************ Methods *********************************/
-/******************************************************************************/
-#if UNUSED
-/*
- * function int random()
- */
-
-static int randomProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsTrace(ep, "random()\n");
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function void yield()
- */
-
-static int yieldProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsTrace(ep, "yield()\n");
- return 0;
-}
-
-/******************************************************************************/
-/*
- * function void sleep(int milliSeconds)
- */
-
-static int sleepProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsTrace(ep, "sleep()\n");
- return 0;
-}
-
-#endif
-/******************************************************************************/
-/*
- * function void exit(int status)
- *
- * Exit the widget with the given status. All JavaScript processing ceases.
- */
-
-static int exitProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- int status;
-
- status = 0;
- if ((argc == 1) && ejsVarIsInteger(argv[0])) {
- status = argv[0]->integer;
- }
- ejsExit(ep, status);
- return 0;
-}
-
-/******************************************************************************/
-/******************************** Initialization ******************************/
-/******************************************************************************/
-
-int ejsDefineSystemClass(Ejs *ep)
-{
- EjsVar *systemClass;
-
- /*
- * We create the system class and define static methods on it.
- * NOTE: There is no object instance
- */
- systemClass = ejsDefineClass(ep, "System", "Object", 0);
- if (systemClass == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
-
- ejsDefineCMethod(ep, systemClass, "exit", exitProc, EJS_NO_LOCAL);
-
-#if UNUSED
- ejsDefineCMethod(ep, systemClass, "random", randomProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, systemClass, "yield", yieldProc, EJS_NO_LOCAL);
- ejsDefineCMethod(ep, systemClass, "sleep", sleepProc, EJS_NO_LOCAL);
-
- /*
- * Define properties
- */
- ejsSetPropertyToString(systemClass, "name", "");
-#endif
-
- return ejsObjHasErrors(systemClass) ? MPR_ERR_CANT_INITIALIZE : 0;
-}
-
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemApp.c b/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemApp.c
deleted file mode 100644
index e2f1ceb363..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemApp.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * @file ejsSystemApp.c
- * @brief App class
- */
-/********************************** Copyright *********************************/
-/*
- * Copyright (c) Mbedthis Software Inc, 2005-2006. All Rights Reserved.
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-/************************************ Code ************************************/
-
-int ejsDefineAppClass(Ejs *ep)
-{
- EjsVar *appClass;
-
- appClass = ejsDefineClass(ep, "System.App", "Object", 0);
- if (appClass == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
-
- /*
- * Define properties
- */
- ejsSetPropertyToString(ep, appClass, "name", BLD_PRODUCT);
- ejsSetPropertyToString(ep, appClass, "title", BLD_NAME);
- ejsSetPropertyToString(ep, appClass, "version", BLD_VERSION);
-
- /*
- * Command line arguments
- */
- ejsSetPropertyToNull(ep, appClass, "args");
-
- return ejsObjHasErrors(appClass) ? MPR_ERR_CANT_INITIALIZE : 0;
-}
-
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemDebug.c b/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemDebug.c
deleted file mode 100644
index 5a011e2a2d..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemDebug.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * @file ejsSystemDebug.c
- * @brief System.Debug class
- */
-/********************************** Copyright *********************************/
-/*
- * Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved.
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-/******************************************************************************/
-/************************************ Methods *********************************/
-/******************************************************************************/
-/*
- * function bool isDebugMode()
- * MOB -- convert to accessor
- */
-
-static int isDebugMode(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsTrace(ejs, "isDebugMode()\n");
- ejsSetReturnValueToInteger(ejs, mprGetDebugMode(ejs));
- return 0;
-}
-
-/******************************************************************************/
-/******************************** Initialization ******************************/
-/******************************************************************************/
-
-int ejsDefineDebugClass(Ejs *ejs)
-{
- EjsVar *systemDebugClass;
-
- systemDebugClass = ejsDefineClass(ejs, "System.Debug", "Object", 0);
- if (systemDebugClass == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
-
- /*
- * Define the class methods
- */
- ejsDefineCMethod(ejs, systemDebugClass, "isDebugMode", isDebugMode,
- EJS_NO_LOCAL);
-
- return ejsObjHasErrors(systemDebugClass) ? MPR_ERR_CANT_INITIALIZE : 0;
-}
-
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemLog.c b/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemLog.c
deleted file mode 100644
index 66467f8fcf..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemLog.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * @file ejsSystemLog.c
- * @brief System.Log class for the EJS Object Model
- */
-/********************************** Copyright *********************************/
-/*
- * Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved.
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-/*********************************** Usage ************************************/
-/*
- * System.Log.setLog(path);
- * System.Log.enable;
- */
-/******************************************************************************/
-
-static void logHandler(MPR_LOC_DEC(ctx, loc), int flags, int level,
- const char *msg)
-{
- MprApp *app;
- char *buf;
- int len;
-
- app = mprGetApp(ctx);
- if (app->logFile == 0) {
- return;
- }
-
- if (flags & MPR_LOG_SRC) {
- len = mprAllocSprintf(MPR_LOC_PASS(ctx, loc), &buf, 0,
- "Log %d: %s\n", level, msg);
-
- } else if (flags & MPR_ERROR_SRC) {
- len = mprAllocSprintf(MPR_LOC_PASS(ctx, loc), &buf, 0,
- "Error: %s\n", msg);
-
- } else if (flags & MPR_FATAL_SRC) {
- len = mprAllocSprintf(MPR_LOC_PASS(ctx, loc), &buf, 0,
- "Fatal: %s\n", msg);
-
- } else if (flags & MPR_ASSERT_SRC) {
-#if BLD_FEATURE_ALLOC_LEAK_TRACK
- len = mprAllocSprintf(MPR_LOC_PASS(ctx, loc), &buf, 0,
- "Assertion %s, failed at %s\n",
- msg, loc);
-#else
- len = mprAllocSprintf(MPR_LOC_PASS(ctx, loc), &buf, 0,
- "Assertion %s, failed\n", msg);
-#endif
-
- } else if (flags & MPR_RAW) {
- /* OPT */
- len = mprAllocSprintf(MPR_LOC_PASS(ctx, loc), &buf, 0,
- "%s", msg);
-
- } else {
- return;
- }
-
- mprPuts(app->logFile, buf, len);
-
- mprFree(buf);
-}
-
-/******************************************************************************/
-/************************************ Methods *********************************/
-/******************************************************************************/
-/*
- * function int setLog(string path)
- */
-
-static int setLog(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- const char *path;
- MprFile *file;
- MprApp *app;
-
- if (argc != 1 || !ejsVarIsString(argv[0])) {
- ejsArgError(ejs, "Usage: setLog(path)");
- return -1;
- }
-
- app = mprGetApp(ejs);
-
- /*
- * Ignore errors if we can't create the log file.
- * Use the app context so this will live longer than the interpreter
- * MOB -- this leaks files.
- */
- path = argv[0]->string;
- file = mprOpen(app, path, O_CREAT | O_TRUNC | O_WRONLY, 0664);
- if (file) {
- app->logFile = file;
- mprSetLogHandler(ejs, logHandler);
- }
- mprLog(ejs, 0, "Test log");
-
- return 0;
-}
-
-/******************************************************************************/
-#if UNUSED
-
-static int enableSetAccessor(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- if (argc != 1) {
- ejsArgError(ejs, "Usage: set(value)");
- return -1;
- }
- ejsSetProperty(ejs, thisObj, "_enabled", argv[0]);
- return 0;
-}
-
-/******************************************************************************/
-
-static int enableGetAccessor(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsSetReturnValue(ejs, ejsGetPropertyAsVar(ejs, thisObj, "_enabled"));
- return 0;
-}
-
-#endif
-/******************************************************************************/
-/******************************** Initialization ******************************/
-/******************************************************************************/
-
-int ejsDefineLogClass(Ejs *ejs)
-{
- EjsVar *logClass;
-
- logClass = ejsDefineClass(ejs, "System.Log", "Object", 0);
- if (logClass == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
-
- ejsDefineCMethod(ejs, logClass, "setLog", setLog, EJS_NO_LOCAL);
-
-#if UNUSED
- EjsProperty *pp;
- ejsDefineCAccessors(ejs, logClass, "enable", enableSetAccessor,
- enableGetAccessor, EJS_NO_LOCAL);
-
- pp = ejsSetPropertyToBoolean(ejs, logClass, "_enabled", 0);
- ejsMakePropertyEnumerable(pp, 0);
-#endif
-
- return ejsObjHasErrors(logClass) ? MPR_ERR_CANT_INITIALIZE : 0;
-}
-
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemMemory.c b/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemMemory.c
deleted file mode 100755
index d10787b1b4..0000000000
--- a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemMemory.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * @file ejsSystemMemory.c
- * @brief System.Memory class
- */
-/********************************** Copyright *********************************/
-/*
- * Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved.
- */
-/********************************** Includes **********************************/
-
-#include "ejs.h"
-
-/****************************** Forward Declarations***************************/
-
-static uint getUsedMemory(Ejs *ejs);
-
-/******************************************************************************/
-/*********************************** Methods *********************************/
-/******************************************************************************/
-
-static int getUsedMemoryProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsSetReturnValueToInteger(ejs, getUsedMemory(ejs));
- return 0;
-}
-
-/******************************************************************************/
-
-static int getUsedStackProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
-{
- ejsSetReturnValueToInteger(ejs, mprStackSize(ejs));
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Public function
- */
-
-uint ejsGetAvailableMemory(Ejs *ejs)
-{
- EjsVar *memoryClass;
- uint ram;
-
- memoryClass = ejsGetClass(ejs, 0, "System.Memory");
-
- ram = ejsGetPropertyAsInteger(ejs, memoryClass, "ram");
- return ram - getUsedMemory(ejs);
-}
-
-/******************************************************************************/
-
-static int getAvailableMemoryProc(Ejs *ejs, EjsVar *thisObj, int argc,
- EjsVar **argv)
-{
- EjsVar *memoryClass;
- uint ram;
-
- memoryClass = ejsGetClass(ejs, 0, "System.Memory");
-
- ram = ejsGetPropertyAsInteger(ejs, memoryClass, "ram");
-#if BREW
- ejsSetReturnValueToInteger(ejs, ram - getUsedMemory(ejs));
-#else
- ejsSetReturnValueToInteger(ejs, 0);
-#endif
- return 0;
-}
-
-/******************************************************************************/
-
-static uint getUsedMemory(Ejs *ejs)
-{
-#if BREW
- MprApp *app;
- IHeap *heap;
- uint memInUse;
- void *ptr;
-
- app = mprGetApp(ejs);
- ptr = (void*) &heap;
- if (ISHELL_CreateInstance(app->shell, AEECLSID_HEAP, (void**) ptr)
- == SUCCESS) {
- memInUse = IHEAP_GetMemStats(heap);
- IHEAP_Release(heap);
- } else {
- memInUse = 0;
- }
-
- return memInUse;
-#else
- return 0;
-#endif
-}
-
-/******************************************************************************/
-/******************************** Initialization ******************************/
-/******************************************************************************/
-
-int ejsDefineMemoryClass(Ejs *ejs)
-{
- EjsVar *memoryClass;
- uint used;
-
-#if BREW
- MprApp *app;
- AEEDeviceInfo *info;
-
- /*
- * Get needed information for class properties.
- */
- info = mprAllocType(ejs, AEEDeviceInfo);
- if (info == 0) {
- return MPR_ERR_CANT_ALLOCATE;
- }
- info->wStructSize = sizeof(AEEDeviceInfo);
- app = mprGetApp(ejs);
- ISHELL_GetDeviceInfo(app->shell, info);
- used = getUsedMemory(ejs);
-#else
- used = 0;
-#endif
-
- /*
- * Create the class
- */
- memoryClass = ejsDefineClass(ejs, "System.Memory", "Object", 0);
- if (memoryClass == 0) {
- return MPR_ERR_CANT_INITIALIZE;
- }
-
- /*
- * Define the class methods
- * MOB -- change to accessors
- */
- ejsDefineCMethod(ejs, memoryClass, "getUsedStack", getUsedStackProc,
- EJS_NO_LOCAL);
- ejsDefineCMethod(ejs, memoryClass, "getUsedMemory", getUsedMemoryProc,
- EJS_NO_LOCAL);
- ejsDefineCMethod(ejs, memoryClass, "getAvailableMemory",
- getAvailableMemoryProc, EJS_NO_LOCAL);
-
- /*
- * Define properties
- */
-#if BREW
- ejsSetPropertyToInteger(ejs, memoryClass, "ram", info->dwRAM);
-
-#if UNUSED
- /* MOB -- delete this */
- ejsSetPropertyToInteger(ejs, memoryClass, "available",
- info->dwRAM - used);
-#endif
-#endif
-
-#if UNUSED
- ejsSetPropertyToInteger(ejs, memoryClass, "used", used);
- ejsSetPropertyToInteger(ejs, memoryClass, "flash", 0);
-#endif
-
- return ejsObjHasErrors(memoryClass) ? MPR_ERR_CANT_INITIALIZE : 0;
-}
-
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/exml/Makefile b/source4/lib/appweb/ejs-2.0/exml/Makefile
deleted file mode 100644
index 663e65ed53..0000000000
--- a/source4/lib/appweb/ejs-2.0/exml/Makefile
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Makefile for Embedded XML (EXML)
-#
-# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
-#
-
-#
-# EXML may be linked into shared handlers so we must build the objects both
-# shared and static.
-#
-COMPILE := *.c
-EXPORT_OBJECTS := yes
-MAKE_IFLAGS := -I../mpr
-
-include make.dep
-
-ifeq ($(BLD_FEATURE_TEST),1)
-POST_DIRS := test
-endif
-
-TARGETS += $(BLD_BIN_DIR)/libexml$(BLD_LIB)
-
-ifeq ($(BLD_FEATURE_XML),1)
-compileExtra: $(TARGETS)
-endif
-
-# MOB -- remove when FEATURE_XML is defined
-compileExtra: $(TARGETS)
-
-$(BLD_BIN_DIR)/libexml$(BLD_LIB): $(FILES)
- @bld --library $(BLD_BIN_DIR)/libexml \
- --objectsDir $(BLD_OBJ_DIR) --objectList files --libs mpr
-
-cleanExtra:
- @echo "rm -f $(TARGETS)" | $(BLDOUT)
- @rm -f $(TARGETS)
- @rm -f $(BLD_BIN_DIR)/libexml.*
-
-## Local variables:
-## tab-width: 4
-## End:
-## vim: tw=78 sw=4 ts=4
diff --git a/source4/lib/appweb/ejs-2.0/exml/exml.h b/source4/lib/appweb/ejs-2.0/exml/exml.h
deleted file mode 100644
index 44c50a56b9..0000000000
--- a/source4/lib/appweb/ejs-2.0/exml/exml.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * exml.h -- Embedded Xml Parser header
- *
- * Copyright (c) Mbedthis Software, LLC, 2003-2003. All Rights Reserved. -- MOB
- */
-
-#ifndef _h_EXML
-#define _h_EXML 1
-
-/******************************** Description *********************************/
-
-#include "mpr.h"
-
-/********************************** Defines ***********************************/
-
-#if BLD_FEATURE_SQUEEZE
- #define EXML_BUFSIZE 512 /* Read buffer size */
-#else
- #define EXML_BUFSIZE 1024 /* Read buffer size */
-#endif
-
-/*
- * XML parser states. The states that are passed to the user handler have
- * "U" appended to the comment. The error states (ERR and EOF) must be
- * negative.
- */
-#define EXML_ERR -1 /* Error */
-#define EXML_EOF -2 /* End of input */
-#define EXML_BEGIN 1 /* Before next tag */
-#define EXML_AFTER_LS 2 /* Seen "<" */
-#define EXML_COMMENT 3 /* Seen "<!--" (usr) U */
-#define EXML_NEW_ELT 4 /* Seen "<tag" (usr) U */
-#define EXML_ATT_NAME 5 /* Seen "<tag att" */
-#define EXML_ATT_EQ 6 /* Seen "<tag att" = */
-#define EXML_NEW_ATT 7 /* Seen "<tag att = "val" U */
-#define EXML_SOLO_ELT_DEFINED 8 /* Seen "<tag../>" U */
-#define EXML_ELT_DEFINED 9 /* Seen "<tag...>" U */
-#define EXML_ELT_DATA 10 /* Seen "<tag>....<" U */
-#define EXML_END_ELT 11 /* Seen "<tag>....</tag>" U */
-#define EXML_PI 12 /* Seen "<?processingInst" U */
-#define EXML_CDATA 13 /* Seen "<![CDATA[" U */
-
-/*
- * Lex tokens
- */
-typedef enum ExmlToken {
- TOKEN_ERR,
- TOKEN_TOO_BIG, /* Token is too big */
- TOKEN_CDATA,
- TOKEN_COMMENT,
- TOKEN_INSTRUCTIONS,
- TOKEN_LS, /* "<" -- Opening a tag */
- TOKEN_LS_SLASH, /* "</" -- Closing a tag */
- TOKEN_GR, /* ">" -- End of an open tag */
- TOKEN_SLASH_GR, /* "/>" -- End of a solo tag */
- TOKEN_TEXT,
- TOKEN_EQ,
- TOKEN_EOF,
- TOKEN_SPACE,
-} ExmlToken;
-
-struct Exml;
-typedef int (*ExmlHandler)(struct Exml *xp, int state,
- const char *tagName, const char* attName, const char* value);
-typedef int (*ExmlInputStream)(struct Exml *xp, void *arg, char *buf, int size);
-
-/*
- * Per XML session structure
- */
-typedef struct Exml {
- ExmlHandler handler; /* Callback function */
- ExmlInputStream readFn; /* Read data function */
- MprBuf *inBuf; /* Input data queue */
- MprBuf *tokBuf; /* Parsed token buffer */
- int quoteChar; /* XdbAtt quote char */
- int lineNumber; /* Current line no for debug */
- void *parseArg; /* Arg passed to exmlParse() */
- void *inputArg; /* Arg passed to exmlSetInputStream() */
- char *errMsg; /* Error message text */
-} Exml;
-
-extern Exml *exmlOpen(MprCtx ctx, int initialSize, int maxSize);
-extern void exmlClose(Exml *xp);
-extern void exmlSetParserHandler(Exml *xp, ExmlHandler h);
-extern void exmlSetInputStream(Exml *xp, ExmlInputStream s, void *arg);
-extern int exmlParse(Exml *xp);
-extern void exmlSetParseArg(Exml *xp, void *parseArg);
-extern void *exmlGetParseArg(Exml *xp);
-extern const char *exmlGetErrorMsg(Exml *xp);
-extern int exmlGetLineNumber(Exml *xp);
-
-/******************************************************************************/
-
-#endif /* _h_EXML */
diff --git a/source4/lib/appweb/ejs-2.0/exml/exmlParser.c b/source4/lib/appweb/ejs-2.0/exml/exmlParser.c
deleted file mode 100644
index 14871411a6..0000000000
--- a/source4/lib/appweb/ejs-2.0/exml/exmlParser.c
+++ /dev/null
@@ -1,752 +0,0 @@
-/*
- * exml.c -- A simple SAX style XML parser
- */
-
-/********************************* Description ********************************/
-/*
- * This is a recursive descent parser for XML text files. It is a one-pass
- * simple parser that invokes a user supplied callback for key tokens in the
- * XML file. The user supplies a read function so that XML files can be parsed
- * from disk or in-memory.
- */
-/********************************** Includes **********************************/
-
-#include "exml.h"
-
-/****************************** Forward Declarations **************************/
-/* MOB -- FIX */
-#if BLD_FEATURE_EXML || 1
-
-static int parseNext(Exml *xp, int state);
-static ExmlToken getToken(Exml *xp, int state);
-static int getNextChar(Exml *xp);
-static int scanFor(Exml *xp, char *str);
-static int putLastChar(Exml *xp, int c);
-static void error(Exml *xp, char *fmt, ...);
-static void trimToken(Exml *xp);
-
-/************************************ Code ************************************/
-
-Exml *exmlOpen(MprCtx ctx, int initialSize, int maxSize)
-{
- Exml *xp;
-
- xp = mprAllocTypeZeroed(ctx, Exml);
-
- xp->inBuf = mprCreateBuf(xp, EXML_BUFSIZE, EXML_BUFSIZE);
- xp->tokBuf = mprCreateBuf(xp, initialSize, maxSize);
-
- return xp;
-}
-
-/******************************************************************************/
-
-void exmlClose(Exml *xp)
-{
- mprAssert(xp);
-
- mprFree(xp);
-}
-
-/******************************************************************************/
-
-void exmlSetParserHandler(Exml *xp, ExmlHandler h)
-{
- mprAssert(xp);
-
- xp->handler = h;
-}
-
-/******************************************************************************/
-
-void exmlSetInputStream(Exml *xp, ExmlInputStream s, void *arg)
-{
- mprAssert(xp);
-
- xp->readFn = s;
- xp->inputArg = arg;
-}
-
-/******************************************************************************/
-/*
- * Set the parse arg
- */
-
-void exmlSetParseArg(Exml *xp, void *parseArg)
-{
- mprAssert(xp);
-
- xp->parseArg = parseArg;
-}
-
-/******************************************************************************/
-/*
- * Set the parse arg
- */
-
-void *exmlGetParseArg(Exml *xp)
-{
- mprAssert(xp);
-
- return xp->parseArg;
-}
-
-/******************************************************************************/
-/*
- * Parse an XML file. Return 0 for success, -1 for error.
- */
-
-int exmlParse(Exml *xp)
-{
- mprAssert(xp);
-
- return parseNext(xp, EXML_BEGIN);
-}
-
-/******************************************************************************/
-/*
- * XML parser. This is a recursive descent parser. Return -1 for errors, 0 for
- * EOF and 1 if there is still more data to parse.
- */
-
-static int parseNext(Exml *xp, int state)
-{
- ExmlHandler handler;
- ExmlToken token;
- MprBuf *tokBuf;
- char *tname, *aname;
- int rc;
-
- mprAssert(state >= 0);
-
- tokBuf = xp->tokBuf;
- handler = xp->handler;
- tname = aname = 0;
- rc = 0;
-
- /*
- * In this parse loop, the state is never assigned EOF or ERR. In
- * such cases we always return EOF or ERR.
- */
- while (1) {
-
- token = getToken(xp, state);
-
- if (token == TOKEN_TOO_BIG) {
- error(xp, "XML token is too big");
- goto err;
- }
-
- switch (state) {
- case EXML_BEGIN: /* ------------------------------------------ */
- /*
- * Expect to get an element, comment or processing instruction
- */
- switch (token) {
- case TOKEN_EOF:
- goto exit;
-
- case TOKEN_LS:
- /*
- * Recurse to handle the new element, comment etc.
- */
- rc = parseNext(xp, EXML_AFTER_LS);
- if (rc < 0) {
- goto exit;
- }
- break;
-
- default:
- error(xp, "Syntax error");
- goto err;
- }
- break;
-
- case EXML_AFTER_LS: /* ------------------------------------------ */
- switch (token) {
- case TOKEN_COMMENT:
- state = EXML_COMMENT;
- rc = (*handler)(xp, state, "!--", 0, mprGetBufStart(tokBuf));
- if (rc < 0) {
- goto err;
- }
- rc = 1;
- goto exit;
-
- case TOKEN_CDATA:
- state = EXML_CDATA;
- rc = (*handler)(xp, state, "!--", 0, mprGetBufStart(tokBuf));
- if (rc < 0) {
- goto err;
- }
- rc = 1;
- goto exit;
-
- case TOKEN_INSTRUCTIONS:
- /* Just ignore processing instructions */
- rc = 1;
- goto exit;
-
- case TOKEN_TEXT:
- state = EXML_NEW_ELT;
- tname = mprStrdup(xp, mprGetBufStart(tokBuf));
- if (tname == 0) {
- rc = MPR_ERR_MEMORY;
- goto exit;
- }
- rc = (*handler)(xp, state, tname, 0, 0);
- if (rc < 0) {
- goto err;
- }
- break;
-
- default:
- error(xp, "Syntax error");
- goto err;
- }
- break;
-
- case EXML_NEW_ELT: /* ------------------------------------------ */
- /*
- * We have seen the opening "<element" for a new element and have
- * not yet seen the terminating ">" of the opening element.
- */
- switch (token) {
- case TOKEN_TEXT:
- /*
- * Must be an attribute name
- */
- aname = mprStrdup(xp, mprGetBufStart(tokBuf));
- token = getToken(xp, state);
- if (token != TOKEN_EQ) {
- error(xp, "Missing assignment for attribute \"%s\"", aname);
- goto err;
- }
-
- token = getToken(xp, state);
- if (token != TOKEN_TEXT) {
- error(xp, "Missing value for attribute \"%s\"", aname);
- goto err;
- }
- state = EXML_NEW_ATT;
- rc = (*handler)(xp, state, tname, aname,
- mprGetBufStart(tokBuf));
- if (rc < 0) {
- goto err;
- }
- state = EXML_NEW_ELT;
- break;
-
- case TOKEN_GR:
- /*
- * This is ">" the termination of the opening element
- */
- if (*tname == '\0') {
- error(xp, "Missing element name");
- goto err;
- }
-
- /*
- * Tell the user that the opening element is now complete
- */
- state = EXML_ELT_DEFINED;
- rc = (*handler)(xp, state, tname, 0, 0);
- if (rc < 0) {
- goto err;
- }
- state = EXML_ELT_DATA;
- break;
-
- case TOKEN_SLASH_GR:
- /*
- * If we see a "/>" then this is a solo element
- */
- if (*tname == '\0') {
- error(xp, "Missing element name");
- goto err;
- }
- state = EXML_SOLO_ELT_DEFINED;
- rc = (*handler)(xp, state, tname, 0, 0);
- if (rc < 0) {
- goto err;
- }
- rc = 1;
- goto exit;
-
- default:
- error(xp, "Syntax error");
- goto err;
- }
- break;
-
- case EXML_ELT_DATA: /* -------------------------------------- */
- /*
- * We have seen the full opening element "<name ...>" and now
- * await data or another element.
- */
- if (token == TOKEN_LS) {
- /*
- * Recurse to handle the new element, comment etc.
- */
- rc = parseNext(xp, EXML_AFTER_LS);
- if (rc < 0) {
- goto exit;
- }
- break;
-
- } else if (token == TOKEN_LS_SLASH) {
- state = EXML_END_ELT;
- break;
-
- } else if (token != TOKEN_TEXT) {
- goto err;
- }
- if (mprGetBufLength(tokBuf) > 0) {
- /*
- * Pass the data between the element to the user
- */
- rc = (*handler)(xp, state, tname, 0, mprGetBufStart(tokBuf));
- if (rc < 0) {
- goto err;
- }
- }
- break;
-
- case EXML_END_ELT: /* -------------------------------------- */
- if (token != TOKEN_TEXT) {
- error(xp, "Missing closing element name for \"%s\"", tname);
- goto err;
- }
- /*
- * The closing element name must match the opening element name
- */
- if (strcmp(tname, mprGetBufStart(tokBuf)) != 0) {
- error(xp,
- "Closing element name \"%s\" does not match on line %d"
- "opening name \"%s\"",
- mprGetBufStart(tokBuf), xp->lineNumber, tname);
- goto err;
- }
- rc = (*handler)(xp, state, tname, 0, 0);
- if (rc < 0) {
- goto err;
- }
- if (getToken(xp, state) != TOKEN_GR) {
- error(xp, "Syntax error");
- goto err;
- }
- return 1;
-
- case EXML_EOF: /* ---------------------------------------------- */
- goto exit;
-
- case EXML_ERR: /* ---------------------------------------------- */
- default:
- goto err;
- }
- }
- mprAssert(0);
-
-err:
- rc = -1;
-
-exit:
- mprFree(tname);
- mprFree(aname);
-
- return rc;
-}
-
-/******************************************************************************/
-/*
- * Lexical analyser for XML. Return the next token reading input as required.
- * It uses a one token look ahead and push back mechanism (LAR1 parser).
- * Text token identifiers are left in the tokBuf parser buffer on exit.
- * This Lex has special cases for the states EXML_ELT_DATA where we
- * have an optimized read of element data, and EXML_AFTER_LS where we
- * distinguish between element names, processing instructions and comments.
- */
-
-static ExmlToken getToken(Exml *xp, int state)
-{
- MprBuf *tokBuf, *inBuf;
- uchar *cp;
- int c, rc;
-
- tokBuf = xp->tokBuf;
- inBuf = xp->inBuf;
-
- mprAssert(state >= 0);
-
- if ((c = getNextChar(xp)) < 0) {
- return TOKEN_EOF;
- }
- mprFlushBuf(tokBuf);
-
- /*
- * Special case parsing for names and for element data. We do this for
- * performance so we can return to the caller the largest token possible
- */
- if (state == EXML_ELT_DATA) {
- /*
- * Read all the data up to the start of the closing element "<" or the
- * start of a sub-element.
- */
-#if UNUSED
- while (isspace(c)) {
- if ((c = getNextChar(xp)) < 0) {
- return TOKEN_EOF;
- }
- }
-#endif
- if (c == '<') {
- if ((c = getNextChar(xp)) < 0) {
- return TOKEN_EOF;
- }
- if (c == '/') {
- return TOKEN_LS_SLASH;
- }
- putLastChar(xp, c);
- return TOKEN_LS;
- }
- do {
- if (mprPutCharToBuf(tokBuf, c) < 0) {
- return TOKEN_TOO_BIG;
- }
- if ((c = getNextChar(xp)) < 0) {
- return TOKEN_EOF;
- }
- } while (c != '<');
-
- /*
- * Put back the last look-ahead character
- */
- putLastChar(xp, c);
-
- /*
- * If all white space, then zero the token buffer
- */
- for (cp = tokBuf->start; *cp; cp++) {
- if (!isspace(*cp)) {
- return TOKEN_TEXT;
- }
- }
- mprFlushBuf(tokBuf);
- return TOKEN_TEXT;
- }
-
- while (1) {
- switch (c) {
- case ' ':
- case '\n':
- case '\t':
- case '\r':
- break;
-
- case '<':
- if ((c = getNextChar(xp)) < 0) {
- return TOKEN_EOF;
- }
- if (c == '/') {
- return TOKEN_LS_SLASH;
- }
- putLastChar(xp, c);
- return TOKEN_LS;
-
- case '=':
- return TOKEN_EQ;
-
- case '>':
- return TOKEN_GR;
-
- case '/':
- if ((c = getNextChar(xp)) < 0) {
- return TOKEN_EOF;
- }
- if (c == '>') {
- return TOKEN_SLASH_GR;
- }
- return TOKEN_ERR;
-
- case '\"':
- case '\'':
- xp->quoteChar = c;
- /* Fall through */
-
- default:
- /*
- * We handle element names, attribute names and attribute values
- * here. We do NOT handle data between elements here. Read the
- * token. Stop on white space or a closing element ">"
- */
- if (xp->quoteChar) {
- if ((c = getNextChar(xp)) < 0) {
- return TOKEN_EOF;
- }
- while (c != xp->quoteChar) {
- if (mprPutCharToBuf(tokBuf, c) < 0) {
- return TOKEN_TOO_BIG;
- }
- if ((c = getNextChar(xp)) < 0) {
- return TOKEN_EOF;
- }
- }
- xp->quoteChar = 0;
-
- } else {
- while (!isspace(c) && c != '>' && c != '/' && c != '=') {
- if (mprPutCharToBuf(tokBuf, c) < 0) {
- return TOKEN_TOO_BIG;
- }
- if ((c = getNextChar(xp)) < 0) {
- return TOKEN_EOF;
- }
- }
- putLastChar(xp, c);
- }
- if (mprGetBufLength(tokBuf) <= 0) {
- return TOKEN_ERR;
- }
- mprAddNullToBuf(tokBuf);
-
- if (state == EXML_AFTER_LS) {
- /*
- * If we are just inside an element "<", then analyze what we
- * have to see if we have an element name, instruction or
- * comment. Tokbuf will hold "?" for instructions or "!--"
- * for comments.
- */
- if (mprLookAtNextCharInBuf(tokBuf) == '?') {
- /* Just ignore processing instructions */
- rc = scanFor(xp, "?>");
- if (rc < 0) {
- return TOKEN_TOO_BIG;
- } else if (rc == 0) {
- return TOKEN_ERR;
- }
- return TOKEN_INSTRUCTIONS;
-
- } else if (mprLookAtNextCharInBuf(tokBuf) == '!') {
- /*
- * First discard the comment leadin "!--" and eat leading
- * white space.
- */
- if (strcmp((char*) tokBuf->start, "![CDATA[") == 0) {
- mprFlushBuf(tokBuf);
-#if UNUSED
- c = mprLookAtNextCharInBuf(inBuf);
- while (isspace(c)) {
- if ((c = getNextChar(xp)) < 0) {
- return TOKEN_EOF;
- }
- c = mprLookAtNextCharInBuf(inBuf);
- }
-#endif
- rc = scanFor(xp, "]]>");
- if (rc < 0) {
- return TOKEN_TOO_BIG;
- } else if (rc == 0) {
- return TOKEN_ERR;
- }
- return TOKEN_CDATA;
-
- } else {
- mprFlushBuf(tokBuf);
-#if UNUSED
- c = mprLookAtNextCharInBuf(inBuf);
- while (isspace(c)) {
- if ((c = getNextChar(xp)) < 0) {
- return TOKEN_EOF;
- }
- c = mprLookAtNextCharInBuf(inBuf);
- }
-#endif
- rc = scanFor(xp, "-->");
- if (rc < 0) {
- return TOKEN_TOO_BIG;
- } else if (rc == 0) {
- return TOKEN_ERR;
- }
- return TOKEN_COMMENT;
- }
- }
- }
- trimToken(xp);
- return TOKEN_TEXT;
- }
- if ((c = getNextChar(xp)) < 0) {
- return TOKEN_EOF;
- }
- }
-
- /* Should never get here */
- mprAssert(0);
- return TOKEN_ERR;
-}
-
-/******************************************************************************/
-/*
- * Scan for a pattern. Eat and discard input up to the pattern. Return 1 if
- * the pattern was found, return 0 if not found. Return < 0 on errors.
- */
-
-static int scanFor(Exml *xp, char *str)
-{
- MprBuf *tokBuf;
- char *cp;
- int c;
-
- mprAssert(str);
-
- tokBuf = xp->tokBuf;
-
- while (1) {
- for (cp = str; *cp; cp++) {
- if ((c = getNextChar(xp)) < 0) {
- return 0;
- }
- if (tokBuf) {
- if (mprPutCharToBuf(tokBuf, c) < 0) {
- return -1;
- }
- }
- if (c != *cp) {
- break;
- }
- }
- if (*cp == '\0') {
- /*
- * Remove the pattern from the tokBuf
- */
- if (tokBuf) {
- mprAdjustBufEnd(tokBuf, -(int) strlen(str));
- trimToken(xp);
- }
- return 1;
- }
- }
-}
-
-/******************************************************************************/
-/*
- * Get another character. We read and buffer blocks of data if we need more
- * data to parse.
- */
-
-static int getNextChar(Exml *xp)
-{
- MprBuf *inBuf;
- char c;
- int l;
-
- inBuf = xp->inBuf;
- if (mprGetBufLength(inBuf) <= 0) {
- /*
- * Flush to reset the servp/endp pointers to the start of the buffer
- * so we can do a maximal read
- */
- mprFlushBuf(inBuf);
- l = (xp->readFn)(xp, xp->inputArg, mprGetBufStart(inBuf),
- mprGetBufLinearSpace(inBuf));
- if (l <= 0) {
- return -1;
- }
- mprAdjustBufEnd(inBuf, l);
- }
- c = mprGetCharFromBuf(inBuf);
-
- if (c == '\n') {
- xp->lineNumber++;
- }
- return c;
-}
-
-/******************************************************************************/
-/*
- * Put back a character in the input buffer
- */
-
-static int putLastChar(Exml *xp, int c)
-{
- if (mprInsertCharToBuf(xp->inBuf, (char) c) < 0) {
- mprAssert(0);
- return -1;
- }
- if (c == '\n') {
- xp->lineNumber--;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Output a parse message
- */
-
-static void error(Exml *xp, char *fmt, ...)
-{
- va_list args;
- char *buf;
-
- mprAssert(fmt);
-
- va_start(args, fmt);
- mprAllocVsprintf(MPR_LOC_ARGS(xp), &buf, MPR_MAX_STRING, fmt, args);
- va_end(args);
-
- /*
- * MOB need to add the failing line text and a pointer to which column
- */
- mprFree(xp->errMsg);
- mprAllocSprintf(MPR_LOC_ARGS(xp), &xp->errMsg, MPR_MAX_STRING,
- "XML error: %s\nAt line %d\n", buf, xp->lineNumber);
-
- mprFree(buf);
-}
-
-/******************************************************************************/
-/*
- * Remove trailing whitespace in a token and ensure it is terminated with
- * a NULL for easy parsing
- */
-
-static void trimToken(Exml *xp)
-{
- while (isspace(mprLookAtLastCharInBuf(xp->tokBuf))) {
- mprAdjustBufEnd(xp->tokBuf, -1);
- }
- mprAddNullToBuf(xp->tokBuf);
-}
-
-/******************************************************************************/
-
-const char *exmlGetErrorMsg(Exml *xp)
-{
- if (xp->errMsg == 0) {
- return "";
- }
- return xp->errMsg;
-}
-
-/******************************************************************************/
-
-int exmlGetLineNumber(Exml *xp)
-{
- return xp->lineNumber;
-}
-
-/******************************************************************************/
-#else
-
-void exmlParserDummy() {}
-#endif /* BLD_FEATURE_EXML */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/exml/files b/source4/lib/appweb/ejs-2.0/exml/files
deleted file mode 100644
index 0f10ea44dd..0000000000
--- a/source4/lib/appweb/ejs-2.0/exml/files
+++ /dev/null
@@ -1 +0,0 @@
-${BLD_OBJ_DIR}/exmlParser${BLD_OBJ}
diff --git a/source4/lib/appweb/ejs-2.0/mpr/Makefile b/source4/lib/appweb/ejs-2.0/mpr/Makefile
deleted file mode 100644
index 6dd0e45d9e..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/Makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Makefile for the Mbedthis Portable Runtime (MPR) library
-#
-# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
-#
-
-COMPILE := *.c
-EXPORT_OBJECTS := yes
-
-include make.dep
-
-ifeq ($(BLD_HOST_UNIX),1)
-PRE_DIRS = UNIX
-else
-PRE_DIRS = $(BLD_HOST_OS)
-endif
-
-POST_DIRS = package
-
-TARGETS += $(BLD_BIN_DIR)/libmpr$(BLD_LIB)
-
-compileExtra: $(TARGETS)
-
-#
-# Build the mpr libraries
-#
-$(BLD_BIN_DIR)/libmpr$(BLD_LIB): files \
- $(shell BLD_OBJ=$(BLD_OBJ) \; BLD_OBJ_DIR=$(BLD_OBJ_DIR) \; \
- eval echo `cat files`)
- @bld --library $(BLD_BIN_DIR)/libmpr \
- --objectsDir $(BLD_OBJ_DIR) --objectList files
-
-cleanExtra:
- @echo "rm -f $(TARGETS)" | $(BLDOUT)
- @rm -f $(TARGETS)
- @rm -f $(BLD_BIN_DIR)/libmpr.*
-
-## Local variables:
-## tab-width: 4
-## End:
-## vim: tw=78 sw=4 ts=4
diff --git a/source4/lib/appweb/ejs-2.0/mpr/UNIX/Makefile b/source4/lib/appweb/ejs-2.0/mpr/UNIX/Makefile
deleted file mode 100644
index 5259b1e3a0..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/UNIX/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# Makefile for the Mbedthis Portable Runtime (MPR) library for UNIX
-#
-# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
-#
-
-COMPILE := *.c
-EXPORT_OBJECTS := yes
-MAKE_IFLAGS := -I..
-
-include make.dep
-
-## Local variables:
-## tab-width: 4
-## End:
-## vim: tw=78 sw=4 ts=4
diff --git a/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprFile.c b/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprFile.c
deleted file mode 100644
index f647f1ed56..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprFile.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * @file mprFile.c
- * @brief File services for Unix
- * @overview
- * @remarks
- * See mprGenFile.c for other file services.
- */
-
-/******************************************************************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/********************************** Includes **********************************/
-
-#include "mpr.h"
-
-/************************************ Code ************************************/
-
-int mprGetFileInfo(MprCtx ctx, const char *path, MprFileInfo *info)
-{
- struct stat s;
-
- mprAssert(path);
- mprAssert(info);
-
- if (stat(path, &s) < 0) {
- return -1;
- }
-
- info->size = s.st_size;
- info->ctime = s.st_ctime;
- info->mtime = s.st_mtime;
- info->inode = s.st_ino;
- info->isDir = (s.st_mode & S_IFDIR) != 0;
- info->isReg = (s.st_mode & S_IFREG) != 0;
-
- if (strcmp(path, "/dev/null") == 0) {
- info->isReg = 0;
- }
-
- return 0;
-}
-
-/******************************************************************************/
-
-int mprMakeDir(MprCtx ctx, const char *path, int perms)
-{
- return mkdir(path, perms);
-}
-
-/******************************************************************************/
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprPlatform.c b/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprPlatform.c
deleted file mode 100644
index 2c7fbf8a00..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprPlatform.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/**
- * @file mprPlatform.c
- * @brief Cross platform routines
- * @overview This module provides low level cross platform routines.
- * @remarks Most routines in this file are not thread-safe. It is the callers
- * responsibility to perform all thread synchronization.
- */
-
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/********************************** Includes **********************************/
-/*
- * We need to use the underlying str(cpy) routines to implement our safe
- * alternatives
- */
-#if !DOXYGEN
-#define UNSAFE_FUNCTIONS_OK 1
-#endif
-
-#include "mpr.h"
-
-/************************************ Code ************************************/
-
-char *mprInetToStr(char *buffer, int bufsize, const struct in_addr in)
-{
-#if HAVE_NTOA_R
- inet_ntoa_r(in, buffer, bufsize);
-#else
- uchar *cp;
- /* FUTURE -- this is not portable */
- cp = (uchar*) &in;
- mprSprintf(buffer, bufsize, "%d.%d.%d.%d", cp[0], cp[1], cp[2], cp[3]);
-#endif
- return buffer;
-}
-
-/******************************************************************************/
-
-void mprSetShell(MprCtx ctx, void *shell)
-{
-}
-
-/******************************************************************************/
-
-void *mprGetShell(MprCtx ctx)
-{
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Sleep. Period given in milliseconds.
- */
-
-void mprSleep(MprCtx ctx, int milliseconds)
-{
- struct timespec timeout;
- int rc;
-
- mprAssert(milliseconds >= 0);
- timeout.tv_sec = milliseconds / 1000;
- timeout.tv_nsec = (milliseconds % 1000) * 1000000;
- do {
- rc = nanosleep(&timeout, 0);
- } while (rc < 0 && errno == EINTR);
-}
-
-/******************************************************************************/
-/*
- * Make intervening directories
- */
-
-int mprMakeDirPath(MprCtx ctx, const char *path)
-{
- char dir[MPR_MAX_PATH], buf[MPR_MAX_PATH];
- char *dirSep;
- char *next, *tok;
-
- dir[0] = '\0';
- dirSep = "/\\";
-
- if (path == 0 || *path == '\0') {
- return MPR_ERR_BAD_ARGS;
- }
-
- mprStrcpy(buf, sizeof(buf), path);
- next = mprStrTok(buf, dirSep, &tok);
- if (*buf == '/') {
- dir[0] = '/';
- }
- while (next != NULL) {
- if (strcmp(next, ".") == 0 ) {
- next = mprStrTok(NULL, dirSep, &tok);
- continue;
- }
- strcat(dir, next);
- if (access(dir, R_OK) != 0) {
- if (mkdir(dir, 0666) < 0) {
- return MPR_ERR_CANT_CREATE;
- }
- }
- strcat(dir, "/");
- next = mprStrTok(NULL, dirSep, &tok);
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Get a fully qualified file name for the given path. Return with forward
- * slashes always
- */
-
-char *mprGetFullPathName(char *buf, int buflen, const char *path)
-{
- if (mprStrcpy(buf, buflen, path) < 0) {
- mprAssert(0);
- return 0;
- }
- return buf;
-}
-
-/******************************************************************************/
-/*
- * Replacement for gethostbyname that is multi-thread safe
- */
-
-struct hostent *mprGetHostByName(MprCtx ctx, const char *name)
-{
- MprApp *app;
- struct hostent *hp;
- struct hostent *ip;
- int count, i;
-
- hp = (struct hostent*) mprAlloc(ctx, sizeof(struct hostent));
- memset(hp, 0, sizeof(struct hostent));
-
- app = mprGetApp(ctx);
-
- #undef gethostbyname
-
- mprGlobalLock(app);
- ip = gethostbyname(name);
- mprGlobalUnlock(app);
-
- if (ip == 0) {
- return 0;
- }
- hp->h_addrtype = ip->h_addrtype;
- hp->h_length = ip->h_length;
- hp->h_name = mprStrdup(hp, ip->h_name);
- hp->h_addr_list = 0;
- hp->h_aliases = 0;
-
- for (count = 0; ip->h_addr_list[count] != 0; ) {
- count++;
- }
- if (count > 0) {
- count++;
- hp->h_addr_list = mprAlloc(hp, count * sizeof(char*));
- for (i = 0; ip->h_addr_list[i] != 0; i++) {
- memcpy(&hp->h_addr_list[i], &ip->h_addr_list[i], ip->h_length);
- }
- hp->h_addr_list[i] = 0;
- }
-
- for (count = 0; ip->h_aliases[count] != 0; ) {
- count++;
- }
- if (count > 0) {
- count++;
- hp->h_aliases = mprAlloc(hp, count * sizeof(char*));
- for (i = 0; ip->h_aliases[i] != 0; i++) {
- hp->h_aliases[i] = mprStrdup(hp, ip->h_aliases[i]);
- }
- hp->h_aliases[i] = 0;
- }
- return hp;
-}
-
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprTime.c b/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprTime.c
deleted file mode 100644
index 0153c0622d..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprTime.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/**
- * @file mprTime.c
- * @brief Time handling for Unix
- * @overview
- */
-
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/********************************* Includes ***********************************/
-
-#include "mpr.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#undef localtime
-#undef localtime_r
-#undef gmtime
-#undef gmtime_r
-#undef ctime
-#undef ctime_r
-#undef asctime
-#undef asctime_r
-
-/******************************************************************************/
-/*
- * Returns time in seconds and milliseconds. This is NOT time-of-day.
- */
-
-MprTime *mprGetTime(MprCtx ctx, MprTime *tp)
-{
- struct timeval tv;
-
- if (gettimeofday(&tv, 0) < 0) {
- mprAssert(0);
- tp->sec = 0;
- tp->msec = 0;
- return tp;
- }
- tp->sec = tv.tv_sec;
- tp->msec = tv.tv_usec / 1000;
- return tp;
-}
-
-/******************************************************************************/
-/*
- * Thread-safe wrapping of localtime
- */
-
-struct tm *mprLocaltime(MprCtx ctx, struct tm *timep, time_t *now)
-{
- localtime_r(now, timep);
-
- return timep;
-}
-
-/******************************************************************************/
-/*
- * Thread-safe wrapping of gmtime
- */
-
-struct tm *mprGmtime(MprCtx ctx, time_t *now, struct tm *timep)
-{
- gmtime_r(now, timep);
-
- return timep;
-}
-
-/******************************************************************************/
-/*
- * Thread-safe wrapping of ctime
- */
-
-int mprCtime(MprCtx ctx, char *buf, int bufsize, const time_t *timer)
-{
- char localBuf[80];
- char *cp;
- int len;
-
- mprAssert(buf);
-
- mprGlobalLock(ctx);
-
- cp = ctime_r(timer, localBuf);
- if ((int) strlen(cp) >= bufsize) {
- mprStrcpy(buf, bufsize, "WONT FIT");
- mprAssert(0);
- return MPR_ERR_WONT_FIT;
- }
- len = mprStrcpy(buf, bufsize, cp);
-
- if (buf[len - 1] == '\n') {
- buf[len - 1] = '\0';
- }
-
- mprGlobalUnlock(ctx);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Thread-safe wrapping of asctime
- */
-
-int mprAsctime(MprCtx ctx, char *buf, int bufsize, const struct tm *timeptr)
-{
- char *cp;
- char localBuf[80];
-
- cp = asctime_r(timeptr, localBuf);
- if ((int) strlen(cp) >= bufsize) {
- mprAssert(0);
- return MPR_ERR_WONT_FIT;
- }
- mprStrcpy(buf, bufsize, cp);
-
- return strlen(buf);
-}
-
-/******************************************************************************/
-
-#ifdef __cplusplus
-}
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/Makefile b/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/Makefile
deleted file mode 100644
index f3a2394b6e..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# Makefile for the Mbedthis Portable Runtime (MPR) library for VXWORKS
-#
-# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
-#
-
-COMPILE := *.c
-EXPORT_OBJECTS := yes
-MAKE_IFLAGS := -I..
-
-include make.dep
-
-## Local variables:
-## tab-width: 4
-## End:
-## vim: tw=78 sw=4 ts=4
diff --git a/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprFile.c b/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprFile.c
deleted file mode 100644
index ae0b523faa..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprFile.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * @file mprUnixFile.c
- * @brief File services for Unix
- * @overview
- * @remarks
- */
-
-/******************************************************************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/********************************** Includes **********************************/
-
-#include "mpr.h"
-
-/************************************ Code ************************************/
-
-int mprGetFileInfo(MprCtx ctx, const char *path, MprFileInfo *info)
-{
- struct stat s;
-
- mprAssert(path);
- mprAssert(info);
-
- if (stat(path, &s) < 0) {
- return -1;
- }
-
- info->size = s.st_size;
- info->ctime = s.st_ctime;
- info->mtime = s.st_mtime;
- info->inode = s.st_ino;
- info->isDir = (s.st_mode & S_IFDIR) != 0;
- info->isReg = (s.st_mode & S_IFREG) != 0;
-
- if (strcmp(path, "/dev/null") == 0) {
- info->isReg = 0;
- }
-
- return 0;
-}
-
-/******************************************************************************/
-
-int mprMakeDir(MprCtx ctx, const char *path, int perms)
-{
- return mkdir(path, perms);
-}
-
-/******************************************************************************/
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprPlatform.c b/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprPlatform.c
deleted file mode 100644
index 29258dfe1c..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprPlatform.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/**
- * @file mprPlatform.c
- * @brief Cross platform routines
- * @overview This module provides low level cross platform routines.
- * @remarks Most routines in this file are not thread-safe. It is the callers
- * responsibility to perform all thread synchronization.
- */
-
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/********************************** Includes **********************************/
-/*
- * We need to use the underlying str(cpy) routines to implement our safe
- * alternatives
- */
-#if !DOXYGEN
-#define UNSAFE_FUNCTIONS_OK 1
-#endif
-
-#include "mpr.h"
-
-/************************************ Code ************************************/
-
-char *mprInetToStr(char *buffer, int bufsize, const struct in_addr in)
-{
-#if HAVE_NTOA_R
- inet_ntoa_r(in, buffer, bufsize);
-#else
- uchar *cp;
- /* FUTURE -- this is not portable */
- cp = (uchar*) &in;
- mprSprintf(buffer, bufsize, "%d.%d.%d.%d", cp[0], cp[1], cp[2], cp[3]);
-#endif
- return buffer;
-}
-
-/******************************************************************************/
-
-void mprSetShell(MprCtx ctx, void *shell)
-{
-}
-
-/******************************************************************************/
-
-void *mprGetShell(MprCtx ctx)
-{
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Sleep. Period given in milliseconds.
- */
-
-void mprSleep(MprCtx ctx, int milliseconds)
-{
- struct timeval timeout;
- int rc;
-
- timeout.tv_sec = milliseconds / 1000;
- timeout.tv_usec = (milliseconds % 1000) * 1000;
- do {
- rc = select(1, 0, 0, 0, &timeout);
- } while (rc < 0 && errno == EINTR);
-}
-
-/******************************************************************************/
-/*
- * Make intervening directories
- */
-
-int mprMakeDirPath(MprCtx ctx, const char *path)
-{
- char dir[MPR_MAX_PATH], buf[MPR_MAX_PATH];
- char *dirSep;
- char *next, *tok;
-
- dir[0] = '\0';
- dirSep = "/\\";
-
- if (path == 0 || *path == '\0') {
- return MPR_ERR_BAD_ARGS;
- }
-
- mprStrcpy(buf, sizeof(buf), path);
- next = mprStrTok(buf, dirSep, &tok);
- if (*buf == '/') {
- dir[0] = '/';
- }
- while (next != NULL) {
- if (strcmp(next, ".") == 0 ) {
- next = mprStrTok(NULL, dirSep, &tok);
- continue;
- }
- strcat(dir, next);
- if (access(dir, R_OK) != 0) {
- if (mkdir(dir) < 0) {
- return MPR_ERR_CANT_CREATE;
- }
- }
- strcat(dir, "/");
- next = mprStrTok(NULL, dirSep, &tok);
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Get a fully qualified file name for the given path. Return with forward
- * slashes always
- */
-
-char *mprGetFullPathName(char *buf, int buflen, const char *path)
-{
- if (mprStrcpy(buf, buflen, path) < 0) {
- mprAssert(0);
- return 0;
- }
- return buf;
-}
-
-/******************************************************************************/
-/*
- * Replacement for gethostbyname that is multi-thread safe
- */
-
-struct hostent *mprGetHostByName(MprCtx ctx, const char *name)
-{
- struct hostent *hp;
-
- hp = (struct hostent*) mprAlloc(ctx, sizeof(struct hostent));
- memset(hp, 0, sizeof(struct hostent));
-
- struct in_addr inaddr;
- inaddr.s_addr = (ulong) hostGetByName(name);
- if (inaddr.s_addr < 0) {
- mprAssert(0);
- return 0;
- }
- hp->h_addrtype = AF_INET;
- hp->h_length = sizeof(int);
- hp->h_name = mprStrdup(name);
- hp->h_addr_list = 0;
- hp->h_aliases = 0;
-
- hp->h_addr_list = new char*[2];
- hp->h_addr_list[0] = (char *) mprAlloc(hp, sizeof(struct in_addr));
- memcpy(&hp->h_addr_list[0], &inaddr, hp->h_length);
- hp->h_addr_list[1] = 0;
-
- return hp;
-}
-
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprTime.c b/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprTime.c
deleted file mode 100755
index c9b7560f46..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprTime.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/**
- * @file mprTime.c
- * @brief Time handling for VxWorks
- * @overview
- */
-
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/********************************* Includes ***********************************/
-
-#include "mpr.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#undef localtime
-#undef localtime_r
-#undef gmtime
-#undef gmtime_r
-#undef ctime
-#undef ctime_r
-#undef asctime
-#undef asctime_r
-
-/******************************************************************************/
-/*
- * Returns time in seconds and milliseconds. This is NOT time-of-day.
- */
-
-MprTime *mprGetTime(MprCtx ctx, MprTime *tp)
-{
- struct timeval tv;
-
- if (gettimeofday(&tv, 0) < 0) {
- mprAssert(0);
- tp->sec = 0;
- tp->msec = 0;
- return tp;
- }
- tp->sec = tv.tv_sec;
- tp->msec = tv.tv_usec / 1000;
- return tp;
-}
-
-/******************************************************************************/
-/*
- * Thread-safe wrapping of localtime
- */
-
-struct tm *mprLocaltime(MprCtx ctx, struct tm *timep, time_t *now)
-{
- localtime_r(now, timep);
-
- return timep;
-}
-
-/******************************************************************************/
-/*
- * Thread-safe wrapping of gmtime
- */
-
-struct tm *mprGmtime(MprCtx ctx, time_t *now, struct tm *timep)
-{
- gmtime_r(now, timep);
-
- return timep;
-}
-
-/******************************************************************************/
-/*
- * Thread-safe wrapping of ctime
- */
-
-int mprCtime(MprCtx ctx, char *buf, int bufsize, const time_t *timer)
-{
- char localBuf[80];
- char *cp;
- int len;
-
- mprAssert(buf);
-
- mprGlobalLock(ctx);
-
- cp = ctime_r(timer, localBuf);
- if ((int) strlen(cp) >= bufsize) {
- mprStrcpy(buf, bufsize, "WONT FIT");
- mprAssert(0);
- return MPR_ERR_WONT_FIT;
- }
- len = mprStrcpy(buf, bufsize, cp);
-
- if (buf[len - 1] == '\n') {
- buf[len - 1] = '\0';
- }
-
- mprGlobalUnlock(ctx);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Thread-safe wrapping of asctime
- */
-
-int mprAsctime(MprCtx ctx, char *buf, int bufsize, const struct tm *timeptr)
-{
- char *cp;
- char localBuf[80];
-
- cp = asctime_r(timeptr, localBuf);
- if ((int) strlen(cp) >= bufsize) {
- mprAssert(0);
- return MPR_ERR_WONT_FIT;
- }
- mprStrcpy(buf, bufsize, cp);
-
- return strlen(buf);
-}
-
-/******************************************************************************/
-
-#ifdef __cplusplus
-}
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/WIN/Makefile b/source4/lib/appweb/ejs-2.0/mpr/WIN/Makefile
deleted file mode 100644
index 84e30ff8f1..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/WIN/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# Makefile for the Mbedthis Portable Runtime (MPR) library for Windows
-#
-# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
-#
-
-COMPILE := *.c
-EXPORT_OBJECTS := yes
-MAKE_IFLAGS := -I..
-
-include make.dep
-
-## Local variables:
-## tab-width: 4
-## End:
-## vim: tw=78 sw=4 ts=4
diff --git a/source4/lib/appweb/ejs-2.0/mpr/WIN/mprFile.c b/source4/lib/appweb/ejs-2.0/mpr/WIN/mprFile.c
deleted file mode 100644
index 9ac1669f3d..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/WIN/mprFile.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/**
- * @file mprWinFile.c
- * @brief File services for Windows
- * @overview
- * @remarks
- */
-
-/******************************************************************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/********************************** Includes **********************************/
-
-#include "mpr.h"
-
-/************************************ Code ************************************/
-
-int mprGetFileInfo(MprCtx ctx, const char *path, MprFileInfo *info)
-{
- struct stat s;
-
- mprAssert(path);
- mprAssert(info);
-
- if (stat(path, &s) < 0) {
- return -1;
- }
-
- info->size = s.st_size;
- /*
- * MOB -- these are time64_t. Loss of precision
- */
- info->ctime = (uint) s.st_ctime;
- info->mtime = (uint) s.st_mtime;
- info->inode = s.st_ino;
- info->isDir = (s.st_mode & S_IFDIR) != 0;
- info->isReg = (s.st_mode & S_IFREG) != 0;
-
- /*
- * Work hard on windows to determine if the file is a regular file.
- * FUTURE -- OPT. Eliminate this CreateFile.
- */
- if (info->isReg) {
- long fileType, att;
-
- if ((att = GetFileAttributes(path)) == -1) {
- return -1;
- }
- if (att & (FILE_ATTRIBUTE_REPARSE_POINT |
- FILE_ATTRIBUTE_DIRECTORY |
- FILE_ATTRIBUTE_ENCRYPTED |
- FILE_ATTRIBUTE_SYSTEM |
- FILE_ATTRIBUTE_OFFLINE)) {
- /*
- * Catch accesses to devices like CON, AUX, NUL, LPT etc
- * att will be set to ENCRYPTED on Win9X and NT.
- */
- info->isReg = 0;
- }
- if (info->isReg) {
- HANDLE handle;
- handle = CreateFile(path, 0, FILE_SHARE_READ | FILE_SHARE_WRITE,
- 0, OPEN_EXISTING, 0, 0);
- if (handle == INVALID_HANDLE_VALUE) {
- info->isReg = 0;
- } else {
- fileType = GetFileType(handle);
- if (fileType == FILE_TYPE_CHAR || fileType == FILE_TYPE_PIPE) {
- info->isReg = 0;
- }
- CloseHandle(handle);
- }
- }
- }
- if (strcmp(path, "nul") == 0) {
- info->isReg = 0;
- }
- return 0;
-}
-
-/******************************************************************************/
-
-int mprMakeDir(MprCtx ctx, const char *path, int perms)
-{
- return mkdir(path, perms);
-}
-
-/******************************************************************************/
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/WIN/mprPlatform.c b/source4/lib/appweb/ejs-2.0/mpr/WIN/mprPlatform.c
deleted file mode 100644
index 65718694b1..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/WIN/mprPlatform.c
+++ /dev/null
@@ -1,378 +0,0 @@
-/**
- * @file mprPlatform.c
- * @brief Cross platform routines
- * @overview This module provides low level cross platform routines.
- * @remarks Most routines in this file are not thread-safe. It is the callers
- * responsibility to perform all thread synchronization.
- */
-
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/********************************** Includes **********************************/
-/*
- * We need to use the underlying str(cpy) routines to implement our safe
- * alternatives
- */
-#if !DOXYGEN
-#define UNSAFE_FUNCTIONS_OK 1
-#endif
-
-#include "mpr.h"
-
-/**************************** Forward Declarations ****************************/
-
-static const char *getHive(const char *keyPath, HKEY *hive);
-
-/************************************ Code ************************************/
-
-char *mprInetToStr(char *buffer, int bufsize, const struct in_addr in)
-{
-#if HAVE_NTOA_R
- inet_ntoa_r(in, buffer, bufsize);
-#else
- uchar *cp;
- cp = (uchar*) &in;
- mprSprintf(buffer, bufsize, "%d.%d.%d.%d", cp[0], cp[1], cp[2], cp[3]);
-#endif
- return buffer;
-}
-
-/******************************************************************************/
-
-void mprSetShell(MprCtx ctx, void *shell)
-{
-}
-
-/******************************************************************************/
-
-void *mprGetShell(MprCtx ctx)
-{
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Sleep. Period given in milliseconds.
- */
-
-void mprSleep(MprCtx ctx, int milliseconds)
-{
- Sleep(milliseconds);
-}
-
-/******************************************************************************/
-/*
- * Make intervening directories
- */
-
-int mprMakeDirPath(MprCtx ctx, const char *path)
-{
- char dir[MPR_MAX_PATH], buf[MPR_MAX_PATH];
- char *dirSep;
- char *next, *tok;
-
- dir[0] = '\0';
- dirSep = "/\\";
-
- if (path == 0 || *path == '\0') {
- return MPR_ERR_BAD_ARGS;
- }
-
- mprStrcpy(buf, sizeof(buf), path);
- next = mprStrTok(buf, dirSep, &tok);
- if (*buf == '/') {
- dir[0] = '/';
- }
- while (next != NULL) {
- if (strcmp(next, ".") == 0 ) {
- next = mprStrTok(NULL, dirSep, &tok);
- continue;
- }
- strcat(dir, next);
- if (access(dir, R_OK) != 0) {
- if (_mkdir(dir) < 0) {
- return MPR_ERR_CANT_CREATE;
- }
- }
- strcat(dir, "/");
- next = mprStrTok(NULL, dirSep, &tok);
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Get a fully qualified file name for the given path. Return with forward
- * slashes always
- */
-
-char *mprGetFullPathName(char *buf, int buflen, const char *path)
-{
-#if (WIN || NW || OS2) && !BLD_FEATURE_ROMFS
- char *junk, *cp;
- int rc;
-
- --buflen;
- rc = GetFullPathName(path, buflen, buf, &junk);
- for (cp = buf; *cp; cp++) {
- if (*cp == '\\') {
- *cp = '/';
- }
- }
- buf[buflen] = '\0';
-#else
- if (mprStrcpy(buf, buflen, path) < 0) {
- mprAssert(0);
- return 0;
- }
-#endif
- return buf;
-}
-
-/******************************************************************************/
-/*
- * Replacement for gethostbyname that is multi-thread safe
- */
-
-struct hostent *mprGetHostByName(MprCtx ctx, const char *name)
-{
- MprApp *app;
- struct hostent *hp;
- struct hostent *ip;
- int count, i;
-
- hp = (struct hostent*) mprAlloc(ctx, sizeof(struct hostent));
- memset(hp, 0, sizeof(struct hostent));
-
- app = mprGetApp(ctx);
-
- #undef gethostbyname
-
- mprGlobalLock(app);
- ip = gethostbyname(name);
- mprGlobalUnlock(app);
-
- if (ip == 0) {
- return 0;
- }
- hp->h_addrtype = ip->h_addrtype;
- hp->h_length = ip->h_length;
- hp->h_name = mprStrdup(hp, ip->h_name);
- hp->h_addr_list = 0;
- hp->h_aliases = 0;
-
- for (count = 0; ip->h_addr_list[count] != 0; ) {
- count++;
- }
- if (count > 0) {
- count++;
- hp->h_addr_list = mprAlloc(hp, count * sizeof(char*));
- for (i = 0; ip->h_addr_list[i] != 0; i++) {
- memcpy(&hp->h_addr_list[i], &ip->h_addr_list[i], ip->h_length);
- }
- hp->h_addr_list[i] = 0;
- }
-
- for (count = 0; ip->h_aliases[count] != 0; ) {
- count++;
- }
- if (count > 0) {
- count++;
- hp->h_aliases = mprAlloc(hp, count * sizeof(char*));
- for (i = 0; ip->h_aliases[i] != 0; i++) {
- hp->h_aliases[i] = mprStrdup(hp, ip->h_aliases[i]);
- }
- hp->h_aliases[i] = 0;
- }
- return hp;
-}
-
-/******************************************************************************/
-/*
- * Read a registry value. Returns allocated memory in buf.
- */
-
-int mprReadRegistry(MprCtx ctx, char **buf, int max, const char *key,
- const char *name)
-{
- HKEY top, h;
- char *value;
- ulong type, size;
-
- mprAssert(key && *key);
- mprAssert(buf);
-
- /*
- * Get the registry hive
- */
- if ((key = getHive(key, &top)) == 0) {
- return MPR_ERR_CANT_ACCESS;
- }
-
- if (RegOpenKeyEx(top, key, 0, KEY_READ, &h) != ERROR_SUCCESS) {
- return MPR_ERR_CANT_ACCESS;
- }
-
- /*
- * Get the type
- */
- if (RegQueryValueEx(h, name, 0, &type, 0, &size) != ERROR_SUCCESS) {
- RegCloseKey(h);
- return MPR_ERR_CANT_READ;
- }
- if (type != REG_SZ && type != REG_EXPAND_SZ) {
- RegCloseKey(h);
- return MPR_ERR_BAD_TYPE;
- }
-
- value = (char*) mprAlloc(ctx, size);
- if ((int) size > max) {
- RegCloseKey(h);
- return MPR_ERR_WONT_FIT;
- }
- if (RegQueryValueEx(h, name, 0, &type, (uchar*) value, &size) !=
- ERROR_SUCCESS) {
- mprFree(value);
- RegCloseKey(h);
- return MPR_ERR_CANT_READ;
- }
-
- RegCloseKey(h);
- *buf = value;
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Write a string registry value. Returns allocated memory in buf.
- */
-
-int mprWriteRegistry(MprCtx ctx, const char *key, const char *name,
- const char *value)
-{
- HKEY top, h, subHandle;
- ulong disposition;
-
- mprAssert(key && *key);
- mprAssert(name && *name);
- mprAssert(value && *value);
-
- /*
- * Get the registry hive
- */
- if ((key = getHive(key, &top)) == 0) {
- return MPR_ERR_CANT_ACCESS;
- }
-
- if (name) {
- /*
- * Write a registry string value
- */
- if (RegOpenKeyEx(top, key, 0, KEY_ALL_ACCESS, &h) != ERROR_SUCCESS) {
- return MPR_ERR_CANT_ACCESS;
- }
- if (RegSetValueEx(h, name, 0, REG_SZ, value, strlen(value) + 1)
- != ERROR_SUCCESS) {
- RegCloseKey(h);
- return MPR_ERR_CANT_READ;
- }
-
- } else {
- /*
- * Create a new sub key
- */
- if (RegOpenKeyEx(top, key, 0, KEY_CREATE_SUB_KEY, &h) != ERROR_SUCCESS){
- return MPR_ERR_CANT_ACCESS;
- }
- if (RegCreateKeyEx(h, name, 0, NULL, REG_OPTION_NON_VOLATILE,
- KEY_ALL_ACCESS, NULL, &subHandle, &disposition) != ERROR_SUCCESS) {
- return MPR_ERR_CANT_ACCESS;
- }
- RegCloseKey(subHandle);
- }
- RegCloseKey(h);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Determine the registry hive by the first portion of the path. Return
- * a pointer to the rest of key path after the hive portion.
- */
-
-static const char *getHive(const char *keyPath, HKEY *hive)
-{
- char key[MPR_MAX_STRING], *cp;
- int len;
-
- mprAssert(keyPath && *keyPath);
-
- *hive = 0;
-
- mprStrcpy(key, sizeof(key), keyPath);
- key[sizeof(key) - 1] = '\0';
-
- if (cp = strchr(key, '\\')) {
- *cp++ = '\0';
- }
- if (cp == 0 || *cp == '\0') {
- return 0;
- }
-
- if (!mprStrcmpAnyCase(key, "HKEY_LOCAL_MACHINE")) {
- *hive = HKEY_LOCAL_MACHINE;
- } else if (!mprStrcmpAnyCase(key, "HKEY_CURRENT_USER")) {
- *hive = HKEY_CURRENT_USER;
- } else if (!mprStrcmpAnyCase(key, "HKEY_USERS")) {
- *hive = HKEY_USERS;
- } else if (!mprStrcmpAnyCase(key, "HKEY_CLASSES_ROOT")) {
- *hive = HKEY_CLASSES_ROOT;
- } else {
- return 0;
- }
-
- if (*hive == 0) {
- return 0;
- }
- len = strlen(key) + 1;
- return keyPath + len;
-}
-
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/WIN/mprTime.c b/source4/lib/appweb/ejs-2.0/mpr/WIN/mprTime.c
deleted file mode 100644
index 74e59c9c73..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/WIN/mprTime.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/**
- * @file mprTime.c
- * @brief Time handling for Windows
- * @overview
- */
-
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/********************************* Includes ***********************************/
-
-#include "mpr.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/************************************ Code ************************************/
-/*
- * Returns time in seconds and milliseconds. This is NOT time-of-day.
- */
-
-MprTime *mprGetTime(MprCtx ctx, MprTime *tp)
-{
- FILETIME fileTime;
- int64 now, base;
-
- GetSystemTimeAsFileTime(&fileTime);
-
- now = ((((int64) fileTime.dwHighDateTime) << BITS(uint)) +
- ((int64) fileTime.dwLowDateTime));
-
- /*
- * Convert from 100-nanosec units to milliseconds
- */
- now = (now / 10000);
-
- /*
- * Adjust to be seconds since Jan 1 1970. Do this to be consistent with
- * UNIX but not really required by the API definition.
- */
- base = ((UINT64(365) * 86400 * (1970 - 1601)) * 1000);
- now -= base;
- tp->sec = (uint) (now / 1000);
- tp->msec = (uint) (now % 1000);
-
-#if UNUSED
-{
- static int64 start;
-
- if (start == 0) {
- start = now;
- }
- if (now < start) {
- mprLog(ctx, 0, "TIME WENT BACKWARDS");
- mprLog(ctx, 0, "start %Ld", start);
- mprLog(ctx, 0, "now %Ld", now);
- }
- mprLog(ctx, 0, "getTime %Ld", now);
- start = now;
-}
-#endif
-
- return tp;
-}
-
-/******************************************************************************/
-/*
- * Thread-safe wrapping of localtime
- */
-
-struct tm *mprLocaltime(MprCtx ctx, struct tm *timep, time_t *now)
-{
- struct tm *tbuf;
- mprGlobalLock(ctx);
- tbuf = localtime(now);
- *timep = *tbuf;
- mprGlobalUnlock(ctx);
-
- return timep;
-}
-
-/******************************************************************************/
-/*
- * Thread-safe wrapping of gmtime
- */
-
-struct tm *mprGmtime(MprCtx ctx, time_t *now, struct tm *timep)
-{
- struct tm *tbuf;
- tbuf = gmtime(now);
- *timep = *tbuf;
-
- return timep;
-}
-
-/******************************************************************************/
-/*
- * Thread-safe wrapping of ctime
- */
-
-int mprCtime(MprCtx ctx, char *buf, int bufsize, const time_t *timer)
-{
- char *cp;
- int len;
-
- mprAssert(buf);
-
- mprGlobalLock(ctx);
-
- cp = ctime(timer);
- if ((int) strlen(cp) >= bufsize) {
- mprStrcpy(buf, bufsize, "WONT FIT");
- mprAssert(0);
- mprGlobalUnlock(ctx);
- return MPR_ERR_WONT_FIT;
- }
-
- len = mprStrcpy(buf, bufsize, cp);
- if (buf[len - 1] == '\n') {
- buf[len - 1] = '\0';
- }
-
- mprGlobalUnlock(ctx);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Thread-safe wrapping of asctime
- */
-
-int mprAsctime(MprCtx ctx, char *buf, int bufsize, const struct tm *timeptr)
-{
- char *cp;
-
- mprAssert(buf);
- mprGlobalLock(ctx);
- cp = asctime(timeptr);
- if ((int) strlen(cp) >= bufsize) {
- mprAssert(0);
- mprGlobalUnlock(ctx);
- return MPR_ERR_WONT_FIT;
- }
- mprStrcpy(buf, bufsize, cp);
- mprGlobalUnlock(ctx);
-
- return strlen(buf);
-}
-
-/******************************************************************************/
-
-#ifdef __cplusplus
-}
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/files b/source4/lib/appweb/ejs-2.0/mpr/files
deleted file mode 100644
index 290c9ce790..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/files
+++ /dev/null
@@ -1,14 +0,0 @@
-${BLD_OBJ_DIR}/mpr${BLD_OBJ}
-${BLD_OBJ_DIR}/mprAlloc${BLD_OBJ}
-${BLD_OBJ_DIR}/mprArray${BLD_OBJ}
-${BLD_OBJ_DIR}/mprBuf${BLD_OBJ}
-${BLD_OBJ_DIR}/mprFile${BLD_OBJ}
-${BLD_OBJ_DIR}/mprGenFile${BLD_OBJ}
-${BLD_OBJ_DIR}/mprGenTime${BLD_OBJ}
-${BLD_OBJ_DIR}/mprLock${BLD_OBJ}
-${BLD_OBJ_DIR}/mprLog${BLD_OBJ}
-${BLD_OBJ_DIR}/mprPlatform${BLD_OBJ}
-${BLD_OBJ_DIR}/mprPrintf${BLD_OBJ}
-${BLD_OBJ_DIR}/mprString${BLD_OBJ}
-${BLD_OBJ_DIR}/mprSymbol${BLD_OBJ}
-${BLD_OBJ_DIR}/mprTime${BLD_OBJ}
diff --git a/source4/lib/appweb/ejs-2.0/mpr/mpr.c b/source4/lib/appweb/ejs-2.0/mpr/mpr.c
deleted file mode 100644
index 163b51eccf..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/mpr.c
+++ /dev/null
@@ -1,340 +0,0 @@
-/**
- * @file mpr.c
- * @brief Mpr initialization
- * @overview
- * @remarks Most routines in this file are not thread-safe. It is the callers
- * responsibility to perform all thread synchronization.
- */
-
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/********************************** Includes **********************************/
-/*
- * We need to use the underlying str(cpy) routines to implement our safe
- * alternatives
- */
-#if !DOXYGEN
-#define UNSAFE_FUNCTIONS_OK 1
-#endif
-
-#include "mpr.h"
-
-/******************************************************************************/
-/*
- * Initialize the MPR. Create the top level memory context. This routine is
- * the first call an MPR application must do. If using MprServices, the
- * creation of an Mpr object will call this routine.
- */
-
-MprApp *mprInit(MprAllocCback cback)
-{
- return mprInitEx(cback, 0);
-}
-
-/******************************************************************************/
-/*
- * Add a shell parameter then do the regular init
- */
-
-MprApp *mprInitEx(MprAllocCback cback, void *shell)
-{
- MprApp *app;
-
- app = (MprApp*) mprAllocInit(cback);
-
- mprAssert(app);
- if (app == 0) {
- return 0;
- }
-
- app->name = mprStrdup(app, BLD_PRODUCT);
- app->title = mprStrdup(app, BLD_NAME);
- app->version = mprStrdup(app, BLD_VERSION);
-
- mprSetShell(app, shell);
-
- app->table = mprCreateSymbolTable(app, 0);
-
- if (mprStartFileServices(app) < 0) {
- mprAllocTerm(app);
- return 0;
- }
-
-#if BLD_FEATURE_MULTITHREAD
- mprInitThreads(app);
-#endif
-
- /*
- * See if any of the preceeding allocations failed
- */
- if (mprGetAllocErrors(app) > 0) {
- mprAllocTerm(app);
- return 0;
- }
-
- /*
- * Mark all blocks allocated so far as required. They will then be
- * omitted from leak reports.
- */
- mprSetRequiredAlloc(app, 1);
-
- return app;
-}
-
-/******************************************************************************/
-/*
- * Terminate the MPR. If doStats is true, then output a memory allocation
- * report.
- */
-
-void mprTerm(MprApp *app, bool doStats)
-{
-#if BLD_FEATURE_ALLOC_STATS
- if (doStats) {
- mprPrintAllocReport(app, 1, "MPR Memory Allocation Report");
- }
-#endif
-
-#if BLD_FEATURE_MULTITHREAD
- mprTermThreads(app);
-#endif
-
- mprStopFileServices(app);
-
-#if BLD_DEBUG
- mprValidateAllocTree(app);
-#endif
- mprAllocTerm(app);
-}
-
-/******************************************************************************/
-
-bool mprIsExiting(MprCtx ctx)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
- if (app == 0) {
- return 1;
- }
- return app->flags & MPR_APP_EXITING;
-}
-
-/******************************************************************************/
-
-int mprHasAllocError(MprCtx ctx)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
- if (app == 0) {
- return 1;
- }
-
- return app->flags & MPR_APP_ALLOC_ERROR;
-}
-
-/******************************************************************************/
-
-void mprSignalExit(MprCtx ctx)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
- app->flags |= MPR_APP_EXITING;
-}
-
-/******************************************************************************/
-
-void mprSignalAllocError(MprCtx ctx)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
- app->flags |= MPR_APP_ALLOC_ERROR;
-}
-
-/******************************************************************************/
-
-int mprSetAppName(MprCtx ctx, const char *name, const char *title,
- const char *version)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
-
- if (name) {
- mprFree(app->name);
- if ((app->name = mprStrdup(ctx, name)) == 0) {
- return MPR_ERR_CANT_ALLOCATE;
- }
- }
-
- if (title) {
- mprFree(app->title);
- if ((app->title = mprStrdup(ctx, title)) == 0) {
- return MPR_ERR_CANT_ALLOCATE;
- }
- }
-
- if (version) {
- mprFree(app->version);
- if ((app->version = mprStrdup(ctx, version)) == 0) {
- return MPR_ERR_CANT_ALLOCATE;
- }
- }
- return 0;
-}
-
-/******************************************************************************/
-
-const char *mprGetAppName(MprCtx ctx)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
- return app->name;
-}
-
-/******************************************************************************/
-
-const char *mprGetAppTitle(MprCtx ctx)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
- return app->title;
-}
-
-/******************************************************************************/
-
-const char *mprGetAppVersion(MprCtx ctx)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
- return app->version;
-}
-
-/******************************************************************************/
-
-int mprSetKeyValue(MprCtx ctx, const char *key, void *ptr)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
- if (mprInsertSymbol(app->table, key, ptr) == 0) {
- return MPR_ERR_CANT_WRITE;
- }
- return 0;
-}
-
-/******************************************************************************/
-
-int mprRemoveKeyValue(MprCtx ctx, const char *key)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
- return mprRemoveSymbol(app->table, key);
-}
-
-/******************************************************************************/
-
-void *mprGetKeyValue(MprCtx ctx, const char *key)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
- return mprLookupSymbol(app->table, key);
-}
-
-/******************************************************************************/
-
-bool mprGetDebugMode(MprCtx ctx)
-{
- return mprGetApp(ctx)->debugMode;
-}
-
-/******************************************************************************/
-
-void mprSetDebugMode(MprCtx ctx, bool on)
-{
- mprGetApp(ctx)->debugMode = on;
-}
-
-/******************************************************************************/
-
-void mprSetLogHandler(MprCtx ctx, MprLogHandler handler)
-{
- mprGetApp(ctx)->logHandler = handler;
-}
-
-/******************************************************************************/
-
-MprLogHandler mprGetLogHandler(MprCtx ctx)
-{
- return mprGetApp(ctx)->logHandler;
-}
-
-#if UNUSED
-/******************************************************************************/
-
-void mprSetMprInstance(MprCtx ctx, void *mprInstance)
-{
- mprGetApp(ctx)->mprInstance = mprInstance;
-}
-
-/******************************************************************************/
-
-void *mprGetMprInstance(MprCtx ctx)
-{
- return mprGetApp(ctx)->mprInstance;
-}
-
-#endif
-/******************************************************************************/
-
-const char *mprCopyright()
-{
- return "Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.";
-}
-
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/mpr.h b/source4/lib/appweb/ejs-2.0/mpr/mpr.h
deleted file mode 100644
index 67505a6e01..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/mpr.h
+++ /dev/null
@@ -1,1027 +0,0 @@
-/*
- * @file mpr.h
- * @brief Header for the Mbedthis Portable Runtime (MPR) Base.
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/******************************* Documentation ********************************/
-/*
- * See mpr.dox for additional documentation.
- */
-
-/******************************************************************************/
-
-#ifndef _h_MPR
-#define _h_MPR 1
-
-/***********************************Includes **********************************/
-
-#include "mprOs.h"
-
-/******************************************************************************/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/********************************** Constants *********************************/
-
-#if BLD_FEATURE_SQUEEZE
-#if BREW || DOXYGEN
-/*
- * Maximum length of a file path name. Reduced from the system maximum to
- * save memory space.
- */
-#define MPR_MAX_FNAME 64 /**< Reasonable filename size */
-#define MPR_MAX_PATH 64 /**< Reasonable path name size */
-#define MPR_DEFAULT_STACK (16 * 1024) /**< Default stack size */
-#else
-#define MPR_MAX_FNAME 128 /**< Reasonable filename size */
-#define MPR_MAX_PATH 256 /**< Reasonable path name size */
-#define MPR_DEFAULT_STACK (32 * 1024) /**< Default stack size */
-#endif
-/*
- * Reasonable length of a file name used by the product. Use where you know
- * the expected file name and it is certain to be less than this limit.
- */
-#define MPR_DEFAULT_ALLOC 64 /**< Default small alloc size */
-#define MPR_DEFAULT_HASH_SIZE 23 /**< Default size of hash table */
-#define MPR_MAX_ARGC 32 /**< Reasonable max of args */
-#define MPR_MAX_STRING 512 /**< Maximum (stack) string size */
-#define MPR_MAX_LOG_STRING 512 /**< Maximum log message */
-#define MPR_MAX_URL 256 /**< Reasonable size of a URL */
-#define MPR_BUFSIZE 512 /**< Reasonable size for buffers */
-#define MPR_SLAB_STR_MAX 32 /**< Size of string slab blocks */
-#define MPR_SLAB_STR_INC 32 /**< Pre-allocate increment */
-#define MPR_SLAB_DEFAULT_INC 8 /**< Default pre-allocate inc */
-#define MPR_ARRAY_INCR 8 /**< Default array growth inc */
-#define MPR_BUF_INCR 1024 /**< Default array growth inc */
-#define MPR_MAX_BUF (1024*4096) /**< Default array growth inc */
-
-#define MPR_BLK_HDR_SIZE ((sizeof(struct MprBlk) + 3) & ~3)
-
-#else
-#define MPR_MAX_FNAME 256
-#define MPR_MAX_PATH 1024
-#define MPR_DEFAULT_ALLOC 256
-#define MPR_DEFAULT_HASH_SIZE 43
-#define MPR_DEFAULT_STACK (64 * 1024)
-#define MPR_MAX_ARGC 128
-#define MPR_MAX_STRING 4096
-#define MPR_MAX_LOG_STRING 8192
-#define MPR_MAX_URL 1024
-#define MPR_BUFSIZE 1024
-#define MPR_SLAB_STR_MAX 32
-#define MPR_SLAB_STR_INC 64
-#define MPR_SLAB_DEFAULT_INC 16
-#define MPR_ARRAY_INCR 16
-#define MPR_BUF_INCR 1024
-#define MPR_MAX_BUF (1024*4096)
-
-#define MPR_BLK_HDR_SIZE ((sizeof(struct MprBlk) + 15) & ~15)
-#endif
-
-/**
- * Maximum size of a host name string
- */
-#define MPR_MAX_IP_NAME 64
-
-/**
- * Maximum size of an IP address
- */
-#define MPR_MAX_IP_ADDR 16
-
-/**
- * Maximum size of an IP address including port number
- */
-#define MPR_MAX_IP_ADDR_PORT 32
-
-#define MPR_MAX_SLAB 16 /* Slabs from 32-512 bytes */
-
-#define MPR_MAX_TIME_SYNC (10 * 1000) /* Time sync adjustments */
-
-/**
- * @overview Memory context type
- * @description Blocks of memory are allocated using a memory context
- * as the parent with the \ref MprApp structure being the root of the
- * tree. Any allocated memory block may serve as the memory context for
- * subsequent memory allocations. Freeing a block via \ref mprFree will
- * release the allocated block and all child blocks.
- * @stability Prototype.
- * @library libmpr.
- * @see mprInit, mprAlloc, mprFree
- */
-typedef const void *MprCtx;
-
-/*
- * Allocated memory destructor type
- */
-typedef int (*MprDestructor)(void *);
-
-/******************************** Error Codes *********************************/
-
-/*
- * Standard MPR return and error codes
- */
-
-#define MPR_ERR_OK (0)
-/**< Success */
-
-#define MPR_ERR_BASE (-200)
-/**< Base error code */
-
-#define MPR_ERR_GENERAL (MPR_ERR_BASE - 1)
-/**< General error */
-#define MPR_ERR_ABORTED (MPR_ERR_BASE - 2)
-/**< Action aborted */
-#define MPR_ERR_ALREADY_EXISTS (MPR_ERR_BASE - 3)
-/**< Item already exists */
-#define MPR_ERR_BAD_ARGS (MPR_ERR_BASE - 4)
-/**< Bad arguments or paramaeters */
-#define MPR_ERR_BAD_FORMAT (MPR_ERR_BASE - 5)
-/**< Bad input format */
-#define MPR_ERR_BAD_HANDLE (MPR_ERR_BASE - 6)
-#define MPR_ERR_BAD_STATE (MPR_ERR_BASE - 7)
-/**< Module is in a bad state */
-#define MPR_ERR_BAD_SYNTAX (MPR_ERR_BASE - 8)
-/**< Input has bad syntax */
-#define MPR_ERR_BAD_TYPE (MPR_ERR_BASE - 9)
-#define MPR_ERR_BAD_VALUE (MPR_ERR_BASE - 10)
-#define MPR_ERR_BUSY (MPR_ERR_BASE - 11)
-#define MPR_ERR_CANT_ACCESS (MPR_ERR_BASE - 12)
-/**< Can't access the file or resource */
-#define MPR_ERR_CANT_COMPLETE (MPR_ERR_BASE - 13)
-#define MPR_ERR_CANT_CREATE (MPR_ERR_BASE - 14)
-/**< Can't create the file or resource */
-#define MPR_ERR_CANT_INITIALIZE (MPR_ERR_BASE - 15)
-#define MPR_ERR_CANT_OPEN (MPR_ERR_BASE - 16)
-/**< Can't open the file or resource */
-#define MPR_ERR_CANT_READ (MPR_ERR_BASE - 17)
-/**< Can't read from the file or resource */
-#define MPR_ERR_CANT_WRITE (MPR_ERR_BASE - 18)
-/**< Can't write to the file or resource */
-#define MPR_ERR_DELETED (MPR_ERR_BASE - 19)
-#define MPR_ERR_NETWORK (MPR_ERR_BASE - 20)
-#define MPR_ERR_NOT_FOUND (MPR_ERR_BASE - 21)
-#define MPR_ERR_NOT_INITIALIZED (MPR_ERR_BASE - 22)
-/**< Module or resource is not initialized */
-#define MPR_ERR_NOT_READY (MPR_ERR_BASE - 23)
-#define MPR_ERR_READ_ONLY (MPR_ERR_BASE - 24)
-/**< The operation timed out */
-#define MPR_ERR_TIMEOUT (MPR_ERR_BASE - 25)
-#define MPR_ERR_TOO_MANY (MPR_ERR_BASE - 26)
-#define MPR_ERR_WONT_FIT (MPR_ERR_BASE - 27)
-#define MPR_ERR_WOULD_BLOCK (MPR_ERR_BASE - 28)
-#define MPR_ERR_CANT_ALLOCATE (MPR_ERR_BASE - 29)
-// MOB -- rename NO_MEMORY
-#define MPR_ERR_MEMORY (MPR_ERR_BASE - 30)
-#define MPR_ERR_CANT_DELETE (MPR_ERR_BASE - 31)
-#define MPR_ERR_MAX (MPR_ERR_BASE - 32)
-
-/*
- * Standard logging trace levels are 0 to 9 with 0 being the most verbose.
- * the These are ored with the error source and type flags. The MPR_LOG_MASK
- * is used to extract the trace level from a flags word. We expect most apps
- * to run with level 2 trace enabled.
- */
-#define MPR_ERROR 1 /**< Hard error trace level */
-#define MPR_WARN 2 /**< Soft warning trace level */
-#define MPR_CONFIG 2 /**< Configuration settings trace level. */
-#define MPR_INFO 3 /**< Informational trace only */
-#define MPR_DEBUG 4 /**< Debug information trace level */
-#define MPR_VERBOSE 9 /**< Highest level of trace */
-#define MPR_LEVEL_MASK 0xf /**< Level mask */
-
-/*
- * Error source flags
- */
-#define MPR_ERROR_SRC 0x10 /**< Originated from mprError */
-#define MPR_LOG_SRC 0x20 /**< Originated from mprLog */
-#define MPR_ASSERT_SRC 0x40 /**< Originated from mprAssert */
-#define MPR_FATAL_SRC 0x80 /**< Fatal error. Log and exit */
-
-/*
- * Log message type flags. Specify what kind of log / error message it is.
- * Listener handlers examine this flag to determine if they should process
- * the message.Assert messages are trapped when in DEV mode. Otherwise ignored.
- */
-#define MPR_LOG_MSG 0x100 /**< Log trace message - not an error */
-#define MPR_ERROR_MSG 0x200 /**< General error */
-#define MPR_ASSERT_MSG 0x400 /**< Assert flags -- trap in debugger */
-#define MPR_USER_MSG 0x800 /**< User message */
-
-/*
- * Log output modifiers
- */
-#define MPR_RAW 0x1000 /**< Raw trace output */
-
-/*
- * Error line number information.
- */
-#define MPR_LINE(s) #s
-#define MPR_LINE2(s) MPR_LINE(s)
-#define MPR_LINE3 MPR_LINE2(__LINE__)
-#define MPR_LOC __FILE__ ":" MPR_LINE3
-
-/*
- * Macros to pass file and line number information
- * Use MPR_LOC_ARGS in normal user code.
- * Use MPR_LOC_DEC in declarations.
- * Use MPR_LOC_PASS in layered APIs to pass original line info down.
- */
-#if BLD_FEATURE_ALLOC_LEAK_TRACK
-#define MPR_LOC_ARGS(ctx) ctx, MPR_LOC
-#define MPR_LOC_DEC(ctx, loc) MprCtx ctx, const char *loc
-#define MPR_LOC_PASS(ctx, loc) ctx, loc
-#else
-#define MPR_LOC_ARGS(ctx) ctx
-#define MPR_LOC_DEC(ctx, loc) MprCtx ctx
-#define MPR_LOC_PASS(ctx, loc) ctx
-#endif
-
-/******************************* Debug and Assert *****************************/
-
-extern void mprBreakpoint(const char *loc, const char *msg);
-
-#if BLD_FEATURE_ASSERT
- #define mprAssert(C) if (C) ; else mprStaticAssert(MPR_LOC, #C)
-#else
- #define mprAssert(C) if (1) ; else
-#endif
-
-/********************************* Safe Strings *******************************/
-/*
- * Unsafe functions that should not be used. Define UNSAFE_STRINGS_OK before
- * including mpr.h if you really want to use these functions. A better approach
- * is to undefine them just prior to using them in your C/C++ source file.
- */
-#if BLD_FEATURE_SAFE_STRINGS
-
-#if BLD_FEATURE_PHP4_MODULE || BLD_FEATURE_PHP5_MODULE
- #ifndef UNSAFE_FUNCTIONS_OK
- #define UNSAFE_FUNCTIONS_OK 1
- #endif
-#endif
-
-#ifndef UNSAFE_FUNCTIONS_OK
- #define sprintf UseMprSprintfInstead
- #define fprintf UseMprFprintfInstead
- #define vsprintf UseMprVsprintfInstead
- #define strtok UseMprStrTokInstead
- #define gethostbyname UseMprGetHostByNameInstead
- #define ctime UseMprCtimeInstead
- #define asctime UseMprAsctimeInstead
- #define localtime UseMprLocaltimeInstead
- #define gmtime UseMprGmtimeInstead
- #define malloc UseMprMallocInstead
- #define free UseMprFreeInstead
- #define realloc UseMprReallocInstead
- #define strncpy UseMprStrcpyInstead
- #define inet_ntoa UseMprInetToStrInstead
-
-#if !BREW
- #define printf UseMprPrintfInstead
-#endif
-
- #if FUTURE
- #define strlen UseMprStrlenInstead
- #define strcpy UseMprStrcpyInstead
- #endif
-
-#endif /* UNSAFE_FUNCTIONS_OK */
-#endif /* BLD_FEATURE_SAFE_STRINGS */
-
-/******************************************************************************/
-
-struct MprBuf;
-typedef int (*MprBufProc)(struct MprBuf* bp, void *arg);
-
-/**
- * @overview Dynamic buffer structure
- * @description MprBuf is a flexible, dynamic growable buffer structure. It
- * utilizes a ring buffer mechanism and is suitable for high performance
- * buffering in a variety of situations.
- * @stability Prototype.
- * @library libmpr.
- * @see mprCreateBuf, mprFree, MprArray
- */
-typedef struct MprBuf {
- uchar *buf; /* Actual buffer for data */
- uchar *endbuf; /* Pointer one past the end of buffer */
- uchar *start; /* Pointer to next data char */
- uchar *end; /* Pointer one past the last data chr */
- int buflen; /* Current size of buffer */
- int maxsize; /* Max size the buffer can ever grow */
- int growBy; /* Next growth increment to use */
- MprBufProc refillProc; /* Auto-refill procedure */
- void *refillArg; /* Refill arg */
-} MprBuf;
-
-/**
- * @overview File structure
- * @description MprFile is the cross platform File I/O abstraction control
- * structure.
- * @stability Prototype.
- * @library libmpr.
- * @see mprOpen, mprClose, mprRead, mprWrite
- */
-typedef struct MprFile
-{
- MprBuf *buf; /* Buffer for I/O */
-#if BREW
- IFile *fd; /* File handle */
-#else
- int fd;
-#endif
-} MprFile;
-
-/**
- * File information structure
- * @overview File information structure
- * @description MprFileInfo is the cross platform File information structure.
- * @stability Prototype.
- * @see mprGetFileInfo, mprOpen, mprClose, mprRead, mprWrite
- */
-typedef struct MprFileInfo
-{
- uint size; /* File length */
- uint ctime; /* Create time */
- uint mtime; /* Modified time */
- uint inode; /* Inode number */
- int isDir; /* Set if directory */
- int isReg; /* Set if a regular file */
-} MprFileInfo;
-
-/**
- * @overview Mpr time structure.
- * @description MprTime is the cross platform time abstraction structure.
- * @stability Prototype.
- * @library libmpr.
- * @see mprGetTime
- */
-typedef struct MprTime
-{
- uint sec; /* Seconds */
- uint msec; /* Milliseconds */
-} MprTime;
-
-
-/**
- * @overview Generic array type
- * @description The MprArray is a dynamic growable array suitable for storing
- * pointers to arbitrary objects.
- * @stability Prototype.
- * @library libmpr.
- * @see mprCreateItemArray, mprFree, MprBuf
- */
-typedef struct MprArray
-{
- int capacity; /* Current capacity of the array */
- int length; /* Count of used items */
- int incr; /* Growth increment */
- int maxSize; /* Maximum capacity */
- void **items;
-} MprArray;
-
-
-#if BLD_FEATURE_MULTITHREAD
-/**
- * @overview Multithreading lock control structure
- * @description MprLock is used for multithread locking in multithreaded
- * applications.
- * @library libmpr.
- * @see mprCreateLock, mprDestroyLock, mprLock, mprUnlock
- */
-typedef struct
-{
- #if WIN
- CRITICAL_SECTION cs; /* O/S critical section */
- #endif
- #if LINUX || MACOSX || SOLARIS
- pthread_mutex_t cs; /* O/S critical section */
- #endif
- #if VXWORKS
- SEM_ID cs; /* Semaphore */
- #endif
-} MprLock;
-#endif
-
-/*
- * Error and Logging callback
- */
-typedef void (*MprLogHandler)(MPR_LOC_DEC(ctx, loc), int flags,
- int level, const char *msg);
-
-/*
- * Symbol table
- * MOB -- rename hash
- */
-typedef struct MprSymbol
-{
- struct MprSymbol *next; /* Next symbol in hash chain */
- char *key; /* Symbol key */
- void *data; /* Pointer to symbol data */
- int bucket; /* Hash bucket index */
-} MprSymbol;
-
-typedef struct MprSymbolTable
-{
- MprSymbol **buckets;
- int hashSize; /* Size of the buckets array */
- int count; /* Number of symbols in the table */
-} MprSymbolTable;
-
-
-/*
- * Memory allocation error callback
- */
-struct MprApp;
-typedef int (*MprAllocCback)(struct MprApp *app, uint size, uint total,
- bool granted);
-
-
-/*
- * Slab block pointer links
- */
-typedef struct MprSlabBlock {
- struct MprSlabBlock *next;
-} MprSlabBlock;
-
-
-#if BLD_FEATURE_ALLOC_STATS
-/*
- * Memory Slab Statistics
- */
-typedef struct MprSlabStats {
- uint allocCount; /* Number of allocated blocks */
- uint freeCount; /* Number of blocks on the slab freelist */
- uint peakAllocCount; /* Peak allocated */
- uint totalAllocCount; /* Total count of allocation calls */
- uint peakFreeCount; /* Peak on the free list */
- MprSlabBlock *next;
-} MprSlabStats;
-#endif
-
-
-/*
- * Slab control structure
- */
-typedef struct MprSlab {
- MprSlabBlock *next;
- uint preAllocateIncr; /* Pre-allocation increment */
-#if BLD_FEATURE_ALLOC_STATS
- MprSlabStats stats;
-#endif
-} MprSlab;
-
-/*
- * Allocation stats (kept even in production code so we can detect memory
- * allocation failures)
- */
-typedef struct MprAllocStats
-{
- uint bytesAllocated; /* Bytes currently allocated */
- uint peakAllocated; /* Peak bytes allocated */
- uint allocCount; /* Number of allocated blocks */
- uint redLine; /* Warn above this level */
- uint maxMemory; /* Max memory to allocate */
- uint errors; /* Allocation errors */
-} MprAllocStats;
-
-/*
- * Memory allocation control
- */
-
-typedef struct MprAlloc {
- MprSlab *slabs; /* Array[MPR_MAX_SLAB] of MprSlab */
- MprAllocCback cback; /* Memory allocation callback */
- MprAllocStats stats; /* Keep stats even in release */
- int inAllocException; /* Recursive protect */
-} MprAlloc;
-
-
-/*
- * MprApp State Flags
- */
-#define MPR_APP_EXITING 0x1 /* App is exiting */
-#define MPR_APP_ALLOC_ERROR 0x2 /* App has allocation error */
-
-/* MOB -- temporary */
-#define MPR_APP_NEED_GC 0x4 /* App needs GC */
-
-/**
- * @overview Primary MPR application control structure
- * @description The MprApp structure stores critical application state
- * information and is the root memory allocation context block. It is
- * used as the MprCtx context for other memory allocations and is thus
- * the ultimate parent of all allocated memory.
- * \n\n
- * The MprApp structure is allocated by the mprInit API.
- */
-typedef struct MprApp
-{
- uint magic; /* Corruption protection */
- MprFile *console; /* Stdout file */
- bool debugMode; /* Run in debug mode (no timers) */
- MprFile *error; /* Stderr file */
- int logLevel; /* Log trace level */
- MprFile *logFile; /* Log file */
- MprLogHandler logHandler; /* Current log handler callback */
- MprSymbolTable *table;
- char *name; /* Product name */
- char *title; /* Product title */
- char *version; /* Product version */
-
-#if BREW
- uint classId; /* Brew class ID */
- IShell *shell; /* Brew shell object */
- IDisplay *display; /* Brew display object */
- IFileMgr *fileMgr; /* File manager */
- ITAPI *tapi; /* TAPI object */
- int displayHeight; /* Display height */
- int displayWidth; /* Display width */
- char *args; /* Command line args */
-#endif
-
- void *stackStart; /* Start of app stack */
- uint maxStack; /* Max stack size recorded */
-
- MprAlloc alloc; /* Memory allocation data */
- int flags; /* App state flags */
-
-#if BLD_FEATURE_MULTITHREAD
- MprLock *globalLock;
- MprLock *allocLock;
-#endif
-} MprApp;
-
-
-/*
- * String type. Minimum size is 8 words (32 bytes).
- */
-#define MPR_MAX_INLINE_STR 24
-
-
-/*
- * The block header structure for all allocated memory blocks (32 bytes)
- * WARNING: Don't increase the size of this structure. It just fits into
- * 32 bytes currently. Alignment requirements will double this size if you
- * add one byte!
- */
-typedef struct MprBlk
-{
- MprApp *app; /* app is the top level alloc context */
- struct MprBlk *parent; /* Parent block */
- struct MprBlk *children; /* First child block */
- struct MprBlk *next; /* Next sibling */
- struct MprBlk *prev; /* Previous sibling */
- MprDestructor destructor; /* Destructor function (optional) */
- uint size; /* Size of block sans HDR_SIZE */
- uint flags; /* Allocation flags and magic number */
-#if BLD_FEATURE_ALLOC_LEAK_TRACK
- const char *location; /* Allocating code (file + line) */
-#endif
-} MprBlk;
-
-/******************************************************************************/
-/****************************** Internal Prototypes ***************************/
-/******************************************************************************/
-
-extern void mprSignalAllocError(MprCtx ctx);
-
-/******************************************************************************/
-/********************************** Prototypes ********************************/
-/******************************************************************************/
-
-extern MprApp *mprInit(MprAllocCback cback);
-extern MprApp *mprInitEx(MprAllocCback cback, void *shell);
-extern void mprTerm(MprApp *app, bool doStats);
-extern void mprSignalExit(MprCtx ctx);
-extern bool mprIsExiting(MprCtx ctx);
-extern bool mprHasAllocError(MprCtx ctx);
-
-#if BLD_DEBUG && UNUSED
-extern MprApp *mprGetApp(MprCtx ctx);
-#else
-#define mprGetApp(ctx) \
- (((MprBlk*) ((char*) ctx - MPR_BLK_HDR_SIZE))->app)
-#endif
-
-/******************************************************************************/
-
-extern int mprSetKeyValue(MprCtx ctx, const char *key, void *ptr);
-/* MOB -- should this be delete or remove or unset */
-extern int mprRemoveKeyValue(MprCtx ctx, const char *key);
-extern void *mprGetKeyValue(MprCtx ctx, const char *key);
-/* MOB -- should be setAppName, getAppName */
-extern int mprSetAppName(MprCtx ctx, const char *name, const char *title,
- const char *version);
-extern const char *mprGetAppName(MprCtx ctx);
-extern const char *mprGetAppTitle(MprCtx ctx);
-extern const char *mprGetAppVersion(MprCtx ctx);
-
-/*
- * File services
- */
-extern void mprStopFileServices(MprCtx ctx);
-extern int mprStartFileServices(MprCtx ctx);
-
-/*
- * Item Array
- */
-#define mprCreateItemArray(ctx, initialSize, maxSize) \
- mprCreateItemArrayInternal(MPR_LOC_ARGS(ctx), initialSize, \
- maxSize)
-
-extern MprArray *mprCreateItemArrayInternal(MPR_LOC_DEC(ctx, loc),
- int initialSize, int maxSize);
-/* MOB -- should be insert not add/delete or insert / remove */
-extern int mprAddItem(MprArray *array, void *item);
-extern void mprClearItems(MprArray *array);
-extern void mprClearAndFreeItems(MprArray *array);
-extern int mprFindItem(MprArray *array, void *item);
-extern void *mprGetFirstItem(MprArray *array, int *lastIndex);
-extern void *mprGetItem(MprArray *array, int index);
-extern int mprGetItemCapacity(MprArray *array);
-extern int mprGetItemCount(MprArray *array);
-extern void *mprGetNextItem(MprArray *array, int *lastIndex);
-extern void *mprGetPrevItem(MprArray *array, int *lastIndex);
-extern int mprRemoveItem(MprArray *array, void *item);
-extern int mprRemoveItemByIndex(MprArray *array, int index);
-extern int mprRemoveRangeOfItems(MprArray *array, int start, int end);
-
-
-/*
- * Printf replacements
- */
-extern int mprSprintf(char *buf, int maxSize, const char *fmt, ...)
- PRINTF_ATTRIBUTE(3,4);
-extern int mprVsprintf(char *buf, int maxSize, const char *fmt,
- va_list arg) PRINTF_ATTRIBUTE(3,0);
-extern char *mprItoa(char *buf, int size, int value);
-extern int mprAtoi(const char *str, int radix);
-
-extern int mprPrintf(MprCtx ctx, const char *fmt, ...)
- PRINTF_ATTRIBUTE(2,3);
-/* MOB -- NEED DOC */
-extern int mprErrorPrintf(MprCtx ctx, const char *fmt, ...)
- PRINTF_ATTRIBUTE(2,3);
-extern int mprStaticPrintf(MprCtx ctx, const char *fmt, ...)
- PRINTF_ATTRIBUTE(2,3);
-extern int mprPrintfError(MprCtx ctx, const char *fmt, ...)
- PRINTF_ATTRIBUTE(2,3);
-extern int mprFprintf(MprFile *file, const char *fmt, ...)
- PRINTF_ATTRIBUTE(2,3);
-
-/*
- * Safe string routines
- */
-extern char *mprGetWordTok(char *buf, int bufsize, const char *str,
- const char *delim, const char **tok);
-extern int mprMemcpy(char *dest, int destMax, const char *src,
- int nbytes);
-extern int mprStrcat(char *dest, int max, const char *delim,
- const char *src, ...);
-extern int mprStrcpy(char *dest, int destMax, const char *src);
-
-extern int mprStrcmpAnyCase(const char *str1, const char *str2);
-extern int mprStrcmpAnyCaseCount(const char *str1, const char *str2,
- int len);
-extern int mprStrlen(const char *src, int max);
-
-extern char *mprStrLower(char *str);
-extern char *mprStrUpper(char *str);
-extern char *mprStrTrim(char *str, const char *set);
-extern char *mprStrTok(char *str, const char *delim, char **last);
-
-/*
- * Symbol table
- */
-extern MprSymbolTable *mprCreateSymbolTable(MprCtx ctx, int hashSize);
-extern MprSymbol *mprGetFirstSymbol(MprSymbolTable *table);
-extern MprSymbol *mprGetNextSymbol(MprSymbolTable *table, MprSymbol *last);
-extern int mprGetSymbolCount(MprSymbolTable *table);
-extern MprSymbol *mprInsertSymbol(MprSymbolTable *table, const char *key,
- void *ptr);
-extern void *mprLookupSymbol(MprSymbolTable *table, const char *key);
-extern int mprRemoveSymbol(MprSymbolTable *table, const char *key);
-
-/*
- * File I/O support
- */
-extern void mprClose(MprFile *file);
-extern int mprDelete(MprCtx ctx, const char *path);
-extern int mprDeleteDir(MprCtx ctx, const char *path);
-extern int mprGetFileInfo(MprCtx ctx, const char *path, MprFileInfo *info);
-extern char *mprGets(MprFile *file, char *buf, uint size);
-extern int mprMakeDir(MprCtx ctx, const char *path, int perms);
-extern MprFile *mprOpen(MprCtx ctx, const char *path, int omode, int perms);
-extern int mprPuts(MprFile *file, const char *buf, uint size);
-extern int mprRead(MprFile *file, void *buf, uint size);
-extern int mprSeek(MprFile *file, int seekType, long distance);
-extern int mprWrite(MprFile *file, const void *buf, uint count);
-
-extern int mprMakeTempFileName(MprCtx ctx, char *buf, int bufsize,
- const char *tmpDir);
-
-
-/*
- * Error handling and logging
- */
-extern void mprSetLogHandler(MprCtx ctx, MprLogHandler handler);
-extern MprLogHandler mprGetLogHandler(MprCtx ctx);
-
-extern void mprAssertError(MPR_LOC_DEC(ctx, loc), const char *msg);
-extern void mprError(MPR_LOC_DEC(ctx, loc),
- const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
-extern void mprFatalError(MPR_LOC_DEC(ctx, loc),
- const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
-extern void mprLog(MprCtx ctx, int level,
- const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
-extern void mprRawLog(MprCtx ctx, const char *fmt, ...);
-extern void mprStaticAssert(const char *loc, const char *msg);
-extern void mprStaticError(MPR_LOC_DEC(ctx, loc),
- const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
-extern void mprUserError(MPR_LOC_DEC(ctx, loc),
- const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
-
-/*
- * Dynamic Buffering routines
- */
-extern MprBuf *mprCreateBuf(MprCtx ctx, int initialSize, int maxSize);
-extern char *mprStealBuf(MprCtx ctx, MprBuf *bp);
-extern void mprAddNullToBuf(MprBuf *bp);
-extern void mprAdjustBufStart(MprBuf *bp, int size);
-extern void mprAdjustBufEnd(MprBuf *bp, int size);
-extern void mprCopyBufDown(MprBuf *bp);
-extern void mprFlushBuf(MprBuf *bp);
-extern int mprGetCharFromBuf(MprBuf *bp);
-extern int mprGetBlockFromBuf(MprBuf *bp, uchar *buf, int len);
-extern int mprGetBufLength(MprBuf *bp);
-extern int mprGetBufLinearSpace(MprBuf *bp);
-extern int mprGetBufLinearData(MprBuf *bp);
-extern char *mprGetBufOrigin(MprBuf *bp);
-extern int mprGetBufSize(MprBuf *bp);
-extern int mprGetBufSpace(MprBuf *bp);
-extern char *mprGetBufStart(MprBuf *bp);
-extern char *mprGetBufEnd(MprBuf *bp);
-extern int mprInsertCharToBuf(MprBuf *bp, int c);
-extern int mprLookAtNextCharInBuf(MprBuf *bp);
-extern int mprLookAtLastCharInBuf(MprBuf *bp);
-extern int mprPutCharToBuf(MprBuf *bp, int c);
-extern int mprPutBlockToBuf(MprBuf *bp, const char *str, int size);
-extern int mprPutIntToBuf(MprBuf *bp, int i);
-extern int mprPutStringToBuf(MprBuf *bp, const char *str);
-extern int mprPutFmtStringToBuf(MprBuf *bp, const char *fmt, ...);
-extern int mprRefillBuf(MprBuf *bp);
-extern void mprResetBufIfEmpty(MprBuf *bp);
-extern void mprSetBufSize(MprBuf *bp, int initialSize, int maxSize);
-extern MprBufProc mprGetBufRefillProc(MprBuf *bp);
-extern void mprSetBufRefillProc(MprBuf *bp, MprBufProc fn, void *arg);
-
-/*
- * General other xPlatform routines
- */
-extern const char *mprGetBaseName(const char *name);
-extern bool mprGetDebugMode(MprCtx ctx);
-extern char *mprGetDirName(char *buf, int bufsize, const char *path);
-extern char *mprGetFullPathName(char *buf, int buflen, const char *path);
-extern int mprGetLogLevel(MprCtx ctx);
-extern int mprGetOsError();
-
-
-extern int mprMakeArgv(MprCtx ctx, const char *prog, const char *cmd,
- char ***argv, int *argc);
-extern int mprMakeDirPath(MprCtx ctx, const char *path);
-extern void mprSetDebugMode(MprCtx ctx, bool on);
-extern void mprSetLogLevel(MprCtx ctx, int level);
-extern void mprSleep(MprCtx ctx, int msec);
-extern void mprSetShell(MprCtx ctx, void *shell);
-extern void *mprGetShell(MprCtx ctx);
-extern void mprSetClassId(MprCtx ctx, uint classId);
-extern uint mprGetClassId(MprCtx ctx);
-
-#if BREW
-extern void mprSetDisplay(MprCtx ctx, void *display);
-extern void *mprGetDisplay(MprCtx ctx);
-extern void mprSetFileMgr(MprCtx ctx, void *fileMgr);
-extern void *mprGetFileMgr(MprCtx ctx);
-#else
-extern char *mprInetToStr(char *buf, int size, const struct in_addr in);
-#endif
-
-/*
- * Memory allocation
- */
-extern MprApp *mprAllocInit(MprAllocCback cback);
-extern void mprAllocTerm(MprApp *app);
-extern void mprAllocAbort();
-
-extern void *mprAllocBlock(MPR_LOC_DEC(ctx, loc), uint size);
-extern void *mprAllocZeroedBlock(MPR_LOC_DEC(ctx, loc), uint size);
-extern void *mprReallocBlock(MPR_LOC_DEC(ctx, loc), void *ptr, uint size);
-extern int mprFree(void *ptr);
-extern int mprStealAllocBlock(MPR_LOC_DEC(ctx, loc), const void *ptr);
-extern void *mprMemdupInternal(MPR_LOC_DEC(ctx, loc), const void *ptr,
- uint size);
-extern char *mprStrndupInternal(MPR_LOC_DEC(ctx, loc), const char *str,
- uint size);
-extern char *mprStrdupInternal(MPR_LOC_DEC(ctx, loc), const char *str);
-
-extern void *mprSlabAllocBlock(MPR_LOC_DEC(ctx, loc), uint size, uint inc);
-extern void *mprSlabAllocZeroedBlock(MPR_LOC_DEC(ctx, loc), uint size,
- uint inc);
-
-extern uint mprGetAllocBlockSize(MprCtx ctx);
-extern uint mprGetAllocBlockCount(MprCtx ctx);
-extern uint mprGetAllocBlockMemory(MprCtx ctx);
-extern void *mprGetAllocParent(MprCtx ctx);
-extern uint mprGetAllocatedMemory(MprCtx ctx);
-extern uint mprGetPeakAllocatedMemory(MprCtx ctx);
-extern uint mprGetAllocatedSlabMemory(MprCtx ctx);
-extern int mprIsAllocBlockValid(MprCtx ctx);
-extern int mprStackCheck(MprCtx ctx);
-extern int mprStackSize(MprCtx ctx);
-extern int mprGetAllocErrors(MprCtx ctx);
-extern void mprClearAllocErrors(MprCtx ctx);
-
-extern MprDestructor mprSetDestructor(MprCtx ctx, MprDestructor destructor);
-extern MprAllocCback mprSetAllocCallback(MprApp *app, MprAllocCback cback);
-extern void mprSetAllocLimits(MprApp *app, uint redLine, uint maxMemory);
-
-#if BLD_FEATURE_ALLOC_STATS
-extern MprSlabStats *mprGetSlabAllocStats(MprApp *app, int slabIndex);
-extern MprAllocStats *mprGetAllocStats(MprApp *app);
-extern void mprPrintAllocReport(MprApp *app, bool doBlocks,
- const char *msg);
-#endif
-
-#if BLD_DEBUG
-extern int mprPrintAllocBlocks(MprCtx ctx, int indent);
-extern const char *mprGetAllocLocation(MprCtx ptr);
-#endif
-
-extern int mprValidateBlock(MprCtx ctx);
-extern int mprValidateAllocTree(MprCtx ptr);
-extern void mprSetRequiredAlloc(MprCtx ptr, bool recurse);
-
-/*
- * Sprintf style allocators
- */
-extern int mprAllocSprintf(MPR_LOC_DEC(ctx, loc), char **buf, int maxSize,
- const char *fmt, ...) PRINTF_ATTRIBUTE(5,6);
-extern int mprAllocVsprintf(MPR_LOC_DEC(ctx, loc), char **buf, int maxSize,
- const char *fmt, va_list arg) PRINTF_ATTRIBUTE(5,0);
-extern int mprAllocMemcpy(MPR_LOC_DEC(ctx, loc), char **dest, int destMax,
- const void *src, int nbytes);
-extern int mprAllocStrcat(MPR_LOC_DEC(ctx, loc), char **dest, int max,
- const char *delim, const char *src, ...);
-extern int mprAllocStrcpy(MPR_LOC_DEC(ctx, loc), char **dest, int max,
- const char *src);
-extern int mprReallocStrcat(MPR_LOC_DEC(ctx, loc), char **dest, int max,
- int existingLen, const char *delim, const char *src, ...);
-
-/*
- * MACROS: These are the convenience macros to automatically supply file
- * names and line numbers when debugging.
- */
-#define mprNew(ctx) new(MPR_LOC_ARGS(ctx))
-
-#define mprAlloc(ctx, size) mprAllocBlock(MPR_LOC_ARGS(ctx), size)
-
-#define mprAllocZeroed(ctx, size) mprAllocZeroedBlock(MPR_LOC_ARGS(ctx), size)
-
-#define mprSlabAlloc(ctx, size, inc) \
- ((type*) mprSlabAllocBlock(MPR_LOC_ARGS(ctx), size, inc))
-
-#define mprSlabAllocZeroed(ctx, size, inc) \
- ((type*) mprSlabAllocBlock(MPR_LOC_ARGS(ctx), size, inc))
-
-#define mprRealloc(ctx, ptr, size) mprReallocBlock(MPR_LOC_ARGS(ctx), ptr, size)
-
-#define mprMemdup(ctx, ptr, size) \
- mprMemdupInternal(MPR_LOC_ARGS(ctx), ptr, size)
-
-#define mprStrdup(ctx, str) mprStrdupInternal(MPR_LOC_ARGS(ctx), str)
-
-#define mprStrndup(ctx, str, size) mprStrndupDebug(MPR_LOC_ARGS(ctx), str, size)
-
-/*
- * Allocate type macros
- */
-#define mprAllocType(ctx, type) \
- ((type*) mprAllocBlock(MPR_LOC_ARGS(ctx), sizeof(type)))
-
-#define mprAllocTypeZeroed(ctx, type) \
- ((type*) mprAllocZeroedBlock(MPR_LOC_ARGS(ctx), sizeof(type)))
-
-#define mprSlabAllocType(ctx, type, inc) \
- ((type*) mprSlabAllocBlock(MPR_LOC_ARGS(ctx), sizeof(type), inc))
-
-#define mprSlabAllocTypeZeroed(ctx, type, inc) \
- ((type*) mprSlabAllocZeroedBlock(MPR_LOC_ARGS(ctx), sizeof(type), \
- inc))
-
-/*
- * Multithread locking
- */
-#if BLD_FEATURE_MULTITHREAD
-extern void mprInitThreads(MprApp *app);
-extern void mprTermThreads(MprApp *app);
-extern MprLock *mprCreateLock(MprCtx ctx);
-extern void mprDestroyLock(MprLock *lock);
-extern void mprLock(MprLock *lock);
-extern int mprTryLock(MprLock *lock);
-extern void mprUnlock(MprLock *lock);
-extern void mprGlobalLock(MprCtx ctx);
-extern void mprGlobalUnlock(MprCtx ctx);
-extern int mprGetCurrentThreadID();
-#else
-/*
- * Disable multithreading
- */
-#define mprInitThreads(ctx, app)
-#define mprTermThreads(app)
-#define mprCreateLock(ctx)
-#define mprDestroyLock(lock)
-#define mprLock(lock)
-#define mprTryLock(lock)
-#define mprUnlock(lock)
-#define mprGlobalLock(app)
-#define mprGlobalUnlock(app)
-#define mprGetCurrentThreadID()
-#endif
-
-/*
- * Time
- */
-extern MprTime *mprGetTime(MprCtx ctx, MprTime *tp);
-extern int mprGetTimeRemaining(MprCtx ctx, MprTime mark, uint timeout);
-extern int mprGetElapsedTime(MprCtx ctx, MprTime mark);
-extern int mprCompareTime(MprTime *t1, MprTime *t2);
-extern uint mprSubtractTime(MprTime *t1, MprTime *t2);
-extern void mprAddElapsedToTime(MprTime *time, uint elapsed);
-
-#if !BREW
-extern int mprAsctime(MprCtx ctx, char *buf, int bufsize,
- const struct tm *timeptr);
-extern int mprCtime(MprCtx ctx, char *buf, int bufsize,
- const time_t *timer);
-extern struct tm *mprLocaltime(MprCtx ctx, struct tm *timep, time_t *now);
-extern struct tm *mprGmtime(MprCtx ctx, time_t* now, struct tm *timep);
-extern int mprRfcTime(MprCtx ctx, char *buf, int bufsize,
- const struct tm *timep);
-#endif /* !BREW */
-
-/*
- * Host name
- */
-extern struct hostent* mprGetHostByName(MprCtx ctx, const char *name);
-
-#if WIN
-extern int mprReadRegistry(MprCtx ctx, char **buf, int max,
- const char *key, const char *val);
-extern int mprWriteRegistry(MprCtx ctx, const char *key, const char *name,
- const char *value);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _h_MPR */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprAlloc.c b/source4/lib/appweb/ejs-2.0/mpr/mprAlloc.c
deleted file mode 100644
index 6fcaa63a6c..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/mprAlloc.c
+++ /dev/null
@@ -1,1775 +0,0 @@
-/**
- * @file mprAlloc.c
- * @brief Memory Allocation
- * @overview
- */
-
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/********************************* Includes ***********************************/
-
-#define UNSAFE_FUNCTIONS_OK 1
-
-#include "mpr.h"
-
-/******************************* Local Defines ********************************/
-/*
- * Set to 1 to disable slab based allocations
- */
-#define NO_SLAB 0
-
-/*
- * Validation mode is quite slow
- */
-#define VALIDATE_ALLOC 0
-#if VALIDATE_ALLOC
-#define VALIDATE_BLOCK(ptr) mprValidateBlock(ptr)
-#else
-#define VALIDATE_BLOCK(ptr)
-#endif
-
-/*
- * Align on 4 bytes if squeeze, Otherwize on 16 bytes.
- */
-#define HDR_SIZE MPR_BLK_HDR_SIZE
-
-#define APP_MAGIC 0xa571cb80
-#define ALLOC_MAGIC 0xe814ecc0
-
-/*
- * This must be at least one word to ensure that the smallest allocation is
- * 4 bytes. Slab allocations need at least one word to store their next ptr.
- */
-#define ALLOC_ALIGN(x) (((x)+3)&~3)
-#define GET_HDR(ptr) ((MprBlk*) (((char*) (ptr)) - HDR_SIZE))
-#define GET_PTR(bp) ((void*) (((char*) (bp)) + HDR_SIZE))
-#define VALID_HDR(bp) (((bp)->flags & ~0x3F) == ALLOC_MAGIC)
-#define VALID_BLK(ptr) (VALID_HDR(GET_HDR(ptr)))
-
-/*
- * In production releases, mprAssert will compile out (not be included)
- * but CHECK_HDR will remain even in production builds.
- */
-#define CHECK_HDR(bp) \
- if (1) { if (! VALID_HDR(bp)) { mprAllocAbort(); } } else
-
-/*
- * Chunk the slabs into 32 byte increments.
- * This allows for allocations up to 512 bytes via slabs and maximizes
- * sharing of slab allocations.
- *
- * Index map:
- * 0 == 32 bytes
- * 1 == 64 bytes
- * 2 == 96 bytes
- * 3 == 128 bytes
- * 4 == 160 bytes
- * 5 == 192 bytes
- * 6 == 224 bytes
- * 7 == 256 bytes
- * 8 == 288 bytes
- * 9 == 320 bytes
- * 10 == 352 bytes
- * 11 == 384 bytes
- * 12 == 416 bytes
- * 13 == 448 bytes
- * 14 == 480 bytes
- * 15 == 512 bytes
- */
-#define SLAB_ALIGN(size) ((size + 31) & ~31)
-#define GET_SLAB(size) (size >> 6)
-
-/*
- * Block flags
- */
-#define ALLOC_FLAGS_FREE 0x1 /* Block is free */
-#define ALLOC_FLAGS_FREEING 0x2 /* Block is being freed */
-#define ALLOC_FLAGS_SLAB_BLOCK 0x4 /* Block was allocated from slab */
-#define ALLOC_FLAGS_REQUIRED 0x8 /* Block is required by alloc */
-#define ALLOC_FLAGS_KEEP 0x10 /* Keep block - don't mprFree */
-#define ALLOC_FLAGS_DONT_OS_FREE 0x20 /* Don't return mem to O/S */
-#define ALLOC_FLAGS_IS_SLAB 0x40 /* Block is a slab */
-
-#if BLD_DEBUG && !BREW
-/*
- * Set this address to break when this address is allocated or freed. This is
- * a block address (not a user ptr).
- */
-static MprBlk *stopAlloc;
-#endif
-
-#if !BREW
-static MprCtx rootCtx; /* Root context if none supplied */
-#endif
-
-/***************************** Forward Declarations ***************************/
-
-static int mprAllocException(MPR_LOC_DEC(ptr, loc), uint size, bool granted);
-static void slabFree(MprBlk *bp);
-static int growSlab(MPR_LOC_DEC(ctx, loc), MprSlab *slab, uint size, uint inc);
-
-/******************************************************************************/
-/*
- * Put first in file so it is easy to locate in a debugger
- */
-
-void mprBreakpoint(const char *loc, const char *msg)
-{
-}
-
-/******************************************************************************/
-#if (WIN || BREW_SIMULATOR) && BLD_DEBUG
-
-int crtReportHook(int type, char *msg, int *retval)
-{
- printf("%s\n", msg);
- *retval = 0;
- return TRUE;
-}
-
-#endif
-/******************************************************************************/
-/*
- * Initialize the memory subsystem
- */
-
-MprApp *mprAllocInit(MprAllocCback cback)
-{
- MprAllocStats *stats;
- MprApp *app;
- MprSlab *slab;
- MprBlk *bp, *sp;
- int i;
-
- bp = malloc(sizeof(MprApp) + HDR_SIZE);
- mprAssert(bp);
- if (bp == 0) {
- if (cback) {
- (*cback)(0, sizeof(MprApp), 0, 0);
- }
- return 0;
- }
- memset(bp, 0, sizeof(MprApp) + HDR_SIZE);
-
- bp->parent = bp;
- bp->size = sizeof(MprApp);
- bp->flags = ALLOC_MAGIC;
- bp->next = bp->prev = bp;
-
-#if BLD_FEATURE_ALLOC_LEAK_TRACK
- bp->location = MPR_LOC;
-#endif
-
- app = (MprApp*) GET_PTR(bp);
- app->magic = APP_MAGIC;
-
- app->alloc.cback = cback;
- app->stackStart = (void*) &app;
-
- bp->app = app;
-
- app->alloc.slabs = mprAllocZeroedBlock(MPR_LOC_PASS(app, MPR_LOC),
- sizeof(MprSlab) * MPR_MAX_SLAB);
- if (app->alloc.slabs == 0) {
- mprFree(app);
- return 0;
- }
-
- /*
- * The slab control structures must not be freed. Set keep to safeguard
- * against accidents.
- */
- sp = GET_HDR(app->alloc.slabs);
- sp->flags |= ALLOC_FLAGS_KEEP;
-
- for (i = 0; i < MPR_MAX_SLAB; i++) {
- /*
- * This is overriden by requestors calling slabAlloc
- */
- slab = &app->alloc.slabs[i];
- slab->preAllocateIncr = MPR_SLAB_DEFAULT_INC;
- }
-
- /*
- * Keep aggregated stats even in production code
- */
- stats = &app->alloc.stats;
- stats->bytesAllocated += sizeof(MprApp);
- if (stats->bytesAllocated > stats->peakAllocated) {
- stats->peakAllocated = stats->bytesAllocated;
- }
- stats->allocCount++;
-
-#if !BREW
- rootCtx = app;
-#endif
-#if (WIN || BREW_SIMULATOR) && BLD_DEBUG
- _CrtSetReportHook(crtReportHook);
-#endif
- return app;
-}
-
-/******************************************************************************/
-/*
- * Terminate the alloc module
- */
-
-void mprAllocTerm(MprApp *app)
-{
- MprSlab *slabs;
- MprBlk *appBlk, *slabBlk;
-
- /*
- * Must do a carefully ordered cleanup. Need to free all children blocks
- * before freeing the slab memory. Save a local pointer to the slabs.
- */
- slabs = app->alloc.slabs;
-
- /*
- * Free the app and all children. Set DONT_OS_FREE to prevent free() being
- * called on app itself. We need that so we can free the slabs below.
- */
- appBlk = GET_HDR(app);
- appBlk->flags |= ALLOC_FLAGS_DONT_OS_FREE;
- mprFree(app);
-
- /*
- * Slabs are initially marked don't free. We must preserve them while all
- * other blocks are freed. Then we clear the don't free flag and free.
- * Now we don't have an app structure which is used by mprFree. We must
- * fake it.
- */
- slabBlk = GET_HDR(slabs);
- slabBlk->flags &= ~ALLOC_FLAGS_KEEP;
- mprFree(slabs);
-
- /*
- * Now we can finally free the memory for the app structure
- */
- free(appBlk);
-}
-
-/******************************************************************************/
-/*
- * Allocate a block
- */
-
-void *mprAllocBlock(MPR_LOC_DEC(ctx, loc), uint size)
-{
- MprAllocStats *stats;
- MprBlk *bp, *parent;
- MprApp *app;
- int diff;
-
- mprAssert(size > 0);
-
- if (ctx == 0) {
-#if BREW
- mprAssert(ctx);
- return 0;
-#else
- ctx = rootCtx;
-#endif
- }
- if (size == 0) {
- size = 1;
- }
-
- mprAssert(VALID_BLK(ctx));
- parent = GET_HDR(ctx);
- mprAssert(VALID_HDR(parent));
-
- CHECK_HDR(parent);
-
- size = ALLOC_ALIGN(size);
-
- app = parent->app;
-
- stats = &app->alloc.stats;
-
- mprLock(app->allocLock);
-
- stats->bytesAllocated += size + HDR_SIZE;
- if (stats->bytesAllocated > stats->peakAllocated) {
- stats->peakAllocated = stats->bytesAllocated;
- }
-
- /*
- * Prevent allocation if over the maximum
- */
- if (stats->maxMemory && stats->bytesAllocated > stats->maxMemory) {
- stats->bytesAllocated -= (size + HDR_SIZE);
- mprUnlock(app->allocLock);
- if (mprAllocException(MPR_LOC_PASS(ctx, loc), size, 0) < 0) {
- return 0;
- }
- mprLock(app->allocLock);
- }
-
- if ((bp = malloc(size + HDR_SIZE)) == 0) {
- mprAssert(bp);
- stats->errors++;
- mprUnlock(app->allocLock);
- mprAllocException(MPR_LOC_PASS(ctx, loc), size, 0);
- return 0;
- }
-
-#if BLD_DEBUG
- memset(bp, 0xf7, size + HDR_SIZE);
-#endif
-
-#if BLD_DEBUG && !BREW
- if (bp == stopAlloc) {
- mprBreakpoint(MPR_LOC, "breakOnAddr");
- }
-#endif
-
- /*
- * Warn if allocation puts us over the red line
- */
- if (stats->redLine && stats->bytesAllocated > stats->redLine) {
- mprUnlock(app->allocLock);
- if (mprAllocException(MPR_LOC_PASS(ctx, loc), size, 1) < 0) {
- return 0;
- }
- mprLock(app->allocLock);
- }
-
- bp->size = size;
- bp->flags = ALLOC_MAGIC;
- bp->destructor = 0;
-
- bp->parent = parent;
-
- if (parent->children == 0) {
- parent->children = bp;
- bp->next = bp->prev = bp;
-
- } else {
- /*
- * Append to the end of the list. Preserve alloc order
- */
- bp->next = parent->children;
- bp->prev = parent->children->prev;
- parent->children->prev->next = bp;
- parent->children->prev = bp;
- }
-
- bp->children = 0;
-
-#if BLD_FEATURE_ALLOC_LEAK_TRACK
- bp->location = loc;
-#endif
-
- bp->app = parent->app;
-
- VALIDATE_BLOCK(GET_PTR(bp));
-
- stats->allocCount++;
-
- /*
- * Monitor stack usage
- */
- diff = (int) bp->app->stackStart - (int) &stats;
- if (diff < 0) {
- app->maxStack -= diff;
- app->stackStart = (void*) &stats;
- diff = 0;
- }
-
- if ((uint) diff > app->maxStack) {
- app->maxStack = diff;
- }
- mprUnlock(app->allocLock);
-
- return GET_PTR(bp);
-}
-
-/******************************************************************************/
-/*
- * Allocate and zero a block
- */
-
-void *mprAllocZeroedBlock(MPR_LOC_DEC(ctx, loc), uint size)
-{
- void *newBlock;
-
- MprBlk *bp;
-
- bp = GET_HDR(ctx);
- mprAssert(VALID_BLK(ctx));
-
- newBlock = mprAllocBlock(MPR_LOC_PASS(ctx, loc), size);
- if (newBlock) {
- memset(newBlock, 0, size);
- }
- return newBlock;
-}
-
-/******************************************************************************/
-/*
- * Free a block of memory. Free all children recursively.
- */
-
-int mprFree(void *ptr)
-{
- MprAllocStats *stats;
- MprBlk *bp, *parent, *cp, *firstChild, *prev;
- MprApp *app;
-
- if (ptr == 0) {
- return 0;
- }
-
- mprAssert(VALID_BLK(ptr));
- VALIDATE_BLOCK(ptr);
-
- bp = GET_HDR(ptr);
-
-#if BLD_DEBUG && !BREW
- if (bp == stopAlloc) {
- mprBreakpoint(MPR_LOC, "breakOnAddr");
- }
-#endif
-
- mprAssert(bp);
- mprAssert(VALID_HDR(bp));
-
- CHECK_HDR(bp);
-
- /*
- * Test if already freed
- */
- mprAssert(! (bp->flags & ALLOC_FLAGS_FREE));
- if (bp->flags & ALLOC_FLAGS_FREE) {
- return 0;
- }
-
- /*
- * Return if recursive freeing or this is a permanent block
- */
- app = bp->app;
- mprLock(app->allocLock);
- if (bp->flags & (ALLOC_FLAGS_FREEING | ALLOC_FLAGS_KEEP)) {
- mprUnlock(app->allocLock);
- return 0;
- }
- bp->flags |= ALLOC_FLAGS_FREEING;
-
-
- /*
- * Call any destructors
- */
- if (bp->destructor) {
- mprUnlock(app->allocLock);
- if ((bp->destructor)(ptr) < 0) {
- return -1;
- }
- mprLock(app->allocLock);
- bp->destructor = 0;
- }
-
- /*
- * Free the children. Free in reverse order so firstChild is preserved
- * during the list scan as an end of list marker.
- */
- if ((firstChild = bp->children) != 0) {
- cp = firstChild->prev;
- while (cp != firstChild) {
-
- mprAssert(VALID_HDR(cp));
- VALIDATE_BLOCK(GET_PTR(cp));
-
- prev = cp->prev;
-
- /*
- * FUTURE - OPT. Make this inline
- */
- mprFree(GET_PTR(cp));
-
- cp = prev;
- }
-
- mprFree(GET_PTR(firstChild));
-
- /*
- * Just for clarity
- */
- bp->children = 0;
- }
-
- parent = bp->parent;
-
- mprAssert(VALID_HDR(parent));
-
- /*
- * Unlink from the parent
- */
- if (parent->children == bp) {
- if (bp->next == bp) {
- parent->children = 0;
- } else {
- parent->children = bp->next;
- }
- }
-
- /*
- * Remove from the sibling chain
- */
- bp->prev->next = bp->next;
- bp->next->prev = bp->prev;
-
- bp->flags |= ALLOC_FLAGS_FREE;
-
- /*
- * Release the memory. If from a slab, return to the slab. Otherwise,
- * return to the O/S.
- */
- if (bp->flags & ALLOC_FLAGS_SLAB_BLOCK) {
- slabFree(bp);
-
- } else {
- mprAssert(bp);
-
- /*
- * Update the stats
- */
- stats = &bp->app->alloc.stats;
- stats->bytesAllocated -= (bp->size + HDR_SIZE);
- mprAssert(stats->bytesAllocated >= 0);
-
- stats->allocCount--;
- mprAssert(stats->allocCount >= 0);
-
-#if BLD_DEBUG && !BREW
- if (bp == stopAlloc) {
- mprBreakpoint(MPR_LOC, "breakOnAddr");
- }
-#endif
-
- /*
- * Return to the O/S
- */
- if (! (bp->flags & ALLOC_FLAGS_DONT_OS_FREE)) {
- free(bp);
- }
- }
- /* OPT */
- if (app != ptr) {
- mprUnlock(app->allocLock);
- }
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Rallocate a block
- */
-
-void *mprReallocBlock(MPR_LOC_DEC(ctx, loc), void *ptr, uint size)
-{
- MprBlk *bp, *newbp, *firstChild, *cp;
- MprApp *app;
- void *newPtr;
-
- mprAssert(VALID_BLK(ctx));
- mprAssert(size > 0);
-
- if (ptr == 0) {
- return mprAllocBlock(MPR_LOC_PASS(ctx, loc), size);
- }
-
- mprAssert(VALID_BLK(ptr));
- bp = GET_HDR(ptr);
- mprAssert(bp);
- mprAssert(VALID_HDR(bp));
-
- CHECK_HDR(bp);
-
- if (size < bp->size) {
- return ptr;
- }
-
- newPtr = mprAllocBlock(MPR_LOC_PASS(ctx, loc), size);
- if (newPtr == 0) {
- bp->flags &= ~ALLOC_FLAGS_FREE;
- free(bp);
- return 0;
- }
-
- newbp = GET_HDR(newPtr);
- mprAssert(newbp->size >= size);
- memcpy((char*) newbp + HDR_SIZE, (char*) bp + HDR_SIZE, bp->size);
- mprAssert(newbp->size >= size);
-
- /*
- * Fix the next / prev pointers
- */
- app = bp->app;
- mprLock(app->allocLock);
- newbp->next->prev = newbp;
- newbp->prev->next = newbp;
-
- /*
- * Need to fix the parent pointer of all children
- */
- if ((firstChild = newbp->children) != 0) {
- cp = firstChild;
- do {
- cp->parent = newbp;
- cp = cp->next;
- } while (cp != firstChild);
- }
-
- /*
- * May need to set the children pointer of our parent
- */
- if (newbp->parent->children == bp) {
- newbp->parent->children = newbp;
- }
-
- /*
- * Free the original block
- */
- mprFree(ptr);
-
- mprUnlock(app->allocLock);
-
- return GET_PTR(newbp);
-}
-
-/******************************************************************************/
-/*
- * Allocate a block from a slab
- */
-
-void *mprSlabAllocBlock(MPR_LOC_DEC(ctx, loc), uint size, uint inc)
-{
-
-#if NO_SLAB
- return mprAllocBlock(MPR_LOC_PASS(ctx, loc), size);
-#else
-
- MprBlk *parent, *bp;
- MprSlabBlock *sb;
- MprApp *app;
- MprSlab *slab;
- int slabIndex;
-
- if (ctx == 0) {
- mprAssert(ctx);
- return 0;
- }
-
- mprAssert(size > 0);
- mprAssert(VALID_BLK(ctx));
-
- parent = GET_HDR(ctx);
- mprAssert(VALID_HDR(parent));
-
- CHECK_HDR(parent);
-
- size = SLAB_ALIGN(size);
-
- app = parent->app;
- mprAssert(app);
-
- slabIndex = GET_SLAB(size);
-
- if (slabIndex < 0 || slabIndex >= MPR_MAX_SLAB) {
- return mprAllocBlock(MPR_LOC_PASS(ctx, loc), size);
- }
-
- /*
- * Dequeue a block from the slab. "sb" will point to the user data
- * portion of the block (i.e. after the MprBlk header). Slabs must be
- * allocated off the "slabs" context to ensure they don't get freed
- * until after all other blocks are freed.
- */
- mprLock(app->allocLock);
- slab = &app->alloc.slabs[slabIndex];
- if ((sb = slab->next) == 0) {
- if (growSlab(MPR_LOC_ARGS(parent->app->alloc.slabs),
- slab, size, inc) < 0) {
- mprUnlock(app->allocLock);
- return 0;
- }
- sb = slab->next;
- }
- mprAssert(sb);
-
- /*
- * Dequeue the block
- */
- slab->next = sb->next;
-
-#if BLD_FEATURE_ALLOC_STATS
-{
- MprSlabStats *slabStats;
- /*
- * Update the slab stats
- */
- slabStats = &slab->stats;
- slabStats->totalAllocCount++;
- slabStats->freeCount--;
- slabStats->allocCount++;
- if (slabStats->allocCount > slabStats->peakAllocCount) {
- slabStats->peakAllocCount = slabStats->allocCount;
- }
-}
-#endif /* BLD_FEATURE_ALLOC_STATS */
-
- bp = GET_HDR(sb);
-
-#if BLD_DEBUG && !BREW
- if (bp == stopAlloc) {
- mprBreakpoint(MPR_LOC, "breakOnAddr");
- }
-#endif
-
- bp->size = size;
- bp->flags = ALLOC_MAGIC | ALLOC_FLAGS_SLAB_BLOCK;
- bp->destructor = 0;
-
- bp->parent = parent;
-
- if (parent->children == 0) {
- parent->children = bp;
- bp->next = bp->prev = bp;
-
- } else {
- /*
- * Append to the end of the list. Preserve alloc order
- */
- bp->next = parent->children;
- bp->prev = parent->children->prev;
- parent->children->prev->next = bp;
- parent->children->prev = bp;
- }
-
- bp->children = 0;
-
- bp->app = app;
-
-#if BLD_FEATURE_ALLOC_LEAK_TRACK
- bp->location = loc;
-#endif
- mprUnlock(app->allocLock);
-
- return GET_PTR(bp);
-#endif
-}
-
-/******************************************************************************/
-/*
- * Return a block back to its slab
- */
-
-static void slabFree(MprBlk *bp)
-{
- MprSlab *slab;
- MprApp *app;
- void *ptr;
- int slabIndex;
-
- mprAssert(VALID_HDR(bp));
-
- slabIndex = GET_SLAB(bp->size);
- mprAssert(0 <= slabIndex && slabIndex < MPR_MAX_SLAB);
-
- if (0 <= slabIndex && slabIndex < MPR_MAX_SLAB) {
- mprLock(bp->app->allocLock);
- slab = &bp->app->alloc.slabs[slabIndex];
- app = bp->app;
-
-#if BLD_DEBUG
- memset(bp, 0xfc, bp->size + HDR_SIZE);
-#endif
-
- ptr = GET_PTR(bp);
- ((MprSlabBlock*) ptr)->next = slab->next;
- slab->next = ((MprSlabBlock*) ptr);
-
-#if BLD_FEATURE_ALLOC_STATS
-{
- MprSlabStats *slabStats;
- slabStats = &slab->stats;
-
- slabStats->freeCount++;
- slabStats->allocCount--;
-
- if (slabStats->freeCount >= slabStats->peakFreeCount) {
- slabStats->peakFreeCount = slabStats->freeCount;
- }
-}
-#endif
- mprUnlock(app->allocLock);
- }
-}
-
-/******************************************************************************/
-/*
- * Grow the slab and return the next free block
- * Must be called locked.
- */
-
-static int growSlab(MPR_LOC_DEC(ctx, loc), MprSlab *slab, uint size, uint inc)
-{
- MprBlk *bp;
- MprSlabBlock *sb;
- int i, chunkSize, len;
-
- mprAssert(VALID_BLK(ctx));
- mprAssert(slab);
- mprAssert(size > 0);
-
- /*
- * Take the maximum requested by anyone
- */
- slab->preAllocateIncr = max(slab->preAllocateIncr, inc);
-
- /*
- * We allocate an array of blocks each of user "size" bytes.
- */
- chunkSize = HDR_SIZE + size;
- len = chunkSize * slab->preAllocateIncr;
- bp = mprAllocBlock(MPR_LOC_PASS(ctx, loc), len);
-
-#if BLD_DEBUG
- memset(bp, 0xf1, len);
-#endif
-
- if (bp == 0) {
- mprAssert(0);
- return MPR_ERR_MEMORY;
- }
- bp->flags |= ALLOC_FLAGS_IS_SLAB;
-
- /*
- * We store the slab information in the user data portion
- */
- sb = (MprSlabBlock*) GET_PTR(bp);
-
-
- sb = (MprSlabBlock*) ((char*) sb + len - chunkSize);
- for (i = slab->preAllocateIncr - 1; i >= 0; i--) {
- sb->next = slab->next;
- slab->next = sb;
- sb = (MprSlabBlock*) ((char*) sb - chunkSize);
- }
-
-#if BLD_FEATURE_ALLOC_STATS
-{
- MprSlabStats *stats;
- stats = &slab->stats;
- stats->freeCount += slab->preAllocateIncr;
- if (stats->freeCount > stats->peakFreeCount) {
- stats->peakFreeCount = stats->freeCount;
- }
-}
-#endif
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Set the pre-allocate amount
- */
-
-int mprSetSlabPreAllocate(MprCtx ctx, int slabIndex, int preAllocateIncr)
-{
- MprApp *app;
- MprSlab *slab;
-
- mprAssert(VALID_BLK(ctx));
- mprAssert(0 <= slabIndex && slabIndex < MPR_MAX_SLAB);
- mprAssert(preAllocateIncr > 0);
-
- if (0 <= slabIndex && slabIndex < MPR_MAX_SLAB) {
- app = mprGetApp(ctx);
- slab = &app->alloc.slabs[slabIndex];
- slab->preAllocateIncr = preAllocateIncr;
- } else {
- return MPR_ERR_BAD_ARGS;
- }
- return 0;
-}
-
-/******************************************************************************/
-
-void *mprSlabAllocZeroedBlock(MPR_LOC_DEC(ctx, loc), uint size, uint inc)
-{
- void *newBlock;
-
- mprAssert(VALID_BLK(ctx));
- mprAssert(size > 0);
-
- newBlock = mprSlabAllocBlock(MPR_LOC_PASS(ctx, loc), size, inc);
- if (newBlock) {
- memset(newBlock, 0, size);
- }
- return newBlock;
-}
-
-/******************************************************************************/
-/*
- * Internal strdup function. Will use the slab allocator for small strings
- */
-
-char *mprStrdupInternal(MPR_LOC_DEC(ctx, loc), const char *str)
-{
- char *newp;
- int len;
-
- mprAssert(VALID_BLK(ctx));
-
- if (str == 0) {
- str = "";
- }
-
- len = strlen(str) + 1;
-
- if (len < MPR_SLAB_STR_MAX) {
- newp = mprSlabAllocBlock(MPR_LOC_PASS(ctx, loc), MPR_SLAB_STR_MAX,
- MPR_SLAB_STR_INC);
- } else {
- newp = mprAllocBlock(MPR_LOC_PASS(ctx, loc), len);
- }
-
- if (newp) {
- memcpy(newp, str, len);
- }
-
- return newp;
-}
-
-/******************************************************************************/
-/*
- * Internal strndup function. Will use the slab allocator for small strings
- */
-
-char *mprStrndupInternal(MPR_LOC_DEC(ctx, loc), const char *str, uint size)
-{
- char *newp;
- uint len;
-
- mprAssert(VALID_BLK(ctx));
-
- if (str == 0) {
- str = "";
- }
- len = strlen(str) + 1;
- len = min(len, size);
-
- if (len < MPR_SLAB_STR_MAX) {
- newp = mprSlabAllocBlock(MPR_LOC_PASS(ctx, loc), MPR_SLAB_STR_MAX,
- MPR_SLAB_STR_INC);
- } else {
- newp = mprAllocBlock(MPR_LOC_PASS(ctx, loc), len);
- }
-
- if (newp) {
- memcpy(newp, str, len);
- }
-
- return newp;
-}
-
-/******************************************************************************/
-/*
- * Internal memcpy function. Will use the slab allocator for small strings
- */
-
-void *mprMemdupInternal(MPR_LOC_DEC(ctx, loc), const void *ptr, uint size)
-{
- char *newp;
-
- mprAssert(VALID_BLK(ctx));
-
- if (size < MPR_SLAB_STR_MAX) {
- newp = mprSlabAllocBlock(MPR_LOC_PASS(ctx, loc), MPR_SLAB_STR_MAX,
- MPR_SLAB_STR_INC);
- } else {
- newp = mprAllocBlock(MPR_LOC_PASS(ctx, loc), size);
- }
-
- if (newp) {
- memcpy(newp, ptr, size);
- }
-
- return newp;
-}
-
-/******************************************************************************/
-/*
- * Steal a block from one context and insert in another
- */
-
-int mprStealAllocBlock(MPR_LOC_DEC(ctx, loc), const void *ptr)
-{
- MprBlk *bp, *parent;
-
- if (ptr == 0) {
- return 0;
- }
-
- mprAssert(VALID_BLK(ctx));
- mprAssert(VALID_BLK(ptr));
-
- bp = GET_HDR(ptr);
-
-#if BLD_DEBUG && !BREW
- if (bp == stopAlloc) {
- mprBreakpoint(MPR_LOC, "breakOnAddr");
- }
-#endif
-
- mprAssert(bp);
- mprAssert(VALID_HDR(bp));
- mprAssert(ptr != mprGetAllocParent(ptr));
-
- CHECK_HDR(bp);
-
- mprAssert(bp->prev);
- mprAssert(bp->prev->next);
- mprAssert(bp->next);
- mprAssert(bp->next->prev);
-
- parent = bp->parent;
- mprAssert(VALID_HDR(parent));
-
- mprLock(bp->app->allocLock);
- if (parent->children == bp) {
- if (bp->next == bp) {
- parent->children = 0;
- } else {
- parent->children = bp->next;
- }
- }
-
- bp->prev->next = bp->next;
- bp->next->prev = bp->prev;
-
- parent = GET_HDR(ctx);
- mprAssert(VALID_HDR(parent));
- bp->parent = parent;
-
- if (parent->children == 0) {
- parent->children = bp;
- bp->next = bp->prev = bp;
-
- } else {
- bp->next = parent->children;
- bp->prev = parent->children->prev;
- parent->children->prev->next = bp;
- parent->children->prev = bp;
- }
-
-#if BLD_FEATURE_ALLOC_LEAK_TRACK
- bp->location = loc;
-#endif
-
- VALIDATE_BLOCK(GET_PTR(bp));
-
- mprUnlock(bp->app->allocLock);
-
- return 0;
-}
-
-/******************************************************************************/
-
-void mprSetRequiredAlloc(MprCtx ptr, bool recurse)
-{
- MprBlk *bp, *firstChild, *cp;
-
- bp = GET_HDR(ptr);
-
- bp->flags |= ALLOC_FLAGS_REQUIRED;
-
- if (recurse && (firstChild = bp->children) != 0) {
- cp = firstChild;
- do {
- mprSetRequiredAlloc(GET_PTR(cp), recurse);
- cp = cp->next;
- } while (cp != firstChild);
- }
-}
-
-/******************************************************************************/
-/*
- * Monitor stack usage. Return true if the stack has grown
- */
-
-int mprStackCheck(MprCtx ptr)
-{
- MprApp *app;
- int size;
-
- mprAssert(VALID_BLK(ptr));
-
- app = mprGetApp(ptr);
-
- size = (int) app->stackStart - (int) &app;
- if (size < 0) {
- app->maxStack -= size;
- app->stackStart = (void*) &app;
- size = 0;
- }
- if ((uint) size > app->maxStack) {
- app->maxStack = size;
- return 1;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Return the stack size
- */
-
-int mprStackSize(MprCtx ptr)
-{
- MprApp *app;
-
- mprAssert(VALID_BLK(ptr));
-
- app = mprGetApp(ptr);
- return app->maxStack;
-}
-
-/******************************************************************************/
-
-static int mprAllocException(MPR_LOC_DEC(ctx, loc), uint size, bool granted)
-{
- MprApp *app;
- MprAlloc *alloc;
- int rc;
-
- mprAssert(VALID_BLK(ctx));
-
- app = mprGetApp(ctx);
- alloc = &app->alloc;
-
- if (alloc->cback == 0) {
- return 0;
- }
-
- mprLock(app->allocLock);
- if (alloc->inAllocException == 0) {
- alloc->inAllocException = 1;
- mprUnlock(app->allocLock);
-
- rc = (alloc->cback)(app, size, alloc->stats.bytesAllocated, granted);
-
- mprLock(app->allocLock);
- app->alloc.inAllocException = 0;
- mprUnlock(app->allocLock);
-
- return rc;
- }
- return 0;
-}
-
-/******************************************************************************/
-
-void mprSetAllocLimits(MprApp *app, uint redLine, uint maxMemory)
-{
- app->alloc.stats.redLine = redLine;
- app->alloc.stats.maxMemory = maxMemory;
-}
-
-/******************************************************************************/
-
-MprAllocCback mprSetAllocCallback(MprApp *app, MprAllocCback cback)
-{
- MprAllocCback old;
-
- mprAssert(app);
- mprAssert(VALID_BLK(app));
-
- old = app->alloc.cback;
- app->alloc.cback = cback;
- return old;
-}
-
-/******************************************************************************/
-
-uint mprGetAllocBlockSize(MprCtx ptr)
-{
- MprBlk *bp;
-
- mprAssert(VALID_BLK(ptr));
-
- if (ptr == 0) {
- return 0;
- }
-
- bp = GET_HDR(ptr);
- mprAssert(VALID_HDR(bp));
-
- CHECK_HDR(bp);
-
- return bp->size;
-}
-
-/******************************************************************************/
-/*
- * Return the total block count used by a block including all children
- */
-
-uint mprGetAllocBlockCount(MprCtx ptr)
-{
- MprBlk *bp, *firstChild, *cp;
- uint count;
-
- mprAssert(VALID_BLK(ptr));
-
- if (ptr == 0) {
- return 0;
- }
-
- bp = GET_HDR(ptr);
- mprAssert(VALID_HDR(bp));
-
- /*
- * Add one for itself
- */
- count = 1;
- if ((firstChild = bp->children) != 0) {
- cp = firstChild;
- do {
- count += mprGetAllocBlockCount(GET_PTR(cp));
- cp = cp->next;
- } while (cp != firstChild);
- }
- return count;
-}
-
-/******************************************************************************/
-/*
- * Return the total of all memory allocated including slabs
- */
-
-uint mprGetAllocBlockMemory(MprCtx ptr)
-{
- MprBlk *bp, *firstChild, *cp;
- uint count;
-
- mprAssert(VALID_BLK(ptr));
-
- if (ptr == 0) {
- return 0;
- }
-
- bp = GET_HDR(ptr);
- mprAssert(VALID_HDR(bp));
-
- count = bp->size + HDR_SIZE;
- if ((firstChild = bp->children) != 0) {
- cp = firstChild;
- do {
- count += mprGetAllocBlockMemory(GET_PTR(cp));
- cp = cp->next;
- } while (cp != firstChild);
- }
- return count;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_ALLOC_LEAK_TRACK
-
-const char *mprGetAllocLocation(MprCtx ptr)
-{
- MprBlk *bp;
-
- if (ptr == 0) {
- return 0;
- }
- mprAssert(VALID_BLK(ptr));
-
- bp = GET_HDR(ptr);
- mprAssert(VALID_HDR(bp));
- return bp->location;
-}
-
-#endif
-/******************************************************************************/
-
-void *mprGetAllocParent(MprCtx ptr)
-{
- MprBlk *bp;
-
- mprAssert(VALID_BLK(ptr));
-
- if (ptr == 0) {
- return 0;
- }
-
- bp = GET_HDR(ptr);
- mprAssert(VALID_HDR(bp));
-
- CHECK_HDR(bp);
-
- return GET_PTR(bp->parent);
-}
-
-/******************************************************************************/
-
-MprAllocStats *mprGetAllocStats(MprApp *app)
-{
- mprAssert(VALID_BLK(app));
-
- return &app->alloc.stats;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_ALLOC_STATS
-
-MprSlabStats *mprGetSlabAllocStats(MprApp *app, int slabIndex)
-{
- MprSlab *slab;
-
- mprAssert(VALID_BLK(app));
-
- if (0 <= slabIndex && slabIndex < MPR_MAX_SLAB) {
- slab = &app->alloc.slabs[slabIndex];
- return &slab->stats;
- }
-
- mprAssert(0 <= slabIndex && slabIndex < MPR_MAX_SLAB);
- return 0;
-}
-
-#endif /* BLD_FEATURE_ALLOC_STATS */
-/******************************************************************************/
-#if BLD_DEBUG
-
-int mprPrintAllocBlocks(MprCtx ptr, int indent)
-{
- MprBlk *bp, *firstChild, *cp;
- const char *location;
- int subTotal, size, indentSpaces, code;
-
- subTotal = 0;
-
- bp = GET_HDR(ptr);
-
- if (! (bp->flags & ALLOC_FLAGS_REQUIRED)) {
- size = bp->size + HDR_SIZE;
-
- /*
- * Take one level off because we don't trace app
- */
- indentSpaces = indent;
-
- if (bp->flags & ALLOC_FLAGS_REQUIRED) {
- code = 'R';
- } else if (bp->flags & ALLOC_FLAGS_IS_SLAB) {
- code = 'S';
- } else {
- code = ' ';
- }
-
-#if BLD_FEATURE_ALLOC_LEAK_TRACK
- location = bp->location;
-#else
- location = "";
-#endif
- mprLog(bp->app, 0,
- "%c %.*s %-16s %.*s size %5d has %3d deps, total %6d", code,
- indentSpaces, " ",
- mprGetBaseName(location),
- 8 - indent, " ",
- size,
- mprGetAllocBlockCount(GET_PTR(bp)),
- mprGetAllocBlockMemory(GET_PTR(bp))
- /* (uint) bp */
- );
-
- subTotal += size;
- }
-
- if ((firstChild = bp->children) != 0) {
- cp = firstChild;
- do {
- subTotal += mprPrintAllocBlocks(GET_PTR(cp), indent + 2);
- cp = cp->next;
- } while (cp != firstChild);
- }
-
- return subTotal;
-}
-
-#endif
-/******************************************************************************/
-#if BLD_FEATURE_ALLOC_STATS
-/*
- * Print a memory allocation report that includes a list of allocated blocks
- * and a statistics summary
- */
-
-void mprPrintAllocReport(MprApp *app, bool printBlocks, const char *msg)
-{
- MprSlabStats *stats;
- uint total;
- int i, size;
-
- mprAssert(VALID_BLK(app));
-
- if (msg) {
- mprLog(app, 0, " ");
- mprLog(app, 0, "%s", msg);
- }
-
-#if BLD_DEBUG
- /*
- * Do block stats
- */
- if (printBlocks) {
- int sum;
- mprLog(app, 0, " ");
- sum = mprPrintAllocBlocks(app, 0);
- if (sum) {
- mprLog(app, 0, " Sum of blocks %d", sum);
- } else {
- mprLog(app, 0, " None");
- }
- }
-#endif
-
- /*
- * Do Slab stats
- */
- mprLog(app, 0, " ");
- mprLog(app, 0, "MPR Slab Memory Stats");
- mprLog(app, 0, " ");
-
- mprLog(app, 0,
- " Index Size Total Allocated Free PeakAlloc PeakFree TotalAlloc");
-
- total = 0;
- for (i = 0; i < MPR_MAX_SLAB; i++) {
- stats = &app->alloc.slabs[i].stats;
- size = 1 << (i + 5);
- if (stats->totalAllocCount > 0) {
- mprLog(app, 0, " %2d %6d %8d %9d %6d %9d %8d %10d",
- i, size, size * (stats->allocCount + stats->freeCount),
- stats->allocCount, stats->freeCount,
- stats->peakAllocCount, stats->peakFreeCount,
- stats->totalAllocCount);
- total += size * (stats->allocCount + stats->freeCount);
- }
- }
- mprLog(app, 0, " ");
- mprLog(app, 0, "MPR Total Allocated Slab RAM: %10d", total);
- mprLog(app, 0, "MPR Total Allocated RAM: %10d",
- mprGetAllocatedMemory(app));
- mprLog(app, 0, "MPR Peak Allocated RAM: %10d",
- mprGetPeakAllocatedMemory(app));
- mprLog(app, 0, " ");
-}
-
-/******************************************************************************/
-/*
- * Return the total memory allocated.
- */
-
-uint mprGetAllocatedMemory(MprCtx ctx)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
-
- return app->alloc.stats.bytesAllocated;
-}
-
-/******************************************************************************/
-/*
- * Return the peak memory allocated.
- */
-
-uint mprGetPeakAllocatedMemory(MprCtx ctx)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
-
- return app->alloc.stats.peakAllocated;
-}
-
-/******************************************************************************/
-/*
- * Return memory in the MPR slab. This excludes the EJS slabs
- */
-
-uint mprGetAllocatedSlabMemory(MprCtx ctx)
-{
- MprApp *app;
- MprSlabStats *stats;
- uint total;
- int i, size;
-
- app = mprGetApp(ctx);
-
- total = 0;
- for (i = 0; i < MPR_MAX_SLAB; i++) {
- stats = &app->alloc.slabs[i].stats;
- size = 1 << (i + 5);
- if (stats->totalAllocCount > 0) {
- total += size * (stats->allocCount + stats->freeCount);
- }
- }
- return total;
-}
-
-#endif /* BLD_FEATURE_ALLOC_STATS */
-/******************************************************************************/
-
-MprDestructor mprSetDestructor(MprCtx ptr, MprDestructor destructor)
-{
- MprDestructor old;
- MprBlk *bp;
-
- mprAssert(VALID_BLK(ptr));
-
- if (ptr == 0) {
- return 0;
- }
-
- bp = GET_HDR(ptr);
-
- mprAssert(bp);
- mprAssert(VALID_HDR(bp));
- mprAssert(ptr != mprGetAllocParent(ptr));
-
- CHECK_HDR(bp);
-
- old = bp->destructor;
- bp->destructor = destructor;
-
- return old;
-}
-
-/******************************************************************************/
-
-int mprIsAllocBlockValid(MprCtx ptr)
-{
- MprBlk *bp;
-
- bp = GET_HDR(ptr);
- return (bp && VALID_HDR(bp));
-}
-
-/******************************************************************************/
-#if VALIDATE_ALLOC
-/*
- * Exhaustive validation of the block and its children. Does not go recursive
- * as it would be too slow.
- */
-
-int mprValidateBlock(MprCtx ptr)
-{
- MprBlk *bp, *parent, *cp, *firstChild;
- int count;
-
- mprAssert(ptr);
- mprAssert(VALID_BLK(ptr));
-
- bp = GET_HDR(ptr);
-
- mprAssert(bp);
- mprAssert(VALID_HDR(bp));
- mprAssert(VALID_HDR(bp->parent));
-
- if (ptr != bp->app) {
- mprAssert(bp != bp->parent);
- }
- mprAssert(! (bp->flags & ALLOC_FLAGS_FREE));
- mprAssert(! (bp->flags & ALLOC_FLAGS_FREEING));
-
- /*
- *
- */
- count = 0;
- parent = bp->parent;
-
- if ((firstChild = bp->children) != 0) {
- cp = firstChild;
- mprAssert((int) cp != 0xfeefee);
- do {
- mprAssert(bp->next->prev == bp);
- mprAssert(bp->prev->next == bp);
- mprAssert(bp->prev->parent == parent);
- mprAssert(bp->next->parent == parent);
-
- count++;
- cp = cp->next;
-
- if (bp->next == bp) {
- mprAssert(bp->prev == bp);
- if (ptr != bp->app) {
- mprAssert(parent->children == bp);
- }
- }
- if (bp->prev == bp) {
- mprAssert(bp->next == bp);
- if (ptr != bp->app) {
- mprAssert(parent->children == bp);
- }
- }
- } while (cp != firstChild);
- }
-
- return 0;
-}
-
-#endif
-/******************************************************************************/
-/*
- * Validate a block and all children
- */
-
-int mprValidateAllocTree(MprCtx ptr)
-{
-#if VALIDATE_ALLOC
- MprBlk *bp, *cp, *firstChild;
-
- mprAssert(ptr);
- mprAssert(VALID_BLK(ptr));
-
- bp = GET_HDR(ptr);
-
- mprValidateBlock(GET_PTR(bp));
-
- if ((firstChild = bp->children) != 0) {
- cp = firstChild;
- do {
- mprValidateAllocTree(GET_PTR(cp));
- cp = cp->next;
- } while (cp != firstChild);
- }
-
-#endif
- return 0;
-}
-
-/******************************************************************************/
-#if UNUSED && FUTURE
-/*
- * Exhaustive validation of the block and its children. Does not go recursive
- * as it would be too slow.
- */
-
-int mprValidateSlabs(MprApp *app)
-{
- MprSlab *slab;
- MprSlabStats *slabStats;
- MprSlabBlock *sp;
- int count, i;
-
- for (i = 0; i < MPR_MAX_SLAB; i++) {
- slab = &app->alloc.slabs[i];
- slabStats = &slab->stats;
-
- count = 0;
- for (sp = slab->next; sp; sp = sp->next) {
- count++;
- }
- mprAssert(count == (int) slabStats->freeCount);
- }
- return 0;
-}
-
-#endif
-/******************************************************************************/
-
-void mprAllocAbort()
-{
-#if BREW
- printf("Bad block header");
-#else
- exit(255);
-#endif
-}
-
-/******************************************************************************/
-#undef mprGetApp
-/*
- * Get the root parent from any block (which is the MprApp structure)
- */
-
-MprApp *mprGetApp(MprCtx ptr)
-{
- MprBlk *bp;
-
- mprAssert(ptr);
-
- bp = GET_HDR(ptr);
- mprAssert(VALID_HDR(bp));
-
- CHECK_HDR(bp);
-
- mprAssert(bp->app->magic == APP_MAGIC);
-
- return bp->app;
-}
-
-/******************************************************************************/
-
-int mprGetAllocErrors(MprCtx ctx)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
- return app->alloc.stats.errors;
-}
-
-/******************************************************************************/
-
-void mprClearAllocErrors(MprCtx ctx)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
- app->alloc.stats.errors = 0;
-}
-
-/******************************************************************************/
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprArray.c b/source4/lib/appweb/ejs-2.0/mpr/mprArray.c
deleted file mode 100644
index 95b0a14450..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/mprArray.c
+++ /dev/null
@@ -1,385 +0,0 @@
-/**
- * @file mprArray.c
- * @brief Growable array structure
- * @overview Simple growable array structure.
- * @remarks Most routines in this file are not thread-safe. It is the callers
- * responsibility to perform all thread synchronization.
- */
-
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/********************************** Includes **********************************/
-
-#include "mpr.h"
-
-/******************************************************************************/
-/*
- * Create a general growable array structure. Use mprFree to destroy.
- */
-
-MprArray *mprCreateItemArrayInternal(MPR_LOC_DEC(ctx, loc), int initialSize,
- int maxSize)
-{
- MprArray *array;
- int size;
-
- mprAssert(initialSize <= maxSize);
-
- array = (MprArray*) mprSlabAllocZeroedBlock(MPR_LOC_PASS(ctx, loc),
- sizeof(MprArray), 0);
- if (array == 0) {
- return 0;
- }
-
- if (initialSize == 0) {
- initialSize = MPR_ARRAY_INCR;
- }
- if (maxSize == 0) {
- maxSize = MAXINT;
- }
- size = initialSize * sizeof(void*);
-
- array->items = (void**) mprSlabAllocBlock(MPR_LOC_PASS(array, loc),
- size, 0);
-
- if (array->items == 0) {
- mprFree(array);
- return 0;
- }
-
- array->capacity = initialSize;
- array->maxSize = maxSize;
- array->incr = min(initialSize * 2, (array->maxSize - array->length));
- array->length = 0;
-
- return array;
-}
-
-/******************************************************************************/
-/*
- * Add an item to the array
- */
-
-int mprAddItem(MprArray *array, void *item)
-{
- int memsize, index, len;
-
- mprAssert(array);
- mprAssert(array->capacity >= 0);
- mprAssert(array->length >= 0);
-
- if (array->length < array->capacity) {
- /*
- * Room to fit in the current capacity
- */
- index = array->length++;
- array->items[index] = item;
- return index;
- }
- mprAssert(array->length == array->capacity);
-
- /*
- * Need to grow the array
- */
- if (array->capacity >= array->maxSize) {
- mprAssert(array->capacity < array->maxSize);
- return MPR_ERR_TOO_MANY;
- }
-
- len = array->capacity + array->incr;
- memsize = len * sizeof(void*);
-
- /*
- * Grow the array of items
- */
-
- array->items = (void**) mprRealloc(array, array->items, memsize);
-
- /*
- * Zero the new portion
- */
- memset(&array->items[array->capacity], 0, sizeof(void*) * array->incr);
- array->capacity = len;
-
- array->incr = min(array->incr * 2, (array->maxSize - array->length));
-
- index = array->length++;
- array->items[index] = item;
-
- return index;
-}
-
-/******************************************************************************/
-/*
- * Remove an item from the array
- */
-
-int mprRemoveItem(MprArray *array, void *item)
-{
- int index;
-
- mprAssert(array);
- mprAssert(array->capacity > 0);
- mprAssert(array->length > 0);
-
- index = mprFindItem(array, item);
- if (index < 0) {
- return index;
- }
-
- return mprRemoveItemByIndex(array, index);
-}
-
-/******************************************************************************/
-/*
- * Remove an index from the array
- */
-
-int mprRemoveItemByIndex(MprArray *array, int index)
-{
- void **items;
- int i;
-
- mprAssert(array);
- mprAssert(array->capacity > 0);
- mprAssert(index >= 0 && index < array->capacity);
- mprAssert(array->items[index] != 0);
- mprAssert(array->length > 0);
-
- if (index < 0 || index >= array->length) {
- return MPR_ERR_NOT_FOUND;
- }
-
- /*
- * Copy down to compress
- */
- items = array->items;
- for (i = index; i < (array->length - 1); i++) {
- items[i] = items[i + 1];
- }
- array->length--;
-
-#if BLD_DEBUG
- if (array->length < array->capacity) {
- items[array->length] = 0;
- }
-#endif
- return 0;
-}
-
-/******************************************************************************/
-
-int mprRemoveRangeOfItems(MprArray *array, int start, int end)
-{
- void **items;
- int i, count;
-
- mprAssert(array);
- mprAssert(array->capacity > 0);
- mprAssert(array->length > 0);
- mprAssert(start > end);
-
- if (start < 0 || start >= array->length) {
- return MPR_ERR_NOT_FOUND;
- }
- if (end < 0 || end >= array->length) {
- return MPR_ERR_NOT_FOUND;
- }
- if (start > end) {
- return MPR_ERR_BAD_ARGS;
- }
-
- /*
- * Copy down to compress
- */
- items = array->items;
- count = end - start;
- for (i = start; i < (array->length - count); i++) {
- items[i] = items[i + count];
- }
- array->length -= count;
-
-#if BLD_DEBUG
- if (array->length < array->capacity) {
- for (i = array->length; i < array->capacity; i++) {
- items[i] = 0;
- }
- }
-#endif
- return 0;
-}
-
-/******************************************************************************/
-
-void *mprGetItem(MprArray *array, int index)
-{
- mprAssert(array);
-
- if (index < 0 || index >= array->length) {
- return 0;
- }
- return array->items[index];
-}
-
-/******************************************************************************/
-
-void *mprGetFirstItem(MprArray *array, int *last)
-{
- mprAssert(array);
- mprAssert(last);
-
- if (array == 0) {
- return 0;
- }
-
- *last = 0;
-
- if (array->length == 0) {
- return 0;
- }
- return array->items[0];
-}
-
-/******************************************************************************/
-
-void *mprGetNextItem(MprArray *array, int *last)
-{
- int index;
-
- mprAssert(array);
- mprAssert(last);
- mprAssert(*last >= 0);
-
- index = *last;
-
- if (++index < array->length) {
- *last = index;
- return array->items[index];
- }
- return 0;
-}
-
-/******************************************************************************/
-
-void *mprGetPrevItem(MprArray *array, int *last)
-{
- int index;
-
- mprAssert(array);
- mprAssert(last);
- mprAssert(*last >= 0);
-
- if (array == 0) {
- return 0;
- }
-
- index = *last;
-
- if (--index < array->length && index >= 0) {
- *last = index;
- return array->items[index];
- }
- return 0;
-}
-
-/******************************************************************************/
-
-int mprGetItemCount(MprArray *array)
-{
- mprAssert(array);
-
- if (array == 0) {
- return 0;
- }
-
- return array->length;
-}
-
-/******************************************************************************/
-
-int mprGetItemCapacity(MprArray *array)
-{
- mprAssert(array);
-
- if (array == 0) {
- return 0;
- }
-
- return array->capacity;
-}
-
-/******************************************************************************/
-
-void mprClearAndFreeItems(MprArray *array)
-{
- int i;
-
- mprAssert(array);
-
- for (i = 0; i < array->length; i++) {
- mprFree(array->items[i]);
- }
-}
-
-/******************************************************************************/
-
-void mprClearItems(MprArray *array)
-{
- mprAssert(array);
-
- array->length = 0;
-}
-
-/******************************************************************************/
-
-int mprFindItem(MprArray *array, void *item)
-{
- int i;
-
- mprAssert(array);
-
- for (i = 0; i < array->length; i++) {
- if (array->items[i] == item) {
- return i;
- }
- }
- return MPR_ERR_NOT_FOUND;
-}
-
-/******************************************************************************/
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprBuf.c b/source4/lib/appweb/ejs-2.0/mpr/mprBuf.c
deleted file mode 100644
index ba9888a9fc..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/mprBuf.c
+++ /dev/null
@@ -1,535 +0,0 @@
-/**
- * @file mprBuf.c
- * @brief Dynamic buffer module
- * @overview
- * @remarks
- */
-
-/******************************************************************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-
-/********************************** Includes **********************************/
-
-#include "mpr.h"
-
-/**************************** Forward Declarations ****************************/
-
-static int grow(MprBuf *bp);
-
-/*********************************** Code *************************************/
-/*
- * Create a new buffer. "maxsize" is the limit to which the buffer can
- * ever grow. -1 means no limit. The buffer can ever only fix maxsize-1 bytes.
- * "initialSize" is used to define the amount to increase the size of the
- * buffer each time if it becomes full. (Note: grow() will exponentially
- * increase this number for performance.)
- */
-
-MprBuf *mprCreateBuf(MprCtx ctx, int initialSize, int maxSize)
-{
- MprBuf *bp;
-
- if (initialSize <= 0) {
- initialSize = MPR_DEFAULT_ALLOC;
- }
- bp = mprAllocTypeZeroed(ctx, MprBuf);
- bp->growBy = MPR_BUFSIZE;
- bp->maxsize = 0;
- mprSetBufSize(bp, initialSize, maxSize);
- return bp;
-}
-
-/******************************************************************************/
-/*
- * Set the initial buffer parameters and create the first buffer
- */
-
-void mprSetBufSize(MprBuf *bp, int initialSize, int max)
-{
- mprAssert(initialSize > 0);
-
- if (max > 0 && initialSize > max) {
- initialSize = max;
- }
-
- if (bp->buf && bp->growBy > 0) {
- mprFree(bp->buf);
- }
-
- bp->buf = (uchar*) mprAlloc(bp, initialSize);
- bp->growBy = initialSize;
- bp->maxsize = max;
- bp->buflen = initialSize;
- bp->endbuf = &bp->buf[bp->buflen];
- bp->start = bp->buf;
- bp->end = bp->buf;
- *bp->start = '\0';
-}
-
-/******************************************************************************/
-
-char *mprStealBuf(MprCtx ctx, MprBuf *bp)
-{
- char *str;
-
- str = (char*) bp->start;
-
- mprStealAllocBlock(MPR_LOC_ARGS(ctx), bp->start);
-
- bp->start = bp->end = bp->buf = bp->endbuf = 0;
- bp->buflen = 0;
-
- return str;
-}
-
-/******************************************************************************/
-
-void mprAddNullToBuf(MprBuf *bp)
-{
- *((char*) bp->end) = (char) '\0';
-}
-
-/******************************************************************************/
-
-void mprAdjustBufEnd(MprBuf *bp, int size)
-{
- mprAssert(bp->buflen == (bp->endbuf - bp->buf));
- mprAssert(size < bp->buflen);
-
- bp->end += size;
- if (bp->end >= bp->endbuf) {
- bp->end -= bp->buflen;
- }
- if (bp->end < bp->buf) {
- bp->end += bp->buflen;
- }
-
- if (bp->end >= bp->endbuf) {
- mprAssert(bp->end < bp->endbuf);
- mprFlushBuf(bp);
- }
-}
-
-/******************************************************************************/
-/*
- * Adjust the start pointer after a user copy
- */
-
-void mprAdjustBufStart(MprBuf *bp, int size)
-{
- mprAssert(bp->buflen == (bp->endbuf - bp->buf));
- mprAssert(size < bp->buflen);
-
- bp->start += size;
- while (bp->start >= bp->endbuf) {
- bp->start -= bp->buflen;
- }
- while (bp->start < bp->buf) {
- bp->start += bp->buflen;
- }
-
- /*
- * Flush the buffer if the start pointer is corrupted via a bad size
- */
- if (bp->start >= bp->endbuf) {
- mprAssert(bp->start < bp->endbuf);
- mprFlushBuf(bp);
- }
-}
-
-
-/******************************************************************************/
-
-void mprFlushBuf(MprBuf *bp)
-{
- bp->start = bp->buf;
- bp->end = bp->buf;
-}
-
-/******************************************************************************/
-
-int mprGetCharFromBuf(MprBuf *bp)
-{
- int c;
-
- if (bp->start == bp->end) {
- return -1;
- }
- c = (uchar) *bp->start++;
- if (bp->start >= bp->endbuf) {
- bp->start = bp->buf;
- }
- return c;
-}
-
-/******************************************************************************/
-
-int mprGetBlockFromBuf(MprBuf *bp, uchar *buf, int size)
-{
- int thisLen, bytesRead;
-
- mprAssert(buf);
- mprAssert(size > 0);
- mprAssert(bp->buflen == (bp->endbuf - bp->buf));
-
- /*
- * Get the max bytes in a straight copy
- */
- bytesRead = 0;
- while (size > 0) {
- thisLen = mprGetBufLinearData(bp);
- thisLen = min(thisLen, size);
- if (thisLen <= 0) {
- break;
- }
-
- memcpy(buf, bp->start, thisLen);
- buf += thisLen;
- bp->start += thisLen;
- size -= thisLen;
- bytesRead += thisLen;
-
- if (bp->start >= bp->endbuf) {
- bp->start = bp->buf;
- }
- }
- return bytesRead;
-}
-
-/******************************************************************************/
-
-int mprGetBufLength(MprBuf *bp)
-{
- if (bp->start > bp->end) {
- return (bp->buflen + (bp->end - bp->start));
- } else {
- return (bp->end - bp->start);
- }
-}
-
-/******************************************************************************/
-
-int mprGetBufLinearData(MprBuf *bp)
-{
- return min(mprGetBufLength(bp), (bp->endbuf - bp->start));
-}
-
-/******************************************************************************/
-
-int mprGetBufLinearSpace(MprBuf *bp)
-{
- int len = mprGetBufLength(bp);
- int space = bp->buflen - len - 1;
- return min((bp->endbuf - bp->end), space);
-}
-
-/******************************************************************************/
-
-int mprGetBufSize(MprBuf *bp)
-{
- return bp->buflen;
-}
-
-/******************************************************************************/
-
-int mprGetBufSpace(MprBuf *bp)
-{
- return bp->buflen - mprGetBufLength(bp) - 1;
-}
-
-/******************************************************************************/
-
-char *mprGetBufOrigin(MprBuf *bp)
-{
- return (char*) bp->buf;
-}
-
-/******************************************************************************/
-
-char *mprGetBufStart(MprBuf *bp)
-{
- return (char*) bp->start;
-}
-
-/******************************************************************************/
-
-char *mprGetBufEnd(MprBuf *bp)
-{
- return (char*) bp->end;
-}
-
-/******************************************************************************/
-
-int mprInsertCharToBuf(MprBuf *bp, int c)
-{
- char *cp;
- int space;
-
- mprAssert(bp->buflen == (bp->endbuf - bp->buf));
-
- space = bp->buflen - mprGetBufLength(bp) - 1;
- if (space < (int) sizeof(char)) {
- if (!grow(bp)) {
- return -1;
- }
- }
- if (bp->start <= bp->buf) {
- bp->start = bp->endbuf;
- }
- cp = (char*) bp->start;
- *--cp = (char) c;
- bp->start = (uchar *) cp;
- return 0;
-}
-
-/******************************************************************************/
-
-int mprLookAtNextCharInBuf(MprBuf *bp)
-{
- if (bp->start == bp->end) {
- return -1;
- }
- return *bp->start;
-}
-
-/******************************************************************************/
-
-int mprLookAtLastCharInBuf(MprBuf *bp)
-{
- if (bp->start == bp->end) {
- return -1;
- }
- return (bp->end == bp->buf) ? bp->endbuf[-1] : bp->end[-1];
-}
-
-/******************************************************************************/
-
-int mprPutCharToBuf(MprBuf *bp, int c)
-{
- char *cp;
- int space;
-
- mprAssert(bp->buflen == (bp->endbuf - bp->buf));
-
- space = bp->buflen - mprGetBufLength(bp) - 1;
- if (space < (int) sizeof(char)) {
- if (! grow(bp)) {
- return -1;
- }
- }
-
- cp = (char*) bp->end;
- *cp++ = (char) c;
- bp->end = (uchar *) cp;
- if (bp->end >= bp->endbuf) {
- bp->end = bp->buf;
- }
- *((char*) bp->end) = (char) '\0';
- return 0;
-}
-
-/******************************************************************************/
-
-int mprPutBlockToBuf(MprBuf *bp, const char *str, int size)
-{
- int thisLen, bytes, space;
-
- mprAssert(str);
- mprAssert(size >= 0);
- mprAssert(bp->buflen == (bp->endbuf - bp->buf));
-
- /*
- * Add the max we can in one copy
- */
- bytes = 0;
- while (size > 0) {
- space = mprGetBufLinearSpace(bp);
- thisLen = min(space, size);
- if (thisLen <= 0) {
- if (! grow(bp)) {
- break;
- }
- space = mprGetBufLinearSpace(bp);
- thisLen = min(space, size);
- }
-
- memcpy(bp->end, str, thisLen);
- str += thisLen;
- bp->end += thisLen;
- size -= thisLen;
- bytes += thisLen;
-
- if (bp->end >= bp->endbuf) {
- bp->end = bp->buf;
- }
- }
- *((char*) bp->end) = (char) '\0';
- return bytes;
-}
-
-/******************************************************************************/
-
-int mprPutStringToBuf(MprBuf *bp, const char *str)
-{
- return mprPutBlockToBuf(bp, str, strlen(str));
-}
-
-/******************************************************************************/
-
-int mprPutFmtStringToBuf(MprBuf *bp, const char *fmt, ...)
-{
- va_list ap;
- char *buf;
- int rc, len, space;
-
- va_start(ap, fmt);
- space = mprGetBufLinearSpace(bp);
-
- /*
- * Add max that the buffer can grow
- */
- space += (bp->maxsize - bp->buflen - 1);
-
- len = mprAllocVsprintf(MPR_LOC_ARGS(bp), &buf, space, fmt, ap);
- rc = mprPutBlockToBuf(bp, buf, len);
-
- mprFree(buf);
- va_end(ap);
- return rc;
-}
-
-/******************************************************************************/
-/*
- * Grow the buffer to fit new data. Return 1 if the buffer can grow.
- * Grow using the growBy size specified when creating the buffer.
- */
-
-static int grow(MprBuf *bp)
-{
- uchar *newbuf;
-
- if (bp->maxsize > 0 && bp->buflen >= bp->maxsize) {
- return 0;
- }
-
- newbuf = (uchar*) mprAlloc(bp, bp->buflen + bp->growBy);
- if (bp->buf) {
- memcpy(newbuf, bp->buf, bp->buflen);
- mprFree(bp->buf);
- }
-
- bp->buflen += bp->growBy;
- bp->end = newbuf + (bp->end - bp->buf);
- bp->start = newbuf + (bp->start - bp->buf);
- bp->buf = newbuf;
- bp->endbuf = &bp->buf[bp->buflen];
-
- /*
- * Increase growBy to reduce overhead
- */
- bp->growBy *= 2;
- if (bp->maxsize > 0 && (bp->buflen + bp->growBy) > bp->maxsize) {
- bp->growBy = bp->maxsize - bp->buflen;
- }
- return 1;
-}
-
-/******************************************************************************/
-/*
- * Add a number to the buffer (always null terminated).
- */
-
-int mprPutIntToBuf(MprBuf *bp, int i)
-{
- char numBuf[16];
- int rc;
-
- mprItoa(numBuf, sizeof(numBuf), i);
- rc = mprPutStringToBuf(bp, numBuf);
- *((char*) bp->end) = (char) '\0';
-
- return rc;
-}
-
-/******************************************************************************/
-
-void mprCopyBufDown(MprBuf *bp)
-{
- if (mprGetBufLength(bp) == 0) {
- mprFlushBuf(bp);
- return;
- }
- memmove(bp->buf, bp->start, (bp->end - bp->start));
- bp->end -= (bp->start - bp->buf);
- bp->start = bp->buf;
-}
-
-/******************************************************************************/
-
-MprBufProc mprGetBufRefillProc(MprBuf *bp)
-{
- return bp->refillProc;
-}
-
-/******************************************************************************/
-
-void mprSetBufRefillProc(MprBuf *bp, MprBufProc fn, void *arg)
-{
- bp->refillProc = fn;
- bp->refillArg = arg;
-}
-
-/******************************************************************************/
-
-int mprRefillBuf(MprBuf *bp)
-{
- return (bp->refillProc) ? (bp->refillProc)(bp, bp->refillArg) : 0;
-}
-
-/******************************************************************************/
-
-void mprResetBufIfEmpty(MprBuf *bp)
-{
- if (mprGetBufLength(bp) == 0) {
- mprFlushBuf(bp);
- }
-}
-
-/******************************************************************************/
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprGenFile.c b/source4/lib/appweb/ejs-2.0/mpr/mprGenFile.c
deleted file mode 100644
index 517e43853f..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/mprGenFile.c
+++ /dev/null
@@ -1,336 +0,0 @@
-/**
- * @file mprGenFile.c
- * @brief Generic File services
- * @overview
- * @remarks
- * See OS/mprFile.c for the per O/S portions
- */
-
-/******************************************************************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/********************************** Includes **********************************/
-
-#include "mpr.h"
-
-/****************************** Forward Declarations **************************/
-#if !BREW
-
-static int closeDestructor(void *data);
-
-/************************************ Code ************************************/
-
-int mprStartFileServices(MprCtx ctx)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
- app->console = mprAllocTypeZeroed(ctx, MprFile);
- app->error = mprAllocTypeZeroed(ctx, MprFile);
-
- /*
- * We assume that STDOUT is 1 and STDERR is 2
- */
- app->console->fd = 1;
- app->error->fd = 2;
-
- return 0;
-}
-
-/******************************************************************************/
-
-void mprStopFileServices(MprCtx ctx)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
-
- mprFree(app->console);
- app->console = 0;
- mprFree(app->error);
- app->error = 0;
-}
-
-/******************************************************************************/
-
-MprFile *mprOpen(MprCtx ctx, const char *path, int omode, int perms)
-{
- MprFile *file;
-
- mprAssert(path && *path);
-
- file = mprAllocTypeZeroed(ctx, MprFile);
-
- file->fd = open(path, omode, perms);
- if (file->fd < 0) {
- mprFree(file);
- return 0;
- }
-
- mprSetDestructor(file, closeDestructor);
- return file;
-}
-
-/******************************************************************************/
-
-static int closeDestructor(void *data)
-{
- MprFile *file = (MprFile*) data;
-
- mprAssert(file);
-
- mprClose(file);
- return 0;
-}
-
-/******************************************************************************/
-
-void mprClose(MprFile *file)
-{
- mprAssert(file);
-
- if (file < 0) {
- return;
- }
-
- mprAssert(file->fd >= 0);
- close(file->fd);
-
- mprSetDestructor(file, 0);
- mprFree(file);
-}
-
-/******************************************************************************/
-
-int mprRead(MprFile *file, void *buf, uint size)
-{
- mprAssert(file);
-
- if (file == 0) {
- return MPR_ERR_BAD_HANDLE;
- }
-
- return read(file->fd, buf, size);
-}
-
-/******************************************************************************/
-
-int mprWrite(MprFile *file, const void *buf, uint count)
-{
- mprAssert(file);
-
- if (file == 0) {
- return MPR_ERR_BAD_HANDLE;
- }
-
- return write(file->fd, buf, count);
-}
-
-/******************************************************************************/
-
-int mprSeek(MprFile *file, int seekType, long distance)
-{
- mprAssert(file);
-
- if (file == 0) {
- return MPR_ERR_BAD_HANDLE;
- }
-
- return lseek(file->fd, seekType, distance);
-}
-
-/******************************************************************************/
-
-int mprDelete(MprCtx ctx, const char *path)
-{
- return unlink(path);
-}
-
-/******************************************************************************/
-
-int mprDeleteDir(MprCtx ctx, const char *path)
-{
- return rmdir(path);
-}
-
-#endif /* !BREW */
-/******************************************************************************/
-
-char *mprGets(MprFile *file, char *buf, uint size)
-{
- MprBuf *bp;
- int count, len, c;
-
- mprAssert(file);
-
- if (file == 0) {
- return 0;
- }
-
- if (file->buf == 0) {
- file->buf = mprCreateBuf(file, MPR_DEFAULT_ALLOC, MPR_MAX_STRING);
- }
- bp = file->buf;
-
- /*
- * Must leave room for null
- */
- count = 0;
- while (--size > 0) {
- if (mprGetBufLength(bp) == 0) {
- mprFlushBuf(bp);
- len = mprRead(file, mprGetBufEnd(bp),
- mprGetBufLinearSpace(bp));
- if (len <= 0) {
- return 0;
- }
- mprAdjustBufEnd(bp, len);
- mprAddNullToBuf(bp);
- }
- if ((c = mprGetCharFromBuf(bp)) == '\n') {
- buf[count] = '\0';
- return buf;
- }
- buf[count++] = c;
- }
- buf[count] = '\0';
- return buf;
-}
-
-/******************************************************************************/
-
-int mprPuts(MprFile *file, const char *writeBuf, uint count)
-{
- MprBuf *bp;
- char *buf;
- int total, bytes, len;
-
- mprAssert(file);
-
- /*
- * Buffer output and flush when full.
- */
- if (file->buf == 0) {
- file->buf = mprCreateBuf(file, MPR_BUFSIZE, 0);
- if (file->buf == 0) {
- return MPR_ERR_CANT_ALLOCATE;
- }
- }
- bp = file->buf;
-
- if (mprGetBufLength(bp) > 0 && mprGetBufSpace(bp) < (int) count) {
- len = mprGetBufLength(bp);
- if (mprWrite(file, mprGetBufStart(bp), len) != len) {
- return MPR_ERR_CANT_WRITE;
- }
- mprFlushBuf(bp);
- }
-
- total = 0;
- buf = (char*) writeBuf;
-
- while (count > 0) {
- bytes = mprPutBlockToBuf(bp, buf, count);
- if (bytes <= 0) {
- return MPR_ERR_CANT_ALLOCATE;
- }
- count -= bytes;
- buf += bytes;
- total += bytes;
- mprAddNullToBuf(bp);
-
- if (count > 0) {
- len = mprGetBufLength(bp);
- if (mprWrite(file, mprGetBufStart(bp), len) != len) {
- return MPR_ERR_CANT_WRITE;
- }
- mprFlushBuf(bp);
- }
- }
- return total;
-}
-
-/******************************************************************************/
-
-int mprMakeTempFileName(MprCtx ctx, char *buf, int bufsize, const char *tempDir)
-{
- MprFile *file;
- MprTime now;
- char *dir;
- int seed, i;
-
- if (tempDir == 0) {
-#if WIN
- char *cp;
- dir = mprStrdup(ctx, getenv("TEMP"));
- for (cp = dir; *cp; cp++) {
- if (*cp == '\\') {
- *cp = '/';
- }
- }
-#else
- dir = mprStrdup(ctx, "/tmp");
-#endif
- } else {
- dir = mprStrdup(ctx, tempDir);
- }
-
- mprGetTime(ctx, &now);
- seed = now.msec % 64000;
- file = 0;
-
- for (i = 0; i < 128; i++) {
- mprSprintf(buf, bufsize, "%s/MPR_%d_%d.tmp", dir, getpid(), seed++);
- file = mprOpen(ctx, buf, O_CREAT | O_EXCL | O_BINARY, 0664);
- if (file) {
- break;
- }
- }
-
- if (file == 0) {
- return MPR_ERR_CANT_CREATE;
- }
-
- mprClose(file);
- mprFree(dir);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprGenTime.c b/source4/lib/appweb/ejs-2.0/mpr/mprGenTime.c
deleted file mode 100644
index 6b0ed97bbc..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/mprGenTime.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/**
- * @file mprGenTime.c
- * @brief Generic Time handling
- * @overview
- */
-
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/********************************* Includes ***********************************/
-
-#include "mpr.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/******************************************************************************/
-/*
- * Return the number of milliseconds until the given timeout has expired.
- */
-
-int mprGetTimeRemaining(MprCtx ctx, MprTime mark, uint timeout)
-{
- MprTime now;
- uint diff;
-
- mprGetTime(ctx, &now);
- diff = ((now.sec - mark.sec) * 1000) + (now.msec - mark.msec);
-
- if (diff < 0) {
- /*
- * Detect time going backwards
- */
- mprAssert(diff >= 0);
- diff = 0;
- }
- return (int) (timeout - diff);
-}
-
-/******************************************************************************/
-/*
- * Return the number of milliseconds until the given timeout has expired.
- */
-
-int mprGetElapsedTime(MprCtx ctx, MprTime mark)
-{
- MprTime now;
-
- mprGetTime(ctx, &now);
- return ((now.sec - mark.sec) * 1000) + (now.msec - mark.msec);
-}
-
-/******************************************************************************/
-
-void mprAddElapsedToTime(MprTime *time, uint elapsed)
-{
- time->sec += elapsed / 1000;
- time->msec += elapsed % 1000;
- if (time->msec > 1000) {
- time->msec -= 1000;
- time->sec++;
- }
-}
-
-/******************************************************************************/
-
-int mprCompareTime(MprTime *t1, MprTime *t2)
-{
- if (t1->sec < t2->sec) {
- return -1;
- } else if (t1->sec == t2->sec) {
- if (t1->msec < t2->msec) {
- return -1;
- } else if (t1->msec == t2->msec) {
- return 0;
- }
- }
- return 1;
-}
-
-/******************************************************************************/
-
-uint mprSubtractTime(MprTime *t1, MprTime *t2)
-{
- return ((t1->sec - t2->sec) * 1000) + (t1->msec - t2->msec);
-}
-
-/******************************************************************************/
-#if !BREW
-/*
- * Thread-safe RFC822 dates (Eg: "Fri, 07 Jan 2003 12:12:21 GMT")
- */
-
-int mprRfcTime(MprCtx ctx, char *buf, int bufsize, const struct tm *timep)
-{
- char months[12][4] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
- "Oct", "Nov", "Dec"
- };
-
- char days[7][4] = {
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
- };
-
- char *dayp, *monthp;
- int year;
-
- if (bufsize < 30) {
- return MPR_ERR_WONT_FIT;
- }
- dayp = &days[timep->tm_wday][0];
- *buf++ = *dayp++;
- *buf++ = *dayp++;
- *buf++ = *dayp++;
- *buf++ = ',';
- *buf++ = ' ';
-
- *buf++ = timep->tm_mday / 10 + '0';
- *buf++ = timep->tm_mday % 10 + '0';
- *buf++ = ' ';
-
- monthp = &months[timep->tm_mon][0];
- *buf++ = *monthp++;
- *buf++ = *monthp++;
- *buf++ = *monthp++;
- *buf++ = ' ';
-
- year = 1900 + timep->tm_year;
- /* This routine isn't y10k ready. */
- *buf++ = year / 1000 + '0';
- *buf++ = year % 1000 / 100 + '0';
- *buf++ = year % 100 / 10 + '0';
- *buf++ = year % 10 + '0';
- *buf++ = ' ';
-
- *buf++ = timep->tm_hour / 10 + '0';
- *buf++ = timep->tm_hour % 10 + '0';
- *buf++ = ':';
- *buf++ = timep->tm_min / 10 + '0';
- *buf++ = timep->tm_min % 10 + '0';
- *buf++ = ':';
- *buf++ = timep->tm_sec / 10 + '0';
- *buf++ = timep->tm_sec % 10 + '0';
- *buf++ = ' ';
-
- *buf++ = 'G';
- *buf++ = 'M';
- *buf++ = 'T';
- *buf++ = 0;
- return 0;
-}
-
-#endif
-/******************************************************************************/
-
-#ifdef __cplusplus
-}
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprLock.c b/source4/lib/appweb/ejs-2.0/mpr/mprLock.c
deleted file mode 100644
index df9ce276d4..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/mprLock.c
+++ /dev/null
@@ -1,266 +0,0 @@
-/**
- * @file mprThread.c
- * @brief Mbedthis Portable Runtime Base Thread Locking Support
- */
-
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-#include "mpr.h"
-
-#if BLD_FEATURE_MULTITHREAD
-/************************************ Code ************************************/
-
-void mprInitThreads(MprApp *app)
-{
- mprAssert(app);
-
- if (app->globalLock == 0) {
- app->globalLock = mprCreateLock(app);
- app->allocLock = mprCreateLock(app);
- }
-}
-
-/******************************************************************************/
-
-void mprTermThreads(MprApp *app)
-{
- mprAssert(app);
-
- if (app->globalLock) {
- mprDestroyLock(app->globalLock);
- app->globalLock = 0;
- }
- if (app->allocLock) {
- MprLock *lock = app->allocLock;
- app->allocLock = 0;
- mprDestroyLock(lock);
- }
-}
-
-/******************************************************************************/
-
-MprLock *mprCreateLock(MprCtx ctx)
-{
- MprLock *lock;
-
- mprAssert(ctx);
-
- lock = mprAllocType(ctx, MprLock);
-
-#if BLD_HOST_UNIX
- pthread_mutexattr_t attr;
-
- pthread_mutexattr_init(&attr);
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
- pthread_mutex_init(&lock->cs, &attr);
- pthread_mutexattr_destroy(&attr);
-#elif WIN
- InitializeCriticalSectionAndSpinCount(&lock->cs, 5000);
-#elif VXWORKS
- lock->cs = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE |
- SEM_INVERSION_SAFE);
- if (lock->cs == 0) {
- mprAssert(0);
- mprFree(lock);
- return 0;
- }
-#endif
- return lock;
-}
-
-/******************************************************************************/
-/*
- * Destroy a lock. Must be locked on entrance.
- */
-
-void mprDestroyLock(MprLock *lock)
-{
- mprAssert(lock);
- if (lock == 0) {
- return;
- }
-
-#if BLD_HOST_UNIX
- pthread_mutex_unlock(&lock->cs);
- pthread_mutex_destroy(&lock->cs);
-#elif WIN
- DeleteCriticalSection(&lock->cs);
-#elif VXWORKS
- semDelete(lock->cs);
-#endif
- mprFree(lock);
-}
-
-/******************************************************************************/
-/*
- * Lock a mutex
- */
-
-void mprLock(MprLock *lock)
-{
- /*
- * OPT -- Do this just so we can allocate MprApp before we have created its
- * lock. Should remove this test here and in mprUnlock.
- */
- if (lock == 0) {
- return;
- }
-
-#if BLD_HOST_UNIX
- pthread_mutex_lock(&lock->cs);
-#elif WIN
- EnterCriticalSection(&lock->cs);
-#elif VXWORKS
- semTake(lock->cs, WAIT_FOREVER);
-#endif
-}
-
-/******************************************************************************/
-/*
- * Try to attain a lock. Do not block!
- */
-
-int mprTryLock(MprLock *lock)
-{
- mprAssert(lock);
-
-#if BLD_HOST_UNIX
- {
- int err;
-
- if ((err = pthread_mutex_trylock(&lock->cs)) != 0) {
- if (err == EBUSY) {
- return MPR_ERR_BUSY;
- } else {
- return MPR_ERR_CANT_ACCESS;
- }
- }
- return 0;
- }
-#elif WIN
- if (TryEnterCriticalSection(&lock->cs) == 0) {
- return MPR_ERR_BUSY;
- }
-#elif VXWORKS
- {
- int rc;
-
- rc = semTake(cs, NO_WAIT);
- if (rc == -1) {
- mprAssert(0);
- }
- if (rc == S_objLib_OBJ_UNAVAILABLE) {
- return MPR_ERR_BUSY;
- } else {
- return MPR_ERR_CANT_ACCESS;
- }
- /* Success */
- return 0;
- }
-#endif
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Unlock.
- */
-
-void mprUnlock(MprLock *lock)
-{
- if (lock == 0) {
- return;
- }
-
-#if BLD_HOST_UNIX
- pthread_mutex_unlock(&lock->cs);
-#elif WIN
- LeaveCriticalSection(&lock->cs);
-#elif VXWORKS
- semGive(lock->cs);
-#endif
-}
-
-/******************************************************************************/
-/*
- * Big global lock. Avoid using this.
- */
-
-void mprGlobalLock(MprCtx ctx)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
- mprAssert(app);
-
- if (app && app->globalLock) {
- mprLock(app->globalLock);
- }
-}
-
-/******************************************************************************/
-
-void mprGlobalUnlock(MprCtx ctx)
-{
- MprApp *app;
-
- app = mprGetApp(ctx);
- mprAssert(app);
-
- if (app && app->globalLock) {
- mprUnlock(app->globalLock);
- }
-}
-
-/******************************************************************************/
-
-int mprGetCurrentThreadID()
-{
-#if BLD_HOST_UNIX
- return (int) pthread_self();
-#elif WIN
- return GetCurrentThreadId();
-#elif VXWORKS
- return (int) pthread_self();
-#endif
-}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_MULTITHREAD */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprLog.c b/source4/lib/appweb/ejs-2.0/mpr/mprLog.c
deleted file mode 100644
index 1eb175ed95..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/mprLog.c
+++ /dev/null
@@ -1,602 +0,0 @@
-/**
- * @file mprLog.c
- * @brief Mbedthis Portable Runtime (MPR) Logging and error reporting.
- * @remarks We always provide these routines.
- */
-
-/*********************************** License **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-#include "mpr.h"
-
-/****************************** Forward Declarations **************************/
-
-static void defaultLogHandler(MPR_LOC_DEC(ctx, loc), int flags,
- int level, const char *msg);
-static void logOutput(MPR_LOC_DEC(ctx, loc), int flags, int level,
- const char *msg);
-
-/************************************ Code ************************************/
-
-void mprLog(MprCtx ctx, int level, const char *fmt, ...)
-{
- va_list args;
- char *buf;
-
- if (level > mprGetLogLevel(ctx)) {
- return;
- }
-
- va_start(args, fmt);
- mprAllocVsprintf(MPR_LOC_ARGS(ctx), &buf, 0, fmt, args);
- va_end(args);
-
- logOutput(MPR_LOC_ARGS(ctx), MPR_LOG_SRC, level, buf);
-
- va_end(args);
- mprFree(buf);
-}
-
-/*****************************************************************************/
-/*
- * Do raw output
- */
-
-void mprRawLog(MprCtx ctx, const char *fmt, ...)
-{
- va_list args;
- char *buf;
- int len;
-
- va_start(args, fmt);
- len = mprAllocVsprintf(MPR_LOC_ARGS(ctx), &buf, 0, fmt, args);
- va_end(args);
-
- logOutput(MPR_LOC_ARGS(ctx), MPR_RAW, 0, buf);
- mprFree(buf);
-}
-
-/*****************************************************************************/
-/*
- * Handle an error
- */
-
-void mprError(MPR_LOC_DEC(ctx, loc), const char *fmt, ...)
-{
- va_list args;
- char *buf;
- int len;
-
- va_start(args, fmt);
- len = mprAllocVsprintf(MPR_LOC_ARGS(ctx), &buf, 0, fmt, args);
- va_end(args);
-
- logOutput(MPR_LOC_PASS(ctx, loc), MPR_ERROR_MSG | MPR_ERROR_SRC, 0, buf);
-
- mprFree(buf);
-}
-
-/*****************************************************************************/
-/*
- * Handle an error that should be displayed to the user
- */
-
-void mprUserError(MPR_LOC_DEC(ctx, loc), const char *fmt, ...)
-{
- va_list args;
- char *buf;
- int len;
-
- va_start(args, fmt);
- len = mprAllocVsprintf(MPR_LOC_ARGS(ctx), &buf, 0, fmt, args);
- va_end(args);
-
- logOutput(MPR_LOC_PASS(ctx, loc), MPR_USER_MSG | MPR_ERROR_SRC, 0, buf);
-
- mprFree(buf);
-}
-
-/*****************************************************************************/
-/*
- * Handle a fatal error. Forcibly shutdown the application.
- */
-
-void mprFatalError(MPR_LOC_DEC(ctx, loc), const char *fmt, ...)
-{
- va_list args;
- char *buf;
- int len;
-
- va_start(args, fmt);
- len = mprAllocVsprintf(MPR_LOC_ARGS(ctx), &buf, 0, fmt, args);
- va_end(args);
-
- logOutput(MPR_LOC_PASS(ctx, loc), MPR_USER_MSG | MPR_FATAL_SRC, 0, buf);
-
- mprFree(buf);
-
-#if BREW
- mprSignalExit(ctx);
-#else
- exit(2);
-#endif
-}
-
-/*****************************************************************************/
-/*
- * Handle a program assertion
- */
-
-void mprAssertError(MPR_LOC_DEC(ctx, loc), const char *msg)
-{
- logOutput(MPR_LOC_PASS(ctx, loc), MPR_ASSERT_MSG | MPR_ASSERT_SRC, 0, msg);
-}
-
-/*****************************************************************************/
-/*
- * Handle an error
- */
-
-void mprStaticError(MPR_LOC_DEC(ctx, loc), const char *fmt, ...)
-{
- va_list args;
- int len;
- char buf[MPR_MAX_STRING];
-
- va_start(args, fmt);
- len = mprVsprintf(buf, sizeof(buf), fmt, args);
- va_end(args);
-
- logOutput(MPR_LOC_PASS(ctx, loc), MPR_ERROR_MSG | MPR_ERROR_SRC, 0, buf);
-}
-
-/*****************************************************************************/
-/*
- * Direct output to the standard output. Does not hook into the logging
- * system and does not allocate memory.
- */
-
-void mprStaticAssert(const char *loc, const char *msg)
-{
-#if BLD_DEBUG
- char buf[MPR_MAX_STRING];
- int len;
-
- len = mprSprintf(buf, sizeof(buf), "Assertion %s, failed at %s\n",
- msg, loc);
- mprBreakpoint(loc, buf);
-
-#if BLD_HOST_UNIX
- /*
- * MOB -- but is stdout always okay to use
- */
- write(1, buf, len);
-#elif BREW || WIN
- /*
- * Only time we use printf. We can't get an alloc context so we have
- * to use real print
- */
-#if BREW && !BREW_SIMULATOR
- printf(" MP: %s\n", buf);
-#else
- printf("%s\n", buf);
-#endif
-
-#endif
-#endif
-}
-
-/*****************************************************************************/
-
-int mprGetLogLevel(MprCtx ctx)
-{
- return mprGetApp(ctx)->logLevel;
-}
-
-/******************************************************************************/
-
-void mprSetLogLevel(MprCtx ctx, int level)
-{
- mprGetApp(ctx)->logLevel = level;
-}
-
-/*****************************************************************************/
-/*
- * Output a log message to the log handler
- */
-
-static void logOutput(MPR_LOC_DEC(ctx, loc), int flags, int level,
- const char *msg)
-{
- MprLogHandler handler;
-
- if (flags & (MPR_ERROR_SRC | MPR_FATAL_SRC | MPR_ASSERT_SRC)) {
- mprBreakpoint(MPR_LOC, 0);
- }
-
- mprAssert(ctx != 0);
- handler = mprGetApp(ctx)->logHandler;
- if (handler != 0) {
- (handler)(MPR_LOC_PASS(ctx, loc), flags, level, msg);
- return;
- }
- defaultLogHandler(MPR_LOC_PASS(ctx, loc), flags, level, msg);
-}
-
-/*****************************************************************************/
-/*
- * Default log output is just to the console
- */
-
-static void defaultLogHandler(MPR_LOC_DEC(ctx, loc), int flags,
- int level, const char *msg)
-{
- MprApp *app;
- char *prefix;
-
- app = mprGetApp(ctx);
- prefix = app->name;
-
- while (*msg == '\n') {
- mprPrintf(ctx, "\n");
- msg++;
- }
-
- if (flags & MPR_LOG_SRC) {
-#if BREW && !BREW_SIMULATOR
- mprPrintf(ctx, "%s\n", msg);
-#else
- mprPrintf(ctx, "%s: %d: %s\n", prefix, level, msg);
-#endif
-
- } else if (flags & MPR_ERROR_SRC) {
- /*
- * Use static printing to avoid malloc when the messages are small.
- * This is important for memory allocation errors.
- */
- if (strlen(msg) < (MPR_MAX_STRING - 32)) {
- mprStaticPrintf(ctx, "%s: Error: %s\n", prefix, msg);
- } else {
- mprPrintf(ctx, "%s: Error: %s\n", prefix, msg);
- }
-
- } else if (flags & MPR_FATAL_SRC) {
- mprPrintf(ctx, "%s: Fatal: %s\n", prefix, msg);
-
- } else if (flags & MPR_ASSERT_SRC) {
-#if BLD_FEATURE_ALLOC_LEAK_TRACK
- mprPrintf(ctx, "%s: Assertion %s, failed at %s\n", prefix, msg, loc);
-#else
- mprPrintf(ctx, "%s: Assertion %s, failed\n", prefix, msg);
-#endif
-
- } else if (flags & MPR_RAW) {
- mprPrintf(ctx, "%s", msg);
-
- } else {
- return;
- }
-}
-
-/*****************************************************************************/
-/*
- * Map the O/S error code to portable error codes.
- */
-
-int mprGetOsError()
-{
-#if WIN
- int rc;
- rc = GetLastError();
-
- /*
- * Client has closed the pipe
- */
- if (rc == ERROR_NO_DATA) {
- return EPIPE;
- }
- return rc;
-#endif
-#if LINUX || VXWORKS || SOLARIS
- return errno;
-#endif
-#if BREW
- /*
- * No such thing on Brew. Errors are per class
- */
- return 0;
-#endif
-}
-
-/******************************************************************************/
-#if UNUSED
-
-const char *mprGetErrorMsg(int err)
-{
- /*
- * MPR error messages. Declare here so we don't have any globals.
- */
- char *mprErrMessages[] = {
- /* 0 MPR_ERR_OK */ "Success",
- /* -201 MPR_ERR_GENERAL */ "General error",
- /* -202 MPR_ERR_ABORTED */ "Aborted",
- /* -203 MPR_ERR_ALREADY_EXISTS */ "Already exists",
- /* -204 MPR_ERR_BAD_ARGS */ "Bad args",
- /* -205 MPR_ERR_BAD_FORMAT */ "Bad format",
- /* -206 MPR_ERR_BAD_HANDLE */ "Bad handle",
- /* -207 MPR_ERR_BAD_STATE */ "Bad state",
- /* -208 MPR_ERR_BAD_SYNTAX */ "Bad syntax",
- /* -209 MPR_ERR_BAD_TYPE */ "Bad type",
- /* -210 MPR_ERR_BAD_VALUE */ "Bad value",
- /* -211 MPR_ERR_BUSY */ "Busy",
- /* -212 MPR_ERR_CANT_ACCESS */ "Can't access",
- /* -213 MPR_ERR_CANT_COMPLETE */ "Can't complete",
- /* -214 MPR_ERR_CANT_CREATE */ "Can't create",
- /* -215 MPR_ERR_CANT_INITIALIZE */ "Can't initialize",
- /* -216 MPR_ERR_CANT_OPEN */ "Can't open",
- /* -217 MPR_ERR_CANT_READ */ "Can't read",
- /* -218 MPR_ERR_CANT_WRITE */ "Can't write",
- /* -219 MPR_ERR_DELETED */ "Already deleted",
- /* -220 MPR_ERR_NETWORK */ "Network error",
- /* -221 MPR_ERR_NOT_FOUND */ "Not found",
- /* -222 MPR_ERR_NOT_INITIALIZED */ "Not initialized",
- /* -223 MPR_ERR_NOT_READY */ "Not ready",
- /* -224 MPR_ERR_READ_ONLY */ "Read only",
- /* -225 MPR_ERR_TIMEOUT */ "Timeout",
- /* -226 MPR_ERR_TOO_MANY */ "Too many",
- /* -227 MPR_ERR_WONT_FIT */ "Won't fit",
- /* -228 MPR_ERR_WOULD_BLOCK */ "Would block",
- /* -229 MPR_ERR_CANT_ALLOCATE */ "Can't allocate",
- };
- int mprNumErr = sizeof(mprErrMessages) / sizeof(char*);
-
-/*
- * Operating system error messages
- */
-#if WIN
-char *osErrMessages[] =
-{
- /* 0 */ "No error",
- /* 1 EPERM */ "Operation not permitted",
- /* 2 ENOENT */ "No such file or directory",
- /* 3 ESRCH */ "No such process",
- /* 4 EINTR */ "Interrupted function call",
- /* 5 EIO */ "I/O error",
- /* 6 ENXIO */ "No such device or address",
- /* 7 E2BIG */ "Arg list too long",
- /* 8 ENOEXEC */ "Exec format error",
- /* 9 EBADF */ "Bad file number",
- /* 10 ECHILD */ "No child processes",
- /* 11 EAGAIN */ "Try again",
- /* 12 ENOMEM */ "Out of memory",
- /* 13 EACCES */ "Permission denied",
- /* 14 EFAULT */ "Bad address",
- /* 15 ENOTBLK */ "Unknown error",
- /* 16 EBUSY */ "Resource busy",
- /* 17 EEXIST */ "File exists",
- /* 18 EXDEV */ "Improper link",
- /* 19 ENODEV */ "No such device",
- /* 20 ENOTDIR */ "Not a directory",
- /* 21 EISDIR */ "Is a directory",
- /* 22 EINVAL */ "Invalid argument",
- /* 23 ENFILE */ "Too many open files in system",
- /* 24 EMFILE */ "Too many open files",
- /* 25 ENOTTY */ "Inappropriate I/O control operation",
- /* 26 ETXTBSY */ "Unknown error",
- /* 27 EFBIG */ "File too large",
- /* 28 ENOSPC */ "No space left on device",
- /* 29 ESPIPE */ "Invalid seek",
- /* 30 EROFS */ "Read-only file system",
- /* 31 EMLINK */ "Too many links",
- /* 32 EPIPE */ "Broken pipe",
- /* 33 EDOM */ "Domain error",
- /* 34 ERANGE */ "Result too large",
- /* 35 EUCLEAN */ "Unknown error",
- /* 36 EDEADLK */ "Resource deadlock would occur",
- /* 37 UNKNOWN */ "Unknown error",
- /* 38 ENAMETOOLONG */ "Filename too long",
- /* 39 ENOLCK */ "No locks available",
- /* 40 ENOSYS */ "Function not implemented",
- /* 41 ENOTEMPTY */ "Directory not empty",
- /* 42 EILSEQ */ "Illegal byte sequence",
- /* 43 ENETDOWN */ "Network is down",
- /* 44 ECONNRESET */ "Connection reset",
- /* 45 ECONNREFUSED */ "Connection refused",
- /* 46 EADDRINUSE */ "Address already in use"
-
-};
-
-#else /* WIN */
-
-char *osErrMessages[] =
-{
- /* 0 */ "Success"
- /* 1 EPERM */ "Operation not permitted"
- /* 2 ENOENT */ "No such file or directory"
- /* 3 ESRCH */ "No such process"
- /* 4 EINTR */ "Interrupted system call"
- /* 5 EIO */ "I/O error"
- /* 6 ENXIO */ "No such device or address"
- /* 7 E2BIG */ "Arg list too long"
- /* 8 ENOEXEC */ "Exec format error"
- /* 9 EBADF */ "Bad file number"
- /* 10 ECHILD */ "No child processes"
- /* 11 EAGAIN */ "Try again"
- /* 12 ENOMEM */ "Out of memory"
- /* 13 EACCES */ "Permission denied"
- /* 14 EFAULT */ "Bad address"
- /* 15 ENOTBLK */ "Block device required"
- /* 16 EBUSY */ "Device or resource busy"
- /* 17 EEXIST */ "File exists"
- /* 18 EXDEV */ "Cross-device link"
- /* 19 ENODEV */ "No such device"
- /* 20 ENOTDIR */ "Not a directory"
- /* 21 EISDIR */ "Is a directory"
- /* 22 EINVAL */ "Invalid argument"
- /* 23 ENFILE */ "File table overflow"
- /* 24 EMFILE */ "Too many open files"
- /* 25 ENOTTY */ "Not a typewriter"
- /* 26 ETXTBSY */ "Text file busy"
- /* 27 EFBIG */ "File too large"
- /* 28 ENOSPC */ "No space left on device"
- /* 29 ESPIPE */ "Illegal seek"
- /* 30 EROFS */ "Read-only file system"
- /* 31 EMLINK */ "Too many links"
- /* 32 EPIPE */ "Broken pipe"
- /* 33 EDOM */ "Math argument out of domain of func"
- /* 34 ERANGE */ "Math result not representable"
- /* 35 EDEADLK */ "Resource deadlock would occur"
- /* 36 ENAMETOOLONG */ "File name too long"
- /* 37 ENOLCK */ "No record locks available"
- /* 38 ENOSYS */ "Function not implemented"
- /* 39 ENOTEMPTY */ "Directory not empty"
- /* 40 ELOOP */ "Too many symbolic links encountered"
- /* 41 EWOULDBLOCK EAGAIN */"Operation would block"
- /* 42 ENOMSG */ "No message of desired type"
- /* 43 EIDRM */ "Identifier removed"
-
-#if !BLD_FEATURE_SQUEEZE
- /* 44 ECHRNG */ "Channel number out of range"
- /* 45 EL2NSYNC */ "Level 2 not synchronized"
- /* 46 EL3HLT */ "Level 3 halted"
- /* 47 EL3RST */ "Level 3 reset"
- /* 48 ELNRNG */ "Link number out of range"
- /* 49 EUNATCH */ "Protocol driver not attached"
- /* 50 ENOCSI */ "No CSI structure available"
- /* 51 EL2HLT */ "Level 2 halted"
- /* 52 EBADE */ "Invalid exchange"
- /* 53 EBADR */ "Invalid request descriptor"
- /* 54 EXFULL */ "Exchange full"
- /* 55 ENOANO */ "No anode"
- /* 56 EBADRQC */ "Invalid request code"
- /* 57 EBADSLT */ "Invalid slot"
- /* 59 EBFONT */ "Bad font file format"
- /* 60 ENOSTR */ "Device not a stream"
- /* 61 ENODATA */ "No data available"
- /* 62 ETIME */ "Timer expired"
- /* 63 ENOSR */ "Out of streams resources"
- /* 64 ENONET */ "Machine is not on the network"
- /* 65 ENOPKG */ "Package not installed"
- /* 66 EREMOTE */ "Object is remote"
- /* 67 ENOLINK */ "Link has been severed"
- /* 68 EADV */ "Advertise error"
- /* 69 ESRMNT */ "Srmount error"
- /* 70 ECOMM */ "Communication error on send"
- /* 71 EPROTO */ "Protocol error"
- /* 72 EMULTIHOP */ "Multihop attempted"
- /* 73 EDOTDOT */ "RFS specific error"
- /* 74 EBADMSG */ "Not a data message"
- /* 75 EOVERFLOW */ "Value too large for defined data type"
- /* 76 ENOTUNIQ */ "Name not unique on network"
- /* 77 EBADFD */ "File descriptor in bad state"
- /* 78 EREMCHG */ "Remote address changed"
- /* 79 ELIBACC */ "Can not access a needed shared library"
- /* 80 ELIBBAD */ "Accessing a corrupted shared library"
- /* 81 ELIBSCN */ ".lib section in a.out corrupted"
- /* 82 ELIBMAX */ "Linking in too many shared libraries"
- /* 83 ELIBEXEC */ "Cannot exec a shared library directly"
- /* 84 EILSEQ */ "Illegal byte sequence"
- /* 85 ERESTART */ "Interrupted system call should be restarted"
- /* 86 ESTRPIPE */ "Streams pipe error"
- /* 87 EUSERS */ "Too many users"
- /* 88 ENOTSOCK */ "Socket operation on non-socket"
- /* 89 EDESTADDRREQ */ "Destination address required"
- /* 90 EMSGSIZE */ "Message too long"
- /* 91 EPROTOTYPE */ "Protocol wrong type for socket"
- /* 92 ENOPROTOOPT */ "Protocol not available"
- /* 93 EPROTONOSUPPORT */ "Protocol not supported"
- /* 94 ESOCKTNOSUPPORT */ "Socket type not supported"
- /* 95 EOPNOTSUPP */ "Operation not supported on transport endpoint"
- /* 96 EPFNOSUPPORT */ "Protocol family not supported"
- /* 97 EAFNOSUPPORT */ "Address family not supported by protocol"
- /* 98 EADDRINUSE */ "Address already in use"
- /* 99 EADDRNOTAVAIL */ "Cannot assign requested address"
- /* 100 ENETDOWN */ "Network is down"
- /* 101 ENETUNREACH */ "Network is unreachable"
- /* 102 ENETRESET */ "Network dropped connection because of reset"
- /* 103 ECONNABORTED */ "Software caused connection abort"
- /* 104 ECONNRESET */ "Connection reset by peer"
- /* 105 ENOBUFS */ "No buffer space available"
- /* 106 EISCONN */ "Transport endpoint is already connected"
- /* 107 ENOTCONN */ "Transport endpoint is not connected"
- /* 108 ESHUTDOWN */ "Cannot send after transport endpoint shutdown"
- /* 109 ETOOMANYREFS */ "Too many references: cannot splice"
- /* 110 ETIMEDOUT */ "Connection timed out"
- /* 111 ECONNREFUSED */ "Connection refused"
- /* 112 EHOSTDOWN */ "Host is down"
- /* 113 EHOSTUNREACH */ "No route to host"
- /* 114 EALREADY */ "Operation already in progress"
- /* 115 EINPROGRESS */ "Operation now in progress"
- /* 116 ESTALE */ "Stale NFS file handle"
- /* 117 EUCLEAN */ "Structure needs cleaning"
- /* 118 ENOTNAM */ "Not a XENIX named type file"
- /* 119 ENAVAIL */ "No XENIX semaphores available"
- /* 120 EISNAM */ "Is a named type file"
- /* 121 EREMOTEIO */ "Remote I/O error"
- /* 122 EDQUOT */ "Quota exceeded"
- /* 123 ENOMEDIUM */ "No medium found"
- /* 124 EMEDIUMTYPE */ "Wrong medium type"
-};
-#endif /* BLD_FEATURE_SQUEEZE */
-#endif /* WIN */
-
- int osNumErr = sizeof(osErrMessages) / sizeof(char*);
-
- if (err < MPR_ERR_BASE) {
- err = MPR_ERR_BASE - err;
- if (err < 0 || err >= mprNumErr) {
- return "Bad error code";
- }
- return mprErrMessages[err];
-
- } else {
- /*
- * Negative O/S error code. Map to a positive standard Posix error.
- */
- err = -err;
- if (err < 0 || err >= osNumErr) {
- return "Bad O/S error code";
- }
- return osErrMessages[err];
- }
-}
-
-#endif
-/*****************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprOs.h b/source4/lib/appweb/ejs-2.0/mpr/mprOs.h
deleted file mode 100644
index bed4ca5979..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/mprOs.h
+++ /dev/null
@@ -1,707 +0,0 @@
-/*
- * @file mprOs.h
- * @brief Include O/S headers and smooth out per-O/S differences
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/******************************* Documentation ********************************/
-
-/*
- * This header is part of the Mbedthis Portable Runtime and aims to include
- * all necessary O/S headers and to unify the constants and declarations
- * required by Mbedthis products. It can be included by C or C++ programs.
- */
-
-/******************************************************************************/
-
-#ifndef _h_MPR_OS_HDRS
-#define _h_MPR_OS_HDRS 1
-
-#include "buildConfig.h"
-
-/********************************* CPU Families *******************************/
-/*
- * Porters, add your CPU families here and update configure code.
- */
-#define MPR_CPU_UNKNOWN 0
-#define MPR_CPU_IX86 1
-#define MPR_CPU_PPC 2
-#define MPR_CPU_SPARC 3
-#define MPR_CPU_XSCALE 4
-#define MPR_CPU_ARM 5
-#define MPR_CPU_MIPS 6
-#define MPR_CPU_68K 7
-#define MPR_CPU_SIMNT 8 /* VxWorks NT simulator */
-#define MPR_CPU_SIMSPARC 9 /* VxWorks sparc simulator */
-
-/********************************* O/S Includes *******************************/
-
-#if LINUX || SOLARIS
- #include <sys/types.h>
- #include <time.h>
- #include <arpa/inet.h>
- #include <ctype.h>
- #include <dirent.h>
- #include <dlfcn.h>
- #include <fcntl.h>
- #include <grp.h>
- #include <errno.h>
- #include <libgen.h>
- #include <limits.h>
- #include <netdb.h>
- #include <net/if.h>
- #include <netinet/in.h>
- #include <netinet/tcp.h>
- #include <netinet/ip.h>
- #include <pthread.h>
- #include <pwd.h>
- #include <resolv.h>
- #include <signal.h>
- #include <stdarg.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <syslog.h>
- #include <sys/ioctl.h>
- #include <sys/stat.h>
- #include <sys/param.h>
- #include <sys/resource.h>
- #include <sys/sem.h>
- #include <sys/shm.h>
- #include <sys/socket.h>
- #include <sys/select.h>
- #include <sys/time.h>
- #include <sys/times.h>
- #include <sys/utsname.h>
- #include <sys/wait.h>
- #include <unistd.h>
-
-#if LINUX
- #include <stdint.h>
-#endif
-
-#if SOLARIS
- #include <netinet/in_systm.h>
-#endif
-
-#if BLD_FEATURE_FLOATING_POINT
- #define __USE_ISOC99 1
- #include <math.h>
- #include <values.h>
-#endif
-
-#endif /* LINUX || SOLARIS */
-
-#if VXWORKS
- #include <vxWorks.h>
- #include <envLib.h>
- #include <sys/types.h>
- #include <time.h>
- #include <arpa/inet.h>
- #include <ctype.h>
- #include <dirent.h>
- #include <fcntl.h>
- #include <errno.h>
- #include <limits.h>
- #include <loadLib.h>
- #include <netdb.h>
- #include <net/if.h>
- #include <netinet/tcp.h>
- #include <netinet/in.h>
- #include <netinet/ip.h>
- #include <signal.h>
- #include <stdarg.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sysSymTbl.h>
- #include <sys/fcntlcom.h>
- #include <sys/ioctl.h>
- #include <sys/stat.h>
- #include <sys/socket.h>
- #include <sys/times.h>
- #include <sys/wait.h>
- #include <unistd.h>
- #include <unldLib.h>
-
- #if BLD_FEATURE_FLOATING_POINT
- #include <float.h>
- #define __USE_ISOC99 1
- #include <math.h>
- #endif
-
- #include <sockLib.h>
- #include <inetLib.h>
- #include <ioLib.h>
- #include <pipeDrv.h>
- #include <hostLib.h>
- #include <netdb.h>
- #include <tickLib.h>
- #include <taskHookLib.h>
-
-#endif /* VXWORKS */
-
-#if MACOSX
- #include <time.h>
- #include <arpa/inet.h>
- #include <ctype.h>
- #include <fcntl.h>
- #include <grp.h>
- #include <errno.h>
- #include <libgen.h>
- #include <limits.h>
- #include <mach-o/dyld.h>
- #include <netdb.h>
- #include <net/if.h>
- #include <netinet/in_systm.h>
- #include <netinet/in.h>
- #include <netinet/tcp.h>
- #include <netinet/ip.h>
- #include <pthread.h>
- #include <pwd.h>
- #include <resolv.h>
- #include <signal.h>
- #include <stdarg.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdint.h>
- #include <string.h>
- #include <syslog.h>
- #include <sys/ioctl.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/param.h>
- #include <sys/resource.h>
- #include <sys/sem.h>
- #include <sys/shm.h>
- #include <sys/socket.h>
- #include <sys/select.h>
- #include <sys/time.h>
- #include <sys/times.h>
- #include <sys/types.h>
- #include <sys/utsname.h>
- #include <sys/wait.h>
- #include <unistd.h>
-#endif /* MACOSX */
-
-#if WIN
- /*
- * We replace insecure functions with Mbedthis replacements
- */
- #define _CRT_SECURE_NO_DEPRECATE 1
-
- #include <ctype.h>
- #include <conio.h>
- #include <direct.h>
- #include <errno.h>
- #include <fcntl.h>
- #include <io.h>
- #include <limits.h>
- #include <malloc.h>
- #include <process.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <stddef.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdarg.h>
- #include <time.h>
- #define WIN32_LEAN_AND_MEAN
- #include <winsock2.h>
- #include <windows.h>
- #include <winbase.h>
- #if BLD_FEATURE_FLOATING_POINT
- #include <float.h>
- #endif
- #include <shlobj.h>
- #include <shellapi.h>
- #include <wincrypt.h>
-
-#if BLD_DEBUG
- #include <crtdbg.h>
-#endif
- #include "mprUnix.h"
-#endif /* WIN */
-
-#if BREW
- #if BLD_FEATURE_FLOATING_POINT
- #warning "Floating point is not supported on Brew"
- #endif
- #if BLD_FEATURE_MULTITHREAD
- #warning "Multithreading is not supported on Brew"
- #endif
-
- #include "AEEModGen.h"
- #include "AEEAppGen.h"
- #include "BREWVersion.h"
-
- #if BREW_MAJ_VER == 2
- /*
- * Fix for BREW 2.X
- */
- #ifdef __GNUC__
- #define __inline extern __inline__
- #endif
- #include "AEENet.h"
- #undef __inline
- #endif
-
- #include "AEE.h"
- #include "AEEBitmap.h"
- #include "AEEDisp.h"
- #include "AEEFile.h"
- #include "AEEHeap.h"
- #include "AEEImageCtl.h"
- #include "AEEMedia.h"
- #include "AEEMediaUtil.h"
- #include "AEEMimeTypes.h"
- #include "AEEStdLib.h"
- #include "AEEShell.h"
- #include "AEESoundPlayer.h"
- #include "AEEText.h"
- #include "AEETransform.h"
- #include "AEEWeb.h"
- #if BREW_MAJ_VER >= 3
- #include "AEESMS.h"
- #endif
- #include "AEETAPI.h"
-
-#if 0
- #include "AEESound.h"
- #include "AEEDb.h"
- #include "AEEMenu.h"
-#endif
-
-#endif /* BREW */
-
-/******************************************************************************/
-/******************************* General Defines ******************************/
-/******************************************************************************/
-
-#ifndef MAXINT
-#if INT_MAX
- #define MAXINT INT_MAX
-#else
- #define MAXINT 0x7fffffff
-#endif
-#endif
-
-#ifndef BITSPERBYTE
-#define BITSPERBYTE (8 * sizeof(char))
-#endif
-
-#define BITS(type) (BITSPERBYTE * (int) sizeof(type))
-
-#ifndef max
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
-#ifndef min
-#define min(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
-#define MPR_ARRAY_SIZE(type) (sizeof(type) / sizeof(type[0]))
-
-#ifndef PRINTF_ATTRIBUTE
-#if (__GNUC__ >= 3) && !DOXYGEN && BLD_FEATURE_ALLOC_LEAK_TRACK
-/** 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
-
-typedef char *MprStr; /* Used for dynamic strings */
-
-#ifdef __cplusplus
-extern "C" {
-#else
-typedef int bool;
-#endif
-
-/******************************************************************************/
-/******************************** Linux Defines *******************************/
-/******************************************************************************/
-
-#if LINUX
- typedef unsigned char uchar;
-
-#if BLD_FEATURE_INT64
- __extension__ typedef long long int int64;
- __extension__ typedef unsigned long long int uint64;
- #define INT64(x) (x##LL)
- #define UINT64(x) (x##ULL)
-#endif
-
- #define closesocket(x) close(x)
- #define MPR_BINARY ""
- #define MPR_TEXT ""
- #define O_BINARY 0
- #define O_TEXT 0
- #define SOCKET_ERROR -1
- #define MPR_DLL_EXT ".so"
-
-#if BLD_FEATURE_FLOATING_POINT
- #define MAX_FLOAT MAXFLOAT
-#endif
-
-/*
- * For some reason it is removed from fedora pthreads.h and only
- * comes in for UNIX96
- */
-extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict
- __attr, int *__restrict __kind) __THROW;
-/* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,
- PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or
- PTHREAD_MUTEX_DEFAULT). */
-extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
- __THROW;
-
-#endif /* LINUX */
-
-/******************************************************************************/
-/******************************* VxWorks Defines ******************************/
-/******************************************************************************/
-
-#if VXWORKS
-
- typedef unsigned char uchar;
- typedef unsigned int uint;
- typedef unsigned long ulong;
-
- #define HAVE_SOCKLEN_T
- typedef int socklen_t;
-
-#if BLD_FEATURE_INT64
- typedef long long int int64;
- typedef unsigned long long int uint64;
- #define INT64(x) (x##LL)
- #define UINT64(x) (x##ULL)
-#endif
-
- #define closesocket(x) close(x)
- #define getpid() taskIdSelf()
- #define MPR_BINARY ""
- #define MPR_TEXT ""
- #define O_BINARY 0
- #define O_TEXT 0
- #define SOCKET_ERROR -1
- #define MPR_DLL_EXT ".so"
-
-#if BLD_FEATURE_FLOATING_POINT
- #define MAX_FLOAT FLT_MAX
-#endif
-
- #undef R_OK
- #define R_OK 4
- #undef W_OK
- #define W_OK 2
- #undef X_OK
- #define X_OK 1
- #undef F_OK
- #define F_OK 0
-
- #define MSG_NOSIGNAL 0
-
- extern int access(char *path, int mode);
- extern int sysClkRateGet();
-
-#endif /* VXWORKS */
-
-/******************************************************************************/
-/******************************** MacOsx Defines ******************************/
-/******************************************************************************/
-#if MACOSX
- typedef unsigned long ulong;
- typedef unsigned char uchar;
-
-#if BLD_FEATURE_INT64
- __extension__ typedef long long int int64;
- __extension__ typedef unsigned long long int uint64;
- #define INT64(x) (x##LL)
- #define UINT64(x) (x##ULL)
-#endif
-
- #define closesocket(x) close(x)
- #define MPR_BINARY ""
- #define MPR_TEXT ""
- #define O_BINARY 0
- #define O_TEXT 0
- #define SOCKET_ERROR -1
- #define MPR_DLL_EXT ".dylib"
- #define MSG_NOSIGNAL 0
- #define __WALL 0x40000000
- #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
-
-#if BLD_FEATURE_FLOATING_POINT
- #define MAX_FLOAT MAXFLOAT
-#endif
-
-#endif /* MACOSX */
-
-/******************************************************************************/
-/******************************* Windows Defines ******************************/
-/******************************************************************************/
-
-#if WIN
- typedef unsigned char uchar;
- typedef unsigned int uint;
- typedef unsigned long ulong;
- typedef unsigned short ushort;
-
-/*
- * We always define INT64 types on windows
- */
-#if BLD_FEATURE_INT64 || 1
- typedef __int64 int64;
- typedef unsigned __int64 uint64;
- #define INT64(x) (x##i64)
- #define UINT64(x) (x##Ui64)
-#endif
-
- typedef int uid_t;
- typedef void *handle;
- typedef char *caddr_t;
- typedef long pid_t;
- typedef int gid_t;
- typedef ushort mode_t;
- typedef void *siginfo_t;
-
- #define HAVE_SOCKLEN_T
- typedef int socklen_t;
-
- #undef R_OK
- #define R_OK 4
- #undef W_OK
- #define W_OK 2
-
- /*
- * On windows map X_OK to R_OK
- */
- #undef X_OK
- #define X_OK 4
- #undef F_OK
- #define F_OK 0
-
- #ifndef EADDRINUSE
- #define EADDRINUSE 46
- #endif
- #ifndef EWOULDBLOCK
- #define EWOULDBLOCK EAGAIN
- #endif
- #ifndef ENETDOWN
- #define ENETDOWN 43
- #endif
- #ifndef ECONNRESET
- #define ECONNRESET 44
- #endif
- #ifndef ECONNREFUSED
- #define ECONNREFUSED 45
- #endif
-
- #define MSG_NOSIGNAL 0
- #define MPR_BINARY "b"
- #define MPR_TEXT "t"
-
-#if BLD_FEATURE_FLOATING_POINT
- #define MAX_FLOAT DBL_MAX
-#endif
-
-#ifndef FILE_FLAG_FIRST_PIPE_INSTANCE
-#define FILE_FLAG_FIRST_PIPE_INSTANCE 0x00080000
-#endif
-
- #define MPR_DLL_EXT ".dll"
-#endif /* WIN */
-
-/******************************************************************************/
-/****************************** Solaris Defines *******************************/
-/******************************************************************************/
-
-#if SOLARIS
- typedef unsigned char uchar;
-
-#if BLD_FEATURE_INT64
- typedef long long int int64;
- typedef unsigned long long int uint64;
- #define INT64(x) (x##LL)
- #define UINT64(x) (x##ULL)
-#endif
-
- #define closesocket(x) close(x)
- #define MPR_BINARY ""
- #define MPR_TEXT ""
- #define O_BINARY 0
- #define O_TEXT 0
- #define SOCKET_ERROR -1
- #define MPR_DLL_EXT ".so"
- #define MSG_NOSIGNAL 0
- #define INADDR_NONE ((in_addr_t) 0xffffffff)
- #define __WALL 0
- #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
-
-#if BLD_FEATURE_FLOATING_POINT
- #define MAX_FLOAT MAXFLOAT
-#endif
-
-#endif /* SOLARIS */
-
-/******************************************************************************/
-/********************************* BREW Defines *******************************/
-/******************************************************************************/
-
-#if BREW
- typedef unsigned char uchar;
- typedef unsigned int uint;
- typedef unsigned long ulong;
- typedef unsigned short ushort;
-
- typedef uint off_t;
- typedef long pid_t;
-
-#if UNUSED
- typedef int uid_t;
- typedef void *handle;
- typedef char *caddr_t;
- typedef int gid_t;
- typedef ushort mode_t;
- typedef void *siginfo_t;
-
- #define HAVE_SOCKLEN_T
- typedef int socklen_t;
-
- #ifndef EADDRINUSE
- #define EADDRINUSE 46
- #endif
- #ifndef EWOULDBLOCK
- #define EWOULDBLOCK EAGAIN
- #endif
- #ifndef ENETDOWN
- #define ENETDOWN 43
- #endif
- #ifndef ECONNRESET
- #define ECONNRESET 44
- #endif
- #ifndef ECONNREFUSED
- #define ECONNREFUSED 45
- #endif
-
- #define MSG_NOSIGNAL 0
- #define MPR_BINARY "b"
- #define MPR_TEXT "t"
-
- #define MPR_DLL_EXT ".dll"
-#endif
-
- #define O_RDONLY 0
- #define O_WRONLY 1
- #define O_RDWR 2
- #define O_CREAT 0x200
- #define O_TRUNC 0x400
- #define O_BINARY 0
- #define O_TEXT 0x20000
- #define O_EXCL 0x40000
- #define O_APPEND 0x80000
-
- #define R_OK 4
- #define W_OK 2
- #define X_OK 1
- #define F_OK 0
-
- #define SEEK_SET 0
- #define SEEK_CUR 1
- #define SEEK_END 2
-
-#if UNUSED
-struct stat {
- uint st_size;
-};
-#endif
-
-extern int getpid();
-extern int isalnum(int c);
-extern int isalpha(int c);
-extern int isdigit(int c);
-extern int islower(int c);
-extern int isupper(int c);
-extern int isspace(int c);
-extern int isxdigit(int c);
-
-extern uint strlen(const char *str);
-extern char *strstr(const char *string, const char *strSet);
-extern void *memset(const void *dest, int c, uint count);
-extern void exit(int status);
-extern char *strpbrk(const char *str, const char *set);
-extern uint strspn(const char *str, const char *set);
-extern int tolower(int c);
-extern int toupper(int c);
-extern void *memcpy(void *dest, const void *src, uint count);
-extern void *memmove(void *dest, const void *src, uint count);
-
-extern int atoi(const char *str);
-extern void free(void *ptr);
-extern void *malloc(uint size);
-extern void *realloc(void *ptr, uint size);
-extern char *strcat(char *dest, const char *src);
-extern char *strchr(const char *str, int c);
-extern int strcmp(const char *s1, const char *s2);
-extern int strncmp(const char *s1, const char *s2, uint count);
-extern char *strcpy(char *dest, const char *src);
-extern char *strncpy(char *dest, const char *src, uint count);
-extern char *strrchr(const char *str, int c);
-
-#undef printf
-#define printf DBGPRINTF
-
-#if BREW_SIMULATOR && BLD_DEBUG
-extern _CRTIMP int __cdecl _CrtCheckMemory(void);
-extern _CRTIMP int __cdecl _CrtSetReportHook();
-#endif
-
-#endif /* BREW */
-
-/******************************************************************************/
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _h_MPR_OS_HDRS */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprPrintf.c b/source4/lib/appweb/ejs-2.0/mpr/mprPrintf.c
deleted file mode 100644
index 2d0951acfa..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/mprPrintf.c
+++ /dev/null
@@ -1,924 +0,0 @@
-/**
- * @file mprPrintf.c
- * @brief Printf routines safe for embedded programming
- * @overview This module provides safe replacements for the standard
- * printf formatting routines.
- * @remarks Most routines in this file are not thread-safe. It is the callers
- * responsibility to perform all thread synchronization.
- */
-
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/********************************** Includes **********************************/
-/*
- * We need to use the underlying str(cpy) routines to implement our safe
- * alternatives
- */
-#if !DOXYGEN
-#define UNSAFE_FUNCTIONS_OK 1
-#endif
-
-#include "mpr.h"
-
-/*********************************** Defines **********************************/
-/*
- * Class definitions
- */
-#define CLASS_NORMAL 0 /* [All other] Normal characters */
-#define CLASS_PERCENT 1 /* [%] Begin format */
-#define CLASS_MODIFIER 2 /* [-+ #,] Modifiers */
-#define CLASS_ZERO 3 /* [0] Special modifier */
-#define CLASS_STAR 4 /* [*] Width supplied by arg */
-#define CLASS_DIGIT 5 /* [1-9] Field widths */
-#define CLASS_DOT 6 /* [.] Introduce precision */
-#define CLASS_BITS 7 /* [hlL] Length bits */
-#define CLASS_TYPE 8 /* [cdfinopsSuxX] Type specifiers */
-
-#define STATE_NORMAL 0 /* Normal chars in format string */
-#define STATE_PERCENT 1 /* "%" */
-#define STATE_MODIFIER 2 /* Read flag */
-#define STATE_WIDTH 3 /* Width spec */
-#define STATE_DOT 4 /* "." */
-#define STATE_PRECISION 5 /* Precision spec */
-#define STATE_BITS 6 /* Size spec */
-#define STATE_TYPE 7 /* Data type */
-#define STATE_COUNT 8
-
-/*
- * Format: %[modifier][width][precision][bits][type]
- *
- * #define CLASS_MODIFIER 2 [-+ #,] Modifiers
- * #define CLASS_BITS 7 [hlL] Length bits
- */
-
-
-/*
- * Flags
- */
-#define SPRINTF_LEFT 0x1 /* Left align */
-#define SPRINTF_SIGN 0x2 /* Always sign the result */
-#define SPRINTF_LEAD_SPACE 0x4 /* put leading space for +ve numbers */
-#define SPRINTF_ALTERNATE 0x8 /* Alternate format */
-#define SPRINTF_LEAD_ZERO 0x10 /* Zero pad */
-#define SPRINTF_SHORT 0x20 /* 16-bit */
-#define SPRINTF_LONG 0x40 /* 32-bit */
-#if BLD_FEATURE_INT64
-#define SPRINTF_LONGLONG 0x80 /* 64-bit */
-#endif
-#define SPRINTF_COMMA 0x100 /* Thousand comma separators */
-#define SPRINTF_UPPER_CASE 0x200 /* As the name says for numbers */
-
-typedef struct Format {
- uchar *buf;
- uchar *endbuf;
- uchar *start;
- uchar *end;
- int growBy;
- int maxsize;
-
- int precision;
- int radix;
- int width;
- int flags;
- int len;
-} Format;
-
-static int growBuf(MPR_LOC_DEC(ctx, loc), Format *fmt);
-
-#define BPUT(ctx, loc, fmt, c) \
- if (1) { \
- /* Less one to allow room for the null */ \
- if ((fmt)->end >= ((fmt)->endbuf - sizeof(char))) { \
- if (growBuf(MPR_LOC_PASS(ctx, loc), fmt)) { \
- *(fmt)->end++ = (c); \
- } \
- } else { \
- *(fmt)->end++ = (c); \
- } \
- } else
-
-#define BPUTNULL(ctx, loc, fmt) \
- if (1) { \
- if ((fmt)->end > (fmt)->endbuf) { \
- if (growBuf(MPR_LOC_PASS(ctx, loc), fmt)) { \
- *(fmt)->end = '\0'; \
- } \
- } else { \
- *(fmt)->end = '\0'; \
- } \
- } else
-
-/******************************************************************************/
-
-#if BLD_FEATURE_INT64
-#define unum uint64
-#define num int64
-#else
-#define unum uint
-#define num int
-#endif
-
-/***************************** Forward Declarations ***************************/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static int getState(char c, int state);
-static int mprSprintfCore(MPR_LOC_DEC(ctx, loc), char **s,
- int maxsize, const char *fmt, va_list arg);
-static void outNum(MPR_LOC_DEC(ctx, loc), Format *fmt, const char *prefix,
- unum val);
-
-#if BLD_FEATURE_FLOATING_POINT
-static void outFloat(MPR_LOC_DEC(ctx, loc), Format *fmt, char specChar,
- double value);
-#endif
-
-/******************************************************************************/
-
-int mprPrintf(MprCtx ctx, const char *fmt, ...)
-{
- va_list ap;
- char *buf;
- int len;
- MprApp *app;
-
- /* No asserts here as this is used as part of assert reporting */
-
- app = mprGetApp(ctx);
-
- va_start(ap, fmt);
- len = mprAllocVsprintf(MPR_LOC_ARGS(ctx), &buf, 0, fmt, ap);
- va_end(ap);
- if (len >= 0 && app->console) {
- len = mprWrite(app->console, buf, len);
- }
- mprFree(buf);
-
- return len;
-}
-
-/******************************************************************************/
-
-int mprErrorPrintf(MprCtx ctx, const char *fmt, ...)
-{
- va_list ap;
- char *buf;
- int len;
- MprApp *app;
-
- /* No asserts here as this is used as part of assert reporting */
-
- app = mprGetApp(ctx);
-
- va_start(ap, fmt);
- len = mprAllocVsprintf(MPR_LOC_ARGS(ctx), &buf, 0, fmt, ap);
- va_end(ap);
- if (len >= 0 && app->error) {
- len = mprWrite(app->error, buf, len);
- }
- mprFree(buf);
-
- return len;
-}
-
-/******************************************************************************/
-
-int mprFprintf(MprFile *file, const char *fmt, ...)
-{
- va_list ap;
- char *buf;
- int len;
-
- if (file == 0) {
- return MPR_ERR_BAD_HANDLE;
- }
-
- va_start(ap, fmt);
- len = mprAllocVsprintf(MPR_LOC_ARGS(file), &buf, 0, fmt, ap);
- va_end(ap);
-
- if (len >= 0) {
- len = mprWrite(file, buf, len);
- }
- mprFree(buf);
- return len;
-}
-
-/******************************************************************************/
-/*
- * Printf with a static buffer. Used internally only. WILL NOT MALLOC.
- */
-
-int mprStaticPrintf(MprCtx ctx, const char *fmt, ...)
-{
- va_list ap;
- char buf[MPR_MAX_STRING];
- char *bufp;
- int len;
- MprApp *app;
-
- app = mprGetApp(ctx);
-
- va_start(ap, fmt);
- bufp = buf;
- len = mprSprintfCore(MPR_LOC_ARGS(0), &bufp, MPR_MAX_STRING, fmt, ap);
- va_end(ap);
- if (len >= 0) {
- len = mprWrite(app->console, buf, len);
- }
- return len;
-}
-
-/******************************************************************************/
-
-int mprSprintf(char *buf, int n, const char *fmt, ...)
-{
- va_list ap;
- int result;
-
- mprAssert(buf);
- mprAssert(fmt);
- mprAssert(n > 0);
-
- va_start(ap, fmt);
- result = mprSprintfCore(MPR_LOC_ARGS(0), &buf, n, fmt, ap);
- va_end(ap);
- return result;
-}
-
-/******************************************************************************/
-
-int mprVsprintf(char *buf, int n, const char *fmt, va_list arg)
-{
- mprAssert(buf);
- mprAssert(fmt);
- mprAssert(n > 0);
-
- return mprSprintfCore(MPR_LOC_ARGS(0), &buf, n, fmt, arg);
-}
-
-/******************************************************************************/
-
-int mprAllocSprintf(MPR_LOC_DEC(ctx, loc), char **buf, int maxSize,
- const char *fmt, ...)
-{
- va_list ap;
- int result;
-
- mprAssert(buf);
- mprAssert(fmt);
-
- *buf = 0;
- va_start(ap, fmt);
- result = mprSprintfCore(MPR_LOC_PASS(ctx, loc), buf, maxSize, fmt, ap);
- va_end(ap);
- return result;
-}
-
-/******************************************************************************/
-
-int mprAllocVsprintf(MPR_LOC_DEC(ctx, loc), char **buf, int maxSize,
- const char *fmt, va_list arg)
-{
- mprAssert(buf);
- mprAssert(fmt);
-
- *buf = 0;
- return mprSprintfCore(MPR_LOC_PASS(ctx, loc), buf, maxSize, fmt, arg);
-}
-
-/******************************************************************************/
-
-static int getState(char c, int state)
-{
- /*
- * Declared here to remove all static / globals
- * FUTURE OPT -- need to measure this. Could be slow on BREW.
- */
-
- char stateMap[] = {
- /* STATES: Normal Percent Modifier Width Dot Prec Bits Type */
- /* CLASS 0 1 2 3 4 5 6 7 */
- /* Normal 0 */ 0, 0, 0, 0, 0, 0, 0, 0,
- /* Percent 1 */ 1, 0, 1, 1, 1, 1, 1, 1,
- /* Modifier 2 */ 0, 2, 2, 0, 0, 0, 0, 0,
- /* Zero 3 */ 0, 2, 2, 3, 0, 5, 0, 0,
- /* Star 4 */ 0, 3, 3, 0, 5, 0, 0, 0,
- /* Digit 5 */ 0, 3, 3, 3, 5, 5, 0, 0,
- /* Dot 6 */ 0, 4, 4, 4, 0, 0, 0, 0,
- /* Bits 7 */ 0, 6, 6, 6, 6, 6, 6, 0,
- /* Types 8 */ 0, 7, 7, 7, 7, 7, 7, 0,
- };
-
- /*
- * Format: %[modifier][width][precision][bits][type]
- */
- char classMap[] = {
- /* 0 ' ' ! " # $ % & ' */
- 2, 0, 0, 2, 0, 1, 0, 0,
- /* 07 ( ) * + , - . / */
- 0, 0, 4, 2, 2, 2, 6, 0,
- /* 10 0 1 2 3 4 5 6 7 */
- 3, 5, 5, 5, 5, 5, 5, 5,
- /* 17 8 9 : ; < = > ? */
- 5, 5, 0, 0, 0, 0, 0, 0,
- /* 20 @ A B C D E F G */
- 0, 0, 0, 0, 0, 0, 0, 0,
- /* 27 H I J K L M N O */
- 0, 0, 0, 0, 7, 0, 0, 0,
- /* 30 P Q R S T U V W */
- 0, 0, 0, 8, 0, 0, 0, 0,
- /* 37 X Y Z [ \ ] ^ _ */
- 8, 0, 0, 0, 0, 0, 0, 0,
- /* 40 ' a b c d e f g */
- 0, 0, 0, 8, 8, 0, 8, 0,
- /* 47 h i j k l m n o */
- 7, 8, 0, 0, 7, 0, 8, 8,
- /* 50 p q r s t u v w */
- 8, 0, 0, 8, 0, 8, 0, 0,
- /* 57 x y z */
- 8, 0, 0,
- };
-
- int chrClass;
-
- if (c < ' ' || c > 'z') {
- chrClass = CLASS_NORMAL;
- } else {
- mprAssert((c - ' ') < (int) sizeof(classMap));
- chrClass = classMap[(c - ' ')];
- }
- mprAssert((chrClass * STATE_COUNT + state) < (int) sizeof(stateMap));
- state = stateMap[chrClass * STATE_COUNT + state];
- return state;
-}
-
-/******************************************************************************/
-
-static int mprSprintfCore(MPR_LOC_DEC(ctx, loc), char **bufPtr,
- int maxsize, const char *spec, va_list arg)
-{
- Format fmt;
- char *cp;
- char c;
- char *sValue;
- num iValue;
- unum uValue;
- int count, i, len, state;
-
- mprAssert(bufPtr);
- mprAssert(spec);
-
- if (*bufPtr != 0) {
- mprAssert(maxsize > 0);
- fmt.buf = (uchar*) *bufPtr;
- fmt.endbuf = &fmt.buf[maxsize];
- fmt.growBy = 0;
- } else {
- if (maxsize <= 0) {
- maxsize = MAXINT;
- }
-
- len = min(MPR_DEFAULT_ALLOC, maxsize);
- fmt.buf = (uchar*) mprAllocBlock(MPR_LOC_PASS(ctx, loc), len);
- fmt.endbuf = &fmt.buf[len];
- fmt.growBy = MPR_DEFAULT_ALLOC * 2;
- }
-
- fmt.maxsize = maxsize;
- fmt.start = fmt.buf;
- fmt.end = fmt.buf;
- fmt.len = 0;
- *fmt.start = '\0';
-
- state = STATE_NORMAL;
-
- while ((c = *spec++) != '\0') {
- state = getState(c, state);
-
- switch (state) {
- case STATE_NORMAL:
- BPUT(ctx, loc, &fmt, c);
- break;
-
- case STATE_PERCENT:
- fmt.precision = -1;
- fmt.width = 0;
- fmt.flags = 0;
- break;
-
- case STATE_MODIFIER:
- switch (c) {
- case '+':
- fmt.flags |= SPRINTF_SIGN;
- break;
- case '-':
- fmt.flags |= SPRINTF_LEFT;
- break;
- case '#':
- fmt.flags |= SPRINTF_ALTERNATE;
- break;
- case '0':
- fmt.flags |= SPRINTF_LEAD_ZERO;
- break;
- case ' ':
- fmt.flags |= SPRINTF_LEAD_SPACE;
- break;
- case ',':
- fmt.flags |= SPRINTF_COMMA;
- break;
- }
- break;
-
- case STATE_WIDTH:
- if (c == '*') {
- fmt.width = va_arg(arg, int);
- if (fmt.width < 0) {
- fmt.width = -fmt.width;
- fmt.flags |= SPRINTF_LEFT;
- }
- } else {
- while (isdigit((int)c)) {
- fmt.width = fmt.width * 10 + (c - '0');
- c = *spec++;
- }
- spec--;
- }
- break;
-
- case STATE_DOT:
- fmt.precision = 0;
- fmt.flags &= ~SPRINTF_LEAD_ZERO;
- break;
-
- case STATE_PRECISION:
- if (c == '*') {
- fmt.precision = va_arg(arg, int);
- } else {
- while (isdigit((int) c)) {
- fmt.precision = fmt.precision * 10 + (c - '0');
- c = *spec++;
- }
- spec--;
- }
- break;
-
- case STATE_BITS:
- switch (c) {
-#if BLD_FEATURE_INT64
- case 'L':
- fmt.flags |= SPRINTF_LONGLONG; /* 64 bit */
- break;
-#endif
-
- case 'l':
- fmt.flags |= SPRINTF_LONG;
- break;
-
- case 'h':
- fmt.flags |= SPRINTF_SHORT;
- break;
- }
- break;
-
- case STATE_TYPE:
- switch (c) {
-#if BLD_FEATURE_FLOATING_POINT
- case 'e':
- case 'g':
- case 'f':
- fmt.radix = 10;
- outFloat(MPR_LOC_PASS(ctx, loc), &fmt, c,
- (double) va_arg(arg, double));
- break;
-#endif
- case 'c':
- BPUT(ctx, loc, &fmt, (char) va_arg(arg, int));
- break;
-
- case 's':
- case 'S':
- sValue = va_arg(arg, char*);
- if (sValue == 0) {
- sValue = "null";
- len = strlen(sValue);
- } else if (fmt.flags & SPRINTF_ALTERNATE) {
- sValue++;
- len = (int) *sValue;
- } else if (fmt.precision >= 0) {
- /*
- * Can't use strlen(), the string may not have a null
- */
- cp = sValue;
- for (len = 0; len < fmt.precision; len++) {
- if (*cp++ == '\0') {
- break;
- }
- }
- } else {
- len = strlen(sValue);
- }
- if (!(fmt.flags & SPRINTF_LEFT)) {
- for (i = len; i < fmt.width; i++) {
- BPUT(ctx, loc, &fmt, (char) ' ');
- }
- }
- for (i = 0; i < len && *sValue; i++) {
- BPUT(ctx, loc, &fmt, *sValue++);
- }
- if (fmt.flags & SPRINTF_LEFT) {
- for (i = len; i < fmt.width; i++) {
- BPUT(ctx, loc, &fmt, (char) ' ');
- }
- }
- break;
-
- case 'i':
- ;
- case 'd':
- fmt.radix = 10;
- if (fmt.flags & SPRINTF_SHORT) {
- iValue = (short) va_arg(arg, int);
- } else if (fmt.flags & SPRINTF_LONG) {
- iValue = va_arg(arg, long);
-#if BLD_FEATURE_INT64
- } else if (fmt.flags & SPRINTF_LONGLONG) {
- iValue = va_arg(arg, num);
-#endif
- } else {
- iValue = va_arg(arg, int);
- }
- if (iValue >= 0) {
- if (fmt.flags & SPRINTF_LEAD_SPACE) {
- outNum(MPR_LOC_PASS(ctx, loc), &fmt, " ", iValue);
- } else if (fmt.flags & SPRINTF_SIGN) {
- outNum(MPR_LOC_PASS(ctx, loc), &fmt, "+", iValue);
- } else {
- outNum(MPR_LOC_PASS(ctx, loc), &fmt, 0, iValue);
- }
- } else {
- outNum(MPR_LOC_PASS(ctx, loc), &fmt, "-", -iValue);
- }
- break;
-
- case 'X':
- fmt.flags |= SPRINTF_UPPER_CASE;
- /* Fall through */
- case 'o':
- case 'x':
- case 'u':
- if (fmt.flags & SPRINTF_SHORT) {
- uValue = (ushort) va_arg(arg, uint);
- } else if (fmt.flags & SPRINTF_LONG) {
- uValue = va_arg(arg, ulong);
-#if BLD_FEATURE_INT64
- } else if (fmt.flags & SPRINTF_LONGLONG) {
- uValue = va_arg(arg, unum);
-#endif
- } else {
- uValue = va_arg(arg, uint);
- }
- if (c == 'u') {
- fmt.radix = 10;
- outNum(MPR_LOC_PASS(ctx, loc), &fmt, 0, uValue);
- } else if (c == 'o') {
- fmt.radix = 8;
- if (fmt.flags & SPRINTF_ALTERNATE && uValue != 0) {
- outNum(MPR_LOC_PASS(ctx, loc), &fmt, "0", uValue);
- } else {
- outNum(MPR_LOC_PASS(ctx, loc), &fmt, 0, uValue);
- }
- } else {
- fmt.radix = 16;
- if (fmt.flags & SPRINTF_ALTERNATE && uValue != 0) {
- if (c == 'X') {
- outNum(MPR_LOC_PASS(ctx, loc), &fmt, "0X", uValue);
- } else {
- outNum(MPR_LOC_PASS(ctx, loc), &fmt, "0x", uValue);
- }
- } else {
- outNum(MPR_LOC_PASS(ctx, loc), &fmt, 0, uValue);
- }
- }
- break;
-
- case 'n': /* Count of chars seen thus far */
- if (fmt.flags & SPRINTF_SHORT) {
- short *count = va_arg(arg, short*);
- *count = fmt.end - fmt.start;
- } else if (fmt.flags & SPRINTF_LONG) {
- long *count = va_arg(arg, long*);
- *count = fmt.end - fmt.start;
- } else {
- int *count = va_arg(arg, int *);
- *count = fmt.end - fmt.start;
- }
- break;
-
- case 'p': /* Pointer */
-#if __WORDSIZE == 64 && BLD_FEATURE_INT64
- uValue = (unum) va_arg(arg, void*);
-#else
- uValue = (uint) (int) va_arg(arg, void*);
-#endif
- fmt.radix = 16;
- outNum(MPR_LOC_PASS(ctx, loc), &fmt, "0x", uValue);
- break;
-
- default:
- BPUT(ctx, loc, &fmt, c);
- }
- }
- }
- BPUTNULL(ctx, loc, &fmt);
-
- count = fmt.end - fmt.start;
- if (*bufPtr == 0) {
- *bufPtr = (char*) fmt.buf;
- }
- return count;
-}
-
-/******************************************************************************/
-/*
- * Output a number according to the given format. If BLD_FEATURE_INT64 is
- * defined, then uses 64 bits universally. Slower but smaller code.
- */
-
-static void outNum(MPR_LOC_DEC(ctx, loc), Format *fmt, const char *prefix,
- unum value)
-{
- char numBuf[64];
- char *cp;
- char *endp;
- char c;
- int letter, len, leadingZeros, i, fill;
-
- endp = &numBuf[sizeof(numBuf) - 1];
- *endp = '\0';
- cp = endp;
-
- /*
- * Convert to ascii
- */
- if (fmt->radix == 16) {
- do {
- letter = (int) (value % fmt->radix);
- if (letter > 9) {
- if (fmt->flags & SPRINTF_UPPER_CASE) {
- letter = 'A' + letter - 10;
- } else {
- letter = 'a' + letter - 10;
- }
- } else {
- letter += '0';
- }
- *--cp = letter;
- value /= fmt->radix;
- } while (value > 0);
-
- } else if (fmt->flags & SPRINTF_COMMA) {
- i = 1;
- do {
- *--cp = '0' + (int) (value % fmt->radix);
- value /= fmt->radix;
- if ((i++ % 3) == 0 && value > 0) {
- *--cp = ',';
- }
- } while (value > 0);
- } else {
- do {
- *--cp = '0' + (int) (value % fmt->radix);
- value /= fmt->radix;
- } while (value > 0);
- }
-
- len = endp - cp;
- fill = fmt->width - len;
-
- if (prefix != 0) {
- fill -= strlen(prefix);
- }
- leadingZeros = (fmt->precision > len) ? fmt->precision - len : 0;
- fill -= leadingZeros;
-
- if (!(fmt->flags & SPRINTF_LEFT)) {
- c = (fmt->flags & SPRINTF_LEAD_ZERO) ? '0': ' ';
- for (i = 0; i < fill; i++) {
- BPUT(ctx, loc, fmt, c);
- }
- }
- if (prefix != 0) {
- while (*prefix) {
- BPUT(ctx, loc, fmt, *prefix++);
- }
- }
- for (i = 0; i < leadingZeros; i++) {
- BPUT(ctx, loc, fmt, '0');
- }
- while (*cp) {
- BPUT(ctx, loc, fmt, *cp);
- cp++;
- }
- if (fmt->flags & SPRINTF_LEFT) {
- for (i = 0; i < fill; i++) {
- BPUT(ctx, loc, fmt, ' ');
- }
- }
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_FLOATING_POINT
-/*
- * Output a floating point number
- */
-
-static void outFloat(MPR_LOC_DEC(ctx, loc), Format *fmt, char specChar,
- double value)
-{
- char *cp;
-#if FUTURE
- char numBuf[64];
- char *endp;
- char c;
- int letter, len, leadingZeros, i, fill, width, precision;
-
- endp = &numBuf[sizeof(numBuf) - 1];
- *endp = '\0';
-
- precision = fmt->precision;
- if (precision < 0) {
- precision = 6;
- } else if (precision > (sizeof(numBuf) - 1)) {
- precision = (sizeof(numBuf) - 1);
- }
- width = min(fmt->width, sizeof(numBuf) - 1);
-
- if (__isnanl(value)) {
- "nan"
- } else if (__isinfl(value)) {
- "infinity"
- } else if (value < 0) {
- prefix = "-";
- } else if (fmt.flags & SPRINTF_LEAD_SPACE) {
- prefix = " ";
- } else if (fmt.flags & SPRINTF_SIGN) {
- prefix = "+";
- }
-
-
- /*
- * Do the exponent part
- */
- cp = &numBuf[sizeof(numBuf) - precision];
- for (i = 0; i < precision; i++) {
- *cp++ = '0' + (int) (value % fmt->radix);
- value /= fmt->radix;
- }
-
- /*
- * Do the decimal part
- */
- if (fmt->flags & SPRINTF_COMMA) {
- i = 1;
- do {
- *--cp = '0' + (int) (value % fmt->radix);
- value /= fmt->radix;
- if ((i++ % 3) == 0 && value > 0) {
- *--cp = ',';
- }
- } while (value >= 1.0);
-
- } else {
- do {
- *--cp = '0' + (int) (value % fmt->radix);
- value /= fmt->radix;
- } while (value > 1.0);
- }
-
- len = endp - cp;
- fill = fmt->width - len;
-
- if (prefix != 0) {
- fill -= strlen(prefix);
- }
-
- leadingZeros = (fmt->precision > len) ? fmt->precision - len : 0;
- fill -= leadingZeros;
-
- if (!(fmt->flags & SPRINTF_LEFT)) {
- c = (fmt->flags & SPRINTF_LEAD_ZERO) ? '0': ' ';
- for (i = 0; i < fill; i++) {
- BPUT(ctx, loc, fmt, c);
- }
- }
- if (prefix != 0) {
- BPUT(ctx, loc, fmt, prefix);
- }
- for (i = 0; i < leadingZeros; i++) {
- BPUT(ctx, loc, fmt, '0');
- }
- BPUT(ctx, loc, fmt, cp);
- if (fmt->flags & SPRINTF_LEFT) {
- for (i = 0; i < fill; i++) {
- BPUT(ctx, loc, fmt, ' ');
- }
- }
-#else
- char numBuf[64];
- if (specChar == 'f') {
- sprintf(numBuf, "%*.*f", fmt->width, fmt->precision, value);
- } else if (specChar == 'g') {
- sprintf(numBuf, "%*.*g", fmt->width, fmt->precision, value);
- } else if (specChar == 'e') {
- sprintf(numBuf, "%*.*e", fmt->width, fmt->precision, value);
- }
- for (cp = numBuf; *cp; cp++) {
- BPUT(ctx, loc, fmt, *cp);
- }
-#endif
-}
-
-#endif /* BLD_FEATURE_FLOATING_POINT */
-/******************************************************************************/
-/*
- * Grow the buffer to fit new data. Return 1 if the buffer can grow.
- * Grow using the growBy size specified when creating the buffer.
- */
-
-static int growBuf(MPR_LOC_DEC(ctx, loc), Format *fmt)
-{
- uchar *newbuf;
- int buflen;
-
- buflen = fmt->endbuf - fmt->buf;
- if (fmt->maxsize >= 0 && buflen >= fmt->maxsize) {
- return 0;
- }
- if (fmt->growBy < 0) {
- /*
- * User supplied buffer
- */
- return 0;
- }
-
- newbuf = (uchar*) mprAlloc(ctx, buflen + fmt->growBy);
- if (fmt->buf) {
- memcpy(newbuf, fmt->buf, buflen);
- mprFree(fmt->buf);
- }
-
- buflen += fmt->growBy;
- fmt->end = newbuf + (fmt->end - fmt->buf);
- fmt->start = newbuf + (fmt->start - fmt->buf);
- fmt->buf = newbuf;
- fmt->endbuf = &fmt->buf[buflen];
-
- /*
- * Increase growBy to reduce overhead
- */
- if ((buflen + (fmt->growBy * 2)) < fmt->maxsize) {
- fmt->growBy *= 2;
- }
- return 1;
-}
-
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprString.c b/source4/lib/appweb/ejs-2.0/mpr/mprString.c
deleted file mode 100644
index d39fc8b746..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/mprString.c
+++ /dev/null
@@ -1,733 +0,0 @@
-/**
- * @file mprString.c
- * @brief String routines safe for embedded programming
- * @overview This module provides safe replacements for the standard
- * string library.
- * @remarks Most routines in this file are not thread-safe. It is the callers
- * responsibility to perform all thread synchronization.
- */
-
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-#include "mpr.h"
-
-/********************************** Includes **********************************/
-/*
- * We need to use the underlying str(cpy) routines to implement our safe
- * alternatives
- */
-#if !DOXYGEN
-#define UNSAFE_FUNCTIONS_OK 1
-#endif
-
-/******************************************************************************/
-/**************************** Safe String Handling ****************************/
-/******************************************************************************/
-
-int mprStrcpy(char *dest, int destMax, const char *src)
-{
- int len;
-
- mprAssert(dest);
- mprAssert(destMax >= 0);
- mprAssert(src);
-
- len = strlen(src);
- if (destMax > 0 && len >= destMax && len > 0) {
- return MPR_ERR_WONT_FIT;
- }
- if (len > 0) {
- memcpy(dest, src, len);
- dest[len] = '\0';
- } else {
- *dest = '\0';
- len = 0;
- }
- return len;
-}
-
-/******************************************************************************/
-
-int mprAllocStrcpy(MPR_LOC_DEC(ctx, loc), char **dest, int destMax,
- const char *src)
-{
- int len;
-
- mprAssert(dest);
- mprAssert(destMax >= 0);
- mprAssert(src);
-
- len = strlen(src);
- if (destMax > 0 && len >= destMax) {
- mprAssert(0);
- return MPR_ERR_WONT_FIT;
- }
- if (len > 0) {
- *dest = (char*) mprAllocBlock(MPR_LOC_PASS(ctx, loc), len);
- memcpy(*dest, src, len);
- (*dest)[len] = '\0';
- } else {
- *dest = (char*) mprAlloc(ctx, 1);
- *dest = '\0';
- len = 0;
- }
- return len;
-}
-
-/******************************************************************************/
-
-int mprMemcpy(char *dest, int destMax, const char *src, int nbytes)
-{
- mprAssert(dest);
- mprAssert(destMax <= 0 || destMax >= nbytes);
- mprAssert(src);
- mprAssert(nbytes >= 0);
-
- if (destMax > 0 && nbytes > destMax) {
- mprAssert(0);
- return MPR_ERR_WONT_FIT;
- }
- if (nbytes > 0) {
- memcpy(dest, src, nbytes);
- return nbytes;
- } else {
- return 0;
- }
-}
-
-/******************************************************************************/
-
-int mprAllocMemcpy(MPR_LOC_DEC(ctx, loc), char **dest, int destMax,
- const void *src, int nbytes)
-{
- mprAssert(dest);
- mprAssert(src);
- mprAssert(nbytes > 0);
- mprAssert(destMax <= 0 || destMax >= nbytes);
-
- if (destMax > 0 && nbytes > destMax) {
- mprAssert(0);
- return MPR_ERR_WONT_FIT;
- }
- if (nbytes > 0) {
- *dest = (char*) mprAllocBlock(MPR_LOC_PASS(ctx,loc), nbytes);
- if (*dest == 0) {
- return MPR_ERR_MEMORY;
- }
- memcpy(*dest, src, nbytes);
- } else {
- *dest = (char*) mprAlloc(ctx, 1);
- }
- return nbytes;
-}
-
-/******************************************************************************/
-
-static int mprCoreStrcat(MPR_LOC_DEC(ctx, loc), char **destp, int destMax,
- int existingLen, const char *delim, const char *src, va_list args)
-{
- va_list ap;
- char *dest, *str, *dp;
- int sepLen, addBytes, required;
-
- mprAssert(destp);
- mprAssert(destMax >= 0);
- mprAssert(src);
-
- dest = *destp;
- sepLen = (delim) ? strlen(delim) : 0;
-
-#ifdef __va_copy
- __va_copy(ap, args);
-#else
- ap = args;
-#endif
- addBytes = 0;
- if (existingLen > 0) {
- addBytes += sepLen;
- }
- str = (char*) src;
-
- while (str) {
- addBytes += strlen(str);
- str = va_arg(ap, char*);
- if (str) {
- addBytes += sepLen;
- }
- }
-
- required = existingLen + addBytes + 1;
- if (destMax > 0 && required >= destMax) {
- mprAssert(0);
- return MPR_ERR_WONT_FIT;
- }
-
- if (ctx != 0) {
- if (dest == 0) {
- dest = (char*) mprAllocBlock(MPR_LOC_PASS(ctx, loc), required);
- } else {
- dest = (char*) mprReallocBlock(MPR_LOC_PASS(ctx, loc), dest,
- required);
- }
- } else {
- dest = (char*) *destp;
- }
-
- dp = &dest[existingLen];
- if (delim && existingLen > 0) {
- strcpy(dp, delim);
- dp += sepLen;
- }
-
- if (addBytes > 0) {
-#ifdef __va_copy
- __va_copy(ap, args);
-#else
- ap = args;
-#endif
- str = (char*) src;
- while (str) {
- strcpy(dp, str);
- dp += strlen(str);
- str = va_arg(ap, char*);
- if (delim && str) {
- strcpy(dp, delim);
- dp += sepLen;
- }
- }
- } else if (dest == 0) {
- dest = (char*) mprAlloc(ctx, 1);
- }
- *dp = '\0';
-
- *destp = dest;
- mprAssert(dp < &dest[required]);
- return required - 1;
-}
-
-/*****************************************************************************
- Note that this VARARGS function must be NULL (not 0, this must be a
- pointer) terminated
-*/
-int mprStrcat(char *dest, int destMax, const char *delim, const char *src, ...)
-{
- va_list ap;
- int rc;
-
- mprAssert(dest);
- mprAssert(src);
-
- va_start(ap, src);
- rc = mprCoreStrcat(MPR_LOC_ARGS(0), &dest, destMax, strlen(dest),
- delim, src, ap);
- va_end(ap);
- return rc;
-}
-
-/*****************************************************************************
- Note that this VARARGS function must be NULL (not 0, this must be a
- pointer) terminated
-*/
-int mprAllocStrcat(MPR_LOC_DEC(ctx, loc), char **destp, int destMax,
- const char *delim, const char *src, ...)
-{
- va_list ap;
- int rc;
-
- mprAssert(destp);
- mprAssert(src);
-
- *destp = 0;
- va_start(ap, src);
- rc = mprCoreStrcat(MPR_LOC_PASS(ctx, loc), destp, destMax, 0, delim,
- src, ap);
- va_end(ap);
- return rc;
-}
-
-/*****************************************************************************
- Note that this VARARGS function must be NULL (not 0, this must be a
- pointer) terminated
-*/
-int mprReallocStrcat(MPR_LOC_DEC(ctx, loc), char **destp, int destMax,
- int existingLen, const char *delim, const char *src,...)
-{
- va_list ap;
- int rc;
-
- va_start(ap, src);
- rc = mprCoreStrcat(MPR_LOC_PASS(ctx, loc), destp, destMax, existingLen,
- delim, src, ap);
- va_end(ap);
- return rc;
-}
-
-/******************************************************************************/
-
-int mprStrlen(const char *src, int max)
-{
- int len;
-
- len = strlen(src);
- if (len >= max) {
- mprAssert(0);
- return MPR_ERR_WONT_FIT;
- }
- return len;
-}
-
-/******************************************************************************/
-
-char *mprStrTrim(char *str, const char *set)
-{
- int len, i;
-
- if (str == 0 || set == 0) {
- return str;
- }
-
- i = strspn(str, set);
- str += i;
-
- len = strlen(str);
- while (strspn(&str[len - 1], set) > 0) {
- str[len - 1] = '\0';
- len--;
- }
- return str;
-}
-
-/******************************************************************************/
-/*
- * Map a string to lower case (overwrites original string)
- */
-
-char *mprStrLower(char *str)
-{
- char *cp;
-
- mprAssert(str);
-
- if (str == 0) {
- return 0;
- }
-
- for (cp = str; *cp; cp++) {
- if (isupper(*cp)) {
- *cp = (char) tolower(*cp);
- }
- }
- return str;
-}
-
-/******************************************************************************/
-/*
- * Map a string to upper case (overwrites buffer)
- */
-
-char *mprStrUpper(char *str)
-{
- char *cp;
-
- mprAssert(str);
- if (str == 0) {
- return 0;
- }
-
- for (cp = str; *cp; cp++) {
- if (islower(*cp)) {
- *cp = (char) toupper(*cp);
- }
- }
- return str;
-}
-
-/******************************************************************************/
-/*
- * Case insensitive string comparison. Stop at the end of str1.
- */
-
-int mprStrcmpAnyCase(const char *str1, const char *str2)
-{
- int rc;
-
- if (str1 == 0 || str2 == 0) {
- return -1;
- }
- if (str1 == str2) {
- return 0;
- }
-
- for (rc = 0; *str1 && rc == 0; str1++, str2++) {
- rc = tolower(*str1) - tolower(*str2);
- }
- if (*str2) {
- return -1;
- }
- return rc;
-}
-
-/******************************************************************************/
-/*
- * Case insensitive string comparison. Limited by length
- */
-
-int mprStrcmpAnyCaseCount(const char *str1, const char *str2, int len)
-{
- int rc;
-
- if (str1 == 0 || str2 == 0) {
- return -1;
- }
- if (str1 == str2) {
- return 0;
- }
-
- for (rc = 0; len-- > 0 && *str1 && rc == 0; str1++, str2++) {
- rc = tolower(*str1) - tolower(*str2);
- }
- return rc;
-}
-
-/******************************************************************************/
-/*
- * Return the last portion of a pathname
- */
-
-const char *mprGetBaseName(const char *name)
-{
- char *cp;
-
- cp = strrchr(name, '/');
-
- if (cp == 0) {
- cp = strrchr(name, '\\');
- if (cp == 0) {
- return name;
- }
- }
- if (cp == name) {
- if (cp[1] == '\0') {
- return name;
- }
- } else {
- if (cp[1] == '\0') {
- return "";
- }
- }
- return &cp[1];
-}
-
-/******************************************************************************/
-/*
- * Return the directory portion of a pathname into the users buffer.
- */
-
-char *mprGetDirName(char *buf, int bufsize, const char *path)
-{
- char *cp;
- int dlen;
-
- mprAssert(path);
- mprAssert(buf);
- mprAssert(bufsize > 0);
-
- cp = strrchr(path, '/');
- if (cp == 0) {
-#if WIN
- cp = strrchr(path, '\\');
- if (cp == 0)
-#endif
- {
- buf[0] = '\0';
- return buf;
- }
- }
-
- if (cp == path && cp[1] == '\0') {
- strcpy(buf, ".");
- return buf;
- }
-
- dlen = cp - path;
- if (dlen < bufsize) {
- if (dlen == 0) {
- dlen++;
- }
- mprMemcpy(buf, bufsize, path, dlen);
- buf[dlen] = '\0';
- return buf;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Thread-safe wrapping of strtok. Note "str" is modifed as per strtok()
- */
-
-char *mprStrTok(char *str, const char *delim, char **last)
-{
- char *start, *end;
- int i;
-
- start = str ? str : *last;
-
- if (start == 0) {
- return 0;
- }
-
- i = strspn(start, delim);
- start += i;
- if (*start == '\0') {
- *last = 0;
- return 0;
- }
- end = strpbrk(start, delim);
- if (end) {
- *end++ = '\0';
- i = strspn(end, delim);
- end += i;
- }
- *last = end;
- return start;
-}
-
-/******************************************************************************/
-/*
- * Split the buffer into word tokens
- */
-
-char *mprGetWordTok(char *buf, int bufsize, const char *str, const char *delim,
- const char **tok)
-{
- const char *start, *end;
- int i, len;
-
- start = str ? str : *tok;
-
- if (start == 0) {
- return 0;
- }
-
- i = strspn(start, delim);
- start += i;
- if (*start =='\0') {
- *tok = 0;
- return 0;
- }
- end = strpbrk(start, delim);
- if (end) {
- len = min(end - start, bufsize - 1);
- mprMemcpy(buf, bufsize, start, len);
- buf[len] = '\0';
- } else {
- if (mprStrcpy(buf, bufsize, start) < 0) {
- buf[bufsize - 1] = '\0';
- return 0;
- }
- buf[bufsize - 1] = '\0';
- }
- *tok = end;
- return buf;
-}
-
-/******************************************************************************/
-/*
- * Format a number as a string.
- */
-
-char *mprItoa(char *buf, int size, int value)
-{
- char numBuf[16];
- char *cp, *dp, *endp;
- int negative;
-
- cp = &numBuf[sizeof(numBuf)];
- *--cp = '\0';
-
- if (value < 0) {
- negative = 1;
- value = -value;
- size--;
- } else {
- negative = 0;
- }
-
- do {
- *--cp = '0' + (value % 10);
- value /= 10;
- } while (value > 0);
-
- if (negative) {
- *--cp = '-';
- }
-
- dp = buf;
- endp = &buf[size];
- while (dp < endp && *cp) {
- *dp++ = *cp++;
- }
- *dp++ = '\0';
- return buf;
-}
-
-/******************************************************************************/
-/*
- * Parse an ascii number. Supports radix 10 or 16.
- */
-
-int mprAtoi(const char *str, int radix)
-{
- int c, val, negative;
-
- mprAssert(radix == 10 || radix == 16);
-
- if (str == 0) {
- return 0;
- }
-
- val = 0;
- if (radix == 10 && *str == '-') {
- negative = 1;
- str++;
- } else {
- negative = 0;
- }
-
- if (radix == 10) {
- while (*str && isdigit(*str)) {
- val = (val * radix) + *str - '0';
- str++;
- }
- } else if (radix == 16) {
- if (*str == '0' && tolower(str[1]) == 'x') {
- str += 2;
- }
- while (*str) {
- c = tolower(*str);
- if (isdigit(c)) {
- val = (val * radix) + c - '0';
- } else if (c >= 'a' && c <= 'f') {
- val = (val * radix) + c - 'a' + 10;
- } else {
- break;
- }
- str++;
- }
- }
-
- return (negative) ? -val: val;
-}
-
-/******************************************************************************/
-/*
- * Make an argv array. Caller must free by calling mprFree(argv) to free
- * everything.
- */
-
-int mprMakeArgv(MprCtx ctx, const char *program, const char *cmd,
- char ***argvp, int *argcp)
-{
- char *cp, **argv, *buf, *args;
- int size, argc;
-
- /*
- * Allocate one buffer for argv and the actual args themselves
- */
- size = strlen(cmd) + 1;
-
- buf = (char*) mprAlloc(ctx, (MPR_MAX_ARGC * sizeof(char*)) + size);
- if (buf == 0) {
- return MPR_ERR_MEMORY;
- }
-
- args = &buf[MPR_MAX_ARGC * sizeof(char*)];
- strcpy(args, cmd);
- argv = (char**) buf;
-
- argc = 0;
- if (program) {
- argv[argc++] = (char*) mprStrdup(ctx, program);
- }
-
- for (cp = args; cp && *cp != '\0'; argc++) {
- if (argc >= MPR_MAX_ARGC) {
- mprAssert(argc < MPR_MAX_ARGC);
- mprFree(buf);
- *argvp = 0;
- if (argcp) {
- *argcp = 0;
- }
- return MPR_ERR_TOO_MANY;
- }
- while (isspace(*cp)) {
- cp++;
- }
- if (*cp == '\0') {
- break;
- }
- if (*cp == '"') {
- cp++;
- argv[argc] = cp;
- while ((*cp != '\0') && (*cp != '"')) {
- cp++;
- }
- } else {
- argv[argc] = cp;
- while (*cp != '\0' && !isspace(*cp)) {
- cp++;
- }
- }
- if (*cp != '\0') {
- *cp++ = '\0';
- }
- }
- argv[argc] = 0;
-
- if (argcp) {
- *argcp = argc;
- }
- *argvp = argv;
-
- return argc;
-}
-
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprSymbol.c b/source4/lib/appweb/ejs-2.0/mpr/mprSymbol.c
deleted file mode 100644
index 11ac278db4..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/mprSymbol.c
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * @file mprSym.cpp
- * @brief Fast hashing symbol table lookup module
- * @overview This symbol table uses a fast key lookup mechanism. Keys are
- * strings and the value entries are arbitrary pointers. The keys are
- * hashed into a series of buckets which then have a chain of hash
- * entries using the standard doubly linked list classes (List/Link).
- * The chain in in collating sequence so search time through the chain
- * is on average (N/hashSize)/2.
- * @remarks This module is not thread-safe. It is the callers responsibility
- * to perform all thread synchronization.
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http: *www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http: *www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "mpr.h"
-
-/**************************** Forward Declarations ****************************/
-
-static int hashIndex(const char *key, int size);
-static MprSymbol *lookupInner(int *bucketIndex, MprSymbol **prevSp,
- MprSymbolTable *table, const char *key);
-
-/*********************************** Code *************************************/
-/*
- * Create a new symbol table of a given size. Caller should provide a size
- * that is a prime number for the greatest efficiency. Caller should use
- * mprFree to free the symbol table.
- */
-
-MprSymbolTable *mprCreateSymbolTable(MprCtx ctx, int hashSize)
-{
- MprSymbolTable *table;
-
- table = mprAllocTypeZeroed(ctx, MprSymbolTable);
- if (table == 0) {
- return 0;
- }
-
- if (hashSize < MPR_DEFAULT_HASH_SIZE) {
- hashSize = MPR_DEFAULT_HASH_SIZE;
- }
- table->hashSize = hashSize;
-
- table->count = 0;
- table->hashSize = hashSize;
- table->buckets = mprAllocZeroedBlock(MPR_LOC_ARGS(table),
- sizeof(MprSymbol*) * hashSize);
-
- if (table->buckets == 0) {
- mprFree(table);
- return 0;
- }
-
- return table;
-}
-
-/******************************************************************************/
-/*
- * Insert an entry into the symbol table. If the entry already exists, update
- * its value. Order of insertion is not preserved.
- */
-
-MprSymbol *mprInsertSymbol(MprSymbolTable *table, const char *key, void *ptr)
-{
- MprSymbol *sp, *prevSp;
- int index;
-
- sp = lookupInner(&index, &prevSp, table, key);
-
- if (sp != 0) {
- /*
- * Already exists. Just update the data.
- */
- sp->data = ptr;
- return sp;
- }
-
- /*
- * New entry
- */
- sp = mprAllocTypeZeroed(table, MprSymbol);
- if (sp == 0) {
- return 0;
- }
-
- sp->data = ptr;
- sp->key = mprStrdup(sp, key);
- sp->bucket = index;
-
- sp->next = table->buckets[index];
- table->buckets[index] = sp;
-
- table->count++;
- return sp;
-}
-
-/******************************************************************************/
-/*
- * Remove an entry from the table
- */
-
-int mprRemoveSymbol(MprSymbolTable *table, const char *key)
-{
- MprSymbol *sp, *prevSp;
- int index;
-
- if ((sp = lookupInner(&index, &prevSp, table, key)) == 0) {
- return MPR_ERR_NOT_FOUND;
- }
-
- if (prevSp) {
- prevSp->next = sp->next;
- } else {
- table->buckets[index] = sp->next;
- }
- table->count--;
-
- mprFree(sp);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Lookup a key and return the hash entry
- */
-
-void *mprLookupSymbol(MprSymbolTable *table, const char *key)
-{
- MprSymbol *sp;
-
- mprAssert(key);
-
- sp = lookupInner(0, 0, table, key);
- if (sp == 0) {
- return 0;
- }
- return sp->data;
-}
-
-/******************************************************************************/
-
-static MprSymbol *lookupInner(int *bucketIndex, MprSymbol **prevSp,
- MprSymbolTable *table, const char *key)
-{
- MprSymbol *sp, *prev;
- int index, rc;
-
- mprAssert(key);
-
- index = hashIndex(key, table->hashSize);
- if (bucketIndex) {
- *bucketIndex = index;
- }
-
- sp = table->buckets[index];
- prev = 0;
-
- while (sp) {
- rc = strcmp(sp->key, key);
- if (rc == 0) {
- if (prevSp) {
- *prevSp = prev;
- }
- return sp;
- }
- prev = sp;
- mprAssert(sp != sp->next);
- sp = sp->next;
- }
- return 0;
-}
-
-/******************************************************************************/
-
-int mprGetSymbolCount(MprSymbolTable *table)
-{
- return table->count;
-}
-
-/******************************************************************************/
-/*
- * Return the first entry in the table.
- */
-
-MprSymbol *mprGetFirstSymTab(MprSymbolTable *table)
-{
- MprSymbol *sp;
- int i;
-
- mprAssert(table);
-
- for (i = 0; i < table->hashSize; i++) {
- if ((sp = (MprSymbol*) table->buckets[i]) != 0) {
- return sp;
- }
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Return the next entry in the table
- */
-
-MprSymbol *mprGetNextSymTab(MprSymbolTable *table, MprSymbol *last)
-{
- MprSymbol *sp;
- int i;
-
- mprAssert(table);
-
- if (last->next) {
- return last->next;
- }
-
- for (i = last->bucket + 1; i < table->hashSize; i++) {
- if ((sp = (MprSymbol*) table->buckets[i]) != 0) {
- return sp;
- }
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Hash the key to produce a hash index.
- */
-
-static int hashIndex(const char *key, int size)
-{
- uint sum;
-
- sum = 0;
- while (*key) {
- sum += (sum * 33) + *key++;
- }
-
- return sum % size;
-}
-
-/******************************************************************************/
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprUnix.h b/source4/lib/appweb/ejs-2.0/mpr/mprUnix.h
deleted file mode 100644
index fbbe29ae9c..0000000000
--- a/source4/lib/appweb/ejs-2.0/mpr/mprUnix.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * @file mprUnix.h
- * @brief Make windows a bit more unix like
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/******************************* Documentation ********************************/
-
-/*
- * This header is part of the Mbedthis Portable Runtime and aims to include
- * all necessary O/S headers and to unify the constants and declarations
- * required by Mbedthis products. It can be included by C or C++ programs.
- */
-
-/******************************************************************************/
-
-#ifndef _h_MPR_UNIX
-#define _h_MPR_UNIX 1
-
-/******************************************************************************/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Define BLD_NO_POSIX_REMAP if these defines mess with your app
- */
-#if WIN && !BLD_NO_POSIX_REMAP
-/*
- * MOB -- clashes with ATL
- */
-#define access _access
-#define close _close
-#define fileno _fileno
-#define fstat _fstat
-#define getpid _getpid
-#define open _open
-#define putenv _putenv
-#define read _read
-#define stat _stat
-#define umask _umask
-#define unlink _unlink
-#define write _write
-#define strdup _strdup
-#define lseek _lseek
-#define getcwd _getcwd
-#define chdir _chdir
-
-#define mkdir(a,b) _mkdir(a)
-#define rmdir(a) _rmdir(a)
-
-#define R_OK 4
-#define W_OK 2
-#define MPR_TEXT "t"
-
-extern void srand48(long);
-extern long lrand48(void);
-extern long ulimit(int, ...);
-extern long nap(long);
-extern int getuid(void);
-extern int geteuid(void);
-#endif
-
-
-/******************************************************************************/
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _h_MPR_UNIX */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs/config.h b/source4/lib/appweb/ejs/config.h
deleted file mode 100644
index 8c06d28147..0000000000
--- a/source4/lib/appweb/ejs/config.h
+++ /dev/null
@@ -1,141 +0,0 @@
-#define BLD_PRODUCT "Samba4"
-#define BLD_NAME "Samba4 WEB Applications"
-#define BLD_VERSION "4"
-#define BLD_NUMBER "1"
-#define BLD_TYPE "DEBUG"
-#define BLD_DEFAULTS "normal"
-#define BLD_PACKAGES ""
-#define BLD_APPWEB_CONFIG "normal.conf"
-#define BLD_APPWEB 0
-#define BLD_COMPANY "Mbedthis"
-#define BLD_DEBUG 0
-#define BLD_DIRS "bootstrap include obj bin mpr ejs esp http doc appWeb appWebSamples images"
-#define BLD_HTTP_PORT 7777
-#define BLD_LIB_VERSION "1.0.0"
-#define BLD_SSL_PORT 4443
-#define BLD_CLEAN_INSTALL "0"
-#define BLD_LICENSE "gpl"
-#define BLD_HOST_SYSTEM "i686-pc-linux-gnu"
-#define BLD_BUILD_SYSTEM "i686-pc-linux-gnu"
-#define BLD_HOST_OS "LINUX"
-#define BLD_HOST_CPU_ARCH MPR_CPU_IX86
-#define BLD_HOST_CPU "i686"
-#define BLD_HOST_UNIX 1
-#define BLD_BUILD_OS "LINUX"
-#define BLD_BUILD_CPU_ARCH MPR_CPU_IX86
-#define BLD_BUILD_CPU i686
-#define BLD_BUILD_UNIX 1
-#define BLD_ROOT_PREFIX "/"
-#define BLD_FEATURE_ACCESS_LOG 0
-#define BLD_FEATURE_ADMIN_MODULE 0
-#define BLD_FEATURE_ASPNET_MODULE 0
-#define BLD_FEATURE_ASSERT 1
-#define BLD_FEATURE_AUTH_MODULE 0
-#define BLD_FEATURE_C_API_MODULE 1
-#define BLD_FEATURE_C_API_CLIENT 0
-#define BLD_FEATURE_CGI_MODULE 0
-#define BLD_FEATURE_COMPAT_MODULE 0
-#define BLD_FEATURE_CONFIG_PARSE 0
-#define BLD_FEATURE_CONFIG_SAVE 0
-#define BLD_FEATURE_COOKIE 0
-#define BLD_FEATURE_COPY_MODULE 0
-#define BLD_FEATURE_DIGEST 0
-#define BLD_FEATURE_DLL 0
-#define BLD_FEATURE_EGI_MODULE 0
-#define BLD_FEATURE_EJS 1
-#define BLD_FEATURE_ESP_MODULE 1
-#define BLD_FEATURE_EVAL_PERIOD 30
-#define BLD_FEATURE_FLOATING_POINT 1
-#define BLD_FEATURE_IF_MODIFIED 0
-#define BLD_FEATURE_INT64 1
-#define BLD_FEATURE_KEEP_ALIVE 0
-#define BLD_FEATURE_LEGACY_API 0
-#define BLD_FEATURE_LIB_STDCPP 0
-#define BLD_FEATURE_LICENSE 0
-#define BLD_FEATURE_LOG 0
-#define BLD_FEATURE_MULTITHREAD 0
-#define BLD_FEATURE_MALLOC 0
-#define BLD_FEATURE_MALLOC_STATS 0
-#define BLD_FEATURE_MALLOC_LEAK 0
-#define BLD_FEATURE_MALLOC_HOOK 0
-#define BLD_FEATURE_NUM_TYPE int64_t
-#define BLD_FEATURE_NUM_TYPE_ID MPR_TYPE_INT64
-#define BLD_FEATURE_ROMFS 0
-#define BLD_FEATURE_RUN_AS_SERVICE 0
-#define BLD_FEATURE_SAFE_STRINGS 0
-#define BLD_FEATURE_SAMPLES 0
-#define BLD_FEATURE_SESSION 1
-#define BLD_FEATURE_SHARED 0
-#define BLD_FEATURE_SQUEEZE 0
-#define BLD_FEATURE_SSL_MODULE 0
-#define BLD_FEATURE_STATIC 1
-#define BLD_FEATURE_STATIC_LINK_LIBC 0
-#define BLD_FEATURE_TEST 0
-#define BLD_FEATURE_UPLOAD_MODULE 0
-#define BLD_FEATURE_XDB_MODULE 0
-#define BLD_FEATURE_ADMIN_MODULE_BUILTIN 0
-#define BLD_FEATURE_ASPNET_MODULE_BUILTIN 0
-#define BLD_FEATURE_AUTH_MODULE_BUILTIN 0
-#define BLD_FEATURE_C_API_MODULE_BUILTIN 0
-#define BLD_FEATURE_CGI_MODULE_BUILTIN 0
-#define BLD_FEATURE_COMPAT_MODULE_BUILTIN 0
-#define BLD_FEATURE_COPY_MODULE_BUILTIN 0
-#define BLD_FEATURE_EGI_MODULE_BUILTIN 0
-#define BLD_FEATURE_ESP_MODULE_BUILTIN 0
-#define BLD_FEATURE_SSL_MODULE_BUILTIN 0
-#define BLD_FEATURE_UPLOAD_MODULE_BUILTIN 0
-#define BLD_FEATURE_XDB_MODULE_BUILTIN 0
-#define BLD_FEATURE_ADMIN_MODULE_LOADABLE 0
-#define BLD_FEATURE_ASPNET_MODULE_LOADABLE 0
-#define BLD_FEATURE_AUTH_MODULE_LOADABLE 0
-#define BLD_FEATURE_C_API_MODULE_LOADABLE 0
-#define BLD_FEATURE_CGI_MODULE_LOADABLE 0
-#define BLD_FEATURE_COMPAT_MODULE_LOADABLE 0
-#define BLD_FEATURE_COPY_MODULE_LOADABLE 0
-#define BLD_FEATURE_EGI_MODULE_LOADABLE 0
-#define BLD_FEATURE_ESP_MODULE_LOADABLE 0
-#define BLD_FEATURE_SSL_MODULE_LOADABLE 0
-#define BLD_FEATURE_UPLOAD_MODULE_LOADABLE 0
-#define BLD_FEATURE_XDB_MODULE_LOADABLE 0
-#define BLD_AR_FOR_BUILD "ar"
-#define BLD_CC_FOR_BUILD "cc"
-#define BLD_CSC_FOR_BUILD ""
-#define BLD_JAVAC_FOR_BUILD ""
-#define BLD_LD_FOR_BUILD "ld"
-#define BLD_RANLIB_FOR_BUILD ""
-#define BLD_NM_FOR_BUILD "nm"
-#define BLD_CFLAGS_FOR_BUILD ""
-#define BLD_IFLAGS_FOR_BUILD ""
-#define BLD_LDFLAGS_FOR_BUILD ""
-#define BLD_ARCHIVE_FOR_BUILD ".a"
-#define BLD_EXE_FOR_BUILD ""
-#define BLD_OBJ_FOR_BUILD ".o"
-#define BLD_PIOBJ_FOR_BUILD ".lo"
-#define BLD_CLASS_FOR_BUILD ".class"
-#define BLD_SHLIB_FOR_BUILD ""
-#define BLD_SHOBJ_FOR_BUILD ".so"
-#define BLD_AR_FOR_HOST "ar"
-#define BLD_CC_FOR_HOST "cc"
-#define BLD_CSC_FOR_HOST "csc"
-#define BLD_JAVAC_FOR_HOST "javac"
-#define BLD_LD_FOR_HOST "ld"
-#define BLD_RANLIB_FOR_HOST "true"
-#define BLD_NM_FOR_HOST "nm"
-#define BLD_CFLAGS_FOR_HOST ""
-#define BLD_IFLAGS_FOR_HOST ""
-#define BLD_LDFLAGS_FOR_HOST ""
-#define BLD_ARCHIVE_FOR_HOST ".a"
-#define BLD_EXE_FOR_HOST ""
-#define BLD_OBJ_FOR_HOST ".o"
-#define BLD_PIOBJ_FOR_HOST ".lo"
-#define BLD_CLASS_FOR_HOST ".class"
-#define BLD_SHLIB_FOR_HOST ""
-#define BLD_SHOBJ_FOR_HOST ".so"
-#define BLD_TOOLS_DIR "${BLD_TOP}/bin"
-#define BLD_BIN_DIR "${BLD_TOP}/bin"
-#define BLD_INC_DIR "/usr/include/${BLD_PRODUCT}"
-#define BLD_EXP_OBJ_DIR "${BLD_TOP}/obj"
-
-#ifndef MAX_FLOAT
-#define MAX_FLOAT 3.40282347e+38F
-#endif
diff --git a/source4/lib/appweb/ejs/ejs.h b/source4/lib/appweb/ejs/ejs.h
deleted file mode 100644
index c7b0c54d8e..0000000000
--- a/source4/lib/appweb/ejs/ejs.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * @file ejs.h
- * @brief Primary Embedded Javascript (ECMAScript) header.
- * @overview This Embedded Javascript (EJS) header defines the
- * public API. This API should only be used by those directly
- * using EJS without using Embedded Server Pages (ESP). ESP
- * wraps all relevant APIs to expose a single consistent API.
- * \n\n
- * This API requires the mpr/var.h facilities to create and
- * manage objects and properties.
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default.g
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved.
- * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#ifndef _h_EJS
-#define _h_EJS 1
-
-#include "lib/appweb/mpr/miniMpr.h"
-#include "lib/appweb/mpr/var.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/********************************* Prototypes *********************************/
-
-typedef MprVarHandle EjsId;
-typedef MprVarHandle EjsHandle;
-
-/*
- * Multithreaded lock routines
- */
-typedef void (*EjsLock)(void *lockData);
-typedef void (*EjsUnlock)(void *lockData);
-
-/********************************* Prototypes *********************************/
-/*
- * Module management
- */
-extern int ejsOpen(EjsLock lock, EjsUnlock unlock, void *lockData);
-extern void ejsClose(void);
-extern EjsId ejsOpenEngine(EjsHandle primaryHandle, EjsHandle altHandle);
-extern void ejsCloseEngine(EjsId eid);
-
-void *ejs_save_state(void);
-void ejs_restore_state(void *ptr);
-
-/*
- * Evaluation functions
- */
-extern int ejsEvalFile(EjsId eid, char *path, MprVar *result, char **emsg);
-extern int ejsEvalScript(EjsId eid, char *script, MprVar *result,
- char **emsg);
-extern int ejsRunFunction(int eid, MprVar *obj, const char *functionName,
- MprArray *args);
-
-/*
- * Composite variable get / set routines. Can also use the MPR property
- * routines on an object variable.
- */
-extern MprVar ejsCreateObj(const char *name, int hashSize);
-extern MprVar ejsCreateArray(const char *name, int hashSize);
-extern bool ejsDestroyVar(MprVar *obj);
-extern int ejsCopyVar(EjsId eid, const char *var, MprVar *value,
- bool copyRef);
-extern int ejsReadVar(EjsId eid, const char *var, MprVar *value);
-extern int ejsWriteVar(EjsId eid, const char *var, MprVar *value);
-extern int ejsWriteVarValue(EjsId eid, const char *var, MprVar value);
-extern int ejsDeleteVar(EjsId eid, const char *var);
-
-extern MprVar *ejsGetLocalObject(EjsId eid);
-extern MprVar *ejsGetGlobalObject(EjsId eid);
-
-/*
- * Function routines
- */
-extern void ejsDefineFunction(EjsId eid, const char *functionName,
- char *args, char *body);
-extern void ejsDefineCFunction(EjsId eid, const char *functionName,
- MprCFunction fn, void *thisPtr, int flags);
-extern void ejsDefineStringCFunction(EjsId eid, const char *functionName,
- MprStringCFunction fn, void *thisPtr, int flags);
-extern void *ejsGetThisPtr(EjsId eid);
-extern MprVar *ejsGetReturnValue(EjsId eid);
-extern int ejsGetLineNumber(EjsId eid);
-extern int ejsParseArgs(int argc, char **argv, char *fmt, ...);
-extern void ejsSetErrorMsg(EjsId eid, const char* fmt, ...)
- PRINTF_ATTRIBUTE(2,3);
-extern void ejsSetReturnValue(EjsId eid, MprVar value);
-extern void ejsSetReturnString(EjsId eid, const char *str);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* _h_EJS */
-
-/*****************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs/ejsInternal.h b/source4/lib/appweb/ejs/ejsInternal.h
deleted file mode 100644
index 8b66dafdca..0000000000
--- a/source4/lib/appweb/ejs/ejsInternal.h
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * @file ejsInternal.h
- * @brief Private header for Embedded Javascript (ECMAScript)
- * @overview This Embedded Javascript header defines the private Embedded
- * Javascript internal structures.
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default.g
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved.
- * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************* Includes ***********************************/
-
-#ifndef _h_EJS_INTERNAL
-#define _h_EJS_INTERNAL 1
-
-#include "ejs.h"
-
-/********************************** Defines ***********************************/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Constants
- */
-
-#if BLD_FEATURE_SQUEEZE
- #define EJS_PARSE_INCR 256 /* Growth factor */
- #define EJS_MAX_RECURSE 25 /* Sanity for maximum recursion */
- #define EJS_MAX_ID 128 /* Maximum ID length */
- #define EJS_OBJ_HASH_SIZE 13 /* Object hash table size */
- #define EJS_SMALL_OBJ_HASH_SIZE 11 /* Small object hash size */
- #define EJS_LIST_INCR 8 /* Growth increment for lists */
-#else
- #define EJS_PARSE_INCR 1024 /* Growth factor */
- #define EJS_MAX_RECURSE 100 /* Sanity for maximum recursion */
- #define EJS_MAX_ID 256 /* Maximum ID length */
- #define EJS_OBJ_HASH_SIZE 29 /* Object hash table size */
- #define EJS_SMALL_OBJ_HASH_SIZE 11 /* Small object hash size */
- #define EJS_LIST_INCR 16 /* Growth increment for lists */
-#endif
-#define EJS_TOKEN_STACK 4 /* Put back token stack */
-
-/*
- * Lexical analyser tokens
- */
-#define EJS_TOK_ERR -1 /* Any error */
-#define EJS_TOK_LPAREN 1 /* ( */
-#define EJS_TOK_RPAREN 2 /* ) */
-#define EJS_TOK_IF 3 /* if */
-#define EJS_TOK_ELSE 4 /* else */
-#define EJS_TOK_LBRACE 5 /* { */
-#define EJS_TOK_RBRACE 6 /* } */
-#define EJS_TOK_LOGICAL 7 /* ||, &&, ! */
-#define EJS_TOK_EXPR 8 /* +, -, /, % */
-#define EJS_TOK_SEMI 9 /* ; */
-#define EJS_TOK_LITERAL 10 /* literal string */
-#define EJS_TOK_FUNCTION_NAME 11 /* functionName */
-#define EJS_TOK_NEWLINE 12 /* newline white space */
-#define EJS_TOK_ID 13 /* Identifier */
-#define EJS_TOK_EOF 14 /* End of script */
-#define EJS_TOK_COMMA 15 /* Comma */
-#define EJS_TOK_VAR 16 /* var */
-#define EJS_TOK_ASSIGNMENT 17 /* = */
-#define EJS_TOK_FOR 18 /* for */
-#define EJS_TOK_INC_DEC 19 /* ++, -- */
-#define EJS_TOK_RETURN 20 /* return */
-#define EJS_TOK_PERIOD 21 /* . */
-#define EJS_TOK_LBRACKET 22 /* [ */
-#define EJS_TOK_RBRACKET 23 /* ] */
-#define EJS_TOK_NEW 24 /* new */
-#define EJS_TOK_DELETE 25 /* delete */
-#define EJS_TOK_IN 26 /* in */
-#define EJS_TOK_FUNCTION 27 /* function */
-#define EJS_TOK_NUMBER 28 /* Number */
-
-/*
- * Expression operators
- */
-#define EJS_EXPR_LESS 1 /* < */
-#define EJS_EXPR_LESSEQ 2 /* <= */
-#define EJS_EXPR_GREATER 3 /* > */
-#define EJS_EXPR_GREATEREQ 4 /* >= */
-#define EJS_EXPR_EQ 5 /* == */
-#define EJS_EXPR_NOTEQ 6 /* != */
-#define EJS_EXPR_PLUS 7 /* + */
-#define EJS_EXPR_MINUS 8 /* - */
-#define EJS_EXPR_DIV 9 /* / */
-#define EJS_EXPR_MOD 10 /* % */
-#define EJS_EXPR_LSHIFT 11 /* << */
-#define EJS_EXPR_RSHIFT 12 /* >> */
-#define EJS_EXPR_MUL 13 /* * */
-#define EJS_EXPR_ASSIGNMENT 14 /* = */
-#define EJS_EXPR_INC 15 /* ++ */
-#define EJS_EXPR_DEC 16 /* -- */
-#define EJS_EXPR_BOOL_COMP 17 /* ! */
-
-/*
- * Conditional operators
- */
-#define EJS_COND_AND 1 /* && */
-#define EJS_COND_OR 2 /* || */
-#define EJS_COND_NOT 3 /* ! */
-
-/*
- * States
- */
-#define EJS_STATE_ERR -1 /* Error state */
-#define EJS_STATE_EOF 1 /* End of file */
-#define EJS_STATE_COND 2 /* Parsing a "(conditional)" stmt */
-#define EJS_STATE_COND_DONE 3
-#define EJS_STATE_RELEXP 4 /* Parsing a relational expr */
-#define EJS_STATE_RELEXP_DONE 5
-#define EJS_STATE_EXPR 6 /* Parsing an expression */
-#define EJS_STATE_EXPR_DONE 7
-#define EJS_STATE_STMT 8 /* Parsing General statement */
-#define EJS_STATE_STMT_DONE 9
-#define EJS_STATE_STMT_BLOCK_DONE 10 /* End of block "}" */
-#define EJS_STATE_ARG_LIST 11 /* Function arg list */
-#define EJS_STATE_ARG_LIST_DONE 12
-#define EJS_STATE_DEC_LIST 16 /* Declaration list */
-#define EJS_STATE_DEC_LIST_DONE 17
-#define EJS_STATE_DEC 18 /* Declaration statement */
-#define EJS_STATE_DEC_DONE 19
-#define EJS_STATE_RET 20 /* Return statement */
-
-#define EJS_STATE_BEGIN EJS_STATE_STMT
-
-/*
- * General parsing flags.
- */
-#define EJS_FLAGS_EXE 0x1 /* Execute statements */
-#define EJS_FLAGS_LOCAL 0x2 /* Get local vars only */
-#define EJS_FLAGS_GLOBAL 0x4 /* Get global vars only */
-#define EJS_FLAGS_CREATE 0x8 /* Create var */
-#define EJS_FLAGS_ASSIGNMENT 0x10 /* In assignment stmt */
-#define EJS_FLAGS_DELETE 0x20 /* Deleting a variable */
-#define EJS_FLAGS_FOREACH 0x40 /* In foreach */
-#define EJS_FLAGS_NEW 0x80 /* In a new stmt() */
-#define EJS_FLAGS_EXIT 0x100 /* Must exit */
-
-/*
- * Putback token
- */
-
-typedef struct EjsToken {
- char *token; /* Token string */
- int id; /* Token ID */
-} EjsToken;
-
-/*
- * EJ evaluation block structure
- */
-typedef struct ejEval {
- EjsToken putBack[EJS_TOKEN_STACK]; /* Put back token stack */
- int putBackIndex; /* Top of stack index */
- MprStr line; /* Current line */
- int lineLength; /* Current line length */
- int lineNumber; /* Parse line number */
- int lineColumn; /* Column in line */
- MprStr script; /* Input script for parsing */
- char *scriptServp; /* Next token in the script */
- int scriptSize; /* Length of script */
- MprStr tokbuf; /* Current token */
- char *tokEndp; /* Pointer past end of token */
- char *tokServp; /* Pointer to next token char */
- int tokSize; /* Size of token buffer */
- struct ejEval *next; /* used for backtraces */
- const char *procName; /* gives name in backtrace */
-} EjsInput;
-
-/*
- * Function call structure
- */
-typedef struct {
- MprArray *args; /* Args for function */
- MprVar *fn; /* Function definition */
- char *procName; /* Function name */
-} EjsProc;
-
-/*
- * Per EJS structure
- */
-typedef struct ej {
- EjsHandle altHandle; /* alternate callback handle */
- MprVar *currentObj; /* Ptr to current object */
- MprVar *currentProperty; /* Ptr to current property */
- EjsId eid; /* Halloc handle */
- char *error; /* Error message */
- int exitStatus; /* Status to exit() */
- int flags; /* Flags */
- MprArray *frames; /* List of variable frames */
- MprVar *global; /* Global object */
- EjsInput *input; /* Input evaluation block */
- MprVar *local; /* Local object */
- EjsHandle primaryHandle; /* primary callback handle */
- EjsProc *proc; /* Current function */
- MprVar result; /* Variable result */
- void *thisPtr; /* C++ ptr for functions */
- int tid; /* Current token id */
- char *token; /* Pointer to token string */
- MprVar tokenNumber; /* Parsed number */
-} Ejs;
-
-typedef int EjsBlock; /* Scope block id */
-
-/*
- * Function callback when using Alternate handles.
- */
-typedef int (*EjsAltStringCFunction)(EjsHandle userHandle, EjsHandle altHandle,
- int argc, char **argv);
-typedef int (*EjsAltCFunction)(EjsHandle userHandle, EjsHandle altHandle,
- int argc, MprVar **argv);
-
-/******************************** Prototypes **********************************/
-/*
- * Ejs Lex
- */
-extern int ejsLexOpenScript(Ejs* ep, char *script);
-extern void ejsLexCloseScript(Ejs* ep);
-extern int ejsInitInputState(EjsInput *ip);
-extern void ejsLexSaveInputState(Ejs* ep, EjsInput* state);
-extern void ejsLexFreeInputState(Ejs* ep, EjsInput* state);
-extern void ejsLexRestoreInputState(Ejs* ep, EjsInput* state);
-extern int ejsLexGetToken(Ejs* ep, int state);
-extern void ejsLexPutbackToken(Ejs* ep, int tid, char *string);
-
-/*
- * Parsing
- */
-extern MprVar *ejsFindObj(Ejs *ep, int state, const char *property,
- int flags);
-extern MprVar *ejsFindProperty(Ejs *ep, int state, MprVar *obj,
- char *property, int flags);
-extern int ejsGetVarCore(Ejs *ep, const char *var, MprVar **obj,
- MprVar **varValue, int flags);
-extern int ejsParse(Ejs *ep, int state, int flags);
-extern Ejs *ejsPtr(EjsId eid);
-extern void ejsSetExitStatus(int eid, int status);
-extern void ejsSetFlags(int orFlags, int andFlags);
-
-/*
- * Create variable scope blocks
- */
-extern EjsBlock ejsOpenBlock(EjsId eid);
-extern int ejsCloseBlock(EjsId eid, EjsBlock vid);
-extern int ejsEvalBlock(EjsId eid, char *script, MprVar *v, char **err);
-extern int ejsDefineStandardProperties(MprVar *objVar);
-
-/*
- * Error handling
- */
-extern void ejsError(Ejs *ep, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* _h_EJS_INTERNAL */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs/ejsLex.c b/source4/lib/appweb/ejs/ejsLex.c
deleted file mode 100644
index b9a363cfc9..0000000000
--- a/source4/lib/appweb/ejs/ejsLex.c
+++ /dev/null
@@ -1,923 +0,0 @@
-/*
- * @file ejsLex.c
- * @brief EJS Lexical Analyser
- * @overview EJS lexical analyser. This implementes a lexical analyser
- * for a subset of the JavaScript language.
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default.g
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved.
- * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "ejsInternal.h"
-
-#if BLD_FEATURE_EJS
-
-/****************************** Forward Declarations **************************/
-
-static int getLexicalToken(Ejs *ep, int state);
-static int tokenAddChar(Ejs *ep, int c);
-static int inputGetc(Ejs *ep);
-static void inputPutback(Ejs *ep, int c);
-static int charConvert(Ejs *ep, int base, int maxDig);
-
-/************************************* Code ***********************************/
-/*
- * Open a new input script
- */
-
-int ejsLexOpenScript(Ejs *ep, char *script)
-{
- EjsInput *ip;
-
- mprAssert(ep);
- mprAssert(script);
-
- if ((ip = mprMalloc(sizeof(EjsInput))) == NULL) {
- return -1;
- }
- memset(ip, 0, sizeof(*ip));
- ip->next = ep->input;
- ep->input = ip;
- ip->procName = ep->proc?ep->proc->procName:NULL;
-
-/*
- * Create the parse token buffer and script buffer
- */
- ip->tokbuf = mprMalloc(EJS_PARSE_INCR);
- ip->tokSize = EJS_PARSE_INCR;
- ip->tokServp = ip->tokbuf;
- ip->tokEndp = ip->tokbuf;
-
- ip->script = mprStrdup(script);
- ip->scriptSize = strlen(script);
- ip->scriptServp = ip->script;
-
- ip->lineNumber = 1;
- ip->lineLength = 0;
- ip->lineColumn = 0;
- ip->line = NULL;
-
- ip->putBackIndex = -1;
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Close the input script
- */
-
-void ejsLexCloseScript(Ejs *ep)
-{
- EjsInput *ip;
- int i;
-
- mprAssert(ep);
-
- ip = ep->input;
- mprAssert(ip);
- ep->input = ip->next;
-
- for (i = 0; i < EJS_TOKEN_STACK; i++) {
- mprFree(ip->putBack[i].token);
- ip->putBack[i].token = 0;
- }
-
- mprFree(ip->line);
- mprFree(ip->tokbuf);
- mprFree(ip->script);
-
- mprFree(ip);
-}
-
-/******************************************************************************/
-/*
- * Initialize an input state structure
- */
-
-int ejsInitInputState(EjsInput *ip)
-{
- mprAssert(ip);
-
- memset(ip, 0, sizeof(*ip));
- ip->putBackIndex = -1;
-
- return 0;
-}
-/******************************************************************************/
-/*
- * Save the input state
- */
-
-void ejsLexSaveInputState(Ejs *ep, EjsInput *state)
-{
- EjsInput *ip;
- int i;
-
- mprAssert(ep);
-
- ip = ep->input;
- mprAssert(ip);
-
- *state = *ip;
-
- for (i = 0; i < ip->putBackIndex; i++) {
- state->putBack[i].token = mprStrdup(ip->putBack[i].token);
- state->putBack[i].id = ip->putBack[i].id;
- }
- for (; i < EJS_TOKEN_STACK; i++) {
- state->putBack[i].token = 0;
- }
-
- state->line = mprMalloc(ip->lineLength);
- mprStrcpy(state->line, ip->lineLength, ip->line);
-
- state->lineColumn = ip->lineColumn;
- state->lineNumber = ip->lineNumber;
- state->lineLength = ip->lineLength;
-}
-
-/******************************************************************************/
-/*
- * Restore the input state
- */
-
-void ejsLexRestoreInputState(Ejs *ep, EjsInput *state)
-{
- EjsInput *ip;
- int i;
-
- mprAssert(ep);
- mprAssert(state);
-
- ip = ep->input;
- mprAssert(ip);
-
- ip->tokbuf = state->tokbuf;
- ip->tokServp = state->tokServp;
- ip->tokEndp = state->tokEndp;
- ip->tokSize = state->tokSize;
-
- ip->script = state->script;
- ip->scriptServp = state->scriptServp;
- ip->scriptSize = state->scriptSize;
-
- ip->putBackIndex = state->putBackIndex;
- for (i = 0; i < ip->putBackIndex; i++) {
- mprFree(ip->putBack[i].token);
- ip->putBack[i].id = state->putBack[i].id;
- ip->putBack[i].token = mprStrdup(state->putBack[i].token);
- }
-
- mprFree(ip->line);
- ip->line = mprMalloc(state->lineLength);
- mprStrcpy(ip->line, state->lineLength, state->line);
-
- ip->lineColumn = state->lineColumn;
- ip->lineNumber = state->lineNumber;
- ip->lineLength = state->lineLength;
-}
-
-/******************************************************************************/
-/*
- * Free a saved input state
- */
-
-void ejsLexFreeInputState(Ejs *ep, EjsInput *state)
-{
- int i;
-
- mprAssert(ep);
- mprAssert(state);
-
- for (i = 0; i < EJS_TOKEN_STACK; i++) {
- mprFree(state->putBack[i].token);
- }
- state->putBackIndex = -1;
- mprFree(state->line);
- state->lineLength = 0;
- state->lineColumn = 0;
-}
-
-/******************************************************************************/
-/*
- * Get the next EJS token
- */
-
-int ejsLexGetToken(Ejs *ep, int state)
-{
- mprAssert(ep);
-
- ep->tid = getLexicalToken(ep, state);
- return ep->tid;
-}
-
-/******************************************************************************/
-
-/*
- * Check for reserved words "if", "else", "var", "for", "foreach",
- * "delete", "function", and "return". "new", "in" and "function"
- * done below. "true", "false", "null", "undefined" are handled
- * as global objects.
- *
- * Other reserved words not supported:
- * "break", "case", "catch", "continue", "default", "do",
- * "finally", "instanceof", "switch", "this", "throw", "try",
- * "typeof", "while", "with"
- *
- * ECMA extensions reserved words (not supported):
- * "abstract", "boolean", "byte", "char", "class", "const",
- * "debugger", "double", "enum", "export", "extends",
- * "final", "float", "goto", "implements", "import", "int",
- * "interface", "long", "native", "package", "private",
- * "protected", "public", "short", "static", "super",
- * "synchronized", "throws", "transient", "volatile"
- */
-
-static int checkReservedWord(Ejs *ep, int state, int c, int tid)
-{
- if (state == EJS_STATE_STMT) {
- if (strcmp(ep->token, "if") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_IF;
- } else if (strcmp(ep->token, "else") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_ELSE;
- } else if (strcmp(ep->token, "var") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_VAR;
- } else if (strcmp(ep->token, "for") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_FOR;
- } else if (strcmp(ep->token, "delete") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_DELETE;
- } else if (strcmp(ep->token, "function") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_FUNCTION;
- } else if (strcmp(ep->token, "return") == 0) {
- if ((c == ';') || (c == '(')) {
- inputPutback(ep, c);
- }
- return EJS_TOK_RETURN;
- }
- } else if (state == EJS_STATE_EXPR) {
- if (strcmp(ep->token, "new") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_NEW;
- } else if (strcmp(ep->token, "in") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_IN;
- } else if (strcmp(ep->token, "function") == 0) {
- inputPutback(ep, c);
- return EJS_TOK_FUNCTION;
- }
- }
- return tid;
-}
-
-/******************************************************************************/
-/*
- * Get the next EJS token
- */
-
-static int getLexicalToken(Ejs *ep, int state)
-{
- MprType type;
- EjsInput *ip;
- int done, tid, c, quote, style, idx;
-
- mprAssert(ep);
- ip = ep->input;
- mprAssert(ip);
-
- ep->tid = -1;
- tid = -1;
- type = BLD_FEATURE_NUM_TYPE_ID;
-
- /*
- * Use a putback tokens first. Don't free strings as caller needs access.
- */
- if (ip->putBackIndex >= 0) {
- idx = ip->putBackIndex;
- tid = ip->putBack[idx].id;
- ep->token = (char*) ip->putBack[idx].token;
- tid = checkReservedWord(ep, state, 0, tid);
- ip->putBackIndex--;
- return tid;
- }
- ep->token = ip->tokServp = ip->tokEndp = ip->tokbuf;
- *ip->tokServp = '\0';
-
- if ((c = inputGetc(ep)) < 0) {
- return EJS_TOK_EOF;
- }
-
- /*
- * Main lexical analyser
- */
- for (done = 0; !done; ) {
- switch (c) {
- case -1:
- return EJS_TOK_EOF;
-
- case ' ':
- case '\t':
- case '\r':
- do {
- if ((c = inputGetc(ep)) < 0)
- break;
- } while (c == ' ' || c == '\t' || c == '\r');
- break;
-
- case '\n':
- return EJS_TOK_NEWLINE;
-
- case '(':
- tokenAddChar(ep, c);
- return EJS_TOK_LPAREN;
-
- case ')':
- tokenAddChar(ep, c);
- return EJS_TOK_RPAREN;
-
- case '[':
- tokenAddChar(ep, c);
- return EJS_TOK_LBRACKET;
-
- case ']':
- tokenAddChar(ep, c);
- return EJS_TOK_RBRACKET;
-
- case '.':
- tokenAddChar(ep, c);
- return EJS_TOK_PERIOD;
-
- case '{':
- tokenAddChar(ep, c);
- return EJS_TOK_LBRACE;
-
- case '}':
- tokenAddChar(ep, c);
- return EJS_TOK_RBRACE;
-
- case '+':
- if ((c = inputGetc(ep)) < 0) {
- ejsError(ep, "Syntax Error");
- return EJS_TOK_ERR;
- }
- if (c != '+' ) {
- inputPutback(ep, c);
- tokenAddChar(ep, EJS_EXPR_PLUS);
- return EJS_TOK_EXPR;
- }
- tokenAddChar(ep, EJS_EXPR_INC);
- return EJS_TOK_INC_DEC;
-
- case '-':
- if ((c = inputGetc(ep)) < 0) {
- ejsError(ep, "Syntax Error");
- return EJS_TOK_ERR;
- }
- if (c != '-' ) {
- inputPutback(ep, c);
- tokenAddChar(ep, EJS_EXPR_MINUS);
- return EJS_TOK_EXPR;
- }
- tokenAddChar(ep, EJS_EXPR_DEC);
- return EJS_TOK_INC_DEC;
-
- case '*':
- tokenAddChar(ep, EJS_EXPR_MUL);
- return EJS_TOK_EXPR;
-
- case '%':
- tokenAddChar(ep, EJS_EXPR_MOD);
- return EJS_TOK_EXPR;
-
- case '/':
- /*
- * Handle the division operator and comments
- */
- if ((c = inputGetc(ep)) < 0) {
- ejsError(ep, "Syntax Error");
- return EJS_TOK_ERR;
- }
- if (c != '*' && c != '/') {
- inputPutback(ep, c);
- tokenAddChar(ep, EJS_EXPR_DIV);
- return EJS_TOK_EXPR;
- }
- style = c;
- /*
- * Eat comments. Both C and C++ comment styles are supported.
- */
- while (1) {
- if ((c = inputGetc(ep)) < 0) {
- if (style == '/') {
- return EJS_TOK_EOF;
- }
- ejsError(ep, "Syntax Error");
- return EJS_TOK_ERR;
- }
- if (c == '\n' && style == '/') {
- break;
- } else if (c == '*') {
- c = inputGetc(ep);
- if (style == '/') {
- if (c == '\n') {
- break;
- }
- } else {
- if (c == '/') {
- break;
- }
- }
- }
- }
- /*
- * Continue looking for a token, so get the next character
- */
- if ((c = inputGetc(ep)) < 0) {
- return EJS_TOK_EOF;
- }
- break;
-
- case '<': /* < and <= */
- if ((c = inputGetc(ep)) < 0) {
- ejsError(ep, "Syntax Error");
- return EJS_TOK_ERR;
- }
- if (c == '<') {
- tokenAddChar(ep, EJS_EXPR_LSHIFT);
- return EJS_TOK_EXPR;
- } else if (c == '=') {
- tokenAddChar(ep, EJS_EXPR_LESSEQ);
- return EJS_TOK_EXPR;
- }
- tokenAddChar(ep, EJS_EXPR_LESS);
- inputPutback(ep, c);
- return EJS_TOK_EXPR;
-
- case '>': /* > and >= */
- if ((c = inputGetc(ep)) < 0) {
- ejsError(ep, "Syntax Error");
- return EJS_TOK_ERR;
- }
- if (c == '>') {
- tokenAddChar(ep, EJS_EXPR_RSHIFT);
- return EJS_TOK_EXPR;
- } else if (c == '=') {
- tokenAddChar(ep, EJS_EXPR_GREATEREQ);
- return EJS_TOK_EXPR;
- }
- tokenAddChar(ep, EJS_EXPR_GREATER);
- inputPutback(ep, c);
- return EJS_TOK_EXPR;
-
- case '=': /* "==" */
- if ((c = inputGetc(ep)) < 0) {
- ejsError(ep, "Syntax Error");
- return EJS_TOK_ERR;
- }
- if (c == '=') {
- tokenAddChar(ep, EJS_EXPR_EQ);
- return EJS_TOK_EXPR;
- }
- inputPutback(ep, c);
- return EJS_TOK_ASSIGNMENT;
-
- case '!': /* "!=" or "!"*/
- if ((c = inputGetc(ep)) < 0) {
- ejsError(ep, "Syntax Error");
- return EJS_TOK_ERR;
- }
- if (c == '=') {
- tokenAddChar(ep, EJS_EXPR_NOTEQ);
- return EJS_TOK_EXPR;
- }
- inputPutback(ep, c);
- tokenAddChar(ep, EJS_EXPR_BOOL_COMP);
- return EJS_TOK_EXPR;
-
- case ';':
- tokenAddChar(ep, c);
- return EJS_TOK_SEMI;
-
- case ',':
- tokenAddChar(ep, c);
- return EJS_TOK_COMMA;
-
- case '|': /* "||" */
- if ((c = inputGetc(ep)) < 0 || c != '|') {
- ejsError(ep, "Syntax Error");
- return EJS_TOK_ERR;
- }
- tokenAddChar(ep, EJS_COND_OR);
- return EJS_TOK_LOGICAL;
-
- case '&': /* "&&" */
- if ((c = inputGetc(ep)) < 0 || c != '&') {
- ejsError(ep, "Syntax Error");
- return EJS_TOK_ERR;
- }
- tokenAddChar(ep, EJS_COND_AND);
- return EJS_TOK_LOGICAL;
-
- case '\"': /* String quote */
- case '\'':
- quote = c;
- if ((c = inputGetc(ep)) < 0) {
- ejsError(ep, "Syntax Error");
- return EJS_TOK_ERR;
- }
-
- while (c != quote) {
- /*
- * Check for escape sequence characters
- */
- if (c == '\\') {
- c = inputGetc(ep);
-
- if (isdigit(c)) {
- /*
- * Octal support, \101 maps to 65 = 'A'. Put first
- * char back so converter will work properly.
- */
- inputPutback(ep, c);
- c = charConvert(ep, 8, 3);
-
- } else {
- switch (c) {
- case 'n':
- c = '\n'; break;
- case 'b':
- c = '\b'; break;
- case 'f':
- c = '\f'; break;
- case 'r':
- c = '\r'; break;
- case 't':
- c = '\t'; break;
- case 'x':
- /*
- * Hex support, \x41 maps to 65 = 'A'
- */
- c = charConvert(ep, 16, 2);
- break;
- case 'u':
- /*
- * Unicode support, \x0401 maps to 65 = 'A'
- */
- c = charConvert(ep, 16, 2);
- c = c*16 + charConvert(ep, 16, 2);
-
- break;
- case '\'':
- case '\"':
- case '\\':
- break;
- default:
- ejsError(ep, "Invalid Escape Sequence");
- return EJS_TOK_ERR;
- }
- }
- if (tokenAddChar(ep, c) < 0) {
- return EJS_TOK_ERR;
- }
- } else {
- if (tokenAddChar(ep, c) < 0) {
- return EJS_TOK_ERR;
- }
- }
- if ((c = inputGetc(ep)) < 0) {
- ejsError(ep, "Unmatched Quote");
- return EJS_TOK_ERR;
- }
- }
- return EJS_TOK_LITERAL;
-
- case '0':
- if (tokenAddChar(ep, c) < 0) {
- return EJS_TOK_ERR;
- }
- if ((c = inputGetc(ep)) < 0) {
- break;
- }
- if (tolower(c) == 'x') {
- do {
- if (tokenAddChar(ep, c) < 0) {
- return EJS_TOK_ERR;
- }
- if ((c = inputGetc(ep)) < 0) {
- break;
- }
- } while (isdigit(c) || (tolower(c) >= 'a' && tolower(c) <= 'f'));
-
- mprDestroyVar(&ep->tokenNumber);
- ep->tokenNumber = mprParseVar(ep->token, type);
- inputPutback(ep, c);
- return EJS_TOK_NUMBER;
- }
- if (! isdigit(c)) {
-#if BLD_FEATURE_FLOATING_POINT
- if (c == '.' || tolower(c) == 'e' || c == '+' || c == '-') {
- /* Fall through */
- type = MPR_TYPE_FLOAT;
- } else
-#endif
- {
- mprDestroyVar(&ep->tokenNumber);
- ep->tokenNumber = mprParseVar(ep->token, type);
- inputPutback(ep, c);
- return EJS_TOK_NUMBER;
- }
- }
- /* Fall through to get more digits */
-
- case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- do {
- if (tokenAddChar(ep, c) < 0) {
- return EJS_TOK_ERR;
- }
- if ((c = inputGetc(ep)) < 0) {
- break;
- }
-#if BLD_FEATURE_FLOATING_POINT
- if (c == '.' || tolower(c) == 'e' || tolower(c) == 'f') {
- type = MPR_TYPE_FLOAT;
- }
- } while (isdigit(c) || c == '.' || tolower(c) == 'e' || tolower(c) == 'f' ||
- ((type == MPR_TYPE_FLOAT) && (c == '+' || c == '-')));
-#else
- } while (isdigit(c));
-#endif
-
- mprDestroyVar(&ep->tokenNumber);
- ep->tokenNumber = mprParseVar(ep->token, type);
- inputPutback(ep, c);
- return EJS_TOK_NUMBER;
-
- default:
- /*
- * Identifiers or a function names
- */
- while (1) {
- if (c == '\\') {
- if ((c = inputGetc(ep)) < 0) {
- break;
- }
- if (c == '\n' || c == '\r') {
- break;
- }
- } else if (tokenAddChar(ep, c) < 0) {
- break;
- }
- if ((c = inputGetc(ep)) < 0) {
- break;
- }
- if (!isalnum(c) && c != '$' && c != '_' && c != '\\') {
- break;
- }
- }
- if (*ep->token == '\0') {
- c = inputGetc(ep);
- break;
- }
- if (! isalpha((int) *ep->token) && *ep->token != '$' &&
- *ep->token != '_') {
- ejsError(ep, "Invalid identifier %s", ep->token);
- return EJS_TOK_ERR;
- }
-
- tid = checkReservedWord(ep, state, c, EJS_TOK_ID);
- if (tid != EJS_TOK_ID) {
- return tid;
- }
-
- /*
- * Skip white space after token to find out whether this is
- * a function or not.
- */
- while (c == ' ' || c == '\t' || c == '\r' || c == '\n') {
- if ((c = inputGetc(ep)) < 0)
- break;
- }
-
- tid = EJS_TOK_ID;
- done++;
- }
- }
-
- /*
- * Putback the last extra character for next time
- */
- inputPutback(ep, c);
- return tid;
-}
-
-/******************************************************************************/
-/*
- * Convert a hex or octal character back to binary, return original char if
- * not a hex digit
- */
-
-static int charConvert(Ejs *ep, int base, int maxDig)
-{
- int i, c, lval, convChar;
-
- lval = 0;
- for (i = 0; i < maxDig; i++) {
- if ((c = inputGetc(ep)) < 0) {
- break;
- }
- /*
- * Initialize to out of range value
- */
- convChar = base;
- if (isdigit(c)) {
- convChar = c - '0';
- } else if (c >= 'a' && c <= 'f') {
- convChar = c - 'a' + 10;
- } else if (c >= 'A' && c <= 'F') {
- convChar = c - 'A' + 10;
- }
- /*
- * If unexpected character then return it to buffer.
- */
- if (convChar >= base) {
- inputPutback(ep, c);
- break;
- }
- lval = (lval * base) + convChar;
- }
- return lval;
-}
-
-/******************************************************************************/
-/*
- * Putback the last token read. Accept at most one push back token.
- */
-
-void ejsLexPutbackToken(Ejs *ep, int tid, char *string)
-{
- EjsInput *ip;
- int idx;
-
- mprAssert(ep);
- ip = ep->input;
- mprAssert(ip);
-
- ip->putBackIndex += 1;
- idx = ip->putBackIndex;
- ip->putBack[idx].id = tid;
-
- if (ip->putBack[idx].token) {
- if (ip->putBack[idx].token == string) {
- return;
- }
- mprFree(ip->putBack[idx].token);
- }
- ip->putBack[idx].token = mprStrdup(string);
-}
-
-/******************************************************************************/
-/*
- * Add a character to the token buffer
- */
-
-static int tokenAddChar(Ejs *ep, int c)
-{
- EjsInput *ip;
- uchar *oldbuf;
-
- mprAssert(ep);
- ip = ep->input;
- mprAssert(ip);
-
- if (ip->tokEndp >= &ip->tokbuf[ip->tokSize - 1]) {
- ip->tokSize += EJS_PARSE_INCR;
- oldbuf = ip->tokbuf;
- ip->tokbuf = mprRealloc(ip->tokbuf, ip->tokSize);
- if (ip->tokbuf == 0) {
- ejsError(ep, "Token too big");
- return -1;
- }
- ip->tokEndp += (int) ((uchar*) ip->tokbuf - oldbuf);
- ip->tokServp += (int) ((uchar*) ip->tokbuf - oldbuf);
- ep->token += (int) ((uchar*) ip->tokbuf - oldbuf);
- }
- *ip->tokEndp++ = c;
- *ip->tokEndp = '\0';
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Get another input character
- */
-
-static int inputGetc(Ejs *ep)
-{
- EjsInput *ip;
- int c;
-
- mprAssert(ep);
- ip = ep->input;
-
- if (ip->scriptSize <= 0) {
- return -1;
- }
-
- c = (uchar) (*ip->scriptServp++);
- ip->scriptSize--;
-
- /*
- * For debugging, accumulate the line number and the currenly parsed line
- */
- if (c == '\n') {
-#if BLD_DEBUG && 0
- if (ip->lineColumn > 0) {
- printf("PARSED: %s\n", ip->line);
- }
-#endif
- ip->lineNumber++;
- ip->lineColumn = 0;
- } else {
- if ((ip->lineColumn + 2) >= ip->lineLength) {
- ip->lineLength += 80;
- ip->line = mprRealloc(ip->line, ip->lineLength * sizeof(char));
- }
- ip->line[ip->lineColumn++] = c;
- ip->line[ip->lineColumn] = '\0';
- }
- return c;
-}
-
-/******************************************************************************/
-/*
- * Putback a character onto the input queue
- */
-
-static void inputPutback(Ejs *ep, int c)
-{
- EjsInput *ip;
-
- mprAssert(ep);
-
- if (c != 0) {
- ip = ep->input;
- *--ip->scriptServp = c;
- ip->scriptSize++;
- ip->lineColumn--;
- ip->line[ip->lineColumn] = '\0';
- }
-}
-
-/******************************************************************************/
-
-#else
-void ejsLexDummy() {}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_EJS */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs/ejsLib.c b/source4/lib/appweb/ejs/ejsLib.c
deleted file mode 100644
index 67d0a4e760..0000000000
--- a/source4/lib/appweb/ejs/ejsLib.c
+++ /dev/null
@@ -1,1090 +0,0 @@
-/*
- * @file ejs.c
- * @brief Embedded JavaScript (EJS)
- * @overview Main module interface logic.
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default.g
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved.
- * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "ejsInternal.h"
-
-#if BLD_FEATURE_EJS
-
-/********************************** Local Data ********************************/
-
-/*
- * These fields must be locked before any access when multithreaded
- */
-static MprVar master; /* Master object */
-static MprArray *ejsList; /* List of ej handles */
-
-#if BLD_FEATURE_MULTITHREAD
-static EjsLock lock;
-static EjsUnlock unlock;
-static void *lockData;
-#define ejsLock() if (lock) { (lock)(lockData); } else
-#define ejsUnlock() if (unlock) { (unlock)(lockData); } else
-#else
-#define ejsLock()
-#define ejsUnlock()
-#endif
-
-
-/*
- save/restore global ejs state - used to cope with simultaneous ejs requests
- this is a workaround for the use of global variables in ejs
-*/
-struct ejs_state_ctx {
- MprVar master;
- MprArray *ejsList;
-};
-
-void *ejs_save_state(void)
-{
- struct ejs_state_ctx *ctx = talloc(talloc_autofree_context(), struct ejs_state_ctx);
- ctx->master = master;
- ctx->ejsList = ejsList;
- return ctx;
-}
-
-void ejs_restore_state(void *ptr)
-{
- struct ejs_state_ctx *ctx = talloc_get_type(ptr, struct ejs_state_ctx);
- master = ctx->master;
- ejsList = ctx->ejsList;
- talloc_free(ctx);
-}
-
-
-/****************************** Forward Declarations **************************/
-
-static char *getNextVarToken(char **next, char *tokBuf, int tokBufLen);
-
-/************************************* Code ***********************************/
-/*
- * Initialize the EJ subsystem
- */
-
-int ejsOpen(EjsLock lockFn, EjsUnlock unlockFn, void *data)
-{
- MprVar *np;
-
-#if BLD_FEATURE_MULTITHREAD
- if (lockFn) {
- lock = lockFn;
- unlock = unlockFn;
- lockData = data;
- }
-#endif
- ejsLock();
-
- /*
- * Master is the top level object (above global). It is used to clone its
- * contents into the global scope for each. This is never visible to the
- * user, so don't use ejsCreateObj().
- */
- master = mprCreateObjVar("master", EJS_SMALL_OBJ_HASH_SIZE);
- if (master.type == MPR_TYPE_UNDEFINED) {
- ejsUnlock();
- return MPR_ERR_CANT_ALLOCATE;
- }
-
- ejsList = mprCreateArray();
- ejsDefineStandardProperties(&master);
-
- /*
- * Make these objects immutable
- */
- np = mprGetFirstProperty(&master, MPR_ENUM_FUNCTIONS | MPR_ENUM_DATA);
- while (np) {
- mprSetVarReadonly(np, 1);
- np = mprGetNextProperty(&master, np, MPR_ENUM_FUNCTIONS |
- MPR_ENUM_DATA);
- }
- ejsUnlock();
- return 0;
-}
-
-/******************************************************************************/
-
-void ejsClose()
-{
- ejsLock();
- mprDestroyArray(ejsList);
- mprDestroyVar(&master);
- ejsUnlock();
-}
-
-/******************************************************************************/
-/*
- * Create and initialize an EJS engine
- */
-
-EjsId ejsOpenEngine(EjsHandle primaryHandle, EjsHandle altHandle)
-{
- MprVar *np;
- Ejs *ep;
-
- ep = (Ejs *)mprMalloc(sizeof(Ejs));
- if (ep == 0) {
- return (EjsId) -1;
- }
- memset(ep, 0, sizeof(Ejs));
-
- ejsLock();
- ep->eid = (EjsId) mprAddToArray(ejsList, ep);
- ejsUnlock();
-
- /*
- * Create array of local variable frames
- */
- ep->frames = mprCreateArray();
- if (ep->frames == 0) {
- ejsCloseEngine(ep->eid);
- return (EjsId) -1;
- }
- ep->primaryHandle = primaryHandle;
- ep->altHandle = altHandle;
-
- /*
- * Create first frame: global variables
- */
- ep->global = (MprVar*) mprMalloc(sizeof(MprVar));
- *ep->global = ejsCreateObj("global", EJS_OBJ_HASH_SIZE);
- if (ep->global->type == MPR_TYPE_UNDEFINED) {
- ejsCloseEngine(ep->eid);
- return (EjsId) -1;
- }
- mprAddToArray(ep->frames, ep->global);
-
- /*
- * Create first local variable frame
- */
- ep->local = (MprVar*) mprMalloc(sizeof(MprVar));
- *ep->local = ejsCreateObj("local", EJS_OBJ_HASH_SIZE);
- if (ep->local->type == MPR_TYPE_UNDEFINED) {
- ejsCloseEngine(ep->eid);
- return (EjsId) -1;
- }
- mprAddToArray(ep->frames, ep->local);
-
- /*
- * Clone all master variables into the global frame. This does a
- * reference copy.
- *
- * ejsDefineStandardProperties(ep->global);
- */
- np = mprGetFirstProperty(&master, MPR_ENUM_FUNCTIONS | MPR_ENUM_DATA);
- while (np) {
- mprCreateProperty(ep->global, np->name, np);
- np = mprGetNextProperty(&master, np, MPR_ENUM_FUNCTIONS |
- MPR_ENUM_DATA);
- }
-
- mprCreateProperty(ep->global, "global", ep->global);
- mprCreateProperty(ep->global, "this", ep->global);
- mprCreateProperty(ep->local, "local", ep->local);
-
- return ep->eid;
-}
-
-/******************************************************************************/
-/*
- * Close an EJS instance
- */
-
-void ejsCloseEngine(EjsId eid)
-{
- Ejs *ep;
- MprVar *vp;
- void **handles;
- int i;
-
- if ((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- return;
- }
-
- mprFree(ep->error);
- mprDestroyVar(&ep->result);
- mprDestroyVar(&ep->tokenNumber);
-
- if (ep->local) {
- mprDeleteProperty(ep->local, "local");
- }
- mprDeleteProperty(ep->global, "this");
- mprDeleteProperty(ep->global, "global");
-
- handles = ep->frames->handles;
- for (i = 0; i < ep->frames->max; i++) {
- vp = handles[i];
- if (vp) {
-#if BLD_DEBUG
- if (vp->type == MPR_TYPE_OBJECT && vp->properties->refCount > 1) {
- mprLog(7, "ejsCloseEngine: %s has ref count %d\n",
- vp->name, vp->properties->refCount);
- }
-#endif
- mprDestroyVar(vp);
- mprFree(vp);
- mprRemoveFromArray(ep->frames, i);
- }
- }
- mprDestroyArray(ep->frames);
-
- ejsLock();
- mprRemoveFromArray(ejsList, (int) ep->eid);
- ejsUnlock();
-
- mprFree(ep);
-}
-
-/******************************************************************************/
-/*
- * Evaluate an EJS script file
- */
-
-int ejsEvalFile(EjsId eid, char *path, MprVar *result, char **emsg)
-{
- struct stat sbuf;
- Ejs *ep;
- char *script;
- int rc, fd;
-
- mprAssert(path && *path);
-
- if (emsg) {
- *emsg = NULL;
- }
-
- if ((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- goto error;
- }
-
- if ((fd = open(path, O_RDONLY | O_BINARY, 0666)) < 0) {
- ejsError(ep, "Can't open %s\n", path);
- goto error;
- }
-
- if (stat(path, &sbuf) < 0) {
- close(fd);
- ejsError(ep, "Cant stat %s", path);
- goto error;
- }
-
- if ((script = (char*) mprMalloc(sbuf.st_size + 1)) == NULL) {
- close(fd);
- ejsError(ep, "Cant malloc %d", (int) sbuf.st_size);
- goto error;
- }
-
- if (read(fd, script, sbuf.st_size) != (int) sbuf.st_size) {
- close(fd);
- mprFree(script);
- ejsError(ep, "Error reading %s", path);
- goto error;
- }
-
- script[sbuf.st_size] = '\0';
- close(fd);
-
- rc = ejsEvalBlock(eid, script, result, emsg);
- mprFree(script);
-
- return rc;
-
-/*
- * Error return
- */
-error:
- if(emsg)
- *emsg = mprStrdup(ep->error);
- return -1;
-}
-
-/******************************************************************************/
-/*
- * Create a new variable scope block. This pushes the old local frame down
- * the stack and creates a new local variables frame.
- */
-
-int ejsOpenBlock(EjsId eid)
-{
- Ejs *ep;
-
- if((ep = ejsPtr(eid)) == NULL) {
- return -1;
- }
-
- ep->local = (MprVar*) mprMalloc(sizeof(MprVar));
- *ep->local = ejsCreateObj("localBlock", EJS_OBJ_HASH_SIZE);
-
- mprCreateProperty(ep->local, "local", ep->local);
-
- return mprAddToArray(ep->frames, ep->local);
-}
-
-/******************************************************************************/
-/*
- * Close a variable scope block opened via ejsOpenBlock. Pop back the old
- * local variables frame.
- */
-
-int ejsCloseBlock(EjsId eid, int fid)
-{
- Ejs *ep;
-
- if((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- return -1;
- }
-
- /*
- * Must remove self-references before destroying "local"
- */
- mprDeleteProperty(ep->local, "local");
-
- mprDestroyVar(ep->local);
- mprFree(ep->local);
-
- mprRemoveFromArray(ep->frames, fid);
- ep->local = (MprVar*) ep->frames->handles[ep->frames->used - 1];
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Create a new variable scope block and evaluate a script. All frames
- * created during this context will be automatically deleted when complete.
- * vp and emsg are optional. i.e. created local variables will be discarded
- * when this routine returns.
- */
-
-int ejsEvalBlock(EjsId eid, char *script, MprVar *vp, char **emsg)
-{
- int rc, fid;
-
- mprAssert(script);
-
- fid = ejsOpenBlock(eid);
- rc = ejsEvalScript(eid, script, vp, emsg);
- ejsCloseBlock(eid, fid);
-
- return rc;
-}
-
-/******************************************************************************/
-/*
- * Parse and evaluate a EJS. Return the result in *vp. The result is "owned"
- * by EJ and the caller must not free it. Returns -1 on errors and zero
- * for success. On errors, emsg will be set to the reason. The caller must
- * free emsg.
- */
-
-int ejsEvalScript(EjsId eid, char *script, MprVar *vp, char **emsg)
-{
- Ejs *ep;
- int state;
- void *endlessLoopTest;
- int loopCounter;
-
- if (emsg) {
- *emsg = NULL;
- }
-
- if ((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- return -1;
- }
-
- mprDestroyVar(&ep->result);
-
- if (script == 0) {
- return 0;
- }
-
- /*
- * Allocate a new evaluation block, and save the old one
- */
- ejsLexOpenScript(ep, script);
-
- /*
- * Do the actual parsing and evaluation
- */
- loopCounter = 0;
- endlessLoopTest = NULL;
- ep->exitStatus = 0;
-
- do {
- state = ejsParse(ep, EJS_STATE_BEGIN, EJS_FLAGS_EXE);
-
- if (state == EJS_STATE_RET) {
- state = EJS_STATE_EOF;
- }
- /*
- * Stuck parser and endless recursion protection.
- */
- if (endlessLoopTest == ep->input->scriptServp) {
- if (loopCounter++ > 10) {
- state = EJS_STATE_ERR;
- ejsError(ep, "Syntax error");
- }
- } else {
- endlessLoopTest = ep->input->scriptServp;
- loopCounter = 0;
- }
- } while (state != EJS_STATE_EOF && state != EJS_STATE_ERR);
-
- ejsLexCloseScript(ep);
-
- /*
- * Return any error string to the user
- */
- if (state == EJS_STATE_ERR && emsg) {
- *emsg = mprStrdup(ep->error);
- }
-
- if (state == EJS_STATE_ERR) {
- return -1;
- }
-
- if (vp) {
- *vp = ep->result;
- }
-
- return ep->exitStatus;
-}
-
-/******************************************************************************/
-/*
- * Core error handling
- */
-
-static void ejsErrorCore(Ejs* ep, const char *fmt, va_list args)
- PRINTF_ATTRIBUTE(2, 0);
-
-static void ejsErrorCore(Ejs* ep, const char *fmt, va_list args)
-{
- EjsInput *ip;
- char *errbuf, *msgbuf;
- int frame = 0;
-
- mprAssert(ep);
-
- msgbuf = NULL;
- mprAllocVsprintf(&msgbuf, MPR_MAX_STRING, fmt, args);
-
- ip = ep->input;
- mprAllocSprintf(&errbuf, MPR_MAX_STRING, "%s\nBacktrace:\n", msgbuf);
-
- /* form a backtrace */
- while (ip) {
- char *msg2, *ebuf2;
- mprAllocSprintf(&msg2, MPR_MAX_STRING,
- "\t[%2d] %20s:%-4d -> %s\n",
- frame++, ip->procName?ip->procName:"", ip->lineNumber, ip->line);
- ebuf2 = mprRealloc(errbuf, strlen(errbuf) + strlen(msg2) + 1);
- if (ebuf2 == NULL) break;
- errbuf = ebuf2;
- memcpy(errbuf+strlen(errbuf), msg2, strlen(msg2)+1);
- mprFree(msg2);
- ip = ip->next;
- }
- mprFree(ep->error);
- ep->error = errbuf;
- mprFree(msgbuf);
-}
-
-/******************************************************************************/
-/*
- * Internal use function to set the error message
- */
-
-void ejsError(Ejs* ep, const char* fmt, ...)
-{
- va_list args;
-
- va_start(args, fmt);
- ejsErrorCore(ep, fmt, args);
- va_end(args);
-}
-
-/******************************************************************************/
-/*
- * Public routine to set the error message
- */
-
-void ejsSetErrorMsg(EjsId eid, const char* fmt, ...)
-{
- va_list args;
- Ejs *ep;
-
- if ((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- return;
- }
- va_start(args, fmt);
- ejsErrorCore(ep, fmt, args);
- va_end(args);
-}
-
-/******************************************************************************/
-/*
- * Get the current line number
- */
-
-int ejsGetLineNumber(EjsId eid)
-{
- Ejs *ep;
-
- if ((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- return -1;
- }
- return ep->input->lineNumber;
-}
-
-/******************************************************************************/
-/*
- * Return the local object
- */
-
-MprVar *ejsGetLocalObject(EjsId eid)
-{
- Ejs *ep;
-
- if ((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- return 0;
- }
- return ep->local;
-}
-
-/******************************************************************************/
-/*
- * Return the global object
- */
-
-MprVar *ejsGetGlobalObject(EjsId eid)
-{
- Ejs *ep;
-
- if ((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- return 0;
- }
- return ep->global;
-}
-
-/******************************************************************************/
-/*
- * Copy the value of an object property. Return value is in "value".
- * If deepCopy is true, copy all object/strings. Otherwise, object reference
- * counts are incremented. Callers must always call mprDestroyVar on the
- * return value to prevent leaks.
- *
- * Returns: -1 on errors or if the variable is not found.
- */
-
-int ejsCopyVar(EjsId eid, const char *var, MprVar *value, bool deepCopy)
-{
- Ejs *ep;
- MprVar *vp;
-
- mprAssert(var && *var);
- mprAssert(value);
-
- if ((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- return -1;
- }
-
- if (ejsGetVarCore(ep, var, 0, &vp, 0) < 0) {
- return -1;
- }
-
- return mprCopyProperty(value, vp, deepCopy);
-}
-
-/******************************************************************************/
-/*
- * Return the value of an object property. Return value is in "value".
- * Objects and strings are not copied and reference counts are not modified.
- * Callers should NOT call mprDestroyVar. Returns: -1 on errors or if the
- * variable is not found.
- */
-
-int ejsReadVar(EjsId eid, const char *var, MprVar *value)
-{
- Ejs *ep;
- MprVar *vp;
-
- mprAssert(var && *var);
- mprAssert(value);
-
- if ((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- return -1;
- }
-
- if (ejsGetVarCore(ep, var, 0, &vp, 0) < 0) {
- return -1;
- }
-
- return mprReadProperty(vp, value);
-}
-
-/******************************************************************************/
-/*
- * Set a variable that may be an arbitrarily complex object or array reference.
- * Will always define in the top most variable frame.
- */
-
-int ejsWriteVar(EjsId eid, const char *var, MprVar *value)
-{
- Ejs *ep;
- MprVar *vp;
-
- mprAssert(var && *var);
-
- if ((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- return -1;
- }
-
- if (ejsGetVarCore(ep, var, 0, &vp, EJS_FLAGS_CREATE) < 0) {
- return -1;
- }
- mprAssert(vp);
-
- /*
- * Only copy the value. Don't overwrite the object's name
- */
- mprWriteProperty(vp, value);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Set a variable that may be an arbitrarily complex object or array reference.
- * Will always define in the top most variable frame.
- */
-
-int ejsWriteVarValue(EjsId eid, const char *var, MprVar value)
-{
- return ejsWriteVar(eid, var, &value);
-}
-
-/******************************************************************************/
-/*
- * Delete a variable
- */
-
-int ejsDeleteVar(EjsId eid, const char *var)
-{
- Ejs *ep;
- MprVar *vp;
- MprVar *obj;
-
- if ((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- return -1;
- }
- if (ejsGetVarCore(ep, var, &obj, &vp, 0) < 0) {
- return -1;
- }
- mprDeleteProperty(obj, vp->name);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Set the expression return value
- */
-
-void ejsSetReturnValue(EjsId eid, MprVar value)
-{
- Ejs *ep;
-
- if ((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- return;
- }
- mprCopyVar(&ep->result, &value, MPR_SHALLOW_COPY);
-}
-
-/******************************************************************************/
-/*
- * Set the expression return value to a string value
- */
-
-void ejsSetReturnString(EjsId eid, const char *str)
-{
- Ejs *ep;
-
- if ((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- return;
- }
- mprCopyVarValue(&ep->result, mprCreateStringVar(str, 0), MPR_SHALLOW_COPY);
-}
-
-/******************************************************************************/
-/*
- * Get the expression return value
- */
-
-MprVar *ejsGetReturnValue(EjsId eid)
-{
- Ejs *ep;
-
- if ((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- return 0;
- }
- return &ep->result;
-}
-
-/******************************************************************************/
-/*
- * Define a C function. If eid < 0, then update the master object with this
- * function. NOTE: in this case, functionName must be simple without any "." or
- * "[]" elements. If eid >= 0, add to the specified script engine. In this
- * case, functionName can be an arbitrary object reference and can contain "."
- * or "[]".
- */
-
-void ejsDefineCFunction(EjsId eid, const char *functionName, MprCFunction fn,
- void *thisPtr, int flags)
-{
- if (eid < 0) {
- ejsLock();
- mprCreatePropertyValue(&master, functionName,
- mprCreateCFunctionVar(fn, thisPtr, flags));
- ejsUnlock();
- } else {
- ejsWriteVarValue(eid, functionName,
- mprCreateCFunctionVar(fn, thisPtr, flags));
- }
-}
-
-/******************************************************************************/
-/*
- * Define a C function with String arguments
- */
-
-void ejsDefineStringCFunction(EjsId eid, const char *functionName,
- MprStringCFunction fn, void *thisPtr, int flags)
-{
- if (eid < 0) {
- ejsLock();
- mprCreatePropertyValue(&master, functionName,
- mprCreateStringCFunctionVar(fn, thisPtr, flags));
- ejsUnlock();
- } else {
- ejsWriteVarValue(eid, functionName,
- mprCreateStringCFunctionVar(fn, thisPtr, flags));
- }
-}
-
-/******************************************************************************/
-/*
- * Define a JavaScript function. Args should be comma separated.
- * Body should not contain braces.
- */
-
-void ejsDefineFunction(EjsId eid, const char *functionName, char *args,
- char *body)
-{
- MprVar v;
-
- v = mprCreateFunctionVar(args, body, 0);
- if (eid < 0) {
- ejsLock();
- mprCreateProperty(&master, functionName, &v);
- ejsUnlock();
- } else {
- ejsWriteVar(eid, functionName, &v);
- }
- mprDestroyVar(&v);
-}
-
-/******************************************************************************/
-
-void *ejsGetThisPtr(EjsId eid)
-{
- Ejs *ep;
-
- if ((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- return 0;
- }
- return ep->thisPtr;
-}
-
-/******************************************************************************/
-/*
- * Find a variable given a variable name and return the parent object and
- * the variable itself, the variable . This routine supports variable names
- * that may be objects or arrays but may NOT have expressions in the array
- * indicies. Returns -1 on errors or if the variable is not found.
- */
-
-int ejsGetVarCore(Ejs *ep, const char *vname, MprVar **obj,
- MprVar **varValue, int flags)
-{
- MprVar *currentObj;
- MprVar *currentVar;
- char tokBuf[EJS_MAX_ID];
- char *propertyName, *token, *next, *cp, *varName;
-
- if (obj) {
- *obj = 0;
- }
- if (varValue) {
- *varValue = 0;
- }
- currentObj = ejsFindObj(ep, 0, vname, flags);
- currentVar = 0;
- propertyName = 0;
-
- next = varName = mprStrdup(vname);
-
- token = getNextVarToken(&next, tokBuf, sizeof(tokBuf));
-
- while (currentObj != 0 && token != 0 && *token) {
-
- if (*token == '[') {
- token = getNextVarToken(&next, tokBuf, sizeof(tokBuf));
-
- propertyName = token;
- if (*propertyName == '\"') {
- propertyName++;
- if ((cp = strchr(propertyName, '\"')) != 0) {
- *cp = '\0';
- }
- } else if (*propertyName == '\'') {
- propertyName++;
- if ((cp = strchr(propertyName, '\'')) != 0) {
- *cp = '\0';
- }
- }
-
- currentObj = currentVar;
- currentVar = ejsFindProperty(ep, 0, currentObj, propertyName, 0);
-
- token = getNextVarToken(&next, tokBuf, sizeof(tokBuf));
- if (*token != ']') {
- mprFree(varName);
- return -1;
- }
-
- } else if (*token == '.') {
- token = getNextVarToken(&next, tokBuf, sizeof(tokBuf));
- if (!isalpha((int) token[0]) &&
- token[0] != '_' && token[0] != '$') {
- mprFree(varName);
- return -1;
- }
-
- propertyName = token;
- currentObj = currentVar;
- currentVar = ejsFindProperty(ep, 0, currentObj, token, 0);
-
- } else {
- currentVar = ejsFindProperty(ep, 0, currentObj, token, 0);
- }
- token = getNextVarToken(&next, tokBuf, sizeof(tokBuf));
- }
- mprFree(varName);
-
- if (currentVar == 0 && currentObj >= 0 && flags & EJS_FLAGS_CREATE) {
- currentVar = mprCreatePropertyValue(currentObj, propertyName,
- mprCreateUndefinedVar());
- }
- if (obj) {
- *obj = currentObj;
- }
-
- /*
- * Don't use mprCopyVar as it will copy the data
- */
- if (varValue) {
- *varValue = currentVar;
- }
- return currentVar ? 0 : -1;
-}
-
-/******************************************************************************/
-/*
- * Get the next token as part of a variable specification. This will return
- * a pointer to the next token and will return a pointer to the next token
- * (after this one) in "next". The tokBuf holds the parsed token.
- */
-static char *getNextVarToken(char **next, char *tokBuf, int tokBufLen)
-{
- char *start, *cp;
- int len;
-
- start = *next;
- while (isspace((int) *start) || *start == '\n' || *start == '\r') {
- start++;
- }
- cp = start;
-
- if (*cp == '.' || *cp == '[' || *cp == ']') {
- cp++;
- } else {
- while (*cp && *cp != '.' && *cp != '[' && *cp != ']' &&
- !isspace((int) *cp) && *cp != '\n' && *cp != '\r') {
- cp++;
- }
- }
- len = mprMemcpy(tokBuf, tokBufLen - 1, start, cp - start);
- tokBuf[len] = '\0';
-
- *next = cp;
- return tokBuf;
-}
-
-/******************************************************************************/
-/*
- * Get the EJS structure pointer
- */
-
-Ejs *ejsPtr(EjsId eid)
-{
- Ejs *handle;
- int intId;
-
- intId = (int) eid;
-
- ejsLock();
- mprAssert(0 <= intId && intId < ejsList->max);
-
- if (intId < 0 || intId >= ejsList->max || ejsList->handles[intId] == NULL) {
- mprAssert(0);
- ejsUnlock();
- return NULL;
- }
- handle = ejsList->handles[intId];
- ejsUnlock();
- return handle;
-}
-
-/******************************************************************************/
-/*
- * Utility routine to crack JavaScript arguments. Return the number of args
- * seen. This routine only supports %s and %d type args.
- *
- * Typical usage:
- *
- * if (ejsParseArgs(argc, argv, "%s %d", &name, &age) < 2) {
- * mprError("Insufficient args\n");
- * return -1;
- * }
- */
-
-int ejsParseArgs(int argc, char **argv, char *fmt, ...)
-{
- va_list vargs;
- bool *bp;
- char *cp, **sp, *s;
- int *ip, argn;
-
- va_start(vargs, fmt);
-
- if (argv == 0) {
- return 0;
- }
-
- for (argn = 0, cp = fmt; cp && *cp && argn < argc && argv[argn]; ) {
- if (*cp++ != '%') {
- continue;
- }
-
- s = argv[argn];
- switch (*cp) {
- case 'b':
- bp = va_arg(vargs, bool*);
- if (bp) {
- if (strcmp(s, "true") == 0 || s[0] == '1') {
- *bp = 1;
- } else {
- *bp = 0;
- }
- } else {
- *bp = 0;
- }
- break;
-
- case 'd':
- ip = va_arg(vargs, int*);
- *ip = atoi(s);
- break;
-
- case 's':
- sp = va_arg(vargs, char**);
- *sp = s;
- break;
-
- default:
- mprAssert(0);
- }
- argn++;
- }
-
- va_end(vargs);
- return argn;
-}
-
-/******************************************************************************/
-
-#else
-void ejsDummy() {}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_EJS */
-
-/******************************************************************************/
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs/ejsParser.c b/source4/lib/appweb/ejs/ejsParser.c
deleted file mode 100644
index da922a5728..0000000000
--- a/source4/lib/appweb/ejs/ejsParser.c
+++ /dev/null
@@ -1,2436 +0,0 @@
-/*
- * @file ejsParser.c
- * @brief EJS Parser and Execution
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default.g
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved.
- * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/********************************** Includes **********************************/
-
-#include "ejsInternal.h"
-
-#if BLD_FEATURE_EJS
-
-/****************************** Forward Declarations **************************/
-
-static void appendValue(MprVar *v1, MprVar *v2);
-static int evalCond(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs);
-static int evalExpr(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs);
-#if BLD_FEATURE_FLOATING_POINT
-static int evalFloatExpr(Ejs *ep, double l, int rel, double r);
-#endif
-static int evalBoolExpr(Ejs *ep, bool l, int rel, bool r);
-static int evalPtrExpr(Ejs *ep, void *l, int rel, void *r);
-static int evalNumericExpr(Ejs *ep, MprNum l, int rel, MprNum r);
-static int evalStringExpr(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs);
-static int evalFunction(Ejs *ep, MprVar *obj, int flags);
-static void freeProc(EjsProc *proc);
-static int parseArgs(Ejs *ep, int state, int flags);
-static int parseAssignment(Ejs *ep, int state, int flags, char *id,
- char *fullName);
-static int parseCond(Ejs *ep, int state, int flags);
-static int parseDeclaration(Ejs *ep, int state, int flags);
-static int parseExpr(Ejs *ep, int state, int flags);
-static int parseFor(Ejs *ep, int state, int flags);
-static int parseForIn(Ejs *ep, int state, int flags);
-static int parseFunctionDec(Ejs *ep, int state, int flags);
-static int parseFunction(Ejs *ep, int state, int flags, char *id);
-static int parseId(Ejs *ep, int state, int flags, char **id,
- char **fullName, int *fullNameLen, int *done);
-static int parseInc(Ejs *ep, int state, int flags);
-static int parseIf(Ejs *ep, int state, int flags, int *done);
-static int parseStmt(Ejs *ep, int state, int flags);
-static void removeNewlines(Ejs *ep, int state);
-static void updateResult(Ejs *ep, int state, int flags, MprVar *vp);
-
-/************************************* Code ***********************************/
-/*
- * Recursive descent parser for EJS
- */
-
-int ejsParse(Ejs *ep, int state, int flags)
-{
- mprAssert(ep);
-
- switch (state) {
- /*
- * Any statement, function arguments or conditional expressions
- */
- case EJS_STATE_STMT:
- if ((state = parseStmt(ep, state, flags)) != EJS_STATE_STMT_DONE &&
- state != EJS_STATE_EOF && state != EJS_STATE_STMT_BLOCK_DONE &&
- state != EJS_STATE_RET) {
- state = EJS_STATE_ERR;
- }
- break;
-
- case EJS_STATE_DEC:
- if ((state = parseStmt(ep, state, flags)) != EJS_STATE_DEC_DONE &&
- state != EJS_STATE_EOF) {
- state = EJS_STATE_ERR;
- }
- break;
-
- case EJS_STATE_EXPR:
- if ((state = parseStmt(ep, state, flags)) != EJS_STATE_EXPR_DONE &&
- state != EJS_STATE_EOF) {
- state = EJS_STATE_ERR;
- }
- break;
-
- /*
- * Variable declaration list
- */
- case EJS_STATE_DEC_LIST:
- state = parseDeclaration(ep, state, flags);
- break;
-
- /*
- * Function argument string
- */
- case EJS_STATE_ARG_LIST:
- state = parseArgs(ep, state, flags);
- break;
-
- /*
- * Logical condition list (relational operations separated by &&, ||)
- */
- case EJS_STATE_COND:
- state = parseCond(ep, state, flags);
- break;
-
- /*
- * Expression list
- */
- case EJS_STATE_RELEXP:
- state = parseExpr(ep, state, flags);
- break;
- }
-
- if (state == EJS_STATE_ERR && ep->error == NULL) {
- ejsError(ep, "Syntax error");
- }
- return state;
-}
-
-/******************************************************************************/
-/*
- * Parse any statement including functions and simple relational operations
- */
-
-static int parseStmt(Ejs *ep, int state, int flags)
-{
- EjsProc *saveProc;
- MprVar *vp, *saveObj;
- char *id, *fullName, *initToken;
- int done, expectSemi, tid, fullNameLen, rel;
- int initId;
-
- mprAssert(ep);
-
- expectSemi = 0;
- saveProc = NULL;
- id = 0;
- fullName = 0;
- fullNameLen = 0;
-
- ep->currentObj = 0;
- ep->currentProperty = 0;
-
- for (done = 0; !done && state != EJS_STATE_ERR; ) {
- tid = ejsLexGetToken(ep, state);
-
- switch (tid) {
- default:
- ejsLexPutbackToken(ep, EJS_TOK_EXPR, ep->token);
- done++;
- break;
-
- case EJS_TOK_EXPR:
- rel = (int) *ep->token;
- if (state == EJS_STATE_EXPR) {
- ejsLexPutbackToken(ep, EJS_TOK_EXPR, ep->token);
- }
- done++;
- break;
-
- case EJS_TOK_LOGICAL:
- ejsLexPutbackToken(ep, tid, ep->token);
- done++;
- break;
-
- case EJS_TOK_ERR:
- state = EJS_STATE_ERR;
- done++;
- break;
-
- case EJS_TOK_EOF:
- state = EJS_STATE_EOF;
- done++;
- break;
-
- case EJS_TOK_NEWLINE:
- break;
-
- case EJS_TOK_SEMI:
- /*
- * This case is when we discover no statement and just a lone ';'
- */
- if (state != EJS_STATE_STMT) {
- ejsLexPutbackToken(ep, tid, ep->token);
- }
- done++;
- break;
-
- case EJS_TOK_PERIOD:
- if (flags & EJS_FLAGS_EXE) {
- if (ep->currentProperty == 0) {
- ejsError(ep, "Undefined object \"%s\"\n", id);
- goto error;
- }
- }
- ep->currentObj = ep->currentProperty;
-
- if ((tid = ejsLexGetToken(ep, state)) != EJS_TOK_ID) {
- ejsError(ep, "Bad property after '.': %s\n", ep->token);
- goto error;
- }
- mprFree(id);
- id = mprStrdup(ep->token);
-
- vp = ejsFindProperty(ep, state, ep->currentObj, id, flags);
- updateResult(ep, state, flags, vp);
-
-#if BLD_DEBUG
- fullNameLen = mprReallocStrcat(&fullName, MPR_MAX_VAR, fullNameLen,
- 0, ".", NULL);
-#endif
-
- ep->currentProperty = vp;
- ejsLexPutbackToken(ep, tid, ep->token);
- break;
-
- case EJS_TOK_LBRACKET:
- ep->currentObj = ep->currentProperty;
- saveObj = ep->currentObj;
- if (ejsParse(ep, EJS_STATE_RELEXP, flags) != EJS_STATE_RELEXP_DONE){
- goto error;
- }
- ep->currentObj = saveObj;
-
- mprFree(id);
- mprVarToString(&id, MPR_MAX_STRING, 0, &ep->result);
-
- if (id[0] == '\0') {
- if (flags & EJS_FLAGS_EXE) {
- ejsError(ep,
- "[] expression evaluates to the empty string\n");
- goto error;
- }
- } else {
- vp = ejsFindProperty(ep, state, ep->currentObj, id, flags);
- ep->currentProperty = vp;
- updateResult(ep, state, flags, vp);
- }
-
-#if BLD_DEBUG
- if (id[0] && strlen(id) < (MPR_MAX_VAR / 2)) {
- /*
- * If not executing yet, id may not be known
- */
- fullNameLen = mprReallocStrcat(&fullName, MPR_MAX_VAR,
- fullNameLen, 0, "[", id, "]", NULL);
- }
-#endif
-
- if ((tid = ejsLexGetToken(ep, state)) != EJS_TOK_RBRACKET) {
- ejsError(ep, "Missing ']'\n");
- goto error;
- }
- break;
-
- case EJS_TOK_ID:
- state = parseId(ep, state, flags, &id, &fullName, &fullNameLen,
- &done);
- if (done && state == EJS_STATE_STMT) {
- expectSemi++;
- }
- break;
-
- case EJS_TOK_ASSIGNMENT:
- state = parseAssignment(ep, state, flags, id, fullName);
- if (state == EJS_STATE_STMT) {
- expectSemi++;
- done++;
- }
- break;
-
- case EJS_TOK_INC_DEC:
- state = parseInc(ep, state, flags);
- if (state == EJS_STATE_STMT) {
- expectSemi++;
- }
- break;
-
- case EJS_TOK_NEW:
- if (ejsParse(ep, EJS_STATE_EXPR, flags | EJS_FLAGS_NEW)
- != EJS_STATE_EXPR_DONE) {
- goto error;
- }
- break;
-
- case EJS_TOK_DELETE:
- if (ejsParse(ep, EJS_STATE_EXPR,
- flags | EJS_FLAGS_DELETE) != EJS_STATE_EXPR_DONE) {
- goto error;
- }
- if (flags & EJS_FLAGS_EXE) {
- mprDeleteProperty(ep->currentObj, ep->currentProperty->name);
- }
- done++;
- break;
-
- case EJS_TOK_FUNCTION:
- state = parseFunctionDec(ep, state, flags);
- done++;
- break;
-
- case EJS_TOK_LITERAL:
- /*
- * Set the result to the string literal
- */
- mprCopyVarValue(&ep->result, mprCreateStringVar(ep->token, 0),
- MPR_SHALLOW_COPY);
- if (state == EJS_STATE_STMT) {
- expectSemi++;
- }
- done++;
- break;
-
- case EJS_TOK_NUMBER:
- /*
- * Set the result to the parsed number
- */
- mprCopyVar(&ep->result, &ep->tokenNumber, 0);
- if (state == EJS_STATE_STMT) {
- expectSemi++;
- }
- done++;
- break;
-
- case EJS_TOK_FUNCTION_NAME:
- state = parseFunction(ep, state, flags, id);
- if (state == EJS_STATE_STMT) {
- expectSemi++;
- }
- if (ep->flags & EJS_FLAGS_EXIT) {
- state = EJS_STATE_RET;
- }
- done++;
- break;
-
- case EJS_TOK_IF:
- state = parseIf(ep, state, flags, &done);
- if (state == EJS_STATE_RET) {
- goto doneParse;
- }
- break;
-
- case EJS_TOK_FOR:
- if (state != EJS_STATE_STMT) {
- goto error;
- }
- if (ejsLexGetToken(ep, state) != EJS_TOK_LPAREN) {
- goto error;
- }
- /*
- * Need to peek 2-3 tokens ahead and see if this is a
- * for ([var] x in set)
- * or
- * for (init ; whileCond; incr)
- */
- initId = ejsLexGetToken(ep, EJS_STATE_EXPR);
- if (initId == EJS_TOK_ID && strcmp(ep->token, "var") == 0) {
- /* Simply eat var tokens */
- initId = ejsLexGetToken(ep, EJS_STATE_EXPR);
- }
- initToken = mprStrdup(ep->token);
-
- tid = ejsLexGetToken(ep, EJS_STATE_EXPR);
-
- ejsLexPutbackToken(ep, tid, ep->token);
- ejsLexPutbackToken(ep, initId, initToken);
- mprFree(initToken);
-
- if (tid == EJS_TOK_IN) {
- if ((state = parseForIn(ep, state, flags)) < 0) {
- goto error;
- }
- } else {
- if ((state = parseFor(ep, state, flags)) < 0) {
- goto error;
- }
- }
- done++;
- break;
-
- case EJS_TOK_VAR:
- if (ejsParse(ep, EJS_STATE_DEC_LIST, flags)
- != EJS_STATE_DEC_LIST_DONE) {
- goto error;
- }
- done++;
- break;
-
- case EJS_TOK_COMMA:
- ejsLexPutbackToken(ep, tid, ep->token);
- done++;
- break;
-
- case EJS_TOK_LPAREN:
- if (state == EJS_STATE_EXPR) {
- if (ejsParse(ep, EJS_STATE_RELEXP, flags)
- != EJS_STATE_RELEXP_DONE) {
- goto error;
- }
- if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) {
- goto error;
- }
- }
- done++;
- break;
-
- case EJS_TOK_RPAREN:
- ejsLexPutbackToken(ep, tid, ep->token);
- done++;
- break;
-
- case EJS_TOK_LBRACE:
- /*
- * This handles any code in braces except "if () {} else {}"
- */
- if (state != EJS_STATE_STMT) {
- goto error;
- }
-
- /*
- * Parse will return EJS_STATE_STMT_BLOCK_DONE when the RBRACE
- * is seen.
- */
- do {
- state = ejsParse(ep, EJS_STATE_STMT, flags);
- } while (state == EJS_STATE_STMT_DONE);
-
- if (state != EJS_STATE_RET) {
- if (ejsLexGetToken(ep, state) != EJS_TOK_RBRACE) {
- goto error;
- }
- state = EJS_STATE_STMT_DONE;
- }
- done++;
- break;
-
- case EJS_TOK_RBRACE:
- if (state == EJS_STATE_STMT) {
- ejsLexPutbackToken(ep, tid, ep->token);
- state = EJS_STATE_STMT_BLOCK_DONE;
- done++;
- break;
- }
- goto error;
-
- case EJS_TOK_RETURN:
- if (ejsParse(ep, EJS_STATE_RELEXP, flags)
- != EJS_STATE_RELEXP_DONE) {
- goto error;
- }
- if (flags & EJS_FLAGS_EXE) {
- while (ejsLexGetToken(ep, state) != EJS_TOK_EOF) {
- ;
- }
- state = EJS_STATE_RET;
- done++;
- }
- break;
- }
- }
-
- if (expectSemi) {
- tid = ejsLexGetToken(ep, state);
- if (tid != EJS_TOK_SEMI && tid != EJS_TOK_NEWLINE &&
- tid != EJS_TOK_EOF) {
- goto error;
- }
-
- /*
- * Skip newline after semi-colon
- */
- removeNewlines(ep, state);
- }
-
-/*
- * Free resources and return the correct status
- */
-doneParse:
- mprFree(id);
- mprFree(fullName);
-
- /*
- * Advance the state
- */
- switch (state) {
- case EJS_STATE_STMT:
- return EJS_STATE_STMT_DONE;
-
- case EJS_STATE_DEC:
- return EJS_STATE_DEC_DONE;
-
- case EJS_STATE_EXPR:
- return EJS_STATE_EXPR_DONE;
-
- case EJS_STATE_STMT_DONE:
- case EJS_STATE_STMT_BLOCK_DONE:
- case EJS_STATE_EOF:
- case EJS_STATE_RET:
- return state;
-
- default:
- return EJS_STATE_ERR;
- }
-
-/*
- * Common error exit
- */
-error:
- state = EJS_STATE_ERR;
- goto doneParse;
-}
-
-/******************************************************************************/
-/*
- * Parse function arguments
- */
-
-static int parseArgs(Ejs *ep, int state, int flags)
-{
- int tid;
-
- mprAssert(ep);
-
- do {
- /*
- * Peek and see if there are no args
- */
- tid = ejsLexGetToken(ep, state);
- ejsLexPutbackToken(ep, tid, ep->token);
- if (tid == EJS_TOK_RPAREN) {
- break;
- }
-
- state = ejsParse(ep, EJS_STATE_RELEXP, flags);
- if (state == EJS_STATE_EOF || state == EJS_STATE_ERR) {
- return state;
- }
- if (state == EJS_STATE_RELEXP_DONE) {
- if (flags & EJS_FLAGS_EXE) {
- mprAssert(ep->proc->args);
- mprAddToArray(ep->proc->args,
- mprDupVar(&ep->result, MPR_SHALLOW_COPY));
- }
- }
- /*
- * Peek at the next token, continue if more args (ie. comma seen)
- */
- tid = ejsLexGetToken(ep, state);
- if (tid != EJS_TOK_COMMA) {
- ejsLexPutbackToken(ep, tid, ep->token);
- }
- } while (tid == EJS_TOK_COMMA);
-
- if (tid != EJS_TOK_RPAREN && state != EJS_STATE_RELEXP_DONE) {
- return EJS_STATE_ERR;
- }
- return EJS_STATE_ARG_LIST_DONE;
-}
-
-/******************************************************************************/
-/*
- * Parse an assignment statement
- */
-
-static int parseAssignment(Ejs *ep, int state, int flags, char *id,
- char *fullName)
-{
- MprVar *vp, *saveProperty, *saveObj;
-
- if (id == 0) {
- return -1;
- }
-
- saveObj = ep->currentObj;
- saveProperty = ep->currentProperty;
- if (ejsParse(ep, EJS_STATE_RELEXP, flags | EJS_FLAGS_ASSIGNMENT)
- != EJS_STATE_RELEXP_DONE) {
- return -1;
- }
- ep->currentObj = saveObj;
- ep->currentProperty = saveProperty;
-
- if (! (flags & EJS_FLAGS_EXE)) {
- return state;
- }
-
- if (ep->currentProperty) {
- /*
- * Update the variable. Update the property name if not
- * yet defined.
- */
- if (ep->currentProperty->name == 0 ||
- ep->currentProperty->name[0] == '\0') {
- mprSetVarName(ep->currentProperty, id);
- }
- if (mprWriteProperty(ep->currentProperty, &ep->result) < 0){
- ejsError(ep, "Can't write to variable\n");
- return -1;
- }
-
- } else {
- /*
- * Create the variable
- */
- if (ep->currentObj) {
- if (ep->currentObj->type != MPR_TYPE_OBJECT) {
- if (strcmp(ep->currentObj->name, "session") == 0) {
- ejsError(ep, "Variable \"%s\" is not an array or object."
- "If using ESP, you need useSession(); in your page.",
- ep->currentObj->name);
- } else {
- ejsError(ep, "Variable \"%s\" is not an array or object",
- ep->currentObj->name);
- }
- return -1;
- }
- vp = mprCreateProperty(ep->currentObj, id, &ep->result);
-
- } else {
- /*
- * Standard says: "var x" means declare locally.
- * "x = 2" means declare globally if x is undefined.
- */
- if (state == EJS_STATE_DEC) {
- vp = mprCreateProperty(ep->local, id, &ep->result);
- } else {
- vp = mprCreateProperty(ep->global, id, &ep->result);
- }
- }
-#if BLD_DEBUG
- mprSetVarFullName(vp, fullName);
-#endif
- }
- return state;
-}
-
-/******************************************************************************/
-/*
- * Parse conditional expression (relational ops separated by ||, &&)
- */
-
-static int parseCond(Ejs *ep, int state, int flags)
-{
- MprVar lhs, rhs;
- int tid, operator;
-
- mprAssert(ep);
-
- mprDestroyVar(&ep->result);
- rhs = lhs = mprCreateUndefinedVar();
- operator = 0;
-
- do {
- /*
- * Recurse to handle one side of a conditional. Accumulate the
- * left hand side and the final result in ep->result.
- */
- state = ejsParse(ep, EJS_STATE_RELEXP, flags);
- if (state != EJS_STATE_RELEXP_DONE) {
- state = EJS_STATE_ERR;
- break;
- }
-
- if (operator > 0) {
- mprCopyVar(&rhs, &ep->result, MPR_SHALLOW_COPY);
- if (evalCond(ep, &lhs, operator, &rhs) < 0) {
- state = EJS_STATE_ERR;
- break;
- }
- }
- mprCopyVar(&lhs, &ep->result, MPR_SHALLOW_COPY);
-
- tid = ejsLexGetToken(ep, state);
- if (tid == EJS_TOK_LOGICAL) {
- operator = (int) *ep->token;
-
- } else if (tid == EJS_TOK_RPAREN || tid == EJS_TOK_SEMI) {
- ejsLexPutbackToken(ep, tid, ep->token);
- state = EJS_STATE_COND_DONE;
- break;
-
- } else {
- ejsLexPutbackToken(ep, tid, ep->token);
- }
- tid = (state == EJS_STATE_RELEXP_DONE);
-
- } while (state == EJS_STATE_RELEXP_DONE);
-
- mprDestroyVar(&lhs);
- mprDestroyVar(&rhs);
- return state;
-}
-
-/******************************************************************************/
-/*
- * Parse variable declaration list. Declarations can be of the following forms:
- * var x;
- * var x, y, z;
- * var x = 1 + 2 / 3, y = 2 + 4;
- *
- * We set the variable to NULL if there is no associated assignment.
- */
-
-static int parseDeclaration(Ejs *ep, int state, int flags)
-{
- int tid;
-
- mprAssert(ep);
-
- do {
- if ((tid = ejsLexGetToken(ep, state)) != EJS_TOK_ID) {
- return EJS_STATE_ERR;
- }
- ejsLexPutbackToken(ep, tid, ep->token);
-
- /*
- * Parse the entire assignment or simple identifier declaration
- */
- if (ejsParse(ep, EJS_STATE_DEC, flags) != EJS_STATE_DEC_DONE) {
- return EJS_STATE_ERR;
- }
-
- /*
- * Peek at the next token, continue if comma seen
- */
- tid = ejsLexGetToken(ep, state);
- if (tid == EJS_TOK_SEMI) {
- return EJS_STATE_DEC_LIST_DONE;
- } else if (tid != EJS_TOK_COMMA) {
- return EJS_STATE_ERR;
- }
- } while (tid == EJS_TOK_COMMA);
-
- if (tid != EJS_TOK_SEMI) {
- return EJS_STATE_ERR;
- }
- return EJS_STATE_DEC_LIST_DONE;
-}
-
-/******************************************************************************/
-/*
- * Parse expression (leftHandSide operator rightHandSide)
- */
-
-static int parseExpr(Ejs *ep, int state, int flags)
-{
- MprVar lhs, rhs;
- int rel, tid;
-
- mprAssert(ep);
-
- mprDestroyVar(&ep->result);
- rhs = lhs = mprCreateUndefinedVar();
- rel = 0;
- tid = 0;
-
- do {
- /*
- * This loop will handle an entire expression list. We call parse
- * to evalutate each term which returns the result in ep->result.
- */
- if (tid == EJS_TOK_LOGICAL) {
- state = ejsParse(ep, EJS_STATE_RELEXP, flags);
- if (state != EJS_STATE_RELEXP_DONE) {
- state = EJS_STATE_ERR;
- break;
- }
- } else {
- tid = ejsLexGetToken(ep, state);
- if (tid == EJS_TOK_EXPR && (int) *ep->token == EJS_EXPR_MINUS) {
- lhs = mprCreateIntegerVar(0);
- rel = (int) *ep->token;
- } else {
- ejsLexPutbackToken(ep, tid, ep->token);
- }
-
- state = ejsParse(ep, EJS_STATE_EXPR, flags);
- if (state != EJS_STATE_EXPR_DONE) {
- state = EJS_STATE_ERR;
- break;
- }
- }
-
- if (rel > 0) {
- mprCopyVar(&rhs, &ep->result, MPR_SHALLOW_COPY);
- if (tid == EJS_TOK_LOGICAL) {
- if (evalCond(ep, &lhs, rel, &rhs) < 0) {
- state = EJS_STATE_ERR;
- break;
- }
- } else {
- if (evalExpr(ep, &lhs, rel, &rhs) < 0) {
- state = EJS_STATE_ERR;
- break;
- }
- }
- }
- mprCopyVar(&lhs, &ep->result, MPR_SHALLOW_COPY);
-
- if ((tid = ejsLexGetToken(ep, state)) == EJS_TOK_EXPR ||
- tid == EJS_TOK_INC_DEC || tid == EJS_TOK_LOGICAL) {
- rel = (int) *ep->token;
-
- } else {
- ejsLexPutbackToken(ep, tid, ep->token);
- state = EJS_STATE_RELEXP_DONE;
- }
-
- } while (state == EJS_STATE_EXPR_DONE);
-
- mprDestroyVar(&lhs);
- mprDestroyVar(&rhs);
-
- return state;
-}
-
-/******************************************************************************/
-/*
- * Parse the "for ... in" statement. Format for the statement is:
- *
- * for (var in expr) {
- * body;
- * }
- */
-
-static int parseForIn(Ejs *ep, int state, int flags)
-{
- EjsInput endScript, bodyScript;
- MprVar *iteratorVar, *setVar, *vp, v;
- int forFlags, tid;
-
- mprAssert(ep);
-
- tid = ejsLexGetToken(ep, state);
- if (tid != EJS_TOK_ID) {
- return -1;
- }
- ejsLexPutbackToken(ep, tid, ep->token);
-
- if (ejsParse(ep, EJS_STATE_EXPR, EJS_FLAGS_FOREACH | EJS_FLAGS_EXE)
- != EJS_STATE_EXPR_DONE) {
- return -1;
- }
- if (ep->currentProperty == 0) {
- return -1;
- }
- iteratorVar = ep->currentProperty;
-
- if (ejsLexGetToken(ep, state) != EJS_TOK_IN) {
- return -1;
- }
-
- /*
- * Get the set
- */
- tid = ejsLexGetToken(ep, state);
- if (tid != EJS_TOK_ID) {
- return -1;
- }
- ejsLexPutbackToken(ep, tid, ep->token);
-
- if (ejsParse(ep, EJS_STATE_EXPR, flags) != EJS_STATE_EXPR_DONE) {
- return -1;
- }
- if (ep->currentProperty == 0 && flags & EJS_FLAGS_EXE) {
- return -1;
- }
- setVar = ep->currentProperty;
-
- if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) {
- return -1;
- }
-
- /*
- * Parse the body and remember the end of the body script
- */
- forFlags = flags & ~EJS_FLAGS_EXE;
- ejsLexSaveInputState(ep, &bodyScript);
- if (ejsParse(ep, EJS_STATE_STMT, forFlags) != EJS_STATE_STMT_DONE) {
- ejsLexFreeInputState(ep, &bodyScript);
- return -1;
- }
- ejsInitInputState(&endScript);
- ejsLexSaveInputState(ep, &endScript);
-
- /*
- * Now actually do the for loop.
- */
- if (flags & EJS_FLAGS_EXE) {
- if (setVar->type == MPR_TYPE_OBJECT) {
- vp = mprGetFirstProperty(setVar, MPR_ENUM_DATA);
- while (vp) {
- if (strcmp(vp->name, "length") != 0) {
- v = mprCreateStringVar(vp->name, 0);
- if (mprWriteProperty(iteratorVar, &v) < 0) {
- ejsError(ep, "Can't write to variable\n");
- ejsLexFreeInputState(ep, &bodyScript);
- ejsLexFreeInputState(ep, &endScript);
- return -1;
- }
-
- ejsLexRestoreInputState(ep, &bodyScript);
- switch (ejsParse(ep, EJS_STATE_STMT, flags)) {
- case EJS_STATE_RET:
- return EJS_STATE_RET;
- case EJS_STATE_STMT_DONE:
- break;
- default:
- ejsLexFreeInputState(ep, &endScript);
- ejsLexFreeInputState(ep, &bodyScript);
- return -1;
- }
- }
- vp = mprGetNextProperty(setVar, vp, MPR_ENUM_DATA);
- }
- } else {
- ejsError(ep, "Variable \"%s\" is not an array or object",
- setVar->name);
- ejsLexFreeInputState(ep, &endScript);
- ejsLexFreeInputState(ep, &bodyScript);
- return -1;
- }
- }
- ejsLexRestoreInputState(ep, &endScript);
-
- ejsLexFreeInputState(ep, &endScript);
- ejsLexFreeInputState(ep, &bodyScript);
-
- return state;
-}
-
-/******************************************************************************/
-/*
- * Parse the for statement. Format for the expression is:
- *
- * for (initial; condition; incr) {
- * body;
- * }
- */
-
-static int parseFor(Ejs *ep, int state, int flags)
-{
- EjsInput condScript, endScript, bodyScript, incrScript;
- int forFlags, cond;
-
- ejsInitInputState(&endScript);
- ejsInitInputState(&bodyScript);
- ejsInitInputState(&incrScript);
- ejsInitInputState(&condScript);
-
- mprAssert(ep);
-
- /*
- * Evaluate the for loop initialization statement
- */
- if (ejsParse(ep, EJS_STATE_EXPR, flags) != EJS_STATE_EXPR_DONE) {
- return -1;
- }
- if (ejsLexGetToken(ep, state) != EJS_TOK_SEMI) {
- return -1;
- }
-
- /*
- * The first time through, we save the current input context just prior
- * to each step: prior to the conditional, the loop increment and
- * the loop body.
- */
- ejsLexSaveInputState(ep, &condScript);
- if (ejsParse(ep, EJS_STATE_COND, flags) != EJS_STATE_COND_DONE) {
- goto error;
- }
- cond = (ep->result.boolean != 0);
-
- if (ejsLexGetToken(ep, state) != EJS_TOK_SEMI) {
- goto error;
- }
-
- /*
- * Don't execute the loop increment statement or the body
- * first time.
- */
- forFlags = flags & ~EJS_FLAGS_EXE;
- ejsLexSaveInputState(ep, &incrScript);
- if (ejsParse(ep, EJS_STATE_EXPR, forFlags) != EJS_STATE_EXPR_DONE) {
- goto error;
- }
- if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) {
- goto error;
- }
-
- /*
- * Parse the body and remember the end of the body script
- */
- ejsLexSaveInputState(ep, &bodyScript);
- if (ejsParse(ep, EJS_STATE_STMT, forFlags) != EJS_STATE_STMT_DONE) {
- goto error;
- }
- ejsLexSaveInputState(ep, &endScript);
-
- /*
- * Now actually do the for loop. Note loop has been rotated
- */
- while (cond && (flags & EJS_FLAGS_EXE)) {
- /*
- * Evaluate the body
- */
- ejsLexRestoreInputState(ep, &bodyScript);
-
- switch (ejsParse(ep, EJS_STATE_STMT, flags)) {
- case EJS_STATE_RET:
- return EJS_STATE_RET;
- case EJS_STATE_STMT_DONE:
- break;
- default:
- goto error;
- }
- /*
- * Evaluate the increment script
- */
- ejsLexRestoreInputState(ep, &incrScript);
- if (ejsParse(ep, EJS_STATE_EXPR, flags) != EJS_STATE_EXPR_DONE){
- goto error;
- }
- /*
- * Evaluate the condition
- */
- ejsLexRestoreInputState(ep, &condScript);
- if (ejsParse(ep, EJS_STATE_COND, flags) != EJS_STATE_COND_DONE) {
- goto error;
- }
- mprAssert(ep->result.type == MPR_TYPE_BOOL);
- cond = (ep->result.boolean != 0);
- }
-
- ejsLexRestoreInputState(ep, &endScript);
-
-done:
- ejsLexFreeInputState(ep, &condScript);
- ejsLexFreeInputState(ep, &incrScript);
- ejsLexFreeInputState(ep, &endScript);
- ejsLexFreeInputState(ep, &bodyScript);
- return state;
-
-error:
- state = EJS_STATE_ERR;
- goto done;
-}
-
-/******************************************************************************/
-/*
- * Parse a function declaration
- */
-
-static int parseFunctionDec(Ejs *ep, int state, int flags)
-{
- EjsInput endScript, bodyScript;
- MprVar v, *currentObj, *vp;
- char *procName;
- int len, tid, bodyFlags;
-
- mprAssert(ep);
- mprAssert(ejsPtr(ep->eid));
-
- /*
- * function <name>(arg, arg, arg) { body };
- * function name(arg, arg, arg) { body };
- */
-
- tid = ejsLexGetToken(ep, state);
- if (tid == EJS_TOK_ID) {
- procName = mprStrdup(ep->token);
- tid = ejsLexGetToken(ep, state);
- } else {
- procName = 0;
- }
- if (tid != EJS_TOK_LPAREN) {
- mprFree(procName);
- return EJS_STATE_ERR;
- }
-
- /*
- * Hand craft the function value structure.
- */
- v = mprCreateFunctionVar(0, 0, 0);
- tid = ejsLexGetToken(ep, state);
- while (tid == EJS_TOK_ID) {
- mprAddToArray(v.function.args, mprStrdup(ep->token));
- tid = ejsLexGetToken(ep, state);
- if (tid == EJS_TOK_RPAREN || tid != EJS_TOK_COMMA) {
- break;
- }
- tid = ejsLexGetToken(ep, state);
- }
- if (tid != EJS_TOK_RPAREN) {
- mprFree(procName);
- mprDestroyVar(&v);
- return EJS_STATE_ERR;
- }
-
- /* Allow new lines before opening brace */
- do {
- tid = ejsLexGetToken(ep, state);
- } while (tid == EJS_TOK_NEWLINE);
-
- if (tid != EJS_TOK_LBRACE) {
- mprFree(procName);
- mprDestroyVar(&v);
- return EJS_STATE_ERR;
- }
-
- /*
- * Register the function name early to allow for recursive
- * function calls (see note in ECMA standard, page 71)
- */
- if (!(flags & EJS_FLAGS_ASSIGNMENT)) {
- currentObj = ejsFindObj(ep, 0, procName, flags);
- vp = mprSetProperty(currentObj, procName, &v);
- }
-
- /*
- * Parse the function body. Turn execute off.
- */
- bodyFlags = flags & ~EJS_FLAGS_EXE;
- ejsLexSaveInputState(ep, &bodyScript);
-
- do {
- state = ejsParse(ep, EJS_STATE_STMT, bodyFlags);
- } while (state == EJS_STATE_STMT_DONE);
-
- tid = ejsLexGetToken(ep, state);
- if (state != EJS_STATE_STMT_BLOCK_DONE || tid != EJS_TOK_RBRACE) {
- mprFree(procName);
- mprDestroyVar(&v);
- ejsLexFreeInputState(ep, &bodyScript);
- return EJS_STATE_ERR;
- }
- ejsLexSaveInputState(ep, &endScript);
-
- /*
- * Save the function body between the starting and ending parse positions.
- * Overwrite the trailing '}' with a null.
- */
- len = endScript.scriptServp - bodyScript.scriptServp;
- v.function.body = mprMalloc(len + 1);
- memcpy(v.function.body, bodyScript.scriptServp, len);
-
- if (len <= 0) {
- v.function.body[0] = '\0';
- } else {
- v.function.body[len - 1] = '\0';
- }
- ejsLexFreeInputState(ep, &bodyScript);
- ejsLexFreeInputState(ep, &endScript);
-
- /*
- * If we are in an assignment, don't register the function name, rather
- * return the function structure in the parser result.
- */
- if (flags & EJS_FLAGS_ASSIGNMENT) {
- mprCopyVar(&ep->result, &v, MPR_SHALLOW_COPY);
- } else {
- currentObj = ejsFindObj(ep, 0, procName, flags);
- vp = mprSetProperty(currentObj, procName, &v);
- }
-
- mprFree(procName);
- mprDestroyVar(&v);
-
- return EJS_STATE_STMT;
-}
-
-/******************************************************************************/
-/*
- * Parse a function name and invoke the function
- */
-
-static int parseFunction(Ejs *ep, int state, int flags, char *id)
-{
- EjsProc proc, *saveProc;
- MprVar *saveObj;
-
- /*
- * Must save any current ep->proc value for the current stack frame
- * to allow for recursive function calls.
- */
- saveProc = (ep->proc) ? ep->proc: 0;
-
- memset(&proc, 0, sizeof(EjsProc));
- proc.procName = mprStrdup(id);
- proc.fn = ep->currentProperty;
- proc.args = mprCreateArray();
- ep->proc = &proc;
-
- mprDestroyVar(&ep->result);
-
- saveObj = ep->currentObj;
- if (ejsParse(ep, EJS_STATE_ARG_LIST, flags) != EJS_STATE_ARG_LIST_DONE) {
- freeProc(&proc);
- ep->proc = saveProc;
- return -1;
- }
- ep->currentObj = saveObj;
-
- /*
- * Evaluate the function if required
- */
- if (flags & EJS_FLAGS_EXE) {
- if (evalFunction(ep, ep->currentObj, flags) < 0) {
- freeProc(&proc);
- ep->proc = saveProc;
- return -1;
- }
- }
-
- freeProc(&proc);
- ep->proc = saveProc;
-
- if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) {
- return -1;
- }
- return state;
-}
-
-/******************************************************************************/
-/*
- * Parse an identifier. This is a segment of a fully qualified variable.
- * May come here for an initial identifier or for property names
- * after a "." or "[...]".
- */
-
-static int parseId(Ejs *ep, int state, int flags, char **id, char **fullName,
- int *fullNameLen, int *done)
-{
- int tid;
-
- mprFree(*id);
- *id = mprStrdup(ep->token);
-#if BLD_DEBUG
- *fullNameLen = mprReallocStrcat(fullName, MPR_MAX_VAR, *fullNameLen,
- 0, *id, NULL);
-#endif
- if (ep->currentObj == 0) {
- ep->currentObj = ejsFindObj(ep, state, *id, flags);
- }
-
- /*
- * Find the referenced variable and store it in currentProperty.
- */
- ep->currentProperty = ejsFindProperty(ep, state, ep->currentObj,
- *id, flags);
- updateResult(ep, state, flags, ep->currentProperty);
-
-#if BLD_DEBUG
- if (ep->currentProperty && (ep->currentProperty->name == 0 ||
- ep->currentProperty->name[0] == '\0')) {
- mprSetVarName(ep->currentProperty, *id);
- }
-#endif
-
- tid = ejsLexGetToken(ep, state);
- if (tid == EJS_TOK_LPAREN) {
- if (ep->currentProperty == 0 && (flags & EJS_FLAGS_EXE)) {
- ejsError(ep, "Function name not defined \"%s\"\n", *id);
- return -1;
- }
- ejsLexPutbackToken(ep, EJS_TOK_FUNCTION_NAME, ep->token);
- return state;
- }
-
- if (tid == EJS_TOK_PERIOD || tid == EJS_TOK_LBRACKET ||
- tid == EJS_TOK_ASSIGNMENT || tid == EJS_TOK_INC_DEC) {
- ejsLexPutbackToken(ep, tid, ep->token);
- return state;
- }
-
- /*
- * Only come here for variable access and declarations.
- * Assignment handled elsewhere.
- */
- if (flags & EJS_FLAGS_EXE) {
- if (state == EJS_STATE_DEC) {
- /*
- * Declare a variable. Standard allows: var x ; var x ;
- */
-#if DISABLED
- if (ep->currentProperty != 0) {
- ejsError(ep, "Variable already defined \"%s\"\n", *id);
- return -1;
- }
-#endif
- /*
- * Create or overwrite if it already exists
- */
- mprSetPropertyValue(ep->currentObj, *id,
- mprCreateUndefinedVar());
- ep->currentProperty = 0;
- mprDestroyVar(&ep->result);
-
- } else if (flags & EJS_FLAGS_FOREACH) {
- if (ep->currentProperty == 0) {
- ep->currentProperty =
- mprCreatePropertyValue(ep->currentObj, *id,
- mprCreateUndefinedVar());
- }
-
- } else {
- if (ep->currentProperty == 0) {
- if (ep->currentObj == ep->global ||
- ep->currentObj == ep->local) {
- ejsError(ep, "Undefined variable \"%s\"\n", *id);
- return -1;
- }
- ep->currentProperty = mprCreatePropertyValue(ep->currentObj,
- *id, mprCreateUndefinedVar());
- }
- }
- }
- ejsLexPutbackToken(ep, tid, ep->token);
- if (tid == EJS_TOK_RBRACKET || tid == EJS_TOK_COMMA ||
- tid == EJS_TOK_IN) {
- *done = 1;
- }
- return state;
-}
-
-/******************************************************************************/
-/*
- * Parse an "if" statement
- */
-
-static int parseIf(Ejs *ep, int state, int flags, int *done)
-{
- bool ifResult;
- int thenFlags, elseFlags, tid;
-
- if (state != EJS_STATE_STMT) {
- return -1;
- }
- if (ejsLexGetToken(ep, state) != EJS_TOK_LPAREN) {
- return -1;
- }
-
- /*
- * Evaluate the entire condition list "(condition)"
- */
- if (ejsParse(ep, EJS_STATE_COND, flags) != EJS_STATE_COND_DONE) {
- return -1;
- }
- if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) {
- return -1;
- }
-
- /*
- * This is the "then" case. We need to always parse both cases and
- * execute only the relevant case.
- */
- ifResult = mprVarToBool(&ep->result);
- if (ifResult) {
- thenFlags = flags;
- elseFlags = flags & ~EJS_FLAGS_EXE;
- } else {
- thenFlags = flags & ~EJS_FLAGS_EXE;
- elseFlags = flags;
- }
-
- /*
- * Process the "then" case.
- */
- switch (ejsParse(ep, EJS_STATE_STMT, thenFlags)) {
- case EJS_STATE_RET:
- state = EJS_STATE_RET;
- return state;
- case EJS_STATE_STMT_DONE:
- break;
- default:
- return -1;
- }
-
- /*
- * Check to see if there is an "else" case
- */
- removeNewlines(ep, state);
- tid = ejsLexGetToken(ep, state);
- if (tid != EJS_TOK_ELSE) {
- ejsLexPutbackToken(ep, tid, ep->token);
- *done = 1;
- return state;
- }
-
- /*
- * Process the "else" case.
- */
- switch (ejsParse(ep, EJS_STATE_STMT, elseFlags)) {
- case EJS_STATE_RET:
- state = EJS_STATE_RET;
- return state;
- case EJS_STATE_STMT_DONE:
- break;
- default:
- return -1;
- }
- *done = 1;
- return state;
-}
-
-/******************************************************************************/
-/*
- * Parse an "++" or "--" statement
- */
-
-static int parseInc(Ejs *ep, int state, int flags)
-{
- MprVar one;
-
- if (! (flags & EJS_FLAGS_EXE)) {
- return state;
- }
-
- if (ep->currentProperty == 0) {
- ejsError(ep, "Undefined variable \"%s\"\n", ep->token);
- return -1;
- }
- one = mprCreateIntegerVar(1);
- if (evalExpr(ep, ep->currentProperty, (int) *ep->token,
- &one) < 0) {
- return -1;
- }
- if (mprWriteProperty(ep->currentProperty, &ep->result) < 0) {
- ejsError(ep, "Can't write to variable\n");
- return -1;
- }
- return state;
-}
-
-/******************************************************************************/
-/*
- * Evaluate a condition. Implements &&, ||, !. Returns with a boolean result
- * in ep->result. Returns -1 on errors, zero if successful.
- */
-
-static int evalCond(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs)
-{
- bool l, r, lval;
-
- mprAssert(rel > 0);
-
- l = mprVarToBool(lhs);
- r = mprVarToBool(rhs);
-
- switch (rel) {
- case EJS_COND_AND:
- lval = l && r;
- break;
- case EJS_COND_OR:
- lval = l || r;
- break;
- default:
- ejsError(ep, "Bad operator %d", rel);
- return -1;
- }
-
- mprCopyVarValue(&ep->result, mprCreateBoolVar(lval), 0);
- return 0;
-}
-
-
-/*
- return true if this string is a valid number
-*/
-static int string_is_number(const char *s)
-{
- char *endptr = NULL;
- if (s == NULL || *s == 0) {
- return 0;
- }
- strtod(s, &endptr);
- if (endptr != NULL && *endptr == 0) {
- return 1;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Evaluate an operation. Returns with the result in ep->result. Returns -1
- * on errors, otherwise zero is returned.
- */
-
-static int evalExpr(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs)
-{
- char *str;
- MprNum lval, num;
- int rc;
-
- mprAssert(rel > 0);
- str = 0;
- lval = 0;
-
- /*
- * Type conversion. This is tricky and must be according to the standard.
- * Only numbers (including floats) and strings can be compared. All other
- * types are first converted to numbers by preference and if that fails,
- * to strings.
- *
- * First convert objects to comparable types. The "===" operator will
- * test the sameness of object references. Here, we coerce to comparable
- * types first.
- */
- if (lhs->type == MPR_TYPE_OBJECT) {
- if (ejsRunFunction(ep->eid, lhs, "toValue", 0) == 0) {
- mprCopyVar(lhs, &ep->result, MPR_SHALLOW_COPY);
- } else {
- if (ejsRunFunction(ep->eid, lhs, "toString", 0) == 0) {
- mprCopyVar(lhs, &ep->result, MPR_SHALLOW_COPY);
- }
- }
- /* Nothing more can be done */
- }
-
- if (rhs->type == MPR_TYPE_OBJECT) {
- if (ejsRunFunction(ep->eid, rhs, "toValue", 0) == 0) {
- mprCopyVar(rhs, &ep->result, MPR_SHALLOW_COPY);
- } else {
- if (ejsRunFunction(ep->eid, rhs, "toString", 0) == 0) {
- mprCopyVar(rhs, &ep->result, MPR_SHALLOW_COPY);
- }
- }
- /* Nothing more can be done */
- }
-
- /* undefined and null are special, in that they don't get promoted when
- comparing */
- if (rel == EJS_EXPR_EQ || rel == EJS_EXPR_NOTEQ) {
- if (lhs->type == MPR_TYPE_UNDEFINED || rhs->type == MPR_TYPE_UNDEFINED) {
- return evalBoolExpr(ep,
- lhs->type == MPR_TYPE_UNDEFINED,
- rel,
- rhs->type == MPR_TYPE_UNDEFINED);
- }
-
- if (lhs->type == MPR_TYPE_NULL || rhs->type == MPR_TYPE_NULL) {
- return evalBoolExpr(ep,
- lhs->type == MPR_TYPE_NULL,
- rel,
- rhs->type == MPR_TYPE_NULL);
- }
- }
-
- /*
- * From here on, lhs and rhs may contain allocated data (strings), so
- * we must always destroy before overwriting.
- */
-
- /*
- * Only allow a few bool operations. Otherwise convert to number.
- */
- if (lhs->type == MPR_TYPE_BOOL && rhs->type == MPR_TYPE_BOOL &&
- (rel != EJS_EXPR_EQ && rel != EJS_EXPR_NOTEQ &&
- rel != EJS_EXPR_BOOL_COMP)) {
- num = mprVarToNumber(lhs);
- mprDestroyVar(lhs);
- *lhs = mprCreateNumberVar(num);
- }
-
- /*
- * Types do not match, so try to coerce the right operand to match the left
- * But first, try to convert a left operand that is a numeric stored as a
- * string, into a numeric.
- */
- if (lhs->type != rhs->type) {
- if (lhs->type == MPR_TYPE_STRING) {
- if (string_is_number(lhs->string)) {
- num = mprVarToNumber(lhs);
- lhs->allocatedVar = 0;
- mprDestroyVar(lhs);
- *lhs = mprCreateNumberVar(num);
- /* Examine further below */
-
- } else {
- /*
- * Convert the RHS to a string
- */
- mprVarToString(&str, MPR_MAX_STRING, 0, rhs);
- rhs->allocatedVar = 0;
- mprDestroyVar(rhs);
- *rhs = mprCreateStringVar(str, 1);
- mprFree(str);
- }
-
-#if BLD_FEATURE_FLOATING_POINT
- } else if (lhs->type == MPR_TYPE_FLOAT) {
- /*
- * Convert rhs to floating
- */
- double f = mprVarToFloat(rhs);
- mprDestroyVar(rhs);
- *rhs = mprCreateFloatVar(f);
-
-#endif
-#if BLD_FEATURE_INT64
- } else if (lhs->type == MPR_TYPE_INT64) {
- /*
- * Convert the rhs to 64 bit
- */
- int64 n = mprVarToInteger64(rhs);
- mprDestroyVar(rhs);
- *rhs = mprCreateInteger64Var(n);
-#endif
- } else if (lhs->type == MPR_TYPE_BOOL || lhs->type == MPR_TYPE_INT) {
-
- if (rhs->type == MPR_TYPE_STRING) {
- /*
- * Convert to lhs to a string
- */
- mprVarToString(&str, MPR_MAX_STRING, 0, lhs);
- mprDestroyVar(lhs);
- *lhs = mprCreateStringVar(str, 1);
- mprFree(str);
-
-#if BLD_FEATURE_FLOATING_POINT
- } else if (rhs->type == MPR_TYPE_FLOAT) {
- /*
- * Convert lhs to floating
- */
- double f = mprVarToFloat(lhs);
- mprDestroyVar(lhs);
- *lhs = mprCreateFloatVar(f);
-#endif
-
- } else {
- /*
- * Convert both operands to numbers
- */
- num = mprVarToNumber(lhs);
- mprDestroyVar(lhs);
- *lhs = mprCreateNumberVar(num);
-
- num = mprVarToNumber(rhs);
- mprDestroyVar(rhs);
- *rhs = mprCreateNumberVar(num);
- }
- }
- }
-
- /*
- * We have failed to coerce the types to be the same. Special case here
- * for undefined and null. We need to allow comparisions against these
- * special values.
- */
- if (lhs->type == MPR_TYPE_UNDEFINED || lhs->type == MPR_TYPE_NULL) {
- switch (rel) {
- case EJS_EXPR_EQ:
- lval = lhs->type == rhs->type;
- break;
- case EJS_EXPR_NOTEQ:
- lval = lhs->type != rhs->type;
- break;
- case EJS_EXPR_BOOL_COMP:
- lval = ! mprVarToBool(rhs);
- break;
- default:
- lval = 0;
- }
- mprCopyVarValue(&ep->result, mprCreateBoolVar((bool) lval), 0);
- return 0;
- }
-
- /*
- * Types are the same here
- */
- switch (lhs->type) {
- default:
- case MPR_TYPE_UNDEFINED:
- case MPR_TYPE_NULL:
- /* Should be handled above */
- mprAssert(0);
- return 0;
-
- case MPR_TYPE_STRING_CFUNCTION:
- case MPR_TYPE_CFUNCTION:
- case MPR_TYPE_FUNCTION:
- case MPR_TYPE_OBJECT:
- mprCopyVarValue(&ep->result, mprCreateBoolVar(0), 0);
- return 0;
-
- case MPR_TYPE_PTR:
- rc = evalPtrExpr(ep, lhs->ptr, rel, rhs->ptr);
- break;
-
- case MPR_TYPE_BOOL:
- rc = evalBoolExpr(ep, lhs->boolean, rel, rhs->boolean);
- break;
-
-#if BLD_FEATURE_FLOATING_POINT
- case MPR_TYPE_FLOAT:
- rc = evalFloatExpr(ep, lhs->floating, rel, rhs->floating);
- break;
-#endif
-
- case MPR_TYPE_INT:
- rc = evalNumericExpr(ep, (MprNum) lhs->integer, rel,
- (MprNum) rhs->integer);
- break;
-
-#if BLD_FEATURE_INT64
- case MPR_TYPE_INT64:
- rc = evalNumericExpr(ep, (MprNum) lhs->integer64, rel,
- (MprNum) rhs->integer64);
- break;
-#endif
-
- case MPR_TYPE_STRING:
- rc = evalStringExpr(ep, lhs, rel, rhs);
- }
- return rc;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_FLOATING_POINT
-/*
- * Expressions with floating operands
- */
-
-static int evalFloatExpr(Ejs *ep, double l, int rel, double r)
-{
- double lval;
- bool logical;
-
- lval = 0;
- logical = 0;
-
- switch (rel) {
- case EJS_EXPR_PLUS:
- lval = l + r;
- break;
- case EJS_EXPR_INC:
- lval = l + 1;
- break;
- case EJS_EXPR_MINUS:
- lval = l - r;
- break;
- case EJS_EXPR_DEC:
- lval = l - 1;
- break;
- case EJS_EXPR_MUL:
- lval = l * r;
- break;
- case EJS_EXPR_DIV:
- lval = l / r;
- break;
- default:
- logical++;
- break;
- }
-
- /*
- * Logical operators
- */
- if (logical) {
-
- switch (rel) {
- case EJS_EXPR_EQ:
- lval = l == r;
- break;
- case EJS_EXPR_NOTEQ:
- lval = l != r;
- break;
- case EJS_EXPR_LESS:
- lval = (l < r) ? 1 : 0;
- break;
- case EJS_EXPR_LESSEQ:
- lval = (l <= r) ? 1 : 0;
- break;
- case EJS_EXPR_GREATER:
- lval = (l > r) ? 1 : 0;
- break;
- case EJS_EXPR_GREATEREQ:
- lval = (l >= r) ? 1 : 0;
- break;
- case EJS_EXPR_BOOL_COMP:
- lval = (r == 0) ? 1 : 0;
- break;
- default:
- ejsError(ep, "Bad operator %d", rel);
- return -1;
- }
- mprCopyVarValue(&ep->result, mprCreateBoolVar(lval != 0), 0);
-
- } else {
- mprCopyVarValue(&ep->result, mprCreateFloatVar(lval), 0);
- }
- return 0;
-}
-
-#endif /* BLD_FEATURE_FLOATING_POINT */
-/******************************************************************************/
-/*
- * Expressions with boolean operands
- */
-
-static int evalBoolExpr(Ejs *ep, bool l, int rel, bool r)
-{
- bool lval;
-
- switch (rel) {
- case EJS_EXPR_EQ:
- lval = l == r;
- break;
- case EJS_EXPR_NOTEQ:
- lval = l != r;
- break;
- case EJS_EXPR_BOOL_COMP:
- lval = (r == 0) ? 1 : 0;
- break;
- default:
- ejsError(ep, "Bad operator %d", rel);
- return -1;
- }
- mprCopyVarValue(&ep->result, mprCreateBoolVar(lval), 0);
- return 0;
-}
-
-static int evalPtrExpr(Ejs *ep, void *l, int rel, void *r)
-{
- bool lval;
-
- switch (rel) {
- case EJS_EXPR_EQ:
- lval = l == r;
- break;
- case EJS_EXPR_NOTEQ:
- lval = l != r;
- break;
- case EJS_EXPR_BOOL_COMP:
- lval = (r == NULL) ? 1 : 0;
- break;
- default:
- ejsError(ep, "Bad operator %d", rel);
- return -1;
- }
- mprCopyVarValue(&ep->result, mprCreateBoolVar(lval), 0);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Expressions with numeric operands
- */
-
-static int evalNumericExpr(Ejs *ep, MprNum l, int rel, MprNum r)
-{
- MprNum lval;
- bool logical;
-
- lval = 0;
- logical = 0;
-
- switch (rel) {
- case EJS_EXPR_PLUS:
- lval = l + r;
- break;
- case EJS_EXPR_INC:
- lval = l + 1;
- break;
- case EJS_EXPR_MINUS:
- lval = l - r;
- break;
- case EJS_EXPR_DEC:
- lval = l - 1;
- break;
- case EJS_EXPR_MUL:
- lval = l * r;
- break;
- case EJS_EXPR_DIV:
- if (r != 0) {
- lval = l / r;
- } else {
- ejsError(ep, "Divide by zero");
- return -1;
- }
- break;
- case EJS_EXPR_MOD:
- if (r != 0) {
- lval = l % r;
- } else {
- ejsError(ep, "Modulo zero");
- return -1;
- }
- break;
- case EJS_EXPR_LSHIFT:
- lval = l << r;
- break;
- case EJS_EXPR_RSHIFT:
- lval = l >> r;
- break;
-
- default:
- logical++;
- break;
- }
-
- /*
- * Logical operators
- */
- if (logical) {
-
- switch (rel) {
- case EJS_EXPR_EQ:
- lval = l == r;
- break;
- case EJS_EXPR_NOTEQ:
- lval = l != r;
- break;
- case EJS_EXPR_LESS:
- lval = (l < r) ? 1 : 0;
- break;
- case EJS_EXPR_LESSEQ:
- lval = (l <= r) ? 1 : 0;
- break;
- case EJS_EXPR_GREATER:
- lval = (l > r) ? 1 : 0;
- break;
- case EJS_EXPR_GREATEREQ:
- lval = (l >= r) ? 1 : 0;
- break;
- case EJS_EXPR_BOOL_COMP:
- lval = (r == 0) ? 1 : 0;
- break;
- default:
- ejsError(ep, "Bad operator %d", rel);
- return -1;
- }
- mprCopyVarValue(&ep->result, mprCreateBoolVar(lval != 0), 0);
-
- } else {
- mprCopyVarValue(&ep->result, mprCreateNumberVar(lval), 0);
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Expressions with string operands
- */
-
-static int evalStringExpr(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs)
-{
- int lval;
-
- mprAssert(ep);
- mprAssert(lhs);
- mprAssert(rhs);
-
- switch (rel) {
- case EJS_EXPR_LESS:
- lval = strcmp(lhs->string, rhs->string) < 0;
- break;
- case EJS_EXPR_LESSEQ:
- lval = strcmp(lhs->string, rhs->string) <= 0;
- break;
- case EJS_EXPR_GREATER:
- lval = strcmp(lhs->string, rhs->string) > 0;
- break;
- case EJS_EXPR_GREATEREQ:
- lval = strcmp(lhs->string, rhs->string) >= 0;
- break;
- case EJS_EXPR_EQ:
- lval = strcmp(lhs->string, rhs->string) == 0;
- break;
- case EJS_EXPR_NOTEQ:
- lval = strcmp(lhs->string, rhs->string) != 0;
- break;
- case EJS_EXPR_PLUS:
- /*
- * This differs from all the above operations. We append rhs to lhs.
- */
- mprDestroyVar(&ep->result);
- appendValue(&ep->result, lhs);
- appendValue(&ep->result, rhs);
- return 0;
-
- case EJS_EXPR_INC:
- case EJS_EXPR_DEC:
- case EJS_EXPR_MINUS:
- case EJS_EXPR_DIV:
- case EJS_EXPR_MOD:
- case EJS_EXPR_LSHIFT:
- case EJS_EXPR_RSHIFT:
- default:
- ejsError(ep, "Bad operator");
- return -1;
- }
-
- mprCopyVarValue(&ep->result, mprCreateBoolVar(lval), 0);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Evaluate a function. obj is set to the current object if a function is being
- * run.
- */
-
-static int evalFunction(Ejs *ep, MprVar *obj, int flags)
-{
- EjsProc *proc;
- MprVar arguments, callee, thisObject, *prototype, **argValues;
- MprArray *formalArgs, *actualArgs;
- char buf[16], **argNames, **argBuf;
- int i, rc, fid;
-
- mprAssert(ep);
- mprAssert(ejsPtr(ep->eid));
-
- rc = -1;
- proc = ep->proc;
- prototype = proc->fn;
- actualArgs = proc->args;
- argValues = (MprVar**) actualArgs->handles;
-
- /*
- * Create a new variable stack frame. ie. new local variables.
- */
- fid = ejsOpenBlock(ep->eid);
-
- if (flags & EJS_FLAGS_NEW) {
- /*
- * Create a new bare object and pass it into the constructor as the
- * "this" local variable.
- */
- thisObject = ejsCreateObj("this", EJS_OBJ_HASH_SIZE);
- mprCreatePropertyValue(ep->local, "this", thisObject);
-
- } else if (obj) {
- mprCreateProperty(ep->local, "this", obj);
- }
-
- switch (prototype->type) {
- default:
- mprAssert(0);
- break;
-
- case MPR_TYPE_STRING_CFUNCTION:
- if (actualArgs->used > 0) {
- argBuf = mprMalloc((1+actualArgs->used) * sizeof(char*));
- for (i = 0; i < actualArgs->used; i++) {
- mprVarToString(&argBuf[i], MPR_MAX_STRING, 0, argValues[i]);
- }
- argBuf[i] = NULL;
- } else {
- argBuf = 0;
- }
-
- /*
- * Call the function depending on the various handle flags
- */
- ep->thisPtr = prototype->cFunctionWithStrings.thisPtr;
- if (prototype->flags & MPR_VAR_ALT_HANDLE) {
- rc = ((EjsAltStringCFunction) prototype->cFunctionWithStrings.fn)
- (ep->eid, ep->altHandle, actualArgs->used, argBuf);
- } else if (prototype->flags & MPR_VAR_SCRIPT_HANDLE) {
- rc = (prototype->cFunctionWithStrings.fn)(ep->eid,
- actualArgs->used, argBuf);
- } else {
- rc = (prototype->cFunctionWithStrings.fn)(ep->primaryHandle,
- actualArgs->used, argBuf);
- }
-
- if (actualArgs->used > 0) {
- for (i = 0; i < actualArgs->used; i++) {
- mprFree(argBuf[i]);
- }
- mprFree(argBuf);
- }
- ep->thisPtr = 0;
- break;
-
- case MPR_TYPE_CFUNCTION:
- /*
- * Call the function depending on the various handle flags
- */
- ep->thisPtr = prototype->cFunction.thisPtr;
- if (prototype->flags & MPR_VAR_ALT_HANDLE) {
- rc = ((EjsAltCFunction) prototype->cFunction.fn)
- (ep->eid, ep->altHandle, actualArgs->used, argValues);
- } else if (prototype->flags & MPR_VAR_SCRIPT_HANDLE) {
- rc = (prototype->cFunction.fn)(ep->eid, actualArgs->used,
- argValues);
- } else {
- rc = (prototype->cFunction.fn)(ep->primaryHandle,
- actualArgs->used, argValues);
- }
- ep->thisPtr = 0;
- break;
-
- case MPR_TYPE_FUNCTION:
-
- formalArgs = prototype->function.args;
- argNames = (char**) formalArgs->handles;
-
- if (formalArgs->used > actualArgs->used) {
- ejsError(ep, "Bad number of args. Should be %d",
- formalArgs->used);
- return -1;
- }
-
- /*
- * Create the arguments and callee variables
- */
- arguments = ejsCreateObj("arguments", EJS_SMALL_OBJ_HASH_SIZE);
- callee = ejsCreateObj("callee", EJS_SMALL_OBJ_HASH_SIZE);
-
- /*
- * Overwrite the length property
- */
- mprCreatePropertyValue(&arguments, "length",
- mprCreateIntegerVar(actualArgs->used));
- mprCreatePropertyValue(&callee, "length",
- mprCreateIntegerVar(formalArgs->used));
-
- /*
- * Define all the agruments to be set to the actual parameters
- */
- for (i = 0; i < formalArgs->used; i++) {
- mprCreateProperty(ep->local, argNames[i], argValues[i]);
- }
- for (i = 0; i < actualArgs->used; i++) {
- mprItoa(i, buf, sizeof(buf));
- mprCreateProperty(&arguments, buf, argValues[i]);
- }
-
- mprCreateProperty(&arguments, "callee", &callee);
- mprCreateProperty(ep->local, "arguments", &arguments);
-
- /*
- * Can destroy our variables here as they are now referenced via
- * "local"
- */
- mprDestroyVar(&callee);
- mprDestroyVar(&arguments);
-
- /*
- * Actually run the function
- */
- rc = ejsEvalScript(ep->eid, prototype->function.body, 0, 0);
- break;
- }
-
- ejsCloseBlock(ep->eid, fid);
-
- /*
- * New statements return the newly created object as the result of the
- * command
- */
- if (flags & EJS_FLAGS_NEW) {
- mprDestroyVar(&ep->result);
- /*
- * Don't copy, we want to assign the actual object into result.
- * (mprCopyVar would inc the refCount to 2).
- */
- ep->result = thisObject;
- }
- return rc;
-}
-
-/******************************************************************************/
-/*
- * Run a function
- */
-
-int ejsRunFunction(int eid, MprVar *obj, const char *functionName,
- MprArray *args)
-{
- EjsProc proc, *saveProc;
- Ejs *ep;
- int rc;
-
- mprAssert(obj);
- mprAssert(functionName && *functionName);
-
- if ((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- return MPR_ERR_NOT_FOUND;
- }
- saveProc = ep->proc;
- ep->proc = &proc;
-
- memset(&proc, 0, sizeof(EjsProc));
- mprDestroyVar(&ep->result);
-
- proc.fn = mprGetProperty(obj, functionName, 0);
- if (proc.fn == 0 || proc.fn->type == MPR_TYPE_UNDEFINED) {
- ep->proc = saveProc;
- return MPR_ERR_NOT_FOUND;
- }
- proc.procName = mprStrdup(functionName);
- if (args == 0) {
- proc.args = mprCreateArray();
- rc = evalFunction(ep, obj, 0);
- } else {
- proc.args = args;
- rc = evalFunction(ep, obj, 0);
- proc.args = 0;
- }
-
- freeProc(&proc);
- ep->proc = saveProc;
-
- return rc;
-}
-
-/******************************************************************************/
-/*
- * Find which object contains the property given the current context.
- * Only used for top level properties.
- */
-
-MprVar *ejsFindObj(Ejs *ep, int state, const char *property, int flags)
-{
- MprVar *obj;
-
- mprAssert(ep);
- mprAssert(property && *property);
-
- if (flags & EJS_FLAGS_GLOBAL) {
- obj = ep->global;
-
- } else if (state == EJS_STATE_DEC || flags & EJS_FLAGS_LOCAL) {
- obj = ep->local;
-
- } else {
- /* First look local, then look global */
- if (mprGetProperty(ep->local, property, 0)) {
- obj = ep->local;
- } else {
- obj = ep->global;
- }
- }
- return obj;
-}
-
-/******************************************************************************/
-/*
- * Find an object property given a object and a property name. We
- * intelligently look in the local and global namespaces depending on
- * our state. If not found in local or global, try base classes for function
- * names only. Returns the property or NULL.
- */
-
-MprVar *ejsFindProperty(Ejs *ep, int state, MprVar *obj, char *property,
- int flags)
-{
- MprVar *vp;
-
- mprAssert(ep);
- if (flags & EJS_FLAGS_EXE) {
- mprAssert(property && *property);
- }
-
- if (obj != 0) {
-#if FUTURE && MB
- op = obj;
- do {
- vp = mprGetProperty(op, property, 0);
- if (vp != 0) {
- if (op != obj && mprVarIsFunction(vp->type)) {
- }
- break;
- }
- op = op->baseObj;
- } while (op);
-#endif
- vp = mprGetProperty(obj, property, 0);
-
- } else {
- if (state == EJS_STATE_DEC) {
- vp = mprGetProperty(ep->local, property, 0);
-
- } else {
- /* Look local first, then global */
- vp = mprGetProperty(ep->local, property, 0);
- if (vp == NULL) {
- vp = mprGetProperty(ep->global, property, 0);
- }
- }
- }
- return vp;
-}
-
-/******************************************************************************/
-/*
- * Update result
- */
-
-static void updateResult(Ejs *ep, int state, int flags, MprVar *vp)
-{
- if (flags & EJS_FLAGS_EXE && state != EJS_STATE_DEC) {
- mprDestroyVar(&ep->result);
- if (vp) {
- mprCopyProperty(&ep->result, vp, MPR_SHALLOW_COPY);
- }
- }
-}
-
-/******************************************************************************/
-/*
- * Append to the pointer value
- */
-
-static void appendValue(MprVar *dest, MprVar *src)
-{
- char *value, *oldBuf, *buf;
- int len, oldLen;
-
- mprAssert(dest);
-
- mprVarToString(&value, MPR_MAX_STRING, 0, src);
-
- if (mprVarIsValid(dest)) {
- len = strlen(value);
- oldBuf = dest->string;
- oldLen = strlen(oldBuf);
- buf = mprRealloc(oldBuf, (len + oldLen + 1) * sizeof(char));
- dest->string = buf;
- strcpy(&buf[oldLen], value);
-
- } else {
- *dest = mprCreateStringVar(value, 1);
- }
- mprFree(value);
-}
-
-/******************************************************************************/
-/*
- * Exit with status
- */
-
-void ejsSetExitStatus(int eid, int status)
-{
- Ejs *ep;
-
- if ((ep = ejsPtr(eid)) == NULL) {
- mprAssert(ep);
- return;
- }
- ep->exitStatus = status;
- ep->flags |= EJS_FLAGS_EXIT;
-}
-
-/******************************************************************************/
-/*
- * Free an argument list
- */
-
-static void freeProc(EjsProc *proc)
-{
- MprVar **argValues;
- int i;
-
- if (proc->args) {
- argValues = (MprVar**) proc->args->handles;
-
- for (i = 0; i < proc->args->max; i++) {
- if (argValues[i]) {
- mprDestroyVar(argValues[i]);
- mprFree(argValues[i]);
- mprRemoveFromArray(proc->args, i);
- }
- }
-
- mprDestroyArray(proc->args);
- }
-
- if (proc->procName) {
- mprFree(proc->procName);
- proc->procName = NULL;
- }
-}
-
-/******************************************************************************/
-/*
- * This function removes any new lines. Used for else cases, etc.
- */
-
-static void removeNewlines(Ejs *ep, int state)
-{
- int tid;
-
- do {
- tid = ejsLexGetToken(ep, state);
- } while (tid == EJS_TOK_NEWLINE);
-
- ejsLexPutbackToken(ep, tid, ep->token);
-}
-
-/******************************************************************************/
-
-#else
-void ejsParserDummy() {}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_EJS */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/ejs/ejsProcs.c b/source4/lib/appweb/ejs/ejsProcs.c
deleted file mode 100644
index 43fff4a40b..0000000000
--- a/source4/lib/appweb/ejs/ejsProcs.c
+++ /dev/null
@@ -1,704 +0,0 @@
-/*
- * @file ejsProc.c
- * @brief EJS support functions
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default.g
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved.
- * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "ejsInternal.h"
-
-#if BLD_FEATURE_EJS
-
-/****************************** Forward Declarations **************************/
-/*
- * Object constructors
- */
-static int objectConsProc(EjsHandle eid, int argc, MprVar **argv);
-static int arrayConsProc(EjsHandle eid, int argc, MprVar **argv);
-static int booleanConsProc(EjsHandle eid, int argc, MprVar **agv);
-static int numberConsProc(EjsHandle eid, int argc, MprVar **argv);
-static int stringConsProc(EjsHandle eid, int argc, MprVar **argv);
-
-/*
- * Core functions
- */
-static int toStringProc(EjsHandle eid, int argc, MprVar **argv);
-static int valueOfProc(EjsHandle eid, int argc, MprVar **argv);
-
-/*
- * Triggers
- */
-static MprVarTriggerStatus lengthTrigger(MprVarTriggerOp op,
- MprProperties *parentProperties, MprVar *prop, MprVar *newValue,
- int copyRef);
-
-/******************************************************************************/
-/*
- * Routine to create the base common to all object types
- */
-
-MprVar ejsCreateObj(const char *name, int hashSize)
-{
- MprVar o;
-
- o = mprCreateObjVar(name, hashSize);
- if (o.type == MPR_TYPE_UNDEFINED) {
- mprAssert(0);
- return o;
- }
-
- mprCreatePropertyValue(&o, "toString",
- mprCreateCFunctionVar(toStringProc, 0, MPR_VAR_SCRIPT_HANDLE));
- mprCreatePropertyValue(&o, "valueOf",
- mprCreateCFunctionVar(valueOfProc, 0, MPR_VAR_SCRIPT_HANDLE));
- return o;
-}
-
-/******************************************************************************/
-/*
- * Routine to destroy a variable
- */
-
-bool ejsDestroyVar(MprVar *obj)
-{
- return mprDestroyVar(obj);
-}
-
-/******************************************************************************/
-/*
- * Routine to create the base array type
- */
-
-MprVar ejsCreateArray(const char *name, int size)
-{
- MprVar obj, *lp, undef;
- char idx[16];
- int i;
-
- /* Sanity limit for size of hash table */
-
- obj = ejsCreateObj(name, max(size, 503));
- if (obj.type == MPR_TYPE_UNDEFINED) {
- mprAssert(0);
- return obj;
- }
-
- undef = mprCreateUndefinedVar();
- for (i = 0; i < size; i++) {
- mprItoa(i, idx, sizeof(idx));
- mprCreateProperty(&obj, idx, &undef);
- }
-
- lp = mprCreatePropertyValue(&obj, "length", mprCreateIntegerVar(size));
- mprAssert(lp);
-
- mprSetVarReadonly(lp, 1);
- mprAddVarTrigger(lp, lengthTrigger);
-
- return obj;
-}
-
-/******************************************************************************/
-/******************************** Constructors ********************************/
-/******************************************************************************/
-/*
- * Object constructor. Nothing really done here. For future expansion.
- */
-
-static int objectConsProc(EjsHandle eid, int argc, MprVar **argv)
-{
-#if XX_UNUSED_XX
- MprVar *obj;
- Ejs *ep;
-
- if((ep = ejsPtr(eid)) == NULL) {
- return -1;
- }
-
- obj = mprGetProperty(ep->local, "this", 0);
- mprAssert(obj);
-#endif
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Array constructor
- */
-
-static int arrayConsProc(EjsHandle eid, int argc, MprVar **argv)
-{
- MprVar *obj, *lp, undef;
- Ejs *ep;
- char idx[16];
- int i, max;
-
- objectConsProc(eid, argc, argv);
-
- if((ep = ejsPtr(eid)) == NULL) {
- return -1;
- }
- obj = mprGetProperty(ep->local, "this", 0);
- mprAssert(obj);
-
-
- if (argc == 1 && mprVarIsNumber(argv[0]->type)) {
- /*
- * x = new Array(size);
- */
- undef = mprCreateUndefinedVar();
- max = (int) mprVarToInteger(argv[0]);
- for (i = 0; i < max; i++) {
- mprItoa(i, idx, sizeof(idx));
- mprCreateProperty(obj, idx, &undef);
- }
- } else {
- /*
- * x = new Array(element0, element1, ..., elementN):
- */
- max = argc;
- for (i = 0; i < max; i++) {
- mprItoa(i, idx, sizeof(idx));
- mprCreateProperty(obj, idx, argv[i]);
- }
- }
-
- lp = mprCreatePropertyValue(obj, "length", mprCreateIntegerVar(max));
- mprAssert(lp);
-
- mprSetVarReadonly(lp, 1);
- mprAddVarTrigger(lp, lengthTrigger);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Boolean constructor
- */
-
-static int booleanConsProc(EjsHandle eid, int argc, MprVar **argv)
-{
- objectConsProc(eid, argc, argv);
- return 0;
-}
-
-/******************************************************************************/
-#if FUTURE
-/*
- * Date constructor
- */
-
-static int dateConsProc(EjsHandle eid, int argc, MprVar **argv)
-{
- objectConsProc(eid, argc, argv);
- return 0;
-}
-
-#endif
-/******************************************************************************/
-/*
- * Number constructor
- */
-
-static int numberConsProc(EjsHandle eid, int argc, MprVar **argv)
-{
- objectConsProc(eid, argc, argv);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * String constructor
- */
-
-static int stringConsProc(EjsHandle eid, int argc, MprVar **argv)
-{
- objectConsProc(eid, argc, argv);
- return 0;
-}
-
-/******************************************************************************/
-/********************************** Functions *********************************/
-/******************************************************************************/
-
-static int toStringProc(EjsHandle eid, int argc, MprVar **argv)
-{
- MprVar *obj;
- Ejs *ep;
- char *buf;
- int radix;
-
- if (argc == 0) {
- radix = 10;
-
- } else if (argc == 1) {
- radix = (int) mprVarToInteger(argv[0]);
-
- } else {
- mprAssert(0);
- return -1;
- }
-
- if((ep = ejsPtr(eid)) == NULL) {
- return -1;
- }
-
- obj = mprGetProperty(ep->local, "this", 0);
- mprAssert(obj);
-
- mprVarToString(&buf, MPR_MAX_STRING, 0, obj);
- mprCopyVarValue(&ep->result, mprCreateStringVar(buf, 0), MPR_SHALLOW_COPY);
- mprFree(buf);
-
- return 0;
-}
-
-/******************************************************************************/
-
-static int valueOfProc(EjsHandle eid, int argc, MprVar **argv)
-{
- MprVar *obj;
- Ejs *ep;
-
- if (argc != 0) {
- mprAssert(0);
- return -1;
- }
-
- if((ep = ejsPtr(eid)) == NULL) {
- return -1;
- }
-
- obj = mprGetProperty(ep->local, "this", 0);
- mprAssert(obj);
-
- switch (obj->type) {
- default:
- case MPR_TYPE_UNDEFINED:
- case MPR_TYPE_NULL:
- case MPR_TYPE_CFUNCTION:
- case MPR_TYPE_OBJECT:
- case MPR_TYPE_FUNCTION:
- case MPR_TYPE_STRING_CFUNCTION:
- case MPR_TYPE_PTR:
- mprCopyVar(&ep->result, obj, MPR_SHALLOW_COPY);
- break;
-
- case MPR_TYPE_STRING:
- mprCopyVarValue(&ep->result, mprCreateIntegerVar(atoi(obj->string)), 0);
- break;
-
- case MPR_TYPE_BOOL:
- case MPR_TYPE_INT:
-#if BLD_FEATURE_INT64
- case MPR_TYPE_INT64:
-#endif
-#if BLD_FEATURE_FLOATING_POINT
- case MPR_TYPE_FLOAT:
-#endif
- mprCopyVar(&ep->result, obj, 0);
- break;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Var access trigger on the Array.length property. Return the count of
- * enumerable properties (don't count functions).
- */
-
-static MprVarTriggerStatus lengthTrigger(MprVarTriggerOp op,
- MprProperties *parentProperties, MprVar *prop, MprVar *newValue,
- int copyRef)
-{
- switch (op) {
- case MPR_VAR_READ:
- /*
- * Subtract one for the length property
- * FUTURE -- need an API to access parentProperties
- * FUTURE -- contradiction to be read-only yet allow USE_NEW_VALUE.
- * API needs finer control.
- */
- *newValue = mprCreateIntegerVar(parentProperties->numDataItems - 1);
- return MPR_TRIGGER_USE_NEW_VALUE;
-
- case MPR_VAR_WRITE:
- return MPR_TRIGGER_ABORT;
-
- case MPR_VAR_CREATE_PROPERTY:
- case MPR_VAR_DELETE_PROPERTY:
- case MPR_VAR_DELETE:
- default:
- break;
- }
- return MPR_TRIGGER_PROCEED;
-}
-
-/******************************************************************************/
-/**************************** Extension Functions *****************************/
-/******************************************************************************/
-/*
- * Assert
- */
-
-static int assertProc(EjsHandle eid, int argc, MprVar **argv)
-{
- bool b;
-
- if (argc < 1) {
- ejsSetErrorMsg(eid, "usage: assert(condition)\n");
- return -1;
- }
- b = mprVarToBool(argv[0]);
- if (b == 0) {
- ejsSetErrorMsg(eid, "Assertion failure\n");
- return -1;
- }
- ejsSetReturnValue(eid, mprCreateBoolVar(b));
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Exit
- */
-
-static int exitProc(EjsHandle eid, int argc, MprVar **argv)
-{
- int status;
-
- if (argc < 1) {
- ejsSetErrorMsg(eid, "usage: exit(status)\n");
- return -1;
- }
- status = (int) mprVarToInteger(argv[0]);
- ejsSetExitStatus(eid, status);
-
- ejsSetReturnValue(eid, mprCreateStringVar("", 0));
- return 0;
-}
-
-/******************************************************************************/
-
-static void printVar(MprVar *vp, int recurseCount, int indent)
-{
- MprVar *np;
- char *buf;
- int i;
-
- if (recurseCount > 5) {
- write(1, "Skipping - recursion too deep\n", 29);
- return;
- }
-
- for (i = 0; i < indent; i++) {
- write(1, " ", 2);
- }
-
- if (vp->type == MPR_TYPE_OBJECT) {
- if (vp->name) {
- write(1, vp->name, strlen(vp->name));
- } else {
- write(1, "unknown", 7);
- }
- write(1, ": {\n", 4);
- np = mprGetFirstProperty(vp, MPR_ENUM_DATA);
- while (np) {
- if (strcmp(np->name, "local") == 0 ||
- strcmp(np->name, "global") == 0 ||
- strcmp(np->name, "this") == 0) {
- np = mprGetNextProperty(vp, np, MPR_ENUM_DATA);
- continue;
- }
- printVar(np, recurseCount + 1, indent + 1);
- np = mprGetNextProperty(vp, np, MPR_ENUM_DATA);
- if (np) {
- write(1, ",\n", 2);
- }
- }
- write(1, "\n", 1);
- for (i = 0; i < indent; i++) {
- write(1, " ", 2);
- }
- write(1, "}", 1);
-
- } else {
- if (vp->name) {
- write(1, vp->name, strlen(vp->name));
- } else {
- write(1, "unknown", 7);
- }
- write(1, ": ", 2);
-
- /* FUTURE -- other types ? */
- mprVarToString(&buf, MPR_MAX_STRING, 0, vp);
- if (vp->type == MPR_TYPE_STRING) {
- write(1, "\"", 1);
- }
- write(1, buf, strlen(buf));
- if (vp->type == MPR_TYPE_STRING) {
- write(1, "\"", 1);
- }
- mprFree(buf);
- }
-}
-
-/******************************************************************************/
-/*
- * Print the args to stdout
- */
-
-static int printVarsProc(EjsHandle eid, int argc, MprVar **argv)
-{
- MprVar *vp;
- char *buf;
- int i;
-
- for (i = 0; i < argc; i++) {
- vp = argv[i];
- switch (vp->type) {
- case MPR_TYPE_OBJECT:
- printVar(vp, 0, 0);
- break;
- default:
- mprVarToString(&buf, MPR_MAX_STRING, 0, vp);
- write(1, buf, strlen(buf));
- mprFree(buf);
- break;
- }
- }
- write(1, "\n", 1);
-
- ejsSetReturnValue(eid, mprCreateStringVar("", 0));
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Print the args to stdout
- */
-
-static int printProc(EjsHandle eid, int argc, MprVar **argv)
-{
- char *buf;
- int i;
-
- for (i = 0; i < argc; i++) {
- mprVarToString(&buf, MPR_MAX_STRING, 0, argv[i]);
- write(1, buf, strlen(buf));
- mprFree(buf);
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * println
- */
-
-static int printlnProc(EjsHandle eid, int argc, MprVar **argv)
-{
- printProc(eid, argc, argv);
- write(1, "\n", 1);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Trace
- */
-
-static int traceProc(EjsHandle eid, int argc, char **argv)
-{
- if (argc == 1) {
- mprLog(0, "%s", argv[0]);
-
- } else if (argc == 2) {
- mprLog(atoi(argv[0]), "%s", argv[1]);
-
- } else {
- ejsSetErrorMsg(eid, "Usage: trace([level], message)");
- return -1;
- }
- ejsSetReturnString(eid, "");
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Return the object reference count
- */
-
-static int refCountProc(EjsHandle eid, int argc, MprVar **argv)
-{
- MprVar *vp;
- int count;
-
- vp = argv[0];
- if (vp->type == MPR_TYPE_OBJECT) {
- count = mprGetVarRefCount(vp);
- ejsSetReturnValue(eid, mprCreateIntegerVar(count));
- } else {
- ejsSetReturnValue(eid, mprCreateIntegerVar(0));
- }
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Evaluate a sub-script. It is evaluated in the same variable scope as
- * the calling script / function.
- */
-
-static int evalScriptProc(EjsHandle eid, int argc, MprVar **argv)
-{
- MprVar *arg;
- char *emsg;
- int i;
-
- ejsSetReturnValue(eid, mprCreateUndefinedVar());
-
- for (i = 0; i < argc; i++) {
- arg = argv[i];
- if (arg->type != MPR_TYPE_STRING) {
- continue;
- }
- if (ejsEvalScript(eid, arg->string, 0, &emsg) < 0) {
- ejsSetErrorMsg(eid, "%s", emsg);
- mprFree(emsg);
- return -1;
- }
- }
- /*
- * Return with the value of the last expression
- */
- return 0;
-}
-
-/******************************************************************************/
-/******************************************************************************/
-/******************************************************************************/
-/*
- * Define the standard properties and functions inherited by all script engines.
- */
-
-int ejsDefineStandardProperties(MprVar *obj)
-{
-#if BLD_FEATURE_FLOATING_POINT
- double d = 0.0;
-
- /* FUTURE - this generates warnings on some systems. This is okay. */
-
- mprCreatePropertyValue(obj, "NaN", mprCreateFloatVar(0.0 / d));
- d = MAX_FLOAT;
- mprCreatePropertyValue(obj, "Infinity", mprCreateFloatVar(d * d));
-#endif
- mprCreatePropertyValue(obj, "null", mprCreateNullVar());
- mprCreatePropertyValue(obj, "undefined", mprCreateUndefinedVar());
- mprCreatePropertyValue(obj, "true", mprCreateBoolVar(1));
- mprCreatePropertyValue(obj, "false", mprCreateBoolVar(0));
- mprCreatePropertyValue(obj, "NULL", mprCreatePtrVar(NULL));
-
-#if BLD_FEATURE_LEGACY_API
- /*
- * DEPRECATED: 2.0.
- * So that ESP/ASP can ignore "language=javascript" statements
- */
- mprCreatePropertyValue(obj, "javascript", mprCreateIntegerVar(0));
-#endif
-
- /*
- * Extension functions
- */
- mprCreatePropertyValue(obj, "assert",
- mprCreateCFunctionVar(assertProc, 0, MPR_VAR_SCRIPT_HANDLE));
- mprCreatePropertyValue(obj, "eval",
- mprCreateCFunctionVar(evalScriptProc, 0, MPR_VAR_SCRIPT_HANDLE));
- mprCreatePropertyValue(obj, "exit",
- mprCreateCFunctionVar(exitProc, 0, MPR_VAR_SCRIPT_HANDLE));
- mprCreatePropertyValue(obj, "refCount",
- mprCreateCFunctionVar(refCountProc, 0, MPR_VAR_SCRIPT_HANDLE));
- mprCreatePropertyValue(obj, "print",
- mprCreateCFunctionVar(printProc, 0, MPR_VAR_SCRIPT_HANDLE));
- mprCreatePropertyValue(obj, "println",
- mprCreateCFunctionVar(printlnProc, 0, MPR_VAR_SCRIPT_HANDLE));
- mprCreatePropertyValue(obj, "printVars",
- mprCreateCFunctionVar(printVarsProc,0, MPR_VAR_SCRIPT_HANDLE));
- mprCreatePropertyValue(obj, "trace",
- mprCreateStringCFunctionVar(traceProc, 0, MPR_VAR_SCRIPT_HANDLE));
-
- /*
- * Constructors
- */
- mprCreatePropertyValue(obj, "Array",
- mprCreateCFunctionVar(arrayConsProc, 0, MPR_VAR_SCRIPT_HANDLE));
- mprCreatePropertyValue(obj, "Boolean",
- mprCreateCFunctionVar(booleanConsProc, 0, MPR_VAR_SCRIPT_HANDLE));
- mprCreatePropertyValue(obj, "Object",
- mprCreateCFunctionVar(objectConsProc, 0, MPR_VAR_SCRIPT_HANDLE));
- mprCreatePropertyValue(obj, "Number",
- mprCreateCFunctionVar(numberConsProc, 0, MPR_VAR_SCRIPT_HANDLE));
- mprCreatePropertyValue(obj, "String",
- mprCreateCFunctionVar(stringConsProc, 0, MPR_VAR_SCRIPT_HANDLE));
-
- /* mprCreatePropertyValue(obj, "Date",
- * mprCreateCFunctionVar(dateConsProc, 0, MPR_VAR_SCRIPT_HANDLE));
- * mprCreatePropertyValue(obj, "Regexp",
- * mprCreateCFunctionVar(regexpConsProc, 0, MPR_VAR_SCRIPT_HANDLE));
- */
-
- /*
- * Can we use on var x = "string text";
- */
- return 0;
-}
-
-/******************************************************************************/
-
-#else
-void ejsProcsDummy() {}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_EJS */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/esp/esp.c b/source4/lib/appweb/esp/esp.c
deleted file mode 100644
index 3e47503edf..0000000000
--- a/source4/lib/appweb/esp/esp.c
+++ /dev/null
@@ -1,1042 +0,0 @@
-/*
- * @file esp.c
- * @brief Embedded Server Pages (ESP) core processing.
- * @overview Embedded Server Pages provides an efficient way to generate
- * dynamic pages using server-side Javascript. This code provides
- * core processing, and should be called by an associated web
- * server URL handler.
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "esp.h"
-
-#if BLD_FEATURE_ESP_MODULE
-
-/*********************************** Locals ***********************************/
-/*
- * Master ESP control interface with the web server
- */
-
-static const Esp *esp;
-
-/***************************** Forward Declarations ***************************/
-
-static int buildScript(EspRequest *ep, char **jsBuf, char *input, char
- **errMsg);
-
-/************************************ Code ************************************/
-/*
- * Called at server initialization
- */
-
-int espOpen(const Esp *control)
-{
- mprAssert(control);
-
-#if BLD_FEATURE_MULTITHREAD
- ejsOpen(control->lock, control->unlock, control->lockData);
-#else
- ejsOpen(0, 0, 0);
-#endif
-
- /*
- * Register the standard procedures
- */
- espRegisterProcs();
-
- /*
- * Just for brain dead systems that don't zero global memory
- */
- esp = control;
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Called at server termination
- */
-
-void espClose()
-{
- ejsClose();
-}
-
-/******************************************************************************/
-/*
- * Create for new ESP request. Assumed that this is called after all the
- * HTTP headers have been read but before POST data has been read. It is
- * expected that any session cookies have been read and that "variables"
- * contains references to all the environment objects including "session".
- * requestHandle is the web server request handle.
- */
-
-EspRequest *espCreateRequest(EspHandle webServerRequestHandle, char *uri,
- MprVar *variables)
-{
- EspRequest *ep;
- MprVar *global;
-#if BLD_FEATURE_LEGACY_API
- MprVar *np;
- char keyBuf[ESP_MAX_HEADER];
- int i;
-#endif
-
- mprAssert(variables);
-
- ep = mprMalloc(sizeof(EspRequest));
- if (ep == 0) {
- return 0;
- }
- memset(ep, 0, sizeof(EspRequest));
- ep->requestHandle = webServerRequestHandle;
- ep->esp = esp;
- ep->uri = mprStrdup(uri);
- ep->docPath = 0;
- ep->variables = variables;
-
- /*
- * The handle passed to ejsOpenEngine is passed to every C function
- * called by JavaScript.
- */
- ep->eid = ejsOpenEngine((EjsHandle) ep, (EjsHandle) webServerRequestHandle);
- if (ep->eid < 0) {
- mprFree(ep);
- return 0;
- }
-
- /*
- * All these copies and SetProperties will only copy references
- * They will increments the object ref counts.
- */
- mprCopyVar(&variables[ESP_GLOBAL_OBJ], ejsGetGlobalObject(ep->eid),
- MPR_SHALLOW_COPY);
- mprCopyVar(&variables[ESP_LOCAL_OBJ], ejsGetLocalObject(ep->eid),
- MPR_SHALLOW_COPY);
-
- global = &variables[ESP_GLOBAL_OBJ];
- mprCreateProperty(global, "application", &variables[ESP_APPLICATION_OBJ]);
- mprCreateProperty(global, "cookies", &variables[ESP_COOKIES_OBJ]);
- mprCreateProperty(global, "files", &variables[ESP_FILES_OBJ]);
- mprCreateProperty(global, "form", &variables[ESP_FORM_OBJ]);
- mprCreateProperty(global, "headers", &variables[ESP_HEADERS_OBJ]);
- mprCreateProperty(global, "request", &variables[ESP_REQUEST_OBJ]);
-
- /*
- * FUTURE -- could server be shared across all requests for a given host
- * and be made read-only.
- */
- mprCreateProperty(global, "server", &variables[ESP_SERVER_OBJ]);
-
-#if BLD_FEATURE_SESSION
- mprCreateProperty(global, "session", &variables[ESP_SESSION_OBJ]);
-#endif
-
-#if BLD_FEATURE_LEGACY_API
- /*
- * DEPRECATED: 2.0
- * Define variables as globals. headers[] are prefixed with "HTTP_".
- * NOTE: MaRequest::setVar does not copy into globals, whereas espSetVar
- * does if legacy_api is defined. So variables pre-defined by MaRequest
- * must be copied here into globals[].
- *
- * NOTE: if a variable is in session[] and in form[], the form[] will
- * override being later in the variables[] list. Use mprSetProperty
- * instead of mprCreateProperty to cover for this case.
- */
- for (i = 0; i < ESP_OBJ_MAX; i++) {
- if (i == ESP_GLOBAL_OBJ || i == ESP_LOCAL_OBJ) {
- continue;
- }
- if (variables[i].type != MPR_TYPE_OBJECT) {
- continue;
- }
- np = mprGetFirstProperty(&variables[i], MPR_ENUM_DATA);
- while (np) {
- if (i == ESP_HEADERS_OBJ) {
- mprSprintf(keyBuf, sizeof(keyBuf) - 1, "HTTP_%s", np->name);
- mprSetProperty(global, keyBuf, np);
- } else {
- mprSetProperty(global, np->name, np);
- }
- np = mprGetNextProperty(&variables[i], np, MPR_ENUM_DATA);
- }
- }
-#endif
- return ep;
-}
-
-/******************************************************************************/
-
-void espDestroyRequest(EspRequest *ep)
-{
- mprAssert(ep);
- mprAssert(ep->eid >= 0);
-
- mprFree(ep->uri);
- mprFree(ep->docPath);
- ejsCloseEngine(ep->eid);
- mprFree(ep);
-}
-
-/******************************************************************************/
-/*
- * The callback function will be called:
- *
- * (fn)(EjsId eid, EspRequest *ep, argc, argv);
- *
- * Callers can get their web server handle by calling:
- *
- * rq = (requiredCast) espGetHandle(ep);
- */
-
-void espDefineCFunction(EspRequest *ep, const char *functionName, EspCFunction fn,
- void *thisPtr)
-{
- mprAssert(functionName && *functionName);
- mprAssert(fn);
-
- if (ep) {
- ejsDefineCFunction(ep->eid, functionName, (MprCFunction) fn,
- thisPtr, 0);
- } else {
- ejsDefineCFunction(-1, functionName, (MprCFunction) fn, thisPtr, 0);
- }
-}
-
-/******************************************************************************/
-
-void espDefineStringCFunction(EspRequest *ep, const char *functionName,
- EspStringCFunction fn, void *thisPtr)
-{
- mprAssert(functionName && *functionName);
- mprAssert(fn);
-
- if (ep) {
- ejsDefineStringCFunction(ep->eid, functionName, (MprStringCFunction) fn,
- thisPtr, 0);
- } else {
- ejsDefineStringCFunction(-1, functionName, (MprStringCFunction) fn,
- thisPtr, 0);
- }
-}
-
-/******************************************************************************/
-
-void *espGetRequestHandle(EspRequest *ep)
-{
- return ep->requestHandle;
-}
-
-/******************************************************************************/
-
-EjsId espGetScriptHandle(EspRequest *ep)
-{
- return ep->eid;
-}
-
-/******************************************************************************/
-
-char *espGetStringVar(EspRequest *ep, EspEnvType oType, char *var,
- char *defaultValue)
-{
- MprVar value;
-
- if (espGetVar(ep, oType, var, &value) < 0 ||
- value.type != MPR_TYPE_STRING) {
- return defaultValue;
- }
- return value.string;
-}
-
-/******************************************************************************/
-
-int espGetVar(EspRequest *ep, EspEnvType oType, char *var, MprVar *value)
-{
- MprVar *vp;
-
- mprAssert(ep);
- mprAssert(var);
-
- vp = mprGetProperty(&ep->variables[oType], var, 0);
- if (vp == 0) {
- return -1;
- }
- *value = *vp;
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Process the ESP page. docBuf holds the page already. We expect that
- * ep->variables holds all the pertinent environment variables.
- */
-
-int espProcessRequest(EspRequest *ep, const char *docPath, char *docBuf,
- char **errMsg)
-{
- char *jsBuf;
-
- mprAssert(ep);
-
- ep->docPath = mprStrdup(docPath);
-
- jsBuf = 0;
- if (buildScript(ep, &jsBuf, docBuf, errMsg) < 0) {
- return MPR_ERR_CANT_COMPLETE;
- }
-
- if (jsBuf) {
- mprLog(7, "esp: script is:\n%s\n", jsBuf);
-
- /*
- * Now evaluate the entire escript
- * MOB could cache the script
- */
- if (ejsEvalScript(ep->eid, jsBuf, 0, errMsg) < 0) {
- return MPR_ERR_ABORTED;
- }
-
- mprFree(jsBuf);
- }
- return 0;
-}
-
-/******************************************************************************/
-
-void espRedirect(EspRequest *ep, int code, char *url)
-{
- mprAssert(ep);
- mprAssert(url);
-
- ep->esp->redirect(ep->requestHandle, code, url);
-}
-
-/******************************************************************************/
-
-void espError(EspRequest *ep, const char *fmt, ...)
-{
- va_list args;
- char *buf;
-
- mprAssert(ep);
- mprAssert(fmt);
-
- va_start(args, fmt);
- mprAllocVsprintf(&buf, MPR_MAX_HEAP_SIZE, fmt, args);
- ejsSetErrorMsg(ep->eid, "%s", buf);
- mprFree(buf);
- va_end(args);
-}
-
-/******************************************************************************/
-
-void espSetHeader(EspRequest *ep, char *header, bool allowMultiple)
-{
- mprAssert(ep);
-
- ep->esp->setHeader(ep->requestHandle, header, allowMultiple);
-}
-
-/******************************************************************************/
-/*
- * Caller does not need to destroy the var
- */
-
-MprVar *espGetResult(EspRequest *ep)
-{
- mprAssert(ep);
-
- return ejsGetReturnValue(ep->eid);
-}
-
-/******************************************************************************/
-
-void espSetReturn(EspRequest *ep, MprVar value)
-{
- mprAssert(ep);
-
- ejsSetReturnValue(ep->eid, value);
-}
-
-/******************************************************************************/
-
-void espSetReturnString(EspRequest *ep, const char *str)
-{
- mprAssert(ep);
-
- ejsSetReturnValue(ep->eid, mprCreateStringVar(str, 0));
-}
-
-/******************************************************************************/
-
-void espSetResponseCode(EspRequest *ep, int code)
-{
- mprAssert(ep);
-
- ep->esp->setResponseCode(ep->requestHandle, code);
-}
-
-/******************************************************************************/
-
-void espSetVar(EspRequest *ep, EspEnvType oType, char *var, MprVar value)
-{
- mprCreatePropertyValue(&ep->variables[oType], var, value);
-}
-
-/******************************************************************************/
-
-void espSetStringVar(EspRequest *ep, EspEnvType oType,
- const char *var, const char *value)
-{
- /*
- * Will create or update if already existing
- */
- mprCreatePropertyValue(&ep->variables[oType], var,
- mprCreateStringVar(value, 0));
-}
-
-/******************************************************************************/
-
-int espUnsetVar(EspRequest *ep, EspEnvType oType, char *var)
-{
- return mprDeleteProperty(&ep->variables[oType], var);
-}
-
-/******************************************************************************/
-
-int espWrite(EspRequest *ep, char *buf, int size)
-{
- mprAssert(ep);
- mprAssert(buf);
- mprAssert(size >= 0);
-
- return ep->esp->writeBlock(ep->requestHandle, buf, size);
-}
-
-/******************************************************************************/
-
-int espWriteString(EspRequest *ep, char *buf)
-{
- mprAssert(ep);
- mprAssert(buf);
-
- return ep->esp->writeBlock(ep->requestHandle, buf, strlen(buf));
-}
-
-/******************************************************************************/
-
-int espWriteFmt(EspRequest *ep, char *fmt, ...)
-{
- va_list args;
- char *buf;
- int rc, len;
-
- mprAssert(ep);
- mprAssert(fmt);
-
- va_start(args, fmt);
- len = mprAllocVsprintf(&buf, MPR_MAX_HEAP_SIZE, fmt, args);
- rc = ep->esp->writeBlock(ep->requestHandle, buf, len);
- mprFree(buf);
- va_end(args);
- return rc;
-}
-
-/******************************************************************************/
-/******************************************************************************/
-/******************************************************************************/
-/*
- * Get a javascript identifier. Must allow x.y['abc'] or x.y["abc"].
- * Must be careful about quoting and only allow quotes inside [].
- */
-
-static int getIdentifier(EspParse *parse)
-{
- int atQuote, prevC, c;
-
- mprAssert(parse);
-
- atQuote = 0;
- prevC = 0;
- c = *parse->inp++;
-
- while (isalnum(c) || c == '_' || c == '.' || c == '[' ||
- c == ']' || c == '\'' || c == '\"') {
- if (c == '\'' || c == '\"') {
- if (c == atQuote) {
- atQuote = 0;
- } else if (prevC == '[') {
- atQuote = c;
- } else {
- break;
- }
- }
- if (parse->tokp >= parse->endp) {
- parse->token = (char*) mprRealloc(parse->token,
- parse->tokLen + ESP_TOK_INCR);
- if (parse->token == 0) {
- return MPR_ERR_CANT_ALLOCATE;
- }
- parse->token[parse->tokLen] = '\0';
- parse->tokLen += ESP_TOK_INCR;
- parse->endp = &parse->token[parse->tokLen - 1];
- }
- *parse->tokp++ = c;
- prevC = c;
- c = *parse->inp++;
- }
-
- parse->inp--;
- *parse->tokp = '\0';
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Get the next ESP input token. input points to the next input token.
- * parse->token will hold the parsed token. The function returns the token id.
- */
-
-static int getEspToken(int state, EspParse *parse)
-{
- char *cp;
- int tid, done, c, quoted;
-
- tid = ESP_TOK_LITERAL;
- parse->tokp = parse->token;
- parse->tokp[0] = '\0';
- quoted = 0;
-
- c = *parse->inp++;
- for (done = 0; !done; c = *parse->inp++) {
-
- /*
- * Get room for more characters in the token buffer
- */
- if (parse->tokp >= parse->endp) {
- parse->token = (char*) mprRealloc(parse->token,
- parse->tokLen + ESP_TOK_INCR);
- if (parse->token == 0) {
- return ESP_TOK_ERR;
- }
- parse->token[parse->tokLen] = '\0';
- parse->tokp = &parse->token[parse->tokLen - 1];
- parse->tokLen += ESP_TOK_INCR;
- parse->endp = &parse->token[parse->tokLen - 1];
- }
-
- switch (c) {
- case 0:
- if (*parse->token) {
- done++;
- parse->inp--;
- break;
- }
- return ESP_TOK_EOF;
-
- default:
- if (c == '\"' && state != ESP_STATE_IN_ESP_TAG) {
- *parse->tokp++ = '\\';
- }
- *parse->tokp++ = c;
- quoted = 0;
- break;
-
- case '\\':
- quoted = 1;
- *parse->tokp++ = c;
- break;
-
- case '@':
- if (*parse->inp == '@' && state != ESP_STATE_IN_ESP_TAG) {
- if (quoted) {
- parse->tokp--;
- quoted = 0;
- } else {
- if (*parse->token) {
- parse->inp--;
- } else {
- parse->inp++;
- tid = ESP_TOK_ATAT;
- if (getIdentifier(parse) < 0) {
- return ESP_TOK_ERR;
- }
- }
- done++;
- break;
- }
- }
- *parse->tokp++ = c;
- break;
-
- case '<':
- if (*parse->inp == '%' && state != ESP_STATE_IN_ESP_TAG) {
- if (quoted) {
- parse->tokp--;
- quoted = 0;
- *parse->tokp++ = c;
- break;
- }
- if (*parse->token) {
- parse->inp--;
- done++;
- break;
- }
- parse->inp++;
- while (isspace((int) *parse->inp)) {
- parse->inp++;
- }
- if (*parse->inp == '=') {
- parse->inp++;
- while (isspace((int) *parse->inp)) {
- parse->inp++;
- }
- tid = ESP_TOK_EQUALS;
- if (getIdentifier(parse) < 0) {
- return ESP_TOK_ERR;
- }
- done++;
- break;
- }
- if (*parse->inp == 'i' &&
- strncmp(parse->inp, "include", 7) == 0 &&
- isspace((int) parse->inp[7])) {
- tid = ESP_TOK_INCLUDE;
- parse->inp += 7;
- while (isspace((int) *parse->inp)) {
- parse->inp++;
- }
- while (*parse->inp && !isspace((int) *parse->inp) &&
- *parse->inp != '%' && parse->tokp < parse->endp) {
- *parse->tokp++ = *parse->inp++;
- }
- *parse->tokp = '\0';
- if (parse->token[0] == '"') {
- parse->tokp = parse->token;
- for (cp = &parse->token[1]; *cp; ) {
- *parse->tokp++ = *cp++;
- }
- if (cp[-1] == '"') {
- parse->tokp--;
- }
- *parse->tokp = '\0';
- }
-
- } else {
- tid = ESP_TOK_START_ESP;
- }
- done++;
- break;
- }
- *parse->tokp++ = c;
- break;
-
- case '%':
- if (*parse->inp == '>' && state == ESP_STATE_IN_ESP_TAG) {
- if (quoted) {
- parse->tokp--;
- quoted = 0;
- } else {
- if (*parse->token) {
- parse->inp--;
- } else {
- tid = ESP_TOK_END_ESP;
- parse->inp++;
- }
- done++;
- break;
- }
- }
- *parse->tokp++ = c;
- break;
- }
- }
-
- *parse->tokp = '\0';
- parse->inp--;
- return tid;
-}
-
-/******************************************************************************/
-/*
- * Convert an ESP page into a JavaScript. We also expand include files.
- */
-
-static int buildScript(EspRequest *ep, char **jsBuf, char *input, char **errMsg)
-{
- EspParse parse;
- char path[MPR_MAX_FNAME], dir[MPR_MAX_FNAME], incPath[MPR_MAX_FNAME];
- char *incBuf, *incText;
- int state, tid, len, rc, maxScriptSize, incSize;
-
- mprAssert(ep);
- mprAssert(jsBuf);
- mprAssert(input);
-
- rc = 0;
- len = 0;
- state = ESP_STATE_BEGIN;
- if (errMsg) {
- *errMsg = 0;
- }
-
- memset(&parse, 0, sizeof(parse));
- parse.token = (char*) mprMalloc(ESP_TOK_INCR);
- if (parse.token == 0) {
- return MPR_ERR_CANT_ALLOCATE;
- }
- parse.token[0] = '\0';
- parse.tokLen = ESP_TOK_INCR;
- parse.endp = &parse.token[parse.tokLen - 1];
- parse.tokp = parse.token;
- parse.inBuf = input;
- parse.inp = parse.inBuf;
-
- maxScriptSize = esp->maxScriptSize;
-
- tid = getEspToken(state, &parse);
- while (tid != ESP_TOK_EOF && len >= 0) {
-
- switch (tid) {
- default:
- case ESP_TOK_ERR:
- mprFree(parse.token);
- return MPR_ERR_BAD_SYNTAX;
-
- case ESP_TOK_LITERAL:
- len = mprReallocStrcat(jsBuf, maxScriptSize, len, 0,
- "write(\"", parse.token, "\");\n", NULL);
- break;
-
- case ESP_TOK_ATAT:
- /*
- * Trick to get undefined variables to evaluate to "".
- * Catenate with "" to cause toString to run.
- */
- len = mprReallocStrcat(jsBuf, maxScriptSize, len, 0,
- "write(\"\" + ", parse.token, ");\n", NULL);
- break;
-
- case ESP_TOK_EQUALS:
- len = mprReallocStrcat(jsBuf, maxScriptSize, len, 0,
- "write(\"\" + ", parse.token, ");\n", NULL);
- state = ESP_STATE_IN_ESP_TAG;
- break;
-
- case ESP_TOK_START_ESP:
- state = ESP_STATE_IN_ESP_TAG;
- tid = getEspToken(state, &parse);
- while (tid != ESP_TOK_EOF && tid != ESP_TOK_EOF &&
- tid != ESP_TOK_END_ESP && len >= 0) {
- len = mprReallocStrcat(jsBuf, maxScriptSize, len, 0,
- parse.token, NULL);
- tid = getEspToken(state, &parse);
- }
- state = ESP_STATE_BEGIN;
- break;
-
- case ESP_TOK_END_ESP:
- state = ESP_STATE_BEGIN;
- break;
-
- case ESP_TOK_INCLUDE:
- if (parse.token[0] == '/') {
- mprStrcpy(incPath, sizeof(incPath), parse.token);
- } else {
- mprGetDirName(dir, sizeof(dir), ep->uri);
- mprSprintf(incPath, sizeof(incPath), "%s/%s",
- dir, parse.token);
- }
- if (esp->mapToStorage(ep->requestHandle, path, sizeof(path),
- incPath, 0) < 0) {
- mprAllocSprintf(errMsg, MPR_MAX_STRING,
- "Can't find include file: %s", path);
- rc = MPR_ERR_CANT_OPEN;
- break;
- }
- if (esp->readFile(ep->requestHandle, &incText, &incSize, path) < 0){
- mprAllocSprintf(errMsg, MPR_MAX_STRING,
- "Can't read include file: %s", path);
- rc = MPR_ERR_CANT_READ;
- break;
- }
- incText[incSize] = '\0';
-
- /*
- * Recurse and process the include script
- */
- incBuf = 0;
- if ((rc = buildScript(ep, &incBuf, incText, errMsg)) < 0) {
- mprFree(incText);
- mprFree(parse.token);
- return rc;
- }
-
- len = mprReallocStrcat(jsBuf, maxScriptSize, len, 0, incBuf, NULL);
- mprFree(incText);
- mprFree(incBuf);
- state = ESP_STATE_IN_ESP_TAG;
- break;
- }
- tid = getEspToken(state, &parse);
- }
- mprFree(parse.token);
- if (len < 0) {
- mprAllocSprintf(errMsg, MPR_MAX_STRING,
- "Script token is too big in %s.\nConfigured maximum is %d.",
- path, maxScriptSize);
- return MPR_ERR_WONT_FIT;
- }
- return rc;
-}
-
-/******************************************************************************/
-/******************************* Wrapped Routines *****************************/
-/******************************************************************************/
-
-int espCopyVar(EspRequest *ep, char *var, MprVar *value, int copyDepth)
-{
- return ejsCopyVar(ep->eid, var, value, copyDepth);
-}
-
-/******************************************************************************/
-
-MprVar espCreateObjVar(char *name, int hashSize)
-{
- return ejsCreateObj(name, hashSize);
-}
-
-/******************************************************************************/
-
-MprVar espCreateArrayVar(char *name, int size)
-{
- return ejsCreateArray(name, size);
-}
-
-/******************************************************************************/
-
-bool espDestroyVar(MprVar *obj)
-{
- return ejsDestroyVar(obj);
-}
-
-/******************************************************************************/
-
-MprVar *espCreateProperty(MprVar *obj, char *property, MprVar *newValue)
-{
- return mprCreateProperty(obj, property, newValue);
-}
-
-/******************************************************************************/
-
-MprVar *espCreatePropertyValue(MprVar *obj, char *property, MprVar newValue)
-{
- return mprCreatePropertyValue(obj, property, newValue);
-}
-
-/******************************************************************************/
-
-void espDefineFunction(EspRequest *ep, const char *functionName, char *args, char *body)
-{
- ejsDefineFunction(ep->eid, functionName, args, body);
-}
-
-/******************************************************************************/
-
-int espDeleteProperty(MprVar *obj, char *property)
-{
- return mprDeleteProperty(obj, property);
-}
-
-/******************************************************************************/
-
-int espDeleteVar(EspRequest *ep, char *var)
-{
- return ejsDeleteVar(ep->eid, var);
-}
-
-/******************************************************************************/
-int espEvalFile(EspRequest *ep, char *path, MprVar *result, char **emsg)
-{
- return ejsEvalFile(ep->eid, path, result, emsg);
-}
-
-/******************************************************************************/
-
-int espEvalScript(EspRequest *ep, char *script, MprVar *result, char **emsg)
-{
- return ejsEvalScript(ep->eid, script, result, emsg);
-}
-
-/******************************************************************************/
-
-int espGetPropertyCount(MprVar *obj, int includeFlags)
-{
- if (obj->type != MPR_TYPE_OBJECT) {
- return MPR_ERR_BAD_STATE;
- }
- return mprGetPropertyCount(obj, includeFlags);
-}
-
-/******************************************************************************/
-
-MprVar *espGetFirstProperty(MprVar *obj, int includeFlags)
-{
- return mprGetFirstProperty(obj, includeFlags);
-}
-
-/******************************************************************************/
-
-MprVar *espGetGlobalObject(EspRequest *ep)
-{
- return ejsGetGlobalObject(ep->eid);
-}
-
-/******************************************************************************/
-
-MprVar *espGetLocalObject(EspRequest *ep)
-{
- return ejsGetLocalObject(ep->eid);
-}
-
-/******************************************************************************/
-
-MprVar *espGetNextProperty(MprVar *obj, MprVar *currentProperty,
- int includeFlags)
-{
- return mprGetNextProperty(obj, currentProperty, includeFlags);
-}
-
-/******************************************************************************/
-
-MprVar *espGetProperty(MprVar *obj, char *property, MprVar *value)
-{
- return mprGetProperty(obj, property, value);
-}
-
-/******************************************************************************/
-
-void *espGetThisPtr(EspRequest *ep)
-{
- return ejsGetThisPtr(ep->eid);
-}
-
-/******************************************************************************/
-#if XX_UNUSED_XX
-
-int espReadProperty(MprVar *dest, MprVar *prop)
-{
- mprAssert(prop);
- mprAssert(dest);
-
- *dest = *prop;
- return 0;
-}
-
-#endif
-/******************************************************************************/
-
-int espReadVar(EspRequest *ep, char *var, MprVar *value)
-{
- return ejsReadVar(ep->eid, var, value);
-}
-
-/******************************************************************************/
-
-int espRunFunction(EspRequest *ep, MprVar *obj, char *functionName,
- MprArray *args)
-{
- return ejsRunFunction(ep->eid, obj, functionName, args);
-}
-
-/******************************************************************************/
-
-MprVar *espSetProperty(MprVar *obj, char *property, MprVar *newValue)
-{
- return mprSetProperty(obj, property, newValue);
-}
-
-/******************************************************************************/
-
-MprVar *espSetPropertyValue(MprVar *obj, char *property, MprVar newValue)
-{
- return mprSetPropertyValue(obj, property, newValue);
-}
-
-/******************************************************************************/
-
-int espWriteVar(EspRequest *ep, char *var, MprVar *value)
-{
- return ejsWriteVar(ep->eid, var, value);
-}
-
-/******************************************************************************/
-
-int espWriteVarValue(EspRequest *ep, char *var, MprVar value)
-{
- return ejsWriteVarValue(ep->eid, var, value);
-}
-
-/******************************************************************************/
-#if XX_UNUSED_XX
-
-int espWriteProperty(MprVar *prop, MprVar *newValue)
-{
- return mprWriteProperty(prop, newValue);
-}
-
-/******************************************************************************/
-
-int espWritePropertyValue(MprVar *prop, MprVar newValue)
-{
- return mprWritePropertyValue(prop, newValue);
-}
-
-#endif
-/******************************************************************************/
-
-#else /* !BLD_FEATURE_ESP_MODULE */
-void espDummy() {}
-
-/******************************************************************************/
-#endif /* BLD_FEATURE_ESP_MODULE */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/esp/esp.h b/source4/lib/appweb/esp/esp.h
deleted file mode 100644
index 3d9b7bf8dc..0000000000
--- a/source4/lib/appweb/esp/esp.h
+++ /dev/null
@@ -1,277 +0,0 @@
-/**
- * @file esp.h
- * @brief Header for Embedded Server Pages (ESP)
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#ifndef _h_ESP_h
-#define _h_ESP_h 1
-
-#include "lib/appweb/ejs/ejs.h"
-#include "lib/appweb/esp/espEnv.h"
-#include "lib/appweb/mpr/var.h"
-#include "lib/appweb/mpr/miniMpr.h"
-
-/*********************************** Defines **********************************/
-
-#if BLD_FEATURE_SQUEEZE
-#define ESP_TOK_INCR 1024
-#define ESP_MAX_HEADER 1024
-#else
-#define ESP_TOK_INCR 4096
-#define ESP_MAX_HEADER 4096
-#endif
-
-/*
- * ESP lexical analyser tokens
- */
-#define ESP_TOK_ERR -1 /* Any input error */
-#define ESP_TOK_EOF 0 /* End of file */
-#define ESP_TOK_START_ESP 1 /* <% */
-#define ESP_TOK_END_ESP 2 /* %> */
-#define ESP_TOK_ATAT 3 /* @@var */
-#define ESP_TOK_LITERAL 4 /* literal HTML */
-#define ESP_TOK_INCLUDE 5 /* include file.esp */
-#define ESP_TOK_EQUALS 6 /* = var */
-
-/*
- * ESP parser states
- */
-#define ESP_STATE_BEGIN 1 /* Starting state */
-#define ESP_STATE_IN_ESP_TAG 2 /* Inside a <% %> group */
-
-/*********************************** Types ************************************/
-
-typedef void* EspHandle; /* Opaque Web server handle type */
-
-/*
- * Per request control block
- */
-typedef struct EspRequest {
- MprStr docPath; /* Physical path for ESP page */
- EjsId eid; /* EJS instance handle */
- const struct Esp *esp; /* Pointer to ESP control block */
- EspHandle requestHandle; /* Per request web server handle */
- MprStr uri; /* Request URI */
- MprVar *variables; /* Pointer to variables */
-} EspRequest;
-
-/*
- * Master ESP control block. This defines the function callbacks for a
- * web server handler to implement. ESP will call these functions as
- * required.
- */
-typedef struct Esp {
- int maxScriptSize;
- void (*createSession)(EspHandle handle, int timeout);
- void (*destroySession)(EspHandle handle);
- const char *(*getSessionId)(EspHandle handle);
- int (*mapToStorage)(EspHandle handle, char *path, int len, const char *uri,
- int flags);
- int (*readFile)(EspHandle handle, char **buf, int *len, const char *path);
- void (*redirect)(EspHandle handle, int code, char *url);
- void (*setCookie)(EspHandle handle, const char *name, const char *value,
- int lifetime, const char *path, bool secure);
- void (*setHeader)(EspHandle handle, const char *value, bool allowMultiple);
- void (*setResponseCode)(EspHandle handle, int code);
- int (*writeBlock)(EspHandle handle, const char *buf, int size);
- int (*writeFmt)(EspHandle handle, char *fmt, ...);
-#if BLD_FEATURE_MULTITHREAD
- void (*lock)(void *lockData);
- void (*unlock)(void *lockData);
- void *lockData;
-#endif
-} Esp;
-
-
-/*
- * ESP parse context
- */
-typedef struct {
- char *inBuf; /* Input data to parse */
- char *inp; /* Next character for input */
- char *endp; /* End of storage (allow for null) */
- char *tokp; /* Pointer to current parsed token */
- char *token; /* Storage buffer for token */
- int tokLen; /* Length of buffer */
-} EspParse;
-
-
-/******************************** Private APIs ********************************/
-
-extern void espRegisterProcs(void);
-
-/******************************** Published API *******************************/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Function callback signatures
- */
-typedef int (*EspCFunction)(EspRequest *ep, int argc,
- struct MprVar **argv);
-typedef int (*EspStringCFunction)(EspRequest *ep, int argc,
- char **argv);
-
-/*
- * APIs for those hosting the ESP module
- */
-extern int espOpen(const Esp *control);
-extern void espClose(void);
-extern EspRequest *espCreateRequest(EspHandle webServerRequestHandle,
- char *uri, MprVar *envObj);
-extern void espDestroyRequest(EspRequest *ep);
-extern int espProcessRequest(EspRequest *ep, const char *docPath,
- char *docBuf, char **errMsg);
-
-/*
- * Method invocation
- */
-extern void espDefineCFunction(EspRequest *ep, const char *functionName,
- EspCFunction fn, void *thisPtr);
-extern void espDefineFunction(EspRequest *ep, const char *functionName,
- char *args, char *body);
-extern void espDefineStringCFunction(EspRequest *ep,
- const char *functionName, EspStringCFunction fn,
- void *thisPtr);
-extern int espRunFunction(EspRequest *ep, MprVar *obj,
- char *functionName, MprArray *args);
-extern void espSetResponseCode(EspRequest *ep, int code);
-extern void espSetReturn(EspRequest *ep, MprVar value);
-extern void *espGetThisPtr(EspRequest *ep);
-
-/*
- * Utility routines to use in C methods
- */
-extern void espError(EspRequest *ep, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
-extern int espEvalFile(EspRequest *ep, char *path, MprVar *result,
- char **emsg);
-extern int espEvalScript(EspRequest *ep, char *script, MprVar *result,
- char **emsg);
-extern MprVar *espGetLocalObject(EspRequest *ep);
-extern MprVar *espGetGlobalObject(EspRequest *ep);
-extern EspHandle espGetRequestHandle(EspRequest *ep);
-extern MprVar *espGetResult(EspRequest *ep);
-extern EjsId espGetScriptHandle(EspRequest *ep);
-extern void espRedirect(EspRequest *ep, int code, char *url);
-extern void espSetHeader(EspRequest *ep, char *header,
- bool allowMultiple);
-extern void espSetReturnString(EspRequest *ep, const char *str);
-extern int espWrite(EspRequest *ep, char *buf, int size);
-extern int espWriteString(EspRequest *ep, char *buf);
-extern int espWriteFmt(EspRequest *ep, char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
-
-/*
- * ESP array[] variable access (set will update/create)
- */
-extern int espGetVar(EspRequest *ep, EspEnvType oType, char *var,
- MprVar *value);
-extern char *espGetStringVar(EspRequest *ep, EspEnvType oType,
- char *var, char *defaultValue);
-extern void espSetVar(EspRequest *ep, EspEnvType oType, char *var,
- MprVar value);
-extern void espSetStringVar(EspRequest *ep, EspEnvType oType,
- const char *var, const char *value);
-extern int espUnsetVar(EspRequest *ep, EspEnvType oType, char *var);
-
-/*
- * Object creation and management
- */
-extern MprVar espCreateObjVar(char *name, int hashSize);
-extern MprVar espCreateArrayVar(char *name, int size);
-extern bool espDestroyVar(MprVar *var);
-extern MprVar *espCreateProperty(MprVar *obj, char *property,
- MprVar *newValue);
-extern MprVar *espCreatePropertyValue(MprVar *obj, char *property,
- MprVar newValue);
-extern int espDeleteProperty(MprVar *obj, char *property);
-
-/*
- * JavaScript variable management. Set will create/update a property.
- * All return a property reference. GetProperty will optionally return the
- * property in value.
- */
-extern MprVar *espGetProperty(MprVar *obj, char *property,
- MprVar *value);
-extern MprVar *espSetProperty(MprVar *obj, char *property,
- MprVar *newValue);
-extern MprVar *espSetPropertyValue(MprVar *obj, char *property,
- MprVar newValue);
-
-#if 0
-/*
- * Low-level direct read and write of properties.
- * FUTURE: -- Read is not (dest, src). MUST WARN IN DOC ABOUT COPY/READ
- * Will still cause triggers to run.
- */
-extern int espReadProperty(MprVar *dest, MprVar *prop);
-extern int espWriteProperty(MprVar *prop, MprVar *newValue);
-extern int espWritePropertyValue(MprVar *prop, MprVar newValue);
-#endif
-
-
-/*
- * Access JavaScript variables by their full name. Can use "." or "[]". For
- * example: "global.request['REQUEST_URI']"
- * For Read/write, the variables must exist.
- */
-extern int espCopyVar(EspRequest *ep, char *var, MprVar *value,
- int copyDepth);
-extern int espDeleteVar(EspRequest *ep, char *var);
-extern int espReadVar(EspRequest *ep, char *var, MprVar *value);
-extern int espWriteVar(EspRequest *ep, char *var, MprVar *value);
-extern int espWriteVarValue(EspRequest *ep, char *var, MprVar value);
-
-/*
- * Object property enumeration
- */
-extern MprVar *espGetFirstProperty(MprVar *obj, int includeFlags);
-extern MprVar *espGetNextProperty(MprVar *obj, MprVar *currentProperty,
- int includeFlags);
-extern int espGetPropertyCount(MprVar *obj, int includeFlags);
-
-#ifdef __cplusplus
-}
-#endif
-/******************************************************************************/
-#endif /* _h_ESP_h */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/esp/espEnv.h b/source4/lib/appweb/esp/espEnv.h
deleted file mode 100644
index a3c9d9f5c7..0000000000
--- a/source4/lib/appweb/esp/espEnv.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * @file espEnv.h
- * @brief ESP Environment Variables
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/******************************************************************************/
-
-#ifndef _h_ESP_ENV_h
-#define _h_ESP_ENV_h 1
-
-/*
- * @brief Scripting environment variable array types
- */
-typedef enum EspEnvType {
- ESP_UNDEFINED_OBJ = -1,
-
- /**
- * Elements for server[]:
- * DOCUMENT_ROOT GATEWAY_INTERFACE SERVER_ADDR SERVER_PORT SERVER_NAME
- * SERVER_PROTOCOL SERVER_SOFTWARE SERVER_URL UPLOAD_DIR
- * FUTURE: SERVER_ADMIN
- * FUTURE: this could be shared across all hosts and be made read-only.
- */
- ESP_SERVER_OBJ = 0, /*! server[] data */
-
- /**
- * Elements for session[]: are user defined
- */
- ESP_SESSION_OBJ = 1, /*! session[] data */
-
- /**
- * Elements for request[]:
- * AUTH_TYPE CONTENT_LENGTH CONTENT_TYPE QUERY_STRING PATH_INFO
- * PATH_TRANSLATED REMOTE_ADDR REMOTE_HOST REMOTE_USER REQUEST_METHOD
- * REQUEST_URI SCRIPT_FILENAME SCRIPT_NAME
- * FUTURE: FILEPATH_INFO REDIRECT_URL SELF REMOTE_PORT AUTH_USER
- * AUTH_GROUP AUTH_ACL
- */
- ESP_REQUEST_OBJ = 2, /*! request[] data */
-
- /**
- * Elements for headers[]:
- * HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_CONNECTION HTTP_HOST
- * HTTP_REFERER HTTP_USER_AGENT and any other custom headers
- */
- ESP_HEADERS_OBJ = 3, /*! header [] data */
-
- /**
- * Elements for cookies[]: are defined by the HTTP request
- */
- ESP_COOKIES_OBJ = 4, /*! cookies[] data */
-
- /**
- * Elements for files[]: are defined by the HTTP request
- * CLIENT_FILENAME CONTENT_TYPE FILENAME SIZE
- */
- ESP_FILES_OBJ = 5, /*! files[] data */
-
- /**
- * Elements for form[]: are defined by the HTTP request
- */
- ESP_FORM_OBJ = 6, /*! form[] data */
-
- /**
- * Elements for application[]: are user defined
- */
- ESP_APPLICATION_OBJ = 7, /*! application[] data */
-
- /**
- * Elements for global[]: are defined by ESP/EJS
- */
- ESP_GLOBAL_OBJ = 8, /*! global [] data */
-
- /*
- * Elements for local[]: are defined by ESP/EJS
- */
- ESP_LOCAL_OBJ = 9, /*! local [] data */
-} EspEnvType;
-
-#define ESP_OBJ_MAX 10 /* Total objects */
-
-#if BLD_SQUEEZE
-#define ESP_HASH_SIZE 19 /* Size of hash tables */
-#else
-#define ESP_HASH_SIZE 37
-#endif
-
-/******************************************************************************/
-#endif /* _h_ESP_ENV_h */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/esp/espProcs.c b/source4/lib/appweb/esp/espProcs.c
deleted file mode 100644
index 7b5dfe680e..0000000000
--- a/source4/lib/appweb/esp/espProcs.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * @file espProcs.c
- * @brief Embedded Server Pages (ESP) Procedures.
- * @overview These ESP procedures can be used in ESP pages for common tasks.
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "esp.h"
-
-/************************************ Code ************************************/
-#if BLD_FEATURE_ESP_MODULE
-#if BLD_FEATURE_SESSION
-/*
- * destroySession
- */
-
-static int destroySessionProc(EspRequest *ep, int argc, char **argv)
-{
- ep->esp->destroySession(ep->requestHandle);
- return 0;
-}
-
-#endif /* BLD_FEATURE_SESSION */
-
-/******************************************************************************/
-/*
- * include
- *
- * This includes javascript libraries. For example:
- *
- * <% include("file", ...); %>
- *
- * Don't confuse with ESP includes:
- *
- * <% include file.esp %>
- *
- * Filenames are relative to the base document including the file.
- * FUTURE -- move back to EJS. Only here now because we need ep->readFile.
- */
-
-static int includeProc(EspRequest *ep, int argc, char **argv)
-{
- const Esp *esp;
- char path[MPR_MAX_FNAME], dir[MPR_MAX_FNAME];
- char *emsg=NULL, *buf;
- int size, i;
-
- esp = ep->esp;
- mprAssert(argv);
- for (i = 0; i < argc; i++) {
- const char *extension;
-
- if (argv[i][0] != '/') {
- mprGetDirName(dir, sizeof(dir), ep->docPath);
- mprSprintf(path, sizeof(path), "%s/%s", dir, argv[i]);
- } else {
- mprSprintf(path, sizeof(path), "%s", argv[i]);
- }
-
- if (esp->readFile(ep->requestHandle, &buf, &size, path) < 0) {
- espError(ep, "Can't read include file: %s", path);
- return MPR_ERR_CANT_ACCESS;
- }
- buf[size] = '\0';
-
- extension = strrchr(argv[i], '.');
-
- /*
- * Allow nested inclusion of ESP requests
- */
- if (extension && mprStrCmpAnyCase(extension, ".esp") == 0) {
- if (espProcessRequest(ep, path, buf, &emsg) != 0) {
- espError(ep, "Cant evaluate script - %s", emsg?emsg:"");
- mprFree(buf);
- return -1;
- }
- } else {
- if (ejsEvalScript(espGetScriptHandle(ep), buf, 0, &emsg) < 0) {
- espError(ep, "Cant evaluate script - %s", emsg?emsg:"");
- mprFree(buf);
- return -1;
- }
- }
- mprFree(buf);
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * redirect
- *
- * This implemements <% redirect(url, code); %> command. The redirection
- * code is optional.
- */
-
-static int redirectProc(EspRequest *ep, int argc, char **argv)
-{
- char *url;
- int code;
-
- if (argc < 1) {
- espError(ep, "Bad args");
- return MPR_ERR_BAD_ARGS;
- }
- url = argv[0];
- if (argc == 2) {
- code = atoi(argv[1]);
- } else {
- code = 302;
- }
- espRedirect(ep, code, url);
- return 0;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_SESSION
-/*
- * useSession
- */
-
-static int useSessionProc(EspRequest *ep, int argc, char **argv)
-{
- int timeout;
-
- if (argc > 1) {
- espError(ep, "Bad args");
- return MPR_ERR_BAD_ARGS;
-
- } else if (argc == 1) {
- timeout = atoi(argv[0]);
- } else {
- timeout = 0;
- }
-
- ep->esp->createSession(ep->requestHandle, timeout);
- espSetReturnString(ep, ep->esp->getSessionId(ep->requestHandle));
- return 0;
-}
-
-#endif /* BLD_FEATURE_SESSION */
-/******************************************************************************/
-/*
- * setHeader
- *
- * This implemements <% setHeader("key: value", allowMultiple); %> command.
- */
-
-static int setHeaderProc(EspRequest *ep, int argc, char **argv)
-{
- mprAssert(argv);
- if (argc != 2) {
- espError(ep, "Bad args");
- return MPR_ERR_BAD_ARGS;
- }
- ep->esp->setHeader(ep->requestHandle, argv[0], atoi(argv[1]));
- return 0;
-}
-
-/******************************************************************************/
-/*
- * write
- *
- * This implemements <% write("text"); %> command.
- */
-
-static int writeProc(EspRequest *ep, int argc, char **argv)
-{
- char *s;
- int i, len;
-
- mprAssert(argv);
- for (i = 0; i < argc; i++) {
- s = argv[i];
- len = strlen(s);
- if (len > 0) {
- if (espWrite(ep, s, len) != len) {
- espError(ep, "Can't write to client");
- return -1;
- }
- }
- }
- return 0;
-}
-
-/******************************************************************************/
-
-void espRegisterProcs()
-{
- espDefineStringCFunction(0, "write", writeProc, 0);
- espDefineStringCFunction(0, "setHeader", setHeaderProc, 0);
- espDefineStringCFunction(0, "redirect", redirectProc, 0);
- espDefineStringCFunction(0, "include", includeProc, 0);
-
-#if BLD_FEATURE_SESSION
- /*
- * Create and use are synonomous
- */
- espDefineStringCFunction(0, "useSession", useSessionProc, 0);
- espDefineStringCFunction(0, "createSession", useSessionProc, 0);
- espDefineStringCFunction(0, "destroySession", destroySessionProc, 0);
-#endif
-}
-
-/******************************************************************************/
-
-#else
-void mprEspControlsDummy() {}
-
-#endif /* BLD_FEATURE_ESP_MODULE */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/mpr/miniMpr.c b/source4/lib/appweb/mpr/miniMpr.c
deleted file mode 100644
index 381815eb23..0000000000
--- a/source4/lib/appweb/mpr/miniMpr.c
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- * @file miniMpr.cpp
- * @brief Mini Mbedthis Portable Runtime (MPR)
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-#include "miniMpr.h"
-#include "param/param.h"
-#include "lib/events/events.h"
-
-/************************************ Code ************************************/
-#if !BLD_APPWEB
-#if !BLD_GOAHEAD_WEBSERVER
-
-static void *mpr_ctx;
-
-/* set the memory context to be used for all ejs variables */
-void mprSetCtx(TALLOC_CTX *ctx)
-{
- mpr_ctx = ctx;
-}
-
-/* return the memory context being used for all ejs variables */
-void *mprMemCtx(void)
-{
- return mpr_ctx;
-}
-
-struct event_context *mprEventCtx(void)
-{
- return event_context_find(mprMemCtx());
-}
-
-/* return the loadparm context being used for all ejs variables */
-struct loadparm_context *mprLpCtx(void)
-{
- return global_loadparm;
-}
-
-void mprFree(void *ptr)
-{
- talloc_free(ptr);
-}
-
-void *mprMalloc(uint size)
-{
- return talloc_size(mpr_ctx, size);
-}
-
-/******************************************************************************/
-
-void *mprRealloc(void *ptr, uint size)
-{
- return talloc_realloc_size(mpr_ctx, ptr, size);
-}
-
-/******************************************************************************/
-
-char *mprStrdup(const char *str)
-{
- if (str == 0) {
- str = "";
- }
- return talloc_strdup(mpr_ctx, str);
-}
-
-/*****************************************************************************/
-
-int mprAllocSprintf(char **msgbuf, int maxSize, const char *fmt, ...)
-{
- va_list args;
- char *buf;
- int count;
-
- va_start(args, fmt);
- buf = mprMalloc(maxSize + 1);
- count = mtVsprintf(buf, maxSize, fmt, args);
- *msgbuf = buf;
- va_end(args);
- return count;
-}
-
-/*****************************************************************************/
-
-int mprAllocVsprintf(char **msgbuf, int maxSize, const char *fmt, va_list args)
-{
- char *buf;
- int count;
-
- buf = mprMalloc(maxSize + 1);
- count = mtVsprintf(buf, maxSize, fmt, args);
- *msgbuf = buf;
- return count;
-}
-
-
-/*****************************************************************************/
-/*
- * Format a number as a string. FUTURE -- reverse args to be standard.
- * ie. mprItoa(char *userBuf, int bufsize, int value);
- */
-
-char *mprItoa(int value, char *buf, int width)
-{
- char numBuf[16];
- char *cp, *dp, *endp;
- int negative;
-
- cp = &numBuf[sizeof(numBuf)];
- *--cp = '\0';
-
- if (value < 0) {
- negative = 1;
- value = -value;
- width--;
- } else {
- negative = 0;
- }
-
- do {
- *--cp = '0' + (value % 10);
- value /= 10;
- } while (value > 0);
-
- if (negative) {
- *--cp = '-';
- }
-
- dp = buf;
- endp = &buf[width];
- while (dp < endp && *cp) {
- *dp++ = *cp++;
- }
- *dp++ = '\0';
- return buf;
-}
-
-/*****************************************************************************/
-
-void mprLog(int level, const char *fmt, ...)
-{
- va_list args;
- char *buf;
-
- if (DEBUGLVL(level)) {
- va_start(args, fmt);
- mprAllocVsprintf(&buf, MPR_MAX_STRING, fmt, args);
- va_end(args);
- DEBUG(level, ("mprLog: %s", buf));
- mprFree(buf);
- }
-}
-
-/*****************************************************************************/
-
-void mprBreakpoint(const char *file, int line, const char *cond)
-{
- char *buf;
- mprAllocSprintf(&buf, MPR_MAX_STRING, "esp exception - ASSERT at %s:%d, %s\n",
- file, line, cond);
- ejs_exception(buf);
-}
-
-#endif /* !BLD_GOAHEAD_WEBSERVER */
-/*****************************************************************************/
-/*
- * Create a general growable array structure
- */
-
-MprArray *mprCreateArray()
-{
- MprArray *array;
- int size;
-
- array = (MprArray*) mprMalloc(sizeof(MprArray));
- if (array == 0) {
- return 0;
- }
- memset(array, 0, sizeof(MprArray));
-
- size = MPR_ARRAY_INCR * sizeof(void*);
- array->handles = (void**) mprMalloc(size);
- if (array->handles == 0) {
- mprFree(array);
- return 0;
- }
- memset(array->handles, 0, size);
- array->max = MPR_ARRAY_INCR;
- array->used = 0;
- return array;
-}
-
-/*****************************************************************************/
-/*
- * Dispose of the array. Callers responsibility to dispose of handle entries.
- */
-
-void mprDestroyArray(MprArray *array)
-{
- mprAssert(array);
- mprAssert(array->max >= 0);
- mprAssert(array->used >= 0);
-
- mprFree(array->handles);
- mprFree(array);
-}
-
-/*****************************************************************************/
-/*
- * Add an item to the array
- */
-
-int mprAddToArray(MprArray *array, void *item)
-{
- int memsize, idx, len;
-
- mprAssert(array);
- mprAssert(array->max >= 0);
- mprAssert(array->used >= 0);
-
- if (array->used < array->max) {
- idx = array->used++;
- mprAssert(idx >= 0 && idx < array->max);
- mprAssert(array->handles[idx] == 0);
- array->handles[idx] = item;
- return idx;
- }
-
- for (idx = array->used; idx < array->max; idx++) {
- if (array->handles[idx] == 0) {
- array->used++;
- mprAssert(array->handles[idx] == 0);
- array->handles[idx] = item;
- return idx;
- }
- }
-
- len = array->max + MPR_ARRAY_INCR;
- memsize = len * sizeof(void*);
- array->handles = (void**) mprRealloc((void*) array->handles, memsize);
- if (array->handles == NULL) {
- return -1;
- }
- memset(&array->handles[array->max], 0, sizeof(void*) * MPR_ARRAY_INCR);
- array->max = len;
- array->used++;
-
- mprAssert(idx >= 0 && idx < array->max);
- mprAssert(array->handles[idx] == 0);
-
- array->handles[idx] = item;
- return idx;
-}
-
-/*****************************************************************************/
-/*
- * Remove from the array
- */
-
-int mprRemoveFromArray(MprArray *array, int idx)
-{
- mprAssert(array);
- mprAssert(array->max > 0);
- mprAssert(idx >= 0 && idx < array->max);
- mprAssert(array->handles[idx] != 0);
- mprAssert(array->used > 0);
-
- array->handles[idx] = 0;
- return --array->used;
-}
-
-/*****************************************************************************/
-/*
- * Thread-safe wrapping of strtok. Note "str" is modifed as per strtok()
- */
-
-char *mprStrTok(char *str, const char *delim, char **tok)
-{
- char *start, *end;
- int i;
-
- start = str ? str : *tok;
-
- if (start == 0) {
- return 0;
- }
-
- i = strspn(start, delim);
- start += i;
- if (*start == '\0') {
- *tok = 0;
- return 0;
- }
- end = strpbrk(start, delim);
- if (end) {
- *end++ = '\0';
- i = strspn(end, delim);
- end += i;
- }
- *tok = end;
- return start;
-}
-
-/*****************************************************************************/
-
-static int mprCoreStrcat(int alloc, char **destp, int destMax, int existingLen,
- const char *delim, const char *src, va_list args)
-{
- va_list ap;
- char *dest, *dp;
- const char *str;
- int sepLen, addBytes, required;
-
- mprAssert(destp);
- mprAssert(destMax > 0);
- mprAssert(src);
-
- dest = *destp;
- sepLen = (delim) ? strlen(delim) : 0;
-
- va_copy(ap, args);
- addBytes = 0;
- str = src;
- while (str) {
- addBytes += strlen(str) + sepLen;
- str = va_arg(ap, const char*);
- }
- va_end(ap);
-
- if (existingLen > 0) {
- addBytes += sepLen;
- }
- required = existingLen + addBytes + 1;
- if (required >= destMax) {
- mprAssert(0);
- return MPR_ERR_WONT_FIT;
- }
-
- if (alloc) {
- if (dest == 0) {
- dest = (char*) mprMalloc(required);
- } else {
- dest = (char*) mprRealloc(dest, required);
- }
- } else {
- dest = (char*) *destp;
- }
-
- dp = &dest[existingLen];
- if (delim) {
- strcpy(dp, delim);
- dp += sepLen;
- }
-
- if (addBytes > 0) {
- va_copy(ap, args);
- str = src;
- while (str) {
- strcpy(dp, str);
- dp += strlen(str);
- str = va_arg(ap, char*);
- if (delim && str) {
- strcpy(dp, delim);
- dp += sepLen;
- }
- }
- va_end(ap);
- } else if (dest == 0) {
- dest = (char*) mprMalloc(1);
- }
- *dp = '\0';
-
- *destp = dest;
- mprAssert(dp < &dest[required]);
- return required - 1;
-}
-
-/*****************************************************************************
- Note that this VARARGS function must be NULL (not 0, this must be a
- pointer) terminated
-*/
-
-int mprReallocStrcat(char **destp, int destMax, int existingLen,
- const char *delim, const char *src,...)
-{
- va_list ap;
- int rc;
-
- va_start(ap, src);
- rc = mprCoreStrcat(1, destp, destMax, existingLen, delim, src, ap);
- va_end(ap);
- return rc;
-}
-
-/*****************************************************************************/
-/*
- * Return the directory portion of a pathname into the users buffer.
- */
-
-int mprGetDirName(char *buf, int bufsize, char *path)
-{
- char *cp;
- int dlen;
-
- mprAssert(path);
- mprAssert(buf);
- mprAssert(bufsize > 0);
-
- cp = strrchr(path, '/');
- if (cp == 0) {
-#if WIN
- cp = strrchr(path, '\\');
- if (cp == 0)
-#endif
- {
- buf[0] = '\0';
- return 0;
- }
- }
-
- if (cp == path && cp[1] == '\0') {
- strcpy(buf, ".");
- return 0;
- }
-
- dlen = cp - path;
- if (dlen < bufsize) {
- if (dlen == 0) {
- dlen++;
- }
- mprMemcpy(buf, bufsize, path, dlen);
- buf[dlen] = '\0';
- return 0;
- }
- return MPR_ERR_WONT_FIT;
-}
-
-/*****************************************************************************/
-
-int mprStrcpy(char *dest, int destMax, const char *src)
-{
- int len;
-
- mprAssert(dest);
- mprAssert(destMax > 0);
- mprAssert(src);
-
- len = strlen(src);
- if (len >= destMax && len > 0) {
- mprAssert(0);
- return MPR_ERR_WONT_FIT;
- }
- if (len > 0) {
- memcpy(dest, src, len);
- dest[len] = '\0';
- } else {
- *dest = '\0';
- len = 0;
- }
- return len;
-}
-
-/*****************************************************************************/
-
-int mprMemcpy(char *dest, int destMax, const char *src, int nbytes)
-{
- mprAssert(dest);
- mprAssert(destMax > nbytes);
- mprAssert(src);
- mprAssert(nbytes > 0);
-
- if (nbytes > destMax) {
- mprAssert(0);
- return MPR_ERR_WONT_FIT;
- }
- if (nbytes > 0) {
- memcpy(dest, src, nbytes);
- return nbytes;
- } else {
- return 0;
- }
-}
-
-/*****************************************************************************/
-#else
-void miniMprDummy() {}
-#endif // !BLD_APPWEB && !BLD_GOAHEAD_WEBSERVER
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/mpr/miniMpr.h b/source4/lib/appweb/mpr/miniMpr.h
deleted file mode 100644
index 2b8ff0af6a..0000000000
--- a/source4/lib/appweb/mpr/miniMpr.h
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * @file miniMpr.h
- * @brief Mini Mbedthis Portable Runtime (MPR) Environment.
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-#ifndef _h_MINI_MPR
-#define _h_MINI_MPR 1
-
-/********************************** Includes **********************************/
-/*
- * Find out about our configuration
- */
-#ifndef _INCLUDES_H
- #include "includes.h"
-#endif
-
-/* allow this library to use strcpy() */
-#undef strcpy
- #include "lib/appweb/ejs/config.h"
-
-#if BLD_APPWEB
- /*
- * If building within AppWeb, use the full MPR
- */
- #include "mpr.h"
-#else
-
- #include <ctype.h>
- #include <fcntl.h>
- #include <stdarg.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <sys/stat.h>
-
-#if !WIN
- #include <unistd.h>
-#endif
-
-#if CE
- #include <io.h>
- #include "CE/wincompat.h"
-#endif
-
-#if LYNX
- #include <unistd.h>
-#endif
-
-#if QNX4
- #include <dirent.h>
-#endif
-#ifdef HAVE_MATH_H
- #include <math.h>
-#endif
-/********************************** Defines ***********************************/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if BLD_FEATURE_SQUEEZE
-/*
- * Reasonable length of a file path name to use in most cases where you know
- * the expected file name and it is certain to be less than this limit.
- */
-#define MPR_MAX_FNAME 128
-#define MPR_MAX_STRING 512
-#define MPR_DEFAULT_HASH_SIZE 23 /* Default size of hash table index */
-#define MPR_MAX_HEAP_SIZE (32 * 1024)
-#else
-#define MPR_MAX_FNAME 256
-#define MPR_MAX_STRING 4096
-#define MPR_DEFAULT_HASH_SIZE 43 /* Default size of hash table index */
-#define MPR_MAX_HEAP_SIZE (64 * 1024)
-#endif
-
-/*
- * Useful for debugging
- */
-#define MPR_L __FILE__, __LINE__
-
-#if BLD_FEATURE_ASSERT
-#define mprAssert(C) \
- if (C) ; else mprBreakpoint(__FILE__, __LINE__, #C)
-#else
- #define mprAssert(C) if (1) ; else
-#endif
-
-/*
- * Standard MPR return and error codes
- */
-#define MPR_ERR_BASE (-200) /* Error code */
-#define MPR_ERR_GENERAL (MPR_ERR_BASE - 1) /* Error code */
-#define MPR_ERR_ABORTED (MPR_ERR_BASE - 2) /* Error code */
-#define MPR_ERR_ALREADY_EXISTS (MPR_ERR_BASE - 3) /* Error code */
-#define MPR_ERR_BAD_ARGS (MPR_ERR_BASE - 4) /* Error code */
-#define MPR_ERR_BAD_FORMAT (MPR_ERR_BASE - 5) /* Error code */
-#define MPR_ERR_BAD_HANDLE (MPR_ERR_BASE - 6) /* Error code */
-#define MPR_ERR_BAD_STATE (MPR_ERR_BASE - 7) /* Error code */
-#define MPR_ERR_BAD_SYNTAX (MPR_ERR_BASE - 8) /* Error code */
-#define MPR_ERR_BAD_TYPE (MPR_ERR_BASE - 9) /* Error code */
-#define MPR_ERR_BAD_VALUE (MPR_ERR_BASE - 10) /* Error code */
-#define MPR_ERR_BUSY (MPR_ERR_BASE - 11) /* Error code */
-#define MPR_ERR_CANT_ACCESS (MPR_ERR_BASE - 12) /* Error code */
-#define MPR_ERR_CANT_COMPLETE (MPR_ERR_BASE - 13) /* Error code */
-#define MPR_ERR_CANT_CREATE (MPR_ERR_BASE - 14) /* Error code */
-#define MPR_ERR_CANT_INITIALIZE (MPR_ERR_BASE - 15) /* Error code */
-#define MPR_ERR_CANT_OPEN (MPR_ERR_BASE - 16) /* Error code */
-#define MPR_ERR_CANT_READ (MPR_ERR_BASE - 17) /* Error code */
-#define MPR_ERR_CANT_WRITE (MPR_ERR_BASE - 18) /* Error code */
-#define MPR_ERR_DELETED (MPR_ERR_BASE - 19) /* Error code */
-#define MPR_ERR_NETWORK (MPR_ERR_BASE - 20) /* Error code */
-#define MPR_ERR_NOT_FOUND (MPR_ERR_BASE - 21) /* Error code */
-#define MPR_ERR_NOT_INITIALIZED (MPR_ERR_BASE - 22) /* Error code */
-#define MPR_ERR_NOT_READY (MPR_ERR_BASE - 23) /* Error code */
-#define MPR_ERR_READ_ONLY (MPR_ERR_BASE - 24) /* Error code */
-#define MPR_ERR_TIMEOUT (MPR_ERR_BASE - 25) /* Error code */
-#define MPR_ERR_TOO_MANY (MPR_ERR_BASE - 26) /* Error code */
-#define MPR_ERR_WONT_FIT (MPR_ERR_BASE - 27) /* Error code */
-#define MPR_ERR_WOULD_BLOCK (MPR_ERR_BASE - 28) /* Error code */
-#define MPR_ERR_CANT_ALLOCATE (MPR_ERR_BASE - 29) /* Error code */
-#define MPR_ERR_MAX (MPR_ERR_BASE - 30) /* Error code */
-
-/*
- * Standard error severity and trace levels. These are ored with the error
- * severities below. The MPR_LOG_MASK is used to extract the trace level
- * from a flags word. We expect most apps to run with level 2 trace.
- */
-#define MPR_FATAL 0 /* Fatal error. Cant continue. */
-#define MPR_ERROR 1 /* Hard error */
-#define MPR_WARN 2 /* Soft warning */
-#define MPR_CONFIG 2 /* Essential configuration settings */
-#define MPR_INFO 3 /* Informational only */
-#define MPR_DEBUG 4 /* Debug information */
-#define MPR_VERBOSE 9 /* Highest level of trace */
-#define MPR_LOG_MASK 0xf /* Level mask */
-
-/*
- * Error flags. Specify where the error should be sent to. Note that the
- * product.xml setting "headless" will modify how errors are reported.
- * Assert errors are trapped when in DEV mode. Otherwise ignored.
- */
-#define MPR_TRAP 0x10 /* Assert error -- trap in debugger */
-#define MPR_LOG 0x20 /* Log the error in the O/S event log */
-#define MPR_USER 0x40 /* Display to the user */
-#define MPR_ALERT 0x80 /* Send a management alert */
-#define MPR_TRACE 0x100 /* Trace */
-
-/*
- * Error format flags
- */
-#define MPR_RAW 0x200 /* Raw trace output */
-
-/*
- * Error line number information
- */
-#define MPR_L __FILE__, __LINE__
-
-typedef char* MprStr;
-
-#ifndef __cplusplus
-typedef unsigned char uchar;
-#endif
-
-/*
- * Porters: put other operating system type defines here
- */
-#if WIN
- typedef unsigned int uint;
- typedef __int64 int64;
- typedef unsigned __int64 uint64;
-#else
-#define O_BINARY 0
-#ifndef uint
- #define uint unsigned
-#endif
- #define int64 int64_t
- #define uint64 uint64_t
-#endif
-
-/*
- * Flexible array data type
- */
-typedef struct {
- int max; /* Size of the handles array */
- int used; /* Count of used entries in handles */
- void **handles;
-} MprArray;
-
-#if BLD_FEATURE_SQUEEZE
-#define MPR_ARRAY_INCR 8
-#else
-#define MPR_ARRAY_INCR 16
-#endif
-
-#ifndef max
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
-/********************************* Prototypes *********************************/
-/*
- * If running in the GoAhead WebServer, map some MPR routines to WebServer
- * equivalents.
- */
-
-#if BLD_GOAHEAD_WEBSERVER
-#include "uemf.h"
-#define mprMalloc(size) balloc(B_L, size)
-#define mprFree(ptr) bfreeSafe(B_L, ptr)
-#define mprRealloc(ptr, size) brealloc(B_L, ptr, size)
-#define mprStrdup(ptr) bstrdup(B_L, ptr)
-#define mprAllocSprintf fmtAlloc
-#define mprAllocVsprintf fmtValloc
-#define mprSprintf fmtStatic
-#define mprItoa stritoa
-#define mprLog trace
-#define mprBreakpoint(file, line, cond) \
- error(file, line, E_BLD_FEATURE_ASSERT, T("%s"), cond)
-
-#else /* !BLD_GOAHEAD_WEBSERVER */
-/* #define mprMalloc malloc */
-#define mprSprintf snprintf
-#define mtVsprintf vsnprintf
-extern void *mprMalloc(uint size);
-extern void *mprRealloc(void *ptr, uint size);
-extern void mprFree(void *ptr);
-extern char *mprStrdup(const char *str);
-extern int mprAllocVsprintf(char **msgbuf, int maxSize, const char *fmt,
- va_list args) PRINTF_ATTRIBUTE(3,0);
-extern int mprAllocSprintf(char **msgbuf, int maxSize, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
-extern char *mprItoa(int num, char *buf, int width);
-extern void mprLog(int level, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
-extern void mprBreakpoint(const char *file, int line, const char *msg) _NORETURN_;
-#endif /* BLD_GOAHEAD_WEBSERVER */
-
-extern MprArray *mprCreateArray(void);
-extern void mprDestroyArray(MprArray *array);
-extern int mprAddToArray(MprArray *array, void *item);
-extern int mprRemoveFromArray(MprArray *array, int idx);
-extern char *mprStrTok(char *str, const char *delim, char **tok);
-
-extern int mprGetDirName(char *buf, int bufsize, char *path);
-extern int mprReallocStrcat(char **dest, int max, int existingLen,
- const char *delim, const char *src, ...);
-extern int mprStrcpy(char *dest, int destMax, const char *src);
-extern int mprMemcpy(char *dest, int destMax, const char *src, int nbytes);
-
-extern void mprSetCtx(void *ctx);
-extern void *mprMemCtx(void);
-struct loadparm_context;
-extern struct loadparm_context *mprLpCtx(void);
-struct event_context;
-extern struct event_context *mprEventCtx(void);
-
-/* This function needs to be provided by anyone using ejs */
-void ejs_exception(const char *reason);
-
-#define mprStrCmpAnyCase(s1, s2) strcasecmp_m(s1, s2)
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* !BLD_APPWEB */
-#endif /* _h_MINI_MPR */
-
-/*****************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/mpr/var.c b/source4/lib/appweb/mpr/var.c
deleted file mode 100644
index e73da773ea..0000000000
--- a/source4/lib/appweb/mpr/var.c
+++ /dev/null
@@ -1,2215 +0,0 @@
-/*
- * @file var.c
- * @brief MPR Universal Variable Type
- * @overview
- *
- * @copy default.m
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved.
- * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/******************************* Documentation ********************************/
-
-/*
- * This module is NOT multithreaded.
- *
- * Properties are variables that are stored in an object type variable.
- * Properties can be primitive data types, other objects or functions.
- * Properties are indexed by a character name.
- */
-
-/********************************** Includes **********************************/
-
-#include "var.h"
-
-/*********************************** Locals ***********************************/
-#if VAR_DEBUG
-
-static MprProperties objectList; /* Dummy head of objects list */
-static int objectCount = -1; /* Count of objects */
-
-#endif
-/***************************** Forward Declarations ***************************/
-
-static int adjustRefCount(MprProperties *pp, int adj);
-static int adjustVarRefCount(MprVar *vp, int adj);
-static MprVar *allocProperty(const char *propertyName);
-static void copyVarCore(MprVar *dest, MprVar *src, int copyDepth);
-static MprProperties
- *createProperties(const char *name, int hashSize);
-static bool freeVar(MprVar *vp, int force);
-static bool freeVarStorage(MprVar *vp, int force);
-static MprVar *getObjChain(MprProperties *pp, const char *property);
-static int hash(MprProperties *pp, const char *property);
-static bool releaseProperties(MprProperties *pp, int force);
-
-/*********************************** Code *************************************/
-/*
- * Destroy a variable and all referenced variables. Release any referenced
- * object regardless of whether other users still have references. Be VERY
- * careful using this routine.
- *
- * Return TRUE if the underlying data is freed. Objects may not be freed if
- * there are other users of the object.
- */
-
-bool mprDestroyAllVars(MprVar *vp)
-{
- mprAssert(vp);
-
- if (vp->trigger) {
- if ((vp->trigger)(MPR_VAR_DELETE, vp->parentProperties, vp, 0, 0)
- == MPR_TRIGGER_ABORT) {
- return 0;
- }
- }
-
- /*
- * Free the actual value. If this var refers to an object, we will
- * recurse through all the properties freeing all vars.
- */
- return freeVar(vp, 1);
-}
-
-/******************************************************************************/
-/*
- * Destroy a variable. Release any referenced object (destroy if no other
- * users are referencing).
- *
- * Return TRUE if the underlying data is freed. Objects may not be freed if
- * there are other users of the object.
- */
-
-bool mprDestroyVar(MprVar *vp)
-{
- mprAssert(vp);
-
- if (vp->trigger) {
- if ((vp->trigger)(MPR_VAR_DELETE, vp->parentProperties, vp, 0, 0)
- == MPR_TRIGGER_ABORT) {
- return 0;
- }
- }
-
- /*
- * Free the actual value. If this var refers to an object, we will
- * recurse through all the properties freeing all that have no other
- * references.
- */
- return freeVar(vp, 0);
-}
-
-/******************************************************************************/
-/*
- * Free the value in a variable for primitive types. Release objects.
- *
- * Return TRUE if the underlying data is freed. Objects may not be freed if
- * there are other users of the object.
- */
-
-static bool freeVar(MprVar *vp, int force)
-{
- bool freed;
-
- mprAssert(vp);
-
- freed = freeVarStorage(vp, force);
-
- mprFree(vp->name);
- mprFree(vp->fullName);
-
- if (vp->allocatedVar) {
- mprFree(vp);
- } else {
- vp->name = 0;
- vp->fullName = 0;
- vp->type = MPR_TYPE_UNDEFINED;
- }
- return freed;
-}
-
-/******************************************************************************/
-/*
- * Free the value in a variable for primitive types. Release objects.
- *
- * Return TRUE if the underlying data is freed. Objects may not be freed if
- * there are other users of the object.
- */
-
-static bool freeVarStorage(MprVar *vp, int force)
-{
- MprArray *argList;
- bool freed;
- int i;
-
- freed = 1;
- mprAssert(vp);
-
- switch (vp->type) {
- default:
- break;
-
- case MPR_TYPE_STRING:
- if (vp->allocatedData && vp->string != 0) {
- mprFree(vp->string);
- vp->string = 0;
- vp->allocatedData = 0;
- }
- break;
-
- case MPR_TYPE_PTR:
- if (vp->allocatedData) {
- vp->allocatedData = 0;
- mprFree(vp->ptr);
- }
- break;
-
- case MPR_TYPE_OBJECT:
-#if VAR_DEBUG
- /*
- * Recurse through all properties and release / delete. Release the
- * properties hash table.
- */
- if (vp->properties->refCount > 1) {
- mprLog(7, "freeVar: ACT \"%s\", 0x%x, ref %d, force %d\n",
- vp->name, vp->properties, vp->properties->refCount, force);
- } else {
- mprLog(7, "freeVar: DEL \"%s\", 0x%x, ref %d, force %d\n",
- vp->name, vp->properties, vp->properties->refCount, force);
- }
-#endif
- if (vp->allocatedData) {
- freed = releaseProperties(vp->properties, force);
- }
- vp->properties = 0;
- break;
-
- case MPR_TYPE_FUNCTION:
- if (vp->allocatedData) {
- argList = vp->function.args;
- for (i = 0; i < argList->max; i++) {
- if (argList->handles[i] != 0) {
- mprFree(argList->handles[i]);
- }
- }
- mprDestroyArray(argList);
- vp->function.args = 0;
- mprFree(vp->function.body);
- vp->function.body = 0;
- }
- break;
- }
-
- vp->type = MPR_TYPE_UNDEFINED;
- return freed;
-}
-
-/******************************************************************************/
-/*
- * Adjust the object reference count and return the currrent count of
- * users.
- */
-
-static int adjustVarRefCount(MprVar *vp, int adj)
-{
- mprAssert(vp);
-
- if (vp->type != MPR_TYPE_OBJECT) {
- mprAssert(vp->type == MPR_TYPE_OBJECT);
- return 0;
- }
- return adjustRefCount(vp->properties, adj);
-}
-
-/******************************************************************************/
-/*
- * Get the object reference count
- */
-
-int mprGetVarRefCount(MprVar *vp)
-{
- mprAssert(vp);
-
- if (vp->type != MPR_TYPE_OBJECT) {
- mprAssert(vp->type == MPR_TYPE_OBJECT);
- return 0;
- }
- return adjustRefCount(vp->properties, 0);
-}
-
-/******************************************************************************/
-/*
- * Update the variable's name
- */
-
-void mprSetVarName(MprVar *vp, char *name)
-{
- mprAssert(vp);
-
- mprFree(vp->name);
- vp->name = mprStrdup(name);
-}
-
-/******************************************************************************/
-/*
- * Append to the variable's full name
- */
-
-void mprSetVarFullName(MprVar *vp, char *name)
-{
-#if VAR_DEBUG
- mprAssert(vp);
-
- mprFree(vp->fullName);
- vp->fullName = mprStrdup(name);
- if (vp->type == MPR_TYPE_OBJECT) {
- if (strcmp(vp->properties->name, "this") == 0) {
- mprStrcpy(vp->properties->name, sizeof(vp->properties->name), name);
- }
- }
-#endif
-}
-
-/******************************************************************************/
-/*
- * Make a var impervious to recursive forced deletes.
- */
-
-void mprSetVarDeleteProtect(MprVar *vp, int deleteProtect)
-{
- mprAssert(vp);
-
- if (vp->type == MPR_TYPE_OBJECT && vp->properties) {
- vp->properties->deleteProtect = deleteProtect;
- }
-}
-
-/******************************************************************************/
-/*
- * Make a variable readonly. Can still be deleted.
- */
-
-void mprSetVarReadonly(MprVar *vp, int readonly)
-{
- mprAssert(vp);
-
- vp->readonly = readonly;
-}
-
-/******************************************************************************/
-
-MprVarTrigger mprAddVarTrigger(MprVar *vp, MprVarTrigger fn)
-{
- MprVarTrigger oldTrigger;
-
- mprAssert(vp);
- mprAssert(fn);
-
- oldTrigger = vp->trigger;
- vp->trigger = fn;
- return oldTrigger;
-}
-
-/******************************************************************************/
-
-MprType mprGetVarType(MprVar *vp)
-{
- mprAssert(vp);
-
- return vp->type;
-}
-
-/******************************************************************************/
-/********************************** Properties ********************************/
-/******************************************************************************/
-/*
- * Create a property in an object with a defined value. If the property
- * already exists in the object, then just write its value.
- */
-
-MprVar *mprCreateProperty(MprVar *obj, const char *propertyName,
- MprVar *newValue)
-{
- MprVar *prop, *last;
- int bucketIndex;
-
- mprAssert(obj);
- mprAssert(propertyName && *propertyName);
-
- if (obj->type != MPR_TYPE_OBJECT) {
- mprAssert(obj->type == MPR_TYPE_OBJECT);
- return 0;
- }
-
- /*
- * See if property already exists and locate the bucket to hold the
- * property reference.
- */
- last = 0;
- bucketIndex = hash(obj->properties, propertyName);
- prop = obj->properties->buckets[bucketIndex];
-
- /*
- * Find the property in the hash chain if it exists
- */
- for (last = 0; prop; last = prop, prop = prop->forw) {
- if (prop->name[0] == propertyName[0] &&
- strcmp(prop->name, propertyName) == 0) {
- break;
- }
- }
-
- if (prop) {
- /* FUTURE -- remove. Just for debug. */
- mprAssert(prop == 0);
- mprLog(0, "Attempting to create property %s in object %s\n",
- propertyName, obj->name);
- return 0;
- }
-
- if (obj->trigger) {
- if ((obj->trigger)(MPR_VAR_CREATE_PROPERTY, obj->properties, prop,
- newValue, 0) == MPR_TRIGGER_ABORT) {
- return 0;
- }
- }
-
- /*
- * Create a new property
- */
- prop = allocProperty(propertyName);
- if (prop == 0) {
- mprAssert(prop);
- return 0;
- }
-
- copyVarCore(prop, newValue, MPR_SHALLOW_COPY);
-
- prop->bucketIndex = bucketIndex;
- if (last) {
- last->forw = prop;
- } else {
- obj->properties->buckets[bucketIndex] = prop;
- }
- prop->parentProperties = obj->properties;
-
- /*
- * Update the item counts
- */
- obj->properties->numItems++;
- if (! mprVarIsFunction(prop->type)) {
- obj->properties->numDataItems++;
- }
-
- return prop;
-}
-
-/******************************************************************************/
-/*
- * Create a property in an object with a defined value. If the property
- * already exists in the object, then just write its value. Same as
- * mprCreateProperty except that the new value is passed by value rather than
- * by pointer.
- */
-
-MprVar *mprCreatePropertyValue(MprVar *obj, const char *propertyName,
- MprVar newValue)
-{
- return mprCreateProperty(obj, propertyName, &newValue);
-}
-
-/******************************************************************************/
-/*
- * Create a new property
- */
-
-static MprVar *allocProperty(const char *propertyName)
-{
- MprVar *prop;
-
- prop = (MprVar*) mprMalloc(sizeof(MprVar));
- if (prop == 0) {
- mprAssert(prop);
- return 0;
- }
- memset(prop, 0, sizeof(MprVar));
- prop->allocatedVar = 1;
- prop->name = mprStrdup(propertyName);
- prop->forw = (MprVar*) 0;
-
- return prop;
-}
-
-/******************************************************************************/
-/*
- * Update a property in an object with a defined value. Create the property
- * if it doesn not already exist.
- */
-
-MprVar *mprSetProperty(MprVar *obj, const char *propertyName, MprVar *newValue)
-{
- MprVar *prop, triggerValue;
- int rc;
-
- mprAssert(obj);
- mprAssert(propertyName && *propertyName);
- mprAssert(obj->type == MPR_TYPE_OBJECT);
-
- if (obj->type != MPR_TYPE_OBJECT) {
- mprAssert(0);
- return 0;
- }
-
- prop = mprGetProperty(obj, propertyName, 0);
- if (prop == 0) {
- return mprCreateProperty(obj, propertyName, newValue);
- }
-
- if (obj->trigger) {
- /*
- * Call the trigger before the update and pass it the new value.
- */
- triggerValue = *newValue;
- triggerValue.allocatedVar = 0;
- triggerValue.allocatedData = 0;
- rc = (obj->trigger)(MPR_VAR_WRITE, obj->properties, obj,
- &triggerValue, 0);
- if (rc == MPR_TRIGGER_ABORT) {
- return 0;
-
- } else if (rc == MPR_TRIGGER_USE_NEW_VALUE) {
- /*
- * Trigger must copy to triggerValue a variable that is not
- * a structure copy of the existing data.
- */
- copyVarCore(prop, &triggerValue, MPR_SHALLOW_COPY);
- mprDestroyVar(&triggerValue);
- return prop;
- }
- }
- copyVarCore(prop, newValue, MPR_SHALLOW_COPY);
- return prop;
-}
-
-/******************************************************************************/
-/*
- * Update a property in an object with a defined value. Create the property
- * if it does not already exist. Same as mprSetProperty except that the
- * new value is passed by value rather than by pointer.
- */
-
-MprVar *mprSetPropertyValue(MprVar *obj, const char *propertyName,
- MprVar newValue)
-{
- return mprSetProperty(obj, propertyName, &newValue);
-}
-
-/******************************************************************************/
-/*
- * Delete a property from this object
- */
-
-int mprDeleteProperty(MprVar *obj, const char *property)
-{
- MprVar *prop, *last;
- char *cp;
- int bucketIndex;
-
- mprAssert(obj);
- mprAssert(property && *property);
- mprAssert(obj->type == MPR_TYPE_OBJECT);
-
- if (obj->type != MPR_TYPE_OBJECT) {
- mprAssert(obj->type == MPR_TYPE_OBJECT);
- return 0;
- }
-
- last = 0;
- bucketIndex = hash(obj->properties, property);
- if ((prop = obj->properties->buckets[bucketIndex]) != 0) {
- for ( ; prop; prop = prop->forw) {
- cp = prop->name;
- if (cp[0] == property[0] && strcmp(cp, property) == 0) {
- break;
- }
- last = prop;
- }
- }
- if (prop == (MprVar*) 0) {
- mprAssert(prop);
- return MPR_ERR_NOT_FOUND;
- }
- if (prop->readonly) {
- mprAssert(! prop->readonly);
- return MPR_ERR_READ_ONLY;
- }
-
- if (obj->trigger) {
- if ((obj->trigger)(MPR_VAR_DELETE_PROPERTY, obj->properties, prop, 0, 0)
- == MPR_TRIGGER_ABORT) {
- return MPR_ERR_ABORTED;
- }
- }
-
- if (last) {
- last->forw = prop->forw;
- } else {
- obj->properties->buckets[bucketIndex] = prop->forw;
- }
-
- obj->properties->numItems--;
- if (! mprVarIsFunction(prop->type)) {
- obj->properties->numDataItems--;
- }
-
- mprDestroyVar(prop);
-
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Find a property in an object and return a pointer to it. If a value arg
- * is supplied, then copy the data into the var.
- */
-
-MprVar *mprGetProperty(MprVar *obj, const char *property, MprVar *value)
-{
- MprVar *prop, triggerValue;
- int rc;
-
- if (obj == 0 || obj->type != MPR_TYPE_OBJECT || property == 0 ||
- *property == '\0') {
- if (value) {
- value->type = MPR_TYPE_UNDEFINED;
- }
- return 0;
- }
-
- for (prop = getObjChain(obj->properties, property); prop;
- prop = prop->forw) {
- if (prop->name &&
- prop->name[0] == property[0] && strcmp(prop->name, property) == 0) {
- break;
- }
- }
- if (prop == 0) {
- if (value) {
- value->type = MPR_TYPE_UNDEFINED;
- }
- return 0;
- }
- if (value) {
- if (prop->trigger) {
- triggerValue = *prop;
- triggerValue.allocatedVar = 0;
- triggerValue.allocatedData = 0;
- /*
- * Pass the trigger the current read value and may receive
- * a new value.
- */
- rc = (prop->trigger)(MPR_VAR_READ, prop->parentProperties, prop,
- &triggerValue, 0);
- if (rc == MPR_TRIGGER_ABORT) {
- if (value) {
- value->type = MPR_TYPE_UNDEFINED;
- }
- return 0;
-
- } else if (rc == MPR_TRIGGER_USE_NEW_VALUE) {
- copyVarCore(prop, &triggerValue, MPR_SHALLOW_COPY);
- mprDestroyVar(&triggerValue);
- }
- }
- /*
- * Clone. No copy.
- */
- *value = *prop;
- }
- return prop;
-}
-
-/******************************************************************************/
-/*
- * Read a properties value. This returns the property's value. It does not
- * copy object/string data but returns a pointer directly into the variable.
- * The caller does not and should not call mprDestroy on the returned value.
- * If value is null, just read the property and run triggers.
- */
-
-int mprReadProperty(MprVar *prop, MprVar *value)
-{
- MprVar triggerValue;
- int rc;
-
- mprAssert(prop);
-
- if (prop->trigger) {
- triggerValue = *prop;
- triggerValue.allocatedVar = 0;
- triggerValue.allocatedData = 0;
- rc = (prop->trigger)(MPR_VAR_READ, prop->parentProperties, prop,
- &triggerValue, 0);
-
- if (rc == MPR_TRIGGER_ABORT) {
- return MPR_ERR_ABORTED;
-
- } else if (rc == MPR_TRIGGER_USE_NEW_VALUE) {
- copyVarCore(prop, &triggerValue, MPR_SHALLOW_COPY);
- mprDestroyVar(&triggerValue);
- return 0;
- }
- }
- if (value) {
- *value = *prop;
-
- /*
- * Just so that if the user calls mprDestroyVar on value, it will do no
- * harm.
- */
- value->allocatedVar = 0;
- value->allocatedData = 0;
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Read a properties value. This returns a copy of the property variable.
- * However, if the property is an object or string, it returns a copy of the
- * reference to the underlying data. If copyDepth is set to MPR_DEEP_COPY,
- * then the underlying objects and strings data will be copied as well. If
- * copyDepth is set to MPR_SHALLOW_COPY, then only strings will be copied. If
- * it is set to MPR_NO_COPY, then no data will be copied. In all cases, the
- * user must call mprDestroyVar to free resources. This routine will run any
- * registered triggers which may modify the value the user receives (without
- * updating the properties real value).
- *
- * WARNING: the args are reversed to most other APIs. This conforms to the
- * strcpy(dest, src) standard instead.
- */
-
-int mprCopyProperty(MprVar *dest, MprVar *prop, int copyDepth)
-{
- MprVar triggerValue;
- int rc;
-
- mprAssert(prop);
- mprAssert(dest);
-
- if (prop->trigger) {
- triggerValue = *prop;
- triggerValue.allocatedVar = 0;
- triggerValue.allocatedData = 0;
- rc = (prop->trigger)(MPR_VAR_READ, prop->parentProperties, prop,
- &triggerValue, copyDepth);
-
- if (rc == MPR_TRIGGER_ABORT) {
- return MPR_ERR_ABORTED;
-
- } else if (rc == MPR_TRIGGER_USE_NEW_VALUE) {
- copyVarCore(dest, &triggerValue, MPR_SHALLOW_COPY);
- mprDestroyVar(&triggerValue);
- return 0;
- }
- }
- mprCopyVar(dest, prop, copyDepth);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Write a new value into an existing property in an object.
- */
-
-int mprWriteProperty(MprVar *vp, MprVar *value)
-{
- MprVar triggerValue;
- int rc;
-
- mprAssert(vp);
- mprAssert(value);
-
- if (vp->readonly) {
- return MPR_ERR_READ_ONLY;
- }
-
- if (vp->trigger) {
- triggerValue = *value;
-
- rc = (vp->trigger)(MPR_VAR_WRITE, vp->parentProperties, vp,
- &triggerValue, 0);
-
- if (rc == MPR_TRIGGER_ABORT) {
- return MPR_ERR_ABORTED;
-
- } else if (rc == MPR_TRIGGER_USE_NEW_VALUE) {
- copyVarCore(vp, &triggerValue, MPR_SHALLOW_COPY);
- mprDestroyVar(&triggerValue);
- return 0;
- }
- /* Fall through */
- }
-
- copyVarCore(vp, value, MPR_SHALLOW_COPY);
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Write a new value into an existing property in an object.
- */
-
-int mprWritePropertyValue(MprVar *vp, MprVar value)
-{
- mprAssert(vp);
-
- return mprWriteProperty(vp, &value);
-}
-
-/******************************************************************************/
-/*
- * Get the count of properties.
- */
-
-int mprGetPropertyCount(MprVar *vp, int includeFlags)
-{
- mprAssert(vp);
-
- if (vp->type != MPR_TYPE_OBJECT) {
- return 0;
- }
- if (includeFlags == MPR_ENUM_DATA) {
- return vp->properties->numDataItems;
- } else {
- return vp->properties->numItems;
- }
-}
-
-/******************************************************************************/
-/*
- * Get the first property in an object. Used for walking all properties in an
- * object.
- */
-
-MprVar *mprGetFirstProperty(MprVar *obj, int includeFlags)
-{
- MprVar *prop;
- int i;
-
- mprAssert(obj);
- mprAssert(obj->type == MPR_TYPE_OBJECT);
-
- if (obj->type != MPR_TYPE_OBJECT) {
- mprAssert(obj->type == MPR_TYPE_OBJECT);
- return 0;
- }
-
- for (i = 0; i < (int) obj->properties->hashSize; i++) {
- for (prop = obj->properties->buckets[i]; prop; prop = prop->forw) {
- if (prop) {
- if (mprVarIsFunction(prop->type)) {
- if (!(includeFlags & MPR_ENUM_FUNCTIONS)) {
- continue;
- }
- } else {
- if (!(includeFlags & MPR_ENUM_DATA)) {
- continue;
- }
- }
- return prop;
- }
- break;
- }
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Get the next property in sequence.
- */
-
-MprVar *mprGetNextProperty(MprVar *obj, MprVar *last, int includeFlags)
-{
- MprProperties *properties;
- int i;
-
- mprAssert(obj);
- mprAssert(obj->type == MPR_TYPE_OBJECT);
-
- if (obj->type != MPR_TYPE_OBJECT) {
- mprAssert(obj->type == MPR_TYPE_OBJECT);
- return 0;
- }
- properties = obj->properties;
-
- if (last->forw) {
- return last->forw;
- }
-
- for (i = last->bucketIndex + 1; i < (int) properties->hashSize; i++) {
- for (last = properties->buckets[i]; last; last = last->forw) {
- if (mprVarIsFunction(last->type)) {
- if (!(includeFlags & MPR_ENUM_FUNCTIONS)) {
- continue;
- }
- } else {
- if (!(includeFlags & MPR_ENUM_DATA)) {
- continue;
- }
- }
- return last;
- }
- }
- return 0;
-}
-
-/******************************************************************************/
-/************************** Internal Support Routines *************************/
-/******************************************************************************/
-/*
- * Create an hash table to hold and index properties. Properties are just
- * variables which may contain primitive data types, functions or other
- * objects. The hash table is the essence of an object. HashSize specifies
- * the size of the hash table to use and should be a prime number.
- */
-
-static MprProperties *createProperties(const char *name, int hashSize)
-{
- MprProperties *pp;
-
- if (hashSize < 7) {
- hashSize = 7;
- }
- if ((pp = (MprProperties*) mprMalloc(sizeof(MprProperties))) == NULL) {
- mprAssert(0);
- return 0;
- }
- mprAssert(pp);
- memset(pp, 0, sizeof(MprProperties));
-
- pp->numItems = 0;
- pp->numDataItems = 0;
- pp->hashSize = hashSize;
- pp->buckets = (MprVar**) mprMalloc(pp->hashSize * sizeof(MprVar*));
- mprAssert(pp->buckets);
- memset(pp->buckets, 0, pp->hashSize * sizeof(MprVar*));
- pp->refCount = 1;
-
-#if VAR_DEBUG
- if (objectCount == -1) {
- objectCount = 0;
- objectList.next = objectList.prev = &objectList;
- }
-
- mprStrcpy(pp->name, sizeof(pp->name), name);
- pp->next = &objectList;
- pp->prev = objectList.prev;
- objectList.prev->next = pp;
- objectList.prev = pp;
- objectCount++;
-#endif
- return pp;
-}
-
-/******************************************************************************/
-/*
- * Release an object's properties hash table. If this is the last person
- * using it, free it. Return TRUE if the object is released.
- */
-
-static bool releaseProperties(MprProperties *obj, int force)
-{
- MprProperties *pp;
- MprVar *prop, *forw;
- int i;
-
- mprAssert(obj);
- mprAssert(obj->refCount > 0);
-
-#if VAR_DEBUG
- /*
- * Debug sanity check
- */
- mprAssert(obj->refCount < 20);
-#endif
-
- if (--obj->refCount > 0 && !force) {
- return 0;
- }
-
-#if VAR_DEBUG
- mprAssert(obj->prev);
- mprAssert(obj->next);
- mprAssert(obj->next->prev);
- mprAssert(obj->prev->next);
- obj->next->prev = obj->prev;
- obj->prev->next = obj->next;
- objectCount--;
-#endif
-
- for (i = 0; i < (int) obj->hashSize; i++) {
- for (prop = obj->buckets[i]; prop; prop = forw) {
- forw = prop->forw;
- if (prop->type == MPR_TYPE_OBJECT) {
-
- if (prop->properties == obj) {
- /* Self reference */
- continue;
- }
- pp = prop->properties;
- if (pp->visited) {
- continue;
- }
-
- pp->visited = 1;
- if (! freeVar(prop, pp->deleteProtect ? 0 : force)) {
- pp->visited = 0;
- }
-
- } else {
- freeVar(prop, force);
- }
- }
- }
-
- mprFree((void*) obj->buckets);
- mprFree((void*) obj);
-
- return 1;
-}
-
-/******************************************************************************/
-/*
- * Adjust the reference count
- */
-
-static int adjustRefCount(MprProperties *pp, int adj)
-{
- mprAssert(pp);
-
- /*
- * Debug sanity check
- */
- mprAssert(pp->refCount < 20);
-
- return pp->refCount += adj;
-}
-
-/******************************************************************************/
-#if VAR_DEBUG
-/*
- * Print objects held
- */
-
-void mprPrintObjects(char *msg)
-{
- MprProperties *pp, *np;
- MprVar *prop, *forw;
- char *buf;
- int i;
-
- mprLog(7, "%s: Object Store. %d objects.\n", msg, objectCount);
- pp = objectList.next;
- while (pp != &objectList) {
- mprLog(7, "%s: 0x%x, refCount %d, properties %d\n",
- pp->name, pp, pp->refCount, pp->numItems);
- for (i = 0; i < (int) pp->hashSize; i++) {
- for (prop = pp->buckets[i]; prop; prop = forw) {
- forw = prop->forw;
- if (prop->properties == pp) {
- /* Self reference */
- continue;
- }
- mprVarToString(&buf, MPR_MAX_STRING, 0, prop);
- if (prop->type == MPR_TYPE_OBJECT) {
- np = objectList.next;
- while (np != &objectList) {
- if (prop->properties == np) {
- break;
- }
- np = np->next;
- }
- if (prop->properties == np) {
- mprLog(7, " %s: OBJECT 0x%x, <%s>\n",
- prop->name, prop->properties, prop->fullName);
- } else {
- mprLog(7, " %s: OBJECT NOT FOUND, %s <%s>\n",
- prop->name, buf, prop->fullName);
- }
- } else {
- mprLog(7, " %s: <%s> = %s\n", prop->name,
- prop->fullName, buf);
- }
- mprFree(buf);
- }
- }
- pp = pp->next;
- }
-}
-
-/******************************************************************************/
-
-void mprPrintObjRefCount(MprVar *vp)
-{
- mprLog(7, "OBJECT 0x%x, refCount %d\n", vp->properties,
- vp->properties->refCount);
-}
-
-#endif
-/******************************************************************************/
-/*
- * Get the bucket chain containing a property.
- */
-
-static MprVar *getObjChain(MprProperties *obj, const char *property)
-{
- mprAssert(obj);
-
- return obj->buckets[hash(obj, property)];
-}
-
-/******************************************************************************/
-/*
- * Fast hash. The history of this algorithm is part of lost computer science
- * folk lore.
- */
-
-static int hash(MprProperties *pp, const char *property)
-{
- uint sum;
-
- mprAssert(pp);
- mprAssert(property);
-
- sum = 0;
- while (*property) {
- sum += (sum * 33) + *property++;
- }
-
- return sum % pp->hashSize;
-}
-
-/******************************************************************************/
-/*********************************** Constructors *****************************/
-/******************************************************************************/
-/*
- * Initialize an undefined value.
- */
-
-MprVar mprCreateUndefinedVar()
-{
- MprVar v;
-
- memset(&v, 0x0, sizeof(v));
- v.type = MPR_TYPE_UNDEFINED;
- return v;
-}
-
-/******************************************************************************/
-/*
- * Initialize an null value.
- */
-
-MprVar mprCreateNullVar()
-{
- MprVar v;
-
- memset(&v, 0x0, sizeof(v));
- v.type = MPR_TYPE_NULL;
- return v;
-}
-
-/******************************************************************************/
-
-MprVar mprCreateBoolVar(bool value)
-{
- MprVar v;
-
- memset(&v, 0x0, sizeof(v));
- v.type = MPR_TYPE_BOOL;
- v.boolean = value;
- return v;
-}
-
-/******************************************************************************/
-/*
- * Initialize a C function.
- */
-
-MprVar mprCreateCFunctionVar(MprCFunction fn, void *thisPtr, int flags)
-{
- MprVar v;
-
- memset(&v, 0x0, sizeof(v));
- v.type = MPR_TYPE_CFUNCTION;
- v.cFunction.fn = fn;
- v.cFunction.thisPtr = thisPtr;
- v.flags = flags;
-
- return v;
-}
-
-/******************************************************************************/
-/*
- * Initialize a C function.
- */
-
-MprVar mprCreateStringCFunctionVar(MprStringCFunction fn, void *thisPtr,
- int flags)
-{
- MprVar v;
-
- memset(&v, 0x0, sizeof(v));
- v.type = MPR_TYPE_STRING_CFUNCTION;
- v.cFunctionWithStrings.fn = fn;
- v.cFunctionWithStrings.thisPtr = thisPtr;
- v.flags = flags;
-
- return v;
-}
-
-/******************************************************************************/
-/*
- * Initialize an opaque pointer.
- */
-
-MprVar mprCreatePtrVar(void *ptr)
-{
- MprVar v;
-
- memset(&v, 0x0, sizeof(v));
- v.type = MPR_TYPE_PTR;
- v.ptr = ptr;
-
- return v;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_FLOATING_POINT
-/*
- * Initialize a floating value.
- */
-
-MprVar mprCreateFloatVar(double value)
-{
- MprVar v;
-
- memset(&v, 0x0, sizeof(v));
- v.type = MPR_TYPE_FLOAT;
- v.floating = value;
- return v;
-}
-
-#endif
-/******************************************************************************/
-/*
- * Initialize an integer value.
- */
-
-MprVar mprCreateIntegerVar(int value)
-{
- MprVar v;
-
- memset(&v, 0x0, sizeof(v));
- v.type = MPR_TYPE_INT;
- v.integer = value;
- return v;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_INT64
-/*
- * Initialize a 64-bit integer value.
- */
-
-MprVar mprCreateInteger64Var(int64 value)
-{
- MprVar v;
-
- memset(&v, 0x0, sizeof(v));
- v.type = MPR_TYPE_INT64;
- v.integer64 = value;
- return v;
-}
-
-#endif /* BLD_FEATURE_INT64 */
-/******************************************************************************/
-/*
- * Initialize an number variable. Type is defined by configure.
- */
-
-MprVar mprCreateNumberVar(MprNum value)
-{
- MprVar v;
-
- memset(&v, 0x0, sizeof(v));
- v.type = BLD_FEATURE_NUM_TYPE_ID;
-#if BLD_FEATURE_NUM_TYPE_ID == MPR_TYPE_INT64
- v.integer64 = value;
-#elif BLD_FEATURE_NUM_TYPE_ID == MPR_TYPE_FLOAT
- v.float = value;
-#else
- v.integer = value;
-#endif
- return v;
-}
-
-/******************************************************************************/
-/*
- * Initialize a (bare) JavaScript function. args and body can be null.
- */
-
-MprVar mprCreateFunctionVar(char *args, char *body, int flags)
-{
- MprVar v;
- char *cp, *arg, *last;
- int aid;
-
- memset(&v, 0x0, sizeof(v));
- v.type = MPR_TYPE_FUNCTION;
- v.flags = flags;
-
- v.function.args = mprCreateArray();
-
- if (args) {
- args = mprStrdup(args);
- arg = mprStrTok(args, ",", &last);
- while (arg) {
- while (isspace((int) *arg))
- arg++;
- for (cp = &arg[strlen(arg) - 1]; cp > arg; cp--) {
- if (!isspace((int) *cp)) {
- break;
- }
- }
- cp[1] = '\0';
-
- aid = mprAddToArray(v.function.args, mprStrdup(arg));
- arg = mprStrTok(0, ",", &last);
- }
- mprFree(args);
- }
-
- if (body) {
- v.function.body = mprStrdup(body);
- }
- v.allocatedData = 1;
- return v;
-}
-
-/******************************************************************************/
-/*
- * Initialize an object variable. Return type == MPR_TYPE_UNDEFINED if the
- * memory allocation for the properties table failed.
- */
-
-MprVar mprCreateObjVar(const char *name, int hashSize)
-{
- MprVar v;
-
- mprAssert(name && *name);
-
- memset(&v, 0x0, sizeof(MprVar));
- v.type = MPR_TYPE_OBJECT;
- if (hashSize <= 0) {
- hashSize = MPR_DEFAULT_HASH_SIZE;
- }
- v.properties = createProperties(name, hashSize);
- if (v.properties == 0) {
- /* Indicate failed memory allocation */
- v.type = MPR_TYPE_UNDEFINED;
- }
- v.allocatedData = 1;
- v.name = mprStrdup(name);
- mprLog(7, "mprCreateObjVar %s, 0x%p\n", name, v.properties);
- return v;
-}
-
-/******************************************************************************/
-/*
- * Initialize a string value.
- */
-
-MprVar mprCreateStringVar(const char *value, bool allocate)
-{
- MprVar v;
-
- memset(&v, 0x0, sizeof(v));
- v.type = MPR_TYPE_STRING;
- if (value == 0) {
- v.string = (char*) "";
- } else if (allocate) {
- v.string = mprStrdup(value);
- v.allocatedData = 1;
- } else {
- v.string = (char*) value;
- }
- return v;
-}
-
-/******************************************************************************/
-/*
- * Copy an objects core value (only). This preserves the destination object's
- * name. This implements copy by reference for objects and copy by value for
- * strings and other types. Caller must free dest prior to calling.
- */
-
-static void copyVarCore(MprVar *dest, MprVar *src, int copyDepth)
-{
- MprVarTrigger saveTrigger;
- MprVar *srcProp, *destProp, *last;
- char **srcArgs;
- int i;
-
- mprAssert(dest);
- mprAssert(src);
-
- if (dest == src) {
- return;
- }
-
- /*
- * FUTURE: we should allow read-only triggers where the value is never
- * stored in the object. Currently, triggers override the readonly
- * status.
- */
-
- if (dest->type != MPR_TYPE_UNDEFINED && dest->readonly && !dest->trigger) {
- mprAssert(0);
- return;
- }
-
- if (dest->type != MPR_TYPE_UNDEFINED) {
- saveTrigger = dest->trigger;
- freeVarStorage(dest, 0);
- } else {
- saveTrigger = 0;
- }
-
- switch (src->type) {
- default:
- case MPR_TYPE_UNDEFINED:
- case MPR_TYPE_NULL:
- break;
-
- case MPR_TYPE_BOOL:
- dest->boolean = src->boolean;
- break;
-
- case MPR_TYPE_PTR:
- /* we have to reference here so talloc structures survive a
- copy */
- if (src->allocatedData) {
- dest->ptr = talloc_reference(mprMemCtx(), src->ptr);
- dest->allocatedData = 1;
- } else {
- dest->ptr = src->ptr;
- }
- break;
-
- case MPR_TYPE_STRING_CFUNCTION:
- dest->cFunctionWithStrings = src->cFunctionWithStrings;
- break;
-
- case MPR_TYPE_CFUNCTION:
- dest->cFunction = src->cFunction;
- break;
-
-#if BLD_FEATURE_FLOATING_POINT
- case MPR_TYPE_FLOAT:
- dest->floating = src->floating;
- break;
-#endif
-
- case MPR_TYPE_INT:
- dest->integer = src->integer;
- break;
-
-#if BLD_FEATURE_INT64
- case MPR_TYPE_INT64:
- dest->integer64 = src->integer64;
- break;
-#endif
-
- case MPR_TYPE_OBJECT:
- if (copyDepth == MPR_DEEP_COPY) {
-
- dest->properties = createProperties(src->name,
- src->properties->hashSize);
- dest->allocatedData = 1;
-
- for (i = 0; i < (int) src->properties->hashSize; i++) {
- last = 0;
- for (srcProp = src->properties->buckets[i]; srcProp;
- srcProp = srcProp->forw) {
- if (srcProp->visited) {
- continue;
- }
- destProp = allocProperty(srcProp->name);
- if (destProp == 0) {
- mprAssert(destProp);
- return;
- }
-
- destProp->bucketIndex = i;
- if (last) {
- last->forw = destProp;
- } else {
- dest->properties->buckets[i] = destProp;
- }
- destProp->parentProperties = dest->properties;
-
- /*
- * Recursively copy the object
- */
- srcProp->visited = 1;
- copyVarCore(destProp, srcProp, copyDepth);
- srcProp->visited = 0;
- last = destProp;
- }
- }
- dest->properties->numItems = src->properties->numItems;
- dest->properties->numDataItems = src->properties->numDataItems;
- dest->allocatedData = 1;
-
- } else if (copyDepth == MPR_SHALLOW_COPY) {
- dest->properties = src->properties;
- adjustVarRefCount(src, 1);
- dest->allocatedData = 1;
-
- } else {
- dest->properties = src->properties;
- dest->allocatedData = 0;
- }
- break;
-
- case MPR_TYPE_FUNCTION:
- if (copyDepth != MPR_NO_COPY) {
- dest->function.args = mprCreateArray();
- srcArgs = (char**) src->function.args->handles;
- for (i = 0; i < src->function.args->max; i++) {
- if (srcArgs[i]) {
- mprAddToArray(dest->function.args, mprStrdup(srcArgs[i]));
- }
- }
- dest->function.body = mprStrdup(src->function.body);
- dest->allocatedData = 1;
- } else {
- dest->function.args = src->function.args;
- dest->function.body = src->function.body;
- dest->allocatedData = 0;
- }
- break;
-
- case MPR_TYPE_STRING:
- if (src->string && copyDepth != MPR_NO_COPY) {
- dest->string = mprStrdup(src->string);
- dest->allocatedData = 1;
- } else {
- dest->string = src->string;
- dest->allocatedData = 0;
- }
- break;
- }
-
- dest->type = src->type;
- dest->flags = src->flags;
- dest->trigger = saveTrigger;
-
- /*
- * Just for safety
- */
- dest->spare = 0;
-}
-
-/******************************************************************************/
-/*
- * Copy an entire object including name.
- */
-
-void mprCopyVar(MprVar *dest, MprVar *src, int copyDepth)
-{
- mprAssert(dest);
- mprAssert(src);
-
- copyVarCore(dest, src, copyDepth);
-
- mprFree(dest->name);
- dest->name = mprStrdup(src->name);
-
-#if VAR_DEBUG
- if (src->type == MPR_TYPE_OBJECT) {
-
- mprFree(dest->fullName);
- dest->fullName = mprStrdup(src->fullName);
-
- mprLog(7, "mprCopyVar: object \"%s\", FDQ \"%s\" 0x%x, refCount %d\n",
- dest->name, dest->fullName, dest->properties,
- dest->properties->refCount);
- }
-#endif
-}
-
-/******************************************************************************/
-/*
- * Copy an entire object including name.
- */
-
-void mprCopyVarValue(MprVar *dest, MprVar src, int copyDepth)
-{
- mprAssert(dest);
-
- mprCopyVar(dest, &src, copyDepth);
-}
-
-/******************************************************************************/
-/*
- * Copy an object. This implements copy by reference for objects and copy by
- * value for strings and other types. Caller must free dest prior to calling.
- */
-
-MprVar *mprDupVar(MprVar *src, int copyDepth)
-{
- MprVar *dest;
-
- mprAssert(src);
-
- dest = (MprVar*) mprMalloc(sizeof(MprVar));
- memset(dest, 0, sizeof(MprVar));
-
- mprCopyVar(dest, src, copyDepth);
- return dest;
-}
-
-/******************************************************************************/
-/*
- * Convert a value to a text based representation of its value
- * FUTURE -- conver this to use the format string in all cases. Allow
- * arbitrary format strings.
- */
-
-void mprVarToString(char** out, int size, char *fmt, MprVar *obj)
-{
- char *src;
-
- mprAssert(out);
-
- *out = NULL;
-
- if (obj->trigger) {
- mprReadProperty(obj, 0);
- }
-
- switch (obj->type) {
- case MPR_TYPE_UNDEFINED:
- /* FUTURE -- spec says convert to "undefined" */
- *out = mprStrdup("");
- break;
-
- case MPR_TYPE_NULL:
- *out = mprStrdup("null");
- break;
-
- case MPR_TYPE_PTR:
- mprAllocSprintf(out, size, "[Opaque Pointer %p]", obj->ptr);
- break;
-
- case MPR_TYPE_BOOL:
- if (obj->boolean) {
- *out = mprStrdup("true");
- } else {
- *out = mprStrdup("false");
- }
- break;
-
-#if BLD_FEATURE_FLOATING_POINT
- case MPR_TYPE_FLOAT:
- if (fmt == NULL || *fmt == '\0') {
- mprAllocSprintf(out, size, "%f", obj->floating);
- } else {
- mprAllocSprintf(out, size, fmt, obj->floating);
- }
- break;
-#endif
-
- case MPR_TYPE_INT:
- if (fmt == NULL || *fmt == '\0') {
- mprAllocSprintf(out, size, "%d", obj->integer);
- } else {
- mprAllocSprintf(out, size, fmt, obj->integer);
- }
- break;
-
-#if BLD_FEATURE_INT64
- case MPR_TYPE_INT64:
- if (fmt == NULL || *fmt == '\0') {
-#if BLD_GOAHEAD_WEBSERVER
- mprAllocSprintf(out, size, "%d", (int) obj->integer64);
-#else
- mprAllocSprintf(out, size, "%lld", (long long)obj->integer64);
-#endif
- } else {
- mprAllocSprintf(out, size, fmt, obj->integer64);
- }
- break;
-#endif
-
- case MPR_TYPE_CFUNCTION:
- mprAllocSprintf(out, size, "[C Function]");
- break;
-
- case MPR_TYPE_STRING_CFUNCTION:
- mprAllocSprintf(out, size, "[C StringFunction]");
- break;
-
- case MPR_TYPE_FUNCTION:
- mprAllocSprintf(out, size, "[JavaScript Function]");
- break;
-
- case MPR_TYPE_OBJECT:
- /* FUTURE -- really want: [object class: name] */
- mprAllocSprintf(out, size, "[object %s]", obj->name);
- break;
-
- case MPR_TYPE_STRING:
- src = obj->string;
-
- mprAssert(src);
- if (fmt && *fmt) {
- mprAllocSprintf(out, size, fmt, src);
-
- } else if (src == NULL) {
- *out = mprStrdup("null");
-
- } else {
- *out = mprStrdup(src);
- }
- break;
-
- default:
- mprAssert(0);
- }
-}
-
-/******************************************************************************/
-/*
- * Parse a string based on formatting instructions and intelligently
- * create a variable.
- */
-
-MprVar mprParseVar(char *buf, MprType preferredType)
-{
- MprType type;
- char *cp;
-
- mprAssert(buf);
-
- type = preferredType;
-
- if (preferredType == MPR_TYPE_UNDEFINED) {
- if (*buf == '-') {
- type = MPR_NUM_VAR;
-
- } else if (!isdigit((int) *buf)) {
- if (strcmp(buf, "true") == 0 || strcmp(buf, "false") == 0) {
- type = MPR_TYPE_BOOL;
- } else {
- type = MPR_TYPE_STRING;
- }
-
- } else if (isdigit((int) *buf)) {
- type = MPR_NUM_VAR;
- cp = buf;
- if (*cp && tolower(cp[1]) == 'x') {
- cp = &cp[2];
- }
- for (cp = buf; *cp; cp++) {
- if (! isdigit((int) *cp)) {
- break;
- }
- }
-
- if (*cp != '\0') {
-#if BLD_FEATURE_FLOATING_POINT
- if (*cp == '.' || tolower(*cp) == 'e') {
- type = MPR_TYPE_FLOAT;
- } else
-#endif
- {
- type = MPR_NUM_VAR;
- }
- }
- }
- }
-
- switch (type) {
- case MPR_TYPE_OBJECT:
- case MPR_TYPE_UNDEFINED:
- case MPR_TYPE_NULL:
- case MPR_TYPE_PTR:
- default:
- break;
-
- case MPR_TYPE_BOOL:
- return mprCreateBoolVar(buf[0] == 't' ? 1 : 0);
-
- case MPR_TYPE_INT:
- return mprCreateIntegerVar(mprParseInteger(buf));
-
-#if BLD_FEATURE_INT64
- case MPR_TYPE_INT64:
- return mprCreateInteger64Var(mprParseInteger64(buf));
-#endif
-
- case MPR_TYPE_STRING:
- if (strcmp(buf, "null") == 0) {
- return mprCreateNullVar();
- } else if (strcmp(buf, "undefined") == 0) {
- return mprCreateUndefinedVar();
- }
-
- return mprCreateStringVar(buf, 1);
-
-#if BLD_FEATURE_FLOATING_POINT
- case MPR_TYPE_FLOAT:
- return mprCreateFloatVar(atof(buf));
-#endif
-
- }
- return mprCreateUndefinedVar();
-}
-
-/******************************************************************************/
-/*
- * Convert the variable to a boolean. Only for primitive types.
- */
-
-bool mprVarToBool(const MprVar *vp)
-{
- mprAssert(vp);
-
- switch (vp->type) {
- case MPR_TYPE_UNDEFINED:
- case MPR_TYPE_NULL:
- case MPR_TYPE_STRING_CFUNCTION:
- case MPR_TYPE_CFUNCTION:
- case MPR_TYPE_FUNCTION:
- case MPR_TYPE_OBJECT:
- return 0;
-
- case MPR_TYPE_PTR:
- return (vp->ptr != NULL);
-
- case MPR_TYPE_BOOL:
- return vp->boolean;
-
-#if BLD_FEATURE_FLOATING_POINT
- case MPR_TYPE_FLOAT:
- return (vp->floating != 0 && !mprIsNan(vp->floating));
-#endif
-
- case MPR_TYPE_INT:
- return (vp->integer != 0);
-
-#if BLD_FEATURE_INT64
- case MPR_TYPE_INT64:
- return (vp->integer64 != 0);
-#endif
-
- case MPR_TYPE_STRING:
- mprAssert(vp->string);
- return (vp->string[0] != '\0');
- }
-
- /* Not reached */
- return 0;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_FLOATING_POINT
-/*
- * Convert the variable to a floating point number. Only for primitive types.
- */
-
-double mprVarToFloat(const MprVar *vp)
-{
- mprAssert(vp);
-
- switch (vp->type) {
- case MPR_TYPE_UNDEFINED:
- case MPR_TYPE_NULL:
- case MPR_TYPE_STRING_CFUNCTION:
- case MPR_TYPE_CFUNCTION:
- case MPR_TYPE_FUNCTION:
- case MPR_TYPE_OBJECT:
- case MPR_TYPE_PTR:
- return 0;
-
- case MPR_TYPE_BOOL:
- return (vp->boolean) ? 1.0 : 0.0;
-
- case MPR_TYPE_FLOAT:
- return vp->floating;
-
- case MPR_TYPE_INT:
- return (double) vp->integer;
-
-#if BLD_FEATURE_INT64
- case MPR_TYPE_INT64:
- return (double) vp->integer64;
-#endif
-
- case MPR_TYPE_STRING:
- mprAssert(vp->string);
- return atof(vp->string);
- }
-
- /* Not reached */
- return 0;
-}
-
-#endif
-/******************************************************************************/
-/*
- * Convert the variable to a number type. Only works for primitive types.
- */
-
-MprNum mprVarToNumber(const MprVar *vp)
-{
-#if BLD_FEATURE_NUM_TYPE_ID == MPR_TYPE_INT64
- return mprVarToInteger64(vp);
-#elif BLD_FEATURE_NUM_TYPE_ID == MPR_TYPE_FLOAT
- return mprVarToFloat(vp);
-#else
- return mprVarToInteger(vp);
-#endif
-}
-
-/******************************************************************************/
-/*
- * Convert the variable to a number type. Only works for primitive types.
- */
-
-MprNum mprParseNumber(char *s)
-{
-#if BLD_FEATURE_NUM_TYPE_ID == MPR_TYPE_INT64
- return mprParseInteger64(s);
-#elif BLD_FEATURE_NUM_TYPE_ID == MPR_TYPE_FLOAT
- return mprParseFloat(s);
-#else
- return mprParseInteger(s);
-#endif
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_INT64
-/*
- * Convert the variable to an Integer64 type. Only works for primitive types.
- */
-
-int64 mprVarToInteger64(const MprVar *vp)
-{
- mprAssert(vp);
-
- switch (vp->type) {
- case MPR_TYPE_UNDEFINED:
- case MPR_TYPE_NULL:
- case MPR_TYPE_STRING_CFUNCTION:
- case MPR_TYPE_CFUNCTION:
- case MPR_TYPE_FUNCTION:
- case MPR_TYPE_OBJECT:
- case MPR_TYPE_PTR:
- return 0;
-
- case MPR_TYPE_BOOL:
- return (vp->boolean) ? 1 : 0;
-
-#if BLD_FEATURE_FLOATING_POINT
- case MPR_TYPE_FLOAT:
- if (mprIsNan(vp->floating)) {
- return 0;
- }
- return (int64) vp->floating;
-#endif
-
- case MPR_TYPE_INT:
- return vp->integer;
-
- case MPR_TYPE_INT64:
- return vp->integer64;
-
- case MPR_TYPE_STRING:
- return mprParseInteger64(vp->string);
- }
-
- /* Not reached */
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Convert the string buffer to an Integer64.
- */
-
-int64 mprParseInteger64(char *str)
-{
- char *cp;
- int64 num64;
- int radix, c, negative;
-
- mprAssert(str);
-
- cp = str;
- num64 = 0;
- negative = 0;
-
- if (*cp == '-') {
- cp++;
- negative = 1;
- }
-
- /*
- * Parse a number. Observe hex and octal prefixes (0x, 0)
- */
- if (*cp != '0') {
- /*
- * Normal numbers (Radix 10)
- */
- while (isdigit((int) *cp)) {
- num64 = (*cp - '0') + (num64 * 10);
- cp++;
- }
- } else {
- cp++;
- if (tolower(*cp) == 'x') {
- cp++;
- radix = 16;
- while (*cp) {
- c = tolower(*cp);
- if (isdigit(c)) {
- num64 = (c - '0') + (num64 * radix);
- } else if (c >= 'a' && c <= 'f') {
- num64 = (c - ('a' - 10)) + (num64 * radix);
- } else {
- break;
- }
- cp++;
- }
-
- } else{
- radix = 8;
- while (*cp) {
- c = tolower(*cp);
- if (isdigit(c) && c < '8') {
- num64 = (c - '0') + (num64 * radix);
- } else {
- break;
- }
- cp++;
- }
- }
- }
-
- if (negative) {
- return 0 - num64;
- }
- return num64;
-}
-
-#endif /* BLD_FEATURE_INT64 */
-/******************************************************************************/
-/*
- * Convert the variable to an Integer type. Only works for primitive types.
- */
-
-int mprVarToInteger(const MprVar *vp)
-{
- mprAssert(vp);
-
- switch (vp->type) {
- case MPR_TYPE_UNDEFINED:
- case MPR_TYPE_NULL:
- case MPR_TYPE_STRING_CFUNCTION:
- case MPR_TYPE_CFUNCTION:
- case MPR_TYPE_FUNCTION:
- case MPR_TYPE_OBJECT:
- case MPR_TYPE_PTR:
- return 0;
-
- case MPR_TYPE_BOOL:
- return (vp->boolean) ? 1 : 0;
-
-#if BLD_FEATURE_FLOATING_POINT
- case MPR_TYPE_FLOAT:
- if (mprIsNan(vp->floating)) {
- return 0;
- }
- return (int) vp->floating;
-#endif
-
- case MPR_TYPE_INT:
- return vp->integer;
-
-#if BLD_FEATURE_INT64
- case MPR_TYPE_INT64:
- return (int) vp->integer64;
-#endif
-
- case MPR_TYPE_STRING:
- return mprParseInteger(vp->string);
- }
-
- /* Not reached */
- return 0;
-}
-
-/******************************************************************************/
-/*
- * Convert the string buffer to an Integer.
- */
-
-int mprParseInteger(char *str)
-{
- char *cp;
- int num;
- int radix, c, negative;
-
- mprAssert(str);
-
- cp = str;
- num = 0;
- negative = 0;
-
- if (*cp == '-') {
- cp++;
- negative = 1;
- }
-
- /*
- * Parse a number. Observe hex and octal prefixes (0x, 0)
- */
- if (*cp != '0') {
- /*
- * Normal numbers (Radix 10)
- */
- while (isdigit((int) *cp)) {
- num = (*cp - '0') + (num * 10);
- cp++;
- }
- } else {
- cp++;
- if (tolower(*cp) == 'x') {
- cp++;
- radix = 16;
- while (*cp) {
- c = tolower(*cp);
- if (isdigit(c)) {
- num = (c - '0') + (num * radix);
- } else if (c >= 'a' && c <= 'f') {
- num = (c - ('a' - 10)) + (num * radix);
- } else {
- break;
- }
- cp++;
- }
-
- } else{
- radix = 8;
- while (*cp) {
- c = tolower(*cp);
- if (isdigit(c) && c < '8') {
- num = (c - '0') + (num * radix);
- } else {
- break;
- }
- cp++;
- }
- }
- }
-
- if (negative) {
- return 0 - num;
- }
- return num;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_FLOATING_POINT
-/*
- * Convert the string buffer to an Floating.
- */
-
-double mprParseFloat(char *str)
-{
- return atof(str);
-}
-
-/******************************************************************************/
-
-bool mprIsNan(double f)
-{
-#if WIN
- return _isnan(f);
-#elif VXWORKS
- /* FUTURE */
- return (0);
-#elif defined(FP_NAN)
- return (f == FP_NAN);
-#else
- return 0;
-#endif
-}
-/******************************************************************************/
-
-bool mprIsInfinite(double f)
-{
-#if WIN
- return !_finite(f);
-#elif VXWORKS
- /* FUTURE */
- return (0);
-#elif defined(FP_INFINITE)
- return (f == FP_INFINITE);
-#else
- return 0;
-#endif
-}
-
-#endif /* BLD_FEATURE_FLOATING_POINT */
-/******************************************************************************/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/appweb/mpr/var.h b/source4/lib/appweb/mpr/var.h
deleted file mode 100644
index 98313c0476..0000000000
--- a/source4/lib/appweb/mpr/var.h
+++ /dev/null
@@ -1,487 +0,0 @@
-/*
- * @file var.h
- * @brief MPR Universal Variable Type
- * @copy default.m
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved.
- * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; 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 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-
-/******************************* Documentation ********************************/
-/*
- * Variables can efficiently store primitive types and can hold references to
- * objects. Objects can store properties which are themselves variables.
- * Properties can be primitive data types, other objects or functions.
- * Properties are indexed by a character name. A variable may store one of
- * the following types:
- *
- * string, integer, integer-64bit, C function, C function with string args,
- * Javascript function, Floating point number, boolean value, Undefined
- * value and the Null value.
- *
- * Variables have names while objects may be referenced by multiple variables.
- * Objects use reference counting for garbage collection.
- *
- * This module is not thread safe for performance and compactness. It relies
- * on upper modules to provide thread synchronization as required. The API
- * provides primitives to get variable/object references or to get copies of
- * variables which will help minimize required lock times.
- */
-
-#ifndef _h_MPR_VAR
-#define _h_MPR_VAR 1
-
-/********************************* Includes ***********************************/
-
-#include "miniMpr.h"
-
-/********************************** Defines ***********************************/
-
-/*
- * Define VAR_DEBUG if you want to track objects. However, this code is not
- * thread safe and you need to run the server single threaded.
- *
- * #define VAR_DEBUG 1
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Forward declare types
- */
-struct MprProperties;
-struct MprVar;
-
-/*
- * Possible variable types. Don't use enum because we need to be able to
- * do compile time conditional compilation on BLD_FEATURE_NUM_TYPE_ID.
- */
-typedef int MprType;
-#define MPR_TYPE_UNDEFINED 0 /* Undefined. No value has been set. */
-#define MPR_TYPE_NULL 1 /* Value defined to be null. */
-#define MPR_TYPE_BOOL 2 /* Boolean type. */
-#define MPR_TYPE_CFUNCTION 3 /* C function or C++ method */
-#define MPR_TYPE_FLOAT 4 /* Floating point number */
-#define MPR_TYPE_INT 5 /* Integer number */
-#define MPR_TYPE_INT64 6 /* 64-bit Integer number */
-#define MPR_TYPE_OBJECT 7 /* Object reference */
-#define MPR_TYPE_FUNCTION 8 /* JavaScript function */
-#define MPR_TYPE_STRING 9 /* String (immutable) */
-#define MPR_TYPE_STRING_CFUNCTION 10 /* C/C++ function with string args */
-#define MPR_TYPE_PTR 11 /* Opaque pointer */
-
-/*
- * Create a type for the default number type
- * Config.h will define the default number type. For example:
- *
- * BLD_FEATURE_NUM_TYPE=int
- * BLD_FEATURE_NUM_TYPE_ID=MPR_TYPE_INT
- */
-
-/**
- * Set to the type used for MPR numeric variables. Will equate to int, int64
- * or double.
- */
-typedef BLD_FEATURE_NUM_TYPE MprNum;
-
-/**
- * Set to the MPR_TYPE used for MPR numeric variables. Will equate to
- * MPR_TYPE_INT, MPR_TYPE_INT64 or MPR_TYPE_FLOAT.
- */
-#define MPR_NUM_VAR BLD_FEATURE_NUM_TYPE_ID
-#define MPR_TYPE_NUM BLD_FEATURE_NUM_TYPE_ID
-
-/*
- * Return TRUE if a variable is a function type
- */
-#define mprVarIsFunction(type) \
- (type == MPR_TYPE_FUNCTION || type == MPR_TYPE_STRING_CFUNCTION || \
- type == MPR_TYPE_CFUNCTION)
-
-/*
- * Return TRUE if a variable is a numeric type
- */
-#define mprVarIsNumber(type) \
- (type == MPR_TYPE_INT || type == MPR_TYPE_INT64 || type == MPR_TYPE_FLOAT)
-
-/*
- * Return TRUE if a variable is a boolean
- */
-#define mprVarIsBoolean(type) \
- (type == MPR_TYPE_BOOL)
-#define mprVarIsString(type) \
- (type == MPR_TYPE_STRING)
-#define mprVarIsObject(type) \
- (type == MPR_TYPE_OBJECT)
-#define mprVarIsFloating(type) \
- (type == MPR_TYPE_FLOAT)
-#define mprVarIsPtr(type) \
- (type == MPR_TYPE_PTR)
-#define mprVarIsUndefined(var) \
- ((var)->type == MPR_TYPE_UNDEFINED)
-#define mprVarIsNull(var) \
- ((var)->type == MPR_TYPE_NULL)
-#define mprVarIsValid(var) \
- (((var)->type != MPR_TYPE_NULL) && ((var)->type != MPR_TYPE_UNDEFINED))
-
-#define MPR_VAR_MAX_RECURSE 5 /* Max object loops */
-
-#if BLD_FEATURE_SQUEEZE
-#define MPR_MAX_VAR 64 /* Max var full name */
-#else
-#define MPR_MAX_VAR 512
-#endif
-
-/*
- * Function signatures
- */
-typedef int MprVarHandle;
-typedef int (*MprCFunction)(MprVarHandle userHandle, int argc,
- struct MprVar **argv);
-typedef int (*MprStringCFunction)(MprVarHandle userHandle, int argc,
- char **argv);
-
-/*
- * Triggers
- */
-typedef enum {
- MPR_VAR_WRITE, /* This property is being updated */
- MPR_VAR_READ, /* This property is being read */
- MPR_VAR_CREATE_PROPERTY, /* A property is being created */
- MPR_VAR_DELETE_PROPERTY, /* A property is being deleted */
- MPR_VAR_DELETE /* This object is being deleted */
-} MprVarTriggerOp;
-
-/*
- * Trigger function return codes.
- */
-typedef enum {
- MPR_TRIGGER_ABORT, /* Abort the current operation */
- MPR_TRIGGER_USE_NEW_VALUE, /* Proceed and use the newValue */
- MPR_TRIGGER_PROCEED /* Proceed with the operation */
-} MprVarTriggerStatus;
-
-/*
- * The MprVarTrigger arguments have the following meaning:
- *
- * op The operation being performed. See MprVarTriggerOp.
- * parentProperties Pointer to the MprProperties structure.
- * vp Pointer to the property that registered the trigger.
- * newValue New value (see below for more details).
- * copyDepth Specify what data items to copy.
- *
- * For VAR_READ, newVar is set to a temporary variable that the trigger
- * function may assign a value to be returned instead of the actual
- * property value.
- * For VAR_WRITE, newValue holds the new value. The old existing value may be
- * accessed via vp.
- * For DELETE_PROPERTY, vp is the property being deleted. newValue is null.
- * For ADD_PROPERTY, vp is set to the property being added and newValue holds
- * the new value.
- */
-typedef MprVarTriggerStatus (*MprVarTrigger)(MprVarTriggerOp op,
- struct MprProperties *parentProperties, struct MprVar *vp,
- struct MprVar *newValue, int copyDepth);
-
-/*
- * mprCreateFunctionVar flags
- */
-/** Use the alternate handle on function callbacks */
-#define MPR_VAR_ALT_HANDLE 0x1
-
-/** Use the script handle on function callbacks */
-#define MPR_VAR_SCRIPT_HANDLE 0x2
-
-/*
- * Useful define for the copyDepth argument
- */
-/** Don't copy any data. Copy only the variable name */
-#define MPR_NO_COPY 0
-
-/** Copy strings. Increment object reference counts. */
-#define MPR_SHALLOW_COPY 1
-
-/** Copy strings and do complete object copies. */
-#define MPR_DEEP_COPY 2
-
-/*
- * GetFirst / GetNext flags
- */
-/** Step into data properties. */
-#define MPR_ENUM_DATA 0x1
-
-/** Step into functions properties. */
-#define MPR_ENUM_FUNCTIONS 0x2
-
-/*
- * Collection type to hold properties in an object
- */
-typedef struct MprProperties { /* Collection of properties */
-#if VAR_DEBUG
- struct MprProperties *next; /* Linked list */
- struct MprProperties *prev; /* Linked list */
- char name[32]; /* Debug name */
-#endif
- struct MprVar **buckets; /* Hash chains */
- int numItems; /* Total count of items */
- /* FUTURE - Better way of doing this */
- int numDataItems; /* Enumerable data items */
- uint hashSize : 8; /* Size of the hash table */
- /* FUTURE -- increase size of refCount */
- uint refCount : 8; /* References to this property*/
- /* FUTURE - make these flags */
- uint deleteProtect : 8; /* Don't recursively delete */
- uint visited : 8; /* Node has been processed */
-} MprProperties;
-
-/*
- * Universal Variable Type
- */
-typedef struct MprVar {
- /* FUTURE - remove name to outside reference */
- MprStr name; /* Property name */
- /* FUTURE - remove */
- MprStr fullName; /* Full object name */
- /* FUTURE - make part of the union */
- MprProperties *properties; /* Pointer to properties */
-
- /*
- * Packed bit field
- */
- MprType type : 8; /* Selector into union */
- uint bucketIndex : 8; /* Copy of bucket index */
-
- uint flags : 5; /* Type specific flags */
- uint allocatedData : 1; /* Data needs freeing */
- uint readonly : 1; /* Unmodifiable */
- uint deleteProtect : 1; /* Don't recursively delete */
-
- uint visited : 1; /* Node has been processed */
- uint allocatedVar : 1; /* Var needs freeing */
- uint spare : 6; /* Unused */
-
- struct MprVar *forw; /* Hash table linkage */
- MprVarTrigger trigger; /* Trigger function */
-
-#if UNUSED && KEEP
- struct MprVar *baseClass; /* Pointer to class object */
-#endif
- MprProperties *parentProperties; /* Pointer to parent object */
-
- /*
- * Union of primitive types. When debugging on Linux, don't use unions
- * as the gdb debugger can't display them.
- */
-#if 0 && !BLD_DEBUG && !LINUX && !VXWORKS
- union {
-#endif
- bool boolean;
-#if BLD_FEATURE_FLOATING_POINT
- double floating;
-#endif
- int integer;
-#if BLD_FEATURE_INT64
- int64 integer64;
-#endif
- struct { /* Javascript functions */
- MprArray *args; /* Null terminated */
- char *body;
- } function;
- struct { /* Function with MprVar args */
- MprCFunction fn;
- void *thisPtr;
- } cFunction;
- struct { /* Function with string args */
- MprStringCFunction fn;
- void *thisPtr;
- } cFunctionWithStrings;
- MprStr string; /* Allocated string */
- void *ptr; /* Opaque pointer */
-#if 0 && !BLD_DEBUG && !LINUX && !VXWORKS
- };
-#endif
-} MprVar;
-
-/*
- * Define a field macro so code an use numbers in a "generic" fashion.
- */
-#if MPR_NUM_VAR == MPR_TYPE_INT || DOXYGEN
-/* Default numeric type */
-#define mprNumber integer
-#endif
-#if MPR_NUM_VAR == MPR_TYPE_INT64
-/* Default numeric type */
-#define mprNumber integer64
-#endif
-#if MPR_NUM_VAR == MPR_TYPE_FLOAT
-/* Default numeric type */
-#define mprNumber floating
-#endif
-
-typedef BLD_FEATURE_NUM_TYPE MprNumber;
-
-/********************************* Prototypes *********************************/
-/*
- * Variable constructors and destructors
- */
-extern MprVar mprCreateObjVar(const char *name, int hashSize);
-extern MprVar mprCreateBoolVar(bool value);
-extern MprVar mprCreateCFunctionVar(MprCFunction fn, void *thisPtr,
- int flags);
-#if BLD_FEATURE_FLOATING_POINT
-extern MprVar mprCreateFloatVar(double value);
-#endif
-extern MprVar mprCreateIntegerVar(int value);
-#if BLD_FEATURE_INT64
-extern MprVar mprCreateInteger64Var(int64 value);
-#endif
-extern MprVar mprCreateFunctionVar(char *args, char *body, int flags);
-extern MprVar mprCreateNullVar(void);
-extern MprVar mprCreateNumberVar(MprNumber value);
-extern MprVar mprCreateStringCFunctionVar(MprStringCFunction fn,
- void *thisPtr, int flags);
-extern MprVar mprCreateStringVar(const char *value, bool allocate);
-extern MprVar mprCreateUndefinedVar(void);
-extern MprVar mprCreatePtrVar(void *ptr);
-extern bool mprDestroyVar(MprVar *vp);
-extern bool mprDestroyAllVars(MprVar* vp);
-extern MprType mprGetVarType(MprVar *vp);
-
-/*
- * Copy
- */
-extern void mprCopyVar(MprVar *dest, MprVar *src, int copyDepth);
-extern void mprCopyVarValue(MprVar *dest, MprVar src, int copyDepth);
-extern MprVar *mprDupVar(MprVar *src, int copyDepth);
-
-/*
- * Manage vars
- */
-extern MprVarTrigger
- mprAddVarTrigger(MprVar *vp, MprVarTrigger fn);
-extern int mprGetVarRefCount(MprVar *vp);
-extern void mprSetVarDeleteProtect(MprVar *vp, int deleteProtect);
-extern void mprSetVarFullName(MprVar *vp, char *name);
-extern void mprSetVarReadonly(MprVar *vp, int readonly);
-extern void mprSetVarName(MprVar *vp, char *name);
-
-/*
- * Create properties and return a reference to the property.
- */
-extern MprVar *mprCreateProperty(MprVar *obj, const char *property,
- MprVar *newValue);
-extern MprVar *mprCreatePropertyValue(MprVar *obj, const char *property,
- MprVar newValue);
-extern int mprDeleteProperty(MprVar *obj, const char *property);
-
-/*
- * Get/Set properties. Set will update/create.
- */
-extern MprVar *mprGetProperty(MprVar *obj, const char *property,
- MprVar *value);
-extern MprVar *mprSetProperty(MprVar *obj, const char *property,
- MprVar *value);
-extern MprVar *mprSetPropertyValue(MprVar *obj, const char *property,
- MprVar value);
-
-/*
- * Directly read/write property values (the property must already exist)
- * For mprCopyProperty, mprDestroyVar must always called on the var.
- */
-extern int mprReadProperty(MprVar *prop, MprVar *value);
-extern int mprWriteProperty(MprVar *prop, MprVar *newValue);
-extern int mprWritePropertyValue(MprVar *prop, MprVar newValue);
-
-/*
- * Copy a property. NOTE: reverse of most other args: (dest, src)
- */
-extern int mprCopyProperty(MprVar *dest, MprVar *prop, int copyDepth);
-
-/*
- * Enumerate properties
- */
-extern MprVar *mprGetFirstProperty(MprVar *obj, int includeFlags);
-extern MprVar *mprGetNextProperty(MprVar *obj, MprVar *currentProperty,
- int includeFlags);
-
-/*
- * Query properties characteristics
- */
-extern int mprGetPropertyCount(MprVar *obj, int includeFlags);
-
-/*
- * Conversion routines
- */
-extern MprVar mprParseVar(char *str, MprType prefType);
-extern MprNum mprVarToNumber(const MprVar *vp);
-extern int mprVarToInteger(const MprVar *vp);
-#if BLD_FEATURE_INT64
-extern int64 mprVarToInteger64(const MprVar *vp);
-#endif
-extern bool mprVarToBool(const MprVar *vp);
-#if BLD_FEATURE_FLOATING_POINT
-extern double mprVarToFloat(const MprVar *vp);
-#endif
-extern void mprVarToString(char** buf, int size, char *fmt, MprVar *vp);
-
-/*
- * Parsing and utility routines
- */
-extern MprNum mprParseNumber(char *str);
-extern int mprParseInteger(char *str);
-
-#if BLD_FEATURE_INT64
-extern int64 mprParseInteger64(char *str);
-#endif
-
-#if BLD_FEATURE_FLOATING_POINT
-extern double mprParseFloat(char *str);
-extern bool mprIsInfinite(double f);
-extern bool mprIsNan(double f);
-#endif
-
-#if VAR_DEBUG
-extern void mprPrintObjects(char *msg);
-extern void mprPrintObjRefCount(MprVar *vp);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-/*****************************************************************************/
-#endif /* _h_MPR_VAR */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h
index c49745cd7f..041eaeace7 100644
--- a/source4/lib/charset/charset.h
+++ b/source4/lib/charset/charset.h
@@ -97,6 +97,7 @@ size_t count_chars_w(const char *s, char c);
void strupper_m(char *s);
void strlower_m(char *s);
char *strupper_talloc(TALLOC_CTX *ctx, const char *src);
+char *talloc_strdup_upper(TALLOC_CTX *ctx, const char *src);
char *strupper_talloc_n(TALLOC_CTX *ctx, const char *src, size_t n);
char *strlower_talloc(TALLOC_CTX *ctx, const char *src);
bool strhasupper(const char *string);
@@ -146,4 +147,8 @@ struct smb_iconv_convenience *smb_iconv_convenience_init(TALLOC_CTX *mem_ctx,
const char *dos_charset,
const char *unix_charset,
bool native_iconv);
+
+void load_case_tables(void);
+bool charset_register_backend(const void *_funcs);
+
#endif /* __CHARSET_H__ */
diff --git a/source4/lib/charset/iconv.c b/source4/lib/charset/iconv.c
index d4f930b462..150383e7f9 100644
--- a/source4/lib/charset/iconv.c
+++ b/source4/lib/charset/iconv.c
@@ -19,7 +19,7 @@
*/
#include "includes.h"
-#include "lib/util/dlinklist.h"
+#include "../lib/util/dlinklist.h"
#include "system/iconv.h"
#include "system/filesys.h"
#include "param/param.h"
diff --git a/source4/lib/charset/util_unistr.c b/source4/lib/charset/util_unistr.c
index 09ec7b0471..e4f4bb551a 100644
--- a/source4/lib/charset/util_unistr.c
+++ b/source4/lib/charset/util_unistr.c
@@ -37,7 +37,7 @@ static void *lowcase_table;
/*******************************************************************
load the case handling tables
********************************************************************/
-static void load_case_tables(void)
+void load_case_tables(void)
{
TALLOC_CTX *mem_ctx;
@@ -386,6 +386,9 @@ _PUBLIC_ size_t strlen_m_term(const char *s)
**/
_PUBLIC_ char *strchr_m(const char *s, char c)
{
+ if (s == NULL) {
+ return NULL;
+ }
/* characters below 0x3F are guaranteed to not appear in
non-initial position in multi-byte charsets */
if ((c & 0xC0) == 0) {
@@ -411,6 +414,10 @@ _PUBLIC_ char *strrchr_m(const char *s, char c)
{
char *ret = NULL;
+ if (s == NULL) {
+ return NULL;
+ }
+
/* characters below 0x3F are guaranteed to not appear in
non-initial position in multi-byte charsets */
if ((c & 0xC0) == 0) {
@@ -570,7 +577,13 @@ _PUBLIC_ char *strupper_talloc(TALLOC_CTX *ctx, const char *src)
return strupper_talloc_n(ctx, src, src?strlen(src):0);
}
-
+/**
+ talloc_strdup() a unix string to upper case.
+**/
+_PUBLIC_ char *talloc_strdup_upper(TALLOC_CTX *ctx, const char *src)
+{
+ return strupper_talloc(ctx, src);
+}
/**
Convert a string to lower case.
diff --git a/source4/lib/cmdline/credentials.c b/source4/lib/cmdline/credentials.c
index 2e5c6fd94a..f919842e6a 100644
--- a/source4/lib/cmdline/credentials.c
+++ b/source4/lib/cmdline/credentials.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "auth/credentials/credentials.h"
+#include "lib/cmdline/credentials.h"
static const char *cmdline_get_userpassword(struct cli_credentials *credentials)
{
diff --git a/source4/lib/cmdline/popt_common.h b/source4/lib/cmdline/popt_common.h
index df432bb475..733d12a443 100644
--- a/source4/lib/cmdline/popt_common.h
+++ b/source4/lib/cmdline/popt_common.h
@@ -36,4 +36,6 @@ extern struct poptOption popt_common_credentials[];
extern struct cli_credentials *cmdline_credentials;
extern struct loadparm_context *cmdline_lp_ctx;
+void popt_common_dont_ask(void);
+
#endif /* _POPT_COMMON_H */
diff --git a/source4/lib/com/README b/source4/lib/com/README
new file mode 100644
index 0000000000..361024e02c
--- /dev/null
+++ b/source4/lib/com/README
@@ -0,0 +1,9 @@
+This directory contains Samba's very simple COM implementation.
+It is by no means finished yet.
+
+The main aim of this implementation is for use by our DCOM implementation,
+which lives in the dcom subdirectory. The local version is used mostly for
+testing.
+
+More information on this effort can be found in the DCOM whitepaper in
+the lorikeet repository.
diff --git a/source4/lib/com/classes/simple.c b/source4/lib/com/classes/simple.c
new file mode 100644
index 0000000000..295f113207
--- /dev/null
+++ b/source4/lib/com/classes/simple.c
@@ -0,0 +1,122 @@
+/*
+ Unix SMB/CIFS implementation.
+ Simple class
+ Copyright (C) 2004-2005 Jelmer Vernooij <jelmer@samba.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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "lib/com/com.h"
+#include "librpc/gen_ndr/com_dcom.h"
+
+static struct IClassFactory_vtable simple_classobject_vtable;
+static struct IStream_vtable simple_IStream_vtable;
+
+static WERROR simple_IUnknown_QueryInterface (struct IUnknown *d, TALLOC_CTX *mem_ctx, struct GUID *iid, struct IUnknown **iun)
+{
+ *iun = d;
+ return WERR_OK;
+}
+
+static uint32_t simple_IUnknown_AddRef (struct IUnknown *d, TALLOC_CTX *mem_ctx)
+{
+ return 1;
+}
+
+static uint32_t simple_IUnknown_Release (struct IUnknown *d, TALLOC_CTX *mem_ctx)
+{
+ return 1;
+}
+
+static WERROR simple_IStream_Read (struct IStream *d, TALLOC_CTX *mem_ctx, uint8_t *pv, uint32_t num_requested, uint32_t *num_readx, uint32_t num_read)
+{
+ printf("%d bytes are being read\n", num_read);
+ return WERR_OK;
+}
+
+static WERROR simple_IStream_Write (struct IStream *d, TALLOC_CTX *mem_ctx, uint8_t *data, uint32_t num_requested, uint32_t num_written)
+{
+ printf("%d bytes are being written\n", num_requested);
+ return WERR_OK;
+}
+
+static WERROR simpleclass_IUnknown_QueryInterface (struct IUnknown *d, TALLOC_CTX *mem_ctx, struct GUID *iid, struct IUnknown **iun)
+{
+ /* FIXME: Return WERR_IFACE_NOT_SUPPORTED if IID != IID_IUNKNOWN and IID != IID_CLASSFACTORY */
+ *iun = d;
+ return WERR_OK;
+}
+
+static WERROR simpleclass_IClassFactory_CreateInstance (struct IClassFactory *d, TALLOC_CTX *mem_ctx, struct IUnknown *iunk, struct GUID *iid, struct IUnknown **ppv)
+{
+ struct IStream *ret;
+ /* FIXME: Check whether IID == ISTREAM_IID */
+ ret = talloc(mem_ctx, struct IStream);
+ ret->ctx = NULL;
+ ret->vtable = &simple_IStream_vtable;
+ ret->object_data = NULL;
+
+ *ppv = (struct IUnknown *)ret;
+
+ return WERR_OK;
+}
+
+static uint32_t simpleclass_IUnknown_AddRef (struct IUnknown *d, TALLOC_CTX *mem_ctx)
+{
+ return 1;
+}
+
+static uint32_t simpleclass_IUnknown_Release (struct IUnknown *d, TALLOC_CTX *mem_ctx)
+{
+ return 1;
+}
+
+/* Everything below this line should be autogenerated later on */
+static struct IClassFactory_vtable simple_classobject_vtable = {
+ { 0, 0, 0, { 0, 0 }, { 0, 0, 0, 0, 0, 0 } },
+ simpleclass_IUnknown_QueryInterface,
+ simpleclass_IUnknown_AddRef,
+ simpleclass_IUnknown_Release,
+ simpleclass_IClassFactory_CreateInstance,
+ NULL,
+ NULL,
+ NULL
+};
+
+static struct IStream_vtable simple_IStream_vtable = {
+ { 0, 0, 0, { 0, 0 }, { 0, 0, 0, 0, 0, 0 } },
+ simple_IUnknown_QueryInterface,
+ simple_IUnknown_AddRef,
+ simple_IUnknown_Release,
+ simple_IStream_Read,
+ simple_IStream_Write
+};
+
+NTSTATUS com_simple_init(void)
+{
+ struct GUID clsid;
+ struct IUnknown *class_object = talloc(talloc_autofree_context(), struct IUnknown);
+
+ class_object->ctx = NULL;
+ class_object->object_data = NULL;
+ class_object->vtable = (struct IUnknown_vtable *)&simple_classobject_vtable;
+
+ GUID_from_string(CLSID_SIMPLE, &clsid);
+ GUID_from_string(COM_ICLASSFACTORY_UUID, &simple_classobject_vtable.iid);
+ GUID_from_string(COM_ISTREAM_UUID, &simple_IStream_vtable.iid);
+
+ return com_register_running_class(&clsid, PROGID_SIMPLE, class_object);
+}
diff --git a/source4/lib/com/com.h b/source4/lib/com/com.h
new file mode 100644
index 0000000000..5d594ad41b
--- /dev/null
+++ b/source4/lib/com/com.h
@@ -0,0 +1,52 @@
+/*
+ Unix SMB/CIFS implementation.
+ Utility functions for Samba
+ Copyright (C) Jelmer Vernooij 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 __SAMBA_COM_H__
+#define __SAMBA_COM_H__
+
+#include "librpc/gen_ndr/misc.h"
+
+struct com_context;
+struct event_context;
+
+struct com_context
+{
+ struct dcom_client_context *dcom;
+ struct event_context *event_ctx;
+ struct com_extension {
+ uint32_t id;
+ void *data;
+ struct com_extension *prev, *next;
+ } *extensions;
+ struct loadparm_context *lp_ctx;
+};
+
+struct IUnknown *com_class_by_clsid(struct com_context *ctx, const struct GUID *clsid);
+NTSTATUS com_register_running_class(struct GUID *clsid, const char *progid, struct IUnknown *p);
+
+struct dcom_interface_p *dcom_get_local_iface_p(struct GUID *ipid);
+
+WERROR com_init_ctx(struct com_context **ctx, struct event_context *event_ctx);
+WERROR com_create_object(struct com_context *ctx, struct GUID *clsid, int num_ifaces, struct GUID *iid, struct IUnknown **ip, WERROR *results);
+WERROR com_get_class_object(struct com_context *ctx, struct GUID *clsid, struct GUID *iid, struct IUnknown **ip);
+NTSTATUS com_init(void);
+
+typedef struct IUnknown *(*get_class_object_function) (const struct GUID *clsid);
+
+#endif /* __SAMBA_COM_H__ */
diff --git a/source4/lib/com/config.mk b/source4/lib/com/config.mk
new file mode 100644
index 0000000000..73836ef5f8
--- /dev/null
+++ b/source4/lib/com/config.mk
@@ -0,0 +1,22 @@
+[SUBSYSTEM::COM]
+PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG LIBEVENTS LIBNDR
+
+COM_OBJ_FILES = $(addprefix $(comsrcdir)/, tables.o rot.o main.o)
+
+[SUBSYSTEM::DCOM]
+PUBLIC_DEPENDENCIES = COM DCOM_PROXY_DCOM RPC_NDR_REMACT \
+ RPC_NDR_OXIDRESOLVER
+
+DCOM_OBJ_FILES = $(addprefix $(comsrcdir)/dcom/, main.o tables.o)
+
+[MODULE::com_simple]
+SUBSYSTEM = COM
+INIT_FUNCTION = com_simple_init
+
+com_simple_OBJ_FILES = $(comsrcdir)/classes/simple.o
+
+[PYTHON::pycom]
+LIBRARY_REALNAME = samba/com.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = COM
+
+pycom_OBJ_FILES = $(comsrcdir)/pycom.o
diff --git a/source4/lib/com/dcom/dcom.h b/source4/lib/com/dcom/dcom.h
new file mode 100644
index 0000000000..56d6eac93c
--- /dev/null
+++ b/source4/lib/com/dcom/dcom.h
@@ -0,0 +1,85 @@
+/*
+ Unix SMB/CIFS implementation.
+ COM standard objects
+ Copyright (C) Jelmer Vernooij 2004-2005.
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _DCOM_H /* _DCOM_H */
+#define _DCOM_H
+
+struct cli_credentials;
+struct dcerpc_pipe;
+
+#include "lib/com/com.h"
+#include "librpc/gen_ndr/orpc.h"
+
+struct dcom_client_context {
+ struct dcom_server_credentials {
+ const char *server;
+ struct cli_credentials *credentials;
+ struct dcom_server_credentials *prev, *next;
+ } *credentials;
+ struct dcom_object_exporter {
+ uint64_t oxid;
+ char *host;
+ struct IRemUnknown *rem_unknown;
+ struct DUALSTRINGARRAY *bindings;
+ struct dcerpc_pipe *pipe;
+ struct dcom_object_exporter *prev, *next;
+ } *object_exporters;
+};
+
+typedef enum ndr_err_code (*marshal_fn)(TALLOC_CTX *mem_ctx, struct IUnknown *pv, struct OBJREF *o);
+typedef enum ndr_err_code (*unmarshal_fn)(TALLOC_CTX *mem_ctx, struct OBJREF *o, struct IUnknown **pv);
+
+
+struct dcom_client_context *dcom_client_init(struct com_context *ctx, struct cli_credentials *credentials);
+struct dcom_object_exporter *object_exporter_by_oxid(struct com_context *ctx, uint64_t oxid);
+struct dcom_object_exporter *object_exporter_by_ip(struct com_context *ctx, struct IUnknown *ip);
+WERROR dcom_create_object(struct com_context *ctx, struct GUID *clsid, const char *server, int num_ifaces, struct GUID *iid, struct IUnknown ***ip, WERROR *results);
+WERROR dcom_get_class_object(struct com_context *ctx, struct GUID *clsid, const char *server, struct GUID *iid, struct IUnknown **ip);
+NTSTATUS dcom_get_pipe(struct IUnknown *iface, struct dcerpc_pipe **pp);
+NTSTATUS dcom_OBJREF_from_IUnknown(struct OBJREF *o, struct IUnknown *p);
+NTSTATUS dcom_IUnknown_from_OBJREF(TALLOC_CTX *mem_ctx, struct com_context *ctx, struct IUnknown **_p, struct OBJREF *o);
+uint64_t dcom_get_current_oxid(void);
+void dcom_add_server_credentials(struct com_context *ctx, const char *server, struct cli_credentials *credentials);
+WERROR dcom_query_interface(struct IUnknown *d, uint32_t cRefs, uint16_t cIids, struct GUID *iids, struct IUnknown **ip, WERROR *results);
+
+#include "librpc/gen_ndr/com_dcom.h"
+
+NTSTATUS dcom_register_proxy(struct IUnknown_vtable *proxy_vtable);
+struct IUnknown_vtable *dcom_proxy_vtable_by_iid(struct GUID *iid);
+NTSTATUS dcom_register_marshal(struct GUID *clsid, marshal_fn marshal, unmarshal_fn unmarshal);
+
+#include "libcli/composite/composite.h"
+void dcom_release_continue(struct composite_context *cr);
+#define IUnknown_ipid(d) ((d)->obj.u_objref.u_standard.std.ipid)
+struct composite_context *dcom_release_send(struct IUnknown *d, TALLOC_CTX *mem_ctx);
+marshal_fn dcom_marshal_by_clsid(struct GUID *clsid);
+unmarshal_fn dcom_unmarshal_by_clsid(struct GUID *clsid);
+
+struct dcom_proxy_async_call_state {
+ struct IUnknown *d;
+ const struct ndr_interface_table *table;
+ uint32_t opnum;
+ void (*continuation)(struct rpc_request *);
+ TALLOC_CTX *mem_ctx;
+ void *r;
+};
+
+
+#endif /* _DCOM_H */
diff --git a/source4/lib/com/dcom/main.c b/source4/lib/com/dcom/main.c
new file mode 100644
index 0000000000..695bfa7f98
--- /dev/null
+++ b/source4/lib/com/dcom/main.c
@@ -0,0 +1,710 @@
+/*
+ Unix SMB/CIFS implementation.
+ Main DCOM functionality
+ Copyright (C) 2004 Jelmer Vernooij <jelmer@samba.org>
+ Copyright (C) 2006 Andrzej Hajda <andrzej.hajda@wp.pl>
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "system/filesys.h"
+#include "librpc/gen_ndr/epmapper.h"
+#include "librpc/gen_ndr/ndr_remact_c.h"
+#include "librpc/gen_ndr/com_dcom.h"
+#include "librpc/gen_ndr/dcom.h"
+#include "librpc/rpc/dcerpc.h"
+#include "lib/com/dcom/dcom.h"
+#include "librpc/ndr/ndr_table.h"
+#include "../lib/util/dlinklist.h"
+#include "auth/credentials/credentials.h"
+#include "libcli/composite/composite.h"
+
+#define DCOM_NEGOTIATED_PROTOCOLS { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB, EPM_PROTOCOL_NCALRPC }
+
+static NTSTATUS dcerpc_binding_from_STRINGBINDING(TALLOC_CTX *mem_ctx, struct dcerpc_binding **b_out, struct STRINGBINDING *bd)
+{
+ char *host, *endpoint;
+ struct dcerpc_binding *b;
+
+ b = talloc_zero(mem_ctx, struct dcerpc_binding);
+ if (!b) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ b->transport = dcerpc_transport_by_endpoint_protocol(bd->wTowerId);
+
+ if (b->transport == -1) {
+ DEBUG(1, ("Can't find transport match endpoint protocol %d\n", bd->wTowerId));
+ talloc_free(b);
+ return NT_STATUS_NOT_SUPPORTED;
+ }
+
+ host = talloc_strdup(b, bd->NetworkAddr);
+ endpoint = strchr(host, '[');
+
+ if (endpoint) {
+ *endpoint = '\0';
+ endpoint++;
+
+ endpoint[strlen(endpoint)-1] = '\0';
+ }
+
+ b->host = host;
+ b->endpoint = talloc_strdup(b, endpoint);
+
+ *b_out = b;
+ return NT_STATUS_OK;
+}
+
+struct cli_credentials *dcom_get_server_credentials(struct com_context *ctx, const char *server)
+{
+ struct dcom_server_credentials *c;
+ struct cli_credentials *d;
+
+ d = NULL;
+ for (c = ctx->dcom->credentials; c; c = c->next) {
+ if (c->server == NULL) {
+ d = c->credentials;
+ continue;
+ }
+ if (server && !strcmp(c->server, server)) return c->credentials;
+ }
+ return d;
+}
+
+/**
+ * Register credentials for a specific server.
+ *
+ * @param ctx COM context
+ * @param server Name of server, can be NULL
+ * @param credentials Credentials object
+ */
+void dcom_add_server_credentials(struct com_context *ctx, const char *server,
+ struct cli_credentials *credentials)
+{
+ struct dcom_server_credentials *c;
+
+ /* FIXME: Don't use talloc_find_parent_bytype */
+ for (c = ctx->dcom->credentials; c; c = c->next) {
+ if ((server == NULL && c->server == NULL) ||
+ (server != NULL && c->server != NULL &&
+ !strcmp(c->server, server))) {
+ if (c->credentials && c->credentials != credentials) {
+ talloc_unlink(c, c->credentials);
+ c->credentials = credentials;
+ if (talloc_find_parent_bytype(c->credentials, struct dcom_server_credentials))
+ (void)talloc_reference(c, c->credentials);
+ else
+ talloc_steal(c, c->credentials);
+ }
+
+ return;
+ }
+ }
+
+ c = talloc(ctx->event_ctx, struct dcom_server_credentials);
+ c->server = talloc_strdup(c, server);
+ c->credentials = credentials;
+ if (talloc_find_parent_bytype(c->credentials, struct dcom_server_credentials))
+ (void)talloc_reference(c, c->credentials);
+ else
+ talloc_steal(c, c->credentials);
+
+ DLIST_ADD(ctx->dcom->credentials, c);
+}
+
+void dcom_update_credentials_for_aliases(struct com_context *ctx,
+ const char *server,
+ struct DUALSTRINGARRAY *pds)
+{
+ struct cli_credentials *cc;
+ struct dcerpc_binding *b;
+ uint32_t i;
+ NTSTATUS status;
+
+ cc = dcom_get_server_credentials(ctx, server);
+ for (i = 0; pds->stringbindings[i]; ++i) {
+ if (pds->stringbindings[i]->wTowerId != EPM_PROTOCOL_TCP)
+ continue;
+ status = dcerpc_binding_from_STRINGBINDING(ctx, &b, pds->stringbindings[i]);
+ if (!NT_STATUS_IS_OK(status))
+ continue;
+ dcom_add_server_credentials(ctx, b->host, cc);
+ talloc_free(b);
+ }
+}
+
+struct dcom_client_context *dcom_client_init(struct com_context *ctx, struct cli_credentials *credentials)
+{
+ ctx->dcom = talloc_zero(ctx, struct dcom_client_context);
+ if (!credentials) {
+ credentials = cli_credentials_init(ctx);
+ cli_credentials_set_conf(credentials, ctx->lp_ctx);
+ cli_credentials_parse_string(credentials, "%", CRED_SPECIFIED);
+ }
+ dcom_add_server_credentials(ctx, NULL, credentials);
+ return ctx->dcom;
+}
+
+static NTSTATUS dcom_connect_host(struct com_context *ctx,
+ struct dcerpc_pipe **p, const char *server)
+{
+ struct dcerpc_binding *bd;
+ const char * available_transports[] = { "ncacn_ip_tcp", "ncacn_np" };
+ int i;
+ NTSTATUS status;
+ TALLOC_CTX *loc_ctx;
+
+ if (server == NULL) {
+ return dcerpc_pipe_connect(ctx->event_ctx, p, "ncalrpc",
+ &ndr_table_IRemoteActivation,
+ dcom_get_server_credentials(ctx, NULL), ctx->event_ctx, ctx->lp_ctx);
+ }
+ loc_ctx = talloc_new(ctx);
+
+ /* Allow server name to contain a binding string */
+ if (strchr(server, ':') &&
+ NT_STATUS_IS_OK(dcerpc_parse_binding(loc_ctx, server, &bd))) {
+ if (DEBUGLVL(11))
+ bd->flags |= DCERPC_DEBUG_PRINT_BOTH;
+ status = dcerpc_pipe_connect_b(ctx->event_ctx, p, bd,
+ &ndr_table_IRemoteActivation,
+ dcom_get_server_credentials(ctx, bd->host), ctx->event_ctx, ctx->lp_ctx);
+ goto end;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(available_transports); i++)
+ {
+ char *binding = talloc_asprintf(loc_ctx, "%s:%s", available_transports[i], server);
+ if (!binding) {
+ status = NT_STATUS_NO_MEMORY;
+ goto end;
+ }
+ status = dcerpc_pipe_connect(ctx->event_ctx, p, binding,
+ &ndr_table_IRemoteActivation,
+ dcom_get_server_credentials(ctx, server),
+ ctx->event_ctx, ctx->lp_ctx);
+
+ if (NT_STATUS_IS_OK(status)) {
+ if (DEBUGLVL(11))
+ (*p)->conn->flags |= DCERPC_DEBUG_PRINT_BOTH;
+ goto end;
+ } else {
+ DEBUG(1,(__location__": dcom_connect_host : %s\n", get_friendly_nt_error_msg(status)));
+ }
+ }
+
+end:
+ talloc_free(loc_ctx);
+ return status;
+}
+
+struct dcom_object_exporter *object_exporter_by_oxid(struct com_context *ctx,
+ uint64_t oxid)
+{
+ struct dcom_object_exporter *ox;
+ for (ox = ctx->dcom->object_exporters; ox; ox = ox->next) {
+ if (ox->oxid == oxid) {
+ return ox;
+ }
+ }
+
+ return NULL;
+}
+
+struct dcom_object_exporter *object_exporter_update_oxid(struct com_context *ctx, uint64_t oxid, struct DUALSTRINGARRAY *bindings)
+{
+ struct dcom_object_exporter *ox;
+ ox = object_exporter_by_oxid(ctx, oxid);
+ if (!ox) {
+ ox = talloc_zero(ctx, struct dcom_object_exporter);
+ DLIST_ADD(ctx->dcom->object_exporters, ox);
+ ox->oxid = oxid;
+ } else {
+ talloc_free(ox->bindings);
+ }
+ ox->bindings = bindings;
+ talloc_steal(ox, bindings);
+ return ox;
+}
+
+struct dcom_object_exporter *object_exporter_by_ip(struct com_context *ctx, struct IUnknown *ip)
+{
+ return object_exporter_by_oxid(ctx, ip->obj.u_objref.u_standard.std.oxid);
+}
+
+WERROR dcom_create_object(struct com_context *ctx, struct GUID *clsid, const char *server, int num_ifaces, struct GUID *iid, struct IUnknown ***ip, WERROR *results)
+{
+ uint16_t protseq[] = DCOM_NEGOTIATED_PROTOCOLS;
+ struct dcerpc_pipe *p;
+ struct dcom_object_exporter *m;
+ NTSTATUS status;
+ struct RemoteActivation r;
+ struct DUALSTRINGARRAY *pds;
+ int i;
+ WERROR hr;
+ uint64_t oxid;
+ struct GUID ipidRemUnknown;
+ struct IUnknown *ru_template;
+ struct ORPCTHAT that;
+ uint32_t AuthnHint;
+ struct COMVERSION ServerVersion;
+ struct MInterfacePointer **ifaces;
+ TALLOC_CTX *loc_ctx;
+
+ status = dcom_connect_host(ctx, &p, server);
+ if (NT_STATUS_IS_ERR(status)) {
+ DEBUG(1, ("Unable to connect to %s - %s\n", server, get_friendly_nt_error_msg(status)));
+ return ntstatus_to_werror(status);
+ }
+ loc_ctx = talloc_new(ctx);
+
+ ifaces = talloc_array(loc_ctx, struct MInterfacePointer *, num_ifaces);
+
+ ZERO_STRUCT(r.in);
+ r.in.this.version.MajorVersion = COM_MAJOR_VERSION;
+ r.in.this.version.MinorVersion = COM_MINOR_VERSION;
+ r.in.this.cid = GUID_random();
+ r.in.Clsid = *clsid;
+ r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY;
+ r.in.num_protseqs = ARRAY_SIZE(protseq);
+ r.in.protseq = protseq;
+ r.in.Interfaces = num_ifaces;
+ r.in.pIIDs = iid;
+ r.out.that = &that;
+ r.out.pOxid = &oxid;
+ r.out.pdsaOxidBindings = &pds;
+ r.out.ipidRemUnknown = &ipidRemUnknown;
+ r.out.AuthnHint = &AuthnHint;
+ r.out.ServerVersion = &ServerVersion;
+ r.out.hr = &hr;
+ r.out.ifaces = ifaces;
+ r.out.results = results;
+
+ status = dcerpc_RemoteActivation(p, loc_ctx, &r);
+ talloc_free(p);
+
+ if(NT_STATUS_IS_ERR(status)) {
+ DEBUG(1, ("Error while running RemoteActivation %s\n", nt_errstr(status)));
+ hr = ntstatus_to_werror(status);
+ goto end;
+ }
+
+ if(!W_ERROR_IS_OK(r.out.result)) {
+ hr = r.out.result;
+ goto end;
+ }
+
+ if(!W_ERROR_IS_OK(hr)) {
+ goto end;
+ }
+
+ m = object_exporter_update_oxid(ctx, oxid, pds);
+
+ ru_template = NULL;
+ *ip = talloc_array(ctx, struct IUnknown *, num_ifaces);
+ for (i = 0; i < num_ifaces; i++) {
+ (*ip)[i] = NULL;
+ if (W_ERROR_IS_OK(results[i])) {
+ status = dcom_IUnknown_from_OBJREF(ctx, &(*ip)[i], &r.out.ifaces[i]->obj);
+ if (!NT_STATUS_IS_OK(status)) {
+ results[i] = ntstatus_to_werror(status);
+ } else if (!ru_template)
+ ru_template = (*ip)[i];
+ }
+ }
+
+ /* TODO:avg check when exactly oxid should be updated,its lifetime etc */
+ if (m->rem_unknown && memcmp(&m->rem_unknown->obj.u_objref.u_standard.std.ipid, &ipidRemUnknown, sizeof(ipidRemUnknown))) {
+ talloc_free(m->rem_unknown);
+ m->rem_unknown = NULL;
+ }
+ if (!m->rem_unknown) {
+ if (!ru_template) {
+ DEBUG(1,("dcom_create_object: Cannot Create IRemUnknown - template interface not available\n"));
+ hr = WERR_GENERAL_FAILURE;
+ }
+ m->rem_unknown = talloc_zero(m, struct IRemUnknown);
+ memcpy(m->rem_unknown, ru_template, sizeof(struct IUnknown));
+ GUID_from_string(COM_IREMUNKNOWN_UUID, &m->rem_unknown->obj.iid);
+ m->rem_unknown->obj.u_objref.u_standard.std.ipid = ipidRemUnknown;
+ m->rem_unknown->vtable = (struct IRemUnknown_vtable *)dcom_proxy_vtable_by_iid(&m->rem_unknown->obj.iid);
+ /* TODO:avg copy stringbindigs?? */
+ }
+
+ dcom_update_credentials_for_aliases(ctx, server, pds);
+ {
+ char *c;
+ c = strchr(server, '[');
+ if (m->host) talloc_free(m->host);
+ m->host = c ? talloc_strndup(m, server, c - server) : talloc_strdup(m, server);
+ }
+ hr = WERR_OK;
+end:
+ talloc_free(loc_ctx);
+ return hr;
+}
+
+int find_similar_binding(struct STRINGBINDING **sb, const char *host)
+{
+ int i, l;
+ l = strlen(host);
+ for (i = 0; sb[i]; ++i) {
+ if ((sb[i]->wTowerId == EPM_PROTOCOL_TCP) && !strncasecmp(host, sb[i]->NetworkAddr, l) && (sb[i]->NetworkAddr[l] == '['))
+ break;
+ }
+ return i;
+}
+
+WERROR dcom_query_interface(struct IUnknown *d, uint32_t cRefs, uint16_t cIids, struct GUID *iids, struct IUnknown **ip, WERROR *results)
+{
+ struct dcom_object_exporter *ox;
+ struct REMQIRESULT *rqir;
+ WERROR result;
+ NTSTATUS status;
+ int i;
+ TALLOC_CTX *loc_ctx;
+ struct IUnknown ru;
+
+ loc_ctx = talloc_new(d);
+ ox = object_exporter_by_ip(d->ctx, d);
+
+ result = IRemUnknown_RemQueryInterface(ox->rem_unknown, loc_ctx, &IUnknown_ipid(d), cRefs, cIids, iids, &rqir);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(1, ("dcom_query_interface failed: %08X\n", W_ERROR_V(result)));
+ talloc_free(loc_ctx);
+ return result;
+ }
+ ru = *(struct IUnknown *)ox->rem_unknown;
+ for (i = 0; i < cIids; ++i) {
+ ip[i] = NULL;
+ results[i] = rqir[i].hResult;
+ if (W_ERROR_IS_OK(results[i])) {
+ ru.obj.iid = iids[i];
+ ru.obj.u_objref.u_standard.std = rqir[i].std;
+ status = dcom_IUnknown_from_OBJREF(d->ctx, &ip[i], &ru.obj);
+ if (!NT_STATUS_IS_OK(status)) {
+ results[i] = ntstatus_to_werror(status);
+ }
+ }
+ }
+
+ talloc_free(loc_ctx);
+ return WERR_OK;
+}
+
+int is_ip_binding(const char* s)
+{
+ while (*s && (*s != '[')) {
+ if (((*s >= '0') && (*s <= '9')) || *s == '.')
+ ++s;
+ else
+ return 0;
+ }
+ return 1;
+}
+
+NTSTATUS dcom_get_pipe(struct IUnknown *iface, struct dcerpc_pipe **pp)
+{
+ struct dcerpc_binding *binding;
+ struct GUID iid;
+ uint64_t oxid;
+ NTSTATUS status;
+ int i, j, isimilar;
+ struct dcerpc_pipe *p;
+ struct dcom_object_exporter *ox;
+ const struct ndr_interface_table *table;
+
+ ox = object_exporter_by_oxid(iface->ctx, iface->obj.u_objref.u_standard.std.oxid);
+ if (!ox) {
+ DEBUG(0, ("dcom_get_pipe: OXID not found\n"));
+ return NT_STATUS_NOT_SUPPORTED;
+ }
+
+ p = ox->pipe;
+
+ iid = iface->vtable->iid;
+ table = ndr_table_by_uuid(&iid);
+ if (table == NULL) {
+ char *guid_str;
+ guid_str = GUID_string(NULL, &iid);
+ DEBUG(0,(__location__": dcom_get_pipe - unrecognized interface{%s}\n", guid_str));
+ talloc_free(guid_str);
+ return NT_STATUS_NOT_SUPPORTED;
+ }
+
+ if (p && p->last_fault_code) {
+ talloc_free(p);
+ ox->pipe = p = NULL;
+ }
+
+ if (p) {
+ if (!GUID_equal(&p->syntax.uuid, &iid)) {
+ ox->pipe->syntax.uuid = iid;
+
+ /* interface will always be present, so
+ * idl_iface_by_uuid can't return NULL */
+ /* status = dcerpc_secondary_context(p, &p2, idl_iface_by_uuid(&iid)); */
+ status = dcerpc_alter_context(p, p, &ndr_table_by_uuid(&iid)->syntax_id, &p->transfer_syntax);
+ } else
+ status = NT_STATUS_OK;
+ *pp = p;
+ return status;
+ }
+
+ status = NT_STATUS_NO_MORE_ENTRIES;
+
+ /* To avoid delays whe connecting nonroutable bindings we 1st check binding starting with hostname */
+ /* FIX:low create concurrent connections to all bindings, fastest wins - Win2k and newer does this way???? */
+ isimilar = find_similar_binding(ox->bindings->stringbindings, ox->host);
+ DEBUG(1, (__location__": dcom_get_pipe: host=%s, similar=%s\n", ox->host, ox->bindings->stringbindings[isimilar] ? ox->bindings->stringbindings[isimilar]->NetworkAddr : "None"));
+ j = isimilar - 1;
+ for (i = 0; ox->bindings->stringbindings[i]; ++i) {
+ if (!ox->bindings->stringbindings[++j]) j = 0;
+ /* FIXME:LOW Use also other transports if possible */
+ if ((j != isimilar) && (ox->bindings->stringbindings[j]->wTowerId != EPM_PROTOCOL_TCP || !is_ip_binding(ox->bindings->stringbindings[j]->NetworkAddr))) {
+ DEBUG(9, ("dcom_get_pipe: Skipping stringbinding %24.24s\n", ox->bindings->stringbindings[j]->NetworkAddr));
+ continue;
+ }
+ DEBUG(9, ("dcom_get_pipe: Trying stringbinding %s\n", ox->bindings->stringbindings[j]->NetworkAddr));
+ status = dcerpc_binding_from_STRINGBINDING(iface->ctx, &binding,
+ ox->bindings->stringbindings[j]);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("Error parsing string binding"));
+ } else {
+ /* FIXME:LOW Make flags more flexible */
+ binding->flags |= DCERPC_AUTH_NTLM | DCERPC_SIGN;
+ if (DEBUGLVL(11))
+ binding->flags |= DCERPC_DEBUG_PRINT_BOTH;
+ status = dcerpc_pipe_connect_b(iface->ctx->event_ctx, &p, binding,
+ ndr_table_by_uuid(&iid),
+ dcom_get_server_credentials(iface->ctx, binding->host),
+ iface->ctx->event_ctx, iface->ctx->lp_ctx);
+ talloc_unlink(iface->ctx, binding);
+ }
+ if (NT_STATUS_IS_OK(status)) break;
+ }
+
+ if (NT_STATUS_IS_ERR(status)) {
+ DEBUG(0, ("Unable to connect to remote host - %s\n", nt_errstr(status)));
+ return status;
+ }
+
+ DEBUG(2, ("Successfully connected to OXID %llx\n", (long long)oxid));
+
+ ox->pipe = *pp = p;
+
+ return NT_STATUS_OK;
+}
+
+NTSTATUS dcom_OBJREF_from_IUnknown(TALLLOC_CTX *mem_ctx, struct OBJREF *o, struct IUnknown *p)
+{
+ /* FIXME: Cache generated objref objects? */
+ ZERO_STRUCTP(o);
+
+ if (!p) {
+ o->signature = OBJREF_SIGNATURE;
+ o->flags = OBJREF_NULL;
+ } else {
+ *o = p->obj;
+ switch(o->flags) {
+ case OBJREF_CUSTOM: {
+ marshal_fn marshal;
+
+ marshal = dcom_marshal_by_clsid(&o->u_objref.u_custom.clsid);
+ if (marshal) {
+ return marshal(mem_ctx, p, o);
+ } else {
+ return NT_STATUS_NOT_SUPPORTED;
+ }
+ }
+ }
+ }
+
+ return NT_STATUS_OK;
+}
+
+enum ndr_err_code dcom_IUnknown_from_OBJREF(struct com_context *ctx, struct IUnknown **_p, struct OBJREF *o)
+{
+ struct IUnknown *p;
+ struct dcom_object_exporter *ox;
+ unmarshal_fn unmarshal;
+
+ switch(o->flags) {
+ case OBJREF_NULL:
+ *_p = NULL;
+ return NDR_ERR_SUCCESS;
+
+ case OBJREF_STANDARD:
+ p = talloc_zero(ctx, struct IUnknown);
+ p->ctx = ctx;
+ p->obj = *o;
+ p->vtable = dcom_proxy_vtable_by_iid(&o->iid);
+
+ if (!p->vtable) {
+ DEBUG(0, ("Unable to find proxy class for interface with IID %s\n", GUID_string(ctx, &o->iid)));
+ return NDR_ERR_INVALID_POINTER;
+ }
+
+ p->vtable->Release_send = dcom_release_send;
+
+ ox = object_exporter_by_oxid(ctx, o->u_objref.u_standard.std.oxid);
+ /* FIXME: Add object to list of objects to ping */
+ *_p = p;
+ return NDR_ERR_SUCCESS;
+
+ case OBJREF_HANDLER:
+ p = talloc_zero(ctx, struct IUnknown);
+ p->ctx = ctx;
+ p->obj = *o;
+ ox = object_exporter_by_oxid(ctx, o->u_objref.u_handler.std.oxid );
+ /* FIXME: Add object to list of objects to ping */
+/*FIXME p->vtable = dcom_vtable_by_clsid(&o->u_objref.u_handler.clsid);*/
+ /* FIXME: Do the custom unmarshaling call */
+
+ *_p = p;
+ return NDR_ERR_BAD_SWITCH;
+
+ case OBJREF_CUSTOM:
+ p = talloc_zero(ctx, struct IUnknown);
+ p->ctx = ctx;
+ p->vtable = NULL;
+ p->obj = *o;
+ unmarshal = dcom_unmarshal_by_clsid(&o->u_objref.u_custom.clsid);
+ *_p = p;
+ if (unmarshal) {
+ return unmarshal(ctx, o, _p);
+ } else {
+ return NDR_ERR_BAD_SWITCH;
+ }
+ }
+
+ return NDR_ERR_BAD_SWITCH;
+}
+
+uint64_t dcom_get_current_oxid(void)
+{
+ return getpid();
+}
+
+/* FIXME:Fake async dcom_get_pipe_* */
+struct composite_context *dcom_get_pipe_send(struct IUnknown *d, TALLOC_CTX *mem_ctx)
+{
+ struct composite_context *c;
+
+ c = composite_create(0, d->ctx->event_ctx);
+ if (c == NULL) return NULL;
+ c->private_data = d;
+ /* composite_done(c); bugged - callback is triggered twice by composite_continue and composite_done */
+ c->state = COMPOSITE_STATE_DONE; /* this is workaround */
+
+ return c;
+}
+
+NTSTATUS dcom_get_pipe_recv(struct composite_context *c, struct dcerpc_pipe **pp)
+{
+ NTSTATUS status;
+
+ status = dcom_get_pipe((struct IUnknown *)c->private_data, pp);
+ talloc_free(c);
+
+ return status;
+}
+
+/* FIXME:avg put IUnknown_Release_out into header */
+struct IUnknown_Release_out {
+ uint32_t result;
+};
+
+void dcom_release_continue(struct composite_context *cr)
+{
+ struct composite_context *c;
+ struct IUnknown *d;
+ struct IUnknown_Release_out *out;
+ WERROR r;
+
+ c = talloc_get_type(cr->async.private_data, struct composite_context);
+ d = c->private_data;
+ r = IRemUnknown_RemRelease_recv(cr);
+ talloc_free(d);
+ out = talloc_zero(c, struct IUnknown_Release_out);
+ out->result = W_ERROR_V(r);
+ c->private_data = out;
+ composite_done(c);
+}
+
+struct composite_context *dcom_release_send(struct IUnknown *d, TALLOC_CTX *mem_ctx)
+{
+ struct composite_context *c, *cr;
+ struct REMINTERFACEREF iref;
+ struct dcom_object_exporter *ox;
+
+ c = composite_create(d->ctx, d->ctx->event_ctx);
+ if (c == NULL) return NULL;
+ c->private_data = d;
+
+ ox = object_exporter_by_ip(d->ctx, d);
+ iref.ipid = IUnknown_ipid(d);
+ iref.cPublicRefs = 5;
+ iref.cPrivateRefs = 0;
+ cr = IRemUnknown_RemRelease_send(ox->rem_unknown, mem_ctx, 1, &iref);
+
+ composite_continue(c, cr, dcom_release_continue, c);
+ return c;
+}
+
+uint32_t dcom_release_recv(struct composite_context *c)
+{
+ NTSTATUS status;
+ WERROR r;
+
+ status = composite_wait(c);
+ if (!NT_STATUS_IS_OK(status))
+ r = ntstatus_to_werror(status);
+ else
+ W_ERROR_V(r) = ((struct IUnknown_Release_out *)c->private_data)->result;
+ talloc_free(c);
+ return W_ERROR_IS_OK(r) ? 0 : W_ERROR_V(r);
+}
+
+uint32_t dcom_release(void *interface, TALLOC_CTX *mem_ctx)
+{
+ struct composite_context *c;
+
+ c = dcom_release_send(interface, mem_ctx);
+ return dcom_release_recv(c);
+}
+
+void dcom_proxy_async_call_recv_pipe_send_rpc(struct composite_context *c_pipe)
+{
+ struct composite_context *c;
+ struct dcom_proxy_async_call_state *s;
+ struct dcerpc_pipe *p;
+ struct rpc_request *req;
+ NTSTATUS status;
+
+ c = c_pipe->async.private_data;
+ s = talloc_get_type(c->private_data, struct dcom_proxy_async_call_state);
+
+ status = dcom_get_pipe_recv(c_pipe, &p);
+ if (!NT_STATUS_IS_OK(status)) {
+ composite_error(c, NT_STATUS_RPC_NT_CALL_FAILED);
+ return;
+ }
+
+ req = dcerpc_ndr_request_send(p, &s->d->obj.u_objref.u_standard.std.ipid, s->table, s->opnum, s, s->r);
+ composite_continue_rpc(c, req, s->continuation, c);
+}
diff --git a/source4/lib/com/dcom/tables.c b/source4/lib/com/dcom/tables.c
new file mode 100644
index 0000000000..f94aa87925
--- /dev/null
+++ b/source4/lib/com/dcom/tables.c
@@ -0,0 +1,92 @@
+/*
+ Unix SMB/CIFS implementation.
+ DCOM proxy tables functionality
+ Copyright (C) 2005 Jelmer Vernooij <jelmer@samba.org>
+ Copyright (C) 2006 Andrzej Hajda <andrzej.hajda@wp.pl>
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "../lib/util/dlinklist.h"
+#include "librpc/gen_ndr/com_dcom.h"
+#include "lib/com/dcom/dcom.h"
+
+static struct dcom_proxy {
+ struct IUnknown_vtable *vtable;
+ struct dcom_proxy *prev, *next;
+} *proxies = NULL;
+
+NTSTATUS dcom_register_proxy(struct IUnknown_vtable *proxy_vtable)
+{
+ struct dcom_proxy *proxy = talloc(talloc_autofree_context(), struct dcom_proxy);
+
+ proxy->vtable = proxy_vtable;
+ DLIST_ADD(proxies, proxy);
+
+ return NT_STATUS_OK;
+}
+
+struct IUnknown_vtable *dcom_proxy_vtable_by_iid(struct GUID *iid)
+{
+ struct dcom_proxy *p;
+ for (p = proxies; p; p = p->next) {
+ if (GUID_equal(&p->vtable->iid, iid)) {
+ return p->vtable;
+ }
+ }
+ return NULL;
+}
+
+static struct dcom_marshal {
+ struct GUID clsid;
+ marshal_fn marshal;
+ unmarshal_fn unmarshal;
+ struct dcom_marshal *prev, *next;
+} *marshals = NULL;
+
+NTSTATUS dcom_register_marshal(struct GUID *clsid, marshal_fn marshal, unmarshal_fn unmarshal)
+{
+ struct dcom_marshal *p = talloc(talloc_autofree_context(), struct dcom_marshal);
+
+ p->clsid = *clsid;
+ p->marshal = marshal;
+ p->unmarshal = unmarshal;
+ DLIST_ADD(marshals, p);
+ return NT_STATUS_OK;
+}
+
+_PUBLIC_ marshal_fn dcom_marshal_by_clsid(struct GUID *clsid)
+{
+ struct dcom_marshal *p;
+ for (p = marshals; p; p = p->next) {
+ if (GUID_equal(&p->clsid, clsid)) {
+ return p->marshal;
+ }
+ }
+ return NULL;
+}
+
+_PUBLIC_ unmarshal_fn dcom_unmarshal_by_clsid(struct GUID *clsid)
+{
+ struct dcom_marshal *p;
+ for (p = marshals; p; p = p->next) {
+ if (GUID_equal(&p->clsid, clsid)) {
+ return p->unmarshal;
+ }
+ }
+ return NULL;
+}
+
diff --git a/source4/lib/com/main.c b/source4/lib/com/main.c
new file mode 100644
index 0000000000..daed8c11e5
--- /dev/null
+++ b/source4/lib/com/main.c
@@ -0,0 +1,90 @@
+/*
+ Unix SMB/CIFS implementation.
+ Main COM functionality
+ Copyright (C) 2004 Jelmer Vernooij <jelmer@samba.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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "../lib/util/dlinklist.h"
+#include "lib/com/com.h"
+#include "lib/events/events.h"
+#include "librpc/gen_ndr/com_dcom.h"
+
+WERROR com_init_ctx(struct com_context **ctx, struct event_context *event_ctx)
+{
+ *ctx = talloc(NULL, struct com_context);
+ if (event_ctx == NULL) {
+ event_ctx = event_context_init(*ctx);
+ }
+ (*ctx)->event_ctx = event_ctx;
+ return WERR_OK;
+}
+
+WERROR com_create_object(struct com_context *ctx, struct GUID *clsid, int num_ifaces, struct GUID *iid, struct IUnknown **ip, WERROR *results)
+{
+ struct IUnknown *iunk = NULL;
+ struct IClassFactory *factory;
+ WERROR error;
+ int i;
+ struct GUID classfact_iid;
+
+ GUID_from_string(NDR_ICLASSFACTORY_UUID, &classfact_iid);
+
+ /* Obtain class object */
+ error = com_get_class_object(ctx, clsid, &classfact_iid, (struct IUnknown **)&factory);
+ if (!W_ERROR_IS_OK(error)) {
+ DEBUG(3, ("Unable to obtain class object for %s\n", GUID_string(NULL, clsid)));
+ return error;
+ }
+
+ /* Run IClassFactory::CreateInstance() */
+ error = IClassFactory_CreateInstance(factory, ctx, NULL, &classfact_iid, &iunk);
+ if (!W_ERROR_IS_OK(error)) {
+ DEBUG(3, ("Error while calling IClassFactory::CreateInstance : %s\n", win_errstr(error)));
+ return error;
+ }
+
+ if (!iunk) {
+ DEBUG(0, ("IClassFactory_CreateInstance returned success but result pointer is still NULL!\n"));
+ return WERR_GENERAL_FAILURE;
+ }
+
+ /* Release class object */
+ IUnknown_Release(factory, ctx);
+
+ error = WERR_OK;
+
+ /* Do one or more QueryInterface calls */
+ for (i = 0; i < num_ifaces; i++) {
+ results[i] = IUnknown_QueryInterface(iunk, ctx, &iid[i], &ip[i]);
+ if (!W_ERROR_IS_OK(results[i])) error = results[i];
+ }
+
+ return error;
+}
+
+WERROR com_get_class_object(struct com_context *ctx, struct GUID *clsid, struct GUID *iid, struct IUnknown **ip)
+{
+ struct IUnknown *iu;
+
+ iu = com_class_by_clsid(ctx, clsid);
+ if (!iu) {
+ return WERR_CLASS_NOT_REGISTERED;
+ }
+
+ return IUnknown_QueryInterface(iu, ctx, iid, ip);
+}
diff --git a/source4/lib/com/pycom.c b/source4/lib/com/pycom.c
new file mode 100644
index 0000000000..9222be438d
--- /dev/null
+++ b/source4/lib/com/pycom.c
@@ -0,0 +1,81 @@
+/*
+ Unix SMB/CIFS implementation.
+ Python bindings for COM library.
+ Copyright (C) Jelmer Vernooij <jelmer@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 "includes.h"
+#include <Python.h>
+#include "lib/com/com.h"
+#include "librpc/ndr/libndr.h"
+#include "libcli/util/pyerrors.h"
+
+static struct com_context *py_com_ctx = NULL; /* FIXME: evil global */
+
+static PyObject *py_get_class_object(PyObject *self, PyObject *args)
+{
+ char *s_clsid, *s_iid;
+ struct GUID clsid, iid;
+ struct IUnknown *object;
+ NTSTATUS status;
+ WERROR error;
+
+ if (!PyArg_ParseTuple(args, "ss", &s_clsid, &s_iid))
+ return NULL;
+
+ status = GUID_from_string(s_clsid, &clsid);
+ if (!NT_STATUS_IS_OK(status)) {
+ PyErr_FromNTSTATUS(status);
+ return NULL;
+ }
+
+ status = GUID_from_string(s_iid, &iid);
+ if (!NT_STATUS_IS_OK(status)) {
+ PyErr_FromNTSTATUS(status);
+ return NULL;
+ }
+
+ error = com_get_class_object(py_com_ctx, &clsid, &iid, &object);
+ if (!W_ERROR_IS_OK(error)) {
+ PyErr_FromWERROR(error);
+ return NULL;
+ }
+
+ /* FIXME: Magic, integrate with stubs generated by pidl. */
+
+ return Py_None;
+}
+
+static struct PyMethodDef com_methods[] = {
+ { "get_class_object", (PyCFunction)py_get_class_object, METH_VARARGS, "S.get_class_object(clsid, iid) -> instance" },
+ { NULL },
+};
+
+void initcom(void)
+{
+ PyObject *m;
+ WERROR error;
+
+ error = com_init_ctx(&py_com_ctx, NULL);
+ if (!W_ERROR_IS_OK(error)) {
+ PyErr_FromWERROR(error);
+ return;
+ }
+
+ m = Py_InitModule3("com", com_methods, "Simple COM implementation");
+ if (m == NULL)
+ return;
+}
diff --git a/source4/lib/com/rot.c b/source4/lib/com/rot.c
new file mode 100644
index 0000000000..0180a92f1b
--- /dev/null
+++ b/source4/lib/com/rot.c
@@ -0,0 +1,35 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Running object table functions
+
+ Copyright (C) Jelmer Vernooij 2004-2005
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "lib/com/com.h"
+
+struct dcom_interface_p *dcom_get_local_iface_p(struct GUID *ipid)
+{
+ /* FIXME: Call the local ROT and do a
+ * rot_get_interface_pointer call */
+
+ /* FIXME: Perhaps have a local (thread-local) table with
+ * local DCOM objects so that not every DCOM call requires a lookup
+ * to the ROT? */
+ return NULL;
+}
diff --git a/source4/lib/com/tables.c b/source4/lib/com/tables.c
new file mode 100644
index 0000000000..ed21da7cd8
--- /dev/null
+++ b/source4/lib/com/tables.c
@@ -0,0 +1,109 @@
+/*
+ Unix SMB/CIFS implementation.
+ COM class tables
+ Copyright (C) 2004 Jelmer Vernooij <jelmer@samba.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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "../lib/util/dlinklist.h"
+#include "lib/com/com.h"
+#include "librpc/gen_ndr/ndr_misc.h"
+
+/* Specific implementation of one or more interfaces */
+struct com_class
+{
+ const char *progid;
+ struct GUID clsid;
+
+ struct IUnknown *class_object;
+ struct com_class *prev, *next;
+} * running_classes = NULL;
+
+static struct IUnknown *get_com_class_running(const struct GUID *clsid)
+{
+ struct com_class *c = running_classes;
+
+ while(c) {
+
+ if (GUID_equal(clsid, &c->clsid)) {
+ return c->class_object;
+ }
+
+ c = c->next;
+ }
+
+ return NULL;
+}
+
+static struct IUnknown *get_com_class_so(TALLOC_CTX *mem_ctx, const struct GUID *clsid)
+{
+ char *mod_name;
+ char *clsid_str;
+ void *mod;
+ get_class_object_function f;
+
+ clsid_str = GUID_string(mem_ctx, clsid);
+ mod_name = talloc_asprintf(mem_ctx, "%s.so", clsid_str);
+ talloc_free(clsid_str);
+
+ mod = dlopen(mod_name, 0);
+
+ if (!mod) {
+ return NULL;
+ }
+
+ f = dlsym(mod, "get_class_object");
+
+ if (!f) {
+ return NULL;
+ }
+
+ return f(clsid);
+}
+
+struct IUnknown *com_class_by_clsid(struct com_context *ctx, const struct GUID *clsid)
+{
+ struct IUnknown *c;
+
+ /* Check list of running COM classes first */
+ c = get_com_class_running(clsid);
+
+ if (c != NULL) {
+ return c;
+ }
+
+ c = get_com_class_so(ctx, clsid);
+
+ if (c != NULL) {
+ return c;
+ }
+
+ return NULL;
+}
+
+NTSTATUS com_register_running_class(struct GUID *clsid, const char *progid, struct IUnknown *p)
+{
+ struct com_class *l = talloc_zero(running_classes?running_classes:talloc_autofree_context(), struct com_class);
+
+ l->clsid = *clsid;
+ l->progid = talloc_strdup(l, progid);
+ l->class_object = p;
+
+ DLIST_ADD(running_classes, l);
+
+ return NT_STATUS_OK;
+}
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/crypto/arcfour.c b/source4/lib/crypto/arcfour.c
deleted file mode 100644
index 94196fa1ee..0000000000
--- a/source4/lib/crypto/arcfour.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- An implementation of the arcfour algorithm
-
- Copyright (C) Andrew Tridgell 1998
-
- 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/crypto/crypto.h"
-
-/* initialise the arcfour sbox with key */
-_PUBLIC_ void arcfour_init(struct arcfour_state *state, const DATA_BLOB *key)
-{
- int ind;
- uint8_t j = 0;
- for (ind = 0; ind < sizeof(state->sbox); ind++) {
- state->sbox[ind] = (uint8_t)ind;
- }
-
- for (ind = 0; ind < sizeof(state->sbox); ind++) {
- uint8_t tc;
-
- j += (state->sbox[ind] + key->data[ind%key->length]);
-
- tc = state->sbox[ind];
- state->sbox[ind] = state->sbox[j];
- state->sbox[j] = tc;
- }
- state->index_i = 0;
- state->index_j = 0;
-}
-
-/* crypt the data with arcfour */
-_PUBLIC_ void arcfour_crypt_sbox(struct arcfour_state *state, uint8_t *data, int len)
-{
- int ind;
-
- for (ind = 0; ind < len; ind++) {
- uint8_t tc;
- uint8_t t;
-
- state->index_i++;
- state->index_j += state->sbox[state->index_i];
-
- tc = state->sbox[state->index_i];
- state->sbox[state->index_i] = state->sbox[state->index_j];
- state->sbox[state->index_j] = tc;
-
- t = state->sbox[state->index_i] + state->sbox[state->index_j];
- data[ind] = data[ind] ^ state->sbox[t];
- }
-}
-
-/*
- arcfour encryption with a blob key
-*/
-_PUBLIC_ void arcfour_crypt_blob(uint8_t *data, int len, const DATA_BLOB *key)
-{
- struct arcfour_state state;
- arcfour_init(&state, key);
- arcfour_crypt_sbox(&state, data, len);
-}
-
-/*
- a variant that assumes a 16 byte key. This should be removed
- when the last user is gone
-*/
-_PUBLIC_ void arcfour_crypt(uint8_t *data, const uint8_t keystr[16], int len)
-{
- DATA_BLOB key = data_blob(keystr, 16);
-
- arcfour_crypt_blob(data, len, &key);
-
- data_blob_free(&key);
-}
-
-
diff --git a/source4/lib/crypto/config.mk b/source4/lib/crypto/config.mk
deleted file mode 100644
index ee111bd088..0000000000
--- a/source4/lib/crypto/config.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-##############################
-# Start SUBSYSTEM LIBCRYPTO
-[SUBSYSTEM::LIBCRYPTO]
-# End SUBSYSTEM LIBCRYPTO
-##############################
-
-LIBCRYPTO_OBJ_FILES = $(addprefix $(libcryptosrcdir)/, \
- crc32.o md5.o hmacmd5.o md4.o \
- arcfour.o sha256.o hmacsha256.o)
-
-[MODULE::TORTURE_LIBCRYPTO]
-SUBSYSTEM = smbtorture
-PRIVATE_DEPENDENCIES = LIBCRYPTO
-
-TORTURE_LIBCRYPTO_OBJ_FILES = $(addprefix $(libcryptosrcdir)/, \
- md4test.o md5test.o hmacmd5test.o)
-
-$(eval $(call proto_header_template,$(libcryptosrcdir)/test_proto.h,$(TORTURE_LIBCRYPTO_OBJ_FILES:.o=.c)))
diff --git a/source4/lib/crypto/crc32.c b/source4/lib/crypto/crc32.c
deleted file mode 100644
index 5b9d9b108d..0000000000
--- a/source4/lib/crypto/crc32.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*-
- * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
- * code or tables extracted from it, as desired without restriction.
- *
- * First, the polynomial itself and its table of feedback terms. The
- * polynomial is
- * X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0
- *
- * Note that we take it "backwards" and put the highest-order term in
- * the lowest-order bit. The X^32 term is "implied"; the LSB is the
- * X^31 term, etc. The X^0 term (usually shown as "+1") results in
- * the MSB being 1
- *
- * Note that the usual hardware shift register implementation, which
- * is what we're using (we're merely optimizing it by doing eight-bit
- * chunks at a time) shifts bits into the lowest-order term. In our
- * implementation, that means shifting towards the right. Why do we
- * do it this way? Because the calculated CRC must be transmitted in
- * order from highest-order term to lowest-order term. UARTs transmit
- * characters in order from LSB to MSB. By storing the CRC this way
- * we hand it to the UART in the order low-byte to high-byte; the UART
- * sends each low-bit to hight-bit; and the result is transmission bit
- * by bit from highest- to lowest-order term without requiring any bit
- * shuffling on our part. Reception works similarly
- *
- * The feedback terms table consists of 256, 32-bit entries. Notes
- *
- * The table can be generated at runtime if desired; code to do so
- * is shown later. It might not be obvious, but the feedback
- * terms simply represent the results of eight shift/xor opera
- * tions for all combinations of data and CRC register values
- *
- * The values must be right-shifted by eight bits by the "updcrc
- * logic; the shift must be unsigned (bring in zeroes). On some
- * hardware you could probably optimize the shift in assembler by
- * using byte-swap instructions
- * polynomial $edb88320
- *
- *
- * CRC32 code derived from work by Gary S. Brown.
- */
-
-#include "includes.h"
-
-static const uint32_t crc32_tab[] = {
- 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
- 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
- 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
- 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
- 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
- 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
- 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
- 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
- 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
- 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
- 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
- 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
- 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
- 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
- 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
- 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
- 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
- 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
- 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
- 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
- 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
- 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
- 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
- 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
- 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
- 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
- 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
- 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
- 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
- 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
- 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
- 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
- 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
- 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
- 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
- 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
- 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
- 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
- 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
- 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
- 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
- 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
- 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
-};
-
-uint32_t crc32_calc_buffer(const uint8_t *buf, size_t size)
-{
- const uint8_t *p;
- uint32_t crc;
-
- p = buf;
- crc = ~0U;
-
- while (size--)
- crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8);
-
- return crc ^ ~0U;
-}
diff --git a/source4/lib/crypto/crc32.h b/source4/lib/crypto/crc32.h
deleted file mode 100644
index 7854abf865..0000000000
--- a/source4/lib/crypto/crc32.h
+++ /dev/null
@@ -1 +0,0 @@
-uint32_t crc32_calc_buffer(const uint8_t *buf, size_t size);
diff --git a/source4/lib/crypto/crypto.h b/source4/lib/crypto/crypto.h
deleted file mode 100644
index fc283f72ba..0000000000
--- a/source4/lib/crypto/crypto.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Copyright (C) Andrew Tridgell 2004
-
- 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 "lib/crypto/crc32.h"
-#include "lib/crypto/md4.h"
-#include "lib/crypto/md5.h"
-#include "lib/crypto/hmacmd5.h"
-#include "lib/crypto/sha256.h"
-#include "lib/crypto/hmacsha256.h"
-
-struct arcfour_state {
- uint8_t sbox[256];
- uint8_t index_i;
- uint8_t index_j;
-};
-
-void arcfour_init(struct arcfour_state *state, const DATA_BLOB *key);
-void arcfour_crypt_sbox(struct arcfour_state *state, uint8_t *data, int len);
-void arcfour_crypt_blob(uint8_t *data, int len, const DATA_BLOB *key);
-void arcfour_crypt(uint8_t *data, const uint8_t keystr[16], int len);
-
diff --git a/source4/lib/crypto/hmacmd5.c b/source4/lib/crypto/hmacmd5.c
deleted file mode 100644
index 3a9ec38a27..0000000000
--- a/source4/lib/crypto/hmacmd5.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- HMAC MD5 code for use in NTLMv2
- Copyright (C) Luke Kenneth Casson Leighton 1996-2000
- Copyright (C) Andrew Tridgell 1992-2000
-
- 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/>.
-*/
-
-/* taken direct from rfc2104 implementation and modified for suitable use
- * for ntlmv2.
- */
-
-#include "includes.h"
-#include "lib/crypto/crypto.h"
-
-/***********************************************************************
- the rfc 2104 version of hmac_md5 initialisation.
-***********************************************************************/
-_PUBLIC_ void hmac_md5_init_rfc2104(const uint8_t *key, int key_len, HMACMD5Context *ctx)
-{
- int i;
- uint8_t tk[16];
-
- /* if key is longer than 64 bytes reset it to key=MD5(key) */
- if (key_len > 64)
- {
- struct MD5Context tctx;
-
- MD5Init(&tctx);
- MD5Update(&tctx, key, key_len);
- MD5Final(tk, &tctx);
-
- key = tk;
- key_len = 16;
- }
-
- /* start out by storing key in pads */
- ZERO_STRUCT(ctx->k_ipad);
- ZERO_STRUCT(ctx->k_opad);
- memcpy( ctx->k_ipad, key, key_len);
- memcpy( ctx->k_opad, key, key_len);
-
- /* XOR key with ipad and opad values */
- for (i=0; i<64; i++)
- {
- ctx->k_ipad[i] ^= 0x36;
- ctx->k_opad[i] ^= 0x5c;
- }
-
- MD5Init(&ctx->ctx);
- MD5Update(&ctx->ctx, ctx->k_ipad, 64);
-}
-
-/***********************************************************************
- the microsoft version of hmac_md5 initialisation.
-***********************************************************************/
-_PUBLIC_ void hmac_md5_init_limK_to_64(const uint8_t *key, int key_len,
- HMACMD5Context *ctx)
-{
- /* if key is longer than 64 bytes truncate it */
- if (key_len > 64)
- {
- key_len = 64;
- }
-
- hmac_md5_init_rfc2104(key, key_len, ctx);
-}
-
-/***********************************************************************
- update hmac_md5 "inner" buffer
-***********************************************************************/
-_PUBLIC_ void hmac_md5_update(const uint8_t *text, int text_len, HMACMD5Context *ctx)
-{
- MD5Update(&ctx->ctx, text, text_len); /* then text of datagram */
-}
-
-/***********************************************************************
- finish off hmac_md5 "inner" buffer and generate outer one.
-***********************************************************************/
-_PUBLIC_ void hmac_md5_final(uint8_t *digest, HMACMD5Context *ctx)
-{
- struct MD5Context ctx_o;
-
- MD5Final(digest, &ctx->ctx);
-
- MD5Init(&ctx_o);
- MD5Update(&ctx_o, ctx->k_opad, 64);
- MD5Update(&ctx_o, digest, 16);
- MD5Final(digest, &ctx_o);
-}
-
-/***********************************************************
- single function to calculate an HMAC MD5 digest from data.
- use the microsoft hmacmd5 init method because the key is 16 bytes.
-************************************************************/
-_PUBLIC_ void hmac_md5(const uint8_t key[16], const uint8_t *data, int data_len, uint8_t *digest)
-{
- HMACMD5Context ctx;
- hmac_md5_init_limK_to_64(key, 16, &ctx);
- if (data_len != 0)
- {
- hmac_md5_update(data, data_len, &ctx);
- }
- hmac_md5_final(digest, &ctx);
-}
diff --git a/source4/lib/crypto/hmacmd5.h b/source4/lib/crypto/hmacmd5.h
deleted file mode 100644
index 5769737fcd..0000000000
--- a/source4/lib/crypto/hmacmd5.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Interface header: HMAC MD5 code
- Copyright (C) Luke Kenneth Casson Leighton 1996-1999
- Copyright (C) Andrew Tridgell 1992-1999
-
- 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 _HMAC_MD5_H
-
-typedef struct
-{
- struct MD5Context ctx;
- uint8_t k_ipad[65];
- uint8_t k_opad[65];
-
-} HMACMD5Context;
-
-void hmac_md5_init_limK_to_64(const uint8_t *key, int key_len,
- HMACMD5Context *ctx);
-void hmac_md5_update(const uint8_t *text, int text_len, HMACMD5Context *ctx);
-void hmac_md5_final(uint8_t *digest, HMACMD5Context *ctx);
-void hmac_md5(const uint8_t key[16], const uint8_t *data, int data_len, uint8_t *digest);
-void hmac_md5_init_rfc2104(const uint8_t *key, int key_len, HMACMD5Context *ctx);
-
-#endif /* _HMAC_MD5_H */
diff --git a/source4/lib/crypto/hmacmd5test.c b/source4/lib/crypto/hmacmd5test.c
deleted file mode 100644
index 07ed54c98d..0000000000
--- a/source4/lib/crypto/hmacmd5test.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- HMAC MD5 tests
- Copyright (C) Stefan Metzmacher 2006
-
- 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/crypto/crypto.h"
-
-struct torture_context;
-
-static DATA_BLOB data_blob_repeat_byte(uint8_t byte, size_t length)
-{
- DATA_BLOB b = data_blob(NULL, length);
- memset(b.data, byte, length);
- return b;
-}
-
-/*
- This uses the test values from rfc 2104, 2202
-*/
-bool torture_local_crypto_hmacmd5(struct torture_context *torture)
-{
- bool ret = true;
- uint32_t i;
- struct {
- DATA_BLOB key;
- DATA_BLOB data;
- DATA_BLOB md5;
- } testarray[8];
-
- testarray[0].key = data_blob_repeat_byte(0x0b, 16);
- testarray[0].data = data_blob_string_const("Hi There");
- testarray[0].md5 = strhex_to_data_blob("9294727a3638bb1c13f48ef8158bfc9d");
-
- testarray[1].key = data_blob_string_const("Jefe");
- testarray[1].data = data_blob_string_const("what do ya want for nothing?");
- testarray[1].md5 = strhex_to_data_blob("750c783e6ab0b503eaa86e310a5db738");
-
- testarray[2].key = data_blob_repeat_byte(0xaa, 16);
- testarray[2].data = data_blob_repeat_byte(0xdd, 50);
- testarray[2].md5 = strhex_to_data_blob("56be34521d144c88dbb8c733f0e8b3f6");
-
- testarray[3].key = strhex_to_data_blob("0102030405060708090a0b0c0d0e0f10111213141516171819");
- testarray[3].data = data_blob_repeat_byte(0xcd, 50);
- testarray[3].md5 = strhex_to_data_blob("697eaf0aca3a3aea3a75164746ffaa79");
-
- testarray[4].key = data_blob_repeat_byte(0x0c, 16);
- testarray[4].data = data_blob_string_const("Test With Truncation");
- testarray[4].md5 = strhex_to_data_blob("56461ef2342edc00f9bab995690efd4c");
-
- testarray[5].key = data_blob_repeat_byte(0xaa, 80);
- testarray[5].data = data_blob_string_const("Test Using Larger Than Block-Size Key - Hash Key First");
- testarray[5].md5 = strhex_to_data_blob("6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd");
-
- testarray[6].key = data_blob_repeat_byte(0xaa, 80);
- testarray[6].data = data_blob_string_const("Test Using Larger Than Block-Size Key "
- "and Larger Than One Block-Size Data");
- testarray[6].md5 = strhex_to_data_blob("6f630fad67cda0ee1fb1f562db3aa53e");
-
- testarray[7].key = data_blob(NULL, 0);
-
- for (i=0; testarray[i].key.data; i++) {
- HMACMD5Context ctx;
- uint8_t md5[16];
- int e;
-
- hmac_md5_init_rfc2104(testarray[i].key.data, testarray[i].key.length, &ctx);
- hmac_md5_update(testarray[i].data.data, testarray[i].data.length, &ctx);
- hmac_md5_final(md5, &ctx);
-
- e = memcmp(testarray[i].md5.data,
- md5,
- MIN(testarray[i].md5.length, sizeof(md5)));
- if (e != 0) {
- printf("hmacmd5 test[%u]: failed\n", i);
- dump_data(0, testarray[i].key.data, testarray[i].key.length);
- dump_data(0, testarray[i].data.data, testarray[i].data.length);
- dump_data(0, testarray[i].md5.data, testarray[i].md5.length);
- dump_data(0, md5, sizeof(md5));
- ret = false;
- }
- }
-
- return ret;
-}
diff --git a/source4/lib/crypto/hmacsha256.c b/source4/lib/crypto/hmacsha256.c
deleted file mode 100644
index 6b0af9ee83..0000000000
--- a/source4/lib/crypto/hmacsha256.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Interface header: HMAC SHA-256 code
-
- Copyright (C) Andrew Tridgell 2008
-
- based in hmacsha1.c which is:
- Copyright (C) Stefan Metzmacher
-
- 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/>.
-*/
-
-/*
- taken direct from rfc2202 implementation and modified for suitable use
- */
-
-#include "includes.h"
-#include "lib/crypto/crypto.h"
-
-/***********************************************************************
- the rfc 2104/2202 version of hmac_sha256 initialisation.
-***********************************************************************/
-_PUBLIC_ void hmac_sha256_init(const uint8_t *key, size_t key_len, struct HMACSHA256Context *ctx)
-{
- int i;
- uint8_t tk[SHA256_DIGEST_LENGTH];
-
- /* if key is longer than 64 bytes reset it to key=HASH(key) */
- if (key_len > 64)
- {
- SHA256_CTX tctx;
-
- SHA256_Init(&tctx);
- SHA256_Update(&tctx, key, key_len);
- SHA256_Final(tk, &tctx);
-
- key = tk;
- key_len = SHA256_DIGEST_LENGTH;
- }
-
- /* start out by storing key in pads */
- ZERO_STRUCT(ctx->k_ipad);
- ZERO_STRUCT(ctx->k_opad);
- memcpy( ctx->k_ipad, key, key_len);
- memcpy( ctx->k_opad, key, key_len);
-
- /* XOR key with ipad and opad values */
- for (i=0; i<64; i++)
- {
- ctx->k_ipad[i] ^= 0x36;
- ctx->k_opad[i] ^= 0x5c;
- }
-
- SHA256_Init(&ctx->ctx);
- SHA256_Update(&ctx->ctx, ctx->k_ipad, 64);
-}
-
-/***********************************************************************
- update hmac_sha256 "inner" buffer
-***********************************************************************/
-_PUBLIC_ void hmac_sha256_update(const uint8_t *data, size_t data_len, struct HMACSHA256Context *ctx)
-{
- SHA256_Update(&ctx->ctx, data, data_len); /* then text of datagram */
-}
-
-/***********************************************************************
- finish off hmac_sha256 "inner" buffer and generate outer one.
-***********************************************************************/
-_PUBLIC_ void hmac_sha256_final(uint8_t digest[SHA256_DIGEST_LENGTH], struct HMACSHA256Context *ctx)
-{
- SHA256_CTX ctx_o;
-
- SHA256_Final(digest, &ctx->ctx);
-
- SHA256_Init(&ctx_o);
- SHA256_Update(&ctx_o, ctx->k_opad, 64);
- SHA256_Update(&ctx_o, digest, SHA256_DIGEST_LENGTH);
- SHA256_Final(digest, &ctx_o);
-}
diff --git a/source4/lib/crypto/hmacsha256.h b/source4/lib/crypto/hmacsha256.h
deleted file mode 100644
index 8960c636c1..0000000000
--- a/source4/lib/crypto/hmacsha256.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Interface header: HMAC SHA256 code
-
- Copyright (C) Andrew Tridgell 2008
-
- based on hmacsha1.h which is:
-
- Copyright (C) Stefan Metzmacher 2006
-
- 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 _HMAC_SHA256_H
-
-struct HMACSHA256Context {
- SHA256_CTX ctx;
- uint8_t k_ipad[65];
- uint8_t k_opad[65];
-};
-
-void hmac_sha256_init(const uint8_t *key, size_t key_len, struct HMACSHA256Context *ctx);
-void hmac_sha256_update(const uint8_t *data, size_t data_len, struct HMACSHA256Context *ctx);
-void hmac_sha256_final(uint8_t digest[20], struct HMACSHA256Context *ctx);
-
-#endif /* _HMAC_SHA256_H */
diff --git a/source4/lib/crypto/md4.c b/source4/lib/crypto/md4.c
deleted file mode 100644
index 7ad93ce786..0000000000
--- a/source4/lib/crypto/md4.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- a implementation of MD4 designed for use in the SMB authentication protocol
- Copyright (C) Andrew Tridgell 1997-1998.
-
- 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"
-
-/* NOTE: This code makes no attempt to be fast!
-
- It assumes that a int is at least 32 bits long
-*/
-
-struct mdfour_state {
- uint32_t A, B, C, D;
-};
-
-static uint32_t F(uint32_t X, uint32_t Y, uint32_t Z)
-{
- return (X&Y) | ((~X)&Z);
-}
-
-static uint32_t G(uint32_t X, uint32_t Y, uint32_t Z)
-{
- return (X&Y) | (X&Z) | (Y&Z);
-}
-
-static uint32_t H(uint32_t X, uint32_t Y, uint32_t Z)
-{
- return X^Y^Z;
-}
-
-static uint32_t lshift(uint32_t x, int s)
-{
- x &= 0xFFFFFFFF;
- return ((x<<s)&0xFFFFFFFF) | (x>>(32-s));
-}
-
-#define ROUND1(a,b,c,d,k,s) a = lshift(a + F(b,c,d) + X[k], s)
-#define ROUND2(a,b,c,d,k,s) a = lshift(a + G(b,c,d) + X[k] + (uint32_t)0x5A827999,s)
-#define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + (uint32_t)0x6ED9EBA1,s)
-
-/* this applies md4 to 64 byte chunks */
-static void mdfour64(struct mdfour_state *s, uint32_t *M)
-{
- int j;
- uint32_t AA, BB, CC, DD;
- uint32_t X[16];
-
- for (j=0;j<16;j++)
- X[j] = M[j];
-
- AA = s->A; BB = s->B; CC = s->C; DD = s->D;
-
- ROUND1(s->A,s->B,s->C,s->D, 0, 3); ROUND1(s->D,s->A,s->B,s->C, 1, 7);
- ROUND1(s->C,s->D,s->A,s->B, 2, 11); ROUND1(s->B,s->C,s->D,s->A, 3, 19);
- ROUND1(s->A,s->B,s->C,s->D, 4, 3); ROUND1(s->D,s->A,s->B,s->C, 5, 7);
- ROUND1(s->C,s->D,s->A,s->B, 6, 11); ROUND1(s->B,s->C,s->D,s->A, 7, 19);
- ROUND1(s->A,s->B,s->C,s->D, 8, 3); ROUND1(s->D,s->A,s->B,s->C, 9, 7);
- ROUND1(s->C,s->D,s->A,s->B, 10, 11); ROUND1(s->B,s->C,s->D,s->A, 11, 19);
- ROUND1(s->A,s->B,s->C,s->D, 12, 3); ROUND1(s->D,s->A,s->B,s->C, 13, 7);
- ROUND1(s->C,s->D,s->A,s->B, 14, 11); ROUND1(s->B,s->C,s->D,s->A, 15, 19);
-
- ROUND2(s->A,s->B,s->C,s->D, 0, 3); ROUND2(s->D,s->A,s->B,s->C, 4, 5);
- ROUND2(s->C,s->D,s->A,s->B, 8, 9); ROUND2(s->B,s->C,s->D,s->A, 12, 13);
- ROUND2(s->A,s->B,s->C,s->D, 1, 3); ROUND2(s->D,s->A,s->B,s->C, 5, 5);
- ROUND2(s->C,s->D,s->A,s->B, 9, 9); ROUND2(s->B,s->C,s->D,s->A, 13, 13);
- ROUND2(s->A,s->B,s->C,s->D, 2, 3); ROUND2(s->D,s->A,s->B,s->C, 6, 5);
- ROUND2(s->C,s->D,s->A,s->B, 10, 9); ROUND2(s->B,s->C,s->D,s->A, 14, 13);
- ROUND2(s->A,s->B,s->C,s->D, 3, 3); ROUND2(s->D,s->A,s->B,s->C, 7, 5);
- ROUND2(s->C,s->D,s->A,s->B, 11, 9); ROUND2(s->B,s->C,s->D,s->A, 15, 13);
-
- ROUND3(s->A,s->B,s->C,s->D, 0, 3); ROUND3(s->D,s->A,s->B,s->C, 8, 9);
- ROUND3(s->C,s->D,s->A,s->B, 4, 11); ROUND3(s->B,s->C,s->D,s->A, 12, 15);
- ROUND3(s->A,s->B,s->C,s->D, 2, 3); ROUND3(s->D,s->A,s->B,s->C, 10, 9);
- ROUND3(s->C,s->D,s->A,s->B, 6, 11); ROUND3(s->B,s->C,s->D,s->A, 14, 15);
- ROUND3(s->A,s->B,s->C,s->D, 1, 3); ROUND3(s->D,s->A,s->B,s->C, 9, 9);
- ROUND3(s->C,s->D,s->A,s->B, 5, 11); ROUND3(s->B,s->C,s->D,s->A, 13, 15);
- ROUND3(s->A,s->B,s->C,s->D, 3, 3); ROUND3(s->D,s->A,s->B,s->C, 11, 9);
- ROUND3(s->C,s->D,s->A,s->B, 7, 11); ROUND3(s->B,s->C,s->D,s->A, 15, 15);
-
- s->A += AA;
- s->B += BB;
- s->C += CC;
- s->D += DD;
-
- s->A &= 0xFFFFFFFF;
- s->B &= 0xFFFFFFFF;
- s->C &= 0xFFFFFFFF;
- s->D &= 0xFFFFFFFF;
-
- for (j=0;j<16;j++)
- X[j] = 0;
-}
-
-static void copy64(uint32_t *M, const uint8_t *in)
-{
- int i;
-
- for (i=0;i<16;i++)
- M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) |
- (in[i*4+1]<<8) | (in[i*4+0]<<0);
-}
-
-static void copy4(uint8_t *out, uint32_t x)
-{
- out[0] = x&0xFF;
- out[1] = (x>>8)&0xFF;
- out[2] = (x>>16)&0xFF;
- out[3] = (x>>24)&0xFF;
-}
-
-/**
- * produce a md4 message digest from data of length n bytes
- */
-_PUBLIC_ void mdfour(uint8_t *out, const uint8_t *in, int n)
-{
- uint8_t buf[128];
- uint32_t M[16];
- uint32_t b = n * 8;
- int i;
- struct mdfour_state state;
-
- state.A = 0x67452301;
- state.B = 0xefcdab89;
- state.C = 0x98badcfe;
- state.D = 0x10325476;
-
- while (n > 64) {
- copy64(M, in);
- mdfour64(&state, M);
- in += 64;
- n -= 64;
- }
-
- for (i=0;i<128;i++)
- buf[i] = 0;
- memcpy(buf, in, n);
- buf[n] = 0x80;
-
- if (n <= 55) {
- copy4(buf+56, b);
- copy64(M, buf);
- mdfour64(&state, M);
- } else {
- copy4(buf+120, b);
- copy64(M, buf);
- mdfour64(&state, M);
- copy64(M, buf+64);
- mdfour64(&state, M);
- }
-
- for (i=0;i<128;i++)
- buf[i] = 0;
- copy64(M, buf);
-
- copy4(out, state.A);
- copy4(out+4, state.B);
- copy4(out+8, state.C);
- copy4(out+12, state.D);
-}
-
-
diff --git a/source4/lib/crypto/md4.h b/source4/lib/crypto/md4.h
deleted file mode 100644
index 234e488e4f..0000000000
--- a/source4/lib/crypto/md4.h
+++ /dev/null
@@ -1 +0,0 @@
-void mdfour(uint8_t *out, const uint8_t *in, int n);
diff --git a/source4/lib/crypto/md4test.c b/source4/lib/crypto/md4test.c
deleted file mode 100644
index 5e0451973c..0000000000
--- a/source4/lib/crypto/md4test.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- MD4 tests
- Copyright (C) Stefan Metzmacher 2006
-
- 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/crypto/crypto.h"
-
-struct torture_context;
-
-/*
- This uses the test values from rfc1320
-*/
-bool torture_local_crypto_md4(struct torture_context *torture)
-{
- bool ret = true;
- uint32_t i;
- struct {
- const char *data;
- const char *md4;
- } testarray[] = {
- {
- .data = "",
- .md4 = "31d6cfe0d16ae931b73c59d7e0c089c0"
- },{
- .data = "a",
- .md4 = "bde52cb31de33e46245e05fbdbd6fb24"
- },{
- .data = "abc",
- .md4 = "a448017aaf21d8525fc10ae87aa6729d"
- },{
- .data = "message digest",
- .md4 = "d9130a8164549fe818874806e1c7014b"
- },{
- .data = "abcdefghijklmnopqrstuvwxyz",
- .md4 = "d79e1c308aa5bbcdeea8ed63df412da9"
- },{
- .data = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
- .md4 = "043f8582f241db351ce627e153e7f0e4"
- },{
- .data = "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
- .md4 = "e33b4ddc9c38f2199c3e7b164fcc0536"
- }
- };
-
- for (i=0; i < ARRAY_SIZE(testarray); i++) {
- uint8_t md4[16];
- int e;
- DATA_BLOB data;
- DATA_BLOB md4blob;
-
- data = data_blob_string_const(testarray[i].data);
- md4blob = strhex_to_data_blob(testarray[i].md4);
-
- mdfour(md4, data.data, data.length);
-
- e = memcmp(md4blob.data, md4, MIN(md4blob.length, sizeof(md4)));
- if (e != 0) {
- printf("md4 test[%u]: failed\n", i);
- dump_data(0, data.data, data.length);
- dump_data(0, md4blob.data, md4blob.length);
- dump_data(0, md4, sizeof(md4));
- ret = false;
- }
- talloc_free(md4blob.data);
- }
-
- return ret;
-}
diff --git a/source4/lib/crypto/md5.c b/source4/lib/crypto/md5.c
deleted file mode 100644
index 584c46ef2d..0000000000
--- a/source4/lib/crypto/md5.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * This code implements the MD5 message-digest algorithm.
- * The algorithm is due to Ron Rivest. This code was
- * written by Colin Plumb in 1993, no copyright is claimed.
- * This code is in the public domain; do with it what you wish.
- *
- * Equivalent code is available from RSA Data Security, Inc.
- * This code has been tested against that, and is equivalent,
- * except that you don't need to include two pages of legalese
- * with every copy.
- *
- * To compute the message digest of a chunk of bytes, declare an
- * MD5Context structure, pass it to MD5Init, call MD5Update as
- * needed on buffers full of bytes, and then call MD5Final, which
- * will fill a supplied 16-byte array with the digest.
- */
-
-/* This code slightly modified to fit into Samba by
- abartlet@samba.org Jun 2001 */
-
-#include "includes.h"
-
-#include "md5.h"
-
-
-static void MD5Transform(uint32_t buf[4], uint32_t const in[16]);
-
-/*
- * Note: this code is harmless on little-endian machines.
- */
-static void byteReverse(uint8_t *buf, uint_t longs)
-{
- uint32_t t;
- do {
- t = (uint32_t) ((uint_t) buf[3] << 8 | buf[2]) << 16 |
- ((uint_t) buf[1] << 8 | buf[0]);
- *(uint32_t *) buf = t;
- buf += 4;
- } while (--longs);
-}
-
-/*
- * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
- * initialization constants.
- */
-_PUBLIC_ void MD5Init(struct MD5Context *ctx)
-{
- ctx->buf[0] = 0x67452301;
- ctx->buf[1] = 0xefcdab89;
- ctx->buf[2] = 0x98badcfe;
- ctx->buf[3] = 0x10325476;
-
- ctx->bits[0] = 0;
- ctx->bits[1] = 0;
-}
-
-/*
- * Update context to reflect the concatenation of another buffer full
- * of bytes.
- */
-_PUBLIC_ void MD5Update(struct MD5Context *ctx, const uint8_t *buf, size_t len)
-{
- register uint32_t t;
-
- /* Update bitcount */
-
- t = ctx->bits[0];
- if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
- ctx->bits[1]++; /* Carry from low to high */
- ctx->bits[1] += len >> 29;
-
- t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
-
- /* Handle any leading odd-sized chunks */
-
- if (t) {
- uint8_t *p = (uint8_t *) ctx->in + t;
-
- t = 64 - t;
- if (len < t) {
- memmove(p, buf, len);
- return;
- }
- memmove(p, buf, t);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32_t *) ctx->in);
- buf += t;
- len -= t;
- }
- /* Process data in 64-byte chunks */
-
- while (len >= 64) {
- memmove(ctx->in, buf, 64);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32_t *) ctx->in);
- buf += 64;
- len -= 64;
- }
-
- /* Handle any remaining bytes of data. */
-
- memmove(ctx->in, buf, len);
-}
-
-/*
- * Final wrapup - pad to 64-byte boundary with the bit pattern
- * 1 0* (64-bit count of bits processed, MSB-first)
- */
-_PUBLIC_ void MD5Final(uint8_t digest[16], struct MD5Context *ctx)
-{
- uint_t count;
- uint8_t *p;
-
- /* Compute number of bytes mod 64 */
- count = (ctx->bits[0] >> 3) & 0x3F;
-
- /* Set the first char of padding to 0x80. This is safe since there is
- always at least one byte free */
- p = ctx->in + count;
- *p++ = 0x80;
-
- /* Bytes of padding needed to make 64 bytes */
- count = 64 - 1 - count;
-
- /* Pad out to 56 mod 64 */
- if (count < 8) {
- /* Two lots of padding: Pad the first block to 64 bytes */
- memset(p, 0, count);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32_t *) ctx->in);
-
- /* Now fill the next block with 56 bytes */
- memset(ctx->in, 0, 56);
- } else {
- /* Pad block to 56 bytes */
- memset(p, 0, count - 8);
- }
- byteReverse(ctx->in, 14);
-
- /* Append length in bits and transform */
- ((uint32_t *) ctx->in)[14] = ctx->bits[0];
- ((uint32_t *) ctx->in)[15] = ctx->bits[1];
-
- MD5Transform(ctx->buf, (uint32_t *) ctx->in);
- byteReverse((uint8_t *) ctx->buf, 4);
- memmove(digest, ctx->buf, 16);
- memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
-}
-
-/* The four core functions - F1 is optimized somewhat */
-
-/* #define F1(x, y, z) (x & y | ~x & z) */
-#define F1(x, y, z) (z ^ (x & (y ^ z)))
-#define F2(x, y, z) F1(z, x, y)
-#define F3(x, y, z) (x ^ y ^ z)
-#define F4(x, y, z) (y ^ (x | ~z))
-
-/* This is the central step in the MD5 algorithm. */
-#define MD5STEP(f, w, x, y, z, data, s) \
- ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
-
-/*
- * The core of the MD5 algorithm, this alters an existing MD5 hash to
- * reflect the addition of 16 longwords of new data. MD5Update blocks
- * the data and converts bytes into longwords for this routine.
- */
-static void MD5Transform(uint32_t buf[4], uint32_t const in[16])
-{
- register uint32_t a, b, c, d;
-
- a = buf[0];
- b = buf[1];
- c = buf[2];
- d = buf[3];
-
- MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
- MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
- MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
- MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
- MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
- MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
- MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
- MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
- MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
- MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
- MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
- MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
- MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
- MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
- MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
- MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
- MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
- MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
- MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
- MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
- MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
- MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
- MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
- MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
- MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
- MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
- MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
- MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
- MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
- MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
- MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
- MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
- MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
- MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
- MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
- MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
- MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
- MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
- MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
- MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
- MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
- MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
- MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
- MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
- MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
- MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
- MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
- MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
- MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
- MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
- MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
- MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
- MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
- MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
- MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
- MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
- MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
- MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
- MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
- MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
- MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
- MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
- MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
- MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
-
- buf[0] += a;
- buf[1] += b;
- buf[2] += c;
- buf[3] += d;
-}
diff --git a/source4/lib/crypto/md5.h b/source4/lib/crypto/md5.h
deleted file mode 100644
index 4064d6f003..0000000000
--- a/source4/lib/crypto/md5.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef MD5_H
-#define MD5_H
-#ifndef HEADER_MD5_H
-/* Try to avoid clashes with OpenSSL */
-#define HEADER_MD5_H
-#endif
-
-struct MD5Context {
- uint32_t buf[4];
- uint32_t bits[2];
- uint8_t in[64];
-};
-
-void MD5Init(struct MD5Context *context);
-void MD5Update(struct MD5Context *context, const uint8_t *buf,
- size_t len);
-void MD5Final(uint8_t digest[16], struct MD5Context *context);
-
-#endif /* !MD5_H */
diff --git a/source4/lib/crypto/md5test.c b/source4/lib/crypto/md5test.c
deleted file mode 100644
index 702e0fcf41..0000000000
--- a/source4/lib/crypto/md5test.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- MD5 tests
- Copyright (C) Stefan Metzmacher
-
- 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/crypto/crypto.h"
-
-struct torture_context;
-
-/*
- This uses the test values from rfc1321
-*/
-bool torture_local_crypto_md5(struct torture_context *torture)
-{
- bool ret = true;
- uint32_t i;
- struct {
- const char *data;
- const char *md5;
- } testarray[] = {
- {
- .data = "",
- .md5 = "d41d8cd98f00b204e9800998ecf8427e"
- },{
- .data = "a",
- .md5 = "0cc175b9c0f1b6a831c399e269772661"
- },{
- .data = "abc",
- .md5 = "900150983cd24fb0d6963f7d28e17f72"
- },{
- .data = "message digest",
- .md5 = "f96b697d7cb7938d525a2f31aaf161d0"
- },{
- .data = "abcdefghijklmnopqrstuvwxyz",
- .md5 = "c3fcd3d76192e4007dfb496cca67e13b"
- },{
- .data = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "0123456789",
- .md5 = "d174ab98d277d9f5a5611c2c9f419d9f"
- },{
- .data = "123456789012345678901234567890"
- "123456789012345678901234567890"
- "12345678901234567890",
- .md5 = "57edf4a22be3c955ac49da2e2107b67a"
- }
- };
-
- for (i=0; i < ARRAY_SIZE(testarray); i++) {
- struct MD5Context ctx;
- uint8_t md5[16];
- int e;
-
- DATA_BLOB data;
- DATA_BLOB md5blob;
-
- data = data_blob_string_const(testarray[i].data);
- md5blob = strhex_to_data_blob(testarray[i].md5);
-
- MD5Init(&ctx);
- MD5Update(&ctx, data.data, data.length);
- MD5Final(md5, &ctx);
-
- e = memcmp(md5blob.data,
- md5,
- MIN(md5blob.length, sizeof(md5)));
- if (e != 0) {
- printf("md5 test[%u]: failed\n", i);
- dump_data(0, data.data, data.length);
- dump_data(0, md5blob.data, md5blob.length);
- dump_data(0, md5, sizeof(md5));
- ret = false;
- }
- talloc_free(md5blob.data);
- }
-
- return ret;
-}
diff --git a/source4/lib/crypto/sha256.c b/source4/lib/crypto/sha256.c
deleted file mode 100644
index a2def25814..0000000000
--- a/source4/lib/crypto/sha256.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- based on heildal lib/hcrypto/sha256.c. Copied to lib/crypto to avoid a link
- problem. Hopefully will be removed once we solve this link problem
-
- (tridge)
- */
-
-/*
- * Copyright (c) 2006 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.
- */
-
-#include "includes.h"
-#include "sha256.h"
-
-#define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z)))
-#define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
-
-#define ROTR(x,n) (((x)>>(n)) | ((x) << (32 - (n))))
-
-#define Sigma0(x) (ROTR(x,2) ^ ROTR(x,13) ^ ROTR(x,22))
-#define Sigma1(x) (ROTR(x,6) ^ ROTR(x,11) ^ ROTR(x,25))
-#define sigma0(x) (ROTR(x,7) ^ ROTR(x,18) ^ ((x)>>3))
-#define sigma1(x) (ROTR(x,17) ^ ROTR(x,19) ^ ((x)>>10))
-
-#define A m->counter[0]
-#define B m->counter[1]
-#define C m->counter[2]
-#define D m->counter[3]
-#define E m->counter[4]
-#define F m->counter[5]
-#define G m->counter[6]
-#define H m->counter[7]
-
-static const uint32_t constant_256[64] = {
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
- 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
- 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
- 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
- 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
- 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
- 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
- 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
- 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
-};
-
-void
-SHA256_Init (SHA256_CTX *m)
-{
- m->sz[0] = 0;
- m->sz[1] = 0;
- A = 0x6a09e667;
- B = 0xbb67ae85;
- C = 0x3c6ef372;
- D = 0xa54ff53a;
- E = 0x510e527f;
- F = 0x9b05688c;
- G = 0x1f83d9ab;
- H = 0x5be0cd19;
-}
-
-static void
-calc (SHA256_CTX *m, uint32_t *in)
-{
- uint32_t AA, BB, CC, DD, EE, FF, GG, HH;
- uint32_t data[64];
- int i;
-
- AA = A;
- BB = B;
- CC = C;
- DD = D;
- EE = E;
- FF = F;
- GG = G;
- HH = H;
-
- for (i = 0; i < 16; ++i)
- data[i] = in[i];
- for (i = 16; i < 64; ++i)
- data[i] = sigma1(data[i-2]) + data[i-7] +
- sigma0(data[i-15]) + data[i - 16];
-
- for (i = 0; i < 64; i++) {
- uint32_t T1, T2;
-
- T1 = HH + Sigma1(EE) + Ch(EE, FF, GG) + constant_256[i] + data[i];
- T2 = Sigma0(AA) + Maj(AA,BB,CC);
-
- HH = GG;
- GG = FF;
- FF = EE;
- EE = DD + T1;
- DD = CC;
- CC = BB;
- BB = AA;
- AA = T1 + T2;
- }
-
- A += AA;
- B += BB;
- C += CC;
- D += DD;
- E += EE;
- F += FF;
- G += GG;
- H += HH;
-}
-
-/*
- * From `Performance analysis of MD5' by Joseph D. Touch <touch@isi.edu>
- */
-
-#if !defined(WORDS_BIGENDIAN) || defined(_CRAY)
-/* Vector Crays doesn't have a good 32-bit type, or more precisely,
- int32_t as defined by <bind/bitypes.h> isn't 32 bits, and we don't
- want to depend in being able to redefine this type. To cope with
- this we have to clamp the result in some places to [0,2^32); no
- need to do this on other machines. Did I say this was a mess?
- */
-
-#ifdef _CRAY
-#define CRAYFIX(X) ((X) & 0xffffffff)
-#else
-#define CRAYFIX(X) (X)
-#endif
-
-static inline uint32_t
-cshift (uint32_t x, unsigned int n)
-{
- x = CRAYFIX(x);
- return CRAYFIX((x << n) | (x >> (32 - n)));
-}
-
-static inline uint32_t
-swap_uint32_t (uint32_t t)
-{
- uint32_t temp1, temp2;
-
- temp1 = cshift(t, 16);
- temp2 = temp1 >> 8;
- temp1 &= 0x00ff00ff;
- temp2 &= 0x00ff00ff;
- temp1 <<= 8;
- return temp1 | temp2;
-}
-#endif
-
-struct x32{
- unsigned int a:32;
- unsigned int b:32;
-};
-
-void
-SHA256_Update (SHA256_CTX *m, const void *v, size_t len)
-{
- const unsigned char *p = v;
- size_t old_sz = m->sz[0];
- size_t offset;
-
- m->sz[0] += len * 8;
- if (m->sz[0] < old_sz)
- ++m->sz[1];
- offset = (old_sz / 8) % 64;
- while(len > 0){
- size_t l = MIN(len, 64 - offset);
- memcpy(m->save + offset, p, l);
- offset += l;
- p += l;
- len -= l;
- if(offset == 64){
-#if !defined(WORDS_BIGENDIAN) || defined(_CRAY)
- int i;
- uint32_t current[16];
- struct x32 *u = (struct x32*)m->save;
- for(i = 0; i < 8; i++){
- current[2*i+0] = swap_uint32_t(u[i].a);
- current[2*i+1] = swap_uint32_t(u[i].b);
- }
- calc(m, current);
-#else
- calc(m, (uint32_t*)m->save);
-#endif
- offset = 0;
- }
- }
-}
-
-void
-SHA256_Final (void *res, SHA256_CTX *m)
-{
- unsigned char zeros[72];
- unsigned offset = (m->sz[0] / 8) % 64;
- unsigned int dstart = (120 - offset - 1) % 64 + 1;
-
- *zeros = 0x80;
- memset (zeros + 1, 0, sizeof(zeros) - 1);
- zeros[dstart+7] = (m->sz[0] >> 0) & 0xff;
- zeros[dstart+6] = (m->sz[0] >> 8) & 0xff;
- zeros[dstart+5] = (m->sz[0] >> 16) & 0xff;
- zeros[dstart+4] = (m->sz[0] >> 24) & 0xff;
- zeros[dstart+3] = (m->sz[1] >> 0) & 0xff;
- zeros[dstart+2] = (m->sz[1] >> 8) & 0xff;
- zeros[dstart+1] = (m->sz[1] >> 16) & 0xff;
- zeros[dstart+0] = (m->sz[1] >> 24) & 0xff;
- SHA256_Update (m, zeros, dstart + 8);
- {
- int i;
- unsigned char *r = (unsigned char*)res;
-
- for (i = 0; i < 8; ++i) {
- r[4*i+3] = m->counter[i] & 0xFF;
- r[4*i+2] = (m->counter[i] >> 8) & 0xFF;
- r[4*i+1] = (m->counter[i] >> 16) & 0xFF;
- r[4*i] = (m->counter[i] >> 24) & 0xFF;
- }
- }
-}
diff --git a/source4/lib/crypto/sha256.h b/source4/lib/crypto/sha256.h
deleted file mode 100644
index 4a5f2cbe94..0000000000
--- a/source4/lib/crypto/sha256.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 1995 - 2001 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.
- */
-
-/* $Id: sha.h 17450 2006-05-05 11:11:43Z lha $ */
-
-#ifndef HEIM_SHA_H
-/*
- based on heildal lib/hcrypto/sha.h. Copied to lib/crypto to avoid a link
- problem. Hopefully will be removed once we solve this link problem
-
- (tridge)
- */
-#define HEIM_SHA_H 1
-
-#if 0
-/* symbol renaming */
-#define SHA1_Init hc_SHA1_Init
-#define SHA1_Update hc_SHA1_Update
-#define SHA1_Final hc_SHA1_Final
-#define SHA256_Init hc_SHA256_Init
-#define SHA256_Update hc_SHA256_Update
-#define SHA256_Final hc_SHA256_Final
-#endif
-
-/*
- * SHA-1
- */
-
-#define SHA_DIGEST_LENGTH 20
-
-struct sha {
- unsigned int sz[2];
- uint32_t counter[5];
- unsigned char save[64];
-};
-
-typedef struct sha SHA_CTX;
-
-void SHA1_Init (struct sha *m);
-void SHA1_Update (struct sha *m, const void *v, size_t len);
-void SHA1_Final (void *res, struct sha *m);
-
-/*
- * SHA-2 256
- */
-
-#define SHA256_DIGEST_LENGTH 32
-
-struct hc_sha256state {
- unsigned int sz[2];
- uint32_t counter[8];
- unsigned char save[64];
-};
-
-typedef struct hc_sha256state SHA256_CTX;
-
-void SHA256_Init (SHA256_CTX *);
-void SHA256_Update (SHA256_CTX *, const void *, size_t);
-void SHA256_Final (void *, SHA256_CTX *);
-
-#endif /* HEIM_SHA_H */
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/events/Makefile.in b/source4/lib/events/Makefile.in
index 0a0df9bef9..4257119849 100644
--- a/source4/lib/events/Makefile.in
+++ b/source4/lib/events/Makefile.in
@@ -9,9 +9,11 @@ exec_prefix = @exec_prefix@
bindir = @bindir@
includedir = @includedir@
libdir = @libdir@
-VPATH = @srcdir@:@tallocdir@:@libreplacedir@
+VPATH = @srcdir@:@libreplacedir@
srcdir = @srcdir@
builddir = @builddir@
+sharedbuilddir = @sharedbuilddir@
+INSTALLCMD = @INSTALL@
CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/include -Iinclude -I.
LDFLAGS = @LDFLAGS@
EXEEXT = @EXEEXT@
@@ -28,26 +30,40 @@ PYTHON_INSTALL_TARGET = @PYTHON_INSTALL_TARGET@
PYTHON_CHECK_TARGET = @PYTHON_CHECK_TARGET@
LIB_PATH_VAR = @LIB_PATH_VAR@
eventsdir = @eventsdir@
-tallocdir = @tallocdir@
-TALLOC_LIBS = @TALLOC_LIBS@
TALLOC_CFLAGS = @TALLOC_CFLAGS@
-TALLOC_OBJ = @TALLOC_OBJ@
+TALLOC_LDFLAGS = @TALLOC_CFLAGS@
+TALLOC_LIBS = @TALLOC_LIBS@
-CFLAGS = $(CPPFLAGS) $(TALLOC_CFLAGS) @CFLAGS@
+EVENTS_CFLAGS = @EVENTS_CFLAGS@
+EVENTS_LDFLAGS = @EVENTS_CFLAGS@
+EVENTS_LIBS = @EVENTS_LIBS@
-EVENTS_OBJ = @EVENTS_OBJ@ $(TALLOC_OBJ) @LIBREPLACEOBJ@
+CFLAGS = $(CPPFLAGS) $(TALLOC_CFLAGS) $(EVENTS_CFLAGS) @CFLAGS@
+LDFLAGS = $(TALLOC_LDFLAGS) $(EVENTS_LDFLAGS) @LDFLAGS@
+LIBS = $(TALLOC_LIBS) $(EVENTS_LIBS) @LIBS@
+
+EVENTS_OBJ = @EVENTS_OBJ@ @LIBREPLACEOBJ@
default: all
include $(eventsdir)/events.mk
include $(eventsdir)/rules.mk
-all:: showflags dirs $(PROGS) $(LIBEVENTS_SOLIB) libevents.a $(PYTHON_BUILD_TARGET)
+all:: showflags dirs $(PROGS) $(EVENTS_SOLIB) libevents.a $(PYTHON_BUILD_TARGET)
install:: all
-$(LIBEVENTS_SOLIB): $(EVENTS_OBJ)
- $(SHLD) $(SHLD_FLAGS) -o $@ $(EVENTS_OBJ) $(TALLOC_LIBS) @SONAMEFLAG@$(LIBEVENTS_SONAME)
+$(EVENTS_SOLIB): $(EVENTS_OBJ)
+ $(SHLD) $(SHLD_FLAGS) $(LDFLAGS) $(LIBS) -o $@ $(EVENTS_OBJ) @SONAMEFLAG@$(EVENTS_SONAME)
+
+shared-build: all
+ ${INSTALLCMD} -d $(sharedbuilddir)/lib
+ ${INSTALLCMD} -m 644 libevents.a $(sharedbuilddir)/lib
+ ${INSTALLCMD} -m 755 $(EVENTS_SOLIB) $(sharedbuilddir)/lib
+ ln -sf $(EVENTS_SOLIB) $(sharedbuilddir)/lib/$(EVENTS_SONAME)
+ ln -sf $(EVENTS_SOLIB) $(sharedbuilddir)/lib/libevents.so
+ ${INSTALLCMD} -d $(sharedbuilddir)/include
+ ${INSTALLCMD} -m 644 $(srcdir)/events.h $(sharedbuilddir)/include
check: test
@@ -56,7 +72,6 @@ installcheck:: test install
clean::
rm -f *.o *.a */*.o
- rm -f $(TALLOC_OBJ)
distclean:: clean
rm -f config.log config.status include/config.h config.cache
diff --git a/source4/lib/events/autogen.sh b/source4/lib/events/autogen.sh
index b13a4b685d..fec05f54d4 100755
--- a/source4/lib/events/autogen.sh
+++ b/source4/lib/events/autogen.sh
@@ -3,8 +3,7 @@
rm -rf autom4te.cache
rm -f configure config.h.in
-IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace"
-IPATHS="$IPATHS -I lib/talloc -I talloc -I ../talloc"
+IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace -I ../../../lib/replace"
autoconf $IPATHS || exit 1
autoheader $IPATHS || exit 1
diff --git a/source4/lib/events/build_macros.m4 b/source4/lib/events/build_macros.m4
new file mode 100644
index 0000000000..c036668cd1
--- /dev/null
+++ b/source4/lib/events/build_macros.m4
@@ -0,0 +1,14 @@
+AC_DEFUN(BUILD_WITH_SHARED_BUILD_DIR,
+ [ AC_ARG_WITH([shared-build-dir],
+ [AC_HELP_STRING([--with-shared-build-dir=DIR],
+ [temporary build directory where libraries are installed [$srcdir/sharedbuild]])])
+
+ sharedbuilddir="$srcdir/sharedbuild"
+ if test x"$with_shared_build_dir" != x; then
+ sharedbuilddir=$with_shared_build_dir
+ CFLAGS="$CFLAGS -I$with_shared_build_dir/include"
+ LDFLAGS="$LDFLAGS -L$with_shared_build_dir/lib"
+ fi
+ AC_SUBST(sharedbuilddir)
+ ])
+
diff --git a/source4/lib/events/configure.ac b/source4/lib/events/configure.ac
index fbd23b10e5..895f2a1daa 100644
--- a/source4/lib/events/configure.ac
+++ b/source4/lib/events/configure.ac
@@ -8,8 +8,6 @@ AC_CONFIG_SRCDIR([events.c])
AC_CONFIG_HEADER(config.h)
AC_LIBREPLACE_ALL_CHECKS
-m4_include(libtalloc.m4)
-
AC_LD_EXPORT_DYNAMIC
AC_LD_SONAMEFLAG
AC_LD_PICFLAG
@@ -17,6 +15,13 @@ AC_LD_SHLIBEXT
AC_LIBREPLACE_SHLD
AC_LIBREPLACE_SHLD_FLAGS
AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
+
+m4_include(build_macros.m4)
+BUILD_WITH_SHARED_BUILD_DIR
+
+m4_include(pkg.m4)
+m4_include(libtalloc.m4)
+
m4_include(libevents.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])
diff --git a/source4/lib/events/events.i b/source4/lib/events/events.i
index 5f790aeac5..8a0d9c4b6f 100644
--- a/source4/lib/events/events.i
+++ b/source4/lib/events/events.i
@@ -18,7 +18,7 @@
%module(docstring="Event management.",package="samba.events") events;
-%import "../talloc/talloc.i";
+%import "../../../lib/talloc/talloc.i";
%{
#include "events.h"
diff --git a/source4/lib/events/events.mk b/source4/lib/events/events.mk
index f4b02eae83..2bc6221689 100644
--- a/source4/lib/events/events.mk
+++ b/source4/lib/events/events.mk
@@ -5,7 +5,7 @@ EVENTS_SOLIB = libevents.$(SHLIBEXT).$(PACKAGE_VERSION)
libevents.a: $(EVENTS_OBJ)
ar -rv libevents.a $(EVENTS_OBJ)
-libevents.$(SHLIBEXT): $(LIBEVENTS_SOLIB)
+libevents.$(SHLIBEXT): $(EVENTS_SOLIB)
ln -fs $< $@
$(EVENTS_SONAME): $(EVENTS_SOLIB)
@@ -24,7 +24,7 @@ installheaders:: installdirs
installlibs:: installdirs
cp events.pc $(DESTDIR)$(libdir)/pkgconfig
- cp libevents.a $(LIBEVENTS_SOLIB) $(DESTDIR)$(libdir)
+ cp libevents.a $(EVENTS_SOLIB) $(DESTDIR)$(libdir)
install:: all installdirs installheaders installlibs $(PYTHON_INSTALL_TARGET)
diff --git a/source4/lib/events/events.py b/source4/lib/events/events.py
index f217c29d78..c15ea8b9e5 100644
--- a/source4/lib/events/events.py
+++ b/source4/lib/events/events.py
@@ -1,5 +1,5 @@
# This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.33
+# Version 1.3.36
#
# Don't modify this file, modify the SWIG interface instead.
diff --git a/source4/lib/events/events_util.c b/source4/lib/events/events_util.c
index 93f6492560..9e7d758405 100644
--- a/source4/lib/events/events_util.c
+++ b/source4/lib/events/events_util.c
@@ -22,6 +22,7 @@
#include "talloc.h"
#include "events.h"
#include "events_internal.h"
+#include "events_util.h"
#include <fcntl.h>
/**
diff --git a/source4/lib/events/events_wrap.c b/source4/lib/events/events_wrap.c
index ccaeab7ad6..335652101b 100644
--- a/source4/lib/events/events_wrap.c
+++ b/source4/lib/events/events_wrap.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.35
+ * Version 1.3.36
*
* 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
@@ -52,6 +52,12 @@
# endif
#endif
+#ifndef SWIG_MSC_UNSUPPRESS_4505
+# if defined(_MSC_VER)
+# pragma warning(disable : 4505) /* unreferenced local function has been removed */
+# endif
+#endif
+
#ifndef SWIGUNUSEDPARM
# ifdef __cplusplus
# define SWIGUNUSEDPARM(p)
@@ -2511,7 +2517,7 @@ static swig_module_info swig_module = {swig_types, 4, 0, 0, 0, 0};
#define SWIG_name "_events"
-#define SWIGVERSION 0x010335
+#define SWIGVERSION 0x010336
#define SWIG_VERSION SWIGVERSION
@@ -2623,10 +2629,10 @@ fail:
SWIGINTERN PyObject *_wrap_event_loop_once(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
event *arg1 = (event *) 0 ;
- int result;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject *swig_obj[1] ;
+ int result;
if (!args) SWIG_fail;
swig_obj[0] = args;
@@ -2646,10 +2652,10 @@ fail:
SWIGINTERN PyObject *_wrap_event_loop_wait(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
event *arg1 = (event *) 0 ;
- int result;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject *swig_obj[1] ;
+ int result;
if (!args) SWIG_fail;
swig_obj[0] = args;
@@ -2681,7 +2687,6 @@ SWIGINTERN PyObject *_wrap_delete_event(PyObject *SWIGUNUSEDPARM(self), PyObject
}
arg1 = (event *)(argp1);
delete_event(arg1);
-
resultobj = SWIG_Py_Void();
return resultobj;
fail:
@@ -2704,7 +2709,6 @@ SWIGINTERN PyObject *_wrap_event_context_init_byname(PyObject *SWIGUNUSEDPARM(se
PyObject *resultobj = 0;
TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
char *arg2 = (char *) 0 ;
- struct event_context *result = 0 ;
int res2 ;
char *buf2 = 0 ;
int alloc2 = 0 ;
@@ -2712,6 +2716,7 @@ SWIGINTERN PyObject *_wrap_event_context_init_byname(PyObject *SWIGUNUSEDPARM(se
char * kwnames[] = {
(char *) "name", NULL
};
+ struct event_context *result = 0 ;
arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:event_context_init_byname",kwnames,&obj0)) SWIG_fail;
diff --git a/source4/lib/events/libevents.m4 b/source4/lib/events/libevents.m4
index d17da64b32..ed76b03d4f 100644
--- a/source4/lib/events/libevents.m4
+++ b/source4/lib/events/libevents.m4
@@ -43,7 +43,7 @@ SMB_EXT_LIB(LIBAIO_LINUX, $AIO_LIBS)
EVENTS_CFLAGS="-I$eventsdir"
AC_SUBST(EVENTS_CFLAGS)
-EVENTS_LIBS=""
+EVENTS_LIBS="$AIO_LIBS"
AC_SUBST(EVENTS_LIBS)
diff --git a/source4/lib/events/libtalloc.m4 b/source4/lib/events/libtalloc.m4
new file mode 100644
index 0000000000..a4c5b8a9d9
--- /dev/null
+++ b/source4/lib/events/libtalloc.m4
@@ -0,0 +1,7 @@
+AC_SUBST(TALLOC_OBJ)
+AC_SUBST(TALLOC_CFLAGS)
+AC_SUBST(TALLOC_LIBS)
+
+AC_CHECK_HEADER(talloc.h,
+ [AC_CHECK_LIB(talloc, talloc_init, [TALLOC_LIBS="-ltalloc"]) ],
+ [PKG_CHECK_MODULES(TALLOC, talloc)])
diff --git a/source4/lib/events/pkg.m4 b/source4/lib/events/pkg.m4
new file mode 100644
index 0000000000..a8b3d06c81
--- /dev/null
+++ b/source4/lib/events/pkg.m4
@@ -0,0 +1,156 @@
+# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
+#
+# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
+#
+# 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/>.
+#
+# 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.
+
+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
+# ----------------------------------
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+ _pkg_min_version=m4_default([$1], [0.9.0])
+ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ PKG_CONFIG=""
+ fi
+
+fi[]dnl
+])# PKG_PROG_PKG_CONFIG
+
+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# Check to see whether a particular set of modules exists. Similar
+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
+#
+#
+# Similar to PKG_CHECK_MODULES, make sure that the first instance of
+# this or PKG_CHECK_MODULES is called, or make sure to call
+# PKG_CHECK_EXISTS manually
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+ m4_ifval([$2], [$2], [:])
+m4_ifvaln([$3], [else
+ $3])dnl
+fi])
+
+
+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+# ---------------------------------------------
+m4_define([_PKG_CONFIG],
+[if test -n "$PKG_CONFIG"; then
+ if test -n "$$1"; then
+ pkg_cv_[]$1="$$1"
+ else
+ PKG_CHECK_EXISTS([$3],
+ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
+ [pkg_failed=yes])
+ fi
+else
+ pkg_failed=untried
+fi[]dnl
+])# _PKG_CONFIG
+
+# _PKG_SHORT_ERRORS_SUPPORTED
+# -----------------------------
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi[]dnl
+])# _PKG_SHORT_ERRORS_SUPPORTED
+
+
+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+#
+# Note that if there is a possibility the first call to
+# PKG_CHECK_MODULES might not happen, you should be sure to include an
+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+#
+#
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
+
+if test $pkg_failed = yes; then
+ _PKG_SHORT_ERRORS_SUPPORTED
+ if test $_pkg_short_errors_supported = yes; then
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
+ else
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+ ifelse([$4], , [AC_MSG_ERROR(dnl
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT
+])],
+ [AC_MSG_RESULT([no])
+ $4])
+elif test $pkg_failed = untried; then
+ ifelse([$4], , [AC_MSG_FAILURE(dnl
+[The pkg-config script could not be found or is too old. Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://www.freedesktop.org/software/pkgconfig>.])],
+ [$4])
+else
+ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+ AC_MSG_RESULT([yes])
+ ifelse([$3], , :, [$3])
+fi[]dnl
+])# PKG_CHECK_MODULES
diff --git a/source4/lib/gencache/gencache.c b/source4/lib/gencache/gencache.c
deleted file mode 100644
index aaaa40eea8..0000000000
--- a/source4/lib/gencache/gencache.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Generic, persistent and shared between processes cache mechanism for use
- by various parts of the Samba code
-
- Copyright (C) Rafal Szczesniak 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/>.
-*/
-
-#include "includes.h"
-#include "system/time.h"
-#include "system/filesys.h"
-#include "tdb_wrap.h"
-#include "lib/gencache/gencache.h"
-
-#define TIMEOUT_LEN 12
-#define CACHE_DATA_FMT "%12u/%s"
-
-static struct tdb_wrap *cache;
-
-/**
- * @file gencache.c
- * @brief Generic, persistent and shared between processes cache mechanism
- * for use by various parts of the Samba code
- *
- **/
-
-
-/**
- * Cache initialisation function. Opens cache tdb file or creates
- * it if does not exist.
- *
- * @return true on successful initialisation of the cache or
- * false on failure
- **/
-
-bool gencache_init(struct loadparm_context *lp_ctx)
-{
- char* cache_fname = NULL;
- TALLOC_CTX *mem_ctx = talloc_autofree_context();
-
- /* skip file open if it's already opened */
- if (cache) return true;
-
- cache_fname = lock_path(mem_ctx, lp_ctx, "gencache.tdb");
- if (cache_fname != NULL) {
- DEBUG(5, ("Opening cache file at %s\n", cache_fname));
- } else {
- DEBUG(0, ("Filename allocation failed.\n"));
- return false;
- }
-
- cache = tdb_wrap_open(mem_ctx, cache_fname, 0, TDB_DEFAULT,
- O_RDWR|O_CREAT, 0644);
-
- talloc_free(cache_fname);
- if (!cache) {
- DEBUG(5, ("Attempt to open gencache.tdb has failed.\n"));
- return false;
- }
- return true;
-}
-
-
-/**
- * Cache shutdown function. Closes opened cache tdb file.
- *
- * @return true on successful closing the cache or
- * false on failure during cache shutdown
- **/
-
-bool gencache_shutdown(void)
-{
- if (!cache) return false;
- DEBUG(5, ("Closing cache file\n"));
- talloc_free(cache);
- return true;
-}
-
-
-/**
- * Set an entry in the cache file. If there's no such
- * one, then add it.
- *
- * @param keystr string that represents a key of this entry
- * @param value text representation value being cached
- * @param timeout time when the value is expired
- *
- * @retval true when entry is successfuly stored
- * @retval false on failure
- **/
-
-bool gencache_set(const char *keystr, const char *value, time_t timeout)
-{
- int ret;
- TDB_DATA keybuf, databuf;
- char* valstr = NULL;
-
- /* fail completely if get null pointers passed */
- SMB_ASSERT(keystr && value);
-
- if (!gencache_init()) return false;
-
- asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value);
- if (!valstr)
- return false;
-
- keybuf.dptr = (uint8_t *)strdup(keystr);
- keybuf.dsize = strlen(keystr)+1;
- databuf.dptr = (uint8_t *)strdup(valstr);
- databuf.dsize = strlen(valstr)+1;
- DEBUG(10, ("Adding cache entry with key = %s; value = %s and timeout \
- = %s (%d seconds %s)\n", keybuf.dptr, value, ctime(&timeout),
- (int)(timeout - time(NULL)), timeout > time(NULL) ? "ahead" : "in the past"));
-
- ret = tdb_store(cache->tdb, keybuf, databuf, 0);
- SAFE_FREE(valstr);
- SAFE_FREE(keybuf.dptr);
- SAFE_FREE(databuf.dptr);
-
- return ret == 0;
-}
-
-
-/**
- * Set existing entry to the cache file.
- *
- * @param keystr string that represents a key of this entry
- * @param valstr text representation value being cached
- * @param timeout time when the value is expired
- *
- * @retval true when entry is successfuly set
- * @retval false on failure
- **/
-
-bool gencache_set_only(const char *keystr, const char *valstr, time_t timeout)
-{
- int ret = -1;
- TDB_DATA keybuf, databuf;
- char *old_valstr, *datastr;
- time_t old_timeout;
-
- /* fail completely if get null pointers passed */
- SMB_ASSERT(keystr && valstr);
-
- if (!gencache_init()) return false;
-
- /*
- * Check whether entry exists in the cache
- * Don't verify gencache_get exit code, since the entry may be expired
- */
- gencache_get(keystr, &old_valstr, &old_timeout);
-
- if (!(old_valstr && old_timeout)) return false;
-
- DEBUG(10, ("Setting cache entry with key = %s; old value = %s and old timeout \
- = %s\n", keystr, old_valstr, ctime(&old_timeout)));
-
- asprintf(&datastr, CACHE_DATA_FMT, (int)timeout, valstr);
- keybuf.dptr = (uint8_t *)strdup(keystr);
- keybuf.dsize = strlen(keystr)+1;
- databuf.dptr = (uint8_t *)strdup(datastr);
- databuf.dsize = strlen(datastr)+1;
- DEBUGADD(10, ("New value = %s, new timeout = %s (%d seconds %s)", valstr,
- ctime(&timeout), (int)(timeout - time(NULL)),
- timeout > time(NULL) ? "ahead" : "in the past"));
-
-
- ret = tdb_store(cache->tdb, keybuf, databuf, TDB_REPLACE);
-
- SAFE_FREE(datastr);
- SAFE_FREE(old_valstr);
- SAFE_FREE(keybuf.dptr);
- SAFE_FREE(databuf.dptr);
-
- return ret == 0;
-}
-
-
-/**
- * Delete one entry from the cache file.
- *
- * @param keystr string that represents a key of this entry
- *
- * @retval true upon successful deletion
- * @retval false in case of failure
- **/
-
-bool gencache_del(const char *keystr)
-{
- int ret;
- TDB_DATA keybuf;
-
- /* fail completely if get null pointers passed */
- SMB_ASSERT(keystr);
-
- if (!gencache_init()) return false;
-
- keybuf.dptr = (uint8_t *)strdup(keystr);
- keybuf.dsize = strlen(keystr)+1;
- DEBUG(10, ("Deleting cache entry (key = %s)\n", keystr));
- ret = tdb_delete(cache->tdb, keybuf);
-
- SAFE_FREE(keybuf.dptr);
- return ret == 0;
-}
-
-
-/**
- * Get existing entry from the cache file.
- *
- * @param keystr string that represents a key of this entry
- * @param valstr buffer that is allocated and filled with the entry value
- * buffer's disposing must be done outside
- * @param timeout pointer to a time_t that is filled with entry's
- * timeout
- *
- * @retval true when entry is successfuly fetched
- * @retval false for failure
- **/
-
-bool gencache_get(const char *keystr, char **valstr, time_t *timeout)
-{
- TDB_DATA keybuf, databuf;
-
- /* fail completely if get null pointers passed */
- SMB_ASSERT(keystr);
-
- if (!gencache_init())
- return false;
-
- keybuf.dptr = (uint8_t *)strdup(keystr);
- keybuf.dsize = strlen(keystr)+1;
- databuf = tdb_fetch(cache->tdb, keybuf);
- SAFE_FREE(keybuf.dptr);
-
- if (databuf.dptr && databuf.dsize > TIMEOUT_LEN) {
- char* entry_buf = strndup((char *)databuf.dptr, databuf.dsize);
- char *v;
- time_t t;
- unsigned i;
-
- v = malloc_array_p(char, databuf.dsize - TIMEOUT_LEN);
-
- SAFE_FREE(databuf.dptr);
- sscanf(entry_buf, CACHE_DATA_FMT, (int*)&i, v);
- SAFE_FREE(entry_buf);
- t = i;
-
- DEBUG(10, ("Returning %s cache entry: key = %s, value = %s, "
- "timeout = %s\n", t > time(NULL) ? "valid" :
- "expired", keystr, v, ctime(&t)));
-
- if (valstr)
- *valstr = v;
- else
- SAFE_FREE(v);
-
- if (timeout)
- *timeout = t;
-
- return t > time(NULL);
-
- } else {
- SAFE_FREE(databuf.dptr);
-
- if (valstr)
- *valstr = NULL;
-
- if (timeout)
- timeout = NULL;
-
- DEBUG(10, ("Cache entry with key = %s couldn't be found\n",
- keystr));
-
- return false;
- }
-}
-
-
-/**
- * Iterate through all entries which key matches to specified pattern
- *
- * @param fn pointer to the function that will be supplied with each single
- * matching cache entry (key, value and timeout) as an arguments
- * @param data void pointer to an arbitrary data that is passed directly to the fn
- * function on each call
- * @param keystr_pattern pattern the existing entries' keys are matched to
- *
- **/
-
-void gencache_iterate(void (*fn)(const char* key, const char *value, time_t timeout, void* dptr),
- void* data, const char* keystr_pattern)
-{
- TDB_LIST_NODE *node, *first_node;
- TDB_DATA databuf;
- char *keystr = NULL, *valstr = NULL, *entry = NULL;
- time_t timeout = 0;
- unsigned i;
-
- /* fail completely if get null pointers passed */
- SMB_ASSERT(fn && keystr_pattern);
-
- if (!gencache_init()) return;
-
- DEBUG(5, ("Searching cache keys with pattern %s\n", keystr_pattern));
- node = tdb_search_keys(cache->tdb, keystr_pattern);
- first_node = node;
-
- while (node) {
- /* ensure null termination of the key string */
- keystr = strndup((char *)node->node_key.dptr, node->node_key.dsize);
-
- /*
- * We don't use gencache_get function, because we need to iterate through
- * all of the entries. Validity verification is up to fn routine.
- */
- databuf = tdb_fetch(cache->tdb, node->node_key);
- if (!databuf.dptr || databuf.dsize <= TIMEOUT_LEN) {
- SAFE_FREE(databuf.dptr);
- SAFE_FREE(keystr);
- node = node->next;
- continue;
- }
- entry = strndup((char *)databuf.dptr, databuf.dsize);
- SAFE_FREE(databuf.dptr);
- valstr = malloc_array_p(char, databuf.dsize - TIMEOUT_LEN);
- sscanf(entry, CACHE_DATA_FMT, (int*)(&i), valstr);
- timeout = i;
-
- DEBUG(10, ("Calling function with arguments (key = %s, value = %s, timeout = %s)\n",
- keystr, valstr, ctime(&timeout)));
- fn(keystr, valstr, timeout, data);
-
- SAFE_FREE(valstr);
- SAFE_FREE(entry);
- SAFE_FREE(keystr);
- node = node->next;
- }
-
- tdb_search_list_free(first_node);
-}
-
-/********************************************************************
- lock a key
-********************************************************************/
-
-int gencache_lock_entry( const char *key )
-{
- return tdb_lock_bystring(cache->tdb, key);
-}
-
-/********************************************************************
- unlock a key
-********************************************************************/
-
-void gencache_unlock_entry( const char *key )
-{
- tdb_unlock_bystring(cache->tdb, key);
-}
-
-
diff --git a/source4/lib/gencache/gencache.h b/source4/lib/gencache/gencache.h
deleted file mode 100644
index 1481676fd9..0000000000
--- a/source4/lib/gencache/gencache.h
+++ /dev/null
@@ -1,94 +0,0 @@
-#ifndef __LIB_GENCACHE_GENCACHE_H__
-#define __LIB_GENCACHE_GENCACHE_H__
-
-/**
- * Cache initialisation function. Opens cache tdb file or creates
- * it if does not exist.
- *
- * @return true on successful initialisation of the cache or
- * false on failure
- **/
-bool gencache_init(struct loadparm_context *lp_ctx);
-
-/**
- * Cache shutdown function. Closes opened cache tdb file.
- *
- * @return true on successful closing the cache or
- * false on failure during cache shutdown
- **/
-bool gencache_shutdown(void);
-
-/**
- * Set an entry in the cache file. If there's no such
- * one, then add it.
- *
- * @param keystr string that represents a key of this entry
- * @param value text representation value being cached
- * @param timeout time when the value is expired
- *
- * @retval true when entry is successfuly stored
- * @retval false on failure
- **/
-bool gencache_set(const char *keystr, const char *value, time_t timeout);
-
-/**
- * Set existing entry to the cache file.
- *
- * @param keystr string that represents a key of this entry
- * @param valstr text representation value being cached
- * @param timeout time when the value is expired
- *
- * @retval true when entry is successfuly set
- * @retval false on failure
- **/
-bool gencache_set_only(const char *keystr, const char *valstr, time_t timeout);
-
-/**
- * Delete one entry from the cache file.
- *
- * @param keystr string that represents a key of this entry
- *
- * @retval true upon successful deletion
- * @retval false in case of failure
- **/
-bool gencache_del(const char *keystr);
-
-/**
- * Get existing entry from the cache file.
- *
- * @param keystr string that represents a key of this entry
- * @param valstr buffer that is allocated and filled with the entry value
- * buffer's disposing must be done outside
- * @param timeout pointer to a time_t that is filled with entry's
- * timeout
- *
- * @retval true when entry is successfuly fetched
- * @retval false for failure
- **/
-bool gencache_get(const char *keystr, char **valstr, time_t *timeout);
-
-/**
- * Iterate through all entries which key matches to specified pattern
- *
- * @param fn pointer to the function that will be supplied with each single
- * matching cache entry (key, value and timeout) as an arguments
- * @param data void pointer to an arbitrary data that is passed directly to the fn
- * function on each call
- * @param keystr_pattern pattern the existing entries' keys are matched to
- *
- **/
-void gencache_iterate(void (*fn)(const char* key, const char *value, time_t timeout, void* dptr),
- void* data, const char* keystr_pattern);
-
-/********************************************************************
- lock a key
-********************************************************************/
-int gencache_lock_entry( const char *key );
-
-/********************************************************************
- unlock a key
-********************************************************************/
-void gencache_unlock_entry( const char *key );
-
-#endif /* __LIB_GENCACHE_GENCACHE_H__ */
-
diff --git a/source4/lib/json/AUTHORS b/source4/lib/json/AUTHORS
deleted file mode 100644
index 38f2ce02a2..0000000000
--- a/source4/lib/json/AUTHORS
+++ /dev/null
@@ -1,2 +0,0 @@
-Michael Clark <michael@metaparadigm.com>
-C. Watford (christopher.watford@gmail.com)
diff --git a/source4/lib/json/COPYING b/source4/lib/json/COPYING
deleted file mode 100644
index b07ea94498..0000000000
--- a/source4/lib/json/COPYING
+++ /dev/null
@@ -1,18 +0,0 @@
-Copyright (c) 2004, 2005 Metaparadigm Pte Ltd
-
-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
-BRIAN PAUL 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.
diff --git a/source4/lib/json/ChangeLog b/source4/lib/json/ChangeLog
deleted file mode 100644
index a0f848e261..0000000000
--- a/source4/lib/json/ChangeLog
+++ /dev/null
@@ -1,55 +0,0 @@
-0.6
- * Fix bug in escaping of control characters
- Johan Björklund, johbjo09 at kth dot se
- * Remove include "config.h" from headers (should only
- be included from .c files)
- Michael Clark <michael@metaparadigm.com>
-
-0.5
- * Make headers C++ compatible by change *this to *obj
- * Add ifdef C++ extern "C" to headers
- * Use simpler definition of min and max in bits.h
- Larry Lansing, llansing at fuzzynerd dot com
-
- * Remove automake 1.6 requirement
- * Move autogen commands into autogen.sh. Update README
- * Remove error pointer special case for Windows
- * Change license from LGPL to MIT
- Michael Clark <michael@metaparadigm.com>
-
-0.4
- * Fix additional error case in object parsing
- * Add back sign reversal in nested object parse as error pointer
- value is negative, while error value is positive.
- Michael Clark <michael@metaparadigm.com>
-
-0.3
- * fix pointer arithmetic bug for error pointer check in is_error() macro
- * fix type passed to printbuf_memappend in json_tokener
- * update autotools bootstrap instructions in README
- Michael Clark <michael@metaparadigm.com>
-
-0.2
- * printbuf.c - C. Watford (christopher.watford@gmail.com)
- Added a Win32/Win64 compliant implementation of vasprintf
- * debug.c - C. Watford (christopher.watford@gmail.com)
- Removed usage of vsyslog on Win32/Win64 systems, needs to be handled
- by a configure script
- * json_object.c - C. Watford (christopher.watford@gmail.com)
- Added scope operator to wrap usage of json_object_object_foreach, this
- needs to be rethought to be more ANSI C friendly
- * json_object.h - C. Watford (christopher.watford@gmail.com)
- Added Microsoft C friendly version of json_object_object_foreach
- * json_tokener.c - C. Watford (christopher.watford@gmail.com)
- Added a Win32/Win64 compliant implementation of strndup
- * json_util.c - C. Watford (christopher.watford@gmail.com)
- Added cast and mask to suffice size_t v. unsigned int conversion
- correctness
- * json_tokener.c - sign reversal issue on error info for nested object parse
- spotted by Johan Björklund (johbjo09 at kth.se)
- * json_object.c - escape " in json_escape_str
- * Change to automake and libtool to build shared and static library
- Michael Clark <michael@metaparadigm.com>
-
-0.1
- * initial release
diff --git a/source4/lib/json/Doxyfile b/source4/lib/json/Doxyfile
deleted file mode 100644
index 7e5f306df3..0000000000
--- a/source4/lib/json/Doxyfile
+++ /dev/null
@@ -1,1153 +0,0 @@
-# Doxyfile 1.3.8
-
-# This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project
-#
-# All text after a hash (#) is considered a comment and will be ignored
-# The format is:
-# TAG = value [value, ...]
-# For lists items can also be appended using:
-# TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ")
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
-# by quotes) that should identify the project.
-
-PROJECT_NAME = json-c
-
-# The PROJECT_NUMBER tag can be used to enter a project or revision number.
-# This could be handy for archiving the generated documentation or
-# if some version control system is used.
-
-PROJECT_NUMBER = 0.2
-
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
-# base path where the generated documentation will be put.
-# If a relative path is entered, it will be relative to the location
-# where doxygen was started. If left blank the current directory will be used.
-
-OUTPUT_DIRECTORY = doc
-
-# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
-# 4096 sub-directories (in 2 levels) under the output directory of each output
-# format and will distribute the generated files over these directories.
-# Enabling this option can be useful when feeding doxygen a huge amount of source
-# files, where putting all generated files in the same directory would otherwise
-# cause performance problems for the file system.
-
-CREATE_SUBDIRS = NO
-
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all
-# documentation generated by doxygen is written. Doxygen will use this
-# information to generate all constant output in the proper language.
-# The default language is English, other supported languages are:
-# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish,
-# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese,
-# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian,
-# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish,
-# Swedish, and Ukrainian.
-
-OUTPUT_LANGUAGE = English
-
-# This tag can be used to specify the encoding used in the generated output.
-# The encoding is not always determined by the language that is chosen,
-# but also whether or not the output is meant for Windows or non-Windows users.
-# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES
-# forces the Windows encoding (this is the default for the Windows binary),
-# whereas setting the tag to NO uses a Unix-style encoding (the default for
-# all platforms other than Windows).
-
-USE_WINDOWS_ENCODING = NO
-
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
-# include brief member descriptions after the members that are listed in
-# the file and class documentation (similar to JavaDoc).
-# Set to NO to disable this.
-
-BRIEF_MEMBER_DESC = YES
-
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
-# the brief description of a member or function before the detailed description.
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
-# brief descriptions will be completely suppressed.
-
-REPEAT_BRIEF = YES
-
-# This tag implements a quasi-intelligent brief description abbreviator
-# that is used to form the text in various listings. Each string
-# in this list, if found as the leading text of the brief description, will be
-# stripped from the text and the result after processing the whole list, is used
-# as the annotated text. Otherwise, the brief description is used as-is. If left
-# blank, the following values are used ("$name" is automatically replaced with the
-# name of the entity): "The $name class" "The $name widget" "The $name file"
-# "is" "provides" "specifies" "contains" "represents" "a" "an" "the"
-
-ABBREVIATE_BRIEF =
-
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
-# Doxygen will generate a detailed section even if there is only a brief
-# description.
-
-ALWAYS_DETAILED_SEC = NO
-
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited
-# members of a class in the documentation of that class as if those members were
-# ordinary class members. Constructors, destructors and assignment operators of
-# the base classes will not be shown.
-
-INLINE_INHERITED_MEMB = NO
-
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
-# path before files name in the file list and in the header files. If set
-# to NO the shortest path that makes the file name unique will be used.
-
-FULL_PATH_NAMES = YES
-
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
-# can be used to strip a user-defined part of the path. Stripping is
-# only done if one of the specified strings matches the left-hand part of
-# the path. The tag can be used to show relative paths in the file list.
-# If left blank the directory from which doxygen is run is used as the
-# path to strip.
-
-STRIP_FROM_PATH =
-
-# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
-# the path mentioned in the documentation of a class, which tells
-# the reader which header file to include in order to use a class.
-# If left blank only the name of the header file containing the class
-# definition is used. Otherwise one should specify the include paths that
-# are normally passed to the compiler using the -I flag.
-
-STRIP_FROM_INC_PATH =
-
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
-# (but less readable) file names. This can be useful is your file systems
-# doesn't support long names like on DOS, Mac, or CD-ROM.
-
-SHORT_NAMES = NO
-
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
-# will interpret the first line (until the first dot) of a JavaDoc-style
-# comment as the brief description. If set to NO, the JavaDoc
-# comments will behave just like the Qt-style comments (thus requiring an
-# explicit @brief command for a brief description.
-
-JAVADOC_AUTOBRIEF = NO
-
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
-# treat a multi-line C++ special comment block (i.e. a block of //! or ///
-# comments) as a brief description. This used to be the default behaviour.
-# The new default is to treat a multi-line C++ comment block as a detailed
-# description. Set this tag to YES if you prefer the old behaviour instead.
-
-MULTILINE_CPP_IS_BRIEF = NO
-
-# If the DETAILS_AT_TOP tag is set to YES then Doxygen
-# will output the detailed description near the top, like JavaDoc.
-# If set to NO, the detailed description appears after the member
-# documentation.
-
-DETAILS_AT_TOP = NO
-
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
-# member inherits the documentation from any documented member that it
-# re-implements.
-
-INHERIT_DOCS = YES
-
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
-# tag is set to YES, then doxygen will reuse the documentation of the first
-# member in the group (if any) for the other members of the group. By default
-# all members of a group must be documented explicitly.
-
-DISTRIBUTE_GROUP_DOC = NO
-
-# The TAB_SIZE tag can be used to set the number of spaces in a tab.
-# Doxygen uses this value to replace tabs by spaces in code fragments.
-
-TAB_SIZE = 8
-
-# This tag can be used to specify a number of aliases that acts
-# as commands in the documentation. An alias has the form "name=value".
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to
-# put the command \sideeffect (or @sideeffect) in the documentation, which
-# will result in a user-defined paragraph with heading "Side Effects:".
-# You can put \n's in the value part of an alias to insert newlines.
-
-ALIASES =
-
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
-# only. Doxygen will then generate output that is more tailored for C.
-# For instance, some of the names that are used will be different. The list
-# of all members will be omitted, etc.
-
-OPTIMIZE_OUTPUT_FOR_C = YES
-
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources
-# only. Doxygen will then generate output that is more tailored for Java.
-# For instance, namespaces will be presented as packages, qualified scopes
-# will look different, etc.
-
-OPTIMIZE_OUTPUT_JAVA = NO
-
-# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
-# the same type (for instance a group of public functions) to be put as a
-# subgroup of that type (e.g. under the Public Functions section). Set it to
-# NO to prevent subgrouping. Alternatively, this can be done per class using
-# the \nosubgrouping command.
-
-SUBGROUPING = YES
-
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
-# documentation are documented, even if no documentation was available.
-# Private class members and static file members will be hidden unless
-# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
-
-EXTRACT_ALL = YES
-
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
-# will be included in the documentation.
-
-EXTRACT_PRIVATE = NO
-
-# If the EXTRACT_STATIC tag is set to YES all static members of a file
-# will be included in the documentation.
-
-EXTRACT_STATIC = NO
-
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
-# defined locally in source files will be included in the documentation.
-# If set to NO only classes defined in header files are included.
-
-EXTRACT_LOCAL_CLASSES = NO
-
-# This flag is only useful for Objective-C code. When set to YES local
-# methods, which are defined in the implementation section but not in
-# the interface are included in the documentation.
-# If set to NO (the default) only methods in the interface are included.
-
-EXTRACT_LOCAL_METHODS = NO
-
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
-# undocumented members of documented classes, files or namespaces.
-# If set to NO (the default) these members will be included in the
-# various overviews, but no documentation section is generated.
-# This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_MEMBERS = NO
-
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
-# undocumented classes that are normally visible in the class hierarchy.
-# If set to NO (the default) these classes will be included in the various
-# overviews. This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_CLASSES = NO
-
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
-# friend (class|struct|union) declarations.
-# If set to NO (the default) these declarations will be included in the
-# documentation.
-
-HIDE_FRIEND_COMPOUNDS = NO
-
-# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
-# documentation blocks found inside the body of a function.
-# If set to NO (the default) these blocks will be appended to the
-# function's detailed documentation block.
-
-HIDE_IN_BODY_DOCS = NO
-
-# The INTERNAL_DOCS tag determines if documentation
-# that is typed after a \internal command is included. If the tag is set
-# to NO (the default) then the documentation will be excluded.
-# Set it to YES to include the internal documentation.
-
-INTERNAL_DOCS = NO
-
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
-# file names in lower-case letters. If set to YES upper-case letters are also
-# allowed. This is useful if you have classes or files whose names only differ
-# in case and if your file system supports case sensitive file names. Windows
-# and Mac users are advised to set this option to NO.
-
-CASE_SENSE_NAMES = YES
-
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
-# will show members with their full class and namespace scopes in the
-# documentation. If set to YES the scope will be hidden.
-
-HIDE_SCOPE_NAMES = NO
-
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
-# will put a list of the files that are included by a file in the documentation
-# of that file.
-
-SHOW_INCLUDE_FILES = NO
-
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
-# is inserted in the documentation for inline members.
-
-INLINE_INFO = YES
-
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
-# will sort the (detailed) documentation of file and class members
-# alphabetically by member name. If set to NO the members will appear in
-# declaration order.
-
-SORT_MEMBER_DOCS = YES
-
-# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
-# brief documentation of file, namespace and class members alphabetically
-# by member name. If set to NO (the default) the members will appear in
-# declaration order.
-
-SORT_BRIEF_DOCS = NO
-
-# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
-# sorted by fully-qualified names, including namespaces. If set to
-# NO (the default), the class list will be sorted only by class name,
-# not including the namespace part.
-# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
-# Note: This option applies only to the class list, not to the
-# alphabetical list.
-
-SORT_BY_SCOPE_NAME = NO
-
-# The GENERATE_TODOLIST tag can be used to enable (YES) or
-# disable (NO) the todo list. This list is created by putting \todo
-# commands in the documentation.
-
-GENERATE_TODOLIST = YES
-
-# The GENERATE_TESTLIST tag can be used to enable (YES) or
-# disable (NO) the test list. This list is created by putting \test
-# commands in the documentation.
-
-GENERATE_TESTLIST = YES
-
-# The GENERATE_BUGLIST tag can be used to enable (YES) or
-# disable (NO) the bug list. This list is created by putting \bug
-# commands in the documentation.
-
-GENERATE_BUGLIST = YES
-
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
-# disable (NO) the deprecated list. This list is created by putting
-# \deprecated commands in the documentation.
-
-GENERATE_DEPRECATEDLIST= YES
-
-# The ENABLED_SECTIONS tag can be used to enable conditional
-# documentation sections, marked by \if sectionname ... \endif.
-
-ENABLED_SECTIONS =
-
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
-# the initial value of a variable or define consists of for it to appear in
-# the documentation. If the initializer consists of more lines than specified
-# here it will be hidden. Use a value of 0 to hide initializers completely.
-# The appearance of the initializer of individual variables and defines in the
-# documentation can be controlled using \showinitializer or \hideinitializer
-# command in the documentation regardless of this setting.
-
-MAX_INITIALIZER_LINES = 30
-
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
-# at the bottom of the documentation of classes and structs. If set to YES the
-# list will mention the files that were used to generate the documentation.
-
-SHOW_USED_FILES = YES
-
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-
-# The QUIET tag can be used to turn on/off the messages that are generated
-# by doxygen. Possible values are YES and NO. If left blank NO is used.
-
-QUIET = NO
-
-# The WARNINGS tag can be used to turn on/off the warning messages that are
-# generated by doxygen. Possible values are YES and NO. If left blank
-# NO is used.
-
-WARNINGS = YES
-
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
-# automatically be disabled.
-
-WARN_IF_UNDOCUMENTED = YES
-
-# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
-# potential errors in the documentation, such as not documenting some
-# parameters in a documented function, or documenting parameters that
-# don't exist or using markup commands wrongly.
-
-WARN_IF_DOC_ERROR = YES
-
-# The WARN_FORMAT tag determines the format of the warning messages that
-# doxygen can produce. The string should contain the $file, $line, and $text
-# tags, which will be replaced by the file and line number from which the
-# warning originated and the warning text.
-
-WARN_FORMAT = "$file:$line: $text"
-
-# The WARN_LOGFILE tag can be used to specify a file to which warning
-# and error messages should be written. If left blank the output is written
-# to stderr.
-
-WARN_LOGFILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-
-# The INPUT tag can be used to specify the files and/or directories that contain
-# documented source files. You may enter file names like "myfile.cpp" or
-# directories like "/usr/src/myproject". Separate the files or directories
-# with spaces.
-
-INPUT =
-
-# If the value of the INPUT tag contains directories, you can use the
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank the following patterns are tested:
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp
-# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm
-
-FILE_PATTERNS = *.h
-
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories
-# should be searched for input files as well. Possible values are YES and NO.
-# If left blank NO is used.
-
-RECURSIVE = NO
-
-# The EXCLUDE tag can be used to specify files and/or directories that should
-# excluded from the INPUT source files. This way you can easily exclude a
-# subdirectory from a directory tree whose root is specified with the INPUT tag.
-
-EXCLUDE =
-
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories
-# that are symbolic links (a Unix filesystem feature) are excluded from the input.
-
-EXCLUDE_SYMLINKS = NO
-
-# If the value of the INPUT tag contains directories, you can use the
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
-# certain files from those directories.
-
-EXCLUDE_PATTERNS =
-
-# The EXAMPLE_PATH tag can be used to specify one or more files or
-# directories that contain example code fragments that are included (see
-# the \include command).
-
-EXAMPLE_PATH =
-
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank all files are included.
-
-EXAMPLE_PATTERNS =
-
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
-# searched for input files to be used with the \include or \dontinclude
-# commands irrespective of the value of the RECURSIVE tag.
-# Possible values are YES and NO. If left blank NO is used.
-
-EXAMPLE_RECURSIVE = NO
-
-# The IMAGE_PATH tag can be used to specify one or more files or
-# directories that contain image that are included in the documentation (see
-# the \image command).
-
-IMAGE_PATH =
-
-# The INPUT_FILTER tag can be used to specify a program that doxygen should
-# invoke to filter for each input file. Doxygen will invoke the filter program
-# by executing (via popen()) the command <filter> <input-file>, where <filter>
-# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
-# input file. Doxygen will then use the output that the filter program writes
-# to standard output. If FILTER_PATTERNS is specified, this tag will be
-# ignored.
-
-INPUT_FILTER =
-
-# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
-# basis. Doxygen will compare the file name with each pattern and apply the
-# filter if there is a match. The filters are a list of the form:
-# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
-# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
-# is applied to all files.
-
-FILTER_PATTERNS =
-
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
-# INPUT_FILTER) will be used to filter the input files when producing source
-# files to browse (i.e. when SOURCE_BROWSER is set to YES).
-
-FILTER_SOURCE_FILES = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will
-# be generated. Documented entities will be cross-referenced with these sources.
-# Note: To get rid of all source code in the generated output, make sure also
-# VERBATIM_HEADERS is set to NO.
-
-SOURCE_BROWSER = NO
-
-# Setting the INLINE_SOURCES tag to YES will include the body
-# of functions and classes directly in the documentation.
-
-INLINE_SOURCES = NO
-
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
-# doxygen to hide any special comment blocks from generated source code
-# fragments. Normal C and C++ comments will always remain visible.
-
-STRIP_CODE_COMMENTS = YES
-
-# If the REFERENCED_BY_RELATION tag is set to YES (the default)
-# then for each documented function all documented
-# functions referencing it will be listed.
-
-REFERENCED_BY_RELATION = YES
-
-# If the REFERENCES_RELATION tag is set to YES (the default)
-# then for each documented function all documented entities
-# called/used by that function will be listed.
-
-REFERENCES_RELATION = YES
-
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
-# will generate a verbatim copy of the header file for each class for
-# which an include is specified. Set to NO to disable this.
-
-VERBATIM_HEADERS = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
-# of all compounds will be generated. Enable this if the project
-# contains a lot of classes, structs, unions or interfaces.
-
-ALPHABETICAL_INDEX = NO
-
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
-# in which this list will be split (can be a number in the range [1..20])
-
-COLS_IN_ALPHA_INDEX = 5
-
-# In case all classes in a project start with a common prefix, all
-# classes will be put under the same header in the alphabetical index.
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
-# should be ignored while generating the index headers.
-
-IGNORE_PREFIX =
-
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
-# generate HTML output.
-
-GENERATE_HTML = YES
-
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `html' will be used as the default path.
-
-HTML_OUTPUT = html
-
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
-# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
-# doxygen will generate files with .html extension.
-
-HTML_FILE_EXTENSION = .html
-
-# The HTML_HEADER tag can be used to specify a personal HTML header for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard header.
-
-HTML_HEADER =
-
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard footer.
-
-HTML_FOOTER =
-
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
-# style sheet that is used by each HTML page. It can be used to
-# fine-tune the look of the HTML output. If the tag is left blank doxygen
-# will generate a default style sheet. Note that doxygen will try to copy
-# the style sheet file to the HTML output directory, so don't put your own
-# stylesheet in the HTML output directory as well, or it will be erased!
-
-HTML_STYLESHEET =
-
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
-# files or namespaces will be aligned in HTML using tables. If set to
-# NO a bullet list will be used.
-
-HTML_ALIGN_MEMBERS = YES
-
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files
-# will be generated that can be used as input for tools like the
-# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
-# of the generated HTML documentation.
-
-GENERATE_HTMLHELP = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
-# be used to specify the file name of the resulting .chm file. You
-# can add a path in front of the file if the result should not be
-# written to the html output directory.
-
-CHM_FILE =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
-# be used to specify the location (absolute path including file name) of
-# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
-# the HTML help compiler on the generated index.hhp.
-
-HHC_LOCATION =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
-# controls if a separate .chi index file is generated (YES) or that
-# it should be included in the master .chm file (NO).
-
-GENERATE_CHI = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
-# controls whether a binary table of contents is generated (YES) or a
-# normal table of contents (NO) in the .chm file.
-
-BINARY_TOC = NO
-
-# The TOC_EXPAND flag can be set to YES to add extra items for group members
-# to the contents of the HTML help documentation and to the tree view.
-
-TOC_EXPAND = NO
-
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
-# top of each HTML page. The value NO (the default) enables the index and
-# the value YES disables it.
-
-DISABLE_INDEX = NO
-
-# This tag can be used to set the number of enum values (range [1..20])
-# that doxygen will group on one line in the generated HTML documentation.
-
-ENUM_VALUES_PER_LINE = 4
-
-# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
-# generated containing a tree-like index structure (just like the one that
-# is generated for HTML Help). For this to work a browser that supports
-# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
-# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
-# probably better off using the HTML help feature.
-
-GENERATE_TREEVIEW = NO
-
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
-# used to set the initial width (in pixels) of the frame in which the tree
-# is shown.
-
-TREEVIEW_WIDTH = 250
-
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
-# generate Latex output.
-
-GENERATE_LATEX = NO
-
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `latex' will be used as the default path.
-
-LATEX_OUTPUT = latex
-
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
-# invoked. If left blank `latex' will be used as the default command name.
-
-LATEX_CMD_NAME = latex
-
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
-# generate index for LaTeX. If left blank `makeindex' will be used as the
-# default command name.
-
-MAKEINDEX_CMD_NAME = makeindex
-
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
-# LaTeX documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_LATEX = NO
-
-# The PAPER_TYPE tag can be used to set the paper type that is used
-# by the printer. Possible values are: a4, a4wide, letter, legal and
-# executive. If left blank a4wide will be used.
-
-PAPER_TYPE = a4wide
-
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
-# packages that should be included in the LaTeX output.
-
-EXTRA_PACKAGES =
-
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
-# the generated latex document. The header should contain everything until
-# the first chapter. If it is left blank doxygen will generate a
-# standard header. Notice: only use this tag if you know what you are doing!
-
-LATEX_HEADER =
-
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will
-# contain links (just like the HTML output) instead of page references
-# This makes the output suitable for online browsing using a pdf viewer.
-
-PDF_HYPERLINKS = NO
-
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
-# plain latex in the generated Makefile. Set this option to YES to get a
-# higher quality PDF documentation.
-
-USE_PDFLATEX = NO
-
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
-# command to the generated LaTeX files. This will instruct LaTeX to keep
-# running if errors occur, instead of asking the user for help.
-# This option is also used when generating formulas in HTML.
-
-LATEX_BATCHMODE = NO
-
-# If LATEX_HIDE_INDICES is set to YES then doxygen will not
-# include the index chapters (such as File Index, Compound Index, etc.)
-# in the output.
-
-LATEX_HIDE_INDICES = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
-# The RTF output is optimized for Word 97 and may not look very pretty with
-# other RTF readers or editors.
-
-GENERATE_RTF = NO
-
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `rtf' will be used as the default path.
-
-RTF_OUTPUT = rtf
-
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
-# RTF documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_RTF = NO
-
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
-# will contain hyperlink fields. The RTF file will
-# contain links (just like the HTML output) instead of page references.
-# This makes the output suitable for online browsing using WORD or other
-# programs which support those fields.
-# Note: wordpad (write) and others do not support links.
-
-RTF_HYPERLINKS = NO
-
-# Load stylesheet definitions from file. Syntax is similar to doxygen's
-# config file, i.e. a series of assignments. You only have to provide
-# replacements, missing definitions are set to their default value.
-
-RTF_STYLESHEET_FILE =
-
-# Set optional variables used in the generation of an rtf document.
-# Syntax is similar to doxygen's config file.
-
-RTF_EXTENSIONS_FILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
-# generate man pages
-
-GENERATE_MAN = NO
-
-# The MAN_OUTPUT tag is used to specify where the man pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `man' will be used as the default path.
-
-MAN_OUTPUT = man
-
-# The MAN_EXTENSION tag determines the extension that is added to
-# the generated man pages (default is the subroutine's section .3)
-
-MAN_EXTENSION = .3
-
-# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
-# then it will generate one additional man file for each entity
-# documented in the real man page(s). These additional files
-# only source the real man page, but without them the man command
-# would be unable to find the correct page. The default is NO.
-
-MAN_LINKS = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_XML tag is set to YES Doxygen will
-# generate an XML file that captures the structure of
-# the code including all documentation.
-
-GENERATE_XML = NO
-
-# The XML_OUTPUT tag is used to specify where the XML pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `xml' will be used as the default path.
-
-XML_OUTPUT = xml
-
-# The XML_SCHEMA tag can be used to specify an XML schema,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_SCHEMA =
-
-# The XML_DTD tag can be used to specify an XML DTD,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_DTD =
-
-# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
-# dump the program listings (including syntax highlighting
-# and cross-referencing information) to the XML output. Note that
-# enabling this will significantly increase the size of the XML output.
-
-XML_PROGRAMLISTING = YES
-
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
-# generate an AutoGen Definitions (see autogen.sf.net) file
-# that captures the structure of the code including all
-# documentation. Note that this feature is still experimental
-# and incomplete at the moment.
-
-GENERATE_AUTOGEN_DEF = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_PERLMOD tag is set to YES Doxygen will
-# generate a Perl module file that captures the structure of
-# the code including all documentation. Note that this
-# feature is still experimental and incomplete at the
-# moment.
-
-GENERATE_PERLMOD = NO
-
-# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
-# the necessary Makefile rules, Perl scripts and LaTeX code to be able
-# to generate PDF and DVI output from the Perl module output.
-
-PERLMOD_LATEX = NO
-
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
-# nicely formatted so it can be parsed by a human reader. This is useful
-# if you want to understand what is going on. On the other hand, if this
-# tag is set to NO the size of the Perl module output will be much smaller
-# and Perl will parse it just the same.
-
-PERLMOD_PRETTY = YES
-
-# The names of the make variables in the generated doxyrules.make file
-# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
-# This is useful so different doxyrules.make files included by the same
-# Makefile don't overwrite each other's variables.
-
-PERLMOD_MAKEVAR_PREFIX =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
-# evaluate all C-preprocessor directives found in the sources and include
-# files.
-
-ENABLE_PREPROCESSING = YES
-
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
-# names in the source code. If set to NO (the default) only conditional
-# compilation will be performed. Macro expansion can be done in a controlled
-# way by setting EXPAND_ONLY_PREDEF to YES.
-
-MACRO_EXPANSION = NO
-
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
-# then the macro expansion is limited to the macros specified with the
-# PREDEFINED and EXPAND_AS_PREDEFINED tags.
-
-EXPAND_ONLY_PREDEF = NO
-
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
-# in the INCLUDE_PATH (see below) will be search if a #include is found.
-
-SEARCH_INCLUDES = YES
-
-# The INCLUDE_PATH tag can be used to specify one or more directories that
-# contain include files that are not input files but should be processed by
-# the preprocessor.
-
-INCLUDE_PATH =
-
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
-# patterns (like *.h and *.hpp) to filter out the header-files in the
-# directories. If left blank, the patterns specified with FILE_PATTERNS will
-# be used.
-
-INCLUDE_FILE_PATTERNS =
-
-# The PREDEFINED tag can be used to specify one or more macro names that
-# are defined before the preprocessor is started (similar to the -D option of
-# gcc). The argument of the tag is a list of macros of the form: name
-# or name=definition (no spaces). If the definition and the = are
-# omitted =1 is assumed.
-
-PREDEFINED =
-
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
-# this tag can be used to specify a list of macro names that should be expanded.
-# The macro definition that is found in the sources will be used.
-# Use the PREDEFINED tag if you want to use a different macro definition.
-
-EXPAND_AS_DEFINED =
-
-# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
-# doxygen's preprocessor will remove all function-like macros that are alone
-# on a line, have an all uppercase name, and do not end with a semicolon. Such
-# function macros are typically used for boiler-plate code, and will confuse the
-# parser if not removed.
-
-SKIP_FUNCTION_MACROS = YES
-
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references
-#---------------------------------------------------------------------------
-
-# The TAGFILES option can be used to specify one or more tagfiles.
-# Optionally an initial location of the external documentation
-# can be added for each tagfile. The format of a tag file without
-# this location is as follows:
-# TAGFILES = file1 file2 ...
-# Adding location for the tag files is done as follows:
-# TAGFILES = file1=loc1 "file2 = loc2" ...
-# where "loc1" and "loc2" can be relative or absolute paths or
-# URLs. If a location is present for each tag, the installdox tool
-# does not have to be run to correct the links.
-# Note that each tag file must have a unique name
-# (where the name does NOT include the path)
-# If a tag file is not located in the directory in which doxygen
-# is run, you must also specify the path to the tagfile here.
-
-TAGFILES =
-
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create
-# a tag file that is based on the input files it reads.
-
-GENERATE_TAGFILE =
-
-# If the ALLEXTERNALS tag is set to YES all external classes will be listed
-# in the class index. If set to NO only the inherited external classes
-# will be listed.
-
-ALLEXTERNALS = NO
-
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
-# in the modules index. If set to NO, only the current project's groups will
-# be listed.
-
-EXTERNAL_GROUPS = YES
-
-# The PERL_PATH should be the absolute path and name of the perl script
-# interpreter (i.e. the result of `which perl').
-
-PERL_PATH = /usr/bin/perl
-
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-
-# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or
-# super classes. Setting the tag to NO turns the diagrams off. Note that this
-# option is superseded by the HAVE_DOT option below. This is only a fallback. It is
-# recommended to install and use dot, since it yields more powerful graphs.
-
-CLASS_DIAGRAMS = YES
-
-# If set to YES, the inheritance and collaboration graphs will hide
-# inheritance and usage relations if the target is undocumented
-# or is not a class.
-
-HIDE_UNDOC_RELATIONS = YES
-
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
-# available from the path. This tool is part of Graphviz, a graph visualization
-# toolkit from AT&T and Lucent Bell Labs. The other options in this section
-# have no effect if this option is set to NO (the default)
-
-HAVE_DOT = NO
-
-# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect inheritance relations. Setting this tag to YES will force the
-# the CLASS_DIAGRAMS tag to NO.
-
-CLASS_GRAPH = YES
-
-# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect implementation dependencies (inheritance, containment, and
-# class references variables) of the class with other documented classes.
-
-COLLABORATION_GRAPH = YES
-
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
-# collaboration diagrams in a style similar to the OMG's Unified Modeling
-# Language.
-
-UML_LOOK = NO
-
-# If set to YES, the inheritance and collaboration graphs will show the
-# relations between templates and their instances.
-
-TEMPLATE_RELATIONS = NO
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
-# tags are set to YES then doxygen will generate a graph for each documented
-# file showing the direct and indirect include dependencies of the file with
-# other documented files.
-
-INCLUDE_GRAPH = YES
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
-# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
-# documented header file showing the documented files that directly or
-# indirectly include this file.
-
-INCLUDED_BY_GRAPH = YES
-
-# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will
-# generate a call dependency graph for every global function or class method.
-# Note that enabling this option will significantly increase the time of a run.
-# So in most cases it will be better to enable call graphs for selected
-# functions only using the \callgraph command.
-
-CALL_GRAPH = NO
-
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
-# will graphical hierarchy of all classes instead of a textual one.
-
-GRAPHICAL_HIERARCHY = YES
-
-# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
-# generated by dot. Possible values are png, jpg, or gif
-# If left blank png will be used.
-
-DOT_IMAGE_FORMAT = png
-
-# The tag DOT_PATH can be used to specify the path where the dot tool can be
-# found. If left blank, it is assumed the dot tool can be found on the path.
-
-DOT_PATH =
-
-# The DOTFILE_DIRS tag can be used to specify one or more directories that
-# contain dot files that are included in the documentation (see the
-# \dotfile command).
-
-DOTFILE_DIRS =
-
-# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
-# (in pixels) of the graphs generated by dot. If a graph becomes larger than
-# this value, doxygen will try to truncate the graph, so that it fits within
-# the specified constraint. Beware that most browsers cannot cope with very
-# large images.
-
-MAX_DOT_GRAPH_WIDTH = 1024
-
-# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
-# (in pixels) of the graphs generated by dot. If a graph becomes larger than
-# this value, doxygen will try to truncate the graph, so that it fits within
-# the specified constraint. Beware that most browsers cannot cope with very
-# large images.
-
-MAX_DOT_GRAPH_HEIGHT = 1024
-
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
-# graphs generated by dot. A depth value of 3 means that only nodes reachable
-# from the root by following a path via at most 3 edges will be shown. Nodes that
-# lay further from the root node will be omitted. Note that setting this option to
-# 1 or 2 may greatly reduce the computation time needed for large code bases. Also
-# note that a graph may be further truncated if the graph's image dimensions are
-# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT).
-# If 0 is used for the depth value (the default), the graph is not depth-constrained.
-
-MAX_DOT_GRAPH_DEPTH = 0
-
-# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
-# generate a legend page explaining the meaning of the various boxes and
-# arrows in the dot generated graphs.
-
-GENERATE_LEGEND = YES
-
-# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
-# remove the intermediate dot files that are used to generate
-# the various graphs.
-
-DOT_CLEANUP = YES
-
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine
-#---------------------------------------------------------------------------
-
-# The SEARCHENGINE tag specifies whether or not a search engine should be
-# used. If set to NO the values of all tags below this one will be ignored.
-
-SEARCHENGINE = NO
diff --git a/source4/lib/json/INSTALL b/source4/lib/json/INSTALL
deleted file mode 100644
index a4b34144dc..0000000000
--- a/source4/lib/json/INSTALL
+++ /dev/null
@@ -1,229 +0,0 @@
-Copyright 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
-Foundation, Inc.
-
- This file is free documentation; the Free Software Foundation gives
-unlimited permission to copy, distribute and modify it.
-
-Basic Installation
-==================
-
- These are generic installation instructions.
-
- The `configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation. It uses
-those values to create a `Makefile' in each directory of the package.
-It may also create one or more `.h' files containing system-dependent
-definitions. Finally, it creates a shell script `config.status' that
-you can run in the future to recreate the current configuration, and a
-file `config.log' containing compiler output (useful mainly for
-debugging `configure').
-
- It can also use an optional file (typically called `config.cache'
-and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring. (Caching is
-disabled by default to prevent problems with accidental use of stale
-cache files.)
-
- If you need to do unusual things to compile the package, please try
-to figure out how `configure' could check whether to do them, and mail
-diffs or instructions to the address given in the `README' so they can
-be considered for the next release. If you are using the cache, and at
-some point `config.cache' contains results you don't want to keep, you
-may remove or edit it.
-
- The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'. You only need
-`configure.ac' if you want to change it or regenerate `configure' using
-a newer version of `autoconf'.
-
-The simplest way to compile this package is:
-
- 1. `cd' to the directory containing the package's source code and type
- `./configure' to configure the package for your system. If you're
- using `csh' on an old version of System V, you might need to type
- `sh ./configure' instead to prevent `csh' from trying to execute
- `configure' itself.
-
- Running `configure' takes awhile. While running, it prints some
- messages telling which features it is checking for.
-
- 2. Type `make' to compile the package.
-
- 3. Optionally, type `make check' to run any self-tests that come with
- the package.
-
- 4. Type `make install' to install the programs and any data files and
- documentation.
-
- 5. You can remove the program binaries and object files from the
- source code directory by typing `make clean'. To also remove the
- files that `configure' created (so you can compile the package for
- a different kind of computer), type `make distclean'. There is
- also a `make maintainer-clean' target, but that is intended mainly
- for the package's developers. If you use it, you may have to get
- all sorts of other programs in order to regenerate files that came
- with the distribution.
-
-Compilers and Options
-=====================
-
- Some systems require unusual options for compilation or linking that
-the `configure' script does not know about. Run `./configure --help'
-for details on some of the pertinent environment variables.
-
- You can give `configure' initial values for configuration parameters
-by setting variables in the command line or in the environment. Here
-is an example:
-
- ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
-
- *Note Defining Variables::, for more details.
-
-Compiling For Multiple Architectures
-====================================
-
- You can compile the package for more than one kind of computer at the
-same time, by placing the object files for each architecture in their
-own directory. To do this, you must use a version of `make' that
-supports the `VPATH' variable, such as GNU `make'. `cd' to the
-directory where you want the object files and executables to go and run
-the `configure' script. `configure' automatically checks for the
-source code in the directory that `configure' is in and in `..'.
-
- If you have to use a `make' that does not support the `VPATH'
-variable, you have to compile the package for one architecture at a
-time in the source code directory. After you have installed the
-package for one architecture, use `make distclean' before reconfiguring
-for another architecture.
-
-Installation Names
-==================
-
- By default, `make install' will install the package's files in
-`/usr/local/bin', `/usr/local/man', etc. You can specify an
-installation prefix other than `/usr/local' by giving `configure' the
-option `--prefix=PATH'.
-
- You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files. If you
-give `configure' the option `--exec-prefix=PATH', the package will use
-PATH as the prefix for installing programs and libraries.
-Documentation and other data files will still use the regular prefix.
-
- In addition, if you use an unusual directory layout you can give
-options like `--bindir=PATH' to specify different values for particular
-kinds of files. Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them.
-
- If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving `configure' the
-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
-
-Optional Features
-=================
-
- Some packages pay attention to `--enable-FEATURE' options to
-`configure', where FEATURE indicates an optional part of the package.
-They may also pay attention to `--with-PACKAGE' options, where PACKAGE
-is something like `gnu-as' or `x' (for the X Window System). The
-`README' should mention any `--enable-' and `--with-' options that the
-package recognizes.
-
- For packages that use the X Window System, `configure' can usually
-find the X include and library files automatically, but if it doesn't,
-you can use the `configure' options `--x-includes=DIR' and
-`--x-libraries=DIR' to specify their locations.
-
-Specifying the System Type
-==========================
-
- There may be some features `configure' cannot figure out
-automatically, but needs to determine by the type of machine the package
-will run on. Usually, assuming the package is built to be run on the
-_same_ architectures, `configure' can figure that out, but if it prints
-a message saying it cannot guess the machine type, give it the
-`--build=TYPE' option. TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name which has the form:
-
- CPU-COMPANY-SYSTEM
-
-where SYSTEM can have one of these forms:
-
- OS KERNEL-OS
-
- See the file `config.sub' for the possible values of each field. If
-`config.sub' isn't included in this package, then this package doesn't
-need to know the machine type.
-
- If you are _building_ compiler tools for cross-compiling, you should
-use the `--target=TYPE' option to select the type of system they will
-produce code for.
-
- If you want to _use_ a cross compiler, that generates code for a
-platform different from the build platform, you should specify the
-"host" platform (i.e., that on which the generated programs will
-eventually be run) with `--host=TYPE'.
-
-Sharing Defaults
-================
-
- If you want to set default values for `configure' scripts to share,
-you can create a site shell script called `config.site' that gives
-default values for variables like `CC', `cache_file', and `prefix'.
-`configure' looks for `PREFIX/share/config.site' if it exists, then
-`PREFIX/etc/config.site' if it exists. Or, you can set the
-`CONFIG_SITE' environment variable to the location of the site script.
-A warning: not all `configure' scripts look for a site script.
-
-Defining Variables
-==================
-
- Variables not defined in a site shell script can be set in the
-environment passed to `configure'. However, some packages may run
-configure again during the build, and the customized values of these
-variables may be lost. In order to avoid this problem, you should set
-them in the `configure' command line, using `VAR=value'. For example:
-
- ./configure CC=/usr/local2/bin/gcc
-
-will cause the specified gcc to be used as the C compiler (unless it is
-overridden in the site shell script).
-
-`configure' Invocation
-======================
-
- `configure' recognizes the following options to control how it
-operates.
-
-`--help'
-`-h'
- Print a summary of the options to `configure', and exit.
-
-`--version'
-`-V'
- Print the version of Autoconf used to generate the `configure'
- script, and exit.
-
-`--cache-file=FILE'
- Enable the cache: use and save the results of the tests in FILE,
- traditionally `config.cache'. FILE defaults to `/dev/null' to
- disable caching.
-
-`--config-cache'
-`-C'
- Alias for `--cache-file=config.cache'.
-
-`--quiet'
-`--silent'
-`-q'
- Do not print messages saying which checks are being made. To
- suppress all normal output, redirect it to `/dev/null' (any error
- messages will still be shown).
-
-`--srcdir=DIR'
- Look for the package's source code in directory DIR. Usually
- `configure' can determine that directory automatically.
-
-`configure' also accepts some other, not widely useful, options. Run
-`configure --help' for more details.
-
diff --git a/source4/lib/json/Makefile.am b/source4/lib/json/Makefile.am
deleted file mode 100644
index 4b01dc16bf..0000000000
--- a/source4/lib/json/Makefile.am
+++ /dev/null
@@ -1,36 +0,0 @@
-CFLAGS = -Wall -std=gnu99 -D_GNU_SOURCE -D_REENTRANT
-
-lib_LTLIBRARIES = libjson.la
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = json.pc
-
-libjsonincludedir = $(includedir)/json
-libjsoninclude_HEADERS = \
- json.h \
- bits.h \
- debug.h \
- linkhash.h \
- arraylist.h \
- json_util.h \
- json_object.h \
- json_tokener.h
-
-libjson_la_LDFLAGS = -version-info 0:1:0
-
-libjson_la_SOURCES = \
- arraylist.c \
- debug.c \
- json_object.c \
- json_tokener.c \
- json_util.c \
- linkhash.c \
- printbuf.c
-
-check_PROGRAMS = test1 test2
-
-test1_SOURCES = test1.c
-test1_LDADD = $(lib_LTLIBRARIES)
-
-test2_SOURCES = test2.c
-test2_LDADD = $(lib_LTLIBRARIES)
diff --git a/source4/lib/json/Makefile.in b/source4/lib/json/Makefile.in
deleted file mode 100644
index f135701e14..0000000000
--- a/source4/lib/json/Makefile.in
+++ /dev/null
@@ -1,533 +0,0 @@
-# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
-
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-
-SHELL = @SHELL@
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-
-top_builddir = .
-
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-host_alias = @host_alias@
-host_triplet = @host@
-AR = @AR@
-AS = @AS@
-CC = @CC@
-CXX = @CXX@
-CXXCPP = @CXXCPP@
-DLLTOOL = @DLLTOOL@
-ECHO = @ECHO@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
-F77 = @F77@
-GCJ = @GCJ@
-GCJFLAGS = @GCJFLAGS@
-HAVE_LIB = @HAVE_LIB@
-LIB = @LIB@
-LIBTOOL = @LIBTOOL@
-LN_S = @LN_S@
-LTLIB = @LTLIB@
-MAKEINFO = @MAKEINFO@
-OBJDUMP = @OBJDUMP@
-OBJEXT = @OBJEXT@
-PACKAGE = @PACKAGE@
-RANLIB = @RANLIB@
-RC = @RC@
-STRIP = @STRIP@
-VERSION = @VERSION@
-
-CFLAGS = -Wall -std=gnu99 -D_GNU_SOURCE -D_REENTRANT
-
-lib_LTLIBRARIES = libjson.la
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = json.pc
-
-libjsonincludedir = $(includedir)/json
-libjsoninclude_HEADERS = json.h bits.h debug.h linkhash.h arraylist.h json_util.h json_object.h json_tokener.h
-
-
-libjson_la_LDFLAGS = -version-info 0:1:0
-
-libjson_la_SOURCES = arraylist.c debug.c json_object.c json_tokener.c json_util.c linkhash.c printbuf.c
-
-
-check_PROGRAMS = test1 test2
-
-test1_SOURCES = test1.c
-test1_LDADD = $(lib_LTLIBRARIES)
-
-test2_SOURCES = test2.c
-test2_LDADD = $(lib_LTLIBRARIES)
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = config.h
-CONFIG_CLEAN_FILES = json.pc
-LTLIBRARIES = $(lib_LTLIBRARIES)
-
-
-DEFS = @DEFS@ -I. -I$(srcdir) -I.
-CPPFLAGS = @CPPFLAGS@
-LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
-libjson_la_LIBADD =
-libjson_la_OBJECTS = arraylist.lo debug.lo json_object.lo \
-json_tokener.lo json_util.lo linkhash.lo printbuf.lo
-check_PROGRAMS = test1$(EXEEXT) test2$(EXEEXT)
-test1_OBJECTS = test1.$(OBJEXT)
-test1_DEPENDENCIES = libjson.la
-test1_LDFLAGS =
-test2_OBJECTS = test2.$(OBJEXT)
-test2_DEPENDENCIES = libjson.la
-test2_LDFLAGS =
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-CCLD = $(CC)
-LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
-DATA = $(pkgconfig_DATA)
-
-HEADERS = $(libjsoninclude_HEADERS)
-
-DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \
-Makefile.am Makefile.in NEWS aclocal.m4 config.guess config.h.in \
-config.sub configure configure.in install-sh json.pc.in ltmain.sh \
-missing mkinstalldirs
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = tar
-GZIP_ENV = --best
-DEP_FILES = .deps/arraylist.P .deps/debug.P .deps/json_object.P \
-.deps/json_tokener.P .deps/json_util.P .deps/linkhash.P \
-.deps/printbuf.P .deps/test1.P .deps/test2.P
-SOURCES = $(libjson_la_SOURCES) $(test1_SOURCES) $(test2_SOURCES)
-OBJECTS = $(libjson_la_OBJECTS) $(test1_OBJECTS) $(test2_OBJECTS)
-
-all: all-redirect
-.SUFFIXES:
-.SUFFIXES: .S .c .lo .o .obj .s
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
- cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile
-
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
- cd $(top_builddir) \
- && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-$(ACLOCAL_M4): configure.in
- cd $(srcdir) && $(ACLOCAL)
-
-config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
- $(SHELL) ./config.status --recheck
-$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
- cd $(srcdir) && $(AUTOCONF)
-
-config.h: stamp-h
- @if test ! -f $@; then \
- rm -f stamp-h; \
- $(MAKE) stamp-h; \
- else :; fi
-stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status
- cd $(top_builddir) \
- && CONFIG_FILES= CONFIG_HEADERS=config.h \
- $(SHELL) ./config.status
- @echo timestamp > stamp-h 2> /dev/null
-$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
- @if test ! -f $@; then \
- rm -f $(srcdir)/stamp-h.in; \
- $(MAKE) $(srcdir)/stamp-h.in; \
- else :; fi
-$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4)
- cd $(top_srcdir) && $(AUTOHEADER)
- @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null
-
-mostlyclean-hdr:
-
-clean-hdr:
-
-distclean-hdr:
- -rm -f config.h
-
-maintainer-clean-hdr:
-json.pc: $(top_builddir)/config.status json.pc.in
- cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-mostlyclean-libLTLIBRARIES:
-
-clean-libLTLIBRARIES:
- -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
-
-distclean-libLTLIBRARIES:
-
-maintainer-clean-libLTLIBRARIES:
-
-install-libLTLIBRARIES: $(lib_LTLIBRARIES)
- @$(NORMAL_INSTALL)
- $(mkinstalldirs) $(DESTDIR)$(libdir)
- @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
- if test -f $$p; then \
- echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
- $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
- else :; fi; \
- done
-
-uninstall-libLTLIBRARIES:
- @$(NORMAL_UNINSTALL)
- list='$(lib_LTLIBRARIES)'; for p in $$list; do \
- $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
- done
-
-# FIXME: We should only use cygpath when building on Windows,
-# and only if it is available.
-.c.obj:
- $(COMPILE) -c `cygpath -w $<`
-
-.s.o:
- $(COMPILE) -c $<
-
-.S.o:
- $(COMPILE) -c $<
-
-mostlyclean-compile:
- -rm -f *.o core *.core
- -rm -f *.$(OBJEXT)
-
-clean-compile:
-
-distclean-compile:
- -rm -f *.tab.c
-
-maintainer-clean-compile:
-
-.s.lo:
- $(LIBTOOL) --mode=compile $(COMPILE) -c $<
-
-.S.lo:
- $(LIBTOOL) --mode=compile $(COMPILE) -c $<
-
-mostlyclean-libtool:
- -rm -f *.lo
-
-clean-libtool:
- -rm -rf .libs _libs
-
-distclean-libtool:
-
-maintainer-clean-libtool:
-
-libjson.la: $(libjson_la_OBJECTS) $(libjson_la_DEPENDENCIES)
- $(LINK) -rpath $(libdir) $(libjson_la_LDFLAGS) $(libjson_la_OBJECTS) $(libjson_la_LIBADD) $(LIBS)
-
-mostlyclean-checkPROGRAMS:
-
-clean-checkPROGRAMS:
- -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
-
-distclean-checkPROGRAMS:
-
-maintainer-clean-checkPROGRAMS:
-
-test1$(EXEEXT): $(test1_OBJECTS) $(test1_DEPENDENCIES)
- @rm -f test1$(EXEEXT)
- $(LINK) $(test1_LDFLAGS) $(test1_OBJECTS) $(test1_LDADD) $(LIBS)
-
-test2$(EXEEXT): $(test2_OBJECTS) $(test2_DEPENDENCIES)
- @rm -f test2$(EXEEXT)
- $(LINK) $(test2_LDFLAGS) $(test2_OBJECTS) $(test2_LDADD) $(LIBS)
-
-install-pkgconfigDATA: $(pkgconfig_DATA)
- @$(NORMAL_INSTALL)
- $(mkinstalldirs) $(DESTDIR)$(pkgconfigdir)
- @list='$(pkgconfig_DATA)'; for p in $$list; do \
- if test -f $(srcdir)/$$p; then \
- echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(pkgconfigdir)/$$p"; \
- $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(pkgconfigdir)/$$p; \
- else if test -f $$p; then \
- echo " $(INSTALL_DATA) $$p $(DESTDIR)$(pkgconfigdir)/$$p"; \
- $(INSTALL_DATA) $$p $(DESTDIR)$(pkgconfigdir)/$$p; \
- fi; fi; \
- done
-
-uninstall-pkgconfigDATA:
- @$(NORMAL_UNINSTALL)
- list='$(pkgconfig_DATA)'; for p in $$list; do \
- rm -f $(DESTDIR)$(pkgconfigdir)/$$p; \
- done
-
-install-libjsonincludeHEADERS: $(libjsoninclude_HEADERS)
- @$(NORMAL_INSTALL)
- $(mkinstalldirs) $(DESTDIR)$(libjsonincludedir)
- @list='$(libjsoninclude_HEADERS)'; for p in $$list; do \
- if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
- echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(libjsonincludedir)/$$p"; \
- $(INSTALL_DATA) $$d$$p $(DESTDIR)$(libjsonincludedir)/$$p; \
- done
-
-uninstall-libjsonincludeHEADERS:
- @$(NORMAL_UNINSTALL)
- list='$(libjsoninclude_HEADERS)'; for p in $$list; do \
- rm -f $(DESTDIR)$(libjsonincludedir)/$$p; \
- done
-
-tags: TAGS
-
-ID: $(HEADERS) $(SOURCES) $(LISP)
- list='$(SOURCES) $(HEADERS)'; \
- unique=`for i in $$list; do echo $$i; done | \
- awk ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- here=`pwd` && cd $(srcdir) \
- && mkid -f$$here/ID $$unique $(LISP)
-
-TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP)
- tags=; \
- here=`pwd`; \
- list='$(SOURCES) $(HEADERS)'; \
- unique=`for i in $$list; do echo $$i; done | \
- awk ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \
- || (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP))
-
-mostlyclean-tags:
-
-clean-tags:
-
-distclean-tags:
- -rm -f TAGS ID
-
-maintainer-clean-tags:
-
-distdir = $(PACKAGE)-$(VERSION)
-top_distdir = $(distdir)
-
-# This target untars the dist file and tries a VPATH configuration. Then
-# it guarantees that the distribution is self-contained by making another
-# tarfile.
-distcheck: dist
- -rm -rf $(distdir)
- GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
- mkdir $(distdir)/=build
- mkdir $(distdir)/=inst
- dc_install_base=`cd $(distdir)/=inst && pwd`; \
- cd $(distdir)/=build \
- && ../configure --srcdir=.. --prefix=$$dc_install_base \
- && $(MAKE) $(AM_MAKEFLAGS) \
- && $(MAKE) $(AM_MAKEFLAGS) dvi \
- && $(MAKE) $(AM_MAKEFLAGS) check \
- && $(MAKE) $(AM_MAKEFLAGS) install \
- && $(MAKE) $(AM_MAKEFLAGS) installcheck \
- && $(MAKE) $(AM_MAKEFLAGS) dist
- -rm -rf $(distdir)
- @banner="$(distdir).tar.gz is ready for distribution"; \
- dashes=`echo "$$banner" | sed s/./=/g`; \
- echo "$$dashes"; \
- echo "$$banner"; \
- echo "$$dashes"
-dist: distdir
- -chmod -R a+r $(distdir)
- GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
- -rm -rf $(distdir)
-dist-all: distdir
- -chmod -R a+r $(distdir)
- GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
- -rm -rf $(distdir)
-distdir: $(DISTFILES)
- -rm -rf $(distdir)
- mkdir $(distdir)
- -chmod 777 $(distdir)
- here=`cd $(top_builddir) && pwd`; \
- top_distdir=`cd $(distdir) && pwd`; \
- distdir=`cd $(distdir) && pwd`; \
- cd $(top_srcdir) \
- && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Makefile
- @for file in $(DISTFILES); do \
- d=$(srcdir); \
- if test -d $$d/$$file; then \
- cp -pr $$d/$$file $(distdir)/$$file; \
- else \
- test -f $(distdir)/$$file \
- || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
- || cp -p $$d/$$file $(distdir)/$$file || :; \
- fi; \
- done
-
-DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
-
--include $(DEP_FILES)
-
-mostlyclean-depend:
-
-clean-depend:
-
-distclean-depend:
- -rm -rf .deps
-
-maintainer-clean-depend:
-
-%.o: %.c
- @echo '$(COMPILE) -c $<'; \
- $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
- @-cp .deps/$(*F).pp .deps/$(*F).P; \
- tr ' ' '\012' < .deps/$(*F).pp \
- | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
- >> .deps/$(*F).P; \
- rm .deps/$(*F).pp
-
-%.lo: %.c
- @echo '$(LTCOMPILE) -c $<'; \
- $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
- @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
- < .deps/$(*F).pp > .deps/$(*F).P; \
- tr ' ' '\012' < .deps/$(*F).pp \
- | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
- >> .deps/$(*F).P; \
- rm -f .deps/$(*F).pp
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
-check-am: all-am
- $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-check: check-am
-installcheck-am:
-installcheck: installcheck-am
-all-recursive-am: config.h
- $(MAKE) $(AM_MAKEFLAGS) all-recursive
-
-install-exec-am: install-libLTLIBRARIES
-install-exec: install-exec-am
-
-install-data-am: install-pkgconfigDATA install-libjsonincludeHEADERS
-install-data: install-data-am
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am: uninstall-libLTLIBRARIES uninstall-pkgconfigDATA \
- uninstall-libjsonincludeHEADERS
-uninstall: uninstall-am
-all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS) config.h
-all-redirect: all-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
- $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(pkgconfigdir) \
- $(DESTDIR)$(libjsonincludedir)
-
-
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
- -rm -f Makefile $(CONFIG_CLEAN_FILES)
- -rm -f config.cache config.log stamp-h stamp-h[0-9]*
-
-maintainer-clean-generic:
-mostlyclean-am: mostlyclean-hdr mostlyclean-libLTLIBRARIES \
- mostlyclean-compile mostlyclean-libtool \
- mostlyclean-checkPROGRAMS mostlyclean-tags \
- mostlyclean-depend mostlyclean-generic
-
-mostlyclean: mostlyclean-am
-
-clean-am: clean-hdr clean-libLTLIBRARIES clean-compile clean-libtool \
- clean-checkPROGRAMS clean-tags clean-depend \
- clean-generic mostlyclean-am
-
-clean: clean-am
-
-distclean-am: distclean-hdr distclean-libLTLIBRARIES distclean-compile \
- distclean-libtool distclean-checkPROGRAMS \
- distclean-tags distclean-depend distclean-generic \
- clean-am
- -rm -f libtool
-
-distclean: distclean-am
- -rm -f config.status
-
-maintainer-clean-am: maintainer-clean-hdr \
- maintainer-clean-libLTLIBRARIES \
- maintainer-clean-compile maintainer-clean-libtool \
- maintainer-clean-checkPROGRAMS maintainer-clean-tags \
- maintainer-clean-depend maintainer-clean-generic \
- distclean-am
- @echo "This command is intended for maintainers to use;"
- @echo "it deletes files that may require special tools to rebuild."
-
-maintainer-clean: maintainer-clean-am
- -rm -f config.status
-
-.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
-mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \
-clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \
-uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \
-distclean-compile clean-compile maintainer-clean-compile \
-mostlyclean-libtool distclean-libtool clean-libtool \
-maintainer-clean-libtool mostlyclean-checkPROGRAMS \
-distclean-checkPROGRAMS clean-checkPROGRAMS \
-maintainer-clean-checkPROGRAMS uninstall-pkgconfigDATA \
-install-pkgconfigDATA uninstall-libjsonincludeHEADERS \
-install-libjsonincludeHEADERS tags mostlyclean-tags distclean-tags \
-clean-tags maintainer-clean-tags distdir mostlyclean-depend \
-distclean-depend clean-depend maintainer-clean-depend info-am info \
-dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \
-install-exec-am install-exec install-data-am install-data install-am \
-install uninstall-am uninstall all-redirect all-am all installdirs \
-mostlyclean-generic distclean-generic clean-generic \
-maintainer-clean-generic clean mostlyclean distclean maintainer-clean
-
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/source4/lib/json/NEWS b/source4/lib/json/NEWS
deleted file mode 100644
index 41e843b5a5..0000000000
--- a/source4/lib/json/NEWS
+++ /dev/null
@@ -1 +0,0 @@
-News
diff --git a/source4/lib/json/README b/source4/lib/json/README
deleted file mode 100644
index beeba53d5f..0000000000
--- a/source4/lib/json/README
+++ /dev/null
@@ -1,20 +0,0 @@
-Building on Unix with gcc and autotools
-
-If checking out from CVS:
-
- sh autogen.sh
-
-Then configure, make, make install
-
-
-Test programs
-
-To build the test programs run 'make check'
-
-
-Linking to libjson
-
-If your system has pkgconfig then you can just add this to your makefile
-
-CFLAGS += $(shell pkg-config --cflags json)
-LDFLAGS += $(shell pkg-config --libs json)
diff --git a/source4/lib/json/README-WIN32.html b/source4/lib/json/README-WIN32.html
deleted file mode 100644
index fb50159819..0000000000
--- a/source4/lib/json/README-WIN32.html
+++ /dev/null
@@ -1,61 +0,0 @@
-<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <title>JSON-C - A JSON implementation in C - Win32 specific notes</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- </head>
- <body>
- <h2>Windows specific notes for JSON-C</h2>
- <p>Please send Win32 bug reports to <a href="mailto:christopher.watford@gmail.com">christopher.watford@gmail.com</a></p>
- <p><b>Win32 Specific Changes:</b></p>
- <ul>
- <li>
- Various functions have been redefined to their Win32 version (i.e. <tt>open</tt>
- on win32 is <tt>_open</tt>)</li>
- <li>
- Implemented missing functions from MS's libc (i.e. <tt>vasprintf</tt> and <tt>strndup</tt>)</li>
- <li>
- Added code to allow Win64 support without integer resizing issues, this
- probably makes it much nicer on 64bit machines everywhere (i.e. using <tt>ptrdiff_t</tt>
- for pointer math)</li>
- </ul>
- <p><b>Porting Changelog:</b></p>
- <dl>
- <dt><tt>printbuf.c</tt> - C. Watford (christopher.watford@gmail.com)</dt>
- <dd>
- Added a Win32/Win64 compliant implementation of <tt>vasprintf</tt></dd>
- <dt><tt>debug.c</tt> - C. Watford (christopher.watford@gmail.com)</dt>
- <dd>
- Removed usage of <tt>vsyslog</tt> on Win32/Win64 systems, needs to be handled
- by a configure script</dd>
- <dt><tt>json_object.c</tt> - C. Watford (christopher.watford@gmail.com)</dt>
- <dd>
- Added scope operator to wrap usage of <tt>json_object_object_foreach</tt>, this needs to be
- rethought to be more ANSI C friendly</dd>
- <dt><tt>json_object.h</tt> - C. Watford (christopher.watford@gmail.com)</dt>
- <dd>
- Added Microsoft C friendly version of <tt>json_object_object_foreach</tt></dd>
- <dt><tt>json_tokener.c</tt> - C. Watford (christopher.watford@gmail.com)</dt>
- <dd>
- Added a Win32/Win64 compliant implementation of <tt>strndup</tt></dd>
- <dt><tt>json_util.c</tt> - C. Watford (christopher.watford@gmail.com)</dt>
- <dd>
- Added cast and mask to suffice <tt>size_t</tt> v. <tt>unsigned int</tt>
- conversion correctness</dd>
- </dl>
- <h3>Anonymous CVS</h3>
- <p><code># <b>export CVSROOT=:pserver:anoncvs@cvs.metaparadigm.com:/cvsroot</b><br />
- # <b>cvs login</b><br />
- Logging in to :pserver:anoncvs@cvs.metaparadigm.com:2401/cvsroot<br />
- CVS password: &lt;enter '<b>anoncvs</b>'&gt;<br />
- # <b>cvs co json-c</b></code></p>
- <p>Copyright Metaparadigm Pte. Ltd. 2004, 2005. <a href="mailto:michael@metaparadigm.com">Michael
- Clark </a>
- </p>
- <p>This program is free software; you can redistribute it and/or modify it under
- the terms of the MIT License. See COPYING for details.</p>
- <hr />
- </body>
-</html>
diff --git a/source4/lib/json/README.html b/source4/lib/json/README.html
deleted file mode 100644
index 7b3a65ebe9..0000000000
--- a/source4/lib/json/README.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <title>JSON-C - A JSON implementation in C</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- </head>
- <body>
- <h2>JSON-C - A JSON implementation in C</h2>
- <p>Latest release: <a href="json-c-0.6.tar.gz">json-c-0.6.tar.gz</a></p>
- <p>JSON-C implements a reference counting object model that allows you to easily
- construct JSON objects in C, output them as JSON formatted strings and parse
- JSON formatted strings back into the C representation of JSON objects.</p>
- <p>Minimal documentation exists <a href="doc/html/json__object_8h.html">here</a>,
- Although you are probably better reading the example code in test1.c.</p>
- <p>To setup JSON-C to build on your system please run <tt>configure</tt> before
- compiling. If you are on Win32 and are not using the VS project file, be sure
- to rename <tt>config.h.win32</tt> to <tt>config.h</tt> before building.</p>
- <P>Win32 specific notes can be found <a href="README-WIN32.html">here</a>.</P>
- <p>Please send bug reports to <a href="mailto:michael@metaparadigm.com">michael@metaparadigm.com</a></p>
- <p>Please send Win32 bug reports to <a href="mailto:christopher.watford@gmail.com">christopher.watford@gmail.com</a></p>
- <h3>Anonymous CVS</h3>
- <p><code># <b>export CVSROOT=:pserver:anoncvs@cvs.metaparadigm.com:/cvsroot</b><br>
- # <b>cvs login</b><br>
- Logging in to :pserver:anoncvs@cvs.metaparadigm.com:2401/cvsroot<br>
- CVS password: &lt;enter '<b>anoncvs</b>'&gt;<br>
- # <b>cvs co json-c</b></code></p>
- <p>Copyright Metaparadigm Pte. Ltd. 2004, 2005. <a href="mailto:michael@metaparadigm.com">Michael
- Clark </a>
- </p>
- <p>This program is free software; you can redistribute it and/or modify it under
- the terms of the MIT License. See COPYING for details.</p>
- <hr>
- </body>
-</html>
diff --git a/source4/lib/json/aclocal.m4 b/source4/lib/json/aclocal.m4
deleted file mode 100644
index 6f6764ecad..0000000000
--- a/source4/lib/json/aclocal.m4
+++ /dev/null
@@ -1,7379 +0,0 @@
-dnl aclocal.m4t generated automatically by aclocal 1.4-p6
-
-dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-dnl PARTICULAR PURPOSE.
-
-# lib-prefix.m4 serial 4 (gettext-0.14.2)
-dnl Copyright (C) 2001-2005 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Bruno Haible.
-
-dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
-dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
-dnl require excessive bracketing.
-ifdef([AC_HELP_STRING],
-[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
-[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
-
-dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
-dnl to access previously installed libraries. The basic assumption is that
-dnl a user will want packages to use other packages he previously installed
-dnl with the same --prefix option.
-dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
-dnl libraries, but is otherwise very convenient.
-AC_DEFUN([AC_LIB_PREFIX],
-[
- AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
- AC_REQUIRE([AC_PROG_CC])
- AC_REQUIRE([AC_CANONICAL_HOST])
- AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
- dnl By default, look in $includedir and $libdir.
- use_additional=yes
- AC_LIB_WITH_FINAL_PREFIX([
- eval additional_includedir=\"$includedir\"
- eval additional_libdir=\"$libdir\"
- ])
- AC_LIB_ARG_WITH([lib-prefix],
-[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
- --without-lib-prefix don't search for libraries in includedir and libdir],
-[
- if test "X$withval" = "Xno"; then
- use_additional=no
- else
- if test "X$withval" = "X"; then
- AC_LIB_WITH_FINAL_PREFIX([
- eval additional_includedir=\"$includedir\"
- eval additional_libdir=\"$libdir\"
- ])
- else
- additional_includedir="$withval/include"
- additional_libdir="$withval/lib"
- fi
- fi
-])
- if test $use_additional = yes; then
- dnl Potentially add $additional_includedir to $CPPFLAGS.
- dnl But don't add it
- dnl 1. if it's the standard /usr/include,
- dnl 2. if it's already present in $CPPFLAGS,
- dnl 3. if it's /usr/local/include and we are using GCC on Linux,
- dnl 4. if it doesn't exist as a directory.
- if test "X$additional_includedir" != "X/usr/include"; then
- haveit=
- for x in $CPPFLAGS; do
- AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
- if test "X$x" = "X-I$additional_includedir"; then
- haveit=yes
- break
- fi
- done
- if test -z "$haveit"; then
- if test "X$additional_includedir" = "X/usr/local/include"; then
- if test -n "$GCC"; then
- case $host_os in
- linux* | gnu* | k*bsd*-gnu) haveit=yes;;
- esac
- fi
- fi
- if test -z "$haveit"; then
- if test -d "$additional_includedir"; then
- dnl Really add $additional_includedir to $CPPFLAGS.
- CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
- fi
- fi
- fi
- fi
- dnl Potentially add $additional_libdir to $LDFLAGS.
- dnl But don't add it
- dnl 1. if it's the standard /usr/lib,
- dnl 2. if it's already present in $LDFLAGS,
- dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
- dnl 4. if it doesn't exist as a directory.
- if test "X$additional_libdir" != "X/usr/lib"; then
- haveit=
- for x in $LDFLAGS; do
- AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
- if test "X$x" = "X-L$additional_libdir"; then
- haveit=yes
- break
- fi
- done
- if test -z "$haveit"; then
- if test "X$additional_libdir" = "X/usr/local/lib"; then
- if test -n "$GCC"; then
- case $host_os in
- linux*) haveit=yes;;
- esac
- fi
- fi
- if test -z "$haveit"; then
- if test -d "$additional_libdir"; then
- dnl Really add $additional_libdir to $LDFLAGS.
- LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
- fi
- fi
- fi
- fi
- fi
-])
-
-dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
-dnl acl_final_exec_prefix, containing the values to which $prefix and
-dnl $exec_prefix will expand at the end of the configure script.
-AC_DEFUN([AC_LIB_PREPARE_PREFIX],
-[
- dnl Unfortunately, prefix and exec_prefix get only finally determined
- dnl at the end of configure.
- if test "X$prefix" = "XNONE"; then
- acl_final_prefix="$ac_default_prefix"
- else
- acl_final_prefix="$prefix"
- fi
- if test "X$exec_prefix" = "XNONE"; then
- acl_final_exec_prefix='${prefix}'
- else
- acl_final_exec_prefix="$exec_prefix"
- fi
- acl_save_prefix="$prefix"
- prefix="$acl_final_prefix"
- eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
- prefix="$acl_save_prefix"
-])
-
-dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
-dnl variables prefix and exec_prefix bound to the values they will have
-dnl at the end of the configure script.
-AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
-[
- acl_save_prefix="$prefix"
- prefix="$acl_final_prefix"
- acl_save_exec_prefix="$exec_prefix"
- exec_prefix="$acl_final_exec_prefix"
- $1
- exec_prefix="$acl_save_exec_prefix"
- prefix="$acl_save_prefix"
-])
-
-# lib-link.m4 serial 6 (gettext-0.14.3)
-dnl Copyright (C) 2001-2005 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Bruno Haible.
-
-AC_PREREQ(2.50)
-
-dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
-dnl the libraries corresponding to explicit and implicit dependencies.
-dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
-dnl augments the CPPFLAGS variable.
-AC_DEFUN([AC_LIB_LINKFLAGS],
-[
- AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
- AC_REQUIRE([AC_LIB_RPATH])
- define([Name],[translit([$1],[./-], [___])])
- define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
- [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
- AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
- AC_LIB_LINKFLAGS_BODY([$1], [$2])
- ac_cv_lib[]Name[]_libs="$LIB[]NAME"
- ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
- ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
- ])
- LIB[]NAME="$ac_cv_lib[]Name[]_libs"
- LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
- INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
- AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
- AC_SUBST([LIB]NAME)
- AC_SUBST([LTLIB]NAME)
- dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
- dnl results of this search when this library appears as a dependency.
- HAVE_LIB[]NAME=yes
- undefine([Name])
- undefine([NAME])
-])
-
-dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
-dnl searches for libname and the libraries corresponding to explicit and
-dnl implicit dependencies, together with the specified include files and
-dnl the ability to compile and link the specified testcode. If found, it
-dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
-dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
-dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
-dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
-AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
-[
- AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
- AC_REQUIRE([AC_LIB_RPATH])
- define([Name],[translit([$1],[./-], [___])])
- define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
- [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
-
- dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
- dnl accordingly.
- AC_LIB_LINKFLAGS_BODY([$1], [$2])
-
- dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
- dnl because if the user has installed lib[]Name and not disabled its use
- dnl via --without-lib[]Name-prefix, he wants to use it.
- ac_save_CPPFLAGS="$CPPFLAGS"
- AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
-
- AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
- ac_save_LIBS="$LIBS"
- LIBS="$LIBS $LIB[]NAME"
- AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
- LIBS="$ac_save_LIBS"
- ])
- if test "$ac_cv_lib[]Name" = yes; then
- HAVE_LIB[]NAME=yes
- AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
- AC_MSG_CHECKING([how to link with lib[]$1])
- AC_MSG_RESULT([$LIB[]NAME])
- else
- HAVE_LIB[]NAME=no
- dnl If $LIB[]NAME didn't lead to a usable library, we don't need
- dnl $INC[]NAME either.
- CPPFLAGS="$ac_save_CPPFLAGS"
- LIB[]NAME=
- LTLIB[]NAME=
- fi
- AC_SUBST([HAVE_LIB]NAME)
- AC_SUBST([LIB]NAME)
- AC_SUBST([LTLIB]NAME)
- undefine([Name])
- undefine([NAME])
-])
-
-dnl Determine the platform dependent parameters needed to use rpath:
-dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
-dnl hardcode_direct, hardcode_minus_L.
-AC_DEFUN([AC_LIB_RPATH],
-[
- dnl Tell automake >= 1.10 to complain if config.rpath is missing.
- m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
- AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
- AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
- AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
- AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
- AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
- CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
- ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
- . ./conftest.sh
- rm -f ./conftest.sh
- acl_cv_rpath=done
- ])
- wl="$acl_cv_wl"
- libext="$acl_cv_libext"
- shlibext="$acl_cv_shlibext"
- hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
- hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
- hardcode_direct="$acl_cv_hardcode_direct"
- hardcode_minus_L="$acl_cv_hardcode_minus_L"
- dnl Determine whether the user wants rpath handling at all.
- AC_ARG_ENABLE(rpath,
- [ --disable-rpath do not hardcode runtime library paths],
- :, enable_rpath=yes)
-])
-
-dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
-dnl the libraries corresponding to explicit and implicit dependencies.
-dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
-AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
-[
- define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
- [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
- dnl By default, look in $includedir and $libdir.
- use_additional=yes
- AC_LIB_WITH_FINAL_PREFIX([
- eval additional_includedir=\"$includedir\"
- eval additional_libdir=\"$libdir\"
- ])
- AC_LIB_ARG_WITH([lib$1-prefix],
-[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib
- --without-lib$1-prefix don't search for lib$1 in includedir and libdir],
-[
- if test "X$withval" = "Xno"; then
- use_additional=no
- else
- if test "X$withval" = "X"; then
- AC_LIB_WITH_FINAL_PREFIX([
- eval additional_includedir=\"$includedir\"
- eval additional_libdir=\"$libdir\"
- ])
- else
- additional_includedir="$withval/include"
- additional_libdir="$withval/lib"
- fi
- fi
-])
- dnl Search the library and its dependencies in $additional_libdir and
- dnl $LDFLAGS. Using breadth-first-seach.
- LIB[]NAME=
- LTLIB[]NAME=
- INC[]NAME=
- rpathdirs=
- ltrpathdirs=
- names_already_handled=
- names_next_round='$1 $2'
- while test -n "$names_next_round"; do
- names_this_round="$names_next_round"
- names_next_round=
- for name in $names_this_round; do
- already_handled=
- for n in $names_already_handled; do
- if test "$n" = "$name"; then
- already_handled=yes
- break
- fi
- done
- if test -z "$already_handled"; then
- names_already_handled="$names_already_handled $name"
- dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
- dnl or AC_LIB_HAVE_LINKFLAGS call.
- uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
- eval value=\"\$HAVE_LIB$uppername\"
- if test -n "$value"; then
- if test "$value" = yes; then
- eval value=\"\$LIB$uppername\"
- test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
- eval value=\"\$LTLIB$uppername\"
- test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
- else
- dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
- dnl that this library doesn't exist. So just drop it.
- :
- fi
- else
- dnl Search the library lib$name in $additional_libdir and $LDFLAGS
- dnl and the already constructed $LIBNAME/$LTLIBNAME.
- found_dir=
- found_la=
- found_so=
- found_a=
- if test $use_additional = yes; then
- if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
- found_dir="$additional_libdir"
- found_so="$additional_libdir/lib$name.$shlibext"
- if test -f "$additional_libdir/lib$name.la"; then
- found_la="$additional_libdir/lib$name.la"
- fi
- else
- if test -f "$additional_libdir/lib$name.$libext"; then
- found_dir="$additional_libdir"
- found_a="$additional_libdir/lib$name.$libext"
- if test -f "$additional_libdir/lib$name.la"; then
- found_la="$additional_libdir/lib$name.la"
- fi
- fi
- fi
- fi
- if test "X$found_dir" = "X"; then
- for x in $LDFLAGS $LTLIB[]NAME; do
- AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
- case "$x" in
- -L*)
- dir=`echo "X$x" | sed -e 's/^X-L//'`
- if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
- found_dir="$dir"
- found_so="$dir/lib$name.$shlibext"
- if test -f "$dir/lib$name.la"; then
- found_la="$dir/lib$name.la"
- fi
- else
- if test -f "$dir/lib$name.$libext"; then
- found_dir="$dir"
- found_a="$dir/lib$name.$libext"
- if test -f "$dir/lib$name.la"; then
- found_la="$dir/lib$name.la"
- fi
- fi
- fi
- ;;
- esac
- if test "X$found_dir" != "X"; then
- break
- fi
- done
- fi
- if test "X$found_dir" != "X"; then
- dnl Found the library.
- LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
- if test "X$found_so" != "X"; then
- dnl Linking with a shared library. We attempt to hardcode its
- dnl directory into the executable's runpath, unless it's the
- dnl standard /usr/lib.
- if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
- dnl No hardcoding is needed.
- LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
- else
- dnl Use an explicit option to hardcode DIR into the resulting
- dnl binary.
- dnl Potentially add DIR to ltrpathdirs.
- dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
- haveit=
- for x in $ltrpathdirs; do
- if test "X$x" = "X$found_dir"; then
- haveit=yes
- break
- fi
- done
- if test -z "$haveit"; then
- ltrpathdirs="$ltrpathdirs $found_dir"
- fi
- dnl The hardcoding into $LIBNAME is system dependent.
- if test "$hardcode_direct" = yes; then
- dnl Using DIR/libNAME.so during linking hardcodes DIR into the
- dnl resulting binary.
- LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
- else
- if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
- dnl Use an explicit option to hardcode DIR into the resulting
- dnl binary.
- LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
- dnl Potentially add DIR to rpathdirs.
- dnl The rpathdirs will be appended to $LIBNAME at the end.
- haveit=
- for x in $rpathdirs; do
- if test "X$x" = "X$found_dir"; then
- haveit=yes
- break
- fi
- done
- if test -z "$haveit"; then
- rpathdirs="$rpathdirs $found_dir"
- fi
- else
- dnl Rely on "-L$found_dir".
- dnl But don't add it if it's already contained in the LDFLAGS
- dnl or the already constructed $LIBNAME
- haveit=
- for x in $LDFLAGS $LIB[]NAME; do
- AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
- if test "X$x" = "X-L$found_dir"; then
- haveit=yes
- break
- fi
- done
- if test -z "$haveit"; then
- LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
- fi
- if test "$hardcode_minus_L" != no; then
- dnl FIXME: Not sure whether we should use
- dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
- dnl here.
- LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
- else
- dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
- dnl here, because this doesn't fit in flags passed to the
- dnl compiler. So give up. No hardcoding. This affects only
- dnl very old systems.
- dnl FIXME: Not sure whether we should use
- dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
- dnl here.
- LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
- fi
- fi
- fi
- fi
- else
- if test "X$found_a" != "X"; then
- dnl Linking with a static library.
- LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
- else
- dnl We shouldn't come here, but anyway it's good to have a
- dnl fallback.
- LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
- fi
- fi
- dnl Assume the include files are nearby.
- additional_includedir=
- case "$found_dir" in
- */lib | */lib/)
- basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
- additional_includedir="$basedir/include"
- ;;
- esac
- if test "X$additional_includedir" != "X"; then
- dnl Potentially add $additional_includedir to $INCNAME.
- dnl But don't add it
- dnl 1. if it's the standard /usr/include,
- dnl 2. if it's /usr/local/include and we are using GCC on Linux,
- dnl 3. if it's already present in $CPPFLAGS or the already
- dnl constructed $INCNAME,
- dnl 4. if it doesn't exist as a directory.
- if test "X$additional_includedir" != "X/usr/include"; then
- haveit=
- if test "X$additional_includedir" = "X/usr/local/include"; then
- if test -n "$GCC"; then
- case $host_os in
- linux* | gnu* | k*bsd*-gnu) haveit=yes;;
- esac
- fi
- fi
- if test -z "$haveit"; then
- for x in $CPPFLAGS $INC[]NAME; do
- AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
- if test "X$x" = "X-I$additional_includedir"; then
- haveit=yes
- break
- fi
- done
- if test -z "$haveit"; then
- if test -d "$additional_includedir"; then
- dnl Really add $additional_includedir to $INCNAME.
- INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
- fi
- fi
- fi
- fi
- fi
- dnl Look for dependencies.
- if test -n "$found_la"; then
- dnl Read the .la file. It defines the variables
- dnl dlname, library_names, old_library, dependency_libs, current,
- dnl age, revision, installed, dlopen, dlpreopen, libdir.
- save_libdir="$libdir"
- case "$found_la" in
- */* | *\\*) . "$found_la" ;;
- *) . "./$found_la" ;;
- esac
- libdir="$save_libdir"
- dnl We use only dependency_libs.
- for dep in $dependency_libs; do
- case "$dep" in
- -L*)
- additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
- dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
- dnl But don't add it
- dnl 1. if it's the standard /usr/lib,
- dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
- dnl 3. if it's already present in $LDFLAGS or the already
- dnl constructed $LIBNAME,
- dnl 4. if it doesn't exist as a directory.
- if test "X$additional_libdir" != "X/usr/lib"; then
- haveit=
- if test "X$additional_libdir" = "X/usr/local/lib"; then
- if test -n "$GCC"; then
- case $host_os in
- linux* | gnu* | k*bsd*-gnu) haveit=yes;;
- esac
- fi
- fi
- if test -z "$haveit"; then
- haveit=
- for x in $LDFLAGS $LIB[]NAME; do
- AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
- if test "X$x" = "X-L$additional_libdir"; then
- haveit=yes
- break
- fi
- done
- if test -z "$haveit"; then
- if test -d "$additional_libdir"; then
- dnl Really add $additional_libdir to $LIBNAME.
- LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
- fi
- fi
- haveit=
- for x in $LDFLAGS $LTLIB[]NAME; do
- AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
- if test "X$x" = "X-L$additional_libdir"; then
- haveit=yes
- break
- fi
- done
- if test -z "$haveit"; then
- if test -d "$additional_libdir"; then
- dnl Really add $additional_libdir to $LTLIBNAME.
- LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
- fi
- fi
- fi
- fi
- ;;
- -R*)
- dir=`echo "X$dep" | sed -e 's/^X-R//'`
- if test "$enable_rpath" != no; then
- dnl Potentially add DIR to rpathdirs.
- dnl The rpathdirs will be appended to $LIBNAME at the end.
- haveit=
- for x in $rpathdirs; do
- if test "X$x" = "X$dir"; then
- haveit=yes
- break
- fi
- done
- if test -z "$haveit"; then
- rpathdirs="$rpathdirs $dir"
- fi
- dnl Potentially add DIR to ltrpathdirs.
- dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
- haveit=
- for x in $ltrpathdirs; do
- if test "X$x" = "X$dir"; then
- haveit=yes
- break
- fi
- done
- if test -z "$haveit"; then
- ltrpathdirs="$ltrpathdirs $dir"
- fi
- fi
- ;;
- -l*)
- dnl Handle this in the next round.
- names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
- ;;
- *.la)
- dnl Handle this in the next round. Throw away the .la's
- dnl directory; it is already contained in a preceding -L
- dnl option.
- names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
- ;;
- *)
- dnl Most likely an immediate library name.
- LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
- LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
- ;;
- esac
- done
- fi
- else
- dnl Didn't find the library; assume it is in the system directories
- dnl known to the linker and runtime loader. (All the system
- dnl directories known to the linker should also be known to the
- dnl runtime loader, otherwise the system is severely misconfigured.)
- LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
- LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
- fi
- fi
- fi
- done
- done
- if test "X$rpathdirs" != "X"; then
- if test -n "$hardcode_libdir_separator"; then
- dnl Weird platform: only the last -rpath option counts, the user must
- dnl pass all path elements in one option. We can arrange that for a
- dnl single library, but not when more than one $LIBNAMEs are used.
- alldirs=
- for found_dir in $rpathdirs; do
- alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
- done
- dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
- acl_save_libdir="$libdir"
- libdir="$alldirs"
- eval flag=\"$hardcode_libdir_flag_spec\"
- libdir="$acl_save_libdir"
- LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
- else
- dnl The -rpath options are cumulative.
- for found_dir in $rpathdirs; do
- acl_save_libdir="$libdir"
- libdir="$found_dir"
- eval flag=\"$hardcode_libdir_flag_spec\"
- libdir="$acl_save_libdir"
- LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
- done
- fi
- fi
- if test "X$ltrpathdirs" != "X"; then
- dnl When using libtool, the option that works for both libraries and
- dnl executables is -R. The -R options are cumulative.
- for found_dir in $ltrpathdirs; do
- LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
- done
- fi
-])
-
-dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
-dnl unless already present in VAR.
-dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
-dnl contains two or three consecutive elements that belong together.
-AC_DEFUN([AC_LIB_APPENDTOVAR],
-[
- for element in [$2]; do
- haveit=
- for x in $[$1]; do
- AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
- if test "X$x" = "X$element"; then
- haveit=yes
- break
- fi
- done
- if test -z "$haveit"; then
- [$1]="${[$1]}${[$1]:+ }$element"
- fi
- done
-])
-
-# lib-ld.m4 serial 3 (gettext-0.13)
-dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl Subroutines of libtool.m4,
-dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
-dnl with libtool.m4.
-
-dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
-AC_DEFUN([AC_LIB_PROG_LD_GNU],
-[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
-[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
-case `$LD -v 2>&1 </dev/null` in
-*GNU* | *'with BFD'*)
- acl_cv_prog_gnu_ld=yes ;;
-*)
- acl_cv_prog_gnu_ld=no ;;
-esac])
-with_gnu_ld=$acl_cv_prog_gnu_ld
-])
-
-dnl From libtool-1.4. Sets the variable LD.
-AC_DEFUN([AC_LIB_PROG_LD],
-[AC_ARG_WITH(gnu-ld,
-[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
-test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
-AC_REQUIRE([AC_PROG_CC])dnl
-AC_REQUIRE([AC_CANONICAL_HOST])dnl
-# Prepare PATH_SEPARATOR.
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- echo "#! /bin/sh" >conf$$.sh
- echo "exit 0" >>conf$$.sh
- chmod +x conf$$.sh
- if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
- PATH_SEPARATOR=';'
- else
- PATH_SEPARATOR=:
- fi
- rm -f conf$$.sh
-fi
-ac_prog=ld
-if test "$GCC" = yes; then
- # Check if gcc -print-prog-name=ld gives a path.
- AC_MSG_CHECKING([for ld used by GCC])
- case $host in
- *-*-mingw*)
- # gcc leaves a trailing carriage return which upsets mingw
- ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
- *)
- ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
- esac
- case $ac_prog in
- # Accept absolute paths.
- [[\\/]* | [A-Za-z]:[\\/]*)]
- [re_direlt='/[^/][^/]*/\.\./']
- # Canonicalize the path of ld
- ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
- ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
- done
- test -z "$LD" && LD="$ac_prog"
- ;;
- "")
- # If it fails, then pretend we aren't using GCC.
- ac_prog=ld
- ;;
- *)
- # If it is relative, then search for the first ld in PATH.
- with_gnu_ld=unknown
- ;;
- esac
-elif test "$with_gnu_ld" = yes; then
- AC_MSG_CHECKING([for GNU ld])
-else
- AC_MSG_CHECKING([for non-GNU ld])
-fi
-AC_CACHE_VAL(acl_cv_path_LD,
-[if test -z "$LD"; then
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
- acl_cv_path_LD="$ac_dir/$ac_prog"
- # Check to see if the program is GNU ld. I'd rather use --version,
- # but apparently some GNU ld's only accept -v.
- # Break only if it was the GNU/non-GNU ld that we prefer.
- case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
- *GNU* | *'with BFD'*)
- test "$with_gnu_ld" != no && break ;;
- *)
- test "$with_gnu_ld" != yes && break ;;
- esac
- fi
- done
- IFS="$ac_save_ifs"
-else
- acl_cv_path_LD="$LD" # Let the user override the test with a path.
-fi])
-LD="$acl_cv_path_LD"
-if test -n "$LD"; then
- AC_MSG_RESULT($LD)
-else
- AC_MSG_RESULT(no)
-fi
-test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
-AC_LIB_PROG_LD_GNU
-])
-
-# Do all the work for Automake. This macro actually does too much --
-# some checks are only needed if your package does certain things.
-# But this isn't really a big deal.
-
-# serial 1
-
-dnl Usage:
-dnl AM_INIT_AUTOMAKE(package,version, [no-define])
-
-AC_DEFUN([AM_INIT_AUTOMAKE],
-[AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
-AC_REQUIRE([AC_PROG_INSTALL])
-PACKAGE=[$1]
-AC_SUBST(PACKAGE)
-VERSION=[$2]
-AC_SUBST(VERSION)
-dnl test to see if srcdir already configured
-if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
- AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
-fi
-ifelse([$3],,
-AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
-AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
-AC_REQUIRE([AM_SANITY_CHECK])
-AC_REQUIRE([AC_ARG_PROGRAM])
-dnl FIXME This is truly gross.
-missing_dir=`cd $ac_aux_dir && pwd`
-AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}, $missing_dir)
-AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
-AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}, $missing_dir)
-AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
-AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
-AC_REQUIRE([AC_PROG_MAKE_SET])])
-
-# Copyright 2002 Free Software Foundation, Inc.
-
-# 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 2, 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/>.
-
-# AM_AUTOMAKE_VERSION(VERSION)
-# ----------------------------
-# Automake X.Y traces this macro to ensure aclocal.m4 has been
-# generated from the m4 files accompanying Automake X.Y.
-AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.4"])
-
-# AM_SET_CURRENT_AUTOMAKE_VERSION
-# -------------------------------
-# Call AM_AUTOMAKE_VERSION so it can be traced.
-# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
-AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
- [AM_AUTOMAKE_VERSION([1.4-p6])])
-
-#
-# Check to make sure that the build environment is sane.
-#
-
-AC_DEFUN([AM_SANITY_CHECK],
-[AC_MSG_CHECKING([whether build environment is sane])
-# Just in case
-sleep 1
-echo timestamp > conftestfile
-# Do `set' in a subshell so we don't clobber the current shell's
-# arguments. Must try -L first in case configure is actually a
-# symlink; some systems play weird games with the mod time of symlinks
-# (eg FreeBSD returns the mod time of the symlink's containing
-# directory).
-if (
- set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
- if test "[$]*" = "X"; then
- # -L didn't work.
- set X `ls -t $srcdir/configure conftestfile`
- fi
- if test "[$]*" != "X $srcdir/configure conftestfile" \
- && test "[$]*" != "X conftestfile $srcdir/configure"; then
-
- # If neither matched, then we have a broken ls. This can happen
- # if, for instance, CONFIG_SHELL is bash and it inherits a
- # broken ls alias from the environment. This has actually
- # happened. Such a system could not be considered "sane".
- AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
-alias in your environment])
- fi
-
- test "[$]2" = conftestfile
- )
-then
- # Ok.
- :
-else
- AC_MSG_ERROR([newly created file is older than distributed files!
-Check your system clock])
-fi
-rm -f conftest*
-AC_MSG_RESULT(yes)])
-
-dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
-dnl The program must properly implement --version.
-AC_DEFUN([AM_MISSING_PROG],
-[AC_MSG_CHECKING(for working $2)
-# Run test in a subshell; some versions of sh will print an error if
-# an executable is not found, even if stderr is redirected.
-# Redirect stdin to placate older versions of autoconf. Sigh.
-if ($2 --version) < /dev/null > /dev/null 2>&1; then
- $1=$2
- AC_MSG_RESULT(found)
-else
- $1="$3/missing $2"
- AC_MSG_RESULT(missing)
-fi
-AC_SUBST($1)])
-
-# Like AC_CONFIG_HEADER, but automatically create stamp file.
-
-AC_DEFUN([AM_CONFIG_HEADER],
-[AC_PREREQ([2.12])
-AC_CONFIG_HEADER([$1])
-dnl When config.status generates a header, we must update the stamp-h file.
-dnl This file resides in the same directory as the config header
-dnl that is generated. We must strip everything past the first ":",
-dnl and everything past the last "/".
-AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
-ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
-<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
-<<am_indx=1
-for am_file in <<$1>>; do
- case " <<$>>CONFIG_HEADERS " in
- *" <<$>>am_file "*<<)>>
- echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
- ;;
- esac
- am_indx=`expr "<<$>>am_indx" + 1`
-done<<>>dnl>>)
-changequote([,]))])
-
-# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
-
-# serial 48 Debian 1.5.22-2 AC_PROG_LIBTOOL
-
-
-# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
-# -----------------------------------------------------------
-# If this macro is not defined by Autoconf, define it here.
-m4_ifdef([AC_PROVIDE_IFELSE],
- [],
- [m4_define([AC_PROVIDE_IFELSE],
- [m4_ifdef([AC_PROVIDE_$1],
- [$2], [$3])])])
-
-
-# AC_PROG_LIBTOOL
-# ---------------
-AC_DEFUN([AC_PROG_LIBTOOL],
-[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
-dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
-dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
- AC_PROVIDE_IFELSE([AC_PROG_CXX],
- [AC_LIBTOOL_CXX],
- [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
- ])])
-dnl And a similar setup for Fortran 77 support
- AC_PROVIDE_IFELSE([AC_PROG_F77],
- [AC_LIBTOOL_F77],
- [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77
-])])
-
-dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
-dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
-dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
- AC_PROVIDE_IFELSE([AC_PROG_GCJ],
- [AC_LIBTOOL_GCJ],
- [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
- [AC_LIBTOOL_GCJ],
- [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
- [AC_LIBTOOL_GCJ],
- [ifdef([AC_PROG_GCJ],
- [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])
- ifdef([A][M_PROG_GCJ],
- [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])])
- ifdef([LT_AC_PROG_GCJ],
- [define([LT_AC_PROG_GCJ],
- defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])])
-])])# AC_PROG_LIBTOOL
-
-
-# _AC_PROG_LIBTOOL
-# ----------------
-AC_DEFUN([_AC_PROG_LIBTOOL],
-[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
-AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
-AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl
-AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl
-
-# This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
-
-# Always use our own libtool.
-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
-AC_SUBST(LIBTOOL)dnl
-
-# Prevent multiple expansion
-define([AC_PROG_LIBTOOL], [])
-])# _AC_PROG_LIBTOOL
-
-
-# AC_LIBTOOL_SETUP
-# ----------------
-AC_DEFUN([AC_LIBTOOL_SETUP],
-[AC_PREREQ(2.50)dnl
-AC_REQUIRE([AC_ENABLE_SHARED])dnl
-AC_REQUIRE([AC_ENABLE_STATIC])dnl
-AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
-AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
-AC_REQUIRE([AC_PROG_CC])dnl
-AC_REQUIRE([AC_PROG_LD])dnl
-AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl
-AC_REQUIRE([AC_PROG_NM])dnl
-
-AC_REQUIRE([AC_PROG_LN_S])dnl
-AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
-# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
-AC_REQUIRE([AC_OBJEXT])dnl
-AC_REQUIRE([AC_EXEEXT])dnl
-dnl
-
-AC_LIBTOOL_SYS_MAX_CMD_LEN
-AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
-AC_LIBTOOL_OBJDIR
-
-AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
-_LT_AC_PROG_ECHO_BACKSLASH
-
-case $host_os in
-aix3*)
- # AIX sometimes has problems with the GCC collect2 program. For some
- # reason, if we set the COLLECT_NAMES environment variable, the problems
- # vanish in a puff of smoke.
- if test "X${COLLECT_NAMES+set}" != Xset; then
- COLLECT_NAMES=
- export COLLECT_NAMES
- fi
- ;;
-esac
-
-# Sed substitution that helps us do robust quoting. It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
-[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g']
-
-# Same as above, but do not quote variable references.
-[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g']
-
-# Sed substitution to delay expansion of an escaped shell variable in a
-# double_quote_subst'ed string.
-delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
-
-# Sed substitution to avoid accidental globbing in evaled expressions
-no_glob_subst='s/\*/\\\*/g'
-
-# Constants:
-rm="rm -f"
-
-# Global variables:
-default_ofile=libtool
-can_build_shared=yes
-
-# All known linkers require a `.a' archive for static linking (except MSVC,
-# which needs '.lib').
-libext=a
-ltmain="$ac_aux_dir/ltmain.sh"
-ofile="$default_ofile"
-with_gnu_ld="$lt_cv_prog_gnu_ld"
-
-AC_CHECK_TOOL(AR, ar, false)
-AC_CHECK_TOOL(RANLIB, ranlib, :)
-AC_CHECK_TOOL(STRIP, strip, :)
-
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
-
-# Set sane defaults for various variables
-test -z "$AR" && AR=ar
-test -z "$AR_FLAGS" && AR_FLAGS=cru
-test -z "$AS" && AS=as
-test -z "$CC" && CC=cc
-test -z "$LTCC" && LTCC=$CC
-test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
-test -z "$DLLTOOL" && DLLTOOL=dlltool
-test -z "$LD" && LD=ld
-test -z "$LN_S" && LN_S="ln -s"
-test -z "$MAGIC_CMD" && MAGIC_CMD=file
-test -z "$NM" && NM=nm
-test -z "$SED" && SED=sed
-test -z "$OBJDUMP" && OBJDUMP=objdump
-test -z "$RANLIB" && RANLIB=:
-test -z "$STRIP" && STRIP=:
-test -z "$ac_objext" && ac_objext=o
-
-# Determine commands to create old-style static archives.
-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
-old_postinstall_cmds='chmod 644 $oldlib'
-old_postuninstall_cmds=
-
-if test -n "$RANLIB"; then
- case $host_os in
- openbsd*)
- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
- ;;
- *)
- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
- ;;
- esac
- old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
-fi
-
-_LT_CC_BASENAME([$compiler])
-
-# Only perform the check for file, if the check method requires it
-case $deplibs_check_method in
-file_magic*)
- if test "$file_magic_cmd" = '$MAGIC_CMD'; then
- AC_PATH_MAGIC
- fi
- ;;
-esac
-
-AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no)
-AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
-enable_win32_dll=yes, enable_win32_dll=no)
-
-AC_ARG_ENABLE([libtool-lock],
- [AC_HELP_STRING([--disable-libtool-lock],
- [avoid locking (might break parallel builds)])])
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
-
-AC_ARG_WITH([pic],
- [AC_HELP_STRING([--with-pic],
- [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
- [pic_mode="$withval"],
- [pic_mode=default])
-test -z "$pic_mode" && pic_mode=default
-
-# Use C for the default configuration in the libtool script
-tagname=
-AC_LIBTOOL_LANG_C_CONFIG
-_LT_AC_TAGCONFIG
-])# AC_LIBTOOL_SETUP
-
-
-# _LT_AC_SYS_COMPILER
-# -------------------
-AC_DEFUN([_LT_AC_SYS_COMPILER],
-[AC_REQUIRE([AC_PROG_CC])dnl
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-])# _LT_AC_SYS_COMPILER
-
-
-# _LT_CC_BASENAME(CC)
-# -------------------
-# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
-AC_DEFUN([_LT_CC_BASENAME],
-[for cc_temp in $1""; do
- case $cc_temp in
- compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
- distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-])
-
-
-# _LT_COMPILER_BOILERPLATE
-# ------------------------
-# Check for compiler boilerplate output or warnings with
-# the simple compiler test code.
-AC_DEFUN([_LT_COMPILER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-])# _LT_COMPILER_BOILERPLATE
-
-
-# _LT_LINKER_BOILERPLATE
-# ----------------------
-# Check for linker boilerplate output or warnings with
-# the simple link test code.
-AC_DEFUN([_LT_LINKER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-])# _LT_LINKER_BOILERPLATE
-
-
-# _LT_AC_SYS_LIBPATH_AIX
-# ----------------------
-# Links a minimal program and checks the executable
-# for the system default hardcoded library path. In most cases,
-# this is /usr/lib:/lib, but when the MPI compilers are used
-# the location of the communication and MPI libs are included too.
-# If we don't find anything, use the default library path according
-# to the aix ld manual.
-AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX],
-[AC_LINK_IFELSE(AC_LANG_PROGRAM,[
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi],[])
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-])# _LT_AC_SYS_LIBPATH_AIX
-
-
-# _LT_AC_SHELL_INIT(ARG)
-# ----------------------
-AC_DEFUN([_LT_AC_SHELL_INIT],
-[ifdef([AC_DIVERSION_NOTICE],
- [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
- [AC_DIVERT_PUSH(NOTICE)])
-$1
-AC_DIVERT_POP
-])# _LT_AC_SHELL_INIT
-
-
-# _LT_AC_PROG_ECHO_BACKSLASH
-# --------------------------
-# Add some code to the start of the generated configure script which
-# will find an echo command which doesn't interpret backslashes.
-AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH],
-[_LT_AC_SHELL_INIT([
-# Check that we are running under the correct shell.
-SHELL=${CONFIG_SHELL-/bin/sh}
-
-case X$ECHO in
-X*--fallback-echo)
- # Remove one level of quotation (which was required for Make).
- ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
- ;;
-esac
-
-echo=${ECHO-echo}
-if test "X[$]1" = X--no-reexec; then
- # Discard the --no-reexec flag, and continue.
- shift
-elif test "X[$]1" = X--fallback-echo; then
- # Avoid inline document here, it may be left over
- :
-elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
- # Yippee, $echo works!
- :
-else
- # Restart under the correct shell.
- exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
-fi
-
-if test "X[$]1" = X--fallback-echo; then
- # used as fallback echo
- shift
- cat <<EOF
-[$]*
-EOF
- exit 0
-fi
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-if test -z "$ECHO"; then
-if test "X${echo_test_string+set}" != Xset; then
-# find a string as large as possible, as long as the shell can cope with it
- for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
- # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
- if (echo_test_string=`eval $cmd`) 2>/dev/null &&
- echo_test_string=`eval $cmd` &&
- (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
- then
- break
- fi
- done
-fi
-
-if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- :
-else
- # The Solaris, AIX, and Digital Unix default echo programs unquote
- # backslashes. This makes it impossible to quote backslashes using
- # echo "$something" | sed 's/\\/\\\\/g'
- #
- # So, first we look for a working echo in the user's PATH.
-
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for dir in $PATH /usr/ucb; do
- IFS="$lt_save_ifs"
- if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
- test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- echo="$dir/echo"
- break
- fi
- done
- IFS="$lt_save_ifs"
-
- if test "X$echo" = Xecho; then
- # We didn't find a better echo, so look for alternatives.
- if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- # This shell has a builtin print -r that does the trick.
- echo='print -r'
- elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
- test "X$CONFIG_SHELL" != X/bin/ksh; then
- # If we have ksh, try running configure again with it.
- ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
- export ORIGINAL_CONFIG_SHELL
- CONFIG_SHELL=/bin/ksh
- export CONFIG_SHELL
- exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
- else
- # Try using printf.
- echo='printf %s\n'
- if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- # Cool, printf works
- :
- elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
- test "X$echo_testing_string" = 'X\t' &&
- echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
- export CONFIG_SHELL
- SHELL="$CONFIG_SHELL"
- export SHELL
- echo="$CONFIG_SHELL [$]0 --fallback-echo"
- elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
- test "X$echo_testing_string" = 'X\t' &&
- echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- echo="$CONFIG_SHELL [$]0 --fallback-echo"
- else
- # maybe with a smaller string...
- prev=:
-
- for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
- if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
- then
- break
- fi
- prev="$cmd"
- done
-
- if test "$prev" != 'sed 50q "[$]0"'; then
- echo_test_string=`eval $prev`
- export echo_test_string
- exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
- else
- # Oops. We lost completely, so just stick with echo.
- echo=echo
- fi
- fi
- fi
- fi
-fi
-fi
-
-# Copy echo and quote the copy suitably for passing to libtool from
-# the Makefile, instead of quoting the original, which is used later.
-ECHO=$echo
-if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
- ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
-fi
-
-AC_SUBST(ECHO)
-])])# _LT_AC_PROG_ECHO_BACKSLASH
-
-
-# _LT_AC_LOCK
-# -----------
-AC_DEFUN([_LT_AC_LOCK],
-[AC_ARG_ENABLE([libtool-lock],
- [AC_HELP_STRING([--disable-libtool-lock],
- [avoid locking (might break parallel builds)])])
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
-
-# Some flags need to be propagated to the compiler or linker for good
-# libtool support.
-case $host in
-ia64-*-hpux*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if AC_TRY_EVAL(ac_compile); then
- case `/usr/bin/file conftest.$ac_objext` in
- *ELF-32*)
- HPUX_IA64_MODE="32"
- ;;
- *ELF-64*)
- HPUX_IA64_MODE="64"
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-*-*-irix6*)
- # Find out which ABI we are using.
- echo '[#]line __oline__ "configure"' > conftest.$ac_ext
- if AC_TRY_EVAL(ac_compile); then
- if test "$lt_cv_prog_gnu_ld" = yes; then
- case `/usr/bin/file conftest.$ac_objext` in
- *32-bit*)
- LD="${LD-ld} -melf32bsmip"
- ;;
- *N32*)
- LD="${LD-ld} -melf32bmipn32"
- ;;
- *64-bit*)
- LD="${LD-ld} -melf64bmip"
- ;;
- esac
- else
- case `/usr/bin/file conftest.$ac_objext` in
- *32-bit*)
- LD="${LD-ld} -32"
- ;;
- *N32*)
- LD="${LD-ld} -n32"
- ;;
- *64-bit*)
- LD="${LD-ld} -64"
- ;;
- esac
- fi
- fi
- rm -rf conftest*
- ;;
-
-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if AC_TRY_EVAL(ac_compile); then
- case `/usr/bin/file conftest.o` in
- *32-bit*)
- case $host in
- x86_64-*linux*)
- LD="${LD-ld} -m elf_i386"
- ;;
- ppc64-*linux*|powerpc64-*linux*)
- LD="${LD-ld} -m elf32ppclinux"
- ;;
- s390x-*linux*)
- LD="${LD-ld} -m elf_s390"
- ;;
- sparc64-*linux*)
- LD="${LD-ld} -m elf32_sparc"
- ;;
- esac
- ;;
- *64-bit*)
- case $host in
- x86_64-*linux*)
- LD="${LD-ld} -m elf_x86_64"
- ;;
- ppc*-*linux*|powerpc*-*linux*)
- LD="${LD-ld} -m elf64ppc"
- ;;
- s390*-*linux*)
- LD="${LD-ld} -m elf64_s390"
- ;;
- sparc*-*linux*)
- LD="${LD-ld} -m elf64_sparc"
- ;;
- esac
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-
-*-*-sco3.2v5*)
- # On SCO OpenServer 5, we need -belf to get full-featured binaries.
- SAVE_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -belf"
- AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
- [AC_LANG_PUSH(C)
- AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
- AC_LANG_POP])
- if test x"$lt_cv_cc_needs_belf" != x"yes"; then
- # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
- CFLAGS="$SAVE_CFLAGS"
- fi
- ;;
-sparc*-*solaris*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if AC_TRY_EVAL(ac_compile); then
- case `/usr/bin/file conftest.o` in
- *64-bit*)
- case $lt_cv_prog_gnu_ld in
- yes*) LD="${LD-ld} -m elf64_sparc" ;;
- *) LD="${LD-ld} -64" ;;
- esac
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-
-AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
-[*-*-cygwin* | *-*-mingw* | *-*-pw32*)
- AC_CHECK_TOOL(DLLTOOL, dlltool, false)
- AC_CHECK_TOOL(AS, as, false)
- AC_CHECK_TOOL(OBJDUMP, objdump, false)
- ;;
- ])
-esac
-
-need_locks="$enable_libtool_lock"
-
-])# _LT_AC_LOCK
-
-
-# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
-# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
-# ----------------------------------------------------------------
-# Check whether the given compiler option works
-AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION],
-[AC_REQUIRE([LT_AC_PROG_SED])
-AC_CACHE_CHECK([$1], [$2],
- [$2=no
- ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="$3"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&AS_MESSAGE_LOG_FD
- echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- $2=yes
- fi
- fi
- $rm conftest*
-])
-
-if test x"[$]$2" = xyes; then
- ifelse([$5], , :, [$5])
-else
- ifelse([$6], , :, [$6])
-fi
-])# AC_LIBTOOL_COMPILER_OPTION
-
-
-# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
-# [ACTION-SUCCESS], [ACTION-FAILURE])
-# ------------------------------------------------------------
-# Check whether the given compiler option works
-AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
-[AC_CACHE_CHECK([$1], [$2],
- [$2=no
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $3"
- printf "$lt_simple_link_test_code" > conftest.$ac_ext
- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
- # The linker can only warn and ignore the option if not recognized
- # So say no if there are warnings
- if test -s conftest.err; then
- # Append any errors to the config.log.
- cat conftest.err 1>&AS_MESSAGE_LOG_FD
- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if diff conftest.exp conftest.er2 >/dev/null; then
- $2=yes
- fi
- else
- $2=yes
- fi
- fi
- $rm conftest*
- LDFLAGS="$save_LDFLAGS"
-])
-
-if test x"[$]$2" = xyes; then
- ifelse([$4], , :, [$4])
-else
- ifelse([$5], , :, [$5])
-fi
-])# AC_LIBTOOL_LINKER_OPTION
-
-
-# AC_LIBTOOL_SYS_MAX_CMD_LEN
-# --------------------------
-AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN],
-[# find the maximum length of command line arguments
-AC_MSG_CHECKING([the maximum length of command line arguments])
-AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
- i=0
- teststring="ABCD"
-
- case $build_os in
- msdosdjgpp*)
- # On DJGPP, this test can blow up pretty badly due to problems in libc
- # (any single argument exceeding 2000 bytes causes a buffer overrun
- # during glob expansion). Even if it were fixed, the result of this
- # check would be larger than it should be.
- lt_cv_sys_max_cmd_len=12288; # 12K is about right
- ;;
-
- gnu*)
- # Under GNU Hurd, this test is not required because there is
- # no limit to the length of command line arguments.
- # Libtool will interpret -1 as no limit whatsoever
- lt_cv_sys_max_cmd_len=-1;
- ;;
-
- cygwin* | mingw*)
- # On Win9x/ME, this test blows up -- it succeeds, but takes
- # about 5 minutes as the teststring grows exponentially.
- # Worse, since 9x/ME are not pre-emptively multitasking,
- # you end up with a "frozen" computer, even though with patience
- # the test eventually succeeds (with a max line length of 256k).
- # Instead, let's just punt: use the minimum linelength reported by
- # all of the supported platforms: 8192 (on NT/2K/XP).
- lt_cv_sys_max_cmd_len=8192;
- ;;
-
- amigaos*)
- # On AmigaOS with pdksh, this test takes hours, literally.
- # So we just punt and use a minimum line length of 8192.
- lt_cv_sys_max_cmd_len=8192;
- ;;
-
- netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
- # This has been around since 386BSD, at least. Likely further.
- if test -x /sbin/sysctl; then
- lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
- elif test -x /usr/sbin/sysctl; then
- lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
- else
- lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
- fi
- # And add a safety zone
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
- ;;
-
- interix*)
- # We know the value 262144 and hardcode it with a safety zone (like BSD)
- lt_cv_sys_max_cmd_len=196608
- ;;
-
- osf*)
- # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
- # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
- # nice to cause kernel panics so lets avoid the loop below.
- # First set a reasonable default.
- lt_cv_sys_max_cmd_len=16384
- #
- if test -x /sbin/sysconfig; then
- case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
- *1*) lt_cv_sys_max_cmd_len=-1 ;;
- esac
- fi
- ;;
- sco3.2v5*)
- lt_cv_sys_max_cmd_len=102400
- ;;
- sysv5* | sco5v6* | sysv4.2uw2*)
- kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
- if test -n "$kargmax"; then
- lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
- else
- lt_cv_sys_max_cmd_len=32768
- fi
- ;;
- *)
- # If test is not a shell built-in, we'll probably end up computing a
- # maximum length that is only half of the actual maximum length, but
- # we can't tell.
- SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
- while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
- = "XX$teststring") >/dev/null 2>&1 &&
- new_result=`expr "X$teststring" : ".*" 2>&1` &&
- lt_cv_sys_max_cmd_len=$new_result &&
- test $i != 17 # 1/2 MB should be enough
- do
- i=`expr $i + 1`
- teststring=$teststring$teststring
- done
- teststring=
- # Add a significant safety factor because C++ compilers can tack on massive
- # amounts of additional arguments before passing them to the linker.
- # It appears as though 1/2 is a usable value.
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
- ;;
- esac
-])
-if test -n $lt_cv_sys_max_cmd_len ; then
- AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
-else
- AC_MSG_RESULT(none)
-fi
-])# AC_LIBTOOL_SYS_MAX_CMD_LEN
-
-
-# _LT_AC_CHECK_DLFCN
-# ------------------
-AC_DEFUN([_LT_AC_CHECK_DLFCN],
-[AC_CHECK_HEADERS(dlfcn.h)dnl
-])# _LT_AC_CHECK_DLFCN
-
-
-# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
-# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
-# ---------------------------------------------------------------------
-AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF],
-[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
-if test "$cross_compiling" = yes; then :
- [$4]
-else
- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
- lt_status=$lt_dlunknown
- cat > conftest.$ac_ext <<EOF
-[#line __oline__ "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-# define LT_DLGLOBAL RTLD_GLOBAL
-#else
-# ifdef DL_GLOBAL
-# define LT_DLGLOBAL DL_GLOBAL
-# else
-# define LT_DLGLOBAL 0
-# endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
- find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-# ifdef RTLD_LAZY
-# define LT_DLLAZY_OR_NOW RTLD_LAZY
-# else
-# ifdef DL_LAZY
-# define LT_DLLAZY_OR_NOW DL_LAZY
-# else
-# ifdef RTLD_NOW
-# define LT_DLLAZY_OR_NOW RTLD_NOW
-# else
-# ifdef DL_NOW
-# define LT_DLLAZY_OR_NOW DL_NOW
-# else
-# define LT_DLLAZY_OR_NOW 0
-# endif
-# endif
-# endif
-# endif
-#endif
-
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-
-void fnord() { int i=42;}
-int main ()
-{
- void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
- int status = $lt_dlunknown;
-
- if (self)
- {
- if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
- else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
- /* dlclose (self); */
- }
- else
- puts (dlerror ());
-
- exit (status);
-}]
-EOF
- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
- (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
- lt_status=$?
- case x$lt_status in
- x$lt_dlno_uscore) $1 ;;
- x$lt_dlneed_uscore) $2 ;;
- x$lt_dlunknown|x*) $3 ;;
- esac
- else :
- # compilation failed
- $3
- fi
-fi
-rm -fr conftest*
-])# _LT_AC_TRY_DLOPEN_SELF
-
-
-# AC_LIBTOOL_DLOPEN_SELF
-# ----------------------
-AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF],
-[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
-if test "x$enable_dlopen" != xyes; then
- enable_dlopen=unknown
- enable_dlopen_self=unknown
- enable_dlopen_self_static=unknown
-else
- lt_cv_dlopen=no
- lt_cv_dlopen_libs=
-
- case $host_os in
- beos*)
- lt_cv_dlopen="load_add_on"
- lt_cv_dlopen_libs=
- lt_cv_dlopen_self=yes
- ;;
-
- mingw* | pw32*)
- lt_cv_dlopen="LoadLibrary"
- lt_cv_dlopen_libs=
- ;;
-
- cygwin*)
- lt_cv_dlopen="dlopen"
- lt_cv_dlopen_libs=
- ;;
-
- darwin*)
- # if libdl is installed we need to link against it
- AC_CHECK_LIB([dl], [dlopen],
- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
- lt_cv_dlopen="dyld"
- lt_cv_dlopen_libs=
- lt_cv_dlopen_self=yes
- ])
- ;;
-
- *)
- AC_CHECK_FUNC([shl_load],
- [lt_cv_dlopen="shl_load"],
- [AC_CHECK_LIB([dld], [shl_load],
- [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"],
- [AC_CHECK_FUNC([dlopen],
- [lt_cv_dlopen="dlopen"],
- [AC_CHECK_LIB([dl], [dlopen],
- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
- [AC_CHECK_LIB([svld], [dlopen],
- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
- [AC_CHECK_LIB([dld], [dld_link],
- [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"])
- ])
- ])
- ])
- ])
- ])
- ;;
- esac
-
- if test "x$lt_cv_dlopen" != xno; then
- enable_dlopen=yes
- else
- enable_dlopen=no
- fi
-
- case $lt_cv_dlopen in
- dlopen)
- save_CPPFLAGS="$CPPFLAGS"
- test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
-
- save_LDFLAGS="$LDFLAGS"
- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
-
- save_LIBS="$LIBS"
- LIBS="$lt_cv_dlopen_libs $LIBS"
-
- AC_CACHE_CHECK([whether a program can dlopen itself],
- lt_cv_dlopen_self, [dnl
- _LT_AC_TRY_DLOPEN_SELF(
- lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
- lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
- ])
-
- if test "x$lt_cv_dlopen_self" = xyes; then
- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
- AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
- lt_cv_dlopen_self_static, [dnl
- _LT_AC_TRY_DLOPEN_SELF(
- lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
- lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
- ])
- fi
-
- CPPFLAGS="$save_CPPFLAGS"
- LDFLAGS="$save_LDFLAGS"
- LIBS="$save_LIBS"
- ;;
- esac
-
- case $lt_cv_dlopen_self in
- yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
- *) enable_dlopen_self=unknown ;;
- esac
-
- case $lt_cv_dlopen_self_static in
- yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
- *) enable_dlopen_self_static=unknown ;;
- esac
-fi
-])# AC_LIBTOOL_DLOPEN_SELF
-
-
-# AC_LIBTOOL_PROG_CC_C_O([TAGNAME])
-# ---------------------------------
-# Check to see if options -c and -o are simultaneously supported by compiler
-AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O],
-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
-AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
- [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
- [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
- $rm -r conftest 2>/dev/null
- mkdir conftest
- cd conftest
- mkdir out
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- lt_compiler_flag="-o out/conftest2.$ac_objext"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
- (eval "$lt_compile" 2>out/conftest.err)
- ac_status=$?
- cat out/conftest.err >&AS_MESSAGE_LOG_FD
- echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
- if (exit $ac_status) && test -s out/conftest2.$ac_objext
- then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
- _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
- fi
- fi
- chmod u+w . 2>&AS_MESSAGE_LOG_FD
- $rm conftest*
- # SGI C++ compiler will create directory out/ii_files/ for
- # template instantiation
- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
- $rm out/* && rmdir out
- cd ..
- rmdir conftest
- $rm conftest*
-])
-])# AC_LIBTOOL_PROG_CC_C_O
-
-
-# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME])
-# -----------------------------------------
-# Check to see if we can do hard links to lock some files if needed
-AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS],
-[AC_REQUIRE([_LT_AC_LOCK])dnl
-
-hard_links="nottested"
-if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
- # do not overwrite the value of need_locks provided by the user
- AC_MSG_CHECKING([if we can lock with hard links])
- hard_links=yes
- $rm conftest*
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- touch conftest.a
- ln conftest.a conftest.b 2>&5 || hard_links=no
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- AC_MSG_RESULT([$hard_links])
- if test "$hard_links" = no; then
- AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
- need_locks=warn
- fi
-else
- need_locks=no
-fi
-])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS
-
-
-# AC_LIBTOOL_OBJDIR
-# -----------------
-AC_DEFUN([AC_LIBTOOL_OBJDIR],
-[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
-[rm -f .libs 2>/dev/null
-mkdir .libs 2>/dev/null
-if test -d .libs; then
- lt_cv_objdir=.libs
-else
- # MS-DOS does not allow filenames that begin with a dot.
- lt_cv_objdir=_libs
-fi
-rmdir .libs 2>/dev/null])
-objdir=$lt_cv_objdir
-])# AC_LIBTOOL_OBJDIR
-
-
-# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME])
-# ----------------------------------------------
-# Check hardcoding attributes.
-AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH],
-[AC_MSG_CHECKING([how to hardcode library paths into programs])
-_LT_AC_TAGVAR(hardcode_action, $1)=
-if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \
- test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \
- test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
-
- # We can hardcode non-existant directories.
- if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no &&
- # If the only mechanism to avoid hardcoding is shlibpath_var, we
- # have to relink, otherwise we might link with an installed library
- # when we should be linking with a yet-to-be-installed one
- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
- test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then
- # Linking always hardcodes the temporary library directory.
- _LT_AC_TAGVAR(hardcode_action, $1)=relink
- else
- # We can link without hardcoding, and we can hardcode nonexisting dirs.
- _LT_AC_TAGVAR(hardcode_action, $1)=immediate
- fi
-else
- # We cannot hardcode anything, or else we can only hardcode existing
- # directories.
- _LT_AC_TAGVAR(hardcode_action, $1)=unsupported
-fi
-AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)])
-
-if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then
- # Fast installation is not supported
- enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
- test "$enable_shared" = no; then
- # Fast installation is not necessary
- enable_fast_install=needless
-fi
-])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH
-
-
-# AC_LIBTOOL_SYS_LIB_STRIP
-# ------------------------
-AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP],
-[striplib=
-old_striplib=
-AC_MSG_CHECKING([whether stripping libraries is possible])
-if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
- test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
- test -z "$striplib" && striplib="$STRIP --strip-unneeded"
- AC_MSG_RESULT([yes])
-else
-# FIXME - insert some real tests, host_os isn't really good enough
- case $host_os in
- darwin*)
- if test -n "$STRIP" ; then
- striplib="$STRIP -x"
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
-fi
- ;;
- *)
- AC_MSG_RESULT([no])
- ;;
- esac
-fi
-])# AC_LIBTOOL_SYS_LIB_STRIP
-
-
-# AC_LIBTOOL_SYS_DYNAMIC_LINKER
-# -----------------------------
-# PORTME Fill in your ld.so characteristics
-AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER],
-[AC_MSG_CHECKING([dynamic linker characteristics])
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
- # if the path contains ";" then we assume it to be the separator
- # otherwise default to the standard path separator (i.e. ":") - it is
- # assumed that no part of a normal pathname contains ";" but that should
- # okay in the real world where ";" in dirpaths is itself problematic.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
-else
- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
- shlibpath_var=LIBPATH
-
- # AIX 3 has no versioning support, so we append a major version to the name.
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
-
-aix4* | aix5*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- hardcode_into_libs=yes
- if test "$host_cpu" = ia64; then
- # AIX 5 supports IA64
- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- else
- # With GCC up to 2.95.x, collect2 would create an import file
- # for dependence libraries. The import file would start with
- # the line `#! .'. This would cause the generated library to
- # depend on `.', always an invalid library. This was fixed in
- # development snapshots of GCC prior to 3.0.
- case $host_os in
- aix4 | aix4.[[01]] | aix4.[[01]].*)
- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
- echo ' yes '
- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
- :
- else
- can_build_shared=no
- fi
- ;;
- esac
- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
- # soname into executable. Probably we can add versioning support to
- # collect2, so additional links can be useful in future.
- if test "$aix_use_runtimelinking" = yes; then
- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
- # instead of lib<name>.a to let people know that these are not
- # typical AIX shared libraries.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- else
- # We preserve .a as extension for shared libraries through AIX4.2
- # and later when we are not doing run time linking.
- library_names_spec='${libname}${release}.a $libname.a'
- soname_spec='${libname}${release}${shared_ext}$major'
- fi
- shlibpath_var=LIBPATH
- fi
- ;;
-
-amigaos*)
- library_names_spec='$libname.ixlibrary $libname.a'
- # Create ${libname}_ixlibrary.a entries in /sys/libs.
- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
- ;;
-
-beos*)
- library_names_spec='${libname}${shared_ext}'
- dynamic_linker="$host_os ld.so"
- shlibpath_var=LIBRARY_PATH
- ;;
-
-bsdi[[45]]*)
- version_type=linux
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
- # the default ld.so.conf also contains /usr/contrib/lib and
- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
- # libtool to hard-code these into programs
- ;;
-
-cygwin* | mingw* | pw32*)
- version_type=windows
- shrext_cmds=".dll"
- need_version=no
- need_lib_prefix=no
-
- case $GCC,$host_os in
- yes,cygwin* | yes,mingw* | yes,pw32*)
- library_names_spec='$libname.dll.a'
- # DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
- dldir=$destdir/`dirname \$dlpath`~
- test -d \$dldir || mkdir -p \$dldir~
- $install_prog $dir/$dlname \$dldir/$dlname~
- chmod a+x \$dldir/$dlname'
- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
- dlpath=$dir/\$dldll~
- $rm \$dlpath'
- shlibpath_overrides_runpath=yes
-
- case $host_os in
- cygwin*)
- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
- ;;
- mingw*)
- # MinGW DLLs use traditional 'lib' prefix
- soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then
- # It is most probably a Windows format PATH printed by
- # mingw gcc, but we are running on Cygwin. Gcc prints its search
- # path with ; separators, and with drive letters. We can handle the
- # drive letters (cygwin fileutils understands them), so leave them,
- # especially as we might pass files found there to a mingw objdump,
- # which wouldn't understand a cygwinified path. Ahh.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
- ;;
- pw32*)
- # pw32 DLLs use 'pw' prefix rather than 'lib'
- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
- ;;
- esac
- ;;
-
- *)
- library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
- ;;
- esac
- dynamic_linker='Win32 ld.exe'
- # FIXME: first we should search . and the directory the executable is in
- shlibpath_var=PATH
- ;;
-
-darwin* | rhapsody*)
- dynamic_linker="$host_os dyld"
- version_type=darwin
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
- soname_spec='${libname}${release}${major}$shared_ext'
- shlibpath_overrides_runpath=yes
- shlibpath_var=DYLD_LIBRARY_PATH
- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
- if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
- else
- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
- fi
- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
- ;;
-
-dgux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-freebsd1*)
- dynamic_linker=no
- ;;
-
-kfreebsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-freebsd* | dragonfly*)
- # DragonFly does not have aout. When/if they implement a new
- # versioning mechanism, adjust this.
- if test -x /usr/bin/objformat; then
- objformat=`/usr/bin/objformat`
- else
- case $host_os in
- freebsd[[123]]*) objformat=aout ;;
- *) objformat=elf ;;
- esac
- fi
- version_type=freebsd-$objformat
- case $version_type in
- freebsd-elf*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- need_version=no
- need_lib_prefix=no
- ;;
- freebsd-*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
- need_version=yes
- ;;
- esac
- shlibpath_var=LD_LIBRARY_PATH
- case $host_os in
- freebsd2*)
- shlibpath_overrides_runpath=yes
- ;;
- freebsd3.[[01]]* | freebsdelf3.[[01]]*)
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
- freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
- freebsd*) # from 4.6 on
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- esac
- ;;
-
-gnu*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- ;;
-
-hpux9* | hpux10* | hpux11*)
- # Give a soname corresponding to the major version so that dld.sl refuses to
- # link against other versions.
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- case $host_cpu in
- ia64*)
- shrext_cmds='.so'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.so"
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- if test "X$HPUX_IA64_MODE" = X32; then
- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
- else
- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
- fi
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- hppa*64*)
- shrext_cmds='.sl'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- *)
- shrext_cmds='.sl'
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=SHLIB_PATH
- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
- esac
- # HP-UX runs *really* slowly unless shared libraries are mode 555.
- postinstall_cmds='chmod 555 $lib'
- ;;
-
-interix3*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $host_os in
- nonstopux*) version_type=nonstopux ;;
- *)
- if test "$lt_cv_prog_gnu_ld" = yes; then
- version_type=linux
- else
- version_type=irix
- fi ;;
- esac
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
- case $host_os in
- irix5* | nonstopux*)
- libsuff= shlibsuff=
- ;;
- *)
- case $LD in # libtool.m4 will add one of these switches to LD
- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
- libsuff= shlibsuff= libmagic=32-bit;;
- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
- libsuff=32 shlibsuff=N32 libmagic=N32;;
- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
- libsuff=64 shlibsuff=64 libmagic=64-bit;;
- *) libsuff= shlibsuff= libmagic=never-match;;
- esac
- ;;
- esac
- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
- hardcode_into_libs=yes
- ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
- dynamic_linker=no
- ;;
-
-# This must be Linux ELF.
-linux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- # This implies no fast_install, which is unacceptable.
- # Some rework will be needed to allow for fast_install
- # before this can be enabled.
- hardcode_into_libs=yes
-
- # Append ld.so.conf contents to the search path
- if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
- fi
-
- # We used to test for /lib/ld.so.1 and disable shared libraries on
- # powerpc, because MkLinux only supported shared libraries with the
- # GNU dynamic linker. Since this was broken with cross compilers,
- # most powerpc-linux boxes support dynamic linking these days and
- # people can always --disable-shared, the test was removed, and we
- # assume the GNU/Linux dynamic linker is in use.
- dynamic_linker='GNU/Linux ld.so'
- ;;
-
-netbsdelf*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='NetBSD ld.elf_so'
- ;;
-
-knetbsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-netbsd*)
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- dynamic_linker='NetBSD (a.out) ld.so'
- else
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='NetBSD ld.elf_so'
- fi
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
-
-newsos6)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-nto-qnx*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-openbsd*)
- version_type=sunos
- sys_lib_dlsearch_path_spec="/usr/lib"
- need_lib_prefix=no
- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
- case $host_os in
- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
- *) need_version=no ;;
- esac
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- case $host_os in
- openbsd2.[[89]] | openbsd2.[[89]].*)
- shlibpath_overrides_runpath=no
- ;;
- *)
- shlibpath_overrides_runpath=yes
- ;;
- esac
- else
- shlibpath_overrides_runpath=yes
- fi
- ;;
-
-os2*)
- libname_spec='$name'
- shrext_cmds=".dll"
- need_lib_prefix=no
- library_names_spec='$libname${shared_ext} $libname.a'
- dynamic_linker='OS/2 ld.exe'
- shlibpath_var=LIBPATH
- ;;
-
-osf3* | osf4* | osf5*)
- version_type=osf
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
- ;;
-
-solaris*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- # ldd complains unless libraries are executable
- postinstall_cmds='chmod +x $lib'
- ;;
-
-sunos4*)
- version_type=sunos
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- if test "$with_gnu_ld" = yes; then
- need_lib_prefix=no
- fi
- need_version=yes
- ;;
-
-sysv4 | sysv4.3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- case $host_vendor in
- sni)
- shlibpath_overrides_runpath=no
- need_lib_prefix=no
- export_dynamic_flag_spec='${wl}-Blargedynsym'
- runpath_var=LD_RUN_PATH
- ;;
- siemens)
- need_lib_prefix=no
- ;;
- motorola)
- need_lib_prefix=no
- need_version=no
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
- ;;
- esac
- ;;
-
-sysv4*MP*)
- if test -d /usr/nec ;then
- version_type=linux
- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
- soname_spec='$libname${shared_ext}.$major'
- shlibpath_var=LD_LIBRARY_PATH
- fi
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- version_type=freebsd-elf
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- if test "$with_gnu_ld" = yes; then
- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
- shlibpath_overrides_runpath=no
- else
- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
- shlibpath_overrides_runpath=yes
- case $host_os in
- sco3.2v5*)
- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
- ;;
- esac
- fi
- sys_lib_dlsearch_path_spec='/usr/lib'
- ;;
-
-uts4*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-*)
- dynamic_linker=no
- ;;
-esac
-AC_MSG_RESULT([$dynamic_linker])
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-])# AC_LIBTOOL_SYS_DYNAMIC_LINKER
-
-
-# _LT_AC_TAGCONFIG
-# ----------------
-AC_DEFUN([_LT_AC_TAGCONFIG],
-[AC_ARG_WITH([tags],
- [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@],
- [include additional configurations @<:@automatic@:>@])],
- [tagnames="$withval"])
-
-if test -f "$ltmain" && test -n "$tagnames"; then
- if test ! -f "${ofile}"; then
- AC_MSG_WARN([output file `$ofile' does not exist])
- fi
-
- if test -z "$LTCC"; then
- eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
- if test -z "$LTCC"; then
- AC_MSG_WARN([output file `$ofile' does not look like a libtool script])
- else
- AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
- fi
- fi
- if test -z "$LTCFLAGS"; then
- eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
- fi
-
- # Extract list of available tagged configurations in $ofile.
- # Note that this assumes the entire list is on one line.
- available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
-
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for tagname in $tagnames; do
- IFS="$lt_save_ifs"
- # Check whether tagname contains only valid characters
- case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in
- "") ;;
- *) AC_MSG_ERROR([invalid tag name: $tagname])
- ;;
- esac
-
- if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
- then
- AC_MSG_ERROR([tag name \"$tagname\" already exists])
- fi
-
- # Update the list of available tags.
- if test -n "$tagname"; then
- echo appending configuration tag \"$tagname\" to $ofile
-
- case $tagname in
- CXX)
- if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
- (test "X$CXX" != "Xg++"))) ; then
- AC_LIBTOOL_LANG_CXX_CONFIG
- else
- tagname=""
- fi
- ;;
-
- F77)
- if test -n "$F77" && test "X$F77" != "Xno"; then
- AC_LIBTOOL_LANG_F77_CONFIG
- else
- tagname=""
- fi
- ;;
-
- GCJ)
- if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
- AC_LIBTOOL_LANG_GCJ_CONFIG
- else
- tagname=""
- fi
- ;;
-
- RC)
- AC_LIBTOOL_LANG_RC_CONFIG
- ;;
-
- *)
- AC_MSG_ERROR([Unsupported tag name: $tagname])
- ;;
- esac
-
- # Append the new tag name to the list of available tags.
- if test -n "$tagname" ; then
- available_tags="$available_tags $tagname"
- fi
- fi
- done
- IFS="$lt_save_ifs"
-
- # Now substitute the updated list of available tags.
- if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
- mv "${ofile}T" "$ofile"
- chmod +x "$ofile"
- else
- rm -f "${ofile}T"
- AC_MSG_ERROR([unable to update list of available tagged configurations.])
- fi
-fi
-])# _LT_AC_TAGCONFIG
-
-
-# AC_LIBTOOL_DLOPEN
-# -----------------
-# enable checks for dlopen support
-AC_DEFUN([AC_LIBTOOL_DLOPEN],
- [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])
-])# AC_LIBTOOL_DLOPEN
-
-
-# AC_LIBTOOL_WIN32_DLL
-# --------------------
-# declare package support for building win32 DLLs
-AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
-[AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
-])# AC_LIBTOOL_WIN32_DLL
-
-
-# AC_ENABLE_SHARED([DEFAULT])
-# ---------------------------
-# implement the --enable-shared flag
-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
-AC_DEFUN([AC_ENABLE_SHARED],
-[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
-AC_ARG_ENABLE([shared],
- [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
- [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])],
- [p=${PACKAGE-default}
- case $enableval in
- yes) enable_shared=yes ;;
- no) enable_shared=no ;;
- *)
- enable_shared=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_shared=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac],
- [enable_shared=]AC_ENABLE_SHARED_DEFAULT)
-])# AC_ENABLE_SHARED
-
-
-# AC_DISABLE_SHARED
-# -----------------
-# set the default shared flag to --disable-shared
-AC_DEFUN([AC_DISABLE_SHARED],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-AC_ENABLE_SHARED(no)
-])# AC_DISABLE_SHARED
-
-
-# AC_ENABLE_STATIC([DEFAULT])
-# ---------------------------
-# implement the --enable-static flag
-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
-AC_DEFUN([AC_ENABLE_STATIC],
-[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
-AC_ARG_ENABLE([static],
- [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@],
- [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])],
- [p=${PACKAGE-default}
- case $enableval in
- yes) enable_static=yes ;;
- no) enable_static=no ;;
- *)
- enable_static=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_static=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac],
- [enable_static=]AC_ENABLE_STATIC_DEFAULT)
-])# AC_ENABLE_STATIC
-
-
-# AC_DISABLE_STATIC
-# -----------------
-# set the default static flag to --disable-static
-AC_DEFUN([AC_DISABLE_STATIC],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-AC_ENABLE_STATIC(no)
-])# AC_DISABLE_STATIC
-
-
-# AC_ENABLE_FAST_INSTALL([DEFAULT])
-# ---------------------------------
-# implement the --enable-fast-install flag
-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
-AC_DEFUN([AC_ENABLE_FAST_INSTALL],
-[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
-AC_ARG_ENABLE([fast-install],
- [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
- [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
- [p=${PACKAGE-default}
- case $enableval in
- yes) enable_fast_install=yes ;;
- no) enable_fast_install=no ;;
- *)
- enable_fast_install=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_fast_install=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac],
- [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT)
-])# AC_ENABLE_FAST_INSTALL
-
-
-# AC_DISABLE_FAST_INSTALL
-# -----------------------
-# set the default to --disable-fast-install
-AC_DEFUN([AC_DISABLE_FAST_INSTALL],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-AC_ENABLE_FAST_INSTALL(no)
-])# AC_DISABLE_FAST_INSTALL
-
-
-# AC_LIBTOOL_PICMODE([MODE])
-# --------------------------
-# implement the --with-pic flag
-# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
-AC_DEFUN([AC_LIBTOOL_PICMODE],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-pic_mode=ifelse($#,1,$1,default)
-])# AC_LIBTOOL_PICMODE
-
-
-# AC_PROG_EGREP
-# -------------
-# This is predefined starting with Autoconf 2.54, so this conditional
-# definition can be removed once we require Autoconf 2.54 or later.
-m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP],
-[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
- [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
- then ac_cv_prog_egrep='grep -E'
- else ac_cv_prog_egrep='egrep'
- fi])
- EGREP=$ac_cv_prog_egrep
- AC_SUBST([EGREP])
-])])
-
-
-# AC_PATH_TOOL_PREFIX
-# -------------------
-# find a file program which can recognise shared library
-AC_DEFUN([AC_PATH_TOOL_PREFIX],
-[AC_REQUIRE([AC_PROG_EGREP])dnl
-AC_MSG_CHECKING([for $1])
-AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
-[case $MAGIC_CMD in
-[[\\/*] | ?:[\\/]*])
- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
- ;;
-*)
- lt_save_MAGIC_CMD="$MAGIC_CMD"
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-dnl $ac_dummy forces splitting on constant user-supplied paths.
-dnl POSIX.2 word splitting is done only on the output of word expansions,
-dnl not every word. This closes a longstanding sh security hole.
- ac_dummy="ifelse([$2], , $PATH, [$2])"
- for ac_dir in $ac_dummy; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$1; then
- lt_cv_path_MAGIC_CMD="$ac_dir/$1"
- if test -n "$file_magic_test_file"; then
- case $deplibs_check_method in
- "file_magic "*)
- file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
- MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
- $EGREP "$file_magic_regex" > /dev/null; then
- :
- else
- cat <<EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such. This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem. Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool@gnu.org
-
-EOF
- fi ;;
- esac
- fi
- break
- fi
- done
- IFS="$lt_save_ifs"
- MAGIC_CMD="$lt_save_MAGIC_CMD"
- ;;
-esac])
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
- AC_MSG_RESULT($MAGIC_CMD)
-else
- AC_MSG_RESULT(no)
-fi
-])# AC_PATH_TOOL_PREFIX
-
-
-# AC_PATH_MAGIC
-# -------------
-# find a file program which can recognise a shared library
-AC_DEFUN([AC_PATH_MAGIC],
-[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
-if test -z "$lt_cv_path_MAGIC_CMD"; then
- if test -n "$ac_tool_prefix"; then
- AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
- else
- MAGIC_CMD=:
- fi
-fi
-])# AC_PATH_MAGIC
-
-
-# AC_PROG_LD
-# ----------
-# find the pathname to the GNU or non-GNU linker
-AC_DEFUN([AC_PROG_LD],
-[AC_ARG_WITH([gnu-ld],
- [AC_HELP_STRING([--with-gnu-ld],
- [assume the C compiler uses GNU ld @<:@default=no@:>@])],
- [test "$withval" = no || with_gnu_ld=yes],
- [with_gnu_ld=no])
-AC_REQUIRE([LT_AC_PROG_SED])dnl
-AC_REQUIRE([AC_PROG_CC])dnl
-AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
-ac_prog=ld
-if test "$GCC" = yes; then
- # Check if gcc -print-prog-name=ld gives a path.
- AC_MSG_CHECKING([for ld used by $CC])
- case $host in
- *-*-mingw*)
- # gcc leaves a trailing carriage return which upsets mingw
- ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
- *)
- ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
- esac
- case $ac_prog in
- # Accept absolute paths.
- [[\\/]]* | ?:[[\\/]]*)
- re_direlt='/[[^/]][[^/]]*/\.\./'
- # Canonicalize the pathname of ld
- ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
- ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
- done
- test -z "$LD" && LD="$ac_prog"
- ;;
- "")
- # If it fails, then pretend we aren't using GCC.
- ac_prog=ld
- ;;
- *)
- # If it is relative, then search for the first ld in PATH.
- with_gnu_ld=unknown
- ;;
- esac
-elif test "$with_gnu_ld" = yes; then
- AC_MSG_CHECKING([for GNU ld])
-else
- AC_MSG_CHECKING([for non-GNU ld])
-fi
-AC_CACHE_VAL(lt_cv_path_LD,
-[if test -z "$LD"; then
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for ac_dir in $PATH; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
- lt_cv_path_LD="$ac_dir/$ac_prog"
- # Check to see if the program is GNU ld. I'd rather use --version,
- # but apparently some variants of GNU ld only accept -v.
- # Break only if it was the GNU/non-GNU ld that we prefer.
- case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
- *GNU* | *'with BFD'*)
- test "$with_gnu_ld" != no && break
- ;;
- *)
- test "$with_gnu_ld" != yes && break
- ;;
- esac
- fi
- done
- IFS="$lt_save_ifs"
-else
- lt_cv_path_LD="$LD" # Let the user override the test with a path.
-fi])
-LD="$lt_cv_path_LD"
-if test -n "$LD"; then
- AC_MSG_RESULT($LD)
-else
- AC_MSG_RESULT(no)
-fi
-test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
-AC_PROG_LD_GNU
-])# AC_PROG_LD
-
-
-# AC_PROG_LD_GNU
-# --------------
-AC_DEFUN([AC_PROG_LD_GNU],
-[AC_REQUIRE([AC_PROG_EGREP])dnl
-AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
-[# I'd rather use --version here, but apparently some GNU lds only accept -v.
-case `$LD -v 2>&1 </dev/null` in
-*GNU* | *'with BFD'*)
- lt_cv_prog_gnu_ld=yes
- ;;
-*)
- lt_cv_prog_gnu_ld=no
- ;;
-esac])
-with_gnu_ld=$lt_cv_prog_gnu_ld
-])# AC_PROG_LD_GNU
-
-
-# AC_PROG_LD_RELOAD_FLAG
-# ----------------------
-# find reload flag for linker
-# -- PORTME Some linkers may need a different reload flag.
-AC_DEFUN([AC_PROG_LD_RELOAD_FLAG],
-[AC_CACHE_CHECK([for $LD option to reload object files],
- lt_cv_ld_reload_flag,
- [lt_cv_ld_reload_flag='-r'])
-reload_flag=$lt_cv_ld_reload_flag
-case $reload_flag in
-"" | " "*) ;;
-*) reload_flag=" $reload_flag" ;;
-esac
-reload_cmds='$LD$reload_flag -o $output$reload_objs'
-case $host_os in
- darwin*)
- if test "$GCC" = yes; then
- reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
- else
- reload_cmds='$LD$reload_flag -o $output$reload_objs'
- fi
- ;;
-esac
-])# AC_PROG_LD_RELOAD_FLAG
-
-
-# AC_DEPLIBS_CHECK_METHOD
-# -----------------------
-# how to check for library dependencies
-# -- PORTME fill in with the dynamic library characteristics
-AC_DEFUN([AC_DEPLIBS_CHECK_METHOD],
-[AC_CACHE_CHECK([how to recognise dependent libraries],
-lt_cv_deplibs_check_method,
-[lt_cv_file_magic_cmd='$MAGIC_CMD'
-lt_cv_file_magic_test_file=
-lt_cv_deplibs_check_method='unknown'
-# Need to set the preceding variable on all platforms that support
-# interlibrary dependencies.
-# 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
-# 'pass_all' -- all dependencies passed with no checks.
-# 'test_compile' -- check by making test program.
-# 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
-
-case $host_os in
-aix4* | aix5*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-beos*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-bsdi[[45]]*)
- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
- lt_cv_file_magic_cmd='/usr/bin/file -L'
- lt_cv_file_magic_test_file=/shlib/libc.so
- ;;
-
-cygwin*)
- # func_win32_libid is a shell function defined in ltmain.sh
- lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
- lt_cv_file_magic_cmd='func_win32_libid'
- ;;
-
-mingw* | pw32*)
- # Base MSYS/MinGW do not provide the 'file' command needed by
- # func_win32_libid shell function, so use a weaker test based on 'objdump'.
- lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
- lt_cv_file_magic_cmd='$OBJDUMP -f'
- ;;
-
-darwin* | rhapsody*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-freebsd* | kfreebsd*-gnu | dragonfly*)
- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
- case $host_cpu in
- i*86 )
- # Not sure whether the presence of OpenBSD here was a mistake.
- # Let's accept both of them until this is cleared up.
- lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
- lt_cv_file_magic_cmd=/usr/bin/file
- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
- ;;
- esac
- else
- lt_cv_deplibs_check_method=pass_all
- fi
- ;;
-
-gnu*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-hpux10.20* | hpux11*)
- lt_cv_file_magic_cmd=/usr/bin/file
- case $host_cpu in
- ia64*)
- lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
- lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
- ;;
- hppa*64*)
- [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
- lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
- ;;
- *)
- lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
- lt_cv_file_magic_test_file=/usr/lib/libc.sl
- ;;
- esac
- ;;
-
-interix3*)
- # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $LD in
- *-32|*"-32 ") libmagic=32-bit;;
- *-n32|*"-n32 ") libmagic=N32;;
- *-64|*"-64 ") libmagic=64-bit;;
- *) libmagic=never-match;;
- esac
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-# This must be Linux ELF.
-linux*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
- else
- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
- fi
- ;;
-
-newos6*)
- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
- lt_cv_file_magic_cmd=/usr/bin/file
- lt_cv_file_magic_test_file=/usr/lib/libnls.so
- ;;
-
-nto-qnx*)
- lt_cv_deplibs_check_method=unknown
- ;;
-
-openbsd*)
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
- else
- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
- fi
- ;;
-
-osf3* | osf4* | osf5*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-solaris*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-sysv4 | sysv4.3*)
- case $host_vendor in
- motorola)
- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
- ;;
- ncr)
- lt_cv_deplibs_check_method=pass_all
- ;;
- sequent)
- lt_cv_file_magic_cmd='/bin/file'
- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
- ;;
- sni)
- lt_cv_file_magic_cmd='/bin/file'
- lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
- lt_cv_file_magic_test_file=/lib/libc.so
- ;;
- siemens)
- lt_cv_deplibs_check_method=pass_all
- ;;
- pc)
- lt_cv_deplibs_check_method=pass_all
- ;;
- esac
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-esac
-])
-file_magic_cmd=$lt_cv_file_magic_cmd
-deplibs_check_method=$lt_cv_deplibs_check_method
-test -z "$deplibs_check_method" && deplibs_check_method=unknown
-])# AC_DEPLIBS_CHECK_METHOD
-
-
-# AC_PROG_NM
-# ----------
-# find the pathname to a BSD-compatible name lister
-AC_DEFUN([AC_PROG_NM],
-[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM,
-[if test -n "$NM"; then
- # Let the user override the test.
- lt_cv_path_NM="$NM"
-else
- lt_nm_to_check="${ac_tool_prefix}nm"
- if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
- lt_nm_to_check="$lt_nm_to_check nm"
- fi
- for lt_tmp_nm in $lt_nm_to_check; do
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- tmp_nm="$ac_dir/$lt_tmp_nm"
- if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
- # Check to see if the nm accepts a BSD-compat flag.
- # Adding the `sed 1q' prevents false positives on HP-UX, which says:
- # nm: unknown option "B" ignored
- # Tru64's nm complains that /dev/null is an invalid object file
- case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
- */dev/null* | *'Invalid file or object type'*)
- lt_cv_path_NM="$tmp_nm -B"
- break
- ;;
- *)
- case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
- */dev/null*)
- lt_cv_path_NM="$tmp_nm -p"
- break
- ;;
- *)
- lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
- continue # so that we can try to find one that supports BSD flags
- ;;
- esac
- ;;
- esac
- fi
- done
- IFS="$lt_save_ifs"
- done
- test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
-fi])
-NM="$lt_cv_path_NM"
-])# AC_PROG_NM
-
-
-# AC_CHECK_LIBM
-# -------------
-# check for math library
-AC_DEFUN([AC_CHECK_LIBM],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-LIBM=
-case $host in
-*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
- # These system don't have libm, or don't need it
- ;;
-*-ncr-sysv4.3*)
- AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
- AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
- ;;
-*)
- AC_CHECK_LIB(m, cos, LIBM="-lm")
- ;;
-esac
-])# AC_CHECK_LIBM
-
-
-# AC_LIBLTDL_CONVENIENCE([DIRECTORY])
-# -----------------------------------
-# sets LIBLTDL to the link flags for the libltdl convenience library and
-# LTDLINCL to the include flags for the libltdl header and adds
-# --enable-ltdl-convenience to the configure arguments. Note that
-# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided,
-# it is assumed to be `libltdl'. LIBLTDL will be prefixed with
-# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/'
-# (note the single quotes!). If your package is not flat and you're not
-# using automake, define top_builddir and top_srcdir appropriately in
-# the Makefiles.
-AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
- case $enable_ltdl_convenience in
- no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
- "") enable_ltdl_convenience=yes
- ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
- esac
- LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
- LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
- # For backwards non-gettext consistent compatibility...
- INCLTDL="$LTDLINCL"
-])# AC_LIBLTDL_CONVENIENCE
-
-
-# AC_LIBLTDL_INSTALLABLE([DIRECTORY])
-# -----------------------------------
-# sets LIBLTDL to the link flags for the libltdl installable library and
-# LTDLINCL to the include flags for the libltdl header and adds
-# --enable-ltdl-install to the configure arguments. Note that
-# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided,
-# and an installed libltdl is not found, it is assumed to be `libltdl'.
-# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with
-# '${top_srcdir}/' (note the single quotes!). If your package is not
-# flat and you're not using automake, define top_builddir and top_srcdir
-# appropriately in the Makefiles.
-# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
-AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
- AC_CHECK_LIB(ltdl, lt_dlinit,
- [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
- [if test x"$enable_ltdl_install" = xno; then
- AC_MSG_WARN([libltdl not installed, but installation disabled])
- else
- enable_ltdl_install=yes
- fi
- ])
- if test x"$enable_ltdl_install" = x"yes"; then
- ac_configure_args="$ac_configure_args --enable-ltdl-install"
- LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
- LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
- else
- ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
- LIBLTDL="-lltdl"
- LTDLINCL=
- fi
- # For backwards non-gettext consistent compatibility...
- INCLTDL="$LTDLINCL"
-])# AC_LIBLTDL_INSTALLABLE
-
-
-# AC_LIBTOOL_CXX
-# --------------
-# enable support for C++ libraries
-AC_DEFUN([AC_LIBTOOL_CXX],
-[AC_REQUIRE([_LT_AC_LANG_CXX])
-])# AC_LIBTOOL_CXX
-
-
-# _LT_AC_LANG_CXX
-# ---------------
-AC_DEFUN([_LT_AC_LANG_CXX],
-[AC_REQUIRE([AC_PROG_CXX])
-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX])
-])# _LT_AC_LANG_CXX
-
-# _LT_AC_PROG_CXXCPP
-# ------------------
-AC_DEFUN([_LT_AC_PROG_CXXCPP],
-[
-AC_REQUIRE([AC_PROG_CXX])
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
- (test "X$CXX" != "Xg++"))) ; then
- AC_PROG_CXXCPP
-fi
-])# _LT_AC_PROG_CXXCPP
-
-# AC_LIBTOOL_F77
-# --------------
-# enable support for Fortran 77 libraries
-AC_DEFUN([AC_LIBTOOL_F77],
-[AC_REQUIRE([_LT_AC_LANG_F77])
-])# AC_LIBTOOL_F77
-
-
-# _LT_AC_LANG_F77
-# ---------------
-AC_DEFUN([_LT_AC_LANG_F77],
-[AC_REQUIRE([AC_PROG_F77])
-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77])
-])# _LT_AC_LANG_F77
-
-
-# AC_LIBTOOL_GCJ
-# --------------
-# enable support for GCJ libraries
-AC_DEFUN([AC_LIBTOOL_GCJ],
-[AC_REQUIRE([_LT_AC_LANG_GCJ])
-])# AC_LIBTOOL_GCJ
-
-
-# _LT_AC_LANG_GCJ
-# ---------------
-AC_DEFUN([_LT_AC_LANG_GCJ],
-[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
- [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
- [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
- [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
- [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
- [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ])
-])# _LT_AC_LANG_GCJ
-
-
-# AC_LIBTOOL_RC
-# -------------
-# enable support for Windows resource files
-AC_DEFUN([AC_LIBTOOL_RC],
-[AC_REQUIRE([LT_AC_PROG_RC])
-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC])
-])# AC_LIBTOOL_RC
-
-
-# AC_LIBTOOL_LANG_C_CONFIG
-# ------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined. Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG])
-AC_DEFUN([_LT_AC_LANG_C_CONFIG],
-[lt_save_CC="$CC"
-AC_LANG_PUSH(C)
-
-# Source file extension for C test sources.
-ac_ext=c
-
-# Object file extension for compiled C test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(){return(0);}\n'
-
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
-AC_LIBTOOL_PROG_COMPILER_PIC($1)
-AC_LIBTOOL_PROG_CC_C_O($1)
-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-AC_LIBTOOL_PROG_LD_SHLIBS($1)
-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-AC_LIBTOOL_SYS_LIB_STRIP
-AC_LIBTOOL_DLOPEN_SELF
-
-# Report which library types will actually be built
-AC_MSG_CHECKING([if libtool supports shared libraries])
-AC_MSG_RESULT([$can_build_shared])
-
-AC_MSG_CHECKING([whether to build shared libraries])
-test "$can_build_shared" = "no" && enable_shared=no
-
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
-case $host_os in
-aix3*)
- test "$enable_shared" = yes && enable_static=no
- if test -n "$RANLIB"; then
- archive_cmds="$archive_cmds~\$RANLIB \$lib"
- postinstall_cmds='$RANLIB $lib'
- fi
- ;;
-
-aix4* | aix5*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
- fi
- ;;
-esac
-AC_MSG_RESULT([$enable_shared])
-
-AC_MSG_CHECKING([whether to build static libraries])
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-AC_MSG_RESULT([$enable_static])
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_POP
-CC="$lt_save_CC"
-])# AC_LIBTOOL_LANG_C_CONFIG
-
-
-# AC_LIBTOOL_LANG_CXX_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined. Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)])
-AC_DEFUN([_LT_AC_LANG_CXX_CONFIG],
-[AC_LANG_PUSH(C++)
-AC_REQUIRE([AC_PROG_CXX])
-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
-
-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-_LT_AC_TAGVAR(allow_undefined_flag, $1)=
-_LT_AC_TAGVAR(always_export_symbols, $1)=no
-_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
-_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
-_LT_AC_TAGVAR(hardcode_direct, $1)=no
-_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
-_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
-_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
-_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-_LT_AC_TAGVAR(hardcode_automatic, $1)=no
-_LT_AC_TAGVAR(module_cmds, $1)=
-_LT_AC_TAGVAR(module_expsym_cmds, $1)=
-_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_AC_TAGVAR(no_undefined_flag, $1)=
-_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
-
-# Dependencies to place before and after the object being linked:
-_LT_AC_TAGVAR(predep_objects, $1)=
-_LT_AC_TAGVAR(postdep_objects, $1)=
-_LT_AC_TAGVAR(predeps, $1)=
-_LT_AC_TAGVAR(postdeps, $1)=
-_LT_AC_TAGVAR(compiler_lib_search_path, $1)=
-
-# Source file extension for C++ test sources.
-ac_ext=cpp
-
-# Object file extension for compiled C++ test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }\n'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC=$CC
-lt_save_LD=$LD
-lt_save_GCC=$GCC
-GCC=$GXX
-lt_save_with_gnu_ld=$with_gnu_ld
-lt_save_path_LD=$lt_cv_path_LD
-if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
- lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
-else
- $as_unset lt_cv_prog_gnu_ld
-fi
-if test -n "${lt_cv_path_LDCXX+set}"; then
- lt_cv_path_LD=$lt_cv_path_LDCXX
-else
- $as_unset lt_cv_path_LD
-fi
-test -z "${LDCXX+set}" || LD=$LDCXX
-CC=${CXX-"c++"}
-compiler=$CC
-_LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-
-# We don't want -fno-exception wen compiling C++ code, so set the
-# no_builtin_flag separately
-if test "$GXX" = yes; then
- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
-else
- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
-fi
-
-if test "$GXX" = yes; then
- # Set up default GNU C++ configuration
-
- AC_PROG_LD
-
- # Check if GNU C++ uses GNU ld as the underlying linker, since the
- # archiving commands below assume that GNU ld is being used.
- if test "$with_gnu_ld" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-
- # If archive_cmds runs LD, not CC, wlarc should be empty
- # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
- # investigate it a little bit more. (MM)
- wlarc='${wl}'
-
- # ancient GNU ld didn't support --whole-archive et. al.
- if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
- grep 'no-whole-archive' > /dev/null; then
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
- fi
- else
- with_gnu_ld=no
- wlarc=
-
- # A generic and very simple default shared library creation
- # command for GNU C++ for the case where it uses the native
- # linker, instead of GNU ld. If possible, this setting should
- # overridden to take advantage of the native linker features on
- # the platform it is being used on.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
- fi
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
-else
- GXX=no
- with_gnu_ld=no
- wlarc=
-fi
-
-# PORTME: fill in a description of your system's C++ link characteristics
-AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
-_LT_AC_TAGVAR(ld_shlibs, $1)=yes
-case $host_os in
- aix3*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
- for ld_flag in $LDFLAGS; do
- case $ld_flag in
- *-brtl*)
- aix_use_runtimelinking=yes
- break
- ;;
- esac
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- _LT_AC_TAGVAR(archive_cmds, $1)=''
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
- if test "$GXX" = yes; then
- case $host_os in aix4.[[012]]|aix4.[[012]].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- else
- # We have old collect2
- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- _LT_AC_SYS_LIBPATH_AIX
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- _LT_AC_SYS_LIBPATH_AIX
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
-
- chorus*)
- case $cc_basename in
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
- # as there is no search path for DLLs.
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- _LT_AC_TAGVAR(always_export_symbols, $1)=no
- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[[012]])
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[[012]])
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
- if test "$GXX" = yes ; then
- lt_int_apple_cc_single_mod=no
- output_verbose_link_cmd='echo'
- if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
- lt_int_apple_cc_single_mod=yes
- fi
- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- fi
- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- fi
- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- case $cc_basename in
- ec++*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- ghcx*)
- # Green Hills C++ Compiler
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- ;;
- freebsd[[12]]*)
- # C++ shared libraries reported to be fairly broken before switch to ELF
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- freebsd-elf*)
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- ;;
- freebsd* | kfreebsd*-gnu | dragonfly*)
- # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
- # conventions
- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
- ;;
- gnu*)
- ;;
- hpux9*)
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
- # but as the default
- # location of the library.
-
- case $cc_basename in
- CC*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- aCC*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
- ;;
- hpux10*|hpux11*)
- if test $with_gnu_ld = no; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
- ;;
- *)
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- ;;
- esac
- fi
- case $host_cpu in
- hppa*64*|ia64*)
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
- *)
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
- # but as the default
- # location of the library.
- ;;
- esac
-
- case $cc_basename in
- CC*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- aCC*)
- case $host_cpu in
- hppa*64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- ia64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- esac
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes; then
- if test $with_gnu_ld = no; then
- case $host_cpu in
- hppa*64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- ia64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- esac
- fi
- else
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
- ;;
- interix3*)
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
- irix5* | irix6*)
- case $cc_basename in
- CC*)
- # SGI C++
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-
- # Archives containing C++ object files must be created using
- # "CC -ar", where "CC" is the IRIX C++ compiler. This is
- # necessary to make sure instantiated templates are included
- # in the archive.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
- ;;
- *)
- if test "$GXX" = yes; then
- if test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
- fi
- fi
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- ;;
- esac
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- ;;
- linux*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-
- # Archives containing C++ object files must be created using
- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
- ;;
- icpc*)
- # Intel C++
- with_gnu_ld=yes
- # version 8.0 and above of icpc choke on multiply defined symbols
- # if we add $predep_objects and $postdep_objects, however 7.1 and
- # earlier do not add the objects themselves.
- case `$CC -V 2>&1` in
- *"Version 7."*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- ;;
- *) # Version 8.0 or newer
- tmp_idyn=
- case $host_cpu in
- ia64*) tmp_idyn=' -i_dynamic';;
- esac
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- ;;
- esac
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
- ;;
- pgCC*)
- # Portland Group C++ compiler
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- ;;
- cxx*)
- # Compaq C++
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
-
- runpath_var=LD_RUN_PATH
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- esac
- ;;
- lynxos*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- m88k*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- mvs*)
- case $cc_basename in
- cxx*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- ;;
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
- wlarc=
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- fi
- # Workaround some broken pre-1.5 toolchains
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
- ;;
- openbsd2*)
- # C++ shared libraries are fairly broken
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- openbsd*)
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- fi
- output_verbose_link_cmd='echo'
- ;;
- osf3*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Archives containing C++ object files must be created using
- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
-
- ;;
- RCC*)
- # Rational C++ 2.4.1
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- cxx*)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
- else
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
- ;;
- osf4* | osf5*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Archives containing C++ object files must be created using
- # the KAI C++ compiler.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs'
- ;;
- RCC*)
- # Rational C++ 2.4.1
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- cxx*)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
- echo "-hidden">> $lib.exp~
- $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~
- $rm $lib.exp'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
- else
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
- ;;
- psos*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- sunos4*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.x
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- lcc*)
- # Lucid
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- ;;
- solaris*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.2, 5.x and Centerline C++
- _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- case $host_os in
- solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
- *)
- # The C++ compiler is used as linker so we must use $wl
- # flag to pass the commands to the underlying system
- # linker. We must also pass each convience library through
- # to the system linker between allextract/defaultextract.
- # The C++ compiler will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
- ;;
- esac
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
- output_verbose_link_cmd='echo'
-
- # Archives containing C++ object files must be created using
- # "CC -xar", where "CC" is the Sun C++ compiler. This is
- # necessary to make sure instantiated templates are included
- # in the archive.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
- ;;
- gcx*)
- # Green Hills C++ Compiler
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-
- # The C++ compiler must be used to create the archive.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
- ;;
- *)
- # GNU C++ compiler with Solaris linker
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
- if $CC --version | grep -v '^2\.7' > /dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
- else
- # g++ 2.7 appears to require `-G' NOT `-shared' on this
- # platform.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
- fi
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
- fi
- ;;
- esac
- ;;
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- runpath_var='LD_RUN_PATH'
-
- case $cc_basename in
- CC*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- ;;
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- # For security reasons, it is highly recommended that you always
- # use absolute paths for naming shared libraries, and exclude the
- # DT_RUNPATH tag from executables and libraries. But doing so
- # requires that you compile everything twice, which is a pain.
- # So that behaviour is only enabled if SCOABSPATH is set to a
- # non-empty value in the environment. Most likely only useful for
- # creating official distributions of packages.
- # This is a hack until libtool officially supports absolute path
- # names for shared libraries.
- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- case $cc_basename in
- CC*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- ;;
- tandem*)
- case $cc_basename in
- NCC*)
- # NonStop-UX NCC 3.20
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- ;;
- vxworks*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
-esac
-AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
-test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
-
-_LT_AC_TAGVAR(GCC, $1)="$GXX"
-_LT_AC_TAGVAR(LD, $1)="$LD"
-
-AC_LIBTOOL_POSTDEP_PREDEP($1)
-AC_LIBTOOL_PROG_COMPILER_PIC($1)
-AC_LIBTOOL_PROG_CC_C_O($1)
-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-AC_LIBTOOL_PROG_LD_SHLIBS($1)
-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_POP
-CC=$lt_save_CC
-LDCXX=$LD
-LD=$lt_save_LD
-GCC=$lt_save_GCC
-with_gnu_ldcxx=$with_gnu_ld
-with_gnu_ld=$lt_save_with_gnu_ld
-lt_cv_path_LDCXX=$lt_cv_path_LD
-lt_cv_path_LD=$lt_save_path_LD
-lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
-lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-])# AC_LIBTOOL_LANG_CXX_CONFIG
-
-# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
-# ------------------------------------
-# Figure out "hidden" library dependencies from verbose
-# compiler output when linking a shared library.
-# Parse the compiler output and extract the necessary
-# objects, libraries and library flags.
-AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[
-dnl we can't use the lt_simple_compile_test_code here,
-dnl because it contains code intended for an executable,
-dnl not a library. It's possible we should let each
-dnl tag define a new lt_????_link_test_code variable,
-dnl but it's only used here...
-ifelse([$1],[],[cat > conftest.$ac_ext <<EOF
-int a;
-void foo (void) { a = 0; }
-EOF
-],[$1],[CXX],[cat > conftest.$ac_ext <<EOF
-class Foo
-{
-public:
- Foo (void) { a = 0; }
-private:
- int a;
-};
-EOF
-],[$1],[F77],[cat > conftest.$ac_ext <<EOF
- subroutine foo
- implicit none
- integer*4 a
- a=0
- return
- end
-EOF
-],[$1],[GCJ],[cat > conftest.$ac_ext <<EOF
-public class foo {
- private int a;
- public void bar (void) {
- a = 0;
- }
-};
-EOF
-])
-dnl Parse the compiler output and extract the necessary
-dnl objects, libraries and library flags.
-if AC_TRY_EVAL(ac_compile); then
- # Parse the compiler output and extract the necessary
- # objects, libraries and library flags.
-
- # Sentinel used to keep track of whether or not we are before
- # the conftest object file.
- pre_test_object_deps_done=no
-
- # The `*' in the case matches for architectures that use `case' in
- # $output_verbose_cmd can trigger glob expansion during the loop
- # eval without this substitution.
- output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
-
- for p in `eval $output_verbose_link_cmd`; do
- case $p in
-
- -L* | -R* | -l*)
- # Some compilers place space between "-{L,R}" and the path.
- # Remove the space.
- if test $p = "-L" \
- || test $p = "-R"; then
- prev=$p
- continue
- else
- prev=
- fi
-
- if test "$pre_test_object_deps_done" = no; then
- case $p in
- -L* | -R*)
- # Internal compiler library paths should come after those
- # provided the user. The postdeps already come after the
- # user supplied libs so there is no need to process them.
- if test -z "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
- _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
- else
- _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${_LT_AC_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
- fi
- ;;
- # The "-l" case would never come before the object being
- # linked, so don't bother handling this case.
- esac
- else
- if test -z "$_LT_AC_TAGVAR(postdeps, $1)"; then
- _LT_AC_TAGVAR(postdeps, $1)="${prev}${p}"
- else
- _LT_AC_TAGVAR(postdeps, $1)="${_LT_AC_TAGVAR(postdeps, $1)} ${prev}${p}"
- fi
- fi
- ;;
-
- *.$objext)
- # This assumes that the test object file only shows up
- # once in the compiler output.
- if test "$p" = "conftest.$objext"; then
- pre_test_object_deps_done=yes
- continue
- fi
-
- if test "$pre_test_object_deps_done" = no; then
- if test -z "$_LT_AC_TAGVAR(predep_objects, $1)"; then
- _LT_AC_TAGVAR(predep_objects, $1)="$p"
- else
- _LT_AC_TAGVAR(predep_objects, $1)="$_LT_AC_TAGVAR(predep_objects, $1) $p"
- fi
- else
- if test -z "$_LT_AC_TAGVAR(postdep_objects, $1)"; then
- _LT_AC_TAGVAR(postdep_objects, $1)="$p"
- else
- _LT_AC_TAGVAR(postdep_objects, $1)="$_LT_AC_TAGVAR(postdep_objects, $1) $p"
- fi
- fi
- ;;
-
- *) ;; # Ignore the rest.
-
- esac
- done
-
- # Clean up.
- rm -f a.out a.exe
-else
- echo "libtool.m4: error: problem compiling $1 test program"
-fi
-
-$rm -f confest.$objext
-
-# PORTME: override above test on systems where it is broken
-ifelse([$1],[CXX],
-[case $host_os in
-interix3*)
- # Interix 3.5 installs completely hosed .la files for C++, so rather than
- # hack all around it, let's just trust "g++" to DTRT.
- _LT_AC_TAGVAR(predep_objects,$1)=
- _LT_AC_TAGVAR(postdep_objects,$1)=
- _LT_AC_TAGVAR(postdeps,$1)=
- ;;
-
-solaris*)
- case $cc_basename in
- CC*)
- # Adding this requires a known-good setup of shared libraries for
- # Sun compiler versions before 5.6, else PIC objects from an old
- # archive will be linked into the output, leading to subtle bugs.
- _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
- ;;
- esac
- ;;
-esac
-])
-
-case " $_LT_AC_TAGVAR(postdeps, $1) " in
-*" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
-esac
-])# AC_LIBTOOL_POSTDEP_PREDEP
-
-# AC_LIBTOOL_LANG_F77_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined. Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)])
-AC_DEFUN([_LT_AC_LANG_F77_CONFIG],
-[AC_REQUIRE([AC_PROG_F77])
-AC_LANG_PUSH(Fortran 77)
-
-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-_LT_AC_TAGVAR(allow_undefined_flag, $1)=
-_LT_AC_TAGVAR(always_export_symbols, $1)=no
-_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
-_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
-_LT_AC_TAGVAR(hardcode_direct, $1)=no
-_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
-_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
-_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
-_LT_AC_TAGVAR(hardcode_automatic, $1)=no
-_LT_AC_TAGVAR(module_cmds, $1)=
-_LT_AC_TAGVAR(module_expsym_cmds, $1)=
-_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_AC_TAGVAR(no_undefined_flag, $1)=
-_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
-
-# Source file extension for f77 test sources.
-ac_ext=f
-
-# Object file extension for compiled f77 test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code=" subroutine t\n return\n end\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code=" program t\n end\n"
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${F77-"f77"}
-compiler=$CC
-_LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-
-AC_MSG_CHECKING([if libtool supports shared libraries])
-AC_MSG_RESULT([$can_build_shared])
-
-AC_MSG_CHECKING([whether to build shared libraries])
-test "$can_build_shared" = "no" && enable_shared=no
-
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
-case $host_os in
-aix3*)
- test "$enable_shared" = yes && enable_static=no
- if test -n "$RANLIB"; then
- archive_cmds="$archive_cmds~\$RANLIB \$lib"
- postinstall_cmds='$RANLIB $lib'
- fi
- ;;
-aix4* | aix5*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
- fi
- ;;
-esac
-AC_MSG_RESULT([$enable_shared])
-
-AC_MSG_CHECKING([whether to build static libraries])
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-AC_MSG_RESULT([$enable_static])
-
-_LT_AC_TAGVAR(GCC, $1)="$G77"
-_LT_AC_TAGVAR(LD, $1)="$LD"
-
-AC_LIBTOOL_PROG_COMPILER_PIC($1)
-AC_LIBTOOL_PROG_CC_C_O($1)
-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-AC_LIBTOOL_PROG_LD_SHLIBS($1)
-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_POP
-CC="$lt_save_CC"
-])# AC_LIBTOOL_LANG_F77_CONFIG
-
-
-# AC_LIBTOOL_LANG_GCJ_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined. Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)])
-AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG],
-[AC_LANG_SAVE
-
-# Source file extension for Java test sources.
-ac_ext=java
-
-# Object file extension for compiled Java test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="class foo {}\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }\n'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${GCJ-"gcj"}
-compiler=$CC
-_LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-
-# GCJ did not exist at the time GCC didn't implicitly link libc in.
-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-
-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-
-AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
-AC_LIBTOOL_PROG_COMPILER_PIC($1)
-AC_LIBTOOL_PROG_CC_C_O($1)
-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-AC_LIBTOOL_PROG_LD_SHLIBS($1)
-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_RESTORE
-CC="$lt_save_CC"
-])# AC_LIBTOOL_LANG_GCJ_CONFIG
-
-
-# AC_LIBTOOL_LANG_RC_CONFIG
-# -------------------------
-# Ensure that the configuration vars for the Windows resource compiler are
-# suitably defined. Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)])
-AC_DEFUN([_LT_AC_LANG_RC_CONFIG],
-[AC_LANG_SAVE
-
-# Source file extension for RC test sources.
-ac_ext=rc
-
-# Object file extension for compiled RC test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
-
-# Code to be used in simple link tests
-lt_simple_link_test_code="$lt_simple_compile_test_code"
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${RC-"windres"}
-compiler=$CC
-_LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_RESTORE
-CC="$lt_save_CC"
-])# AC_LIBTOOL_LANG_RC_CONFIG
-
-
-# AC_LIBTOOL_CONFIG([TAGNAME])
-# ----------------------------
-# If TAGNAME is not passed, then create an initial libtool script
-# with a default configuration from the untagged config vars. Otherwise
-# add code to config.status for appending the configuration named by
-# TAGNAME from the matching tagged config vars.
-AC_DEFUN([AC_LIBTOOL_CONFIG],
-[# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- _LT_AC_TAGVAR(compiler, $1) \
- _LT_AC_TAGVAR(CC, $1) \
- _LT_AC_TAGVAR(LD, $1) \
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1) \
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1) \
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1) \
- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) \
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \
- _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \
- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) \
- _LT_AC_TAGVAR(old_archive_cmds, $1) \
- _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \
- _LT_AC_TAGVAR(predep_objects, $1) \
- _LT_AC_TAGVAR(postdep_objects, $1) \
- _LT_AC_TAGVAR(predeps, $1) \
- _LT_AC_TAGVAR(postdeps, $1) \
- _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
- _LT_AC_TAGVAR(archive_cmds, $1) \
- _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
- _LT_AC_TAGVAR(postinstall_cmds, $1) \
- _LT_AC_TAGVAR(postuninstall_cmds, $1) \
- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) \
- _LT_AC_TAGVAR(allow_undefined_flag, $1) \
- _LT_AC_TAGVAR(no_undefined_flag, $1) \
- _LT_AC_TAGVAR(export_symbols_cmds, $1) \
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) \
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) \
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1) \
- _LT_AC_TAGVAR(hardcode_automatic, $1) \
- _LT_AC_TAGVAR(module_cmds, $1) \
- _LT_AC_TAGVAR(module_expsym_cmds, $1) \
- _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \
- _LT_AC_TAGVAR(exclude_expsyms, $1) \
- _LT_AC_TAGVAR(include_expsyms, $1); do
-
- case $var in
- _LT_AC_TAGVAR(old_archive_cmds, $1) | \
- _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) | \
- _LT_AC_TAGVAR(archive_cmds, $1) | \
- _LT_AC_TAGVAR(archive_expsym_cmds, $1) | \
- _LT_AC_TAGVAR(module_cmds, $1) | \
- _LT_AC_TAGVAR(module_expsym_cmds, $1) | \
- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) | \
- _LT_AC_TAGVAR(export_symbols_cmds, $1) | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\[$]0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\[$]0 --fallback-echo"[$]/[$]0 --fallback-echo"/'`
- ;;
- esac
-
-ifelse([$1], [],
- [cfgfile="${ofile}T"
- trap "$rm \"$cfgfile\"; exit 1" 1 2 15
- $rm -f "$cfgfile"
- AC_MSG_NOTICE([creating $ofile])],
- [cfgfile="$ofile"])
-
- cat <<__EOF__ >> "$cfgfile"
-ifelse([$1], [],
-[#! $SHELL
-
-# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
-# NOTE: Changes made to this file will be lost: look at ltmain.sh.
-#
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
-# Free Software Foundation, Inc.
-#
-# This file is part of GNU Libtool:
-# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
-#
-# 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/>.
-#
-# 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.
-
-# A sed program that does not truncate output.
-SED=$lt_SED
-
-# Sed that helps us avoid accidentally triggering echo(1) options like -n.
-Xsed="$SED -e 1s/^X//"
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-# The names of the tagged configurations supported by this script.
-available_tags=
-
-# ### BEGIN LIBTOOL CONFIG],
-[# ### BEGIN LIBTOOL TAG CONFIG: $tagname])
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
-
-# Is the compiler the GNU C compiler?
-with_gcc=$_LT_AC_TAGVAR(GCC, $1)
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_[]_LT_AC_TAGVAR(LD, $1)
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1)
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1)
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1)
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1)
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1)
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1)
-archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1)
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1)
-module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1)
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1)
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1)
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1)
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1)
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1)
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1)
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1)
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1)
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1)
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1)
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1)
-
-# Symbols that must always be exported.
-include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1)
-
-ifelse([$1],[],
-[# ### END LIBTOOL CONFIG],
-[# ### END LIBTOOL TAG CONFIG: $tagname])
-
-__EOF__
-
-ifelse([$1],[], [
- case $host_os in
- aix3*)
- cat <<\EOF >> "$cfgfile"
-
-# AIX sometimes has problems with the GCC collect2 program. For some
-# reason, if we set the COLLECT_NAMES environment variable, the problems
-# vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
- COLLECT_NAMES=
- export COLLECT_NAMES
-fi
-EOF
- ;;
- esac
-
- # We use sed instead of cat because bash on DJGPP gets confused if
- # if finds mixed CR/LF and LF-only lines. Since sed operates in
- # text mode, it properly converts lines to CR/LF. This bash problem
- # is reportedly fixed, but why not run on old versions too?
- sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
-
- mv -f "$cfgfile" "$ofile" || \
- (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
- chmod +x "$ofile"
-])
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-])# AC_LIBTOOL_CONFIG
-
-
-# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME])
-# -------------------------------------------
-AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI],
-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
-
-_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
-
-if test "$GCC" = yes; then
- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
-
- AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
- lt_cv_prog_compiler_rtti_exceptions,
- [-fno-rtti -fno-exceptions], [],
- [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
-fi
-])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI
-
-
-# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
-# ---------------------------------
-AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE],
-[AC_REQUIRE([AC_CANONICAL_HOST])
-AC_REQUIRE([AC_PROG_NM])
-AC_REQUIRE([AC_OBJEXT])
-# Check for command to grab the raw symbol name followed by C symbol from nm.
-AC_MSG_CHECKING([command to parse $NM output from $compiler object])
-AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
-[
-# These are sane defaults that work on at least a few old systems.
-# [They come from Ultrix. What could be older than Ultrix?!! ;)]
-
-# Character class describing NM global symbol codes.
-symcode='[[BCDEGRST]]'
-
-# Regexp to match symbols that can be accessed directly from C.
-sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
-
-# Transform an extracted symbol line into a proper C declaration
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
-
-# Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
-
-# Define system-specific variables.
-case $host_os in
-aix*)
- symcode='[[BCDT]]'
- ;;
-cygwin* | mingw* | pw32*)
- symcode='[[ABCDGISTW]]'
- ;;
-hpux*) # Its linker distinguishes data from code symbols
- if test "$host_cpu" = ia64; then
- symcode='[[ABCDEGRST]]'
- fi
- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
- ;;
-linux*)
- if test "$host_cpu" = ia64; then
- symcode='[[ABCDGIRSTW]]'
- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
- fi
- ;;
-irix* | nonstopux*)
- symcode='[[BCDEGRST]]'
- ;;
-osf*)
- symcode='[[BCDEGQRST]]'
- ;;
-solaris*)
- symcode='[[BDRT]]'
- ;;
-sco3.2v5*)
- symcode='[[DT]]'
- ;;
-sysv4.2uw2*)
- symcode='[[DT]]'
- ;;
-sysv5* | sco5v6* | unixware* | OpenUNIX*)
- symcode='[[ABDT]]'
- ;;
-sysv4)
- symcode='[[DFNSTU]]'
- ;;
-esac
-
-# Handle CRLF in mingw tool chain
-opt_cr=
-case $build_os in
-mingw*)
- opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
- ;;
-esac
-
-# If we're using GNU nm, then use its standard symbol codes.
-case `$NM -V 2>&1` in
-*GNU* | *'with BFD'*)
- symcode='[[ABCDGIRSTW]]' ;;
-esac
-
-# Try without a prefix undercore, then with it.
-for ac_symprfx in "" "_"; do
-
- # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
- symxfrm="\\1 $ac_symprfx\\2 \\2"
-
- # Write the raw and C identifiers.
- lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
-
- # Check to see that the pipe works correctly.
- pipe_works=no
-
- rm -f conftest*
- cat > conftest.$ac_ext <<EOF
-#ifdef __cplusplus
-extern "C" {
-#endif
-char nm_test_var;
-void nm_test_func(){}
-#ifdef __cplusplus
-}
-#endif
-int main(){nm_test_var='a';nm_test_func();return(0);}
-EOF
-
- if AC_TRY_EVAL(ac_compile); then
- # Now try to grab the symbols.
- nlist=conftest.nm
- if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
- # Try sorting and uniquifying the output.
- if sort "$nlist" | uniq > "$nlist"T; then
- mv -f "$nlist"T "$nlist"
- else
- rm -f "$nlist"T
- fi
-
- # Make sure that we snagged all the symbols we need.
- if grep ' nm_test_var$' "$nlist" >/dev/null; then
- if grep ' nm_test_func$' "$nlist" >/dev/null; then
- cat <<EOF > conftest.$ac_ext
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-EOF
- # Now generate the symbol file.
- eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
-
- cat <<EOF >> conftest.$ac_ext
-#if defined (__STDC__) && __STDC__
-# define lt_ptr_t void *
-#else
-# define lt_ptr_t char *
-# define const
-#endif
-
-/* The mapping between symbol names and symbols. */
-const struct {
- const char *name;
- lt_ptr_t address;
-}
-lt_preloaded_symbols[[]] =
-{
-EOF
- $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
- cat <<\EOF >> conftest.$ac_ext
- {0, (lt_ptr_t) 0}
-};
-
-#ifdef __cplusplus
-}
-#endif
-EOF
- # Now try linking the two files.
- mv conftest.$ac_objext conftstm.$ac_objext
- lt_save_LIBS="$LIBS"
- lt_save_CFLAGS="$CFLAGS"
- LIBS="conftstm.$ac_objext"
- CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
- pipe_works=yes
- fi
- LIBS="$lt_save_LIBS"
- CFLAGS="$lt_save_CFLAGS"
- else
- echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
- fi
- else
- echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
- fi
- else
- echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
- fi
- else
- echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
- cat conftest.$ac_ext >&5
- fi
- rm -f conftest* conftst*
-
- # Do not use the global_symbol_pipe unless it works.
- if test "$pipe_works" = yes; then
- break
- else
- lt_cv_sys_global_symbol_pipe=
- fi
-done
-])
-if test -z "$lt_cv_sys_global_symbol_pipe"; then
- lt_cv_sys_global_symbol_to_cdecl=
-fi
-if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
- AC_MSG_RESULT(failed)
-else
- AC_MSG_RESULT(ok)
-fi
-]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
-
-
-# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME])
-# ---------------------------------------
-AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC],
-[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=
-_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
-_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=
-
-AC_MSG_CHECKING([for $compiler option to produce PIC])
- ifelse([$1],[CXX],[
- # C++ specific cases for pic, static, wl, etc.
- if test "$GXX" = yes; then
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- fi
- ;;
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
- ;;
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
- mingw* | os2* | pw32*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
- ;;
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
- ;;
- *djgpp*)
- # DJGPP does not support shared libraries at all
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
- ;;
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
- sysv4*MP*)
- if test -d /usr/nec; then
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
- fi
- ;;
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
- ;;
- esac
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
- ;;
- esac
- else
- case $host_os in
- aix4* | aix5*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- else
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- chorus*)
- case $cc_basename in
- cxch68*)
- # Green Hills C++ Compiler
- # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
- ;;
- esac
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- ;;
- esac
- ;;
- dgux*)
- case $cc_basename in
- ec++*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- ;;
- ghcx*)
- # Green Hills C++ Compiler
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
- ;;
- *)
- ;;
- esac
- ;;
- freebsd* | kfreebsd*-gnu | dragonfly*)
- # FreeBSD uses GNU C++
- ;;
- hpux9* | hpux10* | hpux11*)
- case $cc_basename in
- CC*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
- if test "$host_cpu" != ia64; then
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
- fi
- ;;
- aCC*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
- ;;
- esac
- ;;
- *)
- ;;
- esac
- ;;
- interix*)
- # This is c89, which is MS Visual C++ (no shared libs)
- # Anyone wants to do a port?
- ;;
- irix5* | irix6* | nonstopux*)
- case $cc_basename in
- CC*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- # CC pic flag -KPIC is the default.
- ;;
- *)
- ;;
- esac
- ;;
- linux*)
- case $cc_basename in
- KCC*)
- # KAI C++ Compiler
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
- ;;
- icpc* | ecpc*)
- # Intel C++
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
- ;;
- pgCC*)
- # Portland Group C++ compiler.
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
- cxx*)
- # Compaq C++
- # Make sure the PIC flag is empty. It appears that all Alpha
- # Linux and Compaq Tru64 Unix objects are PIC.
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- ;;
- *)
- ;;
- esac
- ;;
- lynxos*)
- ;;
- m88k*)
- ;;
- mvs*)
- case $cc_basename in
- cxx*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
- ;;
- *)
- ;;
- esac
- ;;
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- ;;
- osf3* | osf4* | osf5*)
- case $cc_basename in
- KCC*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
- ;;
- RCC*)
- # Rational C++ 2.4.1
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
- ;;
- cxx*)
- # Digital/Compaq C++
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- # Make sure the PIC flag is empty. It appears that all Alpha
- # Linux and Compaq Tru64 Unix objects are PIC.
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- ;;
- *)
- ;;
- esac
- ;;
- psos*)
- ;;
- solaris*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.2, 5.x and Centerline C++
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
- ;;
- gcx*)
- # Green Hills C++ Compiler
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
- ;;
- *)
- ;;
- esac
- ;;
- sunos4*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.x
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
- lcc*)
- # Lucid
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
- ;;
- *)
- ;;
- esac
- ;;
- tandem*)
- case $cc_basename in
- NCC*)
- # NonStop-UX NCC 3.20
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- ;;
- *)
- ;;
- esac
- ;;
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- case $cc_basename in
- CC*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
- esac
- ;;
- vxworks*)
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
- ;;
- esac
- fi
-],
-[
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- fi
- ;;
-
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
- ;;
-
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
- ;;
-
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
- ;;
-
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
-
- msdosdjgpp*)
- # Just because we use GCC doesn't mean we suddenly get shared libraries
- # on systems that don't support them.
- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
- enable_shared=no
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
- fi
- ;;
-
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
- ;;
- esac
- ;;
-
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
- ;;
- esac
- else
- # PORTME Check for flag to pass linker flags through the system compiler.
- case $host_os in
- aix*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- else
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- ;;
- esac
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
- ;;
-
- hpux9* | hpux10* | hpux11*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
- ;;
- esac
- # Is there a better lt_prog_compiler_static that works with the bundled CC?
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
- ;;
-
- irix5* | irix6* | nonstopux*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- # PIC (with -KPIC) is the default.
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- ;;
-
- newsos6)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
-
- linux*)
- case $cc_basename in
- icc* | ecc*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
- ;;
- pgcc* | pgf77* | pgf90* | pgf95*)
- # Portland Group compilers (*not* the Pentium gcc compiler,
- # which looks to be a dead project)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
- ccc*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- # All Alpha code is PIC.
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- ;;
- esac
- ;;
-
- osf3* | osf4* | osf5*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- # All OSF/1 code is PIC.
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- ;;
-
- solaris*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- case $cc_basename in
- f77* | f90* | f95*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
- esac
- ;;
-
- sunos4*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
-
- sysv4 | sysv4.2uw2* | sysv4.3*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec ;then
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- fi
- ;;
-
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
-
- unicos*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
- ;;
-
- uts4*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
-
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
- ;;
- esac
- fi
-])
-AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)])
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
- AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works],
- _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1),
- [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [],
- [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in
- "" | " "*) ;;
- *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;;
- esac],
- [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
-fi
-case $host_os in
- # For platforms which do not support PIC, -DPIC is meaningless:
- *djgpp*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])"
- ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\"
-AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
- _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1),
- $lt_tmp_static_flag,
- [],
- [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
-])
-
-
-# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME])
-# ------------------------------------
-# See if the linker supports building shared libraries.
-AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS],
-[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
-ifelse([$1],[CXX],[
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- case $host_os in
- aix4* | aix5*)
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
- else
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
- fi
- ;;
- pw32*)
- _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
- ;;
- cygwin* | mingw*)
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
- ;;
- kfreebsd*-gnu)
- _LT_AC_TAGVAR(link_all_deplibs, $1)=no
- ;;
- linux*)
- _LT_AC_TAGVAR(link_all_deplibs, $1)=no
- ;;
- *)
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- ;;
- esac
-],[
- runpath_var=
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=
- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
- _LT_AC_TAGVAR(archive_cmds, $1)=
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)=
- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)=
- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)=
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
- _LT_AC_TAGVAR(thread_safe_flag_spec, $1)=
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
- _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
- _LT_AC_TAGVAR(hardcode_automatic, $1)=no
- _LT_AC_TAGVAR(module_cmds, $1)=
- _LT_AC_TAGVAR(module_expsym_cmds, $1)=
- _LT_AC_TAGVAR(always_export_symbols, $1)=no
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- # include_expsyms should be a list of space-separated symbols to be *always*
- # included in the symbol list
- _LT_AC_TAGVAR(include_expsyms, $1)=
- # exclude_expsyms can be an extended regexp of symbols to exclude
- # it will be wrapped by ` (' and `)$', so one must not match beginning or
- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
- # as well as any symbol that contains `d'.
- _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_"
- # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
- # platforms (ab)use it in PIC code, but their linkers get confused if
- # the symbol is explicitly referenced. Since portable code cannot
- # rely on this symbol name, it's probably fine to never include it in
- # preloaded symbol tables.
- extract_expsyms_cmds=
- # Just being paranoid about ensuring that cc_basename is set.
- _LT_CC_BASENAME([$compiler])
- case $host_os in
- cygwin* | mingw* | pw32*)
- # FIXME: the MSVC++ port hasn't been tested in a loooong time
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- if test "$GCC" != yes; then
- with_gnu_ld=no
- fi
- ;;
- interix*)
- # we just hope/assume this is gcc and not c89 (= MSVC++)
- with_gnu_ld=yes
- ;;
- openbsd*)
- with_gnu_ld=no
- ;;
- esac
-
- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
- if test "$with_gnu_ld" = yes; then
- # If archive_cmds runs LD, not CC, wlarc should be empty
- wlarc='${wl}'
-
- # Set some defaults for GNU ld with shared library support. These
- # are reset later if shared libraries are not supported. Putting them
- # here allows them to be overridden if necessary.
- runpath_var=LD_RUN_PATH
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
- # ancient GNU ld didn't support --whole-archive et. al.
- if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
- fi
- supports_anon_versioning=no
- case `$LD -v 2>/dev/null` in
- *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
- *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
- *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
- *\ 2.11.*) ;; # other 2.11 versions
- *) supports_anon_versioning=yes ;;
- esac
-
- # See if GNU ld supports shared libraries.
- case $host_os in
- aix3* | aix4* | aix5*)
- # On AIX/PPC, the GNU linker is very broken
- if test "$host_cpu" != ia64; then
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support. If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
- fi
- ;;
-
- amigaos*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-
- # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
- # that the semantics of dynamic libraries on AmigaOS, at least up
- # to version 4, is to share data among multiple programs linked
- # with the same dynamic library. Since this doesn't match the
- # behavior of shared libraries on other platforms, we can't use
- # them.
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
- # as there is no search path for DLLs.
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- _LT_AC_TAGVAR(always_export_symbols, $1)=no
- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
-
- interix3*)
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
-
- linux*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- tmp_addflag=
- case $cc_basename,$host_cpu in
- pgcc*) # Portland Group C compiler
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag'
- ;;
- pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag -Mnomain' ;;
- ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
- tmp_addflag=' -i_dynamic' ;;
- efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
- tmp_addflag=' -i_dynamic -nofor_main' ;;
- ifc* | ifort*) # Intel Fortran compiler
- tmp_addflag=' -nofor_main' ;;
- esac
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
- if test $supports_anon_versioning = yes; then
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- $echo "local: *; };" >> $output_objdir/$libname.ver~
- $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
- fi
- _LT_AC_TAGVAR(link_all_deplibs, $1)=no
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
- wlarc=
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- fi
- ;;
-
- solaris*)
- if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-EOF
- elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
- case `$LD -v 2>&1` in
- *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
- ;;
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
- ;;
-
- sunos4*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- wlarc=
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
-
- if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then
- runpath_var=
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
- fi
- else
- # PORTME fill in a description of your system's linker (not GNU ld)
- case $host_os in
- aix3*)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
- # Note: this linker hardcodes the directories in LIBPATH if there
- # are no directories specified by -L.
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
- # Neither direct hardcoding nor static linking is supported with a
- # broken collect2.
- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
- fi
- ;;
-
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
- else
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
- fi
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
- for ld_flag in $LDFLAGS; do
- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
- aix_use_runtimelinking=yes
- break
- fi
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- _LT_AC_TAGVAR(archive_cmds, $1)=''
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
- if test "$GCC" = yes; then
- case $host_os in aix4.[[012]]|aix4.[[012]].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- else
- # We have old collect2
- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- _LT_AC_SYS_LIBPATH_AIX
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- _LT_AC_SYS_LIBPATH_AIX
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- amigaos*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- # see comment about different semantics on the GNU ld section
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
-
- bsdi[[45]]*)
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
- ;;
-
- cygwin* | mingw* | pw32*)
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- # hardcode_libdir_flag_spec is actually meaningless, as there is
- # no search path for DLLs.
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- # Tell ltmain to make .lib files, not .a files.
- libext=lib
- # Tell ltmain to make .dll files, not .so files.
- shrext_cmds=".dll"
- # FIXME: Setting linknames here is a bad hack.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
- # The linker will automatically build a .lib file if we build a DLL.
- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
- # FIXME: Should let the user specify the lib program.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
- _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
- ;;
-
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[[012]])
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[[012]])
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- if test "$GCC" = yes ; then
- output_verbose_link_cmd='echo'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- freebsd1*)
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
-
- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
- # support. Future versions do this automatically, but an explicit c++rt0.o
- # does not break anything, and helps significantly (at the cost of a little
- # extra space).
- freebsd2.2*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- # Unfortunately, older versions of FreeBSD 2 do not have this feature.
- freebsd2*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
- freebsd* | dragonfly*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- # GNU/kFreeBSD uses gcc -shared to do shared libraries.
- kfreebsd*-gnu)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(link_all_deplibs, $1)=no
- ;;
-
- hpux9*)
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- ;;
-
- hpux10*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
- fi
- if test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- fi
- ;;
-
- hpux11*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- case $host_cpu in
- hppa*64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- else
- case $host_cpu in
- hppa*64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- fi
- if test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
- *)
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- ;;
- esac
- fi
- ;;
-
- irix5* | irix6* | nonstopux*)
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- newsos6)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- openbsd*)
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- else
- case $host_os in
- openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- ;;
- esac
- fi
- ;;
-
- os2*)
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
- ;;
-
- osf3*)
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- ;;
-
- osf4* | osf5*) # as osf3* with the addition of -msym flag
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- else
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
-
- # Both c and cxx compiler support -rpath directly
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- ;;
-
- solaris*)
- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
- if test "$GCC" = yes; then
- wlarc='${wl}'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
- else
- wlarc=''
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- case $host_os in
- solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
- *)
- # The compiler driver will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl, iff we do not link with $LD.
- # Luckily, gcc supports the same syntax we need for Sun Studio.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- case $wlarc in
- '')
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
- *)
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- esac ;;
- esac
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- ;;
-
- sunos4*)
- if test "x$host_vendor" = xsequent; then
- # Use $CC to link under sequent, because it throws in some extra .o
- # files that make .init and .fini sections work.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- sysv4)
- case $host_vendor in
- sni)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true???
- ;;
- siemens)
- ## LD is ld it makes a PLAMLIB
- ## CC just makes a GrossModule.
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- ;;
- motorola)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
- ;;
- esac
- runpath_var='LD_RUN_PATH'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- sysv4.3*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- runpath_var=LD_RUN_PATH
- hardcode_runpath_var=yes
- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
- fi
- ;;
-
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7*)
- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- uts4*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- *)
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- fi
-])
-AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
-test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in
-x|xyes)
- # Assume -lc should be added
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
-
- if test "$enable_shared" = yes && test "$GCC" = yes; then
- case $_LT_AC_TAGVAR(archive_cmds, $1) in
- *'~'*)
- # FIXME: we may have to deal with multi-command sequences.
- ;;
- '$CC '*)
- # Test whether the compiler implicitly links with -lc since on some
- # systems, -lgcc has to come before -lc. If gcc already passes -lc
- # to ld, don't add -lc before -lgcc.
- AC_MSG_CHECKING([whether -lc should be explicitly linked in])
- $rm conftest*
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
- soname=conftest
- lib=conftest
- libobjs=conftest.$ac_objext
- deplibs=
- wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
- pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
- compiler_flags=-v
- linker_flags=-v
- verstring=
- output_objdir=.
- libname=conftest
- lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=
- if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1)
- then
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- else
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
- fi
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
- else
- cat conftest.err 1>&5
- fi
- $rm conftest*
- AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)])
- ;;
- esac
- fi
- ;;
-esac
-])# AC_LIBTOOL_PROG_LD_SHLIBS
-
-
-# _LT_AC_FILE_LTDLL_C
-# -------------------
-# Be careful that the start marker always follows a newline.
-AC_DEFUN([_LT_AC_FILE_LTDLL_C], [
-# /* ltdll.c starts here */
-# #define WIN32_LEAN_AND_MEAN
-# #include <windows.h>
-# #undef WIN32_LEAN_AND_MEAN
-# #include <stdio.h>
-#
-# #ifndef __CYGWIN__
-# # ifdef __CYGWIN32__
-# # define __CYGWIN__ __CYGWIN32__
-# # endif
-# #endif
-#
-# #ifdef __cplusplus
-# extern "C" {
-# #endif
-# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
-# #ifdef __cplusplus
-# }
-# #endif
-#
-# #ifdef __CYGWIN__
-# #include <cygwin/cygwin_dll.h>
-# DECLARE_CYGWIN_DLL( DllMain );
-# #endif
-# HINSTANCE __hDllInstance_base;
-#
-# BOOL APIENTRY
-# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
-# {
-# __hDllInstance_base = hInst;
-# return TRUE;
-# }
-# /* ltdll.c ends here */
-])# _LT_AC_FILE_LTDLL_C
-
-
-# _LT_AC_TAGVAR(VARNAME, [TAGNAME])
-# ---------------------------------
-AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])])
-
-
-# old names
-AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL])
-AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
-AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
-AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
-AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
-AC_DEFUN([AM_PROG_LD], [AC_PROG_LD])
-AC_DEFUN([AM_PROG_NM], [AC_PROG_NM])
-
-# This is just to silence aclocal about the macro not being used
-ifelse([AC_DISABLE_FAST_INSTALL])
-
-AC_DEFUN([LT_AC_PROG_GCJ],
-[AC_CHECK_TOOL(GCJ, gcj, no)
- test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
- AC_SUBST(GCJFLAGS)
-])
-
-AC_DEFUN([LT_AC_PROG_RC],
-[AC_CHECK_TOOL(RC, windres, no)
-])
-
-# NOTE: This macro has been submitted for inclusion into #
-# GNU Autoconf as AC_PROG_SED. When it is available in #
-# a released version of Autoconf we should remove this #
-# macro and use it instead. #
-# LT_AC_PROG_SED
-# --------------
-# Check for a fully-functional sed program, that truncates
-# as few characters as possible. Prefer GNU sed if found.
-AC_DEFUN([LT_AC_PROG_SED],
-[AC_MSG_CHECKING([for a sed that does not truncate output])
-AC_CACHE_VAL(lt_cv_path_SED,
-[# Loop through the user's path and test for sed and gsed.
-# Then use that list of sed's as ones to test for truncation.
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for lt_ac_prog in sed gsed; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
- lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
- fi
- done
- done
-done
-lt_ac_max=0
-lt_ac_count=0
-# Add /usr/xpg4/bin/sed as it is typically found on Solaris
-# along with /bin/sed that truncates output.
-for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
- test ! -f $lt_ac_sed && continue
- cat /dev/null > conftest.in
- lt_ac_count=0
- echo $ECHO_N "0123456789$ECHO_C" >conftest.in
- # Check for GNU sed and select it if it is found.
- if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
- lt_cv_path_SED=$lt_ac_sed
- break
- fi
- while true; do
- cat conftest.in conftest.in >conftest.tmp
- mv conftest.tmp conftest.in
- cp conftest.in conftest.nl
- echo >>conftest.nl
- $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
- cmp -s conftest.out conftest.nl || break
- # 10000 chars as input seems more than enough
- test $lt_ac_count -gt 10 && break
- lt_ac_count=`expr $lt_ac_count + 1`
- if test $lt_ac_count -gt $lt_ac_max; then
- lt_ac_max=$lt_ac_count
- lt_cv_path_SED=$lt_ac_sed
- fi
- done
-done
-])
-SED=$lt_cv_path_SED
-AC_MSG_RESULT([$SED])
-])
-
diff --git a/source4/lib/json/arraylist.c b/source4/lib/json/arraylist.c
deleted file mode 100644
index dbd075d80d..0000000000
--- a/source4/lib/json/arraylist.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * $Id: arraylist.c,v 1.4 2006/01/26 02:16:28 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-#include "config.h"
-
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#endif /* STDC_HEADERS */
-
-#if HAVE_STRINGS_H
-# include <strings.h>
-#endif /* HAVE_STRINGS_H */
-
-#include "bits.h"
-#include "arraylist.h"
-
-struct array_list*
-array_list_new(array_list_free_fn *free_fn)
-{
- struct array_list *this;
-
- if(!(this = calloc(1, sizeof(struct array_list)))) return NULL;
- this->size = ARRAY_LIST_DEFAULT_SIZE;
- this->length = 0;
- this->free_fn = free_fn;
- if(!(this->array = calloc(sizeof(void*), this->size))) {
- free(this);
- return NULL;
- }
- return this;
-}
-
-extern void
-array_list_free(struct array_list *this)
-{
- int i;
- for(i = 0; i < this->length; i++)
- if(this->array[i]) this->free_fn(this->array[i]);
- free(this->array);
- free(this);
-}
-
-void*
-array_list_get_idx(struct array_list *this, int i)
-{
- if(i >= this->length) return NULL;
- return this->array[i];
-}
-
-static int array_list_expand_internal(struct array_list *this, int max)
-{
- void *t;
- int new_size;
-
- if(max < this->size) return 0;
- new_size = max(this->size << 1, max);
- if(!(t = realloc(this->array, new_size*sizeof(void*)))) return -1;
- this->array = t;
- (void)memset(this->array + this->size, 0, (new_size-this->size)*sizeof(void*));
- this->size = new_size;
- return 0;
-}
-
-int
-array_list_put_idx(struct array_list *this, int idx, void *data)
-{
- if(array_list_expand_internal(this, idx)) return -1;
- if(this->array[idx]) this->free_fn(this->array[idx]);
- this->array[idx] = data;
- if(this->length <= idx) this->length = idx + 1;
- return 0;
-}
-
-int
-array_list_add(struct array_list *this, void *data)
-{
- return array_list_put_idx(this, this->length, data);
-}
-
-int
-array_list_length(struct array_list *this)
-{
- return this->length;
-}
diff --git a/source4/lib/json/arraylist.h b/source4/lib/json/arraylist.h
deleted file mode 100644
index 2948e042a9..0000000000
--- a/source4/lib/json/arraylist.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * $Id: arraylist.h,v 1.4 2006/01/26 02:16:28 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-#ifndef _arraylist_h_
-#define _arraylist_h_
-
-#define ARRAY_LIST_DEFAULT_SIZE 32
-
-typedef void (array_list_free_fn) (void *data);
-
-struct array_list
-{
- void **array;
- int length;
- int size;
- array_list_free_fn *free_fn;
-};
-
-extern struct array_list*
-array_list_new(array_list_free_fn *free_fn);
-
-extern void
-array_list_free(struct array_list *al);
-
-extern void*
-array_list_get_idx(struct array_list *al, int i);
-
-extern int
-array_list_put_idx(struct array_list *al, int i, void *data);
-
-extern int
-array_list_add(struct array_list *al, void *data);
-
-extern int
-array_list_length(struct array_list *al);
-
-#endif
diff --git a/source4/lib/json/autogen.sh b/source4/lib/json/autogen.sh
deleted file mode 100644
index c67b9034d5..0000000000
--- a/source4/lib/json/autogen.sh
+++ /dev/null
@@ -1 +0,0 @@
-autoreconf -v --install || exit 1
diff --git a/source4/lib/json/bits.h b/source4/lib/json/bits.h
deleted file mode 100644
index 2c107cce11..0000000000
--- a/source4/lib/json/bits.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * $Id: bits.h,v 1.10 2006/01/30 23:07:57 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-#ifndef _bits_h_
-#define _bits_h_
-
-#ifndef min
-#define min(a,b) ((a) < (b) ? (a) : (b))
-#endif
-
-#ifndef max
-#define max(a,b) ((a) > (b) ? (a) : (b))
-#endif
-
-#define hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9)
-#define error_ptr(error) ((void*)error)
-#define is_error(ptr) ((unsigned long)ptr > (unsigned long)-4000L)
-
-#endif
diff --git a/source4/lib/json/config.guess b/source4/lib/json/config.guess
deleted file mode 100755
index dd7f7136cc..0000000000
--- a/source4/lib/json/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-04-22'
-
-# 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 0 ;;
- --version | -v )
- echo "$version" ; exit 0 ;;
- --help | --h* | -h )
- echo "$usage"; exit 0 ;;
- -- ) # 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 ;'
-
-# 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 0 ;;
- amd64:OpenBSD:*:*)
- echo x86_64-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- amiga:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- cats:OpenBSD:*:*)
- echo arm-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- hp300:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- luna88k:OpenBSD:*:*)
- echo m88k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mac68k:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- macppc:OpenBSD:*:*)
- echo powerpc-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mvme68k:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mvme88k:OpenBSD:*:*)
- echo m88k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mvmeppc:OpenBSD:*:*)
- echo powerpc-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- sgi:OpenBSD:*:*)
- echo mips64-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- sun3:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- *:OpenBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- *:ekkoBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
- exit 0 ;;
- macppc:MirBSD:*:*)
- echo powerppc-unknown-mirbsd${UNAME_RELEASE}
- exit 0 ;;
- *:MirBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
- exit 0 ;;
- 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 0 ;;
- 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 0 ;;
- 21064:Windows_NT:50:3)
- echo alpha-dec-winnt3.5
- exit 0 ;;
- Amiga*:UNIX_System_V:4.0:*)
- echo m68k-unknown-sysv4
- exit 0;;
- *:[Aa]miga[Oo][Ss]:*:*)
- echo ${UNAME_MACHINE}-unknown-amigaos
- exit 0 ;;
- *:[Mm]orph[Oo][Ss]:*:*)
- echo ${UNAME_MACHINE}-unknown-morphos
- exit 0 ;;
- *:OS/390:*:*)
- echo i370-ibm-openedition
- exit 0 ;;
- *:z/VM:*:*)
- echo s390-ibm-zvmoe
- exit 0 ;;
- *:OS400:*:*)
- echo powerpc-ibm-os400
- exit 0 ;;
- arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
- echo arm-acorn-riscix${UNAME_RELEASE}
- exit 0;;
- SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
- echo hppa1.1-hitachi-hiuxmpp
- exit 0;;
- 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 0 ;;
- NILE*:*:*:dcosx)
- echo pyramid-pyramid-svr4
- exit 0 ;;
- DRS?6000:unix:4.0:6*)
- echo sparc-icl-nx6
- exit 0 ;;
- 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 0 ;;
- esac ;;
- sun4H:SunOS:5.*:*)
- echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit 0 ;;
- sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
- echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit 0 ;;
- i86pc:SunOS:5.*:*)
- echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit 0 ;;
- 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 0 ;;
- 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 0 ;;
- sun3*:SunOS:*:*)
- echo m68k-sun-sunos${UNAME_RELEASE}
- exit 0 ;;
- 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 0 ;;
- aushp:SunOS:*:*)
- echo sparc-auspex-sunos${UNAME_RELEASE}
- exit 0 ;;
- # 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 0 ;;
- atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit 0 ;;
- *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit 0 ;;
- milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
- echo m68k-milan-mint${UNAME_RELEASE}
- exit 0 ;;
- hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
- echo m68k-hades-mint${UNAME_RELEASE}
- exit 0 ;;
- *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
- echo m68k-unknown-mint${UNAME_RELEASE}
- exit 0 ;;
- m68k:machten:*:*)
- echo m68k-apple-machten${UNAME_RELEASE}
- exit 0 ;;
- powerpc:machten:*:*)
- echo powerpc-apple-machten${UNAME_RELEASE}
- exit 0 ;;
- RISC*:Mach:*:*)
- echo mips-dec-mach_bsd4.3
- exit 0 ;;
- RISC*:ULTRIX:*:*)
- echo mips-dec-ultrix${UNAME_RELEASE}
- exit 0 ;;
- VAX*:ULTRIX*:*:*)
- echo vax-dec-ultrix${UNAME_RELEASE}
- exit 0 ;;
- 2020:CLIX:*:* | 2430:CLIX:*:*)
- echo clipper-intergraph-clix${UNAME_RELEASE}
- exit 0 ;;
- 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 \
- && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
- && exit 0
- echo mips-mips-riscos${UNAME_RELEASE}
- exit 0 ;;
- Motorola:PowerMAX_OS:*:*)
- echo powerpc-motorola-powermax
- exit 0 ;;
- Motorola:*:4.3:PL8-*)
- echo powerpc-harris-powermax
- exit 0 ;;
- Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
- echo powerpc-harris-powermax
- exit 0 ;;
- Night_Hawk:Power_UNIX:*:*)
- echo powerpc-harris-powerunix
- exit 0 ;;
- m88k:CX/UX:7*:*)
- echo m88k-harris-cxux7
- exit 0 ;;
- m88k:*:4*:R4*)
- echo m88k-motorola-sysv4
- exit 0 ;;
- m88k:*:3*:R3*)
- echo m88k-motorola-sysv3
- exit 0 ;;
- 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 0 ;;
- M88*:DolphinOS:*:*) # DolphinOS (SVR3)
- echo m88k-dolphin-sysv3
- exit 0 ;;
- M88*:*:R3*:*)
- # Delta 88k system running SVR3
- echo m88k-motorola-sysv3
- exit 0 ;;
- XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
- echo m88k-tektronix-sysv3
- exit 0 ;;
- Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
- echo m68k-tektronix-bsd
- exit 0 ;;
- *:IRIX*:*:*)
- echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
- exit 0 ;;
- ????????: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 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
- i*86:AIX:*:*)
- echo i386-ibm-aix
- exit 0 ;;
- 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 0 ;;
- *: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
- $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
- echo rs6000-ibm-aix3.2.5
- 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 0 ;;
- *: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 0 ;;
- *:AIX:*:*)
- echo rs6000-ibm-aix
- exit 0 ;;
- ibmrt:4.4BSD:*|romp-ibm:BSD:*)
- echo romp-ibm-bsd4.4
- exit 0 ;;
- ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
- echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
- exit 0 ;; # report: romp-ibm BSD 4.3
- *:BOSX:*:*)
- echo rs6000-bull-bosx
- exit 0 ;;
- DPX/2?00:B.O.S.:*:*)
- echo m68k-bull-sysv3
- exit 0 ;;
- 9000/[34]??:4.3bsd:1.*:*)
- echo m68k-hp-bsd
- exit 0 ;;
- hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
- echo m68k-hp-bsd4.4
- exit 0 ;;
- 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
- # avoid double evaluation of $set_cc_for_build
- test -n "$CC_FOR_BUILD" || eval $set_cc_for_build
- if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null
- then
- HP_ARCH="hppa2.0w"
- else
- HP_ARCH="hppa64"
- fi
- fi
- echo ${HP_ARCH}-hp-hpux${HPUX_REV}
- exit 0 ;;
- ia64:HP-UX:*:*)
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
- echo ia64-hp-hpux${HPUX_REV}
- exit 0 ;;
- 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 && $dummy && exit 0
- echo unknown-hitachi-hiuxwe2
- exit 0 ;;
- 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
- echo hppa1.1-hp-bsd
- exit 0 ;;
- 9000/8??:4.3bsd:*:*)
- echo hppa1.0-hp-bsd
- exit 0 ;;
- *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
- echo hppa1.0-hp-mpeix
- exit 0 ;;
- hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
- echo hppa1.1-hp-osf
- exit 0 ;;
- hp8??:OSF1:*:*)
- echo hppa1.0-hp-osf
- exit 0 ;;
- i*86:OSF1:*:*)
- if [ -x /usr/sbin/sysversion ] ; then
- echo ${UNAME_MACHINE}-unknown-osf1mk
- else
- echo ${UNAME_MACHINE}-unknown-osf1
- fi
- exit 0 ;;
- parisc*:Lites*:*:*)
- echo hppa1.1-hp-lites
- exit 0 ;;
- C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
- echo c1-convex-bsd
- exit 0 ;;
- C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit 0 ;;
- C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
- echo c34-convex-bsd
- exit 0 ;;
- C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
- echo c38-convex-bsd
- exit 0 ;;
- C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
- echo c4-convex-bsd
- exit 0 ;;
- CRAY*Y-MP:*:*:*)
- echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit 0 ;;
- 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 0 ;;
- CRAY*TS:*:*:*)
- echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit 0 ;;
- CRAY*T3E:*:*:*)
- echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit 0 ;;
- CRAY*SV1:*:*:*)
- echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit 0 ;;
- *:UNICOS/mp:*:*)
- echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit 0 ;;
- 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 0 ;;
- 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 0 ;;
- i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
- echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
- exit 0 ;;
- sparc*:BSD/OS:*:*)
- echo sparc-unknown-bsdi${UNAME_RELEASE}
- exit 0 ;;
- *:BSD/OS:*:*)
- echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
- exit 0 ;;
- *:FreeBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
- exit 0 ;;
- i*:CYGWIN*:*)
- echo ${UNAME_MACHINE}-pc-cygwin
- exit 0 ;;
- i*:MINGW*:*)
- echo ${UNAME_MACHINE}-pc-mingw32
- exit 0 ;;
- i*:PW*:*)
- echo ${UNAME_MACHINE}-pc-pw32
- exit 0 ;;
- x86:Interix*:[34]*)
- echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
- exit 0 ;;
- [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
- echo i${UNAME_MACHINE}-pc-mks
- exit 0 ;;
- 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 0 ;;
- i*:UWIN*:*)
- echo ${UNAME_MACHINE}-pc-uwin
- exit 0 ;;
- amd64:CYGWIN*:*:*)
- echo x86_64-unknown-cygwin
- exit 0 ;;
- p*:CYGWIN*:*)
- echo powerpcle-unknown-cygwin
- exit 0 ;;
- prep*:SunOS:5.*:*)
- echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit 0 ;;
- *:GNU:*:*)
- # the GNU system
- echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
- exit 0 ;;
- *: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 0 ;;
- i*86:Minix:*:*)
- echo ${UNAME_MACHINE}-pc-minix
- exit 0 ;;
- arm*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit 0 ;;
- cris:Linux:*:*)
- echo cris-axis-linux-gnu
- exit 0 ;;
- crisv32:Linux:*:*)
- echo crisv32-axis-linux-gnu
- exit 0 ;;
- frv:Linux:*:*)
- echo frv-unknown-linux-gnu
- exit 0 ;;
- ia64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit 0 ;;
- m32r*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit 0 ;;
- m68*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit 0 ;;
- 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 0
- ;;
- 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 0
- ;;
- ppc:Linux:*:*)
- echo powerpc-unknown-linux-gnu
- exit 0 ;;
- ppc64:Linux:*:*)
- echo powerpc64-unknown-linux-gnu
- exit 0 ;;
- 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 0 ;;
- 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 0 ;;
- parisc64:Linux:*:* | hppa64:Linux:*:*)
- echo hppa64-unknown-linux-gnu
- exit 0 ;;
- s390:Linux:*:* | s390x:Linux:*:*)
- echo ${UNAME_MACHINE}-ibm-linux
- exit 0 ;;
- sh64*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit 0 ;;
- sh*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit 0 ;;
- sparc:Linux:*:* | sparc64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit 0 ;;
- x86_64:Linux:*:*)
- echo x86_64-unknown-linux-gnu
- exit 0 ;;
- 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 0 ;;
- coff-i386)
- echo "${UNAME_MACHINE}-pc-linux-gnucoff"
- exit 0 ;;
- "")
- # 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 0 ;;
- 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 0
- test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
- ;;
- 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 0 ;;
- 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 0 ;;
- 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 0 ;;
- i*86:XTS-300:*:STOP)
- echo ${UNAME_MACHINE}-unknown-stop
- exit 0 ;;
- i*86:atheos:*:*)
- echo ${UNAME_MACHINE}-unknown-atheos
- exit 0 ;;
- i*86:syllable:*:*)
- echo ${UNAME_MACHINE}-pc-syllable
- exit 0 ;;
- i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
- echo i386-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
- i*86:*DOS:*:*)
- echo ${UNAME_MACHINE}-pc-msdosdjgpp
- exit 0 ;;
- 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 0 ;;
- i*86:*:5:[78]*)
- 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 0 ;;
- 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 0 ;;
- 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 0 ;;
- Intel:Mach:3*:*)
- echo i386-pc-mach3
- exit 0 ;;
- paragon:*:*:*)
- echo i860-intel-osf1
- exit 0 ;;
- 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 0 ;;
- mini*:CTIX:SYS*5:*)
- # "miniframe"
- echo m68010-convergent-sysv
- exit 0 ;;
- mc68k:UNIX:SYSTEM5:3.51m)
- echo m68k-convergent-sysv
- exit 0 ;;
- M680?0:D-NIX:5.3:*)
- echo m68k-diab-dnix
- exit 0 ;;
- M68*:*:R3V[5678]*:*)
- test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
- 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 0
- /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
- && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
- 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
- /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && echo i486-ncr-sysv4 && exit 0 ;;
- m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
- echo m68k-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
- mc68030:UNIX_System_V:4.*:*)
- echo m68k-atari-sysv4
- exit 0 ;;
- TSUNAMI:LynxOS:2.*:*)
- echo sparc-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
- rs6000:LynxOS:2.*:*)
- echo rs6000-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
- PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
- echo powerpc-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
- SM[BE]S:UNIX_SV:*:*)
- echo mips-dde-sysv${UNAME_RELEASE}
- exit 0 ;;
- RM*:ReliantUNIX-*:*:*)
- echo mips-sni-sysv4
- exit 0 ;;
- RM*:SINIX-*:*:*)
- echo mips-sni-sysv4
- exit 0 ;;
- *: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 0 ;;
- PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
- # says <Richard.M.Bartel@ccMail.Census.GOV>
- echo i586-unisys-sysv4
- exit 0 ;;
- *:UNIX_System_V:4*:FTX*)
- # From Gerald Hewes <hewes@openmarket.com>.
- # How about differentiating between stratus architectures? -djm
- echo hppa1.1-stratus-sysv4
- exit 0 ;;
- *:*:*:FTX*)
- # From seanf@swdc.stratus.com.
- echo i860-stratus-sysv4
- exit 0 ;;
- i*86:VOS:*:*)
- # From Paul.Green@stratus.com.
- echo ${UNAME_MACHINE}-stratus-vos
- exit 0 ;;
- *:VOS:*:*)
- # From Paul.Green@stratus.com.
- echo hppa1.1-stratus-vos
- exit 0 ;;
- mc68*:A/UX:*:*)
- echo m68k-apple-aux${UNAME_RELEASE}
- exit 0 ;;
- news*:NEWS-OS:6*:*)
- echo mips-sony-newsos6
- exit 0 ;;
- 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 0 ;;
- BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
- echo powerpc-be-beos
- exit 0 ;;
- BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
- echo powerpc-apple-beos
- exit 0 ;;
- BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
- echo i586-pc-beos
- exit 0 ;;
- SX-4:SUPER-UX:*:*)
- echo sx4-nec-superux${UNAME_RELEASE}
- exit 0 ;;
- SX-5:SUPER-UX:*:*)
- echo sx5-nec-superux${UNAME_RELEASE}
- exit 0 ;;
- SX-6:SUPER-UX:*:*)
- echo sx6-nec-superux${UNAME_RELEASE}
- exit 0 ;;
- Power*:Rhapsody:*:*)
- echo powerpc-apple-rhapsody${UNAME_RELEASE}
- exit 0 ;;
- *:Rhapsody:*:*)
- echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
- exit 0 ;;
- *: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 0 ;;
- *: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 0 ;;
- *:QNX:*:4*)
- echo i386-pc-qnx
- exit 0 ;;
- NSE-?:NONSTOP_KERNEL:*:*)
- echo nse-tandem-nsk${UNAME_RELEASE}
- exit 0 ;;
- NSR-?:NONSTOP_KERNEL:*:*)
- echo nsr-tandem-nsk${UNAME_RELEASE}
- exit 0 ;;
- *:NonStop-UX:*:*)
- echo mips-compaq-nonstopux
- exit 0 ;;
- BS2000:POSIX*:*:*)
- echo bs2000-siemens-sysv
- exit 0 ;;
- DS/*:UNIX_System_V:*:*)
- echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
- exit 0 ;;
- *: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 0 ;;
- *:TOPS-10:*:*)
- echo pdp10-unknown-tops10
- exit 0 ;;
- *:TENEX:*:*)
- echo pdp10-unknown-tenex
- exit 0 ;;
- KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
- echo pdp10-dec-tops20
- exit 0 ;;
- XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
- echo pdp10-xkl-tops20
- exit 0 ;;
- *:TOPS-20:*:*)
- echo pdp10-unknown-tops20
- exit 0 ;;
- *:ITS:*:*)
- echo pdp10-unknown-its
- exit 0 ;;
- SEI:*:*:SEIUX)
- echo mips-sei-seiux${UNAME_RELEASE}
- exit 0 ;;
- *:DragonFly:*:*)
- echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
- exit 0 ;;
- *:*VMS:*:*)
- UNAME_MACHINE=`(uname -p) 2>/dev/null`
- case "${UNAME_MACHINE}" in
- A*) echo alpha-dec-vms && exit 0 ;;
- I*) echo ia64-dec-vms && exit 0 ;;
- V*) echo vax-dec-vms && exit 0 ;;
- esac ;;
- *:XENIX:*:SysV)
- echo i386-pc-xenix
- exit 0 ;;
-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"); 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 && $dummy && exit 0
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
-
-# 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 0 ;;
- c2*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit 0 ;;
- c34*)
- echo c34-convex-bsd
- exit 0 ;;
- c38*)
- echo c38-convex-bsd
- exit 0 ;;
- c4*)
- echo c4-convex-bsd
- exit 0 ;;
- 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/json/config.h.in b/source4/lib/json/config.h.in
deleted file mode 100644
index 83ab7973a8..0000000000
--- a/source4/lib/json/config.h.in
+++ /dev/null
@@ -1,117 +0,0 @@
-/* config.h.in. Generated from configure.in by autoheader. */
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
-#undef HAVE_DOPRNT
-
-/* Define to 1 if you have the <fcntl.h> header file. */
-#undef HAVE_FCNTL_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the <limits.h> header file. */
-#undef HAVE_LIMITS_H
-
-/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
- to 0 otherwise. */
-#undef HAVE_MALLOC
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the `open' function. */
-#undef HAVE_OPEN
-
-/* Define to 1 if your system has a GNU libc compatible `realloc' function,
- and to 0 otherwise. */
-#undef HAVE_REALLOC
-
-/* Define to 1 if you have the <stdarg.h> header file. */
-#undef HAVE_STDARG_H
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the `strerror' function. */
-#undef HAVE_STRERROR
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the `strncasecmp' function. */
-#undef HAVE_STRNCASECMP
-
-/* Define to 1 if you have the `strndup' function. */
-#undef HAVE_STRNDUP
-
-/* Define to 1 if you have the <syslog.h> header file. */
-#undef HAVE_SYSLOG_H
-
-/* Define to 1 if you have the <sys/param.h> header file. */
-#undef HAVE_SYS_PARAM_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to 1 if you have the `vasprintf' function. */
-#undef HAVE_VASPRINTF
-
-/* Define to 1 if you have the `vprintf' function. */
-#undef HAVE_VPRINTF
-
-/* Define to 1 if you have the `vsnprintf' function. */
-#undef HAVE_VSNPRINTF
-
-/* Define to 1 if you have the `vsyslog' function. */
-#undef HAVE_VSYSLOG
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Version number of package */
-#undef VERSION
-
-/* Define to empty if `const' does not conform to ANSI C. */
-#undef const
-
-/* Define to rpl_malloc if the replacement function should be used. */
-#undef malloc
-
-/* Define to rpl_realloc if the replacement function should be used. */
-#undef realloc
-
-/* Define to `unsigned' if <sys/types.h> does not define. */
-#undef size_t
diff --git a/source4/lib/json/config.h.win32 b/source4/lib/json/config.h.win32
deleted file mode 100644
index 7f7e6aee16..0000000000
--- a/source4/lib/json/config.h.win32
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * $Id: config.h.win32,v 1.2 2006/01/26 02:16:28 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-/* config.h.win32 Generated by configure. */
-
-#define PACKAGE_STRING "JSON C Library 0.2"
-#define PACKAGE_BUGREPORT "michael@metaparadigm.com"
-#define PACKAGE_NAME "JSON C Library"
-#define PACKAGE_TARNAME "json-c"
-#define PACKAGE_VERSION "0.2"
-
-/* config.h.in. Generated from configure.ac by autoheader. */
-
-/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
-/* #undef HAVE_DOPRNT */
-
-/* Define to 1 if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the <limits.h> header file. */
-#define HAVE_LIMITS_H 1
-
-/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
- to 0 otherwise. */
-#define HAVE_MALLOC 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the `open' function. */
-#undef HAVE_OPEN
-
-/* Define to 1 if your system has a GNU libc compatible `realloc' function,
- and to 0 otherwise. */
-#define HAVE_REALLOC 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the `strdup' function. */
-#undef HAVE_STRNDUP
-
-/* Define to 1 if you have the <stdarg.h> header file. */
-#define HAVE_STDARG_H 1
-
-/* Define to 1 if you have the `strerror' function. */
-#define HAVE_STRERROR 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the <syslog.h> header file. */
-#undef HAVE_SYSLOG_H
-
-/* Define to 1 if you have the <sys/param.h> header file. */
-#undef HAVE_SYS_PARAM_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to 1 if you have the `vprintf' function. */
-#undef HAVE_VPRINTF
-
-/* Define to 1 if you have the `vsyslog' function. */
-#undef HAVE_VSYSLOG
-
-/* Define to 1 if you have the `strncasecmp' function. */
-#undef HAVE_STRNCASECMP
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
diff --git a/source4/lib/json/config.sub b/source4/lib/json/config.sub
deleted file mode 100755
index aa620b5a56..0000000000
--- a/source4/lib/json/config.sub
+++ /dev/null
@@ -1,1568 +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='2007-07-10'
-
-# 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 0 ;;
- --version | -v )
- echo "$version" ; exit 0 ;;
- --help | --h* | -h )
- echo "$usage"; exit 0 ;;
- -- ) # 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 0;;
-
- * )
- 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 \
- | mipsisa32 | mipsisa32el \
- | mipsisa32r2 | mipsisa32r2el \
- | mipsisa64 | mipsisa64el \
- | mipsisa64r2 | mipsisa64r2el \
- | mipsisa64sb1 | mipsisa64sb1el \
- | mipsisa64sr71k | mipsisa64sr71kel \
- | mipstx39 | mipstx39el \
- | mn10200 | mn10300 \
- | msp430 \
- | ns16k | ns32k \
- | openrisc | or32 \
- | pdp10 | pdp11 | pj | pjl \
- | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
- | pyramid \
- | sh | sh[1234] | 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
- ;;
- 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-* \
- | mipsisa32-* | mipsisa32el-* \
- | mipsisa32r2-* | mipsisa32r2el-* \
- | mipsisa64-* | mipsisa64el-* \
- | mipsisa64r2-* | mipsisa64r2el-* \
- | mipsisa64sb1-* | mipsisa64sb1el-* \
- | mipsisa64sr71k-* | mipsisa64sr71kel-* \
- | mipstx39-* | mipstx39el-* \
- | mmix-* \
- | msp430-* \
- | none-* | np1-* | ns16k-* | ns32k-* \
- | orion-* \
- | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
- | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
- | pyramid-* \
- | romp-* | rs6000-* \
- | sh-* | sh[1234]-* | 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-*)
- ;;
- # 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
- ;;
- or32 | or32-*)
- basic_machine=or32-unknown
- os=-coff
- ;;
- 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
- ;;
- sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele)
- basic_machine=sh-unknown
- ;;
- sh64)
- basic_machine=sh64-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*)
- # 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* \
- | -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
- ;;
- *-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 0
-
-# 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/json/configure b/source4/lib/json/configure
deleted file mode 100755
index dadf0d5d71..0000000000
--- a/source4/lib/json/configure
+++ /dev/null
@@ -1,20603 +0,0 @@
-#! /bin/sh
-# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for JSON C Library 0.3.
-#
-# Report bugs to <michael@metaparadigm.com>.
-#
-# Copyright (C) 2003 Free Software Foundation, Inc.
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-## --------------------- ##
-## M4sh Initialization. ##
-## --------------------- ##
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
- set -o posix
-fi
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
- as_unset=unset
-else
- as_unset=false
-fi
-
-
-# Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-for as_var in \
- LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
- LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
- LC_TELEPHONE LC_TIME
-do
- if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
- eval $as_var=C; export $as_var
- else
- $as_unset $as_var
- fi
-done
-
-# Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-
-
-# Name of the executable.
-as_me=`$as_basename "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)$' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X/"$0" |
- sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
- /^X\/\(\/\/\)$/{ s//\1/; q; }
- /^X\/\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
-
-
-# PATH needs CR, and LINENO needs CR and PATH.
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- echo "#! /bin/sh" >conf$$.sh
- echo "exit 0" >>conf$$.sh
- chmod +x conf$$.sh
- if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
- PATH_SEPARATOR=';'
- else
- PATH_SEPARATOR=:
- fi
- rm -f conf$$.sh
-fi
-
-
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" || {
- # Find who we are. Look in the path if we contain no path at all
- # relative or not.
- case $0 in
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
-
- ;;
- esac
- # We did not find ourselves, most probably we were run as `sh COMMAND'
- # in which case we are not to be found in the path.
- if test "x$as_myself" = x; then
- as_myself=$0
- fi
- if test ! -f "$as_myself"; then
- { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
- { (exit 1); exit 1; }; }
- fi
- case $CONFIG_SHELL in
- '')
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for as_base in sh bash ksh sh5; do
- case $as_dir in
- /*)
- if ("$as_dir/$as_base" -c '
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
- $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
- $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
- CONFIG_SHELL=$as_dir/$as_base
- export CONFIG_SHELL
- exec "$CONFIG_SHELL" "$0" ${1+"$@"}
- fi;;
- esac
- done
-done
-;;
- esac
-
- # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
- # uniformly replaced by the line number. The first 'sed' inserts a
- # line-number line before each line; the second 'sed' does the real
- # work. The second script uses 'N' to pair each line-number line
- # with the numbered line, and appends trailing '-' during
- # substitution so that $LINENO is not a special case at line end.
- # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
- # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
- sed '=' <$as_myself |
- sed '
- N
- s,$,-,
- : loop
- s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
- t loop
- s,-$,,
- s,^['$as_cr_digits']*\n,,
- ' >$as_me.lineno &&
- chmod +x $as_me.lineno ||
- { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
- { (exit 1); exit 1; }; }
-
- # Don't try to exec as it changes $[0], causing all sort of problems
- # (the dirname of $[0] is not the place where we might find the
- # original and so on. Autoconf is especially sensible to this).
- . ./$as_me.lineno
- # Exit status is that of the last command.
- exit
-}
-
-
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
- *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T=' ' ;;
- *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
- *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
-esac
-
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-rm -f conf$$ conf$$.exe conf$$.file
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
- # We could just check for DJGPP; but this test a) works b) is more generic
- # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
- if test -f conf$$.exe; then
- # Don't use ln at all; we don't have any links
- as_ln_s='cp -p'
- else
- as_ln_s='ln -s'
- fi
-elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
-else
- as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.file
-
-if mkdir -p . 2>/dev/null; then
- as_mkdir_p=:
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-
-as_executable_p="test -f"
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" $as_nl"
-
-# CDPATH.
-$as_unset CDPATH
-
-
-
-# Check that we are running under the correct shell.
-SHELL=${CONFIG_SHELL-/bin/sh}
-
-case X$ECHO in
-X*--fallback-echo)
- # Remove one level of quotation (which was required for Make).
- ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','`
- ;;
-esac
-
-echo=${ECHO-echo}
-if test "X$1" = X--no-reexec; then
- # Discard the --no-reexec flag, and continue.
- shift
-elif test "X$1" = X--fallback-echo; then
- # Avoid inline document here, it may be left over
- :
-elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
- # Yippee, $echo works!
- :
-else
- # Restart under the correct shell.
- exec $SHELL "$0" --no-reexec ${1+"$@"}
-fi
-
-if test "X$1" = X--fallback-echo; then
- # used as fallback echo
- shift
- cat <<EOF
-$*
-EOF
- exit 0
-fi
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-if test -z "$ECHO"; then
-if test "X${echo_test_string+set}" != Xset; then
-# find a string as large as possible, as long as the shell can cope with it
- for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
- # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
- if (echo_test_string=`eval $cmd`) 2>/dev/null &&
- echo_test_string=`eval $cmd` &&
- (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
- then
- break
- fi
- done
-fi
-
-if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- :
-else
- # The Solaris, AIX, and Digital Unix default echo programs unquote
- # backslashes. This makes it impossible to quote backslashes using
- # echo "$something" | sed 's/\\/\\\\/g'
- #
- # So, first we look for a working echo in the user's PATH.
-
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for dir in $PATH /usr/ucb; do
- IFS="$lt_save_ifs"
- if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
- test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- echo="$dir/echo"
- break
- fi
- done
- IFS="$lt_save_ifs"
-
- if test "X$echo" = Xecho; then
- # We didn't find a better echo, so look for alternatives.
- if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- # This shell has a builtin print -r that does the trick.
- echo='print -r'
- elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
- test "X$CONFIG_SHELL" != X/bin/ksh; then
- # If we have ksh, try running configure again with it.
- ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
- export ORIGINAL_CONFIG_SHELL
- CONFIG_SHELL=/bin/ksh
- export CONFIG_SHELL
- exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"}
- else
- # Try using printf.
- echo='printf %s\n'
- if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- # Cool, printf works
- :
- elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
- test "X$echo_testing_string" = 'X\t' &&
- echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
- export CONFIG_SHELL
- SHELL="$CONFIG_SHELL"
- export SHELL
- echo="$CONFIG_SHELL $0 --fallback-echo"
- elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
- test "X$echo_testing_string" = 'X\t' &&
- echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- echo="$CONFIG_SHELL $0 --fallback-echo"
- else
- # maybe with a smaller string...
- prev=:
-
- for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
- if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
- then
- break
- fi
- prev="$cmd"
- done
-
- if test "$prev" != 'sed 50q "$0"'; then
- echo_test_string=`eval $prev`
- export echo_test_string
- exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"}
- else
- # Oops. We lost completely, so just stick with echo.
- echo=echo
- fi
- fi
- fi
- fi
-fi
-fi
-
-# Copy echo and quote the copy suitably for passing to libtool from
-# the Makefile, instead of quoting the original, which is used later.
-ECHO=$echo
-if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then
- ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo"
-fi
-
-
-
-
-tagnames=${tagnames+${tagnames},}CXX
-
-tagnames=${tagnames+${tagnames},}F77
-
-# Name of the host.
-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
-# so uname gets run too.
-ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
-
-exec 6>&1
-
-#
-# Initializations.
-#
-ac_default_prefix=/usr/local
-ac_config_libobj_dir=.
-cross_compiling=no
-subdirs=
-MFLAGS=
-MAKEFLAGS=
-SHELL=${CONFIG_SHELL-/bin/sh}
-
-# Maximum number of lines to put in a shell here document.
-# This variable seems obsolete. It should probably be removed, and
-# only ac_max_sed_lines should be used.
-: ${ac_max_here_lines=38}
-
-# Identity of this package.
-PACKAGE_NAME='JSON C Library'
-PACKAGE_TARNAME='json-c'
-PACKAGE_VERSION='0.3'
-PACKAGE_STRING='JSON C Library 0.3'
-PACKAGE_BUGREPORT='michael@metaparadigm.com'
-
-# Factoring default headers for most tests.
-ac_includes_default="\
-#include <stdio.h>
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# if HAVE_STDLIB_H
-# include <stdlib.h>
-# endif
-#endif
-#if HAVE_STRING_H
-# if !STDC_HEADERS && HAVE_MEMORY_H
-# include <memory.h>
-# endif
-# include <string.h>
-#endif
-#if HAVE_STRINGS_H
-# include <strings.h>
-#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#else
-# if HAVE_STDINT_H
-# include <stdint.h>
-# endif
-#endif
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif"
-
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP LIBOBJS build build_cpu build_vendor build_os host host_cpu host_vendor host_os LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP CXX CXXFLAGS ac_ct_CXX CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LTLIBOBJS'
-ac_subst_files=''
-
-# Initialize some variables set by options.
-ac_init_help=
-ac_init_version=false
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-cache_file=/dev/null
-exec_prefix=NONE
-no_create=
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-verbose=
-x_includes=NONE
-x_libraries=NONE
-
-# Installation directory options.
-# These are left unexpanded so users can "make install exec_prefix=/foo"
-# and all the variables that are supposed to be based on exec_prefix
-# by default will actually change.
-# Use braces instead of parens because sh, perl, etc. also accept them.
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
-
-ac_prev=
-for ac_option
-do
- # If the previous option needs an argument, assign it.
- if test -n "$ac_prev"; then
- eval "$ac_prev=\$ac_option"
- ac_prev=
- continue
- fi
-
- ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case $ac_option in
-
- -bindir | --bindir | --bindi | --bind | --bin | --bi)
- ac_prev=bindir ;;
- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
- bindir=$ac_optarg ;;
-
- -build | --build | --buil | --bui | --bu)
- ac_prev=build_alias ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build_alias=$ac_optarg ;;
-
- -cache-file | --cache-file | --cache-fil | --cache-fi \
- | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
- ac_prev=cache_file ;;
- -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
- | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
- cache_file=$ac_optarg ;;
-
- --config-cache | -C)
- cache_file=config.cache ;;
-
- -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
- | --da=*)
- datadir=$ac_optarg ;;
-
- -disable-* | --disable-*)
- ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid feature name: $ac_feature" >&2
- { (exit 1); exit 1; }; }
- ac_feature=`echo $ac_feature | sed 's/-/_/g'`
- eval "enable_$ac_feature=no" ;;
-
- -enable-* | --enable-*)
- ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid feature name: $ac_feature" >&2
- { (exit 1); exit 1; }; }
- ac_feature=`echo $ac_feature | sed 's/-/_/g'`
- case $ac_option in
- *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
- *) ac_optarg=yes ;;
- esac
- eval "enable_$ac_feature='$ac_optarg'" ;;
-
- -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
- | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
- | --exec | --exe | --ex)
- ac_prev=exec_prefix ;;
- -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
- | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
- | --exec=* | --exe=* | --ex=*)
- exec_prefix=$ac_optarg ;;
-
- -gas | --gas | --ga | --g)
- # Obsolete; use --with-gas.
- with_gas=yes ;;
-
- -help | --help | --hel | --he | -h)
- ac_init_help=long ;;
- -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
- ac_init_help=recursive ;;
- -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
- ac_init_help=short ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host_alias ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host_alias=$ac_optarg ;;
-
- -includedir | --includedir | --includedi | --included | --include \
- | --includ | --inclu | --incl | --inc)
- ac_prev=includedir ;;
- -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
- | --includ=* | --inclu=* | --incl=* | --inc=*)
- includedir=$ac_optarg ;;
-
- -infodir | --infodir | --infodi | --infod | --info | --inf)
- ac_prev=infodir ;;
- -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
- infodir=$ac_optarg ;;
-
- -libdir | --libdir | --libdi | --libd)
- ac_prev=libdir ;;
- -libdir=* | --libdir=* | --libdi=* | --libd=*)
- libdir=$ac_optarg ;;
-
- -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
- | --libexe | --libex | --libe)
- ac_prev=libexecdir ;;
- -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
- | --libexe=* | --libex=* | --libe=*)
- libexecdir=$ac_optarg ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst \
- | --locals | --local | --loca | --loc | --lo)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* \
- | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
- localstatedir=$ac_optarg ;;
-
- -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
- ac_prev=mandir ;;
- -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
- mandir=$ac_optarg ;;
-
- -nfp | --nfp | --nf)
- # Obsolete; use --without-fp.
- with_fp=no ;;
-
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c | -n)
- no_create=yes ;;
-
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
- no_recursion=yes ;;
-
- -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
- | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
- | --oldin | --oldi | --old | --ol | --o)
- ac_prev=oldincludedir ;;
- -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
- | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
- | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
- oldincludedir=$ac_optarg ;;
-
- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
- ac_prev=prefix ;;
- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
- prefix=$ac_optarg ;;
-
- -program-prefix | --program-prefix | --program-prefi | --program-pref \
- | --program-pre | --program-pr | --program-p)
- ac_prev=program_prefix ;;
- -program-prefix=* | --program-prefix=* | --program-prefi=* \
- | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
- program_prefix=$ac_optarg ;;
-
- -program-suffix | --program-suffix | --program-suffi | --program-suff \
- | --program-suf | --program-su | --program-s)
- ac_prev=program_suffix ;;
- -program-suffix=* | --program-suffix=* | --program-suffi=* \
- | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
- program_suffix=$ac_optarg ;;
-
- -program-transform-name | --program-transform-name \
- | --program-transform-nam | --program-transform-na \
- | --program-transform-n | --program-transform- \
- | --program-transform | --program-transfor \
- | --program-transfo | --program-transf \
- | --program-trans | --program-tran \
- | --progr-tra | --program-tr | --program-t)
- ac_prev=program_transform_name ;;
- -program-transform-name=* | --program-transform-name=* \
- | --program-transform-nam=* | --program-transform-na=* \
- | --program-transform-n=* | --program-transform-=* \
- | --program-transform=* | --program-transfor=* \
- | --program-transfo=* | --program-transf=* \
- | --program-trans=* | --program-tran=* \
- | --progr-tra=* | --program-tr=* | --program-t=*)
- program_transform_name=$ac_optarg ;;
-
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- silent=yes ;;
-
- -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
- ac_prev=sbindir ;;
- -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
- | --sbi=* | --sb=*)
- sbindir=$ac_optarg ;;
-
- -sharedstatedir | --sharedstatedir | --sharedstatedi \
- | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
- | --sharedst | --shareds | --shared | --share | --shar \
- | --sha | --sh)
- ac_prev=sharedstatedir ;;
- -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
- | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
- | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
- | --sha=* | --sh=*)
- sharedstatedir=$ac_optarg ;;
-
- -site | --site | --sit)
- ac_prev=site ;;
- -site=* | --site=* | --sit=*)
- site=$ac_optarg ;;
-
- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
- ac_prev=srcdir ;;
- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
- srcdir=$ac_optarg ;;
-
- -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
- | --syscon | --sysco | --sysc | --sys | --sy)
- ac_prev=sysconfdir ;;
- -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
- | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
- sysconfdir=$ac_optarg ;;
-
- -target | --target | --targe | --targ | --tar | --ta | --t)
- ac_prev=target_alias ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target_alias=$ac_optarg ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers | -V)
- ac_init_version=: ;;
-
- -with-* | --with-*)
- ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid package name: $ac_package" >&2
- { (exit 1); exit 1; }; }
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- case $ac_option in
- *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
- *) ac_optarg=yes ;;
- esac
- eval "with_$ac_package='$ac_optarg'" ;;
-
- -without-* | --without-*)
- ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid package name: $ac_package" >&2
- { (exit 1); exit 1; }; }
- ac_package=`echo $ac_package | sed 's/-/_/g'`
- eval "with_$ac_package=no" ;;
-
- --x)
- # Obsolete; use --with-x.
- with_x=yes ;;
-
- -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
- | --x-incl | --x-inc | --x-in | --x-i)
- ac_prev=x_includes ;;
- -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
- | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
- x_includes=$ac_optarg ;;
-
- -x-libraries | --x-libraries | --x-librarie | --x-librari \
- | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
- ac_prev=x_libraries ;;
- -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
- | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
- x_libraries=$ac_optarg ;;
-
- -*) { echo "$as_me: error: unrecognized option: $ac_option
-Try \`$0 --help' for more information." >&2
- { (exit 1); exit 1; }; }
- ;;
-
- *=*)
- ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
- # Reject names that are not valid shell variable names.
- expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
- { (exit 1); exit 1; }; }
- ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
- eval "$ac_envvar='$ac_optarg'"
- export $ac_envvar ;;
-
- *)
- # FIXME: should be removed in autoconf 3.0.
- echo "$as_me: WARNING: you should use --build, --host, --target" >&2
- expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
- echo "$as_me: WARNING: invalid host type: $ac_option" >&2
- : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- ac_option=--`echo $ac_prev | sed 's/_/-/g'`
- { echo "$as_me: error: missing argument to $ac_option" >&2
- { (exit 1); exit 1; }; }
-fi
-
-# Be sure to have absolute paths.
-for ac_var in exec_prefix prefix
-do
- eval ac_val=$`echo $ac_var`
- case $ac_val in
- [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
- *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
- { (exit 1); exit 1; }; };;
- esac
-done
-
-# Be sure to have absolute paths.
-for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
- localstatedir libdir includedir oldincludedir infodir mandir
-do
- eval ac_val=$`echo $ac_var`
- case $ac_val in
- [\\/$]* | ?:[\\/]* ) ;;
- *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
- { (exit 1); exit 1; }; };;
- esac
-done
-
-# There might be people who depend on the old broken behavior: `$host'
-# used to hold the argument of --host etc.
-# FIXME: To remove some day.
-build=$build_alias
-host=$host_alias
-target=$target_alias
-
-# FIXME: To remove some day.
-if test "x$host_alias" != x; then
- if test "x$build_alias" = x; then
- cross_compiling=maybe
- echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
- If a cross compiler is detected then cross compile mode will be used." >&2
- elif test "x$build_alias" != "x$host_alias"; then
- cross_compiling=yes
- fi
-fi
-
-ac_tool_prefix=
-test -n "$host_alias" && ac_tool_prefix=$host_alias-
-
-test "$silent" = yes && exec 6>/dev/null
-
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
- ac_srcdir_defaulted=yes
- # Try the directory containing this script, then its parent.
- ac_confdir=`(dirname "$0") 2>/dev/null ||
-$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$0" : 'X\(//\)[^/]' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$0" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- srcdir=$ac_confdir
- if test ! -r $srcdir/$ac_unique_file; then
- srcdir=..
- fi
-else
- ac_srcdir_defaulted=no
-fi
-if test ! -r $srcdir/$ac_unique_file; then
- if test "$ac_srcdir_defaulted" = yes; then
- { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
- { (exit 1); exit 1; }; }
- else
- { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
- { (exit 1); exit 1; }; }
- fi
-fi
-(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
- { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
- { (exit 1); exit 1; }; }
-srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
-ac_env_build_alias_set=${build_alias+set}
-ac_env_build_alias_value=$build_alias
-ac_cv_env_build_alias_set=${build_alias+set}
-ac_cv_env_build_alias_value=$build_alias
-ac_env_host_alias_set=${host_alias+set}
-ac_env_host_alias_value=$host_alias
-ac_cv_env_host_alias_set=${host_alias+set}
-ac_cv_env_host_alias_value=$host_alias
-ac_env_target_alias_set=${target_alias+set}
-ac_env_target_alias_value=$target_alias
-ac_cv_env_target_alias_set=${target_alias+set}
-ac_cv_env_target_alias_value=$target_alias
-ac_env_CC_set=${CC+set}
-ac_env_CC_value=$CC
-ac_cv_env_CC_set=${CC+set}
-ac_cv_env_CC_value=$CC
-ac_env_CFLAGS_set=${CFLAGS+set}
-ac_env_CFLAGS_value=$CFLAGS
-ac_cv_env_CFLAGS_set=${CFLAGS+set}
-ac_cv_env_CFLAGS_value=$CFLAGS
-ac_env_LDFLAGS_set=${LDFLAGS+set}
-ac_env_LDFLAGS_value=$LDFLAGS
-ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
-ac_cv_env_LDFLAGS_value=$LDFLAGS
-ac_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_env_CPPFLAGS_value=$CPPFLAGS
-ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_cv_env_CPPFLAGS_value=$CPPFLAGS
-ac_env_CPP_set=${CPP+set}
-ac_env_CPP_value=$CPP
-ac_cv_env_CPP_set=${CPP+set}
-ac_cv_env_CPP_value=$CPP
-ac_env_CXX_set=${CXX+set}
-ac_env_CXX_value=$CXX
-ac_cv_env_CXX_set=${CXX+set}
-ac_cv_env_CXX_value=$CXX
-ac_env_CXXFLAGS_set=${CXXFLAGS+set}
-ac_env_CXXFLAGS_value=$CXXFLAGS
-ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set}
-ac_cv_env_CXXFLAGS_value=$CXXFLAGS
-ac_env_CXXCPP_set=${CXXCPP+set}
-ac_env_CXXCPP_value=$CXXCPP
-ac_cv_env_CXXCPP_set=${CXXCPP+set}
-ac_cv_env_CXXCPP_value=$CXXCPP
-ac_env_F77_set=${F77+set}
-ac_env_F77_value=$F77
-ac_cv_env_F77_set=${F77+set}
-ac_cv_env_F77_value=$F77
-ac_env_FFLAGS_set=${FFLAGS+set}
-ac_env_FFLAGS_value=$FFLAGS
-ac_cv_env_FFLAGS_set=${FFLAGS+set}
-ac_cv_env_FFLAGS_value=$FFLAGS
-
-#
-# Report the --help message.
-#
-if test "$ac_init_help" = "long"; then
- # Omit some internal or obsolete options to make the list less imposing.
- # This message is too long to be a string in the A/UX 3.1 sh.
- cat <<_ACEOF
-\`configure' configures JSON C Library 0.3 to adapt to many kinds of systems.
-
-Usage: $0 [OPTION]... [VAR=VALUE]...
-
-To assign environment variables (e.g., CC, CFLAGS...), specify them as
-VAR=VALUE. See below for descriptions of some of the useful variables.
-
-Defaults for the options are specified in brackets.
-
-Configuration:
- -h, --help display this help and exit
- --help=short display options specific to this package
- --help=recursive display the short help of all the included packages
- -V, --version display version information and exit
- -q, --quiet, --silent do not print \`checking...' messages
- --cache-file=FILE cache test results in FILE [disabled]
- -C, --config-cache alias for \`--cache-file=config.cache'
- -n, --no-create do not create output files
- --srcdir=DIR find the sources in DIR [configure dir or \`..']
-
-_ACEOF
-
- cat <<_ACEOF
-Installation directories:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [PREFIX]
-
-By default, \`make install' will install all the files in
-\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
-an installation prefix other than \`$ac_default_prefix' using \`--prefix',
-for instance \`--prefix=\$HOME'.
-
-For better control, use the options below.
-
-Fine tuning of the installation directories:
- --bindir=DIR user executables [EPREFIX/bin]
- --sbindir=DIR system admin executables [EPREFIX/sbin]
- --libexecdir=DIR program executables [EPREFIX/libexec]
- --datadir=DIR read-only architecture-independent data [PREFIX/share]
- --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --libdir=DIR object code libraries [EPREFIX/lib]
- --includedir=DIR C header files [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc [/usr/include]
- --infodir=DIR info documentation [PREFIX/info]
- --mandir=DIR man documentation [PREFIX/man]
-_ACEOF
-
- cat <<\_ACEOF
-
-Program names:
- --program-prefix=PREFIX prepend PREFIX to installed program names
- --program-suffix=SUFFIX append SUFFIX to installed program names
- --program-transform-name=PROGRAM run sed PROGRAM on installed program names
-
-System types:
- --build=BUILD configure for building on BUILD [guessed]
- --host=HOST cross-compile to build programs to run on HOST [BUILD]
-_ACEOF
-fi
-
-if test -n "$ac_init_help"; then
- case $ac_init_help in
- short | recursive ) echo "Configuration of JSON C Library 0.3:";;
- esac
- cat <<\_ACEOF
-
-Optional Features:
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --enable-shared[=PKGS]
- build shared libraries [default=yes]
- --enable-static[=PKGS]
- build static libraries [default=yes]
- --enable-fast-install[=PKGS]
- optimize for fast installation [default=yes]
- --disable-libtool-lock avoid locking (might break parallel builds)
-
-Optional Packages:
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --with-gnu-ld assume the C compiler uses GNU ld [default=no]
- --with-pic try to use only PIC/non-PIC objects [default=use
- both]
- --with-tags[=TAGS]
- include additional configurations [automatic]
-
-Some influential environment variables:
- CC C compiler command
- CFLAGS C compiler flags
- LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
- nonstandard directory <lib dir>
- CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
- headers in a nonstandard directory <include dir>
- CPP C preprocessor
- CXX C++ compiler command
- CXXFLAGS C++ compiler flags
- CXXCPP C++ preprocessor
- F77 Fortran 77 compiler command
- FFLAGS Fortran 77 compiler flags
-
-Use these variables to override the choices made by `configure' or to help
-it to find libraries and programs with nonstandard names/locations.
-
-Report bugs to <michael@metaparadigm.com>.
-_ACEOF
-fi
-
-if test "$ac_init_help" = "recursive"; then
- # If there are subdirs, report their specific --help.
- ac_popdir=`pwd`
- for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
- test -d $ac_dir || continue
- ac_builddir=.
-
-if test "$ac_dir" != .; then
- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
- # A "../" for each directory in $ac_dir_suffix.
- ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
- ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
- .) # No --srcdir option. We are building in place.
- ac_srcdir=.
- if test -z "$ac_top_builddir"; then
- ac_top_srcdir=.
- else
- ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
- fi ;;
- [\\/]* | ?:[\\/]* ) # Absolute path.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir ;;
- *) # Relative path.
- ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
- case "$ac_dir" in
- .) ac_abs_builddir=`pwd`;;
- [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
- *) ac_abs_builddir=`pwd`/"$ac_dir";;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
- case ${ac_top_builddir}. in
- .) ac_abs_top_builddir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
- *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
- case $ac_srcdir in
- .) ac_abs_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
- *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
- case $ac_top_srcdir in
- .) ac_abs_top_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
- *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
- esac;;
-esac
-
- cd $ac_dir
- # Check for guested configure; otherwise get Cygnus style configure.
- if test -f $ac_srcdir/configure.gnu; then
- echo
- $SHELL $ac_srcdir/configure.gnu --help=recursive
- elif test -f $ac_srcdir/configure; then
- echo
- $SHELL $ac_srcdir/configure --help=recursive
- elif test -f $ac_srcdir/configure.ac ||
- test -f $ac_srcdir/configure.in; then
- echo
- $ac_configure --help
- else
- echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
- fi
- cd "$ac_popdir"
- done
-fi
-
-test -n "$ac_init_help" && exit 0
-if $ac_init_version; then
- cat <<\_ACEOF
-JSON C Library configure 0.3
-generated by GNU Autoconf 2.59
-
-Copyright (C) 2003 Free Software Foundation, Inc.
-This configure script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it.
-_ACEOF
- exit 0
-fi
-exec 5>config.log
-cat >&5 <<_ACEOF
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-
-It was created by JSON C Library $as_me 0.3, which was
-generated by GNU Autoconf 2.59. Invocation command line was
-
- $ $0 $@
-
-_ACEOF
-{
-cat <<_ASUNAME
-## --------- ##
-## Platform. ##
-## --------- ##
-
-hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
-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 || echo unknown`
-/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
-
-/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
-/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
-hostinfo = `(hostinfo) 2>/dev/null || echo unknown`
-/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
-/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
-/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
-
-_ASUNAME
-
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- echo "PATH: $as_dir"
-done
-
-} >&5
-
-cat >&5 <<_ACEOF
-
-
-## ----------- ##
-## Core tests. ##
-## ----------- ##
-
-_ACEOF
-
-
-# Keep a trace of the command line.
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Strip out --silent because we don't want to record it for future runs.
-# Also quote any args containing shell meta-characters.
-# Make two passes to allow for proper duplicate-argument suppression.
-ac_configure_args=
-ac_configure_args0=
-ac_configure_args1=
-ac_sep=
-ac_must_keep_next=false
-for ac_pass in 1 2
-do
- for ac_arg
- do
- case $ac_arg in
- -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- continue ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
- ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
- esac
- case $ac_pass in
- 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
- 2)
- ac_configure_args1="$ac_configure_args1 '$ac_arg'"
- if test $ac_must_keep_next = true; then
- ac_must_keep_next=false # Got value, back to normal.
- else
- case $ac_arg in
- *=* | --config-cache | -C | -disable-* | --disable-* \
- | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
- | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
- | -with-* | --with-* | -without-* | --without-* | --x)
- case "$ac_configure_args0 " in
- "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
- esac
- ;;
- -* ) ac_must_keep_next=true ;;
- esac
- fi
- ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
- # Get rid of the leading space.
- ac_sep=" "
- ;;
- esac
- done
-done
-$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
-$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
-
-# When interrupted or exit'd, cleanup temporary files, and complete
-# config.log. We remove comments because anyway the quotes in there
-# would cause problems or look ugly.
-# WARNING: Be sure not to use single quotes in there, as some shells,
-# such as our DU 5.0 friend, will then `close' the trap.
-trap 'exit_status=$?
- # Save into config.log some information that might help in debugging.
- {
- echo
-
- cat <<\_ASBOX
-## ---------------- ##
-## Cache variables. ##
-## ---------------- ##
-_ASBOX
- echo
- # The following way of writing the cache mishandles newlines in values,
-{
- (set) 2>&1 |
- case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
- *ac_space=\ *)
- sed -n \
- "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
- ;;
- *)
- sed -n \
- "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
- ;;
- esac;
-}
- echo
-
- cat <<\_ASBOX
-## ----------------- ##
-## Output variables. ##
-## ----------------- ##
-_ASBOX
- echo
- for ac_var in $ac_subst_vars
- do
- eval ac_val=$`echo $ac_var`
- echo "$ac_var='"'"'$ac_val'"'"'"
- done | sort
- echo
-
- if test -n "$ac_subst_files"; then
- cat <<\_ASBOX
-## ------------- ##
-## Output files. ##
-## ------------- ##
-_ASBOX
- echo
- for ac_var in $ac_subst_files
- do
- eval ac_val=$`echo $ac_var`
- echo "$ac_var='"'"'$ac_val'"'"'"
- done | sort
- echo
- fi
-
- if test -s confdefs.h; then
- cat <<\_ASBOX
-## ----------- ##
-## confdefs.h. ##
-## ----------- ##
-_ASBOX
- echo
- sed "/^$/d" confdefs.h | sort
- echo
- fi
- test "$ac_signal" != 0 &&
- echo "$as_me: caught signal $ac_signal"
- echo "$as_me: exit $exit_status"
- } >&5
- rm -f core *.core &&
- rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
- exit $exit_status
- ' 0
-for ac_signal in 1 2 13 15; do
- trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
-done
-ac_signal=0
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo >confdefs.h
-
-# Predefined preprocessor variables.
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_NAME "$PACKAGE_NAME"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_VERSION "$PACKAGE_VERSION"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_STRING "$PACKAGE_STRING"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
-_ACEOF
-
-
-# Let the site file select an alternate cache file if it wants to.
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
- if test "x$prefix" != xNONE; then
- CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
- else
- CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
- fi
-fi
-for ac_site_file in $CONFIG_SITE; do
- if test -r "$ac_site_file"; then
- { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
-echo "$as_me: loading site script $ac_site_file" >&6;}
- sed 's/^/| /' "$ac_site_file" >&5
- . "$ac_site_file"
- fi
-done
-
-if test -r "$cache_file"; then
- # Some versions of bash will fail to source /dev/null (special
- # files actually), so we avoid doing that.
- if test -f "$cache_file"; then
- { echo "$as_me:$LINENO: loading cache $cache_file" >&5
-echo "$as_me: loading cache $cache_file" >&6;}
- case $cache_file in
- [\\/]* | ?:[\\/]* ) . $cache_file;;
- *) . ./$cache_file;;
- esac
- fi
-else
- { echo "$as_me:$LINENO: creating cache $cache_file" >&5
-echo "$as_me: creating cache $cache_file" >&6;}
- >$cache_file
-fi
-
-# Check that the precious variables saved in the cache have kept the same
-# value.
-ac_cache_corrupted=false
-for ac_var in `(set) 2>&1 |
- sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
- eval ac_old_set=\$ac_cv_env_${ac_var}_set
- eval ac_new_set=\$ac_env_${ac_var}_set
- eval ac_old_val="\$ac_cv_env_${ac_var}_value"
- eval ac_new_val="\$ac_env_${ac_var}_value"
- case $ac_old_set,$ac_new_set in
- set,)
- { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,set)
- { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,);;
- *)
- if test "x$ac_old_val" != "x$ac_new_val"; then
- { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
-echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
- { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
-echo "$as_me: former value: $ac_old_val" >&2;}
- { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
-echo "$as_me: current value: $ac_new_val" >&2;}
- ac_cache_corrupted=:
- fi;;
- esac
- # Pass precious variables to config.status.
- if test "$ac_new_set" = set; then
- case $ac_new_val in
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
- ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
- *) ac_arg=$ac_var=$ac_new_val ;;
- esac
- case " $ac_configure_args " in
- *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
- *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
- esac
- fi
-done
-if $ac_cache_corrupted; then
- { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
-echo "$as_me: error: changes in the environment can compromise the build" >&2;}
- { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
-echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-am__api_version="1.4"
-ac_aux_dir=
-for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
- if test -f $ac_dir/install-sh; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install-sh -c"
- break
- elif test -f $ac_dir/install.sh; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install.sh -c"
- break
- elif test -f $ac_dir/shtool; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/shtool install -c"
- break
- fi
-done
-if test -z "$ac_aux_dir"; then
- { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
-echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
- { (exit 1); exit 1; }; }
-fi
-ac_config_guess="$SHELL $ac_aux_dir/config.guess"
-ac_config_sub="$SHELL $ac_aux_dir/config.sub"
-ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
-
-# Find a good install program. We prefer a C program (faster),
-# so one script is as good as another. But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# AmigaOS /C/install, which installs bootblocks on floppy discs
-# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# OS/2's system install, which has a completely different semantic
-# ./install, which can be erroneously created by make from ./install.sh.
-echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
-echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
-if test -z "$INSTALL"; then
-if test "${ac_cv_path_install+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- # Account for people who put trailing slashes in PATH elements.
-case $as_dir/ in
- ./ | .// | /cC/* | \
- /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
- ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
- /usr/ucb/* ) ;;
- *)
- # OSF1 and SCO ODT 3.0 have their own names for install.
- # Don't use installbsd from OSF since it installs stuff as root
- # by default.
- for ac_prog in ginstall scoinst install; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
- if test $ac_prog = install &&
- grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
- # AIX install. It has an incompatible calling convention.
- :
- elif test $ac_prog = install &&
- grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
- # program-specific install script used by HP pwplus--don't use.
- :
- else
- ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
- break 3
- fi
- fi
- done
- done
- ;;
-esac
-done
-
-
-fi
- if test "${ac_cv_path_install+set}" = set; then
- INSTALL=$ac_cv_path_install
- else
- # As a last resort, use the slow shell script. We don't cache a
- # path for INSTALL within a source directory, because that will
- # break other packages using the cache if that directory is
- # removed, or if the path is relative.
- INSTALL=$ac_install_sh
- fi
-fi
-echo "$as_me:$LINENO: result: $INSTALL" >&5
-echo "${ECHO_T}$INSTALL" >&6
-
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
-
-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-echo "$as_me:$LINENO: checking whether build environment is sane" >&5
-echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6
-# Just in case
-sleep 1
-echo timestamp > conftestfile
-# Do `set' in a subshell so we don't clobber the current shell's
-# arguments. Must try -L first in case configure is actually a
-# symlink; some systems play weird games with the mod time of symlinks
-# (eg FreeBSD returns the mod time of the symlink's containing
-# directory).
-if (
- set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
- if test "$*" = "X"; then
- # -L didn't work.
- set X `ls -t $srcdir/configure conftestfile`
- fi
- if test "$*" != "X $srcdir/configure conftestfile" \
- && test "$*" != "X conftestfile $srcdir/configure"; then
-
- # If neither matched, then we have a broken ls. This can happen
- # if, for instance, CONFIG_SHELL is bash and it inherits a
- # broken ls alias from the environment. This has actually
- # happened. Such a system could not be considered "sane".
- { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken
-alias in your environment" >&5
-echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken
-alias in your environment" >&2;}
- { (exit 1); exit 1; }; }
- fi
-
- test "$2" = conftestfile
- )
-then
- # Ok.
- :
-else
- { { echo "$as_me:$LINENO: error: newly created file is older than distributed files!
-Check your system clock" >&5
-echo "$as_me: error: newly created file is older than distributed files!
-Check your system clock" >&2;}
- { (exit 1); exit 1; }; }
-fi
-rm -f conftest*
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-test "$program_prefix" != NONE &&
- program_transform_name="s,^,$program_prefix,;$program_transform_name"
-# Use a double $ so make ignores it.
-test "$program_suffix" != NONE &&
- program_transform_name="s,\$,$program_suffix,;$program_transform_name"
-# Double any \ or $. echo might interpret backslashes.
-# By default was `s,x,x', remove it if useless.
-cat <<\_ACEOF >conftest.sed
-s/[\\$]/&&/g;s/;s,x,x,$//
-_ACEOF
-program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
-rm conftest.sed
-
-echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
-echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6
-set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'`
-if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.make <<\_ACEOF
-all:
- @echo 'ac_maketemp="$(MAKE)"'
-_ACEOF
-# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
-eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`
-if test -n "$ac_maketemp"; then
- eval ac_cv_prog_make_${ac_make}_set=yes
-else
- eval ac_cv_prog_make_${ac_make}_set=no
-fi
-rm -f conftest.make
-fi
-if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
- echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
- SET_MAKE=
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
- SET_MAKE="MAKE=${MAKE-make}"
-fi
-
-
-PACKAGE=JSON C Library
-
-VERSION=0.3
-
-if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
- { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
-echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE "$PACKAGE"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define VERSION "$VERSION"
-_ACEOF
-
-
-
-missing_dir=`cd $ac_aux_dir && pwd`
-echo "$as_me:$LINENO: checking for working aclocal-${am__api_version}" >&5
-echo $ECHO_N "checking for working aclocal-${am__api_version}... $ECHO_C" >&6
-# Run test in a subshell; some versions of sh will print an error if
-# an executable is not found, even if stderr is redirected.
-# Redirect stdin to placate older versions of autoconf. Sigh.
-if (aclocal-${am__api_version} --version) < /dev/null > /dev/null 2>&1; then
- ACLOCAL=aclocal-${am__api_version}
- echo "$as_me:$LINENO: result: found" >&5
-echo "${ECHO_T}found" >&6
-else
- ACLOCAL="$missing_dir/missing aclocal-${am__api_version}"
- echo "$as_me:$LINENO: result: missing" >&5
-echo "${ECHO_T}missing" >&6
-fi
-
-echo "$as_me:$LINENO: checking for working autoconf" >&5
-echo $ECHO_N "checking for working autoconf... $ECHO_C" >&6
-# Run test in a subshell; some versions of sh will print an error if
-# an executable is not found, even if stderr is redirected.
-# Redirect stdin to placate older versions of autoconf. Sigh.
-if (autoconf --version) < /dev/null > /dev/null 2>&1; then
- AUTOCONF=autoconf
- echo "$as_me:$LINENO: result: found" >&5
-echo "${ECHO_T}found" >&6
-else
- AUTOCONF="$missing_dir/missing autoconf"
- echo "$as_me:$LINENO: result: missing" >&5
-echo "${ECHO_T}missing" >&6
-fi
-
-echo "$as_me:$LINENO: checking for working automake-${am__api_version}" >&5
-echo $ECHO_N "checking for working automake-${am__api_version}... $ECHO_C" >&6
-# Run test in a subshell; some versions of sh will print an error if
-# an executable is not found, even if stderr is redirected.
-# Redirect stdin to placate older versions of autoconf. Sigh.
-if (automake-${am__api_version} --version) < /dev/null > /dev/null 2>&1; then
- AUTOMAKE=automake-${am__api_version}
- echo "$as_me:$LINENO: result: found" >&5
-echo "${ECHO_T}found" >&6
-else
- AUTOMAKE="$missing_dir/missing automake-${am__api_version}"
- echo "$as_me:$LINENO: result: missing" >&5
-echo "${ECHO_T}missing" >&6
-fi
-
-echo "$as_me:$LINENO: checking for working autoheader" >&5
-echo $ECHO_N "checking for working autoheader... $ECHO_C" >&6
-# Run test in a subshell; some versions of sh will print an error if
-# an executable is not found, even if stderr is redirected.
-# Redirect stdin to placate older versions of autoconf. Sigh.
-if (autoheader --version) < /dev/null > /dev/null 2>&1; then
- AUTOHEADER=autoheader
- echo "$as_me:$LINENO: result: found" >&5
-echo "${ECHO_T}found" >&6
-else
- AUTOHEADER="$missing_dir/missing autoheader"
- echo "$as_me:$LINENO: result: missing" >&5
-echo "${ECHO_T}missing" >&6
-fi
-
-echo "$as_me:$LINENO: checking for working makeinfo" >&5
-echo $ECHO_N "checking for working makeinfo... $ECHO_C" >&6
-# Run test in a subshell; some versions of sh will print an error if
-# an executable is not found, even if stderr is redirected.
-# Redirect stdin to placate older versions of autoconf. Sigh.
-if (makeinfo --version) < /dev/null > /dev/null 2>&1; then
- MAKEINFO=makeinfo
- echo "$as_me:$LINENO: result: found" >&5
-echo "${ECHO_T}found" >&6
-else
- MAKEINFO="$missing_dir/missing makeinfo"
- echo "$as_me:$LINENO: result: missing" >&5
-echo "${ECHO_T}missing" >&6
-fi
-
-
-
-# Checks for programs.
-
-# Checks for libraries.
-
-# Checks for header files.
-
- ac_config_headers="$ac_config_headers config.h"
-
- ac_config_commands="$ac_config_commands default-1"
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}gcc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="gcc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- CC=$ac_ct_CC
-else
- CC="$ac_cv_prog_CC"
-fi
-
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- CC=$ac_ct_CC
-else
- CC="$ac_cv_prog_CC"
-fi
-
-fi
-if test -z "$CC"; then
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- ac_prog_rejected=no
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-if test $ac_prog_rejected = yes; then
- # We found a bogon in the path, so make sure we never use it.
- set dummy $ac_cv_prog_CC
- shift
- if test $# != 0; then
- # We chose a different compiler from the bogus one.
- # However, it has the same basename, so the bogon will be chosen
- # first if we set CC to just the basename; use the full file name.
- shift
- ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
- fi
-fi
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- for ac_prog in cl
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$CC" && break
- done
-fi
-if test -z "$CC"; then
- ac_ct_CC=$CC
- for ac_prog in cl
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$ac_ct_CC" && break
-done
-
- CC=$ac_ct_CC
-fi
-
-fi
-
-
-test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&5
-echo "$as_me: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-
-# Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
- "checking for C compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
- (eval $ac_compiler --version </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
- (eval $ac_compiler -v </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
- (eval $ac_compiler -V </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.exe b.out"
-# Try to create an executable without -o first, disregard a.out.
-# It will help us diagnose broken compilers, and finding out an intuition
-# of exeext.
-echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
-echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6
-ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
- (eval $ac_link_default) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # Find the output, starting from the most likely. This scheme is
-# not robust to junk in `.', hence go to wildcards (a.*) only as a last
-# resort.
-
-# Be careful to initialize this variable, since it used to be cached.
-# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
-ac_cv_exeext=
-# b.out is created by i960 compilers.
-for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
-do
- test -f "$ac_file" || continue
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
- ;;
- conftest.$ac_ext )
- # This is the source file.
- ;;
- [ab].out )
- # We found the default executable, but exeext='' is most
- # certainly right.
- break;;
- *.* )
- ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- # FIXME: I believe we export ac_cv_exeext for Libtool,
- # but it would be cool to find out if it's true. Does anybody
- # maintain Libtool? --akim.
- export ac_cv_exeext
- break;;
- * )
- break;;
- esac
-done
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
-See \`config.log' for more details." >&5
-echo "$as_me: error: C compiler cannot create executables
-See \`config.log' for more details." >&2;}
- { (exit 77); exit 77; }; }
-fi
-
-ac_exeext=$ac_cv_exeext
-echo "$as_me:$LINENO: result: $ac_file" >&5
-echo "${ECHO_T}$ac_file" >&6
-
-# Check the compiler produces executables we can run. If not, either
-# the compiler is broken, or we cross compile.
-echo "$as_me:$LINENO: checking whether the C compiler works" >&5
-echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
-# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
-# If not cross compiling, check that we can run a simple program.
-if test "$cross_compiling" != yes; then
- if { ac_try='./$ac_file'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- cross_compiling=no
- else
- if test "$cross_compiling" = maybe; then
- cross_compiling=yes
- else
- { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
- fi
- fi
-fi
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-
-rm -f a.out a.exe conftest$ac_cv_exeext b.out
-ac_clean_files=$ac_clean_files_save
-# Check the compiler produces executables we can run. If not, either
-# the compiler is broken, or we cross compile.
-echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
-echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: $cross_compiling" >&5
-echo "${ECHO_T}$cross_compiling" >&6
-
-echo "$as_me:$LINENO: checking for suffix of executables" >&5
-echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # If both `conftest.exe' and `conftest' are `present' (well, observable)
-# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
-# work properly (i.e., refer to `conftest.exe'), while it won't with
-# `rm'.
-for ac_file in conftest.exe conftest conftest.*; do
- test -f "$ac_file" || continue
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
- *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- export ac_cv_exeext
- break;;
- * ) break;;
- esac
-done
-else
- { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-rm -f conftest$ac_cv_exeext
-echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
-echo "${ECHO_T}$ac_cv_exeext" >&6
-
-rm -f conftest.$ac_ext
-EXEEXT=$ac_cv_exeext
-ac_exeext=$EXEEXT
-echo "$as_me:$LINENO: checking for suffix of object files" >&5
-echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
-if test "${ac_cv_objext+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.o conftest.obj
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
- *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
- break;;
- esac
-done
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-rm -f conftest.$ac_cv_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
-echo "${ECHO_T}$ac_cv_objext" >&6
-OBJEXT=$ac_cv_objext
-ac_objext=$OBJEXT
-echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
-if test "${ac_cv_c_compiler_gnu+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-#ifndef __GNUC__
- choke me
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_compiler_gnu=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_c_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
-GCC=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-CFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
-echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_g+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_g=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_cc_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
-if test "$ac_test_CFLAGS" = set; then
- CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
- if test "$GCC" = yes; then
- CFLAGS="-g -O2"
- else
- CFLAGS="-g"
- fi
-else
- if test "$GCC" = yes; then
- CFLAGS="-O2"
- else
- CFLAGS=
- fi
-fi
-echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
-echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_stdc+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_prog_cc_stdc=no
-ac_save_CC=$CC
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
- char **p;
- int i;
-{
- return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
- char *s;
- va_list v;
- va_start (v,p);
- s = g (p, va_arg (v,int));
- va_end (v);
- return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
- function prototypes and stuff, but not '\xHH' hex character constants.
- These don't provoke an error unfortunately, instead are silently treated
- as 'x'. The following induces an error, until -std1 is added to get
- proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
- array size at least. It's necessary to write '\x00'==0 to get something
- that's true only with -std1. */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
- ;
- return 0;
-}
-_ACEOF
-# Don't try gcc -ansi; that turns off useful extensions and
-# breaks some systems' header files.
-# AIX -qlanglvl=ansi
-# Ultrix and OSF/1 -std1
-# HP-UX 10.20 and later -Ae
-# HP-UX older versions -Aa -D_HPUX_SOURCE
-# SVR4 -Xc -D__EXTENSIONS__
-for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
- CC="$ac_save_CC $ac_arg"
- rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_stdc=$ac_arg
-break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext
-done
-rm -f conftest.$ac_ext conftest.$ac_objext
-CC=$ac_save_CC
-
-fi
-
-case "x$ac_cv_prog_cc_stdc" in
- x|xno)
- echo "$as_me:$LINENO: result: none needed" >&5
-echo "${ECHO_T}none needed" >&6 ;;
- *)
- echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
- CC="$CC $ac_cv_prog_cc_stdc" ;;
-esac
-
-# Some people use a C++ compiler to compile C. Since we use `exit',
-# in C++ we need to declare it. In case someone uses the same compiler
-# for both compiling C and C++ we need to have the C++ compiler decide
-# the declaration of exit, since it's the most demanding environment.
-cat >conftest.$ac_ext <<_ACEOF
-#ifndef __cplusplus
- choke me
-#endif
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- for ac_declaration in \
- '' \
- 'extern "C" void std::exit (int) throw (); using std::exit;' \
- 'extern "C" void std::exit (int); using std::exit;' \
- 'extern "C" void exit (int) throw ();' \
- 'extern "C" void exit (int);' \
- 'void exit (int);'
-do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-#include <stdlib.h>
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
- echo '#ifdef __cplusplus' >>confdefs.h
- echo $ac_declaration >>confdefs.h
- echo '#endif' >>confdefs.h
-fi
-
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
-echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
- if test "${ac_cv_prog_CPP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # Double quotes because CPP needs to be expanded
- for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
- do
- ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- break
-fi
-
- done
- ac_cv_prog_CPP=$CPP
-
-fi
- CPP=$ac_cv_prog_CPP
-else
- ac_cv_prog_CPP=$CPP
-fi
-echo "$as_me:$LINENO: result: $CPP" >&5
-echo "${ECHO_T}$CPP" >&6
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- :
-else
- { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&5
-echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-echo "$as_me:$LINENO: checking for egrep" >&5
-echo $ECHO_N "checking for egrep... $ECHO_C" >&6
-if test "${ac_cv_prog_egrep+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if echo a | (grep -E '(a|b)') >/dev/null 2>&1
- then ac_cv_prog_egrep='grep -E'
- else ac_cv_prog_egrep='egrep'
- fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
-echo "${ECHO_T}$ac_cv_prog_egrep" >&6
- EGREP=$ac_cv_prog_egrep
-
-
-echo "$as_me:$LINENO: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
-if test "${ac_cv_header_stdc+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_header_stdc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_header_stdc=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "memchr" >/dev/null 2>&1; then
- :
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "free" >/dev/null 2>&1; then
- :
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
- if test "$cross_compiling" = yes; then
- :
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ctype.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
- (('a' <= (c) && (c) <= 'i') \
- || ('j' <= (c) && (c) <= 'r') \
- || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
- int i;
- for (i = 0; i < 256; i++)
- if (XOR (islower (i), ISLOWER (i))
- || toupper (i) != TOUPPER (i))
- exit(2);
- exit (0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_header_stdc=no
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6
-if test $ac_cv_header_stdc = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define STDC_HEADERS 1
-_ACEOF
-
-fi
-
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-
-
-
-
-
-
-
-
-
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
- inttypes.h stdint.h unistd.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Header=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_Header=no"
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-
-
-
-
-
-
-
-for ac_header in fcntl.h limits.h strings.h syslog.h unistd.h sys/param.h stdarg.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-else
- # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
- (
- cat <<\_ASBOX
-## --------------------------------------- ##
-## Report this to michael@metaparadigm.com ##
-## --------------------------------------- ##
-_ASBOX
- ) |
- sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- eval "$as_ac_Header=\$ac_header_preproc"
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-# Checks for typedefs, structures, and compiler characteristics.
-echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
-echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
-if test "${ac_cv_c_const+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-/* FIXME: Include the comments suggested by Paul. */
-#ifndef __cplusplus
- /* Ultrix mips cc rejects this. */
- typedef int charset[2];
- const charset x;
- /* SunOS 4.1.1 cc rejects this. */
- char const *const *ccp;
- char **p;
- /* NEC SVR4.0.2 mips cc rejects this. */
- struct point {int x, y;};
- static struct point const zero = {0,0};
- /* AIX XL C 1.02.0.0 rejects this.
- It does not let you subtract one const X* pointer from another in
- an arm of an if-expression whose if-part is not a constant
- expression */
- const char *g = "string";
- ccp = &g + (g ? g-g : 0);
- /* HPUX 7.0 cc rejects these. */
- ++ccp;
- p = (char**) ccp;
- ccp = (char const *const *) p;
- { /* SCO 3.2v4 cc rejects this. */
- char *t;
- char const *s = 0 ? (char *) 0 : (char const *) 0;
-
- *t++ = 0;
- }
- { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
- int x[] = {25, 17};
- const int *foo = &x[0];
- ++foo;
- }
- { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
- typedef const int *iptr;
- iptr p = 0;
- ++p;
- }
- { /* AIX XL C 1.02.0.0 rejects this saying
- "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
- struct s { int j; const int *ap[3]; };
- struct s *b; b->j = 5;
- }
- { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
- const int foo = 10;
- }
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_c_const=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_c_const=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
-echo "${ECHO_T}$ac_cv_c_const" >&6
-if test $ac_cv_c_const = no; then
-
-cat >>confdefs.h <<\_ACEOF
-#define const
-_ACEOF
-
-fi
-
-echo "$as_me:$LINENO: checking for size_t" >&5
-echo $ECHO_N "checking for size_t... $ECHO_C" >&6
-if test "${ac_cv_type_size_t+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-int
-main ()
-{
-if ((size_t *) 0)
- return 0;
-if (sizeof (size_t))
- return 0;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_type_size_t=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_type_size_t=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
-echo "${ECHO_T}$ac_cv_type_size_t" >&6
-if test $ac_cv_type_size_t = yes; then
- :
-else
-
-cat >>confdefs.h <<_ACEOF
-#define size_t unsigned
-_ACEOF
-
-fi
-
-
-# Checks for library functions.
-
-for ac_func in vprintf
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define $ac_func innocuous_$ac_func
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $ac_func
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char $ac_func ();
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-char (*f) () = $ac_func;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != $ac_func;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_var=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_var=no"
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-echo "$as_me:$LINENO: checking for _doprnt" >&5
-echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6
-if test "${ac_cv_func__doprnt+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-/* Define _doprnt to an innocuous variant, in case <limits.h> declares _doprnt.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define _doprnt innocuous__doprnt
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char _doprnt (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef _doprnt
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char _doprnt ();
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub__doprnt) || defined (__stub____doprnt)
-choke me
-#else
-char (*f) () = _doprnt;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != _doprnt;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_func__doprnt=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_func__doprnt=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5
-echo "${ECHO_T}$ac_cv_func__doprnt" >&6
-if test $ac_cv_func__doprnt = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_DOPRNT 1
-_ACEOF
-
-fi
-
-fi
-done
-
-
-echo "$as_me:$LINENO: checking for working memcmp" >&5
-echo $ECHO_N "checking for working memcmp... $ECHO_C" >&6
-if test "${ac_cv_func_memcmp_working+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_func_memcmp_working=no
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-int
-main ()
-{
-
- /* Some versions of memcmp are not 8-bit clean. */
- char c0 = 0x40, c1 = 0x80, c2 = 0x81;
- if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
- exit (1);
-
- /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
- or more and with at least one buffer not starting on a 4-byte boundary.
- William Lewis provided this test program. */
- {
- char foo[21];
- char bar[21];
- int i;
- for (i = 0; i < 4; i++)
- {
- char *a = foo + i;
- char *b = bar + i;
- strcpy (a, "--------01111111");
- strcpy (b, "--------10000000");
- if (memcmp (a, b, 16) >= 0)
- exit (1);
- }
- exit (0);
- }
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_func_memcmp_working=yes
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_func_memcmp_working=no
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func_memcmp_working" >&5
-echo "${ECHO_T}$ac_cv_func_memcmp_working" >&6
-test $ac_cv_func_memcmp_working = no && case $LIBOBJS in
- "memcmp.$ac_objext" | \
- *" memcmp.$ac_objext" | \
- "memcmp.$ac_objext "* | \
- *" memcmp.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS memcmp.$ac_objext" ;;
-esac
-
-
-
-for ac_header in stdlib.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-else
- # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
- (
- cat <<\_ASBOX
-## --------------------------------------- ##
-## Report this to michael@metaparadigm.com ##
-## --------------------------------------- ##
-_ASBOX
- ) |
- sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- eval "$as_ac_Header=\$ac_header_preproc"
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-echo "$as_me:$LINENO: checking for GNU libc compatible malloc" >&5
-echo $ECHO_N "checking for GNU libc compatible malloc... $ECHO_C" >&6
-if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_func_malloc_0_nonnull=no
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#if STDC_HEADERS || HAVE_STDLIB_H
-# include <stdlib.h>
-#else
-char *malloc ();
-#endif
-
-int
-main ()
-{
-exit (malloc (0) ? 0 : 1);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_func_malloc_0_nonnull=yes
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_func_malloc_0_nonnull=no
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func_malloc_0_nonnull" >&5
-echo "${ECHO_T}$ac_cv_func_malloc_0_nonnull" >&6
-if test $ac_cv_func_malloc_0_nonnull = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_MALLOC 1
-_ACEOF
-
-else
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_MALLOC 0
-_ACEOF
-
- case $LIBOBJS in
- "malloc.$ac_objext" | \
- *" malloc.$ac_objext" | \
- "malloc.$ac_objext "* | \
- *" malloc.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS malloc.$ac_objext" ;;
-esac
-
-
-cat >>confdefs.h <<\_ACEOF
-#define malloc rpl_malloc
-_ACEOF
-
-fi
-
-
-
-
-for ac_header in stdlib.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-else
- # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
- (
- cat <<\_ASBOX
-## --------------------------------------- ##
-## Report this to michael@metaparadigm.com ##
-## --------------------------------------- ##
-_ASBOX
- ) |
- sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- eval "$as_ac_Header=\$ac_header_preproc"
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-echo "$as_me:$LINENO: checking for GNU libc compatible realloc" >&5
-echo $ECHO_N "checking for GNU libc compatible realloc... $ECHO_C" >&6
-if test "${ac_cv_func_realloc_0_nonnull+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_func_realloc_0_nonnull=no
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#if STDC_HEADERS || HAVE_STDLIB_H
-# include <stdlib.h>
-#else
-char *realloc ();
-#endif
-
-int
-main ()
-{
-exit (realloc (0, 0) ? 0 : 1);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_func_realloc_0_nonnull=yes
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_func_realloc_0_nonnull=no
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func_realloc_0_nonnull" >&5
-echo "${ECHO_T}$ac_cv_func_realloc_0_nonnull" >&6
-if test $ac_cv_func_realloc_0_nonnull = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_REALLOC 1
-_ACEOF
-
-else
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_REALLOC 0
-_ACEOF
-
- case $LIBOBJS in
- "realloc.$ac_objext" | \
- *" realloc.$ac_objext" | \
- "realloc.$ac_objext "* | \
- *" realloc.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS realloc.$ac_objext" ;;
-esac
-
-
-cat >>confdefs.h <<\_ACEOF
-#define realloc rpl_realloc
-_ACEOF
-
-fi
-
-
-
-
-
-
-
-
-
-
-for ac_func in strndup strerror vsnprintf vasprintf open vsyslog strncasecmp
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define $ac_func innocuous_$ac_func
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $ac_func
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char $ac_func ();
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-char (*f) () = $ac_func;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != $ac_func;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_var=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_var=no"
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-
-# Check whether --enable-shared or --disable-shared was given.
-if test "${enable_shared+set}" = set; then
- enableval="$enable_shared"
- p=${PACKAGE-default}
- case $enableval in
- yes) enable_shared=yes ;;
- no) enable_shared=no ;;
- *)
- enable_shared=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_shared=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac
-else
- enable_shared=yes
-fi;
-
-# Check whether --enable-static or --disable-static was given.
-if test "${enable_static+set}" = set; then
- enableval="$enable_static"
- p=${PACKAGE-default}
- case $enableval in
- yes) enable_static=yes ;;
- no) enable_static=no ;;
- *)
- enable_static=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_static=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac
-else
- enable_static=yes
-fi;
-
-# Check whether --enable-fast-install or --disable-fast-install was given.
-if test "${enable_fast_install+set}" = set; then
- enableval="$enable_fast_install"
- p=${PACKAGE-default}
- case $enableval in
- yes) enable_fast_install=yes ;;
- no) enable_fast_install=no ;;
- *)
- enable_fast_install=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_fast_install=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac
-else
- enable_fast_install=yes
-fi;
-
-# Make sure we can run config.sub.
-$ac_config_sub sun4 >/dev/null 2>&1 ||
- { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5
-echo "$as_me: error: cannot run $ac_config_sub" >&2;}
- { (exit 1); exit 1; }; }
-
-echo "$as_me:$LINENO: checking build system type" >&5
-echo $ECHO_N "checking build system type... $ECHO_C" >&6
-if test "${ac_cv_build+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_build_alias=$build_alias
-test -z "$ac_cv_build_alias" &&
- ac_cv_build_alias=`$ac_config_guess`
-test -z "$ac_cv_build_alias" &&
- { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
-echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
- { (exit 1); exit 1; }; }
-ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
- { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5
-echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;}
- { (exit 1); exit 1; }; }
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_build" >&5
-echo "${ECHO_T}$ac_cv_build" >&6
-build=$ac_cv_build
-build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-
-
-echo "$as_me:$LINENO: checking host system type" >&5
-echo $ECHO_N "checking host system type... $ECHO_C" >&6
-if test "${ac_cv_host+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_host_alias=$host_alias
-test -z "$ac_cv_host_alias" &&
- ac_cv_host_alias=$ac_cv_build_alias
-ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
- { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5
-echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
- { (exit 1); exit 1; }; }
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_host" >&5
-echo "${ECHO_T}$ac_cv_host" >&6
-host=$ac_cv_host
-host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-
-
-echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5
-echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6
-if test "${lt_cv_path_SED+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # Loop through the user's path and test for sed and gsed.
-# Then use that list of sed's as ones to test for truncation.
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for lt_ac_prog in sed gsed; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
- lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
- fi
- done
- done
-done
-lt_ac_max=0
-lt_ac_count=0
-# Add /usr/xpg4/bin/sed as it is typically found on Solaris
-# along with /bin/sed that truncates output.
-for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
- test ! -f $lt_ac_sed && continue
- cat /dev/null > conftest.in
- lt_ac_count=0
- echo $ECHO_N "0123456789$ECHO_C" >conftest.in
- # Check for GNU sed and select it if it is found.
- if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
- lt_cv_path_SED=$lt_ac_sed
- break
- fi
- while true; do
- cat conftest.in conftest.in >conftest.tmp
- mv conftest.tmp conftest.in
- cp conftest.in conftest.nl
- echo >>conftest.nl
- $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
- cmp -s conftest.out conftest.nl || break
- # 10000 chars as input seems more than enough
- test $lt_ac_count -gt 10 && break
- lt_ac_count=`expr $lt_ac_count + 1`
- if test $lt_ac_count -gt $lt_ac_max; then
- lt_ac_max=$lt_ac_count
- lt_cv_path_SED=$lt_ac_sed
- fi
- done
-done
-
-fi
-
-SED=$lt_cv_path_SED
-echo "$as_me:$LINENO: result: $SED" >&5
-echo "${ECHO_T}$SED" >&6
-
-
-# Check whether --with-gnu-ld or --without-gnu-ld was given.
-if test "${with_gnu_ld+set}" = set; then
- withval="$with_gnu_ld"
- test "$withval" = no || with_gnu_ld=yes
-else
- with_gnu_ld=no
-fi;
-ac_prog=ld
-if test "$GCC" = yes; then
- # Check if gcc -print-prog-name=ld gives a path.
- echo "$as_me:$LINENO: checking for ld used by $CC" >&5
-echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6
- case $host in
- *-*-mingw*)
- # gcc leaves a trailing carriage return which upsets mingw
- ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
- *)
- ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
- esac
- case $ac_prog in
- # Accept absolute paths.
- [\\/]* | ?:[\\/]*)
- re_direlt='/[^/][^/]*/\.\./'
- # Canonicalize the pathname of ld
- ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
- ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
- done
- test -z "$LD" && LD="$ac_prog"
- ;;
- "")
- # If it fails, then pretend we aren't using GCC.
- ac_prog=ld
- ;;
- *)
- # If it is relative, then search for the first ld in PATH.
- with_gnu_ld=unknown
- ;;
- esac
-elif test "$with_gnu_ld" = yes; then
- echo "$as_me:$LINENO: checking for GNU ld" >&5
-echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6
-else
- echo "$as_me:$LINENO: checking for non-GNU ld" >&5
-echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6
-fi
-if test "${lt_cv_path_LD+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -z "$LD"; then
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for ac_dir in $PATH; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
- lt_cv_path_LD="$ac_dir/$ac_prog"
- # Check to see if the program is GNU ld. I'd rather use --version,
- # but apparently some variants of GNU ld only accept -v.
- # Break only if it was the GNU/non-GNU ld that we prefer.
- case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
- *GNU* | *'with BFD'*)
- test "$with_gnu_ld" != no && break
- ;;
- *)
- test "$with_gnu_ld" != yes && break
- ;;
- esac
- fi
- done
- IFS="$lt_save_ifs"
-else
- lt_cv_path_LD="$LD" # Let the user override the test with a path.
-fi
-fi
-
-LD="$lt_cv_path_LD"
-if test -n "$LD"; then
- echo "$as_me:$LINENO: result: $LD" >&5
-echo "${ECHO_T}$LD" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
-echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
- { (exit 1); exit 1; }; }
-echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
-echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
-if test "${lt_cv_prog_gnu_ld+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # I'd rather use --version here, but apparently some GNU lds only accept -v.
-case `$LD -v 2>&1 </dev/null` in
-*GNU* | *'with BFD'*)
- lt_cv_prog_gnu_ld=yes
- ;;
-*)
- lt_cv_prog_gnu_ld=no
- ;;
-esac
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
-echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6
-with_gnu_ld=$lt_cv_prog_gnu_ld
-
-
-echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5
-echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6
-if test "${lt_cv_ld_reload_flag+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_ld_reload_flag='-r'
-fi
-echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5
-echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6
-reload_flag=$lt_cv_ld_reload_flag
-case $reload_flag in
-"" | " "*) ;;
-*) reload_flag=" $reload_flag" ;;
-esac
-reload_cmds='$LD$reload_flag -o $output$reload_objs'
-case $host_os in
- darwin*)
- if test "$GCC" = yes; then
- reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
- else
- reload_cmds='$LD$reload_flag -o $output$reload_objs'
- fi
- ;;
-esac
-
-echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5
-echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6
-if test "${lt_cv_path_NM+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$NM"; then
- # Let the user override the test.
- lt_cv_path_NM="$NM"
-else
- lt_nm_to_check="${ac_tool_prefix}nm"
- if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
- lt_nm_to_check="$lt_nm_to_check nm"
- fi
- for lt_tmp_nm in $lt_nm_to_check; do
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- tmp_nm="$ac_dir/$lt_tmp_nm"
- if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
- # Check to see if the nm accepts a BSD-compat flag.
- # Adding the `sed 1q' prevents false positives on HP-UX, which says:
- # nm: unknown option "B" ignored
- # Tru64's nm complains that /dev/null is an invalid object file
- case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
- */dev/null* | *'Invalid file or object type'*)
- lt_cv_path_NM="$tmp_nm -B"
- break
- ;;
- *)
- case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
- */dev/null*)
- lt_cv_path_NM="$tmp_nm -p"
- break
- ;;
- *)
- lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
- continue # so that we can try to find one that supports BSD flags
- ;;
- esac
- ;;
- esac
- fi
- done
- IFS="$lt_save_ifs"
- done
- test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
-fi
-fi
-echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5
-echo "${ECHO_T}$lt_cv_path_NM" >&6
-NM="$lt_cv_path_NM"
-
-echo "$as_me:$LINENO: checking whether ln -s works" >&5
-echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6
-LN_S=$as_ln_s
-if test "$LN_S" = "ln -s"; then
- echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-else
- echo "$as_me:$LINENO: result: no, using $LN_S" >&5
-echo "${ECHO_T}no, using $LN_S" >&6
-fi
-
-echo "$as_me:$LINENO: checking how to recognise dependent libraries" >&5
-echo $ECHO_N "checking how to recognise dependent libraries... $ECHO_C" >&6
-if test "${lt_cv_deplibs_check_method+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_file_magic_cmd='$MAGIC_CMD'
-lt_cv_file_magic_test_file=
-lt_cv_deplibs_check_method='unknown'
-# Need to set the preceding variable on all platforms that support
-# interlibrary dependencies.
-# 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
-# 'pass_all' -- all dependencies passed with no checks.
-# 'test_compile' -- check by making test program.
-# 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
-
-case $host_os in
-aix4* | aix5*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-beos*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-bsdi[45]*)
- lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
- lt_cv_file_magic_cmd='/usr/bin/file -L'
- lt_cv_file_magic_test_file=/shlib/libc.so
- ;;
-
-cygwin*)
- # func_win32_libid is a shell function defined in ltmain.sh
- lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
- lt_cv_file_magic_cmd='func_win32_libid'
- ;;
-
-mingw* | pw32*)
- # Base MSYS/MinGW do not provide the 'file' command needed by
- # func_win32_libid shell function, so use a weaker test based on 'objdump'.
- lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
- lt_cv_file_magic_cmd='$OBJDUMP -f'
- ;;
-
-darwin* | rhapsody*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-freebsd* | kfreebsd*-gnu | dragonfly*)
- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
- case $host_cpu in
- i*86 )
- # Not sure whether the presence of OpenBSD here was a mistake.
- # Let's accept both of them until this is cleared up.
- lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
- lt_cv_file_magic_cmd=/usr/bin/file
- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
- ;;
- esac
- else
- lt_cv_deplibs_check_method=pass_all
- fi
- ;;
-
-gnu*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-hpux10.20* | hpux11*)
- lt_cv_file_magic_cmd=/usr/bin/file
- case $host_cpu in
- ia64*)
- lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
- lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
- ;;
- hppa*64*)
- lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'
- lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
- ;;
- *)
- lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
- lt_cv_file_magic_test_file=/usr/lib/libc.sl
- ;;
- esac
- ;;
-
-interix3*)
- # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
- lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $LD in
- *-32|*"-32 ") libmagic=32-bit;;
- *-n32|*"-n32 ") libmagic=N32;;
- *-64|*"-64 ") libmagic=64-bit;;
- *) libmagic=never-match;;
- esac
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-# This must be Linux ELF.
-linux*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
- lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
- else
- lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
- fi
- ;;
-
-newos6*)
- lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
- lt_cv_file_magic_cmd=/usr/bin/file
- lt_cv_file_magic_test_file=/usr/lib/libnls.so
- ;;
-
-nto-qnx*)
- lt_cv_deplibs_check_method=unknown
- ;;
-
-openbsd*)
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
- else
- lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
- fi
- ;;
-
-osf3* | osf4* | osf5*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-solaris*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-sysv4 | sysv4.3*)
- case $host_vendor in
- motorola)
- lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
- ;;
- ncr)
- lt_cv_deplibs_check_method=pass_all
- ;;
- sequent)
- lt_cv_file_magic_cmd='/bin/file'
- lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
- ;;
- sni)
- lt_cv_file_magic_cmd='/bin/file'
- lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
- lt_cv_file_magic_test_file=/lib/libc.so
- ;;
- siemens)
- lt_cv_deplibs_check_method=pass_all
- ;;
- pc)
- lt_cv_deplibs_check_method=pass_all
- ;;
- esac
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-esac
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5
-echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6
-file_magic_cmd=$lt_cv_file_magic_cmd
-deplibs_check_method=$lt_cv_deplibs_check_method
-test -z "$deplibs_check_method" && deplibs_check_method=unknown
-
-
-
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-# Check whether --enable-libtool-lock or --disable-libtool-lock was given.
-if test "${enable_libtool_lock+set}" = set; then
- enableval="$enable_libtool_lock"
-
-fi;
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
-
-# Some flags need to be propagated to the compiler or linker for good
-# libtool support.
-case $host in
-ia64-*-hpux*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- case `/usr/bin/file conftest.$ac_objext` in
- *ELF-32*)
- HPUX_IA64_MODE="32"
- ;;
- *ELF-64*)
- HPUX_IA64_MODE="64"
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-*-*-irix6*)
- # Find out which ABI we are using.
- echo '#line 5005 "configure"' > conftest.$ac_ext
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- if test "$lt_cv_prog_gnu_ld" = yes; then
- case `/usr/bin/file conftest.$ac_objext` in
- *32-bit*)
- LD="${LD-ld} -melf32bsmip"
- ;;
- *N32*)
- LD="${LD-ld} -melf32bmipn32"
- ;;
- *64-bit*)
- LD="${LD-ld} -melf64bmip"
- ;;
- esac
- else
- case `/usr/bin/file conftest.$ac_objext` in
- *32-bit*)
- LD="${LD-ld} -32"
- ;;
- *N32*)
- LD="${LD-ld} -n32"
- ;;
- *64-bit*)
- LD="${LD-ld} -64"
- ;;
- esac
- fi
- fi
- rm -rf conftest*
- ;;
-
-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- case `/usr/bin/file conftest.o` in
- *32-bit*)
- case $host in
- x86_64-*linux*)
- LD="${LD-ld} -m elf_i386"
- ;;
- ppc64-*linux*|powerpc64-*linux*)
- LD="${LD-ld} -m elf32ppclinux"
- ;;
- s390x-*linux*)
- LD="${LD-ld} -m elf_s390"
- ;;
- sparc64-*linux*)
- LD="${LD-ld} -m elf32_sparc"
- ;;
- esac
- ;;
- *64-bit*)
- case $host in
- x86_64-*linux*)
- LD="${LD-ld} -m elf_x86_64"
- ;;
- ppc*-*linux*|powerpc*-*linux*)
- LD="${LD-ld} -m elf64ppc"
- ;;
- s390*-*linux*)
- LD="${LD-ld} -m elf64_s390"
- ;;
- sparc*-*linux*)
- LD="${LD-ld} -m elf64_sparc"
- ;;
- esac
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-
-*-*-sco3.2v5*)
- # On SCO OpenServer 5, we need -belf to get full-featured binaries.
- SAVE_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -belf"
- echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5
-echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6
-if test "${lt_cv_cc_needs_belf+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- lt_cv_cc_needs_belf=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-lt_cv_cc_needs_belf=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
- ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5
-echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6
- if test x"$lt_cv_cc_needs_belf" != x"yes"; then
- # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
- CFLAGS="$SAVE_CFLAGS"
- fi
- ;;
-sparc*-*solaris*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- case `/usr/bin/file conftest.o` in
- *64-bit*)
- case $lt_cv_prog_gnu_ld in
- yes*) LD="${LD-ld} -m elf64_sparc" ;;
- *) LD="${LD-ld} -64" ;;
- esac
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-
-
-esac
-
-need_locks="$enable_libtool_lock"
-
-
-
-for ac_header in dlfcn.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-else
- # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
- (
- cat <<\_ASBOX
-## --------------------------------------- ##
-## Report this to michael@metaparadigm.com ##
-## --------------------------------------- ##
-_ASBOX
- ) |
- sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- eval "$as_ac_Header=\$ac_header_preproc"
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CXX"; then
- ac_cv_prog_CXX="$CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CXX=$ac_cv_prog_CXX
-if test -n "$CXX"; then
- echo "$as_me:$LINENO: result: $CXX" >&5
-echo "${ECHO_T}$CXX" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$CXX" && break
- done
-fi
-if test -z "$CXX"; then
- ac_ct_CXX=$CXX
- for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CXX"; then
- ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CXX="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
-if test -n "$ac_ct_CXX"; then
- echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
-echo "${ECHO_T}$ac_ct_CXX" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$ac_ct_CXX" && break
-done
-test -n "$ac_ct_CXX" || ac_ct_CXX="g++"
-
- CXX=$ac_ct_CXX
-fi
-
-
-# Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
- "checking for C++ compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
- (eval $ac_compiler --version </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
- (eval $ac_compiler -v </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
- (eval $ac_compiler -V </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-
-echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6
-if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-#ifndef __GNUC__
- choke me
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_compiler_gnu=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6
-GXX=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CXXFLAGS=${CXXFLAGS+set}
-ac_save_CXXFLAGS=$CXXFLAGS
-CXXFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
-echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_cxx_g+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cxx_g=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_cxx_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6
-if test "$ac_test_CXXFLAGS" = set; then
- CXXFLAGS=$ac_save_CXXFLAGS
-elif test $ac_cv_prog_cxx_g = yes; then
- if test "$GXX" = yes; then
- CXXFLAGS="-g -O2"
- else
- CXXFLAGS="-g"
- fi
-else
- if test "$GXX" = yes; then
- CXXFLAGS="-O2"
- else
- CXXFLAGS=
- fi
-fi
-for ac_declaration in \
- '' \
- 'extern "C" void std::exit (int) throw (); using std::exit;' \
- 'extern "C" void std::exit (int); using std::exit;' \
- 'extern "C" void exit (int) throw ();' \
- 'extern "C" void exit (int);' \
- 'void exit (int);'
-do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-#include <stdlib.h>
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
- echo '#ifdef __cplusplus' >>confdefs.h
- echo $ac_declaration >>confdefs.h
- echo '#endif' >>confdefs.h
-fi
-
-ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-
-
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
- (test "X$CXX" != "Xg++"))) ; then
- ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5
-echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6
-if test -z "$CXXCPP"; then
- if test "${ac_cv_prog_CXXCPP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # Double quotes because CXXCPP needs to be expanded
- for CXXCPP in "$CXX -E" "/lib/cpp"
- do
- ac_preproc_ok=false
-for ac_cxx_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_cxx_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_cxx_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- break
-fi
-
- done
- ac_cv_prog_CXXCPP=$CXXCPP
-
-fi
- CXXCPP=$ac_cv_prog_CXXCPP
-else
- ac_cv_prog_CXXCPP=$CXXCPP
-fi
-echo "$as_me:$LINENO: result: $CXXCPP" >&5
-echo "${ECHO_T}$CXXCPP" >&6
-ac_preproc_ok=false
-for ac_cxx_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_cxx_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_cxx_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- :
-else
- { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check
-See \`config.log' for more details." >&5
-echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-fi
-
-
-ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_F77+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$F77"; then
- ac_cv_prog_F77="$F77" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_F77="$ac_tool_prefix$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-F77=$ac_cv_prog_F77
-if test -n "$F77"; then
- echo "$as_me:$LINENO: result: $F77" >&5
-echo "${ECHO_T}$F77" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$F77" && break
- done
-fi
-if test -z "$F77"; then
- ac_ct_F77=$F77
- for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_F77+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_F77"; then
- ac_cv_prog_ac_ct_F77="$ac_ct_F77" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_F77="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_F77=$ac_cv_prog_ac_ct_F77
-if test -n "$ac_ct_F77"; then
- echo "$as_me:$LINENO: result: $ac_ct_F77" >&5
-echo "${ECHO_T}$ac_ct_F77" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$ac_ct_F77" && break
-done
-
- F77=$ac_ct_F77
-fi
-
-
-# Provide some information about the compiler.
-echo "$as_me:6016:" \
- "checking for Fortran 77 compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
- (eval $ac_compiler --version </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
- (eval $ac_compiler -v </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
- (eval $ac_compiler -V </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-rm -f a.out
-
-# If we don't use `.F' as extension, the preprocessor is not run on the
-# input file. (Note that this only needs to work for GNU compilers.)
-ac_save_ext=$ac_ext
-ac_ext=F
-echo "$as_me:$LINENO: checking whether we are using the GNU Fortran 77 compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU Fortran 77 compiler... $ECHO_C" >&6
-if test "${ac_cv_f77_compiler_gnu+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
- program main
-#ifndef __GNUC__
- choke me
-#endif
-
- end
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_compiler_gnu=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_f77_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_f77_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_f77_compiler_gnu" >&6
-ac_ext=$ac_save_ext
-ac_test_FFLAGS=${FFLAGS+set}
-ac_save_FFLAGS=$FFLAGS
-FFLAGS=
-echo "$as_me:$LINENO: checking whether $F77 accepts -g" >&5
-echo $ECHO_N "checking whether $F77 accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_f77_g+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- FFLAGS=-g
-cat >conftest.$ac_ext <<_ACEOF
- program main
-
- end
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_f77_g=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_f77_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_f77_g" >&5
-echo "${ECHO_T}$ac_cv_prog_f77_g" >&6
-if test "$ac_test_FFLAGS" = set; then
- FFLAGS=$ac_save_FFLAGS
-elif test $ac_cv_prog_f77_g = yes; then
- if test "x$ac_cv_f77_compiler_gnu" = xyes; then
- FFLAGS="-g -O2"
- else
- FFLAGS="-g"
- fi
-else
- if test "x$ac_cv_f77_compiler_gnu" = xyes; then
- FFLAGS="-O2"
- else
- FFLAGS=
- fi
-fi
-
-G77=`test $ac_compiler_gnu = yes && echo yes`
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
-
-# find the maximum length of command line arguments
-echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5
-echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6
-if test "${lt_cv_sys_max_cmd_len+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- i=0
- teststring="ABCD"
-
- case $build_os in
- msdosdjgpp*)
- # On DJGPP, this test can blow up pretty badly due to problems in libc
- # (any single argument exceeding 2000 bytes causes a buffer overrun
- # during glob expansion). Even if it were fixed, the result of this
- # check would be larger than it should be.
- lt_cv_sys_max_cmd_len=12288; # 12K is about right
- ;;
-
- gnu*)
- # Under GNU Hurd, this test is not required because there is
- # no limit to the length of command line arguments.
- # Libtool will interpret -1 as no limit whatsoever
- lt_cv_sys_max_cmd_len=-1;
- ;;
-
- cygwin* | mingw*)
- # On Win9x/ME, this test blows up -- it succeeds, but takes
- # about 5 minutes as the teststring grows exponentially.
- # Worse, since 9x/ME are not pre-emptively multitasking,
- # you end up with a "frozen" computer, even though with patience
- # the test eventually succeeds (with a max line length of 256k).
- # Instead, let's just punt: use the minimum linelength reported by
- # all of the supported platforms: 8192 (on NT/2K/XP).
- lt_cv_sys_max_cmd_len=8192;
- ;;
-
- amigaos*)
- # On AmigaOS with pdksh, this test takes hours, literally.
- # So we just punt and use a minimum line length of 8192.
- lt_cv_sys_max_cmd_len=8192;
- ;;
-
- netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
- # This has been around since 386BSD, at least. Likely further.
- if test -x /sbin/sysctl; then
- lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
- elif test -x /usr/sbin/sysctl; then
- lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
- else
- lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
- fi
- # And add a safety zone
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
- ;;
-
- interix*)
- # We know the value 262144 and hardcode it with a safety zone (like BSD)
- lt_cv_sys_max_cmd_len=196608
- ;;
-
- osf*)
- # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
- # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
- # nice to cause kernel panics so lets avoid the loop below.
- # First set a reasonable default.
- lt_cv_sys_max_cmd_len=16384
- #
- if test -x /sbin/sysconfig; then
- case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
- *1*) lt_cv_sys_max_cmd_len=-1 ;;
- esac
- fi
- ;;
- sco3.2v5*)
- lt_cv_sys_max_cmd_len=102400
- ;;
- sysv5* | sco5v6* | sysv4.2uw2*)
- kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
- if test -n "$kargmax"; then
- lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'`
- else
- lt_cv_sys_max_cmd_len=32768
- fi
- ;;
- *)
- # If test is not a shell built-in, we'll probably end up computing a
- # maximum length that is only half of the actual maximum length, but
- # we can't tell.
- SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
- while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \
- = "XX$teststring") >/dev/null 2>&1 &&
- new_result=`expr "X$teststring" : ".*" 2>&1` &&
- lt_cv_sys_max_cmd_len=$new_result &&
- test $i != 17 # 1/2 MB should be enough
- do
- i=`expr $i + 1`
- teststring=$teststring$teststring
- done
- teststring=
- # Add a significant safety factor because C++ compilers can tack on massive
- # amounts of additional arguments before passing them to the linker.
- # It appears as though 1/2 is a usable value.
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
- ;;
- esac
-
-fi
-
-if test -n $lt_cv_sys_max_cmd_len ; then
- echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5
-echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6
-else
- echo "$as_me:$LINENO: result: none" >&5
-echo "${ECHO_T}none" >&6
-fi
-
-
-
-
-# Check for command to grab the raw symbol name followed by C symbol from nm.
-echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5
-echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6
-if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-# These are sane defaults that work on at least a few old systems.
-# [They come from Ultrix. What could be older than Ultrix?!! ;)]
-
-# Character class describing NM global symbol codes.
-symcode='[BCDEGRST]'
-
-# Regexp to match symbols that can be accessed directly from C.
-sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
-
-# Transform an extracted symbol line into a proper C declaration
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
-
-# Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
-
-# Define system-specific variables.
-case $host_os in
-aix*)
- symcode='[BCDT]'
- ;;
-cygwin* | mingw* | pw32*)
- symcode='[ABCDGISTW]'
- ;;
-hpux*) # Its linker distinguishes data from code symbols
- if test "$host_cpu" = ia64; then
- symcode='[ABCDEGRST]'
- fi
- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
- ;;
-linux*)
- if test "$host_cpu" = ia64; then
- symcode='[ABCDGIRSTW]'
- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
- fi
- ;;
-irix* | nonstopux*)
- symcode='[BCDEGRST]'
- ;;
-osf*)
- symcode='[BCDEGQRST]'
- ;;
-solaris*)
- symcode='[BDRT]'
- ;;
-sco3.2v5*)
- symcode='[DT]'
- ;;
-sysv4.2uw2*)
- symcode='[DT]'
- ;;
-sysv5* | sco5v6* | unixware* | OpenUNIX*)
- symcode='[ABDT]'
- ;;
-sysv4)
- symcode='[DFNSTU]'
- ;;
-esac
-
-# Handle CRLF in mingw tool chain
-opt_cr=
-case $build_os in
-mingw*)
- opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
- ;;
-esac
-
-# If we're using GNU nm, then use its standard symbol codes.
-case `$NM -V 2>&1` in
-*GNU* | *'with BFD'*)
- symcode='[ABCDGIRSTW]' ;;
-esac
-
-# Try without a prefix undercore, then with it.
-for ac_symprfx in "" "_"; do
-
- # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
- symxfrm="\\1 $ac_symprfx\\2 \\2"
-
- # Write the raw and C identifiers.
- lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
-
- # Check to see that the pipe works correctly.
- pipe_works=no
-
- rm -f conftest*
- cat > conftest.$ac_ext <<EOF
-#ifdef __cplusplus
-extern "C" {
-#endif
-char nm_test_var;
-void nm_test_func(){}
-#ifdef __cplusplus
-}
-#endif
-int main(){nm_test_var='a';nm_test_func();return(0);}
-EOF
-
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # Now try to grab the symbols.
- nlist=conftest.nm
- if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5
- (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && test -s "$nlist"; then
- # Try sorting and uniquifying the output.
- if sort "$nlist" | uniq > "$nlist"T; then
- mv -f "$nlist"T "$nlist"
- else
- rm -f "$nlist"T
- fi
-
- # Make sure that we snagged all the symbols we need.
- if grep ' nm_test_var$' "$nlist" >/dev/null; then
- if grep ' nm_test_func$' "$nlist" >/dev/null; then
- cat <<EOF > conftest.$ac_ext
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-EOF
- # Now generate the symbol file.
- eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
-
- cat <<EOF >> conftest.$ac_ext
-#if defined (__STDC__) && __STDC__
-# define lt_ptr_t void *
-#else
-# define lt_ptr_t char *
-# define const
-#endif
-
-/* The mapping between symbol names and symbols. */
-const struct {
- const char *name;
- lt_ptr_t address;
-}
-lt_preloaded_symbols[] =
-{
-EOF
- $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
- cat <<\EOF >> conftest.$ac_ext
- {0, (lt_ptr_t) 0}
-};
-
-#ifdef __cplusplus
-}
-#endif
-EOF
- # Now try linking the two files.
- mv conftest.$ac_objext conftstm.$ac_objext
- lt_save_LIBS="$LIBS"
- lt_save_CFLAGS="$CFLAGS"
- LIBS="conftstm.$ac_objext"
- CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
- if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && test -s conftest${ac_exeext}; then
- pipe_works=yes
- fi
- LIBS="$lt_save_LIBS"
- CFLAGS="$lt_save_CFLAGS"
- else
- echo "cannot find nm_test_func in $nlist" >&5
- fi
- else
- echo "cannot find nm_test_var in $nlist" >&5
- fi
- else
- echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
- fi
- else
- echo "$progname: failed program was:" >&5
- cat conftest.$ac_ext >&5
- fi
- rm -f conftest* conftst*
-
- # Do not use the global_symbol_pipe unless it works.
- if test "$pipe_works" = yes; then
- break
- else
- lt_cv_sys_global_symbol_pipe=
- fi
-done
-
-fi
-
-if test -z "$lt_cv_sys_global_symbol_pipe"; then
- lt_cv_sys_global_symbol_to_cdecl=
-fi
-if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
- echo "$as_me:$LINENO: result: failed" >&5
-echo "${ECHO_T}failed" >&6
-else
- echo "$as_me:$LINENO: result: ok" >&5
-echo "${ECHO_T}ok" >&6
-fi
-
-echo "$as_me:$LINENO: checking for objdir" >&5
-echo $ECHO_N "checking for objdir... $ECHO_C" >&6
-if test "${lt_cv_objdir+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- rm -f .libs 2>/dev/null
-mkdir .libs 2>/dev/null
-if test -d .libs; then
- lt_cv_objdir=.libs
-else
- # MS-DOS does not allow filenames that begin with a dot.
- lt_cv_objdir=_libs
-fi
-rmdir .libs 2>/dev/null
-fi
-echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5
-echo "${ECHO_T}$lt_cv_objdir" >&6
-objdir=$lt_cv_objdir
-
-
-
-
-
-case $host_os in
-aix3*)
- # AIX sometimes has problems with the GCC collect2 program. For some
- # reason, if we set the COLLECT_NAMES environment variable, the problems
- # vanish in a puff of smoke.
- if test "X${COLLECT_NAMES+set}" != Xset; then
- COLLECT_NAMES=
- export COLLECT_NAMES
- fi
- ;;
-esac
-
-# Sed substitution that helps us do robust quoting. It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
-sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'
-
-# Same as above, but do not quote variable references.
-double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'
-
-# Sed substitution to delay expansion of an escaped shell variable in a
-# double_quote_subst'ed string.
-delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
-
-# Sed substitution to avoid accidental globbing in evaled expressions
-no_glob_subst='s/\*/\\\*/g'
-
-# Constants:
-rm="rm -f"
-
-# Global variables:
-default_ofile=libtool
-can_build_shared=yes
-
-# All known linkers require a `.a' archive for static linking (except MSVC,
-# which needs '.lib').
-libext=a
-ltmain="$ac_aux_dir/ltmain.sh"
-ofile="$default_ofile"
-with_gnu_ld="$lt_cv_prog_gnu_ld"
-
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ar; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_AR+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$AR"; then
- ac_cv_prog_AR="$AR" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_AR="${ac_tool_prefix}ar"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-AR=$ac_cv_prog_AR
-if test -n "$AR"; then
- echo "$as_me:$LINENO: result: $AR" >&5
-echo "${ECHO_T}$AR" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_AR"; then
- ac_ct_AR=$AR
- # Extract the first word of "ar", so it can be a program name with args.
-set dummy ar; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_AR+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_AR"; then
- ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_AR="ar"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
- test -z "$ac_cv_prog_ac_ct_AR" && ac_cv_prog_ac_ct_AR="false"
-fi
-fi
-ac_ct_AR=$ac_cv_prog_ac_ct_AR
-if test -n "$ac_ct_AR"; then
- echo "$as_me:$LINENO: result: $ac_ct_AR" >&5
-echo "${ECHO_T}$ac_ct_AR" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- AR=$ac_ct_AR
-else
- AR="$ac_cv_prog_AR"
-fi
-
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_RANLIB+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$RANLIB"; then
- ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-RANLIB=$ac_cv_prog_RANLIB
-if test -n "$RANLIB"; then
- echo "$as_me:$LINENO: result: $RANLIB" >&5
-echo "${ECHO_T}$RANLIB" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_RANLIB"; then
- ac_ct_RANLIB=$RANLIB
- # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_RANLIB"; then
- ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_RANLIB="ranlib"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
- test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":"
-fi
-fi
-ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
-if test -n "$ac_ct_RANLIB"; then
- echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
-echo "${ECHO_T}$ac_ct_RANLIB" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- RANLIB=$ac_ct_RANLIB
-else
- RANLIB="$ac_cv_prog_RANLIB"
-fi
-
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
-set dummy ${ac_tool_prefix}strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_STRIP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$STRIP"; then
- ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_STRIP="${ac_tool_prefix}strip"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-STRIP=$ac_cv_prog_STRIP
-if test -n "$STRIP"; then
- echo "$as_me:$LINENO: result: $STRIP" >&5
-echo "${ECHO_T}$STRIP" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_STRIP"; then
- ac_ct_STRIP=$STRIP
- # Extract the first word of "strip", so it can be a program name with args.
-set dummy strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_STRIP"; then
- ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_STRIP="strip"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
- test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":"
-fi
-fi
-ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
-if test -n "$ac_ct_STRIP"; then
- echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
-echo "${ECHO_T}$ac_ct_STRIP" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- STRIP=$ac_ct_STRIP
-else
- STRIP="$ac_cv_prog_STRIP"
-fi
-
-
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
-
-# Set sane defaults for various variables
-test -z "$AR" && AR=ar
-test -z "$AR_FLAGS" && AR_FLAGS=cru
-test -z "$AS" && AS=as
-test -z "$CC" && CC=cc
-test -z "$LTCC" && LTCC=$CC
-test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
-test -z "$DLLTOOL" && DLLTOOL=dlltool
-test -z "$LD" && LD=ld
-test -z "$LN_S" && LN_S="ln -s"
-test -z "$MAGIC_CMD" && MAGIC_CMD=file
-test -z "$NM" && NM=nm
-test -z "$SED" && SED=sed
-test -z "$OBJDUMP" && OBJDUMP=objdump
-test -z "$RANLIB" && RANLIB=:
-test -z "$STRIP" && STRIP=:
-test -z "$ac_objext" && ac_objext=o
-
-# Determine commands to create old-style static archives.
-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
-old_postinstall_cmds='chmod 644 $oldlib'
-old_postuninstall_cmds=
-
-if test -n "$RANLIB"; then
- case $host_os in
- openbsd*)
- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
- ;;
- *)
- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
- ;;
- esac
- old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
-fi
-
-for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
-# Only perform the check for file, if the check method requires it
-case $deplibs_check_method in
-file_magic*)
- if test "$file_magic_cmd" = '$MAGIC_CMD'; then
- echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5
-echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6
-if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- case $MAGIC_CMD in
-[\\/*] | ?:[\\/]*)
- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
- ;;
-*)
- lt_save_MAGIC_CMD="$MAGIC_CMD"
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
- for ac_dir in $ac_dummy; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/${ac_tool_prefix}file; then
- lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
- if test -n "$file_magic_test_file"; then
- case $deplibs_check_method in
- "file_magic "*)
- file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
- MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
- $EGREP "$file_magic_regex" > /dev/null; then
- :
- else
- cat <<EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such. This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem. Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool@gnu.org
-
-EOF
- fi ;;
- esac
- fi
- break
- fi
- done
- IFS="$lt_save_ifs"
- MAGIC_CMD="$lt_save_MAGIC_CMD"
- ;;
-esac
-fi
-
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
- echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
-echo "${ECHO_T}$MAGIC_CMD" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-if test -z "$lt_cv_path_MAGIC_CMD"; then
- if test -n "$ac_tool_prefix"; then
- echo "$as_me:$LINENO: checking for file" >&5
-echo $ECHO_N "checking for file... $ECHO_C" >&6
-if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- case $MAGIC_CMD in
-[\\/*] | ?:[\\/]*)
- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
- ;;
-*)
- lt_save_MAGIC_CMD="$MAGIC_CMD"
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
- for ac_dir in $ac_dummy; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/file; then
- lt_cv_path_MAGIC_CMD="$ac_dir/file"
- if test -n "$file_magic_test_file"; then
- case $deplibs_check_method in
- "file_magic "*)
- file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
- MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
- $EGREP "$file_magic_regex" > /dev/null; then
- :
- else
- cat <<EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such. This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem. Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool@gnu.org
-
-EOF
- fi ;;
- esac
- fi
- break
- fi
- done
- IFS="$lt_save_ifs"
- MAGIC_CMD="$lt_save_MAGIC_CMD"
- ;;
-esac
-fi
-
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
- echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
-echo "${ECHO_T}$MAGIC_CMD" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- else
- MAGIC_CMD=:
- fi
-fi
-
- fi
- ;;
-esac
-
-enable_dlopen=no
-enable_win32_dll=no
-
-# Check whether --enable-libtool-lock or --disable-libtool-lock was given.
-if test "${enable_libtool_lock+set}" = set; then
- enableval="$enable_libtool_lock"
-
-fi;
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
-
-
-# Check whether --with-pic or --without-pic was given.
-if test "${with_pic+set}" = set; then
- withval="$with_pic"
- pic_mode="$withval"
-else
- pic_mode=default
-fi;
-test -z "$pic_mode" && pic_mode=default
-
-# Use C for the default configuration in the libtool script
-tagname=
-lt_save_CC="$CC"
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-# Source file extension for C test sources.
-ac_ext=c
-
-# Object file extension for compiled C test sources.
-objext=o
-objext=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(){return(0);}\n'
-
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-
-lt_prog_compiler_no_builtin_flag=
-
-if test "$GCC" = yes; then
- lt_prog_compiler_no_builtin_flag=' -fno-builtin'
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
-echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_rtti_exceptions=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="-fno-rtti -fno-exceptions"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7077: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:7081: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_rtti_exceptions=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6
-
-if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
- lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
-else
- :
-fi
-
-fi
-
-lt_prog_compiler_wl=
-lt_prog_compiler_pic=
-lt_prog_compiler_static=
-
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
-
- if test "$GCC" = yes; then
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_static='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static='-Bstatic'
- fi
- ;;
-
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
- ;;
-
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic='-DDLL_EXPORT'
- ;;
-
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- lt_prog_compiler_pic='-fno-common'
- ;;
-
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
-
- msdosdjgpp*)
- # Just because we use GCC doesn't mean we suddenly get shared libraries
- # on systems that don't support them.
- lt_prog_compiler_can_build_shared=no
- enable_shared=no
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- lt_prog_compiler_pic=-Kconform_pic
- fi
- ;;
-
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic='-fPIC'
- ;;
- esac
- ;;
-
- *)
- lt_prog_compiler_pic='-fPIC'
- ;;
- esac
- else
- # PORTME Check for flag to pass linker flags through the system compiler.
- case $host_os in
- aix*)
- lt_prog_compiler_wl='-Wl,'
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static='-Bstatic'
- else
- lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- lt_prog_compiler_pic='-qnocommon'
- lt_prog_compiler_wl='-Wl,'
- ;;
- esac
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic='-DDLL_EXPORT'
- ;;
-
- hpux9* | hpux10* | hpux11*)
- lt_prog_compiler_wl='-Wl,'
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic='+Z'
- ;;
- esac
- # Is there a better lt_prog_compiler_static that works with the bundled CC?
- lt_prog_compiler_static='${wl}-a ${wl}archive'
- ;;
-
- irix5* | irix6* | nonstopux*)
- lt_prog_compiler_wl='-Wl,'
- # PIC (with -KPIC) is the default.
- lt_prog_compiler_static='-non_shared'
- ;;
-
- newsos6)
- lt_prog_compiler_pic='-KPIC'
- lt_prog_compiler_static='-Bstatic'
- ;;
-
- linux*)
- case $cc_basename in
- icc* | ecc*)
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_pic='-KPIC'
- lt_prog_compiler_static='-static'
- ;;
- pgcc* | pgf77* | pgf90* | pgf95*)
- # Portland Group compilers (*not* the Pentium gcc compiler,
- # which looks to be a dead project)
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_pic='-fpic'
- lt_prog_compiler_static='-Bstatic'
- ;;
- ccc*)
- lt_prog_compiler_wl='-Wl,'
- # All Alpha code is PIC.
- lt_prog_compiler_static='-non_shared'
- ;;
- esac
- ;;
-
- osf3* | osf4* | osf5*)
- lt_prog_compiler_wl='-Wl,'
- # All OSF/1 code is PIC.
- lt_prog_compiler_static='-non_shared'
- ;;
-
- solaris*)
- lt_prog_compiler_pic='-KPIC'
- lt_prog_compiler_static='-Bstatic'
- case $cc_basename in
- f77* | f90* | f95*)
- lt_prog_compiler_wl='-Qoption ld ';;
- *)
- lt_prog_compiler_wl='-Wl,';;
- esac
- ;;
-
- sunos4*)
- lt_prog_compiler_wl='-Qoption ld '
- lt_prog_compiler_pic='-PIC'
- lt_prog_compiler_static='-Bstatic'
- ;;
-
- sysv4 | sysv4.2uw2* | sysv4.3*)
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_pic='-KPIC'
- lt_prog_compiler_static='-Bstatic'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec ;then
- lt_prog_compiler_pic='-Kconform_pic'
- lt_prog_compiler_static='-Bstatic'
- fi
- ;;
-
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_pic='-KPIC'
- lt_prog_compiler_static='-Bstatic'
- ;;
-
- unicos*)
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_can_build_shared=no
- ;;
-
- uts4*)
- lt_prog_compiler_pic='-pic'
- lt_prog_compiler_static='-Bstatic'
- ;;
-
- *)
- lt_prog_compiler_can_build_shared=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic" >&6
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic"; then
-
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_pic_works=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7345: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:7349: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_pic_works=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works" >&6
-
-if test x"$lt_prog_compiler_pic_works" = xyes; then
- case $lt_prog_compiler_pic in
- "" | " "*) ;;
- *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
- esac
-else
- lt_prog_compiler_pic=
- lt_prog_compiler_can_build_shared=no
-fi
-
-fi
-case $host_os in
- # For platforms which do not support PIC, -DPIC is meaningless:
- *djgpp*)
- lt_prog_compiler_pic=
- ;;
- *)
- lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
- ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_static_works=no
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
- printf "$lt_simple_link_test_code" > conftest.$ac_ext
- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
- # The linker can only warn and ignore the option if not recognized
- # So say no if there are warnings
- if test -s conftest.err; then
- # Append any errors to the config.log.
- cat conftest.err 1>&5
- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_static_works=yes
- fi
- else
- lt_prog_compiler_static_works=yes
- fi
- fi
- $rm conftest*
- LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works" >&6
-
-if test x"$lt_prog_compiler_static_works" = xyes; then
- :
-else
- lt_prog_compiler_static=
-fi
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_c_o=no
- $rm -r conftest 2>/dev/null
- mkdir conftest
- cd conftest
- mkdir out
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- lt_compiler_flag="-o out/conftest2.$ac_objext"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7449: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>out/conftest.err)
- ac_status=$?
- cat out/conftest.err >&5
- echo "$as_me:7453: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s out/conftest2.$ac_objext
- then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_c_o=yes
- fi
- fi
- chmod u+w . 2>&5
- $rm conftest*
- # SGI C++ compiler will create directory out/ii_files/ for
- # template instantiation
- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
- $rm out/* && rmdir out
- cd ..
- rmdir conftest
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6
-
-
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
- # do not overwrite the value of need_locks provided by the user
- echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
- hard_links=yes
- $rm conftest*
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- touch conftest.a
- ln conftest.a conftest.b 2>&5 || hard_links=no
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
- if test "$hard_links" = no; then
- { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
- need_locks=warn
- fi
-else
- need_locks=no
-fi
-
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-
- runpath_var=
- allow_undefined_flag=
- enable_shared_with_static_runtimes=no
- archive_cmds=
- archive_expsym_cmds=
- old_archive_From_new_cmds=
- old_archive_from_expsyms_cmds=
- export_dynamic_flag_spec=
- whole_archive_flag_spec=
- thread_safe_flag_spec=
- hardcode_libdir_flag_spec=
- hardcode_libdir_flag_spec_ld=
- hardcode_libdir_separator=
- hardcode_direct=no
- hardcode_minus_L=no
- hardcode_shlibpath_var=unsupported
- link_all_deplibs=unknown
- hardcode_automatic=no
- module_cmds=
- module_expsym_cmds=
- always_export_symbols=no
- export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- # include_expsyms should be a list of space-separated symbols to be *always*
- # included in the symbol list
- include_expsyms=
- # exclude_expsyms can be an extended regexp of symbols to exclude
- # it will be wrapped by ` (' and `)$', so one must not match beginning or
- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
- # as well as any symbol that contains `d'.
- exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
- # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
- # platforms (ab)use it in PIC code, but their linkers get confused if
- # the symbol is explicitly referenced. Since portable code cannot
- # rely on this symbol name, it's probably fine to never include it in
- # preloaded symbol tables.
- extract_expsyms_cmds=
- # Just being paranoid about ensuring that cc_basename is set.
- for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
- case $host_os in
- cygwin* | mingw* | pw32*)
- # FIXME: the MSVC++ port hasn't been tested in a loooong time
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- if test "$GCC" != yes; then
- with_gnu_ld=no
- fi
- ;;
- interix*)
- # we just hope/assume this is gcc and not c89 (= MSVC++)
- with_gnu_ld=yes
- ;;
- openbsd*)
- with_gnu_ld=no
- ;;
- esac
-
- ld_shlibs=yes
- if test "$with_gnu_ld" = yes; then
- # If archive_cmds runs LD, not CC, wlarc should be empty
- wlarc='${wl}'
-
- # Set some defaults for GNU ld with shared library support. These
- # are reset later if shared libraries are not supported. Putting them
- # here allows them to be overridden if necessary.
- runpath_var=LD_RUN_PATH
- hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
- export_dynamic_flag_spec='${wl}--export-dynamic'
- # ancient GNU ld didn't support --whole-archive et. al.
- if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
- whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- whole_archive_flag_spec=
- fi
- supports_anon_versioning=no
- case `$LD -v 2>/dev/null` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
- *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
- *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
- *\ 2.11.*) ;; # other 2.11 versions
- *) supports_anon_versioning=yes ;;
- esac
-
- # See if GNU ld supports shared libraries.
- case $host_os in
- aix3* | aix4* | aix5*)
- # On AIX/PPC, the GNU linker is very broken
- if test "$host_cpu" != ia64; then
- ld_shlibs=no
- cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support. If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
- fi
- ;;
-
- amigaos*)
- archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_minus_L=yes
-
- # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
- # that the semantics of dynamic libraries on AmigaOS, at least up
- # to version 4, is to share data among multiple programs linked
- # with the same dynamic library. Since this doesn't match the
- # behavior of shared libraries on other platforms, we can't use
- # them.
- ld_shlibs=no
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- allow_undefined_flag=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- ld_shlibs=no
- fi
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
- # as there is no search path for DLLs.
- hardcode_libdir_flag_spec='-L$libdir'
- allow_undefined_flag=unsupported
- always_export_symbols=no
- enable_shared_with_static_runtimes=yes
- export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- ld_shlibs=no
- fi
- ;;
-
- interix3*)
- hardcode_direct=no
- hardcode_shlibpath_var=no
- hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
- export_dynamic_flag_spec='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
-
- linux*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- tmp_addflag=
- case $cc_basename,$host_cpu in
- pgcc*) # Portland Group C compiler
- whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag'
- ;;
- pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
- whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag -Mnomain' ;;
- ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
- tmp_addflag=' -i_dynamic' ;;
- efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
- tmp_addflag=' -i_dynamic -nofor_main' ;;
- ifc* | ifort*) # Intel Fortran compiler
- tmp_addflag=' -nofor_main' ;;
- esac
- archive_cmds='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
- if test $supports_anon_versioning = yes; then
- archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- $echo "local: *; };" >> $output_objdir/$libname.ver~
- $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
- fi
- link_all_deplibs=no
- else
- ld_shlibs=no
- fi
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
- wlarc=
- else
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- fi
- ;;
-
- solaris*)
- if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
- ld_shlibs=no
- cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-EOF
- elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs=no
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
- case `$LD -v 2>&1` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
- ld_shlibs=no
- cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
- ;;
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
- archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
- else
- ld_shlibs=no
- fi
- ;;
- esac
- ;;
-
- sunos4*)
- archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- wlarc=
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- ;;
-
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs=no
- fi
- ;;
- esac
-
- if test "$ld_shlibs" = no; then
- runpath_var=
- hardcode_libdir_flag_spec=
- export_dynamic_flag_spec=
- whole_archive_flag_spec=
- fi
- else
- # PORTME fill in a description of your system's linker (not GNU ld)
- case $host_os in
- aix3*)
- allow_undefined_flag=unsupported
- always_export_symbols=yes
- archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
- # Note: this linker hardcodes the directories in LIBPATH if there
- # are no directories specified by -L.
- hardcode_minus_L=yes
- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
- # Neither direct hardcoding nor static linking is supported with a
- # broken collect2.
- hardcode_direct=unsupported
- fi
- ;;
-
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- else
- export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- fi
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[23]|aix4.[23].*|aix5*)
- for ld_flag in $LDFLAGS; do
- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
- aix_use_runtimelinking=yes
- break
- fi
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- archive_cmds=''
- hardcode_direct=yes
- hardcode_libdir_separator=':'
- link_all_deplibs=yes
-
- if test "$GCC" = yes; then
- case $host_os in aix4.[012]|aix4.[012].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- hardcode_direct=yes
- else
- # We have old collect2
- hardcode_direct=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- hardcode_minus_L=yes
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_libdir_separator=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- always_export_symbols=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- allow_undefined_flag='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
- archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
- allow_undefined_flag="-z nodefs"
- archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- no_undefined_flag=' ${wl}-bernotok'
- allow_undefined_flag=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- whole_archive_flag_spec='$convenience'
- archive_cmds_need_lc=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- amigaos*)
- archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_minus_L=yes
- # see comment about different semantics on the GNU ld section
- ld_shlibs=no
- ;;
-
- bsdi[45]*)
- export_dynamic_flag_spec=-rdynamic
- ;;
-
- cygwin* | mingw* | pw32*)
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- # hardcode_libdir_flag_spec is actually meaningless, as there is
- # no search path for DLLs.
- hardcode_libdir_flag_spec=' '
- allow_undefined_flag=unsupported
- # Tell ltmain to make .lib files, not .a files.
- libext=lib
- # Tell ltmain to make .dll files, not .so files.
- shrext_cmds=".dll"
- # FIXME: Setting linknames here is a bad hack.
- archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
- # The linker will automatically build a .lib file if we build a DLL.
- old_archive_From_new_cmds='true'
- # FIXME: Should let the user specify the lib program.
- old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs'
- fix_srcfile_path='`cygpath -w "$srcfile"`'
- enable_shared_with_static_runtimes=yes
- ;;
-
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[012])
- allow_undefined_flag='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[012])
- allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- allow_undefined_flag='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- archive_cmds_need_lc=no
- hardcode_direct=no
- hardcode_automatic=yes
- hardcode_shlibpath_var=unsupported
- whole_archive_flag_spec=''
- link_all_deplibs=yes
- if test "$GCC" = yes ; then
- output_verbose_link_cmd='echo'
- archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- ld_shlibs=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_shlibpath_var=no
- ;;
-
- freebsd1*)
- ld_shlibs=no
- ;;
-
- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
- # support. Future versions do this automatically, but an explicit c++rt0.o
- # does not break anything, and helps significantly (at the cost of a little
- # extra space).
- freebsd2.2*)
- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- ;;
-
- # Unfortunately, older versions of FreeBSD 2 do not have this feature.
- freebsd2*)
- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct=yes
- hardcode_minus_L=yes
- hardcode_shlibpath_var=no
- ;;
-
- # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
- freebsd* | dragonfly*)
- archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- ;;
-
- # GNU/kFreeBSD uses gcc -shared to do shared libraries.
- kfreebsd*-gnu)
- archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- link_all_deplibs=no
- ;;
-
- hpux9*)
- if test "$GCC" = yes; then
- archive_cmds='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- fi
- hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator=:
- hardcode_direct=yes
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L=yes
- export_dynamic_flag_spec='${wl}-E'
- ;;
-
- hpux10*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator=:
-
- hardcode_direct=yes
- export_dynamic_flag_spec='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L=yes
- fi
- ;;
-
- hpux11*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- case $host_cpu in
- hppa*64*)
- archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- else
- case $host_cpu in
- hppa*64*)
- archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- hardcode_libdir_flag_spec_ld='+b $libdir'
- hardcode_direct=no
- hardcode_shlibpath_var=no
- ;;
- *)
- hardcode_direct=yes
- export_dynamic_flag_spec='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L=yes
- ;;
- esac
- fi
- ;;
-
- irix5* | irix6* | nonstopux*)
- if test "$GCC" = yes; then
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec_ld='-rpath $libdir'
- fi
- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator=:
- link_all_deplibs=yes
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
- else
- archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
- fi
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- ;;
-
- newsos6)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct=yes
- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator=:
- hardcode_shlibpath_var=no
- ;;
-
- openbsd*)
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
- hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
- export_dynamic_flag_spec='${wl}-E'
- else
- case $host_os in
- openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec='-R$libdir'
- ;;
- *)
- archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
- ;;
- esac
- fi
- ;;
-
- os2*)
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_minus_L=yes
- allow_undefined_flag=unsupported
- archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
- old_archive_From_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
- ;;
-
- osf3*)
- if test "$GCC" = yes; then
- allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- allow_undefined_flag=' -expect_unresolved \*'
- archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- fi
- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator=:
- ;;
-
- osf4* | osf5*) # as osf3* with the addition of -msym flag
- if test "$GCC" = yes; then
- allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
- else
- allow_undefined_flag=' -expect_unresolved \*'
- archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
-
- # Both c and cxx compiler support -rpath directly
- hardcode_libdir_flag_spec='-rpath $libdir'
- fi
- hardcode_libdir_separator=:
- ;;
-
- solaris*)
- no_undefined_flag=' -z text'
- if test "$GCC" = yes; then
- wlarc='${wl}'
- archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
- else
- wlarc=''
- archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
- archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
- fi
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_shlibpath_var=no
- case $host_os in
- solaris2.[0-5] | solaris2.[0-5].*) ;;
- *)
- # The compiler driver will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl, iff we do not link with $LD.
- # Luckily, gcc supports the same syntax we need for Sun Studio.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- case $wlarc in
- '')
- whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
- *)
- whole_archive_flag_spec='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- esac ;;
- esac
- link_all_deplibs=yes
- ;;
-
- sunos4*)
- if test "x$host_vendor" = xsequent; then
- # Use $CC to link under sequent, because it throws in some extra .o
- # files that make .init and .fini sections work.
- archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
- fi
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_direct=yes
- hardcode_minus_L=yes
- hardcode_shlibpath_var=no
- ;;
-
- sysv4)
- case $host_vendor in
- sni)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct=yes # is this really true???
- ;;
- siemens)
- ## LD is ld it makes a PLAMLIB
- ## CC just makes a GrossModule.
- archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
- reload_cmds='$CC -r -o $output$reload_objs'
- hardcode_direct=no
- ;;
- motorola)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct=no #Motorola manual says yes, but my tests say they lie
- ;;
- esac
- runpath_var='LD_RUN_PATH'
- hardcode_shlibpath_var=no
- ;;
-
- sysv4.3*)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var=no
- export_dynamic_flag_spec='-Bexport'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var=no
- runpath_var=LD_RUN_PATH
- hardcode_runpath_var=yes
- ld_shlibs=yes
- fi
- ;;
-
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
- no_undefined_flag='${wl}-z,text'
- archive_cmds_need_lc=no
- hardcode_shlibpath_var=no
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- no_undefined_flag='${wl}-z,text'
- allow_undefined_flag='${wl}-z,nodefs'
- archive_cmds_need_lc=no
- hardcode_shlibpath_var=no
- hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- hardcode_libdir_separator=':'
- link_all_deplibs=yes
- export_dynamic_flag_spec='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- uts4*)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_shlibpath_var=no
- ;;
-
- *)
- ld_shlibs=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $ld_shlibs" >&5
-echo "${ECHO_T}$ld_shlibs" >&6
-test "$ld_shlibs" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc" in
-x|xyes)
- # Assume -lc should be added
- archive_cmds_need_lc=yes
-
- if test "$enable_shared" = yes && test "$GCC" = yes; then
- case $archive_cmds in
- *'~'*)
- # FIXME: we may have to deal with multi-command sequences.
- ;;
- '$CC '*)
- # Test whether the compiler implicitly links with -lc since on some
- # systems, -lgcc has to come before -lc. If gcc already passes -lc
- # to ld, don't add -lc before -lgcc.
- echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
- $rm conftest*
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } 2>conftest.err; then
- soname=conftest
- lib=conftest
- libobjs=conftest.$ac_objext
- deplibs=
- wl=$lt_prog_compiler_wl
- pic_flag=$lt_prog_compiler_pic
- compiler_flags=-v
- linker_flags=-v
- verstring=
- output_objdir=.
- libname=conftest
- lt_save_allow_undefined_flag=$allow_undefined_flag
- allow_undefined_flag=
- if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
- (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
- then
- archive_cmds_need_lc=no
- else
- archive_cmds_need_lc=yes
- fi
- allow_undefined_flag=$lt_save_allow_undefined_flag
- else
- cat conftest.err 1>&5
- fi
- $rm conftest*
- echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5
-echo "${ECHO_T}$archive_cmds_need_lc" >&6
- ;;
- esac
- fi
- ;;
-esac
-
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
- # if the path contains ";" then we assume it to be the separator
- # otherwise default to the standard path separator (i.e. ":") - it is
- # assumed that no part of a normal pathname contains ";" but that should
- # okay in the real world where ";" in dirpaths is itself problematic.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
-else
- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
- shlibpath_var=LIBPATH
-
- # AIX 3 has no versioning support, so we append a major version to the name.
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
-
-aix4* | aix5*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- hardcode_into_libs=yes
- if test "$host_cpu" = ia64; then
- # AIX 5 supports IA64
- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- else
- # With GCC up to 2.95.x, collect2 would create an import file
- # for dependence libraries. The import file would start with
- # the line `#! .'. This would cause the generated library to
- # depend on `.', always an invalid library. This was fixed in
- # development snapshots of GCC prior to 3.0.
- case $host_os in
- aix4 | aix4.[01] | aix4.[01].*)
- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
- echo ' yes '
- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
- :
- else
- can_build_shared=no
- fi
- ;;
- esac
- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
- # soname into executable. Probably we can add versioning support to
- # collect2, so additional links can be useful in future.
- if test "$aix_use_runtimelinking" = yes; then
- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
- # instead of lib<name>.a to let people know that these are not
- # typical AIX shared libraries.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- else
- # We preserve .a as extension for shared libraries through AIX4.2
- # and later when we are not doing run time linking.
- library_names_spec='${libname}${release}.a $libname.a'
- soname_spec='${libname}${release}${shared_ext}$major'
- fi
- shlibpath_var=LIBPATH
- fi
- ;;
-
-amigaos*)
- library_names_spec='$libname.ixlibrary $libname.a'
- # Create ${libname}_ixlibrary.a entries in /sys/libs.
- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
- ;;
-
-beos*)
- library_names_spec='${libname}${shared_ext}'
- dynamic_linker="$host_os ld.so"
- shlibpath_var=LIBRARY_PATH
- ;;
-
-bsdi[45]*)
- version_type=linux
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
- # the default ld.so.conf also contains /usr/contrib/lib and
- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
- # libtool to hard-code these into programs
- ;;
-
-cygwin* | mingw* | pw32*)
- version_type=windows
- shrext_cmds=".dll"
- need_version=no
- need_lib_prefix=no
-
- case $GCC,$host_os in
- yes,cygwin* | yes,mingw* | yes,pw32*)
- library_names_spec='$libname.dll.a'
- # DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
- dldir=$destdir/`dirname \$dlpath`~
- test -d \$dldir || mkdir -p \$dldir~
- $install_prog $dir/$dlname \$dldir/$dlname~
- chmod a+x \$dldir/$dlname'
- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
- dlpath=$dir/\$dldll~
- $rm \$dlpath'
- shlibpath_overrides_runpath=yes
-
- case $host_os in
- cygwin*)
- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
- ;;
- mingw*)
- # MinGW DLLs use traditional 'lib' prefix
- soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
- # It is most probably a Windows format PATH printed by
- # mingw gcc, but we are running on Cygwin. Gcc prints its search
- # path with ; separators, and with drive letters. We can handle the
- # drive letters (cygwin fileutils understands them), so leave them,
- # especially as we might pass files found there to a mingw objdump,
- # which wouldn't understand a cygwinified path. Ahh.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
- ;;
- pw32*)
- # pw32 DLLs use 'pw' prefix rather than 'lib'
- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- ;;
- esac
- ;;
-
- *)
- library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
- ;;
- esac
- dynamic_linker='Win32 ld.exe'
- # FIXME: first we should search . and the directory the executable is in
- shlibpath_var=PATH
- ;;
-
-darwin* | rhapsody*)
- dynamic_linker="$host_os dyld"
- version_type=darwin
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
- soname_spec='${libname}${release}${major}$shared_ext'
- shlibpath_overrides_runpath=yes
- shlibpath_var=DYLD_LIBRARY_PATH
- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
- if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
- else
- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
- fi
- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
- ;;
-
-dgux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-freebsd1*)
- dynamic_linker=no
- ;;
-
-kfreebsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-freebsd* | dragonfly*)
- # DragonFly does not have aout. When/if they implement a new
- # versioning mechanism, adjust this.
- if test -x /usr/bin/objformat; then
- objformat=`/usr/bin/objformat`
- else
- case $host_os in
- freebsd[123]*) objformat=aout ;;
- *) objformat=elf ;;
- esac
- fi
- version_type=freebsd-$objformat
- case $version_type in
- freebsd-elf*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- need_version=no
- need_lib_prefix=no
- ;;
- freebsd-*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
- need_version=yes
- ;;
- esac
- shlibpath_var=LD_LIBRARY_PATH
- case $host_os in
- freebsd2*)
- shlibpath_overrides_runpath=yes
- ;;
- freebsd3.[01]* | freebsdelf3.[01]*)
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
- freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
- freebsd*) # from 4.6 on
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- esac
- ;;
-
-gnu*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- ;;
-
-hpux9* | hpux10* | hpux11*)
- # Give a soname corresponding to the major version so that dld.sl refuses to
- # link against other versions.
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- case $host_cpu in
- ia64*)
- shrext_cmds='.so'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.so"
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- if test "X$HPUX_IA64_MODE" = X32; then
- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
- else
- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
- fi
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- hppa*64*)
- shrext_cmds='.sl'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- *)
- shrext_cmds='.sl'
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=SHLIB_PATH
- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
- esac
- # HP-UX runs *really* slowly unless shared libraries are mode 555.
- postinstall_cmds='chmod 555 $lib'
- ;;
-
-interix3*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $host_os in
- nonstopux*) version_type=nonstopux ;;
- *)
- if test "$lt_cv_prog_gnu_ld" = yes; then
- version_type=linux
- else
- version_type=irix
- fi ;;
- esac
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
- case $host_os in
- irix5* | nonstopux*)
- libsuff= shlibsuff=
- ;;
- *)
- case $LD in # libtool.m4 will add one of these switches to LD
- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
- libsuff= shlibsuff= libmagic=32-bit;;
- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
- libsuff=32 shlibsuff=N32 libmagic=N32;;
- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
- libsuff=64 shlibsuff=64 libmagic=64-bit;;
- *) libsuff= shlibsuff= libmagic=never-match;;
- esac
- ;;
- esac
- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
- hardcode_into_libs=yes
- ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
- dynamic_linker=no
- ;;
-
-# This must be Linux ELF.
-linux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- # This implies no fast_install, which is unacceptable.
- # Some rework will be needed to allow for fast_install
- # before this can be enabled.
- hardcode_into_libs=yes
-
- # Append ld.so.conf contents to the search path
- if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
- fi
-
- # We used to test for /lib/ld.so.1 and disable shared libraries on
- # powerpc, because MkLinux only supported shared libraries with the
- # GNU dynamic linker. Since this was broken with cross compilers,
- # most powerpc-linux boxes support dynamic linking these days and
- # people can always --disable-shared, the test was removed, and we
- # assume the GNU/Linux dynamic linker is in use.
- dynamic_linker='GNU/Linux ld.so'
- ;;
-
-netbsdelf*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='NetBSD ld.elf_so'
- ;;
-
-knetbsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-netbsd*)
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- dynamic_linker='NetBSD (a.out) ld.so'
- else
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='NetBSD ld.elf_so'
- fi
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
-
-newsos6)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-nto-qnx*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-openbsd*)
- version_type=sunos
- sys_lib_dlsearch_path_spec="/usr/lib"
- need_lib_prefix=no
- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
- case $host_os in
- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
- *) need_version=no ;;
- esac
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- case $host_os in
- openbsd2.[89] | openbsd2.[89].*)
- shlibpath_overrides_runpath=no
- ;;
- *)
- shlibpath_overrides_runpath=yes
- ;;
- esac
- else
- shlibpath_overrides_runpath=yes
- fi
- ;;
-
-os2*)
- libname_spec='$name'
- shrext_cmds=".dll"
- need_lib_prefix=no
- library_names_spec='$libname${shared_ext} $libname.a'
- dynamic_linker='OS/2 ld.exe'
- shlibpath_var=LIBPATH
- ;;
-
-osf3* | osf4* | osf5*)
- version_type=osf
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
- ;;
-
-solaris*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- # ldd complains unless libraries are executable
- postinstall_cmds='chmod +x $lib'
- ;;
-
-sunos4*)
- version_type=sunos
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- if test "$with_gnu_ld" = yes; then
- need_lib_prefix=no
- fi
- need_version=yes
- ;;
-
-sysv4 | sysv4.3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- case $host_vendor in
- sni)
- shlibpath_overrides_runpath=no
- need_lib_prefix=no
- export_dynamic_flag_spec='${wl}-Blargedynsym'
- runpath_var=LD_RUN_PATH
- ;;
- siemens)
- need_lib_prefix=no
- ;;
- motorola)
- need_lib_prefix=no
- need_version=no
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
- ;;
- esac
- ;;
-
-sysv4*MP*)
- if test -d /usr/nec ;then
- version_type=linux
- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
- soname_spec='$libname${shared_ext}.$major'
- shlibpath_var=LD_LIBRARY_PATH
- fi
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- version_type=freebsd-elf
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- if test "$with_gnu_ld" = yes; then
- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
- shlibpath_overrides_runpath=no
- else
- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
- shlibpath_overrides_runpath=yes
- case $host_os in
- sco3.2v5*)
- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
- ;;
- esac
- fi
- sys_lib_dlsearch_path_spec='/usr/lib'
- ;;
-
-uts4*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-*)
- dynamic_linker=no
- ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action=
-if test -n "$hardcode_libdir_flag_spec" || \
- test -n "$runpath_var" || \
- test "X$hardcode_automatic" = "Xyes" ; then
-
- # We can hardcode non-existant directories.
- if test "$hardcode_direct" != no &&
- # If the only mechanism to avoid hardcoding is shlibpath_var, we
- # have to relink, otherwise we might link with an installed library
- # when we should be linking with a yet-to-be-installed one
- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, )" != no &&
- test "$hardcode_minus_L" != no; then
- # Linking always hardcodes the temporary library directory.
- hardcode_action=relink
- else
- # We can link without hardcoding, and we can hardcode nonexisting dirs.
- hardcode_action=immediate
- fi
-else
- # We cannot hardcode anything, or else we can only hardcode existing
- # directories.
- hardcode_action=unsupported
-fi
-echo "$as_me:$LINENO: result: $hardcode_action" >&5
-echo "${ECHO_T}$hardcode_action" >&6
-
-if test "$hardcode_action" = relink; then
- # Fast installation is not supported
- enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
- test "$enable_shared" = no; then
- # Fast installation is not necessary
- enable_fast_install=needless
-fi
-
-striplib=
-old_striplib=
-echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
-echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6
-if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
- test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
- test -z "$striplib" && striplib="$STRIP --strip-unneeded"
- echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-else
-# FIXME - insert some real tests, host_os isn't really good enough
- case $host_os in
- darwin*)
- if test -n "$STRIP" ; then
- striplib="$STRIP -x"
- echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
- else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
- ;;
- *)
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
- ;;
- esac
-fi
-
-if test "x$enable_dlopen" != xyes; then
- enable_dlopen=unknown
- enable_dlopen_self=unknown
- enable_dlopen_self_static=unknown
-else
- lt_cv_dlopen=no
- lt_cv_dlopen_libs=
-
- case $host_os in
- beos*)
- lt_cv_dlopen="load_add_on"
- lt_cv_dlopen_libs=
- lt_cv_dlopen_self=yes
- ;;
-
- mingw* | pw32*)
- lt_cv_dlopen="LoadLibrary"
- lt_cv_dlopen_libs=
- ;;
-
- cygwin*)
- lt_cv_dlopen="dlopen"
- lt_cv_dlopen_libs=
- ;;
-
- darwin*)
- # if libdl is installed we need to link against it
- echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
-echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
-if test "${ac_cv_lib_dl_dlopen+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldl $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char dlopen ();
-int
-main ()
-{
-dlopen ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_dl_dlopen=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_dl_dlopen=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
-echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
-if test $ac_cv_lib_dl_dlopen = yes; then
- lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
-else
-
- lt_cv_dlopen="dyld"
- lt_cv_dlopen_libs=
- lt_cv_dlopen_self=yes
-
-fi
-
- ;;
-
- *)
- echo "$as_me:$LINENO: checking for shl_load" >&5
-echo $ECHO_N "checking for shl_load... $ECHO_C" >&6
-if test "${ac_cv_func_shl_load+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-/* Define shl_load to an innocuous variant, in case <limits.h> declares shl_load.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define shl_load innocuous_shl_load
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char shl_load (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef shl_load
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char shl_load ();
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_shl_load) || defined (__stub___shl_load)
-choke me
-#else
-char (*f) () = shl_load;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != shl_load;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_func_shl_load=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_func_shl_load=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5
-echo "${ECHO_T}$ac_cv_func_shl_load" >&6
-if test $ac_cv_func_shl_load = yes; then
- lt_cv_dlopen="shl_load"
-else
- echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5
-echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6
-if test "${ac_cv_lib_dld_shl_load+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldld $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char shl_load ();
-int
-main ()
-{
-shl_load ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_dld_shl_load=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_dld_shl_load=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5
-echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6
-if test $ac_cv_lib_dld_shl_load = yes; then
- lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
-else
- echo "$as_me:$LINENO: checking for dlopen" >&5
-echo $ECHO_N "checking for dlopen... $ECHO_C" >&6
-if test "${ac_cv_func_dlopen+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-/* Define dlopen to an innocuous variant, in case <limits.h> declares dlopen.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define dlopen innocuous_dlopen
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char dlopen (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef dlopen
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char dlopen ();
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_dlopen) || defined (__stub___dlopen)
-choke me
-#else
-char (*f) () = dlopen;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != dlopen;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_func_dlopen=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_func_dlopen=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5
-echo "${ECHO_T}$ac_cv_func_dlopen" >&6
-if test $ac_cv_func_dlopen = yes; then
- lt_cv_dlopen="dlopen"
-else
- echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
-echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
-if test "${ac_cv_lib_dl_dlopen+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldl $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char dlopen ();
-int
-main ()
-{
-dlopen ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_dl_dlopen=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_dl_dlopen=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
-echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
-if test $ac_cv_lib_dl_dlopen = yes; then
- lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
-else
- echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5
-echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6
-if test "${ac_cv_lib_svld_dlopen+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsvld $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char dlopen ();
-int
-main ()
-{
-dlopen ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_svld_dlopen=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_svld_dlopen=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5
-echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6
-if test $ac_cv_lib_svld_dlopen = yes; then
- lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
-else
- echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5
-echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6
-if test "${ac_cv_lib_dld_dld_link+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldld $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char dld_link ();
-int
-main ()
-{
-dld_link ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_dld_dld_link=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_dld_dld_link=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5
-echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6
-if test $ac_cv_lib_dld_dld_link = yes; then
- lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
-fi
-
-
-fi
-
-
-fi
-
-
-fi
-
-
-fi
-
-
-fi
-
- ;;
- esac
-
- if test "x$lt_cv_dlopen" != xno; then
- enable_dlopen=yes
- else
- enable_dlopen=no
- fi
-
- case $lt_cv_dlopen in
- dlopen)
- save_CPPFLAGS="$CPPFLAGS"
- test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
-
- save_LDFLAGS="$LDFLAGS"
- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
-
- save_LIBS="$LIBS"
- LIBS="$lt_cv_dlopen_libs $LIBS"
-
- echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5
-echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6
-if test "${lt_cv_dlopen_self+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "$cross_compiling" = yes; then :
- lt_cv_dlopen_self=cross
-else
- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
- lt_status=$lt_dlunknown
- cat > conftest.$ac_ext <<EOF
-#line 9807 "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-# define LT_DLGLOBAL RTLD_GLOBAL
-#else
-# ifdef DL_GLOBAL
-# define LT_DLGLOBAL DL_GLOBAL
-# else
-# define LT_DLGLOBAL 0
-# endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
- find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-# ifdef RTLD_LAZY
-# define LT_DLLAZY_OR_NOW RTLD_LAZY
-# else
-# ifdef DL_LAZY
-# define LT_DLLAZY_OR_NOW DL_LAZY
-# else
-# ifdef RTLD_NOW
-# define LT_DLLAZY_OR_NOW RTLD_NOW
-# else
-# ifdef DL_NOW
-# define LT_DLLAZY_OR_NOW DL_NOW
-# else
-# define LT_DLLAZY_OR_NOW 0
-# endif
-# endif
-# endif
-# endif
-#endif
-
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-
-void fnord() { int i=42;}
-int main ()
-{
- void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
- int status = $lt_dlunknown;
-
- if (self)
- {
- if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
- else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
- /* dlclose (self); */
- }
- else
- puts (dlerror ());
-
- exit (status);
-}
-EOF
- if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
- (./conftest; exit; ) >&5 2>/dev/null
- lt_status=$?
- case x$lt_status in
- x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
- x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
- x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
- esac
- else :
- # compilation failed
- lt_cv_dlopen_self=no
- fi
-fi
-rm -fr conftest*
-
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5
-echo "${ECHO_T}$lt_cv_dlopen_self" >&6
-
- if test "x$lt_cv_dlopen_self" = xyes; then
- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
- echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5
-echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6
-if test "${lt_cv_dlopen_self_static+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "$cross_compiling" = yes; then :
- lt_cv_dlopen_self_static=cross
-else
- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
- lt_status=$lt_dlunknown
- cat > conftest.$ac_ext <<EOF
-#line 9907 "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-# define LT_DLGLOBAL RTLD_GLOBAL
-#else
-# ifdef DL_GLOBAL
-# define LT_DLGLOBAL DL_GLOBAL
-# else
-# define LT_DLGLOBAL 0
-# endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
- find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-# ifdef RTLD_LAZY
-# define LT_DLLAZY_OR_NOW RTLD_LAZY
-# else
-# ifdef DL_LAZY
-# define LT_DLLAZY_OR_NOW DL_LAZY
-# else
-# ifdef RTLD_NOW
-# define LT_DLLAZY_OR_NOW RTLD_NOW
-# else
-# ifdef DL_NOW
-# define LT_DLLAZY_OR_NOW DL_NOW
-# else
-# define LT_DLLAZY_OR_NOW 0
-# endif
-# endif
-# endif
-# endif
-#endif
-
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-
-void fnord() { int i=42;}
-int main ()
-{
- void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
- int status = $lt_dlunknown;
-
- if (self)
- {
- if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
- else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
- /* dlclose (self); */
- }
- else
- puts (dlerror ());
-
- exit (status);
-}
-EOF
- if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
- (./conftest; exit; ) >&5 2>/dev/null
- lt_status=$?
- case x$lt_status in
- x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
- x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
- x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
- esac
- else :
- # compilation failed
- lt_cv_dlopen_self_static=no
- fi
-fi
-rm -fr conftest*
-
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5
-echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6
- fi
-
- CPPFLAGS="$save_CPPFLAGS"
- LDFLAGS="$save_LDFLAGS"
- LIBS="$save_LIBS"
- ;;
- esac
-
- case $lt_cv_dlopen_self in
- yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
- *) enable_dlopen_self=unknown ;;
- esac
-
- case $lt_cv_dlopen_self_static in
- yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
- *) enable_dlopen_self_static=unknown ;;
- esac
-fi
-
-
-# Report which library types will actually be built
-echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
-echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: $can_build_shared" >&5
-echo "${ECHO_T}$can_build_shared" >&6
-
-echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
-echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6
-test "$can_build_shared" = "no" && enable_shared=no
-
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
-case $host_os in
-aix3*)
- test "$enable_shared" = yes && enable_static=no
- if test -n "$RANLIB"; then
- archive_cmds="$archive_cmds~\$RANLIB \$lib"
- postinstall_cmds='$RANLIB $lib'
- fi
- ;;
-
-aix4* | aix5*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
- fi
- ;;
-esac
-echo "$as_me:$LINENO: result: $enable_shared" >&5
-echo "${ECHO_T}$enable_shared" >&6
-
-echo "$as_me:$LINENO: checking whether to build static libraries" >&5
-echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-echo "$as_me:$LINENO: result: $enable_static" >&5
-echo "${ECHO_T}$enable_static" >&6
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- compiler \
- CC \
- LD \
- lt_prog_compiler_wl \
- lt_prog_compiler_pic \
- lt_prog_compiler_static \
- lt_prog_compiler_no_builtin_flag \
- export_dynamic_flag_spec \
- thread_safe_flag_spec \
- whole_archive_flag_spec \
- enable_shared_with_static_runtimes \
- old_archive_cmds \
- old_archive_from_new_cmds \
- predep_objects \
- postdep_objects \
- predeps \
- postdeps \
- compiler_lib_search_path \
- archive_cmds \
- archive_expsym_cmds \
- postinstall_cmds \
- postuninstall_cmds \
- old_archive_from_expsyms_cmds \
- allow_undefined_flag \
- no_undefined_flag \
- export_symbols_cmds \
- hardcode_libdir_flag_spec \
- hardcode_libdir_flag_spec_ld \
- hardcode_libdir_separator \
- hardcode_automatic \
- module_cmds \
- module_expsym_cmds \
- lt_cv_prog_compiler_c_o \
- exclude_expsyms \
- include_expsyms; do
-
- case $var in
- old_archive_cmds | \
- old_archive_from_new_cmds | \
- archive_cmds | \
- archive_expsym_cmds | \
- module_cmds | \
- module_expsym_cmds | \
- old_archive_from_expsyms_cmds | \
- export_symbols_cmds | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\$0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
- ;;
- esac
-
-cfgfile="${ofile}T"
- trap "$rm \"$cfgfile\"; exit 1" 1 2 15
- $rm -f "$cfgfile"
- { echo "$as_me:$LINENO: creating $ofile" >&5
-echo "$as_me: creating $ofile" >&6;}
-
- cat <<__EOF__ >> "$cfgfile"
-#! $SHELL
-
-# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
-# NOTE: Changes made to this file will be lost: look at ltmain.sh.
-#
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
-# Free Software Foundation, Inc.
-#
-# This file is part of GNU Libtool:
-# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
-#
-# 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/>.
-#
-# 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.
-
-# A sed program that does not truncate output.
-SED=$lt_SED
-
-# Sed that helps us avoid accidentally triggering echo(1) options like -n.
-Xsed="$SED -e 1s/^X//"
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-# The names of the tagged configurations supported by this script.
-available_tags=
-
-# ### BEGIN LIBTOOL CONFIG
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds
-archive_expsym_cmds=$lt_archive_expsym_cmds
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds
-module_expsym_cmds=$lt_module_expsym_cmds
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_predep_objects
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_postdep_objects
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms
-
-# ### END LIBTOOL CONFIG
-
-__EOF__
-
-
- case $host_os in
- aix3*)
- cat <<\EOF >> "$cfgfile"
-
-# AIX sometimes has problems with the GCC collect2 program. For some
-# reason, if we set the COLLECT_NAMES environment variable, the problems
-# vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
- COLLECT_NAMES=
- export COLLECT_NAMES
-fi
-EOF
- ;;
- esac
-
- # We use sed instead of cat because bash on DJGPP gets confused if
- # if finds mixed CR/LF and LF-only lines. Since sed operates in
- # text mode, it properly converts lines to CR/LF. This bash problem
- # is reportedly fixed, but why not run on old versions too?
- sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
-
- mv -f "$cfgfile" "$ofile" || \
- (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
- chmod +x "$ofile"
-
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
-
-# Check whether --with-tags or --without-tags was given.
-if test "${with_tags+set}" = set; then
- withval="$with_tags"
- tagnames="$withval"
-fi;
-
-if test -f "$ltmain" && test -n "$tagnames"; then
- if test ! -f "${ofile}"; then
- { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not exist" >&5
-echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;}
- fi
-
- if test -z "$LTCC"; then
- eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
- if test -z "$LTCC"; then
- { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not look like a libtool script" >&5
-echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;}
- else
- { echo "$as_me:$LINENO: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5
-echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;}
- fi
- fi
- if test -z "$LTCFLAGS"; then
- eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
- fi
-
- # Extract list of available tagged configurations in $ofile.
- # Note that this assumes the entire list is on one line.
- available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
-
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for tagname in $tagnames; do
- IFS="$lt_save_ifs"
- # Check whether tagname contains only valid characters
- case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in
- "") ;;
- *) { { echo "$as_me:$LINENO: error: invalid tag name: $tagname" >&5
-echo "$as_me: error: invalid tag name: $tagname" >&2;}
- { (exit 1); exit 1; }; }
- ;;
- esac
-
- if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
- then
- { { echo "$as_me:$LINENO: error: tag name \"$tagname\" already exists" >&5
-echo "$as_me: error: tag name \"$tagname\" already exists" >&2;}
- { (exit 1); exit 1; }; }
- fi
-
- # Update the list of available tags.
- if test -n "$tagname"; then
- echo appending configuration tag \"$tagname\" to $ofile
-
- case $tagname in
- CXX)
- if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
- (test "X$CXX" != "Xg++"))) ; then
- ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-
-
-
-archive_cmds_need_lc_CXX=no
-allow_undefined_flag_CXX=
-always_export_symbols_CXX=no
-archive_expsym_cmds_CXX=
-export_dynamic_flag_spec_CXX=
-hardcode_direct_CXX=no
-hardcode_libdir_flag_spec_CXX=
-hardcode_libdir_flag_spec_ld_CXX=
-hardcode_libdir_separator_CXX=
-hardcode_minus_L_CXX=no
-hardcode_shlibpath_var_CXX=unsupported
-hardcode_automatic_CXX=no
-module_cmds_CXX=
-module_expsym_cmds_CXX=
-link_all_deplibs_CXX=unknown
-old_archive_cmds_CXX=$old_archive_cmds
-no_undefined_flag_CXX=
-whole_archive_flag_spec_CXX=
-enable_shared_with_static_runtimes_CXX=no
-
-# Dependencies to place before and after the object being linked:
-predep_objects_CXX=
-postdep_objects_CXX=
-predeps_CXX=
-postdeps_CXX=
-compiler_lib_search_path_CXX=
-
-# Source file extension for C++ test sources.
-ac_ext=cpp
-
-# Object file extension for compiled C++ test sources.
-objext=o
-objext_CXX=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-# Allow CC to be a program name with arguments.
-lt_save_CC=$CC
-lt_save_LD=$LD
-lt_save_GCC=$GCC
-GCC=$GXX
-lt_save_with_gnu_ld=$with_gnu_ld
-lt_save_path_LD=$lt_cv_path_LD
-if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
- lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
-else
- $as_unset lt_cv_prog_gnu_ld
-fi
-if test -n "${lt_cv_path_LDCXX+set}"; then
- lt_cv_path_LD=$lt_cv_path_LDCXX
-else
- $as_unset lt_cv_path_LD
-fi
-test -z "${LDCXX+set}" || LD=$LDCXX
-CC=${CXX-"c++"}
-compiler=$CC
-compiler_CXX=$CC
-for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
-# We don't want -fno-exception wen compiling C++ code, so set the
-# no_builtin_flag separately
-if test "$GXX" = yes; then
- lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
-else
- lt_prog_compiler_no_builtin_flag_CXX=
-fi
-
-if test "$GXX" = yes; then
- # Set up default GNU C++ configuration
-
-
-# Check whether --with-gnu-ld or --without-gnu-ld was given.
-if test "${with_gnu_ld+set}" = set; then
- withval="$with_gnu_ld"
- test "$withval" = no || with_gnu_ld=yes
-else
- with_gnu_ld=no
-fi;
-ac_prog=ld
-if test "$GCC" = yes; then
- # Check if gcc -print-prog-name=ld gives a path.
- echo "$as_me:$LINENO: checking for ld used by $CC" >&5
-echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6
- case $host in
- *-*-mingw*)
- # gcc leaves a trailing carriage return which upsets mingw
- ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
- *)
- ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
- esac
- case $ac_prog in
- # Accept absolute paths.
- [\\/]* | ?:[\\/]*)
- re_direlt='/[^/][^/]*/\.\./'
- # Canonicalize the pathname of ld
- ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
- ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
- done
- test -z "$LD" && LD="$ac_prog"
- ;;
- "")
- # If it fails, then pretend we aren't using GCC.
- ac_prog=ld
- ;;
- *)
- # If it is relative, then search for the first ld in PATH.
- with_gnu_ld=unknown
- ;;
- esac
-elif test "$with_gnu_ld" = yes; then
- echo "$as_me:$LINENO: checking for GNU ld" >&5
-echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6
-else
- echo "$as_me:$LINENO: checking for non-GNU ld" >&5
-echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6
-fi
-if test "${lt_cv_path_LD+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -z "$LD"; then
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for ac_dir in $PATH; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
- lt_cv_path_LD="$ac_dir/$ac_prog"
- # Check to see if the program is GNU ld. I'd rather use --version,
- # but apparently some variants of GNU ld only accept -v.
- # Break only if it was the GNU/non-GNU ld that we prefer.
- case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
- *GNU* | *'with BFD'*)
- test "$with_gnu_ld" != no && break
- ;;
- *)
- test "$with_gnu_ld" != yes && break
- ;;
- esac
- fi
- done
- IFS="$lt_save_ifs"
-else
- lt_cv_path_LD="$LD" # Let the user override the test with a path.
-fi
-fi
-
-LD="$lt_cv_path_LD"
-if test -n "$LD"; then
- echo "$as_me:$LINENO: result: $LD" >&5
-echo "${ECHO_T}$LD" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
-echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
- { (exit 1); exit 1; }; }
-echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
-echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
-if test "${lt_cv_prog_gnu_ld+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # I'd rather use --version here, but apparently some GNU lds only accept -v.
-case `$LD -v 2>&1 </dev/null` in
-*GNU* | *'with BFD'*)
- lt_cv_prog_gnu_ld=yes
- ;;
-*)
- lt_cv_prog_gnu_ld=no
- ;;
-esac
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
-echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6
-with_gnu_ld=$lt_cv_prog_gnu_ld
-
-
-
- # Check if GNU C++ uses GNU ld as the underlying linker, since the
- # archiving commands below assume that GNU ld is being used.
- if test "$with_gnu_ld" = yes; then
- archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
- export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-
- # If archive_cmds runs LD, not CC, wlarc should be empty
- # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
- # investigate it a little bit more. (MM)
- wlarc='${wl}'
-
- # ancient GNU ld didn't support --whole-archive et. al.
- if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
- grep 'no-whole-archive' > /dev/null; then
- whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- whole_archive_flag_spec_CXX=
- fi
- else
- with_gnu_ld=no
- wlarc=
-
- # A generic and very simple default shared library creation
- # command for GNU C++ for the case where it uses the native
- # linker, instead of GNU ld. If possible, this setting should
- # overridden to take advantage of the native linker features on
- # the platform it is being used on.
- archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
- fi
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
-else
- GXX=no
- with_gnu_ld=no
- wlarc=
-fi
-
-# PORTME: fill in a description of your system's C++ link characteristics
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-ld_shlibs_CXX=yes
-case $host_os in
- aix3*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[23]|aix4.[23].*|aix5*)
- for ld_flag in $LDFLAGS; do
- case $ld_flag in
- *-brtl*)
- aix_use_runtimelinking=yes
- break
- ;;
- esac
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- archive_cmds_CXX=''
- hardcode_direct_CXX=yes
- hardcode_libdir_separator_CXX=':'
- link_all_deplibs_CXX=yes
-
- if test "$GXX" = yes; then
- case $host_os in aix4.[012]|aix4.[012].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- hardcode_direct_CXX=yes
- else
- # We have old collect2
- hardcode_direct_CXX=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- hardcode_minus_L_CXX=yes
- hardcode_libdir_flag_spec_CXX='-L$libdir'
- hardcode_libdir_separator_CXX=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- always_export_symbols_CXX=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- allow_undefined_flag_CXX='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
-
- archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
- allow_undefined_flag_CXX="-z nodefs"
- archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- no_undefined_flag_CXX=' ${wl}-bernotok'
- allow_undefined_flag_CXX=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- whole_archive_flag_spec_CXX='$convenience'
- archive_cmds_need_lc_CXX=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- allow_undefined_flag_CXX=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- ld_shlibs_CXX=no
- fi
- ;;
-
- chorus*)
- case $cc_basename in
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- esac
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
- # as there is no search path for DLLs.
- hardcode_libdir_flag_spec_CXX='-L$libdir'
- allow_undefined_flag_CXX=unsupported
- always_export_symbols_CXX=no
- enable_shared_with_static_runtimes_CXX=yes
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- ld_shlibs_CXX=no
- fi
- ;;
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[012])
- allow_undefined_flag_CXX='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[012])
- allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- allow_undefined_flag_CXX='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- archive_cmds_need_lc_CXX=no
- hardcode_direct_CXX=no
- hardcode_automatic_CXX=yes
- hardcode_shlibpath_var_CXX=unsupported
- whole_archive_flag_spec_CXX=''
- link_all_deplibs_CXX=yes
-
- if test "$GXX" = yes ; then
- lt_int_apple_cc_single_mod=no
- output_verbose_link_cmd='echo'
- if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
- lt_int_apple_cc_single_mod=yes
- fi
- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
- archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- else
- archive_cmds_CXX='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- fi
- module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
- archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- fi
- module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- ld_shlibs_CXX=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- case $cc_basename in
- ec++*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- ghcx*)
- # Green Hills C++ Compiler
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- esac
- ;;
- freebsd[12]*)
- # C++ shared libraries reported to be fairly broken before switch to ELF
- ld_shlibs_CXX=no
- ;;
- freebsd-elf*)
- archive_cmds_need_lc_CXX=no
- ;;
- freebsd* | kfreebsd*-gnu | dragonfly*)
- # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
- # conventions
- ld_shlibs_CXX=yes
- ;;
- gnu*)
- ;;
- hpux9*)
- hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
- export_dynamic_flag_spec_CXX='${wl}-E'
- hardcode_direct_CXX=yes
- hardcode_minus_L_CXX=yes # Not in the search PATH,
- # but as the default
- # location of the library.
-
- case $cc_basename in
- CC*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- aCC*)
- archive_cmds_CXX='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes; then
- archive_cmds_CXX='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- fi
- ;;
- esac
- ;;
- hpux10*|hpux11*)
- if test $with_gnu_ld = no; then
- hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- hardcode_libdir_flag_spec_ld_CXX='+b $libdir'
- ;;
- *)
- export_dynamic_flag_spec_CXX='${wl}-E'
- ;;
- esac
- fi
- case $host_cpu in
- hppa*64*|ia64*)
- hardcode_direct_CXX=no
- hardcode_shlibpath_var_CXX=no
- ;;
- *)
- hardcode_direct_CXX=yes
- hardcode_minus_L_CXX=yes # Not in the search PATH,
- # but as the default
- # location of the library.
- ;;
- esac
-
- case $cc_basename in
- CC*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- aCC*)
- case $host_cpu in
- hppa*64*)
- archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- ia64*)
- archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- *)
- archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- esac
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes; then
- if test $with_gnu_ld = no; then
- case $host_cpu in
- hppa*64*)
- archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- ia64*)
- archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- *)
- archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- esac
- fi
- else
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- fi
- ;;
- esac
- ;;
- interix3*)
- hardcode_direct_CXX=no
- hardcode_shlibpath_var_CXX=no
- hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_CXX='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
- irix5* | irix6*)
- case $cc_basename in
- CC*)
- # SGI C++
- archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-
- # Archives containing C++ object files must be created using
- # "CC -ar", where "CC" is the IRIX C++ compiler. This is
- # necessary to make sure instantiated templates are included
- # in the archive.
- old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
- ;;
- *)
- if test "$GXX" = yes; then
- if test "$with_gnu_ld" = no; then
- archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
- fi
- fi
- link_all_deplibs_CXX=yes
- ;;
- esac
- hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
- ;;
- linux*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
- archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-
- hardcode_libdir_flag_spec_CXX='${wl}--rpath,$libdir'
- export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-
- # Archives containing C++ object files must be created using
- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
- old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
- ;;
- icpc*)
- # Intel C++
- with_gnu_ld=yes
- # version 8.0 and above of icpc choke on multiply defined symbols
- # if we add $predep_objects and $postdep_objects, however 7.1 and
- # earlier do not add the objects themselves.
- case `$CC -V 2>&1` in
- *"Version 7."*)
- archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- ;;
- *) # Version 8.0 or newer
- tmp_idyn=
- case $host_cpu in
- ia64*) tmp_idyn=' -i_dynamic';;
- esac
- archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- ;;
- esac
- archive_cmds_need_lc_CXX=no
- hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
- whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
- ;;
- pgCC*)
- # Portland Group C++ compiler
- archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
- archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
- export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
- whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- ;;
- cxx*)
- # Compaq C++
- archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
-
- runpath_var=LD_RUN_PATH
- hardcode_libdir_flag_spec_CXX='-rpath $libdir'
- hardcode_libdir_separator_CXX=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- esac
- ;;
- lynxos*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- m88k*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- mvs*)
- case $cc_basename in
- cxx*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- esac
- ;;
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
- wlarc=
- hardcode_libdir_flag_spec_CXX='-R$libdir'
- hardcode_direct_CXX=yes
- hardcode_shlibpath_var_CXX=no
- fi
- # Workaround some broken pre-1.5 toolchains
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
- ;;
- openbsd2*)
- # C++ shared libraries are fairly broken
- ld_shlibs_CXX=no
- ;;
- openbsd*)
- hardcode_direct_CXX=yes
- hardcode_shlibpath_var_CXX=no
- archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
- hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
- export_dynamic_flag_spec_CXX='${wl}-E'
- whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- fi
- output_verbose_link_cmd='echo'
- ;;
- osf3*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
- hardcode_libdir_separator_CXX=:
-
- # Archives containing C++ object files must be created using
- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
- old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
-
- ;;
- RCC*)
- # Rational C++ 2.4.1
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- cxx*)
- allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
- else
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- fi
- ;;
- esac
- ;;
- osf4* | osf5*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
- hardcode_libdir_separator_CXX=:
-
- # Archives containing C++ object files must be created using
- # the KAI C++ compiler.
- old_archive_cmds_CXX='$CC -o $oldlib $oldobjs'
- ;;
- RCC*)
- # Rational C++ 2.4.1
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- cxx*)
- allow_undefined_flag_CXX=' -expect_unresolved \*'
- archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
- echo "-hidden">> $lib.exp~
- $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~
- $rm $lib.exp'
-
- hardcode_libdir_flag_spec_CXX='-rpath $libdir'
- hardcode_libdir_separator_CXX=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
- else
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- fi
- ;;
- esac
- ;;
- psos*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- sunos4*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.x
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- lcc*)
- # Lucid
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- esac
- ;;
- solaris*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.2, 5.x and Centerline C++
- archive_cmds_need_lc_CXX=yes
- no_undefined_flag_CXX=' -zdefs'
- archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- hardcode_libdir_flag_spec_CXX='-R$libdir'
- hardcode_shlibpath_var_CXX=no
- case $host_os in
- solaris2.[0-5] | solaris2.[0-5].*) ;;
- *)
- # The C++ compiler is used as linker so we must use $wl
- # flag to pass the commands to the underlying system
- # linker. We must also pass each convience library through
- # to the system linker between allextract/defaultextract.
- # The C++ compiler will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
- ;;
- esac
- link_all_deplibs_CXX=yes
-
- output_verbose_link_cmd='echo'
-
- # Archives containing C++ object files must be created using
- # "CC -xar", where "CC" is the Sun C++ compiler. This is
- # necessary to make sure instantiated templates are included
- # in the archive.
- old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
- ;;
- gcx*)
- # Green Hills C++ Compiler
- archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-
- # The C++ compiler must be used to create the archive.
- old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
- ;;
- *)
- # GNU C++ compiler with Solaris linker
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
- if $CC --version | grep -v '^2\.7' > /dev/null; then
- archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
- else
- # g++ 2.7 appears to require `-G' NOT `-shared' on this
- # platform.
- archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
- fi
-
- hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
- fi
- ;;
- esac
- ;;
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
- no_undefined_flag_CXX='${wl}-z,text'
- archive_cmds_need_lc_CXX=no
- hardcode_shlibpath_var_CXX=no
- runpath_var='LD_RUN_PATH'
-
- case $cc_basename in
- CC*)
- archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- ;;
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- # For security reasons, it is highly recommended that you always
- # use absolute paths for naming shared libraries, and exclude the
- # DT_RUNPATH tag from executables and libraries. But doing so
- # requires that you compile everything twice, which is a pain.
- # So that behaviour is only enabled if SCOABSPATH is set to a
- # non-empty value in the environment. Most likely only useful for
- # creating official distributions of packages.
- # This is a hack until libtool officially supports absolute path
- # names for shared libraries.
- no_undefined_flag_CXX='${wl}-z,text'
- allow_undefined_flag_CXX='${wl}-z,nodefs'
- archive_cmds_need_lc_CXX=no
- hardcode_shlibpath_var_CXX=no
- hardcode_libdir_flag_spec_CXX='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- hardcode_libdir_separator_CXX=':'
- link_all_deplibs_CXX=yes
- export_dynamic_flag_spec_CXX='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- case $cc_basename in
- CC*)
- archive_cmds_CXX='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_CXX='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- ;;
- tandem*)
- case $cc_basename in
- NCC*)
- # NonStop-UX NCC 3.20
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- esac
- ;;
- vxworks*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
-esac
-echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5
-echo "${ECHO_T}$ld_shlibs_CXX" >&6
-test "$ld_shlibs_CXX" = no && can_build_shared=no
-
-GCC_CXX="$GXX"
-LD_CXX="$LD"
-
-
-cat > conftest.$ac_ext <<EOF
-class Foo
-{
-public:
- Foo (void) { a = 0; }
-private:
- int a;
-};
-EOF
-
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # Parse the compiler output and extract the necessary
- # objects, libraries and library flags.
-
- # Sentinel used to keep track of whether or not we are before
- # the conftest object file.
- pre_test_object_deps_done=no
-
- # The `*' in the case matches for architectures that use `case' in
- # $output_verbose_cmd can trigger glob expansion during the loop
- # eval without this substitution.
- output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
-
- for p in `eval $output_verbose_link_cmd`; do
- case $p in
-
- -L* | -R* | -l*)
- # Some compilers place space between "-{L,R}" and the path.
- # Remove the space.
- if test $p = "-L" \
- || test $p = "-R"; then
- prev=$p
- continue
- else
- prev=
- fi
-
- if test "$pre_test_object_deps_done" = no; then
- case $p in
- -L* | -R*)
- # Internal compiler library paths should come after those
- # provided the user. The postdeps already come after the
- # user supplied libs so there is no need to process them.
- if test -z "$compiler_lib_search_path_CXX"; then
- compiler_lib_search_path_CXX="${prev}${p}"
- else
- compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
- fi
- ;;
- # The "-l" case would never come before the object being
- # linked, so don't bother handling this case.
- esac
- else
- if test -z "$postdeps_CXX"; then
- postdeps_CXX="${prev}${p}"
- else
- postdeps_CXX="${postdeps_CXX} ${prev}${p}"
- fi
- fi
- ;;
-
- *.$objext)
- # This assumes that the test object file only shows up
- # once in the compiler output.
- if test "$p" = "conftest.$objext"; then
- pre_test_object_deps_done=yes
- continue
- fi
-
- if test "$pre_test_object_deps_done" = no; then
- if test -z "$predep_objects_CXX"; then
- predep_objects_CXX="$p"
- else
- predep_objects_CXX="$predep_objects_CXX $p"
- fi
- else
- if test -z "$postdep_objects_CXX"; then
- postdep_objects_CXX="$p"
- else
- postdep_objects_CXX="$postdep_objects_CXX $p"
- fi
- fi
- ;;
-
- *) ;; # Ignore the rest.
-
- esac
- done
-
- # Clean up.
- rm -f a.out a.exe
-else
- echo "libtool.m4: error: problem compiling CXX test program"
-fi
-
-$rm -f confest.$objext
-
-# PORTME: override above test on systems where it is broken
-case $host_os in
-interix3*)
- # Interix 3.5 installs completely hosed .la files for C++, so rather than
- # hack all around it, let's just trust "g++" to DTRT.
- predep_objects_CXX=
- postdep_objects_CXX=
- postdeps_CXX=
- ;;
-
-solaris*)
- case $cc_basename in
- CC*)
- # Adding this requires a known-good setup of shared libraries for
- # Sun compiler versions before 5.6, else PIC objects from an old
- # archive will be linked into the output, leading to subtle bugs.
- postdeps_CXX='-lCstd -lCrun'
- ;;
- esac
- ;;
-esac
-
-
-case " $postdeps_CXX " in
-*" -lc "*) archive_cmds_need_lc_CXX=no ;;
-esac
-
-lt_prog_compiler_wl_CXX=
-lt_prog_compiler_pic_CXX=
-lt_prog_compiler_static_CXX=
-
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
-
- # C++ specific cases for pic, static, wl, etc.
- if test "$GXX" = yes; then
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_static_CXX='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_CXX='-Bstatic'
- fi
- ;;
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
- ;;
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
- mingw* | os2* | pw32*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
- ;;
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- lt_prog_compiler_pic_CXX='-fno-common'
- ;;
- *djgpp*)
- # DJGPP does not support shared libraries at all
- lt_prog_compiler_pic_CXX=
- ;;
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
- sysv4*MP*)
- if test -d /usr/nec; then
- lt_prog_compiler_pic_CXX=-Kconform_pic
- fi
- ;;
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- ;;
- *)
- lt_prog_compiler_pic_CXX='-fPIC'
- ;;
- esac
- ;;
- *)
- lt_prog_compiler_pic_CXX='-fPIC'
- ;;
- esac
- else
- case $host_os in
- aix4* | aix5*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_CXX='-Bstatic'
- else
- lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- chorus*)
- case $cc_basename in
- cxch68*)
- # Green Hills C++ Compiler
- # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
- ;;
- esac
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- lt_prog_compiler_pic_CXX='-qnocommon'
- lt_prog_compiler_wl_CXX='-Wl,'
- ;;
- esac
- ;;
- dgux*)
- case $cc_basename in
- ec++*)
- lt_prog_compiler_pic_CXX='-KPIC'
- ;;
- ghcx*)
- # Green Hills C++ Compiler
- lt_prog_compiler_pic_CXX='-pic'
- ;;
- *)
- ;;
- esac
- ;;
- freebsd* | kfreebsd*-gnu | dragonfly*)
- # FreeBSD uses GNU C++
- ;;
- hpux9* | hpux10* | hpux11*)
- case $cc_basename in
- CC*)
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
- if test "$host_cpu" != ia64; then
- lt_prog_compiler_pic_CXX='+Z'
- fi
- ;;
- aCC*)
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic_CXX='+Z'
- ;;
- esac
- ;;
- *)
- ;;
- esac
- ;;
- interix*)
- # This is c89, which is MS Visual C++ (no shared libs)
- # Anyone wants to do a port?
- ;;
- irix5* | irix6* | nonstopux*)
- case $cc_basename in
- CC*)
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_static_CXX='-non_shared'
- # CC pic flag -KPIC is the default.
- ;;
- *)
- ;;
- esac
- ;;
- linux*)
- case $cc_basename in
- KCC*)
- # KAI C++ Compiler
- lt_prog_compiler_wl_CXX='--backend -Wl,'
- lt_prog_compiler_pic_CXX='-fPIC'
- ;;
- icpc* | ecpc*)
- # Intel C++
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_pic_CXX='-KPIC'
- lt_prog_compiler_static_CXX='-static'
- ;;
- pgCC*)
- # Portland Group C++ compiler.
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_pic_CXX='-fpic'
- lt_prog_compiler_static_CXX='-Bstatic'
- ;;
- cxx*)
- # Compaq C++
- # Make sure the PIC flag is empty. It appears that all Alpha
- # Linux and Compaq Tru64 Unix objects are PIC.
- lt_prog_compiler_pic_CXX=
- lt_prog_compiler_static_CXX='-non_shared'
- ;;
- *)
- ;;
- esac
- ;;
- lynxos*)
- ;;
- m88k*)
- ;;
- mvs*)
- case $cc_basename in
- cxx*)
- lt_prog_compiler_pic_CXX='-W c,exportall'
- ;;
- *)
- ;;
- esac
- ;;
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- ;;
- osf3* | osf4* | osf5*)
- case $cc_basename in
- KCC*)
- lt_prog_compiler_wl_CXX='--backend -Wl,'
- ;;
- RCC*)
- # Rational C++ 2.4.1
- lt_prog_compiler_pic_CXX='-pic'
- ;;
- cxx*)
- # Digital/Compaq C++
- lt_prog_compiler_wl_CXX='-Wl,'
- # Make sure the PIC flag is empty. It appears that all Alpha
- # Linux and Compaq Tru64 Unix objects are PIC.
- lt_prog_compiler_pic_CXX=
- lt_prog_compiler_static_CXX='-non_shared'
- ;;
- *)
- ;;
- esac
- ;;
- psos*)
- ;;
- solaris*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.2, 5.x and Centerline C++
- lt_prog_compiler_pic_CXX='-KPIC'
- lt_prog_compiler_static_CXX='-Bstatic'
- lt_prog_compiler_wl_CXX='-Qoption ld '
- ;;
- gcx*)
- # Green Hills C++ Compiler
- lt_prog_compiler_pic_CXX='-PIC'
- ;;
- *)
- ;;
- esac
- ;;
- sunos4*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.x
- lt_prog_compiler_pic_CXX='-pic'
- lt_prog_compiler_static_CXX='-Bstatic'
- ;;
- lcc*)
- # Lucid
- lt_prog_compiler_pic_CXX='-pic'
- ;;
- *)
- ;;
- esac
- ;;
- tandem*)
- case $cc_basename in
- NCC*)
- # NonStop-UX NCC 3.20
- lt_prog_compiler_pic_CXX='-KPIC'
- ;;
- *)
- ;;
- esac
- ;;
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- case $cc_basename in
- CC*)
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_pic_CXX='-KPIC'
- lt_prog_compiler_static_CXX='-Bstatic'
- ;;
- esac
- ;;
- vxworks*)
- ;;
- *)
- lt_prog_compiler_can_build_shared_CXX=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic_CXX"; then
-
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_pic_works_CXX=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:12245: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:12249: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_pic_works_CXX=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_CXX" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works_CXX" >&6
-
-if test x"$lt_prog_compiler_pic_works_CXX" = xyes; then
- case $lt_prog_compiler_pic_CXX in
- "" | " "*) ;;
- *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
- esac
-else
- lt_prog_compiler_pic_CXX=
- lt_prog_compiler_can_build_shared_CXX=no
-fi
-
-fi
-case $host_os in
- # For platforms which do not support PIC, -DPIC is meaningless:
- *djgpp*)
- lt_prog_compiler_pic_CXX=
- ;;
- *)
- lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC"
- ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_static_works_CXX=no
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
- printf "$lt_simple_link_test_code" > conftest.$ac_ext
- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
- # The linker can only warn and ignore the option if not recognized
- # So say no if there are warnings
- if test -s conftest.err; then
- # Append any errors to the config.log.
- cat conftest.err 1>&5
- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_static_works_CXX=yes
- fi
- else
- lt_prog_compiler_static_works_CXX=yes
- fi
- fi
- $rm conftest*
- LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_CXX" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_CXX" >&6
-
-if test x"$lt_prog_compiler_static_works_CXX" = xyes; then
- :
-else
- lt_prog_compiler_static_CXX=
-fi
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_c_o_CXX=no
- $rm -r conftest 2>/dev/null
- mkdir conftest
- cd conftest
- mkdir out
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- lt_compiler_flag="-o out/conftest2.$ac_objext"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:12349: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>out/conftest.err)
- ac_status=$?
- cat out/conftest.err >&5
- echo "$as_me:12353: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s out/conftest2.$ac_objext
- then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_c_o_CXX=yes
- fi
- fi
- chmod u+w . 2>&5
- $rm conftest*
- # SGI C++ compiler will create directory out/ii_files/ for
- # template instantiation
- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
- $rm out/* && rmdir out
- cd ..
- rmdir conftest
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6
-
-
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
- # do not overwrite the value of need_locks provided by the user
- echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
- hard_links=yes
- $rm conftest*
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- touch conftest.a
- ln conftest.a conftest.b 2>&5 || hard_links=no
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
- if test "$hard_links" = no; then
- { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
- need_locks=warn
- fi
-else
- need_locks=no
-fi
-
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-
- export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- case $host_os in
- aix4* | aix5*)
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- else
- export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- fi
- ;;
- pw32*)
- export_symbols_cmds_CXX="$ltdll_cmds"
- ;;
- cygwin* | mingw*)
- export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([^ ]*\) [^ ]*/\1 DATA/;/^I /d;/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
- ;;
- kfreebsd*-gnu)
- link_all_deplibs_CXX=no
- ;;
- linux*)
- link_all_deplibs_CXX=no
- ;;
- *)
- export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- ;;
- esac
-
-echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5
-echo "${ECHO_T}$ld_shlibs_CXX" >&6
-test "$ld_shlibs_CXX" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc_CXX" in
-x|xyes)
- # Assume -lc should be added
- archive_cmds_need_lc_CXX=yes
-
- if test "$enable_shared" = yes && test "$GCC" = yes; then
- case $archive_cmds_CXX in
- *'~'*)
- # FIXME: we may have to deal with multi-command sequences.
- ;;
- '$CC '*)
- # Test whether the compiler implicitly links with -lc since on some
- # systems, -lgcc has to come before -lc. If gcc already passes -lc
- # to ld, don't add -lc before -lgcc.
- echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
- $rm conftest*
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } 2>conftest.err; then
- soname=conftest
- lib=conftest
- libobjs=conftest.$ac_objext
- deplibs=
- wl=$lt_prog_compiler_wl_CXX
- pic_flag=$lt_prog_compiler_pic_CXX
- compiler_flags=-v
- linker_flags=-v
- verstring=
- output_objdir=.
- libname=conftest
- lt_save_allow_undefined_flag=$allow_undefined_flag_CXX
- allow_undefined_flag_CXX=
- if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
- (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
- then
- archive_cmds_need_lc_CXX=no
- else
- archive_cmds_need_lc_CXX=yes
- fi
- allow_undefined_flag_CXX=$lt_save_allow_undefined_flag
- else
- cat conftest.err 1>&5
- fi
- $rm conftest*
- echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5
-echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6
- ;;
- esac
- fi
- ;;
-esac
-
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
- # if the path contains ";" then we assume it to be the separator
- # otherwise default to the standard path separator (i.e. ":") - it is
- # assumed that no part of a normal pathname contains ";" but that should
- # okay in the real world where ";" in dirpaths is itself problematic.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
-else
- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
- shlibpath_var=LIBPATH
-
- # AIX 3 has no versioning support, so we append a major version to the name.
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
-
-aix4* | aix5*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- hardcode_into_libs=yes
- if test "$host_cpu" = ia64; then
- # AIX 5 supports IA64
- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- else
- # With GCC up to 2.95.x, collect2 would create an import file
- # for dependence libraries. The import file would start with
- # the line `#! .'. This would cause the generated library to
- # depend on `.', always an invalid library. This was fixed in
- # development snapshots of GCC prior to 3.0.
- case $host_os in
- aix4 | aix4.[01] | aix4.[01].*)
- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
- echo ' yes '
- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
- :
- else
- can_build_shared=no
- fi
- ;;
- esac
- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
- # soname into executable. Probably we can add versioning support to
- # collect2, so additional links can be useful in future.
- if test "$aix_use_runtimelinking" = yes; then
- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
- # instead of lib<name>.a to let people know that these are not
- # typical AIX shared libraries.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- else
- # We preserve .a as extension for shared libraries through AIX4.2
- # and later when we are not doing run time linking.
- library_names_spec='${libname}${release}.a $libname.a'
- soname_spec='${libname}${release}${shared_ext}$major'
- fi
- shlibpath_var=LIBPATH
- fi
- ;;
-
-amigaos*)
- library_names_spec='$libname.ixlibrary $libname.a'
- # Create ${libname}_ixlibrary.a entries in /sys/libs.
- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
- ;;
-
-beos*)
- library_names_spec='${libname}${shared_ext}'
- dynamic_linker="$host_os ld.so"
- shlibpath_var=LIBRARY_PATH
- ;;
-
-bsdi[45]*)
- version_type=linux
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
- # the default ld.so.conf also contains /usr/contrib/lib and
- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
- # libtool to hard-code these into programs
- ;;
-
-cygwin* | mingw* | pw32*)
- version_type=windows
- shrext_cmds=".dll"
- need_version=no
- need_lib_prefix=no
-
- case $GCC,$host_os in
- yes,cygwin* | yes,mingw* | yes,pw32*)
- library_names_spec='$libname.dll.a'
- # DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
- dldir=$destdir/`dirname \$dlpath`~
- test -d \$dldir || mkdir -p \$dldir~
- $install_prog $dir/$dlname \$dldir/$dlname~
- chmod a+x \$dldir/$dlname'
- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
- dlpath=$dir/\$dldll~
- $rm \$dlpath'
- shlibpath_overrides_runpath=yes
-
- case $host_os in
- cygwin*)
- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
- ;;
- mingw*)
- # MinGW DLLs use traditional 'lib' prefix
- soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
- # It is most probably a Windows format PATH printed by
- # mingw gcc, but we are running on Cygwin. Gcc prints its search
- # path with ; separators, and with drive letters. We can handle the
- # drive letters (cygwin fileutils understands them), so leave them,
- # especially as we might pass files found there to a mingw objdump,
- # which wouldn't understand a cygwinified path. Ahh.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
- ;;
- pw32*)
- # pw32 DLLs use 'pw' prefix rather than 'lib'
- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- ;;
- esac
- ;;
-
- *)
- library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
- ;;
- esac
- dynamic_linker='Win32 ld.exe'
- # FIXME: first we should search . and the directory the executable is in
- shlibpath_var=PATH
- ;;
-
-darwin* | rhapsody*)
- dynamic_linker="$host_os dyld"
- version_type=darwin
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
- soname_spec='${libname}${release}${major}$shared_ext'
- shlibpath_overrides_runpath=yes
- shlibpath_var=DYLD_LIBRARY_PATH
- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
- if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
- else
- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
- fi
- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
- ;;
-
-dgux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-freebsd1*)
- dynamic_linker=no
- ;;
-
-kfreebsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-freebsd* | dragonfly*)
- # DragonFly does not have aout. When/if they implement a new
- # versioning mechanism, adjust this.
- if test -x /usr/bin/objformat; then
- objformat=`/usr/bin/objformat`
- else
- case $host_os in
- freebsd[123]*) objformat=aout ;;
- *) objformat=elf ;;
- esac
- fi
- version_type=freebsd-$objformat
- case $version_type in
- freebsd-elf*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- need_version=no
- need_lib_prefix=no
- ;;
- freebsd-*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
- need_version=yes
- ;;
- esac
- shlibpath_var=LD_LIBRARY_PATH
- case $host_os in
- freebsd2*)
- shlibpath_overrides_runpath=yes
- ;;
- freebsd3.[01]* | freebsdelf3.[01]*)
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
- freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
- freebsd*) # from 4.6 on
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- esac
- ;;
-
-gnu*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- ;;
-
-hpux9* | hpux10* | hpux11*)
- # Give a soname corresponding to the major version so that dld.sl refuses to
- # link against other versions.
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- case $host_cpu in
- ia64*)
- shrext_cmds='.so'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.so"
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- if test "X$HPUX_IA64_MODE" = X32; then
- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
- else
- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
- fi
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- hppa*64*)
- shrext_cmds='.sl'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- *)
- shrext_cmds='.sl'
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=SHLIB_PATH
- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
- esac
- # HP-UX runs *really* slowly unless shared libraries are mode 555.
- postinstall_cmds='chmod 555 $lib'
- ;;
-
-interix3*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $host_os in
- nonstopux*) version_type=nonstopux ;;
- *)
- if test "$lt_cv_prog_gnu_ld" = yes; then
- version_type=linux
- else
- version_type=irix
- fi ;;
- esac
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
- case $host_os in
- irix5* | nonstopux*)
- libsuff= shlibsuff=
- ;;
- *)
- case $LD in # libtool.m4 will add one of these switches to LD
- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
- libsuff= shlibsuff= libmagic=32-bit;;
- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
- libsuff=32 shlibsuff=N32 libmagic=N32;;
- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
- libsuff=64 shlibsuff=64 libmagic=64-bit;;
- *) libsuff= shlibsuff= libmagic=never-match;;
- esac
- ;;
- esac
- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
- hardcode_into_libs=yes
- ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
- dynamic_linker=no
- ;;
-
-# This must be Linux ELF.
-linux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- # This implies no fast_install, which is unacceptable.
- # Some rework will be needed to allow for fast_install
- # before this can be enabled.
- hardcode_into_libs=yes
-
- # Append ld.so.conf contents to the search path
- if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
- fi
-
- # We used to test for /lib/ld.so.1 and disable shared libraries on
- # powerpc, because MkLinux only supported shared libraries with the
- # GNU dynamic linker. Since this was broken with cross compilers,
- # most powerpc-linux boxes support dynamic linking these days and
- # people can always --disable-shared, the test was removed, and we
- # assume the GNU/Linux dynamic linker is in use.
- dynamic_linker='GNU/Linux ld.so'
- ;;
-
-netbsdelf*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='NetBSD ld.elf_so'
- ;;
-
-knetbsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-netbsd*)
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- dynamic_linker='NetBSD (a.out) ld.so'
- else
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='NetBSD ld.elf_so'
- fi
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
-
-newsos6)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-nto-qnx*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-openbsd*)
- version_type=sunos
- sys_lib_dlsearch_path_spec="/usr/lib"
- need_lib_prefix=no
- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
- case $host_os in
- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
- *) need_version=no ;;
- esac
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- case $host_os in
- openbsd2.[89] | openbsd2.[89].*)
- shlibpath_overrides_runpath=no
- ;;
- *)
- shlibpath_overrides_runpath=yes
- ;;
- esac
- else
- shlibpath_overrides_runpath=yes
- fi
- ;;
-
-os2*)
- libname_spec='$name'
- shrext_cmds=".dll"
- need_lib_prefix=no
- library_names_spec='$libname${shared_ext} $libname.a'
- dynamic_linker='OS/2 ld.exe'
- shlibpath_var=LIBPATH
- ;;
-
-osf3* | osf4* | osf5*)
- version_type=osf
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
- ;;
-
-solaris*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- # ldd complains unless libraries are executable
- postinstall_cmds='chmod +x $lib'
- ;;
-
-sunos4*)
- version_type=sunos
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- if test "$with_gnu_ld" = yes; then
- need_lib_prefix=no
- fi
- need_version=yes
- ;;
-
-sysv4 | sysv4.3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- case $host_vendor in
- sni)
- shlibpath_overrides_runpath=no
- need_lib_prefix=no
- export_dynamic_flag_spec='${wl}-Blargedynsym'
- runpath_var=LD_RUN_PATH
- ;;
- siemens)
- need_lib_prefix=no
- ;;
- motorola)
- need_lib_prefix=no
- need_version=no
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
- ;;
- esac
- ;;
-
-sysv4*MP*)
- if test -d /usr/nec ;then
- version_type=linux
- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
- soname_spec='$libname${shared_ext}.$major'
- shlibpath_var=LD_LIBRARY_PATH
- fi
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- version_type=freebsd-elf
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- if test "$with_gnu_ld" = yes; then
- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
- shlibpath_overrides_runpath=no
- else
- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
- shlibpath_overrides_runpath=yes
- case $host_os in
- sco3.2v5*)
- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
- ;;
- esac
- fi
- sys_lib_dlsearch_path_spec='/usr/lib'
- ;;
-
-uts4*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-*)
- dynamic_linker=no
- ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action_CXX=
-if test -n "$hardcode_libdir_flag_spec_CXX" || \
- test -n "$runpath_var_CXX" || \
- test "X$hardcode_automatic_CXX" = "Xyes" ; then
-
- # We can hardcode non-existant directories.
- if test "$hardcode_direct_CXX" != no &&
- # If the only mechanism to avoid hardcoding is shlibpath_var, we
- # have to relink, otherwise we might link with an installed library
- # when we should be linking with a yet-to-be-installed one
- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
- test "$hardcode_minus_L_CXX" != no; then
- # Linking always hardcodes the temporary library directory.
- hardcode_action_CXX=relink
- else
- # We can link without hardcoding, and we can hardcode nonexisting dirs.
- hardcode_action_CXX=immediate
- fi
-else
- # We cannot hardcode anything, or else we can only hardcode existing
- # directories.
- hardcode_action_CXX=unsupported
-fi
-echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5
-echo "${ECHO_T}$hardcode_action_CXX" >&6
-
-if test "$hardcode_action_CXX" = relink; then
- # Fast installation is not supported
- enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
- test "$enable_shared" = no; then
- # Fast installation is not necessary
- enable_fast_install=needless
-fi
-
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- compiler_CXX \
- CC_CXX \
- LD_CXX \
- lt_prog_compiler_wl_CXX \
- lt_prog_compiler_pic_CXX \
- lt_prog_compiler_static_CXX \
- lt_prog_compiler_no_builtin_flag_CXX \
- export_dynamic_flag_spec_CXX \
- thread_safe_flag_spec_CXX \
- whole_archive_flag_spec_CXX \
- enable_shared_with_static_runtimes_CXX \
- old_archive_cmds_CXX \
- old_archive_from_new_cmds_CXX \
- predep_objects_CXX \
- postdep_objects_CXX \
- predeps_CXX \
- postdeps_CXX \
- compiler_lib_search_path_CXX \
- archive_cmds_CXX \
- archive_expsym_cmds_CXX \
- postinstall_cmds_CXX \
- postuninstall_cmds_CXX \
- old_archive_from_expsyms_cmds_CXX \
- allow_undefined_flag_CXX \
- no_undefined_flag_CXX \
- export_symbols_cmds_CXX \
- hardcode_libdir_flag_spec_CXX \
- hardcode_libdir_flag_spec_ld_CXX \
- hardcode_libdir_separator_CXX \
- hardcode_automatic_CXX \
- module_cmds_CXX \
- module_expsym_cmds_CXX \
- lt_cv_prog_compiler_c_o_CXX \
- exclude_expsyms_CXX \
- include_expsyms_CXX; do
-
- case $var in
- old_archive_cmds_CXX | \
- old_archive_from_new_cmds_CXX | \
- archive_cmds_CXX | \
- archive_expsym_cmds_CXX | \
- module_cmds_CXX | \
- module_expsym_cmds_CXX | \
- old_archive_from_expsyms_cmds_CXX | \
- export_symbols_cmds_CXX | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\$0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
- ;;
- esac
-
-cfgfile="$ofile"
-
- cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_CXX
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler_CXX
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_CXX
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD_CXX
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_CXX
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_CXX
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_CXX
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_CXX
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_CXX
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_CXX
-archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_CXX
-module_expsym_cmds=$lt_module_expsym_cmds_CXX
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_predep_objects_CXX
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_postdep_objects_CXX
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_CXX
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_CXX
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_CXX
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_CXX
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_CXX
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_CXX
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_CXX
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_CXX
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_CXX
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_CXX"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_CXX
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_CXX
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_CXX
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_CXX
-
-# ### END LIBTOOL TAG CONFIG: $tagname
-
-__EOF__
-
-
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC=$lt_save_CC
-LDCXX=$LD
-LD=$lt_save_LD
-GCC=$lt_save_GCC
-with_gnu_ldcxx=$with_gnu_ld
-with_gnu_ld=$lt_save_with_gnu_ld
-lt_cv_path_LDCXX=$lt_cv_path_LD
-lt_cv_path_LD=$lt_save_path_LD
-lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
-lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-
- else
- tagname=""
- fi
- ;;
-
- F77)
- if test -n "$F77" && test "X$F77" != "Xno"; then
-
-ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-
-
-archive_cmds_need_lc_F77=no
-allow_undefined_flag_F77=
-always_export_symbols_F77=no
-archive_expsym_cmds_F77=
-export_dynamic_flag_spec_F77=
-hardcode_direct_F77=no
-hardcode_libdir_flag_spec_F77=
-hardcode_libdir_flag_spec_ld_F77=
-hardcode_libdir_separator_F77=
-hardcode_minus_L_F77=no
-hardcode_automatic_F77=no
-module_cmds_F77=
-module_expsym_cmds_F77=
-link_all_deplibs_F77=unknown
-old_archive_cmds_F77=$old_archive_cmds
-no_undefined_flag_F77=
-whole_archive_flag_spec_F77=
-enable_shared_with_static_runtimes_F77=no
-
-# Source file extension for f77 test sources.
-ac_ext=f
-
-# Object file extension for compiled f77 test sources.
-objext=o
-objext_F77=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code=" subroutine t\n return\n end\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code=" program t\n end\n"
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${F77-"f77"}
-compiler=$CC
-compiler_F77=$CC
-for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
-echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
-echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: $can_build_shared" >&5
-echo "${ECHO_T}$can_build_shared" >&6
-
-echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
-echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6
-test "$can_build_shared" = "no" && enable_shared=no
-
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
-case $host_os in
-aix3*)
- test "$enable_shared" = yes && enable_static=no
- if test -n "$RANLIB"; then
- archive_cmds="$archive_cmds~\$RANLIB \$lib"
- postinstall_cmds='$RANLIB $lib'
- fi
- ;;
-aix4* | aix5*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
- fi
- ;;
-esac
-echo "$as_me:$LINENO: result: $enable_shared" >&5
-echo "${ECHO_T}$enable_shared" >&6
-
-echo "$as_me:$LINENO: checking whether to build static libraries" >&5
-echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-echo "$as_me:$LINENO: result: $enable_static" >&5
-echo "${ECHO_T}$enable_static" >&6
-
-GCC_F77="$G77"
-LD_F77="$LD"
-
-lt_prog_compiler_wl_F77=
-lt_prog_compiler_pic_F77=
-lt_prog_compiler_static_F77=
-
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
-
- if test "$GCC" = yes; then
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_static_F77='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_F77='-Bstatic'
- fi
- ;;
-
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4'
- ;;
-
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic_F77='-DDLL_EXPORT'
- ;;
-
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- lt_prog_compiler_pic_F77='-fno-common'
- ;;
-
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
-
- msdosdjgpp*)
- # Just because we use GCC doesn't mean we suddenly get shared libraries
- # on systems that don't support them.
- lt_prog_compiler_can_build_shared_F77=no
- enable_shared=no
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- lt_prog_compiler_pic_F77=-Kconform_pic
- fi
- ;;
-
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic_F77='-fPIC'
- ;;
- esac
- ;;
-
- *)
- lt_prog_compiler_pic_F77='-fPIC'
- ;;
- esac
- else
- # PORTME Check for flag to pass linker flags through the system compiler.
- case $host_os in
- aix*)
- lt_prog_compiler_wl_F77='-Wl,'
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_F77='-Bstatic'
- else
- lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- lt_prog_compiler_pic_F77='-qnocommon'
- lt_prog_compiler_wl_F77='-Wl,'
- ;;
- esac
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic_F77='-DDLL_EXPORT'
- ;;
-
- hpux9* | hpux10* | hpux11*)
- lt_prog_compiler_wl_F77='-Wl,'
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic_F77='+Z'
- ;;
- esac
- # Is there a better lt_prog_compiler_static that works with the bundled CC?
- lt_prog_compiler_static_F77='${wl}-a ${wl}archive'
- ;;
-
- irix5* | irix6* | nonstopux*)
- lt_prog_compiler_wl_F77='-Wl,'
- # PIC (with -KPIC) is the default.
- lt_prog_compiler_static_F77='-non_shared'
- ;;
-
- newsos6)
- lt_prog_compiler_pic_F77='-KPIC'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
-
- linux*)
- case $cc_basename in
- icc* | ecc*)
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_pic_F77='-KPIC'
- lt_prog_compiler_static_F77='-static'
- ;;
- pgcc* | pgf77* | pgf90* | pgf95*)
- # Portland Group compilers (*not* the Pentium gcc compiler,
- # which looks to be a dead project)
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_pic_F77='-fpic'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
- ccc*)
- lt_prog_compiler_wl_F77='-Wl,'
- # All Alpha code is PIC.
- lt_prog_compiler_static_F77='-non_shared'
- ;;
- esac
- ;;
-
- osf3* | osf4* | osf5*)
- lt_prog_compiler_wl_F77='-Wl,'
- # All OSF/1 code is PIC.
- lt_prog_compiler_static_F77='-non_shared'
- ;;
-
- solaris*)
- lt_prog_compiler_pic_F77='-KPIC'
- lt_prog_compiler_static_F77='-Bstatic'
- case $cc_basename in
- f77* | f90* | f95*)
- lt_prog_compiler_wl_F77='-Qoption ld ';;
- *)
- lt_prog_compiler_wl_F77='-Wl,';;
- esac
- ;;
-
- sunos4*)
- lt_prog_compiler_wl_F77='-Qoption ld '
- lt_prog_compiler_pic_F77='-PIC'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
-
- sysv4 | sysv4.2uw2* | sysv4.3*)
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_pic_F77='-KPIC'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec ;then
- lt_prog_compiler_pic_F77='-Kconform_pic'
- lt_prog_compiler_static_F77='-Bstatic'
- fi
- ;;
-
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_pic_F77='-KPIC'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
-
- unicos*)
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_can_build_shared_F77=no
- ;;
-
- uts4*)
- lt_prog_compiler_pic_F77='-pic'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
-
- *)
- lt_prog_compiler_can_build_shared_F77=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_F77" >&6
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic_F77"; then
-
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works_F77+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_pic_works_F77=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="$lt_prog_compiler_pic_F77"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:13937: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:13941: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_pic_works_F77=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_F77" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works_F77" >&6
-
-if test x"$lt_prog_compiler_pic_works_F77" = xyes; then
- case $lt_prog_compiler_pic_F77 in
- "" | " "*) ;;
- *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;;
- esac
-else
- lt_prog_compiler_pic_F77=
- lt_prog_compiler_can_build_shared_F77=no
-fi
-
-fi
-case $host_os in
- # For platforms which do not support PIC, -DPIC is meaningless:
- *djgpp*)
- lt_prog_compiler_pic_F77=
- ;;
- *)
- lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77"
- ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_F77 eval lt_tmp_static_flag=\"$lt_prog_compiler_static_F77\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works_F77+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_static_works_F77=no
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
- printf "$lt_simple_link_test_code" > conftest.$ac_ext
- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
- # The linker can only warn and ignore the option if not recognized
- # So say no if there are warnings
- if test -s conftest.err; then
- # Append any errors to the config.log.
- cat conftest.err 1>&5
- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_static_works_F77=yes
- fi
- else
- lt_prog_compiler_static_works_F77=yes
- fi
- fi
- $rm conftest*
- LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_F77" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_F77" >&6
-
-if test x"$lt_prog_compiler_static_works_F77" = xyes; then
- :
-else
- lt_prog_compiler_static_F77=
-fi
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_c_o_F77=no
- $rm -r conftest 2>/dev/null
- mkdir conftest
- cd conftest
- mkdir out
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- lt_compiler_flag="-o out/conftest2.$ac_objext"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:14041: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>out/conftest.err)
- ac_status=$?
- cat out/conftest.err >&5
- echo "$as_me:14045: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s out/conftest2.$ac_objext
- then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_c_o_F77=yes
- fi
- fi
- chmod u+w . 2>&5
- $rm conftest*
- # SGI C++ compiler will create directory out/ii_files/ for
- # template instantiation
- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
- $rm out/* && rmdir out
- cd ..
- rmdir conftest
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o_F77" >&6
-
-
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then
- # do not overwrite the value of need_locks provided by the user
- echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
- hard_links=yes
- $rm conftest*
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- touch conftest.a
- ln conftest.a conftest.b 2>&5 || hard_links=no
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
- if test "$hard_links" = no; then
- { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
- need_locks=warn
- fi
-else
- need_locks=no
-fi
-
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-
- runpath_var=
- allow_undefined_flag_F77=
- enable_shared_with_static_runtimes_F77=no
- archive_cmds_F77=
- archive_expsym_cmds_F77=
- old_archive_From_new_cmds_F77=
- old_archive_from_expsyms_cmds_F77=
- export_dynamic_flag_spec_F77=
- whole_archive_flag_spec_F77=
- thread_safe_flag_spec_F77=
- hardcode_libdir_flag_spec_F77=
- hardcode_libdir_flag_spec_ld_F77=
- hardcode_libdir_separator_F77=
- hardcode_direct_F77=no
- hardcode_minus_L_F77=no
- hardcode_shlibpath_var_F77=unsupported
- link_all_deplibs_F77=unknown
- hardcode_automatic_F77=no
- module_cmds_F77=
- module_expsym_cmds_F77=
- always_export_symbols_F77=no
- export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- # include_expsyms should be a list of space-separated symbols to be *always*
- # included in the symbol list
- include_expsyms_F77=
- # exclude_expsyms can be an extended regexp of symbols to exclude
- # it will be wrapped by ` (' and `)$', so one must not match beginning or
- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
- # as well as any symbol that contains `d'.
- exclude_expsyms_F77="_GLOBAL_OFFSET_TABLE_"
- # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
- # platforms (ab)use it in PIC code, but their linkers get confused if
- # the symbol is explicitly referenced. Since portable code cannot
- # rely on this symbol name, it's probably fine to never include it in
- # preloaded symbol tables.
- extract_expsyms_cmds=
- # Just being paranoid about ensuring that cc_basename is set.
- for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
- case $host_os in
- cygwin* | mingw* | pw32*)
- # FIXME: the MSVC++ port hasn't been tested in a loooong time
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- if test "$GCC" != yes; then
- with_gnu_ld=no
- fi
- ;;
- interix*)
- # we just hope/assume this is gcc and not c89 (= MSVC++)
- with_gnu_ld=yes
- ;;
- openbsd*)
- with_gnu_ld=no
- ;;
- esac
-
- ld_shlibs_F77=yes
- if test "$with_gnu_ld" = yes; then
- # If archive_cmds runs LD, not CC, wlarc should be empty
- wlarc='${wl}'
-
- # Set some defaults for GNU ld with shared library support. These
- # are reset later if shared libraries are not supported. Putting them
- # here allows them to be overridden if necessary.
- runpath_var=LD_RUN_PATH
- hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir'
- export_dynamic_flag_spec_F77='${wl}--export-dynamic'
- # ancient GNU ld didn't support --whole-archive et. al.
- if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
- whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- whole_archive_flag_spec_F77=
- fi
- supports_anon_versioning=no
- case `$LD -v 2>/dev/null` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
- *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
- *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
- *\ 2.11.*) ;; # other 2.11 versions
- *) supports_anon_versioning=yes ;;
- esac
-
- # See if GNU ld supports shared libraries.
- case $host_os in
- aix3* | aix4* | aix5*)
- # On AIX/PPC, the GNU linker is very broken
- if test "$host_cpu" != ia64; then
- ld_shlibs_F77=no
- cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support. If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
- fi
- ;;
-
- amigaos*)
- archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_minus_L_F77=yes
-
- # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
- # that the semantics of dynamic libraries on AmigaOS, at least up
- # to version 4, is to share data among multiple programs linked
- # with the same dynamic library. Since this doesn't match the
- # behavior of shared libraries on other platforms, we can't use
- # them.
- ld_shlibs_F77=no
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- allow_undefined_flag_F77=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- ld_shlibs_F77=no
- fi
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless,
- # as there is no search path for DLLs.
- hardcode_libdir_flag_spec_F77='-L$libdir'
- allow_undefined_flag_F77=unsupported
- always_export_symbols_F77=no
- enable_shared_with_static_runtimes_F77=yes
- export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- ld_shlibs_F77=no
- fi
- ;;
-
- interix3*)
- hardcode_direct_F77=no
- hardcode_shlibpath_var_F77=no
- hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_F77='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- archive_cmds_F77='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- archive_expsym_cmds_F77='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
-
- linux*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- tmp_addflag=
- case $cc_basename,$host_cpu in
- pgcc*) # Portland Group C compiler
- whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag'
- ;;
- pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
- whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag -Mnomain' ;;
- ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
- tmp_addflag=' -i_dynamic' ;;
- efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
- tmp_addflag=' -i_dynamic -nofor_main' ;;
- ifc* | ifort*) # Intel Fortran compiler
- tmp_addflag=' -nofor_main' ;;
- esac
- archive_cmds_F77='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
- if test $supports_anon_versioning = yes; then
- archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- $echo "local: *; };" >> $output_objdir/$libname.ver~
- $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
- fi
- link_all_deplibs_F77=no
- else
- ld_shlibs_F77=no
- fi
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
- wlarc=
- else
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- fi
- ;;
-
- solaris*)
- if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
- ld_shlibs_F77=no
- cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-EOF
- elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs_F77=no
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
- case `$LD -v 2>&1` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
- ld_shlibs_F77=no
- cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
- ;;
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
- archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
- else
- ld_shlibs_F77=no
- fi
- ;;
- esac
- ;;
-
- sunos4*)
- archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- wlarc=
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs_F77=no
- fi
- ;;
- esac
-
- if test "$ld_shlibs_F77" = no; then
- runpath_var=
- hardcode_libdir_flag_spec_F77=
- export_dynamic_flag_spec_F77=
- whole_archive_flag_spec_F77=
- fi
- else
- # PORTME fill in a description of your system's linker (not GNU ld)
- case $host_os in
- aix3*)
- allow_undefined_flag_F77=unsupported
- always_export_symbols_F77=yes
- archive_expsym_cmds_F77='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
- # Note: this linker hardcodes the directories in LIBPATH if there
- # are no directories specified by -L.
- hardcode_minus_L_F77=yes
- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
- # Neither direct hardcoding nor static linking is supported with a
- # broken collect2.
- hardcode_direct_F77=unsupported
- fi
- ;;
-
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- else
- export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- fi
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[23]|aix4.[23].*|aix5*)
- for ld_flag in $LDFLAGS; do
- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
- aix_use_runtimelinking=yes
- break
- fi
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- archive_cmds_F77=''
- hardcode_direct_F77=yes
- hardcode_libdir_separator_F77=':'
- link_all_deplibs_F77=yes
-
- if test "$GCC" = yes; then
- case $host_os in aix4.[012]|aix4.[012].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- hardcode_direct_F77=yes
- else
- # We have old collect2
- hardcode_direct_F77=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- hardcode_minus_L_F77=yes
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_libdir_separator_F77=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- always_export_symbols_F77=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- allow_undefined_flag_F77='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
- program main
-
- end
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
- archive_expsym_cmds_F77="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib'
- allow_undefined_flag_F77="-z nodefs"
- archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
- program main
-
- end
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- no_undefined_flag_F77=' ${wl}-bernotok'
- allow_undefined_flag_F77=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- whole_archive_flag_spec_F77='$convenience'
- archive_cmds_need_lc_F77=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- amigaos*)
- archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_minus_L_F77=yes
- # see comment about different semantics on the GNU ld section
- ld_shlibs_F77=no
- ;;
-
- bsdi[45]*)
- export_dynamic_flag_spec_F77=-rdynamic
- ;;
-
- cygwin* | mingw* | pw32*)
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- # hardcode_libdir_flag_spec is actually meaningless, as there is
- # no search path for DLLs.
- hardcode_libdir_flag_spec_F77=' '
- allow_undefined_flag_F77=unsupported
- # Tell ltmain to make .lib files, not .a files.
- libext=lib
- # Tell ltmain to make .dll files, not .so files.
- shrext_cmds=".dll"
- # FIXME: Setting linknames here is a bad hack.
- archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
- # The linker will automatically build a .lib file if we build a DLL.
- old_archive_From_new_cmds_F77='true'
- # FIXME: Should let the user specify the lib program.
- old_archive_cmds_F77='lib /OUT:$oldlib$oldobjs$old_deplibs'
- fix_srcfile_path_F77='`cygpath -w "$srcfile"`'
- enable_shared_with_static_runtimes_F77=yes
- ;;
-
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[012])
- allow_undefined_flag_F77='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[012])
- allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- allow_undefined_flag_F77='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- archive_cmds_need_lc_F77=no
- hardcode_direct_F77=no
- hardcode_automatic_F77=yes
- hardcode_shlibpath_var_F77=unsupported
- whole_archive_flag_spec_F77=''
- link_all_deplibs_F77=yes
- if test "$GCC" = yes ; then
- output_verbose_link_cmd='echo'
- archive_cmds_F77='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- archive_cmds_F77='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- ld_shlibs_F77=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_shlibpath_var_F77=no
- ;;
-
- freebsd1*)
- ld_shlibs_F77=no
- ;;
-
- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
- # support. Future versions do this automatically, but an explicit c++rt0.o
- # does not break anything, and helps significantly (at the cost of a little
- # extra space).
- freebsd2.2*)
- archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
- hardcode_libdir_flag_spec_F77='-R$libdir'
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- # Unfortunately, older versions of FreeBSD 2 do not have this feature.
- freebsd2*)
- archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_F77=yes
- hardcode_minus_L_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
- freebsd* | dragonfly*)
- archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_F77='-R$libdir'
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- # GNU/kFreeBSD uses gcc -shared to do shared libraries.
- kfreebsd*-gnu)
- archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_F77='-R$libdir'
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- link_all_deplibs_F77=no
- ;;
-
- hpux9*)
- if test "$GCC" = yes; then
- archive_cmds_F77='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- archive_cmds_F77='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- fi
- hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_F77=:
- hardcode_direct_F77=yes
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_F77=yes
- export_dynamic_flag_spec_F77='${wl}-E'
- ;;
-
- hpux10*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_F77=:
-
- hardcode_direct_F77=yes
- export_dynamic_flag_spec_F77='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_F77=yes
- fi
- ;;
-
- hpux11*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- case $host_cpu in
- hppa*64*)
- archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- else
- case $host_cpu in
- hppa*64*)
- archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_F77=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- hardcode_libdir_flag_spec_ld_F77='+b $libdir'
- hardcode_direct_F77=no
- hardcode_shlibpath_var_F77=no
- ;;
- *)
- hardcode_direct_F77=yes
- export_dynamic_flag_spec_F77='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_F77=yes
- ;;
- esac
- fi
- ;;
-
- irix5* | irix6* | nonstopux*)
- if test "$GCC" = yes; then
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- archive_cmds_F77='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec_ld_F77='-rpath $libdir'
- fi
- hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_F77=:
- link_all_deplibs_F77=yes
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
- else
- archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
- fi
- hardcode_libdir_flag_spec_F77='-R$libdir'
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- newsos6)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_F77=yes
- hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_F77=:
- hardcode_shlibpath_var_F77=no
- ;;
-
- openbsd*)
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
- hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_F77='${wl}-E'
- else
- case $host_os in
- openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
- archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_F77='-R$libdir'
- ;;
- *)
- archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
- ;;
- esac
- fi
- ;;
-
- os2*)
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_minus_L_F77=yes
- allow_undefined_flag_F77=unsupported
- archive_cmds_F77='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
- old_archive_From_new_cmds_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
- ;;
-
- osf3*)
- if test "$GCC" = yes; then
- allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- allow_undefined_flag_F77=' -expect_unresolved \*'
- archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- fi
- hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_F77=:
- ;;
-
- osf4* | osf5*) # as osf3* with the addition of -msym flag
- if test "$GCC" = yes; then
- allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
- else
- allow_undefined_flag_F77=' -expect_unresolved \*'
- archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
-
- # Both c and cxx compiler support -rpath directly
- hardcode_libdir_flag_spec_F77='-rpath $libdir'
- fi
- hardcode_libdir_separator_F77=:
- ;;
-
- solaris*)
- no_undefined_flag_F77=' -z text'
- if test "$GCC" = yes; then
- wlarc='${wl}'
- archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
- else
- wlarc=''
- archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
- archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
- fi
- hardcode_libdir_flag_spec_F77='-R$libdir'
- hardcode_shlibpath_var_F77=no
- case $host_os in
- solaris2.[0-5] | solaris2.[0-5].*) ;;
- *)
- # The compiler driver will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl, iff we do not link with $LD.
- # Luckily, gcc supports the same syntax we need for Sun Studio.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- case $wlarc in
- '')
- whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;;
- *)
- whole_archive_flag_spec_F77='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- esac ;;
- esac
- link_all_deplibs_F77=yes
- ;;
-
- sunos4*)
- if test "x$host_vendor" = xsequent; then
- # Use $CC to link under sequent, because it throws in some extra .o
- # files that make .init and .fini sections work.
- archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
- fi
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_direct_F77=yes
- hardcode_minus_L_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- sysv4)
- case $host_vendor in
- sni)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_F77=yes # is this really true???
- ;;
- siemens)
- ## LD is ld it makes a PLAMLIB
- ## CC just makes a GrossModule.
- archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags'
- reload_cmds_F77='$CC -r -o $output$reload_objs'
- hardcode_direct_F77=no
- ;;
- motorola)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie
- ;;
- esac
- runpath_var='LD_RUN_PATH'
- hardcode_shlibpath_var_F77=no
- ;;
-
- sysv4.3*)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var_F77=no
- export_dynamic_flag_spec_F77='-Bexport'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var_F77=no
- runpath_var=LD_RUN_PATH
- hardcode_runpath_var=yes
- ld_shlibs_F77=yes
- fi
- ;;
-
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
- no_undefined_flag_F77='${wl}-z,text'
- archive_cmds_need_lc_F77=no
- hardcode_shlibpath_var_F77=no
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds_F77='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_F77='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- no_undefined_flag_F77='${wl}-z,text'
- allow_undefined_flag_F77='${wl}-z,nodefs'
- archive_cmds_need_lc_F77=no
- hardcode_shlibpath_var_F77=no
- hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- hardcode_libdir_separator_F77=':'
- link_all_deplibs_F77=yes
- export_dynamic_flag_spec_F77='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds_F77='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_F77='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- uts4*)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_shlibpath_var_F77=no
- ;;
-
- *)
- ld_shlibs_F77=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5
-echo "${ECHO_T}$ld_shlibs_F77" >&6
-test "$ld_shlibs_F77" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc_F77" in
-x|xyes)
- # Assume -lc should be added
- archive_cmds_need_lc_F77=yes
-
- if test "$enable_shared" = yes && test "$GCC" = yes; then
- case $archive_cmds_F77 in
- *'~'*)
- # FIXME: we may have to deal with multi-command sequences.
- ;;
- '$CC '*)
- # Test whether the compiler implicitly links with -lc since on some
- # systems, -lgcc has to come before -lc. If gcc already passes -lc
- # to ld, don't add -lc before -lgcc.
- echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
- $rm conftest*
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } 2>conftest.err; then
- soname=conftest
- lib=conftest
- libobjs=conftest.$ac_objext
- deplibs=
- wl=$lt_prog_compiler_wl_F77
- pic_flag=$lt_prog_compiler_pic_F77
- compiler_flags=-v
- linker_flags=-v
- verstring=
- output_objdir=.
- libname=conftest
- lt_save_allow_undefined_flag=$allow_undefined_flag_F77
- allow_undefined_flag_F77=
- if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
- (eval $archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
- then
- archive_cmds_need_lc_F77=no
- else
- archive_cmds_need_lc_F77=yes
- fi
- allow_undefined_flag_F77=$lt_save_allow_undefined_flag
- else
- cat conftest.err 1>&5
- fi
- $rm conftest*
- echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5
-echo "${ECHO_T}$archive_cmds_need_lc_F77" >&6
- ;;
- esac
- fi
- ;;
-esac
-
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
- # if the path contains ";" then we assume it to be the separator
- # otherwise default to the standard path separator (i.e. ":") - it is
- # assumed that no part of a normal pathname contains ";" but that should
- # okay in the real world where ";" in dirpaths is itself problematic.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
-else
- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
- shlibpath_var=LIBPATH
-
- # AIX 3 has no versioning support, so we append a major version to the name.
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
-
-aix4* | aix5*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- hardcode_into_libs=yes
- if test "$host_cpu" = ia64; then
- # AIX 5 supports IA64
- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- else
- # With GCC up to 2.95.x, collect2 would create an import file
- # for dependence libraries. The import file would start with
- # the line `#! .'. This would cause the generated library to
- # depend on `.', always an invalid library. This was fixed in
- # development snapshots of GCC prior to 3.0.
- case $host_os in
- aix4 | aix4.[01] | aix4.[01].*)
- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
- echo ' yes '
- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
- :
- else
- can_build_shared=no
- fi
- ;;
- esac
- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
- # soname into executable. Probably we can add versioning support to
- # collect2, so additional links can be useful in future.
- if test "$aix_use_runtimelinking" = yes; then
- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
- # instead of lib<name>.a to let people know that these are not
- # typical AIX shared libraries.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- else
- # We preserve .a as extension for shared libraries through AIX4.2
- # and later when we are not doing run time linking.
- library_names_spec='${libname}${release}.a $libname.a'
- soname_spec='${libname}${release}${shared_ext}$major'
- fi
- shlibpath_var=LIBPATH
- fi
- ;;
-
-amigaos*)
- library_names_spec='$libname.ixlibrary $libname.a'
- # Create ${libname}_ixlibrary.a entries in /sys/libs.
- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
- ;;
-
-beos*)
- library_names_spec='${libname}${shared_ext}'
- dynamic_linker="$host_os ld.so"
- shlibpath_var=LIBRARY_PATH
- ;;
-
-bsdi[45]*)
- version_type=linux
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
- # the default ld.so.conf also contains /usr/contrib/lib and
- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
- # libtool to hard-code these into programs
- ;;
-
-cygwin* | mingw* | pw32*)
- version_type=windows
- shrext_cmds=".dll"
- need_version=no
- need_lib_prefix=no
-
- case $GCC,$host_os in
- yes,cygwin* | yes,mingw* | yes,pw32*)
- library_names_spec='$libname.dll.a'
- # DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
- dldir=$destdir/`dirname \$dlpath`~
- test -d \$dldir || mkdir -p \$dldir~
- $install_prog $dir/$dlname \$dldir/$dlname~
- chmod a+x \$dldir/$dlname'
- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
- dlpath=$dir/\$dldll~
- $rm \$dlpath'
- shlibpath_overrides_runpath=yes
-
- case $host_os in
- cygwin*)
- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
- ;;
- mingw*)
- # MinGW DLLs use traditional 'lib' prefix
- soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
- # It is most probably a Windows format PATH printed by
- # mingw gcc, but we are running on Cygwin. Gcc prints its search
- # path with ; separators, and with drive letters. We can handle the
- # drive letters (cygwin fileutils understands them), so leave them,
- # especially as we might pass files found there to a mingw objdump,
- # which wouldn't understand a cygwinified path. Ahh.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
- ;;
- pw32*)
- # pw32 DLLs use 'pw' prefix rather than 'lib'
- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- ;;
- esac
- ;;
-
- *)
- library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
- ;;
- esac
- dynamic_linker='Win32 ld.exe'
- # FIXME: first we should search . and the directory the executable is in
- shlibpath_var=PATH
- ;;
-
-darwin* | rhapsody*)
- dynamic_linker="$host_os dyld"
- version_type=darwin
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
- soname_spec='${libname}${release}${major}$shared_ext'
- shlibpath_overrides_runpath=yes
- shlibpath_var=DYLD_LIBRARY_PATH
- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
- if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
- else
- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
- fi
- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
- ;;
-
-dgux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-freebsd1*)
- dynamic_linker=no
- ;;
-
-kfreebsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-freebsd* | dragonfly*)
- # DragonFly does not have aout. When/if they implement a new
- # versioning mechanism, adjust this.
- if test -x /usr/bin/objformat; then
- objformat=`/usr/bin/objformat`
- else
- case $host_os in
- freebsd[123]*) objformat=aout ;;
- *) objformat=elf ;;
- esac
- fi
- version_type=freebsd-$objformat
- case $version_type in
- freebsd-elf*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- need_version=no
- need_lib_prefix=no
- ;;
- freebsd-*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
- need_version=yes
- ;;
- esac
- shlibpath_var=LD_LIBRARY_PATH
- case $host_os in
- freebsd2*)
- shlibpath_overrides_runpath=yes
- ;;
- freebsd3.[01]* | freebsdelf3.[01]*)
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
- freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
- freebsd*) # from 4.6 on
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- esac
- ;;
-
-gnu*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- ;;
-
-hpux9* | hpux10* | hpux11*)
- # Give a soname corresponding to the major version so that dld.sl refuses to
- # link against other versions.
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- case $host_cpu in
- ia64*)
- shrext_cmds='.so'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.so"
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- if test "X$HPUX_IA64_MODE" = X32; then
- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
- else
- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
- fi
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- hppa*64*)
- shrext_cmds='.sl'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- *)
- shrext_cmds='.sl'
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=SHLIB_PATH
- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
- esac
- # HP-UX runs *really* slowly unless shared libraries are mode 555.
- postinstall_cmds='chmod 555 $lib'
- ;;
-
-interix3*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $host_os in
- nonstopux*) version_type=nonstopux ;;
- *)
- if test "$lt_cv_prog_gnu_ld" = yes; then
- version_type=linux
- else
- version_type=irix
- fi ;;
- esac
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
- case $host_os in
- irix5* | nonstopux*)
- libsuff= shlibsuff=
- ;;
- *)
- case $LD in # libtool.m4 will add one of these switches to LD
- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
- libsuff= shlibsuff= libmagic=32-bit;;
- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
- libsuff=32 shlibsuff=N32 libmagic=N32;;
- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
- libsuff=64 shlibsuff=64 libmagic=64-bit;;
- *) libsuff= shlibsuff= libmagic=never-match;;
- esac
- ;;
- esac
- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
- hardcode_into_libs=yes
- ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
- dynamic_linker=no
- ;;
-
-# This must be Linux ELF.
-linux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- # This implies no fast_install, which is unacceptable.
- # Some rework will be needed to allow for fast_install
- # before this can be enabled.
- hardcode_into_libs=yes
-
- # Append ld.so.conf contents to the search path
- if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
- fi
-
- # We used to test for /lib/ld.so.1 and disable shared libraries on
- # powerpc, because MkLinux only supported shared libraries with the
- # GNU dynamic linker. Since this was broken with cross compilers,
- # most powerpc-linux boxes support dynamic linking these days and
- # people can always --disable-shared, the test was removed, and we
- # assume the GNU/Linux dynamic linker is in use.
- dynamic_linker='GNU/Linux ld.so'
- ;;
-
-netbsdelf*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='NetBSD ld.elf_so'
- ;;
-
-knetbsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-netbsd*)
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- dynamic_linker='NetBSD (a.out) ld.so'
- else
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='NetBSD ld.elf_so'
- fi
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
-
-newsos6)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-nto-qnx*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-openbsd*)
- version_type=sunos
- sys_lib_dlsearch_path_spec="/usr/lib"
- need_lib_prefix=no
- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
- case $host_os in
- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
- *) need_version=no ;;
- esac
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- case $host_os in
- openbsd2.[89] | openbsd2.[89].*)
- shlibpath_overrides_runpath=no
- ;;
- *)
- shlibpath_overrides_runpath=yes
- ;;
- esac
- else
- shlibpath_overrides_runpath=yes
- fi
- ;;
-
-os2*)
- libname_spec='$name'
- shrext_cmds=".dll"
- need_lib_prefix=no
- library_names_spec='$libname${shared_ext} $libname.a'
- dynamic_linker='OS/2 ld.exe'
- shlibpath_var=LIBPATH
- ;;
-
-osf3* | osf4* | osf5*)
- version_type=osf
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
- ;;
-
-solaris*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- # ldd complains unless libraries are executable
- postinstall_cmds='chmod +x $lib'
- ;;
-
-sunos4*)
- version_type=sunos
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- if test "$with_gnu_ld" = yes; then
- need_lib_prefix=no
- fi
- need_version=yes
- ;;
-
-sysv4 | sysv4.3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- case $host_vendor in
- sni)
- shlibpath_overrides_runpath=no
- need_lib_prefix=no
- export_dynamic_flag_spec='${wl}-Blargedynsym'
- runpath_var=LD_RUN_PATH
- ;;
- siemens)
- need_lib_prefix=no
- ;;
- motorola)
- need_lib_prefix=no
- need_version=no
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
- ;;
- esac
- ;;
-
-sysv4*MP*)
- if test -d /usr/nec ;then
- version_type=linux
- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
- soname_spec='$libname${shared_ext}.$major'
- shlibpath_var=LD_LIBRARY_PATH
- fi
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- version_type=freebsd-elf
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- if test "$with_gnu_ld" = yes; then
- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
- shlibpath_overrides_runpath=no
- else
- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
- shlibpath_overrides_runpath=yes
- case $host_os in
- sco3.2v5*)
- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
- ;;
- esac
- fi
- sys_lib_dlsearch_path_spec='/usr/lib'
- ;;
-
-uts4*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-*)
- dynamic_linker=no
- ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action_F77=
-if test -n "$hardcode_libdir_flag_spec_F77" || \
- test -n "$runpath_var_F77" || \
- test "X$hardcode_automatic_F77" = "Xyes" ; then
-
- # We can hardcode non-existant directories.
- if test "$hardcode_direct_F77" != no &&
- # If the only mechanism to avoid hardcoding is shlibpath_var, we
- # have to relink, otherwise we might link with an installed library
- # when we should be linking with a yet-to-be-installed one
- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, F77)" != no &&
- test "$hardcode_minus_L_F77" != no; then
- # Linking always hardcodes the temporary library directory.
- hardcode_action_F77=relink
- else
- # We can link without hardcoding, and we can hardcode nonexisting dirs.
- hardcode_action_F77=immediate
- fi
-else
- # We cannot hardcode anything, or else we can only hardcode existing
- # directories.
- hardcode_action_F77=unsupported
-fi
-echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5
-echo "${ECHO_T}$hardcode_action_F77" >&6
-
-if test "$hardcode_action_F77" = relink; then
- # Fast installation is not supported
- enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
- test "$enable_shared" = no; then
- # Fast installation is not necessary
- enable_fast_install=needless
-fi
-
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- compiler_F77 \
- CC_F77 \
- LD_F77 \
- lt_prog_compiler_wl_F77 \
- lt_prog_compiler_pic_F77 \
- lt_prog_compiler_static_F77 \
- lt_prog_compiler_no_builtin_flag_F77 \
- export_dynamic_flag_spec_F77 \
- thread_safe_flag_spec_F77 \
- whole_archive_flag_spec_F77 \
- enable_shared_with_static_runtimes_F77 \
- old_archive_cmds_F77 \
- old_archive_from_new_cmds_F77 \
- predep_objects_F77 \
- postdep_objects_F77 \
- predeps_F77 \
- postdeps_F77 \
- compiler_lib_search_path_F77 \
- archive_cmds_F77 \
- archive_expsym_cmds_F77 \
- postinstall_cmds_F77 \
- postuninstall_cmds_F77 \
- old_archive_from_expsyms_cmds_F77 \
- allow_undefined_flag_F77 \
- no_undefined_flag_F77 \
- export_symbols_cmds_F77 \
- hardcode_libdir_flag_spec_F77 \
- hardcode_libdir_flag_spec_ld_F77 \
- hardcode_libdir_separator_F77 \
- hardcode_automatic_F77 \
- module_cmds_F77 \
- module_expsym_cmds_F77 \
- lt_cv_prog_compiler_c_o_F77 \
- exclude_expsyms_F77 \
- include_expsyms_F77; do
-
- case $var in
- old_archive_cmds_F77 | \
- old_archive_from_new_cmds_F77 | \
- archive_cmds_F77 | \
- archive_expsym_cmds_F77 | \
- module_cmds_F77 | \
- module_expsym_cmds_F77 | \
- old_archive_from_expsyms_cmds_F77 | \
- export_symbols_cmds_F77 | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\$0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
- ;;
- esac
-
-cfgfile="$ofile"
-
- cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_F77
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler_F77
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_F77
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD_F77
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_F77
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_F77
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_F77
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_F77
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_F77
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_F77
-archive_expsym_cmds=$lt_archive_expsym_cmds_F77
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_F77
-module_expsym_cmds=$lt_module_expsym_cmds_F77
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_predep_objects_F77
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_postdep_objects_F77
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_F77
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_F77
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_F77
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_F77
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_F77
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_F77
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_F77
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_F77
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_F77
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_F77
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_F77
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_F77
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_F77"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_F77
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_F77
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_F77
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_F77
-
-# ### END LIBTOOL TAG CONFIG: $tagname
-
-__EOF__
-
-
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
- else
- tagname=""
- fi
- ;;
-
- GCJ)
- if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
-
-
-
-# Source file extension for Java test sources.
-ac_ext=java
-
-# Object file extension for compiled Java test sources.
-objext=o
-objext_GCJ=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="class foo {}\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${GCJ-"gcj"}
-compiler=$CC
-compiler_GCJ=$CC
-for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
-# GCJ did not exist at the time GCC didn't implicitly link libc in.
-archive_cmds_need_lc_GCJ=no
-
-old_archive_cmds_GCJ=$old_archive_cmds
-
-
-lt_prog_compiler_no_builtin_flag_GCJ=
-
-if test "$GCC" = yes; then
- lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin'
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
-echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_rtti_exceptions=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="-fno-rtti -fno-exceptions"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16264: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:16268: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_rtti_exceptions=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6
-
-if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
- lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions"
-else
- :
-fi
-
-fi
-
-lt_prog_compiler_wl_GCJ=
-lt_prog_compiler_pic_GCJ=
-lt_prog_compiler_static_GCJ=
-
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
-
- if test "$GCC" = yes; then
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_static_GCJ='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_GCJ='-Bstatic'
- fi
- ;;
-
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- lt_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4'
- ;;
-
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
- ;;
-
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- lt_prog_compiler_pic_GCJ='-fno-common'
- ;;
-
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
-
- msdosdjgpp*)
- # Just because we use GCC doesn't mean we suddenly get shared libraries
- # on systems that don't support them.
- lt_prog_compiler_can_build_shared_GCJ=no
- enable_shared=no
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- lt_prog_compiler_pic_GCJ=-Kconform_pic
- fi
- ;;
-
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic_GCJ='-fPIC'
- ;;
- esac
- ;;
-
- *)
- lt_prog_compiler_pic_GCJ='-fPIC'
- ;;
- esac
- else
- # PORTME Check for flag to pass linker flags through the system compiler.
- case $host_os in
- aix*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_GCJ='-Bstatic'
- else
- lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- lt_prog_compiler_pic_GCJ='-qnocommon'
- lt_prog_compiler_wl_GCJ='-Wl,'
- ;;
- esac
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
- ;;
-
- hpux9* | hpux10* | hpux11*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic_GCJ='+Z'
- ;;
- esac
- # Is there a better lt_prog_compiler_static that works with the bundled CC?
- lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive'
- ;;
-
- irix5* | irix6* | nonstopux*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- # PIC (with -KPIC) is the default.
- lt_prog_compiler_static_GCJ='-non_shared'
- ;;
-
- newsos6)
- lt_prog_compiler_pic_GCJ='-KPIC'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
-
- linux*)
- case $cc_basename in
- icc* | ecc*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_pic_GCJ='-KPIC'
- lt_prog_compiler_static_GCJ='-static'
- ;;
- pgcc* | pgf77* | pgf90* | pgf95*)
- # Portland Group compilers (*not* the Pentium gcc compiler,
- # which looks to be a dead project)
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_pic_GCJ='-fpic'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
- ccc*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- # All Alpha code is PIC.
- lt_prog_compiler_static_GCJ='-non_shared'
- ;;
- esac
- ;;
-
- osf3* | osf4* | osf5*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- # All OSF/1 code is PIC.
- lt_prog_compiler_static_GCJ='-non_shared'
- ;;
-
- solaris*)
- lt_prog_compiler_pic_GCJ='-KPIC'
- lt_prog_compiler_static_GCJ='-Bstatic'
- case $cc_basename in
- f77* | f90* | f95*)
- lt_prog_compiler_wl_GCJ='-Qoption ld ';;
- *)
- lt_prog_compiler_wl_GCJ='-Wl,';;
- esac
- ;;
-
- sunos4*)
- lt_prog_compiler_wl_GCJ='-Qoption ld '
- lt_prog_compiler_pic_GCJ='-PIC'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
-
- sysv4 | sysv4.2uw2* | sysv4.3*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_pic_GCJ='-KPIC'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec ;then
- lt_prog_compiler_pic_GCJ='-Kconform_pic'
- lt_prog_compiler_static_GCJ='-Bstatic'
- fi
- ;;
-
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_pic_GCJ='-KPIC'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
-
- unicos*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_can_build_shared_GCJ=no
- ;;
-
- uts4*)
- lt_prog_compiler_pic_GCJ='-pic'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
-
- *)
- lt_prog_compiler_can_build_shared_GCJ=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_GCJ" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_GCJ" >&6
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic_GCJ"; then
-
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_pic_works_GCJ=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="$lt_prog_compiler_pic_GCJ"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16532: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:16536: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_pic_works_GCJ=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_GCJ" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works_GCJ" >&6
-
-if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then
- case $lt_prog_compiler_pic_GCJ in
- "" | " "*) ;;
- *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;;
- esac
-else
- lt_prog_compiler_pic_GCJ=
- lt_prog_compiler_can_build_shared_GCJ=no
-fi
-
-fi
-case $host_os in
- # For platforms which do not support PIC, -DPIC is meaningless:
- *djgpp*)
- lt_prog_compiler_pic_GCJ=
- ;;
- *)
- lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ"
- ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_GCJ eval lt_tmp_static_flag=\"$lt_prog_compiler_static_GCJ\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works_GCJ+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_static_works_GCJ=no
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
- printf "$lt_simple_link_test_code" > conftest.$ac_ext
- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
- # The linker can only warn and ignore the option if not recognized
- # So say no if there are warnings
- if test -s conftest.err; then
- # Append any errors to the config.log.
- cat conftest.err 1>&5
- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_static_works_GCJ=yes
- fi
- else
- lt_prog_compiler_static_works_GCJ=yes
- fi
- fi
- $rm conftest*
- LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_GCJ" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_GCJ" >&6
-
-if test x"$lt_prog_compiler_static_works_GCJ" = xyes; then
- :
-else
- lt_prog_compiler_static_GCJ=
-fi
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_c_o_GCJ=no
- $rm -r conftest 2>/dev/null
- mkdir conftest
- cd conftest
- mkdir out
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- lt_compiler_flag="-o out/conftest2.$ac_objext"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16636: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>out/conftest.err)
- ac_status=$?
- cat out/conftest.err >&5
- echo "$as_me:16640: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s out/conftest2.$ac_objext
- then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_c_o_GCJ=yes
- fi
- fi
- chmod u+w . 2>&5
- $rm conftest*
- # SGI C++ compiler will create directory out/ii_files/ for
- # template instantiation
- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
- $rm out/* && rmdir out
- cd ..
- rmdir conftest
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_GCJ" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o_GCJ" >&6
-
-
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then
- # do not overwrite the value of need_locks provided by the user
- echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
- hard_links=yes
- $rm conftest*
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- touch conftest.a
- ln conftest.a conftest.b 2>&5 || hard_links=no
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
- if test "$hard_links" = no; then
- { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
- need_locks=warn
- fi
-else
- need_locks=no
-fi
-
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-
- runpath_var=
- allow_undefined_flag_GCJ=
- enable_shared_with_static_runtimes_GCJ=no
- archive_cmds_GCJ=
- archive_expsym_cmds_GCJ=
- old_archive_From_new_cmds_GCJ=
- old_archive_from_expsyms_cmds_GCJ=
- export_dynamic_flag_spec_GCJ=
- whole_archive_flag_spec_GCJ=
- thread_safe_flag_spec_GCJ=
- hardcode_libdir_flag_spec_GCJ=
- hardcode_libdir_flag_spec_ld_GCJ=
- hardcode_libdir_separator_GCJ=
- hardcode_direct_GCJ=no
- hardcode_minus_L_GCJ=no
- hardcode_shlibpath_var_GCJ=unsupported
- link_all_deplibs_GCJ=unknown
- hardcode_automatic_GCJ=no
- module_cmds_GCJ=
- module_expsym_cmds_GCJ=
- always_export_symbols_GCJ=no
- export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- # include_expsyms should be a list of space-separated symbols to be *always*
- # included in the symbol list
- include_expsyms_GCJ=
- # exclude_expsyms can be an extended regexp of symbols to exclude
- # it will be wrapped by ` (' and `)$', so one must not match beginning or
- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
- # as well as any symbol that contains `d'.
- exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_"
- # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
- # platforms (ab)use it in PIC code, but their linkers get confused if
- # the symbol is explicitly referenced. Since portable code cannot
- # rely on this symbol name, it's probably fine to never include it in
- # preloaded symbol tables.
- extract_expsyms_cmds=
- # Just being paranoid about ensuring that cc_basename is set.
- for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
- case $host_os in
- cygwin* | mingw* | pw32*)
- # FIXME: the MSVC++ port hasn't been tested in a loooong time
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- if test "$GCC" != yes; then
- with_gnu_ld=no
- fi
- ;;
- interix*)
- # we just hope/assume this is gcc and not c89 (= MSVC++)
- with_gnu_ld=yes
- ;;
- openbsd*)
- with_gnu_ld=no
- ;;
- esac
-
- ld_shlibs_GCJ=yes
- if test "$with_gnu_ld" = yes; then
- # If archive_cmds runs LD, not CC, wlarc should be empty
- wlarc='${wl}'
-
- # Set some defaults for GNU ld with shared library support. These
- # are reset later if shared libraries are not supported. Putting them
- # here allows them to be overridden if necessary.
- runpath_var=LD_RUN_PATH
- hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir'
- export_dynamic_flag_spec_GCJ='${wl}--export-dynamic'
- # ancient GNU ld didn't support --whole-archive et. al.
- if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
- whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- whole_archive_flag_spec_GCJ=
- fi
- supports_anon_versioning=no
- case `$LD -v 2>/dev/null` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
- *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
- *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
- *\ 2.11.*) ;; # other 2.11 versions
- *) supports_anon_versioning=yes ;;
- esac
-
- # See if GNU ld supports shared libraries.
- case $host_os in
- aix3* | aix4* | aix5*)
- # On AIX/PPC, the GNU linker is very broken
- if test "$host_cpu" != ia64; then
- ld_shlibs_GCJ=no
- cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support. If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
- fi
- ;;
-
- amigaos*)
- archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_minus_L_GCJ=yes
-
- # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
- # that the semantics of dynamic libraries on AmigaOS, at least up
- # to version 4, is to share data among multiple programs linked
- # with the same dynamic library. Since this doesn't match the
- # behavior of shared libraries on other platforms, we can't use
- # them.
- ld_shlibs_GCJ=no
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- allow_undefined_flag_GCJ=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- ld_shlibs_GCJ=no
- fi
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless,
- # as there is no search path for DLLs.
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- allow_undefined_flag_GCJ=unsupported
- always_export_symbols_GCJ=no
- enable_shared_with_static_runtimes_GCJ=yes
- export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- ld_shlibs_GCJ=no
- fi
- ;;
-
- interix3*)
- hardcode_direct_GCJ=no
- hardcode_shlibpath_var_GCJ=no
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_GCJ='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- archive_cmds_GCJ='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- archive_expsym_cmds_GCJ='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
-
- linux*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- tmp_addflag=
- case $cc_basename,$host_cpu in
- pgcc*) # Portland Group C compiler
- whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag'
- ;;
- pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
- whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag -Mnomain' ;;
- ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
- tmp_addflag=' -i_dynamic' ;;
- efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
- tmp_addflag=' -i_dynamic -nofor_main' ;;
- ifc* | ifort*) # Intel Fortran compiler
- tmp_addflag=' -nofor_main' ;;
- esac
- archive_cmds_GCJ='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
- if test $supports_anon_versioning = yes; then
- archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- $echo "local: *; };" >> $output_objdir/$libname.ver~
- $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
- fi
- link_all_deplibs_GCJ=no
- else
- ld_shlibs_GCJ=no
- fi
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
- wlarc=
- else
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- fi
- ;;
-
- solaris*)
- if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
- ld_shlibs_GCJ=no
- cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-EOF
- elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs_GCJ=no
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
- case `$LD -v 2>&1` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
- ld_shlibs_GCJ=no
- cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
- ;;
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
- archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
- else
- ld_shlibs_GCJ=no
- fi
- ;;
- esac
- ;;
-
- sunos4*)
- archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- wlarc=
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs_GCJ=no
- fi
- ;;
- esac
-
- if test "$ld_shlibs_GCJ" = no; then
- runpath_var=
- hardcode_libdir_flag_spec_GCJ=
- export_dynamic_flag_spec_GCJ=
- whole_archive_flag_spec_GCJ=
- fi
- else
- # PORTME fill in a description of your system's linker (not GNU ld)
- case $host_os in
- aix3*)
- allow_undefined_flag_GCJ=unsupported
- always_export_symbols_GCJ=yes
- archive_expsym_cmds_GCJ='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
- # Note: this linker hardcodes the directories in LIBPATH if there
- # are no directories specified by -L.
- hardcode_minus_L_GCJ=yes
- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
- # Neither direct hardcoding nor static linking is supported with a
- # broken collect2.
- hardcode_direct_GCJ=unsupported
- fi
- ;;
-
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- else
- export_symbols_cmds_GCJ='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- fi
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[23]|aix4.[23].*|aix5*)
- for ld_flag in $LDFLAGS; do
- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
- aix_use_runtimelinking=yes
- break
- fi
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- archive_cmds_GCJ=''
- hardcode_direct_GCJ=yes
- hardcode_libdir_separator_GCJ=':'
- link_all_deplibs_GCJ=yes
-
- if test "$GCC" = yes; then
- case $host_os in aix4.[012]|aix4.[012].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- hardcode_direct_GCJ=yes
- else
- # We have old collect2
- hardcode_direct_GCJ=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- hardcode_minus_L_GCJ=yes
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_libdir_separator_GCJ=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- always_export_symbols_GCJ=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- allow_undefined_flag_GCJ='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
- archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib'
- allow_undefined_flag_GCJ="-z nodefs"
- archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- no_undefined_flag_GCJ=' ${wl}-bernotok'
- allow_undefined_flag_GCJ=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- whole_archive_flag_spec_GCJ='$convenience'
- archive_cmds_need_lc_GCJ=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- amigaos*)
- archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_minus_L_GCJ=yes
- # see comment about different semantics on the GNU ld section
- ld_shlibs_GCJ=no
- ;;
-
- bsdi[45]*)
- export_dynamic_flag_spec_GCJ=-rdynamic
- ;;
-
- cygwin* | mingw* | pw32*)
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- # hardcode_libdir_flag_spec is actually meaningless, as there is
- # no search path for DLLs.
- hardcode_libdir_flag_spec_GCJ=' '
- allow_undefined_flag_GCJ=unsupported
- # Tell ltmain to make .lib files, not .a files.
- libext=lib
- # Tell ltmain to make .dll files, not .so files.
- shrext_cmds=".dll"
- # FIXME: Setting linknames here is a bad hack.
- archive_cmds_GCJ='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
- # The linker will automatically build a .lib file if we build a DLL.
- old_archive_From_new_cmds_GCJ='true'
- # FIXME: Should let the user specify the lib program.
- old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs'
- fix_srcfile_path_GCJ='`cygpath -w "$srcfile"`'
- enable_shared_with_static_runtimes_GCJ=yes
- ;;
-
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[012])
- allow_undefined_flag_GCJ='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[012])
- allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- allow_undefined_flag_GCJ='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- archive_cmds_need_lc_GCJ=no
- hardcode_direct_GCJ=no
- hardcode_automatic_GCJ=yes
- hardcode_shlibpath_var_GCJ=unsupported
- whole_archive_flag_spec_GCJ=''
- link_all_deplibs_GCJ=yes
- if test "$GCC" = yes ; then
- output_verbose_link_cmd='echo'
- archive_cmds_GCJ='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- archive_cmds_GCJ='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- ld_shlibs_GCJ=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- freebsd1*)
- ld_shlibs_GCJ=no
- ;;
-
- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
- # support. Future versions do this automatically, but an explicit c++rt0.o
- # does not break anything, and helps significantly (at the cost of a little
- # extra space).
- freebsd2.2*)
- archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- # Unfortunately, older versions of FreeBSD 2 do not have this feature.
- freebsd2*)
- archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_GCJ=yes
- hardcode_minus_L_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
- freebsd* | dragonfly*)
- archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- # GNU/kFreeBSD uses gcc -shared to do shared libraries.
- kfreebsd*-gnu)
- archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- link_all_deplibs_GCJ=no
- ;;
-
- hpux9*)
- if test "$GCC" = yes; then
- archive_cmds_GCJ='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- archive_cmds_GCJ='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- fi
- hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
- hardcode_direct_GCJ=yes
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_GCJ=yes
- export_dynamic_flag_spec_GCJ='${wl}-E'
- ;;
-
- hpux10*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
-
- hardcode_direct_GCJ=yes
- export_dynamic_flag_spec_GCJ='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_GCJ=yes
- fi
- ;;
-
- hpux11*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- case $host_cpu in
- hppa*64*)
- archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- else
- case $host_cpu in
- hppa*64*)
- archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- hardcode_libdir_flag_spec_ld_GCJ='+b $libdir'
- hardcode_direct_GCJ=no
- hardcode_shlibpath_var_GCJ=no
- ;;
- *)
- hardcode_direct_GCJ=yes
- export_dynamic_flag_spec_GCJ='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_GCJ=yes
- ;;
- esac
- fi
- ;;
-
- irix5* | irix6* | nonstopux*)
- if test "$GCC" = yes; then
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- archive_cmds_GCJ='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec_ld_GCJ='-rpath $libdir'
- fi
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
- link_all_deplibs_GCJ=yes
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
- else
- archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
- fi
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- newsos6)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_GCJ=yes
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- openbsd*)
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_GCJ='${wl}-E'
- else
- case $host_os in
- openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
- archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- ;;
- *)
- archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
- ;;
- esac
- fi
- ;;
-
- os2*)
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_minus_L_GCJ=yes
- allow_undefined_flag_GCJ=unsupported
- archive_cmds_GCJ='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
- old_archive_From_new_cmds_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
- ;;
-
- osf3*)
- if test "$GCC" = yes; then
- allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- allow_undefined_flag_GCJ=' -expect_unresolved \*'
- archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- fi
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
- ;;
-
- osf4* | osf5*) # as osf3* with the addition of -msym flag
- if test "$GCC" = yes; then
- allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
- else
- allow_undefined_flag_GCJ=' -expect_unresolved \*'
- archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
-
- # Both c and cxx compiler support -rpath directly
- hardcode_libdir_flag_spec_GCJ='-rpath $libdir'
- fi
- hardcode_libdir_separator_GCJ=:
- ;;
-
- solaris*)
- no_undefined_flag_GCJ=' -z text'
- if test "$GCC" = yes; then
- wlarc='${wl}'
- archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
- else
- wlarc=''
- archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
- archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
- fi
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- hardcode_shlibpath_var_GCJ=no
- case $host_os in
- solaris2.[0-5] | solaris2.[0-5].*) ;;
- *)
- # The compiler driver will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl, iff we do not link with $LD.
- # Luckily, gcc supports the same syntax we need for Sun Studio.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- case $wlarc in
- '')
- whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;;
- *)
- whole_archive_flag_spec_GCJ='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- esac ;;
- esac
- link_all_deplibs_GCJ=yes
- ;;
-
- sunos4*)
- if test "x$host_vendor" = xsequent; then
- # Use $CC to link under sequent, because it throws in some extra .o
- # files that make .init and .fini sections work.
- archive_cmds_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
- fi
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_direct_GCJ=yes
- hardcode_minus_L_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- sysv4)
- case $host_vendor in
- sni)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_GCJ=yes # is this really true???
- ;;
- siemens)
- ## LD is ld it makes a PLAMLIB
- ## CC just makes a GrossModule.
- archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags'
- reload_cmds_GCJ='$CC -r -o $output$reload_objs'
- hardcode_direct_GCJ=no
- ;;
- motorola)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie
- ;;
- esac
- runpath_var='LD_RUN_PATH'
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- sysv4.3*)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var_GCJ=no
- export_dynamic_flag_spec_GCJ='-Bexport'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var_GCJ=no
- runpath_var=LD_RUN_PATH
- hardcode_runpath_var=yes
- ld_shlibs_GCJ=yes
- fi
- ;;
-
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
- no_undefined_flag_GCJ='${wl}-z,text'
- archive_cmds_need_lc_GCJ=no
- hardcode_shlibpath_var_GCJ=no
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds_GCJ='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_GCJ='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- no_undefined_flag_GCJ='${wl}-z,text'
- allow_undefined_flag_GCJ='${wl}-z,nodefs'
- archive_cmds_need_lc_GCJ=no
- hardcode_shlibpath_var_GCJ=no
- hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- hardcode_libdir_separator_GCJ=':'
- link_all_deplibs_GCJ=yes
- export_dynamic_flag_spec_GCJ='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds_GCJ='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_GCJ='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- uts4*)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- *)
- ld_shlibs_GCJ=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $ld_shlibs_GCJ" >&5
-echo "${ECHO_T}$ld_shlibs_GCJ" >&6
-test "$ld_shlibs_GCJ" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc_GCJ" in
-x|xyes)
- # Assume -lc should be added
- archive_cmds_need_lc_GCJ=yes
-
- if test "$enable_shared" = yes && test "$GCC" = yes; then
- case $archive_cmds_GCJ in
- *'~'*)
- # FIXME: we may have to deal with multi-command sequences.
- ;;
- '$CC '*)
- # Test whether the compiler implicitly links with -lc since on some
- # systems, -lgcc has to come before -lc. If gcc already passes -lc
- # to ld, don't add -lc before -lgcc.
- echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
- $rm conftest*
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } 2>conftest.err; then
- soname=conftest
- lib=conftest
- libobjs=conftest.$ac_objext
- deplibs=
- wl=$lt_prog_compiler_wl_GCJ
- pic_flag=$lt_prog_compiler_pic_GCJ
- compiler_flags=-v
- linker_flags=-v
- verstring=
- output_objdir=.
- libname=conftest
- lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ
- allow_undefined_flag_GCJ=
- if { (eval echo "$as_me:$LINENO: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
- (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
- then
- archive_cmds_need_lc_GCJ=no
- else
- archive_cmds_need_lc_GCJ=yes
- fi
- allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag
- else
- cat conftest.err 1>&5
- fi
- $rm conftest*
- echo "$as_me:$LINENO: result: $archive_cmds_need_lc_GCJ" >&5
-echo "${ECHO_T}$archive_cmds_need_lc_GCJ" >&6
- ;;
- esac
- fi
- ;;
-esac
-
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
- # if the path contains ";" then we assume it to be the separator
- # otherwise default to the standard path separator (i.e. ":") - it is
- # assumed that no part of a normal pathname contains ";" but that should
- # okay in the real world where ";" in dirpaths is itself problematic.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
-else
- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
- shlibpath_var=LIBPATH
-
- # AIX 3 has no versioning support, so we append a major version to the name.
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
-
-aix4* | aix5*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- hardcode_into_libs=yes
- if test "$host_cpu" = ia64; then
- # AIX 5 supports IA64
- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- else
- # With GCC up to 2.95.x, collect2 would create an import file
- # for dependence libraries. The import file would start with
- # the line `#! .'. This would cause the generated library to
- # depend on `.', always an invalid library. This was fixed in
- # development snapshots of GCC prior to 3.0.
- case $host_os in
- aix4 | aix4.[01] | aix4.[01].*)
- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
- echo ' yes '
- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
- :
- else
- can_build_shared=no
- fi
- ;;
- esac
- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
- # soname into executable. Probably we can add versioning support to
- # collect2, so additional links can be useful in future.
- if test "$aix_use_runtimelinking" = yes; then
- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
- # instead of lib<name>.a to let people know that these are not
- # typical AIX shared libraries.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- else
- # We preserve .a as extension for shared libraries through AIX4.2
- # and later when we are not doing run time linking.
- library_names_spec='${libname}${release}.a $libname.a'
- soname_spec='${libname}${release}${shared_ext}$major'
- fi
- shlibpath_var=LIBPATH
- fi
- ;;
-
-amigaos*)
- library_names_spec='$libname.ixlibrary $libname.a'
- # Create ${libname}_ixlibrary.a entries in /sys/libs.
- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
- ;;
-
-beos*)
- library_names_spec='${libname}${shared_ext}'
- dynamic_linker="$host_os ld.so"
- shlibpath_var=LIBRARY_PATH
- ;;
-
-bsdi[45]*)
- version_type=linux
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
- # the default ld.so.conf also contains /usr/contrib/lib and
- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
- # libtool to hard-code these into programs
- ;;
-
-cygwin* | mingw* | pw32*)
- version_type=windows
- shrext_cmds=".dll"
- need_version=no
- need_lib_prefix=no
-
- case $GCC,$host_os in
- yes,cygwin* | yes,mingw* | yes,pw32*)
- library_names_spec='$libname.dll.a'
- # DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
- dldir=$destdir/`dirname \$dlpath`~
- test -d \$dldir || mkdir -p \$dldir~
- $install_prog $dir/$dlname \$dldir/$dlname~
- chmod a+x \$dldir/$dlname'
- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
- dlpath=$dir/\$dldll~
- $rm \$dlpath'
- shlibpath_overrides_runpath=yes
-
- case $host_os in
- cygwin*)
- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
- ;;
- mingw*)
- # MinGW DLLs use traditional 'lib' prefix
- soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
- # It is most probably a Windows format PATH printed by
- # mingw gcc, but we are running on Cygwin. Gcc prints its search
- # path with ; separators, and with drive letters. We can handle the
- # drive letters (cygwin fileutils understands them), so leave them,
- # especially as we might pass files found there to a mingw objdump,
- # which wouldn't understand a cygwinified path. Ahh.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
- ;;
- pw32*)
- # pw32 DLLs use 'pw' prefix rather than 'lib'
- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- ;;
- esac
- ;;
-
- *)
- library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
- ;;
- esac
- dynamic_linker='Win32 ld.exe'
- # FIXME: first we should search . and the directory the executable is in
- shlibpath_var=PATH
- ;;
-
-darwin* | rhapsody*)
- dynamic_linker="$host_os dyld"
- version_type=darwin
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
- soname_spec='${libname}${release}${major}$shared_ext'
- shlibpath_overrides_runpath=yes
- shlibpath_var=DYLD_LIBRARY_PATH
- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
- if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
- else
- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
- fi
- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
- ;;
-
-dgux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-freebsd1*)
- dynamic_linker=no
- ;;
-
-kfreebsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-freebsd* | dragonfly*)
- # DragonFly does not have aout. When/if they implement a new
- # versioning mechanism, adjust this.
- if test -x /usr/bin/objformat; then
- objformat=`/usr/bin/objformat`
- else
- case $host_os in
- freebsd[123]*) objformat=aout ;;
- *) objformat=elf ;;
- esac
- fi
- version_type=freebsd-$objformat
- case $version_type in
- freebsd-elf*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- need_version=no
- need_lib_prefix=no
- ;;
- freebsd-*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
- need_version=yes
- ;;
- esac
- shlibpath_var=LD_LIBRARY_PATH
- case $host_os in
- freebsd2*)
- shlibpath_overrides_runpath=yes
- ;;
- freebsd3.[01]* | freebsdelf3.[01]*)
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
- freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
- freebsd*) # from 4.6 on
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- esac
- ;;
-
-gnu*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- ;;
-
-hpux9* | hpux10* | hpux11*)
- # Give a soname corresponding to the major version so that dld.sl refuses to
- # link against other versions.
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- case $host_cpu in
- ia64*)
- shrext_cmds='.so'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.so"
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- if test "X$HPUX_IA64_MODE" = X32; then
- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
- else
- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
- fi
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- hppa*64*)
- shrext_cmds='.sl'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- *)
- shrext_cmds='.sl'
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=SHLIB_PATH
- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
- esac
- # HP-UX runs *really* slowly unless shared libraries are mode 555.
- postinstall_cmds='chmod 555 $lib'
- ;;
-
-interix3*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $host_os in
- nonstopux*) version_type=nonstopux ;;
- *)
- if test "$lt_cv_prog_gnu_ld" = yes; then
- version_type=linux
- else
- version_type=irix
- fi ;;
- esac
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
- case $host_os in
- irix5* | nonstopux*)
- libsuff= shlibsuff=
- ;;
- *)
- case $LD in # libtool.m4 will add one of these switches to LD
- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
- libsuff= shlibsuff= libmagic=32-bit;;
- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
- libsuff=32 shlibsuff=N32 libmagic=N32;;
- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
- libsuff=64 shlibsuff=64 libmagic=64-bit;;
- *) libsuff= shlibsuff= libmagic=never-match;;
- esac
- ;;
- esac
- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
- hardcode_into_libs=yes
- ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
- dynamic_linker=no
- ;;
-
-# This must be Linux ELF.
-linux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- # This implies no fast_install, which is unacceptable.
- # Some rework will be needed to allow for fast_install
- # before this can be enabled.
- hardcode_into_libs=yes
-
- # Append ld.so.conf contents to the search path
- if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
- fi
-
- # We used to test for /lib/ld.so.1 and disable shared libraries on
- # powerpc, because MkLinux only supported shared libraries with the
- # GNU dynamic linker. Since this was broken with cross compilers,
- # most powerpc-linux boxes support dynamic linking these days and
- # people can always --disable-shared, the test was removed, and we
- # assume the GNU/Linux dynamic linker is in use.
- dynamic_linker='GNU/Linux ld.so'
- ;;
-
-netbsdelf*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='NetBSD ld.elf_so'
- ;;
-
-knetbsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-netbsd*)
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- dynamic_linker='NetBSD (a.out) ld.so'
- else
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='NetBSD ld.elf_so'
- fi
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
-
-newsos6)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-nto-qnx*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-openbsd*)
- version_type=sunos
- sys_lib_dlsearch_path_spec="/usr/lib"
- need_lib_prefix=no
- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
- case $host_os in
- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
- *) need_version=no ;;
- esac
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- case $host_os in
- openbsd2.[89] | openbsd2.[89].*)
- shlibpath_overrides_runpath=no
- ;;
- *)
- shlibpath_overrides_runpath=yes
- ;;
- esac
- else
- shlibpath_overrides_runpath=yes
- fi
- ;;
-
-os2*)
- libname_spec='$name'
- shrext_cmds=".dll"
- need_lib_prefix=no
- library_names_spec='$libname${shared_ext} $libname.a'
- dynamic_linker='OS/2 ld.exe'
- shlibpath_var=LIBPATH
- ;;
-
-osf3* | osf4* | osf5*)
- version_type=osf
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
- ;;
-
-solaris*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- # ldd complains unless libraries are executable
- postinstall_cmds='chmod +x $lib'
- ;;
-
-sunos4*)
- version_type=sunos
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- if test "$with_gnu_ld" = yes; then
- need_lib_prefix=no
- fi
- need_version=yes
- ;;
-
-sysv4 | sysv4.3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- case $host_vendor in
- sni)
- shlibpath_overrides_runpath=no
- need_lib_prefix=no
- export_dynamic_flag_spec='${wl}-Blargedynsym'
- runpath_var=LD_RUN_PATH
- ;;
- siemens)
- need_lib_prefix=no
- ;;
- motorola)
- need_lib_prefix=no
- need_version=no
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
- ;;
- esac
- ;;
-
-sysv4*MP*)
- if test -d /usr/nec ;then
- version_type=linux
- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
- soname_spec='$libname${shared_ext}.$major'
- shlibpath_var=LD_LIBRARY_PATH
- fi
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- version_type=freebsd-elf
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- if test "$with_gnu_ld" = yes; then
- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
- shlibpath_overrides_runpath=no
- else
- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
- shlibpath_overrides_runpath=yes
- case $host_os in
- sco3.2v5*)
- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
- ;;
- esac
- fi
- sys_lib_dlsearch_path_spec='/usr/lib'
- ;;
-
-uts4*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-*)
- dynamic_linker=no
- ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action_GCJ=
-if test -n "$hardcode_libdir_flag_spec_GCJ" || \
- test -n "$runpath_var_GCJ" || \
- test "X$hardcode_automatic_GCJ" = "Xyes" ; then
-
- # We can hardcode non-existant directories.
- if test "$hardcode_direct_GCJ" != no &&
- # If the only mechanism to avoid hardcoding is shlibpath_var, we
- # have to relink, otherwise we might link with an installed library
- # when we should be linking with a yet-to-be-installed one
- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no &&
- test "$hardcode_minus_L_GCJ" != no; then
- # Linking always hardcodes the temporary library directory.
- hardcode_action_GCJ=relink
- else
- # We can link without hardcoding, and we can hardcode nonexisting dirs.
- hardcode_action_GCJ=immediate
- fi
-else
- # We cannot hardcode anything, or else we can only hardcode existing
- # directories.
- hardcode_action_GCJ=unsupported
-fi
-echo "$as_me:$LINENO: result: $hardcode_action_GCJ" >&5
-echo "${ECHO_T}$hardcode_action_GCJ" >&6
-
-if test "$hardcode_action_GCJ" = relink; then
- # Fast installation is not supported
- enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
- test "$enable_shared" = no; then
- # Fast installation is not necessary
- enable_fast_install=needless
-fi
-
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- compiler_GCJ \
- CC_GCJ \
- LD_GCJ \
- lt_prog_compiler_wl_GCJ \
- lt_prog_compiler_pic_GCJ \
- lt_prog_compiler_static_GCJ \
- lt_prog_compiler_no_builtin_flag_GCJ \
- export_dynamic_flag_spec_GCJ \
- thread_safe_flag_spec_GCJ \
- whole_archive_flag_spec_GCJ \
- enable_shared_with_static_runtimes_GCJ \
- old_archive_cmds_GCJ \
- old_archive_from_new_cmds_GCJ \
- predep_objects_GCJ \
- postdep_objects_GCJ \
- predeps_GCJ \
- postdeps_GCJ \
- compiler_lib_search_path_GCJ \
- archive_cmds_GCJ \
- archive_expsym_cmds_GCJ \
- postinstall_cmds_GCJ \
- postuninstall_cmds_GCJ \
- old_archive_from_expsyms_cmds_GCJ \
- allow_undefined_flag_GCJ \
- no_undefined_flag_GCJ \
- export_symbols_cmds_GCJ \
- hardcode_libdir_flag_spec_GCJ \
- hardcode_libdir_flag_spec_ld_GCJ \
- hardcode_libdir_separator_GCJ \
- hardcode_automatic_GCJ \
- module_cmds_GCJ \
- module_expsym_cmds_GCJ \
- lt_cv_prog_compiler_c_o_GCJ \
- exclude_expsyms_GCJ \
- include_expsyms_GCJ; do
-
- case $var in
- old_archive_cmds_GCJ | \
- old_archive_from_new_cmds_GCJ | \
- archive_cmds_GCJ | \
- archive_expsym_cmds_GCJ | \
- module_cmds_GCJ | \
- module_expsym_cmds_GCJ | \
- old_archive_from_expsyms_cmds_GCJ | \
- export_symbols_cmds_GCJ | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\$0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
- ;;
- esac
-
-cfgfile="$ofile"
-
- cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_GCJ
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_GCJ
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler_GCJ
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_GCJ
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD_GCJ
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_GCJ
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_GCJ
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_GCJ
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_GCJ
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_GCJ
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_GCJ
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_GCJ
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_GCJ
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_GCJ
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_GCJ
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_GCJ
-archive_expsym_cmds=$lt_archive_expsym_cmds_GCJ
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_GCJ
-module_expsym_cmds=$lt_module_expsym_cmds_GCJ
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_predep_objects_GCJ
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_postdep_objects_GCJ
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_GCJ
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_GCJ
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_GCJ
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_GCJ
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_GCJ
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_GCJ
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_GCJ
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_GCJ
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_GCJ
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_GCJ
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_GCJ
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_GCJ
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_GCJ
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_GCJ
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_GCJ"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_GCJ
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_GCJ
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_GCJ
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_GCJ
-
-# ### END LIBTOOL TAG CONFIG: $tagname
-
-__EOF__
-
-
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
- else
- tagname=""
- fi
- ;;
-
- RC)
-
-
-
-# Source file extension for RC test sources.
-ac_ext=rc
-
-# Object file extension for compiled RC test sources.
-objext=o
-objext_RC=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
-
-# Code to be used in simple link tests
-lt_simple_link_test_code="$lt_simple_compile_test_code"
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${RC-"windres"}
-compiler=$CC
-compiler_RC=$CC
-for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-lt_cv_prog_compiler_c_o_RC=yes
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- compiler_RC \
- CC_RC \
- LD_RC \
- lt_prog_compiler_wl_RC \
- lt_prog_compiler_pic_RC \
- lt_prog_compiler_static_RC \
- lt_prog_compiler_no_builtin_flag_RC \
- export_dynamic_flag_spec_RC \
- thread_safe_flag_spec_RC \
- whole_archive_flag_spec_RC \
- enable_shared_with_static_runtimes_RC \
- old_archive_cmds_RC \
- old_archive_from_new_cmds_RC \
- predep_objects_RC \
- postdep_objects_RC \
- predeps_RC \
- postdeps_RC \
- compiler_lib_search_path_RC \
- archive_cmds_RC \
- archive_expsym_cmds_RC \
- postinstall_cmds_RC \
- postuninstall_cmds_RC \
- old_archive_from_expsyms_cmds_RC \
- allow_undefined_flag_RC \
- no_undefined_flag_RC \
- export_symbols_cmds_RC \
- hardcode_libdir_flag_spec_RC \
- hardcode_libdir_flag_spec_ld_RC \
- hardcode_libdir_separator_RC \
- hardcode_automatic_RC \
- module_cmds_RC \
- module_expsym_cmds_RC \
- lt_cv_prog_compiler_c_o_RC \
- exclude_expsyms_RC \
- include_expsyms_RC; do
-
- case $var in
- old_archive_cmds_RC | \
- old_archive_from_new_cmds_RC | \
- archive_cmds_RC | \
- archive_expsym_cmds_RC | \
- module_cmds_RC | \
- module_expsym_cmds_RC | \
- old_archive_from_expsyms_cmds_RC | \
- export_symbols_cmds_RC | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\$0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
- ;;
- esac
-
-cfgfile="$ofile"
-
- cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_RC
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler_RC
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_RC
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD_RC
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_RC
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_RC
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_RC
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_RC
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_RC
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_RC
-archive_expsym_cmds=$lt_archive_expsym_cmds_RC
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_RC
-module_expsym_cmds=$lt_module_expsym_cmds_RC
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_predep_objects_RC
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_postdep_objects_RC
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_RC
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_RC
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_RC
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_RC
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_RC
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_RC
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_RC
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_RC
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_RC
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_RC
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_RC
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_RC
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_RC"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_RC
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_RC
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_RC
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_RC
-
-# ### END LIBTOOL TAG CONFIG: $tagname
-
-__EOF__
-
-
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
- ;;
-
- *)
- { { echo "$as_me:$LINENO: error: Unsupported tag name: $tagname" >&5
-echo "$as_me: error: Unsupported tag name: $tagname" >&2;}
- { (exit 1); exit 1; }; }
- ;;
- esac
-
- # Append the new tag name to the list of available tags.
- if test -n "$tagname" ; then
- available_tags="$available_tags $tagname"
- fi
- fi
- done
- IFS="$lt_save_ifs"
-
- # Now substitute the updated list of available tags.
- if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
- mv "${ofile}T" "$ofile"
- chmod +x "$ofile"
- else
- rm -f "${ofile}T"
- { { echo "$as_me:$LINENO: error: unable to update list of available tagged configurations." >&5
-echo "$as_me: error: unable to update list of available tagged configurations." >&2;}
- { (exit 1); exit 1; }; }
- fi
-fi
-
-
-
-# This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
-
-# Always use our own libtool.
-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
-
-# Prevent multiple expansion
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ac_config_files="$ac_config_files Makefile json.pc"
-cat >confcache <<\_ACEOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs, see configure's option --config-cache.
-# It is not useful on other systems. If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
-
-_ACEOF
-
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, don't put newlines in cache variables' values.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-{
- (set) 2>&1 |
- case `(ac_space=' '; set | grep ac_space) 2>&1` in
- *ac_space=\ *)
- # `set' does not quote correctly, so add quotes (double-quote
- # substitution turns \\\\ into \\, and sed turns \\ into \).
- sed -n \
- "s/'/'\\\\''/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
- ;;
- *)
- # `set' quotes correctly as required by POSIX, so do not add quotes.
- sed -n \
- "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
- ;;
- esac;
-} |
- sed '
- t clear
- : clear
- s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
- t end
- /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
- : end' >>confcache
-if diff $cache_file confcache >/dev/null 2>&1; then :; else
- if test -w $cache_file; then
- test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
- cat confcache >$cache_file
- else
- echo "not updating unwritable cache $cache_file"
- fi
-fi
-rm -f confcache
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# VPATH may cause trouble with some makes, so we remove $(srcdir),
-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=/{
-s/:*\$(srcdir):*/:/;
-s/:*\${srcdir}:*/:/;
-s/:*@srcdir@:*/:/;
-s/^\([^=]*=[ ]*\):*/\1/;
-s/:*$//;
-s/^[^=]*=[ ]*$//;
-}'
-fi
-
-DEFS=-DHAVE_CONFIG_H
-
-ac_libobjs=
-ac_ltlibobjs=
-for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
- # 1. Remove the extension, and $U if already installed.
- ac_i=`echo "$ac_i" |
- sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
- # 2. Add them.
- ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
- ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
-done
-LIBOBJS=$ac_libobjs
-
-LTLIBOBJS=$ac_ltlibobjs
-
-
-
-: ${CONFIG_STATUS=./config.status}
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
-echo "$as_me: creating $CONFIG_STATUS" >&6;}
-cat >$CONFIG_STATUS <<_ACEOF
-#! $SHELL
-# Generated by $as_me.
-# Run this file to recreate the current configuration.
-# Compiler output produced by configure, useful for debugging
-# configure, is in config.log if it exists.
-
-debug=false
-ac_cs_recheck=false
-ac_cs_silent=false
-SHELL=\${CONFIG_SHELL-$SHELL}
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-## --------------------- ##
-## M4sh Initialization. ##
-## --------------------- ##
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
- set -o posix
-fi
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
- as_unset=unset
-else
- as_unset=false
-fi
-
-
-# Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-for as_var in \
- LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
- LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
- LC_TELEPHONE LC_TIME
-do
- if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
- eval $as_var=C; export $as_var
- else
- $as_unset $as_var
- fi
-done
-
-# Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-
-
-# Name of the executable.
-as_me=`$as_basename "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)$' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X/"$0" |
- sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
- /^X\/\(\/\/\)$/{ s//\1/; q; }
- /^X\/\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
-
-
-# PATH needs CR, and LINENO needs CR and PATH.
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- echo "#! /bin/sh" >conf$$.sh
- echo "exit 0" >>conf$$.sh
- chmod +x conf$$.sh
- if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
- PATH_SEPARATOR=';'
- else
- PATH_SEPARATOR=:
- fi
- rm -f conf$$.sh
-fi
-
-
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" || {
- # Find who we are. Look in the path if we contain no path at all
- # relative or not.
- case $0 in
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
-
- ;;
- esac
- # We did not find ourselves, most probably we were run as `sh COMMAND'
- # in which case we are not to be found in the path.
- if test "x$as_myself" = x; then
- as_myself=$0
- fi
- if test ! -f "$as_myself"; then
- { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
-echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
- { (exit 1); exit 1; }; }
- fi
- case $CONFIG_SHELL in
- '')
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for as_base in sh bash ksh sh5; do
- case $as_dir in
- /*)
- if ("$as_dir/$as_base" -c '
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
- $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
- $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
- CONFIG_SHELL=$as_dir/$as_base
- export CONFIG_SHELL
- exec "$CONFIG_SHELL" "$0" ${1+"$@"}
- fi;;
- esac
- done
-done
-;;
- esac
-
- # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
- # uniformly replaced by the line number. The first 'sed' inserts a
- # line-number line before each line; the second 'sed' does the real
- # work. The second script uses 'N' to pair each line-number line
- # with the numbered line, and appends trailing '-' during
- # substitution so that $LINENO is not a special case at line end.
- # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
- # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
- sed '=' <$as_myself |
- sed '
- N
- s,$,-,
- : loop
- s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
- t loop
- s,-$,,
- s,^['$as_cr_digits']*\n,,
- ' >$as_me.lineno &&
- chmod +x $as_me.lineno ||
- { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
-echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
- { (exit 1); exit 1; }; }
-
- # Don't try to exec as it changes $[0], causing all sort of problems
- # (the dirname of $[0] is not the place where we might find the
- # original and so on. Autoconf is especially sensible to this).
- . ./$as_me.lineno
- # Exit status is that of the last command.
- exit
-}
-
-
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
- *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T=' ' ;;
- *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
- *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
-esac
-
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-rm -f conf$$ conf$$.exe conf$$.file
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
- # We could just check for DJGPP; but this test a) works b) is more generic
- # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
- if test -f conf$$.exe; then
- # Don't use ln at all; we don't have any links
- as_ln_s='cp -p'
- else
- as_ln_s='ln -s'
- fi
-elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
-else
- as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.file
-
-if mkdir -p . 2>/dev/null; then
- as_mkdir_p=:
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-
-as_executable_p="test -f"
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" $as_nl"
-
-# CDPATH.
-$as_unset CDPATH
-
-exec 6>&1
-
-# Open the log real soon, to keep \$[0] and so on meaningful, and to
-# report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling. Logging --version etc. is OK.
-exec 5>>config.log
-{
- echo
- sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
-} >&5
-cat >&5 <<_CSEOF
-
-This file was extended by JSON C Library $as_me 0.3, which was
-generated by GNU Autoconf 2.59. Invocation command line was
-
- CONFIG_FILES = $CONFIG_FILES
- CONFIG_HEADERS = $CONFIG_HEADERS
- CONFIG_LINKS = $CONFIG_LINKS
- CONFIG_COMMANDS = $CONFIG_COMMANDS
- $ $0 $@
-
-_CSEOF
-echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
-echo >&5
-_ACEOF
-
-# Files that config.status was made for.
-if test -n "$ac_config_files"; then
- echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_headers"; then
- echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_links"; then
- echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_commands"; then
- echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
-fi
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-ac_cs_usage="\
-\`$as_me' instantiates files from templates according to the
-current configuration.
-
-Usage: $0 [OPTIONS] [FILE]...
-
- -h, --help print this help, then exit
- -V, --version print version number, then exit
- -q, --quiet do not print progress messages
- -d, --debug don't remove temporary files
- --recheck update $as_me by reconfiguring in the same conditions
- --file=FILE[:TEMPLATE]
- instantiate the configuration file FILE
- --header=FILE[:TEMPLATE]
- instantiate the configuration header FILE
-
-Configuration files:
-$config_files
-
-Configuration headers:
-$config_headers
-
-Configuration commands:
-$config_commands
-
-Report bugs to <bug-autoconf@gnu.org>."
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-ac_cs_version="\\
-JSON C Library config.status 0.3
-configured by $0, generated by GNU Autoconf 2.59,
- with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
-
-Copyright (C) 2003 Free Software Foundation, Inc.
-This config.status script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it."
-srcdir=$srcdir
-INSTALL="$INSTALL"
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-# If no file are specified by the user, then we need to provide default
-# value. By we need to know if files were specified by the user.
-ac_need_defaults=:
-while test $# != 0
-do
- case $1 in
- --*=*)
- ac_option=`expr "x$1" : 'x\([^=]*\)='`
- ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
- ac_shift=:
- ;;
- -*)
- ac_option=$1
- ac_optarg=$2
- ac_shift=shift
- ;;
- *) # This is not an option, so the user has probably given explicit
- # arguments.
- ac_option=$1
- ac_need_defaults=false;;
- esac
-
- case $ac_option in
- # Handling of the options.
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- ac_cs_recheck=: ;;
- --version | --vers* | -V )
- echo "$ac_cs_version"; exit 0 ;;
- --he | --h)
- # Conflict between --help and --header
- { { echo "$as_me:$LINENO: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&2;}
- { (exit 1); exit 1; }; };;
- --help | --hel | -h )
- echo "$ac_cs_usage"; exit 0 ;;
- --debug | --d* | -d )
- debug=: ;;
- --file | --fil | --fi | --f )
- $ac_shift
- CONFIG_FILES="$CONFIG_FILES $ac_optarg"
- ac_need_defaults=false;;
- --header | --heade | --head | --hea )
- $ac_shift
- CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
- ac_need_defaults=false;;
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil | --si | --s)
- ac_cs_silent=: ;;
-
- # This is an error.
- -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&2;}
- { (exit 1); exit 1; }; } ;;
-
- *) ac_config_targets="$ac_config_targets $1" ;;
-
- esac
- shift
-done
-
-ac_configure_extra_args=
-
-if $ac_cs_silent; then
- exec 6>/dev/null
- ac_configure_extra_args="$ac_configure_extra_args --silent"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
-if \$ac_cs_recheck; then
- echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
- exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
-fi
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-#
-# INIT-COMMANDS section.
-#
-
-
-
-_ACEOF
-
-
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-for ac_config_target in $ac_config_targets
-do
- case "$ac_config_target" in
- # Handling of arguments.
- "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
- "json.pc" ) CONFIG_FILES="$CONFIG_FILES json.pc" ;;
- "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;;
- "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
- *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
-echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
- { (exit 1); exit 1; }; };;
- esac
-done
-
-# If the user did not use the arguments to specify the items to instantiate,
-# then the envvar interface is used. Set only those that are not.
-# We use the long form for the default assignment because of an extremely
-# bizarre bug on SunOS 4.1.3.
-if $ac_need_defaults; then
- test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
- test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
- test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
-fi
-
-# Have a temporary directory for convenience. Make it in the build tree
-# simply because there is no reason to put it here, and in addition,
-# creating and moving files from /tmp can sometimes cause problems.
-# Create a temporary directory, and hook for its removal unless debugging.
-$debug ||
-{
- trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
- trap '{ (exit 1); exit 1; }' 1 2 13 15
-}
-
-# Create a (secure) tmp directory for tmp files.
-
-{
- tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
- test -n "$tmp" && test -d "$tmp"
-} ||
-{
- tmp=./confstat$$-$RANDOM
- (umask 077 && mkdir $tmp)
-} ||
-{
- echo "$me: cannot create a temporary directory in ." >&2
- { (exit 1); exit 1; }
-}
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-
-#
-# CONFIG_FILES section.
-#
-
-# No need to generate the scripts if there are no CONFIG_FILES.
-# This happens for instance when ./config.status config.h
-if test -n "\$CONFIG_FILES"; then
- # Protect against being on the right side of a sed subst in config.status.
- sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
- s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
-s,@SHELL@,$SHELL,;t t
-s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
-s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
-s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
-s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
-s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
-s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
-s,@exec_prefix@,$exec_prefix,;t t
-s,@prefix@,$prefix,;t t
-s,@program_transform_name@,$program_transform_name,;t t
-s,@bindir@,$bindir,;t t
-s,@sbindir@,$sbindir,;t t
-s,@libexecdir@,$libexecdir,;t t
-s,@datadir@,$datadir,;t t
-s,@sysconfdir@,$sysconfdir,;t t
-s,@sharedstatedir@,$sharedstatedir,;t t
-s,@localstatedir@,$localstatedir,;t t
-s,@libdir@,$libdir,;t t
-s,@includedir@,$includedir,;t t
-s,@oldincludedir@,$oldincludedir,;t t
-s,@infodir@,$infodir,;t t
-s,@mandir@,$mandir,;t t
-s,@build_alias@,$build_alias,;t t
-s,@host_alias@,$host_alias,;t t
-s,@target_alias@,$target_alias,;t t
-s,@DEFS@,$DEFS,;t t
-s,@ECHO_C@,$ECHO_C,;t t
-s,@ECHO_N@,$ECHO_N,;t t
-s,@ECHO_T@,$ECHO_T,;t t
-s,@LIBS@,$LIBS,;t t
-s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
-s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
-s,@INSTALL_DATA@,$INSTALL_DATA,;t t
-s,@PACKAGE@,$PACKAGE,;t t
-s,@VERSION@,$VERSION,;t t
-s,@ACLOCAL@,$ACLOCAL,;t t
-s,@AUTOCONF@,$AUTOCONF,;t t
-s,@AUTOMAKE@,$AUTOMAKE,;t t
-s,@AUTOHEADER@,$AUTOHEADER,;t t
-s,@MAKEINFO@,$MAKEINFO,;t t
-s,@SET_MAKE@,$SET_MAKE,;t t
-s,@CC@,$CC,;t t
-s,@CFLAGS@,$CFLAGS,;t t
-s,@LDFLAGS@,$LDFLAGS,;t t
-s,@CPPFLAGS@,$CPPFLAGS,;t t
-s,@ac_ct_CC@,$ac_ct_CC,;t t
-s,@EXEEXT@,$EXEEXT,;t t
-s,@OBJEXT@,$OBJEXT,;t t
-s,@CPP@,$CPP,;t t
-s,@EGREP@,$EGREP,;t t
-s,@LIBOBJS@,$LIBOBJS,;t t
-s,@build@,$build,;t t
-s,@build_cpu@,$build_cpu,;t t
-s,@build_vendor@,$build_vendor,;t t
-s,@build_os@,$build_os,;t t
-s,@host@,$host,;t t
-s,@host_cpu@,$host_cpu,;t t
-s,@host_vendor@,$host_vendor,;t t
-s,@host_os@,$host_os,;t t
-s,@LN_S@,$LN_S,;t t
-s,@ECHO@,$ECHO,;t t
-s,@AR@,$AR,;t t
-s,@ac_ct_AR@,$ac_ct_AR,;t t
-s,@RANLIB@,$RANLIB,;t t
-s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
-s,@STRIP@,$STRIP,;t t
-s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t
-s,@CXX@,$CXX,;t t
-s,@CXXFLAGS@,$CXXFLAGS,;t t
-s,@ac_ct_CXX@,$ac_ct_CXX,;t t
-s,@CXXCPP@,$CXXCPP,;t t
-s,@F77@,$F77,;t t
-s,@FFLAGS@,$FFLAGS,;t t
-s,@ac_ct_F77@,$ac_ct_F77,;t t
-s,@LIBTOOL@,$LIBTOOL,;t t
-s,@LTLIBOBJS@,$LTLIBOBJS,;t t
-CEOF
-
-_ACEOF
-
- cat >>$CONFIG_STATUS <<\_ACEOF
- # Split the substitutions into bite-sized pieces for seds with
- # small command number limits, like on Digital OSF/1 and HP-UX.
- ac_max_sed_lines=48
- ac_sed_frag=1 # Number of current file.
- ac_beg=1 # First line for current file.
- ac_end=$ac_max_sed_lines # Line after last line for current file.
- ac_more_lines=:
- ac_sed_cmds=
- while $ac_more_lines; do
- if test $ac_beg -gt 1; then
- sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
- else
- sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
- fi
- if test ! -s $tmp/subs.frag; then
- ac_more_lines=false
- else
- # The purpose of the label and of the branching condition is to
- # speed up the sed processing (if there are no `@' at all, there
- # is no need to browse any of the substitutions).
- # These are the two extra sed commands mentioned above.
- (echo ':t
- /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
- else
- ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
- fi
- ac_sed_frag=`expr $ac_sed_frag + 1`
- ac_beg=$ac_end
- ac_end=`expr $ac_end + $ac_max_sed_lines`
- fi
- done
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds=cat
- fi
-fi # test -n "$CONFIG_FILES"
-
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case $ac_file in
- - | *:- | *:-:* ) # input from stdin
- cat >$tmp/stdin
- ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- * ) ac_file_in=$ac_file.in ;;
- esac
-
- # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
- ac_dir=`(dirname "$ac_file") 2>/dev/null ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_file" : 'X\(//\)[^/]' \| \
- X"$ac_file" : 'X\(//\)$' \| \
- X"$ac_file" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$ac_file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- { if $as_mkdir_p; then
- mkdir -p "$ac_dir"
- else
- as_dir="$ac_dir"
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
- { (exit 1); exit 1; }; }; }
-
- ac_builddir=.
-
-if test "$ac_dir" != .; then
- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
- # A "../" for each directory in $ac_dir_suffix.
- ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
- ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
- .) # No --srcdir option. We are building in place.
- ac_srcdir=.
- if test -z "$ac_top_builddir"; then
- ac_top_srcdir=.
- else
- ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
- fi ;;
- [\\/]* | ?:[\\/]* ) # Absolute path.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir ;;
- *) # Relative path.
- ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
- case "$ac_dir" in
- .) ac_abs_builddir=`pwd`;;
- [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
- *) ac_abs_builddir=`pwd`/"$ac_dir";;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
- case ${ac_top_builddir}. in
- .) ac_abs_top_builddir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
- *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
- case $ac_srcdir in
- .) ac_abs_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
- *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
- case $ac_top_srcdir in
- .) ac_abs_top_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
- *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
- esac;;
-esac
-
-
- case $INSTALL in
- [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
- *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
- esac
-
- # Let's still pretend it is `configure' which instantiates (i.e., don't
- # use $as_me), people would be surprised to read:
- # /* config.h. Generated by config.status. */
- if test x"$ac_file" = x-; then
- configure_input=
- else
- configure_input="$ac_file. "
- fi
- configure_input=$configure_input"Generated from `echo $ac_file_in |
- sed 's,.*/,,'` by configure."
-
- # First look for the input files in the build tree, otherwise in the
- # src tree.
- ac_file_inputs=`IFS=:
- for f in $ac_file_in; do
- case $f in
- -) echo $tmp/stdin ;;
- [\\/$]*)
- # Absolute (can't be DOS-style, as IFS=:)
- test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- echo "$f";;
- *) # Relative
- if test -f "$f"; then
- # Build tree
- echo "$f"
- elif test -f "$srcdir/$f"; then
- # Source tree
- echo "$srcdir/$f"
- else
- # /dev/null tree
- { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- fi;;
- esac
- done` || { (exit 1); exit 1; }
-
- if test x"$ac_file" != x-; then
- { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
- rm -f "$ac_file"
- fi
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
- sed "$ac_vpsub
-$extrasub
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-:t
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s,@configure_input@,$configure_input,;t t
-s,@srcdir@,$ac_srcdir,;t t
-s,@abs_srcdir@,$ac_abs_srcdir,;t t
-s,@top_srcdir@,$ac_top_srcdir,;t t
-s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
-s,@builddir@,$ac_builddir,;t t
-s,@abs_builddir@,$ac_abs_builddir,;t t
-s,@top_builddir@,$ac_top_builddir,;t t
-s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
-s,@INSTALL@,$ac_INSTALL,;t t
-" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
- rm -f $tmp/stdin
- if test x"$ac_file" != x-; then
- mv $tmp/out $ac_file
- else
- cat $tmp/out
- rm -f $tmp/out
- fi
-
-done
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-#
-# CONFIG_HEADER section.
-#
-
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)'
-ac_dB='[ ].*$,\1#\2'
-ac_dC=' '
-ac_dD=',;t'
-# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_uB='$,\1#\2define\3'
-ac_uC=' '
-ac_uD=',;t'
-
-for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case $ac_file in
- - | *:- | *:-:* ) # input from stdin
- cat >$tmp/stdin
- ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- * ) ac_file_in=$ac_file.in ;;
- esac
-
- test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
-
- # First look for the input files in the build tree, otherwise in the
- # src tree.
- ac_file_inputs=`IFS=:
- for f in $ac_file_in; do
- case $f in
- -) echo $tmp/stdin ;;
- [\\/$]*)
- # Absolute (can't be DOS-style, as IFS=:)
- test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- # Do quote $f, to prevent DOS paths from being IFS'd.
- echo "$f";;
- *) # Relative
- if test -f "$f"; then
- # Build tree
- echo "$f"
- elif test -f "$srcdir/$f"; then
- # Source tree
- echo "$srcdir/$f"
- else
- # /dev/null tree
- { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- fi;;
- esac
- done` || { (exit 1); exit 1; }
- # Remove the trailing spaces.
- sed 's/[ ]*$//' $ac_file_inputs >$tmp/in
-
-_ACEOF
-
-# Transform confdefs.h into two sed scripts, `conftest.defines' and
-# `conftest.undefs', that substitutes the proper values into
-# config.h.in to produce config.h. The first handles `#define'
-# templates, and the second `#undef' templates.
-# And first: Protect against being on the right side of a sed subst in
-# config.status. Protect against being in an unquoted here document
-# in config.status.
-rm -f conftest.defines conftest.undefs
-# Using a here document instead of a string reduces the quoting nightmare.
-# Putting comments in sed scripts is not portable.
-#
-# `end' is used to avoid that the second main sed command (meant for
-# 0-ary CPP macros) applies to n-ary macro definitions.
-# See the Autoconf documentation for `clear'.
-cat >confdef2sed.sed <<\_ACEOF
-s/[\\&,]/\\&/g
-s,[\\$`],\\&,g
-t clear
-: clear
-s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
-t end
-s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
-: end
-_ACEOF
-# If some macros were called several times there might be several times
-# the same #defines, which is useless. Nevertheless, we may not want to
-# sort them, since we want the *last* AC-DEFINE to be honored.
-uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
-sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
-rm -f confdef2sed.sed
-
-# This sed command replaces #undef with comments. This is necessary, for
-# example, in the case of _POSIX_SOURCE, which is predefined and required
-# on some systems where configure will not decide to define it.
-cat >>conftest.undefs <<\_ACEOF
-s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
-_ACEOF
-
-# Break up conftest.defines because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
-echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
-echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
-echo ' :' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.defines >/dev/null
-do
- # Write a limited-size here document to $tmp/defines.sed.
- echo ' cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
- # Speed up: don't consider the non `#define' lines.
- echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS
- # Work around the forget-to-reset-the-flag bug.
- echo 't clr' >>$CONFIG_STATUS
- echo ': clr' >>$CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
- echo 'CEOF
- sed -f $tmp/defines.sed $tmp/in >$tmp/out
- rm -f $tmp/in
- mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
- rm -f conftest.defines
- mv conftest.tail conftest.defines
-done
-rm -f conftest.defines
-echo ' fi # grep' >>$CONFIG_STATUS
-echo >>$CONFIG_STATUS
-
-# Break up conftest.undefs because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo ' # Handle all the #undef templates' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.undefs >/dev/null
-do
- # Write a limited-size here document to $tmp/undefs.sed.
- echo ' cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
- # Speed up: don't consider the non `#undef'
- echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS
- # Work around the forget-to-reset-the-flag bug.
- echo 't clr' >>$CONFIG_STATUS
- echo ': clr' >>$CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
- echo 'CEOF
- sed -f $tmp/undefs.sed $tmp/in >$tmp/out
- rm -f $tmp/in
- mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
- rm -f conftest.undefs
- mv conftest.tail conftest.undefs
-done
-rm -f conftest.undefs
-
-cat >>$CONFIG_STATUS <<\_ACEOF
- # Let's still pretend it is `configure' which instantiates (i.e., don't
- # use $as_me), people would be surprised to read:
- # /* config.h. Generated by config.status. */
- if test x"$ac_file" = x-; then
- echo "/* Generated by configure. */" >$tmp/config.h
- else
- echo "/* $ac_file. Generated by configure. */" >$tmp/config.h
- fi
- cat $tmp/in >>$tmp/config.h
- rm -f $tmp/in
- if test x"$ac_file" != x-; then
- if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
- { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
-echo "$as_me: $ac_file is unchanged" >&6;}
- else
- ac_dir=`(dirname "$ac_file") 2>/dev/null ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_file" : 'X\(//\)[^/]' \| \
- X"$ac_file" : 'X\(//\)$' \| \
- X"$ac_file" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$ac_file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- { if $as_mkdir_p; then
- mkdir -p "$ac_dir"
- else
- as_dir="$ac_dir"
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
- { (exit 1); exit 1; }; }; }
-
- rm -f $ac_file
- mv $tmp/config.h $ac_file
- fi
- else
- cat $tmp/config.h
- rm -f $tmp/config.h
- fi
-done
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-#
-# CONFIG_COMMANDS section.
-#
-for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue
- ac_dest=`echo "$ac_file" | sed 's,:.*,,'`
- ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_dir=`(dirname "$ac_dest") 2>/dev/null ||
-$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_dest" : 'X\(//\)[^/]' \| \
- X"$ac_dest" : 'X\(//\)$' \| \
- X"$ac_dest" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$ac_dest" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- { if $as_mkdir_p; then
- mkdir -p "$ac_dir"
- else
- as_dir="$ac_dir"
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
- { (exit 1); exit 1; }; }; }
-
- ac_builddir=.
-
-if test "$ac_dir" != .; then
- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
- # A "../" for each directory in $ac_dir_suffix.
- ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
- ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
- .) # No --srcdir option. We are building in place.
- ac_srcdir=.
- if test -z "$ac_top_builddir"; then
- ac_top_srcdir=.
- else
- ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
- fi ;;
- [\\/]* | ?:[\\/]* ) # Absolute path.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir ;;
- *) # Relative path.
- ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
- case "$ac_dir" in
- .) ac_abs_builddir=`pwd`;;
- [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
- *) ac_abs_builddir=`pwd`/"$ac_dir";;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
- case ${ac_top_builddir}. in
- .) ac_abs_top_builddir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
- *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
- case $ac_srcdir in
- .) ac_abs_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
- *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
- case $ac_top_srcdir in
- .) ac_abs_top_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
- *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
- esac;;
-esac
-
-
- { echo "$as_me:$LINENO: executing $ac_dest commands" >&5
-echo "$as_me: executing $ac_dest commands" >&6;}
- case $ac_dest in
- default-1 ) test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h ;;
- esac
-done
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-{ (exit 0); exit 0; }
-_ACEOF
-chmod +x $CONFIG_STATUS
-ac_clean_files=$ac_clean_files_save
-
-
-# configure is writing to config.log, and then calls config.status.
-# config.status does its own redirection, appending to config.log.
-# Unfortunately, on DOS this fails, as config.log is still kept open
-# by configure, so config.status won't be able to write to it; its
-# output is simply discarded. So we exec the FD to /dev/null,
-# effectively closing config.log, so it can be properly (re)opened and
-# appended to by config.status. When coming back to configure, we
-# need to make the FD available again.
-if test "$no_create" != yes; then
- ac_cs_success=:
- ac_config_status_args=
- test "$silent" = yes &&
- ac_config_status_args="$ac_config_status_args --quiet"
- exec 5>/dev/null
- $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
- exec 5>>config.log
- # Use ||, not &&, to avoid exiting from the if with $? = 1, which
- # would make configure fail if this is the last instruction.
- $ac_cs_success || { (exit 1); exit 1; }
-fi
-
diff --git a/source4/lib/json/configure.in b/source4/lib/json/configure.in
deleted file mode 100644
index f0a7d3aa5c..0000000000
--- a/source4/lib/json/configure.in
+++ /dev/null
@@ -1,33 +0,0 @@
-AC_PREREQ(2.52)
-
-# Process this file with autoconf to produce a configure script.
-AC_INIT([JSON C Library], 0.3, [michael@metaparadigm.com], [json-c])
-
-AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
-
-# Checks for programs.
-
-# Checks for libraries.
-
-# Checks for header files.
-AM_CONFIG_HEADER(config.h)
-AC_HEADER_STDC
-AC_CHECK_HEADERS(fcntl.h limits.h strings.h syslog.h unistd.h [sys/param.h] stdarg.h)
-
-# Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_TYPE_SIZE_T
-
-# Checks for library functions.
-AC_FUNC_VPRINTF
-AC_FUNC_MEMCMP
-AC_FUNC_MALLOC
-AC_FUNC_REALLOC
-AC_CHECK_FUNCS(strndup strerror vsnprintf vasprintf open vsyslog strncasecmp)
-
-AM_PROG_LIBTOOL
-
-AC_OUTPUT([
-Makefile
-json.pc
-])
diff --git a/source4/lib/json/debug.c b/source4/lib/json/debug.c
deleted file mode 100644
index a315b0e2a4..0000000000
--- a/source4/lib/json/debug.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * $Id: debug.c,v 1.5 2006/01/26 02:16:28 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-
-#if HAVE_SYSLOG_H
-# include <syslog.h>
-#endif /* HAVE_SYSLOG_H */
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-
-#if HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif /* HAVE_SYS_PARAM_H */
-
-#include "debug.h"
-
-static int _syslog = 0;
-static int _debug = 0;
-
-void mc_set_debug(int debug) { _debug = debug; }
-int mc_get_debug() { return _debug; }
-
-extern void mc_set_syslog(int syslog)
-{
- _syslog = syslog;
-}
-
-_NORETURN_ void mc_abort(const char *msg, ...)
-{
- va_list ap;
- va_start(ap, msg);
-#if HAVE_VSYSLOG
- if(_syslog) {
- vsyslog(LOG_ERR, msg, ap);
- } else
-#endif
- vprintf(msg, ap);
- exit(1);
-}
-
-
-void mc_debug(const char *msg, ...)
-{
- va_list ap;
- if(_debug) {
- va_start(ap, msg);
-#if HAVE_VSYSLOG
- if(_syslog) {
- vsyslog(LOG_DEBUG, msg, ap);
- } else
-#endif
- vprintf(msg, ap);
- }
-}
-
-void mc_error(const char *msg, ...)
-{
- va_list ap;
- va_start(ap, msg);
-#if HAVE_VSYSLOG
- if(_syslog) {
- vsyslog(LOG_ERR, msg, ap);
- } else
-#endif
- vfprintf(stderr, msg, ap);
-}
-
-void mc_info(const char *msg, ...)
-{
- va_list ap;
- va_start(ap, msg);
-#if HAVE_VSYSLOG
- if(_syslog) {
- vsyslog(LOG_INFO, msg, ap);
- } else
-#endif
- vfprintf(stderr, msg, ap);
-}
diff --git a/source4/lib/json/debug.h b/source4/lib/json/debug.h
deleted file mode 100644
index 1db69ef016..0000000000
--- a/source4/lib/json/debug.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * $Id: debug.h,v 1.5 2006/01/30 23:07:57 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-#ifndef _DEBUG_H_
-#define _DEBUG_H_
-
-extern void mc_set_debug(int debug);
-extern int mc_get_debug();
-
-extern void mc_set_syslog(int syslog);
-extern void mc_abort(const char *msg, ...);
-extern void mc_debug(const char *msg, ...);
-extern void mc_error(const char *msg, ...);
-extern void mc_info(const char *msg, ...);
-
-#endif
diff --git a/source4/lib/json/depcomp b/source4/lib/json/depcomp
deleted file mode 100755
index c5b511c63d..0000000000
--- a/source4/lib/json/depcomp
+++ /dev/null
@@ -1,421 +0,0 @@
-#! /bin/sh
-
-# depcomp - compile a program generating dependencies as side-effects
-# Copyright 1999, 2000 Free Software Foundation, Inc.
-
-# 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 2, 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 Alexandre Oliva <oliva@dcc.unicamp.br>.
-
-if test -z "$depmode" || test -z "$source" || test -z "$object"; then
- echo "depcomp: Variables source, object and depmode must be set" 1>&2
- exit 1
-fi
-# `libtool' can also be set to `yes' or `no'.
-
-if test -z "$depfile"; then
- base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
- dir=`echo "$object" | sed 's,/.*$,/,'`
- if test "$dir" = "$object"; then
- dir=
- fi
- # FIXME: should be _deps on DOS.
- depfile="$dir.deps/$base"
-fi
-
-tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
-
-rm -f "$tmpdepfile"
-
-# Some modes work just like other modes, but use different flags. We
-# parameterize here, but still list the modes in the big case below,
-# to make depend.m4 easier to write. Note that we *cannot* use a case
-# here, because this file can only contain one case statement.
-if test "$depmode" = hp; then
- # HP compiler uses -M and no extra arg.
- gccflag=-M
- depmode=gcc
-fi
-
-if test "$depmode" = dashXmstdout; then
- # This is just like dashmstdout with a different argument.
- dashmflag=-xM
- depmode=dashmstdout
-fi
-
-case "$depmode" in
-gcc3)
-## gcc 3 implements dependency tracking that does exactly what
-## we want. Yay! Note: for some reason libtool 1.4 doesn't like
-## it if -MD -MP comes after the -MF stuff. Hmm.
- "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- mv "$tmpdepfile" "$depfile"
- ;;
-
-gcc)
-## There are various ways to get dependency output from gcc. Here's
-## why we pick this rather obscure method:
-## - Don't want to use -MD because we'd like the dependencies to end
-## up in a subdir. Having to rename by hand is ugly.
-## (We might end up doing this anyway to support other compilers.)
-## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
-## -MM, not -M (despite what the docs say).
-## - Using -M directly means running the compiler twice (even worse
-## than renaming).
- if test -z "$gccflag"; then
- gccflag=-MD,
- fi
- "$@" -Wp,"$gccflag$tmpdepfile"
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- rm -f "$depfile"
- echo "$object : \\" > "$depfile"
- alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
-## The second -e expression handles DOS-style file names with drive letters.
- sed -e 's/^[^:]*: / /' \
- -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
-## This next piece of magic avoids the `deleted header file' problem.
-## The problem is that when a header file which appears in a .P file
-## is deleted, the dependency causes make to die (because there is
-## typically no way to rebuild the header). We avoid this by adding
-## dummy dependencies for each header file. Too bad gcc doesn't do
-## this for us directly.
- tr ' ' '
-' < "$tmpdepfile" |
-## Some versions of gcc put a space before the `:'. On the theory
-## that the space means something, we add a space to the output as
-## well.
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly. Breaking it into two sed invocations is a workaround.
- sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-hp)
- # This case exists only to let depend.m4 do its work. It works by
- # looking at the text of this script. This case will never be run,
- # since it is checked for above.
- exit 1
- ;;
-
-sgi)
- if test "$libtool" = yes; then
- "$@" "-Wp,-MDupdate,$tmpdepfile"
- else
- "$@" -MDupdate "$tmpdepfile"
- fi
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- rm -f "$depfile"
-
- if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
- echo "$object : \\" > "$depfile"
-
- # Clip off the initial element (the dependent). Don't try to be
- # clever and replace this with sed code, as IRIX sed won't handle
- # lines with more than a fixed number of characters (4096 in
- # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
- # the IRIX cc adds comments like `#:fec' to the end of the
- # dependency line.
- tr ' ' '
-' < "$tmpdepfile" \
- | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
- tr '
-' ' ' >> $depfile
- echo >> $depfile
-
- # The second pass generates a dummy entry for each header file.
- tr ' ' '
-' < "$tmpdepfile" \
- | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
- >> $depfile
- else
- # The sourcefile does not contain any dependencies, so just
- # store a dummy comment line, to avoid errors with the Makefile
- # "include basename.Plo" scheme.
- echo "#dummy" > "$depfile"
- fi
- rm -f "$tmpdepfile"
- ;;
-
-aix)
- # The C for AIX Compiler uses -M and outputs the dependencies
- # in a .u file. This file always lives in the current directory.
- # Also, the AIX compiler puts `$object:' at the start of each line;
- # $object doesn't have directory information.
- stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
- tmpdepfile="$stripped.u"
- outname="$stripped.o"
- if test "$libtool" = yes; then
- "$@" -Wc,-M
- else
- "$@" -M
- fi
-
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
-
- if test -f "$tmpdepfile"; then
- # Each line is of the form `foo.o: dependent.h'.
- # Do two passes, one to just change these to
- # `$object: dependent.h' and one to simply `dependent.h:'.
- sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
- sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
- else
- # The sourcefile does not contain any dependencies, so just
- # store a dummy comment line, to avoid errors with the Makefile
- # "include basename.Plo" scheme.
- echo "#dummy" > "$depfile"
- fi
- rm -f "$tmpdepfile"
- ;;
-
-tru64)
- # The Tru64 compiler uses -MD to generate dependencies as a side
- # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
- # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
- # dependencies in `foo.d' instead, so we check for that too.
- # Subdirectories are respected.
- dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
- test "x$dir" = "x$object" && dir=
- base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
-
- if test "$libtool" = yes; then
- tmpdepfile1="$dir.libs/$base.lo.d"
- tmpdepfile2="$dir.libs/$base.d"
- "$@" -Wc,-MD
- else
- tmpdepfile1="$dir$base.o.d"
- tmpdepfile2="$dir$base.d"
- "$@" -MD
- fi
-
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile1" "$tmpdepfile2"
- exit $stat
- fi
-
- if test -f "$tmpdepfile1"; then
- tmpdepfile="$tmpdepfile1"
- else
- tmpdepfile="$tmpdepfile2"
- fi
- if test -f "$tmpdepfile"; then
- sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
- # That's a space and a tab in the [].
- sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
- else
- echo "#dummy" > "$depfile"
- fi
- rm -f "$tmpdepfile"
- ;;
-
-#nosideeffect)
- # This comment above is used by automake to tell side-effect
- # dependency tracking mechanisms from slower ones.
-
-dashmstdout)
- # Important note: in order to support this mode, a compiler *must*
- # always write the proprocessed file to stdout, regardless of -o.
- "$@" || exit $?
-
- # Remove the call to Libtool.
- if test "$libtool" = yes; then
- while test $1 != '--mode=compile'; do
- shift
- done
- shift
- fi
-
- # Remove `-o $object'. We will use -o /dev/null later,
- # however we can't do the remplacement now because
- # `-o $object' might simply not be used
- IFS=" "
- for arg
- do
- case $arg in
- -o)
- shift
- ;;
- $object)
- shift
- ;;
- *)
- set fnord "$@" "$arg"
- shift # fnord
- shift # $arg
- ;;
- esac
- done
-
- test -z "$dashmflag" && dashmflag=-M
- "$@" -o /dev/null $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
- rm -f "$depfile"
- cat < "$tmpdepfile" > "$depfile"
- tr ' ' '
-' < "$tmpdepfile" | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly. Breaking it into two sed invocations is a workaround.
- sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-dashXmstdout)
- # This case only exists to satisfy depend.m4. It is never actually
- # run, as this mode is specially recognized in the preamble.
- exit 1
- ;;
-
-makedepend)
- "$@" || exit $?
- # X makedepend
- shift
- cleared=no
- for arg in "$@"; do
- case $cleared in
- no)
- set ""; shift
- cleared=yes ;;
- esac
- case "$arg" in
- -D*|-I*)
- set fnord "$@" "$arg"; shift ;;
- -*)
- ;;
- *)
- set fnord "$@" "$arg"; shift ;;
- esac
- done
- obj_suffix="`echo $object | sed 's/^.*\././'`"
- touch "$tmpdepfile"
- ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
- rm -f "$depfile"
- cat < "$tmpdepfile" > "$depfile"
- sed '1,2d' "$tmpdepfile" | tr ' ' '
-' | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly. Breaking it into two sed invocations is a workaround.
- sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile" "$tmpdepfile".bak
- ;;
-
-cpp)
- # Important note: in order to support this mode, a compiler *must*
- # always write the proprocessed file to stdout.
- "$@" || exit $?
-
- # Remove the call to Libtool.
- if test "$libtool" = yes; then
- while test $1 != '--mode=compile'; do
- shift
- done
- shift
- fi
-
- # Remove `-o $object'.
- IFS=" "
- for arg
- do
- case $arg in
- -o)
- shift
- ;;
- $object)
- shift
- ;;
- *)
- set fnord "$@" "$arg"
- shift # fnord
- shift # $arg
- ;;
- esac
- done
-
- "$@" -E |
- sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
- sed '$ s: \\$::' > "$tmpdepfile"
- rm -f "$depfile"
- echo "$object : \\" > "$depfile"
- cat < "$tmpdepfile" >> "$depfile"
- sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-msvisualcpp)
- # Important note: in order to support this mode, a compiler *must*
- # always write the proprocessed file to stdout, regardless of -o,
- # because we must use -o when running libtool.
- "$@" || exit $?
- IFS=" "
- for arg
- do
- case "$arg" in
- "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
- set fnord "$@"
- shift
- shift
- ;;
- *)
- set fnord "$@" "$arg"
- shift
- shift
- ;;
- esac
- done
- "$@" -E |
- sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
- rm -f "$depfile"
- echo "$object : \\" > "$depfile"
- . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
- echo " " >> "$depfile"
- . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-none)
- exec "$@"
- ;;
-
-*)
- echo "Unknown depmode $depmode" 1>&2
- exit 1
- ;;
-esac
-
-exit 0
diff --git a/source4/lib/json/install-sh b/source4/lib/json/install-sh
deleted file mode 100755
index fca26e5622..0000000000
--- a/source4/lib/json/install-sh
+++ /dev/null
@@ -1,269 +0,0 @@
-#!/bin/sh
-#
-# install - install a program, script, or datafile
-#
-# This originates from X11R5 (mit/util/scripts/install.sh), which was
-# later released in X11R6 (xc/config/util/install.sh) with the
-# following copyright and license.
-#
-# Copyright (C) 1994 X Consortium
-#
-# 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 CONNEC-
-# TION 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 deal-
-# ings in this Software without prior written authorization from the X Consor-
-# tium.
-#
-#
-# FSF changes to this file are in the public domain.
-#
-# 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. It can only install one file at a time, a restriction
-# shared with many OS's install programs.
-
-
-# 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
- :
-fi
-
-if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- chmodcmd=""
- else
- instcmd=$mkdirprog
- 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" ] || [ -d "$src" ]
- then
- :
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- :
- 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
- :
- 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
- :
- fi
-
- pathcomp="${pathcomp}/"
-done
-fi
-
-if [ x"$dir_arg" != x ]
-then
- $doit $instcmd $dst &&
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; 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
- :
- 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 :;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;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/json/json-c.vcproj b/source4/lib/json/json-c.vcproj
deleted file mode 100644
index 0b88754459..0000000000
--- a/source4/lib/json/json-c.vcproj
+++ /dev/null
@@ -1,179 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="7.10"
- Name="json-c"
- ProjectGUID="{04D8CDBE-FB3E-4362-87E6-07DC3C0083B2}"
- Keyword="Win32Proj">
- <Platforms>
- <Platform
- Name="Win32"/>
- </Platforms>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="Debug"
- IntermediateDirectory="Debug"
- ConfigurationType="4"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
- MinimalRebuild="TRUE"
- BasicRuntimeChecks="3"
- RuntimeLibrary="5"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="TRUE"
- DebugInformationFormat="4"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)/jsonD.lib"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"
- CommandLine="copy config.h.win32 config.h"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCXMLDataGeneratorTool"/>
- <Tool
- Name="VCManagedWrapperGeneratorTool"/>
- <Tool
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release"
- ConfigurationType="4"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
- RuntimeLibrary="4"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="TRUE"
- DebugInformationFormat="3"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)/json.lib"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCXMLDataGeneratorTool"/>
- <Tool
- Name="VCManagedWrapperGeneratorTool"/>
- <Tool
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
- <File
- RelativePath=".\arraylist.c">
- </File>
- <File
- RelativePath=".\debug.c">
- </File>
- <File
- RelativePath=".\json_object.c">
- </File>
- <File
- RelativePath=".\json_tokener.c">
- </File>
- <File
- RelativePath=".\json_util.c">
- </File>
- <File
- RelativePath=".\linkhash.c">
- </File>
- <File
- RelativePath=".\printbuf.c">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
- <File
- RelativePath=".\arraylist.h">
- </File>
- <File
- RelativePath=".\bits.h">
- </File>
- <File
- RelativePath=".\debug.h">
- </File>
- <File
- RelativePath=".\json_object.h">
- </File>
- <File
- RelativePath=".\json_object_private.h">
- </File>
- <File
- RelativePath=".\json_tokener.h">
- </File>
- <File
- RelativePath=".\json_util.h">
- </File>
- <File
- RelativePath=".\linkhash.h">
- </File>
- <File
- RelativePath=".\printbuf.h">
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
- </Filter>
- <Filter
- Name="Documentation"
- Filter="">
- <File
- RelativePath=".\Doxyfile">
- </File>
- </Filter>
- <File
- RelativePath=".\config.h.win32">
- </File>
- <File
- RelativePath=".\README-WIN32.html">
- </File>
- <File
- RelativePath=".\README.html">
- </File>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/source4/lib/json/json.h b/source4/lib/json/json.h
deleted file mode 100644
index a5a3432b2c..0000000000
--- a/source4/lib/json/json.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * $Id: json.h,v 1.6 2006/01/26 02:16:28 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-#ifndef _json_h_
-#define _json_h_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "bits.h"
-#include "debug.h"
-#include "linkhash.h"
-#include "arraylist.h"
-#include "json_util.h"
-#include "json_object.h"
-#include "json_tokener.h"
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/source4/lib/json/json.pc.in b/source4/lib/json/json.pc.in
deleted file mode 100644
index b3d140be97..0000000000
--- a/source4/lib/json/json.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: json
-Description: JSON implementation in C
-Version: @VERSION@
-Requires:
-Libs: -L${libdir} -ljson
-Cflags: -I${includedir}/json
diff --git a/source4/lib/json/json_object.c b/source4/lib/json/json_object.c
deleted file mode 100644
index 525e2171e9..0000000000
--- a/source4/lib/json/json_object.c
+++ /dev/null
@@ -1,504 +0,0 @@
-/*
- * $Id: json_object.c,v 1.15 2006/01/30 23:07:57 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "debug.h"
-#include "printbuf.h"
-#include "linkhash.h"
-#include "arraylist.h"
-#include "json_object.h"
-#include "json_object_private.h"
-#include "json_tokener.h"
-
-#if !HAVE_STRNDUP
- char* strndup(const char* str, size_t n);
-#endif /* !HAVE_STRNDUP */
-
-/* #define REFCOUNT_DEBUG 1 */
-
-char *json_number_chars = "0123456789.+-e";
-char *json_hex_chars = "0123456789abcdef";
-
-#ifdef REFCOUNT_DEBUG
-static char* json_type_name[] = {
- "null",
- "boolean",
- "double",
- "int",
- "object",
- "array",
- "string",
-};
-#endif /* REFCOUNT_DEBUG */
-
-static void json_object_generic_delete(struct json_object* this);
-static struct json_object* json_object_new(enum json_type o_type);
-
-
-/* ref count debugging */
-
-#ifdef REFCOUNT_DEBUG
-
-static struct lh_table *json_object_table;
-
-static void json_object_init() __attribute__ ((constructor));
-static void json_object_init() {
- mc_debug("json_object_init: creating object table\n");
- json_object_table = lh_kptr_table_new(128, "json_object_table", NULL);
-}
-
-static void json_object_fini() __attribute__ ((destructor));
-static void json_object_fini() {
- struct lh_entry *ent;
- if(mc_get_debug() && json_object_table->count) {
- mc_debug("json_object_fini: %d referenced objects at exit\n",
- json_object_table->count);
- lh_foreach(json_object_table, ent) {
- struct json_object* obj = (struct json_object*)ent->v;
- mc_debug("\t%s:%p\n", json_type_name[obj->o_type], obj);
- }
- }
- mc_debug("json_object_fini: freeing object table\n");
- lh_table_free(json_object_table);
-}
-#endif /* REFCOUNT_DEBUG */
-
-
-/* string escaping */
-
-static int json_escape_str(struct printbuf *pb, char *str)
-{
- int pos = 0, start_offset = 0;
- unsigned char c;
- do {
- c = str[pos];
- switch(c) {
- case '\0':
- break;
- case '\b':
- case '\n':
- case '\r':
- case '\t':
- case '"':
- if(pos - start_offset > 0)
- printbuf_memappend(pb, str + start_offset, pos - start_offset);
- if(c == '\b') printbuf_memappend(pb, "\\b", 2);
- else if(c == '\n') printbuf_memappend(pb, "\\n", 2);
- else if(c == '\r') printbuf_memappend(pb, "\\r", 2);
- else if(c == '\t') printbuf_memappend(pb, "\\t", 2);
- else if(c == '"') printbuf_memappend(pb, "\\\"", 2);
- start_offset = ++pos;
- break;
- default:
- if(c < ' ') {
- if(pos - start_offset > 0)
- printbuf_memappend(pb, str + start_offset, pos - start_offset);
- sprintbuf(pb, "\\u00%c%c",
- json_hex_chars[c >> 4],
- json_hex_chars[c & 0xf]);
- start_offset = ++pos;
- } else pos++;
- }
- } while(c);
- if(pos - start_offset > 0)
- printbuf_memappend(pb, str + start_offset, pos - start_offset);
- return 0;
-}
-
-
-/* reference counting */
-
-extern struct json_object* json_object_get(struct json_object *this)
-{
- if(this) {
- this->_ref_count++;
- }
- return this;
-}
-
-extern void json_object_put(struct json_object *this)
-{
- if(this) {
- this->_ref_count--;
- if(!this->_ref_count) this->_delete(this);
- }
-}
-
-
-/* generic object construction and destruction parts */
-
-static void json_object_generic_delete(struct json_object* this)
-{
-#ifdef REFCOUNT_DEBUG
- mc_debug("json_object_delete_%s: %p\n",
- json_type_name[this->o_type], this);
- lh_table_delete(json_object_table, this);
-#endif /* REFCOUNT_DEBUG */
- printbuf_free(this->_pb);
- free(this);
-}
-
-static struct json_object* json_object_new(enum json_type o_type)
-{
- struct json_object *this = calloc(sizeof(struct json_object), 1);
- if(!this) return NULL;
- this->o_type = o_type;
- this->_ref_count = 1;
- this->_delete = &json_object_generic_delete;
-#ifdef REFCOUNT_DEBUG
- lh_table_insert(json_object_table, this, this);
- mc_debug("json_object_new_%s: %p\n", json_type_name[this->o_type], this);
-#endif /* REFCOUNT_DEBUG */
- return this;
-}
-
-
-/* type checking functions */
-
-int json_object_is_type(struct json_object *this, enum json_type type)
-{
- return (this->o_type == type);
-}
-
-enum json_type json_object_get_type(struct json_object *this)
-{
- return this->o_type;
-}
-
-
-/* json_object_to_json_string */
-
-char* json_object_to_json_string(struct json_object *this)
-{
- if(!this) return "null";
- if(!this->_pb) {
- if(!(this->_pb = printbuf_new())) return NULL;
- } else {
- printbuf_reset(this->_pb);
- }
- if(this->_to_json_string(this, this->_pb) < 0) return NULL;
- return this->_pb->buf;
-}
-
-
-/* json_object_object */
-
-static int json_object_object_to_json_string(struct json_object* this,
- struct printbuf *pb)
-{
- int i=0;
- struct json_object_iter iter;
- sprintbuf(pb, "{");
-
- /* CAW: scope operator to make ANSI correctness */
- /* CAW: switched to json_object_object_foreachC which uses an iterator struct */
- json_object_object_foreachC(this, iter) {
- if(i) sprintbuf(pb, ",");
- sprintbuf(pb, " \"");
- json_escape_str(pb, iter.key);
- sprintbuf(pb, "\": ");
- if(iter.val == NULL) sprintbuf(pb, "null");
- else iter.val->_to_json_string(iter.val, pb);
- i++;
- }
-
- return sprintbuf(pb, " }");
-}
-
-static void json_object_lh_entry_free(struct lh_entry *ent)
-{
- free(ent->k);
- json_object_put((struct json_object*)ent->v);
-}
-
-static void json_object_object_delete(struct json_object* this)
-{
- lh_table_free(this->o.c_object);
- json_object_generic_delete(this);
-}
-
-struct json_object* json_object_new_object()
-{
- struct json_object *this = json_object_new(json_type_object);
- if(!this) return NULL;
- this->_delete = &json_object_object_delete;
- this->_to_json_string = &json_object_object_to_json_string;
- this->o.c_object = lh_kchar_table_new(JSON_OBJECT_DEF_HASH_ENTIRES,
- NULL, &json_object_lh_entry_free);
- return this;
-}
-
-struct lh_table* json_object_get_object(struct json_object *this)
-{
- if(!this) return NULL;
- switch(this->o_type) {
- case json_type_object:
- return this->o.c_object;
- default:
- return NULL;
- }
-}
-
-void json_object_object_add(struct json_object* this, char *key,
- struct json_object *val)
-{
- lh_table_delete(this->o.c_object, key);
- lh_table_insert(this->o.c_object, strdup(key), val);
-}
-
-struct json_object* json_object_object_get(struct json_object* this, char *key)
-{
- return (struct json_object*) lh_table_lookup(this->o.c_object, key);
-}
-
-void json_object_object_del(struct json_object* this, char *key)
-{
- lh_table_delete(this->o.c_object, key);
-}
-
-
-/* json_object_boolean */
-
-static int json_object_boolean_to_json_string(struct json_object* this,
- struct printbuf *pb)
-{
- if(this->o.c_boolean) return sprintbuf(pb, "true");
- else return sprintbuf(pb, "false");
-}
-
-struct json_object* json_object_new_boolean(boolean b)
-{
- struct json_object *this = json_object_new(json_type_boolean);
- if(!this) return NULL;
- this->_to_json_string = &json_object_boolean_to_json_string;
- this->o.c_boolean = b;
- return this;
-}
-
-boolean json_object_get_boolean(struct json_object *this)
-{
- if(!this) return FALSE;
- switch(this->o_type) {
- case json_type_boolean:
- return this->o.c_boolean;
- case json_type_int:
- return (this->o.c_int != 0);
- case json_type_double:
- return (this->o.c_double != 0);
- case json_type_string:
- if(strlen(this->o.c_string)) return TRUE;
- default:
- return TRUE;
- }
-}
-
-
-/* json_object_int */
-
-static int json_object_int_to_json_string(struct json_object* this,
- struct printbuf *pb)
-{
- return sprintbuf(pb, "%d", this->o.c_int);
-}
-
-struct json_object* json_object_new_int(int i)
-{
- struct json_object *this = json_object_new(json_type_int);
- if(!this) return NULL;
- this->_to_json_string = &json_object_int_to_json_string;
- this->o.c_int = i;
- return this;
-}
-
-int json_object_get_int(struct json_object *this)
-{
- int cint;
-
- if(!this) return 0;
- switch(this->o_type) {
- case json_type_int:
- return this->o.c_int;
- case json_type_double:
- return (int)this->o.c_double;
- case json_type_boolean:
- return this->o.c_boolean;
- case json_type_string:
- if(sscanf(this->o.c_string, "%d", &cint) == 1) return cint;
- default:
- return 0;
- }
-}
-
-
-/* json_object_double */
-
-static int json_object_double_to_json_string(struct json_object* this,
- struct printbuf *pb)
-{
- return sprintbuf(pb, "%lf", this->o.c_double);
-}
-
-struct json_object* json_object_new_double(double d)
-{
- struct json_object *this = json_object_new(json_type_double);
- if(!this) return NULL;
- this->_to_json_string = &json_object_double_to_json_string;
- this->o.c_double = d;
- return this;
-}
-
-double json_object_get_double(struct json_object *this)
-{
- double cdouble;
-
- if(!this) return 0.0;
- switch(this->o_type) {
- case json_type_double:
- return this->o.c_double;
- case json_type_int:
- return this->o.c_int;
- case json_type_boolean:
- return this->o.c_boolean;
- case json_type_string:
- if(sscanf(this->o.c_string, "%lf", &cdouble) == 1) return cdouble;
- default:
- return 0.0;
- }
-}
-
-
-/* json_object_string */
-
-static int json_object_string_to_json_string(struct json_object* this,
- struct printbuf *pb)
-{
- sprintbuf(pb, "\"");
- json_escape_str(pb, this->o.c_string);
- sprintbuf(pb, "\"");
- return 0;
-}
-
-static void json_object_string_delete(struct json_object* this)
-{
- free(this->o.c_string);
- json_object_generic_delete(this);
-}
-
-struct json_object* json_object_new_string(char *s)
-{
- struct json_object *this = json_object_new(json_type_string);
- if(!this) return NULL;
- this->_delete = &json_object_string_delete;
- this->_to_json_string = &json_object_string_to_json_string;
- this->o.c_string = strdup(s);
- return this;
-}
-
-struct json_object* json_object_new_string_len(char *s, int len)
-{
- struct json_object *this = json_object_new(json_type_string);
- if(!this) return NULL;
- this->_delete = &json_object_string_delete;
- this->_to_json_string = &json_object_string_to_json_string;
- this->o.c_string = strndup(s, len);
- return this;
-}
-
-char* json_object_get_string(struct json_object *this)
-{
- if(!this) return NULL;
- switch(this->o_type) {
- case json_type_string:
- return this->o.c_string;
- default:
- return json_object_to_json_string(this);
- }
-}
-
-
-/* json_object_array */
-
-static int json_object_array_to_json_string(struct json_object* this,
- struct printbuf *pb)
-{
- int i;
- sprintbuf(pb, "[");
- for(i=0; i < json_object_array_length(this); i++) {
- struct json_object *val;
- if(i) { sprintbuf(pb, ", "); }
- else { sprintbuf(pb, " "); }
-
- val = json_object_array_get_idx(this, i);
- if(val == NULL) { sprintbuf(pb, "null"); }
- else { val->_to_json_string(val, pb); }
- }
- return sprintbuf(pb, " ]");
-}
-
-static void json_object_array_entry_free(void *data)
-{
- json_object_put((struct json_object*)data);
-}
-
-static void json_object_array_delete(struct json_object* this)
-{
- array_list_free(this->o.c_array);
- json_object_generic_delete(this);
-}
-
-struct json_object* json_object_new_array()
-{
- struct json_object *this = json_object_new(json_type_array);
- if(!this) return NULL;
- this->_delete = &json_object_array_delete;
- this->_to_json_string = &json_object_array_to_json_string;
- this->o.c_array = array_list_new(&json_object_array_entry_free);
- return this;
-}
-
-struct array_list* json_object_get_array(struct json_object *this)
-{
- if(!this) return NULL;
- switch(this->o_type) {
- case json_type_array:
- return this->o.c_array;
- default:
- return NULL;
- }
-}
-
-int json_object_array_length(struct json_object *this)
-{
- return array_list_length(this->o.c_array);
-}
-
-int json_object_array_add(struct json_object *this,struct json_object *val)
-{
- return array_list_add(this->o.c_array, val);
-}
-
-int json_object_array_put_idx(struct json_object *this, int idx,
- struct json_object *val)
-{
- return array_list_put_idx(this->o.c_array, idx, val);
-}
-
-struct json_object* json_object_array_get_idx(struct json_object *this,
- int idx)
-{
- return (struct json_object*)array_list_get_idx(this->o.c_array, idx);
-}
-
diff --git a/source4/lib/json/json_object.h b/source4/lib/json/json_object.h
deleted file mode 100644
index 5c25968dba..0000000000
--- a/source4/lib/json/json_object.h
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * $Id: json_object.h,v 1.12 2006/01/30 23:07:57 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-#ifndef _json_object_h_
-#define _json_object_h_
-
-#define JSON_OBJECT_DEF_HASH_ENTIRES 16
-
-#undef FALSE
-#define FALSE ((boolean)0)
-
-#undef TRUE
-#define TRUE ((boolean)1)
-
-extern char *json_number_chars;
-extern char *json_hex_chars;
-
-/* forward structure definitions */
-
-typedef int boolean;
-struct printbuf;
-struct lh_table;
-struct array_list;
-struct json_object;
-struct json_object_iter;
-
-/* supported object types */
-
-enum json_type {
- json_type_null,
- json_type_boolean,
- json_type_double,
- json_type_int,
- json_type_object,
- json_type_array,
- json_type_string
-};
-
-/* reference counting functions */
-
-/**
- * Increment the reference count of json_object
- * @param obj the json_object instance
- */
-extern struct json_object* json_object_get(struct json_object *obj);
-
-/**
- * Decrement the reference count of json_object and free if it reaches zero
- * @param obj the json_object instance
- */
-extern void json_object_put(struct json_object *obj);
-
-
-/**
- * Check if the json_object is of a given type
- * @param obj the json_object instance
- * @param type one of:
- json_type_boolean,
- json_type_double,
- json_type_int,
- json_type_object,
- json_type_array,
- json_type_string,
- */
-extern int json_object_is_type(struct json_object *obj, enum json_type type);
-
-/**
- * Get the type of the json_object
- * @param obj the json_object instance
- * @returns type being one of:
- json_type_boolean,
- json_type_double,
- json_type_int,
- json_type_object,
- json_type_array,
- json_type_string,
- */
-extern enum json_type json_object_get_type(struct json_object *obj);
-
-
-/** Stringify object to json format
- * @param obj the json_object instance
- * @returns a string in JSON format
- */
-extern char* json_object_to_json_string(struct json_object *obj);
-
-
-/* object type methods */
-
-/** Create a new empty object
- * @returns a json_object of type json_type_object
- */
-extern struct json_object* json_object_new_object();
-
-/** Get the hashtable of a json_object of type json_type_object
- * @param obj the json_object instance
- * @returns a linkhash
- */
-extern struct lh_table* json_object_get_object(struct json_object *obj);
-
-/** Add an object field to a json_object of type json_type_object
- *
- * The reference count will *not* be incremented. This is to make adding
- * fields to objects in code more compact. If you want to retain a reference
- * to an added object you must wrap the passed object with json_object_get
- *
- * @param obj the json_object instance
- * @param key the object field name (a private copy will be duplicated)
- * @param val a json_object or NULL member to associate with the given field
- */
-extern void json_object_object_add(struct json_object* obj, char *key,
- struct json_object *val);
-
-/** Get the json_object associate with a given object field
- * @param obj the json_object instance
- * @param key the object field name
- * @returns the json_object associated with the given field name
- */
-extern struct json_object* json_object_object_get(struct json_object* obj,
- char *key);
-
-/** Delete the given json_object field
- *
- * The reference count will be decremented for the deleted object
- *
- * @param obj the json_object instance
- * @param key the object field name
- */
-extern void json_object_object_del(struct json_object* obj, char *key);
-
-/** Iterate through all keys and values of an object
- * @param obj the json_object instance
- * @param key the local name for the char* key variable defined in the body
- * @param val the local name for the json_object* object variable defined in the body
- */
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-
-# define json_object_object_foreach(obj,key,val) \
- char *key; struct json_object *val; \
- for(struct lh_entry *entry = json_object_get_object(obj)->head; ({ if(entry) { key = (char*)entry->k; val = (struct json_object*)entry->v; } ; entry; }); entry = entry->next )
-
-#else /* ANSI C or MSC */
-
-# define json_object_object_foreach(obj,key,val) \
- char *key; struct json_object *val; struct lh_entry *entry; \
- for(entry = json_object_get_object(obj)->head; (entry ? (key = (char*)entry->k, val = (struct json_object*)entry->v, entry) : 0); entry = entry->next)
-
-#endif /* defined(__GNUC__) && !defined(__STRICT_ANSI__) */
-
-/** Iterate through all keys and values of an object (ANSI C Safe)
- * @param obj the json_object instance
- * @param iter the object iterator
- */
-#define json_object_object_foreachC(obj,iter) \
- for(iter.entry = json_object_get_object(obj)->head; (iter.entry ? (iter.key = (char*)iter.entry->k, iter.val = (struct json_object*)iter.entry->v, iter.entry) : 0); iter.entry = iter.entry->next)
-
-/* Array type methods */
-
-/** Create a new empty json_object of type json_type_array
- * @returns a json_object of type json_type_array
- */
-extern struct json_object* json_object_new_array();
-
-/** Get the arraylist of a json_object of type json_type_array
- * @param obj the json_object instance
- * @returns an arraylist
- */
-extern struct array_list* json_object_get_array(struct json_object *obj);
-
-/** Get the length of a json_object of type json_type_array
- * @param obj the json_object instance
- * @returns an int
- */
-extern int json_object_array_length(struct json_object *obj);
-
-/** Add an element to the end of a json_object of type json_type_array
- *
- * The reference count will *not* be incremented. This is to make adding
- * fields to objects in code more compact. If you want to retain a reference
- * to an added object you must wrap the passed object with json_object_get
- *
- * @param obj the json_object instance
- * @param val the json_object to be added
- */
-extern int json_object_array_add(struct json_object *obj,
- struct json_object *val);
-
-/** Insert or replace an element at a specified index in an array (a json_object of type json_type_array)
- *
- * The reference count will *not* be incremented. This is to make adding
- * fields to objects in code more compact. If you want to retain a reference
- * to an added object you must wrap the passed object with json_object_get
- *
- * The reference count of a replaced object will be decremented.
- *
- * The array size will be automatically be expanded to the size of the
- * index if the index is larger than the current size.
- *
- * @param obj the json_object instance
- * @param idx the index to insert the element at
- * @param val the json_object to be added
- */
-extern int json_object_array_put_idx(struct json_object *obj, int idx,
- struct json_object *val);
-
-/** Get the element at specificed index of the array (a json_object of type json_type_array)
- * @param obj the json_object instance
- * @param idx the index to get the element at
- * @returns the json_object at the specified index (or NULL)
- */
-extern struct json_object* json_object_array_get_idx(struct json_object *obj,
- int idx);
-
-/* boolean type methods */
-
-/** Create a new empty json_object of type json_type_boolean
- * @param b a boolean TRUE or FALSE (0 or 1)
- * @returns a json_object of type json_type_boolean
- */
-extern struct json_object* json_object_new_boolean(boolean b);
-
-/** Get the boolean value of a json_object
- *
- * The type is coerced to a boolean if the passed object is not a boolean.
- * integer and double objects will return FALSE if there value is zero
- * or TRUE otherwise. If the passed object is a string it will return
- * TRUE if it has a non zero length. If any other object type is passed
- * TRUE will be returned if the object is not NULL.
- *
- * @param obj the json_object instance
- * @returns a boolean
- */
-extern boolean json_object_get_boolean(struct json_object *obj);
-
-
-/* int type methods */
-
-/** Create a new empty json_object of type json_type_int
- * @param i the integer
- * @returns a json_object of type json_type_int
- */
-extern struct json_object* json_object_new_int(int i);
-
-/** Get the int value of a json_object
- *
- * The type is coerced to a int if the passed object is not a int.
- * double objects will return their integer conversion. Strings will be
- * parsed as an integer. If no conversion exists then 0 is returned.
- *
- * @param obj the json_object instance
- * @returns an int
- */
-extern int json_object_get_int(struct json_object *obj);
-
-
-/* double type methods */
-
-/** Create a new empty json_object of type json_type_double
- * @param d the double
- * @returns a json_object of type json_type_double
- */
-extern struct json_object* json_object_new_double(double d);
-
-/** Get the double value of a json_object
- *
- * The type is coerced to a double if the passed object is not a double.
- * integer objects will return their dboule conversion. Strings will be
- * parsed as a double. If no conversion exists then 0.0 is returned.
- *
- * @param obj the json_object instance
- * @returns an double
- */
-extern double json_object_get_double(struct json_object *obj);
-
-
-/* string type methods */
-
-/** Create a new empty json_object of type json_type_string
- *
- * A copy of the string is made and the memory is managed by the json_object
- *
- * @param s the string
- * @returns a json_object of type json_type_string
- */
-extern struct json_object* json_object_new_string(char *s);
-
-extern struct json_object* json_object_new_string_len(char *s, int len);
-
-/** Get the string value of a json_object
- *
- * If the passed object is not of type json_type_string then the JSON
- * representation of the object is returned.
- *
- * The returned string memory is managed by the json_object and will
- * be freed when the reference count of the json_object drops to zero.
- *
- * @param obj the json_object instance
- * @returns a string
- */
-extern char* json_object_get_string(struct json_object *obj);
-
-#endif
diff --git a/source4/lib/json/json_object_private.h b/source4/lib/json/json_object_private.h
deleted file mode 100644
index 35a44f3a09..0000000000
--- a/source4/lib/json/json_object_private.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * $Id: json_object_private.h,v 1.4 2006/01/26 02:16:28 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-#ifndef _json_object_private_h_
-#define _json_object_private_h_
-
-typedef void (json_object_delete_fn)(struct json_object *o);
-typedef int (json_object_to_json_string_fn)(struct json_object *o,
- struct printbuf *pb);
-
-struct json_object
-{
- enum json_type o_type;
- json_object_delete_fn *_delete;
- json_object_to_json_string_fn *_to_json_string;
- int _ref_count;
- struct printbuf *_pb;
- union data {
- boolean c_boolean;
- double c_double;
- int c_int;
- struct lh_table *c_object;
- struct array_list *c_array;
- char *c_string;
- } o;
-};
-
-/* CAW: added for ANSI C iteration correctness */
-struct json_object_iter
-{
- char *key;
- struct json_object *val;
- struct lh_entry *entry;
-};
-
-#endif
diff --git a/source4/lib/json/json_tokener.c b/source4/lib/json/json_tokener.c
deleted file mode 100644
index a3ebf10878..0000000000
--- a/source4/lib/json/json_tokener.c
+++ /dev/null
@@ -1,465 +0,0 @@
-/*
- * $Id: json_tokener.c,v 1.19 2006/01/30 23:07:57 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-
-#include "bits.h"
-#include "debug.h"
-#include "printbuf.h"
-#include "arraylist.h"
-#include "json_object.h"
-#include "json_tokener.h"
-
-#if !HAVE_STRNCASECMP && defined(_MSC_VER)
- /* MSC has the version as _strnicmp */
-# define strncasecmp _strnicmp
-#elif !HAVE_STRNCASECMP
-# error You do not have strncasecmp on your system.
-#endif /* HAVE_STRNCASECMP */
-
-
-static struct json_object* json_tokener_do_parse(struct json_tokener *this);
-
-struct json_object* json_tokener_parse(char * s)
-{
- struct json_tokener tok;
- struct json_object* obj;
-
- tok.source = s;
- tok.pos = 0;
- tok.pb = printbuf_new();
- obj = json_tokener_do_parse(&tok);
- printbuf_free(tok.pb);
- return obj;
-}
-
-#if !HAVE_STRNDUP
-/* CAW: compliant version of strndup() */
-char* strndup(const char* str, size_t n)
-{
- if(str) {
- size_t len = strlen(str);
- size_t nn = min(len,n);
- char* s = (char*)malloc(sizeof(char) * (nn + 1));
-
- if(s) {
- memcpy(s, str, nn);
- s[nn] = '\0';
- }
-
- return s;
- }
-
- return NULL;
-}
-#endif
-
-static struct json_object* json_tokener_do_parse(struct json_tokener *this)
-{
- enum json_tokener_state state, saved_state;
- enum json_tokener_error err = json_tokener_success;
- struct json_object *current = NULL, *obj;
- char *obj_field_name = NULL;
- char quote_char;
- int deemed_double, start_offset;
- char c;
-
- state = json_tokener_state_eatws;
- saved_state = json_tokener_state_start;
-
- do {
- c = this->source[this->pos];
- switch(state) {
-
- case json_tokener_state_eatws:
- if(isspace(c)) {
- this->pos++;
- } else if(c == '/') {
- state = json_tokener_state_comment_start;
- start_offset = this->pos++;
- } else {
- state = saved_state;
- }
- break;
-
- case json_tokener_state_start:
- switch(c) {
- case '{':
- state = json_tokener_state_eatws;
- saved_state = json_tokener_state_object;
- current = json_object_new_object();
- this->pos++;
- break;
- case '[':
- state = json_tokener_state_eatws;
- saved_state = json_tokener_state_array;
- current = json_object_new_array();
- this->pos++;
- break;
- case 'N':
- case 'n':
- state = json_tokener_state_null;
- start_offset = this->pos++;
- break;
- case '"':
- case '\'':
- quote_char = c;
- printbuf_reset(this->pb);
- state = json_tokener_state_string;
- start_offset = ++this->pos;
- break;
- case 'T':
- case 't':
- case 'F':
- case 'f':
- state = json_tokener_state_boolean;
- start_offset = this->pos++;
- break;
-#if defined(__GNUC__)
- case '0' ... '9':
-#else
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
-#endif
- case '-':
- deemed_double = 0;
- state = json_tokener_state_number;
- start_offset = this->pos++;
- break;
- default:
- err = json_tokener_error_parse_unexpected;
- goto out;
- }
- break;
-
- case json_tokener_state_finish:
- goto out;
-
- case json_tokener_state_null:
- if(strncasecmp("null", this->source + start_offset,
- this->pos - start_offset))
- return error_ptr(-json_tokener_error_parse_null);
- if(this->pos - start_offset == 4) {
- current = NULL;
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else {
- this->pos++;
- }
- break;
-
- case json_tokener_state_comment_start:
- if(c == '*') {
- state = json_tokener_state_comment;
- } else if(c == '/') {
- state = json_tokener_state_comment_eol;
- } else {
- err = json_tokener_error_parse_comment;
- goto out;
- }
- this->pos++;
- break;
-
- case json_tokener_state_comment:
- if(c == '*') state = json_tokener_state_comment_end;
- this->pos++;
- break;
-
- case json_tokener_state_comment_eol:
- if(c == '\n') {
- if(mc_get_debug()) {
- char *tmp = strndup(this->source + start_offset,
- this->pos - start_offset);
- mc_debug("json_tokener_comment: %s\n", tmp);
- free(tmp);
- }
- state = json_tokener_state_eatws;
- }
- this->pos++;
- break;
-
- case json_tokener_state_comment_end:
- if(c == '/') {
- if(mc_get_debug()) {
- char *tmp = strndup(this->source + start_offset,
- this->pos - start_offset + 1);
- mc_debug("json_tokener_comment: %s\n", tmp);
- free(tmp);
- }
- state = json_tokener_state_eatws;
- } else {
- state = json_tokener_state_comment;
- }
- this->pos++;
- break;
-
- case json_tokener_state_string:
- if(c == quote_char) {
- printbuf_memappend(this->pb, this->source + start_offset,
- this->pos - start_offset);
- current = json_object_new_string(this->pb->buf);
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else if(c == '\\') {
- saved_state = json_tokener_state_string;
- state = json_tokener_state_string_escape;
- }
- this->pos++;
- break;
-
- case json_tokener_state_string_escape:
- switch(c) {
- case '"':
- case '\\':
- printbuf_memappend(this->pb, this->source + start_offset,
- this->pos - start_offset - 1);
- start_offset = this->pos++;
- state = saved_state;
- break;
- case 'b':
- case 'n':
- case 'r':
- case 't':
- printbuf_memappend(this->pb, this->source + start_offset,
- this->pos - start_offset - 1);
- if(c == 'b') printbuf_memappend(this->pb, "\b", 1);
- else if(c == 'n') printbuf_memappend(this->pb, "\n", 1);
- else if(c == 'r') printbuf_memappend(this->pb, "\r", 1);
- else if(c == 't') printbuf_memappend(this->pb, "\t", 1);
- start_offset = ++this->pos;
- state = saved_state;
- break;
- case 'u':
- printbuf_memappend(this->pb, this->source + start_offset,
- this->pos - start_offset - 1);
- start_offset = ++this->pos;
- state = json_tokener_state_escape_unicode;
- break;
- default:
- err = json_tokener_error_parse_string;
- goto out;
- }
- break;
-
- case json_tokener_state_escape_unicode:
- if(strchr(json_hex_chars, c)) {
- this->pos++;
- if(this->pos - start_offset == 4) {
- unsigned char utf_out[3];
- unsigned int ucs_char =
- (hexdigit(*(this->source + start_offset)) << 12) +
- (hexdigit(*(this->source + start_offset + 1)) << 8) +
- (hexdigit(*(this->source + start_offset + 2)) << 4) +
- hexdigit(*(this->source + start_offset + 3));
- if (ucs_char < 0x80) {
- utf_out[0] = ucs_char;
- printbuf_memappend(this->pb, (char*)utf_out, 1);
- } else if (ucs_char < 0x800) {
- utf_out[0] = 0xc0 | (ucs_char >> 6);
- utf_out[1] = 0x80 | (ucs_char & 0x3f);
- printbuf_memappend(this->pb, (char*)utf_out, 2);
- } else {
- utf_out[0] = 0xe0 | (ucs_char >> 12);
- utf_out[1] = 0x80 | ((ucs_char >> 6) & 0x3f);
- utf_out[2] = 0x80 | (ucs_char & 0x3f);
- printbuf_memappend(this->pb, (char*)utf_out, 3);
- }
- start_offset = this->pos;
- state = saved_state;
- }
- } else {
- err = json_tokener_error_parse_string;
- goto out;
- }
- break;
-
- case json_tokener_state_boolean:
- if(strncasecmp("true", this->source + start_offset,
- this->pos - start_offset) == 0) {
- if(this->pos - start_offset == 4) {
- current = json_object_new_boolean(1);
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else {
- this->pos++;
- }
- } else if(strncasecmp("false", this->source + start_offset,
- this->pos - start_offset) == 0) {
- if(this->pos - start_offset == 5) {
- current = json_object_new_boolean(0);
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else {
- this->pos++;
- }
- } else {
- err = json_tokener_error_parse_boolean;
- goto out;
- }
- break;
-
- case json_tokener_state_number:
- if(!c || !strchr(json_number_chars, c)) {
- int numi;
- double numd;
- char *tmp = strndup(this->source + start_offset,
- this->pos - start_offset);
- if(!deemed_double && sscanf(tmp, "%d", &numi) == 1) {
- current = json_object_new_int(numi);
- } else if(deemed_double && sscanf(tmp, "%lf", &numd) == 1) {
- current = json_object_new_double(numd);
- } else {
- free(tmp);
- err = json_tokener_error_parse_number;
- goto out;
- }
- free(tmp);
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else {
- if(c == '.' || c == 'e') deemed_double = 1;
- this->pos++;
- }
- break;
-
- case json_tokener_state_array:
- if(c == ']') {
- this->pos++;
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else {
- obj = json_tokener_do_parse(this);
- if(is_error(obj)) {
- err = -(enum json_tokener_error)obj;
- goto out;
- }
- json_object_array_add(current, obj);
- saved_state = json_tokener_state_array_sep;
- state = json_tokener_state_eatws;
- }
- break;
-
- case json_tokener_state_array_sep:
- if(c == ']') {
- this->pos++;
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else if(c == ',') {
- this->pos++;
- saved_state = json_tokener_state_array;
- state = json_tokener_state_eatws;
- } else {
- json_object_put(current);
- return error_ptr(-json_tokener_error_parse_array);
- }
- break;
-
- case json_tokener_state_object:
- state = json_tokener_state_object_field_start;
- start_offset = this->pos;
- break;
-
- case json_tokener_state_object_field_start:
- if(c == '}') {
- this->pos++;
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else if (c == '"' || c == '\'') {
- quote_char = c;
- printbuf_reset(this->pb);
- state = json_tokener_state_object_field;
- start_offset = ++this->pos;
- } else {
- err = json_tokener_error_parse_object;
- goto out;
- }
- break;
-
- case json_tokener_state_object_field:
- if(c == quote_char) {
- printbuf_memappend(this->pb, this->source + start_offset,
- this->pos - start_offset);
- obj_field_name = strdup(this->pb->buf);
- saved_state = json_tokener_state_object_field_end;
- state = json_tokener_state_eatws;
- } else if(c == '\\') {
- saved_state = json_tokener_state_object_field;
- state = json_tokener_state_string_escape;
- }
- this->pos++;
- break;
-
- case json_tokener_state_object_field_end:
- if(c == ':') {
- this->pos++;
- saved_state = json_tokener_state_object_value;
- state = json_tokener_state_eatws;
- } else {
- return error_ptr(-json_tokener_error_parse_object);
- }
- break;
-
- case json_tokener_state_object_value:
- obj = json_tokener_do_parse(this);
- if(is_error(obj)) {
- err = -(enum json_tokener_error)obj;
- goto out;
- }
- json_object_object_add(current, obj_field_name, obj);
- free(obj_field_name);
- obj_field_name = NULL;
- saved_state = json_tokener_state_object_sep;
- state = json_tokener_state_eatws;
- break;
-
- case json_tokener_state_object_sep:
- if(c == '}') {
- this->pos++;
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else if(c == ',') {
- this->pos++;
- saved_state = json_tokener_state_object;
- state = json_tokener_state_eatws;
- } else {
- err = json_tokener_error_parse_object;
- goto out;
- }
- break;
-
- }
- } while(c);
-
- if(state != json_tokener_state_finish &&
- saved_state != json_tokener_state_finish)
- err = json_tokener_error_parse_eof;
-
- out:
- free(obj_field_name);
- if(err == json_tokener_success) return current;
- mc_debug("json_tokener_do_parse: error=%d state=%d char=%c\n",
- err, state, c);
- json_object_put(current);
- return error_ptr(-err);
-}
diff --git a/source4/lib/json/json_tokener.h b/source4/lib/json/json_tokener.h
deleted file mode 100644
index 12227a996b..0000000000
--- a/source4/lib/json/json_tokener.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * $Id: json_tokener.h,v 1.9 2006/01/30 23:07:57 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-#ifndef _json_tokener_h_
-#define _json_tokener_h_
-
-#include "json_object.h"
-
-enum json_tokener_error {
- json_tokener_success,
- json_tokener_error_parse_unexpected,
- json_tokener_error_parse_null,
- json_tokener_error_parse_boolean,
- json_tokener_error_parse_number,
- json_tokener_error_parse_array,
- json_tokener_error_parse_object,
- json_tokener_error_parse_string,
- json_tokener_error_parse_comment,
- json_tokener_error_parse_eof
-};
-
-enum json_tokener_state {
- json_tokener_state_eatws,
- json_tokener_state_start,
- json_tokener_state_finish,
- json_tokener_state_null,
- json_tokener_state_comment_start,
- json_tokener_state_comment,
- json_tokener_state_comment_eol,
- json_tokener_state_comment_end,
- json_tokener_state_string,
- json_tokener_state_string_escape,
- json_tokener_state_escape_unicode,
- json_tokener_state_boolean,
- json_tokener_state_number,
- json_tokener_state_array,
- json_tokener_state_array_sep,
- json_tokener_state_object,
- json_tokener_state_object_field_start,
- json_tokener_state_object_field,
- json_tokener_state_object_field_end,
- json_tokener_state_object_value,
- json_tokener_state_object_sep
-};
-
-struct json_tokener
-{
- char *source;
- int pos;
- struct printbuf *pb;
-};
-
-extern struct json_object* json_tokener_parse(char *s);
-
-#endif
diff --git a/source4/lib/json/json_util.c b/source4/lib/json/json_util.c
deleted file mode 100644
index e20be24038..0000000000
--- a/source4/lib/json/json_util.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * $Id: json_util.c,v 1.4 2006/01/30 23:07:57 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <string.h>
-#include <errno.h>
-
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif /* HAVE_SYS_TYPES_H */
-
-#if HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif /* HAVE_SYS_STAT_H */
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#endif /* HAVE_FCNTL_H */
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-
-#ifdef WIN32
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-# include <io.h>
-#endif /* defined(WIN32) */
-
-#if !HAVE_OPEN && defined(WIN32)
-# define open _open
-#endif
-
-
-#include "bits.h"
-#include "debug.h"
-#include "printbuf.h"
-#include "json_object.h"
-#include "json_tokener.h"
-#include "json_util.h"
-
-struct json_object* json_object_from_file(char *filename)
-{
- struct printbuf *pb;
- struct json_object *obj;
- char buf[JSON_FILE_BUF_SIZE];
- int fd, ret;
-
- if((fd = open(filename, O_RDONLY)) < 0) {
- mc_error("json_object_from_file: error reading file %s: %s\n",
- filename, strerror(errno));
- return error_ptr(-1);
- }
- if(!(pb = printbuf_new())) {
- mc_error("json_object_from_file: printbuf_new failed\n");
- return error_ptr(-1);
- }
- while((ret = read(fd, buf, JSON_FILE_BUF_SIZE)) > 0) {
- printbuf_memappend(pb, buf, ret);
- }
- close(fd);
- if(ret < 0) {
- mc_abort("json_object_from_file: error reading file %s: %s\n",
- filename, strerror(errno));
- printbuf_free(pb);
- return error_ptr(-1);
- }
- obj = json_tokener_parse(pb->buf);
- printbuf_free(pb);
- return obj;
-}
-
-int json_object_to_file(char *filename, struct json_object *obj)
-{
- char *json_str;
- int fd, ret;
- unsigned int wpos, wsize;
-
- if(!obj) {
- mc_error("json_object_to_file: object is null\n");
- return -1;
- }
-
- if((fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, 0644)) < 0) {
- mc_error("json_object_to_file: error opening file %s: %s\n",
- filename, strerror(errno));
- return -1;
- }
-
- if(!(json_str = json_object_to_json_string(obj))) { return -1; }
-
-
- wsize = (unsigned int)(strlen(json_str) & UINT_MAX); /* CAW: probably unnecessary, but the most 64bit safe */
- wpos = 0;
- while(wpos < wsize) {
- if((ret = write(fd, json_str + wpos, wsize-wpos)) < 0) {
- close(fd);
- mc_error("json_object_to_file: error writing file %s: %s\n",
- filename, strerror(errno));
- return -1;
- }
-
- /* because of the above check for ret < 0, we can safely cast and add */
- wpos += (unsigned int)ret;
- }
-
- close(fd);
- return 0;
-}
diff --git a/source4/lib/json/json_util.h b/source4/lib/json/json_util.h
deleted file mode 100644
index 30fe2ab2c4..0000000000
--- a/source4/lib/json/json_util.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * $Id: json_util.h,v 1.4 2006/01/30 23:07:57 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-#ifndef _json_util_h_
-#define _json_util_h_
-
-#include "json_object.h"
-
-#define JSON_FILE_BUF_SIZE 4096
-
-/* utlitiy functions */
-extern struct json_object* json_object_from_file(char *filename);
-extern int json_object_to_file(char *filename, struct json_object *obj);
-
-#endif
diff --git a/source4/lib/json/linkhash.c b/source4/lib/json/linkhash.c
deleted file mode 100644
index b04254b597..0000000000
--- a/source4/lib/json/linkhash.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * $Id: linkhash.c,v 1.4 2006/01/26 02:16:28 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stddef.h>
-#include <limits.h>
-
-#include "linkhash.h"
-
-_NORETURN_ void lh_abort(const char *msg, ...)
-{
- va_list ap;
- va_start(ap, msg);
- vprintf(msg, ap);
- exit(1);
-}
-
-unsigned long lh_ptr_hash(void *k)
-{
- /* CAW: refactored to be 64bit nice */
- return (unsigned long)((((ptrdiff_t)k * LH_PRIME) >> 4) & ULONG_MAX);
-}
-
-int lh_ptr_equal(void *k1, void *k2)
-{
- return (k1 == k2);
-}
-
-unsigned long lh_char_hash(void *k)
-{
- unsigned int h = 0;
- const char* data = k;
-
- while( *data!=0 ) h = h*129 + (unsigned int)(*data++) + LH_PRIME;
-
- return h;
-}
-
-int lh_char_equal(void *k1, void *k2)
-{
- return (strcmp((char*)k1, (char*)k2) == 0);
-}
-
-struct lh_table* lh_table_new(int size, char *name,
- lh_entry_free_fn *free_fn,
- lh_hash_fn *hash_fn,
- lh_equal_fn *equal_fn)
-{
- int i;
- struct lh_table *t;
-
- t = calloc(1, sizeof(struct lh_table));
- if(!t) lh_abort("lh_table_new: calloc failed\n");
- t->count = 0;
- t->size = size;
- t->name = name;
- t->table = calloc(size, sizeof(struct lh_entry));
- if(!t->table) lh_abort("lh_table_new: calloc failed\n");
- t->free_fn = free_fn;
- t->hash_fn = hash_fn;
- t->equal_fn = equal_fn;
- for(i = 0; i < size; i++) t->table[i].k = LH_EMPTY;
- return t;
-}
-
-struct lh_table* lh_kchar_table_new(int size, char *name,
- lh_entry_free_fn *free_fn)
-{
- return lh_table_new(size, name, free_fn, lh_char_hash, lh_char_equal);
-}
-
-struct lh_table* lh_kptr_table_new(int size, char *name,
- lh_entry_free_fn *free_fn)
-{
- return lh_table_new(size, name, free_fn, lh_ptr_hash, lh_ptr_equal);
-}
-
-void lh_table_resize(struct lh_table *t, int new_size)
-{
- struct lh_table *new_t;
- struct lh_entry *ent;
-
- new_t = lh_table_new(new_size, t->name, NULL, t->hash_fn, t->equal_fn);
- ent = t->head;
- while(ent) {
- lh_table_insert(new_t, ent->k, ent->v);
- ent = ent->next;
- }
- free(t->table);
- t->table = new_t->table;
- t->size = new_size;
- t->head = new_t->head;
- t->tail = new_t->tail;
- t->resizes++;
- free(new_t);
-}
-
-void lh_table_free(struct lh_table *t)
-{
- struct lh_entry *c;
- for(c = t->head; c != NULL; c = c->next) {
- if(t->free_fn) {
- t->free_fn(c);
- }
- }
- free(t->table);
- free(t);
-}
-
-
-int lh_table_insert(struct lh_table *t, void *k, void *v)
-{
- unsigned long h, n;
-
- t->inserts++;
- if(t->count > t->size * 0.66) lh_table_resize(t, t->size * 2);
-
- h = t->hash_fn(k);
- n = h % t->size;
-
- while( 1 ) {
- if(t->table[n].k == LH_EMPTY || t->table[n].k == LH_FREED) break;
- t->collisions++;
- if(++n == t->size) n = 0;
- }
-
- t->table[n].k = k;
- t->table[n].v = v;
- t->count++;
-
- if(t->head == NULL) {
- t->head = t->tail = &t->table[n];
- t->table[n].next = t->table[n].prev = NULL;
- } else {
- t->tail->next = &t->table[n];
- t->table[n].prev = t->tail;
- t->table[n].next = NULL;
- t->tail = &t->table[n];
- }
-
- return 0;
-}
-
-
-struct lh_entry* lh_table_lookup_entry(struct lh_table *t, void *k)
-{
- unsigned long h = t->hash_fn(k);
- unsigned long n = h % t->size;
-
- t->lookups++;
- while( 1 ) {
- if(t->table[n].k == LH_EMPTY) return NULL;
- if(t->table[n].k != LH_FREED &&
- t->equal_fn(t->table[n].k, k)) return &t->table[n];
- if(++n == t->size) n = 0;
- }
- return NULL;
-}
-
-
-void* lh_table_lookup(struct lh_table *t, void *k)
-{
- struct lh_entry *e = lh_table_lookup_entry(t, k);
- if(e) return e->v;
- return NULL;
-}
-
-
-int lh_table_delete_entry(struct lh_table *t, struct lh_entry *e)
-{
- ptrdiff_t n = (ptrdiff_t)(e - t->table); /* CAW: fixed to be 64bit nice, still need the crazy negative case... */
-
- /* CAW: this is bad, really bad, maybe stack goes other direction on this machine... */
- if(n < 0) { return -2; }
-
- if(t->table[n].k == LH_EMPTY || t->table[n].k == LH_FREED) return -1;
- t->count--;
- if(t->free_fn) t->free_fn(e);
- t->table[n].v = NULL;
- t->table[n].k = LH_FREED;
- if(t->tail == &t->table[n] && t->head == &t->table[n]) {
- t->head = t->tail = NULL;
- } else if (t->head == &t->table[n]) {
- t->head->next->prev = NULL;
- t->head = t->head->next;
- } else if (t->tail == &t->table[n]) {
- t->tail->prev->next = NULL;
- t->tail = t->tail->prev;
- } else {
- t->table[n].prev->next = t->table[n].next;
- t->table[n].next->prev = t->table[n].prev;
- }
- t->table[n].next = t->table[n].prev = NULL;
- return 0;
-}
-
-
-int lh_table_delete(struct lh_table *t, void *k)
-{
- struct lh_entry *e = lh_table_lookup_entry(t, k);
- if(!e) return -1;
- return lh_table_delete_entry(t, e);
-}
-
diff --git a/source4/lib/json/linkhash.h b/source4/lib/json/linkhash.h
deleted file mode 100644
index 5c9fa852d8..0000000000
--- a/source4/lib/json/linkhash.h
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * $Id: linkhash.h,v 1.6 2006/01/30 23:07:57 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-#ifndef _linkhash_h_
-#define _linkhash_h_
-
-/**
- * golden prime used in hash functions
- */
-#define LH_PRIME 0x9e370001UL
-
-/**
- * sentinel pointer value for empty slots
- */
-#define LH_EMPTY (void*)-1
-
-/**
- * sentinel pointer value for freed slots
- */
-#define LH_FREED (void*)-2
-
-struct lh_entry;
-
-/**
- * callback function prototypes
- */
-typedef void (lh_entry_free_fn) (struct lh_entry *e);
-/**
- * callback function prototypes
- */
-typedef unsigned long (lh_hash_fn) (void *k);
-/**
- * callback function prototypes
- */
-typedef int (lh_equal_fn) (void *k1, void *k2);
-
-/**
- * An entry in the hash table
- */
-struct lh_entry {
- /**
- * The key.
- */
- void *k;
- /**
- * The value.
- */
- void *v;
- /**
- * The next entry
- */
- struct lh_entry *next;
- /**
- * The previous entry.
- */
- struct lh_entry *prev;
-};
-
-
-/**
- * The hash table structure.
- */
-struct lh_table {
- /**
- * Size of our hash.
- */
- int size;
- /**
- * Numbers of entries.
- */
- int count;
-
- /**
- * Number of collisions.
- */
- int collisions;
-
- /**
- * Number of resizes.
- */
- int resizes;
-
- /**
- * Number of lookups.
- */
- int lookups;
-
- /**
- * Number of inserts.
- */
- int inserts;
-
- /**
- * Number of deletes.
- */
- int deletes;
-
- /**
- * Name of the hash table.
- */
- char *name;
-
- /**
- * The first entry.
- */
- struct lh_entry *head;
-
- /**
- * The last entry.
- */
- struct lh_entry *tail;
-
- struct lh_entry *table;
-
- /**
- * A pointer onto the function responsible for freeing an entry.
- */
- lh_entry_free_fn *free_fn;
- lh_hash_fn *hash_fn;
- lh_equal_fn *equal_fn;
-};
-
-
-/**
- * Pre-defined hash and equality functions
- */
-extern unsigned long lh_ptr_hash(void *k);
-extern int lh_ptr_equal(void *k1, void *k2);
-
-extern unsigned long lh_char_hash(void *k);
-extern int lh_char_equal(void *k1, void *k2);
-
-
-/**
- * Convenience list iterator.
- */
-#define lh_foreach(table, entry) \
-for(entry = table->head; entry; entry = entry->next)
-
-/**
- * lh_foreach_safe allows calling of deletion routine while iterating.
- */
-#define lh_foreach_safe(table, entry, tmp) \
-for(entry = table->head; entry && ((tmp = entry->next) || 1); entry = tmp)
-
-
-
-/**
- * Create a new linkhash table.
- * @param size initial table size. The table is automatically resized
- * although this incurs a performance penalty.
- * @param name the table name.
- * @param free_fn callback function used to free memory for entries
- * when lh_table_free or lh_table_delete is called.
- * If NULL is provided, then memory for keys and values
- * must be freed by the caller.
- * @param hash_fn function used to hash keys. 2 standard ones are defined:
- * lh_ptr_hash and lh_char_hash for hashing pointer values
- * and C strings respectively.
- * @param equal_fn comparison function to compare keys. 2 standard ones defined:
- * lh_ptr_hash and lh_char_hash for comparing pointer values
- * and C strings respectively.
- * @return a pointer onto the linkhash table.
- */
-extern struct lh_table* lh_table_new(int size, char *name,
- lh_entry_free_fn *free_fn,
- lh_hash_fn *hash_fn,
- lh_equal_fn *equal_fn);
-
-/**
- * Convenience function to create a new linkhash
- * table with char keys.
- * @param size initial table size.
- * @param name table name.
- * @param free_fn callback function used to free memory for entries.
- * @return a pointer onto the linkhash table.
- */
-extern struct lh_table* lh_kchar_table_new(int size, char *name,
- lh_entry_free_fn *free_fn);
-
-
-/**
- * Convenience function to create a new linkhash
- * table with ptr keys.
- * @param size initial table size.
- * @param name table name.
- * @param free_fn callback function used to free memory for entries.
- * @return a pointer onto the linkhash table.
- */
-extern struct lh_table* lh_kptr_table_new(int size, char *name,
- lh_entry_free_fn *free_fn);
-
-
-/**
- * Free a linkhash table.
- * If a callback free function is provided then it is called for all
- * entries in the table.
- * @param t table to free.
- */
-extern void lh_table_free(struct lh_table *t);
-
-
-/**
- * Insert a record into the table.
- * @param t the table to insert into.
- * @param k a pointer to the key to insert.
- * @param v a pointer to the value to insert.
- */
-extern int lh_table_insert(struct lh_table *t, void *k, void *v);
-
-
-/**
- * Lookup a record into the table.
- * @param t the table to lookup
- * @param k a pointer to the key to lookup
- * @return a pointer to the record structure of the value or NULL if it does not exist.
- */
-extern struct lh_entry* lh_table_lookup_entry(struct lh_table *t, void *k);
-
-/**
- * Lookup a record into the table
- * @param t the table to lookup
- * @param k a pointer to the key to lookup
- * @return a pointer to the found value or NULL if it does not exist.
- */
-extern void* lh_table_lookup(struct lh_table *t, void *k);
-
-
-/**
- * Delete a record from the table.
- * If a callback free function is provided then it is called for the
- * for the item being deleted.
- * @param t the table to delete from.
- * @param e a pointer to the entry to delete.
- * @return 0 if the item was deleted.
- * @return -1 if it was not found.
- */
-extern int lh_table_delete_entry(struct lh_table *t, struct lh_entry *e);
-
-
-/**
- * Delete a record from the table.
- * If a callback free function is provided then it is called for the
- * for the item being deleted.
- * @param t the table to delete from.
- * @param k a pointer to the key to delete.
- * @return 0 if the item was deleted.
- * @return -1 if it was not found.
- */
-extern int lh_table_delete(struct lh_table *t, void *k);
-
-
-#endif
diff --git a/source4/lib/json/ltmain.sh b/source4/lib/json/ltmain.sh
deleted file mode 100644
index cf3e25def5..0000000000
--- a/source4/lib/json/ltmain.sh
+++ /dev/null
@@ -1,6425 +0,0 @@
-# ltmain.sh - Provide generalized library-building support services.
-# NOTE: Changing this file will not affect anything until you rerun configure.
-#
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004
-# Free Software Foundation, Inc.
-# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
-#
-# 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/>.
-#
-# 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.
-
-basename="s,^.*/,,g"
-
-# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
-# is ksh but when the shell is invoked as "sh" and the current value of
-# the _XPG environment variable is not equal to 1 (one), the special
-# positional parameter $0, within a function call, is the name of the
-# function.
-progpath="$0"
-
-# The name of this program:
-progname=`echo "$progpath" | $SED $basename`
-modename="$progname"
-
-# Global variables:
-EXIT_SUCCESS=0
-EXIT_FAILURE=1
-
-PROGRAM=ltmain.sh
-PACKAGE=libtool
-VERSION=1.5.6
-TIMESTAMP=" (1.1220.2.95 2004/04/11 05:50:42) Debian$Rev: 224 $"
-
-
-# Check that we have a working $echo.
-if test "X$1" = X--no-reexec; then
- # Discard the --no-reexec flag, and continue.
- shift
-elif test "X$1" = X--fallback-echo; then
- # Avoid inline document here, it may be left over
- :
-elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
- # Yippee, $echo works!
- :
-else
- # Restart under the correct shell, and then maybe $echo will work.
- exec $SHELL "$progpath" --no-reexec ${1+"$@"}
-fi
-
-if test "X$1" = X--fallback-echo; then
- # used as fallback echo
- shift
- cat <<EOF
-$*
-EOF
- exit $EXIT_SUCCESS
-fi
-
-default_mode=
-help="Try \`$progname --help' for more information."
-magic="%%%MAGIC variable%%%"
-mkdir="mkdir"
-mv="mv -f"
-rm="rm -f"
-
-# Sed substitution that helps us do robust quoting. It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed="${SED}"' -e 1s/^X//'
-sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
-# test EBCDIC or ASCII
-case `echo A|tr A '\301'` in
- A) # EBCDIC based system
- SP2NL="tr '\100' '\n'"
- NL2SP="tr '\r\n' '\100\100'"
- ;;
- *) # Assume ASCII based system
- SP2NL="tr '\040' '\012'"
- NL2SP="tr '\015\012' '\040\040'"
- ;;
-esac
-
-# NLS nuisances.
-# Only set LANG and LC_ALL to C if already set.
-# These must not be set unconditionally because not all systems understand
-# e.g. LANG=C (notably SCO).
-# We save the old values to restore during execute mode.
-if test "${LC_ALL+set}" = set; then
- save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
-fi
-if test "${LANG+set}" = set; then
- save_LANG="$LANG"; LANG=C; export LANG
-fi
-
-# Make sure IFS has a sensible default
-: ${IFS="
-"}
-
-if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
- $echo "$modename: not configured to build any kind of library" 1>&2
- $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
- exit $EXIT_FAILURE
-fi
-
-# Global variables.
-mode=$default_mode
-nonopt=
-prev=
-prevopt=
-run=
-show="$echo"
-show_help=
-execute_dlfiles=
-lo2o="s/\\.lo\$/.${objext}/"
-o2lo="s/\\.${objext}\$/.lo/"
-
-#####################################
-# Shell function definitions:
-# This seems to be the best place for them
-
-# func_win32_libid arg
-# return the library type of file 'arg'
-#
-# Need a lot of goo to handle *both* DLLs and import libs
-# Has to be a shell function in order to 'eat' the argument
-# that is supplied when $file_magic_command is called.
-func_win32_libid () {
- win32_libid_type="unknown"
- win32_fileres=`file -L $1 2>/dev/null`
- case $win32_fileres in
- *ar\ archive\ import\ library*) # definitely import
- win32_libid_type="x86 archive import"
- ;;
- *ar\ archive*) # could be an import, or static
- if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
- $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
- win32_nmres=`eval $NM -f posix -A $1 | \
- sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
- if test "X$win32_nmres" = "Ximport" ; then
- win32_libid_type="x86 archive import"
- else
- win32_libid_type="x86 archive static"
- fi
- fi
- ;;
- *DLL*)
- win32_libid_type="x86 DLL"
- ;;
- *executable*) # but shell scripts are "executable" too...
- case $win32_fileres in
- *MS\ Windows\ PE\ Intel*)
- win32_libid_type="x86 DLL"
- ;;
- esac
- ;;
- esac
- $echo $win32_libid_type
-}
-
-
-# func_infer_tag arg
-# Infer tagged configuration to use if any are available and
-# if one wasn't chosen via the "--tag" command line option.
-# Only attempt this if the compiler in the base compile
-# command doesn't match the default compiler.
-# arg is usually of the form 'gcc ...'
-func_infer_tag () {
- if test -n "$available_tags" && test -z "$tagname"; then
- CC_quoted=
- for arg in $CC; do
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- CC_quoted="$CC_quoted $arg"
- done
- case $@ in
- # Blanks in the command may have been stripped by the calling shell,
- # but not from the CC environment variable when configure was run.
- " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
- # Blanks at the start of $base_compile will cause this to fail
- # if we don't check for them as well.
- *)
- for z in $available_tags; do
- if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
- # Evaluate the configuration.
- eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
- CC_quoted=
- for arg in $CC; do
- # Double-quote args containing other shell metacharacters.
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- CC_quoted="$CC_quoted $arg"
- done
- case "$@ " in
- " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
- # The compiler in the base compile command matches
- # the one in the tagged configuration.
- # Assume this is the tagged configuration we want.
- tagname=$z
- break
- ;;
- esac
- fi
- done
- # If $tagname still isn't set, then no tagged configuration
- # was found and let the user know that the "--tag" command
- # line option must be used.
- if test -z "$tagname"; then
- $echo "$modename: unable to infer tagged configuration"
- $echo "$modename: specify a tag with \`--tag'" 1>&2
- exit $EXIT_FAILURE
-# else
-# $echo "$modename: using $tagname tagged configuration"
- fi
- ;;
- esac
- fi
-}
-# End of Shell function definitions
-#####################################
-
-# Darwin sucks
-eval std_shrext=\"$shrext_cmds\"
-
-# Parse our command line options once, thoroughly.
-while test "$#" -gt 0
-do
- arg="$1"
- shift
-
- case $arg in
- -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
- *) optarg= ;;
- esac
-
- # If the previous option needs an argument, assign it.
- if test -n "$prev"; then
- case $prev in
- execute_dlfiles)
- execute_dlfiles="$execute_dlfiles $arg"
- ;;
- tag)
- tagname="$arg"
- preserve_args="${preserve_args}=$arg"
-
- # Check whether tagname contains only valid characters
- case $tagname in
- *[!-_A-Za-z0-9,/]*)
- $echo "$progname: invalid tag name: $tagname" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- case $tagname in
- CC)
- # Don't test for the "default" C tag, as we know, it's there, but
- # not specially marked.
- ;;
- *)
- if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
- taglist="$taglist $tagname"
- # Evaluate the configuration.
- eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
- else
- $echo "$progname: ignoring unknown tag $tagname" 1>&2
- fi
- ;;
- esac
- ;;
- *)
- eval "$prev=\$arg"
- ;;
- esac
-
- prev=
- prevopt=
- continue
- fi
-
- # Have we seen a non-optional argument yet?
- case $arg in
- --help)
- show_help=yes
- ;;
-
- --version)
- $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
- $echo
- $echo "Copyright (C) 2003 Free Software Foundation, Inc."
- $echo "This is free software; see the source for copying conditions. There is NO"
- $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
- exit $EXIT_SUCCESS
- ;;
-
- --config)
- ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
- # Now print the configurations for the tags.
- for tagname in $taglist; do
- ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
- done
- exit $EXIT_SUCCESS
- ;;
-
- --debug)
- $echo "$progname: enabling shell trace mode"
- set -x
- preserve_args="$preserve_args $arg"
- ;;
-
- --dry-run | -n)
- run=:
- ;;
-
- --features)
- $echo "host: $host"
- if test "$build_libtool_libs" = yes; then
- $echo "enable shared libraries"
- else
- $echo "disable shared libraries"
- fi
- if test "$build_old_libs" = yes; then
- $echo "enable static libraries"
- else
- $echo "disable static libraries"
- fi
- exit $EXIT_SUCCESS
- ;;
-
- --finish) mode="finish" ;;
-
- --mode) prevopt="--mode" prev=mode ;;
- --mode=*) mode="$optarg" ;;
-
- --preserve-dup-deps) duplicate_deps="yes" ;;
-
- --quiet | --silent)
- show=:
- preserve_args="$preserve_args $arg"
- ;;
-
- --tag) prevopt="--tag" prev=tag ;;
- --tag=*)
- set tag "$optarg" ${1+"$@"}
- shift
- prev=tag
- preserve_args="$preserve_args --tag"
- ;;
-
- -dlopen)
- prevopt="-dlopen"
- prev=execute_dlfiles
- ;;
-
- -*)
- $echo "$modename: unrecognized option \`$arg'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- ;;
-
- *)
- nonopt="$arg"
- break
- ;;
- esac
-done
-
-if test -n "$prevopt"; then
- $echo "$modename: option \`$prevopt' requires an argument" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
-fi
-
-# If this variable is set in any of the actions, the command in it
-# will be execed at the end. This prevents here-documents from being
-# left over by shells.
-exec_cmd=
-
-if test -z "$show_help"; then
-
- # Infer the operation mode.
- if test -z "$mode"; then
- $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
- $echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2
- case $nonopt in
- *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
- mode=link
- for arg
- do
- case $arg in
- -c)
- mode=compile
- break
- ;;
- esac
- done
- ;;
- *db | *dbx | *strace | *truss)
- mode=execute
- ;;
- *install*|cp|mv)
- mode=install
- ;;
- *rm)
- mode=uninstall
- ;;
- *)
- # If we have no mode, but dlfiles were specified, then do execute mode.
- test -n "$execute_dlfiles" && mode=execute
-
- # Just use the default operation mode.
- if test -z "$mode"; then
- if test -n "$nonopt"; then
- $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
- else
- $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
- fi
- fi
- ;;
- esac
- fi
-
- # Only execute mode is allowed to have -dlopen flags.
- if test -n "$execute_dlfiles" && test "$mode" != execute; then
- $echo "$modename: unrecognized option \`-dlopen'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Change the help message to a mode-specific one.
- generic_help="$help"
- help="Try \`$modename --help --mode=$mode' for more information."
-
- # These modes are in order of execution frequency so that they run quickly.
- case $mode in
- # libtool compile mode
- compile)
- modename="$modename: compile"
- # Get the compilation command and the source file.
- base_compile=
- srcfile="$nonopt" # always keep a non-empty value in "srcfile"
- suppress_opt=yes
- suppress_output=
- arg_mode=normal
- libobj=
- later=
-
- for arg
- do
- case "$arg_mode" in
- arg )
- # do not "continue". Instead, add this to base_compile
- lastarg="$arg"
- arg_mode=normal
- ;;
-
- target )
- libobj="$arg"
- arg_mode=normal
- continue
- ;;
-
- normal )
- # Accept any command-line options.
- case $arg in
- -o)
- if test -n "$libobj" ; then
- $echo "$modename: you cannot specify \`-o' more than once" 1>&2
- exit $EXIT_FAILURE
- fi
- arg_mode=target
- continue
- ;;
-
- -static | -prefer-pic | -prefer-non-pic)
- later="$later $arg"
- continue
- ;;
-
- -no-suppress)
- suppress_opt=no
- continue
- ;;
-
- -Xcompiler)
- arg_mode=arg # the next one goes into the "base_compile" arg list
- continue # The current "srcfile" will either be retained or
- ;; # replaced later. I would guess that would be a bug.
-
- -Wc,*)
- args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
- lastarg=
- save_ifs="$IFS"; IFS=','
- for arg in $args; do
- IFS="$save_ifs"
-
- # Double-quote args containing other shell metacharacters.
- # Many Bourne shells cannot handle close brackets correctly
- # in scan sets, so we specify it separately.
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- lastarg="$lastarg $arg"
- done
- IFS="$save_ifs"
- lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
-
- # Add the arguments to base_compile.
- base_compile="$base_compile $lastarg"
- continue
- ;;
-
- * )
- # Accept the current argument as the source file.
- # The previous "srcfile" becomes the current argument.
- #
- lastarg="$srcfile"
- srcfile="$arg"
- ;;
- esac # case $arg
- ;;
- esac # case $arg_mode
-
- # Aesthetically quote the previous argument.
- lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
-
- case $lastarg in
- # Double-quote args containing other shell metacharacters.
- # Many Bourne shells cannot handle close brackets correctly
- # in scan sets, so we specify it separately.
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- lastarg="\"$lastarg\""
- ;;
- esac
-
- base_compile="$base_compile $lastarg"
- done # for arg
-
- case $arg_mode in
- arg)
- $echo "$modename: you must specify an argument for -Xcompile"
- exit $EXIT_FAILURE
- ;;
- target)
- $echo "$modename: you must specify a target with \`-o'" 1>&2
- exit $EXIT_FAILURE
- ;;
- *)
- # Get the name of the library object.
- [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
- ;;
- esac
-
- # Recognize several different file suffixes.
- # If the user specifies -o file.o, it is replaced with file.lo
- xform='[cCFSifmso]'
- case $libobj in
- *.ada) xform=ada ;;
- *.adb) xform=adb ;;
- *.ads) xform=ads ;;
- *.asm) xform=asm ;;
- *.c++) xform=c++ ;;
- *.cc) xform=cc ;;
- *.ii) xform=ii ;;
- *.class) xform=class ;;
- *.cpp) xform=cpp ;;
- *.cxx) xform=cxx ;;
- *.f90) xform=f90 ;;
- *.for) xform=for ;;
- *.java) xform=java ;;
- esac
-
- libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
-
- case $libobj in
- *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
- *)
- $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- func_infer_tag $base_compile
-
- for arg in $later; do
- case $arg in
- -static)
- build_old_libs=yes
- continue
- ;;
-
- -prefer-pic)
- pic_mode=yes
- continue
- ;;
-
- -prefer-non-pic)
- pic_mode=no
- continue
- ;;
- esac
- done
-
- objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
- xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$xdir" = "X$obj"; then
- xdir=
- else
- xdir=$xdir/
- fi
- lobj=${xdir}$objdir/$objname
-
- if test -z "$base_compile"; then
- $echo "$modename: you must specify a compilation command" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Delete any leftover library objects.
- if test "$build_old_libs" = yes; then
- removelist="$obj $lobj $libobj ${libobj}T"
- else
- removelist="$lobj $libobj ${libobj}T"
- fi
-
- $run $rm $removelist
- trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
-
- # On Cygwin there's no "real" PIC flag so we must build both object types
- case $host_os in
- cygwin* | mingw* | pw32* | os2*)
- pic_mode=default
- ;;
- esac
- if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
- # non-PIC code in shared libraries is not supported
- pic_mode=default
- fi
-
- # Calculate the filename of the output object if compiler does
- # not support -o with -c
- if test "$compiler_c_o" = no; then
- output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
- lockfile="$output_obj.lock"
- removelist="$removelist $output_obj $lockfile"
- trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
- else
- output_obj=
- need_locks=no
- lockfile=
- fi
-
- # Lock this critical section if it is needed
- # We use this script file to make the link, it avoids creating a new file
- if test "$need_locks" = yes; then
- until $run ln "$progpath" "$lockfile" 2>/dev/null; do
- $show "Waiting for $lockfile to be removed"
- sleep 2
- done
- elif test "$need_locks" = warn; then
- if test -f "$lockfile"; then
- $echo "\
-*** ERROR, $lockfile exists and contains:
-`cat $lockfile 2>/dev/null`
-
-This indicates that another process is trying to use the same
-temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together. If you
-repeat this compilation, it may succeed, by chance, but you had better
-avoid parallel builds (make -j) in this platform, or get a better
-compiler."
-
- $run $rm $removelist
- exit $EXIT_FAILURE
- fi
- $echo $srcfile > "$lockfile"
- fi
-
- if test -n "$fix_srcfile_path"; then
- eval srcfile=\"$fix_srcfile_path\"
- fi
-
- $run $rm "$libobj" "${libobj}T"
-
- # Create a libtool object file (analogous to a ".la" file),
- # but don't create it if we're doing a dry run.
- test -z "$run" && cat > ${libobj}T <<EOF
-# $libobj - a libtool object file
-# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
-#
-# Please DO NOT delete this file!
-# It is necessary for linking the library.
-
-# Name of the PIC object.
-EOF
-
- # Only build a PIC object if we are building libtool libraries.
- if test "$build_libtool_libs" = yes; then
- # Without this assignment, base_compile gets emptied.
- fbsd_hideous_sh_bug=$base_compile
-
- if test "$pic_mode" != no; then
- command="$base_compile $srcfile $pic_flag"
- else
- # Don't build PIC code
- command="$base_compile $srcfile"
- fi
-
- if test ! -d "${xdir}$objdir"; then
- $show "$mkdir ${xdir}$objdir"
- $run $mkdir ${xdir}$objdir
- status=$?
- if test "$status" -ne 0 && test ! -d "${xdir}$objdir"; then
- exit $status
- fi
- fi
-
- if test -z "$output_obj"; then
- # Place PIC objects in $objdir
- command="$command -o $lobj"
- fi
-
- $run $rm "$lobj" "$output_obj"
-
- $show "$command"
- if $run eval "$command"; then :
- else
- test -n "$output_obj" && $run $rm $removelist
- exit $EXIT_FAILURE
- fi
-
- if test "$need_locks" = warn &&
- test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
- $echo "\
-*** ERROR, $lockfile contains:
-`cat $lockfile 2>/dev/null`
-
-but it should contain:
-$srcfile
-
-This indicates that another process is trying to use the same
-temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together. If you
-repeat this compilation, it may succeed, by chance, but you had better
-avoid parallel builds (make -j) in this platform, or get a better
-compiler."
-
- $run $rm $removelist
- exit $EXIT_FAILURE
- fi
-
- # Just move the object if needed, then go on to compile the next one
- if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
- $show "$mv $output_obj $lobj"
- if $run $mv $output_obj $lobj; then :
- else
- error=$?
- $run $rm $removelist
- exit $error
- fi
- fi
-
- # Append the name of the PIC object to the libtool object file.
- test -z "$run" && cat >> ${libobj}T <<EOF
-pic_object='$objdir/$objname'
-
-EOF
-
- # Allow error messages only from the first compilation.
- if test "$suppress_opt" = yes; then
- suppress_output=' >/dev/null 2>&1'
- fi
- else
- # No PIC object so indicate it doesn't exist in the libtool
- # object file.
- test -z "$run" && cat >> ${libobj}T <<EOF
-pic_object=none
-
-EOF
- fi
-
- # Only build a position-dependent object if we build old libraries.
- if test "$build_old_libs" = yes; then
- if test "$pic_mode" != yes; then
- # Don't build PIC code
- command="$base_compile $srcfile"
- else
- command="$base_compile $srcfile $pic_flag"
- fi
- if test "$compiler_c_o" = yes; then
- command="$command -o $obj"
- fi
-
- # Suppress compiler output if we already did a PIC compilation.
- command="$command$suppress_output"
- $run $rm "$obj" "$output_obj"
- $show "$command"
- if $run eval "$command"; then :
- else
- $run $rm $removelist
- exit $EXIT_FAILURE
- fi
-
- if test "$need_locks" = warn &&
- test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
- $echo "\
-*** ERROR, $lockfile contains:
-`cat $lockfile 2>/dev/null`
-
-but it should contain:
-$srcfile
-
-This indicates that another process is trying to use the same
-temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together. If you
-repeat this compilation, it may succeed, by chance, but you had better
-avoid parallel builds (make -j) in this platform, or get a better
-compiler."
-
- $run $rm $removelist
- exit $EXIT_FAILURE
- fi
-
- # Just move the object if needed
- if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
- $show "$mv $output_obj $obj"
- if $run $mv $output_obj $obj; then :
- else
- error=$?
- $run $rm $removelist
- exit $error
- fi
- fi
-
- # Append the name of the non-PIC object the libtool object file.
- # Only append if the libtool object file exists.
- test -z "$run" && cat >> ${libobj}T <<EOF
-# Name of the non-PIC object.
-non_pic_object='$objname'
-
-EOF
- else
- # Append the name of the non-PIC object the libtool object file.
- # Only append if the libtool object file exists.
- test -z "$run" && cat >> ${libobj}T <<EOF
-# Name of the non-PIC object.
-non_pic_object=none
-
-EOF
- fi
-
- $run $mv "${libobj}T" "${libobj}"
-
- # Unlock the critical section if it was locked
- if test "$need_locks" != no; then
- $run $rm "$lockfile"
- fi
-
- exit $EXIT_SUCCESS
- ;;
-
- # libtool link mode
- link | relink)
- modename="$modename: link"
- case $host in
- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
- # It is impossible to link a dll without this setting, and
- # we shouldn't force the makefile maintainer to figure out
- # which system we are compiling for in order to pass an extra
- # flag for every libtool invocation.
- # allow_undefined=no
-
- # FIXME: Unfortunately, there are problems with the above when trying
- # to make a dll which has undefined symbols, in which case not
- # even a static library is built. For now, we need to specify
- # -no-undefined on the libtool link line when we can be certain
- # that all symbols are satisfied, otherwise we get a static library.
- allow_undefined=yes
- ;;
- *)
- allow_undefined=yes
- ;;
- esac
- libtool_args="$nonopt"
- base_compile="$nonopt $@"
- compile_command="$nonopt"
- finalize_command="$nonopt"
-
- compile_rpath=
- finalize_rpath=
- compile_shlibpath=
- finalize_shlibpath=
- convenience=
- old_convenience=
- deplibs=
- old_deplibs=
- compiler_flags=
- linker_flags=
- dllsearchpath=
- lib_search_path=`pwd`
- inst_prefix_dir=
-
- avoid_version=no
- dlfiles=
- dlprefiles=
- dlself=no
- export_dynamic=no
- export_symbols=
- export_symbols_regex=
- generated=
- libobjs=
- ltlibs=
- module=no
- no_install=no
- objs=
- non_pic_objects=
- precious_files_regex=
- prefer_static_libs=no
- preload=no
- prev=
- prevarg=
- release=
- rpath=
- xrpath=
- perm_rpath=
- temp_rpath=
- thread_safe=no
- vinfo=
- vinfo_number=no
-
- func_infer_tag $base_compile
-
- # We need to know -static, to get the right output filenames.
- for arg
- do
- case $arg in
- -all-static | -static)
- if test "X$arg" = "X-all-static"; then
- if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
- $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
- fi
- if test -n "$link_static_flag"; then
- dlopen_self=$dlopen_self_static
- fi
- else
- if test -z "$pic_flag" && test -n "$link_static_flag"; then
- dlopen_self=$dlopen_self_static
- fi
- fi
- build_libtool_libs=no
- build_old_libs=yes
- prefer_static_libs=yes
- break
- ;;
- esac
- done
-
- # See if our shared archives depend on static archives.
- test -n "$old_archive_from_new_cmds" && build_old_libs=yes
-
- # Go through the arguments, transforming them on the way.
- while test "$#" -gt 0; do
- arg="$1"
- shift
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
- ;;
- *) qarg=$arg ;;
- esac
- libtool_args="$libtool_args $qarg"
-
- # If the previous option needs an argument, assign it.
- if test -n "$prev"; then
- case $prev in
- output)
- compile_command="$compile_command @OUTPUT@"
- finalize_command="$finalize_command @OUTPUT@"
- ;;
- esac
-
- case $prev in
- dlfiles|dlprefiles)
- if test "$preload" = no; then
- # Add the symbol object into the linking commands.
- compile_command="$compile_command @SYMFILE@"
- finalize_command="$finalize_command @SYMFILE@"
- preload=yes
- fi
- case $arg in
- *.la | *.lo) ;; # We handle these cases below.
- force)
- if test "$dlself" = no; then
- dlself=needless
- export_dynamic=yes
- fi
- prev=
- continue
- ;;
- self)
- if test "$prev" = dlprefiles; then
- dlself=yes
- elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
- dlself=yes
- else
- dlself=needless
- export_dynamic=yes
- fi
- prev=
- continue
- ;;
- *)
- if test "$prev" = dlfiles; then
- dlfiles="$dlfiles $arg"
- else
- dlprefiles="$dlprefiles $arg"
- fi
- prev=
- continue
- ;;
- esac
- ;;
- expsyms)
- export_symbols="$arg"
- if test ! -f "$arg"; then
- $echo "$modename: symbol file \`$arg' does not exist"
- exit $EXIT_FAILURE
- fi
- prev=
- continue
- ;;
- expsyms_regex)
- export_symbols_regex="$arg"
- prev=
- continue
- ;;
- inst_prefix)
- inst_prefix_dir="$arg"
- prev=
- continue
- ;;
- precious_regex)
- precious_files_regex="$arg"
- prev=
- continue
- ;;
- release)
- release="-$arg"
- prev=
- continue
- ;;
- objectlist)
- if test -f "$arg"; then
- save_arg=$arg
- moreargs=
- for fil in `cat $save_arg`
- do
-# moreargs="$moreargs $fil"
- arg=$fil
- # A libtool-controlled object.
-
- # Check to see that this really is a libtool object.
- if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- pic_object=
- non_pic_object=
-
- # Read the .lo file
- # If there is no directory component, then add one.
- case $arg in
- */* | *\\*) . $arg ;;
- *) . ./$arg ;;
- esac
-
- if test -z "$pic_object" || \
- test -z "$non_pic_object" ||
- test "$pic_object" = none && \
- test "$non_pic_object" = none; then
- $echo "$modename: cannot find name of object for \`$arg'" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Extract subdirectory from the argument.
- xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$xdir" = "X$arg"; then
- xdir=
- else
- xdir="$xdir/"
- fi
-
- if test "$pic_object" != none; then
- # Prepend the subdirectory the object is found in.
- pic_object="$xdir$pic_object"
-
- if test "$prev" = dlfiles; then
- if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
- dlfiles="$dlfiles $pic_object"
- prev=
- continue
- else
- # If libtool objects are unsupported, then we need to preload.
- prev=dlprefiles
- fi
- fi
-
- # CHECK ME: I think I busted this. -Ossama
- if test "$prev" = dlprefiles; then
- # Preload the old-style object.
- dlprefiles="$dlprefiles $pic_object"
- prev=
- fi
-
- # A PIC object.
- libobjs="$libobjs $pic_object"
- arg="$pic_object"
- fi
-
- # Non-PIC object.
- if test "$non_pic_object" != none; then
- # Prepend the subdirectory the object is found in.
- non_pic_object="$xdir$non_pic_object"
-
- # A standard non-PIC object
- non_pic_objects="$non_pic_objects $non_pic_object"
- if test -z "$pic_object" || test "$pic_object" = none ; then
- arg="$non_pic_object"
- fi
- fi
- else
- # Only an error if not doing a dry-run.
- if test -z "$run"; then
- $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
- exit $EXIT_FAILURE
- else
- # Dry-run case.
-
- # Extract subdirectory from the argument.
- xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$xdir" = "X$arg"; then
- xdir=
- else
- xdir="$xdir/"
- fi
-
- pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
- non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
- libobjs="$libobjs $pic_object"
- non_pic_objects="$non_pic_objects $non_pic_object"
- fi
- fi
- done
- else
- $echo "$modename: link input file \`$save_arg' does not exist"
- exit $EXIT_FAILURE
- fi
- arg=$save_arg
- prev=
- continue
- ;;
- rpath | xrpath)
- # We need an absolute path.
- case $arg in
- [\\/]* | [A-Za-z]:[\\/]*) ;;
- *)
- $echo "$modename: only absolute run-paths are allowed" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- if test "$prev" = rpath; then
- case "$rpath " in
- *" $arg "*) ;;
- *) rpath="$rpath $arg" ;;
- esac
- else
- case "$xrpath " in
- *" $arg "*) ;;
- *) xrpath="$xrpath $arg" ;;
- esac
- fi
- prev=
- continue
- ;;
- xcompiler)
- compiler_flags="$compiler_flags $qarg"
- prev=
- compile_command="$compile_command $qarg"
- finalize_command="$finalize_command $qarg"
- continue
- ;;
- xlinker)
- linker_flags="$linker_flags $qarg"
- compiler_flags="$compiler_flags $wl$qarg"
- prev=
- compile_command="$compile_command $wl$qarg"
- finalize_command="$finalize_command $wl$qarg"
- continue
- ;;
- xcclinker)
- linker_flags="$linker_flags $qarg"
- compiler_flags="$compiler_flags $qarg"
- prev=
- compile_command="$compile_command $qarg"
- finalize_command="$finalize_command $qarg"
- continue
- ;;
- shrext)
- shrext_cmds="$arg"
- prev=
- continue
- ;;
- *)
- eval "$prev=\"\$arg\""
- prev=
- continue
- ;;
- esac
- fi # test -n "$prev"
-
- prevarg="$arg"
-
- case $arg in
- -all-static)
- if test -n "$link_static_flag"; then
- compile_command="$compile_command $link_static_flag"
- finalize_command="$finalize_command $link_static_flag"
- fi
- continue
- ;;
-
- -allow-undefined)
- # FIXME: remove this flag sometime in the future.
- $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
- continue
- ;;
-
- -avoid-version)
- avoid_version=yes
- continue
- ;;
-
- -dlopen)
- prev=dlfiles
- continue
- ;;
-
- -dlpreopen)
- prev=dlprefiles
- continue
- ;;
-
- -export-dynamic)
- export_dynamic=yes
- continue
- ;;
-
- -export-symbols | -export-symbols-regex)
- if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
- $echo "$modename: more than one -exported-symbols argument is not allowed"
- exit $EXIT_FAILURE
- fi
- if test "X$arg" = "X-export-symbols"; then
- prev=expsyms
- else
- prev=expsyms_regex
- fi
- continue
- ;;
-
- -inst-prefix-dir)
- prev=inst_prefix
- continue
- ;;
-
- # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
- # so, if we see these flags be careful not to treat them like -L
- -L[A-Z][A-Z]*:*)
- case $with_gcc/$host in
- no/*-*-irix* | /*-*-irix*)
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- ;;
- esac
- continue
- ;;
-
- -L*)
- dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
- # We need an absolute path.
- case $dir in
- [\\/]* | [A-Za-z]:[\\/]*) ;;
- *)
- absdir=`cd "$dir" && pwd`
- if test -z "$absdir"; then
- $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
- exit $EXIT_FAILURE
- fi
- dir="$absdir"
- ;;
- esac
- case "$deplibs " in
- *" -L$dir "*) ;;
- *)
- deplibs="$deplibs -L$dir"
- lib_search_path="$lib_search_path $dir"
- ;;
- esac
- case $host in
- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
- case :$dllsearchpath: in
- *":$dir:"*) ;;
- *) dllsearchpath="$dllsearchpath:$dir";;
- esac
- ;;
- esac
- continue
- ;;
-
- -l*)
- if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
- case $host in
- *-*-cygwin* | *-*-pw32* | *-*-beos*)
- # These systems don't actually have a C or math library (as such)
- continue
- ;;
- *-*-mingw* | *-*-os2*)
- # These systems don't actually have a C library (as such)
- test "X$arg" = "X-lc" && continue
- ;;
- *-*-openbsd* | *-*-freebsd*)
- # Do not include libc due to us having libc/libc_r.
- test "X$arg" = "X-lc" && continue
- ;;
- *-*-rhapsody* | *-*-darwin1.[012])
- # Rhapsody C and math libraries are in the System framework
- deplibs="$deplibs -framework System"
- continue
- esac
- elif test "X$arg" = "X-lc_r"; then
- case $host in
- *-*-openbsd* | *-*-freebsd*)
- # Do not include libc_r directly, use -pthread flag.
- continue
- ;;
- esac
- fi
- deplibs="$deplibs $arg"
- continue
- ;;
-
- -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
- deplibs="$deplibs $arg"
- continue
- ;;
-
- -module)
- module=yes
- continue
- ;;
-
- # gcc -m* arguments should be passed to the linker via $compiler_flags
- # in order to pass architecture information to the linker
- # (e.g. 32 vs 64-bit). This may also be accomplished via -Wl,-mfoo
- # but this is not reliable with gcc because gcc may use -mfoo to
- # select a different linker, different libraries, etc, while
- # -Wl,-mfoo simply passes -mfoo to the linker.
- -m*)
- # Unknown arguments in both finalize_command and compile_command need
- # to be aesthetically quoted because they are evaled later.
- arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- if test "$with_gcc" = "yes" ; then
- compiler_flags="$compiler_flags $arg"
- fi
- continue
- ;;
-
- -shrext)
- prev=shrext
- continue
- ;;
-
- -no-fast-install)
- fast_install=no
- continue
- ;;
-
- -no-install)
- case $host in
- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
- # The PATH hackery in wrapper scripts is required on Windows
- # in order for the loader to find any dlls it needs.
- $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
- $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
- fast_install=no
- ;;
- *) no_install=yes ;;
- esac
- continue
- ;;
-
- -no-undefined)
- allow_undefined=no
- continue
- ;;
-
- -objectlist)
- prev=objectlist
- continue
- ;;
-
- -o) prev=output ;;
-
- -precious-files-regex)
- prev=precious_regex
- continue
- ;;
-
- -release)
- prev=release
- continue
- ;;
-
- -rpath)
- prev=rpath
- continue
- ;;
-
- -R)
- prev=xrpath
- continue
- ;;
-
- -R*)
- dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
- # We need an absolute path.
- case $dir in
- [\\/]* | [A-Za-z]:[\\/]*) ;;
- *)
- $echo "$modename: only absolute run-paths are allowed" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- case "$xrpath " in
- *" $dir "*) ;;
- *) xrpath="$xrpath $dir" ;;
- esac
- continue
- ;;
-
- -static)
- # The effects of -static are defined in a previous loop.
- # We used to do the same as -all-static on platforms that
- # didn't have a PIC flag, but the assumption that the effects
- # would be equivalent was wrong. It would break on at least
- # Digital Unix and AIX.
- continue
- ;;
-
- -thread-safe)
- thread_safe=yes
- continue
- ;;
-
- -version-info)
- prev=vinfo
- continue
- ;;
- -version-number)
- prev=vinfo
- vinfo_number=yes
- continue
- ;;
-
- -Wc,*)
- args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
- arg=
- save_ifs="$IFS"; IFS=','
- for flag in $args; do
- IFS="$save_ifs"
- case $flag in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- flag="\"$flag\""
- ;;
- esac
- arg="$arg $wl$flag"
- compiler_flags="$compiler_flags $flag"
- done
- IFS="$save_ifs"
- arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
- ;;
-
- -Wl,*)
- args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
- arg=
- save_ifs="$IFS"; IFS=','
- for flag in $args; do
- IFS="$save_ifs"
- case $flag in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- flag="\"$flag\""
- ;;
- esac
- arg="$arg $wl$flag"
- compiler_flags="$compiler_flags $wl$flag"
- linker_flags="$linker_flags $flag"
- done
- IFS="$save_ifs"
- arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
- ;;
-
- -Xcompiler)
- prev=xcompiler
- continue
- ;;
-
- -Xlinker)
- prev=xlinker
- continue
- ;;
-
- -XCClinker)
- prev=xcclinker
- continue
- ;;
-
- # Some other compiler flag.
- -* | +*)
- # Unknown arguments in both finalize_command and compile_command need
- # to be aesthetically quoted because they are evaled later.
- arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- ;;
-
- *.$objext)
- # A standard object.
- objs="$objs $arg"
- ;;
-
- *.lo)
- # A libtool-controlled object.
-
- # Check to see that this really is a libtool object.
- if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- pic_object=
- non_pic_object=
-
- # Read the .lo file
- # If there is no directory component, then add one.
- case $arg in
- */* | *\\*) . $arg ;;
- *) . ./$arg ;;
- esac
-
- if test -z "$pic_object" || \
- test -z "$non_pic_object" ||
- test "$pic_object" = none && \
- test "$non_pic_object" = none; then
- $echo "$modename: cannot find name of object for \`$arg'" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Extract subdirectory from the argument.
- xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$xdir" = "X$arg"; then
- xdir=
- else
- xdir="$xdir/"
- fi
-
- if test "$pic_object" != none; then
- # Prepend the subdirectory the object is found in.
- pic_object="$xdir$pic_object"
-
- if test "$prev" = dlfiles; then
- if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
- dlfiles="$dlfiles $pic_object"
- prev=
- continue
- else
- # If libtool objects are unsupported, then we need to preload.
- prev=dlprefiles
- fi
- fi
-
- # CHECK ME: I think I busted this. -Ossama
- if test "$prev" = dlprefiles; then
- # Preload the old-style object.
- dlprefiles="$dlprefiles $pic_object"
- prev=
- fi
-
- # A PIC object.
- libobjs="$libobjs $pic_object"
- arg="$pic_object"
- fi
-
- # Non-PIC object.
- if test "$non_pic_object" != none; then
- # Prepend the subdirectory the object is found in.
- non_pic_object="$xdir$non_pic_object"
-
- # A standard non-PIC object
- non_pic_objects="$non_pic_objects $non_pic_object"
- if test -z "$pic_object" || test "$pic_object" = none ; then
- arg="$non_pic_object"
- fi
- fi
- else
- # Only an error if not doing a dry-run.
- if test -z "$run"; then
- $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
- exit $EXIT_FAILURE
- else
- # Dry-run case.
-
- # Extract subdirectory from the argument.
- xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$xdir" = "X$arg"; then
- xdir=
- else
- xdir="$xdir/"
- fi
-
- pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
- non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
- libobjs="$libobjs $pic_object"
- non_pic_objects="$non_pic_objects $non_pic_object"
- fi
- fi
- ;;
-
- *.$libext)
- # An archive.
- deplibs="$deplibs $arg"
- old_deplibs="$old_deplibs $arg"
- continue
- ;;
-
- *.la)
- # A libtool-controlled library.
-
- if test "$prev" = dlfiles; then
- # This library was specified with -dlopen.
- dlfiles="$dlfiles $arg"
- prev=
- elif test "$prev" = dlprefiles; then
- # The library was specified with -dlpreopen.
- dlprefiles="$dlprefiles $arg"
- prev=
- else
- deplibs="$deplibs $arg"
- fi
- continue
- ;;
-
- # Some other compiler argument.
- *)
- # Unknown arguments in both finalize_command and compile_command need
- # to be aesthetically quoted because they are evaled later.
- arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- ;;
- esac # arg
-
- # Now actually substitute the argument into the commands.
- if test -n "$arg"; then
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- fi
- done # argument parsing loop
-
- if test -n "$prev"; then
- $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
- eval arg=\"$export_dynamic_flag_spec\"
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- fi
-
- oldlibs=
- # calculate the name of the file, without its directory
- outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
- libobjs_save="$libobjs"
-
- if test -n "$shlibpath_var"; then
- # get the directories listed in $shlibpath_var
- eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
- else
- shlib_search_path=
- fi
- eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
- eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
-
- output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$output_objdir" = "X$output"; then
- output_objdir="$objdir"
- else
- output_objdir="$output_objdir/$objdir"
- fi
- # Create the object directory.
- if test ! -d "$output_objdir"; then
- $show "$mkdir $output_objdir"
- $run $mkdir $output_objdir
- status=$?
- if test "$status" -ne 0 && test ! -d "$output_objdir"; then
- exit $status
- fi
- fi
-
- # Determine the type of output
- case $output in
- "")
- $echo "$modename: you must specify an output file" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- ;;
- *.$libext) linkmode=oldlib ;;
- *.lo | *.$objext) linkmode=obj ;;
- *.la) linkmode=lib ;;
- *) linkmode=prog ;; # Anything else should be a program.
- esac
-
- case $host in
- *cygwin* | *mingw* | *pw32*)
- # don't eliminate duplications in $postdeps and $predeps
- duplicate_compiler_generated_deps=yes
- ;;
- *)
- duplicate_compiler_generated_deps=$duplicate_deps
- ;;
- esac
- specialdeplibs=
-
- libs=
- # Find all interdependent deplibs by searching for libraries
- # that are linked more than once (e.g. -la -lb -la)
- for deplib in $deplibs; do
- if test "X$duplicate_deps" = "Xyes" ; then
- case "$libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
- fi
- libs="$libs $deplib"
- done
-
- if test "$linkmode" = lib; then
- libs="$predeps $libs $compiler_lib_search_path $postdeps"
-
- # Compute libraries that are listed more than once in $predeps
- # $postdeps and mark them as special (i.e., whose duplicates are
- # not to be eliminated).
- pre_post_deps=
- if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
- for pre_post_dep in $predeps $postdeps; do
- case "$pre_post_deps " in
- *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
- esac
- pre_post_deps="$pre_post_deps $pre_post_dep"
- done
- fi
- pre_post_deps=
- fi
-
- deplibs=
- newdependency_libs=
- newlib_search_path=
- need_relink=no # whether we're linking any uninstalled libtool libraries
- notinst_deplibs= # not-installed libtool libraries
- notinst_path= # paths that contain not-installed libtool libraries
- case $linkmode in
- lib)
- passes="conv link"
- for file in $dlfiles $dlprefiles; do
- case $file in
- *.la) ;;
- *)
- $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- done
- ;;
- prog)
- compile_deplibs=
- finalize_deplibs=
- alldeplibs=no
- newdlfiles=
- newdlprefiles=
- passes="conv scan dlopen dlpreopen link"
- ;;
- *) passes="conv"
- ;;
- esac
- for pass in $passes; do
- if test "$linkmode,$pass" = "lib,link" ||
- test "$linkmode,$pass" = "prog,scan"; then
- libs="$deplibs"
- deplibs=
- fi
- if test "$linkmode" = prog; then
- case $pass in
- dlopen) libs="$dlfiles" ;;
- dlpreopen) libs="$dlprefiles" ;;
- link)
- libs="$deplibs %DEPLIBS%"
- test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
- ;;
- esac
- fi
- if test "$pass" = dlopen; then
- # Collect dlpreopened libraries
- save_deplibs="$deplibs"
- deplibs=
- fi
- for deplib in $libs; do
- lib=
- found=no
- case $deplib in
- -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
- if test "$linkmode,$pass" = "prog,link"; then
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- else
- deplibs="$deplib $deplibs"
- fi
- continue
- ;;
- -l*)
- if test "$linkmode" != lib && test "$linkmode" != prog; then
- $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
- continue
- fi
- name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
- for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
- for search_ext in .la $std_shrext .so .a; do
- # Search the libtool library
- lib="$searchdir/lib${name}${search_ext}"
- if test -f "$lib"; then
- if test "$search_ext" = ".la"; then
- found=yes
- else
- found=no
- fi
- break 2
- fi
- done
- done
- if test "$found" != yes; then
- # deplib doesn't seem to be a libtool library
- if test "$linkmode,$pass" = "prog,link"; then
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- else
- deplibs="$deplib $deplibs"
- test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
- fi
- continue
- else # deplib is a libtool library
- # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
- # We need to do some special things here, and not later.
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- case " $predeps $postdeps " in
- *" $deplib "*)
- if (${SED} -e '2q' $lib |
- grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- library_names=
- old_library=
- case $lib in
- */* | *\\*) . $lib ;;
- *) . ./$lib ;;
- esac
- for l in $old_library $library_names; do
- ll="$l"
- done
- if test "X$ll" = "X$old_library" ; then # only static version available
- found=no
- ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
- test "X$ladir" = "X$lib" && ladir="."
- lib=$ladir/$old_library
- if test "$linkmode,$pass" = "prog,link"; then
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- else
- deplibs="$deplib $deplibs"
- test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
- fi
- continue
- fi
- fi
- ;;
- *) ;;
- esac
- fi
- fi
- ;; # -l
- -L*)
- case $linkmode in
- lib)
- deplibs="$deplib $deplibs"
- test "$pass" = conv && continue
- newdependency_libs="$deplib $newdependency_libs"
- newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
- ;;
- prog)
- if test "$pass" = conv; then
- deplibs="$deplib $deplibs"
- continue
- fi
- if test "$pass" = scan; then
- deplibs="$deplib $deplibs"
- else
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- fi
- newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
- ;;
- *)
- $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
- ;;
- esac # linkmode
- continue
- ;; # -L
- -R*)
- if test "$pass" = link; then
- dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
- # Make sure the xrpath contains only unique directories.
- case "$xrpath " in
- *" $dir "*) ;;
- *) xrpath="$xrpath $dir" ;;
- esac
- fi
- deplibs="$deplib $deplibs"
- continue
- ;;
- *.la) lib="$deplib" ;;
- *.$libext)
- if test "$pass" = conv; then
- deplibs="$deplib $deplibs"
- continue
- fi
- case $linkmode in
- lib)
- if test "$deplibs_check_method" != pass_all; then
- $echo
- $echo "*** Warning: Trying to link with static lib archive $deplib."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which you do not appear to have"
- $echo "*** because the file extensions .$libext of this argument makes me believe"
- $echo "*** that it is just a static archive that I should not used here."
- else
- $echo
- $echo "*** Warning: Linking the shared library $output against the"
- $echo "*** static library $deplib is not portable!"
- deplibs="$deplib $deplibs"
- fi
- continue
- ;;
- prog)
- if test "$pass" != link; then
- deplibs="$deplib $deplibs"
- else
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- fi
- continue
- ;;
- esac # linkmode
- ;; # *.$libext
- *.lo | *.$objext)
- if test "$pass" = conv; then
- deplibs="$deplib $deplibs"
- elif test "$linkmode" = prog; then
- if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
- # If there is no dlopen support or we're linking statically,
- # we need to preload.
- newdlprefiles="$newdlprefiles $deplib"
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- else
- newdlfiles="$newdlfiles $deplib"
- fi
- fi
- continue
- ;;
- %DEPLIBS%)
- alldeplibs=yes
- continue
- ;;
- esac # case $deplib
- if test "$found" = yes || test -f "$lib"; then :
- else
- $echo "$modename: cannot find the library \`$lib'" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Check to see that this really is a libtool archive.
- if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
- else
- $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
- exit $EXIT_FAILURE
- fi
-
- ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
- test "X$ladir" = "X$lib" && ladir="."
-
- dlname=
- dlopen=
- dlpreopen=
- libdir=
- library_names=
- old_library=
- # If the library was installed with an old release of libtool,
- # it will not redefine variables installed, or shouldnotlink
- installed=yes
- shouldnotlink=no
-
- # Read the .la file
- case $lib in
- */* | *\\*) . $lib ;;
- *) . ./$lib ;;
- esac
-
- if test "$linkmode,$pass" = "lib,link" ||
- test "$linkmode,$pass" = "prog,scan" ||
- { test "$linkmode" != prog && test "$linkmode" != lib; }; then
- test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
- test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
- fi
-
- if test "$pass" = conv; then
- # Only check for convenience libraries
- deplibs="$lib $deplibs"
- if test -z "$libdir"; then
- if test -z "$old_library"; then
- $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
- exit $EXIT_FAILURE
- fi
- # It is a libtool convenience library, so add in its objects.
- convenience="$convenience $ladir/$objdir/$old_library"
- old_convenience="$old_convenience $ladir/$objdir/$old_library"
- tmp_libs=
- for deplib in $dependency_libs; do
- deplibs="$deplib $deplibs"
- if test "X$duplicate_deps" = "Xyes" ; then
- case "$tmp_libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
- fi
- tmp_libs="$tmp_libs $deplib"
- done
- elif test "$linkmode" != prog && test "$linkmode" != lib; then
- $echo "$modename: \`$lib' is not a convenience library" 1>&2
- exit $EXIT_FAILURE
- fi
- continue
- fi # $pass = conv
-
-
- # Get the name of the library we link against.
- linklib=
- for l in $old_library $library_names; do
- linklib="$l"
- done
- if test -z "$linklib"; then
- $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # This library was specified with -dlopen.
- if test "$pass" = dlopen; then
- if test -z "$libdir"; then
- $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
- exit $EXIT_FAILURE
- fi
- if test -z "$dlname" ||
- test "$dlopen_support" != yes ||
- test "$build_libtool_libs" = no; then
- # If there is no dlname, no dlopen support or we're linking
- # statically, we need to preload. We also need to preload any
- # dependent libraries so libltdl's deplib preloader doesn't
- # bomb out in the load deplibs phase.
- dlprefiles="$dlprefiles $lib $dependency_libs"
- else
- newdlfiles="$newdlfiles $lib"
- fi
- continue
- fi # $pass = dlopen
-
- # We need an absolute path.
- case $ladir in
- [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
- *)
- abs_ladir=`cd "$ladir" && pwd`
- if test -z "$abs_ladir"; then
- $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
- $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
- abs_ladir="$ladir"
- fi
- ;;
- esac
- laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
-
- # Find the relevant object directory and library name.
- if test "X$installed" = Xyes; then
- if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
- $echo "$modename: warning: library \`$lib' was moved." 1>&2
- dir="$ladir"
- absdir="$abs_ladir"
- libdir="$abs_ladir"
- else
- dir="$libdir"
- absdir="$libdir"
- fi
- else
- dir="$ladir/$objdir"
- absdir="$abs_ladir/$objdir"
- # Remove this search path later
- notinst_path="$notinst_path $abs_ladir"
- fi # $installed = yes
- name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
-
- # This library was specified with -dlpreopen.
- if test "$pass" = dlpreopen; then
- if test -z "$libdir"; then
- $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
- exit $EXIT_FAILURE
- fi
- # Prefer using a static library (so that no silly _DYNAMIC symbols
- # are required to link).
- if test -n "$old_library"; then
- newdlprefiles="$newdlprefiles $dir/$old_library"
- # Otherwise, use the dlname, so that lt_dlopen finds it.
- elif test -n "$dlname"; then
- newdlprefiles="$newdlprefiles $dir/$dlname"
- else
- newdlprefiles="$newdlprefiles $dir/$linklib"
- fi
- fi # $pass = dlpreopen
-
- if test -z "$libdir"; then
- # Link the convenience library
- if test "$linkmode" = lib; then
- deplibs="$dir/$old_library $deplibs"
- elif test "$linkmode,$pass" = "prog,link"; then
- compile_deplibs="$dir/$old_library $compile_deplibs"
- finalize_deplibs="$dir/$old_library $finalize_deplibs"
- else
- deplibs="$lib $deplibs" # used for prog,scan pass
- fi
- continue
- fi
-
-
- if test "$linkmode" = prog && test "$pass" != link; then
- newlib_search_path="$newlib_search_path $ladir"
- deplibs="$lib $deplibs"
-
- linkalldeplibs=no
- if test "$link_all_deplibs" != no || test -z "$library_names" ||
- test "$build_libtool_libs" = no; then
- linkalldeplibs=yes
- fi
-
- tmp_libs=
- for deplib in $dependency_libs; do
- case $deplib in
- -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
- esac
- # Need to link against all dependency_libs?
- if test "$linkalldeplibs" = yes; then
- deplibs="$deplib $deplibs"
- else
- # Need to hardcode shared library paths
- # or/and link against static libraries
- newdependency_libs="$deplib $newdependency_libs"
- fi
- if test "X$duplicate_deps" = "Xyes" ; then
- case "$tmp_libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
- fi
- tmp_libs="$tmp_libs $deplib"
- done # for deplib
- continue
- fi # $linkmode = prog...
-
- if test "$linkmode,$pass" = "prog,link"; then
- if test -n "$library_names" &&
- { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
- # We need to hardcode the library path
- if test -n "$shlibpath_var"; then
- # Make sure the rpath contains only unique directories.
- case "$temp_rpath " in
- *" $dir "*) ;;
- *" $absdir "*) ;;
- *) temp_rpath="$temp_rpath $dir" ;;
- esac
- fi
-
- # Hardcode the library path.
- # Skip directories that are in the system default run-time
- # search path.
- case " $sys_lib_dlsearch_path " in
- *" $absdir "*) ;;
- *)
- case "$compile_rpath " in
- *" $absdir "*) ;;
- *) compile_rpath="$compile_rpath $absdir"
- esac
- ;;
- esac
- case " $sys_lib_dlsearch_path " in
- *" $libdir "*) ;;
- *)
- case "$finalize_rpath " in
- *" $libdir "*) ;;
- *) finalize_rpath="$finalize_rpath $libdir"
- esac
- ;;
- esac
- fi # $linkmode,$pass = prog,link...
-
- if test "$alldeplibs" = yes &&
- { test "$deplibs_check_method" = pass_all ||
- { test "$build_libtool_libs" = yes &&
- test -n "$library_names"; }; }; then
- # We only need to search for static libraries
- continue
- fi
- fi
-
- link_static=no # Whether the deplib will be linked statically
- if test -n "$library_names" &&
- { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
- if test "$installed" = no; then
- notinst_deplibs="$notinst_deplibs $lib"
- need_relink=yes
- fi
- # This is a shared library
-
- # Warn about portability, can't link against -module's on
- # some systems (darwin)
- if test "$shouldnotlink" = yes && test "$pass" = link ; then
- $echo
- if test "$linkmode" = prog; then
- $echo "*** Warning: Linking the executable $output against the loadable module"
- else
- $echo "*** Warning: Linking the shared library $output against the loadable module"
- fi
- $echo "*** $linklib is not portable!"
- fi
- if test "$linkmode" = lib &&
- test "$hardcode_into_libs" = yes; then
- # Hardcode the library path.
- # Skip directories that are in the system default run-time
- # search path.
- case " $sys_lib_dlsearch_path " in
- *" $absdir "*) ;;
- *)
- case "$compile_rpath " in
- *" $absdir "*) ;;
- *) compile_rpath="$compile_rpath $absdir"
- esac
- ;;
- esac
- case " $sys_lib_dlsearch_path " in
- *" $libdir "*) ;;
- *)
- case "$finalize_rpath " in
- *" $libdir "*) ;;
- *) finalize_rpath="$finalize_rpath $libdir"
- esac
- ;;
- esac
- fi
-
- if test -n "$old_archive_from_expsyms_cmds"; then
- # figure out the soname
- set dummy $library_names
- realname="$2"
- shift; shift
- libname=`eval \\$echo \"$libname_spec\"`
- # use dlname if we got it. it's perfectly good, no?
- if test -n "$dlname"; then
- soname="$dlname"
- elif test -n "$soname_spec"; then
- # bleh windows
- case $host in
- *cygwin* | mingw*)
- major=`expr $current - $age`
- versuffix="-$major"
- ;;
- esac
- eval soname=\"$soname_spec\"
- else
- soname="$realname"
- fi
-
- # Make a new name for the extract_expsyms_cmds to use
- soroot="$soname"
- soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
- newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
-
- # If the library has no export list, then create one now
- if test -f "$output_objdir/$soname-def"; then :
- else
- $show "extracting exported symbol list from \`$soname'"
- save_ifs="$IFS"; IFS='~'
- cmds=$extract_expsyms_cmds
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
- fi
-
- # Create $newlib
- if test -f "$output_objdir/$newlib"; then :; else
- $show "generating import library for \`$soname'"
- save_ifs="$IFS"; IFS='~'
- cmds=$old_archive_from_expsyms_cmds
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
- fi
- # make sure the library variables are pointing to the new library
- dir=$output_objdir
- linklib=$newlib
- fi # test -n "$old_archive_from_expsyms_cmds"
-
- if test "$linkmode" = prog || test "$mode" != relink; then
- add_shlibpath=
- add_dir=
- add=
- lib_linked=yes
- case $hardcode_action in
- immediate | unsupported)
- if test "$hardcode_direct" = no; then
- add="$dir/$linklib"
- case $host in
- *-*-sco3.2v5* ) add_dir="-L$dir" ;;
- *-*-darwin* )
- # if the lib is a module then we can not link against
- # it, someone is ignoring the new warnings I added
- if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then
- $echo "** Warning, lib $linklib is a module, not a shared library"
- if test -z "$old_library" ; then
- $echo
- $echo "** And there doesn't seem to be a static archive available"
- $echo "** The link will probably fail, sorry"
- else
- add="$dir/$old_library"
- fi
- fi
- esac
- elif test "$hardcode_minus_L" = no; then
- case $host in
- *-*-sunos*) add_shlibpath="$dir" ;;
- esac
- add_dir="-L$dir"
- add="-l$name"
- elif test "$hardcode_shlibpath_var" = no; then
- add_shlibpath="$dir"
- add="-l$name"
- else
- lib_linked=no
- fi
- ;;
- relink)
- if test "$hardcode_direct" = yes; then
- add="$dir/$linklib"
- elif test "$hardcode_minus_L" = yes; then
- add_dir="-L$dir"
- # Try looking first in the location we're being installed to.
- if test -n "$inst_prefix_dir"; then
- case "$libdir" in
- [\\/]*)
- add_dir="$add_dir -L$inst_prefix_dir$libdir"
- ;;
- esac
- fi
- add="-l$name"
- elif test "$hardcode_shlibpath_var" = yes; then
- add_shlibpath="$dir"
- add="-l$name"
- else
- lib_linked=no
- fi
- ;;
- *) lib_linked=no ;;
- esac
-
- if test "$lib_linked" != yes; then
- $echo "$modename: configuration error: unsupported hardcode properties"
- exit $EXIT_FAILURE
- fi
-
- if test -n "$add_shlibpath"; then
- case :$compile_shlibpath: in
- *":$add_shlibpath:"*) ;;
- *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
- esac
- fi
- if test "$linkmode" = prog; then
- test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
- test -n "$add" && compile_deplibs="$add $compile_deplibs"
- else
- test -n "$add_dir" && deplibs="$add_dir $deplibs"
- test -n "$add" && deplibs="$add $deplibs"
- if test "$hardcode_direct" != yes && \
- test "$hardcode_minus_L" != yes && \
- test "$hardcode_shlibpath_var" = yes; then
- case :$finalize_shlibpath: in
- *":$libdir:"*) ;;
- *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
- esac
- fi
- fi
- fi
-
- if test "$linkmode" = prog || test "$mode" = relink; then
- add_shlibpath=
- add_dir=
- add=
- # Finalize command for both is simple: just hardcode it.
- if test "$hardcode_direct" = yes; then
- add="$libdir/$linklib"
- elif test "$hardcode_minus_L" = yes; then
- add_dir="-L$libdir"
- add="-l$name"
- elif test "$hardcode_shlibpath_var" = yes; then
- case :$finalize_shlibpath: in
- *":$libdir:"*) ;;
- *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
- esac
- add="-l$name"
- elif test "$hardcode_automatic" = yes; then
- if test -n "$inst_prefix_dir" &&
- test -f "$inst_prefix_dir$libdir/$linklib" ; then
- add="$inst_prefix_dir$libdir/$linklib"
- else
- add="$libdir/$linklib"
- fi
- else
- # We cannot seem to hardcode it, guess we'll fake it.
- add_dir="-L$libdir"
- # Try looking first in the location we're being installed to.
- if test -n "$inst_prefix_dir"; then
- case "$libdir" in
- [\\/]*)
- add_dir="$add_dir -L$inst_prefix_dir$libdir"
- ;;
- esac
- fi
- add="-l$name"
- fi
-
- if test "$linkmode" = prog; then
- test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
- test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
- else
- test -n "$add_dir" && deplibs="$add_dir $deplibs"
- test -n "$add" && deplibs="$add $deplibs"
- fi
- fi
- elif test "$linkmode" = prog; then
- # Here we assume that one of hardcode_direct or hardcode_minus_L
- # is not unsupported. This is valid on all known static and
- # shared platforms.
- if test "$hardcode_direct" != unsupported; then
- test -n "$old_library" && linklib="$old_library"
- compile_deplibs="$dir/$linklib $compile_deplibs"
- finalize_deplibs="$dir/$linklib $finalize_deplibs"
- else
- compile_deplibs="-l$name -L$dir $compile_deplibs"
- finalize_deplibs="-l$name -L$dir $finalize_deplibs"
- fi
- elif test "$build_libtool_libs" = yes; then
- # Not a shared library
- if test "$deplibs_check_method" != pass_all; then
- # We're trying link a shared library against a static one
- # but the system doesn't support it.
-
- # Just print a warning and add the library to dependency_libs so
- # that the program can be linked against the static library.
- $echo
- $echo "*** Warning: This system can not link to static lib archive $lib."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which you do not appear to have."
- if test "$module" = yes; then
- $echo "*** But as you try to build a module library, libtool will still create "
- $echo "*** a static module, that should work as long as the dlopening application"
- $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
- if test -z "$global_symbol_pipe"; then
- $echo
- $echo "*** However, this would only work if libtool was able to extract symbol"
- $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
- $echo "*** not find such a program. So, this module is probably useless."
- $echo "*** \`nm' from GNU binutils and a full rebuild may help."
- fi
- if test "$build_old_libs" = no; then
- build_libtool_libs=module
- build_old_libs=yes
- else
- build_libtool_libs=no
- fi
- fi
- else
- convenience="$convenience $dir/$old_library"
- old_convenience="$old_convenience $dir/$old_library"
- deplibs="$dir/$old_library $deplibs"
- link_static=yes
- fi
- fi # link shared/static library?
-
- if test "$linkmode" = lib; then
- if test -n "$dependency_libs" &&
- { test "$hardcode_into_libs" != yes ||
- test "$build_old_libs" = yes ||
- test "$link_static" = yes; }; then
- # Extract -R from dependency_libs
- temp_deplibs=
- for libdir in $dependency_libs; do
- case $libdir in
- -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
- case " $xrpath " in
- *" $temp_xrpath "*) ;;
- *) xrpath="$xrpath $temp_xrpath";;
- esac;;
- *) temp_deplibs="$temp_deplibs $libdir";;
- esac
- done
- dependency_libs="$temp_deplibs"
- fi
-
- newlib_search_path="$newlib_search_path $absdir"
- # Link against this library
- test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
- # ... and its dependency_libs
- tmp_libs=
- for deplib in $dependency_libs; do
- newdependency_libs="$deplib $newdependency_libs"
- if test "X$duplicate_deps" = "Xyes" ; then
- case "$tmp_libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
- fi
- tmp_libs="$tmp_libs $deplib"
- done
-
- if test "$link_all_deplibs" != no; then
- # Add the search paths of all dependency libraries
- for deplib in $dependency_libs; do
- case $deplib in
- -L*) path="$deplib" ;;
- *.la)
- dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
- test "X$dir" = "X$deplib" && dir="."
- # We need an absolute path.
- case $dir in
- [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
- *)
- absdir=`cd "$dir" && pwd`
- if test -z "$absdir"; then
- $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
- absdir="$dir"
- fi
- ;;
- esac
- if grep "^installed=no" $deplib > /dev/null; then
- path="$absdir/$objdir"
- else
- eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
- if test -z "$libdir"; then
- $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
- exit $EXIT_FAILURE
- fi
- if test "$absdir" != "$libdir"; then
- $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
- fi
- path="$absdir"
- fi
- depdepl=
- case $host in
- *-*-darwin*)
- # we do not want to link against static libs,
- # but need to link against shared
- eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
- if test -n "$deplibrary_names" ; then
- for tmp in $deplibrary_names ; do
- depdepl=$tmp
- done
- if test -f "$path/$depdepl" ; then
- depdepl="$path/$depdepl"
- fi
- # do not add paths which are already there
- case " $newlib_search_path " in
- *" $path "*) ;;
- *) newlib_search_path="$newlib_search_path $path";;
- esac
- fi
- path=""
- ;;
- *)
- path="-L$path"
- ;;
- esac
- ;;
- -l*)
- case $host in
- *-*-darwin*)
- # Again, we only want to link against shared libraries
- eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
- for tmp in $newlib_search_path ; do
- if test -f "$tmp/lib$tmp_libs.dylib" ; then
- eval depdepl="$tmp/lib$tmp_libs.dylib"
- break
- fi
- done
- path=""
- ;;
- *) continue ;;
- esac
- ;;
- *) continue ;;
- esac
- case " $deplibs " in
- *" $depdepl "*) ;;
- *) deplibs="$depdepl $deplibs" ;;
- esac
- case " $deplibs " in
- *" $path "*) ;;
- *) deplibs="$deplibs $path" ;;
- esac
- done
- fi # link_all_deplibs != no
- fi # linkmode = lib
- done # for deplib in $libs
- dependency_libs="$newdependency_libs"
- if test "$pass" = dlpreopen; then
- # Link the dlpreopened libraries before other libraries
- for deplib in $save_deplibs; do
- deplibs="$deplib $deplibs"
- done
- fi
- if test "$pass" != dlopen; then
- if test "$pass" != conv; then
- # Make sure lib_search_path contains only unique directories.
- lib_search_path=
- for dir in $newlib_search_path; do
- case "$lib_search_path " in
- *" $dir "*) ;;
- *) lib_search_path="$lib_search_path $dir" ;;
- esac
- done
- newlib_search_path=
- fi
-
- if test "$linkmode,$pass" != "prog,link"; then
- vars="deplibs"
- else
- vars="compile_deplibs finalize_deplibs"
- fi
- for var in $vars dependency_libs; do
- # Add libraries to $var in reverse order
- eval tmp_libs=\"\$$var\"
- new_libs=
- for deplib in $tmp_libs; do
- # FIXME: Pedantically, this is the right thing to do, so
- # that some nasty dependency loop isn't accidentally
- # broken:
- #new_libs="$deplib $new_libs"
- # Pragmatically, this seems to cause very few problems in
- # practice:
- case $deplib in
- -L*) new_libs="$deplib $new_libs" ;;
- -R*) ;;
- *)
- # And here is the reason: when a library appears more
- # than once as an explicit dependence of a library, or
- # is implicitly linked in more than once by the
- # compiler, it is considered special, and multiple
- # occurrences thereof are not removed. Compare this
- # with having the same library being listed as a
- # dependency of multiple other libraries: in this case,
- # we know (pedantically, we assume) the library does not
- # need to be listed more than once, so we keep only the
- # last copy. This is not always right, but it is rare
- # enough that we require users that really mean to play
- # such unportable linking tricks to link the library
- # using -Wl,-lname, so that libtool does not consider it
- # for duplicate removal.
- case " $specialdeplibs " in
- *" $deplib "*) new_libs="$deplib $new_libs" ;;
- *)
- case " $new_libs " in
- *" $deplib "*) ;;
- *) new_libs="$deplib $new_libs" ;;
- esac
- ;;
- esac
- ;;
- esac
- done
- tmp_libs=
- for deplib in $new_libs; do
- case $deplib in
- -L*)
- case " $tmp_libs " in
- *" $deplib "*) ;;
- *) tmp_libs="$tmp_libs $deplib" ;;
- esac
- ;;
- *) tmp_libs="$tmp_libs $deplib" ;;
- esac
- done
- eval $var=\"$tmp_libs\"
- done # for var
- fi
- # Last step: remove runtime libs from dependency_libs
- # (they stay in deplibs)
- tmp_libs=
- for i in $dependency_libs ; do
- case " $predeps $postdeps $compiler_lib_search_path " in
- *" $i "*)
- i=""
- ;;
- esac
- if test -n "$i" ; then
- tmp_libs="$tmp_libs $i"
- fi
- done
- dependency_libs=$tmp_libs
- done # for pass
- if test "$linkmode" = prog; then
- dlfiles="$newdlfiles"
- dlprefiles="$newdlprefiles"
- fi
-
- case $linkmode in
- oldlib)
- if test -n "$deplibs"; then
- $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
- fi
-
- if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
- $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
- fi
-
- if test -n "$rpath"; then
- $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
- fi
-
- if test -n "$xrpath"; then
- $echo "$modename: warning: \`-R' is ignored for archives" 1>&2
- fi
-
- if test -n "$vinfo"; then
- $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
- fi
-
- if test -n "$release"; then
- $echo "$modename: warning: \`-release' is ignored for archives" 1>&2
- fi
-
- if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
- $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
- fi
-
- # Now set the variables for building old libraries.
- build_libtool_libs=no
- oldlibs="$output"
- objs="$objs$old_deplibs"
- ;;
-
- lib)
- # Make sure we only generate libraries of the form `libNAME.la'.
- case $outputname in
- lib*)
- name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
- eval shared_ext=\"$shrext_cmds\"
- eval libname=\"$libname_spec\"
- ;;
- *)
- if test "$module" = no; then
- $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
- if test "$need_lib_prefix" != no; then
- # Add the "lib" prefix for modules if required
- name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
- eval shared_ext=\"$shrext_cmds\"
- eval libname=\"$libname_spec\"
- else
- libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
- fi
- ;;
- esac
-
- if test -n "$objs"; then
- if test "$deplibs_check_method" != pass_all; then
- $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
- exit $EXIT_FAILURE
- else
- $echo
- $echo "*** Warning: Linking the shared library $output against the non-libtool"
- $echo "*** objects $objs is not portable!"
- libobjs="$libobjs $objs"
- fi
- fi
-
- if test "$dlself" != no; then
- $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
- fi
-
- set dummy $rpath
- if test "$#" -gt 2; then
- $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
- fi
- install_libdir="$2"
-
- oldlibs=
- if test -z "$rpath"; then
- if test "$build_libtool_libs" = yes; then
- # Building a libtool convenience library.
- # Some compilers have problems with a `.al' extension so
- # convenience libraries should have the same extension an
- # archive normally would.
- oldlibs="$output_objdir/$libname.$libext $oldlibs"
- build_libtool_libs=convenience
- build_old_libs=yes
- fi
-
- if test -n "$vinfo"; then
- $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
- fi
-
- if test -n "$release"; then
- $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
- fi
- else
-
- # Parse the version information argument.
- save_ifs="$IFS"; IFS=':'
- set dummy $vinfo 0 0 0
- IFS="$save_ifs"
-
- if test -n "$8"; then
- $echo "$modename: too many parameters to \`-version-info'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # convert absolute version numbers to libtool ages
- # this retains compatibility with .la files and attempts
- # to make the code below a bit more comprehensible
-
- case $vinfo_number in
- yes)
- number_major="$2"
- number_minor="$3"
- number_revision="$4"
- #
- # There are really only two kinds -- those that
- # use the current revision as the major version
- # and those that subtract age and use age as
- # a minor version. But, then there is irix
- # which has an extra 1 added just for fun
- #
- case $version_type in
- darwin|linux|osf|windows)
- current=`expr $number_major + $number_minor`
- age="$number_minor"
- revision="$number_revision"
- ;;
- freebsd-aout|freebsd-elf|sunos)
- current="$number_major"
- revision="$number_minor"
- age="0"
- ;;
- irix|nonstopux)
- current=`expr $number_major + $number_minor - 1`
- age="$number_minor"
- revision="$number_minor"
- ;;
- *)
- $echo "$modename: unknown library version type \`$version_type'" 1>&2
- $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- ;;
- no)
- current="$2"
- revision="$3"
- age="$4"
- ;;
- esac
-
- # Check that each of the things are valid numbers.
- case $current in
- 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
- *)
- $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
- $echo "$modename: \`$vinfo' is not valid version information" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- case $revision in
- 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
- *)
- $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
- $echo "$modename: \`$vinfo' is not valid version information" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- case $age in
- 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
- *)
- $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
- $echo "$modename: \`$vinfo' is not valid version information" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- if test "$age" -gt "$current"; then
- $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
- $echo "$modename: \`$vinfo' is not valid version information" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Calculate the version variables.
- major=
- versuffix=
- verstring=
- case $version_type in
- none) ;;
-
- darwin)
- # Like Linux, but with the current version available in
- # verstring for coding it into the library header
- major=.`expr $current - $age`
- versuffix="$major.$age.$revision"
- # Darwin ld doesn't like 0 for these options...
- minor_current=`expr $current + 1`
- verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
- ;;
-
- freebsd-aout)
- major=".$current"
- versuffix=".$current.$revision";
- ;;
-
- freebsd-elf)
- major=".$current"
- versuffix=".$current";
- ;;
-
- irix | nonstopux)
- major=`expr $current - $age + 1`
-
- case $version_type in
- nonstopux) verstring_prefix=nonstopux ;;
- *) verstring_prefix=sgi ;;
- esac
- verstring="$verstring_prefix$major.$revision"
-
- # Add in all the interfaces that we are compatible with.
- loop=$revision
- while test "$loop" -ne 0; do
- iface=`expr $revision - $loop`
- loop=`expr $loop - 1`
- verstring="$verstring_prefix$major.$iface:$verstring"
- done
-
- # Before this point, $major must not contain `.'.
- major=.$major
- versuffix="$major.$revision"
- ;;
-
- linux)
- major=.`expr $current - $age`
- versuffix="$major.$age.$revision"
- ;;
-
- osf)
- major=.`expr $current - $age`
- versuffix=".$current.$age.$revision"
- verstring="$current.$age.$revision"
-
- # Add in all the interfaces that we are compatible with.
- loop=$age
- while test "$loop" -ne 0; do
- iface=`expr $current - $loop`
- loop=`expr $loop - 1`
- verstring="$verstring:${iface}.0"
- done
-
- # Make executables depend on our current version.
- verstring="$verstring:${current}.0"
- ;;
-
- sunos)
- major=".$current"
- versuffix=".$current.$revision"
- ;;
-
- windows)
- # Use '-' rather than '.', since we only want one
- # extension on DOS 8.3 filesystems.
- major=`expr $current - $age`
- versuffix="-$major"
- ;;
-
- *)
- $echo "$modename: unknown library version type \`$version_type'" 1>&2
- $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- # Clear the version info if we defaulted, and they specified a release.
- if test -z "$vinfo" && test -n "$release"; then
- major=
- case $version_type in
- darwin)
- # we can't check for "0.0" in archive_cmds due to quoting
- # problems, so we reset it completely
- verstring=
- ;;
- *)
- verstring="0.0"
- ;;
- esac
- if test "$need_version" = no; then
- versuffix=
- else
- versuffix=".0.0"
- fi
- fi
-
- # Remove version info from name if versioning should be avoided
- if test "$avoid_version" = yes && test "$need_version" = no; then
- major=
- versuffix=
- verstring=""
- fi
-
- # Check to see if the archive will have undefined symbols.
- if test "$allow_undefined" = yes; then
- if test "$allow_undefined_flag" = unsupported; then
- $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
- build_libtool_libs=no
- build_old_libs=yes
- fi
- else
- # Don't allow undefined symbols.
- allow_undefined_flag="$no_undefined_flag"
- fi
- fi
-
- if test "$mode" != relink; then
- # Remove our outputs, but don't remove object files since they
- # may have been created when compiling PIC objects.
- removelist=
- tempremovelist=`$echo "$output_objdir/*"`
- for p in $tempremovelist; do
- case $p in
- *.$objext)
- ;;
- $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
- if test "X$precious_files_regex" != "X"; then
- if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
- then
- continue
- fi
- fi
- removelist="$removelist $p"
- ;;
- *) ;;
- esac
- done
- if test -n "$removelist"; then
- $show "${rm}r $removelist"
- $run ${rm}r $removelist
- fi
- fi
-
- # Now set the variables for building old libraries.
- if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
- oldlibs="$oldlibs $output_objdir/$libname.$libext"
-
- # Transform .lo files to .o files.
- oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
- fi
-
- # Eliminate all temporary directories.
- for path in $notinst_path; do
- lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'`
- deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'`
- dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'`
- done
-
- if test -n "$xrpath"; then
- # If the user specified any rpath flags, then add them.
- temp_xrpath=
- for libdir in $xrpath; do
- temp_xrpath="$temp_xrpath -R$libdir"
- case "$finalize_rpath " in
- *" $libdir "*) ;;
- *) finalize_rpath="$finalize_rpath $libdir" ;;
- esac
- done
- if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
- dependency_libs="$temp_xrpath $dependency_libs"
- fi
- fi
-
- # Make sure dlfiles contains only unique files that won't be dlpreopened
- old_dlfiles="$dlfiles"
- dlfiles=
- for lib in $old_dlfiles; do
- case " $dlprefiles $dlfiles " in
- *" $lib "*) ;;
- *) dlfiles="$dlfiles $lib" ;;
- esac
- done
-
- # Make sure dlprefiles contains only unique files
- old_dlprefiles="$dlprefiles"
- dlprefiles=
- for lib in $old_dlprefiles; do
- case "$dlprefiles " in
- *" $lib "*) ;;
- *) dlprefiles="$dlprefiles $lib" ;;
- esac
- done
-
- if test "$build_libtool_libs" = yes; then
- if test -n "$rpath"; then
- case $host in
- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
- # these systems don't actually have a c library (as such)!
- ;;
- *-*-rhapsody* | *-*-darwin1.[012])
- # Rhapsody C library is in the System framework
- deplibs="$deplibs -framework System"
- ;;
- *-*-netbsd*)
- # Don't link with libc until the a.out ld.so is fixed.
- ;;
- *-*-openbsd* | *-*-freebsd*)
- # Do not include libc due to us having libc/libc_r.
- test "X$arg" = "X-lc" && continue
- ;;
- *)
- # Add libc to deplibs on all other systems if necessary.
- if test "$build_libtool_need_lc" = "yes"; then
- deplibs="$deplibs -lc"
- fi
- ;;
- esac
- fi
-
- # Transform deplibs into only deplibs that can be linked in shared.
- name_save=$name
- libname_save=$libname
- release_save=$release
- versuffix_save=$versuffix
- major_save=$major
- # I'm not sure if I'm treating the release correctly. I think
- # release should show up in the -l (ie -lgmp5) so we don't want to
- # add it in twice. Is that correct?
- release=""
- versuffix=""
- major=""
- newdeplibs=
- droppeddeps=no
- case $deplibs_check_method in
- pass_all)
- # Don't check for shared/static. Everything works.
- # This might be a little naive. We might want to check
- # whether the library exists or not. But this is on
- # osf3 & osf4 and I'm not really sure... Just
- # implementing what was already the behavior.
- newdeplibs=$deplibs
- ;;
- test_compile)
- # This code stresses the "libraries are programs" paradigm to its
- # limits. Maybe even breaks it. We compile a program, linking it
- # against the deplibs as a proxy for the library. Then we can check
- # whether they linked in statically or dynamically with ldd.
- $rm conftest.c
- cat > conftest.c <<EOF
- int main() { return 0; }
-EOF
- $rm conftest
- $LTCC -o conftest conftest.c $deplibs
- if test "$?" -eq 0 ; then
- ldd_output=`ldd conftest`
- for i in $deplibs; do
- name="`expr $i : '-l\(.*\)'`"
- # If $name is empty we are operating on a -L argument.
- if test "$name" != "" && test "$name" -ne "0"; then
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- case " $predeps $postdeps " in
- *" $i "*)
- newdeplibs="$newdeplibs $i"
- i=""
- ;;
- esac
- fi
- if test -n "$i" ; then
- libname=`eval \\$echo \"$libname_spec\"`
- deplib_matches=`eval \\$echo \"$library_names_spec\"`
- set dummy $deplib_matches
- deplib_match=$2
- if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
- newdeplibs="$newdeplibs $i"
- else
- droppeddeps=yes
- $echo
- $echo "*** Warning: dynamic linker does not accept needed library $i."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which I believe you do not have"
- $echo "*** because a test_compile did reveal that the linker did not use it for"
- $echo "*** its dynamic dependency list that programs get resolved with at runtime."
- fi
- fi
- else
- newdeplibs="$newdeplibs $i"
- fi
- done
- else
- # Error occurred in the first compile. Let's try to salvage
- # the situation: Compile a separate program for each library.
- for i in $deplibs; do
- name="`expr $i : '-l\(.*\)'`"
- # If $name is empty we are operating on a -L argument.
- if test "$name" != "" && test "$name" != "0"; then
- $rm conftest
- $LTCC -o conftest conftest.c $i
- # Did it work?
- if test "$?" -eq 0 ; then
- ldd_output=`ldd conftest`
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- case " $predeps $postdeps " in
- *" $i "*)
- newdeplibs="$newdeplibs $i"
- i=""
- ;;
- esac
- fi
- if test -n "$i" ; then
- libname=`eval \\$echo \"$libname_spec\"`
- deplib_matches=`eval \\$echo \"$library_names_spec\"`
- set dummy $deplib_matches
- deplib_match=$2
- if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
- newdeplibs="$newdeplibs $i"
- else
- droppeddeps=yes
- $echo
- $echo "*** Warning: dynamic linker does not accept needed library $i."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which you do not appear to have"
- $echo "*** because a test_compile did reveal that the linker did not use this one"
- $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
- fi
- fi
- else
- droppeddeps=yes
- $echo
- $echo "*** Warning! Library $i is needed by this library but I was not able to"
- $echo "*** make it link in! You will probably need to install it or some"
- $echo "*** library that it depends on before this library will be fully"
- $echo "*** functional. Installing it before continuing would be even better."
- fi
- else
- newdeplibs="$newdeplibs $i"
- fi
- done
- fi
- ;;
- file_magic*)
- set dummy $deplibs_check_method
- file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
- for a_deplib in $deplibs; do
- name="`expr $a_deplib : '-l\(.*\)'`"
- # If $name is empty we are operating on a -L argument.
- if test "$name" != "" && test "$name" != "0"; then
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- case " $predeps $postdeps " in
- *" $a_deplib "*)
- newdeplibs="$newdeplibs $a_deplib"
- a_deplib=""
- ;;
- esac
- fi
- if test -n "$a_deplib" ; then
- libname=`eval \\$echo \"$libname_spec\"`
- for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
- potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
- for potent_lib in $potential_libs; do
- # Follow soft links.
- if ls -lLd "$potent_lib" 2>/dev/null \
- | grep " -> " >/dev/null; then
- continue
- fi
- # The statement above tries to avoid entering an
- # endless loop below, in case of cyclic links.
- # We might still enter an endless loop, since a link
- # loop can be closed while we follow links,
- # but so what?
- potlib="$potent_lib"
- while test -h "$potlib" 2>/dev/null; do
- potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
- case $potliblink in
- [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
- *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
- esac
- done
- if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
- | ${SED} 10q \
- | $EGREP "$file_magic_regex" > /dev/null; then
- newdeplibs="$newdeplibs $a_deplib"
- a_deplib=""
- break 2
- fi
- done
- done
- fi
- if test -n "$a_deplib" ; then
- droppeddeps=yes
- $echo
- $echo "*** Warning: linker path does not have real file for library $a_deplib."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which you do not appear to have"
- $echo "*** because I did check the linker path looking for a file starting"
- if test -z "$potlib" ; then
- $echo "*** with $libname but no candidates were found. (...for file magic test)"
- else
- $echo "*** with $libname and none of the candidates passed a file format test"
- $echo "*** using a file magic. Last file checked: $potlib"
- fi
- fi
- else
- # Add a -L argument.
- newdeplibs="$newdeplibs $a_deplib"
- fi
- done # Gone through all deplibs.
- ;;
- match_pattern*)
- set dummy $deplibs_check_method
- match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
- for a_deplib in $deplibs; do
- name="`expr $a_deplib : '-l\(.*\)'`"
- # If $name is empty we are operating on a -L argument.
- if test -n "$name" && test "$name" != "0"; then
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- case " $predeps $postdeps " in
- *" $a_deplib "*)
- newdeplibs="$newdeplibs $a_deplib"
- a_deplib=""
- ;;
- esac
- fi
- if test -n "$a_deplib" ; then
- libname=`eval \\$echo \"$libname_spec\"`
- for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
- potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
- for potent_lib in $potential_libs; do
- potlib="$potent_lib" # see symlink-check above in file_magic test
- if eval $echo \"$potent_lib\" 2>/dev/null \
- | ${SED} 10q \
- | $EGREP "$match_pattern_regex" > /dev/null; then
- newdeplibs="$newdeplibs $a_deplib"
- a_deplib=""
- break 2
- fi
- done
- done
- fi
- if test -n "$a_deplib" ; then
- droppeddeps=yes
- $echo
- $echo "*** Warning: linker path does not have real file for library $a_deplib."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which you do not appear to have"
- $echo "*** because I did check the linker path looking for a file starting"
- if test -z "$potlib" ; then
- $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
- else
- $echo "*** with $libname and none of the candidates passed a file format test"
- $echo "*** using a regex pattern. Last file checked: $potlib"
- fi
- fi
- else
- # Add a -L argument.
- newdeplibs="$newdeplibs $a_deplib"
- fi
- done # Gone through all deplibs.
- ;;
- none | unknown | *)
- newdeplibs=""
- tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
- -e 's/ -[LR][^ ]*//g'`
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- for i in $predeps $postdeps ; do
- # can't use Xsed below, because $i might contain '/'
- tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
- done
- fi
- if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \
- | grep . >/dev/null; then
- $echo
- if test "X$deplibs_check_method" = "Xnone"; then
- $echo "*** Warning: inter-library dependencies are not supported in this platform."
- else
- $echo "*** Warning: inter-library dependencies are not known to be supported."
- fi
- $echo "*** All declared inter-library dependencies are being dropped."
- droppeddeps=yes
- fi
- ;;
- esac
- versuffix=$versuffix_save
- major=$major_save
- release=$release_save
- libname=$libname_save
- name=$name_save
-
- case $host in
- *-*-rhapsody* | *-*-darwin1.[012])
- # On Rhapsody replace the C library is the System framework
- newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
- ;;
- esac
-
- if test "$droppeddeps" = yes; then
- if test "$module" = yes; then
- $echo
- $echo "*** Warning: libtool could not satisfy all declared inter-library"
- $echo "*** dependencies of module $libname. Therefore, libtool will create"
- $echo "*** a static module, that should work as long as the dlopening"
- $echo "*** application is linked with the -dlopen flag."
- if test -z "$global_symbol_pipe"; then
- $echo
- $echo "*** However, this would only work if libtool was able to extract symbol"
- $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
- $echo "*** not find such a program. So, this module is probably useless."
- $echo "*** \`nm' from GNU binutils and a full rebuild may help."
- fi
- if test "$build_old_libs" = no; then
- oldlibs="$output_objdir/$libname.$libext"
- build_libtool_libs=module
- build_old_libs=yes
- else
- build_libtool_libs=no
- fi
- else
- $echo "*** The inter-library dependencies that have been dropped here will be"
- $echo "*** automatically added whenever a program is linked with this library"
- $echo "*** or is declared to -dlopen it."
-
- if test "$allow_undefined" = no; then
- $echo
- $echo "*** Since this library must not contain undefined symbols,"
- $echo "*** because either the platform does not support them or"
- $echo "*** it was explicitly requested with -no-undefined,"
- $echo "*** libtool will only create a static version of it."
- if test "$build_old_libs" = no; then
- oldlibs="$output_objdir/$libname.$libext"
- build_libtool_libs=module
- build_old_libs=yes
- else
- build_libtool_libs=no
- fi
- fi
- fi
- fi
- # Done checking deplibs!
- deplibs=$newdeplibs
- fi
-
- # All the library-specific variables (install_libdir is set above).
- library_names=
- old_library=
- dlname=
-
- # Test again, we may have decided not to build it any more
- if test "$build_libtool_libs" = yes; then
- if test "$hardcode_into_libs" = yes; then
- # Hardcode the library paths
- hardcode_libdirs=
- dep_rpath=
- rpath="$finalize_rpath"
- test "$mode" != relink && rpath="$compile_rpath$rpath"
- for libdir in $rpath; do
- if test -n "$hardcode_libdir_flag_spec"; then
- if test -n "$hardcode_libdir_separator"; then
- if test -z "$hardcode_libdirs"; then
- hardcode_libdirs="$libdir"
- else
- # Just accumulate the unique libdirs.
- case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
- *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
- ;;
- *)
- hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
- ;;
- esac
- fi
- else
- eval flag=\"$hardcode_libdir_flag_spec\"
- dep_rpath="$dep_rpath $flag"
- fi
- elif test -n "$runpath_var"; then
- case "$perm_rpath " in
- *" $libdir "*) ;;
- *) perm_rpath="$perm_rpath $libdir" ;;
- esac
- fi
- done
- # Substitute the hardcoded libdirs into the rpath.
- if test -n "$hardcode_libdir_separator" &&
- test -n "$hardcode_libdirs"; then
- libdir="$hardcode_libdirs"
- if test -n "$hardcode_libdir_flag_spec_ld"; then
- eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
- else
- eval dep_rpath=\"$hardcode_libdir_flag_spec\"
- fi
- fi
- if test -n "$runpath_var" && test -n "$perm_rpath"; then
- # We should set the runpath_var.
- rpath=
- for dir in $perm_rpath; do
- rpath="$rpath$dir:"
- done
- eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
- fi
- test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
- fi
-
- shlibpath="$finalize_shlibpath"
- test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
- if test -n "$shlibpath"; then
- eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
- fi
-
- # Get the real and link names of the library.
- eval shared_ext=\"$shrext_cmds\"
- eval library_names=\"$library_names_spec\"
- set dummy $library_names
- realname="$2"
- shift; shift
-
- if test -n "$soname_spec"; then
- eval soname=\"$soname_spec\"
- else
- soname="$realname"
- fi
- if test -z "$dlname"; then
- dlname=$soname
- fi
-
- lib="$output_objdir/$realname"
- for link
- do
- linknames="$linknames $link"
- done
-
- # Use standard objects if they are pic
- test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
-
- # Prepare the list of exported symbols
- if test -z "$export_symbols"; then
- if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
- $show "generating symbol list for \`$libname.la'"
- export_symbols="$output_objdir/$libname.exp"
- $run $rm $export_symbols
- cmds=$export_symbols_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- if len=`expr "X$cmd" : ".*"` &&
- test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
- $show "$cmd"
- $run eval "$cmd" || exit $?
- skipped_export=false
- else
- # The command line is too long to execute in one step.
- $show "using reloadable object file for export list..."
- skipped_export=:
- fi
- done
- IFS="$save_ifs"
- if test -n "$export_symbols_regex"; then
- $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
- $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
- $show "$mv \"${export_symbols}T\" \"$export_symbols\""
- $run eval '$mv "${export_symbols}T" "$export_symbols"'
- fi
- fi
- fi
-
- if test -n "$export_symbols" && test -n "$include_expsyms"; then
- $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
- fi
-
- tmp_deplibs=
- for test_deplib in $deplibs; do
- case " $convenience " in
- *" $test_deplib "*) ;;
- *)
- tmp_deplibs="$tmp_deplibs $test_deplib"
- ;;
- esac
- done
- deplibs="$tmp_deplibs"
-
- if test -n "$convenience"; then
- if test -n "$whole_archive_flag_spec"; then
- save_libobjs=$libobjs
- eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
- else
- gentop="$output_objdir/${outputname}x"
- $show "${rm}r $gentop"
- $run ${rm}r "$gentop"
- $show "$mkdir $gentop"
- $run $mkdir "$gentop"
- status=$?
- if test "$status" -ne 0 && test ! -d "$gentop"; then
- exit $status
- fi
- generated="$generated $gentop"
-
- for xlib in $convenience; do
- # Extract the objects.
- case $xlib in
- [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
- *) xabs=`pwd`"/$xlib" ;;
- esac
- xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
- xdir="$gentop/$xlib"
-
- $show "${rm}r $xdir"
- $run ${rm}r "$xdir"
- $show "$mkdir $xdir"
- $run $mkdir "$xdir"
- status=$?
- if test "$status" -ne 0 && test ! -d "$xdir"; then
- exit $status
- fi
- # We will extract separately just the conflicting names and we will no
- # longer touch any unique names. It is faster to leave these extract
- # automatically by $AR in one run.
- $show "(cd $xdir && $AR x $xabs)"
- $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
- if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
- :
- else
- $echo "$modename: warning: object name conflicts; renaming object files" 1>&2
- $echo "$modename: warning: to ensure that they will not overwrite" 1>&2
- $AR t "$xabs" | sort | uniq -cd | while read -r count name
- do
- i=1
- while test "$i" -le "$count"
- do
- # Put our $i before any first dot (extension)
- # Never overwrite any file
- name_to="$name"
- while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
- do
- name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
- done
- $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
- $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
- i=`expr $i + 1`
- done
- done
- fi
-
- libobjs="$libobjs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
- done
- fi
- fi
-
- if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
- eval flag=\"$thread_safe_flag_spec\"
- linker_flags="$linker_flags $flag"
- fi
-
- # Make a backup of the uninstalled library when relinking
- if test "$mode" = relink; then
- $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
- fi
-
- # Do each of the archive commands.
- if test "$module" = yes && test -n "$module_cmds" ; then
- if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
- eval test_cmds=\"$module_expsym_cmds\"
- cmds=$module_expsym_cmds
- else
- eval test_cmds=\"$module_cmds\"
- cmds=$module_cmds
- fi
- else
- if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
- eval test_cmds=\"$archive_expsym_cmds\"
- cmds=$archive_expsym_cmds
- else
- eval test_cmds=\"$archive_cmds\"
- cmds=$archive_cmds
- fi
- fi
-
- if test "X$skipped_export" != "X:" && len=`expr "X$test_cmds" : ".*"` &&
- test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
- :
- else
- # The command line is too long to link in one step, link piecewise.
- $echo "creating reloadable object files..."
-
- # Save the value of $output and $libobjs because we want to
- # use them later. If we have whole_archive_flag_spec, we
- # want to use save_libobjs as it was before
- # whole_archive_flag_spec was expanded, because we can't
- # assume the linker understands whole_archive_flag_spec.
- # This may have to be revisited, in case too many
- # convenience libraries get linked in and end up exceeding
- # the spec.
- if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
- save_libobjs=$libobjs
- fi
- save_output=$output
-
- # Clear the reloadable object creation command queue and
- # initialize k to one.
- test_cmds=
- concat_cmds=
- objlist=
- delfiles=
- last_robj=
- k=1
- output=$output_objdir/$save_output-${k}.$objext
- # Loop over the list of objects to be linked.
- for obj in $save_libobjs
- do
- eval test_cmds=\"$reload_cmds $objlist $last_robj\"
- if test "X$objlist" = X ||
- { len=`expr "X$test_cmds" : ".*"` &&
- test "$len" -le "$max_cmd_len"; }; then
- objlist="$objlist $obj"
- else
- # The command $test_cmds is almost too long, add a
- # command to the queue.
- if test "$k" -eq 1 ; then
- # The first file doesn't have a previous command to add.
- eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
- else
- # All subsequent reloadable object files will link in
- # the last one created.
- eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
- fi
- last_robj=$output_objdir/$save_output-${k}.$objext
- k=`expr $k + 1`
- output=$output_objdir/$save_output-${k}.$objext
- objlist=$obj
- len=1
- fi
- done
- # Handle the remaining objects by creating one last
- # reloadable object file. All subsequent reloadable object
- # files will link in the last one created.
- test -z "$concat_cmds" || concat_cmds=$concat_cmds~
- eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
-
- if ${skipped_export-false}; then
- $show "generating symbol list for \`$libname.la'"
- export_symbols="$output_objdir/$libname.exp"
- $run $rm $export_symbols
- libobjs=$output
- # Append the command to create the export file.
- eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
- fi
-
- # Set up a command to remove the reloadale object files
- # after they are used.
- i=0
- while test "$i" -lt "$k"
- do
- i=`expr $i + 1`
- delfiles="$delfiles $output_objdir/$save_output-${i}.$objext"
- done
-
- $echo "creating a temporary reloadable object file: $output"
-
- # Loop through the commands generated above and execute them.
- save_ifs="$IFS"; IFS='~'
- for cmd in $concat_cmds; do
- IFS="$save_ifs"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
-
- libobjs=$output
- # Restore the value of output.
- output=$save_output
-
- if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
- eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
- fi
- # Expand the library linking commands again to reset the
- # value of $libobjs for piecewise linking.
-
- # Do each of the archive commands.
- if test "$module" = yes && test -n "$module_cmds" ; then
- if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
- cmds=$module_expsym_cmds
- else
- cmds=$module_cmds
- fi
- else
- if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
- cmds=$archive_expsym_cmds
- else
- cmds=$archive_cmds
- fi
- fi
-
- # Append the command to remove the reloadable object files
- # to the just-reset $cmds.
- eval cmds=\"\$cmds~\$rm $delfiles\"
- fi
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
-
- # Restore the uninstalled library and exit
- if test "$mode" = relink; then
- $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
- exit $EXIT_SUCCESS
- fi
-
- # Create links to the real library.
- for linkname in $linknames; do
- if test "$realname" != "$linkname"; then
- $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
- $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
- fi
- done
-
- # If -module or -export-dynamic was specified, set the dlname.
- if test "$module" = yes || test "$export_dynamic" = yes; then
- # On all known operating systems, these are identical.
- dlname="$soname"
- fi
- fi
- ;;
-
- obj)
- if test -n "$deplibs"; then
- $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
- fi
-
- if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
- $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
- fi
-
- if test -n "$rpath"; then
- $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
- fi
-
- if test -n "$xrpath"; then
- $echo "$modename: warning: \`-R' is ignored for objects" 1>&2
- fi
-
- if test -n "$vinfo"; then
- $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
- fi
-
- if test -n "$release"; then
- $echo "$modename: warning: \`-release' is ignored for objects" 1>&2
- fi
-
- case $output in
- *.lo)
- if test -n "$objs$old_deplibs"; then
- $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
- exit $EXIT_FAILURE
- fi
- libobj="$output"
- obj=`$echo "X$output" | $Xsed -e "$lo2o"`
- ;;
- *)
- libobj=
- obj="$output"
- ;;
- esac
-
- # Delete the old objects.
- $run $rm $obj $libobj
-
- # Objects from convenience libraries. This assumes
- # single-version convenience libraries. Whenever we create
- # different ones for PIC/non-PIC, this we'll have to duplicate
- # the extraction.
- reload_conv_objs=
- gentop=
- # reload_cmds runs $LD directly, so let us get rid of
- # -Wl from whole_archive_flag_spec
- wl=
-
- if test -n "$convenience"; then
- if test -n "$whole_archive_flag_spec"; then
- eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
- else
- gentop="$output_objdir/${obj}x"
- $show "${rm}r $gentop"
- $run ${rm}r "$gentop"
- $show "$mkdir $gentop"
- $run $mkdir "$gentop"
- status=$?
- if test "$status" -ne 0 && test ! -d "$gentop"; then
- exit $status
- fi
- generated="$generated $gentop"
-
- for xlib in $convenience; do
- # Extract the objects.
- case $xlib in
- [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
- *) xabs=`pwd`"/$xlib" ;;
- esac
- xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
- xdir="$gentop/$xlib"
-
- $show "${rm}r $xdir"
- $run ${rm}r "$xdir"
- $show "$mkdir $xdir"
- $run $mkdir "$xdir"
- status=$?
- if test "$status" -ne 0 && test ! -d "$xdir"; then
- exit $status
- fi
- # We will extract separately just the conflicting names and we will no
- # longer touch any unique names. It is faster to leave these extract
- # automatically by $AR in one run.
- $show "(cd $xdir && $AR x $xabs)"
- $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
- if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
- :
- else
- $echo "$modename: warning: object name conflicts; renaming object files" 1>&2
- $echo "$modename: warning: to ensure that they will not overwrite" 1>&2
- $AR t "$xabs" | sort | uniq -cd | while read -r count name
- do
- i=1
- while test "$i" -le "$count"
- do
- # Put our $i before any first dot (extension)
- # Never overwrite any file
- name_to="$name"
- while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
- do
- name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
- done
- $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
- $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
- i=`expr $i + 1`
- done
- done
- fi
-
- reload_conv_objs="$reload_objs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
- done
- fi
- fi
-
- # Create the old-style object.
- reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
-
- output="$obj"
- cmds=$reload_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
-
- # Exit if we aren't doing a library object file.
- if test -z "$libobj"; then
- if test -n "$gentop"; then
- $show "${rm}r $gentop"
- $run ${rm}r $gentop
- fi
-
- exit $EXIT_SUCCESS
- fi
-
- if test "$build_libtool_libs" != yes; then
- if test -n "$gentop"; then
- $show "${rm}r $gentop"
- $run ${rm}r $gentop
- fi
-
- # Create an invalid libtool object if no PIC, so that we don't
- # accidentally link it into a program.
- # $show "echo timestamp > $libobj"
- # $run eval "echo timestamp > $libobj" || exit $?
- exit $EXIT_SUCCESS
- fi
-
- if test -n "$pic_flag" || test "$pic_mode" != default; then
- # Only do commands if we really have different PIC objects.
- reload_objs="$libobjs $reload_conv_objs"
- output="$libobj"
- cmds=$reload_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
- fi
-
- if test -n "$gentop"; then
- $show "${rm}r $gentop"
- $run ${rm}r $gentop
- fi
-
- exit $EXIT_SUCCESS
- ;;
-
- prog)
- case $host in
- *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
- esac
- if test -n "$vinfo"; then
- $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
- fi
-
- if test -n "$release"; then
- $echo "$modename: warning: \`-release' is ignored for programs" 1>&2
- fi
-
- if test "$preload" = yes; then
- if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
- test "$dlopen_self_static" = unknown; then
- $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
- fi
- fi
-
- case $host in
- *-*-rhapsody* | *-*-darwin1.[012])
- # On Rhapsody replace the C library is the System framework
- compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
- finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
- ;;
- esac
-
- case $host in
- *darwin*)
- # Don't allow lazy linking, it breaks C++ global constructors
- if test "$tagname" = CXX ; then
- compile_command="$compile_command ${wl}-bind_at_load"
- finalize_command="$finalize_command ${wl}-bind_at_load"
- fi
- ;;
- esac
-
- compile_command="$compile_command $compile_deplibs"
- finalize_command="$finalize_command $finalize_deplibs"
-
- if test -n "$rpath$xrpath"; then
- # If the user specified any rpath flags, then add them.
- for libdir in $rpath $xrpath; do
- # This is the magic to use -rpath.
- case "$finalize_rpath " in
- *" $libdir "*) ;;
- *) finalize_rpath="$finalize_rpath $libdir" ;;
- esac
- done
- fi
-
- # Now hardcode the library paths
- rpath=
- hardcode_libdirs=
- for libdir in $compile_rpath $finalize_rpath; do
- if test -n "$hardcode_libdir_flag_spec"; then
- if test -n "$hardcode_libdir_separator"; then
- if test -z "$hardcode_libdirs"; then
- hardcode_libdirs="$libdir"
- else
- # Just accumulate the unique libdirs.
- case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
- *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
- ;;
- *)
- hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
- ;;
- esac
- fi
- else
- eval flag=\"$hardcode_libdir_flag_spec\"
- rpath="$rpath $flag"
- fi
- elif test -n "$runpath_var"; then
- case "$perm_rpath " in
- *" $libdir "*) ;;
- *) perm_rpath="$perm_rpath $libdir" ;;
- esac
- fi
- case $host in
- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
- case :$dllsearchpath: in
- *":$libdir:"*) ;;
- *) dllsearchpath="$dllsearchpath:$libdir";;
- esac
- ;;
- esac
- done
- # Substitute the hardcoded libdirs into the rpath.
- if test -n "$hardcode_libdir_separator" &&
- test -n "$hardcode_libdirs"; then
- libdir="$hardcode_libdirs"
- eval rpath=\" $hardcode_libdir_flag_spec\"
- fi
- compile_rpath="$rpath"
-
- rpath=
- hardcode_libdirs=
- for libdir in $finalize_rpath; do
- if test -n "$hardcode_libdir_flag_spec"; then
- if test -n "$hardcode_libdir_separator"; then
- if test -z "$hardcode_libdirs"; then
- hardcode_libdirs="$libdir"
- else
- # Just accumulate the unique libdirs.
- case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
- *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
- ;;
- *)
- hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
- ;;
- esac
- fi
- else
- eval flag=\"$hardcode_libdir_flag_spec\"
- rpath="$rpath $flag"
- fi
- elif test -n "$runpath_var"; then
- case "$finalize_perm_rpath " in
- *" $libdir "*) ;;
- *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
- esac
- fi
- done
- # Substitute the hardcoded libdirs into the rpath.
- if test -n "$hardcode_libdir_separator" &&
- test -n "$hardcode_libdirs"; then
- libdir="$hardcode_libdirs"
- eval rpath=\" $hardcode_libdir_flag_spec\"
- fi
- finalize_rpath="$rpath"
-
- if test -n "$libobjs" && test "$build_old_libs" = yes; then
- # Transform all the library objects into standard objects.
- compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
- finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
- fi
-
- dlsyms=
- if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
- if test -n "$NM" && test -n "$global_symbol_pipe"; then
- dlsyms="${outputname}S.c"
- else
- $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
- fi
- fi
-
- if test -n "$dlsyms"; then
- case $dlsyms in
- "") ;;
- *.c)
- # Discover the nlist of each of the dlfiles.
- nlist="$output_objdir/${outputname}.nm"
-
- $show "$rm $nlist ${nlist}S ${nlist}T"
- $run $rm "$nlist" "${nlist}S" "${nlist}T"
-
- # Parse the name list into a source file.
- $show "creating $output_objdir/$dlsyms"
-
- test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
-/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
-/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
-
-#ifdef __cplusplus
-extern \"C\" {
-#endif
-
-/* Prevent the only kind of declaration conflicts we can make. */
-#define lt_preloaded_symbols some_other_symbol
-
-/* External symbol declarations for the compiler. */\
-"
-
- if test "$dlself" = yes; then
- $show "generating symbol list for \`$output'"
-
- test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
-
- # Add our own program objects to the symbol list.
- progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
- for arg in $progfiles; do
- $show "extracting global C symbols from \`$arg'"
- $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
- done
-
- if test -n "$exclude_expsyms"; then
- $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
- $run eval '$mv "$nlist"T "$nlist"'
- fi
-
- if test -n "$export_symbols_regex"; then
- $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
- $run eval '$mv "$nlist"T "$nlist"'
- fi
-
- # Prepare the list of exported symbols
- if test -z "$export_symbols"; then
- export_symbols="$output_objdir/$output.exp"
- $run $rm $export_symbols
- $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
- else
- $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
- $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
- $run eval 'mv "$nlist"T "$nlist"'
- fi
- fi
-
- for arg in $dlprefiles; do
- $show "extracting global C symbols from \`$arg'"
- name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
- $run eval '$echo ": $name " >> "$nlist"'
- $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
- done
-
- if test -z "$run"; then
- # Make sure we have at least an empty file.
- test -f "$nlist" || : > "$nlist"
-
- if test -n "$exclude_expsyms"; then
- $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
- $mv "$nlist"T "$nlist"
- fi
-
- # Try sorting and uniquifying the output.
- if grep -v "^: " < "$nlist" |
- if sort -k 3 </dev/null >/dev/null 2>&1; then
- sort -k 3
- else
- sort +2
- fi |
- uniq > "$nlist"S; then
- :
- else
- grep -v "^: " < "$nlist" > "$nlist"S
- fi
-
- if test -f "$nlist"S; then
- eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
- else
- $echo '/* NONE */' >> "$output_objdir/$dlsyms"
- fi
-
- $echo >> "$output_objdir/$dlsyms" "\
-
-#undef lt_preloaded_symbols
-
-#if defined (__STDC__) && __STDC__
-# define lt_ptr void *
-#else
-# define lt_ptr char *
-# define const
-#endif
-
-/* The mapping between symbol names and symbols. */
-const struct {
- const char *name;
- lt_ptr address;
-}
-lt_preloaded_symbols[] =
-{\
-"
-
- eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
-
- $echo >> "$output_objdir/$dlsyms" "\
- {0, (lt_ptr) 0}
-};
-
-/* This works around a problem in FreeBSD linker */
-#ifdef FREEBSD_WORKAROUND
-static const void *lt_preloaded_setup() {
- return lt_preloaded_symbols;
-}
-#endif
-
-#ifdef __cplusplus
-}
-#endif\
-"
- fi
-
- pic_flag_for_symtable=
- case $host in
- # compiling the symbol table file with pic_flag works around
- # a FreeBSD bug that causes programs to crash when -lm is
- # linked before any other PIC object. But we must not use
- # pic_flag when linking with -static. The problem exists in
- # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
- *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
- case "$compile_command " in
- *" -static "*) ;;
- *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
- esac;;
- *-*-hpux*)
- case "$compile_command " in
- *" -static "*) ;;
- *) pic_flag_for_symtable=" $pic_flag";;
- esac
- esac
-
- # Now compile the dynamic symbol file.
- $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
- $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
-
- # Clean up the generated files.
- $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
- $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
-
- # Transform the symbol file into the correct name.
- compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
- finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
- ;;
- *)
- $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- else
- # We keep going just in case the user didn't refer to
- # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
- # really was required.
-
- # Nullify the symbol file.
- compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
- finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
- fi
-
- if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
- # Replace the output file specification.
- compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
- link_command="$compile_command$compile_rpath"
-
- # We have no uninstalled library dependencies, so finalize right now.
- $show "$link_command"
- $run eval "$link_command"
- status=$?
-
- # Delete the generated files.
- if test -n "$dlsyms"; then
- $show "$rm $output_objdir/${outputname}S.${objext}"
- $run $rm "$output_objdir/${outputname}S.${objext}"
- fi
-
- exit $status
- fi
-
- if test -n "$shlibpath_var"; then
- # We should set the shlibpath_var
- rpath=
- for dir in $temp_rpath; do
- case $dir in
- [\\/]* | [A-Za-z]:[\\/]*)
- # Absolute path.
- rpath="$rpath$dir:"
- ;;
- *)
- # Relative path: add a thisdir entry.
- rpath="$rpath\$thisdir/$dir:"
- ;;
- esac
- done
- temp_rpath="$rpath"
- fi
-
- if test -n "$compile_shlibpath$finalize_shlibpath"; then
- compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
- fi
- if test -n "$finalize_shlibpath"; then
- finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
- fi
-
- compile_var=
- finalize_var=
- if test -n "$runpath_var"; then
- if test -n "$perm_rpath"; then
- # We should set the runpath_var.
- rpath=
- for dir in $perm_rpath; do
- rpath="$rpath$dir:"
- done
- compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
- fi
- if test -n "$finalize_perm_rpath"; then
- # We should set the runpath_var.
- rpath=
- for dir in $finalize_perm_rpath; do
- rpath="$rpath$dir:"
- done
- finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
- fi
- fi
-
- if test "$no_install" = yes; then
- # We don't need to create a wrapper script.
- link_command="$compile_var$compile_command$compile_rpath"
- # Replace the output file specification.
- link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
- # Delete the old output file.
- $run $rm $output
- # Link the executable and exit
- $show "$link_command"
- $run eval "$link_command" || exit $?
- exit $EXIT_SUCCESS
- fi
-
- if test "$hardcode_action" = relink; then
- # Fast installation is not supported
- link_command="$compile_var$compile_command$compile_rpath"
- relink_command="$finalize_var$finalize_command$finalize_rpath"
-
- $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
- $echo "$modename: \`$output' will be relinked during installation" 1>&2
- else
- if test "$fast_install" != no; then
- link_command="$finalize_var$compile_command$finalize_rpath"
- if test "$fast_install" = yes; then
- relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
- else
- # fast_install is set to needless
- relink_command=
- fi
- else
- link_command="$compile_var$compile_command$compile_rpath"
- relink_command="$finalize_var$finalize_command$finalize_rpath"
- fi
- fi
-
- # Replace the output file specification.
- link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
-
- # Delete the old output files.
- $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
-
- $show "$link_command"
- $run eval "$link_command" || exit $?
-
- # Now create the wrapper script.
- $show "creating $output"
-
- # Quote the relink command for shipping.
- if test -n "$relink_command"; then
- # Preserve any variables that may affect compiler behavior
- for var in $variables_saved_for_relink; do
- if eval test -z \"\${$var+set}\"; then
- relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
- elif eval var_value=\$$var; test -z "$var_value"; then
- relink_command="$var=; export $var; $relink_command"
- else
- var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
- relink_command="$var=\"$var_value\"; export $var; $relink_command"
- fi
- done
- relink_command="(cd `pwd`; $relink_command)"
- relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
- fi
-
- # Quote $echo for shipping.
- if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
- case $progpath in
- [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
- *) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
- esac
- qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
- else
- qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
- fi
-
- # Only actually do things if our run command is non-null.
- if test -z "$run"; then
- # win32 will think the script is a binary if it has
- # a .exe suffix, so we strip it off here.
- case $output in
- *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
- esac
- # test for cygwin because mv fails w/o .exe extensions
- case $host in
- *cygwin*)
- exeext=.exe
- outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
- *) exeext= ;;
- esac
- case $host in
- *cygwin* | *mingw* )
- cwrappersource=`$echo ${objdir}/lt-${output}.c`
- cwrapper=`$echo ${output}.exe`
- $rm $cwrappersource $cwrapper
- trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
-
- cat > $cwrappersource <<EOF
-
-/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
- Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
-
- The $output program cannot be directly executed until all the libtool
- libraries that it depends on are installed.
-
- This wrapper executable should never be moved out of the build directory.
- If it is, it will not operate correctly.
-
- Currently, it simply execs the wrapper *script* "/bin/sh $output",
- but could eventually absorb all of the scripts functionality and
- exec $objdir/$outputname directly.
-*/
-EOF
- cat >> $cwrappersource<<"EOF"
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <malloc.h>
-#include <stdarg.h>
-#include <assert.h>
-
-#if defined(PATH_MAX)
-# define LT_PATHMAX PATH_MAX
-#elif defined(MAXPATHLEN)
-# define LT_PATHMAX MAXPATHLEN
-#else
-# define LT_PATHMAX 1024
-#endif
-
-#ifndef DIR_SEPARATOR
-#define DIR_SEPARATOR '/'
-#endif
-
-#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
- defined (__OS2__)
-#define HAVE_DOS_BASED_FILE_SYSTEM
-#ifndef DIR_SEPARATOR_2
-#define DIR_SEPARATOR_2 '\\'
-#endif
-#endif
-
-#ifndef DIR_SEPARATOR_2
-# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
-#else /* DIR_SEPARATOR_2 */
-# define IS_DIR_SEPARATOR(ch) \
- (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
-#endif /* DIR_SEPARATOR_2 */
-
-#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
-#define XFREE(stale) do { \
- if (stale) { free ((void *) stale); stale = 0; } \
-} while (0)
-
-const char *program_name = NULL;
-
-void * xmalloc (size_t num);
-char * xstrdup (const char *string);
-char * basename (const char *name);
-char * fnqualify(const char *path);
-char * strendzap(char *str, const char *pat);
-void lt_fatal (const char *message, ...);
-
-int
-main (int argc, char *argv[])
-{
- char **newargz;
- int i;
-
- program_name = (char *) xstrdup ((char *) basename (argv[0]));
- newargz = XMALLOC(char *, argc+2);
-EOF
-
- cat >> $cwrappersource <<EOF
- newargz[0] = "$SHELL";
-EOF
-
- cat >> $cwrappersource <<"EOF"
- newargz[1] = fnqualify(argv[0]);
- /* we know the script has the same name, without the .exe */
- /* so make sure newargz[1] doesn't end in .exe */
- strendzap(newargz[1],".exe");
- for (i = 1; i < argc; i++)
- newargz[i+1] = xstrdup(argv[i]);
- newargz[argc+1] = NULL;
-EOF
-
- cat >> $cwrappersource <<EOF
- execv("$SHELL",newargz);
-EOF
-
- cat >> $cwrappersource <<"EOF"
-}
-
-void *
-xmalloc (size_t num)
-{
- void * p = (void *) malloc (num);
- if (!p)
- lt_fatal ("Memory exhausted");
-
- return p;
-}
-
-char *
-xstrdup (const char *string)
-{
- return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
-;
-}
-
-char *
-basename (const char *name)
-{
- const char *base;
-
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
- /* Skip over the disk name in MSDOS pathnames. */
- if (isalpha (name[0]) && name[1] == ':')
- name += 2;
-#endif
-
- for (base = name; *name; name++)
- if (IS_DIR_SEPARATOR (*name))
- base = name + 1;
- return (char *) base;
-}
-
-char *
-fnqualify(const char *path)
-{
- size_t size;
- char *p;
- char tmp[LT_PATHMAX + 1];
-
- assert(path != NULL);
-
- /* Is it qualified already? */
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
- if (isalpha (path[0]) && path[1] == ':')
- return xstrdup (path);
-#endif
- if (IS_DIR_SEPARATOR (path[0]))
- return xstrdup (path);
-
- /* prepend the current directory */
- /* doesn't handle '~' */
- if (getcwd (tmp, LT_PATHMAX) == NULL)
- lt_fatal ("getcwd failed");
- size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */
- p = XMALLOC(char, size);
- sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path);
- return p;
-}
-
-char *
-strendzap(char *str, const char *pat)
-{
- size_t len, patlen;
-
- assert(str != NULL);
- assert(pat != NULL);
-
- len = strlen(str);
- patlen = strlen(pat);
-
- if (patlen <= len)
- {
- str += len - patlen;
- if (strcmp(str, pat) == 0)
- *str = '\0';
- }
- return str;
-}
-
-static void
-lt_error_core (int exit_status, const char * mode,
- const char * message, va_list ap)
-{
- fprintf (stderr, "%s: %s: ", program_name, mode);
- vfprintf (stderr, message, ap);
- fprintf (stderr, ".\n");
-
- if (exit_status >= 0)
- exit (exit_status);
-}
-
-void
-lt_fatal (const char *message, ...)
-{
- va_list ap;
- va_start (ap, message);
- lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
- va_end (ap);
-}
-EOF
- # we should really use a build-platform specific compiler
- # here, but OTOH, the wrappers (shell script and this C one)
- # are only useful if you want to execute the "real" binary.
- # Since the "real" binary is built for $host, then this
- # wrapper might as well be built for $host, too.
- $run $LTCC -s -o $cwrapper $cwrappersource
- ;;
- esac
- $rm $output
- trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
-
- $echo > $output "\
-#! $SHELL
-
-# $output - temporary wrapper script for $objdir/$outputname
-# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
-#
-# The $output program cannot be directly executed until all the libtool
-# libraries that it depends on are installed.
-#
-# This wrapper script should never be moved out of the build directory.
-# If it is, it will not operate correctly.
-
-# Sed substitution that helps us do robust quoting. It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed='${SED} -e 1s/^X//'
-sed_quote_subst='$sed_quote_subst'
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi
-
-relink_command=\"$relink_command\"
-
-# This environment variable determines our operation mode.
-if test \"\$libtool_install_magic\" = \"$magic\"; then
- # install mode needs the following variable:
- notinst_deplibs='$notinst_deplibs'
-else
- # When we are sourced in execute mode, \$file and \$echo are already set.
- if test \"\$libtool_execute_magic\" != \"$magic\"; then
- echo=\"$qecho\"
- file=\"\$0\"
- # Make sure echo works.
- if test \"X\$1\" = X--no-reexec; then
- # Discard the --no-reexec flag, and continue.
- shift
- elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
- # Yippee, \$echo works!
- :
- else
- # Restart under the correct shell, and then maybe \$echo will work.
- exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
- fi
- fi\
-"
- $echo >> $output "\
-
- # Find the directory that this script lives in.
- thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
- test \"x\$thisdir\" = \"x\$file\" && thisdir=.
-
- # Follow symbolic links until we get to the real thisdir.
- file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
- while test -n \"\$file\"; do
- destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
-
- # If there was a directory component, then change thisdir.
- if test \"x\$destdir\" != \"x\$file\"; then
- case \"\$destdir\" in
- [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
- *) thisdir=\"\$thisdir/\$destdir\" ;;
- esac
- fi
-
- file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
- file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
- done
-
- # Try to get the absolute directory name.
- absdir=\`cd \"\$thisdir\" && pwd\`
- test -n \"\$absdir\" && thisdir=\"\$absdir\"
-"
-
- if test "$fast_install" = yes; then
- $echo >> $output "\
- program=lt-'$outputname'$exeext
- progdir=\"\$thisdir/$objdir\"
-
- if test ! -f \"\$progdir/\$program\" || \\
- { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
- test \"X\$file\" != \"X\$progdir/\$program\"; }; then
-
- file=\"\$\$-\$program\"
-
- if test ! -d \"\$progdir\"; then
- $mkdir \"\$progdir\"
- else
- $rm \"\$progdir/\$file\"
- fi"
-
- $echo >> $output "\
-
- # relink executable if necessary
- if test -n \"\$relink_command\"; then
- if relink_command_output=\`eval \$relink_command 2>&1\`; then :
- else
- $echo \"\$relink_command_output\" >&2
- $rm \"\$progdir/\$file\"
- exit $EXIT_FAILURE
- fi
- fi
-
- $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
- { $rm \"\$progdir/\$program\";
- $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
- $rm \"\$progdir/\$file\"
- fi"
- else
- $echo >> $output "\
- program='$outputname'
- progdir=\"\$thisdir/$objdir\"
-"
- fi
-
- $echo >> $output "\
-
- if test -f \"\$progdir/\$program\"; then"
-
- # Export our shlibpath_var if we have one.
- if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
- $echo >> $output "\
- # Add our own library path to $shlibpath_var
- $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
-
- # Some systems cannot cope with colon-terminated $shlibpath_var
- # The second colon is a workaround for a bug in BeOS R4 sed
- $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
-
- export $shlibpath_var
-"
- fi
-
- # fixup the dll searchpath if we need to.
- if test -n "$dllsearchpath"; then
- $echo >> $output "\
- # Add the dll search path components to the executable PATH
- PATH=$dllsearchpath:\$PATH
-"
- fi
-
- $echo >> $output "\
- if test \"\$libtool_execute_magic\" != \"$magic\"; then
- # Run the actual program with our arguments.
-"
- case $host in
- # Backslashes separate directories on plain windows
- *-*-mingw | *-*-os2*)
- $echo >> $output "\
- exec \$progdir\\\\\$program \${1+\"\$@\"}
-"
- ;;
-
- *)
- $echo >> $output "\
- exec \$progdir/\$program \${1+\"\$@\"}
-"
- ;;
- esac
- $echo >> $output "\
- \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
- exit $EXIT_FAILURE
- fi
- else
- # The program doesn't exist.
- \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2
- \$echo \"This script is just a wrapper for \$program.\" 1>&2
- $echo \"See the $PACKAGE documentation for more information.\" 1>&2
- exit $EXIT_FAILURE
- fi
-fi\
-"
- chmod +x $output
- fi
- exit $EXIT_SUCCESS
- ;;
- esac
-
- # See if we need to build an old-fashioned archive.
- for oldlib in $oldlibs; do
-
- if test "$build_libtool_libs" = convenience; then
- oldobjs="$libobjs_save"
- addlibs="$convenience"
- build_libtool_libs=no
- else
- if test "$build_libtool_libs" = module; then
- oldobjs="$libobjs_save"
- build_libtool_libs=no
- else
- oldobjs="$old_deplibs $non_pic_objects"
- fi
- addlibs="$old_convenience"
- fi
-
- if test -n "$addlibs"; then
- gentop="$output_objdir/${outputname}x"
- $show "${rm}r $gentop"
- $run ${rm}r "$gentop"
- $show "$mkdir $gentop"
- $run $mkdir "$gentop"
- status=$?
- if test "$status" -ne 0 && test ! -d "$gentop"; then
- exit $status
- fi
- generated="$generated $gentop"
-
- # Add in members from convenience archives.
- for xlib in $addlibs; do
- # Extract the objects.
- case $xlib in
- [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
- *) xabs=`pwd`"/$xlib" ;;
- esac
- xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
- xdir="$gentop/$xlib"
-
- $show "${rm}r $xdir"
- $run ${rm}r "$xdir"
- $show "$mkdir $xdir"
- $run $mkdir "$xdir"
- status=$?
- if test "$status" -ne 0 && test ! -d "$xdir"; then
- exit $status
- fi
- # We will extract separately just the conflicting names and we will no
- # longer touch any unique names. It is faster to leave these extract
- # automatically by $AR in one run.
- $show "(cd $xdir && $AR x $xabs)"
- $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
- if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
- :
- else
- $echo "$modename: warning: object name conflicts; renaming object files" 1>&2
- $echo "$modename: warning: to ensure that they will not overwrite" 1>&2
- $AR t "$xabs" | sort | uniq -cd | while read -r count name
- do
- i=1
- while test "$i" -le "$count"
- do
- # Put our $i before any first dot (extension)
- # Never overwrite any file
- name_to="$name"
- while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
- do
- name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
- done
- $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
- $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
- i=`expr $i + 1`
- done
- done
- fi
-
- oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP`
- done
- fi
-
- # Do each command in the archive commands.
- if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
- cmds=$old_archive_from_new_cmds
- else
- eval cmds=\"$old_archive_cmds\"
-
- if len=`expr "X$cmds" : ".*"` &&
- test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
- cmds=$old_archive_cmds
- else
- # the command line is too long to link in one step, link in parts
- $echo "using piecewise archive linking..."
- save_RANLIB=$RANLIB
- RANLIB=:
- objlist=
- concat_cmds=
- save_oldobjs=$oldobjs
- # GNU ar 2.10+ was changed to match POSIX; thus no paths are
- # encoded into archives. This makes 'ar r' malfunction in
- # this piecewise linking case whenever conflicting object
- # names appear in distinct ar calls; check, warn and compensate.
- if (for obj in $save_oldobjs
- do
- $echo "X$obj" | $Xsed -e 's%^.*/%%'
- done | sort | sort -uc >/dev/null 2>&1); then
- :
- else
- $echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2
- $echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2
- AR_FLAGS=cq
- fi
- # Is there a better way of finding the last object in the list?
- for obj in $save_oldobjs
- do
- last_oldobj=$obj
- done
- for obj in $save_oldobjs
- do
- oldobjs="$objlist $obj"
- objlist="$objlist $obj"
- eval test_cmds=\"$old_archive_cmds\"
- if len=`expr "X$test_cmds" : ".*"` &&
- test "$len" -le "$max_cmd_len"; then
- :
- else
- # the above command should be used before it gets too long
- oldobjs=$objlist
- if test "$obj" = "$last_oldobj" ; then
- RANLIB=$save_RANLIB
- fi
- test -z "$concat_cmds" || concat_cmds=$concat_cmds~
- eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
- objlist=
- fi
- done
- RANLIB=$save_RANLIB
- oldobjs=$objlist
- if test "X$oldobjs" = "X" ; then
- eval cmds=\"\$concat_cmds\"
- else
- eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
- fi
- fi
- fi
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- eval cmd=\"$cmd\"
- IFS="$save_ifs"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
- done
-
- if test -n "$generated"; then
- $show "${rm}r$generated"
- $run ${rm}r$generated
- fi
-
- # Now create the libtool archive.
- case $output in
- *.la)
- old_library=
- test "$build_old_libs" = yes && old_library="$libname.$libext"
- $show "creating $output"
-
- # Preserve any variables that may affect compiler behavior
- for var in $variables_saved_for_relink; do
- if eval test -z \"\${$var+set}\"; then
- relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
- elif eval var_value=\$$var; test -z "$var_value"; then
- relink_command="$var=; export $var; $relink_command"
- else
- var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
- relink_command="$var=\"$var_value\"; export $var; $relink_command"
- fi
- done
- # Quote the link command for shipping.
- relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
- relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
- if test "$hardcode_automatic" = yes ; then
- relink_command=
- fi
-
-
- # Only create the output if not a dry run.
- if test -z "$run"; then
- for installed in no yes; do
- if test "$installed" = yes; then
- if test -z "$install_libdir"; then
- break
- fi
- output="$output_objdir/$outputname"i
- # Replace all uninstalled libtool libraries with the installed ones
- newdependency_libs=
- for deplib in $dependency_libs; do
- case $deplib in
- *.la)
- name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
- eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
- if test -z "$libdir"; then
- $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
- exit $EXIT_FAILURE
- fi
- newdependency_libs="$newdependency_libs $libdir/$name"
- ;;
- *) newdependency_libs="$newdependency_libs $deplib" ;;
- esac
- done
- dependency_libs="$newdependency_libs"
- newdlfiles=
- for lib in $dlfiles; do
- name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
- eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
- if test -z "$libdir"; then
- $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
- exit $EXIT_FAILURE
- fi
- newdlfiles="$newdlfiles $libdir/$name"
- done
- dlfiles="$newdlfiles"
- newdlprefiles=
- for lib in $dlprefiles; do
- name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
- eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
- if test -z "$libdir"; then
- $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
- exit $EXIT_FAILURE
- fi
- newdlprefiles="$newdlprefiles $libdir/$name"
- done
- dlprefiles="$newdlprefiles"
- else
- newdlfiles=
- for lib in $dlfiles; do
- case $lib in
- [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
- *) abs=`pwd`"/$lib" ;;
- esac
- newdlfiles="$newdlfiles $abs"
- done
- dlfiles="$newdlfiles"
- newdlprefiles=
- for lib in $dlprefiles; do
- case $lib in
- [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
- *) abs=`pwd`"/$lib" ;;
- esac
- newdlprefiles="$newdlprefiles $abs"
- done
- dlprefiles="$newdlprefiles"
- fi
- $rm $output
- # place dlname in correct position for cygwin
- tdlname=$dlname
- case $host,$output,$installed,$module,$dlname in
- *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
- esac
- $echo > $output "\
-# $outputname - a libtool library file
-# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
-#
-# Please DO NOT delete this file!
-# It is necessary for linking the library.
-
-# The name that we can dlopen(3).
-dlname='$tdlname'
-
-# Names of this library.
-library_names='$library_names'
-
-# The name of the static archive.
-old_library='$old_library'
-
-# Libraries that this one depends upon.
-dependency_libs='$dependency_libs'
-
-# Version information for $libname.
-current=$current
-age=$age
-revision=$revision
-
-# Is this an already installed library?
-installed=$installed
-
-# Should we warn about portability when linking against -modules?
-shouldnotlink=$module
-
-# Files to dlopen/dlpreopen
-dlopen='$dlfiles'
-dlpreopen='$dlprefiles'
-
-# Directory that this library needs to be installed in:
-libdir='$install_libdir'"
- if test "$installed" = no && test "$need_relink" = yes; then
- $echo >> $output "\
-relink_command=\"$relink_command\""
- fi
- done
- fi
-
- # Do a symbolic link so that the libtool archive can be found in
- # LD_LIBRARY_PATH before the program is installed.
- $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
- $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
- ;;
- esac
- exit $EXIT_SUCCESS
- ;;
-
- # libtool install mode
- install)
- modename="$modename: install"
-
- # There may be an optional sh(1) argument at the beginning of
- # install_prog (especially on Windows NT).
- if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
- # Allow the use of GNU shtool's install command.
- $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then
- # Aesthetically quote it.
- arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
- arg="\"$arg\""
- ;;
- esac
- install_prog="$arg "
- arg="$1"
- shift
- else
- install_prog=
- arg="$nonopt"
- fi
-
- # The real first argument should be the name of the installation program.
- # Aesthetically quote it.
- arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
- arg="\"$arg\""
- ;;
- esac
- install_prog="$install_prog$arg"
-
- # We need to accept at least all the BSD install flags.
- dest=
- files=
- opts=
- prev=
- install_type=
- isdir=no
- stripme=
- for arg
- do
- if test -n "$dest"; then
- files="$files $dest"
- dest="$arg"
- continue
- fi
-
- case $arg in
- -d) isdir=yes ;;
- -f) prev="-f" ;;
- -g) prev="-g" ;;
- -m) prev="-m" ;;
- -o) prev="-o" ;;
- -s)
- stripme=" -s"
- continue
- ;;
- -*) ;;
-
- *)
- # If the previous option needed an argument, then skip it.
- if test -n "$prev"; then
- prev=
- else
- dest="$arg"
- continue
- fi
- ;;
- esac
-
- # Aesthetically quote the argument.
- arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
- arg="\"$arg\""
- ;;
- esac
- install_prog="$install_prog $arg"
- done
-
- if test -z "$install_prog"; then
- $echo "$modename: you must specify an install program" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- if test -n "$prev"; then
- $echo "$modename: the \`$prev' option requires an argument" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- if test -z "$files"; then
- if test -z "$dest"; then
- $echo "$modename: no file or destination specified" 1>&2
- else
- $echo "$modename: you must specify a destination" 1>&2
- fi
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Strip any trailing slash from the destination.
- dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
-
- # Check to see that the destination is a directory.
- test -d "$dest" && isdir=yes
- if test "$isdir" = yes; then
- destdir="$dest"
- destname=
- else
- destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
- test "X$destdir" = "X$dest" && destdir=.
- destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
-
- # Not a directory, so check to see that there is only one file specified.
- set dummy $files
- if test "$#" -gt 2; then
- $echo "$modename: \`$dest' is not a directory" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
- fi
- case $destdir in
- [\\/]* | [A-Za-z]:[\\/]*) ;;
- *)
- for file in $files; do
- case $file in
- *.lo) ;;
- *)
- $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- done
- ;;
- esac
-
- # This variable tells wrapper scripts just to set variables rather
- # than running their programs.
- libtool_install_magic="$magic"
-
- staticlibs=
- future_libdirs=
- current_libdirs=
- for file in $files; do
-
- # Do each installation.
- case $file in
- *.$libext)
- # Do the static libraries later.
- staticlibs="$staticlibs $file"
- ;;
-
- *.la)
- # Check to see that this really is a libtool archive.
- if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
- else
- $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- library_names=
- old_library=
- relink_command=
- # If there is no directory component, then add one.
- case $file in
- */* | *\\*) . $file ;;
- *) . ./$file ;;
- esac
-
- # Add the libdir to current_libdirs if it is the destination.
- if test "X$destdir" = "X$libdir"; then
- case "$current_libdirs " in
- *" $libdir "*) ;;
- *) current_libdirs="$current_libdirs $libdir" ;;
- esac
- else
- # Note the libdir as a future libdir.
- case "$future_libdirs " in
- *" $libdir "*) ;;
- *) future_libdirs="$future_libdirs $libdir" ;;
- esac
- fi
-
- dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
- test "X$dir" = "X$file/" && dir=
- dir="$dir$objdir"
-
- if test -n "$relink_command"; then
- # Determine the prefix the user has applied to our future dir.
- inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
-
- # Don't allow the user to place us outside of our expected
- # location b/c this prevents finding dependent libraries that
- # are installed to the same prefix.
- # At present, this check doesn't affect windows .dll's that
- # are installed into $libdir/../bin (currently, that works fine)
- # but it's something to keep an eye on.
- if test "$inst_prefix_dir" = "$destdir"; then
- $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
- exit $EXIT_FAILURE
- fi
-
- if test -n "$inst_prefix_dir"; then
- # Stick the inst_prefix_dir data into the link command.
- relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
- else
- relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
- fi
-
- $echo "$modename: warning: relinking \`$file'" 1>&2
- $show "$relink_command"
- if $run eval "$relink_command"; then :
- else
- $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
- exit $EXIT_FAILURE
- fi
- fi
-
- # See the names of the shared library.
- set dummy $library_names
- if test -n "$2"; then
- realname="$2"
- shift
- shift
-
- srcname="$realname"
- test -n "$relink_command" && srcname="$realname"T
-
- # Install the shared library and build the symlinks.
- $show "$install_prog $dir/$srcname $destdir/$realname"
- $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
- if test -n "$stripme" && test -n "$striplib"; then
- $show "$striplib $destdir/$realname"
- $run eval "$striplib $destdir/$realname" || exit $?
- fi
-
- if test "$#" -gt 0; then
- # Delete the old symlinks, and create new ones.
- for linkname
- do
- if test "$linkname" != "$realname"; then
- $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
- $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
- fi
- done
- fi
-
- # Do each command in the postinstall commands.
- lib="$destdir/$realname"
- cmds=$postinstall_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
- fi
-
- # Install the pseudo-library for information purposes.
- name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
- instname="$dir/$name"i
- $show "$install_prog $instname $destdir/$name"
- $run eval "$install_prog $instname $destdir/$name" || exit $?
-
- # Maybe install the static library, too.
- test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
- ;;
-
- *.lo)
- # Install (i.e. copy) a libtool object.
-
- # Figure out destination file name, if it wasn't already specified.
- if test -n "$destname"; then
- destfile="$destdir/$destname"
- else
- destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
- destfile="$destdir/$destfile"
- fi
-
- # Deduce the name of the destination old-style object file.
- case $destfile in
- *.lo)
- staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
- ;;
- *.$objext)
- staticdest="$destfile"
- destfile=
- ;;
- *)
- $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- # Install the libtool object if requested.
- if test -n "$destfile"; then
- $show "$install_prog $file $destfile"
- $run eval "$install_prog $file $destfile" || exit $?
- fi
-
- # Install the old object if enabled.
- if test "$build_old_libs" = yes; then
- # Deduce the name of the old-style object file.
- staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
-
- $show "$install_prog $staticobj $staticdest"
- $run eval "$install_prog \$staticobj \$staticdest" || exit $?
- fi
- exit $EXIT_SUCCESS
- ;;
-
- *)
- # Figure out destination file name, if it wasn't already specified.
- if test -n "$destname"; then
- destfile="$destdir/$destname"
- else
- destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
- destfile="$destdir/$destfile"
- fi
-
- # If the file is missing, and there is a .exe on the end, strip it
- # because it is most likely a libtool script we actually want to
- # install
- stripped_ext=""
- case $file in
- *.exe)
- if test ! -f "$file"; then
- file=`$echo $file|${SED} 's,.exe$,,'`
- stripped_ext=".exe"
- fi
- ;;
- esac
-
- # Do a test to see if this is really a libtool program.
- case $host in
- *cygwin*|*mingw*)
- wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
- ;;
- *)
- wrapper=$file
- ;;
- esac
- if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
- notinst_deplibs=
- relink_command=
-
- # To insure that "foo" is sourced, and not "foo.exe",
- # finese the cygwin/MSYS system by explicitly sourcing "foo."
- # which disallows the automatic-append-.exe behavior.
- case $build in
- *cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
- *) wrapperdot=${wrapper} ;;
- esac
- # If there is no directory component, then add one.
- case $file in
- */* | *\\*) . ${wrapperdot} ;;
- *) . ./${wrapperdot} ;;
- esac
-
- # Check the variables that should have been set.
- if test -z "$notinst_deplibs"; then
- $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
- exit $EXIT_FAILURE
- fi
-
- finalize=yes
- for lib in $notinst_deplibs; do
- # Check to see that each library is installed.
- libdir=
- if test -f "$lib"; then
- # If there is no directory component, then add one.
- case $lib in
- */* | *\\*) . $lib ;;
- *) . ./$lib ;;
- esac
- fi
- libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
- if test -n "$libdir" && test ! -f "$libfile"; then
- $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
- finalize=no
- fi
- done
-
- relink_command=
- # To insure that "foo" is sourced, and not "foo.exe",
- # finese the cygwin/MSYS system by explicitly sourcing "foo."
- # which disallows the automatic-append-.exe behavior.
- case $build in
- *cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
- *) wrapperdot=${wrapper} ;;
- esac
- # If there is no directory component, then add one.
- case $file in
- */* | *\\*) . ${wrapperdot} ;;
- *) . ./${wrapperdot} ;;
- esac
-
- outputname=
- if test "$fast_install" = no && test -n "$relink_command"; then
- if test "$finalize" = yes && test -z "$run"; then
- tmpdir="/tmp"
- test -n "$TMPDIR" && tmpdir="$TMPDIR"
- tmpdir="$tmpdir/libtool-$$"
- save_umask=`umask`
- umask 0077
- if $mkdir "$tmpdir"; then
- umask $save_umask
- else
- umask $save_umask
- $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
- continue
- fi
- file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
- outputname="$tmpdir/$file"
- # Replace the output file specification.
- relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
-
- $show "$relink_command"
- if $run eval "$relink_command"; then :
- else
- $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
- ${rm}r "$tmpdir"
- continue
- fi
- file="$outputname"
- else
- $echo "$modename: warning: cannot relink \`$file'" 1>&2
- fi
- else
- # Install the binary that we compiled earlier.
- file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
- fi
- fi
-
- # remove .exe since cygwin /usr/bin/install will append another
- # one anyways
- case $install_prog,$host in
- */usr/bin/install*,*cygwin*)
- case $file:$destfile in
- *.exe:*.exe)
- # this is ok
- ;;
- *.exe:*)
- destfile=$destfile.exe
- ;;
- *:*.exe)
- destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
- ;;
- esac
- ;;
- esac
- $show "$install_prog$stripme $file $destfile"
- $run eval "$install_prog\$stripme \$file \$destfile" || exit $?
- test -n "$outputname" && ${rm}r "$tmpdir"
- ;;
- esac
- done
-
- for file in $staticlibs; do
- name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
-
- # Set up the ranlib parameters.
- oldlib="$destdir/$name"
-
- $show "$install_prog $file $oldlib"
- $run eval "$install_prog \$file \$oldlib" || exit $?
-
- if test -n "$stripme" && test -n "$old_striplib"; then
- $show "$old_striplib $oldlib"
- $run eval "$old_striplib $oldlib" || exit $?
- fi
-
- # Do each command in the postinstall commands.
- cmds=$old_postinstall_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
- done
-
- if test -n "$future_libdirs"; then
- $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
- fi
-
- if test -n "$current_libdirs"; then
- # Maybe just do a dry run.
- test -n "$run" && current_libdirs=" -n$current_libdirs"
- exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
- else
- exit $EXIT_SUCCESS
- fi
- ;;
-
- # libtool finish mode
- finish)
- modename="$modename: finish"
- libdirs="$nonopt"
- admincmds=
-
- if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
- for dir
- do
- libdirs="$libdirs $dir"
- done
-
- for libdir in $libdirs; do
- if test -n "$finish_cmds"; then
- # Do each command in the finish commands.
- cmds=$finish_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || admincmds="$admincmds
- $cmd"
- done
- IFS="$save_ifs"
- fi
- if test -n "$finish_eval"; then
- # Do the single finish_eval.
- eval cmds=\"$finish_eval\"
- $run eval "$cmds" || admincmds="$admincmds
- $cmds"
- fi
- done
- fi
-
- # Exit here if they wanted silent mode.
- test "$show" = : && exit $EXIT_SUCCESS
-
- $echo "----------------------------------------------------------------------"
- $echo "Libraries have been installed in:"
- for libdir in $libdirs; do
- $echo " $libdir"
- done
- $echo
- $echo "If you ever happen to want to link against installed libraries"
- $echo "in a given directory, LIBDIR, you must either use libtool, and"
- $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
- $echo "flag during linking and do at least one of the following:"
- if test -n "$shlibpath_var"; then
- $echo " - add LIBDIR to the \`$shlibpath_var' environment variable"
- $echo " during execution"
- fi
- if test -n "$runpath_var"; then
- $echo " - add LIBDIR to the \`$runpath_var' environment variable"
- $echo " during linking"
- fi
- if test -n "$hardcode_libdir_flag_spec"; then
- libdir=LIBDIR
- eval flag=\"$hardcode_libdir_flag_spec\"
-
- $echo " - use the \`$flag' linker flag"
- fi
- if test -n "$admincmds"; then
- $echo " - have your system administrator run these commands:$admincmds"
- fi
- if test -f /etc/ld.so.conf; then
- $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
- fi
- $echo
- $echo "See any operating system documentation about shared libraries for"
- $echo "more information, such as the ld(1) and ld.so(8) manual pages."
- $echo "----------------------------------------------------------------------"
- exit $EXIT_SUCCESS
- ;;
-
- # libtool execute mode
- execute)
- modename="$modename: execute"
-
- # The first argument is the command name.
- cmd="$nonopt"
- if test -z "$cmd"; then
- $echo "$modename: you must specify a COMMAND" 1>&2
- $echo "$help"
- exit $EXIT_FAILURE
- fi
-
- # Handle -dlopen flags immediately.
- for file in $execute_dlfiles; do
- if test ! -f "$file"; then
- $echo "$modename: \`$file' is not a file" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- dir=
- case $file in
- *.la)
- # Check to see that this really is a libtool archive.
- if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
- else
- $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Read the libtool library.
- dlname=
- library_names=
-
- # If there is no directory component, then add one.
- case $file in
- */* | *\\*) . $file ;;
- *) . ./$file ;;
- esac
-
- # Skip this library if it cannot be dlopened.
- if test -z "$dlname"; then
- # Warn if it was a shared library.
- test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
- continue
- fi
-
- dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
- test "X$dir" = "X$file" && dir=.
-
- if test -f "$dir/$objdir/$dlname"; then
- dir="$dir/$objdir"
- else
- $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
- exit $EXIT_FAILURE
- fi
- ;;
-
- *.lo)
- # Just add the directory containing the .lo file.
- dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
- test "X$dir" = "X$file" && dir=.
- ;;
-
- *)
- $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
- continue
- ;;
- esac
-
- # Get the absolute pathname.
- absdir=`cd "$dir" && pwd`
- test -n "$absdir" && dir="$absdir"
-
- # Now add the directory to shlibpath_var.
- if eval "test -z \"\$$shlibpath_var\""; then
- eval "$shlibpath_var=\"\$dir\""
- else
- eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
- fi
- done
-
- # This variable tells wrapper scripts just to set shlibpath_var
- # rather than running their programs.
- libtool_execute_magic="$magic"
-
- # Check if any of the arguments is a wrapper script.
- args=
- for file
- do
- case $file in
- -*) ;;
- *)
- # Do a test to see if this is really a libtool program.
- if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- # If there is no directory component, then add one.
- case $file in
- */* | *\\*) . $file ;;
- *) . ./$file ;;
- esac
-
- # Transform arg to wrapped name.
- file="$progdir/$program"
- fi
- ;;
- esac
- # Quote arguments (to preserve shell metacharacters).
- file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
- args="$args \"$file\""
- done
-
- if test -z "$run"; then
- if test -n "$shlibpath_var"; then
- # Export the shlibpath_var.
- eval "export $shlibpath_var"
- fi
-
- # Restore saved environment variables
- if test "${save_LC_ALL+set}" = set; then
- LC_ALL="$save_LC_ALL"; export LC_ALL
- fi
- if test "${save_LANG+set}" = set; then
- LANG="$save_LANG"; export LANG
- fi
-
- # Now prepare to actually exec the command.
- exec_cmd="\$cmd$args"
- else
- # Display what would be done.
- if test -n "$shlibpath_var"; then
- eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
- $echo "export $shlibpath_var"
- fi
- $echo "$cmd$args"
- exit $EXIT_SUCCESS
- fi
- ;;
-
- # libtool clean and uninstall mode
- clean | uninstall)
- modename="$modename: $mode"
- rm="$nonopt"
- files=
- rmforce=
- exit_status=0
-
- # This variable tells wrapper scripts just to set variables rather
- # than running their programs.
- libtool_install_magic="$magic"
-
- for arg
- do
- case $arg in
- -f) rm="$rm $arg"; rmforce=yes ;;
- -*) rm="$rm $arg" ;;
- *) files="$files $arg" ;;
- esac
- done
-
- if test -z "$rm"; then
- $echo "$modename: you must specify an RM program" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- rmdirs=
-
- origobjdir="$objdir"
- for file in $files; do
- dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$dir" = "X$file"; then
- dir=.
- objdir="$origobjdir"
- else
- objdir="$dir/$origobjdir"
- fi
- name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
- test "$mode" = uninstall && objdir="$dir"
-
- # Remember objdir for removal later, being careful to avoid duplicates
- if test "$mode" = clean; then
- case " $rmdirs " in
- *" $objdir "*) ;;
- *) rmdirs="$rmdirs $objdir" ;;
- esac
- fi
-
- # Don't error if the file doesn't exist and rm -f was used.
- if (test -L "$file") >/dev/null 2>&1 \
- || (test -h "$file") >/dev/null 2>&1 \
- || test -f "$file"; then
- :
- elif test -d "$file"; then
- exit_status=1
- continue
- elif test "$rmforce" = yes; then
- continue
- fi
-
- rmfiles="$file"
-
- case $name in
- *.la)
- # Possibly a libtool archive, so verify it.
- if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- . $dir/$name
-
- # Delete the libtool libraries and symlinks.
- for n in $library_names; do
- rmfiles="$rmfiles $objdir/$n"
- done
- test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
- test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
-
- if test "$mode" = uninstall; then
- if test -n "$library_names"; then
- # Do each command in the postuninstall commands.
- cmds=$postuninstall_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd"
- if test "$?" -ne 0 && test "$rmforce" != yes; then
- exit_status=1
- fi
- done
- IFS="$save_ifs"
- fi
-
- if test -n "$old_library"; then
- # Do each command in the old_postuninstall commands.
- cmds=$old_postuninstall_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd"
- if test "$?" -ne 0 && test "$rmforce" != yes; then
- exit_status=1
- fi
- done
- IFS="$save_ifs"
- fi
- # FIXME: should reinstall the best remaining shared library.
- fi
- fi
- ;;
-
- *.lo)
- # Possibly a libtool object, so verify it.
- if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
-
- # Read the .lo file
- . $dir/$name
-
- # Add PIC object to the list of files to remove.
- if test -n "$pic_object" \
- && test "$pic_object" != none; then
- rmfiles="$rmfiles $dir/$pic_object"
- fi
-
- # Add non-PIC object to the list of files to remove.
- if test -n "$non_pic_object" \
- && test "$non_pic_object" != none; then
- rmfiles="$rmfiles $dir/$non_pic_object"
- fi
- fi
- ;;
-
- *)
- if test "$mode" = clean ; then
- noexename=$name
- case $file in
- *.exe)
- file=`$echo $file|${SED} 's,.exe$,,'`
- noexename=`$echo $name|${SED} 's,.exe$,,'`
- # $file with .exe has already been added to rmfiles,
- # add $file without .exe
- rmfiles="$rmfiles $file"
- ;;
- esac
- # Do a test to see if this is a libtool program.
- if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- relink_command=
- . $dir/$noexename
-
- # note $name still contains .exe if it was in $file originally
- # as does the version of $file that was added into $rmfiles
- rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
- if test "$fast_install" = yes && test -n "$relink_command"; then
- rmfiles="$rmfiles $objdir/lt-$name"
- fi
- if test "X$noexename" != "X$name" ; then
- rmfiles="$rmfiles $objdir/lt-${noexename}.c"
- fi
- fi
- fi
- ;;
- esac
- $show "$rm $rmfiles"
- $run $rm $rmfiles || exit_status=1
- done
- objdir="$origobjdir"
-
- # Try to remove the ${objdir}s in the directories where we deleted files
- for dir in $rmdirs; do
- if test -d "$dir"; then
- $show "rmdir $dir"
- $run rmdir $dir >/dev/null 2>&1
- fi
- done
-
- exit $exit_status
- ;;
-
- "")
- $echo "$modename: you must specify a MODE" 1>&2
- $echo "$generic_help" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- if test -z "$exec_cmd"; then
- $echo "$modename: invalid operation mode \`$mode'" 1>&2
- $echo "$generic_help" 1>&2
- exit $EXIT_FAILURE
- fi
-fi # test -z "$show_help"
-
-if test -n "$exec_cmd"; then
- eval exec $exec_cmd
- exit $EXIT_FAILURE
-fi
-
-# We need to display help for each of the modes.
-case $mode in
-"") $echo \
-"Usage: $modename [OPTION]... [MODE-ARG]...
-
-Provide generalized library-building support services.
-
- --config show all configuration variables
- --debug enable verbose shell tracing
--n, --dry-run display commands without modifying any files
- --features display basic configuration information and exit
- --finish same as \`--mode=finish'
- --help display this help message and exit
- --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS]
- --quiet same as \`--silent'
- --silent don't print informational messages
- --tag=TAG use configuration variables from tag TAG
- --version print version information
-
-MODE must be one of the following:
-
- clean remove files from the build directory
- compile compile a source file into a libtool object
- execute automatically set library path, then run a program
- finish complete the installation of libtool libraries
- install install libraries or executables
- link create a library or an executable
- uninstall remove libraries from an installed directory
-
-MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for
-a more detailed description of MODE.
-
-Report bugs to <bug-libtool@gnu.org>."
- exit $EXIT_SUCCESS
- ;;
-
-clean)
- $echo \
-"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
-
-Remove files from the build directory.
-
-RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
-to RM.
-
-If FILE is a libtool library, object or program, all the files associated
-with it are deleted. Otherwise, only FILE itself is deleted using RM."
- ;;
-
-compile)
- $echo \
-"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
-
-Compile a source file into a libtool library object.
-
-This mode accepts the following additional options:
-
- -o OUTPUT-FILE set the output file name to OUTPUT-FILE
- -prefer-pic try to building PIC objects only
- -prefer-non-pic try to building non-PIC objects only
- -static always build a \`.o' file suitable for static linking
-
-COMPILE-COMMAND is a command to be used in creating a \`standard' object file
-from the given SOURCEFILE.
-
-The output file name is determined by removing the directory component from
-SOURCEFILE, then substituting the C source code suffix \`.c' with the
-library object suffix, \`.lo'."
- ;;
-
-execute)
- $echo \
-"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
-
-Automatically set library path, then run a program.
-
-This mode accepts the following additional options:
-
- -dlopen FILE add the directory containing FILE to the library path
-
-This mode sets the library path environment variable according to \`-dlopen'
-flags.
-
-If any of the ARGS are libtool executable wrappers, then they are translated
-into their corresponding uninstalled binary, and any of their required library
-directories are added to the library path.
-
-Then, COMMAND is executed, with ARGS as arguments."
- ;;
-
-finish)
- $echo \
-"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
-
-Complete the installation of libtool libraries.
-
-Each LIBDIR is a directory that contains libtool libraries.
-
-The commands that this mode executes may require superuser privileges. Use
-the \`--dry-run' option if you just want to see what would be executed."
- ;;
-
-install)
- $echo \
-"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
-
-Install executables or libraries.
-
-INSTALL-COMMAND is the installation command. The first component should be
-either the \`install' or \`cp' program.
-
-The rest of the components are interpreted as arguments to that command (only
-BSD-compatible install options are recognized)."
- ;;
-
-link)
- $echo \
-"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
-
-Link object files or libraries together to form another library, or to
-create an executable program.
-
-LINK-COMMAND is a command using the C compiler that you would use to create
-a program from several object files.
-
-The following components of LINK-COMMAND are treated specially:
-
- -all-static do not do any dynamic linking at all
- -avoid-version do not add a version suffix if possible
- -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
- -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
- -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
- -export-symbols SYMFILE
- try to export only the symbols listed in SYMFILE
- -export-symbols-regex REGEX
- try to export only the symbols matching REGEX
- -LLIBDIR search LIBDIR for required installed libraries
- -lNAME OUTPUT-FILE requires the installed library libNAME
- -module build a library that can dlopened
- -no-fast-install disable the fast-install mode
- -no-install link a not-installable executable
- -no-undefined declare that a library does not refer to external symbols
- -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
- -objectlist FILE Use a list of object files found in FILE to specify objects
- -precious-files-regex REGEX
- don't remove output files matching REGEX
- -release RELEASE specify package release information
- -rpath LIBDIR the created library will eventually be installed in LIBDIR
- -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
- -static do not do any dynamic linking of libtool libraries
- -version-info CURRENT[:REVISION[:AGE]]
- specify library version info [each variable defaults to 0]
-
-All other options (arguments beginning with \`-') are ignored.
-
-Every other argument is treated as a filename. Files ending in \`.la' are
-treated as uninstalled libtool libraries, other files are standard or library
-object files.
-
-If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
-only library objects (\`.lo' files) may be specified, and \`-rpath' is
-required, except when creating a convenience library.
-
-If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
-using \`ar' and \`ranlib', or on Windows using \`lib'.
-
-If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
-is created, otherwise an executable program is created."
- ;;
-
-uninstall)
- $echo \
-"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
-
-Remove libraries from an installation directory.
-
-RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
-to RM.
-
-If FILE is a libtool library, all the files associated with it are deleted.
-Otherwise, only FILE itself is deleted using RM."
- ;;
-
-*)
- $echo "$modename: invalid operation mode \`$mode'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- ;;
-esac
-
-$echo
-$echo "Try \`$modename --help' for more information about other modes."
-
-exit $EXIT_SUCCESS
-
-# The TAGs below are defined such that we never get into a situation
-# in which we disable both kinds of libraries. Given conflicting
-# choices, we go for a static library, that is the most portable,
-# since we can't tell whether shared libraries were disabled because
-# the user asked for that or because the platform doesn't support
-# them. This is particularly important on AIX, because we don't
-# support having both static and shared libraries enabled at the same
-# time on that platform, so we default to a shared-only configuration.
-# If a disable-shared tag is given, we'll fallback to a static-only
-# configuration. But we'll never go from static-only to shared-only.
-
-# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
-build_libtool_libs=no
-build_old_libs=yes
-# ### END LIBTOOL TAG CONFIG: disable-shared
-
-# ### BEGIN LIBTOOL TAG CONFIG: disable-static
-build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac`
-# ### END LIBTOOL TAG CONFIG: disable-static
-
-# Local Variables:
-# mode:shell-script
-# sh-indentation:2
-# End:
diff --git a/source4/lib/json/missing b/source4/lib/json/missing
deleted file mode 100755
index 5846bcf8b0..0000000000
--- a/source4/lib/json/missing
+++ /dev/null
@@ -1,334 +0,0 @@
-#! /bin/sh
-# Common stub for a few missing GNU programs while installing.
-# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
-# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
-
-# 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 2, 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.
-
-if test $# -eq 0; then
- echo 1>&2 "Try \`$0 --help' for more information"
- exit 1
-fi
-
-run=:
-
-# In the cases where this matters, `missing' is being run in the
-# srcdir already.
-if test -f configure.ac; then
- configure_ac=configure.ac
-else
- configure_ac=configure.in
-fi
-
-case "$1" in
---run)
- # Try to run requested program, and just exit if it succeeds.
- run=
- shift
- "$@" && exit 0
- ;;
-esac
-
-# If it does not exist, or fails to run (possibly an outdated version),
-# try to emulate it.
-case "$1" in
-
- -h|--h|--he|--hel|--help)
- echo "\
-$0 [OPTION]... PROGRAM [ARGUMENT]...
-
-Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
-error status if there is no known handling for PROGRAM.
-
-Options:
- -h, --help display this help and exit
- -v, --version output version information and exit
- --run try to run the given command, and emulate it if it fails
-
-Supported PROGRAM values:
- aclocal touch file \`aclocal.m4'
- autoconf touch file \`configure'
- autoheader touch file \`config.h.in'
- automake touch all \`Makefile.in' files
- bison create \`y.tab.[ch]', if possible, from existing .[ch]
- flex create \`lex.yy.c', if possible, from existing .c
- help2man touch the output file
- lex create \`lex.yy.c', if possible, from existing .c
- makeinfo touch the output file
- tar try tar, gnutar, gtar, then tar without non-portable flags
- yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
- ;;
-
- -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
- echo "missing 0.4 - GNU automake"
- ;;
-
- -*)
- echo 1>&2 "$0: Unknown \`$1' option"
- echo 1>&2 "Try \`$0 --help' for more information"
- exit 1
- ;;
-
- aclocal*)
- if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
- # We have it, but it failed.
- exit 1
- fi
-
- echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
- you modified \`acinclude.m4' or \`${configure_ac}'. You might want
- to install the \`Automake' and \`Perl' packages. Grab them from
- any GNU archive site."
- touch aclocal.m4
- ;;
-
- autoconf)
- if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
- # We have it, but it failed.
- exit 1
- fi
-
- echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
- you modified \`${configure_ac}'. You might want to install the
- \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
- archive site."
- touch configure
- ;;
-
- autoheader)
- if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
- # We have it, but it failed.
- exit 1
- fi
-
- echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
- you modified \`acconfig.h' or \`${configure_ac}'. You might want
- to install the \`Autoconf' and \`GNU m4' packages. Grab them
- from any GNU archive site."
- files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
- test -z "$files" && files="config.h"
- touch_files=
- for f in $files; do
- case "$f" in
- *:*) touch_files="$touch_files "`echo "$f" |
- sed -e 's/^[^:]*://' -e 's/:.*//'`;;
- *) touch_files="$touch_files $f.in";;
- esac
- done
- touch $touch_files
- ;;
-
- automake*)
- if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
- # We have it, but it failed.
- exit 1
- fi
-
- echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
- you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
- You might want to install the \`Automake' and \`Perl' packages.
- Grab them from any GNU archive site."
- find . -type f -name Makefile.am -print |
- sed 's/\.am$/.in/' |
- while read f; do touch "$f"; done
- ;;
-
- autom4te)
- if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
- # We have it, but it failed.
- exit 1
- fi
-
- echo 1>&2 "\
-WARNING: \`$1' is needed, and you do not seem to have it handy on your
- system. You might have modified some files without having the
- proper tools for further handling them.
- You can get \`$1Help2man' as part of \`Autoconf' from any GNU
- archive site."
-
- file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
- test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
- if test -f "$file"; then
- touch $file
- else
- test -z "$file" || exec >$file
- echo "#! /bin/sh"
- echo "# Created by GNU Automake missing as a replacement of"
- echo "# $ $@"
- echo "exit 0"
- chmod +x $file
- exit 1
- fi
- ;;
-
- bison|yacc)
- echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
- you modified a \`.y' file. You may need the \`Bison' package
- in order for those modifications to take effect. You can get
- \`Bison' from any GNU archive site."
- rm -f y.tab.c y.tab.h
- if [ $# -ne 1 ]; then
- eval LASTARG="\${$#}"
- case "$LASTARG" in
- *.y)
- SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
- if [ -f "$SRCFILE" ]; then
- cp "$SRCFILE" y.tab.c
- fi
- SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
- if [ -f "$SRCFILE" ]; then
- cp "$SRCFILE" y.tab.h
- fi
- ;;
- esac
- fi
- if [ ! -f y.tab.h ]; then
- echo >y.tab.h
- fi
- if [ ! -f y.tab.c ]; then
- echo 'main() { return 0; }' >y.tab.c
- fi
- ;;
-
- lex|flex)
- echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
- you modified a \`.l' file. You may need the \`Flex' package
- in order for those modifications to take effect. You can get
- \`Flex' from any GNU archive site."
- rm -f lex.yy.c
- if [ $# -ne 1 ]; then
- eval LASTARG="\${$#}"
- case "$LASTARG" in
- *.l)
- SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
- if [ -f "$SRCFILE" ]; then
- cp "$SRCFILE" lex.yy.c
- fi
- ;;
- esac
- fi
- if [ ! -f lex.yy.c ]; then
- echo 'main() { return 0; }' >lex.yy.c
- fi
- ;;
-
- help2man)
- if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
- # We have it, but it failed.
- exit 1
- fi
-
- echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
- you modified a dependency of a manual page. You may need the
- \`Help2man' package in order for those modifications to take
- effect. You can get \`Help2man' from any GNU archive site."
-
- file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
- if test -z "$file"; then
- file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
- fi
- if [ -f "$file" ]; then
- touch $file
- else
- test -z "$file" || exec >$file
- echo ".ab help2man is required to generate this page"
- exit 1
- fi
- ;;
-
- makeinfo)
- if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
- # We have makeinfo, but it failed.
- exit 1
- fi
-
- echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
- you modified a \`.texi' or \`.texinfo' file, or any other file
- indirectly affecting the aspect of the manual. The spurious
- call might also be the consequence of using a buggy \`make' (AIX,
- DU, IRIX). You might want to install the \`Texinfo' package or
- the \`GNU make' package. Grab either from any GNU archive site."
- file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
- if test -z "$file"; then
- file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
- file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
- fi
- touch $file
- ;;
-
- tar)
- shift
- if test -n "$run"; then
- echo 1>&2 "ERROR: \`tar' requires --run"
- exit 1
- fi
-
- # We have already tried tar in the generic part.
- # Look for gnutar/gtar before invocation to avoid ugly error
- # messages.
- if (gnutar --version > /dev/null 2>&1); then
- gnutar "$@" && exit 0
- fi
- if (gtar --version > /dev/null 2>&1); then
- gtar "$@" && exit 0
- fi
- firstarg="$1"
- if shift; then
- case "$firstarg" in
- *o*)
- firstarg=`echo "$firstarg" | sed s/o//`
- tar "$firstarg" "$@" && exit 0
- ;;
- esac
- case "$firstarg" in
- *h*)
- firstarg=`echo "$firstarg" | sed s/h//`
- tar "$firstarg" "$@" && exit 0
- ;;
- esac
- fi
-
- echo 1>&2 "\
-WARNING: I can't seem to be able to run \`tar' with the given arguments.
- You may want to install GNU tar or Free paxutils, or check the
- command line arguments."
- exit 1
- ;;
-
- *)
- echo 1>&2 "\
-WARNING: \`$1' is needed, and you do not seem to have it handy on your
- system. You might have modified some files without having the
- proper tools for further handling them. Check the \`README' file,
- it often tells you about the needed prerequirements for installing
- this package. You may also peek at any GNU archive site, in case
- some other package would contain this missing \`$1' program."
- exit 1
- ;;
-esac
-
-exit 0
diff --git a/source4/lib/json/mkinstalldirs b/source4/lib/json/mkinstalldirs
deleted file mode 100755
index 8ab885ec92..0000000000
--- a/source4/lib/json/mkinstalldirs
+++ /dev/null
@@ -1,99 +0,0 @@
-#! /bin/sh
-# mkinstalldirs --- make directory hierarchy
-# Author: Noah Friedman <friedman@prep.ai.mit.edu>
-# Created: 1993-05-16
-# Public domain
-
-errstatus=0
-dirmode=""
-
-usage="\
-Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
-
-# process command line arguments
-while test $# -gt 0 ; do
- case "${1}" in
- -h | --help | --h* ) # -h for help
- echo "${usage}" 1>&2; exit 0 ;;
- -m ) # -m PERM arg
- shift
- test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
- dirmode="${1}"
- shift ;;
- -- ) shift; break ;; # stop option processing
- -* ) echo "${usage}" 1>&2; exit 1 ;; # unknown option
- * ) break ;; # first non-opt arg
- esac
-done
-
-for file
-do
- if test -d "$file"; then
- shift
- else
- break
- fi
-done
-
-case $# in
-0) exit 0 ;;
-esac
-
-case $dirmode in
-'')
- if mkdir -p -- . 2>/dev/null; then
- echo "mkdir -p -- $*"
- exec mkdir -p -- "$@"
- fi ;;
-*)
- if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
- echo "mkdir -m $dirmode -p -- $*"
- exec mkdir -m "$dirmode" -p -- "$@"
- fi ;;
-esac
-
-for file
-do
- set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
- shift
-
- pathcomp=
- for d
- do
- pathcomp="$pathcomp$d"
- case "$pathcomp" in
- -* ) pathcomp=./$pathcomp ;;
- esac
-
- if test ! -d "$pathcomp"; then
- echo "mkdir $pathcomp"
-
- mkdir "$pathcomp" || lasterr=$?
-
- if test ! -d "$pathcomp"; then
- errstatus=$lasterr
- else
- if test ! -z "$dirmode"; then
- echo "chmod $dirmode $pathcomp"
-
- lasterr=""
- chmod "$dirmode" "$pathcomp" || lasterr=$?
-
- if test ! -z "$lasterr"; then
- errstatus=$lasterr
- fi
- fi
- fi
- fi
-
- pathcomp="$pathcomp/"
- done
-done
-
-exit $errstatus
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 3
-# End:
-# mkinstalldirs ends here
diff --git a/source4/lib/json/printbuf.c b/source4/lib/json/printbuf.c
deleted file mode 100644
index 79bdaf554a..0000000000
--- a/source4/lib/json/printbuf.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * $Id: printbuf.c,v 1.5 2006/01/26 02:16:28 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if HAVE_STDARG_H
-# include <stdarg.h>
-#else /* !HAVE_STDARG_H */
-# error Not enough var arg support!
-#endif /* HAVE_STDARG_H */
-
-#include "bits.h"
-#include "debug.h"
-#include "printbuf.h"
-
-struct printbuf* printbuf_new()
-{
- struct printbuf *p;
-
- if(!(p = calloc(1, sizeof(struct printbuf)))) return NULL;
- p->size = 32;
- p->bpos = 0;
- if(!(p->buf = malloc(p->size))) {
- free(p);
- return NULL;
- }
- return p;
-}
-
-
-int printbuf_memappend(struct printbuf *p, char *buf, int size)
-{
- char *t;
- if(p->size - p->bpos <= size) {
- int new_size = max(p->size * 2, p->bpos + size + 8);
-#ifdef PRINTBUF_DEBUG
- mc_debug("printbuf_memappend: realloc "
- "bpos=%d wrsize=%d old_size=%d new_size=%d\n",
- p->bpos, size, p->size, new_size);
-#endif /* PRINTBUF_DEBUG */
- if(!(t = realloc(p->buf, new_size))) return -1;
- p->size = new_size;
- p->buf = t;
- }
- memcpy(p->buf + p->bpos, buf, size);
- p->bpos += size;
- p->buf[p->bpos]= '\0';
- return size;
-}
-
-#if !HAVE_VSNPRINTF && defined(WIN32)
-# define vsnprintf _vsnprintf
-#elif !HAVE_VSNPRINTF /* !HAVE_VSNPRINTF */
-# error Need vsnprintf!
-#endif /* !HAVE_VSNPRINTF && defined(WIN32) */
-
-#if !HAVE_VASPRINTF
-/* CAW: compliant version of vasprintf */
-static int vasprintf(char **buf, const char *fmt, va_list ap)
-{
-#ifndef WIN32
- static char _T_emptybuffer = '\0';
-#endif /* !defined(WIN32) */
- int chars;
- char *b;
-
- if(!buf) { return -1; }
-
-#ifdef WIN32
- chars = _vscprintf(fmt, ap)+1;
-#else /* !defined(WIN32) */
- /* CAW: RAWR! We have to hope to god here that vsnprintf doesn't overwrite
- our buffer like on some 64bit sun systems.... but hey, its time to move on */
- chars = vsnprintf(&_T_emptybuffer, 0, fmt, ap)+1;
- if(chars < 0) { chars *= -1; } /* CAW: old glibc versions have this problem */
-#endif /* defined(WIN32) */
-
- b = (char*)malloc(sizeof(char)*chars);
- if(!b) { return -1; }
-
- if((chars = vsprintf(b, fmt, ap)) < 0)
- {
- free(b);
- } else {
- *buf = b;
- }
-
- return chars;
-}
-#endif /* !HAVE_VASPRINTF */
-
-int sprintbuf(struct printbuf *p, const char *msg, ...)
-{
- va_list ap;
- char *t;
- int size;
- char buf[128];
-
- /* user stack buffer first */
- va_start(ap, msg);
- size = vsnprintf(buf, 128, msg, ap);
- va_end(ap);
- /* if string is greater than stack buffer, then use dynamic string
- with vasprintf. Note: some implementation of vsnprintf return -1
- if output is truncated whereas some return the number of bytes that
- would have been writen - this code handles both cases. */
- if(size == -1 || size > 127) {
- int ret;
- va_start(ap, msg);
- if((size = vasprintf(&t, msg, ap)) == -1) return -1;
- va_end(ap);
- ret = printbuf_memappend(p, t, size);
- free(t);
- return ret;
- } else {
- return printbuf_memappend(p, buf, size);
- }
-}
-
-void printbuf_reset(struct printbuf *p)
-{
- p->buf[0] = '\0';
- p->bpos = 0;
-}
-
-void printbuf_free(struct printbuf *p)
-{
- if(p) {
- free(p->buf);
- free(p);
- }
-}
diff --git a/source4/lib/json/printbuf.h b/source4/lib/json/printbuf.h
deleted file mode 100644
index bc1669bd19..0000000000
--- a/source4/lib/json/printbuf.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * $Id: printbuf.h,v 1.4 2006/01/26 02:16:28 mclark Exp $
- *
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- */
-
-#ifndef _printbuf_h_
-#define _printbuf_h_
-
-#undef PRINTBUF_DEBUG
-
-struct printbuf {
- char *buf;
- int bpos;
- int size;
-};
-
-extern struct printbuf*
-printbuf_new();
-
-extern int
-printbuf_memappend(struct printbuf *p, char *buf, int size);
-
-extern int
-sprintbuf(struct printbuf *p, const char *msg, ...);
-
-extern void
-printbuf_reset(struct printbuf *p);
-
-extern void
-printbuf_free(struct printbuf *p);
-
-#endif
diff --git a/source4/lib/json/stamp-h.in b/source4/lib/json/stamp-h.in
deleted file mode 100644
index 9788f70238..0000000000
--- a/source4/lib/json/stamp-h.in
+++ /dev/null
@@ -1 +0,0 @@
-timestamp
diff --git a/source4/lib/json/test1.c b/source4/lib/json/test1.c
deleted file mode 100644
index 8e49d100a3..0000000000
--- a/source4/lib/json/test1.c
+++ /dev/null
@@ -1,137 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "json.h"
-
-int main(int argc, char **argv)
-{
- struct json_object *my_string, *my_int, *my_object, *my_array;
- struct json_object *new_obj;
- int i;
-
- my_string = json_object_new_string("\t");
- printf("my_string=%s\n", json_object_get_string(my_string));
- printf("my_string.to_string()=%s\n", json_object_to_json_string(my_string));
- json_object_put(my_string);
-
- my_string = json_object_new_string("foo");
- printf("my_string=%s\n", json_object_get_string(my_string));
- printf("my_string.to_string()=%s\n", json_object_to_json_string(my_string));
-
- my_int = json_object_new_int(9);
- printf("my_int=%d\n", json_object_get_int(my_int));
- printf("my_int.to_string()=%s\n", json_object_to_json_string(my_int));
-
- my_array = json_object_new_array();
- json_object_array_add(my_array, json_object_new_int(1));
- json_object_array_add(my_array, json_object_new_int(2));
- json_object_array_add(my_array, json_object_new_int(3));
- json_object_array_put_idx(my_array, 4, json_object_new_int(5));
- printf("my_array=\n");
- for(i=0; i < json_object_array_length(my_array); i++) {
- struct json_object *obj = json_object_array_get_idx(my_array, i);
- printf("\t[%d]=%s\n", i, json_object_to_json_string(obj));
- }
- printf("my_array.to_string()=%s\n", json_object_to_json_string(my_array));
-
- my_object = json_object_new_object();
- json_object_object_add(my_object, "abc", json_object_new_int(12));
- json_object_object_add(my_object, "foo", json_object_new_string("bar"));
- json_object_object_add(my_object, "bool0", json_object_new_boolean(0));
- json_object_object_add(my_object, "bool1", json_object_new_boolean(1));
- json_object_object_add(my_object, "baz", json_object_new_string("bang"));
- json_object_object_add(my_object, "baz", json_object_new_string("fark"));
- json_object_object_del(my_object, "baz");
- json_object_object_add(my_object, "arr", my_array);
- printf("my_object=\n");
- json_object_object_foreach(my_object, key, val) {
- printf("\t%s: %s\n", key, json_object_to_json_string(val));
- }
- printf("my_object.to_string()=%s\n", json_object_to_json_string(my_object));
-
- new_obj = json_tokener_parse("\"\003\"");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("/* hello */\"foo\"");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("// hello\n\"foo\"");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("\"\\u0041\\u0042\\u0043\"");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("null");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("True");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("12");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("12.3");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("[\"\\n\"]");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("[\"\\nabc\\n\"]");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("[null]");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("[]");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("[\"abc\",null,\"def\",12]");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("{}");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("{ \"foo\": \"bar\" }");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("{ \"foo\": \"bar\", \"baz\": null, \"bool0\": true }");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("{ \"foo\": [null, \"foo\"] }");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("{ \"abc\": 12, \"foo\": \"bar\", \"bool0\": false, \"bool1\": true, \"arr\": [ 1, 2, 3, null, 5 ] }");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- new_obj = json_tokener_parse("{ foo }");
- if(is_error(new_obj)) printf("got error as expected\n");
-
- new_obj = json_tokener_parse("foo");
- if(is_error(new_obj)) printf("got error as expected\n");
-
- json_object_put(my_string);
- json_object_put(my_int);
- json_object_put(my_object);
- //json_object_put(my_array);
-
- return 0;
-}
diff --git a/source4/lib/json/test2.c b/source4/lib/json/test2.c
deleted file mode 100644
index b7bdf62888..0000000000
--- a/source4/lib/json/test2.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "json.h"
-
-
-int main(int argc, char **argv)
-{
- struct json_object *new_obj;
-
- mc_set_debug(1);
-
- new_obj = json_tokener_parse("/* more difficult test case */ { \"glossary\": { \"title\": \"example glossary\", \"GlossDiv\": { \"title\": \"S\", \"GlossList\": [ { \"ID\": \"SGML\", \"SortAs\": \"SGML\", \"GlossTerm\": \"Standard Generalized Markup Language\", \"Acronym\": \"SGML\", \"Abbrev\": \"ISO 8879:1986\", \"GlossDef\": \"A meta-markup language, used to create markup languages such as DocBook.\", \"GlossSeeAlso\": [\"GML\", \"XML\", \"markup\"] } ] } } }");
- printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
- json_object_put(new_obj);
-
- return 0;
-}
diff --git a/source4/lib/ldb/Makefile.in b/source4/lib/ldb/Makefile.in
index ecb6b6516b..8d95dae7ea 100644
--- a/source4/lib/ldb/Makefile.in
+++ b/source4/lib/ldb/Makefile.in
@@ -11,9 +11,11 @@ includedir = @includedir@
libdir = @libdir@
bindir = @bindir@
mandir = @mandir@
-VPATH = @srcdir@:@tdbdir@:@tallocdir@:@libreplacedir@:@poptdir@:@eventsdir@
+VPATH = @srcdir@:@libreplacedir@
srcdir = @srcdir@
builddir = @builddir@
+sharedbuilddir = @sharedbuilddir@
+INSTALLCMD = @INSTALL@
SLAPD = @SLAPD@
SWIG = swig
EXTRA_OBJ=@EXTRA_OBJ@
@@ -21,9 +23,7 @@ TESTS=test-tdb.sh @TESTS@
PACKAGE_VERSION = @PACKAGE_VERSION@
PYTHON = @PYTHON@
PYTHON_CONFIG = @PYTHON_CONFIG@
-tdbdir = @tdbdir@
ldbdir = $(srcdir)
-tallocdir = @tallocdir@
TALLOC_LIBS = @TALLOC_LIBS@
TALLOC_CFLAGS = @TALLOC_CFLAGS@
@@ -33,6 +33,7 @@ TDB_LIBS = @TDB_LIBS@
TDB_CFLAGS = @TDB_CFLAGS@
TDB_OBJ = @TDB_OBJ@
+EVENTS_LIBS = @EVENTS_LIBS@
EVENTS_CFLAGS = @EVENTS_CFLAGS@
EVENTS_OBJ = @EVENTS_OBJ@
@@ -65,7 +66,7 @@ OBJS = $(MODULES_OBJ) $(COMMON_OBJ) $(LDB_TDB_OBJ) $(TDB_OBJ) $(EVENTS_OBJ) $(TA
headers = $(srcdir)/include/ldb.h $(srcdir)/include/ldb_errors.h $(srcdir)/include/ldb_handlers.h
-BINS = bin/ldbadd bin/ldbsearch bin/ldbdel bin/ldbmodify bin/ldbedit bin/ldbrename bin/ldbtest bin/oLschema2ldif
+BINS = bin/ldbadd bin/ldbsearch bin/ldbdel bin/ldbmodify bin/ldbedit bin/ldbrename bin/ldbtest
EXAMPLES = examples/ldbreader examples/ldifreader
@@ -81,24 +82,37 @@ nssdir:
@mkdir -p $(NSSDIR)
SONAME = libldb.$(SHLIBEXT).0
-SOLIB = lib/libldb.$(SHLIBEXT).$(PACKAGE_VERSION)
+SOLIB = libldb.$(SHLIBEXT).$(PACKAGE_VERSION)
+LIBSOLIB = lib/$(SOLIB)
STATICLIB = lib/libldb.a
-lib/$(SONAME): $(SOLIB)
+lib/$(SONAME): $(LIBSOLIB)
ln -fs libldb.$(SHLIBEXT).$(PACKAGE_VERSION) $@
-lib/libldb.$(SHLIBEXT): $(SOLIB)
+lib/libldb.$(SHLIBEXT): $(LIBSOLIB)
ln -fs libldb.$(SHLIBEXT).$(PACKAGE_VERSION) $@
-lib/libnss_ldb.$(SHLIBEXT).2: $(NSS_OBJ) $(SOLIB)
- $(SHLD) $(SHLD_FLAGS) -o $@ $(NSS_OBJ) $(LDFLAGS) $(SOLIB) @SONAMEFLAG@libnss_ldb.$(SHLIBEXT).2
+lib/libnss_ldb.$(SHLIBEXT).2: $(NSS_OBJ) $(LIBSOLIB)
+ $(SHLD) $(SHLD_FLAGS) -o $@ $(NSS_OBJ) $(LDFLAGS) $(LIBSOLIB) @SONAMEFLAG@libnss_ldb.$(SHLIBEXT).2
-$(SOLIB): $(OBJS)
- $(SHLD) $(SHLD_FLAGS) -o $@ $(OBJS) $(LDFLAGS) $(LIBS) $(TALLOC_LIBS) $(TDB_LIBS) $(LIBDL) $(LDAP_LIBS) @SONAMEFLAG@$(SONAME)
+$(LIBSOLIB): $(OBJS)
+ $(SHLD) $(SHLD_FLAGS) -o $@ $(OBJS) $(LDFLAGS) $(LIBS) $(TALLOC_LIBS) $(TDB_LIBS) $(EVENTS_LIBS) $(LIBDL) $(LDAP_LIBS) @SONAMEFLAG@$(SONAME)
+ ln -sf libldb.$(SHLIBEXT).$(PACKAGE_VERSION) lib/libldb.$(SHLIBEXT)
-all: showflags dirs $(OBJS) $(STATICLIB) $(SOLIB) $(BINS) $(EXAMPLES) manpages \
+all: showflags dirs $(OBJS) $(STATICLIB) $(LIBSOLIB) $(BINS) $(EXAMPLES) manpages \
@PYTHON_BUILD_TARGET@
+shared-build: all
+ ${INSTALLCMD} -d $(sharedbuilddir)/lib
+ ${INSTALLCMD} -m 644 $(STATICLIB) $(sharedbuilddir)/lib
+ ${INSTALLCMD} -m 755 $(LIBSOLIB) $(sharedbuilddir)/lib
+ ln -sf $(SOLIB) $(sharedbuilddir)/lib/$(SONAME)
+ ln -sf $(SOLIB) $(sharedbuilddir)/lib/libldb.so
+ ${INSTALLCMD} -d $(sharedbuilddir)/include
+ ${INSTALLCMD} -m 644 $(srcdir)/include/ldb.h $(sharedbuilddir)/include
+ ${INSTALLCMD} -m 644 $(srcdir)/include/ldb_errors.h $(sharedbuilddir)/include
+ ${INSTALLCMD} -m 644 $(srcdir)/include/ldb_handlers.h $(sharedbuilddir)/include
+
dirs:
@mkdir -p $(DIRS)
@@ -110,7 +124,7 @@ doxygen::
clean::
rm -f *.o */*.o *.gcov */*.gc?? tdbtest.ldb*
- rm -f $(BINS) $(TDB_OBJ) $(TALLOC_OBJ) $(STATICLIB) $(NSS_LIB) $(SOLIB)
+ rm -f $(BINS) $(TDB_OBJ) $(TALLOC_OBJ) $(STATICLIB) $(NSS_LIB) $(LIBSOLIB)
rm -f $(POPT_OBJ)
rm -f man/*.1 man/*.3 man/*.html
rm -f $(EXAMPLES)
@@ -149,7 +163,7 @@ installheaders:: installdirs
cp $(headers) $(DESTDIR)$(includedir)
installlibs:: installdirs
- cp $(STATICLIB) $(SOLIB) $(DESTDIR)$(libdir)
+ cp $(STATICLIB) $(LIBSOLIB) $(DESTDIR)$(libdir)
cp ldb.pc $(DESTDIR)$(libdir)/pkgconfig
installbin:: installdirs
diff --git a/source4/lib/ldb/autogen.sh b/source4/lib/ldb/autogen.sh
index b81e5b094e..52fc8b63e2 100755
--- a/source4/lib/ldb/autogen.sh
+++ b/source4/lib/ldb/autogen.sh
@@ -3,14 +3,7 @@
rm -rf autom4te.cache
rm -f configure config.h.in
-IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace"
-IPATHS="$IPATHS -I lib/events -I events -I ../events"
-IPATHS="$IPATHS -I lib/talloc -I talloc -I ../talloc"
-IPATHS="$IPATHS -I lib/tdb -I tdb -I ../tdb"
-IPATHS="$IPATHS -I lib/popt -I popt -I ../popt"
-
-# Always keep this listed last, so the built-in versions of tdb and talloc
-# get used if available.
+IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace -I ../../../lib/replace"
IPATHS="$IPATHS -I ./external"
autoheader $IPATHS || exit 1
diff --git a/source4/lib/ldb/build_macros.m4 b/source4/lib/ldb/build_macros.m4
new file mode 100644
index 0000000000..c036668cd1
--- /dev/null
+++ b/source4/lib/ldb/build_macros.m4
@@ -0,0 +1,14 @@
+AC_DEFUN(BUILD_WITH_SHARED_BUILD_DIR,
+ [ AC_ARG_WITH([shared-build-dir],
+ [AC_HELP_STRING([--with-shared-build-dir=DIR],
+ [temporary build directory where libraries are installed [$srcdir/sharedbuild]])])
+
+ sharedbuilddir="$srcdir/sharedbuild"
+ if test x"$with_shared_build_dir" != x; then
+ sharedbuilddir=$with_shared_build_dir
+ CFLAGS="$CFLAGS -I$with_shared_build_dir/include"
+ LDFLAGS="$LDFLAGS -L$with_shared_build_dir/lib"
+ fi
+ AC_SUBST(sharedbuilddir)
+ ])
+
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 9e04cc7845..c013565da0 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -88,15 +88,14 @@ void ldb_set_default_dns(struct ldb_context *ldb)
};
tmp_ctx = talloc_new(ldb);
- ret = ldb_search(ldb, ldb_dn_new(tmp_ctx, ldb, NULL), LDB_SCOPE_BASE,
- "(objectClass=*)", attrs, &res);
+ ret = ldb_search(ldb, tmp_ctx, &res, ldb_dn_new(tmp_ctx, ldb, NULL),
+ LDB_SCOPE_BASE, attrs, "(objectClass=*)");
if (ret != LDB_SUCCESS) {
talloc_free(tmp_ctx);
return;
}
if (res->count != 1) {
- talloc_free(res);
talloc_free(tmp_ctx);
return;
}
@@ -125,7 +124,6 @@ void ldb_set_default_dns(struct ldb_context *ldb)
ldb_set_opaque(ldb, "defaultNamingContext", tmp_dn);
}
- talloc_free(res);
talloc_free(tmp_ctx);
}
@@ -195,9 +193,6 @@ int ldb_connect(struct ldb_context *ldb, const char *url,
return LDB_ERR_OTHER;
}
- /* TODO: get timeout from options if available there */
- ldb->default_timeout = 300; /* set default to 5 minutes */
-
/* set the default base dn */
ldb_set_default_dns(ldb);
@@ -398,24 +393,44 @@ static int ldb_autotransaction_request(struct ldb_context *ldb,
int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
{
- int ret;
+ struct event_context *ev;
+
if (!handle) {
- return LDB_SUCCESS;
+ return LDB_ERR_UNAVAILABLE;
}
- ret = handle->module->ops->wait(handle, type);
- if (!ldb_errstring(handle->module->ldb)) {
- /* Set a default error string, to place the blame somewhere */
- ldb_asprintf_errstring(handle->module->ldb,
- "error waiting on module %s: %s (%d)",
- handle->module->ops->name,
- ldb_strerror(ret), ret);
+ if (handle->state == LDB_ASYNC_DONE) {
+ return handle->status;
}
- return ret;
+
+ ev = ldb_get_event_context(handle->ldb);
+ if (NULL == ev) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ switch (type) {
+ case LDB_WAIT_NONE:
+ event_loop_once(ev);
+ if (handle->state == LDB_ASYNC_DONE ||
+ handle->status != LDB_SUCCESS) {
+ return handle->status;
+ }
+ break;
+
+ case LDB_WAIT_ALL:
+ while (handle->state != LDB_ASYNC_DONE) {
+ event_loop_once(ev);
+ if (handle->status != LDB_SUCCESS) {
+ return handle->status;
+ }
+ }
+ return handle->status;
+ }
+
+ return LDB_SUCCESS;
}
/* set the specified timeout or, if timeout is 0 set the default timeout */
-/* timeout == -1 means no timeout */
int ldb_set_timeout(struct ldb_context *ldb,
struct ldb_request *req,
int timeout)
@@ -437,20 +452,14 @@ int ldb_set_timeout_from_prev_req(struct ldb_context *ldb,
struct ldb_request *oldreq,
struct ldb_request *newreq)
{
- time_t now;
-
if (newreq == NULL) return LDB_ERR_OPERATIONS_ERROR;
- now = time(NULL);
-
- if (oldreq == NULL)
+ if (oldreq == NULL) {
return ldb_set_timeout(ldb, newreq, 0);
-
- if ((now - oldreq->starttime) > oldreq->timeout) {
- return LDB_ERR_TIME_LIMIT_EXCEEDED;
}
+
newreq->starttime = oldreq->starttime;
- newreq->timeout = oldreq->timeout - (now - oldreq->starttime);
+ newreq->timeout = oldreq->timeout;
return LDB_SUCCESS;
}
@@ -485,6 +494,11 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *req)
struct ldb_module *module;
int ret;
+ if (req->callback == NULL) {
+ ldb_set_errstring(ldb, "Requests MUST define callbacks");
+ return LDB_ERR_UNWILLING_TO_PERFORM;
+ }
+
ldb_reset_err_string(ldb);
/* call the first module in the chain */
@@ -513,10 +527,6 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *req)
FIRST_OP(ldb, extended);
ret = module->ops->extended(module, req);
break;
- case LDB_SEQUENCE_NUMBER:
- FIRST_OP(ldb, sequence_number);
- ret = module->ops->sequence_number(module, req);
- break;
default:
FIRST_OP(ldb, request);
ret = module->ops->request(module, req);
@@ -526,6 +536,13 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *req)
return ret;
}
+int ldb_request_done(struct ldb_request *req, int status)
+{
+ req->handle->state = LDB_ASYNC_DONE;
+ req->handle->status = status;
+ return status;
+}
+
/*
search the database given a LDAP-like search expression
@@ -534,32 +551,27 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *req)
Use talloc_free to free the ldb_message returned in 'res', if successful
*/
-int ldb_search_default_callback(struct ldb_context *ldb,
- void *context,
+int ldb_search_default_callback(struct ldb_request *req,
struct ldb_reply *ares)
{
struct ldb_result *res;
int n;
- if (!context) {
- ldb_set_errstring(ldb, "NULL Context in callback");
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- res = talloc_get_type(context, struct ldb_result);
+ res = talloc_get_type(req->context, struct ldb_result);
- if (!res || !ares) {
- ldb_set_errstring(ldb, "NULL res or ares in callback");
- goto error;
+ if (!ares) {
+ return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR);
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_request_done(req, ares->error);
}
switch (ares->type) {
case LDB_REPLY_ENTRY:
res->msgs = talloc_realloc(res, res->msgs,
- struct ldb_message *,
- res->count + 2);
+ struct ldb_message *, res->count + 2);
if (! res->msgs) {
- goto error;
+ return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR);
}
res->msgs[res->count + 1] = NULL;
@@ -567,6 +579,7 @@ int ldb_search_default_callback(struct ldb_context *ldb,
res->msgs[res->count] = talloc_move(res->msgs, &ares->message);
res->count++;
break;
+
case LDB_REPLY_REFERRAL:
if (res->refs) {
for (n = 0; res->refs[n]; n++) /*noop*/ ;
@@ -576,37 +589,63 @@ int ldb_search_default_callback(struct ldb_context *ldb,
res->refs = talloc_realloc(res, res->refs, char *, n + 2);
if (! res->refs) {
- goto error;
+ return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR);
}
res->refs[n] = talloc_move(res->refs, &ares->referral);
res->refs[n + 1] = NULL;
break;
- case LDB_REPLY_EXTENDED:
+
case LDB_REPLY_DONE:
/* TODO: we should really support controls on entries
* and referrals too! */
res->controls = talloc_move(res, &ares->controls);
- break;
+
+ /* this is the last message, and means the request is done */
+ /* we have to signal and eventual ldb_wait() waiting that the
+ * async request operation was completed */
+ return ldb_request_done(req, LDB_SUCCESS);
}
+
talloc_free(ares);
return LDB_SUCCESS;
+}
+
+int ldb_op_default_callback(struct ldb_request *req, struct ldb_reply *ares)
+{
+ int ret;
+
+ if (!ares) {
+ return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR);
+ }
+
+ if (ares->error != LDB_SUCCESS) {
+ ret = ares->error;
+ talloc_free(ares);
+ return ldb_request_done(req, ret);
+ }
+
+ if (ares->type != LDB_REPLY_DONE) {
+ talloc_free(ares);
+ ldb_set_errstring(req->handle->ldb, "Invalid reply type!");
+ return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR);
+ }
-error:
talloc_free(ares);
- return LDB_ERR_OPERATIONS_ERROR;
+ return ldb_request_done(req, LDB_SUCCESS);
}
-int ldb_build_search_req(struct ldb_request **ret_req,
+int ldb_build_search_req_ex(struct ldb_request **ret_req,
struct ldb_context *ldb,
void *mem_ctx,
struct ldb_dn *base,
enum ldb_scope scope,
- const char *expression,
+ struct ldb_parse_tree *tree,
const char * const *attrs,
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback)
+ ldb_request_callback_t callback,
+ struct ldb_request *parent)
{
struct ldb_request *req;
@@ -614,7 +653,7 @@ int ldb_build_search_req(struct ldb_request **ret_req,
req = talloc(mem_ctx, struct ldb_request);
if (req == NULL) {
- ldb_set_errstring(ldb, "Out of Memory");
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -626,9 +665,9 @@ int ldb_build_search_req(struct ldb_request **ret_req,
}
req->op.search.scope = scope;
- req->op.search.tree = ldb_parse_tree(req, expression);
+ req->op.search.tree = tree;
if (req->op.search.tree == NULL) {
- ldb_set_errstring(ldb, "Unable to parse search expression");
+ ldb_set_errstring(ldb, "'tree' can't be NULL");
talloc_free(req);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -638,17 +677,56 @@ int ldb_build_search_req(struct ldb_request **ret_req,
req->context = context;
req->callback = callback;
+ ldb_set_timeout_from_prev_req(ldb, parent, req);
+
+ req->handle = ldb_handle_new(req, ldb);
+ if (req->handle == NULL) {
+ ldb_oom(ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
*ret_req = req;
return LDB_SUCCESS;
}
+int ldb_build_search_req(struct ldb_request **ret_req,
+ struct ldb_context *ldb,
+ void *mem_ctx,
+ struct ldb_dn *base,
+ enum ldb_scope scope,
+ const char *expression,
+ const char * const *attrs,
+ struct ldb_control **controls,
+ void *context,
+ ldb_request_callback_t callback,
+ struct ldb_request *parent)
+{
+ struct ldb_parse_tree *tree;
+ int ret;
+
+ tree = ldb_parse_tree(mem_ctx, expression);
+ if (tree == NULL) {
+ ldb_set_errstring(ldb, "Unable to parse search expression");
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ ret = ldb_build_search_req_ex(ret_req, ldb, mem_ctx, base,
+ scope, tree, attrs, controls,
+ context, callback, parent);
+ if (ret == LDB_SUCCESS) {
+ talloc_steal(*ret_req, tree);
+ }
+ return ret;
+}
+
int ldb_build_add_req(struct ldb_request **ret_req,
struct ldb_context *ldb,
void *mem_ctx,
const struct ldb_message *message,
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback)
+ ldb_request_callback_t callback,
+ struct ldb_request *parent)
{
struct ldb_request *req;
@@ -666,6 +744,14 @@ int ldb_build_add_req(struct ldb_request **ret_req,
req->context = context;
req->callback = callback;
+ ldb_set_timeout_from_prev_req(ldb, parent, req);
+
+ req->handle = ldb_handle_new(req, ldb);
+ if (req->handle == NULL) {
+ ldb_oom(ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
*ret_req = req;
return LDB_SUCCESS;
@@ -677,7 +763,8 @@ int ldb_build_mod_req(struct ldb_request **ret_req,
const struct ldb_message *message,
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback)
+ ldb_request_callback_t callback,
+ struct ldb_request *parent)
{
struct ldb_request *req;
@@ -695,6 +782,14 @@ int ldb_build_mod_req(struct ldb_request **ret_req,
req->context = context;
req->callback = callback;
+ ldb_set_timeout_from_prev_req(ldb, parent, req);
+
+ req->handle = ldb_handle_new(req, ldb);
+ if (req->handle == NULL) {
+ ldb_oom(ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
*ret_req = req;
return LDB_SUCCESS;
@@ -706,7 +801,8 @@ int ldb_build_del_req(struct ldb_request **ret_req,
struct ldb_dn *dn,
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback)
+ ldb_request_callback_t callback,
+ struct ldb_request *parent)
{
struct ldb_request *req;
@@ -724,6 +820,14 @@ int ldb_build_del_req(struct ldb_request **ret_req,
req->context = context;
req->callback = callback;
+ ldb_set_timeout_from_prev_req(ldb, parent, req);
+
+ req->handle = ldb_handle_new(req, ldb);
+ if (req->handle == NULL) {
+ ldb_oom(ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
*ret_req = req;
return LDB_SUCCESS;
@@ -736,7 +840,8 @@ int ldb_build_rename_req(struct ldb_request **ret_req,
struct ldb_dn *newdn,
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback)
+ ldb_request_callback_t callback,
+ struct ldb_request *parent)
{
struct ldb_request *req;
@@ -755,47 +860,46 @@ int ldb_build_rename_req(struct ldb_request **ret_req,
req->context = context;
req->callback = callback;
+ ldb_set_timeout_from_prev_req(ldb, parent, req);
+
+ req->handle = ldb_handle_new(req, ldb);
+ if (req->handle == NULL) {
+ ldb_oom(ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
*ret_req = req;
return LDB_SUCCESS;
}
-int ldb_extended_default_callback(struct ldb_context *ldb,
- void *context,
+int ldb_extended_default_callback(struct ldb_request *req,
struct ldb_reply *ares)
{
struct ldb_result *res;
- if (!context) {
- ldb_set_errstring(ldb, "NULL Context in callback");
- return LDB_ERR_OPERATIONS_ERROR;
- }
+ res = talloc_get_type(req->context, struct ldb_result);
- res = talloc_get_type(context, struct ldb_result);
- if (!res || !ares) {
- ldb_set_errstring(ldb, "NULL res or ares in callback");
- goto error;
+ if (!ares) {
+ return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR);
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_request_done(req, ares->error);
}
- switch (ares->type) {
- case LDB_REPLY_ENTRY:
- case LDB_REPLY_REFERRAL:
- case LDB_REPLY_DONE:
- ldb_set_errstring(ldb, "invalid ares type in callback");
- goto error;
- case LDB_REPLY_EXTENDED:
- /* TODO: we should really support controls on entries and
- * referrals too! */
+ if (ares->type == LDB_REPLY_DONE) {
+
+ /* TODO: we should really support controls on entries and referrals too! */
res->extended = talloc_move(res, &ares->response);
res->controls = talloc_move(res, &ares->controls);
- break;
+
+ talloc_free(ares);
+ return ldb_request_done(req, LDB_SUCCESS);
}
- talloc_free(ares);
- return LDB_SUCCESS;
-error:
talloc_free(ares);
- return LDB_ERR_OPERATIONS_ERROR;
+ ldb_set_errstring(req->handle->ldb, "Invalid reply type!");
+ return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR);
}
int ldb_build_extended_req(struct ldb_request **ret_req,
@@ -805,7 +909,8 @@ int ldb_build_extended_req(struct ldb_request **ret_req,
void *data,
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback)
+ ldb_request_callback_t callback,
+ struct ldb_request *parent)
{
struct ldb_request *req;
@@ -824,6 +929,14 @@ int ldb_build_extended_req(struct ldb_request **ret_req,
req->context = context;
req->callback = callback;
+ ldb_set_timeout_from_prev_req(ldb, parent, req);
+
+ req->handle = ldb_handle_new(req, ldb);
+ if (req->handle == NULL) {
+ ldb_oom(ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
*ret_req = req;
return LDB_SUCCESS;
@@ -847,7 +960,8 @@ int ldb_extended(struct ldb_context *ldb,
ret = ldb_build_extended_req(&req, ldb, ldb,
oid, data, NULL,
- res, ldb_extended_default_callback);
+ res, ldb_extended_default_callback,
+ NULL);
if (ret != LDB_SUCCESS) goto done;
ldb_set_timeout(ldb, req, 0); /* use default timeout */
@@ -873,95 +987,71 @@ done:
note that ldb_search() will automatically replace a NULL 'base' value
with the defaultNamingContext from the rootDSE if available.
*/
-int ldb_search(struct ldb_context *ldb,
- struct ldb_dn *base,
- enum ldb_scope scope,
- const char *expression,
- const char * const *attrs,
- struct ldb_result **_res)
+int ldb_search(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
+ struct ldb_result **result, struct ldb_dn *base,
+ enum ldb_scope scope, const char * const *attrs,
+ const char *exp_fmt, ...)
{
struct ldb_request *req;
- int ret;
struct ldb_result *res;
+ char *expression;
+ va_list ap;
+ int ret;
- *_res = NULL;
+ expression = NULL;
+ *result = NULL;
+ req = NULL;
- res = talloc_zero(ldb, struct ldb_result);
+ res = talloc_zero(mem_ctx, struct ldb_result);
if (!res) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_build_search_req(&req, ldb, ldb,
+ if (exp_fmt) {
+ va_start(ap, exp_fmt);
+ expression = talloc_vasprintf(mem_ctx, exp_fmt, ap);
+ va_end(ap);
+
+ if (!expression) {
+ talloc_free(res);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ }
+
+ ret = ldb_build_search_req(&req, ldb, mem_ctx,
base?base:ldb_get_default_basedn(ldb),
scope,
expression,
attrs,
NULL,
res,
- ldb_search_default_callback);
+ ldb_search_default_callback,
+ NULL);
if (ret != LDB_SUCCESS) goto done;
- ldb_set_timeout(ldb, req, 0); /* use default timeout */
-
ret = ldb_request(ldb, req);
if (ret == LDB_SUCCESS) {
ret = ldb_wait(req->handle, LDB_WAIT_ALL);
}
- talloc_free(req);
-
done:
if (ret != LDB_SUCCESS) {
talloc_free(res);
- }
-
- *_res = res;
- return ret;
-}
-
-/*
- a useful search function where you can easily define the expression and that
- takes a memory context where results are allocated
-*/
-
-int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
- struct ldb_result **result, struct ldb_dn *base,
- enum ldb_scope scope, const char * const *attrs,
- const char *exp_fmt, ...)
-{
- struct ldb_result *res;
- char *expression;
- va_list ap;
- int ret;
-
- res = NULL;
- *result = NULL;
-
- va_start(ap, exp_fmt);
- expression = talloc_vasprintf(mem_ctx, exp_fmt, ap);
- va_end(ap);
-
- if ( ! expression) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- ret = ldb_search(ldb, base, scope, expression, attrs, &res);
-
- if (ret == LDB_SUCCESS) {
- talloc_steal(mem_ctx, res);
- *result = res;
+ res = NULL;
}
talloc_free(expression);
+ talloc_free(req);
+ *result = res;
return ret;
}
/*
- add a record to the database. Will fail if a record with the
- given class and key already exists
+ add a record to the database. Will fail if a record with the given class
+ and key already exists
*/
int ldb_add(struct ldb_context *ldb,
const struct ldb_message *message)
@@ -978,12 +1068,11 @@ int ldb_add(struct ldb_context *ldb,
message,
NULL,
NULL,
+ ldb_op_default_callback,
NULL);
if (ret != LDB_SUCCESS) return ret;
- ldb_set_timeout(ldb, req, 0); /* use default timeout */
-
/* do request and autostart a transaction */
ret = ldb_autotransaction_request(ldb, req);
@@ -1009,12 +1098,11 @@ int ldb_modify(struct ldb_context *ldb,
message,
NULL,
NULL,
+ ldb_op_default_callback,
NULL);
if (ret != LDB_SUCCESS) return ret;
- ldb_set_timeout(ldb, req, 0); /* use default timeout */
-
/* do request and autostart a transaction */
ret = ldb_autotransaction_request(ldb, req);
@@ -1035,12 +1123,11 @@ int ldb_delete(struct ldb_context *ldb, struct ldb_dn *dn)
dn,
NULL,
NULL,
+ ldb_op_default_callback,
NULL);
if (ret != LDB_SUCCESS) return ret;
- ldb_set_timeout(ldb, req, 0); /* use default timeout */
-
/* do request and autostart a transaction */
ret = ldb_autotransaction_request(ldb, req);
@@ -1062,12 +1149,11 @@ int ldb_rename(struct ldb_context *ldb,
newdn,
NULL,
NULL,
+ ldb_op_default_callback,
NULL);
if (ret != LDB_SUCCESS) return ret;
- ldb_set_timeout(ldb, req, 0); /* use default timeout */
-
/* do request and autostart a transaction */
ret = ldb_autotransaction_request(ldb, req);
@@ -1080,38 +1166,49 @@ int ldb_rename(struct ldb_context *ldb,
return the global sequence number
*/
int ldb_sequence_number(struct ldb_context *ldb,
- enum ldb_sequence_type type,
- uint64_t *seq_num)
+ enum ldb_sequence_type type, uint64_t *seq_num)
{
- struct ldb_request *req;
+ struct ldb_seqnum_request *seq;
+ struct ldb_seqnum_result *seqr;
+ struct ldb_result *res;
+ TALLOC_CTX *tmp_ctx;
int ret;
- req = talloc(ldb, struct ldb_request);
- if (req == NULL) {
+ *seq_num = 0;
+
+ tmp_ctx = talloc_zero(ldb, struct ldb_request);
+ if (tmp_ctx == NULL) {
ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
+ seq = talloc_zero(tmp_ctx, struct ldb_seqnum_request);
+ if (seq == NULL) {
+ ldb_set_errstring(ldb, "Out of Memory");
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ goto done;
+ }
+ seq->type = type;
- req->operation = LDB_SEQUENCE_NUMBER;
- req->controls = NULL;
- req->context = NULL;
- req->callback = NULL;
- ldb_set_timeout(ldb, req, 0); /* use default timeout */
-
- req->op.seq_num.type = type;
- /* do request and autostart a transaction */
- ret = ldb_request(ldb, req);
+ ret = ldb_extended(ldb, LDB_EXTENDED_SEQUENCE_NUMBER, seq, &res);
+ if (ret != LDB_SUCCESS) {
+ goto done;
+ }
+ talloc_steal(tmp_ctx, res);
- if (ret == LDB_SUCCESS) {
- *seq_num = req->op.seq_num.seq_num;
+ if (strcmp(LDB_EXTENDED_SEQUENCE_NUMBER, res->extended->oid) != 0) {
+ ldb_set_errstring(ldb, "Invalid OID in reply");
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ goto done;
}
+ seqr = talloc_get_type(res->extended->data,
+ struct ldb_seqnum_result);
+ *seq_num = seqr->seq_num;
- talloc_free(req);
+done:
+ talloc_free(tmp_ctx);
return ret;
}
-
-
/*
return extended error information
*/
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index c0d36cfbf3..e36aea4e69 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -91,7 +91,7 @@ struct ldb_dn *ldb_dn_from_ldb_val(void *mem_ctx, struct ldb_context *ldb, const
* exploded_dn control is used */
dn->special = true;
/* FIXME: add a GUID string to ldb_dn structure */
- } else if (strdn->length >= 8 && strncasecmp((const char *)strdn->data, "<SID=", 8) == 0) {
+ } else if (strdn->length >= 5 && strncasecmp((const char *)strdn->data, "<SID=", 5) == 0) {
/* this is special DN returned when the
* exploded_dn control is used */
dn->special = true;
@@ -150,7 +150,7 @@ struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char
* exploded_dn control is used */
dn->special = true;
/* FIXME: add a GUID string to ldb_dn structure */
- } else if (strncasecmp(strdn, "<SID=", 8) == 0) {
+ } else if (strncasecmp(strdn, "<SID=", 5) == 0) {
/* this is special DN returned when the
* exploded_dn control is used */
dn->special = true;
diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c
index 4d69dc662e..2b453bb0c3 100644
--- a/source4/lib/ldb/common/ldb_modules.c
+++ b/source4/lib/ldb/common/ldb_modules.c
@@ -1,7 +1,7 @@
/*
ldb database library
- Copyright (C) Simo Sorce 2004
+ Copyright (C) Simo Sorce 2004-2008
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
@@ -419,7 +419,7 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
return -1;
}
- ret = ldb_search_exp_fmt(ldb, mods_dn, &res, mods_dn, LDB_SCOPE_BASE, attrs, "@LIST=*");
+ ret = ldb_search(ldb, mods_dn, &res, mods_dn, LDB_SCOPE_BASE, attrs, "@LIST=*");
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
ldb_debug(ldb, LDB_DEBUG_TRACE, "no modules required by the db");
@@ -486,6 +486,12 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
int ldb_next_request(struct ldb_module *module, struct ldb_request *request)
{
int ret;
+
+ if (request->callback == NULL) {
+ ldb_set_errstring(module->ldb, "Requests MUST define callbacks");
+ return LDB_ERR_UNWILLING_TO_PERFORM;
+ }
+
switch (request->operation) {
case LDB_SEARCH:
FIND_OP(module, search);
@@ -511,10 +517,6 @@ int ldb_next_request(struct ldb_module *module, struct ldb_request *request)
FIND_OP(module, extended);
ret = module->ops->extended(module, request);
break;
- case LDB_SEQUENCE_NUMBER:
- FIND_OP(module, sequence_number);
- ret = module->ops->sequence_number(module, request);
- break;
default:
FIND_OP(module, request);
ret = module->ops->request(module, request);
@@ -555,6 +557,139 @@ int ldb_next_del_trans(struct ldb_module *module)
return module->ops->del_transaction(module);
}
+struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb)
+{
+ struct ldb_handle *h;
+
+ h = talloc_zero(mem_ctx, struct ldb_handle);
+ if (h == NULL) {
+ ldb_set_errstring(ldb, "Out of Memory");
+ return NULL;
+ }
+
+ h->status = LDB_SUCCESS;
+ h->state = LDB_ASYNC_INIT;
+ h->ldb = ldb;
+
+ return h;
+}
+
+/* calls the request callback to send an entry
+ *
+ * params:
+ * req: the original request passed to your module
+ * msg: reply message (must be a talloc pointer, and it will be stolen
+ * on the ldb_reply that is sent to the callback)
+ */
+
+int ldb_module_send_entry(struct ldb_request *req,
+ struct ldb_message *msg)
+{
+ struct ldb_reply *ares;
+
+ ares = talloc_zero(req, struct ldb_reply);
+ if (!ares) {
+ ldb_oom(req->handle->ldb);
+ req->callback(req, NULL);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ ares->type = LDB_REPLY_ENTRY;
+ ares->message = talloc_steal(ares, msg);
+ ares->error = LDB_SUCCESS;
+
+ return req->callback(req, ares);
+}
+
+/* calls the request callback to send an referrals
+ *
+ * params:
+ * req: the original request passed to your module
+ * ref: referral string (must be a talloc pointeri, steal)
+ */
+
+int ldb_module_send_referral(struct ldb_request *req,
+ char *ref)
+{
+ struct ldb_reply *ares;
+
+ ares = talloc_zero(req, struct ldb_reply);
+ if (!ares) {
+ ldb_oom(req->handle->ldb);
+ req->callback(req, NULL);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ ares->type = LDB_REPLY_REFERRAL;
+ ares->referral = talloc_steal(ares, ref);
+ ares->error = LDB_SUCCESS;
+
+ return req->callback(req, ares);
+}
+
+/* calls the original request callback
+ *
+ * params:
+ * req: the original request passed to your module
+ * ctrls: controls to send in the reply (must be a talloc pointer, steal)
+ * response: results for extended request (steal)
+ * error: LDB_SUCCESS for a succesful return
+ * any other ldb error otherwise
+ */
+int ldb_module_done(struct ldb_request *req,
+ struct ldb_control **ctrls,
+ struct ldb_extended *response,
+ int error)
+{
+ struct ldb_reply *ares;
+
+ ares = talloc_zero(req, struct ldb_reply);
+ if (!ares) {
+ ldb_oom(req->handle->ldb);
+ req->callback(req, NULL);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ ares->type = LDB_REPLY_DONE;
+ ares->controls = talloc_steal(ares, ctrls);
+ ares->response = talloc_steal(ares, response);
+ ares->error = error;
+
+ req->callback(req, ares);
+ return error;
+}
+
+/* to be used *only* in modules init functions.
+ * this function i synchronous and will register
+ * the requested OID in the rootdse module if present
+ * otherwise it will return an error */
+int ldb_mod_register_control(struct ldb_module *module, const char *oid)
+{
+ struct ldb_request *req;
+ int ret;
+
+ req = talloc_zero(module, struct ldb_request);
+ if (req == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ req->operation = LDB_REQ_REGISTER_CONTROL;
+ req->op.reg_control.oid = oid;
+ req->callback = ldb_op_default_callback;
+
+ ldb_set_timeout(module->ldb, req, 0);
+
+ req->handle = ldb_handle_new(req, module->ldb);
+ if (req->handle == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ ret = ldb_request(module->ldb, req);
+ if (ret == LDB_SUCCESS) {
+ ret = ldb_wait(req->handle, LDB_WAIT_ALL);
+ }
+ talloc_free(req);
+
+ return ret;
+}
+
#ifndef STATIC_LIBLDB_MODULES
#ifdef HAVE_LDB_LDAP
diff --git a/source4/lib/ldb/configure.ac b/source4/lib/ldb/configure.ac
index 4a703e8139..095caa5e92 100644
--- a/source4/lib/ldb/configure.ac
+++ b/source4/lib/ldb/configure.ac
@@ -43,6 +43,10 @@ AC_SUBST(LDB_MODULESDIR)
TESTS=""
EXTRA_OBJ=""
+m4_include(build_macros.m4)
+BUILD_WITH_SHARED_BUILD_DIR
+
+m4_include(pkg.m4)
m4_include(libpopt.m4)
m4_include(libtalloc.m4)
m4_include(libtdb.m4)
diff --git a/source4/lib/ldb/examples/ldbreader.c b/source4/lib/ldb/examples/ldbreader.c
index 6e58114531..e48b3d338a 100644
--- a/source4/lib/ldb/examples/ldbreader.c
+++ b/source4/lib/ldb/examples/ldbreader.c
@@ -88,8 +88,9 @@ int main(int argc, const char **argv)
quite fine grained results with the LDAP search syntax, however it is a bit
confusing to start with. See RFC2254.
*/
- if (LDB_SUCCESS != ldb_search(ldb, NULL, LDB_SCOPE_DEFAULT,
- expression, NULL, &resultMsg) ) {
+ if (LDB_SUCCESS != ldb_search(ldb, ldb, &resultMsg,
+ NULL, LDB_SCOPE_DEFAULT, NULL,
+ "%s", expression)) {
printf("Problem in search\n");
exit(-1);
}
diff --git a/source4/lib/ldb/external/libevents.m4 b/source4/lib/ldb/external/libevents.m4
index f0f80e9d8e..4fd2e71ec2 100644
--- a/source4/lib/ldb/external/libevents.m4
+++ b/source4/lib/ldb/external/libevents.m4
@@ -1,4 +1,7 @@
-m4_include(pkg.m4)
-EVENTS_OBJ=""
AC_SUBST(EVENTS_OBJ)
-PKG_CHECK_MODULES(EVENTS, events)
+AC_SUBST(EVENTS_CFLAGS)
+AC_SUBST(EVENTS_LIBS)
+
+AC_CHECK_HEADER(events.h,
+ [AC_CHECK_LIB(events, event_context_init, [EVENTS_LIBS="-levents"]) ],
+ [PKG_CHECK_MODULES(EVENTS, events)])
diff --git a/source4/lib/ldb/external/libtalloc.m4 b/source4/lib/ldb/external/libtalloc.m4
index d08bd42065..a4c5b8a9d9 100644
--- a/source4/lib/ldb/external/libtalloc.m4
+++ b/source4/lib/ldb/external/libtalloc.m4
@@ -1,4 +1,7 @@
-m4_include(pkg.m4)
-TALLOC_OBJ=""
AC_SUBST(TALLOC_OBJ)
-PKG_CHECK_MODULES(TALLOC, talloc)
+AC_SUBST(TALLOC_CFLAGS)
+AC_SUBST(TALLOC_LIBS)
+
+AC_CHECK_HEADER(talloc.h,
+ [AC_CHECK_LIB(talloc, talloc_init, [TALLOC_LIBS="-ltalloc"]) ],
+ [PKG_CHECK_MODULES(TALLOC, talloc)])
diff --git a/source4/lib/ldb/external/libtdb.m4 b/source4/lib/ldb/external/libtdb.m4
index 4c1f4b530e..8c2cab702f 100644
--- a/source4/lib/ldb/external/libtdb.m4
+++ b/source4/lib/ldb/external/libtdb.m4
@@ -1,4 +1,7 @@
-m4_include(pkg.m4)
-TDB_OBJ=""
AC_SUBST(TDB_OBJ)
-PKG_CHECK_MODULES(TDB, tdb >= 1.1.0)
+AC_SUBST(TDB_CFLAGS)
+AC_SUBST(TDB_LIBS)
+
+AC_CHECK_HEADER(tdb.h,
+ [AC_CHECK_LIB(tdb, tdb_open, [TDB_LIBS="-ltdb"]) ],
+ [PKG_CHECK_MODULES(TDB, tdb >= 1.1.0)])
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index 937029f52c..9bc5c183d8 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -181,6 +181,7 @@ enum ldb_scope {LDB_SCOPE_DEFAULT=-1,
LDB_SCOPE_SUBTREE=2};
struct ldb_context;
+struct event_context;
/* debugging uses one of the following levels */
enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR,
@@ -651,7 +652,6 @@ enum ldb_request_type {
LDB_DELETE,
LDB_RENAME,
LDB_EXTENDED,
- LDB_SEQUENCE_NUMBER,
LDB_REQ_REGISTER_CONTROL,
LDB_REQ_REGISTER_PARTITION
};
@@ -659,7 +659,6 @@ enum ldb_request_type {
enum ldb_reply_type {
LDB_REPLY_ENTRY,
LDB_REPLY_REFERRAL,
- LDB_REPLY_EXTENDED,
LDB_REPLY_DONE
};
@@ -679,28 +678,42 @@ struct ldb_extended {
void *data; /* NULL or a valid talloc pointer! talloc_get_type() will be used on it */
};
+#define LDB_EXTENDED_SEQUENCE_NUMBER "1.3.6.1.4.1.7165.4.4.3"
+
+enum ldb_sequence_type {
+ LDB_SEQ_HIGHEST_SEQ,
+ LDB_SEQ_HIGHEST_TIMESTAMP,
+ LDB_SEQ_NEXT
+};
+
+struct ldb_seqnum_request {
+ enum ldb_sequence_type type;
+};
+
+struct ldb_seqnum_result {
+ uint64_t seq_num;
+ uint32_t flags;
+};
+
struct ldb_result {
unsigned int count;
struct ldb_message **msgs;
- char **refs;
struct ldb_extended *extended;
struct ldb_control **controls;
+ char **refs;
};
struct ldb_reply {
+ int error;
enum ldb_reply_type type;
struct ldb_message *message;
struct ldb_extended *response;
- char *referral;
struct ldb_control **controls;
+ char *referral;
};
-struct ldb_handle {
- int status;
- enum ldb_state state;
- void *private_data;
- struct ldb_module *module;
-};
+struct ldb_request;
+struct ldb_handle;
struct ldb_search {
struct ldb_dn *base;
@@ -735,19 +748,8 @@ struct ldb_register_partition {
struct ldb_dn *dn;
};
-enum ldb_sequence_type {
- LDB_SEQ_HIGHEST_SEQ,
- LDB_SEQ_HIGHEST_TIMESTAMP,
- LDB_SEQ_NEXT
-};
+typedef int (*ldb_request_callback_t)(struct ldb_request *, struct ldb_reply *);
-struct ldb_sequence_number {
- enum ldb_sequence_type type;
- uint64_t seq_num;
- uint32_t flags;
-};
-
-typedef int (*ldb_request_callback_t)(struct ldb_context *, void *, struct ldb_reply *);
struct ldb_request {
enum ldb_request_type operation;
@@ -759,7 +761,6 @@ struct ldb_request {
struct ldb_delete del;
struct ldb_rename rename;
struct ldb_extended extended;
- struct ldb_sequence_number seq_num;
struct ldb_register_control reg_control;
struct ldb_register_partition reg_partition;
} op;
@@ -775,7 +776,10 @@ struct ldb_request {
};
int ldb_request(struct ldb_context *ldb, struct ldb_request *request);
+int ldb_request_done(struct ldb_request *req, int status);
+bool ldb_request_is_done(struct ldb_request *req);
+int ldb_modules_wait(struct ldb_handle *handle);
int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type);
int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeout);
@@ -831,6 +835,19 @@ struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx);
(that is, with LDB_FLG_RDONLY). However in read-write mode, the database will be
created if it does not exist.
*/
+
+typedef void (*ldb_async_timeout_fn) (void *);
+typedef bool (*ldb_async_callback_fn) (void *);
+typedef int (*ldb_async_ctx_add_op_fn)(void *, time_t, void *, ldb_async_timeout_fn, ldb_async_callback_fn);
+typedef int (*ldb_async_ctx_wait_op_fn)(void *);
+
+void ldb_async_ctx_set_private_data(struct ldb_context *ldb,
+ void *private_data);
+void ldb_async_ctx_set_add_op(struct ldb_context *ldb,
+ ldb_async_ctx_add_op_fn add_op);
+void ldb_async_ctx_set_wait_op(struct ldb_context *ldb,
+ ldb_async_ctx_wait_op_fn wait_op);
+
int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]);
/*
@@ -860,13 +877,12 @@ struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb);
/**
The default async search callback function
- \param ldb the context associated with the database (from ldb_init())
- \param context the callback context (struct ldb_result *)
+ \param req the request we are callback of
\param ares a single reply from the async core
\return result code (LDB_SUCCESS on success, or a failure code)
- \note this function expects the context to always be an struct ldb_result pointer
+ \note this function expects req->context to always be an struct ldb_result pointer
AND a talloc context, this function will steal on the context each message
from the ares reply passed on by the async core so that in the end all the
messages will be in the context (ldb_result) memory tree.
@@ -875,7 +891,18 @@ struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb);
request that can be freed as sson as the search request is finished)
*/
-int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares);
+int ldb_search_default_callback(struct ldb_request *req, struct ldb_reply *ares);
+
+/**
+ The default async extended operation callback function
+
+ \param req the request we are callback of
+ \param ares a single reply from the async core
+
+ \return result code (LDB_SUCCESS on success, or a failure code)
+*/
+int ldb_op_default_callback(struct ldb_request *req, struct ldb_reply *ares);
+
/**
Helper function to build a search request
@@ -889,7 +916,8 @@ int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct l
\param attrs the search attributes for the query (pass NULL if none required)
\param controls an array of controls
\param context the callback function context
- \param callback the callback function to handle the async replies
+ \param the callback function to handle the async replies
+ \param the parent request if any
\return result code (LDB_SUCCESS on success, or a failure code)
*/
@@ -903,7 +931,20 @@ int ldb_build_search_req(struct ldb_request **ret_req,
const char * const *attrs,
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback);
+ ldb_request_callback_t callback,
+ struct ldb_request *parent);
+
+int ldb_build_search_req_ex(struct ldb_request **ret_req,
+ struct ldb_context *ldb,
+ TALLOC_CTX *mem_ctx,
+ struct ldb_dn *base,
+ enum ldb_scope scope,
+ struct ldb_parse_tree *tree,
+ const char * const *attrs,
+ struct ldb_control **controls,
+ void *context,
+ ldb_request_callback_t callback,
+ struct ldb_request *parent);
/**
Helper function to build an add request
@@ -914,7 +955,8 @@ int ldb_build_search_req(struct ldb_request **ret_req,
\param message contains the entry to be added
\param controls an array of controls
\param context the callback function context
- \param callback the callback function to handle the async replies
+ \param the callback function to handle the async replies
+ \param the parent request if any
\return result code (LDB_SUCCESS on success, or a failure code)
*/
@@ -925,7 +967,8 @@ int ldb_build_add_req(struct ldb_request **ret_req,
const struct ldb_message *message,
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback);
+ ldb_request_callback_t callback,
+ struct ldb_request *parent);
/**
Helper function to build a modify request
@@ -936,7 +979,8 @@ int ldb_build_add_req(struct ldb_request **ret_req,
\param message contains the entry to be modified
\param controls an array of controls
\param context the callback function context
- \param callback the callback function to handle the async replies
+ \param the callback function to handle the async replies
+ \param the parent request if any
\return result code (LDB_SUCCESS on success, or a failure code)
*/
@@ -947,7 +991,8 @@ int ldb_build_mod_req(struct ldb_request **ret_req,
const struct ldb_message *message,
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback);
+ ldb_request_callback_t callback,
+ struct ldb_request *parent);
/**
Helper function to build a delete request
@@ -958,7 +1003,8 @@ int ldb_build_mod_req(struct ldb_request **ret_req,
\param dn the DN to be deleted
\param controls an array of controls
\param context the callback function context
- \param callback the callback function to handle the async replies
+ \param the callback function to handle the async replies
+ \param the parent request if any
\return result code (LDB_SUCCESS on success, or a failure code)
*/
@@ -969,7 +1015,8 @@ int ldb_build_del_req(struct ldb_request **ret_req,
struct ldb_dn *dn,
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback);
+ ldb_request_callback_t callback,
+ struct ldb_request *parent);
/**
Helper function to build a rename request
@@ -981,7 +1028,8 @@ int ldb_build_del_req(struct ldb_request **ret_req,
\param newdn the new DN
\param controls an array of controls
\param context the callback function context
- \param callback the callback function to handle the async replies
+ \param the callback function to handle the async replies
+ \param the parent request if any
\return result code (LDB_SUCCESS on success, or a failure code)
*/
@@ -993,7 +1041,8 @@ int ldb_build_rename_req(struct ldb_request **ret_req,
struct ldb_dn *newdn,
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback);
+ ldb_request_callback_t callback,
+ struct ldb_request *parent);
/**
Add a ldb_control to a ldb_request
@@ -1023,31 +1072,21 @@ struct ldb_control *ldb_request_get_control(struct ldb_request *req, const char
records that match an LDAP-like search expression
\param ldb the context associated with the database (from ldb_init())
+ \param mem_ctx the memory context to use for the request and the results
+ \param result the return result
\param base the Base Distinguished Name for the query (use ldb_dn_new() for an empty one)
\param scope the search scope for the query
- \param expression the search expression to use for this query
\param attrs the search attributes for the query (pass NULL if none required)
- \param res the return result
+ \param exp_fmt the search expression to use for this query (printf like)
\return result code (LDB_SUCCESS on success, or a failure code)
\note use talloc_free() to free the ldb_result returned
*/
-int ldb_search(struct ldb_context *ldb,
- struct ldb_dn *base,
- enum ldb_scope scope,
- const char *expression,
- const char * const *attrs, struct ldb_result **res);
-
-/*
- * a useful search function where you can easily define the expression and
- * that takes a memory context where results are allocated
-*/
-
-int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
- struct ldb_result **result, struct ldb_dn *base,
- enum ldb_scope scope, const char * const *attrs,
- const char *exp_fmt, ...) PRINTF_ATTRIBUTE(7,8);
+int ldb_search(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
+ struct ldb_result **result, struct ldb_dn *base,
+ enum ldb_scope scope, const char * const *attrs,
+ const char *exp_fmt, ...) PRINTF_ATTRIBUTE(7,8);
/**
Add a record to the database.
@@ -1113,13 +1152,12 @@ int ldb_delete(struct ldb_context *ldb, struct ldb_dn *dn);
/**
The default async extended operation callback function
- \param ldb the context associated with the database (from ldb_init())
- \param context the callback context (struct ldb_result *)
+ \param req the request we are callback of
\param ares a single reply from the async core
\return result code (LDB_SUCCESS on success, or a failure code)
- \note this function expects the context to always be an struct ldb_result pointer
+ \note this function expects req->context to always be an struct ldb_result pointer
AND a talloc context, this function will steal on the context each message
from the ares reply passed on by the async core so that in the end all the
messages will be in the context (ldb_result) memory tree.
@@ -1127,7 +1165,9 @@ int ldb_delete(struct ldb_context *ldb, struct ldb_dn *dn);
(the request need to be freed separately and the result doe not depend on the
request that can be freed as sson as the search request is finished)
*/
-int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares);
+
+int ldb_extended_default_callback(struct ldb_request *req, struct ldb_reply *ares);
+
/**
Helper function to build a extended request
@@ -1140,7 +1180,8 @@ int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct
it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it
\param controls an array of controls
\param context the callback function context
- \param callback the callback function to handle the async replies
+ \param the callback function to handle the async replies
+ \param the parent request if any
\return result code (LDB_SUCCESS on success, or a failure code)
*/
@@ -1151,7 +1192,8 @@ int ldb_build_extended_req(struct ldb_request **ret_req,
void *data,/* NULL or a valid talloc pointer! talloc_get_type() will be used on it */
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback);
+ ldb_request_callback_t callback,
+ struct ldb_request *parent);
/**
call an extended operation
diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h
index e1026ab781..8f7e010bee 100644
--- a/source4/lib/ldb/include/ldb_private.h
+++ b/source4/lib/ldb/include/ldb_private.h
@@ -43,6 +43,12 @@ struct ldb_module_ops;
struct ldb_backend_ops;
+struct ldb_handle {
+ int status;
+ enum ldb_state state;
+ struct ldb_context *ldb;
+};
+
/* basic module structure */
struct ldb_module {
struct ldb_module *prev, *next;
@@ -51,9 +57,8 @@ struct ldb_module {
const struct ldb_module_ops *ops;
};
-/*
- these function pointers define the operations that a ldb module must perform
- they correspond exactly to the ldb_*() interface
+/*
+ these function pointers define the operations that a ldb module can intercept
*/
struct ldb_module_ops {
const char *name;
@@ -68,22 +73,10 @@ struct ldb_module_ops {
int (*start_transaction)(struct ldb_module *);
int (*end_transaction)(struct ldb_module *);
int (*del_transaction)(struct ldb_module *);
- int (*wait)(struct ldb_handle *, enum ldb_wait_type);
int (*sequence_number)(struct ldb_module *, struct ldb_request *);
+ void *private_data;
};
-
-typedef int (*ldb_connect_fn) (struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[],
- struct ldb_module **module);
-
-
-struct ldb_backend_ops {
- const char *name;
- ldb_connect_fn connect_fn;
-};
-
-const char *ldb_default_modules_dir(void);
-
/*
schema related information needed for matching rules
*/
@@ -145,27 +138,6 @@ int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *op
struct ldb_module **backend_module);
void ldb_set_default_dns(struct ldb_context *ldb);
-/* The following definitions come from lib/ldb/common/ldb_modules.c */
-
-const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *string);
-int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, struct ldb_module *backend, struct ldb_module **out);
-int ldb_load_modules(struct ldb_context *ldb, const char *options[]);
-int ldb_init_module_chain(struct ldb_context *ldb, struct ldb_module *module);
-int ldb_next_request(struct ldb_module *module, struct ldb_request *request);
-int ldb_next_start_trans(struct ldb_module *module);
-int ldb_next_end_trans(struct ldb_module *module);
-int ldb_next_del_trans(struct ldb_module *module);
-int ldb_next_init(struct ldb_module *module);
-
-void ldb_set_errstring(struct ldb_context *ldb, const char *err_string);
-void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
-void ldb_reset_err_string(struct ldb_context *ldb);
-
-int ldb_register_module(const struct ldb_module_ops *);
-int ldb_register_backend(const char *url_prefix, ldb_connect_fn);
-void *ldb_dso_load_symbol(struct ldb_context *ldb, const char *name,
- const char *symbol);
-
/* The following definitions come from lib/ldb/common/ldb_debug.c */
void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level,
@@ -239,6 +211,10 @@ char *ldb_casefold_default(void *context, void *mem_ctx, const char *s, size_t n
void ldb_msg_remove_element(struct ldb_message *msg, struct ldb_message_element *el);
+int ldb_msg_element_compare_name(struct ldb_message_element *el1,
+ struct ldb_message_element *el2);
+void ldb_dump_results(struct ldb_context *ldb, struct ldb_result *result, FILE *f);
+
/**
Obtain current/next database sequence number
*/
@@ -248,4 +224,60 @@ int ldb_sequence_number(struct ldb_context *ldb, enum ldb_sequence_type type, ui
#define LDB_SEQ_TIMESTAMP_SEQUENCE 0x02
+/* MODULES specific headers -- SSS */
+
+/* The following definitions come from lib/ldb/common/ldb_modules.c */
+
+const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *string);
+int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, struct ldb_module *backend, struct ldb_module **out);
+int ldb_load_modules(struct ldb_context *ldb, const char *options[]);
+int ldb_init_module_chain(struct ldb_context *ldb, struct ldb_module *module);
+int ldb_next_request(struct ldb_module *module, struct ldb_request *request);
+int ldb_next_start_trans(struct ldb_module *module);
+int ldb_next_end_trans(struct ldb_module *module);
+int ldb_next_del_trans(struct ldb_module *module);
+int ldb_next_init(struct ldb_module *module);
+
+void ldb_set_errstring(struct ldb_context *ldb, const char *err_string);
+void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
+void ldb_reset_err_string(struct ldb_context *ldb);
+
+const char *ldb_default_modules_dir(void);
+
+int ldb_register_module(const struct ldb_module_ops *);
+
+typedef int (*ldb_connect_fn)(struct ldb_context *ldb, const char *url,
+ unsigned int flags, const char *options[],
+ struct ldb_module **module);
+
+struct ldb_backend_ops {
+ const char *name;
+ ldb_connect_fn connect_fn;
+};
+
+const char *ldb_default_modules_dir(void);
+
+int ldb_register_backend(const char *url_prefix, ldb_connect_fn);
+
+void *ldb_dso_load_symbol(struct ldb_context *ldb, const char *name,
+ const char *symbol);
+
+struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb);
+
+int ldb_module_send_entry(struct ldb_request *req,
+ struct ldb_message *msg);
+
+int ldb_module_send_referral(struct ldb_request *req,
+ char *ref);
+
+int ldb_module_done(struct ldb_request *req,
+ struct ldb_control **ctrls,
+ struct ldb_extended *response,
+ int error);
+
+int ldb_mod_register_control(struct ldb_module *module, const char *oid);
+
+
+struct ldb_val ldb_binary_decode(void *mem_ctx, const char *str);
+
#endif
diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i
index 4b61ddba5b..6013462225 100644
--- a/source4/lib/ldb/ldb.i
+++ b/source4/lib/ldb/ldb.i
@@ -46,6 +46,7 @@ typedef struct ldb_context ldb;
typedef struct ldb_dn ldb_dn;
typedef struct ldb_ldif ldb_ldif;
typedef struct ldb_message_element ldb_message_element;
+typedef struct ldb_module ldb_module;
typedef int ldb_error;
typedef int ldb_int_error;
@@ -152,17 +153,21 @@ PyObject *ldb_val_to_py_object(struct ldb_context *ldb_ctx,
* Wrap struct ldb_result
*/
-%typemap(in,noblock=1,numinputs=0) struct ldb_result **OUT (struct ldb_result *temp_ldb_result) {
+%typemap(in,noblock=1,numinputs=0) struct ldb_result ** (struct ldb_result *temp_ldb_result) {
$1 = &temp_ldb_result;
}
#ifdef SWIGPYTHON
%typemap(argout,noblock=1) struct ldb_result ** (int i) {
- $result = PyList_New((*$1)->count);
- for (i = 0; i < (*$1)->count; i++) {
- PyList_SetItem($result, i,
- SWIG_NewPointerObj((*$1)->msgs[i], SWIGTYPE_p_ldb_message, 0)
- );
+ if ($1 == NULL) {
+ $result = Py_None;
+ } else {
+ $result = PyList_New((*$1)->count);
+ for (i = 0; i < (*$1)->count; i++) {
+ PyList_SetItem($result, i,
+ SWIG_NewPointerObj((*$1)->msgs[i], SWIGTYPE_p_ldb_message, 0)
+ );
+ }
}
}
@@ -189,7 +194,7 @@ PyObject *ldb_val_to_py_object(struct ldb_context *ldb_ctx,
#endif
-%types(struct ldb_result *);
+%types(struct ldb_result *, struct ldb_parse_tree *);
/*
* Wrap struct ldb_dn
@@ -685,6 +690,20 @@ PyObject *PyExc_LdbError;
/* Top-level ldb operations */
typedef struct ldb_context {
+ %rename(firstmodule) modules;
+ struct ldb_module *modules;
+
+ %pythoncode {
+ def itermodules(self):
+ m = self.firstmodule
+ while m is not None:
+ yield m
+ m = m.next
+
+ def modules(self):
+ return list(self.itermodules())
+ }
+
%extend {
ldb(void) {
return ldb_init(NULL, event_context_init(NULL));
@@ -718,15 +737,14 @@ typedef struct ldb_context {
attrs,
controls,
res,
- ldb_search_default_callback);
+ ldb_search_default_callback,
+ NULL);
if (ret != LDB_SUCCESS) {
talloc_free(res);
return ret;
}
- ldb_set_timeout($self, req, 0); /* use default timeout */
-
ret = ldb_request($self, req);
if (ret == LDB_SUCCESS) {
@@ -826,8 +844,7 @@ typedef struct ldb_context {
%typemap(freearg,noblock=1) struct ldb_result **result_as_bool { talloc_free(*$1); }
ldb_error __contains__(ldb_dn *dn, struct ldb_result **result_as_bool)
{
- return ldb_search($self, dn, LDB_SCOPE_BASE, NULL, NULL,
- result_as_bool);
+ return ldb_search($self, $self, result_as_bool, dn, LDB_SCOPE_BASE, NULL, NULL);
}
%feature("docstring") parse_ldif "S.parse_ldif(ldif) -> iter(messages)\n" \
@@ -915,10 +932,347 @@ static char *timestring(time_t t)
"Parse a LDAP time string into a UNIX timestamp.";
time_t ldb_string_to_time(const char *s);
+typedef struct ldb_module {
+ struct ldb_module *prev, *next;
+
+ %extend {
+#ifdef SWIGPYTHON
+ const char *__str__() {
+ return $self->ops->name;
+ }
+ char *__repr__() {
+ char *ret;
+ asprintf(&ret, "<ldb module '%s'>", $self->ops->name);
+ return ret;
+ }
+#endif
+ int search(struct ldb_dn *base, enum ldb_scope scope, struct ldb_parse_tree *tree, const char * const * attrs, struct ldb_result **res) {
+ int ret;
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+
+ req->operation = LDB_SEARCH;
+ req->op.search.base = base;
+ req->op.search.scope = scope;
+ req->op.search.tree = tree;
+ req->op.search.attrs = attrs;
+
+ req->op.search.res = talloc_zero(NULL, struct ldb_result);
+
+ ret = $self->ops->search($self, req);
+
+ *res = req->op.search.res;
+
+ talloc_free(req);
+
+ return ret;
+ }
+ ldb_error add(struct ldb_message *message) {
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+ req->operation = LDB_ADD;
+ req->op.add.message = message;
+
+ return $self->ops->add($self, &req);
+ }
+ ldb_error modify(struct ldb_message *message) {
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+ req->operation = LDB_MODIFY;
+ req->op.mod.message = message;
+
+ return $self->ops->modify($self, &req);
+ }
+ ldb_error delete(struct ldb_dn *dn) {
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+ req->operation = LDB_DELETE;
+ req->op.del.dn = dn;
+
+ return $self->ops->del($self, &req);
+
+ }
+ ldb_error rename(struct ldb_dn *olddn, struct ldb_dn *newdn) {
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+ req->operation = LDB_RENAME;
+ req->op.rename.olddn = olddn;
+ req->op.rename.olddn = newdn;
+
+ return $self->ops->rename($self, &req);
+ }
+ ldb_error start_transaction() {
+ return $self->ops->start_transaction($self);
+ }
+ ldb_error end_transaction() {
+ return $self->ops->end_transaction($self);
+ }
+ ldb_error del_transaction() {
+ return $self->ops->del_transaction($self);
+ }
+ }
+} ldb_module;
+
+%{
+int py_module_search(struct ldb_module *mod, struct ldb_request *req)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result, *py_base, *py_attrs, *py_tree;
+
+ py_base = SWIG_NewPointerObj(req->op.search.base, SWIGTYPE_p_ldb_dn, 0);
+
+ if (py_base == NULL)
+ return LDB_ERR_OPERATIONS_ERROR;
+
+ py_tree = SWIG_NewPointerObj(req->op.search.tree, SWIGTYPE_p_ldb_parse_tree, 0);
+
+ if (py_tree == NULL)
+ return LDB_ERR_OPERATIONS_ERROR;
+
+ if (req->op.search.attrs == NULL) {
+ py_attrs = Py_None;
+ } else {
+ int i, len;
+ for (len = 0; req->op.search.attrs[len]; len++);
+ py_attrs = PyList_New(len);
+ for (i = 0; i < len; i++)
+ PyList_SetItem(py_attrs, i, PyString_FromString(req->op.search.attrs[i]));
+ }
+
+ py_result = PyObject_CallMethod(py_ldb, "search", "OiOO", py_base, req->op.search.scope, py_tree, py_attrs);
+
+ Py_DECREF(py_attrs);
+ Py_DECREF(py_tree);
+ Py_DECREF(py_base);
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ if (SWIG_ConvertPtr(py_result, &req->op.search.res, SWIGTYPE_p_ldb_result, 0) != 0) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ Py_DECREF(py_result);
+
+ return LDB_SUCCESS;
+}
+
+int py_module_add(struct ldb_module *mod, struct ldb_request *req)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result, *py_msg;
+
+ py_msg = SWIG_NewPointerObj(req->op.add.message, SWIGTYPE_p_ldb_message, 0);
+
+ if (py_msg == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ py_result = PyObject_CallMethod(py_ldb, "add", "O", py_msg);
+
+ Py_DECREF(py_msg);
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ Py_DECREF(py_result);
+
+ return LDB_SUCCESS;
+}
+
+int py_module_modify(struct ldb_module *mod, struct ldb_request *req)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result, *py_msg;
+
+ py_msg = SWIG_NewPointerObj(req->op.mod.message, SWIGTYPE_p_ldb_message, 0);
+
+ if (py_msg == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ py_result = PyObject_CallMethod(py_ldb, "modify", "O", py_msg);
+
+ Py_DECREF(py_msg);
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ Py_DECREF(py_result);
+
+ return LDB_SUCCESS;
+}
+
+int py_module_del(struct ldb_module *mod, struct ldb_request *req)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result, *py_dn;
+
+ py_dn = SWIG_NewPointerObj(req->op.del.dn, SWIGTYPE_p_ldb_dn, 0);
+
+ if (py_dn == NULL)
+ return LDB_ERR_OPERATIONS_ERROR;
+
+ py_result = PyObject_CallMethod(py_ldb, "delete", "O", py_dn);
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ Py_DECREF(py_result);
+
+ return LDB_SUCCESS;
+}
+
+int py_module_rename(struct ldb_module *mod, struct ldb_request *req)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result, *py_olddn, *py_newdn;
+
+ py_olddn = SWIG_NewPointerObj(req->op.rename.olddn, SWIGTYPE_p_ldb_dn, 0);
+
+ if (py_olddn == NULL)
+ return LDB_ERR_OPERATIONS_ERROR;
+
+ py_newdn = SWIG_NewPointerObj(req->op.rename.newdn, SWIGTYPE_p_ldb_dn, 0);
+
+ if (py_newdn == NULL)
+ return LDB_ERR_OPERATIONS_ERROR;
+
+ py_result = PyObject_CallMethod(py_ldb, "rename", "OO", py_olddn, py_newdn);
+
+ Py_DECREF(py_olddn);
+ Py_DECREF(py_newdn);
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ Py_DECREF(py_result);
+
+ return LDB_SUCCESS;
+}
+
+int py_module_request(struct ldb_module *mod, struct ldb_request *req)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result;
+
+ py_result = PyObject_CallMethod(py_ldb, "request", "");
+
+ return LDB_ERR_OPERATIONS_ERROR;
+}
+
+int py_module_extended(struct ldb_module *mod, struct ldb_request *req)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result;
+
+ py_result = PyObject_CallMethod(py_ldb, "extended", "");
+
+ return LDB_ERR_OPERATIONS_ERROR;
+}
+
+int py_module_start_transaction(struct ldb_module *mod)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result;
+
+ py_result = PyObject_CallMethod(py_ldb, "start_transaction", "");
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ Py_DECREF(py_result);
+
+ return LDB_SUCCESS;
+}
+
+int py_module_end_transaction(struct ldb_module *mod)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result;
+
+ py_result = PyObject_CallMethod(py_ldb, "end_transaction", "");
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ Py_DECREF(py_result);
+
+ return LDB_SUCCESS;
+}
+
+int py_module_del_transaction(struct ldb_module *mod)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result;
+
+ py_result = PyObject_CallMethod(py_ldb, "del_transaction", "");
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ Py_DECREF(py_result);
+
+ return LDB_SUCCESS;
+}
+
+static int py_module_destructor(void *_mod)
+{
+ struct ldb_module *mod = _mod;
+ Py_DECREF((PyObject *)mod->private_data);
+ return 0;
+}
+
+int py_module_init (struct ldb_module *mod)
+{
+ PyObject *py_class = mod->ops->private_data;
+ PyObject *py_result, *py_next, *py_ldb;
+
+ py_ldb = SWIG_NewPointerObj(mod->ldb, SWIGTYPE_p_ldb_context, 0);
+
+ if (py_ldb == NULL)
+ return LDB_ERR_OPERATIONS_ERROR;
+
+ py_next = SWIG_NewPointerObj(mod->next, SWIGTYPE_p_ldb_module, 0);
+
+ if (py_next == NULL)
+ return LDB_ERR_OPERATIONS_ERROR;
+
+ py_result = PyObject_CallFunction(py_class, "OO", py_ldb, py_next);
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ mod->private_data = py_result;
+
+ talloc_set_destructor (mod, py_module_destructor);
+
+ return ldb_next_init(mod);
+}
+%}
+
%typemap(in,noblock=1) const struct ldb_module_ops * {
$1 = talloc_zero(talloc_autofree_context(), struct ldb_module_ops);
- $1->name = (char *)PyObject_GetAttrString($input, (char *)"name");
+ $1->name = talloc_strdup($1, PyString_AsString(PyObject_GetAttrString($input, (char *)"name")));
+
+ Py_INCREF($input);
+ $1->private_data = $input;
+ $1->init_context = py_module_init;
+ $1->search = py_module_search;
+ $1->add = py_module_add;
+ $1->modify = py_module_modify;
+ $1->del = py_module_del;
+ $1->rename = py_module_rename;
+ $1->request = py_module_request;
+ $1->extended = py_module_extended;
+ $1->start_transaction = py_module_start_transaction;
+ $1->end_transaction = py_module_end_transaction;
+ $1->del_transaction = py_module_del_transaction;
}
%feature("docstring") ldb_register_module "S.register_module(module) -> None\n"
@@ -928,4 +1282,5 @@ ldb_int_error ldb_register_module(const struct ldb_module_ops *);
%pythoncode {
__docformat__ = "restructuredText"
+open = Ldb
}
diff --git a/source4/lib/ldb/ldb.mk b/source4/lib/ldb/ldb.mk
index df11e9d2ab..a7b1cb0c69 100644
--- a/source4/lib/ldb/ldb.mk
+++ b/source4/lib/ldb/ldb.mk
@@ -1,7 +1,7 @@
-LDB_LIB = $(STATICLIB)
+LDB_LIB = -Llib -lldb
-LIB_FLAGS=$(LDFLAGS) -Llib $(LDB_LIB) $(LIBS) $(POPT_LIBS) $(TALLOC_LIBS) \
- $(TDB_LIBS) $(LDAP_LIBS) $(LIBDL)
+LIB_FLAGS=$(LDFLAGS) $(LIBS) $(LDB_LIB) $(POPT_LIBS) $(TALLOC_LIBS) \
+ $(TDB_LIBS) $(EVENTS_LIBS) $(LDAP_LIBS) $(LIBDL)
LDB_TDB_DIR=ldb_tdb
LDB_TDB_OBJ=$(LDB_TDB_DIR)/ldb_tdb.o \
@@ -34,34 +34,31 @@ lib/libldb.a: $(OBJS)
sample.$(SHLIBEXT): tests/sample_module.o
$(MDLD) $(MDLD_FLAGS) -o $@ tests/sample_module.o
-bin/ldbadd: tools/ldbadd.o tools/cmdline.o $(LIBS)
+bin/ldbadd: tools/ldbadd.o tools/cmdline.o
$(CC) -o bin/ldbadd tools/ldbadd.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-bin/ldbsearch: tools/ldbsearch.o tools/cmdline.o $(LIBS)
+bin/ldbsearch: tools/ldbsearch.o tools/cmdline.o
$(CC) -o bin/ldbsearch tools/ldbsearch.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-bin/ldbdel: tools/ldbdel.o tools/cmdline.o $(LIBS)
+bin/ldbdel: tools/ldbdel.o tools/cmdline.o
$(CC) -o bin/ldbdel tools/ldbdel.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-bin/ldbmodify: tools/ldbmodify.o tools/cmdline.o $(LIBS)
+bin/ldbmodify: tools/ldbmodify.o tools/cmdline.o
$(CC) -o bin/ldbmodify tools/ldbmodify.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-bin/ldbedit: tools/ldbedit.o tools/cmdline.o $(LIBS)
+bin/ldbedit: tools/ldbedit.o tools/cmdline.o
$(CC) -o bin/ldbedit tools/ldbedit.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-bin/ldbrename: tools/ldbrename.o tools/cmdline.o $(LIBS)
+bin/ldbrename: tools/ldbrename.o tools/cmdline.o
$(CC) -o bin/ldbrename tools/ldbrename.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-bin/ldbtest: tools/ldbtest.o tools/cmdline.o $(LIBS)
+bin/ldbtest: tools/ldbtest.o tools/cmdline.o
$(CC) -o bin/ldbtest tools/ldbtest.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-bin/oLschema2ldif: tools/oLschema2ldif.o tools/cmdline.o tools/convert.o $(LIBS)
- $(CC) -o bin/oLschema2ldif tools/oLschema2ldif.o tools/cmdline.o tools/convert.o $(LIB_FLAGS)
-
-examples/ldbreader: examples/ldbreader.o $(LIBS)
+examples/ldbreader: examples/ldbreader.o
$(CC) -o examples/ldbreader examples/ldbreader.o $(LIB_FLAGS)
-examples/ldifreader: examples/ldifreader.o $(LIBS)
+examples/ldifreader: examples/ldifreader.o
$(CC) -o examples/ldifreader examples/ldifreader.o $(LIB_FLAGS)
# Python bindings
@@ -70,7 +67,7 @@ build-python:: _ldb.$(SHLIBEXT)
ldb_wrap.o: $(ldbdir)/ldb_wrap.c
$(CC) $(PICFLAG) -c $(ldbdir)/ldb_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags`
-_ldb.$(SHLIBEXT): $(LIBS) ldb_wrap.o
+_ldb.$(SHLIBEXT): ldb_wrap.o
$(SHLD) $(SHLD_FLAGS) -o _ldb.$(SHLIBEXT) ldb_wrap.o $(LIB_FLAGS) `$(PYTHON_CONFIG) --ldflags`
install-python:: build-python
diff --git a/source4/lib/ldb/ldb.py b/source4/lib/ldb/ldb.py
index 5826c6b752..4cf36441fd 100644
--- a/source4/lib/ldb/ldb.py
+++ b/source4/lib/ldb/ldb.py
@@ -281,6 +281,16 @@ LDB_ERR_OTHER = _ldb.LDB_ERR_OTHER
class Ldb(object):
"""Connection to a LDB database."""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
+ firstmodule = _swig_property(_ldb.Ldb_firstmodule_get, _ldb.Ldb_firstmodule_set)
+ def itermodules(self):
+ m = self.firstmodule
+ while m is not None:
+ yield m
+ m = m.next
+
+ def modules(self):
+ return list(self.itermodules())
+
def __init__(self, *args, **kwargs):
_ldb.Ldb_swiginit(self,_ldb.new_Ldb(*args, **kwargs))
def connect(*args, **kwargs):
@@ -464,6 +474,26 @@ def string_to_time(*args, **kwargs):
Parse a LDAP time string into a UNIX timestamp.
"""
return _ldb.string_to_time(*args, **kwargs)
+class ldb_module(object):
+ thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
+ prev = _swig_property(_ldb.ldb_module_prev_get, _ldb.ldb_module_prev_set)
+ next = _swig_property(_ldb.ldb_module_next_get, _ldb.ldb_module_next_set)
+ def __init__(self, *args, **kwargs):
+ _ldb.ldb_module_swiginit(self,_ldb.new_ldb_module(*args, **kwargs))
+ __swig_destroy__ = _ldb.delete_ldb_module
+ldb_module.__str__ = new_instancemethod(_ldb.ldb_module___str__,None,ldb_module)
+ldb_module.__repr__ = new_instancemethod(_ldb.ldb_module___repr__,None,ldb_module)
+ldb_module.search = new_instancemethod(_ldb.ldb_module_search,None,ldb_module)
+ldb_module.add = new_instancemethod(_ldb.ldb_module_add,None,ldb_module)
+ldb_module.modify = new_instancemethod(_ldb.ldb_module_modify,None,ldb_module)
+ldb_module.delete = new_instancemethod(_ldb.ldb_module_delete,None,ldb_module)
+ldb_module.rename = new_instancemethod(_ldb.ldb_module_rename,None,ldb_module)
+ldb_module.start_transaction = new_instancemethod(_ldb.ldb_module_start_transaction,None,ldb_module)
+ldb_module.end_transaction = new_instancemethod(_ldb.ldb_module_end_transaction,None,ldb_module)
+ldb_module.del_transaction = new_instancemethod(_ldb.ldb_module_del_transaction,None,ldb_module)
+ldb_module_swigregister = _ldb.ldb_module_swigregister
+ldb_module_swigregister(ldb_module)
+
def register_module(*args, **kwargs):
"""
@@ -472,6 +502,7 @@ def register_module(*args, **kwargs):
"""
return _ldb.register_module(*args, **kwargs)
__docformat__ = "restructuredText"
+open = Ldb
diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
index 5ad671ea2e..4aa71e6036 100644
--- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c
+++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
@@ -53,17 +53,57 @@
struct ildb_private {
struct ldap_connection *ldap;
- struct ldb_module *module;
+ struct event_context *event_ctx;
};
struct ildb_context {
+ struct ldb_module *module;
+ struct ldb_request *req;
+
struct ildb_private *ildb;
- struct ldb_handle *handle;
- struct ldap_request *req;
- void *context;
- int (*callback)(struct ldb_context *, void *, struct ldb_reply *);
+ struct ldap_request *ireq;
+
+ bool done;
+
+ struct ildb_destructor_ctx *dc;
};
+static void ildb_request_done(struct ildb_context *ctx,
+ struct ldb_control **ctrls, int error)
+{
+ struct ldb_reply *ares;
+
+ ctx->done = true;
+
+ if (ctx->req == NULL) {
+ /* if the req has been freed already just return */
+ return;
+ }
+
+ ares = talloc_zero(ctx->req, struct ldb_reply);
+ if (!ares) {
+ ldb_oom(ctx->req->handle->ldb);
+ ctx->req->callback(ctx->req, NULL);
+ return;
+ }
+ ares->type = LDB_REPLY_DONE;
+ ares->controls = talloc_steal(ares, ctrls);
+ ares->error = error;
+
+ ctx->req->callback(ctx->req, ares);
+}
+
+static void ildb_auto_done_callback(struct event_context *ev,
+ struct timed_event *te,
+ struct timeval t,
+ void *private_data)
+{
+ struct ildb_context *ac;
+
+ ac = talloc_get_type(private_data, struct ildb_context);
+ ildb_request_done(ac, NULL, LDB_SUCCESS);
+}
+
/*
convert a ldb_message structure to a list of ldap_mod structures
ready for ildap_add() or ildap_modify()
@@ -122,17 +162,19 @@ failed:
/*
map an ildap NTSTATUS to a ldb error code
*/
-static int ildb_map_error(struct ildb_private *ildb, NTSTATUS status)
+static int ildb_map_error(struct ldb_module *module, NTSTATUS status)
{
+ struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
+
TALLOC_CTX *mem_ctx = talloc_new(ildb);
if (NT_STATUS_IS_OK(status)) {
return LDB_SUCCESS;
}
if (!mem_ctx) {
- ldb_oom(ildb->module->ldb);
+ ldb_oom(module->ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- ldb_set_errstring(ildb->module->ldb,
+ ldb_set_errstring(module->ldb,
ldap_errstr(ildb->ldap, mem_ctx, status));
talloc_free(mem_ctx);
if (NT_STATUS_IS_LDAP(status)) {
@@ -141,47 +183,46 @@ static int ildb_map_error(struct ildb_private *ildb, NTSTATUS status)
return LDB_ERR_OPERATIONS_ERROR;
}
-static void ildb_request_timeout(struct event_context *ev,
- struct timed_event *te,
+static void ildb_request_timeout(struct event_context *ev, struct timed_event *te,
struct timeval t, void *private_data)
{
- struct ildb_context *ac;
- struct ldb_handle *handle;
-
- ac = talloc_get_type(private_data, struct ildb_context);
- handle = ac->handle;
-
- ac = talloc_get_type(private_data, struct ildb_context);
+ struct ildb_context *ac = talloc_get_type(private_data, struct ildb_context);
- if (ac->req->state == LDAP_REQUEST_PENDING) {
- DLIST_REMOVE(ac->req->conn->pending, ac->req);
+ if (ac->ireq->state == LDAP_REQUEST_PENDING) {
+ DLIST_REMOVE(ac->ireq->conn->pending, ac->ireq);
}
- handle->status = LDB_ERR_TIME_LIMIT_EXCEEDED;
-
- return;
+ ildb_request_done(ac, NULL, LDB_ERR_TIME_LIMIT_EXCEEDED);
}
static void ildb_callback(struct ldap_request *req)
{
struct ildb_context *ac;
- struct ldb_handle *handle;
- struct ildb_private *ildb;
NTSTATUS status;
+ struct ldap_SearchResEntry *search;
+ struct ldap_message *msg;
+ struct ldb_control **controls;
+ struct ldb_message *ldbmsg;
+ char *referral;
+ bool callback_failed;
+ bool request_done;
+ int ret;
int i;
ac = talloc_get_type(req->async.private_data, struct ildb_context);
- ildb = ac->ildb;
- handle = ac->handle;
- handle->status = LDB_SUCCESS;
+ callback_failed = false;
+ request_done = false;
+ controls = NULL;
if (!NT_STATUS_IS_OK(req->status)) {
- handle->status = ildb_map_error(ildb, req->status);
+ ret = ildb_map_error(ac->module, req->status);
+ ildb_request_done(ac, NULL, ret);
return;
}
if (req->num_replies < 1) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ ildb_request_done(ac, NULL, ret);
return;
}
@@ -189,140 +230,112 @@ static void ildb_callback(struct ldap_request *req)
case LDAP_TAG_ModifyRequest:
if (req->replies[0]->type != LDAP_TAG_ModifyResponse) {
- handle->status = LDB_ERR_PROTOCOL_ERROR;
- return;
+ ret = LDB_ERR_PROTOCOL_ERROR;
+ break;
}
- status = ldap_check_response(req->conn, &req->replies[0]->r.GeneralResult);
- handle->status = ildb_map_error(ildb, status);
- if (ac->callback && handle->status == LDB_SUCCESS) {
- /* FIXME: build a corresponding ares to pass on */
- handle->status = ac->callback(ac->ildb->module->ldb, ac->context, NULL);
- }
- handle->state = LDB_ASYNC_DONE;
+ status = ldap_check_response(ac->ireq->conn, &req->replies[0]->r.GeneralResult);
+ ret = ildb_map_error(ac->module, status);
+ request_done = true;
break;
case LDAP_TAG_AddRequest:
if (req->replies[0]->type != LDAP_TAG_AddResponse) {
- handle->status = LDB_ERR_PROTOCOL_ERROR;
+ ret = LDB_ERR_PROTOCOL_ERROR;
return;
}
- status = ldap_check_response(req->conn, &req->replies[0]->r.GeneralResult);
- handle->status = ildb_map_error(ildb, status);
- if (ac->callback && handle->status == LDB_SUCCESS) {
- /* FIXME: build a corresponding ares to pass on */
- handle->status = ac->callback(ac->ildb->module->ldb, ac->context, NULL);
- }
- handle->state = LDB_ASYNC_DONE;
+ status = ldap_check_response(ac->ireq->conn, &req->replies[0]->r.GeneralResult);
+ ret = ildb_map_error(ac->module, status);
+ request_done = true;
break;
case LDAP_TAG_DelRequest:
if (req->replies[0]->type != LDAP_TAG_DelResponse) {
- handle->status = LDB_ERR_PROTOCOL_ERROR;
+ ret = LDB_ERR_PROTOCOL_ERROR;
return;
}
- status = ldap_check_response(req->conn, &req->replies[0]->r.GeneralResult);
- handle->status = ildb_map_error(ildb, status);
- if (ac->callback && handle->status == LDB_SUCCESS) {
- /* FIXME: build a corresponding ares to pass on */
- handle->status = ac->callback(ac->ildb->module->ldb, ac->context, NULL);
- }
- handle->state = LDB_ASYNC_DONE;
+ status = ldap_check_response(ac->ireq->conn, &req->replies[0]->r.GeneralResult);
+ ret = ildb_map_error(ac->module, status);
+ request_done = true;
break;
case LDAP_TAG_ModifyDNRequest:
if (req->replies[0]->type != LDAP_TAG_ModifyDNResponse) {
- handle->status = LDB_ERR_PROTOCOL_ERROR;
+ ret = LDB_ERR_PROTOCOL_ERROR;
return;
}
- status = ldap_check_response(req->conn, &req->replies[0]->r.GeneralResult);
- handle->status = ildb_map_error(ildb, status);
- if (ac->callback && handle->status == LDB_SUCCESS) {
- /* FIXME: build a corresponding ares to pass on */
- handle->status = ac->callback(ac->ildb->module->ldb, ac->context, NULL);
- }
- handle->state = LDB_ASYNC_DONE;
+ status = ldap_check_response(ac->ireq->conn, &req->replies[0]->r.GeneralResult);
+ ret = ildb_map_error(ac->module, status);
+ request_done = true;
break;
case LDAP_TAG_SearchRequest:
/* loop over all messages */
for (i = 0; i < req->num_replies; i++) {
- struct ldap_SearchResEntry *search;
- struct ldb_reply *ares = NULL;
- struct ldap_message *msg;
- int ret;
-
- ares = talloc_zero(ac, struct ldb_reply);
- if (!ares) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- return;
- }
msg = req->replies[i];
switch (msg->type) {
case LDAP_TAG_SearchResultDone:
- status = ldap_check_response(req->conn, &msg->r.GeneralResult);
+ status = ldap_check_response(ac->ireq->conn, &msg->r.GeneralResult);
if (!NT_STATUS_IS_OK(status)) {
- handle->status = ildb_map_error(ildb, status);
- return;
+ ret = ildb_map_error(ac->module, status);
+ break;
}
- ares->controls = talloc_move(ares, &msg->controls);
+ controls = talloc_steal(ac, msg->controls);
if (msg->r.SearchResultDone.resultcode) {
if (msg->r.SearchResultDone.errormessage) {
- ldb_set_errstring(ac->ildb->module->ldb, msg->r.SearchResultDone.errormessage);
+ ldb_set_errstring(ac->module->ldb, msg->r.SearchResultDone.errormessage);
}
}
- handle->status = msg->r.SearchResultDone.resultcode;
- handle->state = LDB_ASYNC_DONE;
- ares->type = LDB_REPLY_DONE;
+ ret = msg->r.SearchResultDone.resultcode;
+ request_done = true;
break;
case LDAP_TAG_SearchResultEntry:
-
- ares->message = ldb_msg_new(ares);
- if (!ares->message) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- return;
+ ldbmsg = ldb_msg_new(ac);
+ if (!ldbmsg) {
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ break;
}
search = &(msg->r.SearchResultEntry);
- ares->message->dn = ldb_dn_new(ares->message, ac->ildb->module->ldb, search->dn);
- if ( ! ldb_dn_validate(ares->message->dn)) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- return;
+ ldbmsg->dn = ldb_dn_new(ldbmsg, ac->module->ldb, search->dn);
+ if ( ! ldb_dn_validate(ldbmsg->dn)) {
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ break;
}
- ares->message->num_elements = search->num_attributes;
- ares->message->elements = talloc_move(ares->message,
- &search->attributes);
+ ldbmsg->num_elements = search->num_attributes;
+ ldbmsg->elements = talloc_move(ldbmsg, &search->attributes);
- handle->status = LDB_SUCCESS;
- handle->state = LDB_ASYNC_PENDING;
- ares->type = LDB_REPLY_ENTRY;
+ ret = ldb_module_send_entry(ac->req, ldbmsg);
+ if (ret != LDB_SUCCESS) {
+ callback_failed = true;
+ }
break;
case LDAP_TAG_SearchResultReference:
- ares->referral = talloc_strdup(ares, msg->r.SearchResultReference.referral);
+ referral = talloc_strdup(ac, msg->r.SearchResultReference.referral);
- handle->status = LDB_SUCCESS;
- handle->state = LDB_ASYNC_PENDING;
- ares->type = LDB_REPLY_REFERRAL;
+ ret = ldb_module_send_referral(ac->req, referral);
+ if (ret != LDB_SUCCESS) {
+ callback_failed = true;
+ }
break;
default:
/* TAG not handled, fail ! */
- handle->status = LDB_ERR_PROTOCOL_ERROR;
- return;
+ ret = LDB_ERR_PROTOCOL_ERROR;
+ break;
}
- ret = ac->callback(ac->ildb->module->ldb, ac->context, ares);
- if (ret) {
- handle->status = ret;
+ if (ret != LDB_SUCCESS) {
+ break;
}
}
@@ -333,121 +346,81 @@ static void ildb_callback(struct ldap_request *req)
break;
default:
- handle->status = LDB_ERR_PROTOCOL_ERROR;
- return;
+ ret = LDB_ERR_PROTOCOL_ERROR;
+ break;
}
-}
-static struct ildb_context *init_ildb_handle(struct ildb_private *ildb,
- struct ldb_request *req)
-{
- struct ildb_context *ildb_ac;
- struct ldb_handle *h;
+ if (ret != LDB_SUCCESS) {
- h = talloc_zero(req, struct ldb_handle);
- if (h == NULL) {
- ldb_set_errstring(ildb->module->ldb, "Out of Memory");
- return NULL;
+ /* if the callback failed the caller will have freed the
+ * request. Just return and don't try to use it */
+ if ( ! callback_failed) {
+ request_done = true;
+ }
}
- h->module = ildb->module;
-
- ildb_ac = talloc(h, struct ildb_context);
- if (ildb_ac == NULL) {
- ldb_set_errstring(ildb->module->ldb, "Out of Memory");
- talloc_free(h);
- return NULL;
+ if (request_done) {
+ ildb_request_done(ac, controls, ret);
}
-
- h->private_data = ildb_ac;
-
- h->state = LDB_ASYNC_INIT;
- h->status = LDB_SUCCESS;
-
- ildb_ac->ildb = ildb;
- ildb_ac->handle = h;
- ildb_ac->context = req->context;
- ildb_ac->callback = req->callback;
-
- req->handle = h;
- return ildb_ac;
+ return;
}
-static int ildb_request_send(struct ildb_private *ildb, struct ldap_message *msg, struct ldb_request *r)
+static int ildb_request_send(struct ildb_context *ac, struct ldap_message *msg)
{
- struct ildb_context *ildb_ac = init_ildb_handle(ildb, r);
struct ldap_request *req;
- if (!ildb_ac) {
+ if (!ac) {
return LDB_ERR_OPERATIONS_ERROR;
}
- req = ldap_request_send(ildb->ldap, msg);
+ req = ldap_request_send(ac->ildb->ldap, msg);
if (req == NULL) {
- ldb_set_errstring(ildb->module->ldb, "async send request failed");
+ ldb_set_errstring(ac->module->ldb, "async send request failed");
return LDB_ERR_OPERATIONS_ERROR;
}
- ildb_ac->req = talloc_steal(ildb_ac, req);
+ ac->ireq = talloc_steal(ac, req);
- if (!req->conn) {
- ldb_set_errstring(ildb->module->ldb, "connection to remote LDAP server dropped?");
+ if (!ac->ireq->conn) {
+ ldb_set_errstring(ac->module->ldb, "connection to remote LDAP server dropped?");
return LDB_ERR_OPERATIONS_ERROR;
}
talloc_free(req->time_event);
req->time_event = NULL;
- if (r->timeout) {
- req->time_event = event_add_timed(req->conn->event.event_ctx, ildb_ac,
- timeval_current_ofs(r->timeout, 0),
- ildb_request_timeout, ildb_ac);
+ if (ac->req->timeout) {
+ req->time_event = event_add_timed(ac->ildb->event_ctx, ac,
+ timeval_current_ofs(ac->req->timeout, 0),
+ ildb_request_timeout, ac);
}
req->async.fn = ildb_callback;
- req->async.private_data = ildb_ac;
+ req->async.private_data = ac;
return LDB_SUCCESS;
}
-static int ildb_request_noop(struct ildb_private *ildb, struct ldb_request *req)
-{
- struct ildb_context *ildb_ac = init_ildb_handle(ildb, req);
- int ret = LDB_SUCCESS;
-
- if (!ildb_ac) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- if (ildb_ac->callback) {
- ret = ildb_ac->callback(ildb->module->ldb, ildb_ac->context, NULL);
- }
- ildb_ac->handle->state = LDB_ASYNC_DONE;
- return ret;
-}
-
/*
search for matching records using an asynchronous function
*/
-static int ildb_search(struct ldb_module *module, struct ldb_request *req)
+static int ildb_search(struct ildb_context *ac)
{
- struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
+ struct ldb_request *req = ac->req;
struct ldap_message *msg;
int n;
- req->handle = NULL;
-
if (!req->callback || !req->context) {
- ldb_set_errstring(module->ldb, "Async interface called with NULL callback function or NULL context");
+ ldb_set_errstring(ac->module->ldb, "Async interface called with NULL callback function or NULL context");
return LDB_ERR_OPERATIONS_ERROR;
}
if (req->op.search.tree == NULL) {
- ldb_set_errstring(module->ldb, "Invalid expression parse tree");
+ ldb_set_errstring(ac->module->ldb, "Invalid expression parse tree");
return LDB_ERR_OPERATIONS_ERROR;
}
msg = new_ldap_message(req);
if (msg == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
+ ldb_set_errstring(ac->module->ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -459,7 +432,7 @@ static int ildb_search(struct ldb_module *module, struct ldb_request *req)
msg->r.SearchRequest.basedn = ldb_dn_alloc_linearized(msg, req->op.search.base);
}
if (msg->r.SearchRequest.basedn == NULL) {
- ldb_set_errstring(module->ldb, "Unable to determine baseDN");
+ ldb_set_errstring(ac->module->ldb, "Unable to determine baseDN");
talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -481,26 +454,19 @@ static int ildb_search(struct ldb_module *module, struct ldb_request *req)
msg->r.SearchRequest.attributes = discard_const(req->op.search.attrs);
msg->controls = req->controls;
- return ildb_request_send(ildb, msg, req);
+ return ildb_request_send(ac, msg);
}
/*
add a record
*/
-static int ildb_add(struct ldb_module *module, struct ldb_request *req)
+static int ildb_add(struct ildb_context *ac)
{
- struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
+ struct ldb_request *req = ac->req;
struct ldap_message *msg;
struct ldap_mod **mods;
int i,n;
- req->handle = NULL;
-
- /* ignore ltdb specials */
- if (ldb_dn_is_special(req->op.add.message->dn)) {
- return ildb_request_noop(ildb, req);
- }
-
msg = new_ldap_message(req);
if (msg == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -531,26 +497,19 @@ static int ildb_add(struct ldb_module *module, struct ldb_request *req)
msg->r.AddRequest.attributes[i] = mods[i]->attrib;
}
- return ildb_request_send(ildb, msg, req);
+ return ildb_request_send(ac, msg);
}
/*
modify a record
*/
-static int ildb_modify(struct ldb_module *module, struct ldb_request *req)
+static int ildb_modify(struct ildb_context *ac)
{
- struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
+ struct ldb_request *req = ac->req;
struct ldap_message *msg;
struct ldap_mod **mods;
int i,n;
- req->handle = NULL;
-
- /* ignore ltdb specials */
- if (ldb_dn_is_special(req->op.mod.message->dn)) {
- return ildb_request_noop(ildb, req);
- }
-
msg = new_ldap_message(req);
if (msg == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -581,24 +540,17 @@ static int ildb_modify(struct ldb_module *module, struct ldb_request *req)
msg->r.ModifyRequest.mods[i] = *mods[i];
}
- return ildb_request_send(ildb, msg, req);
+ return ildb_request_send(ac, msg);
}
/*
delete a record
*/
-static int ildb_delete(struct ldb_module *module, struct ldb_request *req)
+static int ildb_delete(struct ildb_context *ac)
{
- struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
+ struct ldb_request *req = ac->req;
struct ldap_message *msg;
- req->handle = NULL;
-
- /* ignore ltdb specials */
- if (ldb_dn_is_special(req->op.del.dn)) {
- return ildb_request_noop(ildb, req);
- }
-
msg = new_ldap_message(req);
if (msg == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -612,24 +564,17 @@ static int ildb_delete(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_INVALID_DN_SYNTAX;
}
- return ildb_request_send(ildb, msg, req);
+ return ildb_request_send(ac, msg);
}
/*
rename a record
*/
-static int ildb_rename(struct ldb_module *module, struct ldb_request *req)
+static int ildb_rename(struct ildb_context *ac)
{
- struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
+ struct ldb_request *req = ac->req;
struct ldap_message *msg;
- req->handle = NULL;
-
- /* ignore ltdb specials */
- if (ldb_dn_is_special(req->op.rename.olddn) || ldb_dn_is_special(req->op.rename.newdn)) {
- return ildb_request_noop(ildb, req);
- }
-
msg = new_ldap_message(req);
if (msg == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -660,7 +605,7 @@ static int ildb_rename(struct ldb_module *module, struct ldb_request *req)
msg->r.ModifyDNRequest.deleteolddn = true;
- return ildb_request_send(ildb, msg, req);
+ return ildb_request_send(ac, msg);
}
static int ildb_start_trans(struct ldb_module *module)
@@ -684,57 +629,105 @@ static int ildb_del_trans(struct ldb_module *module)
return LDB_SUCCESS;
}
-static int ildb_request(struct ldb_module *module, struct ldb_request *req)
+static bool ildb_dn_is_special(struct ldb_request *req)
{
- return LDB_ERR_OPERATIONS_ERROR;
+ struct ldb_dn *dn = NULL;
+
+ switch (req->operation) {
+ case LDB_ADD:
+ dn = req->op.add.message->dn;
+ break;
+ case LDB_MODIFY:
+ dn = req->op.mod.message->dn;
+ break;
+ case LDB_DELETE:
+ dn = req->op.del.dn;
+ break;
+ case LDB_RENAME:
+ dn = req->op.rename.olddn;
+ break;
+ default:
+ break;
+ }
+
+ if (dn && ldb_dn_is_special(dn)) {
+ return true;
+ }
+ return false;
}
-static int ildb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
+static int ildb_handle_request(struct ldb_module *module, struct ldb_request *req)
{
- struct ildb_context *ac = talloc_get_type(handle->private_data, struct ildb_context);
+ struct ildb_private *ildb;
+ struct ildb_context *ac;
+ struct timed_event *te;
+ int ret;
+
+ ildb = talloc_get_type(module->private_data, struct ildb_private);
- if (handle->state == LDB_ASYNC_DONE) {
- return handle->status;
+ if (req->starttime == 0 || req->timeout == 0) {
+ ldb_set_errstring(module->ldb, "Invalid timeout settings");
+ return LDB_ERR_TIME_LIMIT_EXCEEDED;
}
- if (!ac) {
+ ac = talloc_zero(req, struct ildb_context);
+ if (ac == NULL) {
+ ldb_set_errstring(module->ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
- handle->state = LDB_ASYNC_INIT;
+ ac->module = module;
+ ac->req = req;
+ ac->ildb = ildb;
+
+ if (ildb_dn_is_special(req)) {
- switch(type) {
- case LDB_WAIT_NONE:
- if (event_loop_once(ac->req->conn->event.event_ctx) != 0) {
- return LDB_ERR_OTHER;
+ te = event_add_timed(ac->ildb->event_ctx,
+ ac, timeval_zero(),
+ ildb_auto_done_callback, ac);
+ if (NULL == te) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
+
+ return LDB_SUCCESS;
+ }
+
+ switch (ac->req->operation) {
+ case LDB_SEARCH:
+ ret = ildb_search(ac);
break;
- case LDB_WAIT_ALL:
- while (handle->status == LDB_SUCCESS && handle->state != LDB_ASYNC_DONE) {
- if (event_loop_once(ac->req->conn->event.event_ctx) != 0) {
- return LDB_ERR_OTHER;
- }
- }
+ case LDB_ADD:
+ ret = ildb_add(ac);
+ break;
+ case LDB_MODIFY:
+ ret = ildb_modify(ac);
+ break;
+ case LDB_DELETE:
+ ret = ildb_delete(ac);
+ break;
+ case LDB_RENAME:
+ ret = ildb_rename(ac);
break;
default:
- return LDB_ERR_OPERATIONS_ERROR;
+ /* no other op supported */
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ break;
}
- return handle->status;
+ return ret;
}
static const struct ldb_module_ops ildb_ops = {
.name = "ldap",
- .search = ildb_search,
- .add = ildb_add,
- .modify = ildb_modify,
- .del = ildb_delete,
- .rename = ildb_rename,
- .request = ildb_request,
+ .search = ildb_handle_request,
+ .add = ildb_handle_request,
+ .modify = ildb_handle_request,
+ .del = ildb_handle_request,
+ .rename = ildb_handle_request,
+/* .request = ildb_handle_request, */
.start_transaction = ildb_start_trans,
.end_transaction = ildb_end_trans,
.del_transaction = ildb_del_trans,
- .wait = ildb_wait
};
/*
@@ -748,7 +741,6 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
struct ildb_private *ildb;
NTSTATUS status;
struct cli_credentials *creds;
- struct event_context *event_ctx;
module = talloc(ldb, struct ldb_module);
if (!module) {
@@ -758,7 +750,6 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
talloc_set_name_const(module, "ldb_ildap backend");
module->ldb = ldb;
module->prev = module->next = NULL;
- module->private_data = NULL;
module->ops = &ildb_ops;
ildb = talloc(module, struct ildb_private);
@@ -767,12 +758,12 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
goto failed;
}
module->private_data = ildb;
- ildb->module = module;
- event_ctx = ldb_get_event_context(ldb);
+ ildb->event_ctx = ldb_get_event_context(ldb);
+
ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, "loadparm"),
- event_ctx);
+ ildb->event_ctx);
if (!ildb->ldap) {
ldb_oom(ldb);
goto failed;
diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
index a4534c549a..7caee10b47 100644
--- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c
+++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
@@ -45,17 +45,16 @@
struct lldb_private {
LDAP *ldap;
- struct ldb_module *module;
};
struct lldb_context {
+ struct ldb_module *module;
+ struct ldb_request *req;
+
struct lldb_private *lldb;
- struct ldb_handle *handle;
+
+ struct ldb_control **controls;
int msgid;
- int timeout;
- time_t starttime;
- void *context;
- int (*callback)(struct ldb_context *, void *, struct ldb_reply *);
};
static int lldb_ldap_to_ldb(int err) {
@@ -63,42 +62,6 @@ static int lldb_ldap_to_ldb(int err) {
return err;
}
-static struct lldb_context *init_lldb_handle(struct lldb_private *lldb, struct ldb_request *req)
-{
- struct lldb_context *ac;
- struct ldb_handle *h;
-
- h = talloc_zero(req, struct ldb_handle);
- if (h == NULL) {
- ldb_set_errstring(lldb->module->ldb, "Out of Memory");
- return NULL;
- }
-
- h->module = lldb->module;
-
- ac = talloc(h, struct lldb_context);
- if (ac == NULL) {
- ldb_set_errstring(lldb->module->ldb, "Out of Memory");
- talloc_free(h);
- return NULL;
- }
-
- h->private_data = ac;
-
- h->state = LDB_ASYNC_INIT;
- h->status = LDB_SUCCESS;
-
- ac->lldb = lldb;
- ac->handle = h;
- ac->context = req->context;
- ac->callback = req->callback;
- ac->timeout = req->timeout;
- ac->starttime = req->starttime;
- ac->msgid = 0;
-
- req->handle = h;
- return ac;
-}
/*
convert a ldb_message structure to a list of LDAPMod structures
ready for ldap_add() or ldap_modify()
@@ -230,10 +193,11 @@ static int lldb_add_msg_attr(struct ldb_context *ldb,
/*
search for matching records
*/
-static int lldb_search(struct ldb_module *module, struct ldb_request *req)
+static int lldb_search(struct lldb_context *lldb_ac)
{
- struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
- struct lldb_context *lldb_ac;
+ struct lldb_private *lldb = lldb_ac->lldb;
+ struct ldb_module *module = lldb_ac->module;
+ struct ldb_request *req = lldb_ac->req;
struct timeval tv;
int ldap_scope;
char *search_base;
@@ -254,10 +218,7 @@ static int lldb_search(struct ldb_module *module, struct ldb_request *req)
ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Controls are not yet supported by ldb_ldap backend!\n");
}
- lldb_ac = init_lldb_handle(lldb, req);
- if (lldb_ac == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
+ req->handle->state = LDB_ASYNC_PENDING;
search_base = ldb_dn_alloc_linearized(lldb_ac, req->op.search.base);
if (req->op.search.base == NULL) {
@@ -307,23 +268,16 @@ static int lldb_search(struct ldb_module *module, struct ldb_request *req)
/*
add a record
*/
-static int lldb_add(struct ldb_module *module, struct ldb_request *req)
+static int lldb_add(struct lldb_context *lldb_ac)
{
- struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
- struct lldb_context *lldb_ac;
+ struct lldb_private *lldb = lldb_ac->lldb;
+ struct ldb_module *module = lldb_ac->module;
+ struct ldb_request *req = lldb_ac->req;
LDAPMod **mods;
char *dn;
int ret;
- /* ltdb specials should not reach this point */
- if (ldb_dn_is_special(req->op.add.message->dn)) {
- return LDB_ERR_INVALID_DN_SYNTAX;
- }
-
- lldb_ac = init_lldb_handle(lldb, req);
- if (lldb_ac == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
+ req->handle->state = LDB_ASYNC_PENDING;
mods = lldb_msg_to_mods(lldb_ac, req->op.add.message, 0);
if (mods == NULL) {
@@ -350,23 +304,16 @@ static int lldb_add(struct ldb_module *module, struct ldb_request *req)
/*
modify a record
*/
-static int lldb_modify(struct ldb_module *module, struct ldb_request *req)
+static int lldb_modify(struct lldb_context *lldb_ac)
{
- struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
- struct lldb_context *lldb_ac;
+ struct lldb_private *lldb = lldb_ac->lldb;
+ struct ldb_module *module = lldb_ac->module;
+ struct ldb_request *req = lldb_ac->req;
LDAPMod **mods;
char *dn;
int ret;
- /* ltdb specials should not reach this point */
- if (ldb_dn_is_special(req->op.mod.message->dn)) {
- return LDB_ERR_INVALID_DN_SYNTAX;
- }
-
- lldb_ac = init_lldb_handle(lldb, req);
- if (req->handle == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
+ req->handle->state = LDB_ASYNC_PENDING;
mods = lldb_msg_to_mods(lldb_ac, req->op.mod.message, 1);
if (mods == NULL) {
@@ -393,22 +340,15 @@ static int lldb_modify(struct ldb_module *module, struct ldb_request *req)
/*
delete a record
*/
-static int lldb_delete(struct ldb_module *module, struct ldb_request *req)
+static int lldb_delete(struct lldb_context *lldb_ac)
{
- struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
- struct lldb_context *lldb_ac;
+ struct lldb_private *lldb = lldb_ac->lldb;
+ struct ldb_module *module = lldb_ac->module;
+ struct ldb_request *req = lldb_ac->req;
char *dnstr;
int ret;
-
- /* ltdb specials should not reach this point */
- if (ldb_dn_is_special(req->op.del.dn)) {
- return LDB_ERR_INVALID_DN_SYNTAX;
- }
- lldb_ac = init_lldb_handle(lldb, req);
- if (lldb_ac == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
+ req->handle->state = LDB_ASYNC_PENDING;
dnstr = ldb_dn_alloc_linearized(lldb_ac, req->op.del.dn);
@@ -427,24 +367,17 @@ static int lldb_delete(struct ldb_module *module, struct ldb_request *req)
/*
rename a record
*/
-static int lldb_rename(struct ldb_module *module, struct ldb_request *req)
+static int lldb_rename(struct lldb_context *lldb_ac)
{
- struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
- struct lldb_context *lldb_ac;
+ struct lldb_private *lldb = lldb_ac->lldb;
+ struct ldb_module *module = lldb_ac->module;
+ struct ldb_request *req = lldb_ac->req;
char *old_dn;
char *newrdn;
char *parentdn;
int ret;
-
- /* ltdb specials should not reach this point */
- if (ldb_dn_is_special(req->op.rename.olddn) || ldb_dn_is_special(req->op.rename.newdn)) {
- return LDB_ERR_INVALID_DN_SYNTAX;
- }
- lldb_ac = init_lldb_handle(lldb, req);
- if (lldb_ac == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
+ req->handle->state = LDB_ASYNC_PENDING;
old_dn = ldb_dn_alloc_linearized(lldb_ac, req->op.rename.olddn);
if (old_dn == NULL) {
@@ -474,57 +407,99 @@ static int lldb_rename(struct ldb_module *module, struct ldb_request *req)
return lldb_ldap_to_ldb(ret);
}
-static int lldb_parse_result(struct lldb_context *ac, LDAPMessage *result)
+static int lldb_start_trans(struct ldb_module *module)
+{
+ /* TODO implement a local transaction mechanism here */
+
+ return LDB_SUCCESS;
+}
+
+static int lldb_end_trans(struct ldb_module *module)
+{
+ /* TODO implement a local transaction mechanism here */
+
+ return LDB_SUCCESS;
+}
+
+static int lldb_del_trans(struct ldb_module *module)
+{
+ /* TODO implement a local transaction mechanism here */
+
+ return LDB_SUCCESS;
+}
+
+void lldb_request_done(struct ldb_request *req,
+ struct ldb_control **ctrls, int error)
+{
+ struct ldb_reply *ares;
+
+ ares = talloc_zero(req, struct ldb_reply);
+ if (!ares) {
+ ldb_oom(req->handle->ldb);
+ req->callback(req, NULL);
+ return;
+ }
+ ares->type = LDB_REPLY_DONE;
+ ares->controls = talloc_steal(ares, ctrls);
+ ares->error = error;
+
+ req->callback(req, ares);
+}
+
+/* return false if the request is still in progress
+ * return true if the request is completed
+ */
+static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result)
{
- struct ldb_handle *handle = ac->handle;
struct lldb_private *lldb = ac->lldb;
- struct ldb_reply *ares = NULL;
- LDAPMessage *msg;
- int type;
+ LDAPControl **serverctrlsp = NULL;
+ char **referralsp = NULL;
char *matcheddnp = NULL;
char *errmsgp = NULL;
- char **referralsp = NULL;
- LDAPControl **serverctrlsp = NULL;
- int ret = LDB_SUCCESS;
-
- type = ldap_msgtype(result);
+ LDAPMessage *msg;
+ int type;
+ struct ldb_message *ldbmsg;
+ char *referral;
+ bool callback_failed;
+ bool request_done;
+ bool lret;
+ int ret;
+ int i;
- handle->status = 0;
+ type = ldap_msgtype(result);
+ callback_failed = false;
+ request_done = false;
switch (type) {
-
case LDAP_RES_SEARCH_ENTRY:
+
msg = ldap_first_entry(lldb->ldap, result);
if (msg != NULL) {
BerElement *berptr = NULL;
char *attr, *dn;
- ares = talloc_zero(ac, struct ldb_reply);
- if (!ares) {
- ret = LDB_ERR_OPERATIONS_ERROR;
- goto error;
- }
-
- ares->message = ldb_msg_new(ares);
- if (!ares->message) {
+ ldbmsg = ldb_msg_new(ac);
+ if (!ldbmsg) {
ret = LDB_ERR_OPERATIONS_ERROR;
- goto error;
+ break;
}
dn = ldap_get_dn(lldb->ldap, msg);
if (!dn) {
+ talloc_free(ldbmsg);
ret = LDB_ERR_OPERATIONS_ERROR;
- goto error;
+ break;
}
- ares->message->dn = ldb_dn_new(ares->message, ac->lldb->module->ldb, dn);
- if ( ! ldb_dn_validate(ares->message->dn)) {
+ ldbmsg->dn = ldb_dn_new(ldbmsg, ac->module->ldb, dn);
+ if ( ! ldb_dn_validate(ldbmsg->dn)) {
+ talloc_free(ldbmsg);
ret = LDB_ERR_OPERATIONS_ERROR;
- goto error;
+ break;
}
ldap_memfree(dn);
- ares->message->num_elements = 0;
- ares->message->elements = NULL;
+ ldbmsg->num_elements = 0;
+ ldbmsg->elements = NULL;
/* loop over all attributes */
for (attr=ldap_first_attribute(lldb->ldap, msg, &berptr);
@@ -534,97 +509,104 @@ static int lldb_parse_result(struct lldb_context *ac, LDAPMessage *result)
bval = ldap_get_values_len(lldb->ldap, msg, attr);
if (bval) {
- lldb_add_msg_attr(ac->lldb->module->ldb, ares->message, attr, bval);
+ lldb_add_msg_attr(ac->module->ldb, ldbmsg, attr, bval);
ldap_value_free_len(bval);
- }
+ }
}
if (berptr) ber_free(berptr, 0);
+ ret = ldb_module_send_entry(ac->req, ldbmsg);
+ if (ret != LDB_SUCCESS) {
- ares->type = LDB_REPLY_ENTRY;
- ret = ac->callback(ac->lldb->module->ldb, ac->context, ares);
+ callback_failed = true;
+ }
} else {
- handle->status = LDB_ERR_PROTOCOL_ERROR;
- handle->state = LDB_ASYNC_DONE;
+ ret = LDB_ERR_OPERATIONS_ERROR;
}
break;
case LDAP_RES_SEARCH_REFERENCE:
- if (ldap_parse_result(lldb->ldap, result, &handle->status,
+
+ if (ldap_parse_result(lldb->ldap, result, &ret,
&matcheddnp, &errmsgp,
&referralsp, &serverctrlsp, 0) != LDAP_SUCCESS) {
ret = LDB_ERR_OPERATIONS_ERROR;
- goto error;
}
- if (referralsp == NULL) {
- handle->status = LDB_ERR_PROTOCOL_ERROR;
- goto error;
+ if (ret != LDB_SUCCESS) {
+ break;
}
-
- ares = talloc_zero(ac, struct ldb_reply);
- if (!ares) {
- ret = LDB_ERR_OPERATIONS_ERROR;
- goto error;
+ if (referralsp == NULL) {
+ ret = LDB_ERR_PROTOCOL_ERROR;
+ break;
}
- ares->referral = talloc_strdup(ares, *referralsp);
- ares->type = LDB_REPLY_REFERRAL;
- ret = ac->callback(ac->lldb->module->ldb, ac->context, ares);
+ for (i = 0; referralsp[i]; i++) {
+ referral = talloc_strdup(ac, referralsp[i]);
+ ret = ldb_module_send_referral(ac->req, referral);
+ if (ret != LDB_SUCCESS) {
+ callback_failed = true;
+ break;
+ }
+ }
break;
case LDAP_RES_SEARCH_RESULT:
- if (ldap_parse_result(lldb->ldap, result, &handle->status,
+ case LDAP_RES_MODIFY:
+ case LDAP_RES_ADD:
+ case LDAP_RES_DELETE:
+ case LDAP_RES_MODDN:
+
+ if (ldap_parse_result(lldb->ldap, result, &ret,
&matcheddnp, &errmsgp,
&referralsp, &serverctrlsp, 0) != LDAP_SUCCESS) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- goto error;
- }
-
- ares = talloc_zero(ac, struct ldb_reply);
- if (!ares) {
ret = LDB_ERR_OPERATIONS_ERROR;
- goto error;
+ }
+ if (ret != LDB_SUCCESS) {
+ break;
}
if (serverctrlsp != NULL) {
/* FIXME: transform the LDAPControl list into an ldb_control one */
- ares->controls = NULL;
+ ac->controls = NULL;
}
-
- ares->type = LDB_REPLY_DONE;
- handle->state = LDB_ASYNC_DONE;
- ret = ac->callback(ac->lldb->module->ldb, ac->context, ares);
-
- break;
- case LDAP_RES_MODIFY:
- case LDAP_RES_ADD:
- case LDAP_RES_DELETE:
- case LDAP_RES_MODDN:
- if (ldap_parse_result(lldb->ldap, result, &handle->status,
- &matcheddnp, &errmsgp,
- &referralsp, &serverctrlsp, 0) != LDAP_SUCCESS) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- goto error;
- }
- if (ac->callback && handle->status == LDB_SUCCESS) {
- ares = NULL; /* FIXME: build a corresponding ares to pass on */
- ret = ac->callback(ac->lldb->module->ldb, ac->context, ares);
- }
- handle->state = LDB_ASYNC_DONE;
+ request_done = true;
break;
default:
ret = LDB_ERR_PROTOCOL_ERROR;
- goto error;
+ break;
}
+ if (ret != LDB_SUCCESS) {
+
+ /* if the callback failed the caller will have freed the
+ * request. Just return and don't try to use it */
+ if (callback_failed) {
+
+ /* tell lldb_wait to remove the request from the
+ * queue */
+ lret = true;
+ goto free_and_return;
+ }
+
+ request_done = true;
+ }
+
+ if (request_done) {
+ lldb_request_done(ac->req, ac->controls, ret);
+ lret = true;
+ goto free_and_return;
+ }
+
+ lret = false;
+
+free_and_return:
+
if (matcheddnp) ldap_memfree(matcheddnp);
if (errmsgp && *errmsgp) {
- ldb_set_errstring(ac->lldb->module->ldb, errmsgp);
- } else if (handle->status) {
- ldb_set_errstring(ac->lldb->module->ldb, ldap_err2string(handle->status));
+ ldb_set_errstring(ac->module->ldb, errmsgp);
}
if (errmsgp) {
ldap_memfree(errmsgp);
@@ -633,131 +615,203 @@ static int lldb_parse_result(struct lldb_context *ac, LDAPMessage *result)
if (serverctrlsp) ldap_controls_free(serverctrlsp);
ldap_msgfree(result);
- return lldb_ldap_to_ldb(handle->status);
-error:
- handle->state = LDB_ASYNC_DONE;
- ldap_msgfree(result);
- return ret;
+ return lret;
}
-static int lldb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
+static void lldb_timeout(struct event_context *ev,
+ struct timed_event *te,
+ struct timeval t,
+ void *private_data)
{
- struct lldb_context *ac = talloc_get_type(handle->private_data, struct lldb_context);
- struct lldb_private *lldb = ac->lldb;
- struct timeval timeout;
+ struct lldb_context *ac;
+ ac = talloc_get_type(private_data, struct lldb_context);
+
+ lldb_request_done(ac->req, NULL, LDB_ERR_TIME_LIMIT_EXCEEDED);
+}
+
+static void lldb_callback(struct event_context *ev,
+ struct timed_event *te,
+ struct timeval t,
+ void *private_data)
+{
+ struct lldb_context *ac;
+ struct timed_event *lte;
+ struct timeval tv;
LDAPMessage *result;
- int ret, lret;
+ int lret;
+
+ ac = talloc_get_type(private_data, struct lldb_context);
- if (handle->state == LDB_ASYNC_DONE) {
- return handle->status;
+ if (!ac->msgid) {
+ lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR);
+ return;
}
- if (!ac || !ac->msgid) {
- return LDB_ERR_OPERATIONS_ERROR;
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ lret = ldap_result(ac->lldb->ldap, ac->msgid, 0, &tv, &result);
+ if (lret == 0) {
+ goto respin;
+ }
+ if (lret == -1) {
+ lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR);
+ return;
}
- handle->state = LDB_ASYNC_PENDING;
- handle->status = LDB_SUCCESS;
+ if ( ! lldb_parse_result(ac, result)) {
+ goto respin;
+ }
- switch(type) {
- case LDB_WAIT_NONE:
+ return;
- if ((ac->timeout != -1) &&
- ((ac->starttime + ac->timeout) > time(NULL))) {
- return LDB_ERR_TIME_LIMIT_EXCEEDED;
- }
+respin:
+ tv.tv_sec = 0;
+ tv.tv_usec = 100;
+ lte = event_add_timed(ev, ac, tv, lldb_callback, ac);
+ if (NULL == lte) {
+ lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR);
+ }
+}
- timeout.tv_sec = 0;
- timeout.tv_usec = 0;
+static bool lldb_dn_is_special(struct ldb_request *req)
+{
+ struct ldb_dn *dn = NULL;
- lret = ldap_result(lldb->ldap, ac->msgid, 0, &timeout, &result);
- if (lret == -1) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
- if (lret == 0) {
- ret = LDB_SUCCESS;
- goto done;
- }
+ switch (req->operation) {
+ case LDB_ADD:
+ dn = req->op.add.message->dn;
+ break;
+ case LDB_MODIFY:
+ dn = req->op.mod.message->dn;
+ break;
+ case LDB_DELETE:
+ dn = req->op.del.dn;
+ break;
+ case LDB_RENAME:
+ dn = req->op.rename.olddn;
+ break;
+ default:
+ break;
+ }
- return lldb_parse_result(ac, result);
+ if (dn && ldb_dn_is_special(dn)) {
+ return true;
+ }
+ return false;
+}
- case LDB_WAIT_ALL:
- timeout.tv_usec = 0;
- ret = LDB_ERR_OPERATIONS_ERROR;
+static void lldb_auto_done_callback(struct event_context *ev,
+ struct timed_event *te,
+ struct timeval t,
+ void *private_data)
+{
+ struct lldb_context *ac;
- while (handle->status == LDB_SUCCESS && handle->state != LDB_ASYNC_DONE) {
+ ac = talloc_get_type(private_data, struct lldb_context);
+ lldb_request_done(ac->req, NULL, LDB_SUCCESS);
+}
- if (ac->timeout == -1) {
- lret = ldap_result(lldb->ldap, ac->msgid, 0, NULL, &result);
- } else {
- timeout.tv_sec = ac->timeout - (time(NULL) - ac->starttime);
- if (timeout.tv_sec <= 0)
- return LDB_ERR_TIME_LIMIT_EXCEEDED;
- lret = ldap_result(lldb->ldap, ac->msgid, 0, &timeout, &result);
- }
- if (lret == -1) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
- if (lret == 0) {
- return LDB_ERR_TIME_LIMIT_EXCEEDED;
- }
+static int lldb_handle_request(struct ldb_module *module, struct ldb_request *req)
+{
+ struct lldb_private *lldb;
+ struct lldb_context *ac;
+ struct event_context *ev;
+ struct timed_event *te;
+ struct timeval tv;
+ int ret;
- ret = lldb_parse_result(ac, result);
- if (ret != LDB_SUCCESS) {
- return ret;
- }
+ lldb = talloc_get_type(module->private_data, struct lldb_private);
+
+ if (req->starttime == 0 || req->timeout == 0) {
+ ldb_set_errstring(module->ldb, "Invalid timeout settings");
+ return LDB_ERR_TIME_LIMIT_EXCEEDED;
+ }
+
+ ev = ldb_get_event_context(module->ldb);
+ if (NULL == ev) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ ac = talloc_zero(module->ldb, struct lldb_context);
+ if (ac == NULL) {
+ ldb_set_errstring(module->ldb, "Out of Memory");
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ ac->module = module;
+ ac->req = req;
+ ac->lldb = lldb;
+ ac->msgid = 0;
+
+ if (lldb_dn_is_special(req)) {
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ te = event_add_timed(ev, ac, tv,
+ lldb_auto_done_callback, ac);
+ if (NULL == te) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
+ return LDB_SUCCESS;
+ }
+
+ switch (ac->req->operation) {
+ case LDB_SEARCH:
+ ret = lldb_search(ac);
+ break;
+ case LDB_ADD:
+ ret = lldb_add(ac);
+ break;
+ case LDB_MODIFY:
+ ret = lldb_modify(ac);
+ break;
+ case LDB_DELETE:
+ ret = lldb_delete(ac);
+ break;
+ case LDB_RENAME:
+ ret = lldb_rename(ac);
break;
-
default:
- handle->state = LDB_ASYNC_DONE;
+ /* no other op supported */
ret = LDB_ERR_OPERATIONS_ERROR;
+ break;
}
-done:
- return ret;
-}
-
-static int lldb_start_trans(struct ldb_module *module)
-{
- /* TODO implement a local transaction mechanism here */
-
- return LDB_SUCCESS;
-}
+ if (ret != LDB_SUCCESS) {
+ lldb_request_done(req, NULL, ret);
+ return ret;
+ }
-static int lldb_end_trans(struct ldb_module *module)
-{
- /* TODO implement a local transaction mechanism here */
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ te = event_add_timed(ev, ac, tv, lldb_callback, ac);
+ if (NULL == te) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
- return LDB_SUCCESS;
-}
-static int lldb_del_trans(struct ldb_module *module)
-{
- /* TODO implement a local transaction mechanism here */
+ tv.tv_sec = req->starttime + req->timeout;
+ tv.tv_usec = 0;
+ te = event_add_timed(ev, ac, tv, lldb_timeout, ac);
+ if (NULL == te) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
return LDB_SUCCESS;
}
-static int lldb_request(struct ldb_module *module, struct ldb_request *req)
-{
- return LDB_ERR_OPERATIONS_ERROR;
-}
-
static const struct ldb_module_ops lldb_ops = {
.name = "ldap",
- .search = lldb_search,
- .add = lldb_add,
- .modify = lldb_modify,
- .del = lldb_delete,
- .rename = lldb_rename,
- .request = lldb_request,
+ .search = lldb_handle_request,
+ .add = lldb_handle_request,
+ .modify = lldb_handle_request,
+ .del = lldb_handle_request,
+ .rename = lldb_handle_request,
+ .request = lldb_handle_request,
.start_transaction = lldb_start_trans,
.end_transaction = lldb_end_trans,
.del_transaction = lldb_del_trans,
- .wait = lldb_wait
};
@@ -771,8 +825,8 @@ static int lldb_destructor(struct lldb_private *lldb)
connect to the database
*/
static int lldb_connect(struct ldb_context *ldb,
- const char *url,
- unsigned int flags,
+ const char *url,
+ unsigned int flags,
const char *options[],
struct ldb_module **_module)
{
@@ -790,7 +844,6 @@ static int lldb_connect(struct ldb_context *ldb,
talloc_set_name_const(module, "ldb_ldap backend");
module->ldb = ldb;
module->prev = module->next = NULL;
- module->private_data = NULL;
module->ops = &lldb_ops;
lldb = talloc(module, struct lldb_private);
@@ -799,7 +852,6 @@ static int lldb_connect(struct ldb_context *ldb,
goto failed;
}
module->private_data = lldb;
- lldb->module = module;
lldb->ldap = NULL;
ret = ldap_initialize(&lldb->ldap, url);
diff --git a/source4/lib/ldb/ldb_map/ldb_map.c b/source4/lib/ldb/ldb_map/ldb_map.c
index b3f639dc67..fafbb63b0a 100644
--- a/source4/lib/ldb/ldb_map/ldb_map.c
+++ b/source4/lib/ldb/ldb_map/ldb_map.c
@@ -3,6 +3,7 @@
Copyright (C) Jelmer Vernooij 2005
Copyright (C) Martin Kuehl <mkhl@samba.org> 2006
+ Copyright (C) Simo Sorce 2008
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
@@ -106,69 +107,23 @@ const struct ldb_map_context *map_get_context(struct ldb_module *module)
}
/* Create a generic request context. */
-static struct map_context *map_init_context(struct ldb_handle *h, struct ldb_request *req)
+struct map_context *map_init_context(struct ldb_module *module,
+ struct ldb_request *req)
{
struct map_context *ac;
- ac = talloc_zero(h, struct map_context);
+ ac = talloc_zero(req, struct map_context);
if (ac == NULL) {
- map_oom(h->module);
+ ldb_set_errstring(module->ldb, "Out of Memory");
return NULL;
}
- ac->module = h->module;
- ac->orig_req = req;
+ ac->module = module;
+ ac->req = req;
return ac;
}
-/* Create a search request context. */
-struct map_search_context *map_init_search_context(struct map_context *ac, struct ldb_reply *ares)
-{
- struct map_search_context *sc;
-
- sc = talloc_zero(ac, struct map_search_context);
- if (sc == NULL) {
- map_oom(ac->module);
- return NULL;
- }
-
- sc->ac = ac;
- sc->local_res = NULL;
- sc->remote_res = ares;
-
- return sc;
-}
-
-/* Create a request context and handle. */
-struct ldb_handle *map_init_handle(struct ldb_request *req, struct ldb_module *module)
-{
- struct map_context *ac;
- struct ldb_handle *h;
-
- h = talloc_zero(req, struct ldb_handle);
- if (h == NULL) {
- map_oom(module);
- return NULL;
- }
-
- h->module = module;
-
- ac = map_init_context(h, req);
- if (ac == NULL) {
- talloc_free(h);
- return NULL;
- }
-
- h->private_data = (void *)ac;
-
- h->state = LDB_ASYNC_INIT;
- h->status = LDB_SUCCESS;
-
- return h;
-}
-
-
/* Dealing with DNs for different partitions
* ========================================= */
@@ -888,113 +843,52 @@ static int map_objectclass_convert_operator(struct ldb_module *module, void *mem
/* Auxiliary request construction
* ============================== */
-/* Store the DN of a single search result in context. */
-static int map_search_self_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
-{
- struct map_context *ac;
-
- if (context == NULL || ares == NULL) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- ac = talloc_get_type(context, struct map_context);
-
- /* We are interested only in the single reply */
- if (ares->type != LDB_REPLY_ENTRY) {
- talloc_free(ares);
- return LDB_SUCCESS;
- }
-
- /* We have already found a remote DN */
- if (ac->local_dn) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "Too many results to base search"));
- talloc_free(ares);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- /* Store local DN */
- ac->local_dn = ares->message->dn;
-
- return LDB_SUCCESS;
-}
-
/* Build a request to search a record by its DN. */
-struct ldb_request *map_search_base_req(struct map_context *ac, struct ldb_dn *dn, const char * const *attrs, const struct ldb_parse_tree *tree, void *context, ldb_search_callback callback)
+struct ldb_request *map_search_base_req(struct map_context *ac, struct ldb_dn *dn, const char * const *attrs, const struct ldb_parse_tree *tree, void *context, ldb_map_callback_t callback)
{
+ const struct ldb_parse_tree *search_tree;
struct ldb_request *req;
-
- req = talloc_zero(ac, struct ldb_request);
- if (req == NULL) {
- map_oom(ac->module);
- return NULL;
- }
-
- req->operation = LDB_SEARCH;
- req->op.search.base = dn;
- req->op.search.scope = LDB_SCOPE_BASE;
- req->op.search.attrs = attrs;
+ int ret;
if (tree) {
- req->op.search.tree = tree;
+ search_tree = tree;
} else {
- req->op.search.tree = ldb_parse_tree(req, NULL);
- if (req->op.search.tree == NULL) {
- talloc_free(req);
+ search_tree = ldb_parse_tree(ac, NULL);
+ if (search_tree == NULL) {
return NULL;
}
}
- req->controls = NULL;
- req->context = context;
- req->callback = callback;
- ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, req);
-
- return req;
-}
-
-/* Build a request to search the local record by its DN. */
-struct ldb_request *map_search_self_req(struct map_context *ac, struct ldb_dn *dn)
-{
- /* attrs[] is returned from this function in
- * ac->search_req->op.search.attrs, so it must be static, as
- * otherwise the compiler can put it on the stack */
- static const char * const attrs[] = { IS_MAPPED, NULL };
- struct ldb_parse_tree *tree;
-
- /* Limit search to records with 'IS_MAPPED' present */
- /* TODO: `tree = ldb_parse_tree(ac, IS_MAPPED);' won't do. */
- tree = talloc_zero(ac, struct ldb_parse_tree);
- if (tree == NULL) {
- map_oom(ac->module);
+ ret = ldb_build_search_req_ex(&req, ac->module->ldb, ac,
+ dn, LDB_SCOPE_BASE,
+ search_tree, attrs,
+ NULL,
+ context, callback,
+ ac->req);
+ if (ret != LDB_SUCCESS) {
return NULL;
}
- tree->operation = LDB_OP_PRESENT;
- tree->u.present.attr = talloc_strdup(tree, IS_MAPPED);
-
- return map_search_base_req(ac, dn, attrs, tree, ac, map_search_self_callback);
+ return req;
}
/* Build a request to update the 'IS_MAPPED' attribute */
-struct ldb_request *map_build_fixup_req(struct map_context *ac, struct ldb_dn *olddn, struct ldb_dn *newdn)
+struct ldb_request *map_build_fixup_req(struct map_context *ac,
+ struct ldb_dn *olddn,
+ struct ldb_dn *newdn,
+ void *context,
+ ldb_map_callback_t callback)
{
struct ldb_request *req;
struct ldb_message *msg;
const char *dn;
-
- /* Prepare request */
- req = talloc_zero(ac, struct ldb_request);
- if (req == NULL) {
- map_oom(ac->module);
- return NULL;
- }
+ int ret;
/* Prepare message */
- msg = ldb_msg_new(req);
+ msg = ldb_msg_new(ac);
if (msg == NULL) {
map_oom(ac->module);
- goto failed;
+ return NULL;
}
/* Update local 'IS_MAPPED' to the new remote DN */
@@ -1010,193 +904,22 @@ struct ldb_request *map_build_fixup_req(struct map_context *ac, struct ldb_dn *o
goto failed;
}
- req->operation = LDB_MODIFY;
- req->op.mod.message = msg;
- req->controls = NULL;
- req->handle = NULL;
- req->context = NULL;
- req->callback = NULL;
+ /* Prepare request */
+ ret = ldb_build_mod_req(&req, ac->module->ldb,
+ ac, msg, NULL,
+ context, callback,
+ ac->req);
+ if (ret != LDB_SUCCESS) {
+ goto failed;
+ }
+ talloc_steal(req, msg);
return req;
-
failed:
- talloc_free(req);
+ talloc_free(msg);
return NULL;
}
-
-/* Asynchronous call structure
- * =========================== */
-
-/* Figure out which request is currently pending. */
-static struct ldb_request *map_get_req(struct map_context *ac)
-{
- switch (ac->step) {
- case MAP_SEARCH_SELF_MODIFY:
- case MAP_SEARCH_SELF_DELETE:
- case MAP_SEARCH_SELF_RENAME:
- return ac->search_req;
-
- case MAP_ADD_REMOTE:
- case MAP_MODIFY_REMOTE:
- case MAP_DELETE_REMOTE:
- case MAP_RENAME_REMOTE:
- return ac->remote_req;
-
- case MAP_RENAME_FIXUP:
- return ac->down_req;
-
- case MAP_ADD_LOCAL:
- case MAP_MODIFY_LOCAL:
- case MAP_DELETE_LOCAL:
- case MAP_RENAME_LOCAL:
- return ac->local_req;
-
- case MAP_SEARCH_REMOTE:
- /* Can't happen */
- break;
- }
-
- return NULL; /* unreachable; silences a warning */
-}
-
-typedef int (*map_next_function)(struct ldb_handle *handle);
-
-/* Figure out the next request to run. */
-static map_next_function map_get_next(struct map_context *ac)
-{
- switch (ac->step) {
- case MAP_SEARCH_REMOTE:
- return NULL;
-
- case MAP_ADD_LOCAL:
- return map_add_do_remote;
- case MAP_ADD_REMOTE:
- return NULL;
-
- case MAP_SEARCH_SELF_MODIFY:
- return map_modify_do_local;
- case MAP_MODIFY_LOCAL:
- return map_modify_do_remote;
- case MAP_MODIFY_REMOTE:
- return NULL;
-
- case MAP_SEARCH_SELF_DELETE:
- return map_delete_do_local;
- case MAP_DELETE_LOCAL:
- return map_delete_do_remote;
- case MAP_DELETE_REMOTE:
- return NULL;
-
- case MAP_SEARCH_SELF_RENAME:
- return map_rename_do_local;
- case MAP_RENAME_LOCAL:
- return map_rename_do_fixup;
- case MAP_RENAME_FIXUP:
- return map_rename_do_remote;
- case MAP_RENAME_REMOTE:
- return NULL;
- }
-
- return NULL; /* unreachable; silences a warning */
-}
-
-/* Wait for the current pending request to finish and continue with the next. */
-static int map_wait_next(struct ldb_handle *handle)
-{
- struct map_context *ac;
- struct ldb_request *req;
- map_next_function next;
- int ret;
-
- if (handle == NULL || handle->private_data == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- if (handle->state == LDB_ASYNC_DONE) {
- return handle->status;
- }
-
- handle->state = LDB_ASYNC_PENDING;
- handle->status = LDB_SUCCESS;
-
- ac = talloc_get_type(handle->private_data, struct map_context);
-
- if (ac->step == MAP_SEARCH_REMOTE) {
- int i;
- for (i = 0; i < ac->num_searches; i++) {
- req = ac->search_reqs[i];
- ret = ldb_wait(req->handle, LDB_WAIT_NONE);
-
- if (ret != LDB_SUCCESS) {
- handle->status = ret;
- goto done;
- }
- if (req->handle->status != LDB_SUCCESS) {
- handle->status = req->handle->status;
- goto done;
- }
- if (req->handle->state != LDB_ASYNC_DONE) {
- return LDB_SUCCESS;
- }
- }
- } else {
-
- req = map_get_req(ac);
-
- ret = ldb_wait(req->handle, LDB_WAIT_NONE);
-
- if (ret != LDB_SUCCESS) {
- handle->status = ret;
- goto done;
- }
- if (req->handle->status != LDB_SUCCESS) {
- handle->status = req->handle->status;
- goto done;
- }
- if (req->handle->state != LDB_ASYNC_DONE) {
- return LDB_SUCCESS;
- }
-
- next = map_get_next(ac);
- if (next) {
- return next(handle);
- }
- }
-
- ret = LDB_SUCCESS;
-
-done:
- handle->state = LDB_ASYNC_DONE;
- return ret;
-}
-
-/* Wait for all current pending requests to finish. */
-static int map_wait_all(struct ldb_handle *handle)
-{
- int ret;
-
- while (handle->state != LDB_ASYNC_DONE) {
- ret = map_wait_next(handle);
- if (ret != LDB_SUCCESS) {
- return ret;
- }
- }
-
- return handle->status;
-}
-
-/* Wait for pending requests to finish. */
-int map_wait(struct ldb_handle *handle, enum ldb_wait_type type)
-{
- if (type == LDB_WAIT_ALL) {
- return map_wait_all(handle);
- } else {
- return map_wait_next(handle);
- }
-}
-
-
/* Module initialization
* ===================== */
@@ -1256,7 +979,7 @@ static int map_init_dns(struct ldb_module *module, struct ldb_map_context *data,
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_search(module->ldb, dn, LDB_SCOPE_BASE, NULL, attrs, &res);
+ ret = ldb_search(module->ldb, data, &res, dn, LDB_SCOPE_BASE, attrs, NULL);
talloc_free(dn);
if (ret != LDB_SUCCESS) {
return ret;
diff --git a/source4/lib/ldb/ldb_map/ldb_map.h b/source4/lib/ldb/ldb_map/ldb_map.h
index e40bb9cd7e..7f92c15b98 100644
--- a/source4/lib/ldb/ldb_map/ldb_map.h
+++ b/source4/lib/ldb/ldb_map/ldb_map.h
@@ -160,14 +160,12 @@ int map_search(struct ldb_module *module, struct ldb_request *req);
int map_rename(struct ldb_module *module, struct ldb_request *req);
int map_delete(struct ldb_module *module, struct ldb_request *req);
int map_modify(struct ldb_module *module, struct ldb_request *req);
-int map_wait(struct ldb_handle *handle, enum ldb_wait_type type);
#define LDB_MAP_OPS \
.add = map_add, \
.modify = map_modify, \
.del = map_delete, \
.rename = map_rename, \
- .search = map_search, \
- .wait = map_wait,
+ .search = map_search,
#endif /* __LDB_MAP_H__ */
diff --git a/source4/lib/ldb/ldb_map/ldb_map_inbound.c b/source4/lib/ldb/ldb_map/ldb_map_inbound.c
index 7fc3ac4ed5..96605f23eb 100644
--- a/source4/lib/ldb/ldb_map/ldb_map_inbound.c
+++ b/source4/lib/ldb/ldb_map/ldb_map_inbound.c
@@ -3,6 +3,7 @@
Copyright (C) Jelmer Vernooij 2005
Copyright (C) Martin Kuehl <mkhl@samba.org> 2006
+ Copyright (C) Simo Sorce <idra@samba.org> 2008
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
@@ -178,51 +179,181 @@ static int ldb_msg_partition(struct ldb_module *module, struct ldb_message *loca
}
-/* Inbound requests: add, modify, rename, delete
- * ============================================= */
+static int map_add_do_local(struct map_context *ac);
+static int map_modify_do_local(struct map_context *ac);
+static int map_delete_do_local(struct map_context *ac);
+static int map_rename_do_local(struct map_context *ac);
+static int map_rename_do_fixup(struct map_context *ac);
+static int map_rename_local_callback(struct ldb_request *req,
+ struct ldb_reply *ares);
-/* Add the remote record. */
-int map_add_do_remote(struct ldb_handle *handle)
+
+/*****************************************************************************
+ * COMMON INBOUND functions
+*****************************************************************************/
+
+/* Store the DN of a single search result in context. */
+static int map_search_self_callback(struct ldb_request *req, struct ldb_reply *ares)
{
struct map_context *ac;
+ int ret;
- ac = talloc_get_type(handle->private_data, struct map_context);
+ ac = talloc_get_type(req->context, struct map_context);
- ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->remote_req);
+ if (!ares) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
+ }
- ac->step = MAP_ADD_REMOTE;
+ /* We are interested only in the single reply */
+ switch(ares->type) {
+ case LDB_REPLY_ENTRY:
+ /* We have already found a remote DN */
+ if (ac->local_dn) {
+ ldb_set_errstring(ac->module->ldb,
+ "Too many results!");
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
- handle->state = LDB_ASYNC_INIT;
- handle->status = LDB_SUCCESS;
+ /* Store local DN */
+ ac->local_dn = talloc_steal(ac, ares->message->dn);
+ break;
- return ldb_next_remote_request(ac->module, ac->remote_req);
+ case LDB_REPLY_DONE:
+
+ switch (ac->req->operation) {
+ case LDB_MODIFY:
+ ret = map_modify_do_local(ac);
+ break;
+ case LDB_DELETE:
+ ret = map_delete_do_local(ac);
+ break;
+ case LDB_RENAME:
+ ret = map_rename_do_local(ac);
+ break;
+ default:
+ /* if we get here we have definitely a problem */
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ }
+ if (ret != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+
+ default:
+ /* ignore referrals */
+ break;
+ }
+
+ talloc_free(ares);
+ return LDB_SUCCESS;
}
-/* Add the local record. */
-int map_add_do_local(struct ldb_handle *handle)
+/* Build a request to search the local record by its DN. */
+static int map_search_self_req(struct ldb_request **req,
+ struct map_context *ac,
+ struct ldb_dn *dn)
+{
+ /* attrs[] is returned from this function in
+ * ac->search_req->op.search.attrs, so it must be static, as
+ * otherwise the compiler can put it on the stack */
+ static const char * const attrs[] = { IS_MAPPED, NULL };
+ struct ldb_parse_tree *tree;
+
+ /* Limit search to records with 'IS_MAPPED' present */
+ tree = ldb_parse_tree(ac, "(" IS_MAPPED "=*)");
+ if (tree == NULL) {
+ map_oom(ac->module);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ *req = map_search_base_req(ac, dn, attrs, tree,
+ ac, map_search_self_callback);
+ if (*req == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ return LDB_SUCCESS;
+}
+
+static int map_op_local_callback(struct ldb_request *req,
+ struct ldb_reply *ares)
{
struct map_context *ac;
+ int ret;
- ac = talloc_get_type(handle->private_data, struct map_context);
+ ac = talloc_get_type(req->context, struct map_context);
- ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->local_req);
+ if (!ares) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
+ }
- ac->step = MAP_ADD_LOCAL;
+ if (ares->type != LDB_REPLY_DONE) {
+ ldb_set_errstring(req->handle->ldb, "Invalid reply type!");
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
- handle->state = LDB_ASYNC_INIT;
- handle->status = LDB_SUCCESS;
+ /* Do the remote request. */
+ ret = ldb_next_remote_request(ac->module, ac->remote_req);
+ if (ret != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
- return ldb_next_request(ac->module, ac->local_req);
+ return LDB_SUCCESS;
}
+static int map_op_remote_callback(struct ldb_request *req,
+ struct ldb_reply *ares)
+{
+ struct map_context *ac;
+
+ ac = talloc_get_type(req->context, struct map_context);
+
+ if (!ares) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
+ }
+
+ if (ares->type != LDB_REPLY_DONE) {
+ ldb_set_errstring(req->handle->ldb, "Invalid reply type!");
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
+}
+
+
+/*****************************************************************************
+ * ADD operations
+*****************************************************************************/
+
+
/* Add a record. */
int map_add(struct ldb_module *module, struct ldb_request *req)
{
const struct ldb_message *msg = req->op.add.message;
- struct ldb_handle *h;
struct map_context *ac;
- struct ldb_message *local, *remote;
+ struct ldb_message *remote_msg;
const char *dn;
+ int ret;
/* Do not manipulate our control entries */
if (ldb_dn_is_special(msg->dn)) {
@@ -240,141 +371,88 @@ int map_add(struct ldb_module *module, struct ldb_request *req)
}
/* Prepare context and handle */
- h = map_init_handle(req, module);
- if (h == NULL) {
+ ac = map_init_context(module, req);
+ if (ac == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(h->private_data, struct map_context);
-
- /* Prepare the local operation */
- ac->local_req = talloc(ac, struct ldb_request);
- if (ac->local_req == NULL) {
- goto oom;
- }
- *(ac->local_req) = *req; /* copy the request */
-
- ac->local_req->context = NULL;
- ac->local_req->callback = NULL;
-
- /* Prepare the remote operation */
- ac->remote_req = talloc(ac, struct ldb_request);
- if (ac->remote_req == NULL) {
- goto oom;
- }
-
- *(ac->remote_req) = *req; /* copy the request */
-
- ac->remote_req->context = NULL;
- ac->remote_req->callback = NULL;
/* Prepare the local message */
- local = ldb_msg_new(ac->local_req);
- if (local == NULL) {
- goto oom;
+ ac->local_msg = ldb_msg_new(ac);
+ if (ac->local_msg == NULL) {
+ map_oom(module);
+ return LDB_ERR_OPERATIONS_ERROR;
}
- local->dn = msg->dn;
+ ac->local_msg->dn = msg->dn;
/* Prepare the remote message */
- remote = ldb_msg_new(ac->remote_req);
- if (remote == NULL) {
- goto oom;
+ remote_msg = ldb_msg_new(ac);
+ if (remote_msg == NULL) {
+ map_oom(module);
+ return LDB_ERR_OPERATIONS_ERROR;
}
- remote->dn = ldb_dn_map_local(ac->module, remote, msg->dn);
+ remote_msg->dn = ldb_dn_map_local(ac->module, remote_msg, msg->dn);
/* Split local from remote message */
- ldb_msg_partition(module, local, remote, msg);
- ac->local_req->op.add.message = local;
- ac->remote_req->op.add.message = remote;
+ ldb_msg_partition(module, ac->local_msg, remote_msg, msg);
+
+ /* Prepare the remote operation */
+ ret = ldb_build_add_req(&ac->remote_req, module->ldb,
+ ac, remote_msg,
+ req->controls,
+ ac, map_op_remote_callback,
+ req);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
- if ((local->num_elements == 0) || (!map_check_local_db(ac->module))) {
+ if ((ac->local_msg->num_elements == 0) ||
+ ( ! map_check_local_db(ac->module))) {
/* No local data or db, just run the remote request */
- talloc_free(ac->local_req);
- req->handle = h; /* return our own handle to deal with this call */
- return map_add_do_remote(h);
+ return ldb_next_remote_request(ac->module, ac->remote_req);
}
/* Store remote DN in 'IS_MAPPED' */
/* TODO: use GUIDs here instead */
- dn = ldb_dn_alloc_linearized(local, remote->dn);
- if (ldb_msg_add_string(local, IS_MAPPED, dn) != 0) {
- goto failed;
+ dn = ldb_dn_alloc_linearized(ac->local_msg, remote_msg->dn);
+ if (ldb_msg_add_string(ac->local_msg, IS_MAPPED, dn) != 0) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- req->handle = h; /* return our own handle to deal with this call */
- return map_add_do_local(h);
-
-oom:
- map_oom(module);
-failed:
- talloc_free(h);
- return LDB_ERR_OPERATIONS_ERROR;
-}
-
-/* Modify the remote record. */
-int map_modify_do_remote(struct ldb_handle *handle)
-{
- struct map_context *ac;
-
- ac = talloc_get_type(handle->private_data, struct map_context);
-
- ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->remote_req);
-
- ac->step = MAP_MODIFY_REMOTE;
-
- handle->state = LDB_ASYNC_INIT;
- handle->status = LDB_SUCCESS;
-
- return ldb_next_remote_request(ac->module, ac->remote_req);
+ return map_add_do_local(ac);
}
-/* Modify the local record. */
-int map_modify_do_local(struct ldb_handle *handle)
+/* Add the local record. */
+static int map_add_do_local(struct map_context *ac)
{
- struct map_context *ac;
- struct ldb_message *msg;
- char *dn;
-
- ac = talloc_get_type(handle->private_data, struct map_context);
-
- if (ac->local_dn == NULL) {
- /* No local record present, add it instead */
- msg = discard_const_p(struct ldb_message, ac->local_req->op.mod.message);
-
- /* Add local 'IS_MAPPED' */
- /* TODO: use GUIDs here instead */
- if (ldb_msg_add_empty(msg, IS_MAPPED, LDB_FLAG_MOD_ADD, NULL) != 0) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
- dn = ldb_dn_alloc_linearized(msg, ac->remote_req->op.mod.message->dn);
- if (ldb_msg_add_string(msg, IS_MAPPED, dn) != 0) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
+ struct ldb_request *local_req;
+ int ret;
- /* Turn request into 'add' */
- ac->local_req->operation = LDB_ADD;
- ac->local_req->op.add.message = msg;
- /* TODO: Could I just leave msg in there? I think so,
- * but it looks clearer this way. */
+ /* Prepare the local operation */
+ ret = ldb_build_add_req(&local_req, ac->module->ldb, ac,
+ ac->local_msg,
+ ac->req->controls,
+ ac,
+ map_op_local_callback,
+ ac->req);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
-
- ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->local_req);
-
- ac->step = MAP_MODIFY_LOCAL;
-
- handle->state = LDB_ASYNC_INIT;
- handle->status = LDB_SUCCESS;
-
- return ldb_next_request(ac->module, ac->local_req);
+ return ldb_next_request(ac->module, local_req);
}
+/*****************************************************************************
+ * MODIFY operations
+*****************************************************************************/
+
/* Modify a record. */
int map_modify(struct ldb_module *module, struct ldb_request *req)
{
const struct ldb_message *msg = req->op.mod.message;
- struct ldb_handle *h;
+ struct ldb_request *search_req;
+ struct ldb_message *remote_msg;
struct map_context *ac;
- struct ldb_message *local, *remote;
+ int ret;
/* Do not manipulate our control entries */
if (ldb_dn_is_special(msg->dn)) {
@@ -395,257 +473,200 @@ int map_modify(struct ldb_module *module, struct ldb_request *req)
}
/* Prepare context and handle */
- h = map_init_handle(req, module);
- if (h == NULL) {
+ ac = map_init_context(module, req);
+ if (ac == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(h->private_data, struct map_context);
-
- /* Prepare the local operation */
- ac->local_req = talloc(ac, struct ldb_request);
- if (ac->local_req == NULL) {
- goto oom;
- }
-
- *(ac->local_req) = *req; /* copy the request */
-
- ac->local_req->context = NULL;
- ac->local_req->callback = NULL;
-
- /* Prepare the remote operation */
- ac->remote_req = talloc(ac, struct ldb_request);
- if (ac->remote_req == NULL) {
- goto oom;
- }
-
- *(ac->remote_req) = *req; /* copy the request */
-
- ac->remote_req->context = NULL;
- ac->remote_req->callback = NULL;
/* Prepare the local message */
- local = ldb_msg_new(ac->local_req);
- if (local == NULL) {
- goto oom;
+ ac->local_msg = ldb_msg_new(ac);
+ if (ac->local_msg == NULL) {
+ map_oom(module);
+ return LDB_ERR_OPERATIONS_ERROR;
}
- local->dn = msg->dn;
+ ac->local_msg->dn = msg->dn;
/* Prepare the remote message */
- remote = ldb_msg_new(ac->remote_req);
- if (remote == NULL) {
- goto oom;
+ remote_msg = ldb_msg_new(ac->remote_req);
+ if (remote_msg == NULL) {
+ map_oom(module);
+ return LDB_ERR_OPERATIONS_ERROR;
}
- remote->dn = ldb_dn_map_local(ac->module, remote, msg->dn);
+ remote_msg->dn = ldb_dn_map_local(ac->module, remote_msg, msg->dn);
/* Split local from remote message */
- ldb_msg_partition(module, local, remote, msg);
- ac->local_req->op.mod.message = local;
- ac->remote_req->op.mod.message = remote;
+ ldb_msg_partition(module, ac->local_msg, remote_msg, msg);
+
+ /* Prepare the remote operation */
+ ret = ldb_build_mod_req(&ac->remote_req, module->ldb,
+ ac, remote_msg,
+ req->controls,
+ ac, map_op_remote_callback,
+ req);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
- if ((local->num_elements == 0) || (!map_check_local_db(ac->module))) {
+ if ((ac->local_msg->num_elements == 0) ||
+ ( ! map_check_local_db(ac->module))) {
/* No local data or db, just run the remote request */
- talloc_free(ac->local_req);
- req->handle = h; /* return our own handle to deal with this call */
- return map_modify_do_remote(h);
+ return ldb_next_remote_request(ac->module, ac->remote_req);
}
/* prepare the search operation */
- ac->search_req = map_search_self_req(ac, msg->dn);
- if (ac->search_req == NULL) {
- goto failed;
+ ret = map_search_self_req(&search_req, ac, msg->dn);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- ac->step = MAP_SEARCH_SELF_MODIFY;
-
- req->handle = h; /* return our own handle to deal with this call */
- return ldb_next_request(module, ac->search_req);
-
-oom:
- map_oom(module);
-failed:
- talloc_free(h);
- return LDB_ERR_OPERATIONS_ERROR;
-}
-
-/* Delete the remote record. */
-int map_delete_do_remote(struct ldb_handle *handle)
-{
- struct map_context *ac;
-
- ac = talloc_get_type(handle->private_data, struct map_context);
-
- ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->remote_req);
-
- ac->step = MAP_DELETE_REMOTE;
-
- handle->state = LDB_ASYNC_INIT;
- handle->status = LDB_SUCCESS;
-
- return ldb_next_remote_request(ac->module, ac->remote_req);
+ return ldb_next_request(module, search_req);
}
-/* Delete the local record. */
-int map_delete_do_local(struct ldb_handle *handle)
+/* Modify the local record. */
+static int map_modify_do_local(struct map_context *ac)
{
- struct map_context *ac;
-
- ac = talloc_get_type(handle->private_data, struct map_context);
+ struct ldb_request *local_req;
+ char *dn;
+ int ret;
- /* No local record, continue remotely */
if (ac->local_dn == NULL) {
- return map_delete_do_remote(handle);
- }
-
- ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->local_req);
-
- ac->step = MAP_DELETE_LOCAL;
+ /* No local record present, add it instead */
+ /* Add local 'IS_MAPPED' */
+ /* TODO: use GUIDs here instead */
+ if (ldb_msg_add_empty(ac->local_msg, IS_MAPPED,
+ LDB_FLAG_MOD_ADD, NULL) != 0) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ dn = ldb_dn_alloc_linearized(ac->local_msg,
+ ac->remote_req->op.mod.message->dn);
+ if (ldb_msg_add_string(ac->local_msg, IS_MAPPED, dn) != 0) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
- handle->state = LDB_ASYNC_INIT;
- handle->status = LDB_SUCCESS;
+ /* Prepare the local operation */
+ ret = ldb_build_add_req(&local_req, ac->module->ldb, ac,
+ ac->local_msg,
+ ac->req->controls,
+ ac,
+ map_op_local_callback,
+ ac->req);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ } else {
+ /* Prepare the local operation */
+ ret = ldb_build_mod_req(&local_req, ac->module->ldb, ac,
+ ac->local_msg,
+ ac->req->controls,
+ ac,
+ map_op_local_callback,
+ ac->req);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ }
- return ldb_next_request(ac->module, ac->local_req);
+ return ldb_next_request(ac->module, local_req);
}
+/*****************************************************************************
+ * DELETE operations
+*****************************************************************************/
+
/* Delete a record. */
int map_delete(struct ldb_module *module, struct ldb_request *req)
{
- struct ldb_handle *h;
+ struct ldb_request *search_req;
struct map_context *ac;
+ int ret;
/* Do not manipulate our control entries */
if (ldb_dn_is_special(req->op.del.dn)) {
return ldb_next_request(module, req);
}
- /* No mapping requested (perhaps no DN mapping specified), skip to next module */
+ /* No mapping requested (perhaps no DN mapping specified).
+ * Skip to next module */
if (!ldb_dn_check_local(module, req->op.del.dn)) {
return ldb_next_request(module, req);
}
/* Prepare context and handle */
- h = map_init_handle(req, module);
- if (h == NULL) {
+ ac = map_init_context(module, req);
+ if (ac == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(h->private_data, struct map_context);
-
- /* Prepare the local operation */
- ac->local_req = talloc(ac, struct ldb_request);
- if (ac->local_req == NULL) {
- goto oom;
- }
-
- *(ac->local_req) = *req; /* copy the request */
- ac->local_req->op.del.dn = req->op.del.dn;
-
- ac->local_req->context = NULL;
- ac->local_req->callback = NULL;
/* Prepare the remote operation */
- ac->remote_req = talloc(ac, struct ldb_request);
- if (ac->remote_req == NULL) {
- goto oom;
+ ret = ldb_build_del_req(&ac->remote_req, module->ldb, ac,
+ ldb_dn_map_local(module, ac, req->op.del.dn),
+ req->controls,
+ ac,
+ map_op_remote_callback,
+ req);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- *(ac->remote_req) = *req; /* copy the request */
- ac->remote_req->op.del.dn = ldb_dn_map_local(module, ac->remote_req, req->op.del.dn);
-
/* No local db, just run the remote request */
if (!map_check_local_db(ac->module)) {
- req->handle = h; /* return our own handle to deal with this call */
- return map_delete_do_remote(h);
+ /* Do the remote request. */
+ return ldb_next_remote_request(ac->module, ac->remote_req);
}
- ac->remote_req->context = NULL;
- ac->remote_req->callback = NULL;
-
/* Prepare the search operation */
- ac->search_req = map_search_self_req(ac, req->op.del.dn);
- if (ac->search_req == NULL) {
- goto failed;
+ ret = map_search_self_req(&search_req, ac, req->op.del.dn);
+ if (ret != LDB_SUCCESS) {
+ map_oom(module);
+ return LDB_ERR_OPERATIONS_ERROR;
}
- req->handle = h; /* return our own handle to deal with this call */
-
- ac->step = MAP_SEARCH_SELF_DELETE;
-
- return ldb_next_request(module, ac->search_req);
-
-oom:
- map_oom(module);
-failed:
- talloc_free(h);
- return LDB_ERR_OPERATIONS_ERROR;
+ return ldb_next_request(module, search_req);
}
-/* Rename the remote record. */
-int map_rename_do_remote(struct ldb_handle *handle)
-{
- struct map_context *ac;
-
- ac = talloc_get_type(handle->private_data, struct map_context);
-
- ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->remote_req);
-
- ac->step = MAP_RENAME_REMOTE;
-
- handle->state = LDB_ASYNC_INIT;
- handle->status = LDB_SUCCESS;
-
- return ldb_next_remote_request(ac->module, ac->remote_req);
-}
-
-/* Update the local 'IS_MAPPED' attribute. */
-int map_rename_do_fixup(struct ldb_handle *handle)
-{
- struct map_context *ac;
-
- ac = talloc_get_type(handle->private_data, struct map_context);
-
- ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->down_req);
-
- ac->step = MAP_RENAME_FIXUP;
-
- handle->state = LDB_ASYNC_INIT;
- handle->status = LDB_SUCCESS;
-
- return ldb_next_request(ac->module, ac->down_req);
-}
-
-/* Rename the local record. */
-int map_rename_do_local(struct ldb_handle *handle)
+/* Delete the local record. */
+static int map_delete_do_local(struct map_context *ac)
{
- struct map_context *ac;
-
- ac = talloc_get_type(handle->private_data, struct map_context);
+ struct ldb_request *local_req;
+ int ret;
/* No local record, continue remotely */
if (ac->local_dn == NULL) {
- return map_rename_do_remote(handle);
+ /* Do the remote request. */
+ return ldb_next_remote_request(ac->module, ac->remote_req);
}
- ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->local_req);
-
- ac->step = MAP_RENAME_LOCAL;
-
- handle->state = LDB_ASYNC_INIT;
- handle->status = LDB_SUCCESS;
-
- return ldb_next_request(ac->module, ac->local_req);
+ /* Prepare the local operation */
+ ret = ldb_build_del_req(&local_req, ac->module->ldb, ac,
+ ac->req->op.del.dn,
+ ac->req->controls,
+ ac,
+ map_op_local_callback,
+ ac->req);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ return ldb_next_request(ac->module, local_req);
}
+/*****************************************************************************
+ * RENAME operations
+*****************************************************************************/
+
/* Rename a record. */
int map_rename(struct ldb_module *module, struct ldb_request *req)
{
- struct ldb_handle *h;
+ struct ldb_request *search_req;
struct map_context *ac;
+ int ret;
/* Do not manipulate our control entries */
if (ldb_dn_is_special(req->op.rename.olddn)) {
return ldb_next_request(module, req);
}
- /* No mapping requested (perhaps no DN mapping specified), skip to next module */
+ /* No mapping requested (perhaps no DN mapping specified).
+ * Skip to next module */
if ((!ldb_dn_check_local(module, req->op.rename.olddn)) &&
(!ldb_dn_check_local(module, req->op.rename.newdn))) {
return ldb_next_request(module, req);
@@ -658,66 +679,113 @@ int map_rename(struct ldb_module *module, struct ldb_request *req)
}
/* Prepare context and handle */
- h = map_init_handle(req, module);
- if (h == NULL) {
+ ac = map_init_context(module, req);
+ if (ac == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(h->private_data, struct map_context);
- /* Prepare the local operation */
- ac->local_req = talloc(ac, struct ldb_request);
- if (ac->local_req == NULL) {
- goto oom;
+ /* Prepare the remote operation */
+ ret = ldb_build_rename_req(&ac->remote_req, module->ldb, ac,
+ ldb_dn_map_local(module, ac, req->op.rename.olddn),
+ ldb_dn_map_local(module, ac, req->op.rename.newdn),
+ req->controls,
+ ac, map_op_remote_callback,
+ req);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- *(ac->local_req) = *req; /* copy the request */
- ac->local_req->op.rename.olddn = req->op.rename.olddn;
- ac->local_req->op.rename.newdn = req->op.rename.newdn;
+ /* No local db, just run the remote request */
+ if (!map_check_local_db(ac->module)) {
+ /* Do the remote request. */
+ return ldb_next_remote_request(ac->module, ac->remote_req);
+ }
- ac->local_req->context = NULL;
- ac->local_req->callback = NULL;
+ /* Prepare the search operation */
+ ret = map_search_self_req(&search_req, ac, req->op.rename.olddn);
+ if (ret != LDB_SUCCESS) {
+ map_oom(module);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
- /* Prepare the remote operation */
- ac->remote_req = talloc(ac, struct ldb_request);
- if (ac->remote_req == NULL) {
- goto oom;
+ return ldb_next_request(module, search_req);
+}
+
+/* Rename the local record. */
+static int map_rename_do_local(struct map_context *ac)
+{
+ struct ldb_request *local_req;
+ int ret;
+
+ /* No local record, continue remotely */
+ if (ac->local_dn == NULL) {
+ /* Do the remote request. */
+ return ldb_next_remote_request(ac->module, ac->remote_req);
}
- *(ac->remote_req) = *req; /* copy the request */
- ac->remote_req->op.rename.olddn = ldb_dn_map_local(module, ac->remote_req, req->op.rename.olddn);
- ac->remote_req->op.rename.newdn = ldb_dn_map_local(module, ac->remote_req, req->op.rename.newdn);
+ /* Prepare the local operation */
+ ret = ldb_build_rename_req(&local_req, ac->module->ldb, ac,
+ ac->req->op.rename.olddn,
+ ac->req->op.rename.newdn,
+ ac->req->controls,
+ ac,
+ map_rename_local_callback,
+ ac->req);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
- ac->remote_req->context = NULL;
- ac->remote_req->callback = NULL;
+ return ldb_next_request(ac->module, local_req);
+}
- /* No local db, just run the remote request */
- if (!map_check_local_db(ac->module)) {
- req->handle = h; /* return our own handle to deal with this call */
- return map_rename_do_remote(h);
+static int map_rename_local_callback(struct ldb_request *req,
+ struct ldb_reply *ares)
+{
+ struct map_context *ac;
+ int ret;
+
+ ac = talloc_get_type(req->context, struct map_context);
+
+ if (!ares) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
}
- /* Prepare the fixup operation */
- /* TODO: use GUIDs here instead -- or skip it when GUIDs are used. */
- ac->down_req = map_build_fixup_req(ac, req->op.rename.newdn, ac->remote_req->op.rename.newdn);
- if (ac->down_req == NULL) {
- goto failed;
+ if (ares->type != LDB_REPLY_DONE) {
+ ldb_set_errstring(req->handle->ldb, "Invalid reply type!");
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
}
- /* Prepare the search operation */
- ac->search_req = map_search_self_req(ac, req->op.rename.olddn);
- if (ac->search_req == NULL) {
- goto failed;
+ /* proceed with next step */
+ ret = map_rename_do_fixup(ac);
+ if (ret != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
}
- req->handle = h; /* return our own handle to deal with this call */
+ return LDB_SUCCESS;
+}
- ac->step = MAP_SEARCH_SELF_RENAME;
+/* Update the local 'IS_MAPPED' attribute. */
+static int map_rename_do_fixup(struct map_context *ac)
+{
+ struct ldb_request *local_req;
- return ldb_next_request(module, ac->search_req);
+ /* Prepare the fixup operation */
+ /* TODO: use GUIDs here instead -- or skip it when GUIDs are used. */
+ local_req = map_build_fixup_req(ac,
+ ac->req->op.rename.newdn,
+ ac->remote_req->op.rename.newdn,
+ ac,
+ map_op_local_callback);
+ if (local_req == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
-oom:
- map_oom(module);
-failed:
- talloc_free(h);
- return LDB_ERR_OPERATIONS_ERROR;
+ return ldb_next_request(ac->module, local_req);
}
diff --git a/source4/lib/ldb/ldb_map/ldb_map_outbound.c b/source4/lib/ldb/ldb_map/ldb_map_outbound.c
index fbc097f313..5f524a8be3 100644
--- a/source4/lib/ldb/ldb_map/ldb_map_outbound.c
+++ b/source4/lib/ldb/ldb_map/ldb_map_outbound.c
@@ -4,6 +4,7 @@
Copyright (C) Jelmer Vernooij 2005
Copyright (C) Martin Kuehl <mkhl@samba.org> 2006
Copyright (C) Andrew Bartlett <abartlet@samba.org> 2006
+ Copyright (C) Simo Sorce <idra@samba.org> 2008
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
@@ -905,7 +906,11 @@ static int map_subtree_collect_remote(struct ldb_module *module, void *mem_ctx,
/* Split subtrees that query attributes in the local partition from
* those that query the remote partition. */
-static int ldb_parse_tree_partition(struct ldb_module *module, void *local_ctx, void *remote_ctx, struct ldb_parse_tree **local_tree, struct ldb_parse_tree **remote_tree, const struct ldb_parse_tree *tree)
+static int ldb_parse_tree_partition(struct ldb_module *module,
+ void *mem_ctx,
+ struct ldb_parse_tree **local_tree,
+ struct ldb_parse_tree **remote_tree,
+ const struct ldb_parse_tree *tree)
{
int ret;
@@ -918,13 +923,13 @@ static int ldb_parse_tree_partition(struct ldb_module *module, void *local_ctx,
}
/* Generate local tree */
- ret = map_subtree_select_local(module, local_ctx, local_tree, tree);
+ ret = map_subtree_select_local(module, mem_ctx, local_tree, tree);
if (ret) {
return ret;
}
/* Generate remote tree */
- ret = map_subtree_collect_remote(module, remote_ctx, remote_tree, tree);
+ ret = map_subtree_collect_remote(module, mem_ctx, remote_tree, tree);
if (ret) {
talloc_free(*local_tree);
return ret;
@@ -1008,24 +1013,46 @@ oom:
/* Outbound requests: search
* ========================= */
-/* Pass a merged search result up the callback chain. */
-int map_up_callback(struct ldb_context *ldb, const struct ldb_request *req, struct ldb_reply *ares)
+static int map_remote_search_callback(struct ldb_request *req,
+ struct ldb_reply *ares);
+static int map_local_merge_callback(struct ldb_request *req,
+ struct ldb_reply *ares);
+static int map_search_local(struct map_context *ac);
+
+static int map_save_entry(struct map_context *ac, struct ldb_reply *ares)
{
- int i;
+ struct map_reply *mr;
- /* No callback registered, stop */
- if (req->callback == NULL) {
- return LDB_SUCCESS;
+ mr = talloc_zero(ac, struct map_reply);
+ if (mr == NULL) {
+ map_oom(ac->module);
+ return LDB_ERR_OPERATIONS_ERROR;
}
-
- /* Only records need special treatment */
- if (ares->type != LDB_REPLY_ENTRY) {
- return req->callback(ldb, req->context, ares);
+ mr->remote = talloc_steal(mr, ares);
+ if (ac->r_current) {
+ ac->r_current->next = mr;
+ } else {
+ /* first entry */
+ ac->r_list = mr;
}
+ ac->r_current = mr;
+
+ return LDB_SUCCESS;
+}
+
+/* Pass a merged search result up the callback chain. */
+int map_return_entry(struct map_context *ac, struct ldb_reply *ares)
+{
+ struct ldb_message_element *el;
+ const char * const *attrs;
+ int i;
/* Merged result doesn't match original query, skip */
- if (!ldb_match_msg(ldb, ares->message, req->op.search.tree, req->op.search.base, req->op.search.scope)) {
- ldb_debug(ldb, LDB_DEBUG_TRACE, "ldb_map: "
+ if (!ldb_match_msg(ac->module->ldb, ares->message,
+ ac->req->op.search.tree,
+ ac->req->op.search.base,
+ ac->req->op.search.scope)) {
+ ldb_debug(ac->module->ldb, LDB_DEBUG_TRACE, "ldb_map: "
"Skipping record '%s': "
"doesn't match original search\n",
ldb_dn_get_linearized(ares->message->dn));
@@ -1033,10 +1060,16 @@ int map_up_callback(struct ldb_context *ldb, const struct ldb_request *req, stru
}
/* Limit result to requested attrs */
- if ((req->op.search.attrs) && (!ldb_attr_in_list(req->op.search.attrs, "*"))) {
- for (i = 0; i < ares->message->num_elements; ) {
- struct ldb_message_element *el = &ares->message->elements[i];
- if (!ldb_attr_in_list(req->op.search.attrs, el->name)) {
+ if (ac->req->op.search.attrs &&
+ (! ldb_attr_in_list(ac->req->op.search.attrs, "*"))) {
+
+ attrs = ac->req->op.search.attrs;
+ i = 0;
+
+ while (i < ares->message->num_elements) {
+
+ el = &ares->message->elements[i];
+ if ( ! ldb_attr_in_list(attrs, el->name)) {
ldb_msg_remove_element(ares->message, el);
} else {
i++;
@@ -1044,129 +1077,16 @@ int map_up_callback(struct ldb_context *ldb, const struct ldb_request *req, stru
}
}
- return req->callback(ldb, req->context, ares);
-}
-
-/* Merge the remote and local parts of a search result. */
-int map_local_merge_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
-{
- struct map_search_context *sc;
- int ret;
-
- if (context == NULL || ares == NULL) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "ldb_map: "
- "NULL Context or Result in `map_local_merge_callback`"));
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- sc = talloc_get_type(context, struct map_search_context);
-
- switch (ares->type) {
- case LDB_REPLY_ENTRY:
- /* We have already found a local record */
- if (sc->local_res) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "ldb_map: "
- "Too many results to base search for local entry"));
- talloc_free(ares);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- /* Store local result */
- sc->local_res = ares;
-
- /* Merge remote into local message */
- ret = ldb_msg_merge_local(sc->ac->module, ares->message, sc->remote_res->message);
- if (ret) {
- talloc_free(ares);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- return map_up_callback(ldb, sc->ac->orig_req, ares);
-
- case LDB_REPLY_DONE:
- /* No local record found, continue with remote record */
- if (sc->local_res == NULL) {
- return map_up_callback(ldb, sc->ac->orig_req, sc->remote_res);
- }
- return LDB_SUCCESS;
-
- default:
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "ldb_map: "
- "Unexpected result type in base search for local entry"));
- talloc_free(ares);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-}
-
-/* Search the local part of a remote search result. */
-int map_remote_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
-{
- struct map_context *ac;
- struct map_search_context *sc;
- struct ldb_request *req;
- int ret;
-
- if (context == NULL || ares == NULL) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "ldb_map: "
- "NULL Context or Result in `map_remote_search_callback`"));
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- ac = talloc_get_type(context, struct map_context);
-
- /* It's not a record, stop searching */
- if (ares->type != LDB_REPLY_ENTRY) {
- return map_up_callback(ldb, ac->orig_req, ares);
- }
-
- /* Map result record into a local message */
- ret = map_reply_remote(ac, ares);
- if (ret) {
- talloc_free(ares);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- /* There is no local db, stop searching */
- if (!map_check_local_db(ac->module)) {
- return map_up_callback(ldb, ac->orig_req, ares);
- }
-
- /* Prepare local search context */
- sc = map_init_search_context(ac, ares);
- if (sc == NULL) {
- talloc_free(ares);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- /* Prepare local search request */
- /* TODO: use GUIDs here instead? */
-
- ac->search_reqs = talloc_realloc(ac, ac->search_reqs, struct ldb_request *, ac->num_searches + 2);
- if (ac->search_reqs == NULL) {
- talloc_free(ares);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- ac->search_reqs[ac->num_searches]
- = req = map_search_base_req(ac, ares->message->dn,
- NULL, NULL, sc, map_local_merge_callback);
- if (req == NULL) {
- talloc_free(sc);
- talloc_free(ares);
- return LDB_ERR_OPERATIONS_ERROR;
- }
- ac->num_searches++;
- ac->search_reqs[ac->num_searches] = NULL;
-
- return ldb_next_request(ac->module, req);
+ return ldb_module_send_entry(ac->req, ares->message);
}
/* Search a record. */
int map_search(struct ldb_module *module, struct ldb_request *req)
{
- struct ldb_handle *h;
+ struct ldb_parse_tree *remote_tree;
+ struct ldb_parse_tree *local_tree;
+ struct ldb_request *remote_req;
struct map_context *ac;
- struct ldb_parse_tree *local_tree, *remote_tree;
int ret;
const char *wildcard[] = { "*", NULL };
@@ -1176,8 +1096,9 @@ int map_search(struct ldb_module *module, struct ldb_request *req)
return ldb_next_request(module, req);
/* Do not manipulate our control entries */
- if (ldb_dn_is_special(req->op.search.base))
+ if (ldb_dn_is_special(req->op.search.base)) {
return ldb_next_request(module, req);
+ }
/* No mapping requested, skip to next module */
if ((req->op.search.base) && (!ldb_dn_check_local(module, req->op.search.base))) {
@@ -1188,32 +1109,10 @@ int map_search(struct ldb_module *module, struct ldb_request *req)
* targetting when there is no search base? */
/* Prepare context and handle */
- h = map_init_handle(req, module);
- if (h == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
- ac = talloc_get_type(h->private_data, struct map_context);
-
- ac->search_reqs = talloc_array(ac, struct ldb_request *, 2);
- if (ac->search_reqs == NULL) {
- talloc_free(h);
+ ac = map_init_context(module, req);
+ if (ac == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac->num_searches = 1;
- ac->search_reqs[1] = NULL;
-
- /* Prepare the remote operation */
- ac->search_reqs[0] = talloc(ac, struct ldb_request);
- if (ac->search_reqs[0] == NULL) {
- goto oom;
- }
-
- *(ac->search_reqs[0]) = *req; /* copy the request */
-
- ac->search_reqs[0]->handle = h; /* return our own handle to deal with this call */
-
- ac->search_reqs[0]->context = ac;
- ac->search_reqs[0]->callback = map_remote_search_callback;
/* It is easier to deal with the two different ways of
* expressing the wildcard in the same codepath */
@@ -1226,17 +1125,15 @@ int map_search(struct ldb_module *module, struct ldb_request *req)
ret = map_attrs_collect_and_partition(module, ac,
attrs, req->op.search.tree);
if (ret) {
- goto failed;
+ return LDB_ERR_OPERATIONS_ERROR;
}
- ac->search_reqs[0]->op.search.attrs = ac->remote_attrs;
-
/* Split local from remote tree */
- ret = ldb_parse_tree_partition(module, ac, ac->search_reqs[0],
- &local_tree, &remote_tree,
+ ret = ldb_parse_tree_partition(module, ac,
+ &local_tree, &remote_tree,
req->op.search.tree);
if (ret) {
- goto failed;
+ return LDB_ERR_OPERATIONS_ERROR;
}
if (((local_tree != NULL) && (remote_tree != NULL)) &&
@@ -1251,7 +1148,7 @@ int map_search(struct ldb_module *module, struct ldb_request *req)
local_tree = talloc_zero(ac, struct ldb_parse_tree);
if (local_tree == NULL) {
map_oom(ac->module);
- goto failed;
+ return LDB_ERR_OPERATIONS_ERROR;
}
local_tree->operation = LDB_OP_PRESENT;
@@ -1259,31 +1156,209 @@ int map_search(struct ldb_module *module, struct ldb_request *req)
}
if (remote_tree == NULL) {
/* Construct default remote parse tree */
- remote_tree = ldb_parse_tree(ac->search_reqs[0], NULL);
+ remote_tree = ldb_parse_tree(ac, NULL);
if (remote_tree == NULL) {
- goto failed;
+ return LDB_ERR_OPERATIONS_ERROR;
}
}
ac->local_tree = local_tree;
- ac->search_reqs[0]->op.search.tree = remote_tree;
- ldb_set_timeout_from_prev_req(module->ldb, req, ac->search_reqs[0]);
+ /* Prepare the remote operation */
+ ret = ldb_build_search_req_ex(&remote_req, module->ldb, ac,
+ req->op.search.base,
+ req->op.search.scope,
+ remote_tree,
+ ac->remote_attrs,
+ req->controls,
+ ac, map_remote_search_callback,
+ req);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
- h->state = LDB_ASYNC_INIT;
- h->status = LDB_SUCCESS;
+ return ldb_next_remote_request(module, remote_req);
+}
+
+/* Now, search the local part of a remote search result. */
+static int map_remote_search_callback(struct ldb_request *req,
+ struct ldb_reply *ares)
+{
+ struct map_context *ac;
+ int ret;
- ac->step = MAP_SEARCH_REMOTE;
+ ac = talloc_get_type(req->context, struct map_context);
- ret = ldb_next_remote_request(module, ac->search_reqs[0]);
- if (ret == LDB_SUCCESS) {
- req->handle = h;
+ if (!ares) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
}
- return ret;
-oom:
- map_oom(module);
-failed:
- talloc_free(h);
- return LDB_ERR_OPERATIONS_ERROR;
+ switch (ares->type) {
+ case LDB_REPLY_REFERRAL:
+
+ /* ignore referrals */
+ talloc_free(ares);
+ return LDB_SUCCESS;
+
+ case LDB_REPLY_ENTRY:
+
+ /* Map result record into a local message */
+ ret = map_reply_remote(ac, ares);
+ if (ret) {
+ talloc_free(ares);
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+
+ /* if we have no local db, then we can just return the reply to
+ * the upper layer, otherwise we must save it and process it
+ * when all replies ahve been gathered */
+ if ( ! map_check_local_db(ac->module)) {
+ ret = map_return_entry(ac, ares);
+ } else {
+ ret = map_save_entry(ac,ares);
+ }
+
+ if (ret != LDB_SUCCESS) {
+ talloc_free(ares);
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+ break;
+
+ case LDB_REPLY_DONE:
+
+ if ( ! map_check_local_db(ac->module)) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, LDB_SUCCESS);
+ }
+
+ talloc_free(ares);
+
+ /* reset the pointer to the start of the list */
+ ac->r_current = ac->r_list;
+
+ /* no entry just return */
+ if (ac->r_current == NULL) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, LDB_SUCCESS);
+ }
+
+ ret = map_search_local(ac);
+ if (ret != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, NULL, NULL, ret);
+ }
+ }
+
+ return LDB_SUCCESS;
+}
+
+static int map_search_local(struct map_context *ac)
+{
+ struct ldb_request *search_req;
+
+ if (ac->r_current == NULL || ac->r_current->remote == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ /* Prepare local search request */
+ /* TODO: use GUIDs here instead? */
+ search_req = map_search_base_req(ac,
+ ac->r_current->remote->message->dn,
+ NULL, NULL,
+ ac, map_local_merge_callback);
+ if (search_req == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ return ldb_next_request(ac->module, search_req);
+}
+
+/* Merge the remote and local parts of a search result. */
+int map_local_merge_callback(struct ldb_request *req, struct ldb_reply *ares)
+{
+ struct map_context *ac;
+ int ret;
+
+ ac = talloc_get_type(req->context, struct map_context);
+
+ if (!ares) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
+ }
+
+ switch (ares->type) {
+ case LDB_REPLY_ENTRY:
+ /* We have already found a local record */
+ if (ac->r_current->local) {
+ talloc_free(ares);
+ ldb_set_errstring(ac->module->ldb, "ldb_map: Too many results!");
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+
+ /* Store local result */
+ ac->r_current->local = talloc_steal(ac->r_current, ares);
+
+ break;
+
+ case LDB_REPLY_REFERRAL:
+ /* ignore referrals */
+ talloc_free(ares);
+ break;
+
+ case LDB_REPLY_DONE:
+ talloc_free(ares);
+
+ /* No local record found, map and send remote record */
+ if (ac->r_current->local != NULL) {
+ /* Merge remote into local message */
+ ret = ldb_msg_merge_local(ac->module,
+ ac->r_current->local->message,
+ ac->r_current->remote->message);
+ if (ret == LDB_SUCCESS) {
+ ret = map_return_entry(ac, ac->r_current->local);
+ }
+ if (ret != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+ } else {
+ ret = map_return_entry(ac, ac->r_current->remote);
+ if (ret != LDB_SUCCESS) {
+ return ldb_module_done(ac->req,
+ NULL, NULL, ret);
+ }
+ }
+
+ if (ac->r_current->next != NULL) {
+ ac->r_current = ac->r_current->next;
+ if (ac->r_current->remote->type == LDB_REPLY_ENTRY) {
+ ret = map_search_local(ac);
+ if (ret != LDB_SUCCESS) {
+ return ldb_module_done(ac->req,
+ NULL, NULL, ret);
+ }
+ break;
+ }
+ }
+
+ /* ok we are done with all search, finally it is time to
+ * finish operations for this module */
+ return ldb_module_done(ac->req,
+ ac->r_current->remote->controls,
+ ac->r_current->remote->response,
+ ac->r_current->remote->error);
+ }
+
+ return LDB_SUCCESS;
}
diff --git a/source4/lib/ldb/ldb_map/ldb_map_private.h b/source4/lib/ldb/ldb_map/ldb_map_private.h
index 58a9f2704e..0543ba71b9 100644
--- a/source4/lib/ldb/ldb_map/ldb_map_private.h
+++ b/source4/lib/ldb/ldb_map/ldb_map_private.h
@@ -3,7 +3,7 @@
#define map_oom(module) ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
/* The type of search callback functions */
-typedef int (*ldb_search_callback)(struct ldb_context *, void *, struct ldb_reply *);
+typedef int (*ldb_map_callback_t)(struct ldb_request *, struct ldb_reply *);
/* The special DN from which the local and remote base DNs are fetched */
#define MAP_DN_NAME "@MAP"
@@ -13,25 +13,17 @@ typedef int (*ldb_search_callback)(struct ldb_context *, void *, struct ldb_repl
/* Private data structures
* ======================= */
+struct map_reply {
+ struct map_reply *next;
+ struct ldb_reply *remote;
+ struct ldb_reply *local;
+};
+
/* Context data for mapped requests */
struct map_context {
- enum map_step {
- MAP_SEARCH_REMOTE,
- MAP_ADD_REMOTE,
- MAP_ADD_LOCAL,
- MAP_SEARCH_SELF_MODIFY,
- MAP_MODIFY_REMOTE,
- MAP_MODIFY_LOCAL,
- MAP_SEARCH_SELF_DELETE,
- MAP_DELETE_REMOTE,
- MAP_DELETE_LOCAL,
- MAP_SEARCH_SELF_RENAME,
- MAP_RENAME_REMOTE,
- MAP_RENAME_FIXUP,
- MAP_RENAME_LOCAL
- } step;
struct ldb_module *module;
+ struct ldb_request *req;
struct ldb_dn *local_dn;
const struct ldb_parse_tree *local_tree;
@@ -39,32 +31,20 @@ struct map_context {
const char * const *remote_attrs;
const char * const *all_attrs;
- struct ldb_request *orig_req;
- struct ldb_request *local_req;
+ struct ldb_message *local_msg;
struct ldb_request *remote_req;
- struct ldb_request *down_req;
- struct ldb_request *search_req;
-
- /* for search, we may have a lot of contexts */
- int num_searches;
- struct ldb_request **search_reqs;
-};
-/* Context data for mapped search requests */
-struct map_search_context {
- struct map_context *ac;
- struct ldb_reply *local_res;
- struct ldb_reply *remote_res;
+ struct map_reply *r_list;
+ struct map_reply *r_current;
};
-
/* Common operations
* ================= */
/* The following definitions come from lib/ldb/modules/ldb_map.c */
const struct ldb_map_context *map_get_context(struct ldb_module *module);
-struct map_search_context *map_init_search_context(struct map_context *ac, struct ldb_reply *ares);
-struct ldb_handle *map_init_handle(struct ldb_request *req, struct ldb_module *module);
+struct map_context *map_init_context(struct ldb_module *module,
+ struct ldb_request *req);
int ldb_next_remote_request(struct ldb_module *module, struct ldb_request *request);
@@ -86,25 +66,25 @@ struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, struct
struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn);
struct ldb_dn *ldb_dn_map_rebase_remote(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn);
-struct ldb_request *map_search_base_req(struct map_context *ac, struct ldb_dn *dn, const char * const *attrs, const struct ldb_parse_tree *tree, void *context, ldb_search_callback callback);
-struct ldb_request *map_search_self_req(struct map_context *ac, struct ldb_dn *dn);
-struct ldb_request *map_build_fixup_req(struct map_context *ac, struct ldb_dn *olddn, struct ldb_dn *newdn);
-
-int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx, struct ldb_parse_tree **new, const struct ldb_parse_tree *tree, const struct ldb_map_attribute *map);
-
-/* LDB Requests
- * ============ */
-
-/* The following definitions come from lib/ldb/modules/ldb_map_inbound.c */
-int map_add_do_remote(struct ldb_handle *handle);
-int map_add_do_local(struct ldb_handle *handle);
-
-int map_modify_do_remote(struct ldb_handle *handle);
-int map_modify_do_local(struct ldb_handle *handle);
-
-int map_delete_do_remote(struct ldb_handle *handle);
-int map_delete_do_local(struct ldb_handle *handle);
-
-int map_rename_do_remote(struct ldb_handle *handle);
-int map_rename_do_fixup(struct ldb_handle *handle);
-int map_rename_do_local(struct ldb_handle *handle);
+struct ldb_request *map_search_base_req(struct map_context *ac,
+ struct ldb_dn *dn,
+ const char * const *attrs,
+ const struct ldb_parse_tree *tree,
+ void *context,
+ ldb_map_callback_t callback);
+struct ldb_request *map_build_fixup_req(struct map_context *ac,
+ struct ldb_dn *olddn,
+ struct ldb_dn *newdn,
+ void *context,
+ ldb_map_callback_t callback);
+int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx,
+ struct ldb_parse_tree **new,
+ const struct ldb_parse_tree *tree,
+ const struct ldb_map_attribute *map);
+int map_return_fatal_error(struct ldb_request *req,
+ struct ldb_reply *ares);
+int map_return_normal_error(struct ldb_request *req,
+ struct ldb_reply *ares,
+ int error);
+
+int map_return_entry(struct map_context *ac, struct ldb_reply *ares);
diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
index a0e63c8da1..be99c29d1e 100644
--- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
+++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
@@ -44,51 +44,14 @@ struct lsqlite3_private {
struct lsql_context {
struct ldb_module *module;
+ struct ldb_request *req;
/* search stuff */
long long current_eid;
const char * const * attrs;
struct ldb_reply *ares;
-
- /* async stuff */
- void *context;
- int (*callback)(struct ldb_context *, void *, struct ldb_reply *);
};
-static struct ldb_handle *init_handle(struct lsqlite3_private *lsqlite3,
- struct ldb_module *module,
- struct ldb_request *req)
-{
- struct lsql_context *ac;
- struct ldb_handle *h;
-
- h = talloc_zero(lsqlite3, struct ldb_handle);
- if (h == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
- return NULL;
- }
-
- h->module = module;
-
- ac = talloc(h, struct lsql_context);
- if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
- talloc_free(h);
- return NULL;
- }
-
- h->private_data = (void *)ac;
-
- h->state = LDB_ASYNC_INIT;
- h->status = LDB_SUCCESS;
-
- ac->module = module;
- ac->context = req->context;
- ac->callback = req->callback;
-
- return h;
-}
-
/*
* Macros used throughout
*/
@@ -835,11 +798,6 @@ int lsql_search(struct ldb_module *module, struct ldb_request *req)
char *query = NULL;
int ret;
- req->handle = init_handle(lsqlite3, module, req);
- if (req->handle == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context);
if ((( ! ldb_dn_is_valid(req->op.search.base)) || ldb_dn_is_null(req->op.search.base)) &&
@@ -1013,10 +971,6 @@ static int lsql_add(struct ldb_module *module, struct ldb_request *req)
int i;
int ret = LDB_SUCCESS;
- req->handle = init_handle(lsqlite3, module, req);
- if (req->handle == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context);
req->handle->state = LDB_ASYNC_DONE;
req->handle->status = LDB_SUCCESS;
@@ -1143,10 +1097,6 @@ static int lsql_modify(struct ldb_module *module, struct ldb_request *req)
int i;
int ret = LDB_SUCCESS;
- req->handle = init_handle(lsqlite3, module, req);
- if (req->handle == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context);
req->handle->state = LDB_ASYNC_DONE;
req->handle->status = LDB_SUCCESS;
@@ -1329,10 +1279,6 @@ static int lsql_delete(struct ldb_module *module, struct ldb_request *req)
int ret = LDB_SUCCESS;
- req->handle = init_handle(lsqlite3, module, req);
- if (req->handle == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context);
req->handle->state = LDB_ASYNC_DONE;
req->handle->status = LDB_SUCCESS;
@@ -1382,10 +1328,6 @@ static int lsql_rename(struct ldb_module *module, struct ldb_request *req)
char *query;
int ret = LDB_SUCCESS;
- req->handle = init_handle(lsqlite3, module, req);
- if (req->handle == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context);
req->handle->state = LDB_ASYNC_DONE;
req->handle->status = LDB_SUCCESS;
@@ -1501,9 +1443,61 @@ static int lsql_request(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_OPERATIONS_ERROR;
}
-static int lsql_wait(struct ldb_handle *handle, enum ldb_wait_type type)
+static int lsql_run_request(struct ldb_module *module, struct ldb_request *req)
+{
+ switch (req->operation) {
+ case LDB_SEARCH:
+ return lsql_search(module, req);
+ break;
+ case LDB_ADD:
+ return lsql_add(module, req);
+ break;
+ case LDB_MODIFY:
+ return lsql_modify(module, req);
+ break;
+ case LDB_DELETE:
+ return lsql_delete(module, req);
+ break;
+ case LDB_RENAME:
+ return lsql_rename(module, req);
+ break;
+/* TODO:
+ case LDB_SEQUENCE_NUMBER:
+ return lsql_sequence_number(module, req);
+ break;
+ */
+ default:
+ return lsql_request(module, req);
+ break;
+ }
+
+ return LDB_ERR_OPERATIONS_ERROR;
+}
+
+static int lsql_handle_request(struct ldb_module *module, struct ldb_request *req)
{
- return handle->status;
+ struct lsql_context *ac;
+
+ if (check_critical_controls(req->controls)) {
+ return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
+ }
+
+ ac = talloc_zero(req, struct lsql_context);
+ if (ac == NULL) {
+ ldb_set_errstring(module->ldb, "Out of Memory");
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ ac->module = module;
+ ac->req = req;
+
+ req->handle = ldb_handle_new(req, lsql_run_request, ac);
+ if (req->handle == NULL) {
+ talloc_free(ac);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ return LDB_SUCCESS;
}
/*
@@ -1511,16 +1505,16 @@ static int lsql_wait(struct ldb_handle *handle, enum ldb_wait_type type)
*/
static const struct ldb_module_ops lsqlite3_ops = {
.name = "sqlite",
- .search = lsql_search,
- .add = lsql_add,
- .modify = lsql_modify,
- .del = lsql_delete,
- .rename = lsql_rename,
- .request = lsql_request,
+ .search = lsql_handle_request,
+ .add = lsql_handle_request,
+ .modify = lsql_handle_request,
+ .del = lsql_handle_request,
+ .rename = lsql_handle_request,
+ .request = lsql_handle_request,
.start_transaction = lsql_start_trans,
.end_transaction = lsql_end_trans,
.del_transaction = lsql_del_trans,
- .wait = lsql_wait,
+ /* TODO: .sequence_number = lsql_handle_request */
};
/*
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index 269305a468..65711d9f4b 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -667,74 +667,58 @@ static int ltdb_index_dn(struct ldb_module *module,
extracting just the given attributes
*/
static int ltdb_index_filter(const struct dn_list *dn_list,
- struct ldb_handle *handle)
+ struct ltdb_context *ac)
{
- struct ltdb_context *ac = talloc_get_type(handle->private_data, struct ltdb_context);
- struct ldb_reply *ares = NULL;
+ struct ldb_message *msg;
unsigned int i;
for (i = 0; i < dn_list->count; i++) {
struct ldb_dn *dn;
int ret;
- ares = talloc_zero(ac, struct ldb_reply);
- if (!ares) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- handle->state = LDB_ASYNC_DONE;
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- ares->message = ldb_msg_new(ares);
- if (!ares->message) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- handle->state = LDB_ASYNC_DONE;
- talloc_free(ares);
+ msg = ldb_msg_new(ac);
+ if (!msg) {
return LDB_ERR_OPERATIONS_ERROR;
}
-
- dn = ldb_dn_new(ares->message, ac->module->ldb, dn_list->dn[i]);
+ dn = ldb_dn_new(msg, ac->module->ldb, dn_list->dn[i]);
if (dn == NULL) {
- talloc_free(ares);
+ talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ltdb_search_dn1(ac->module, dn, ares->message);
+ ret = ltdb_search_dn1(ac->module, dn, msg);
talloc_free(dn);
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
/* the record has disappeared? yes, this can happen */
- talloc_free(ares);
+ talloc_free(msg);
continue;
}
if (ret != LDB_SUCCESS && ret != LDB_ERR_NO_SUCH_OBJECT) {
/* an internal error */
- talloc_free(ares);
+ talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
}
- if (!ldb_match_msg(ac->module->ldb, ares->message, ac->tree, ac->base, ac->scope)) {
- talloc_free(ares);
+ if (!ldb_match_msg(ac->module->ldb, msg,
+ ac->tree, ac->base, ac->scope)) {
+ talloc_free(msg);
continue;
}
/* filter the attributes that the user wants */
- ret = ltdb_filter_attrs(ares->message, ac->attrs);
+ ret = ltdb_filter_attrs(msg, ac->attrs);
if (ret == -1) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- handle->state = LDB_ASYNC_DONE;
- talloc_free(ares);
+ talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
}
- ares->type = LDB_REPLY_ENTRY;
- handle->state = LDB_ASYNC_PENDING;
- handle->status = ac->callback(ac->module->ldb, ac->context, ares);
-
- if (handle->status != LDB_SUCCESS) {
- handle->state = LDB_ASYNC_DONE;
- return handle->status;
+ ret = ldb_module_send_entry(ac->req, msg);
+ if (ret != LDB_SUCCESS) {
+ ac->callback_failed = true;
+ return ret;
}
}
@@ -746,9 +730,8 @@ static int ltdb_index_filter(const struct dn_list *dn_list,
returns -1 if an indexed search is not possible, in which
case the caller should call ltdb_search_full()
*/
-int ltdb_search_indexed(struct ldb_handle *handle)
+int ltdb_search_indexed(struct ltdb_context *ac)
{
- struct ltdb_context *ac = talloc_get_type(handle->private_data, struct ltdb_context);
struct ltdb_private *ltdb = talloc_get_type(ac->module->private_data, struct ltdb_private);
struct dn_list *dn_list;
int ret, idxattr, idxone;
@@ -773,7 +756,7 @@ int ltdb_search_indexed(struct ldb_handle *handle)
ret = LDB_ERR_OPERATIONS_ERROR;
- dn_list = talloc_zero(handle, struct dn_list);
+ dn_list = talloc_zero(ac, struct dn_list);
if (dn_list == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -810,9 +793,7 @@ int ltdb_search_indexed(struct ldb_handle *handle)
if (ret == LDB_SUCCESS) {
/* we've got a candidate list - now filter by the full tree
and extract the needed attributes */
- ret = ltdb_index_filter(dn_list, handle);
- handle->status = ret;
- handle->state = LDB_ASYNC_DONE;
+ ret = ltdb_index_filter(dn_list, ac);
}
talloc_free(dn_list);
diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c
index da899c361e..6ab06c4e48 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_search.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_search.c
@@ -205,7 +205,7 @@ static struct ldb_message *ltdb_pull_attrs(struct ldb_module *module,
return LDB_ERR_NO_SUCH_OBJECT on record-not-found
and LDB_SUCCESS on success
*/
-int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn)
+static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn)
{
struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
TDB_DATA tdb_key, tdb_data;
@@ -277,30 +277,6 @@ int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_mes
}
/*
- lock the database for read - use by ltdb_search
-*/
-static int ltdb_lock_read(struct ldb_module *module)
-{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
- if (ltdb->in_transaction == 0) {
- return tdb_lockall_read(ltdb->tdb);
- }
- return 0;
-}
-
-/*
- unlock the database after a ltdb_lock_read()
-*/
-static int ltdb_unlock_read(struct ldb_module *module)
-{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
- if (ltdb->in_transaction == 0) {
- return tdb_unlockall_read(ltdb->tdb);
- }
- return 0;
-}
-
-/*
add a set of attributes from a record to a set of results
return 0 on success, -1 on failure
*/
@@ -395,71 +371,57 @@ int ltdb_filter_attrs(struct ldb_message *msg, const char * const *attrs)
*/
static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *state)
{
- struct ldb_handle *handle = talloc_get_type(state, struct ldb_handle);
- struct ltdb_context *ac = talloc_get_type(handle->private_data, struct ltdb_context);
- struct ldb_reply *ares = NULL;
+ struct ltdb_context *ac;
+ struct ldb_message *msg;
int ret;
+ ac = talloc_get_type(state, struct ltdb_context);
+
if (key.dsize < 4 ||
strncmp((char *)key.dptr, "DN=", 3) != 0) {
return 0;
}
- ares = talloc_zero(ac, struct ldb_reply);
- if (!ares) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- handle->state = LDB_ASYNC_DONE;
- return -1;
- }
-
- ares->message = ldb_msg_new(ares);
- if (!ares->message) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- handle->state = LDB_ASYNC_DONE;
- talloc_free(ares);
+ msg = ldb_msg_new(ac);
+ if (!msg) {
return -1;
}
/* unpack the record */
- ret = ltdb_unpack_data(ac->module, &data, ares->message);
+ ret = ltdb_unpack_data(ac->module, &data, msg);
if (ret == -1) {
- talloc_free(ares);
+ talloc_free(msg);
return -1;
}
- if (!ares->message->dn) {
- ares->message->dn = ldb_dn_new(ares->message, ac->module->ldb, (char *)key.dptr + 3);
- if (ares->message->dn == NULL) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- handle->state = LDB_ASYNC_DONE;
- talloc_free(ares);
+ if (!msg->dn) {
+ msg->dn = ldb_dn_new(msg, ac->module->ldb,
+ (char *)key.dptr + 3);
+ if (msg->dn == NULL) {
+ talloc_free(msg);
return -1;
}
}
/* see if it matches the given expression */
- if (!ldb_match_msg(ac->module->ldb, ares->message, ac->tree,
- ac->base, ac->scope)) {
- talloc_free(ares);
+ if (!ldb_match_msg(ac->module->ldb, msg,
+ ac->tree, ac->base, ac->scope)) {
+ talloc_free(msg);
return 0;
}
/* filter the attributes that the user wants */
- ret = ltdb_filter_attrs(ares->message, ac->attrs);
+ ret = ltdb_filter_attrs(msg, ac->attrs);
if (ret == -1) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- handle->state = LDB_ASYNC_DONE;
- talloc_free(ares);
+ talloc_free(msg);
return -1;
}
- ares->type = LDB_REPLY_ENTRY;
- handle->state = LDB_ASYNC_PENDING;
- handle->status = ac->callback(ac->module->ldb, ac->context, ares);
-
- if (handle->status != LDB_SUCCESS) {
- /* don't try to free ares here, the callback is in charge of that */
+ ret = ldb_module_send_entry(ac->req, msg);
+ if (ret != LDB_SUCCESS) {
+ ac->callback_failed = true;
+ /* the callback failed, abort the operation */
return -1;
}
@@ -471,23 +433,21 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi
search the database with a LDAP-like expression.
this is the "full search" non-indexed variant
*/
-static int ltdb_search_full(struct ldb_handle *handle)
+static int ltdb_search_full(struct ltdb_context *ctx)
{
- struct ltdb_context *ac = talloc_get_type(handle->private_data, struct ltdb_context);
- struct ltdb_private *ltdb = talloc_get_type(ac->module->private_data, struct ltdb_private);
+ struct ltdb_private *ltdb = talloc_get_type(ctx->module->private_data, struct ltdb_private);
int ret;
if (ltdb->in_transaction != 0) {
- ret = tdb_traverse(ltdb->tdb, search_func, handle);
+ ret = tdb_traverse(ltdb->tdb, search_func, ctx);
} else {
- ret = tdb_traverse_read(ltdb->tdb, search_func, handle);
+ ret = tdb_traverse_read(ltdb->tdb, search_func, ctx);
}
if (ret == -1) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
+ return LDB_ERR_OPERATIONS_ERROR;
}
- handle->state = LDB_ASYNC_DONE;
return LDB_SUCCESS;
}
@@ -495,13 +455,15 @@ static int ltdb_search_full(struct ldb_handle *handle)
search the database with a LDAP-like expression.
choses a search method
*/
-int ltdb_search(struct ldb_module *module, struct ldb_request *req)
+int ltdb_search(struct ltdb_context *ctx)
{
+ struct ldb_module *module = ctx->module;
+ struct ldb_request *req = ctx->req;
struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
- struct ltdb_context *ltdb_ac;
- struct ldb_reply *ares;
int ret;
+ req->handle->state = LDB_ASYNC_PENDING;
+
if (ltdb_lock_read(module) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -516,12 +478,6 @@ int ltdb_search(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_OPERATIONS_ERROR;
}
- req->handle = init_ltdb_handle(ltdb, module, req);
- if (req->handle == NULL) {
- ltdb_unlock_read(module);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
if ((req->op.search.base == NULL) || (ldb_dn_is_null(req->op.search.base) == true)) {
/* Check what we should do with a NULL dn */
@@ -564,53 +520,32 @@ int ltdb_search(struct ldb_module *module, struct ldb_request *req)
ret = LDB_SUCCESS;
}
- ltdb_ac = talloc_get_type(req->handle->private_data, struct ltdb_context);
-
- ltdb_ac->tree = req->op.search.tree;
- ltdb_ac->scope = req->op.search.scope;
- ltdb_ac->base = req->op.search.base;
- ltdb_ac->attrs = req->op.search.attrs;
-
+ ctx->tree = req->op.search.tree;
+ ctx->scope = req->op.search.scope;
+ ctx->base = req->op.search.base;
+ ctx->attrs = req->op.search.attrs;
if (ret == LDB_SUCCESS) {
- ret = ltdb_search_indexed(req->handle);
+ ret = ltdb_search_indexed(ctx);
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
/* Not in the index, therefore OK! */
ret = LDB_SUCCESS;
- } else if (ret == LDB_ERR_OPERATIONS_ERROR) {
+ }
+ /* Check if we got just a normal error.
+ * In that case proceed to a full search unless we got a
+ * callback error */
+ if ( ! ctx->callback_failed && ret != LDB_SUCCESS) {
/* Not indexed, so we need to do a full scan */
- ret = ltdb_search_full(req->handle);
+ ret = ltdb_search_full(ctx);
if (ret != LDB_SUCCESS) {
ldb_set_errstring(module->ldb, "Indexed and full searches both failed!\n");
}
}
}
- if (ret != LDB_SUCCESS) {
- req->handle->state = LDB_ASYNC_DONE;
- req->handle->status = ret;
- }
-
- /* Finally send an LDB_REPLY_DONE packet when searching is finished */
-
- ares = talloc_zero(req, struct ldb_reply);
- if (!ares) {
- ltdb_unlock_read(module);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- req->handle->state = LDB_ASYNC_DONE;
-
- if (ret == LDB_SUCCESS) {
- ares->type = LDB_REPLY_DONE;
-
- ret = req->callback(module->ldb, req->context, ares);
- req->handle->status = ret;
- }
-
ltdb_unlock_read(module);
- return LDB_SUCCESS;
+ return ret;
}
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index 01d570c89a..34a4e03965 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -3,7 +3,7 @@
Copyright (C) Andrew Tridgell 2004
Copyright (C) Stefan Metzmacher 2004
- Copyright (C) Simo Sorce 2006
+ Copyright (C) Simo Sorce 2006-2008
** NOTE! The following LGPL license applies to the ldb
@@ -39,6 +39,10 @@
* - description: make the module use asyncronous calls
* date: Feb 2006
* Author: Simo Sorce
+ *
+ * - description: make it possible to use event contexts
+ * date: Jan 2008
+ * Author: Simo Sorce
*/
#include "ldb_includes.h"
@@ -75,41 +79,31 @@ static int ltdb_err_map(enum TDB_ERROR tdb_code)
return LDB_ERR_OTHER;
}
-
-struct ldb_handle *init_ltdb_handle(struct ltdb_private *ltdb,
- struct ldb_module *module,
- struct ldb_request *req)
+/*
+ lock the database for read - use by ltdb_search and ltdb_sequence_number
+*/
+int ltdb_lock_read(struct ldb_module *module)
{
- struct ltdb_context *ac;
- struct ldb_handle *h;
-
- h = talloc_zero(req, struct ldb_handle);
- if (h == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
- return NULL;
+ struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ if (ltdb->in_transaction == 0) {
+ return tdb_lockall_read(ltdb->tdb);
}
+ return 0;
+}
- h->module = module;
-
- ac = talloc_zero(h, struct ltdb_context);
- if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
- talloc_free(h);
- return NULL;
+/*
+ unlock the database after a ltdb_lock_read()
+*/
+int ltdb_unlock_read(struct ldb_module *module)
+{
+ struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ if (ltdb->in_transaction == 0) {
+ return tdb_unlockall_read(ltdb->tdb);
}
-
- h->private_data = (void *)ac;
-
- h->state = LDB_ASYNC_INIT;
- h->status = LDB_SUCCESS;
-
- ac->module = module;
- ac->context = req->context;
- ac->callback = req->callback;
-
- return h;
+ return 0;
}
+
/*
form a TDB_DATA for a record key
caller frees
@@ -167,7 +161,7 @@ failed:
check special dn's have valid attributes
currently only @ATTRIBUTES is checked
*/
-int ltdb_check_special_dn(struct ldb_module *module,
+static int ltdb_check_special_dn(struct ldb_module *module,
const struct ldb_message *msg)
{
int i, j;
@@ -296,36 +290,20 @@ static int ltdb_add_internal(struct ldb_module *module,
/*
add a record to the database
*/
-static int ltdb_add(struct ldb_module *module, struct ldb_request *req)
+static int ltdb_add(struct ltdb_context *ctx)
{
- struct ltdb_private *ltdb;
- struct ltdb_context *ltdb_ac;
- int tret, ret = LDB_SUCCESS;
-
- ltdb = talloc_get_type(module->private_data, struct ltdb_private);
-
- if (check_critical_controls(req->controls)) {
- return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
- }
+ struct ldb_module *module = ctx->module;
+ struct ldb_request *req = ctx->req;
+ int tret;
- req->handle = init_ltdb_handle(ltdb, module, req);
- if (req->handle == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
- ltdb_ac = talloc_get_type(req->handle->private_data, struct ltdb_context);
+ req->handle->state = LDB_ASYNC_PENDING;
tret = ltdb_add_internal(module, req->op.add.message);
if (tret != LDB_SUCCESS) {
- req->handle->status = tret;
- goto done;
+ return tret;
}
- if (ltdb_ac->callback) {
- ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL);
- }
-done:
- req->handle->state = LDB_ASYNC_DONE;
- return ret;
+ return LDB_SUCCESS;
}
/*
@@ -402,42 +380,24 @@ done:
/*
delete a record from the database
*/
-static int ltdb_delete(struct ldb_module *module, struct ldb_request *req)
+static int ltdb_delete(struct ltdb_context *ctx)
{
- struct ltdb_private *ltdb;
- struct ltdb_context *ltdb_ac;
- int tret, ret = LDB_SUCCESS;
-
- ltdb = talloc_get_type(module->private_data, struct ltdb_private);
-
- if (check_critical_controls(req->controls)) {
- return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
- }
+ struct ldb_module *module = ctx->module;
+ struct ldb_request *req = ctx->req;
+ int tret;
- req->handle = NULL;
+ req->handle->state = LDB_ASYNC_PENDING;
if (ltdb_cache_load(module) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
}
- req->handle = init_ltdb_handle(ltdb, module, req);
- if (req->handle == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
- ltdb_ac = talloc_get_type(req->handle->private_data, struct ltdb_context);
-
tret = ltdb_delete_internal(module, req->op.del.dn);
if (tret != LDB_SUCCESS) {
- req->handle->status = tret;
- goto done;
+ return tret;
}
- if (ltdb_ac->callback) {
- ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL);
- }
-done:
- req->handle->state = LDB_ASYNC_DONE;
- return ret;
+ return LDB_SUCCESS;
}
/*
@@ -784,83 +744,50 @@ failed:
/*
modify a record
*/
-static int ltdb_modify(struct ldb_module *module, struct ldb_request *req)
+static int ltdb_modify(struct ltdb_context *ctx)
{
- struct ltdb_private *ltdb;
- struct ltdb_context *ltdb_ac;
- int tret, ret = LDB_SUCCESS;
-
- ltdb = talloc_get_type(module->private_data, struct ltdb_private);
-
- if (check_critical_controls(req->controls)) {
- return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
- }
-
- req->handle = NULL;
+ struct ldb_module *module = ctx->module;
+ struct ldb_request *req = ctx->req;
+ int tret;
- req->handle = init_ltdb_handle(ltdb, module, req);
- if (req->handle == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
- ltdb_ac = talloc_get_type(req->handle->private_data, struct ltdb_context);
+ req->handle->state = LDB_ASYNC_PENDING;
tret = ltdb_check_special_dn(module, req->op.mod.message);
if (tret != LDB_SUCCESS) {
- req->handle->status = tret;
- goto done;
+ return tret;
}
if (ltdb_cache_load(module) != 0) {
- ret = LDB_ERR_OPERATIONS_ERROR;
- goto done;
+ return LDB_ERR_OPERATIONS_ERROR;
}
tret = ltdb_modify_internal(module, req->op.mod.message);
if (tret != LDB_SUCCESS) {
- req->handle->status = tret;
- goto done;
+ return tret;
}
- if (ltdb_ac->callback) {
- ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL);
- }
-done:
- req->handle->state = LDB_ASYNC_DONE;
- return ret;
+ return LDB_SUCCESS;
}
/*
rename a record
*/
-static int ltdb_rename(struct ldb_module *module, struct ldb_request *req)
+static int ltdb_rename(struct ltdb_context *ctx)
{
- struct ltdb_private *ltdb;
- struct ltdb_context *ltdb_ac;
+ struct ldb_module *module = ctx->module;
+ struct ldb_request *req = ctx->req;
struct ldb_message *msg;
- int tret, ret = LDB_SUCCESS;
-
- ltdb = talloc_get_type(module->private_data, struct ltdb_private);
-
- if (check_critical_controls(req->controls)) {
- return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
- }
+ int tret;
- req->handle = NULL;
+ req->handle->state = LDB_ASYNC_PENDING;
- if (ltdb_cache_load(module) != 0) {
+ if (ltdb_cache_load(ctx->module) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
}
- req->handle = init_ltdb_handle(ltdb, module, req);
- if (req->handle == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
- ltdb_ac = talloc_get_type(req->handle->private_data, struct ltdb_context);
-
- msg = talloc(ltdb_ac, struct ldb_message);
+ msg = talloc(ctx, struct ldb_message);
if (msg == NULL) {
- ret = LDB_ERR_OPERATIONS_ERROR;
- goto done;
+ return LDB_ERR_OPERATIONS_ERROR;
}
/* in case any attribute of the message was indexed, we need
@@ -868,14 +795,12 @@ static int ltdb_rename(struct ldb_module *module, struct ldb_request *req)
tret = ltdb_search_dn1(module, req->op.rename.olddn, msg);
if (tret != LDB_SUCCESS) {
/* not finding the old record is an error */
- req->handle->status = tret;
- goto done;
+ return tret;
}
msg->dn = ldb_dn_copy(msg, req->op.rename.newdn);
if (!msg->dn) {
- ret = LDB_ERR_OPERATIONS_ERROR;
- goto done;
+ return LDB_ERR_OPERATIONS_ERROR;
}
if (ldb_dn_compare(req->op.rename.olddn, req->op.rename.newdn) == 0) {
@@ -886,38 +811,32 @@ static int ltdb_rename(struct ldb_module *module, struct ldb_request *req)
The only drawback to this is that if the delete
succeeds but the add fails, we rely on the
transaction to roll this all back. */
- ret = ltdb_delete_internal(module, req->op.rename.olddn);
- if (ret != LDB_SUCCESS) {
- goto done;
+ tret = ltdb_delete_internal(module, req->op.rename.olddn);
+ if (tret != LDB_SUCCESS) {
+ return tret;
}
- ret = ltdb_add_internal(module, msg);
- if (ret != LDB_SUCCESS) {
- goto done;
+ tret = ltdb_add_internal(module, msg);
+ if (tret != LDB_SUCCESS) {
+ return tret;
}
} else {
/* The rename operation is changing DNs. Try to add the new
DN first to avoid clobbering another DN not related to
this rename operation. */
- ret = ltdb_add_internal(module, msg);
- if (ret != LDB_SUCCESS) {
- goto done;
+ tret = ltdb_add_internal(module, msg);
+ if (tret != LDB_SUCCESS) {
+ return tret;
}
tret = ltdb_delete_internal(module, req->op.rename.olddn);
if (tret != LDB_SUCCESS) {
ltdb_delete_internal(module, req->op.rename.newdn);
- ret = LDB_ERR_OPERATIONS_ERROR;
- goto done;
+ return LDB_ERR_OPERATIONS_ERROR;
}
}
- if (ltdb_ac->callback) {
- ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL);
- }
-done:
- req->handle->state = LDB_ASYNC_DONE;
- return ret;
+ return LDB_SUCCESS;
}
static int ltdb_start_trans(struct ldb_module *module)
@@ -962,95 +881,261 @@ static int ltdb_del_trans(struct ldb_module *module)
return LDB_SUCCESS;
}
-static int ltdb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
-{
- return handle->status;
-}
-
-static int ltdb_request(struct ldb_module *module, struct ldb_request *req)
-{
- /* check for oustanding critical controls
- * and return an error if found */
- if (check_critical_controls(req->controls)) {
- return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
- }
-
- /* search, add, modify, delete, rename are handled by their own,
- * no other op supported */
- return LDB_ERR_OPERATIONS_ERROR;
-}
-
/*
return sequenceNumber from @BASEINFO
*/
-static int ltdb_sequence_number(struct ldb_module *module,
- struct ldb_request *req)
+static int ltdb_sequence_number(struct ltdb_context *ctx,
+ struct ldb_extended **ext)
{
+ struct ldb_module *module = ctx->module;
+ struct ldb_request *req = ctx->req;
TALLOC_CTX *tmp_ctx;
+ struct ldb_seqnum_request *seq;
+ struct ldb_seqnum_result *res;
struct ldb_message *msg = NULL;
struct ldb_dn *dn;
const char *date;
- int tret;
+ int ret;
+
+ seq = talloc_get_type(req->op.extended.data,
+ struct ldb_seqnum_request);
+ if (seq == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ req->handle->state = LDB_ASYNC_PENDING;
+
+ if (ltdb_lock_read(module) != 0) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ res = talloc_zero(req, struct ldb_seqnum_result);
+ if (res == NULL) {
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ goto done;
+ }
tmp_ctx = talloc_new(req);
if (tmp_ctx == NULL) {
- talloc_free(tmp_ctx);
- return LDB_ERR_OPERATIONS_ERROR;
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ goto done;
}
dn = ldb_dn_new(tmp_ctx, module->ldb, LTDB_BASEINFO);
msg = talloc(tmp_ctx, struct ldb_message);
if (msg == NULL) {
- talloc_free(tmp_ctx);
- return LDB_ERR_OPERATIONS_ERROR;
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ goto done;
}
- req->op.seq_num.flags = 0;
-
- tret = ltdb_search_dn1(module, dn, msg);
- if (tret != LDB_SUCCESS) {
- talloc_free(tmp_ctx);
- /* zero is as good as anything when we don't know */
- req->op.seq_num.seq_num = 0;
- return LDB_SUCCESS;
+ ret = ltdb_search_dn1(module, dn, msg);
+ if (ret != LDB_SUCCESS) {
+ goto done;
}
- switch (req->op.seq_num.type) {
+ switch (seq->type) {
case LDB_SEQ_HIGHEST_SEQ:
- req->op.seq_num.seq_num = ldb_msg_find_attr_as_uint64(msg, LTDB_SEQUENCE_NUMBER, 0);
+ res->seq_num = ldb_msg_find_attr_as_uint64(msg, LTDB_SEQUENCE_NUMBER, 0);
break;
case LDB_SEQ_NEXT:
- req->op.seq_num.seq_num = ldb_msg_find_attr_as_uint64(msg, LTDB_SEQUENCE_NUMBER, 0);
- req->op.seq_num.seq_num++;
+ res->seq_num = ldb_msg_find_attr_as_uint64(msg, LTDB_SEQUENCE_NUMBER, 0);
+ res->seq_num++;
break;
case LDB_SEQ_HIGHEST_TIMESTAMP:
date = ldb_msg_find_attr_as_string(msg, LTDB_MOD_TIMESTAMP, NULL);
if (date) {
- req->op.seq_num.seq_num = ldb_string_to_time(date);
+ res->seq_num = ldb_string_to_time(date);
} else {
- req->op.seq_num.seq_num = 0;
+ res->seq_num = 0;
/* zero is as good as anything when we don't know */
}
break;
}
+
+ *ext = talloc_zero(req, struct ldb_extended);
+ if (*ext == NULL) {
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ goto done;
+ }
+ (*ext)->oid = LDB_EXTENDED_SEQUENCE_NUMBER;
+ (*ext)->data = talloc_steal(*ext, res);
+
+ ret = LDB_SUCCESS;
+
+done:
talloc_free(tmp_ctx);
+ ltdb_unlock_read(module);
+ return ret;
+}
+
+static void ltdb_request_done(struct ldb_request *req, int error)
+{
+ struct ldb_reply *ares;
+
+ /* if we already returned an error just return */
+ if (req->handle->status != LDB_SUCCESS) {
+ return;
+ }
+
+ ares = talloc_zero(req, struct ldb_reply);
+ if (!ares) {
+ ldb_oom(req->handle->ldb);
+ req->callback(req, NULL);
+ return;
+ }
+ ares->type = LDB_REPLY_DONE;
+ ares->error = error;
+
+ req->callback(req, ares);
+}
+
+static void ltdb_timeout(struct event_context *ev,
+ struct timed_event *te,
+ struct timeval t,
+ void *private_data)
+{
+ struct ltdb_context *ctx;
+ ctx = talloc_get_type(private_data, struct ltdb_context);
+
+ ltdb_request_done(ctx->req, LDB_ERR_TIME_LIMIT_EXCEEDED);
+}
+
+static void ltdb_request_extended_done(struct ldb_request *req,
+ struct ldb_extended *ext,
+ int error)
+{
+ struct ldb_reply *ares;
+
+ /* if we already returned an error just return */
+ if (req->handle->status != LDB_SUCCESS) {
+ return;
+ }
+
+ ares = talloc_zero(req, struct ldb_reply);
+ if (!ares) {
+ ldb_oom(req->handle->ldb);
+ req->callback(req, NULL);
+ return;
+ }
+ ares->type = LDB_REPLY_DONE;
+ ares->response = ext;
+ ares->error = error;
+
+ req->callback(req, ares);
+}
+
+static void ltdb_handle_extended(struct ltdb_context *ctx)
+{
+ struct ldb_extended *ext = NULL;
+ int ret;
+
+ if (strcmp(ctx->req->op.extended.oid,
+ LDB_EXTENDED_SEQUENCE_NUMBER) == 0) {
+ /* get sequence number */
+ ret = ltdb_sequence_number(ctx, &ext);
+ } else {
+ /* not recognized */
+ ret = LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
+ }
+
+ ltdb_request_extended_done(ctx->req, ext, ret);
+}
+
+static void ltdb_callback(struct event_context *ev,
+ struct timed_event *te,
+ struct timeval t,
+ void *private_data)
+{
+ struct ltdb_context *ctx;
+ int ret;
+
+ ctx = talloc_get_type(private_data, struct ltdb_context);
+
+ switch (ctx->req->operation) {
+ case LDB_SEARCH:
+ ret = ltdb_search(ctx);
+ break;
+ case LDB_ADD:
+ ret = ltdb_add(ctx);
+ break;
+ case LDB_MODIFY:
+ ret = ltdb_modify(ctx);
+ break;
+ case LDB_DELETE:
+ ret = ltdb_delete(ctx);
+ break;
+ case LDB_RENAME:
+ ret = ltdb_rename(ctx);
+ break;
+ case LDB_EXTENDED:
+ ltdb_handle_extended(ctx);
+ return;
+ default:
+ /* no other op supported */
+ ret = LDB_ERR_UNWILLING_TO_PERFORM;
+ }
+
+ if (!ctx->callback_failed) {
+ ltdb_request_done(ctx->req, ret);
+ }
+}
+
+static int ltdb_handle_request(struct ldb_module *module,
+ struct ldb_request *req)
+{
+ struct event_context *ev;
+ struct ltdb_context *ac;
+ struct timed_event *te;
+ struct timeval tv;
+
+ if (check_critical_controls(req->controls)) {
+ return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
+ }
+
+ if (req->starttime == 0 || req->timeout == 0) {
+ ldb_set_errstring(module->ldb, "Invalid timeout settings");
+ return LDB_ERR_TIME_LIMIT_EXCEEDED;
+ }
+
+ ev = ldb_get_event_context(module->ldb);
+
+ ac = talloc_zero(req, struct ltdb_context);
+ if (ac == NULL) {
+ ldb_set_errstring(module->ldb, "Out of Memory");
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ ac->module = module;
+ ac->req = req;
+
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ te = event_add_timed(ev, ac, tv, ltdb_callback, ac);
+ if (NULL == te) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+
+ tv.tv_sec = req->starttime + req->timeout;
+ te = event_add_timed(ev, ac, tv, ltdb_timeout, ac);
+ if (NULL == te) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
return LDB_SUCCESS;
}
static const struct ldb_module_ops ltdb_ops = {
.name = "tdb",
- .search = ltdb_search,
- .add = ltdb_add,
- .modify = ltdb_modify,
- .del = ltdb_delete,
- .rename = ltdb_rename,
- .request = ltdb_request,
+ .search = ltdb_handle_request,
+ .add = ltdb_handle_request,
+ .modify = ltdb_handle_request,
+ .del = ltdb_handle_request,
+ .rename = ltdb_handle_request,
+ .extended = ltdb_handle_request,
.start_transaction = ltdb_start_trans,
.end_transaction = ltdb_end_trans,
.del_transaction = ltdb_del_trans,
- .wait = ltdb_wait,
- .sequence_number = ltdb_sequence_number
};
/*
@@ -1114,7 +1199,7 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url,
ltdb->sequence_number = 0;
*module = talloc(ldb, struct ldb_module);
- if (!module) {
+ if ((*module) == NULL) {
ldb_oom(ldb);
talloc_free(ltdb);
return -1;
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.h b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
index 4beced30eb..61e90bccc6 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.h
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
@@ -41,16 +41,15 @@ struct ltdb_private {
*/
struct ltdb_context {
struct ldb_module *module;
+ struct ldb_request *req;
+
+ bool callback_failed;
/* search stuff */
const struct ldb_parse_tree *tree;
struct ldb_dn *base;
enum ldb_scope scope;
const char * const *attrs;
-
- /* async stuff */
- void *context;
- int (*callback)(struct ldb_context *, void *, struct ldb_reply *);
};
/* special record types */
@@ -80,7 +79,7 @@ int ltdb_check_at_attributes_values(const struct ldb_val *value);
struct ldb_parse_tree;
-int ltdb_search_indexed(struct ldb_handle *handle);
+int ltdb_search_indexed(struct ltdb_context *ctx);
int ltdb_index_add(struct ldb_module *module, const struct ldb_message *msg);
int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg);
int ltdb_index_one(struct ldb_module *module, const struct ldb_message *msg, int add);
@@ -110,11 +109,11 @@ int ltdb_add_attr_results(struct ldb_module *module,
unsigned int *count,
struct ldb_message ***res);
int ltdb_filter_attrs(struct ldb_message *msg, const char * const *attrs);
-int ltdb_search(struct ldb_module *module, struct ldb_request *req);
+int ltdb_search(struct ltdb_context *ctx);
/* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c */
-struct ldb_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module *module,
- struct ldb_request *req);
+int ltdb_lock_read(struct ldb_module *module);
+int ltdb_unlock_read(struct ldb_module *module);
struct TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn);
int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs);
int ltdb_delete_noindex(struct ldb_module *module, struct ldb_dn *dn);
@@ -127,4 +126,3 @@ struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx,
const char *path, int hash_size, int tdb_flags,
int open_flags, mode_t mode,
struct ldb_context *ldb);
-
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c b/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c
index 654574cd2f..4fea43c8c8 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c
@@ -64,6 +64,10 @@ static void ltdb_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, con
struct ldb_context *ldb = talloc_get_type(tdb_get_logging_private(tdb), struct ldb_context);
enum ldb_debug_level ldb_level;
char *message;
+
+ if (ldb == NULL)
+ return;
+
va_start(ap, fmt);
message = talloc_vasprintf(ldb, fmt, ap);
va_end(ap);
diff --git a/source4/lib/ldb/ldb_wrap.c b/source4/lib/ldb/ldb_wrap.c
index c9dd9dccd8..bc9266a306 100644
--- a/source4/lib/ldb/ldb_wrap.c
+++ b/source4/lib/ldb/ldb_wrap.c
@@ -2492,23 +2492,25 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
#define SWIGTYPE_p_ldb_ldif swig_types[6]
#define SWIGTYPE_p_ldb_message swig_types[7]
#define SWIGTYPE_p_ldb_message_element swig_types[8]
-#define SWIGTYPE_p_ldb_module_ops swig_types[9]
-#define SWIGTYPE_p_ldb_result swig_types[10]
-#define SWIGTYPE_p_ldb_val swig_types[11]
-#define SWIGTYPE_p_long_long swig_types[12]
-#define SWIGTYPE_p_p_char swig_types[13]
-#define SWIGTYPE_p_p_ldb_control swig_types[14]
-#define SWIGTYPE_p_p_ldb_result swig_types[15]
-#define SWIGTYPE_p_short swig_types[16]
-#define SWIGTYPE_p_signed_char swig_types[17]
-#define SWIGTYPE_p_unsigned_char swig_types[18]
-#define SWIGTYPE_p_unsigned_int swig_types[19]
-#define SWIGTYPE_p_unsigned_long swig_types[20]
-#define SWIGTYPE_p_unsigned_long_long swig_types[21]
-#define SWIGTYPE_p_unsigned_short swig_types[22]
-#define SWIGTYPE_p_void swig_types[23]
-static swig_type_info *swig_types[25];
-static swig_module_info swig_module = {swig_types, 24, 0, 0, 0, 0};
+#define SWIGTYPE_p_ldb_module swig_types[9]
+#define SWIGTYPE_p_ldb_module_ops swig_types[10]
+#define SWIGTYPE_p_ldb_parse_tree swig_types[11]
+#define SWIGTYPE_p_ldb_result swig_types[12]
+#define SWIGTYPE_p_ldb_val swig_types[13]
+#define SWIGTYPE_p_long_long swig_types[14]
+#define SWIGTYPE_p_p_char swig_types[15]
+#define SWIGTYPE_p_p_ldb_control swig_types[16]
+#define SWIGTYPE_p_p_ldb_result swig_types[17]
+#define SWIGTYPE_p_short swig_types[18]
+#define SWIGTYPE_p_signed_char swig_types[19]
+#define SWIGTYPE_p_unsigned_char swig_types[20]
+#define SWIGTYPE_p_unsigned_int swig_types[21]
+#define SWIGTYPE_p_unsigned_long swig_types[22]
+#define SWIGTYPE_p_unsigned_long_long swig_types[23]
+#define SWIGTYPE_p_unsigned_short swig_types[24]
+#define SWIGTYPE_p_void swig_types[25]
+static swig_type_info *swig_types[27];
+static swig_module_info swig_module = {swig_types, 26, 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)
@@ -2562,6 +2564,7 @@ typedef struct ldb_context ldb;
typedef struct ldb_dn ldb_dn;
typedef struct ldb_ldif ldb_ldif;
typedef struct ldb_message_element ldb_message_element;
+typedef struct ldb_module ldb_module;
typedef int ldb_error;
typedef int ldb_int_error;
@@ -3153,15 +3156,14 @@ SWIGINTERN ldb_error ldb_search_ex(ldb *self,TALLOC_CTX *mem_ctx,ldb_dn *base,en
attrs,
controls,
res,
- ldb_search_default_callback);
+ ldb_search_default_callback,
+ NULL);
if (ret != 0) {
talloc_free(res);
return ret;
}
- ldb_set_timeout(self, req, 0); /* use default timeout */
-
ret = ldb_request(self, req);
if (ret == 0) {
@@ -3201,8 +3203,7 @@ SWIGINTERN PyObject *ldb_schema_format_value(ldb *self,char const *element_name,
return ret;
}
SWIGINTERN ldb_error ldb___contains__(ldb *self,ldb_dn *dn,struct ldb_result **result_as_bool){
- return ldb_search(self, dn, LDB_SCOPE_BASE, NULL, NULL,
- result_as_bool);
+ return ldb_search(self, self, result_as_bool, dn, LDB_SCOPE_BASE, NULL, NULL);
}
SWIGINTERN PyObject *ldb_parse_ldif(ldb *self,char const *s){
PyObject *list = PyList_New(0);
@@ -3226,6 +3227,319 @@ static char *timestring(time_t t)
return result;
}
+SWIGINTERN char const *ldb_module___str__(ldb_module *self){
+ return self->ops->name;
+ }
+SWIGINTERN char *ldb_module___repr__(ldb_module *self){
+ char *ret;
+ asprintf(&ret, "<ldb module '%s'>", self->ops->name);
+ return ret;
+ }
+SWIGINTERN int ldb_module_search(ldb_module *self,struct ldb_dn *base,enum ldb_scope scope,struct ldb_parse_tree *tree,char const *const *attrs,struct ldb_result **res){
+ int ret;
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+
+ req->operation = LDB_SEARCH;
+ req->op.search.base = base;
+ req->op.search.scope = scope;
+ req->op.search.tree = tree;
+ req->op.search.attrs = attrs;
+
+ req->op.search.res = talloc_zero(NULL, struct ldb_result);
+
+ ret = self->ops->search(self, req);
+
+ *res = req->op.search.res;
+
+ talloc_free(req);
+
+ return ret;
+ }
+SWIGINTERN ldb_error ldb_module_add(ldb_module *self,struct ldb_message *message){
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+ req->operation = LDB_ADD;
+ req->op.add.message = message;
+
+ return self->ops->add(self, &req);
+ }
+SWIGINTERN ldb_error ldb_module_modify(ldb_module *self,struct ldb_message *message){
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+ req->operation = LDB_MODIFY;
+ req->op.mod.message = message;
+
+ return self->ops->modify(self, &req);
+ }
+SWIGINTERN ldb_error ldb_module_delete(ldb_module *self,struct ldb_dn *dn){
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+ req->operation = LDB_DELETE;
+ req->op.del.dn = dn;
+
+ return self->ops->del(self, &req);
+
+ }
+SWIGINTERN ldb_error ldb_module_rename(ldb_module *self,struct ldb_dn *olddn,struct ldb_dn *newdn){
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+ req->operation = LDB_RENAME;
+ req->op.rename.olddn = olddn;
+ req->op.rename.olddn = newdn;
+
+ return self->ops->rename(self, &req);
+ }
+SWIGINTERN ldb_error ldb_module_start_transaction(ldb_module *self){
+ return self->ops->start_transaction(self);
+ }
+SWIGINTERN ldb_error ldb_module_end_transaction(ldb_module *self){
+ return self->ops->end_transaction(self);
+ }
+SWIGINTERN ldb_error ldb_module_del_transaction(ldb_module *self){
+ return self->ops->del_transaction(self);
+ }
+
+int py_module_search(struct ldb_module *mod, struct ldb_request *req)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result, *py_base, *py_attrs, *py_tree;
+
+ py_base = SWIG_NewPointerObj(req->op.search.base, SWIGTYPE_p_ldb_dn, 0);
+
+ if (py_base == NULL)
+ return LDB_ERR_OPERATIONS_ERROR;
+
+ py_tree = SWIG_NewPointerObj(req->op.search.tree, SWIGTYPE_p_ldb_parse_tree, 0);
+
+ if (py_tree == NULL)
+ return LDB_ERR_OPERATIONS_ERROR;
+
+ if (req->op.search.attrs == NULL) {
+ py_attrs = Py_None;
+ } else {
+ int i, len;
+ for (len = 0; req->op.search.attrs[len]; len++);
+ py_attrs = PyList_New(len);
+ for (i = 0; i < len; i++)
+ PyList_SetItem(py_attrs, i, PyString_FromString(req->op.search.attrs[i]));
+ }
+
+ py_result = PyObject_CallMethod(py_ldb, "search", "OiOO", py_base, req->op.search.scope, py_tree, py_attrs);
+
+ Py_DECREF(py_attrs);
+ Py_DECREF(py_tree);
+ Py_DECREF(py_base);
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ if (SWIG_ConvertPtr(py_result, &req->op.search.res, SWIGTYPE_p_ldb_result, 0) != 0) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ Py_DECREF(py_result);
+
+ return LDB_SUCCESS;
+}
+
+int py_module_add(struct ldb_module *mod, struct ldb_request *req)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result, *py_msg;
+
+ py_msg = SWIG_NewPointerObj(req->op.add.message, SWIGTYPE_p_ldb_message, 0);
+
+ if (py_msg == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ py_result = PyObject_CallMethod(py_ldb, "add", "O", py_msg);
+
+ Py_DECREF(py_msg);
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ Py_DECREF(py_result);
+
+ return LDB_SUCCESS;
+}
+
+int py_module_modify(struct ldb_module *mod, struct ldb_request *req)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result, *py_msg;
+
+ py_msg = SWIG_NewPointerObj(req->op.mod.message, SWIGTYPE_p_ldb_message, 0);
+
+ if (py_msg == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ py_result = PyObject_CallMethod(py_ldb, "modify", "O", py_msg);
+
+ Py_DECREF(py_msg);
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ Py_DECREF(py_result);
+
+ return LDB_SUCCESS;
+}
+
+int py_module_del(struct ldb_module *mod, struct ldb_request *req)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result, *py_dn;
+
+ py_dn = SWIG_NewPointerObj(req->op.del.dn, SWIGTYPE_p_ldb_dn, 0);
+
+ if (py_dn == NULL)
+ return LDB_ERR_OPERATIONS_ERROR;
+
+ py_result = PyObject_CallMethod(py_ldb, "delete", "O", py_dn);
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ Py_DECREF(py_result);
+
+ return LDB_SUCCESS;
+}
+
+int py_module_rename(struct ldb_module *mod, struct ldb_request *req)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result, *py_olddn, *py_newdn;
+
+ py_olddn = SWIG_NewPointerObj(req->op.rename.olddn, SWIGTYPE_p_ldb_dn, 0);
+
+ if (py_olddn == NULL)
+ return LDB_ERR_OPERATIONS_ERROR;
+
+ py_newdn = SWIG_NewPointerObj(req->op.rename.newdn, SWIGTYPE_p_ldb_dn, 0);
+
+ if (py_newdn == NULL)
+ return LDB_ERR_OPERATIONS_ERROR;
+
+ py_result = PyObject_CallMethod(py_ldb, "rename", "OO", py_olddn, py_newdn);
+
+ Py_DECREF(py_olddn);
+ Py_DECREF(py_newdn);
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ Py_DECREF(py_result);
+
+ return LDB_SUCCESS;
+}
+
+int py_module_request(struct ldb_module *mod, struct ldb_request *req)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result;
+
+ py_result = PyObject_CallMethod(py_ldb, "request", "");
+
+ return LDB_ERR_OPERATIONS_ERROR;
+}
+
+int py_module_extended(struct ldb_module *mod, struct ldb_request *req)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result;
+
+ py_result = PyObject_CallMethod(py_ldb, "extended", "");
+
+ return LDB_ERR_OPERATIONS_ERROR;
+}
+
+int py_module_start_transaction(struct ldb_module *mod)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result;
+
+ py_result = PyObject_CallMethod(py_ldb, "start_transaction", "");
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ Py_DECREF(py_result);
+
+ return LDB_SUCCESS;
+}
+
+int py_module_end_transaction(struct ldb_module *mod)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result;
+
+ py_result = PyObject_CallMethod(py_ldb, "end_transaction", "");
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ Py_DECREF(py_result);
+
+ return LDB_SUCCESS;
+}
+
+int py_module_del_transaction(struct ldb_module *mod)
+{
+ PyObject *py_ldb = mod->private_data;
+ PyObject *py_result;
+
+ py_result = PyObject_CallMethod(py_ldb, "del_transaction", "");
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ Py_DECREF(py_result);
+
+ return LDB_SUCCESS;
+}
+
+static int py_module_destructor(void *_mod)
+{
+ struct ldb_module *mod = _mod;
+ Py_DECREF((PyObject *)mod->private_data);
+ return 0;
+}
+
+int py_module_init (struct ldb_module *mod)
+{
+ PyObject *py_class = mod->ops->private_data;
+ PyObject *py_result, *py_next, *py_ldb;
+
+ py_ldb = SWIG_NewPointerObj(mod->ldb, SWIGTYPE_p_ldb_context, 0);
+
+ if (py_ldb == NULL)
+ return LDB_ERR_OPERATIONS_ERROR;
+
+ py_next = SWIG_NewPointerObj(mod->next, SWIGTYPE_p_ldb_module, 0);
+
+ if (py_next == NULL)
+ return LDB_ERR_OPERATIONS_ERROR;
+
+ py_result = PyObject_CallFunction(py_class, "OO", py_ldb, py_next);
+
+ if (py_result == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ mod->private_data = py_result;
+
+ talloc_set_destructor (mod, py_module_destructor);
+
+ return ldb_next_init(mod);
+}
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -4433,6 +4747,64 @@ fail:
}
+SWIGINTERN PyObject *_wrap_Ldb_firstmodule_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb *arg1 = (ldb *) 0 ;
+ struct ldb_module *arg2 = (struct ldb_module *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject *swig_obj[2] ;
+
+ if (!SWIG_Python_UnpackTuple(args,"Ldb_firstmodule_set",2,2,swig_obj)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_firstmodule_set" "', argument " "1"" of type '" "ldb *""'");
+ }
+ arg1 = (ldb *)(argp1);
+ res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ldb_module, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Ldb_firstmodule_set" "', argument " "2"" of type '" "struct ldb_module *""'");
+ }
+ arg2 = (struct ldb_module *)(argp2);
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
+ if (arg1) (arg1)->modules = arg2;
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_Ldb_firstmodule_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb *arg1 = (ldb *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+ struct ldb_module *result = 0 ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_firstmodule_get" "', argument " "1"" of type '" "ldb *""'");
+ }
+ arg1 = (ldb *)(argp1);
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
+ result = (struct ldb_module *) ((arg1)->modules);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_module, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_new_Ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
ldb *result = 0 ;
@@ -4625,11 +4997,15 @@ SWIGINTERN PyObject *_wrap_Ldb_search_ex(PyObject *SWIGUNUSEDPARM(self), PyObjec
SWIG_fail;
}
resultobj = Py_None;
- resultobj = PyList_New((*arg8)->count);
- for (i8 = 0; i8 < (*arg8)->count; i8++) {
- PyList_SetItem(resultobj, i8,
- SWIG_NewPointerObj((*arg8)->msgs[i8], SWIGTYPE_p_ldb_message, 0)
- );
+ if (arg8 == NULL) {
+ resultobj = Py_None;
+ } else {
+ resultobj = PyList_New((*arg8)->count);
+ for (i8 = 0; i8 < (*arg8)->count; i8++) {
+ PyList_SetItem(resultobj, i8,
+ SWIG_NewPointerObj((*arg8)->msgs[i8], SWIGTYPE_p_ldb_message, 0)
+ );
+ }
}
talloc_free(arg3);
if (alloc5 == SWIG_NEWOBJ) free((char*)buf5);
@@ -5707,6 +6083,525 @@ fail:
}
+SWIGINTERN PyObject *_wrap_ldb_module_prev_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb_module *arg1 = (ldb_module *) 0 ;
+ struct ldb_module *arg2 = (struct ldb_module *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject *swig_obj[2] ;
+
+ if (!SWIG_Python_UnpackTuple(args,"ldb_module_prev_set",2,2,swig_obj)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_prev_set" "', argument " "1"" of type '" "ldb_module *""'");
+ }
+ arg1 = (ldb_module *)(argp1);
+ res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ldb_module, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_prev_set" "', argument " "2"" of type '" "struct ldb_module *""'");
+ }
+ arg2 = (struct ldb_module *)(argp2);
+ if (arg1) (arg1)->prev = arg2;
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ldb_module_prev_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb_module *arg1 = (ldb_module *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+ struct ldb_module *result = 0 ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_prev_get" "', argument " "1"" of type '" "ldb_module *""'");
+ }
+ arg1 = (ldb_module *)(argp1);
+ result = (struct ldb_module *) ((arg1)->prev);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_module, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ldb_module_next_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb_module *arg1 = (ldb_module *) 0 ;
+ struct ldb_module *arg2 = (struct ldb_module *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject *swig_obj[2] ;
+
+ if (!SWIG_Python_UnpackTuple(args,"ldb_module_next_set",2,2,swig_obj)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_next_set" "', argument " "1"" of type '" "ldb_module *""'");
+ }
+ arg1 = (ldb_module *)(argp1);
+ res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ldb_module, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_next_set" "', argument " "2"" of type '" "struct ldb_module *""'");
+ }
+ arg2 = (struct ldb_module *)(argp2);
+ if (arg1) (arg1)->next = arg2;
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ldb_module_next_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb_module *arg1 = (ldb_module *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+ struct ldb_module *result = 0 ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_next_get" "', argument " "1"" of type '" "ldb_module *""'");
+ }
+ arg1 = (ldb_module *)(argp1);
+ result = (struct ldb_module *) ((arg1)->next);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_module, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ldb_module___str__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb_module *arg1 = (ldb_module *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+ char *result = 0 ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module___str__" "', argument " "1"" of type '" "ldb_module *""'");
+ }
+ arg1 = (ldb_module *)(argp1);
+ result = (char *)ldb_module___str__(arg1);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ldb_module___repr__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb_module *arg1 = (ldb_module *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+ char *result = 0 ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module___repr__" "', argument " "1"" of type '" "ldb_module *""'");
+ }
+ arg1 = (ldb_module *)(argp1);
+ result = (char *)ldb_module___repr__(arg1);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ldb_module_search(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ ldb_module *arg1 = (ldb_module *) 0 ;
+ struct ldb_dn *arg2 = (struct ldb_dn *) 0 ;
+ enum ldb_scope arg3 ;
+ struct ldb_parse_tree *arg4 = (struct ldb_parse_tree *) 0 ;
+ char **arg5 = (char **) 0 ;
+ struct ldb_result **arg6 = (struct ldb_result **) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ void *argp4 = 0 ;
+ int res4 = 0 ;
+ struct ldb_result *temp_ldb_result6 ;
+ int i6 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "base",(char *) "scope",(char *) "tree",(char *) "attrs", NULL
+ };
+ int result;
+
+ arg6 = &temp_ldb_result6;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:ldb_module_search",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_module, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_search" "', argument " "1"" of type '" "ldb_module *""'");
+ }
+ arg1 = (ldb_module *)(argp1);
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_dn, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_search" "', argument " "2"" of type '" "struct ldb_dn *""'");
+ }
+ arg2 = (struct ldb_dn *)(argp2);
+ ecode3 = SWIG_AsVal_int(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ldb_module_search" "', argument " "3"" of type '" "enum ldb_scope""'");
+ }
+ arg3 = (enum ldb_scope)(val3);
+ res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_ldb_parse_tree, 0 | 0 );
+ if (!SWIG_IsOK(res4)) {
+ SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ldb_module_search" "', argument " "4"" of type '" "struct ldb_parse_tree *""'");
+ }
+ arg4 = (struct ldb_parse_tree *)(argp4);
+ if (obj4 == Py_None) {
+ arg5 = NULL;
+ } else if (PySequence_Check(obj4)) {
+ int i;
+ arg5 = talloc_array(NULL, char *, PySequence_Size(obj4)+1);
+ for(i = 0; i < PySequence_Size(obj4); i++)
+ arg5[i] = PyString_AsString(PySequence_GetItem(obj4, i));
+ arg5[i] = NULL;
+ } else {
+ SWIG_exception(SWIG_TypeError, "expected sequence");
+ }
+ result = (int)ldb_module_search(arg1,arg2,arg3,arg4,(char const *const *)arg5,arg6);
+ resultobj = SWIG_From_int((int)(result));
+ if (arg6 == NULL) {
+ resultobj = Py_None;
+ } else {
+ resultobj = PyList_New((*arg6)->count);
+ for (i6 = 0; i6 < (*arg6)->count; i6++) {
+ PyList_SetItem(resultobj, i6,
+ SWIG_NewPointerObj((*arg6)->msgs[i6], SWIGTYPE_p_ldb_message, 0)
+ );
+ }
+ }
+ talloc_free(arg5);
+ return resultobj;
+fail:
+ talloc_free(arg5);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ldb_module_add(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ ldb_module *arg1 = (ldb_module *) 0 ;
+ struct ldb_message *arg2 = (struct ldb_message *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "message", NULL
+ };
+ ldb_error result;
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_module_add",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_module, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_add" "', argument " "1"" of type '" "ldb_module *""'");
+ }
+ arg1 = (ldb_module *)(argp1);
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_message, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_add" "', argument " "2"" of type '" "struct ldb_message *""'");
+ }
+ arg2 = (struct ldb_message *)(argp2);
+ result = ldb_module_add(arg1,arg2);
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1)));
+ SWIG_fail;
+ }
+ resultobj = Py_None;
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ldb_module_modify(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ ldb_module *arg1 = (ldb_module *) 0 ;
+ struct ldb_message *arg2 = (struct ldb_message *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "message", NULL
+ };
+ ldb_error result;
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_module_modify",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_module, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_modify" "', argument " "1"" of type '" "ldb_module *""'");
+ }
+ arg1 = (ldb_module *)(argp1);
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_message, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_modify" "', argument " "2"" of type '" "struct ldb_message *""'");
+ }
+ arg2 = (struct ldb_message *)(argp2);
+ result = ldb_module_modify(arg1,arg2);
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1)));
+ SWIG_fail;
+ }
+ resultobj = Py_None;
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ldb_module_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ ldb_module *arg1 = (ldb_module *) 0 ;
+ struct ldb_dn *arg2 = (struct ldb_dn *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "dn", NULL
+ };
+ ldb_error result;
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_module_delete",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_module, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_delete" "', argument " "1"" of type '" "ldb_module *""'");
+ }
+ arg1 = (ldb_module *)(argp1);
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_dn, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_delete" "', argument " "2"" of type '" "struct ldb_dn *""'");
+ }
+ arg2 = (struct ldb_dn *)(argp2);
+ result = ldb_module_delete(arg1,arg2);
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1)));
+ SWIG_fail;
+ }
+ resultobj = Py_None;
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ldb_module_rename(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ ldb_module *arg1 = (ldb_module *) 0 ;
+ struct ldb_dn *arg2 = (struct ldb_dn *) 0 ;
+ struct ldb_dn *arg3 = (struct ldb_dn *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ void *argp3 = 0 ;
+ int res3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "olddn",(char *) "newdn", NULL
+ };
+ ldb_error result;
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:ldb_module_rename",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_module, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_rename" "', argument " "1"" of type '" "ldb_module *""'");
+ }
+ arg1 = (ldb_module *)(argp1);
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_dn, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_rename" "', argument " "2"" of type '" "struct ldb_dn *""'");
+ }
+ arg2 = (struct ldb_dn *)(argp2);
+ res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_ldb_dn, 0 | 0 );
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ldb_module_rename" "', argument " "3"" of type '" "struct ldb_dn *""'");
+ }
+ arg3 = (struct ldb_dn *)(argp3);
+ result = ldb_module_rename(arg1,arg2,arg3);
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1)));
+ SWIG_fail;
+ }
+ resultobj = Py_None;
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ldb_module_start_transaction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb_module *arg1 = (ldb_module *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+ ldb_error result;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_start_transaction" "', argument " "1"" of type '" "ldb_module *""'");
+ }
+ arg1 = (ldb_module *)(argp1);
+ result = ldb_module_start_transaction(arg1);
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1)));
+ SWIG_fail;
+ }
+ resultobj = Py_None;
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ldb_module_end_transaction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb_module *arg1 = (ldb_module *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+ ldb_error result;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_end_transaction" "', argument " "1"" of type '" "ldb_module *""'");
+ }
+ arg1 = (ldb_module *)(argp1);
+ result = ldb_module_end_transaction(arg1);
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1)));
+ SWIG_fail;
+ }
+ resultobj = Py_None;
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ldb_module_del_transaction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb_module *arg1 = (ldb_module *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+ ldb_error result;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_del_transaction" "', argument " "1"" of type '" "ldb_module *""'");
+ }
+ arg1 = (ldb_module *)(argp1);
+ result = ldb_module_del_transaction(arg1);
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1)));
+ SWIG_fail;
+ }
+ resultobj = Py_None;
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_ldb_module(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb_module *result = 0 ;
+
+ if (!SWIG_Python_UnpackTuple(args,"new_ldb_module",0,0,0)) SWIG_fail;
+ result = (ldb_module *)calloc(1, sizeof(ldb_module));
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_module, SWIG_POINTER_NEW | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_delete_ldb_module(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb_module *arg1 = (ldb_module *) 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_ldb_module, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ldb_module" "', argument " "1"" of type '" "ldb_module *""'");
+ }
+ arg1 = (ldb_module *)(argp1);
+ free((char *) arg1);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *ldb_module_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *obj;
+ if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
+ SWIG_TypeNewClientData(SWIGTYPE_p_ldb_module, SWIG_NewClientData(obj));
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *ldb_module_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ return SWIG_Python_InitShadowInstance(args);
+}
+
SWIGINTERN PyObject *_wrap_register_module(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
struct ldb_module_ops *arg1 = (struct ldb_module_ops *) 0 ;
@@ -5719,7 +6614,21 @@ SWIGINTERN PyObject *_wrap_register_module(PyObject *SWIGUNUSEDPARM(self), PyObj
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:register_module",kwnames,&obj0)) SWIG_fail;
arg1 = talloc_zero(talloc_autofree_context(), struct ldb_module_ops);
- arg1->name = (char *)PyObject_GetAttrString(obj0, (char *)"name");
+ arg1->name = talloc_strdup(arg1, PyString_AsString(PyObject_GetAttrString(obj0, (char *)"name")));
+
+ Py_INCREF(obj0);
+ arg1->private_data = obj0;
+ arg1->init_context = py_module_init;
+ arg1->search = py_module_search;
+ arg1->add = py_module_add;
+ arg1->modify = py_module_modify;
+ arg1->del = py_module_del;
+ arg1->rename = py_module_rename;
+ arg1->request = py_module_request;
+ arg1->extended = py_module_extended;
+ arg1->start_transaction = py_module_start_transaction;
+ arg1->end_transaction = py_module_end_transaction;
+ arg1->del_transaction = py_module_del_transaction;
result = ldb_register_module((struct ldb_module_ops const *)arg1);
if (result != 0) {
PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_strerror(result)));
@@ -5804,6 +6713,8 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"Message_swigregister", Message_swigregister, METH_VARARGS, NULL},
{ (char *)"Message_swiginit", Message_swiginit, METH_VARARGS, NULL},
{ (char *)"ldb_ldif_to_pyobject", (PyCFunction) _wrap_ldb_ldif_to_pyobject, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Ldb_firstmodule_set", _wrap_Ldb_firstmodule_set, METH_VARARGS, NULL},
+ { (char *)"Ldb_firstmodule_get", (PyCFunction)_wrap_Ldb_firstmodule_get, METH_O, NULL},
{ (char *)"new_Ldb", (PyCFunction)_wrap_new_Ldb, METH_NOARGS, NULL},
{ (char *)"Ldb_connect", (PyCFunction) _wrap_Ldb_connect, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
"S.connect(url,flags=0,options=None) -> None\n"
@@ -5892,6 +6803,24 @@ static PyMethodDef SwigMethods[] = {
"S.string_to_time(string) -> int\n"
"Parse a LDAP time string into a UNIX timestamp.\n"
""},
+ { (char *)"ldb_module_prev_set", _wrap_ldb_module_prev_set, METH_VARARGS, NULL},
+ { (char *)"ldb_module_prev_get", (PyCFunction)_wrap_ldb_module_prev_get, METH_O, NULL},
+ { (char *)"ldb_module_next_set", _wrap_ldb_module_next_set, METH_VARARGS, NULL},
+ { (char *)"ldb_module_next_get", (PyCFunction)_wrap_ldb_module_next_get, METH_O, NULL},
+ { (char *)"ldb_module___str__", (PyCFunction)_wrap_ldb_module___str__, METH_O, NULL},
+ { (char *)"ldb_module___repr__", (PyCFunction)_wrap_ldb_module___repr__, METH_O, NULL},
+ { (char *)"ldb_module_search", (PyCFunction) _wrap_ldb_module_search, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"ldb_module_add", (PyCFunction) _wrap_ldb_module_add, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"ldb_module_modify", (PyCFunction) _wrap_ldb_module_modify, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"ldb_module_delete", (PyCFunction) _wrap_ldb_module_delete, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"ldb_module_rename", (PyCFunction) _wrap_ldb_module_rename, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"ldb_module_start_transaction", (PyCFunction)_wrap_ldb_module_start_transaction, METH_O, NULL},
+ { (char *)"ldb_module_end_transaction", (PyCFunction)_wrap_ldb_module_end_transaction, METH_O, NULL},
+ { (char *)"ldb_module_del_transaction", (PyCFunction)_wrap_ldb_module_del_transaction, METH_O, NULL},
+ { (char *)"new_ldb_module", (PyCFunction)_wrap_new_ldb_module, METH_NOARGS, NULL},
+ { (char *)"delete_ldb_module", (PyCFunction)_wrap_delete_ldb_module, METH_O, NULL},
+ { (char *)"ldb_module_swigregister", ldb_module_swigregister, METH_VARARGS, NULL},
+ { (char *)"ldb_module_swiginit", ldb_module_swiginit, METH_VARARGS, NULL},
{ (char *)"register_module", (PyCFunction) _wrap_register_module, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
"S.register_module(module) -> None\n"
"Register a LDB module.\n"
@@ -5911,7 +6840,9 @@ static swig_type_info _swigt__p_ldb_dn = {"_p_ldb_dn", "struct ldb_dn *|ldb_dn *
static swig_type_info _swigt__p_ldb_ldif = {"_p_ldb_ldif", "struct ldb_ldif *|ldb_ldif *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_message = {"_p_ldb_message", "ldb_msg *|struct ldb_message *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_message_element = {"_p_ldb_message_element", "struct ldb_message_element *|ldb_message_element *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_ldb_module = {"_p_ldb_module", "struct ldb_module *|ldb_module *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_module_ops = {"_p_ldb_module_ops", "struct ldb_module_ops *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_ldb_parse_tree = {"_p_ldb_parse_tree", "struct ldb_parse_tree *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_result = {"_p_ldb_result", "struct ldb_result *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_val = {"_p_ldb_val", "struct ldb_val *", 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};
@@ -5937,7 +6868,9 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_ldb_ldif,
&_swigt__p_ldb_message,
&_swigt__p_ldb_message_element,
+ &_swigt__p_ldb_module,
&_swigt__p_ldb_module_ops,
+ &_swigt__p_ldb_parse_tree,
&_swigt__p_ldb_result,
&_swigt__p_ldb_val,
&_swigt__p_long_long,
@@ -5963,7 +6896,9 @@ static swig_cast_info _swigc__p_ldb_dn[] = { {&_swigt__p_ldb_dn, 0, 0, 0},{0, 0
static swig_cast_info _swigc__p_ldb_ldif[] = { {&_swigt__p_ldb_ldif, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_ldb_message[] = { {&_swigt__p_ldb_message, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_ldb_message_element[] = { {&_swigt__p_ldb_message_element, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_ldb_module[] = { {&_swigt__p_ldb_module, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_ldb_module_ops[] = { {&_swigt__p_ldb_module_ops, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_ldb_parse_tree[] = { {&_swigt__p_ldb_parse_tree, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_ldb_result[] = { {&_swigt__p_ldb_result, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_ldb_val[] = { {&_swigt__p_ldb_val, 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}};
@@ -5989,7 +6924,9 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_ldb_ldif,
_swigc__p_ldb_message,
_swigc__p_ldb_message_element,
+ _swigc__p_ldb_module,
_swigc__p_ldb_module_ops,
+ _swigc__p_ldb_parse_tree,
_swigc__p_ldb_result,
_swigc__p_ldb_val,
_swigc__p_long_long,
diff --git a/source4/lib/ldb/libldb.m4 b/source4/lib/ldb/libldb.m4
index 77ebcc5ff4..5653794a88 100644
--- a/source4/lib/ldb/libldb.m4
+++ b/source4/lib/ldb/libldb.m4
@@ -2,6 +2,6 @@
# disable ldb_sqlite3 by default
SMB_ENABLE(ldb_sqlite3, NO)
-if test x"$with_sqlite3_support" = x"yes"; then
- SMB_ENABLE(ldb_sqlite3, YES)
-fi
+#if test x"$with_sqlite3_support" = x"yes"; then
+# SMB_ENABLE(ldb_sqlite3, YES)
+#fi
diff --git a/source4/lib/ldb/modules/asq.c b/source4/lib/ldb/modules/asq.c
index eb27263b16..835715e7dc 100644
--- a/source4/lib/ldb/modules/asq.c
+++ b/source4/lib/ldb/modules/asq.c
@@ -1,7 +1,7 @@
/*
ldb database library
- Copyright (C) Simo Sorce 2005
+ Copyright (C) Simo Sorce 2005-2008
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
@@ -36,10 +36,10 @@
struct asq_context {
- enum {ASQ_INIT, ASQ_SEARCH_BASE, ASQ_SEARCH_MULTI} step;
+ enum {ASQ_SEARCH_BASE, ASQ_SEARCH_MULTI} step;
struct ldb_module *module;
- struct ldb_request *orig_req;
+ struct ldb_request *req;
struct ldb_asq_control *asq_ctrl;
@@ -52,7 +52,6 @@ struct asq_context {
ASQ_CTRL_AFFECTS_MULTIPLE_DSA = 71
} asq_ret;
- struct ldb_request *base_req;
struct ldb_reply *base_res;
struct ldb_request **reqs;
@@ -62,192 +61,200 @@ struct asq_context {
struct ldb_control **controls;
};
-static struct ldb_handle *init_handle(struct ldb_request *req, struct ldb_module *module)
+static struct asq_context *asq_context_init(struct ldb_module *module, struct ldb_request *req)
{
struct asq_context *ac;
- struct ldb_handle *h;
-
- h = talloc_zero(req, struct ldb_handle);
- if (h == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
- return NULL;
- }
- h->module = module;
-
- ac = talloc_zero(h, struct asq_context);
+ ac = talloc_zero(req, struct asq_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
- talloc_free(h);
+ ldb_oom(module->ldb);
return NULL;
}
- h->private_data = (void *)ac;
-
- h->state = LDB_ASYNC_INIT;
- h->status = LDB_SUCCESS;
-
- ac->step = ASQ_INIT;
ac->module = module;
- ac->orig_req = req;
+ ac->req = req;
- return h;
+ return ac;
}
-static int asq_terminate(struct ldb_handle *handle)
+static int asq_search_continue(struct asq_context *ac);
+
+static int asq_search_terminate(struct asq_context *ac)
{
- struct asq_context *ac;
- struct ldb_reply *ares;
struct ldb_asq_control *asq;
int i;
- ac = talloc_get_type(handle->private_data, struct asq_context);
- if (ac == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- handle->status = LDB_SUCCESS;
- handle->state = LDB_ASYNC_DONE;
-
- ares = talloc_zero(ac, struct ldb_reply);
- if (ares == NULL)
- return LDB_ERR_OPERATIONS_ERROR;
-
- ares->type = LDB_REPLY_DONE;
-
if (ac->controls) {
- for (i = 0; ac->controls[i]; i++);
- ares->controls = talloc_move(ares, &ac->controls);
+ for (i = 0; ac->controls[i]; i++) /* count em */ ;
} else {
i = 0;
}
- ares->controls = talloc_realloc(ares, ares->controls, struct ldb_control *, i + 2);
-
- if (ares->controls == NULL)
+ ac->controls = talloc_realloc(ac, ac->controls, struct ldb_control *, i + 2);
+
+ if (ac->controls == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
+ }
- ares->controls[i] = talloc(ares->controls, struct ldb_control);
- if (ares->controls[i] == NULL)
+ ac->controls[i] = talloc(ac->controls, struct ldb_control);
+ if (ac->controls[i] == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
+ }
- ares->controls[i]->oid = LDB_CONTROL_ASQ_OID;
- ares->controls[i]->critical = 0;
+ ac->controls[i]->oid = LDB_CONTROL_ASQ_OID;
+ ac->controls[i]->critical = 0;
- asq = talloc_zero(ares->controls[i], struct ldb_asq_control);
+ asq = talloc_zero(ac->controls[i], struct ldb_asq_control);
if (asq == NULL)
return LDB_ERR_OPERATIONS_ERROR;
asq->result = ac->asq_ret;
-
- ares->controls[i]->data = asq;
- ares->controls[i + 1] = NULL;
+ ac->controls[i]->data = asq;
- ac->orig_req->callback(ac->module->ldb, ac->orig_req->context, ares);
+ ac->controls[i + 1] = NULL;
- return LDB_SUCCESS;
+ return ldb_module_done(ac->req, ac->controls, NULL, LDB_SUCCESS);
}
-static int asq_base_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
+static int asq_base_callback(struct ldb_request *req, struct ldb_reply *ares)
{
struct asq_context *ac;
+ int ret;
- if (!context || !ares) {
- ldb_set_errstring(ldb, "NULL Context or Result in callback");
- goto error;
- }
+ ac = talloc_get_type(req->context, struct asq_context);
- ac = talloc_get_type(context, struct asq_context);
- if (ac == NULL) {
- goto error;
+ if (!ares) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
}
- /* we are interested only in the single reply (base search) we receive here */
- if (ares->type == LDB_REPLY_ENTRY) {
+ switch (ares->type) {
+ case LDB_REPLY_ENTRY:
ac->base_res = talloc_move(ac, &ares);
- } else {
+ break;
+
+ case LDB_REPLY_REFERRAL:
+ /* ignore referrals */
talloc_free(ares);
- }
+ break;
+ case LDB_REPLY_DONE:
+
+ talloc_free(ares);
+
+ /* next step */
+ ret = asq_search_continue(ac);
+ if (ret != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, NULL, NULL, ret);
+ }
+ break;
+
+ }
return LDB_SUCCESS;
-error:
- talloc_free(ares);
- return LDB_ERR_OPERATIONS_ERROR;
}
-static int asq_reqs_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
+static int asq_reqs_callback(struct ldb_request *req, struct ldb_reply *ares)
{
struct asq_context *ac;
+ int ret;
- if (!context || !ares) {
- ldb_set_errstring(ldb, "NULL Context or Result in callback");
- goto error;
- }
+ ac = talloc_get_type(req->context, struct asq_context);
- ac = talloc_get_type(context, struct asq_context);
- if (ac == NULL) {
- goto error;
+ if (!ares) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
}
- /* we are interested only in the single reply (base search) we receive here */
- if (ares->type == LDB_REPLY_ENTRY) {
-
+ switch (ares->type) {
+ case LDB_REPLY_ENTRY:
/* pass the message up to the original callback as we
* do not have to elaborate on it any further */
- return ac->orig_req->callback(ac->module->ldb, ac->orig_req->context, ares);
-
- } else { /* ignore any REFERRAL or DONE reply */
+ ret = ldb_module_send_entry(ac->req, ares->message);
+ if (ret != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, NULL, NULL, ret);
+ }
+ talloc_free(ares);
+ break;
+
+ case LDB_REPLY_REFERRAL:
+ /* ignore referrals */
+ talloc_free(ares);
+ break;
+
+ case LDB_REPLY_DONE:
+
talloc_free(ares);
+
+ ret = asq_search_continue(ac);
+ if (ret != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, NULL, NULL, ret);
+ }
+ break;
}
return LDB_SUCCESS;
-error:
- talloc_free(ares);
- return LDB_ERR_OPERATIONS_ERROR;
}
-static int asq_build_first_request(struct asq_context *ac)
+static int asq_build_first_request(struct asq_context *ac, struct ldb_request **base_req)
{
- char **base_attrs;
+ const char **base_attrs;
+ int ret;
- ac->base_req = talloc_zero(ac, struct ldb_request);
- if (ac->base_req == NULL) return LDB_ERR_OPERATIONS_ERROR;
+ ac->req_attrs = ac->req->op.search.attrs;
+ ac->req_attribute = talloc_strdup(ac, ac->asq_ctrl->source_attribute);
+ if (ac->req_attribute == NULL)
+ return LDB_ERR_OPERATIONS_ERROR;
- ac->base_req->operation = ac->orig_req->operation;
- ac->base_req->op.search.base = ac->orig_req->op.search.base;
- ac->base_req->op.search.scope = LDB_SCOPE_BASE;
- ac->base_req->op.search.tree = ac->orig_req->op.search.tree;
- base_attrs = talloc_array(ac->base_req, char *, 2);
+ base_attrs = talloc_array(ac, const char *, 2);
if (base_attrs == NULL) return LDB_ERR_OPERATIONS_ERROR;
base_attrs[0] = talloc_strdup(base_attrs, ac->asq_ctrl->source_attribute);
if (base_attrs[0] == NULL) return LDB_ERR_OPERATIONS_ERROR;
base_attrs[1] = NULL;
- ac->base_req->op.search.attrs = (const char * const *)base_attrs;
- ac->base_req->context = ac;
- ac->base_req->callback = asq_base_callback;
- ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->base_req);
+ ret = ldb_build_search_req(base_req, ac->module->ldb, ac,
+ ac->req->op.search.base,
+ LDB_SCOPE_BASE,
+ NULL,
+ (const char * const *)base_attrs,
+ NULL,
+ ac, asq_base_callback,
+ ac->req);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
return LDB_SUCCESS;
}
-static int asq_build_multiple_requests(struct asq_context *ac, struct ldb_handle *handle)
+static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated)
{
+ struct ldb_control **saved_controls;
+ struct ldb_control *control;
+ struct ldb_dn *dn;
struct ldb_message_element *el;
- int i;
+ int ret, i;
- /* look up the DNs */
if (ac->base_res == NULL) {
return LDB_ERR_NO_SUCH_OBJECT;
}
+
el = ldb_msg_find_element(ac->base_res->message, ac->req_attribute);
/* no values found */
if (el == NULL) {
ac->asq_ret = ASQ_CTRL_SUCCESS;
- return asq_terminate(handle);
+ *terminated = true;
+ return asq_search_terminate(ac);
}
ac->num_reqs = el->num_values;
@@ -259,144 +266,75 @@ static int asq_build_multiple_requests(struct asq_context *ac, struct ldb_handle
for (i = 0; i < el->num_values; i++) {
- ac->reqs[i] = talloc_zero(ac->reqs, struct ldb_request);
- if (ac->reqs[i] == NULL)
- return LDB_ERR_OPERATIONS_ERROR;
- ac->reqs[i]->operation = LDB_SEARCH;
- ac->reqs[i]->op.search.base = ldb_dn_new(ac->reqs[i], ac->module->ldb, (const char *)el->values[i].data);
- if ( ! ldb_dn_validate(ac->reqs[i]->op.search.base)) {
+ dn = ldb_dn_new(ac, ac->module->ldb,
+ (const char *)el->values[i].data);
+ if ( ! ldb_dn_validate(dn)) {
ac->asq_ret = ASQ_CTRL_INVALID_ATTRIBUTE_SYNTAX;
- return asq_terminate(handle);
+ *terminated = true;
+ return asq_search_terminate(ac);
+ }
+
+ ret = ldb_build_search_req_ex(&ac->reqs[i],
+ ac->module->ldb, ac,
+ dn, LDB_SCOPE_BASE,
+ ac->req->op.search.tree,
+ ac->req_attrs,
+ ac->req->controls,
+ ac, asq_reqs_callback,
+ ac->req);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- ac->reqs[i]->op.search.scope = LDB_SCOPE_BASE;
- ac->reqs[i]->op.search.tree = ac->base_req->op.search.tree;
- ac->reqs[i]->op.search.attrs = ac->req_attrs;
- ac->reqs[i]->context = ac;
- ac->reqs[i]->callback = asq_reqs_callback;
- ldb_set_timeout_from_prev_req(ac->module->ldb, ac->base_req, ac->reqs[i]);
+ /* remove the ASQ control itself */
+ control = ldb_request_get_control(ac->req, LDB_CONTROL_ASQ_OID);
+ if (!save_controls(control, ac->reqs[i], &saved_controls)) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
}
return LDB_SUCCESS;
}
-static int asq_search_continue(struct ldb_handle *handle)
+static int asq_search_continue(struct asq_context *ac)
{
- struct asq_context *ac;
+ bool terminated = false;
int ret;
-
- if (!handle || !handle->private_data) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- if (handle->state == LDB_ASYNC_DONE) {
- return handle->status;
- }
-
- ac = talloc_get_type(handle->private_data, struct asq_context);
- if (ac == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
switch (ac->step) {
- case ASQ_INIT:
- /* check the search is well formed */
- if (ac->orig_req->op.search.scope != LDB_SCOPE_BASE) {
- ac->asq_ret = ASQ_CTRL_UNWILLING_TO_PERFORM;
- return asq_terminate(handle);
- }
-
- ac->req_attrs = ac->orig_req->op.search.attrs;
- ac->req_attribute = talloc_strdup(ac, ac->asq_ctrl->source_attribute);
- if (ac->req_attribute == NULL)
- return LDB_ERR_OPERATIONS_ERROR;
-
- /* get the object to retrieve the DNs to search */
- ret = asq_build_first_request(ac);
- if (ret != LDB_SUCCESS) {
- return ret;
- }
-
- ac->step = ASQ_SEARCH_BASE;
-
- handle->state = LDB_ASYNC_PENDING;
- handle->status = LDB_SUCCESS;
-
- return ldb_request(ac->module->ldb, ac->base_req);
-
case ASQ_SEARCH_BASE:
- ret = ldb_wait(ac->base_req->handle, LDB_WAIT_NONE);
-
- if (ret != LDB_SUCCESS) {
- handle->status = ret;
- goto done;
- }
-
- if (ac->base_req->handle->status != LDB_SUCCESS) {
- handle->status = ac->base_req->handle->status;
- goto done;
+ /* build up the requests call chain */
+ ret = asq_build_multiple_requests(ac, &terminated);
+ if (ret != LDB_SUCCESS || terminated) {
+ return ret;
}
- if (ac->base_req->handle->state == LDB_ASYNC_DONE) {
+ ac->step = ASQ_SEARCH_MULTI;
- /* build up the requests call chain */
- ret = asq_build_multiple_requests(ac, handle);
- if (ret != LDB_SUCCESS) {
- return ret;
- }
- if (handle->state == LDB_ASYNC_DONE) {
- return LDB_SUCCESS;
- }
-
- ac->step = ASQ_SEARCH_MULTI;
-
- return ldb_request(ac->module->ldb, ac->reqs[ac->cur_req]);
- }
-
- /* request still pending, return to cycle again */
- return LDB_SUCCESS;
+ return ldb_request(ac->module->ldb, ac->reqs[ac->cur_req]);
case ASQ_SEARCH_MULTI:
- ret = ldb_wait(ac->reqs[ac->cur_req]->handle, LDB_WAIT_NONE);
-
- if (ret != LDB_SUCCESS) {
- handle->status = ret;
- goto done;
- }
- if (ac->reqs[ac->cur_req]->handle->status != LDB_SUCCESS) {
- handle->status = ac->reqs[ac->cur_req]->handle->status;
- }
-
- if (ac->reqs[ac->cur_req]->handle->state == LDB_ASYNC_DONE) {
- ac->cur_req++;
+ ac->cur_req++;
- if (ac->cur_req < ac->num_reqs) {
- return ldb_request(ac->module->ldb, ac->reqs[ac->cur_req]);
- }
-
- return asq_terminate(handle);
+ if (ac->cur_req == ac->num_reqs) {
+ /* done */
+ return asq_search_terminate(ac);
}
- /* request still pending, return to cycle again */
- return LDB_SUCCESS;
-
- default:
- ret = LDB_ERR_OPERATIONS_ERROR;
- break;
+ return ldb_request(ac->module->ldb, ac->reqs[ac->cur_req]);
}
-done:
- handle->state = LDB_ASYNC_DONE;
- return ret;
+ return LDB_ERR_OPERATIONS_ERROR;
}
static int asq_search(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_request *base_req;
struct ldb_control *control;
struct asq_context *ac;
- struct ldb_handle *h;
+ int ret;
/* check if there's a paged request control */
control = ldb_request_get_control(req, LDB_CONTROL_ASQ_OID);
@@ -405,67 +343,37 @@ static int asq_search(struct ldb_module *module, struct ldb_request *req)
return ldb_next_request(module, req);
}
- req->handle = NULL;
-
- if (!req->callback || !req->context) {
- ldb_set_errstring(module->ldb,
- "Async interface called with NULL callback function or NULL context");
+ ac = asq_context_init(module, req);
+ if (!ac) {
return LDB_ERR_OPERATIONS_ERROR;
}
- h = init_handle(req, module);
- if (!h) {
- return LDB_ERR_OPERATIONS_ERROR;
+ /* check the search is well formed */
+ if (req->op.search.scope != LDB_SCOPE_BASE) {
+ ac->asq_ret = ASQ_CTRL_UNWILLING_TO_PERFORM;
+ return asq_search_terminate(ac);
}
- ac = talloc_get_type(h->private_data, struct asq_context);
ac->asq_ctrl = talloc_get_type(control->data, struct ldb_asq_control);
if (!ac->asq_ctrl) {
return LDB_ERR_PROTOCOL_ERROR;
}
- req->handle = h;
-
- return asq_search_continue(h);
-}
-
-static int asq_wait(struct ldb_handle *handle, enum ldb_wait_type type)
-{
- int ret;
-
- if (!handle || !handle->private_data) {
- return LDB_ERR_OPERATIONS_ERROR;
+ ret = asq_build_first_request(ac, &base_req);
+ if (ret != LDB_SUCCESS) {
+ return ret;
}
- if (type == LDB_WAIT_ALL) {
- while (handle->state != LDB_ASYNC_DONE) {
- ret = asq_search_continue(handle);
- if (ret != LDB_SUCCESS) {
- return ret;
- }
- }
-
- return handle->status;
- }
+ ac->step = ASQ_SEARCH_BASE;
- return asq_search_continue(handle);
+ return ldb_request(module->ldb, base_req);
}
static int asq_init(struct ldb_module *module)
{
- struct ldb_request *req;
int ret;
- req = talloc_zero(module, struct ldb_request);
- if (req == NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "asq: Out of memory!\n");
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- req->operation = LDB_REQ_REGISTER_CONTROL;
- req->op.reg_control.oid = LDB_CONTROL_ASQ_OID;
-
- ret = ldb_request(module->ldb, req);
+ ret = ldb_mod_register_control(module, LDB_CONTROL_ASQ_OID);
if (ret != LDB_SUCCESS) {
ldb_debug(module->ldb, LDB_DEBUG_WARNING, "asq: Unable to register control with rootdse!\n");
}
@@ -476,6 +384,5 @@ static int asq_init(struct ldb_module *module)
const struct ldb_module_ops ldb_asq_module_ops = {
.name = "asq",
.search = asq_search,
- .wait = asq_wait,
.init_context = asq_init
};
diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c
index a59e81becd..abb1d4ca1a 100644
--- a/source4/lib/ldb/modules/operational.c
+++ b/source4/lib/ldb/modules/operational.c
@@ -2,7 +2,7 @@
ldb database library
Copyright (C) Andrew Tridgell 2005
- Copyright (C) Simo Sorce 2006
+ Copyright (C) Simo Sorce 2006-2008
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
@@ -173,38 +173,53 @@ failed:
*/
struct operational_context {
-
struct ldb_module *module;
- void *up_context;
- int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *);
+ struct ldb_request *req;
const char * const *attrs;
};
-static int operational_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
+static int operational_callback(struct ldb_request *req, struct ldb_reply *ares)
{
struct operational_context *ac;
+ int ret;
- if (!context || !ares) {
- ldb_set_errstring(ldb, "NULL Context or Result in callback");
- goto error;
- }
+ ac = talloc_get_type(req->context, struct operational_context);
- ac = talloc_get_type(context, struct operational_context);
+ if (!ares) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
+ }
- if (ares->type == LDB_REPLY_ENTRY) {
+ switch (ares->type) {
+ case LDB_REPLY_ENTRY:
/* for each record returned post-process to add any derived
attributes that have been asked for */
- if (operational_search_post_process(ac->module, ares->message, ac->attrs) != 0) {
- goto error;
+ ret = operational_search_post_process(ac->module,
+ ares->message,
+ ac->attrs);
+ if (ret != 0) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
}
- }
+ return ldb_module_send_entry(ac->req, ares->message);
- return ac->up_callback(ldb, ac->up_context, ares);
+ case LDB_REPLY_REFERRAL:
+ /* ignore referrals */
+ break;
+
+ case LDB_REPLY_DONE:
+
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, LDB_SUCCESS);
+ }
-error:
talloc_free(ares);
- return LDB_ERR_OPERATIONS_ERROR;
+ return LDB_SUCCESS;
}
static int operational_search(struct ldb_module *module, struct ldb_request *req)
@@ -212,9 +227,8 @@ static int operational_search(struct ldb_module *module, struct ldb_request *req
struct operational_context *ac;
struct ldb_request *down_req;
const char **search_attrs = NULL;
- int i, a, ret;
-
- req->handle = NULL;
+ int i, a;
+ int ret;
ac = talloc(req, struct operational_context);
if (ac == NULL) {
@@ -222,21 +236,10 @@ static int operational_search(struct ldb_module *module, struct ldb_request *req
}
ac->module = module;
- ac->up_context = req->context;
- ac->up_callback = req->callback;
+ ac->req = req;
ac->attrs = req->op.search.attrs;
- down_req = talloc_zero(req, struct ldb_request);
- if (down_req == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- down_req->operation = req->operation;
- down_req->op.search.base = req->op.search.base;
- down_req->op.search.scope = req->op.search.scope;
- down_req->op.search.tree = req->op.search.tree;
-
- /* FIXME: I hink we should copy the tree and keep the original
+ /* FIXME: We must copy the tree and keep the original
* unmodified. SSS */
/* replace any attributes in the parse tree that are
searchable, but are stored using a different name in the
@@ -264,27 +267,26 @@ static int operational_search(struct ldb_module *module, struct ldb_request *req
}
}
}
-
- /* use new set of attrs if any */
- if (search_attrs) down_req->op.search.attrs = search_attrs;
- else down_req->op.search.attrs = req->op.search.attrs;
-
- down_req->controls = req->controls;
-
- down_req->context = ac;
- down_req->callback = operational_callback;
- ldb_set_timeout_from_prev_req(module->ldb, req, down_req);
- /* perform the search */
- ret = ldb_next_request(module, down_req);
+ /* use new set of attrs if any */
+ if (search_attrs == NULL) {
+ search_attrs = req->op.search.attrs;
+ }
- /* do not free down_req as the call results may be linked to it,
- * it will be freed when the upper level request get freed */
- if (ret == LDB_SUCCESS) {
- req->handle = down_req->handle;
+ ret = ldb_build_search_req_ex(&down_req, module->ldb, ac,
+ req->op.search.base,
+ req->op.search.scope,
+ req->op.search.tree,
+ (const char * const *)search_attrs,
+ req->controls,
+ ac, operational_callback,
+ req);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- return ret;
+ /* perform the search */
+ return ldb_next_request(module, down_req);
}
static int operational_init(struct ldb_module *ctx)
diff --git a/source4/lib/ldb/modules/paged_results.c b/source4/lib/ldb/modules/paged_results.c
index b62b1f92cb..1a242f1be0 100644
--- a/source4/lib/ldb/modules/paged_results.c
+++ b/source4/lib/ldb/modules/paged_results.c
@@ -1,7 +1,7 @@
/*
ldb database library
- Copyright (C) Simo Sorce 2005-2006
+ Copyright (C) Simo Sorce 2005-2008
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
@@ -51,9 +51,8 @@ struct results_store {
char *cookie;
time_t timestamp;
- struct results_store *prev;
struct results_store *next;
-
+
struct message_store *first;
struct message_store *last;
int num_entries;
@@ -62,8 +61,6 @@ struct results_store {
struct message_store *last_ref;
struct ldb_control **controls;
-
- struct ldb_request *req;
};
struct private_data {
@@ -73,20 +70,25 @@ struct private_data {
};
-int store_destructor(struct results_store *store)
+static int store_destructor(struct results_store *del)
{
- if (store->prev) {
- store->prev->next = store->next;
- }
- if (store->next) {
- store->next->prev = store->prev;
+ struct private_data *priv = del->priv;
+ struct results_store *loop;
+
+ if (priv->store == del) {
+ priv->store = del->next;
+ return 0;
}
- if (store == store->priv->store) {
- store->priv->store = NULL;
+ for (loop = priv->store; loop; loop = loop->next) {
+ if (loop->next == del) {
+ loop->next = del->next;
+ return 0;
+ }
}
- return 0;
+ /* is not in list ? */
+ return -1;
}
static struct results_store *new_store(struct private_data *priv)
@@ -116,10 +118,7 @@ static struct results_store *new_store(struct private_data *priv)
newr->first_ref = NULL;
newr->controls = NULL;
- /* put this entry as first */
- newr->prev = NULL;
newr->next = priv->store;
- if (priv->store != NULL) priv->store->prev = newr;
priv->store = newr;
talloc_set_destructor(newr, store_destructor);
@@ -129,101 +128,164 @@ static struct results_store *new_store(struct private_data *priv)
struct paged_context {
struct ldb_module *module;
- void *up_context;
- int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *);
-
- int size;
+ struct ldb_request *req;
struct results_store *store;
+ int size;
+ struct ldb_control **controls;
};
-static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_reply *))
+static int paged_results(struct paged_context *ac)
{
- struct paged_context *ac;
- struct ldb_handle *h;
+ struct ldb_paged_control *paged;
+ struct message_store *msg;
+ int i, num_ctrls, ret;
- h = talloc_zero(mem_ctx, struct ldb_handle);
- if (h == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
- return NULL;
+ if (ac->store == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- h->module = module;
+ while (ac->store->num_entries > 0 && ac->size > 0) {
+ msg = ac->store->first;
+ ret = ldb_module_send_entry(ac->req, msg->r->message);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
- ac = talloc_zero(h, struct paged_context);
- if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
- talloc_free(h);
- return NULL;
+ ac->store->first = msg->next;
+ talloc_free(msg);
+ ac->store->num_entries--;
+ ac->size--;
}
- h->private_data = (void *)ac;
+ while (ac->store->first_ref != NULL) {
+ msg = ac->store->first_ref;
+ ret = ldb_module_send_referral(ac->req, msg->r->referral);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
- h->state = LDB_ASYNC_INIT;
- h->status = LDB_SUCCESS;
+ ac->store->first_ref = msg->next;
+ talloc_free(msg);
+ }
- ac->module = module;
- ac->up_context = context;
- ac->up_callback = callback;
+ /* return result done */
+ num_ctrls = 1;
+ i = 0;
+
+ if (ac->store->controls != NULL) {
+ while (ac->store->controls[i]) i++; /* counting */
+
+ num_ctrls += i;
+ }
+
+ ac->controls = talloc_array(ac, struct ldb_control *, num_ctrls +1);
+ if (ac->controls == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ ac->controls[num_ctrls] = NULL;
+
+ for (i = 0; i < (num_ctrls -1); i++) {
+ ac->controls[i] = talloc_reference(ac->controls, ac->store->controls[i]);
+ }
+
+ ac->controls[i] = talloc(ac->controls, struct ldb_control);
+ if (ac->controls[i] == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
- return h;
+ ac->controls[i]->oid = talloc_strdup(ac->controls[i],
+ LDB_CONTROL_PAGED_RESULTS_OID);
+ if (ac->controls[i]->oid == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ ac->controls[i]->critical = 0;
+
+ paged = talloc(ac->controls[i], struct ldb_paged_control);
+ if (paged == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ ac->controls[i]->data = paged;
+
+ if (ac->size > 0) {
+ paged->size = 0;
+ paged->cookie = NULL;
+ paged->cookie_len = 0;
+ } else {
+ paged->size = ac->store->num_entries;
+ paged->cookie = talloc_strdup(paged, ac->store->cookie);
+ paged->cookie_len = strlen(paged->cookie) + 1;
+ }
+
+ return LDB_SUCCESS;
}
-static int paged_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
+static int paged_search_callback(struct ldb_request *req, struct ldb_reply *ares)
{
- struct paged_context *ac = NULL;
+ struct paged_context *ac ;
+ struct message_store *msg_store;
+ int ret;
- if (!context || !ares) {
- ldb_set_errstring(ldb, "NULL Context or Result in callback");
- goto error;
+ ac = talloc_get_type(req->context, struct paged_context);
+
+ if (!ares) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
}
- ac = talloc_get_type(context, struct paged_context);
+ switch (ares->type) {
+ case LDB_REPLY_ENTRY:
+ msg_store = talloc(ac->store, struct message_store);
+ if (msg_store == NULL) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+ msg_store->next = NULL;
+ msg_store->r = talloc_steal(msg_store, ares);
- if (ares->type == LDB_REPLY_ENTRY) {
if (ac->store->first == NULL) {
- ac->store->first = ac->store->last = talloc(ac->store, struct message_store);
+ ac->store->first = msg_store;
} else {
- ac->store->last->next = talloc(ac->store, struct message_store);
- ac->store->last = ac->store->last->next;
- }
- if (ac->store->last == NULL) {
- goto error;
+ ac->store->last->next = msg_store;
}
+ ac->store->last = msg_store;
ac->store->num_entries++;
- ac->store->last->r = talloc_steal(ac->store->last, ares);
- ac->store->last->next = NULL;
- }
+ break;
+
+ case LDB_REPLY_REFERRAL:
+ msg_store = talloc(ac->store, struct message_store);
+ if (msg_store == NULL) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+ msg_store->next = NULL;
+ msg_store->r = talloc_steal(msg_store, ares);
- if (ares->type == LDB_REPLY_REFERRAL) {
if (ac->store->first_ref == NULL) {
- ac->store->first_ref = ac->store->last_ref = talloc(ac->store, struct message_store);
+ ac->store->first_ref = msg_store;
} else {
- ac->store->last_ref->next = talloc(ac->store, struct message_store);
- ac->store->last_ref = ac->store->last_ref->next;
- }
- if (ac->store->last_ref == NULL) {
- goto error;
+ ac->store->last_ref->next = msg_store;
}
+ ac->store->last_ref = msg_store;
- ac->store->last_ref->r = talloc_steal(ac->store->last, ares);
- ac->store->last_ref->next = NULL;
- }
+ break;
- if (ares->type == LDB_REPLY_DONE) {
+ case LDB_REPLY_DONE:
ac->store->controls = talloc_move(ac->store, &ares->controls);
- talloc_free(ares);
+ ret = paged_results(ac);
+ return ldb_module_done(ac->req, ac->controls,
+ ares->response, ret);
}
return LDB_SUCCESS;
-
-error:
- talloc_free(ares);
- return LDB_ERR_OPERATIONS_ERROR;
}
static int paged_search(struct ldb_module *module, struct ldb_request *req)
@@ -232,8 +294,8 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req)
struct private_data *private_data;
struct ldb_paged_control *paged_ctrl;
struct ldb_control **saved_controls;
+ struct ldb_request *search_req;
struct paged_context *ac;
- struct ldb_handle *h;
int ret;
/* check if there's a paged request control */
@@ -243,65 +305,57 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req)
return ldb_next_request(module, req);
}
- private_data = talloc_get_type(module->private_data, struct private_data);
-
- req->handle = NULL;
-
- if (!req->callback || !req->context) {
- ldb_set_errstring(module->ldb,
- "Async interface called with NULL callback function or NULL context");
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
paged_ctrl = talloc_get_type(control->data, struct ldb_paged_control);
if (!paged_ctrl) {
return LDB_ERR_PROTOCOL_ERROR;
}
- h = init_handle(req, module, req->context, req->callback);
- if (!h) {
+ private_data = talloc_get_type(module->private_data, struct private_data);
+
+ ac = talloc_zero(req, struct paged_context);
+ if (ac == NULL) {
+ ldb_set_errstring(module->ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(h->private_data, struct paged_context);
+ ac->module = module;
+ ac->req = req;
ac->size = paged_ctrl->size;
/* check if it is a continuation search the store */
if (paged_ctrl->cookie_len == 0) {
-
- ac->store = new_store(private_data);
- if (ac->store == NULL) {
- talloc_free(h);
- return LDB_ERR_UNWILLING_TO_PERFORM;
+ if (paged_ctrl->size == 0) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- ac->store->req = talloc(ac->store, struct ldb_request);
- if (!ac->store->req)
+ ac->store = new_store(private_data);
+ if (ac->store == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
+ }
- ac->store->req->operation = req->operation;
- ac->store->req->op.search.base = req->op.search.base;
- ac->store->req->op.search.scope = req->op.search.scope;
- ac->store->req->op.search.tree = req->op.search.tree;
- ac->store->req->op.search.attrs = req->op.search.attrs;
- ac->store->req->controls = req->controls;
+ ret = ldb_build_search_req_ex(&search_req, module->ldb, ac,
+ req->op.search.base,
+ req->op.search.scope,
+ req->op.search.tree,
+ req->op.search.attrs,
+ req->controls,
+ ac,
+ paged_search_callback,
+ req);
/* save it locally and remove it from the list */
/* we do not need to replace them later as we
* are keeping the original req intact */
- if (!save_controls(control, ac->store->req, &saved_controls)) {
+ if (!save_controls(control, search_req, &saved_controls)) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac->store->req->context = ac;
- ac->store->req->callback = paged_search_callback;
- ldb_set_timeout_from_prev_req(module->ldb, req, ac->store->req);
-
- ret = ldb_next_request(module, ac->store->req);
+ return ldb_next_request(module, search_req);
} else {
struct results_store *current = NULL;
+ /* TODO: age out old outstanding requests */
for (current = private_data->store; current; current = current->next) {
if (strcmp(current->cookie, paged_ctrl->cookie) == 0) {
current->timestamp = time(NULL);
@@ -309,249 +363,52 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req)
}
}
if (current == NULL) {
- talloc_free(h);
return LDB_ERR_UNWILLING_TO_PERFORM;
}
ac->store = current;
- ret = LDB_SUCCESS;
- }
-
- req->handle = h;
-
- /* check if it is an abandon */
- if (ac->size == 0) {
- talloc_free(ac->store);
- h->status = LDB_SUCCESS;
- h->state = LDB_ASYNC_DONE;
- return LDB_SUCCESS;
- }
-
- /* TODO: age out old outstanding requests */
-
- return ret;
-
-}
-
-static int paged_results(struct ldb_handle *handle)
-{
- struct paged_context *ac;
- struct ldb_paged_control *paged;
- struct ldb_reply *ares;
- struct message_store *msg;
- int i, num_ctrls, ret;
-
- ac = talloc_get_type(handle->private_data, struct paged_context);
-
- if (ac->store == NULL)
- return LDB_ERR_OPERATIONS_ERROR;
- while (ac->store->num_entries > 0 && ac->size > 0) {
- msg = ac->store->first;
- ret = ac->up_callback(ac->module->ldb, ac->up_context, msg->r);
- if (ret != LDB_SUCCESS) {
- handle->status = ret;
- handle->state = LDB_ASYNC_DONE;
- return ret;
+ /* check if it is an abandon */
+ if (ac->size == 0) {
+ return ldb_module_done(req, NULL, NULL,
+ LDB_SUCCESS);
}
- ac->store->first = msg->next;
- talloc_free(msg);
- ac->store->num_entries--;
- ac->size--;
- }
-
- handle->state = LDB_ASYNC_DONE;
-
- while (ac->store->first_ref != NULL) {
- msg = ac->store->first_ref;
- ret = ac->up_callback(ac->module->ldb, ac->up_context, msg->r);
+ ret = paged_results(ac);
if (ret != LDB_SUCCESS) {
- handle->status = ret;
- handle->state = LDB_ASYNC_DONE;
- return ret;
+ return ldb_module_done(req, NULL, NULL, ret);
}
-
- ac->store->first_ref = msg->next;
- talloc_free(msg);
- }
-
- ares = talloc_zero(ac->store, struct ldb_reply);
- if (ares == NULL) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- return handle->status;
- }
- num_ctrls = 2;
- i = 0;
-
- if (ac->store->controls != NULL) {
- ares->controls = ac->store->controls;
- while (ares->controls[i]) i++; /* counting */
-
- ares->controls = talloc_move(ares, &ac->store->controls);
- num_ctrls += i;
- }
-
- ares->controls = talloc_realloc(ares, ares->controls, struct ldb_control *, num_ctrls);
- if (ares->controls == NULL) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- return handle->status;
+ return ldb_module_done(req, ac->controls, NULL,
+ LDB_SUCCESS);
}
-
- ares->controls[i] = talloc(ares->controls, struct ldb_control);
- if (ares->controls[i] == NULL) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- return handle->status;
- }
-
- ares->controls[i]->oid = talloc_strdup(ares->controls[i], LDB_CONTROL_PAGED_RESULTS_OID);
- if (ares->controls[i]->oid == NULL) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- return handle->status;
- }
-
- ares->controls[i]->critical = 0;
- ares->controls[i + 1] = NULL;
-
- paged = talloc(ares->controls[i], struct ldb_paged_control);
- if (paged == NULL) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- return handle->status;
- }
-
- ares->controls[i]->data = paged;
-
- if (ac->size > 0) {
- paged->size = 0;
- paged->cookie = NULL;
- paged->cookie_len = 0;
- } else {
- paged->size = ac->store->num_entries;
- paged->cookie = talloc_strdup(paged, ac->store->cookie);
- paged->cookie_len = strlen(paged->cookie) + 1;
- }
-
- ares->type = LDB_REPLY_DONE;
-
- ret = ac->up_callback(ac->module->ldb, ac->up_context, ares);
-
- handle->status = ret;
-
- return ret;
-}
-
-static int paged_wait_once(struct ldb_handle *handle) {
- struct paged_context *ac;
- int ret;
-
- if (!handle || !handle->private_data) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- if (handle->state == LDB_ASYNC_DONE) {
- return handle->status;
- }
-
- handle->state = LDB_ASYNC_PENDING;
-
- ac = talloc_get_type(handle->private_data, struct paged_context);
-
- if (ac->store->req->handle->state == LDB_ASYNC_DONE) {
- /* if lower level is finished we do not need to call it anymore */
- /* return all we have until size == 0 or we empty storage */
- ret = paged_results(handle);
-
- /* we are done, if num_entries is zero free the storage
- * as that mean we delivered the last batch */
- if (ac->store->num_entries == 0) {
- talloc_free(ac->store);
- }
-
- return ret;
- }
-
- ret = ldb_wait(ac->store->req->handle, LDB_WAIT_NONE);
- if (ret != LDB_SUCCESS) {
- handle->state = LDB_ASYNC_DONE;
- handle->status = ret;
- return ret;
- }
-
- handle->status = ret;
-
- if (ac->store->num_entries >= ac->size ||
- ac->store->req->handle->state == LDB_ASYNC_DONE) {
-
- ret = paged_results(handle);
-
- /* we are done, if num_entries is zero free the storage
- * as that mean we delivered the last batch */
- if (ac->store->num_entries == 0) {
- talloc_free(ac->store);
- }
- }
-
- return ret;
-}
-
-static int paged_wait(struct ldb_handle *handle, enum ldb_wait_type type)
-{
- int ret;
-
- if (!handle || !handle->private_data) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- if (type == LDB_WAIT_ALL) {
- while (handle->state != LDB_ASYNC_DONE) {
- ret = paged_wait_once(handle);
- if (ret != LDB_SUCCESS) {
- return ret;
- }
- }
-
- return handle->status;
- }
-
- return paged_wait_once(handle);
}
static int paged_request_init(struct ldb_module *module)
{
struct private_data *data;
- struct ldb_request *req;
int ret;
data = talloc(module, struct private_data);
if (data == NULL) {
return LDB_ERR_OTHER;
}
-
+
data->next_free_id = 1;
data->store = NULL;
module->private_data = data;
- req = talloc(module, struct ldb_request);
- if (req == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- req->operation = LDB_REQ_REGISTER_CONTROL;
- req->op.reg_control.oid = LDB_CONTROL_PAGED_RESULTS_OID;
- req->controls = NULL;
-
- ret = ldb_request(module->ldb, req);
+ ret = ldb_mod_register_control(module, LDB_CONTROL_PAGED_RESULTS_OID);
if (ret != LDB_SUCCESS) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "paged_request: Unable to register control with rootdse!\n");
+ ldb_debug(module->ldb, LDB_DEBUG_WARNING,
+ "paged_request:"
+ "Unable to register control with rootdse!\n");
}
- talloc_free(req);
return ldb_next_init(module);
}
const struct ldb_module_ops ldb_paged_results_module_ops = {
.name = "paged_results",
.search = paged_search,
- .wait = paged_wait,
.init_context = paged_request_init
};
diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c
index 40e87f70d6..7a728e3bb0 100644
--- a/source4/lib/ldb/modules/paged_searches.c
+++ b/source4/lib/ldb/modules/paged_searches.c
@@ -1,7 +1,7 @@
/*
ldb database library
- Copyright (C) Simo Sorce 2005-2006
+ Copyright (C) Simo Sorce 2005-2008
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
@@ -46,12 +46,7 @@ struct private_data {
struct ps_context {
struct ldb_module *module;
- void *up_context;
- int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *);
-
- struct ldb_request *orig_req;
-
- struct ldb_request *new_req;
+ struct ldb_request *req;
bool pending;
@@ -59,51 +54,13 @@ struct ps_context {
int num_referrals;
};
-static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_reply *))
+static int check_ps_continuation(struct ldb_request *req, struct ldb_reply *ares)
{
struct ps_context *ac;
- struct ldb_handle *h;
-
- h = talloc_zero(mem_ctx, struct ldb_handle);
- if (h == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
- return NULL;
- }
-
- h->module = module;
-
- ac = talloc_zero(h, struct ps_context);
- if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
- talloc_free(h);
- return NULL;
- }
-
- h->private_data = (void *)ac;
-
- h->state = LDB_ASYNC_INIT;
- h->status = LDB_SUCCESS;
-
- ac->module = module;
- ac->up_context = context;
- ac->up_callback = callback;
-
- ac->pending = false;
-
-
-
- ac->saved_referrals = NULL;
- ac->num_referrals = 0;
-
- return h;
-}
-
-static int check_ps_continuation(struct ldb_reply *ares, struct ps_context *ac)
-{
struct ldb_paged_control *rep_control, *req_control;
+ ac = talloc_get_type(req->context, struct ps_context);
+
/* look up our paged control */
if (!ares->controls || strcmp(LDB_CONTROL_PAGED_RESULTS_OID, ares->controls[0]->oid) != 0) {
/* something wrong here */
@@ -122,12 +79,12 @@ static int check_ps_continuation(struct ldb_reply *ares, struct ps_context *ac)
/* if there's a reply control we must find a request
* control matching it */
- if (strcmp(LDB_CONTROL_PAGED_RESULTS_OID, ac->new_req->controls[0]->oid) != 0) {
+ if (strcmp(LDB_CONTROL_PAGED_RESULTS_OID, req->controls[0]->oid) != 0) {
/* something wrong here */
return LDB_ERR_OPERATIONS_ERROR;
}
- req_control = talloc_get_type(ac->new_req->controls[0]->data, struct ldb_paged_control);
+ req_control = talloc_get_type(req->controls[0]->data, struct ldb_paged_control);
if (req_control->cookie) {
talloc_free(req_control->cookie);
@@ -142,7 +99,7 @@ static int check_ps_continuation(struct ldb_reply *ares, struct ps_context *ac)
return LDB_SUCCESS;
}
-static int store_referral(char *referral, struct ps_context *ac)
+static int store_referral(struct ps_context *ac, char *referral)
{
ac->saved_referrals = talloc_realloc(ac, ac->saved_referrals, char *, ac->num_referrals + 2);
if (!ac->saved_referrals) {
@@ -160,13 +117,14 @@ static int store_referral(char *referral, struct ps_context *ac)
return LDB_SUCCESS;
}
-static int send_referrals(struct ldb_context *ldb, struct ps_context *ac)
+static int send_referrals(struct ps_context *ac)
{
struct ldb_reply *ares;
+ int ret;
int i;
for (i = 0; i < ac->num_referrals; i++) {
- ares = talloc_zero(ac, struct ldb_reply);
+ ares = talloc_zero(ac->req, struct ldb_reply);
if (!ares) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -174,69 +132,87 @@ static int send_referrals(struct ldb_context *ldb, struct ps_context *ac)
ares->type = LDB_REPLY_REFERRAL;
ares->referral = ac->saved_referrals[i];
- ac->up_callback(ldb, ac->up_context, ares);
+ ret = ldb_module_send_referral(ac->req, ares->referral);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
}
return LDB_SUCCESS;
}
-static int ps_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
+static int ps_next_request(struct ps_context *ac);
+
+static int ps_callback(struct ldb_request *req, struct ldb_reply *ares)
{
- struct ps_context *ac = NULL;
- int ret = LDB_ERR_OPERATIONS_ERROR;
+ struct ps_context *ac;
+ int ret;
- if (!context || !ares) {
- ldb_set_errstring(ldb, "NULL Context or Result in callback");
- goto error;
- }
+ ac = talloc_get_type(req->context, struct ps_context);
- ac = talloc_get_type(context, struct ps_context);
+ if (!ares) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
+ }
switch (ares->type) {
case LDB_REPLY_ENTRY:
- ac->up_callback(ldb, ac->up_context, ares);
+ ret = ldb_module_send_entry(ac->req, ares->message);
+ if (ret != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, NULL, NULL, ret);
+ }
break;
case LDB_REPLY_REFERRAL:
- ret = store_referral(ares->referral, ac);
+ ret = store_referral(ac, ares->referral);
if (ret != LDB_SUCCESS) {
- goto error;
+ return ldb_module_done(ac->req, NULL, NULL, ret);
}
break;
case LDB_REPLY_DONE:
- ret = check_ps_continuation(ares, ac);
+
+ ret = check_ps_continuation(req, ares);
if (ret != LDB_SUCCESS) {
- goto error;
+ return ldb_module_done(ac->req, NULL, NULL, ret);
}
- if (!ac->pending) {
+
+ if (ac->pending) {
+
+ ret = ps_next_request(ac);
+ if (ret != LDB_SUCCESS) {
+ return ldb_module_done(ac->req,
+ NULL, NULL, ret);
+ }
+
+ } else {
+
/* send referrals */
- ret = send_referrals(ldb, ac);
+ ret = send_referrals(ac);
if (ret != LDB_SUCCESS) {
- goto error;
+ return ldb_module_done(ac->req,
+ NULL, NULL, ret);
}
/* send REPLY_DONE */
- ac->up_callback(ldb, ac->up_context, ares);
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, LDB_SUCCESS);
}
break;
- default:
- goto error;
}
- return LDB_SUCCESS;
-
-error:
talloc_free(ares);
- return ret;
+ return LDB_SUCCESS;
}
static int ps_search(struct ldb_module *module, struct ldb_request *req)
{
struct private_data *private_data;
- struct ldb_paged_control *control;
struct ps_context *ac;
- struct ldb_handle *h;
private_data = talloc_get_type(module->private_data, struct private_data);
@@ -248,216 +224,151 @@ static int ps_search(struct ldb_module *module, struct ldb_request *req)
return ldb_next_request(module, req);
}
- if (!req->callback || !req->context) {
- ldb_set_errstring(module->ldb,
- "Async interface called with NULL callback function or NULL context");
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- h = init_handle(req, module, req->context, req->callback);
- if (!h) {
+ ac = talloc_zero(req, struct ps_context);
+ if (ac == NULL) {
+ ldb_oom(module->ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(h->private_data, struct ps_context);
-
- ac->new_req = talloc(ac, struct ldb_request);
- if (!ac->new_req) return LDB_ERR_OPERATIONS_ERROR;
-
- ac->new_req->controls = talloc_array(ac->new_req, struct ldb_control *, 2);
- if (!ac->new_req->controls) return LDB_ERR_OPERATIONS_ERROR;
-
- ac->new_req->controls[0] = talloc(ac->new_req->controls, struct ldb_control);
- if (!ac->new_req->controls[0]) return LDB_ERR_OPERATIONS_ERROR;
-
- control = talloc(ac->new_req->controls[0], struct ldb_paged_control);
- if (!control) return LDB_ERR_OPERATIONS_ERROR;
-
- control->size = PS_DEFAULT_PAGE_SIZE;
- control->cookie = NULL;
- control->cookie_len = 0;
-
- ac->new_req->controls[0]->oid = LDB_CONTROL_PAGED_RESULTS_OID;
- ac->new_req->controls[0]->critical = 1;
- ac->new_req->controls[0]->data = control;
-
- ac->new_req->controls[1] = NULL;
- ac->new_req->operation = req->operation;
- ac->new_req->op.search.base = req->op.search.base;
- ac->new_req->op.search.scope = req->op.search.scope;
- ac->new_req->op.search.tree = req->op.search.tree;
- ac->new_req->op.search.attrs = req->op.search.attrs;
- ac->new_req->context = ac;
- ac->new_req->callback = ps_callback;
- ldb_set_timeout_from_prev_req(module->ldb, req, ac->new_req);
-
- req->handle = h;
+ ac->module = module;
+ ac->req = req;
+ ac->pending = false;
+ ac->saved_referrals = NULL;
+ ac->num_referrals = 0;
- return ldb_next_request(module, ac->new_req);
+ return ps_next_request(ac);
}
-static int ps_continuation(struct ldb_handle *handle)
-{
- struct ps_context *ac;
+static int ps_next_request(struct ps_context *ac) {
- if (!handle || !handle->private_data) {
+ struct ldb_paged_control *control;
+ struct ldb_control **controls;
+ struct ldb_request *new_req;
+ int ret;
+
+ controls = talloc_array(ac, struct ldb_control *, 2);
+ if (!controls) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(handle->private_data, struct ps_context);
-
- /* reset the requests handle */
- ac->new_req->handle = NULL;
-
- return ldb_next_request(handle->module, ac->new_req);
-}
-
-static int ps_wait_once(struct ldb_handle *handle)
-{
- struct ps_context *ac;
- int ret;
-
- if (!handle || !handle->private_data) {
+ controls[0] = talloc(controls, struct ldb_control);
+ if (!controls[0]) {
return LDB_ERR_OPERATIONS_ERROR;
}
- if (handle->state == LDB_ASYNC_DONE) {
- return handle->status;
+ control = talloc(controls[0], struct ldb_paged_control);
+ if (!control) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- handle->state = LDB_ASYNC_PENDING;
- handle->status = LDB_SUCCESS;
-
- ac = talloc_get_type(handle->private_data, struct ps_context);
-
- ret = ldb_wait(ac->new_req->handle, LDB_WAIT_NONE);
+ control->size = PS_DEFAULT_PAGE_SIZE;
+ control->cookie = NULL;
+ control->cookie_len = 0;
+ controls[0]->oid = LDB_CONTROL_PAGED_RESULTS_OID;
+ controls[0]->critical = 1;
+ controls[0]->data = control;
+ controls[1] = NULL;
+
+ ret = ldb_build_search_req_ex(&new_req, ac->module->ldb, ac,
+ ac->req->op.search.base,
+ ac->req->op.search.scope,
+ ac->req->op.search.tree,
+ ac->req->op.search.attrs,
+ controls,
+ ac,
+ ps_callback,
+ ac->req);
if (ret != LDB_SUCCESS) {
- handle->status = ret;
- goto done;
- }
-
- if (ac->new_req->handle->status != LDB_SUCCESS) {
- handle->status = ac->new_req->handle->status;
- goto done;
- }
-
- if (ac->new_req->handle->state != LDB_ASYNC_DONE) {
- return LDB_SUCCESS;
- }
-
- /* see if we need to send another request for the next batch */
- if (ac->pending) {
- ret = ps_continuation(handle);
- if (ret != LDB_SUCCESS) {
- handle->status = ret;
- goto done;
- }
-
- /* continue the search with the next request */
- return LDB_SUCCESS;
+ return ret;
}
+ talloc_steal(new_req, controls);
- ret = LDB_SUCCESS;
-
-done:
- handle->state = LDB_ASYNC_DONE;
- return ret;
+ return ldb_next_request(ac->module, new_req);
}
-static int ps_wait(struct ldb_handle *handle, enum ldb_wait_type type)
+static int check_supported_paged(struct ldb_request *req,
+ struct ldb_reply *ares)
{
- int ret;
-
- if (!handle || !handle->private_data) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
+ struct private_data *data;
- if (type == LDB_WAIT_ALL) {
- while (handle->state != LDB_ASYNC_DONE) {
- ret = ps_wait_once(handle);
- if (ret != LDB_SUCCESS) {
- return ret;
- }
- }
+ data = talloc_get_type(req->context, struct private_data);
- return handle->status;
+ if (!ares) {
+ return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR);
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR);
}
- return ps_wait_once(handle);
-}
-static int check_supported_paged(struct ldb_context *ldb, void *context,
- struct ldb_reply *ares)
-{
- struct private_data *data;
- data = talloc_get_type(context,
- struct private_data);
- if (ares->type == LDB_REPLY_ENTRY) {
+ switch (ares->type) {
+ case LDB_REPLY_ENTRY:
if (ldb_msg_check_string_attribute(ares->message,
"supportedControl",
LDB_CONTROL_PAGED_RESULTS_OID)) {
data->paged_supported = true;
}
+ break;
+
+ case LDB_REPLY_REFERRAL:
+ /* ignore */
+ break;
+
+ case LDB_REPLY_DONE:
+ return ldb_request_done(req, LDB_SUCCESS);
}
+
+ talloc_free(ares);
return LDB_SUCCESS;
}
-
static int ps_init(struct ldb_module *module)
{
static const char *attrs[] = { "supportedControl", NULL };
struct private_data *data;
+ struct ldb_dn *base;
int ret;
struct ldb_request *req;
data = talloc(module, struct private_data);
if (data == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
- return LDB_ERR_OTHER;
+ ldb_oom(module->ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
}
module->private_data = data;
data->paged_supported = false;
- req = talloc(module, struct ldb_request);
- if (req == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
+ base = ldb_dn_new(module, module->ldb, "");
+ if (base == NULL) {
+ ldb_oom(module->ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
-
- req->operation = LDB_SEARCH;
- req->op.search.base = ldb_dn_new(req, module->ldb, "");
- req->op.search.scope = LDB_SCOPE_BASE;
-
- req->op.search.tree = ldb_parse_tree(req, "objectClass=*");
- if (req->op.search.tree == NULL) {
- ldb_set_errstring(module->ldb, "Unable to parse search expression");
- talloc_free(req);
- return LDB_ERR_OPERATIONS_ERROR;
+ ret = ldb_build_search_req(&req, module->ldb, module,
+ base, LDB_SCOPE_BASE,
+ "(objectClass=*)",
+ attrs, NULL,
+ data, check_supported_paged,
+ NULL);
+ if (ret != LDB_SUCCESS) {
+ return ret;
}
- req->op.search.attrs = attrs;
- req->controls = NULL;
- req->context = data;
- req->callback = check_supported_paged;
- ldb_set_timeout(module->ldb, req, 0); /* use default timeout */
-
ret = ldb_next_request(module, req);
-
if (ret == LDB_SUCCESS) {
ret = ldb_wait(req->handle, LDB_WAIT_ALL);
}
-
- talloc_free(req);
if (ret != LDB_SUCCESS) {
return ret;
}
+ talloc_free(base);
+ talloc_free(req);
+
return ldb_next_init(module);
}
_PUBLIC_ const struct ldb_module_ops ldb_paged_searches_module_ops = {
.name = "paged_searches",
.search = ps_search,
- .wait = ps_wait,
.init_context = ps_init
};
diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c
index 65c044c0f4..62b8ce5112 100644
--- a/source4/lib/ldb/modules/rdn_name.c
+++ b/source4/lib/ldb/modules/rdn_name.c
@@ -2,7 +2,7 @@
ldb database library
Copyright (C) Andrew Bartlet 2005
- Copyright (C) Simo Sorce 2006
+ Copyright (C) Simo Sorce 2006-2008
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
@@ -38,6 +38,14 @@
#include "ldb_includes.h"
+struct rename_context {
+
+ struct ldb_module *module;
+ struct ldb_request *req;
+
+ struct ldb_reply *ares;
+};
+
static struct ldb_message_element *rdn_name_find_attribute(const struct ldb_message *msg, const char *name)
{
int i;
@@ -51,11 +59,38 @@ static struct ldb_message_element *rdn_name_find_attribute(const struct ldb_mess
return NULL;
}
+static int rdn_name_add_callback(struct ldb_request *req,
+ struct ldb_reply *ares)
+{
+ struct rename_context *ac;
+
+ ac = talloc_get_type(req->context, struct rename_context);
+
+ if (!ares) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
+ }
+
+ if (ares->type != LDB_REPLY_DONE) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, LDB_SUCCESS);
+}
+
static int rdn_name_add(struct ldb_module *module, struct ldb_request *req)
{
struct ldb_request *down_req;
+ struct rename_context *ac;
struct ldb_message *msg;
struct ldb_message_element *attribute;
+ const struct ldb_schema_attribute *a;
const char *rdn_name;
struct ldb_val rdn_val;
int i, ret;
@@ -67,21 +102,22 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req)
return ldb_next_request(module, req);
}
- down_req = talloc(req, struct ldb_request);
- if (down_req == NULL) {
+ ac = talloc_zero(req, struct rename_context);
+ if (ac == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- *down_req = *req;
+ ac->module = module;
+ ac->req = req;
- down_req->op.add.message = msg = ldb_msg_copy_shallow(down_req, req->op.add.message);
+ msg = ldb_msg_copy_shallow(req, req->op.add.message);
if (msg == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
rdn_name = ldb_dn_get_rdn_name(msg->dn);
if (rdn_name == NULL) {
- talloc_free(down_req);
+ talloc_free(ac);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -93,7 +129,7 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req)
}
if (ldb_msg_add_value(msg, "name", &rdn_val, NULL) != 0) {
- talloc_free(down_req);
+ talloc_free(ac);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -101,14 +137,16 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req)
if (!attribute) {
if (ldb_msg_add_value(msg, rdn_name, &rdn_val, NULL) != 0) {
- talloc_free(down_req);
+ talloc_free(ac);
return LDB_ERR_OPERATIONS_ERROR;
}
} else {
- const struct ldb_schema_attribute *a = ldb_schema_attribute_by_name(module->ldb, rdn_name);
+ a = ldb_schema_attribute_by_name(module->ldb, rdn_name);
for (i = 0; i < attribute->num_values; i++) {
- if (a->syntax->comparison_fn(module->ldb, msg, &rdn_val, &attribute->values[i]) == 0) {
+ ret = a->syntax->comparison_fn(module->ldb, msg,
+ &rdn_val, &attribute->values[i]);
+ if (ret == 0) {
/* overwrite so it matches in case */
attribute->values[i] = rdn_val;
break;
@@ -118,218 +156,166 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req)
ldb_debug_set(module->ldb, LDB_DEBUG_FATAL,
"RDN mismatch on %s: %s (%s)",
ldb_dn_get_linearized(msg->dn), rdn_name, rdn_val.data);
- talloc_free(down_req);
+ talloc_free(ac);
/* Match AD's error here */
return LDB_ERR_INVALID_DN_SYNTAX;
}
}
- /* go on with the call chain */
- ret = ldb_next_request(module, down_req);
-
- /* do not free down_req as the call results may be linked to it,
- * it will be freed when the upper level request get freed */
- if (ret == LDB_SUCCESS) {
- req->handle = down_req->handle;
+ ret = ldb_build_add_req(&down_req, module->ldb, req,
+ msg,
+ req->controls,
+ ac, rdn_name_add_callback,
+ req);
+ if (ret != LDB_SUCCESS) {
+ return ret;
}
- return ret;
-}
-
-struct rename_context {
+ talloc_steal(down_req, msg);
- enum {RENAME_RENAME, RENAME_MODIFY} step;
- struct ldb_request *orig_req;
- struct ldb_request *down_req;
- struct ldb_request *mod_req;
-};
+ /* go on with the call chain */
+ return ldb_next_request(module, down_req);
+}
-static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req)
+static int rdn_modify_callback(struct ldb_request *req, struct ldb_reply *ares)
{
- struct ldb_handle *h;
struct rename_context *ac;
- ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_rename\n");
+ ac = talloc_get_type(req->context, struct rename_context);
- /* do not manipulate our control entries */
- if (ldb_dn_is_special(req->op.rename.newdn)) {
- return ldb_next_request(module, req);
+ if (!ares) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
}
-
- h = talloc_zero(req, struct ldb_handle);
- if (h == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
}
- h->module = module;
-
- ac = talloc_zero(h, struct rename_context);
- if (ac == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
+ /* the only supported reply right now is a LDB_REPLY_DONE */
+ if (ares->type != LDB_REPLY_DONE) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
}
- h->private_data = (void *)ac;
-
- h->state = LDB_ASYNC_INIT;
- h->status = LDB_SUCCESS;
-
- ac->orig_req = req;
- ac->down_req = talloc(req, struct ldb_request);
- if (ac->down_req == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- *(ac->down_req) = *req;
-
- ac->step = RENAME_RENAME;
-
- req->handle = h;
-
- /* rename first, modify "name" if rename is ok */
- return ldb_next_request(module, ac->down_req);
+ /* send saved controls eventually */
+ return ldb_module_done(ac->req, ac->ares->controls,
+ ac->ares->response, LDB_SUCCESS);
}
-static int rdn_name_rename_do_mod(struct ldb_handle *h) {
-
+static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares)
+{
struct rename_context *ac;
+ struct ldb_request *mod_req;
const char *rdn_name;
struct ldb_val rdn_val;
struct ldb_message *msg;
+ int ret;
- ac = talloc_get_type(h->private_data, struct rename_context);
+ ac = talloc_get_type(req->context, struct rename_context);
- ac->mod_req = talloc_zero(ac, struct ldb_request);
+ if (!ares) {
+ goto error;
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
+ }
- ac->mod_req->operation = LDB_MODIFY;
- ac->mod_req->op.mod.message = msg = ldb_msg_new(ac->mod_req);
- if (msg == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
+ /* the only supported reply right now is a LDB_REPLY_DONE */
+ if (ares->type != LDB_REPLY_DONE) {
+ goto error;
}
- msg->dn = ldb_dn_copy(msg, ac->orig_req->op.rename.newdn);
+ /* save reply for caller */
+ ac->ares = talloc_steal(ac, ares);
+
+ msg = ldb_msg_new(ac);
+ if (msg == NULL) {
+ goto error;
+ }
+ msg->dn = ldb_dn_copy(msg, ac->req->op.rename.newdn);
if (msg->dn == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
+ goto error;
}
-
- rdn_name = ldb_dn_get_rdn_name(ac->orig_req->op.rename.newdn);
+ rdn_name = ldb_dn_get_rdn_name(ac->req->op.rename.newdn);
if (rdn_name == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
+ goto error;
}
- rdn_val = ldb_val_dup(msg, ldb_dn_get_rdn_val(ac->orig_req->op.rename.newdn));
+ rdn_val = ldb_val_dup(msg, ldb_dn_get_rdn_val(ac->req->op.rename.newdn));
if (ldb_msg_add_empty(msg, rdn_name, LDB_FLAG_MOD_REPLACE, NULL) != 0) {
- return LDB_ERR_OPERATIONS_ERROR;
+ goto error;
}
if (ldb_msg_add_value(msg, rdn_name, &rdn_val, NULL) != 0) {
- return LDB_ERR_OPERATIONS_ERROR;
+ goto error;
}
if (ldb_msg_add_empty(msg, "name", LDB_FLAG_MOD_REPLACE, NULL) != 0) {
- return LDB_ERR_OPERATIONS_ERROR;
+ goto error;
}
if (ldb_msg_add_value(msg, "name", &rdn_val, NULL) != 0) {
- return LDB_ERR_OPERATIONS_ERROR;
+ goto error;
}
- ldb_set_timeout_from_prev_req(h->module->ldb, ac->orig_req, ac->mod_req);
-
- ac->step = RENAME_MODIFY;
+ ret = ldb_build_mod_req(&mod_req, ac->module->ldb,
+ ac, msg, NULL,
+ ac, rdn_modify_callback,
+ req);
+ if (ret != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, NULL, NULL, ret);
+ }
+ talloc_steal(mod_req, msg);
/* do the mod call */
- return ldb_request(h->module->ldb, ac->mod_req);
+ return ldb_request(ac->module->ldb, mod_req);
+
+error:
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
}
-static int rdn_name_wait_once(struct ldb_handle *handle)
+static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req)
{
struct rename_context *ac;
+ struct ldb_request *down_req;
int ret;
-
- if (!handle || !handle->private_data) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- if (handle->state == LDB_ASYNC_DONE) {
- return handle->status;
- }
- handle->state = LDB_ASYNC_PENDING;
- handle->status = LDB_SUCCESS;
-
- ac = talloc_get_type(handle->private_data, struct rename_context);
-
- switch(ac->step) {
- case RENAME_RENAME:
- ret = ldb_wait(ac->down_req->handle, LDB_WAIT_NONE);
- if (ret != LDB_SUCCESS) {
- handle->status = ret;
- goto done;
- }
- if (ac->down_req->handle->status != LDB_SUCCESS) {
- handle->status = ac->down_req->handle->status;
- goto done;
- }
-
- if (ac->down_req->handle->state != LDB_ASYNC_DONE) {
- return LDB_SUCCESS;
- }
-
- /* rename operation done */
- return rdn_name_rename_do_mod(handle);
-
- case RENAME_MODIFY:
- ret = ldb_wait(ac->mod_req->handle, LDB_WAIT_NONE);
- if (ret != LDB_SUCCESS) {
- handle->status = ret;
- goto done;
- }
- if (ac->mod_req->handle->status != LDB_SUCCESS) {
- handle->status = ac->mod_req->handle->status;
- goto done;
- }
-
- if (ac->mod_req->handle->state != LDB_ASYNC_DONE) {
- return LDB_SUCCESS;
- }
-
- break;
+ ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_rename\n");
- default:
- ret = LDB_ERR_OPERATIONS_ERROR;
- goto done;
+ /* do not manipulate our control entries */
+ if (ldb_dn_is_special(req->op.rename.newdn)) {
+ return ldb_next_request(module, req);
}
- ret = LDB_SUCCESS;
-
-done:
- handle->state = LDB_ASYNC_DONE;
- return ret;
-}
-
-static int rdn_name_wait(struct ldb_handle *handle, enum ldb_wait_type type)
-{
- int ret;
-
- if (!handle || !handle->private_data) {
+ ac = talloc_zero(req, struct rename_context);
+ if (ac == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- if (type == LDB_WAIT_ALL) {
- while (handle->state != LDB_ASYNC_DONE) {
- ret = rdn_name_wait_once(handle);
- if (ret != LDB_SUCCESS) {
- return ret;
- }
- }
+ ac->module = module;
+ ac->req = req;
- return handle->status;
+ ret = ldb_build_rename_req(&down_req,
+ module->ldb,
+ ac,
+ req->op.rename.olddn,
+ req->op.rename.newdn,
+ req->controls,
+ ac,
+ rdn_rename_callback,
+ req);
+
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- return rdn_name_wait_once(handle);
+ /* rename first, modify "name" if rename is ok */
+ return ldb_next_request(module, down_req);
}
const struct ldb_module_ops ldb_rdn_name_module_ops = {
.name = "rdn_name",
.add = rdn_name_add,
.rename = rdn_name_rename,
- .wait = rdn_name_wait
};
diff --git a/source4/lib/ldb/modules/sort.c b/source4/lib/ldb/modules/sort.c
index 746befa559..64d60f370c 100644
--- a/source4/lib/ldb/modules/sort.c
+++ b/source4/lib/ldb/modules/sort.c
@@ -1,7 +1,7 @@
/*
ldb database library
- Copyright (C) Simo Sorce 2005
+ Copyright (C) Simo Sorce 2005-2008
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
@@ -43,8 +43,6 @@ struct opaque {
struct sort_context {
struct ldb_module *module;
- void *up_context;
- int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *);
char *attributeName;
char *orderingRule;
@@ -53,7 +51,6 @@ struct sort_context {
struct ldb_request *req;
struct ldb_message **msgs;
char **referrals;
- struct ldb_control **controls;
int num_msgs;
int num_refs;
@@ -61,40 +58,6 @@ struct sort_context {
int sort_result;
};
-static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_reply *))
-{
- struct sort_context *ac;
- struct ldb_handle *h;
-
- h = talloc_zero(mem_ctx, struct ldb_handle);
- if (h == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
- return NULL;
- }
-
- h->module = module;
-
- ac = talloc_zero(h, struct sort_context);
- if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
- talloc_free(h);
- return NULL;
- }
-
- h->private_data = (void *)ac;
-
- h->state = LDB_ASYNC_INIT;
- h->status = LDB_SUCCESS;
-
- ac->module = module;
- ac->up_context = context;
- ac->up_callback = callback;
-
- return h;
-}
-
static int build_response(void *mem_ctx, struct ldb_control ***ctrls, int result, const char *desc)
{
struct ldb_control **controls;
@@ -142,7 +105,7 @@ static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, vo
struct sort_context *ac = talloc_get_type(opaque, struct sort_context);
struct ldb_message_element *el1, *el2;
- if (ac->sort_result != 0) {
+ if (!ac || ac->sort_result != 0) {
/* an error occurred previously,
* let's exit the sorting by returning always 0 */
return 0;
@@ -154,7 +117,7 @@ static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, vo
if (!el1 || !el2) {
/* the attribute was not found return and
* set an error */
- ac->sort_result = 53;
+ ac->sort_result = LDB_ERR_UNWILLING_TO_PERFORM;
return 0;
}
@@ -164,51 +127,111 @@ static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, vo
return ac->a->syntax->comparison_fn(ac->module->ldb, ac, &el1->values[0], &el2->values[0]);
}
-static int server_sort_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
+static int server_sort_results(struct sort_context *ac)
{
- struct sort_context *ac = NULL;
-
- if (!context || !ares) {
- ldb_set_errstring(ldb, "NULL Context or Result in callback");
- goto error;
- }
+ struct ldb_reply *ares;
+ int i, ret;
+
+ ac->a = ldb_schema_attribute_by_name(ac->module->ldb, ac->attributeName);
+ ac->sort_result = 0;
+
+ ldb_qsort(ac->msgs, ac->num_msgs,
+ sizeof(struct ldb_message *),
+ ac, (ldb_qsort_cmp_fn_t)sort_compare);
+
+ if (ac->sort_result != LDB_SUCCESS) {
+ return ac->sort_result;
+ }
+
+ for (i = 0; i < ac->num_msgs; i++) {
+ ares = talloc_zero(ac, struct ldb_reply);
+ if (!ares) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ ares->type = LDB_REPLY_ENTRY;
+ ares->message = talloc_move(ares, &ac->msgs[i]);
+
+ ret = ldb_module_send_entry(ac->req, ares->message);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+ }
+
+ for (i = 0; i < ac->num_refs; i++) {
+ ares = talloc_zero(ac, struct ldb_reply);
+ if (!ares) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ ares->type = LDB_REPLY_REFERRAL;
+ ares->referral = talloc_move(ares, &ac->referrals[i]);
+
+ ret = ldb_module_send_referral(ac->req, ares->referral);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+ }
+
+ return LDB_SUCCESS;
+}
+
+static int server_sort_search_callback(struct ldb_request *req, struct ldb_reply *ares)
+{
+ struct sort_context *ac;
+ int ret;
- ac = talloc_get_type(context, struct sort_context);
+ ac = talloc_get_type(req->context, struct sort_context);
- if (ares->type == LDB_REPLY_ENTRY) {
+ if (!ares) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
+ }
+
+ switch (ares->type) {
+ case LDB_REPLY_ENTRY:
ac->msgs = talloc_realloc(ac, ac->msgs, struct ldb_message *, ac->num_msgs + 2);
if (! ac->msgs) {
- goto error;
+ talloc_free(ares);
+ ldb_oom(ac->module->ldb);
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
}
- ac->msgs[ac->num_msgs + 1] = NULL;
-
- ac->msgs[ac->num_msgs] = talloc_move(ac->msgs, &ares->message);
+ ac->msgs[ac->num_msgs] = talloc_steal(ac->msgs, ares->message);
ac->num_msgs++;
- }
+ ac->msgs[ac->num_msgs] = NULL;
- if (ares->type == LDB_REPLY_REFERRAL) {
+ break;
+
+ case LDB_REPLY_REFERRAL:
ac->referrals = talloc_realloc(ac, ac->referrals, char *, ac->num_refs + 2);
if (! ac->referrals) {
- goto error;
+ talloc_free(ares);
+ ldb_oom(ac->module->ldb);
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
}
- ac->referrals[ac->num_refs + 1] = NULL;
- ac->referrals[ac->num_refs] = talloc_move(ac->referrals, &ares->referral);
-
+ ac->referrals[ac->num_refs] = talloc_steal(ac->referrals, ares->referral);
ac->num_refs++;
- }
+ ac->referrals[ac->num_refs] = NULL;
- if (ares->type == LDB_REPLY_DONE) {
- ac->controls = talloc_move(ac, &ares->controls);
+ break;
+
+ case LDB_REPLY_DONE:
+
+ ret = server_sort_results(ac);
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ret);
}
talloc_free(ares);
return LDB_SUCCESS;
-
-error:
- talloc_free(ares);
- return LDB_ERR_OPERATIONS_ERROR;
}
static int server_sort_search(struct ldb_module *module, struct ldb_request *req)
@@ -216,8 +239,9 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req
struct ldb_control *control;
struct ldb_server_sort_control **sort_ctrls;
struct ldb_control **saved_controls;
+ struct ldb_control **controls;
+ struct ldb_request *down_req;
struct sort_context *ac;
- struct ldb_handle *h;
int ret;
/* check if there's a paged request control */
@@ -227,19 +251,14 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req
return ldb_next_request(module, req);
}
- req->handle = NULL;
-
- if (!req->callback || !req->context) {
- ldb_set_errstring(module->ldb,
- "Async interface called with NULL callback function or NULL context");
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- h = init_handle(req, module, req->context, req->callback);
- if (!h) {
+ ac = talloc_zero(req, struct sort_context);
+ if (ac == NULL) {
+ ldb_oom(module->ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(h->private_data, struct sort_context);
+
+ ac->module = module;
+ ac->req = req;
sort_ctrls = talloc_get_type(control->data, struct ldb_server_sort_control *);
if (!sort_ctrls) {
@@ -251,26 +270,20 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req
if (sort_ctrls[1] != NULL) {
if (control->critical) {
- struct ldb_reply *ares;
-
- ares = talloc_zero(req, struct ldb_reply);
- if (!ares)
- return LDB_ERR_OPERATIONS_ERROR;
- /* 53 = unwilling to perform */
- ares->type = LDB_REPLY_DONE;
- if ((ret = build_response(ares, &ares->controls, 53, "sort control is not complete yet")) != LDB_SUCCESS) {
- return ret;
+ /* callback immediately */
+ ret = build_response(req, &controls,
+ LDB_ERR_UNWILLING_TO_PERFORM,
+ "sort control is not complete yet");
+ if (ret != LDB_SUCCESS) {
+ return ldb_module_done(req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
}
- h->status = LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
- h->state = LDB_ASYNC_DONE;
- ret = ac->up_callback(module->ldb, ac->up_context, ares);
-
- return ret;
+ return ldb_module_done(req, controls, NULL, ret);
} else {
/* just pass the call down and don't do any sorting */
- ldb_next_request(module, req);
+ return ldb_next_request(module, req);
}
}
@@ -278,181 +291,45 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req
ac->orderingRule = sort_ctrls[0]->orderingRule;
ac->reverse = sort_ctrls[0]->reverse;
- ac->req = talloc(req, struct ldb_request);
- if (!ac->req)
+ ret = ldb_build_search_req_ex(&down_req, module->ldb, ac,
+ req->op.search.base,
+ req->op.search.scope,
+ req->op.search.tree,
+ req->op.search.attrs,
+ req->controls,
+ ac,
+ server_sort_search_callback,
+ req);
+ if (ret != LDB_SUCCESS) {
return LDB_ERR_OPERATIONS_ERROR;
-
- ac->req->operation = req->operation;
- ac->req->op.search.base = req->op.search.base;
- ac->req->op.search.scope = req->op.search.scope;
- ac->req->op.search.tree = req->op.search.tree;
- ac->req->op.search.attrs = req->op.search.attrs;
- ac->req->controls = req->controls;
+ }
/* save it locally and remove it from the list */
/* we do not need to replace them later as we
* are keeping the original req intact */
- if (!save_controls(control, ac->req, &saved_controls)) {
+ if (!save_controls(control, down_req, &saved_controls)) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac->req->context = ac;
- ac->req->callback = server_sort_search_callback;
- ldb_set_timeout_from_prev_req(module->ldb, req, ac->req);
-
- req->handle = h;
-
- return ldb_next_request(module, ac->req);
-}
-
-static int server_sort_results(struct ldb_handle *handle)
-{
- struct sort_context *ac;
- struct ldb_reply *ares;
- int i, ret;
-
- ac = talloc_get_type(handle->private_data, struct sort_context);
-
- ac->a = ldb_schema_attribute_by_name(ac->module->ldb, ac->attributeName);
- ac->sort_result = 0;
-
- ldb_qsort(ac->msgs, ac->num_msgs,
- sizeof(struct ldb_message *),
- ac, (ldb_qsort_cmp_fn_t)sort_compare);
-
- for (i = 0; i < ac->num_msgs; i++) {
- ares = talloc_zero(ac, struct ldb_reply);
- if (!ares) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- return handle->status;
- }
-
- ares->type = LDB_REPLY_ENTRY;
- ares->message = talloc_move(ares, &ac->msgs[i]);
-
- handle->status = ac->up_callback(ac->module->ldb, ac->up_context, ares);
- if (handle->status != LDB_SUCCESS) {
- return handle->status;
- }
- }
-
- for (i = 0; i < ac->num_refs; i++) {
- ares = talloc_zero(ac, struct ldb_reply);
- if (!ares) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- return handle->status;
- }
-
- ares->type = LDB_REPLY_REFERRAL;
- ares->referral = talloc_move(ares, &ac->referrals[i]);
-
- handle->status = ac->up_callback(ac->module->ldb, ac->up_context, ares);
- if (handle->status != LDB_SUCCESS) {
- return handle->status;
- }
- }
-
- ares = talloc_zero(ac, struct ldb_reply);
- if (!ares) {
- handle->status = LDB_ERR_OPERATIONS_ERROR;
- return handle->status;
- }
-
- ares->type = LDB_REPLY_DONE;
- ares->controls = talloc_move(ares, &ac->controls);
-
- handle->status = ac->up_callback(ac->module->ldb, ac->up_context, ares);
- if (handle->status != LDB_SUCCESS) {
- return handle->status;
- }
-
- if ((ret = build_response(ac, &ac->controls, ac->sort_result, "sort control is not complete yet")) != LDB_SUCCESS) {
- return ret;
- }
-
- return LDB_SUCCESS;
-}
-
-static int server_sort_wait_once(struct ldb_handle *handle)
-{
- struct sort_context *ac;
- int ret;
-
- if (!handle || !handle->private_data) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- ac = talloc_get_type(handle->private_data, struct sort_context);
-
- ret = ldb_wait(ac->req->handle, LDB_WAIT_NONE);
-
- if (ret != LDB_SUCCESS) {
- handle->status = ret;
- return ret;
- }
-
- handle->state = ac->req->handle->state;
- handle->status = ac->req->handle->status;
-
- if (handle->status != LDB_SUCCESS) {
- return handle->status;
- }
-
- if (handle->state == LDB_ASYNC_DONE) {
- ret = server_sort_results(handle);
- }
-
- return ret;
-}
-
-static int server_sort_wait(struct ldb_handle *handle, enum ldb_wait_type type)
-{
- int ret;
-
- if (!handle || !handle->private_data) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- if (type == LDB_WAIT_ALL) {
- while (handle->state != LDB_ASYNC_DONE) {
- ret = server_sort_wait_once(handle);
- if (ret != LDB_SUCCESS) {
- return ret;
- }
- }
-
- return handle->status;
- }
-
- return server_sort_wait_once(handle);
+ return ldb_next_request(module, down_req);
}
static int server_sort_init(struct ldb_module *module)
{
- struct ldb_request *req;
int ret;
- req = talloc(module, struct ldb_request);
- if (req == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- req->operation = LDB_REQ_REGISTER_CONTROL;
- req->op.reg_control.oid = LDB_CONTROL_SERVER_SORT_OID;
- req->controls = NULL;
-
- ret = ldb_request(module->ldb, req);
+ ret = ldb_mod_register_control(module, LDB_CONTROL_SERVER_SORT_OID);
if (ret != LDB_SUCCESS) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "server_sort: Unable to register control with rootdse!\n");
+ ldb_debug(module->ldb, LDB_DEBUG_WARNING,
+ "server_sort:"
+ "Unable to register control with rootdse!\n");
}
- talloc_free(req);
return ldb_next_init(module);
}
const struct ldb_module_ops ldb_server_sort_module_ops = {
.name = "server_sort",
.search = server_sort_search,
- .wait = server_sort_wait,
.init_context = server_sort_init
};
diff --git a/source4/lib/ldb/nssldb/ldb-grp.c b/source4/lib/ldb/nssldb/ldb-grp.c
index 71e27a9161..5e7556dc73 100644
--- a/source4/lib/ldb/nssldb/ldb-grp.c
+++ b/source4/lib/ldb/nssldb/ldb-grp.c
@@ -60,11 +60,12 @@ NSS_STATUS _nss_ldb_setgrent(void)
}
ret = ldb_search(_ldb_nss_ctx->ldb,
+ _ldb_nss_ctx->ldb,
+ &_ldb_nss_ctx->gr_res,
_ldb_nss_ctx->base,
LDB_SCOPE_SUBTREE,
- _LDB_NSS_GRENT_FILTER,
_ldb_nss_gr_attrs,
- &_ldb_nss_ctx->gr_res);
+ _LDB_NSS_GRENT_FILTER);
if (ret != LDB_SUCCESS) {
return NSS_STATUS_UNAVAIL;
}
@@ -178,11 +179,12 @@ NSS_STATUS _nss_ldb_getgrnam_r(const char *name, struct group *result_buf, char
/* search the entry */
ret = ldb_search(_ldb_nss_ctx->ldb,
+ _ldb_nss_ctx->ldb,
+ &gr_res,
_ldb_nss_ctx->base,
LDB_SCOPE_SUBTREE,
- filter,
_ldb_nss_gr_attrs,
- &gr_res);
+ filter);
if (ret != LDB_SUCCESS) {
/* this is a fatal error */
*errnop = errno = ENOENT;
@@ -275,11 +277,12 @@ NSS_STATUS _nss_ldb_getgrgid_r(gid_t gid, struct group *result_buf, char *buffer
/* search the entry */
ret = ldb_search(_ldb_nss_ctx->ldb,
+ _ldb_nss_ctx->ldb,
+ &gr_res,
_ldb_nss_ctx->base,
LDB_SCOPE_SUBTREE,
- filter,
_ldb_nss_gr_attrs,
- &gr_res);
+ filter);
if (ret != LDB_SUCCESS) {
/* this is a fatal error */
*errnop = errno = ENOENT;
@@ -367,11 +370,12 @@ NSS_STATUS _nss_ldb_initgroups_dyn(const char *user, gid_t group, long int *star
/* search the entry */
ret = ldb_search(_ldb_nss_ctx->ldb,
+ _ldb_nss_ctx->ldb,
+ &uid_res,
_ldb_nss_ctx->base,
LDB_SCOPE_SUBTREE,
- filter,
attrs,
- &uid_res);
+ filter);
if (ret != LDB_SUCCESS) {
/* this is a fatal error */
*errnop = errno = ENOENT;
diff --git a/source4/lib/ldb/nssldb/ldb-pwd.c b/source4/lib/ldb/nssldb/ldb-pwd.c
index 44b0ab21ee..6ab103a6fe 100644
--- a/source4/lib/ldb/nssldb/ldb-pwd.c
+++ b/source4/lib/ldb/nssldb/ldb-pwd.c
@@ -47,11 +47,12 @@ NSS_STATUS _nss_ldb_setpwent(void)
}
ret = ldb_search(_ldb_nss_ctx->ldb,
+ _ldb_nss_ctx->ldb,
+ &_ldb_nss_ctx->pw_res,
_ldb_nss_ctx->base,
LDB_SCOPE_SUBTREE,
- _LDB_NSS_PWENT_FILTER,
_ldb_nss_pw_attrs,
- &_ldb_nss_ctx->pw_res);
+ _LDB_NSS_PWENT_FILTER);
if (ret != LDB_SUCCESS) {
return NSS_STATUS_UNAVAIL;
}
@@ -137,11 +138,12 @@ NSS_STATUS _nss_ldb_getpwuid_r(uid_t uid, struct passwd *result_buf, char *buffe
/* search the entry */
ret = ldb_search(_ldb_nss_ctx->ldb,
+ _ldb_nss_ctx->ldb,
+ &res,
_ldb_nss_ctx->base,
LDB_SCOPE_SUBTREE,
- filter,
_ldb_nss_pw_attrs,
- &res);
+ filter);
if (ret != LDB_SUCCESS) {
/* this is a fatal error */
*errnop = errno = ENOENT;
@@ -198,11 +200,12 @@ NSS_STATUS _nss_ldb_getpwnam_r(const char *name, struct passwd *result_buf, char
/* search the entry */
ret = ldb_search(_ldb_nss_ctx->ldb,
+ _ldb_nss_ctx->ldb,
+ &res,
_ldb_nss_ctx->base,
LDB_SCOPE_SUBTREE,
- filter,
_ldb_nss_pw_attrs,
- &res);
+ filter);
if (ret != LDB_SUCCESS) {
/* this is a fatal error */
*errnop = errno = ENOENT;
diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py
index 99ad1a9e66..4b3501839f 100755
--- a/source4/lib/ldb/tests/python/api.py
+++ b/source4/lib/ldb/tests/python/api.py
@@ -2,7 +2,7 @@
# Simple tests for the ldb python bindings.
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-import sys
+import os, sys
import unittest
# Required for the standalone LDB build
@@ -48,6 +48,14 @@ class SimpleLdb(unittest.TestCase):
x = ldb.Ldb()
x.set_modules_dir("/tmp")
+ def test_modules_none(self):
+ x = ldb.Ldb()
+ self.assertEquals([], x.modules())
+
+ def test_modules_tdb(self):
+ x = ldb.Ldb("bar.ldb")
+ self.assertEquals("[<ldb module 'tdb'>]", repr(x.modules()))
+
def test_search(self):
l = ldb.Ldb("foo.ldb")
self.assertEquals(len(l.search()), 1)
@@ -451,12 +459,32 @@ class MessageElementTests(unittest.TestCase):
x = ldb.MessageElement(["foo"])
self.assertEquals("foo", x)
-class ExampleModule:
- name = "example"
-
class ModuleTests(unittest.TestCase):
def test_register_module(self):
- ldb.register_module(ExampleModule())
+ class ExampleModule:
+ name = "example"
+ ldb.register_module(ExampleModule)
+
+ def test_use_module(self):
+ ops = []
+ class ExampleModule:
+ name = "bla"
+
+ def __init__(self, ldb, next):
+ ops.append("init")
+ self.next = next
+
+ def search(self, *args, **kwargs):
+ return self.next.search(*args, **kwargs)
+
+ ldb.register_module(ExampleModule)
+ if os.path.exists("usemodule.ldb"):
+ os.unlink("usemodule.ldb")
+ l = ldb.Ldb("usemodule.ldb")
+ l.add({"dn": "@MODULES", "@LIST": "bla"})
+ self.assertEquals([], ops)
+ l = ldb.Ldb("usemodule.ldb")
+ self.assertEquals(["init"], ops)
if __name__ == '__main__':
import unittest
diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py
index bc6f80e856..71fd98876e 100755
--- a/source4/lib/ldb/tests/python/ldap.py
+++ b/source4/lib/ldb/tests/python/ldap.py
@@ -8,6 +8,7 @@ import sys
import time
sys.path.append("bin/python")
+sys.path.append("../lib/subunit/python")
import samba.getopt as options
@@ -755,7 +756,7 @@ member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + self.base_dn + """
ldb.delete(res[0].dn)
- attrs = ["cn", "name", "objectClass", "objectGUID", "whenCreated", "nTSecurityDescriptor", "memberOf"]
+ attrs = ["cn", "name", "objectClass", "objectGUID", "whenCreated", "nTSecurityDescriptor", "memberOf", "allowedAttributes", "allowedAttributesEffective"]
print "Testing ldb.search for (&(cn=ldaptestUSer2)(objectClass=user))"
res = ldb.search(self.base_dn, expression="(&(cn=ldaptestUSer2)(objectClass=user))", scope=SCOPE_SUBTREE, attrs=attrs)
self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestUSer2)(objectClass=user))")
@@ -767,9 +768,11 @@ member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + self.base_dn + """
self.assertTrue("objectGUID" in res[0])
self.assertTrue("whenCreated" in res[0])
self.assertTrue("nTSecurityDescriptor" in res[0])
+ self.assertTrue("allowedAttributes" in res[0])
+ self.assertTrue("allowedAttributesEffective" in res[0])
self.assertEquals(res[0]["memberOf"][0].upper(), ("CN=ldaptestgroup2,CN=Users," + self.base_dn).upper())
- attrs = ["cn", "name", "objectClass", "objectGUID", "whenCreated", "nTSecurityDescriptor", "member"]
+ attrs = ["cn", "name", "objectClass", "objectGUID", "whenCreated", "nTSecurityDescriptor", "member", "allowedAttributes", "allowedAttributesEffective"]
print "Testing ldb.search for (&(cn=ldaptestgroup2)(objectClass=group))"
res = ldb.search(self.base_dn, expression="(&(cn=ldaptestgroup2)(objectClass=group))", scope=SCOPE_SUBTREE, attrs=attrs)
self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestgroup2)(objectClass=group))")
@@ -781,7 +784,12 @@ member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + self.base_dn + """
self.assertTrue("objectGuid" not in res[0])
self.assertTrue("whenCreated" in res[0])
self.assertTrue("nTSecurityDescriptor" in res[0])
- self.assertEquals(res[0]["member"][0].upper(), ("CN=ldaptestuser2,CN=Users," + self.base_dn).upper())
+ self.assertTrue("allowedAttributes" in res[0])
+ self.assertTrue("allowedAttributesEffective" in res[0])
+ memberUP = []
+ for m in res[0]["member"]:
+ memberUP.append(m.upper())
+ self.assertTrue(("CN=ldaptestuser2,CN=Users," + self.base_dn).upper() in memberUP)
ldb.modify_ldif("""
dn: cn=ldaptestgroup2,cn=users,""" + self.base_dn + """
diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c
index e66d4fb973..22d4aa6976 100644
--- a/source4/lib/ldb/tools/ldbdel.c
+++ b/source4/lib/ldb/tools/ldbdel.c
@@ -40,7 +40,7 @@ static int ldb_delete_recursive(struct ldb_context *ldb, struct ldb_dn *dn)
const char *attrs[] = { NULL };
struct ldb_result *res;
- ret = ldb_search(ldb, dn, LDB_SCOPE_SUBTREE, "distinguishedName=*", attrs, &res);
+ ret = ldb_search(ldb, ldb, &res, dn, LDB_SCOPE_SUBTREE, attrs, "distinguishedName=*");
if (ret != LDB_SUCCESS) return -1;
for (i = 0; i < res->count; i++) {
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c
index e58a5a271e..b2a040cd09 100644
--- a/source4/lib/ldb/tools/ldbedit.c
+++ b/source4/lib/ldb/tools/ldbedit.c
@@ -303,7 +303,7 @@ int main(int argc, const char **argv)
}
}
- ret = ldb_search(ldb, basedn, options->scope, expression, attrs, &result);
+ ret = ldb_search(ldb, ldb, &result, basedn, options->scope, attrs, "%s", expression);
if (ret != LDB_SUCCESS) {
printf("search failed - %s\n", ldb_errstring(ldb));
exit(1);
diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c
index b3d1f934a6..ceabd5cd78 100644
--- a/source4/lib/ldb/tools/ldbsearch.c
+++ b/source4/lib/ldb/tools/ldbsearch.c
@@ -56,6 +56,7 @@ static int do_compare_msg(struct ldb_message **el1,
}
struct search_context {
+ struct ldb_context *ldb;
struct ldb_control **req_ctrls;
int sort;
@@ -101,7 +102,7 @@ static int store_referral(char *referral, struct search_context *sctx) {
return 0;
}
-static int display_message(struct ldb_context *ldb, struct ldb_message *msg, struct search_context *sctx) {
+static int display_message(struct ldb_message *msg, struct search_context *sctx) {
struct ldb_ldif ldif;
sctx->entries++;
@@ -119,7 +120,7 @@ static int display_message(struct ldb_context *ldb, struct ldb_message *msg, str
ldb_msg_sort_elements(ldif.msg);
}
- ldb_ldif_write_file(ldb, stdout, &ldif);
+ ldb_ldif_write_file(sctx->ldb, stdout, &ldif);
return 0;
}
@@ -133,18 +134,26 @@ static int display_referral(char *referral, struct search_context *sctx)
return 0;
}
-static int search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
+static int search_callback(struct ldb_request *req, struct ldb_reply *ares)
{
- struct search_context *sctx = talloc_get_type(context, struct search_context);
+ struct search_context *sctx;
int ret;
+
+ sctx = talloc_get_type(req->context, struct search_context);
+
+ if (!ares) {
+ return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR);
+ }
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_request_done(req, ares->error);
+ }
switch (ares->type) {
-
case LDB_REPLY_ENTRY:
if (sctx->sort) {
ret = store_message(ares->message, sctx);
} else {
- ret = display_message(ldb, ares->message, sctx);
+ ret = display_message(ares->message, sctx);
}
break;
@@ -154,6 +163,9 @@ static int search_callback(struct ldb_context *ldb, void *context, struct ldb_re
} else {
ret = display_referral(ares->referral, sctx);
}
+ if (ret) {
+ return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR);
+ }
break;
case LDB_REPLY_DONE:
@@ -161,22 +173,13 @@ static int search_callback(struct ldb_context *ldb, void *context, struct ldb_re
if (handle_controls_reply(ares->controls, sctx->req_ctrls) == 1)
sctx->pending = 1;
}
- ret = 0;
- break;
-
- default:
- fprintf(stderr, "unknown Reply Type\n");
- return LDB_ERR_OTHER;
- }
-
- if (talloc_free(ares) == -1) {
- fprintf(stderr, "talloc_free failed\n");
- sctx->pending = 0;
- return LDB_ERR_OPERATIONS_ERROR;
+ talloc_free(ares);
+ return ldb_request_done(req, LDB_SUCCESS);
}
+ talloc_free(ares);
if (ret) {
- return LDB_ERR_OPERATIONS_ERROR;
+ return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR);
}
return LDB_SUCCESS;
@@ -192,12 +195,12 @@ static int do_search(struct ldb_context *ldb,
struct search_context *sctx;
int ret;
- req = talloc(ldb, struct ldb_request);
- if (!req) return -1;
+ req = NULL;
- sctx = talloc(req, struct search_context);
+ sctx = talloc(ldb, struct search_context);
if (!sctx) return -1;
+ sctx->ldb = ldb;
sctx->sort = options->sorted;
sctx->num_stored = 0;
sctx->refs_stored = 0;
@@ -214,18 +217,22 @@ static int do_search(struct ldb_context *ldb,
basedn = ldb_get_default_basedn(ldb);
}
- req->operation = LDB_SEARCH;
- req->op.search.base = basedn;
- req->op.search.scope = options->scope;
- req->op.search.tree = ldb_parse_tree(req, expression);
- if (req->op.search.tree == NULL) return -1;
- req->op.search.attrs = attrs;
- req->controls = sctx->req_ctrls;
- req->context = sctx;
- req->callback = &search_callback;
- ldb_set_timeout(ldb, req, 0); /* TODO: make this settable by command line */
-
again:
+ /* free any previous requests */
+ if (req) talloc_free(req);
+
+ ret = ldb_build_search_req(&req, ldb, ldb,
+ basedn, options->scope,
+ expression, attrs,
+ sctx->req_ctrls,
+ sctx, search_callback,
+ NULL);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(sctx);
+ printf("allocating request failed: %s\n", ldb_errstring(ldb));
+ return -1;
+ }
+
sctx->pending = 0;
ret = ldb_request(ldb, req);
@@ -251,7 +258,7 @@ again:
ldb, (ldb_qsort_cmp_fn_t)do_compare_msg);
}
for (i = 0; i < sctx->num_stored; i++) {
- display_message(ldb, sctx->store[i], sctx);
+ display_message(sctx->store[i], sctx);
}
for (i = 0; i < sctx->refs_stored; i++) {
@@ -262,6 +269,7 @@ again:
printf("# returned %d records\n# %d entries\n# %d referrals\n",
sctx->entries + sctx->refs, sctx->entries, sctx->refs);
+ talloc_free(sctx);
talloc_free(req);
return 0;
diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c
index 169ff02da1..f3d6d621a9 100644
--- a/source4/lib/ldb/tools/ldbtest.c
+++ b/source4/lib/ldb/tools/ldbtest.c
@@ -227,7 +227,7 @@ static void search_uid(struct ldb_context *ldb, struct ldb_dn *basedn, int nreco
int ret;
expr = talloc_asprintf(ldb, "(uid=TEST%d)", uid);
- ret = ldb_search(ldb, basedn, LDB_SCOPE_SUBTREE, expr, NULL, &res);
+ ret = ldb_search(ldb, ldb, &res, basedn, LDB_SCOPE_SUBTREE, NULL, "%s", expr);
if (ret != LDB_SUCCESS || (uid < nrecords && res->count != 1)) {
printf("Failed to find %s - %s\n", expr, ldb_errstring(ldb));
@@ -354,7 +354,7 @@ static void start_test_index(struct ldb_context **ldb)
basedn = ldb_dn_new(*ldb, *ldb, options->basedn);
- ret = ldb_search(*ldb, basedn, LDB_SCOPE_SUBTREE, "uid=test", NULL, &res);
+ ret = ldb_search(*ldb, *ldb, &res, basedn, LDB_SCOPE_SUBTREE, NULL, "uid=test");
if (ret != LDB_SUCCESS) {
printf("Search with (uid=test) filter failed!\n");
exit(1);
diff --git a/source4/lib/ldb_wrap.c b/source4/lib/ldb_wrap.c
index 6c683a1e33..617371333f 100644
--- a/source4/lib/ldb_wrap.c
+++ b/source4/lib/ldb_wrap.c
@@ -71,6 +71,7 @@ static void ldb_wrap_debug(void *context, enum ldb_debug_level level,
static int ldb_wrap_destructor(struct ldb_context *ldb)
{
size_t *startup_blocks = (size_t *)ldb_get_opaque(ldb, "startup_blocks");
+
if (startup_blocks &&
talloc_total_blocks(ldb) > *startup_blocks + 400) {
DEBUG(0,("WARNING: probable memory leak in ldb %s - %lu blocks (startup %lu) %lu bytes\n",
@@ -124,15 +125,6 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
"%s/ldb",
lp_modulesdir(lp_ctx)));
-#if 0
- if (ev) {
- ldb_event_sys_op_init(ldb, ev);
- } else {
- talloc_free(ldb);
- return NULL;
- }
-#endif
-
if (ldb_set_opaque(ldb, "sessionInfo", session_info)) {
talloc_free(ldb);
return NULL;
@@ -198,6 +190,3 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
return ldb;
}
-
-
-
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index 4b90e8c4fd..dcc29180cc 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -23,16 +23,15 @@
#include "lib/events/events.h"
#include "system/filesys.h"
#include "messaging/messaging.h"
-#include "lib/util/dlinklist.h"
+#include "../lib/util/dlinklist.h"
#include "lib/socket/socket.h"
#include "librpc/gen_ndr/ndr_irpc.h"
#include "lib/messaging/irpc.h"
#include "tdb_wrap.h"
-#include "lib/util/unix_privs.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 "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/registry/dir.c b/source4/lib/registry/dir.c
index 449ee0f6ee..42946bceec 100644
--- a/source4/lib/registry/dir.c
+++ b/source4/lib/registry/dir.c
@@ -327,7 +327,7 @@ static WERROR reg_dir_get_value(TALLOC_CTX *mem_ctx,
size_t size;
char *contents;
- contents = file_load(path, &size, mem_ctx);
+ contents = file_load(path, &size, 0, mem_ctx);
talloc_free(path);
if (contents == NULL)
return WERR_BADFILE;
diff --git a/source4/lib/registry/interface.c b/source4/lib/registry/interface.c
index c9b3b06447..81ca2c39bc 100644
--- a/source4/lib/registry/interface.c
+++ b/source4/lib/registry/interface.c
@@ -18,7 +18,7 @@
*/
#include "includes.h"
-#include "lib/util/dlinklist.h"
+#include "../lib/util/dlinklist.h"
#include "lib/registry/registry.h"
#include "system/filesys.h"
diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c
index 87d066e2de..9c1f59c4df 100644
--- a/source4/lib/registry/ldb.c
+++ b/source4/lib/registry/ldb.c
@@ -225,7 +225,7 @@ static WERROR cache_subkeys(struct ldb_key_data *kd)
struct ldb_result *res;
int ret;
- ret = ldb_search(c, kd->dn, LDB_SCOPE_ONELEVEL, "(key=*)", NULL, &res);
+ ret = ldb_search(c, c, &res, kd->dn, LDB_SCOPE_ONELEVEL, NULL, "(key=*)");
if (ret != LDB_SUCCESS) {
DEBUG(0, ("Error getting subkeys for '%s': %s\n",
@@ -246,8 +246,8 @@ static WERROR cache_values(struct ldb_key_data *kd)
struct ldb_result *res;
int ret;
- ret = ldb_search(c, kd->dn, LDB_SCOPE_ONELEVEL,
- "(value=*)", NULL, &res);
+ ret = ldb_search(c, c, &res, kd->dn, LDB_SCOPE_ONELEVEL,
+ NULL, "(value=*)");
if (ret != LDB_SUCCESS) {
DEBUG(0, ("Error getting values for '%s': %s\n",
@@ -373,7 +373,7 @@ static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k,
} else {
/* normal value */
query = talloc_asprintf(mem_ctx, "(value=%s)", name);
- ret = ldb_search(c, kd->dn, LDB_SCOPE_ONELEVEL, query, NULL, &res);
+ ret = ldb_search(c, kd->dn, &res, LDB_SCOPE_ONELEVEL, query, NULL, "%s", query);
talloc_free(query);
if (ret != LDB_SUCCESS) {
@@ -391,6 +391,7 @@ static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k,
talloc_free(res);
}
+ talloc_free(res);
return WERR_OK;
}
@@ -406,7 +407,7 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
ldap_path = reg_path_to_ldb(mem_ctx, h, name, NULL);
- ret = ldb_search(c, ldap_path, LDB_SCOPE_BASE, "(key=*)", NULL, &res);
+ ret = ldb_search(c, mem_ctx, &res, ldap_path, LDB_SCOPE_BASE, NULL, "(key=*)");
if (ret != LDB_SUCCESS) {
DEBUG(3, ("Error opening key '%s': %s\n",
@@ -598,8 +599,8 @@ static WERROR ldb_del_key(const struct hive_key *key, const char *name)
}
/* Search for subkeys */
- ret = ldb_search(c, ldap_path, LDB_SCOPE_ONELEVEL,
- "(key=*)", NULL, &res_keys);
+ ret = ldb_search(c, mem_ctx, &res_keys, ldap_path, LDB_SCOPE_ONELEVEL,
+ NULL, "(key=*)");
if (ret != LDB_SUCCESS) {
DEBUG(0, ("Error getting subkeys for '%s': %s\n",
@@ -609,8 +610,8 @@ static WERROR ldb_del_key(const struct hive_key *key, const char *name)
}
/* Search for values */
- ret = ldb_search(c, ldap_path, LDB_SCOPE_ONELEVEL,
- "(value=*)", NULL, &res_vals);
+ ret = ldb_search(c, mem_ctx, &res_vals, ldap_path, LDB_SCOPE_ONELEVEL,
+ NULL, "(value=*)");
if (ret != LDB_SUCCESS) {
DEBUG(0, ("Error getting values for '%s': %s\n",
diff --git a/source4/lib/registry/local.c b/source4/lib/registry/local.c
index 4af95e2dd6..a3aee06b13 100644
--- a/source4/lib/registry/local.c
+++ b/source4/lib/registry/local.c
@@ -19,7 +19,7 @@
*/
#include "includes.h"
-#include "lib/util/dlinklist.h"
+#include "../lib/util/dlinklist.h"
#include "lib/registry/registry.h"
#include "system/filesys.h"
diff --git a/source4/lib/registry/patchfile.c b/source4/lib/registry/patchfile.c
index 0ede3106f0..a6f947ee78 100644
--- a/source4/lib/registry/patchfile.c
+++ b/source4/lib/registry/patchfile.c
@@ -4,6 +4,7 @@
Copyright (C) Jelmer Vernooij 2004-2007
Copyright (C) Wilco Baan Hofman 2006
+ Copyright (C) Matthias Dieter Wallnöfer 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
@@ -58,8 +59,9 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
&old_num_subkeys, &old_num_values,
NULL, NULL, NULL, NULL);
if (!W_ERROR_IS_OK(error)) {
- DEBUG(0, ("Error occured while getting key info: %s\n",
+ DEBUG(0, ("Error occurred while getting key info: %s\n",
win_errstr(error)));
+ talloc_free(mem_ctx);
return error;
}
} else {
@@ -67,37 +69,46 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
old_num_values = 0;
}
- /* Subkeys that were deleted */
+ /* Subkeys that were changed or deleted */
for (i = 0; i < old_num_subkeys; i++) {
error1 = reg_key_get_subkey_by_index(mem_ctx, oldkey, i,
- &keyname1,
- NULL, NULL);
+ &keyname1, NULL, NULL);
if (!W_ERROR_IS_OK(error1)) {
- DEBUG(0, ("Error occured while getting subkey by index: %s\n",
- win_errstr(error2)));
+ DEBUG(0, ("Error occurred while getting subkey by index: %s\n",
+ win_errstr(error1)));
continue;
}
if (newkey != NULL) {
error2 = reg_open_key(mem_ctx, newkey, keyname1, &t2);
-
- if (W_ERROR_IS_OK(error2))
- continue;
} else {
error2 = WERR_BADFILE;
t2 = NULL;
}
- if (!W_ERROR_EQUAL(error2, WERR_BADFILE)) {
+ if (!W_ERROR_IS_OK(error2) && !W_ERROR_EQUAL(error2, WERR_BADFILE)) {
DEBUG(0, ("Error occured while getting subkey by name: %s\n",
win_errstr(error2)));
talloc_free(mem_ctx);
return error2;
}
- /* newkey didn't have such a subkey, add del diff */
+ /* if "error2" is going to be "WERR_BADFILE", then newkey */
+ /* didn't have such a subkey and therefore add a del diff */
tmppath = talloc_asprintf(mem_ctx, "%s\\%s", path, keyname1);
- callbacks->del_key(callback_data, tmppath);
+ if (!W_ERROR_IS_OK(error2))
+ callbacks->del_key(callback_data, tmppath);
+
+ /* perform here also the recursive invocation */
+ error1 = reg_open_key(mem_ctx, oldkey, keyname1, &t1);
+ if (!W_ERROR_IS_OK(error1)) {
+ DEBUG(0, ("Error occured while getting subkey by name: %s\n",
+ win_errstr(error1)));
+ talloc_free(mem_ctx);
+ return error1;
+ }
+ reg_generate_diff_key(t1, t2, tmppath, callbacks, callback_data);
+
talloc_free(tmppath);
}
@@ -106,8 +117,9 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
&new_num_subkeys, &new_num_values,
NULL, NULL, NULL, NULL);
if (!W_ERROR_IS_OK(error)) {
- DEBUG(0, ("Error occured while getting key info: %s\n",
+ DEBUG(0, ("Error occurred while getting key info: %s\n",
win_errstr(error)));
+ talloc_free(mem_ctx);
return error;
}
} else {
@@ -117,11 +129,10 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
/* Subkeys that were added */
for(i = 0; i < new_num_subkeys; i++) {
- error1 = reg_key_get_subkey_by_index(mem_ctx, newkey,
- i, &keyname1,
- NULL, NULL);
+ error1 = reg_key_get_subkey_by_index(mem_ctx, newkey, i,
+ &keyname1, NULL, NULL);
if (!W_ERROR_IS_OK(error1)) {
- DEBUG(0, ("Error occured while getting subkey by index: %s\n",
+ DEBUG(0, ("Error occurred while getting subkey by index: %s\n",
win_errstr(error1)));
talloc_free(mem_ctx);
return error1;
@@ -133,12 +144,12 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
if (W_ERROR_IS_OK(error2))
continue;
} else {
+ error2 = WERR_BADFILE;
t1 = NULL;
- error2 = WERR_BADFILE;
}
if (!W_ERROR_EQUAL(error2, WERR_BADFILE)) {
- DEBUG(0, ("Error occured while getting subkey by name: %s\n",
+ DEBUG(0, ("Error occurred while getting subkey by name: %s\n",
win_errstr(error2)));
talloc_free(mem_ctx);
return error2;
@@ -148,15 +159,20 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
tmppath = talloc_asprintf(mem_ctx, "%s\\%s", path, keyname1);
callbacks->add_key(callback_data, tmppath);
- W_ERROR_NOT_OK_RETURN(
- reg_open_key(mem_ctx, newkey, keyname1, &t2));
+ /* perform here also the recursive invocation */
+ error1 = reg_open_key(mem_ctx, newkey, keyname1, &t2);
+ if (!W_ERROR_IS_OK(error1)) {
+ DEBUG(0, ("Error occured while getting subkey by name: %s\n",
+ win_errstr(error1)));
+ talloc_free(mem_ctx);
+ return error1;
+ }
+ reg_generate_diff_key(t1, t2, tmppath, callbacks, callback_data);
- reg_generate_diff_key(t1, t2, tmppath,
- callbacks, callback_data);
talloc_free(tmppath);
}
- /* Values that were changed */
+ /* Values that were added or changed */
for(i = 0; i < new_num_values; i++) {
const char *name;
uint32_t type1, type2;
@@ -165,7 +181,7 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
error1 = reg_key_get_value_by_index(mem_ctx, newkey, i,
&name, &type1, &contents1);
if (!W_ERROR_IS_OK(error1)) {
- DEBUG(0, ("Unable to get key by index: %s\n",
+ DEBUG(0, ("Unable to get value by index: %s\n",
win_errstr(error1)));
talloc_free(mem_ctx);
return error1;
@@ -178,16 +194,17 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
} else
error2 = WERR_BADFILE;
- if(!W_ERROR_IS_OK(error2) &&
- !W_ERROR_EQUAL(error2, WERR_BADFILE)) {
- DEBUG(0, ("Error occured while getting value by name: %s\n",
+ if (!W_ERROR_IS_OK(error2)
+ && !W_ERROR_EQUAL(error2, WERR_BADFILE)) {
+ DEBUG(0, ("Error occurred while getting value by name: %s\n",
win_errstr(error2)));
talloc_free(mem_ctx);
return error2;
}
- if (W_ERROR_IS_OK(error2) &&
- data_blob_cmp(&contents1, &contents2) == 0)
+ if (W_ERROR_IS_OK(error2)
+ && (data_blob_cmp(&contents1, &contents2) == 0)
+ && (type1 == type2))
continue;
callbacks->set_value(callback_data, path, name,
@@ -197,24 +214,31 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
/* Values that were deleted */
for (i = 0; i < old_num_values; i++) {
const char *name;
+ uint32_t type;
+ DATA_BLOB contents;
+
error1 = reg_key_get_value_by_index(mem_ctx, oldkey, i, &name,
- NULL, NULL);
+ &type, &contents);
if (!W_ERROR_IS_OK(error1)) {
- DEBUG(0, ("Error ocurred getting value by index: %s\n",
+ DEBUG(0, ("Unable to get value by index: %s\n",
win_errstr(error1)));
talloc_free(mem_ctx);
return error1;
}
- error2 = reg_key_get_value_by_name(mem_ctx, newkey, name, NULL,
- NULL);
+ if (newkey != NULL)
+ error2 = reg_key_get_value_by_name(mem_ctx, newkey,
+ name, &type, &contents);
+ else
+ error2 = WERR_BADFILE;
if (W_ERROR_IS_OK(error2))
continue;
if (!W_ERROR_EQUAL(error2, WERR_BADFILE)) {
- DEBUG(0, ("Error occured while getting value by name: %s\n",
+ DEBUG(0, ("Error occurred while getting value by name: %s\n",
win_errstr(error2)));
+ talloc_free(mem_ctx);
return error2;
}
@@ -236,27 +260,30 @@ _PUBLIC_ WERROR reg_generate_diff(struct registry_context *ctx1,
int i;
WERROR error;
- for(i = HKEY_FIRST; i <= HKEY_LAST; i++) {
+ for (i = 0; reg_predefined_keys[i].name; i++) {
struct registry_key *r1 = NULL, *r2 = NULL;
- error = reg_get_predefined_key(ctx1, i, &r1);
+
+ error = reg_get_predefined_key(ctx1,
+ reg_predefined_keys[i].handle, &r1);
if (!W_ERROR_IS_OK(error) &&
!W_ERROR_EQUAL(error, WERR_BADFILE)) {
DEBUG(0, ("Unable to open hive %s for backend 1\n",
- reg_get_predef_name(i)));
+ reg_predefined_keys[i].name));
+ continue;
}
- error = reg_get_predefined_key(ctx2, i, &r2);
+ error = reg_get_predefined_key(ctx2,
+ reg_predefined_keys[i].handle, &r2);
if (!W_ERROR_IS_OK(error) &&
!W_ERROR_EQUAL(error, WERR_BADFILE)) {
DEBUG(0, ("Unable to open hive %s for backend 2\n",
- reg_get_predef_name(i)));
- }
-
- if (r1 == NULL && r2 == NULL)
+ reg_predefined_keys[i].name));
continue;
+ }
- error = reg_generate_diff_key(r1, r2, reg_get_predef_name(i),
- callbacks, callback_data);
+ error = reg_generate_diff_key(r1, r2,
+ reg_predefined_keys[i].name, callbacks,
+ callback_data);
if (!W_ERROR_IS_OK(error)) {
DEBUG(0, ("Unable to determine diff: %s\n",
win_errstr(error)));
@@ -357,14 +384,13 @@ static WERROR reg_diff_apply_add_key(void *_ctx, const char *key_name)
static WERROR reg_diff_apply_del_key(void *_ctx, const char *key_name)
{
struct registry_context *ctx = (struct registry_context *)_ctx;
- WERROR error;
- error = reg_key_del_abs(ctx, key_name);
+ /* We can't proof here for success, because a common superkey could */
+ /* have been deleted before the subkey's (diff order). This removed */
+ /* therefore all childs recursively and the "WERR_BADFILE" result is */
+ /* expected. */
- if(!W_ERROR_IS_OK(error)) {
- DEBUG(0, ("Unable to delete key '%s'\n", key_name));
- return error;
- }
+ reg_key_del_abs(ctx, key_name);
return WERR_OK;
}
@@ -426,8 +452,7 @@ static WERROR reg_diff_apply_del_all_values(void *_ctx, const char *key_name)
struct registry_context *ctx = (struct registry_context *)_ctx;
struct registry_key *key;
WERROR error;
- int i;
- uint32_t num_values;
+ const char* value_name;
error = reg_open_key_abs(ctx, ctx, key_name, &key);
@@ -437,14 +462,15 @@ static WERROR reg_diff_apply_del_all_values(void *_ctx, const char *key_name)
}
W_ERROR_NOT_OK_RETURN(reg_key_get_info(ctx, key, NULL,
- NULL, &num_values, NULL, NULL, NULL, NULL));
+ NULL, NULL, NULL, NULL, NULL, NULL));
- for (i = 0; i < num_values; i++) {
- const char *name;
- W_ERROR_NOT_OK_RETURN(reg_key_get_value_by_index(ctx, key, i,
- &name,
- NULL, NULL));
- W_ERROR_NOT_OK_RETURN(reg_del_value(key, name));
+ while (W_ERROR_IS_OK(reg_key_get_value_by_index(
+ ctx, key, 0, &value_name, NULL, NULL))) {
+ error = reg_del_value(key, value_name);
+ if (!W_ERROR_IS_OK(error)) {
+ DEBUG(0, ("Error deleting value '%s'\n", value_name));
+ return error;
+ }
}
return WERR_OK;
diff --git a/source4/lib/registry/regf.c b/source4/lib/registry/regf.c
index 57a895aa00..dd3ff47b78 100644
--- a/source4/lib/registry/regf.c
+++ b/source4/lib/registry/regf.c
@@ -2066,7 +2066,7 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx, const char *location,
pull = tdr_pull_init(regf, regf->iconv_convenience);
- pull->data.data = (uint8_t*)fd_load(regf->fd, &pull->data.length, regf);
+ pull->data.data = (uint8_t*)fd_load(regf->fd, &pull->data.length, 0, regf);
if (pull->data.data == NULL) {
DEBUG(0, ("Error reading data\n"));
diff --git a/source4/lib/registry/registry.h b/source4/lib/registry/registry.h
index e134e3e532..e89d6fd55c 100644
--- a/source4/lib/registry/registry.h
+++ b/source4/lib/registry/registry.h
@@ -29,8 +29,8 @@ struct smb_iconv_convenience;
#include "libcli/util/werror.h"
#include "librpc/gen_ndr/security.h"
#include "libcli/util/ntstatus.h"
-#include "util/time.h"
-#include "util/data_blob.h"
+#include "../lib/util/time.h"
+#include "../lib/util/data_blob.h"
/**
* The hive API. This API is generally used for
@@ -508,6 +508,18 @@ WERROR reg_diff_load(const char *filename,
const struct reg_diff_callbacks *callbacks,
void *callback_data);
+WERROR reg_dotreg_diff_load(int fd,
+ struct smb_iconv_convenience *iconv_convenience,
+ const struct reg_diff_callbacks *callbacks,
+ void *callback_data);
+
+WERROR reg_preg_diff_load(int fd,
+ struct smb_iconv_convenience *iconv_convenience,
+ const struct reg_diff_callbacks *callbacks,
+ void *callback_data);
+
+WERROR local_get_predefined_key(struct registry_context *ctx,
+ uint32_t key_id, struct registry_key **key);
#endif /* _REGISTRY_H */
diff --git a/source4/lib/registry/registry.i b/source4/lib/registry/registry.i
index c55197c3d0..fe3a81d889 100644
--- a/source4/lib/registry/registry.i
+++ b/source4/lib/registry/registry.i
@@ -43,7 +43,7 @@ typedef struct hive_key hive_key;
}
%import "stdint.i"
-%import "../../lib/talloc/talloc.i"
+%import "../../../lib/talloc/talloc.i"
%import "../../auth/credentials/credentials.i"
%import "../../param/param.i"
%import "../events/events.i"
diff --git a/source4/lib/registry/rpc.c b/source4/lib/registry/rpc.c
index 18b7607713..3a16ae1db5 100644
--- a/source4/lib/registry/rpc.c
+++ b/source4/lib/registry/rpc.c
@@ -2,6 +2,7 @@
Samba Unix/Linux SMB implementation
RPC backend for the registry library
Copyright (C) 2003-2007 Jelmer Vernooij, jelmer@samba.org
+ Copyright (C) 2008 Matthias Dieter Wallnöfer, mwallnoefer@yahoo.de
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
@@ -20,16 +21,23 @@
#include "registry.h"
#include "librpc/gen_ndr/ndr_winreg_c.h"
+#define MAX_NAMESIZE 512
+#define MAX_VALSIZE 32768
+
struct rpc_key {
struct registry_key key;
struct policy_handle pol;
struct dcerpc_pipe *pipe;
- uint32_t num_values;
+ const char* classname;
uint32_t num_subkeys;
+ uint32_t max_subkeylen;
+ uint32_t max_classlen;
+ uint32_t num_values;
uint32_t max_valnamelen;
- uint32_t max_valdatalen;
- uint32_t max_subkeynamelen;
+ uint32_t max_valbufsize;
+ uint32_t secdescsize;
+ NTTIME last_changed_time;
};
struct rpc_registry_context {
@@ -43,26 +51,22 @@ static struct registry_operations reg_backend_rpc;
* This is the RPC backend for the registry library.
*/
-static void init_winreg_String(struct winreg_String *name, const char *s)
-{
- name->name = s;
-}
-
-
#define openhive(u) static WERROR open_ ## u(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *hnd) \
{ \
struct winreg_Open ## u r; \
NTSTATUS status; \
- \
+\
+ ZERO_STRUCT(r); \
r.in.system_name = NULL; \
r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; \
r.out.handle = hnd;\
- \
+\
status = dcerpc_winreg_Open ## u(p, mem_ctx, &r); \
- if (NT_STATUS_IS_ERR(status)) {\
- DEBUG(0,("Error executing open\n"));\
- return ntstatus_to_werror(status);\
- }\
+\
+ if (!NT_STATUS_IS_OK(status)) { \
+ DEBUG(1, ("OpenHive failed - %s\n", nt_errstr(status))); \
+ return ntstatus_to_werror(status); \
+ } \
\
return r.out.result;\
}
@@ -90,7 +94,7 @@ static struct {
{ 0, NULL }
};
-static WERROR rpc_query_key(const struct registry_key *k);
+static WERROR rpc_query_key(TALLOC_CTX *mem_ctx, const struct registry_key *k);
static WERROR rpc_get_predefined_key(struct registry_context *ctx,
uint32_t hkey_type,
@@ -127,15 +131,15 @@ static WERROR rpc_key_put_rpc_data(TALLOC_CTX *mem_ctx, struct registry_key *k)
struct winreg_OpenKey r;
struct rpc_key_data *mykeydata;
- k->backend_data = mykeydata = talloc(mem_ctx, struct rpc_key_data);
+ k->backend_data = mykeydata = talloc_zero(mem_ctx, struct rpc_key_data);
mykeydata->num_values = -1;
mykeydata->num_subkeys = -1;
/* Then, open the handle using the hive */
- memset(&r, 0, sizeof(struct winreg_OpenKey));
+ ZERO_STRUCT(r);
r.in.handle = &(((struct rpc_key_data *)k->hive->root->backend_data)->pol);
- init_winreg_String(&r.in.keyname, k->path);
+ r.in.keyname.name = k->path;
r.in.unknown = 0x00000000;
r.in.access_mask = 0x02000000;
r.out.handle = &mykeydata->pol;
@@ -155,8 +159,7 @@ static WERROR rpc_open_key(TALLOC_CTX *mem_ctx, struct registry_key *h,
struct winreg_OpenKey r;
NTSTATUS status;
- mykeydata = talloc(mem_ctx, struct rpc_key);
-
+ mykeydata = talloc_zero(mem_ctx, struct rpc_key);
mykeydata->key.context = parentkeydata->key.context;
mykeydata->pipe = talloc_reference(mykeydata, parentkeydata->pipe);
mykeydata->num_values = -1;
@@ -166,14 +169,15 @@ static WERROR rpc_open_key(TALLOC_CTX *mem_ctx, struct registry_key *h,
/* Then, open the handle using the hive */
ZERO_STRUCT(r);
r.in.parent_handle = &parentkeydata->pol;
- init_winreg_String(&r.in.keyname, name);
+ r.in.keyname.name = name;
r.in.unknown = 0x00000000;
r.in.access_mask = 0x02000000;
r.out.handle = &mykeydata->pol;
status = dcerpc_winreg_OpenKey(mykeydata->pipe, mem_ctx, &r);
- if (NT_STATUS_IS_ERR(status)) {
- DEBUG(0,("Error executing openkey: %s\n", nt_errstr(status)));
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("OpenKey failed - %s\n", nt_errstr(status)));
return ntstatus_to_werror(status);
}
@@ -188,47 +192,94 @@ static WERROR rpc_get_value_by_index(TALLOC_CTX *mem_ctx,
DATA_BLOB *data)
{
struct rpc_key *mykeydata = talloc_get_type(parent, struct rpc_key);
- WERROR error;
struct winreg_EnumValue r;
- uint32_t in_type = 0;
- NTSTATUS status;
struct winreg_StringBuf name;
+ uint8_t value;
+ uint32_t val_size = MAX_VALSIZE;
uint32_t zero = 0;
-
- ZERO_STRUCT(r);
+ WERROR error;
+ NTSTATUS status;
if (mykeydata->num_values == -1) {
- error = rpc_query_key(parent);
+ error = rpc_query_key(mem_ctx, parent);
if(!W_ERROR_IS_OK(error)) return error;
}
- name.length = 0;
- name.size = mykeydata->max_valnamelen * 2;
- name.name = NULL;
+ name.name = "";
+ name.size = MAX_NAMESIZE;
+ ZERO_STRUCT(r);
r.in.handle = &mykeydata->pol;
r.in.enum_index = n;
r.in.name = &name;
- r.in.type = &in_type;
- r.in.value = talloc_zero_array(mem_ctx, uint8_t, 0);
+ r.in.type = type;
+ r.in.value = &value;
+ r.in.size = &val_size;
r.in.length = &zero;
- r.in.size = &mykeydata->max_valdatalen;
r.out.name = &name;
r.out.type = type;
+ r.out.value = &value;
+ r.out.size = &val_size;
+ r.out.length = &zero;
status = dcerpc_winreg_EnumValue(mykeydata->pipe, mem_ctx, &r);
- if(NT_STATUS_IS_ERR(status)) {
- DEBUG(0, ("Error in EnumValue: %s\n", nt_errstr(status)));
- return WERR_GENERAL_FAILURE;
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("EnumValue failed - %s\n", nt_errstr(status)));
+ return ntstatus_to_werror(status);
}
- if(NT_STATUS_IS_OK(status) &&
- W_ERROR_IS_OK(r.out.result) && r.out.length) {
- *value_name = talloc_strdup(mem_ctx, r.out.name->name);
- *data = data_blob_talloc(mem_ctx, r.out.value, *r.out.length);
- return WERR_OK;
+ *value_name = talloc_reference(mem_ctx, r.out.name->name);
+ *type = *(r.out.type);
+ *data = data_blob_talloc(mem_ctx, r.out.value, *r.out.length);
+
+ return r.out.result;
+}
+
+static WERROR rpc_get_value_by_name(TALLOC_CTX *mem_ctx,
+ const struct registry_key *parent,
+ const char *value_name,
+ uint32_t *type,
+ DATA_BLOB *data)
+{
+ struct rpc_key *mykeydata = talloc_get_type(parent, struct rpc_key);
+ struct winreg_QueryValue r;
+ struct winreg_String name;
+ uint8_t value;
+ uint32_t val_size = MAX_VALSIZE;
+ uint32_t zero = 0;
+ WERROR error;
+ NTSTATUS status;
+
+ if (mykeydata->num_values == -1) {
+ error = rpc_query_key(mem_ctx, parent);
+ if(!W_ERROR_IS_OK(error)) return error;
}
+ name.name = value_name;
+
+ ZERO_STRUCT(r);
+ r.in.handle = &mykeydata->pol;
+ r.in.value_name = &name;
+ r.in.type = type;
+ r.in.data = &value;
+ r.in.data_size = &val_size;
+ r.in.data_length = &zero;
+ r.out.type = type;
+ r.out.data = &value;
+ r.out.data_size = &val_size;
+ r.out.data_length = &zero;
+
+ status = dcerpc_winreg_QueryValue(mykeydata->pipe, mem_ctx, &r);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("QueryValue failed - %s\n", nt_errstr(status)));
+ return ntstatus_to_werror(status);
+ }
+
+ *type = *(r.out.type);
+ *data = data_blob_talloc(mem_ctx, r.out.data, *r.out.data_length);
+
return r.out.result;
}
@@ -241,34 +292,39 @@ static WERROR rpc_get_subkey_by_index(TALLOC_CTX *mem_ctx,
{
struct winreg_EnumKey r;
struct rpc_key *mykeydata = talloc_get_type(parent, struct rpc_key);
- NTSTATUS status;
struct winreg_StringBuf namebuf, classbuf;
NTTIME change_time = 0;
+ NTSTATUS status;
- ZERO_STRUCT(r);
-
- namebuf.length = 0;
- namebuf.size = 1024;
- namebuf.name = NULL;
- classbuf.length = 0;
- classbuf.size = 0;
- classbuf.name = NULL;
+ namebuf.name = "";
+ namebuf.size = MAX_NAMESIZE;
+ classbuf.name = NULL;
+ classbuf.size = 0;
+ ZERO_STRUCT(r);
r.in.handle = &mykeydata->pol;
r.in.enum_index = n;
r.in.name = &namebuf;
r.in.keyclass = &classbuf;
r.in.last_changed_time = &change_time;
-
r.out.name = &namebuf;
+ r.out.keyclass = &classbuf;
+ r.out.last_changed_time = &change_time;
status = dcerpc_winreg_EnumKey(mykeydata->pipe, mem_ctx, &r);
- if (NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(r.out.result)) {
- *name = talloc_strdup(mem_ctx, r.out.name->name);
- if (keyclass != NULL)
- *keyclass = talloc_strdup(mem_ctx, r.out.keyclass->name);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("EnumKey failed - %s\n", nt_errstr(status)));
+ return ntstatus_to_werror(status);
}
+ if (name != NULL)
+ *name = talloc_reference(mem_ctx, r.out.name->name);
+ if (keyclass != NULL)
+ *keyclass = talloc_reference(mem_ctx, r.out.keyclass->name);
+ if (last_changed_time != NULL)
+ *last_changed_time = *(r.out.last_changed_time);
+
return r.out.result;
}
@@ -278,19 +334,22 @@ static WERROR rpc_add_key(TALLOC_CTX *mem_ctx,
struct security_descriptor *sec,
struct registry_key **key)
{
- NTSTATUS status;
struct winreg_CreateKey r;
struct rpc_key *parentkd = talloc_get_type(parent, struct rpc_key);
struct rpc_key *rpck = talloc(mem_ctx, struct rpc_key);
+
+ NTSTATUS status;
- init_winreg_String(&r.in.name, name);
- init_winreg_String(&r.in.keyclass, NULL);
-
+ ZERO_STRUCT(r);
r.in.handle = &parentkd->pol;
- r.out.new_handle = &rpck->pol;
+ r.in.name.name = name;
+ r.in.keyclass.name = NULL;
r.in.options = 0;
- r.in.access_mask = SEC_STD_ALL;
+ r.in.access_mask = 0x02000000;
r.in.secdesc = NULL;
+ r.in.action_taken = NULL;
+ r.out.new_handle = &rpck->pol;
+ r.out.action_taken = NULL;
status = dcerpc_winreg_CreateKey(parentkd->pipe, mem_ctx, &r);
@@ -300,49 +359,42 @@ static WERROR rpc_add_key(TALLOC_CTX *mem_ctx,
return ntstatus_to_werror(status);
}
- if (W_ERROR_IS_OK(r.out.result)) {
- rpck->pipe = talloc_reference(rpck, parentkd->pipe);
- *key = (struct registry_key *)rpck;
- }
+ rpck->pipe = talloc_reference(rpck, parentkd->pipe);
+ *key = (struct registry_key *)rpck;
return r.out.result;
}
-static WERROR rpc_query_key(const struct registry_key *k)
+static WERROR rpc_query_key(TALLOC_CTX *mem_ctx, const struct registry_key *k)
{
- NTSTATUS status;
struct winreg_QueryInfoKey r;
struct rpc_key *mykeydata = talloc_get_type(k, struct rpc_key);
- TALLOC_CTX *mem_ctx = talloc_init("query_key");
- uint32_t max_subkeysize;
- uint32_t secdescsize;
- NTTIME last_changed_time;
+ struct winreg_String classname;
+ NTSTATUS status;
- ZERO_STRUCT(r.out);
+ classname.name = NULL;
+ ZERO_STRUCT(r);
+ r.in.handle = &mykeydata->pol;
+ r.in.classname = &classname;
+ r.out.classname = &classname;
r.out.num_subkeys = &mykeydata->num_subkeys;
- r.out.max_subkeylen = &mykeydata->max_subkeynamelen;
- r.out.max_valnamelen = &mykeydata->max_valnamelen;
- r.out.max_valbufsize = &mykeydata->max_valdatalen;
- r.out.max_subkeysize = &max_subkeysize;
+ r.out.max_subkeylen = &mykeydata->max_subkeylen;
+ r.out.max_classlen = &mykeydata->max_classlen;
r.out.num_values = &mykeydata->num_values;
- r.out.secdescsize = &secdescsize;
- r.out.last_changed_time = &last_changed_time;
-
- r.out.classname = r.in.classname = talloc_zero(mem_ctx, struct winreg_String);
- init_winreg_String(r.in.classname, NULL);
- r.in.handle = &mykeydata->pol;
+ r.out.max_valnamelen = &mykeydata->max_valnamelen;
+ r.out.max_valbufsize = &mykeydata->max_valbufsize;
+ r.out.secdescsize = &mykeydata->secdescsize;
+ r.out.last_changed_time = &mykeydata->last_changed_time;
status = dcerpc_winreg_QueryInfoKey(mykeydata->pipe, mem_ctx, &r);
- talloc_free(mem_ctx);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("QueryInfoKey failed - %s\n", nt_errstr(status)));
return ntstatus_to_werror(status);
}
- if (W_ERROR_IS_OK(r.out.result)) {
- }
+ mykeydata->classname = talloc_reference(mem_ctx, r.out.classname->name);
return r.out.result;
}
@@ -354,22 +406,28 @@ static WERROR rpc_del_key(struct registry_key *parent, const char *name)
struct winreg_DeleteKey r;
TALLOC_CTX *mem_ctx = talloc_init("del_key");
+ ZERO_STRUCT(r);
r.in.handle = &mykeydata->pol;
- init_winreg_String(&r.in.key, name);
+ r.in.key.name = name;
status = dcerpc_winreg_DeleteKey(mykeydata->pipe, mem_ctx, &r);
talloc_free(mem_ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("DeleteKey failed - %s\n", nt_errstr(status)));
+ return ntstatus_to_werror(status);
+ }
+
return r.out.result;
}
static WERROR rpc_get_info(TALLOC_CTX *mem_ctx, const struct registry_key *key,
const char **classname,
- uint32_t *numsubkeys,
- uint32_t *numvalue,
+ uint32_t *num_subkeys,
+ uint32_t *num_values,
NTTIME *last_changed_time,
- uint32_t *max_subkeynamelen,
+ uint32_t *max_subkeylen,
uint32_t *max_valnamelen,
uint32_t *max_valbufsize)
{
@@ -377,27 +435,30 @@ static WERROR rpc_get_info(TALLOC_CTX *mem_ctx, const struct registry_key *key,
WERROR error;
if (mykeydata->num_values == -1) {
- error = rpc_query_key(key);
+ error = rpc_query_key(mem_ctx, key);
if(!W_ERROR_IS_OK(error)) return error;
}
- /* FIXME: *classname = talloc_strdup(mem_ctx, mykeydata->classname); */
- /* FIXME: *last_changed_time = mykeydata->last_changed_time */
+ if (classname != NULL)
+ *classname = mykeydata->classname;
+
+ if (num_subkeys != NULL)
+ *num_subkeys = mykeydata->num_subkeys;
- if (numvalue != NULL)
- *numvalue = mykeydata->num_values;
+ if (num_values != NULL)
+ *num_values = mykeydata->num_values;
- if (numsubkeys != NULL)
- *numsubkeys = mykeydata->num_subkeys;
+ if (last_changed_time != NULL)
+ *last_changed_time = mykeydata->last_changed_time;
+
+ if (max_subkeylen != NULL)
+ *max_subkeylen = mykeydata->max_subkeylen;
if (max_valnamelen != NULL)
*max_valnamelen = mykeydata->max_valnamelen;
if (max_valbufsize != NULL)
- *max_valbufsize = mykeydata->max_valdatalen;
-
- if (max_subkeynamelen != NULL)
- *max_subkeynamelen = mykeydata->max_subkeynamelen;
+ *max_valbufsize = mykeydata->max_valbufsize;
return WERR_OK;
}
@@ -408,6 +469,7 @@ static struct registry_operations reg_backend_rpc = {
.get_predefined_key = rpc_get_predefined_key,
.enum_key = rpc_get_subkey_by_index,
.enum_value = rpc_get_value_by_index,
+ .get_value = rpc_get_value_by_name,
.create_key = rpc_add_key,
.delete_key = rpc_del_key,
.get_key_info = rpc_get_info,
diff --git a/source4/lib/registry/tests/generic.c b/source4/lib/registry/tests/generic.c
index 6eae26bc46..2b7eb838ba 100644
--- a/source4/lib/registry/tests/generic.c
+++ b/source4/lib/registry/tests/generic.c
@@ -53,7 +53,7 @@ static bool test_reg_val_data_string_dword(struct torture_context *ctx)
static bool test_reg_val_data_string_sz(struct torture_context *ctx)
{
DATA_BLOB db;
- db.length = convert_string_talloc(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UNIX, CH_UTF16,
+ db.length = convert_string_talloc(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16,
"bla", 3, (void **)&db.data);
torture_assert_str_equal(ctx, "bla",
reg_val_data_string(ctx, lp_iconv_convenience(ctx->lp_ctx), REG_SZ, db),
@@ -88,7 +88,7 @@ static bool test_reg_val_data_string_empty(struct torture_context *ctx)
static bool test_reg_val_description(struct torture_context *ctx)
{
DATA_BLOB data;
- data.length = convert_string_talloc(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UNIX, CH_UTF16,
+ data.length = convert_string_talloc(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16,
"stationary traveller",
strlen("stationary traveller"),
(void **)&data.data);
@@ -102,7 +102,7 @@ static bool test_reg_val_description(struct torture_context *ctx)
static bool test_reg_val_description_nullname(struct torture_context *ctx)
{
DATA_BLOB data;
- data.length = convert_string_talloc(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UNIX, CH_UTF16,
+ data.length = convert_string_talloc(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16,
"west berlin",
strlen("west berlin"),
(void **)&data.data);
diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c
index 240c582340..fcf7c26237 100644
--- a/source4/lib/registry/tools/regdiff.c
+++ b/source4/lib/registry/tools/regdiff.c
@@ -46,7 +46,7 @@ static struct registry_context *open_backend(poptContext pc,
break;
case REG_REMOTE:
error = reg_open_remote(&ctx, NULL, cmdline_credentials, lp_ctx,
- remote_host, NULL);
+ remote_host, ev_ctx);
break;
case REG_NULL:
error = reg_open_local(NULL, &ctx);
diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c
index 98f7f02c38..5c308bfbda 100644
--- a/source4/lib/registry/tools/regshell.c
+++ b/source4/lib/registry/tools/regshell.c
@@ -207,8 +207,8 @@ static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv)
{
int i;
WERROR error;
- uint32_t data_type;
- DATA_BLOB data;
+ uint32_t valuetype;
+ DATA_BLOB valuedata;
const char *name = NULL;
for (i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(ctx,
@@ -221,19 +221,15 @@ static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv)
}
if (!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) {
- DEBUG(0, ("Error occured while browsing thru keys: %s\n",
- win_errstr(error)));
+ fprintf(stderr, "Error occured while browsing thru keys: %s\n",
+ win_errstr(error));
+ return error;
}
for (i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(ctx,
- ctx->current,
- i,
- &name,
- &data_type,
- &data)); i++) {
- printf("V \"%s\" %s %s\n", name, str_regtype(data_type),
- reg_val_data_string(ctx, lp_iconv_convenience(cmdline_lp_ctx), data_type, data));
- }
+ ctx->current, i, &name, &valuetype, &valuedata)); i++)
+ printf("V \"%s\" %s %s\n", name, str_regtype(valuetype),
+ reg_val_data_string(ctx, lp_iconv_convenience(cmdline_lp_ctx), valuetype, valuedata));
return WERR_OK;
}
@@ -250,7 +246,8 @@ static WERROR cmd_mkkey(struct regshell_context *ctx, int argc, char **argv)
error = reg_key_add_name(ctx, ctx->current, argv[1], 0, NULL, &tmp);
if (!W_ERROR_IS_OK(error)) {
- fprintf(stderr, "Error adding new subkey '%s'\n", argv[1]);
+ fprintf(stderr, "Error adding new subkey '%s': %s\n", argv[1],
+ win_errstr(error));
return error;
}
@@ -438,7 +435,7 @@ static char **reg_complete_key(const char *text, int start, int end)
len = strlen(text);
for(i = 0; j < MAX_COMPLETIONS-1; i++) {
status = reg_key_get_subkey_by_index(mem_ctx, base, i,
- &subkeyname, NULL, NULL);
+ &subkeyname, NULL, NULL);
if(W_ERROR_IS_OK(status)) {
if(!strncmp(text, subkeyname, len)) {
matches[j] = strdup(subkeyname);
@@ -536,7 +533,8 @@ int main(int argc, char **argv)
if (ctx->current == NULL) {
int i;
- for (i = 0; reg_predefined_keys[i].handle; i++) {
+ for (i = 0; (reg_predefined_keys[i].handle != 0) &&
+ (ctx->current == NULL); i++) {
WERROR err;
err = reg_get_predefined_key(ctx->registry,
reg_predefined_keys[i].handle,
diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c
index 19e4a010b4..6d55a3eb84 100644
--- a/source4/lib/registry/tools/regtree.c
+++ b/source4/lib/registry/tools/regtree.c
@@ -38,10 +38,9 @@ static void print_tree(int level, struct registry_key *p,
bool fullpath, bool novals)
{
struct registry_key *subkey;
- const char *valuename;
- const char *keyname;
- uint32_t value_type;
- DATA_BLOB value_data;
+ const char *valuename, *keyname;
+ uint32_t valuetype;
+ DATA_BLOB valuedata;
struct security_descriptor *sec_desc;
WERROR error;
int i;
@@ -73,18 +72,14 @@ static void print_tree(int level, struct registry_key *p,
if (!novals) {
mem_ctx = talloc_init("print_tree");
- for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(mem_ctx,
- p,
- i,
- &valuename,
- &value_type,
- &value_data)); i++) {
+ for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(
+ mem_ctx, p, i, &valuename, &valuetype, &valuedata));
+ i++) {
int j;
- char *desc;
for(j = 0; j < level+1; j++) putchar(' ');
- desc = reg_val_description(mem_ctx, lp_iconv_convenience(cmdline_lp_ctx), valuename,
- value_type, value_data);
- printf("%s\n", desc);
+ printf("%s\n", reg_val_description(mem_ctx,
+ lp_iconv_convenience(cmdline_lp_ctx), valuename,
+ valuetype, valuedata));
}
talloc_free(mem_ctx);
diff --git a/source4/lib/registry/util.c b/source4/lib/registry/util.c
index 68efd56a86..b3b6e49ea5 100644
--- a/source4/lib/registry/util.c
+++ b/source4/lib/registry/util.c
@@ -140,8 +140,7 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx,
break;
case REG_BINARY:
- *data = strhex_to_data_blob(data_str);
- talloc_steal(mem_ctx, data->data);
+ *data = strhex_to_data_blob(mem_ctx, data_str);
break;
default:
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/samba3/config.mk b/source4/lib/samba3/config.mk
index e089149393..365347fe21 100644
--- a/source4/lib/samba3/config.mk
+++ b/source4/lib/samba3/config.mk
@@ -6,5 +6,3 @@ PRIVATE_DEPENDENCIES = CHARSET LIBSAMBA-UTIL
################################################
SMBPASSWD_OBJ_FILES = $(libsrcdir)/samba3/smbpasswd.o
-
-$(eval $(call proto_header_template,$(libsrcdir)/samba3/samba3_smbpasswd_proto.h,$(SMBPASSWD_OBJ_FILES:.o=.c)))
diff --git a/source4/lib/samba3/samba3.h b/source4/lib/samba3/samba3.h
index aea87dac14..1a0ce04143 100644
--- a/source4/lib/samba3/samba3.h
+++ b/source4/lib/samba3/samba3.h
@@ -24,191 +24,9 @@
#include "librpc/gen_ndr/samr.h"
#include "param/param.h"
-struct samba3_samaccount {
- uint32_t logon_time,
- logoff_time,
- kickoff_time,
- bad_password_time,
- pass_last_set_time,
- pass_can_change_time,
- pass_must_change_time;
- char *username;
- char *domain;
- char *nt_username;
- char *dir_drive;
- char *unknown_str;
- char *munged_dial;
- char *fullname;
- char *homedir;
- char *logon_script;
- char *profile_path;
- char *acct_desc;
- char *workstations;
- uint32_t user_rid, group_rid, hours_len, unknown_6;
- uint16_t acct_ctrl, logon_divs;
- uint16_t bad_password_count, logon_count;
- struct samr_Password lm_pw, nt_pw;
- uint8_t *nt_pw_hist_ptr;
- uint8_t *hours;
-};
-
-struct samba3_groupmapping {
- gid_t gid;
- struct dom_sid *sid;
- int sid_name_use;
- const char *nt_name;
- const char *comment;
-};
-
-struct samba3_alias {
- struct dom_sid *sid;
- uint32_t member_count;
- struct dom_sid **members;
-};
-
-struct samba3_groupdb {
- uint32_t groupmap_count;
- struct samba3_groupmapping *groupmappings;
-
- uint32_t alias_count;
- struct samba3_alias *aliases;
-};
-
-struct samba3_idmap_mapping
-{
- enum { IDMAP_GROUP, IDMAP_USER } type;
- uint32_t unix_id;
- struct dom_sid *sid;
-};
-
-struct samba3_idmapdb
-{
- /* High water marks */
- uint32_t user_hwm;
- uint32_t group_hwm;
-
- uint32_t mapping_count;
- struct samba3_idmap_mapping *mappings;
-};
-
-struct samba3_winsdb_entry
-{
- char *name;
- int nb_flags;
- int type;
- time_t ttl;
- uint32_t ip_count;
- struct in_addr *ips;
-};
-
-struct samba3_policy
-{
- uint32_t min_password_length;
- uint32_t password_history;
- uint32_t user_must_logon_to_change_password;
- uint32_t maximum_password_age;
- uint32_t minimum_password_age;
- uint32_t lockout_duration;
- uint32_t reset_count_minutes;
- uint32_t bad_lockout_minutes;
- uint32_t disconnect_time;
- uint32_t refuse_machine_password_change;
-};
-
-struct samba3_regval {
- char *name;
- uint16_t type;
- DATA_BLOB data;
-};
-
-struct samba3_regkey {
- char *name;
-
- uint32_t value_count;
- struct samba3_regval *values;
-
- uint32_t subkey_count;
- char **subkeys;
-};
-
-struct samba3_regdb
-{
- uint32_t key_count;
- struct samba3_regkey *keys;
-};
-
-struct samba3_secrets
-{
- struct cli_credentials *ipc_cred;
-
- uint32_t ldappw_count;
- struct samba3_ldappw
- {
- char *dn;
- char *password;
- } *ldappws;
-
- uint32_t domain_count;
- struct samba3_domainsecrets
- {
- char *name;
- struct dom_sid sid;
- struct GUID guid;
- char *plaintext_pw;
- time_t last_change_time;
- struct {
- uint8_t hash[16];
- time_t mod_time;
- } hash_pw;
- int sec_channel_type;
- } *domains;
-
- uint32_t trusted_domain_count;
- struct samba3_trusted_dom_pass {
- uint32_t uni_name_len;
- const char *uni_name[32]; /* unicode domain name */
- const char *pass; /* trust relationship's password */
- time_t mod_time;
- struct dom_sid domain_sid; /* remote domain's sid */
- } *trusted_domains;
-
- uint32_t afs_keyfile_count;
-
- struct samba3_afs_keyfile {
- uint32_t nkeys;
- struct {
- uint32_t kvno;
- char key[8];
- } entry[8];
- char *cell;
- } *afs_keyfiles;
-};
-
-struct samba3_share_info {
- char *name;
- struct security_descriptor secdesc;
-};
-
-struct samba3
-{
- struct param_context *configuration;
-
- uint32_t winsdb_count;
- struct samba3_winsdb_entry *winsdb_entries;
-
- uint32_t samaccount_count;
- struct samba3_samaccount *samaccounts;
-
- uint32_t share_count;
- struct samba3_share_info *shares;
-
- struct samba3_secrets secrets;
- struct samba3_groupdb group;
- struct samba3_idmapdb idmap;
- struct samba3_policy policy;
- struct samba3_regdb registry;
-};
-
-#include "lib/samba3/samba3_smbpasswd_proto.h"
+struct samr_Password *smbpasswd_gethexpwd(TALLOC_CTX *mem_ctx, const char *p);
+char *smbpasswd_sethexpwd(TALLOC_CTX *mem_ctx, struct samr_Password *pwd, uint16_t acb_info);
+uint16_t smbpasswd_decode_acb_info(const char *p);
+char *smbpasswd_encode_acb_info(TALLOC_CTX *mem_ctx, uint16_t acb_info);
#endif /* _SAMBA3_H */
diff --git a/source4/lib/smbreadline/smbreadline.c b/source4/lib/smbreadline/smbreadline.c
index a85f335b8a..5fb3bf4fae 100644
--- a/source4/lib/smbreadline/smbreadline.c
+++ b/source4/lib/smbreadline/smbreadline.c
@@ -29,7 +29,7 @@
This is what sys_select() used to do in Samba.
********************************************************************/
-int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *tval)
+static int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *tval)
{
int ret;
fd_set *readfds2, readfds_buf, *writefds2, writefds_buf, *errorfds2, errorfds_buf;
@@ -82,7 +82,7 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void)
int fd = STDIN_FILENO;
char *ret;
- do_debug("%s", prompt);
+ printf("%s", prompt);
line = (char *)malloc(BUFSIZ);
if (!line) {
diff --git a/source4/lib/socket/interface.c b/source4/lib/socket/interface.c
index c327f02bbd..b4e7c2bf32 100644
--- a/source4/lib/socket/interface.c
+++ b/source4/lib/socket/interface.c
@@ -22,7 +22,7 @@
#include "includes.h"
#include "system/network.h"
#include "lib/socket/netif.h"
-#include "lib/util/dlinklist.h"
+#include "../lib/util/dlinklist.h"
#include "param/param.h"
/** used for network interfaces */
diff --git a/source4/lib/socket/socket.c b/source4/lib/socket/socket.c
index 92f0a44005..0c3d032068 100644
--- a/source4/lib/socket/socket.c
+++ b/source4/lib/socket/socket.c
@@ -491,7 +491,7 @@ static const struct {
**/
_PUBLIC_ void set_socket_options(int fd, const char *options)
{
- const char **options_list = str_list_make(NULL, options, " \t,");
+ const char **options_list = (const char **)str_list_make(NULL, options, " \t,");
int j;
if (!options_list)
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/stream/packet.c b/source4/lib/stream/packet.c
index 92fa0e5a54..72a7e6485c 100644
--- a/source4/lib/stream/packet.c
+++ b/source4/lib/stream/packet.c
@@ -21,7 +21,7 @@
*/
#include "includes.h"
-#include "lib/util/dlinklist.h"
+#include "../lib/util/dlinklist.h"
#include "lib/events/events.h"
#include "lib/socket/socket.h"
#include "lib/stream/packet.h"
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/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..da27803b06 100644
--- a/source4/lib/tdb_wrap.c
+++ b/source4/lib/tdb_wrap.c
@@ -20,8 +20,8 @@
*/
#include "includes.h"
-#include "lib/tdb/include/tdb.h"
-#include "lib/util/dlinklist.h"
+#include "../tdb/include/tdb.h"
+#include "../lib/util/dlinklist.h"
#include "tdb_wrap.h"
#include "tdb.h"
@@ -46,7 +46,7 @@ static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level,
{
va_list ap;
char *ptr = NULL;
- int debug_level;
+ int dl;
va_start(ap, format);
vasprintf(&ptr, format, ap);
@@ -54,24 +54,24 @@ static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level,
switch (level) {
case TDB_DEBUG_FATAL:
- debug_level = 0;
+ dl = 0;
break;
case TDB_DEBUG_ERROR:
- debug_level = 1;
+ dl = 1;
break;
case TDB_DEBUG_WARNING:
- debug_level = 2;
+ dl = 2;
break;
case TDB_DEBUG_TRACE:
- debug_level = 5;
+ dl = 5;
break;
default:
- debug_level = 0;
+ dl = 0;
}
if (ptr != NULL) {
const char *name = tdb_name(tdb);
- DEBUG(debug_level, ("tdb(%s): %s", name ? name : "unnamed", ptr));
+ DEBUG(dl, ("tdb(%s): %s", name ? name : "unnamed", ptr));
free(ptr);
}
}
diff --git a/source4/lib/tls/tls.c b/source4/lib/tls/tls.c
index b298fb10cf..f72aafe542 100644
--- a/source4/lib/tls/tls.c
+++ b/source4/lib/tls/tls.c
@@ -363,7 +363,6 @@ struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx, struct loadparm_context *
const char *crlfile = private_path(tmp_ctx, lp_ctx, lp_tls_crlfile(lp_ctx));
const char *dhpfile = private_path(tmp_ctx, lp_ctx, lp_tls_dhpfile(lp_ctx));
void tls_cert_generate(TALLOC_CTX *, const char *, const char *, const char *);
-
params = talloc(mem_ctx, struct tls_params);
if (params == NULL) {
talloc_free(tmp_ctx);
@@ -421,7 +420,7 @@ struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx, struct loadparm_context *
if (dhpfile && *dhpfile) {
gnutls_datum_t dhparms;
size_t size;
- dhparms.data = (uint8_t *)file_load(dhpfile, &size, mem_ctx);
+ dhparms.data = (uint8_t *)file_load(dhpfile, &size, 0, mem_ctx);
if (!dhparms.data) {
DEBUG(0,("Failed to read DH Parms from %s\n", dhpfile));
diff --git a/source4/lib/tls/tlscert.c b/source4/lib/tls/tlscert.c
index 240ae056c1..f2e79f2a89 100644
--- a/source4/lib/tls/tlscert.c
+++ b/source4/lib/tls/tlscert.c
@@ -31,6 +31,10 @@
#define LIFETIME 700*24*60*60
#define DH_BITS 1024
+void tls_cert_generate(TALLOC_CTX *mem_ctx,
+ const char *keyfile, const char *certfile,
+ const char *cafile);
+
/*
auto-generate a set of self signed certificates
*/
diff --git a/source4/lib/torture/torture.c b/source4/lib/torture/torture.c
index 33959ded16..ba7168f3fe 100644
--- a/source4/lib/torture/torture.c
+++ b/source4/lib/torture/torture.c
@@ -20,7 +20,7 @@
#include "includes.h"
#include "torture/torture.h"
-#include "lib/util/dlinklist.h"
+#include "../lib/util/dlinklist.h"
#include "param/param.h"
#include "system/filesys.h"
@@ -235,19 +235,6 @@ void torture_ui_test_start(struct torture_context *context,
context->ui_ops->test_start(context, tcase, test);
}
-int str_list_match(const char *name, char **list)
-{
- int i, ret = 0;
- if (list == NULL)
- return 0;
-
- for (i = 0; list[i]; i++) {
- if (gen_fnmatch(list[i], name) == 0)
- ret++;
- }
- return ret;
-}
-
void torture_ui_test_result(struct torture_context *context,
enum torture_result result,
const char *comment)
diff --git a/source4/lib/torture/torture.h b/source4/lib/torture/torture.h
index f023f319ff..0f966a52d1 100644
--- a/source4/lib/torture/torture.h
+++ b/source4/lib/torture/torture.h
@@ -267,7 +267,7 @@ void torture_result(struct torture_context *test,
char *__got; \
const char *__expected = (expected); \
size_t __size; \
- __got = file_load(filename, &__size, torture_ctx); \
+ __got = file_load(filename, &__size, 0, torture_ctx); \
if (__got == NULL) { \
torture_result(torture_ctx, TORTURE_FAIL, \
__location__": unable to open %s: %s\n", \
@@ -288,7 +288,7 @@ void torture_result(struct torture_context *test,
#define torture_assert_file_contains(torture_ctx,filename,expected,cmt)\
do { const char *__got, *__expected = (expected); \
size_t __size; \
- __got = file_load(filename, *size, torture_ctx); \
+ __got = file_load(filename, *size, 0, torture_ctx); \
if (strcmp_safe(__got, __expected) != 0) { \
torture_result(torture_ctx, TORTURE_FAIL, \
__location__": %s contained:\n%sExpected: %s%s\n", \
diff --git a/source4/lib/util/Doxyfile b/source4/lib/util/Doxyfile
deleted file mode 100644
index 02e36a7af9..0000000000
--- a/source4/lib/util/Doxyfile
+++ /dev/null
@@ -1,24 +0,0 @@
-PROJECT_NAME = SAMBA_UTIL
-OUTPUT_DIRECTORY = apidocs
-BRIEF_MEMBER_DESC = YES
-REPEAT_BRIEF = YES
-OPTIMIZE_OUTPUT_FOR_C = YES
-SORT_MEMBER_DOCS = YES
-SORT_BRIEF_DOCS = NO
-GENERATE_TODOLIST = YES
-GENERATE_BUGLIST = YES
-GENERATE_DEPRECATEDLIST= YES
-SHOW_USED_FILES = NO
-SHOW_DIRECTORIES = NO
-WARNINGS = YES
-WARN_IF_UNDOCUMENTED = YES
-WARN_IF_DOC_ERROR = YES
-WARN_NO_PARAMDOC = NO
-WARN_FORMAT = "$file:$line: $text"
-INPUT = .
-FILE_PATTERNS = *.c *.h *.dox
-GENERATE_HTML = YES
-HTML_OUTPUT = html
-GENERATE_MAN = YES
-ALWAYS_DETAILED_SEC = YES
-JAVADOC_AUTOBRIEF = YES
diff --git a/source4/lib/util/asn1.c b/source4/lib/util/asn1.c
deleted file mode 100644
index 4756c0640d..0000000000
--- a/source4/lib/util/asn1.c
+++ /dev/null
@@ -1,770 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- simple ASN1 routines
- 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 "includes.h"
-#include "lib/util/asn1.h"
-
-/* allocate an asn1 structure */
-struct asn1_data *asn1_init(TALLOC_CTX *mem_ctx)
-{
- struct asn1_data *ret = talloc_zero(mem_ctx, struct asn1_data);
- if (ret == NULL) {
- DEBUG(0,("asn1_init failed! out of memory\n"));
- }
- return ret;
-}
-
-/* free an asn1 structure */
-void asn1_free(struct asn1_data *data)
-{
- talloc_free(data);
-}
-
-/* write to the ASN1 buffer, advancing the buffer pointer */
-bool asn1_write(struct asn1_data *data, const void *p, int len)
-{
- if (data->has_error) return false;
- if (data->length < data->ofs+len) {
- uint8_t *newp;
- newp = talloc_realloc(data, data->data, uint8_t, data->ofs+len);
- if (!newp) {
- asn1_free(data);
- data->has_error = true;
- return false;
- }
- data->data = newp;
- data->length = data->ofs+len;
- }
- memcpy(data->data + data->ofs, p, len);
- data->ofs += len;
- return true;
-}
-
-/* useful fn for writing a uint8_t */
-bool asn1_write_uint8(struct asn1_data *data, uint8_t v)
-{
- return asn1_write(data, &v, 1);
-}
-
-/* push a tag onto the asn1 data buffer. Used for nested structures */
-bool asn1_push_tag(struct asn1_data *data, uint8_t tag)
-{
- struct nesting *nesting;
-
- asn1_write_uint8(data, tag);
- nesting = talloc(data, struct nesting);
- if (!nesting) {
- data->has_error = true;
- return false;
- }
-
- nesting->start = data->ofs;
- nesting->next = data->nesting;
- data->nesting = nesting;
- return asn1_write_uint8(data, 0xff);
-}
-
-/* pop a tag */
-bool asn1_pop_tag(struct asn1_data *data)
-{
- struct nesting *nesting;
- size_t len;
-
- nesting = data->nesting;
-
- if (!nesting) {
- data->has_error = true;
- return false;
- }
- len = data->ofs - (nesting->start+1);
- /* yes, this is ugly. We don't know in advance how many bytes the length
- of a tag will take, so we assumed 1 byte. If we were wrong then we
- need to correct our mistake */
- if (len > 0xFFFFFF) {
- data->data[nesting->start] = 0x84;
- if (!asn1_write_uint8(data, 0)) return false;
- if (!asn1_write_uint8(data, 0)) return false;
- if (!asn1_write_uint8(data, 0)) return false;
- if (!asn1_write_uint8(data, 0)) return false;
- memmove(data->data+nesting->start+5, data->data+nesting->start+1, len);
- data->data[nesting->start+1] = (len>>24) & 0xFF;
- data->data[nesting->start+2] = (len>>16) & 0xFF;
- data->data[nesting->start+3] = (len>>8) & 0xFF;
- data->data[nesting->start+4] = len&0xff;
- } else if (len > 0xFFFF) {
- data->data[nesting->start] = 0x83;
- if (!asn1_write_uint8(data, 0)) return false;
- if (!asn1_write_uint8(data, 0)) return false;
- if (!asn1_write_uint8(data, 0)) return false;
- memmove(data->data+nesting->start+4, data->data+nesting->start+1, len);
- data->data[nesting->start+1] = (len>>16) & 0xFF;
- data->data[nesting->start+2] = (len>>8) & 0xFF;
- data->data[nesting->start+3] = len&0xff;
- } else if (len > 255) {
- data->data[nesting->start] = 0x82;
- if (!asn1_write_uint8(data, 0)) return false;
- if (!asn1_write_uint8(data, 0)) return false;
- memmove(data->data+nesting->start+3, data->data+nesting->start+1, len);
- data->data[nesting->start+1] = len>>8;
- data->data[nesting->start+2] = len&0xff;
- } else if (len > 127) {
- data->data[nesting->start] = 0x81;
- if (!asn1_write_uint8(data, 0)) return false;
- memmove(data->data+nesting->start+2, data->data+nesting->start+1, len);
- data->data[nesting->start+1] = len;
- } else {
- data->data[nesting->start] = len;
- }
-
- data->nesting = nesting->next;
- talloc_free(nesting);
- return true;
-}
-
-/* "i" is the one's complement representation, as is the normal result of an
- * implicit signed->unsigned conversion */
-
-static bool push_int_bigendian(struct asn1_data *data, unsigned int i, bool negative)
-{
- uint8_t lowest = i & 0xFF;
-
- i = i >> 8;
- if (i != 0)
- if (!push_int_bigendian(data, i, negative))
- return false;
-
- if (data->nesting->start+1 == data->ofs) {
-
- /* We did not write anything yet, looking at the highest
- * valued byte */
-
- if (negative) {
- /* Don't write leading 0xff's */
- if (lowest == 0xFF)
- return true;
-
- if ((lowest & 0x80) == 0) {
- /* The only exception for a leading 0xff is if
- * the highest bit is 0, which would indicate
- * a positive value */
- if (!asn1_write_uint8(data, 0xff))
- return false;
- }
- } else {
- if (lowest & 0x80) {
- /* The highest bit of a positive integer is 1,
- * this would indicate a negative number. Push
- * a 0 to indicate a positive one */
- if (!asn1_write_uint8(data, 0))
- return false;
- }
- }
- }
-
- return asn1_write_uint8(data, lowest);
-}
-
-/* write an Integer without the tag framing. Needed for example for the LDAP
- * Abandon Operation */
-
-bool asn1_write_implicit_Integer(struct asn1_data *data, int i)
-{
- if (i == -1) {
- /* -1 is special as it consists of all-0xff bytes. In
- push_int_bigendian this is the only case that is not
- properly handled, as all 0xff bytes would be handled as
- leading ones to be ignored. */
- return asn1_write_uint8(data, 0xff);
- } else {
- return push_int_bigendian(data, i, i<0);
- }
-}
-
-
-/* write an integer */
-bool asn1_write_Integer(struct asn1_data *data, int i)
-{
- if (!asn1_push_tag(data, ASN1_INTEGER)) return false;
- if (!asn1_write_implicit_Integer(data, i)) return false;
- return asn1_pop_tag(data);
-}
-
-bool ber_write_OID_String(DATA_BLOB *blob, const char *OID)
-{
- uint_t v, v2;
- const char *p = (const char *)OID;
- char *newp;
- int i;
-
- v = strtoul(p, &newp, 10);
- if (newp[0] != '.') return false;
- p = newp + 1;
-
- v2 = strtoul(p, &newp, 10);
- if (newp[0] != '.') return false;
- p = newp + 1;
-
- /*the ber representation can't use more space then the string one */
- *blob = data_blob(NULL, strlen(OID));
- if (!blob->data) return false;
-
- blob->data[0] = 40*v + v2;
-
- i = 1;
- while (*p) {
- v = strtoul(p, &newp, 10);
- if (newp[0] == '.') {
- p = newp + 1;
- } else if (newp[0] == '\0') {
- p = newp;
- } else {
- data_blob_free(blob);
- return false;
- }
- if (v >= (1<<28)) blob->data[i++] = (0x80 | ((v>>28)&0x7f));
- if (v >= (1<<21)) blob->data[i++] = (0x80 | ((v>>21)&0x7f));
- if (v >= (1<<14)) blob->data[i++] = (0x80 | ((v>>14)&0x7f));
- if (v >= (1<<7)) blob->data[i++] = (0x80 | ((v>>7)&0x7f));
- blob->data[i++] = (v&0x7f);
- }
-
- blob->length = i;
-
- return true;
-}
-
-/* write an object ID to a ASN1 buffer */
-bool asn1_write_OID(struct asn1_data *data, const char *OID)
-{
- DATA_BLOB blob;
-
- if (!asn1_push_tag(data, ASN1_OID)) return false;
-
- if (!ber_write_OID_String(&blob, OID)) {
- data->has_error = true;
- return false;
- }
-
- if (!asn1_write(data, blob.data, blob.length)) {
- data->has_error = true;
- return false;
- }
- data_blob_free(&blob);
- return asn1_pop_tag(data);
-}
-
-/* write an octet string */
-bool asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length)
-{
- asn1_push_tag(data, ASN1_OCTET_STRING);
- asn1_write(data, p, length);
- asn1_pop_tag(data);
- return !data->has_error;
-}
-
-/* write a LDAP string */
-bool asn1_write_LDAPString(struct asn1_data *data, const char *s)
-{
- asn1_write(data, s, strlen(s));
- return !data->has_error;
-}
-
-/* write a LDAP string from a DATA_BLOB */
-bool asn1_write_DATA_BLOB_LDAPString(struct asn1_data *data, const DATA_BLOB *s)
-{
- asn1_write(data, s->data, s->length);
- return !data->has_error;
-}
-
-/* write a general string */
-bool asn1_write_GeneralString(struct asn1_data *data, const char *s)
-{
- asn1_push_tag(data, ASN1_GENERAL_STRING);
- asn1_write_LDAPString(data, s);
- asn1_pop_tag(data);
- return !data->has_error;
-}
-
-bool asn1_write_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob)
-{
- asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(num));
- asn1_write(data, blob->data, blob->length);
- asn1_pop_tag(data);
- return !data->has_error;
-}
-
-/* write a BOOLEAN */
-bool asn1_write_BOOLEAN(struct asn1_data *data, bool v)
-{
- asn1_push_tag(data, ASN1_BOOLEAN);
- asn1_write_uint8(data, v ? 0xFF : 0);
- asn1_pop_tag(data);
- return !data->has_error;
-}
-
-bool asn1_read_BOOLEAN(struct asn1_data *data, bool *v)
-{
- uint8_t tmp = 0;
- asn1_start_tag(data, ASN1_BOOLEAN);
- asn1_read_uint8(data, &tmp);
- if (tmp == 0xFF) {
- *v = true;
- } else {
- *v = false;
- }
- asn1_end_tag(data);
- return !data->has_error;
-}
-
-/* check a BOOLEAN */
-bool asn1_check_BOOLEAN(struct asn1_data *data, bool v)
-{
- uint8_t b = 0;
-
- asn1_read_uint8(data, &b);
- if (b != ASN1_BOOLEAN) {
- data->has_error = true;
- return false;
- }
- asn1_read_uint8(data, &b);
- if (b != v) {
- data->has_error = true;
- return false;
- }
- return !data->has_error;
-}
-
-
-/* load a struct asn1_data structure with a lump of data, ready to be parsed */
-bool asn1_load(struct asn1_data *data, DATA_BLOB blob)
-{
- ZERO_STRUCTP(data);
- data->data = talloc_memdup(data, blob.data, blob.length);
- if (!data->data) {
- data->has_error = true;
- return false;
- }
- data->length = blob.length;
- return true;
-}
-
-/* Peek into an ASN1 buffer, not advancing the pointer */
-bool asn1_peek(struct asn1_data *data, void *p, int len)
-{
- if (data->has_error)
- return false;
-
- if (len < 0 || data->ofs + len < data->ofs || data->ofs + len < len)
- return false;
-
- if (data->ofs + len > data->length) {
- /* we need to mark the buffer as consumed, so the caller knows
- this was an out of data error, and not a decode error */
- data->ofs = data->length;
- return false;
- }
-
- memcpy(p, data->data + data->ofs, len);
- return true;
-}
-
-/* read from a ASN1 buffer, advancing the buffer pointer */
-bool asn1_read(struct asn1_data *data, void *p, int len)
-{
- if (!asn1_peek(data, p, len)) {
- data->has_error = true;
- return false;
- }
-
- data->ofs += len;
- return true;
-}
-
-/* read a uint8_t from a ASN1 buffer */
-bool asn1_read_uint8(struct asn1_data *data, uint8_t *v)
-{
- return asn1_read(data, v, 1);
-}
-
-bool asn1_peek_uint8(struct asn1_data *data, uint8_t *v)
-{
- return asn1_peek(data, v, 1);
-}
-
-bool asn1_peek_tag(struct asn1_data *data, uint8_t tag)
-{
- uint8_t b;
-
- if (asn1_tag_remaining(data) <= 0) {
- return false;
- }
-
- if (!asn1_peek_uint8(data, &b))
- return false;
-
- return (b == tag);
-}
-
-/* start reading a nested asn1 structure */
-bool asn1_start_tag(struct asn1_data *data, uint8_t tag)
-{
- uint8_t b;
- struct nesting *nesting;
-
- if (!asn1_read_uint8(data, &b))
- return false;
-
- if (b != tag) {
- data->has_error = true;
- return false;
- }
- nesting = talloc(data, struct nesting);
- if (!nesting) {
- data->has_error = true;
- return false;
- }
-
- if (!asn1_read_uint8(data, &b)) {
- return false;
- }
-
- if (b & 0x80) {
- int n = b & 0x7f;
- if (!asn1_read_uint8(data, &b))
- return false;
- nesting->taglen = b;
- while (n > 1) {
- if (!asn1_read_uint8(data, &b))
- return false;
- nesting->taglen = (nesting->taglen << 8) | b;
- n--;
- }
- } else {
- nesting->taglen = b;
- }
- nesting->start = data->ofs;
- nesting->next = data->nesting;
- data->nesting = nesting;
- if (asn1_tag_remaining(data) == -1) {
- return false;
- }
- return !data->has_error;
-}
-
-/* stop reading a tag */
-bool asn1_end_tag(struct asn1_data *data)
-{
- struct nesting *nesting;
-
- /* make sure we read it all */
- if (asn1_tag_remaining(data) != 0) {
- data->has_error = true;
- return false;
- }
-
- nesting = data->nesting;
-
- if (!nesting) {
- data->has_error = true;
- return false;
- }
-
- data->nesting = nesting->next;
- talloc_free(nesting);
- return true;
-}
-
-/* work out how many bytes are left in this nested tag */
-int asn1_tag_remaining(struct asn1_data *data)
-{
- int remaining;
- if (data->has_error) {
- return -1;
- }
-
- if (!data->nesting) {
- data->has_error = true;
- return -1;
- }
- remaining = data->nesting->taglen - (data->ofs - data->nesting->start);
- if (remaining > (data->length - data->ofs)) {
- data->has_error = true;
- return -1;
- }
- return remaining;
-}
-
-/* read an object ID from a data blob */
-bool ber_read_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB blob, const char **OID)
-{
- int i;
- uint8_t *b;
- uint_t v;
- char *tmp_oid = NULL;
-
- if (blob.length < 2) return false;
-
- b = blob.data;
-
- tmp_oid = talloc_asprintf(mem_ctx, "%u", b[0]/40);
- if (!tmp_oid) goto nomem;
- tmp_oid = talloc_asprintf_append_buffer(tmp_oid, ".%u", b[0]%40);
- if (!tmp_oid) goto nomem;
-
- for(i = 1, v = 0; i < blob.length; i++) {
- v = (v<<7) | (b[i]&0x7f);
- if ( ! (b[i] & 0x80)) {
- tmp_oid = talloc_asprintf_append_buffer(tmp_oid, ".%u", v);
- v = 0;
- }
- if (!tmp_oid) goto nomem;
- }
-
- if (v != 0) {
- talloc_free(tmp_oid);
- return false;
- }
-
- *OID = tmp_oid;
- return true;
-
-nomem:
- return false;
-}
-
-/* read an object ID from a ASN1 buffer */
-bool asn1_read_OID(struct asn1_data *data, TALLOC_CTX *mem_ctx, const char **OID)
-{
- DATA_BLOB blob;
- int len;
-
- if (!asn1_start_tag(data, ASN1_OID)) return false;
-
- len = asn1_tag_remaining(data);
- if (len < 0) {
- data->has_error = true;
- return false;
- }
-
- blob = data_blob(NULL, len);
- if (!blob.data) {
- data->has_error = true;
- return false;
- }
-
- asn1_read(data, blob.data, len);
- asn1_end_tag(data);
- if (data->has_error) {
- data_blob_free(&blob);
- return false;
- }
-
- if (!ber_read_OID_String(mem_ctx, blob, OID)) {
- data->has_error = true;
- data_blob_free(&blob);
- return false;
- }
-
- data_blob_free(&blob);
- return true;
-}
-
-/* check that the next object ID is correct */
-bool asn1_check_OID(struct asn1_data *data, const char *OID)
-{
- const char *id;
-
- if (!asn1_read_OID(data, data, &id)) return false;
-
- if (strcmp(id, OID) != 0) {
- talloc_free(discard_const(id));
- data->has_error = true;
- return false;
- }
- talloc_free(discard_const(id));
- return true;
-}
-
-/* read a LDAPString from a ASN1 buffer */
-bool asn1_read_LDAPString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s)
-{
- int len;
- len = asn1_tag_remaining(data);
- if (len < 0) {
- data->has_error = true;
- return false;
- }
- *s = talloc_array(mem_ctx, char, len+1);
- if (! *s) {
- data->has_error = true;
- return false;
- }
- asn1_read(data, *s, len);
- (*s)[len] = 0;
- return !data->has_error;
-}
-
-
-/* read a GeneralString from a ASN1 buffer */
-bool asn1_read_GeneralString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s)
-{
- if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) return false;
- if (!asn1_read_LDAPString(data, mem_ctx, s)) return false;
- return asn1_end_tag(data);
-}
-
-
-/* read a octet string blob */
-bool asn1_read_OctetString(struct asn1_data *data, TALLOC_CTX *mem_ctx, DATA_BLOB *blob)
-{
- int len;
- ZERO_STRUCTP(blob);
- if (!asn1_start_tag(data, ASN1_OCTET_STRING)) return false;
- len = asn1_tag_remaining(data);
- if (len < 0) {
- data->has_error = true;
- return false;
- }
- *blob = data_blob_talloc(mem_ctx, NULL, len+1);
- if (!blob->data) {
- data->has_error = true;
- return false;
- }
- asn1_read(data, blob->data, len);
- asn1_end_tag(data);
- blob->length--;
- blob->data[len] = 0;
-
- if (data->has_error) {
- data_blob_free(blob);
- *blob = data_blob(NULL, 0);
- return false;
- }
- return true;
-}
-
-bool asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob)
-{
- int len;
- ZERO_STRUCTP(blob);
- if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(num))) return false;
- len = asn1_tag_remaining(data);
- if (len < 0) {
- data->has_error = true;
- return false;
- }
- *blob = data_blob(NULL, len);
- if ((len != 0) && (!blob->data)) {
- data->has_error = true;
- return false;
- }
- asn1_read(data, blob->data, len);
- asn1_end_tag(data);
- return !data->has_error;
-}
-
-/* read an integer without tag*/
-bool asn1_read_implicit_Integer(struct asn1_data *data, int *i)
-{
- uint8_t b;
- *i = 0;
-
- while (!data->has_error && asn1_tag_remaining(data)>0) {
- if (!asn1_read_uint8(data, &b)) return false;
- *i = (*i << 8) + b;
- }
- return !data->has_error;
-
-}
-
-/* read an integer */
-bool asn1_read_Integer(struct asn1_data *data, int *i)
-{
- *i = 0;
-
- if (!asn1_start_tag(data, ASN1_INTEGER)) return false;
- if (!asn1_read_implicit_Integer(data, i)) return false;
- return asn1_end_tag(data);
-}
-
-/* read an integer */
-bool asn1_read_enumerated(struct asn1_data *data, int *v)
-{
- *v = 0;
-
- if (!asn1_start_tag(data, ASN1_ENUMERATED)) return false;
- while (!data->has_error && asn1_tag_remaining(data)>0) {
- uint8_t b;
- asn1_read_uint8(data, &b);
- *v = (*v << 8) + b;
- }
- return asn1_end_tag(data);
-}
-
-/* check a enumerated value is correct */
-bool asn1_check_enumerated(struct asn1_data *data, int v)
-{
- uint8_t b;
- if (!asn1_start_tag(data, ASN1_ENUMERATED)) return false;
- asn1_read_uint8(data, &b);
- asn1_end_tag(data);
-
- if (v != b)
- data->has_error = false;
-
- return !data->has_error;
-}
-
-/* write an enumerated value to the stream */
-bool asn1_write_enumerated(struct asn1_data *data, uint8_t v)
-{
- if (!asn1_push_tag(data, ASN1_ENUMERATED)) return false;
- asn1_write_uint8(data, v);
- asn1_pop_tag(data);
- return !data->has_error;
-}
-
-/*
- check if a ASN.1 blob is a full tag
-*/
-NTSTATUS asn1_full_tag(DATA_BLOB blob, uint8_t tag, size_t *packet_size)
-{
- struct asn1_data *asn1 = asn1_init(NULL);
- int size;
-
- NT_STATUS_HAVE_NO_MEMORY(asn1);
-
- asn1->data = blob.data;
- asn1->length = blob.length;
- asn1_start_tag(asn1, tag);
- if (asn1->has_error) {
- talloc_free(asn1);
- return STATUS_MORE_ENTRIES;
- }
- size = asn1_tag_remaining(asn1) + asn1->ofs;
-
- talloc_free(asn1);
-
- if (size > blob.length) {
- return STATUS_MORE_ENTRIES;
- }
-
- *packet_size = size;
- return NT_STATUS_OK;
-}
diff --git a/source4/lib/util/asn1.h b/source4/lib/util/asn1.h
deleted file mode 100644
index 34aa1e2cb9..0000000000
--- a/source4/lib/util/asn1.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- simple ASN1 code
- 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/>.
-*/
-
-#ifndef _ASN_1_H
-#define _ASN_1_H
-
-struct nesting {
- off_t start;
- size_t taglen; /* for parsing */
- struct nesting *next;
-};
-
-struct asn1_data {
- uint8_t *data;
- size_t length;
- off_t ofs;
- struct nesting *nesting;
- bool has_error;
-};
-
-#define ASN1_APPLICATION(x) ((x)+0x60)
-#define ASN1_APPLICATION_SIMPLE(x) ((x)+0x40)
-#define ASN1_SEQUENCE(x) ((x)+0x30)
-#define ASN1_CONTEXT(x) ((x)+0xa0)
-#define ASN1_CONTEXT_SIMPLE(x) ((x)+0x80)
-#define ASN1_GENERAL_STRING 0x1b
-#define ASN1_OCTET_STRING 0x4
-#define ASN1_OID 0x6
-#define ASN1_BOOLEAN 0x1
-#define ASN1_INTEGER 0x2
-#define ASN1_ENUMERATED 0xa
-#define ASN1_SET 0x31
-
-#define ASN1_MAX_OIDS 20
-
-#include "lib/util/asn1_proto.h"
-
-#endif /* _ASN_1_H */
diff --git a/source4/lib/util/attr.h b/source4/lib/util/attr.h
deleted file mode 100644
index f64b272a67..0000000000
--- a/source4/lib/util/attr.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba utility functions
- 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/>.
-*/
-
-#ifndef __UTIL_ATTR_H__
-#define __UTIL_ATTR_H__
-
-#ifdef __GNUC__
-/** gcc attribute used on function parameters so that it does not emit
- * warnings about them being unused. **/
-# define UNUSED(param) param __attribute__ ((unused))
-#else
-# define UNUSED(param) param
-/** Feel free to add definitions for other compilers here. */
-#endif
-
-#ifdef HAVE_VISIBILITY_ATTR
-# define _PUBLIC_ __attribute__((visibility("default")))
-#else
-# define _PUBLIC_
-#endif
-
-#ifndef _DEPRECATED_
-#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
-#define _DEPRECATED_ __attribute__ ((deprecated))
-#else
-#define _DEPRECATED_
-#endif
-#endif
-
-#ifndef _WARN_UNUSED_RESULT_
-#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
-#define _WARN_UNUSED_RESULT_ __attribute__ ((warn_unused_result))
-#else
-#define _WARN_UNUSED_RESULT_
-#endif
-#endif
-
-#ifndef _NORETURN_
-#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
-#define _NORETURN_ __attribute__ ((noreturn))
-#else
-#define _NORETURN_
-#endif
-#endif
-
-#ifndef _PURE_
-#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1)
-#define _PURE_ __attribute__((pure))
-#else
-#define _PURE_
-#endif
-#endif
-
-#ifndef NONNULL
-#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1)
-#define NONNULL(param) param __attribute__((nonnull))
-#else
-#define NONNULL(param) param
-#endif
-#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
-
-#endif /* __UTIL_ATTR_H__ */
diff --git a/source4/lib/util/become_daemon.c b/source4/lib/util/become_daemon.c
deleted file mode 100644
index 034114eade..0000000000
--- a/source4/lib/util/become_daemon.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba utility functions
- Copyright (C) Andrew Tridgell 1992-1998
- Copyright (C) Jeremy Allison 2001-2002
- Copyright (C) Simo Sorce 2001
- Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
- Copyright (C) James J Myers 2003
-
- 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/filesys.h"
-#include "system/locale.h"
-
-/*******************************************************************
- Close the low 3 fd's and open dev/null in their place.
-********************************************************************/
-static void close_low_fds(bool stderr_too)
-{
-#ifndef VALGRIND
- int fd;
- int i;
-
- close(0);
- close(1);
-
- if (stderr_too)
- close(2);
-
- /* try and use up these file descriptors, so silly
- library routines writing to stdout etc won't cause havoc */
- for (i=0;i<3;i++) {
- if (i == 2 && !stderr_too)
- continue;
-
- fd = open("/dev/null",O_RDWR,0);
- if (fd < 0)
- fd = open("/dev/null",O_WRONLY,0);
- if (fd < 0) {
- DEBUG(0,("Can't open /dev/null\n"));
- return;
- }
- if (fd != i) {
- DEBUG(0,("Didn't get file descriptor %d\n",i));
- return;
- }
- }
-#endif
-}
-
-/**
- Become a daemon, discarding the controlling terminal.
-**/
-
-_PUBLIC_ void become_daemon(bool Fork)
-{
- if (Fork) {
- if (fork()) {
- _exit(0);
- }
- }
-
- /* detach from the terminal */
-#ifdef HAVE_SETSID
- setsid();
-#elif defined(TIOCNOTTY)
- {
- int i = open("/dev/tty", O_RDWR, 0);
- if (i != -1) {
- ioctl(i, (int) TIOCNOTTY, (char *)0);
- close(i);
- }
- }
-#endif /* HAVE_SETSID */
-
- /* Close fd's 0,1,2. Needed if started by rsh */
- close_low_fds(false); /* Don't close stderr, let the debug system
- attach it to the logfile */
-}
-
diff --git a/source4/lib/util/byteorder.h b/source4/lib/util/byteorder.h
deleted file mode 100644
index 894beccabf..0000000000
--- a/source4/lib/util/byteorder.h
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- SMB Byte handling
- Copyright (C) Andrew Tridgell 1992-1998
-
- 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 _BYTEORDER_H
-#define _BYTEORDER_H
-
-/*
- This file implements macros for machine independent short and
- int manipulation
-
-Here is a description of this file that I emailed to the samba list once:
-
-> I am confused about the way that byteorder.h works in Samba. I have
-> looked at it, and I would have thought that you might make a distinction
-> between LE and BE machines, but you only seem to distinguish between 386
-> and all other architectures.
->
-> Can you give me a clue?
-
-sure.
-
-The distinction between 386 and other architectures is only there as
-an optimisation. You can take it out completely and it will make no
-difference. The routines (macros) in byteorder.h are totally byteorder
-independent. The 386 optimsation just takes advantage of the fact that
-the x86 processors don't care about alignment, so we don't have to
-align ints on int boundaries etc. If there are other processors out
-there that aren't alignment sensitive then you could also define
-CAREFUL_ALIGNMENT=0 on those processors as well.
-
-Ok, now to the macros themselves. I'll take a simple example, say we
-want to extract a 2 byte integer from a SMB packet and put it into a
-type called uint16_t that is in the local machines byte order, and you
-want to do it with only the assumption that uint16_t is _at_least_ 16
-bits long (this last condition is very important for architectures
-that don't have any int types that are 2 bytes long)
-
-You do this:
-
-#define CVAL(buf,pos) (((uint8_t *)(buf))[pos])
-#define PVAL(buf,pos) ((uint_t)CVAL(buf,pos))
-#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
-
-then to extract a uint16_t value at offset 25 in a buffer you do this:
-
-char *buffer = foo_bar();
-uint16_t xx = SVAL(buffer,25);
-
-We are using the byteoder independence of the ANSI C bitshifts to do
-the work. A good optimising compiler should turn this into efficient
-code, especially if it happens to have the right byteorder :-)
-
-I know these macros can be made a bit tidier by removing some of the
-casts, but you need to look at byteorder.h as a whole to see the
-reasoning behind them. byteorder.h defines the following macros:
-
-SVAL(buf,pos) - extract a 2 byte SMB value
-IVAL(buf,pos) - extract a 4 byte SMB value
-BVAL(buf,pos) - extract a 8 byte SMB value
-SVALS(buf,pos) - signed version of SVAL()
-IVALS(buf,pos) - signed version of IVAL()
-BVALS(buf,pos) - signed version of BVAL()
-
-SSVAL(buf,pos,val) - put a 2 byte SMB value into a buffer
-SIVAL(buf,pos,val) - put a 4 byte SMB value into a buffer
-SBVAL(buf,pos,val) - put a 8 byte SMB value into a buffer
-SSVALS(buf,pos,val) - signed version of SSVAL()
-SIVALS(buf,pos,val) - signed version of SIVAL()
-SBVALS(buf,pos,val) - signed version of SBVAL()
-
-RSVAL(buf,pos) - like SVAL() but for NMB byte ordering
-RSVALS(buf,pos) - like SVALS() but for NMB byte ordering
-RIVAL(buf,pos) - like IVAL() but for NMB byte ordering
-RIVALS(buf,pos) - like IVALS() but for NMB byte ordering
-RSSVAL(buf,pos,val) - like SSVAL() but for NMB ordering
-RSIVAL(buf,pos,val) - like SIVAL() but for NMB ordering
-RSIVALS(buf,pos,val) - like SIVALS() but for NMB ordering
-
-it also defines lots of intermediate macros, just ignore those :-)
-
-*/
-
-
-/*
- on powerpc we can use the magic instructions to load/store
- in little endian
-*/
-#if (defined(__powerpc__) && defined(__GNUC__))
-static __inline__ uint16_t ld_le16(const uint16_t *addr)
-{
- uint16_t val;
- __asm__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
- return val;
-}
-
-static __inline__ void st_le16(uint16_t *addr, const uint16_t val)
-{
- __asm__ ("sthbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
-}
-
-static __inline__ uint32_t ld_le32(const uint32_t *addr)
-{
- uint32_t val;
- __asm__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
- return val;
-}
-
-static __inline__ void st_le32(uint32_t *addr, const uint32_t val)
-{
- __asm__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
-}
-#define HAVE_ASM_BYTEORDER 1
-#else
-#define HAVE_ASM_BYTEORDER 0
-#endif
-
-
-
-#undef CAREFUL_ALIGNMENT
-
-/* we know that the 386 can handle misalignment and has the "right"
- byteorder */
-#if defined(__i386__)
-#define CAREFUL_ALIGNMENT 0
-#endif
-
-#ifndef CAREFUL_ALIGNMENT
-#define CAREFUL_ALIGNMENT 1
-#endif
-
-#define CVAL(buf,pos) ((uint_t)(((const uint8_t *)(buf))[pos]))
-#define CVAL_NC(buf,pos) (((uint8_t *)(buf))[pos]) /* Non-const version of CVAL */
-#define PVAL(buf,pos) (CVAL(buf,pos))
-#define SCVAL(buf,pos,val) (CVAL_NC(buf,pos) = (val))
-
-#if HAVE_ASM_BYTEORDER
-
-#define _PTRPOS(buf,pos) (((const uint8_t *)buf)+(pos))
-#define SVAL(buf,pos) ld_le16((const uint16_t *)_PTRPOS(buf,pos))
-#define IVAL(buf,pos) ld_le32((const uint32_t *)_PTRPOS(buf,pos))
-#define SSVAL(buf,pos,val) st_le16((uint16_t *)_PTRPOS(buf,pos), val)
-#define SIVAL(buf,pos,val) st_le32((uint32_t *)_PTRPOS(buf,pos), val)
-#define SVALS(buf,pos) ((int16_t)SVAL(buf,pos))
-#define IVALS(buf,pos) ((int32_t)IVAL(buf,pos))
-#define SSVALS(buf,pos,val) SSVAL((buf),(pos),((int16_t)(val)))
-#define SIVALS(buf,pos,val) SIVAL((buf),(pos),((int32_t)(val)))
-
-#elif CAREFUL_ALIGNMENT
-
-#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
-#define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)
-#define SSVALX(buf,pos,val) (CVAL_NC(buf,pos)=(uint8_t)((val)&0xFF),CVAL_NC(buf,pos+1)=(uint8_t)((val)>>8))
-#define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
-#define SVALS(buf,pos) ((int16_t)SVAL(buf,pos))
-#define IVALS(buf,pos) ((int32_t)IVAL(buf,pos))
-#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((uint16_t)(val)))
-#define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32_t)(val)))
-#define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16_t)(val)))
-#define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32_t)(val)))
-
-#else /* not CAREFUL_ALIGNMENT */
-
-/* this handles things for architectures like the 386 that can handle
- alignment errors */
-/*
- WARNING: This section is dependent on the length of int16_t and int32_t
- being correct
-*/
-
-/* get single value from an SMB buffer */
-#define SVAL(buf,pos) (*(const uint16_t *)((const char *)(buf) + (pos)))
-#define SVAL_NC(buf,pos) (*(uint16_t *)((char *)(buf) + (pos))) /* Non const version of above. */
-#define IVAL(buf,pos) (*(const uint32_t *)((const char *)(buf) + (pos)))
-#define IVAL_NC(buf,pos) (*(uint32_t *)((char *)(buf) + (pos))) /* Non const version of above. */
-#define SVALS(buf,pos) (*(const int16_t *)((const char *)(buf) + (pos)))
-#define SVALS_NC(buf,pos) (*(int16_t *)((char *)(buf) + (pos))) /* Non const version of above. */
-#define IVALS(buf,pos) (*(const int32_t *)((const char *)(buf) + (pos)))
-#define IVALS_NC(buf,pos) (*(int32_t *)((char *)(buf) + (pos))) /* Non const version of above. */
-
-/* store single value in an SMB buffer */
-#define SSVAL(buf,pos,val) SVAL_NC(buf,pos)=((uint16_t)(val))
-#define SIVAL(buf,pos,val) IVAL_NC(buf,pos)=((uint32_t)(val))
-#define SSVALS(buf,pos,val) SVALS_NC(buf,pos)=((int16_t)(val))
-#define SIVALS(buf,pos,val) IVALS_NC(buf,pos)=((int32_t)(val))
-
-#endif /* not CAREFUL_ALIGNMENT */
-
-/* now the reverse routines - these are used in nmb packets (mostly) */
-#define SREV(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
-#define IREV(x) ((SREV(x)<<16) | (SREV((x)>>16)))
-
-#define RSVAL(buf,pos) SREV(SVAL(buf,pos))
-#define RSVALS(buf,pos) SREV(SVALS(buf,pos))
-#define RIVAL(buf,pos) IREV(IVAL(buf,pos))
-#define RIVALS(buf,pos) IREV(IVALS(buf,pos))
-#define RSSVAL(buf,pos,val) SSVAL(buf,pos,SREV(val))
-#define RSSVALS(buf,pos,val) SSVALS(buf,pos,SREV(val))
-#define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val))
-#define RSIVALS(buf,pos,val) SIVALS(buf,pos,IREV(val))
-
-/* Alignment macros. */
-#define ALIGN4(p,base) ((p) + ((4 - (PTR_DIFF((p), (base)) & 3)) & 3))
-#define ALIGN2(p,base) ((p) + ((2 - (PTR_DIFF((p), (base)) & 1)) & 1))
-
-
-/* macros for accessing SMB protocol elements */
-#define VWV(vwv) ((vwv)*2)
-
-/* 64 bit macros */
-#define BVAL(p, ofs) (IVAL(p,ofs) | (((uint64_t)IVAL(p,(ofs)+4)) << 32))
-#define BVALS(p, ofs) ((int64_t)BVAL(p,ofs))
-#define SBVAL(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,((uint64_t)(v))>>32))
-#define SBVALS(p, ofs, v) (SBVAL(p,ofs,(uint64_t)v))
-
-#endif /* _BYTEORDER_H */
diff --git a/source4/lib/util/capability.c b/source4/lib/util/capability.c
deleted file mode 100644
index 2d13826c14..0000000000
--- a/source4/lib/util/capability.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Copyright (C) Andrew Tridgell 1992-1998
- Copyright (C) Jeremy Allison 1998-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/>.
-*/
-
-/**
- * @file
- * @brief Capabilities functions
- **/
-
-/*
- capabilities fns - will be needed when we enable kernel oplocks
-*/
-
-#include "includes.h"
-#include "system/network.h"
-#include "system/wait.h"
-#include "system/filesys.h"
-
-
-#if defined(HAVE_IRIX_SPECIFIC_CAPABILITIES)
-/**************************************************************************
- Try and abstract process capabilities (for systems that have them).
-****************************************************************************/
-static bool set_process_capability( uint32_t cap_flag, bool enable )
-{
- if(cap_flag == KERNEL_OPLOCK_CAPABILITY) {
- cap_t cap = cap_get_proc();
-
- if (cap == NULL) {
- DEBUG(0,("set_process_capability: cap_get_proc failed. Error was %s\n",
- strerror(errno)));
- return false;
- }
-
- if(enable)
- cap->cap_effective |= CAP_NETWORK_MGT;
- else
- cap->cap_effective &= ~CAP_NETWORK_MGT;
-
- if (cap_set_proc(cap) == -1) {
- DEBUG(0,("set_process_capability: cap_set_proc failed. Error was %s\n",
- strerror(errno)));
- cap_free(cap);
- return false;
- }
-
- cap_free(cap);
-
- DEBUG(10,("set_process_capability: Set KERNEL_OPLOCK_CAPABILITY.\n"));
- }
- return true;
-}
-
-/**************************************************************************
- Try and abstract inherited process capabilities (for systems that have them).
-****************************************************************************/
-
-static bool set_inherited_process_capability( uint32_t cap_flag, bool enable )
-{
- if(cap_flag == KERNEL_OPLOCK_CAPABILITY) {
- cap_t cap = cap_get_proc();
-
- if (cap == NULL) {
- DEBUG(0,("set_inherited_process_capability: cap_get_proc failed. Error was %s\n",
- strerror(errno)));
- return false;
- }
-
- if(enable)
- cap->cap_inheritable |= CAP_NETWORK_MGT;
- else
- cap->cap_inheritable &= ~CAP_NETWORK_MGT;
-
- if (cap_set_proc(cap) == -1) {
- DEBUG(0,("set_inherited_process_capability: cap_set_proc failed. Error was %s\n",
- strerror(errno)));
- cap_free(cap);
- return false;
- }
-
- cap_free(cap);
-
- DEBUG(10,("set_inherited_process_capability: Set KERNEL_OPLOCK_CAPABILITY.\n"));
- }
- return true;
-}
-#endif
diff --git a/source4/lib/util/capability.m4 b/source4/lib/util/capability.m4
deleted file mode 100644
index 2a95a607d5..0000000000
--- a/source4/lib/util/capability.m4
+++ /dev/null
@@ -1,17 +0,0 @@
-AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
-AC_TRY_RUN([#include <sys/types.h>
-#include <sys/capability.h>
-main() {
- cap_t cap;
- if ((cap = cap_get_proc()) == NULL)
- exit(1);
- cap->cap_effective |= CAP_NETWORK_MGT;
- cap->cap_inheritable |= CAP_NETWORK_MGT;
- cap_set_proc(cap);
- exit(0);
-}
-],
-samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
-if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
- AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES,1,[Whether IRIX specific capabilities are available])
-fi
diff --git a/source4/lib/util/config.mk b/source4/lib/util/config.mk
deleted file mode 100644
index 925713a53c..0000000000
--- a/source4/lib/util/config.mk
+++ /dev/null
@@ -1,71 +0,0 @@
-[SUBSYSTEM::LIBSAMBA-UTIL]
-PUBLIC_DEPENDENCIES = \
- LIBTALLOC LIBCRYPTO \
- SOCKET_WRAPPER LIBREPLACE_NETWORK \
- CHARSET EXECINFO
-
-LIBSAMBA-UTIL_OBJ_FILES = $(addprefix $(libutilsrcdir)/, \
- xfile.o \
- debug.o \
- fault.o \
- signal.o \
- system.o \
- time.o \
- genrand.o \
- dprintf.o \
- util_str.o \
- util_strlist.o \
- util_file.o \
- data_blob.o \
- util.o \
- fsusage.o \
- ms_fnmatch.o \
- mutex.o \
- idtree.o \
- become_daemon.o \
- params.o)
-
-PUBLIC_HEADERS += $(addprefix $(libutilsrcdir)/, util.h \
- attr.h \
- byteorder.h \
- data_blob.h \
- debug.h \
- mutex.h \
- safe_string.h \
- time.h \
- util_ldb.h \
- xfile.h)
-
-[SUBSYSTEM::ASN1_UTIL]
-
-ASN1_UTIL_OBJ_FILES = $(libutilsrcdir)/asn1.o
-
-$(eval $(call proto_header_template,$(libutilsrcdir)/asn1_proto.h,$(ASN1_UTIL_OBJ_FILES:.o=.c)))
-
-[SUBSYSTEM::UNIX_PRIVS]
-
-UNIX_PRIVS_OBJ_FILES = $(libutilsrcdir)/unix_privs.o
-
-$(eval $(call proto_header_template,$(libutilsrcdir)/unix_privs.h,$(UNIX_PRIVS_OBJ_FILES:.o=.c)))
-
-################################################
-# Start SUBSYSTEM WRAP_XATTR
-[SUBSYSTEM::WRAP_XATTR]
-PUBLIC_DEPENDENCIES = XATTR
-#
-# End SUBSYSTEM WRAP_XATTR
-################################################
-
-WRAP_XATTR_OBJ_FILES = $(libutilsrcdir)/wrap_xattr.o
-
-[SUBSYSTEM::UTIL_TDB]
-PUBLIC_DEPENDENCIES = LIBTDB
-
-UTIL_TDB_OBJ_FILES = $(libutilsrcdir)/util_tdb.o
-
-$(eval $(call proto_header_template,$(libutilsrcdir)/util_tdb.h,$(UTIL_TDB_OBJ_FILES:.o=.c)))
-
-[SUBSYSTEM::UTIL_LDB]
-PUBLIC_DEPENDENCIES = LIBLDB
-
-UTIL_LDB_OBJ_FILES = $(libutilsrcdir)/util_ldb.o
diff --git a/source4/lib/util/data_blob.c b/source4/lib/util/data_blob.c
deleted file mode 100644
index 57b34b7ae7..0000000000
--- a/source4/lib/util/data_blob.c
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Easy management of byte-length data
- Copyright (C) Andrew Tridgell 2001
- Copyright (C) Andrew Bartlett 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 "includes.h"
-
-/**
- * @file
- * @brief Manipulation of arbitrary data blobs
- **/
-
-/**
- construct a data blob, must be freed with data_blob_free()
- you can pass NULL for p and get a blank data blob
-**/
-_PUBLIC_ DATA_BLOB data_blob_named(const void *p, size_t length, const char *name)
-{
- DATA_BLOB ret;
-
- if (p == NULL && length == 0) {
- ZERO_STRUCT(ret);
- return ret;
- }
-
- if (p) {
- ret.data = (uint8_t *)talloc_memdup(NULL, p, length);
- } else {
- ret.data = talloc_array(NULL, uint8_t, length);
- }
- if (ret.data == NULL) {
- ret.length = 0;
- return ret;
- }
- talloc_set_name_const(ret.data, name);
- ret.length = length;
- return ret;
-}
-
-/**
- construct a data blob, using supplied TALLOC_CTX
-**/
-_PUBLIC_ DATA_BLOB data_blob_talloc_named(TALLOC_CTX *mem_ctx, const void *p, size_t length, const char *name)
-{
- DATA_BLOB ret = data_blob_named(p, length, name);
-
- if (ret.data) {
- talloc_steal(mem_ctx, ret.data);
- }
- return ret;
-}
-
-
-/**
- reference a data blob, to the supplied TALLOC_CTX.
- Returns a NULL DATA_BLOB on failure
-**/
-_PUBLIC_ DATA_BLOB data_blob_talloc_reference(TALLOC_CTX *mem_ctx, DATA_BLOB *blob)
-{
- DATA_BLOB ret = *blob;
-
- ret.data = talloc_reference(mem_ctx, blob->data);
-
- if (!ret.data) {
- return data_blob(NULL, 0);
- }
- return ret;
-}
-
-/**
- construct a zero data blob, using supplied TALLOC_CTX.
- use this sparingly as it initialises data - better to initialise
- yourself if you want specific data in the blob
-**/
-_PUBLIC_ DATA_BLOB data_blob_talloc_zero(TALLOC_CTX *mem_ctx, size_t length)
-{
- DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, length);
- data_blob_clear(&blob);
- return blob;
-}
-
-/**
-free a data blob
-**/
-_PUBLIC_ void data_blob_free(DATA_BLOB *d)
-{
- if (d) {
- talloc_free(d->data);
- d->data = NULL;
- d->length = 0;
- }
-}
-
-/**
-clear a DATA_BLOB's contents
-**/
-_PUBLIC_ void data_blob_clear(DATA_BLOB *d)
-{
- if (d->data) {
- memset(d->data, 0, d->length);
- }
-}
-
-/**
-free a data blob and clear its contents
-**/
-_PUBLIC_ void data_blob_clear_free(DATA_BLOB *d)
-{
- data_blob_clear(d);
- data_blob_free(d);
-}
-
-
-/**
-check if two data blobs are equal
-**/
-_PUBLIC_ int data_blob_cmp(const DATA_BLOB *d1, const DATA_BLOB *d2)
-{
- int ret;
- if (d1->data == NULL && d2->data != NULL) {
- return -1;
- }
- if (d1->data != NULL && d2->data == NULL) {
- return 1;
- }
- if (d1->data == d2->data) {
- return d1->length - d2->length;
- }
- ret = memcmp(d1->data, d2->data, MIN(d1->length, d2->length));
- if (ret == 0) {
- return d1->length - d2->length;
- }
- return ret;
-}
-
-/**
-print the data_blob as hex string
-**/
-_PUBLIC_ char *data_blob_hex_string(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob)
-{
- int i;
- char *hex_string;
-
- hex_string = talloc_array(mem_ctx, char, (blob->length*2)+1);
- if (!hex_string) {
- return NULL;
- }
-
- for (i = 0; i < blob->length; i++)
- slprintf(&hex_string[i*2], 3, "%02X", blob->data[i]);
-
- hex_string[(blob->length*2)] = '\0';
- return hex_string;
-}
-
-/**
- useful for constructing data blobs in test suites, while
- avoiding const warnings
-**/
-_PUBLIC_ DATA_BLOB data_blob_string_const(const char *str)
-{
- DATA_BLOB blob;
- blob.data = discard_const_p(uint8_t, str);
- blob.length = str ? strlen(str) : 0;
- return blob;
-}
-
-/**
- * Create a new data blob from const data
- */
-
-_PUBLIC_ DATA_BLOB data_blob_const(const void *p, size_t length)
-{
- DATA_BLOB blob;
- blob.data = discard_const_p(uint8_t, p);
- blob.length = length;
- return blob;
-}
-
-
-/**
- realloc a data_blob
-**/
-_PUBLIC_ bool data_blob_realloc(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, size_t length)
-{
- blob->data = talloc_realloc(mem_ctx, blob->data, uint8_t, length);
- if (blob->data == NULL)
- return false;
- blob->length = length;
- return true;
-}
-
-
-/**
- append some data to a data blob
-**/
-_PUBLIC_ bool data_blob_append(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
- const void *p, size_t length)
-{
- size_t old_len = blob->length;
- size_t new_len = old_len + length;
- if (new_len < length || new_len < old_len) {
- return false;
- }
-
- if ((const uint8_t *)p + length < (const uint8_t *)p) {
- return false;
- }
-
- if (!data_blob_realloc(mem_ctx, blob, new_len)) {
- return false;
- }
-
- memcpy(blob->data + old_len, p, length);
- return true;
-}
-
diff --git a/source4/lib/util/data_blob.h b/source4/lib/util/data_blob.h
deleted file mode 100644
index e9dca67772..0000000000
--- a/source4/lib/util/data_blob.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- DATA BLOB
-
- 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 is a public header file that is installed as part of Samba.
- * If you remove any functions or change their signature, update
- * the so version number. */
-
-#ifndef _SAMBA_DATABLOB_H_
-#define _SAMBA_DATABLOB_H_
-
-#ifndef _PUBLIC_
-#define _PUBLIC_
-#endif
-
-#include <talloc.h>
-#include <stdint.h>
-
-/* used to hold an arbitrary blob of data */
-typedef struct datablob {
- uint8_t *data;
- size_t length;
-} DATA_BLOB;
-
-struct data_blob_list_item {
- struct data_blob_list_item *prev,*next;
- DATA_BLOB blob;
-};
-
-/* by making struct ldb_val and DATA_BLOB the same, we can simplify
- a fair bit of code */
-#define ldb_val datablob
-
-#define data_blob(ptr, size) data_blob_named(ptr, size, "DATA_BLOB: "__location__)
-#define data_blob_talloc(ctx, ptr, size) data_blob_talloc_named(ctx, ptr, size, "DATA_BLOB: "__location__)
-#define data_blob_dup_talloc(ctx, blob) data_blob_talloc_named(ctx, (blob)->data, (blob)->length, "DATA_BLOB: "__location__)
-
-/**
- construct a data blob, must be freed with data_blob_free()
- you can pass NULL for p and get a blank data blob
-**/
-_PUBLIC_ DATA_BLOB data_blob_named(const void *p, size_t length, const char *name);
-
-/**
- construct a data blob, using supplied TALLOC_CTX
-**/
-_PUBLIC_ DATA_BLOB data_blob_talloc_named(TALLOC_CTX *mem_ctx, const void *p, size_t length, const char *name);
-
-/**
- reference a data blob, to the supplied TALLOC_CTX.
- Returns a NULL DATA_BLOB on failure
-**/
-_PUBLIC_ DATA_BLOB data_blob_talloc_reference(TALLOC_CTX *mem_ctx, DATA_BLOB *blob);
-
-/**
- construct a zero data blob, using supplied TALLOC_CTX.
- use this sparingly as it initialises data - better to initialise
- yourself if you want specific data in the blob
-**/
-_PUBLIC_ DATA_BLOB data_blob_talloc_zero(TALLOC_CTX *mem_ctx, size_t length);
-
-/**
-free a data blob
-**/
-_PUBLIC_ void data_blob_free(DATA_BLOB *d);
-
-/**
-clear a DATA_BLOB's contents
-**/
-_PUBLIC_ void data_blob_clear(DATA_BLOB *d);
-
-/**
-free a data blob and clear its contents
-**/
-_PUBLIC_ void data_blob_clear_free(DATA_BLOB *d);
-
-/**
-check if two data blobs are equal
-**/
-_PUBLIC_ int data_blob_cmp(const DATA_BLOB *d1, const DATA_BLOB *d2);
-
-/**
-print the data_blob as hex string
-**/
-_PUBLIC_ char *data_blob_hex_string(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob);
-
-/**
- useful for constructing data blobs in test suites, while
- avoiding const warnings
-**/
-_PUBLIC_ DATA_BLOB data_blob_string_const(const char *str);
-
-/**
- * Create a new data blob from const data
- */
-_PUBLIC_ DATA_BLOB data_blob_const(const void *p, size_t length);
-
-/**
- realloc a data_blob
-**/
-_PUBLIC_ bool data_blob_realloc(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, size_t length);
-
-/**
- append some data to a data blob
-**/
-_PUBLIC_ bool data_blob_append(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
- const void *p, size_t length);
-
-#endif /* _SAMBA_DATABLOB_H_ */
diff --git a/source4/lib/util/debug.c b/source4/lib/util/debug.c
deleted file mode 100644
index 00dcbfc8bd..0000000000
--- a/source4/lib/util/debug.c
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba debug functions
- Copyright (C) Andrew Tridgell 2003
- Copyright (C) James J Myers 2003
-
- 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/filesys.h"
-#include "system/time.h"
-#include "dynconfig/dynconfig.h"
-
-/**
- * @file
- * @brief Debug logging
- **/
-
-/**
- * this global variable determines what messages are printed
- */
-_PUBLIC_ int DEBUGLEVEL;
-
-/* the registered mutex handlers */
-static struct {
- const char *name;
- struct debug_ops ops;
-} debug_handlers;
-
-/* state variables for the debug system */
-static struct {
- int fd;
- enum debug_logtype logtype;
- const char *prog_name;
-} state;
-
-static bool reopen_logs_scheduled;
-static bool check_reopen_logs(void)
-{
- if (state.fd == 0 || reopen_logs_scheduled) {
- reopen_logs_scheduled = false;
- reopen_logs();
- }
-
- if (state.fd <= 0)
- return false;
-
- return true;
-}
-
-_PUBLIC_ void debug_schedule_reopen_logs(void)
-{
- reopen_logs_scheduled = true;
-}
-
-static void log_timestring(int level, const char *location, const char *func)
-{
- char *t = NULL;
- char *s = NULL;
-
- if (!check_reopen_logs()) return;
-
- if (state.logtype != DEBUG_FILE) return;
-
- t = timestring(NULL, time(NULL));
- if (!t) return;
-
- asprintf(&s, "[%s, %d %s:%s()]\n", t, level, location, func);
- talloc_free(t);
- if (!s) return;
-
- write(state.fd, s, strlen(s));
- free(s);
-}
-
-/**
- the backend for debug messages. Note that the DEBUG() macro has already
- ensured that the log level has been met before this is called
-*/
-_PUBLIC_ void do_debug_header(int level, const char *location, const char *func)
-{
- log_timestring(level, location, func);
- log_task_id();
-}
-
-/**
- the backend for debug messages. Note that the DEBUG() macro has already
- ensured that the log level has been met before this is called
-
- @note You should never have to call this function directly. Call the DEBUG()
- macro instead.
-*/
-_PUBLIC_ void do_debug(const char *format, ...)
-{
- va_list ap;
- char *s = NULL;
-
- if (!check_reopen_logs()) return;
-
- va_start(ap, format);
- vasprintf(&s, format, ap);
- va_end(ap);
-
- write(state.fd, s, strlen(s));
- free(s);
-}
-
-_PUBLIC_ const char *logfile = NULL;
-
-/**
- reopen the log file (usually called because the log file name might have changed)
-*/
-_PUBLIC_ void reopen_logs(void)
-{
- char *fname = NULL;
- int old_fd = state.fd;
-
- switch (state.logtype) {
- case DEBUG_STDOUT:
- state.fd = 1;
- break;
-
- case DEBUG_STDERR:
- state.fd = 2;
- break;
-
- case DEBUG_FILE:
- if (logfile && (*logfile) == '/') {
- fname = strdup(logfile);
- } else {
- asprintf(&fname, "%s/%s.log", dyn_LOGFILEBASE, state.prog_name);
- }
- if (fname) {
- int newfd = open(fname, O_CREAT|O_APPEND|O_WRONLY, 0600);
- if (newfd == -1) {
- DEBUG(1, ("Failed to open new logfile: %s\n", fname));
- old_fd = -1;
- } else {
- state.fd = newfd;
- }
- free(fname);
- } else {
- DEBUG(1, ("Failed to find name for file-based logfile!\n"));
- }
-
- break;
- }
-
- if (old_fd > 2) {
- close(old_fd);
- }
-}
-
-/**
- control the name of the logfile and whether logging will be to stdout, stderr
- or a file
-*/
-_PUBLIC_ void setup_logging(const char *prog_name, enum debug_logtype new_logtype)
-{
- if (state.logtype < new_logtype) {
- state.logtype = new_logtype;
- }
- if (prog_name) {
- state.prog_name = prog_name;
- }
- reopen_logs();
-}
-
-/**
- return a string constant containing n tabs
- no more than 10 tabs are returned
-*/
-_PUBLIC_ const char *do_debug_tab(int n)
-{
- const char *tabs[] = {"", "\t", "\t\t", "\t\t\t", "\t\t\t\t", "\t\t\t\t\t",
- "\t\t\t\t\t\t", "\t\t\t\t\t\t\t", "\t\t\t\t\t\t\t\t",
- "\t\t\t\t\t\t\t\t\t", "\t\t\t\t\t\t\t\t\t\t"};
- return tabs[MIN(n, 10)];
-}
-
-
-/**
- log suspicious usage - print comments and backtrace
-*/
-_PUBLIC_ void log_suspicious_usage(const char *from, const char *info)
-{
- if (!debug_handlers.ops.log_suspicious_usage) return;
-
- debug_handlers.ops.log_suspicious_usage(from, info);
-}
-
-
-/**
- print suspicious usage - print comments and backtrace
-*/
-_PUBLIC_ void print_suspicious_usage(const char* from, const char* info)
-{
- if (!debug_handlers.ops.print_suspicious_usage) return;
-
- debug_handlers.ops.print_suspicious_usage(from, info);
-}
-
-_PUBLIC_ uint32_t get_task_id(void)
-{
- if (debug_handlers.ops.get_task_id) {
- return debug_handlers.ops.get_task_id();
- }
- return getpid();
-}
-
-_PUBLIC_ void log_task_id(void)
-{
- if (!debug_handlers.ops.log_task_id) return;
-
- if (!check_reopen_logs()) return;
-
- debug_handlers.ops.log_task_id(state.fd);
-}
-
-/**
- register a set of debug handlers.
-*/
-_PUBLIC_ void register_debug_handlers(const char *name, struct debug_ops *ops)
-{
- debug_handlers.name = name;
- debug_handlers.ops = *ops;
-}
diff --git a/source4/lib/util/debug.h b/source4/lib/util/debug.h
deleted file mode 100644
index 605628174a..0000000000
--- a/source4/lib/util/debug.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba debug defines
- Copyright (C) Andrew Tridgell 2003
-
- 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/>.
-*/
-
-/**
- * @file
- * @brief Debugging macros
- */
-
-/* the debug operations structure - contains function pointers to
- various debug implementations of each operation */
-struct debug_ops {
- /* function to log (using DEBUG) suspicious usage of data structure */
- void (*log_suspicious_usage)(const char* from, const char* info);
-
- /* function to log (using printf) suspicious usage of data structure.
- * To be used in circumstances when using DEBUG would cause loop. */
- void (*print_suspicious_usage)(const char* from, const char* info);
-
- /* function to return process/thread id */
- uint32_t (*get_task_id)(void);
-
- /* function to log process/thread id */
- void (*log_task_id)(int fd);
-};
-
-extern int DEBUGLEVEL;
-
-#define debug_ctx() (_debug_ctx?_debug_ctx:(_debug_ctx=talloc_new(NULL)))
-
-#define DEBUGLVL(level) ((level) <= DEBUGLEVEL)
-#define _DEBUG(level, body, header) do { \
- if (DEBUGLVL(level)) { \
- void* _debug_ctx=NULL; \
- if (header) { \
- do_debug_header(level, __location__, __FUNCTION__); \
- } \
- do_debug body; \
- talloc_free(_debug_ctx); \
- } \
-} while (0)
-/**
- * Write to the debug log.
- */
-#define DEBUG(level, body) _DEBUG(level, body, true)
-/**
- * Add data to an existing debug log entry.
- */
-#define DEBUGADD(level, body) _DEBUG(level, body, false)
-
-/**
- * Obtain indentation string for the debug log.
- *
- * Level specified by n.
- */
-#define DEBUGTAB(n) do_debug_tab(n)
-
-/** Possible destinations for the debug log */
-enum debug_logtype {DEBUG_STDOUT = 0, DEBUG_FILE = 1, DEBUG_STDERR = 2};
-
-/**
- the backend for debug messages. Note that the DEBUG() macro has already
- ensured that the log level has been met before this is called
-*/
-_PUBLIC_ void do_debug_header(int level, const char *location, const char *func);
-
-/**
- reopen the log file (usually called because the log file name might have changed)
-*/
-_PUBLIC_ void reopen_logs(void);
-
-/**
- * this global variable determines what messages are printed
- */
-_PUBLIC_ void debug_schedule_reopen_logs(void);
-
-/**
- control the name of the logfile and whether logging will be to stdout, stderr
- or a file
-*/
-_PUBLIC_ void setup_logging(const char *prog_name, enum debug_logtype new_logtype);
-
-/**
- return a string constant containing n tabs
- no more than 10 tabs are returned
-*/
-_PUBLIC_ const char *do_debug_tab(int n);
-
-/**
- log suspicious usage - print comments and backtrace
-*/
-_PUBLIC_ void log_suspicious_usage(const char *from, const char *info);
-
-/**
- print suspicious usage - print comments and backtrace
-*/
-_PUBLIC_ void print_suspicious_usage(const char* from, const char* info);
-_PUBLIC_ uint32_t get_task_id(void);
-_PUBLIC_ void log_task_id(void);
-
-/**
- register a set of debug handlers.
-*/
-_PUBLIC_ void register_debug_handlers(const char *name, struct debug_ops *ops);
-
-/**
- the backend for debug messages. Note that the DEBUG() macro has already
- ensured that the log level has been met before this is called
-
- @note You should never have to call this function directly. Call the DEBUG()
- macro instead.
-*/
-_PUBLIC_ void do_debug(const char *format, ...) PRINTF_ATTRIBUTE(1,2);
diff --git a/source4/lib/util/dlinklist.h b/source4/lib/util/dlinklist.h
deleted file mode 100644
index 5624124459..0000000000
--- a/source4/lib/util/dlinklist.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- some simple double linked list macros
- Copyright (C) Andrew Tridgell 1998
-
- 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/>.
-*/
-
-/* To use these macros you must have a structure containing a next and
- prev pointer */
-
-#ifndef _DLINKLIST_H
-#define _DLINKLIST_H
-
-
-/* hook into the front of the list */
-#define DLIST_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 DLIST_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) != (list)) (p)->next = (p)->prev = NULL; \
-} while (0)
-
-/* promote an element to the top of the list */
-#define DLIST_PROMOTE(list, p) \
-do { \
- DLIST_REMOVE(list, p); \
- DLIST_ADD(list, p); \
-} while (0)
-
-/* hook into the end of the list - needs a tmp pointer */
-#define DLIST_ADD_END(list, p, type) \
-do { \
- if (!(list)) { \
- (list) = (p); \
- (p)->next = (p)->prev = NULL; \
- } else { \
- type tmp; \
- for (tmp = (list); tmp->next; tmp = tmp->next) ; \
- tmp->next = (p); \
- (p)->next = NULL; \
- (p)->prev = tmp; \
- } \
-} while (0)
-
-/* insert 'p' after the given element 'el' in a list. If el is NULL then
- this is the same as a DLIST_ADD() */
-#define DLIST_ADD_AFTER(list, p, el) \
-do { \
- if (!(list) || !(el)) { \
- DLIST_ADD(list, p); \
- } else { \
- p->prev = el; \
- p->next = el->next; \
- el->next = p; \
- if (p->next) p->next->prev = p; \
- }\
-} while (0)
-
-/* demote an element to the end of the list, needs a tmp pointer */
-#define DLIST_DEMOTE(list, p, tmp) \
-do { \
- DLIST_REMOVE(list, p); \
- DLIST_ADD_END(list, p, tmp); \
-} while (0)
-
-/* concatenate two lists - putting all elements of the 2nd list at the
- end of the first list */
-#define DLIST_CONCATENATE(list1, list2, type) \
-do { \
- if (!(list1)) { \
- (list1) = (list2); \
- } else { \
- type tmp; \
- for (tmp = (list1); tmp->next; tmp = tmp->next) ; \
- tmp->next = (list2); \
- if (list2) { \
- (list2)->prev = tmp; \
- } \
- } \
-} while (0)
-
-#endif /* _DLINKLIST_H */
diff --git a/source4/lib/util/dprintf.c b/source4/lib/util/dprintf.c
deleted file mode 100644
index e4f02758eb..0000000000
--- a/source4/lib/util/dprintf.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- display print functions
- Copyright (C) Andrew Tridgell 2001
- 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/>.
-*/
-
-
-/*
- this module provides functions for printing internal strings in the
- "display charset".
-
- This charset may be quite different from the chosen unix charset.
-
- Eventually these functions will need to take care of column count constraints
-
- The d_ prefix on print functions in Samba refers to the display character set
- conversion
-*/
-
-#include "includes.h"
-#include "system/locale.h"
-#include "param/param.h"
-
-static smb_iconv_t display_cd = (smb_iconv_t)-1;
-
-void d_set_iconv(smb_iconv_t cd)
-{
- display_cd = cd;
-}
-
-_PUBLIC_ int d_vfprintf(FILE *f, const char *format, va_list ap)
-{
- char *p, *p2;
- int ret, clen;
- va_list ap2;
-
- /* If there's nothing to convert, take a shortcut */
- if (display_cd == (smb_iconv_t)-1) {
- return vfprintf(f, format, ap);
- }
-
- /* do any message translations */
- va_copy(ap2, ap);
- ret = vasprintf(&p, format, ap2);
- va_end(ap2);
-
- if (ret <= 0) return ret;
-
- clen = convert_string_talloc_descriptor(NULL, display_cd, p, ret, (void **)&p2);
- if (clen == -1) {
- /* the string can't be converted - do the best we can,
- filling in non-printing chars with '?' */
- int i;
- for (i=0;i<ret;i++) {
- if (isprint(p[i]) || isspace(p[i])) {
- fwrite(p+i, 1, 1, f);
- } else {
- fwrite("?", 1, 1, f);
- }
- }
- SAFE_FREE(p);
- return ret;
- }
-
- /* good, its converted OK */
- SAFE_FREE(p);
- ret = fwrite(p2, 1, clen, f);
- talloc_free(p2);
-
- return ret;
-}
-
-
-_PUBLIC_ int d_fprintf(FILE *f, const char *format, ...)
-{
- int ret;
- va_list ap;
-
- va_start(ap, format);
- ret = d_vfprintf(f, format, ap);
- va_end(ap);
-
- return ret;
-}
-
-_PUBLIC_ int d_printf(const char *format, ...)
-{
- int ret;
- va_list ap;
-
- va_start(ap, format);
- ret = d_vfprintf(stdout, format, ap);
- va_end(ap);
-
- return ret;
-}
-
diff --git a/source4/lib/util/fault.c b/source4/lib/util/fault.c
deleted file mode 100644
index cb51cbd859..0000000000
--- a/source4/lib/util/fault.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Critical Fault handling
- Copyright (C) Andrew Tridgell 1992-1998
-
- 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 "version.h"
-#include "system/wait.h"
-#include "system/filesys.h"
-
-/**
- * @file
- * @brief Fault handling
- */
-
-/* the registered fault handler */
-static struct {
- const char *name;
- void (*fault_handler)(int sig);
-} fault_handlers;
-
-static const char *progname;
-
-#ifdef HAVE_BACKTRACE
-#include <execinfo.h>
-#elif HAVE_LIBEXC_H
-#include <libexc.h>
-#endif
-
-/**
- * Write backtrace to debug log
- */
-_PUBLIC_ void call_backtrace(void)
-{
-#ifdef HAVE_BACKTRACE
-#ifndef BACKTRACE_STACK_SIZE
-#define BACKTRACE_STACK_SIZE 64
-#endif
- void *backtrace_stack[BACKTRACE_STACK_SIZE];
- size_t backtrace_size;
- char **backtrace_strings;
-
- /* get the backtrace (stack frames) */
- backtrace_size = backtrace(backtrace_stack,BACKTRACE_STACK_SIZE);
- backtrace_strings = backtrace_symbols(backtrace_stack, backtrace_size);
-
- DEBUG(0, ("BACKTRACE: %lu stack frames:\n",
- (unsigned long)backtrace_size));
-
- if (backtrace_strings) {
- int i;
-
- for (i = 0; i < backtrace_size; i++)
- DEBUGADD(0, (" #%u %s\n", i, backtrace_strings[i]));
-
- /* Leak the backtrace_strings, rather than risk what free() might do */
- }
-
-#elif HAVE_LIBEXC
-
-#define NAMESIZE 32 /* Arbitrary */
-#ifndef BACKTRACE_STACK_SIZE
-#define BACKTRACE_STACK_SIZE 64
-#endif
-
- /* The IRIX libexc library provides an API for unwinding the stack. See
- * libexc(3) for details. Apparantly trace_back_stack leaks memory, but
- * since we are about to abort anyway, it hardly matters.
- *
- * Note that if we paniced due to a SIGSEGV or SIGBUS (or similar) this
- * will fail with a nasty message upon failing to open the /proc entry.
- */
- {
- uint64_t addrs[BACKTRACE_STACK_SIZE];
- char * names[BACKTRACE_STACK_SIZE];
- char namebuf[BACKTRACE_STACK_SIZE * NAMESIZE];
-
- int i;
- int levels;
-
- ZERO_ARRAY(addrs);
- ZERO_ARRAY(names);
- ZERO_ARRAY(namebuf);
-
- for (i = 0; i < BACKTRACE_STACK_SIZE; i++) {
- names[i] = namebuf + (i * NAMESIZE);
- }
-
- levels = trace_back_stack(0, addrs, names,
- BACKTRACE_STACK_SIZE, NAMESIZE);
-
- DEBUG(0, ("BACKTRACE: %d stack frames:\n", levels));
- for (i = 0; i < levels; i++) {
- DEBUGADD(0, (" #%d 0x%llx %s\n", i, addrs[i], names[i]));
- }
- }
-#undef NAMESIZE
-#endif
-}
-
-_PUBLIC_ const char *panic_action = NULL;
-
-/**
- Something really nasty happened - panic !
-**/
-_PUBLIC_ _NORETURN_ void smb_panic(const char *why)
-{
- int result;
-
- if (panic_action && *panic_action) {
- char pidstr[20];
- char cmdstring[200];
- safe_strcpy(cmdstring, panic_action, sizeof(cmdstring));
- snprintf(pidstr, sizeof(pidstr), "%u", getpid());
- all_string_sub(cmdstring, "%PID%", pidstr, sizeof(cmdstring));
- if (progname) {
- all_string_sub(cmdstring, "%PROG%", progname, sizeof(cmdstring));
- }
- DEBUG(0, ("smb_panic(): calling panic action [%s]\n", cmdstring));
- result = system(cmdstring);
-
- if (result == -1)
- DEBUG(0, ("smb_panic(): fork failed in panic action: %s\n",
- strerror(errno)));
- else
- DEBUG(0, ("smb_panic(): action returned status %d\n",
- WEXITSTATUS(result)));
- }
- DEBUG(0,("PANIC: %s\n", why));
-
- call_backtrace();
-
-#ifdef SIGABRT
- CatchSignal(SIGABRT,SIGNAL_CAST SIG_DFL);
-#endif
- abort();
-}
-
-/**
-report a fault
-**/
-_NORETURN_ static void fault_report(int sig)
-{
- static int counter;
-
- if (counter) _exit(1);
-
- DEBUG(0,("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n"));
- DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)getpid(),SAMBA_VERSION_STRING));
- DEBUG(0,("\nPlease read the file BUGS.txt in the distribution\n"));
- DEBUG(0,("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n"));
-
- smb_panic("internal error");
-
- exit(1);
-}
-
-/**
-catch serious errors
-**/
-_NORETURN_ static void sig_fault(int sig)
-{
- if (fault_handlers.fault_handler) {
- /* we have a fault handler, call it. It may not return. */
- fault_handlers.fault_handler(sig);
- }
- /* If it returns or doesn't exist, use regular reporter */
- fault_report(sig);
-}
-
-/**
-setup our fault handlers
-**/
-_PUBLIC_ void fault_setup(const char *pname)
-{
- if (progname == NULL) {
- progname = pname;
- }
-#ifdef SIGSEGV
- CatchSignal(SIGSEGV,SIGNAL_CAST sig_fault);
-#endif
-#ifdef SIGBUS
- CatchSignal(SIGBUS,SIGNAL_CAST sig_fault);
-#endif
-#ifdef SIGABRT
- CatchSignal(SIGABRT,SIGNAL_CAST sig_fault);
-#endif
-#ifdef SIGFPE
- CatchSignal(SIGFPE,SIGNAL_CAST sig_fault);
-#endif
-}
-
-/**
- register a fault handler.
- Should only be called once in the execution of smbd.
-*/
-_PUBLIC_ bool register_fault_handler(const char *name,
- void (*fault_handler)(int sig))
-{
- if (fault_handlers.name != NULL) {
- /* it's already registered! */
- DEBUG(2,("fault handler '%s' already registered - failed '%s'\n",
- fault_handlers.name, name));
- return false;
- }
-
- fault_handlers.name = name;
- fault_handlers.fault_handler = fault_handler;
-
- DEBUG(2,("fault handler '%s' registered\n", name));
- return true;
-}
diff --git a/source4/lib/util/fault.m4 b/source4/lib/util/fault.m4
deleted file mode 100644
index b24e63641c..0000000000
--- a/source4/lib/util/fault.m4
+++ /dev/null
@@ -1,5 +0,0 @@
-AC_CHECK_HEADERS(execinfo.h)
-AC_SEARCH_LIBS_EXT(backtrace, [execinfo], EXECINFO_LIBS)
-AC_CHECK_FUNC_EXT(backtrace, $EXECINFO_LIBS)
-SMB_EXT_LIB(EXECINFO,[${EXECINFO_LIBS}])
-SMB_ENABLE(EXECINFO)
diff --git a/source4/lib/util/fsusage.c b/source4/lib/util/fsusage.c
deleted file mode 100644
index 43c8787216..0000000000
--- a/source4/lib/util/fsusage.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- functions to calculate the free disk space
- Copyright (C) Andrew Tridgell 1998-2000
-
- 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/filesys.h"
-
-/**
- * @file
- * @brief Utility functions for getting the amount of free disk space
- */
-
-/* Return the number of TOSIZE-byte blocks used by
- BLOCKS FROMSIZE-byte blocks, rounding away from zero.
-*/
-static uint64_t adjust_blocks(uint64_t blocks, uint64_t fromsize, uint64_t tosize)
-{
- if (fromsize == tosize) /* e.g., from 512 to 512 */
- return blocks;
- else if (fromsize > tosize) /* e.g., from 2048 to 512 */
- return blocks * (fromsize / tosize);
- else /* e.g., from 256 to 512 */
- return (blocks + 1) / (tosize / fromsize);
-}
-
-/**
- * Retrieve amount of free disk space.
- * this does all of the system specific guff to get the free disk space.
- * It is derived from code in the GNU fileutils package, but has been
- * considerably mangled for use here
- *
- * results are returned in *dfree and *dsize, in 512 byte units
-*/
-_PUBLIC_ int sys_fsusage(const char *path, uint64_t *dfree, uint64_t *dsize)
-{
-#ifdef STAT_STATFS3_OSF1
-#define CONVERT_BLOCKS(B) adjust_blocks ((uint64_t)(B), (uint64_t)fsd.f_fsize, (uint64_t)512)
- struct statfs fsd;
-
- if (statfs (path, &fsd, sizeof (struct statfs)) != 0)
- return -1;
-#endif /* STAT_STATFS3_OSF1 */
-
-#ifdef STAT_STATFS2_FS_DATA /* Ultrix */
-#define CONVERT_BLOCKS(B) adjust_blocks ((uint64_t)(B), (uint64_t)1024, (uint64_t)512)
- struct fs_data fsd;
-
- if (statfs (path, &fsd) != 1)
- return -1;
-
- (*dsize) = CONVERT_BLOCKS (fsd.fd_req.btot);
- (*dfree) = CONVERT_BLOCKS (fsd.fd_req.bfreen);
-#endif /* STAT_STATFS2_FS_DATA */
-
-#ifdef STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */
-#define CONVERT_BLOCKS(B) adjust_blocks ((uint64_t)(B), (uint64_t)fsd.f_bsize, (uint64_t)512)
- struct statfs fsd;
-
- if (statfs (path, &fsd) < 0)
- return -1;
-
-#ifdef STATFS_TRUNCATES_BLOCK_COUNTS
- /* In SunOS 4.1.2, 4.1.3, and 4.1.3_U1, the block counts in the
- struct statfs are truncated to 2GB. These conditions detect that
- truncation, presumably without botching the 4.1.1 case, in which
- the values are not truncated. The correct counts are stored in
- undocumented spare fields. */
- if (fsd.f_blocks == 0x1fffff && fsd.f_spare[0] > 0) {
- fsd.f_blocks = fsd.f_spare[0];
- fsd.f_bfree = fsd.f_spare[1];
- fsd.f_bavail = fsd.f_spare[2];
- }
-#endif /* STATFS_TRUNCATES_BLOCK_COUNTS */
-#endif /* STAT_STATFS2_BSIZE */
-
-
-#ifdef STAT_STATFS2_FSIZE /* 4.4BSD */
-#define CONVERT_BLOCKS(B) adjust_blocks ((uint64_t)(B), (uint64_t)fsd.f_fsize, (uint64_t)512)
-
- struct statfs fsd;
-
- if (statfs (path, &fsd) < 0)
- return -1;
-#endif /* STAT_STATFS2_FSIZE */
-
-#ifdef STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */
-# if _AIX || defined(_CRAY)
-# define CONVERT_BLOCKS(B) adjust_blocks ((uint64_t)(B), (uint64_t)fsd.f_bsize, (uint64_t)512)
-# ifdef _CRAY
-# define f_bavail f_bfree
-# endif
-# else
-# define CONVERT_BLOCKS(B) ((uint64_t)B)
-# ifndef _SEQUENT_ /* _SEQUENT_ is DYNIX/ptx */
-# ifndef DOLPHIN /* DOLPHIN 3.8.alfa/7.18 has f_bavail */
-# define f_bavail f_bfree
-# endif
-# endif
-# endif
-
- struct statfs fsd;
-
- if (statfs (path, &fsd, sizeof fsd, 0) < 0)
- return -1;
- /* Empirically, the block counts on most SVR3 and SVR3-derived
- systems seem to always be in terms of 512-byte blocks,
- no matter what value f_bsize has. */
-
-#endif /* STAT_STATFS4 */
-
-#if defined(STAT_STATVFS) || defined(STAT_STATVFS64) /* SVR4 */
-# define CONVERT_BLOCKS(B) \
- adjust_blocks ((uint64_t)(B), fsd.f_frsize ? (uint64_t)fsd.f_frsize : (uint64_t)fsd.f_bsize, (uint64_t)512)
-
-#ifdef STAT_STATVFS64
- struct statvfs64 fsd;
- if (statvfs64(path, &fsd) < 0) return -1;
-#else
- struct statvfs fsd;
- if (statvfs(path, &fsd) < 0) return -1;
-#endif
-
- /* f_frsize isn't guaranteed to be supported. */
-
-#endif /* STAT_STATVFS */
-
-#ifndef CONVERT_BLOCKS
- /* we don't have any dfree code! */
- return -1;
-#else
-#if !defined(STAT_STATFS2_FS_DATA)
- /* !Ultrix */
- (*dsize) = CONVERT_BLOCKS (fsd.f_blocks);
- (*dfree) = CONVERT_BLOCKS (fsd.f_bavail);
-#endif /* not STAT_STATFS2_FS_DATA */
-#endif
-
- return 0;
-}
diff --git a/source4/lib/util/fsusage.m4 b/source4/lib/util/fsusage.m4
deleted file mode 100644
index 6d5d13fe25..0000000000
--- a/source4/lib/util/fsusage.m4
+++ /dev/null
@@ -1,190 +0,0 @@
-#################################################
-# these tests are taken from the GNU fileutils package
-AC_CHECKING(how to get filesystem space usage)
-AC_CHECK_HEADERS(sys/statfs.h sys/statvfs.h sys/vfs.h)
-
-AC_CHECK_HEADERS(sys/mount.h, , , [AC_INCLUDES_DEFAULT
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif])
-
-space=no
-
-# Test for statvfs64.
-if test $space = no; then
- # SVR4
- AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
- [AC_TRY_RUN([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <sys/types.h>
-#include <sys/statvfs.h>
- main ()
- {
- struct statvfs64 fsd;
- exit (statvfs64 (".", &fsd));
- }],
- fu_cv_sys_stat_statvfs64=yes,
- fu_cv_sys_stat_statvfs64=no,
- fu_cv_sys_stat_statvfs64=cross)])
- if test $fu_cv_sys_stat_statvfs64 = yes; then
- space=yes
- AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
- fi
-fi
-
-# Perform only the link test since it seems there are no variants of the
-# statvfs function. This check is more than just AC_CHECK_FUNCS(statvfs)
-# because that got a false positive on SCO OSR5. Adding the declaration
-# of a `struct statvfs' causes this test to fail (as it should) on such
-# systems. That system is reported to work fine with STAT_STATFS4 which
-# is what it gets when this test fails.
-if test $space = no; then
- # SVR4
- AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
- [AC_TRY_LINK([#include <sys/types.h>
-#include <sys/statvfs.h>],
- [struct statvfs fsd; statvfs (0, &fsd);],
- fu_cv_sys_stat_statvfs=yes,
- fu_cv_sys_stat_statvfs=no)])
- if test $fu_cv_sys_stat_statvfs = yes; then
- space=yes
- AC_DEFINE(STAT_STATVFS,1,[Whether statvfs() is available])
- fi
-fi
-
-if test $space = no; then
- # DEC Alpha running OSF/1
- AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
- AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
- [AC_TRY_RUN([
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/mount.h>
- main ()
- {
- struct statfs fsd;
- fsd.f_fsize = 0;
- exit (statfs (".", &fsd, sizeof (struct statfs)));
- }],
- fu_cv_sys_stat_statfs3_osf1=yes,
- fu_cv_sys_stat_statfs3_osf1=no,
- fu_cv_sys_stat_statfs3_osf1=no)])
- AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
- if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
- space=yes
- AC_DEFINE(STAT_STATFS3_OSF1,1,[Whether statfs requires 3 arguments])
- fi
-fi
-
-if test $space = no; then
-# AIX
- AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
-member (AIX, 4.3BSD)])
- AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
- [AC_TRY_RUN([
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-#ifdef HAVE_SYS_MOUNT_H
-#include <sys/mount.h>
-#endif
-#ifdef HAVE_SYS_VFS_H
-#include <sys/vfs.h>
-#endif
- main ()
- {
- struct statfs fsd;
- fsd.f_bsize = 0;
- exit (statfs (".", &fsd));
- }],
- fu_cv_sys_stat_statfs2_bsize=yes,
- fu_cv_sys_stat_statfs2_bsize=no,
- fu_cv_sys_stat_statfs2_bsize=no)])
- AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
- if test $fu_cv_sys_stat_statfs2_bsize = yes; then
- space=yes
- AC_DEFINE(STAT_STATFS2_BSIZE,1,[Whether statfs requires two arguments and struct statfs has bsize property])
- fi
-fi
-
-if test $space = no; then
-# SVR3
- AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
- AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
- [AC_TRY_RUN([#include <sys/types.h>
-#include <sys/statfs.h>
- main ()
- {
- struct statfs fsd;
- exit (statfs (".", &fsd, sizeof fsd, 0));
- }],
- fu_cv_sys_stat_statfs4=yes,
- fu_cv_sys_stat_statfs4=no,
- fu_cv_sys_stat_statfs4=no)])
- AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
- if test $fu_cv_sys_stat_statfs4 = yes; then
- space=yes
- AC_DEFINE(STAT_STATFS4,1,[Whether statfs requires 4 arguments])
- fi
-fi
-
-if test $space = no; then
-# 4.4BSD and NetBSD
- AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
-member (4.4BSD and NetBSD)])
- AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
- [AC_TRY_RUN([#include <sys/types.h>
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-#ifdef HAVE_SYS_MOUNT_H
-#include <sys/mount.h>
-#endif
- main ()
- {
- struct statfs fsd;
- fsd.f_fsize = 0;
- exit (statfs (".", &fsd));
- }],
- fu_cv_sys_stat_statfs2_fsize=yes,
- fu_cv_sys_stat_statfs2_fsize=no,
- fu_cv_sys_stat_statfs2_fsize=no)])
- AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
- if test $fu_cv_sys_stat_statfs2_fsize = yes; then
- space=yes
- AC_DEFINE(STAT_STATFS2_FSIZE,1,[Whether statfs requires 2 arguments and struct statfs has fsize])
- fi
-fi
-
-if test $space = no; then
- # Ultrix
- AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
- AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
- [AC_TRY_RUN([#include <sys/types.h>
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-#ifdef HAVE_SYS_MOUNT_H
-#include <sys/mount.h>
-#endif
-#ifdef HAVE_SYS_FS_TYPES_H
-#include <sys/fs_types.h>
-#endif
- main ()
- {
- struct fs_data fsd;
- /* Ultrix's statfs returns 1 for success,
- 0 for not mounted, -1 for failure. */
- exit (statfs (".", &fsd) != 1);
- }],
- fu_cv_sys_stat_fs_data=yes,
- fu_cv_sys_stat_fs_data=no,
- fu_cv_sys_stat_fs_data=no)])
- AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
- if test $fu_cv_sys_stat_fs_data = yes; then
- space=yes
- AC_DEFINE(STAT_STATFS2_FS_DATA,1,[Whether statfs requires 2 arguments and struct fs_data is available])
- fi
-fi
diff --git a/source4/lib/util/genrand.c b/source4/lib/util/genrand.c
deleted file mode 100644
index 7df4ec4e20..0000000000
--- a/source4/lib/util/genrand.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Functions to create reasonable random numbers for crypto use.
-
- Copyright (C) Jeremy Allison 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 "includes.h"
-#include "system/filesys.h"
-#include "lib/crypto/crypto.h"
-#include "system/locale.h"
-
-/**
- * @file
- * @brief Random number generation
- */
-
-static unsigned char hash[258];
-static uint32_t counter;
-
-static bool done_reseed = false;
-static unsigned int bytes_since_reseed = 0;
-
-static int urand_fd = -1;
-
-static void (*reseed_callback)(void *userdata, int *newseed);
-static void *reseed_callback_userdata = NULL;
-
-/**
- Copy any user given reseed data.
-**/
-
-_PUBLIC_ void set_rand_reseed_callback(void (*fn)(void *, int *), void *userdata)
-{
- reseed_callback = fn;
- reseed_callback_userdata = userdata;
- set_need_random_reseed();
-}
-
-/**
- * Tell the random number generator it needs to reseed.
- */
-_PUBLIC_ void set_need_random_reseed(void)
-{
- done_reseed = false;
- bytes_since_reseed = 0;
-}
-
-static void get_rand_reseed_data(int *reseed_data)
-{
- if (reseed_callback) {
- reseed_callback(reseed_callback_userdata, reseed_data);
- } else {
- *reseed_data = 0;
- }
-}
-
-/****************************************************************
- Setup the seed.
-*****************************************************************/
-
-static void seed_random_stream(unsigned char *seedval, size_t seedlen)
-{
- unsigned char j = 0;
- size_t ind;
-
- for (ind = 0; ind < 256; ind++)
- hash[ind] = (unsigned char)ind;
-
- for( ind = 0; ind < 256; ind++) {
- unsigned char tc;
-
- j += (hash[ind] + seedval[ind%seedlen]);
-
- tc = hash[ind];
- hash[ind] = hash[j];
- hash[j] = tc;
- }
-
- hash[256] = 0;
- hash[257] = 0;
-}
-
-/****************************************************************
- Get datasize bytes worth of random data.
-*****************************************************************/
-
-static void get_random_stream(unsigned char *data, size_t datasize)
-{
- unsigned char index_i = hash[256];
- unsigned char index_j = hash[257];
- size_t ind;
-
- for( ind = 0; ind < datasize; ind++) {
- unsigned char tc;
- unsigned char t;
-
- index_i++;
- index_j += hash[index_i];
-
- tc = hash[index_i];
- hash[index_i] = hash[index_j];
- hash[index_j] = tc;
-
- t = hash[index_i] + hash[index_j];
- data[ind] = hash[t];
- }
-
- hash[256] = index_i;
- hash[257] = index_j;
-}
-
-/****************************************************************
- Get a 16 byte hash from the contents of a file.
-
- Note that the hash is initialised, because the extra entropy is not
- worth the valgrind pain.
-*****************************************************************/
-
-static void do_filehash(const char *fname, unsigned char *the_hash)
-{
- unsigned char buf[1011]; /* deliberate weird size */
- unsigned char tmp_md4[16];
- int fd, n;
-
- ZERO_STRUCT(tmp_md4);
-
- fd = open(fname,O_RDONLY,0);
- if (fd == -1)
- return;
-
- while ((n = read(fd, (char *)buf, sizeof(buf))) > 0) {
- mdfour(tmp_md4, buf, n);
- for (n=0;n<16;n++)
- the_hash[n] ^= tmp_md4[n];
- }
- close(fd);
-}
-
-/**************************************************************
- Try and get a good random number seed. Try a number of
- different factors. Firstly, try /dev/urandom - use if exists.
-
- We use /dev/urandom as a read of /dev/random can block if
- the entropy pool dries up. This leads clients to timeout
- or be very slow on connect.
-
- If we can't use /dev/urandom then seed the stream random generator
- above...
-**************************************************************/
-
-static int do_reseed(bool use_fd, int fd)
-{
- unsigned char seed_inbuf[40];
- uint32_t v1, v2; struct timeval tval; pid_t mypid;
- int reseed_data = 0;
-
- if (use_fd) {
- if (fd == -1) {
- fd = open( "/dev/urandom", O_RDONLY,0);
- }
- if (fd != -1
- && (read(fd, seed_inbuf, sizeof(seed_inbuf)) == sizeof(seed_inbuf))) {
- seed_random_stream(seed_inbuf, sizeof(seed_inbuf));
- return fd;
- }
- }
-
- /* Add in some secret file contents */
-
- do_filehash("/etc/shadow", &seed_inbuf[0]);
-
- /*
- * Add the counter, time of day, and pid.
- */
-
- GetTimeOfDay(&tval);
- mypid = getpid();
- v1 = (counter++) + mypid + tval.tv_sec;
- v2 = (counter++) * mypid + tval.tv_usec;
-
- SIVAL(seed_inbuf, 32, v1 ^ IVAL(seed_inbuf, 32));
- SIVAL(seed_inbuf, 36, v2 ^ IVAL(seed_inbuf, 36));
-
- /*
- * Add any user-given reseed data.
- */
-
- get_rand_reseed_data(&reseed_data);
- if (reseed_data) {
- size_t i;
- for (i = 0; i < sizeof(seed_inbuf); i++)
- seed_inbuf[i] ^= ((char *)(&reseed_data))[i % sizeof(reseed_data)];
- }
-
- seed_random_stream(seed_inbuf, sizeof(seed_inbuf));
-
- return -1;
-}
-
-/**
- Interface to the (hopefully) good crypto random number generator.
- Will use our internal PRNG if more than 40 bytes of random generation
- has been requested, otherwise tries to read from /dev/random
-**/
-_PUBLIC_ void generate_random_buffer(uint8_t *out, int len)
-{
- unsigned char md4_buf[64];
- unsigned char tmp_buf[16];
- unsigned char *p;
-
- if(!done_reseed) {
- bytes_since_reseed += len;
-
- /* Magic constant to try and avoid reading 40 bytes
- * and setting up the PRNG if the app only ever wants
- * a few bytes */
- if (bytes_since_reseed < 40) {
- if (urand_fd == -1) {
- urand_fd = open( "/dev/urandom", O_RDONLY,0);
- }
- if(urand_fd != -1 && (read(urand_fd, out, len) == len)) {
- return;
- }
- }
-
- urand_fd = do_reseed(true, urand_fd);
- done_reseed = true;
- }
-
- /*
- * Generate random numbers in chunks of 64 bytes,
- * then md4 them & copy to the output buffer.
- * This way the raw state of the stream is never externally
- * seen.
- */
-
- p = out;
- while(len > 0) {
- int copy_len = len > 16 ? 16 : len;
-
- get_random_stream(md4_buf, sizeof(md4_buf));
- mdfour(tmp_buf, md4_buf, sizeof(md4_buf));
- memcpy(p, tmp_buf, copy_len);
- p += copy_len;
- len -= copy_len;
- }
-}
-
-/**
- Interface to the (hopefully) good crypto random number generator.
- Will always use /dev/urandom if available.
-**/
-_PUBLIC_ void generate_secret_buffer(uint8_t *out, int len)
-{
- if (urand_fd == -1) {
- urand_fd = open( "/dev/urandom", O_RDONLY,0);
- }
- if(urand_fd != -1 && (read(urand_fd, out, len) == len)) {
- return;
- }
-
- generate_random_buffer(out, len);
-}
-
-/**
- generate a single random uint32_t
-**/
-_PUBLIC_ uint32_t generate_random(void)
-{
- uint8_t v[4];
- generate_random_buffer(v, 4);
- return IVAL(v, 0);
-}
-
-
-/**
- very basic password quality checker
-**/
-_PUBLIC_ bool check_password_quality(const char *s)
-{
- int has_digit=0, has_capital=0, has_lower=0, has_special=0, has_high=0;
- while (*s) {
- if (isdigit((unsigned char)*s)) {
- has_digit |= 1;
- } else if (isupper((unsigned char)*s)) {
- has_capital |= 1;
- } else if (islower((unsigned char)*s)) {
- has_lower |= 1;
- } else if (isascii((unsigned char)*s)) {
- has_special |= 1;
- } else {
- has_high++;
- }
- s++;
- }
-
- return ((has_digit + has_lower + has_capital + has_special) >= 3
- || (has_high > strlen(s)/2));
-}
-
-/**
- Use the random number generator to generate a random string.
-**/
-
-_PUBLIC_ char *generate_random_str_list(TALLOC_CTX *mem_ctx, size_t len, const char *list)
-{
- size_t i;
- size_t list_len = strlen(list);
-
- char *retstr = talloc_array(mem_ctx, char, len + 1);
- if (!retstr) return NULL;
-
- generate_random_buffer((uint8_t *)retstr, len);
- for (i = 0; i < len; i++) {
- retstr[i] = list[retstr[i] % list_len];
- }
- retstr[i] = '\0';
-
- return retstr;
-}
-
-/**
- * Generate a random text string consisting of the specified length.
- * The returned string will be allocated.
- *
- * Characters used are: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_-#.,
- */
-
-_PUBLIC_ char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len)
-{
- char *retstr;
- const char *c_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_-#.,";
-
-again:
- retstr = generate_random_str_list(mem_ctx, len, c_list);
- if (!retstr) return NULL;
-
- /* we need to make sure the random string passes basic quality tests
- or it might be rejected by windows as a password */
- if (len >= 7 && !check_password_quality(retstr)) {
- talloc_free(retstr);
- goto again;
- }
-
- return retstr;
-}
diff --git a/source4/lib/util/idtree.c b/source4/lib/util/idtree.c
deleted file mode 100644
index 1e2cc2976a..0000000000
--- a/source4/lib/util/idtree.c
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- very efficient functions to manage mapping a id (such as a fnum) to
- a pointer. This is used for fnum and search id allocation.
-
- Copyright (C) Andrew Tridgell 2004
-
- This code is derived from lib/idr.c in the 2.6 Linux kernel, which was
- written by Jim Houston jim.houston@ccur.com, and is
- Copyright (C) 2002 by Concurrent Computer Corporation
-
- 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/>.
-*/
-
-/*
- see the section marked "public interface" below for documentation
-*/
-
-/**
- * @file
- */
-
-#include "includes.h"
-
-#define IDR_BITS 5
-#define IDR_FULL 0xfffffffful
-#if 0 /* unused */
-#define TOP_LEVEL_FULL (IDR_FULL >> 30)
-#endif
-#define IDR_SIZE (1 << IDR_BITS)
-#define IDR_MASK ((1 << IDR_BITS)-1)
-#define MAX_ID_SHIFT (sizeof(int)*8 - 1)
-#define MAX_ID_BIT (1U << MAX_ID_SHIFT)
-#define MAX_ID_MASK (MAX_ID_BIT - 1)
-#define MAX_LEVEL (MAX_ID_SHIFT + IDR_BITS - 1) / IDR_BITS
-#define IDR_FREE_MAX MAX_LEVEL + MAX_LEVEL
-
-#define set_bit(bit, v) (v) |= (1<<(bit))
-#define clear_bit(bit, v) (v) &= ~(1<<(bit))
-#define test_bit(bit, v) ((v) & (1<<(bit)))
-
-struct idr_layer {
- uint32_t bitmap;
- struct idr_layer *ary[IDR_SIZE];
- int count;
-};
-
-struct idr_context {
- struct idr_layer *top;
- struct idr_layer *id_free;
- int layers;
- int id_free_cnt;
-};
-
-static struct idr_layer *alloc_layer(struct idr_context *idp)
-{
- struct idr_layer *p;
-
- if (!(p = idp->id_free))
- return NULL;
- idp->id_free = p->ary[0];
- idp->id_free_cnt--;
- p->ary[0] = NULL;
- return p;
-}
-
-static int find_next_bit(uint32_t bm, int maxid, int n)
-{
- while (n<maxid && !test_bit(n, bm)) n++;
- return n;
-}
-
-static void free_layer(struct idr_context *idp, struct idr_layer *p)
-{
- p->ary[0] = idp->id_free;
- idp->id_free = p;
- idp->id_free_cnt++;
-}
-
-static int idr_pre_get(struct idr_context *idp)
-{
- while (idp->id_free_cnt < IDR_FREE_MAX) {
- struct idr_layer *new = talloc_zero(idp, struct idr_layer);
- if(new == NULL)
- return (0);
- free_layer(idp, new);
- }
- return 1;
-}
-
-static int sub_alloc(struct idr_context *idp, void *ptr, int *starting_id)
-{
- int n, m, sh;
- struct idr_layer *p, *new;
- struct idr_layer *pa[MAX_LEVEL];
- int l, id;
- uint32_t bm;
-
- memset(pa, 0, sizeof(pa));
-
- id = *starting_id;
- p = idp->top;
- l = idp->layers;
- pa[l--] = NULL;
- while (1) {
- /*
- * We run around this while until we reach the leaf node...
- */
- n = (id >> (IDR_BITS*l)) & IDR_MASK;
- bm = ~p->bitmap;
- m = find_next_bit(bm, IDR_SIZE, n);
- if (m == IDR_SIZE) {
- /* no space available go back to previous layer. */
- l++;
- id = (id | ((1 << (IDR_BITS*l))-1)) + 1;
- if (!(p = pa[l])) {
- *starting_id = id;
- return -2;
- }
- continue;
- }
- if (m != n) {
- sh = IDR_BITS*l;
- id = ((id >> sh) ^ n ^ m) << sh;
- }
- if ((id >= MAX_ID_BIT) || (id < 0))
- return -1;
- if (l == 0)
- break;
- /*
- * Create the layer below if it is missing.
- */
- if (!p->ary[m]) {
- if (!(new = alloc_layer(idp)))
- return -1;
- p->ary[m] = new;
- p->count++;
- }
- pa[l--] = p;
- p = p->ary[m];
- }
- /*
- * We have reached the leaf node, plant the
- * users pointer and return the raw id.
- */
- p->ary[m] = (struct idr_layer *)ptr;
- set_bit(m, p->bitmap);
- p->count++;
- /*
- * If this layer is full mark the bit in the layer above
- * to show that this part of the radix tree is full.
- * This may complete the layer above and require walking
- * up the radix tree.
- */
- n = id;
- while (p->bitmap == IDR_FULL) {
- if (!(p = pa[++l]))
- break;
- n = n >> IDR_BITS;
- set_bit((n & IDR_MASK), p->bitmap);
- }
- return(id);
-}
-
-static int idr_get_new_above_int(struct idr_context *idp, void *ptr, int starting_id)
-{
- struct idr_layer *p, *new;
- int layers, v, id;
-
- idr_pre_get(idp);
-
- id = starting_id;
-build_up:
- p = idp->top;
- layers = idp->layers;
- if (!p) {
- if (!(p = alloc_layer(idp)))
- return -1;
- layers = 1;
- }
- /*
- * Add a new layer to the top of the tree if the requested
- * id is larger than the currently allocated space.
- */
- while ((layers < MAX_LEVEL) && (id >= (1 << (layers*IDR_BITS)))) {
- layers++;
- if (!p->count)
- continue;
- if (!(new = alloc_layer(idp))) {
- /*
- * The allocation failed. If we built part of
- * the structure tear it down.
- */
- for (new = p; p && p != idp->top; new = p) {
- p = p->ary[0];
- new->ary[0] = NULL;
- new->bitmap = new->count = 0;
- free_layer(idp, new);
- }
- return -1;
- }
- new->ary[0] = p;
- new->count = 1;
- if (p->bitmap == IDR_FULL)
- set_bit(0, new->bitmap);
- p = new;
- }
- idp->top = p;
- idp->layers = layers;
- v = sub_alloc(idp, ptr, &id);
- if (v == -2)
- goto build_up;
- return(v);
-}
-
-static int sub_remove(struct idr_context *idp, int shift, int id)
-{
- struct idr_layer *p = idp->top;
- struct idr_layer **pa[MAX_LEVEL];
- struct idr_layer ***paa = &pa[0];
- int n;
-
- *paa = NULL;
- *++paa = &idp->top;
-
- while ((shift > 0) && p) {
- n = (id >> shift) & IDR_MASK;
- clear_bit(n, p->bitmap);
- *++paa = &p->ary[n];
- p = p->ary[n];
- shift -= IDR_BITS;
- }
- n = id & IDR_MASK;
- if (p != NULL && test_bit(n, p->bitmap)) {
- clear_bit(n, p->bitmap);
- p->ary[n] = NULL;
- while(*paa && ! --((**paa)->count)){
- free_layer(idp, **paa);
- **paa-- = NULL;
- }
- if ( ! *paa )
- idp->layers = 0;
- return 0;
- }
- return -1;
-}
-
-static void *_idr_find(struct idr_context *idp, int id)
-{
- int n;
- struct idr_layer *p;
-
- n = idp->layers * IDR_BITS;
- p = idp->top;
- /*
- * This tests to see if bits outside the current tree are
- * present. If so, tain't one of ours!
- */
- if ((id & ~(~0 << MAX_ID_SHIFT)) >> (n + IDR_BITS))
- return NULL;
-
- /* Mask off upper bits we don't use for the search. */
- id &= MAX_ID_MASK;
-
- while (n >= IDR_BITS && p) {
- n -= IDR_BITS;
- p = p->ary[(id >> n) & IDR_MASK];
- }
- return((void *)p);
-}
-
-static int _idr_remove(struct idr_context *idp, int id)
-{
- struct idr_layer *p;
-
- /* Mask off upper bits we don't use for the search. */
- id &= MAX_ID_MASK;
-
- if (sub_remove(idp, (idp->layers - 1) * IDR_BITS, id) == -1) {
- return -1;
- }
-
- if ( idp->top && idp->top->count == 1 &&
- (idp->layers > 1) &&
- idp->top->ary[0]) {
- /* We can drop a layer */
- p = idp->top->ary[0];
- idp->top->bitmap = idp->top->count = 0;
- free_layer(idp, idp->top);
- idp->top = p;
- --idp->layers;
- }
- while (idp->id_free_cnt >= IDR_FREE_MAX) {
- p = alloc_layer(idp);
- talloc_free(p);
- }
- return 0;
-}
-
-/************************************************************************
- this is the public interface
-**************************************************************************/
-
-/**
- initialise a idr tree. The context return value must be passed to
- all subsequent idr calls. To destroy the idr tree use talloc_free()
- on this context
- */
-_PUBLIC_ struct idr_context *idr_init(TALLOC_CTX *mem_ctx)
-{
- return talloc_zero(mem_ctx, struct idr_context);
-}
-
-/**
- allocate the next available id, and assign 'ptr' into its slot.
- you can retrieve later this pointer using idr_find()
-*/
-_PUBLIC_ int idr_get_new(struct idr_context *idp, void *ptr, int limit)
-{
- int ret = idr_get_new_above_int(idp, ptr, 0);
- if (ret > limit) {
- idr_remove(idp, ret);
- return -1;
- }
- return ret;
-}
-
-/**
- allocate a new id, giving the first available value greater than or
- equal to the given starting id
-*/
-_PUBLIC_ int idr_get_new_above(struct idr_context *idp, void *ptr, int starting_id, int limit)
-{
- int ret = idr_get_new_above_int(idp, ptr, starting_id);
- if (ret > limit) {
- idr_remove(idp, ret);
- return -1;
- }
- return ret;
-}
-
-/**
- allocate a new id randomly in the given range
-*/
-_PUBLIC_ int idr_get_new_random(struct idr_context *idp, void *ptr, int limit)
-{
- int id;
-
- /* first try a random starting point in the whole range, and if that fails,
- then start randomly in the bottom half of the range. This can only
- fail if the range is over half full */
- id = idr_get_new_above(idp, ptr, 1+(generate_random() % limit), limit);
- if (id == -1) {
- id = idr_get_new_above(idp, ptr, 1+(generate_random()%(limit/2)), limit);
- }
-
- return id;
-}
-
-/**
- find a pointer value previously set with idr_get_new given an id
-*/
-_PUBLIC_ void *idr_find(struct idr_context *idp, int id)
-{
- return _idr_find(idp, id);
-}
-
-/**
- remove an id from the idr tree
-*/
-_PUBLIC_ int idr_remove(struct idr_context *idp, int id)
-{
- int ret;
- ret = _idr_remove((struct idr_context *)idp, id);
- if (ret != 0) {
- DEBUG(0,("WARNING: attempt to remove unset id %d in idtree\n", id));
- }
- return ret;
-}
diff --git a/source4/lib/util/mainpage.dox b/source4/lib/util/mainpage.dox
deleted file mode 100644
index 464151e771..0000000000
--- a/source4/lib/util/mainpage.dox
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
-
-\mainpage util
-
-\section Introduction
-
-This library contains convenience functions that are used heavily
-throughout Samba. None of these functions are SMB or Samba-specific.
-It's a bit to Samba what GLib is to the GNOME folks.
-
-*/
diff --git a/source4/lib/util/ms_fnmatch.c b/source4/lib/util/ms_fnmatch.c
deleted file mode 100644
index 5e04ec1f4b..0000000000
--- a/source4/lib/util/ms_fnmatch.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- filename matching routine
- Copyright (C) Andrew Tridgell 1992-2004
-
- 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 module was originally based on fnmatch.c copyright by the Free
- Software Foundation. It bears little (if any) resemblence to that
- code now
-*/
-
-/**
- * @file
- * @brief MS-style Filename matching
- */
-
-#include "includes.h"
-#include "param/param.h"
-
-static int null_match(const char *p)
-{
- for (;*p;p++) {
- if (*p != '*' &&
- *p != '<' &&
- *p != '"' &&
- *p != '>') return -1;
- }
- return 0;
-}
-
-/*
- the max_n structure is purely for efficiency, it doesn't contribute
- to the matching algorithm except by ensuring that the algorithm does
- not grow exponentially
-*/
-struct max_n {
- const char *predot;
- const char *postdot;
-};
-
-
-/*
- p and n are the pattern and string being matched. The max_n array is
- an optimisation only. The ldot pointer is NULL if the string does
- not contain a '.', otherwise it points at the last dot in 'n'.
-*/
-static int ms_fnmatch_core(const char *p, const char *n,
- struct max_n *max_n, const char *ldot)
-{
- codepoint_t c, c2;
- int i;
- size_t size, size_n;
- struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
-
- while ((c = next_codepoint(iconv_convenience, p, &size))) {
- p += size;
-
- switch (c) {
- case '*':
- /* a '*' matches zero or more characters of any type */
- if (max_n->predot && max_n->predot <= n) {
- return null_match(p);
- }
- for (i=0; n[i]; i += size_n) {
- next_codepoint(iconv_convenience, n+i, &size_n);
- if (ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) {
- return 0;
- }
- }
- if (!max_n->predot || max_n->predot > n) max_n->predot = n;
- return null_match(p);
-
- case '<':
- /* a '<' matches zero or more characters of
- any type, but stops matching at the last
- '.' in the string. */
- if (max_n->predot && max_n->predot <= n) {
- return null_match(p);
- }
- if (max_n->postdot && max_n->postdot <= n && n <= ldot) {
- return -1;
- }
- for (i=0; n[i]; i += size_n) {
- next_codepoint(iconv_convenience, n+i, &size_n);
- if (ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) return 0;
- if (n+i == ldot) {
- if (ms_fnmatch_core(p, n+i+size_n, max_n+1, ldot) == 0) return 0;
- if (!max_n->postdot || max_n->postdot > n) max_n->postdot = n;
- return -1;
- }
- }
- if (!max_n->predot || max_n->predot > n) max_n->predot = n;
- return null_match(p);
-
- case '?':
- /* a '?' matches any single character */
- if (! *n) {
- return -1;
- }
- next_codepoint(iconv_convenience, n, &size_n);
- n += size_n;
- break;
-
- case '>':
- /* a '?' matches any single character, but
- treats '.' specially */
- if (n[0] == '.') {
- if (! n[1] && null_match(p) == 0) {
- return 0;
- }
- break;
- }
- if (! *n) return null_match(p);
- next_codepoint(iconv_convenience, n, &size_n);
- n += size_n;
- break;
-
- case '"':
- /* a bit like a soft '.' */
- if (*n == 0 && null_match(p) == 0) {
- return 0;
- }
- if (*n != '.') return -1;
- next_codepoint(iconv_convenience, n, &size_n);
- n += size_n;
- break;
-
- default:
- c2 = next_codepoint(iconv_convenience, n, &size_n);
- if (c != c2 && codepoint_cmpi(c, c2) != 0) {
- return -1;
- }
- n += size_n;
- break;
- }
- }
-
- if (! *n) {
- return 0;
- }
-
- return -1;
-}
-
-int ms_fnmatch(const char *pattern, const char *string, enum protocol_types protocol)
-{
- int ret, count, i;
- struct max_n *max_n = NULL;
-
- if (strcmp(string, "..") == 0) {
- string = ".";
- }
-
- if (strpbrk(pattern, "<>*?\"") == NULL) {
- /* this is not just an optimisation - it is essential
- for LANMAN1 correctness */
- return strcasecmp_m(pattern, string);
- }
-
- if (protocol <= PROTOCOL_LANMAN2) {
- char *p = talloc_strdup(NULL, pattern);
- if (p == NULL) {
- return -1;
- }
- /*
- for older negotiated protocols it is possible to
- translate the pattern to produce a "new style"
- pattern that exactly matches w2k behaviour
- */
- for (i=0;p[i];i++) {
- if (p[i] == '?') {
- p[i] = '>';
- } else if (p[i] == '.' &&
- (p[i+1] == '?' ||
- p[i+1] == '*' ||
- p[i+1] == 0)) {
- p[i] = '"';
- } else if (p[i] == '*' &&
- p[i+1] == '.') {
- p[i] = '<';
- }
- }
- ret = ms_fnmatch(p, string, PROTOCOL_NT1);
- talloc_free(p);
- return ret;
- }
-
- for (count=i=0;pattern[i];i++) {
- if (pattern[i] == '*' || pattern[i] == '<') count++;
- }
-
- max_n = talloc_zero_array(NULL, struct max_n, count);
- if (max_n == NULL) {
- return -1;
- }
-
- ret = ms_fnmatch_core(pattern, string, max_n, strrchr(string, '.'));
-
- talloc_free(max_n);
-
- return ret;
-}
-
-
-/** a generic fnmatch function - uses for non-CIFS pattern matching */
-int gen_fnmatch(const char *pattern, const char *string)
-{
- return ms_fnmatch(pattern, string, PROTOCOL_NT1);
-}
diff --git a/source4/lib/util/mutex.c b/source4/lib/util/mutex.c
deleted file mode 100644
index 4d0df68eed..0000000000
--- a/source4/lib/util/mutex.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba mutex/lock functions
- Copyright (C) Andrew Tridgell 2003
- Copyright (C) James J Myers 2003
-
- 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 "mutex.h"
-
-/**
- * @file
- * @brief Mutex utility functions
- */
-
-/* the registered mutex handlers */
-static struct {
- const char *name;
- struct mutex_ops ops;
-} mutex_handlers;
-
-/* read/write lock routines */
-
-
-/**
- register a set of mutex/rwlock handlers.
- Should only be called once in the execution of smbd.
-*/
-_PUBLIC_ bool register_mutex_handlers(const char *name, struct mutex_ops *ops)
-{
- if (mutex_handlers.name != NULL) {
- /* it's already registered! */
- DEBUG(2,("mutex handler '%s' already registered - failed '%s'\n",
- mutex_handlers.name, name));
- return false;
- }
-
- mutex_handlers.name = name;
- mutex_handlers.ops = *ops;
-
- DEBUG(2,("mutex handler '%s' registered\n", name));
- return true;
-}
-
diff --git a/source4/lib/util/mutex.h b/source4/lib/util/mutex.h
deleted file mode 100644
index bf845906f2..0000000000
--- a/source4/lib/util/mutex.h
+++ /dev/null
@@ -1,75 +0,0 @@
-#ifndef _MUTEX_H_
-#define _MUTEX_H_
-/*
- Unix SMB/CIFS implementation.
- Samba mutex functions
- Copyright (C) Andrew Tridgell 2003
- Copyright (C) James J Myers 2003
-
- 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/>.
-*/
-
-/**
- * @file
- * @brief Mutex operations
- */
-
-struct mutex_ops;
-
-/* To add a new read/write lock, add it to enum rwlock_id
- */
-enum rwlock_id { RWLOCK_SMBD, /* global smbd lock */
-
- RWLOCK_MAX /* this MUST be kept last */
-};
-
-#define MUTEX_LOCK_BY_ID(mutex_index) smb_mutex_lock_by_id(mutex_index, #mutex_index)
-#define MUTEX_UNLOCK_BY_ID(mutex_index) smb_mutex_unlock_by_id(mutex_index, #mutex_index)
-#define MUTEX_INIT(mutex, name) smb_mutex_init(mutex, #name)
-#define MUTEX_DESTROY(mutex, name) smb_mutex_destroy(mutex, #name)
-#define MUTEX_LOCK(mutex, name) smb_mutex_lock(mutex, #name)
-#define MUTEX_UNLOCK(mutex, name) smb_mutex_unlock(mutex, #name)
-
-#define RWLOCK_INIT(rwlock, name) smb_rwlock_init(rwlock, #name)
-#define RWLOCK_DESTROY(rwlock, name) smb_rwlock_destroy(rwlock, #name)
-#define RWLOCK_LOCK_WRITE(rwlock, name) smb_rwlock_lock_write(rwlock, #name)
-#define RWLOCK_LOCK_READ(rwlock, name) smb_rwlock_lock_read(rwlock, #name)
-#define RWLOCK_UNLOCK(rwlock, name) smb_rwlock_unlock(rwlock, #name)
-
-
-
-/* this null typedef ensures we get the types right and avoids the
- pitfalls of void* */
-typedef struct smb_mutex {
- void *mutex;
-} smb_mutex_t;
-typedef struct {
- void *rwlock;
-} smb_rwlock_t;
-
-/* the mutex model operations structure - contains function pointers to
- the model-specific implementations of each operation */
-struct mutex_ops {
- int (*mutex_init)(smb_mutex_t *mutex, const char *name);
- int (*mutex_lock)(smb_mutex_t *mutex, const char *name);
- int (*mutex_unlock)(smb_mutex_t *mutex, const char *name);
- int (*mutex_destroy)(smb_mutex_t *mutex, const char *name);
- int (*rwlock_init)(smb_rwlock_t *rwlock, const char *name);
- int (*rwlock_lock_write)(smb_rwlock_t *rwlock, const char *name);
- int (*rwlock_lock_read)(smb_rwlock_t *rwlock, const char *name);
- int (*rwlock_unlock)(smb_rwlock_t *rwlock, const char *name);
- int (*rwlock_destroy)(smb_rwlock_t *rwlock, const char *name);
-};
-
-#endif /* endif _MUTEX_H_ */
diff --git a/source4/lib/util/params.c b/source4/lib/util/params.c
deleted file mode 100644
index 3a9e2b9505..0000000000
--- a/source4/lib/util/params.c
+++ /dev/null
@@ -1,587 +0,0 @@
-/* -------------------------------------------------------------------------- **
- * Microsoft Network Services for Unix, AKA., Andrew Tridgell's SAMBA.
- *
- * This module Copyright (C) 1990-1998 Karl Auer
- *
- * Rewritten almost completely by Christopher R. Hertel
- * at the University of Minnesota, September, 1997.
- * This module Copyright (C) 1997-1998 by the University of Minnesota
- * -------------------------------------------------------------------------- **
- *
- * 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/>.
- *
- * -------------------------------------------------------------------------- **
- *
- * Module name: params
- *
- * -------------------------------------------------------------------------- **
- *
- * This module performs lexical analysis and initial parsing of a
- * Windows-like parameter file. It recognizes and handles four token
- * types: section-name, parameter-name, parameter-value, and
- * end-of-file. Comments and line continuation are handled
- * internally.
- *
- * The entry point to the module is function pm_process(). This
- * function opens the source file, calls the Parse() function to parse
- * the input, and then closes the file when either the EOF is reached
- * or a fatal error is encountered.
- *
- * A sample parameter file might look like this:
- *
- * [section one]
- * parameter one = value string
- * parameter two = another value
- * [section two]
- * new parameter = some value or t'other
- *
- * The parameter file is divided into sections by section headers:
- * section names enclosed in square brackets (eg. [section one]).
- * Each section contains parameter lines, each of which consist of a
- * parameter name and value delimited by an equal sign. Roughly, the
- * syntax is:
- *
- * <file> :== { <section> } EOF
- *
- * <section> :== <section header> { <parameter line> }
- *
- * <section header> :== '[' NAME ']'
- *
- * <parameter line> :== NAME '=' VALUE '\n'
- *
- * Blank lines and comment lines are ignored. Comment lines are lines
- * beginning with either a semicolon (';') or a pound sign ('#').
- *
- * All whitespace in section names and parameter names is compressed
- * to single spaces. Leading and trailing whitespace is stipped from
- * both names and values.
- *
- * Only the first equals sign in a parameter line is significant.
- * Parameter values may contain equals signs, square brackets and
- * semicolons. Internal whitespace is retained in parameter values,
- * with the exception of the '\r' character, which is stripped for
- * historic reasons. Parameter names may not start with a left square
- * bracket, an equal sign, a pound sign, or a semicolon, because these
- * are used to identify other tokens.
- *
- * -------------------------------------------------------------------------- **
- */
-
-#include "includes.h"
-#include "system/locale.h"
-
-/* -------------------------------------------------------------------------- **
- * Constants...
- */
-
-#define BUFR_INC 1024
-
-
-/* we can't use FILE* due to the 256 fd limit - use this cheap hack
- instead */
-typedef struct {
- char *buf;
- char *p;
- size_t size;
- char *bufr;
- int bSize;
-} myFILE;
-
-static int mygetc(myFILE *f)
-{
- if (f->p >= f->buf+f->size) return EOF;
- /* be sure to return chars >127 as positive values */
- return (int)( *(f->p++) & 0x00FF );
-}
-
-static void myfile_close(myFILE *f)
-{
- talloc_free(f);
-}
-
-/* -------------------------------------------------------------------------- **
- * Functions...
- */
-
-static int EatWhitespace( myFILE *InFile )
- /* ------------------------------------------------------------------------ **
- * Scan past whitespace (see ctype(3C)) and return the first non-whitespace
- * character, or newline, or EOF.
- *
- * Input: InFile - Input source.
- *
- * Output: The next non-whitespace character in the input stream.
- *
- * Notes: Because the config files use a line-oriented grammar, we
- * explicitly exclude the newline character from the list of
- * whitespace characters.
- * - Note that both EOF (-1) and the nul character ('\0') are
- * considered end-of-file markers.
- *
- * ------------------------------------------------------------------------ **
- */
- {
- int c;
-
- for( c = mygetc( InFile ); isspace( c ) && ('\n' != c); c = mygetc( InFile ) )
- ;
- return( c );
- } /* EatWhitespace */
-
-static int EatComment( myFILE *InFile )
- /* ------------------------------------------------------------------------ **
- * Scan to the end of a comment.
- *
- * Input: InFile - Input source.
- *
- * Output: The character that marks the end of the comment. Normally,
- * this will be a newline, but it *might* be an EOF.
- *
- * Notes: Because the config files use a line-oriented grammar, we
- * explicitly exclude the newline character from the list of
- * whitespace characters.
- * - Note that both EOF (-1) and the nul character ('\0') are
- * considered end-of-file markers.
- *
- * ------------------------------------------------------------------------ **
- */
- {
- int c;
-
- for( c = mygetc( InFile ); ('\n'!=c) && (EOF!=c) && (c>0); c = mygetc( InFile ) )
- ;
- return( c );
- } /* EatComment */
-
-/*****************************************************************************
- * Scan backards within a string to discover if the last non-whitespace
- * character is a line-continuation character ('\\').
- *
- * Input: line - A pointer to a buffer containing the string to be
- * scanned.
- * pos - This is taken to be the offset of the end of the
- * string. This position is *not* scanned.
- *
- * Output: The offset of the '\\' character if it was found, or -1 to
- * indicate that it was not.
- *
- *****************************************************************************/
-
-static int Continuation(char *line, int pos )
-{
- pos--;
- while( (pos >= 0) && isspace((int)line[pos]))
- pos--;
-
- return (((pos >= 0) && ('\\' == line[pos])) ? pos : -1 );
-}
-
-
-static bool Section( myFILE *InFile, bool (*sfunc)(const char *, void *), void *userdata )
- /* ------------------------------------------------------------------------ **
- * Scan a section name, and pass the name to function sfunc().
- *
- * Input: InFile - Input source.
- * sfunc - Pointer to the function to be called if the section
- * name is successfully read.
- *
- * Output: true if the section name was read and true was returned from
- * <sfunc>. false if <sfunc> failed or if a lexical error was
- * encountered.
- *
- * ------------------------------------------------------------------------ **
- */
- {
- int c;
- int i;
- int end;
- const char *func = "params.c:Section() -";
-
- i = 0; /* <i> is the offset of the next free byte in bufr[] and */
- end = 0; /* <end> is the current "end of string" offset. In most */
- /* cases these will be the same, but if the last */
- /* character written to bufr[] is a space, then <end> */
- /* will be one less than <i>. */
-
- c = EatWhitespace( InFile ); /* We've already got the '['. Scan */
- /* past initial white space. */
-
- while( (EOF != c) && (c > 0) )
- {
-
- /* Check that the buffer is big enough for the next character. */
- if( i > (InFile->bSize - 2) )
- {
- char *tb;
-
- tb = talloc_realloc(InFile, InFile->bufr, char, InFile->bSize + BUFR_INC);
- if( NULL == tb )
- {
- DEBUG(0, ("%s Memory re-allocation failure.", func) );
- return( false );
- }
- InFile->bufr = tb;
- InFile->bSize += BUFR_INC;
- }
-
- /* Handle a single character. */
- switch( c )
- {
- case ']': /* Found the closing bracket. */
- InFile->bufr[end] = '\0';
- if( 0 == end ) /* Don't allow an empty name. */
- {
- DEBUG(0, ("%s Empty section name in configuration file.\n", func ));
- return( false );
- }
- if( !sfunc(InFile->bufr,userdata) ) /* Got a valid name. Deal with it. */
- return( false );
- (void)EatComment( InFile ); /* Finish off the line. */
- return( true );
-
- case '\n': /* Got newline before closing ']'. */
- i = Continuation( InFile->bufr, i ); /* Check for line continuation. */
- if( i < 0 )
- {
- InFile->bufr[end] = '\0';
- DEBUG(0, ("%s Badly formed line in configuration file: %s\n",
- func, InFile->bufr ));
- return( false );
- }
- end = ( (i > 0) && (' ' == InFile->bufr[i - 1]) ) ? (i - 1) : (i);
- c = mygetc( InFile ); /* Continue with next line. */
- break;
-
- default: /* All else are a valid name chars. */
- if( isspace( c ) ) /* One space per whitespace region. */
- {
- InFile->bufr[end] = ' ';
- i = end + 1;
- c = EatWhitespace( InFile );
- }
- else /* All others copy verbatim. */
- {
- InFile->bufr[i++] = c;
- end = i;
- c = mygetc( InFile );
- }
- }
- }
-
- /* We arrive here if we've met the EOF before the closing bracket. */
- DEBUG(0, ("%s Unexpected EOF in the configuration file\n", func));
- return( false );
- } /* Section */
-
-static bool Parameter( myFILE *InFile, bool (*pfunc)(const char *, const char *, void *), int c, void *userdata )
- /* ------------------------------------------------------------------------ **
- * Scan a parameter name and value, and pass these two fields to pfunc().
- *
- * Input: InFile - The input source.
- * pfunc - A pointer to the function that will be called to
- * process the parameter, once it has been scanned.
- * c - The first character of the parameter name, which
- * would have been read by Parse(). Unlike a comment
- * line or a section header, there is no lead-in
- * character that can be discarded.
- *
- * Output: true if the parameter name and value were scanned and processed
- * successfully, else false.
- *
- * Notes: This function is in two parts. The first loop scans the
- * parameter name. Internal whitespace is compressed, and an
- * equal sign (=) terminates the token. Leading and trailing
- * whitespace is discarded. The second loop scans the parameter
- * value. When both have been successfully identified, they are
- * passed to pfunc() for processing.
- *
- * ------------------------------------------------------------------------ **
- */
- {
- int i = 0; /* Position within bufr. */
- int end = 0; /* bufr[end] is current end-of-string. */
- int vstart = 0; /* Starting position of the parameter value. */
- const char *func = "params.c:Parameter() -";
-
- /* Read the parameter name. */
- while( 0 == vstart ) /* Loop until we've found the start of the value. */
- {
-
- if( i > (InFile->bSize - 2) ) /* Ensure there's space for next char. */
- {
- char *tb;
-
- tb = talloc_realloc(InFile, InFile->bufr, char, InFile->bSize + BUFR_INC );
- if( NULL == tb )
- {
- DEBUG(0, ("%s Memory re-allocation failure.", func) );
- return( false );
- }
- InFile->bufr = tb;
- InFile->bSize += BUFR_INC;
- }
-
- switch( c )
- {
- case '=': /* Equal sign marks end of param name. */
- if( 0 == end ) /* Don't allow an empty name. */
- {
- DEBUG(0, ("%s Invalid parameter name in config. file.\n", func ));
- return( false );
- }
- InFile->bufr[end++] = '\0'; /* Mark end of string & advance. */
- i = end; /* New string starts here. */
- vstart = end; /* New string is parameter value. */
- InFile->bufr[i] = '\0'; /* New string is nul, for now. */
- break;
-
- case '\n': /* Find continuation char, else error. */
- i = Continuation( InFile->bufr, i );
- if( i < 0 )
- {
- InFile->bufr[end] = '\0';
- DEBUG(1,("%s Ignoring badly formed line in configuration file: %s\n",
- func, InFile->bufr ));
- return( true );
- }
- end = ( (i > 0) && (' ' == InFile->bufr[i - 1]) ) ? (i - 1) : (i);
- c = mygetc( InFile ); /* Read past eoln. */
- break;
-
- case '\0': /* Shouldn't have EOF within param name. */
- case EOF:
- InFile->bufr[i] = '\0';
- DEBUG(1,("%s Unexpected end-of-file at: %s\n", func, InFile->bufr ));
- return( true );
-
- default:
- if( isspace( c ) ) /* One ' ' per whitespace region. */
- {
- InFile->bufr[end] = ' ';
- i = end + 1;
- c = EatWhitespace( InFile );
- }
- else /* All others verbatim. */
- {
- InFile->bufr[i++] = c;
- end = i;
- c = mygetc( InFile );
- }
- }
- }
-
- /* Now parse the value. */
- c = EatWhitespace( InFile ); /* Again, trim leading whitespace. */
- while( (EOF !=c) && (c > 0) )
- {
-
- if( i > (InFile->bSize - 2) ) /* Make sure there's enough room. */
- {
- char *tb;
-
- tb = talloc_realloc(InFile, InFile->bufr, char, InFile->bSize + BUFR_INC );
- if( NULL == tb )
- {
- DEBUG(0, ("%s Memory re-allocation failure.", func) );
- return( false );
- }
- InFile->bufr = tb;
- InFile->bSize += BUFR_INC;
- }
-
- switch( c )
- {
- case '\r': /* Explicitly remove '\r' because the older */
- c = mygetc( InFile ); /* version called fgets_slash() which also */
- break; /* removes them. */
-
- case '\n': /* Marks end of value unless there's a '\'. */
- i = Continuation( InFile->bufr, i );
- if( i < 0 )
- c = 0;
- else
- {
- for( end = i; (end >= 0) && isspace((int)InFile->bufr[end]); end-- )
- ;
- c = mygetc( InFile );
- }
- break;
-
- default: /* All others verbatim. Note that spaces do */
- InFile->bufr[i++] = c; /* not advance <end>. This allows trimming */
- if( !isspace( c ) ) /* of whitespace at the end of the line. */
- end = i;
- c = mygetc( InFile );
- break;
- }
- }
- InFile->bufr[end] = '\0'; /* End of value. */
-
- return( pfunc( InFile->bufr, &InFile->bufr[vstart], userdata ) ); /* Pass name & value to pfunc(). */
- } /* Parameter */
-
-static bool Parse( myFILE *InFile,
- bool (*sfunc)(const char *, void *),
- bool (*pfunc)(const char *, const char *, void *),
- void *userdata )
- /* ------------------------------------------------------------------------ **
- * Scan & parse the input.
- *
- * Input: InFile - Input source.
- * sfunc - Function to be called when a section name is scanned.
- * See Section().
- * pfunc - Function to be called when a parameter is scanned.
- * See Parameter().
- *
- * Output: true if the file was successfully scanned, else false.
- *
- * Notes: The input can be viewed in terms of 'lines'. There are four
- * types of lines:
- * Blank - May contain whitespace, otherwise empty.
- * Comment - First non-whitespace character is a ';' or '#'.
- * The remainder of the line is ignored.
- * Section - First non-whitespace character is a '['.
- * Parameter - The default case.
- *
- * ------------------------------------------------------------------------ **
- */
- {
- int c;
-
- c = EatWhitespace( InFile );
- while( (EOF != c) && (c > 0) )
- {
- switch( c )
- {
- case '\n': /* Blank line. */
- c = EatWhitespace( InFile );
- break;
-
- case ';': /* Comment line. */
- case '#':
- c = EatComment( InFile );
- break;
-
- case '[': /* Section Header. */
- if( !Section( InFile, sfunc, userdata ) )
- return( false );
- c = EatWhitespace( InFile );
- break;
-
- case '\\': /* Bogus backslash. */
- c = EatWhitespace( InFile );
- break;
-
- default: /* Parameter line. */
- if( !Parameter( InFile, pfunc, c, userdata ) )
- return( false );
- c = EatWhitespace( InFile );
- break;
- }
- }
- return( true );
- } /* Parse */
-
-static myFILE *OpenConfFile( const char *FileName )
- /* ------------------------------------------------------------------------ **
- * Open a configuration file.
- *
- * Input: FileName - The pathname of the config file to be opened.
- *
- * Output: A pointer of type (char **) to the lines of the file
- *
- * ------------------------------------------------------------------------ **
- */
- {
- const char *func = "params.c:OpenConfFile() -";
- myFILE *ret;
-
- ret = talloc(talloc_autofree_context(), myFILE);
- if (!ret) return NULL;
-
- ret->buf = file_load(FileName, &ret->size, ret);
- if( NULL == ret->buf )
- {
- DEBUG( 1,
- ("%s Unable to open configuration file \"%s\":\n\t%s\n",
- func, FileName, strerror(errno)) );
- talloc_free(ret);
- return NULL;
- }
-
- ret->p = ret->buf;
- ret->bufr = NULL;
- ret->bSize = 0;
- return( ret );
- } /* OpenConfFile */
-
-bool pm_process( const char *FileName,
- bool (*sfunc)(const char *, void *),
- bool (*pfunc)(const char *, const char *, void *),
- void *userdata)
- /* ------------------------------------------------------------------------ **
- * Process the named parameter file.
- *
- * Input: FileName - The pathname of the parameter file to be opened.
- * sfunc - A pointer to a function that will be called when
- * a section name is discovered.
- * pfunc - A pointer to a function that will be called when
- * a parameter name and value are discovered.
- *
- * Output: TRUE if the file was successfully parsed, else FALSE.
- *
- * ------------------------------------------------------------------------ **
- */
- {
- int result;
- myFILE *InFile;
- const char *func = "params.c:pm_process() -";
-
- InFile = OpenConfFile( FileName ); /* Open the config file. */
- if( NULL == InFile )
- return( false );
-
- DEBUG( 3, ("%s Processing configuration file \"%s\"\n", func, FileName) );
-
- if( NULL != InFile->bufr ) /* If we already have a buffer */
- result = Parse( InFile, sfunc, pfunc, userdata ); /* (recursive call), then just */
- /* use it. */
-
- else /* If we don't have a buffer */
- { /* allocate one, then parse, */
- InFile->bSize = BUFR_INC; /* then free. */
- InFile->bufr = talloc_array(InFile, char, InFile->bSize );
- if( NULL == InFile->bufr )
- {
- DEBUG(0,("%s memory allocation failure.\n", func));
- myfile_close(InFile);
- return( false );
- }
- result = Parse( InFile, sfunc, pfunc, userdata );
- InFile->bufr = NULL;
- InFile->bSize = 0;
- }
-
- myfile_close(InFile);
-
- if( !result ) /* Generic failure. */
- {
- DEBUG(0,("%s Failed. Error returned from params.c:parse().\n", func));
- return( false );
- }
-
- return( true ); /* Generic success. */
- } /* pm_process */
-
-/* -------------------------------------------------------------------------- */
diff --git a/source4/lib/util/safe_string.h b/source4/lib/util/safe_string.h
deleted file mode 100644
index a6c052f874..0000000000
--- a/source4/lib/util/safe_string.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Safe string handling routines.
- Copyright (C) Andrew Tridgell 1994-1998
-
- 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 _SAFE_STRING_H
-#define _SAFE_STRING_H
-
-#ifndef _SPLINT_ /* http://www.splint.org */
-/* Some macros to ensure people don't use buffer overflow vulnerable string
- functions. */
-
-#ifdef strcpy
-#undef strcpy
-#endif /* strcpy */
-#define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
-
-#ifdef strcat
-#undef strcat
-#endif /* strcat */
-#define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
-
-#ifdef sprintf
-#undef sprintf
-#endif /* sprintf */
-#define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
-
-#endif /* !_SPLINT_ */
-
-#endif
diff --git a/source4/lib/util/signal.c b/source4/lib/util/signal.c
deleted file mode 100644
index ead947eb5e..0000000000
--- a/source4/lib/util/signal.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- signal handling functions
-
- Copyright (C) Andrew Tridgell 1998
-
- 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/wait.h"
-
-/**
- * @file
- * @brief Signal handling
- */
-
-/****************************************************************************
- Catch child exits and reap the child zombie status.
-****************************************************************************/
-
-static void sig_cld(int signum)
-{
- while (waitpid((pid_t)-1,(int *)NULL, WNOHANG) > 0)
- ;
-
- /*
- * Turns out it's *really* important not to
- * restore the signal handler here if we have real POSIX
- * signal handling. If we do, then we get the signal re-delivered
- * immediately - hey presto - instant loop ! JRA.
- */
-
-#if !defined(HAVE_SIGACTION)
- CatchSignal(SIGCLD, sig_cld);
-#endif
-}
-
-/****************************************************************************
-catch child exits - leave status;
-****************************************************************************/
-
-static void sig_cld_leave_status(int signum)
-{
- /*
- * Turns out it's *really* important not to
- * restore the signal handler here if we have real POSIX
- * signal handling. If we do, then we get the signal re-delivered
- * immediately - hey presto - instant loop ! JRA.
- */
-
-#if !defined(HAVE_SIGACTION)
- CatchSignal(SIGCLD, sig_cld_leave_status);
-#endif
-}
-
-/**
- Block sigs.
-**/
-
-void BlockSignals(bool block, int signum)
-{
-#ifdef HAVE_SIGPROCMASK
- sigset_t set;
- sigemptyset(&set);
- sigaddset(&set,signum);
- sigprocmask(block?SIG_BLOCK:SIG_UNBLOCK,&set,NULL);
-#elif defined(HAVE_SIGBLOCK)
- if (block) {
- sigblock(sigmask(signum));
- } else {
- sigsetmask(siggetmask() & ~sigmask(signum));
- }
-#else
- /* yikes! This platform can't block signals? */
- static int done;
- if (!done) {
- DEBUG(0,("WARNING: No signal blocking available\n"));
- done=1;
- }
-#endif
-}
-
-/**
- Catch a signal. This should implement the following semantics:
-
- 1) The handler remains installed after being called.
- 2) The signal should be blocked during handler execution.
-**/
-
-void (*CatchSignal(int signum,void (*handler)(int )))(int)
-{
-#ifdef HAVE_SIGACTION
- struct sigaction act;
- struct sigaction oldact;
-
- ZERO_STRUCT(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);
- return oldact.sa_handler;
-#else /* !HAVE_SIGACTION */
- /* FIXME: need to handle sigvec and systems with broken signal() */
- return signal(signum, handler);
-#endif
-}
-
-/**
- Ignore SIGCLD via whatever means is necessary for this OS.
-**/
-
-void CatchChild(void)
-{
- CatchSignal(SIGCLD, sig_cld);
-}
-
-/**
- Catch SIGCLD but leave the child around so it's status can be reaped.
-**/
-
-void CatchChildLeaveStatus(void)
-{
- CatchSignal(SIGCLD, sig_cld_leave_status);
-}
diff --git a/source4/lib/util/signal.m4 b/source4/lib/util/signal.m4
deleted file mode 100644
index c6d7f72f68..0000000000
--- a/source4/lib/util/signal.m4
+++ /dev/null
@@ -1 +0,0 @@
-AC_CHECK_FUNCS(sigprocmask sigblock sigaction)
diff --git a/source4/lib/util/system.c b/source4/lib/util/system.c
deleted file mode 100644
index 9bd1800233..0000000000
--- a/source4/lib/util/system.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba system utilities
- Copyright (C) Andrew Tridgell 1992-1998
- Copyright (C) Jeremy Allison 1998-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/>.
-*/
-
-#include "includes.h"
-#include "system/network.h"
-#include "system/filesys.h"
-
-/*
- The idea is that this file will eventually have wrappers around all
- important system calls in samba. The aims are:
-
- - to enable easier porting by putting OS dependent stuff in here
-
- - to allow for hooks into other "pseudo-filesystems"
-
- - to allow easier integration of things like the japanese extensions
-
- - to support the philosophy of Samba to expose the features of
- the OS within the SMB model. In general whatever file/printer/variable
- expansions/etc make sense to the OS should be acceptable to Samba.
-*/
-
-/**************************************************************************
-A wrapper for gethostbyname() that tries avoids looking up hostnames
-in the root domain, which can cause dial-on-demand links to come up for no
-apparent reason.
-****************************************************************************/
-
-_PUBLIC_ struct hostent *sys_gethostbyname(const char *name)
-{
-#ifdef REDUCE_ROOT_DNS_LOOKUPS
- char query[256], hostname[256];
- char *domain;
-
- /* Does this name have any dots in it? If so, make no change */
-
- if (strchr(name, '.'))
- return(gethostbyname(name));
-
- /* Get my hostname, which should have domain name
- attached. If not, just do the gethostname on the
- original string.
- */
-
- gethostname(hostname, sizeof(hostname) - 1);
- hostname[sizeof(hostname) - 1] = 0;
- if ((domain = strchr(hostname, '.')) == NULL)
- return(gethostbyname(name));
-
- /* Attach domain name to query and do modified query.
- If names too large, just do gethostname on the
- original string.
- */
-
- if((strlen(name) + strlen(domain)) >= sizeof(query))
- return(gethostbyname(name));
-
- slprintf(query, sizeof(query)-1, "%s%s", name, domain);
- return(gethostbyname(query));
-#else /* REDUCE_ROOT_DNS_LOOKUPS */
- return(gethostbyname(name));
-#endif /* REDUCE_ROOT_DNS_LOOKUPS */
-}
-
-_PUBLIC_ struct in_addr sys_inet_makeaddr(int net, int host)
-{
- struct in_addr in;
- struct in_addr in2;
- in = inet_makeaddr(net, host);
- in2.s_addr = in.s_addr;
- return in2;
-}
-
diff --git a/source4/lib/util/tests/file.c b/source4/lib/util/tests/file.c
deleted file mode 100644
index 3377e833dc..0000000000
--- a/source4/lib/util/tests/file.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- util_file testing
-
- Copyright (C) Jelmer Vernooij 2005
-
- 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/filesys.h"
-#include "torture/torture.h"
-
-#define TEST_FILENAME "utilfile.test"
-#define TEST_LINE1 "This is list line 1..."
-#define TEST_LINE2 ".. and this is line 2"
-#define TEST_LINE3 "and end of the file"
-
-#define TEST_DATA TEST_LINE1 "\n" TEST_LINE2 "\n" TEST_LINE3
-
-static bool test_file_load_save(struct torture_context *tctx)
-{
- size_t len;
- char *data;
- TALLOC_CTX *mem_ctx = tctx;
-
- torture_assert(tctx, file_save(TEST_FILENAME, TEST_DATA, strlen(TEST_DATA)),
- "saving file");
-
- torture_assert_file_contains_text(tctx, TEST_FILENAME, TEST_DATA,
- "file contents");
-
- data = file_load(TEST_FILENAME, &len, mem_ctx);
- torture_assert(tctx, data, "loading file");
-
- torture_assert_int_equal(tctx, len, strlen(TEST_DATA), "Length");
-
- torture_assert_mem_equal(tctx, data, TEST_DATA, len, "Contents");
-
- unlink(TEST_FILENAME);
- return true;
-}
-
-
-static bool test_afdgets(struct torture_context *tctx)
-{
- int fd;
- char *line;
- TALLOC_CTX *mem_ctx = tctx;
-
- torture_assert(tctx, file_save(TEST_FILENAME, (const void *)TEST_DATA,
- strlen(TEST_DATA)),
- "saving file");
-
- fd = open(TEST_FILENAME, O_RDONLY);
-
- torture_assert(tctx, fd != -1, "opening file");
-
- line = afdgets(fd, mem_ctx, 8);
- torture_assert(tctx, strcmp(line, TEST_LINE1) == 0, "line 1 mismatch");
-
- line = afdgets(fd, mem_ctx, 8);
- torture_assert(tctx, strcmp(line, TEST_LINE2) == 0, "line 2 mismatch");
-
- line = afdgets(fd, mem_ctx, 8);
- torture_assert(tctx, strcmp(line, TEST_LINE3) == 0, "line 3 mismatch");
-
- close(fd);
-
- unlink(TEST_FILENAME);
- return true;
-}
-
-struct torture_suite *torture_local_util_file(TALLOC_CTX *mem_ctx)
-{
- struct torture_suite *suite = torture_suite_create(mem_ctx, "FILE");
-
- torture_suite_add_simple_test(suite, "file_load_save",
- test_file_load_save);
-
- torture_suite_add_simple_test(suite, "afdgets",
- test_afdgets);
-
- return suite;
-}
diff --git a/source4/lib/util/tests/genrand.c b/source4/lib/util/tests/genrand.c
deleted file mode 100644
index 5fe229c089..0000000000
--- a/source4/lib/util/tests/genrand.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- local testing of random data routines.
-
- Copyright (C) Jelmer Vernooij <jelmer@samba.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 "torture/torture.h"
-
-static void dummy_reseed(void *userdata, int *d)
-{
- *d = 42;
-}
-
-static bool test_reseed_callback(struct torture_context *tctx)
-{
- set_rand_reseed_callback(dummy_reseed, NULL);
- return true;
-}
-
-static bool test_check_password_quality(struct torture_context *tctx)
-{
- torture_assert(tctx, !check_password_quality(""), "empty password");
- torture_assert(tctx, !check_password_quality("a"), "one char password");
- torture_assert(tctx, !check_password_quality("aaaaaaaaaaaa"), "same char password");
- torture_assert(tctx, !check_password_quality("BLA"), "multiple upcases password");
- torture_assert(tctx, !check_password_quality("123"), "digits only");
- torture_assert(tctx, check_password_quality("A2e"), "valid");
- torture_assert(tctx, check_password_quality("BA2eLi443"), "valid");
- return true;
-}
-
-static bool test_generate_random_str(struct torture_context *tctx)
-{
- TALLOC_CTX *mem_ctx = talloc_init(__FUNCTION__);
- char *r = generate_random_str(mem_ctx, 10);
- torture_assert_int_equal(tctx, strlen(r), 10, "right length generated");
- r = generate_random_str(mem_ctx, 5);
- torture_assert_int_equal(tctx, strlen(r), 5, "right length generated");
- return true;
-}
-
-struct torture_suite *torture_local_genrand(TALLOC_CTX *mem_ctx)
-{
- struct torture_suite *suite = torture_suite_create(mem_ctx, "GENRAND");
- torture_suite_add_simple_test(suite, "reseed_callback", test_reseed_callback);
- torture_suite_add_simple_test(suite, "check_password_quality", test_check_password_quality);
- torture_suite_add_simple_test(suite, "generate_random_str", test_generate_random_str);
- return suite;
-}
diff --git a/source4/lib/util/tests/idtree.c b/source4/lib/util/tests/idtree.c
deleted file mode 100644
index d89fb8c489..0000000000
--- a/source4/lib/util/tests/idtree.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- local testing of idtree routines.
-
- Copyright (C) Andrew Tridgell 2004
-
- 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"
-
-static bool torture_local_idtree_simple(struct torture_context *tctx)
-{
- struct idr_context *idr;
- int i, ret;
- int *ids;
- int *present;
- extern int torture_numops;
- int n = torture_numops;
- TALLOC_CTX *mem_ctx = tctx;
-
- idr = idr_init(mem_ctx);
-
- ids = talloc_zero_array(mem_ctx, int, n);
- present = talloc_zero_array(mem_ctx, int, n);
-
- for (i=0;i<n;i++) {
- ids[i] = -1;
- }
-
- for (i=0;i<n;i++) {
- int ii = random() % n;
- void *p = idr_find(idr, ids[ii]);
- if (present[ii]) {
- if (p != &ids[ii]) {
- torture_fail(tctx, talloc_asprintf(tctx,
- "wrong ptr at %d - %p should be %p",
- ii, p, &ids[ii]));
- }
- if (random() % 7 == 0) {
- if (idr_remove(idr, ids[ii]) != 0) {
- torture_fail(tctx, talloc_asprintf(tctx,
- "remove failed at %d (id=%d)",
- i, ids[ii]));
- }
- present[ii] = 0;
- ids[ii] = -1;
- }
- } else {
- if (p != NULL) {
- torture_fail(tctx,
- talloc_asprintf(tctx,
- "non-present at %d gave %p (would be %d)",
- ii, p,
- (int)((((char *)p) - (char *)(&ids[0])) / sizeof(int))));
- }
- if (random() % 5) {
- ids[ii] = idr_get_new(idr, &ids[ii], n);
- if (ids[ii] < 0) {
- torture_fail(tctx, talloc_asprintf(tctx,
- "alloc failure at %d (ret=%d)",
- ii, ids[ii]));
- } else {
- present[ii] = 1;
- }
- }
- }
- }
-
- torture_comment(tctx, "done %d random ops\n", i);
-
- for (i=0;i<n;i++) {
- if (present[i]) {
- if (idr_remove(idr, ids[i]) != 0) {
- torture_fail(tctx, talloc_asprintf(tctx,
- "delete failed on cleanup at %d (id=%d)",
- i, ids[i]));
- }
- }
- }
-
- /* now test some limits */
- for (i=0;i<25000;i++) {
- ret = idr_get_new_above(idr, &ids[0], random() % 25000, 0x10000-3);
- torture_assert(tctx, ret != -1, "idr_get_new_above failed");
- }
-
- ret = idr_get_new_above(idr, &ids[0], 0x10000-2, 0x10000);
- torture_assert_int_equal(tctx, ret, 0x10000-2, "idr_get_new_above failed");
- ret = idr_get_new_above(idr, &ids[0], 0x10000-1, 0x10000);
- torture_assert_int_equal(tctx, ret, 0x10000-1, "idr_get_new_above failed");
- ret = idr_get_new_above(idr, &ids[0], 0x10000, 0x10000);
- torture_assert_int_equal(tctx, ret, 0x10000, "idr_get_new_above failed");
- ret = idr_get_new_above(idr, &ids[0], 0x10000+1, 0x10000);
- torture_assert_int_equal(tctx, ret, -1, "idr_get_new_above succeeded above limit");
- ret = idr_get_new_above(idr, &ids[0], 0x10000+2, 0x10000);
- torture_assert_int_equal(tctx, ret, -1, "idr_get_new_above succeeded above limit");
-
- torture_comment(tctx, "cleaned up\n");
- return true;
-}
-
-struct torture_suite *torture_local_idtree(TALLOC_CTX *mem_ctx)
-{
- struct torture_suite *suite = torture_suite_create(mem_ctx, "IDTREE");
- torture_suite_add_simple_test(suite, "idtree", torture_local_idtree_simple);
- return suite;
-}
diff --git a/source4/lib/util/tests/str.c b/source4/lib/util/tests/str.c
deleted file mode 100644
index 3bd6a02fdc..0000000000
--- a/source4/lib/util/tests/str.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- util_str testing
-
- 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/>.
-*/
-
-#include "includes.h"
-#include "torture/torture.h"
-
-static bool test_string_sub_simple(struct torture_context *tctx)
-{
- char tmp[100];
- safe_strcpy(tmp, "foobar", sizeof(tmp));
- string_sub(tmp, "foo", "bar", sizeof(tmp));
- torture_assert_str_equal(tctx, tmp, "barbar", "invalid sub");
- return true;
-}
-
-static bool test_string_sub_multiple(struct torture_context *tctx)
-{
- char tmp[100];
- safe_strcpy(tmp, "fooblafoo", sizeof(tmp));
- string_sub(tmp, "foo", "bar", sizeof(tmp));
- torture_assert_str_equal(tctx, tmp, "barblabar", "invalid sub");
- return true;
-}
-
-static bool test_string_sub_longer(struct torture_context *tctx)
-{
- char tmp[100];
- safe_strcpy(tmp, "foobla", sizeof(tmp));
- string_sub(tmp, "foo", "blie", sizeof(tmp));
- torture_assert_str_equal(tctx, tmp, "bliebla", "invalid sub");
- return true;
-}
-
-static bool test_string_sub_shorter(struct torture_context *tctx)
-{
- char tmp[100];
- safe_strcpy(tmp, "foobla", sizeof(tmp));
- string_sub(tmp, "foo", "bl", sizeof(tmp));
- torture_assert_str_equal(tctx, tmp, "blbla", "invalid sub");
- return true;
-}
-
-static bool test_string_sub_special_char(struct torture_context *tctx)
-{
- char tmp[100];
- safe_strcpy(tmp, "foobla", sizeof(tmp));
- string_sub(tmp, "foo", "%b;l", sizeof(tmp));
- torture_assert_str_equal(tctx, tmp, "_b_lbla", "invalid sub");
- return true;
-}
-
-static bool test_string_sub_talloc_simple(struct torture_context *tctx)
-{
- char *t;
-
- t = string_sub_talloc(tctx, "foobla", "foo", "bl");
-
- torture_assert_str_equal(tctx, t, "blbla", "invalid sub");
-
- return true;
-}
-
-static bool test_string_sub_talloc_multiple(struct torture_context *tctx)
-{
- char *t;
-
- t = string_sub_talloc(tctx, "fooblafoo", "foo", "aapnootmies");
-
- torture_assert_str_equal(tctx, t, "aapnootmiesblaaapnootmies",
- "invalid sub");
-
- return true;
-}
-
-
-
-struct torture_suite *torture_local_util_str(TALLOC_CTX *mem_ctx)
-{
- struct torture_suite *suite = torture_suite_create(mem_ctx, "STR");
-
- torture_suite_add_simple_test(suite, "string_sub_simple",
- test_string_sub_simple);
-
- torture_suite_add_simple_test(suite, "string_sub_multiple",
- test_string_sub_multiple);
-
- torture_suite_add_simple_test(suite, "string_sub_shorter",
- test_string_sub_shorter);
-
- torture_suite_add_simple_test(suite, "string_sub_longer",
- test_string_sub_longer);
-
- torture_suite_add_simple_test(suite, "string_sub_special_chars",
- test_string_sub_special_char);
-
- torture_suite_add_simple_test(suite, "string_sub_talloc_simple",
- test_string_sub_talloc_simple);
-
- torture_suite_add_simple_test(suite, "string_sub_talloc_multiple",
- test_string_sub_talloc_multiple);
-
- return suite;
-}
diff --git a/source4/lib/util/tests/strlist.c b/source4/lib/util/tests/strlist.c
deleted file mode 100644
index 9af26f9e71..0000000000
--- a/source4/lib/util/tests/strlist.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- util_strlist testing
-
- Copyright (C) Jelmer Vernooij 2005
-
- 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"
-
-static const char *test_lists_shell_strings[] = {
- "",
- "foo",
- "foo bar",
- "foo bar \"bla \"",
- "foo \"\" bla",
- "bla \"\"\"\" blie",
- NULL
-};
-
-static bool test_lists_shell(struct torture_context *tctx,
- const void *test_data)
-{
- const char *data = (const char *)test_data;
- const char **ret1, **ret2, *tmp;
- bool match = true;
- TALLOC_CTX *mem_ctx = tctx;
-
- ret1 = str_list_make_shell(mem_ctx, data, " ");
- tmp = str_list_join_shell(mem_ctx, ret1, ' ');
- ret2 = str_list_make_shell(mem_ctx, tmp, " ");
-
- if ((ret1 == NULL || ret2 == NULL) && ret2 != ret1) {
- match = false;
- } else {
- int j;
- for (j = 0; ret1[j] && ret2[j]; j++) {
- if (strcmp(ret1[j], ret2[j]) != 0) {
- match = false;
- break;
- }
- }
-
- if (ret1[j] || ret2[j])
- match = false;
- }
-
- torture_assert(tctx, match, talloc_asprintf(tctx,
- "str_list_{make,join}_shell: Error double parsing, first run:\n%s\nSecond run: \n%s", data, tmp));
- return true;
-}
-
-static bool test_list_copy(struct torture_context *tctx)
-{
- const char **result;
- const char *list[] = { "foo", "bar", NULL };
- const char *empty_list[] = { NULL };
- const char **null_list = NULL;
-
- result = str_list_copy(tctx, list);
- torture_assert_int_equal(tctx, str_list_length(result), 2, "list length");
- torture_assert_str_equal(tctx, result[0], "foo", "element 0");
- torture_assert_str_equal(tctx, result[1], "bar", "element 1");
- torture_assert_str_equal(tctx, result[2], NULL, "element 2");
-
- result = str_list_copy(tctx, empty_list);
- torture_assert_int_equal(tctx, str_list_length(result), 0, "list length");
- torture_assert_str_equal(tctx, result[0], NULL, "element 0");
-
- result = str_list_copy(tctx, null_list);
- torture_assert(tctx, result == NULL, "result NULL");
-
- return true;
-}
-
-struct torture_suite *torture_local_util_strlist(TALLOC_CTX *mem_ctx)
-{
- struct torture_suite *suite = torture_suite_create(mem_ctx, "STRLIST");
- int i;
-
- for (i = 0; test_lists_shell_strings[i]; i++) {
- torture_suite_add_simple_tcase_const(suite, "lists_shell",
- test_lists_shell, &test_lists_shell_strings[i]);
- }
-
- torture_suite_add_simple_test(suite, "list_copy", test_list_copy);
-
- return suite;
-}
diff --git a/source4/lib/util/time.c b/source4/lib/util/time.c
deleted file mode 100644
index 978d73cc0a..0000000000
--- a/source4/lib/util/time.c
+++ /dev/null
@@ -1,622 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- time handling functions
-
- Copyright (C) Andrew Tridgell 1992-2004
- Copyright (C) Stefan (metze) Metzmacher 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/>.
-*/
-
-#include "includes.h"
-#include "system/time.h"
-
-/**
- * @file
- * @brief time handling functions
- */
-
-#ifndef TIME_T_MIN
-/* we use 0 here, because (time_t)-1 means error */
-#define TIME_T_MIN 0
-#endif
-
-/*
- * we use the INT32_MAX here as on 64 bit systems,
- * gmtime() fails with INT64_MAX
- */
-
-#ifndef TIME_T_MAX
-#define TIME_T_MAX MIN(INT32_MAX,_TYPE_MAXIMUM(time_t))
-#endif
-
-/**
- External access to time_t_min and time_t_max.
-**/
-_PUBLIC_ time_t get_time_t_max(void)
-{
- return TIME_T_MAX;
-}
-
-/**
-a gettimeofday wrapper
-**/
-_PUBLIC_ void GetTimeOfDay(struct timeval *tval)
-{
-#ifdef HAVE_GETTIMEOFDAY_TZ
- gettimeofday(tval,NULL);
-#else
- gettimeofday(tval);
-#endif
-}
-
-
-#define TIME_FIXUP_CONSTANT 11644473600LL
-
-/**
-interpret an 8 byte "filetime" structure to a time_t
-It's originally in "100ns units since jan 1st 1601"
-**/
-_PUBLIC_ time_t nt_time_to_unix(NTTIME nt)
-{
- if (nt == 0) {
- return 0;
- }
- if (nt == -1LL) {
- return (time_t)-1;
- }
- nt += 1000*1000*10/2;
- nt /= 1000*1000*10;
- nt -= TIME_FIXUP_CONSTANT;
-
- if (TIME_T_MIN > nt || nt > TIME_T_MAX) {
- return 0;
- }
-
- return (time_t)nt;
-}
-
-
-/**
-put a 8 byte filetime from a time_t
-This takes GMT as input
-**/
-_PUBLIC_ void unix_to_nt_time(NTTIME *nt, time_t t)
-{
- uint64_t t2;
-
- if (t == (time_t)-1) {
- *nt = (NTTIME)-1LL;
- return;
- }
- if (t == 0) {
- *nt = 0;
- return;
- }
-
- t2 = t;
- t2 += TIME_FIXUP_CONSTANT;
- t2 *= 1000*1000*10;
-
- *nt = t2;
-}
-
-
-/**
-check if it's a null unix time
-**/
-_PUBLIC_ bool null_time(time_t t)
-{
- return t == 0 ||
- t == (time_t)0xFFFFFFFF ||
- t == (time_t)-1;
-}
-
-
-/**
-check if it's a null NTTIME
-**/
-_PUBLIC_ bool null_nttime(NTTIME t)
-{
- return t == 0 || t == (NTTIME)-1;
-}
-
-/*******************************************************************
- create a 16 bit dos packed date
-********************************************************************/
-static uint16_t make_dos_date1(struct tm *t)
-{
- uint16_t ret=0;
- ret = (((unsigned int)(t->tm_mon+1)) >> 3) | ((t->tm_year-80) << 1);
- ret = ((ret&0xFF)<<8) | (t->tm_mday | (((t->tm_mon+1) & 0x7) << 5));
- return ret;
-}
-
-/*******************************************************************
- create a 16 bit dos packed time
-********************************************************************/
-static uint16_t make_dos_time1(struct tm *t)
-{
- uint16_t ret=0;
- ret = ((((unsigned int)t->tm_min >> 3)&0x7) | (((unsigned int)t->tm_hour) << 3));
- ret = ((ret&0xFF)<<8) | ((t->tm_sec/2) | ((t->tm_min & 0x7) << 5));
- return ret;
-}
-
-/*******************************************************************
- create a 32 bit dos packed date/time from some parameters
- This takes a GMT time and returns a packed localtime structure
-********************************************************************/
-static uint32_t make_dos_date(time_t unixdate, int zone_offset)
-{
- struct tm *t;
- uint32_t ret=0;
-
- if (unixdate == 0) {
- return 0;
- }
-
- unixdate -= zone_offset;
-
- t = gmtime(&unixdate);
- if (!t) {
- return 0xFFFFFFFF;
- }
-
- ret = make_dos_date1(t);
- ret = ((ret&0xFFFF)<<16) | make_dos_time1(t);
-
- return ret;
-}
-
-/**
-put a dos date into a buffer (time/date format)
-This takes GMT time and puts local time in the buffer
-**/
-_PUBLIC_ void push_dos_date(uint8_t *buf, int offset, time_t unixdate, int zone_offset)
-{
- uint32_t x = make_dos_date(unixdate, zone_offset);
- SIVAL(buf,offset,x);
-}
-
-/**
-put a dos date into a buffer (date/time format)
-This takes GMT time and puts local time in the buffer
-**/
-_PUBLIC_ void push_dos_date2(uint8_t *buf,int offset,time_t unixdate, int zone_offset)
-{
- uint32_t x;
- x = make_dos_date(unixdate, zone_offset);
- x = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
- SIVAL(buf,offset,x);
-}
-
-/**
-put a dos 32 bit "unix like" date into a buffer. This routine takes
-GMT and converts it to LOCAL time before putting it (most SMBs assume
-localtime for this sort of date)
-**/
-_PUBLIC_ void push_dos_date3(uint8_t *buf,int offset,time_t unixdate, int zone_offset)
-{
- if (!null_time(unixdate)) {
- unixdate -= zone_offset;
- }
- SIVAL(buf,offset,unixdate);
-}
-
-/*******************************************************************
- interpret a 32 bit dos packed date/time to some parameters
-********************************************************************/
-static void interpret_dos_date(uint32_t date,int *year,int *month,int *day,int *hour,int *minute,int *second)
-{
- uint32_t p0,p1,p2,p3;
-
- p0=date&0xFF; p1=((date&0xFF00)>>8)&0xFF;
- p2=((date&0xFF0000)>>16)&0xFF; p3=((date&0xFF000000)>>24)&0xFF;
-
- *second = 2*(p0 & 0x1F);
- *minute = ((p0>>5)&0xFF) + ((p1&0x7)<<3);
- *hour = (p1>>3)&0xFF;
- *day = (p2&0x1F);
- *month = ((p2>>5)&0xFF) + ((p3&0x1)<<3) - 1;
- *year = ((p3>>1)&0xFF) + 80;
-}
-
-/**
- create a unix date (int GMT) from a dos date (which is actually in
- localtime)
-**/
-_PUBLIC_ time_t pull_dos_date(const uint8_t *date_ptr, int zone_offset)
-{
- uint32_t dos_date=0;
- struct tm t;
- time_t ret;
-
- dos_date = IVAL(date_ptr,0);
-
- if (dos_date == 0) return (time_t)0;
-
- interpret_dos_date(dos_date,&t.tm_year,&t.tm_mon,
- &t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec);
- t.tm_isdst = -1;
-
- ret = timegm(&t);
-
- ret += zone_offset;
-
- return ret;
-}
-
-/**
-like make_unix_date() but the words are reversed
-**/
-_PUBLIC_ time_t pull_dos_date2(const uint8_t *date_ptr, int zone_offset)
-{
- uint32_t x,x2;
-
- x = IVAL(date_ptr,0);
- x2 = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
- SIVAL(&x,0,x2);
-
- return pull_dos_date((const uint8_t *)&x, zone_offset);
-}
-
-/**
- create a unix GMT date from a dos date in 32 bit "unix like" format
- these generally arrive as localtimes, with corresponding DST
-**/
-_PUBLIC_ time_t pull_dos_date3(const uint8_t *date_ptr, int zone_offset)
-{
- time_t t = (time_t)IVAL(date_ptr,0);
- if (!null_time(t)) {
- t += zone_offset;
- }
- return t;
-}
-
-
-/**
-return a HTTP/1.0 time string
-**/
-_PUBLIC_ char *http_timestring(TALLOC_CTX *mem_ctx, time_t t)
-{
- char *buf;
- char tempTime[60];
- struct tm *tm = localtime(&t);
-
- if (!tm) {
- return talloc_asprintf(mem_ctx,"%ld seconds since the Epoch",(long)t);
- }
-
-#ifndef HAVE_STRFTIME
- buf = talloc_strdup(mem_ctx, asctime(tm));
- if (buf[strlen(buf)-1] == '\n') {
- buf[strlen(buf)-1] = 0;
- }
-#else
- strftime(tempTime, sizeof(tempTime)-1, "%a, %d %b %Y %H:%M:%S %Z", tm);
- buf = talloc_strdup(mem_ctx, tempTime);
-#endif /* !HAVE_STRFTIME */
-
- return buf;
-}
-
-/**
- Return the date and time as a string
-**/
-_PUBLIC_ char *timestring(TALLOC_CTX *mem_ctx, time_t t)
-{
- char *TimeBuf;
- char tempTime[80];
- struct tm *tm;
-
- tm = localtime(&t);
- if (!tm) {
- return talloc_asprintf(mem_ctx,
- "%ld seconds since the Epoch",
- (long)t);
- }
-
-#ifdef HAVE_STRFTIME
- /* some versions of gcc complain about using %c. This is a bug
- in the gcc warning, not a bug in this code. See a recent
- strftime() manual page for details.
- */
- strftime(tempTime,sizeof(tempTime)-1,"%c %Z",tm);
- TimeBuf = talloc_strdup(mem_ctx, tempTime);
-#else
- TimeBuf = talloc_strdup(mem_ctx, asctime(tm));
-#endif
-
- return TimeBuf;
-}
-
-/**
- return a talloced string representing a NTTIME for human consumption
-*/
-_PUBLIC_ const char *nt_time_string(TALLOC_CTX *mem_ctx, NTTIME nt)
-{
- time_t t;
- if (nt == 0) {
- return "NTTIME(0)";
- }
- t = nt_time_to_unix(nt);
- return timestring(mem_ctx, t);
-}
-
-
-/**
- put a NTTIME into a packet
-*/
-_PUBLIC_ void push_nttime(uint8_t *base, uint16_t offset, NTTIME t)
-{
- SBVAL(base, offset, t);
-}
-
-/**
- pull a NTTIME from a packet
-*/
-_PUBLIC_ NTTIME pull_nttime(uint8_t *base, uint16_t offset)
-{
- NTTIME ret = BVAL(base, offset);
- return ret;
-}
-
-/**
- return (tv1 - tv2) in microseconds
-*/
-_PUBLIC_ int64_t usec_time_diff(const struct timeval *tv1, const struct timeval *tv2)
-{
- int64_t sec_diff = tv1->tv_sec - tv2->tv_sec;
- return (sec_diff * 1000000) + (int64_t)(tv1->tv_usec - tv2->tv_usec);
-}
-
-
-/**
- return a zero timeval
-*/
-_PUBLIC_ struct timeval timeval_zero(void)
-{
- struct timeval tv;
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- return tv;
-}
-
-/**
- return true if a timeval is zero
-*/
-_PUBLIC_ bool timeval_is_zero(const struct timeval *tv)
-{
- return tv->tv_sec == 0 && tv->tv_usec == 0;
-}
-
-/**
- return a timeval for the current time
-*/
-_PUBLIC_ struct timeval timeval_current(void)
-{
- struct timeval tv;
- GetTimeOfDay(&tv);
- return tv;
-}
-
-/**
- return a timeval struct with the given elements
-*/
-_PUBLIC_ struct timeval timeval_set(uint32_t secs, uint32_t usecs)
-{
- struct timeval tv;
- tv.tv_sec = secs;
- tv.tv_usec = usecs;
- return tv;
-}
-
-
-/**
- return a timeval ofs microseconds after tv
-*/
-_PUBLIC_ struct timeval timeval_add(const struct timeval *tv,
- uint32_t secs, uint32_t usecs)
-{
- struct timeval tv2 = *tv;
- const unsigned int million = 1000000;
- tv2.tv_sec += secs;
- tv2.tv_usec += usecs;
- tv2.tv_sec += tv2.tv_usec / million;
- tv2.tv_usec = tv2.tv_usec % million;
- return tv2;
-}
-
-/**
- return the sum of two timeval structures
-*/
-struct timeval timeval_sum(const struct timeval *tv1,
- const struct timeval *tv2)
-{
- return timeval_add(tv1, tv2->tv_sec, tv2->tv_usec);
-}
-
-/**
- return a timeval secs/usecs into the future
-*/
-_PUBLIC_ struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs)
-{
- struct timeval tv = timeval_current();
- return timeval_add(&tv, secs, usecs);
-}
-
-/**
- compare two timeval structures.
- Return -1 if tv1 < tv2
- Return 0 if tv1 == tv2
- Return 1 if tv1 > tv2
-*/
-_PUBLIC_ int timeval_compare(const struct timeval *tv1, const struct timeval *tv2)
-{
- if (tv1->tv_sec > tv2->tv_sec) return 1;
- if (tv1->tv_sec < tv2->tv_sec) return -1;
- if (tv1->tv_usec > tv2->tv_usec) return 1;
- if (tv1->tv_usec < tv2->tv_usec) return -1;
- return 0;
-}
-
-/**
- return true if a timer is in the past
-*/
-_PUBLIC_ bool timeval_expired(const struct timeval *tv)
-{
- struct timeval tv2 = timeval_current();
- if (tv2.tv_sec > tv->tv_sec) return true;
- if (tv2.tv_sec < tv->tv_sec) return false;
- return (tv2.tv_usec >= tv->tv_usec);
-}
-
-/**
- return the number of seconds elapsed between two times
-*/
-_PUBLIC_ double timeval_elapsed2(const struct timeval *tv1, const struct timeval *tv2)
-{
- return (tv2->tv_sec - tv1->tv_sec) +
- (tv2->tv_usec - tv1->tv_usec)*1.0e-6;
-}
-
-/**
- return the number of seconds elapsed since a given time
-*/
-_PUBLIC_ double timeval_elapsed(const struct timeval *tv)
-{
- struct timeval tv2 = timeval_current();
- return timeval_elapsed2(tv, &tv2);
-}
-
-/**
- return the lesser of two timevals
-*/
-_PUBLIC_ struct timeval timeval_min(const struct timeval *tv1,
- const struct timeval *tv2)
-{
- if (tv1->tv_sec < tv2->tv_sec) return *tv1;
- if (tv1->tv_sec > tv2->tv_sec) return *tv2;
- if (tv1->tv_usec < tv2->tv_usec) return *tv1;
- return *tv2;
-}
-
-/**
- return the greater of two timevals
-*/
-_PUBLIC_ struct timeval timeval_max(const struct timeval *tv1,
- const struct timeval *tv2)
-{
- if (tv1->tv_sec > tv2->tv_sec) return *tv1;
- if (tv1->tv_sec < tv2->tv_sec) return *tv2;
- if (tv1->tv_usec > tv2->tv_usec) return *tv1;
- return *tv2;
-}
-
-/**
- return the difference between two timevals as a timeval
- if tv1 comes after tv2, then return a zero timeval
- (this is *tv2 - *tv1)
-*/
-_PUBLIC_ struct timeval timeval_until(const struct timeval *tv1,
- const struct timeval *tv2)
-{
- struct timeval t;
- if (timeval_compare(tv1, tv2) >= 0) {
- return timeval_zero();
- }
- t.tv_sec = tv2->tv_sec - tv1->tv_sec;
- if (tv1->tv_usec > tv2->tv_usec) {
- t.tv_sec--;
- t.tv_usec = 1000000 - (tv1->tv_usec - tv2->tv_usec);
- } else {
- t.tv_usec = tv2->tv_usec - tv1->tv_usec;
- }
- return t;
-}
-
-
-/**
- convert a timeval to a NTTIME
-*/
-_PUBLIC_ NTTIME timeval_to_nttime(const struct timeval *tv)
-{
- return 10*(tv->tv_usec +
- ((TIME_FIXUP_CONSTANT + (uint64_t)tv->tv_sec) * 1000000));
-}
-
-/**
- convert a NTTIME to a timeval
-*/
-_PUBLIC_ void nttime_to_timeval(struct timeval *tv, NTTIME t)
-{
- if (tv == NULL) return;
-
- t += 10/2;
- t /= 10;
- t -= TIME_FIXUP_CONSTANT*1000*1000;
-
- tv->tv_sec = t / 1000000;
-
- if (TIME_T_MIN > tv->tv_sec || tv->tv_sec > TIME_T_MAX) {
- tv->tv_sec = 0;
- tv->tv_usec = 0;
- return;
- }
-
- tv->tv_usec = t - tv->tv_sec*1000000;
-}
-
-/*******************************************************************
-yield the difference between *A and *B, in seconds, ignoring leap seconds
-********************************************************************/
-static int tm_diff(struct tm *a, struct tm *b)
-{
- int ay = a->tm_year + (1900 - 1);
- int by = b->tm_year + (1900 - 1);
- int intervening_leap_days =
- (ay/4 - by/4) - (ay/100 - by/100) + (ay/400 - by/400);
- int years = ay - by;
- int days = 365*years + intervening_leap_days + (a->tm_yday - b->tm_yday);
- int hours = 24*days + (a->tm_hour - b->tm_hour);
- int minutes = 60*hours + (a->tm_min - b->tm_min);
- int seconds = 60*minutes + (a->tm_sec - b->tm_sec);
-
- return seconds;
-}
-
-/**
- return the UTC offset in seconds west of UTC, or 0 if it cannot be determined
- */
-_PUBLIC_ int get_time_zone(time_t t)
-{
- struct tm *tm = gmtime(&t);
- struct tm tm_utc;
- if (!tm)
- return 0;
- tm_utc = *tm;
- tm = localtime(&t);
- if (!tm)
- return 0;
- return tm_diff(&tm_utc,tm);
-}
-
-/**
- check if 2 NTTIMEs are equal.
-*/
-bool nt_time_equal(NTTIME *t1, NTTIME *t2)
-{
- return *t1 == *t2;
-}
diff --git a/source4/lib/util/time.h b/source4/lib/util/time.h
deleted file mode 100644
index e4008c5782..0000000000
--- a/source4/lib/util/time.h
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- time utility functions
-
- 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 _SAMBA_TIME_H_
-#define _SAMBA_TIME_H_
-
-#ifndef _PUBLIC_
-#define _PUBLIC_
-#endif
-
-/* 64 bit time (100 nanosec) 1601 - cifs6.txt, section 3.5, page 30, 4 byte aligned */
-typedef uint64_t NTTIME;
-
-/**
- External access to time_t_min and time_t_max.
-**/
-_PUBLIC_ time_t get_time_t_max(void);
-
-/**
-a gettimeofday wrapper
-**/
-_PUBLIC_ void GetTimeOfDay(struct timeval *tval);
-
-/**
-interpret an 8 byte "filetime" structure to a time_t
-It's originally in "100ns units since jan 1st 1601"
-**/
-_PUBLIC_ time_t nt_time_to_unix(NTTIME nt);
-
-/**
-put a 8 byte filetime from a time_t
-This takes GMT as input
-**/
-_PUBLIC_ void unix_to_nt_time(NTTIME *nt, time_t t);
-
-/**
-check if it's a null unix time
-**/
-_PUBLIC_ bool null_time(time_t t);
-
-/**
-check if it's a null NTTIME
-**/
-_PUBLIC_ bool null_nttime(NTTIME t);
-
-/**
-put a dos date into a buffer (time/date format)
-This takes GMT time and puts local time in the buffer
-**/
-_PUBLIC_ void push_dos_date(uint8_t *buf, int offset, time_t unixdate, int zone_offset);
-
-/**
-put a dos date into a buffer (date/time format)
-This takes GMT time and puts local time in the buffer
-**/
-_PUBLIC_ void push_dos_date2(uint8_t *buf,int offset,time_t unixdate, int zone_offset);
-
-/**
-put a dos 32 bit "unix like" date into a buffer. This routine takes
-GMT and converts it to LOCAL time before putting it (most SMBs assume
-localtime for this sort of date)
-**/
-_PUBLIC_ void push_dos_date3(uint8_t *buf,int offset,time_t unixdate, int zone_offset);
-
-/**
- create a unix date (int GMT) from a dos date (which is actually in
- localtime)
-**/
-_PUBLIC_ time_t pull_dos_date(const uint8_t *date_ptr, int zone_offset);
-
-/**
-like make_unix_date() but the words are reversed
-**/
-_PUBLIC_ time_t pull_dos_date2(const uint8_t *date_ptr, int zone_offset);
-
-/**
- create a unix GMT date from a dos date in 32 bit "unix like" format
- these generally arrive as localtimes, with corresponding DST
-**/
-_PUBLIC_ time_t pull_dos_date3(const uint8_t *date_ptr, int zone_offset);
-
-/**
-return a HTTP/1.0 time string
-**/
-_PUBLIC_ char *http_timestring(TALLOC_CTX *mem_ctx, time_t t);
-
-/**
- Return the date and time as a string
-**/
-_PUBLIC_ char *timestring(TALLOC_CTX *mem_ctx, time_t t);
-
-/**
- return a talloced string representing a NTTIME for human consumption
-*/
-_PUBLIC_ const char *nt_time_string(TALLOC_CTX *mem_ctx, NTTIME nt);
-
-/**
- put a NTTIME into a packet
-*/
-_PUBLIC_ void push_nttime(uint8_t *base, uint16_t offset, NTTIME t);
-
-/**
- pull a NTTIME from a packet
-*/
-_PUBLIC_ NTTIME pull_nttime(uint8_t *base, uint16_t offset);
-
-/**
- parse a nttime as a large integer in a string and return a NTTIME
-*/
-_PUBLIC_ NTTIME nttime_from_string(const char *s);
-
-/**
- return (tv1 - tv2) in microseconds
-*/
-_PUBLIC_ int64_t usec_time_diff(const struct timeval *tv1, const struct timeval *tv2);
-
-/**
- return a zero timeval
-*/
-_PUBLIC_ struct timeval timeval_zero(void);
-
-/**
- return true if a timeval is zero
-*/
-_PUBLIC_ bool timeval_is_zero(const struct timeval *tv);
-
-/**
- return a timeval for the current time
-*/
-_PUBLIC_ struct timeval timeval_current(void);
-
-/**
- return a timeval struct with the given elements
-*/
-_PUBLIC_ struct timeval timeval_set(uint32_t secs, uint32_t usecs);
-
-/**
- return a timeval ofs microseconds after tv
-*/
-_PUBLIC_ struct timeval timeval_add(const struct timeval *tv,
- uint32_t secs, uint32_t usecs);
-
-/**
- return the sum of two timeval structures
-*/
-struct timeval timeval_sum(const struct timeval *tv1,
- const struct timeval *tv2);
-
-/**
- return a timeval secs/usecs into the future
-*/
-_PUBLIC_ struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs);
-
-/**
- compare two timeval structures.
- Return -1 if tv1 < tv2
- Return 0 if tv1 == tv2
- Return 1 if tv1 > tv2
-*/
-_PUBLIC_ int timeval_compare(const struct timeval *tv1, const struct timeval *tv2);
-
-/**
- return true if a timer is in the past
-*/
-_PUBLIC_ bool timeval_expired(const struct timeval *tv);
-
-/**
- return the number of seconds elapsed between two times
-*/
-_PUBLIC_ double timeval_elapsed2(const struct timeval *tv1, const struct timeval *tv2);
-
-/**
- return the number of seconds elapsed since a given time
-*/
-_PUBLIC_ double timeval_elapsed(const struct timeval *tv);
-
-/**
- return the lesser of two timevals
-*/
-_PUBLIC_ struct timeval timeval_min(const struct timeval *tv1,
- const struct timeval *tv2);
-
-/**
- return the greater of two timevals
-*/
-_PUBLIC_ struct timeval timeval_max(const struct timeval *tv1,
- const struct timeval *tv2);
-
-/**
- return the difference between two timevals as a timeval
- if tv1 comes after tv2, then return a zero timeval
- (this is *tv2 - *tv1)
-*/
-_PUBLIC_ struct timeval timeval_until(const struct timeval *tv1,
- const struct timeval *tv2);
-
-/**
- convert a timeval to a NTTIME
-*/
-_PUBLIC_ NTTIME timeval_to_nttime(const struct timeval *tv);
-
-/**
- convert a NTTIME to a timeval
-*/
-_PUBLIC_ void nttime_to_timeval(struct timeval *tv, NTTIME t);
-
-/**
- return the UTC offset in seconds west of UTC, or 0 if it cannot be determined
- */
-_PUBLIC_ int get_time_zone(time_t t);
-
-/**
- check if 2 NTTIMEs are equal.
-*/
-bool nt_time_equal(NTTIME *t1, NTTIME *t2);
-
-#endif /* _SAMBA_TIME_H_ */
diff --git a/source4/lib/util/time.m4 b/source4/lib/util/time.m4
deleted file mode 100644
index f61ae4cd25..0000000000
--- a/source4/lib/util/time.m4
+++ /dev/null
@@ -1,9 +0,0 @@
-AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
-AC_TRY_RUN([
-#include <sys/time.h>
-#include <unistd.h>
-main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
- samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
-if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
- AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday() is available])
-fi
diff --git a/source4/lib/util/unix_privs.c b/source4/lib/util/unix_privs.c
deleted file mode 100644
index 47c172dcfa..0000000000
--- a/source4/lib/util/unix_privs.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- gain/lose root privileges
-
- Copyright (C) Andrew Tridgell 2004
-
- 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/filesys.h"
-
-/**
- * @file
- * @brief Gaining/losing root privileges
- */
-
-/*
- there are times when smbd needs to temporarily gain root privileges
- to do some operation. To do this you call root_privileges(), which
- returns a talloc handle. To restore your previous privileges
- talloc_free() this pointer.
-
- Note that this call is considered successful even if it does not
- manage to gain root privileges, but it will call smb_abort() if it
- fails to restore the privileges afterwards. The logic is that
- failing to gain root access can be caught by whatever operation
- needs to be run as root failing, but failing to lose the root
- privileges is dangerous.
-
- This also means that this code is safe to be called from completely
- unprivileged processes.
-*/
-
-struct saved_state {
- uid_t uid;
-};
-
-static int privileges_destructor(struct saved_state *s)
-{
- if (geteuid() != s->uid &&
- seteuid(s->uid) != 0) {
- smb_panic("Failed to restore privileges");
- }
- return 0;
-}
-
-/**
- * Obtain root privileges for the current process.
- *
- * The privileges can be dropped by talloc_free()-ing the
- * token returned by this function
- */
-void *root_privileges(void)
-{
- struct saved_state *s;
- s = talloc(NULL, struct saved_state);
- if (!s) return NULL;
- s->uid = geteuid();
- if (s->uid != 0) {
- seteuid(0);
- }
- talloc_set_destructor(s, privileges_destructor);
- return s;
-}
diff --git a/source4/lib/util/util.c b/source4/lib/util/util.c
deleted file mode 100644
index b5bb75358e..0000000000
--- a/source4/lib/util/util.c
+++ /dev/null
@@ -1,599 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba utility functions
- Copyright (C) Andrew Tridgell 1992-1998
- Copyright (C) Jeremy Allison 2001-2002
- Copyright (C) Simo Sorce 2001
- Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
- Copyright (C) James J Myers 2003
-
- 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 "system/filesys.h"
-#include "system/locale.h"
-
-/**
- * @file
- * @brief Misc utility functions
- */
-
-/**
- Find a suitable temporary directory. The result should be copied immediately
- as it may be overwritten by a subsequent call.
-**/
-_PUBLIC_ const char *tmpdir(void)
-{
- char *p;
- if ((p = getenv("TMPDIR")))
- return p;
- return "/tmp";
-}
-
-
-/**
- Check if a file exists - call vfs_file_exist for samba files.
-**/
-_PUBLIC_ bool file_exist(const char *fname)
-{
- struct stat st;
-
- if (stat(fname, &st) != 0) {
- return false;
- }
-
- return ((S_ISREG(st.st_mode)) || (S_ISFIFO(st.st_mode)));
-}
-
-/**
- Check a files mod time.
-**/
-
-_PUBLIC_ time_t file_modtime(const char *fname)
-{
- struct stat st;
-
- if (stat(fname,&st) != 0)
- return(0);
-
- return(st.st_mtime);
-}
-
-/**
- Check if a directory exists.
-**/
-
-_PUBLIC_ bool directory_exist(const char *dname)
-{
- struct stat st;
- bool ret;
-
- if (stat(dname,&st) != 0) {
- return false;
- }
-
- ret = S_ISDIR(st.st_mode);
- if(!ret)
- errno = ENOTDIR;
- return ret;
-}
-
-/**
- * Try to create the specified directory if it didn't exist.
- *
- * @retval true if the directory already existed and has the right permissions
- * or was successfully created.
- */
-_PUBLIC_ bool directory_create_or_exist(const char *dname, uid_t uid,
- mode_t dir_perms)
-{
- mode_t old_umask;
- struct stat st;
-
- old_umask = umask(0);
- if (lstat(dname, &st) == -1) {
- if (errno == ENOENT) {
- /* Create directory */
- if (mkdir(dname, dir_perms) == -1) {
- DEBUG(0, ("error creating directory "
- "%s: %s\n", dname,
- strerror(errno)));
- umask(old_umask);
- return false;
- }
- } else {
- DEBUG(0, ("lstat failed on directory %s: %s\n",
- dname, strerror(errno)));
- umask(old_umask);
- return false;
- }
- } else {
- /* Check ownership and permission on existing directory */
- if (!S_ISDIR(st.st_mode)) {
- DEBUG(0, ("directory %s isn't a directory\n",
- dname));
- umask(old_umask);
- return false;
- }
- if ((st.st_uid != uid) ||
- ((st.st_mode & 0777) != dir_perms)) {
- DEBUG(0, ("invalid permissions on directory "
- "%s\n", dname));
- umask(old_umask);
- return false;
- }
- }
- return true;
-}
-
-
-/**
- Set a fd into blocking/nonblocking mode. Uses POSIX O_NONBLOCK if available,
- else
- if SYSV use O_NDELAY
- if BSD use FNDELAY
-**/
-
-_PUBLIC_ int set_blocking(int fd, bool set)
-{
- int val;
-#ifdef O_NONBLOCK
-#define FLAG_TO_SET O_NONBLOCK
-#else
-#ifdef SYSV
-#define FLAG_TO_SET O_NDELAY
-#else /* BSD */
-#define FLAG_TO_SET FNDELAY
-#endif
-#endif
-
- if((val = fcntl(fd, F_GETFL, 0)) == -1)
- return -1;
- if(set) /* Turn blocking on - ie. clear nonblock flag */
- val &= ~FLAG_TO_SET;
- else
- val |= FLAG_TO_SET;
- return fcntl( fd, F_SETFL, val);
-#undef FLAG_TO_SET
-}
-
-
-/**
- Sleep for a specified number of milliseconds.
-**/
-
-_PUBLIC_ void msleep(unsigned int t)
-{
- struct timeval tval;
-
- tval.tv_sec = t/1000;
- tval.tv_usec = 1000*(t%1000);
- /* this should be the real select - do NOT replace
- with sys_select() */
- select(0,NULL,NULL,NULL,&tval);
-}
-
-/**
- Get my own name, return in malloc'ed storage.
-**/
-
-_PUBLIC_ char *get_myname(void)
-{
- char *hostname;
- char *p;
-
- hostname = (char *)malloc(MAXHOSTNAMELEN+1);
- *hostname = 0;
-
- /* get my host name */
- if (gethostname(hostname, MAXHOSTNAMELEN+1) == -1) {
- DEBUG(0,("gethostname failed\n"));
- return NULL;
- }
-
- /* Ensure null termination. */
- hostname[MAXHOSTNAMELEN] = '\0';
-
- /* split off any parts after an initial . */
- p = strchr(hostname, '.');
-
- if (p != NULL)
- *p = 0;
-
- return hostname;
-}
-
-/**
- Return true if a string could be a pure IP address.
-**/
-
-_PUBLIC_ bool is_ipaddress(const char *str)
-{
- bool pure_address = true;
- int i;
-
- if (str == NULL) return false;
-
- for (i=0; pure_address && str[i]; i++)
- if (!(isdigit((int)str[i]) || str[i] == '.'))
- pure_address = false;
-
- /* Check that a pure number is not misinterpreted as an IP */
- pure_address = pure_address && (strchr(str, '.') != NULL);
-
- return pure_address;
-}
-
-/**
- Interpret an internet address or name into an IP address in 4 byte form.
-**/
-_PUBLIC_ uint32_t interpret_addr(const char *str)
-{
- struct hostent *hp;
- uint32_t res;
-
- if (str == NULL || *str == 0 ||
- strcmp(str,"0.0.0.0") == 0) {
- return 0;
- }
- if (strcmp(str,"255.255.255.255") == 0) {
- return 0xFFFFFFFF;
- }
- /* recognise 'localhost' as a special name. This fixes problems with
- some hosts that don't have localhost in /etc/hosts */
- if (strcasecmp(str,"localhost") == 0) {
- str = "127.0.0.1";
- }
-
- /* if it's in the form of an IP address then get the lib to interpret it */
- if (is_ipaddress(str)) {
- res = inet_addr(str);
- } else {
- /* otherwise assume it's a network name of some sort and use
- sys_gethostbyname */
- if ((hp = sys_gethostbyname(str)) == 0) {
- DEBUG(3,("sys_gethostbyname: Unknown host. %s\n",str));
- return 0;
- }
-
- if(hp->h_addr == NULL) {
- DEBUG(3,("sys_gethostbyname: host address is invalid for host %s\n",str));
- return 0;
- }
- memcpy((char *)&res,(char *)hp->h_addr, 4);
- }
-
- if (res == (uint32_t)-1)
- return(0);
-
- return(res);
-}
-
-/**
- A convenient addition to interpret_addr().
-**/
-_PUBLIC_ struct in_addr interpret_addr2(const char *str)
-{
- struct in_addr ret;
- uint32_t a = interpret_addr(str);
- ret.s_addr = a;
- return ret;
-}
-
-/**
- Check if an IP is the 0.0.0.0.
-**/
-
-_PUBLIC_ bool is_zero_ip(struct in_addr ip)
-{
- return ip.s_addr == 0;
-}
-
-/**
- Are two IPs on the same subnet?
-**/
-
-_PUBLIC_ bool same_net(struct in_addr ip1, struct in_addr ip2, struct in_addr mask)
-{
- uint32_t net1,net2,nmask;
-
- nmask = ntohl(mask.s_addr);
- net1 = ntohl(ip1.s_addr);
- net2 = ntohl(ip2.s_addr);
-
- return((net1 & nmask) == (net2 & nmask));
-}
-
-
-/**
- Check if a process exists. Does this work on all unixes?
-**/
-
-_PUBLIC_ bool process_exists(pid_t pid)
-{
- /* Doing kill with a non-positive pid causes messages to be
- * sent to places we don't want. */
- SMB_ASSERT(pid > 0);
- return(kill(pid,0) == 0 || errno != ESRCH);
-}
-
-/**
- Simple routine to do POSIX file locking. Cruft in NFS and 64->32 bit mapping
- is dealt with in posix.c
-**/
-
-_PUBLIC_ bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type)
-{
- struct flock lock;
- int ret;
-
- DEBUG(8,("fcntl_lock %d %d %.0f %.0f %d\n",fd,op,(double)offset,(double)count,type));
-
- lock.l_type = type;
- lock.l_whence = SEEK_SET;
- lock.l_start = offset;
- lock.l_len = count;
- lock.l_pid = 0;
-
- ret = fcntl(fd,op,&lock);
-
- if (ret == -1 && errno != 0)
- DEBUG(3,("fcntl_lock: fcntl lock gave errno %d (%s)\n",errno,strerror(errno)));
-
- /* a lock query */
- if (op == F_GETLK) {
- if ((ret != -1) &&
- (lock.l_type != F_UNLCK) &&
- (lock.l_pid != 0) &&
- (lock.l_pid != getpid())) {
- DEBUG(3,("fcntl_lock: fd %d is locked by pid %d\n",fd,(int)lock.l_pid));
- return true;
- }
-
- /* it must be not locked or locked by me */
- return false;
- }
-
- /* a lock set or unset */
- if (ret == -1) {
- DEBUG(3,("fcntl_lock: lock failed at offset %.0f count %.0f op %d type %d (%s)\n",
- (double)offset,(double)count,op,type,strerror(errno)));
- return false;
- }
-
- /* everything went OK */
- DEBUG(8,("fcntl_lock: Lock call successful\n"));
-
- return true;
-}
-
-
-static void print_asc(int level, const uint8_t *buf,int len)
-{
- int i;
- for (i=0;i<len;i++)
- DEBUGADD(level,("%c", isprint(buf[i])?buf[i]:'.'));
-}
-
-/**
- * Write dump of binary data to the log file.
- *
- * The data is only written if the log level is at least level.
- */
-static void _dump_data(int level, const uint8_t *buf, int len,
- bool omit_zero_bytes)
-{
- int i=0;
- const uint8_t empty[16];
- bool skipped = false;
-
- if (len<=0) return;
-
- if (!DEBUGLVL(level)) return;
-
- memset(&empty, '\0', 16);
-
- for (i=0;i<len;) {
-
- if (i%16 == 0) {
- if ((omit_zero_bytes == true) &&
- (i > 0) &&
- (len > i+16) &&
- (memcmp(&buf[i], &empty, 16) == 0))
- {
- i +=16;
- continue;
- }
-
- if (i<len) {
- DEBUGADD(level,("[%04X] ",i));
- }
- }
-
- DEBUGADD(level,("%02X ",(int)buf[i]));
- i++;
- if (i%8 == 0) DEBUGADD(level,(" "));
- if (i%16 == 0) {
-
- print_asc(level,&buf[i-16],8); DEBUGADD(level,(" "));
- print_asc(level,&buf[i-8],8); DEBUGADD(level,("\n"));
-
- if ((omit_zero_bytes == true) &&
- (len > i+16) &&
- (memcmp(&buf[i], &empty, 16) == 0)) {
- if (!skipped) {
- DEBUGADD(level,("skipping zero buffer bytes\n"));
- skipped = true;
- }
- }
- }
- }
-
- if (i%16) {
- int n;
- n = 16 - (i%16);
- DEBUGADD(level,(" "));
- if (n>8) DEBUGADD(level,(" "));
- while (n--) DEBUGADD(level,(" "));
- n = MIN(8,i%16);
- print_asc(level,&buf[i-(i%16)],n); DEBUGADD(level,( " " ));
- n = (i%16) - n;
- if (n>0) print_asc(level,&buf[i-n],n);
- DEBUGADD(level,("\n"));
- }
-
-}
-
-/**
- * Write dump of binary data to the log file.
- *
- * The data is only written if the log level is at least level.
- */
-_PUBLIC_ void dump_data(int level, const uint8_t *buf, int len)
-{
- _dump_data(level, buf, len, false);
-}
-
-/**
- * Write dump of binary data to the log file.
- *
- * The data is only written if the log level is at least level.
- * 16 zero bytes in a row are ommited
- */
-_PUBLIC_ void dump_data_skip_zeros(int level, const uint8_t *buf, int len)
-{
- _dump_data(level, buf, len, true);
-}
-
-
-/**
- malloc that aborts with smb_panic on fail or zero size.
-**/
-
-_PUBLIC_ void *smb_xmalloc(size_t size)
-{
- void *p;
- if (size == 0)
- smb_panic("smb_xmalloc: called with zero size.\n");
- if ((p = malloc(size)) == NULL)
- smb_panic("smb_xmalloc: malloc fail.\n");
- return p;
-}
-
-/**
- Memdup with smb_panic on fail.
-**/
-
-_PUBLIC_ void *smb_xmemdup(const void *p, size_t size)
-{
- void *p2;
- p2 = smb_xmalloc(size);
- memcpy(p2, p, size);
- return p2;
-}
-
-/**
- strdup that aborts on malloc fail.
-**/
-
-_PUBLIC_ char *smb_xstrdup(const char *s)
-{
- char *s1 = strdup(s);
- if (!s1)
- smb_panic("smb_xstrdup: malloc fail\n");
- return s1;
-}
-
-
-/**
- Like strdup but for memory.
-**/
-
-_PUBLIC_ void *memdup(const void *p, size_t size)
-{
- void *p2;
- if (size == 0)
- return NULL;
- p2 = malloc(size);
- if (!p2)
- return NULL;
- memcpy(p2, p, size);
- return p2;
-}
-
-/**
- * Write a password to the log file.
- *
- * @note Only actually does something if DEBUG_PASSWORD was defined during
- * compile-time.
- */
-_PUBLIC_ void dump_data_pw(const char *msg, const uint8_t * data, size_t len)
-{
-#ifdef DEBUG_PASSWORD
- DEBUG(11, ("%s", msg));
- if (data != NULL && len > 0)
- {
- dump_data(11, data, len);
- }
-#endif
-}
-
-
-/**
- * see if a range of memory is all zero. A NULL pointer is considered
- * to be all zero
- */
-_PUBLIC_ bool all_zero(const uint8_t *ptr, size_t size)
-{
- int i;
- if (!ptr) return true;
- for (i=0;i<size;i++) {
- if (ptr[i]) return false;
- }
- return true;
-}
-
-/**
- realloc an array, checking for integer overflow in the array size
-*/
-_PUBLIC_ void *realloc_array(void *ptr, size_t el_size, unsigned count)
-{
-#define MAX_MALLOC_SIZE 0x7fffffff
- if (count == 0 ||
- count >= MAX_MALLOC_SIZE/el_size) {
- return NULL;
- }
- if (!ptr) {
- return malloc(el_size * count);
- }
- return realloc(ptr, el_size * count);
-}
-
-_PUBLIC_ void *talloc_check_name_abort(const void *ptr, const char *name)
-{
- void *result;
-
- result = talloc_check_name(ptr, name);
- if (result != NULL)
- return result;
-
- DEBUG(0, ("Talloc type mismatch, expected %s, got %s\n",
- name, talloc_get_name(ptr)));
- smb_panic("talloc type mismatch");
- /* Keep the compiler happy */
- return NULL;
-}
-
diff --git a/source4/lib/util/util.h b/source4/lib/util/util.h
deleted file mode 100644
index ffe83c14b2..0000000000
--- a/source4/lib/util/util.h
+++ /dev/null
@@ -1,813 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Utility functions for Samba
- Copyright (C) Andrew Tridgell 1992-1999
- Copyright (C) Jelmer Vernooij 2005
-
- 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 _SAMBA_UTIL_H_
-#define _SAMBA_UTIL_H_
-
-#include "util/attr.h"
-
-#include "charset/charset.h"
-
-/* for TALLOC_CTX */
-#include <talloc.h>
-
-/**
- * @file
- * @brief Helpful macros
- */
-
-struct smbsrv_tcon;
-
-extern const char *logfile;
-extern const char *panic_action;
-
-#include "util/time.h"
-#include "util/data_blob.h"
-#include "util/xfile.h"
-#include "util/debug.h"
-#include "util/mutex.h"
-#include "util/byteorder.h"
-
-/**
- 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.
-*/
-#ifndef discard_const
-#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
-#endif
-
-/** Type-safe version of discard_const */
-#ifndef discard_const_p
-#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
-#endif
-
-/**
- * assert macros
- */
-#define SMB_ASSERT(b) do { if (!(b)) { \
- DEBUG(0,("PANIC: assert failed at %s(%d)\n", __FILE__, __LINE__)); \
- smb_panic("assert failed"); }} while (0)
-
-#ifndef SAFE_FREE /* Oh no this is also defined in tdb.h */
-/**
- * Free memory if the pointer and zero the pointer.
- *
- * @note You are explicitly allowed to pass NULL pointers -- they will
- * always be ignored.
- **/
-#define SAFE_FREE(x) do { if ((x) != NULL) {free(discard_const_p(void *, (x))); (x)=NULL;} } while(0)
-#endif
-
-/**
- * Type-safe version of malloc. Allocated one copy of the
- * specified data type.
- */
-#define malloc_p(type) (type *)malloc(sizeof(type))
-
-/**
- * Allocate an array of elements of one data type. Does type-checking.
- */
-#define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count)
-
-/**
- * Resize an array of elements of one data type. Does type-checking.
- */
-#define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count)
-
-#if defined(VALGRIND)
-#define strlen(x) valgrind_strlen(x)
-#endif
-
-/**
- * zero a structure
- */
-#ifndef ZERO_STRUCT
-#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
-#endif
-
-/**
- * zero a structure given a pointer to the structure
- */
-#ifndef ZERO_STRUCTP
-#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)
-#endif
-
-/**
- * zero a structure given a pointer to the structure - no zero check
- */
-#ifndef ZERO_STRUCTPN
-#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x)))
-#endif
-
-/* zero an array - note that sizeof(array) must work - ie. it must not be a
- pointer */
-#ifndef ZERO_ARRAY
-#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x))
-#endif
-
-/**
- * work out how many elements there are in a static array
- */
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
-#endif
-
-/**
- * pointer difference macro
- */
-#ifndef PTR_DIFF
-#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2)))
-#endif
-
-/* The following definitions come from lib/util/fault.c */
-
-
-/**
- * Write backtrace to debug log
- */
-_PUBLIC_ void call_backtrace(void);
-
-/**
- Something really nasty happened - panic !
-**/
-_PUBLIC_ _NORETURN_ void smb_panic(const char *why);
-
-/**
-setup our fault handlers
-**/
-_PUBLIC_ void fault_setup(const char *pname);
-
-/**
- register a fault handler.
- Should only be called once in the execution of smbd.
-*/
-_PUBLIC_ bool register_fault_handler(const char *name, void (*fault_handler)(int sig));
-
-/* The following definitions come from lib/util/signal.c */
-
-
-/**
- Block sigs.
-**/
-void BlockSignals(bool block, int signum);
-
-/**
- Catch a signal. This should implement the following semantics:
-
- 1) The handler remains installed after being called.
- 2) The signal should be blocked during handler execution.
-**/
-void (*CatchSignal(int signum,void (*handler)(int )))(int);
-
-/**
- Ignore SIGCLD via whatever means is necessary for this OS.
-**/
-void CatchChild(void);
-
-/**
- Catch SIGCLD but leave the child around so it's status can be reaped.
-**/
-void CatchChildLeaveStatus(void);
-
-/* The following definitions come from lib/util/system.c */
-
-
-struct in_addr;
-
-/**************************************************************************
-A wrapper for gethostbyname() that tries avoids looking up hostnames
-in the root domain, which can cause dial-on-demand links to come up for no
-apparent reason.
-****************************************************************************/
-_PUBLIC_ struct hostent *sys_gethostbyname(const char *name);
-_PUBLIC_ struct in_addr sys_inet_makeaddr(int net, int host);
-
-/* The following definitions come from lib/util/genrand.c */
-
-/**
- Copy any user given reseed data.
-**/
-_PUBLIC_ void set_rand_reseed_callback(void (*fn)(void *, int *), void *);
-
-/**
- * Tell the random number generator it needs to reseed.
- */
-_PUBLIC_ void set_need_random_reseed(void);
-
-/**
- Interface to the (hopefully) good crypto random number generator.
- Will use our internal PRNG if more than 40 bytes of random generation
- has been requested, otherwise tries to read from /dev/random
-**/
-_PUBLIC_ void generate_random_buffer(uint8_t *out, int len);
-
-/**
- Interface to the (hopefully) good crypto random number generator.
- Will always use /dev/urandom if available.
-**/
-_PUBLIC_ void generate_secret_buffer(uint8_t *out, int len);
-
-/**
- generate a single random uint32_t
-**/
-_PUBLIC_ uint32_t generate_random(void);
-
-/**
- very basic password quality checker
-**/
-_PUBLIC_ bool check_password_quality(const char *s);
-
-/**
- Use the random number generator to generate a random string.
-**/
-_PUBLIC_ char *generate_random_str_list(TALLOC_CTX *mem_ctx, size_t len, const char *list);
-
-/**
- * Generate a random text string consisting of the specified length.
- * The returned string will be allocated.
- *
- * Characters used are: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_-#.,
- */
-_PUBLIC_ char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len);
-
-/* The following definitions come from lib/util/dprintf.c */
-
-_PUBLIC_ void d_set_iconv(smb_iconv_t);
-_PUBLIC_ int d_vfprintf(FILE *f, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
-_PUBLIC_ int d_fprintf(FILE *f, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
-_PUBLIC_ int d_printf(const char *format, ...) PRINTF_ATTRIBUTE(1,2);
-_PUBLIC_ void display_set_stderr(void);
-
-/* The following definitions come from lib/util/util_str.c */
-
-
-/**
- Trim the specified elements off the front and back of a string.
-**/
-_PUBLIC_ bool trim_string(char *s, const char *front, const char *back);
-
-/**
- Find the number of 'c' chars in a string
-**/
-_PUBLIC_ _PURE_ size_t count_chars(const char *s, char c);
-
-/**
- Safe string copy into a known length string. maxlength does not
- include the terminating zero.
-**/
-_PUBLIC_ char *safe_strcpy(char *dest,const char *src, size_t maxlength);
-
-/**
- Safe string cat into a string. maxlength does not
- include the terminating zero.
-**/
-_PUBLIC_ char *safe_strcat(char *dest, const char *src, size_t maxlength);
-
-/**
- Routine to get hex characters and turn them into a 16 byte array.
- the array can be variable length, and any non-hex-numeric
- characters are skipped. "0xnn" or "0Xnn" is specially catered
- for.
-
- valid examples: "0A5D15"; "0x15, 0x49, 0xa2"; "59\ta9\te3\n"
-
-
-**/
-_PUBLIC_ size_t strhex_to_str(char *p, size_t len, const char *strhex);
-
-/**
- * Parse a hex string and return a data blob.
- */
-_PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(const char *strhex) ;
-
-/**
- * Routine to print a buffer as HEX digits, into an allocated string.
- */
-_PUBLIC_ void hex_encode(const unsigned char *buff_in, size_t len, char **out_hex_buffer);
-
-/**
- * talloc version of hex_encode()
- */
-_PUBLIC_ char *hex_encode_talloc(TALLOC_CTX *mem_ctx, const unsigned char *buff_in, size_t len);
-
-/**
- Substitute a string for a pattern in another string. Make sure there is
- enough room!
-
- This routine looks for pattern in s and replaces it with
- insert. It may do multiple replacements.
-
- Any of " ; ' $ or ` in the insert string are replaced with _
- if len==0 then the string cannot be extended. This is different from the old
- use of len==0 which was for no length checks to be done.
-**/
-_PUBLIC_ void string_sub(char *s,const char *pattern, const char *insert, size_t len);
-
-
-_PUBLIC_ char *string_sub_talloc(TALLOC_CTX *mem_ctx, const char *s,
- const char *pattern, const char *insert);
-
-/**
- Similar to string_sub() but allows for any character to be substituted.
- Use with caution!
- if len==0 then the string cannot be extended. This is different from the old
- use of len==0 which was for no length checks to be done.
-**/
-_PUBLIC_ void all_string_sub(char *s,const char *pattern,const char *insert, size_t len);
-
-/**
- Unescape a URL encoded string, in place.
-**/
-_PUBLIC_ void rfc1738_unescape(char *buf);
-size_t valgrind_strlen(const char *s);
-
-/**
- format a string into length-prefixed dotted domain format, as used in NBT
- and in some ADS structures
-**/
-_PUBLIC_ const char *str_format_nbt_domain(TALLOC_CTX *mem_ctx, const char *s);
-
-/**
- * Add a string to an array of strings.
- *
- * num should be a pointer to an integer that holds the current
- * number of elements in strings. It will be updated by this function.
- */
-_PUBLIC_ bool add_string_to_array(TALLOC_CTX *mem_ctx,
- const char *str, const char ***strings, int *num);
-
-/**
- varient of strcmp() that handles NULL ptrs
-**/
-_PUBLIC_ int strcmp_safe(const char *s1, const char *s2);
-
-/**
-return the number of bytes occupied by a buffer in ASCII format
-the result includes the null termination
-limited by 'n' bytes
-**/
-_PUBLIC_ size_t ascii_len_n(const char *src, size_t n);
-
-/**
- Return a string representing a CIFS attribute for a file.
-**/
-_PUBLIC_ char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib);
-
-/**
- Set a boolean variable from the text value stored in the passed string.
- Returns true in success, false if the passed string does not correctly
- represent a boolean.
-**/
-_PUBLIC_ bool set_boolean(const char *boolean_string, bool *boolean);
-
-/**
- * Parse a string containing a boolean value.
- *
- * val will be set to the read value.
- *
- * @retval true if a boolean value was parsed, false otherwise.
- */
-_PUBLIC_ bool conv_str_bool(const char * str, bool * val);
-
-/**
- * Convert a size specification like 16K into an integral number of bytes.
- **/
-_PUBLIC_ bool conv_str_size(const char * str, uint64_t * val);
-
-/**
- * Parse a uint64_t value from a string
- *
- * val will be set to the value read.
- *
- * @retval true if parsing was successful, false otherwise
- */
-_PUBLIC_ bool conv_str_u64(const char * str, uint64_t * val);
-
-/**
-return the number of bytes occupied by a buffer in CH_UTF16 format
-the result includes the null termination
-**/
-_PUBLIC_ size_t utf16_len(const void *buf);
-
-/**
-return the number of bytes occupied by a buffer in CH_UTF16 format
-the result includes the null termination
-limited by 'n' bytes
-**/
-_PUBLIC_ size_t utf16_len_n(const void *src, size_t n);
-_PUBLIC_ size_t ucs2_align(const void *base_ptr, const void *p, int flags);
-
-/**
-Do a case-insensitive, whitespace-ignoring string compare.
-**/
-_PUBLIC_ int strwicmp(const char *psz1, const char *psz2);
-
-/**
- String replace.
-**/
-_PUBLIC_ void string_replace(char *s, char oldc, char newc);
-
-/**
- * Compare 2 strings.
- *
- * @note The comparison is case-insensitive.
- **/
-_PUBLIC_ bool strequal(const char *s1, const char *s2);
-
-/* The following definitions come from lib/util/util_strlist.c */
-
-
-/**
- build a null terminated list of strings from a input string and a
- separator list. The separator list must contain characters less than
- or equal to 0x2f for this to work correctly on multi-byte strings
-*/
-_PUBLIC_ const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep);
-
-/**
- * build a null terminated list of strings from an argv-like input string
- * Entries are seperated by spaces and can be enclosed by quotes.
- * Does NOT support escaping
- */
-_PUBLIC_ const char **str_list_make_shell(TALLOC_CTX *mem_ctx, const char *string, const char *sep);
-
-/**
- * join a list back to one string
- */
-_PUBLIC_ char *str_list_join(TALLOC_CTX *mem_ctx, const char **list, char seperator);
-
-/** join a list back to one (shell-like) string; entries
- * seperated by spaces, using quotes where necessary */
-_PUBLIC_ char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list, char sep);
-
-/**
- return the number of elements in a string list
-*/
-_PUBLIC_ size_t str_list_length(const char **list);
-
-/**
- copy a string list
-*/
-_PUBLIC_ const char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list);
-
-/**
- Return true if all the elements of the list match exactly.
- */
-_PUBLIC_ bool str_list_equal(const char **list1, const char **list2);
-
-/**
- add an entry to a string list
-*/
-_PUBLIC_ const char **str_list_add(const char **list, const char *s);
-
-/**
- remove an entry from a string list
-*/
-_PUBLIC_ void str_list_remove(const char **list, const char *s);
-
-/**
- return true if a string is in a list
-*/
-_PUBLIC_ bool str_list_check(const char **list, const char *s);
-
-/**
- return true if a string is in a list, case insensitively
-*/
-_PUBLIC_ bool str_list_check_ci(const char **list, const char *s);
-
-/* The following definitions come from lib/util/util_file.c */
-
-
-/**
-read a line from a file with possible \ continuation chars.
-Blanks at the start or end of a line are stripped.
-The string will be allocated if s2 is NULL
-**/
-_PUBLIC_ char *fgets_slash(char *s2,int maxlen,XFILE *f);
-
-/**
- * Read one line (data until next newline or eof) and allocate it
- */
-_PUBLIC_ char *afdgets(int fd, TALLOC_CTX *mem_ctx, size_t hint);
-
-/**
-load a file into memory from a fd.
-**/
-_PUBLIC_ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx);
-
-/**
-load a file into memory
-**/
-_PUBLIC_ char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx);
-
-/**
-mmap (if possible) or read a file
-**/
-_PUBLIC_ void *map_file(const char *fname, size_t size);
-
-/**
-load a file into memory and return an array of pointers to lines in the file
-must be freed with talloc_free().
-**/
-_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, TALLOC_CTX *mem_ctx);
-
-/**
-load a fd into memory and return an array of pointers to lines in the file
-must be freed with talloc_free(). If convert is true calls unix_to_dos on
-the list.
-**/
-_PUBLIC_ char **fd_lines_load(int fd, int *numlines, TALLOC_CTX *mem_ctx);
-
-/**
-take a list of lines and modify them to produce a list where \ continues
-a line
-**/
-_PUBLIC_ void file_lines_slashcont(char **lines);
-
-/**
- save a lump of data into a file. Mostly used for debugging
-*/
-_PUBLIC_ bool file_save(const char *fname, const void *packet, size_t length);
-_PUBLIC_ int vfdprintf(int fd, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
-_PUBLIC_ int fdprintf(int fd, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
-_PUBLIC_ bool large_file_support(const char *path);
-
-/* The following definitions come from lib/util/util.c */
-
-
-/**
- Find a suitable temporary directory. The result should be copied immediately
- as it may be overwritten by a subsequent call.
-**/
-_PUBLIC_ const char *tmpdir(void);
-
-/**
- Check if a file exists - call vfs_file_exist for samba files.
-**/
-_PUBLIC_ bool file_exist(const char *fname);
-
-/**
- Check a files mod time.
-**/
-_PUBLIC_ time_t file_modtime(const char *fname);
-
-/**
- Check if a directory exists.
-**/
-_PUBLIC_ bool directory_exist(const char *dname);
-
-/**
- * Try to create the specified directory if it didn't exist.
- *
- * @retval true if the directory already existed and has the right permissions
- * or was successfully created.
- */
-_PUBLIC_ bool directory_create_or_exist(const char *dname, uid_t uid,
- mode_t dir_perms);
-
-/**
- Set a fd into blocking/nonblocking mode. Uses POSIX O_NONBLOCK if available,
- else
- if SYSV use O_NDELAY
- if BSD use FNDELAY
-**/
-_PUBLIC_ int set_blocking(int fd, bool set);
-
-/**
- Sleep for a specified number of milliseconds.
-**/
-_PUBLIC_ void msleep(unsigned int t);
-
-/**
- Get my own name, return in malloc'ed storage.
-**/
-_PUBLIC_ char* get_myname(void);
-
-/**
- Return true if a string could be a pure IP address.
-**/
-_PUBLIC_ bool is_ipaddress(const char *str);
-
-/**
- Interpret an internet address or name into an IP address in 4 byte form.
-**/
-_PUBLIC_ uint32_t interpret_addr(const char *str);
-
-/**
- A convenient addition to interpret_addr().
-**/
-_PUBLIC_ struct in_addr interpret_addr2(const char *str);
-
-/**
- Check if an IP is the 0.0.0.0.
-**/
-_PUBLIC_ bool is_zero_ip(struct in_addr ip);
-
-/**
- Are two IPs on the same subnet?
-**/
-_PUBLIC_ bool same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
-
-/**
- Check if a process exists. Does this work on all unixes?
-**/
-_PUBLIC_ bool process_exists(pid_t pid);
-
-/**
- Simple routine to do POSIX file locking. Cruft in NFS and 64->32 bit mapping
- is dealt with in posix.c
-**/
-_PUBLIC_ bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type);
-
-/**
- * Write dump of binary data to the log file.
- *
- * The data is only written if the log level is at least level.
- */
-_PUBLIC_ void dump_data(int level, const uint8_t *buf,int len);
-
-/**
- * Write dump of binary data to the log file.
- *
- * The data is only written if the log level is at least level.
- * 16 zero bytes in a row are ommited
- */
-_PUBLIC_ void dump_data_skip_zeros(int level, const uint8_t *buf, int len);
-
-/**
- malloc that aborts with smb_panic on fail or zero size.
-**/
-_PUBLIC_ void *smb_xmalloc(size_t size);
-
-/**
- Memdup with smb_panic on fail.
-**/
-_PUBLIC_ void *smb_xmemdup(const void *p, size_t size);
-
-/**
- strdup that aborts on malloc fail.
-**/
-_PUBLIC_ char *smb_xstrdup(const char *s);
-
-/**
- Like strdup but for memory.
-**/
-_PUBLIC_ void *memdup(const void *p, size_t size);
-
-/**
- * Write a password to the log file.
- *
- * @note Only actually does something if DEBUG_PASSWORD was defined during
- * compile-time.
- */
-_PUBLIC_ void dump_data_pw(const char *msg, const uint8_t * data, size_t len);
-
-/**
- * see if a range of memory is all zero. A NULL pointer is considered
- * to be all zero
- */
-_PUBLIC_ bool all_zero(const uint8_t *ptr, size_t size);
-
-/**
- realloc an array, checking for integer overflow in the array size
-*/
-_PUBLIC_ void *realloc_array(void *ptr, size_t el_size, unsigned count);
-
-/* The following definitions come from lib/util/fsusage.c */
-
-
-/**
- * Retrieve amount of free disk space.
- * this does all of the system specific guff to get the free disk space.
- * It is derived from code in the GNU fileutils package, but has been
- * considerably mangled for use here
- *
- * results are returned in *dfree and *dsize, in 512 byte units
-*/
-_PUBLIC_ int sys_fsusage(const char *path, uint64_t *dfree, uint64_t *dsize);
-
-/* The following definitions come from lib/util/ms_fnmatch.c */
-
-
-/**
- * @file
- * @brief MS-style Filename matching
- */
-
-/* protocol types. It assumes that higher protocols include lower protocols
- as subsets. FIXME: Move to one of the smb-specific headers */
-enum protocol_types {
- PROTOCOL_NONE,
- PROTOCOL_CORE,
- PROTOCOL_COREPLUS,
- PROTOCOL_LANMAN1,
- PROTOCOL_LANMAN2,
- PROTOCOL_NT1,
- PROTOCOL_SMB2
-};
-
-int ms_fnmatch(const char *pattern, const char *string, enum protocol_types protocol);
-
-/** a generic fnmatch function - uses for non-CIFS pattern matching */
-int gen_fnmatch(const char *pattern, const char *string);
-
-/* The following definitions come from lib/util/mutex.c */
-
-
-/**
- register a set of mutex/rwlock handlers.
- Should only be called once in the execution of smbd.
-*/
-_PUBLIC_ bool register_mutex_handlers(const char *name, struct mutex_ops *ops);
-
-/* The following definitions come from lib/util/idtree.c */
-
-
-/**
- initialise a idr tree. The context return value must be passed to
- all subsequent idr calls. To destroy the idr tree use talloc_free()
- on this context
- */
-_PUBLIC_ struct idr_context *idr_init(TALLOC_CTX *mem_ctx);
-
-/**
- allocate the next available id, and assign 'ptr' into its slot.
- you can retrieve later this pointer using idr_find()
-*/
-_PUBLIC_ int idr_get_new(struct idr_context *idp, void *ptr, int limit);
-
-/**
- allocate a new id, giving the first available value greater than or
- equal to the given starting id
-*/
-_PUBLIC_ int idr_get_new_above(struct idr_context *idp, void *ptr, int starting_id, int limit);
-
-/**
- allocate a new id randomly in the given range
-*/
-_PUBLIC_ int idr_get_new_random(struct idr_context *idp, void *ptr, int limit);
-
-/**
- find a pointer value previously set with idr_get_new given an id
-*/
-_PUBLIC_ void *idr_find(struct idr_context *idp, int id);
-
-/**
- remove an id from the idr tree
-*/
-_PUBLIC_ int idr_remove(struct idr_context *idp, int id);
-
-/* The following definitions come from lib/util/become_daemon.c */
-
-/**
- Become a daemon, discarding the controlling terminal.
-**/
-_PUBLIC_ void become_daemon(bool fork);
-
-/**
- * Load a ini-style file.
- */
-bool pm_process( const char *fileName,
- bool (*sfunc)(const char *, void *),
- bool (*pfunc)(const char *, const char *, void *),
- void *userdata);
-
-/**
- * Add-on to talloc_get_type
- */
-_PUBLIC_ void *talloc_check_name_abort(const void *ptr, const char *name);
-#define talloc_get_type_abort(ptr, type) \
- (type *)talloc_check_name_abort(ptr, #type)
-
-#endif /* _SAMBA_UTIL_H_ */
diff --git a/source4/lib/util/util.m4 b/source4/lib/util/util.m4
deleted file mode 100644
index 9e362954cd..0000000000
--- a/source4/lib/util/util.m4
+++ /dev/null
@@ -1 +0,0 @@
-AC_CHECK_FUNCS(setsid)
diff --git a/source4/lib/util/util_file.c b/source4/lib/util/util_file.c
deleted file mode 100644
index c3e22196c0..0000000000
--- a/source4/lib/util/util_file.c
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * SMB parameters and setup
- * Copyright (C) Andrew Tridgell 1992-1998 Modified by Jeremy Allison 1995.
- *
- * Added afdgets() Jelmer Vernooij 2005
- *
- * 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/shmem.h"
-#include "system/filesys.h"
-
-/**
- * @file
- * @brief File-related utility functions
- */
-
-/**
-read a line from a file with possible \ continuation chars.
-Blanks at the start or end of a line are stripped.
-The string will be allocated if s2 is NULL
-**/
-_PUBLIC_ char *fgets_slash(char *s2,int maxlen,XFILE *f)
-{
- char *s=s2;
- int len = 0;
- int c;
- bool start_of_line = true;
-
- if (x_feof(f))
- return(NULL);
-
- if (maxlen <2) return(NULL);
-
- if (!s2)
- {
- maxlen = MIN(maxlen,8);
- s = (char *)malloc(maxlen);
- }
-
- if (!s) return(NULL);
-
- *s = 0;
-
- while (len < maxlen-1)
- {
- c = x_getc(f);
- switch (c)
- {
- case '\r':
- break;
- case '\n':
- while (len > 0 && s[len-1] == ' ')
- {
- s[--len] = 0;
- }
- if (len > 0 && s[len-1] == '\\')
- {
- s[--len] = 0;
- start_of_line = true;
- break;
- }
- return(s);
- case EOF:
- if (len <= 0 && !s2)
- SAFE_FREE(s);
- return(len>0?s:NULL);
- case ' ':
- if (start_of_line)
- break;
- /* fall through */
- default:
- start_of_line = false;
- s[len++] = c;
- s[len] = 0;
- }
- if (!s2 && len > maxlen-3)
- {
- char *t;
-
- maxlen *= 2;
- t = realloc_p(s, char, maxlen);
- if (!t) {
- DEBUG(0,("fgets_slash: failed to expand buffer!\n"));
- SAFE_FREE(s);
- return(NULL);
- } else s = t;
- }
- }
- return(s);
-}
-
-/**
- * Read one line (data until next newline or eof) and allocate it
- */
-_PUBLIC_ char *afdgets(int fd, TALLOC_CTX *mem_ctx, size_t hint)
-{
- char *data = NULL;
- ssize_t alloc_size = 0, offset = 0, ret;
- int p;
-
- if (hint <= 0) hint = 0x100;
-
- do {
- alloc_size += hint;
-
- data = talloc_realloc(mem_ctx, data, char, alloc_size);
-
- if (!data)
- return NULL;
-
- ret = read(fd, data + offset, hint);
-
- if (ret == 0) {
- return NULL;
- }
-
- if (ret == -1) {
- talloc_free(data);
- return NULL;
- }
-
- /* Find newline */
- for (p = 0; p < ret; p++) {
- if (data[offset + p] == '\n')
- break;
- }
-
- if (p < ret) {
- data[offset + p] = '\0';
-
- /* Go back to position of newline */
- lseek(fd, p - ret + 1, SEEK_CUR);
- return data;
- }
-
- offset += ret;
-
- } while (ret == hint);
-
- data[offset] = '\0';
-
- return data;
-}
-
-
-/**
-load a file into memory from a fd.
-**/
-_PUBLIC_ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx)
-{
- struct stat sbuf;
- char *p;
-
- if (fstat(fd, &sbuf) != 0) return NULL;
-
- p = (char *)talloc_size(mem_ctx, sbuf.st_size+1);
- if (!p) return NULL;
-
- if (read(fd, p, sbuf.st_size) != sbuf.st_size) {
- talloc_free(p);
- return NULL;
- }
- p[sbuf.st_size] = 0;
-
- if (size) *size = sbuf.st_size;
-
- return p;
-}
-
-/**
-load a file into memory
-**/
-_PUBLIC_ char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx)
-{
- int fd;
- char *p;
-
- if (!fname || !*fname) return NULL;
-
- fd = open(fname,O_RDONLY);
- if (fd == -1) return NULL;
-
- p = fd_load(fd, size, mem_ctx);
-
- close(fd);
-
- return p;
-}
-
-
-/**
-mmap (if possible) or read a file
-**/
-_PUBLIC_ void *map_file(const char *fname, size_t size)
-{
- size_t s2 = 0;
- void *p = NULL;
-#ifdef HAVE_MMAP
- int fd;
- fd = open(fname, O_RDONLY, 0);
- if (fd == -1) {
- DEBUG(2,("Failed to load %s - %s\n", fname, strerror(errno)));
- return NULL;
- }
- p = mmap(NULL, size, PROT_READ, MAP_SHARED|MAP_FILE, fd, 0);
- close(fd);
- if (p == MAP_FAILED) {
- DEBUG(1,("Failed to mmap %s - %s\n", fname, strerror(errno)));
- return NULL;
- }
-#endif
- if (!p) {
- p = file_load(fname, &s2, talloc_autofree_context());
- if (!p) return NULL;
- if (s2 != size) {
- DEBUG(1,("incorrect size for %s - got %d expected %d\n",
- fname, (int)s2, (int)size));
- talloc_free(p);
- return NULL;
- }
- }
-
- return p;
-}
-
-
-/**
-parse a buffer into lines
-'p' will be freed on error, and otherwise will be made a child of the returned array
-**/
-static char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx)
-{
- int i;
- char *s, **ret;
-
- if (!p) return NULL;
-
- for (s = p, i=0; s < p+size; s++) {
- if (s[0] == '\n') i++;
- }
-
- ret = talloc_array(mem_ctx, char *, i+2);
- if (!ret) {
- talloc_free(p);
- return NULL;
- }
-
- talloc_steal(ret, p);
-
- memset(ret, 0, sizeof(ret[0])*(i+2));
-
- ret[0] = p;
- for (s = p, i=0; s < p+size; s++) {
- if (s[0] == '\n') {
- s[0] = 0;
- i++;
- ret[i] = s+1;
- }
- if (s[0] == '\r') s[0] = 0;
- }
-
- /* remove any blank lines at the end */
- while (i > 0 && ret[i-1][0] == 0) {
- i--;
- }
-
- if (numlines) *numlines = i;
-
- return ret;
-}
-
-
-/**
-load a file into memory and return an array of pointers to lines in the file
-must be freed with talloc_free().
-**/
-_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, TALLOC_CTX *mem_ctx)
-{
- char *p;
- size_t size;
-
- p = file_load(fname, &size, mem_ctx);
- if (!p) return NULL;
-
- return file_lines_parse(p, size, numlines, mem_ctx);
-}
-
-/**
-load a fd into memory and return an array of pointers to lines in the file
-must be freed with talloc_free(). If convert is true calls unix_to_dos on
-the list.
-**/
-_PUBLIC_ char **fd_lines_load(int fd, int *numlines, TALLOC_CTX *mem_ctx)
-{
- char *p;
- size_t size;
-
- p = fd_load(fd, &size, mem_ctx);
- if (!p) return NULL;
-
- return file_lines_parse(p, size, numlines, mem_ctx);
-}
-
-
-/**
-take a list of lines and modify them to produce a list where \ continues
-a line
-**/
-_PUBLIC_ void file_lines_slashcont(char **lines)
-{
- int i, j;
-
- for (i=0; lines[i];) {
- int len = strlen(lines[i]);
- if (lines[i][len-1] == '\\') {
- lines[i][len-1] = ' ';
- if (lines[i+1]) {
- char *p = &lines[i][len];
- while (p < lines[i+1]) *p++ = ' ';
- for (j = i+1; lines[j]; j++) lines[j] = lines[j+1];
- }
- } else {
- i++;
- }
- }
-}
-
-/**
- save a lump of data into a file. Mostly used for debugging
-*/
-_PUBLIC_ bool file_save(const char *fname, const void *packet, size_t length)
-{
- int fd;
- fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0644);
- if (fd == -1) {
- return false;
- }
- if (write(fd, packet, length) != (size_t)length) {
- return false;
- }
- close(fd);
- return true;
-}
-
-_PUBLIC_ int vfdprintf(int fd, const char *format, va_list ap)
-{
- char *p;
- int len, ret;
- va_list ap2;
-
- va_copy(ap2, ap);
- len = vasprintf(&p, format, ap2);
- va_end(ap2);
- if (len <= 0) return len;
- ret = write(fd, p, len);
- SAFE_FREE(p);
- return ret;
-}
-
-_PUBLIC_ int fdprintf(int fd, const char *format, ...)
-{
- va_list ap;
- int ret;
-
- va_start(ap, format);
- ret = vfdprintf(fd, format, ap);
- va_end(ap);
- return ret;
-}
-
-
-/*
- try to determine if the filesystem supports large files
-*/
-_PUBLIC_ bool large_file_support(const char *path)
-{
- int fd;
- ssize_t ret;
- char c;
-
- fd = open(path, O_RDWR|O_CREAT, 0600);
- unlink(path);
- if (fd == -1) {
- /* have to assume large files are OK */
- return true;
- }
- ret = pread(fd, &c, 1, ((uint64_t)1)<<32);
- close(fd);
- return ret == 0;
-}
diff --git a/source4/lib/util/util_getent.c b/source4/lib/util/util_getent.c
deleted file mode 100644
index b9b2658f59..0000000000
--- a/source4/lib/util/util_getent.c
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba utility functions
- Copyright (C) Simo Sorce 2001
- Copyright (C) Jeremy Allison 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 "includes.h"
-
-
-/****************************************************************
- Returns a single linked list of group entries.
- Use grent_free() to free it after use.
-****************************************************************/
-
-struct sys_grent * getgrent_list(void)
-{
- struct sys_grent *glist;
- struct sys_grent *gent;
- struct group *grp;
-
- gent = malloc_p(struct sys_grent);
- if (gent == NULL) {
- DEBUG (0, ("Out of memory in getgrent_list!\n"));
- return NULL;
- }
- memset(gent, '\0', sizeof(struct sys_grent));
- glist = gent;
-
- setgrent();
- grp = getgrent();
- if (grp == NULL) {
- endgrent();
- SAFE_FREE(glist);
- return NULL;
- }
-
- while (grp != NULL) {
- int i,num;
-
- if (grp->gr_name) {
- if ((gent->gr_name = strdup(grp->gr_name)) == NULL)
- goto err;
- }
- if (grp->gr_passwd) {
- if ((gent->gr_passwd = strdup(grp->gr_passwd)) == NULL)
- goto err;
- }
- gent->gr_gid = grp->gr_gid;
-
- /* number of strings in gr_mem */
- for (num = 0; grp->gr_mem[num]; num++)
- ;
-
- /* alloc space for gr_mem string pointers */
- if ((gent->gr_mem = malloc_array_p(char *, num+1)) == NULL)
- goto err;
-
- memset(gent->gr_mem, '\0', (num+1) * sizeof(char *));
-
- for (i=0; i < num; i++) {
- if ((gent->gr_mem[i] = strdup(grp->gr_mem[i])) == NULL)
- goto err;
- }
- gent->gr_mem[num] = NULL;
-
- grp = getgrent();
- if (grp) {
- gent->next = malloc_p(struct sys_grent);
- if (gent->next == NULL)
- goto err;
- gent = gent->next;
- memset(gent, '\0', sizeof(struct sys_grent));
- }
- }
-
- endgrent();
- return glist;
-
- err:
-
- endgrent();
- DEBUG(0, ("Out of memory in getgrent_list!\n"));
- grent_free(glist);
- return NULL;
-}
-
-/****************************************************************
- Free the single linked list of group entries made by
- getgrent_list()
-****************************************************************/
-
-void grent_free (struct sys_grent *glist)
-{
- while (glist) {
- struct sys_grent *prev;
-
- SAFE_FREE(glist->gr_name);
- SAFE_FREE(glist->gr_passwd);
- if (glist->gr_mem) {
- int i;
- for (i = 0; glist->gr_mem[i]; i++)
- SAFE_FREE(glist->gr_mem[i]);
- SAFE_FREE(glist->gr_mem);
- }
- prev = glist;
- glist = glist->next;
- SAFE_FREE(prev);
- }
-}
-
-/****************************************************************
- Returns a single linked list of passwd entries.
- Use pwent_free() to free it after use.
-****************************************************************/
-
-struct sys_pwent * getpwent_list(void)
-{
- struct sys_pwent *plist;
- struct sys_pwent *pent;
- struct passwd *pwd;
-
- pent = malloc_p(struct sys_pwent);
- if (pent == NULL) {
- DEBUG (0, ("Out of memory in getpwent_list!\n"));
- return NULL;
- }
- plist = pent;
-
- setpwent();
- pwd = getpwent();
- while (pwd != NULL) {
- memset(pent, '\0', sizeof(struct sys_pwent));
- if (pwd->pw_name) {
- if ((pent->pw_name = strdup(pwd->pw_name)) == NULL)
- goto err;
- }
- if (pwd->pw_passwd) {
- if ((pent->pw_passwd = strdup(pwd->pw_passwd)) == NULL)
- goto err;
- }
- pent->pw_uid = pwd->pw_uid;
- pent->pw_gid = pwd->pw_gid;
- if (pwd->pw_gecos) {
- if ((pent->pw_name = strdup(pwd->pw_gecos)) == NULL)
- goto err;
- }
- if (pwd->pw_dir) {
- if ((pent->pw_name = strdup(pwd->pw_dir)) == NULL)
- goto err;
- }
- if (pwd->pw_shell) {
- if ((pent->pw_name = strdup(pwd->pw_shell)) == NULL)
- goto err;
- }
-
- pwd = getpwent();
- if (pwd) {
- pent->next = malloc_p(struct sys_pwent);
- if (pent->next == NULL)
- goto err;
- pent = pent->next;
- }
- }
-
- endpwent();
- return plist;
-
- err:
-
- endpwent();
- DEBUG(0, ("Out of memory in getpwent_list!\n"));
- pwent_free(plist);
- return NULL;
-}
-
-/****************************************************************
- Free the single linked list of passwd entries made by
- getpwent_list()
-****************************************************************/
-
-void pwent_free (struct sys_pwent *plist)
-{
- while (plist) {
- struct sys_pwent *prev;
-
- SAFE_FREE(plist->pw_name);
- SAFE_FREE(plist->pw_passwd);
- SAFE_FREE(plist->pw_gecos);
- SAFE_FREE(plist->pw_dir);
- SAFE_FREE(plist->pw_shell);
-
- prev = plist;
- plist = plist->next;
- SAFE_FREE(prev);
- }
-}
-
-/****************************************************************
- Add the individual group users onto the list.
-****************************************************************/
-
-static struct sys_userlist *add_members_to_userlist(struct sys_userlist *list_head, const struct group *grp)
-{
- size_t num_users, i;
-
- /* Count the number of users. */
- for (num_users = 0; grp->gr_mem[num_users]; num_users++)
- ;
-
- for (i = 0; i < num_users; i++) {
- struct sys_userlist *entry = malloc_p(struct sys_userlist);
- if (entry == NULL) {
- free_userlist(list_head);
- return NULL;
- }
- entry->unix_name = (char *)strdup(grp->gr_mem[i]);
- if (entry->unix_name == NULL) {
- SAFE_FREE(entry);
- free_userlist(list_head);
- return NULL;
- }
- DLIST_ADD(list_head, entry);
- }
- return list_head;
-}
-
-/****************************************************************
- Get the list of UNIX users in a group.
- We have to enumerate the /etc/group file as some UNIX getgrnam()
- calls won't do that for us (notably Tru64 UNIX).
-****************************************************************/
-
-struct sys_userlist *get_users_in_group(const char *gname)
-{
- struct sys_userlist *list_head = NULL;
- struct group *gptr;
-
-#if !defined(BROKEN_GETGRNAM)
- if ((gptr = (struct group *)getgrnam(gname)) == NULL)
- return NULL;
- return add_members_to_userlist(list_head, gptr);
-#else
- /* BROKEN_GETGRNAM - True64 */
- setgrent();
- while((gptr = getgrent()) != NULL) {
- if (strequal(gname, gptr->gr_name)) {
- list_head = add_members_to_userlist(list_head, gptr);
- if (list_head == NULL)
- return NULL;
- }
- }
- endgrent();
- return list_head;
-#endif
-}
-
-/****************************************************************
- Free list allocated above.
-****************************************************************/
-
-void free_userlist(struct sys_userlist *list_head)
-{
- while (list_head) {
- struct sys_userlist *old_head = list_head;
- DLIST_REMOVE(list_head, list_head);
- SAFE_FREE(old_head->unix_name);
- SAFE_FREE(old_head);
- }
-}
diff --git a/source4/lib/util/util_ldb.c b/source4/lib/util/util_ldb.c
deleted file mode 100644
index fab729c036..0000000000
--- a/source4/lib/util/util_ldb.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- common share info functions
-
- Copyright (C) Andrew Tridgell 2004
- Copyright (C) Tim Potter 2004
-
- 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/events/events.h"
-#include "lib/ldb/include/ldb.h"
-#include "lib/ldb/include/ldb_errors.h"
-#include "lib/util/util_ldb.h"
-/*
- search the sam for the specified attributes - va_list variant
-*/
-int gendb_search_v(struct ldb_context *ldb,
- TALLOC_CTX *mem_ctx,
- struct ldb_dn *basedn,
- struct ldb_message ***msgs,
- const char * const *attrs,
- const char *format,
- va_list ap)
-{
- enum ldb_scope scope = LDB_SCOPE_SUBTREE;
- struct ldb_result *res;
- char *expr = NULL;
- int ret;
-
- if (format) {
- expr = talloc_vasprintf(mem_ctx, format, ap);
- if (expr == NULL) {
- return -1;
- }
- } else {
- scope = LDB_SCOPE_BASE;
- }
-
- res = NULL;
-
- ret = ldb_search(ldb, basedn, scope, expr, attrs, &res);
-
- if (ret == LDB_SUCCESS) {
- talloc_steal(mem_ctx, res->msgs);
-
- DEBUG(6,("gendb_search_v: %s %s -> %d\n",
- basedn?ldb_dn_get_linearized(basedn):"NULL",
- expr?expr:"NULL", res->count));
-
- ret = res->count;
- *msgs = res->msgs;
- talloc_free(res);
- } else if (scope == LDB_SCOPE_BASE && ret == LDB_ERR_NO_SUCH_OBJECT) {
- ret = 0;
- *msgs = NULL;
- } else {
- DEBUG(4,("gendb_search_v: search failed: %s\n",
- ldb_errstring(ldb)));
- ret = -1;
- }
-
- talloc_free(expr);
-
- return ret;
-}
-
-/*
- search the LDB for the specified attributes - varargs variant
-*/
-int gendb_search(struct ldb_context *ldb,
- TALLOC_CTX *mem_ctx,
- struct ldb_dn *basedn,
- struct ldb_message ***res,
- const char * const *attrs,
- const char *format, ...)
-{
- va_list ap;
- int count;
-
- va_start(ap, format);
- count = gendb_search_v(ldb, mem_ctx, basedn, res, attrs, format, ap);
- va_end(ap);
-
- return count;
-}
-
-/*
- search the LDB for a specified record (by DN)
-*/
-
-int gendb_search_dn(struct ldb_context *ldb,
- TALLOC_CTX *mem_ctx,
- struct ldb_dn *dn,
- struct ldb_message ***res,
- const char * const *attrs)
-{
- return gendb_search(ldb, mem_ctx, dn, res, attrs, NULL);
-}
-
-/*
- setup some initial ldif in a ldb
-*/
-int gendb_add_ldif(struct ldb_context *ldb, const char *ldif_string)
-{
- struct ldb_ldif *ldif;
- int ret;
- ldif = ldb_ldif_read_string(ldb, &ldif_string);
- if (ldif == NULL) return -1;
- ret = ldb_add(ldb, ldif->msg);
- talloc_free(ldif);
- return ret;
-}
-
-char *wrap_casefold(void *context, void *mem_ctx, const char *s, size_t n)
-{
- return strupper_talloc_n(mem_ctx, s, n);
-}
-
-
diff --git a/source4/lib/util/util_ldb.h b/source4/lib/util/util_ldb.h
deleted file mode 100644
index 43f98ae1a9..0000000000
--- a/source4/lib/util/util_ldb.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef __LIB_UTIL_UTIL_LDB_H__
-#define __LIB_UTIL_UTIL_LDB_H__
-
-/* The following definitions come from lib/util/util_ldb.c */
-
-int gendb_search_v(struct ldb_context *ldb,
- TALLOC_CTX *mem_ctx,
- struct ldb_dn *basedn,
- struct ldb_message ***msgs,
- const char * const *attrs,
- const char *format,
- va_list ap) PRINTF_ATTRIBUTE(6,0);
-int gendb_search(struct ldb_context *ldb,
- TALLOC_CTX *mem_ctx,
- struct ldb_dn *basedn,
- struct ldb_message ***res,
- const char * const *attrs,
- const char *format, ...) PRINTF_ATTRIBUTE(6,7);
-int gendb_search_dn(struct ldb_context *ldb,
- TALLOC_CTX *mem_ctx,
- struct ldb_dn *dn,
- struct ldb_message ***res,
- const char * const *attrs);
-int gendb_add_ldif(struct ldb_context *ldb, const char *ldif_string);
-char *wrap_casefold(void *context, void *mem_ctx, const char *s, size_t n);
-
-#endif /* __LIB_UTIL_UTIL_LDB_H__ */
diff --git a/source4/lib/util/util_pw.c b/source4/lib/util/util_pw.c
deleted file mode 100644
index 11e46ec4e3..0000000000
--- a/source4/lib/util/util_pw.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Safe versions of getpw* calls
-
- Copyright (C) Andrew Bartlett 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/>.
-*/
-
-#include "includes.h"
-
-static struct passwd *alloc_copy_passwd(TALLOC_CTX *mem_ctx,
- const struct passwd *from)
-{
- struct passwd *ret = talloc_zero(mem_ctx, struct passwd);
-
- if (ret == NULL)
- return NULL;
-
- ret->pw_name = talloc_strdup(ret, from->pw_name);
- ret->pw_passwd = talloc_strdup(ret, from->pw_passwd);
- ret->pw_uid = from->pw_uid;
- ret->pw_gid = from->pw_gid;
- ret->pw_gecos = talloc_strdup(ret, from->pw_gecos);
- ret->pw_dir = talloc_strdup(ret, from->pw_dir);
- ret->pw_shell = talloc_strdup(ret, from->pw_shell);
-
- return ret;
-}
-
-struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name)
-{
- struct passwd *temp;
-
- temp = sys_getpwnam(name);
-
- if (!temp) {
-#if 0
- if (errno == ENOMEM) {
- /* what now? */
- }
-#endif
- return NULL;
- }
-
- return alloc_copy_passwd(mem_ctx, temp);
-}
-
-struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid)
-{
- struct passwd *temp;
-
- temp = sys_getpwuid(uid);
-
- if (!temp) {
-#if 0
- if (errno == ENOMEM) {
- /* what now? */
- }
-#endif
- return NULL;
- }
-
- return alloc_copy_passwd(mem_ctx, temp);
-}
diff --git a/source4/lib/util/util_str.c b/source4/lib/util/util_str.c
deleted file mode 100644
index 9ea6403c52..0000000000
--- a/source4/lib/util/util_str.c
+++ /dev/null
@@ -1,790 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba utility functions
-
- Copyright (C) Andrew Tridgell 1992-2001
- Copyright (C) Simo Sorce 2001-2002
- Copyright (C) Martin Pool 2003
- Copyright (C) James Peach 2005
-
- 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 "libcli/raw/smb.h"
-#include "system/locale.h"
-
-/**
- * @file
- * @brief String utilities.
- **/
-
-
-/**
- Trim the specified elements off the front and back of a string.
-**/
-_PUBLIC_ bool trim_string(char *s, const char *front, const char *back)
-{
- bool ret = false;
- size_t front_len;
- size_t back_len;
- size_t len;
-
- /* Ignore null or empty strings. */
- if (!s || (s[0] == '\0'))
- return false;
-
- front_len = front? strlen(front) : 0;
- back_len = back? strlen(back) : 0;
-
- len = strlen(s);
-
- if (front_len) {
- while (len && strncmp(s, front, front_len)==0) {
- /* Must use memmove here as src & dest can
- * easily overlap. Found by valgrind. JRA. */
- memmove(s, s+front_len, (len-front_len)+1);
- len -= front_len;
- ret=true;
- }
- }
-
- if (back_len) {
- while ((len >= back_len) && strncmp(s+len-back_len,back,back_len)==0) {
- s[len-back_len]='\0';
- len -= back_len;
- ret=true;
- }
- }
- return ret;
-}
-
-/**
- Find the number of 'c' chars in a string
-**/
-_PUBLIC_ _PURE_ size_t count_chars(const char *s, char c)
-{
- size_t count = 0;
-
- while (*s) {
- if (*s == c) count++;
- s ++;
- }
-
- return count;
-}
-
-
-
-/**
- Safe string copy into a known length string. maxlength does not
- include the terminating zero.
-**/
-_PUBLIC_ char *safe_strcpy(char *dest,const char *src, size_t maxlength)
-{
- size_t len;
-
- if (!dest) {
- DEBUG(0,("ERROR: NULL dest in safe_strcpy\n"));
- return NULL;
- }
-
-#ifdef DEVELOPER
- /* We intentionally write out at the extremity of the destination
- * string. If the destination is too short (e.g. pstrcpy into mallocd
- * or fstring) then this should cause an error under a memory
- * checker. */
- dest[maxlength] = '\0';
- if (PTR_DIFF(&len, dest) > 0) { /* check if destination is on the stack, ok if so */
- log_suspicious_usage("safe_strcpy", src);
- }
-#endif
-
- if (!src) {
- *dest = 0;
- return dest;
- }
-
- len = strlen(src);
-
- if (len > maxlength) {
- DEBUG(0,("ERROR: string overflow by %u (%u - %u) in safe_strcpy [%.50s]\n",
- (uint_t)(len-maxlength), (unsigned)len, (unsigned)maxlength, src));
- len = maxlength;
- }
-
- memmove(dest, src, len);
- dest[len] = 0;
- return dest;
-}
-
-/**
- Safe string cat into a string. maxlength does not
- include the terminating zero.
-**/
-_PUBLIC_ char *safe_strcat(char *dest, const char *src, size_t maxlength)
-{
- size_t src_len, dest_len;
-
- if (!dest) {
- DEBUG(0,("ERROR: NULL dest in safe_strcat\n"));
- return NULL;
- }
-
- if (!src)
- return dest;
-
-#ifdef DEVELOPER
- if (PTR_DIFF(&src_len, dest) > 0) { /* check if destination is on the stack, ok if so */
- log_suspicious_usage("safe_strcat", src);
- }
-#endif
- src_len = strlen(src);
- dest_len = strlen(dest);
-
- if (src_len + dest_len > maxlength) {
- DEBUG(0,("ERROR: string overflow by %d in safe_strcat [%.50s]\n",
- (int)(src_len + dest_len - maxlength), src));
- if (maxlength > dest_len) {
- memcpy(&dest[dest_len], src, maxlength - dest_len);
- }
- dest[maxlength] = 0;
- return NULL;
- }
-
- memcpy(&dest[dest_len], src, src_len);
- dest[dest_len + src_len] = 0;
- return dest;
-}
-
-/**
- Routine to get hex characters and turn them into a 16 byte array.
- the array can be variable length, and any non-hex-numeric
- characters are skipped. "0xnn" or "0Xnn" is specially catered
- for.
-
- valid examples: "0A5D15"; "0x15, 0x49, 0xa2"; "59\ta9\te3\n"
-
-
-**/
-_PUBLIC_ size_t strhex_to_str(char *p, size_t len, const char *strhex)
-{
- size_t i;
- size_t num_chars = 0;
- uint8_t lonybble, hinybble;
- const char *hexchars = "0123456789ABCDEF";
- char *p1 = NULL, *p2 = NULL;
-
- for (i = 0; i < len && strhex[i] != 0; i++) {
- if (strncasecmp(hexchars, "0x", 2) == 0) {
- i++; /* skip two chars */
- continue;
- }
-
- if (!(p1 = strchr(hexchars, toupper((unsigned char)strhex[i]))))
- break;
-
- i++; /* next hex digit */
-
- if (!(p2 = strchr(hexchars, toupper((unsigned char)strhex[i]))))
- break;
-
- /* get the two nybbles */
- hinybble = PTR_DIFF(p1, hexchars);
- lonybble = PTR_DIFF(p2, hexchars);
-
- p[num_chars] = (hinybble << 4) | lonybble;
- num_chars++;
-
- p1 = NULL;
- p2 = NULL;
- }
- return num_chars;
-}
-
-/**
- * Parse a hex string and return a data blob.
- */
-_PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(const char *strhex)
-{
- DATA_BLOB ret_blob = data_blob(NULL, strlen(strhex)/2+1);
-
- ret_blob.length = strhex_to_str((char *)ret_blob.data,
- strlen(strhex),
- strhex);
-
- return ret_blob;
-}
-
-
-/**
- * Routine to print a buffer as HEX digits, into an allocated string.
- */
-_PUBLIC_ void hex_encode(const unsigned char *buff_in, size_t len, char **out_hex_buffer)
-{
- int i;
- char *hex_buffer;
-
- *out_hex_buffer = malloc_array_p(char, (len*2)+1);
- hex_buffer = *out_hex_buffer;
-
- for (i = 0; i < len; i++)
- slprintf(&hex_buffer[i*2], 3, "%02X", buff_in[i]);
-}
-
-/**
- * talloc version of hex_encode()
- */
-_PUBLIC_ char *hex_encode_talloc(TALLOC_CTX *mem_ctx, const unsigned char *buff_in, size_t len)
-{
- int i;
- char *hex_buffer;
-
- hex_buffer = talloc_array(mem_ctx, char, (len*2)+1);
-
- for (i = 0; i < len; i++)
- slprintf(&hex_buffer[i*2], 3, "%02X", buff_in[i]);
-
- return hex_buffer;
-}
-
-/**
- Substitute a string for a pattern in another string. Make sure there is
- enough room!
-
- This routine looks for pattern in s and replaces it with
- insert. It may do multiple replacements.
-
- Any of " ; ' $ or ` in the insert string are replaced with _
- if len==0 then the string cannot be extended. This is different from the old
- use of len==0 which was for no length checks to be done.
-**/
-
-_PUBLIC_ void string_sub(char *s, const char *pattern, const char *insert, size_t len)
-{
- char *p;
- ssize_t ls, lp, li, i;
-
- if (!insert || !pattern || !*pattern || !s)
- return;
-
- ls = (ssize_t)strlen(s);
- lp = (ssize_t)strlen(pattern);
- li = (ssize_t)strlen(insert);
-
- if (len == 0)
- len = ls + 1; /* len is number of *bytes* */
-
- while (lp <= ls && (p = strstr(s, pattern))) {
- if (ls + (li-lp) >= len) {
- DEBUG(0,("ERROR: string overflow by %d in string_sub(%.50s, %d)\n",
- (int)(ls + (li-lp) - len),
- pattern, (int)len));
- break;
- }
- if (li != lp) {
- memmove(p+li,p+lp,strlen(p+lp)+1);
- }
- for (i=0;i<li;i++) {
- switch (insert[i]) {
- case '`':
- case '"':
- case '\'':
- case ';':
- case '$':
- case '%':
- case '\r':
- case '\n':
- p[i] = '_';
- break;
- default:
- p[i] = insert[i];
- }
- }
- s = p + li;
- ls += (li-lp);
- }
-}
-
-/**
- * Talloc'ed version of string_sub
- */
-_PUBLIC_ char *string_sub_talloc(TALLOC_CTX *mem_ctx, const char *s,
- const char *pattern, const char *insert)
-{
- const char *p;
- char *ret;
- size_t len, alloc_len;
-
- if (insert == NULL || pattern == NULL || !*pattern || s == NULL)
- return NULL;
-
- /* determine length needed */
- len = strlen(s);
-
- for (p = strstr(s, pattern); p != NULL;
- p = strstr(p+strlen(pattern), pattern)) {
- len += strlen(insert) - strlen(pattern);
- }
-
- alloc_len = MAX(len, strlen(s))+1;
- ret = talloc_array(mem_ctx, char, alloc_len);
- if (ret == NULL)
- return NULL;
- strncpy(ret, s, alloc_len);
- string_sub(ret, pattern, insert, alloc_len);
-
- ret = talloc_realloc(mem_ctx, ret, char, len+1);
- if (ret == NULL)
- return NULL;
-
- SMB_ASSERT(ret[len] == '\0');
-
- return ret;
-}
-
-/**
- Similar to string_sub() but allows for any character to be substituted.
- Use with caution!
- if len==0 then the string cannot be extended. This is different from the old
- use of len==0 which was for no length checks to be done.
-**/
-
-_PUBLIC_ void all_string_sub(char *s,const char *pattern,const char *insert, size_t len)
-{
- char *p;
- ssize_t ls,lp,li;
-
- if (!insert || !pattern || !s)
- return;
-
- ls = (ssize_t)strlen(s);
- lp = (ssize_t)strlen(pattern);
- li = (ssize_t)strlen(insert);
-
- if (!*pattern)
- return;
-
- if (len == 0)
- len = ls + 1; /* len is number of *bytes* */
-
- while (lp <= ls && (p = strstr(s,pattern))) {
- if (ls + (li-lp) >= len) {
- DEBUG(0,("ERROR: string overflow by %d in all_string_sub(%.50s, %d)\n",
- (int)(ls + (li-lp) - len),
- pattern, (int)len));
- break;
- }
- if (li != lp) {
- memmove(p+li,p+lp,strlen(p+lp)+1);
- }
- memcpy(p, insert, li);
- s = p + li;
- ls += (li-lp);
- }
-}
-
-
-
-/**
- Unescape a URL encoded string, in place.
-**/
-
-_PUBLIC_ void rfc1738_unescape(char *buf)
-{
- char *p=buf;
-
- while ((p=strchr(p,'+')))
- *p = ' ';
-
- p = buf;
-
- while (p && *p && (p=strchr(p,'%'))) {
- int c1 = p[1];
- int c2 = p[2];
-
- if (c1 >= '0' && c1 <= '9')
- c1 = c1 - '0';
- else if (c1 >= 'A' && c1 <= 'F')
- c1 = 10 + c1 - 'A';
- else if (c1 >= 'a' && c1 <= 'f')
- c1 = 10 + c1 - 'a';
- else {p++; continue;}
-
- if (c2 >= '0' && c2 <= '9')
- c2 = c2 - '0';
- else if (c2 >= 'A' && c2 <= 'F')
- c2 = 10 + c2 - 'A';
- else if (c2 >= 'a' && c2 <= 'f')
- c2 = 10 + c2 - 'a';
- else {p++; continue;}
-
- *p = (c1<<4) | c2;
-
- memmove(p+1, p+3, strlen(p+3)+1);
- p++;
- }
-}
-
-#ifdef VALGRIND
-size_t valgrind_strlen(const char *s)
-{
- size_t count;
- for(count = 0; *s++; count++)
- ;
- return count;
-}
-#endif
-
-
-/**
- format a string into length-prefixed dotted domain format, as used in NBT
- and in some ADS structures
-**/
-_PUBLIC_ const char *str_format_nbt_domain(TALLOC_CTX *mem_ctx, const char *s)
-{
- char *ret;
- int i;
- if (!s || !*s) {
- return talloc_strdup(mem_ctx, "");
- }
- ret = talloc_array(mem_ctx, char, strlen(s)+2);
- if (!ret) {
- return ret;
- }
-
- memcpy(ret+1, s, strlen(s)+1);
- ret[0] = '.';
-
- for (i=0;ret[i];i++) {
- if (ret[i] == '.') {
- char *p = strchr(ret+i+1, '.');
- if (p) {
- ret[i] = p-(ret+i+1);
- } else {
- ret[i] = strlen(ret+i+1);
- }
- }
- }
-
- return ret;
-}
-
-/**
- * Add a string to an array of strings.
- *
- * num should be a pointer to an integer that holds the current
- * number of elements in strings. It will be updated by this function.
- */
-_PUBLIC_ bool add_string_to_array(TALLOC_CTX *mem_ctx,
- const char *str, const char ***strings, int *num)
-{
- char *dup_str = talloc_strdup(mem_ctx, str);
-
- *strings = talloc_realloc(mem_ctx,
- *strings,
- const char *, ((*num)+1));
-
- if ((*strings == NULL) || (dup_str == NULL))
- return false;
-
- (*strings)[*num] = dup_str;
- *num += 1;
-
- return true;
-}
-
-
-
-/**
- varient of strcmp() that handles NULL ptrs
-**/
-_PUBLIC_ int strcmp_safe(const char *s1, const char *s2)
-{
- if (s1 == s2) {
- return 0;
- }
- if (s1 == NULL || s2 == NULL) {
- return s1?-1:1;
- }
- return strcmp(s1, s2);
-}
-
-
-/**
-return the number of bytes occupied by a buffer in ASCII format
-the result includes the null termination
-limited by 'n' bytes
-**/
-_PUBLIC_ size_t ascii_len_n(const char *src, size_t n)
-{
- size_t len;
-
- len = strnlen(src, n);
- if (len+1 <= n) {
- len += 1;
- }
-
- return len;
-}
-
-
-/**
- Return a string representing a CIFS attribute for a file.
-**/
-_PUBLIC_ char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib)
-{
- int i, len;
- const struct {
- char c;
- uint16_t attr;
- } attr_strs[] = {
- {'V', FILE_ATTRIBUTE_VOLUME},
- {'D', FILE_ATTRIBUTE_DIRECTORY},
- {'A', FILE_ATTRIBUTE_ARCHIVE},
- {'H', FILE_ATTRIBUTE_HIDDEN},
- {'S', FILE_ATTRIBUTE_SYSTEM},
- {'N', FILE_ATTRIBUTE_NORMAL},
- {'R', FILE_ATTRIBUTE_READONLY},
- {'d', FILE_ATTRIBUTE_DEVICE},
- {'t', FILE_ATTRIBUTE_TEMPORARY},
- {'s', FILE_ATTRIBUTE_SPARSE},
- {'r', FILE_ATTRIBUTE_REPARSE_POINT},
- {'c', FILE_ATTRIBUTE_COMPRESSED},
- {'o', FILE_ATTRIBUTE_OFFLINE},
- {'n', FILE_ATTRIBUTE_NONINDEXED},
- {'e', FILE_ATTRIBUTE_ENCRYPTED}
- };
- char *ret;
-
- ret = talloc_array(mem_ctx, char, ARRAY_SIZE(attr_strs)+1);
- if (!ret) {
- return NULL;
- }
-
- for (len=i=0; i<ARRAY_SIZE(attr_strs); i++) {
- if (attrib & attr_strs[i].attr) {
- ret[len++] = attr_strs[i].c;
- }
- }
-
- ret[len] = 0;
-
- return ret;
-}
-
-/**
- Set a boolean variable from the text value stored in the passed string.
- Returns true in success, false if the passed string does not correctly
- represent a boolean.
-**/
-
-_PUBLIC_ bool set_boolean(const char *boolean_string, bool *boolean)
-{
- if (strwicmp(boolean_string, "yes") == 0 ||
- strwicmp(boolean_string, "true") == 0 ||
- strwicmp(boolean_string, "on") == 0 ||
- strwicmp(boolean_string, "1") == 0) {
- *boolean = true;
- return true;
- } else if (strwicmp(boolean_string, "no") == 0 ||
- strwicmp(boolean_string, "false") == 0 ||
- strwicmp(boolean_string, "off") == 0 ||
- strwicmp(boolean_string, "0") == 0) {
- *boolean = false;
- return true;
- }
- return false;
-}
-
-/**
- * Parse a string containing a boolean value.
- *
- * val will be set to the read value.
- *
- * @retval true if a boolean value was parsed, false otherwise.
- */
-_PUBLIC_ bool conv_str_bool(const char * str, bool * val)
-{
- char * end = NULL;
- long lval;
-
- if (str == NULL || *str == '\0') {
- return false;
- }
-
- lval = strtol(str, &end, 10 /* base */);
- if (end == NULL || *end != '\0' || end == str) {
- return set_boolean(str, val);
- }
-
- *val = (lval) ? true : false;
- return true;
-}
-
-/**
- * Convert a size specification like 16K into an integral number of bytes.
- **/
-_PUBLIC_ bool conv_str_size(const char * str, uint64_t * val)
-{
- char * end = NULL;
- unsigned long long lval;
-
- if (str == NULL || *str == '\0') {
- return false;
- }
-
- lval = strtoull(str, &end, 10 /* base */);
- if (end == NULL || end == str) {
- return false;
- }
-
- if (*end) {
- if (strwicmp(end, "K") == 0) {
- lval *= 1024ULL;
- } else if (strwicmp(end, "M") == 0) {
- lval *= (1024ULL * 1024ULL);
- } else if (strwicmp(end, "G") == 0) {
- lval *= (1024ULL * 1024ULL * 1024ULL);
- } else if (strwicmp(end, "T") == 0) {
- lval *= (1024ULL * 1024ULL * 1024ULL * 1024ULL);
- } else if (strwicmp(end, "P") == 0) {
- lval *= (1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL);
- } else {
- return false;
- }
- }
-
- *val = (uint64_t)lval;
- return true;
-}
-
-/**
- * Parse a uint64_t value from a string
- *
- * val will be set to the value read.
- *
- * @retval true if parsing was successful, false otherwise
- */
-_PUBLIC_ bool conv_str_u64(const char * str, uint64_t * val)
-{
- char * end = NULL;
- unsigned long long lval;
-
- if (str == NULL || *str == '\0') {
- return false;
- }
-
- lval = strtoull(str, &end, 10 /* base */);
- if (end == NULL || *end != '\0' || end == str) {
- return false;
- }
-
- *val = (uint64_t)lval;
- return true;
-}
-
-/**
-return the number of bytes occupied by a buffer in CH_UTF16 format
-the result includes the null termination
-**/
-_PUBLIC_ size_t utf16_len(const void *buf)
-{
- size_t len;
-
- for (len = 0; SVAL(buf,len); len += 2) ;
-
- return len + 2;
-}
-
-/**
-return the number of bytes occupied by a buffer in CH_UTF16 format
-the result includes the null termination
-limited by 'n' bytes
-**/
-_PUBLIC_ size_t utf16_len_n(const void *src, size_t n)
-{
- size_t len;
-
- for (len = 0; (len+2 < n) && SVAL(src, len); len += 2) ;
-
- if (len+2 <= n) {
- len += 2;
- }
-
- return len;
-}
-
-_PUBLIC_ size_t ucs2_align(const void *base_ptr, const void *p, int flags)
-{
- if (flags & (STR_NOALIGN|STR_ASCII))
- return 0;
- return PTR_DIFF(p, base_ptr) & 1;
-}
-
-/**
-Do a case-insensitive, whitespace-ignoring string compare.
-**/
-_PUBLIC_ int strwicmp(const char *psz1, const char *psz2)
-{
- /* if BOTH strings are NULL, return TRUE, if ONE is NULL return */
- /* appropriate value. */
- if (psz1 == psz2)
- return (0);
- else if (psz1 == NULL)
- return (-1);
- else if (psz2 == NULL)
- return (1);
-
- /* sync the strings on first non-whitespace */
- while (1) {
- while (isspace((int)*psz1))
- psz1++;
- while (isspace((int)*psz2))
- psz2++;
- if (toupper((unsigned char)*psz1) != toupper((unsigned char)*psz2)
- || *psz1 == '\0'
- || *psz2 == '\0')
- break;
- psz1++;
- psz2++;
- }
- return (*psz1 - *psz2);
-}
-
-/**
- String replace.
-**/
-_PUBLIC_ void string_replace(char *s, char oldc, char newc)
-{
- while (*s) {
- if (*s == oldc) *s = newc;
- s++;
- }
-}
-
-/**
- * Compare 2 strings.
- *
- * @note The comparison is case-insensitive.
- **/
-_PUBLIC_ bool strequal(const char *s1, const char *s2)
-{
- if (s1 == s2)
- return true;
- if (!s1 || !s2)
- return false;
-
- return strcasecmp(s1,s2) == 0;
-}
diff --git a/source4/lib/util/util_strlist.c b/source4/lib/util/util_strlist.c
deleted file mode 100644
index 30de4b962d..0000000000
--- a/source4/lib/util/util_strlist.c
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Copyright (C) Andrew Tridgell 2005
- Copyright (C) Jelmer Vernooij 2005
-
- 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/locale.h"
-
-/**
- * @file
- * @brief String list manipulation
- */
-
-/**
- build a null terminated list of strings from a input string and a
- separator list. The separator list must contain characters less than
- or equal to 0x2f for this to work correctly on multi-byte strings
-*/
-_PUBLIC_ const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep)
-{
- int num_elements = 0;
- const char **ret = NULL;
-
- if (sep == NULL) {
- sep = LIST_SEP;
- }
-
- ret = talloc_array(mem_ctx, const char *, 1);
- if (ret == NULL) {
- return NULL;
- }
-
- while (string && *string) {
- size_t len = strcspn(string, sep);
- const char **ret2;
-
- if (len == 0) {
- string += strspn(string, sep);
- continue;
- }
-
- ret2 = talloc_realloc(mem_ctx, ret, const char *, num_elements+2);
- if (ret2 == NULL) {
- talloc_free(ret);
- return NULL;
- }
- ret = ret2;
-
- ret[num_elements] = talloc_strndup(ret, string, len);
- if (ret[num_elements] == NULL) {
- talloc_free(ret);
- return NULL;
- }
-
- num_elements++;
- string += len;
- }
-
- ret[num_elements] = NULL;
-
- return ret;
-}
-
-/**
- * build a null terminated list of strings from an argv-like input string
- * Entries are seperated by spaces and can be enclosed by quotes.
- * Does NOT support escaping
- */
-_PUBLIC_ const char **str_list_make_shell(TALLOC_CTX *mem_ctx, const char *string, const char *sep)
-{
- int num_elements = 0;
- const char **ret = NULL;
-
- ret = talloc_array(mem_ctx, const char *, 1);
- if (ret == NULL) {
- return NULL;
- }
-
- if (sep == NULL)
- sep = " \t\n\r";
-
- while (string && *string) {
- size_t len = strcspn(string, sep);
- char *element;
- const char **ret2;
-
- if (len == 0) {
- string += strspn(string, sep);
- continue;
- }
-
- if (*string == '\"') {
- string++;
- len = strcspn(string, "\"");
- element = talloc_strndup(ret, string, len);
- string += len + 1;
- } else {
- element = talloc_strndup(ret, string, len);
- string += len;
- }
-
- if (element == NULL) {
- talloc_free(ret);
- return NULL;
- }
-
- ret2 = talloc_realloc(mem_ctx, ret, const char *, num_elements+2);
- if (ret2 == NULL) {
- talloc_free(ret);
- return NULL;
- }
- ret = ret2;
-
- ret[num_elements] = element;
-
- num_elements++;
- }
-
- ret[num_elements] = NULL;
-
- return ret;
-
-}
-
-/**
- * join a list back to one string
- */
-_PUBLIC_ char *str_list_join(TALLOC_CTX *mem_ctx, const char **list, char seperator)
-{
- char *ret = NULL;
- int i;
-
- if (list[0] == NULL)
- return talloc_strdup(mem_ctx, "");
-
- ret = talloc_strdup(mem_ctx, list[0]);
-
- for (i = 1; list[i]; i++) {
- ret = talloc_asprintf_append_buffer(ret, "%c%s", seperator, list[i]);
- }
-
- return ret;
-}
-
-/** join a list back to one (shell-like) string; entries
- * seperated by spaces, using quotes where necessary */
-_PUBLIC_ char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list, char sep)
-{
- char *ret = NULL;
- int i;
-
- if (list[0] == NULL)
- return talloc_strdup(mem_ctx, "");
-
- if (strchr(list[0], ' ') || strlen(list[0]) == 0)
- ret = talloc_asprintf(mem_ctx, "\"%s\"", list[0]);
- else
- ret = talloc_strdup(mem_ctx, list[0]);
-
- for (i = 1; list[i]; i++) {
- if (strchr(list[i], ' ') || strlen(list[i]) == 0)
- ret = talloc_asprintf_append_buffer(ret, "%c\"%s\"", sep, list[i]);
- else
- ret = talloc_asprintf_append_buffer(ret, "%c%s", sep, list[i]);
- }
-
- return ret;
-}
-
-/**
- return the number of elements in a string list
-*/
-_PUBLIC_ size_t str_list_length(const char **list)
-{
- size_t ret;
- for (ret=0;list && list[ret];ret++) /* noop */ ;
- return ret;
-}
-
-
-/**
- copy a string list
-*/
-_PUBLIC_ const char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list)
-{
- int i;
- const char **ret;
-
- if (list == NULL)
- return NULL;
-
- ret = talloc_array(mem_ctx, const char *, str_list_length(list)+1);
- if (ret == NULL)
- return NULL;
-
- for (i=0;list && list[i];i++) {
- ret[i] = talloc_strdup(ret, list[i]);
- if (ret[i] == NULL) {
- talloc_free(ret);
- return NULL;
- }
- }
- ret[i] = NULL;
- return ret;
-}
-
-/**
- Return true if all the elements of the list match exactly.
- */
-_PUBLIC_ bool str_list_equal(const char **list1, const char **list2)
-{
- int i;
-
- if (list1 == NULL || list2 == NULL) {
- return (list1 == list2);
- }
-
- for (i=0;list1[i] && list2[i];i++) {
- if (strcmp(list1[i], list2[i]) != 0) {
- return false;
- }
- }
- if (list1[i] || list2[i]) {
- return false;
- }
- return true;
-}
-
-
-/**
- add an entry to a string list
-*/
-_PUBLIC_ const char **str_list_add(const char **list, const char *s)
-{
- size_t len = str_list_length(list);
- const char **ret;
-
- ret = talloc_realloc(NULL, list, const char *, len+2);
- if (ret == NULL) return NULL;
-
- ret[len] = talloc_strdup(ret, s);
- if (ret[len] == NULL) return NULL;
-
- ret[len+1] = NULL;
-
- return ret;
-}
-
-/**
- remove an entry from a string list
-*/
-_PUBLIC_ void str_list_remove(const char **list, const char *s)
-{
- int i;
-
- for (i=0;list[i];i++) {
- if (strcmp(list[i], s) == 0) break;
- }
- if (!list[i]) return;
-
- for (;list[i];i++) {
- list[i] = list[i+1];
- }
-}
-
-
-/**
- return true if a string is in a list
-*/
-_PUBLIC_ bool str_list_check(const char **list, const char *s)
-{
- int i;
-
- for (i=0;list[i];i++) {
- if (strcmp(list[i], s) == 0) return true;
- }
- return false;
-}
-
-/**
- return true if a string is in a list, case insensitively
-*/
-_PUBLIC_ bool str_list_check_ci(const char **list, const char *s)
-{
- int i;
-
- for (i=0;list[i];i++) {
- if (strcasecmp(list[i], s) == 0) return true;
- }
- return false;
-}
-
-
diff --git a/source4/lib/util/util_tdb.c b/source4/lib/util/util_tdb.c
deleted file mode 100644
index e4219dfd69..0000000000
--- a/source4/lib/util/util_tdb.c
+++ /dev/null
@@ -1,546 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- tdb utility functions
-
- Copyright (C) Andrew Tridgell 1992-2006
-
- 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/tdb/include/tdb.h"
-#include "pstring.h"
-#include "lib/util/util_tdb.h"
-
-/* these are little tdb utility functions that are meant to make
- dealing with a tdb database a little less cumbersome in Samba */
-
-/***************************************************************
- Make a TDB_DATA and keep the const warning in one place
-****************************************************************/
-
-static TDB_DATA make_tdb_data(const char *dptr, size_t dsize)
-{
- TDB_DATA ret;
- ret.dptr = discard_const_p(unsigned char, dptr);
- ret.dsize = dsize;
- return ret;
-}
-
-/****************************************************************************
- Lock a chain by string. Return -1 if lock failed.
-****************************************************************************/
-
-int tdb_lock_bystring(struct tdb_context *tdb, const char *keyval)
-{
- TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1);
-
- return tdb_chainlock(tdb, key);
-}
-
-/****************************************************************************
- Unlock a chain by string.
-****************************************************************************/
-
-void tdb_unlock_bystring(struct tdb_context *tdb, const char *keyval)
-{
- TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1);
-
- tdb_chainunlock(tdb, key);
-}
-
-/****************************************************************************
- Read lock a chain by string. Return -1 if lock failed.
-****************************************************************************/
-
-int tdb_read_lock_bystring(struct tdb_context *tdb, const char *keyval)
-{
- TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1);
-
- return tdb_chainlock_read(tdb, key);
-}
-
-/****************************************************************************
- Read unlock a chain by string.
-****************************************************************************/
-
-void tdb_read_unlock_bystring(struct tdb_context *tdb, const char *keyval)
-{
- TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1);
-
- tdb_chainunlock_read(tdb, key);
-}
-
-
-/****************************************************************************
- Fetch a int32_t value by a arbitrary blob key, return -1 if not found.
- Output is int32_t in native byte order.
-****************************************************************************/
-
-int32_t tdb_fetch_int32_byblob(struct tdb_context *tdb, const char *keyval, size_t len)
-{
- TDB_DATA key = make_tdb_data(keyval, len);
- TDB_DATA data;
- int32_t ret;
-
- data = tdb_fetch(tdb, key);
- if (!data.dptr || data.dsize != sizeof(int32_t)) {
- SAFE_FREE(data.dptr);
- return -1;
- }
-
- ret = IVAL(data.dptr,0);
- SAFE_FREE(data.dptr);
- return ret;
-}
-
-/****************************************************************************
- Fetch a int32_t value by string key, return -1 if not found.
- Output is int32_t in native byte order.
-****************************************************************************/
-
-int32_t tdb_fetch_int32(struct tdb_context *tdb, const char *keystr)
-{
- return tdb_fetch_int32_byblob(tdb, keystr, strlen(keystr) + 1);
-}
-
-/****************************************************************************
- Store a int32_t value by an arbitary blob key, return 0 on success, -1 on failure.
- Input is int32_t in native byte order. Output in tdb is in little-endian.
-****************************************************************************/
-
-int tdb_store_int32_byblob(struct tdb_context *tdb, const char *keystr, size_t len, int32_t v)
-{
- TDB_DATA key = make_tdb_data(keystr, len);
- TDB_DATA data;
- int32_t v_store;
-
- SIVAL(&v_store,0,v);
- data.dptr = (unsigned char *)&v_store;
- data.dsize = sizeof(int32_t);
-
- return tdb_store(tdb, key, data, TDB_REPLACE);
-}
-
-/****************************************************************************
- Store a int32_t value by string key, return 0 on success, -1 on failure.
- Input is int32_t in native byte order. Output in tdb is in little-endian.
-****************************************************************************/
-
-int tdb_store_int32(struct tdb_context *tdb, const char *keystr, int32_t v)
-{
- return tdb_store_int32_byblob(tdb, keystr, strlen(keystr) + 1, v);
-}
-
-/****************************************************************************
- Fetch a uint32_t value by a arbitrary blob key, return -1 if not found.
- Output is uint32_t in native byte order.
-****************************************************************************/
-
-bool tdb_fetch_uint32_byblob(struct tdb_context *tdb, const char *keyval, size_t len, uint32_t *value)
-{
- TDB_DATA key = make_tdb_data(keyval, len);
- TDB_DATA data;
-
- data = tdb_fetch(tdb, key);
- if (!data.dptr || data.dsize != sizeof(uint32_t)) {
- SAFE_FREE(data.dptr);
- return false;
- }
-
- *value = IVAL(data.dptr,0);
- SAFE_FREE(data.dptr);
- return true;
-}
-
-/****************************************************************************
- Fetch a uint32_t value by string key, return -1 if not found.
- Output is uint32_t in native byte order.
-****************************************************************************/
-
-bool tdb_fetch_uint32(struct tdb_context *tdb, const char *keystr, uint32_t *value)
-{
- return tdb_fetch_uint32_byblob(tdb, keystr, strlen(keystr) + 1, value);
-}
-
-/****************************************************************************
- Store a uint32_t value by an arbitary blob key, return 0 on success, -1 on failure.
- Input is uint32_t in native byte order. Output in tdb is in little-endian.
-****************************************************************************/
-
-bool tdb_store_uint32_byblob(struct tdb_context *tdb, const char *keystr, size_t len, uint32_t value)
-{
- TDB_DATA key = make_tdb_data(keystr, len);
- TDB_DATA data;
- uint32_t v_store;
- bool ret = true;
-
- SIVAL(&v_store, 0, value);
- data.dptr = (unsigned char *)&v_store;
- data.dsize = sizeof(uint32_t);
-
- if (tdb_store(tdb, key, data, TDB_REPLACE) == -1)
- ret = false;
-
- return ret;
-}
-
-/****************************************************************************
- Store a uint32_t value by string key, return 0 on success, -1 on failure.
- Input is uint32_t in native byte order. Output in tdb is in little-endian.
-****************************************************************************/
-
-bool tdb_store_uint32(struct tdb_context *tdb, const char *keystr, uint32_t value)
-{
- return tdb_store_uint32_byblob(tdb, keystr, strlen(keystr) + 1, value);
-}
-/****************************************************************************
- Store a buffer by a null terminated string key. Return 0 on success, -1
- on failure.
-****************************************************************************/
-
-int tdb_store_bystring(struct tdb_context *tdb, const char *keystr, TDB_DATA data, int flags)
-{
- TDB_DATA key = make_tdb_data(keystr, strlen(keystr)+1);
-
- return tdb_store(tdb, key, data, flags);
-}
-
-/****************************************************************************
- Fetch a buffer using a null terminated string key. Don't forget to call
- free() on the result dptr.
-****************************************************************************/
-
-TDB_DATA tdb_fetch_bystring(struct tdb_context *tdb, const char *keystr)
-{
- TDB_DATA key = make_tdb_data(keystr, strlen(keystr)+1);
-
- return tdb_fetch(tdb, key);
-}
-
-/****************************************************************************
- Delete an entry using a null terminated string key.
-****************************************************************************/
-
-int tdb_delete_bystring(struct tdb_context *tdb, const char *keystr)
-{
- TDB_DATA key = make_tdb_data(keystr, strlen(keystr)+1);
-
- return tdb_delete(tdb, key);
-}
-
-/****************************************************************************
- Atomic integer change. Returns old value. To create, set initial value in *oldval.
-****************************************************************************/
-
-int32_t tdb_change_int32_atomic(struct tdb_context *tdb, const char *keystr, int32_t *oldval, int32_t change_val)
-{
- int32_t val;
- int32_t ret = -1;
-
- if (tdb_lock_bystring(tdb, keystr) == -1)
- return -1;
-
- if ((val = tdb_fetch_int32(tdb, keystr)) == -1) {
- /* The lookup failed */
- if (tdb_error(tdb) != TDB_ERR_NOEXIST) {
- /* but not because it didn't exist */
- goto err_out;
- }
-
- /* Start with 'old' value */
- val = *oldval;
-
- } else {
- /* It worked, set return value (oldval) to tdb data */
- *oldval = val;
- }
-
- /* Increment value for storage and return next time */
- val += change_val;
-
- if (tdb_store_int32(tdb, keystr, val) == -1)
- goto err_out;
-
- ret = 0;
-
- err_out:
-
- tdb_unlock_bystring(tdb, keystr);
- return ret;
-}
-
-/****************************************************************************
- Atomic unsigned integer change. Returns old value. To create, set initial value in *oldval.
-****************************************************************************/
-
-bool tdb_change_uint32_atomic(struct tdb_context *tdb, const char *keystr, uint32_t *oldval, uint32_t change_val)
-{
- uint32_t val;
- bool ret = false;
-
- if (tdb_lock_bystring(tdb, keystr) == -1)
- return false;
-
- if (!tdb_fetch_uint32(tdb, keystr, &val)) {
- /* It failed */
- if (tdb_error(tdb) != TDB_ERR_NOEXIST) {
- /* and not because it didn't exist */
- goto err_out;
- }
-
- /* Start with 'old' value */
- val = *oldval;
-
- } else {
- /* it worked, set return value (oldval) to tdb data */
- *oldval = val;
-
- }
-
- /* get a new value to store */
- val += change_val;
-
- if (!tdb_store_uint32(tdb, keystr, val))
- goto err_out;
-
- ret = true;
-
- err_out:
-
- tdb_unlock_bystring(tdb, keystr);
- return ret;
-}
-
-/****************************************************************************
- Allow tdb_delete to be used as a tdb_traversal_fn.
-****************************************************************************/
-
-int tdb_traverse_delete_fn(struct tdb_context *the_tdb, TDB_DATA key, TDB_DATA dbuf,
- void *state)
-{
- return tdb_delete(the_tdb, key);
-}
-
-
-
-/****************************************************************************
- Useful pair of routines for packing/unpacking data consisting of
- integers and strings.
-****************************************************************************/
-
-size_t tdb_pack(TDB_CONTEXT *tdb, char *buf, int bufsize, const char *fmt, ...)
-{
- va_list ap;
- uint8_t bt;
- uint16_t w;
- uint32_t d;
- int i;
- void *p;
- int len;
- char *s;
- char c;
- char *buf0 = buf;
- const char *fmt0 = fmt;
- int bufsize0 = bufsize;
- tdb_log_func log_fn = tdb_log_fn(tdb);
-
- va_start(ap, fmt);
-
- while (*fmt) {
- switch ((c = *fmt++)) {
- case 'b': /* unsigned 8-bit integer */
- len = 1;
- bt = (uint8_t)va_arg(ap, int);
- if (bufsize && bufsize >= len)
- SSVAL(buf, 0, bt);
- break;
- case 'w': /* unsigned 16-bit integer */
- len = 2;
- w = (uint16_t)va_arg(ap, int);
- if (bufsize && bufsize >= len)
- SSVAL(buf, 0, w);
- break;
- case 'd': /* signed 32-bit integer (standard int in most systems) */
- len = 4;
- d = va_arg(ap, uint32_t);
- if (bufsize && bufsize >= len)
- SIVAL(buf, 0, d);
- break;
- case 'p': /* pointer */
- len = 4;
- p = va_arg(ap, void *);
- d = p?1:0;
- if (bufsize && bufsize >= len)
- SIVAL(buf, 0, d);
- break;
- case 'P': /* null-terminated string */
- s = va_arg(ap,char *);
- w = strlen(s);
- len = w + 1;
- if (bufsize && bufsize >= len)
- memcpy(buf, s, len);
- break;
- case 'f': /* null-terminated string */
- s = va_arg(ap,char *);
- w = strlen(s);
- len = w + 1;
- if (bufsize && bufsize >= len)
- memcpy(buf, s, len);
- break;
- case 'B': /* fixed-length string */
- i = va_arg(ap, int);
- s = va_arg(ap, char *);
- len = 4+i;
- if (bufsize && bufsize >= len) {
- SIVAL(buf, 0, i);
- memcpy(buf+4, s, i);
- }
- break;
- default:
- log_fn(tdb, 0,"Unknown tdb_pack format %c in %s\n",
- c, fmt);
- len = 0;
- break;
- }
-
- buf += len;
- if (bufsize)
- bufsize -= len;
- if (bufsize < 0)
- bufsize = 0;
- }
-
- va_end(ap);
-
- log_fn(tdb, 18,"tdb_pack(%s, %d) -> %d\n",
- fmt0, bufsize0, (int)PTR_DIFF(buf, buf0));
-
- return PTR_DIFF(buf, buf0);
-}
-
-/****************************************************************************
- Useful pair of routines for packing/unpacking data consisting of
- integers and strings.
-****************************************************************************/
-
-int tdb_unpack(TDB_CONTEXT *tdb, char *buf, int bufsize, const char *fmt, ...)
-{
- va_list ap;
- uint8_t *bt;
- uint16_t *w;
- uint32_t *d;
- int len;
- int *i;
- void **p;
- char *s, **b, **ps;
- char c;
- char *buf0 = buf;
- const char *fmt0 = fmt;
- int bufsize0 = bufsize;
- tdb_log_func log_fn = tdb_log_fn(tdb);
-
- va_start(ap, fmt);
-
- while (*fmt) {
- switch ((c=*fmt++)) {
- case 'b':
- len = 1;
- bt = va_arg(ap, uint8_t *);
- if (bufsize < len)
- goto no_space;
- *bt = SVAL(buf, 0);
- break;
- case 'w':
- len = 2;
- w = va_arg(ap, uint16_t *);
- if (bufsize < len)
- goto no_space;
- *w = SVAL(buf, 0);
- break;
- case 'd':
- len = 4;
- d = va_arg(ap, uint32_t *);
- if (bufsize < len)
- goto no_space;
- *d = IVAL(buf, 0);
- break;
- case 'p':
- len = 4;
- p = va_arg(ap, void **);
- if (bufsize < len)
- goto no_space;
-
- /*
- * This isn't a real pointer - only a token (1 or 0)
- * to mark the fact a pointer is present.
- */
-
- *p = (void *)(IVAL(buf, 0) ? (void *)1 : NULL);
- break;
- case 'P':
- /* Return a malloc'ed string. */
- ps = va_arg(ap,char ** );
- len = strlen((const char *)buf) + 1;
- *ps = strdup((const char *)buf);
- break;
- case 'f':
- s = va_arg(ap,char *);
- len = strlen(buf) + 1;
- if (bufsize < len || len > sizeof(fstring))
- goto no_space;
- memcpy(s, buf, len);
- break;
- case 'B':
- i = va_arg(ap, int *);
- b = va_arg(ap, char **);
- len = 4;
- if (bufsize < len)
- goto no_space;
- *i = IVAL(buf, 0);
- if (! *i) {
- *b = NULL;
- break;
- }
- len += *i;
- if (bufsize < len)
- goto no_space;
- *b = (char *)malloc(*i);
- if (! *b)
- goto no_space;
- memcpy(*b, buf+4, *i);
- break;
- default:
- log_fn(tdb, 0, "Unknown tdb_unpack format %c in %s\n",
- c, fmt);
-
- len = 0;
- break;
- }
-
- buf += len;
- bufsize -= len;
- }
-
- va_end(ap);
-
- log_fn(tdb, 18, "tdb_unpack(%s, %d) -> %d\n",
- fmt0, bufsize0, (int)PTR_DIFF(buf, buf0));
-
- return PTR_DIFF(buf, buf0);
-
- no_space:
- return -1;
-}
diff --git a/source4/lib/util/wrap_xattr.c b/source4/lib/util/wrap_xattr.c
deleted file mode 100644
index 955f39a7eb..0000000000
--- a/source4/lib/util/wrap_xattr.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- POSIX NTVFS backend - xattr support using filesystem xattrs
-
- Copyright (C) Andrew Tridgell 2004
-
- 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/filesys.h"
-#include "lib/util/wrap_xattr.h"
-
-#if defined(HAVE_XATTR_SUPPORT) && defined(XATTR_ADDITIONAL_OPTIONS)
-static ssize_t _wrap_darwin_fgetxattr(int fd, const char *name, void *value, size_t size)
-{
- return fgetxattr(fd, name, value, size, 0, 0);
-}
-static ssize_t _wrap_darwin_getxattr(const char *path, const char *name, void *value, size_t size)
-{
- return getxattr(path, name, value, size, 0, 0);
-}
-static int _wrap_darwin_fsetxattr(int fd, const char *name, void *value, size_t size, int flags)
-{
- return fsetxattr(fd, name, value, size, 0, flags);
-}
-static int _wrap_darwin_setxattr(const char *path, const char *name, void *value, size_t size, int flags)
-{
- return setxattr(path, name, value, size, 0, flags);
-}
-static int _wrap_darwin_fremovexattr(int fd, const char *name)
-{
- return fremovexattr(fd, name, 0);
-}
-static int _wrap_darwin_removexattr(const char *path, const char *name)
-{
- return removexattr(path, name, 0);
-}
-#define fgetxattr _wrap_darwin_fgetxattr
-#define getxattr _wrap_darwin_getxattr
-#define fsetxattr _wrap_darwin_fsetxattr
-#define setxattr _wrap_darwin_setxattr
-#define fremovexattr _wrap_darwin_fremovexattr
-#define removexattr _wrap_darwin_removexattr
-#elif !defined(HAVE_XATTR_SUPPORT)
-static ssize_t _none_fgetxattr(int fd, const char *name, void *value, size_t size)
-{
- errno = ENOSYS;
- return -1;
-}
-static ssize_t _none_getxattr(const char *path, const char *name, void *value, size_t size)
-{
- errno = ENOSYS;
- return -1;
-}
-static int _none_fsetxattr(int fd, const char *name, void *value, size_t size, int flags)
-{
- errno = ENOSYS;
- return -1;
-}
-static int _none_setxattr(const char *path, const char *name, void *value, size_t size, int flags)
-{
- errno = ENOSYS;
- return -1;
-}
-static int _none_fremovexattr(int fd, const char *name)
-{
- errno = ENOSYS;
- return -1;
-}
-static int _none_removexattr(const char *path, const char *name)
-{
- errno = ENOSYS;
- return -1;
-}
-#define fgetxattr _none_fgetxattr
-#define getxattr _none_getxattr
-#define fsetxattr _none_fsetxattr
-#define setxattr _none_setxattr
-#define fremovexattr _none_fremovexattr
-#define removexattr _none_removexattr
-#endif
-
-_PUBLIC_ ssize_t wrap_fgetxattr(int fd, const char *name, void *value, size_t size)
-{
- return fgetxattr(fd, name, value, size);
-}
-_PUBLIC_ ssize_t wrap_getxattr(const char *path, const char *name, void *value, size_t size)
-{
- return getxattr(path, name, value, size);
-}
-_PUBLIC_ int wrap_fsetxattr(int fd, const char *name, void *value, size_t size, int flags)
-{
- return fsetxattr(fd, name, value, size, flags);
-}
-_PUBLIC_ int wrap_setxattr(const char *path, const char *name, void *value, size_t size, int flags)
-{
- return setxattr(path, name, value, size, flags);
-}
-_PUBLIC_ int wrap_fremovexattr(int fd, const char *name)
-{
- return fremovexattr(fd, name);
-}
-_PUBLIC_ int wrap_removexattr(const char *path, const char *name)
-{
- return removexattr(path, name);
-}
-
diff --git a/source4/lib/util/wrap_xattr.h b/source4/lib/util/wrap_xattr.h
deleted file mode 100644
index 64b28d250c..0000000000
--- a/source4/lib/util/wrap_xattr.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef __LIB_UTIL_WRAP_XATTR_H__
-#define __LIB_UTIL_WRAP_XATTR_H__
-
-ssize_t wrap_fgetxattr(int fd, const char *name, void *value, size_t size);
-ssize_t wrap_getxattr(const char *path, const char *name, void *value, size_t size);
-int wrap_fsetxattr(int fd, const char *name, void *value, size_t size, int flags);
-int wrap_setxattr(const char *path, const char *name, void *value, size_t size, int flags);
-int wrap_fremovexattr(int fd, const char *name);
-int wrap_removexattr(const char *path, const char *name);
-
-#endif /* __LIB_UTIL_WRAP_XATTR_H__ */
-
diff --git a/source4/lib/util/xattr.m4 b/source4/lib/util/xattr.m4
deleted file mode 100644
index 497809a47a..0000000000
--- a/source4/lib/util/xattr.m4
+++ /dev/null
@@ -1,32 +0,0 @@
-dnl ############################################
-dnl use flistxattr as the key function for having
-dnl sufficient xattr support for posix xattr backend
-AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h)
-AC_SEARCH_LIBS_EXT(flistxattr, [attr], XATTR_LIBS)
-AC_CHECK_FUNC_EXT(flistxattr, $XATTR_LIBS)
-SMB_EXT_LIB(XATTR,[${XATTR_LIBS}],[${XATTR_CFLAGS}],[${XATTR_CPPFLAGS}],[${XATTR_LDFLAGS}])
-if test x"$ac_cv_func_ext_flistxattr" = x"yes"; then
- AC_CACHE_CHECK([whether xattr interface takes additional options], smb_attr_cv_xattr_add_opt,
- [old_LIBS=$LIBS
- LIBS="$LIBS $XATTRLIBS"
- AC_TRY_COMPILE([
- #include <sys/types.h>
- #if HAVE_ATTR_XATTR_H
- #include <attr/xattr.h>
- #elif HAVE_SYS_XATTR_H
- #include <sys/xattr.h>
- #endif
- #ifndef NULL
- #define NULL ((void *)0)
- #endif
- ],[
- getxattr(NULL, NULL, NULL, 0, 0, 0);
- ],smb_attr_cv_xattr_add_opt=yes,smb_attr_cv_xattr_add_opt=no)
- LIBS=$old_LIBS])
- if test x"$smb_attr_cv_xattr_add_opt" = x"yes"; then
- AC_DEFINE(XATTR_ADDITIONAL_OPTIONS, 1, [xattr functions have additional options])
- fi
- AC_DEFINE(HAVE_XATTR_SUPPORT,1,[Whether we have xattr support])
- SMB_ENABLE(XATTR,YES)
-fi
-
diff --git a/source4/lib/util/xfile.c b/source4/lib/util/xfile.c
deleted file mode 100644
index a016031a77..0000000000
--- a/source4/lib/util/xfile.c
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- stdio replacement
- 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/>.
-*/
-
-/**
- * @file
- * @brief scalable FILE replacement
- */
-
-/*
- stdio is very convenient, but on some systems the file descriptor
- in FILE* is 8 bits, so it fails when more than 255 files are open.
-
- XFILE replaces stdio. It is less efficient, but at least it works
- when you have lots of files open
-
- The main restriction on XFILE is that it doesn't support seeking,
- and doesn't support O_RDWR. That keeps the code simple.
-*/
-
-#include "includes.h"
-#include "system/filesys.h"
-
-#define XBUFSIZE BUFSIZ
-
-static XFILE _x_stdin = { 0, NULL, NULL, XBUFSIZE, 0, O_RDONLY, X_IOFBF, 0 };
-static XFILE _x_stdout = { 1, NULL, NULL, XBUFSIZE, 0, O_WRONLY, X_IOLBF, 0 };
-static XFILE _x_stderr = { 2, NULL, NULL, 0, 0, O_WRONLY, X_IONBF, 0 };
-
-XFILE *x_stdin = &_x_stdin;
-XFILE *x_stdout = &_x_stdout;
-XFILE *x_stderr = &_x_stderr;
-
-#define X_FLAG_EOF 1
-#define X_FLAG_ERROR 2
-#define X_FLAG_EINVAL 3
-
-/** simulate setvbuf() */
-int x_setvbuf(XFILE *f, char *buf, int mode, size_t size)
-{
- x_fflush(f);
- if (f->bufused) return -1;
-
- /* on files being read full buffering is the only option */
- if ((f->open_flags & O_ACCMODE) == O_RDONLY) {
- mode = X_IOFBF;
- }
-
- /* destroy any earlier buffer */
- SAFE_FREE(f->buf);
- f->buf = 0;
- f->bufsize = 0;
- f->next = NULL;
- f->bufused = 0;
- f->buftype = mode;
-
- if (f->buftype == X_IONBF) return 0;
-
- /* if buffering then we need some size */
- if (size == 0) size = XBUFSIZE;
-
- f->bufsize = size;
- f->bufused = 0;
-
- return 0;
-}
-
-/* allocate the buffer */
-static int x_allocate_buffer(XFILE *f)
-{
- if (f->buf) return 1;
- if (f->bufsize == 0) return 0;
- f->buf = (char *)malloc(f->bufsize);
- if (!f->buf) return 0;
- f->next = f->buf;
- return 1;
-}
-
-
-/** this looks more like open() than fopen(), but that is quite deliberate.
- I want programmers to *think* about O_EXCL, O_CREAT etc not just
- get them magically added
-*/
-XFILE *x_fopen(const char *fname, int flags, mode_t mode)
-{
- XFILE *ret;
-
- ret = malloc_p(XFILE);
- if (!ret) return NULL;
-
- memset(ret, 0, sizeof(XFILE));
-
- if ((flags & O_ACCMODE) == O_RDWR) {
- /* we don't support RDWR in XFILE - use file
- descriptors instead */
- errno = EINVAL;
- return NULL;
- }
-
- ret->open_flags = flags;
-
- ret->fd = open(fname, flags, mode);
- if (ret->fd == -1) {
- SAFE_FREE(ret);
- return NULL;
- }
-
- x_setvbuf(ret, NULL, X_IOFBF, XBUFSIZE);
-
- return ret;
-}
-
-/** simulate fclose() */
-int x_fclose(XFILE *f)
-{
- int ret;
-
- /* make sure we flush any buffered data */
- x_fflush(f);
-
- ret = close(f->fd);
- f->fd = -1;
- if (f->buf) {
- /* make sure data can't leak into a later malloc */
- memset(f->buf, 0, f->bufsize);
- SAFE_FREE(f->buf);
- }
- /* check the file descriptor given to the function is NOT one of the static
- * descriptor of this libreary or we will free unallocated memory
- * --sss */
- if (f != x_stdin && f != x_stdout && f != x_stderr) {
- SAFE_FREE(f);
- }
- return ret;
-}
-
-/** simulate fwrite() */
-size_t x_fwrite(const void *p, size_t size, size_t nmemb, XFILE *f)
-{
- ssize_t ret;
- size_t total=0;
-
- /* we might be writing unbuffered */
- if (f->buftype == X_IONBF ||
- (!f->buf && !x_allocate_buffer(f))) {
- ret = write(f->fd, p, size*nmemb);
- if (ret == -1) return -1;
- return ret/size;
- }
-
-
- while (total < size*nmemb) {
- size_t n = f->bufsize - f->bufused;
- n = MIN(n, (size*nmemb)-total);
-
- if (n == 0) {
- /* it's full, flush it */
- x_fflush(f);
- continue;
- }
-
- memcpy(f->buf + f->bufused, total+(const char *)p, n);
- f->bufused += n;
- total += n;
- }
-
- /* when line buffered we need to flush at the last linefeed. This can
- flush a bit more than necessary, but that is harmless */
- if (f->buftype == X_IOLBF && f->bufused) {
- int i;
- for (i=(size*nmemb)-1; i>=0; i--) {
- if (*(i+(const char *)p) == '\n') {
- x_fflush(f);
- break;
- }
- }
- }
-
- return total/size;
-}
-
-/** thank goodness for asprintf() */
- int x_vfprintf(XFILE *f, const char *format, va_list ap)
-{
- char *p;
- int len, ret;
- va_list ap2;
-
- va_copy(ap2, ap);
- len = vasprintf(&p, format, ap2);
- va_end(ap2);
- if (len <= 0) return len;
- ret = x_fwrite(p, 1, len, f);
- SAFE_FREE(p);
- return ret;
-}
-
- int x_fprintf(XFILE *f, const char *format, ...)
-{
- va_list ap;
- int ret;
-
- va_start(ap, format);
- ret = x_vfprintf(f, format, ap);
- va_end(ap);
- return ret;
-}
-
-/* at least fileno() is simple! */
-int x_fileno(XFILE *f)
-{
- return f->fd;
-}
-
-/** simulate fflush() */
-int x_fflush(XFILE *f)
-{
- int ret;
-
- if (f->flags & X_FLAG_ERROR) return -1;
-
- if ((f->open_flags & O_ACCMODE) != O_WRONLY) {
- errno = EINVAL;
- return -1;
- }
-
- if (f->bufused == 0) return 0;
-
- ret = write(f->fd, f->buf, f->bufused);
- if (ret == -1) return -1;
-
- f->bufused -= ret;
- if (f->bufused > 0) {
- f->flags |= X_FLAG_ERROR;
- memmove(f->buf, ret + (char *)f->buf, f->bufused);
- return -1;
- }
-
- return 0;
-}
-
-/** simulate setbuffer() */
-void x_setbuffer(XFILE *f, char *buf, size_t size)
-{
- x_setvbuf(f, buf, buf?X_IOFBF:X_IONBF, size);
-}
-
-/** simulate setbuf() */
-void x_setbuf(XFILE *f, char *buf)
-{
- x_setvbuf(f, buf, buf?X_IOFBF:X_IONBF, XBUFSIZE);
-}
-
-/** simulate setlinebuf() */
-void x_setlinebuf(XFILE *f)
-{
- x_setvbuf(f, NULL, X_IOLBF, 0);
-}
-
-
-/** simulate feof() */
-int x_feof(XFILE *f)
-{
- if (f->flags & X_FLAG_EOF) return 1;
- return 0;
-}
-
-/** simulate ferror() */
-int x_ferror(XFILE *f)
-{
- if (f->flags & X_FLAG_ERROR) return 1;
- return 0;
-}
-
-/* fill the read buffer */
-static void x_fillbuf(XFILE *f)
-{
- int n;
-
- if (f->bufused) return;
-
- if (!f->buf && !x_allocate_buffer(f)) return;
-
- n = read(f->fd, f->buf, f->bufsize);
- if (n <= 0) return;
- f->bufused = n;
- f->next = f->buf;
-}
-
-/** simulate fgetc() */
-int x_fgetc(XFILE *f)
-{
- int ret;
-
- if (f->flags & (X_FLAG_EOF | X_FLAG_ERROR)) return EOF;
-
- if (f->bufused == 0) x_fillbuf(f);
-
- if (f->bufused == 0) {
- f->flags |= X_FLAG_EOF;
- return EOF;
- }
-
- ret = *(uint8_t *)(f->next);
- f->next++;
- f->bufused--;
- return ret;
-}
-
-/** simulate fread */
-size_t x_fread(void *p, size_t size, size_t nmemb, XFILE *f)
-{
- size_t total = 0;
- while (total < size*nmemb) {
- int c = x_fgetc(f);
- if (c == EOF) break;
- (total+(char *)p)[0] = (char)c;
- total++;
- }
- return total/size;
-}
-
-/** simulate fgets() */
-char *x_fgets(char *s, int size, XFILE *stream)
-{
- char *s0 = s;
- int l = size;
- while (l>1) {
- int c = x_fgetc(stream);
- if (c == EOF) break;
- *s++ = (char)c;
- l--;
- if (c == '\n') break;
- }
- if (l==size || x_ferror(stream)) {
- return 0;
- }
- *s = 0;
- return s0;
-}
-
-/**
- * trivial seek, works only for SEEK_SET and SEEK_END if SEEK_CUR is
- * set then an error is returned */
-off_t x_tseek(XFILE *f, off_t offset, int whence)
-{
- if (f->flags & X_FLAG_ERROR)
- return -1;
-
- /* only SEEK_SET and SEEK_END are supported */
- /* SEEK_CUR needs internal offset counter */
- if (whence != SEEK_SET && whence != SEEK_END) {
- f->flags |= X_FLAG_EINVAL;
- errno = EINVAL;
- return -1;
- }
-
- /* empty the buffer */
- switch (f->open_flags & O_ACCMODE) {
- case O_RDONLY:
- f->bufused = 0;
- break;
- case O_WRONLY:
- if (x_fflush(f) != 0)
- return -1;
- break;
- default:
- errno = EINVAL;
- return -1;
- }
-
- f->flags &= ~X_FLAG_EOF;
- return lseek(f->fd, offset, whence);
-}
diff --git a/source4/lib/util/xfile.h b/source4/lib/util/xfile.h
deleted file mode 100644
index 2cc369d8d8..0000000000
--- a/source4/lib/util/xfile.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- stdio replacement
- 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/>.
-*/
-
-#ifndef _XFILE_H_
-#define _XFILE_H_
-/*
- see xfile.c for explanations
-*/
-
-typedef struct {
- int fd;
- char *buf;
- char *next;
- int bufsize;
- int bufused;
- int open_flags;
- int buftype;
- int flags;
-} XFILE;
-
-extern XFILE *x_stdin, *x_stdout, *x_stderr;
-
-/* buffering type */
-#define X_IOFBF 0
-#define X_IOLBF 1
-#define X_IONBF 2
-
-#define x_getc(f) x_fgetc(f)
-
-int x_vfprintf(XFILE *f, const char *format, va_list ap) PRINTF_ATTRIBUTE(2, 0);
-int x_fprintf(XFILE *f, const char *format, ...) PRINTF_ATTRIBUTE(2, 3);
-
-/** simulate setvbuf() */
-int x_setvbuf(XFILE *f, char *buf, int mode, size_t size);
-
-/** this looks more like open() than fopen(), but that is quite deliberate.
- I want programmers to *think* about O_EXCL, O_CREAT etc not just
- get them magically added
-*/
-XFILE *x_fopen(const char *fname, int flags, mode_t mode);
-
-/** simulate fclose() */
-int x_fclose(XFILE *f);
-
-/** simulate fwrite() */
-size_t x_fwrite(const void *p, size_t size, size_t nmemb, XFILE *f);
-
-/** thank goodness for asprintf() */
-int x_fileno(XFILE *f);
-
-/** simulate fflush() */
-int x_fflush(XFILE *f);
-
-/** simulate setbuffer() */
-void x_setbuffer(XFILE *f, char *buf, size_t size);
-
-/** simulate setbuf() */
-void x_setbuf(XFILE *f, char *buf);
-
-/** simulate setlinebuf() */
-void x_setlinebuf(XFILE *f);
-
-/** simulate feof() */
-int x_feof(XFILE *f);
-
-/** simulate ferror() */
-int x_ferror(XFILE *f);
-
-/** simulate fgetc() */
-int x_fgetc(XFILE *f);
-
-/** simulate fread */
-size_t x_fread(void *p, size_t size, size_t nmemb, XFILE *f);
-
-/** simulate fgets() */
-char *x_fgets(char *s, int size, XFILE *stream) ;
-
-/**
- * trivial seek, works only for SEEK_SET and SEEK_END if SEEK_CUR is
- * set then an error is returned */
-off_t x_tseek(XFILE *f, off_t offset, int whence);
-
-#endif /* _XFILE_H_ */
diff --git a/source4/lib/wmi/config.mk b/source4/lib/wmi/config.mk
new file mode 100644
index 0000000000..28f6c73dcd
--- /dev/null
+++ b/source4/lib/wmi/config.mk
@@ -0,0 +1,69 @@
+[SUBSYSTEM::WMI]
+PUBLIC_DEPENDENCIES = RPC_NDR_OXIDRESOLVER \
+ NDR_DCOM \
+ RPC_NDR_REMACT \
+ NDR_TABLE \
+ DCOM_PROXY_DCOM \
+ DCOM
+
+WMI_OBJ_FILES = $(addprefix $(wmisrcdir)/, wmicore.o wbemdata.o ../../librpc/gen_ndr/dcom_p.o)
+
+#################################
+# Start BINARY wmic
+[BINARY::wmic]
+INSTALLDIR = BINDIR
+PRIVATE_DEPENDENCIES = \
+ POPT_SAMBA \
+ POPT_CREDENTIALS \
+ LIBPOPT \
+ WMI
+
+wmic_OBJ_FILES = $(wmisrcdir)/tools/wmic.o
+# End BINARY wmic
+#################################
+
+#################################
+# Start BINARY wmis
+[BINARY::wmis]
+INSTALLDIR = BINDIR
+PRIVATE_DEPENDENCIES = \
+ POPT_SAMBA \
+ POPT_CREDENTIALS \
+ LIBPOPT \
+ WMI
+
+wmis_OBJ_FILES = \
+ $(wmisrcdir)/tools/wmis.o
+
+# End BINARY wmis
+#################################
+
+librpc/gen_ndr/dcom_p.c: idl
+
+#######################
+# Start LIBRARY swig_dcerpc
+[PYTHON::pywmi]
+PUBLIC_DEPENDENCIES = LIBCLI_SMB NDR_MISC LIBSAMBA-UTIL LIBSAMBA-CONFIG WMI
+
+$(eval $(call python_py_module_template,wmi.py,$(wmisrcdir)/wmi.py))
+
+pywmi_OBJ_FILES = $(wmisrcdir)/wmi_wrap.o
+$(pywmi_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
+
+# End LIBRARY swig_dcerpc
+#######################
+
+#################################
+# Start BINARY pdhc
+#[BINARY::pdhc]
+#INSTALLDIR = BINDIR
+#OBJ_FILES = \
+# pdhc.o
+#PRIVATE_DEPENDENCIES = \
+# POPT_SAMBA \
+# POPT_CREDENTIALS \
+# LIBPOPT \
+# NDR_TABLE \
+# RPC_NDR_WINREG
+# End BINARY pdhc
+#################################
diff --git a/source4/lib/wmi/tools/wmic.c b/source4/lib/wmi/tools/wmic.c
new file mode 100644
index 0000000000..bbfe5ed334
--- /dev/null
+++ b/source4/lib/wmi/tools/wmic.c
@@ -0,0 +1,221 @@
+/*
+ WMI Sample client
+ Copyright (C) 2006 Andrzej Hajda <andrzej.hajda@wp.pl>
+ Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "lib/cmdline/popt_common.h"
+#include "librpc/rpc/dcerpc.h"
+#include "librpc/gen_ndr/ndr_oxidresolver.h"
+#include "librpc/gen_ndr/ndr_oxidresolver_c.h"
+#include "librpc/gen_ndr/ndr_dcom.h"
+#include "librpc/gen_ndr/ndr_dcom_c.h"
+#include "librpc/gen_ndr/ndr_remact_c.h"
+#include "librpc/gen_ndr/ndr_epmapper_c.h"
+#include "librpc/gen_ndr/com_dcom.h"
+
+#include "lib/com/dcom/dcom.h"
+#include "lib/com/com.h"
+
+#include "lib/wmi/wmi.h"
+
+struct program_args {
+ char *hostname;
+ char *query;
+ char *ns;
+};
+
+static void parse_args(int argc, char *argv[], struct program_args *pmyargs)
+{
+ poptContext pc;
+ int opt, i;
+
+ int argc_new;
+ char **argv_new;
+
+ struct poptOption long_options[] = {
+ POPT_AUTOHELP
+ POPT_COMMON_SAMBA
+ POPT_COMMON_CONNECTION
+ POPT_COMMON_CREDENTIALS
+ POPT_COMMON_VERSION
+ {"namespace", 0, POPT_ARG_STRING, &pmyargs->ns, 0,
+ "WMI namespace, default to root\\cimv2", 0},
+ POPT_TABLEEND
+ };
+
+ pc = poptGetContext("wmi", argc, (const char **) argv,
+ long_options, POPT_CONTEXT_KEEP_FIRST);
+
+ poptSetOtherOptionHelp(pc, "//host query\n\nExample: wmic -U [domain/]adminuser%password //host \"select * from Win32_ComputerSystem\"");
+
+ while ((opt = poptGetNextOpt(pc)) != -1) {
+ poptPrintUsage(pc, stdout, 0);
+ poptFreeContext(pc);
+ exit(1);
+ }
+
+ argv_new = discard_const_p(char *, poptGetArgs(pc));
+
+ argc_new = argc;
+ for (i = 0; i < argc; i++) {
+ if (argv_new[i] == NULL) {
+ argc_new = i;
+ break;
+ }
+ }
+
+ if (argc_new != 3 || argv_new[1][0] != '/'
+ || argv_new[1][1] != '/') {
+ poptPrintUsage(pc, stdout, 0);
+ poptFreeContext(pc);
+ exit(1);
+ }
+
+ pmyargs->hostname = argv_new[1] + 2;
+ pmyargs->query = argv_new[2];
+ poptFreeContext(pc);
+}
+
+#define WERR_CHECK(msg) if (!W_ERROR_IS_OK(result)) { \
+ DEBUG(0, ("ERROR: %s\n", msg)); \
+ goto error; \
+ } else { \
+ DEBUG(1, ("OK : %s\n", msg)); \
+ }
+
+#define RETURN_CVAR_ARRAY_STR(fmt, arr) {\
+ uint32_t i;\
+ char *r;\
+\
+ if (!arr) {\
+ return talloc_strdup(mem_ctx, "NULL");\
+ }\
+ r = talloc_strdup(mem_ctx, "(");\
+ for (i = 0; i < arr->count; ++i) {\
+ r = talloc_asprintf_append(r, fmt "%s", arr->item[i], (i+1 == arr->count)?"":",");\
+ }\
+ return talloc_asprintf_append(r, ")");\
+}
+
+char *string_CIMVAR(TALLOC_CTX *mem_ctx, union CIMVAR *v, enum CIMTYPE_ENUMERATION cimtype)
+{
+ switch (cimtype) {
+ case CIM_SINT8: return talloc_asprintf(mem_ctx, "%d", v->v_sint8);
+ case CIM_UINT8: return talloc_asprintf(mem_ctx, "%u", v->v_uint8);
+ case CIM_SINT16: return talloc_asprintf(mem_ctx, "%d", v->v_sint16);
+ case CIM_UINT16: return talloc_asprintf(mem_ctx, "%u", v->v_uint16);
+ case CIM_SINT32: return talloc_asprintf(mem_ctx, "%d", v->v_sint32);
+ case CIM_UINT32: return talloc_asprintf(mem_ctx, "%u", v->v_uint32);
+ case CIM_SINT64: return talloc_asprintf(mem_ctx, "%lld", v->v_sint64);
+ case CIM_UINT64: return talloc_asprintf(mem_ctx, "%llu", v->v_sint64);
+ case CIM_REAL32: return talloc_asprintf(mem_ctx, "%f", (double)v->v_uint32);
+ case CIM_REAL64: return talloc_asprintf(mem_ctx, "%f", (double)v->v_uint64);
+ case CIM_BOOLEAN: return talloc_asprintf(mem_ctx, "%s", v->v_boolean?"True":"False");
+ case CIM_STRING:
+ case CIM_DATETIME:
+ case CIM_REFERENCE: return talloc_asprintf(mem_ctx, "%s", v->v_string);
+ case CIM_CHAR16: return talloc_asprintf(mem_ctx, "Unsupported");
+ case CIM_OBJECT: return talloc_asprintf(mem_ctx, "Unsupported");
+ case CIM_ARR_SINT8: RETURN_CVAR_ARRAY_STR("%d", v->a_sint8);
+ case CIM_ARR_UINT8: RETURN_CVAR_ARRAY_STR("%u", v->a_uint8);
+ case CIM_ARR_SINT16: RETURN_CVAR_ARRAY_STR("%d", v->a_sint16);
+ case CIM_ARR_UINT16: RETURN_CVAR_ARRAY_STR("%u", v->a_uint16);
+ case CIM_ARR_SINT32: RETURN_CVAR_ARRAY_STR("%d", v->a_sint32);
+ case CIM_ARR_UINT32: RETURN_CVAR_ARRAY_STR("%u", v->a_uint32);
+ case CIM_ARR_SINT64: RETURN_CVAR_ARRAY_STR("%lld", v->a_sint64);
+ case CIM_ARR_UINT64: RETURN_CVAR_ARRAY_STR("%llu", v->a_uint64);
+ case CIM_ARR_REAL32: RETURN_CVAR_ARRAY_STR("%f", v->a_real32);
+ case CIM_ARR_REAL64: RETURN_CVAR_ARRAY_STR("%f", v->a_real64);
+ case CIM_ARR_BOOLEAN: RETURN_CVAR_ARRAY_STR("%d", v->a_boolean);
+ case CIM_ARR_STRING: RETURN_CVAR_ARRAY_STR("%s", v->a_string);
+ case CIM_ARR_DATETIME: RETURN_CVAR_ARRAY_STR("%s", v->a_datetime);
+ case CIM_ARR_REFERENCE: RETURN_CVAR_ARRAY_STR("%s", v->a_reference);
+ default: return talloc_asprintf(mem_ctx, "Unsupported");
+ }
+}
+
+#undef RETURN_CVAR_ARRAY_STR
+
+int main(int argc, char **argv)
+{
+ struct program_args args = {};
+ uint32_t cnt = 5, ret;
+ char *class_name = NULL;
+ WERROR result;
+ NTSTATUS status;
+ struct IWbemServices *pWS = NULL;
+ struct BSTR queryLanguage, query;
+ struct IEnumWbemClassObject *pEnum = NULL;
+ struct com_context *ctx = NULL;
+
+ parse_args(argc, argv, &args);
+
+ wmi_init(&ctx, cmdline_credentials);
+
+ if (!args.ns)
+ args.ns = "root\\cimv2";
+ result = WBEM_ConnectServer(ctx, args.hostname, args.ns, 0, 0, 0, 0, 0, 0, &pWS);
+ WERR_CHECK("Login to remote object.");
+
+ queryLanguage.data = "WQL";
+ query.data = args.query;
+ result = IWbemServices_ExecQuery(pWS, ctx, queryLanguage, query, WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_ENSURE_LOCATABLE, NULL, &pEnum);
+ WERR_CHECK("WMI query execute.");
+
+ IEnumWbemClassObject_Reset(pEnum, ctx);
+ WERR_CHECK("Reset result of WMI query.");
+
+ do {
+ uint32_t i, j;
+ struct WbemClassObject *co[cnt];
+
+ result = IEnumWbemClassObject_SmartNext(pEnum, ctx, 0xFFFFFFFF, cnt, co, &ret);
+ /* WERR_BADFUNC is OK, it means only that there is less returned objects than requested */
+ if (!W_ERROR_EQUAL(result, WERR_BADFUNC)) {
+ WERR_CHECK("Retrieve result data.");
+ } else {
+ DEBUG(1, ("OK : Retrieved less objects than requested (it is normal).\n"));
+ }
+ if (!ret) break;
+
+ for (i = 0; i < ret; ++i) {
+ if (!class_name || strcmp(co[i]->obj_class->__CLASS, class_name)) {
+ if (class_name) talloc_free(class_name);
+ class_name = talloc_strdup(ctx, co[i]->obj_class->__CLASS);
+ printf("CLASS: %s\n", class_name);
+ for (j = 0; j < co[i]->obj_class->__PROPERTY_COUNT; ++j)
+ printf("%s%s", j?"|":"", co[i]->obj_class->properties[j].property.name);
+ printf("\n");
+ }
+ for (j = 0; j < co[i]->obj_class->__PROPERTY_COUNT; ++j) {
+ char *s;
+ s = string_CIMVAR(ctx, &co[i]->instance->data[j], co[i]->obj_class->properties[j].property.desc->cimtype & CIM_TYPEMASK);
+ printf("%s%s", j?"|":"", s);
+ }
+ printf("\n");
+ }
+ } while (ret == cnt);
+ talloc_free(ctx);
+ return 0;
+error:
+ status = werror_to_ntstatus(result);
+ fprintf(stderr, "NTSTATUS: %s - %s\n", nt_errstr(status), get_friendly_nt_error_msg(status));
+ talloc_free(ctx);
+ return 1;
+}
diff --git a/source4/lib/wmi/tools/wmis.c b/source4/lib/wmi/tools/wmis.c
new file mode 100644
index 0000000000..314fdd1cd7
--- /dev/null
+++ b/source4/lib/wmi/tools/wmis.c
@@ -0,0 +1,221 @@
+/*
+ WMI Sample client
+ Copyright (C) 2006 Andrzej Hajda <andrzej.hajda@wp.pl>
+ Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "lib/cmdline/popt_common.h"
+#include "auth/credentials/credentials.h"
+#include "librpc/rpc/dcerpc.h"
+#include "librpc/gen_ndr/ndr_oxidresolver.h"
+#include "librpc/gen_ndr/ndr_oxidresolver_c.h"
+#include "librpc/gen_ndr/dcom.h"
+#include "librpc/gen_ndr/ndr_dcom.h"
+#include "librpc/gen_ndr/ndr_dcom_c.h"
+#include "librpc/gen_ndr/ndr_remact_c.h"
+#include "librpc/gen_ndr/ndr_epmapper_c.h"
+#include "librpc/gen_ndr/com_dcom.h"
+
+#include "lib/com/dcom/dcom.h"
+#include "librpc/gen_ndr/com_wmi.h"
+#include "librpc/ndr/ndr_table.h"
+
+#include "lib/wmi/wmi.h"
+
+struct program_args {
+ char *hostname;
+ char *query;
+};
+
+static void parse_args(int argc, char *argv[], struct program_args *pmyargs)
+{
+ poptContext pc;
+ int opt, i;
+
+ int argc_new;
+ char **argv_new;
+
+ struct poptOption long_options[] = {
+ POPT_AUTOHELP
+ POPT_COMMON_SAMBA
+ POPT_COMMON_CONNECTION
+ POPT_COMMON_CREDENTIALS
+ POPT_COMMON_VERSION
+ POPT_TABLEEND
+ };
+
+ pc = poptGetContext("wmi", argc, (const char **) argv,
+ long_options, POPT_CONTEXT_KEEP_FIRST);
+
+ poptSetOtherOptionHelp(pc, "//host\n\nExample: wmis -U [domain/]adminuser%password //host");
+
+ while ((opt = poptGetNextOpt(pc)) != -1) {
+ poptPrintUsage(pc, stdout, 0);
+ poptFreeContext(pc);
+ exit(1);
+ }
+
+ argv_new = discard_const_p(char *, poptGetArgs(pc));
+
+ argc_new = argc;
+ for (i = 0; i < argc; i++) {
+ if (argv_new[i] == NULL) {
+ argc_new = i;
+ break;
+ }
+ }
+
+ if (argc_new < 2 || argv_new[1][0] != '/'
+ || argv_new[1][1] != '/') {
+ poptPrintUsage(pc, stdout, 0);
+ poptFreeContext(pc);
+ exit(1);
+ }
+
+ pmyargs->hostname = argv_new[1] + 2;
+ poptFreeContext(pc);
+}
+
+#define WERR_CHECK(msg) if (!W_ERROR_IS_OK(result)) { \
+ DEBUG(0, ("ERROR: %s\n", msg)); \
+ goto error; \
+ } else { \
+ DEBUG(1, ("OK : %s\n", msg)); \
+ }
+/*
+WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const char *nspace, const char *user, const char *password, const char *locale, uint32_t flags, const char *authority, struct IWbemContext* wbem_ctx, struct IWbemServices** services)
+{
+ struct GUID clsid;
+ struct GUID iid;
+ WERROR result, coresult;
+ struct IUnknown **mqi;
+ struct IWbemLevel1Login *pL;
+
+ if (user) {
+ char *cred;
+ struct cli_credentials *cc;
+
+ cred = talloc_asprintf(NULL, "%s%%%s", user, password);
+ cc = cli_credentials_init(ctx);
+ cli_credentials_set_conf(cc);
+ cli_credentials_parse_string(cc, cred, CRED_SPECIFIED);
+ dcom_set_server_credentials(ctx, server, cc);
+ talloc_free(cred);
+ }
+
+ GUID_from_string(CLSID_WBEMLEVEL1LOGIN, &clsid);
+ GUID_from_string(COM_IWBEMLEVEL1LOGIN_UUID, &iid);
+ result = dcom_create_object(ctx, &clsid, server, 1, &iid, &mqi, &coresult);
+ WERR_CHECK("dcom_create_object.");
+ result = coresult;
+ WERR_CHECK("Create remote WMI object.");
+ pL = (struct IWbemLevel1Login *)mqi[0];
+ talloc_free(mqi);
+
+ result = IWbemLevel1Login_NTLMLogin(pL, ctx, nspace, locale, flags, wbem_ctx, services);
+ WERR_CHECK("Login to remote object.");
+error:
+ return result;
+}
+*/
+WERROR WBEM_RemoteExecute(struct IWbemServices *pWS, const char *cmdline, uint32_t *ret_code)
+{
+ struct IWbemClassObject *wco = NULL;
+ struct IWbemClassObject *inc, *outc, *in;
+ struct IWbemClassObject *out = NULL;
+ WERROR result;
+ union CIMVAR v;
+ TALLOC_CTX *ctx;
+ struct BSTR objectPath, methodName;
+
+ ctx = talloc_new(0);
+
+ objectPath.data = "Win32_Process";
+
+ result = IWbemServices_GetObject(pWS, ctx, objectPath,
+ WBEM_FLAG_RETURN_WBEM_COMPLETE, NULL, &wco, NULL);
+ WERR_CHECK("GetObject.");
+
+ result = IWbemClassObject_GetMethod(wco, ctx, "Create", 0, &inc, &outc);
+ WERR_CHECK("IWbemClassObject_GetMethod.");
+
+ result = IWbemClassObject_SpawnInstance(inc, ctx, 0, &in);
+ WERR_CHECK("IWbemClassObject_SpawnInstance.");
+
+ v.v_string = cmdline;
+ result = IWbemClassObject_Put(in, ctx, "CommandLine", 0, &v, 0);
+ WERR_CHECK("IWbemClassObject_Put(CommandLine).");
+
+ methodName.data = "Create";
+ result = IWbemServices_ExecMethod(pWS, ctx, objectPath, methodName, 0, NULL, in, &out,
+ NULL);
+ WERR_CHECK("IWbemServices_ExecMethod.");
+
+ if (ret_code) {
+ result = WbemClassObject_Get(out->object_data, ctx, "ReturnValue", 0, &v, 0, 0);
+ WERR_CHECK("IWbemClassObject_Put(CommandLine).");
+ *ret_code = v.v_uint32;
+ }
+error:
+ talloc_free(ctx);
+ return result;
+}
+
+int main(int argc, char **argv)
+{
+ struct program_args args = {};
+ struct com_context *ctx = NULL;
+ WERROR result;
+ NTSTATUS status;
+ struct IWbemServices *pWS = NULL;
+ struct IEnumWbemClassObject *pEnum = NULL;
+ uint32_t cnt;
+ struct BSTR queryLanguage;
+ struct BSTR query;
+
+ parse_args(argc, argv, &args);
+
+ wmi_init(&ctx, cmdline_credentials);
+ result = WBEM_ConnectServer(ctx, args.hostname, "root\\cimv2", 0, 0, 0, 0, 0, 0, &pWS);
+ WERR_CHECK("WBEM_ConnectServer.");
+
+ printf("1: Creating directory C:\\wmi_test_dir_tmp using method Win32_Process.Create\n");
+ WBEM_RemoteExecute(pWS, "cmd.exe /C mkdir C:\\wmi_test_dir_tmp", &cnt);
+ WERR_CHECK("WBEM_RemoteExecute.");
+ printf("2: ReturnCode: %d\n", cnt);
+
+ printf("3: Monitoring directory C:\\wmi_test_dir_tmp. Please create/delete files in that directory to see notifications, after 4 events program quits.\n");
+ query.data = "SELECT * FROM __InstanceOperationEvent WITHIN 1 WHERE Targetinstance ISA 'CIM_DirectoryContainsFile' and TargetInstance.GroupComponent= 'Win32_Directory.Name=\"C:\\\\\\\\wmi_test_dir_tmp\"'";
+ queryLanguage.data = "WQL";
+ result = IWbemServices_ExecNotificationQuery(pWS, ctx, queryLanguage,
+ query, WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum);
+ WERR_CHECK("WMI query execute.");
+ for (cnt = 0; cnt < 4; ++cnt) {
+ struct WbemClassObject *co;
+ uint32_t ret;
+ result = IEnumWbemClassObject_SmartNext(pEnum, ctx, 0xFFFFFFFF, 1, &co, &ret);
+ WERR_CHECK("IEnumWbemClassObject_Next.");
+ printf("%s\n", co->obj_class->__CLASS);
+ }
+
+error:
+ status = werror_to_ntstatus(result);
+ fprintf(stderr, "NTSTATUS: %s - %s\n", nt_errstr(status), get_friendly_nt_error_msg(status));
+ talloc_free(ctx);
+ return 1;
+}
diff --git a/source4/lib/wmi/wbemdata.c b/source4/lib/wmi/wbemdata.c
new file mode 100644
index 0000000000..57e4022e7c
--- /dev/null
+++ b/source4/lib/wmi/wbemdata.c
@@ -0,0 +1,451 @@
+/*
+ WMI Implementation
+ Copyright (C) 2006 Andrzej Hajda <andrzej.hajda@wp.pl>
+ Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "librpc/gen_ndr/dcom.h"
+#include "librpc/gen_ndr/com_dcom.h"
+#include "librpc/ndr/libndr.h"
+#include "librpc/ndr/libndr_proto.h"
+#include "lib/com/com.h"
+#include "lib/com/dcom/dcom.h"
+#include "lib/util/dlinklist.h"
+#include "librpc/ndr/libndr.h"
+#include "librpc/gen_ndr/ndr_dcom.h"
+#include "librpc/rpc/dcerpc.h"
+#include "librpc/gen_ndr/ndr_misc.h"
+#include "lib/talloc/talloc.h"
+#include "libcli/composite/composite.h"
+#include "lib/wmi/wmi.h"
+#include "librpc/gen_ndr/ndr_wmi.h"
+
+enum {
+ DATATYPE_CLASSOBJECT = 2,
+ DATATYPE_OBJECT = 3,
+ COFLAG_IS_CLASS = 4,
+};
+
+static enum ndr_err_code marshal(TALLOC_CTX *mem_ctx, struct IUnknown *pv, struct OBJREF *o)
+{
+ struct ndr_push *ndr;
+ struct IWbemClassObject *wco;
+ struct MInterfacePointer *mp;
+
+ mp = (struct MInterfacePointer *)((char *)o - offsetof(struct MInterfacePointer, obj)); /* FIXME:high remove this Mumbo Jumbo */
+ wco = pv->object_data;
+ ndr = talloc_zero(mem_ctx, struct ndr_push);
+ ndr->flags = 0;
+ ndr->alloc_size = 1024;
+ ndr->data = talloc_array(mp, uint8_t, ndr->alloc_size);
+
+ if (wco) {
+ uint32_t ofs;
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x12345678));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_IWbemClassObject(ndr, NDR_SCALARS | NDR_BUFFERS, wco));
+ ofs = ndr->offset;
+ ndr->offset = 4;
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ofs - 8));
+ ndr->offset = ofs;
+ } else {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ }
+ o->u_objref.u_custom.pData = talloc_realloc(mp, ndr->data, uint8_t, ndr->offset);
+ o->u_objref.u_custom.size = ndr->offset;
+ mp->size = sizeof(struct OBJREF) - sizeof(union OBJREF_Types) + sizeof(struct u_custom) + o->u_objref.u_custom.size - 4;
+ if (DEBUGLVL(9)) {
+ NDR_PRINT_DEBUG(IWbemClassObject, wco);
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code unmarshal(TALLOC_CTX *mem_ctx, struct OBJREF *o, struct IUnknown **pv)
+{
+ struct ndr_pull *ndr;
+ struct IWbemClassObject *wco;
+ enum ndr_err_code ndr_err;
+ uint32_t u;
+
+ mem_ctx = talloc_new(0);
+ ndr = talloc_zero(mem_ctx, struct ndr_pull);
+ ndr->current_mem_ctx = mem_ctx;
+ ndr->data = o->u_objref.u_custom.pData;
+ ndr->data_size = o->u_objref.u_custom.size;
+
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
+ if (!u) {
+ talloc_free(*pv);
+ *pv = NULL;
+ return NDR_ERR_SUCCESS;
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
+ if (u + 8 > ndr->data_size) {
+ DEBUG(1, ("unmarshall_IWbemClassObject: Incorrect data_size"));
+ return NDR_ERR_BUFSIZE;
+ }
+ wco = talloc_zero(*pv, struct IWbemClassObject);
+ ndr->current_mem_ctx = wco;
+ ndr_err = ndr_pull_IWbemClassObject(ndr, NDR_SCALARS | NDR_BUFFERS, wco);
+
+ if (NDR_ERR_CODE_IS_SUCCESS(ndr_err) && (DEBUGLVL(9))) {
+ NDR_PRINT_DEBUG(IWbemClassObject, wco);
+ }
+
+ if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ (*pv)->object_data = wco;
+ } else {
+ talloc_free(wco);
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+WERROR dcom_IWbemClassObject_from_WbemClassObject(struct com_context *ctx, struct IWbemClassObject **_p, struct IWbemClassObject *wco)
+{
+ struct IWbemClassObject *p;
+
+ p = talloc_zero(ctx, struct IWbemClassObject);
+ p->ctx = ctx;
+ p->obj.signature = 0x574f454d;
+ p->obj.flags = OBJREF_CUSTOM;
+ GUID_from_string("dc12a681-737f-11cf-884d-00aa004b2e24", &p->obj.iid);
+ GUID_from_string("4590f812-1d3a-11d0-891f-00aa004b2e24", &p->obj.u_objref.u_custom.clsid);
+ p->object_data = (void *)wco;
+ talloc_steal(p, p->object_data);
+ *_p = p;
+ return WERR_OK;
+}
+
+WERROR IWbemClassObject_GetMethod(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, struct IWbemClassObject **in, struct IWbemClassObject **out)
+{
+ uint32_t i;
+ struct IWbemClassObject *wco;
+
+ wco = (struct IWbemClassObject *)d->object_data;
+ for (i = 0; i < wco->obj_methods->count; ++i)
+ if (!strcmp(wco->obj_methods->method[i].name, name)) {
+ if (in) dcom_IWbemClassObject_from_WbemClassObject(d->ctx, in, wco->obj_methods->method[i].in);
+ if (out) dcom_IWbemClassObject_from_WbemClassObject(d->ctx, out, wco->obj_methods->method[i].out);
+ return WERR_OK;
+ }
+ return WERR_NOT_FOUND;
+}
+
+void IWbemClassObject_CreateInstance(struct IWbemClassObject *wco)
+{
+ uint32_t i;
+
+ wco->instance = talloc_zero(wco, struct WbemInstance);
+ wco->instance->default_flags = talloc_array(wco->instance, uint8_t, wco->obj_class->__PROPERTY_COUNT);
+ wco->instance->data = talloc_array(wco->instance, union CIMVAR, wco->obj_class->__PROPERTY_COUNT);
+ memset(wco->instance->data, 0, sizeof(union CIMVAR) * wco->obj_class->__PROPERTY_COUNT);
+ for (i = 0; i < wco->obj_class->__PROPERTY_COUNT; ++i) {
+ wco->instance->default_flags[i] = 1; /* FIXME:high resolve this magic */
+ }
+ wco->instance->__CLASS = wco->obj_class->__CLASS;
+ wco->instance->u2_4 = 4;
+ wco->instance->u3_1 = 1;
+}
+
+WERROR IWbemClassObject_Clone(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, struct IWbemClassObject **copy)
+{
+ return WERR_NOT_SUPPORTED;
+}
+
+WERROR IWbemClassObject_SpawnInstance(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, uint32_t flags, struct IWbemClassObject **instance)
+{
+ struct IWbemClassObject *wco, *nwco;
+
+ wco = (struct IWbemClassObject *)d->object_data;
+ nwco = talloc_zero(mem_ctx, struct IWbemClassObject);
+ nwco->flags = WCF_INSTANCE;
+ nwco->obj_class = wco->obj_class;
+ IWbemClassObject_CreateInstance(nwco);
+ dcom_IWbemClassObject_from_WbemClassObject(d->ctx, instance, nwco);
+ return WERR_OK;
+}
+
+WERROR IWbemClassObject_Get(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, union CIMVAR *val, enum CIMTYPE_ENUMERATION *cimtype, uint32_t *flavor)
+{
+ uint32_t i;
+ for (i = 0; i < d->obj_class->__PROPERTY_COUNT; ++i) {
+ if (!strcmp(d->obj_class->properties[i].property.name, name)) {
+ duplicate_CIMVAR(mem_ctx, &d->instance->data[i], val, d->obj_class->properties[i].property.desc->cimtype);
+ if (cimtype != NULL)
+ *cimtype = d->obj_class->properties[i].property.desc->cimtype;
+ if (flavor != NULL)
+ *flavor = 0; /* FIXME:avg implement flavor */
+ return WERR_OK;
+ }
+ }
+ return WERR_NOT_FOUND;
+}
+
+WERROR IWbemClassObject_Put(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, union CIMVAR *val, enum CIMTYPE_ENUMERATION cimtype)
+{
+ struct IWbemClassObject *wco;
+ uint32_t i;
+
+ wco = (struct IWbemClassObject *)d->object_data;
+ for (i = 0; i < wco->obj_class->__PROPERTY_COUNT; ++i) {
+ if (!strcmp(wco->obj_class->properties[i].property.name, name)) {
+ if (cimtype && cimtype != wco->obj_class->properties[i].property.desc->cimtype) return WERR_INVALID_PARAM;
+ wco->instance->default_flags[i] = 0;
+ duplicate_CIMVAR(wco->instance, val, &wco->instance->data[i], wco->obj_class->properties[i].property.desc->cimtype);
+ return WERR_OK;
+ }
+ }
+ return WERR_NOT_FOUND;
+}
+
+#define WERR_CHECK(msg) if (!W_ERROR_IS_OK(result)) { \
+ DEBUG(1, ("ERROR: %s - %s\n", msg, wmi_errstr(result))); \
+ return result; \
+ } else { \
+ DEBUG(1, ("OK : %s\n", msg)); \
+ }
+
+struct pair_guid_ptr {
+ struct GUID guid;
+ void *ptr;
+ struct pair_guid_ptr *next, *prev;
+};
+
+static void *get_ptr_by_guid(struct pair_guid_ptr *list, struct GUID *uuid)
+{
+ for (; list; list = list->next) {
+ if (GUID_equal(&list->guid, uuid))
+ return list->ptr;
+ }
+ return NULL;
+}
+
+static void add_pair_guid_ptr(TALLOC_CTX *mem_ctx, struct pair_guid_ptr **list, struct GUID *uuid, void *ptr)
+{
+ struct pair_guid_ptr *e;
+
+ e = talloc(mem_ctx, struct pair_guid_ptr);
+ e->guid = *uuid;
+ e->ptr = ptr;
+ talloc_steal(e, ptr);
+ DLIST_ADD(*list, e);
+}
+
+struct IEnumWbemClassObject_data {
+ struct GUID guid;
+ struct IWbemFetchSmartEnum *pFSE;
+ struct IWbemWCOSmartEnum *pSE;
+ struct pair_guid_ptr *cache;
+};
+#define NDR_CHECK_EXPR(expr) do { if (!(expr)) {\
+ DEBUG(0, ("%s(%d): WBEMDATA_ERR(0x%08X): Error parsing(%s)\n", __FILE__, __LINE__, ndr->offset, #expr)); \
+ return NDR_ERR_VALIDATE; \
+ } \
+ } while(0)
+
+#define NDR_CHECK_CONST(val, exp) NDR_CHECK_EXPR((val) == (exp))
+
+
+static enum ndr_err_code WBEMDATA_Parse(TALLOC_CTX *mem_ctx, uint8_t *data, uint32_t size, struct IEnumWbemClassObject *d, uint32_t uCount, struct IWbemClassObject **apObjects)
+{
+ struct ndr_pull *ndr;
+ uint32_t u, i, ofs_next;
+ uint8_t u8, datatype;
+ struct GUID guid;
+ struct IEnumWbemClassObject_data *ecod;
+
+ if (!uCount)
+ return NDR_ERR_BAD_SWITCH;
+
+ ecod = d->object_data;
+
+ ndr = talloc_zero(mem_ctx, struct ndr_pull);
+ ndr->current_mem_ctx = d->ctx;
+ ndr->data = data;
+ ndr->data_size = size;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
+
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
+ NDR_CHECK_CONST(u, 0x0);
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
+ NDR_CHECK_CONST(u, *(const uint32_t *)"WBEM");
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
+ NDR_CHECK_CONST(u, *(const uint32_t *)"DATA");
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
+ NDR_CHECK_CONST(u, 0x1A); /* Length of header */
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
+ NDR_PULL_NEED_BYTES(ndr, u + 6);
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
+ NDR_CHECK_CONST(u, 0x0);
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &u8));
+ NDR_CHECK_CONST(u8, 0x01); /* Major Version */
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &u8));
+ NDR_CHECK_EXPR(u8 <= 1); /* Minor Version 0 - Win2000, 1 - XP/2003 */
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
+ NDR_CHECK_CONST(u, 0x8); /* Length of header */
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
+ NDR_PULL_NEED_BYTES(ndr, u);
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
+ NDR_CHECK_CONST(u, 0xC); /* Length of header */
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
+ NDR_PULL_NEED_BYTES(ndr, u + 4);
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
+ NDR_CHECK_CONST(u, uCount);
+ for (i = 0; i < uCount; ++i) {
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
+ NDR_CHECK_CONST(u, 0x9); /* Length of header */
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
+ NDR_PULL_NEED_BYTES(ndr, u + 1);
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &datatype));
+ ofs_next = ndr->offset + u;
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
+ NDR_CHECK_CONST(u, 0x18); /* Length of header */
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
+ NDR_PULL_NEED_BYTES(ndr, u + 16);
+ NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &guid));
+ switch (datatype) {
+ case DATATYPE_CLASSOBJECT:
+ apObjects[i] = talloc_zero(d->ctx, struct IWbemClassObject);
+ ndr->current_mem_ctx = apObjects[i];
+ NDR_CHECK(ndr_pull_WbemClassObject(ndr, NDR_SCALARS|NDR_BUFFERS, apObjects[i]));
+ ndr->current_mem_ctx = d->ctx;
+ add_pair_guid_ptr(ecod, &ecod->cache, &guid, apObjects[i]->obj_class);
+ break;
+ case DATATYPE_OBJECT:
+ apObjects[i] = talloc_zero(d->ctx, struct IWbemClassObject);
+ apObjects[i]->obj_class = get_ptr_by_guid(ecod->cache, &guid);
+ (void)talloc_reference(apObjects[i], apObjects[i]->obj_class);
+ ndr->current_mem_ctx = apObjects[i];
+ NDR_CHECK(ndr_pull_WbemClassObject_Object(ndr, NDR_SCALARS|NDR_BUFFERS, apObjects[i]));
+ ndr->current_mem_ctx = d->ctx;
+ break;
+ default:
+ DEBUG(0, ("WBEMDATA_Parse: Data type %d not supported\n", datatype));
+ return NDR_ERR_BAD_SWITCH;
+ }
+ ndr->offset = ofs_next;
+ if (DEBUGLVL(9)) {
+ NDR_PRINT_DEBUG(IWbemClassObject, apObjects[i]);
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX *mem_ctx, int32_t lTimeout, uint32_t uCount, struct IWbemClassObject **apObjects, uint32_t *puReturned)
+{
+ WERROR result;
+ NTSTATUS status;
+ struct IEnumWbemClassObject_data *ecod;
+ TALLOC_CTX *loc_ctx;
+ uint32_t size;
+ uint8_t *data;
+
+ loc_ctx = talloc_new(0);
+ ecod = d->object_data;
+ if (!ecod) {
+ struct GUID iid;
+ WERROR coresult;
+
+ d->object_data = ecod = talloc_zero(d, struct IEnumWbemClassObject_data);
+ GUID_from_string(COM_IWBEMFETCHSMARTENUM_UUID, &iid);
+ result = dcom_query_interface((struct IUnknown *)d, 5, 1, &iid, (struct IUnknown **)&ecod->pFSE, &coresult);
+ WERR_CHECK("dcom_query_interface.");
+ result = coresult;
+ WERR_CHECK("Retrieve enumerator of result(IWbemFetchSmartEnum).");
+
+ result = IWbemFetchSmartEnum_Fetch(ecod->pFSE, mem_ctx, &ecod->pSE);
+ WERR_CHECK("Retrieve enumerator of result(IWbemWCOSmartEnum).");
+
+ ecod->guid = GUID_random();
+ d->vtable->Release_send = dcom_proxy_IEnumWbemClassObject_Release_send;
+ }
+
+ result = IWbemWCOSmartEnum_Next(ecod->pSE, loc_ctx, &ecod->guid, lTimeout, uCount, puReturned, &size, &data);
+ if (!W_ERROR_EQUAL(result, WERR_BADFUNC)) {
+ WERR_CHECK("IWbemWCOSmartEnum_Next.");
+ }
+
+ if (data) {
+ NDR_CHECK(WBEMDATA_Parse(mem_ctx, data, size, d, *puReturned, apObjects));
+ }
+ if (!W_ERROR_IS_OK(result)) {
+ status = werror_to_ntstatus(result);
+ DEBUG(9, ("dcom_proxy_IEnumWbemClassObject_Next: %s - %s\n", nt_errstr(status), get_friendly_nt_error_msg(status)));
+ }
+ talloc_free(loc_ctx);
+ return result;
+}
+
+struct composite_context *dcom_proxy_IEnumWbemClassObject_Release_send(struct IUnknown *d, TALLOC_CTX *mem_ctx)
+{
+ struct composite_context *c, *cr;
+ struct REMINTERFACEREF iref[3];
+ struct dcom_object_exporter *ox;
+ struct IEnumWbemClassObject_data *ecod;
+ int n;
+
+ c = composite_create(d->ctx, d->ctx->event_ctx);
+ if (c == NULL) return NULL;
+ c->private_data = d;
+
+ ox = object_exporter_by_ip(d->ctx, d);
+ iref[0].ipid = IUnknown_ipid(d);
+ iref[0].cPublicRefs = 5;
+ iref[0].cPrivateRefs = 0;
+ n = 1;
+
+ ecod = d->object_data;
+ if (ecod) {
+ if (ecod->pFSE) {
+ talloc_steal(d, ecod->pFSE);
+ iref[n].ipid = IUnknown_ipid(ecod->pFSE);
+ iref[n].cPublicRefs = 5;
+ iref[n].cPrivateRefs = 0;
+ ++n;
+ }
+ if (ecod->pSE) {
+ talloc_steal(d, ecod->pSE);
+ iref[n].ipid = IUnknown_ipid(ecod->pSE);
+ iref[n].cPublicRefs = 5;
+ iref[n].cPrivateRefs = 0;
+ ++n;
+ }
+ }
+ cr = IRemUnknown_RemRelease_send(ox->rem_unknown, mem_ctx, n, iref);
+
+ composite_continue(c, cr, dcom_release_continue, c);
+ return c;
+}
+
+NTSTATUS dcom_proxy_IWbemClassObject_init(void)
+{
+ struct GUID clsid;
+ GUID_from_string("4590f812-1d3a-11d0-891f-00aa004b2e24", &clsid);
+ dcom_register_marshal(&clsid, marshal, unmarshal);
+
+#if 0
+ struct IEnumWbemClassObject_vtable *proxy_vtable;
+ proxy_vtable = (struct IEnumWbemClassObject_vtable *)dcom_proxy_vtable_by_iid((struct GUID *)&dcerpc_table_IEnumWbemClassObject.syntax_id.uuid);
+ if (proxy_vtable)
+ proxy_vtable->Release_send = dcom_proxy_IEnumWbemClassObject_Release_send;
+ else
+ DEBUG(0, ("WARNING: IEnumWbemClassObject should be initialized before IWbemClassObject."));
+#endif
+
+ return NT_STATUS_OK;
+}
diff --git a/source4/lib/wmi/wmi.h b/source4/lib/wmi/wmi.h
new file mode 100644
index 0000000000..46c9b70cdb
--- /dev/null
+++ b/source4/lib/wmi/wmi.h
@@ -0,0 +1,48 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+ Copyright (C) Jelmer Vernooij <jelmer@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 _WMI_H_
+#define _WMI_H_
+
+#include "librpc/gen_ndr/com_wmi.h"
+
+/* The following definitions come from lib/wmi/wmicore.c */
+
+
+/** FIXME: Use credentials struct rather than user/password here */
+WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const char *nspace,
+ struct cli_credentials *credentials,
+ const char *locale, uint32_t flags, const char *authority,
+ struct IWbemContext* wbem_ctx, struct IWbemServices** services);
+const char *wmi_errstr(WERROR werror);
+
+/* The following definitions come from lib/wmi/wbemdata.c */
+
+WERROR IWbemClassObject_GetMethod(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, struct IWbemClassObject **in, struct IWbemClassObject **out);
+void WbemClassObject_CreateInstance(struct IWbemClassObject *wco);
+WERROR IWbemClassObject_Clone(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, struct IWbemClassObject **copy);
+WERROR IWbemClassObject_SpawnInstance(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, uint32_t flags, struct IWbemClassObject **instance);
+WERROR IWbemClassObject_Get(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, union CIMVAR *val, enum CIMTYPE_ENUMERATION *cimtype, uint32_t *flavor);
+WERROR IWbemClassObject_Put(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, union CIMVAR *val, enum CIMTYPE_ENUMERATION cimtype);
+WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX *mem_ctx, int32_t lTimeout, uint32_t uCount, struct IWbemClassObject **apObjects, uint32_t *puReturned);
+struct composite_context *dcom_proxy_IEnumWbemClassObject_Release_send(struct IUnknown *d, TALLOC_CTX *mem_ctx);
+
+void wmi_init(struct com_context **ctx, struct cli_credentials *credentials);
+
+#endif
diff --git a/source4/lib/wmi/wmi.i b/source4/lib/wmi/wmi.i
new file mode 100644
index 0000000000..2c8bbe517e
--- /dev/null
+++ b/source4/lib/wmi/wmi.i
@@ -0,0 +1,352 @@
+/*
+ WMI Implementation
+ Copyright (C) 2006 Andrzej Hajda <andrzej.hajda@wp.pl>
+ Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+%module wmi
+
+%include "typemaps.i"
+%include "libcli/util/errors.i"
+%import "stdint.i"
+%import "lib/talloc/talloc.i"
+
+%runtime %{
+void push_object(PyObject **stack, PyObject *o)
+{
+ if ((!*stack) || (*stack == Py_None)) {
+ *stack = o;
+ } else {
+ PyObject *o2, *o3;
+ if (!PyTuple_Check(*stack)) {
+ o2 = *stack;
+ *stack = PyTuple_New(1);
+ PyTuple_SetItem(*stack,0,o2);
+ }
+ o3 = PyTuple_New(1);
+ PyTuple_SetItem(o3,0,o);
+ o2 = *stack;
+ *stack = PySequence_Concat(o2,o3);
+ Py_DECREF(o2);
+ Py_DECREF(o3);
+ }
+}
+%}
+
+%{
+#include "includes.h"
+#include "librpc/gen_ndr/misc.h"
+#include "librpc/rpc/dcerpc.h"
+#include "lib/com/dcom/dcom.h"
+#include "librpc/gen_ndr/com_dcom.h"
+#include "lib/wmi/wmi.h"
+
+
+WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const char *nspace, const char *user, const char *password,
+ const char *locale, uint32_t flags, const char *authority, struct IWbemContext* wbem_ctx, struct IWbemServices** services);
+WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX *mem_ctx, int32_t lTimeout,uint32_t uCount,
+ struct WbemClassObject **apObjects, uint32_t *puReturned);
+
+static PyObject *PyObject_FromCVAR(uint32_t cimtype, union CIMVAR *cvar);
+static PyObject *PySWbemObject_FromWbemClassObject(struct WbemClassObject *wco);
+
+static struct com_context *com_ctx;
+static PyObject *ComError;
+static PyObject *mod_win32_client;
+static PyObject *mod_pywintypes;
+
+typedef struct IUnknown IUnknown;
+typedef struct IWbemServices IWbemServices;
+typedef struct IWbemClassObject IWbemClassObject;
+typedef struct IEnumWbemClassObject IEnumWbemClassObject;
+%}
+
+%wrapper %{
+
+#define RETURN_CVAR_ARRAY(fmt, arr) {\
+ PyObject *l, *o;\
+ uint32_t i;\
+\
+ if (!arr) {\
+ Py_INCREF(Py_None);\
+ return Py_None;\
+ }\
+ l = PyList_New(arr->count);\
+ if (!l) return NULL;\
+ for (i = 0; i < arr->count; ++i) {\
+ o = _Py_BuildValue(fmt, arr->item[i]);\
+ if (!o) {\
+ Py_DECREF(l);\
+ return NULL;\
+ }\
+ PyList_SET_ITEM(l, i, o);\
+ }\
+ return l;\
+}
+
+static PyObject *_Py_BuildValue(char *str, ...)
+{
+ PyObject * result = NULL;
+ va_list lst;
+ va_start(lst, str);
+ if (str && *str == 'I') {
+ uint32_t value = va_arg(lst, uint32_t);
+ if (value & 0x80000000) {
+ result = Py_BuildValue("L", (long)value);
+ } else {
+ result = Py_BuildValue("i", value);
+ }
+ } else {
+ result = Py_VaBuildValue(str, lst);
+ }
+ va_end(lst);
+ return result;
+}
+
+
+static PyObject *PyObject_FromCVAR(uint32_t cimtype, union CIMVAR *cvar)
+{
+ switch (cimtype) {
+ case CIM_SINT8: return Py_BuildValue("b", cvar->v_sint8);
+ case CIM_UINT8: return Py_BuildValue("B", cvar->v_uint8);
+ case CIM_SINT16: return Py_BuildValue("h", cvar->v_sint16);
+ case CIM_UINT16: return Py_BuildValue("H", cvar->v_uint16);
+ case CIM_SINT32: return Py_BuildValue("i", cvar->v_sint32);
+ case CIM_UINT32: return _Py_BuildValue("I", cvar->v_uint32);
+ case CIM_SINT64: return Py_BuildValue("L", cvar->v_sint64);
+ case CIM_UINT64: return Py_BuildValue("K", cvar->v_uint64);
+ case CIM_REAL32: return Py_BuildValue("f", cvar->v_real32);
+ case CIM_REAL64: return Py_BuildValue("d", cvar->v_real64);
+ case CIM_BOOLEAN: return Py_BuildValue("h", cvar->v_boolean);
+ case CIM_STRING: return Py_BuildValue("s", cvar->v_string);
+ case CIM_DATETIME: return Py_BuildValue("s", cvar->v_datetime);
+ case CIM_REFERENCE: return Py_BuildValue("s", cvar->v_reference);
+ case CIM_OBJECT: return PySWbemObject_FromWbemClassObject(cvar->v_object);
+ case CIM_ARR_SINT8: RETURN_CVAR_ARRAY("b", cvar->a_sint8);
+ case CIM_ARR_UINT8: RETURN_CVAR_ARRAY("B", cvar->a_uint8);
+ case CIM_ARR_SINT16: RETURN_CVAR_ARRAY("h", cvar->a_sint16);
+ case CIM_ARR_UINT16: RETURN_CVAR_ARRAY("H", cvar->a_uint16);
+ case CIM_ARR_SINT32: RETURN_CVAR_ARRAY("i", cvar->a_sint32);
+ case CIM_ARR_UINT32: RETURN_CVAR_ARRAY("I", cvar->a_uint32);
+ case CIM_ARR_SINT64: RETURN_CVAR_ARRAY("L", cvar->a_sint64);
+ case CIM_ARR_UINT64: RETURN_CVAR_ARRAY("K", cvar->a_uint64);
+ case CIM_ARR_REAL32: RETURN_CVAR_ARRAY("f", cvar->a_real32);
+ case CIM_ARR_REAL64: RETURN_CVAR_ARRAY("d", cvar->a_real64);
+ case CIM_ARR_BOOLEAN: RETURN_CVAR_ARRAY("h", cvar->a_boolean);
+ case CIM_ARR_STRING: RETURN_CVAR_ARRAY("s", cvar->a_string);
+ case CIM_ARR_DATETIME: RETURN_CVAR_ARRAY("s", cvar->a_datetime);
+ case CIM_ARR_REFERENCE: RETURN_CVAR_ARRAY("s", cvar->a_reference);
+ default:
+ {
+ char *str;
+ str = talloc_asprintf(NULL, "Unsupported CIMTYPE(0x%04X)", cimtype);
+ PyErr_SetString(PyExc_RuntimeError, str);
+ talloc_free(str);
+ return NULL;
+ }
+ }
+}
+
+#undef RETURN_CVAR_ARRAY
+
+PyObject *PySWbemObject_InitProperites(PyObject *o, struct WbemClassObject *wco)
+{
+ PyObject *properties;
+ PyObject *addProp;
+ uint32_t i;
+ int32_t r;
+ PyObject *result;
+
+ result = NULL;
+ properties = PyObject_GetAttrString(o, "Properties_");
+ if (!properties) return NULL;
+ addProp = PyObject_GetAttrString(properties, "Add");
+ if (!addProp) {
+ Py_DECREF(properties);
+ return NULL;
+ }
+
+ for (i = 0; i < wco->obj_class->__PROPERTY_COUNT; ++i) {
+ PyObject *args, *property;
+
+ args = Py_BuildValue("(si)", wco->obj_class->properties[i].property.name, wco->obj_class->properties[i].property.desc->cimtype & CIM_TYPEMASK);
+ if (!args) goto finish;
+ property = PyObject_CallObject(addProp, args);
+ Py_DECREF(args);
+ if (!property) goto finish;
+ if (wco->flags & WCF_INSTANCE) {
+ PyObject *value;
+
+ if (wco->instance->default_flags[i] & 1) {
+ value = Py_None;
+ Py_INCREF(Py_None);
+ } else
+ value = PyObject_FromCVAR(wco->obj_class->properties[i].property.desc->cimtype & CIM_TYPEMASK, &wco->instance->data[i]);
+ if (!value) {
+ Py_DECREF(property);
+ goto finish;
+ }
+ r = PyObject_SetAttrString(property, "Value", value);
+ Py_DECREF(value);
+ if (r == -1) {
+ PyErr_SetString(PyExc_RuntimeError, "Error setting value of property");
+ goto finish;
+ }
+ }
+ Py_DECREF(property);
+ }
+
+ Py_INCREF(Py_None);
+ result = Py_None;
+finish:
+ Py_DECREF(addProp);
+ Py_DECREF(properties);
+ return result;
+}
+
+static PyObject *PySWbemObject_FromWbemClassObject(struct WbemClassObject *wco)
+{
+ PyObject *swo_class, *swo, *args, *result;
+
+ swo_class = PyObject_GetAttrString(mod_win32_client, "SWbemObject");
+ if (!swo_class) return NULL;
+ args = PyTuple_New(0);
+ if (!args) {
+ Py_DECREF(swo_class);
+ return NULL;
+ }
+ swo = PyObject_CallObject(swo_class, args);
+ Py_DECREF(args);
+ Py_DECREF(swo_class);
+ if (!swo) return NULL;
+
+ result = PySWbemObject_InitProperites(swo, wco);
+ if (!result) {
+ Py_DECREF(swo);
+ return NULL;
+ }
+ Py_DECREF(result);
+
+ return swo;
+}
+
+%}
+
+%typemap(in, numinputs=0) struct com_context *ctx {
+ $1 = com_ctx;
+}
+
+%typemap(in, numinputs=0) struct IWbemServices **services (struct IWbemServices *temp) {
+ $1 = &temp;
+}
+
+%typemap(argout) struct IWbemServices **services {
+ PyObject *o;
+ o = SWIG_NewPointerObj(*$1, SWIGTYPE_p_IWbemServices, 0);
+ push_object(&$result, o);
+}
+
+WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const char *nspace, const char *user, const char *password,
+ const char *locale, uint32_t flags, const char *authority, struct IWbemContext* wbem_ctx, struct IWbemServices** services);
+
+%typemap(in, numinputs=0) struct IEnumWbemClassObject **ppEnum (struct IEnumWbemClassObject *temp) {
+ $1 = &temp;
+}
+
+%typemap(argout) struct IEnumWbemClassObject **ppEnum {
+ PyObject *o;
+ o = SWIG_NewPointerObj(*$1, SWIGTYPE_p_IEnumWbemClassObject, 0);
+ push_object(&$result, o);
+}
+
+typedef struct IUnknown {
+ %extend {
+ uint32_t Release(TALLOC_CTX *mem_ctx);
+ }
+} IUnknown;
+
+%typemap(in) struct BSTR {
+ $1.data = PyString_AsString($input);
+}
+
+
+typedef struct IWbemServices {
+ %extend {
+ WERROR ExecQuery(TALLOC_CTX *mem_ctx, struct BSTR strQueryLanguage, struct BSTR strQuery, int32_t lFlags, struct IWbemContext *pCtx, struct IEnumWbemClassObject **ppEnum);
+ WERROR ExecNotificationQuery(TALLOC_CTX *mem_ctx, struct BSTR strQueryLanguage, struct BSTR strQuery, int32_t lFlags, struct IWbemContext *pCtx, struct IEnumWbemClassObject **ppEnum);
+ WERROR CreateInstanceEnum(TALLOC_CTX *mem_ctx, struct BSTR strClass,
+ int32_t lFlags, struct IWbemContext *pCtx, struct IEnumWbemClassObject **ppEnum);
+ }
+} IWbemServices;
+
+typedef struct IEnumWbemClassObject {
+ %extend {
+ WERROR Reset(TALLOC_CTX *mem_ctx);
+ }
+} IEnumWbemClassObject;
+
+%typemap(in, numinputs=1) (uint32_t uCount, struct WbemClassObject **apObjects, uint32_t *puReturned) (uint32_t uReturned) {
+ if (PyLong_Check($input))
+ $1 = PyLong_AsUnsignedLong($input);
+ else if (PyInt_Check($input))
+ $1 = PyInt_AsLong($input);
+ else {
+ PyErr_SetString(PyExc_TypeError,"Expected a long or an int");
+ return NULL;
+ }
+ $2 = talloc_array(NULL, struct WbemClassObject *, $1);
+ $3 = &uReturned;
+}
+
+%typemap(argout) (struct WbemClassObject **apObjects, uint32_t *puReturned) {
+ uint32_t i;
+ PyObject *o;
+ int32_t error;
+
+ error = 0;
+
+ $result = PyTuple_New(*$2);
+ for (i = 0; i < *$2; ++i) {
+ if (!error) {
+ o = PySWbemObject_FromWbemClassObject($1[i]);
+ if (!o)
+ --error;
+ else
+ error = PyTuple_SetItem($result, i, o);
+ }
+ talloc_free($1[i]);
+ }
+ talloc_free($1);
+ if (error) return NULL;
+}
+
+WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX *mem_ctx, int32_t lTimeout, uint32_t uCount,
+ struct WbemClassObject **apObjects, uint32_t *puReturned);
+
+%init %{
+
+ mod_win32_client = PyImport_ImportModule("win32com.client");
+ mod_pywintypes = PyImport_ImportModule("pywintypes");
+ ComError = PyObject_GetAttrString(mod_pywintypes, "com_error");
+
+ wmi_init(&com_ctx, NULL);
+ {
+ PyObject *pModule;
+
+ pModule = PyImport_ImportModule( "win32com.client" );
+ }
+%}
diff --git a/source4/lib/wmi/wmi.py b/source4/lib/wmi/wmi.py
new file mode 100644
index 0000000000..4bc59cfe41
--- /dev/null
+++ b/source4/lib/wmi/wmi.py
@@ -0,0 +1,95 @@
+# This file was automatically generated by SWIG (http://www.swig.org).
+# Version 1.3.36
+#
+# Don't modify this file, modify the SWIG interface instead.
+
+import _wmi
+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
+
+
+WBEM_ConnectServer = _wmi.WBEM_ConnectServer
+class IUnknown(object):
+ 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):
+ _wmi.IUnknown_swiginit(self,_wmi.new_IUnknown(*args, **kwargs))
+ __swig_destroy__ = _wmi.delete_IUnknown
+IUnknown.Release = new_instancemethod(_wmi.IUnknown_Release,None,IUnknown)
+IUnknown_swigregister = _wmi.IUnknown_swigregister
+IUnknown_swigregister(IUnknown)
+
+class IWbemServices(object):
+ 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):
+ _wmi.IWbemServices_swiginit(self,_wmi.new_IWbemServices(*args, **kwargs))
+ __swig_destroy__ = _wmi.delete_IWbemServices
+IWbemServices.ExecQuery = new_instancemethod(_wmi.IWbemServices_ExecQuery,None,IWbemServices)
+IWbemServices.ExecNotificationQuery = new_instancemethod(_wmi.IWbemServices_ExecNotificationQuery,None,IWbemServices)
+IWbemServices.CreateInstanceEnum = new_instancemethod(_wmi.IWbemServices_CreateInstanceEnum,None,IWbemServices)
+IWbemServices_swigregister = _wmi.IWbemServices_swigregister
+IWbemServices_swigregister(IWbemServices)
+
+class IEnumWbemClassObject(object):
+ 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):
+ _wmi.IEnumWbemClassObject_swiginit(self,_wmi.new_IEnumWbemClassObject(*args, **kwargs))
+ __swig_destroy__ = _wmi.delete_IEnumWbemClassObject
+IEnumWbemClassObject.Reset = new_instancemethod(_wmi.IEnumWbemClassObject_Reset,None,IEnumWbemClassObject)
+IEnumWbemClassObject_swigregister = _wmi.IEnumWbemClassObject_swigregister
+IEnumWbemClassObject_swigregister(IEnumWbemClassObject)
+
+IEnumWbemClassObject_SmartNext = _wmi.IEnumWbemClassObject_SmartNext
+
+
diff --git a/source4/lib/tdb/tdb_wrap.c b/source4/lib/wmi/wmi_wrap.c
index 32665d79fd..ee5a8fcb0f 100644
--- a/source4/lib/tdb/tdb_wrap.c
+++ b/source4/lib/wmi/wmi_wrap.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.35
+ * Version 1.3.36
*
* 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
@@ -52,6 +52,12 @@
# endif
#endif
+#ifndef SWIG_MSC_UNSUPPRESS_4505
+# if defined(_MSC_VER)
+# pragma warning(disable : 4505) /* unreferenced local function has been removed */
+# endif
+#endif
+
#ifndef SWIGUNUSEDPARM
# ifdef __cplusplus
# define SWIGUNUSEDPARM(p)
@@ -2472,21 +2478,50 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
+void push_object(PyObject **stack, PyObject *o)
+{
+ if ((!*stack) || (*stack == Py_None)) {
+ *stack = o;
+ } else {
+ PyObject *o2, *o3;
+ if (!PyTuple_Check(*stack)) {
+ o2 = *stack;
+ *stack = PyTuple_New(1);
+ PyTuple_SetItem(*stack,0,o2);
+ }
+ o3 = PyTuple_New(1);
+ PyTuple_SetItem(o3,0,o);
+ o2 = *stack;
+ *stack = PySequence_Concat(o2,o3);
+ Py_DECREF(o2);
+ Py_DECREF(o3);
+ }
+}
+
+
/* -------- 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 SWIGTYPE_p_BSTR swig_types[0]
+#define SWIGTYPE_p_IEnumWbemClassObject swig_types[1]
+#define SWIGTYPE_p_IUnknown swig_types[2]
+#define SWIGTYPE_p_IWbemContext swig_types[3]
+#define SWIGTYPE_p_IWbemServices swig_types[4]
+#define SWIGTYPE_p_TALLOC_CTX swig_types[5]
+#define SWIGTYPE_p_char swig_types[6]
+#define SWIGTYPE_p_com_context swig_types[7]
+#define SWIGTYPE_p_int swig_types[8]
+#define SWIGTYPE_p_long_long swig_types[9]
+#define SWIGTYPE_p_p_IEnumWbemClassObject swig_types[10]
+#define SWIGTYPE_p_p_IWbemServices swig_types[11]
+#define SWIGTYPE_p_p_WbemClassObject swig_types[12]
+#define SWIGTYPE_p_short swig_types[13]
+#define SWIGTYPE_p_signed_char swig_types[14]
+#define SWIGTYPE_p_unsigned_char swig_types[15]
+#define SWIGTYPE_p_unsigned_int swig_types[16]
+#define SWIGTYPE_p_unsigned_long_long swig_types[17]
+#define SWIGTYPE_p_unsigned_short swig_types[18]
+static swig_type_info *swig_types[20];
+static swig_module_info swig_module = {swig_types, 19, 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)
@@ -2512,13 +2547,13 @@ static swig_module_info swig_module = {swig_types, 11, 0, 0, 0, 0};
#define SWIG_TypeQuery SWIG_Python_TypeQuery
/*-----------------------------------------------
- @(target):= _tdb.so
+ @(target):= _wmi.so
------------------------------------------------*/
-#define SWIG_init init_tdb
+#define SWIG_init init_wmi
-#define SWIG_name "_tdb"
+#define SWIG_name "_wmi"
-#define SWIGVERSION 0x010335
+#define SWIGVERSION 0x010336
#define SWIG_VERSION SWIGVERSION
@@ -2526,31 +2561,34 @@ static swig_module_info swig_module = {swig_types, 11, 0, 0, 0, 0};
#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
+#include "libcli/util/pyerrors.h"
-/* 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>
+#include "includes.h"
+#include "librpc/gen_ndr/misc.h"
+#include "librpc/rpc/dcerpc.h"
+#include "lib/com/dcom/dcom.h"
+#include "librpc/gen_ndr/com_dcom.h"
+#include "lib/wmi/wmi.h"
-typedef TDB_CONTEXT tdb;
+WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const char *nspace, const char *user, const char *password,
+ const char *locale, uint32_t flags, const char *authority, struct IWbemContext* wbem_ctx, struct IWbemServices** services);
+WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX *mem_ctx, int32_t lTimeout,uint32_t uCount,
+ struct WbemClassObject **apObjects, uint32_t *puReturned);
- #define SWIG_From_long PyInt_FromLong
+static PyObject *PyObject_FromCVAR(uint32_t cimtype, union CIMVAR *cvar);
+static PyObject *PySWbemObject_FromWbemClassObject(struct WbemClassObject *wco);
+static struct com_context *com_ctx;
+static PyObject *ComError;
+static PyObject *mod_win32_client;
+static PyObject *mod_pywintypes;
-SWIGINTERNINLINE PyObject *
-SWIG_From_int (int value)
-{
- return SWIG_From_long (value);
-}
+typedef struct IUnknown IUnknown;
+typedef struct IWbemServices IWbemServices;
+typedef struct IWbemClassObject IWbemClassObject;
+typedef struct IEnumWbemClassObject IEnumWbemClassObject;
SWIGINTERN swig_type_info*
@@ -2712,6 +2750,84 @@ SWIG_CanCastAsInteger(double *d, double min, double max) {
SWIGINTERN int
+SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val)
+{
+ if (PyInt_Check(obj)) {
+ long v = PyInt_AsLong(obj);
+ if (v >= 0) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ return SWIG_OverflowError;
+ }
+ } else if (PyLong_Check(obj)) {
+ unsigned long v = PyLong_AsUnsignedLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ PyErr_Clear();
+ }
+ }
+#ifdef SWIG_PYTHON_CAST_MODE
+ {
+ int dispatch = 0;
+ unsigned long v = PyLong_AsUnsignedLong(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, 0, ULONG_MAX)) {
+ if (val) *val = (unsigned long)(d);
+ return res;
+ }
+ }
+ }
+#endif
+ return SWIG_TypeError;
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val)
+{
+ unsigned long v;
+ int res = SWIG_AsVal_unsigned_SS_long (obj, &v);
+ if (SWIG_IsOK(res)) {
+ if ((v > UINT_MAX)) {
+ return SWIG_OverflowError;
+ } else {
+ if (val) *val = (unsigned int)(v);
+ }
+ }
+ return res;
+}
+
+
+ #define SWIG_From_long PyInt_FromLong
+
+
+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_unsigned_SS_int (unsigned int value)
+{
+ return SWIG_From_unsigned_SS_long (value);
+}
+
+
+SWIGINTERN int
SWIG_AsVal_long (PyObject *obj, long* val)
{
if (PyInt_Check(obj)) {
@@ -2765,472 +2881,508 @@ SWIG_AsVal_int (PyObject * obj, int *val)
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); }
+#ifdef __cplusplus
+extern "C" {
+#endif
-SWIGINTERNINLINE PyObject *
-SWIG_FromCharPtrAndSize(const char* carray, size_t size)
+
+#define RETURN_CVAR_ARRAY(fmt, arr) {\
+ PyObject *l, *o;\
+ uint32_t i;\
+\
+ if (!arr) {\
+ Py_INCREF(Py_None);\
+ return Py_None;\
+ }\
+ l = PyList_New(arr->count);\
+ if (!l) return NULL;\
+ for (i = 0; i < arr->count; ++i) {\
+ o = _Py_BuildValue(fmt, arr->item[i]);\
+ if (!o) {\
+ Py_DECREF(l);\
+ return NULL;\
+ }\
+ PyList_SET_ITEM(l, i, o);\
+ }\
+ return l;\
+}
+
+static PyObject *_Py_BuildValue(char *str, ...)
{
- 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();
- }
+ PyObject * result = NULL;
+ va_list lst;
+ va_start(lst, str);
+ if (str && *str == 'I') {
+ uint32_t value = va_arg(lst, uint32_t);
+ if (value & 0x80000000) {
+ result = Py_BuildValue("L", (long)value);
+ } else {
+ result = Py_BuildValue("i", value);
+ }
+ } else {
+ result = Py_VaBuildValue(str, lst);
+ }
+ va_end(lst);
+ return result;
}
-SWIGINTERNINLINE PyObject *
-SWIG_FromCharPtr(const char *cptr)
-{
- return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0));
+static PyObject *PyObject_FromCVAR(uint32_t cimtype, union CIMVAR *cvar)
+{
+ switch (cimtype) {
+ case CIM_SINT8: return Py_BuildValue("b", cvar->v_sint8);
+ case CIM_UINT8: return Py_BuildValue("B", cvar->v_uint8);
+ case CIM_SINT16: return Py_BuildValue("h", cvar->v_sint16);
+ case CIM_UINT16: return Py_BuildValue("H", cvar->v_uint16);
+ case CIM_SINT32: return Py_BuildValue("i", cvar->v_sint32);
+ case CIM_UINT32: return _Py_BuildValue("I", cvar->v_uint32);
+ case CIM_SINT64: return Py_BuildValue("L", cvar->v_sint64);
+ case CIM_UINT64: return Py_BuildValue("K", cvar->v_uint64);
+ case CIM_REAL32: return Py_BuildValue("f", cvar->v_real32);
+ case CIM_REAL64: return Py_BuildValue("d", cvar->v_real64);
+ case CIM_BOOLEAN: return Py_BuildValue("h", cvar->v_boolean);
+ case CIM_STRING: return Py_BuildValue("s", cvar->v_string);
+ case CIM_DATETIME: return Py_BuildValue("s", cvar->v_datetime);
+ case CIM_REFERENCE: return Py_BuildValue("s", cvar->v_reference);
+ case CIM_OBJECT: return PySWbemObject_FromWbemClassObject(cvar->v_object);
+ case CIM_ARR_SINT8: RETURN_CVAR_ARRAY("b", cvar->a_sint8);
+ case CIM_ARR_UINT8: RETURN_CVAR_ARRAY("B", cvar->a_uint8);
+ case CIM_ARR_SINT16: RETURN_CVAR_ARRAY("h", cvar->a_sint16);
+ case CIM_ARR_UINT16: RETURN_CVAR_ARRAY("H", cvar->a_uint16);
+ case CIM_ARR_SINT32: RETURN_CVAR_ARRAY("i", cvar->a_sint32);
+ case CIM_ARR_UINT32: RETURN_CVAR_ARRAY("I", cvar->a_uint32);
+ case CIM_ARR_SINT64: RETURN_CVAR_ARRAY("L", cvar->a_sint64);
+ case CIM_ARR_UINT64: RETURN_CVAR_ARRAY("K", cvar->a_uint64);
+ case CIM_ARR_REAL32: RETURN_CVAR_ARRAY("f", cvar->a_real32);
+ case CIM_ARR_REAL64: RETURN_CVAR_ARRAY("d", cvar->a_real64);
+ case CIM_ARR_BOOLEAN: RETURN_CVAR_ARRAY("h", cvar->a_boolean);
+ case CIM_ARR_STRING: RETURN_CVAR_ARRAY("s", cvar->a_string);
+ case CIM_ARR_DATETIME: RETURN_CVAR_ARRAY("s", cvar->a_datetime);
+ case CIM_ARR_REFERENCE: RETURN_CVAR_ARRAY("s", cvar->a_reference);
+ default:
+ {
+ char *str;
+ str = talloc_asprintf(NULL, "Unsupported CIMTYPE(0x%04X)", cimtype);
+ PyErr_SetString(PyExc_RuntimeError, str);
+ talloc_free(str);
+ return NULL;
+ }
+ }
}
+#undef RETURN_CVAR_ARRAY
-SWIGINTERNINLINE PyObject*
-SWIG_From_unsigned_SS_long (unsigned long value)
+PyObject *PySWbemObject_InitProperites(PyObject *o, struct WbemClassObject *wco)
{
- return (value > LONG_MAX) ?
- PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)(value));
+ PyObject *properties;
+ PyObject *addProp;
+ uint32_t i;
+ int32_t r;
+ PyObject *result;
+
+ result = NULL;
+ properties = PyObject_GetAttrString(o, "Properties_");
+ if (!properties) return NULL;
+ addProp = PyObject_GetAttrString(properties, "Add");
+ if (!addProp) {
+ Py_DECREF(properties);
+ return NULL;
+ }
+
+ for (i = 0; i < wco->obj_class->__PROPERTY_COUNT; ++i) {
+ PyObject *args, *property;
+
+ args = Py_BuildValue("(si)", wco->obj_class->properties[i].property.name, wco->obj_class->properties[i].property.desc->cimtype & CIM_TYPEMASK);
+ if (!args) goto finish;
+ property = PyObject_CallObject(addProp, args);
+ Py_DECREF(args);
+ if (!property) goto finish;
+ if (wco->flags & WCF_INSTANCE) {
+ PyObject *value;
+
+ if (wco->instance->default_flags[i] & 1) {
+ value = Py_None;
+ Py_INCREF(Py_None);
+ } else
+ value = PyObject_FromCVAR(wco->obj_class->properties[i].property.desc->cimtype & CIM_TYPEMASK, &wco->instance->data[i]);
+ if (!value) {
+ Py_DECREF(property);
+ goto finish;
+ }
+ r = PyObject_SetAttrString(property, "Value", value);
+ Py_DECREF(value);
+ if (r == -1) {
+ PyErr_SetString(PyExc_RuntimeError, "Error setting value of property");
+ goto finish;
+ }
+ }
+ Py_DECREF(property);
+ }
+
+ Py_INCREF(Py_None);
+ result = Py_None;
+finish:
+ Py_DECREF(addProp);
+ Py_DECREF(properties);
+ return result;
}
+static PyObject *PySWbemObject_FromWbemClassObject(struct WbemClassObject *wco)
+{
+ PyObject *swo_class, *swo, *args, *result;
+
+ swo_class = PyObject_GetAttrString(mod_win32_client, "SWbemObject");
+ if (!swo_class) return NULL;
+ args = PyTuple_New(0);
+ if (!args) {
+ Py_DECREF(swo_class);
+ return NULL;
+ }
+ swo = PyObject_CallObject(swo_class, args);
+ Py_DECREF(args);
+ Py_DECREF(swo_class);
+ if (!swo) return NULL;
+
+ result = PySWbemObject_InitProperites(swo, wco);
+ if (!result) {
+ Py_DECREF(swo);
+ return NULL;
+ }
+ Py_DECREF(result);
-SWIGINTERNINLINE PyObject *
-SWIG_From_size_t (size_t value)
-{
- return SWIG_From_unsigned_SS_long ((unsigned long)(value));
+ return swo;
}
-#ifdef __cplusplus
-extern "C" {
-#endif
-SWIGINTERN PyObject *_wrap_new_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+
+SWIGINTERN PyObject *_wrap_WBEM_ConnectServer(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 ;
+ struct com_context *arg1 = (struct com_context *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) 0 ;
+ char *arg4 = (char *) 0 ;
+ char *arg5 = (char *) 0 ;
+ char *arg6 = (char *) 0 ;
+ uint32_t arg7 ;
+ char *arg8 = (char *) 0 ;
+ struct IWbemContext *arg9 = (struct IWbemContext *) 0 ;
+ struct IWbemServices **arg10 = (struct IWbemServices **) 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+ int res4 ;
+ char *buf4 = 0 ;
+ int alloc4 = 0 ;
+ int res5 ;
+ char *buf5 = 0 ;
+ int alloc5 = 0 ;
+ int res6 ;
+ char *buf6 = 0 ;
+ int alloc6 = 0 ;
+ unsigned int val7 ;
+ int ecode7 = 0 ;
+ int res8 ;
+ char *buf8 = 0 ;
+ int alloc8 = 0 ;
+ void *argp9 = 0 ;
+ int res9 = 0 ;
+ struct IWbemServices *temp10 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
PyObject * obj3 = 0 ;
PyObject * obj4 = 0 ;
+ PyObject * obj5 = 0 ;
+ PyObject * obj6 = 0 ;
+ PyObject * obj7 = 0 ;
char * kwnames[] = {
- (char *) "name",(char *) "hash_size",(char *) "tdb_flags",(char *) "flags",(char *) "mode", NULL
+ (char *) "server",(char *) "nspace",(char *) "user",(char *) "password",(char *) "locale",(char *) "flags",(char *) "authority",(char *) "wbem_ctx", NULL
};
+ WERROR result;
- 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 = com_ctx;
}
- 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);
+ {
+ arg10 = &temp10;
}
- 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 (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOOOOO:WBEM_ConnectServer",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail;
+ res2 = SWIG_AsCharPtrAndSize(obj0, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "WBEM_ConnectServer" "', argument " "2"" of type '" "char const *""'");
}
- 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);
+ arg2 = (char *)(buf2);
+ res3 = SWIG_AsCharPtrAndSize(obj1, &buf3, NULL, &alloc3);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "WBEM_ConnectServer" "', argument " "3"" of type '" "char const *""'");
}
- 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);
+ arg3 = (char *)(buf3);
+ res4 = SWIG_AsCharPtrAndSize(obj2, &buf4, NULL, &alloc4);
+ if (!SWIG_IsOK(res4)) {
+ SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "WBEM_ConnectServer" "', argument " "4"" of type '" "char const *""'");
}
- 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);
+ arg4 = (char *)(buf4);
+ res5 = SWIG_AsCharPtrAndSize(obj3, &buf5, NULL, &alloc5);
+ if (!SWIG_IsOK(res5)) {
+ SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "WBEM_ConnectServer" "', argument " "5"" of type '" "char const *""'");
+ }
+ arg5 = (char *)(buf5);
+ res6 = SWIG_AsCharPtrAndSize(obj4, &buf6, NULL, &alloc6);
+ if (!SWIG_IsOK(res6)) {
+ SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "WBEM_ConnectServer" "', argument " "6"" of type '" "char const *""'");
+ }
+ arg6 = (char *)(buf6);
+ ecode7 = SWIG_AsVal_unsigned_SS_int(obj5, &val7);
+ if (!SWIG_IsOK(ecode7)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "WBEM_ConnectServer" "', argument " "7"" of type '" "uint32_t""'");
+ }
+ arg7 = (uint32_t)(val7);
+ res8 = SWIG_AsCharPtrAndSize(obj6, &buf8, NULL, &alloc8);
+ if (!SWIG_IsOK(res8)) {
+ SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "WBEM_ConnectServer" "', argument " "8"" of type '" "char const *""'");
+ }
+ arg8 = (char *)(buf8);
+ res9 = SWIG_ConvertPtr(obj7, &argp9,SWIGTYPE_p_IWbemContext, 0 | 0 );
+ if (!SWIG_IsOK(res9)) {
+ SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "WBEM_ConnectServer" "', argument " "9"" of type '" "struct IWbemContext *""'");
+ }
+ arg9 = (struct IWbemContext *)(argp9);
+ result = WBEM_ConnectServer(arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5,(char const *)arg6,arg7,(char const *)arg8,arg9,arg10);
+ if (!W_ERROR_IS_OK(result)) {
+ PyErr_SetWERROR(result);
SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
+ }
+ {
+ PyObject *o;
+ o = SWIG_NewPointerObj(*arg10, SWIGTYPE_p_IWbemServices, 0);
+ push_object(&resultobj, o);
}
- resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_tdb_context, 0);
- if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ if (alloc4 == SWIG_NEWOBJ) free((char*)buf4);
+ if (alloc5 == SWIG_NEWOBJ) free((char*)buf5);
+ if (alloc6 == SWIG_NEWOBJ) free((char*)buf6);
+ if (alloc8 == SWIG_NEWOBJ) free((char*)buf8);
return resultobj;
fail:
- if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ if (alloc4 == SWIG_NEWOBJ) free((char*)buf4);
+ if (alloc5 == SWIG_NEWOBJ) free((char*)buf5);
+ if (alloc6 == SWIG_NEWOBJ) free((char*)buf6);
+ if (alloc8 == SWIG_NEWOBJ) free((char*)buf8);
return NULL;
}
-SWIGINTERN PyObject *_wrap_Tdb_error(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IUnknown_Release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- enum TDB_ERROR result;
+ IUnknown *arg1 = (IUnknown *) 0 ;
+ TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject *swig_obj[1] ;
+ uint32_t result;
+ arg2 = NULL;
if (!args) SWIG_fail;
swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IUnknown, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_error" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IUnknown_Release" "', argument " "1"" of type '" "IUnknown *""'");
}
- arg1 = (tdb *)(argp1);
- result = (enum TDB_ERROR)tdb_error(arg1);
- resultobj = SWIG_From_int((int)(result));
+ arg1 = (IUnknown *)(argp1);
+ result = (uint32_t)IUnknown_Release(arg1,arg2);
+ resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result));
return resultobj;
fail:
return NULL;
}
-SWIGINTERN PyObject *_wrap_delete_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_IUnknown(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
+ IUnknown *result = 0 ;
- 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();
+ if (!SWIG_Python_UnpackTuple(args,"new_IUnknown",0,0,0)) SWIG_fail;
+ result = (IUnknown *)calloc(1, sizeof(IUnknown));
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IUnknown, SWIG_POINTER_NEW | 0 );
return resultobj;
fail:
return NULL;
}
-SWIGINTERN PyObject *_wrap_Tdb_close(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_delete_IUnknown(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
+ IUnknown *arg1 = (IUnknown *) 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 );
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IUnknown, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_close" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IUnknown" "', argument " "1"" of type '" "IUnknown *""'");
}
- arg1 = (tdb *)(argp1);
- result = (int)tdb_close(arg1);
- resultobj = SWIG_From_int((int)(result));
+ arg1 = (IUnknown *)(argp1);
+ free((char *) arg1);
+ resultobj = SWIG_Py_Void();
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 *IUnknown_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *obj;
+ if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
+ SWIG_TypeNewClientData(SWIGTYPE_p_IUnknown, SWIG_NewClientData(obj));
+ return SWIG_Py_Void();
}
-
-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 *IUnknown_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ return SWIG_Python_InitShadowInstance(args);
}
-
-SWIGINTERN PyObject *_wrap_Tdb_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_IWbemServices_ExecQuery(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- TDB_DATA arg2 ;
- TDB_DATA result;
+ IWbemServices *arg1 = (IWbemServices *) 0 ;
+ TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
+ struct BSTR arg3 ;
+ struct BSTR arg4 ;
+ int32_t arg5 ;
+ struct IWbemContext *arg6 = (struct IWbemContext *) 0 ;
+ struct IEnumWbemClassObject **arg7 = (struct IEnumWbemClassObject **) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
+ int val5 ;
+ int ecode5 = 0 ;
+ void *argp6 = 0 ;
+ int res6 = 0 ;
+ struct IEnumWbemClassObject *temp7 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "key", NULL
+ (char *) "self",(char *) "strQueryLanguage",(char *) "strQuery",(char *) "lFlags",(char *) "pCtx", NULL
};
+ WERROR result;
- 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 );
+ arg2 = NULL;
+ {
+ arg7 = &temp7;
+ }
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:IWbemServices_ExecQuery",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_IWbemServices, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_get" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IWbemServices_ExecQuery" "', argument " "1"" of type '" "IWbemServices *""'");
}
- 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);
+ arg1 = (IWbemServices *)(argp1);
+ {
+ (&arg3)->data = 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);
+ {
+ (&arg4)->data = PyString_AsString(obj2);
}
- 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 *""'");
+ ecode5 = SWIG_AsVal_int(obj3, &val5);
+ if (!SWIG_IsOK(ecode5)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "IWbemServices_ExecQuery" "', argument " "5"" of type '" "int32_t""'");
+ }
+ arg5 = (int32_t)(val5);
+ res6 = SWIG_ConvertPtr(obj4, &argp6,SWIGTYPE_p_IWbemContext, 0 | 0 );
+ if (!SWIG_IsOK(res6)) {
+ SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "IWbemServices_ExecQuery" "', argument " "6"" of type '" "struct IWbemContext *""'");
}
- 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);
+ arg6 = (struct IWbemContext *)(argp6);
+ result = IWbemServices_ExecQuery(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
+ if (!W_ERROR_IS_OK(result)) {
+ PyErr_SetWERROR(result);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
+ }
+ {
+ PyObject *o;
+ o = SWIG_NewPointerObj(*arg7, SWIGTYPE_p_IEnumWbemClassObject, 0);
+ push_object(&resultobj, o);
}
- 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) {
+SWIGINTERN PyObject *_wrap_IWbemServices_ExecNotificationQuery(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- TDB_DATA arg2 ;
- TDB_DATA arg3 ;
- int arg4 ;
- int result;
+ IWbemServices *arg1 = (IWbemServices *) 0 ;
+ TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
+ struct BSTR arg3 ;
+ struct BSTR arg4 ;
+ int32_t arg5 ;
+ struct IWbemContext *arg6 = (struct IWbemContext *) 0 ;
+ struct IEnumWbemClassObject **arg7 = (struct IEnumWbemClassObject **) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
- int val4 ;
- int ecode4 = 0 ;
+ int val5 ;
+ int ecode5 = 0 ;
+ void *argp6 = 0 ;
+ int res6 = 0 ;
+ struct IEnumWbemClassObject *temp7 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "key",(char *) "dbuf",(char *) "flag", NULL
+ (char *) "self",(char *) "strQueryLanguage",(char *) "strQuery",(char *) "lFlags",(char *) "pCtx", NULL
};
+ WERROR result;
- 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);
+ arg2 = NULL;
+ {
+ arg7 = &temp7;
}
- 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 (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:IWbemServices_ExecNotificationQuery",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_IWbemServices, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_exists" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IWbemServices_ExecNotificationQuery" "', argument " "1"" of type '" "IWbemServices *""'");
}
- 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);
+ arg1 = (IWbemServices *)(argp1);
+ {
+ (&arg3)->data = 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 *""'");
+ {
+ (&arg4)->data = PyString_AsString(obj2);
}
- arg1 = (tdb *)(argp1);
- result = tdb_firstkey(arg1);
- if ((&result)->dptr == NULL && (&result)->dsize == 0) {
+ ecode5 = SWIG_AsVal_int(obj3, &val5);
+ if (!SWIG_IsOK(ecode5)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "IWbemServices_ExecNotificationQuery" "', argument " "5"" of type '" "int32_t""'");
+ }
+ arg5 = (int32_t)(val5);
+ res6 = SWIG_ConvertPtr(obj4, &argp6,SWIGTYPE_p_IWbemContext, 0 | 0 );
+ if (!SWIG_IsOK(res6)) {
+ SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "IWbemServices_ExecNotificationQuery" "', argument " "6"" of type '" "struct IWbemContext *""'");
+ }
+ arg6 = (struct IWbemContext *)(argp6);
+ result = IWbemServices_ExecNotificationQuery(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
+ if (!W_ERROR_IS_OK(result)) {
+ PyErr_SetWERROR(result);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
resultobj = Py_None;
- } else {
- resultobj = PyString_FromStringAndSize((const char *)(&result)->dptr, (&result)->dsize);
- free((&result)->dptr);
+ }
+ {
+ PyObject *o;
+ o = SWIG_NewPointerObj(*arg7, SWIGTYPE_p_IEnumWbemClassObject, 0);
+ push_object(&resultobj, o);
}
return resultobj;
fail:
@@ -3238,517 +3390,376 @@ fail:
}
-SWIGINTERN PyObject *_wrap_Tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_IWbemServices_CreateInstanceEnum(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- TDB_DATA arg2 ;
- TDB_DATA result;
+ IWbemServices *arg1 = (IWbemServices *) 0 ;
+ TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
+ struct BSTR arg3 ;
+ int32_t arg4 ;
+ struct IWbemContext *arg5 = (struct IWbemContext *) 0 ;
+ struct IEnumWbemClassObject **arg6 = (struct IEnumWbemClassObject **) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
+ int val4 ;
+ int ecode4 = 0 ;
+ void *argp5 = 0 ;
+ int res5 = 0 ;
+ struct IEnumWbemClassObject *temp6 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "key", NULL
+ (char *) "self",(char *) "strClass",(char *) "lFlags",(char *) "pCtx", NULL
};
+ WERROR result;
- 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 );
+ arg2 = NULL;
+ {
+ arg6 = &temp6;
+ }
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:IWbemServices_CreateInstanceEnum",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_IWbemServices, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_nextkey" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IWbemServices_CreateInstanceEnum" "', argument " "1"" of type '" "IWbemServices *""'");
}
- 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);
+ arg1 = (IWbemServices *)(argp1);
+ {
+ (&arg3)->data = 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);
+ ecode4 = SWIG_AsVal_int(obj2, &val4);
+ if (!SWIG_IsOK(ecode4)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "IWbemServices_CreateInstanceEnum" "', argument " "4"" of type '" "int32_t""'");
+ }
+ arg4 = (int32_t)(val4);
+ res5 = SWIG_ConvertPtr(obj3, &argp5,SWIGTYPE_p_IWbemContext, 0 | 0 );
+ if (!SWIG_IsOK(res5)) {
+ SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "IWbemServices_CreateInstanceEnum" "', argument " "5"" of type '" "struct IWbemContext *""'");
}
- 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 *""'");
+ arg5 = (struct IWbemContext *)(argp5);
+ result = IWbemServices_CreateInstanceEnum(arg1,arg2,arg3,arg4,arg5,arg6);
+ if (!W_ERROR_IS_OK(result)) {
+ PyErr_SetWERROR(result);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
}
- 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 *""'");
+ {
+ PyObject *o;
+ o = SWIG_NewPointerObj(*arg6, SWIGTYPE_p_IEnumWbemClassObject, 0);
+ push_object(&resultobj, o);
}
- 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) {
+SWIGINTERN PyObject *_wrap_new_IWbemServices(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
+ IWbemServices *result = 0 ;
- 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));
+ if (!SWIG_Python_UnpackTuple(args,"new_IWbemServices",0,0,0)) SWIG_fail;
+ result = (IWbemServices *)calloc(1, sizeof(IWbemServices));
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IWbemServices, SWIG_POINTER_NEW | 0 );
return resultobj;
fail:
return NULL;
}
-SWIGINTERN PyObject *_wrap_Tdb_read_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_delete_IWbemServices(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
+ IWbemServices *arg1 = (IWbemServices *) 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 );
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IWbemServices, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_read_unlock_all" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IWbemServices" "', argument " "1"" of type '" "IWbemServices *""'");
}
- arg1 = (tdb *)(argp1);
- result = (int)tdb_unlockall_read(arg1);
- resultobj = SWIG_From_int((int)(result));
+ arg1 = (IWbemServices *)(argp1);
+ free((char *) arg1);
+ resultobj = SWIG_Py_Void();
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 *IWbemServices_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *obj;
+ if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
+ SWIG_TypeNewClientData(SWIGTYPE_p_IWbemServices, SWIG_NewClientData(obj));
+ return SWIG_Py_Void();
}
-
-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 *IWbemServices_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ return SWIG_Python_InitShadowInstance(args);
}
-
-SWIGINTERN PyObject *_wrap_Tdb_transaction_commit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IEnumWbemClassObject_Reset(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
+ IEnumWbemClassObject *arg1 = (IEnumWbemClassObject *) 0 ;
+ TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject *swig_obj[1] ;
+ WERROR result;
+ arg2 = NULL;
if (!args) SWIG_fail;
swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IEnumWbemClassObject, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_commit" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IEnumWbemClassObject_Reset" "', argument " "1"" of type '" "IEnumWbemClassObject *""'");
}
- 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 = (IEnumWbemClassObject *)(argp1);
+ result = IEnumWbemClassObject_Reset(arg1,arg2);
+ if (!W_ERROR_IS_OK(result)) {
+ PyErr_SetWERROR(result);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
}
- 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) {
+SWIGINTERN PyObject *_wrap_new_IEnumWbemClassObject(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
+ IEnumWbemClassObject *result = 0 ;
- 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));
+ if (!SWIG_Python_UnpackTuple(args,"new_IEnumWbemClassObject",0,0,0)) SWIG_fail;
+ result = (IEnumWbemClassObject *)calloc(1, sizeof(IEnumWbemClassObject));
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IEnumWbemClassObject, SWIG_POINTER_NEW | 0 );
return resultobj;
fail:
return NULL;
}
-SWIGINTERN PyObject *_wrap_Tdb_hash_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_delete_IEnumWbemClassObject(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
+ IEnumWbemClassObject *arg1 = (IEnumWbemClassObject *) 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 );
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IEnumWbemClassObject, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_hash_size" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IEnumWbemClassObject" "', argument " "1"" of type '" "IEnumWbemClassObject *""'");
}
- arg1 = (tdb *)(argp1);
- result = (int)tdb_hash_size(arg1);
- resultobj = SWIG_From_int((int)(result));
+ arg1 = (IEnumWbemClassObject *)(argp1);
+ free((char *) arg1);
+ resultobj = SWIG_Py_Void();
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 *IEnumWbemClassObject_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *obj;
+ if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
+ SWIG_TypeNewClientData(SWIGTYPE_p_IEnumWbemClassObject, SWIG_NewClientData(obj));
+ return SWIG_Py_Void();
}
-
-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 *IEnumWbemClassObject_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ return SWIG_Python_InitShadowInstance(args);
}
-
-SWIGINTERN PyObject *_wrap_Tdb_set_max_dead(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_IEnumWbemClassObject_SmartNext(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int arg2 ;
+ struct IEnumWbemClassObject *arg1 = (struct IEnumWbemClassObject *) 0 ;
+ TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
+ int32_t arg3 ;
+ uint32_t arg4 ;
+ struct WbemClassObject **arg5 = (struct WbemClassObject **) 0 ;
+ uint32_t *arg6 = (uint32_t *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
- int val2 ;
- int ecode2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ uint32_t uReturned4 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "max_dead", NULL
+ (char *) "d",(char *) "lTimeout",(char *) "uCount", NULL
};
+ WERROR result;
- 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 );
+ arg2 = NULL;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:IEnumWbemClassObject_SmartNext",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_IEnumWbemClassObject, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_set_max_dead" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IEnumWbemClassObject_SmartNext" "', argument " "1"" of type '" "struct IEnumWbemClassObject *""'");
}
- 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""'");
+ arg1 = (struct IEnumWbemClassObject *)(argp1);
+ ecode3 = SWIG_AsVal_int(obj1, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IEnumWbemClassObject_SmartNext" "', argument " "3"" of type '" "int32_t""'");
}
- 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 *""'");
+ arg3 = (int32_t)(val3);
+ {
+ if (PyLong_Check(obj2))
+ arg4 = PyLong_AsUnsignedLong(obj2);
+ else if (PyInt_Check(obj2))
+ arg4 = PyInt_AsLong(obj2);
+ else {
+ PyErr_SetString(PyExc_TypeError,"Expected a long or an int");
+ return NULL;
+ }
+ arg5 = talloc_array(NULL, struct WbemClassObject *, arg4);
+ arg6 = &uReturned4;
+ }
+ result = IEnumWbemClassObject_SmartNext(arg1,arg2,arg3,arg4,arg5,arg6);
+ if (!W_ERROR_IS_OK(result)) {
+ PyErr_SetWERROR(result);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
+ }
+ {
+ uint32_t i;
+ PyObject *o;
+ int32_t error;
+
+ error = 0;
+
+ resultobj = PyTuple_New(*arg6);
+ for (i = 0; i < *arg6; ++i) {
+ if (!error) {
+ o = PySWbemObject_FromWbemClassObject(arg5[i]);
+ if (!o)
+ --error;
+ else
+ error = PyTuple_SetItem(resultobj, i, o);
+ }
+ talloc_free(arg5[i]);
+ }
+ talloc_free(arg5);
+ if (error) return NULL;
}
- 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},
+ { (char *)"WBEM_ConnectServer", (PyCFunction) _wrap_WBEM_ConnectServer, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"IUnknown_Release", (PyCFunction)_wrap_IUnknown_Release, METH_O, NULL},
+ { (char *)"new_IUnknown", (PyCFunction)_wrap_new_IUnknown, METH_NOARGS, NULL},
+ { (char *)"delete_IUnknown", (PyCFunction)_wrap_delete_IUnknown, METH_O, NULL},
+ { (char *)"IUnknown_swigregister", IUnknown_swigregister, METH_VARARGS, NULL},
+ { (char *)"IUnknown_swiginit", IUnknown_swiginit, METH_VARARGS, NULL},
+ { (char *)"IWbemServices_ExecQuery", (PyCFunction) _wrap_IWbemServices_ExecQuery, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"IWbemServices_ExecNotificationQuery", (PyCFunction) _wrap_IWbemServices_ExecNotificationQuery, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"IWbemServices_CreateInstanceEnum", (PyCFunction) _wrap_IWbemServices_CreateInstanceEnum, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"new_IWbemServices", (PyCFunction)_wrap_new_IWbemServices, METH_NOARGS, NULL},
+ { (char *)"delete_IWbemServices", (PyCFunction)_wrap_delete_IWbemServices, METH_O, NULL},
+ { (char *)"IWbemServices_swigregister", IWbemServices_swigregister, METH_VARARGS, NULL},
+ { (char *)"IWbemServices_swiginit", IWbemServices_swiginit, METH_VARARGS, NULL},
+ { (char *)"IEnumWbemClassObject_Reset", (PyCFunction)_wrap_IEnumWbemClassObject_Reset, METH_O, NULL},
+ { (char *)"new_IEnumWbemClassObject", (PyCFunction)_wrap_new_IEnumWbemClassObject, METH_NOARGS, NULL},
+ { (char *)"delete_IEnumWbemClassObject", (PyCFunction)_wrap_delete_IEnumWbemClassObject, METH_O, NULL},
+ { (char *)"IEnumWbemClassObject_swigregister", IEnumWbemClassObject_swigregister, METH_VARARGS, NULL},
+ { (char *)"IEnumWbemClassObject_swiginit", IEnumWbemClassObject_swiginit, METH_VARARGS, NULL},
+ { (char *)"IEnumWbemClassObject_SmartNext", (PyCFunction) _wrap_IEnumWbemClassObject_SmartNext, METH_VARARGS | METH_KEYWORDS, 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_BSTR = {"_p_BSTR", "struct BSTR *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_IEnumWbemClassObject = {"_p_IEnumWbemClassObject", "struct IEnumWbemClassObject *|IEnumWbemClassObject *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_IUnknown = {"_p_IUnknown", "struct IUnknown *|IUnknown *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_IWbemContext = {"_p_IWbemContext", "struct IWbemContext *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_IWbemServices = {"_p_IWbemServices", "struct IWbemServices *|IWbemServices *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_TALLOC_CTX = {"_p_TALLOC_CTX", "TALLOC_CTX *", 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_com_context = {"_p_com_context", "struct com_context *", 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 *", 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_p_IEnumWbemClassObject = {"_p_p_IEnumWbemClassObject", "struct IEnumWbemClassObject **", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_p_IWbemServices = {"_p_p_IWbemServices", "struct IWbemServices **", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_p_WbemClassObject = {"_p_p_WbemClassObject", "struct WbemClassObject **", 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_BSTR,
+ &_swigt__p_IEnumWbemClassObject,
+ &_swigt__p_IUnknown,
+ &_swigt__p_IWbemContext,
+ &_swigt__p_IWbemServices,
+ &_swigt__p_TALLOC_CTX,
&_swigt__p_char,
+ &_swigt__p_com_context,
&_swigt__p_int,
&_swigt__p_long_long,
+ &_swigt__p_p_IEnumWbemClassObject,
+ &_swigt__p_p_IWbemServices,
+ &_swigt__p_p_WbemClassObject,
&_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_BSTR[] = { {&_swigt__p_BSTR, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_IEnumWbemClassObject[] = { {&_swigt__p_IEnumWbemClassObject, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_IUnknown[] = { {&_swigt__p_IUnknown, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_IWbemContext[] = { {&_swigt__p_IWbemContext, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_IWbemServices[] = { {&_swigt__p_IWbemServices, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_TALLOC_CTX[] = { {&_swigt__p_TALLOC_CTX, 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_com_context[] = { {&_swigt__p_com_context, 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_p_IEnumWbemClassObject[] = { {&_swigt__p_p_IEnumWbemClassObject, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_p_IWbemServices[] = { {&_swigt__p_p_IWbemServices, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_p_WbemClassObject[] = { {&_swigt__p_p_WbemClassObject, 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_BSTR,
+ _swigc__p_IEnumWbemClassObject,
+ _swigc__p_IUnknown,
+ _swigc__p_IWbemContext,
+ _swigc__p_IWbemServices,
+ _swigc__p_TALLOC_CTX,
_swigc__p_char,
+ _swigc__p_com_context,
_swigc__p_int,
_swigc__p_long_long,
+ _swigc__p_p_IEnumWbemClassObject,
+ _swigc__p_p_IWbemServices,
+ _swigc__p_p_WbemClassObject,
_swigc__p_short,
_swigc__p_signed_char,
- _swigc__p_tdb_context,
_swigc__p_unsigned_char,
_swigc__p_unsigned_int,
_swigc__p_unsigned_long_long,
@@ -4282,26 +4293,18 @@ SWIGEXPORT void SWIG_init(void) {
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)));
+
+
+ mod_win32_client = PyImport_ImportModule("win32com.client");
+ mod_pywintypes = PyImport_ImportModule("pywintypes");
+ ComError = PyObject_GetAttrString(mod_pywintypes, "com_error");
+
+ wmi_init(&com_ctx, NULL);
+ {
+ PyObject *pModule;
+
+ pModule = PyImport_ImportModule( "win32com.client" );
+ }
+
}
diff --git a/source4/lib/wmi/wmicore.c b/source4/lib/wmi/wmicore.c
new file mode 100644
index 0000000000..3ac6c89292
--- /dev/null
+++ b/source4/lib/wmi/wmicore.c
@@ -0,0 +1,252 @@
+/*
+ WMI Sample client
+ Copyright (C) 2006 Andrzej Hajda <andrzej.hajda@wp.pl>
+ Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "auth/credentials/credentials.h"
+#include "librpc/gen_ndr/com_dcom.h"
+#include "lib/com/dcom/dcom.h"
+#include "librpc/gen_ndr/wmi.h"
+#include "librpc/gen_ndr/com_wmi.h"
+#include "librpc/rpc/dcerpc.h"
+#include "librpc/ndr/ndr_table.h"
+#include "param/param.h"
+
+struct IWbemServices;
+struct IWbemContext;
+
+#define WERR_CHECK(msg) if (!W_ERROR_IS_OK(result)) { \
+ DEBUG(0, ("ERROR: %s\n", msg)); \
+ goto end; \
+ } else { \
+ DEBUG(1, ("OK : %s\n", msg)); \
+ }
+
+void wmi_init(struct com_context **ctx, struct cli_credentials *credentials)
+{
+ dcerpc_init();
+ ndr_table_init();
+
+ /* FIXME: Register DCOM proxies? */
+
+ com_init_ctx(ctx, NULL);
+ dcom_client_init(*ctx, credentials);
+}
+
+/** FIXME: Use credentials struct rather than user/password here */
+WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const uint16_t *nspace,
+ struct cli_credentials *credentials,
+ const char *locale, uint32_t flags, const char *authority,
+ struct IWbemContext* wbem_ctx, struct IWbemServices** services)
+{
+ struct GUID clsid;
+ struct GUID iid;
+ WERROR result, coresult;
+ struct IUnknown **mqi;
+ struct IWbemLevel1Login *pL;
+
+ GUID_from_string(CLSID_WBEMLEVEL1LOGIN, &clsid);
+ GUID_from_string(COM_IWBEMLEVEL1LOGIN_UUID, &iid);
+ result = dcom_create_object(ctx, &clsid, server, 1, &iid, &mqi, &coresult);
+ WERR_CHECK("dcom_create_object.");
+ result = coresult;
+ WERR_CHECK("Create remote WMI object.");
+ pL = (struct IWbemLevel1Login *)mqi[0];
+ talloc_free(mqi);
+
+ result = IWbemLevel1Login_NTLMLogin(pL, ctx, nspace, locale, flags, wbem_ctx, services);
+ WERR_CHECK("Login to remote object.");
+
+ IUnknown_Release((struct IUnknown *)pL, ctx);
+end:
+ return result;
+}
+
+struct werror_code_struct {
+ const char *dos_errstr;
+ WERROR werror;
+};
+
+static const struct werror_code_struct wmi_errs[] =
+{
+ { "RPC_S_CALL_FAILED", W_ERROR(RPC_S_CALL_FAILED) },
+
+ { "WBEM_NO_ERROR", W_ERROR(WBEM_NO_ERROR) },
+ { "WBEM_S_NO_ERROR", W_ERROR(WBEM_S_NO_ERROR) },
+ { "WBEM_S_SAME", W_ERROR(WBEM_S_SAME) },
+ { "WBEM_S_FALSE", W_ERROR(WBEM_S_FALSE) },
+ { "WBEM_S_ALREADY_EXISTS", W_ERROR(WBEM_S_ALREADY_EXISTS) },
+ { "WBEM_S_RESET_TO_DEFAULT", W_ERROR(WBEM_S_RESET_TO_DEFAULT) },
+ { "WBEM_S_DIFFERENT", W_ERROR(WBEM_S_DIFFERENT) },
+ { "WBEM_S_TIMEDOUT", W_ERROR(WBEM_S_TIMEDOUT) },
+ { "WBEM_S_NO_MORE_DATA", W_ERROR(WBEM_S_NO_MORE_DATA) },
+ { "WBEM_S_OPERATION_CANCELLED", W_ERROR(WBEM_S_OPERATION_CANCELLED) },
+ { "WBEM_S_PENDING", W_ERROR(WBEM_S_PENDING) },
+ { "WBEM_S_DUPLICATE_OBJECTS", W_ERROR(WBEM_S_DUPLICATE_OBJECTS) },
+ { "WBEM_S_ACCESS_DENIED", W_ERROR(WBEM_S_ACCESS_DENIED) },
+ { "WBEM_S_PARTIAL_RESULTS", W_ERROR(WBEM_S_PARTIAL_RESULTS) },
+ { "WBEM_S_NO_POSTHOOK", W_ERROR(WBEM_S_NO_POSTHOOK) },
+ { "WBEM_S_POSTHOOK_WITH_BOTH", W_ERROR(WBEM_S_POSTHOOK_WITH_BOTH) },
+ { "WBEM_S_POSTHOOK_WITH_NEW", W_ERROR(WBEM_S_POSTHOOK_WITH_NEW) },
+ { "WBEM_S_POSTHOOK_WITH_STATUS", W_ERROR(WBEM_S_POSTHOOK_WITH_STATUS) },
+ { "WBEM_S_POSTHOOK_WITH_OLD", W_ERROR(WBEM_S_POSTHOOK_WITH_OLD) },
+ { "WBEM_S_REDO_PREHOOK_WITH_ORIGINAL_OBJECT", W_ERROR(WBEM_S_REDO_PREHOOK_WITH_ORIGINAL_OBJECT) },
+ { "WBEM_S_SOURCE_NOT_AVAILABLE", W_ERROR(WBEM_S_SOURCE_NOT_AVAILABLE) },
+ { "WBEM_E_FAILED", W_ERROR(WBEM_E_FAILED) },
+ { "WBEM_E_NOT_FOUND", W_ERROR(WBEM_E_NOT_FOUND) },
+ { "WBEM_E_ACCESS_DENIED", W_ERROR(WBEM_E_ACCESS_DENIED) },
+ { "WBEM_E_PROVIDER_FAILURE", W_ERROR(WBEM_E_PROVIDER_FAILURE) },
+ { "WBEM_E_TYPE_MISMATCH", W_ERROR(WBEM_E_TYPE_MISMATCH) },
+ { "WBEM_E_OUT_OF_MEMORY", W_ERROR(WBEM_E_OUT_OF_MEMORY) },
+ { "WBEM_E_INVALID_CONTEXT", W_ERROR(WBEM_E_INVALID_CONTEXT) },
+ { "WBEM_E_INVALID_PARAMETER", W_ERROR(WBEM_E_INVALID_PARAMETER) },
+ { "WBEM_E_NOT_AVAILABLE", W_ERROR(WBEM_E_NOT_AVAILABLE) },
+ { "WBEM_E_CRITICAL_ERROR", W_ERROR(WBEM_E_CRITICAL_ERROR) },
+ { "WBEM_E_INVALID_STREAM", W_ERROR(WBEM_E_INVALID_STREAM) },
+ { "WBEM_E_NOT_SUPPORTED", W_ERROR(WBEM_E_NOT_SUPPORTED) },
+ { "WBEM_E_INVALID_SUPERCLASS", W_ERROR(WBEM_E_INVALID_SUPERCLASS) },
+ { "WBEM_E_INVALID_NAMESPACE", W_ERROR(WBEM_E_INVALID_NAMESPACE) },
+ { "WBEM_E_INVALID_OBJECT", W_ERROR(WBEM_E_INVALID_OBJECT) },
+ { "WBEM_E_INVALID_CLASS", W_ERROR(WBEM_E_INVALID_CLASS) },
+ { "WBEM_E_PROVIDER_NOT_FOUND", W_ERROR(WBEM_E_PROVIDER_NOT_FOUND) },
+ { "WBEM_E_INVALID_PROVIDER_REGISTRATION", W_ERROR(WBEM_E_INVALID_PROVIDER_REGISTRATION) },
+ { "WBEM_E_PROVIDER_LOAD_FAILURE", W_ERROR(WBEM_E_PROVIDER_LOAD_FAILURE) },
+ { "WBEM_E_INITIALIZATION_FAILURE", W_ERROR(WBEM_E_INITIALIZATION_FAILURE) },
+ { "WBEM_E_TRANSPORT_FAILURE", W_ERROR(WBEM_E_TRANSPORT_FAILURE) },
+ { "WBEM_E_INVALID_OPERATION", W_ERROR(WBEM_E_INVALID_OPERATION) },
+ { "WBEM_E_INVALID_QUERY", W_ERROR(WBEM_E_INVALID_QUERY) },
+ { "WBEM_E_INVALID_QUERY_TYPE", W_ERROR(WBEM_E_INVALID_QUERY_TYPE) },
+ { "WBEM_E_ALREADY_EXISTS", W_ERROR(WBEM_E_ALREADY_EXISTS) },
+ { "WBEM_E_OVERRIDE_NOT_ALLOWED", W_ERROR(WBEM_E_OVERRIDE_NOT_ALLOWED) },
+ { "WBEM_E_PROPAGATED_QUALIFIER", W_ERROR(WBEM_E_PROPAGATED_QUALIFIER) },
+ { "WBEM_E_PROPAGATED_PROPERTY", W_ERROR(WBEM_E_PROPAGATED_PROPERTY) },
+ { "WBEM_E_UNEXPECTED", W_ERROR(WBEM_E_UNEXPECTED) },
+ { "WBEM_E_ILLEGAL_OPERATION", W_ERROR(WBEM_E_ILLEGAL_OPERATION) },
+ { "WBEM_E_CANNOT_BE_KEY", W_ERROR(WBEM_E_CANNOT_BE_KEY) },
+ { "WBEM_E_INCOMPLETE_CLASS", W_ERROR(WBEM_E_INCOMPLETE_CLASS) },
+ { "WBEM_E_INVALID_SYNTAX", W_ERROR(WBEM_E_INVALID_SYNTAX) },
+ { "WBEM_E_NONDECORATED_OBJECT", W_ERROR(WBEM_E_NONDECORATED_OBJECT) },
+ { "WBEM_E_READ_ONLY", W_ERROR(WBEM_E_READ_ONLY) },
+ { "WBEM_E_PROVIDER_NOT_CAPABLE", W_ERROR(WBEM_E_PROVIDER_NOT_CAPABLE) },
+ { "WBEM_E_CLASS_HAS_CHILDREN", W_ERROR(WBEM_E_CLASS_HAS_CHILDREN) },
+ { "WBEM_E_CLASS_HAS_INSTANCES", W_ERROR(WBEM_E_CLASS_HAS_INSTANCES) },
+ { "WBEM_E_QUERY_NOT_IMPLEMENTED", W_ERROR(WBEM_E_QUERY_NOT_IMPLEMENTED) },
+ { "WBEM_E_ILLEGAL_NULL", W_ERROR(WBEM_E_ILLEGAL_NULL) },
+ { "WBEM_E_INVALID_QUALIFIER_TYPE", W_ERROR(WBEM_E_INVALID_QUALIFIER_TYPE) },
+ { "WBEM_E_INVALID_PROPERTY_TYPE", W_ERROR(WBEM_E_INVALID_PROPERTY_TYPE) },
+ { "WBEM_E_VALUE_OUT_OF_RANGE", W_ERROR(WBEM_E_VALUE_OUT_OF_RANGE) },
+ { "WBEM_E_CANNOT_BE_SINGLETON", W_ERROR(WBEM_E_CANNOT_BE_SINGLETON) },
+ { "WBEM_E_INVALID_CIM_TYPE", W_ERROR(WBEM_E_INVALID_CIM_TYPE) },
+ { "WBEM_E_INVALID_METHOD", W_ERROR(WBEM_E_INVALID_METHOD) },
+ { "WBEM_E_INVALID_METHOD_PARAMETERS", W_ERROR(WBEM_E_INVALID_METHOD_PARAMETERS) },
+ { "WBEM_E_SYSTEM_PROPERTY", W_ERROR(WBEM_E_SYSTEM_PROPERTY) },
+ { "WBEM_E_INVALID_PROPERTY", W_ERROR(WBEM_E_INVALID_PROPERTY) },
+ { "WBEM_E_CALL_CANCELLED", W_ERROR(WBEM_E_CALL_CANCELLED) },
+ { "WBEM_E_SHUTTING_DOWN", W_ERROR(WBEM_E_SHUTTING_DOWN) },
+ { "WBEM_E_PROPAGATED_METHOD", W_ERROR(WBEM_E_PROPAGATED_METHOD) },
+ { "WBEM_E_UNSUPPORTED_PARAMETER", W_ERROR(WBEM_E_UNSUPPORTED_PARAMETER) },
+ { "WBEM_E_MISSING_PARAMETER_ID", W_ERROR(WBEM_E_MISSING_PARAMETER_ID) },
+ { "WBEM_E_INVALID_PARAMETER_ID", W_ERROR(WBEM_E_INVALID_PARAMETER_ID) },
+ { "WBEM_E_NONCONSECUTIVE_PARAMETER_IDS", W_ERROR(WBEM_E_NONCONSECUTIVE_PARAMETER_IDS) },
+ { "WBEM_E_PARAMETER_ID_ON_RETVAL", W_ERROR(WBEM_E_PARAMETER_ID_ON_RETVAL) },
+ { "WBEM_E_INVALID_OBJECT_PATH", W_ERROR(WBEM_E_INVALID_OBJECT_PATH) },
+ { "WBEM_E_OUT_OF_DISK_SPACE", W_ERROR(WBEM_E_OUT_OF_DISK_SPACE) },
+ { "WBEM_E_BUFFER_TOO_SMALL", W_ERROR(WBEM_E_BUFFER_TOO_SMALL) },
+ { "WBEM_E_UNSUPPORTED_PUT_EXTENSION", W_ERROR(WBEM_E_UNSUPPORTED_PUT_EXTENSION) },
+ { "WBEM_E_UNKNOWN_OBJECT_TYPE", W_ERROR(WBEM_E_UNKNOWN_OBJECT_TYPE) },
+ { "WBEM_E_UNKNOWN_PACKET_TYPE", W_ERROR(WBEM_E_UNKNOWN_PACKET_TYPE) },
+ { "WBEM_E_MARSHAL_VERSION_MISMATCH", W_ERROR(WBEM_E_MARSHAL_VERSION_MISMATCH) },
+ { "WBEM_E_MARSHAL_INVALID_SIGNATURE", W_ERROR(WBEM_E_MARSHAL_INVALID_SIGNATURE) },
+ { "WBEM_E_INVALID_QUALIFIER", W_ERROR(WBEM_E_INVALID_QUALIFIER) },
+ { "WBEM_E_INVALID_DUPLICATE_PARAMETER", W_ERROR(WBEM_E_INVALID_DUPLICATE_PARAMETER) },
+ { "WBEM_E_TOO_MUCH_DATA", W_ERROR(WBEM_E_TOO_MUCH_DATA) },
+ { "WBEM_E_SERVER_TOO_BUSY", W_ERROR(WBEM_E_SERVER_TOO_BUSY) },
+ { "WBEM_E_INVALID_FLAVOR", W_ERROR(WBEM_E_INVALID_FLAVOR) },
+ { "WBEM_E_CIRCULAR_REFERENCE", W_ERROR(WBEM_E_CIRCULAR_REFERENCE) },
+ { "WBEM_E_UNSUPPORTED_CLASS_UPDATE", W_ERROR(WBEM_E_UNSUPPORTED_CLASS_UPDATE) },
+ { "WBEM_E_CANNOT_CHANGE_KEY_INHERITANCE", W_ERROR(WBEM_E_CANNOT_CHANGE_KEY_INHERITANCE) },
+ { "WBEM_E_CANNOT_CHANGE_INDEX_INHERITANCE", W_ERROR(WBEM_E_CANNOT_CHANGE_INDEX_INHERITANCE) },
+ { "WBEM_E_TOO_MANY_PROPERTIES", W_ERROR(WBEM_E_TOO_MANY_PROPERTIES) },
+ { "WBEM_E_UPDATE_TYPE_MISMATCH", W_ERROR(WBEM_E_UPDATE_TYPE_MISMATCH) },
+ { "WBEM_E_UPDATE_OVERRIDE_NOT_ALLOWED", W_ERROR(WBEM_E_UPDATE_OVERRIDE_NOT_ALLOWED) },
+ { "WBEM_E_UPDATE_PROPAGATED_METHOD", W_ERROR(WBEM_E_UPDATE_PROPAGATED_METHOD) },
+ { "WBEM_E_METHOD_NOT_IMPLEMENTED", W_ERROR(WBEM_E_METHOD_NOT_IMPLEMENTED) },
+ { "WBEM_E_METHOD_DISABLED", W_ERROR(WBEM_E_METHOD_DISABLED) },
+ { "WBEM_E_REFRESHER_BUSY", W_ERROR(WBEM_E_REFRESHER_BUSY) },
+ { "WBEM_E_UNPARSABLE_QUERY", W_ERROR(WBEM_E_UNPARSABLE_QUERY) },
+ { "WBEM_E_NOT_EVENT_CLASS", W_ERROR(WBEM_E_NOT_EVENT_CLASS) },
+ { "WBEM_E_MISSING_GROUP_WITHIN", W_ERROR(WBEM_E_MISSING_GROUP_WITHIN) },
+ { "WBEM_E_MISSING_AGGREGATION_LIST", W_ERROR(WBEM_E_MISSING_AGGREGATION_LIST) },
+ { "WBEM_E_PROPERTY_NOT_AN_OBJECT", W_ERROR(WBEM_E_PROPERTY_NOT_AN_OBJECT) },
+ { "WBEM_E_AGGREGATING_BY_OBJECT", W_ERROR(WBEM_E_AGGREGATING_BY_OBJECT) },
+ { "WBEM_E_UNINTERPRETABLE_PROVIDER_QUERY", W_ERROR(WBEM_E_UNINTERPRETABLE_PROVIDER_QUERY) },
+ { "WBEM_E_BACKUP_RESTORE_WINMGMT_RUNNING", W_ERROR(WBEM_E_BACKUP_RESTORE_WINMGMT_RUNNING) },
+ { "WBEM_E_QUEUE_OVERFLOW", W_ERROR(WBEM_E_QUEUE_OVERFLOW) },
+ { "WBEM_E_PRIVILEGE_NOT_HELD", W_ERROR(WBEM_E_PRIVILEGE_NOT_HELD) },
+ { "WBEM_E_INVALID_OPERATOR", W_ERROR(WBEM_E_INVALID_OPERATOR) },
+ { "WBEM_E_LOCAL_CREDENTIALS", W_ERROR(WBEM_E_LOCAL_CREDENTIALS) },
+ { "WBEM_E_CANNOT_BE_ABSTRACT", W_ERROR(WBEM_E_CANNOT_BE_ABSTRACT) },
+ { "WBEM_E_AMENDED_OBJECT", W_ERROR(WBEM_E_AMENDED_OBJECT) },
+ { "WBEM_E_CLIENT_TOO_SLOW", W_ERROR(WBEM_E_CLIENT_TOO_SLOW) },
+ { "WBEM_E_NULL_SECURITY_DESCRIPTOR", W_ERROR(WBEM_E_NULL_SECURITY_DESCRIPTOR) },
+ { "WBEM_E_TIMED_OUT", W_ERROR(WBEM_E_TIMED_OUT) },
+ { "WBEM_E_INVALID_ASSOCIATION", W_ERROR(WBEM_E_INVALID_ASSOCIATION) },
+ { "WBEM_E_AMBIGUOUS_OPERATION", W_ERROR(WBEM_E_AMBIGUOUS_OPERATION) },
+ { "WBEM_E_QUOTA_VIOLATION", W_ERROR(WBEM_E_QUOTA_VIOLATION) },
+ { "WBEM_E_RESERVED_001", W_ERROR(WBEM_E_RESERVED_001) },
+ { "WBEM_E_RESERVED_002", W_ERROR(WBEM_E_RESERVED_002) },
+ { "WBEM_E_UNSUPPORTED_LOCALE", W_ERROR(WBEM_E_UNSUPPORTED_LOCALE) },
+ { "WBEM_E_HANDLE_OUT_OF_DATE", W_ERROR(WBEM_E_HANDLE_OUT_OF_DATE) },
+ { "WBEM_E_CONNECTION_FAILED", W_ERROR(WBEM_E_CONNECTION_FAILED) },
+ { "WBEM_E_INVALID_HANDLE_REQUEST", W_ERROR(WBEM_E_INVALID_HANDLE_REQUEST) },
+ { "WBEM_E_PROPERTY_NAME_TOO_WIDE", W_ERROR(WBEM_E_PROPERTY_NAME_TOO_WIDE) },
+ { "WBEM_E_CLASS_NAME_TOO_WIDE", W_ERROR(WBEM_E_CLASS_NAME_TOO_WIDE) },
+ { "WBEM_E_METHOD_NAME_TOO_WIDE", W_ERROR(WBEM_E_METHOD_NAME_TOO_WIDE) },
+ { "WBEM_E_QUALIFIER_NAME_TOO_WIDE", W_ERROR(WBEM_E_QUALIFIER_NAME_TOO_WIDE) },
+ { "WBEM_E_RERUN_COMMAND", W_ERROR(WBEM_E_RERUN_COMMAND) },
+ { "WBEM_E_DATABASE_VER_MISMATCH", W_ERROR(WBEM_E_DATABASE_VER_MISMATCH) },
+ { "WBEM_E_VETO_DELETE", W_ERROR(WBEM_E_VETO_DELETE) },
+ { "WBEM_E_VETO_PUT", W_ERROR(WBEM_E_VETO_PUT) },
+ { "WBEM_E_INVALID_LOCALE", W_ERROR(WBEM_E_INVALID_LOCALE) },
+ { "WBEM_E_PROVIDER_SUSPENDED", W_ERROR(WBEM_E_PROVIDER_SUSPENDED) },
+ { "WBEM_E_SYNCHRONIZATION_REQUIRED", W_ERROR(WBEM_E_SYNCHRONIZATION_REQUIRED) },
+ { "WBEM_E_NO_SCHEMA", W_ERROR(WBEM_E_NO_SCHEMA) },
+ { "WBEM_E_PROVIDER_ALREADY_REGISTERED", W_ERROR(WBEM_E_PROVIDER_ALREADY_REGISTERED) },
+ { "WBEM_E_PROVIDER_NOT_REGISTERED", W_ERROR(WBEM_E_PROVIDER_NOT_REGISTERED) },
+ { "WBEM_E_FATAL_TRANSPORT_ERROR", W_ERROR(WBEM_E_FATAL_TRANSPORT_ERROR) },
+ { "WBEM_E_ENCRYPTED_CONNECTION_REQUIRED", W_ERROR(WBEM_E_ENCRYPTED_CONNECTION_REQUIRED) },
+ { "WBEM_E_PROVIDER_TIMED_OUT", W_ERROR(WBEM_E_PROVIDER_TIMED_OUT) },
+ { "WBEM_E_NO_KEY", W_ERROR(WBEM_E_NO_KEY) },
+ { "WBEM_E_PROVIDER_DISABLED", W_ERROR(WBEM_E_PROVIDER_DISABLED) },
+ { NULL, W_ERROR(0) }
+};
+
+const char *wmi_errstr(WERROR werror)
+{
+ int idx = 0;
+
+ while (wmi_errs[idx].dos_errstr != NULL) {
+ if (W_ERROR_V(wmi_errs[idx].werror) ==
+ W_ERROR_V(werror))
+ return wmi_errs[idx].dos_errstr;
+ idx++;
+ }
+
+ return win_errstr(werror);
+}
diff --git a/source4/lib/zlib.m4 b/source4/lib/zlib.m4
deleted file mode 100644
index 9ee7b8e49e..0000000000
--- a/source4/lib/zlib.m4
+++ /dev/null
@@ -1,27 +0,0 @@
-
-AC_CHECK_HEADERS(zlib.h)
-
-AC_CHECK_LIB_EXT(z, ZLIB_LIBS, zlibVersion)
-
-AC_CACHE_CHECK([for zlib >= 1.2.3], samba_cv_zlib_1_2_3, [
- AC_TRY_COMPILE([
- #include <zlib.h>
- ],[
- #if (ZLIB_VERNUM >= 0x1230)
- #else
- #error "ZLIB_VERNUM < 0x1230"
- #endif
- ],[
- samba_cv_zlib_1_2_3=yes
- ],[
- samba_cv_zlib_1_2_3=no
- ])
-])
-
-if test x"$ac_cv_header_zlib_h" = x"yes" -a \
- x"$ac_cv_lib_ext_z_zlibVersion" = x"yes" -a \
- x"$samba_cv_zlib_1_2_3" = x"yes"; then
- SMB_EXT_LIB(ZLIB, [${ZLIB_LIBS}])
-else
- SMB_INCLUDE_MK(lib/zlib.mk)
-fi
diff --git a/source4/lib/zlib/ChangeLog b/source4/lib/zlib/ChangeLog
deleted file mode 100644
index 7f6869d323..0000000000
--- a/source4/lib/zlib/ChangeLog
+++ /dev/null
@@ -1,855 +0,0 @@
-
- ChangeLog file for zlib
-
-Changes in 1.2.3 (18 July 2005)
-- Apply security vulnerability fixes to contrib/infback9 as well
-- Clean up some text files (carriage returns, trailing space)
-- Update testzlib, vstudio, masmx64, and masmx86 in contrib [Vollant]
-
-Changes in 1.2.2.4 (11 July 2005)
-- Add inflatePrime() function for starting inflation at bit boundary
-- Avoid some Visual C warnings in deflate.c
-- Avoid more silly Visual C warnings in inflate.c and inftrees.c for 64-bit
- compile
-- Fix some spelling errors in comments [Betts]
-- Correct inflateInit2() error return documentation in zlib.h
-- Added zran.c example of compressed data random access to examples
- directory, shows use of inflatePrime()
-- Fix cast for assignments to strm->state in inflate.c and infback.c
-- Fix zlibCompileFlags() in zutil.c to use 1L for long shifts [Oberhumer]
-- Move declarations of gf2 functions to right place in crc32.c [Oberhumer]
-- Add cast in trees.c t avoid a warning [Oberhumer]
-- Avoid some warnings in fitblk.c, gun.c, gzjoin.c in examples [Oberhumer]
-- Update make_vms.com [Zinser]
-- Initialize state->write in inflateReset() since copied in inflate_fast()
-- Be more strict on incomplete code sets in inflate_table() and increase
- ENOUGH and MAXD -- this repairs a possible security vulnerability for
- invalid inflate input. Thanks to Tavis Ormandy and Markus Oberhumer for
- discovering the vulnerability and providing test cases.
-- Add ia64 support to configure for HP-UX [Smith]
-- Add error return to gzread() for format or i/o error [Levin]
-- Use malloc.h for OS/2 [Necasek]
-
-Changes in 1.2.2.3 (27 May 2005)
-- Replace 1U constants in inflate.c and inftrees.c for 64-bit compile
-- Typecast fread() return values in gzio.c [Vollant]
-- Remove trailing space in minigzip.c outmode (VC++ can't deal with it)
-- Fix crc check bug in gzread() after gzungetc() [Heiner]
-- Add the deflateTune() function to adjust internal compression parameters
-- Add a fast gzip decompressor, gun.c, to examples (use of inflateBack)
-- Remove an incorrect assertion in examples/zpipe.c
-- Add C++ wrapper in infback9.h [Donais]
-- Fix bug in inflateCopy() when decoding fixed codes
-- Note in zlib.h how much deflateSetDictionary() actually uses
-- Remove USE_DICT_HEAD in deflate.c (would mess up inflate if used)
-- Add _WIN32_WCE to define WIN32 in zconf.in.h [Spencer]
-- Don't include stderr.h or errno.h for _WIN32_WCE in zutil.h [Spencer]
-- Add gzdirect() function to indicate transparent reads
-- Update contrib/minizip [Vollant]
-- Fix compilation of deflate.c when both ASMV and FASTEST [Oberhumer]
-- Add casts in crc32.c to avoid warnings [Oberhumer]
-- Add contrib/masmx64 [Vollant]
-- Update contrib/asm586, asm686, masmx86, testzlib, vstudio [Vollant]
-
-Changes in 1.2.2.2 (30 December 2004)
-- Replace structure assignments in deflate.c and inflate.c with zmemcpy to
- avoid implicit memcpy calls (portability for no-library compilation)
-- Increase sprintf() buffer size in gzdopen() to allow for large numbers
-- Add INFLATE_STRICT to check distances against zlib header
-- Improve WinCE errno handling and comments [Chang]
-- Remove comment about no gzip header processing in FAQ
-- Add Z_FIXED strategy option to deflateInit2() to force fixed trees
-- Add updated make_vms.com [Coghlan], update README
-- Create a new "examples" directory, move gzappend.c there, add zpipe.c,
- fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html.
-- Add FAQ entry and comments in deflate.c on uninitialized memory access
-- Add Solaris 9 make options in configure [Gilbert]
-- Allow strerror() usage in gzio.c for STDC
-- Fix DecompressBuf in contrib/delphi/ZLib.pas [ManChesTer]
-- Update contrib/masmx86/inffas32.asm and gvmat32.asm [Vollant]
-- Use z_off_t for adler32_combine() and crc32_combine() lengths
-- Make adler32() much faster for small len
-- Use OS_CODE in deflate() default gzip header
-
-Changes in 1.2.2.1 (31 October 2004)
-- Allow inflateSetDictionary() call for raw inflate
-- Fix inflate header crc check bug for file names and comments
-- Add deflateSetHeader() and gz_header structure for custom gzip headers
-- Add inflateGetheader() to retrieve gzip headers
-- Add crc32_combine() and adler32_combine() functions
-- Add alloc_func, free_func, in_func, out_func to Z_PREFIX list
-- Use zstreamp consistently in zlib.h (inflate_back functions)
-- Remove GUNZIP condition from definition of inflate_mode in inflate.h
- and in contrib/inflate86/inffast.S [Truta, Anderson]
-- Add support for AMD64 in contrib/inflate86/inffas86.c [Anderson]
-- Update projects/README.projects and projects/visualc6 [Truta]
-- Update win32/DLL_FAQ.txt [Truta]
-- Avoid warning under NO_GZCOMPRESS in gzio.c; fix typo [Truta]
-- Deprecate Z_ASCII; use Z_TEXT instead [Truta]
-- Use a new algorithm for setting strm->data_type in trees.c [Truta]
-- Do not define an exit() prototype in zutil.c unless DEBUG defined
-- Remove prototype of exit() from zutil.c, example.c, minigzip.c [Truta]
-- Add comment in zlib.h for Z_NO_FLUSH parameter to deflate()
-- Fix Darwin build version identification [Peterson]
-
-Changes in 1.2.2 (3 October 2004)
-- Update zlib.h comments on gzip in-memory processing
-- Set adler to 1 in inflateReset() to support Java test suite [Walles]
-- Add contrib/dotzlib [Ravn]
-- Update win32/DLL_FAQ.txt [Truta]
-- Update contrib/minizip [Vollant]
-- Move contrib/visual-basic.txt to old/ [Truta]
-- Fix assembler builds in projects/visualc6/ [Truta]
-
-Changes in 1.2.1.2 (9 September 2004)
-- Update INDEX file
-- Fix trees.c to update strm->data_type (no one ever noticed!)
-- Fix bug in error case in inflate.c, infback.c, and infback9.c [Brown]
-- Add "volatile" to crc table flag declaration (for DYNAMIC_CRC_TABLE)
-- Add limited multitasking protection to DYNAMIC_CRC_TABLE
-- Add NO_vsnprintf for VMS in zutil.h [Mozilla]
-- Don't declare strerror() under VMS [Mozilla]
-- Add comment to DYNAMIC_CRC_TABLE to use get_crc_table() to initialize
-- Update contrib/ada [Anisimkov]
-- Update contrib/minizip [Vollant]
-- Fix configure to not hardcode directories for Darwin [Peterson]
-- Fix gzio.c to not return error on empty files [Brown]
-- Fix indentation; update version in contrib/delphi/ZLib.pas and
- contrib/pascal/zlibpas.pas [Truta]
-- Update mkasm.bat in contrib/masmx86 [Truta]
-- Update contrib/untgz [Truta]
-- Add projects/README.projects [Truta]
-- Add project for MS Visual C++ 6.0 in projects/visualc6 [Cadieux, Truta]
-- Update win32/DLL_FAQ.txt [Truta]
-- Update list of Z_PREFIX symbols in zconf.h [Randers-Pehrson, Truta]
-- Remove an unnecessary assignment to curr in inftrees.c [Truta]
-- Add OS/2 to exe builds in configure [Poltorak]
-- Remove err dummy parameter in zlib.h [Kientzle]
-
-Changes in 1.2.1.1 (9 January 2004)
-- Update email address in README
-- Several FAQ updates
-- Fix a big fat bug in inftrees.c that prevented decoding valid
- dynamic blocks with only literals and no distance codes --
- Thanks to "Hot Emu" for the bug report and sample file
-- Add a note to puff.c on no distance codes case.
-
-Changes in 1.2.1 (17 November 2003)
-- Remove a tab in contrib/gzappend/gzappend.c
-- Update some interfaces in contrib for new zlib functions
-- Update zlib version number in some contrib entries
-- Add Windows CE definition for ptrdiff_t in zutil.h [Mai, Truta]
-- Support shared libraries on Hurd and KFreeBSD [Brown]
-- Fix error in NO_DIVIDE option of adler32.c
-
-Changes in 1.2.0.8 (4 November 2003)
-- Update version in contrib/delphi/ZLib.pas and contrib/pascal/zlibpas.pas
-- Add experimental NO_DIVIDE #define in adler32.c
- - Possibly faster on some processors (let me know if it is)
-- Correct Z_BLOCK to not return on first inflate call if no wrap
-- Fix strm->data_type on inflate() return to correctly indicate EOB
-- Add deflatePrime() function for appending in the middle of a byte
-- Add contrib/gzappend for an example of appending to a stream
-- Update win32/DLL_FAQ.txt [Truta]
-- Delete Turbo C comment in README [Truta]
-- Improve some indentation in zconf.h [Truta]
-- Fix infinite loop on bad input in configure script [Church]
-- Fix gzeof() for concatenated gzip files [Johnson]
-- Add example to contrib/visual-basic.txt [Michael B.]
-- Add -p to mkdir's in Makefile.in [vda]
-- Fix configure to properly detect presence or lack of printf functions
-- Add AS400 support [Monnerat]
-- Add a little Cygwin support [Wilson]
-
-Changes in 1.2.0.7 (21 September 2003)
-- Correct some debug formats in contrib/infback9
-- Cast a type in a debug statement in trees.c
-- Change search and replace delimiter in configure from % to # [Beebe]
-- Update contrib/untgz to 0.2 with various fixes [Truta]
-- Add build support for Amiga [Nikl]
-- Remove some directories in old that have been updated to 1.2
-- Add dylib building for Mac OS X in configure and Makefile.in
-- Remove old distribution stuff from Makefile
-- Update README to point to DLL_FAQ.txt, and add comment on Mac OS X
-- Update links in README
-
-Changes in 1.2.0.6 (13 September 2003)
-- Minor FAQ updates
-- Update contrib/minizip to 1.00 [Vollant]
-- Remove test of gz functions in example.c when GZ_COMPRESS defined [Truta]
-- Update POSTINC comment for 68060 [Nikl]
-- Add contrib/infback9 with deflate64 decoding (unsupported)
-- For MVS define NO_vsnprintf and undefine FAR [van Burik]
-- Add pragma for fdopen on MVS [van Burik]
-
-Changes in 1.2.0.5 (8 September 2003)
-- Add OF to inflateBackEnd() declaration in zlib.h
-- Remember start when using gzdopen in the middle of a file
-- Use internal off_t counters in gz* functions to properly handle seeks
-- Perform more rigorous check for distance-too-far in inffast.c
-- Add Z_BLOCK flush option to return from inflate at block boundary
-- Set strm->data_type on return from inflate
- - Indicate bits unused, if at block boundary, and if in last block
-- Replace size_t with ptrdiff_t in crc32.c, and check for correct size
-- Add condition so old NO_DEFLATE define still works for compatibility
-- FAQ update regarding the Windows DLL [Truta]
-- INDEX update: add qnx entry, remove aix entry [Truta]
-- Install zlib.3 into mandir [Wilson]
-- Move contrib/zlib_dll_FAQ.txt to win32/DLL_FAQ.txt; update [Truta]
-- Adapt the zlib interface to the new DLL convention guidelines [Truta]
-- Introduce ZLIB_WINAPI macro to allow the export of functions using
- the WINAPI calling convention, for Visual Basic [Vollant, Truta]
-- Update msdos and win32 scripts and makefiles [Truta]
-- Export symbols by name, not by ordinal, in win32/zlib.def [Truta]
-- Add contrib/ada [Anisimkov]
-- Move asm files from contrib/vstudio/vc70_32 to contrib/asm386 [Truta]
-- Rename contrib/asm386 to contrib/masmx86 [Truta, Vollant]
-- Add contrib/masm686 [Truta]
-- Fix offsets in contrib/inflate86 and contrib/masmx86/inffas32.asm
- [Truta, Vollant]
-- Update contrib/delphi; rename to contrib/pascal; add example [Truta]
-- Remove contrib/delphi2; add a new contrib/delphi [Truta]
-- Avoid inclusion of the nonstandard <memory.h> in contrib/iostream,
- and fix some method prototypes [Truta]
-- Fix the ZCR_SEED2 constant to avoid warnings in contrib/minizip
- [Truta]
-- Avoid the use of backslash (\) in contrib/minizip [Vollant]
-- Fix file time handling in contrib/untgz; update makefiles [Truta]
-- Update contrib/vstudio/vc70_32 to comply with the new DLL guidelines
- [Vollant]
-- Remove contrib/vstudio/vc15_16 [Vollant]
-- Rename contrib/vstudio/vc70_32 to contrib/vstudio/vc7 [Truta]
-- Update README.contrib [Truta]
-- Invert the assignment order of match_head and s->prev[...] in
- INSERT_STRING [Truta]
-- Compare TOO_FAR with 32767 instead of 32768, to avoid 16-bit warnings
- [Truta]
-- Compare function pointers with 0, not with NULL or Z_NULL [Truta]
-- Fix prototype of syncsearch in inflate.c [Truta]
-- Introduce ASMINF macro to be enabled when using an ASM implementation
- of inflate_fast [Truta]
-- Change NO_DEFLATE to NO_GZCOMPRESS [Truta]
-- Modify test_gzio in example.c to take a single file name as a
- parameter [Truta]
-- Exit the example.c program if gzopen fails [Truta]
-- Add type casts around strlen in example.c [Truta]
-- Remove casting to sizeof in minigzip.c; give a proper type
- to the variable compared with SUFFIX_LEN [Truta]
-- Update definitions of STDC and STDC99 in zconf.h [Truta]
-- Synchronize zconf.h with the new Windows DLL interface [Truta]
-- Use SYS16BIT instead of __32BIT__ to distinguish between
- 16- and 32-bit platforms [Truta]
-- Use far memory allocators in small 16-bit memory models for
- Turbo C [Truta]
-- Add info about the use of ASMV, ASMINF and ZLIB_WINAPI in
- zlibCompileFlags [Truta]
-- Cygwin has vsnprintf [Wilson]
-- In Windows16, OS_CODE is 0, as in MSDOS [Truta]
-- In Cygwin, OS_CODE is 3 (Unix), not 11 (Windows32) [Wilson]
-
-Changes in 1.2.0.4 (10 August 2003)
-- Minor FAQ updates
-- Be more strict when checking inflateInit2's windowBits parameter
-- Change NO_GUNZIP compile option to NO_GZIP to cover deflate as well
-- Add gzip wrapper option to deflateInit2 using windowBits
-- Add updated QNX rule in configure and qnx directory [Bonnefoy]
-- Make inflate distance-too-far checks more rigorous
-- Clean up FAR usage in inflate
-- Add casting to sizeof() in gzio.c and minigzip.c
-
-Changes in 1.2.0.3 (19 July 2003)
-- Fix silly error in gzungetc() implementation [Vollant]
-- Update contrib/minizip and contrib/vstudio [Vollant]
-- Fix printf format in example.c
-- Correct cdecl support in zconf.in.h [Anisimkov]
-- Minor FAQ updates
-
-Changes in 1.2.0.2 (13 July 2003)
-- Add ZLIB_VERNUM in zlib.h for numerical preprocessor comparisons
-- Attempt to avoid warnings in crc32.c for pointer-int conversion
-- Add AIX to configure, remove aix directory [Bakker]
-- Add some casts to minigzip.c
-- Improve checking after insecure sprintf() or vsprintf() calls
-- Remove #elif's from crc32.c
-- Change leave label to inf_leave in inflate.c and infback.c to avoid
- library conflicts
-- Remove inflate gzip decoding by default--only enable gzip decoding by
- special request for stricter backward compatibility
-- Add zlibCompileFlags() function to return compilation information
-- More typecasting in deflate.c to avoid warnings
-- Remove leading underscore from _Capital #defines [Truta]
-- Fix configure to link shared library when testing
-- Add some Windows CE target adjustments [Mai]
-- Remove #define ZLIB_DLL in zconf.h [Vollant]
-- Add zlib.3 [Rodgers]
-- Update RFC URL in deflate.c and algorithm.txt [Mai]
-- Add zlib_dll_FAQ.txt to contrib [Truta]
-- Add UL to some constants [Truta]
-- Update minizip and vstudio [Vollant]
-- Remove vestigial NEED_DUMMY_RETURN from zconf.in.h
-- Expand use of NO_DUMMY_DECL to avoid all dummy structures
-- Added iostream3 to contrib [Schwardt]
-- Replace rewind() with fseek() for WinCE [Truta]
-- Improve setting of zlib format compression level flags
- - Report 0 for huffman and rle strategies and for level == 0 or 1
- - Report 2 only for level == 6
-- Only deal with 64K limit when necessary at compile time [Truta]
-- Allow TOO_FAR check to be turned off at compile time [Truta]
-- Add gzclearerr() function [Souza]
-- Add gzungetc() function
-
-Changes in 1.2.0.1 (17 March 2003)
-- Add Z_RLE strategy for run-length encoding [Truta]
- - When Z_RLE requested, restrict matches to distance one
- - Update zlib.h, minigzip.c, gzopen(), gzdopen() for Z_RLE
-- Correct FASTEST compilation to allow level == 0
-- Clean up what gets compiled for FASTEST
-- Incorporate changes to zconf.in.h [Vollant]
- - Refine detection of Turbo C need for dummy returns
- - Refine ZLIB_DLL compilation
- - Include additional header file on VMS for off_t typedef
-- Try to use _vsnprintf where it supplants vsprintf [Vollant]
-- Add some casts in inffast.c
-- Enchance comments in zlib.h on what happens if gzprintf() tries to
- write more than 4095 bytes before compression
-- Remove unused state from inflateBackEnd()
-- Remove exit(0) from minigzip.c, example.c
-- Get rid of all those darn tabs
-- Add "check" target to Makefile.in that does the same thing as "test"
-- Add "mostlyclean" and "maintainer-clean" targets to Makefile.in
-- Update contrib/inflate86 [Anderson]
-- Update contrib/testzlib, contrib/vstudio, contrib/minizip [Vollant]
-- Add msdos and win32 directories with makefiles [Truta]
-- More additions and improvements to the FAQ
-
-Changes in 1.2.0 (9 March 2003)
-- New and improved inflate code
- - About 20% faster
- - Does not allocate 32K window unless and until needed
- - Automatically detects and decompresses gzip streams
- - Raw inflate no longer needs an extra dummy byte at end
- - Added inflateBack functions using a callback interface--even faster
- than inflate, useful for file utilities (gzip, zip)
- - Added inflateCopy() function to record state for random access on
- externally generated deflate streams (e.g. in gzip files)
- - More readable code (I hope)
-- New and improved crc32()
- - About 50% faster, thanks to suggestions from Rodney Brown
-- Add deflateBound() and compressBound() functions
-- Fix memory leak in deflateInit2()
-- Permit setting dictionary for raw deflate (for parallel deflate)
-- Fix const declaration for gzwrite()
-- Check for some malloc() failures in gzio.c
-- Fix bug in gzopen() on single-byte file 0x1f
-- Fix bug in gzread() on concatenated file with 0x1f at end of buffer
- and next buffer doesn't start with 0x8b
-- Fix uncompress() to return Z_DATA_ERROR on truncated input
-- Free memory at end of example.c
-- Remove MAX #define in trees.c (conflicted with some libraries)
-- Fix static const's in deflate.c, gzio.c, and zutil.[ch]
-- Declare malloc() and free() in gzio.c if STDC not defined
-- Use malloc() instead of calloc() in zutil.c if int big enough
-- Define STDC for AIX
-- Add aix/ with approach for compiling shared library on AIX
-- Add HP-UX support for shared libraries in configure
-- Add OpenUNIX support for shared libraries in configure
-- Use $cc instead of gcc to build shared library
-- Make prefix directory if needed when installing
-- Correct Macintosh avoidance of typedef Byte in zconf.h
-- Correct Turbo C memory allocation when under Linux
-- Use libz.a instead of -lz in Makefile (assure use of compiled library)
-- Update configure to check for snprintf or vsnprintf functions and their
- return value, warn during make if using an insecure function
-- Fix configure problem with compile-time knowledge of HAVE_UNISTD_H that
- is lost when library is used--resolution is to build new zconf.h
-- Documentation improvements (in zlib.h):
- - Document raw deflate and inflate
- - Update RFCs URL
- - Point out that zlib and gzip formats are different
- - Note that Z_BUF_ERROR is not fatal
- - Document string limit for gzprintf() and possible buffer overflow
- - Note requirement on avail_out when flushing
- - Note permitted values of flush parameter of inflate()
-- Add some FAQs (and even answers) to the FAQ
-- Add contrib/inflate86/ for x86 faster inflate
-- Add contrib/blast/ for PKWare Data Compression Library decompression
-- Add contrib/puff/ simple inflate for deflate format description
-
-Changes in 1.1.4 (11 March 2002)
-- ZFREE was repeated on same allocation on some error conditions.
- This creates a security problem described in
- http://www.zlib.org/advisory-2002-03-11.txt
-- Returned incorrect error (Z_MEM_ERROR) on some invalid data
-- Avoid accesses before window for invalid distances with inflate window
- less than 32K.
-- force windowBits > 8 to avoid a bug in the encoder for a window size
- of 256 bytes. (A complete fix will be available in 1.1.5).
-
-Changes in 1.1.3 (9 July 1998)
-- fix "an inflate input buffer bug that shows up on rare but persistent
- occasions" (Mark)
-- fix gzread and gztell for concatenated .gz files (Didier Le Botlan)
-- fix gzseek(..., SEEK_SET) in write mode
-- fix crc check after a gzeek (Frank Faubert)
-- fix miniunzip when the last entry in a zip file is itself a zip file
- (J Lillge)
-- add contrib/asm586 and contrib/asm686 (Brian Raiter)
- See http://www.muppetlabs.com/~breadbox/software/assembly.html
-- add support for Delphi 3 in contrib/delphi (Bob Dellaca)
-- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti)
-- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren)
-- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks)
-- added a FAQ file
-
-- Support gzdopen on Mac with Metrowerks (Jason Linhart)
-- Do not redefine Byte on Mac (Brad Pettit & Jason Linhart)
-- define SEEK_END too if SEEK_SET is not defined (Albert Chin-A-Young)
-- avoid some warnings with Borland C (Tom Tanner)
-- fix a problem in contrib/minizip/zip.c for 16-bit MSDOS (Gilles Vollant)
-- emulate utime() for WIN32 in contrib/untgz (Gilles Vollant)
-- allow several arguments to configure (Tim Mooney, Frodo Looijaard)
-- use libdir and includedir in Makefile.in (Tim Mooney)
-- support shared libraries on OSF1 V4 (Tim Mooney)
-- remove so_locations in "make clean" (Tim Mooney)
-- fix maketree.c compilation error (Glenn, Mark)
-- Python interface to zlib now in Python 1.5 (Jeremy Hylton)
-- new Makefile.riscos (Rich Walker)
-- initialize static descriptors in trees.c for embedded targets (Nick Smith)
-- use "foo-gz" in example.c for RISCOS and VMS (Nick Smith)
-- add the OS/2 files in Makefile.in too (Andrew Zabolotny)
-- fix fdopen and halloc macros for Microsoft C 6.0 (Tom Lane)
-- fix maketree.c to allow clean compilation of inffixed.h (Mark)
-- fix parameter check in deflateCopy (Gunther Nikl)
-- cleanup trees.c, use compressed_len only in debug mode (Christian Spieler)
-- Many portability patches by Christian Spieler:
- . zutil.c, zutil.h: added "const" for zmem*
- . Make_vms.com: fixed some typos
- . Make_vms.com: msdos/Makefile.*: removed zutil.h from some dependency lists
- . msdos/Makefile.msc: remove "default rtl link library" info from obj files
- . msdos/Makefile.*: use model-dependent name for the built zlib library
- . msdos/Makefile.emx, nt/Makefile.emx, nt/Makefile.gcc:
- new makefiles, for emx (DOS/OS2), emx&rsxnt and mingw32 (Windows 9x / NT)
-- use define instead of typedef for Bytef also for MSC small/medium (Tom Lane)
-- replace __far with _far for better portability (Christian Spieler, Tom Lane)
-- fix test for errno.h in configure (Tim Newsham)
-
-Changes in 1.1.2 (19 March 98)
-- added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant)
- See http://www.winimage.com/zLibDll/unzip.html
-- preinitialize the inflate tables for fixed codes, to make the code
- completely thread safe (Mark)
-- some simplifications and slight speed-up to the inflate code (Mark)
-- fix gzeof on non-compressed files (Allan Schrum)
-- add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs)
-- use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn)
-- added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny)
-- add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori)
-- do not wrap extern "C" around system includes (Tom Lane)
-- mention zlib binding for TCL in README (Andreas Kupries)
-- added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert)
-- allow "make install prefix=..." even after configure (Glenn Randers-Pehrson)
-- allow "configure --prefix $HOME" (Tim Mooney)
-- remove warnings in example.c and gzio.c (Glenn Randers-Pehrson)
-- move Makefile.sas to amiga/Makefile.sas
-
-Changes in 1.1.1 (27 Feb 98)
-- fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson)
-- remove block truncation heuristic which had very marginal effect for zlib
- (smaller lit_bufsize than in gzip 1.2.4) and degraded a little the
- compression ratio on some files. This also allows inlining _tr_tally for
- matches in deflate_slow.
-- added msdos/Makefile.w32 for WIN32 Microsoft Visual C++ (Bob Frazier)
-
-Changes in 1.1.0 (24 Feb 98)
-- do not return STREAM_END prematurely in inflate (John Bowler)
-- revert to the zlib 1.0.8 inflate to avoid the gcc 2.8.0 bug (Jeremy Buhler)
-- compile with -DFASTEST to get compression code optimized for speed only
-- in minigzip, try mmap'ing the input file first (Miguel Albrecht)
-- increase size of I/O buffers in minigzip.c and gzio.c (not a big gain
- on Sun but significant on HP)
-
-- add a pointer to experimental unzip library in README (Gilles Vollant)
-- initialize variable gcc in configure (Chris Herborth)
-
-Changes in 1.0.9 (17 Feb 1998)
-- added gzputs and gzgets functions
-- do not clear eof flag in gzseek (Mark Diekhans)
-- fix gzseek for files in transparent mode (Mark Diekhans)
-- do not assume that vsprintf returns the number of bytes written (Jens Krinke)
-- replace EXPORT with ZEXPORT to avoid conflict with other programs
-- added compress2 in zconf.h, zlib.def, zlib.dnt
-- new asm code from Gilles Vollant in contrib/asm386
-- simplify the inflate code (Mark):
- . Replace ZALLOC's in huft_build() with single ZALLOC in inflate_blocks_new()
- . ZALLOC the length list in inflate_trees_fixed() instead of using stack
- . ZALLOC the value area for huft_build() instead of using stack
- . Simplify Z_FINISH check in inflate()
-
-- Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8
-- in inftrees.c, avoid cc -O bug on HP (Farshid Elahi)
-- in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with
- the declaration of FAR (Gilles VOllant)
-- install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann)
-- read_buf buf parameter of type Bytef* instead of charf*
-- zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout)
-- do not redeclare unlink in minigzip.c for WIN32 (John Bowler)
-- fix check for presence of directories in "make install" (Ian Willis)
-
-Changes in 1.0.8 (27 Jan 1998)
-- fixed offsets in contrib/asm386/gvmat32.asm (Gilles Vollant)
-- fix gzgetc and gzputc for big endian systems (Markus Oberhumer)
-- added compress2() to allow setting the compression level
-- include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong)
-- use constant arrays for the static trees in trees.c instead of computing
- them at run time (thanks to Ken Raeburn for this suggestion). To create
- trees.h, compile with GEN_TREES_H and run "make test".
-- check return code of example in "make test" and display result
-- pass minigzip command line options to file_compress
-- simplifying code of inflateSync to avoid gcc 2.8 bug
-
-- support CC="gcc -Wall" in configure -s (QingLong)
-- avoid a flush caused by ftell in gzopen for write mode (Ken Raeburn)
-- fix test for shared library support to avoid compiler warnings
-- zlib.lib -> zlib.dll in msdos/zlib.rc (Gilles Vollant)
-- check for TARGET_OS_MAC in addition to MACOS (Brad Pettit)
-- do not use fdopen for Metrowerks on Mac (Brad Pettit))
-- add checks for gzputc and gzputc in example.c
-- avoid warnings in gzio.c and deflate.c (Andreas Kleinert)
-- use const for the CRC table (Ken Raeburn)
-- fixed "make uninstall" for shared libraries
-- use Tracev instead of Trace in infblock.c
-- in example.c use correct compressed length for test_sync
-- suppress +vnocompatwarnings in configure for HPUX (not always supported)
-
-Changes in 1.0.7 (20 Jan 1998)
-- fix gzseek which was broken in write mode
-- return error for gzseek to negative absolute position
-- fix configure for Linux (Chun-Chung Chen)
-- increase stack space for MSC (Tim Wegner)
-- get_crc_table and inflateSyncPoint are EXPORTed (Gilles Vollant)
-- define EXPORTVA for gzprintf (Gilles Vollant)
-- added man page zlib.3 (Rick Rodgers)
-- for contrib/untgz, fix makedir() and improve Makefile
-
-- check gzseek in write mode in example.c
-- allocate extra buffer for seeks only if gzseek is actually called
-- avoid signed/unsigned comparisons (Tim Wegner, Gilles Vollant)
-- add inflateSyncPoint in zconf.h
-- fix list of exported functions in nt/zlib.dnt and mdsos/zlib.def
-
-Changes in 1.0.6 (19 Jan 1998)
-- add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and
- gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code)
-- Fix a deflate bug occurring only with compression level 0 (thanks to
- Andy Buckler for finding this one).
-- In minigzip, pass transparently also the first byte for .Z files.
-- return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress()
-- check Z_FINISH in inflate (thanks to Marc Schluper)
-- Implement deflateCopy (thanks to Adam Costello)
-- make static libraries by default in configure, add --shared option.
-- move MSDOS or Windows specific files to directory msdos
-- suppress the notion of partial flush to simplify the interface
- (but the symbol Z_PARTIAL_FLUSH is kept for compatibility with 1.0.4)
-- suppress history buffer provided by application to simplify the interface
- (this feature was not implemented anyway in 1.0.4)
-- next_in and avail_in must be initialized before calling inflateInit or
- inflateInit2
-- add EXPORT in all exported functions (for Windows DLL)
-- added Makefile.nt (thanks to Stephen Williams)
-- added the unsupported "contrib" directory:
- contrib/asm386/ by Gilles Vollant <info@winimage.com>
- 386 asm code replacing longest_match().
- contrib/iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
- A C++ I/O streams interface to the zlib gz* functions
- contrib/iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no>
- Another C++ I/O streams interface
- contrib/untgz/ by "Pedro A. Aranda Guti\irrez" <paag@tid.es>
- A very simple tar.gz file extractor using zlib
- contrib/visual-basic.txt by Carlos Rios <c_rios@sonda.cl>
- How to use compress(), uncompress() and the gz* functions from VB.
-- pass params -f (filtered data), -h (huffman only), -1 to -9 (compression
- level) in minigzip (thanks to Tom Lane)
-
-- use const for rommable constants in deflate
-- added test for gzseek and gztell in example.c
-- add undocumented function inflateSyncPoint() (hack for Paul Mackerras)
-- add undocumented function zError to convert error code to string
- (for Tim Smithers)
-- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code.
-- Use default memcpy for Symantec MSDOS compiler.
-- Add EXPORT keyword for check_func (needed for Windows DLL)
-- add current directory to LD_LIBRARY_PATH for "make test"
-- create also a link for libz.so.1
-- added support for FUJITSU UXP/DS (thanks to Toshiaki Nomura)
-- use $(SHAREDLIB) instead of libz.so in Makefile.in (for HPUX)
-- added -soname for Linux in configure (Chun-Chung Chen,
-- assign numbers to the exported functions in zlib.def (for Windows DLL)
-- add advice in zlib.h for best usage of deflateSetDictionary
-- work around compiler bug on Atari (cast Z_NULL in call of s->checkfn)
-- allow compilation with ANSI keywords only enabled for TurboC in large model
-- avoid "versionString"[0] (Borland bug)
-- add NEED_DUMMY_RETURN for Borland
-- use variable z_verbose for tracing in debug mode (L. Peter Deutsch).
-- allow compilation with CC
-- defined STDC for OS/2 (David Charlap)
-- limit external names to 8 chars for MVS (Thomas Lund)
-- in minigzip.c, use static buffers only for 16-bit systems
-- fix suffix check for "minigzip -d foo.gz"
-- do not return an error for the 2nd of two consecutive gzflush() (Felix Lee)
-- use _fdopen instead of fdopen for MSC >= 6.0 (Thomas Fanslau)
-- added makelcc.bat for lcc-win32 (Tom St Denis)
-- in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe)
-- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion.
-- check for unistd.h in configure (for off_t)
-- remove useless check parameter in inflate_blocks_free
-- avoid useless assignment of s->check to itself in inflate_blocks_new
-- do not flush twice in gzclose (thanks to Ken Raeburn)
-- rename FOPEN as F_OPEN to avoid clash with /usr/include/sys/file.h
-- use NO_ERRNO_H instead of enumeration of operating systems with errno.h
-- work around buggy fclose on pipes for HP/UX
-- support zlib DLL with BORLAND C++ 5.0 (thanks to Glenn Randers-Pehrson)
-- fix configure if CC is already equal to gcc
-
-Changes in 1.0.5 (3 Jan 98)
-- Fix inflate to terminate gracefully when fed corrupted or invalid data
-- Use const for rommable constants in inflate
-- Eliminate memory leaks on error conditions in inflate
-- Removed some vestigial code in inflate
-- Update web address in README
-
-Changes in 1.0.4 (24 Jul 96)
-- In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF
- bit, so the decompressor could decompress all the correct data but went
- on to attempt decompressing extra garbage data. This affected minigzip too.
-- zlibVersion and gzerror return const char* (needed for DLL)
-- port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno)
-- use z_error only for DEBUG (avoid problem with DLLs)
-
-Changes in 1.0.3 (2 Jul 96)
-- use z_streamp instead of z_stream *, which is now a far pointer in MSDOS
- small and medium models; this makes the library incompatible with previous
- versions for these models. (No effect in large model or on other systems.)
-- return OK instead of BUF_ERROR if previous deflate call returned with
- avail_out as zero but there is nothing to do
-- added memcmp for non STDC compilers
-- define NO_DUMMY_DECL for more Mac compilers (.h files merged incorrectly)
-- define __32BIT__ if __386__ or i386 is defined (pb. with Watcom and SCO)
-- better check for 16-bit mode MSC (avoids problem with Symantec)
-
-Changes in 1.0.2 (23 May 96)
-- added Windows DLL support
-- added a function zlibVersion (for the DLL support)
-- fixed declarations using Bytef in infutil.c (pb with MSDOS medium model)
-- Bytef is define's instead of typedef'd only for Borland C
-- avoid reading uninitialized memory in example.c
-- mention in README that the zlib format is now RFC1950
-- updated Makefile.dj2
-- added algorithm.doc
-
-Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion]
-- fix array overlay in deflate.c which sometimes caused bad compressed data
-- fix inflate bug with empty stored block
-- fix MSDOS medium model which was broken in 0.99
-- fix deflateParams() which could generated bad compressed data.
-- Bytef is define'd instead of typedef'ed (work around Borland bug)
-- added an INDEX file
-- new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32),
- Watcom (Makefile.wat), Amiga SAS/C (Makefile.sas)
-- speed up adler32 for modern machines without auto-increment
-- added -ansi for IRIX in configure
-- static_init_done in trees.c is an int
-- define unlink as delete for VMS
-- fix configure for QNX
-- add configure branch for SCO and HPUX
-- avoid many warnings (unused variables, dead assignments, etc...)
-- no fdopen for BeOS
-- fix the Watcom fix for 32 bit mode (define FAR as empty)
-- removed redefinition of Byte for MKWERKS
-- work around an MWKERKS bug (incorrect merge of all .h files)
-
-Changes in 0.99 (27 Jan 96)
-- allow preset dictionary shared between compressor and decompressor
-- allow compression level 0 (no compression)
-- add deflateParams in zlib.h: allow dynamic change of compression level
- and compression strategy.
-- test large buffers and deflateParams in example.c
-- add optional "configure" to build zlib as a shared library
-- suppress Makefile.qnx, use configure instead
-- fixed deflate for 64-bit systems (detected on Cray)
-- fixed inflate_blocks for 64-bit systems (detected on Alpha)
-- declare Z_DEFLATED in zlib.h (possible parameter for deflateInit2)
-- always return Z_BUF_ERROR when deflate() has nothing to do
-- deflateInit and inflateInit are now macros to allow version checking
-- prefix all global functions and types with z_ with -DZ_PREFIX
-- make falloc completely reentrant (inftrees.c)
-- fixed very unlikely race condition in ct_static_init
-- free in reverse order of allocation to help memory manager
-- use zlib-1.0/* instead of zlib/* inside the tar.gz
-- make zlib warning-free with "gcc -O3 -Wall -Wwrite-strings -Wpointer-arith
- -Wconversion -Wstrict-prototypes -Wmissing-prototypes"
-- allow gzread on concatenated .gz files
-- deflateEnd now returns Z_DATA_ERROR if it was premature
-- deflate is finally (?) fully deterministic (no matches beyond end of input)
-- Document Z_SYNC_FLUSH
-- add uninstall in Makefile
-- Check for __cpluplus in zlib.h
-- Better test in ct_align for partial flush
-- avoid harmless warnings for Borland C++
-- initialize hash_head in deflate.c
-- avoid warning on fdopen (gzio.c) for HP cc -Aa
-- include stdlib.h for STDC compilers
-- include errno.h for Cray
-- ignore error if ranlib doesn't exist
-- call ranlib twice for NeXTSTEP
-- use exec_prefix instead of prefix for libz.a
-- renamed ct_* as _tr_* to avoid conflict with applications
-- clear z->msg in inflateInit2 before any error return
-- initialize opaque in example.c, gzio.c, deflate.c and inflate.c
-- fixed typo in zconf.h (_GNUC__ => __GNUC__)
-- check for WIN32 in zconf.h and zutil.c (avoid farmalloc in 32-bit mode)
-- fix typo in Make_vms.com (f$trnlnm -> f$getsyi)
-- in fcalloc, normalize pointer if size > 65520 bytes
-- don't use special fcalloc for 32 bit Borland C++
-- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc...
-- use Z_BINARY instead of BINARY
-- document that gzclose after gzdopen will close the file
-- allow "a" as mode in gzopen.
-- fix error checking in gzread
-- allow skipping .gz extra-field on pipes
-- added reference to Perl interface in README
-- put the crc table in FAR data (I dislike more and more the medium model :)
-- added get_crc_table
-- added a dimension to all arrays (Borland C can't count).
-- workaround Borland C bug in declaration of inflate_codes_new & inflate_fast
-- guard against multiple inclusion of *.h (for precompiled header on Mac)
-- Watcom C pretends to be Microsoft C small model even in 32 bit mode.
-- don't use unsized arrays to avoid silly warnings by Visual C++:
- warning C4746: 'inflate_mask' : unsized array treated as '__far'
- (what's wrong with far data in far model?).
-- define enum out of inflate_blocks_state to allow compilation with C++
-
-Changes in 0.95 (16 Aug 95)
-- fix MSDOS small and medium model (now easier to adapt to any compiler)
-- inlined send_bits
-- fix the final (:-) bug for deflate with flush (output was correct but
- not completely flushed in rare occasions).
-- default window size is same for compression and decompression
- (it's now sufficient to set MAX_WBITS in zconf.h).
-- voidp -> voidpf and voidnp -> voidp (for consistency with other
- typedefs and because voidnp was not near in large model).
-
-Changes in 0.94 (13 Aug 95)
-- support MSDOS medium model
-- fix deflate with flush (could sometimes generate bad output)
-- fix deflateReset (zlib header was incorrectly suppressed)
-- added support for VMS
-- allow a compression level in gzopen()
-- gzflush now calls fflush
-- For deflate with flush, flush even if no more input is provided.
-- rename libgz.a as libz.a
-- avoid complex expression in infcodes.c triggering Turbo C bug
-- work around a problem with gcc on Alpha (in INSERT_STRING)
-- don't use inline functions (problem with some gcc versions)
-- allow renaming of Byte, uInt, etc... with #define.
-- avoid warning about (unused) pointer before start of array in deflate.c
-- avoid various warnings in gzio.c, example.c, infblock.c, adler32.c, zutil.c
-- avoid reserved word 'new' in trees.c
-
-Changes in 0.93 (25 June 95)
-- temporarily disable inline functions
-- make deflate deterministic
-- give enough lookahead for PARTIAL_FLUSH
-- Set binary mode for stdin/stdout in minigzip.c for OS/2
-- don't even use signed char in inflate (not portable enough)
-- fix inflate memory leak for segmented architectures
-
-Changes in 0.92 (3 May 95)
-- don't assume that char is signed (problem on SGI)
-- Clear bit buffer when starting a stored block
-- no memcpy on Pyramid
-- suppressed inftest.c
-- optimized fill_window, put longest_match inline for gcc
-- optimized inflate on stored blocks.
-- untabify all sources to simplify patches
-
-Changes in 0.91 (2 May 95)
-- Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h
-- Document the memory requirements in zconf.h
-- added "make install"
-- fix sync search logic in inflateSync
-- deflate(Z_FULL_FLUSH) now works even if output buffer too short
-- after inflateSync, don't scare people with just "lo world"
-- added support for DJGPP
-
-Changes in 0.9 (1 May 95)
-- don't assume that zalloc clears the allocated memory (the TurboC bug
- was Mark's bug after all :)
-- let again gzread copy uncompressed data unchanged (was working in 0.71)
-- deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented
-- added a test of inflateSync in example.c
-- moved MAX_WBITS to zconf.h because users might want to change that.
-- document explicitly that zalloc(64K) on MSDOS must return a normalized
- pointer (zero offset)
-- added Makefiles for Microsoft C, Turbo C, Borland C++
-- faster crc32()
-
-Changes in 0.8 (29 April 95)
-- added fast inflate (inffast.c)
-- deflate(Z_FINISH) now returns Z_STREAM_END when done. Warning: this
- is incompatible with previous versions of zlib which returned Z_OK.
-- work around a TurboC compiler bug (bad code for b << 0, see infutil.h)
- (actually that was not a compiler bug, see 0.81 above)
-- gzread no longer reads one extra byte in certain cases
-- In gzio destroy(), don't reference a freed structure
-- avoid many warnings for MSDOS
-- avoid the ERROR symbol which is used by MS Windows
-
-Changes in 0.71 (14 April 95)
-- Fixed more MSDOS compilation problems :( There is still a bug with
- TurboC large model.
-
-Changes in 0.7 (14 April 95)
-- Added full inflate support.
-- Simplified the crc32() interface. The pre- and post-conditioning
- (one's complement) is now done inside crc32(). WARNING: this is
- incompatible with previous versions; see zlib.h for the new usage.
-
-Changes in 0.61 (12 April 95)
-- workaround for a bug in TurboC. example and minigzip now work on MSDOS.
-
-Changes in 0.6 (11 April 95)
-- added minigzip.c
-- added gzdopen to reopen a file descriptor as gzFile
-- added transparent reading of non-gziped files in gzread.
-- fixed bug in gzread (don't read crc as data)
-- fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose).
-- don't allocate big arrays in the stack (for MSDOS)
-- fix some MSDOS compilation problems
-
-Changes in 0.5:
-- do real compression in deflate.c. Z_PARTIAL_FLUSH is supported but
- not yet Z_FULL_FLUSH.
-- support decompression but only in a single step (forced Z_FINISH)
-- added opaque object for zalloc and zfree.
-- added deflateReset and inflateReset
-- added a variable zlib_version for consistency checking.
-- renamed the 'filter' parameter of deflateInit2 as 'strategy'.
- Added Z_FILTERED and Z_HUFFMAN_ONLY constants.
-
-Changes in 0.4:
-- avoid "zip" everywhere, use zlib instead of ziplib.
-- suppress Z_BLOCK_FLUSH, interpret Z_PARTIAL_FLUSH as block flush
- if compression method == 8.
-- added adler32 and crc32
-- renamed deflateOptions as deflateInit2, call one or the other but not both
-- added the method parameter for deflateInit2.
-- added inflateInit2
-- simplied considerably deflateInit and inflateInit by not supporting
- user-provided history buffer. This is supported only in deflateInit2
- and inflateInit2.
-
-Changes in 0.3:
-- prefix all macro names with Z_
-- use Z_FINISH instead of deflateEnd to finish compression.
-- added Z_HUFFMAN_ONLY
-- added gzerror()
diff --git a/source4/lib/zlib/FAQ b/source4/lib/zlib/FAQ
deleted file mode 100644
index 441d910daa..0000000000
--- a/source4/lib/zlib/FAQ
+++ /dev/null
@@ -1,339 +0,0 @@
-
- Frequently Asked Questions about zlib
-
-
-If your question is not there, please check the zlib home page
-http://www.zlib.org which may have more recent information.
-The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
-
-
- 1. Is zlib Y2K-compliant?
-
- Yes. zlib doesn't handle dates.
-
- 2. Where can I get a Windows DLL version?
-
- The zlib sources can be compiled without change to produce a DLL.
- See the file win32/DLL_FAQ.txt in the zlib distribution.
- Pointers to the precompiled DLL are found in the zlib web site at
- http://www.zlib.org.
-
- 3. Where can I get a Visual Basic interface to zlib?
-
- See
- * http://www.dogma.net/markn/articles/zlibtool/zlibtool.htm
- * contrib/visual-basic.txt in the zlib distribution
- * win32/DLL_FAQ.txt in the zlib distribution
-
- 4. compress() returns Z_BUF_ERROR.
-
- Make sure that before the call of compress, the length of the compressed
- buffer is equal to the total size of the compressed buffer and not
- zero. For Visual Basic, check that this parameter is passed by reference
- ("as any"), not by value ("as long").
-
- 5. deflate() or inflate() returns Z_BUF_ERROR.
-
- Before making the call, make sure that avail_in and avail_out are not
- zero. When setting the parameter flush equal to Z_FINISH, also make sure
- that avail_out is big enough to allow processing all pending input.
- Note that a Z_BUF_ERROR is not fatal--another call to deflate() or
- inflate() can be made with more input or output space. A Z_BUF_ERROR
- may in fact be unavoidable depending on how the functions are used, since
- it is not possible to tell whether or not there is more output pending
- when strm.avail_out returns with zero.
-
- 6. Where's the zlib documentation (man pages, etc.)?
-
- It's in zlib.h for the moment, and Francis S. Lin has converted it to a
- web page zlib.html. Volunteers to transform this to Unix-style man pages,
- please contact us (zlib@gzip.org). Examples of zlib usage are in the files
- example.c and minigzip.c.
-
- 7. Why don't you use GNU autoconf or libtool or ...?
-
- Because we would like to keep zlib as a very small and simple
- package. zlib is rather portable and doesn't need much configuration.
-
- 8. I found a bug in zlib.
-
- Most of the time, such problems are due to an incorrect usage of
- zlib. Please try to reproduce the problem with a small program and send
- the corresponding source to us at zlib@gzip.org . Do not send
- multi-megabyte data files without prior agreement.
-
- 9. Why do I get "undefined reference to gzputc"?
-
- If "make test" produces something like
-
- example.o(.text+0x154): undefined reference to `gzputc'
-
- check that you don't have old files libz.* in /usr/lib, /usr/local/lib or
- /usr/X11R6/lib. Remove any old versions, then do "make install".
-
-10. I need a Delphi interface to zlib.
-
- See the contrib/delphi directory in the zlib distribution.
-
-11. Can zlib handle .zip archives?
-
- Not by itself, no. See the directory contrib/minizip in the zlib
- distribution.
-
-12. Can zlib handle .Z files?
-
- No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt
- the code of uncompress on your own.
-
-13. How can I make a Unix shared library?
-
- make clean
- ./configure -s
- make
-
-14. How do I install a shared zlib library on Unix?
-
- After the above, then:
-
- make install
-
- However, many flavors of Unix come with a shared zlib already installed.
- Before going to the trouble of compiling a shared version of zlib and
- trying to install it, you may want to check if it's already there! If you
- can #include <zlib.h>, it's there. The -lz option will probably link to it.
-
-15. I have a question about OttoPDF.
-
- We are not the authors of OttoPDF. The real author is on the OttoPDF web
- site: Joel Hainley, jhainley@myndkryme.com.
-
-16. Can zlib decode Flate data in an Adobe PDF file?
-
- Yes. See http://www.fastio.com/ (ClibPDF), or http://www.pdflib.com/ .
- To modify PDF forms, see http://sourceforge.net/projects/acroformtool/ .
-
-17. Why am I getting this "register_frame_info not found" error on Solaris?
-
- After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib
- generates an error such as:
-
- ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so:
- symbol __register_frame_info: referenced symbol not found
-
- The symbol __register_frame_info is not part of zlib, it is generated by
- the C compiler (cc or gcc). You must recompile applications using zlib
- which have this problem. This problem is specific to Solaris. See
- http://www.sunfreeware.com for Solaris versions of zlib and applications
- using zlib.
-
-18. Why does gzip give an error on a file I make with compress/deflate?
-
- The compress and deflate functions produce data in the zlib format, which
- is different and incompatible with the gzip format. The gz* functions in
- zlib on the other hand use the gzip format. Both the zlib and gzip
- formats use the same compressed data format internally, but have different
- headers and trailers around the compressed data.
-
-19. Ok, so why are there two different formats?
-
- The gzip format was designed to retain the directory information about
- a single file, such as the name and last modification date. The zlib
- format on the other hand was designed for in-memory and communication
- channel applications, and has a much more compact header and trailer and
- uses a faster integrity check than gzip.
-
-20. Well that's nice, but how do I make a gzip file in memory?
-
- You can request that deflate write the gzip format instead of the zlib
- format using deflateInit2(). You can also request that inflate decode
- the gzip format using inflateInit2(). Read zlib.h for more details.
-
-21. Is zlib thread-safe?
-
- Yes. However any library routines that zlib uses and any application-
- provided memory allocation routines must also be thread-safe. zlib's gz*
- functions use stdio library routines, and most of zlib's functions use the
- library memory allocation routines by default. zlib's Init functions allow
- for the application to provide custom memory allocation routines.
-
- Of course, you should only operate on any given zlib or gzip stream from a
- single thread at a time.
-
-22. Can I use zlib in my commercial application?
-
- Yes. Please read the license in zlib.h.
-
-23. Is zlib under the GNU license?
-
- No. Please read the license in zlib.h.
-
-24. The license says that altered source versions must be "plainly marked". So
- what exactly do I need to do to meet that requirement?
-
- You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In
- particular, the final version number needs to be changed to "f", and an
- identification string should be appended to ZLIB_VERSION. Version numbers
- x.x.x.f are reserved for modifications to zlib by others than the zlib
- maintainers. For example, if the version of the base zlib you are altering
- is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and
- ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also
- update the version strings in deflate.c and inftrees.c.
-
- For altered source distributions, you should also note the origin and
- nature of the changes in zlib.h, as well as in ChangeLog and README, along
- with the dates of the alterations. The origin should include at least your
- name (or your company's name), and an email address to contact for help or
- issues with the library.
-
- Note that distributing a compiled zlib library along with zlib.h and
- zconf.h is also a source distribution, and so you should change
- ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes
- in zlib.h as you would for a full source distribution.
-
-25. Will zlib work on a big-endian or little-endian architecture, and can I
- exchange compressed data between them?
-
- Yes and yes.
-
-26. Will zlib work on a 64-bit machine?
-
- It should. It has been tested on 64-bit machines, and has no dependence
- on any data types being limited to 32-bits in length. If you have any
- difficulties, please provide a complete problem report to zlib@gzip.org
-
-27. Will zlib decompress data from the PKWare Data Compression Library?
-
- No. The PKWare DCL uses a completely different compressed data format
- than does PKZIP and zlib. However, you can look in zlib's contrib/blast
- directory for a possible solution to your problem.
-
-28. Can I access data randomly in a compressed stream?
-
- No, not without some preparation. If when compressing you periodically
- use Z_FULL_FLUSH, carefully write all the pending data at those points,
- and keep an index of those locations, then you can start decompression
- at those points. You have to be careful to not use Z_FULL_FLUSH too
- often, since it can significantly degrade compression.
-
-29. Does zlib work on MVS, OS/390, CICS, etc.?
-
- We don't know for sure. We have heard occasional reports of success on
- these systems. If you do use it on one of these, please provide us with
- a report, instructions, and patches that we can reference when we get
- these questions. Thanks.
-
-30. Is there some simpler, easier to read version of inflate I can look at
- to understand the deflate format?
-
- First off, you should read RFC 1951. Second, yes. Look in zlib's
- contrib/puff directory.
-
-31. Does zlib infringe on any patents?
-
- As far as we know, no. In fact, that was originally the whole point behind
- zlib. Look here for some more information:
-
- http://www.gzip.org/#faq11
-
-32. Can zlib work with greater than 4 GB of data?
-
- Yes. inflate() and deflate() will process any amount of data correctly.
- Each call of inflate() or deflate() is limited to input and output chunks
- of the maximum value that can be stored in the compiler's "unsigned int"
- type, but there is no limit to the number of chunks. Note however that the
- strm.total_in and strm_total_out counters may be limited to 4 GB. These
- counters are provided as a convenience and are not used internally by
- inflate() or deflate(). The application can easily set up its own counters
- updated after each call of inflate() or deflate() to count beyond 4 GB.
- compress() and uncompress() may be limited to 4 GB, since they operate in a
- single call. gzseek() and gztell() may be limited to 4 GB depending on how
- zlib is compiled. See the zlibCompileFlags() function in zlib.h.
-
- The word "may" appears several times above since there is a 4 GB limit
- only if the compiler's "long" type is 32 bits. If the compiler's "long"
- type is 64 bits, then the limit is 16 exabytes.
-
-33. Does zlib have any security vulnerabilities?
-
- The only one that we are aware of is potentially in gzprintf(). If zlib
- is compiled to use sprintf() or vsprintf(), then there is no protection
- against a buffer overflow of a 4K string space, other than the caller of
- gzprintf() assuring that the output will not exceed 4K. On the other
- hand, if zlib is compiled to use snprintf() or vsnprintf(), which should
- normally be the case, then there is no vulnerability. The ./configure
- script will display warnings if an insecure variation of sprintf() will
- be used by gzprintf(). Also the zlibCompileFlags() function will return
- information on what variant of sprintf() is used by gzprintf().
-
- If you don't have snprintf() or vsnprintf() and would like one, you can
- find a portable implementation here:
-
- http://www.ijs.si/software/snprintf/
-
- Note that you should be using the most recent version of zlib. Versions
- 1.1.3 and before were subject to a double-free vulnerability.
-
-34. Is there a Java version of zlib?
-
- Probably what you want is to use zlib in Java. zlib is already included
- as part of the Java SDK in the java.util.zip package. If you really want
- a version of zlib written in the Java language, look on the zlib home
- page for links: http://www.zlib.org/
-
-35. I get this or that compiler or source-code scanner warning when I crank it
- up to maximally-pedantic. Can't you guys write proper code?
-
- Many years ago, we gave up attempting to avoid warnings on every compiler
- in the universe. It just got to be a waste of time, and some compilers
- were downright silly. So now, we simply make sure that the code always
- works.
-
-36. Valgrind (or some similar memory access checker) says that deflate is
- performing a conditional jump that depends on an uninitialized value.
- Isn't that a bug?
-
- No. That is intentional for performance reasons, and the output of
- deflate is not affected. This only started showing up recently since
- zlib 1.2.x uses malloc() by default for allocations, whereas earlier
- versions used calloc(), which zeros out the allocated memory.
-
-37. Will zlib read the (insert any ancient or arcane format here) compressed
- data format?
-
- Probably not. Look in the comp.compression FAQ for pointers to various
- formats and associated software.
-
-38. How can I encrypt/decrypt zip files with zlib?
-
- zlib doesn't support encryption. The original PKZIP encryption is very weak
- and can be broken with freely available programs. To get strong encryption,
- use GnuPG, http://www.gnupg.org/ , which already includes zlib compression.
- For PKZIP compatible "encryption", look at http://www.info-zip.org/
-
-39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
-
- "gzip" is the gzip format, and "deflate" is the zlib format. They should
- probably have called the second one "zlib" instead to avoid confusion
- with the raw deflate compressed data format. While the HTTP 1.1 RFC 2616
- correctly points to the zlib specification in RFC 1950 for the "deflate"
- transfer encoding, there have been reports of servers and browsers that
- incorrectly produce or expect raw deflate data per the deflate
- specficiation in RFC 1951, most notably Microsoft. So even though the
- "deflate" transfer encoding using the zlib format would be the more
- efficient approach (and in fact exactly what the zlib format was designed
- for), using the "gzip" transfer encoding is probably more reliable due to
- an unfortunate choice of name on the part of the HTTP 1.1 authors.
-
- Bottom line: use the gzip format for HTTP 1.1 encoding.
-
-40. Does zlib support the new "Deflate64" format introduced by PKWare?
-
- No. PKWare has apparently decided to keep that format proprietary, since
- they have not documented it as they have previous compression formats.
- In any case, the compression improvements are so modest compared to other
- more modern approaches, that it's not worth the effort to implement.
-
-41. Can you please sign these lengthy legal documents and fax them back to us
- so that we can use your software in our product?
-
- No. Go away. Shoo.
diff --git a/source4/lib/zlib/INDEX b/source4/lib/zlib/INDEX
deleted file mode 100644
index 0587e5902b..0000000000
--- a/source4/lib/zlib/INDEX
+++ /dev/null
@@ -1,51 +0,0 @@
-ChangeLog history of changes
-FAQ Frequently Asked Questions about zlib
-INDEX this file
-Makefile makefile for Unix (generated by configure)
-Makefile.in makefile for Unix (template for configure)
-README guess what
-algorithm.txt description of the (de)compression algorithm
-configure configure script for Unix
-zconf.in.h template for zconf.h (used by configure)
-
-amiga/ makefiles for Amiga SAS C
-as400/ makefiles for IBM AS/400
-msdos/ makefiles for MSDOS
-old/ makefiles for various architectures and zlib documentation
- files that have not yet been updated for zlib 1.2.x
-projects/ projects for various Integrated Development Environments
-qnx/ makefiles for QNX
-win32/ makefiles for Windows
-
- zlib public header files (must be kept):
-zconf.h
-zlib.h
-
- private source files used to build the zlib library:
-adler32.c
-compress.c
-crc32.c
-crc32.h
-deflate.c
-deflate.h
-gzio.c
-infback.c
-inffast.c
-inffast.h
-inffixed.h
-inflate.c
-inflate.h
-inftrees.c
-inftrees.h
-trees.c
-trees.h
-uncompr.c
-zutil.c
-zutil.h
-
- source files for sample programs:
-example.c
-minigzip.c
-
- unsupported contribution by third parties
-See contrib/README.contrib
diff --git a/source4/lib/zlib/Makefile b/source4/lib/zlib/Makefile
deleted file mode 100644
index 2fd6e45c48..0000000000
--- a/source4/lib/zlib/Makefile
+++ /dev/null
@@ -1,154 +0,0 @@
-# Makefile for zlib
-# Copyright (C) 1995-2005 Jean-loup Gailly.
-# For conditions of distribution and use, see copyright notice in zlib.h
-
-# To compile and test, type:
-# ./configure; make test
-# The call of configure is optional if you don't have special requirements
-# If you wish to build zlib as a shared library, use: ./configure -s
-
-# To use the asm code, type:
-# cp contrib/asm?86/match.S ./match.S
-# make LOC=-DASMV OBJA=match.o
-
-# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
-# make install
-# To install in $HOME instead of /usr/local, use:
-# make install prefix=$HOME
-
-CC=cc
-
-CFLAGS=-O
-#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
-#CFLAGS=-g -DDEBUG
-#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
-# -Wstrict-prototypes -Wmissing-prototypes
-
-LDFLAGS=libz.a
-LDSHARED=$(CC)
-CPP=$(CC) -E
-
-LIBS=libz.a
-SHAREDLIB=libz.so
-SHAREDLIBV=libz.so.1.2.3
-SHAREDLIBM=libz.so.1
-
-AR=ar rc
-RANLIB=ranlib
-TAR=tar
-SHELL=/bin/sh
-EXE=
-
-prefix = /usr/local
-exec_prefix = ${prefix}
-libdir = ${exec_prefix}/lib
-includedir = ${prefix}/include
-mandir = ${prefix}/share/man
-man3dir = ${mandir}/man3
-
-OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
- zutil.o inflate.o infback.o inftrees.o inffast.o
-
-OBJA =
-# to use the asm code: make OBJA=match.o
-
-TEST_OBJS = example.o minigzip.o
-
-all: example$(EXE) minigzip$(EXE)
-
-check: test
-test: all
- @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
- echo hello world | ./minigzip | ./minigzip -d || \
- echo ' *** minigzip test FAILED ***' ; \
- if ./example; then \
- echo ' *** zlib test OK ***'; \
- else \
- echo ' *** zlib test FAILED ***'; \
- fi
-
-libz.a: $(OBJS) $(OBJA)
- $(AR) $@ $(OBJS) $(OBJA)
- -@ ($(RANLIB) $@ || true) >/dev/null 2>&1
-
-match.o: match.S
- $(CPP) match.S > _match.s
- $(CC) -c _match.s
- mv _match.o match.o
- rm -f _match.s
-
-$(SHAREDLIBV): $(OBJS)
- $(LDSHARED) -o $@ $(OBJS)
- rm -f $(SHAREDLIB) $(SHAREDLIBM)
- ln -s $@ $(SHAREDLIB)
- ln -s $@ $(SHAREDLIBM)
-
-example$(EXE): example.o $(LIBS)
- $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
-
-minigzip$(EXE): minigzip.o $(LIBS)
- $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
-
-install: $(LIBS)
- -@if [ ! -d $(exec_prefix) ]; then mkdir -p $(exec_prefix); fi
- -@if [ ! -d $(includedir) ]; then mkdir -p $(includedir); fi
- -@if [ ! -d $(libdir) ]; then mkdir -p $(libdir); fi
- -@if [ ! -d $(man3dir) ]; then mkdir -p $(man3dir); fi
- cp zlib.h zconf.h $(includedir)
- chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h
- cp $(LIBS) $(libdir)
- cd $(libdir); chmod 755 $(LIBS)
- -@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
- cd $(libdir); if test -f $(SHAREDLIBV); then \
- rm -f $(SHAREDLIB) $(SHAREDLIBM); \
- ln -s $(SHAREDLIBV) $(SHAREDLIB); \
- ln -s $(SHAREDLIBV) $(SHAREDLIBM); \
- (ldconfig || true) >/dev/null 2>&1; \
- fi
- cp zlib.3 $(man3dir)
- chmod 644 $(man3dir)/zlib.3
-# The ranlib in install is needed on NeXTSTEP which checks file times
-# ldconfig is for Linux
-
-uninstall:
- cd $(includedir); \
- cd $(libdir); rm -f libz.a; \
- if test -f $(SHAREDLIBV); then \
- rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
- fi
- cd $(man3dir); rm -f zlib.3
-
-mostlyclean: clean
-clean:
- rm -f *.o *~ example$(EXE) minigzip$(EXE) \
- libz.* foo.gz so_locations \
- _match.s maketree contrib/infback9/*.o
-
-maintainer-clean: distclean
-distclean: clean
- cp -p Makefile.in Makefile
- cp -p zconf.in.h zconf.h
- rm -f .DS_Store
-
-tags:
- etags *.[ch]
-
-depend:
- makedepend -- $(CFLAGS) -- *.[ch]
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-adler32.o: zlib.h zconf.h
-compress.o: zlib.h zconf.h
-crc32.o: crc32.h zlib.h zconf.h
-deflate.o: deflate.h zutil.h zlib.h zconf.h
-example.o: zlib.h zconf.h
-gzio.o: zutil.h zlib.h zconf.h
-inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
-inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
-infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
-inftrees.o: zutil.h zlib.h zconf.h inftrees.h
-minigzip.o: zlib.h zconf.h
-trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
-uncompr.o: zlib.h zconf.h
-zutil.o: zutil.h zlib.h zconf.h
diff --git a/source4/lib/zlib/Makefile.in b/source4/lib/zlib/Makefile.in
deleted file mode 100644
index 2fd6e45c48..0000000000
--- a/source4/lib/zlib/Makefile.in
+++ /dev/null
@@ -1,154 +0,0 @@
-# Makefile for zlib
-# Copyright (C) 1995-2005 Jean-loup Gailly.
-# For conditions of distribution and use, see copyright notice in zlib.h
-
-# To compile and test, type:
-# ./configure; make test
-# The call of configure is optional if you don't have special requirements
-# If you wish to build zlib as a shared library, use: ./configure -s
-
-# To use the asm code, type:
-# cp contrib/asm?86/match.S ./match.S
-# make LOC=-DASMV OBJA=match.o
-
-# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
-# make install
-# To install in $HOME instead of /usr/local, use:
-# make install prefix=$HOME
-
-CC=cc
-
-CFLAGS=-O
-#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
-#CFLAGS=-g -DDEBUG
-#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
-# -Wstrict-prototypes -Wmissing-prototypes
-
-LDFLAGS=libz.a
-LDSHARED=$(CC)
-CPP=$(CC) -E
-
-LIBS=libz.a
-SHAREDLIB=libz.so
-SHAREDLIBV=libz.so.1.2.3
-SHAREDLIBM=libz.so.1
-
-AR=ar rc
-RANLIB=ranlib
-TAR=tar
-SHELL=/bin/sh
-EXE=
-
-prefix = /usr/local
-exec_prefix = ${prefix}
-libdir = ${exec_prefix}/lib
-includedir = ${prefix}/include
-mandir = ${prefix}/share/man
-man3dir = ${mandir}/man3
-
-OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
- zutil.o inflate.o infback.o inftrees.o inffast.o
-
-OBJA =
-# to use the asm code: make OBJA=match.o
-
-TEST_OBJS = example.o minigzip.o
-
-all: example$(EXE) minigzip$(EXE)
-
-check: test
-test: all
- @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
- echo hello world | ./minigzip | ./minigzip -d || \
- echo ' *** minigzip test FAILED ***' ; \
- if ./example; then \
- echo ' *** zlib test OK ***'; \
- else \
- echo ' *** zlib test FAILED ***'; \
- fi
-
-libz.a: $(OBJS) $(OBJA)
- $(AR) $@ $(OBJS) $(OBJA)
- -@ ($(RANLIB) $@ || true) >/dev/null 2>&1
-
-match.o: match.S
- $(CPP) match.S > _match.s
- $(CC) -c _match.s
- mv _match.o match.o
- rm -f _match.s
-
-$(SHAREDLIBV): $(OBJS)
- $(LDSHARED) -o $@ $(OBJS)
- rm -f $(SHAREDLIB) $(SHAREDLIBM)
- ln -s $@ $(SHAREDLIB)
- ln -s $@ $(SHAREDLIBM)
-
-example$(EXE): example.o $(LIBS)
- $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
-
-minigzip$(EXE): minigzip.o $(LIBS)
- $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
-
-install: $(LIBS)
- -@if [ ! -d $(exec_prefix) ]; then mkdir -p $(exec_prefix); fi
- -@if [ ! -d $(includedir) ]; then mkdir -p $(includedir); fi
- -@if [ ! -d $(libdir) ]; then mkdir -p $(libdir); fi
- -@if [ ! -d $(man3dir) ]; then mkdir -p $(man3dir); fi
- cp zlib.h zconf.h $(includedir)
- chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h
- cp $(LIBS) $(libdir)
- cd $(libdir); chmod 755 $(LIBS)
- -@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
- cd $(libdir); if test -f $(SHAREDLIBV); then \
- rm -f $(SHAREDLIB) $(SHAREDLIBM); \
- ln -s $(SHAREDLIBV) $(SHAREDLIB); \
- ln -s $(SHAREDLIBV) $(SHAREDLIBM); \
- (ldconfig || true) >/dev/null 2>&1; \
- fi
- cp zlib.3 $(man3dir)
- chmod 644 $(man3dir)/zlib.3
-# The ranlib in install is needed on NeXTSTEP which checks file times
-# ldconfig is for Linux
-
-uninstall:
- cd $(includedir); \
- cd $(libdir); rm -f libz.a; \
- if test -f $(SHAREDLIBV); then \
- rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
- fi
- cd $(man3dir); rm -f zlib.3
-
-mostlyclean: clean
-clean:
- rm -f *.o *~ example$(EXE) minigzip$(EXE) \
- libz.* foo.gz so_locations \
- _match.s maketree contrib/infback9/*.o
-
-maintainer-clean: distclean
-distclean: clean
- cp -p Makefile.in Makefile
- cp -p zconf.in.h zconf.h
- rm -f .DS_Store
-
-tags:
- etags *.[ch]
-
-depend:
- makedepend -- $(CFLAGS) -- *.[ch]
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-adler32.o: zlib.h zconf.h
-compress.o: zlib.h zconf.h
-crc32.o: crc32.h zlib.h zconf.h
-deflate.o: deflate.h zutil.h zlib.h zconf.h
-example.o: zlib.h zconf.h
-gzio.o: zutil.h zlib.h zconf.h
-inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
-inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
-infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
-inftrees.o: zutil.h zlib.h zconf.h inftrees.h
-minigzip.o: zlib.h zconf.h
-trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
-uncompr.o: zlib.h zconf.h
-zutil.o: zutil.h zlib.h zconf.h
diff --git a/source4/lib/zlib/README b/source4/lib/zlib/README
deleted file mode 100644
index 758cc50020..0000000000
--- a/source4/lib/zlib/README
+++ /dev/null
@@ -1,125 +0,0 @@
-ZLIB DATA COMPRESSION LIBRARY
-
-zlib 1.2.3 is a general purpose data compression library. All the code is
-thread safe. The data format used by the zlib library is described by RFCs
-(Request for Comments) 1950 to 1952 in the files
-http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
-and rfc1952.txt (gzip format). These documents are also available in other
-formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
-
-All functions of the compression library are documented in the file zlib.h
-(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
-of the library is given in the file example.c which also tests that the library
-is working correctly. Another example is given in the file minigzip.c. The
-compression library itself is composed of all source files except example.c and
-minigzip.c.
-
-To compile all files and run the test program, follow the instructions given at
-the top of Makefile. In short "make test; make install" should work for most
-machines. For Unix: "./configure; make test; make install". For MSDOS, use one
-of the special makefiles such as Makefile.msc. For VMS, use make_vms.com.
-
-Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
-<info@winimage.com> for the Windows DLL version. The zlib home page is
-http://www.zlib.org or http://www.gzip.org/zlib/ Before reporting a problem,
-please check this site to verify that you have the latest version of zlib;
-otherwise get the latest version and check whether the problem still exists or
-not.
-
-PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html before asking
-for help.
-
-Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
-issue of Dr. Dobb's Journal; a copy of the article is available in
-http://dogma.net/markn/articles/zlibtool/zlibtool.htm
-
-The changes made in version 1.2.3 are documented in the file ChangeLog.
-
-Unsupported third party contributions are provided in directory "contrib".
-
-A Java implementation of zlib is available in the Java Development Kit
-http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/package-summary.html
-See the zlib home page http://www.zlib.org for details.
-
-A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is in the
-CPAN (Comprehensive Perl Archive Network) sites
-http://www.cpan.org/modules/by-module/Compress/
-
-A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
-available in Python 1.5 and later versions, see
-http://www.python.org/doc/lib/module-zlib.html
-
-A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com> is
-availlable at http://www.oche.de/~akupries/soft/trf/trf_zip.html
-
-An experimental package to read and write files in .zip format, written on top
-of zlib by Gilles Vollant <info@winimage.com>, is available in the
-contrib/minizip directory of zlib.
-
-
-Notes for some targets:
-
-- For Windows DLL versions, please see win32/DLL_FAQ.txt
-
-- For 64-bit Irix, deflate.c must be compiled without any optimization. With
- -O, one libpng test fails. The test works in 32 bit mode (with the -n32
- compiler flag). The compiler bug has been reported to SGI.
-
-- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
- when compiled with cc.
-
-- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is
- necessary to get gzprintf working correctly. This is done by configure.
-
-- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
- other compilers. Use "make test" to check your compiler.
-
-- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
-
-- For PalmOs, see http://palmzlib.sourceforge.net/
-
-- When building a shared, i.e. dynamic library on Mac OS X, the library must be
- installed before testing (do "make install" before "make test"), since the
- library location is specified in the library.
-
-
-Acknowledgments:
-
- The deflate format used by zlib was defined by Phil Katz. The deflate
- and zlib specifications were written by L. Peter Deutsch. Thanks to all the
- people who reported problems and suggested various improvements in zlib;
- they are too numerous to cite here.
-
-Copyright notice:
-
- (C) 1995-2004 Jean-loup Gailly and Mark Adler
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Jean-loup Gailly Mark Adler
- jloup@gzip.org madler@alumni.caltech.edu
-
-If you use the zlib library in a product, we would appreciate *not*
-receiving lengthy legal documents to sign. The sources are provided
-for free but without warranty of any kind. The library has been
-entirely written by Jean-loup Gailly and Mark Adler; it does not
-include third-party code.
-
-If you redistribute modified sources, we would appreciate that you include
-in the file ChangeLog history information documenting your changes. Please
-read the FAQ for more information on the distribution of modified source
-versions.
diff --git a/source4/lib/zlib/adler32.c b/source4/lib/zlib/adler32.c
deleted file mode 100644
index b5333d7b8e..0000000000
--- a/source4/lib/zlib/adler32.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/* adler32.c -- compute the Adler-32 checksum of a data stream
- * Copyright (C) 1995-2004 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#include "zutil.h"
-
-#define BASE 65521UL /* largest prime smaller than 65536 */
-#define NMAX 5552
-/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
-
-#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
-#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
-#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
-#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
-#define DO16(buf) DO8(buf,0); DO8(buf,8);
-
-/* use NO_DIVIDE if your processor does not do division in hardware */
-#ifdef NO_DIVIDE
-# define MOD(a) \
- do { \
- if (a >= (BASE << 16)) a -= (BASE << 16); \
- if (a >= (BASE << 15)) a -= (BASE << 15); \
- if (a >= (BASE << 14)) a -= (BASE << 14); \
- if (a >= (BASE << 13)) a -= (BASE << 13); \
- if (a >= (BASE << 12)) a -= (BASE << 12); \
- if (a >= (BASE << 11)) a -= (BASE << 11); \
- if (a >= (BASE << 10)) a -= (BASE << 10); \
- if (a >= (BASE << 9)) a -= (BASE << 9); \
- if (a >= (BASE << 8)) a -= (BASE << 8); \
- if (a >= (BASE << 7)) a -= (BASE << 7); \
- if (a >= (BASE << 6)) a -= (BASE << 6); \
- if (a >= (BASE << 5)) a -= (BASE << 5); \
- if (a >= (BASE << 4)) a -= (BASE << 4); \
- if (a >= (BASE << 3)) a -= (BASE << 3); \
- if (a >= (BASE << 2)) a -= (BASE << 2); \
- if (a >= (BASE << 1)) a -= (BASE << 1); \
- if (a >= BASE) a -= BASE; \
- } while (0)
-# define MOD4(a) \
- do { \
- if (a >= (BASE << 4)) a -= (BASE << 4); \
- if (a >= (BASE << 3)) a -= (BASE << 3); \
- if (a >= (BASE << 2)) a -= (BASE << 2); \
- if (a >= (BASE << 1)) a -= (BASE << 1); \
- if (a >= BASE) a -= BASE; \
- } while (0)
-#else
-# define MOD(a) a %= BASE
-# define MOD4(a) a %= BASE
-#endif
-
-/* ========================================================================= */
-uLong ZEXPORT adler32(adler, buf, len)
- uLong adler;
- const Bytef *buf;
- uInt len;
-{
- unsigned long sum2;
- unsigned n;
-
- /* split Adler-32 into component sums */
- sum2 = (adler >> 16) & 0xffff;
- adler &= 0xffff;
-
- /* in case user likes doing a byte at a time, keep it fast */
- if (len == 1) {
- adler += buf[0];
- if (adler >= BASE)
- adler -= BASE;
- sum2 += adler;
- if (sum2 >= BASE)
- sum2 -= BASE;
- return adler | (sum2 << 16);
- }
-
- /* initial Adler-32 value (deferred check for len == 1 speed) */
- if (buf == Z_NULL)
- return 1L;
-
- /* in case short lengths are provided, keep it somewhat fast */
- if (len < 16) {
- while (len--) {
- adler += *buf++;
- sum2 += adler;
- }
- if (adler >= BASE)
- adler -= BASE;
- MOD4(sum2); /* only added so many BASE's */
- return adler | (sum2 << 16);
- }
-
- /* do length NMAX blocks -- requires just one modulo operation */
- while (len >= NMAX) {
- len -= NMAX;
- n = NMAX / 16; /* NMAX is divisible by 16 */
- do {
- DO16(buf); /* 16 sums unrolled */
- buf += 16;
- } while (--n);
- MOD(adler);
- MOD(sum2);
- }
-
- /* do remaining bytes (less than NMAX, still just one modulo) */
- if (len) { /* avoid modulos if none remaining */
- while (len >= 16) {
- len -= 16;
- DO16(buf);
- buf += 16;
- }
- while (len--) {
- adler += *buf++;
- sum2 += adler;
- }
- MOD(adler);
- MOD(sum2);
- }
-
- /* return recombined sums */
- return adler | (sum2 << 16);
-}
-
-/* ========================================================================= */
-uLong ZEXPORT adler32_combine(adler1, adler2, len2)
- uLong adler1;
- uLong adler2;
- z_off_t len2;
-{
- unsigned long sum1;
- unsigned long sum2;
- unsigned rem;
-
- /* the derivation of this formula is left as an exercise for the reader */
- rem = (unsigned)(len2 % BASE);
- sum1 = adler1 & 0xffff;
- sum2 = rem * sum1;
- MOD(sum2);
- sum1 += (adler2 & 0xffff) + BASE - 1;
- sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
- if (sum1 > BASE) sum1 -= BASE;
- if (sum1 > BASE) sum1 -= BASE;
- if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
- if (sum2 > BASE) sum2 -= BASE;
- return sum1 | (sum2 << 16);
-}
diff --git a/source4/lib/zlib/algorithm.txt b/source4/lib/zlib/algorithm.txt
deleted file mode 100644
index b022dde312..0000000000
--- a/source4/lib/zlib/algorithm.txt
+++ /dev/null
@@ -1,209 +0,0 @@
-1. Compression algorithm (deflate)
-
-The deflation algorithm used by gzip (also zip and zlib) is a variation of
-LZ77 (Lempel-Ziv 1977, see reference below). It finds duplicated strings in
-the input data. The second occurrence of a string is replaced by a
-pointer to the previous string, in the form of a pair (distance,
-length). Distances are limited to 32K bytes, and lengths are limited
-to 258 bytes. When a string does not occur anywhere in the previous
-32K bytes, it is emitted as a sequence of literal bytes. (In this
-description, `string' must be taken as an arbitrary sequence of bytes,
-and is not restricted to printable characters.)
-
-Literals or match lengths are compressed with one Huffman tree, and
-match distances are compressed with another tree. The trees are stored
-in a compact form at the start of each block. The blocks can have any
-size (except that the compressed data for one block must fit in
-available memory). A block is terminated when deflate() determines that
-it would be useful to start another block with fresh trees. (This is
-somewhat similar to the behavior of LZW-based _compress_.)
-
-Duplicated strings are found using a hash table. All input strings of
-length 3 are inserted in the hash table. A hash index is computed for
-the next 3 bytes. If the hash chain for this index is not empty, all
-strings in the chain are compared with the current input string, and
-the longest match is selected.
-
-The hash chains are searched starting with the most recent strings, to
-favor small distances and thus take advantage of the Huffman encoding.
-The hash chains are singly linked. There are no deletions from the
-hash chains, the algorithm simply discards matches that are too old.
-
-To avoid a worst-case situation, very long hash chains are arbitrarily
-truncated at a certain length, determined by a runtime option (level
-parameter of deflateInit). So deflate() does not always find the longest
-possible match but generally finds a match which is long enough.
-
-deflate() also defers the selection of matches with a lazy evaluation
-mechanism. After a match of length N has been found, deflate() searches for
-a longer match at the next input byte. If a longer match is found, the
-previous match is truncated to a length of one (thus producing a single
-literal byte) and the process of lazy evaluation begins again. Otherwise,
-the original match is kept, and the next match search is attempted only N
-steps later.
-
-The lazy match evaluation is also subject to a runtime parameter. If
-the current match is long enough, deflate() reduces the search for a longer
-match, thus speeding up the whole process. If compression ratio is more
-important than speed, deflate() attempts a complete second search even if
-the first match is already long enough.
-
-The lazy match evaluation is not performed for the fastest compression
-modes (level parameter 1 to 3). For these fast modes, new strings
-are inserted in the hash table only when no match was found, or
-when the match is not too long. This degrades the compression ratio
-but saves time since there are both fewer insertions and fewer searches.
-
-
-2. Decompression algorithm (inflate)
-
-2.1 Introduction
-
-The key question is how to represent a Huffman code (or any prefix code) so
-that you can decode fast. The most important characteristic is that shorter
-codes are much more common than longer codes, so pay attention to decoding the
-short codes fast, and let the long codes take longer to decode.
-
-inflate() sets up a first level table that covers some number of bits of
-input less than the length of longest code. It gets that many bits from the
-stream, and looks it up in the table. The table will tell if the next
-code is that many bits or less and how many, and if it is, it will tell
-the value, else it will point to the next level table for which inflate()
-grabs more bits and tries to decode a longer code.
-
-How many bits to make the first lookup is a tradeoff between the time it
-takes to decode and the time it takes to build the table. If building the
-table took no time (and if you had infinite memory), then there would only
-be a first level table to cover all the way to the longest code. However,
-building the table ends up taking a lot longer for more bits since short
-codes are replicated many times in such a table. What inflate() does is
-simply to make the number of bits in the first table a variable, and then
-to set that variable for the maximum speed.
-
-For inflate, which has 286 possible codes for the literal/length tree, the size
-of the first table is nine bits. Also the distance trees have 30 possible
-values, and the size of the first table is six bits. Note that for each of
-those cases, the table ended up one bit longer than the ``average'' code
-length, i.e. the code length of an approximately flat code which would be a
-little more than eight bits for 286 symbols and a little less than five bits
-for 30 symbols.
-
-
-2.2 More details on the inflate table lookup
-
-Ok, you want to know what this cleverly obfuscated inflate tree actually
-looks like. You are correct that it's not a Huffman tree. It is simply a
-lookup table for the first, let's say, nine bits of a Huffman symbol. The
-symbol could be as short as one bit or as long as 15 bits. If a particular
-symbol is shorter than nine bits, then that symbol's translation is duplicated
-in all those entries that start with that symbol's bits. For example, if the
-symbol is four bits, then it's duplicated 32 times in a nine-bit table. If a
-symbol is nine bits long, it appears in the table once.
-
-If the symbol is longer than nine bits, then that entry in the table points
-to another similar table for the remaining bits. Again, there are duplicated
-entries as needed. The idea is that most of the time the symbol will be short
-and there will only be one table look up. (That's whole idea behind data
-compression in the first place.) For the less frequent long symbols, there
-will be two lookups. If you had a compression method with really long
-symbols, you could have as many levels of lookups as is efficient. For
-inflate, two is enough.
-
-So a table entry either points to another table (in which case nine bits in
-the above example are gobbled), or it contains the translation for the symbol
-and the number of bits to gobble. Then you start again with the next
-ungobbled bit.
-
-You may wonder: why not just have one lookup table for how ever many bits the
-longest symbol is? The reason is that if you do that, you end up spending
-more time filling in duplicate symbol entries than you do actually decoding.
-At least for deflate's output that generates new trees every several 10's of
-kbytes. You can imagine that filling in a 2^15 entry table for a 15-bit code
-would take too long if you're only decoding several thousand symbols. At the
-other extreme, you could make a new table for every bit in the code. In fact,
-that's essentially a Huffman tree. But then you spend two much time
-traversing the tree while decoding, even for short symbols.
-
-So the number of bits for the first lookup table is a trade of the time to
-fill out the table vs. the time spent looking at the second level and above of
-the table.
-
-Here is an example, scaled down:
-
-The code being decoded, with 10 symbols, from 1 to 6 bits long:
-
-A: 0
-B: 10
-C: 1100
-D: 11010
-E: 11011
-F: 11100
-G: 11101
-H: 11110
-I: 111110
-J: 111111
-
-Let's make the first table three bits long (eight entries):
-
-000: A,1
-001: A,1
-010: A,1
-011: A,1
-100: B,2
-101: B,2
-110: -> table X (gobble 3 bits)
-111: -> table Y (gobble 3 bits)
-
-Each entry is what the bits decode as and how many bits that is, i.e. how
-many bits to gobble. Or the entry points to another table, with the number of
-bits to gobble implicit in the size of the table.
-
-Table X is two bits long since the longest code starting with 110 is five bits
-long:
-
-00: C,1
-01: C,1
-10: D,2
-11: E,2
-
-Table Y is three bits long since the longest code starting with 111 is six
-bits long:
-
-000: F,2
-001: F,2
-010: G,2
-011: G,2
-100: H,2
-101: H,2
-110: I,3
-111: J,3
-
-So what we have here are three tables with a total of 20 entries that had to
-be constructed. That's compared to 64 entries for a single table. Or
-compared to 16 entries for a Huffman tree (six two entry tables and one four
-entry table). Assuming that the code ideally represents the probability of
-the symbols, it takes on the average 1.25 lookups per symbol. That's compared
-to one lookup for the single table, or 1.66 lookups per symbol for the
-Huffman tree.
-
-There, I think that gives you a picture of what's going on. For inflate, the
-meaning of a particular symbol is often more than just a letter. It can be a
-byte (a "literal"), or it can be either a length or a distance which
-indicates a base value and a number of bits to fetch after the code that is
-added to the base value. Or it might be the special end-of-block code. The
-data structures created in inftrees.c try to encode all that information
-compactly in the tables.
-
-
-Jean-loup Gailly Mark Adler
-jloup@gzip.org madler@alumni.caltech.edu
-
-
-References:
-
-[LZ77] Ziv J., Lempel A., ``A Universal Algorithm for Sequential Data
-Compression,'' IEEE Transactions on Information Theory, Vol. 23, No. 3,
-pp. 337-343.
-
-``DEFLATE Compressed Data Format Specification'' available in
-http://www.ietf.org/rfc/rfc1951.txt
diff --git a/source4/lib/zlib/amiga/Makefile.pup b/source4/lib/zlib/amiga/Makefile.pup
deleted file mode 100644
index 3f7e15537f..0000000000
--- a/source4/lib/zlib/amiga/Makefile.pup
+++ /dev/null
@@ -1,66 +0,0 @@
-# Amiga powerUP (TM) Makefile
-# makefile for libpng and SAS C V6.58/7.00 PPC compiler
-# Copyright (C) 1998 by Andreas R. Kleinert
-
-LIBNAME = libzip.a
-
-CC = scppc
-CFLAGS = NOSTKCHK NOSINT OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL \
- OPTLOOP OPTRDEP=8 OPTDEP=8 OPTCOMP=8 NOVER
-AR = ppc-amigaos-ar cr
-RANLIB = ppc-amigaos-ranlib
-LD = ppc-amigaos-ld -r
-LDFLAGS = -o
-LDLIBS = LIB:scppc.a LIB:end.o
-RM = delete quiet
-
-OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
- zutil.o inflate.o infback.o inftrees.o inffast.o
-
-TEST_OBJS = example.o minigzip.o
-
-all: example minigzip
-
-check: test
-test: all
- example
- echo hello world | minigzip | minigzip -d
-
-$(LIBNAME): $(OBJS)
- $(AR) $@ $(OBJS)
- -$(RANLIB) $@
-
-example: example.o $(LIBNAME)
- $(LD) $(LDFLAGS) $@ LIB:c_ppc.o $@.o $(LIBNAME) $(LDLIBS)
-
-minigzip: minigzip.o $(LIBNAME)
- $(LD) $(LDFLAGS) $@ LIB:c_ppc.o $@.o $(LIBNAME) $(LDLIBS)
-
-mostlyclean: clean
-clean:
- $(RM) *.o example minigzip $(LIBNAME) foo.gz
-
-zip:
- zip -ul9 zlib README ChangeLog Makefile Make????.??? Makefile.?? \
- descrip.mms *.[ch]
-
-tgz:
- cd ..; tar cfz zlib/zlib.tgz zlib/README zlib/ChangeLog zlib/Makefile \
- zlib/Make????.??? zlib/Makefile.?? zlib/descrip.mms zlib/*.[ch]
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-adler32.o: zlib.h zconf.h
-compress.o: zlib.h zconf.h
-crc32.o: crc32.h zlib.h zconf.h
-deflate.o: deflate.h zutil.h zlib.h zconf.h
-example.o: zlib.h zconf.h
-gzio.o: zutil.h zlib.h zconf.h
-inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
-inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
-infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
-inftrees.o: zutil.h zlib.h zconf.h inftrees.h
-minigzip.o: zlib.h zconf.h
-trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
-uncompr.o: zlib.h zconf.h
-zutil.o: zutil.h zlib.h zconf.h
diff --git a/source4/lib/zlib/amiga/Makefile.sas b/source4/lib/zlib/amiga/Makefile.sas
deleted file mode 100644
index 296ef48a22..0000000000
--- a/source4/lib/zlib/amiga/Makefile.sas
+++ /dev/null
@@ -1,65 +0,0 @@
-# SMakefile for zlib
-# Modified from the standard UNIX Makefile Copyright Jean-loup Gailly
-# Osma Ahvenlampi <Osma.Ahvenlampi@hut.fi>
-# Amiga, SAS/C 6.56 & Smake
-
-CC=sc
-CFLAGS=OPT
-#CFLAGS=OPT CPU=68030
-#CFLAGS=DEBUG=LINE
-LDFLAGS=LIB z.lib
-
-SCOPTIONS=OPTSCHED OPTINLINE OPTALIAS OPTTIME OPTINLOCAL STRMERGE \
- NOICONS PARMS=BOTH NOSTACKCHECK UTILLIB NOVERSION ERRORREXX \
- DEF=POSTINC
-
-OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
- zutil.o inflate.o infback.o inftrees.o inffast.o
-
-TEST_OBJS = example.o minigzip.o
-
-all: SCOPTIONS example minigzip
-
-check: test
-test: all
- example
- echo hello world | minigzip | minigzip -d
-
-install: z.lib
- copy clone zlib.h zconf.h INCLUDE:
- copy clone z.lib LIB:
-
-z.lib: $(OBJS)
- oml z.lib r $(OBJS)
-
-example: example.o z.lib
- $(CC) $(CFLAGS) LINK TO $@ example.o $(LDFLAGS)
-
-minigzip: minigzip.o z.lib
- $(CC) $(CFLAGS) LINK TO $@ minigzip.o $(LDFLAGS)
-
-mostlyclean: clean
-clean:
- -delete force quiet example minigzip *.o z.lib foo.gz *.lnk SCOPTIONS
-
-SCOPTIONS: Makefile.sas
- copy to $@ <from <
-$(SCOPTIONS)
-<
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-adler32.o: zlib.h zconf.h
-compress.o: zlib.h zconf.h
-crc32.o: crc32.h zlib.h zconf.h
-deflate.o: deflate.h zutil.h zlib.h zconf.h
-example.o: zlib.h zconf.h
-gzio.o: zutil.h zlib.h zconf.h
-inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
-inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
-infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
-inftrees.o: zutil.h zlib.h zconf.h inftrees.h
-minigzip.o: zlib.h zconf.h
-trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
-uncompr.o: zlib.h zconf.h
-zutil.o: zutil.h zlib.h zconf.h
diff --git a/source4/lib/zlib/as400/bndsrc b/source4/lib/zlib/as400/bndsrc
deleted file mode 100644
index 9cf94bb356..0000000000
--- a/source4/lib/zlib/as400/bndsrc
+++ /dev/null
@@ -1,132 +0,0 @@
-STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB')
-
-/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
-/* Version 1.1.3 entry points. */
-/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
-
-/********************************************************************/
-/* *MODULE ADLER32 ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("adler32")
-
-/********************************************************************/
-/* *MODULE COMPRESS ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("compress")
- EXPORT SYMBOL("compress2")
-
-/********************************************************************/
-/* *MODULE CRC32 ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("crc32")
- EXPORT SYMBOL("get_crc_table")
-
-/********************************************************************/
-/* *MODULE DEFLATE ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("deflate")
- EXPORT SYMBOL("deflateEnd")
- EXPORT SYMBOL("deflateSetDictionary")
- EXPORT SYMBOL("deflateCopy")
- EXPORT SYMBOL("deflateReset")
- EXPORT SYMBOL("deflateParams")
- EXPORT SYMBOL("deflatePrime")
- EXPORT SYMBOL("deflateInit_")
- EXPORT SYMBOL("deflateInit2_")
-
-/********************************************************************/
-/* *MODULE GZIO ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("gzopen")
- EXPORT SYMBOL("gzdopen")
- EXPORT SYMBOL("gzsetparams")
- EXPORT SYMBOL("gzread")
- EXPORT SYMBOL("gzwrite")
- EXPORT SYMBOL("gzprintf")
- EXPORT SYMBOL("gzputs")
- EXPORT SYMBOL("gzgets")
- EXPORT SYMBOL("gzputc")
- EXPORT SYMBOL("gzgetc")
- EXPORT SYMBOL("gzflush")
- EXPORT SYMBOL("gzseek")
- EXPORT SYMBOL("gzrewind")
- EXPORT SYMBOL("gztell")
- EXPORT SYMBOL("gzeof")
- EXPORT SYMBOL("gzclose")
- EXPORT SYMBOL("gzerror")
-
-/********************************************************************/
-/* *MODULE INFLATE ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("inflate")
- EXPORT SYMBOL("inflateEnd")
- EXPORT SYMBOL("inflateSetDictionary")
- EXPORT SYMBOL("inflateSync")
- EXPORT SYMBOL("inflateReset")
- EXPORT SYMBOL("inflateInit_")
- EXPORT SYMBOL("inflateInit2_")
- EXPORT SYMBOL("inflateSyncPoint")
-
-/********************************************************************/
-/* *MODULE UNCOMPR ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("uncompress")
-
-/********************************************************************/
-/* *MODULE ZUTIL ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("zlibVersion")
- EXPORT SYMBOL("zError")
-
-/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
-/* Version 1.2.1 additional entry points. */
-/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
-
-/********************************************************************/
-/* *MODULE COMPRESS ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("compressBound")
-
-/********************************************************************/
-/* *MODULE DEFLATE ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("deflateBound")
-
-/********************************************************************/
-/* *MODULE GZIO ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("gzungetc")
- EXPORT SYMBOL("gzclearerr")
-
-/********************************************************************/
-/* *MODULE INFBACK ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("inflateBack")
- EXPORT SYMBOL("inflateBackEnd")
- EXPORT SYMBOL("inflateBackInit_")
-
-/********************************************************************/
-/* *MODULE INFLATE ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("inflateCopy")
-
-/********************************************************************/
-/* *MODULE ZUTIL ZLIB 01/02/01 00:15:09 */
-/********************************************************************/
-
- EXPORT SYMBOL("zlibCompileFlags")
-
-ENDPGMEXP
diff --git a/source4/lib/zlib/as400/compile.clp b/source4/lib/zlib/as400/compile.clp
deleted file mode 100644
index 8554951500..0000000000
--- a/source4/lib/zlib/as400/compile.clp
+++ /dev/null
@@ -1,123 +0,0 @@
-/******************************************************************************/
-/* */
-/* ZLIB */
-/* */
-/* Compile sources into modules and link them into a service program. */
-/* */
-/******************************************************************************/
-
- PGM
-
-/* Configuration adjustable parameters. */
-
- DCL VAR(&SRCLIB) TYPE(*CHAR) LEN(10) +
- VALUE('ZLIB') /* Source library. */
- DCL VAR(&SRCFILE) TYPE(*CHAR) LEN(10) +
- VALUE('SOURCES') /* Source member file. */
- DCL VAR(&CTLFILE) TYPE(*CHAR) LEN(10) +
- VALUE('TOOLS') /* Control member file. */
-
- DCL VAR(&MODLIB) TYPE(*CHAR) LEN(10) +
- VALUE('ZLIB') /* Module library. */
-
- DCL VAR(&SRVLIB) TYPE(*CHAR) LEN(10) +
- VALUE('LGPL') /* Service program library. */
-
- DCL VAR(&CFLAGS) TYPE(*CHAR) +
- VALUE('OPTIMIZE(40)') /* Compile options. */
-
-
-/* Working storage. */
-
- DCL VAR(&CMDLEN) TYPE(*DEC) LEN(15 5) VALUE(300) /* Command length. */
- DCL VAR(&CMD) TYPE(*CHAR) LEN(512)
-
-
-/* Compile sources into modules. */
-
- CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
- '/ADLER32) SRCFILE(' *TCAT +
- &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
- ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
- '/COMPRESS) SRCFILE(' *TCAT +
- &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
- ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
- '/CRC32) SRCFILE(' *TCAT +
- &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
- ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
- '/DEFLATE) SRCFILE(' *TCAT +
- &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
- ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
- '/GZIO) SRCFILE(' *TCAT +
- &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
- ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
- '/INFBACK) SRCFILE(' *TCAT +
- &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
- ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
- '/INFFAST) SRCFILE(' *TCAT +
- &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
- ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
- '/INFLATE) SRCFILE(' *TCAT +
- &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
- ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
- '/INFTREES) SRCFILE(' *TCAT +
- &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
- ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
- '/TREES) SRCFILE(' *TCAT +
- &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
- ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
- '/UNCOMPR) SRCFILE(' *TCAT +
- &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
- ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
- CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
- '/ZUTIL) SRCFILE(' *TCAT +
- &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
- ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
- CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
-
-
-/* Link modules into a service program. */
-
- CRTSRVPGM SRVPGM(&SRVLIB/ZLIB) +
- MODULE(&MODLIB/ADLER32 &MODLIB/COMPRESS +
- &MODLIB/CRC32 &MODLIB/DEFLATE +
- &MODLIB/GZIO &MODLIB/INFBACK +
- &MODLIB/INFFAST &MODLIB/INFLATE +
- &MODLIB/INFTREES &MODLIB/TREES +
- &MODLIB/UNCOMPR &MODLIB/ZUTIL) +
- SRCFILE(&SRCLIB/&CTLFILE) SRCMBR(BNDSRC) +
- TEXT('ZLIB 1.2.3') TGTRLS(V4R4M0)
-
- ENDPGM
diff --git a/source4/lib/zlib/as400/readme.txt b/source4/lib/zlib/as400/readme.txt
deleted file mode 100644
index beae13f565..0000000000
--- a/source4/lib/zlib/as400/readme.txt
+++ /dev/null
@@ -1,111 +0,0 @@
- ZLIB version 1.2.3 for AS400 installation instructions
-
-I) From an AS400 *SAVF file:
-
-1) Unpacking archive to an AS400 save file
-
-On the AS400:
-
-_ Create the ZLIB AS400 library:
-
- CRTLIB LIB(ZLIB) TYPE(PROD) TEXT('ZLIB compression API library')
-
-_ Create a work save file, for example:
-
- CRTSAVF FILE(ZLIB/ZLIBSAVF)
-
-On a PC connected to the target AS400:
-
-_ Unpack the save file image to a PC file "ZLIBSAVF"
-_ Upload this file into the save file on the AS400, for example
- using ftp in BINARY mode.
-
-
-2) Populating the ZLIB AS400 source library
-
-On the AS400:
-
-_ Extract the saved objects into the ZLIB AS400 library using:
-
-RSTOBJ OBJ(*ALL) SAVLIB(ZLIB) DEV(*SAVF) SAVF(ZLIB/ZLIBSAVF) RSTLIB(ZLIB)
-
-
-3) Customize installation:
-
-_ Edit CL member ZLIB/TOOLS(COMPILE) and change parameters if needed,
- according to the comments.
-
-_ Compile this member with:
-
- CRTCLPGM PGM(ZLIB/COMPILE) SRCFILE(ZLIB/TOOLS) SRCMBR(COMPILE)
-
-
-4) Compile and generate the service program:
-
-_ This can now be done by executing:
-
- CALL PGM(ZLIB/COMPILE)
-
-
-
-II) From the original source distribution:
-
-1) On the AS400, create the source library:
-
- CRTLIB LIB(ZLIB) TYPE(PROD) TEXT('ZLIB compression API library')
-
-2) Create the source files:
-
- CRTSRCPF FILE(ZLIB/SOURCES) RCDLEN(112) TEXT('ZLIB library modules')
- CRTSRCPF FILE(ZLIB/H) RCDLEN(112) TEXT('ZLIB library includes')
- CRTSRCPF FILE(ZLIB/TOOLS) RCDLEN(112) TEXT('ZLIB library control utilities')
-
-3) From the machine hosting the distribution files, upload them (with
- FTP in text mode, for example) according to the following table:
-
- Original AS400 AS400 AS400 AS400
- file file member type description
- SOURCES Original ZLIB C subprogram sources
- adler32.c ADLER32 C ZLIB - Compute the Adler-32 checksum of a dta strm
- compress.c COMPRESS C ZLIB - Compress a memory buffer
- crc32.c CRC32 C ZLIB - Compute the CRC-32 of a data stream
- deflate.c DEFLATE C ZLIB - Compress data using the deflation algorithm
- gzio.c GZIO C ZLIB - IO on .gz files
- infback.c INFBACK C ZLIB - Inflate using a callback interface
- inffast.c INFFAST C ZLIB - Fast proc. literals & length/distance pairs
- inflate.c INFLATE C ZLIB - Interface to inflate modules
- inftrees.c INFTREES C ZLIB - Generate Huffman trees for efficient decode
- trees.c TREES C ZLIB - Output deflated data using Huffman coding
- uncompr.c UNCOMPR C ZLIB - Decompress a memory buffer
- zutil.c ZUTIL C ZLIB - Target dependent utility functions
- H Original ZLIB C and ILE/RPG include files
- crc32.h CRC32 C ZLIB - CRC32 tables
- deflate.h DEFLATE C ZLIB - Internal compression state
- inffast.h INFFAST C ZLIB - Header to use inffast.c
- inffixed.h INFFIXED C ZLIB - Table for decoding fixed codes
- inflate.h INFLATE C ZLIB - Internal inflate state definitions
- inftrees.h INFTREES C ZLIB - Header to use inftrees.c
- trees.h TREES C ZLIB - Created automatically with -DGEN_TREES_H
- zconf.h ZCONF C ZLIB - Compression library configuration
- zlib.h ZLIB C ZLIB - Compression library C user interface
- as400/zlib.inc ZLIB.INC RPGLE ZLIB - Compression library ILE RPG user interface
- zutil.h ZUTIL C ZLIB - Internal interface and configuration
- TOOLS Building source software & AS/400 README
- as400/bndsrc BNDSRC Entry point exportation list
- as400/compile.clp COMPILE CLP Compile sources & generate service program
- as400/readme.txt README TXT Installation instructions
-
-4) Continue as in I)3).
-
-
-
-
-Notes: For AS400 ILE RPG programmers, a /copy member defining the ZLIB
- API prototypes for ILE RPG can be found in ZLIB/H(ZLIB.INC).
- Please read comments in this member for more information.
-
- Remember that most foreign textual data are ASCII coded: this
- implementation does not handle conversion from/to ASCII, so
- text data code conversions must be done explicitely.
-
- Always open zipped files in binary mode.
diff --git a/source4/lib/zlib/as400/zlib.inc b/source4/lib/zlib/as400/zlib.inc
deleted file mode 100644
index 7bbfb7e417..0000000000
--- a/source4/lib/zlib/as400/zlib.inc
+++ /dev/null
@@ -1,331 +0,0 @@
- * ZLIB.INC - Interface to the general purpose compression library
- *
- * ILE RPG400 version by Patrick Monnerat, DATASPHERE.
- * Version 1.2.3
- *
- *
- * WARNING:
- * Procedures inflateInit(), inflateInit2(), deflateInit(),
- * deflateInit2() and inflateBackInit() need to be called with
- * two additional arguments:
- * the package version string and the stream control structure.
- * size. This is needed because RPG lacks some macro feature.
- * Call these procedures as:
- * inflateInit(...: ZLIB_VERSION: %size(z_stream))
- *
- /if not defined(ZLIB_H_)
- /define ZLIB_H_
- *
- **************************************************************************
- * Constants
- **************************************************************************
- *
- * Versioning information.
- *
- D ZLIB_VERSION C '1.2.3'
- D ZLIB_VERNUM C X'1230'
- *
- * Other equates.
- *
- D Z_NO_FLUSH C 0
- D Z_SYNC_FLUSH C 2
- D Z_FULL_FLUSH C 3
- D Z_FINISH C 4
- D Z_BLOCK C 5
- *
- D Z_OK C 0
- D Z_STREAM_END C 1
- D Z_NEED_DICT C 2
- D Z_ERRNO C -1
- D Z_STREAM_ERROR C -2
- D Z_DATA_ERROR C -3
- D Z_MEM_ERROR C -4
- D Z_BUF_ERROR C -5
- DZ_VERSION_ERROR C -6
- *
- D Z_NO_COMPRESSION...
- D C 0
- D Z_BEST_SPEED C 1
- D Z_BEST_COMPRESSION...
- D C 9
- D Z_DEFAULT_COMPRESSION...
- D C -1
- *
- D Z_FILTERED C 1
- D Z_HUFFMAN_ONLY C 2
- D Z_RLE C 3
- D Z_DEFAULT_STRATEGY...
- D C 0
- *
- D Z_BINARY C 0
- D Z_ASCII C 1
- D Z_UNKNOWN C 2
- *
- D Z_DEFLATED C 8
- *
- D Z_NULL C 0
- *
- **************************************************************************
- * Types
- **************************************************************************
- *
- D z_streamp S * Stream struct ptr
- D gzFile S * File pointer
- D z_off_t S 10i 0 Stream offsets
- *
- **************************************************************************
- * Structures
- **************************************************************************
- *
- * The GZIP encode/decode stream support structure.
- *
- D z_stream DS align based(z_streamp)
- D zs_next_in * Next input byte
- D zs_avail_in 10U 0 Byte cnt at next_in
- D zs_total_in 10U 0 Total bytes read
- D zs_next_out * Output buffer ptr
- D zs_avail_out 10U 0 Room left @ next_out
- D zs_total_out 10U 0 Total bytes written
- D zs_msg * Last errmsg or null
- D zs_state * Internal state
- D zs_zalloc * procptr Int. state allocator
- D zs_free * procptr Int. state dealloc.
- D zs_opaque * Private alloc. data
- D zs_data_type 10i 0 ASC/BIN best guess
- D zs_adler 10u 0 Uncompr. adler32 val
- D 10U 0 Reserved
- D 10U 0 Ptr. alignment
- *
- **************************************************************************
- * Utility function prototypes
- **************************************************************************
- *
- D compress PR 10I 0 extproc('compress')
- D dest 32767 options(*varsize) Destination buffer
- D destLen 10U 0 Destination length
- D source 32767 const options(*varsize) Source buffer
- D sourceLen 10u 0 value Source length
- *
- D compress2 PR 10I 0 extproc('compress2')
- D dest 32767 options(*varsize) Destination buffer
- D destLen 10U 0 Destination length
- D source 32767 const options(*varsize) Source buffer
- D sourceLen 10U 0 value Source length
- D level 10I 0 value Compression level
- *
- D compressBound PR 10U 0 extproc('compressBound')
- D sourceLen 10U 0 value
- *
- D uncompress PR 10I 0 extproc('uncompress')
- D dest 32767 options(*varsize) Destination buffer
- D destLen 10U 0 Destination length
- D source 32767 const options(*varsize) Source buffer
- D sourceLen 10U 0 value Source length
- *
- D gzopen PR extproc('gzopen')
- D like(gzFile)
- D path * value options(*string) File pathname
- D mode * value options(*string) Open mode
- *
- D gzdopen PR extproc('gzdopen')
- D like(gzFile)
- D fd 10i 0 value File descriptor
- D mode * value options(*string) Open mode
- *
- D gzsetparams PR 10I 0 extproc('gzsetparams')
- D file value like(gzFile) File pointer
- D level 10I 0 value
- D strategy 10i 0 value
- *
- D gzread PR 10I 0 extproc('gzread')
- D file value like(gzFile) File pointer
- D buf 32767 options(*varsize) Buffer
- D len 10u 0 value Buffer length
- *
- D gzwrite PR 10I 0 extproc('gzwrite')
- D file value like(gzFile) File pointer
- D buf 32767 const options(*varsize) Buffer
- D len 10u 0 value Buffer length
- *
- D gzputs PR 10I 0 extproc('gzputs')
- D file value like(gzFile) File pointer
- D s * value options(*string) String to output
- *
- D gzgets PR * extproc('gzgets')
- D file value like(gzFile) File pointer
- D buf 32767 options(*varsize) Read buffer
- D len 10i 0 value Buffer length
- *
- D gzflush PR 10i 0 extproc('gzflush')
- D file value like(gzFile) File pointer
- D flush 10I 0 value Type of flush
- *
- D gzseek PR extproc('gzseek')
- D like(z_off_t)
- D file value like(gzFile) File pointer
- D offset value like(z_off_t) Offset
- D whence 10i 0 value Origin
- *
- D gzrewind PR 10i 0 extproc('gzrewind')
- D file value like(gzFile) File pointer
- *
- D gztell PR extproc('gztell')
- D like(z_off_t)
- D file value like(gzFile) File pointer
- *
- D gzeof PR 10i 0 extproc('gzeof')
- D file value like(gzFile) File pointer
- *
- D gzclose PR 10i 0 extproc('gzclose')
- D file value like(gzFile) File pointer
- *
- D gzerror PR * extproc('gzerror') Error string
- D file value like(gzFile) File pointer
- D errnum 10I 0 Error code
- *
- D gzclearerr PR extproc('gzclearerr')
- D file value like(gzFile) File pointer
- *
- **************************************************************************
- * Basic function prototypes
- **************************************************************************
- *
- D zlibVersion PR * extproc('zlibVersion') Version string
- *
- D deflateInit PR 10I 0 extproc('deflateInit_') Init. compression
- D strm like(z_stream) Compression stream
- D level 10I 0 value Compression level
- D version * value options(*string) Version string
- D stream_size 10i 0 value Stream struct. size
- *
- D deflate PR 10I 0 extproc('deflate') Compress data
- D strm like(z_stream) Compression stream
- D flush 10I 0 value Flush type required
- *
- D deflateEnd PR 10I 0 extproc('deflateEnd') Termin. compression
- D strm like(z_stream) Compression stream
- *
- D inflateInit PR 10I 0 extproc('inflateInit_') Init. expansion
- D strm like(z_stream) Expansion stream
- D version * value options(*string) Version string
- D stream_size 10i 0 value Stream struct. size
- *
- D inflate PR 10I 0 extproc('inflate') Expand data
- D strm like(z_stream) Expansion stream
- D flush 10I 0 value Flush type required
- *
- D inflateEnd PR 10I 0 extproc('inflateEnd') Termin. expansion
- D strm like(z_stream) Expansion stream
- *
- **************************************************************************
- * Advanced function prototypes
- **************************************************************************
- *
- D deflateInit2 PR 10I 0 extproc('deflateInit2_') Init. compression
- D strm like(z_stream) Compression stream
- D level 10I 0 value Compression level
- D method 10I 0 value Compression method
- D windowBits 10I 0 value log2(window size)
- D memLevel 10I 0 value Mem/cmpress tradeoff
- D strategy 10I 0 value Compression stategy
- D version * value options(*string) Version string
- D stream_size 10i 0 value Stream struct. size
- *
- D deflateSetDictionary...
- D PR 10I 0 extproc('deflateSetDictionary') Init. dictionary
- D strm like(z_stream) Compression stream
- D dictionary 32767 const options(*varsize) Dictionary bytes
- D dictLength 10U 0 value Dictionary length
- *
- D deflateCopy PR 10I 0 extproc('deflateCopy') Compress strm 2 strm
- D dest like(z_stream) Destination stream
- D source like(z_stream) Source stream
- *
- D deflateReset PR 10I 0 extproc('deflateReset') End and init. stream
- D strm like(z_stream) Compression stream
- *
- D deflateParams PR 10I 0 extproc('deflateParams') Change level & strat
- D strm like(z_stream) Compression stream
- D level 10I 0 value Compression level
- D strategy 10I 0 value Compression stategy
- *
- D deflateBound PR 10U 0 extproc('deflateBound') Change level & strat
- D strm like(z_stream) Compression stream
- D sourcelen 10U 0 value Compression level
- *
- D deflatePrime PR 10I 0 extproc('deflatePrime') Change level & strat
- D strm like(z_stream) Compression stream
- D bits 10I 0 value Number of bits to insert
- D value 10I 0 value Bits to insert
- *
- D inflateInit2 PR 10I 0 extproc('inflateInit2_') Init. expansion
- D strm like(z_stream) Expansion stream
- D windowBits 10I 0 value log2(window size)
- D version * value options(*string) Version string
- D stream_size 10i 0 value Stream struct. size
- *
- D inflateSetDictionary...
- D PR 10I 0 extproc('inflateSetDictionary') Init. dictionary
- D strm like(z_stream) Expansion stream
- D dictionary 32767 const options(*varsize) Dictionary bytes
- D dictLength 10U 0 value Dictionary length
- *
- D inflateSync PR 10I 0 extproc('inflateSync') Sync. expansion
- D strm like(z_stream) Expansion stream
- *
- D inflateCopy PR 10I 0 extproc('inflateCopy')
- D dest like(z_stream) Destination stream
- D source like(z_stream) Source stream
- *
- D inflateReset PR 10I 0 extproc('inflateReset') End and init. stream
- D strm like(z_stream) Expansion stream
- *
- D inflateBackInit...
- D PR 10I 0 extproc('inflateBackInit_')
- D strm like(z_stream) Expansion stream
- D windowBits 10I 0 value Log2(buffer size)
- D window 32767 options(*varsize) Buffer
- D version * value options(*string) Version string
- D stream_size 10i 0 value Stream struct. size
- *
- D inflateBack PR 10I 0 extproc('inflateBack')
- D strm like(z_stream) Expansion stream
- D in * value procptr Input function
- D in_desc * value Input descriptor
- D out * value procptr Output function
- D out_desc * value Output descriptor
- *
- D inflateBackEnd PR 10I 0 extproc('inflateBackEnd')
- D strm like(z_stream) Expansion stream
- *
- D zlibCompileFlags...
- D PR 10U 0 extproc('zlibCompileFlags')
- *
- **************************************************************************
- * Checksum function prototypes
- **************************************************************************
- *
- D adler32 PR 10U 0 extproc('adler32') New checksum
- D adler 10U 0 value Old checksum
- D buf 32767 const options(*varsize) Bytes to accumulate
- D len 10U 0 value Buffer length
- *
- D crc32 PR 10U 0 extproc('crc32') New checksum
- D crc 10U 0 value Old checksum
- D buf 32767 const options(*varsize) Bytes to accumulate
- D len 10U 0 value Buffer length
- *
- **************************************************************************
- * Miscellaneous function prototypes
- **************************************************************************
- *
- D zError PR * extproc('zError') Error string
- D err 10I 0 value Error code
- *
- D inflateSyncPoint...
- D PR 10I 0 extproc('inflateSyncPoint')
- D strm like(z_stream) Expansion stream
- *
- D get_crc_table PR * extproc('get_crc_table') Ptr to ulongs
- *
- /endif
diff --git a/source4/lib/zlib/compress.c b/source4/lib/zlib/compress.c
deleted file mode 100644
index 40a53cd476..0000000000
--- a/source4/lib/zlib/compress.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* compress.c -- compress a memory buffer
- * Copyright (C) 1995-2003 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#include "zutil.h"
-
-/* ===========================================================================
- Compresses the source buffer into the destination buffer. The level
- parameter has the same meaning as in deflateInit. sourceLen is the byte
- length of the source buffer. Upon entry, destLen is the total size of the
- destination buffer, which must be at least 0.1% larger than sourceLen plus
- 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
-
- compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_BUF_ERROR if there was not enough room in the output buffer,
- Z_STREAM_ERROR if the level parameter is invalid.
-*/
-int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
- int level;
-{
- z_stream stream;
- int err;
-
- stream.next_in = source;
- stream.avail_in = (uInt)sourceLen;
-#ifdef MAXSEG_64K
- /* Check for source > 64K on 16-bit machine: */
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-#endif
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
-
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
- stream.opaque = (voidpf)0;
-
- err = deflateInit(&stream, level);
- if (err != Z_OK) return err;
-
- err = deflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- deflateEnd(&stream);
- return err == Z_OK ? Z_BUF_ERROR : err;
- }
- *destLen = stream.total_out;
-
- err = deflateEnd(&stream);
- return err;
-}
-
-/* ===========================================================================
- */
-int ZEXPORT compress (dest, destLen, source, sourceLen)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
-{
- return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
-}
-
-/* ===========================================================================
- If the default memLevel or windowBits for deflateInit() is changed, then
- this function needs to be updated.
- */
-uLong ZEXPORT compressBound (sourceLen)
- uLong sourceLen;
-{
- return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
-}
diff --git a/source4/lib/zlib/contrib/README.contrib b/source4/lib/zlib/contrib/README.contrib
deleted file mode 100644
index 20afc62154..0000000000
--- a/source4/lib/zlib/contrib/README.contrib
+++ /dev/null
@@ -1,71 +0,0 @@
-All files under this contrib directory are UNSUPPORTED. There were
-provided by users of zlib and were not tested by the authors of zlib.
-Use at your own risk. Please contact the authors of the contributions
-for help about these, not the zlib authors. Thanks.
-
-
-ada/ by Dmitriy Anisimkov <anisimkov@yahoo.com>
- Support for Ada
- See http://zlib-ada.sourceforge.net/
-
-asm586/
-asm686/ by Brian Raiter <breadbox@muppetlabs.com>
- asm code for Pentium and PPro/PII, using the AT&T (GNU as) syntax
- See http://www.muppetlabs.com/~breadbox/software/assembly.html
-
-blast/ by Mark Adler <madler@alumni.caltech.edu>
- Decompressor for output of PKWare Data Compression Library (DCL)
-
-delphi/ by Cosmin Truta <cosmint@cs.ubbcluj.ro>
- Support for Delphi and C++ Builder
-
-dotzlib/ by Henrik Ravn <henrik@ravn.com>
- Support for Microsoft .Net and Visual C++ .Net
-
-infback9/ by Mark Adler <madler@alumni.caltech.edu>
- Unsupported diffs to infback to decode the deflate64 format
-
-inflate86/ by Chris Anderson <christop@charm.net>
- Tuned x86 gcc asm code to replace inflate_fast()
-
-iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
- A C++ I/O streams interface to the zlib gz* functions
-
-iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no>
- Another C++ I/O streams interface
-
-iostream3/ by Ludwig Schwardt <schwardt@sun.ac.za>
- and Kevin Ruland <kevin@rodin.wustl.edu>
- Yet another C++ I/O streams interface
-
-masm686/ by Dan Higdon <hdan@kinesoft.com>
- and Chuck Walbourn <chuckw@kinesoft.com>
- asm code for Pentium Pro/PII, using the MASM syntax
-
-masmx64/ by Gilles Vollant <info@winimage.com>
- x86 64-bit (AMD64 and Intel EM64t) code for x64 assembler to
- replace longest_match() and inflate_fast()
-
-masmx86/ by Gilles Vollant <info@winimage.com>
- x86 asm code to replace longest_match() and inflate_fast(),
- for Visual C++ and MASM
-
-minizip/ by Gilles Vollant <info@winimage.com>
- Mini zip and unzip based on zlib
- See http://www.winimage.com/zLibDll/unzip.html
-
-pascal/ by Bob Dellaca <bobdl@xtra.co.nz> et al.
- Support for Pascal
-
-puff/ by Mark Adler <madler@alumni.caltech.edu>
- Small, low memory usage inflate. Also serves to provide an
- unambiguous description of the deflate format.
-
-testzlib/ by Gilles Vollant <info@winimage.com>
- Example of the use of zlib
-
-untgz/ by Pedro A. Aranda Gutierrez <paag@tid.es>
- A very simple tar.gz file extractor using zlib
-
-vstudio/ by Gilles Vollant <info@winimage.com>
- Building a minizip-enhanced zlib with Microsoft Visual Studio
diff --git a/source4/lib/zlib/contrib/ada/buffer_demo.adb b/source4/lib/zlib/contrib/ada/buffer_demo.adb
deleted file mode 100644
index 46b8638107..0000000000
--- a/source4/lib/zlib/contrib/ada/buffer_demo.adb
+++ /dev/null
@@ -1,106 +0,0 @@
-----------------------------------------------------------------
--- ZLib for Ada thick binding. --
--- --
--- Copyright (C) 2002-2004 Dmitriy Anisimkov --
--- --
--- Open source license information is in the zlib.ads file. --
-----------------------------------------------------------------
---
--- $Id: buffer_demo.adb,v 1.3 2004/09/06 06:55:35 vagul Exp $
-
--- This demo program provided by Dr Steve Sangwine <sjs@essex.ac.uk>
---
--- Demonstration of a problem with Zlib-Ada (already fixed) when a buffer
--- of exactly the correct size is used for decompressed data, and the last
--- few bytes passed in to Zlib are checksum bytes.
-
--- This program compresses a string of text, and then decompresses the
--- compressed text into a buffer of the same size as the original text.
-
-with Ada.Streams; use Ada.Streams;
-with Ada.Text_IO;
-
-with ZLib; use ZLib;
-
-procedure Buffer_Demo is
- EOL : Character renames ASCII.LF;
- Text : constant String
- := "Four score and seven years ago our fathers brought forth," & EOL &
- "upon this continent, a new nation, conceived in liberty," & EOL &
- "and dedicated to the proposition that `all men are created equal'.";
-
- Source : Stream_Element_Array (1 .. Text'Length);
- for Source'Address use Text'Address;
-
-begin
- Ada.Text_IO.Put (Text);
- Ada.Text_IO.New_Line;
- Ada.Text_IO.Put_Line
- ("Uncompressed size : " & Positive'Image (Text'Length) & " bytes");
-
- declare
- Compressed_Data : Stream_Element_Array (1 .. Text'Length);
- L : Stream_Element_Offset;
- begin
- Compress : declare
- Compressor : Filter_Type;
- I : Stream_Element_Offset;
- begin
- Deflate_Init (Compressor);
-
- -- Compress the whole of T at once.
-
- Translate (Compressor, Source, I, Compressed_Data, L, Finish);
- pragma Assert (I = Source'Last);
-
- Close (Compressor);
-
- Ada.Text_IO.Put_Line
- ("Compressed size : "
- & Stream_Element_Offset'Image (L) & " bytes");
- end Compress;
-
- -- Now we decompress the data, passing short blocks of data to Zlib
- -- (because this demonstrates the problem - the last block passed will
- -- contain checksum information and there will be no output, only a
- -- check inside Zlib that the checksum is correct).
-
- Decompress : declare
- Decompressor : Filter_Type;
-
- Uncompressed_Data : Stream_Element_Array (1 .. Text'Length);
-
- Block_Size : constant := 4;
- -- This makes sure that the last block contains
- -- only Adler checksum data.
-
- P : Stream_Element_Offset := Compressed_Data'First - 1;
- O : Stream_Element_Offset;
- begin
- Inflate_Init (Decompressor);
-
- loop
- Translate
- (Decompressor,
- Compressed_Data
- (P + 1 .. Stream_Element_Offset'Min (P + Block_Size, L)),
- P,
- Uncompressed_Data
- (Total_Out (Decompressor) + 1 .. Uncompressed_Data'Last),
- O,
- No_Flush);
-
- Ada.Text_IO.Put_Line
- ("Total in : " & Count'Image (Total_In (Decompressor)) &
- ", out : " & Count'Image (Total_Out (Decompressor)));
-
- exit when P = L;
- end loop;
-
- Ada.Text_IO.New_Line;
- Ada.Text_IO.Put_Line
- ("Decompressed text matches original text : "
- & Boolean'Image (Uncompressed_Data = Source));
- end Decompress;
- end;
-end Buffer_Demo;
diff --git a/source4/lib/zlib/contrib/ada/mtest.adb b/source4/lib/zlib/contrib/ada/mtest.adb
deleted file mode 100644
index c4dfd080f0..0000000000
--- a/source4/lib/zlib/contrib/ada/mtest.adb
+++ /dev/null
@@ -1,156 +0,0 @@
-----------------------------------------------------------------
--- ZLib for Ada thick binding. --
--- --
--- Copyright (C) 2002-2003 Dmitriy Anisimkov --
--- --
--- Open source license information is in the zlib.ads file. --
-----------------------------------------------------------------
--- Continuous test for ZLib multithreading. If the test would fail
--- we should provide thread safe allocation routines for the Z_Stream.
---
--- $Id: mtest.adb,v 1.4 2004/07/23 07:49:54 vagul Exp $
-
-with ZLib;
-with Ada.Streams;
-with Ada.Numerics.Discrete_Random;
-with Ada.Text_IO;
-with Ada.Exceptions;
-with Ada.Task_Identification;
-
-procedure MTest is
- use Ada.Streams;
- use ZLib;
-
- Stop : Boolean := False;
-
- pragma Atomic (Stop);
-
- subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#;
-
- package Random_Elements is
- new Ada.Numerics.Discrete_Random (Visible_Symbols);
-
- task type Test_Task;
-
- task body Test_Task is
- Buffer : Stream_Element_Array (1 .. 100_000);
- Gen : Random_Elements.Generator;
-
- Buffer_First : Stream_Element_Offset;
- Compare_First : Stream_Element_Offset;
-
- Deflate : Filter_Type;
- Inflate : Filter_Type;
-
- procedure Further (Item : in Stream_Element_Array);
-
- procedure Read_Buffer
- (Item : out Ada.Streams.Stream_Element_Array;
- Last : out Ada.Streams.Stream_Element_Offset);
-
- -------------
- -- Further --
- -------------
-
- procedure Further (Item : in Stream_Element_Array) is
-
- procedure Compare (Item : in Stream_Element_Array);
-
- -------------
- -- Compare --
- -------------
-
- procedure Compare (Item : in Stream_Element_Array) is
- Next_First : Stream_Element_Offset := Compare_First + Item'Length;
- begin
- if Buffer (Compare_First .. Next_First - 1) /= Item then
- raise Program_Error;
- end if;
-
- Compare_First := Next_First;
- end Compare;
-
- procedure Compare_Write is new ZLib.Write (Write => Compare);
- begin
- Compare_Write (Inflate, Item, No_Flush);
- end Further;
-
- -----------------
- -- Read_Buffer --
- -----------------
-
- procedure Read_Buffer
- (Item : out Ada.Streams.Stream_Element_Array;
- Last : out Ada.Streams.Stream_Element_Offset)
- is
- Buff_Diff : Stream_Element_Offset := Buffer'Last - Buffer_First;
- Next_First : Stream_Element_Offset;
- begin
- if Item'Length <= Buff_Diff then
- Last := Item'Last;
-
- Next_First := Buffer_First + Item'Length;
-
- Item := Buffer (Buffer_First .. Next_First - 1);
-
- Buffer_First := Next_First;
- else
- Last := Item'First + Buff_Diff;
- Item (Item'First .. Last) := Buffer (Buffer_First .. Buffer'Last);
- Buffer_First := Buffer'Last + 1;
- end if;
- end Read_Buffer;
-
- procedure Translate is new Generic_Translate
- (Data_In => Read_Buffer,
- Data_Out => Further);
-
- begin
- Random_Elements.Reset (Gen);
-
- Buffer := (others => 20);
-
- Main : loop
- for J in Buffer'Range loop
- Buffer (J) := Random_Elements.Random (Gen);
-
- Deflate_Init (Deflate);
- Inflate_Init (Inflate);
-
- Buffer_First := Buffer'First;
- Compare_First := Buffer'First;
-
- Translate (Deflate);
-
- if Compare_First /= Buffer'Last + 1 then
- raise Program_Error;
- end if;
-
- Ada.Text_IO.Put_Line
- (Ada.Task_Identification.Image
- (Ada.Task_Identification.Current_Task)
- & Stream_Element_Offset'Image (J)
- & ZLib.Count'Image (Total_Out (Deflate)));
-
- Close (Deflate);
- Close (Inflate);
-
- exit Main when Stop;
- end loop;
- end loop Main;
- exception
- when E : others =>
- Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E));
- Stop := True;
- end Test_Task;
-
- Test : array (1 .. 4) of Test_Task;
-
- pragma Unreferenced (Test);
-
- Dummy : Character;
-
-begin
- Ada.Text_IO.Get_Immediate (Dummy);
- Stop := True;
-end MTest;
diff --git a/source4/lib/zlib/contrib/ada/read.adb b/source4/lib/zlib/contrib/ada/read.adb
deleted file mode 100644
index 1f2efbfeb8..0000000000
--- a/source4/lib/zlib/contrib/ada/read.adb
+++ /dev/null
@@ -1,156 +0,0 @@
-----------------------------------------------------------------
--- ZLib for Ada thick binding. --
--- --
--- Copyright (C) 2002-2003 Dmitriy Anisimkov --
--- --
--- Open source license information is in the zlib.ads file. --
-----------------------------------------------------------------
-
--- $Id: read.adb,v 1.8 2004/05/31 10:53:40 vagul Exp $
-
--- Test/demo program for the generic read interface.
-
-with Ada.Numerics.Discrete_Random;
-with Ada.Streams;
-with Ada.Text_IO;
-
-with ZLib;
-
-procedure Read is
-
- use Ada.Streams;
-
- ------------------------------------
- -- Test configuration parameters --
- ------------------------------------
-
- File_Size : Stream_Element_Offset := 100_000;
-
- Continuous : constant Boolean := False;
- -- If this constant is True, the test would be repeated again and again,
- -- with increment File_Size for every iteration.
-
- Header : constant ZLib.Header_Type := ZLib.Default;
- -- Do not use Header other than Default in ZLib versions 1.1.4 and older.
-
- Init_Random : constant := 8;
- -- We are using the same random sequence, in case of we catch bug,
- -- so we would be able to reproduce it.
-
- -- End --
-
- Pack_Size : Stream_Element_Offset;
- Offset : Stream_Element_Offset;
-
- Filter : ZLib.Filter_Type;
-
- subtype Visible_Symbols
- is Stream_Element range 16#20# .. 16#7E#;
-
- package Random_Elements is new
- Ada.Numerics.Discrete_Random (Visible_Symbols);
-
- Gen : Random_Elements.Generator;
- Period : constant Stream_Element_Offset := 200;
- -- Period constant variable for random generator not to be very random.
- -- Bigger period, harder random.
-
- Read_Buffer : Stream_Element_Array (1 .. 2048);
- Read_First : Stream_Element_Offset;
- Read_Last : Stream_Element_Offset;
-
- procedure Reset;
-
- procedure Read
- (Item : out Stream_Element_Array;
- Last : out Stream_Element_Offset);
- -- this procedure is for generic instantiation of
- -- ZLib.Read
- -- reading data from the File_In.
-
- procedure Read is new ZLib.Read
- (Read,
- Read_Buffer,
- Rest_First => Read_First,
- Rest_Last => Read_Last);
-
- ----------
- -- Read --
- ----------
-
- procedure Read
- (Item : out Stream_Element_Array;
- Last : out Stream_Element_Offset) is
- begin
- Last := Stream_Element_Offset'Min
- (Item'Last,
- Item'First + File_Size - Offset);
-
- for J in Item'First .. Last loop
- if J < Item'First + Period then
- Item (J) := Random_Elements.Random (Gen);
- else
- Item (J) := Item (J - Period);
- end if;
-
- Offset := Offset + 1;
- end loop;
- end Read;
-
- -----------
- -- Reset --
- -----------
-
- procedure Reset is
- begin
- Random_Elements.Reset (Gen, Init_Random);
- Pack_Size := 0;
- Offset := 1;
- Read_First := Read_Buffer'Last + 1;
- Read_Last := Read_Buffer'Last;
- end Reset;
-
-begin
- Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version);
-
- loop
- for Level in ZLib.Compression_Level'Range loop
-
- Ada.Text_IO.Put ("Level ="
- & ZLib.Compression_Level'Image (Level));
-
- -- Deflate using generic instantiation.
-
- ZLib.Deflate_Init
- (Filter,
- Level,
- Header => Header);
-
- Reset;
-
- Ada.Text_IO.Put
- (Stream_Element_Offset'Image (File_Size) & " ->");
-
- loop
- declare
- Buffer : Stream_Element_Array (1 .. 1024);
- Last : Stream_Element_Offset;
- begin
- Read (Filter, Buffer, Last);
-
- Pack_Size := Pack_Size + Last - Buffer'First + 1;
-
- exit when Last < Buffer'Last;
- end;
- end loop;
-
- Ada.Text_IO.Put_Line (Stream_Element_Offset'Image (Pack_Size));
-
- ZLib.Close (Filter);
- end loop;
-
- exit when not Continuous;
-
- File_Size := File_Size + 1;
- end loop;
-end Read;
diff --git a/source4/lib/zlib/contrib/ada/readme.txt b/source4/lib/zlib/contrib/ada/readme.txt
deleted file mode 100644
index ce4d2cadf0..0000000000
--- a/source4/lib/zlib/contrib/ada/readme.txt
+++ /dev/null
@@ -1,65 +0,0 @@
- ZLib for Ada thick binding (ZLib.Ada)
- Release 1.3
-
-ZLib.Ada is a thick binding interface to the popular ZLib data
-compression library, available at http://www.gzip.org/zlib/.
-It provides Ada-style access to the ZLib C library.
-
-
- Here are the main changes since ZLib.Ada 1.2:
-
-- Attension: ZLib.Read generic routine have a initialization requirement
- for Read_Last parameter now. It is a bit incompartible with previous version,
- but extends functionality, we could use new parameters Allow_Read_Some and
- Flush now.
-
-- Added Is_Open routines to ZLib and ZLib.Streams packages.
-
-- Add pragma Assert to check Stream_Element is 8 bit.
-
-- Fix extraction to buffer with exact known decompressed size. Error reported by
- Steve Sangwine.
-
-- Fix definition of ULong (changed to unsigned_long), fix regression on 64 bits
- computers. Patch provided by Pascal Obry.
-
-- Add Status_Error exception definition.
-
-- Add pragma Assertion that Ada.Streams.Stream_Element size is 8 bit.
-
-
- How to build ZLib.Ada under GNAT
-
-You should have the ZLib library already build on your computer, before
-building ZLib.Ada. Make the directory of ZLib.Ada sources current and
-issue the command:
-
- gnatmake test -largs -L<directory where libz.a is> -lz
-
-Or use the GNAT project file build for GNAT 3.15 or later:
-
- gnatmake -Pzlib.gpr -L<directory where libz.a is>
-
-
- How to build ZLib.Ada under Aonix ObjectAda for Win32 7.2.2
-
-1. Make a project with all *.ads and *.adb files from the distribution.
-2. Build the libz.a library from the ZLib C sources.
-3. Rename libz.a to z.lib.
-4. Add the library z.lib to the project.
-5. Add the libc.lib library from the ObjectAda distribution to the project.
-6. Build the executable using test.adb as a main procedure.
-
-
- How to use ZLib.Ada
-
-The source files test.adb and read.adb are small demo programs that show
-the main functionality of ZLib.Ada.
-
-The routines from the package specifications are commented.
-
-
-Homepage: http://zlib-ada.sourceforge.net/
-Author: Dmitriy Anisimkov <anisimkov@yahoo.com>
-
-Contributors: Pascal Obry <pascal@obry.org>, Steve Sangwine <sjs@essex.ac.uk>
diff --git a/source4/lib/zlib/contrib/ada/test.adb b/source4/lib/zlib/contrib/ada/test.adb
deleted file mode 100644
index 90773acfa1..0000000000
--- a/source4/lib/zlib/contrib/ada/test.adb
+++ /dev/null
@@ -1,463 +0,0 @@
-----------------------------------------------------------------
--- ZLib for Ada thick binding. --
--- --
--- Copyright (C) 2002-2003 Dmitriy Anisimkov --
--- --
--- Open source license information is in the zlib.ads file. --
-----------------------------------------------------------------
-
--- $Id: test.adb,v 1.17 2003/08/12 12:13:30 vagul Exp $
-
--- The program has a few aims.
--- 1. Test ZLib.Ada95 thick binding functionality.
--- 2. Show the example of use main functionality of the ZLib.Ada95 binding.
--- 3. Build this program automatically compile all ZLib.Ada95 packages under
--- GNAT Ada95 compiler.
-
-with ZLib.Streams;
-with Ada.Streams.Stream_IO;
-with Ada.Numerics.Discrete_Random;
-
-with Ada.Text_IO;
-
-with Ada.Calendar;
-
-procedure Test is
-
- use Ada.Streams;
- use Stream_IO;
-
- ------------------------------------
- -- Test configuration parameters --
- ------------------------------------
-
- File_Size : Count := 100_000;
- Continuous : constant Boolean := False;
-
- Header : constant ZLib.Header_Type := ZLib.Default;
- -- ZLib.None;
- -- ZLib.Auto;
- -- ZLib.GZip;
- -- Do not use Header other then Default in ZLib versions 1.1.4
- -- and older.
-
- Strategy : constant ZLib.Strategy_Type := ZLib.Default_Strategy;
- Init_Random : constant := 10;
-
- -- End --
-
- In_File_Name : constant String := "testzlib.in";
- -- Name of the input file
-
- Z_File_Name : constant String := "testzlib.zlb";
- -- Name of the compressed file.
-
- Out_File_Name : constant String := "testzlib.out";
- -- Name of the decompressed file.
-
- File_In : File_Type;
- File_Out : File_Type;
- File_Back : File_Type;
- File_Z : ZLib.Streams.Stream_Type;
-
- Filter : ZLib.Filter_Type;
-
- Time_Stamp : Ada.Calendar.Time;
-
- procedure Generate_File;
- -- Generate file of spetsified size with some random data.
- -- The random data is repeatable, for the good compression.
-
- procedure Compare_Streams
- (Left, Right : in out Root_Stream_Type'Class);
- -- The procedure compearing data in 2 streams.
- -- It is for compare data before and after compression/decompression.
-
- procedure Compare_Files (Left, Right : String);
- -- Compare files. Based on the Compare_Streams.
-
- procedure Copy_Streams
- (Source, Target : in out Root_Stream_Type'Class;
- Buffer_Size : in Stream_Element_Offset := 1024);
- -- Copying data from one stream to another. It is for test stream
- -- interface of the library.
-
- procedure Data_In
- (Item : out Stream_Element_Array;
- Last : out Stream_Element_Offset);
- -- this procedure is for generic instantiation of
- -- ZLib.Generic_Translate.
- -- reading data from the File_In.
-
- procedure Data_Out (Item : in Stream_Element_Array);
- -- this procedure is for generic instantiation of
- -- ZLib.Generic_Translate.
- -- writing data to the File_Out.
-
- procedure Stamp;
- -- Store the timestamp to the local variable.
-
- procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count);
- -- Print the time statistic with the message.
-
- procedure Translate is new ZLib.Generic_Translate
- (Data_In => Data_In,
- Data_Out => Data_Out);
- -- This procedure is moving data from File_In to File_Out
- -- with compression or decompression, depend on initialization of
- -- Filter parameter.
-
- -------------------
- -- Compare_Files --
- -------------------
-
- procedure Compare_Files (Left, Right : String) is
- Left_File, Right_File : File_Type;
- begin
- Open (Left_File, In_File, Left);
- Open (Right_File, In_File, Right);
- Compare_Streams (Stream (Left_File).all, Stream (Right_File).all);
- Close (Left_File);
- Close (Right_File);
- end Compare_Files;
-
- ---------------------
- -- Compare_Streams --
- ---------------------
-
- procedure Compare_Streams
- (Left, Right : in out Ada.Streams.Root_Stream_Type'Class)
- is
- Left_Buffer, Right_Buffer : Stream_Element_Array (0 .. 16#FFF#);
- Left_Last, Right_Last : Stream_Element_Offset;
- begin
- loop
- Read (Left, Left_Buffer, Left_Last);
- Read (Right, Right_Buffer, Right_Last);
-
- if Left_Last /= Right_Last then
- Ada.Text_IO.Put_Line ("Compare error :"
- & Stream_Element_Offset'Image (Left_Last)
- & " /= "
- & Stream_Element_Offset'Image (Right_Last));
-
- raise Constraint_Error;
-
- elsif Left_Buffer (0 .. Left_Last)
- /= Right_Buffer (0 .. Right_Last)
- then
- Ada.Text_IO.Put_Line ("ERROR: IN and OUT files is not equal.");
- raise Constraint_Error;
-
- end if;
-
- exit when Left_Last < Left_Buffer'Last;
- end loop;
- end Compare_Streams;
-
- ------------------
- -- Copy_Streams --
- ------------------
-
- procedure Copy_Streams
- (Source, Target : in out Ada.Streams.Root_Stream_Type'Class;
- Buffer_Size : in Stream_Element_Offset := 1024)
- is
- Buffer : Stream_Element_Array (1 .. Buffer_Size);
- Last : Stream_Element_Offset;
- begin
- loop
- Read (Source, Buffer, Last);
- Write (Target, Buffer (1 .. Last));
-
- exit when Last < Buffer'Last;
- end loop;
- end Copy_Streams;
-
- -------------
- -- Data_In --
- -------------
-
- procedure Data_In
- (Item : out Stream_Element_Array;
- Last : out Stream_Element_Offset) is
- begin
- Read (File_In, Item, Last);
- end Data_In;
-
- --------------
- -- Data_Out --
- --------------
-
- procedure Data_Out (Item : in Stream_Element_Array) is
- begin
- Write (File_Out, Item);
- end Data_Out;
-
- -------------------
- -- Generate_File --
- -------------------
-
- procedure Generate_File is
- subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#;
-
- package Random_Elements is
- new Ada.Numerics.Discrete_Random (Visible_Symbols);
-
- Gen : Random_Elements.Generator;
- Buffer : Stream_Element_Array := (1 .. 77 => 16#20#) & 10;
-
- Buffer_Count : constant Count := File_Size / Buffer'Length;
- -- Number of same buffers in the packet.
-
- Density : constant Count := 30; -- from 0 to Buffer'Length - 2;
-
- procedure Fill_Buffer (J, D : in Count);
- -- Change the part of the buffer.
-
- -----------------
- -- Fill_Buffer --
- -----------------
-
- procedure Fill_Buffer (J, D : in Count) is
- begin
- for K in 0 .. D loop
- Buffer
- (Stream_Element_Offset ((J + K) mod (Buffer'Length - 1) + 1))
- := Random_Elements.Random (Gen);
-
- end loop;
- end Fill_Buffer;
-
- begin
- Random_Elements.Reset (Gen, Init_Random);
-
- Create (File_In, Out_File, In_File_Name);
-
- Fill_Buffer (1, Buffer'Length - 2);
-
- for J in 1 .. Buffer_Count loop
- Write (File_In, Buffer);
-
- Fill_Buffer (J, Density);
- end loop;
-
- -- fill remain size.
-
- Write
- (File_In,
- Buffer
- (1 .. Stream_Element_Offset
- (File_Size - Buffer'Length * Buffer_Count)));
-
- Flush (File_In);
- Close (File_In);
- end Generate_File;
-
- ---------------------
- -- Print_Statistic --
- ---------------------
-
- procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count) is
- use Ada.Calendar;
- use Ada.Text_IO;
-
- package Count_IO is new Integer_IO (ZLib.Count);
-
- Curr_Dur : Duration := Clock - Time_Stamp;
- begin
- Put (Msg);
-
- Set_Col (20);
- Ada.Text_IO.Put ("size =");
-
- Count_IO.Put
- (Data_Size,
- Width => Stream_IO.Count'Image (File_Size)'Length);
-
- Put_Line (" duration =" & Duration'Image (Curr_Dur));
- end Print_Statistic;
-
- -----------
- -- Stamp --
- -----------
-
- procedure Stamp is
- begin
- Time_Stamp := Ada.Calendar.Clock;
- end Stamp;
-
-begin
- Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version);
-
- loop
- Generate_File;
-
- for Level in ZLib.Compression_Level'Range loop
-
- Ada.Text_IO.Put_Line ("Level ="
- & ZLib.Compression_Level'Image (Level));
-
- -- Test generic interface.
- Open (File_In, In_File, In_File_Name);
- Create (File_Out, Out_File, Z_File_Name);
-
- Stamp;
-
- -- Deflate using generic instantiation.
-
- ZLib.Deflate_Init
- (Filter => Filter,
- Level => Level,
- Strategy => Strategy,
- Header => Header);
-
- Translate (Filter);
- Print_Statistic ("Generic compress", ZLib.Total_Out (Filter));
- ZLib.Close (Filter);
-
- Close (File_In);
- Close (File_Out);
-
- Open (File_In, In_File, Z_File_Name);
- Create (File_Out, Out_File, Out_File_Name);
-
- Stamp;
-
- -- Inflate using generic instantiation.
-
- ZLib.Inflate_Init (Filter, Header => Header);
-
- Translate (Filter);
- Print_Statistic ("Generic decompress", ZLib.Total_Out (Filter));
-
- ZLib.Close (Filter);
-
- Close (File_In);
- Close (File_Out);
-
- Compare_Files (In_File_Name, Out_File_Name);
-
- -- Test stream interface.
-
- -- Compress to the back stream.
-
- Open (File_In, In_File, In_File_Name);
- Create (File_Back, Out_File, Z_File_Name);
-
- Stamp;
-
- ZLib.Streams.Create
- (Stream => File_Z,
- Mode => ZLib.Streams.Out_Stream,
- Back => ZLib.Streams.Stream_Access
- (Stream (File_Back)),
- Back_Compressed => True,
- Level => Level,
- Strategy => Strategy,
- Header => Header);
-
- Copy_Streams
- (Source => Stream (File_In).all,
- Target => File_Z);
-
- -- Flushing internal buffers to the back stream.
-
- ZLib.Streams.Flush (File_Z, ZLib.Finish);
-
- Print_Statistic ("Write compress",
- ZLib.Streams.Write_Total_Out (File_Z));
-
- ZLib.Streams.Close (File_Z);
-
- Close (File_In);
- Close (File_Back);
-
- -- Compare reading from original file and from
- -- decompression stream.
-
- Open (File_In, In_File, In_File_Name);
- Open (File_Back, In_File, Z_File_Name);
-
- ZLib.Streams.Create
- (Stream => File_Z,
- Mode => ZLib.Streams.In_Stream,
- Back => ZLib.Streams.Stream_Access
- (Stream (File_Back)),
- Back_Compressed => True,
- Header => Header);
-
- Stamp;
- Compare_Streams (Stream (File_In).all, File_Z);
-
- Print_Statistic ("Read decompress",
- ZLib.Streams.Read_Total_Out (File_Z));
-
- ZLib.Streams.Close (File_Z);
- Close (File_In);
- Close (File_Back);
-
- -- Compress by reading from compression stream.
-
- Open (File_Back, In_File, In_File_Name);
- Create (File_Out, Out_File, Z_File_Name);
-
- ZLib.Streams.Create
- (Stream => File_Z,
- Mode => ZLib.Streams.In_Stream,
- Back => ZLib.Streams.Stream_Access
- (Stream (File_Back)),
- Back_Compressed => False,
- Level => Level,
- Strategy => Strategy,
- Header => Header);
-
- Stamp;
- Copy_Streams
- (Source => File_Z,
- Target => Stream (File_Out).all);
-
- Print_Statistic ("Read compress",
- ZLib.Streams.Read_Total_Out (File_Z));
-
- ZLib.Streams.Close (File_Z);
-
- Close (File_Out);
- Close (File_Back);
-
- -- Decompress to decompression stream.
-
- Open (File_In, In_File, Z_File_Name);
- Create (File_Back, Out_File, Out_File_Name);
-
- ZLib.Streams.Create
- (Stream => File_Z,
- Mode => ZLib.Streams.Out_Stream,
- Back => ZLib.Streams.Stream_Access
- (Stream (File_Back)),
- Back_Compressed => False,
- Header => Header);
-
- Stamp;
-
- Copy_Streams
- (Source => Stream (File_In).all,
- Target => File_Z);
-
- Print_Statistic ("Write decompress",
- ZLib.Streams.Write_Total_Out (File_Z));
-
- ZLib.Streams.Close (File_Z);
- Close (File_In);
- Close (File_Back);
-
- Compare_Files (In_File_Name, Out_File_Name);
- end loop;
-
- Ada.Text_IO.Put_Line (Count'Image (File_Size) & " Ok.");
-
- exit when not Continuous;
-
- File_Size := File_Size + 1;
- end loop;
-end Test;
diff --git a/source4/lib/zlib/contrib/ada/zlib-streams.adb b/source4/lib/zlib/contrib/ada/zlib-streams.adb
deleted file mode 100644
index b6497bae28..0000000000
--- a/source4/lib/zlib/contrib/ada/zlib-streams.adb
+++ /dev/null
@@ -1,225 +0,0 @@
-----------------------------------------------------------------
--- ZLib for Ada thick binding. --
--- --
--- Copyright (C) 2002-2003 Dmitriy Anisimkov --
--- --
--- Open source license information is in the zlib.ads file. --
-----------------------------------------------------------------
-
--- $Id: zlib-streams.adb,v 1.10 2004/05/31 10:53:40 vagul Exp $
-
-with Ada.Unchecked_Deallocation;
-
-package body ZLib.Streams is
-
- -----------
- -- Close --
- -----------
-
- procedure Close (Stream : in out Stream_Type) is
- procedure Free is new Ada.Unchecked_Deallocation
- (Stream_Element_Array, Buffer_Access);
- begin
- if Stream.Mode = Out_Stream or Stream.Mode = Duplex then
- -- We should flush the data written by the writer.
-
- Flush (Stream, Finish);
-
- Close (Stream.Writer);
- end if;
-
- if Stream.Mode = In_Stream or Stream.Mode = Duplex then
- Close (Stream.Reader);
- Free (Stream.Buffer);
- end if;
- end Close;
-
- ------------
- -- Create --
- ------------
-
- procedure Create
- (Stream : out Stream_Type;
- Mode : in Stream_Mode;
- Back : in Stream_Access;
- Back_Compressed : in Boolean;
- Level : in Compression_Level := Default_Compression;
- Strategy : in Strategy_Type := Default_Strategy;
- Header : in Header_Type := Default;
- Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset
- := Default_Buffer_Size;
- Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset
- := Default_Buffer_Size)
- is
-
- subtype Buffer_Subtype is Stream_Element_Array (1 .. Read_Buffer_Size);
-
- procedure Init_Filter
- (Filter : in out Filter_Type;
- Compress : in Boolean);
-
- -----------------
- -- Init_Filter --
- -----------------
-
- procedure Init_Filter
- (Filter : in out Filter_Type;
- Compress : in Boolean) is
- begin
- if Compress then
- Deflate_Init
- (Filter, Level, Strategy, Header => Header);
- else
- Inflate_Init (Filter, Header => Header);
- end if;
- end Init_Filter;
-
- begin
- Stream.Back := Back;
- Stream.Mode := Mode;
-
- if Mode = Out_Stream or Mode = Duplex then
- Init_Filter (Stream.Writer, Back_Compressed);
- Stream.Buffer_Size := Write_Buffer_Size;
- else
- Stream.Buffer_Size := 0;
- end if;
-
- if Mode = In_Stream or Mode = Duplex then
- Init_Filter (Stream.Reader, not Back_Compressed);
-
- Stream.Buffer := new Buffer_Subtype;
- Stream.Rest_First := Stream.Buffer'Last + 1;
- Stream.Rest_Last := Stream.Buffer'Last;
- end if;
- end Create;
-
- -----------
- -- Flush --
- -----------
-
- procedure Flush
- (Stream : in out Stream_Type;
- Mode : in Flush_Mode := Sync_Flush)
- is
- Buffer : Stream_Element_Array (1 .. Stream.Buffer_Size);
- Last : Stream_Element_Offset;
- begin
- loop
- Flush (Stream.Writer, Buffer, Last, Mode);
-
- Ada.Streams.Write (Stream.Back.all, Buffer (1 .. Last));
-
- exit when Last < Buffer'Last;
- end loop;
- end Flush;
-
- -------------
- -- Is_Open --
- -------------
-
- function Is_Open (Stream : Stream_Type) return Boolean is
- begin
- return Is_Open (Stream.Reader) or else Is_Open (Stream.Writer);
- end Is_Open;
-
- ----------
- -- Read --
- ----------
-
- procedure Read
- (Stream : in out Stream_Type;
- Item : out Stream_Element_Array;
- Last : out Stream_Element_Offset)
- is
-
- procedure Read
- (Item : out Stream_Element_Array;
- Last : out Stream_Element_Offset);
-
- ----------
- -- Read --
- ----------
-
- procedure Read
- (Item : out Stream_Element_Array;
- Last : out Stream_Element_Offset) is
- begin
- Ada.Streams.Read (Stream.Back.all, Item, Last);
- end Read;
-
- procedure Read is new ZLib.Read
- (Read => Read,
- Buffer => Stream.Buffer.all,
- Rest_First => Stream.Rest_First,
- Rest_Last => Stream.Rest_Last);
-
- begin
- Read (Stream.Reader, Item, Last);
- end Read;
-
- -------------------
- -- Read_Total_In --
- -------------------
-
- function Read_Total_In (Stream : in Stream_Type) return Count is
- begin
- return Total_In (Stream.Reader);
- end Read_Total_In;
-
- --------------------
- -- Read_Total_Out --
- --------------------
-
- function Read_Total_Out (Stream : in Stream_Type) return Count is
- begin
- return Total_Out (Stream.Reader);
- end Read_Total_Out;
-
- -----------
- -- Write --
- -----------
-
- procedure Write
- (Stream : in out Stream_Type;
- Item : in Stream_Element_Array)
- is
-
- procedure Write (Item : in Stream_Element_Array);
-
- -----------
- -- Write --
- -----------
-
- procedure Write (Item : in Stream_Element_Array) is
- begin
- Ada.Streams.Write (Stream.Back.all, Item);
- end Write;
-
- procedure Write is new ZLib.Write
- (Write => Write,
- Buffer_Size => Stream.Buffer_Size);
-
- begin
- Write (Stream.Writer, Item, No_Flush);
- end Write;
-
- --------------------
- -- Write_Total_In --
- --------------------
-
- function Write_Total_In (Stream : in Stream_Type) return Count is
- begin
- return Total_In (Stream.Writer);
- end Write_Total_In;
-
- ---------------------
- -- Write_Total_Out --
- ---------------------
-
- function Write_Total_Out (Stream : in Stream_Type) return Count is
- begin
- return Total_Out (Stream.Writer);
- end Write_Total_Out;
-
-end ZLib.Streams;
diff --git a/source4/lib/zlib/contrib/ada/zlib-streams.ads b/source4/lib/zlib/contrib/ada/zlib-streams.ads
deleted file mode 100644
index f0193c6bae..0000000000
--- a/source4/lib/zlib/contrib/ada/zlib-streams.ads
+++ /dev/null
@@ -1,114 +0,0 @@
-----------------------------------------------------------------
--- ZLib for Ada thick binding. --
--- --
--- Copyright (C) 2002-2003 Dmitriy Anisimkov --
--- --
--- Open source license information is in the zlib.ads file. --
-----------------------------------------------------------------
-
--- $Id: zlib-streams.ads,v 1.12 2004/05/31 10:53:40 vagul Exp $
-
-package ZLib.Streams is
-
- type Stream_Mode is (In_Stream, Out_Stream, Duplex);
-
- type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
-
- type Stream_Type is
- new Ada.Streams.Root_Stream_Type with private;
-
- procedure Read
- (Stream : in out Stream_Type;
- Item : out Ada.Streams.Stream_Element_Array;
- Last : out Ada.Streams.Stream_Element_Offset);
-
- procedure Write
- (Stream : in out Stream_Type;
- Item : in Ada.Streams.Stream_Element_Array);
-
- procedure Flush
- (Stream : in out Stream_Type;
- Mode : in Flush_Mode := Sync_Flush);
- -- Flush the written data to the back stream,
- -- all data placed to the compressor is flushing to the Back stream.
- -- Should not be used untill necessary, becouse it is decreasing
- -- compression.
-
- function Read_Total_In (Stream : in Stream_Type) return Count;
- pragma Inline (Read_Total_In);
- -- Return total number of bytes read from back stream so far.
-
- function Read_Total_Out (Stream : in Stream_Type) return Count;
- pragma Inline (Read_Total_Out);
- -- Return total number of bytes read so far.
-
- function Write_Total_In (Stream : in Stream_Type) return Count;
- pragma Inline (Write_Total_In);
- -- Return total number of bytes written so far.
-
- function Write_Total_Out (Stream : in Stream_Type) return Count;
- pragma Inline (Write_Total_Out);
- -- Return total number of bytes written to the back stream.
-
- procedure Create
- (Stream : out Stream_Type;
- Mode : in Stream_Mode;
- Back : in Stream_Access;
- Back_Compressed : in Boolean;
- Level : in Compression_Level := Default_Compression;
- Strategy : in Strategy_Type := Default_Strategy;
- Header : in Header_Type := Default;
- Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset
- := Default_Buffer_Size;
- Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset
- := Default_Buffer_Size);
- -- Create the Comression/Decompression stream.
- -- If mode is In_Stream then Write operation is disabled.
- -- If mode is Out_Stream then Read operation is disabled.
-
- -- If Back_Compressed is true then
- -- Data written to the Stream is compressing to the Back stream
- -- and data read from the Stream is decompressed data from the Back stream.
-
- -- If Back_Compressed is false then
- -- Data written to the Stream is decompressing to the Back stream
- -- and data read from the Stream is compressed data from the Back stream.
-
- -- !!! When the Need_Header is False ZLib-Ada is using undocumented
- -- ZLib 1.1.4 functionality to do not create/wait for ZLib headers.
-
- function Is_Open (Stream : Stream_Type) return Boolean;
-
- procedure Close (Stream : in out Stream_Type);
-
-private
-
- use Ada.Streams;
-
- type Buffer_Access is access all Stream_Element_Array;
-
- type Stream_Type
- is new Root_Stream_Type with
- record
- Mode : Stream_Mode;
-
- Buffer : Buffer_Access;
- Rest_First : Stream_Element_Offset;
- Rest_Last : Stream_Element_Offset;
- -- Buffer for Read operation.
- -- We need to have this buffer in the record
- -- becouse not all read data from back stream
- -- could be processed during the read operation.
-
- Buffer_Size : Stream_Element_Offset;
- -- Buffer size for write operation.
- -- We do not need to have this buffer
- -- in the record becouse all data could be
- -- processed in the write operation.
-
- Back : Stream_Access;
- Reader : Filter_Type;
- Writer : Filter_Type;
- end record;
-
-end ZLib.Streams;
diff --git a/source4/lib/zlib/contrib/ada/zlib-thin.adb b/source4/lib/zlib/contrib/ada/zlib-thin.adb
deleted file mode 100644
index 0ca4a71204..0000000000
--- a/source4/lib/zlib/contrib/ada/zlib-thin.adb
+++ /dev/null
@@ -1,141 +0,0 @@
-----------------------------------------------------------------
--- ZLib for Ada thick binding. --
--- --
--- Copyright (C) 2002-2003 Dmitriy Anisimkov --
--- --
--- Open source license information is in the zlib.ads file. --
-----------------------------------------------------------------
-
--- $Id: zlib-thin.adb,v 1.8 2003/12/14 18:27:31 vagul Exp $
-
-package body ZLib.Thin is
-
- ZLIB_VERSION : constant Chars_Ptr := zlibVersion;
-
- Z_Stream_Size : constant Int := Z_Stream'Size / System.Storage_Unit;
-
- --------------
- -- Avail_In --
- --------------
-
- function Avail_In (Strm : in Z_Stream) return UInt is
- begin
- return Strm.Avail_In;
- end Avail_In;
-
- ---------------
- -- Avail_Out --
- ---------------
-
- function Avail_Out (Strm : in Z_Stream) return UInt is
- begin
- return Strm.Avail_Out;
- end Avail_Out;
-
- ------------------
- -- Deflate_Init --
- ------------------
-
- function Deflate_Init
- (strm : Z_Streamp;
- level : Int;
- method : Int;
- windowBits : Int;
- memLevel : Int;
- strategy : Int)
- return Int is
- begin
- return deflateInit2
- (strm,
- level,
- method,
- windowBits,
- memLevel,
- strategy,
- ZLIB_VERSION,
- Z_Stream_Size);
- end Deflate_Init;
-
- ------------------
- -- Inflate_Init --
- ------------------
-
- function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int is
- begin
- return inflateInit2 (strm, windowBits, ZLIB_VERSION, Z_Stream_Size);
- end Inflate_Init;
-
- ------------------------
- -- Last_Error_Message --
- ------------------------
-
- function Last_Error_Message (Strm : in Z_Stream) return String is
- use Interfaces.C.Strings;
- begin
- if Strm.msg = Null_Ptr then
- return "";
- else
- return Value (Strm.msg);
- end if;
- end Last_Error_Message;
-
- ------------
- -- Set_In --
- ------------
-
- procedure Set_In
- (Strm : in out Z_Stream;
- Buffer : in Voidp;
- Size : in UInt) is
- begin
- Strm.Next_In := Buffer;
- Strm.Avail_In := Size;
- end Set_In;
-
- ------------------
- -- Set_Mem_Func --
- ------------------
-
- procedure Set_Mem_Func
- (Strm : in out Z_Stream;
- Opaque : in Voidp;
- Alloc : in alloc_func;
- Free : in free_func) is
- begin
- Strm.opaque := Opaque;
- Strm.zalloc := Alloc;
- Strm.zfree := Free;
- end Set_Mem_Func;
-
- -------------
- -- Set_Out --
- -------------
-
- procedure Set_Out
- (Strm : in out Z_Stream;
- Buffer : in Voidp;
- Size : in UInt) is
- begin
- Strm.Next_Out := Buffer;
- Strm.Avail_Out := Size;
- end Set_Out;
-
- --------------
- -- Total_In --
- --------------
-
- function Total_In (Strm : in Z_Stream) return ULong is
- begin
- return Strm.Total_In;
- end Total_In;
-
- ---------------
- -- Total_Out --
- ---------------
-
- function Total_Out (Strm : in Z_Stream) return ULong is
- begin
- return Strm.Total_Out;
- end Total_Out;
-
-end ZLib.Thin;
diff --git a/source4/lib/zlib/contrib/ada/zlib-thin.ads b/source4/lib/zlib/contrib/ada/zlib-thin.ads
deleted file mode 100644
index d4407eb800..0000000000
--- a/source4/lib/zlib/contrib/ada/zlib-thin.ads
+++ /dev/null
@@ -1,450 +0,0 @@
-----------------------------------------------------------------
--- ZLib for Ada thick binding. --
--- --
--- Copyright (C) 2002-2003 Dmitriy Anisimkov --
--- --
--- Open source license information is in the zlib.ads file. --
-----------------------------------------------------------------
-
--- $Id: zlib-thin.ads,v 1.11 2004/07/23 06:33:11 vagul Exp $
-
-with Interfaces.C.Strings;
-
-with System;
-
-private package ZLib.Thin is
-
- -- From zconf.h
-
- MAX_MEM_LEVEL : constant := 9; -- zconf.h:105
- -- zconf.h:105
- MAX_WBITS : constant := 15; -- zconf.h:115
- -- 32K LZ77 window
- -- zconf.h:115
- SEEK_SET : constant := 8#0000#; -- zconf.h:244
- -- Seek from beginning of file.
- -- zconf.h:244
- SEEK_CUR : constant := 1; -- zconf.h:245
- -- Seek from current position.
- -- zconf.h:245
- SEEK_END : constant := 2; -- zconf.h:246
- -- Set file pointer to EOF plus "offset"
- -- zconf.h:246
-
- type Byte is new Interfaces.C.unsigned_char; -- 8 bits
- -- zconf.h:214
- type UInt is new Interfaces.C.unsigned; -- 16 bits or more
- -- zconf.h:216
- type Int is new Interfaces.C.int;
-
- type ULong is new Interfaces.C.unsigned_long; -- 32 bits or more
- -- zconf.h:217
- subtype Chars_Ptr is Interfaces.C.Strings.chars_ptr;
-
- type ULong_Access is access ULong;
- type Int_Access is access Int;
-
- subtype Voidp is System.Address; -- zconf.h:232
-
- subtype Byte_Access is Voidp;
-
- Nul : constant Voidp := System.Null_Address;
- -- end from zconf
-
- Z_NO_FLUSH : constant := 8#0000#; -- zlib.h:125
- -- zlib.h:125
- Z_PARTIAL_FLUSH : constant := 1; -- zlib.h:126
- -- will be removed, use
- -- Z_SYNC_FLUSH instead
- -- zlib.h:126
- Z_SYNC_FLUSH : constant := 2; -- zlib.h:127
- -- zlib.h:127
- Z_FULL_FLUSH : constant := 3; -- zlib.h:128
- -- zlib.h:128
- Z_FINISH : constant := 4; -- zlib.h:129
- -- zlib.h:129
- Z_OK : constant := 8#0000#; -- zlib.h:132
- -- zlib.h:132
- Z_STREAM_END : constant := 1; -- zlib.h:133
- -- zlib.h:133
- Z_NEED_DICT : constant := 2; -- zlib.h:134
- -- zlib.h:134
- Z_ERRNO : constant := -1; -- zlib.h:135
- -- zlib.h:135
- Z_STREAM_ERROR : constant := -2; -- zlib.h:136
- -- zlib.h:136
- Z_DATA_ERROR : constant := -3; -- zlib.h:137
- -- zlib.h:137
- Z_MEM_ERROR : constant := -4; -- zlib.h:138
- -- zlib.h:138
- Z_BUF_ERROR : constant := -5; -- zlib.h:139
- -- zlib.h:139
- Z_VERSION_ERROR : constant := -6; -- zlib.h:140
- -- zlib.h:140
- Z_NO_COMPRESSION : constant := 8#0000#; -- zlib.h:145
- -- zlib.h:145
- Z_BEST_SPEED : constant := 1; -- zlib.h:146
- -- zlib.h:146
- Z_BEST_COMPRESSION : constant := 9; -- zlib.h:147
- -- zlib.h:147
- Z_DEFAULT_COMPRESSION : constant := -1; -- zlib.h:148
- -- zlib.h:148
- Z_FILTERED : constant := 1; -- zlib.h:151
- -- zlib.h:151
- Z_HUFFMAN_ONLY : constant := 2; -- zlib.h:152
- -- zlib.h:152
- Z_DEFAULT_STRATEGY : constant := 8#0000#; -- zlib.h:153
- -- zlib.h:153
- Z_BINARY : constant := 8#0000#; -- zlib.h:156
- -- zlib.h:156
- Z_ASCII : constant := 1; -- zlib.h:157
- -- zlib.h:157
- Z_UNKNOWN : constant := 2; -- zlib.h:158
- -- zlib.h:158
- Z_DEFLATED : constant := 8; -- zlib.h:161
- -- zlib.h:161
- Z_NULL : constant := 8#0000#; -- zlib.h:164
- -- for initializing zalloc, zfree, opaque
- -- zlib.h:164
- type gzFile is new Voidp; -- zlib.h:646
-
- type Z_Stream is private;
-
- type Z_Streamp is access all Z_Stream; -- zlib.h:89
-
- type alloc_func is access function
- (Opaque : Voidp;
- Items : UInt;
- Size : UInt)
- return Voidp; -- zlib.h:63
-
- type free_func is access procedure (opaque : Voidp; address : Voidp);
-
- function zlibVersion return Chars_Ptr;
-
- function Deflate (strm : Z_Streamp; flush : Int) return Int;
-
- function DeflateEnd (strm : Z_Streamp) return Int;
-
- function Inflate (strm : Z_Streamp; flush : Int) return Int;
-
- function InflateEnd (strm : Z_Streamp) return Int;
-
- function deflateSetDictionary
- (strm : Z_Streamp;
- dictionary : Byte_Access;
- dictLength : UInt)
- return Int;
-
- function deflateCopy (dest : Z_Streamp; source : Z_Streamp) return Int;
- -- zlib.h:478
-
- function deflateReset (strm : Z_Streamp) return Int; -- zlib.h:495
-
- function deflateParams
- (strm : Z_Streamp;
- level : Int;
- strategy : Int)
- return Int; -- zlib.h:506
-
- function inflateSetDictionary
- (strm : Z_Streamp;
- dictionary : Byte_Access;
- dictLength : UInt)
- return Int; -- zlib.h:548
-
- function inflateSync (strm : Z_Streamp) return Int; -- zlib.h:565
-
- function inflateReset (strm : Z_Streamp) return Int; -- zlib.h:580
-
- function compress
- (dest : Byte_Access;
- destLen : ULong_Access;
- source : Byte_Access;
- sourceLen : ULong)
- return Int; -- zlib.h:601
-
- function compress2
- (dest : Byte_Access;
- destLen : ULong_Access;
- source : Byte_Access;
- sourceLen : ULong;
- level : Int)
- return Int; -- zlib.h:615
-
- function uncompress
- (dest : Byte_Access;
- destLen : ULong_Access;
- source : Byte_Access;
- sourceLen : ULong)
- return Int;
-
- function gzopen (path : Chars_Ptr; mode : Chars_Ptr) return gzFile;
-
- function gzdopen (fd : Int; mode : Chars_Ptr) return gzFile;
-
- function gzsetparams
- (file : gzFile;
- level : Int;
- strategy : Int)
- return Int;
-
- function gzread
- (file : gzFile;
- buf : Voidp;
- len : UInt)
- return Int;
-
- function gzwrite
- (file : in gzFile;
- buf : in Voidp;
- len : in UInt)
- return Int;
-
- function gzprintf (file : in gzFile; format : in Chars_Ptr) return Int;
-
- function gzputs (file : in gzFile; s : in Chars_Ptr) return Int;
-
- function gzgets
- (file : gzFile;
- buf : Chars_Ptr;
- len : Int)
- return Chars_Ptr;
-
- function gzputc (file : gzFile; char : Int) return Int;
-
- function gzgetc (file : gzFile) return Int;
-
- function gzflush (file : gzFile; flush : Int) return Int;
-
- function gzseek
- (file : gzFile;
- offset : Int;
- whence : Int)
- return Int;
-
- function gzrewind (file : gzFile) return Int;
-
- function gztell (file : gzFile) return Int;
-
- function gzeof (file : gzFile) return Int;
-
- function gzclose (file : gzFile) return Int;
-
- function gzerror (file : gzFile; errnum : Int_Access) return Chars_Ptr;
-
- function adler32
- (adler : ULong;
- buf : Byte_Access;
- len : UInt)
- return ULong;
-
- function crc32
- (crc : ULong;
- buf : Byte_Access;
- len : UInt)
- return ULong;
-
- function deflateInit
- (strm : Z_Streamp;
- level : Int;
- version : Chars_Ptr;
- stream_size : Int)
- return Int;
-
- function deflateInit2
- (strm : Z_Streamp;
- level : Int;
- method : Int;
- windowBits : Int;
- memLevel : Int;
- strategy : Int;
- version : Chars_Ptr;
- stream_size : Int)
- return Int;
-
- function Deflate_Init
- (strm : Z_Streamp;
- level : Int;
- method : Int;
- windowBits : Int;
- memLevel : Int;
- strategy : Int)
- return Int;
- pragma Inline (Deflate_Init);
-
- function inflateInit
- (strm : Z_Streamp;
- version : Chars_Ptr;
- stream_size : Int)
- return Int;
-
- function inflateInit2
- (strm : in Z_Streamp;
- windowBits : in Int;
- version : in Chars_Ptr;
- stream_size : in Int)
- return Int;
-
- function inflateBackInit
- (strm : in Z_Streamp;
- windowBits : in Int;
- window : in Byte_Access;
- version : in Chars_Ptr;
- stream_size : in Int)
- return Int;
- -- Size of window have to be 2**windowBits.
-
- function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int;
- pragma Inline (Inflate_Init);
-
- function zError (err : Int) return Chars_Ptr;
-
- function inflateSyncPoint (z : Z_Streamp) return Int;
-
- function get_crc_table return ULong_Access;
-
- -- Interface to the available fields of the z_stream structure.
- -- The application must update next_in and avail_in when avail_in has
- -- dropped to zero. It must update next_out and avail_out when avail_out
- -- has dropped to zero. The application must initialize zalloc, zfree and
- -- opaque before calling the init function.
-
- procedure Set_In
- (Strm : in out Z_Stream;
- Buffer : in Voidp;
- Size : in UInt);
- pragma Inline (Set_In);
-
- procedure Set_Out
- (Strm : in out Z_Stream;
- Buffer : in Voidp;
- Size : in UInt);
- pragma Inline (Set_Out);
-
- procedure Set_Mem_Func
- (Strm : in out Z_Stream;
- Opaque : in Voidp;
- Alloc : in alloc_func;
- Free : in free_func);
- pragma Inline (Set_Mem_Func);
-
- function Last_Error_Message (Strm : in Z_Stream) return String;
- pragma Inline (Last_Error_Message);
-
- function Avail_Out (Strm : in Z_Stream) return UInt;
- pragma Inline (Avail_Out);
-
- function Avail_In (Strm : in Z_Stream) return UInt;
- pragma Inline (Avail_In);
-
- function Total_In (Strm : in Z_Stream) return ULong;
- pragma Inline (Total_In);
-
- function Total_Out (Strm : in Z_Stream) return ULong;
- pragma Inline (Total_Out);
-
- function inflateCopy
- (dest : in Z_Streamp;
- Source : in Z_Streamp)
- return Int;
-
- function compressBound (Source_Len : in ULong) return ULong;
-
- function deflateBound
- (Strm : in Z_Streamp;
- Source_Len : in ULong)
- return ULong;
-
- function gzungetc (C : in Int; File : in gzFile) return Int;
-
- function zlibCompileFlags return ULong;
-
-private
-
- type Z_Stream is record -- zlib.h:68
- Next_In : Voidp := Nul; -- next input byte
- Avail_In : UInt := 0; -- number of bytes available at next_in
- Total_In : ULong := 0; -- total nb of input bytes read so far
- Next_Out : Voidp := Nul; -- next output byte should be put there
- Avail_Out : UInt := 0; -- remaining free space at next_out
- Total_Out : ULong := 0; -- total nb of bytes output so far
- msg : Chars_Ptr; -- last error message, NULL if no error
- state : Voidp; -- not visible by applications
- zalloc : alloc_func := null; -- used to allocate the internal state
- zfree : free_func := null; -- used to free the internal state
- opaque : Voidp; -- private data object passed to
- -- zalloc and zfree
- data_type : Int; -- best guess about the data type:
- -- ascii or binary
- adler : ULong; -- adler32 value of the uncompressed
- -- data
- reserved : ULong; -- reserved for future use
- end record;
-
- pragma Convention (C, Z_Stream);
-
- pragma Import (C, zlibVersion, "zlibVersion");
- pragma Import (C, Deflate, "deflate");
- pragma Import (C, DeflateEnd, "deflateEnd");
- pragma Import (C, Inflate, "inflate");
- pragma Import (C, InflateEnd, "inflateEnd");
- pragma Import (C, deflateSetDictionary, "deflateSetDictionary");
- pragma Import (C, deflateCopy, "deflateCopy");
- pragma Import (C, deflateReset, "deflateReset");
- pragma Import (C, deflateParams, "deflateParams");
- pragma Import (C, inflateSetDictionary, "inflateSetDictionary");
- pragma Import (C, inflateSync, "inflateSync");
- pragma Import (C, inflateReset, "inflateReset");
- pragma Import (C, compress, "compress");
- pragma Import (C, compress2, "compress2");
- pragma Import (C, uncompress, "uncompress");
- pragma Import (C, gzopen, "gzopen");
- pragma Import (C, gzdopen, "gzdopen");
- pragma Import (C, gzsetparams, "gzsetparams");
- pragma Import (C, gzread, "gzread");
- pragma Import (C, gzwrite, "gzwrite");
- pragma Import (C, gzprintf, "gzprintf");
- pragma Import (C, gzputs, "gzputs");
- pragma Import (C, gzgets, "gzgets");
- pragma Import (C, gzputc, "gzputc");
- pragma Import (C, gzgetc, "gzgetc");
- pragma Import (C, gzflush, "gzflush");
- pragma Import (C, gzseek, "gzseek");
- pragma Import (C, gzrewind, "gzrewind");
- pragma Import (C, gztell, "gztell");
- pragma Import (C, gzeof, "gzeof");
- pragma Import (C, gzclose, "gzclose");
- pragma Import (C, gzerror, "gzerror");
- pragma Import (C, adler32, "adler32");
- pragma Import (C, crc32, "crc32");
- pragma Import (C, deflateInit, "deflateInit_");
- pragma Import (C, inflateInit, "inflateInit_");
- pragma Import (C, deflateInit2, "deflateInit2_");
- pragma Import (C, inflateInit2, "inflateInit2_");
- pragma Import (C, zError, "zError");
- pragma Import (C, inflateSyncPoint, "inflateSyncPoint");
- pragma Import (C, get_crc_table, "get_crc_table");
-
- -- since zlib 1.2.0:
-
- pragma Import (C, inflateCopy, "inflateCopy");
- pragma Import (C, compressBound, "compressBound");
- pragma Import (C, deflateBound, "deflateBound");
- pragma Import (C, gzungetc, "gzungetc");
- pragma Import (C, zlibCompileFlags, "zlibCompileFlags");
-
- pragma Import (C, inflateBackInit, "inflateBackInit_");
-
- -- I stopped binding the inflateBack routines, becouse realize that
- -- it does not support zlib and gzip headers for now, and have no
- -- symmetric deflateBack routines.
- -- ZLib-Ada is symmetric regarding deflate/inflate data transformation
- -- and has a similar generic callback interface for the
- -- deflate/inflate transformation based on the regular Deflate/Inflate
- -- routines.
-
- -- pragma Import (C, inflateBack, "inflateBack");
- -- pragma Import (C, inflateBackEnd, "inflateBackEnd");
-
-end ZLib.Thin;
diff --git a/source4/lib/zlib/contrib/ada/zlib.adb b/source4/lib/zlib/contrib/ada/zlib.adb
deleted file mode 100644
index 8b6fd686ac..0000000000
--- a/source4/lib/zlib/contrib/ada/zlib.adb
+++ /dev/null
@@ -1,701 +0,0 @@
-----------------------------------------------------------------
--- ZLib for Ada thick binding. --
--- --
--- Copyright (C) 2002-2004 Dmitriy Anisimkov --
--- --
--- Open source license information is in the zlib.ads file. --
-----------------------------------------------------------------
-
--- $Id: zlib.adb,v 1.31 2004/09/06 06:53:19 vagul Exp $
-
-with Ada.Exceptions;
-with Ada.Unchecked_Conversion;
-with Ada.Unchecked_Deallocation;
-
-with Interfaces.C.Strings;
-
-with ZLib.Thin;
-
-package body ZLib is
-
- use type Thin.Int;
-
- type Z_Stream is new Thin.Z_Stream;
-
- type Return_Code_Enum is
- (OK,
- STREAM_END,
- NEED_DICT,
- ERRNO,
- STREAM_ERROR,
- DATA_ERROR,
- MEM_ERROR,
- BUF_ERROR,
- VERSION_ERROR);
-
- type Flate_Step_Function is access
- function (Strm : in Thin.Z_Streamp; Flush : in Thin.Int) return Thin.Int;
- pragma Convention (C, Flate_Step_Function);
-
- type Flate_End_Function is access
- function (Ctrm : in Thin.Z_Streamp) return Thin.Int;
- pragma Convention (C, Flate_End_Function);
-
- type Flate_Type is record
- Step : Flate_Step_Function;
- Done : Flate_End_Function;
- end record;
-
- subtype Footer_Array is Stream_Element_Array (1 .. 8);
-
- Simple_GZip_Header : constant Stream_Element_Array (1 .. 10)
- := (16#1f#, 16#8b#, -- Magic header
- 16#08#, -- Z_DEFLATED
- 16#00#, -- Flags
- 16#00#, 16#00#, 16#00#, 16#00#, -- Time
- 16#00#, -- XFlags
- 16#03# -- OS code
- );
- -- The simplest gzip header is not for informational, but just for
- -- gzip format compatibility.
- -- Note that some code below is using assumption
- -- Simple_GZip_Header'Last > Footer_Array'Last, so do not make
- -- Simple_GZip_Header'Last <= Footer_Array'Last.
-
- Return_Code : constant array (Thin.Int range <>) of Return_Code_Enum
- := (0 => OK,
- 1 => STREAM_END,
- 2 => NEED_DICT,
- -1 => ERRNO,
- -2 => STREAM_ERROR,
- -3 => DATA_ERROR,
- -4 => MEM_ERROR,
- -5 => BUF_ERROR,
- -6 => VERSION_ERROR);
-
- Flate : constant array (Boolean) of Flate_Type
- := (True => (Step => Thin.Deflate'Access,
- Done => Thin.DeflateEnd'Access),
- False => (Step => Thin.Inflate'Access,
- Done => Thin.InflateEnd'Access));
-
- Flush_Finish : constant array (Boolean) of Flush_Mode
- := (True => Finish, False => No_Flush);
-
- procedure Raise_Error (Stream : in Z_Stream);
- pragma Inline (Raise_Error);
-
- procedure Raise_Error (Message : in String);
- pragma Inline (Raise_Error);
-
- procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int);
-
- procedure Free is new Ada.Unchecked_Deallocation
- (Z_Stream, Z_Stream_Access);
-
- function To_Thin_Access is new Ada.Unchecked_Conversion
- (Z_Stream_Access, Thin.Z_Streamp);
-
- procedure Translate_GZip
- (Filter : in out Filter_Type;
- In_Data : in Ada.Streams.Stream_Element_Array;
- In_Last : out Ada.Streams.Stream_Element_Offset;
- Out_Data : out Ada.Streams.Stream_Element_Array;
- Out_Last : out Ada.Streams.Stream_Element_Offset;
- Flush : in Flush_Mode);
- -- Separate translate routine for make gzip header.
-
- procedure Translate_Auto
- (Filter : in out Filter_Type;
- In_Data : in Ada.Streams.Stream_Element_Array;
- In_Last : out Ada.Streams.Stream_Element_Offset;
- Out_Data : out Ada.Streams.Stream_Element_Array;
- Out_Last : out Ada.Streams.Stream_Element_Offset;
- Flush : in Flush_Mode);
- -- translate routine without additional headers.
-
- -----------------
- -- Check_Error --
- -----------------
-
- procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int) is
- use type Thin.Int;
- begin
- if Code /= Thin.Z_OK then
- Raise_Error
- (Return_Code_Enum'Image (Return_Code (Code))
- & ": " & Last_Error_Message (Stream));
- end if;
- end Check_Error;
-
- -----------
- -- Close --
- -----------
-
- procedure Close
- (Filter : in out Filter_Type;
- Ignore_Error : in Boolean := False)
- is
- Code : Thin.Int;
- begin
- if not Ignore_Error and then not Is_Open (Filter) then
- raise Status_Error;
- end if;
-
- Code := Flate (Filter.Compression).Done (To_Thin_Access (Filter.Strm));
-
- if Ignore_Error or else Code = Thin.Z_OK then
- Free (Filter.Strm);
- else
- declare
- Error_Message : constant String
- := Last_Error_Message (Filter.Strm.all);
- begin
- Free (Filter.Strm);
- Ada.Exceptions.Raise_Exception
- (ZLib_Error'Identity,
- Return_Code_Enum'Image (Return_Code (Code))
- & ": " & Error_Message);
- end;
- end if;
- end Close;
-
- -----------
- -- CRC32 --
- -----------
-
- function CRC32
- (CRC : in Unsigned_32;
- Data : in Ada.Streams.Stream_Element_Array)
- return Unsigned_32
- is
- use Thin;
- begin
- return Unsigned_32 (crc32 (ULong (CRC),
- Data'Address,
- Data'Length));
- end CRC32;
-
- procedure CRC32
- (CRC : in out Unsigned_32;
- Data : in Ada.Streams.Stream_Element_Array) is
- begin
- CRC := CRC32 (CRC, Data);
- end CRC32;
-
- ------------------
- -- Deflate_Init --
- ------------------
-
- procedure Deflate_Init
- (Filter : in out Filter_Type;
- Level : in Compression_Level := Default_Compression;
- Strategy : in Strategy_Type := Default_Strategy;
- Method : in Compression_Method := Deflated;
- Window_Bits : in Window_Bits_Type := Default_Window_Bits;
- Memory_Level : in Memory_Level_Type := Default_Memory_Level;
- Header : in Header_Type := Default)
- is
- use type Thin.Int;
- Win_Bits : Thin.Int := Thin.Int (Window_Bits);
- begin
- if Is_Open (Filter) then
- raise Status_Error;
- end if;
-
- -- We allow ZLib to make header only in case of default header type.
- -- Otherwise we would either do header by ourselfs, or do not do
- -- header at all.
-
- if Header = None or else Header = GZip then
- Win_Bits := -Win_Bits;
- end if;
-
- -- For the GZip CRC calculation and make headers.
-
- if Header = GZip then
- Filter.CRC := 0;
- Filter.Offset := Simple_GZip_Header'First;
- else
- Filter.Offset := Simple_GZip_Header'Last + 1;
- end if;
-
- Filter.Strm := new Z_Stream;
- Filter.Compression := True;
- Filter.Stream_End := False;
- Filter.Header := Header;
-
- if Thin.Deflate_Init
- (To_Thin_Access (Filter.Strm),
- Level => Thin.Int (Level),
- method => Thin.Int (Method),
- windowBits => Win_Bits,
- memLevel => Thin.Int (Memory_Level),
- strategy => Thin.Int (Strategy)) /= Thin.Z_OK
- then
- Raise_Error (Filter.Strm.all);
- end if;
- end Deflate_Init;
-
- -----------
- -- Flush --
- -----------
-
- procedure Flush
- (Filter : in out Filter_Type;
- Out_Data : out Ada.Streams.Stream_Element_Array;
- Out_Last : out Ada.Streams.Stream_Element_Offset;
- Flush : in Flush_Mode)
- is
- No_Data : Stream_Element_Array := (1 .. 0 => 0);
- Last : Stream_Element_Offset;
- begin
- Translate (Filter, No_Data, Last, Out_Data, Out_Last, Flush);
- end Flush;
-
- -----------------------
- -- Generic_Translate --
- -----------------------
-
- procedure Generic_Translate
- (Filter : in out ZLib.Filter_Type;
- In_Buffer_Size : in Integer := Default_Buffer_Size;
- Out_Buffer_Size : in Integer := Default_Buffer_Size)
- is
- In_Buffer : Stream_Element_Array
- (1 .. Stream_Element_Offset (In_Buffer_Size));
- Out_Buffer : Stream_Element_Array
- (1 .. Stream_Element_Offset (Out_Buffer_Size));
- Last : Stream_Element_Offset;
- In_Last : Stream_Element_Offset;
- In_First : Stream_Element_Offset;
- Out_Last : Stream_Element_Offset;
- begin
- Main : loop
- Data_In (In_Buffer, Last);
-
- In_First := In_Buffer'First;
-
- loop
- Translate
- (Filter => Filter,
- In_Data => In_Buffer (In_First .. Last),
- In_Last => In_Last,
- Out_Data => Out_Buffer,
- Out_Last => Out_Last,
- Flush => Flush_Finish (Last < In_Buffer'First));
-
- if Out_Buffer'First <= Out_Last then
- Data_Out (Out_Buffer (Out_Buffer'First .. Out_Last));
- end if;
-
- exit Main when Stream_End (Filter);
-
- -- The end of in buffer.
-
- exit when In_Last = Last;
-
- In_First := In_Last + 1;
- end loop;
- end loop Main;
-
- end Generic_Translate;
-
- ------------------
- -- Inflate_Init --
- ------------------
-
- procedure Inflate_Init
- (Filter : in out Filter_Type;
- Window_Bits : in Window_Bits_Type := Default_Window_Bits;
- Header : in Header_Type := Default)
- is
- use type Thin.Int;
- Win_Bits : Thin.Int := Thin.Int (Window_Bits);
-
- procedure Check_Version;
- -- Check the latest header types compatibility.
-
- procedure Check_Version is
- begin
- if Version <= "1.1.4" then
- Raise_Error
- ("Inflate header type " & Header_Type'Image (Header)
- & " incompatible with ZLib version " & Version);
- end if;
- end Check_Version;
-
- begin
- if Is_Open (Filter) then
- raise Status_Error;
- end if;
-
- case Header is
- when None =>
- Check_Version;
-
- -- Inflate data without headers determined
- -- by negative Win_Bits.
-
- Win_Bits := -Win_Bits;
- when GZip =>
- Check_Version;
-
- -- Inflate gzip data defined by flag 16.
-
- Win_Bits := Win_Bits + 16;
- when Auto =>
- Check_Version;
-
- -- Inflate with automatic detection
- -- of gzip or native header defined by flag 32.
-
- Win_Bits := Win_Bits + 32;
- when Default => null;
- end case;
-
- Filter.Strm := new Z_Stream;
- Filter.Compression := False;
- Filter.Stream_End := False;
- Filter.Header := Header;
-
- if Thin.Inflate_Init
- (To_Thin_Access (Filter.Strm), Win_Bits) /= Thin.Z_OK
- then
- Raise_Error (Filter.Strm.all);
- end if;
- end Inflate_Init;
-
- -------------
- -- Is_Open --
- -------------
-
- function Is_Open (Filter : in Filter_Type) return Boolean is
- begin
- return Filter.Strm /= null;
- end Is_Open;
-
- -----------------
- -- Raise_Error --
- -----------------
-
- procedure Raise_Error (Message : in String) is
- begin
- Ada.Exceptions.Raise_Exception (ZLib_Error'Identity, Message);
- end Raise_Error;
-
- procedure Raise_Error (Stream : in Z_Stream) is
- begin
- Raise_Error (Last_Error_Message (Stream));
- end Raise_Error;
-
- ----------
- -- Read --
- ----------
-
- procedure Read
- (Filter : in out Filter_Type;
- Item : out Ada.Streams.Stream_Element_Array;
- Last : out Ada.Streams.Stream_Element_Offset;
- Flush : in Flush_Mode := No_Flush)
- is
- In_Last : Stream_Element_Offset;
- Item_First : Ada.Streams.Stream_Element_Offset := Item'First;
- V_Flush : Flush_Mode := Flush;
-
- begin
- pragma Assert (Rest_First in Buffer'First .. Buffer'Last + 1);
- pragma Assert (Rest_Last in Buffer'First - 1 .. Buffer'Last);
-
- loop
- if Rest_Last = Buffer'First - 1 then
- V_Flush := Finish;
-
- elsif Rest_First > Rest_Last then
- Read (Buffer, Rest_Last);
- Rest_First := Buffer'First;
-
- if Rest_Last < Buffer'First then
- V_Flush := Finish;
- end if;
- end if;
-
- Translate
- (Filter => Filter,
- In_Data => Buffer (Rest_First .. Rest_Last),
- In_Last => In_Last,
- Out_Data => Item (Item_First .. Item'Last),
- Out_Last => Last,
- Flush => V_Flush);
-
- Rest_First := In_Last + 1;
-
- exit when Stream_End (Filter)
- or else Last = Item'Last
- or else (Last >= Item'First and then Allow_Read_Some);
-
- Item_First := Last + 1;
- end loop;
- end Read;
-
- ----------------
- -- Stream_End --
- ----------------
-
- function Stream_End (Filter : in Filter_Type) return Boolean is
- begin
- if Filter.Header = GZip and Filter.Compression then
- return Filter.Stream_End
- and then Filter.Offset = Footer_Array'Last + 1;
- else
- return Filter.Stream_End;
- end if;
- end Stream_End;
-
- --------------
- -- Total_In --
- --------------
-
- function Total_In (Filter : in Filter_Type) return Count is
- begin
- return Count (Thin.Total_In (To_Thin_Access (Filter.Strm).all));
- end Total_In;
-
- ---------------
- -- Total_Out --
- ---------------
-
- function Total_Out (Filter : in Filter_Type) return Count is
- begin
- return Count (Thin.Total_Out (To_Thin_Access (Filter.Strm).all));
- end Total_Out;
-
- ---------------
- -- Translate --
- ---------------
-
- procedure Translate
- (Filter : in out Filter_Type;
- In_Data : in Ada.Streams.Stream_Element_Array;
- In_Last : out Ada.Streams.Stream_Element_Offset;
- Out_Data : out Ada.Streams.Stream_Element_Array;
- Out_Last : out Ada.Streams.Stream_Element_Offset;
- Flush : in Flush_Mode) is
- begin
- if Filter.Header = GZip and then Filter.Compression then
- Translate_GZip
- (Filter => Filter,
- In_Data => In_Data,
- In_Last => In_Last,
- Out_Data => Out_Data,
- Out_Last => Out_Last,
- Flush => Flush);
- else
- Translate_Auto
- (Filter => Filter,
- In_Data => In_Data,
- In_Last => In_Last,
- Out_Data => Out_Data,
- Out_Last => Out_Last,
- Flush => Flush);
- end if;
- end Translate;
-
- --------------------
- -- Translate_Auto --
- --------------------
-
- procedure Translate_Auto
- (Filter : in out Filter_Type;
- In_Data : in Ada.Streams.Stream_Element_Array;
- In_Last : out Ada.Streams.Stream_Element_Offset;
- Out_Data : out Ada.Streams.Stream_Element_Array;
- Out_Last : out Ada.Streams.Stream_Element_Offset;
- Flush : in Flush_Mode)
- is
- use type Thin.Int;
- Code : Thin.Int;
-
- begin
- if not Is_Open (Filter) then
- raise Status_Error;
- end if;
-
- if Out_Data'Length = 0 and then In_Data'Length = 0 then
- raise Constraint_Error;
- end if;
-
- Set_Out (Filter.Strm.all, Out_Data'Address, Out_Data'Length);
- Set_In (Filter.Strm.all, In_Data'Address, In_Data'Length);
-
- Code := Flate (Filter.Compression).Step
- (To_Thin_Access (Filter.Strm),
- Thin.Int (Flush));
-
- if Code = Thin.Z_STREAM_END then
- Filter.Stream_End := True;
- else
- Check_Error (Filter.Strm.all, Code);
- end if;
-
- In_Last := In_Data'Last
- - Stream_Element_Offset (Avail_In (Filter.Strm.all));
- Out_Last := Out_Data'Last
- - Stream_Element_Offset (Avail_Out (Filter.Strm.all));
- end Translate_Auto;
-
- --------------------
- -- Translate_GZip --
- --------------------
-
- procedure Translate_GZip
- (Filter : in out Filter_Type;
- In_Data : in Ada.Streams.Stream_Element_Array;
- In_Last : out Ada.Streams.Stream_Element_Offset;
- Out_Data : out Ada.Streams.Stream_Element_Array;
- Out_Last : out Ada.Streams.Stream_Element_Offset;
- Flush : in Flush_Mode)
- is
- Out_First : Stream_Element_Offset;
-
- procedure Add_Data (Data : in Stream_Element_Array);
- -- Add data to stream from the Filter.Offset till necessary,
- -- used for add gzip headr/footer.
-
- procedure Put_32
- (Item : in out Stream_Element_Array;
- Data : in Unsigned_32);
- pragma Inline (Put_32);
-
- --------------
- -- Add_Data --
- --------------
-
- procedure Add_Data (Data : in Stream_Element_Array) is
- Data_First : Stream_Element_Offset renames Filter.Offset;
- Data_Last : Stream_Element_Offset;
- Data_Len : Stream_Element_Offset; -- -1
- Out_Len : Stream_Element_Offset; -- -1
- begin
- Out_First := Out_Last + 1;
-
- if Data_First > Data'Last then
- return;
- end if;
-
- Data_Len := Data'Last - Data_First;
- Out_Len := Out_Data'Last - Out_First;
-
- if Data_Len <= Out_Len then
- Out_Last := Out_First + Data_Len;
- Data_Last := Data'Last;
- else
- Out_Last := Out_Data'Last;
- Data_Last := Data_First + Out_Len;
- end if;
-
- Out_Data (Out_First .. Out_Last) := Data (Data_First .. Data_Last);
-
- Data_First := Data_Last + 1;
- Out_First := Out_Last + 1;
- end Add_Data;
-
- ------------
- -- Put_32 --
- ------------
-
- procedure Put_32
- (Item : in out Stream_Element_Array;
- Data : in Unsigned_32)
- is
- D : Unsigned_32 := Data;
- begin
- for J in Item'First .. Item'First + 3 loop
- Item (J) := Stream_Element (D and 16#FF#);
- D := Shift_Right (D, 8);
- end loop;
- end Put_32;
-
- begin
- Out_Last := Out_Data'First - 1;
-
- if not Filter.Stream_End then
- Add_Data (Simple_GZip_Header);
-
- Translate_Auto
- (Filter => Filter,
- In_Data => In_Data,
- In_Last => In_Last,
- Out_Data => Out_Data (Out_First .. Out_Data'Last),
- Out_Last => Out_Last,
- Flush => Flush);
-
- CRC32 (Filter.CRC, In_Data (In_Data'First .. In_Last));
- end if;
-
- if Filter.Stream_End and then Out_Last <= Out_Data'Last then
- -- This detection method would work only when
- -- Simple_GZip_Header'Last > Footer_Array'Last
-
- if Filter.Offset = Simple_GZip_Header'Last + 1 then
- Filter.Offset := Footer_Array'First;
- end if;
-
- declare
- Footer : Footer_Array;
- begin
- Put_32 (Footer, Filter.CRC);
- Put_32 (Footer (Footer'First + 4 .. Footer'Last),
- Unsigned_32 (Total_In (Filter)));
- Add_Data (Footer);
- end;
- end if;
- end Translate_GZip;
-
- -------------
- -- Version --
- -------------
-
- function Version return String is
- begin
- return Interfaces.C.Strings.Value (Thin.zlibVersion);
- end Version;
-
- -----------
- -- Write --
- -----------
-
- procedure Write
- (Filter : in out Filter_Type;
- Item : in Ada.Streams.Stream_Element_Array;
- Flush : in Flush_Mode := No_Flush)
- is
- Buffer : Stream_Element_Array (1 .. Buffer_Size);
- In_Last : Stream_Element_Offset;
- Out_Last : Stream_Element_Offset;
- In_First : Stream_Element_Offset := Item'First;
- begin
- if Item'Length = 0 and Flush = No_Flush then
- return;
- end if;
-
- loop
- Translate
- (Filter => Filter,
- In_Data => Item (In_First .. Item'Last),
- In_Last => In_Last,
- Out_Data => Buffer,
- Out_Last => Out_Last,
- Flush => Flush);
-
- if Out_Last >= Buffer'First then
- Write (Buffer (1 .. Out_Last));
- end if;
-
- exit when In_Last = Item'Last or Stream_End (Filter);
-
- In_First := In_Last + 1;
- end loop;
- end Write;
-
-end ZLib;
diff --git a/source4/lib/zlib/contrib/ada/zlib.ads b/source4/lib/zlib/contrib/ada/zlib.ads
deleted file mode 100644
index 79ffc4095c..0000000000
--- a/source4/lib/zlib/contrib/ada/zlib.ads
+++ /dev/null
@@ -1,328 +0,0 @@
-------------------------------------------------------------------------------
--- ZLib for Ada thick binding. --
--- --
--- Copyright (C) 2002-2004 Dmitriy Anisimkov --
--- --
--- This library 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 2 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 --
--- General Public License for more details. --
--- --
--- You should have received a copy of the GNU General Public License --
--- along with this library; if not, write to the Free Software Foundation, --
--- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
--- --
--- As a special exception, if other files instantiate generics from this --
--- unit, or you link this unit with other files to produce an executable, --
--- this unit does not by itself cause the resulting executable to be --
--- covered by the GNU General Public License. This exception does not --
--- however invalidate any other reasons why the executable file might be --
--- covered by the GNU Public License. --
-------------------------------------------------------------------------------
-
--- $Id: zlib.ads,v 1.26 2004/09/06 06:53:19 vagul Exp $
-
-with Ada.Streams;
-
-with Interfaces;
-
-package ZLib is
-
- ZLib_Error : exception;
- Status_Error : exception;
-
- type Compression_Level is new Integer range -1 .. 9;
-
- type Flush_Mode is private;
-
- type Compression_Method is private;
-
- type Window_Bits_Type is new Integer range 8 .. 15;
-
- type Memory_Level_Type is new Integer range 1 .. 9;
-
- type Unsigned_32 is new Interfaces.Unsigned_32;
-
- type Strategy_Type is private;
-
- type Header_Type is (None, Auto, Default, GZip);
- -- Header type usage have a some limitation for inflate.
- -- See comment for Inflate_Init.
-
- subtype Count is Ada.Streams.Stream_Element_Count;
-
- Default_Memory_Level : constant Memory_Level_Type := 8;
- Default_Window_Bits : constant Window_Bits_Type := 15;
-
- ----------------------------------
- -- Compression method constants --
- ----------------------------------
-
- Deflated : constant Compression_Method;
- -- Only one method allowed in this ZLib version
-
- ---------------------------------
- -- Compression level constants --
- ---------------------------------
-
- No_Compression : constant Compression_Level := 0;
- Best_Speed : constant Compression_Level := 1;
- Best_Compression : constant Compression_Level := 9;
- Default_Compression : constant Compression_Level := -1;
-
- --------------------------
- -- Flush mode constants --
- --------------------------
-
- No_Flush : constant Flush_Mode;
- -- Regular way for compression, no flush
-
- Partial_Flush : constant Flush_Mode;
- -- Will be removed, use Z_SYNC_FLUSH instead
-
- Sync_Flush : constant Flush_Mode;
- -- All pending output is flushed to the output buffer and the output
- -- is aligned on a byte boundary, so that the decompressor can get all
- -- input data available so far. (In particular avail_in is zero after the
- -- call if enough output space has been provided before the call.)
- -- Flushing may degrade compression for some compression algorithms and so
- -- it should be used only when necessary.
-
- Block_Flush : constant Flush_Mode;
- -- Z_BLOCK requests that inflate() stop
- -- if and when it get to the next deflate block boundary. When decoding the
- -- zlib or gzip format, this will cause inflate() to return immediately
- -- after the header and before the first block. When doing a raw inflate,
- -- inflate() will go ahead and process the first block, and will return
- -- when it gets to the end of that block, or when it runs out of data.
-
- Full_Flush : constant Flush_Mode;
- -- All output is flushed as with SYNC_FLUSH, and the compression state
- -- is reset so that decompression can restart from this point if previous
- -- compressed data has been damaged or if random access is desired. Using
- -- Full_Flush too often can seriously degrade the compression.
-
- Finish : constant Flush_Mode;
- -- Just for tell the compressor that input data is complete.
-
- ------------------------------------
- -- Compression strategy constants --
- ------------------------------------
-
- -- RLE stategy could be used only in version 1.2.0 and later.
-
- Filtered : constant Strategy_Type;
- Huffman_Only : constant Strategy_Type;
- RLE : constant Strategy_Type;
- Default_Strategy : constant Strategy_Type;
-
- Default_Buffer_Size : constant := 4096;
-
- type Filter_Type is tagged limited private;
- -- The filter is for compression and for decompression.
- -- The usage of the type is depend of its initialization.
-
- function Version return String;
- pragma Inline (Version);
- -- Return string representation of the ZLib version.
-
- procedure Deflate_Init
- (Filter : in out Filter_Type;
- Level : in Compression_Level := Default_Compression;
- Strategy : in Strategy_Type := Default_Strategy;
- Method : in Compression_Method := Deflated;
- Window_Bits : in Window_Bits_Type := Default_Window_Bits;
- Memory_Level : in Memory_Level_Type := Default_Memory_Level;
- Header : in Header_Type := Default);
- -- Compressor initialization.
- -- When Header parameter is Auto or Default, then default zlib header
- -- would be provided for compressed data.
- -- When Header is GZip, then gzip header would be set instead of
- -- default header.
- -- When Header is None, no header would be set for compressed data.
-
- procedure Inflate_Init
- (Filter : in out Filter_Type;
- Window_Bits : in Window_Bits_Type := Default_Window_Bits;
- Header : in Header_Type := Default);
- -- Decompressor initialization.
- -- Default header type mean that ZLib default header is expecting in the
- -- input compressed stream.
- -- Header type None mean that no header is expecting in the input stream.
- -- GZip header type mean that GZip header is expecting in the
- -- input compressed stream.
- -- Auto header type mean that header type (GZip or Native) would be
- -- detected automatically in the input stream.
- -- Note that header types parameter values None, GZip and Auto are
- -- supported for inflate routine only in ZLib versions 1.2.0.2 and later.
- -- Deflate_Init is supporting all header types.
-
- function Is_Open (Filter : in Filter_Type) return Boolean;
- pragma Inline (Is_Open);
- -- Is the filter opened for compression or decompression.
-
- procedure Close
- (Filter : in out Filter_Type;
- Ignore_Error : in Boolean := False);
- -- Closing the compression or decompressor.
- -- If stream is closing before the complete and Ignore_Error is False,
- -- The exception would be raised.
-
- generic
- with procedure Data_In
- (Item : out Ada.Streams.Stream_Element_Array;
- Last : out Ada.Streams.Stream_Element_Offset);
- with procedure Data_Out
- (Item : in Ada.Streams.Stream_Element_Array);
- procedure Generic_Translate
- (Filter : in out Filter_Type;
- In_Buffer_Size : in Integer := Default_Buffer_Size;
- Out_Buffer_Size : in Integer := Default_Buffer_Size);
- -- Compress/decompress data fetch from Data_In routine and pass the result
- -- to the Data_Out routine. User should provide Data_In and Data_Out
- -- for compression/decompression data flow.
- -- Compression or decompression depend on Filter initialization.
-
- function Total_In (Filter : in Filter_Type) return Count;
- pragma Inline (Total_In);
- -- Returns total number of input bytes read so far
-
- function Total_Out (Filter : in Filter_Type) return Count;
- pragma Inline (Total_Out);
- -- Returns total number of bytes output so far
-
- function CRC32
- (CRC : in Unsigned_32;
- Data : in Ada.Streams.Stream_Element_Array)
- return Unsigned_32;
- pragma Inline (CRC32);
- -- Compute CRC32, it could be necessary for make gzip format
-
- procedure CRC32
- (CRC : in out Unsigned_32;
- Data : in Ada.Streams.Stream_Element_Array);
- pragma Inline (CRC32);
- -- Compute CRC32, it could be necessary for make gzip format
-
- -------------------------------------------------
- -- Below is more complex low level routines. --
- -------------------------------------------------
-
- procedure Translate
- (Filter : in out Filter_Type;
- In_Data : in Ada.Streams.Stream_Element_Array;
- In_Last : out Ada.Streams.Stream_Element_Offset;
- Out_Data : out Ada.Streams.Stream_Element_Array;
- Out_Last : out Ada.Streams.Stream_Element_Offset;
- Flush : in Flush_Mode);
- -- Compress/decompress the In_Data buffer and place the result into
- -- Out_Data. In_Last is the index of last element from In_Data accepted by
- -- the Filter. Out_Last is the last element of the received data from
- -- Filter. To tell the filter that incoming data are complete put the
- -- Flush parameter to Finish.
-
- function Stream_End (Filter : in Filter_Type) return Boolean;
- pragma Inline (Stream_End);
- -- Return the true when the stream is complete.
-
- procedure Flush
- (Filter : in out Filter_Type;
- Out_Data : out Ada.Streams.Stream_Element_Array;
- Out_Last : out Ada.Streams.Stream_Element_Offset;
- Flush : in Flush_Mode);
- pragma Inline (Flush);
- -- Flushing the data from the compressor.
-
- generic
- with procedure Write
- (Item : in Ada.Streams.Stream_Element_Array);
- -- User should provide this routine for accept
- -- compressed/decompressed data.
-
- Buffer_Size : in Ada.Streams.Stream_Element_Offset
- := Default_Buffer_Size;
- -- Buffer size for Write user routine.
-
- procedure Write
- (Filter : in out Filter_Type;
- Item : in Ada.Streams.Stream_Element_Array;
- Flush : in Flush_Mode := No_Flush);
- -- Compress/Decompress data from Item to the generic parameter procedure
- -- Write. Output buffer size could be set in Buffer_Size generic parameter.
-
- generic
- with procedure Read
- (Item : out Ada.Streams.Stream_Element_Array;
- Last : out Ada.Streams.Stream_Element_Offset);
- -- User should provide data for compression/decompression
- -- thru this routine.
-
- Buffer : in out Ada.Streams.Stream_Element_Array;
- -- Buffer for keep remaining data from the previous
- -- back read.
-
- Rest_First, Rest_Last : in out Ada.Streams.Stream_Element_Offset;
- -- Rest_First have to be initialized to Buffer'Last + 1
- -- Rest_Last have to be initialized to Buffer'Last
- -- before usage.
-
- Allow_Read_Some : in Boolean := False;
- -- Is it allowed to return Last < Item'Last before end of data.
-
- procedure Read
- (Filter : in out Filter_Type;
- Item : out Ada.Streams.Stream_Element_Array;
- Last : out Ada.Streams.Stream_Element_Offset;
- Flush : in Flush_Mode := No_Flush);
- -- Compress/Decompress data from generic parameter procedure Read to the
- -- Item. User should provide Buffer and initialized Rest_First, Rest_Last
- -- indicators. If Allow_Read_Some is True, Read routines could return
- -- Last < Item'Last only at end of stream.
-
-private
-
- use Ada.Streams;
-
- pragma Assert (Ada.Streams.Stream_Element'Size = 8);
- pragma Assert (Ada.Streams.Stream_Element'Modulus = 2**8);
-
- type Flush_Mode is new Integer range 0 .. 5;
-
- type Compression_Method is new Integer range 8 .. 8;
-
- type Strategy_Type is new Integer range 0 .. 3;
-
- No_Flush : constant Flush_Mode := 0;
- Partial_Flush : constant Flush_Mode := 1;
- Sync_Flush : constant Flush_Mode := 2;
- Full_Flush : constant Flush_Mode := 3;
- Finish : constant Flush_Mode := 4;
- Block_Flush : constant Flush_Mode := 5;
-
- Filtered : constant Strategy_Type := 1;
- Huffman_Only : constant Strategy_Type := 2;
- RLE : constant Strategy_Type := 3;
- Default_Strategy : constant Strategy_Type := 0;
-
- Deflated : constant Compression_Method := 8;
-
- type Z_Stream;
-
- type Z_Stream_Access is access all Z_Stream;
-
- type Filter_Type is tagged limited record
- Strm : Z_Stream_Access;
- Compression : Boolean;
- Stream_End : Boolean;
- Header : Header_Type;
- CRC : Unsigned_32;
- Offset : Stream_Element_Offset;
- -- Offset for gzip header/footer output.
- end record;
-
-end ZLib;
diff --git a/source4/lib/zlib/contrib/ada/zlib.gpr b/source4/lib/zlib/contrib/ada/zlib.gpr
deleted file mode 100644
index 296b22aa96..0000000000
--- a/source4/lib/zlib/contrib/ada/zlib.gpr
+++ /dev/null
@@ -1,20 +0,0 @@
-project Zlib is
-
- for Languages use ("Ada");
- for Source_Dirs use (".");
- for Object_Dir use ".";
- for Main use ("test.adb", "mtest.adb", "read.adb", "buffer_demo");
-
- package Compiler is
- for Default_Switches ("ada") use ("-gnatwcfilopru", "-gnatVcdfimorst", "-gnatyabcefhiklmnoprst");
- end Compiler;
-
- package Linker is
- for Default_Switches ("ada") use ("-lz");
- end Linker;
-
- package Builder is
- for Default_Switches ("ada") use ("-s", "-gnatQ");
- end Builder;
-
-end Zlib;
diff --git a/source4/lib/zlib/contrib/asm586/README.586 b/source4/lib/zlib/contrib/asm586/README.586
deleted file mode 100644
index 6bb78f3206..0000000000
--- a/source4/lib/zlib/contrib/asm586/README.586
+++ /dev/null
@@ -1,43 +0,0 @@
-This is a patched version of zlib modified to use
-Pentium-optimized assembly code in the deflation algorithm. The files
-changed/added by this patch are:
-
-README.586
-match.S
-
-The effectiveness of these modifications is a bit marginal, as the the
-program's bottleneck seems to be mostly L1-cache contention, for which
-there is no real way to work around without rewriting the basic
-algorithm. The speedup on average is around 5-10% (which is generally
-less than the amount of variance between subsequent executions).
-However, when used at level 9 compression, the cache contention can
-drop enough for the assembly version to achieve 10-20% speedup (and
-sometimes more, depending on the amount of overall redundancy in the
-files). Even here, though, cache contention can still be the limiting
-factor, depending on the nature of the program using the zlib library.
-This may also mean that better improvements will be seen on a Pentium
-with MMX, which suffers much less from L1-cache contention, but I have
-not yet verified this.
-
-Note that this code has been tailored for the Pentium in particular,
-and will not perform well on the Pentium Pro (due to the use of a
-partial register in the inner loop).
-
-If you are using an assembler other than GNU as, you will have to
-translate match.S to use your assembler's syntax. (Have fun.)
-
-Brian Raiter
-breadbox@muppetlabs.com
-April, 1998
-
-
-Added for zlib 1.1.3:
-
-The patches come from
-http://www.muppetlabs.com/~breadbox/software/assembly.html
-
-To compile zlib with this asm file, copy match.S to the zlib directory
-then do:
-
-CFLAGS="-O3 -DASMV" ./configure
-make OBJA=match.o
diff --git a/source4/lib/zlib/contrib/asm586/match.S b/source4/lib/zlib/contrib/asm586/match.S
deleted file mode 100644
index 0368b35fe3..0000000000
--- a/source4/lib/zlib/contrib/asm586/match.S
+++ /dev/null
@@ -1,364 +0,0 @@
-/* match.s -- Pentium-optimized version of longest_match()
- * Written for zlib 1.1.2
- * Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com>
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License.
- */
-
-#ifndef NO_UNDERLINE
-#define match_init _match_init
-#define longest_match _longest_match
-#endif
-
-#define MAX_MATCH (258)
-#define MIN_MATCH (3)
-#define MIN_LOOKAHEAD (MAX_MATCH + MIN_MATCH + 1)
-#define MAX_MATCH_8 ((MAX_MATCH + 7) & ~7)
-
-/* stack frame offsets */
-
-#define wmask 0 /* local copy of s->wmask */
-#define window 4 /* local copy of s->window */
-#define windowbestlen 8 /* s->window + bestlen */
-#define chainlenscanend 12 /* high word: current chain len */
- /* low word: last bytes sought */
-#define scanstart 16 /* first two bytes of string */
-#define scanalign 20 /* dword-misalignment of string */
-#define nicematch 24 /* a good enough match size */
-#define bestlen 28 /* size of best match so far */
-#define scan 32 /* ptr to string wanting match */
-
-#define LocalVarsSize (36)
-/* saved ebx 36 */
-/* saved edi 40 */
-/* saved esi 44 */
-/* saved ebp 48 */
-/* return address 52 */
-#define deflatestate 56 /* the function arguments */
-#define curmatch 60
-
-/* Offsets for fields in the deflate_state structure. These numbers
- * are calculated from the definition of deflate_state, with the
- * assumption that the compiler will dword-align the fields. (Thus,
- * changing the definition of deflate_state could easily cause this
- * program to crash horribly, without so much as a warning at
- * compile time. Sigh.)
- */
-
-/* All the +zlib1222add offsets are due to the addition of fields
- * in zlib in the deflate_state structure since the asm code was first written
- * (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)").
- * (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0").
- * if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8").
- */
-
-#define zlib1222add (8)
-
-#define dsWSize (36+zlib1222add)
-#define dsWMask (44+zlib1222add)
-#define dsWindow (48+zlib1222add)
-#define dsPrev (56+zlib1222add)
-#define dsMatchLen (88+zlib1222add)
-#define dsPrevMatch (92+zlib1222add)
-#define dsStrStart (100+zlib1222add)
-#define dsMatchStart (104+zlib1222add)
-#define dsLookahead (108+zlib1222add)
-#define dsPrevLen (112+zlib1222add)
-#define dsMaxChainLen (116+zlib1222add)
-#define dsGoodMatch (132+zlib1222add)
-#define dsNiceMatch (136+zlib1222add)
-
-
-.file "match.S"
-
-.globl match_init, longest_match
-
-.text
-
-/* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */
-
-longest_match:
-
-/* Save registers that the compiler may be using, and adjust %esp to */
-/* make room for our stack frame. */
-
- pushl %ebp
- pushl %edi
- pushl %esi
- pushl %ebx
- subl $LocalVarsSize, %esp
-
-/* Retrieve the function arguments. %ecx will hold cur_match */
-/* throughout the entire function. %edx will hold the pointer to the */
-/* deflate_state structure during the function's setup (before */
-/* entering the main loop). */
-
- movl deflatestate(%esp), %edx
- movl curmatch(%esp), %ecx
-
-/* if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; */
-
- movl dsNiceMatch(%edx), %eax
- movl dsLookahead(%edx), %ebx
- cmpl %eax, %ebx
- jl LookaheadLess
- movl %eax, %ebx
-LookaheadLess: movl %ebx, nicematch(%esp)
-
-/* register Bytef *scan = s->window + s->strstart; */
-
- movl dsWindow(%edx), %esi
- movl %esi, window(%esp)
- movl dsStrStart(%edx), %ebp
- lea (%esi,%ebp), %edi
- movl %edi, scan(%esp)
-
-/* Determine how many bytes the scan ptr is off from being */
-/* dword-aligned. */
-
- movl %edi, %eax
- negl %eax
- andl $3, %eax
- movl %eax, scanalign(%esp)
-
-/* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */
-/* s->strstart - (IPos)MAX_DIST(s) : NIL; */
-
- movl dsWSize(%edx), %eax
- subl $MIN_LOOKAHEAD, %eax
- subl %eax, %ebp
- jg LimitPositive
- xorl %ebp, %ebp
-LimitPositive:
-
-/* unsigned chain_length = s->max_chain_length; */
-/* if (s->prev_length >= s->good_match) { */
-/* chain_length >>= 2; */
-/* } */
-
- movl dsPrevLen(%edx), %eax
- movl dsGoodMatch(%edx), %ebx
- cmpl %ebx, %eax
- movl dsMaxChainLen(%edx), %ebx
- jl LastMatchGood
- shrl $2, %ebx
-LastMatchGood:
-
-/* chainlen is decremented once beforehand so that the function can */
-/* use the sign flag instead of the zero flag for the exit test. */
-/* It is then shifted into the high word, to make room for the scanend */
-/* scanend value, which it will always accompany. */
-
- decl %ebx
- shll $16, %ebx
-
-/* int best_len = s->prev_length; */
-
- movl dsPrevLen(%edx), %eax
- movl %eax, bestlen(%esp)
-
-/* Store the sum of s->window + best_len in %esi locally, and in %esi. */
-
- addl %eax, %esi
- movl %esi, windowbestlen(%esp)
-
-/* register ush scan_start = *(ushf*)scan; */
-/* register ush scan_end = *(ushf*)(scan+best_len-1); */
-
- movw (%edi), %bx
- movw %bx, scanstart(%esp)
- movw -1(%edi,%eax), %bx
- movl %ebx, chainlenscanend(%esp)
-
-/* Posf *prev = s->prev; */
-/* uInt wmask = s->w_mask; */
-
- movl dsPrev(%edx), %edi
- movl dsWMask(%edx), %edx
- mov %edx, wmask(%esp)
-
-/* Jump into the main loop. */
-
- jmp LoopEntry
-
-.balign 16
-
-/* do {
- * match = s->window + cur_match;
- * if (*(ushf*)(match+best_len-1) != scan_end ||
- * *(ushf*)match != scan_start) continue;
- * [...]
- * } while ((cur_match = prev[cur_match & wmask]) > limit
- * && --chain_length != 0);
- *
- * Here is the inner loop of the function. The function will spend the
- * majority of its time in this loop, and majority of that time will
- * be spent in the first ten instructions.
- *
- * Within this loop:
- * %ebx = chainlenscanend - i.e., ((chainlen << 16) | scanend)
- * %ecx = curmatch
- * %edx = curmatch & wmask
- * %esi = windowbestlen - i.e., (window + bestlen)
- * %edi = prev
- * %ebp = limit
- *
- * Two optimization notes on the choice of instructions:
- *
- * The first instruction uses a 16-bit address, which costs an extra,
- * unpairable cycle. This is cheaper than doing a 32-bit access and
- * zeroing the high word, due to the 3-cycle misalignment penalty which
- * would occur half the time. This also turns out to be cheaper than
- * doing two separate 8-bit accesses, as the memory is so rarely in the
- * L1 cache.
- *
- * The window buffer, however, apparently spends a lot of time in the
- * cache, and so it is faster to retrieve the word at the end of the
- * match string with two 8-bit loads. The instructions that test the
- * word at the beginning of the match string, however, are executed
- * much less frequently, and there it was cheaper to use 16-bit
- * instructions, which avoided the necessity of saving off and
- * subsequently reloading one of the other registers.
- */
-LookupLoop:
- /* 1 U & V */
- movw (%edi,%edx,2), %cx /* 2 U pipe */
- movl wmask(%esp), %edx /* 2 V pipe */
- cmpl %ebp, %ecx /* 3 U pipe */
- jbe LeaveNow /* 3 V pipe */
- subl $0x00010000, %ebx /* 4 U pipe */
- js LeaveNow /* 4 V pipe */
-LoopEntry: movb -1(%esi,%ecx), %al /* 5 U pipe */
- andl %ecx, %edx /* 5 V pipe */
- cmpb %bl, %al /* 6 U pipe */
- jnz LookupLoop /* 6 V pipe */
- movb (%esi,%ecx), %ah
- cmpb %bh, %ah
- jnz LookupLoop
- movl window(%esp), %eax
- movw (%eax,%ecx), %ax
- cmpw scanstart(%esp), %ax
- jnz LookupLoop
-
-/* Store the current value of chainlen. */
-
- movl %ebx, chainlenscanend(%esp)
-
-/* Point %edi to the string under scrutiny, and %esi to the string we */
-/* are hoping to match it up with. In actuality, %esi and %edi are */
-/* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */
-/* initialized to -(MAX_MATCH_8 - scanalign). */
-
- movl window(%esp), %esi
- movl scan(%esp), %edi
- addl %ecx, %esi
- movl scanalign(%esp), %eax
- movl $(-MAX_MATCH_8), %edx
- lea MAX_MATCH_8(%edi,%eax), %edi
- lea MAX_MATCH_8(%esi,%eax), %esi
-
-/* Test the strings for equality, 8 bytes at a time. At the end,
- * adjust %edx so that it is offset to the exact byte that mismatched.
- *
- * We already know at this point that the first three bytes of the
- * strings match each other, and they can be safely passed over before
- * starting the compare loop. So what this code does is skip over 0-3
- * bytes, as much as necessary in order to dword-align the %edi
- * pointer. (%esi will still be misaligned three times out of four.)
- *
- * It should be confessed that this loop usually does not represent
- * much of the total running time. Replacing it with a more
- * straightforward "rep cmpsb" would not drastically degrade
- * performance.
- */
-LoopCmps:
- movl (%esi,%edx), %eax
- movl (%edi,%edx), %ebx
- xorl %ebx, %eax
- jnz LeaveLoopCmps
- movl 4(%esi,%edx), %eax
- movl 4(%edi,%edx), %ebx
- xorl %ebx, %eax
- jnz LeaveLoopCmps4
- addl $8, %edx
- jnz LoopCmps
- jmp LenMaximum
-LeaveLoopCmps4: addl $4, %edx
-LeaveLoopCmps: testl $0x0000FFFF, %eax
- jnz LenLower
- addl $2, %edx
- shrl $16, %eax
-LenLower: subb $1, %al
- adcl $0, %edx
-
-/* Calculate the length of the match. If it is longer than MAX_MATCH, */
-/* then automatically accept it as the best possible match and leave. */
-
- lea (%edi,%edx), %eax
- movl scan(%esp), %edi
- subl %edi, %eax
- cmpl $MAX_MATCH, %eax
- jge LenMaximum
-
-/* If the length of the match is not longer than the best match we */
-/* have so far, then forget it and return to the lookup loop. */
-
- movl deflatestate(%esp), %edx
- movl bestlen(%esp), %ebx
- cmpl %ebx, %eax
- jg LongerMatch
- movl chainlenscanend(%esp), %ebx
- movl windowbestlen(%esp), %esi
- movl dsPrev(%edx), %edi
- movl wmask(%esp), %edx
- andl %ecx, %edx
- jmp LookupLoop
-
-/* s->match_start = cur_match; */
-/* best_len = len; */
-/* if (len >= nice_match) break; */
-/* scan_end = *(ushf*)(scan+best_len-1); */
-
-LongerMatch: movl nicematch(%esp), %ebx
- movl %eax, bestlen(%esp)
- movl %ecx, dsMatchStart(%edx)
- cmpl %ebx, %eax
- jge LeaveNow
- movl window(%esp), %esi
- addl %eax, %esi
- movl %esi, windowbestlen(%esp)
- movl chainlenscanend(%esp), %ebx
- movw -1(%edi,%eax), %bx
- movl dsPrev(%edx), %edi
- movl %ebx, chainlenscanend(%esp)
- movl wmask(%esp), %edx
- andl %ecx, %edx
- jmp LookupLoop
-
-/* Accept the current string, with the maximum possible length. */
-
-LenMaximum: movl deflatestate(%esp), %edx
- movl $MAX_MATCH, bestlen(%esp)
- movl %ecx, dsMatchStart(%edx)
-
-/* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */
-/* return s->lookahead; */
-
-LeaveNow:
- movl deflatestate(%esp), %edx
- movl bestlen(%esp), %ebx
- movl dsLookahead(%edx), %eax
- cmpl %eax, %ebx
- jg LookaheadRet
- movl %ebx, %eax
-LookaheadRet:
-
-/* Restore the stack and return from whence we came. */
-
- addl $LocalVarsSize, %esp
- popl %ebx
- popl %esi
- popl %edi
- popl %ebp
-match_init: ret
diff --git a/source4/lib/zlib/contrib/asm686/README.686 b/source4/lib/zlib/contrib/asm686/README.686
deleted file mode 100644
index a593f23afd..0000000000
--- a/source4/lib/zlib/contrib/asm686/README.686
+++ /dev/null
@@ -1,34 +0,0 @@
-This is a patched version of zlib, modified to use
-Pentium-Pro-optimized assembly code in the deflation algorithm. The
-files changed/added by this patch are:
-
-README.686
-match.S
-
-The speedup that this patch provides varies, depending on whether the
-compiler used to build the original version of zlib falls afoul of the
-PPro's speed traps. My own tests show a speedup of around 10-20% at
-the default compression level, and 20-30% using -9, against a version
-compiled using gcc 2.7.2.3. Your mileage may vary.
-
-Note that this code has been tailored for the PPro/PII in particular,
-and will not perform particuarly well on a Pentium.
-
-If you are using an assembler other than GNU as, you will have to
-translate match.S to use your assembler's syntax. (Have fun.)
-
-Brian Raiter
-breadbox@muppetlabs.com
-April, 1998
-
-
-Added for zlib 1.1.3:
-
-The patches come from
-http://www.muppetlabs.com/~breadbox/software/assembly.html
-
-To compile zlib with this asm file, copy match.S to the zlib directory
-then do:
-
-CFLAGS="-O3 -DASMV" ./configure
-make OBJA=match.o
diff --git a/source4/lib/zlib/contrib/asm686/match.S b/source4/lib/zlib/contrib/asm686/match.S
deleted file mode 100644
index 5c3e9ee367..0000000000
--- a/source4/lib/zlib/contrib/asm686/match.S
+++ /dev/null
@@ -1,329 +0,0 @@
-/* match.s -- Pentium-Pro-optimized version of longest_match()
- * Written for zlib 1.1.2
- * Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com>
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License.
- */
-
-#ifndef NO_UNDERLINE
-#define match_init _match_init
-#define longest_match _longest_match
-#endif
-
-#define MAX_MATCH (258)
-#define MIN_MATCH (3)
-#define MIN_LOOKAHEAD (MAX_MATCH + MIN_MATCH + 1)
-#define MAX_MATCH_8 ((MAX_MATCH + 7) & ~7)
-
-/* stack frame offsets */
-
-#define chainlenwmask 0 /* high word: current chain len */
- /* low word: s->wmask */
-#define window 4 /* local copy of s->window */
-#define windowbestlen 8 /* s->window + bestlen */
-#define scanstart 16 /* first two bytes of string */
-#define scanend 12 /* last two bytes of string */
-#define scanalign 20 /* dword-misalignment of string */
-#define nicematch 24 /* a good enough match size */
-#define bestlen 28 /* size of best match so far */
-#define scan 32 /* ptr to string wanting match */
-
-#define LocalVarsSize (36)
-/* saved ebx 36 */
-/* saved edi 40 */
-/* saved esi 44 */
-/* saved ebp 48 */
-/* return address 52 */
-#define deflatestate 56 /* the function arguments */
-#define curmatch 60
-
-/* All the +zlib1222add offsets are due to the addition of fields
- * in zlib in the deflate_state structure since the asm code was first written
- * (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)").
- * (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0").
- * if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8").
- */
-
-#define zlib1222add (8)
-
-#define dsWSize (36+zlib1222add)
-#define dsWMask (44+zlib1222add)
-#define dsWindow (48+zlib1222add)
-#define dsPrev (56+zlib1222add)
-#define dsMatchLen (88+zlib1222add)
-#define dsPrevMatch (92+zlib1222add)
-#define dsStrStart (100+zlib1222add)
-#define dsMatchStart (104+zlib1222add)
-#define dsLookahead (108+zlib1222add)
-#define dsPrevLen (112+zlib1222add)
-#define dsMaxChainLen (116+zlib1222add)
-#define dsGoodMatch (132+zlib1222add)
-#define dsNiceMatch (136+zlib1222add)
-
-
-.file "match.S"
-
-.globl match_init, longest_match
-
-.text
-
-/* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */
-
-longest_match:
-
-/* Save registers that the compiler may be using, and adjust %esp to */
-/* make room for our stack frame. */
-
- pushl %ebp
- pushl %edi
- pushl %esi
- pushl %ebx
- subl $LocalVarsSize, %esp
-
-/* Retrieve the function arguments. %ecx will hold cur_match */
-/* throughout the entire function. %edx will hold the pointer to the */
-/* deflate_state structure during the function's setup (before */
-/* entering the main loop). */
-
- movl deflatestate(%esp), %edx
- movl curmatch(%esp), %ecx
-
-/* uInt wmask = s->w_mask; */
-/* unsigned chain_length = s->max_chain_length; */
-/* if (s->prev_length >= s->good_match) { */
-/* chain_length >>= 2; */
-/* } */
-
- movl dsPrevLen(%edx), %eax
- movl dsGoodMatch(%edx), %ebx
- cmpl %ebx, %eax
- movl dsWMask(%edx), %eax
- movl dsMaxChainLen(%edx), %ebx
- jl LastMatchGood
- shrl $2, %ebx
-LastMatchGood:
-
-/* chainlen is decremented once beforehand so that the function can */
-/* use the sign flag instead of the zero flag for the exit test. */
-/* It is then shifted into the high word, to make room for the wmask */
-/* value, which it will always accompany. */
-
- decl %ebx
- shll $16, %ebx
- orl %eax, %ebx
- movl %ebx, chainlenwmask(%esp)
-
-/* if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; */
-
- movl dsNiceMatch(%edx), %eax
- movl dsLookahead(%edx), %ebx
- cmpl %eax, %ebx
- jl LookaheadLess
- movl %eax, %ebx
-LookaheadLess: movl %ebx, nicematch(%esp)
-
-/* register Bytef *scan = s->window + s->strstart; */
-
- movl dsWindow(%edx), %esi
- movl %esi, window(%esp)
- movl dsStrStart(%edx), %ebp
- lea (%esi,%ebp), %edi
- movl %edi, scan(%esp)
-
-/* Determine how many bytes the scan ptr is off from being */
-/* dword-aligned. */
-
- movl %edi, %eax
- negl %eax
- andl $3, %eax
- movl %eax, scanalign(%esp)
-
-/* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */
-/* s->strstart - (IPos)MAX_DIST(s) : NIL; */
-
- movl dsWSize(%edx), %eax
- subl $MIN_LOOKAHEAD, %eax
- subl %eax, %ebp
- jg LimitPositive
- xorl %ebp, %ebp
-LimitPositive:
-
-/* int best_len = s->prev_length; */
-
- movl dsPrevLen(%edx), %eax
- movl %eax, bestlen(%esp)
-
-/* Store the sum of s->window + best_len in %esi locally, and in %esi. */
-
- addl %eax, %esi
- movl %esi, windowbestlen(%esp)
-
-/* register ush scan_start = *(ushf*)scan; */
-/* register ush scan_end = *(ushf*)(scan+best_len-1); */
-/* Posf *prev = s->prev; */
-
- movzwl (%edi), %ebx
- movl %ebx, scanstart(%esp)
- movzwl -1(%edi,%eax), %ebx
- movl %ebx, scanend(%esp)
- movl dsPrev(%edx), %edi
-
-/* Jump into the main loop. */
-
- movl chainlenwmask(%esp), %edx
- jmp LoopEntry
-
-.balign 16
-
-/* do {
- * match = s->window + cur_match;
- * if (*(ushf*)(match+best_len-1) != scan_end ||
- * *(ushf*)match != scan_start) continue;
- * [...]
- * } while ((cur_match = prev[cur_match & wmask]) > limit
- * && --chain_length != 0);
- *
- * Here is the inner loop of the function. The function will spend the
- * majority of its time in this loop, and majority of that time will
- * be spent in the first ten instructions.
- *
- * Within this loop:
- * %ebx = scanend
- * %ecx = curmatch
- * %edx = chainlenwmask - i.e., ((chainlen << 16) | wmask)
- * %esi = windowbestlen - i.e., (window + bestlen)
- * %edi = prev
- * %ebp = limit
- */
-LookupLoop:
- andl %edx, %ecx
- movzwl (%edi,%ecx,2), %ecx
- cmpl %ebp, %ecx
- jbe LeaveNow
- subl $0x00010000, %edx
- js LeaveNow
-LoopEntry: movzwl -1(%esi,%ecx), %eax
- cmpl %ebx, %eax
- jnz LookupLoop
- movl window(%esp), %eax
- movzwl (%eax,%ecx), %eax
- cmpl scanstart(%esp), %eax
- jnz LookupLoop
-
-/* Store the current value of chainlen. */
-
- movl %edx, chainlenwmask(%esp)
-
-/* Point %edi to the string under scrutiny, and %esi to the string we */
-/* are hoping to match it up with. In actuality, %esi and %edi are */
-/* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */
-/* initialized to -(MAX_MATCH_8 - scanalign). */
-
- movl window(%esp), %esi
- movl scan(%esp), %edi
- addl %ecx, %esi
- movl scanalign(%esp), %eax
- movl $(-MAX_MATCH_8), %edx
- lea MAX_MATCH_8(%edi,%eax), %edi
- lea MAX_MATCH_8(%esi,%eax), %esi
-
-/* Test the strings for equality, 8 bytes at a time. At the end,
- * adjust %edx so that it is offset to the exact byte that mismatched.
- *
- * We already know at this point that the first three bytes of the
- * strings match each other, and they can be safely passed over before
- * starting the compare loop. So what this code does is skip over 0-3
- * bytes, as much as necessary in order to dword-align the %edi
- * pointer. (%esi will still be misaligned three times out of four.)
- *
- * It should be confessed that this loop usually does not represent
- * much of the total running time. Replacing it with a more
- * straightforward "rep cmpsb" would not drastically degrade
- * performance.
- */
-LoopCmps:
- movl (%esi,%edx), %eax
- xorl (%edi,%edx), %eax
- jnz LeaveLoopCmps
- movl 4(%esi,%edx), %eax
- xorl 4(%edi,%edx), %eax
- jnz LeaveLoopCmps4
- addl $8, %edx
- jnz LoopCmps
- jmp LenMaximum
-LeaveLoopCmps4: addl $4, %edx
-LeaveLoopCmps: testl $0x0000FFFF, %eax
- jnz LenLower
- addl $2, %edx
- shrl $16, %eax
-LenLower: subb $1, %al
- adcl $0, %edx
-
-/* Calculate the length of the match. If it is longer than MAX_MATCH, */
-/* then automatically accept it as the best possible match and leave. */
-
- lea (%edi,%edx), %eax
- movl scan(%esp), %edi
- subl %edi, %eax
- cmpl $MAX_MATCH, %eax
- jge LenMaximum
-
-/* If the length of the match is not longer than the best match we */
-/* have so far, then forget it and return to the lookup loop. */
-
- movl deflatestate(%esp), %edx
- movl bestlen(%esp), %ebx
- cmpl %ebx, %eax
- jg LongerMatch
- movl windowbestlen(%esp), %esi
- movl dsPrev(%edx), %edi
- movl scanend(%esp), %ebx
- movl chainlenwmask(%esp), %edx
- jmp LookupLoop
-
-/* s->match_start = cur_match; */
-/* best_len = len; */
-/* if (len >= nice_match) break; */
-/* scan_end = *(ushf*)(scan+best_len-1); */
-
-LongerMatch: movl nicematch(%esp), %ebx
- movl %eax, bestlen(%esp)
- movl %ecx, dsMatchStart(%edx)
- cmpl %ebx, %eax
- jge LeaveNow
- movl window(%esp), %esi
- addl %eax, %esi
- movl %esi, windowbestlen(%esp)
- movzwl -1(%edi,%eax), %ebx
- movl dsPrev(%edx), %edi
- movl %ebx, scanend(%esp)
- movl chainlenwmask(%esp), %edx
- jmp LookupLoop
-
-/* Accept the current string, with the maximum possible length. */
-
-LenMaximum: movl deflatestate(%esp), %edx
- movl $MAX_MATCH, bestlen(%esp)
- movl %ecx, dsMatchStart(%edx)
-
-/* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */
-/* return s->lookahead; */
-
-LeaveNow:
- movl deflatestate(%esp), %edx
- movl bestlen(%esp), %ebx
- movl dsLookahead(%edx), %eax
- cmpl %eax, %ebx
- jg LookaheadRet
- movl %ebx, %eax
-LookaheadRet:
-
-/* Restore the stack and return from whence we came. */
-
- addl $LocalVarsSize, %esp
- popl %ebx
- popl %esi
- popl %edi
- popl %ebp
-match_init: ret
diff --git a/source4/lib/zlib/contrib/blast/Makefile b/source4/lib/zlib/contrib/blast/Makefile
deleted file mode 100644
index 9be80bafe0..0000000000
--- a/source4/lib/zlib/contrib/blast/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-blast: blast.c blast.h
- cc -DTEST -o blast blast.c
-
-test: blast
- blast < test.pk | cmp - test.txt
-
-clean:
- rm -f blast blast.o
diff --git a/source4/lib/zlib/contrib/blast/README b/source4/lib/zlib/contrib/blast/README
deleted file mode 100644
index e3a60b3f5c..0000000000
--- a/source4/lib/zlib/contrib/blast/README
+++ /dev/null
@@ -1,4 +0,0 @@
-Read blast.h for purpose and usage.
-
-Mark Adler
-madler@alumni.caltech.edu
diff --git a/source4/lib/zlib/contrib/blast/blast.c b/source4/lib/zlib/contrib/blast/blast.c
deleted file mode 100644
index 4ce697a41f..0000000000
--- a/source4/lib/zlib/contrib/blast/blast.c
+++ /dev/null
@@ -1,444 +0,0 @@
-/* blast.c
- * Copyright (C) 2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in blast.h
- * version 1.1, 16 Feb 2003
- *
- * blast.c decompresses data compressed by the PKWare Compression Library.
- * This function provides functionality similar to the explode() function of
- * the PKWare library, hence the name "blast".
- *
- * This decompressor is based on the excellent format description provided by
- * Ben Rudiak-Gould in comp.compression on August 13, 2001. Interestingly, the
- * example Ben provided in the post is incorrect. The distance 110001 should
- * instead be 111000. When corrected, the example byte stream becomes:
- *
- * 00 04 82 24 25 8f 80 7f
- *
- * which decompresses to "AIAIAIAIAIAIA" (without the quotes).
- */
-
-/*
- * Change history:
- *
- * 1.0 12 Feb 2003 - First version
- * 1.1 16 Feb 2003 - Fixed distance check for > 4 GB uncompressed data
- */
-
-#include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */
-#include "blast.h" /* prototype for blast() */
-
-#define local static /* for local function definitions */
-#define MAXBITS 13 /* maximum code length */
-#define MAXWIN 4096 /* maximum window size */
-
-/* input and output state */
-struct state {
- /* input state */
- blast_in infun; /* input function provided by user */
- void *inhow; /* opaque information passed to infun() */
- unsigned char *in; /* next input location */
- unsigned left; /* available input at in */
- int bitbuf; /* bit buffer */
- int bitcnt; /* number of bits in bit buffer */
-
- /* input limit error return state for bits() and decode() */
- jmp_buf env;
-
- /* output state */
- blast_out outfun; /* output function provided by user */
- void *outhow; /* opaque information passed to outfun() */
- unsigned next; /* index of next write location in out[] */
- int first; /* true to check distances (for first 4K) */
- unsigned char out[MAXWIN]; /* output buffer and sliding window */
-};
-
-/*
- * Return need bits from the input stream. This always leaves less than
- * eight bits in the buffer. bits() works properly for need == 0.
- *
- * Format notes:
- *
- * - Bits are stored in bytes from the least significant bit to the most
- * significant bit. Therefore bits are dropped from the bottom of the bit
- * buffer, using shift right, and new bytes are appended to the top of the
- * bit buffer, using shift left.
- */
-local int bits(struct state *s, int need)
-{
- int val; /* bit accumulator */
-
- /* load at least need bits into val */
- val = s->bitbuf;
- while (s->bitcnt < need) {
- if (s->left == 0) {
- s->left = s->infun(s->inhow, &(s->in));
- if (s->left == 0) longjmp(s->env, 1); /* out of input */
- }
- val |= (int)(*(s->in)++) << s->bitcnt; /* load eight bits */
- s->left--;
- s->bitcnt += 8;
- }
-
- /* drop need bits and update buffer, always zero to seven bits left */
- s->bitbuf = val >> need;
- s->bitcnt -= need;
-
- /* return need bits, zeroing the bits above that */
- return val & ((1 << need) - 1);
-}
-
-/*
- * Huffman code decoding tables. count[1..MAXBITS] is the number of symbols of
- * each length, which for a canonical code are stepped through in order.
- * symbol[] are the symbol values in canonical order, where the number of
- * entries is the sum of the counts in count[]. The decoding process can be
- * seen in the function decode() below.
- */
-struct huffman {
- short *count; /* number of symbols of each length */
- short *symbol; /* canonically ordered symbols */
-};
-
-/*
- * Decode a code from the stream s using huffman table h. Return the symbol or
- * a negative value if there is an error. If all of the lengths are zero, i.e.
- * an empty code, or if the code is incomplete and an invalid code is received,
- * then -9 is returned after reading MAXBITS bits.
- *
- * Format notes:
- *
- * - The codes as stored in the compressed data are bit-reversed relative to
- * a simple integer ordering of codes of the same lengths. Hence below the
- * bits are pulled from the compressed data one at a time and used to
- * build the code value reversed from what is in the stream in order to
- * permit simple integer comparisons for decoding.
- *
- * - The first code for the shortest length is all ones. Subsequent codes of
- * the same length are simply integer decrements of the previous code. When
- * moving up a length, a one bit is appended to the code. For a complete
- * code, the last code of the longest length will be all zeros. To support
- * this ordering, the bits pulled during decoding are inverted to apply the
- * more "natural" ordering starting with all zeros and incrementing.
- */
-local int decode(struct state *s, struct huffman *h)
-{
- int len; /* current number of bits in code */
- int code; /* len bits being decoded */
- int first; /* first code of length len */
- int count; /* number of codes of length len */
- int index; /* index of first code of length len in symbol table */
- int bitbuf; /* bits from stream */
- int left; /* bits left in next or left to process */
- short *next; /* next number of codes */
-
- bitbuf = s->bitbuf;
- left = s->bitcnt;
- code = first = index = 0;
- len = 1;
- next = h->count + 1;
- while (1) {
- while (left--) {
- code |= (bitbuf & 1) ^ 1; /* invert code */
- bitbuf >>= 1;
- count = *next++;
- if (code < first + count) { /* if length len, return symbol */
- s->bitbuf = bitbuf;
- s->bitcnt = (s->bitcnt - len) & 7;
- return h->symbol[index + (code - first)];
- }
- index += count; /* else update for next length */
- first += count;
- first <<= 1;
- code <<= 1;
- len++;
- }
- left = (MAXBITS+1) - len;
- if (left == 0) break;
- if (s->left == 0) {
- s->left = s->infun(s->inhow, &(s->in));
- if (s->left == 0) longjmp(s->env, 1); /* out of input */
- }
- bitbuf = *(s->in)++;
- s->left--;
- if (left > 8) left = 8;
- }
- return -9; /* ran out of codes */
-}
-
-/*
- * Given a list of repeated code lengths rep[0..n-1], where each byte is a
- * count (high four bits + 1) and a code length (low four bits), generate the
- * list of code lengths. This compaction reduces the size of the object code.
- * Then given the list of code lengths length[0..n-1] representing a canonical
- * Huffman code for n symbols, construct the tables required to decode those
- * codes. Those tables are the number of codes of each length, and the symbols
- * sorted by length, retaining their original order within each length. The
- * return value is zero for a complete code set, negative for an over-
- * subscribed code set, and positive for an incomplete code set. The tables
- * can be used if the return value is zero or positive, but they cannot be used
- * if the return value is negative. If the return value is zero, it is not
- * possible for decode() using that table to return an error--any stream of
- * enough bits will resolve to a symbol. If the return value is positive, then
- * it is possible for decode() using that table to return an error for received
- * codes past the end of the incomplete lengths.
- */
-local int construct(struct huffman *h, const unsigned char *rep, int n)
-{
- int symbol; /* current symbol when stepping through length[] */
- int len; /* current length when stepping through h->count[] */
- int left; /* number of possible codes left of current length */
- short offs[MAXBITS+1]; /* offsets in symbol table for each length */
- short length[256]; /* code lengths */
-
- /* convert compact repeat counts into symbol bit length list */
- symbol = 0;
- do {
- len = *rep++;
- left = (len >> 4) + 1;
- len &= 15;
- do {
- length[symbol++] = len;
- } while (--left);
- } while (--n);
- n = symbol;
-
- /* count number of codes of each length */
- for (len = 0; len <= MAXBITS; len++)
- h->count[len] = 0;
- for (symbol = 0; symbol < n; symbol++)
- (h->count[length[symbol]])++; /* assumes lengths are within bounds */
- if (h->count[0] == n) /* no codes! */
- return 0; /* complete, but decode() will fail */
-
- /* check for an over-subscribed or incomplete set of lengths */
- left = 1; /* one possible code of zero length */
- for (len = 1; len <= MAXBITS; len++) {
- left <<= 1; /* one more bit, double codes left */
- left -= h->count[len]; /* deduct count from possible codes */
- if (left < 0) return left; /* over-subscribed--return negative */
- } /* left > 0 means incomplete */
-
- /* generate offsets into symbol table for each length for sorting */
- offs[1] = 0;
- for (len = 1; len < MAXBITS; len++)
- offs[len + 1] = offs[len] + h->count[len];
-
- /*
- * put symbols in table sorted by length, by symbol order within each
- * length
- */
- for (symbol = 0; symbol < n; symbol++)
- if (length[symbol] != 0)
- h->symbol[offs[length[symbol]]++] = symbol;
-
- /* return zero for complete set, positive for incomplete set */
- return left;
-}
-
-/*
- * Decode PKWare Compression Library stream.
- *
- * Format notes:
- *
- * - First byte is 0 if literals are uncoded or 1 if they are coded. Second
- * byte is 4, 5, or 6 for the number of extra bits in the distance code.
- * This is the base-2 logarithm of the dictionary size minus six.
- *
- * - Compressed data is a combination of literals and length/distance pairs
- * terminated by an end code. Literals are either Huffman coded or
- * uncoded bytes. A length/distance pair is a coded length followed by a
- * coded distance to represent a string that occurs earlier in the
- * uncompressed data that occurs again at the current location.
- *
- * - A bit preceding a literal or length/distance pair indicates which comes
- * next, 0 for literals, 1 for length/distance.
- *
- * - If literals are uncoded, then the next eight bits are the literal, in the
- * normal bit order in th stream, i.e. no bit-reversal is needed. Similarly,
- * no bit reversal is needed for either the length extra bits or the distance
- * extra bits.
- *
- * - Literal bytes are simply written to the output. A length/distance pair is
- * an instruction to copy previously uncompressed bytes to the output. The
- * copy is from distance bytes back in the output stream, copying for length
- * bytes.
- *
- * - Distances pointing before the beginning of the output data are not
- * permitted.
- *
- * - Overlapped copies, where the length is greater than the distance, are
- * allowed and common. For example, a distance of one and a length of 518
- * simply copies the last byte 518 times. A distance of four and a length of
- * twelve copies the last four bytes three times. A simple forward copy
- * ignoring whether the length is greater than the distance or not implements
- * this correctly.
- */
-local int decomp(struct state *s)
-{
- int lit; /* true if literals are coded */
- int dict; /* log2(dictionary size) - 6 */
- int symbol; /* decoded symbol, extra bits for distance */
- int len; /* length for copy */
- int dist; /* distance for copy */
- int copy; /* copy counter */
- unsigned char *from, *to; /* copy pointers */
- static int virgin = 1; /* build tables once */
- static short litcnt[MAXBITS+1], litsym[256]; /* litcode memory */
- static short lencnt[MAXBITS+1], lensym[16]; /* lencode memory */
- static short distcnt[MAXBITS+1], distsym[64]; /* distcode memory */
- static struct huffman litcode = {litcnt, litsym}; /* length code */
- static struct huffman lencode = {lencnt, lensym}; /* length code */
- static struct huffman distcode = {distcnt, distsym};/* distance code */
- /* bit lengths of literal codes */
- static const unsigned char litlen[] = {
- 11, 124, 8, 7, 28, 7, 188, 13, 76, 4, 10, 8, 12, 10, 12, 10, 8, 23, 8,
- 9, 7, 6, 7, 8, 7, 6, 55, 8, 23, 24, 12, 11, 7, 9, 11, 12, 6, 7, 22, 5,
- 7, 24, 6, 11, 9, 6, 7, 22, 7, 11, 38, 7, 9, 8, 25, 11, 8, 11, 9, 12,
- 8, 12, 5, 38, 5, 38, 5, 11, 7, 5, 6, 21, 6, 10, 53, 8, 7, 24, 10, 27,
- 44, 253, 253, 253, 252, 252, 252, 13, 12, 45, 12, 45, 12, 61, 12, 45,
- 44, 173};
- /* bit lengths of length codes 0..15 */
- static const unsigned char lenlen[] = {2, 35, 36, 53, 38, 23};
- /* bit lengths of distance codes 0..63 */
- static const unsigned char distlen[] = {2, 20, 53, 230, 247, 151, 248};
- static const short base[16] = { /* base for length codes */
- 3, 2, 4, 5, 6, 7, 8, 9, 10, 12, 16, 24, 40, 72, 136, 264};
- static const char extra[16] = { /* extra bits for length codes */
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8};
-
- /* set up decoding tables (once--might not be thread-safe) */
- if (virgin) {
- construct(&litcode, litlen, sizeof(litlen));
- construct(&lencode, lenlen, sizeof(lenlen));
- construct(&distcode, distlen, sizeof(distlen));
- virgin = 0;
- }
-
- /* read header */
- lit = bits(s, 8);
- if (lit > 1) return -1;
- dict = bits(s, 8);
- if (dict < 4 || dict > 6) return -2;
-
- /* decode literals and length/distance pairs */
- do {
- if (bits(s, 1)) {
- /* get length */
- symbol = decode(s, &lencode);
- len = base[symbol] + bits(s, extra[symbol]);
- if (len == 519) break; /* end code */
-
- /* get distance */
- symbol = len == 2 ? 2 : dict;
- dist = decode(s, &distcode) << symbol;
- dist += bits(s, symbol);
- dist++;
- if (s->first && dist > s->next)
- return -3; /* distance too far back */
-
- /* copy length bytes from distance bytes back */
- do {
- to = s->out + s->next;
- from = to - dist;
- copy = MAXWIN;
- if (s->next < dist) {
- from += copy;
- copy = dist;
- }
- copy -= s->next;
- if (copy > len) copy = len;
- len -= copy;
- s->next += copy;
- do {
- *to++ = *from++;
- } while (--copy);
- if (s->next == MAXWIN) {
- if (s->outfun(s->outhow, s->out, s->next)) return 1;
- s->next = 0;
- s->first = 0;
- }
- } while (len != 0);
- }
- else {
- /* get literal and write it */
- symbol = lit ? decode(s, &litcode) : bits(s, 8);
- s->out[s->next++] = symbol;
- if (s->next == MAXWIN) {
- if (s->outfun(s->outhow, s->out, s->next)) return 1;
- s->next = 0;
- s->first = 0;
- }
- }
- } while (1);
- return 0;
-}
-
-/* See comments in blast.h */
-int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow)
-{
- struct state s; /* input/output state */
- int err; /* return value */
-
- /* initialize input state */
- s.infun = infun;
- s.inhow = inhow;
- s.left = 0;
- s.bitbuf = 0;
- s.bitcnt = 0;
-
- /* initialize output state */
- s.outfun = outfun;
- s.outhow = outhow;
- s.next = 0;
- s.first = 1;
-
- /* return if bits() or decode() tries to read past available input */
- if (setjmp(s.env) != 0) /* if came back here via longjmp(), */
- err = 2; /* then skip decomp(), return error */
- else
- err = decomp(&s); /* decompress */
-
- /* write any leftover output and update the error code if needed */
- if (err != 1 && s.next && s.outfun(s.outhow, s.out, s.next) && err == 0)
- err = 1;
- return err;
-}
-
-#ifdef TEST
-/* Example of how to use blast() */
-#include <stdio.h>
-#include <stdlib.h>
-
-#define CHUNK 16384
-
-local unsigned inf(void *how, unsigned char **buf)
-{
- static unsigned char hold[CHUNK];
-
- *buf = hold;
- return fread(hold, 1, CHUNK, (FILE *)how);
-}
-
-local int outf(void *how, unsigned char *buf, unsigned len)
-{
- return fwrite(buf, 1, len, (FILE *)how) != len;
-}
-
-/* Decompress a PKWare Compression Library stream from stdin to stdout */
-int main(void)
-{
- int ret, n;
-
- /* decompress to stdout */
- ret = blast(inf, stdin, outf, stdout);
- if (ret != 0) fprintf(stderr, "blast error: %d\n", ret);
-
- /* see if there are any leftover bytes */
- n = 0;
- while (getchar() != EOF) n++;
- if (n) fprintf(stderr, "blast warning: %d unused bytes of input\n", n);
-
- /* return blast() error code */
- return ret;
-}
-#endif
diff --git a/source4/lib/zlib/contrib/blast/blast.h b/source4/lib/zlib/contrib/blast/blast.h
deleted file mode 100644
index ce9e5410f4..0000000000
--- a/source4/lib/zlib/contrib/blast/blast.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* blast.h -- interface for blast.c
- Copyright (C) 2003 Mark Adler
- version 1.1, 16 Feb 2003
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the author be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Mark Adler madler@alumni.caltech.edu
- */
-
-
-/*
- * blast() decompresses the PKWare Data Compression Library (DCL) compressed
- * format. It provides the same functionality as the explode() function in
- * that library. (Note: PKWare overused the "implode" verb, and the format
- * used by their library implode() function is completely different and
- * incompatible with the implode compression method supported by PKZIP.)
- */
-
-
-typedef unsigned (*blast_in)(void *how, unsigned char **buf);
-typedef int (*blast_out)(void *how, unsigned char *buf, unsigned len);
-/* Definitions for input/output functions passed to blast(). See below for
- * what the provided functions need to do.
- */
-
-
-int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow);
-/* Decompress input to output using the provided infun() and outfun() calls.
- * On success, the return value of blast() is zero. If there is an error in
- * the source data, i.e. it is not in the proper format, then a negative value
- * is returned. If there is not enough input available or there is not enough
- * output space, then a positive error is returned.
- *
- * The input function is invoked: len = infun(how, &buf), where buf is set by
- * infun() to point to the input buffer, and infun() returns the number of
- * available bytes there. If infun() returns zero, then blast() returns with
- * an input error. (blast() only asks for input if it needs it.) inhow is for
- * use by the application to pass an input descriptor to infun(), if desired.
- *
- * The output function is invoked: err = outfun(how, buf, len), where the bytes
- * to be written are buf[0..len-1]. If err is not zero, then blast() returns
- * with an output error. outfun() is always called with len <= 4096. outhow
- * is for use by the application to pass an output descriptor to outfun(), if
- * desired.
- *
- * The return codes are:
- *
- * 2: ran out of input before completing decompression
- * 1: output error before completing decompression
- * 0: successful decompression
- * -1: literal flag not zero or one
- * -2: dictionary size not in 4..6
- * -3: distance is too far back
- *
- * At the bottom of blast.c is an example program that uses blast() that can be
- * compiled to produce a command-line decompression filter by defining TEST.
- */
diff --git a/source4/lib/zlib/contrib/blast/test.pk b/source4/lib/zlib/contrib/blast/test.pk
deleted file mode 100644
index be10b2bbb2..0000000000
--- a/source4/lib/zlib/contrib/blast/test.pk
+++ /dev/null
Binary files differ
diff --git a/source4/lib/zlib/contrib/blast/test.txt b/source4/lib/zlib/contrib/blast/test.txt
deleted file mode 100644
index bfdf1c5dca..0000000000
--- a/source4/lib/zlib/contrib/blast/test.txt
+++ /dev/null
@@ -1 +0,0 @@
-AIAIAIAIAIAIA \ No newline at end of file
diff --git a/source4/lib/zlib/contrib/delphi/ZLib.pas b/source4/lib/zlib/contrib/delphi/ZLib.pas
deleted file mode 100644
index 3f2b8b4a5c..0000000000
--- a/source4/lib/zlib/contrib/delphi/ZLib.pas
+++ /dev/null
@@ -1,557 +0,0 @@
-{*******************************************************}
-{ }
-{ Borland Delphi Supplemental Components }
-{ ZLIB Data Compression Interface Unit }
-{ }
-{ Copyright (c) 1997,99 Borland Corporation }
-{ }
-{*******************************************************}
-
-{ Updated for zlib 1.2.x by Cosmin Truta <cosmint@cs.ubbcluj.ro> }
-
-unit ZLib;
-
-interface
-
-uses SysUtils, Classes;
-
-type
- TAlloc = function (AppData: Pointer; Items, Size: Integer): Pointer; cdecl;
- TFree = procedure (AppData, Block: Pointer); cdecl;
-
- // Internal structure. Ignore.
- TZStreamRec = packed record
- next_in: PChar; // next input byte
- avail_in: Integer; // number of bytes available at next_in
- total_in: Longint; // total nb of input bytes read so far
-
- next_out: PChar; // next output byte should be put here
- avail_out: Integer; // remaining free space at next_out
- total_out: Longint; // total nb of bytes output so far
-
- msg: PChar; // last error message, NULL if no error
- internal: Pointer; // not visible by applications
-
- zalloc: TAlloc; // used to allocate the internal state
- zfree: TFree; // used to free the internal state
- AppData: Pointer; // private data object passed to zalloc and zfree
-
- data_type: Integer; // best guess about the data type: ascii or binary
- adler: Longint; // adler32 value of the uncompressed data
- reserved: Longint; // reserved for future use
- end;
-
- // Abstract ancestor class
- TCustomZlibStream = class(TStream)
- private
- FStrm: TStream;
- FStrmPos: Integer;
- FOnProgress: TNotifyEvent;
- FZRec: TZStreamRec;
- FBuffer: array [Word] of Char;
- protected
- procedure Progress(Sender: TObject); dynamic;
- property OnProgress: TNotifyEvent read FOnProgress write FOnProgress;
- constructor Create(Strm: TStream);
- end;
-
-{ TCompressionStream compresses data on the fly as data is written to it, and
- stores the compressed data to another stream.
-
- TCompressionStream is write-only and strictly sequential. Reading from the
- stream will raise an exception. Using Seek to move the stream pointer
- will raise an exception.
-
- Output data is cached internally, written to the output stream only when
- the internal output buffer is full. All pending output data is flushed
- when the stream is destroyed.
-
- The Position property returns the number of uncompressed bytes of
- data that have been written to the stream so far.
-
- CompressionRate returns the on-the-fly percentage by which the original
- data has been compressed: (1 - (CompressedBytes / UncompressedBytes)) * 100
- If raw data size = 100 and compressed data size = 25, the CompressionRate
- is 75%
-
- The OnProgress event is called each time the output buffer is filled and
- written to the output stream. This is useful for updating a progress
- indicator when you are writing a large chunk of data to the compression
- stream in a single call.}
-
-
- TCompressionLevel = (clNone, clFastest, clDefault, clMax);
-
- TCompressionStream = class(TCustomZlibStream)
- private
- function GetCompressionRate: Single;
- public
- constructor Create(CompressionLevel: TCompressionLevel; Dest: TStream);
- destructor Destroy; override;
- function Read(var Buffer; Count: Longint): Longint; override;
- function Write(const Buffer; Count: Longint): Longint; override;
- function Seek(Offset: Longint; Origin: Word): Longint; override;
- property CompressionRate: Single read GetCompressionRate;
- property OnProgress;
- end;
-
-{ TDecompressionStream decompresses data on the fly as data is read from it.
-
- Compressed data comes from a separate source stream. TDecompressionStream
- is read-only and unidirectional; you can seek forward in the stream, but not
- backwards. The special case of setting the stream position to zero is
- allowed. Seeking forward decompresses data until the requested position in
- the uncompressed data has been reached. Seeking backwards, seeking relative
- to the end of the stream, requesting the size of the stream, and writing to
- the stream will raise an exception.
-
- The Position property returns the number of bytes of uncompressed data that
- have been read from the stream so far.
-
- The OnProgress event is called each time the internal input buffer of
- compressed data is exhausted and the next block is read from the input stream.
- This is useful for updating a progress indicator when you are reading a
- large chunk of data from the decompression stream in a single call.}
-
- TDecompressionStream = class(TCustomZlibStream)
- public
- constructor Create(Source: TStream);
- destructor Destroy; override;
- function Read(var Buffer; Count: Longint): Longint; override;
- function Write(const Buffer; Count: Longint): Longint; override;
- function Seek(Offset: Longint; Origin: Word): Longint; override;
- property OnProgress;
- end;
-
-
-
-{ CompressBuf compresses data, buffer to buffer, in one call.
- In: InBuf = ptr to compressed data
- InBytes = number of bytes in InBuf
- Out: OutBuf = ptr to newly allocated buffer containing decompressed data
- OutBytes = number of bytes in OutBuf }
-procedure CompressBuf(const InBuf: Pointer; InBytes: Integer;
- out OutBuf: Pointer; out OutBytes: Integer);
-
-
-{ DecompressBuf decompresses data, buffer to buffer, in one call.
- In: InBuf = ptr to compressed data
- InBytes = number of bytes in InBuf
- OutEstimate = zero, or est. size of the decompressed data
- Out: OutBuf = ptr to newly allocated buffer containing decompressed data
- OutBytes = number of bytes in OutBuf }
-procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer;
- OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer);
-
-{ DecompressToUserBuf decompresses data, buffer to buffer, in one call.
- In: InBuf = ptr to compressed data
- InBytes = number of bytes in InBuf
- Out: OutBuf = ptr to user-allocated buffer to contain decompressed data
- BufSize = number of bytes in OutBuf }
-procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer;
- const OutBuf: Pointer; BufSize: Integer);
-
-const
- zlib_version = '1.2.3';
-
-type
- EZlibError = class(Exception);
- ECompressionError = class(EZlibError);
- EDecompressionError = class(EZlibError);
-
-implementation
-
-uses ZLibConst;
-
-const
- Z_NO_FLUSH = 0;
- Z_PARTIAL_FLUSH = 1;
- Z_SYNC_FLUSH = 2;
- Z_FULL_FLUSH = 3;
- Z_FINISH = 4;
-
- Z_OK = 0;
- Z_STREAM_END = 1;
- Z_NEED_DICT = 2;
- Z_ERRNO = (-1);
- Z_STREAM_ERROR = (-2);
- Z_DATA_ERROR = (-3);
- Z_MEM_ERROR = (-4);
- Z_BUF_ERROR = (-5);
- Z_VERSION_ERROR = (-6);
-
- Z_NO_COMPRESSION = 0;
- Z_BEST_SPEED = 1;
- Z_BEST_COMPRESSION = 9;
- Z_DEFAULT_COMPRESSION = (-1);
-
- Z_FILTERED = 1;
- Z_HUFFMAN_ONLY = 2;
- Z_RLE = 3;
- Z_DEFAULT_STRATEGY = 0;
-
- Z_BINARY = 0;
- Z_ASCII = 1;
- Z_UNKNOWN = 2;
-
- Z_DEFLATED = 8;
-
-
-{$L adler32.obj}
-{$L compress.obj}
-{$L crc32.obj}
-{$L deflate.obj}
-{$L infback.obj}
-{$L inffast.obj}
-{$L inflate.obj}
-{$L inftrees.obj}
-{$L trees.obj}
-{$L uncompr.obj}
-{$L zutil.obj}
-
-procedure adler32; external;
-procedure compressBound; external;
-procedure crc32; external;
-procedure deflateInit2_; external;
-procedure deflateParams; external;
-
-function _malloc(Size: Integer): Pointer; cdecl;
-begin
- Result := AllocMem(Size);
-end;
-
-procedure _free(Block: Pointer); cdecl;
-begin
- FreeMem(Block);
-end;
-
-procedure _memset(P: Pointer; B: Byte; count: Integer); cdecl;
-begin
- FillChar(P^, count, B);
-end;
-
-procedure _memcpy(dest, source: Pointer; count: Integer); cdecl;
-begin
- Move(source^, dest^, count);
-end;
-
-
-
-// deflate compresses data
-function deflateInit_(var strm: TZStreamRec; level: Integer; version: PChar;
- recsize: Integer): Integer; external;
-function deflate(var strm: TZStreamRec; flush: Integer): Integer; external;
-function deflateEnd(var strm: TZStreamRec): Integer; external;
-
-// inflate decompresses data
-function inflateInit_(var strm: TZStreamRec; version: PChar;
- recsize: Integer): Integer; external;
-function inflate(var strm: TZStreamRec; flush: Integer): Integer; external;
-function inflateEnd(var strm: TZStreamRec): Integer; external;
-function inflateReset(var strm: TZStreamRec): Integer; external;
-
-
-function zlibAllocMem(AppData: Pointer; Items, Size: Integer): Pointer; cdecl;
-begin
-// GetMem(Result, Items*Size);
- Result := AllocMem(Items * Size);
-end;
-
-procedure zlibFreeMem(AppData, Block: Pointer); cdecl;
-begin
- FreeMem(Block);
-end;
-
-{function zlibCheck(code: Integer): Integer;
-begin
- Result := code;
- if code < 0 then
- raise EZlibError.Create('error'); //!!
-end;}
-
-function CCheck(code: Integer): Integer;
-begin
- Result := code;
- if code < 0 then
- raise ECompressionError.Create('error'); //!!
-end;
-
-function DCheck(code: Integer): Integer;
-begin
- Result := code;
- if code < 0 then
- raise EDecompressionError.Create('error'); //!!
-end;
-
-procedure CompressBuf(const InBuf: Pointer; InBytes: Integer;
- out OutBuf: Pointer; out OutBytes: Integer);
-var
- strm: TZStreamRec;
- P: Pointer;
-begin
- FillChar(strm, sizeof(strm), 0);
- strm.zalloc := zlibAllocMem;
- strm.zfree := zlibFreeMem;
- OutBytes := ((InBytes + (InBytes div 10) + 12) + 255) and not 255;
- GetMem(OutBuf, OutBytes);
- try
- strm.next_in := InBuf;
- strm.avail_in := InBytes;
- strm.next_out := OutBuf;
- strm.avail_out := OutBytes;
- CCheck(deflateInit_(strm, Z_BEST_COMPRESSION, zlib_version, sizeof(strm)));
- try
- while CCheck(deflate(strm, Z_FINISH)) <> Z_STREAM_END do
- begin
- P := OutBuf;
- Inc(OutBytes, 256);
- ReallocMem(OutBuf, OutBytes);
- strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P)));
- strm.avail_out := 256;
- end;
- finally
- CCheck(deflateEnd(strm));
- end;
- ReallocMem(OutBuf, strm.total_out);
- OutBytes := strm.total_out;
- except
- FreeMem(OutBuf);
- raise
- end;
-end;
-
-
-procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer;
- OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer);
-var
- strm: TZStreamRec;
- P: Pointer;
- BufInc: Integer;
-begin
- FillChar(strm, sizeof(strm), 0);
- strm.zalloc := zlibAllocMem;
- strm.zfree := zlibFreeMem;
- BufInc := (InBytes + 255) and not 255;
- if OutEstimate = 0 then
- OutBytes := BufInc
- else
- OutBytes := OutEstimate;
- GetMem(OutBuf, OutBytes);
- try
- strm.next_in := InBuf;
- strm.avail_in := InBytes;
- strm.next_out := OutBuf;
- strm.avail_out := OutBytes;
- DCheck(inflateInit_(strm, zlib_version, sizeof(strm)));
- try
- while DCheck(inflate(strm, Z_NO_FLUSH)) <> Z_STREAM_END do
- begin
- P := OutBuf;
- Inc(OutBytes, BufInc);
- ReallocMem(OutBuf, OutBytes);
- strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P)));
- strm.avail_out := BufInc;
- end;
- finally
- DCheck(inflateEnd(strm));
- end;
- ReallocMem(OutBuf, strm.total_out);
- OutBytes := strm.total_out;
- except
- FreeMem(OutBuf);
- raise
- end;
-end;
-
-procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer;
- const OutBuf: Pointer; BufSize: Integer);
-var
- strm: TZStreamRec;
-begin
- FillChar(strm, sizeof(strm), 0);
- strm.zalloc := zlibAllocMem;
- strm.zfree := zlibFreeMem;
- strm.next_in := InBuf;
- strm.avail_in := InBytes;
- strm.next_out := OutBuf;
- strm.avail_out := BufSize;
- DCheck(inflateInit_(strm, zlib_version, sizeof(strm)));
- try
- if DCheck(inflate(strm, Z_FINISH)) <> Z_STREAM_END then
- raise EZlibError.CreateRes(@sTargetBufferTooSmall);
- finally
- DCheck(inflateEnd(strm));
- end;
-end;
-
-// TCustomZlibStream
-
-constructor TCustomZLibStream.Create(Strm: TStream);
-begin
- inherited Create;
- FStrm := Strm;
- FStrmPos := Strm.Position;
- FZRec.zalloc := zlibAllocMem;
- FZRec.zfree := zlibFreeMem;
-end;
-
-procedure TCustomZLibStream.Progress(Sender: TObject);
-begin
- if Assigned(FOnProgress) then FOnProgress(Sender);
-end;
-
-
-// TCompressionStream
-
-constructor TCompressionStream.Create(CompressionLevel: TCompressionLevel;
- Dest: TStream);
-const
- Levels: array [TCompressionLevel] of ShortInt =
- (Z_NO_COMPRESSION, Z_BEST_SPEED, Z_DEFAULT_COMPRESSION, Z_BEST_COMPRESSION);
-begin
- inherited Create(Dest);
- FZRec.next_out := FBuffer;
- FZRec.avail_out := sizeof(FBuffer);
- CCheck(deflateInit_(FZRec, Levels[CompressionLevel], zlib_version, sizeof(FZRec)));
-end;
-
-destructor TCompressionStream.Destroy;
-begin
- FZRec.next_in := nil;
- FZRec.avail_in := 0;
- try
- if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos;
- while (CCheck(deflate(FZRec, Z_FINISH)) <> Z_STREAM_END)
- and (FZRec.avail_out = 0) do
- begin
- FStrm.WriteBuffer(FBuffer, sizeof(FBuffer));
- FZRec.next_out := FBuffer;
- FZRec.avail_out := sizeof(FBuffer);
- end;
- if FZRec.avail_out < sizeof(FBuffer) then
- FStrm.WriteBuffer(FBuffer, sizeof(FBuffer) - FZRec.avail_out);
- finally
- deflateEnd(FZRec);
- end;
- inherited Destroy;
-end;
-
-function TCompressionStream.Read(var Buffer; Count: Longint): Longint;
-begin
- raise ECompressionError.CreateRes(@sInvalidStreamOp);
-end;
-
-function TCompressionStream.Write(const Buffer; Count: Longint): Longint;
-begin
- FZRec.next_in := @Buffer;
- FZRec.avail_in := Count;
- if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos;
- while (FZRec.avail_in > 0) do
- begin
- CCheck(deflate(FZRec, 0));
- if FZRec.avail_out = 0 then
- begin
- FStrm.WriteBuffer(FBuffer, sizeof(FBuffer));
- FZRec.next_out := FBuffer;
- FZRec.avail_out := sizeof(FBuffer);
- FStrmPos := FStrm.Position;
- Progress(Self);
- end;
- end;
- Result := Count;
-end;
-
-function TCompressionStream.Seek(Offset: Longint; Origin: Word): Longint;
-begin
- if (Offset = 0) and (Origin = soFromCurrent) then
- Result := FZRec.total_in
- else
- raise ECompressionError.CreateRes(@sInvalidStreamOp);
-end;
-
-function TCompressionStream.GetCompressionRate: Single;
-begin
- if FZRec.total_in = 0 then
- Result := 0
- else
- Result := (1.0 - (FZRec.total_out / FZRec.total_in)) * 100.0;
-end;
-
-
-// TDecompressionStream
-
-constructor TDecompressionStream.Create(Source: TStream);
-begin
- inherited Create(Source);
- FZRec.next_in := FBuffer;
- FZRec.avail_in := 0;
- DCheck(inflateInit_(FZRec, zlib_version, sizeof(FZRec)));
-end;
-
-destructor TDecompressionStream.Destroy;
-begin
- FStrm.Seek(-FZRec.avail_in, 1);
- inflateEnd(FZRec);
- inherited Destroy;
-end;
-
-function TDecompressionStream.Read(var Buffer; Count: Longint): Longint;
-begin
- FZRec.next_out := @Buffer;
- FZRec.avail_out := Count;
- if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos;
- while (FZRec.avail_out > 0) do
- begin
- if FZRec.avail_in = 0 then
- begin
- FZRec.avail_in := FStrm.Read(FBuffer, sizeof(FBuffer));
- if FZRec.avail_in = 0 then
- begin
- Result := Count - FZRec.avail_out;
- Exit;
- end;
- FZRec.next_in := FBuffer;
- FStrmPos := FStrm.Position;
- Progress(Self);
- end;
- CCheck(inflate(FZRec, 0));
- end;
- Result := Count;
-end;
-
-function TDecompressionStream.Write(const Buffer; Count: Longint): Longint;
-begin
- raise EDecompressionError.CreateRes(@sInvalidStreamOp);
-end;
-
-function TDecompressionStream.Seek(Offset: Longint; Origin: Word): Longint;
-var
- I: Integer;
- Buf: array [0..4095] of Char;
-begin
- if (Offset = 0) and (Origin = soFromBeginning) then
- begin
- DCheck(inflateReset(FZRec));
- FZRec.next_in := FBuffer;
- FZRec.avail_in := 0;
- FStrm.Position := 0;
- FStrmPos := 0;
- end
- else if ( (Offset >= 0) and (Origin = soFromCurrent)) or
- ( ((Offset - FZRec.total_out) > 0) and (Origin = soFromBeginning)) then
- begin
- if Origin = soFromBeginning then Dec(Offset, FZRec.total_out);
- if Offset > 0 then
- begin
- for I := 1 to Offset div sizeof(Buf) do
- ReadBuffer(Buf, sizeof(Buf));
- ReadBuffer(Buf, Offset mod sizeof(Buf));
- end;
- end
- else
- raise EDecompressionError.CreateRes(@sInvalidStreamOp);
- Result := FZRec.total_out;
-end;
-
-
-end.
diff --git a/source4/lib/zlib/contrib/delphi/ZLibConst.pas b/source4/lib/zlib/contrib/delphi/ZLibConst.pas
deleted file mode 100644
index cdfe13671d..0000000000
--- a/source4/lib/zlib/contrib/delphi/ZLibConst.pas
+++ /dev/null
@@ -1,11 +0,0 @@
-unit ZLibConst;
-
-interface
-
-resourcestring
- sTargetBufferTooSmall = 'ZLib error: target buffer may be too small';
- sInvalidStreamOp = 'Invalid stream operation';
-
-implementation
-
-end.
diff --git a/source4/lib/zlib/contrib/delphi/readme.txt b/source4/lib/zlib/contrib/delphi/readme.txt
deleted file mode 100644
index 2dc9a8bba2..0000000000
--- a/source4/lib/zlib/contrib/delphi/readme.txt
+++ /dev/null
@@ -1,76 +0,0 @@
-
-Overview
-========
-
-This directory contains an update to the ZLib interface unit,
-distributed by Borland as a Delphi supplemental component.
-
-The original ZLib unit is Copyright (c) 1997,99 Borland Corp.,
-and is based on zlib version 1.0.4. There are a series of bugs
-and security problems associated with that old zlib version, and
-we recommend the users to update their ZLib unit.
-
-
-Summary of modifications
-========================
-
-- Improved makefile, adapted to zlib version 1.2.1.
-
-- Some field types from TZStreamRec are changed from Integer to
- Longint, for consistency with the zlib.h header, and for 64-bit
- readiness.
-
-- The zlib_version constant is updated.
-
-- The new Z_RLE strategy has its corresponding symbolic constant.
-
-- The allocation and deallocation functions and function types
- (TAlloc, TFree, zlibAllocMem and zlibFreeMem) are now cdecl,
- and _malloc and _free are added as C RTL stubs. As a result,
- the original C sources of zlib can be compiled out of the box,
- and linked to the ZLib unit.
-
-
-Suggestions for improvements
-============================
-
-Currently, the ZLib unit provides only a limited wrapper around
-the zlib library, and much of the original zlib functionality is
-missing. Handling compressed file formats like ZIP/GZIP or PNG
-cannot be implemented without having this functionality.
-Applications that handle these formats are either using their own,
-duplicated code, or not using the ZLib unit at all.
-
-Here are a few suggestions:
-
-- Checksum class wrappers around adler32() and crc32(), similar
- to the Java classes that implement the java.util.zip.Checksum
- interface.
-
-- The ability to read and write raw deflate streams, without the
- zlib stream header and trailer. Raw deflate streams are used
- in the ZIP file format.
-
-- The ability to read and write gzip streams, used in the GZIP
- file format, and normally produced by the gzip program.
-
-- The ability to select a different compression strategy, useful
- to PNG and MNG image compression, and to multimedia compression
- in general. Besides the compression level
-
- TCompressionLevel = (clNone, clFastest, clDefault, clMax);
-
- which, in fact, could have used the 'z' prefix and avoided
- TColor-like symbols
-
- TCompressionLevel = (zcNone, zcFastest, zcDefault, zcMax);
-
- there could be a compression strategy
-
- TCompressionStrategy = (zsDefault, zsFiltered, zsHuffmanOnly, zsRle);
-
-- ZIP and GZIP stream handling via TStreams.
-
-
---
-Cosmin Truta <cosmint@cs.ubbcluj.ro>
diff --git a/source4/lib/zlib/contrib/delphi/zlibd32.mak b/source4/lib/zlib/contrib/delphi/zlibd32.mak
deleted file mode 100644
index 88fafa0b14..0000000000
--- a/source4/lib/zlib/contrib/delphi/zlibd32.mak
+++ /dev/null
@@ -1,93 +0,0 @@
-# Makefile for zlib
-# For use with Delphi and C++ Builder under Win32
-# Updated for zlib 1.2.x by Cosmin Truta
-
-# ------------ Borland C++ ------------
-
-# This project uses the Delphi (fastcall/register) calling convention:
-LOC = -DZEXPORT=__fastcall -DZEXPORTVA=__cdecl
-
-CC = bcc32
-LD = bcc32
-AR = tlib
-# do not use "-pr" in CFLAGS
-CFLAGS = -a -d -k- -O2 $(LOC)
-LDFLAGS =
-
-
-# variables
-ZLIB_LIB = zlib.lib
-
-OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj
-OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj
-OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj
-OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj
-
-
-# targets
-all: $(ZLIB_LIB) example.exe minigzip.exe
-
-.c.obj:
- $(CC) -c $(CFLAGS) $*.c
-
-adler32.obj: adler32.c zlib.h zconf.h
-
-compress.obj: compress.c zlib.h zconf.h
-
-crc32.obj: crc32.c zlib.h zconf.h crc32.h
-
-deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h
-
-gzio.obj: gzio.c zutil.h zlib.h zconf.h
-
-infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h inffixed.h
-
-inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h
-
-inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h inffixed.h
-
-inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h
-
-trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h
-
-uncompr.obj: uncompr.c zlib.h zconf.h
-
-zutil.obj: zutil.c zutil.h zlib.h zconf.h
-
-example.obj: example.c zlib.h zconf.h
-
-minigzip.obj: minigzip.c zlib.h zconf.h
-
-
-# For the sake of the old Borland make,
-# the command line is cut to fit in the MS-DOS 128 byte limit:
-$(ZLIB_LIB): $(OBJ1) $(OBJ2)
- -del $(ZLIB_LIB)
- $(AR) $(ZLIB_LIB) $(OBJP1)
- $(AR) $(ZLIB_LIB) $(OBJP2)
-
-
-# testing
-test: example.exe minigzip.exe
- example
- echo hello world | minigzip | minigzip -d
-
-example.exe: example.obj $(ZLIB_LIB)
- $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB)
-
-minigzip.exe: minigzip.obj $(ZLIB_LIB)
- $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB)
-
-
-# cleanup
-clean:
- -del *.obj
- -del *.exe
- -del *.lib
- -del *.tds
- -del zlib.bak
- -del foo.gz
-
diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib.build b/source4/lib/zlib/contrib/dotzlib/DotZLib.build
deleted file mode 100644
index ed19cc9dcd..0000000000
--- a/source4/lib/zlib/contrib/dotzlib/DotZLib.build
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<project name="DotZLib" default="build" basedir="./DotZLib">
- <description>A .Net wrapper library around ZLib1.dll</description>
-
- <property name="nunit.location" value="c:/program files/NUnit V2.1/bin" />
- <property name="build.root" value="bin" />
-
- <property name="debug" value="true" />
- <property name="nunit" value="true" />
-
- <property name="build.folder" value="${build.root}/debug/" if="${debug}" />
- <property name="build.folder" value="${build.root}/release/" unless="${debug}" />
-
- <target name="clean" description="Remove all generated files">
- <delete dir="${build.root}" failonerror="false" />
- </target>
-
- <target name="build" description="compiles the source code">
-
- <mkdir dir="${build.folder}" />
- <csc target="library" output="${build.folder}DotZLib.dll" debug="${debug}">
- <references basedir="${nunit.location}">
- <includes if="${nunit}" name="nunit.framework.dll" />
- </references>
- <sources>
- <includes name="*.cs" />
- <excludes name="UnitTests.cs" unless="${nunit}" />
- </sources>
- <arg value="/d:nunit" if="${nunit}" />
- </csc>
- </target>
-
-</project> \ No newline at end of file
diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib.chm b/source4/lib/zlib/contrib/dotzlib/DotZLib.chm
deleted file mode 100644
index 0bc7df76e4..0000000000
--- a/source4/lib/zlib/contrib/dotzlib/DotZLib.chm
+++ /dev/null
Binary files differ
diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib.sln b/source4/lib/zlib/contrib/dotzlib/DotZLib.sln
deleted file mode 100644
index ac45ca048b..0000000000
--- a/source4/lib/zlib/contrib/dotzlib/DotZLib.sln
+++ /dev/null
@@ -1,21 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotZLib", "DotZLib\DotZLib.csproj", "{BB1EE0B1-1808-46CB-B786-949D91117FC5}"
- ProjectSection(ProjectDependencies) = postProject
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfiguration) = preSolution
- Debug = Debug
- Release = Release
- EndGlobalSection
- GlobalSection(ProjectConfiguration) = postSolution
- {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Debug.ActiveCfg = Debug|.NET
- {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Debug.Build.0 = Debug|.NET
- {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Release.ActiveCfg = Release|.NET
- {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Release.Build.0 = Release|.NET
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- EndGlobalSection
- GlobalSection(ExtensibilityAddIns) = postSolution
- EndGlobalSection
-EndGlobal
diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs b/source4/lib/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs
deleted file mode 100644
index 6fc0fdcc24..0000000000
--- a/source4/lib/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
-[assembly: AssemblyTitle("DotZLib")]
-[assembly: AssemblyDescription(".Net bindings for ZLib compression dll 1.2.x")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Henrik Ravn")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("(c) 2004 by Henrik Ravn")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-
-[assembly: AssemblyVersion("1.0.*")]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs b/source4/lib/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs
deleted file mode 100644
index dfe7e90a8a..0000000000
--- a/source4/lib/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs
+++ /dev/null
@@ -1,202 +0,0 @@
-//
-// © Copyright Henrik Ravn 2004
-//
-// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-using System;
-using System.Runtime.InteropServices;
-using System.Text;
-
-
-namespace DotZLib
-{
- #region ChecksumGeneratorBase
- /// <summary>
- /// Implements the common functionality needed for all <see cref="ChecksumGenerator"/>s
- /// </summary>
- /// <example></example>
- public abstract class ChecksumGeneratorBase : ChecksumGenerator
- {
- /// <summary>
- /// The value of the current checksum
- /// </summary>
- protected uint _current;
-
- /// <summary>
- /// Initializes a new instance of the checksum generator base - the current checksum is
- /// set to zero
- /// </summary>
- public ChecksumGeneratorBase()
- {
- _current = 0;
- }
-
- /// <summary>
- /// Initializes a new instance of the checksum generator basewith a specified value
- /// </summary>
- /// <param name="initialValue">The value to set the current checksum to</param>
- public ChecksumGeneratorBase(uint initialValue)
- {
- _current = initialValue;
- }
-
- /// <summary>
- /// Resets the current checksum to zero
- /// </summary>
- public void Reset() { _current = 0; }
-
- /// <summary>
- /// Gets the current checksum value
- /// </summary>
- public uint Value { get { return _current; } }
-
- /// <summary>
- /// Updates the current checksum with part of an array of bytes
- /// </summary>
- /// <param name="data">The data to update the checksum with</param>
- /// <param name="offset">Where in <c>data</c> to start updating</param>
- /// <param name="count">The number of bytes from <c>data</c> to use</param>
- /// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
- /// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
- /// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
- /// <remarks>All the other <c>Update</c> methods are implmeneted in terms of this one.
- /// This is therefore the only method a derived class has to implement</remarks>
- public abstract void Update(byte[] data, int offset, int count);
-
- /// <summary>
- /// Updates the current checksum with an array of bytes.
- /// </summary>
- /// <param name="data">The data to update the checksum with</param>
- public void Update(byte[] data)
- {
- Update(data, 0, data.Length);
- }
-
- /// <summary>
- /// Updates the current checksum with the data from a string
- /// </summary>
- /// <param name="data">The string to update the checksum with</param>
- /// <remarks>The characters in the string are converted by the UTF-8 encoding</remarks>
- public void Update(string data)
- {
- Update(Encoding.UTF8.GetBytes(data));
- }
-
- /// <summary>
- /// Updates the current checksum with the data from a string, using a specific encoding
- /// </summary>
- /// <param name="data">The string to update the checksum with</param>
- /// <param name="encoding">The encoding to use</param>
- public void Update(string data, Encoding encoding)
- {
- Update(encoding.GetBytes(data));
- }
-
- }
- #endregion
-
- #region CRC32
- /// <summary>
- /// Implements a CRC32 checksum generator
- /// </summary>
- public sealed class CRC32Checksum : ChecksumGeneratorBase
- {
- #region DLL imports
-
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
- private static extern uint crc32(uint crc, int data, uint length);
-
- #endregion
-
- /// <summary>
- /// Initializes a new instance of the CRC32 checksum generator
- /// </summary>
- public CRC32Checksum() : base() {}
-
- /// <summary>
- /// Initializes a new instance of the CRC32 checksum generator with a specified value
- /// </summary>
- /// <param name="initialValue">The value to set the current checksum to</param>
- public CRC32Checksum(uint initialValue) : base(initialValue) {}
-
- /// <summary>
- /// Updates the current checksum with part of an array of bytes
- /// </summary>
- /// <param name="data">The data to update the checksum with</param>
- /// <param name="offset">Where in <c>data</c> to start updating</param>
- /// <param name="count">The number of bytes from <c>data</c> to use</param>
- /// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
- /// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
- /// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
- public override void Update(byte[] data, int offset, int count)
- {
- if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
- if ((offset+count) > data.Length) throw new ArgumentException();
- GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned);
- try
- {
- _current = crc32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count);
- }
- finally
- {
- hData.Free();
- }
- }
-
- }
- #endregion
-
- #region Adler
- /// <summary>
- /// Implements a checksum generator that computes the Adler checksum on data
- /// </summary>
- public sealed class AdlerChecksum : ChecksumGeneratorBase
- {
- #region DLL imports
-
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
- private static extern uint adler32(uint adler, int data, uint length);
-
- #endregion
-
- /// <summary>
- /// Initializes a new instance of the Adler checksum generator
- /// </summary>
- public AdlerChecksum() : base() {}
-
- /// <summary>
- /// Initializes a new instance of the Adler checksum generator with a specified value
- /// </summary>
- /// <param name="initialValue">The value to set the current checksum to</param>
- public AdlerChecksum(uint initialValue) : base(initialValue) {}
-
- /// <summary>
- /// Updates the current checksum with part of an array of bytes
- /// </summary>
- /// <param name="data">The data to update the checksum with</param>
- /// <param name="offset">Where in <c>data</c> to start updating</param>
- /// <param name="count">The number of bytes from <c>data</c> to use</param>
- /// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
- /// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
- /// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
- public override void Update(byte[] data, int offset, int count)
- {
- if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
- if ((offset+count) > data.Length) throw new ArgumentException();
- GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned);
- try
- {
- _current = adler32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count);
- }
- finally
- {
- hData.Free();
- }
- }
-
- }
- #endregion
-
-} \ No newline at end of file
diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs b/source4/lib/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs
deleted file mode 100644
index 16997e906b..0000000000
--- a/source4/lib/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-//
-// © Copyright Henrik Ravn 2004
-//
-// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-using System;
-using System.Diagnostics;
-
-namespace DotZLib
-{
-
- /// <summary>
- /// This class implements a circular buffer
- /// </summary>
- internal class CircularBuffer
- {
- #region Private data
- private int _capacity;
- private int _head;
- private int _tail;
- private int _size;
- private byte[] _buffer;
- #endregion
-
- public CircularBuffer(int capacity)
- {
- Debug.Assert( capacity > 0 );
- _buffer = new byte[capacity];
- _capacity = capacity;
- _head = 0;
- _tail = 0;
- _size = 0;
- }
-
- public int Size { get { return _size; } }
-
- public int Put(byte[] source, int offset, int count)
- {
- Debug.Assert( count > 0 );
- int trueCount = Math.Min(count, _capacity - Size);
- for (int i = 0; i < trueCount; ++i)
- _buffer[(_tail+i) % _capacity] = source[offset+i];
- _tail += trueCount;
- _tail %= _capacity;
- _size += trueCount;
- return trueCount;
- }
-
- public bool Put(byte b)
- {
- if (Size == _capacity) // no room
- return false;
- _buffer[_tail++] = b;
- _tail %= _capacity;
- ++_size;
- return true;
- }
-
- public int Get(byte[] destination, int offset, int count)
- {
- int trueCount = Math.Min(count,Size);
- for (int i = 0; i < trueCount; ++i)
- destination[offset + i] = _buffer[(_head+i) % _capacity];
- _head += trueCount;
- _head %= _capacity;
- _size -= trueCount;
- return trueCount;
- }
-
- public int Get()
- {
- if (Size == 0)
- return -1;
-
- int result = (int)_buffer[_head++ % _capacity];
- --_size;
- return result;
- }
-
- }
-}
diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/CodecBase.cs b/source4/lib/zlib/contrib/dotzlib/DotZLib/CodecBase.cs
deleted file mode 100644
index 954db7db05..0000000000
--- a/source4/lib/zlib/contrib/dotzlib/DotZLib/CodecBase.cs
+++ /dev/null
@@ -1,198 +0,0 @@
-//
-// © Copyright Henrik Ravn 2004
-//
-// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace DotZLib
-{
- /// <summary>
- /// Implements the common functionality needed for all <see cref="Codec"/>s
- /// </summary>
- public abstract class CodecBase : Codec, IDisposable
- {
-
- #region Data members
-
- /// <summary>
- /// Instance of the internal zlib buffer structure that is
- /// passed to all functions in the zlib dll
- /// </summary>
- internal ZStream _ztream = new ZStream();
-
- /// <summary>
- /// True if the object instance has been disposed, false otherwise
- /// </summary>
- protected bool _isDisposed = false;
-
- /// <summary>
- /// The size of the internal buffers
- /// </summary>
- protected const int kBufferSize = 16384;
-
- private byte[] _outBuffer = new byte[kBufferSize];
- private byte[] _inBuffer = new byte[kBufferSize];
-
- private GCHandle _hInput;
- private GCHandle _hOutput;
-
- private uint _checksum = 0;
-
- #endregion
-
- /// <summary>
- /// Initializes a new instance of the <c>CodeBase</c> class.
- /// </summary>
- public CodecBase()
- {
- try
- {
- _hInput = GCHandle.Alloc(_inBuffer, GCHandleType.Pinned);
- _hOutput = GCHandle.Alloc(_outBuffer, GCHandleType.Pinned);
- }
- catch (Exception)
- {
- CleanUp(false);
- throw;
- }
- }
-
-
- #region Codec Members
-
- /// <summary>
- /// Occurs when more processed data are available.
- /// </summary>
- public event DataAvailableHandler DataAvailable;
-
- /// <summary>
- /// Fires the <see cref="DataAvailable"/> event
- /// </summary>
- protected void OnDataAvailable()
- {
- if (_ztream.total_out > 0)
- {
- if (DataAvailable != null)
- DataAvailable( _outBuffer, 0, (int)_ztream.total_out);
- resetOutput();
- }
- }
-
- /// <summary>
- /// Adds more data to the codec to be processed.
- /// </summary>
- /// <param name="data">Byte array containing the data to be added to the codec</param>
- /// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
- public void Add(byte[] data)
- {
- Add(data,0,data.Length);
- }
-
- /// <summary>
- /// Adds more data to the codec to be processed.
- /// </summary>
- /// <param name="data">Byte array containing the data to be added to the codec</param>
- /// <param name="offset">The index of the first byte to add from <c>data</c></param>
- /// <param name="count">The number of bytes to add</param>
- /// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
- /// <remarks>This must be implemented by a derived class</remarks>
- public abstract void Add(byte[] data, int offset, int count);
-
- /// <summary>
- /// Finishes up any pending data that needs to be processed and handled.
- /// </summary>
- /// <remarks>This must be implemented by a derived class</remarks>
- public abstract void Finish();
-
- /// <summary>
- /// Gets the checksum of the data that has been added so far
- /// </summary>
- public uint Checksum { get { return _checksum; } }
-
- #endregion
-
- #region Destructor & IDisposable stuff
-
- /// <summary>
- /// Destroys this instance
- /// </summary>
- ~CodecBase()
- {
- CleanUp(false);
- }
-
- /// <summary>
- /// Releases any unmanaged resources and calls the <see cref="CleanUp()"/> method of the derived class
- /// </summary>
- public void Dispose()
- {
- CleanUp(true);
- }
-
- /// <summary>
- /// Performs any codec specific cleanup
- /// </summary>
- /// <remarks>This must be implemented by a derived class</remarks>
- protected abstract void CleanUp();
-
- // performs the release of the handles and calls the dereived CleanUp()
- private void CleanUp(bool isDisposing)
- {
- if (!_isDisposed)
- {
- CleanUp();
- if (_hInput.IsAllocated)
- _hInput.Free();
- if (_hOutput.IsAllocated)
- _hOutput.Free();
-
- _isDisposed = true;
- }
- }
-
-
- #endregion
-
- #region Helper methods
-
- /// <summary>
- /// Copies a number of bytes to the internal codec buffer - ready for proccesing
- /// </summary>
- /// <param name="data">The byte array that contains the data to copy</param>
- /// <param name="startIndex">The index of the first byte to copy</param>
- /// <param name="count">The number of bytes to copy from <c>data</c></param>
- protected void copyInput(byte[] data, int startIndex, int count)
- {
- Array.Copy(data, startIndex, _inBuffer,0, count);
- _ztream.next_in = _hInput.AddrOfPinnedObject();
- _ztream.total_in = 0;
- _ztream.avail_in = (uint)count;
-
- }
-
- /// <summary>
- /// Resets the internal output buffers to a known state - ready for processing
- /// </summary>
- protected void resetOutput()
- {
- _ztream.total_out = 0;
- _ztream.avail_out = kBufferSize;
- _ztream.next_out = _hOutput.AddrOfPinnedObject();
- }
-
- /// <summary>
- /// Updates the running checksum property
- /// </summary>
- /// <param name="newSum">The new checksum value</param>
- protected void setChecksum(uint newSum)
- {
- _checksum = newSum;
- }
- #endregion
-
- }
-}
diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/Deflater.cs b/source4/lib/zlib/contrib/dotzlib/DotZLib/Deflater.cs
deleted file mode 100644
index d7b8dcccac..0000000000
--- a/source4/lib/zlib/contrib/dotzlib/DotZLib/Deflater.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-//
-// © Copyright Henrik Ravn 2004
-//
-// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-using System;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-
-namespace DotZLib
-{
-
- /// <summary>
- /// Implements a data compressor, using the deflate algorithm in the ZLib dll
- /// </summary>
- public sealed class Deflater : CodecBase
- {
- #region Dll imports
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)]
- private static extern int deflateInit_(ref ZStream sz, int level, string vs, int size);
-
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
- private static extern int deflate(ref ZStream sz, int flush);
-
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
- private static extern int deflateReset(ref ZStream sz);
-
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
- private static extern int deflateEnd(ref ZStream sz);
- #endregion
-
- /// <summary>
- /// Constructs an new instance of the <c>Deflater</c>
- /// </summary>
- /// <param name="level">The compression level to use for this <c>Deflater</c></param>
- public Deflater(CompressLevel level) : base()
- {
- int retval = deflateInit_(ref _ztream, (int)level, Info.Version, Marshal.SizeOf(_ztream));
- if (retval != 0)
- throw new ZLibException(retval, "Could not initialize deflater");
-
- resetOutput();
- }
-
- /// <summary>
- /// Adds more data to the codec to be processed.
- /// </summary>
- /// <param name="data">Byte array containing the data to be added to the codec</param>
- /// <param name="offset">The index of the first byte to add from <c>data</c></param>
- /// <param name="count">The number of bytes to add</param>
- /// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
- public override void Add(byte[] data, int offset, int count)
- {
- if (data == null) throw new ArgumentNullException();
- if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
- if ((offset+count) > data.Length) throw new ArgumentException();
-
- int total = count;
- int inputIndex = offset;
- int err = 0;
-
- while (err >= 0 && inputIndex < total)
- {
- copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize));
- while (err >= 0 && _ztream.avail_in > 0)
- {
- err = deflate(ref _ztream, (int)FlushTypes.None);
- if (err == 0)
- while (_ztream.avail_out == 0)
- {
- OnDataAvailable();
- err = deflate(ref _ztream, (int)FlushTypes.None);
- }
- inputIndex += (int)_ztream.total_in;
- }
- }
- setChecksum( _ztream.adler );
- }
-
-
- /// <summary>
- /// Finishes up any pending data that needs to be processed and handled.
- /// </summary>
- public override void Finish()
- {
- int err;
- do
- {
- err = deflate(ref _ztream, (int)FlushTypes.Finish);
- OnDataAvailable();
- }
- while (err == 0);
- setChecksum( _ztream.adler );
- deflateReset(ref _ztream);
- resetOutput();
- }
-
- /// <summary>
- /// Closes the internal zlib deflate stream
- /// </summary>
- protected override void CleanUp() { deflateEnd(ref _ztream); }
-
- }
-}
diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/DotZLib.cs b/source4/lib/zlib/contrib/dotzlib/DotZLib/DotZLib.cs
deleted file mode 100644
index 410deb0885..0000000000
--- a/source4/lib/zlib/contrib/dotzlib/DotZLib/DotZLib.cs
+++ /dev/null
@@ -1,288 +0,0 @@
-//
-// © Copyright Henrik Ravn 2004
-//
-// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-using System;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Text;
-
-
-namespace DotZLib
-{
-
- #region Internal types
-
- /// <summary>
- /// Defines constants for the various flush types used with zlib
- /// </summary>
- internal enum FlushTypes
- {
- None, Partial, Sync, Full, Finish, Block
- }
-
- #region ZStream structure
- // internal mapping of the zlib zstream structure for marshalling
- [StructLayoutAttribute(LayoutKind.Sequential, Pack=4, Size=0, CharSet=CharSet.Ansi)]
- internal struct ZStream
- {
- public IntPtr next_in;
- public uint avail_in;
- public uint total_in;
-
- public IntPtr next_out;
- public uint avail_out;
- public uint total_out;
-
- [MarshalAs(UnmanagedType.LPStr)]
- string msg;
- uint state;
-
- uint zalloc;
- uint zfree;
- uint opaque;
-
- int data_type;
- public uint adler;
- uint reserved;
- }
-
- #endregion
-
- #endregion
-
- #region Public enums
- /// <summary>
- /// Defines constants for the available compression levels in zlib
- /// </summary>
- public enum CompressLevel : int
- {
- /// <summary>
- /// The default compression level with a reasonable compromise between compression and speed
- /// </summary>
- Default = -1,
- /// <summary>
- /// No compression at all. The data are passed straight through.
- /// </summary>
- None = 0,
- /// <summary>
- /// The maximum compression rate available.
- /// </summary>
- Best = 9,
- /// <summary>
- /// The fastest available compression level.
- /// </summary>
- Fastest = 1
- }
- #endregion
-
- #region Exception classes
- /// <summary>
- /// The exception that is thrown when an error occurs on the zlib dll
- /// </summary>
- public class ZLibException : ApplicationException
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="ZLibException"/> class with a specified
- /// error message and error code
- /// </summary>
- /// <param name="errorCode">The zlib error code that caused the exception</param>
- /// <param name="msg">A message that (hopefully) describes the error</param>
- public ZLibException(int errorCode, string msg) : base(String.Format("ZLib error {0} {1}", errorCode, msg))
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ZLibException"/> class with a specified
- /// error code
- /// </summary>
- /// <param name="errorCode">The zlib error code that caused the exception</param>
- public ZLibException(int errorCode) : base(String.Format("ZLib error {0}", errorCode))
- {
- }
- }
- #endregion
-
- #region Interfaces
-
- /// <summary>
- /// Declares methods and properties that enables a running checksum to be calculated
- /// </summary>
- public interface ChecksumGenerator
- {
- /// <summary>
- /// Gets the current value of the checksum
- /// </summary>
- uint Value { get; }
-
- /// <summary>
- /// Clears the current checksum to 0
- /// </summary>
- void Reset();
-
- /// <summary>
- /// Updates the current checksum with an array of bytes
- /// </summary>
- /// <param name="data">The data to update the checksum with</param>
- void Update(byte[] data);
-
- /// <summary>
- /// Updates the current checksum with part of an array of bytes
- /// </summary>
- /// <param name="data">The data to update the checksum with</param>
- /// <param name="offset">Where in <c>data</c> to start updating</param>
- /// <param name="count">The number of bytes from <c>data</c> to use</param>
- /// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
- /// <exception cref="ArgumentNullException"><c>data</c> is a null reference</exception>
- /// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
- void Update(byte[] data, int offset, int count);
-
- /// <summary>
- /// Updates the current checksum with the data from a string
- /// </summary>
- /// <param name="data">The string to update the checksum with</param>
- /// <remarks>The characters in the string are converted by the UTF-8 encoding</remarks>
- void Update(string data);
-
- /// <summary>
- /// Updates the current checksum with the data from a string, using a specific encoding
- /// </summary>
- /// <param name="data">The string to update the checksum with</param>
- /// <param name="encoding">The encoding to use</param>
- void Update(string data, Encoding encoding);
- }
-
-
- /// <summary>
- /// Represents the method that will be called from a codec when new data
- /// are available.
- /// </summary>
- /// <paramref name="data">The byte array containing the processed data</paramref>
- /// <paramref name="startIndex">The index of the first processed byte in <c>data</c></paramref>
- /// <paramref name="count">The number of processed bytes available</paramref>
- /// <remarks>On return from this method, the data may be overwritten, so grab it while you can.
- /// You cannot assume that startIndex will be zero.
- /// </remarks>
- public delegate void DataAvailableHandler(byte[] data, int startIndex, int count);
-
- /// <summary>
- /// Declares methods and events for implementing compressors/decompressors
- /// </summary>
- public interface Codec
- {
- /// <summary>
- /// Occurs when more processed data are available.
- /// </summary>
- event DataAvailableHandler DataAvailable;
-
- /// <summary>
- /// Adds more data to the codec to be processed.
- /// </summary>
- /// <param name="data">Byte array containing the data to be added to the codec</param>
- /// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
- void Add(byte[] data);
-
- /// <summary>
- /// Adds more data to the codec to be processed.
- /// </summary>
- /// <param name="data">Byte array containing the data to be added to the codec</param>
- /// <param name="offset">The index of the first byte to add from <c>data</c></param>
- /// <param name="count">The number of bytes to add</param>
- /// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
- void Add(byte[] data, int offset, int count);
-
- /// <summary>
- /// Finishes up any pending data that needs to be processed and handled.
- /// </summary>
- void Finish();
-
- /// <summary>
- /// Gets the checksum of the data that has been added so far
- /// </summary>
- uint Checksum { get; }
-
-
- }
-
- #endregion
-
- #region Classes
- /// <summary>
- /// Encapsulates general information about the ZLib library
- /// </summary>
- public class Info
- {
- #region DLL imports
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
- private static extern uint zlibCompileFlags();
-
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
- private static extern string zlibVersion();
- #endregion
-
- #region Private stuff
- private uint _flags;
-
- // helper function that unpacks a bitsize mask
- private static int bitSize(uint bits)
- {
- switch (bits)
- {
- case 0: return 16;
- case 1: return 32;
- case 2: return 64;
- }
- return -1;
- }
- #endregion
-
- /// <summary>
- /// Constructs an instance of the <c>Info</c> class.
- /// </summary>
- public Info()
- {
- _flags = zlibCompileFlags();
- }
-
- /// <summary>
- /// True if the library is compiled with debug info
- /// </summary>
- public bool HasDebugInfo { get { return 0 != (_flags & 0x100); } }
-
- /// <summary>
- /// True if the library is compiled with assembly optimizations
- /// </summary>
- public bool UsesAssemblyCode { get { return 0 != (_flags & 0x200); } }
-
- /// <summary>
- /// Gets the size of the unsigned int that was compiled into Zlib
- /// </summary>
- public int SizeOfUInt { get { return bitSize(_flags & 3); } }
-
- /// <summary>
- /// Gets the size of the unsigned long that was compiled into Zlib
- /// </summary>
- public int SizeOfULong { get { return bitSize((_flags >> 2) & 3); } }
-
- /// <summary>
- /// Gets the size of the pointers that were compiled into Zlib
- /// </summary>
- public int SizeOfPointer { get { return bitSize((_flags >> 4) & 3); } }
-
- /// <summary>
- /// Gets the size of the z_off_t type that was compiled into Zlib
- /// </summary>
- public int SizeOfOffset { get { return bitSize((_flags >> 6) & 3); } }
-
- /// <summary>
- /// Gets the version of ZLib as a string, e.g. "1.2.1"
- /// </summary>
- public static string Version { get { return zlibVersion(); } }
- }
-
- #endregion
-
-}
diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj b/source4/lib/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj
deleted file mode 100644
index 71eeb8590a..0000000000
--- a/source4/lib/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj
+++ /dev/null
@@ -1,141 +0,0 @@
-<VisualStudioProject>
- <CSHARP
- ProjectType = "Local"
- ProductVersion = "7.10.3077"
- SchemaVersion = "2.0"
- ProjectGuid = "{BB1EE0B1-1808-46CB-B786-949D91117FC5}"
- >
- <Build>
- <Settings
- ApplicationIcon = ""
- AssemblyKeyContainerName = ""
- AssemblyName = "DotZLib"
- AssemblyOriginatorKeyFile = ""
- DefaultClientScript = "JScript"
- DefaultHTMLPageLayout = "Grid"
- DefaultTargetSchema = "IE50"
- DelaySign = "false"
- OutputType = "Library"
- PreBuildEvent = ""
- PostBuildEvent = ""
- RootNamespace = "DotZLib"
- RunPostBuildEvent = "OnBuildSuccess"
- StartupObject = ""
- >
- <Config
- Name = "Debug"
- AllowUnsafeBlocks = "false"
- BaseAddress = "285212672"
- CheckForOverflowUnderflow = "false"
- ConfigurationOverrideFile = ""
- DefineConstants = "DEBUG;TRACE"
- DocumentationFile = "docs\DotZLib.xml"
- DebugSymbols = "true"
- FileAlignment = "4096"
- IncrementalBuild = "false"
- NoStdLib = "false"
- NoWarn = "1591"
- Optimize = "false"
- OutputPath = "bin\Debug\"
- RegisterForComInterop = "false"
- RemoveIntegerChecks = "false"
- TreatWarningsAsErrors = "false"
- WarningLevel = "4"
- />
- <Config
- Name = "Release"
- AllowUnsafeBlocks = "false"
- BaseAddress = "285212672"
- CheckForOverflowUnderflow = "false"
- ConfigurationOverrideFile = ""
- DefineConstants = "TRACE"
- DocumentationFile = "docs\DotZLib.xml"
- DebugSymbols = "false"
- FileAlignment = "4096"
- IncrementalBuild = "false"
- NoStdLib = "false"
- NoWarn = ""
- Optimize = "true"
- OutputPath = "bin\Release\"
- RegisterForComInterop = "false"
- RemoveIntegerChecks = "false"
- TreatWarningsAsErrors = "false"
- WarningLevel = "4"
- />
- </Settings>
- <References>
- <Reference
- Name = "System"
- AssemblyName = "System"
- HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.dll"
- />
- <Reference
- Name = "System.Data"
- AssemblyName = "System.Data"
- HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
- />
- <Reference
- Name = "System.XML"
- AssemblyName = "System.Xml"
- HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
- />
- <Reference
- Name = "nunit.framework"
- AssemblyName = "nunit.framework"
- HintPath = "E:\apps\NUnit V2.1\\bin\nunit.framework.dll"
- AssemblyFolderKey = "hklm\dn\nunit.framework"
- />
- </References>
- </Build>
- <Files>
- <Include>
- <File
- RelPath = "AssemblyInfo.cs"
- SubType = "Code"
- BuildAction = "Compile"
- />
- <File
- RelPath = "ChecksumImpl.cs"
- SubType = "Code"
- BuildAction = "Compile"
- />
- <File
- RelPath = "CircularBuffer.cs"
- SubType = "Code"
- BuildAction = "Compile"
- />
- <File
- RelPath = "CodecBase.cs"
- SubType = "Code"
- BuildAction = "Compile"
- />
- <File
- RelPath = "Deflater.cs"
- SubType = "Code"
- BuildAction = "Compile"
- />
- <File
- RelPath = "DotZLib.cs"
- SubType = "Code"
- BuildAction = "Compile"
- />
- <File
- RelPath = "GZipStream.cs"
- SubType = "Code"
- BuildAction = "Compile"
- />
- <File
- RelPath = "Inflater.cs"
- SubType = "Code"
- BuildAction = "Compile"
- />
- <File
- RelPath = "UnitTests.cs"
- SubType = "Code"
- BuildAction = "Compile"
- />
- </Include>
- </Files>
- </CSHARP>
-</VisualStudioProject>
-
diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/GZipStream.cs b/source4/lib/zlib/contrib/dotzlib/DotZLib/GZipStream.cs
deleted file mode 100644
index f861675b51..0000000000
--- a/source4/lib/zlib/contrib/dotzlib/DotZLib/GZipStream.cs
+++ /dev/null
@@ -1,301 +0,0 @@
-//
-// © Copyright Henrik Ravn 2004
-//
-// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-using System;
-using System.IO;
-using System.Runtime.InteropServices;
-
-namespace DotZLib
-{
- /// <summary>
- /// Implements a compressed <see cref="Stream"/>, in GZip (.gz) format.
- /// </summary>
- public class GZipStream : Stream, IDisposable
- {
- #region Dll Imports
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)]
- private static extern IntPtr gzopen(string name, string mode);
-
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
- private static extern int gzclose(IntPtr gzFile);
-
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
- private static extern int gzwrite(IntPtr gzFile, int data, int length);
-
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
- private static extern int gzread(IntPtr gzFile, int data, int length);
-
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
- private static extern int gzgetc(IntPtr gzFile);
-
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
- private static extern int gzputc(IntPtr gzFile, int c);
-
- #endregion
-
- #region Private data
- private IntPtr _gzFile;
- private bool _isDisposed = false;
- private bool _isWriting;
- #endregion
-
- #region Constructors
- /// <summary>
- /// Creates a new file as a writeable GZipStream
- /// </summary>
- /// <param name="fileName">The name of the compressed file to create</param>
- /// <param name="level">The compression level to use when adding data</param>
- /// <exception cref="ZLibException">If an error occurred in the internal zlib function</exception>
- public GZipStream(string fileName, CompressLevel level)
- {
- _isWriting = true;
- _gzFile = gzopen(fileName, String.Format("wb{0}", (int)level));
- if (_gzFile == IntPtr.Zero)
- throw new ZLibException(-1, "Could not open " + fileName);
- }
-
- /// <summary>
- /// Opens an existing file as a readable GZipStream
- /// </summary>
- /// <param name="fileName">The name of the file to open</param>
- /// <exception cref="ZLibException">If an error occurred in the internal zlib function</exception>
- public GZipStream(string fileName)
- {
- _isWriting = false;
- _gzFile = gzopen(fileName, "rb");
- if (_gzFile == IntPtr.Zero)
- throw new ZLibException(-1, "Could not open " + fileName);
-
- }
- #endregion
-
- #region Access properties
- /// <summary>
- /// Returns true of this stream can be read from, false otherwise
- /// </summary>
- public override bool CanRead
- {
- get
- {
- return !_isWriting;
- }
- }
-
-
- /// <summary>
- /// Returns false.
- /// </summary>
- public override bool CanSeek
- {
- get
- {
- return false;
- }
- }
-
- /// <summary>
- /// Returns true if this tsream is writeable, false otherwise
- /// </summary>
- public override bool CanWrite
- {
- get
- {
- return _isWriting;
- }
- }
- #endregion
-
- #region Destructor & IDispose stuff
-
- /// <summary>
- /// Destroys this instance
- /// </summary>
- ~GZipStream()
- {
- cleanUp(false);
- }
-
- /// <summary>
- /// Closes the external file handle
- /// </summary>
- public void Dispose()
- {
- cleanUp(true);
- }
-
- // Does the actual closing of the file handle.
- private void cleanUp(bool isDisposing)
- {
- if (!_isDisposed)
- {
- gzclose(_gzFile);
- _isDisposed = true;
- }
- }
- #endregion
-
- #region Basic reading and writing
- /// <summary>
- /// Attempts to read a number of bytes from the stream.
- /// </summary>
- /// <param name="buffer">The destination data buffer</param>
- /// <param name="offset">The index of the first destination byte in <c>buffer</c></param>
- /// <param name="count">The number of bytes requested</param>
- /// <returns>The number of bytes read</returns>
- /// <exception cref="ArgumentNullException">If <c>buffer</c> is null</exception>
- /// <exception cref="ArgumentOutOfRangeException">If <c>count</c> or <c>offset</c> are negative</exception>
- /// <exception cref="ArgumentException">If <c>offset</c> + <c>count</c> is &gt; buffer.Length</exception>
- /// <exception cref="NotSupportedException">If this stream is not readable.</exception>
- /// <exception cref="ObjectDisposedException">If this stream has been disposed.</exception>
- public override int Read(byte[] buffer, int offset, int count)
- {
- if (!CanRead) throw new NotSupportedException();
- if (buffer == null) throw new ArgumentNullException();
- if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
- if ((offset+count) > buffer.Length) throw new ArgumentException();
- if (_isDisposed) throw new ObjectDisposedException("GZipStream");
-
- GCHandle h = GCHandle.Alloc(buffer, GCHandleType.Pinned);
- int result;
- try
- {
- result = gzread(_gzFile, h.AddrOfPinnedObject().ToInt32() + offset, count);
- if (result < 0)
- throw new IOException();
- }
- finally
- {
- h.Free();
- }
- return result;
- }
-
- /// <summary>
- /// Attempts to read a single byte from the stream.
- /// </summary>
- /// <returns>The byte that was read, or -1 in case of error or End-Of-File</returns>
- public override int ReadByte()
- {
- if (!CanRead) throw new NotSupportedException();
- if (_isDisposed) throw new ObjectDisposedException("GZipStream");
- return gzgetc(_gzFile);
- }
-
- /// <summary>
- /// Writes a number of bytes to the stream
- /// </summary>
- /// <param name="buffer"></param>
- /// <param name="offset"></param>
- /// <param name="count"></param>
- /// <exception cref="ArgumentNullException">If <c>buffer</c> is null</exception>
- /// <exception cref="ArgumentOutOfRangeException">If <c>count</c> or <c>offset</c> are negative</exception>
- /// <exception cref="ArgumentException">If <c>offset</c> + <c>count</c> is &gt; buffer.Length</exception>
- /// <exception cref="NotSupportedException">If this stream is not writeable.</exception>
- /// <exception cref="ObjectDisposedException">If this stream has been disposed.</exception>
- public override void Write(byte[] buffer, int offset, int count)
- {
- if (!CanWrite) throw new NotSupportedException();
- if (buffer == null) throw new ArgumentNullException();
- if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
- if ((offset+count) > buffer.Length) throw new ArgumentException();
- if (_isDisposed) throw new ObjectDisposedException("GZipStream");
-
- GCHandle h = GCHandle.Alloc(buffer, GCHandleType.Pinned);
- try
- {
- int result = gzwrite(_gzFile, h.AddrOfPinnedObject().ToInt32() + offset, count);
- if (result < 0)
- throw new IOException();
- }
- finally
- {
- h.Free();
- }
- }
-
- /// <summary>
- /// Writes a single byte to the stream
- /// </summary>
- /// <param name="value">The byte to add to the stream.</param>
- /// <exception cref="NotSupportedException">If this stream is not writeable.</exception>
- /// <exception cref="ObjectDisposedException">If this stream has been disposed.</exception>
- public override void WriteByte(byte value)
- {
- if (!CanWrite) throw new NotSupportedException();
- if (_isDisposed) throw new ObjectDisposedException("GZipStream");
-
- int result = gzputc(_gzFile, (int)value);
- if (result < 0)
- throw new IOException();
- }
- #endregion
-
- #region Position & length stuff
- /// <summary>
- /// Not supported.
- /// </summary>
- /// <param name="value"></param>
- /// <exception cref="NotSupportedException">Always thrown</exception>
- public override void SetLength(long value)
- {
- throw new NotSupportedException();
- }
-
- /// <summary>
- /// Not suppported.
- /// </summary>
- /// <param name="offset"></param>
- /// <param name="origin"></param>
- /// <returns></returns>
- /// <exception cref="NotSupportedException">Always thrown</exception>
- public override long Seek(long offset, SeekOrigin origin)
- {
- throw new NotSupportedException();
- }
-
- /// <summary>
- /// Flushes the <c>GZipStream</c>.
- /// </summary>
- /// <remarks>In this implementation, this method does nothing. This is because excessive
- /// flushing may degrade the achievable compression rates.</remarks>
- public override void Flush()
- {
- // left empty on purpose
- }
-
- /// <summary>
- /// Gets/sets the current position in the <c>GZipStream</c>. Not suppported.
- /// </summary>
- /// <remarks>In this implementation this property is not supported</remarks>
- /// <exception cref="NotSupportedException">Always thrown</exception>
- public override long Position
- {
- get
- {
- throw new NotSupportedException();
- }
- set
- {
- throw new NotSupportedException();
- }
- }
-
- /// <summary>
- /// Gets the size of the stream. Not suppported.
- /// </summary>
- /// <remarks>In this implementation this property is not supported</remarks>
- /// <exception cref="NotSupportedException">Always thrown</exception>
- public override long Length
- {
- get
- {
- throw new NotSupportedException();
- }
- }
- #endregion
- }
-}
diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/Inflater.cs b/source4/lib/zlib/contrib/dotzlib/DotZLib/Inflater.cs
deleted file mode 100644
index 4e60cda078..0000000000
--- a/source4/lib/zlib/contrib/dotzlib/DotZLib/Inflater.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-//
-// © Copyright Henrik Ravn 2004
-//
-// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-using System;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-
-namespace DotZLib
-{
-
- /// <summary>
- /// Implements a data decompressor, using the inflate algorithm in the ZLib dll
- /// </summary>
- public class Inflater : CodecBase
- {
- #region Dll imports
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)]
- private static extern int inflateInit_(ref ZStream sz, string vs, int size);
-
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
- private static extern int inflate(ref ZStream sz, int flush);
-
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
- private static extern int inflateReset(ref ZStream sz);
-
- [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
- private static extern int inflateEnd(ref ZStream sz);
- #endregion
-
- /// <summary>
- /// Constructs an new instance of the <c>Inflater</c>
- /// </summary>
- public Inflater() : base()
- {
- int retval = inflateInit_(ref _ztream, Info.Version, Marshal.SizeOf(_ztream));
- if (retval != 0)
- throw new ZLibException(retval, "Could not initialize inflater");
-
- resetOutput();
- }
-
-
- /// <summary>
- /// Adds more data to the codec to be processed.
- /// </summary>
- /// <param name="data">Byte array containing the data to be added to the codec</param>
- /// <param name="offset">The index of the first byte to add from <c>data</c></param>
- /// <param name="count">The number of bytes to add</param>
- /// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
- public override void Add(byte[] data, int offset, int count)
- {
- if (data == null) throw new ArgumentNullException();
- if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
- if ((offset+count) > data.Length) throw new ArgumentException();
-
- int total = count;
- int inputIndex = offset;
- int err = 0;
-
- while (err >= 0 && inputIndex < total)
- {
- copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize));
- err = inflate(ref _ztream, (int)FlushTypes.None);
- if (err == 0)
- while (_ztream.avail_out == 0)
- {
- OnDataAvailable();
- err = inflate(ref _ztream, (int)FlushTypes.None);
- }
-
- inputIndex += (int)_ztream.total_in;
- }
- setChecksum( _ztream.adler );
- }
-
-
- /// <summary>
- /// Finishes up any pending data that needs to be processed and handled.
- /// </summary>
- public override void Finish()
- {
- int err;
- do
- {
- err = inflate(ref _ztream, (int)FlushTypes.Finish);
- OnDataAvailable();
- }
- while (err == 0);
- setChecksum( _ztream.adler );
- inflateReset(ref _ztream);
- resetOutput();
- }
-
- /// <summary>
- /// Closes the internal zlib inflate stream
- /// </summary>
- protected override void CleanUp() { inflateEnd(ref _ztream); }
-
-
- }
-}
diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/UnitTests.cs b/source4/lib/zlib/contrib/dotzlib/DotZLib/UnitTests.cs
deleted file mode 100644
index 8dc00db92d..0000000000
--- a/source4/lib/zlib/contrib/dotzlib/DotZLib/UnitTests.cs
+++ /dev/null
@@ -1,274 +0,0 @@
-//
-// © Copyright Henrik Ravn 2004
-//
-// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-using System;
-using System.Collections;
-using System.IO;
-
-// uncomment the define below to include unit tests
-//#define nunit
-#if nunit
-using NUnit.Framework;
-
-// Unit tests for the DotZLib class library
-// ----------------------------------------
-//
-// Use this with NUnit 2 from http://www.nunit.org
-//
-
-namespace DotZLibTests
-{
- using DotZLib;
-
- // helper methods
- internal class Utils
- {
- public static bool byteArrEqual( byte[] lhs, byte[] rhs )
- {
- if (lhs.Length != rhs.Length)
- return false;
- for (int i = lhs.Length-1; i >= 0; --i)
- if (lhs[i] != rhs[i])
- return false;
- return true;
- }
-
- }
-
-
- [TestFixture]
- public class CircBufferTests
- {
- #region Circular buffer tests
- [Test]
- public void SinglePutGet()
- {
- CircularBuffer buf = new CircularBuffer(10);
- Assert.AreEqual( 0, buf.Size );
- Assert.AreEqual( -1, buf.Get() );
-
- Assert.IsTrue(buf.Put( 1 ));
- Assert.AreEqual( 1, buf.Size );
- Assert.AreEqual( 1, buf.Get() );
- Assert.AreEqual( 0, buf.Size );
- Assert.AreEqual( -1, buf.Get() );
- }
-
- [Test]
- public void BlockPutGet()
- {
- CircularBuffer buf = new CircularBuffer(10);
- byte[] arr = {1,2,3,4,5,6,7,8,9,10};
- Assert.AreEqual( 10, buf.Put(arr,0,10) );
- Assert.AreEqual( 10, buf.Size );
- Assert.IsFalse( buf.Put(11) );
- Assert.AreEqual( 1, buf.Get() );
- Assert.IsTrue( buf.Put(11) );
-
- byte[] arr2 = (byte[])arr.Clone();
- Assert.AreEqual( 9, buf.Get(arr2,1,9) );
- Assert.IsTrue( Utils.byteArrEqual(arr,arr2) );
- }
-
- #endregion
- }
-
- [TestFixture]
- public class ChecksumTests
- {
- #region CRC32 Tests
- [Test]
- public void CRC32_Null()
- {
- CRC32Checksum crc32 = new CRC32Checksum();
- Assert.AreEqual( 0, crc32.Value );
-
- crc32 = new CRC32Checksum(1);
- Assert.AreEqual( 1, crc32.Value );
-
- crc32 = new CRC32Checksum(556);
- Assert.AreEqual( 556, crc32.Value );
- }
-
- [Test]
- public void CRC32_Data()
- {
- CRC32Checksum crc32 = new CRC32Checksum();
- byte[] data = { 1,2,3,4,5,6,7 };
- crc32.Update(data);
- Assert.AreEqual( 0x70e46888, crc32.Value );
-
- crc32 = new CRC32Checksum();
- crc32.Update("penguin");
- Assert.AreEqual( 0x0e5c1a120, crc32.Value );
-
- crc32 = new CRC32Checksum(1);
- crc32.Update("penguin");
- Assert.AreEqual(0x43b6aa94, crc32.Value);
-
- }
- #endregion
-
- #region Adler tests
-
- [Test]
- public void Adler_Null()
- {
- AdlerChecksum adler = new AdlerChecksum();
- Assert.AreEqual(0, adler.Value);
-
- adler = new AdlerChecksum(1);
- Assert.AreEqual( 1, adler.Value );
-
- adler = new AdlerChecksum(556);
- Assert.AreEqual( 556, adler.Value );
- }
-
- [Test]
- public void Adler_Data()
- {
- AdlerChecksum adler = new AdlerChecksum(1);
- byte[] data = { 1,2,3,4,5,6,7 };
- adler.Update(data);
- Assert.AreEqual( 0x5b001d, adler.Value );
-
- adler = new AdlerChecksum();
- adler.Update("penguin");
- Assert.AreEqual(0x0bcf02f6, adler.Value );
-
- adler = new AdlerChecksum(1);
- adler.Update("penguin");
- Assert.AreEqual(0x0bd602f7, adler.Value);
-
- }
- #endregion
- }
-
- [TestFixture]
- public class InfoTests
- {
- #region Info tests
- [Test]
- public void Info_Version()
- {
- Info info = new Info();
- Assert.AreEqual("1.2.3", Info.Version);
- Assert.AreEqual(32, info.SizeOfUInt);
- Assert.AreEqual(32, info.SizeOfULong);
- Assert.AreEqual(32, info.SizeOfPointer);
- Assert.AreEqual(32, info.SizeOfOffset);
- }
- #endregion
- }
-
- [TestFixture]
- public class DeflateInflateTests
- {
- #region Deflate tests
- [Test]
- public void Deflate_Init()
- {
- using (Deflater def = new Deflater(CompressLevel.Default))
- {
- }
- }
-
- private ArrayList compressedData = new ArrayList();
- private uint adler1;
-
- private ArrayList uncompressedData = new ArrayList();
- private uint adler2;
-
- public void CDataAvail(byte[] data, int startIndex, int count)
- {
- for (int i = 0; i < count; ++i)
- compressedData.Add(data[i+startIndex]);
- }
-
- [Test]
- public void Deflate_Compress()
- {
- compressedData.Clear();
-
- byte[] testData = new byte[35000];
- for (int i = 0; i < testData.Length; ++i)
- testData[i] = 5;
-
- using (Deflater def = new Deflater((CompressLevel)5))
- {
- def.DataAvailable += new DataAvailableHandler(CDataAvail);
- def.Add(testData);
- def.Finish();
- adler1 = def.Checksum;
- }
- }
- #endregion
-
- #region Inflate tests
- [Test]
- public void Inflate_Init()
- {
- using (Inflater inf = new Inflater())
- {
- }
- }
-
- private void DDataAvail(byte[] data, int startIndex, int count)
- {
- for (int i = 0; i < count; ++i)
- uncompressedData.Add(data[i+startIndex]);
- }
-
- [Test]
- public void Inflate_Expand()
- {
- uncompressedData.Clear();
-
- using (Inflater inf = new Inflater())
- {
- inf.DataAvailable += new DataAvailableHandler(DDataAvail);
- inf.Add((byte[])compressedData.ToArray(typeof(byte)));
- inf.Finish();
- adler2 = inf.Checksum;
- }
- Assert.AreEqual( adler1, adler2 );
- }
- #endregion
- }
-
- [TestFixture]
- public class GZipStreamTests
- {
- #region GZipStream test
- [Test]
- public void GZipStream_WriteRead()
- {
- using (GZipStream gzOut = new GZipStream("gzstream.gz", CompressLevel.Best))
- {
- BinaryWriter writer = new BinaryWriter(gzOut);
- writer.Write("hi there");
- writer.Write(Math.PI);
- writer.Write(42);
- }
-
- using (GZipStream gzIn = new GZipStream("gzstream.gz"))
- {
- BinaryReader reader = new BinaryReader(gzIn);
- string s = reader.ReadString();
- Assert.AreEqual("hi there",s);
- double d = reader.ReadDouble();
- Assert.AreEqual(Math.PI, d);
- int i = reader.ReadInt32();
- Assert.AreEqual(42,i);
- }
-
- }
- #endregion
- }
-}
-
-#endif \ No newline at end of file
diff --git a/source4/lib/zlib/contrib/dotzlib/LICENSE_1_0.txt b/source4/lib/zlib/contrib/dotzlib/LICENSE_1_0.txt
deleted file mode 100644
index 30aac2cf47..0000000000
--- a/source4/lib/zlib/contrib/dotzlib/LICENSE_1_0.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-Boost Software License - Version 1.0 - August 17th, 2003
-
-Permission is hereby granted, free of charge, to any person or organization
-obtaining a copy of the software and accompanying documentation covered by
-this license (the "Software") to use, reproduce, display, distribute,
-execute, and transmit the Software, and to prepare derivative works of the
-Software, and to permit third-parties to whom the Software is furnished to
-do so, all subject to the following:
-
-The copyright notices in the Software and this entire statement, including
-the above license grant, this restriction and the following disclaimer,
-must be included in all copies of the Software, in whole or in part, and
-all derivative works of the Software, unless such copies or derivative
-works are solely in the form of machine-executable object code generated by
-a source language processor.
-
-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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE. \ No newline at end of file
diff --git a/source4/lib/zlib/contrib/dotzlib/readme.txt b/source4/lib/zlib/contrib/dotzlib/readme.txt
deleted file mode 100644
index 210f4b0019..0000000000
--- a/source4/lib/zlib/contrib/dotzlib/readme.txt
+++ /dev/null
@@ -1,58 +0,0 @@
-This directory contains a .Net wrapper class library for the ZLib1.dll
-
-The wrapper includes support for inflating/deflating memory buffers,
-.Net streaming wrappers for the gz streams part of zlib, and wrappers
-for the checksum parts of zlib. See DotZLib/UnitTests.cs for examples.
-
-Directory structure:
---------------------
-
-LICENSE_1_0.txt - License file.
-readme.txt - This file.
-DotZLib.chm - Class library documentation
-DotZLib.build - NAnt build file
-DotZLib.sln - Microsoft Visual Studio 2003 solution file
-
-DotZLib\*.cs - Source files for the class library
-
-Unit tests:
------------
-The file DotZLib/UnitTests.cs contains unit tests for use with NUnit 2.1 or higher.
-To include unit tests in the build, define nunit before building.
-
-
-Build instructions:
--------------------
-
-1. Using Visual Studio.Net 2003:
- Open DotZLib.sln in VS.Net and build from there. Output file (DotZLib.dll)
- will be found ./DotZLib/bin/release or ./DotZLib/bin/debug, depending on
- you are building the release or debug version of the library. Check
- DotZLib/UnitTests.cs for instructions on how to include unit tests in the
- build.
-
-2. Using NAnt:
- Open a command prompt with access to the build environment and run nant
- in the same directory as the DotZLib.build file.
- You can define 2 properties on the nant command-line to control the build:
- debug={true|false} to toggle between release/debug builds (default=true).
- nunit={true|false} to include or esclude unit tests (default=true).
- Also the target clean will remove binaries.
- Output file (DotZLib.dll) will be found in either ./DotZLib/bin/release
- or ./DotZLib/bin/debug, depending on whether you are building the release
- or debug version of the library.
-
- Examples:
- nant -D:debug=false -D:nunit=false
- will build a release mode version of the library without unit tests.
- nant
- will build a debug version of the library with unit tests
- nant clean
- will remove all previously built files.
-
-
----------------------------------
-Copyright (c) Henrik Ravn 2004
-
-Use, modification and distribution are subject to the Boost Software License, Version 1.0.
-(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/source4/lib/zlib/contrib/infback9/README b/source4/lib/zlib/contrib/infback9/README
deleted file mode 100644
index e75ed13294..0000000000
--- a/source4/lib/zlib/contrib/infback9/README
+++ /dev/null
@@ -1 +0,0 @@
-See infback9.h for what this is and how to use it.
diff --git a/source4/lib/zlib/contrib/infback9/infback9.c b/source4/lib/zlib/contrib/infback9/infback9.c
deleted file mode 100644
index f5ddde67da..0000000000
--- a/source4/lib/zlib/contrib/infback9/infback9.c
+++ /dev/null
@@ -1,608 +0,0 @@
-/* infback9.c -- inflate deflate64 data using a call-back interface
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "zutil.h"
-#include "infback9.h"
-#include "inftree9.h"
-#include "inflate9.h"
-
-#define WSIZE 65536UL
-
-/*
- strm provides memory allocation functions in zalloc and zfree, or
- Z_NULL to use the library memory allocation functions.
-
- window is a user-supplied window and output buffer that is 64K bytes.
- */
-int ZEXPORT inflateBack9Init_(strm, window, version, stream_size)
-z_stream FAR *strm;
-unsigned char FAR *window;
-const char *version;
-int stream_size;
-{
- struct inflate_state FAR *state;
-
- if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
- stream_size != (int)(sizeof(z_stream)))
- return Z_VERSION_ERROR;
- if (strm == Z_NULL || window == Z_NULL)
- return Z_STREAM_ERROR;
- strm->msg = Z_NULL; /* in case we return an error */
- if (strm->zalloc == (alloc_func)0) {
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
- }
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
- state = (struct inflate_state FAR *)ZALLOC(strm, 1,
- sizeof(struct inflate_state));
- if (state == Z_NULL) return Z_MEM_ERROR;
- Tracev((stderr, "inflate: allocated\n"));
- strm->state = (voidpf)state;
- state->window = window;
- return Z_OK;
-}
-
-/*
- Build and output length and distance decoding tables for fixed code
- decoding.
- */
-#ifdef MAKEFIXED
-#include <stdio.h>
-
-void makefixed9(void)
-{
- unsigned sym, bits, low, size;
- code *next, *lenfix, *distfix;
- struct inflate_state state;
- code fixed[544];
-
- /* literal/length table */
- sym = 0;
- while (sym < 144) state.lens[sym++] = 8;
- while (sym < 256) state.lens[sym++] = 9;
- while (sym < 280) state.lens[sym++] = 7;
- while (sym < 288) state.lens[sym++] = 8;
- next = fixed;
- lenfix = next;
- bits = 9;
- inflate_table9(LENS, state.lens, 288, &(next), &(bits), state.work);
-
- /* distance table */
- sym = 0;
- while (sym < 32) state.lens[sym++] = 5;
- distfix = next;
- bits = 5;
- inflate_table9(DISTS, state.lens, 32, &(next), &(bits), state.work);
-
- /* write tables */
- puts(" /* inffix9.h -- table for decoding deflate64 fixed codes");
- puts(" * Generated automatically by makefixed9().");
- puts(" */");
- puts("");
- puts(" /* WARNING: this file should *not* be used by applications.");
- puts(" It is part of the implementation of this library and is");
- puts(" subject to change. Applications should only use zlib.h.");
- puts(" */");
- puts("");
- size = 1U << 9;
- printf(" static const code lenfix[%u] = {", size);
- low = 0;
- for (;;) {
- if ((low % 6) == 0) printf("\n ");
- printf("{%u,%u,%d}", lenfix[low].op, lenfix[low].bits,
- lenfix[low].val);
- if (++low == size) break;
- putchar(',');
- }
- puts("\n };");
- size = 1U << 5;
- printf("\n static const code distfix[%u] = {", size);
- low = 0;
- for (;;) {
- if ((low % 5) == 0) printf("\n ");
- printf("{%u,%u,%d}", distfix[low].op, distfix[low].bits,
- distfix[low].val);
- if (++low == size) break;
- putchar(',');
- }
- puts("\n };");
-}
-#endif /* MAKEFIXED */
-
-/* Macros for inflateBack(): */
-
-/* Clear the input bit accumulator */
-#define INITBITS() \
- do { \
- hold = 0; \
- bits = 0; \
- } while (0)
-
-/* Assure that some input is available. If input is requested, but denied,
- then return a Z_BUF_ERROR from inflateBack(). */
-#define PULL() \
- do { \
- if (have == 0) { \
- have = in(in_desc, &next); \
- if (have == 0) { \
- next = Z_NULL; \
- ret = Z_BUF_ERROR; \
- goto inf_leave; \
- } \
- } \
- } while (0)
-
-/* Get a byte of input into the bit accumulator, or return from inflateBack()
- with an error if there is no input available. */
-#define PULLBYTE() \
- do { \
- PULL(); \
- have--; \
- hold += (unsigned long)(*next++) << bits; \
- bits += 8; \
- } while (0)
-
-/* Assure that there are at least n bits in the bit accumulator. If there is
- not enough available input to do that, then return from inflateBack() with
- an error. */
-#define NEEDBITS(n) \
- do { \
- while (bits < (unsigned)(n)) \
- PULLBYTE(); \
- } while (0)
-
-/* Return the low n bits of the bit accumulator (n <= 16) */
-#define BITS(n) \
- ((unsigned)hold & ((1U << (n)) - 1))
-
-/* Remove n bits from the bit accumulator */
-#define DROPBITS(n) \
- do { \
- hold >>= (n); \
- bits -= (unsigned)(n); \
- } while (0)
-
-/* Remove zero to seven bits as needed to go to a byte boundary */
-#define BYTEBITS() \
- do { \
- hold >>= bits & 7; \
- bits -= bits & 7; \
- } while (0)
-
-/* Assure that some output space is available, by writing out the window
- if it's full. If the write fails, return from inflateBack() with a
- Z_BUF_ERROR. */
-#define ROOM() \
- do { \
- if (left == 0) { \
- put = window; \
- left = WSIZE; \
- wrap = 1; \
- if (out(out_desc, put, (unsigned)left)) { \
- ret = Z_BUF_ERROR; \
- goto inf_leave; \
- } \
- } \
- } while (0)
-
-/*
- strm provides the memory allocation functions and window buffer on input,
- and provides information on the unused input on return. For Z_DATA_ERROR
- returns, strm will also provide an error message.
-
- in() and out() are the call-back input and output functions. When
- inflateBack() needs more input, it calls in(). When inflateBack() has
- filled the window with output, or when it completes with data in the
- window, it calls out() to write out the data. The application must not
- change the provided input until in() is called again or inflateBack()
- returns. The application must not change the window/output buffer until
- inflateBack() returns.
-
- in() and out() are called with a descriptor parameter provided in the
- inflateBack() call. This parameter can be a structure that provides the
- information required to do the read or write, as well as accumulated
- information on the input and output such as totals and check values.
-
- in() should return zero on failure. out() should return non-zero on
- failure. If either in() or out() fails, than inflateBack() returns a
- Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it
- was in() or out() that caused in the error. Otherwise, inflateBack()
- returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format
- error, or Z_MEM_ERROR if it could not allocate memory for the state.
- inflateBack() can also return Z_STREAM_ERROR if the input parameters
- are not correct, i.e. strm is Z_NULL or the state was not initialized.
- */
-int ZEXPORT inflateBack9(strm, in, in_desc, out, out_desc)
-z_stream FAR *strm;
-in_func in;
-void FAR *in_desc;
-out_func out;
-void FAR *out_desc;
-{
- struct inflate_state FAR *state;
- unsigned char FAR *next; /* next input */
- unsigned char FAR *put; /* next output */
- unsigned have; /* available input */
- unsigned long left; /* available output */
- inflate_mode mode; /* current inflate mode */
- int lastblock; /* true if processing last block */
- int wrap; /* true if the window has wrapped */
- unsigned long write; /* window write index */
- unsigned char FAR *window; /* allocated sliding window, if needed */
- unsigned long hold; /* bit buffer */
- unsigned bits; /* bits in bit buffer */
- unsigned extra; /* extra bits needed */
- unsigned long length; /* literal or length of data to copy */
- unsigned long offset; /* distance back to copy string from */
- unsigned long copy; /* number of stored or match bytes to copy */
- unsigned char FAR *from; /* where to copy match bytes from */
- code const FAR *lencode; /* starting table for length/literal codes */
- code const FAR *distcode; /* starting table for distance codes */
- unsigned lenbits; /* index bits for lencode */
- unsigned distbits; /* index bits for distcode */
- code this; /* current decoding table entry */
- code last; /* parent table entry */
- unsigned len; /* length to copy for repeats, bits to drop */
- int ret; /* return code */
- static const unsigned short order[19] = /* permutation of code lengths */
- {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-#include "inffix9.h"
-
- /* Check that the strm exists and that the state was initialized */
- if (strm == Z_NULL || strm->state == Z_NULL)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
-
- /* Reset the state */
- strm->msg = Z_NULL;
- mode = TYPE;
- lastblock = 0;
- write = 0;
- wrap = 0;
- window = state->window;
- next = strm->next_in;
- have = next != Z_NULL ? strm->avail_in : 0;
- hold = 0;
- bits = 0;
- put = window;
- left = WSIZE;
- lencode = Z_NULL;
- distcode = Z_NULL;
-
- /* Inflate until end of block marked as last */
- for (;;)
- switch (mode) {
- case TYPE:
- /* determine and dispatch block type */
- if (lastblock) {
- BYTEBITS();
- mode = DONE;
- break;
- }
- NEEDBITS(3);
- lastblock = BITS(1);
- DROPBITS(1);
- switch (BITS(2)) {
- case 0: /* stored block */
- Tracev((stderr, "inflate: stored block%s\n",
- lastblock ? " (last)" : ""));
- mode = STORED;
- break;
- case 1: /* fixed block */
- lencode = lenfix;
- lenbits = 9;
- distcode = distfix;
- distbits = 5;
- Tracev((stderr, "inflate: fixed codes block%s\n",
- lastblock ? " (last)" : ""));
- mode = LEN; /* decode codes */
- break;
- case 2: /* dynamic block */
- Tracev((stderr, "inflate: dynamic codes block%s\n",
- lastblock ? " (last)" : ""));
- mode = TABLE;
- break;
- case 3:
- strm->msg = (char *)"invalid block type";
- mode = BAD;
- }
- DROPBITS(2);
- break;
-
- case STORED:
- /* get and verify stored block length */
- BYTEBITS(); /* go to byte boundary */
- NEEDBITS(32);
- if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
- strm->msg = (char *)"invalid stored block lengths";
- mode = BAD;
- break;
- }
- length = (unsigned)hold & 0xffff;
- Tracev((stderr, "inflate: stored length %lu\n",
- length));
- INITBITS();
-
- /* copy stored block from input to output */
- while (length != 0) {
- copy = length;
- PULL();
- ROOM();
- if (copy > have) copy = have;
- if (copy > left) copy = left;
- zmemcpy(put, next, copy);
- have -= copy;
- next += copy;
- left -= copy;
- put += copy;
- length -= copy;
- }
- Tracev((stderr, "inflate: stored end\n"));
- mode = TYPE;
- break;
-
- case TABLE:
- /* get dynamic table entries descriptor */
- NEEDBITS(14);
- state->nlen = BITS(5) + 257;
- DROPBITS(5);
- state->ndist = BITS(5) + 1;
- DROPBITS(5);
- state->ncode = BITS(4) + 4;
- DROPBITS(4);
- if (state->nlen > 286) {
- strm->msg = (char *)"too many length symbols";
- mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: table sizes ok\n"));
-
- /* get code length code lengths (not a typo) */
- state->have = 0;
- while (state->have < state->ncode) {
- NEEDBITS(3);
- state->lens[order[state->have++]] = (unsigned short)BITS(3);
- DROPBITS(3);
- }
- while (state->have < 19)
- state->lens[order[state->have++]] = 0;
- state->next = state->codes;
- lencode = (code const FAR *)(state->next);
- lenbits = 7;
- ret = inflate_table9(CODES, state->lens, 19, &(state->next),
- &(lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid code lengths set";
- mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: code lengths ok\n"));
-
- /* get length and distance code code lengths */
- state->have = 0;
- while (state->have < state->nlen + state->ndist) {
- for (;;) {
- this = lencode[BITS(lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.val < 16) {
- NEEDBITS(this.bits);
- DROPBITS(this.bits);
- state->lens[state->have++] = this.val;
- }
- else {
- if (this.val == 16) {
- NEEDBITS(this.bits + 2);
- DROPBITS(this.bits);
- if (state->have == 0) {
- strm->msg = (char *)"invalid bit length repeat";
- mode = BAD;
- break;
- }
- len = (unsigned)(state->lens[state->have - 1]);
- copy = 3 + BITS(2);
- DROPBITS(2);
- }
- else if (this.val == 17) {
- NEEDBITS(this.bits + 3);
- DROPBITS(this.bits);
- len = 0;
- copy = 3 + BITS(3);
- DROPBITS(3);
- }
- else {
- NEEDBITS(this.bits + 7);
- DROPBITS(this.bits);
- len = 0;
- copy = 11 + BITS(7);
- DROPBITS(7);
- }
- if (state->have + copy > state->nlen + state->ndist) {
- strm->msg = (char *)"invalid bit length repeat";
- mode = BAD;
- break;
- }
- while (copy--)
- state->lens[state->have++] = (unsigned short)len;
- }
- }
-
- /* handle error breaks in while */
- if (mode == BAD) break;
-
- /* build code tables */
- state->next = state->codes;
- lencode = (code const FAR *)(state->next);
- lenbits = 9;
- ret = inflate_table9(LENS, state->lens, state->nlen,
- &(state->next), &(lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid literal/lengths set";
- mode = BAD;
- break;
- }
- distcode = (code const FAR *)(state->next);
- distbits = 6;
- ret = inflate_table9(DISTS, state->lens + state->nlen,
- state->ndist, &(state->next), &(distbits),
- state->work);
- if (ret) {
- strm->msg = (char *)"invalid distances set";
- mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: codes ok\n"));
- mode = LEN;
-
- case LEN:
- /* get a literal, length, or end-of-block code */
- for (;;) {
- this = lencode[BITS(lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.op && (this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = lencode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- length = (unsigned)this.val;
-
- /* process literal */
- if (this.op == 0) {
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- ROOM();
- *put++ = (unsigned char)(length);
- left--;
- mode = LEN;
- break;
- }
-
- /* process end of block */
- if (this.op & 32) {
- Tracevv((stderr, "inflate: end of block\n"));
- mode = TYPE;
- break;
- }
-
- /* invalid code */
- if (this.op & 64) {
- strm->msg = (char *)"invalid literal/length code";
- mode = BAD;
- break;
- }
-
- /* length code -- get extra bits, if any */
- extra = (unsigned)(this.op) & 31;
- if (extra != 0) {
- NEEDBITS(extra);
- length += BITS(extra);
- DROPBITS(extra);
- }
- Tracevv((stderr, "inflate: length %lu\n", length));
-
- /* get distance code */
- for (;;) {
- this = distcode[BITS(distbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if ((this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = distcode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- if (this.op & 64) {
- strm->msg = (char *)"invalid distance code";
- mode = BAD;
- break;
- }
- offset = (unsigned)this.val;
-
- /* get distance extra bits, if any */
- extra = (unsigned)(this.op) & 15;
- if (extra != 0) {
- NEEDBITS(extra);
- offset += BITS(extra);
- DROPBITS(extra);
- }
- if (offset > WSIZE - (wrap ? 0: left)) {
- strm->msg = (char *)"invalid distance too far back";
- mode = BAD;
- break;
- }
- Tracevv((stderr, "inflate: distance %lu\n", offset));
-
- /* copy match from window to output */
- do {
- ROOM();
- copy = WSIZE - offset;
- if (copy < left) {
- from = put + copy;
- copy = left - copy;
- }
- else {
- from = put - offset;
- copy = left;
- }
- if (copy > length) copy = length;
- length -= copy;
- left -= copy;
- do {
- *put++ = *from++;
- } while (--copy);
- } while (length != 0);
- break;
-
- case DONE:
- /* inflate stream terminated properly -- write leftover output */
- ret = Z_STREAM_END;
- if (left < WSIZE) {
- if (out(out_desc, window, (unsigned)(WSIZE - left)))
- ret = Z_BUF_ERROR;
- }
- goto inf_leave;
-
- case BAD:
- ret = Z_DATA_ERROR;
- goto inf_leave;
-
- default: /* can't happen, but makes compilers happy */
- ret = Z_STREAM_ERROR;
- goto inf_leave;
- }
-
- /* Return unused input */
- inf_leave:
- strm->next_in = next;
- strm->avail_in = have;
- return ret;
-}
-
-int ZEXPORT inflateBack9End(strm)
-z_stream FAR *strm;
-{
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
- Tracev((stderr, "inflate: end\n"));
- return Z_OK;
-}
diff --git a/source4/lib/zlib/contrib/infback9/infback9.h b/source4/lib/zlib/contrib/infback9/infback9.h
deleted file mode 100644
index 1073c0a38e..0000000000
--- a/source4/lib/zlib/contrib/infback9/infback9.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* infback9.h -- header for using inflateBack9 functions
- * Copyright (C) 2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * This header file and associated patches provide a decoder for PKWare's
- * undocumented deflate64 compression method (method 9). Use with infback9.c,
- * inftree9.h, inftree9.c, and inffix9.h. These patches are not supported.
- * This should be compiled with zlib, since it uses zutil.h and zutil.o.
- * This code has not yet been tested on 16-bit architectures. See the
- * comments in zlib.h for inflateBack() usage. These functions are used
- * identically, except that there is no windowBits parameter, and a 64K
- * window must be provided. Also if int's are 16 bits, then a zero for
- * the third parameter of the "out" function actually means 65536UL.
- * zlib.h must be included before this header file.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-ZEXTERN int ZEXPORT inflateBack9 OF((z_stream FAR *strm,
- in_func in, void FAR *in_desc,
- out_func out, void FAR *out_desc));
-ZEXTERN int ZEXPORT inflateBack9End OF((z_stream FAR *strm));
-ZEXTERN int ZEXPORT inflateBack9Init_ OF((z_stream FAR *strm,
- unsigned char FAR *window,
- const char *version,
- int stream_size));
-#define inflateBack9Init(strm, window) \
- inflateBack9Init_((strm), (window), \
- ZLIB_VERSION, sizeof(z_stream))
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/source4/lib/zlib/contrib/infback9/inffix9.h b/source4/lib/zlib/contrib/infback9/inffix9.h
deleted file mode 100644
index ee5671d2df..0000000000
--- a/source4/lib/zlib/contrib/infback9/inffix9.h
+++ /dev/null
@@ -1,107 +0,0 @@
- /* inffix9.h -- table for decoding deflate64 fixed codes
- * Generated automatically by makefixed9().
- */
-
- /* WARNING: this file should *not* be used by applications.
- It is part of the implementation of this library and is
- subject to change. Applications should only use zlib.h.
- */
-
- static const code lenfix[512] = {
- {96,7,0},{0,8,80},{0,8,16},{132,8,115},{130,7,31},{0,8,112},
- {0,8,48},{0,9,192},{128,7,10},{0,8,96},{0,8,32},{0,9,160},
- {0,8,0},{0,8,128},{0,8,64},{0,9,224},{128,7,6},{0,8,88},
- {0,8,24},{0,9,144},{131,7,59},{0,8,120},{0,8,56},{0,9,208},
- {129,7,17},{0,8,104},{0,8,40},{0,9,176},{0,8,8},{0,8,136},
- {0,8,72},{0,9,240},{128,7,4},{0,8,84},{0,8,20},{133,8,227},
- {131,7,43},{0,8,116},{0,8,52},{0,9,200},{129,7,13},{0,8,100},
- {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},
- {128,7,8},{0,8,92},{0,8,28},{0,9,152},{132,7,83},{0,8,124},
- {0,8,60},{0,9,216},{130,7,23},{0,8,108},{0,8,44},{0,9,184},
- {0,8,12},{0,8,140},{0,8,76},{0,9,248},{128,7,3},{0,8,82},
- {0,8,18},{133,8,163},{131,7,35},{0,8,114},{0,8,50},{0,9,196},
- {129,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},{0,8,130},
- {0,8,66},{0,9,228},{128,7,7},{0,8,90},{0,8,26},{0,9,148},
- {132,7,67},{0,8,122},{0,8,58},{0,9,212},{130,7,19},{0,8,106},
- {0,8,42},{0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},
- {128,7,5},{0,8,86},{0,8,22},{65,8,0},{131,7,51},{0,8,118},
- {0,8,54},{0,9,204},{129,7,15},{0,8,102},{0,8,38},{0,9,172},
- {0,8,6},{0,8,134},{0,8,70},{0,9,236},{128,7,9},{0,8,94},
- {0,8,30},{0,9,156},{132,7,99},{0,8,126},{0,8,62},{0,9,220},
- {130,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
- {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{133,8,131},
- {130,7,31},{0,8,113},{0,8,49},{0,9,194},{128,7,10},{0,8,97},
- {0,8,33},{0,9,162},{0,8,1},{0,8,129},{0,8,65},{0,9,226},
- {128,7,6},{0,8,89},{0,8,25},{0,9,146},{131,7,59},{0,8,121},
- {0,8,57},{0,9,210},{129,7,17},{0,8,105},{0,8,41},{0,9,178},
- {0,8,9},{0,8,137},{0,8,73},{0,9,242},{128,7,4},{0,8,85},
- {0,8,21},{144,8,3},{131,7,43},{0,8,117},{0,8,53},{0,9,202},
- {129,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},
- {0,8,69},{0,9,234},{128,7,8},{0,8,93},{0,8,29},{0,9,154},
- {132,7,83},{0,8,125},{0,8,61},{0,9,218},{130,7,23},{0,8,109},
- {0,8,45},{0,9,186},{0,8,13},{0,8,141},{0,8,77},{0,9,250},
- {128,7,3},{0,8,83},{0,8,19},{133,8,195},{131,7,35},{0,8,115},
- {0,8,51},{0,9,198},{129,7,11},{0,8,99},{0,8,35},{0,9,166},
- {0,8,3},{0,8,131},{0,8,67},{0,9,230},{128,7,7},{0,8,91},
- {0,8,27},{0,9,150},{132,7,67},{0,8,123},{0,8,59},{0,9,214},
- {130,7,19},{0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},
- {0,8,75},{0,9,246},{128,7,5},{0,8,87},{0,8,23},{77,8,0},
- {131,7,51},{0,8,119},{0,8,55},{0,9,206},{129,7,15},{0,8,103},
- {0,8,39},{0,9,174},{0,8,7},{0,8,135},{0,8,71},{0,9,238},
- {128,7,9},{0,8,95},{0,8,31},{0,9,158},{132,7,99},{0,8,127},
- {0,8,63},{0,9,222},{130,7,27},{0,8,111},{0,8,47},{0,9,190},
- {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},
- {0,8,16},{132,8,115},{130,7,31},{0,8,112},{0,8,48},{0,9,193},
- {128,7,10},{0,8,96},{0,8,32},{0,9,161},{0,8,0},{0,8,128},
- {0,8,64},{0,9,225},{128,7,6},{0,8,88},{0,8,24},{0,9,145},
- {131,7,59},{0,8,120},{0,8,56},{0,9,209},{129,7,17},{0,8,104},
- {0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},{0,9,241},
- {128,7,4},{0,8,84},{0,8,20},{133,8,227},{131,7,43},{0,8,116},
- {0,8,52},{0,9,201},{129,7,13},{0,8,100},{0,8,36},{0,9,169},
- {0,8,4},{0,8,132},{0,8,68},{0,9,233},{128,7,8},{0,8,92},
- {0,8,28},{0,9,153},{132,7,83},{0,8,124},{0,8,60},{0,9,217},
- {130,7,23},{0,8,108},{0,8,44},{0,9,185},{0,8,12},{0,8,140},
- {0,8,76},{0,9,249},{128,7,3},{0,8,82},{0,8,18},{133,8,163},
- {131,7,35},{0,8,114},{0,8,50},{0,9,197},{129,7,11},{0,8,98},
- {0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
- {128,7,7},{0,8,90},{0,8,26},{0,9,149},{132,7,67},{0,8,122},
- {0,8,58},{0,9,213},{130,7,19},{0,8,106},{0,8,42},{0,9,181},
- {0,8,10},{0,8,138},{0,8,74},{0,9,245},{128,7,5},{0,8,86},
- {0,8,22},{65,8,0},{131,7,51},{0,8,118},{0,8,54},{0,9,205},
- {129,7,15},{0,8,102},{0,8,38},{0,9,173},{0,8,6},{0,8,134},
- {0,8,70},{0,9,237},{128,7,9},{0,8,94},{0,8,30},{0,9,157},
- {132,7,99},{0,8,126},{0,8,62},{0,9,221},{130,7,27},{0,8,110},
- {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},
- {96,7,0},{0,8,81},{0,8,17},{133,8,131},{130,7,31},{0,8,113},
- {0,8,49},{0,9,195},{128,7,10},{0,8,97},{0,8,33},{0,9,163},
- {0,8,1},{0,8,129},{0,8,65},{0,9,227},{128,7,6},{0,8,89},
- {0,8,25},{0,9,147},{131,7,59},{0,8,121},{0,8,57},{0,9,211},
- {129,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},{0,8,137},
- {0,8,73},{0,9,243},{128,7,4},{0,8,85},{0,8,21},{144,8,3},
- {131,7,43},{0,8,117},{0,8,53},{0,9,203},{129,7,13},{0,8,101},
- {0,8,37},{0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},
- {128,7,8},{0,8,93},{0,8,29},{0,9,155},{132,7,83},{0,8,125},
- {0,8,61},{0,9,219},{130,7,23},{0,8,109},{0,8,45},{0,9,187},
- {0,8,13},{0,8,141},{0,8,77},{0,9,251},{128,7,3},{0,8,83},
- {0,8,19},{133,8,195},{131,7,35},{0,8,115},{0,8,51},{0,9,199},
- {129,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
- {0,8,67},{0,9,231},{128,7,7},{0,8,91},{0,8,27},{0,9,151},
- {132,7,67},{0,8,123},{0,8,59},{0,9,215},{130,7,19},{0,8,107},
- {0,8,43},{0,9,183},{0,8,11},{0,8,139},{0,8,75},{0,9,247},
- {128,7,5},{0,8,87},{0,8,23},{77,8,0},{131,7,51},{0,8,119},
- {0,8,55},{0,9,207},{129,7,15},{0,8,103},{0,8,39},{0,9,175},
- {0,8,7},{0,8,135},{0,8,71},{0,9,239},{128,7,9},{0,8,95},
- {0,8,31},{0,9,159},{132,7,99},{0,8,127},{0,8,63},{0,9,223},
- {130,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},
- {0,8,79},{0,9,255}
- };
-
- static const code distfix[32] = {
- {128,5,1},{135,5,257},{131,5,17},{139,5,4097},{129,5,5},
- {137,5,1025},{133,5,65},{141,5,16385},{128,5,3},{136,5,513},
- {132,5,33},{140,5,8193},{130,5,9},{138,5,2049},{134,5,129},
- {142,5,32769},{128,5,2},{135,5,385},{131,5,25},{139,5,6145},
- {129,5,7},{137,5,1537},{133,5,97},{141,5,24577},{128,5,4},
- {136,5,769},{132,5,49},{140,5,12289},{130,5,13},{138,5,3073},
- {134,5,193},{142,5,49153}
- };
diff --git a/source4/lib/zlib/contrib/infback9/inflate9.h b/source4/lib/zlib/contrib/infback9/inflate9.h
deleted file mode 100644
index ee9a79394b..0000000000
--- a/source4/lib/zlib/contrib/infback9/inflate9.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* inflate9.h -- internal inflate state definition
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* Possible inflate modes between inflate() calls */
-typedef enum {
- TYPE, /* i: waiting for type bits, including last-flag bit */
- STORED, /* i: waiting for stored size (length and complement) */
- TABLE, /* i: waiting for dynamic block table lengths */
- LEN, /* i: waiting for length/lit code */
- DONE, /* finished check, done -- remain here until reset */
- BAD /* got a data error -- remain here until reset */
-} inflate_mode;
-
-/*
- State transitions between above modes -
-
- (most modes can go to the BAD mode -- not shown for clarity)
-
- Read deflate blocks:
- TYPE -> STORED or TABLE or LEN or DONE
- STORED -> TYPE
- TABLE -> LENLENS -> CODELENS -> LEN
- Read deflate codes:
- LEN -> LEN or TYPE
- */
-
-/* state maintained between inflate() calls. Approximately 7K bytes. */
-struct inflate_state {
- /* sliding window */
- unsigned char FAR *window; /* allocated sliding window, if needed */
- /* dynamic table building */
- unsigned ncode; /* number of code length code lengths */
- unsigned nlen; /* number of length code lengths */
- unsigned ndist; /* number of distance code lengths */
- unsigned have; /* number of code lengths in lens[] */
- code FAR *next; /* next available space in codes[] */
- unsigned short lens[320]; /* temporary storage for code lengths */
- unsigned short work[288]; /* work area for code table building */
- code codes[ENOUGH]; /* space for code tables */
-};
diff --git a/source4/lib/zlib/contrib/infback9/inftree9.c b/source4/lib/zlib/contrib/infback9/inftree9.c
deleted file mode 100644
index 0993f75646..0000000000
--- a/source4/lib/zlib/contrib/infback9/inftree9.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/* inftree9.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "zutil.h"
-#include "inftree9.h"
-
-#define MAXBITS 15
-
-const char inflate9_copyright[] =
- " inflate9 1.2.3 Copyright 1995-2005 Mark Adler ";
-/*
- If you use the zlib library in a product, an acknowledgment is welcome
- in the documentation of your product. If for some reason you cannot
- include such an acknowledgment, I would appreciate that you keep this
- copyright string in the executable of your product.
- */
-
-/*
- Build a set of tables to decode the provided canonical Huffman code.
- The code lengths are lens[0..codes-1]. The result starts at *table,
- whose indices are 0..2^bits-1. work is a writable array of at least
- lens shorts, which is used as a work area. type is the type of code
- to be generated, CODES, LENS, or DISTS. On return, zero is success,
- -1 is an invalid code, and +1 means that ENOUGH isn't enough. table
- on return points to the next available entry's address. bits is the
- requested root table index bits, and on return it is the actual root
- table index bits. It will differ if the request is greater than the
- longest code or if it is less than the shortest code.
- */
-int inflate_table9(type, lens, codes, table, bits, work)
-codetype type;
-unsigned short FAR *lens;
-unsigned codes;
-code FAR * FAR *table;
-unsigned FAR *bits;
-unsigned short FAR *work;
-{
- unsigned len; /* a code's length in bits */
- unsigned sym; /* index of code symbols */
- unsigned min, max; /* minimum and maximum code lengths */
- unsigned root; /* number of index bits for root table */
- unsigned curr; /* number of index bits for current table */
- unsigned drop; /* code bits to drop for sub-table */
- int left; /* number of prefix codes available */
- unsigned used; /* code entries in table used */
- unsigned huff; /* Huffman code */
- unsigned incr; /* for incrementing code, index */
- unsigned fill; /* index for replicating entries */
- unsigned low; /* low bits for current root entry */
- unsigned mask; /* mask for low root bits */
- code this; /* table entry for duplication */
- code FAR *next; /* next available space in table */
- const unsigned short FAR *base; /* base value table to use */
- const unsigned short FAR *extra; /* extra bits table to use */
- int end; /* use base and extra for symbol > end */
- unsigned short count[MAXBITS+1]; /* number of codes of each length */
- unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
- static const unsigned short lbase[31] = { /* Length codes 257..285 base */
- 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, 3, 0, 0};
- static const unsigned short lext[31] = { /* Length codes 257..285 extra */
- 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
- 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
- 133, 133, 133, 133, 144, 201, 196};
- static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
- 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, 32769, 49153};
- static const unsigned short dext[32] = { /* Distance codes 0..31 extra */
- 128, 128, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132,
- 133, 133, 134, 134, 135, 135, 136, 136, 137, 137, 138, 138,
- 139, 139, 140, 140, 141, 141, 142, 142};
-
- /*
- Process a set of code lengths to create a canonical Huffman code. The
- code lengths are lens[0..codes-1]. Each length corresponds to the
- symbols 0..codes-1. The Huffman code is generated by first sorting the
- symbols by length from short to long, and retaining the symbol order
- for codes with equal lengths. Then the code starts with all zero bits
- for the first code of the shortest length, and the codes are integer
- increments for the same length, and zeros are appended as the length
- increases. For the deflate format, these bits are stored backwards
- from their more natural integer increment ordering, and so when the
- decoding tables are built in the large loop below, the integer codes
- are incremented backwards.
-
- This routine assumes, but does not check, that all of the entries in
- lens[] are in the range 0..MAXBITS. The caller must assure this.
- 1..MAXBITS is interpreted as that code length. zero means that that
- symbol does not occur in this code.
-
- The codes are sorted by computing a count of codes for each length,
- creating from that a table of starting indices for each length in the
- sorted table, and then entering the symbols in order in the sorted
- table. The sorted table is work[], with that space being provided by
- the caller.
-
- The length counts are used for other purposes as well, i.e. finding
- the minimum and maximum length codes, determining if there are any
- codes at all, checking for a valid set of lengths, and looking ahead
- at length counts to determine sub-table sizes when building the
- decoding tables.
- */
-
- /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
- for (len = 0; len <= MAXBITS; len++)
- count[len] = 0;
- for (sym = 0; sym < codes; sym++)
- count[lens[sym]]++;
-
- /* bound code lengths, force root to be within code lengths */
- root = *bits;
- for (max = MAXBITS; max >= 1; max--)
- if (count[max] != 0) break;
- if (root > max) root = max;
- if (max == 0) return -1; /* no codes! */
- for (min = 1; min <= MAXBITS; min++)
- if (count[min] != 0) break;
- if (root < min) root = min;
-
- /* check for an over-subscribed or incomplete set of lengths */
- left = 1;
- for (len = 1; len <= MAXBITS; len++) {
- left <<= 1;
- left -= count[len];
- if (left < 0) return -1; /* over-subscribed */
- }
- if (left > 0 && (type == CODES || max != 1))
- return -1; /* incomplete set */
-
- /* generate offsets into symbol table for each length for sorting */
- offs[1] = 0;
- for (len = 1; len < MAXBITS; len++)
- offs[len + 1] = offs[len] + count[len];
-
- /* sort symbols by length, by symbol order within each length */
- for (sym = 0; sym < codes; sym++)
- if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
-
- /*
- Create and fill in decoding tables. In this loop, the table being
- filled is at next and has curr index bits. The code being used is huff
- with length len. That code is converted to an index by dropping drop
- bits off of the bottom. For codes where len is less than drop + curr,
- those top drop + curr - len bits are incremented through all values to
- fill the table with replicated entries.
-
- root is the number of index bits for the root table. When len exceeds
- root, sub-tables are created pointed to by the root entry with an index
- of the low root bits of huff. This is saved in low to check for when a
- new sub-table should be started. drop is zero when the root table is
- being filled, and drop is root when sub-tables are being filled.
-
- When a new sub-table is needed, it is necessary to look ahead in the
- code lengths to determine what size sub-table is needed. The length
- counts are used for this, and so count[] is decremented as codes are
- entered in the tables.
-
- used keeps track of how many table entries have been allocated from the
- provided *table space. It is checked when a LENS table is being made
- against the space in *table, ENOUGH, minus the maximum space needed by
- the worst case distance code, MAXD. This should never happen, but the
- sufficiency of ENOUGH has not been proven exhaustively, hence the check.
- This assumes that when type == LENS, bits == 9.
-
- sym increments through all symbols, and the loop terminates when
- all codes of length max, i.e. all codes, have been processed. This
- routine permits incomplete codes, so another loop after this one fills
- in the rest of the decoding tables with invalid code markers.
- */
-
- /* set up for code type */
- switch (type) {
- case CODES:
- base = extra = work; /* dummy value--not used */
- end = 19;
- break;
- case LENS:
- base = lbase;
- base -= 257;
- extra = lext;
- extra -= 257;
- end = 256;
- break;
- default: /* DISTS */
- base = dbase;
- extra = dext;
- end = -1;
- }
-
- /* initialize state for loop */
- huff = 0; /* starting code */
- sym = 0; /* starting code symbol */
- len = min; /* starting code length */
- next = *table; /* current table to fill in */
- curr = root; /* current table index bits */
- drop = 0; /* current bits to drop from code for index */
- low = (unsigned)(-1); /* trigger new sub-table when len > root */
- used = 1U << root; /* use root table entries */
- mask = used - 1; /* mask for comparing low */
-
- /* check available table space */
- if (type == LENS && used >= ENOUGH - MAXD)
- return 1;
-
- /* process all codes and make table entries */
- for (;;) {
- /* create table entry */
- this.bits = (unsigned char)(len - drop);
- if ((int)(work[sym]) < end) {
- this.op = (unsigned char)0;
- this.val = work[sym];
- }
- else if ((int)(work[sym]) > end) {
- this.op = (unsigned char)(extra[work[sym]]);
- this.val = base[work[sym]];
- }
- else {
- this.op = (unsigned char)(32 + 64); /* end of block */
- this.val = 0;
- }
-
- /* replicate for those indices with low len bits equal to huff */
- incr = 1U << (len - drop);
- fill = 1U << curr;
- do {
- fill -= incr;
- next[(huff >> drop) + fill] = this;
- } while (fill != 0);
-
- /* backwards increment the len-bit code huff */
- incr = 1U << (len - 1);
- while (huff & incr)
- incr >>= 1;
- if (incr != 0) {
- huff &= incr - 1;
- huff += incr;
- }
- else
- huff = 0;
-
- /* go to next symbol, update count, len */
- sym++;
- if (--(count[len]) == 0) {
- if (len == max) break;
- len = lens[work[sym]];
- }
-
- /* create new sub-table if needed */
- if (len > root && (huff & mask) != low) {
- /* if first time, transition to sub-tables */
- if (drop == 0)
- drop = root;
-
- /* increment past last table */
- next += 1U << curr;
-
- /* determine length of next table */
- curr = len - drop;
- left = (int)(1 << curr);
- while (curr + drop < max) {
- left -= count[curr + drop];
- if (left <= 0) break;
- curr++;
- left <<= 1;
- }
-
- /* check for enough space */
- used += 1U << curr;
- if (type == LENS && used >= ENOUGH - MAXD)
- return 1;
-
- /* point entry in root table to sub-table */
- low = huff & mask;
- (*table)[low].op = (unsigned char)curr;
- (*table)[low].bits = (unsigned char)root;
- (*table)[low].val = (unsigned short)(next - *table);
- }
- }
-
- /*
- Fill in rest of table for incomplete codes. This loop is similar to the
- loop above in incrementing huff for table indices. It is assumed that
- len is equal to curr + drop, so there is no loop needed to increment
- through high index bits. When the current sub-table is filled, the loop
- drops back to the root table to fill in any remaining entries there.
- */
- this.op = (unsigned char)64; /* invalid code marker */
- this.bits = (unsigned char)(len - drop);
- this.val = (unsigned short)0;
- while (huff != 0) {
- /* when done with sub-table, drop back to root table */
- if (drop != 0 && (huff & mask) != low) {
- drop = 0;
- len = root;
- next = *table;
- curr = root;
- this.bits = (unsigned char)len;
- }
-
- /* put invalid code marker in table */
- next[huff >> drop] = this;
-
- /* backwards increment the len-bit code huff */
- incr = 1U << (len - 1);
- while (huff & incr)
- incr >>= 1;
- if (incr != 0) {
- huff &= incr - 1;
- huff += incr;
- }
- else
- huff = 0;
- }
-
- /* set return parameters */
- *table += used;
- *bits = root;
- return 0;
-}
diff --git a/source4/lib/zlib/contrib/infback9/inftree9.h b/source4/lib/zlib/contrib/infback9/inftree9.h
deleted file mode 100644
index a268084eea..0000000000
--- a/source4/lib/zlib/contrib/infback9/inftree9.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* inftree9.h -- header to use inftree9.c
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* Structure for decoding tables. Each entry provides either the
- information needed to do the operation requested by the code that
- indexed that table entry, or it provides a pointer to another
- table that indexes more bits of the code. op indicates whether
- the entry is a pointer to another table, a literal, a length or
- distance, an end-of-block, or an invalid code. For a table
- pointer, the low four bits of op is the number of index bits of
- that table. For a length or distance, the low four bits of op
- is the number of extra bits to get after the code. bits is
- the number of bits in this code or part of the code to drop off
- of the bit buffer. val is the actual byte to output in the case
- of a literal, the base length or distance, or the offset from
- the current table to the next table. Each entry is four bytes. */
-typedef struct {
- unsigned char op; /* operation, extra bits, table bits */
- unsigned char bits; /* bits in this part of the code */
- unsigned short val; /* offset in table or code value */
-} code;
-
-/* op values as set by inflate_table():
- 00000000 - literal
- 0000tttt - table link, tttt != 0 is the number of table index bits
- 100eeeee - length or distance, eeee is the number of extra bits
- 01100000 - end of block
- 01000000 - invalid code
- */
-
-/* Maximum size of dynamic tree. The maximum found in a long but non-
- exhaustive search was 1444 code structures (852 for length/literals
- and 592 for distances, the latter actually the result of an
- exhaustive search). The true maximum is not known, but the value
- below is more than safe. */
-#define ENOUGH 2048
-#define MAXD 592
-
-/* Type of code to build for inftable() */
-typedef enum {
- CODES,
- LENS,
- DISTS
-} codetype;
-
-extern int inflate_table9 OF((codetype type, unsigned short FAR *lens,
- unsigned codes, code FAR * FAR *table,
- unsigned FAR *bits, unsigned short FAR *work));
diff --git a/source4/lib/zlib/contrib/inflate86/inffas86.c b/source4/lib/zlib/contrib/inflate86/inffas86.c
deleted file mode 100644
index 6da76358cc..0000000000
--- a/source4/lib/zlib/contrib/inflate86/inffas86.c
+++ /dev/null
@@ -1,1157 +0,0 @@
-/* inffas86.c is a hand tuned assembler version of
- *
- * inffast.c -- fast decoding
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- *
- * Copyright (C) 2003 Chris Anderson <christop@charm.net>
- * Please use the copyright conditions above.
- *
- * Dec-29-2003 -- I added AMD64 inflate asm support. This version is also
- * slightly quicker on x86 systems because, instead of using rep movsb to copy
- * data, it uses rep movsw, which moves data in 2-byte chunks instead of single
- * bytes. I've tested the AMD64 code on a Fedora Core 1 + the x86_64 updates
- * from http://fedora.linux.duke.edu/fc1_x86_64
- * which is running on an Athlon 64 3000+ / Gigabyte GA-K8VT800M system with
- * 1GB ram. The 64-bit version is about 4% faster than the 32-bit version,
- * when decompressing mozilla-source-1.3.tar.gz.
- *
- * Mar-13-2003 -- Most of this is derived from inffast.S which is derived from
- * the gcc -S output of zlib-1.2.0/inffast.c. Zlib-1.2.0 is in beta release at
- * the moment. I have successfully compiled and tested this code with gcc2.96,
- * gcc3.2, icc5.0, msvc6.0. It is very close to the speed of inffast.S
- * compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX
- * enabled. I will attempt to merge the MMX code into this version. Newer
- * versions of this and inffast.S can be found at
- * http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-/* Mark Adler's comments from inffast.c: */
-
-/*
- Decode literal, length, and distance codes and write out the resulting
- literal and match bytes until either not enough input or output is
- available, an end-of-block is encountered, or a data error is encountered.
- When large enough input and output buffers are supplied to inflate(), for
- example, a 16K input buffer and a 64K output buffer, more than 95% of the
- inflate execution time is spent in this routine.
-
- Entry assumptions:
-
- state->mode == LEN
- strm->avail_in >= 6
- strm->avail_out >= 258
- start >= strm->avail_out
- state->bits < 8
-
- On return, state->mode is one of:
-
- LEN -- ran out of enough output space or enough available input
- TYPE -- reached end of block code, inflate() to interpret next block
- BAD -- error in block data
-
- Notes:
-
- - The maximum input bits used by a length/distance pair is 15 bits for the
- length code, 5 bits for the length extra, 15 bits for the distance code,
- and 13 bits for the distance extra. This totals 48 bits, or six bytes.
- Therefore if strm->avail_in >= 6, then there is enough input to avoid
- checking for available input while decoding.
-
- - The maximum bytes that a single length/distance pair can output is 258
- bytes, which is the maximum length that can be coded. inflate_fast()
- requires strm->avail_out >= 258 for each loop to avoid checking for
- output space.
- */
-void inflate_fast(strm, start)
-z_streamp strm;
-unsigned start; /* inflate()'s starting value for strm->avail_out */
-{
- struct inflate_state FAR *state;
- struct inffast_ar {
-/* 64 32 x86 x86_64 */
-/* ar offset register */
-/* 0 0 */ void *esp; /* esp save */
-/* 8 4 */ void *ebp; /* ebp save */
-/* 16 8 */ unsigned char FAR *in; /* esi rsi local strm->next_in */
-/* 24 12 */ unsigned char FAR *last; /* r9 while in < last */
-/* 32 16 */ unsigned char FAR *out; /* edi rdi local strm->next_out */
-/* 40 20 */ unsigned char FAR *beg; /* inflate()'s init next_out */
-/* 48 24 */ unsigned char FAR *end; /* r10 while out < end */
-/* 56 28 */ unsigned char FAR *window;/* size of window, wsize!=0 */
-/* 64 32 */ code const FAR *lcode; /* ebp rbp local strm->lencode */
-/* 72 36 */ code const FAR *dcode; /* r11 local strm->distcode */
-/* 80 40 */ unsigned long hold; /* edx rdx local strm->hold */
-/* 88 44 */ unsigned bits; /* ebx rbx local strm->bits */
-/* 92 48 */ unsigned wsize; /* window size */
-/* 96 52 */ unsigned write; /* window write index */
-/*100 56 */ unsigned lmask; /* r12 mask for lcode */
-/*104 60 */ unsigned dmask; /* r13 mask for dcode */
-/*108 64 */ unsigned len; /* r14 match length */
-/*112 68 */ unsigned dist; /* r15 match distance */
-/*116 72 */ unsigned status; /* set when state chng*/
- } ar;
-
-#if defined( __GNUC__ ) && defined( __amd64__ ) && ! defined( __i386 )
-#define PAD_AVAIL_IN 6
-#define PAD_AVAIL_OUT 258
-#else
-#define PAD_AVAIL_IN 5
-#define PAD_AVAIL_OUT 257
-#endif
-
- /* copy state to local variables */
- state = (struct inflate_state FAR *)strm->state;
- ar.in = strm->next_in;
- ar.last = ar.in + (strm->avail_in - PAD_AVAIL_IN);
- ar.out = strm->next_out;
- ar.beg = ar.out - (start - strm->avail_out);
- ar.end = ar.out + (strm->avail_out - PAD_AVAIL_OUT);
- ar.wsize = state->wsize;
- ar.write = state->write;
- ar.window = state->window;
- ar.hold = state->hold;
- ar.bits = state->bits;
- ar.lcode = state->lencode;
- ar.dcode = state->distcode;
- ar.lmask = (1U << state->lenbits) - 1;
- ar.dmask = (1U << state->distbits) - 1;
-
- /* decode literals and length/distances until end-of-block or not enough
- input data or output space */
-
- /* align in on 1/2 hold size boundary */
- while (((unsigned long)(void *)ar.in & (sizeof(ar.hold) / 2 - 1)) != 0) {
- ar.hold += (unsigned long)*ar.in++ << ar.bits;
- ar.bits += 8;
- }
-
-#if defined( __GNUC__ ) && defined( __amd64__ ) && ! defined( __i386 )
- __asm__ __volatile__ (
-" leaq %0, %%rax\n"
-" movq %%rbp, 8(%%rax)\n" /* save regs rbp and rsp */
-" movq %%rsp, (%%rax)\n"
-" movq %%rax, %%rsp\n" /* make rsp point to &ar */
-" movq 16(%%rsp), %%rsi\n" /* rsi = in */
-" movq 32(%%rsp), %%rdi\n" /* rdi = out */
-" movq 24(%%rsp), %%r9\n" /* r9 = last */
-" movq 48(%%rsp), %%r10\n" /* r10 = end */
-" movq 64(%%rsp), %%rbp\n" /* rbp = lcode */
-" movq 72(%%rsp), %%r11\n" /* r11 = dcode */
-" movq 80(%%rsp), %%rdx\n" /* rdx = hold */
-" movl 88(%%rsp), %%ebx\n" /* ebx = bits */
-" movl 100(%%rsp), %%r12d\n" /* r12d = lmask */
-" movl 104(%%rsp), %%r13d\n" /* r13d = dmask */
- /* r14d = len */
- /* r15d = dist */
-" cld\n"
-" cmpq %%rdi, %%r10\n"
-" je .L_one_time\n" /* if only one decode left */
-" cmpq %%rsi, %%r9\n"
-" je .L_one_time\n"
-" jmp .L_do_loop\n"
-
-".L_one_time:\n"
-" movq %%r12, %%r8\n" /* r8 = lmask */
-" cmpb $32, %%bl\n"
-" ja .L_get_length_code_one_time\n"
-
-" lodsl\n" /* eax = *(uint *)in++ */
-" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */
-" addb $32, %%bl\n" /* bits += 32 */
-" shlq %%cl, %%rax\n"
-" orq %%rax, %%rdx\n" /* hold |= *((uint *)in)++ << bits */
-" jmp .L_get_length_code_one_time\n"
-
-".align 32,0x90\n"
-".L_while_test:\n"
-" cmpq %%rdi, %%r10\n"
-" jbe .L_break_loop\n"
-" cmpq %%rsi, %%r9\n"
-" jbe .L_break_loop\n"
-
-".L_do_loop:\n"
-" movq %%r12, %%r8\n" /* r8 = lmask */
-" cmpb $32, %%bl\n"
-" ja .L_get_length_code\n" /* if (32 < bits) */
-
-" lodsl\n" /* eax = *(uint *)in++ */
-" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */
-" addb $32, %%bl\n" /* bits += 32 */
-" shlq %%cl, %%rax\n"
-" orq %%rax, %%rdx\n" /* hold |= *((uint *)in)++ << bits */
-
-".L_get_length_code:\n"
-" andq %%rdx, %%r8\n" /* r8 &= hold */
-" movl (%%rbp,%%r8,4), %%eax\n" /* eax = lcode[hold & lmask] */
-
-" movb %%ah, %%cl\n" /* cl = this.bits */
-" subb %%ah, %%bl\n" /* bits -= this.bits */
-" shrq %%cl, %%rdx\n" /* hold >>= this.bits */
-
-" testb %%al, %%al\n"
-" jnz .L_test_for_length_base\n" /* if (op != 0) 45.7% */
-
-" movq %%r12, %%r8\n" /* r8 = lmask */
-" shrl $16, %%eax\n" /* output this.val char */
-" stosb\n"
-
-".L_get_length_code_one_time:\n"
-" andq %%rdx, %%r8\n" /* r8 &= hold */
-" movl (%%rbp,%%r8,4), %%eax\n" /* eax = lcode[hold & lmask] */
-
-".L_dolen:\n"
-" movb %%ah, %%cl\n" /* cl = this.bits */
-" subb %%ah, %%bl\n" /* bits -= this.bits */
-" shrq %%cl, %%rdx\n" /* hold >>= this.bits */
-
-" testb %%al, %%al\n"
-" jnz .L_test_for_length_base\n" /* if (op != 0) 45.7% */
-
-" shrl $16, %%eax\n" /* output this.val char */
-" stosb\n"
-" jmp .L_while_test\n"
-
-".align 32,0x90\n"
-".L_test_for_length_base:\n"
-" movl %%eax, %%r14d\n" /* len = this */
-" shrl $16, %%r14d\n" /* len = this.val */
-" movb %%al, %%cl\n"
-
-" testb $16, %%al\n"
-" jz .L_test_for_second_level_length\n" /* if ((op & 16) == 0) 8% */
-" andb $15, %%cl\n" /* op &= 15 */
-" jz .L_decode_distance\n" /* if (!op) */
-
-".L_add_bits_to_len:\n"
-" subb %%cl, %%bl\n"
-" xorl %%eax, %%eax\n"
-" incl %%eax\n"
-" shll %%cl, %%eax\n"
-" decl %%eax\n"
-" andl %%edx, %%eax\n" /* eax &= hold */
-" shrq %%cl, %%rdx\n"
-" addl %%eax, %%r14d\n" /* len += hold & mask[op] */
-
-".L_decode_distance:\n"
-" movq %%r13, %%r8\n" /* r8 = dmask */
-" cmpb $32, %%bl\n"
-" ja .L_get_distance_code\n" /* if (32 < bits) */
-
-" lodsl\n" /* eax = *(uint *)in++ */
-" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */
-" addb $32, %%bl\n" /* bits += 32 */
-" shlq %%cl, %%rax\n"
-" orq %%rax, %%rdx\n" /* hold |= *((uint *)in)++ << bits */
-
-".L_get_distance_code:\n"
-" andq %%rdx, %%r8\n" /* r8 &= hold */
-" movl (%%r11,%%r8,4), %%eax\n" /* eax = dcode[hold & dmask] */
-
-".L_dodist:\n"
-" movl %%eax, %%r15d\n" /* dist = this */
-" shrl $16, %%r15d\n" /* dist = this.val */
-" movb %%ah, %%cl\n"
-" subb %%ah, %%bl\n" /* bits -= this.bits */
-" shrq %%cl, %%rdx\n" /* hold >>= this.bits */
-" movb %%al, %%cl\n" /* cl = this.op */
-
-" testb $16, %%al\n" /* if ((op & 16) == 0) */
-" jz .L_test_for_second_level_dist\n"
-" andb $15, %%cl\n" /* op &= 15 */
-" jz .L_check_dist_one\n"
-
-".L_add_bits_to_dist:\n"
-" subb %%cl, %%bl\n"
-" xorl %%eax, %%eax\n"
-" incl %%eax\n"
-" shll %%cl, %%eax\n"
-" decl %%eax\n" /* (1 << op) - 1 */
-" andl %%edx, %%eax\n" /* eax &= hold */
-" shrq %%cl, %%rdx\n"
-" addl %%eax, %%r15d\n" /* dist += hold & ((1 << op) - 1) */
-
-".L_check_window:\n"
-" movq %%rsi, %%r8\n" /* save in so from can use it's reg */
-" movq %%rdi, %%rax\n"
-" subq 40(%%rsp), %%rax\n" /* nbytes = out - beg */
-
-" cmpl %%r15d, %%eax\n"
-" jb .L_clip_window\n" /* if (dist > nbytes) 4.2% */
-
-" movl %%r14d, %%ecx\n" /* ecx = len */
-" movq %%rdi, %%rsi\n"
-" subq %%r15, %%rsi\n" /* from = out - dist */
-
-" sarl %%ecx\n"
-" jnc .L_copy_two\n" /* if len % 2 == 0 */
-
-" rep movsw\n"
-" movb (%%rsi), %%al\n"
-" movb %%al, (%%rdi)\n"
-" incq %%rdi\n"
-
-" movq %%r8, %%rsi\n" /* move in back to %rsi, toss from */
-" jmp .L_while_test\n"
-
-".L_copy_two:\n"
-" rep movsw\n"
-" movq %%r8, %%rsi\n" /* move in back to %rsi, toss from */
-" jmp .L_while_test\n"
-
-".align 32,0x90\n"
-".L_check_dist_one:\n"
-" cmpl $1, %%r15d\n" /* if dist 1, is a memset */
-" jne .L_check_window\n"
-" cmpq %%rdi, 40(%%rsp)\n" /* if out == beg, outside window */
-" je .L_check_window\n"
-
-" movl %%r14d, %%ecx\n" /* ecx = len */
-" movb -1(%%rdi), %%al\n"
-" movb %%al, %%ah\n"
-
-" sarl %%ecx\n"
-" jnc .L_set_two\n"
-" movb %%al, (%%rdi)\n"
-" incq %%rdi\n"
-
-".L_set_two:\n"
-" rep stosw\n"
-" jmp .L_while_test\n"
-
-".align 32,0x90\n"
-".L_test_for_second_level_length:\n"
-" testb $64, %%al\n"
-" jnz .L_test_for_end_of_block\n" /* if ((op & 64) != 0) */
-
-" xorl %%eax, %%eax\n"
-" incl %%eax\n"
-" shll %%cl, %%eax\n"
-" decl %%eax\n"
-" andl %%edx, %%eax\n" /* eax &= hold */
-" addl %%r14d, %%eax\n" /* eax += len */
-" movl (%%rbp,%%rax,4), %%eax\n" /* eax = lcode[val+(hold&mask[op])]*/
-" jmp .L_dolen\n"
-
-".align 32,0x90\n"
-".L_test_for_second_level_dist:\n"
-" testb $64, %%al\n"
-" jnz .L_invalid_distance_code\n" /* if ((op & 64) != 0) */
-
-" xorl %%eax, %%eax\n"
-" incl %%eax\n"
-" shll %%cl, %%eax\n"
-" decl %%eax\n"
-" andl %%edx, %%eax\n" /* eax &= hold */
-" addl %%r15d, %%eax\n" /* eax += dist */
-" movl (%%r11,%%rax,4), %%eax\n" /* eax = dcode[val+(hold&mask[op])]*/
-" jmp .L_dodist\n"
-
-".align 32,0x90\n"
-".L_clip_window:\n"
-" movl %%eax, %%ecx\n" /* ecx = nbytes */
-" movl 92(%%rsp), %%eax\n" /* eax = wsize, prepare for dist cmp */
-" negl %%ecx\n" /* nbytes = -nbytes */
-
-" cmpl %%r15d, %%eax\n"
-" jb .L_invalid_distance_too_far\n" /* if (dist > wsize) */
-
-" addl %%r15d, %%ecx\n" /* nbytes = dist - nbytes */
-" cmpl $0, 96(%%rsp)\n"
-" jne .L_wrap_around_window\n" /* if (write != 0) */
-
-" movq 56(%%rsp), %%rsi\n" /* from = window */
-" subl %%ecx, %%eax\n" /* eax -= nbytes */
-" addq %%rax, %%rsi\n" /* from += wsize - nbytes */
-
-" movl %%r14d, %%eax\n" /* eax = len */
-" cmpl %%ecx, %%r14d\n"
-" jbe .L_do_copy\n" /* if (nbytes >= len) */
-
-" subl %%ecx, %%eax\n" /* eax -= nbytes */
-" rep movsb\n"
-" movq %%rdi, %%rsi\n"
-" subq %%r15, %%rsi\n" /* from = &out[ -dist ] */
-" jmp .L_do_copy\n"
-
-".align 32,0x90\n"
-".L_wrap_around_window:\n"
-" movl 96(%%rsp), %%eax\n" /* eax = write */
-" cmpl %%eax, %%ecx\n"
-" jbe .L_contiguous_in_window\n" /* if (write >= nbytes) */
-
-" movl 92(%%rsp), %%esi\n" /* from = wsize */
-" addq 56(%%rsp), %%rsi\n" /* from += window */
-" addq %%rax, %%rsi\n" /* from += write */
-" subq %%rcx, %%rsi\n" /* from -= nbytes */
-" subl %%eax, %%ecx\n" /* nbytes -= write */
-
-" movl %%r14d, %%eax\n" /* eax = len */
-" cmpl %%ecx, %%eax\n"
-" jbe .L_do_copy\n" /* if (nbytes >= len) */
-
-" subl %%ecx, %%eax\n" /* len -= nbytes */
-" rep movsb\n"
-" movq 56(%%rsp), %%rsi\n" /* from = window */
-" movl 96(%%rsp), %%ecx\n" /* nbytes = write */
-" cmpl %%ecx, %%eax\n"
-" jbe .L_do_copy\n" /* if (nbytes >= len) */
-
-" subl %%ecx, %%eax\n" /* len -= nbytes */
-" rep movsb\n"
-" movq %%rdi, %%rsi\n"
-" subq %%r15, %%rsi\n" /* from = out - dist */
-" jmp .L_do_copy\n"
-
-".align 32,0x90\n"
-".L_contiguous_in_window:\n"
-" movq 56(%%rsp), %%rsi\n" /* rsi = window */
-" addq %%rax, %%rsi\n"
-" subq %%rcx, %%rsi\n" /* from += write - nbytes */
-
-" movl %%r14d, %%eax\n" /* eax = len */
-" cmpl %%ecx, %%eax\n"
-" jbe .L_do_copy\n" /* if (nbytes >= len) */
-
-" subl %%ecx, %%eax\n" /* len -= nbytes */
-" rep movsb\n"
-" movq %%rdi, %%rsi\n"
-" subq %%r15, %%rsi\n" /* from = out - dist */
-" jmp .L_do_copy\n" /* if (nbytes >= len) */
-
-".align 32,0x90\n"
-".L_do_copy:\n"
-" movl %%eax, %%ecx\n" /* ecx = len */
-" rep movsb\n"
-
-" movq %%r8, %%rsi\n" /* move in back to %esi, toss from */
-" jmp .L_while_test\n"
-
-".L_test_for_end_of_block:\n"
-" testb $32, %%al\n"
-" jz .L_invalid_literal_length_code\n"
-" movl $1, 116(%%rsp)\n"
-" jmp .L_break_loop_with_status\n"
-
-".L_invalid_literal_length_code:\n"
-" movl $2, 116(%%rsp)\n"
-" jmp .L_break_loop_with_status\n"
-
-".L_invalid_distance_code:\n"
-" movl $3, 116(%%rsp)\n"
-" jmp .L_break_loop_with_status\n"
-
-".L_invalid_distance_too_far:\n"
-" movl $4, 116(%%rsp)\n"
-" jmp .L_break_loop_with_status\n"
-
-".L_break_loop:\n"
-" movl $0, 116(%%rsp)\n"
-
-".L_break_loop_with_status:\n"
-/* put in, out, bits, and hold back into ar and pop esp */
-" movq %%rsi, 16(%%rsp)\n" /* in */
-" movq %%rdi, 32(%%rsp)\n" /* out */
-" movl %%ebx, 88(%%rsp)\n" /* bits */
-" movq %%rdx, 80(%%rsp)\n" /* hold */
-" movq (%%rsp), %%rax\n" /* restore rbp and rsp */
-" movq 8(%%rsp), %%rbp\n"
-" movq %%rax, %%rsp\n"
- :
- : "m" (ar)
- : "memory", "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi",
- "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
- );
-#elif ( defined( __GNUC__ ) || defined( __ICC ) ) && defined( __i386 )
- __asm__ __volatile__ (
-" leal %0, %%eax\n"
-" movl %%esp, (%%eax)\n" /* save esp, ebp */
-" movl %%ebp, 4(%%eax)\n"
-" movl %%eax, %%esp\n"
-" movl 8(%%esp), %%esi\n" /* esi = in */
-" movl 16(%%esp), %%edi\n" /* edi = out */
-" movl 40(%%esp), %%edx\n" /* edx = hold */
-" movl 44(%%esp), %%ebx\n" /* ebx = bits */
-" movl 32(%%esp), %%ebp\n" /* ebp = lcode */
-
-" cld\n"
-" jmp .L_do_loop\n"
-
-".align 32,0x90\n"
-".L_while_test:\n"
-" cmpl %%edi, 24(%%esp)\n" /* out < end */
-" jbe .L_break_loop\n"
-" cmpl %%esi, 12(%%esp)\n" /* in < last */
-" jbe .L_break_loop\n"
-
-".L_do_loop:\n"
-" cmpb $15, %%bl\n"
-" ja .L_get_length_code\n" /* if (15 < bits) */
-
-" xorl %%eax, %%eax\n"
-" lodsw\n" /* al = *(ushort *)in++ */
-" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */
-" addb $16, %%bl\n" /* bits += 16 */
-" shll %%cl, %%eax\n"
-" orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */
-
-".L_get_length_code:\n"
-" movl 56(%%esp), %%eax\n" /* eax = lmask */
-" andl %%edx, %%eax\n" /* eax &= hold */
-" movl (%%ebp,%%eax,4), %%eax\n" /* eax = lcode[hold & lmask] */
-
-".L_dolen:\n"
-" movb %%ah, %%cl\n" /* cl = this.bits */
-" subb %%ah, %%bl\n" /* bits -= this.bits */
-" shrl %%cl, %%edx\n" /* hold >>= this.bits */
-
-" testb %%al, %%al\n"
-" jnz .L_test_for_length_base\n" /* if (op != 0) 45.7% */
-
-" shrl $16, %%eax\n" /* output this.val char */
-" stosb\n"
-" jmp .L_while_test\n"
-
-".align 32,0x90\n"
-".L_test_for_length_base:\n"
-" movl %%eax, %%ecx\n" /* len = this */
-" shrl $16, %%ecx\n" /* len = this.val */
-" movl %%ecx, 64(%%esp)\n" /* save len */
-" movb %%al, %%cl\n"
-
-" testb $16, %%al\n"
-" jz .L_test_for_second_level_length\n" /* if ((op & 16) == 0) 8% */
-" andb $15, %%cl\n" /* op &= 15 */
-" jz .L_decode_distance\n" /* if (!op) */
-" cmpb %%cl, %%bl\n"
-" jae .L_add_bits_to_len\n" /* if (op <= bits) */
-
-" movb %%cl, %%ch\n" /* stash op in ch, freeing cl */
-" xorl %%eax, %%eax\n"
-" lodsw\n" /* al = *(ushort *)in++ */
-" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */
-" addb $16, %%bl\n" /* bits += 16 */
-" shll %%cl, %%eax\n"
-" orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */
-" movb %%ch, %%cl\n" /* move op back to ecx */
-
-".L_add_bits_to_len:\n"
-" subb %%cl, %%bl\n"
-" xorl %%eax, %%eax\n"
-" incl %%eax\n"
-" shll %%cl, %%eax\n"
-" decl %%eax\n"
-" andl %%edx, %%eax\n" /* eax &= hold */
-" shrl %%cl, %%edx\n"
-" addl %%eax, 64(%%esp)\n" /* len += hold & mask[op] */
-
-".L_decode_distance:\n"
-" cmpb $15, %%bl\n"
-" ja .L_get_distance_code\n" /* if (15 < bits) */
-
-" xorl %%eax, %%eax\n"
-" lodsw\n" /* al = *(ushort *)in++ */
-" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */
-" addb $16, %%bl\n" /* bits += 16 */
-" shll %%cl, %%eax\n"
-" orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */
-
-".L_get_distance_code:\n"
-" movl 60(%%esp), %%eax\n" /* eax = dmask */
-" movl 36(%%esp), %%ecx\n" /* ecx = dcode */
-" andl %%edx, %%eax\n" /* eax &= hold */
-" movl (%%ecx,%%eax,4), %%eax\n"/* eax = dcode[hold & dmask] */
-
-".L_dodist:\n"
-" movl %%eax, %%ebp\n" /* dist = this */
-" shrl $16, %%ebp\n" /* dist = this.val */
-" movb %%ah, %%cl\n"
-" subb %%ah, %%bl\n" /* bits -= this.bits */
-" shrl %%cl, %%edx\n" /* hold >>= this.bits */
-" movb %%al, %%cl\n" /* cl = this.op */
-
-" testb $16, %%al\n" /* if ((op & 16) == 0) */
-" jz .L_test_for_second_level_dist\n"
-" andb $15, %%cl\n" /* op &= 15 */
-" jz .L_check_dist_one\n"
-" cmpb %%cl, %%bl\n"
-" jae .L_add_bits_to_dist\n" /* if (op <= bits) 97.6% */
-
-" movb %%cl, %%ch\n" /* stash op in ch, freeing cl */
-" xorl %%eax, %%eax\n"
-" lodsw\n" /* al = *(ushort *)in++ */
-" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */
-" addb $16, %%bl\n" /* bits += 16 */
-" shll %%cl, %%eax\n"
-" orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */
-" movb %%ch, %%cl\n" /* move op back to ecx */
-
-".L_add_bits_to_dist:\n"
-" subb %%cl, %%bl\n"
-" xorl %%eax, %%eax\n"
-" incl %%eax\n"
-" shll %%cl, %%eax\n"
-" decl %%eax\n" /* (1 << op) - 1 */
-" andl %%edx, %%eax\n" /* eax &= hold */
-" shrl %%cl, %%edx\n"
-" addl %%eax, %%ebp\n" /* dist += hold & ((1 << op) - 1) */
-
-".L_check_window:\n"
-" movl %%esi, 8(%%esp)\n" /* save in so from can use it's reg */
-" movl %%edi, %%eax\n"
-" subl 20(%%esp), %%eax\n" /* nbytes = out - beg */
-
-" cmpl %%ebp, %%eax\n"
-" jb .L_clip_window\n" /* if (dist > nbytes) 4.2% */
-
-" movl 64(%%esp), %%ecx\n" /* ecx = len */
-" movl %%edi, %%esi\n"
-" subl %%ebp, %%esi\n" /* from = out - dist */
-
-" sarl %%ecx\n"
-" jnc .L_copy_two\n" /* if len % 2 == 0 */
-
-" rep movsw\n"
-" movb (%%esi), %%al\n"
-" movb %%al, (%%edi)\n"
-" incl %%edi\n"
-
-" movl 8(%%esp), %%esi\n" /* move in back to %esi, toss from */
-" movl 32(%%esp), %%ebp\n" /* ebp = lcode */
-" jmp .L_while_test\n"
-
-".L_copy_two:\n"
-" rep movsw\n"
-" movl 8(%%esp), %%esi\n" /* move in back to %esi, toss from */
-" movl 32(%%esp), %%ebp\n" /* ebp = lcode */
-" jmp .L_while_test\n"
-
-".align 32,0x90\n"
-".L_check_dist_one:\n"
-" cmpl $1, %%ebp\n" /* if dist 1, is a memset */
-" jne .L_check_window\n"
-" cmpl %%edi, 20(%%esp)\n"
-" je .L_check_window\n" /* out == beg, if outside window */
-
-" movl 64(%%esp), %%ecx\n" /* ecx = len */
-" movb -1(%%edi), %%al\n"
-" movb %%al, %%ah\n"
-
-" sarl %%ecx\n"
-" jnc .L_set_two\n"
-" movb %%al, (%%edi)\n"
-" incl %%edi\n"
-
-".L_set_two:\n"
-" rep stosw\n"
-" movl 32(%%esp), %%ebp\n" /* ebp = lcode */
-" jmp .L_while_test\n"
-
-".align 32,0x90\n"
-".L_test_for_second_level_length:\n"
-" testb $64, %%al\n"
-" jnz .L_test_for_end_of_block\n" /* if ((op & 64) != 0) */
-
-" xorl %%eax, %%eax\n"
-" incl %%eax\n"
-" shll %%cl, %%eax\n"
-" decl %%eax\n"
-" andl %%edx, %%eax\n" /* eax &= hold */
-" addl 64(%%esp), %%eax\n" /* eax += len */
-" movl (%%ebp,%%eax,4), %%eax\n" /* eax = lcode[val+(hold&mask[op])]*/
-" jmp .L_dolen\n"
-
-".align 32,0x90\n"
-".L_test_for_second_level_dist:\n"
-" testb $64, %%al\n"
-" jnz .L_invalid_distance_code\n" /* if ((op & 64) != 0) */
-
-" xorl %%eax, %%eax\n"
-" incl %%eax\n"
-" shll %%cl, %%eax\n"
-" decl %%eax\n"
-" andl %%edx, %%eax\n" /* eax &= hold */
-" addl %%ebp, %%eax\n" /* eax += dist */
-" movl 36(%%esp), %%ecx\n" /* ecx = dcode */
-" movl (%%ecx,%%eax,4), %%eax\n" /* eax = dcode[val+(hold&mask[op])]*/
-" jmp .L_dodist\n"
-
-".align 32,0x90\n"
-".L_clip_window:\n"
-" movl %%eax, %%ecx\n"
-" movl 48(%%esp), %%eax\n" /* eax = wsize */
-" negl %%ecx\n" /* nbytes = -nbytes */
-" movl 28(%%esp), %%esi\n" /* from = window */
-
-" cmpl %%ebp, %%eax\n"
-" jb .L_invalid_distance_too_far\n" /* if (dist > wsize) */
-
-" addl %%ebp, %%ecx\n" /* nbytes = dist - nbytes */
-" cmpl $0, 52(%%esp)\n"
-" jne .L_wrap_around_window\n" /* if (write != 0) */
-
-" subl %%ecx, %%eax\n"
-" addl %%eax, %%esi\n" /* from += wsize - nbytes */
-
-" movl 64(%%esp), %%eax\n" /* eax = len */
-" cmpl %%ecx, %%eax\n"
-" jbe .L_do_copy\n" /* if (nbytes >= len) */
-
-" subl %%ecx, %%eax\n" /* len -= nbytes */
-" rep movsb\n"
-" movl %%edi, %%esi\n"
-" subl %%ebp, %%esi\n" /* from = out - dist */
-" jmp .L_do_copy\n"
-
-".align 32,0x90\n"
-".L_wrap_around_window:\n"
-" movl 52(%%esp), %%eax\n" /* eax = write */
-" cmpl %%eax, %%ecx\n"
-" jbe .L_contiguous_in_window\n" /* if (write >= nbytes) */
-
-" addl 48(%%esp), %%esi\n" /* from += wsize */
-" addl %%eax, %%esi\n" /* from += write */
-" subl %%ecx, %%esi\n" /* from -= nbytes */
-" subl %%eax, %%ecx\n" /* nbytes -= write */
-
-" movl 64(%%esp), %%eax\n" /* eax = len */
-" cmpl %%ecx, %%eax\n"
-" jbe .L_do_copy\n" /* if (nbytes >= len) */
-
-" subl %%ecx, %%eax\n" /* len -= nbytes */
-" rep movsb\n"
-" movl 28(%%esp), %%esi\n" /* from = window */
-" movl 52(%%esp), %%ecx\n" /* nbytes = write */
-" cmpl %%ecx, %%eax\n"
-" jbe .L_do_copy\n" /* if (nbytes >= len) */
-
-" subl %%ecx, %%eax\n" /* len -= nbytes */
-" rep movsb\n"
-" movl %%edi, %%esi\n"
-" subl %%ebp, %%esi\n" /* from = out - dist */
-" jmp .L_do_copy\n"
-
-".align 32,0x90\n"
-".L_contiguous_in_window:\n"
-" addl %%eax, %%esi\n"
-" subl %%ecx, %%esi\n" /* from += write - nbytes */
-
-" movl 64(%%esp), %%eax\n" /* eax = len */
-" cmpl %%ecx, %%eax\n"
-" jbe .L_do_copy\n" /* if (nbytes >= len) */
-
-" subl %%ecx, %%eax\n" /* len -= nbytes */
-" rep movsb\n"
-" movl %%edi, %%esi\n"
-" subl %%ebp, %%esi\n" /* from = out - dist */
-" jmp .L_do_copy\n" /* if (nbytes >= len) */
-
-".align 32,0x90\n"
-".L_do_copy:\n"
-" movl %%eax, %%ecx\n"
-" rep movsb\n"
-
-" movl 8(%%esp), %%esi\n" /* move in back to %esi, toss from */
-" movl 32(%%esp), %%ebp\n" /* ebp = lcode */
-" jmp .L_while_test\n"
-
-".L_test_for_end_of_block:\n"
-" testb $32, %%al\n"
-" jz .L_invalid_literal_length_code\n"
-" movl $1, 72(%%esp)\n"
-" jmp .L_break_loop_with_status\n"
-
-".L_invalid_literal_length_code:\n"
-" movl $2, 72(%%esp)\n"
-" jmp .L_break_loop_with_status\n"
-
-".L_invalid_distance_code:\n"
-" movl $3, 72(%%esp)\n"
-" jmp .L_break_loop_with_status\n"
-
-".L_invalid_distance_too_far:\n"
-" movl 8(%%esp), %%esi\n"
-" movl $4, 72(%%esp)\n"
-" jmp .L_break_loop_with_status\n"
-
-".L_break_loop:\n"
-" movl $0, 72(%%esp)\n"
-
-".L_break_loop_with_status:\n"
-/* put in, out, bits, and hold back into ar and pop esp */
-" movl %%esi, 8(%%esp)\n" /* save in */
-" movl %%edi, 16(%%esp)\n" /* save out */
-" movl %%ebx, 44(%%esp)\n" /* save bits */
-" movl %%edx, 40(%%esp)\n" /* save hold */
-" movl 4(%%esp), %%ebp\n" /* restore esp, ebp */
-" movl (%%esp), %%esp\n"
- :
- : "m" (ar)
- : "memory", "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi"
- );
-#elif defined( _MSC_VER ) && ! defined( _M_AMD64 )
- __asm {
- lea eax, ar
- mov [eax], esp /* save esp, ebp */
- mov [eax+4], ebp
- mov esp, eax
- mov esi, [esp+8] /* esi = in */
- mov edi, [esp+16] /* edi = out */
- mov edx, [esp+40] /* edx = hold */
- mov ebx, [esp+44] /* ebx = bits */
- mov ebp, [esp+32] /* ebp = lcode */
-
- cld
- jmp L_do_loop
-
-ALIGN 4
-L_while_test:
- cmp [esp+24], edi
- jbe L_break_loop
- cmp [esp+12], esi
- jbe L_break_loop
-
-L_do_loop:
- cmp bl, 15
- ja L_get_length_code /* if (15 < bits) */
-
- xor eax, eax
- lodsw /* al = *(ushort *)in++ */
- mov cl, bl /* cl = bits, needs it for shifting */
- add bl, 16 /* bits += 16 */
- shl eax, cl
- or edx, eax /* hold |= *((ushort *)in)++ << bits */
-
-L_get_length_code:
- mov eax, [esp+56] /* eax = lmask */
- and eax, edx /* eax &= hold */
- mov eax, [ebp+eax*4] /* eax = lcode[hold & lmask] */
-
-L_dolen:
- mov cl, ah /* cl = this.bits */
- sub bl, ah /* bits -= this.bits */
- shr edx, cl /* hold >>= this.bits */
-
- test al, al
- jnz L_test_for_length_base /* if (op != 0) 45.7% */
-
- shr eax, 16 /* output this.val char */
- stosb
- jmp L_while_test
-
-ALIGN 4
-L_test_for_length_base:
- mov ecx, eax /* len = this */
- shr ecx, 16 /* len = this.val */
- mov [esp+64], ecx /* save len */
- mov cl, al
-
- test al, 16
- jz L_test_for_second_level_length /* if ((op & 16) == 0) 8% */
- and cl, 15 /* op &= 15 */
- jz L_decode_distance /* if (!op) */
- cmp bl, cl
- jae L_add_bits_to_len /* if (op <= bits) */
-
- mov ch, cl /* stash op in ch, freeing cl */
- xor eax, eax
- lodsw /* al = *(ushort *)in++ */
- mov cl, bl /* cl = bits, needs it for shifting */
- add bl, 16 /* bits += 16 */
- shl eax, cl
- or edx, eax /* hold |= *((ushort *)in)++ << bits */
- mov cl, ch /* move op back to ecx */
-
-L_add_bits_to_len:
- sub bl, cl
- xor eax, eax
- inc eax
- shl eax, cl
- dec eax
- and eax, edx /* eax &= hold */
- shr edx, cl
- add [esp+64], eax /* len += hold & mask[op] */
-
-L_decode_distance:
- cmp bl, 15
- ja L_get_distance_code /* if (15 < bits) */
-
- xor eax, eax
- lodsw /* al = *(ushort *)in++ */
- mov cl, bl /* cl = bits, needs it for shifting */
- add bl, 16 /* bits += 16 */
- shl eax, cl
- or edx, eax /* hold |= *((ushort *)in)++ << bits */
-
-L_get_distance_code:
- mov eax, [esp+60] /* eax = dmask */
- mov ecx, [esp+36] /* ecx = dcode */
- and eax, edx /* eax &= hold */
- mov eax, [ecx+eax*4]/* eax = dcode[hold & dmask] */
-
-L_dodist:
- mov ebp, eax /* dist = this */
- shr ebp, 16 /* dist = this.val */
- mov cl, ah
- sub bl, ah /* bits -= this.bits */
- shr edx, cl /* hold >>= this.bits */
- mov cl, al /* cl = this.op */
-
- test al, 16 /* if ((op & 16) == 0) */
- jz L_test_for_second_level_dist
- and cl, 15 /* op &= 15 */
- jz L_check_dist_one
- cmp bl, cl
- jae L_add_bits_to_dist /* if (op <= bits) 97.6% */
-
- mov ch, cl /* stash op in ch, freeing cl */
- xor eax, eax
- lodsw /* al = *(ushort *)in++ */
- mov cl, bl /* cl = bits, needs it for shifting */
- add bl, 16 /* bits += 16 */
- shl eax, cl
- or edx, eax /* hold |= *((ushort *)in)++ << bits */
- mov cl, ch /* move op back to ecx */
-
-L_add_bits_to_dist:
- sub bl, cl
- xor eax, eax
- inc eax
- shl eax, cl
- dec eax /* (1 << op) - 1 */
- and eax, edx /* eax &= hold */
- shr edx, cl
- add ebp, eax /* dist += hold & ((1 << op) - 1) */
-
-L_check_window:
- mov [esp+8], esi /* save in so from can use it's reg */
- mov eax, edi
- sub eax, [esp+20] /* nbytes = out - beg */
-
- cmp eax, ebp
- jb L_clip_window /* if (dist > nbytes) 4.2% */
-
- mov ecx, [esp+64] /* ecx = len */
- mov esi, edi
- sub esi, ebp /* from = out - dist */
-
- sar ecx, 1
- jnc L_copy_two
-
- rep movsw
- mov al, [esi]
- mov [edi], al
- inc edi
-
- mov esi, [esp+8] /* move in back to %esi, toss from */
- mov ebp, [esp+32] /* ebp = lcode */
- jmp L_while_test
-
-L_copy_two:
- rep movsw
- mov esi, [esp+8] /* move in back to %esi, toss from */
- mov ebp, [esp+32] /* ebp = lcode */
- jmp L_while_test
-
-ALIGN 4
-L_check_dist_one:
- cmp ebp, 1 /* if dist 1, is a memset */
- jne L_check_window
- cmp [esp+20], edi
- je L_check_window /* out == beg, if outside window */
-
- mov ecx, [esp+64] /* ecx = len */
- mov al, [edi-1]
- mov ah, al
-
- sar ecx, 1
- jnc L_set_two
- mov [edi], al /* memset out with from[-1] */
- inc edi
-
-L_set_two:
- rep stosw
- mov ebp, [esp+32] /* ebp = lcode */
- jmp L_while_test
-
-ALIGN 4
-L_test_for_second_level_length:
- test al, 64
- jnz L_test_for_end_of_block /* if ((op & 64) != 0) */
-
- xor eax, eax
- inc eax
- shl eax, cl
- dec eax
- and eax, edx /* eax &= hold */
- add eax, [esp+64] /* eax += len */
- mov eax, [ebp+eax*4] /* eax = lcode[val+(hold&mask[op])]*/
- jmp L_dolen
-
-ALIGN 4
-L_test_for_second_level_dist:
- test al, 64
- jnz L_invalid_distance_code /* if ((op & 64) != 0) */
-
- xor eax, eax
- inc eax
- shl eax, cl
- dec eax
- and eax, edx /* eax &= hold */
- add eax, ebp /* eax += dist */
- mov ecx, [esp+36] /* ecx = dcode */
- mov eax, [ecx+eax*4] /* eax = dcode[val+(hold&mask[op])]*/
- jmp L_dodist
-
-ALIGN 4
-L_clip_window:
- mov ecx, eax
- mov eax, [esp+48] /* eax = wsize */
- neg ecx /* nbytes = -nbytes */
- mov esi, [esp+28] /* from = window */
-
- cmp eax, ebp
- jb L_invalid_distance_too_far /* if (dist > wsize) */
-
- add ecx, ebp /* nbytes = dist - nbytes */
- cmp dword ptr [esp+52], 0
- jne L_wrap_around_window /* if (write != 0) */
-
- sub eax, ecx
- add esi, eax /* from += wsize - nbytes */
-
- mov eax, [esp+64] /* eax = len */
- cmp eax, ecx
- jbe L_do_copy /* if (nbytes >= len) */
-
- sub eax, ecx /* len -= nbytes */
- rep movsb
- mov esi, edi
- sub esi, ebp /* from = out - dist */
- jmp L_do_copy
-
-ALIGN 4
-L_wrap_around_window:
- mov eax, [esp+52] /* eax = write */
- cmp ecx, eax
- jbe L_contiguous_in_window /* if (write >= nbytes) */
-
- add esi, [esp+48] /* from += wsize */
- add esi, eax /* from += write */
- sub esi, ecx /* from -= nbytes */
- sub ecx, eax /* nbytes -= write */
-
- mov eax, [esp+64] /* eax = len */
- cmp eax, ecx
- jbe L_do_copy /* if (nbytes >= len) */
-
- sub eax, ecx /* len -= nbytes */
- rep movsb
- mov esi, [esp+28] /* from = window */
- mov ecx, [esp+52] /* nbytes = write */
- cmp eax, ecx
- jbe L_do_copy /* if (nbytes >= len) */
-
- sub eax, ecx /* len -= nbytes */
- rep movsb
- mov esi, edi
- sub esi, ebp /* from = out - dist */
- jmp L_do_copy
-
-ALIGN 4
-L_contiguous_in_window:
- add esi, eax
- sub esi, ecx /* from += write - nbytes */
-
- mov eax, [esp+64] /* eax = len */
- cmp eax, ecx
- jbe L_do_copy /* if (nbytes >= len) */
-
- sub eax, ecx /* len -= nbytes */
- rep movsb
- mov esi, edi
- sub esi, ebp /* from = out - dist */
- jmp L_do_copy
-
-ALIGN 4
-L_do_copy:
- mov ecx, eax
- rep movsb
-
- mov esi, [esp+8] /* move in back to %esi, toss from */
- mov ebp, [esp+32] /* ebp = lcode */
- jmp L_while_test
-
-L_test_for_end_of_block:
- test al, 32
- jz L_invalid_literal_length_code
- mov dword ptr [esp+72], 1
- jmp L_break_loop_with_status
-
-L_invalid_literal_length_code:
- mov dword ptr [esp+72], 2
- jmp L_break_loop_with_status
-
-L_invalid_distance_code:
- mov dword ptr [esp+72], 3
- jmp L_break_loop_with_status
-
-L_invalid_distance_too_far:
- mov esi, [esp+4]
- mov dword ptr [esp+72], 4
- jmp L_break_loop_with_status
-
-L_break_loop:
- mov dword ptr [esp+72], 0
-
-L_break_loop_with_status:
-/* put in, out, bits, and hold back into ar and pop esp */
- mov [esp+8], esi /* save in */
- mov [esp+16], edi /* save out */
- mov [esp+44], ebx /* save bits */
- mov [esp+40], edx /* save hold */
- mov ebp, [esp+4] /* restore esp, ebp */
- mov esp, [esp]
- }
-#else
-#error "x86 architecture not defined"
-#endif
-
- if (ar.status > 1) {
- if (ar.status == 2)
- strm->msg = "invalid literal/length code";
- else if (ar.status == 3)
- strm->msg = "invalid distance code";
- else
- strm->msg = "invalid distance too far back";
- state->mode = BAD;
- }
- else if ( ar.status == 1 ) {
- state->mode = TYPE;
- }
-
- /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
- ar.len = ar.bits >> 3;
- ar.in -= ar.len;
- ar.bits -= ar.len << 3;
- ar.hold &= (1U << ar.bits) - 1;
-
- /* update state and return */
- strm->next_in = ar.in;
- strm->next_out = ar.out;
- strm->avail_in = (unsigned)(ar.in < ar.last ?
- PAD_AVAIL_IN + (ar.last - ar.in) :
- PAD_AVAIL_IN - (ar.in - ar.last));
- strm->avail_out = (unsigned)(ar.out < ar.end ?
- PAD_AVAIL_OUT + (ar.end - ar.out) :
- PAD_AVAIL_OUT - (ar.out - ar.end));
- state->hold = ar.hold;
- state->bits = ar.bits;
- return;
-}
-
diff --git a/source4/lib/zlib/contrib/inflate86/inffast.S b/source4/lib/zlib/contrib/inflate86/inffast.S
deleted file mode 100644
index 2245a2905b..0000000000
--- a/source4/lib/zlib/contrib/inflate86/inffast.S
+++ /dev/null
@@ -1,1368 +0,0 @@
-/*
- * inffast.S is a hand tuned assembler version of:
- *
- * inffast.c -- fast decoding
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- *
- * Copyright (C) 2003 Chris Anderson <christop@charm.net>
- * Please use the copyright conditions above.
- *
- * This version (Jan-23-2003) of inflate_fast was coded and tested under
- * GNU/Linux on a pentium 3, using the gcc-3.2 compiler distribution. On that
- * machine, I found that gzip style archives decompressed about 20% faster than
- * the gcc-3.2 -O3 -fomit-frame-pointer compiled version. Your results will
- * depend on how large of a buffer is used for z_stream.next_in & next_out
- * (8K-32K worked best for my 256K cpu cache) and how much overhead there is in
- * stream processing I/O and crc32/addler32. In my case, this routine used
- * 70% of the cpu time and crc32 used 20%.
- *
- * I am confident that this version will work in the general case, but I have
- * not tested a wide variety of datasets or a wide variety of platforms.
- *
- * Jan-24-2003 -- Added -DUSE_MMX define for slightly faster inflating.
- * It should be a runtime flag instead of compile time flag...
- *
- * Jan-26-2003 -- Added runtime check for MMX support with cpuid instruction.
- * With -DUSE_MMX, only MMX code is compiled. With -DNO_MMX, only non-MMX code
- * is compiled. Without either option, runtime detection is enabled. Runtime
- * detection should work on all modern cpus and the recomended algorithm (flip
- * ID bit on eflags and then use the cpuid instruction) is used in many
- * multimedia applications. Tested under win2k with gcc-2.95 and gas-2.12
- * distributed with cygwin3. Compiling with gcc-2.95 -c inffast.S -o
- * inffast.obj generates a COFF object which can then be linked with MSVC++
- * compiled code. Tested under FreeBSD 4.7 with gcc-2.95.
- *
- * Jan-28-2003 -- Tested Athlon XP... MMX mode is slower than no MMX (and
- * slower than compiler generated code). Adjusted cpuid check to use the MMX
- * code only for Pentiums < P4 until I have more data on the P4. Speed
- * improvment is only about 15% on the Athlon when compared with code generated
- * with MSVC++. Not sure yet, but I think the P4 will also be slower using the
- * MMX mode because many of it's x86 ALU instructions execute in .5 cycles and
- * have less latency than MMX ops. Added code to buffer the last 11 bytes of
- * the input stream since the MMX code grabs bits in chunks of 32, which
- * differs from the inffast.c algorithm. I don't think there would have been
- * read overruns where a page boundary was crossed (a segfault), but there
- * could have been overruns when next_in ends on unaligned memory (unintialized
- * memory read).
- *
- * Mar-13-2003 -- P4 MMX is slightly slower than P4 NO_MMX. I created a C
- * version of the non-MMX code so that it doesn't depend on zstrm and zstate
- * structure offsets which are hard coded in this file. This was last tested
- * with zlib-1.2.0 which is currently in beta testing, newer versions of this
- * and inffas86.c can be found at http://www.eetbeetee.com/zlib/ and
- * http://www.charm.net/~christop/zlib/
- */
-
-
-/*
- * if you have underscore linking problems (_inflate_fast undefined), try
- * using -DGAS_COFF
- */
-#if ! defined( GAS_COFF ) && ! defined( GAS_ELF )
-
-#if defined( WIN32 ) || defined( __CYGWIN__ )
-#define GAS_COFF /* windows object format */
-#else
-#define GAS_ELF
-#endif
-
-#endif /* ! GAS_COFF && ! GAS_ELF */
-
-
-#if defined( GAS_COFF )
-
-/* coff externals have underscores */
-#define inflate_fast _inflate_fast
-#define inflate_fast_use_mmx _inflate_fast_use_mmx
-
-#endif /* GAS_COFF */
-
-
-.file "inffast.S"
-
-.globl inflate_fast
-
-.text
-.align 4,0
-.L_invalid_literal_length_code_msg:
-.string "invalid literal/length code"
-
-.align 4,0
-.L_invalid_distance_code_msg:
-.string "invalid distance code"
-
-.align 4,0
-.L_invalid_distance_too_far_msg:
-.string "invalid distance too far back"
-
-#if ! defined( NO_MMX )
-.align 4,0
-.L_mask: /* mask[N] = ( 1 << N ) - 1 */
-.long 0
-.long 1
-.long 3
-.long 7
-.long 15
-.long 31
-.long 63
-.long 127
-.long 255
-.long 511
-.long 1023
-.long 2047
-.long 4095
-.long 8191
-.long 16383
-.long 32767
-.long 65535
-.long 131071
-.long 262143
-.long 524287
-.long 1048575
-.long 2097151
-.long 4194303
-.long 8388607
-.long 16777215
-.long 33554431
-.long 67108863
-.long 134217727
-.long 268435455
-.long 536870911
-.long 1073741823
-.long 2147483647
-.long 4294967295
-#endif /* NO_MMX */
-
-.text
-
-/*
- * struct z_stream offsets, in zlib.h
- */
-#define next_in_strm 0 /* strm->next_in */
-#define avail_in_strm 4 /* strm->avail_in */
-#define next_out_strm 12 /* strm->next_out */
-#define avail_out_strm 16 /* strm->avail_out */
-#define msg_strm 24 /* strm->msg */
-#define state_strm 28 /* strm->state */
-
-/*
- * struct inflate_state offsets, in inflate.h
- */
-#define mode_state 0 /* state->mode */
-#define wsize_state 32 /* state->wsize */
-#define write_state 40 /* state->write */
-#define window_state 44 /* state->window */
-#define hold_state 48 /* state->hold */
-#define bits_state 52 /* state->bits */
-#define lencode_state 68 /* state->lencode */
-#define distcode_state 72 /* state->distcode */
-#define lenbits_state 76 /* state->lenbits */
-#define distbits_state 80 /* state->distbits */
-
-/*
- * inflate_fast's activation record
- */
-#define local_var_size 64 /* how much local space for vars */
-#define strm_sp 88 /* first arg: z_stream * (local_var_size + 24) */
-#define start_sp 92 /* second arg: unsigned int (local_var_size + 28) */
-
-/*
- * offsets for local vars on stack
- */
-#define out 60 /* unsigned char* */
-#define window 56 /* unsigned char* */
-#define wsize 52 /* unsigned int */
-#define write 48 /* unsigned int */
-#define in 44 /* unsigned char* */
-#define beg 40 /* unsigned char* */
-#define buf 28 /* char[ 12 ] */
-#define len 24 /* unsigned int */
-#define last 20 /* unsigned char* */
-#define end 16 /* unsigned char* */
-#define dcode 12 /* code* */
-#define lcode 8 /* code* */
-#define dmask 4 /* unsigned int */
-#define lmask 0 /* unsigned int */
-
-/*
- * typedef enum inflate_mode consts, in inflate.h
- */
-#define INFLATE_MODE_TYPE 11 /* state->mode flags enum-ed in inflate.h */
-#define INFLATE_MODE_BAD 26
-
-
-#if ! defined( USE_MMX ) && ! defined( NO_MMX )
-
-#define RUN_TIME_MMX
-
-#define CHECK_MMX 1
-#define DO_USE_MMX 2
-#define DONT_USE_MMX 3
-
-.globl inflate_fast_use_mmx
-
-.data
-
-.align 4,0
-inflate_fast_use_mmx: /* integer flag for run time control 1=check,2=mmx,3=no */
-.long CHECK_MMX
-
-#if defined( GAS_ELF )
-/* elf info */
-.type inflate_fast_use_mmx,@object
-.size inflate_fast_use_mmx,4
-#endif
-
-#endif /* RUN_TIME_MMX */
-
-#if defined( GAS_COFF )
-/* coff info: scl 2 = extern, type 32 = function */
-.def inflate_fast; .scl 2; .type 32; .endef
-#endif
-
-.text
-
-.align 32,0x90
-inflate_fast:
- pushl %edi
- pushl %esi
- pushl %ebp
- pushl %ebx
- pushf /* save eflags (strm_sp, state_sp assumes this is 32 bits) */
- subl $local_var_size, %esp
- cld
-
-#define strm_r %esi
-#define state_r %edi
-
- movl strm_sp(%esp), strm_r
- movl state_strm(strm_r), state_r
-
- /* in = strm->next_in;
- * out = strm->next_out;
- * last = in + strm->avail_in - 11;
- * beg = out - (start - strm->avail_out);
- * end = out + (strm->avail_out - 257);
- */
- movl avail_in_strm(strm_r), %edx
- movl next_in_strm(strm_r), %eax
-
- addl %eax, %edx /* avail_in += next_in */
- subl $11, %edx /* avail_in -= 11 */
-
- movl %eax, in(%esp)
- movl %edx, last(%esp)
-
- movl start_sp(%esp), %ebp
- movl avail_out_strm(strm_r), %ecx
- movl next_out_strm(strm_r), %ebx
-
- subl %ecx, %ebp /* start -= avail_out */
- negl %ebp /* start = -start */
- addl %ebx, %ebp /* start += next_out */
-
- subl $257, %ecx /* avail_out -= 257 */
- addl %ebx, %ecx /* avail_out += out */
-
- movl %ebx, out(%esp)
- movl %ebp, beg(%esp)
- movl %ecx, end(%esp)
-
- /* wsize = state->wsize;
- * write = state->write;
- * window = state->window;
- * hold = state->hold;
- * bits = state->bits;
- * lcode = state->lencode;
- * dcode = state->distcode;
- * lmask = ( 1 << state->lenbits ) - 1;
- * dmask = ( 1 << state->distbits ) - 1;
- */
-
- movl lencode_state(state_r), %eax
- movl distcode_state(state_r), %ecx
-
- movl %eax, lcode(%esp)
- movl %ecx, dcode(%esp)
-
- movl $1, %eax
- movl lenbits_state(state_r), %ecx
- shll %cl, %eax
- decl %eax
- movl %eax, lmask(%esp)
-
- movl $1, %eax
- movl distbits_state(state_r), %ecx
- shll %cl, %eax
- decl %eax
- movl %eax, dmask(%esp)
-
- movl wsize_state(state_r), %eax
- movl write_state(state_r), %ecx
- movl window_state(state_r), %edx
-
- movl %eax, wsize(%esp)
- movl %ecx, write(%esp)
- movl %edx, window(%esp)
-
- movl hold_state(state_r), %ebp
- movl bits_state(state_r), %ebx
-
-#undef strm_r
-#undef state_r
-
-#define in_r %esi
-#define from_r %esi
-#define out_r %edi
-
- movl in(%esp), in_r
- movl last(%esp), %ecx
- cmpl in_r, %ecx
- ja .L_align_long /* if in < last */
-
- addl $11, %ecx /* ecx = &in[ avail_in ] */
- subl in_r, %ecx /* ecx = avail_in */
- movl $12, %eax
- subl %ecx, %eax /* eax = 12 - avail_in */
- leal buf(%esp), %edi
- rep movsb /* memcpy( buf, in, avail_in ) */
- movl %eax, %ecx
- xorl %eax, %eax
- rep stosb /* memset( &buf[ avail_in ], 0, 12 - avail_in ) */
- leal buf(%esp), in_r /* in = buf */
- movl in_r, last(%esp) /* last = in, do just one iteration */
- jmp .L_is_aligned
-
- /* align in_r on long boundary */
-.L_align_long:
- testl $3, in_r
- jz .L_is_aligned
- xorl %eax, %eax
- movb (in_r), %al
- incl in_r
- movl %ebx, %ecx
- addl $8, %ebx
- shll %cl, %eax
- orl %eax, %ebp
- jmp .L_align_long
-
-.L_is_aligned:
- movl out(%esp), out_r
-
-#if defined( NO_MMX )
- jmp .L_do_loop
-#endif
-
-#if defined( USE_MMX )
- jmp .L_init_mmx
-#endif
-
-/*** Runtime MMX check ***/
-
-#if defined( RUN_TIME_MMX )
-.L_check_mmx:
- cmpl $DO_USE_MMX, inflate_fast_use_mmx
- je .L_init_mmx
- ja .L_do_loop /* > 2 */
-
- pushl %eax
- pushl %ebx
- pushl %ecx
- pushl %edx
- pushf
- movl (%esp), %eax /* copy eflags to eax */
- xorl $0x200000, (%esp) /* try toggling ID bit of eflags (bit 21)
- * to see if cpu supports cpuid...
- * ID bit method not supported by NexGen but
- * bios may load a cpuid instruction and
- * cpuid may be disabled on Cyrix 5-6x86 */
- popf
- pushf
- popl %edx /* copy new eflags to edx */
- xorl %eax, %edx /* test if ID bit is flipped */
- jz .L_dont_use_mmx /* not flipped if zero */
- xorl %eax, %eax
- cpuid
- cmpl $0x756e6547, %ebx /* check for GenuineIntel in ebx,ecx,edx */
- jne .L_dont_use_mmx
- cmpl $0x6c65746e, %ecx
- jne .L_dont_use_mmx
- cmpl $0x49656e69, %edx
- jne .L_dont_use_mmx
- movl $1, %eax
- cpuid /* get cpu features */
- shrl $8, %eax
- andl $15, %eax
- cmpl $6, %eax /* check for Pentium family, is 0xf for P4 */
- jne .L_dont_use_mmx
- testl $0x800000, %edx /* test if MMX feature is set (bit 23) */
- jnz .L_use_mmx
- jmp .L_dont_use_mmx
-.L_use_mmx:
- movl $DO_USE_MMX, inflate_fast_use_mmx
- jmp .L_check_mmx_pop
-.L_dont_use_mmx:
- movl $DONT_USE_MMX, inflate_fast_use_mmx
-.L_check_mmx_pop:
- popl %edx
- popl %ecx
- popl %ebx
- popl %eax
- jmp .L_check_mmx
-#endif
-
-
-/*** Non-MMX code ***/
-
-#if defined ( NO_MMX ) || defined( RUN_TIME_MMX )
-
-#define hold_r %ebp
-#define bits_r %bl
-#define bitslong_r %ebx
-
-.align 32,0x90
-.L_while_test:
- /* while (in < last && out < end)
- */
- cmpl out_r, end(%esp)
- jbe .L_break_loop /* if (out >= end) */
-
- cmpl in_r, last(%esp)
- jbe .L_break_loop
-
-.L_do_loop:
- /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out
- *
- * do {
- * if (bits < 15) {
- * hold |= *((unsigned short *)in)++ << bits;
- * bits += 16
- * }
- * this = lcode[hold & lmask]
- */
- cmpb $15, bits_r
- ja .L_get_length_code /* if (15 < bits) */
-
- xorl %eax, %eax
- lodsw /* al = *(ushort *)in++ */
- movb bits_r, %cl /* cl = bits, needs it for shifting */
- addb $16, bits_r /* bits += 16 */
- shll %cl, %eax
- orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */
-
-.L_get_length_code:
- movl lmask(%esp), %edx /* edx = lmask */
- movl lcode(%esp), %ecx /* ecx = lcode */
- andl hold_r, %edx /* edx &= hold */
- movl (%ecx,%edx,4), %eax /* eax = lcode[hold & lmask] */
-
-.L_dolen:
- /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out
- *
- * dolen:
- * bits -= this.bits;
- * hold >>= this.bits
- */
- movb %ah, %cl /* cl = this.bits */
- subb %ah, bits_r /* bits -= this.bits */
- shrl %cl, hold_r /* hold >>= this.bits */
-
- /* check if op is a literal
- * if (op == 0) {
- * PUP(out) = this.val;
- * }
- */
- testb %al, %al
- jnz .L_test_for_length_base /* if (op != 0) 45.7% */
-
- shrl $16, %eax /* output this.val char */
- stosb
- jmp .L_while_test
-
-.L_test_for_length_base:
- /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out, %edx = len
- *
- * else if (op & 16) {
- * len = this.val
- * op &= 15
- * if (op) {
- * if (op > bits) {
- * hold |= *((unsigned short *)in)++ << bits;
- * bits += 16
- * }
- * len += hold & mask[op];
- * bits -= op;
- * hold >>= op;
- * }
- */
-#define len_r %edx
- movl %eax, len_r /* len = this */
- shrl $16, len_r /* len = this.val */
- movb %al, %cl
-
- testb $16, %al
- jz .L_test_for_second_level_length /* if ((op & 16) == 0) 8% */
- andb $15, %cl /* op &= 15 */
- jz .L_save_len /* if (!op) */
- cmpb %cl, bits_r
- jae .L_add_bits_to_len /* if (op <= bits) */
-
- movb %cl, %ch /* stash op in ch, freeing cl */
- xorl %eax, %eax
- lodsw /* al = *(ushort *)in++ */
- movb bits_r, %cl /* cl = bits, needs it for shifting */
- addb $16, bits_r /* bits += 16 */
- shll %cl, %eax
- orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */
- movb %ch, %cl /* move op back to ecx */
-
-.L_add_bits_to_len:
- movl $1, %eax
- shll %cl, %eax
- decl %eax
- subb %cl, bits_r
- andl hold_r, %eax /* eax &= hold */
- shrl %cl, hold_r
- addl %eax, len_r /* len += hold & mask[op] */
-
-.L_save_len:
- movl len_r, len(%esp) /* save len */
-#undef len_r
-
-.L_decode_distance:
- /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out, %edx = dist
- *
- * if (bits < 15) {
- * hold |= *((unsigned short *)in)++ << bits;
- * bits += 16
- * }
- * this = dcode[hold & dmask];
- * dodist:
- * bits -= this.bits;
- * hold >>= this.bits;
- * op = this.op;
- */
-
- cmpb $15, bits_r
- ja .L_get_distance_code /* if (15 < bits) */
-
- xorl %eax, %eax
- lodsw /* al = *(ushort *)in++ */
- movb bits_r, %cl /* cl = bits, needs it for shifting */
- addb $16, bits_r /* bits += 16 */
- shll %cl, %eax
- orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */
-
-.L_get_distance_code:
- movl dmask(%esp), %edx /* edx = dmask */
- movl dcode(%esp), %ecx /* ecx = dcode */
- andl hold_r, %edx /* edx &= hold */
- movl (%ecx,%edx,4), %eax /* eax = dcode[hold & dmask] */
-
-#define dist_r %edx
-.L_dodist:
- movl %eax, dist_r /* dist = this */
- shrl $16, dist_r /* dist = this.val */
- movb %ah, %cl
- subb %ah, bits_r /* bits -= this.bits */
- shrl %cl, hold_r /* hold >>= this.bits */
-
- /* if (op & 16) {
- * dist = this.val
- * op &= 15
- * if (op > bits) {
- * hold |= *((unsigned short *)in)++ << bits;
- * bits += 16
- * }
- * dist += hold & mask[op];
- * bits -= op;
- * hold >>= op;
- */
- movb %al, %cl /* cl = this.op */
-
- testb $16, %al /* if ((op & 16) == 0) */
- jz .L_test_for_second_level_dist
- andb $15, %cl /* op &= 15 */
- jz .L_check_dist_one
- cmpb %cl, bits_r
- jae .L_add_bits_to_dist /* if (op <= bits) 97.6% */
-
- movb %cl, %ch /* stash op in ch, freeing cl */
- xorl %eax, %eax
- lodsw /* al = *(ushort *)in++ */
- movb bits_r, %cl /* cl = bits, needs it for shifting */
- addb $16, bits_r /* bits += 16 */
- shll %cl, %eax
- orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */
- movb %ch, %cl /* move op back to ecx */
-
-.L_add_bits_to_dist:
- movl $1, %eax
- shll %cl, %eax
- decl %eax /* (1 << op) - 1 */
- subb %cl, bits_r
- andl hold_r, %eax /* eax &= hold */
- shrl %cl, hold_r
- addl %eax, dist_r /* dist += hold & ((1 << op) - 1) */
- jmp .L_check_window
-
-.L_check_window:
- /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist
- * %ecx = nbytes
- *
- * nbytes = out - beg;
- * if (dist <= nbytes) {
- * from = out - dist;
- * do {
- * PUP(out) = PUP(from);
- * } while (--len > 0) {
- * }
- */
-
- movl in_r, in(%esp) /* save in so from can use it's reg */
- movl out_r, %eax
- subl beg(%esp), %eax /* nbytes = out - beg */
-
- cmpl dist_r, %eax
- jb .L_clip_window /* if (dist > nbytes) 4.2% */
-
- movl len(%esp), %ecx
- movl out_r, from_r
- subl dist_r, from_r /* from = out - dist */
-
- subl $3, %ecx
- movb (from_r), %al
- movb %al, (out_r)
- movb 1(from_r), %al
- movb 2(from_r), %dl
- addl $3, from_r
- movb %al, 1(out_r)
- movb %dl, 2(out_r)
- addl $3, out_r
- rep movsb
-
- movl in(%esp), in_r /* move in back to %esi, toss from */
- jmp .L_while_test
-
-.align 16,0x90
-.L_check_dist_one:
- cmpl $1, dist_r
- jne .L_check_window
- cmpl out_r, beg(%esp)
- je .L_check_window
-
- decl out_r
- movl len(%esp), %ecx
- movb (out_r), %al
- subl $3, %ecx
-
- movb %al, 1(out_r)
- movb %al, 2(out_r)
- movb %al, 3(out_r)
- addl $4, out_r
- rep stosb
-
- jmp .L_while_test
-
-.align 16,0x90
-.L_test_for_second_level_length:
- /* else if ((op & 64) == 0) {
- * this = lcode[this.val + (hold & mask[op])];
- * }
- */
- testb $64, %al
- jnz .L_test_for_end_of_block /* if ((op & 64) != 0) */
-
- movl $1, %eax
- shll %cl, %eax
- decl %eax
- andl hold_r, %eax /* eax &= hold */
- addl %edx, %eax /* eax += this.val */
- movl lcode(%esp), %edx /* edx = lcode */
- movl (%edx,%eax,4), %eax /* eax = lcode[val + (hold&mask[op])] */
- jmp .L_dolen
-
-.align 16,0x90
-.L_test_for_second_level_dist:
- /* else if ((op & 64) == 0) {
- * this = dcode[this.val + (hold & mask[op])];
- * }
- */
- testb $64, %al
- jnz .L_invalid_distance_code /* if ((op & 64) != 0) */
-
- movl $1, %eax
- shll %cl, %eax
- decl %eax
- andl hold_r, %eax /* eax &= hold */
- addl %edx, %eax /* eax += this.val */
- movl dcode(%esp), %edx /* edx = dcode */
- movl (%edx,%eax,4), %eax /* eax = dcode[val + (hold&mask[op])] */
- jmp .L_dodist
-
-.align 16,0x90
-.L_clip_window:
- /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist
- * %ecx = nbytes
- *
- * else {
- * if (dist > wsize) {
- * invalid distance
- * }
- * from = window;
- * nbytes = dist - nbytes;
- * if (write == 0) {
- * from += wsize - nbytes;
- */
-#define nbytes_r %ecx
- movl %eax, nbytes_r
- movl wsize(%esp), %eax /* prepare for dist compare */
- negl nbytes_r /* nbytes = -nbytes */
- movl window(%esp), from_r /* from = window */
-
- cmpl dist_r, %eax
- jb .L_invalid_distance_too_far /* if (dist > wsize) */
-
- addl dist_r, nbytes_r /* nbytes = dist - nbytes */
- cmpl $0, write(%esp)
- jne .L_wrap_around_window /* if (write != 0) */
-
- subl nbytes_r, %eax
- addl %eax, from_r /* from += wsize - nbytes */
-
- /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist
- * %ecx = nbytes, %eax = len
- *
- * if (nbytes < len) {
- * len -= nbytes;
- * do {
- * PUP(out) = PUP(from);
- * } while (--nbytes);
- * from = out - dist;
- * }
- * }
- */
-#define len_r %eax
- movl len(%esp), len_r
- cmpl nbytes_r, len_r
- jbe .L_do_copy1 /* if (nbytes >= len) */
-
- subl nbytes_r, len_r /* len -= nbytes */
- rep movsb
- movl out_r, from_r
- subl dist_r, from_r /* from = out - dist */
- jmp .L_do_copy1
-
- cmpl nbytes_r, len_r
- jbe .L_do_copy1 /* if (nbytes >= len) */
-
- subl nbytes_r, len_r /* len -= nbytes */
- rep movsb
- movl out_r, from_r
- subl dist_r, from_r /* from = out - dist */
- jmp .L_do_copy1
-
-.L_wrap_around_window:
- /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist
- * %ecx = nbytes, %eax = write, %eax = len
- *
- * else if (write < nbytes) {
- * from += wsize + write - nbytes;
- * nbytes -= write;
- * if (nbytes < len) {
- * len -= nbytes;
- * do {
- * PUP(out) = PUP(from);
- * } while (--nbytes);
- * from = window;
- * nbytes = write;
- * if (nbytes < len) {
- * len -= nbytes;
- * do {
- * PUP(out) = PUP(from);
- * } while(--nbytes);
- * from = out - dist;
- * }
- * }
- * }
- */
-#define write_r %eax
- movl write(%esp), write_r
- cmpl write_r, nbytes_r
- jbe .L_contiguous_in_window /* if (write >= nbytes) */
-
- addl wsize(%esp), from_r
- addl write_r, from_r
- subl nbytes_r, from_r /* from += wsize + write - nbytes */
- subl write_r, nbytes_r /* nbytes -= write */
-#undef write_r
-
- movl len(%esp), len_r
- cmpl nbytes_r, len_r
- jbe .L_do_copy1 /* if (nbytes >= len) */
-
- subl nbytes_r, len_r /* len -= nbytes */
- rep movsb
- movl window(%esp), from_r /* from = window */
- movl write(%esp), nbytes_r /* nbytes = write */
- cmpl nbytes_r, len_r
- jbe .L_do_copy1 /* if (nbytes >= len) */
-
- subl nbytes_r, len_r /* len -= nbytes */
- rep movsb
- movl out_r, from_r
- subl dist_r, from_r /* from = out - dist */
- jmp .L_do_copy1
-
-.L_contiguous_in_window:
- /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist
- * %ecx = nbytes, %eax = write, %eax = len
- *
- * else {
- * from += write - nbytes;
- * if (nbytes < len) {
- * len -= nbytes;
- * do {
- * PUP(out) = PUP(from);
- * } while (--nbytes);
- * from = out - dist;
- * }
- * }
- */
-#define write_r %eax
- addl write_r, from_r
- subl nbytes_r, from_r /* from += write - nbytes */
-#undef write_r
-
- movl len(%esp), len_r
- cmpl nbytes_r, len_r
- jbe .L_do_copy1 /* if (nbytes >= len) */
-
- subl nbytes_r, len_r /* len -= nbytes */
- rep movsb
- movl out_r, from_r
- subl dist_r, from_r /* from = out - dist */
-
-.L_do_copy1:
- /* regs: %esi = from, %esi = in, %ebp = hold, %bl = bits, %edi = out
- * %eax = len
- *
- * while (len > 0) {
- * PUP(out) = PUP(from);
- * len--;
- * }
- * }
- * } while (in < last && out < end);
- */
-#undef nbytes_r
-#define in_r %esi
- movl len_r, %ecx
- rep movsb
-
- movl in(%esp), in_r /* move in back to %esi, toss from */
- jmp .L_while_test
-
-#undef len_r
-#undef dist_r
-
-#endif /* NO_MMX || RUN_TIME_MMX */
-
-
-/*** MMX code ***/
-
-#if defined( USE_MMX ) || defined( RUN_TIME_MMX )
-
-.align 32,0x90
-.L_init_mmx:
- emms
-
-#undef bits_r
-#undef bitslong_r
-#define bitslong_r %ebp
-#define hold_mm %mm0
- movd %ebp, hold_mm
- movl %ebx, bitslong_r
-
-#define used_mm %mm1
-#define dmask2_mm %mm2
-#define lmask2_mm %mm3
-#define lmask_mm %mm4
-#define dmask_mm %mm5
-#define tmp_mm %mm6
-
- movd lmask(%esp), lmask_mm
- movq lmask_mm, lmask2_mm
- movd dmask(%esp), dmask_mm
- movq dmask_mm, dmask2_mm
- pxor used_mm, used_mm
- movl lcode(%esp), %ebx /* ebx = lcode */
- jmp .L_do_loop_mmx
-
-.align 32,0x90
-.L_while_test_mmx:
- /* while (in < last && out < end)
- */
- cmpl out_r, end(%esp)
- jbe .L_break_loop /* if (out >= end) */
-
- cmpl in_r, last(%esp)
- jbe .L_break_loop
-
-.L_do_loop_mmx:
- psrlq used_mm, hold_mm /* hold_mm >>= last bit length */
-
- cmpl $32, bitslong_r
- ja .L_get_length_code_mmx /* if (32 < bits) */
-
- movd bitslong_r, tmp_mm
- movd (in_r), %mm7
- addl $4, in_r
- psllq tmp_mm, %mm7
- addl $32, bitslong_r
- por %mm7, hold_mm /* hold_mm |= *((uint *)in)++ << bits */
-
-.L_get_length_code_mmx:
- pand hold_mm, lmask_mm
- movd lmask_mm, %eax
- movq lmask2_mm, lmask_mm
- movl (%ebx,%eax,4), %eax /* eax = lcode[hold & lmask] */
-
-.L_dolen_mmx:
- movzbl %ah, %ecx /* ecx = this.bits */
- movd %ecx, used_mm
- subl %ecx, bitslong_r /* bits -= this.bits */
-
- testb %al, %al
- jnz .L_test_for_length_base_mmx /* if (op != 0) 45.7% */
-
- shrl $16, %eax /* output this.val char */
- stosb
- jmp .L_while_test_mmx
-
-.L_test_for_length_base_mmx:
-#define len_r %edx
- movl %eax, len_r /* len = this */
- shrl $16, len_r /* len = this.val */
-
- testb $16, %al
- jz .L_test_for_second_level_length_mmx /* if ((op & 16) == 0) 8% */
- andl $15, %eax /* op &= 15 */
- jz .L_decode_distance_mmx /* if (!op) */
-
- psrlq used_mm, hold_mm /* hold_mm >>= last bit length */
- movd %eax, used_mm
- movd hold_mm, %ecx
- subl %eax, bitslong_r
- andl .L_mask(,%eax,4), %ecx
- addl %ecx, len_r /* len += hold & mask[op] */
-
-.L_decode_distance_mmx:
- psrlq used_mm, hold_mm /* hold_mm >>= last bit length */
-
- cmpl $32, bitslong_r
- ja .L_get_dist_code_mmx /* if (32 < bits) */
-
- movd bitslong_r, tmp_mm
- movd (in_r), %mm7
- addl $4, in_r
- psllq tmp_mm, %mm7
- addl $32, bitslong_r
- por %mm7, hold_mm /* hold_mm |= *((uint *)in)++ << bits */
-
-.L_get_dist_code_mmx:
- movl dcode(%esp), %ebx /* ebx = dcode */
- pand hold_mm, dmask_mm
- movd dmask_mm, %eax
- movq dmask2_mm, dmask_mm
- movl (%ebx,%eax,4), %eax /* eax = dcode[hold & lmask] */
-
-.L_dodist_mmx:
-#define dist_r %ebx
- movzbl %ah, %ecx /* ecx = this.bits */
- movl %eax, dist_r
- shrl $16, dist_r /* dist = this.val */
- subl %ecx, bitslong_r /* bits -= this.bits */
- movd %ecx, used_mm
-
- testb $16, %al /* if ((op & 16) == 0) */
- jz .L_test_for_second_level_dist_mmx
- andl $15, %eax /* op &= 15 */
- jz .L_check_dist_one_mmx
-
-.L_add_bits_to_dist_mmx:
- psrlq used_mm, hold_mm /* hold_mm >>= last bit length */
- movd %eax, used_mm /* save bit length of current op */
- movd hold_mm, %ecx /* get the next bits on input stream */
- subl %eax, bitslong_r /* bits -= op bits */
- andl .L_mask(,%eax,4), %ecx /* ecx = hold & mask[op] */
- addl %ecx, dist_r /* dist += hold & mask[op] */
-
-.L_check_window_mmx:
- movl in_r, in(%esp) /* save in so from can use it's reg */
- movl out_r, %eax
- subl beg(%esp), %eax /* nbytes = out - beg */
-
- cmpl dist_r, %eax
- jb .L_clip_window_mmx /* if (dist > nbytes) 4.2% */
-
- movl len_r, %ecx
- movl out_r, from_r
- subl dist_r, from_r /* from = out - dist */
-
- subl $3, %ecx
- movb (from_r), %al
- movb %al, (out_r)
- movb 1(from_r), %al
- movb 2(from_r), %dl
- addl $3, from_r
- movb %al, 1(out_r)
- movb %dl, 2(out_r)
- addl $3, out_r
- rep movsb
-
- movl in(%esp), in_r /* move in back to %esi, toss from */
- movl lcode(%esp), %ebx /* move lcode back to %ebx, toss dist */
- jmp .L_while_test_mmx
-
-.align 16,0x90
-.L_check_dist_one_mmx:
- cmpl $1, dist_r
- jne .L_check_window_mmx
- cmpl out_r, beg(%esp)
- je .L_check_window_mmx
-
- decl out_r
- movl len_r, %ecx
- movb (out_r), %al
- subl $3, %ecx
-
- movb %al, 1(out_r)
- movb %al, 2(out_r)
- movb %al, 3(out_r)
- addl $4, out_r
- rep stosb
-
- movl lcode(%esp), %ebx /* move lcode back to %ebx, toss dist */
- jmp .L_while_test_mmx
-
-.align 16,0x90
-.L_test_for_second_level_length_mmx:
- testb $64, %al
- jnz .L_test_for_end_of_block /* if ((op & 64) != 0) */
-
- andl $15, %eax
- psrlq used_mm, hold_mm /* hold_mm >>= last bit length */
- movd hold_mm, %ecx
- andl .L_mask(,%eax,4), %ecx
- addl len_r, %ecx
- movl (%ebx,%ecx,4), %eax /* eax = lcode[hold & lmask] */
- jmp .L_dolen_mmx
-
-.align 16,0x90
-.L_test_for_second_level_dist_mmx:
- testb $64, %al
- jnz .L_invalid_distance_code /* if ((op & 64) != 0) */
-
- andl $15, %eax
- psrlq used_mm, hold_mm /* hold_mm >>= last bit length */
- movd hold_mm, %ecx
- andl .L_mask(,%eax,4), %ecx
- movl dcode(%esp), %eax /* ecx = dcode */
- addl dist_r, %ecx
- movl (%eax,%ecx,4), %eax /* eax = lcode[hold & lmask] */
- jmp .L_dodist_mmx
-
-.align 16,0x90
-.L_clip_window_mmx:
-#define nbytes_r %ecx
- movl %eax, nbytes_r
- movl wsize(%esp), %eax /* prepare for dist compare */
- negl nbytes_r /* nbytes = -nbytes */
- movl window(%esp), from_r /* from = window */
-
- cmpl dist_r, %eax
- jb .L_invalid_distance_too_far /* if (dist > wsize) */
-
- addl dist_r, nbytes_r /* nbytes = dist - nbytes */
- cmpl $0, write(%esp)
- jne .L_wrap_around_window_mmx /* if (write != 0) */
-
- subl nbytes_r, %eax
- addl %eax, from_r /* from += wsize - nbytes */
-
- cmpl nbytes_r, len_r
- jbe .L_do_copy1_mmx /* if (nbytes >= len) */
-
- subl nbytes_r, len_r /* len -= nbytes */
- rep movsb
- movl out_r, from_r
- subl dist_r, from_r /* from = out - dist */
- jmp .L_do_copy1_mmx
-
- cmpl nbytes_r, len_r
- jbe .L_do_copy1_mmx /* if (nbytes >= len) */
-
- subl nbytes_r, len_r /* len -= nbytes */
- rep movsb
- movl out_r, from_r
- subl dist_r, from_r /* from = out - dist */
- jmp .L_do_copy1_mmx
-
-.L_wrap_around_window_mmx:
-#define write_r %eax
- movl write(%esp), write_r
- cmpl write_r, nbytes_r
- jbe .L_contiguous_in_window_mmx /* if (write >= nbytes) */
-
- addl wsize(%esp), from_r
- addl write_r, from_r
- subl nbytes_r, from_r /* from += wsize + write - nbytes */
- subl write_r, nbytes_r /* nbytes -= write */
-#undef write_r
-
- cmpl nbytes_r, len_r
- jbe .L_do_copy1_mmx /* if (nbytes >= len) */
-
- subl nbytes_r, len_r /* len -= nbytes */
- rep movsb
- movl window(%esp), from_r /* from = window */
- movl write(%esp), nbytes_r /* nbytes = write */
- cmpl nbytes_r, len_r
- jbe .L_do_copy1_mmx /* if (nbytes >= len) */
-
- subl nbytes_r, len_r /* len -= nbytes */
- rep movsb
- movl out_r, from_r
- subl dist_r, from_r /* from = out - dist */
- jmp .L_do_copy1_mmx
-
-.L_contiguous_in_window_mmx:
-#define write_r %eax
- addl write_r, from_r
- subl nbytes_r, from_r /* from += write - nbytes */
-#undef write_r
-
- cmpl nbytes_r, len_r
- jbe .L_do_copy1_mmx /* if (nbytes >= len) */
-
- subl nbytes_r, len_r /* len -= nbytes */
- rep movsb
- movl out_r, from_r
- subl dist_r, from_r /* from = out - dist */
-
-.L_do_copy1_mmx:
-#undef nbytes_r
-#define in_r %esi
- movl len_r, %ecx
- rep movsb
-
- movl in(%esp), in_r /* move in back to %esi, toss from */
- movl lcode(%esp), %ebx /* move lcode back to %ebx, toss dist */
- jmp .L_while_test_mmx
-
-#undef hold_r
-#undef bitslong_r
-
-#endif /* USE_MMX || RUN_TIME_MMX */
-
-
-/*** USE_MMX, NO_MMX, and RUNTIME_MMX from here on ***/
-
-.L_invalid_distance_code:
- /* else {
- * strm->msg = "invalid distance code";
- * state->mode = BAD;
- * }
- */
- movl $.L_invalid_distance_code_msg, %ecx
- movl $INFLATE_MODE_BAD, %edx
- jmp .L_update_stream_state
-
-.L_test_for_end_of_block:
- /* else if (op & 32) {
- * state->mode = TYPE;
- * break;
- * }
- */
- testb $32, %al
- jz .L_invalid_literal_length_code /* if ((op & 32) == 0) */
-
- movl $0, %ecx
- movl $INFLATE_MODE_TYPE, %edx
- jmp .L_update_stream_state
-
-.L_invalid_literal_length_code:
- /* else {
- * strm->msg = "invalid literal/length code";
- * state->mode = BAD;
- * }
- */
- movl $.L_invalid_literal_length_code_msg, %ecx
- movl $INFLATE_MODE_BAD, %edx
- jmp .L_update_stream_state
-
-.L_invalid_distance_too_far:
- /* strm->msg = "invalid distance too far back";
- * state->mode = BAD;
- */
- movl in(%esp), in_r /* from_r has in's reg, put in back */
- movl $.L_invalid_distance_too_far_msg, %ecx
- movl $INFLATE_MODE_BAD, %edx
- jmp .L_update_stream_state
-
-.L_update_stream_state:
- /* set strm->msg = %ecx, strm->state->mode = %edx */
- movl strm_sp(%esp), %eax
- testl %ecx, %ecx /* if (msg != NULL) */
- jz .L_skip_msg
- movl %ecx, msg_strm(%eax) /* strm->msg = msg */
-.L_skip_msg:
- movl state_strm(%eax), %eax /* state = strm->state */
- movl %edx, mode_state(%eax) /* state->mode = edx (BAD | TYPE) */
- jmp .L_break_loop
-
-.align 32,0x90
-.L_break_loop:
-
-/*
- * Regs:
- *
- * bits = %ebp when mmx, and in %ebx when non-mmx
- * hold = %hold_mm when mmx, and in %ebp when non-mmx
- * in = %esi
- * out = %edi
- */
-
-#if defined( USE_MMX ) || defined( RUN_TIME_MMX )
-
-#if defined( RUN_TIME_MMX )
-
- cmpl $DO_USE_MMX, inflate_fast_use_mmx
- jne .L_update_next_in
-
-#endif /* RUN_TIME_MMX */
-
- movl %ebp, %ebx
-
-.L_update_next_in:
-
-#endif
-
-#define strm_r %eax
-#define state_r %edx
-
- /* len = bits >> 3;
- * in -= len;
- * bits -= len << 3;
- * hold &= (1U << bits) - 1;
- * state->hold = hold;
- * state->bits = bits;
- * strm->next_in = in;
- * strm->next_out = out;
- */
- movl strm_sp(%esp), strm_r
- movl %ebx, %ecx
- movl state_strm(strm_r), state_r
- shrl $3, %ecx
- subl %ecx, in_r
- shll $3, %ecx
- subl %ecx, %ebx
- movl out_r, next_out_strm(strm_r)
- movl %ebx, bits_state(state_r)
- movl %ebx, %ecx
-
- leal buf(%esp), %ebx
- cmpl %ebx, last(%esp)
- jne .L_buf_not_used /* if buf != last */
-
- subl %ebx, in_r /* in -= buf */
- movl next_in_strm(strm_r), %ebx
- movl %ebx, last(%esp) /* last = strm->next_in */
- addl %ebx, in_r /* in += strm->next_in */
- movl avail_in_strm(strm_r), %ebx
- subl $11, %ebx
- addl %ebx, last(%esp) /* last = &strm->next_in[ avail_in - 11 ] */
-
-.L_buf_not_used:
- movl in_r, next_in_strm(strm_r)
-
- movl $1, %ebx
- shll %cl, %ebx
- decl %ebx
-
-#if defined( USE_MMX ) || defined( RUN_TIME_MMX )
-
-#if defined( RUN_TIME_MMX )
-
- cmpl $DO_USE_MMX, inflate_fast_use_mmx
- jne .L_update_hold
-
-#endif /* RUN_TIME_MMX */
-
- psrlq used_mm, hold_mm /* hold_mm >>= last bit length */
- movd hold_mm, %ebp
-
- emms
-
-.L_update_hold:
-
-#endif /* USE_MMX || RUN_TIME_MMX */
-
- andl %ebx, %ebp
- movl %ebp, hold_state(state_r)
-
-#define last_r %ebx
-
- /* strm->avail_in = in < last ? 11 + (last - in) : 11 - (in - last) */
- movl last(%esp), last_r
- cmpl in_r, last_r
- jbe .L_last_is_smaller /* if (in >= last) */
-
- subl in_r, last_r /* last -= in */
- addl $11, last_r /* last += 11 */
- movl last_r, avail_in_strm(strm_r)
- jmp .L_fixup_out
-.L_last_is_smaller:
- subl last_r, in_r /* in -= last */
- negl in_r /* in = -in */
- addl $11, in_r /* in += 11 */
- movl in_r, avail_in_strm(strm_r)
-
-#undef last_r
-#define end_r %ebx
-
-.L_fixup_out:
- /* strm->avail_out = out < end ? 257 + (end - out) : 257 - (out - end)*/
- movl end(%esp), end_r
- cmpl out_r, end_r
- jbe .L_end_is_smaller /* if (out >= end) */
-
- subl out_r, end_r /* end -= out */
- addl $257, end_r /* end += 257 */
- movl end_r, avail_out_strm(strm_r)
- jmp .L_done
-.L_end_is_smaller:
- subl end_r, out_r /* out -= end */
- negl out_r /* out = -out */
- addl $257, out_r /* out += 257 */
- movl out_r, avail_out_strm(strm_r)
-
-#undef end_r
-#undef strm_r
-#undef state_r
-
-.L_done:
- addl $local_var_size, %esp
- popf
- popl %ebx
- popl %ebp
- popl %esi
- popl %edi
- ret
-
-#if defined( GAS_ELF )
-/* elf info */
-.type inflate_fast,@function
-.size inflate_fast,.-inflate_fast
-#endif
diff --git a/source4/lib/zlib/contrib/iostream/test.cpp b/source4/lib/zlib/contrib/iostream/test.cpp
deleted file mode 100644
index 7d265b3b5c..0000000000
--- a/source4/lib/zlib/contrib/iostream/test.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-
-#include "zfstream.h"
-
-int main() {
-
- // Construct a stream object with this filebuffer. Anything sent
- // to this stream will go to standard out.
- gzofstream os( 1, ios::out );
-
- // This text is getting compressed and sent to stdout.
- // To prove this, run 'test | zcat'.
- os << "Hello, Mommy" << endl;
-
- os << setcompressionlevel( Z_NO_COMPRESSION );
- os << "hello, hello, hi, ho!" << endl;
-
- setcompressionlevel( os, Z_DEFAULT_COMPRESSION )
- << "I'm compressing again" << endl;
-
- os.close();
-
- return 0;
-
-}
diff --git a/source4/lib/zlib/contrib/iostream/zfstream.cpp b/source4/lib/zlib/contrib/iostream/zfstream.cpp
deleted file mode 100644
index d0cd85faaf..0000000000
--- a/source4/lib/zlib/contrib/iostream/zfstream.cpp
+++ /dev/null
@@ -1,329 +0,0 @@
-
-#include "zfstream.h"
-
-gzfilebuf::gzfilebuf() :
- file(NULL),
- mode(0),
- own_file_descriptor(0)
-{ }
-
-gzfilebuf::~gzfilebuf() {
-
- sync();
- if ( own_file_descriptor )
- close();
-
-}
-
-gzfilebuf *gzfilebuf::open( const char *name,
- int io_mode ) {
-
- if ( is_open() )
- return NULL;
-
- char char_mode[10];
- char *p = char_mode;
-
- if ( io_mode & ios::in ) {
- mode = ios::in;
- *p++ = 'r';
- } else if ( io_mode & ios::app ) {
- mode = ios::app;
- *p++ = 'a';
- } else {
- mode = ios::out;
- *p++ = 'w';
- }
-
- if ( io_mode & ios::binary ) {
- mode |= ios::binary;
- *p++ = 'b';
- }
-
- // Hard code the compression level
- if ( io_mode & (ios::out|ios::app )) {
- *p++ = '9';
- }
-
- // Put the end-of-string indicator
- *p = '\0';
-
- if ( (file = gzopen(name, char_mode)) == NULL )
- return NULL;
-
- own_file_descriptor = 1;
-
- return this;
-
-}
-
-gzfilebuf *gzfilebuf::attach( int file_descriptor,
- int io_mode ) {
-
- if ( is_open() )
- return NULL;
-
- char char_mode[10];
- char *p = char_mode;
-
- if ( io_mode & ios::in ) {
- mode = ios::in;
- *p++ = 'r';
- } else if ( io_mode & ios::app ) {
- mode = ios::app;
- *p++ = 'a';
- } else {
- mode = ios::out;
- *p++ = 'w';
- }
-
- if ( io_mode & ios::binary ) {
- mode |= ios::binary;
- *p++ = 'b';
- }
-
- // Hard code the compression level
- if ( io_mode & (ios::out|ios::app )) {
- *p++ = '9';
- }
-
- // Put the end-of-string indicator
- *p = '\0';
-
- if ( (file = gzdopen(file_descriptor, char_mode)) == NULL )
- return NULL;
-
- own_file_descriptor = 0;
-
- return this;
-
-}
-
-gzfilebuf *gzfilebuf::close() {
-
- if ( is_open() ) {
-
- sync();
- gzclose( file );
- file = NULL;
-
- }
-
- return this;
-
-}
-
-int gzfilebuf::setcompressionlevel( int comp_level ) {
-
- return gzsetparams(file, comp_level, -2);
-
-}
-
-int gzfilebuf::setcompressionstrategy( int comp_strategy ) {
-
- return gzsetparams(file, -2, comp_strategy);
-
-}
-
-
-streampos gzfilebuf::seekoff( streamoff off, ios::seek_dir dir, int which ) {
-
- return streampos(EOF);
-
-}
-
-int gzfilebuf::underflow() {
-
- // If the file hasn't been opened for reading, error.
- if ( !is_open() || !(mode & ios::in) )
- return EOF;
-
- // if a buffer doesn't exists, allocate one.
- if ( !base() ) {
-
- if ( (allocate()) == EOF )
- return EOF;
- setp(0,0);
-
- } else {
-
- if ( in_avail() )
- return (unsigned char) *gptr();
-
- if ( out_waiting() ) {
- if ( flushbuf() == EOF )
- return EOF;
- }
-
- }
-
- // Attempt to fill the buffer.
-
- int result = fillbuf();
- if ( result == EOF ) {
- // disable get area
- setg(0,0,0);
- return EOF;
- }
-
- return (unsigned char) *gptr();
-
-}
-
-int gzfilebuf::overflow( int c ) {
-
- if ( !is_open() || !(mode & ios::out) )
- return EOF;
-
- if ( !base() ) {
- if ( allocate() == EOF )
- return EOF;
- setg(0,0,0);
- } else {
- if (in_avail()) {
- return EOF;
- }
- if (out_waiting()) {
- if (flushbuf() == EOF)
- return EOF;
- }
- }
-
- int bl = blen();
- setp( base(), base() + bl);
-
- if ( c != EOF ) {
-
- *pptr() = c;
- pbump(1);
-
- }
-
- return 0;
-
-}
-
-int gzfilebuf::sync() {
-
- if ( !is_open() )
- return EOF;
-
- if ( out_waiting() )
- return flushbuf();
-
- return 0;
-
-}
-
-int gzfilebuf::flushbuf() {
-
- int n;
- char *q;
-
- q = pbase();
- n = pptr() - q;
-
- if ( gzwrite( file, q, n) < n )
- return EOF;
-
- setp(0,0);
-
- return 0;
-
-}
-
-int gzfilebuf::fillbuf() {
-
- int required;
- char *p;
-
- p = base();
-
- required = blen();
-
- int t = gzread( file, p, required );
-
- if ( t <= 0) return EOF;
-
- setg( base(), base(), base()+t);
-
- return t;
-
-}
-
-gzfilestream_common::gzfilestream_common() :
- ios( gzfilestream_common::rdbuf() )
-{ }
-
-gzfilestream_common::~gzfilestream_common()
-{ }
-
-void gzfilestream_common::attach( int fd, int io_mode ) {
-
- if ( !buffer.attach( fd, io_mode) )
- clear( ios::failbit | ios::badbit );
- else
- clear();
-
-}
-
-void gzfilestream_common::open( const char *name, int io_mode ) {
-
- if ( !buffer.open( name, io_mode ) )
- clear( ios::failbit | ios::badbit );
- else
- clear();
-
-}
-
-void gzfilestream_common::close() {
-
- if ( !buffer.close() )
- clear( ios::failbit | ios::badbit );
-
-}
-
-gzfilebuf *gzfilestream_common::rdbuf()
-{
- return &buffer;
-}
-
-gzifstream::gzifstream() :
- ios( gzfilestream_common::rdbuf() )
-{
- clear( ios::badbit );
-}
-
-gzifstream::gzifstream( const char *name, int io_mode ) :
- ios( gzfilestream_common::rdbuf() )
-{
- gzfilestream_common::open( name, io_mode );
-}
-
-gzifstream::gzifstream( int fd, int io_mode ) :
- ios( gzfilestream_common::rdbuf() )
-{
- gzfilestream_common::attach( fd, io_mode );
-}
-
-gzifstream::~gzifstream() { }
-
-gzofstream::gzofstream() :
- ios( gzfilestream_common::rdbuf() )
-{
- clear( ios::badbit );
-}
-
-gzofstream::gzofstream( const char *name, int io_mode ) :
- ios( gzfilestream_common::rdbuf() )
-{
- gzfilestream_common::open( name, io_mode );
-}
-
-gzofstream::gzofstream( int fd, int io_mode ) :
- ios( gzfilestream_common::rdbuf() )
-{
- gzfilestream_common::attach( fd, io_mode );
-}
-
-gzofstream::~gzofstream() { }
diff --git a/source4/lib/zlib/contrib/iostream/zfstream.h b/source4/lib/zlib/contrib/iostream/zfstream.h
deleted file mode 100644
index ed79098a3a..0000000000
--- a/source4/lib/zlib/contrib/iostream/zfstream.h
+++ /dev/null
@@ -1,128 +0,0 @@
-
-#ifndef zfstream_h
-#define zfstream_h
-
-#include <fstream.h>
-#include "zlib.h"
-
-class gzfilebuf : public streambuf {
-
-public:
-
- gzfilebuf( );
- virtual ~gzfilebuf();
-
- gzfilebuf *open( const char *name, int io_mode );
- gzfilebuf *attach( int file_descriptor, int io_mode );
- gzfilebuf *close();
-
- int setcompressionlevel( int comp_level );
- int setcompressionstrategy( int comp_strategy );
-
- inline int is_open() const { return (file !=NULL); }
-
- virtual streampos seekoff( streamoff, ios::seek_dir, int );
-
- virtual int sync();
-
-protected:
-
- virtual int underflow();
- virtual int overflow( int = EOF );
-
-private:
-
- gzFile file;
- short mode;
- short own_file_descriptor;
-
- int flushbuf();
- int fillbuf();
-
-};
-
-class gzfilestream_common : virtual public ios {
-
- friend class gzifstream;
- friend class gzofstream;
- friend gzofstream &setcompressionlevel( gzofstream &, int );
- friend gzofstream &setcompressionstrategy( gzofstream &, int );
-
-public:
- virtual ~gzfilestream_common();
-
- void attach( int fd, int io_mode );
- void open( const char *name, int io_mode );
- void close();
-
-protected:
- gzfilestream_common();
-
-private:
- gzfilebuf *rdbuf();
-
- gzfilebuf buffer;
-
-};
-
-class gzifstream : public gzfilestream_common, public istream {
-
-public:
-
- gzifstream();
- gzifstream( const char *name, int io_mode = ios::in );
- gzifstream( int fd, int io_mode = ios::in );
-
- virtual ~gzifstream();
-
-};
-
-class gzofstream : public gzfilestream_common, public ostream {
-
-public:
-
- gzofstream();
- gzofstream( const char *name, int io_mode = ios::out );
- gzofstream( int fd, int io_mode = ios::out );
-
- virtual ~gzofstream();
-
-};
-
-template<class T> class gzomanip {
- friend gzofstream &operator<<(gzofstream &, const gzomanip<T> &);
-public:
- gzomanip(gzofstream &(*f)(gzofstream &, T), T v) : func(f), val(v) { }
-private:
- gzofstream &(*func)(gzofstream &, T);
- T val;
-};
-
-template<class T> gzofstream &operator<<(gzofstream &s, const gzomanip<T> &m)
-{
- return (*m.func)(s, m.val);
-}
-
-inline gzofstream &setcompressionlevel( gzofstream &s, int l )
-{
- (s.rdbuf())->setcompressionlevel(l);
- return s;
-}
-
-inline gzofstream &setcompressionstrategy( gzofstream &s, int l )
-{
- (s.rdbuf())->setcompressionstrategy(l);
- return s;
-}
-
-inline gzomanip<int> setcompressionlevel(int l)
-{
- return gzomanip<int>(&setcompressionlevel,l);
-}
-
-inline gzomanip<int> setcompressionstrategy(int l)
-{
- return gzomanip<int>(&setcompressionstrategy,l);
-}
-
-#endif
diff --git a/source4/lib/zlib/contrib/iostream2/zstream.h b/source4/lib/zlib/contrib/iostream2/zstream.h
deleted file mode 100644
index 43d2332b79..0000000000
--- a/source4/lib/zlib/contrib/iostream2/zstream.h
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- *
- * Copyright (c) 1997
- * Christian Michelsen Research AS
- * Advanced Computing
- * Fantoftvegen 38, 5036 BERGEN, Norway
- * http://www.cmr.no
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Christian Michelsen Research AS makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#ifndef ZSTREAM__H
-#define ZSTREAM__H
-
-/*
- * zstream.h - C++ interface to the 'zlib' general purpose compression library
- * $Id: zstream.h 1.1 1997-06-25 12:00:56+02 tyge Exp tyge $
- */
-
-#include <strstream.h>
-#include <string.h>
-#include <stdio.h>
-#include "zlib.h"
-
-#if defined(_WIN32)
-# include <fcntl.h>
-# include <io.h>
-# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
-#else
-# define SET_BINARY_MODE(file)
-#endif
-
-class zstringlen {
-public:
- zstringlen(class izstream&);
- zstringlen(class ozstream&, const char*);
- size_t value() const { return val.word; }
-private:
- struct Val { unsigned char byte; size_t word; } val;
-};
-
-// ----------------------------- izstream -----------------------------
-
-class izstream
-{
- public:
- izstream() : m_fp(0) {}
- izstream(FILE* fp) : m_fp(0) { open(fp); }
- izstream(const char* name) : m_fp(0) { open(name); }
- ~izstream() { close(); }
-
- /* Opens a gzip (.gz) file for reading.
- * open() can be used to read a file which is not in gzip format;
- * in this case read() will directly read from the file without
- * decompression. errno can be checked to distinguish two error
- * cases (if errno is zero, the zlib error is Z_MEM_ERROR).
- */
- void open(const char* name) {
- if (m_fp) close();
- m_fp = ::gzopen(name, "rb");
- }
-
- void open(FILE* fp) {
- SET_BINARY_MODE(fp);
- if (m_fp) close();
- m_fp = ::gzdopen(fileno(fp), "rb");
- }
-
- /* Flushes all pending input if necessary, closes the compressed file
- * and deallocates all the (de)compression state. The return value is
- * the zlib error number (see function error() below).
- */
- int close() {
- int r = ::gzclose(m_fp);
- m_fp = 0; return r;
- }
-
- /* Binary read the given number of bytes from the compressed file.
- */
- int read(void* buf, size_t len) {
- return ::gzread(m_fp, buf, len);
- }
-
- /* Returns the error message for the last error which occurred on the
- * given compressed file. errnum is set to zlib error number. If an
- * error occurred in the file system and not in the compression library,
- * errnum is set to Z_ERRNO and the application may consult errno
- * to get the exact error code.
- */
- const char* error(int* errnum) {
- return ::gzerror(m_fp, errnum);
- }
-
- gzFile fp() { return m_fp; }
-
- private:
- gzFile m_fp;
-};
-
-/*
- * Binary read the given (array of) object(s) from the compressed file.
- * If the input file was not in gzip format, read() copies the objects number
- * of bytes into the buffer.
- * returns the number of uncompressed bytes actually read
- * (0 for end of file, -1 for error).
- */
-template <class T, class Items>
-inline int read(izstream& zs, T* x, Items items) {
- return ::gzread(zs.fp(), x, items*sizeof(T));
-}
-
-/*
- * Binary input with the '>' operator.
- */
-template <class T>
-inline izstream& operator>(izstream& zs, T& x) {
- ::gzread(zs.fp(), &x, sizeof(T));
- return zs;
-}
-
-
-inline zstringlen::zstringlen(izstream& zs) {
- zs > val.byte;
- if (val.byte == 255) zs > val.word;
- else val.word = val.byte;
-}
-
-/*
- * Read length of string + the string with the '>' operator.
- */
-inline izstream& operator>(izstream& zs, char* x) {
- zstringlen len(zs);
- ::gzread(zs.fp(), x, len.value());
- x[len.value()] = '\0';
- return zs;
-}
-
-inline char* read_string(izstream& zs) {
- zstringlen len(zs);
- char* x = new char[len.value()+1];
- ::gzread(zs.fp(), x, len.value());
- x[len.value()] = '\0';
- return x;
-}
-
-// ----------------------------- ozstream -----------------------------
-
-class ozstream
-{
- public:
- ozstream() : m_fp(0), m_os(0) {
- }
- ozstream(FILE* fp, int level = Z_DEFAULT_COMPRESSION)
- : m_fp(0), m_os(0) {
- open(fp, level);
- }
- ozstream(const char* name, int level = Z_DEFAULT_COMPRESSION)
- : m_fp(0), m_os(0) {
- open(name, level);
- }
- ~ozstream() {
- close();
- }
-
- /* Opens a gzip (.gz) file for writing.
- * The compression level parameter should be in 0..9
- * errno can be checked to distinguish two error cases
- * (if errno is zero, the zlib error is Z_MEM_ERROR).
- */
- void open(const char* name, int level = Z_DEFAULT_COMPRESSION) {
- char mode[4] = "wb\0";
- if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level;
- if (m_fp) close();
- m_fp = ::gzopen(name, mode);
- }
-
- /* open from a FILE pointer.
- */
- void open(FILE* fp, int level = Z_DEFAULT_COMPRESSION) {
- SET_BINARY_MODE(fp);
- char mode[4] = "wb\0";
- if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level;
- if (m_fp) close();
- m_fp = ::gzdopen(fileno(fp), mode);
- }
-
- /* Flushes all pending output if necessary, closes the compressed file
- * and deallocates all the (de)compression state. The return value is
- * the zlib error number (see function error() below).
- */
- int close() {
- if (m_os) {
- ::gzwrite(m_fp, m_os->str(), m_os->pcount());
- delete[] m_os->str(); delete m_os; m_os = 0;
- }
- int r = ::gzclose(m_fp); m_fp = 0; return r;
- }
-
- /* Binary write the given number of bytes into the compressed file.
- */
- int write(const void* buf, size_t len) {
- return ::gzwrite(m_fp, (voidp) buf, len);
- }
-
- /* Flushes all pending output into the compressed file. The parameter
- * _flush is as in the deflate() function. The return value is the zlib
- * error number (see function gzerror below). flush() returns Z_OK if
- * the flush_ parameter is Z_FINISH and all output could be flushed.
- * flush() should be called only when strictly necessary because it can
- * degrade compression.
- */
- int flush(int _flush) {
- os_flush();
- return ::gzflush(m_fp, _flush);
- }
-
- /* Returns the error message for the last error which occurred on the
- * given compressed file. errnum is set to zlib error number. If an
- * error occurred in the file system and not in the compression library,
- * errnum is set to Z_ERRNO and the application may consult errno
- * to get the exact error code.
- */
- const char* error(int* errnum) {
- return ::gzerror(m_fp, errnum);
- }
-
- gzFile fp() { return m_fp; }
-
- ostream& os() {
- if (m_os == 0) m_os = new ostrstream;
- return *m_os;
- }
-
- void os_flush() {
- if (m_os && m_os->pcount()>0) {
- ostrstream* oss = new ostrstream;
- oss->fill(m_os->fill());
- oss->flags(m_os->flags());
- oss->precision(m_os->precision());
- oss->width(m_os->width());
- ::gzwrite(m_fp, m_os->str(), m_os->pcount());
- delete[] m_os->str(); delete m_os; m_os = oss;
- }
- }
-
- private:
- gzFile m_fp;
- ostrstream* m_os;
-};
-
-/*
- * Binary write the given (array of) object(s) into the compressed file.
- * returns the number of uncompressed bytes actually written
- * (0 in case of error).
- */
-template <class T, class Items>
-inline int write(ozstream& zs, const T* x, Items items) {
- return ::gzwrite(zs.fp(), (voidp) x, items*sizeof(T));
-}
-
-/*
- * Binary output with the '<' operator.
- */
-template <class T>
-inline ozstream& operator<(ozstream& zs, const T& x) {
- ::gzwrite(zs.fp(), (voidp) &x, sizeof(T));
- return zs;
-}
-
-inline zstringlen::zstringlen(ozstream& zs, const char* x) {
- val.byte = 255; val.word = ::strlen(x);
- if (val.word < 255) zs < (val.byte = val.word);
- else zs < val;
-}
-
-/*
- * Write length of string + the string with the '<' operator.
- */
-inline ozstream& operator<(ozstream& zs, const char* x) {
- zstringlen len(zs, x);
- ::gzwrite(zs.fp(), (voidp) x, len.value());
- return zs;
-}
-
-#ifdef _MSC_VER
-inline ozstream& operator<(ozstream& zs, char* const& x) {
- return zs < (const char*) x;
-}
-#endif
-
-/*
- * Ascii write with the << operator;
- */
-template <class T>
-inline ostream& operator<<(ozstream& zs, const T& x) {
- zs.os_flush();
- return zs.os() << x;
-}
-
-#endif
diff --git a/source4/lib/zlib/contrib/iostream2/zstream_test.cpp b/source4/lib/zlib/contrib/iostream2/zstream_test.cpp
deleted file mode 100644
index 6273f62d62..0000000000
--- a/source4/lib/zlib/contrib/iostream2/zstream_test.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-#include "zstream.h"
-#include <math.h>
-#include <stdlib.h>
-#include <iomanip.h>
-
-void main() {
- char h[256] = "Hello";
- char* g = "Goodbye";
- ozstream out("temp.gz");
- out < "This works well" < h < g;
- out.close();
-
- izstream in("temp.gz"); // read it back
- char *x = read_string(in), *y = new char[256], z[256];
- in > y > z;
- in.close();
- cout << x << endl << y << endl << z << endl;
-
- out.open("temp.gz"); // try ascii output; zcat temp.gz to see the results
- out << setw(50) << setfill('#') << setprecision(20) << x << endl << y << endl << z << endl;
- out << z << endl << y << endl << x << endl;
- out << 1.1234567890123456789 << endl;
-
- delete[] x; delete[] y;
-}
diff --git a/source4/lib/zlib/contrib/iostream3/README b/source4/lib/zlib/contrib/iostream3/README
deleted file mode 100644
index f7b319ab91..0000000000
--- a/source4/lib/zlib/contrib/iostream3/README
+++ /dev/null
@@ -1,35 +0,0 @@
-These classes provide a C++ stream interface to the zlib library. It allows you
-to do things like:
-
- gzofstream outf("blah.gz");
- outf << "These go into the gzip file " << 123 << endl;
-
-It does this by deriving a specialized stream buffer for gzipped files, which is
-the way Stroustrup would have done it. :->
-
-The gzifstream and gzofstream classes were originally written by Kevin Ruland
-and made available in the zlib contrib/iostream directory. The older version still
-compiles under gcc 2.xx, but not under gcc 3.xx, which sparked the development of
-this version.
-
-The new classes are as standard-compliant as possible, closely following the
-approach of the standard library's fstream classes. It compiles under gcc versions
-3.2 and 3.3, but not under gcc 2.xx. This is mainly due to changes in the standard
-library naming scheme. The new version of gzifstream/gzofstream/gzfilebuf differs
-from the previous one in the following respects:
-- added showmanyc
-- added setbuf, with support for unbuffered output via setbuf(0,0)
-- a few bug fixes of stream behavior
-- gzipped output file opened with default compression level instead of maximum level
-- setcompressionlevel()/strategy() members replaced by single setcompression()
-
-The code is provided "as is", with the permission to use, copy, modify, distribute
-and sell it for any purpose without fee.
-
-Ludwig Schwardt
-<schwardt@sun.ac.za>
-
-DSP Lab
-Electrical & Electronic Engineering Department
-University of Stellenbosch
-South Africa
diff --git a/source4/lib/zlib/contrib/iostream3/TODO b/source4/lib/zlib/contrib/iostream3/TODO
deleted file mode 100644
index 7032f97be0..0000000000
--- a/source4/lib/zlib/contrib/iostream3/TODO
+++ /dev/null
@@ -1,17 +0,0 @@
-Possible upgrades to gzfilebuf:
-
-- The ability to do putback (e.g. putbackfail)
-
-- The ability to seek (zlib supports this, but could be slow/tricky)
-
-- Simultaneous read/write access (does it make sense?)
-
-- Support for ios_base::ate open mode
-
-- Locale support?
-
-- Check public interface to see which calls give problems
- (due to dependence on library internals)
-
-- Override operator<<(ostream&, gzfilebuf*) to allow direct copying
- of stream buffer to stream ( i.e. os << is.rdbuf(); )
diff --git a/source4/lib/zlib/contrib/iostream3/test.cc b/source4/lib/zlib/contrib/iostream3/test.cc
deleted file mode 100644
index 94235334f2..0000000000
--- a/source4/lib/zlib/contrib/iostream3/test.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Test program for gzifstream and gzofstream
- *
- * by Ludwig Schwardt <schwardt@sun.ac.za>
- * original version by Kevin Ruland <kevin@rodin.wustl.edu>
- */
-
-#include "zfstream.h"
-#include <iostream> // for cout
-
-int main() {
-
- gzofstream outf;
- gzifstream inf;
- char buf[80];
-
- outf.open("test1.txt.gz");
- outf << "The quick brown fox sidestepped the lazy canine\n"
- << 1.3 << "\nPlan " << 9 << std::endl;
- outf.close();
- std::cout << "Wrote the following message to 'test1.txt.gz' (check with zcat or zless):\n"
- << "The quick brown fox sidestepped the lazy canine\n"
- << 1.3 << "\nPlan " << 9 << std::endl;
-
- std::cout << "\nReading 'test1.txt.gz' (buffered) produces:\n";
- inf.open("test1.txt.gz");
- while (inf.getline(buf,80,'\n')) {
- std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n";
- }
- inf.close();
-
- outf.rdbuf()->pubsetbuf(0,0);
- outf.open("test2.txt.gz");
- outf << setcompression(Z_NO_COMPRESSION)
- << "The quick brown fox sidestepped the lazy canine\n"
- << 1.3 << "\nPlan " << 9 << std::endl;
- outf.close();
- std::cout << "\nWrote the same message to 'test2.txt.gz' in uncompressed form";
-
- std::cout << "\nReading 'test2.txt.gz' (unbuffered) produces:\n";
- inf.rdbuf()->pubsetbuf(0,0);
- inf.open("test2.txt.gz");
- while (inf.getline(buf,80,'\n')) {
- std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n";
- }
- inf.close();
-
- return 0;
-
-}
diff --git a/source4/lib/zlib/contrib/iostream3/zfstream.cc b/source4/lib/zlib/contrib/iostream3/zfstream.cc
deleted file mode 100644
index 94eb933444..0000000000
--- a/source4/lib/zlib/contrib/iostream3/zfstream.cc
+++ /dev/null
@@ -1,479 +0,0 @@
-/*
- * A C++ I/O streams interface to the zlib gz* functions
- *
- * by Ludwig Schwardt <schwardt@sun.ac.za>
- * original version by Kevin Ruland <kevin@rodin.wustl.edu>
- *
- * This version is standard-compliant and compatible with gcc 3.x.
- */
-
-#include "zfstream.h"
-#include <cstring> // for strcpy, strcat, strlen (mode strings)
-#include <cstdio> // for BUFSIZ
-
-// Internal buffer sizes (default and "unbuffered" versions)
-#define BIGBUFSIZE BUFSIZ
-#define SMALLBUFSIZE 1
-
-/*****************************************************************************/
-
-// Default constructor
-gzfilebuf::gzfilebuf()
-: file(NULL), io_mode(std::ios_base::openmode(0)), own_fd(false),
- buffer(NULL), buffer_size(BIGBUFSIZE), own_buffer(true)
-{
- // No buffers to start with
- this->disable_buffer();
-}
-
-// Destructor
-gzfilebuf::~gzfilebuf()
-{
- // Sync output buffer and close only if responsible for file
- // (i.e. attached streams should be left open at this stage)
- this->sync();
- if (own_fd)
- this->close();
- // Make sure internal buffer is deallocated
- this->disable_buffer();
-}
-
-// Set compression level and strategy
-int
-gzfilebuf::setcompression(int comp_level,
- int comp_strategy)
-{
- return gzsetparams(file, comp_level, comp_strategy);
-}
-
-// Open gzipped file
-gzfilebuf*
-gzfilebuf::open(const char *name,
- std::ios_base::openmode mode)
-{
- // Fail if file already open
- if (this->is_open())
- return NULL;
- // Don't support simultaneous read/write access (yet)
- if ((mode & std::ios_base::in) && (mode & std::ios_base::out))
- return NULL;
-
- // Build mode string for gzopen and check it [27.8.1.3.2]
- char char_mode[6] = "\0\0\0\0\0";
- if (!this->open_mode(mode, char_mode))
- return NULL;
-
- // Attempt to open file
- if ((file = gzopen(name, char_mode)) == NULL)
- return NULL;
-
- // On success, allocate internal buffer and set flags
- this->enable_buffer();
- io_mode = mode;
- own_fd = true;
- return this;
-}
-
-// Attach to gzipped file
-gzfilebuf*
-gzfilebuf::attach(int fd,
- std::ios_base::openmode mode)
-{
- // Fail if file already open
- if (this->is_open())
- return NULL;
- // Don't support simultaneous read/write access (yet)
- if ((mode & std::ios_base::in) && (mode & std::ios_base::out))
- return NULL;
-
- // Build mode string for gzdopen and check it [27.8.1.3.2]
- char char_mode[6] = "\0\0\0\0\0";
- if (!this->open_mode(mode, char_mode))
- return NULL;
-
- // Attempt to attach to file
- if ((file = gzdopen(fd, char_mode)) == NULL)
- return NULL;
-
- // On success, allocate internal buffer and set flags
- this->enable_buffer();
- io_mode = mode;
- own_fd = false;
- return this;
-}
-
-// Close gzipped file
-gzfilebuf*
-gzfilebuf::close()
-{
- // Fail immediately if no file is open
- if (!this->is_open())
- return NULL;
- // Assume success
- gzfilebuf* retval = this;
- // Attempt to sync and close gzipped file
- if (this->sync() == -1)
- retval = NULL;
- if (gzclose(file) < 0)
- retval = NULL;
- // File is now gone anyway (postcondition [27.8.1.3.8])
- file = NULL;
- own_fd = false;
- // Destroy internal buffer if it exists
- this->disable_buffer();
- return retval;
-}
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-// Convert int open mode to mode string
-bool
-gzfilebuf::open_mode(std::ios_base::openmode mode,
- char* c_mode) const
-{
- bool testb = mode & std::ios_base::binary;
- bool testi = mode & std::ios_base::in;
- bool testo = mode & std::ios_base::out;
- bool testt = mode & std::ios_base::trunc;
- bool testa = mode & std::ios_base::app;
-
- // Check for valid flag combinations - see [27.8.1.3.2] (Table 92)
- // Original zfstream hardcoded the compression level to maximum here...
- // Double the time for less than 1% size improvement seems
- // excessive though - keeping it at the default level
- // To change back, just append "9" to the next three mode strings
- if (!testi && testo && !testt && !testa)
- strcpy(c_mode, "w");
- if (!testi && testo && !testt && testa)
- strcpy(c_mode, "a");
- if (!testi && testo && testt && !testa)
- strcpy(c_mode, "w");
- if (testi && !testo && !testt && !testa)
- strcpy(c_mode, "r");
- // No read/write mode yet
-// if (testi && testo && !testt && !testa)
-// strcpy(c_mode, "r+");
-// if (testi && testo && testt && !testa)
-// strcpy(c_mode, "w+");
-
- // Mode string should be empty for invalid combination of flags
- if (strlen(c_mode) == 0)
- return false;
- if (testb)
- strcat(c_mode, "b");
- return true;
-}
-
-// Determine number of characters in internal get buffer
-std::streamsize
-gzfilebuf::showmanyc()
-{
- // Calls to underflow will fail if file not opened for reading
- if (!this->is_open() || !(io_mode & std::ios_base::in))
- return -1;
- // Make sure get area is in use
- if (this->gptr() && (this->gptr() < this->egptr()))
- return std::streamsize(this->egptr() - this->gptr());
- else
- return 0;
-}
-
-// Fill get area from gzipped file
-gzfilebuf::int_type
-gzfilebuf::underflow()
-{
- // If something is left in the get area by chance, return it
- // (this shouldn't normally happen, as underflow is only supposed
- // to be called when gptr >= egptr, but it serves as error check)
- if (this->gptr() && (this->gptr() < this->egptr()))
- return traits_type::to_int_type(*(this->gptr()));
-
- // If the file hasn't been opened for reading, produce error
- if (!this->is_open() || !(io_mode & std::ios_base::in))
- return traits_type::eof();
-
- // Attempt to fill internal buffer from gzipped file
- // (buffer must be guaranteed to exist...)
- int bytes_read = gzread(file, buffer, buffer_size);
- // Indicates error or EOF
- if (bytes_read <= 0)
- {
- // Reset get area
- this->setg(buffer, buffer, buffer);
- return traits_type::eof();
- }
- // Make all bytes read from file available as get area
- this->setg(buffer, buffer, buffer + bytes_read);
-
- // Return next character in get area
- return traits_type::to_int_type(*(this->gptr()));
-}
-
-// Write put area to gzipped file
-gzfilebuf::int_type
-gzfilebuf::overflow(int_type c)
-{
- // Determine whether put area is in use
- if (this->pbase())
- {
- // Double-check pointer range
- if (this->pptr() > this->epptr() || this->pptr() < this->pbase())
- return traits_type::eof();
- // Add extra character to buffer if not EOF
- if (!traits_type::eq_int_type(c, traits_type::eof()))
- {
- *(this->pptr()) = traits_type::to_char_type(c);
- this->pbump(1);
- }
- // Number of characters to write to file
- int bytes_to_write = this->pptr() - this->pbase();
- // Overflow doesn't fail if nothing is to be written
- if (bytes_to_write > 0)
- {
- // If the file hasn't been opened for writing, produce error
- if (!this->is_open() || !(io_mode & std::ios_base::out))
- return traits_type::eof();
- // If gzipped file won't accept all bytes written to it, fail
- if (gzwrite(file, this->pbase(), bytes_to_write) != bytes_to_write)
- return traits_type::eof();
- // Reset next pointer to point to pbase on success
- this->pbump(-bytes_to_write);
- }
- }
- // Write extra character to file if not EOF
- else if (!traits_type::eq_int_type(c, traits_type::eof()))
- {
- // If the file hasn't been opened for writing, produce error
- if (!this->is_open() || !(io_mode & std::ios_base::out))
- return traits_type::eof();
- // Impromptu char buffer (allows "unbuffered" output)
- char_type last_char = traits_type::to_char_type(c);
- // If gzipped file won't accept this character, fail
- if (gzwrite(file, &last_char, 1) != 1)
- return traits_type::eof();
- }
-
- // If you got here, you have succeeded (even if c was EOF)
- // The return value should therefore be non-EOF
- if (traits_type::eq_int_type(c, traits_type::eof()))
- return traits_type::not_eof(c);
- else
- return c;
-}
-
-// Assign new buffer
-std::streambuf*
-gzfilebuf::setbuf(char_type* p,
- std::streamsize n)
-{
- // First make sure stuff is sync'ed, for safety
- if (this->sync() == -1)
- return NULL;
- // If buffering is turned off on purpose via setbuf(0,0), still allocate one...
- // "Unbuffered" only really refers to put [27.8.1.4.10], while get needs at
- // least a buffer of size 1 (very inefficient though, therefore make it bigger?)
- // This follows from [27.5.2.4.3]/12 (gptr needs to point at something, it seems)
- if (!p || !n)
- {
- // Replace existing buffer (if any) with small internal buffer
- this->disable_buffer();
- buffer = NULL;
- buffer_size = 0;
- own_buffer = true;
- this->enable_buffer();
- }
- else
- {
- // Replace existing buffer (if any) with external buffer
- this->disable_buffer();
- buffer = p;
- buffer_size = n;
- own_buffer = false;
- this->enable_buffer();
- }
- return this;
-}
-
-// Write put area to gzipped file (i.e. ensures that put area is empty)
-int
-gzfilebuf::sync()
-{
- return traits_type::eq_int_type(this->overflow(), traits_type::eof()) ? -1 : 0;
-}
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-// Allocate internal buffer
-void
-gzfilebuf::enable_buffer()
-{
- // If internal buffer required, allocate one
- if (own_buffer && !buffer)
- {
- // Check for buffered vs. "unbuffered"
- if (buffer_size > 0)
- {
- // Allocate internal buffer
- buffer = new char_type[buffer_size];
- // Get area starts empty and will be expanded by underflow as need arises
- this->setg(buffer, buffer, buffer);
- // Setup entire internal buffer as put area.
- // The one-past-end pointer actually points to the last element of the buffer,
- // so that overflow(c) can safely add the extra character c to the sequence.
- // These pointers remain in place for the duration of the buffer
- this->setp(buffer, buffer + buffer_size - 1);
- }
- else
- {
- // Even in "unbuffered" case, (small?) get buffer is still required
- buffer_size = SMALLBUFSIZE;
- buffer = new char_type[buffer_size];
- this->setg(buffer, buffer, buffer);
- // "Unbuffered" means no put buffer
- this->setp(0, 0);
- }
- }
- else
- {
- // If buffer already allocated, reset buffer pointers just to make sure no
- // stale chars are lying around
- this->setg(buffer, buffer, buffer);
- this->setp(buffer, buffer + buffer_size - 1);
- }
-}
-
-// Destroy internal buffer
-void
-gzfilebuf::disable_buffer()
-{
- // If internal buffer exists, deallocate it
- if (own_buffer && buffer)
- {
- // Preserve unbuffered status by zeroing size
- if (!this->pbase())
- buffer_size = 0;
- delete[] buffer;
- buffer = NULL;
- this->setg(0, 0, 0);
- this->setp(0, 0);
- }
- else
- {
- // Reset buffer pointers to initial state if external buffer exists
- this->setg(buffer, buffer, buffer);
- if (buffer)
- this->setp(buffer, buffer + buffer_size - 1);
- else
- this->setp(0, 0);
- }
-}
-
-/*****************************************************************************/
-
-// Default constructor initializes stream buffer
-gzifstream::gzifstream()
-: std::istream(NULL), sb()
-{ this->init(&sb); }
-
-// Initialize stream buffer and open file
-gzifstream::gzifstream(const char* name,
- std::ios_base::openmode mode)
-: std::istream(NULL), sb()
-{
- this->init(&sb);
- this->open(name, mode);
-}
-
-// Initialize stream buffer and attach to file
-gzifstream::gzifstream(int fd,
- std::ios_base::openmode mode)
-: std::istream(NULL), sb()
-{
- this->init(&sb);
- this->attach(fd, mode);
-}
-
-// Open file and go into fail() state if unsuccessful
-void
-gzifstream::open(const char* name,
- std::ios_base::openmode mode)
-{
- if (!sb.open(name, mode | std::ios_base::in))
- this->setstate(std::ios_base::failbit);
- else
- this->clear();
-}
-
-// Attach to file and go into fail() state if unsuccessful
-void
-gzifstream::attach(int fd,
- std::ios_base::openmode mode)
-{
- if (!sb.attach(fd, mode | std::ios_base::in))
- this->setstate(std::ios_base::failbit);
- else
- this->clear();
-}
-
-// Close file
-void
-gzifstream::close()
-{
- if (!sb.close())
- this->setstate(std::ios_base::failbit);
-}
-
-/*****************************************************************************/
-
-// Default constructor initializes stream buffer
-gzofstream::gzofstream()
-: std::ostream(NULL), sb()
-{ this->init(&sb); }
-
-// Initialize stream buffer and open file
-gzofstream::gzofstream(const char* name,
- std::ios_base::openmode mode)
-: std::ostream(NULL), sb()
-{
- this->init(&sb);
- this->open(name, mode);
-}
-
-// Initialize stream buffer and attach to file
-gzofstream::gzofstream(int fd,
- std::ios_base::openmode mode)
-: std::ostream(NULL), sb()
-{
- this->init(&sb);
- this->attach(fd, mode);
-}
-
-// Open file and go into fail() state if unsuccessful
-void
-gzofstream::open(const char* name,
- std::ios_base::openmode mode)
-{
- if (!sb.open(name, mode | std::ios_base::out))
- this->setstate(std::ios_base::failbit);
- else
- this->clear();
-}
-
-// Attach to file and go into fail() state if unsuccessful
-void
-gzofstream::attach(int fd,
- std::ios_base::openmode mode)
-{
- if (!sb.attach(fd, mode | std::ios_base::out))
- this->setstate(std::ios_base::failbit);
- else
- this->clear();
-}
-
-// Close file
-void
-gzofstream::close()
-{
- if (!sb.close())
- this->setstate(std::ios_base::failbit);
-}
diff --git a/source4/lib/zlib/contrib/iostream3/zfstream.h b/source4/lib/zlib/contrib/iostream3/zfstream.h
deleted file mode 100644
index 8574479ae1..0000000000
--- a/source4/lib/zlib/contrib/iostream3/zfstream.h
+++ /dev/null
@@ -1,466 +0,0 @@
-/*
- * A C++ I/O streams interface to the zlib gz* functions
- *
- * by Ludwig Schwardt <schwardt@sun.ac.za>
- * original version by Kevin Ruland <kevin@rodin.wustl.edu>
- *
- * This version is standard-compliant and compatible with gcc 3.x.
- */
-
-#ifndef ZFSTREAM_H
-#define ZFSTREAM_H
-
-#include <istream> // not iostream, since we don't need cin/cout
-#include <ostream>
-#include "zlib.h"
-
-/*****************************************************************************/
-
-/**
- * @brief Gzipped file stream buffer class.
- *
- * This class implements basic_filebuf for gzipped files. It doesn't yet support
- * seeking (allowed by zlib but slow/limited), putback and read/write access
- * (tricky). Otherwise, it attempts to be a drop-in replacement for the standard
- * file streambuf.
-*/
-class gzfilebuf : public std::streambuf
-{
-public:
- // Default constructor.
- gzfilebuf();
-
- // Destructor.
- virtual
- ~gzfilebuf();
-
- /**
- * @brief Set compression level and strategy on the fly.
- * @param comp_level Compression level (see zlib.h for allowed values)
- * @param comp_strategy Compression strategy (see zlib.h for allowed values)
- * @return Z_OK on success, Z_STREAM_ERROR otherwise.
- *
- * Unfortunately, these parameters cannot be modified separately, as the
- * previous zfstream version assumed. Since the strategy is seldom changed,
- * it can default and setcompression(level) then becomes like the old
- * setcompressionlevel(level).
- */
- int
- setcompression(int comp_level,
- int comp_strategy = Z_DEFAULT_STRATEGY);
-
- /**
- * @brief Check if file is open.
- * @return True if file is open.
- */
- bool
- is_open() const { return (file != NULL); }
-
- /**
- * @brief Open gzipped file.
- * @param name File name.
- * @param mode Open mode flags.
- * @return @c this on success, NULL on failure.
- */
- gzfilebuf*
- open(const char* name,
- std::ios_base::openmode mode);
-
- /**
- * @brief Attach to already open gzipped file.
- * @param fd File descriptor.
- * @param mode Open mode flags.
- * @return @c this on success, NULL on failure.
- */
- gzfilebuf*
- attach(int fd,
- std::ios_base::openmode mode);
-
- /**
- * @brief Close gzipped file.
- * @return @c this on success, NULL on failure.
- */
- gzfilebuf*
- close();
-
-protected:
- /**
- * @brief Convert ios open mode int to mode string used by zlib.
- * @return True if valid mode flag combination.
- */
- bool
- open_mode(std::ios_base::openmode mode,
- char* c_mode) const;
-
- /**
- * @brief Number of characters available in stream buffer.
- * @return Number of characters.
- *
- * This indicates number of characters in get area of stream buffer.
- * These characters can be read without accessing the gzipped file.
- */
- virtual std::streamsize
- showmanyc();
-
- /**
- * @brief Fill get area from gzipped file.
- * @return First character in get area on success, EOF on error.
- *
- * This actually reads characters from gzipped file to stream
- * buffer. Always buffered.
- */
- virtual int_type
- underflow();
-
- /**
- * @brief Write put area to gzipped file.
- * @param c Extra character to add to buffer contents.
- * @return Non-EOF on success, EOF on error.
- *
- * This actually writes characters in stream buffer to
- * gzipped file. With unbuffered output this is done one
- * character at a time.
- */
- virtual int_type
- overflow(int_type c = traits_type::eof());
-
- /**
- * @brief Installs external stream buffer.
- * @param p Pointer to char buffer.
- * @param n Size of external buffer.
- * @return @c this on success, NULL on failure.
- *
- * Call setbuf(0,0) to enable unbuffered output.
- */
- virtual std::streambuf*
- setbuf(char_type* p,
- std::streamsize n);
-
- /**
- * @brief Flush stream buffer to file.
- * @return 0 on success, -1 on error.
- *
- * This calls underflow(EOF) to do the job.
- */
- virtual int
- sync();
-
-//
-// Some future enhancements
-//
-// virtual int_type uflow();
-// virtual int_type pbackfail(int_type c = traits_type::eof());
-// virtual pos_type
-// seekoff(off_type off,
-// std::ios_base::seekdir way,
-// std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out);
-// virtual pos_type
-// seekpos(pos_type sp,
-// std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out);
-
-private:
- /**
- * @brief Allocate internal buffer.
- *
- * This function is safe to call multiple times. It will ensure
- * that a proper internal buffer exists if it is required. If the
- * buffer already exists or is external, the buffer pointers will be
- * reset to their original state.
- */
- void
- enable_buffer();
-
- /**
- * @brief Destroy internal buffer.
- *
- * This function is safe to call multiple times. It will ensure
- * that the internal buffer is deallocated if it exists. In any
- * case, it will also reset the buffer pointers.
- */
- void
- disable_buffer();
-
- /**
- * Underlying file pointer.
- */
- gzFile file;
-
- /**
- * Mode in which file was opened.
- */
- std::ios_base::openmode io_mode;
-
- /**
- * @brief True if this object owns file descriptor.
- *
- * This makes the class responsible for closing the file
- * upon destruction.
- */
- bool own_fd;
-
- /**
- * @brief Stream buffer.
- *
- * For simplicity this remains allocated on the free store for the
- * entire life span of the gzfilebuf object, unless replaced by setbuf.
- */
- char_type* buffer;
-
- /**
- * @brief Stream buffer size.
- *
- * Defaults to system default buffer size (typically 8192 bytes).
- * Modified by setbuf.
- */
- std::streamsize buffer_size;
-
- /**
- * @brief True if this object owns stream buffer.
- *
- * This makes the class responsible for deleting the buffer
- * upon destruction.
- */
- bool own_buffer;
-};
-
-/*****************************************************************************/
-
-/**
- * @brief Gzipped file input stream class.
- *
- * This class implements ifstream for gzipped files. Seeking and putback
- * is not supported yet.
-*/
-class gzifstream : public std::istream
-{
-public:
- // Default constructor
- gzifstream();
-
- /**
- * @brief Construct stream on gzipped file to be opened.
- * @param name File name.
- * @param mode Open mode flags (forced to contain ios::in).
- */
- explicit
- gzifstream(const char* name,
- std::ios_base::openmode mode = std::ios_base::in);
-
- /**
- * @brief Construct stream on already open gzipped file.
- * @param fd File descriptor.
- * @param mode Open mode flags (forced to contain ios::in).
- */
- explicit
- gzifstream(int fd,
- std::ios_base::openmode mode = std::ios_base::in);
-
- /**
- * Obtain underlying stream buffer.
- */
- gzfilebuf*
- rdbuf() const
- { return const_cast<gzfilebuf*>(&sb); }
-
- /**
- * @brief Check if file is open.
- * @return True if file is open.
- */
- bool
- is_open() { return sb.is_open(); }
-
- /**
- * @brief Open gzipped file.
- * @param name File name.
- * @param mode Open mode flags (forced to contain ios::in).
- *
- * Stream will be in state good() if file opens successfully;
- * otherwise in state fail(). This differs from the behavior of
- * ifstream, which never sets the state to good() and therefore
- * won't allow you to reuse the stream for a second file unless
- * you manually clear() the state. The choice is a matter of
- * convenience.
- */
- void
- open(const char* name,
- std::ios_base::openmode mode = std::ios_base::in);
-
- /**
- * @brief Attach to already open gzipped file.
- * @param fd File descriptor.
- * @param mode Open mode flags (forced to contain ios::in).
- *
- * Stream will be in state good() if attach succeeded; otherwise
- * in state fail().
- */
- void
- attach(int fd,
- std::ios_base::openmode mode = std::ios_base::in);
-
- /**
- * @brief Close gzipped file.
- *
- * Stream will be in state fail() if close failed.
- */
- void
- close();
-
-private:
- /**
- * Underlying stream buffer.
- */
- gzfilebuf sb;
-};
-
-/*****************************************************************************/
-
-/**
- * @brief Gzipped file output stream class.
- *
- * This class implements ofstream for gzipped files. Seeking and putback
- * is not supported yet.
-*/
-class gzofstream : public std::ostream
-{
-public:
- // Default constructor
- gzofstream();
-
- /**
- * @brief Construct stream on gzipped file to be opened.
- * @param name File name.
- * @param mode Open mode flags (forced to contain ios::out).
- */
- explicit
- gzofstream(const char* name,
- std::ios_base::openmode mode = std::ios_base::out);
-
- /**
- * @brief Construct stream on already open gzipped file.
- * @param fd File descriptor.
- * @param mode Open mode flags (forced to contain ios::out).
- */
- explicit
- gzofstream(int fd,
- std::ios_base::openmode mode = std::ios_base::out);
-
- /**
- * Obtain underlying stream buffer.
- */
- gzfilebuf*
- rdbuf() const
- { return const_cast<gzfilebuf*>(&sb); }
-
- /**
- * @brief Check if file is open.
- * @return True if file is open.
- */
- bool
- is_open() { return sb.is_open(); }
-
- /**
- * @brief Open gzipped file.
- * @param name File name.
- * @param mode Open mode flags (forced to contain ios::out).
- *
- * Stream will be in state good() if file opens successfully;
- * otherwise in state fail(). This differs from the behavior of
- * ofstream, which never sets the state to good() and therefore
- * won't allow you to reuse the stream for a second file unless
- * you manually clear() the state. The choice is a matter of
- * convenience.
- */
- void
- open(const char* name,
- std::ios_base::openmode mode = std::ios_base::out);
-
- /**
- * @brief Attach to already open gzipped file.
- * @param fd File descriptor.
- * @param mode Open mode flags (forced to contain ios::out).
- *
- * Stream will be in state good() if attach succeeded; otherwise
- * in state fail().
- */
- void
- attach(int fd,
- std::ios_base::openmode mode = std::ios_base::out);
-
- /**
- * @brief Close gzipped file.
- *
- * Stream will be in state fail() if close failed.
- */
- void
- close();
-
-private:
- /**
- * Underlying stream buffer.
- */
- gzfilebuf sb;
-};
-
-/*****************************************************************************/
-
-/**
- * @brief Gzipped file output stream manipulator class.
- *
- * This class defines a two-argument manipulator for gzofstream. It is used
- * as base for the setcompression(int,int) manipulator.
-*/
-template<typename T1, typename T2>
- class gzomanip2
- {
- public:
- // Allows insertor to peek at internals
- template <typename Ta, typename Tb>
- friend gzofstream&
- operator<<(gzofstream&,
- const gzomanip2<Ta,Tb>&);
-
- // Constructor
- gzomanip2(gzofstream& (*f)(gzofstream&, T1, T2),
- T1 v1,
- T2 v2);
- private:
- // Underlying manipulator function
- gzofstream&
- (*func)(gzofstream&, T1, T2);
-
- // Arguments for manipulator function
- T1 val1;
- T2 val2;
- };
-
-/*****************************************************************************/
-
-// Manipulator function thunks through to stream buffer
-inline gzofstream&
-setcompression(gzofstream &gzs, int l, int s = Z_DEFAULT_STRATEGY)
-{
- (gzs.rdbuf())->setcompression(l, s);
- return gzs;
-}
-
-// Manipulator constructor stores arguments
-template<typename T1, typename T2>
- inline
- gzomanip2<T1,T2>::gzomanip2(gzofstream &(*f)(gzofstream &, T1, T2),
- T1 v1,
- T2 v2)
- : func(f), val1(v1), val2(v2)
- { }
-
-// Insertor applies underlying manipulator function to stream
-template<typename T1, typename T2>
- inline gzofstream&
- operator<<(gzofstream& s, const gzomanip2<T1,T2>& m)
- { return (*m.func)(s, m.val1, m.val2); }
-
-// Insert this onto stream to simplify setting of compression level
-inline gzomanip2<int,int>
-setcompression(int l, int s = Z_DEFAULT_STRATEGY)
-{ return gzomanip2<int,int>(&setcompression, l, s); }
-
-#endif // ZFSTREAM_H
diff --git a/source4/lib/zlib/contrib/masm686/match.asm b/source4/lib/zlib/contrib/masm686/match.asm
deleted file mode 100644
index 4b03a71abd..0000000000
--- a/source4/lib/zlib/contrib/masm686/match.asm
+++ /dev/null
@@ -1,413 +0,0 @@
-
-; match.asm -- Pentium-Pro optimized version of longest_match()
-;
-; Updated for zlib 1.1.3 and converted to MASM 6.1x
-; Copyright (C) 2000 Dan Higdon <hdan@kinesoft.com>
-; and Chuck Walbourn <chuckw@kinesoft.com>
-; Corrections by Cosmin Truta <cosmint@cs.ubbcluj.ro>
-;
-; This is free software; you can redistribute it and/or modify it
-; under the terms of the GNU General Public License.
-
-; Based on match.S
-; Written for zlib 1.1.2
-; Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com>
-;
-; Modified by Gilles Vollant (2005) for add gzhead and gzindex
-
- .686P
- .MODEL FLAT
-
-;===========================================================================
-; EQUATES
-;===========================================================================
-
-MAX_MATCH EQU 258
-MIN_MATCH EQU 3
-MIN_LOOKAHEAD EQU (MAX_MATCH + MIN_MATCH + 1)
-MAX_MATCH_8 EQU ((MAX_MATCH + 7) AND (NOT 7))
-
-;===========================================================================
-; STRUCTURES
-;===========================================================================
-
-; This STRUCT assumes a 4-byte alignment
-
-DEFLATE_STATE STRUCT
-ds_strm dd ?
-ds_status dd ?
-ds_pending_buf dd ?
-ds_pending_buf_size dd ?
-ds_pending_out dd ?
-ds_pending dd ?
-ds_wrap dd ?
-; gzhead and gzindex are added in zlib 1.2.2.2 (see deflate.h)
-ds_gzhead dd ?
-ds_gzindex dd ?
-ds_data_type db ?
-ds_method db ?
- db ? ; padding
- db ? ; padding
-ds_last_flush dd ?
-ds_w_size dd ? ; used
-ds_w_bits dd ?
-ds_w_mask dd ? ; used
-ds_window dd ? ; used
-ds_window_size dd ?
-ds_prev dd ? ; used
-ds_head dd ?
-ds_ins_h dd ?
-ds_hash_size dd ?
-ds_hash_bits dd ?
-ds_hash_mask dd ?
-ds_hash_shift dd ?
-ds_block_start dd ?
-ds_match_length dd ? ; used
-ds_prev_match dd ? ; used
-ds_match_available dd ?
-ds_strstart dd ? ; used
-ds_match_start dd ? ; used
-ds_lookahead dd ? ; used
-ds_prev_length dd ? ; used
-ds_max_chain_length dd ? ; used
-ds_max_laxy_match dd ?
-ds_level dd ?
-ds_strategy dd ?
-ds_good_match dd ? ; used
-ds_nice_match dd ? ; used
-
-; Don't need anymore of the struct for match
-DEFLATE_STATE ENDS
-
-;===========================================================================
-; CODE
-;===========================================================================
-_TEXT SEGMENT
-
-;---------------------------------------------------------------------------
-; match_init
-;---------------------------------------------------------------------------
- ALIGN 4
-PUBLIC _match_init
-_match_init PROC
- ; no initialization needed
- ret
-_match_init ENDP
-
-;---------------------------------------------------------------------------
-; uInt longest_match(deflate_state *deflatestate, IPos curmatch)
-;---------------------------------------------------------------------------
- ALIGN 4
-
-PUBLIC _longest_match
-_longest_match PROC
-
-; Since this code uses EBP for a scratch register, the stack frame must
-; be manually constructed and referenced relative to the ESP register.
-
-; Stack image
-; Variables
-chainlenwmask = 0 ; high word: current chain len
- ; low word: s->wmask
-window = 4 ; local copy of s->window
-windowbestlen = 8 ; s->window + bestlen
-scanend = 12 ; last two bytes of string
-scanstart = 16 ; first two bytes of string
-scanalign = 20 ; dword-misalignment of string
-nicematch = 24 ; a good enough match size
-bestlen = 28 ; size of best match so far
-scan = 32 ; ptr to string wanting match
-varsize = 36 ; number of bytes (also offset to last saved register)
-
-; Saved Registers (actually pushed into place)
-ebx_save = 36
-edi_save = 40
-esi_save = 44
-ebp_save = 48
-
-; Parameters
-retaddr = 52
-deflatestate = 56
-curmatch = 60
-
-; Save registers that the compiler may be using
- push ebp
- push edi
- push esi
- push ebx
-
-; Allocate local variable space
- sub esp,varsize
-
-; Retrieve the function arguments. ecx will hold cur_match
-; throughout the entire function. edx will hold the pointer to the
-; deflate_state structure during the function's setup (before
-; entering the main loop).
-
- mov edx, [esp+deflatestate]
-ASSUME edx:PTR DEFLATE_STATE
-
- mov ecx, [esp+curmatch]
-
-; uInt wmask = s->w_mask;
-; unsigned chain_length = s->max_chain_length;
-; if (s->prev_length >= s->good_match) {
-; chain_length >>= 2;
-; }
-
- mov eax, [edx].ds_prev_length
- mov ebx, [edx].ds_good_match
- cmp eax, ebx
- mov eax, [edx].ds_w_mask
- mov ebx, [edx].ds_max_chain_length
- jl SHORT LastMatchGood
- shr ebx, 2
-LastMatchGood:
-
-; chainlen is decremented once beforehand so that the function can
-; use the sign flag instead of the zero flag for the exit test.
-; It is then shifted into the high word, to make room for the wmask
-; value, which it will always accompany.
-
- dec ebx
- shl ebx, 16
- or ebx, eax
- mov [esp+chainlenwmask], ebx
-
-; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
-
- mov eax, [edx].ds_nice_match
- mov ebx, [edx].ds_lookahead
- cmp ebx, eax
- jl SHORT LookaheadLess
- mov ebx, eax
-LookaheadLess:
- mov [esp+nicematch], ebx
-
-;/* register Bytef *scan = s->window + s->strstart; */
-
- mov esi, [edx].ds_window
- mov [esp+window], esi
- mov ebp, [edx].ds_strstart
- lea edi, [esi+ebp]
- mov [esp+scan],edi
-
-;/* Determine how many bytes the scan ptr is off from being */
-;/* dword-aligned. */
-
- mov eax, edi
- neg eax
- and eax, 3
- mov [esp+scanalign], eax
-
-;/* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */
-;/* s->strstart - (IPos)MAX_DIST(s) : NIL; */
-
- mov eax, [edx].ds_w_size
- sub eax, MIN_LOOKAHEAD
- sub ebp, eax
- jg SHORT LimitPositive
- xor ebp, ebp
-LimitPositive:
-
-;/* int best_len = s->prev_length; */
-
- mov eax, [edx].ds_prev_length
- mov [esp+bestlen], eax
-
-;/* Store the sum of s->window + best_len in %esi locally, and in %esi. */
-
- add esi, eax
- mov [esp+windowbestlen], esi
-
-;/* register ush scan_start = *(ushf*)scan; */
-;/* register ush scan_end = *(ushf*)(scan+best_len-1); */
-;/* Posf *prev = s->prev; */
-
- movzx ebx, WORD PTR[edi]
- mov [esp+scanstart], ebx
- movzx ebx, WORD PTR[eax+edi-1]
- mov [esp+scanend], ebx
- mov edi, [edx].ds_prev
-
-;/* Jump into the main loop. */
-
- mov edx, [esp+chainlenwmask]
- jmp SHORT LoopEntry
-
-;/* do {
-; * match = s->window + cur_match;
-; * if (*(ushf*)(match+best_len-1) != scan_end ||
-; * *(ushf*)match != scan_start) continue;
-; * [...]
-; * } while ((cur_match = prev[cur_match & wmask]) > limit
-; * && --chain_length != 0);
-; *
-; * Here is the inner loop of the function. The function will spend the
-; * majority of its time in this loop, and majority of that time will
-; * be spent in the first ten instructions.
-; *
-; * Within this loop:
-; * %ebx = scanend
-; * %ecx = curmatch
-; * %edx = chainlenwmask - i.e., ((chainlen << 16) | wmask)
-; * %esi = windowbestlen - i.e., (window + bestlen)
-; * %edi = prev
-; * %ebp = limit
-; */
-
- ALIGN 4
-LookupLoop:
- and ecx, edx
- movzx ecx, WORD PTR[edi+ecx*2]
- cmp ecx, ebp
- jbe LeaveNow
- sub edx, 000010000H
- js LeaveNow
-
-LoopEntry:
- movzx eax, WORD PTR[esi+ecx-1]
- cmp eax, ebx
- jnz SHORT LookupLoop
-
- mov eax, [esp+window]
- movzx eax, WORD PTR[eax+ecx]
- cmp eax, [esp+scanstart]
- jnz SHORT LookupLoop
-
-;/* Store the current value of chainlen. */
-
- mov [esp+chainlenwmask], edx
-
-;/* Point %edi to the string under scrutiny, and %esi to the string we */
-;/* are hoping to match it up with. In actuality, %esi and %edi are */
-;/* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */
-;/* initialized to -(MAX_MATCH_8 - scanalign). */
-
- mov esi, [esp+window]
- mov edi, [esp+scan]
- add esi, ecx
- mov eax, [esp+scanalign]
- mov edx, -MAX_MATCH_8
- lea edi, [edi+eax+MAX_MATCH_8]
- lea esi, [esi+eax+MAX_MATCH_8]
-
-;/* Test the strings for equality, 8 bytes at a time. At the end,
-; * adjust %edx so that it is offset to the exact byte that mismatched.
-; *
-; * We already know at this point that the first three bytes of the
-; * strings match each other, and they can be safely passed over before
-; * starting the compare loop. So what this code does is skip over 0-3
-; * bytes, as much as necessary in order to dword-align the %edi
-; * pointer. (%esi will still be misaligned three times out of four.)
-; *
-; * It should be confessed that this loop usually does not represent
-; * much of the total running time. Replacing it with a more
-; * straightforward "rep cmpsb" would not drastically degrade
-; * performance.
-; */
-
-LoopCmps:
- mov eax, DWORD PTR[esi+edx]
- xor eax, DWORD PTR[edi+edx]
- jnz SHORT LeaveLoopCmps
-
- mov eax, DWORD PTR[esi+edx+4]
- xor eax, DWORD PTR[edi+edx+4]
- jnz SHORT LeaveLoopCmps4
-
- add edx, 8
- jnz SHORT LoopCmps
- jmp LenMaximum
- ALIGN 4
-
-LeaveLoopCmps4:
- add edx, 4
-
-LeaveLoopCmps:
- test eax, 00000FFFFH
- jnz SHORT LenLower
-
- add edx, 2
- shr eax, 16
-
-LenLower:
- sub al, 1
- adc edx, 0
-
-;/* Calculate the length of the match. If it is longer than MAX_MATCH, */
-;/* then automatically accept it as the best possible match and leave. */
-
- lea eax, [edi+edx]
- mov edi, [esp+scan]
- sub eax, edi
- cmp eax, MAX_MATCH
- jge SHORT LenMaximum
-
-;/* If the length of the match is not longer than the best match we */
-;/* have so far, then forget it and return to the lookup loop. */
-
- mov edx, [esp+deflatestate]
- mov ebx, [esp+bestlen]
- cmp eax, ebx
- jg SHORT LongerMatch
- mov esi, [esp+windowbestlen]
- mov edi, [edx].ds_prev
- mov ebx, [esp+scanend]
- mov edx, [esp+chainlenwmask]
- jmp LookupLoop
- ALIGN 4
-
-;/* s->match_start = cur_match; */
-;/* best_len = len; */
-;/* if (len >= nice_match) break; */
-;/* scan_end = *(ushf*)(scan+best_len-1); */
-
-LongerMatch:
- mov ebx, [esp+nicematch]
- mov [esp+bestlen], eax
- mov [edx].ds_match_start, ecx
- cmp eax, ebx
- jge SHORT LeaveNow
- mov esi, [esp+window]
- add esi, eax
- mov [esp+windowbestlen], esi
- movzx ebx, WORD PTR[edi+eax-1]
- mov edi, [edx].ds_prev
- mov [esp+scanend], ebx
- mov edx, [esp+chainlenwmask]
- jmp LookupLoop
- ALIGN 4
-
-;/* Accept the current string, with the maximum possible length. */
-
-LenMaximum:
- mov edx, [esp+deflatestate]
- mov DWORD PTR[esp+bestlen], MAX_MATCH
- mov [edx].ds_match_start, ecx
-
-;/* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */
-;/* return s->lookahead; */
-
-LeaveNow:
- mov edx, [esp+deflatestate]
- mov ebx, [esp+bestlen]
- mov eax, [edx].ds_lookahead
- cmp ebx, eax
- jg SHORT LookaheadRet
- mov eax, ebx
-LookaheadRet:
-
-; Restore the stack and return from whence we came.
-
- add esp, varsize
- pop ebx
- pop esi
- pop edi
- pop ebp
- ret
-
-_longest_match ENDP
-
-_TEXT ENDS
-END
diff --git a/source4/lib/zlib/contrib/masmx64/bld_ml64.bat b/source4/lib/zlib/contrib/masmx64/bld_ml64.bat
deleted file mode 100644
index 8f9343d0af..0000000000
--- a/source4/lib/zlib/contrib/masmx64/bld_ml64.bat
+++ /dev/null
@@ -1,2 +0,0 @@
-ml64.exe /Flinffasx64 /c /Zi inffasx64.asm
-ml64.exe /Flgvmat64 /c /Zi gvmat64.asm
diff --git a/source4/lib/zlib/contrib/masmx64/gvmat64.asm b/source4/lib/zlib/contrib/masmx64/gvmat64.asm
deleted file mode 100644
index 790d65554a..0000000000
--- a/source4/lib/zlib/contrib/masmx64/gvmat64.asm
+++ /dev/null
@@ -1,513 +0,0 @@
-;uInt longest_match_x64(
-; deflate_state *s,
-; IPos cur_match); /* current match */
-
-; gvmat64.asm -- Asm portion of the optimized longest_match for 32 bits x86
-; Copyright (C) 1995-2005 Jean-loup Gailly, Brian Raiter and Gilles Vollant.
-;
-; File written by Gilles Vollant, by converting to assembly the longest_match
-; from Jean-loup Gailly in deflate.c of zLib and infoZip zip.
-;
-; and by taking inspiration on asm686 with masm, optimised assembly code
-; from Brian Raiter, written 1998
-;
-; http://www.zlib.net
-; http://www.winimage.com/zLibDll
-; http://www.muppetlabs.com/~breadbox/software/assembly.html
-;
-; to compile this file for infozip Zip, I use option:
-; ml64.exe /Flgvmat64 /c /Zi /DINFOZIP gvmat64.asm
-;
-; to compile this file for zLib, I use option:
-; ml64.exe /Flgvmat64 /c /Zi gvmat64.asm
-; Be carrefull to adapt zlib1222add below to your version of zLib
-; (if you use a version of zLib before 1.0.4 or after 1.2.2.2, change
-; value of zlib1222add later)
-;
-; This file compile with Microsoft Macro Assembler (x64) for AMD64
-;
-; ml64.exe is given with Visual Studio 2005 and Windows 2003 server DDK
-;
-; (you can get Windows 2003 server DDK with ml64 and cl for AMD64 from
-; http://www.microsoft.com/whdc/devtools/ddk/default.mspx for low price)
-;
-
-
-;uInt longest_match(s, cur_match)
-; deflate_state *s;
-; IPos cur_match; /* current match */
-.code
-longest_match PROC
-
-
-;LocalVarsSize equ 88
- LocalVarsSize equ 72
-
-; register used : rax,rbx,rcx,rdx,rsi,rdi,r8,r9,r10,r11,r12
-; free register : r14,r15
-; register can be saved : rsp
-
- chainlenwmask equ rsp + 8 - LocalVarsSize ; high word: current chain len
- ; low word: s->wmask
-;window equ rsp + xx - LocalVarsSize ; local copy of s->window ; stored in r10
-;windowbestlen equ rsp + xx - LocalVarsSize ; s->window + bestlen , use r10+r11
-;scanstart equ rsp + xx - LocalVarsSize ; first two bytes of string ; stored in r12w
-;scanend equ rsp + xx - LocalVarsSize ; last two bytes of string use ebx
-;scanalign equ rsp + xx - LocalVarsSize ; dword-misalignment of string r13
-;bestlen equ rsp + xx - LocalVarsSize ; size of best match so far -> r11d
-;scan equ rsp + xx - LocalVarsSize ; ptr to string wanting match -> r9
-IFDEF INFOZIP
-ELSE
- nicematch equ (rsp + 16 - LocalVarsSize) ; a good enough match size
-ENDIF
-
-save_rdi equ rsp + 24 - LocalVarsSize
-save_rsi equ rsp + 32 - LocalVarsSize
-save_rbx equ rsp + 40 - LocalVarsSize
-save_rbp equ rsp + 48 - LocalVarsSize
-save_r12 equ rsp + 56 - LocalVarsSize
-save_r13 equ rsp + 64 - LocalVarsSize
-;save_r14 equ rsp + 72 - LocalVarsSize
-;save_r15 equ rsp + 80 - LocalVarsSize
-
-
-
-; all the +4 offsets are due to the addition of pending_buf_size (in zlib
-; in the deflate_state structure since the asm code was first written
-; (if you compile with zlib 1.0.4 or older, remove the +4).
-; Note : these value are good with a 8 bytes boundary pack structure
-
-
- MAX_MATCH equ 258
- MIN_MATCH equ 3
- MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1)
-
-
-;;; Offsets for fields in the deflate_state structure. These numbers
-;;; are calculated from the definition of deflate_state, with the
-;;; assumption that the compiler will dword-align the fields. (Thus,
-;;; changing the definition of deflate_state could easily cause this
-;;; program to crash horribly, without so much as a warning at
-;;; compile time. Sigh.)
-
-; all the +zlib1222add offsets are due to the addition of fields
-; in zlib in the deflate_state structure since the asm code was first written
-; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)").
-; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0").
-; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8").
-
-
-IFDEF INFOZIP
-
-_DATA SEGMENT
-COMM window_size:DWORD
-; WMask ; 7fff
-COMM window:BYTE:010040H
-COMM prev:WORD:08000H
-; MatchLen : unused
-; PrevMatch : unused
-COMM strstart:DWORD
-COMM match_start:DWORD
-; Lookahead : ignore
-COMM prev_length:DWORD ; PrevLen
-COMM max_chain_length:DWORD
-COMM good_match:DWORD
-COMM nice_match:DWORD
-prev_ad equ OFFSET prev
-window_ad equ OFFSET window
-nicematch equ nice_match
-_DATA ENDS
-WMask equ 07fffh
-
-ELSE
-
- IFNDEF zlib1222add
- zlib1222add equ 8
- ENDIF
-dsWSize equ 56+zlib1222add+(zlib1222add/2)
-dsWMask equ 64+zlib1222add+(zlib1222add/2)
-dsWindow equ 72+zlib1222add
-dsPrev equ 88+zlib1222add
-dsMatchLen equ 128+zlib1222add
-dsPrevMatch equ 132+zlib1222add
-dsStrStart equ 140+zlib1222add
-dsMatchStart equ 144+zlib1222add
-dsLookahead equ 148+zlib1222add
-dsPrevLen equ 152+zlib1222add
-dsMaxChainLen equ 156+zlib1222add
-dsGoodMatch equ 172+zlib1222add
-dsNiceMatch equ 176+zlib1222add
-
-window_size equ [ rcx + dsWSize]
-WMask equ [ rcx + dsWMask]
-window_ad equ [ rcx + dsWindow]
-prev_ad equ [ rcx + dsPrev]
-strstart equ [ rcx + dsStrStart]
-match_start equ [ rcx + dsMatchStart]
-Lookahead equ [ rcx + dsLookahead] ; 0ffffffffh on infozip
-prev_length equ [ rcx + dsPrevLen]
-max_chain_length equ [ rcx + dsMaxChainLen]
-good_match equ [ rcx + dsGoodMatch]
-nice_match equ [ rcx + dsNiceMatch]
-ENDIF
-
-; parameter 1 in r8(deflate state s), param 2 in rdx (cur match)
-
-; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and
-; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp
-;
-; All registers must be preserved across the call, except for
-; rax, rcx, rdx, r8, r9, r10, and r11, which are scratch.
-
-
-
-;;; Save registers that the compiler may be using, and adjust esp to
-;;; make room for our stack frame.
-
-
-;;; Retrieve the function arguments. r8d will hold cur_match
-;;; throughout the entire function. edx will hold the pointer to the
-;;; deflate_state structure during the function's setup (before
-;;; entering the main loop.
-
-; parameter 1 in rcx (deflate_state* s), param 2 in edx -> r8 (cur match)
-
-; this clear high 32 bits of r8, which can be garbage in both r8 and rdx
-
- mov [save_rdi],rdi
- mov [save_rsi],rsi
- mov [save_rbx],rbx
- mov [save_rbp],rbp
-IFDEF INFOZIP
- mov r8d,ecx
-ELSE
- mov r8d,edx
-ENDIF
- mov [save_r12],r12
- mov [save_r13],r13
-; mov [save_r14],r14
-; mov [save_r15],r15
-
-
-;;; uInt wmask = s->w_mask;
-;;; unsigned chain_length = s->max_chain_length;
-;;; if (s->prev_length >= s->good_match) {
-;;; chain_length >>= 2;
-;;; }
-
- mov edi, prev_length
- mov esi, good_match
- mov eax, WMask
- mov ebx, max_chain_length
- cmp edi, esi
- jl LastMatchGood
- shr ebx, 2
-LastMatchGood:
-
-;;; chainlen is decremented once beforehand so that the function can
-;;; use the sign flag instead of the zero flag for the exit test.
-;;; It is then shifted into the high word, to make room for the wmask
-;;; value, which it will always accompany.
-
- dec ebx
- shl ebx, 16
- or ebx, eax
-
-;;; on zlib only
-;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
-
-IFDEF INFOZIP
- mov [chainlenwmask], ebx
-; on infozip nice_match = [nice_match]
-ELSE
- mov eax, nice_match
- mov [chainlenwmask], ebx
- mov r10d, Lookahead
- cmp r10d, eax
- cmovnl r10d, eax
- mov [nicematch],r10d
-ENDIF
-
-;;; register Bytef *scan = s->window + s->strstart;
- mov r10, window_ad
- mov ebp, strstart
- lea r13, [r10 + rbp]
-
-;;; Determine how many bytes the scan ptr is off from being
-;;; dword-aligned.
-
- mov r9,r13
- neg r13
- and r13,3
-
-;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
-;;; s->strstart - (IPos)MAX_DIST(s) : NIL;
-IFDEF INFOZIP
- mov eax,07efah ; MAX_DIST = (WSIZE-MIN_LOOKAHEAD) (0x8000-(3+8+1))
-ELSE
- mov eax, window_size
- sub eax, MIN_LOOKAHEAD
-ENDIF
- xor edi,edi
- sub ebp, eax
-
- mov r11d, prev_length
-
- cmovng ebp,edi
-
-;;; int best_len = s->prev_length;
-
-
-;;; Store the sum of s->window + best_len in esi locally, and in esi.
-
- lea rsi,[r10+r11]
-
-;;; register ush scan_start = *(ushf*)scan;
-;;; register ush scan_end = *(ushf*)(scan+best_len-1);
-;;; Posf *prev = s->prev;
-
- movzx r12d,word ptr [r9]
- movzx ebx, word ptr [r9 + r11 - 1]
-
- mov rdi, prev_ad
-
-;;; Jump into the main loop.
-
- mov edx, [chainlenwmask]
-
- cmp bx,word ptr [rsi + r8 - 1]
- jz LookupLoopIsZero
-
-LookupLoop1:
- and r8d, edx
-
- movzx r8d, word ptr [rdi + r8*2]
- cmp r8d, ebp
- jbe LeaveNow
- sub edx, 00010000h
- js LeaveNow
-
-LoopEntry1:
- cmp bx,word ptr [rsi + r8 - 1]
- jz LookupLoopIsZero
-
-LookupLoop2:
- and r8d, edx
-
- movzx r8d, word ptr [rdi + r8*2]
- cmp r8d, ebp
- jbe LeaveNow
- sub edx, 00010000h
- js LeaveNow
-
-LoopEntry2:
- cmp bx,word ptr [rsi + r8 - 1]
- jz LookupLoopIsZero
-
-LookupLoop4:
- and r8d, edx
-
- movzx r8d, word ptr [rdi + r8*2]
- cmp r8d, ebp
- jbe LeaveNow
- sub edx, 00010000h
- js LeaveNow
-
-LoopEntry4:
-
- cmp bx,word ptr [rsi + r8 - 1]
- jnz LookupLoop1
- jmp LookupLoopIsZero
-
-
-;;; do {
-;;; match = s->window + cur_match;
-;;; if (*(ushf*)(match+best_len-1) != scan_end ||
-;;; *(ushf*)match != scan_start) continue;
-;;; [...]
-;;; } while ((cur_match = prev[cur_match & wmask]) > limit
-;;; && --chain_length != 0);
-;;;
-;;; Here is the inner loop of the function. The function will spend the
-;;; majority of its time in this loop, and majority of that time will
-;;; be spent in the first ten instructions.
-;;;
-;;; Within this loop:
-;;; ebx = scanend
-;;; r8d = curmatch
-;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask)
-;;; esi = windowbestlen - i.e., (window + bestlen)
-;;; edi = prev
-;;; ebp = limit
-
-LookupLoop:
- and r8d, edx
-
- movzx r8d, word ptr [rdi + r8*2]
- cmp r8d, ebp
- jbe LeaveNow
- sub edx, 00010000h
- js LeaveNow
-
-LoopEntry:
-
- cmp bx,word ptr [rsi + r8 - 1]
- jnz LookupLoop1
-LookupLoopIsZero:
- cmp r12w, word ptr [r10 + r8]
- jnz LookupLoop1
-
-
-;;; Store the current value of chainlen.
- mov [chainlenwmask], edx
-
-;;; Point edi to the string under scrutiny, and esi to the string we
-;;; are hoping to match it up with. In actuality, esi and edi are
-;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is
-;;; initialized to -(MAX_MATCH_8 - scanalign).
-
- lea rsi,[r8+r10]
- mov rdx, 0fffffffffffffef8h; -(MAX_MATCH_8)
- lea rsi, [rsi + r13 + 0108h] ;MAX_MATCH_8]
- lea rdi, [r9 + r13 + 0108h] ;MAX_MATCH_8]
-
- prefetcht1 [rsi+rdx]
- prefetcht1 [rdi+rdx]
-
-
-;;; Test the strings for equality, 8 bytes at a time. At the end,
-;;; adjust rdx so that it is offset to the exact byte that mismatched.
-;;;
-;;; We already know at this point that the first three bytes of the
-;;; strings match each other, and they can be safely passed over before
-;;; starting the compare loop. So what this code does is skip over 0-3
-;;; bytes, as much as necessary in order to dword-align the edi
-;;; pointer. (rsi will still be misaligned three times out of four.)
-;;;
-;;; It should be confessed that this loop usually does not represent
-;;; much of the total running time. Replacing it with a more
-;;; straightforward "rep cmpsb" would not drastically degrade
-;;; performance.
-
-
-LoopCmps:
- mov rax, [rsi + rdx]
- xor rax, [rdi + rdx]
- jnz LeaveLoopCmps
-
- mov rax, [rsi + rdx + 8]
- xor rax, [rdi + rdx + 8]
- jnz LeaveLoopCmps8
-
-
- mov rax, [rsi + rdx + 8+8]
- xor rax, [rdi + rdx + 8+8]
- jnz LeaveLoopCmps16
-
- add rdx,8+8+8
-
- jmp short LoopCmps
-LeaveLoopCmps16: add rdx,8
-LeaveLoopCmps8: add rdx,8
-LeaveLoopCmps:
-
- test eax, 0000FFFFh
- jnz LenLower
-
- test eax,0ffffffffh
-
- jnz LenLower32
-
- add rdx,4
- shr rax,32
- or ax,ax
- jnz LenLower
-
-LenLower32:
- shr eax,16
- add rdx,2
-LenLower: sub al, 1
- adc rdx, 0
-;;; Calculate the length of the match. If it is longer than MAX_MATCH,
-;;; then automatically accept it as the best possible match and leave.
-
- lea rax, [rdi + rdx]
- sub rax, r9
- cmp eax, MAX_MATCH
- jge LenMaximum
-
-;;; If the length of the match is not longer than the best match we
-;;; have so far, then forget it and return to the lookup loop.
-;///////////////////////////////////
-
- cmp eax, r11d
- jg LongerMatch
-
- lea rsi,[r10+r11]
-
- mov rdi, prev_ad
- mov edx, [chainlenwmask]
- jmp LookupLoop
-
-;;; s->match_start = cur_match;
-;;; best_len = len;
-;;; if (len >= nice_match) break;
-;;; scan_end = *(ushf*)(scan+best_len-1);
-
-LongerMatch:
- mov r11d, eax
- mov match_start, r8d
- cmp eax, [nicematch]
- jge LeaveNow
-
- lea rsi,[r10+rax]
-
- movzx ebx, word ptr [r9 + rax - 1]
- mov rdi, prev_ad
- mov edx, [chainlenwmask]
- jmp LookupLoop
-
-;;; Accept the current string, with the maximum possible length.
-
-LenMaximum:
- mov r11d,MAX_MATCH
- mov match_start, r8d
-
-;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
-;;; return s->lookahead;
-
-LeaveNow:
-IFDEF INFOZIP
- mov eax,r11d
-ELSE
- mov eax, Lookahead
- cmp r11d, eax
- cmovng eax, r11d
-ENDIF
-
-;;; Restore the stack and return from whence we came.
-
-
- mov rsi,[save_rsi]
- mov rdi,[save_rdi]
- mov rbx,[save_rbx]
- mov rbp,[save_rbp]
- mov r12,[save_r12]
- mov r13,[save_r13]
-; mov r14,[save_r14]
-; mov r15,[save_r15]
-
-
- ret 0
-; please don't remove this string !
-; Your can freely use gvmat64 in any free or commercial app
-; but it is far better don't remove the string in the binary!
- db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998, converted to amd 64 by Gilles Vollant 2005",0dh,0ah,0
-longest_match ENDP
-
-match_init PROC
- ret 0
-match_init ENDP
-
-
-END
diff --git a/source4/lib/zlib/contrib/masmx64/gvmat64.obj b/source4/lib/zlib/contrib/masmx64/gvmat64.obj
deleted file mode 100644
index a49ca029c6..0000000000
--- a/source4/lib/zlib/contrib/masmx64/gvmat64.obj
+++ /dev/null
Binary files differ
diff --git a/source4/lib/zlib/contrib/masmx64/inffas8664.c b/source4/lib/zlib/contrib/masmx64/inffas8664.c
deleted file mode 100644
index 3af764de9c..0000000000
--- a/source4/lib/zlib/contrib/masmx64/inffas8664.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/* inffas8664.c is a hand tuned assembler version of inffast.c - fast decoding
- * version for AMD64 on Windows using Microsoft C compiler
- *
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- *
- * Copyright (C) 2003 Chris Anderson <christop@charm.net>
- * Please use the copyright conditions above.
- *
- * 2005 - Adaptation to Microsoft C Compiler for AMD64 by Gilles Vollant
- *
- * inffas8664.c call function inffas8664fnc in inffasx64.asm
- * inffasx64.asm is automatically convert from AMD64 portion of inffas86.c
- *
- * Dec-29-2003 -- I added AMD64 inflate asm support. This version is also
- * slightly quicker on x86 systems because, instead of using rep movsb to copy
- * data, it uses rep movsw, which moves data in 2-byte chunks instead of single
- * bytes. I've tested the AMD64 code on a Fedora Core 1 + the x86_64 updates
- * from http://fedora.linux.duke.edu/fc1_x86_64
- * which is running on an Athlon 64 3000+ / Gigabyte GA-K8VT800M system with
- * 1GB ram. The 64-bit version is about 4% faster than the 32-bit version,
- * when decompressing mozilla-source-1.3.tar.gz.
- *
- * Mar-13-2003 -- Most of this is derived from inffast.S which is derived from
- * the gcc -S output of zlib-1.2.0/inffast.c. Zlib-1.2.0 is in beta release at
- * the moment. I have successfully compiled and tested this code with gcc2.96,
- * gcc3.2, icc5.0, msvc6.0. It is very close to the speed of inffast.S
- * compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX
- * enabled. I will attempt to merge the MMX code into this version. Newer
- * versions of this and inffast.S can be found at
- * http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/
- *
- */
-
-#include <stdio.h>
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-/* Mark Adler's comments from inffast.c: */
-
-/*
- Decode literal, length, and distance codes and write out the resulting
- literal and match bytes until either not enough input or output is
- available, an end-of-block is encountered, or a data error is encountered.
- When large enough input and output buffers are supplied to inflate(), for
- example, a 16K input buffer and a 64K output buffer, more than 95% of the
- inflate execution time is spent in this routine.
-
- Entry assumptions:
-
- state->mode == LEN
- strm->avail_in >= 6
- strm->avail_out >= 258
- start >= strm->avail_out
- state->bits < 8
-
- On return, state->mode is one of:
-
- LEN -- ran out of enough output space or enough available input
- TYPE -- reached end of block code, inflate() to interpret next block
- BAD -- error in block data
-
- Notes:
-
- - The maximum input bits used by a length/distance pair is 15 bits for the
- length code, 5 bits for the length extra, 15 bits for the distance code,
- and 13 bits for the distance extra. This totals 48 bits, or six bytes.
- Therefore if strm->avail_in >= 6, then there is enough input to avoid
- checking for available input while decoding.
-
- - The maximum bytes that a single length/distance pair can output is 258
- bytes, which is the maximum length that can be coded. inflate_fast()
- requires strm->avail_out >= 258 for each loop to avoid checking for
- output space.
- */
-
-
-
- typedef struct inffast_ar {
-/* 64 32 x86 x86_64 */
-/* ar offset register */
-/* 0 0 */ void *esp; /* esp save */
-/* 8 4 */ void *ebp; /* ebp save */
-/* 16 8 */ unsigned char FAR *in; /* esi rsi local strm->next_in */
-/* 24 12 */ unsigned char FAR *last; /* r9 while in < last */
-/* 32 16 */ unsigned char FAR *out; /* edi rdi local strm->next_out */
-/* 40 20 */ unsigned char FAR *beg; /* inflate()'s init next_out */
-/* 48 24 */ unsigned char FAR *end; /* r10 while out < end */
-/* 56 28 */ unsigned char FAR *window;/* size of window, wsize!=0 */
-/* 64 32 */ code const FAR *lcode; /* ebp rbp local strm->lencode */
-/* 72 36 */ code const FAR *dcode; /* r11 local strm->distcode */
-/* 80 40 */ size_t /*unsigned long */hold; /* edx rdx local strm->hold */
-/* 88 44 */ unsigned bits; /* ebx rbx local strm->bits */
-/* 92 48 */ unsigned wsize; /* window size */
-/* 96 52 */ unsigned write; /* window write index */
-/*100 56 */ unsigned lmask; /* r12 mask for lcode */
-/*104 60 */ unsigned dmask; /* r13 mask for dcode */
-/*108 64 */ unsigned len; /* r14 match length */
-/*112 68 */ unsigned dist; /* r15 match distance */
-/*116 72 */ unsigned status; /* set when state chng*/
- } type_ar;
-#ifdef ASMINF
-
-void inflate_fast(strm, start)
-z_streamp strm;
-unsigned start; /* inflate()'s starting value for strm->avail_out */
-{
- struct inflate_state FAR *state;
- type_ar ar;
- void inffas8664fnc(struct inffast_ar * par);
-
-
-
-#if (defined( __GNUC__ ) && defined( __amd64__ ) && ! defined( __i386 )) || (defined(_MSC_VER) && defined(_M_AMD64))
-#define PAD_AVAIL_IN 6
-#define PAD_AVAIL_OUT 258
-#else
-#define PAD_AVAIL_IN 5
-#define PAD_AVAIL_OUT 257
-#endif
-
- /* copy state to local variables */
- state = (struct inflate_state FAR *)strm->state;
-
- ar.in = strm->next_in;
- ar.last = ar.in + (strm->avail_in - PAD_AVAIL_IN);
- ar.out = strm->next_out;
- ar.beg = ar.out - (start - strm->avail_out);
- ar.end = ar.out + (strm->avail_out - PAD_AVAIL_OUT);
- ar.wsize = state->wsize;
- ar.write = state->write;
- ar.window = state->window;
- ar.hold = state->hold;
- ar.bits = state->bits;
- ar.lcode = state->lencode;
- ar.dcode = state->distcode;
- ar.lmask = (1U << state->lenbits) - 1;
- ar.dmask = (1U << state->distbits) - 1;
-
- /* decode literals and length/distances until end-of-block or not enough
- input data or output space */
-
- /* align in on 1/2 hold size boundary */
- while (((size_t)(void *)ar.in & (sizeof(ar.hold) / 2 - 1)) != 0) {
- ar.hold += (unsigned long)*ar.in++ << ar.bits;
- ar.bits += 8;
- }
-
- inffas8664fnc(&ar);
-
- if (ar.status > 1) {
- if (ar.status == 2)
- strm->msg = "invalid literal/length code";
- else if (ar.status == 3)
- strm->msg = "invalid distance code";
- else
- strm->msg = "invalid distance too far back";
- state->mode = BAD;
- }
- else if ( ar.status == 1 ) {
- state->mode = TYPE;
- }
-
- /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
- ar.len = ar.bits >> 3;
- ar.in -= ar.len;
- ar.bits -= ar.len << 3;
- ar.hold &= (1U << ar.bits) - 1;
-
- /* update state and return */
- strm->next_in = ar.in;
- strm->next_out = ar.out;
- strm->avail_in = (unsigned)(ar.in < ar.last ?
- PAD_AVAIL_IN + (ar.last - ar.in) :
- PAD_AVAIL_IN - (ar.in - ar.last));
- strm->avail_out = (unsigned)(ar.out < ar.end ?
- PAD_AVAIL_OUT + (ar.end - ar.out) :
- PAD_AVAIL_OUT - (ar.out - ar.end));
- state->hold = (unsigned long)ar.hold;
- state->bits = ar.bits;
- return;
-}
-
-#endif
diff --git a/source4/lib/zlib/contrib/masmx64/inffasx64.asm b/source4/lib/zlib/contrib/masmx64/inffasx64.asm
deleted file mode 100644
index b5d93a272a..0000000000
--- a/source4/lib/zlib/contrib/masmx64/inffasx64.asm
+++ /dev/null
@@ -1,392 +0,0 @@
-; inffasx64.asm is a hand tuned assembler version of inffast.c - fast decoding
-; version for AMD64 on Windows using Microsoft C compiler
-;
-; inffasx64.asm is automatically convert from AMD64 portion of inffas86.c
-; inffasx64.asm is called by inffas8664.c, which contain more info.
-
-
-; to compile this file, I use option
-; ml64.exe /Flinffasx64 /c /Zi inffasx64.asm
-; with Microsoft Macro Assembler (x64) for AMD64
-;
-; ml64.exe is given with Visual Studio 2005, Windows 2003 server DDK
-;
-; (you can get Windows 2003 server DDK with ml64 and cl.exe for AMD64 from
-; http://www.microsoft.com/whdc/devtools/ddk/default.mspx for low price)
-;
-
-.code
-inffas8664fnc PROC
-
-; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and
-; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp
-;
-; All registers must be preserved across the call, except for
-; rax, rcx, rdx, r8, r-9, r10, and r11, which are scratch.
-
-
- mov [rsp-8],rsi
- mov [rsp-16],rdi
- mov [rsp-24],r12
- mov [rsp-32],r13
- mov [rsp-40],r14
- mov [rsp-48],r15
- mov [rsp-56],rbx
-
- mov rax,rcx
-
- mov [rax+8], rbp ; /* save regs rbp and rsp */
- mov [rax], rsp
-
- mov rsp, rax ; /* make rsp point to &ar */
-
- mov rsi, [rsp+16] ; /* rsi = in */
- mov rdi, [rsp+32] ; /* rdi = out */
- mov r9, [rsp+24] ; /* r9 = last */
- mov r10, [rsp+48] ; /* r10 = end */
- mov rbp, [rsp+64] ; /* rbp = lcode */
- mov r11, [rsp+72] ; /* r11 = dcode */
- mov rdx, [rsp+80] ; /* rdx = hold */
- mov ebx, [rsp+88] ; /* ebx = bits */
- mov r12d, [rsp+100] ; /* r12d = lmask */
- mov r13d, [rsp+104] ; /* r13d = dmask */
- ; /* r14d = len */
- ; /* r15d = dist */
-
-
- cld
- cmp r10, rdi
- je L_one_time ; /* if only one decode left */
- cmp r9, rsi
-
- jne L_do_loop
-
-
-L_one_time:
- mov r8, r12 ; /* r8 = lmask */
- cmp bl, 32
- ja L_get_length_code_one_time
-
- lodsd ; /* eax = *(uint *)in++ */
- mov cl, bl ; /* cl = bits, needs it for shifting */
- add bl, 32 ; /* bits += 32 */
- shl rax, cl
- or rdx, rax ; /* hold |= *((uint *)in)++ << bits */
- jmp L_get_length_code_one_time
-
-ALIGN 4
-L_while_test:
- cmp r10, rdi
- jbe L_break_loop
- cmp r9, rsi
- jbe L_break_loop
-
-L_do_loop:
- mov r8, r12 ; /* r8 = lmask */
- cmp bl, 32
- ja L_get_length_code ; /* if (32 < bits) */
-
- lodsd ; /* eax = *(uint *)in++ */
- mov cl, bl ; /* cl = bits, needs it for shifting */
- add bl, 32 ; /* bits += 32 */
- shl rax, cl
- or rdx, rax ; /* hold |= *((uint *)in)++ << bits */
-
-L_get_length_code:
- and r8, rdx ; /* r8 &= hold */
- mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */
-
- mov cl, ah ; /* cl = this.bits */
- sub bl, ah ; /* bits -= this.bits */
- shr rdx, cl ; /* hold >>= this.bits */
-
- test al, al
- jnz L_test_for_length_base ; /* if (op != 0) 45.7% */
-
- mov r8, r12 ; /* r8 = lmask */
- shr eax, 16 ; /* output this.val char */
- stosb
-
-L_get_length_code_one_time:
- and r8, rdx ; /* r8 &= hold */
- mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */
-
-L_dolen:
- mov cl, ah ; /* cl = this.bits */
- sub bl, ah ; /* bits -= this.bits */
- shr rdx, cl ; /* hold >>= this.bits */
-
- test al, al
- jnz L_test_for_length_base ; /* if (op != 0) 45.7% */
-
- shr eax, 16 ; /* output this.val char */
- stosb
- jmp L_while_test
-
-ALIGN 4
-L_test_for_length_base:
- mov r14d, eax ; /* len = this */
- shr r14d, 16 ; /* len = this.val */
- mov cl, al
-
- test al, 16
- jz L_test_for_second_level_length ; /* if ((op & 16) == 0) 8% */
- and cl, 15 ; /* op &= 15 */
- jz L_decode_distance ; /* if (!op) */
-
-L_add_bits_to_len:
- sub bl, cl
- xor eax, eax
- inc eax
- shl eax, cl
- dec eax
- and eax, edx ; /* eax &= hold */
- shr rdx, cl
- add r14d, eax ; /* len += hold & mask[op] */
-
-L_decode_distance:
- mov r8, r13 ; /* r8 = dmask */
- cmp bl, 32
- ja L_get_distance_code ; /* if (32 < bits) */
-
- lodsd ; /* eax = *(uint *)in++ */
- mov cl, bl ; /* cl = bits, needs it for shifting */
- add bl, 32 ; /* bits += 32 */
- shl rax, cl
- or rdx, rax ; /* hold |= *((uint *)in)++ << bits */
-
-L_get_distance_code:
- and r8, rdx ; /* r8 &= hold */
- mov eax, [r11+r8*4] ; /* eax = dcode[hold & dmask] */
-
-L_dodist:
- mov r15d, eax ; /* dist = this */
- shr r15d, 16 ; /* dist = this.val */
- mov cl, ah
- sub bl, ah ; /* bits -= this.bits */
- shr rdx, cl ; /* hold >>= this.bits */
- mov cl, al ; /* cl = this.op */
-
- test al, 16 ; /* if ((op & 16) == 0) */
- jz L_test_for_second_level_dist
- and cl, 15 ; /* op &= 15 */
- jz L_check_dist_one
-
-L_add_bits_to_dist:
- sub bl, cl
- xor eax, eax
- inc eax
- shl eax, cl
- dec eax ; /* (1 << op) - 1 */
- and eax, edx ; /* eax &= hold */
- shr rdx, cl
- add r15d, eax ; /* dist += hold & ((1 << op) - 1) */
-
-L_check_window:
- mov r8, rsi ; /* save in so from can use it's reg */
- mov rax, rdi
- sub rax, [rsp+40] ; /* nbytes = out - beg */
-
- cmp eax, r15d
- jb L_clip_window ; /* if (dist > nbytes) 4.2% */
-
- mov ecx, r14d ; /* ecx = len */
- mov rsi, rdi
- sub rsi, r15 ; /* from = out - dist */
-
- sar ecx, 1
- jnc L_copy_two ; /* if len % 2 == 0 */
-
- rep movsw
- mov al, [rsi]
- mov [rdi], al
- inc rdi
-
- mov rsi, r8 ; /* move in back to %rsi, toss from */
- jmp L_while_test
-
-L_copy_two:
- rep movsw
- mov rsi, r8 ; /* move in back to %rsi, toss from */
- jmp L_while_test
-
-ALIGN 4
-L_check_dist_one:
- cmp r15d, 1 ; /* if dist 1, is a memset */
- jne L_check_window
- cmp [rsp+40], rdi ; /* if out == beg, outside window */
- je L_check_window
-
- mov ecx, r14d ; /* ecx = len */
- mov al, [rdi-1]
- mov ah, al
-
- sar ecx, 1
- jnc L_set_two
- mov [rdi], al
- inc rdi
-
-L_set_two:
- rep stosw
- jmp L_while_test
-
-ALIGN 4
-L_test_for_second_level_length:
- test al, 64
- jnz L_test_for_end_of_block ; /* if ((op & 64) != 0) */
-
- xor eax, eax
- inc eax
- shl eax, cl
- dec eax
- and eax, edx ; /* eax &= hold */
- add eax, r14d ; /* eax += len */
- mov eax, [rbp+rax*4] ; /* eax = lcode[val+(hold&mask[op])]*/
- jmp L_dolen
-
-ALIGN 4
-L_test_for_second_level_dist:
- test al, 64
- jnz L_invalid_distance_code ; /* if ((op & 64) != 0) */
-
- xor eax, eax
- inc eax
- shl eax, cl
- dec eax
- and eax, edx ; /* eax &= hold */
- add eax, r15d ; /* eax += dist */
- mov eax, [r11+rax*4] ; /* eax = dcode[val+(hold&mask[op])]*/
- jmp L_dodist
-
-ALIGN 4
-L_clip_window:
- mov ecx, eax ; /* ecx = nbytes */
- mov eax, [rsp+92] ; /* eax = wsize, prepare for dist cmp */
- neg ecx ; /* nbytes = -nbytes */
-
- cmp eax, r15d
- jb L_invalid_distance_too_far ; /* if (dist > wsize) */
-
- add ecx, r15d ; /* nbytes = dist - nbytes */
- cmp dword ptr [rsp+96], 0
- jne L_wrap_around_window ; /* if (write != 0) */
-
- mov rsi, [rsp+56] ; /* from = window */
- sub eax, ecx ; /* eax -= nbytes */
- add rsi, rax ; /* from += wsize - nbytes */
-
- mov eax, r14d ; /* eax = len */
- cmp r14d, ecx
- jbe L_do_copy ; /* if (nbytes >= len) */
-
- sub eax, ecx ; /* eax -= nbytes */
- rep movsb
- mov rsi, rdi
- sub rsi, r15 ; /* from = &out[ -dist ] */
- jmp L_do_copy
-
-ALIGN 4
-L_wrap_around_window:
- mov eax, [rsp+96] ; /* eax = write */
- cmp ecx, eax
- jbe L_contiguous_in_window ; /* if (write >= nbytes) */
-
- mov esi, [rsp+92] ; /* from = wsize */
- add rsi, [rsp+56] ; /* from += window */
- add rsi, rax ; /* from += write */
- sub rsi, rcx ; /* from -= nbytes */
- sub ecx, eax ; /* nbytes -= write */
-
- mov eax, r14d ; /* eax = len */
- cmp eax, ecx
- jbe L_do_copy ; /* if (nbytes >= len) */
-
- sub eax, ecx ; /* len -= nbytes */
- rep movsb
- mov rsi, [rsp+56] ; /* from = window */
- mov ecx, [rsp+96] ; /* nbytes = write */
- cmp eax, ecx
- jbe L_do_copy ; /* if (nbytes >= len) */
-
- sub eax, ecx ; /* len -= nbytes */
- rep movsb
- mov rsi, rdi
- sub rsi, r15 ; /* from = out - dist */
- jmp L_do_copy
-
-ALIGN 4
-L_contiguous_in_window:
- mov rsi, [rsp+56] ; /* rsi = window */
- add rsi, rax
- sub rsi, rcx ; /* from += write - nbytes */
-
- mov eax, r14d ; /* eax = len */
- cmp eax, ecx
- jbe L_do_copy ; /* if (nbytes >= len) */
-
- sub eax, ecx ; /* len -= nbytes */
- rep movsb
- mov rsi, rdi
- sub rsi, r15 ; /* from = out - dist */
- jmp L_do_copy ; /* if (nbytes >= len) */
-
-ALIGN 4
-L_do_copy:
- mov ecx, eax ; /* ecx = len */
- rep movsb
-
- mov rsi, r8 ; /* move in back to %esi, toss from */
- jmp L_while_test
-
-L_test_for_end_of_block:
- test al, 32
- jz L_invalid_literal_length_code
- mov dword ptr [rsp+116], 1
- jmp L_break_loop_with_status
-
-L_invalid_literal_length_code:
- mov dword ptr [rsp+116], 2
- jmp L_break_loop_with_status
-
-L_invalid_distance_code:
- mov dword ptr [rsp+116], 3
- jmp L_break_loop_with_status
-
-L_invalid_distance_too_far:
- mov dword ptr [rsp+116], 4
- jmp L_break_loop_with_status
-
-L_break_loop:
- mov dword ptr [rsp+116], 0
-
-L_break_loop_with_status:
-; /* put in, out, bits, and hold back into ar and pop esp */
- mov [rsp+16], rsi ; /* in */
- mov [rsp+32], rdi ; /* out */
- mov [rsp+88], ebx ; /* bits */
- mov [rsp+80], rdx ; /* hold */
-
- mov rax, [rsp] ; /* restore rbp and rsp */
- mov rbp, [rsp+8]
- mov rsp, rax
-
-
-
- mov rsi,[rsp-8]
- mov rdi,[rsp-16]
- mov r12,[rsp-24]
- mov r13,[rsp-32]
- mov r14,[rsp-40]
- mov r15,[rsp-48]
- mov rbx,[rsp-56]
-
- ret 0
-; :
-; : "m" (ar)
-; : "memory", "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi",
-; "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
-; );
-
-inffas8664fnc ENDP
-;_TEXT ENDS
-END
diff --git a/source4/lib/zlib/contrib/masmx64/inffasx64.obj b/source4/lib/zlib/contrib/masmx64/inffasx64.obj
deleted file mode 100644
index 8df5d82616..0000000000
--- a/source4/lib/zlib/contrib/masmx64/inffasx64.obj
+++ /dev/null
Binary files differ
diff --git a/source4/lib/zlib/contrib/masmx64/readme.txt b/source4/lib/zlib/contrib/masmx64/readme.txt
deleted file mode 100644
index ee03115c5a..0000000000
--- a/source4/lib/zlib/contrib/masmx64/readme.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-Summary
--------
-This directory contains ASM implementations of the functions
-longest_match() and inflate_fast(), for 64 bits x86 (both AMD64 and Intel EM64t),
-for use with Microsoft Macro Assembler (x64) for AMD64 and Microsoft C++ 64 bits.
-
-gvmat64.asm is written by Gilles Vollant (2005), by using Brian Raiter 686/32 bits
- assembly optimized version from Jean-loup Gailly original longest_match function
-
-inffasx64.asm and inffas8664.c were written by Chris Anderson, by optimizing
- original function from Mark Adler
-
-Use instructions
-----------------
-Copy these files into the zlib source directory.
-
-define ASMV and ASMINF in your project. Include inffas8664.c in your source tree,
-and inffasx64.obj and gvmat64.obj as object to link.
-
-
-Build instructions
-------------------
-run bld_64.bat with Microsoft Macro Assembler (x64) for AMD64 (ml64.exe)
-
-ml64.exe is given with Visual Studio 2005, Windows 2003 server DDK
-
-You can get Windows 2003 server DDK with ml64 and cl for AMD64 from
- http://www.microsoft.com/whdc/devtools/ddk/default.mspx for low price)
diff --git a/source4/lib/zlib/contrib/masmx86/bld_ml32.bat b/source4/lib/zlib/contrib/masmx86/bld_ml32.bat
deleted file mode 100644
index 99144d07af..0000000000
--- a/source4/lib/zlib/contrib/masmx86/bld_ml32.bat
+++ /dev/null
@@ -1,2 +0,0 @@
-ml /coff /Zi /c /Flgvmat32.lst gvmat32.asm
-ml /coff /Zi /c /Flinffas32.lst inffas32.asm
diff --git a/source4/lib/zlib/contrib/masmx86/gvmat32.asm b/source4/lib/zlib/contrib/masmx86/gvmat32.asm
deleted file mode 100644
index 874bb2d482..0000000000
--- a/source4/lib/zlib/contrib/masmx86/gvmat32.asm
+++ /dev/null
@@ -1,972 +0,0 @@
-; gvmat32.asm -- Asm portion of the optimized longest_match for 32 bits x86
-; Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant.
-; File written by Gilles Vollant, by modifiying the longest_match
-; from Jean-loup Gailly in deflate.c
-;
-; http://www.zlib.net
-; http://www.winimage.com/zLibDll
-; http://www.muppetlabs.com/~breadbox/software/assembly.html
-;
-; For Visual C++ 4.x and higher and ML 6.x and higher
-; ml.exe is in directory \MASM611C of Win95 DDK
-; ml.exe is also distributed in http://www.masm32.com/masmdl.htm
-; and in VC++2003 toolkit at http://msdn.microsoft.com/visualc/vctoolkit2003/
-;
-; this file contain two implementation of longest_match
-;
-; longest_match_7fff : written 1996 by Gilles Vollant optimized for
-; first Pentium. Assume s->w_mask == 0x7fff
-; longest_match_686 : written by Brian raiter (1998), optimized for Pentium Pro
-;
-; for using an seembly version of longest_match, you need define ASMV in project
-; There is two way in using gvmat32.asm
-;
-; A) Suggested method
-; if you want include both longest_match_7fff and longest_match_686
-; compile the asm file running
-; ml /coff /Zi /Flgvmat32.lst /c gvmat32.asm
-; and include gvmat32c.c in your project
-; if you have an old cpu (386,486 or first Pentium) and s->w_mask==0x7fff,
-; longest_match_7fff will be used
-; if you have a more modern CPU (Pentium Pro, II and higher)
-; longest_match_686 will be used
-; on old cpu with s->w_mask!=0x7fff, longest_match_686 will be used,
-; but this is not a sitation you'll find often
-;
-; B) Alternative
-; if you are not interresed in old cpu performance and want the smaller
-; binaries possible
-;
-; compile the asm file running
-; ml /coff /Zi /c /Flgvmat32.lst /DNOOLDPENTIUMCODE gvmat32.asm
-; and do not include gvmat32c.c in your project (ou define also
-; NOOLDPENTIUMCODE)
-;
-; note : as I known, longest_match_686 is very faster than longest_match_7fff
-; on pentium Pro/II/III, faster (but less) in P4, but it seem
-; longest_match_7fff can be faster (very very litte) on AMD Athlon64/K8
-;
-; see below : zlib1222add must be adjuster if you use a zlib version < 1.2.2.2
-
-;uInt longest_match_7fff(s, cur_match)
-; deflate_state *s;
-; IPos cur_match; /* current match */
-
- NbStack equ 76
- cur_match equ dword ptr[esp+NbStack-0]
- str_s equ dword ptr[esp+NbStack-4]
-; 5 dword on top (ret,ebp,esi,edi,ebx)
- adrret equ dword ptr[esp+NbStack-8]
- pushebp equ dword ptr[esp+NbStack-12]
- pushedi equ dword ptr[esp+NbStack-16]
- pushesi equ dword ptr[esp+NbStack-20]
- pushebx equ dword ptr[esp+NbStack-24]
-
- chain_length equ dword ptr [esp+NbStack-28]
- limit equ dword ptr [esp+NbStack-32]
- best_len equ dword ptr [esp+NbStack-36]
- window equ dword ptr [esp+NbStack-40]
- prev equ dword ptr [esp+NbStack-44]
- scan_start equ word ptr [esp+NbStack-48]
- wmask equ dword ptr [esp+NbStack-52]
- match_start_ptr equ dword ptr [esp+NbStack-56]
- nice_match equ dword ptr [esp+NbStack-60]
- scan equ dword ptr [esp+NbStack-64]
-
- windowlen equ dword ptr [esp+NbStack-68]
- match_start equ dword ptr [esp+NbStack-72]
- strend equ dword ptr [esp+NbStack-76]
- NbStackAdd equ (NbStack-24)
-
- .386p
-
- name gvmatch
- .MODEL FLAT
-
-
-
-; all the +zlib1222add offsets are due to the addition of fields
-; in zlib in the deflate_state structure since the asm code was first written
-; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)").
-; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0").
-; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8").
-
- zlib1222add equ 8
-
-; Note : these value are good with a 8 bytes boundary pack structure
- dep_chain_length equ 74h+zlib1222add
- dep_window equ 30h+zlib1222add
- dep_strstart equ 64h+zlib1222add
- dep_prev_length equ 70h+zlib1222add
- dep_nice_match equ 88h+zlib1222add
- dep_w_size equ 24h+zlib1222add
- dep_prev equ 38h+zlib1222add
- dep_w_mask equ 2ch+zlib1222add
- dep_good_match equ 84h+zlib1222add
- dep_match_start equ 68h+zlib1222add
- dep_lookahead equ 6ch+zlib1222add
-
-
-_TEXT segment
-
-IFDEF NOUNDERLINE
- IFDEF NOOLDPENTIUMCODE
- public longest_match
- public match_init
- ELSE
- public longest_match_7fff
- public cpudetect32
- public longest_match_686
- ENDIF
-ELSE
- IFDEF NOOLDPENTIUMCODE
- public _longest_match
- public _match_init
- ELSE
- public _longest_match_7fff
- public _cpudetect32
- public _longest_match_686
- ENDIF
-ENDIF
-
- MAX_MATCH equ 258
- MIN_MATCH equ 3
- MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1)
-
-
-
-IFNDEF NOOLDPENTIUMCODE
-IFDEF NOUNDERLINE
-longest_match_7fff proc near
-ELSE
-_longest_match_7fff proc near
-ENDIF
-
- mov edx,[esp+4]
-
-
-
- push ebp
- push edi
- push esi
- push ebx
-
- sub esp,NbStackAdd
-
-; initialize or check the variables used in match.asm.
- mov ebp,edx
-
-; chain_length = s->max_chain_length
-; if (prev_length>=good_match) chain_length >>= 2
- mov edx,[ebp+dep_chain_length]
- mov ebx,[ebp+dep_prev_length]
- cmp [ebp+dep_good_match],ebx
- ja noshr
- shr edx,2
-noshr:
-; we increment chain_length because in the asm, the --chain_lenght is in the beginning of the loop
- inc edx
- mov edi,[ebp+dep_nice_match]
- mov chain_length,edx
- mov eax,[ebp+dep_lookahead]
- cmp eax,edi
-; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
- jae nolookaheadnicematch
- mov edi,eax
-nolookaheadnicematch:
-; best_len = s->prev_length
- mov best_len,ebx
-
-; window = s->window
- mov esi,[ebp+dep_window]
- mov ecx,[ebp+dep_strstart]
- mov window,esi
-
- mov nice_match,edi
-; scan = window + strstart
- add esi,ecx
- mov scan,esi
-; dx = *window
- mov dx,word ptr [esi]
-; bx = *(window+best_len-1)
- mov bx,word ptr [esi+ebx-1]
- add esi,MAX_MATCH-1
-; scan_start = *scan
- mov scan_start,dx
-; strend = scan + MAX_MATCH-1
- mov strend,esi
-; bx = scan_end = *(window+best_len-1)
-
-; IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
-; s->strstart - (IPos)MAX_DIST(s) : NIL;
-
- mov esi,[ebp+dep_w_size]
- sub esi,MIN_LOOKAHEAD
-; here esi = MAX_DIST(s)
- sub ecx,esi
- ja nodist
- xor ecx,ecx
-nodist:
- mov limit,ecx
-
-; prev = s->prev
- mov edx,[ebp+dep_prev]
- mov prev,edx
-
-;
- mov edx,dword ptr [ebp+dep_match_start]
- mov bp,scan_start
- mov eax,cur_match
- mov match_start,edx
-
- mov edx,window
- mov edi,edx
- add edi,best_len
- mov esi,prev
- dec edi
-; windowlen = window + best_len -1
- mov windowlen,edi
-
- jmp beginloop2
- align 4
-
-; here, in the loop
-; eax = ax = cur_match
-; ecx = limit
-; bx = scan_end
-; bp = scan_start
-; edi = windowlen (window + best_len -1)
-; esi = prev
-
-
-;// here; chain_length <=16
-normalbeg0add16:
- add chain_length,16
- jz exitloop
-normalbeg0:
- cmp word ptr[edi+eax],bx
- je normalbeg2noroll
-rcontlabnoroll:
-; cur_match = prev[cur_match & wmask]
- and eax,7fffh
- mov ax,word ptr[esi+eax*2]
-; if cur_match > limit, go to exitloop
- cmp ecx,eax
- jnb exitloop
-; if --chain_length != 0, go to exitloop
- dec chain_length
- jnz normalbeg0
- jmp exitloop
-
-normalbeg2noroll:
-; if (scan_start==*(cur_match+window)) goto normalbeg2
- cmp bp,word ptr[edx+eax]
- jne rcontlabnoroll
- jmp normalbeg2
-
-contloop3:
- mov edi,windowlen
-
-; cur_match = prev[cur_match & wmask]
- and eax,7fffh
- mov ax,word ptr[esi+eax*2]
-; if cur_match > limit, go to exitloop
- cmp ecx,eax
-jnbexitloopshort1:
- jnb exitloop
-; if --chain_length != 0, go to exitloop
-
-
-; begin the main loop
-beginloop2:
- sub chain_length,16+1
-; if chain_length <=16, don't use the unrolled loop
- jna normalbeg0add16
-
-do16:
- cmp word ptr[edi+eax],bx
- je normalbeg2dc0
-
-maccn MACRO lab
- and eax,7fffh
- mov ax,word ptr[esi+eax*2]
- cmp ecx,eax
- jnb exitloop
- cmp word ptr[edi+eax],bx
- je lab
- ENDM
-
-rcontloop0:
- maccn normalbeg2dc1
-
-rcontloop1:
- maccn normalbeg2dc2
-
-rcontloop2:
- maccn normalbeg2dc3
-
-rcontloop3:
- maccn normalbeg2dc4
-
-rcontloop4:
- maccn normalbeg2dc5
-
-rcontloop5:
- maccn normalbeg2dc6
-
-rcontloop6:
- maccn normalbeg2dc7
-
-rcontloop7:
- maccn normalbeg2dc8
-
-rcontloop8:
- maccn normalbeg2dc9
-
-rcontloop9:
- maccn normalbeg2dc10
-
-rcontloop10:
- maccn short normalbeg2dc11
-
-rcontloop11:
- maccn short normalbeg2dc12
-
-rcontloop12:
- maccn short normalbeg2dc13
-
-rcontloop13:
- maccn short normalbeg2dc14
-
-rcontloop14:
- maccn short normalbeg2dc15
-
-rcontloop15:
- and eax,7fffh
- mov ax,word ptr[esi+eax*2]
- cmp ecx,eax
- jnb exitloop
-
- sub chain_length,16
- ja do16
- jmp normalbeg0add16
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-normbeg MACRO rcontlab,valsub
-; if we are here, we know that *(match+best_len-1) == scan_end
- cmp bp,word ptr[edx+eax]
-; if (match != scan_start) goto rcontlab
- jne rcontlab
-; calculate the good chain_length, and we'll compare scan and match string
- add chain_length,16-valsub
- jmp iseq
- ENDM
-
-
-normalbeg2dc11:
- normbeg rcontloop11,11
-
-normalbeg2dc12:
- normbeg short rcontloop12,12
-
-normalbeg2dc13:
- normbeg short rcontloop13,13
-
-normalbeg2dc14:
- normbeg short rcontloop14,14
-
-normalbeg2dc15:
- normbeg short rcontloop15,15
-
-normalbeg2dc10:
- normbeg rcontloop10,10
-
-normalbeg2dc9:
- normbeg rcontloop9,9
-
-normalbeg2dc8:
- normbeg rcontloop8,8
-
-normalbeg2dc7:
- normbeg rcontloop7,7
-
-normalbeg2dc6:
- normbeg rcontloop6,6
-
-normalbeg2dc5:
- normbeg rcontloop5,5
-
-normalbeg2dc4:
- normbeg rcontloop4,4
-
-normalbeg2dc3:
- normbeg rcontloop3,3
-
-normalbeg2dc2:
- normbeg rcontloop2,2
-
-normalbeg2dc1:
- normbeg rcontloop1,1
-
-normalbeg2dc0:
- normbeg rcontloop0,0
-
-
-; we go in normalbeg2 because *(ushf*)(match+best_len-1) == scan_end
-
-normalbeg2:
- mov edi,window
-
- cmp bp,word ptr[edi+eax]
- jne contloop3 ; if *(ushf*)match != scan_start, continue
-
-iseq:
-; if we are here, we know that *(match+best_len-1) == scan_end
-; and (match == scan_start)
-
- mov edi,edx
- mov esi,scan ; esi = scan
- add edi,eax ; edi = window + cur_match = match
-
- mov edx,[esi+3] ; compare manually dword at match+3
- xor edx,[edi+3] ; and scan +3
-
- jz begincompare ; if equal, go to long compare
-
-; we will determine the unmatch byte and calculate len (in esi)
- or dl,dl
- je eq1rr
- mov esi,3
- jmp trfinval
-eq1rr:
- or dx,dx
- je eq1
-
- mov esi,4
- jmp trfinval
-eq1:
- and edx,0ffffffh
- jz eq11
- mov esi,5
- jmp trfinval
-eq11:
- mov esi,6
- jmp trfinval
-
-begincompare:
- ; here we now scan and match begin same
- add edi,6
- add esi,6
- mov ecx,(MAX_MATCH-(2+4))/4 ; scan for at most MAX_MATCH bytes
- repe cmpsd ; loop until mismatch
-
- je trfin ; go to trfin if not unmatch
-; we determine the unmatch byte
- sub esi,4
- mov edx,[edi-4]
- xor edx,[esi]
-
- or dl,dl
- jnz trfin
- inc esi
-
- or dx,dx
- jnz trfin
- inc esi
-
- and edx,0ffffffh
- jnz trfin
- inc esi
-
-trfin:
- sub esi,scan ; esi = len
-trfinval:
-; here we have finised compare, and esi contain len of equal string
- cmp esi,best_len ; if len > best_len, go newbestlen
- ja short newbestlen
-; now we restore edx, ecx and esi, for the big loop
- mov esi,prev
- mov ecx,limit
- mov edx,window
- jmp contloop3
-
-newbestlen:
- mov best_len,esi ; len become best_len
-
- mov match_start,eax ; save new position as match_start
- cmp esi,nice_match ; if best_len >= nice_match, exit
- jae exitloop
- mov ecx,scan
- mov edx,window ; restore edx=window
- add ecx,esi
- add esi,edx
-
- dec esi
- mov windowlen,esi ; windowlen = window + best_len-1
- mov bx,[ecx-1] ; bx = *(scan+best_len-1) = scan_end
-
-; now we restore ecx and esi, for the big loop :
- mov esi,prev
- mov ecx,limit
- jmp contloop3
-
-exitloop:
-; exit : s->match_start=match_start
- mov ebx,match_start
- mov ebp,str_s
- mov ecx,best_len
- mov dword ptr [ebp+dep_match_start],ebx
- mov eax,dword ptr [ebp+dep_lookahead]
- cmp ecx,eax
- ja minexlo
- mov eax,ecx
-minexlo:
-; return min(best_len,s->lookahead)
-
-; restore stack and register ebx,esi,edi,ebp
- add esp,NbStackAdd
-
- pop ebx
- pop esi
- pop edi
- pop ebp
- ret
-InfoAuthor:
-; please don't remove this string !
-; Your are free use gvmat32 in any fre or commercial apps if you don't remove the string in the binary!
- db 0dh,0ah,"GVMat32 optimised assembly code written 1996-98 by Gilles Vollant",0dh,0ah
-
-
-
-IFDEF NOUNDERLINE
-longest_match_7fff endp
-ELSE
-_longest_match_7fff endp
-ENDIF
-
-
-IFDEF NOUNDERLINE
-cpudetect32 proc near
-ELSE
-_cpudetect32 proc near
-ENDIF
-
- push ebx
-
- pushfd ; push original EFLAGS
- pop eax ; get original EFLAGS
- mov ecx, eax ; save original EFLAGS
- xor eax, 40000h ; flip AC bit in EFLAGS
- push eax ; save new EFLAGS value on stack
- popfd ; replace current EFLAGS value
- pushfd ; get new EFLAGS
- pop eax ; store new EFLAGS in EAX
- xor eax, ecx ; can’t toggle AC bit, processor=80386
- jz end_cpu_is_386 ; jump if 80386 processor
- push ecx
- popfd ; restore AC bit in EFLAGS first
-
- pushfd
- pushfd
- pop ecx
-
- mov eax, ecx ; get original EFLAGS
- xor eax, 200000h ; flip ID bit in EFLAGS
- push eax ; save new EFLAGS value on stack
- popfd ; replace current EFLAGS value
- pushfd ; get new EFLAGS
- pop eax ; store new EFLAGS in EAX
- popfd ; restore original EFLAGS
- xor eax, ecx ; can’t toggle ID bit,
- je is_old_486 ; processor=old
-
- mov eax,1
- db 0fh,0a2h ;CPUID
-
-exitcpudetect:
- pop ebx
- ret
-
-end_cpu_is_386:
- mov eax,0300h
- jmp exitcpudetect
-
-is_old_486:
- mov eax,0400h
- jmp exitcpudetect
-
-IFDEF NOUNDERLINE
-cpudetect32 endp
-ELSE
-_cpudetect32 endp
-ENDIF
-ENDIF
-
-MAX_MATCH equ 258
-MIN_MATCH equ 3
-MIN_LOOKAHEAD equ (MAX_MATCH + MIN_MATCH + 1)
-MAX_MATCH_8_ equ ((MAX_MATCH + 7) AND 0FFF0h)
-
-
-;;; stack frame offsets
-
-chainlenwmask equ esp + 0 ; high word: current chain len
- ; low word: s->wmask
-window equ esp + 4 ; local copy of s->window
-windowbestlen equ esp + 8 ; s->window + bestlen
-scanstart equ esp + 16 ; first two bytes of string
-scanend equ esp + 12 ; last two bytes of string
-scanalign equ esp + 20 ; dword-misalignment of string
-nicematch equ esp + 24 ; a good enough match size
-bestlen equ esp + 28 ; size of best match so far
-scan equ esp + 32 ; ptr to string wanting match
-
-LocalVarsSize equ 36
-; saved ebx byte esp + 36
-; saved edi byte esp + 40
-; saved esi byte esp + 44
-; saved ebp byte esp + 48
-; return address byte esp + 52
-deflatestate equ esp + 56 ; the function arguments
-curmatch equ esp + 60
-
-;;; Offsets for fields in the deflate_state structure. These numbers
-;;; are calculated from the definition of deflate_state, with the
-;;; assumption that the compiler will dword-align the fields. (Thus,
-;;; changing the definition of deflate_state could easily cause this
-;;; program to crash horribly, without so much as a warning at
-;;; compile time. Sigh.)
-
-dsWSize equ 36+zlib1222add
-dsWMask equ 44+zlib1222add
-dsWindow equ 48+zlib1222add
-dsPrev equ 56+zlib1222add
-dsMatchLen equ 88+zlib1222add
-dsPrevMatch equ 92+zlib1222add
-dsStrStart equ 100+zlib1222add
-dsMatchStart equ 104+zlib1222add
-dsLookahead equ 108+zlib1222add
-dsPrevLen equ 112+zlib1222add
-dsMaxChainLen equ 116+zlib1222add
-dsGoodMatch equ 132+zlib1222add
-dsNiceMatch equ 136+zlib1222add
-
-
-;;; match.asm -- Pentium-Pro-optimized version of longest_match()
-;;; Written for zlib 1.1.2
-;;; Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com>
-;;; You can look at http://www.muppetlabs.com/~breadbox/software/assembly.html
-;;;
-;;; This is free software; you can redistribute it and/or modify it
-;;; under the terms of the GNU General Public License.
-
-;GLOBAL _longest_match, _match_init
-
-
-;SECTION .text
-
-;;; uInt longest_match(deflate_state *deflatestate, IPos curmatch)
-
-;_longest_match:
-IFDEF NOOLDPENTIUMCODE
- IFDEF NOUNDERLINE
- longest_match proc near
- ELSE
- _longest_match proc near
- ENDIF
-ELSE
- IFDEF NOUNDERLINE
- longest_match_686 proc near
- ELSE
- _longest_match_686 proc near
- ENDIF
-ENDIF
-
-;;; Save registers that the compiler may be using, and adjust esp to
-;;; make room for our stack frame.
-
- push ebp
- push edi
- push esi
- push ebx
- sub esp, LocalVarsSize
-
-;;; Retrieve the function arguments. ecx will hold cur_match
-;;; throughout the entire function. edx will hold the pointer to the
-;;; deflate_state structure during the function's setup (before
-;;; entering the main loop.
-
- mov edx, [deflatestate]
- mov ecx, [curmatch]
-
-;;; uInt wmask = s->w_mask;
-;;; unsigned chain_length = s->max_chain_length;
-;;; if (s->prev_length >= s->good_match) {
-;;; chain_length >>= 2;
-;;; }
-
- mov eax, [edx + dsPrevLen]
- mov ebx, [edx + dsGoodMatch]
- cmp eax, ebx
- mov eax, [edx + dsWMask]
- mov ebx, [edx + dsMaxChainLen]
- jl LastMatchGood
- shr ebx, 2
-LastMatchGood:
-
-;;; chainlen is decremented once beforehand so that the function can
-;;; use the sign flag instead of the zero flag for the exit test.
-;;; It is then shifted into the high word, to make room for the wmask
-;;; value, which it will always accompany.
-
- dec ebx
- shl ebx, 16
- or ebx, eax
- mov [chainlenwmask], ebx
-
-;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
-
- mov eax, [edx + dsNiceMatch]
- mov ebx, [edx + dsLookahead]
- cmp ebx, eax
- jl LookaheadLess
- mov ebx, eax
-LookaheadLess: mov [nicematch], ebx
-
-;;; register Bytef *scan = s->window + s->strstart;
-
- mov esi, [edx + dsWindow]
- mov [window], esi
- mov ebp, [edx + dsStrStart]
- lea edi, [esi + ebp]
- mov [scan], edi
-
-;;; Determine how many bytes the scan ptr is off from being
-;;; dword-aligned.
-
- mov eax, edi
- neg eax
- and eax, 3
- mov [scanalign], eax
-
-;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
-;;; s->strstart - (IPos)MAX_DIST(s) : NIL;
-
- mov eax, [edx + dsWSize]
- sub eax, MIN_LOOKAHEAD
- sub ebp, eax
- jg LimitPositive
- xor ebp, ebp
-LimitPositive:
-
-;;; int best_len = s->prev_length;
-
- mov eax, [edx + dsPrevLen]
- mov [bestlen], eax
-
-;;; Store the sum of s->window + best_len in esi locally, and in esi.
-
- add esi, eax
- mov [windowbestlen], esi
-
-;;; register ush scan_start = *(ushf*)scan;
-;;; register ush scan_end = *(ushf*)(scan+best_len-1);
-;;; Posf *prev = s->prev;
-
- movzx ebx, word ptr [edi]
- mov [scanstart], ebx
- movzx ebx, word ptr [edi + eax - 1]
- mov [scanend], ebx
- mov edi, [edx + dsPrev]
-
-;;; Jump into the main loop.
-
- mov edx, [chainlenwmask]
- jmp short LoopEntry
-
-align 4
-
-;;; do {
-;;; match = s->window + cur_match;
-;;; if (*(ushf*)(match+best_len-1) != scan_end ||
-;;; *(ushf*)match != scan_start) continue;
-;;; [...]
-;;; } while ((cur_match = prev[cur_match & wmask]) > limit
-;;; && --chain_length != 0);
-;;;
-;;; Here is the inner loop of the function. The function will spend the
-;;; majority of its time in this loop, and majority of that time will
-;;; be spent in the first ten instructions.
-;;;
-;;; Within this loop:
-;;; ebx = scanend
-;;; ecx = curmatch
-;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask)
-;;; esi = windowbestlen - i.e., (window + bestlen)
-;;; edi = prev
-;;; ebp = limit
-
-LookupLoop:
- and ecx, edx
- movzx ecx, word ptr [edi + ecx*2]
- cmp ecx, ebp
- jbe LeaveNow
- sub edx, 00010000h
- js LeaveNow
-LoopEntry: movzx eax, word ptr [esi + ecx - 1]
- cmp eax, ebx
- jnz LookupLoop
- mov eax, [window]
- movzx eax, word ptr [eax + ecx]
- cmp eax, [scanstart]
- jnz LookupLoop
-
-;;; Store the current value of chainlen.
-
- mov [chainlenwmask], edx
-
-;;; Point edi to the string under scrutiny, and esi to the string we
-;;; are hoping to match it up with. In actuality, esi and edi are
-;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is
-;;; initialized to -(MAX_MATCH_8 - scanalign).
-
- mov esi, [window]
- mov edi, [scan]
- add esi, ecx
- mov eax, [scanalign]
- mov edx, 0fffffef8h; -(MAX_MATCH_8)
- lea edi, [edi + eax + 0108h] ;MAX_MATCH_8]
- lea esi, [esi + eax + 0108h] ;MAX_MATCH_8]
-
-;;; Test the strings for equality, 8 bytes at a time. At the end,
-;;; adjust edx so that it is offset to the exact byte that mismatched.
-;;;
-;;; We already know at this point that the first three bytes of the
-;;; strings match each other, and they can be safely passed over before
-;;; starting the compare loop. So what this code does is skip over 0-3
-;;; bytes, as much as necessary in order to dword-align the edi
-;;; pointer. (esi will still be misaligned three times out of four.)
-;;;
-;;; It should be confessed that this loop usually does not represent
-;;; much of the total running time. Replacing it with a more
-;;; straightforward "rep cmpsb" would not drastically degrade
-;;; performance.
-
-LoopCmps:
- mov eax, [esi + edx]
- xor eax, [edi + edx]
- jnz LeaveLoopCmps
- mov eax, [esi + edx + 4]
- xor eax, [edi + edx + 4]
- jnz LeaveLoopCmps4
- add edx, 8
- jnz LoopCmps
- jmp short LenMaximum
-LeaveLoopCmps4: add edx, 4
-LeaveLoopCmps: test eax, 0000FFFFh
- jnz LenLower
- add edx, 2
- shr eax, 16
-LenLower: sub al, 1
- adc edx, 0
-
-;;; Calculate the length of the match. If it is longer than MAX_MATCH,
-;;; then automatically accept it as the best possible match and leave.
-
- lea eax, [edi + edx]
- mov edi, [scan]
- sub eax, edi
- cmp eax, MAX_MATCH
- jge LenMaximum
-
-;;; If the length of the match is not longer than the best match we
-;;; have so far, then forget it and return to the lookup loop.
-
- mov edx, [deflatestate]
- mov ebx, [bestlen]
- cmp eax, ebx
- jg LongerMatch
- mov esi, [windowbestlen]
- mov edi, [edx + dsPrev]
- mov ebx, [scanend]
- mov edx, [chainlenwmask]
- jmp LookupLoop
-
-;;; s->match_start = cur_match;
-;;; best_len = len;
-;;; if (len >= nice_match) break;
-;;; scan_end = *(ushf*)(scan+best_len-1);
-
-LongerMatch: mov ebx, [nicematch]
- mov [bestlen], eax
- mov [edx + dsMatchStart], ecx
- cmp eax, ebx
- jge LeaveNow
- mov esi, [window]
- add esi, eax
- mov [windowbestlen], esi
- movzx ebx, word ptr [edi + eax - 1]
- mov edi, [edx + dsPrev]
- mov [scanend], ebx
- mov edx, [chainlenwmask]
- jmp LookupLoop
-
-;;; Accept the current string, with the maximum possible length.
-
-LenMaximum: mov edx, [deflatestate]
- mov dword ptr [bestlen], MAX_MATCH
- mov [edx + dsMatchStart], ecx
-
-;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
-;;; return s->lookahead;
-
-LeaveNow:
- mov edx, [deflatestate]
- mov ebx, [bestlen]
- mov eax, [edx + dsLookahead]
- cmp ebx, eax
- jg LookaheadRet
- mov eax, ebx
-LookaheadRet:
-
-;;; Restore the stack and return from whence we came.
-
- add esp, LocalVarsSize
- pop ebx
- pop esi
- pop edi
- pop ebp
-
- ret
-; please don't remove this string !
-; Your can freely use gvmat32 in any free or commercial app if you don't remove the string in the binary!
- db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998",0dh,0ah
-
-
-IFDEF NOOLDPENTIUMCODE
- IFDEF NOUNDERLINE
- longest_match endp
- ELSE
- _longest_match endp
- ENDIF
-
- IFDEF NOUNDERLINE
- match_init proc near
- ret
- match_init endp
- ELSE
- _match_init proc near
- ret
- _match_init endp
- ENDIF
-ELSE
- IFDEF NOUNDERLINE
- longest_match_686 endp
- ELSE
- _longest_match_686 endp
- ENDIF
-ENDIF
-
-_TEXT ends
-end
diff --git a/source4/lib/zlib/contrib/masmx86/gvmat32.obj b/source4/lib/zlib/contrib/masmx86/gvmat32.obj
deleted file mode 100644
index ebb326238a..0000000000
--- a/source4/lib/zlib/contrib/masmx86/gvmat32.obj
+++ /dev/null
Binary files differ
diff --git a/source4/lib/zlib/contrib/masmx86/gvmat32c.c b/source4/lib/zlib/contrib/masmx86/gvmat32c.c
deleted file mode 100644
index 7ad2b27943..0000000000
--- a/source4/lib/zlib/contrib/masmx86/gvmat32c.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/* gvmat32.c -- C portion of the optimized longest_match for 32 bits x86
- * Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant.
- * File written by Gilles Vollant, by modifiying the longest_match
- * from Jean-loup Gailly in deflate.c
- * it prepare all parameters and call the assembly longest_match_gvasm
- * longest_match execute standard C code is wmask != 0x7fff
- * (assembly code is faster with a fixed wmask)
- *
- * Read comment at beginning of gvmat32.asm for more information
- */
-
-#if defined(ASMV) && (!defined(NOOLDPENTIUMCODE))
-#include "deflate.h"
-
-/* if your C compiler don't add underline before function name,
- define ADD_UNDERLINE_ASMFUNC */
-#ifdef ADD_UNDERLINE_ASMFUNC
-#define longest_match_7fff _longest_match_7fff
-#define longest_match_686 _longest_match_686
-#define cpudetect32 _cpudetect32
-#endif
-
-
-unsigned long cpudetect32();
-
-uInt longest_match_c(
- deflate_state *s,
- IPos cur_match); /* current match */
-
-
-uInt longest_match_7fff(
- deflate_state *s,
- IPos cur_match); /* current match */
-
-uInt longest_match_686(
- deflate_state *s,
- IPos cur_match); /* current match */
-
-
-static uInt iIsPPro=2;
-
-void match_init ()
-{
- iIsPPro = (((cpudetect32()/0x100)&0xf)>=6) ? 1 : 0;
-}
-
-uInt longest_match(
- deflate_state *s,
- IPos cur_match) /* current match */
-{
- if (iIsPPro!=0)
- return longest_match_686(s,cur_match);
-
- if (s->w_mask != 0x7fff)
- return longest_match_686(s,cur_match);
-
- /* now ((s->w_mask == 0x7fff) && (iIsPPro==0)) */
- return longest_match_7fff(s,cur_match);
-}
-
-
-#endif /* defined(ASMV) && (!defined(NOOLDPENTIUMCODE)) */
diff --git a/source4/lib/zlib/contrib/masmx86/inffas32.asm b/source4/lib/zlib/contrib/masmx86/inffas32.asm
deleted file mode 100644
index 4a205125ec..0000000000
--- a/source4/lib/zlib/contrib/masmx86/inffas32.asm
+++ /dev/null
@@ -1,1083 +0,0 @@
-;/* inffas32.asm is a hand tuned assembler version of inffast.c -- fast decoding
-; *
-; * inffas32.asm is derivated from inffas86.c, with translation of assembly code
-; *
-; * Copyright (C) 1995-2003 Mark Adler
-; * For conditions of distribution and use, see copyright notice in zlib.h
-; *
-; * Copyright (C) 2003 Chris Anderson <christop@charm.net>
-; * Please use the copyright conditions above.
-; *
-; * Mar-13-2003 -- Most of this is derived from inffast.S which is derived from
-; * the gcc -S output of zlib-1.2.0/inffast.c. Zlib-1.2.0 is in beta release at
-; * the moment. I have successfully compiled and tested this code with gcc2.96,
-; * gcc3.2, icc5.0, msvc6.0. It is very close to the speed of inffast.S
-; * compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX
-; * enabled. I will attempt to merge the MMX code into this version. Newer
-; * versions of this and inffast.S can be found at
-; * http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/
-; *
-; * 2005 : modification by Gilles Vollant
-; */
-; For Visual C++ 4.x and higher and ML 6.x and higher
-; ml.exe is in directory \MASM611C of Win95 DDK
-; ml.exe is also distributed in http://www.masm32.com/masmdl.htm
-; and in VC++2003 toolkit at http://msdn.microsoft.com/visualc/vctoolkit2003/
-;
-;
-; compile with command line option
-; ml /coff /Zi /c /Flinffas32.lst inffas32.asm
-
-; if you define NO_GZIP (see inflate.h), compile with
-; ml /coff /Zi /c /Flinffas32.lst /DNO_GUNZIP inffas32.asm
-
-
-; zlib122sup is 0 fort zlib 1.2.2.1 and lower
-; zlib122sup is 8 fort zlib 1.2.2.2 and more (with addition of dmax and head
-; in inflate_state in inflate.h)
-zlib1222sup equ 8
-
-
-IFDEF GUNZIP
- INFLATE_MODE_TYPE equ 11
- INFLATE_MODE_BAD equ 26
-ELSE
- IFNDEF NO_GUNZIP
- INFLATE_MODE_TYPE equ 11
- INFLATE_MODE_BAD equ 26
- ELSE
- INFLATE_MODE_TYPE equ 3
- INFLATE_MODE_BAD equ 17
- ENDIF
-ENDIF
-
-
-; 75 "inffast.S"
-;FILE "inffast.S"
-
-;;;GLOBAL _inflate_fast
-
-;;;SECTION .text
-
-
-
- .586p
- .mmx
-
- name inflate_fast_x86
- .MODEL FLAT
-
-_DATA segment
-inflate_fast_use_mmx:
- dd 1
-
-
-_TEXT segment
-PUBLIC _inflate_fast
-
-ALIGN 4
-_inflate_fast:
- jmp inflate_fast_entry
-
-
-
-ALIGN 4
- db 'Fast decoding Code from Chris Anderson'
- db 0
-
-ALIGN 4
-invalid_literal_length_code_msg:
- db 'invalid literal/length code'
- db 0
-
-ALIGN 4
-invalid_distance_code_msg:
- db 'invalid distance code'
- db 0
-
-ALIGN 4
-invalid_distance_too_far_msg:
- db 'invalid distance too far back'
- db 0
-
-
-ALIGN 4
-inflate_fast_mask:
-dd 0
-dd 1
-dd 3
-dd 7
-dd 15
-dd 31
-dd 63
-dd 127
-dd 255
-dd 511
-dd 1023
-dd 2047
-dd 4095
-dd 8191
-dd 16383
-dd 32767
-dd 65535
-dd 131071
-dd 262143
-dd 524287
-dd 1048575
-dd 2097151
-dd 4194303
-dd 8388607
-dd 16777215
-dd 33554431
-dd 67108863
-dd 134217727
-dd 268435455
-dd 536870911
-dd 1073741823
-dd 2147483647
-dd 4294967295
-
-
-mode_state equ 0 ;/* state->mode */
-wsize_state equ (32+zlib1222sup) ;/* state->wsize */
-write_state equ (36+4+zlib1222sup) ;/* state->write */
-window_state equ (40+4+zlib1222sup) ;/* state->window */
-hold_state equ (44+4+zlib1222sup) ;/* state->hold */
-bits_state equ (48+4+zlib1222sup) ;/* state->bits */
-lencode_state equ (64+4+zlib1222sup) ;/* state->lencode */
-distcode_state equ (68+4+zlib1222sup) ;/* state->distcode */
-lenbits_state equ (72+4+zlib1222sup) ;/* state->lenbits */
-distbits_state equ (76+4+zlib1222sup) ;/* state->distbits */
-
-
-;;SECTION .text
-; 205 "inffast.S"
-;GLOBAL inflate_fast_use_mmx
-
-;SECTION .data
-
-
-; GLOBAL inflate_fast_use_mmx:object
-;.size inflate_fast_use_mmx, 4
-; 226 "inffast.S"
-;SECTION .text
-
-ALIGN 4
-inflate_fast_entry:
- push edi
- push esi
- push ebp
- push ebx
- pushfd
- sub esp,64
- cld
-
-
-
-
- mov esi, [esp+88]
- mov edi, [esi+28]
-
-
-
-
-
-
-
- mov edx, [esi+4]
- mov eax, [esi+0]
-
- add edx,eax
- sub edx,11
-
- mov [esp+44],eax
- mov [esp+20],edx
-
- mov ebp, [esp+92]
- mov ecx, [esi+16]
- mov ebx, [esi+12]
-
- sub ebp,ecx
- neg ebp
- add ebp,ebx
-
- sub ecx,257
- add ecx,ebx
-
- mov [esp+60],ebx
- mov [esp+40],ebp
- mov [esp+16],ecx
-; 285 "inffast.S"
- mov eax, [edi+lencode_state]
- mov ecx, [edi+distcode_state]
-
- mov [esp+8],eax
- mov [esp+12],ecx
-
- mov eax,1
- mov ecx, [edi+lenbits_state]
- shl eax,cl
- dec eax
- mov [esp+0],eax
-
- mov eax,1
- mov ecx, [edi+distbits_state]
- shl eax,cl
- dec eax
- mov [esp+4],eax
-
- mov eax, [edi+wsize_state]
- mov ecx, [edi+write_state]
- mov edx, [edi+window_state]
-
- mov [esp+52],eax
- mov [esp+48],ecx
- mov [esp+56],edx
-
- mov ebp, [edi+hold_state]
- mov ebx, [edi+bits_state]
-; 321 "inffast.S"
- mov esi, [esp+44]
- mov ecx, [esp+20]
- cmp ecx,esi
- ja L_align_long
-
- add ecx,11
- sub ecx,esi
- mov eax,12
- sub eax,ecx
- lea edi, [esp+28]
- rep movsb
- mov ecx,eax
- xor eax,eax
- rep stosb
- lea esi, [esp+28]
- mov [esp+20],esi
- jmp L_is_aligned
-
-
-L_align_long:
- test esi,3
- jz L_is_aligned
- xor eax,eax
- mov al, [esi]
- inc esi
- mov ecx,ebx
- add ebx,8
- shl eax,cl
- or ebp,eax
- jmp L_align_long
-
-L_is_aligned:
- mov edi, [esp+60]
-; 366 "inffast.S"
-L_check_mmx:
- cmp dword ptr [inflate_fast_use_mmx],2
- je L_init_mmx
- ja L_do_loop
-
- push eax
- push ebx
- push ecx
- push edx
- pushfd
- mov eax, [esp]
- xor dword ptr [esp],0200000h
-
-
-
-
- popfd
- pushfd
- pop edx
- xor edx,eax
- jz L_dont_use_mmx
- xor eax,eax
- cpuid
- cmp ebx,0756e6547h
- jne L_dont_use_mmx
- cmp ecx,06c65746eh
- jne L_dont_use_mmx
- cmp edx,049656e69h
- jne L_dont_use_mmx
- mov eax,1
- cpuid
- shr eax,8
- and eax,15
- cmp eax,6
- jne L_dont_use_mmx
- test edx,0800000h
- jnz L_use_mmx
- jmp L_dont_use_mmx
-L_use_mmx:
- mov dword ptr [inflate_fast_use_mmx],2
- jmp L_check_mmx_pop
-L_dont_use_mmx:
- mov dword ptr [inflate_fast_use_mmx],3
-L_check_mmx_pop:
- pop edx
- pop ecx
- pop ebx
- pop eax
- jmp L_check_mmx
-; 426 "inffast.S"
-ALIGN 4
-L_do_loop:
-; 437 "inffast.S"
- cmp bl,15
- ja L_get_length_code
-
- xor eax,eax
- lodsw
- mov cl,bl
- add bl,16
- shl eax,cl
- or ebp,eax
-
-L_get_length_code:
- mov edx, [esp+0]
- mov ecx, [esp+8]
- and edx,ebp
- mov eax, [ecx+edx*4]
-
-L_dolen:
-
-
-
-
-
-
- mov cl,ah
- sub bl,ah
- shr ebp,cl
-
-
-
-
-
-
- test al,al
- jnz L_test_for_length_base
-
- shr eax,16
- stosb
-
-L_while_test:
-
-
- cmp [esp+16],edi
- jbe L_break_loop
-
- cmp [esp+20],esi
- ja L_do_loop
- jmp L_break_loop
-
-L_test_for_length_base:
-; 502 "inffast.S"
- mov edx,eax
- shr edx,16
- mov cl,al
-
- test al,16
- jz L_test_for_second_level_length
- and cl,15
- jz L_save_len
- cmp bl,cl
- jae L_add_bits_to_len
-
- mov ch,cl
- xor eax,eax
- lodsw
- mov cl,bl
- add bl,16
- shl eax,cl
- or ebp,eax
- mov cl,ch
-
-L_add_bits_to_len:
- mov eax,1
- shl eax,cl
- dec eax
- sub bl,cl
- and eax,ebp
- shr ebp,cl
- add edx,eax
-
-L_save_len:
- mov [esp+24],edx
-
-
-L_decode_distance:
-; 549 "inffast.S"
- cmp bl,15
- ja L_get_distance_code
-
- xor eax,eax
- lodsw
- mov cl,bl
- add bl,16
- shl eax,cl
- or ebp,eax
-
-L_get_distance_code:
- mov edx, [esp+4]
- mov ecx, [esp+12]
- and edx,ebp
- mov eax, [ecx+edx*4]
-
-
-L_dodist:
- mov edx,eax
- shr edx,16
- mov cl,ah
- sub bl,ah
- shr ebp,cl
-; 584 "inffast.S"
- mov cl,al
-
- test al,16
- jz L_test_for_second_level_dist
- and cl,15
- jz L_check_dist_one
- cmp bl,cl
- jae L_add_bits_to_dist
-
- mov ch,cl
- xor eax,eax
- lodsw
- mov cl,bl
- add bl,16
- shl eax,cl
- or ebp,eax
- mov cl,ch
-
-L_add_bits_to_dist:
- mov eax,1
- shl eax,cl
- dec eax
- sub bl,cl
- and eax,ebp
- shr ebp,cl
- add edx,eax
- jmp L_check_window
-
-L_check_window:
-; 625 "inffast.S"
- mov [esp+44],esi
- mov eax,edi
- sub eax, [esp+40]
-
- cmp eax,edx
- jb L_clip_window
-
- mov ecx, [esp+24]
- mov esi,edi
- sub esi,edx
-
- sub ecx,3
- mov al, [esi]
- mov [edi],al
- mov al, [esi+1]
- mov dl, [esi+2]
- add esi,3
- mov [edi+1],al
- mov [edi+2],dl
- add edi,3
- rep movsb
-
- mov esi, [esp+44]
- jmp L_while_test
-
-ALIGN 4
-L_check_dist_one:
- cmp edx,1
- jne L_check_window
- cmp [esp+40],edi
- je L_check_window
-
- dec edi
- mov ecx, [esp+24]
- mov al, [edi]
- sub ecx,3
-
- mov [edi+1],al
- mov [edi+2],al
- mov [edi+3],al
- add edi,4
- rep stosb
-
- jmp L_while_test
-
-ALIGN 4
-L_test_for_second_level_length:
-
-
-
-
- test al,64
- jnz L_test_for_end_of_block
-
- mov eax,1
- shl eax,cl
- dec eax
- and eax,ebp
- add eax,edx
- mov edx, [esp+8]
- mov eax, [edx+eax*4]
- jmp L_dolen
-
-ALIGN 4
-L_test_for_second_level_dist:
-
-
-
-
- test al,64
- jnz L_invalid_distance_code
-
- mov eax,1
- shl eax,cl
- dec eax
- and eax,ebp
- add eax,edx
- mov edx, [esp+12]
- mov eax, [edx+eax*4]
- jmp L_dodist
-
-ALIGN 4
-L_clip_window:
-; 721 "inffast.S"
- mov ecx,eax
- mov eax, [esp+52]
- neg ecx
- mov esi, [esp+56]
-
- cmp eax,edx
- jb L_invalid_distance_too_far
-
- add ecx,edx
- cmp dword ptr [esp+48],0
- jne L_wrap_around_window
-
- sub eax,ecx
- add esi,eax
-; 749 "inffast.S"
- mov eax, [esp+24]
- cmp eax,ecx
- jbe L_do_copy1
-
- sub eax,ecx
- rep movsb
- mov esi,edi
- sub esi,edx
- jmp L_do_copy1
-
- cmp eax,ecx
- jbe L_do_copy1
-
- sub eax,ecx
- rep movsb
- mov esi,edi
- sub esi,edx
- jmp L_do_copy1
-
-L_wrap_around_window:
-; 793 "inffast.S"
- mov eax, [esp+48]
- cmp ecx,eax
- jbe L_contiguous_in_window
-
- add esi, [esp+52]
- add esi,eax
- sub esi,ecx
- sub ecx,eax
-
-
- mov eax, [esp+24]
- cmp eax,ecx
- jbe L_do_copy1
-
- sub eax,ecx
- rep movsb
- mov esi, [esp+56]
- mov ecx, [esp+48]
- cmp eax,ecx
- jbe L_do_copy1
-
- sub eax,ecx
- rep movsb
- mov esi,edi
- sub esi,edx
- jmp L_do_copy1
-
-L_contiguous_in_window:
-; 836 "inffast.S"
- add esi,eax
- sub esi,ecx
-
-
- mov eax, [esp+24]
- cmp eax,ecx
- jbe L_do_copy1
-
- sub eax,ecx
- rep movsb
- mov esi,edi
- sub esi,edx
-
-L_do_copy1:
-; 862 "inffast.S"
- mov ecx,eax
- rep movsb
-
- mov esi, [esp+44]
- jmp L_while_test
-; 878 "inffast.S"
-ALIGN 4
-L_init_mmx:
- emms
-
-
-
-
-
- movd mm0,ebp
- mov ebp,ebx
-; 896 "inffast.S"
- movd mm4,[esp+0]
- movq mm3,mm4
- movd mm5,[esp+4]
- movq mm2,mm5
- pxor mm1,mm1
- mov ebx, [esp+8]
- jmp L_do_loop_mmx
-
-ALIGN 4
-L_do_loop_mmx:
- psrlq mm0,mm1
-
- cmp ebp,32
- ja L_get_length_code_mmx
-
- movd mm6,ebp
- movd mm7,[esi]
- add esi,4
- psllq mm7,mm6
- add ebp,32
- por mm0,mm7
-
-L_get_length_code_mmx:
- pand mm4,mm0
- movd eax,mm4
- movq mm4,mm3
- mov eax, [ebx+eax*4]
-
-L_dolen_mmx:
- movzx ecx,ah
- movd mm1,ecx
- sub ebp,ecx
-
- test al,al
- jnz L_test_for_length_base_mmx
-
- shr eax,16
- stosb
-
-L_while_test_mmx:
-
-
- cmp [esp+16],edi
- jbe L_break_loop
-
- cmp [esp+20],esi
- ja L_do_loop_mmx
- jmp L_break_loop
-
-L_test_for_length_base_mmx:
-
- mov edx,eax
- shr edx,16
-
- test al,16
- jz L_test_for_second_level_length_mmx
- and eax,15
- jz L_decode_distance_mmx
-
- psrlq mm0,mm1
- movd mm1,eax
- movd ecx,mm0
- sub ebp,eax
- and ecx, [inflate_fast_mask+eax*4]
- add edx,ecx
-
-L_decode_distance_mmx:
- psrlq mm0,mm1
-
- cmp ebp,32
- ja L_get_dist_code_mmx
-
- movd mm6,ebp
- movd mm7,[esi]
- add esi,4
- psllq mm7,mm6
- add ebp,32
- por mm0,mm7
-
-L_get_dist_code_mmx:
- mov ebx, [esp+12]
- pand mm5,mm0
- movd eax,mm5
- movq mm5,mm2
- mov eax, [ebx+eax*4]
-
-L_dodist_mmx:
-
- movzx ecx,ah
- mov ebx,eax
- shr ebx,16
- sub ebp,ecx
- movd mm1,ecx
-
- test al,16
- jz L_test_for_second_level_dist_mmx
- and eax,15
- jz L_check_dist_one_mmx
-
-L_add_bits_to_dist_mmx:
- psrlq mm0,mm1
- movd mm1,eax
- movd ecx,mm0
- sub ebp,eax
- and ecx, [inflate_fast_mask+eax*4]
- add ebx,ecx
-
-L_check_window_mmx:
- mov [esp+44],esi
- mov eax,edi
- sub eax, [esp+40]
-
- cmp eax,ebx
- jb L_clip_window_mmx
-
- mov ecx,edx
- mov esi,edi
- sub esi,ebx
-
- sub ecx,3
- mov al, [esi]
- mov [edi],al
- mov al, [esi+1]
- mov dl, [esi+2]
- add esi,3
- mov [edi+1],al
- mov [edi+2],dl
- add edi,3
- rep movsb
-
- mov esi, [esp+44]
- mov ebx, [esp+8]
- jmp L_while_test_mmx
-
-ALIGN 4
-L_check_dist_one_mmx:
- cmp ebx,1
- jne L_check_window_mmx
- cmp [esp+40],edi
- je L_check_window_mmx
-
- dec edi
- mov ecx,edx
- mov al, [edi]
- sub ecx,3
-
- mov [edi+1],al
- mov [edi+2],al
- mov [edi+3],al
- add edi,4
- rep stosb
-
- mov ebx, [esp+8]
- jmp L_while_test_mmx
-
-ALIGN 4
-L_test_for_second_level_length_mmx:
- test al,64
- jnz L_test_for_end_of_block
-
- and eax,15
- psrlq mm0,mm1
- movd ecx,mm0
- and ecx, [inflate_fast_mask+eax*4]
- add ecx,edx
- mov eax, [ebx+ecx*4]
- jmp L_dolen_mmx
-
-ALIGN 4
-L_test_for_second_level_dist_mmx:
- test al,64
- jnz L_invalid_distance_code
-
- and eax,15
- psrlq mm0,mm1
- movd ecx,mm0
- and ecx, [inflate_fast_mask+eax*4]
- mov eax, [esp+12]
- add ecx,ebx
- mov eax, [eax+ecx*4]
- jmp L_dodist_mmx
-
-ALIGN 4
-L_clip_window_mmx:
-
- mov ecx,eax
- mov eax, [esp+52]
- neg ecx
- mov esi, [esp+56]
-
- cmp eax,ebx
- jb L_invalid_distance_too_far
-
- add ecx,ebx
- cmp dword ptr [esp+48],0
- jne L_wrap_around_window_mmx
-
- sub eax,ecx
- add esi,eax
-
- cmp edx,ecx
- jbe L_do_copy1_mmx
-
- sub edx,ecx
- rep movsb
- mov esi,edi
- sub esi,ebx
- jmp L_do_copy1_mmx
-
- cmp edx,ecx
- jbe L_do_copy1_mmx
-
- sub edx,ecx
- rep movsb
- mov esi,edi
- sub esi,ebx
- jmp L_do_copy1_mmx
-
-L_wrap_around_window_mmx:
-
- mov eax, [esp+48]
- cmp ecx,eax
- jbe L_contiguous_in_window_mmx
-
- add esi, [esp+52]
- add esi,eax
- sub esi,ecx
- sub ecx,eax
-
-
- cmp edx,ecx
- jbe L_do_copy1_mmx
-
- sub edx,ecx
- rep movsb
- mov esi, [esp+56]
- mov ecx, [esp+48]
- cmp edx,ecx
- jbe L_do_copy1_mmx
-
- sub edx,ecx
- rep movsb
- mov esi,edi
- sub esi,ebx
- jmp L_do_copy1_mmx
-
-L_contiguous_in_window_mmx:
-
- add esi,eax
- sub esi,ecx
-
-
- cmp edx,ecx
- jbe L_do_copy1_mmx
-
- sub edx,ecx
- rep movsb
- mov esi,edi
- sub esi,ebx
-
-L_do_copy1_mmx:
-
-
- mov ecx,edx
- rep movsb
-
- mov esi, [esp+44]
- mov ebx, [esp+8]
- jmp L_while_test_mmx
-; 1174 "inffast.S"
-L_invalid_distance_code:
-
-
-
-
-
- mov ecx, invalid_distance_code_msg
- mov edx,INFLATE_MODE_BAD
- jmp L_update_stream_state
-
-L_test_for_end_of_block:
-
-
-
-
-
- test al,32
- jz L_invalid_literal_length_code
-
- mov ecx,0
- mov edx,INFLATE_MODE_TYPE
- jmp L_update_stream_state
-
-L_invalid_literal_length_code:
-
-
-
-
-
- mov ecx, invalid_literal_length_code_msg
- mov edx,INFLATE_MODE_BAD
- jmp L_update_stream_state
-
-L_invalid_distance_too_far:
-
-
-
- mov esi, [esp+44]
- mov ecx, invalid_distance_too_far_msg
- mov edx,INFLATE_MODE_BAD
- jmp L_update_stream_state
-
-L_update_stream_state:
-
- mov eax, [esp+88]
- test ecx,ecx
- jz L_skip_msg
- mov [eax+24],ecx
-L_skip_msg:
- mov eax, [eax+28]
- mov [eax+mode_state],edx
- jmp L_break_loop
-
-ALIGN 4
-L_break_loop:
-; 1243 "inffast.S"
- cmp dword ptr [inflate_fast_use_mmx],2
- jne L_update_next_in
-
-
-
- mov ebx,ebp
-
-L_update_next_in:
-; 1266 "inffast.S"
- mov eax, [esp+88]
- mov ecx,ebx
- mov edx, [eax+28]
- shr ecx,3
- sub esi,ecx
- shl ecx,3
- sub ebx,ecx
- mov [eax+12],edi
- mov [edx+bits_state],ebx
- mov ecx,ebx
-
- lea ebx, [esp+28]
- cmp [esp+20],ebx
- jne L_buf_not_used
-
- sub esi,ebx
- mov ebx, [eax+0]
- mov [esp+20],ebx
- add esi,ebx
- mov ebx, [eax+4]
- sub ebx,11
- add [esp+20],ebx
-
-L_buf_not_used:
- mov [eax+0],esi
-
- mov ebx,1
- shl ebx,cl
- dec ebx
-
-
-
-
-
- cmp dword ptr [inflate_fast_use_mmx],2
- jne L_update_hold
-
-
-
- psrlq mm0,mm1
- movd ebp,mm0
-
- emms
-
-L_update_hold:
-
-
-
- and ebp,ebx
- mov [edx+hold_state],ebp
-
-
-
-
- mov ebx, [esp+20]
- cmp ebx,esi
- jbe L_last_is_smaller
-
- sub ebx,esi
- add ebx,11
- mov [eax+4],ebx
- jmp L_fixup_out
-L_last_is_smaller:
- sub esi,ebx
- neg esi
- add esi,11
- mov [eax+4],esi
-
-
-
-
-L_fixup_out:
-
- mov ebx, [esp+16]
- cmp ebx,edi
- jbe L_end_is_smaller
-
- sub ebx,edi
- add ebx,257
- mov [eax+16],ebx
- jmp L_done
-L_end_is_smaller:
- sub edi,ebx
- neg edi
- add edi,257
- mov [eax+16],edi
-
-
-
-
-
-L_done:
- add esp,64
- popfd
- pop ebx
- pop ebp
- pop esi
- pop edi
- ret
-
-_TEXT ends
-end
diff --git a/source4/lib/zlib/contrib/masmx86/inffas32.obj b/source4/lib/zlib/contrib/masmx86/inffas32.obj
deleted file mode 100644
index bd6664d111..0000000000
--- a/source4/lib/zlib/contrib/masmx86/inffas32.obj
+++ /dev/null
Binary files differ
diff --git a/source4/lib/zlib/contrib/masmx86/mkasm.bat b/source4/lib/zlib/contrib/masmx86/mkasm.bat
deleted file mode 100755
index 70a51f8377..0000000000
--- a/source4/lib/zlib/contrib/masmx86/mkasm.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-cl /DASMV /I..\.. /O2 /c gvmat32c.c
-ml /coff /Zi /c /Flgvmat32.lst gvmat32.asm
-ml /coff /Zi /c /Flinffas32.lst inffas32.asm
diff --git a/source4/lib/zlib/contrib/masmx86/readme.txt b/source4/lib/zlib/contrib/masmx86/readme.txt
deleted file mode 100644
index 7b57167b71..0000000000
--- a/source4/lib/zlib/contrib/masmx86/readme.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-
-Summary
--------
-This directory contains ASM implementations of the functions
-longest_match() and inflate_fast().
-
-
-Use instructions
-----------------
-Copy these files into the zlib source directory, then run the
-appropriate makefile, as suggested below.
-
-
-Build instructions
-------------------
-* With Microsoft C and MASM:
-nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" OBJA="gvmat32c.obj gvmat32.obj inffas32.obj"
-
-* With Borland C and TASM:
-make -f win32/Makefile.bor LOCAL_ZLIB="-DASMV -DASMINF" OBJA="gvmat32c.obj gvmat32.obj inffas32.obj" OBJPA="+gvmat32c.obj+gvmat32.obj+inffas32.obj"
-
diff --git a/source4/lib/zlib/contrib/minizip/ChangeLogUnzip b/source4/lib/zlib/contrib/minizip/ChangeLogUnzip
deleted file mode 100644
index 50ca6a9e0f..0000000000
--- a/source4/lib/zlib/contrib/minizip/ChangeLogUnzip
+++ /dev/null
@@ -1,67 +0,0 @@
-Change in 1.01e (12 feb 05)
-- Fix in zipOpen2 for globalcomment (Rolf Kalbermatter)
-- Fix possible memory leak in unzip.c (Zoran Stevanovic)
-
-Change in 1.01b (20 may 04)
-- Integrate patch from Debian package (submited by Mark Brown)
-- Add tools mztools from Xavier Roche
-
-Change in 1.01 (8 may 04)
-- fix buffer overrun risk in unzip.c (Xavier Roche)
-- fix a minor buffer insecurity in minizip.c (Mike Whittaker)
-
-Change in 1.00: (10 sept 03)
-- rename to 1.00
-- cosmetic code change
-
-Change in 0.22: (19 May 03)
-- crypting support (unless you define NOCRYPT)
-- append file in existing zipfile
-
-Change in 0.21: (10 Mar 03)
-- bug fixes
-
-Change in 0.17: (27 Jan 02)
-- bug fixes
-
-Change in 0.16: (19 Jan 02)
-- Support of ioapi for virtualize zip file access
-
-Change in 0.15: (19 Mar 98)
-- fix memory leak in minizip.c
-
-Change in 0.14: (10 Mar 98)
-- fix bugs in minizip.c sample for zipping big file
-- fix problem in month in date handling
-- fix bug in unzlocal_GetCurrentFileInfoInternal in unzip.c for
- comment handling
-
-Change in 0.13: (6 Mar 98)
-- fix bugs in zip.c
-- add real minizip sample
-
-Change in 0.12: (4 Mar 98)
-- add zip.c and zip.h for creates .zip file
-- fix change_file_date in miniunz.c for Unix (Jean-loup Gailly)
-- fix miniunz.c for file without specific record for directory
-
-Change in 0.11: (3 Mar 98)
-- fix bug in unzGetCurrentFileInfo for get extra field and comment
-- enhance miniunz sample, remove the bad unztst.c sample
-
-Change in 0.10: (2 Mar 98)
-- fix bug in unzReadCurrentFile
-- rename unzip* to unz* function and structure
-- remove Windows-like hungary notation variable name
-- modify some structure in unzip.h
-- add somes comment in source
-- remove unzipGetcCurrentFile function
-- replace ZUNZEXPORT by ZEXPORT
-- add unzGetLocalExtrafield for get the local extrafield info
-- add a new sample, miniunz.c
-
-Change in 0.4: (25 Feb 98)
-- suppress the type unzipFileInZip.
- Only on file in the zipfile can be open at the same time
-- fix somes typo in code
-- added tm_unz structure in unzip_file_info (date/time in readable format)
diff --git a/source4/lib/zlib/contrib/minizip/Makefile b/source4/lib/zlib/contrib/minizip/Makefile
deleted file mode 100644
index 84eaad20d4..0000000000
--- a/source4/lib/zlib/contrib/minizip/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-CC=cc
-CFLAGS=-O -I../..
-
-UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a
-ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a
-
-.c.o:
- $(CC) -c $(CFLAGS) $*.c
-
-all: miniunz minizip
-
-miniunz: $(UNZ_OBJS)
- $(CC) $(CFLAGS) -o $@ $(UNZ_OBJS)
-
-minizip: $(ZIP_OBJS)
- $(CC) $(CFLAGS) -o $@ $(ZIP_OBJS)
-
-test: miniunz minizip
- ./minizip test readme.txt
- ./miniunz -l test.zip
- mv readme.txt readme.old
- ./miniunz test.zip
-
-clean:
- /bin/rm -f *.o *~ minizip miniunz
diff --git a/source4/lib/zlib/contrib/minizip/crypt.h b/source4/lib/zlib/contrib/minizip/crypt.h
deleted file mode 100644
index 622f4bc2ec..0000000000
--- a/source4/lib/zlib/contrib/minizip/crypt.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/* crypt.h -- base code for crypt/uncrypt ZIPfile
-
-
- Version 1.01e, February 12th, 2005
-
- Copyright (C) 1998-2005 Gilles Vollant
-
- This code is a modified version of crypting code in Infozip distribution
-
- The encryption/decryption parts of this source code (as opposed to the
- non-echoing password parts) were originally written in Europe. The
- whole source package can be freely distributed, including from the USA.
- (Prior to January 2000, re-export from the US was a violation of US law.)
-
- This encryption code is a direct transcription of the algorithm from
- Roger Schlafly, described by Phil Katz in the file appnote.txt. This
- file (appnote.txt) is distributed with the PKZIP program (even in the
- version without encryption capabilities).
-
- If you don't need crypting in your application, just define symbols
- NOCRYPT and NOUNCRYPT.
-
- This code support the "Traditional PKWARE Encryption".
-
- The new AES encryption added on Zip format by Winzip (see the page
- http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
- Encryption is not supported.
-*/
-
-#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
-
-/***********************************************************************
- * Return the next byte in the pseudo-random sequence
- */
-static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
-{
- unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
- * unpredictable manner on 16-bit systems; not a problem
- * with any known compiler so far, though */
-
- temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
- return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
-}
-
-/***********************************************************************
- * Update the encryption keys with the next byte of plain text
- */
-static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)
-{
- (*(pkeys+0)) = CRC32((*(pkeys+0)), c);
- (*(pkeys+1)) += (*(pkeys+0)) & 0xff;
- (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
- {
- register int keyshift = (int)((*(pkeys+1)) >> 24);
- (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
- }
- return c;
-}
-
-
-/***********************************************************************
- * Initialize the encryption keys and the random header according to
- * the given password.
- */
-static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)
-{
- *(pkeys+0) = 305419896L;
- *(pkeys+1) = 591751049L;
- *(pkeys+2) = 878082192L;
- while (*passwd != '\0') {
- update_keys(pkeys,pcrc_32_tab,(int)*passwd);
- passwd++;
- }
-}
-
-#define zdecode(pkeys,pcrc_32_tab,c) \
- (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
-
-#define zencode(pkeys,pcrc_32_tab,c,t) \
- (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
-
-#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
-
-#define RAND_HEAD_LEN 12
- /* "last resort" source for second part of crypt seed pattern */
-# ifndef ZCR_SEED2
-# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
-# endif
-
-static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
- const char *passwd; /* password string */
- unsigned char *buf; /* where to write header */
- int bufSize;
- unsigned long* pkeys;
- const unsigned long* pcrc_32_tab;
- unsigned long crcForCrypting;
-{
- int n; /* index in random header */
- int t; /* temporary */
- int c; /* random byte */
- unsigned char header[RAND_HEAD_LEN-2]; /* random header */
- static unsigned calls = 0; /* ensure different random header each time */
-
- if (bufSize<RAND_HEAD_LEN)
- return 0;
-
- /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
- * output of rand() to get less predictability, since rand() is
- * often poorly implemented.
- */
- if (++calls == 1)
- {
- srand((unsigned)(time(NULL) ^ ZCR_SEED2));
- }
- init_keys(passwd, pkeys, pcrc_32_tab);
- for (n = 0; n < RAND_HEAD_LEN-2; n++)
- {
- c = (rand() >> 7) & 0xff;
- header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
- }
- /* Encrypt random header (last two bytes is high word of crc) */
- init_keys(passwd, pkeys, pcrc_32_tab);
- for (n = 0; n < RAND_HEAD_LEN-2; n++)
- {
- buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
- }
- buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
- buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
- return n;
-}
-
-#endif
diff --git a/source4/lib/zlib/contrib/minizip/ioapi.c b/source4/lib/zlib/contrib/minizip/ioapi.c
deleted file mode 100644
index f1bee23e64..0000000000
--- a/source4/lib/zlib/contrib/minizip/ioapi.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/* ioapi.c -- IO base function header for compress/uncompress .zip
- files using zlib + zip or unzip API
-
- Version 1.01e, February 12th, 2005
-
- Copyright (C) 1998-2005 Gilles Vollant
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "zlib.h"
-#include "ioapi.h"
-
-
-
-/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
-
-#ifndef SEEK_CUR
-#define SEEK_CUR 1
-#endif
-
-#ifndef SEEK_END
-#define SEEK_END 2
-#endif
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-
-voidpf ZCALLBACK fopen_file_func OF((
- voidpf opaque,
- const char* filename,
- int mode));
-
-uLong ZCALLBACK fread_file_func OF((
- voidpf opaque,
- voidpf stream,
- void* buf,
- uLong size));
-
-uLong ZCALLBACK fwrite_file_func OF((
- voidpf opaque,
- voidpf stream,
- const void* buf,
- uLong size));
-
-long ZCALLBACK ftell_file_func OF((
- voidpf opaque,
- voidpf stream));
-
-long ZCALLBACK fseek_file_func OF((
- voidpf opaque,
- voidpf stream,
- uLong offset,
- int origin));
-
-int ZCALLBACK fclose_file_func OF((
- voidpf opaque,
- voidpf stream));
-
-int ZCALLBACK ferror_file_func OF((
- voidpf opaque,
- voidpf stream));
-
-
-voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
- voidpf opaque;
- const char* filename;
- int mode;
-{
- FILE* file = NULL;
- const char* mode_fopen = NULL;
- if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
- mode_fopen = "rb";
- else
- if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
- mode_fopen = "r+b";
- else
- if (mode & ZLIB_FILEFUNC_MODE_CREATE)
- mode_fopen = "wb";
-
- if ((filename!=NULL) && (mode_fopen != NULL))
- file = fopen(filename, mode_fopen);
- return file;
-}
-
-
-uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
- voidpf opaque;
- voidpf stream;
- void* buf;
- uLong size;
-{
- uLong ret;
- ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
- return ret;
-}
-
-
-uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
- voidpf opaque;
- voidpf stream;
- const void* buf;
- uLong size;
-{
- uLong ret;
- ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
- return ret;
-}
-
-long ZCALLBACK ftell_file_func (opaque, stream)
- voidpf opaque;
- voidpf stream;
-{
- long ret;
- ret = ftell((FILE *)stream);
- return ret;
-}
-
-long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
- voidpf opaque;
- voidpf stream;
- uLong offset;
- int origin;
-{
- int fseek_origin=0;
- long ret;
- switch (origin)
- {
- case ZLIB_FILEFUNC_SEEK_CUR :
- fseek_origin = SEEK_CUR;
- break;
- case ZLIB_FILEFUNC_SEEK_END :
- fseek_origin = SEEK_END;
- break;
- case ZLIB_FILEFUNC_SEEK_SET :
- fseek_origin = SEEK_SET;
- break;
- default: return -1;
- }
- ret = 0;
- fseek((FILE *)stream, offset, fseek_origin);
- return ret;
-}
-
-int ZCALLBACK fclose_file_func (opaque, stream)
- voidpf opaque;
- voidpf stream;
-{
- int ret;
- ret = fclose((FILE *)stream);
- return ret;
-}
-
-int ZCALLBACK ferror_file_func (opaque, stream)
- voidpf opaque;
- voidpf stream;
-{
- int ret;
- ret = ferror((FILE *)stream);
- return ret;
-}
-
-void fill_fopen_filefunc (pzlib_filefunc_def)
- zlib_filefunc_def* pzlib_filefunc_def;
-{
- pzlib_filefunc_def->zopen_file = fopen_file_func;
- pzlib_filefunc_def->zread_file = fread_file_func;
- pzlib_filefunc_def->zwrite_file = fwrite_file_func;
- pzlib_filefunc_def->ztell_file = ftell_file_func;
- pzlib_filefunc_def->zseek_file = fseek_file_func;
- pzlib_filefunc_def->zclose_file = fclose_file_func;
- pzlib_filefunc_def->zerror_file = ferror_file_func;
- pzlib_filefunc_def->opaque = NULL;
-}
diff --git a/source4/lib/zlib/contrib/minizip/ioapi.h b/source4/lib/zlib/contrib/minizip/ioapi.h
deleted file mode 100644
index 7d457baab3..0000000000
--- a/source4/lib/zlib/contrib/minizip/ioapi.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* ioapi.h -- IO base function header for compress/uncompress .zip
- files using zlib + zip or unzip API
-
- Version 1.01e, February 12th, 2005
-
- Copyright (C) 1998-2005 Gilles Vollant
-*/
-
-#ifndef _ZLIBIOAPI_H
-#define _ZLIBIOAPI_H
-
-
-#define ZLIB_FILEFUNC_SEEK_CUR (1)
-#define ZLIB_FILEFUNC_SEEK_END (2)
-#define ZLIB_FILEFUNC_SEEK_SET (0)
-
-#define ZLIB_FILEFUNC_MODE_READ (1)
-#define ZLIB_FILEFUNC_MODE_WRITE (2)
-#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
-
-#define ZLIB_FILEFUNC_MODE_EXISTING (4)
-#define ZLIB_FILEFUNC_MODE_CREATE (8)
-
-
-#ifndef ZCALLBACK
-
-#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
-#define ZCALLBACK CALLBACK
-#else
-#define ZCALLBACK
-#endif
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
-typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
-typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
-typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
-typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
-typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
-typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
-
-typedef struct zlib_filefunc_def_s
-{
- open_file_func zopen_file;
- read_file_func zread_file;
- write_file_func zwrite_file;
- tell_file_func ztell_file;
- seek_file_func zseek_file;
- close_file_func zclose_file;
- testerror_file_func zerror_file;
- voidpf opaque;
-} zlib_filefunc_def;
-
-
-
-void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
-
-#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
-#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
-#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
-#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
-#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
-#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/source4/lib/zlib/contrib/minizip/iowin32.c b/source4/lib/zlib/contrib/minizip/iowin32.c
deleted file mode 100644
index a9b5f78399..0000000000
--- a/source4/lib/zlib/contrib/minizip/iowin32.c
+++ /dev/null
@@ -1,270 +0,0 @@
-/* iowin32.c -- IO base function header for compress/uncompress .zip
- files using zlib + zip or unzip API
- This IO API version uses the Win32 API (for Microsoft Windows)
-
- Version 1.01e, February 12th, 2005
-
- Copyright (C) 1998-2005 Gilles Vollant
-*/
-
-#include <stdlib.h>
-
-#include "zlib.h"
-#include "ioapi.h"
-#include "iowin32.h"
-
-#ifndef INVALID_HANDLE_VALUE
-#define INVALID_HANDLE_VALUE (0xFFFFFFFF)
-#endif
-
-#ifndef INVALID_SET_FILE_POINTER
-#define INVALID_SET_FILE_POINTER ((DWORD)-1)
-#endif
-
-voidpf ZCALLBACK win32_open_file_func OF((
- voidpf opaque,
- const char* filename,
- int mode));
-
-uLong ZCALLBACK win32_read_file_func OF((
- voidpf opaque,
- voidpf stream,
- void* buf,
- uLong size));
-
-uLong ZCALLBACK win32_write_file_func OF((
- voidpf opaque,
- voidpf stream,
- const void* buf,
- uLong size));
-
-long ZCALLBACK win32_tell_file_func OF((
- voidpf opaque,
- voidpf stream));
-
-long ZCALLBACK win32_seek_file_func OF((
- voidpf opaque,
- voidpf stream,
- uLong offset,
- int origin));
-
-int ZCALLBACK win32_close_file_func OF((
- voidpf opaque,
- voidpf stream));
-
-int ZCALLBACK win32_error_file_func OF((
- voidpf opaque,
- voidpf stream));
-
-typedef struct
-{
- HANDLE hf;
- int error;
-} WIN32FILE_IOWIN;
-
-voidpf ZCALLBACK win32_open_file_func (opaque, filename, mode)
- voidpf opaque;
- const char* filename;
- int mode;
-{
- const char* mode_fopen = NULL;
- DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
- HANDLE hFile = 0;
- voidpf ret=NULL;
-
- dwDesiredAccess = dwShareMode = dwFlagsAndAttributes = 0;
-
- if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
- {
- dwDesiredAccess = GENERIC_READ;
- dwCreationDisposition = OPEN_EXISTING;
- dwShareMode = FILE_SHARE_READ;
- }
- else
- if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
- {
- dwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
- dwCreationDisposition = OPEN_EXISTING;
- }
- else
- if (mode & ZLIB_FILEFUNC_MODE_CREATE)
- {
- dwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
- dwCreationDisposition = CREATE_ALWAYS;
- }
-
- if ((filename!=NULL) && (dwDesiredAccess != 0))
- hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL,
- dwCreationDisposition, dwFlagsAndAttributes, NULL);
-
- if (hFile == INVALID_HANDLE_VALUE)
- hFile = NULL;
-
- if (hFile != NULL)
- {
- WIN32FILE_IOWIN w32fiow;
- w32fiow.hf = hFile;
- w32fiow.error = 0;
- ret = malloc(sizeof(WIN32FILE_IOWIN));
- if (ret==NULL)
- CloseHandle(hFile);
- else *((WIN32FILE_IOWIN*)ret) = w32fiow;
- }
- return ret;
-}
-
-
-uLong ZCALLBACK win32_read_file_func (opaque, stream, buf, size)
- voidpf opaque;
- voidpf stream;
- void* buf;
- uLong size;
-{
- uLong ret=0;
- HANDLE hFile = NULL;
- if (stream!=NULL)
- hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
- if (hFile != NULL)
- if (!ReadFile(hFile, buf, size, &ret, NULL))
- {
- DWORD dwErr = GetLastError();
- if (dwErr == ERROR_HANDLE_EOF)
- dwErr = 0;
- ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
- }
-
- return ret;
-}
-
-
-uLong ZCALLBACK win32_write_file_func (opaque, stream, buf, size)
- voidpf opaque;
- voidpf stream;
- const void* buf;
- uLong size;
-{
- uLong ret=0;
- HANDLE hFile = NULL;
- if (stream!=NULL)
- hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
-
- if (hFile !=NULL)
- if (!WriteFile(hFile, buf, size, &ret, NULL))
- {
- DWORD dwErr = GetLastError();
- if (dwErr == ERROR_HANDLE_EOF)
- dwErr = 0;
- ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
- }
-
- return ret;
-}
-
-long ZCALLBACK win32_tell_file_func (opaque, stream)
- voidpf opaque;
- voidpf stream;
-{
- long ret=-1;
- HANDLE hFile = NULL;
- if (stream!=NULL)
- hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
- if (hFile != NULL)
- {
- DWORD dwSet = SetFilePointer(hFile, 0, NULL, FILE_CURRENT);
- if (dwSet == INVALID_SET_FILE_POINTER)
- {
- DWORD dwErr = GetLastError();
- ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
- ret = -1;
- }
- else
- ret=(long)dwSet;
- }
- return ret;
-}
-
-long ZCALLBACK win32_seek_file_func (opaque, stream, offset, origin)
- voidpf opaque;
- voidpf stream;
- uLong offset;
- int origin;
-{
- DWORD dwMoveMethod=0xFFFFFFFF;
- HANDLE hFile = NULL;
-
- long ret=-1;
- if (stream!=NULL)
- hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
- switch (origin)
- {
- case ZLIB_FILEFUNC_SEEK_CUR :
- dwMoveMethod = FILE_CURRENT;
- break;
- case ZLIB_FILEFUNC_SEEK_END :
- dwMoveMethod = FILE_END;
- break;
- case ZLIB_FILEFUNC_SEEK_SET :
- dwMoveMethod = FILE_BEGIN;
- break;
- default: return -1;
- }
-
- if (hFile != NULL)
- {
- DWORD dwSet = SetFilePointer(hFile, offset, NULL, dwMoveMethod);
- if (dwSet == INVALID_SET_FILE_POINTER)
- {
- DWORD dwErr = GetLastError();
- ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
- ret = -1;
- }
- else
- ret=0;
- }
- return ret;
-}
-
-int ZCALLBACK win32_close_file_func (opaque, stream)
- voidpf opaque;
- voidpf stream;
-{
- int ret=-1;
-
- if (stream!=NULL)
- {
- HANDLE hFile;
- hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
- if (hFile != NULL)
- {
- CloseHandle(hFile);
- ret=0;
- }
- free(stream);
- }
- return ret;
-}
-
-int ZCALLBACK win32_error_file_func (opaque, stream)
- voidpf opaque;
- voidpf stream;
-{
- int ret=-1;
- if (stream!=NULL)
- {
- ret = ((WIN32FILE_IOWIN*)stream) -> error;
- }
- return ret;
-}
-
-void fill_win32_filefunc (pzlib_filefunc_def)
- zlib_filefunc_def* pzlib_filefunc_def;
-{
- pzlib_filefunc_def->zopen_file = win32_open_file_func;
- pzlib_filefunc_def->zread_file = win32_read_file_func;
- pzlib_filefunc_def->zwrite_file = win32_write_file_func;
- pzlib_filefunc_def->ztell_file = win32_tell_file_func;
- pzlib_filefunc_def->zseek_file = win32_seek_file_func;
- pzlib_filefunc_def->zclose_file = win32_close_file_func;
- pzlib_filefunc_def->zerror_file = win32_error_file_func;
- pzlib_filefunc_def->opaque=NULL;
-}
diff --git a/source4/lib/zlib/contrib/minizip/iowin32.h b/source4/lib/zlib/contrib/minizip/iowin32.h
deleted file mode 100644
index a3a437adf8..0000000000
--- a/source4/lib/zlib/contrib/minizip/iowin32.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* iowin32.h -- IO base function header for compress/uncompress .zip
- files using zlib + zip or unzip API
- This IO API version uses the Win32 API (for Microsoft Windows)
-
- Version 1.01e, February 12th, 2005
-
- Copyright (C) 1998-2005 Gilles Vollant
-*/
-
-#include <windows.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/source4/lib/zlib/contrib/minizip/miniunz.c b/source4/lib/zlib/contrib/minizip/miniunz.c
deleted file mode 100644
index f599938884..0000000000
--- a/source4/lib/zlib/contrib/minizip/miniunz.c
+++ /dev/null
@@ -1,585 +0,0 @@
-/*
- miniunz.c
- Version 1.01e, February 12th, 2005
-
- Copyright (C) 1998-2005 Gilles Vollant
-*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-#include <fcntl.h>
-
-#ifdef unix
-# include <unistd.h>
-# include <utime.h>
-#else
-# include <direct.h>
-# include <io.h>
-#endif
-
-#include "unzip.h"
-
-#define CASESENSITIVITY (0)
-#define WRITEBUFFERSIZE (8192)
-#define MAXFILENAME (256)
-
-#ifdef WIN32
-#define USEWIN32IOAPI
-#include "iowin32.h"
-#endif
-/*
- mini unzip, demo of unzip package
-
- usage :
- Usage : miniunz [-exvlo] file.zip [file_to_extract] [-d extractdir]
-
- list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT
- if it exists
-*/
-
-
-/* change_file_date : change the date/time of a file
- filename : the filename of the file where date/time must be modified
- dosdate : the new date at the MSDos format (4 bytes)
- tmu_date : the SAME new date at the tm_unz format */
-void change_file_date(filename,dosdate,tmu_date)
- const char *filename;
- uLong dosdate;
- tm_unz tmu_date;
-{
-#ifdef WIN32
- HANDLE hFile;
- FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
-
- hFile = CreateFile(filename,GENERIC_READ | GENERIC_WRITE,
- 0,NULL,OPEN_EXISTING,0,NULL);
- GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite);
- DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
- LocalFileTimeToFileTime(&ftLocal,&ftm);
- SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
- CloseHandle(hFile);
-#else
-#ifdef unix
- struct utimbuf ut;
- struct tm newdate;
- newdate.tm_sec = tmu_date.tm_sec;
- newdate.tm_min=tmu_date.tm_min;
- newdate.tm_hour=tmu_date.tm_hour;
- newdate.tm_mday=tmu_date.tm_mday;
- newdate.tm_mon=tmu_date.tm_mon;
- if (tmu_date.tm_year > 1900)
- newdate.tm_year=tmu_date.tm_year - 1900;
- else
- newdate.tm_year=tmu_date.tm_year ;
- newdate.tm_isdst=-1;
-
- ut.actime=ut.modtime=mktime(&newdate);
- utime(filename,&ut);
-#endif
-#endif
-}
-
-
-/* mymkdir and change_file_date are not 100 % portable
- As I don't know well Unix, I wait feedback for the unix portion */
-
-int mymkdir(dirname)
- const char* dirname;
-{
- int ret=0;
-#ifdef WIN32
- ret = mkdir(dirname);
-#else
-#ifdef unix
- ret = mkdir (dirname,0775);
-#endif
-#endif
- return ret;
-}
-
-int makedir (newdir)
- char *newdir;
-{
- char *buffer ;
- char *p;
- int len = (int)strlen(newdir);
-
- if (len <= 0)
- return 0;
-
- buffer = (char*)malloc(len+1);
- strcpy(buffer,newdir);
-
- if (buffer[len-1] == '/') {
- buffer[len-1] = '\0';
- }
- if (mymkdir(buffer) == 0)
- {
- free(buffer);
- return 1;
- }
-
- p = buffer+1;
- while (1)
- {
- char hold;
-
- while(*p && *p != '\\' && *p != '/')
- p++;
- hold = *p;
- *p = 0;
- if ((mymkdir(buffer) == -1) && (errno == ENOENT))
- {
- printf("couldn't create directory %s\n",buffer);
- free(buffer);
- return 0;
- }
- if (hold == 0)
- break;
- *p++ = hold;
- }
- free(buffer);
- return 1;
-}
-
-void do_banner()
-{
- printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n");
- printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
-}
-
-void do_help()
-{
- printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \
- " -e Extract without pathname (junk paths)\n" \
- " -x Extract with pathname\n" \
- " -v list files\n" \
- " -l list files\n" \
- " -d directory to extract into\n" \
- " -o overwrite files without prompting\n" \
- " -p extract crypted file using password\n\n");
-}
-
-
-int do_list(uf)
- unzFile uf;
-{
- uLong i;
- unz_global_info gi;
- int err;
-
- err = unzGetGlobalInfo (uf,&gi);
- if (err!=UNZ_OK)
- printf("error %d with zipfile in unzGetGlobalInfo \n",err);
- printf(" Length Method Size Ratio Date Time CRC-32 Name\n");
- printf(" ------ ------ ---- ----- ---- ---- ------ ----\n");
- for (i=0;i<gi.number_entry;i++)
- {
- char filename_inzip[256];
- unz_file_info file_info;
- uLong ratio=0;
- const char *string_method;
- char charCrypt=' ';
- err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
- if (err!=UNZ_OK)
- {
- printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
- break;
- }
- if (file_info.uncompressed_size>0)
- ratio = (file_info.compressed_size*100)/file_info.uncompressed_size;
-
- /* display a '*' if the file is crypted */
- if ((file_info.flag & 1) != 0)
- charCrypt='*';
-
- if (file_info.compression_method==0)
- string_method="Stored";
- else
- if (file_info.compression_method==Z_DEFLATED)
- {
- uInt iLevel=(uInt)((file_info.flag & 0x6)/2);
- if (iLevel==0)
- string_method="Defl:N";
- else if (iLevel==1)
- string_method="Defl:X";
- else if ((iLevel==2) || (iLevel==3))
- string_method="Defl:F"; /* 2:fast , 3 : extra fast*/
- }
- else
- string_method="Unkn. ";
-
- printf("%7lu %6s%c%7lu %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n",
- file_info.uncompressed_size,string_method,
- charCrypt,
- file_info.compressed_size,
- ratio,
- (uLong)file_info.tmu_date.tm_mon + 1,
- (uLong)file_info.tmu_date.tm_mday,
- (uLong)file_info.tmu_date.tm_year % 100,
- (uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min,
- (uLong)file_info.crc,filename_inzip);
- if ((i+1)<gi.number_entry)
- {
- err = unzGoToNextFile(uf);
- if (err!=UNZ_OK)
- {
- printf("error %d with zipfile in unzGoToNextFile\n",err);
- break;
- }
- }
- }
-
- return 0;
-}
-
-
-int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
- unzFile uf;
- const int* popt_extract_without_path;
- int* popt_overwrite;
- const char* password;
-{
- char filename_inzip[256];
- char* filename_withoutpath;
- char* p;
- int err=UNZ_OK;
- FILE *fout=NULL;
- void* buf;
- uInt size_buf;
-
- unz_file_info file_info;
- uLong ratio=0;
- err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
-
- if (err!=UNZ_OK)
- {
- printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
- return err;
- }
-
- size_buf = WRITEBUFFERSIZE;
- buf = (void*)malloc(size_buf);
- if (buf==NULL)
- {
- printf("Error allocating memory\n");
- return UNZ_INTERNALERROR;
- }
-
- p = filename_withoutpath = filename_inzip;
- while ((*p) != '\0')
- {
- if (((*p)=='/') || ((*p)=='\\'))
- filename_withoutpath = p+1;
- p++;
- }
-
- if ((*filename_withoutpath)=='\0')
- {
- if ((*popt_extract_without_path)==0)
- {
- printf("creating directory: %s\n",filename_inzip);
- mymkdir(filename_inzip);
- }
- }
- else
- {
- const char* write_filename;
- int skip=0;
-
- if ((*popt_extract_without_path)==0)
- write_filename = filename_inzip;
- else
- write_filename = filename_withoutpath;
-
- err = unzOpenCurrentFilePassword(uf,password);
- if (err!=UNZ_OK)
- {
- printf("error %d with zipfile in unzOpenCurrentFilePassword\n",err);
- }
-
- if (((*popt_overwrite)==0) && (err==UNZ_OK))
- {
- char rep=0;
- FILE* ftestexist;
- ftestexist = fopen(write_filename,"rb");
- if (ftestexist!=NULL)
- {
- fclose(ftestexist);
- do
- {
- char answer[128];
- int ret;
-
- printf("The file %s exists. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename);
- ret = scanf("%1s",answer);
- if (ret != 1)
- {
- exit(EXIT_FAILURE);
- }
- rep = answer[0] ;
- if ((rep>='a') && (rep<='z'))
- rep -= 0x20;
- }
- while ((rep!='Y') && (rep!='N') && (rep!='A'));
- }
-
- if (rep == 'N')
- skip = 1;
-
- if (rep == 'A')
- *popt_overwrite=1;
- }
-
- if ((skip==0) && (err==UNZ_OK))
- {
- fout=fopen(write_filename,"wb");
-
- /* some zipfile don't contain directory alone before file */
- if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
- (filename_withoutpath!=(char*)filename_inzip))
- {
- char c=*(filename_withoutpath-1);
- *(filename_withoutpath-1)='\0';
- makedir(write_filename);
- *(filename_withoutpath-1)=c;
- fout=fopen(write_filename,"wb");
- }
-
- if (fout==NULL)
- {
- printf("error opening %s\n",write_filename);
- }
- }
-
- if (fout!=NULL)
- {
- printf(" extracting: %s\n",write_filename);
-
- do
- {
- err = unzReadCurrentFile(uf,buf,size_buf);
- if (err<0)
- {
- printf("error %d with zipfile in unzReadCurrentFile\n",err);
- break;
- }
- if (err>0)
- if (fwrite(buf,err,1,fout)!=1)
- {
- printf("error in writing extracted file\n");
- err=UNZ_ERRNO;
- break;
- }
- }
- while (err>0);
- if (fout)
- fclose(fout);
-
- if (err==0)
- change_file_date(write_filename,file_info.dosDate,
- file_info.tmu_date);
- }
-
- if (err==UNZ_OK)
- {
- err = unzCloseCurrentFile (uf);
- if (err!=UNZ_OK)
- {
- printf("error %d with zipfile in unzCloseCurrentFile\n",err);
- }
- }
- else
- unzCloseCurrentFile(uf); /* don't lose the error */
- }
-
- free(buf);
- return err;
-}
-
-
-int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
- unzFile uf;
- int opt_extract_without_path;
- int opt_overwrite;
- const char* password;
-{
- uLong i;
- unz_global_info gi;
- int err;
- FILE* fout=NULL;
-
- err = unzGetGlobalInfo (uf,&gi);
- if (err!=UNZ_OK)
- printf("error %d with zipfile in unzGetGlobalInfo \n",err);
-
- for (i=0;i<gi.number_entry;i++)
- {
- if (do_extract_currentfile(uf,&opt_extract_without_path,
- &opt_overwrite,
- password) != UNZ_OK)
- break;
-
- if ((i+1)<gi.number_entry)
- {
- err = unzGoToNextFile(uf);
- if (err!=UNZ_OK)
- {
- printf("error %d with zipfile in unzGoToNextFile\n",err);
- break;
- }
- }
- }
-
- return 0;
-}
-
-int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password)
- unzFile uf;
- const char* filename;
- int opt_extract_without_path;
- int opt_overwrite;
- const char* password;
-{
- int err = UNZ_OK;
- if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
- {
- printf("file %s not found in the zipfile\n",filename);
- return 2;
- }
-
- if (do_extract_currentfile(uf,&opt_extract_without_path,
- &opt_overwrite,
- password) == UNZ_OK)
- return 0;
- else
- return 1;
-}
-
-
-int main(argc,argv)
- int argc;
- char *argv[];
-{
- const char *zipfilename=NULL;
- const char *filename_to_extract=NULL;
- const char *password=NULL;
- char filename_try[MAXFILENAME+16] = "";
- int i;
- int opt_do_list=0;
- int opt_do_extract=1;
- int opt_do_extract_withoutpath=0;
- int opt_overwrite=0;
- int opt_extractdir=0;
- const char *dirname=NULL;
- unzFile uf=NULL;
-
- do_banner();
- if (argc==1)
- {
- do_help();
- return 0;
- }
- else
- {
- for (i=1;i<argc;i++)
- {
- if ((*argv[i])=='-')
- {
- const char *p=argv[i]+1;
-
- while ((*p)!='\0')
- {
- char c=*(p++);;
- if ((c=='l') || (c=='L'))
- opt_do_list = 1;
- if ((c=='v') || (c=='V'))
- opt_do_list = 1;
- if ((c=='x') || (c=='X'))
- opt_do_extract = 1;
- if ((c=='e') || (c=='E'))
- opt_do_extract = opt_do_extract_withoutpath = 1;
- if ((c=='o') || (c=='O'))
- opt_overwrite=1;
- if ((c=='d') || (c=='D'))
- {
- opt_extractdir=1;
- dirname=argv[i+1];
- }
-
- if (((c=='p') || (c=='P')) && (i+1<argc))
- {
- password=argv[i+1];
- i++;
- }
- }
- }
- else
- {
- if (zipfilename == NULL)
- zipfilename = argv[i];
- else if ((filename_to_extract==NULL) && (!opt_extractdir))
- filename_to_extract = argv[i] ;
- }
- }
- }
-
- if (zipfilename!=NULL)
- {
-
-# ifdef USEWIN32IOAPI
- zlib_filefunc_def ffunc;
-# endif
-
- strncpy(filename_try, zipfilename,MAXFILENAME-1);
- /* strncpy doesnt append the trailing NULL, of the string is too long. */
- filename_try[ MAXFILENAME ] = '\0';
-
-# ifdef USEWIN32IOAPI
- fill_win32_filefunc(&ffunc);
- uf = unzOpen2(zipfilename,&ffunc);
-# else
- uf = unzOpen(zipfilename);
-# endif
- if (uf==NULL)
- {
- strcat(filename_try,".zip");
-# ifdef USEWIN32IOAPI
- uf = unzOpen2(filename_try,&ffunc);
-# else
- uf = unzOpen(filename_try);
-# endif
- }
- }
-
- if (uf==NULL)
- {
- printf("Cannot open %s or %s.zip\n",zipfilename,zipfilename);
- return 1;
- }
- printf("%s opened\n",filename_try);
-
- if (opt_do_list==1)
- return do_list(uf);
- else if (opt_do_extract==1)
- {
- if (opt_extractdir && chdir(dirname))
- {
- printf("Error changing into %s, aborting\n", dirname);
- exit(-1);
- }
-
- if (filename_to_extract == NULL)
- return do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,password);
- else
- return do_extract_onefile(uf,filename_to_extract,
- opt_do_extract_withoutpath,opt_overwrite,password);
- }
- unzCloseCurrentFile(uf);
-
- return 0;
-}
diff --git a/source4/lib/zlib/contrib/minizip/minizip.c b/source4/lib/zlib/contrib/minizip/minizip.c
deleted file mode 100644
index f2dfecd8b1..0000000000
--- a/source4/lib/zlib/contrib/minizip/minizip.c
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- minizip.c
- Version 1.01e, February 12th, 2005
-
- Copyright (C) 1998-2005 Gilles Vollant
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-#include <fcntl.h>
-
-#ifdef unix
-# include <unistd.h>
-# include <utime.h>
-# include <sys/types.h>
-# include <sys/stat.h>
-#else
-# include <direct.h>
-# include <io.h>
-#endif
-
-#include "zip.h"
-
-#ifdef WIN32
-#define USEWIN32IOAPI
-#include "iowin32.h"
-#endif
-
-
-
-#define WRITEBUFFERSIZE (16384)
-#define MAXFILENAME (256)
-
-#ifdef WIN32
-uLong filetime(f, tmzip, dt)
- char *f; /* name of file to get info on */
- tm_zip *tmzip; /* return value: access, modific. and creation times */
- uLong *dt; /* dostime */
-{
- int ret = 0;
- {
- FILETIME ftLocal;
- HANDLE hFind;
- WIN32_FIND_DATA ff32;
-
- hFind = FindFirstFile(f,&ff32);
- if (hFind != INVALID_HANDLE_VALUE)
- {
- FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal);
- FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0);
- FindClose(hFind);
- ret = 1;
- }
- }
- return ret;
-}
-#else
-#ifdef unix
-uLong filetime(f, tmzip, dt)
- char *f; /* name of file to get info on */
- tm_zip *tmzip; /* return value: access, modific. and creation times */
- uLong *dt; /* dostime */
-{
- int ret=0;
- struct stat s; /* results of stat() */
- struct tm* filedate;
- time_t tm_t=0;
-
- if (strcmp(f,"-")!=0)
- {
- char name[MAXFILENAME+1];
- int len = strlen(f);
- if (len > MAXFILENAME)
- len = MAXFILENAME;
-
- strncpy(name, f,MAXFILENAME-1);
- /* strncpy doesnt append the trailing NULL, of the string is too long. */
- name[ MAXFILENAME ] = '\0';
-
- if (name[len - 1] == '/')
- name[len - 1] = '\0';
- /* not all systems allow stat'ing a file with / appended */
- if (stat(name,&s)==0)
- {
- tm_t = s.st_mtime;
- ret = 1;
- }
- }
- filedate = localtime(&tm_t);
-
- tmzip->tm_sec = filedate->tm_sec;
- tmzip->tm_min = filedate->tm_min;
- tmzip->tm_hour = filedate->tm_hour;
- tmzip->tm_mday = filedate->tm_mday;
- tmzip->tm_mon = filedate->tm_mon ;
- tmzip->tm_year = filedate->tm_year;
-
- return ret;
-}
-#else
-uLong filetime(f, tmzip, dt)
- char *f; /* name of file to get info on */
- tm_zip *tmzip; /* return value: access, modific. and creation times */
- uLong *dt; /* dostime */
-{
- return 0;
-}
-#endif
-#endif
-
-
-
-
-int check_exist_file(filename)
- const char* filename;
-{
- FILE* ftestexist;
- int ret = 1;
- ftestexist = fopen(filename,"rb");
- if (ftestexist==NULL)
- ret = 0;
- else
- fclose(ftestexist);
- return ret;
-}
-
-void do_banner()
-{
- printf("MiniZip 1.01b, demo of zLib + Zip package written by Gilles Vollant\n");
- printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
-}
-
-void do_help()
-{
- printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] file.zip [files_to_add]\n\n" \
- " -o Overwrite existing file.zip\n" \
- " -a Append to existing file.zip\n" \
- " -0 Store only\n" \
- " -1 Compress faster\n" \
- " -9 Compress better\n\n");
-}
-
-/* calculate the CRC32 of a file,
- because to encrypt a file, we need known the CRC32 of the file before */
-int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc)
-{
- unsigned long calculate_crc=0;
- int err=ZIP_OK;
- FILE * fin = fopen(filenameinzip,"rb");
- unsigned long size_read = 0;
- unsigned long total_read = 0;
- if (fin==NULL)
- {
- err = ZIP_ERRNO;
- }
-
- if (err == ZIP_OK)
- do
- {
- err = ZIP_OK;
- size_read = (int)fread(buf,1,size_buf,fin);
- if (size_read < size_buf)
- if (feof(fin)==0)
- {
- printf("error in reading %s\n",filenameinzip);
- err = ZIP_ERRNO;
- }
-
- if (size_read>0)
- calculate_crc = crc32(calculate_crc,buf,size_read);
- total_read += size_read;
-
- } while ((err == ZIP_OK) && (size_read>0));
-
- if (fin)
- fclose(fin);
-
- *result_crc=calculate_crc;
- printf("file %s crc %x\n",filenameinzip,calculate_crc);
- return err;
-}
-
-int main(argc,argv)
- int argc;
- char *argv[];
-{
- int i;
- int opt_overwrite=0;
- int opt_compress_level=Z_DEFAULT_COMPRESSION;
- int zipfilenamearg = 0;
- char filename_try[MAXFILENAME+16];
- int zipok;
- int err=0;
- int size_buf=0;
- void* buf=NULL;
- const char* password=NULL;
-
-
- do_banner();
- if (argc==1)
- {
- do_help();
- return 0;
- }
- else
- {
- for (i=1;i<argc;i++)
- {
- if ((*argv[i])=='-')
- {
- const char *p=argv[i]+1;
-
- while ((*p)!='\0')
- {
- char c=*(p++);;
- if ((c=='o') || (c=='O'))
- opt_overwrite = 1;
- if ((c=='a') || (c=='A'))
- opt_overwrite = 2;
- if ((c>='0') && (c<='9'))
- opt_compress_level = c-'0';
-
- if (((c=='p') || (c=='P')) && (i+1<argc))
- {
- password=argv[i+1];
- i++;
- }
- }
- }
- else
- if (zipfilenamearg == 0)
- zipfilenamearg = i ;
- }
- }
-
- size_buf = WRITEBUFFERSIZE;
- buf = (void*)malloc(size_buf);
- if (buf==NULL)
- {
- printf("Error allocating memory\n");
- return ZIP_INTERNALERROR;
- }
-
- if (zipfilenamearg==0)
- zipok=0;
- else
- {
- int i,len;
- int dot_found=0;
-
- zipok = 1 ;
- strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1);
- /* strncpy doesnt append the trailing NULL, of the string is too long. */
- filename_try[ MAXFILENAME ] = '\0';
-
- len=(int)strlen(filename_try);
- for (i=0;i<len;i++)
- if (filename_try[i]=='.')
- dot_found=1;
-
- if (dot_found==0)
- strcat(filename_try,".zip");
-
- if (opt_overwrite==2)
- {
- /* if the file don't exist, we not append file */
- if (check_exist_file(filename_try)==0)
- opt_overwrite=1;
- }
- else
- if (opt_overwrite==0)
- if (check_exist_file(filename_try)!=0)
- {
- char rep=0;
- do
- {
- char answer[128];
- int ret;
- printf("The file %s exists. Overwrite ? [y]es, [n]o, [a]ppend : ",filename_try);
- ret = scanf("%1s",answer);
- if (ret != 1)
- {
- exit(EXIT_FAILURE);
- }
- rep = answer[0] ;
- if ((rep>='a') && (rep<='z'))
- rep -= 0x20;
- }
- while ((rep!='Y') && (rep!='N') && (rep!='A'));
- if (rep=='N')
- zipok = 0;
- if (rep=='A')
- opt_overwrite = 2;
- }
- }
-
- if (zipok==1)
- {
- zipFile zf;
- int errclose;
-# ifdef USEWIN32IOAPI
- zlib_filefunc_def ffunc;
- fill_win32_filefunc(&ffunc);
- zf = zipOpen2(filename_try,(opt_overwrite==2) ? 2 : 0,NULL,&ffunc);
-# else
- zf = zipOpen(filename_try,(opt_overwrite==2) ? 2 : 0);
-# endif
-
- if (zf == NULL)
- {
- printf("error opening %s\n",filename_try);
- err= ZIP_ERRNO;
- }
- else
- printf("creating %s\n",filename_try);
-
- for (i=zipfilenamearg+1;(i<argc) && (err==ZIP_OK);i++)
- {
- if (!((((*(argv[i]))=='-') || ((*(argv[i]))=='/')) &&
- ((argv[i][1]=='o') || (argv[i][1]=='O') ||
- (argv[i][1]=='a') || (argv[i][1]=='A') ||
- (argv[i][1]=='p') || (argv[i][1]=='P') ||
- ((argv[i][1]>='0') || (argv[i][1]<='9'))) &&
- (strlen(argv[i]) == 2)))
- {
- FILE * fin;
- int size_read;
- const char* filenameinzip = argv[i];
- zip_fileinfo zi;
- unsigned long crcFile=0;
-
- zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour =
- zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0;
- zi.dosDate = 0;
- zi.internal_fa = 0;
- zi.external_fa = 0;
- filetime(filenameinzip,&zi.tmz_date,&zi.dosDate);
-
-/*
- err = zipOpenNewFileInZip(zf,filenameinzip,&zi,
- NULL,0,NULL,0,NULL / * comment * /,
- (opt_compress_level != 0) ? Z_DEFLATED : 0,
- opt_compress_level);
-*/
- if ((password != NULL) && (err==ZIP_OK))
- err = getFileCrc(filenameinzip,buf,size_buf,&crcFile);
-
- err = zipOpenNewFileInZip3(zf,filenameinzip,&zi,
- NULL,0,NULL,0,NULL /* comment*/,
- (opt_compress_level != 0) ? Z_DEFLATED : 0,
- opt_compress_level,0,
- /* -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, */
- -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
- password,crcFile);
-
- if (err != ZIP_OK)
- printf("error in opening %s in zipfile\n",filenameinzip);
- else
- {
- fin = fopen(filenameinzip,"rb");
- if (fin==NULL)
- {
- err=ZIP_ERRNO;
- printf("error in opening %s for reading\n",filenameinzip);
- }
- }
-
- if (err == ZIP_OK)
- do
- {
- err = ZIP_OK;
- size_read = (int)fread(buf,1,size_buf,fin);
- if (size_read < size_buf)
- if (feof(fin)==0)
- {
- printf("error in reading %s\n",filenameinzip);
- err = ZIP_ERRNO;
- }
-
- if (size_read>0)
- {
- err = zipWriteInFileInZip (zf,buf,size_read);
- if (err<0)
- {
- printf("error in writing %s in the zipfile\n",
- filenameinzip);
- }
-
- }
- } while ((err == ZIP_OK) && (size_read>0));
-
- if (fin)
- fclose(fin);
-
- if (err<0)
- err=ZIP_ERRNO;
- else
- {
- err = zipCloseFileInZip(zf);
- if (err!=ZIP_OK)
- printf("error in closing %s in the zipfile\n",
- filenameinzip);
- }
- }
- }
- errclose = zipClose(zf,NULL);
- if (errclose != ZIP_OK)
- printf("error in closing %s\n",filename_try);
- }
- else
- {
- do_help();
- }
-
- free(buf);
- return 0;
-}
diff --git a/source4/lib/zlib/contrib/minizip/mztools.c b/source4/lib/zlib/contrib/minizip/mztools.c
deleted file mode 100644
index 8a50ee4392..0000000000
--- a/source4/lib/zlib/contrib/minizip/mztools.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- Additional tools for Minizip
- Code: Xavier Roche '2004
- License: Same as ZLIB (www.gzip.org)
-*/
-
-/* Code */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "zlib.h"
-#include "unzip.h"
-
-#define READ_8(adr) ((unsigned char)*(adr))
-#define READ_16(adr) ( READ_8(adr) | (READ_8(adr+1) << 8) )
-#define READ_32(adr) ( READ_16(adr) | (READ_16((adr)+2) << 16) )
-
-#define WRITE_8(buff, n) do { \
- *((unsigned char*)(buff)) = (unsigned char) ((n) & 0xff); \
-} while(0)
-#define WRITE_16(buff, n) do { \
- WRITE_8((unsigned char*)(buff), n); \
- WRITE_8(((unsigned char*)(buff)) + 1, (n) >> 8); \
-} while(0)
-#define WRITE_32(buff, n) do { \
- WRITE_16((unsigned char*)(buff), (n) & 0xffff); \
- WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \
-} while(0)
-
-extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered)
-const char* file;
-const char* fileOut;
-const char* fileOutTmp;
-uLong* nRecovered;
-uLong* bytesRecovered;
-{
- int err = Z_OK;
- FILE* fpZip = fopen(file, "rb");
- FILE* fpOut = fopen(fileOut, "wb");
- FILE* fpOutCD = fopen(fileOutTmp, "wb");
- if (fpZip != NULL && fpOut != NULL) {
- int entries = 0;
- uLong totalBytes = 0;
- char header[30];
- char filename[256];
- char extra[1024];
- int offset = 0;
- int offsetCD = 0;
- while ( fread(header, 1, 30, fpZip) == 30 ) {
- int currentOffset = offset;
-
- /* File entry */
- if (READ_32(header) == 0x04034b50) {
- unsigned int version = READ_16(header + 4);
- unsigned int gpflag = READ_16(header + 6);
- unsigned int method = READ_16(header + 8);
- unsigned int filetime = READ_16(header + 10);
- unsigned int filedate = READ_16(header + 12);
- unsigned int crc = READ_32(header + 14); /* crc */
- unsigned int cpsize = READ_32(header + 18); /* compressed size */
- unsigned int uncpsize = READ_32(header + 22); /* uncompressed sz */
- unsigned int fnsize = READ_16(header + 26); /* file name length */
- unsigned int extsize = READ_16(header + 28); /* extra field length */
- filename[0] = extra[0] = '\0';
-
- /* Header */
- if (fwrite(header, 1, 30, fpOut) == 30) {
- offset += 30;
- } else {
- err = Z_ERRNO;
- break;
- }
-
- /* Filename */
- if (fnsize > 0) {
- if (fread(filename, 1, fnsize, fpZip) == fnsize) {
- if (fwrite(filename, 1, fnsize, fpOut) == fnsize) {
- offset += fnsize;
- } else {
- err = Z_ERRNO;
- break;
- }
- } else {
- err = Z_ERRNO;
- break;
- }
- } else {
- err = Z_STREAM_ERROR;
- break;
- }
-
- /* Extra field */
- if (extsize > 0) {
- if (fread(extra, 1, extsize, fpZip) == extsize) {
- if (fwrite(extra, 1, extsize, fpOut) == extsize) {
- offset += extsize;
- } else {
- err = Z_ERRNO;
- break;
- }
- } else {
- err = Z_ERRNO;
- break;
- }
- }
-
- /* Data */
- {
- int dataSize = cpsize;
- if (dataSize == 0) {
- dataSize = uncpsize;
- }
- if (dataSize > 0) {
- char* data = malloc(dataSize);
- if (data != NULL) {
- if ((int)fread(data, 1, dataSize, fpZip) == dataSize) {
- if ((int)fwrite(data, 1, dataSize, fpOut) == dataSize) {
- offset += dataSize;
- totalBytes += dataSize;
- } else {
- err = Z_ERRNO;
- }
- } else {
- err = Z_ERRNO;
- }
- free(data);
- if (err != Z_OK) {
- break;
- }
- } else {
- err = Z_MEM_ERROR;
- break;
- }
- }
- }
-
- /* Central directory entry */
- {
- char header[46];
- char* comment = "";
- int comsize = (int) strlen(comment);
- WRITE_32(header, 0x02014b50);
- WRITE_16(header + 4, version);
- WRITE_16(header + 6, version);
- WRITE_16(header + 8, gpflag);
- WRITE_16(header + 10, method);
- WRITE_16(header + 12, filetime);
- WRITE_16(header + 14, filedate);
- WRITE_32(header + 16, crc);
- WRITE_32(header + 20, cpsize);
- WRITE_32(header + 24, uncpsize);
- WRITE_16(header + 28, fnsize);
- WRITE_16(header + 30, extsize);
- WRITE_16(header + 32, comsize);
- WRITE_16(header + 34, 0); /* disk # */
- WRITE_16(header + 36, 0); /* int attrb */
- WRITE_32(header + 38, 0); /* ext attrb */
- WRITE_32(header + 42, currentOffset);
- /* Header */
- if (fwrite(header, 1, 46, fpOutCD) == 46) {
- offsetCD += 46;
-
- /* Filename */
- if (fnsize > 0) {
- if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) {
- offsetCD += fnsize;
- } else {
- err = Z_ERRNO;
- break;
- }
- } else {
- err = Z_STREAM_ERROR;
- break;
- }
-
- /* Extra field */
- if (extsize > 0) {
- if (fwrite(extra, 1, extsize, fpOutCD) == extsize) {
- offsetCD += extsize;
- } else {
- err = Z_ERRNO;
- break;
- }
- }
-
- /* Comment field */
- if (comsize > 0) {
- if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) {
- offsetCD += comsize;
- } else {
- err = Z_ERRNO;
- break;
- }
- }
-
-
- } else {
- err = Z_ERRNO;
- break;
- }
- }
-
- /* Success */
- entries++;
-
- } else {
- break;
- }
- }
-
- /* Final central directory */
- {
- int entriesZip = entries;
- char header[22];
- char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools";
- int comsize = (int) strlen(comment);
- if (entriesZip > 0xffff) {
- entriesZip = 0xffff;
- }
- WRITE_32(header, 0x06054b50);
- WRITE_16(header + 4, 0); /* disk # */
- WRITE_16(header + 6, 0); /* disk # */
- WRITE_16(header + 8, entriesZip); /* hack */
- WRITE_16(header + 10, entriesZip); /* hack */
- WRITE_32(header + 12, offsetCD); /* size of CD */
- WRITE_32(header + 16, offset); /* offset to CD */
- WRITE_16(header + 20, comsize); /* comment */
-
- /* Header */
- if (fwrite(header, 1, 22, fpOutCD) == 22) {
-
- /* Comment field */
- if (comsize > 0) {
- if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) {
- err = Z_ERRNO;
- }
- }
-
- } else {
- err = Z_ERRNO;
- }
- }
-
- /* Final merge (file + central directory) */
- fclose(fpOutCD);
- if (err == Z_OK) {
- fpOutCD = fopen(fileOutTmp, "rb");
- if (fpOutCD != NULL) {
- int nRead;
- char buffer[8192];
- while ( (nRead = (int)fread(buffer, 1, sizeof(buffer), fpOutCD)) > 0) {
- if ((int)fwrite(buffer, 1, nRead, fpOut) != nRead) {
- err = Z_ERRNO;
- break;
- }
- }
- fclose(fpOutCD);
- }
- }
-
- /* Close */
- fclose(fpZip);
- fclose(fpOut);
-
- /* Wipe temporary file */
- (void)remove(fileOutTmp);
-
- /* Number of recovered entries */
- if (err == Z_OK) {
- if (nRecovered != NULL) {
- *nRecovered = entries;
- }
- if (bytesRecovered != NULL) {
- *bytesRecovered = totalBytes;
- }
- }
- } else {
- err = Z_STREAM_ERROR;
- }
- return err;
-}
diff --git a/source4/lib/zlib/contrib/minizip/mztools.h b/source4/lib/zlib/contrib/minizip/mztools.h
deleted file mode 100644
index eee78dc56b..0000000000
--- a/source4/lib/zlib/contrib/minizip/mztools.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- Additional tools for Minizip
- Code: Xavier Roche '2004
- License: Same as ZLIB (www.gzip.org)
-*/
-
-#ifndef _zip_tools_H
-#define _zip_tools_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _ZLIB_H
-#include "zlib.h"
-#endif
-
-#include "unzip.h"
-
-/* Repair a ZIP file (missing central directory)
- file: file to recover
- fileOut: output file after recovery
- fileOutTmp: temporary file name used for recovery
-*/
-extern int ZEXPORT unzRepair(const char* file,
- const char* fileOut,
- const char* fileOutTmp,
- uLong* nRecovered,
- uLong* bytesRecovered);
-
-#endif
diff --git a/source4/lib/zlib/contrib/minizip/unzip.c b/source4/lib/zlib/contrib/minizip/unzip.c
deleted file mode 100644
index 9ad4766d8d..0000000000
--- a/source4/lib/zlib/contrib/minizip/unzip.c
+++ /dev/null
@@ -1,1598 +0,0 @@
-/* unzip.c -- IO for uncompress .zip files using zlib
- Version 1.01e, February 12th, 2005
-
- Copyright (C) 1998-2005 Gilles Vollant
-
- Read unzip.h for more info
-*/
-
-/* Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of
-compatibility with older software. The following is from the original crypt.c. Code
-woven in by Terry Thorsen 1/2003.
-*/
-/*
- Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
-
- See the accompanying file LICENSE, version 2000-Apr-09 or later
- (the contents of which are also included in zip.h) for terms of use.
- If, for some reason, all these files are missing, the Info-ZIP license
- also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
-*/
-/*
- crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h]
-
- The encryption/decryption parts of this source code (as opposed to the
- non-echoing password parts) were originally written in Europe. The
- whole source package can be freely distributed, including from the USA.
- (Prior to January 2000, re-export from the US was a violation of US law.)
- */
-
-/*
- This encryption code is a direct transcription of the algorithm from
- Roger Schlafly, described by Phil Katz in the file appnote.txt. This
- file (appnote.txt) is distributed with the PKZIP program (even in the
- version without encryption capabilities).
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "zlib.h"
-#include "unzip.h"
-
-#ifdef STDC
-# include <stddef.h>
-# include <string.h>
-# include <stdlib.h>
-#endif
-#ifdef NO_ERRNO_H
- extern int errno;
-#else
-# include <errno.h>
-#endif
-
-
-#ifndef local
-# define local static
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
-
-#ifndef CASESENSITIVITYDEFAULT_NO
-# if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
-# define CASESENSITIVITYDEFAULT_NO
-# endif
-#endif
-
-
-#ifndef UNZ_BUFSIZE
-#define UNZ_BUFSIZE (16384)
-#endif
-
-#ifndef UNZ_MAXFILENAMEINZIP
-#define UNZ_MAXFILENAMEINZIP (256)
-#endif
-
-#ifndef ALLOC
-# define ALLOC(size) (malloc(size))
-#endif
-#ifndef TRYFREE
-# define TRYFREE(p) {if (p) free(p);}
-#endif
-
-#define SIZECENTRALDIRITEM (0x2e)
-#define SIZEZIPLOCALHEADER (0x1e)
-
-
-
-
-const char unz_copyright[] =
- " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
-
-/* unz_file_info_interntal contain internal info about a file in zipfile*/
-typedef struct unz_file_info_internal_s
-{
- uLong offset_curfile;/* relative offset of local header 4 bytes */
-} unz_file_info_internal;
-
-
-/* file_in_zip_read_info_s contain internal information about a file in zipfile,
- when reading and decompress it */
-typedef struct
-{
- char *read_buffer; /* internal buffer for compressed data */
- z_stream stream; /* zLib stream structure for inflate */
-
- uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/
- uLong stream_initialised; /* flag set if stream structure is initialised*/
-
- uLong offset_local_extrafield;/* offset of the local extra field */
- uInt size_local_extrafield;/* size of the local extra field */
- uLong pos_local_extrafield; /* position in the local extra field in read*/
-
- uLong crc32; /* crc32 of all data uncompressed */
- uLong crc32_wait; /* crc32 we must obtain after decompress all */
- uLong rest_read_compressed; /* number of byte to be decompressed */
- uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/
- zlib_filefunc_def z_filefunc;
- voidpf filestream; /* io structore of the zipfile */
- uLong compression_method; /* compression method (0==store) */
- uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
- int raw;
-} file_in_zip_read_info_s;
-
-
-/* unz_s contain internal information about the zipfile
-*/
-typedef struct
-{
- zlib_filefunc_def z_filefunc;
- voidpf filestream; /* io structore of the zipfile */
- unz_global_info gi; /* public global information */
- uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
- uLong num_file; /* number of the current file in the zipfile*/
- uLong pos_in_central_dir; /* pos of the current file in the central dir*/
- uLong current_file_ok; /* flag about the usability of the current file*/
- uLong central_pos; /* position of the beginning of the central dir*/
-
- uLong size_central_dir; /* size of the central directory */
- uLong offset_central_dir; /* offset of start of central directory with
- respect to the starting disk number */
-
- unz_file_info cur_file_info; /* public info about the current file in zip*/
- unz_file_info_internal cur_file_info_internal; /* private info about it*/
- file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current
- file if we are decompressing it */
- int encrypted;
-# ifndef NOUNCRYPT
- unsigned long keys[3]; /* keys defining the pseudo-random sequence */
- const unsigned long* pcrc_32_tab;
-# endif
-} unz_s;
-
-
-#ifndef NOUNCRYPT
-#include "crypt.h"
-#endif
-
-/* ===========================================================================
- Read a byte from a gz_stream; update next_in and avail_in. Return EOF
- for end of file.
- IN assertion: the stream s has been sucessfully opened for reading.
-*/
-
-
-local int unzlocal_getByte OF((
- const zlib_filefunc_def* pzlib_filefunc_def,
- voidpf filestream,
- int *pi));
-
-local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi)
- const zlib_filefunc_def* pzlib_filefunc_def;
- voidpf filestream;
- int *pi;
-{
- unsigned char c;
- int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
- if (err==1)
- {
- *pi = (int)c;
- return UNZ_OK;
- }
- else
- {
- if (ZERROR(*pzlib_filefunc_def,filestream))
- return UNZ_ERRNO;
- else
- return UNZ_EOF;
- }
-}
-
-
-/* ===========================================================================
- Reads a long in LSB order from the given gz_stream. Sets
-*/
-local int unzlocal_getShort OF((
- const zlib_filefunc_def* pzlib_filefunc_def,
- voidpf filestream,
- uLong *pX));
-
-local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX)
- const zlib_filefunc_def* pzlib_filefunc_def;
- voidpf filestream;
- uLong *pX;
-{
- uLong x ;
- int i;
- int err;
-
- err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
- x = (uLong)i;
-
- if (err==UNZ_OK)
- err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
- x += ((uLong)i)<<8;
-
- if (err==UNZ_OK)
- *pX = x;
- else
- *pX = 0;
- return err;
-}
-
-local int unzlocal_getLong OF((
- const zlib_filefunc_def* pzlib_filefunc_def,
- voidpf filestream,
- uLong *pX));
-
-local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX)
- const zlib_filefunc_def* pzlib_filefunc_def;
- voidpf filestream;
- uLong *pX;
-{
- uLong x ;
- int i;
- int err;
-
- err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
- x = (uLong)i;
-
- if (err==UNZ_OK)
- err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
- x += ((uLong)i)<<8;
-
- if (err==UNZ_OK)
- err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
- x += ((uLong)i)<<16;
-
- if (err==UNZ_OK)
- err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
- x += ((uLong)i)<<24;
-
- if (err==UNZ_OK)
- *pX = x;
- else
- *pX = 0;
- return err;
-}
-
-
-/* My own strcmpi / strcasecmp */
-local int strcmpcasenosensitive_internal (fileName1,fileName2)
- const char* fileName1;
- const char* fileName2;
-{
- for (;;)
- {
- char c1=*(fileName1++);
- char c2=*(fileName2++);
- if ((c1>='a') && (c1<='z'))
- c1 -= 0x20;
- if ((c2>='a') && (c2<='z'))
- c2 -= 0x20;
- if (c1=='\0')
- return ((c2=='\0') ? 0 : -1);
- if (c2=='\0')
- return 1;
- if (c1<c2)
- return -1;
- if (c1>c2)
- return 1;
- }
-}
-
-
-#ifdef CASESENSITIVITYDEFAULT_NO
-#define CASESENSITIVITYDEFAULTVALUE 2
-#else
-#define CASESENSITIVITYDEFAULTVALUE 1
-#endif
-
-#ifndef STRCMPCASENOSENTIVEFUNCTION
-#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
-#endif
-
-/*
- Compare two filename (fileName1,fileName2).
- If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
- If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
- or strcasecmp)
- If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
- (like 1 on Unix, 2 on Windows)
-
-*/
-extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity)
- const char* fileName1;
- const char* fileName2;
- int iCaseSensitivity;
-{
- if (iCaseSensitivity==0)
- iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
-
- if (iCaseSensitivity==1)
- return strcmp(fileName1,fileName2);
-
- return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
-}
-
-#ifndef BUFREADCOMMENT
-#define BUFREADCOMMENT (0x400)
-#endif
-
-/*
- Locate the Central directory of a zipfile (at the end, just before
- the global comment)
-*/
-local uLong unzlocal_SearchCentralDir OF((
- const zlib_filefunc_def* pzlib_filefunc_def,
- voidpf filestream));
-
-local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream)
- const zlib_filefunc_def* pzlib_filefunc_def;
- voidpf filestream;
-{
- unsigned char* buf;
- uLong uSizeFile;
- uLong uBackRead;
- uLong uMaxBack=0xffff; /* maximum size of global comment */
- uLong uPosFound=0;
-
- if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
- return 0;
-
-
- uSizeFile = ZTELL(*pzlib_filefunc_def,filestream);
-
- if (uMaxBack>uSizeFile)
- uMaxBack = uSizeFile;
-
- buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
- if (buf==NULL)
- return 0;
-
- uBackRead = 4;
- while (uBackRead<uMaxBack)
- {
- uLong uReadSize,uReadPos ;
- int i;
- if (uBackRead+BUFREADCOMMENT>uMaxBack)
- uBackRead = uMaxBack;
- else
- uBackRead+=BUFREADCOMMENT;
- uReadPos = uSizeFile-uBackRead ;
-
- uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
- (BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
- if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
- break;
-
- if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
- break;
-
- for (i=(int)uReadSize-3; (i--)>0;)
- if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
- ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
- {
- uPosFound = uReadPos+i;
- break;
- }
-
- if (uPosFound!=0)
- break;
- }
- TRYFREE(buf);
- return uPosFound;
-}
-
-/*
- Open a Zip file. path contain the full pathname (by example,
- on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer
- "zlib/zlib114.zip".
- If the zipfile cannot be opened (file doesn't exist or in not valid), the
- return value is NULL.
- Else, the return value is a unzFile Handle, usable with other function
- of this unzip package.
-*/
-extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def)
- const char *path;
- zlib_filefunc_def* pzlib_filefunc_def;
-{
- unz_s us;
- unz_s *s;
- uLong central_pos,uL;
-
- uLong number_disk; /* number of the current dist, used for
- spaning ZIP, unsupported, always 0*/
- uLong number_disk_with_CD; /* number the the disk with central dir, used
- for spaning ZIP, unsupported, always 0*/
- uLong number_entry_CD; /* total number of entries in
- the central dir
- (same than number_entry on nospan) */
-
- int err=UNZ_OK;
-
- if (unz_copyright[0]!=' ')
- return NULL;
-
- if (pzlib_filefunc_def==NULL)
- fill_fopen_filefunc(&us.z_filefunc);
- else
- us.z_filefunc = *pzlib_filefunc_def;
-
- us.filestream= (*(us.z_filefunc.zopen_file))(us.z_filefunc.opaque,
- path,
- ZLIB_FILEFUNC_MODE_READ |
- ZLIB_FILEFUNC_MODE_EXISTING);
- if (us.filestream==NULL)
- return NULL;
-
- central_pos = unzlocal_SearchCentralDir(&us.z_filefunc,us.filestream);
- if (central_pos==0)
- err=UNZ_ERRNO;
-
- if (ZSEEK(us.z_filefunc, us.filestream,
- central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
- err=UNZ_ERRNO;
-
- /* the signature, already checked */
- if (unzlocal_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* number of this disk */
- if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* number of the disk with the start of the central directory */
- if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* total number of entries in the central dir on this disk */
- if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* total number of entries in the central dir */
- if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- if ((number_entry_CD!=us.gi.number_entry) ||
- (number_disk_with_CD!=0) ||
- (number_disk!=0))
- err=UNZ_BADZIPFILE;
-
- /* size of the central directory */
- if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* offset of start of central directory with respect to the
- starting disk number */
- if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* zipfile comment length */
- if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
- (err==UNZ_OK))
- err=UNZ_BADZIPFILE;
-
- if (err!=UNZ_OK)
- {
- ZCLOSE(us.z_filefunc, us.filestream);
- return NULL;
- }
-
- us.byte_before_the_zipfile = central_pos -
- (us.offset_central_dir+us.size_central_dir);
- us.central_pos = central_pos;
- us.pfile_in_zip_read = NULL;
- us.encrypted = 0;
-
-
- s=(unz_s*)ALLOC(sizeof(unz_s));
- *s=us;
- unzGoToFirstFile((unzFile)s);
- return (unzFile)s;
-}
-
-
-extern unzFile ZEXPORT unzOpen (path)
- const char *path;
-{
- return unzOpen2(path, NULL);
-}
-
-/*
- Close a ZipFile opened with unzipOpen.
- If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
- these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
- return UNZ_OK if there is no problem. */
-extern int ZEXPORT unzClose (file)
- unzFile file;
-{
- unz_s* s;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
-
- if (s->pfile_in_zip_read!=NULL)
- unzCloseCurrentFile(file);
-
- ZCLOSE(s->z_filefunc, s->filestream);
- TRYFREE(s);
- return UNZ_OK;
-}
-
-
-/*
- Write info about the ZipFile in the *pglobal_info structure.
- No preparation of the structure is needed
- return UNZ_OK if there is no problem. */
-extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info)
- unzFile file;
- unz_global_info *pglobal_info;
-{
- unz_s* s;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- *pglobal_info=s->gi;
- return UNZ_OK;
-}
-
-
-/*
- Translate date/time from Dos format to tm_unz (readable more easilty)
-*/
-local void unzlocal_DosDateToTmuDate (ulDosDate, ptm)
- uLong ulDosDate;
- tm_unz* ptm;
-{
- uLong uDate;
- uDate = (uLong)(ulDosDate>>16);
- ptm->tm_mday = (uInt)(uDate&0x1f) ;
- ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ;
- ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
-
- ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
- ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ;
- ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ;
-}
-
-/*
- Get Info about the current file in the zipfile, with internal only info
-*/
-local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file,
- unz_file_info *pfile_info,
- unz_file_info_internal
- *pfile_info_internal,
- char *szFileName,
- uLong fileNameBufferSize,
- void *extraField,
- uLong extraFieldBufferSize,
- char *szComment,
- uLong commentBufferSize));
-
-local int unzlocal_GetCurrentFileInfoInternal (file,
- pfile_info,
- pfile_info_internal,
- szFileName, fileNameBufferSize,
- extraField, extraFieldBufferSize,
- szComment, commentBufferSize)
- unzFile file;
- unz_file_info *pfile_info;
- unz_file_info_internal *pfile_info_internal;
- char *szFileName;
- uLong fileNameBufferSize;
- void *extraField;
- uLong extraFieldBufferSize;
- char *szComment;
- uLong commentBufferSize;
-{
- unz_s* s;
- unz_file_info file_info;
- unz_file_info_internal file_info_internal;
- int err=UNZ_OK;
- uLong uMagic;
- long lSeek=0;
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- if (ZSEEK(s->z_filefunc, s->filestream,
- s->pos_in_central_dir+s->byte_before_the_zipfile,
- ZLIB_FILEFUNC_SEEK_SET)!=0)
- err=UNZ_ERRNO;
-
-
- /* we check the magic */
- if (err==UNZ_OK)
- if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
- err=UNZ_ERRNO;
- else if (uMagic!=0x02014b50)
- err=UNZ_BADZIPFILE;
-
- if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK)
- err=UNZ_ERRNO;
-
- unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
-
- if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
- err=UNZ_ERRNO;
-
- lSeek+=file_info.size_filename;
- if ((err==UNZ_OK) && (szFileName!=NULL))
- {
- uLong uSizeRead ;
- if (file_info.size_filename<fileNameBufferSize)
- {
- *(szFileName+file_info.size_filename)='\0';
- uSizeRead = file_info.size_filename;
- }
- else
- uSizeRead = fileNameBufferSize;
-
- if ((file_info.size_filename>0) && (fileNameBufferSize>0))
- if (ZREAD(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead)
- err=UNZ_ERRNO;
- lSeek -= uSizeRead;
- }
-
-
- if ((err==UNZ_OK) && (extraField!=NULL))
- {
- uLong uSizeRead ;
- if (file_info.size_file_extra<extraFieldBufferSize)
- uSizeRead = file_info.size_file_extra;
- else
- uSizeRead = extraFieldBufferSize;
-
- if (lSeek!=0)
- if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
- lSeek=0;
- else
- err=UNZ_ERRNO;
- if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
- if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead)
- err=UNZ_ERRNO;
- lSeek += file_info.size_file_extra - uSizeRead;
- }
- else
- lSeek+=file_info.size_file_extra;
-
-
- if ((err==UNZ_OK) && (szComment!=NULL))
- {
- uLong uSizeRead ;
- if (file_info.size_file_comment<commentBufferSize)
- {
- *(szComment+file_info.size_file_comment)='\0';
- uSizeRead = file_info.size_file_comment;
- }
- else
- uSizeRead = commentBufferSize;
-
- if (lSeek!=0)
- if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
- lSeek=0;
- else
- err=UNZ_ERRNO;
- if ((file_info.size_file_comment>0) && (commentBufferSize>0))
- if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
- err=UNZ_ERRNO;
- lSeek+=file_info.size_file_comment - uSizeRead;
- }
- else
- lSeek+=file_info.size_file_comment;
-
- if ((err==UNZ_OK) && (pfile_info!=NULL))
- *pfile_info=file_info;
-
- if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
- *pfile_info_internal=file_info_internal;
-
- return err;
-}
-
-
-
-/*
- Write info about the ZipFile in the *pglobal_info structure.
- No preparation of the structure is needed
- return UNZ_OK if there is no problem.
-*/
-extern int ZEXPORT unzGetCurrentFileInfo (file,
- pfile_info,
- szFileName, fileNameBufferSize,
- extraField, extraFieldBufferSize,
- szComment, commentBufferSize)
- unzFile file;
- unz_file_info *pfile_info;
- char *szFileName;
- uLong fileNameBufferSize;
- void *extraField;
- uLong extraFieldBufferSize;
- char *szComment;
- uLong commentBufferSize;
-{
- return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
- szFileName,fileNameBufferSize,
- extraField,extraFieldBufferSize,
- szComment,commentBufferSize);
-}
-
-/*
- Set the current file of the zipfile to the first file.
- return UNZ_OK if there is no problem
-*/
-extern int ZEXPORT unzGoToFirstFile (file)
- unzFile file;
-{
- int err=UNZ_OK;
- unz_s* s;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- s->pos_in_central_dir=s->offset_central_dir;
- s->num_file=0;
- err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
- &s->cur_file_info_internal,
- NULL,0,NULL,0,NULL,0);
- s->current_file_ok = (err == UNZ_OK);
- return err;
-}
-
-/*
- Set the current file of the zipfile to the next file.
- return UNZ_OK if there is no problem
- return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
-*/
-extern int ZEXPORT unzGoToNextFile (file)
- unzFile file;
-{
- unz_s* s;
- int err;
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- if (!s->current_file_ok)
- return UNZ_END_OF_LIST_OF_FILE;
- if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */
- if (s->num_file+1==s->gi.number_entry)
- return UNZ_END_OF_LIST_OF_FILE;
-
- s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
- s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
- s->num_file++;
- err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
- &s->cur_file_info_internal,
- NULL,0,NULL,0,NULL,0);
- s->current_file_ok = (err == UNZ_OK);
- return err;
-}
-
-
-/*
- Try locate the file szFileName in the zipfile.
- For the iCaseSensitivity signification, see unzipStringFileNameCompare
-
- return value :
- UNZ_OK if the file is found. It becomes the current file.
- UNZ_END_OF_LIST_OF_FILE if the file is not found
-*/
-extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
- unzFile file;
- const char *szFileName;
- int iCaseSensitivity;
-{
- unz_s* s;
- int err;
-
- /* We remember the 'current' position in the file so that we can jump
- * back there if we fail.
- */
- unz_file_info cur_file_infoSaved;
- unz_file_info_internal cur_file_info_internalSaved;
- uLong num_fileSaved;
- uLong pos_in_central_dirSaved;
-
-
- if (file==NULL)
- return UNZ_PARAMERROR;
-
- if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
- return UNZ_PARAMERROR;
-
- s=(unz_s*)file;
- if (!s->current_file_ok)
- return UNZ_END_OF_LIST_OF_FILE;
-
- /* Save the current state */
- num_fileSaved = s->num_file;
- pos_in_central_dirSaved = s->pos_in_central_dir;
- cur_file_infoSaved = s->cur_file_info;
- cur_file_info_internalSaved = s->cur_file_info_internal;
-
- err = unzGoToFirstFile(file);
-
- while (err == UNZ_OK)
- {
- char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
- err = unzGetCurrentFileInfo(file,NULL,
- szCurrentFileName,sizeof(szCurrentFileName)-1,
- NULL,0,NULL,0);
- if (err == UNZ_OK)
- {
- if (unzStringFileNameCompare(szCurrentFileName,
- szFileName,iCaseSensitivity)==0)
- return UNZ_OK;
- err = unzGoToNextFile(file);
- }
- }
-
- /* We failed, so restore the state of the 'current file' to where we
- * were.
- */
- s->num_file = num_fileSaved ;
- s->pos_in_central_dir = pos_in_central_dirSaved ;
- s->cur_file_info = cur_file_infoSaved;
- s->cur_file_info_internal = cur_file_info_internalSaved;
- return err;
-}
-
-
-/*
-///////////////////////////////////////////
-// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net)
-// I need random access
-//
-// Further optimization could be realized by adding an ability
-// to cache the directory in memory. The goal being a single
-// comprehensive file read to put the file I need in a memory.
-*/
-
-/*
-typedef struct unz_file_pos_s
-{
- uLong pos_in_zip_directory; // offset in file
- uLong num_of_file; // # of file
-} unz_file_pos;
-*/
-
-extern int ZEXPORT unzGetFilePos(file, file_pos)
- unzFile file;
- unz_file_pos* file_pos;
-{
- unz_s* s;
-
- if (file==NULL || file_pos==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- if (!s->current_file_ok)
- return UNZ_END_OF_LIST_OF_FILE;
-
- file_pos->pos_in_zip_directory = s->pos_in_central_dir;
- file_pos->num_of_file = s->num_file;
-
- return UNZ_OK;
-}
-
-extern int ZEXPORT unzGoToFilePos(file, file_pos)
- unzFile file;
- unz_file_pos* file_pos;
-{
- unz_s* s;
- int err;
-
- if (file==NULL || file_pos==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
-
- /* jump to the right spot */
- s->pos_in_central_dir = file_pos->pos_in_zip_directory;
- s->num_file = file_pos->num_of_file;
-
- /* set the current file */
- err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
- &s->cur_file_info_internal,
- NULL,0,NULL,0,NULL,0);
- /* return results */
- s->current_file_ok = (err == UNZ_OK);
- return err;
-}
-
-/*
-// Unzip Helper Functions - should be here?
-///////////////////////////////////////////
-*/
-
-/*
- Read the local header of the current zipfile
- Check the coherency of the local header and info in the end of central
- directory about this file
- store in *piSizeVar the size of extra info in local header
- (filename and size of extra field data)
-*/
-local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
- poffset_local_extrafield,
- psize_local_extrafield)
- unz_s* s;
- uInt* piSizeVar;
- uLong *poffset_local_extrafield;
- uInt *psize_local_extrafield;
-{
- uLong uMagic,uData,uFlags;
- uLong size_filename;
- uLong size_extra_field;
- int err=UNZ_OK;
-
- *piSizeVar = 0;
- *poffset_local_extrafield = 0;
- *psize_local_extrafield = 0;
-
- if (ZSEEK(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile +
- s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)
- return UNZ_ERRNO;
-
-
- if (err==UNZ_OK)
- if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
- err=UNZ_ERRNO;
- else if (uMagic!=0x04034b50)
- err=UNZ_BADZIPFILE;
-
- if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
- err=UNZ_ERRNO;
-/*
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
- err=UNZ_BADZIPFILE;
-*/
- if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
- err=UNZ_BADZIPFILE;
-
- if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
- (s->cur_file_info.compression_method!=Z_DEFLATED))
- err=UNZ_BADZIPFILE;
-
- if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */
- err=UNZ_ERRNO;
-
- if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) &&
- ((uFlags & 8)==0))
- err=UNZ_BADZIPFILE;
-
- if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) &&
- ((uFlags & 8)==0))
- err=UNZ_BADZIPFILE;
-
- if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) &&
- ((uFlags & 8)==0))
- err=UNZ_BADZIPFILE;
-
-
- if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK)
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
- err=UNZ_BADZIPFILE;
-
- *piSizeVar += (uInt)size_filename;
-
- if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK)
- err=UNZ_ERRNO;
- *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
- SIZEZIPLOCALHEADER + size_filename;
- *psize_local_extrafield = (uInt)size_extra_field;
-
- *piSizeVar += (uInt)size_extra_field;
-
- return err;
-}
-
-/*
- Open for reading data the current file in the zipfile.
- If there is no error and the file is opened, the return value is UNZ_OK.
-*/
-extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
- unzFile file;
- int* method;
- int* level;
- int raw;
- const char* password;
-{
- int err=UNZ_OK;
- uInt iSizeVar;
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- uLong offset_local_extrafield; /* offset of the local extra field */
- uInt size_local_extrafield; /* size of the local extra field */
-# ifndef NOUNCRYPT
- char source[12];
-# else
- if (password != NULL)
- return UNZ_PARAMERROR;
-# endif
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- if (!s->current_file_ok)
- return UNZ_PARAMERROR;
-
- if (s->pfile_in_zip_read != NULL)
- unzCloseCurrentFile(file);
-
- if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,
- &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
- return UNZ_BADZIPFILE;
-
- pfile_in_zip_read_info = (file_in_zip_read_info_s*)
- ALLOC(sizeof(file_in_zip_read_info_s));
- if (pfile_in_zip_read_info==NULL)
- return UNZ_INTERNALERROR;
-
- pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
- pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
- pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
- pfile_in_zip_read_info->pos_local_extrafield=0;
- pfile_in_zip_read_info->raw=raw;
-
- if (pfile_in_zip_read_info->read_buffer==NULL)
- {
- TRYFREE(pfile_in_zip_read_info);
- return UNZ_INTERNALERROR;
- }
-
- pfile_in_zip_read_info->stream_initialised=0;
-
- if (method!=NULL)
- *method = (int)s->cur_file_info.compression_method;
-
- if (level!=NULL)
- {
- *level = 6;
- switch (s->cur_file_info.flag & 0x06)
- {
- case 6 : *level = 1; break;
- case 4 : *level = 2; break;
- case 2 : *level = 9; break;
- }
- }
-
- if ((s->cur_file_info.compression_method!=0) &&
- (s->cur_file_info.compression_method!=Z_DEFLATED))
- err=UNZ_BADZIPFILE;
-
- pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
- pfile_in_zip_read_info->crc32=0;
- pfile_in_zip_read_info->compression_method =
- s->cur_file_info.compression_method;
- pfile_in_zip_read_info->filestream=s->filestream;
- pfile_in_zip_read_info->z_filefunc=s->z_filefunc;
- pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
-
- pfile_in_zip_read_info->stream.total_out = 0;
-
- if ((s->cur_file_info.compression_method==Z_DEFLATED) &&
- (!raw))
- {
- pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
- pfile_in_zip_read_info->stream.zfree = (free_func)0;
- pfile_in_zip_read_info->stream.opaque = (voidpf)0;
- pfile_in_zip_read_info->stream.next_in = (voidpf)0;
- pfile_in_zip_read_info->stream.avail_in = 0;
-
- err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
- if (err == Z_OK)
- pfile_in_zip_read_info->stream_initialised=1;
- else
- {
- TRYFREE(pfile_in_zip_read_info);
- return err;
- }
- /* windowBits is passed < 0 to tell that there is no zlib header.
- * Note that in this case inflate *requires* an extra "dummy" byte
- * after the compressed stream in order to complete decompression and
- * return Z_STREAM_END.
- * In unzip, i don't wait absolutely Z_STREAM_END because I known the
- * size of both compressed and uncompressed data
- */
- }
- pfile_in_zip_read_info->rest_read_compressed =
- s->cur_file_info.compressed_size ;
- pfile_in_zip_read_info->rest_read_uncompressed =
- s->cur_file_info.uncompressed_size ;
-
-
- pfile_in_zip_read_info->pos_in_zipfile =
- s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
- iSizeVar;
-
- pfile_in_zip_read_info->stream.avail_in = (uInt)0;
-
- s->pfile_in_zip_read = pfile_in_zip_read_info;
-
-# ifndef NOUNCRYPT
- if (password != NULL)
- {
- int i;
- s->pcrc_32_tab = get_crc_table();
- init_keys(password,s->keys,s->pcrc_32_tab);
- if (ZSEEK(s->z_filefunc, s->filestream,
- s->pfile_in_zip_read->pos_in_zipfile +
- s->pfile_in_zip_read->byte_before_the_zipfile,
- SEEK_SET)!=0)
- return UNZ_INTERNALERROR;
- if(ZREAD(s->z_filefunc, s->filestream,source, 12)<12)
- return UNZ_INTERNALERROR;
-
- for (i = 0; i<12; i++)
- zdecode(s->keys,s->pcrc_32_tab,source[i]);
-
- s->pfile_in_zip_read->pos_in_zipfile+=12;
- s->encrypted=1;
- }
-# endif
-
-
- return UNZ_OK;
-}
-
-extern int ZEXPORT unzOpenCurrentFile (file)
- unzFile file;
-{
- return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
-}
-
-extern int ZEXPORT unzOpenCurrentFilePassword (file, password)
- unzFile file;
- const char* password;
-{
- return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
-}
-
-extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw)
- unzFile file;
- int* method;
- int* level;
- int raw;
-{
- return unzOpenCurrentFile3(file, method, level, raw, NULL);
-}
-
-/*
- Read bytes from the current file.
- buf contain buffer where data must be copied
- len the size of buf.
-
- return the number of byte copied if somes bytes are copied
- return 0 if the end of file was reached
- return <0 with error code if there is an error
- (UNZ_ERRNO for IO error, or zLib error for uncompress error)
-*/
-extern int ZEXPORT unzReadCurrentFile (file, buf, len)
- unzFile file;
- voidp buf;
- unsigned len;
-{
- int err=UNZ_OK;
- uInt iRead = 0;
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
-
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
-
- if ((pfile_in_zip_read_info->read_buffer == NULL))
- return UNZ_END_OF_LIST_OF_FILE;
- if (len==0)
- return 0;
-
- pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
-
- pfile_in_zip_read_info->stream.avail_out = (uInt)len;
-
- if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
- (!(pfile_in_zip_read_info->raw)))
- pfile_in_zip_read_info->stream.avail_out =
- (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
-
- if ((len>pfile_in_zip_read_info->rest_read_compressed+
- pfile_in_zip_read_info->stream.avail_in) &&
- (pfile_in_zip_read_info->raw))
- pfile_in_zip_read_info->stream.avail_out =
- (uInt)pfile_in_zip_read_info->rest_read_compressed+
- pfile_in_zip_read_info->stream.avail_in;
-
- while (pfile_in_zip_read_info->stream.avail_out>0)
- {
- if ((pfile_in_zip_read_info->stream.avail_in==0) &&
- (pfile_in_zip_read_info->rest_read_compressed>0))
- {
- uInt uReadThis = UNZ_BUFSIZE;
- if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
- uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
- if (uReadThis == 0)
- return UNZ_EOF;
- if (ZSEEK(pfile_in_zip_read_info->z_filefunc,
- pfile_in_zip_read_info->filestream,
- pfile_in_zip_read_info->pos_in_zipfile +
- pfile_in_zip_read_info->byte_before_the_zipfile,
- ZLIB_FILEFUNC_SEEK_SET)!=0)
- return UNZ_ERRNO;
- if (ZREAD(pfile_in_zip_read_info->z_filefunc,
- pfile_in_zip_read_info->filestream,
- pfile_in_zip_read_info->read_buffer,
- uReadThis)!=uReadThis)
- return UNZ_ERRNO;
-
-
-# ifndef NOUNCRYPT
- if(s->encrypted)
- {
- uInt i;
- for(i=0;i<uReadThis;i++)
- pfile_in_zip_read_info->read_buffer[i] =
- zdecode(s->keys,s->pcrc_32_tab,
- pfile_in_zip_read_info->read_buffer[i]);
- }
-# endif
-
-
- pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
-
- pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
-
- pfile_in_zip_read_info->stream.next_in =
- (Bytef*)pfile_in_zip_read_info->read_buffer;
- pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
- }
-
- if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
- {
- uInt uDoCopy,i ;
-
- if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
- (pfile_in_zip_read_info->rest_read_compressed == 0))
- return (iRead==0) ? UNZ_EOF : iRead;
-
- if (pfile_in_zip_read_info->stream.avail_out <
- pfile_in_zip_read_info->stream.avail_in)
- uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
- else
- uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
-
- for (i=0;i<uDoCopy;i++)
- *(pfile_in_zip_read_info->stream.next_out+i) =
- *(pfile_in_zip_read_info->stream.next_in+i);
-
- pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
- pfile_in_zip_read_info->stream.next_out,
- uDoCopy);
- pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
- pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
- pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
- pfile_in_zip_read_info->stream.next_out += uDoCopy;
- pfile_in_zip_read_info->stream.next_in += uDoCopy;
- pfile_in_zip_read_info->stream.total_out += uDoCopy;
- iRead += uDoCopy;
- }
- else
- {
- uLong uTotalOutBefore,uTotalOutAfter;
- const Bytef *bufBefore;
- uLong uOutThis;
- int flush=Z_SYNC_FLUSH;
-
- uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
- bufBefore = pfile_in_zip_read_info->stream.next_out;
-
- /*
- if ((pfile_in_zip_read_info->rest_read_uncompressed ==
- pfile_in_zip_read_info->stream.avail_out) &&
- (pfile_in_zip_read_info->rest_read_compressed == 0))
- flush = Z_FINISH;
- */
- err=inflate(&pfile_in_zip_read_info->stream,flush);
-
- if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL))
- err = Z_DATA_ERROR;
-
- uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
- uOutThis = uTotalOutAfter-uTotalOutBefore;
-
- pfile_in_zip_read_info->crc32 =
- crc32(pfile_in_zip_read_info->crc32,bufBefore,
- (uInt)(uOutThis));
-
- pfile_in_zip_read_info->rest_read_uncompressed -=
- uOutThis;
-
- iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
-
- if (err==Z_STREAM_END)
- return (iRead==0) ? UNZ_EOF : iRead;
- if (err!=Z_OK)
- break;
- }
- }
-
- if (err==Z_OK)
- return iRead;
- return err;
-}
-
-
-/*
- Give the current position in uncompressed data
-*/
-extern z_off_t ZEXPORT unztell (file)
- unzFile file;
-{
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
-
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
- return (z_off_t)pfile_in_zip_read_info->stream.total_out;
-}
-
-
-/*
- return 1 if the end of file was reached, 0 elsewhere
-*/
-extern int ZEXPORT unzeof (file)
- unzFile file;
-{
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
-
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
- if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
- return 1;
- else
- return 0;
-}
-
-
-
-/*
- Read extra field from the current file (opened by unzOpenCurrentFile)
- This is the local-header version of the extra field (sometimes, there is
- more info in the local-header version than in the central-header)
-
- if buf==NULL, it return the size of the local extra field that can be read
-
- if buf!=NULL, len is the size of the buffer, the extra header is copied in
- buf.
- the return value is the number of bytes copied in buf, or (if <0)
- the error code
-*/
-extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
- unzFile file;
- voidp buf;
- unsigned len;
-{
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- uInt read_now;
- uLong size_to_read;
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
-
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
- size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
- pfile_in_zip_read_info->pos_local_extrafield);
-
- if (buf==NULL)
- return (int)size_to_read;
-
- if (len>size_to_read)
- read_now = (uInt)size_to_read;
- else
- read_now = (uInt)len ;
-
- if (read_now==0)
- return 0;
-
- if (ZSEEK(pfile_in_zip_read_info->z_filefunc,
- pfile_in_zip_read_info->filestream,
- pfile_in_zip_read_info->offset_local_extrafield +
- pfile_in_zip_read_info->pos_local_extrafield,
- ZLIB_FILEFUNC_SEEK_SET)!=0)
- return UNZ_ERRNO;
-
- if (ZREAD(pfile_in_zip_read_info->z_filefunc,
- pfile_in_zip_read_info->filestream,
- buf,read_now)!=read_now)
- return UNZ_ERRNO;
-
- return (int)read_now;
-}
-
-/*
- Close the file in zip opened with unzipOpenCurrentFile
- Return UNZ_CRCERROR if all the file was read but the CRC is not good
-*/
-extern int ZEXPORT unzCloseCurrentFile (file)
- unzFile file;
-{
- int err=UNZ_OK;
-
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
-
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
-
- if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
- (!pfile_in_zip_read_info->raw))
- {
- if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
- err=UNZ_CRCERROR;
- }
-
-
- TRYFREE(pfile_in_zip_read_info->read_buffer);
- pfile_in_zip_read_info->read_buffer = NULL;
- if (pfile_in_zip_read_info->stream_initialised)
- inflateEnd(&pfile_in_zip_read_info->stream);
-
- pfile_in_zip_read_info->stream_initialised = 0;
- TRYFREE(pfile_in_zip_read_info);
-
- s->pfile_in_zip_read=NULL;
-
- return err;
-}
-
-
-/*
- Get the global comment string of the ZipFile, in the szComment buffer.
- uSizeBuf is the size of the szComment buffer.
- return the number of byte copied or an error code <0
-*/
-extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
- unzFile file;
- char *szComment;
- uLong uSizeBuf;
-{
- int err=UNZ_OK;
- unz_s* s;
- uLong uReadThis ;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
-
- uReadThis = uSizeBuf;
- if (uReadThis>s->gi.size_comment)
- uReadThis = s->gi.size_comment;
-
- if (ZSEEK(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0)
- return UNZ_ERRNO;
-
- if (uReadThis>0)
- {
- *szComment='\0';
- if (ZREAD(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis)
- return UNZ_ERRNO;
- }
-
- if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
- *(szComment+s->gi.size_comment)='\0';
- return (int)uReadThis;
-}
-
-/* Additions by RX '2004 */
-extern uLong ZEXPORT unzGetOffset (file)
- unzFile file;
-{
- unz_s* s;
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- if (!s->current_file_ok)
- return 0;
- if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)
- if (s->num_file==s->gi.number_entry)
- return 0;
- return s->pos_in_central_dir;
-}
-
-extern int ZEXPORT unzSetOffset (file, pos)
- unzFile file;
- uLong pos;
-{
- unz_s* s;
- int err;
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
-
- s->pos_in_central_dir = pos;
- s->num_file = s->gi.number_entry; /* hack */
- err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
- &s->cur_file_info_internal,
- NULL,0,NULL,0,NULL,0);
- s->current_file_ok = (err == UNZ_OK);
- return err;
-}
diff --git a/source4/lib/zlib/contrib/minizip/unzip.h b/source4/lib/zlib/contrib/minizip/unzip.h
deleted file mode 100644
index b247937c80..0000000000
--- a/source4/lib/zlib/contrib/minizip/unzip.h
+++ /dev/null
@@ -1,354 +0,0 @@
-/* unzip.h -- IO for uncompress .zip files using zlib
- Version 1.01e, February 12th, 2005
-
- Copyright (C) 1998-2005 Gilles Vollant
-
- This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
- WinZip, InfoZip tools and compatible.
-
- Multi volume ZipFile (span) are not supported.
- Encryption compatible with pkzip 2.04g only supported
- Old compressions used by old PKZip 1.x are not supported
-
-
- I WAIT FEEDBACK at mail info@winimage.com
- Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
-
- Condition of use and distribution are the same than zlib :
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
-
-*/
-
-/* for more info about .ZIP format, see
- http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
- http://www.info-zip.org/pub/infozip/doc/
- PkWare has also a specification at :
- ftp://ftp.pkware.com/probdesc.zip
-*/
-
-#ifndef _unz_H
-#define _unz_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _ZLIB_H
-#include "zlib.h"
-#endif
-
-#ifndef _ZLIBIOAPI_H
-#include "ioapi.h"
-#endif
-
-#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
-/* like the STRICT of WIN32, we define a pointer that cannot be converted
- from (void*) without cast */
-typedef struct TagunzFile__ { int unused; } unzFile__;
-typedef unzFile__ *unzFile;
-#else
-typedef voidp unzFile;
-#endif
-
-
-#define UNZ_OK (0)
-#define UNZ_END_OF_LIST_OF_FILE (-100)
-#define UNZ_ERRNO (Z_ERRNO)
-#define UNZ_EOF (0)
-#define UNZ_PARAMERROR (-102)
-#define UNZ_BADZIPFILE (-103)
-#define UNZ_INTERNALERROR (-104)
-#define UNZ_CRCERROR (-105)
-
-/* tm_unz contain date/time info */
-typedef struct tm_unz_s
-{
- uInt tm_sec; /* seconds after the minute - [0,59] */
- uInt tm_min; /* minutes after the hour - [0,59] */
- uInt tm_hour; /* hours since midnight - [0,23] */
- uInt tm_mday; /* day of the month - [1,31] */
- uInt tm_mon; /* months since January - [0,11] */
- uInt tm_year; /* years - [1980..2044] */
-} tm_unz;
-
-/* unz_global_info structure contain global data about the ZIPfile
- These data comes from the end of central dir */
-typedef struct unz_global_info_s
-{
- uLong number_entry; /* total number of entries in
- the central dir on this disk */
- uLong size_comment; /* size of the global comment of the zipfile */
-} unz_global_info;
-
-
-/* unz_file_info contain information about a file in the zipfile */
-typedef struct unz_file_info_s
-{
- uLong version; /* version made by 2 bytes */
- uLong version_needed; /* version needed to extract 2 bytes */
- uLong flag; /* general purpose bit flag 2 bytes */
- uLong compression_method; /* compression method 2 bytes */
- uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
- uLong crc; /* crc-32 4 bytes */
- uLong compressed_size; /* compressed size 4 bytes */
- uLong uncompressed_size; /* uncompressed size 4 bytes */
- uLong size_filename; /* filename length 2 bytes */
- uLong size_file_extra; /* extra field length 2 bytes */
- uLong size_file_comment; /* file comment length 2 bytes */
-
- uLong disk_num_start; /* disk number start 2 bytes */
- uLong internal_fa; /* internal file attributes 2 bytes */
- uLong external_fa; /* external file attributes 4 bytes */
-
- tm_unz tmu_date;
-} unz_file_info;
-
-extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
- const char* fileName2,
- int iCaseSensitivity));
-/*
- Compare two filename (fileName1,fileName2).
- If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
- If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
- or strcasecmp)
- If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
- (like 1 on Unix, 2 on Windows)
-*/
-
-
-extern unzFile ZEXPORT unzOpen OF((const char *path));
-/*
- Open a Zip file. path contain the full pathname (by example,
- on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
- "zlib/zlib113.zip".
- If the zipfile cannot be opened (file don't exist or in not valid), the
- return value is NULL.
- Else, the return value is a unzFile Handle, usable with other function
- of this unzip package.
-*/
-
-extern unzFile ZEXPORT unzOpen2 OF((const char *path,
- zlib_filefunc_def* pzlib_filefunc_def));
-/*
- Open a Zip file, like unzOpen, but provide a set of file low level API
- for read/write the zip file (see ioapi.h)
-*/
-
-extern int ZEXPORT unzClose OF((unzFile file));
-/*
- Close a ZipFile opened with unzipOpen.
- If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
- these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
- return UNZ_OK if there is no problem. */
-
-extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
- unz_global_info *pglobal_info));
-/*
- Write info about the ZipFile in the *pglobal_info structure.
- No preparation of the structure is needed
- return UNZ_OK if there is no problem. */
-
-
-extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
- char *szComment,
- uLong uSizeBuf));
-/*
- Get the global comment string of the ZipFile, in the szComment buffer.
- uSizeBuf is the size of the szComment buffer.
- return the number of byte copied or an error code <0
-*/
-
-
-/***************************************************************************/
-/* Unzip package allow you browse the directory of the zipfile */
-
-extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
-/*
- Set the current file of the zipfile to the first file.
- return UNZ_OK if there is no problem
-*/
-
-extern int ZEXPORT unzGoToNextFile OF((unzFile file));
-/*
- Set the current file of the zipfile to the next file.
- return UNZ_OK if there is no problem
- return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
-*/
-
-extern int ZEXPORT unzLocateFile OF((unzFile file,
- const char *szFileName,
- int iCaseSensitivity));
-/*
- Try locate the file szFileName in the zipfile.
- For the iCaseSensitivity signification, see unzStringFileNameCompare
-
- return value :
- UNZ_OK if the file is found. It becomes the current file.
- UNZ_END_OF_LIST_OF_FILE if the file is not found
-*/
-
-
-/* ****************************************** */
-/* Ryan supplied functions */
-/* unz_file_info contain information about a file in the zipfile */
-typedef struct unz_file_pos_s
-{
- uLong pos_in_zip_directory; /* offset in zip file directory */
- uLong num_of_file; /* # of file */
-} unz_file_pos;
-
-extern int ZEXPORT unzGetFilePos(
- unzFile file,
- unz_file_pos* file_pos);
-
-extern int ZEXPORT unzGoToFilePos(
- unzFile file,
- unz_file_pos* file_pos);
-
-/* ****************************************** */
-
-extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
- unz_file_info *pfile_info,
- char *szFileName,
- uLong fileNameBufferSize,
- void *extraField,
- uLong extraFieldBufferSize,
- char *szComment,
- uLong commentBufferSize));
-/*
- Get Info about the current file
- if pfile_info!=NULL, the *pfile_info structure will contain somes info about
- the current file
- if szFileName!=NULL, the filemane string will be copied in szFileName
- (fileNameBufferSize is the size of the buffer)
- if extraField!=NULL, the extra field information will be copied in extraField
- (extraFieldBufferSize is the size of the buffer).
- This is the Central-header version of the extra field
- if szComment!=NULL, the comment string of the file will be copied in szComment
- (commentBufferSize is the size of the buffer)
-*/
-
-/***************************************************************************/
-/* for reading the content of the current zipfile, you can open it, read data
- from it, and close it (you can close it before reading all the file)
- */
-
-extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
-/*
- Open for reading data the current file in the zipfile.
- If there is no error, the return value is UNZ_OK.
-*/
-
-extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
- const char* password));
-/*
- Open for reading data the current file in the zipfile.
- password is a crypting password
- If there is no error, the return value is UNZ_OK.
-*/
-
-extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
- int* method,
- int* level,
- int raw));
-/*
- Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
- if raw==1
- *method will receive method of compression, *level will receive level of
- compression
- note : you can set level parameter as NULL (if you did not want known level,
- but you CANNOT set method parameter as NULL
-*/
-
-extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
- int* method,
- int* level,
- int raw,
- const char* password));
-/*
- Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
- if raw==1
- *method will receive method of compression, *level will receive level of
- compression
- note : you can set level parameter as NULL (if you did not want known level,
- but you CANNOT set method parameter as NULL
-*/
-
-
-extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
-/*
- Close the file in zip opened with unzOpenCurrentFile
- Return UNZ_CRCERROR if all the file was read but the CRC is not good
-*/
-
-extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
- voidp buf,
- unsigned len));
-/*
- Read bytes from the current file (opened by unzOpenCurrentFile)
- buf contain buffer where data must be copied
- len the size of buf.
-
- return the number of byte copied if somes bytes are copied
- return 0 if the end of file was reached
- return <0 with error code if there is an error
- (UNZ_ERRNO for IO error, or zLib error for uncompress error)
-*/
-
-extern z_off_t ZEXPORT unztell OF((unzFile file));
-/*
- Give the current position in uncompressed data
-*/
-
-extern int ZEXPORT unzeof OF((unzFile file));
-/*
- return 1 if the end of file was reached, 0 elsewhere
-*/
-
-extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
- voidp buf,
- unsigned len));
-/*
- Read extra field from the current file (opened by unzOpenCurrentFile)
- This is the local-header version of the extra field (sometimes, there is
- more info in the local-header version than in the central-header)
-
- if buf==NULL, it return the size of the local extra field
-
- if buf!=NULL, len is the size of the buffer, the extra header is copied in
- buf.
- the return value is the number of bytes copied in buf, or (if <0)
- the error code
-*/
-
-/***************************************************************************/
-
-/* Get the current file offset */
-extern uLong ZEXPORT unzGetOffset (unzFile file);
-
-/* Set the current file offset */
-extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _unz_H */
diff --git a/source4/lib/zlib/contrib/minizip/zip.c b/source4/lib/zlib/contrib/minizip/zip.c
deleted file mode 100644
index 7fbe002743..0000000000
--- a/source4/lib/zlib/contrib/minizip/zip.c
+++ /dev/null
@@ -1,1219 +0,0 @@
-/* zip.c -- IO on .zip files using zlib
- Version 1.01e, February 12th, 2005
-
- 27 Dec 2004 Rolf Kalbermatter
- Modification to zipOpen2 to support globalComment retrieval.
-
- Copyright (C) 1998-2005 Gilles Vollant
-
- Read zip.h for more info
-*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include "zlib.h"
-#include "zip.h"
-
-#ifdef STDC
-# include <stddef.h>
-# include <string.h>
-# include <stdlib.h>
-#endif
-#ifdef NO_ERRNO_H
- extern int errno;
-#else
-# include <errno.h>
-#endif
-
-
-#ifndef local
-# define local static
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
-#ifndef VERSIONMADEBY
-# define VERSIONMADEBY (0x0) /* platform depedent */
-#endif
-
-#ifndef Z_BUFSIZE
-#define Z_BUFSIZE (16384)
-#endif
-
-#ifndef Z_MAXFILENAMEINZIP
-#define Z_MAXFILENAMEINZIP (256)
-#endif
-
-#ifndef ALLOC
-# define ALLOC(size) (malloc(size))
-#endif
-#ifndef TRYFREE
-# define TRYFREE(p) {if (p) free(p);}
-#endif
-
-/*
-#define SIZECENTRALDIRITEM (0x2e)
-#define SIZEZIPLOCALHEADER (0x1e)
-*/
-
-/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
-
-#ifndef SEEK_CUR
-#define SEEK_CUR 1
-#endif
-
-#ifndef SEEK_END
-#define SEEK_END 2
-#endif
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-
-#ifndef DEF_MEM_LEVEL
-#if MAX_MEM_LEVEL >= 8
-# define DEF_MEM_LEVEL 8
-#else
-# define DEF_MEM_LEVEL MAX_MEM_LEVEL
-#endif
-#endif
-const char zip_copyright[] =
- " zip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
-
-
-#define SIZEDATA_INDATABLOCK (4096-(4*4))
-
-#define LOCALHEADERMAGIC (0x04034b50)
-#define CENTRALHEADERMAGIC (0x02014b50)
-#define ENDHEADERMAGIC (0x06054b50)
-
-#define FLAG_LOCALHEADER_OFFSET (0x06)
-#define CRC_LOCALHEADER_OFFSET (0x0e)
-
-#define SIZECENTRALHEADER (0x2e) /* 46 */
-
-typedef struct linkedlist_datablock_internal_s
-{
- struct linkedlist_datablock_internal_s* next_datablock;
- uLong avail_in_this_block;
- uLong filled_in_this_block;
- uLong unused; /* for future use and alignement */
- unsigned char data[SIZEDATA_INDATABLOCK];
-} linkedlist_datablock_internal;
-
-typedef struct linkedlist_data_s
-{
- linkedlist_datablock_internal* first_block;
- linkedlist_datablock_internal* last_block;
-} linkedlist_data;
-
-
-typedef struct
-{
- z_stream stream; /* zLib stream structure for inflate */
- int stream_initialised; /* 1 is stream is initialised */
- uInt pos_in_buffered_data; /* last written byte in buffered_data */
-
- uLong pos_local_header; /* offset of the local header of the file
- currenty writing */
- char* central_header; /* central header data for the current file */
- uLong size_centralheader; /* size of the central header for cur file */
- uLong flag; /* flag of the file currently writing */
-
- int method; /* compression method of file currenty wr.*/
- int raw; /* 1 for directly writing raw data */
- Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/
- uLong dosDate;
- uLong crc32;
- int encrypt;
-#ifndef NOCRYPT
- unsigned long keys[3]; /* keys defining the pseudo-random sequence */
- const unsigned long* pcrc_32_tab;
- int crypt_header_size;
-#endif
-} curfile_info;
-
-typedef struct
-{
- zlib_filefunc_def z_filefunc;
- voidpf filestream; /* io structore of the zipfile */
- linkedlist_data central_dir;/* datablock with central dir in construction*/
- int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/
- curfile_info ci; /* info on the file curretly writing */
-
- uLong begin_pos; /* position of the beginning of the zipfile */
- uLong add_position_when_writting_offset;
- uLong number_entry;
-#ifndef NO_ADDFILEINEXISTINGZIP
- char *globalcomment;
-#endif
-} zip_internal;
-
-
-
-#ifndef NOCRYPT
-#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED
-#include "crypt.h"
-#endif
-
-local linkedlist_datablock_internal* allocate_new_datablock()
-{
- linkedlist_datablock_internal* ldi;
- ldi = (linkedlist_datablock_internal*)
- ALLOC(sizeof(linkedlist_datablock_internal));
- if (ldi!=NULL)
- {
- ldi->next_datablock = NULL ;
- ldi->filled_in_this_block = 0 ;
- ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ;
- }
- return ldi;
-}
-
-local void free_datablock(ldi)
- linkedlist_datablock_internal* ldi;
-{
- while (ldi!=NULL)
- {
- linkedlist_datablock_internal* ldinext = ldi->next_datablock;
- TRYFREE(ldi);
- ldi = ldinext;
- }
-}
-
-local void init_linkedlist(ll)
- linkedlist_data* ll;
-{
- ll->first_block = ll->last_block = NULL;
-}
-
-local void free_linkedlist(ll)
- linkedlist_data* ll;
-{
- free_datablock(ll->first_block);
- ll->first_block = ll->last_block = NULL;
-}
-
-
-local int add_data_in_datablock(ll,buf,len)
- linkedlist_data* ll;
- const void* buf;
- uLong len;
-{
- linkedlist_datablock_internal* ldi;
- const unsigned char* from_copy;
-
- if (ll==NULL)
- return ZIP_INTERNALERROR;
-
- if (ll->last_block == NULL)
- {
- ll->first_block = ll->last_block = allocate_new_datablock();
- if (ll->first_block == NULL)
- return ZIP_INTERNALERROR;
- }
-
- ldi = ll->last_block;
- from_copy = (unsigned char*)buf;
-
- while (len>0)
- {
- uInt copy_this;
- uInt i;
- unsigned char* to_copy;
-
- if (ldi->avail_in_this_block==0)
- {
- ldi->next_datablock = allocate_new_datablock();
- if (ldi->next_datablock == NULL)
- return ZIP_INTERNALERROR;
- ldi = ldi->next_datablock ;
- ll->last_block = ldi;
- }
-
- if (ldi->avail_in_this_block < len)
- copy_this = (uInt)ldi->avail_in_this_block;
- else
- copy_this = (uInt)len;
-
- to_copy = &(ldi->data[ldi->filled_in_this_block]);
-
- for (i=0;i<copy_this;i++)
- *(to_copy+i)=*(from_copy+i);
-
- ldi->filled_in_this_block += copy_this;
- ldi->avail_in_this_block -= copy_this;
- from_copy += copy_this ;
- len -= copy_this;
- }
- return ZIP_OK;
-}
-
-
-
-/****************************************************************************/
-
-#ifndef NO_ADDFILEINEXISTINGZIP
-/* ===========================================================================
- Inputs a long in LSB order to the given file
- nbByte == 1, 2 or 4 (byte, short or long)
-*/
-
-local int ziplocal_putValue OF((const zlib_filefunc_def* pzlib_filefunc_def,
- voidpf filestream, uLong x, int nbByte));
-local int ziplocal_putValue (pzlib_filefunc_def, filestream, x, nbByte)
- const zlib_filefunc_def* pzlib_filefunc_def;
- voidpf filestream;
- uLong x;
- int nbByte;
-{
- unsigned char buf[4];
- int n;
- for (n = 0; n < nbByte; n++)
- {
- buf[n] = (unsigned char)(x & 0xff);
- x >>= 8;
- }
- if (x != 0)
- { /* data overflow - hack for ZIP64 (X Roche) */
- for (n = 0; n < nbByte; n++)
- {
- buf[n] = 0xff;
- }
- }
-
- if (ZWRITE(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte)
- return ZIP_ERRNO;
- else
- return ZIP_OK;
-}
-
-local void ziplocal_putValue_inmemory OF((void* dest, uLong x, int nbByte));
-local void ziplocal_putValue_inmemory (dest, x, nbByte)
- void* dest;
- uLong x;
- int nbByte;
-{
- unsigned char* buf=(unsigned char*)dest;
- int n;
- for (n = 0; n < nbByte; n++) {
- buf[n] = (unsigned char)(x & 0xff);
- x >>= 8;
- }
-
- if (x != 0)
- { /* data overflow - hack for ZIP64 */
- for (n = 0; n < nbByte; n++)
- {
- buf[n] = 0xff;
- }
- }
-}
-
-/****************************************************************************/
-
-
-local uLong ziplocal_TmzDateToDosDate(ptm,dosDate)
- const tm_zip* ptm;
- uLong dosDate;
-{
- uLong year = (uLong)ptm->tm_year;
- if (year>1980)
- year-=1980;
- else if (year>80)
- year-=80;
- return
- (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) |
- ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour));
-}
-
-
-/****************************************************************************/
-
-local int ziplocal_getByte OF((
- const zlib_filefunc_def* pzlib_filefunc_def,
- voidpf filestream,
- int *pi));
-
-local int ziplocal_getByte(pzlib_filefunc_def,filestream,pi)
- const zlib_filefunc_def* pzlib_filefunc_def;
- voidpf filestream;
- int *pi;
-{
- unsigned char c;
- int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
- if (err==1)
- {
- *pi = (int)c;
- return ZIP_OK;
- }
- else
- {
- if (ZERROR(*pzlib_filefunc_def,filestream))
- return ZIP_ERRNO;
- else
- return ZIP_EOF;
- }
-}
-
-
-/* ===========================================================================
- Reads a long in LSB order from the given gz_stream. Sets
-*/
-local int ziplocal_getShort OF((
- const zlib_filefunc_def* pzlib_filefunc_def,
- voidpf filestream,
- uLong *pX));
-
-local int ziplocal_getShort (pzlib_filefunc_def,filestream,pX)
- const zlib_filefunc_def* pzlib_filefunc_def;
- voidpf filestream;
- uLong *pX;
-{
- uLong x ;
- int i;
- int err;
-
- err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
- x = (uLong)i;
-
- if (err==ZIP_OK)
- err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
- x += ((uLong)i)<<8;
-
- if (err==ZIP_OK)
- *pX = x;
- else
- *pX = 0;
- return err;
-}
-
-local int ziplocal_getLong OF((
- const zlib_filefunc_def* pzlib_filefunc_def,
- voidpf filestream,
- uLong *pX));
-
-local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX)
- const zlib_filefunc_def* pzlib_filefunc_def;
- voidpf filestream;
- uLong *pX;
-{
- uLong x ;
- int i;
- int err;
-
- err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
- x = (uLong)i;
-
- if (err==ZIP_OK)
- err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
- x += ((uLong)i)<<8;
-
- if (err==ZIP_OK)
- err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
- x += ((uLong)i)<<16;
-
- if (err==ZIP_OK)
- err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
- x += ((uLong)i)<<24;
-
- if (err==ZIP_OK)
- *pX = x;
- else
- *pX = 0;
- return err;
-}
-
-#ifndef BUFREADCOMMENT
-#define BUFREADCOMMENT (0x400)
-#endif
-/*
- Locate the Central directory of a zipfile (at the end, just before
- the global comment)
-*/
-local uLong ziplocal_SearchCentralDir OF((
- const zlib_filefunc_def* pzlib_filefunc_def,
- voidpf filestream));
-
-local uLong ziplocal_SearchCentralDir(pzlib_filefunc_def,filestream)
- const zlib_filefunc_def* pzlib_filefunc_def;
- voidpf filestream;
-{
- unsigned char* buf;
- uLong uSizeFile;
- uLong uBackRead;
- uLong uMaxBack=0xffff; /* maximum size of global comment */
- uLong uPosFound=0;
-
- if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
- return 0;
-
-
- uSizeFile = ZTELL(*pzlib_filefunc_def,filestream);
-
- if (uMaxBack>uSizeFile)
- uMaxBack = uSizeFile;
-
- buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
- if (buf==NULL)
- return 0;
-
- uBackRead = 4;
- while (uBackRead<uMaxBack)
- {
- uLong uReadSize,uReadPos ;
- int i;
- if (uBackRead+BUFREADCOMMENT>uMaxBack)
- uBackRead = uMaxBack;
- else
- uBackRead+=BUFREADCOMMENT;
- uReadPos = uSizeFile-uBackRead ;
-
- uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
- (BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
- if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
- break;
-
- if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
- break;
-
- for (i=(int)uReadSize-3; (i--)>0;)
- if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
- ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
- {
- uPosFound = uReadPos+i;
- break;
- }
-
- if (uPosFound!=0)
- break;
- }
- TRYFREE(buf);
- return uPosFound;
-}
-#endif /* !NO_ADDFILEINEXISTINGZIP*/
-
-/************************************************************/
-extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc_def)
- const char *pathname;
- int append;
- zipcharpc* globalcomment;
- zlib_filefunc_def* pzlib_filefunc_def;
-{
- zip_internal ziinit;
- zip_internal* zi;
- int err=ZIP_OK;
-
-
- if (pzlib_filefunc_def==NULL)
- fill_fopen_filefunc(&ziinit.z_filefunc);
- else
- ziinit.z_filefunc = *pzlib_filefunc_def;
-
- ziinit.filestream = (*(ziinit.z_filefunc.zopen_file))
- (ziinit.z_filefunc.opaque,
- pathname,
- (append == APPEND_STATUS_CREATE) ?
- (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) :
- (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_EXISTING));
-
- if (ziinit.filestream == NULL)
- return NULL;
- ziinit.begin_pos = ZTELL(ziinit.z_filefunc,ziinit.filestream);
- ziinit.in_opened_file_inzip = 0;
- ziinit.ci.stream_initialised = 0;
- ziinit.number_entry = 0;
- ziinit.add_position_when_writting_offset = 0;
- init_linkedlist(&(ziinit.central_dir));
-
-
- zi = (zip_internal*)ALLOC(sizeof(zip_internal));
- if (zi==NULL)
- {
- ZCLOSE(ziinit.z_filefunc,ziinit.filestream);
- return NULL;
- }
-
- /* now we add file in a zipfile */
-# ifndef NO_ADDFILEINEXISTINGZIP
- ziinit.globalcomment = NULL;
- if (append == APPEND_STATUS_ADDINZIP)
- {
- uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
-
- uLong size_central_dir; /* size of the central directory */
- uLong offset_central_dir; /* offset of start of central directory */
- uLong central_pos,uL;
-
- uLong number_disk; /* number of the current dist, used for
- spaning ZIP, unsupported, always 0*/
- uLong number_disk_with_CD; /* number the the disk with central dir, used
- for spaning ZIP, unsupported, always 0*/
- uLong number_entry;
- uLong number_entry_CD; /* total number of entries in
- the central dir
- (same than number_entry on nospan) */
- uLong size_comment;
-
- central_pos = ziplocal_SearchCentralDir(&ziinit.z_filefunc,ziinit.filestream);
- if (central_pos==0)
- err=ZIP_ERRNO;
-
- if (ZSEEK(ziinit.z_filefunc, ziinit.filestream,
- central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
- err=ZIP_ERRNO;
-
- /* the signature, already checked */
- if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&uL)!=ZIP_OK)
- err=ZIP_ERRNO;
-
- /* number of this disk */
- if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk)!=ZIP_OK)
- err=ZIP_ERRNO;
-
- /* number of the disk with the start of the central directory */
- if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk_with_CD)!=ZIP_OK)
- err=ZIP_ERRNO;
-
- /* total number of entries in the central dir on this disk */
- if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry)!=ZIP_OK)
- err=ZIP_ERRNO;
-
- /* total number of entries in the central dir */
- if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry_CD)!=ZIP_OK)
- err=ZIP_ERRNO;
-
- if ((number_entry_CD!=number_entry) ||
- (number_disk_with_CD!=0) ||
- (number_disk!=0))
- err=ZIP_BADZIPFILE;
-
- /* size of the central directory */
- if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&size_central_dir)!=ZIP_OK)
- err=ZIP_ERRNO;
-
- /* offset of start of central directory with respect to the
- starting disk number */
- if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&offset_central_dir)!=ZIP_OK)
- err=ZIP_ERRNO;
-
- /* zipfile global comment length */
- if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&size_comment)!=ZIP_OK)
- err=ZIP_ERRNO;
-
- if ((central_pos<offset_central_dir+size_central_dir) &&
- (err==ZIP_OK))
- err=ZIP_BADZIPFILE;
-
- if (err!=ZIP_OK)
- {
- ZCLOSE(ziinit.z_filefunc, ziinit.filestream);
- return NULL;
- }
-
- if (size_comment>0)
- {
- ziinit.globalcomment = ALLOC(size_comment+1);
- if (ziinit.globalcomment)
- {
- size_comment = ZREAD(ziinit.z_filefunc, ziinit.filestream,ziinit.globalcomment,size_comment);
- ziinit.globalcomment[size_comment]=0;
- }
- }
-
- byte_before_the_zipfile = central_pos -
- (offset_central_dir+size_central_dir);
- ziinit.add_position_when_writting_offset = byte_before_the_zipfile;
-
- {
- uLong size_central_dir_to_read = size_central_dir;
- size_t buf_size = SIZEDATA_INDATABLOCK;
- void* buf_read = (void*)ALLOC(buf_size);
- if (ZSEEK(ziinit.z_filefunc, ziinit.filestream,
- offset_central_dir + byte_before_the_zipfile,
- ZLIB_FILEFUNC_SEEK_SET) != 0)
- err=ZIP_ERRNO;
-
- while ((size_central_dir_to_read>0) && (err==ZIP_OK))
- {
- uLong read_this = SIZEDATA_INDATABLOCK;
- if (read_this > size_central_dir_to_read)
- read_this = size_central_dir_to_read;
- if (ZREAD(ziinit.z_filefunc, ziinit.filestream,buf_read,read_this) != read_this)
- err=ZIP_ERRNO;
-
- if (err==ZIP_OK)
- err = add_data_in_datablock(&ziinit.central_dir,buf_read,
- (uLong)read_this);
- size_central_dir_to_read-=read_this;
- }
- TRYFREE(buf_read);
- }
- ziinit.begin_pos = byte_before_the_zipfile;
- ziinit.number_entry = number_entry_CD;
-
- if (ZSEEK(ziinit.z_filefunc, ziinit.filestream,
- offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)
- err=ZIP_ERRNO;
- }
-
- if (globalcomment)
- {
- *globalcomment = ziinit.globalcomment;
- }
-# endif /* !NO_ADDFILEINEXISTINGZIP*/
-
- if (err != ZIP_OK)
- {
-# ifndef NO_ADDFILEINEXISTINGZIP
- TRYFREE(ziinit.globalcomment);
-# endif /* !NO_ADDFILEINEXISTINGZIP*/
- TRYFREE(zi);
- return NULL;
- }
- else
- {
- *zi = ziinit;
- return (zipFile)zi;
- }
-}
-
-extern zipFile ZEXPORT zipOpen (pathname, append)
- const char *pathname;
- int append;
-{
- return zipOpen2(pathname,append,NULL,NULL);
-}
-
-extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi,
- extrafield_local, size_extrafield_local,
- extrafield_global, size_extrafield_global,
- comment, method, level, raw,
- windowBits, memLevel, strategy,
- password, crcForCrypting)
- zipFile file;
- const char* filename;
- const zip_fileinfo* zipfi;
- const void* extrafield_local;
- uInt size_extrafield_local;
- const void* extrafield_global;
- uInt size_extrafield_global;
- const char* comment;
- int method;
- int level;
- int raw;
- int windowBits;
- int memLevel;
- int strategy;
- const char* password;
- uLong crcForCrypting;
-{
- zip_internal* zi;
- uInt size_filename;
- uInt size_comment;
- uInt i;
- int err = ZIP_OK;
-
-# ifdef NOCRYPT
- if (password != NULL)
- return ZIP_PARAMERROR;
-# endif
-
- if (file == NULL)
- return ZIP_PARAMERROR;
- if ((method!=0) && (method!=Z_DEFLATED))
- return ZIP_PARAMERROR;
-
- zi = (zip_internal*)file;
-
- if (zi->in_opened_file_inzip == 1)
- {
- err = zipCloseFileInZip (file);
- if (err != ZIP_OK)
- return err;
- }
-
-
- if (filename==NULL)
- filename="-";
-
- if (comment==NULL)
- size_comment = 0;
- else
- size_comment = (uInt)strlen(comment);
-
- size_filename = (uInt)strlen(filename);
-
- if (zipfi == NULL)
- zi->ci.dosDate = 0;
- else
- {
- if (zipfi->dosDate != 0)
- zi->ci.dosDate = zipfi->dosDate;
- else zi->ci.dosDate = ziplocal_TmzDateToDosDate(&zipfi->tmz_date,zipfi->dosDate);
- }
-
- zi->ci.flag = 0;
- if ((level==8) || (level==9))
- zi->ci.flag |= 2;
- if ((level==2))
- zi->ci.flag |= 4;
- if ((level==1))
- zi->ci.flag |= 6;
- if (password != NULL)
- zi->ci.flag |= 1;
-
- zi->ci.crc32 = 0;
- zi->ci.method = method;
- zi->ci.encrypt = 0;
- zi->ci.stream_initialised = 0;
- zi->ci.pos_in_buffered_data = 0;
- zi->ci.raw = raw;
- zi->ci.pos_local_header = ZTELL(zi->z_filefunc,zi->filestream) ;
- zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename +
- size_extrafield_global + size_comment;
- zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader);
-
- ziplocal_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4);
- /* version info */
- ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)VERSIONMADEBY,2);
- ziplocal_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2);
- ziplocal_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2);
- ziplocal_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2);
- ziplocal_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4);
- ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/
- ziplocal_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/
- ziplocal_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/
- ziplocal_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2);
- ziplocal_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2);
- ziplocal_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2);
- ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/
-
- if (zipfi==NULL)
- ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2);
- else
- ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2);
-
- if (zipfi==NULL)
- ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4);
- else
- ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4);
-
- ziplocal_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header- zi->add_position_when_writting_offset,4);
-
- for (i=0;i<size_filename;i++)
- *(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i);
-
- for (i=0;i<size_extrafield_global;i++)
- *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+i) =
- *(((const char*)extrafield_global)+i);
-
- for (i=0;i<size_comment;i++)
- *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+
- size_extrafield_global+i) = *(comment+i);
- if (zi->ci.central_header == NULL)
- return ZIP_INTERNALERROR;
-
- /* write the local header */
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC,4);
-
- if (err==ZIP_OK)
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */
- if (err==ZIP_OK)
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.flag,2);
-
- if (err==ZIP_OK)
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2);
-
- if (err==ZIP_OK)
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4);
-
- if (err==ZIP_OK)
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */
- if (err==ZIP_OK)
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */
- if (err==ZIP_OK)
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */
-
- if (err==ZIP_OK)
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2);
-
- if (err==ZIP_OK)
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield_local,2);
-
- if ((err==ZIP_OK) && (size_filename>0))
- if (ZWRITE(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename)
- err = ZIP_ERRNO;
-
- if ((err==ZIP_OK) && (size_extrafield_local>0))
- if (ZWRITE(zi->z_filefunc,zi->filestream,extrafield_local,size_extrafield_local)
- !=size_extrafield_local)
- err = ZIP_ERRNO;
-
- zi->ci.stream.avail_in = (uInt)0;
- zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;
- zi->ci.stream.next_out = zi->ci.buffered_data;
- zi->ci.stream.total_in = 0;
- zi->ci.stream.total_out = 0;
-
- if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
- {
- zi->ci.stream.zalloc = (alloc_func)0;
- zi->ci.stream.zfree = (free_func)0;
- zi->ci.stream.opaque = (voidpf)0;
-
- if (windowBits>0)
- windowBits = -windowBits;
-
- err = deflateInit2(&zi->ci.stream, level,
- Z_DEFLATED, windowBits, memLevel, strategy);
-
- if (err==Z_OK)
- zi->ci.stream_initialised = 1;
- }
-# ifndef NOCRYPT
- zi->ci.crypt_header_size = 0;
- if ((err==Z_OK) && (password != NULL))
- {
- unsigned char bufHead[RAND_HEAD_LEN];
- unsigned int sizeHead;
- zi->ci.encrypt = 1;
- zi->ci.pcrc_32_tab = get_crc_table();
- /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/
-
- sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting);
- zi->ci.crypt_header_size = sizeHead;
-
- if (ZWRITE(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead)
- err = ZIP_ERRNO;
- }
-# endif
-
- if (err==Z_OK)
- zi->in_opened_file_inzip = 1;
- return err;
-}
-
-extern int ZEXPORT zipOpenNewFileInZip2(file, filename, zipfi,
- extrafield_local, size_extrafield_local,
- extrafield_global, size_extrafield_global,
- comment, method, level, raw)
- zipFile file;
- const char* filename;
- const zip_fileinfo* zipfi;
- const void* extrafield_local;
- uInt size_extrafield_local;
- const void* extrafield_global;
- uInt size_extrafield_global;
- const char* comment;
- int method;
- int level;
- int raw;
-{
- return zipOpenNewFileInZip3 (file, filename, zipfi,
- extrafield_local, size_extrafield_local,
- extrafield_global, size_extrafield_global,
- comment, method, level, raw,
- -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
- NULL, 0);
-}
-
-extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
- extrafield_local, size_extrafield_local,
- extrafield_global, size_extrafield_global,
- comment, method, level)
- zipFile file;
- const char* filename;
- const zip_fileinfo* zipfi;
- const void* extrafield_local;
- uInt size_extrafield_local;
- const void* extrafield_global;
- uInt size_extrafield_global;
- const char* comment;
- int method;
- int level;
-{
- return zipOpenNewFileInZip2 (file, filename, zipfi,
- extrafield_local, size_extrafield_local,
- extrafield_global, size_extrafield_global,
- comment, method, level, 0);
-}
-
-local int zipFlushWriteBuffer(zi)
- zip_internal* zi;
-{
- int err=ZIP_OK;
-
- if (zi->ci.encrypt != 0)
- {
-#ifndef NOCRYPT
- uInt i;
- int t;
- for (i=0;i<zi->ci.pos_in_buffered_data;i++)
- zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab,
- zi->ci.buffered_data[i],t);
-#endif
- }
- if (ZWRITE(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data)
- !=zi->ci.pos_in_buffered_data)
- err = ZIP_ERRNO;
- zi->ci.pos_in_buffered_data = 0;
- return err;
-}
-
-extern int ZEXPORT zipWriteInFileInZip (file, buf, len)
- zipFile file;
- const void* buf;
- unsigned len;
-{
- zip_internal* zi;
- int err=ZIP_OK;
-
- if (file == NULL)
- return ZIP_PARAMERROR;
- zi = (zip_internal*)file;
-
- if (zi->in_opened_file_inzip == 0)
- return ZIP_PARAMERROR;
-
- zi->ci.stream.next_in = (void*)buf;
- zi->ci.stream.avail_in = len;
- zi->ci.crc32 = crc32(zi->ci.crc32,buf,len);
-
- while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
- {
- if (zi->ci.stream.avail_out == 0)
- {
- if (zipFlushWriteBuffer(zi) == ZIP_ERRNO)
- err = ZIP_ERRNO;
- zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;
- zi->ci.stream.next_out = zi->ci.buffered_data;
- }
-
-
- if(err != ZIP_OK)
- break;
-
- if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
- {
- uLong uTotalOutBefore = zi->ci.stream.total_out;
- err=deflate(&zi->ci.stream, Z_NO_FLUSH);
- zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ;
-
- }
- else
- {
- uInt copy_this,i;
- if (zi->ci.stream.avail_in < zi->ci.stream.avail_out)
- copy_this = zi->ci.stream.avail_in;
- else
- copy_this = zi->ci.stream.avail_out;
- for (i=0;i<copy_this;i++)
- *(((char*)zi->ci.stream.next_out)+i) =
- *(((const char*)zi->ci.stream.next_in)+i);
- {
- zi->ci.stream.avail_in -= copy_this;
- zi->ci.stream.avail_out-= copy_this;
- zi->ci.stream.next_in+= copy_this;
- zi->ci.stream.next_out+= copy_this;
- zi->ci.stream.total_in+= copy_this;
- zi->ci.stream.total_out+= copy_this;
- zi->ci.pos_in_buffered_data += copy_this;
- }
- }
- }
-
- return err;
-}
-
-extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32)
- zipFile file;
- uLong uncompressed_size;
- uLong crc32;
-{
- zip_internal* zi;
- uLong compressed_size;
- int err=ZIP_OK;
-
- if (file == NULL)
- return ZIP_PARAMERROR;
- zi = (zip_internal*)file;
-
- if (zi->in_opened_file_inzip == 0)
- return ZIP_PARAMERROR;
- zi->ci.stream.avail_in = 0;
-
- if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
- while (err==ZIP_OK)
- {
- uLong uTotalOutBefore;
- if (zi->ci.stream.avail_out == 0)
- {
- if (zipFlushWriteBuffer(zi) == ZIP_ERRNO)
- err = ZIP_ERRNO;
- zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;
- zi->ci.stream.next_out = zi->ci.buffered_data;
- }
- uTotalOutBefore = zi->ci.stream.total_out;
- err=deflate(&zi->ci.stream, Z_FINISH);
- zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ;
- }
-
- if (err==Z_STREAM_END)
- err=ZIP_OK; /* this is normal */
-
- if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK))
- if (zipFlushWriteBuffer(zi)==ZIP_ERRNO)
- err = ZIP_ERRNO;
-
- if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
- {
- err=deflateEnd(&zi->ci.stream);
- zi->ci.stream_initialised = 0;
- }
-
- if (!zi->ci.raw)
- {
- crc32 = (uLong)zi->ci.crc32;
- uncompressed_size = (uLong)zi->ci.stream.total_in;
- }
- compressed_size = (uLong)zi->ci.stream.total_out;
-# ifndef NOCRYPT
- compressed_size += zi->ci.crypt_header_size;
-# endif
-
- ziplocal_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/
- ziplocal_putValue_inmemory(zi->ci.central_header+20,
- compressed_size,4); /*compr size*/
- if (zi->ci.stream.data_type == Z_ASCII)
- ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2);
- ziplocal_putValue_inmemory(zi->ci.central_header+24,
- uncompressed_size,4); /*uncompr size*/
-
- if (err==ZIP_OK)
- err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header,
- (uLong)zi->ci.size_centralheader);
- free(zi->ci.central_header);
-
- if (err==ZIP_OK)
- {
- long cur_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream);
- if (ZSEEK(zi->z_filefunc,zi->filestream,
- zi->ci.pos_local_header + 14,ZLIB_FILEFUNC_SEEK_SET)!=0)
- err = ZIP_ERRNO;
-
- if (err==ZIP_OK)
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */
-
- if (err==ZIP_OK) /* compressed size, unknown */
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4);
-
- if (err==ZIP_OK) /* uncompressed size, unknown */
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,uncompressed_size,4);
-
- if (ZSEEK(zi->z_filefunc,zi->filestream,
- cur_pos_inzip,ZLIB_FILEFUNC_SEEK_SET)!=0)
- err = ZIP_ERRNO;
- }
-
- zi->number_entry ++;
- zi->in_opened_file_inzip = 0;
-
- return err;
-}
-
-extern int ZEXPORT zipCloseFileInZip (file)
- zipFile file;
-{
- return zipCloseFileInZipRaw (file,0,0);
-}
-
-extern int ZEXPORT zipClose (file, global_comment)
- zipFile file;
- const char* global_comment;
-{
- zip_internal* zi;
- int err = 0;
- uLong size_centraldir = 0;
- uLong centraldir_pos_inzip;
- uInt size_global_comment;
- if (file == NULL)
- return ZIP_PARAMERROR;
- zi = (zip_internal*)file;
-
- if (zi->in_opened_file_inzip == 1)
- {
- err = zipCloseFileInZip (file);
- }
-
-#ifndef NO_ADDFILEINEXISTINGZIP
- if (global_comment==NULL)
- global_comment = zi->globalcomment;
-#endif
- if (global_comment==NULL)
- size_global_comment = 0;
- else
- size_global_comment = (uInt)strlen(global_comment);
-
- centraldir_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream);
- if (err==ZIP_OK)
- {
- linkedlist_datablock_internal* ldi = zi->central_dir.first_block ;
- while (ldi!=NULL)
- {
- if ((err==ZIP_OK) && (ldi->filled_in_this_block>0))
- if (ZWRITE(zi->z_filefunc,zi->filestream,
- ldi->data,ldi->filled_in_this_block)
- !=ldi->filled_in_this_block )
- err = ZIP_ERRNO;
-
- size_centraldir += ldi->filled_in_this_block;
- ldi = ldi->next_datablock;
- }
- }
- free_datablock(zi->central_dir.first_block);
-
- if (err==ZIP_OK) /* Magic End */
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4);
-
- if (err==ZIP_OK) /* number of this disk */
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2);
-
- if (err==ZIP_OK) /* number of the disk with the start of the central directory */
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2);
-
- if (err==ZIP_OK) /* total number of entries in the central dir on this disk */
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2);
-
- if (err==ZIP_OK) /* total number of entries in the central dir */
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2);
-
- if (err==ZIP_OK) /* size of the central directory */
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4);
-
- if (err==ZIP_OK) /* offset of start of central directory with respect to the
- starting disk number */
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,
- (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4);
-
- if (err==ZIP_OK) /* zipfile comment length */
- err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_global_comment,2);
-
- if ((err==ZIP_OK) && (size_global_comment>0))
- if (ZWRITE(zi->z_filefunc,zi->filestream,
- global_comment,size_global_comment) != size_global_comment)
- err = ZIP_ERRNO;
-
- if (ZCLOSE(zi->z_filefunc,zi->filestream) != 0)
- if (err == ZIP_OK)
- err = ZIP_ERRNO;
-
-#ifndef NO_ADDFILEINEXISTINGZIP
- TRYFREE(zi->globalcomment);
-#endif
- TRYFREE(zi);
-
- return err;
-}
diff --git a/source4/lib/zlib/contrib/minizip/zip.h b/source4/lib/zlib/contrib/minizip/zip.h
deleted file mode 100644
index acacce83b9..0000000000
--- a/source4/lib/zlib/contrib/minizip/zip.h
+++ /dev/null
@@ -1,235 +0,0 @@
-/* zip.h -- IO for compress .zip files using zlib
- Version 1.01e, February 12th, 2005
-
- Copyright (C) 1998-2005 Gilles Vollant
-
- This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
- WinZip, InfoZip tools and compatible.
- Multi volume ZipFile (span) are not supported.
- Encryption compatible with pkzip 2.04g only supported
- Old compressions used by old PKZip 1.x are not supported
-
- For uncompress .zip file, look at unzip.h
-
-
- I WAIT FEEDBACK at mail info@winimage.com
- Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
-
- Condition of use and distribution are the same than zlib :
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
-
-*/
-
-/* for more info about .ZIP format, see
- http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
- http://www.info-zip.org/pub/infozip/doc/
- PkWare has also a specification at :
- ftp://ftp.pkware.com/probdesc.zip
-*/
-
-#ifndef _zip_H
-#define _zip_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _ZLIB_H
-#include "zlib.h"
-#endif
-
-#ifndef _ZLIBIOAPI_H
-#include "ioapi.h"
-#endif
-
-#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
-/* like the STRICT of WIN32, we define a pointer that cannot be converted
- from (void*) without cast */
-typedef struct TagzipFile__ { int unused; } zipFile__;
-typedef zipFile__ *zipFile;
-#else
-typedef voidp zipFile;
-#endif
-
-#define ZIP_OK (0)
-#define ZIP_EOF (0)
-#define ZIP_ERRNO (Z_ERRNO)
-#define ZIP_PARAMERROR (-102)
-#define ZIP_BADZIPFILE (-103)
-#define ZIP_INTERNALERROR (-104)
-
-#ifndef DEF_MEM_LEVEL
-# if MAX_MEM_LEVEL >= 8
-# define DEF_MEM_LEVEL 8
-# else
-# define DEF_MEM_LEVEL MAX_MEM_LEVEL
-# endif
-#endif
-/* default memLevel */
-
-/* tm_zip contain date/time info */
-typedef struct tm_zip_s
-{
- uInt tm_sec; /* seconds after the minute - [0,59] */
- uInt tm_min; /* minutes after the hour - [0,59] */
- uInt tm_hour; /* hours since midnight - [0,23] */
- uInt tm_mday; /* day of the month - [1,31] */
- uInt tm_mon; /* months since January - [0,11] */
- uInt tm_year; /* years - [1980..2044] */
-} tm_zip;
-
-typedef struct
-{
- tm_zip tmz_date; /* date in understandable format */
- uLong dosDate; /* if dos_date == 0, tmu_date is used */
-/* uLong flag; */ /* general purpose bit flag 2 bytes */
-
- uLong internal_fa; /* internal file attributes 2 bytes */
- uLong external_fa; /* external file attributes 4 bytes */
-} zip_fileinfo;
-
-typedef const char* zipcharpc;
-
-
-#define APPEND_STATUS_CREATE (0)
-#define APPEND_STATUS_CREATEAFTER (1)
-#define APPEND_STATUS_ADDINZIP (2)
-
-extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
-/*
- Create a zipfile.
- pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
- an Unix computer "zlib/zlib113.zip".
- if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
- will be created at the end of the file.
- (useful if the file contain a self extractor code)
- if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
- add files in existing zip (be sure you don't add file that doesn't exist)
- If the zipfile cannot be opened, the return value is NULL.
- Else, the return value is a zipFile Handle, usable with other function
- of this zip package.
-*/
-
-/* Note : there is no delete function into a zipfile.
- If you want delete file into a zipfile, you must open a zipfile, and create another
- Of couse, you can use RAW reading and writing to copy the file you did not want delte
-*/
-
-extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
- int append,
- zipcharpc* globalcomment,
- zlib_filefunc_def* pzlib_filefunc_def));
-
-extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
- const char* filename,
- const zip_fileinfo* zipfi,
- const void* extrafield_local,
- uInt size_extrafield_local,
- const void* extrafield_global,
- uInt size_extrafield_global,
- const char* comment,
- int method,
- int level));
-/*
- Open a file in the ZIP for writing.
- filename : the filename in zip (if NULL, '-' without quote will be used
- *zipfi contain supplemental information
- if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
- contains the extrafield data the the local header
- if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
- contains the extrafield data the the local header
- if comment != NULL, comment contain the comment string
- method contain the compression method (0 for store, Z_DEFLATED for deflate)
- level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
-*/
-
-
-extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
- const char* filename,
- const zip_fileinfo* zipfi,
- const void* extrafield_local,
- uInt size_extrafield_local,
- const void* extrafield_global,
- uInt size_extrafield_global,
- const char* comment,
- int method,
- int level,
- int raw));
-
-/*
- Same than zipOpenNewFileInZip, except if raw=1, we write raw file
- */
-
-extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
- const char* filename,
- const zip_fileinfo* zipfi,
- const void* extrafield_local,
- uInt size_extrafield_local,
- const void* extrafield_global,
- uInt size_extrafield_global,
- const char* comment,
- int method,
- int level,
- int raw,
- int windowBits,
- int memLevel,
- int strategy,
- const char* password,
- uLong crcForCtypting));
-
-/*
- Same than zipOpenNewFileInZip2, except
- windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
- password : crypting password (NULL for no crypting)
- crcForCtypting : crc of file to compress (needed for crypting)
- */
-
-
-extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
- const void* buf,
- unsigned len));
-/*
- Write data in the zipfile
-*/
-
-extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
-/*
- Close the current file in the zipfile
-*/
-
-extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
- uLong uncompressed_size,
- uLong crc32));
-/*
- Close the current file in the zipfile, for fiel opened with
- parameter raw=1 in zipOpenNewFileInZip2
- uncompressed_size and crc32 are value for the uncompressed size
-*/
-
-extern int ZEXPORT zipClose OF((zipFile file,
- const char* global_comment));
-/*
- Close the zipfile
-*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _zip_H */
diff --git a/source4/lib/zlib/contrib/pascal/example.pas b/source4/lib/zlib/contrib/pascal/example.pas
deleted file mode 100644
index 5518b36a73..0000000000
--- a/source4/lib/zlib/contrib/pascal/example.pas
+++ /dev/null
@@ -1,599 +0,0 @@
-(* example.c -- usage example of the zlib compression library
- * Copyright (C) 1995-2003 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- *
- * Pascal translation
- * Copyright (C) 1998 by Jacques Nomssi Nzali.
- * For conditions of distribution and use, see copyright notice in readme.txt
- *
- * Adaptation to the zlibpas interface
- * Copyright (C) 2003 by Cosmin Truta.
- * For conditions of distribution and use, see copyright notice in readme.txt
- *)
-
-program example;
-
-{$DEFINE TEST_COMPRESS}
-{DO NOT $DEFINE TEST_GZIO}
-{$DEFINE TEST_DEFLATE}
-{$DEFINE TEST_INFLATE}
-{$DEFINE TEST_FLUSH}
-{$DEFINE TEST_SYNC}
-{$DEFINE TEST_DICT}
-
-uses SysUtils, zlibpas;
-
-const TESTFILE = 'foo.gz';
-
-(* "hello world" would be more standard, but the repeated "hello"
- * stresses the compression code better, sorry...
- *)
-const hello: PChar = 'hello, hello!';
-
-const dictionary: PChar = 'hello';
-
-var dictId: LongInt; (* Adler32 value of the dictionary *)
-
-procedure CHECK_ERR(err: Integer; msg: String);
-begin
- if err <> Z_OK then
- begin
- WriteLn(msg, ' error: ', err);
- Halt(1);
- end;
-end;
-
-procedure EXIT_ERR(const msg: String);
-begin
- WriteLn('Error: ', msg);
- Halt(1);
-end;
-
-(* ===========================================================================
- * Test compress and uncompress
- *)
-{$IFDEF TEST_COMPRESS}
-procedure test_compress(compr: Pointer; comprLen: LongInt;
- uncompr: Pointer; uncomprLen: LongInt);
-var err: Integer;
- len: LongInt;
-begin
- len := StrLen(hello)+1;
-
- err := compress(compr, comprLen, hello, len);
- CHECK_ERR(err, 'compress');
-
- StrCopy(PChar(uncompr), 'garbage');
-
- err := uncompress(uncompr, uncomprLen, compr, comprLen);
- CHECK_ERR(err, 'uncompress');
-
- if StrComp(PChar(uncompr), hello) <> 0 then
- EXIT_ERR('bad uncompress')
- else
- WriteLn('uncompress(): ', PChar(uncompr));
-end;
-{$ENDIF}
-
-(* ===========================================================================
- * Test read/write of .gz files
- *)
-{$IFDEF TEST_GZIO}
-procedure test_gzio(const fname: PChar; (* compressed file name *)
- uncompr: Pointer;
- uncomprLen: LongInt);
-var err: Integer;
- len: Integer;
- zfile: gzFile;
- pos: LongInt;
-begin
- len := StrLen(hello)+1;
-
- zfile := gzopen(fname, 'wb');
- if zfile = NIL then
- begin
- WriteLn('gzopen error');
- Halt(1);
- end;
- gzputc(zfile, 'h');
- if gzputs(zfile, 'ello') <> 4 then
- begin
- WriteLn('gzputs err: ', gzerror(zfile, err));
- Halt(1);
- end;
- {$IFDEF GZ_FORMAT_STRING}
- if gzprintf(zfile, ', %s!', 'hello') <> 8 then
- begin
- WriteLn('gzprintf err: ', gzerror(zfile, err));
- Halt(1);
- end;
- {$ELSE}
- if gzputs(zfile, ', hello!') <> 8 then
- begin
- WriteLn('gzputs err: ', gzerror(zfile, err));
- Halt(1);
- end;
- {$ENDIF}
- gzseek(zfile, 1, SEEK_CUR); (* add one zero byte *)
- gzclose(zfile);
-
- zfile := gzopen(fname, 'rb');
- if zfile = NIL then
- begin
- WriteLn('gzopen error');
- Halt(1);
- end;
-
- StrCopy(PChar(uncompr), 'garbage');
-
- if gzread(zfile, uncompr, uncomprLen) <> len then
- begin
- WriteLn('gzread err: ', gzerror(zfile, err));
- Halt(1);
- end;
- if StrComp(PChar(uncompr), hello) <> 0 then
- begin
- WriteLn('bad gzread: ', PChar(uncompr));
- Halt(1);
- end
- else
- WriteLn('gzread(): ', PChar(uncompr));
-
- pos := gzseek(zfile, -8, SEEK_CUR);
- if (pos <> 6) or (gztell(zfile) <> pos) then
- begin
- WriteLn('gzseek error, pos=', pos, ', gztell=', gztell(zfile));
- Halt(1);
- end;
-
- if gzgetc(zfile) <> ' ' then
- begin
- WriteLn('gzgetc error');
- Halt(1);
- end;
-
- if gzungetc(' ', zfile) <> ' ' then
- begin
- WriteLn('gzungetc error');
- Halt(1);
- end;
-
- gzgets(zfile, PChar(uncompr), uncomprLen);
- uncomprLen := StrLen(PChar(uncompr));
- if uncomprLen <> 7 then (* " hello!" *)
- begin
- WriteLn('gzgets err after gzseek: ', gzerror(zfile, err));
- Halt(1);
- end;
- if StrComp(PChar(uncompr), hello + 6) <> 0 then
- begin
- WriteLn('bad gzgets after gzseek');
- Halt(1);
- end
- else
- WriteLn('gzgets() after gzseek: ', PChar(uncompr));
-
- gzclose(zfile);
-end;
-{$ENDIF}
-
-(* ===========================================================================
- * Test deflate with small buffers
- *)
-{$IFDEF TEST_DEFLATE}
-procedure test_deflate(compr: Pointer; comprLen: LongInt);
-var c_stream: z_stream; (* compression stream *)
- err: Integer;
- len: LongInt;
-begin
- len := StrLen(hello)+1;
-
- c_stream.zalloc := NIL;
- c_stream.zfree := NIL;
- c_stream.opaque := NIL;
-
- err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION);
- CHECK_ERR(err, 'deflateInit');
-
- c_stream.next_in := hello;
- c_stream.next_out := compr;
-
- while (c_stream.total_in <> len) and
- (c_stream.total_out < comprLen) do
- begin
- c_stream.avail_out := 1; { force small buffers }
- c_stream.avail_in := 1;
- err := deflate(c_stream, Z_NO_FLUSH);
- CHECK_ERR(err, 'deflate');
- end;
-
- (* Finish the stream, still forcing small buffers: *)
- while TRUE do
- begin
- c_stream.avail_out := 1;
- err := deflate(c_stream, Z_FINISH);
- if err = Z_STREAM_END then
- break;
- CHECK_ERR(err, 'deflate');
- end;
-
- err := deflateEnd(c_stream);
- CHECK_ERR(err, 'deflateEnd');
-end;
-{$ENDIF}
-
-(* ===========================================================================
- * Test inflate with small buffers
- *)
-{$IFDEF TEST_INFLATE}
-procedure test_inflate(compr: Pointer; comprLen : LongInt;
- uncompr: Pointer; uncomprLen : LongInt);
-var err: Integer;
- d_stream: z_stream; (* decompression stream *)
-begin
- StrCopy(PChar(uncompr), 'garbage');
-
- d_stream.zalloc := NIL;
- d_stream.zfree := NIL;
- d_stream.opaque := NIL;
-
- d_stream.next_in := compr;
- d_stream.avail_in := 0;
- d_stream.next_out := uncompr;
-
- err := inflateInit(d_stream);
- CHECK_ERR(err, 'inflateInit');
-
- while (d_stream.total_out < uncomprLen) and
- (d_stream.total_in < comprLen) do
- begin
- d_stream.avail_out := 1; (* force small buffers *)
- d_stream.avail_in := 1;
- err := inflate(d_stream, Z_NO_FLUSH);
- if err = Z_STREAM_END then
- break;
- CHECK_ERR(err, 'inflate');
- end;
-
- err := inflateEnd(d_stream);
- CHECK_ERR(err, 'inflateEnd');
-
- if StrComp(PChar(uncompr), hello) <> 0 then
- EXIT_ERR('bad inflate')
- else
- WriteLn('inflate(): ', PChar(uncompr));
-end;
-{$ENDIF}
-
-(* ===========================================================================
- * Test deflate with large buffers and dynamic change of compression level
- *)
-{$IFDEF TEST_DEFLATE}
-procedure test_large_deflate(compr: Pointer; comprLen: LongInt;
- uncompr: Pointer; uncomprLen: LongInt);
-var c_stream: z_stream; (* compression stream *)
- err: Integer;
-begin
- c_stream.zalloc := NIL;
- c_stream.zfree := NIL;
- c_stream.opaque := NIL;
-
- err := deflateInit(c_stream, Z_BEST_SPEED);
- CHECK_ERR(err, 'deflateInit');
-
- c_stream.next_out := compr;
- c_stream.avail_out := Integer(comprLen);
-
- (* At this point, uncompr is still mostly zeroes, so it should compress
- * very well:
- *)
- c_stream.next_in := uncompr;
- c_stream.avail_in := Integer(uncomprLen);
- err := deflate(c_stream, Z_NO_FLUSH);
- CHECK_ERR(err, 'deflate');
- if c_stream.avail_in <> 0 then
- EXIT_ERR('deflate not greedy');
-
- (* Feed in already compressed data and switch to no compression: *)
- deflateParams(c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
- c_stream.next_in := compr;
- c_stream.avail_in := Integer(comprLen div 2);
- err := deflate(c_stream, Z_NO_FLUSH);
- CHECK_ERR(err, 'deflate');
-
- (* Switch back to compressing mode: *)
- deflateParams(c_stream, Z_BEST_COMPRESSION, Z_FILTERED);
- c_stream.next_in := uncompr;
- c_stream.avail_in := Integer(uncomprLen);
- err := deflate(c_stream, Z_NO_FLUSH);
- CHECK_ERR(err, 'deflate');
-
- err := deflate(c_stream, Z_FINISH);
- if err <> Z_STREAM_END then
- EXIT_ERR('deflate should report Z_STREAM_END');
-
- err := deflateEnd(c_stream);
- CHECK_ERR(err, 'deflateEnd');
-end;
-{$ENDIF}
-
-(* ===========================================================================
- * Test inflate with large buffers
- *)
-{$IFDEF TEST_INFLATE}
-procedure test_large_inflate(compr: Pointer; comprLen: LongInt;
- uncompr: Pointer; uncomprLen: LongInt);
-var err: Integer;
- d_stream: z_stream; (* decompression stream *)
-begin
- StrCopy(PChar(uncompr), 'garbage');
-
- d_stream.zalloc := NIL;
- d_stream.zfree := NIL;
- d_stream.opaque := NIL;
-
- d_stream.next_in := compr;
- d_stream.avail_in := Integer(comprLen);
-
- err := inflateInit(d_stream);
- CHECK_ERR(err, 'inflateInit');
-
- while TRUE do
- begin
- d_stream.next_out := uncompr; (* discard the output *)
- d_stream.avail_out := Integer(uncomprLen);
- err := inflate(d_stream, Z_NO_FLUSH);
- if err = Z_STREAM_END then
- break;
- CHECK_ERR(err, 'large inflate');
- end;
-
- err := inflateEnd(d_stream);
- CHECK_ERR(err, 'inflateEnd');
-
- if d_stream.total_out <> 2 * uncomprLen + comprLen div 2 then
- begin
- WriteLn('bad large inflate: ', d_stream.total_out);
- Halt(1);
- end
- else
- WriteLn('large_inflate(): OK');
-end;
-{$ENDIF}
-
-(* ===========================================================================
- * Test deflate with full flush
- *)
-{$IFDEF TEST_FLUSH}
-procedure test_flush(compr: Pointer; var comprLen : LongInt);
-var c_stream: z_stream; (* compression stream *)
- err: Integer;
- len: Integer;
-begin
- len := StrLen(hello)+1;
-
- c_stream.zalloc := NIL;
- c_stream.zfree := NIL;
- c_stream.opaque := NIL;
-
- err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION);
- CHECK_ERR(err, 'deflateInit');
-
- c_stream.next_in := hello;
- c_stream.next_out := compr;
- c_stream.avail_in := 3;
- c_stream.avail_out := Integer(comprLen);
- err := deflate(c_stream, Z_FULL_FLUSH);
- CHECK_ERR(err, 'deflate');
-
- Inc(PByteArray(compr)^[3]); (* force an error in first compressed block *)
- c_stream.avail_in := len - 3;
-
- err := deflate(c_stream, Z_FINISH);
- if err <> Z_STREAM_END then
- CHECK_ERR(err, 'deflate');
-
- err := deflateEnd(c_stream);
- CHECK_ERR(err, 'deflateEnd');
-
- comprLen := c_stream.total_out;
-end;
-{$ENDIF}
-
-(* ===========================================================================
- * Test inflateSync()
- *)
-{$IFDEF TEST_SYNC}
-procedure test_sync(compr: Pointer; comprLen: LongInt;
- uncompr: Pointer; uncomprLen : LongInt);
-var err: Integer;
- d_stream: z_stream; (* decompression stream *)
-begin
- StrCopy(PChar(uncompr), 'garbage');
-
- d_stream.zalloc := NIL;
- d_stream.zfree := NIL;
- d_stream.opaque := NIL;
-
- d_stream.next_in := compr;
- d_stream.avail_in := 2; (* just read the zlib header *)
-
- err := inflateInit(d_stream);
- CHECK_ERR(err, 'inflateInit');
-
- d_stream.next_out := uncompr;
- d_stream.avail_out := Integer(uncomprLen);
-
- inflate(d_stream, Z_NO_FLUSH);
- CHECK_ERR(err, 'inflate');
-
- d_stream.avail_in := Integer(comprLen-2); (* read all compressed data *)
- err := inflateSync(d_stream); (* but skip the damaged part *)
- CHECK_ERR(err, 'inflateSync');
-
- err := inflate(d_stream, Z_FINISH);
- if err <> Z_DATA_ERROR then
- EXIT_ERR('inflate should report DATA_ERROR');
- (* Because of incorrect adler32 *)
-
- err := inflateEnd(d_stream);
- CHECK_ERR(err, 'inflateEnd');
-
- WriteLn('after inflateSync(): hel', PChar(uncompr));
-end;
-{$ENDIF}
-
-(* ===========================================================================
- * Test deflate with preset dictionary
- *)
-{$IFDEF TEST_DICT}
-procedure test_dict_deflate(compr: Pointer; comprLen: LongInt);
-var c_stream: z_stream; (* compression stream *)
- err: Integer;
-begin
- c_stream.zalloc := NIL;
- c_stream.zfree := NIL;
- c_stream.opaque := NIL;
-
- err := deflateInit(c_stream, Z_BEST_COMPRESSION);
- CHECK_ERR(err, 'deflateInit');
-
- err := deflateSetDictionary(c_stream, dictionary, StrLen(dictionary));
- CHECK_ERR(err, 'deflateSetDictionary');
-
- dictId := c_stream.adler;
- c_stream.next_out := compr;
- c_stream.avail_out := Integer(comprLen);
-
- c_stream.next_in := hello;
- c_stream.avail_in := StrLen(hello)+1;
-
- err := deflate(c_stream, Z_FINISH);
- if err <> Z_STREAM_END then
- EXIT_ERR('deflate should report Z_STREAM_END');
-
- err := deflateEnd(c_stream);
- CHECK_ERR(err, 'deflateEnd');
-end;
-{$ENDIF}
-
-(* ===========================================================================
- * Test inflate with a preset dictionary
- *)
-{$IFDEF TEST_DICT}
-procedure test_dict_inflate(compr: Pointer; comprLen: LongInt;
- uncompr: Pointer; uncomprLen: LongInt);
-var err: Integer;
- d_stream: z_stream; (* decompression stream *)
-begin
- StrCopy(PChar(uncompr), 'garbage');
-
- d_stream.zalloc := NIL;
- d_stream.zfree := NIL;
- d_stream.opaque := NIL;
-
- d_stream.next_in := compr;
- d_stream.avail_in := Integer(comprLen);
-
- err := inflateInit(d_stream);
- CHECK_ERR(err, 'inflateInit');
-
- d_stream.next_out := uncompr;
- d_stream.avail_out := Integer(uncomprLen);
-
- while TRUE do
- begin
- err := inflate(d_stream, Z_NO_FLUSH);
- if err = Z_STREAM_END then
- break;
- if err = Z_NEED_DICT then
- begin
- if d_stream.adler <> dictId then
- EXIT_ERR('unexpected dictionary');
- err := inflateSetDictionary(d_stream, dictionary, StrLen(dictionary));
- end;
- CHECK_ERR(err, 'inflate with dict');
- end;
-
- err := inflateEnd(d_stream);
- CHECK_ERR(err, 'inflateEnd');
-
- if StrComp(PChar(uncompr), hello) <> 0 then
- EXIT_ERR('bad inflate with dict')
- else
- WriteLn('inflate with dictionary: ', PChar(uncompr));
-end;
-{$ENDIF}
-
-var compr, uncompr: Pointer;
- comprLen, uncomprLen: LongInt;
-
-begin
- if zlibVersion^ <> ZLIB_VERSION[1] then
- EXIT_ERR('Incompatible zlib version');
-
- WriteLn('zlib version: ', zlibVersion);
- WriteLn('zlib compile flags: ', Format('0x%x', [zlibCompileFlags]));
-
- comprLen := 10000 * SizeOf(Integer); (* don't overflow on MSDOS *)
- uncomprLen := comprLen;
- GetMem(compr, comprLen);
- GetMem(uncompr, uncomprLen);
- if (compr = NIL) or (uncompr = NIL) then
- EXIT_ERR('Out of memory');
- (* compr and uncompr are cleared to avoid reading uninitialized
- * data and to ensure that uncompr compresses well.
- *)
- FillChar(compr^, comprLen, 0);
- FillChar(uncompr^, uncomprLen, 0);
-
- {$IFDEF TEST_COMPRESS}
- WriteLn('** Testing compress');
- test_compress(compr, comprLen, uncompr, uncomprLen);
- {$ENDIF}
-
- {$IFDEF TEST_GZIO}
- WriteLn('** Testing gzio');
- if ParamCount >= 1 then
- test_gzio(ParamStr(1), uncompr, uncomprLen)
- else
- test_gzio(TESTFILE, uncompr, uncomprLen);
- {$ENDIF}
-
- {$IFDEF TEST_DEFLATE}
- WriteLn('** Testing deflate with small buffers');
- test_deflate(compr, comprLen);
- {$ENDIF}
- {$IFDEF TEST_INFLATE}
- WriteLn('** Testing inflate with small buffers');
- test_inflate(compr, comprLen, uncompr, uncomprLen);
- {$ENDIF}
-
- {$IFDEF TEST_DEFLATE}
- WriteLn('** Testing deflate with large buffers');
- test_large_deflate(compr, comprLen, uncompr, uncomprLen);
- {$ENDIF}
- {$IFDEF TEST_INFLATE}
- WriteLn('** Testing inflate with large buffers');
- test_large_inflate(compr, comprLen, uncompr, uncomprLen);
- {$ENDIF}
-
- {$IFDEF TEST_FLUSH}
- WriteLn('** Testing deflate with full flush');
- test_flush(compr, comprLen);
- {$ENDIF}
- {$IFDEF TEST_SYNC}
- WriteLn('** Testing inflateSync');
- test_sync(compr, comprLen, uncompr, uncomprLen);
- {$ENDIF}
- comprLen := uncomprLen;
-
- {$IFDEF TEST_DICT}
- WriteLn('** Testing deflate and inflate with preset dictionary');
- test_dict_deflate(compr, comprLen);
- test_dict_inflate(compr, comprLen, uncompr, uncomprLen);
- {$ENDIF}
-
- FreeMem(compr, comprLen);
- FreeMem(uncompr, uncomprLen);
-end.
diff --git a/source4/lib/zlib/contrib/pascal/readme.txt b/source4/lib/zlib/contrib/pascal/readme.txt
deleted file mode 100644
index 60e87c8a33..0000000000
--- a/source4/lib/zlib/contrib/pascal/readme.txt
+++ /dev/null
@@ -1,76 +0,0 @@
-
-This directory contains a Pascal (Delphi, Kylix) interface to the
-zlib data compression library.
-
-
-Directory listing
-=================
-
-zlibd32.mak makefile for Borland C++
-example.pas usage example of zlib
-zlibpas.pas the Pascal interface to zlib
-readme.txt this file
-
-
-Compatibility notes
-===================
-
-- Although the name "zlib" would have been more normal for the
- zlibpas unit, this name is already taken by Borland's ZLib unit.
- This is somehow unfortunate, because that unit is not a genuine
- interface to the full-fledged zlib functionality, but a suite of
- class wrappers around zlib streams. Other essential features,
- such as checksums, are missing.
- It would have been more appropriate for that unit to have a name
- like "ZStreams", or something similar.
-
-- The C and zlib-supplied types int, uInt, long, uLong, etc. are
- translated directly into Pascal types of similar sizes (Integer,
- LongInt, etc.), to avoid namespace pollution. In particular,
- there is no conversion of unsigned int into a Pascal unsigned
- integer. The Word type is non-portable and has the same size
- (16 bits) both in a 16-bit and in a 32-bit environment, unlike
- Integer. Even if there is a 32-bit Cardinal type, there is no
- real need for unsigned int in zlib under a 32-bit environment.
-
-- Except for the callbacks, the zlib function interfaces are
- assuming the calling convention normally used in Pascal
- (__pascal for DOS and Windows16, __fastcall for Windows32).
- Since the cdecl keyword is used, the old Turbo Pascal does
- not work with this interface.
-
-- The gz* function interfaces are not translated, to avoid
- interfacing problems with the C runtime library. Besides,
- gzprintf(gzFile file, const char *format, ...)
- cannot be translated into Pascal.
-
-
-Legal issues
-============
-
-The zlibpas interface is:
- Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler.
- Copyright (C) 1998 by Bob Dellaca.
- Copyright (C) 2003 by Cosmin Truta.
-
-The example program is:
- Copyright (C) 1995-2003 by Jean-loup Gailly.
- Copyright (C) 1998,1999,2000 by Jacques Nomssi Nzali.
- Copyright (C) 2003 by Cosmin Truta.
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the author be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
diff --git a/source4/lib/zlib/contrib/pascal/zlibd32.mak b/source4/lib/zlib/contrib/pascal/zlibd32.mak
deleted file mode 100644
index 88fafa0b14..0000000000
--- a/source4/lib/zlib/contrib/pascal/zlibd32.mak
+++ /dev/null
@@ -1,93 +0,0 @@
-# Makefile for zlib
-# For use with Delphi and C++ Builder under Win32
-# Updated for zlib 1.2.x by Cosmin Truta
-
-# ------------ Borland C++ ------------
-
-# This project uses the Delphi (fastcall/register) calling convention:
-LOC = -DZEXPORT=__fastcall -DZEXPORTVA=__cdecl
-
-CC = bcc32
-LD = bcc32
-AR = tlib
-# do not use "-pr" in CFLAGS
-CFLAGS = -a -d -k- -O2 $(LOC)
-LDFLAGS =
-
-
-# variables
-ZLIB_LIB = zlib.lib
-
-OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj
-OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj
-OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj
-OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj
-
-
-# targets
-all: $(ZLIB_LIB) example.exe minigzip.exe
-
-.c.obj:
- $(CC) -c $(CFLAGS) $*.c
-
-adler32.obj: adler32.c zlib.h zconf.h
-
-compress.obj: compress.c zlib.h zconf.h
-
-crc32.obj: crc32.c zlib.h zconf.h crc32.h
-
-deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h
-
-gzio.obj: gzio.c zutil.h zlib.h zconf.h
-
-infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h inffixed.h
-
-inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h
-
-inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h inffixed.h
-
-inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h
-
-trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h
-
-uncompr.obj: uncompr.c zlib.h zconf.h
-
-zutil.obj: zutil.c zutil.h zlib.h zconf.h
-
-example.obj: example.c zlib.h zconf.h
-
-minigzip.obj: minigzip.c zlib.h zconf.h
-
-
-# For the sake of the old Borland make,
-# the command line is cut to fit in the MS-DOS 128 byte limit:
-$(ZLIB_LIB): $(OBJ1) $(OBJ2)
- -del $(ZLIB_LIB)
- $(AR) $(ZLIB_LIB) $(OBJP1)
- $(AR) $(ZLIB_LIB) $(OBJP2)
-
-
-# testing
-test: example.exe minigzip.exe
- example
- echo hello world | minigzip | minigzip -d
-
-example.exe: example.obj $(ZLIB_LIB)
- $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB)
-
-minigzip.exe: minigzip.obj $(ZLIB_LIB)
- $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB)
-
-
-# cleanup
-clean:
- -del *.obj
- -del *.exe
- -del *.lib
- -del *.tds
- -del zlib.bak
- -del foo.gz
-
diff --git a/source4/lib/zlib/contrib/pascal/zlibpas.pas b/source4/lib/zlib/contrib/pascal/zlibpas.pas
deleted file mode 100644
index 836848c2b7..0000000000
--- a/source4/lib/zlib/contrib/pascal/zlibpas.pas
+++ /dev/null
@@ -1,236 +0,0 @@
-(* zlibpas -- Pascal interface to the zlib data compression library
- *
- * Copyright (C) 2003 Cosmin Truta.
- * Derived from original sources by Bob Dellaca.
- * For conditions of distribution and use, see copyright notice in readme.txt
- *)
-
-unit zlibpas;
-
-interface
-
-const
- ZLIB_VERSION = '1.2.3';
-
-type
- alloc_func = function(opaque: Pointer; items, size: Integer): Pointer;
- cdecl;
- free_func = procedure(opaque, address: Pointer);
- cdecl;
-
- in_func = function(opaque: Pointer; var buf: PByte): Integer;
- cdecl;
- out_func = function(opaque: Pointer; buf: PByte; size: Integer): Integer;
- cdecl;
-
- z_streamp = ^z_stream;
- z_stream = packed record
- next_in: PChar; (* next input byte *)
- avail_in: Integer; (* number of bytes available at next_in *)
- total_in: LongInt; (* total nb of input bytes read so far *)
-
- next_out: PChar; (* next output byte should be put there *)
- avail_out: Integer; (* remaining free space at next_out *)
- total_out: LongInt; (* total nb of bytes output so far *)
-
- msg: PChar; (* last error message, NULL if no error *)
- state: Pointer; (* not visible by applications *)
-
- zalloc: alloc_func; (* used to allocate the internal state *)
- zfree: free_func; (* used to free the internal state *)
- opaque: Pointer; (* private data object passed to zalloc and zfree *)
-
- data_type: Integer; (* best guess about the data type: ascii or binary *)
- adler: LongInt; (* adler32 value of the uncompressed data *)
- reserved: LongInt; (* reserved for future use *)
- end;
-
-(* constants *)
-const
- Z_NO_FLUSH = 0;
- Z_PARTIAL_FLUSH = 1;
- Z_SYNC_FLUSH = 2;
- Z_FULL_FLUSH = 3;
- Z_FINISH = 4;
-
- Z_OK = 0;
- Z_STREAM_END = 1;
- Z_NEED_DICT = 2;
- Z_ERRNO = -1;
- Z_STREAM_ERROR = -2;
- Z_DATA_ERROR = -3;
- Z_MEM_ERROR = -4;
- Z_BUF_ERROR = -5;
- Z_VERSION_ERROR = -6;
-
- Z_NO_COMPRESSION = 0;
- Z_BEST_SPEED = 1;
- Z_BEST_COMPRESSION = 9;
- Z_DEFAULT_COMPRESSION = -1;
-
- Z_FILTERED = 1;
- Z_HUFFMAN_ONLY = 2;
- Z_RLE = 3;
- Z_DEFAULT_STRATEGY = 0;
-
- Z_BINARY = 0;
- Z_ASCII = 1;
- Z_UNKNOWN = 2;
-
- Z_DEFLATED = 8;
-
-(* basic functions *)
-function zlibVersion: PChar;
-function deflateInit(var strm: z_stream; level: Integer): Integer;
-function deflate(var strm: z_stream; flush: Integer): Integer;
-function deflateEnd(var strm: z_stream): Integer;
-function inflateInit(var strm: z_stream): Integer;
-function inflate(var strm: z_stream; flush: Integer): Integer;
-function inflateEnd(var strm: z_stream): Integer;
-
-(* advanced functions *)
-function deflateInit2(var strm: z_stream; level, method, windowBits,
- memLevel, strategy: Integer): Integer;
-function deflateSetDictionary(var strm: z_stream; const dictionary: PChar;
- dictLength: Integer): Integer;
-function deflateCopy(var dest, source: z_stream): Integer;
-function deflateReset(var strm: z_stream): Integer;
-function deflateParams(var strm: z_stream; level, strategy: Integer): Integer;
-function deflateBound(var strm: z_stream; sourceLen: LongInt): LongInt;
-function deflatePrime(var strm: z_stream; bits, value: Integer): Integer;
-function inflateInit2(var strm: z_stream; windowBits: Integer): Integer;
-function inflateSetDictionary(var strm: z_stream; const dictionary: PChar;
- dictLength: Integer): Integer;
-function inflateSync(var strm: z_stream): Integer;
-function inflateCopy(var dest, source: z_stream): Integer;
-function inflateReset(var strm: z_stream): Integer;
-function inflateBackInit(var strm: z_stream;
- windowBits: Integer; window: PChar): Integer;
-function inflateBack(var strm: z_stream; in_fn: in_func; in_desc: Pointer;
- out_fn: out_func; out_desc: Pointer): Integer;
-function inflateBackEnd(var strm: z_stream): Integer;
-function zlibCompileFlags: LongInt;
-
-(* utility functions *)
-function compress(dest: PChar; var destLen: LongInt;
- const source: PChar; sourceLen: LongInt): Integer;
-function compress2(dest: PChar; var destLen: LongInt;
- const source: PChar; sourceLen: LongInt;
- level: Integer): Integer;
-function compressBound(sourceLen: LongInt): LongInt;
-function uncompress(dest: PChar; var destLen: LongInt;
- const source: PChar; sourceLen: LongInt): Integer;
-
-(* checksum functions *)
-function adler32(adler: LongInt; const buf: PChar; len: Integer): LongInt;
-function crc32(crc: LongInt; const buf: PChar; len: Integer): LongInt;
-
-(* various hacks, don't look :) *)
-function deflateInit_(var strm: z_stream; level: Integer;
- const version: PChar; stream_size: Integer): Integer;
-function inflateInit_(var strm: z_stream; const version: PChar;
- stream_size: Integer): Integer;
-function deflateInit2_(var strm: z_stream;
- level, method, windowBits, memLevel, strategy: Integer;
- const version: PChar; stream_size: Integer): Integer;
-function inflateInit2_(var strm: z_stream; windowBits: Integer;
- const version: PChar; stream_size: Integer): Integer;
-function inflateBackInit_(var strm: z_stream;
- windowBits: Integer; window: PChar;
- const version: PChar; stream_size: Integer): Integer;
-
-
-implementation
-
-{$L adler32.obj}
-{$L compress.obj}
-{$L crc32.obj}
-{$L deflate.obj}
-{$L infback.obj}
-{$L inffast.obj}
-{$L inflate.obj}
-{$L inftrees.obj}
-{$L trees.obj}
-{$L uncompr.obj}
-{$L zutil.obj}
-
-function adler32; external;
-function compress; external;
-function compress2; external;
-function compressBound; external;
-function crc32; external;
-function deflate; external;
-function deflateBound; external;
-function deflateCopy; external;
-function deflateEnd; external;
-function deflateInit_; external;
-function deflateInit2_; external;
-function deflateParams; external;
-function deflatePrime; external;
-function deflateReset; external;
-function deflateSetDictionary; external;
-function inflate; external;
-function inflateBack; external;
-function inflateBackEnd; external;
-function inflateBackInit_; external;
-function inflateCopy; external;
-function inflateEnd; external;
-function inflateInit_; external;
-function inflateInit2_; external;
-function inflateReset; external;
-function inflateSetDictionary; external;
-function inflateSync; external;
-function uncompress; external;
-function zlibCompileFlags; external;
-function zlibVersion; external;
-
-function deflateInit(var strm: z_stream; level: Integer): Integer;
-begin
- Result := deflateInit_(strm, level, ZLIB_VERSION, sizeof(z_stream));
-end;
-
-function deflateInit2(var strm: z_stream; level, method, windowBits, memLevel,
- strategy: Integer): Integer;
-begin
- Result := deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
- ZLIB_VERSION, sizeof(z_stream));
-end;
-
-function inflateInit(var strm: z_stream): Integer;
-begin
- Result := inflateInit_(strm, ZLIB_VERSION, sizeof(z_stream));
-end;
-
-function inflateInit2(var strm: z_stream; windowBits: Integer): Integer;
-begin
- Result := inflateInit2_(strm, windowBits, ZLIB_VERSION, sizeof(z_stream));
-end;
-
-function inflateBackInit(var strm: z_stream;
- windowBits: Integer; window: PChar): Integer;
-begin
- Result := inflateBackInit_(strm, windowBits, window,
- ZLIB_VERSION, sizeof(z_stream));
-end;
-
-function _malloc(Size: Integer): Pointer; cdecl;
-begin
- GetMem(Result, Size);
-end;
-
-procedure _free(Block: Pointer); cdecl;
-begin
- FreeMem(Block);
-end;
-
-procedure _memset(P: Pointer; B: Byte; count: Integer); cdecl;
-begin
- FillChar(P^, count, B);
-end;
-
-procedure _memcpy(dest, source: Pointer; count: Integer); cdecl;
-begin
- Move(source^, dest^, count);
-end;
-
-end.
diff --git a/source4/lib/zlib/contrib/puff/Makefile b/source4/lib/zlib/contrib/puff/Makefile
deleted file mode 100644
index b6b69404c7..0000000000
--- a/source4/lib/zlib/contrib/puff/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-puff: puff.c puff.h
- cc -DTEST -o puff puff.c
-
-test: puff
- puff zeros.raw
-
-clean:
- rm -f puff puff.o
diff --git a/source4/lib/zlib/contrib/puff/README b/source4/lib/zlib/contrib/puff/README
deleted file mode 100644
index bbc4cb595e..0000000000
--- a/source4/lib/zlib/contrib/puff/README
+++ /dev/null
@@ -1,63 +0,0 @@
-Puff -- A Simple Inflate
-3 Mar 2003
-Mark Adler
-madler@alumni.caltech.edu
-
-What this is --
-
-puff.c provides the routine puff() to decompress the deflate data format. It
-does so more slowly than zlib, but the code is about one-fifth the size of the
-inflate code in zlib, and written to be very easy to read.
-
-Why I wrote this --
-
-puff.c was written to document the deflate format unambiguously, by virtue of
-being working C code. It is meant to supplement RFC 1951, which formally
-describes the deflate format. I have received many questions on details of the
-deflate format, and I hope that reading this code will answer those questions.
-puff.c is heavily commented with details of the deflate format, especially
-those little nooks and cranies of the format that might not be obvious from a
-specification.
-
-puff.c may also be useful in applications where code size or memory usage is a
-very limited resource, and speed is not as important.
-
-How to use it --
-
-Well, most likely you should just be reading puff.c and using zlib for actual
-applications, but if you must ...
-
-Include puff.h in your code, which provides this prototype:
-
-int puff(unsigned char *dest, /* pointer to destination pointer */
- unsigned long *destlen, /* amount of output space */
- unsigned char *source, /* pointer to source data pointer */
- unsigned long *sourcelen); /* amount of input available */
-
-Then you can call puff() to decompress a deflate stream that is in memory in
-its entirety at source, to a sufficiently sized block of memory for the
-decompressed data at dest. puff() is the only external symbol in puff.c The
-only C library functions that puff.c needs are setjmp() and longjmp(), which
-are used to simplify error checking in the code to improve readabilty. puff.c
-does no memory allocation, and uses less than 2K bytes off of the stack.
-
-If destlen is not enough space for the uncompressed data, then inflate will
-return an error without writing more than destlen bytes. Note that this means
-that in order to decompress the deflate data successfully, you need to know
-the size of the uncompressed data ahead of time.
-
-If needed, puff() can determine the size of the uncompressed data with no
-output space. This is done by passing dest equal to (unsigned char *)0. Then
-the initial value of *destlen is ignored and *destlen is set to the length of
-the uncompressed data. So if the size of the uncompressed data is not known,
-then two passes of puff() can be used--first to determine the size, and second
-to do the actual inflation after allocating the appropriate memory. Not
-pretty, but it works. (This is one of the reasons you should be using zlib.)
-
-The deflate format is self-terminating. If the deflate stream does not end
-in *sourcelen bytes, puff() will return an error without reading at or past
-endsource.
-
-On return, *sourcelen is updated to the amount of input data consumed, and
-*destlen is updated to the size of the uncompressed data. See the comments
-in puff.c for the possible return codes for puff().
diff --git a/source4/lib/zlib/contrib/puff/puff.c b/source4/lib/zlib/contrib/puff/puff.c
deleted file mode 100644
index ce0cc405e3..0000000000
--- a/source4/lib/zlib/contrib/puff/puff.c
+++ /dev/null
@@ -1,837 +0,0 @@
-/*
- * puff.c
- * Copyright (C) 2002-2004 Mark Adler
- * For conditions of distribution and use, see copyright notice in puff.h
- * version 1.8, 9 Jan 2004
- *
- * puff.c is a simple inflate written to be an unambiguous way to specify the
- * deflate format. It is not written for speed but rather simplicity. As a
- * side benefit, this code might actually be useful when small code is more
- * important than speed, such as bootstrap applications. For typical deflate
- * data, zlib's inflate() is about four times as fast as puff(). zlib's
- * inflate compiles to around 20K on my machine, whereas puff.c compiles to
- * around 4K on my machine (a PowerPC using GNU cc). If the faster decode()
- * function here is used, then puff() is only twice as slow as zlib's
- * inflate().
- *
- * All dynamically allocated memory comes from the stack. The stack required
- * is less than 2K bytes. This code is compatible with 16-bit int's and
- * assumes that long's are at least 32 bits. puff.c uses the short data type,
- * assumed to be 16 bits, for arrays in order to to conserve memory. The code
- * works whether integers are stored big endian or little endian.
- *
- * In the comments below are "Format notes" that describe the inflate process
- * and document some of the less obvious aspects of the format. This source
- * code is meant to supplement RFC 1951, which formally describes the deflate
- * format:
- *
- * http://www.zlib.org/rfc-deflate.html
- */
-
-/*
- * Change history:
- *
- * 1.0 10 Feb 2002 - First version
- * 1.1 17 Feb 2002 - Clarifications of some comments and notes
- * - Update puff() dest and source pointers on negative
- * errors to facilitate debugging deflators
- * - Remove longest from struct huffman -- not needed
- * - Simplify offs[] index in construct()
- * - Add input size and checking, using longjmp() to
- * maintain easy readability
- * - Use short data type for large arrays
- * - Use pointers instead of long to specify source and
- * destination sizes to avoid arbitrary 4 GB limits
- * 1.2 17 Mar 2002 - Add faster version of decode(), doubles speed (!),
- * but leave simple version for readabilty
- * - Make sure invalid distances detected if pointers
- * are 16 bits
- * - Fix fixed codes table error
- * - Provide a scanning mode for determining size of
- * uncompressed data
- * 1.3 20 Mar 2002 - Go back to lengths for puff() parameters [Jean-loup]
- * - Add a puff.h file for the interface
- * - Add braces in puff() for else do [Jean-loup]
- * - Use indexes instead of pointers for readability
- * 1.4 31 Mar 2002 - Simplify construct() code set check
- * - Fix some comments
- * - Add FIXLCODES #define
- * 1.5 6 Apr 2002 - Minor comment fixes
- * 1.6 7 Aug 2002 - Minor format changes
- * 1.7 3 Mar 2003 - Added test code for distribution
- * - Added zlib-like license
- * 1.8 9 Jan 2004 - Added some comments on no distance codes case
- */
-
-#include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */
-#include "puff.h" /* prototype for puff() */
-
-#define local static /* for local function definitions */
-#define NIL ((unsigned char *)0) /* for no output option */
-
-/*
- * Maximums for allocations and loops. It is not useful to change these --
- * they are fixed by the deflate format.
- */
-#define MAXBITS 15 /* maximum bits in a code */
-#define MAXLCODES 286 /* maximum number of literal/length codes */
-#define MAXDCODES 30 /* maximum number of distance codes */
-#define MAXCODES (MAXLCODES+MAXDCODES) /* maximum codes lengths to read */
-#define FIXLCODES 288 /* number of fixed literal/length codes */
-
-/* input and output state */
-struct state {
- /* output state */
- unsigned char *out; /* output buffer */
- unsigned long outlen; /* available space at out */
- unsigned long outcnt; /* bytes written to out so far */
-
- /* input state */
- unsigned char *in; /* input buffer */
- unsigned long inlen; /* available input at in */
- unsigned long incnt; /* bytes read so far */
- int bitbuf; /* bit buffer */
- int bitcnt; /* number of bits in bit buffer */
-
- /* input limit error return state for bits() and decode() */
- jmp_buf env;
-};
-
-/*
- * Return need bits from the input stream. This always leaves less than
- * eight bits in the buffer. bits() works properly for need == 0.
- *
- * Format notes:
- *
- * - Bits are stored in bytes from the least significant bit to the most
- * significant bit. Therefore bits are dropped from the bottom of the bit
- * buffer, using shift right, and new bytes are appended to the top of the
- * bit buffer, using shift left.
- */
-local int bits(struct state *s, int need)
-{
- long val; /* bit accumulator (can use up to 20 bits) */
-
- /* load at least need bits into val */
- val = s->bitbuf;
- while (s->bitcnt < need) {
- if (s->incnt == s->inlen) longjmp(s->env, 1); /* out of input */
- val |= (long)(s->in[s->incnt++]) << s->bitcnt; /* load eight bits */
- s->bitcnt += 8;
- }
-
- /* drop need bits and update buffer, always zero to seven bits left */
- s->bitbuf = (int)(val >> need);
- s->bitcnt -= need;
-
- /* return need bits, zeroing the bits above that */
- return (int)(val & ((1L << need) - 1));
-}
-
-/*
- * Process a stored block.
- *
- * Format notes:
- *
- * - After the two-bit stored block type (00), the stored block length and
- * stored bytes are byte-aligned for fast copying. Therefore any leftover
- * bits in the byte that has the last bit of the type, as many as seven, are
- * discarded. The value of the discarded bits are not defined and should not
- * be checked against any expectation.
- *
- * - The second inverted copy of the stored block length does not have to be
- * checked, but it's probably a good idea to do so anyway.
- *
- * - A stored block can have zero length. This is sometimes used to byte-align
- * subsets of the compressed data for random access or partial recovery.
- */
-local int stored(struct state *s)
-{
- unsigned len; /* length of stored block */
-
- /* discard leftover bits from current byte (assumes s->bitcnt < 8) */
- s->bitbuf = 0;
- s->bitcnt = 0;
-
- /* get length and check against its one's complement */
- if (s->incnt + 4 > s->inlen) return 2; /* not enough input */
- len = s->in[s->incnt++];
- len |= s->in[s->incnt++] << 8;
- if (s->in[s->incnt++] != (~len & 0xff) ||
- s->in[s->incnt++] != ((~len >> 8) & 0xff))
- return -2; /* didn't match complement! */
-
- /* copy len bytes from in to out */
- if (s->incnt + len > s->inlen) return 2; /* not enough input */
- if (s->out != NIL) {
- if (s->outcnt + len > s->outlen)
- return 1; /* not enough output space */
- while (len--)
- s->out[s->outcnt++] = s->in[s->incnt++];
- }
- else { /* just scanning */
- s->outcnt += len;
- s->incnt += len;
- }
-
- /* done with a valid stored block */
- return 0;
-}
-
-/*
- * Huffman code decoding tables. count[1..MAXBITS] is the number of symbols of
- * each length, which for a canonical code are stepped through in order.
- * symbol[] are the symbol values in canonical order, where the number of
- * entries is the sum of the counts in count[]. The decoding process can be
- * seen in the function decode() below.
- */
-struct huffman {
- short *count; /* number of symbols of each length */
- short *symbol; /* canonically ordered symbols */
-};
-
-/*
- * Decode a code from the stream s using huffman table h. Return the symbol or
- * a negative value if there is an error. If all of the lengths are zero, i.e.
- * an empty code, or if the code is incomplete and an invalid code is received,
- * then -9 is returned after reading MAXBITS bits.
- *
- * Format notes:
- *
- * - The codes as stored in the compressed data are bit-reversed relative to
- * a simple integer ordering of codes of the same lengths. Hence below the
- * bits are pulled from the compressed data one at a time and used to
- * build the code value reversed from what is in the stream in order to
- * permit simple integer comparisons for decoding. A table-based decoding
- * scheme (as used in zlib) does not need to do this reversal.
- *
- * - The first code for the shortest length is all zeros. Subsequent codes of
- * the same length are simply integer increments of the previous code. When
- * moving up a length, a zero bit is appended to the code. For a complete
- * code, the last code of the longest length will be all ones.
- *
- * - Incomplete codes are handled by this decoder, since they are permitted
- * in the deflate format. See the format notes for fixed() and dynamic().
- */
-#ifdef SLOW
-local int decode(struct state *s, struct huffman *h)
-{
- int len; /* current number of bits in code */
- int code; /* len bits being decoded */
- int first; /* first code of length len */
- int count; /* number of codes of length len */
- int index; /* index of first code of length len in symbol table */
-
- code = first = index = 0;
- for (len = 1; len <= MAXBITS; len++) {
- code |= bits(s, 1); /* get next bit */
- count = h->count[len];
- if (code < first + count) /* if length len, return symbol */
- return h->symbol[index + (code - first)];
- index += count; /* else update for next length */
- first += count;
- first <<= 1;
- code <<= 1;
- }
- return -9; /* ran out of codes */
-}
-
-/*
- * A faster version of decode() for real applications of this code. It's not
- * as readable, but it makes puff() twice as fast. And it only makes the code
- * a few percent larger.
- */
-#else /* !SLOW */
-local int decode(struct state *s, struct huffman *h)
-{
- int len; /* current number of bits in code */
- int code; /* len bits being decoded */
- int first; /* first code of length len */
- int count; /* number of codes of length len */
- int index; /* index of first code of length len in symbol table */
- int bitbuf; /* bits from stream */
- int left; /* bits left in next or left to process */
- short *next; /* next number of codes */
-
- bitbuf = s->bitbuf;
- left = s->bitcnt;
- code = first = index = 0;
- len = 1;
- next = h->count + 1;
- while (1) {
- while (left--) {
- code |= bitbuf & 1;
- bitbuf >>= 1;
- count = *next++;
- if (code < first + count) { /* if length len, return symbol */
- s->bitbuf = bitbuf;
- s->bitcnt = (s->bitcnt - len) & 7;
- return h->symbol[index + (code - first)];
- }
- index += count; /* else update for next length */
- first += count;
- first <<= 1;
- code <<= 1;
- len++;
- }
- left = (MAXBITS+1) - len;
- if (left == 0) break;
- if (s->incnt == s->inlen) longjmp(s->env, 1); /* out of input */
- bitbuf = s->in[s->incnt++];
- if (left > 8) left = 8;
- }
- return -9; /* ran out of codes */
-}
-#endif /* SLOW */
-
-/*
- * Given the list of code lengths length[0..n-1] representing a canonical
- * Huffman code for n symbols, construct the tables required to decode those
- * codes. Those tables are the number of codes of each length, and the symbols
- * sorted by length, retaining their original order within each length. The
- * return value is zero for a complete code set, negative for an over-
- * subscribed code set, and positive for an incomplete code set. The tables
- * can be used if the return value is zero or positive, but they cannot be used
- * if the return value is negative. If the return value is zero, it is not
- * possible for decode() using that table to return an error--any stream of
- * enough bits will resolve to a symbol. If the return value is positive, then
- * it is possible for decode() using that table to return an error for received
- * codes past the end of the incomplete lengths.
- *
- * Not used by decode(), but used for error checking, h->count[0] is the number
- * of the n symbols not in the code. So n - h->count[0] is the number of
- * codes. This is useful for checking for incomplete codes that have more than
- * one symbol, which is an error in a dynamic block.
- *
- * Assumption: for all i in 0..n-1, 0 <= length[i] <= MAXBITS
- * This is assured by the construction of the length arrays in dynamic() and
- * fixed() and is not verified by construct().
- *
- * Format notes:
- *
- * - Permitted and expected examples of incomplete codes are one of the fixed
- * codes and any code with a single symbol which in deflate is coded as one
- * bit instead of zero bits. See the format notes for fixed() and dynamic().
- *
- * - Within a given code length, the symbols are kept in ascending order for
- * the code bits definition.
- */
-local int construct(struct huffman *h, short *length, int n)
-{
- int symbol; /* current symbol when stepping through length[] */
- int len; /* current length when stepping through h->count[] */
- int left; /* number of possible codes left of current length */
- short offs[MAXBITS+1]; /* offsets in symbol table for each length */
-
- /* count number of codes of each length */
- for (len = 0; len <= MAXBITS; len++)
- h->count[len] = 0;
- for (symbol = 0; symbol < n; symbol++)
- (h->count[length[symbol]])++; /* assumes lengths are within bounds */
- if (h->count[0] == n) /* no codes! */
- return 0; /* complete, but decode() will fail */
-
- /* check for an over-subscribed or incomplete set of lengths */
- left = 1; /* one possible code of zero length */
- for (len = 1; len <= MAXBITS; len++) {
- left <<= 1; /* one more bit, double codes left */
- left -= h->count[len]; /* deduct count from possible codes */
- if (left < 0) return left; /* over-subscribed--return negative */
- } /* left > 0 means incomplete */
-
- /* generate offsets into symbol table for each length for sorting */
- offs[1] = 0;
- for (len = 1; len < MAXBITS; len++)
- offs[len + 1] = offs[len] + h->count[len];
-
- /*
- * put symbols in table sorted by length, by symbol order within each
- * length
- */
- for (symbol = 0; symbol < n; symbol++)
- if (length[symbol] != 0)
- h->symbol[offs[length[symbol]]++] = symbol;
-
- /* return zero for complete set, positive for incomplete set */
- return left;
-}
-
-/*
- * Decode literal/length and distance codes until an end-of-block code.
- *
- * Format notes:
- *
- * - Compressed data that is after the block type if fixed or after the code
- * description if dynamic is a combination of literals and length/distance
- * pairs terminated by and end-of-block code. Literals are simply Huffman
- * coded bytes. A length/distance pair is a coded length followed by a
- * coded distance to represent a string that occurs earlier in the
- * uncompressed data that occurs again at the current location.
- *
- * - Literals, lengths, and the end-of-block code are combined into a single
- * code of up to 286 symbols. They are 256 literals (0..255), 29 length
- * symbols (257..285), and the end-of-block symbol (256).
- *
- * - There are 256 possible lengths (3..258), and so 29 symbols are not enough
- * to represent all of those. Lengths 3..10 and 258 are in fact represented
- * by just a length symbol. Lengths 11..257 are represented as a symbol and
- * some number of extra bits that are added as an integer to the base length
- * of the length symbol. The number of extra bits is determined by the base
- * length symbol. These are in the static arrays below, lens[] for the base
- * lengths and lext[] for the corresponding number of extra bits.
- *
- * - The reason that 258 gets its own symbol is that the longest length is used
- * often in highly redundant files. Note that 258 can also be coded as the
- * base value 227 plus the maximum extra value of 31. While a good deflate
- * should never do this, it is not an error, and should be decoded properly.
- *
- * - If a length is decoded, including its extra bits if any, then it is
- * followed a distance code. There are up to 30 distance symbols. Again
- * there are many more possible distances (1..32768), so extra bits are added
- * to a base value represented by the symbol. The distances 1..4 get their
- * own symbol, but the rest require extra bits. The base distances and
- * corresponding number of extra bits are below in the static arrays dist[]
- * and dext[].
- *
- * - Literal bytes are simply written to the output. A length/distance pair is
- * an instruction to copy previously uncompressed bytes to the output. The
- * copy is from distance bytes back in the output stream, copying for length
- * bytes.
- *
- * - Distances pointing before the beginning of the output data are not
- * permitted.
- *
- * - Overlapped copies, where the length is greater than the distance, are
- * allowed and common. For example, a distance of one and a length of 258
- * simply copies the last byte 258 times. A distance of four and a length of
- * twelve copies the last four bytes three times. A simple forward copy
- * ignoring whether the length is greater than the distance or not implements
- * this correctly. You should not use memcpy() since its behavior is not
- * defined for overlapped arrays. You should not use memmove() or bcopy()
- * since though their behavior -is- defined for overlapping arrays, it is
- * defined to do the wrong thing in this case.
- */
-local int codes(struct state *s,
- struct huffman *lencode,
- struct huffman *distcode)
-{
- int symbol; /* decoded symbol */
- int len; /* length for copy */
- unsigned dist; /* distance for copy */
- static const short lens[29] = { /* Size base for length 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};
- static const short lext[29] = { /* Extra bits for length 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};
- static const short dists[30] = { /* Offset base 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 short dext[30] = { /* Extra bits for distance codes 0..29 */
- 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};
-
- /* decode literals and length/distance pairs */
- do {
- symbol = decode(s, lencode);
- if (symbol < 0) return symbol; /* invalid symbol */
- if (symbol < 256) { /* literal: symbol is the byte */
- /* write out the literal */
- if (s->out != NIL) {
- if (s->outcnt == s->outlen) return 1;
- s->out[s->outcnt] = symbol;
- }
- s->outcnt++;
- }
- else if (symbol > 256) { /* length */
- /* get and compute length */
- symbol -= 257;
- if (symbol >= 29) return -9; /* invalid fixed code */
- len = lens[symbol] + bits(s, lext[symbol]);
-
- /* get and check distance */
- symbol = decode(s, distcode);
- if (symbol < 0) return symbol; /* invalid symbol */
- dist = dists[symbol] + bits(s, dext[symbol]);
- if (dist > s->outcnt)
- return -10; /* distance too far back */
-
- /* copy length bytes from distance bytes back */
- if (s->out != NIL) {
- if (s->outcnt + len > s->outlen) return 1;
- while (len--) {
- s->out[s->outcnt] = s->out[s->outcnt - dist];
- s->outcnt++;
- }
- }
- else
- s->outcnt += len;
- }
- } while (symbol != 256); /* end of block symbol */
-
- /* done with a valid fixed or dynamic block */
- return 0;
-}
-
-/*
- * Process a fixed codes block.
- *
- * Format notes:
- *
- * - This block type can be useful for compressing small amounts of data for
- * which the size of the code descriptions in a dynamic block exceeds the
- * benefit of custom codes for that block. For fixed codes, no bits are
- * spent on code descriptions. Instead the code lengths for literal/length
- * codes and distance codes are fixed. The specific lengths for each symbol
- * can be seen in the "for" loops below.
- *
- * - The literal/length code is complete, but has two symbols that are invalid
- * and should result in an error if received. This cannot be implemented
- * simply as an incomplete code since those two symbols are in the "middle"
- * of the code. They are eight bits long and the longest literal/length\
- * code is nine bits. Therefore the code must be constructed with those
- * symbols, and the invalid symbols must be detected after decoding.
- *
- * - The fixed distance codes also have two invalid symbols that should result
- * in an error if received. Since all of the distance codes are the same
- * length, this can be implemented as an incomplete code. Then the invalid
- * codes are detected while decoding.
- */
-local int fixed(struct state *s)
-{
- static int virgin = 1;
- static short lencnt[MAXBITS+1], lensym[FIXLCODES];
- static short distcnt[MAXBITS+1], distsym[MAXDCODES];
- static struct huffman lencode = {lencnt, lensym};
- static struct huffman distcode = {distcnt, distsym};
-
- /* build fixed huffman tables if first call (may not be thread safe) */
- if (virgin) {
- int symbol;
- short lengths[FIXLCODES];
-
- /* literal/length table */
- for (symbol = 0; symbol < 144; symbol++)
- lengths[symbol] = 8;
- for (; symbol < 256; symbol++)
- lengths[symbol] = 9;
- for (; symbol < 280; symbol++)
- lengths[symbol] = 7;
- for (; symbol < FIXLCODES; symbol++)
- lengths[symbol] = 8;
- construct(&lencode, lengths, FIXLCODES);
-
- /* distance table */
- for (symbol = 0; symbol < MAXDCODES; symbol++)
- lengths[symbol] = 5;
- construct(&distcode, lengths, MAXDCODES);
-
- /* do this just once */
- virgin = 0;
- }
-
- /* decode data until end-of-block code */
- return codes(s, &lencode, &distcode);
-}
-
-/*
- * Process a dynamic codes block.
- *
- * Format notes:
- *
- * - A dynamic block starts with a description of the literal/length and
- * distance codes for that block. New dynamic blocks allow the compressor to
- * rapidly adapt to changing data with new codes optimized for that data.
- *
- * - The codes used by the deflate format are "canonical", which means that
- * the actual bits of the codes are generated in an unambiguous way simply
- * from the number of bits in each code. Therefore the code descriptions
- * are simply a list of code lengths for each symbol.
- *
- * - The code lengths are stored in order for the symbols, so lengths are
- * provided for each of the literal/length symbols, and for each of the
- * distance symbols.
- *
- * - If a symbol is not used in the block, this is represented by a zero as
- * as the code length. This does not mean a zero-length code, but rather
- * that no code should be created for this symbol. There is no way in the
- * deflate format to represent a zero-length code.
- *
- * - The maximum number of bits in a code is 15, so the possible lengths for
- * any code are 1..15.
- *
- * - The fact that a length of zero is not permitted for a code has an
- * interesting consequence. Normally if only one symbol is used for a given
- * code, then in fact that code could be represented with zero bits. However
- * in deflate, that code has to be at least one bit. So for example, if
- * only a single distance base symbol appears in a block, then it will be
- * represented by a single code of length one, in particular one 0 bit. This
- * is an incomplete code, since if a 1 bit is received, it has no meaning,
- * and should result in an error. So incomplete distance codes of one symbol
- * should be permitted, and the receipt of invalid codes should be handled.
- *
- * - It is also possible to have a single literal/length code, but that code
- * must be the end-of-block code, since every dynamic block has one. This
- * is not the most efficient way to create an empty block (an empty fixed
- * block is fewer bits), but it is allowed by the format. So incomplete
- * literal/length codes of one symbol should also be permitted.
- *
- * - If there are only literal codes and no lengths, then there are no distance
- * codes. This is represented by one distance code with zero bits.
- *
- * - The list of up to 286 length/literal lengths and up to 30 distance lengths
- * are themselves compressed using Huffman codes and run-length encoding. In
- * the list of code lengths, a 0 symbol means no code, a 1..15 symbol means
- * that length, and the symbols 16, 17, and 18 are run-length instructions.
- * Each of 16, 17, and 18 are follwed by extra bits to define the length of
- * the run. 16 copies the last length 3 to 6 times. 17 represents 3 to 10
- * zero lengths, and 18 represents 11 to 138 zero lengths. Unused symbols
- * are common, hence the special coding for zero lengths.
- *
- * - The symbols for 0..18 are Huffman coded, and so that code must be
- * described first. This is simply a sequence of up to 19 three-bit values
- * representing no code (0) or the code length for that symbol (1..7).
- *
- * - A dynamic block starts with three fixed-size counts from which is computed
- * the number of literal/length code lengths, the number of distance code
- * lengths, and the number of code length code lengths (ok, you come up with
- * a better name!) in the code descriptions. For the literal/length and
- * distance codes, lengths after those provided are considered zero, i.e. no
- * code. The code length code lengths are received in a permuted order (see
- * the order[] array below) to make a short code length code length list more
- * likely. As it turns out, very short and very long codes are less likely
- * to be seen in a dynamic code description, hence what may appear initially
- * to be a peculiar ordering.
- *
- * - Given the number of literal/length code lengths (nlen) and distance code
- * lengths (ndist), then they are treated as one long list of nlen + ndist
- * code lengths. Therefore run-length coding can and often does cross the
- * boundary between the two sets of lengths.
- *
- * - So to summarize, the code description at the start of a dynamic block is
- * three counts for the number of code lengths for the literal/length codes,
- * the distance codes, and the code length codes. This is followed by the
- * code length code lengths, three bits each. This is used to construct the
- * code length code which is used to read the remainder of the lengths. Then
- * the literal/length code lengths and distance lengths are read as a single
- * set of lengths using the code length codes. Codes are constructed from
- * the resulting two sets of lengths, and then finally you can start
- * decoding actual compressed data in the block.
- *
- * - For reference, a "typical" size for the code description in a dynamic
- * block is around 80 bytes.
- */
-local int dynamic(struct state *s)
-{
- int nlen, ndist, ncode; /* number of lengths in descriptor */
- int index; /* index of lengths[] */
- int err; /* construct() return value */
- short lengths[MAXCODES]; /* descriptor code lengths */
- short lencnt[MAXBITS+1], lensym[MAXLCODES]; /* lencode memory */
- short distcnt[MAXBITS+1], distsym[MAXDCODES]; /* distcode memory */
- struct huffman lencode = {lencnt, lensym}; /* length code */
- struct huffman distcode = {distcnt, distsym}; /* distance code */
- static const short order[19] = /* permutation of code length codes */
- {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
- /* get number of lengths in each table, check lengths */
- nlen = bits(s, 5) + 257;
- ndist = bits(s, 5) + 1;
- ncode = bits(s, 4) + 4;
- if (nlen > MAXLCODES || ndist > MAXDCODES)
- return -3; /* bad counts */
-
- /* read code length code lengths (really), missing lengths are zero */
- for (index = 0; index < ncode; index++)
- lengths[order[index]] = bits(s, 3);
- for (; index < 19; index++)
- lengths[order[index]] = 0;
-
- /* build huffman table for code lengths codes (use lencode temporarily) */
- err = construct(&lencode, lengths, 19);
- if (err != 0) return -4; /* require complete code set here */
-
- /* read length/literal and distance code length tables */
- index = 0;
- while (index < nlen + ndist) {
- int symbol; /* decoded value */
- int len; /* last length to repeat */
-
- symbol = decode(s, &lencode);
- if (symbol < 16) /* length in 0..15 */
- lengths[index++] = symbol;
- else { /* repeat instruction */
- len = 0; /* assume repeating zeros */
- if (symbol == 16) { /* repeat last length 3..6 times */
- if (index == 0) return -5; /* no last length! */
- len = lengths[index - 1]; /* last length */
- symbol = 3 + bits(s, 2);
- }
- else if (symbol == 17) /* repeat zero 3..10 times */
- symbol = 3 + bits(s, 3);
- else /* == 18, repeat zero 11..138 times */
- symbol = 11 + bits(s, 7);
- if (index + symbol > nlen + ndist)
- return -6; /* too many lengths! */
- while (symbol--) /* repeat last or zero symbol times */
- lengths[index++] = len;
- }
- }
-
- /* build huffman table for literal/length codes */
- err = construct(&lencode, lengths, nlen);
- if (err < 0 || (err > 0 && nlen - lencode.count[0] != 1))
- return -7; /* only allow incomplete codes if just one code */
-
- /* build huffman table for distance codes */
- err = construct(&distcode, lengths + nlen, ndist);
- if (err < 0 || (err > 0 && ndist - distcode.count[0] != 1))
- return -8; /* only allow incomplete codes if just one code */
-
- /* decode data until end-of-block code */
- return codes(s, &lencode, &distcode);
-}
-
-/*
- * Inflate source to dest. On return, destlen and sourcelen are updated to the
- * size of the uncompressed data and the size of the deflate data respectively.
- * On success, the return value of puff() is zero. If there is an error in the
- * source data, i.e. it is not in the deflate format, then a negative value is
- * returned. If there is not enough input available or there is not enough
- * output space, then a positive error is returned. In that case, destlen and
- * sourcelen are not updated to facilitate retrying from the beginning with the
- * provision of more input data or more output space. In the case of invalid
- * inflate data (a negative error), the dest and source pointers are updated to
- * facilitate the debugging of deflators.
- *
- * puff() also has a mode to determine the size of the uncompressed output with
- * no output written. For this dest must be (unsigned char *)0. In this case,
- * the input value of *destlen is ignored, and on return *destlen is set to the
- * size of the uncompressed output.
- *
- * The return codes are:
- *
- * 2: available inflate data did not terminate
- * 1: output space exhausted before completing inflate
- * 0: successful inflate
- * -1: invalid block type (type == 3)
- * -2: stored block length did not match one's complement
- * -3: dynamic block code description: too many length or distance codes
- * -4: dynamic block code description: code lengths codes incomplete
- * -5: dynamic block code description: repeat lengths with no first length
- * -6: dynamic block code description: repeat more than specified lengths
- * -7: dynamic block code description: invalid literal/length code lengths
- * -8: dynamic block code description: invalid distance code lengths
- * -9: invalid literal/length or distance code in fixed or dynamic block
- * -10: distance is too far back in fixed or dynamic block
- *
- * Format notes:
- *
- * - Three bits are read for each block to determine the kind of block and
- * whether or not it is the last block. Then the block is decoded and the
- * process repeated if it was not the last block.
- *
- * - The leftover bits in the last byte of the deflate data after the last
- * block (if it was a fixed or dynamic block) are undefined and have no
- * expected values to check.
- */
-int puff(unsigned char *dest, /* pointer to destination pointer */
- unsigned long *destlen, /* amount of output space */
- unsigned char *source, /* pointer to source data pointer */
- unsigned long *sourcelen) /* amount of input available */
-{
- struct state s; /* input/output state */
- int last, type; /* block information */
- int err; /* return value */
-
- /* initialize output state */
- s.out = dest;
- s.outlen = *destlen; /* ignored if dest is NIL */
- s.outcnt = 0;
-
- /* initialize input state */
- s.in = source;
- s.inlen = *sourcelen;
- s.incnt = 0;
- s.bitbuf = 0;
- s.bitcnt = 0;
-
- /* return if bits() or decode() tries to read past available input */
- if (setjmp(s.env) != 0) /* if came back here via longjmp() */
- err = 2; /* then skip do-loop, return error */
- else {
- /* process blocks until last block or error */
- do {
- last = bits(&s, 1); /* one if last block */
- type = bits(&s, 2); /* block type 0..3 */
- err = type == 0 ? stored(&s) :
- (type == 1 ? fixed(&s) :
- (type == 2 ? dynamic(&s) :
- -1)); /* type == 3, invalid */
- if (err != 0) break; /* return with error */
- } while (!last);
- }
-
- /* update the lengths and return */
- if (err <= 0) {
- *destlen = s.outcnt;
- *sourcelen = s.incnt;
- }
- return err;
-}
-
-#ifdef TEST
-/* Example of how to use puff() */
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-local unsigned char *yank(char *name, unsigned long *len)
-{
- unsigned long size;
- unsigned char *buf;
- FILE *in;
- struct stat s;
-
- *len = 0;
- if (stat(name, &s)) return NULL;
- if ((s.st_mode & S_IFMT) != S_IFREG) return NULL;
- size = (unsigned long)(s.st_size);
- if (size == 0 || (off_t)size != s.st_size) return NULL;
- in = fopen(name, "r");
- if (in == NULL) return NULL;
- buf = malloc(size);
- if (buf != NULL && fread(buf, 1, size, in) != size) {
- free(buf);
- buf = NULL;
- }
- fclose(in);
- *len = size;
- return buf;
-}
-
-int main(int argc, char **argv)
-{
- int ret;
- unsigned char *source;
- unsigned long len, sourcelen, destlen;
-
- if (argc < 2) return 2;
- source = yank(argv[1], &len);
- if (source == NULL) return 2;
- sourcelen = len;
- ret = puff(NIL, &destlen, source, &sourcelen);
- if (ret)
- printf("puff() failed with return code %d\n", ret);
- else {
- printf("puff() succeeded uncompressing %lu bytes\n", destlen);
- if (sourcelen < len) printf("%lu compressed bytes unused\n",
- len - sourcelen);
- }
- free(source);
- return ret;
-}
-#endif
diff --git a/source4/lib/zlib/contrib/puff/puff.h b/source4/lib/zlib/contrib/puff/puff.h
deleted file mode 100644
index ef612520b3..0000000000
--- a/source4/lib/zlib/contrib/puff/puff.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* puff.h
- Copyright (C) 2002, 2003 Mark Adler, all rights reserved
- version 1.7, 3 Mar 2002
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the author be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Mark Adler madler@alumni.caltech.edu
- */
-
-
-/*
- * See puff.c for purpose and usage.
- */
-int puff(unsigned char *dest, /* pointer to destination pointer */
- unsigned long *destlen, /* amount of output space */
- unsigned char *source, /* pointer to source data pointer */
- unsigned long *sourcelen); /* amount of input available */
diff --git a/source4/lib/zlib/contrib/puff/zeros.raw b/source4/lib/zlib/contrib/puff/zeros.raw
deleted file mode 100644
index 637b7be6f5..0000000000
--- a/source4/lib/zlib/contrib/puff/zeros.raw
+++ /dev/null
Binary files differ
diff --git a/source4/lib/zlib/contrib/testzlib/testzlib.c b/source4/lib/zlib/contrib/testzlib/testzlib.c
deleted file mode 100644
index e5574f45e7..0000000000
--- a/source4/lib/zlib/contrib/testzlib/testzlib.c
+++ /dev/null
@@ -1,275 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-
-#include "zlib.h"
-
-
-void MyDoMinus64(LARGE_INTEGER *R,LARGE_INTEGER A,LARGE_INTEGER B)
-{
- R->HighPart = A.HighPart - B.HighPart;
- if (A.LowPart >= B.LowPart)
- R->LowPart = A.LowPart - B.LowPart;
- else
- {
- R->LowPart = A.LowPart - B.LowPart;
- R->HighPart --;
- }
-}
-
-#ifdef _M_X64
-// see http://msdn2.microsoft.com/library/twchhe95(en-us,vs.80).aspx for __rdtsc
-unsigned __int64 __rdtsc(void);
-void BeginCountRdtsc(LARGE_INTEGER * pbeginTime64)
-{
- // printf("rdtsc = %I64x\n",__rdtsc());
- pbeginTime64->QuadPart=__rdtsc();
-}
-
-LARGE_INTEGER GetResRdtsc(LARGE_INTEGER beginTime64,BOOL fComputeTimeQueryPerf)
-{
- LARGE_INTEGER LIres;
- unsigned _int64 res=__rdtsc()-((unsigned _int64)(beginTime64.QuadPart));
- LIres.QuadPart=res;
- // printf("rdtsc = %I64x\n",__rdtsc());
- return LIres;
-}
-#else
-#ifdef _M_IX86
-void myGetRDTSC32(LARGE_INTEGER * pbeginTime64)
-{
- DWORD dwEdx,dwEax;
- _asm
- {
- rdtsc
- mov dwEax,eax
- mov dwEdx,edx
- }
- pbeginTime64->LowPart=dwEax;
- pbeginTime64->HighPart=dwEdx;
-}
-
-void BeginCountRdtsc(LARGE_INTEGER * pbeginTime64)
-{
- myGetRDTSC32(pbeginTime64);
-}
-
-LARGE_INTEGER GetResRdtsc(LARGE_INTEGER beginTime64,BOOL fComputeTimeQueryPerf)
-{
- LARGE_INTEGER LIres,endTime64;
- myGetRDTSC32(&endTime64);
-
- LIres.LowPart=LIres.HighPart=0;
- MyDoMinus64(&LIres,endTime64,beginTime64);
- return LIres;
-}
-#else
-void myGetRDTSC32(LARGE_INTEGER * pbeginTime64)
-{
-}
-
-void BeginCountRdtsc(LARGE_INTEGER * pbeginTime64)
-{
-}
-
-LARGE_INTEGER GetResRdtsc(LARGE_INTEGER beginTime64,BOOL fComputeTimeQueryPerf)
-{
- LARGE_INTEGER lr;
- lr.QuadPart=0;
- return lr;
-}
-#endif
-#endif
-
-void BeginCountPerfCounter(LARGE_INTEGER * pbeginTime64,BOOL fComputeTimeQueryPerf)
-{
- if ((!fComputeTimeQueryPerf) || (!QueryPerformanceCounter(pbeginTime64)))
- {
- pbeginTime64->LowPart = GetTickCount();
- pbeginTime64->HighPart = 0;
- }
-}
-
-DWORD GetMsecSincePerfCounter(LARGE_INTEGER beginTime64,BOOL fComputeTimeQueryPerf)
-{
- LARGE_INTEGER endTime64,ticksPerSecond,ticks;
- DWORDLONG ticksShifted,tickSecShifted;
- DWORD dwLog=16+0;
- DWORD dwRet;
- if ((!fComputeTimeQueryPerf) || (!QueryPerformanceCounter(&endTime64)))
- dwRet = (GetTickCount() - beginTime64.LowPart)*1;
- else
- {
- MyDoMinus64(&ticks,endTime64,beginTime64);
- QueryPerformanceFrequency(&ticksPerSecond);
-
-
- {
- ticksShifted = Int64ShrlMod32(*(DWORDLONG*)&ticks,dwLog);
- tickSecShifted = Int64ShrlMod32(*(DWORDLONG*)&ticksPerSecond,dwLog);
-
- }
-
- dwRet = (DWORD)((((DWORD)ticksShifted)*1000)/(DWORD)(tickSecShifted));
- dwRet *=1;
- }
- return dwRet;
-}
-
-int ReadFileMemory(const char* filename,long* plFileSize,void** pFilePtr)
-{
- FILE* stream;
- void* ptr;
- int retVal=1;
- stream=fopen(filename, "rb");
- if (stream==NULL)
- return 0;
-
- fseek(stream,0,SEEK_END);
-
- *plFileSize=ftell(stream);
- fseek(stream,0,SEEK_SET);
- ptr=malloc((*plFileSize)+1);
- if (ptr==NULL)
- retVal=0;
- else
- {
- if (fread(ptr, 1, *plFileSize,stream) != (*plFileSize))
- retVal=0;
- }
- fclose(stream);
- *pFilePtr=ptr;
- return retVal;
-}
-
-int main(int argc, char *argv[])
-{
- int BlockSizeCompress=0x8000;
- int BlockSizeUncompress=0x8000;
- int cprLevel=Z_DEFAULT_COMPRESSION ;
- long lFileSize;
- unsigned char* FilePtr;
- long lBufferSizeCpr;
- long lBufferSizeUncpr;
- long lCompressedSize=0;
- unsigned char* CprPtr;
- unsigned char* UncprPtr;
- long lSizeCpr,lSizeUncpr;
- DWORD dwGetTick,dwMsecQP;
- LARGE_INTEGER li_qp,li_rdtsc,dwResRdtsc;
-
- if (argc<=1)
- {
- printf("run TestZlib <File> [BlockSizeCompress] [BlockSizeUncompress] [compres. level]\n");
- return 0;
- }
-
- if (ReadFileMemory(argv[1],&lFileSize,&FilePtr)==0)
- {
- printf("error reading %s\n",argv[1]);
- return 1;
- }
- else printf("file %s read, %u bytes\n",argv[1],lFileSize);
-
- if (argc>=3)
- BlockSizeCompress=atol(argv[2]);
-
- if (argc>=4)
- BlockSizeUncompress=atol(argv[3]);
-
- if (argc>=5)
- cprLevel=(int)atol(argv[4]);
-
- lBufferSizeCpr = lFileSize + (lFileSize/0x10) + 0x200;
- lBufferSizeUncpr = lBufferSizeCpr;
-
- CprPtr=(unsigned char*)malloc(lBufferSizeCpr + BlockSizeCompress);
-
- BeginCountPerfCounter(&li_qp,TRUE);
- dwGetTick=GetTickCount();
- BeginCountRdtsc(&li_rdtsc);
- {
- z_stream zcpr;
- int ret=Z_OK;
- long lOrigToDo = lFileSize;
- long lOrigDone = 0;
- int step=0;
- memset(&zcpr,0,sizeof(z_stream));
- deflateInit(&zcpr,cprLevel);
-
- zcpr.next_in = FilePtr;
- zcpr.next_out = CprPtr;
-
-
- do
- {
- long all_read_before = zcpr.total_in;
- zcpr.avail_in = min(lOrigToDo,BlockSizeCompress);
- zcpr.avail_out = BlockSizeCompress;
- ret=deflate(&zcpr,(zcpr.avail_in==lOrigToDo) ? Z_FINISH : Z_SYNC_FLUSH);
- lOrigDone += (zcpr.total_in-all_read_before);
- lOrigToDo -= (zcpr.total_in-all_read_before);
- step++;
- } while (ret==Z_OK);
-
- lSizeCpr=zcpr.total_out;
- deflateEnd(&zcpr);
- dwGetTick=GetTickCount()-dwGetTick;
- dwMsecQP=GetMsecSincePerfCounter(li_qp,TRUE);
- dwResRdtsc=GetResRdtsc(li_rdtsc,TRUE);
- printf("total compress size = %u, in %u step\n",lSizeCpr,step);
- printf("time = %u msec = %f sec\n",dwGetTick,dwGetTick/(double)1000.);
- printf("defcpr time QP = %u msec = %f sec\n",dwMsecQP,dwMsecQP/(double)1000.);
- printf("defcpr result rdtsc = %I64x\n\n",dwResRdtsc.QuadPart);
- }
-
- CprPtr=(unsigned char*)realloc(CprPtr,lSizeCpr);
- UncprPtr=(unsigned char*)malloc(lBufferSizeUncpr + BlockSizeUncompress);
-
- BeginCountPerfCounter(&li_qp,TRUE);
- dwGetTick=GetTickCount();
- BeginCountRdtsc(&li_rdtsc);
- {
- z_stream zcpr;
- int ret=Z_OK;
- long lOrigToDo = lSizeCpr;
- long lOrigDone = 0;
- int step=0;
- memset(&zcpr,0,sizeof(z_stream));
- inflateInit(&zcpr);
-
- zcpr.next_in = CprPtr;
- zcpr.next_out = UncprPtr;
-
-
- do
- {
- long all_read_before = zcpr.total_in;
- zcpr.avail_in = min(lOrigToDo,BlockSizeUncompress);
- zcpr.avail_out = BlockSizeUncompress;
- ret=inflate(&zcpr,Z_SYNC_FLUSH);
- lOrigDone += (zcpr.total_in-all_read_before);
- lOrigToDo -= (zcpr.total_in-all_read_before);
- step++;
- } while (ret==Z_OK);
-
- lSizeUncpr=zcpr.total_out;
- inflateEnd(&zcpr);
- dwGetTick=GetTickCount()-dwGetTick;
- dwMsecQP=GetMsecSincePerfCounter(li_qp,TRUE);
- dwResRdtsc=GetResRdtsc(li_rdtsc,TRUE);
- printf("total uncompress size = %u, in %u step\n",lSizeUncpr,step);
- printf("time = %u msec = %f sec\n",dwGetTick,dwGetTick/(double)1000.);
- printf("uncpr time QP = %u msec = %f sec\n",dwMsecQP,dwMsecQP/(double)1000.);
- printf("uncpr result rdtsc = %I64x\n\n",dwResRdtsc.QuadPart);
- }
-
- if (lSizeUncpr==lFileSize)
- {
- if (memcmp(FilePtr,UncprPtr,lFileSize)==0)
- printf("compare ok\n");
-
- }
-
- return 0;
-}
diff --git a/source4/lib/zlib/contrib/testzlib/testzlib.txt b/source4/lib/zlib/contrib/testzlib/testzlib.txt
deleted file mode 100644
index 62258f1495..0000000000
--- a/source4/lib/zlib/contrib/testzlib/testzlib.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-To build testzLib with Visual Studio 2005:
-
-copy to a directory file from :
-- root of zLib tree
-- contrib/testzlib
-- contrib/masmx86
-- contrib/masmx64
-- contrib/vstudio/vc7
-
-and open testzlib8.sln \ No newline at end of file
diff --git a/source4/lib/zlib/contrib/untgz/Makefile b/source4/lib/zlib/contrib/untgz/Makefile
deleted file mode 100644
index b54266fba2..0000000000
--- a/source4/lib/zlib/contrib/untgz/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-CC=cc
-CFLAGS=-g
-
-untgz: untgz.o ../../libz.a
- $(CC) $(CFLAGS) -o untgz untgz.o -L../.. -lz
-
-untgz.o: untgz.c ../../zlib.h
- $(CC) $(CFLAGS) -c -I../.. untgz.c
-
-../../libz.a:
- cd ../..; ./configure; make
-
-clean:
- rm -f untgz untgz.o *~
diff --git a/source4/lib/zlib/contrib/untgz/Makefile.msc b/source4/lib/zlib/contrib/untgz/Makefile.msc
deleted file mode 100644
index 77b8602213..0000000000
--- a/source4/lib/zlib/contrib/untgz/Makefile.msc
+++ /dev/null
@@ -1,17 +0,0 @@
-CC=cl
-CFLAGS=-MD
-
-untgz.exe: untgz.obj ..\..\zlib.lib
- $(CC) $(CFLAGS) untgz.obj ..\..\zlib.lib
-
-untgz.obj: untgz.c ..\..\zlib.h
- $(CC) $(CFLAGS) -c -I..\.. untgz.c
-
-..\..\zlib.lib:
- cd ..\..
- $(MAKE) -f win32\makefile.msc
- cd contrib\untgz
-
-clean:
- -del untgz.obj
- -del untgz.exe
diff --git a/source4/lib/zlib/contrib/untgz/untgz.c b/source4/lib/zlib/contrib/untgz/untgz.c
deleted file mode 100644
index 2c391e5986..0000000000
--- a/source4/lib/zlib/contrib/untgz/untgz.c
+++ /dev/null
@@ -1,674 +0,0 @@
-/*
- * untgz.c -- Display contents and extract files from a gzip'd TAR file
- *
- * written by Pedro A. Aranda Gutierrez <paag@tid.es>
- * adaptation to Unix by Jean-loup Gailly <jloup@gzip.org>
- * various fixes by Cosmin Truta <cosmint@cs.ubbcluj.ro>
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-
-#include "zlib.h"
-
-#ifdef unix
-# include <unistd.h>
-#else
-# include <direct.h>
-# include <io.h>
-#endif
-
-#ifdef WIN32
-#include <windows.h>
-# ifndef F_OK
-# define F_OK 0
-# endif
-# define mkdir(dirname,mode) _mkdir(dirname)
-# ifdef _MSC_VER
-# define access(path,mode) _access(path,mode)
-# define chmod(path,mode) _chmod(path,mode)
-# define strdup(str) _strdup(str)
-# endif
-#else
-# include <utime.h>
-#endif
-
-
-/* values used in typeflag field */
-
-#define REGTYPE '0' /* regular file */
-#define AREGTYPE '\0' /* regular file */
-#define LNKTYPE '1' /* link */
-#define SYMTYPE '2' /* reserved */
-#define CHRTYPE '3' /* character special */
-#define BLKTYPE '4' /* block special */
-#define DIRTYPE '5' /* directory */
-#define FIFOTYPE '6' /* FIFO special */
-#define CONTTYPE '7' /* reserved */
-
-/* GNU tar extensions */
-
-#define GNUTYPE_DUMPDIR 'D' /* file names from dumped directory */
-#define GNUTYPE_LONGLINK 'K' /* long link name */
-#define GNUTYPE_LONGNAME 'L' /* long file name */
-#define GNUTYPE_MULTIVOL 'M' /* continuation of file from another volume */
-#define GNUTYPE_NAMES 'N' /* file name that does not fit into main hdr */
-#define GNUTYPE_SPARSE 'S' /* sparse file */
-#define GNUTYPE_VOLHDR 'V' /* tape/volume header */
-
-
-/* tar header */
-
-#define BLOCKSIZE 512
-#define SHORTNAMESIZE 100
-
-struct tar_header
-{ /* byte offset */
- char name[100]; /* 0 */
- char mode[8]; /* 100 */
- char uid[8]; /* 108 */
- char gid[8]; /* 116 */
- char size[12]; /* 124 */
- char mtime[12]; /* 136 */
- char chksum[8]; /* 148 */
- char typeflag; /* 156 */
- char linkname[100]; /* 157 */
- char magic[6]; /* 257 */
- char version[2]; /* 263 */
- char uname[32]; /* 265 */
- char gname[32]; /* 297 */
- char devmajor[8]; /* 329 */
- char devminor[8]; /* 337 */
- char prefix[155]; /* 345 */
- /* 500 */
-};
-
-union tar_buffer
-{
- char buffer[BLOCKSIZE];
- struct tar_header header;
-};
-
-struct attr_item
-{
- struct attr_item *next;
- char *fname;
- int mode;
- time_t time;
-};
-
-enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID };
-
-char *TGZfname OF((const char *));
-void TGZnotfound OF((const char *));
-
-int getoct OF((char *, int));
-char *strtime OF((time_t *));
-int setfiletime OF((char *, time_t));
-void push_attr OF((struct attr_item **, char *, int, time_t));
-void restore_attr OF((struct attr_item **));
-
-int ExprMatch OF((char *, char *));
-
-int makedir OF((char *));
-int matchname OF((int, int, char **, char *));
-
-void error OF((const char *));
-int tar OF((gzFile, int, int, int, char **));
-
-void help OF((int));
-int main OF((int, char **));
-
-char *prog;
-
-const char *TGZsuffix[] = { "\0", ".tar", ".tar.gz", ".taz", ".tgz", NULL };
-
-/* return the file name of the TGZ archive */
-/* or NULL if it does not exist */
-
-char *TGZfname (const char *arcname)
-{
- static char buffer[1024];
- int origlen,i;
-
- strcpy(buffer,arcname);
- origlen = strlen(buffer);
-
- for (i=0; TGZsuffix[i]; i++)
- {
- strcpy(buffer+origlen,TGZsuffix[i]);
- if (access(buffer,F_OK) == 0)
- return buffer;
- }
- return NULL;
-}
-
-
-/* error message for the filename */
-
-void TGZnotfound (const char *arcname)
-{
- int i;
-
- fprintf(stderr,"%s: Couldn't find ",prog);
- for (i=0;TGZsuffix[i];i++)
- fprintf(stderr,(TGZsuffix[i+1]) ? "%s%s, " : "or %s%s\n",
- arcname,
- TGZsuffix[i]);
- exit(1);
-}
-
-
-/* convert octal digits to int */
-/* on error return -1 */
-
-int getoct (char *p,int width)
-{
- int result = 0;
- char c;
-
- while (width--)
- {
- c = *p++;
- if (c == 0)
- break;
- if (c == ' ')
- continue;
- if (c < '0' || c > '7')
- return -1;
- result = result * 8 + (c - '0');
- }
- return result;
-}
-
-
-/* convert time_t to string */
-/* use the "YYYY/MM/DD hh:mm:ss" format */
-
-char *strtime (time_t *t)
-{
- struct tm *local;
- static char result[32];
-
- local = localtime(t);
- sprintf(result,"%4d/%02d/%02d %02d:%02d:%02d",
- local->tm_year+1900, local->tm_mon+1, local->tm_mday,
- local->tm_hour, local->tm_min, local->tm_sec);
- return result;
-}
-
-
-/* set file time */
-
-int setfiletime (char *fname,time_t ftime)
-{
-#ifdef WIN32
- static int isWinNT = -1;
- SYSTEMTIME st;
- FILETIME locft, modft;
- struct tm *loctm;
- HANDLE hFile;
- int result;
-
- loctm = localtime(&ftime);
- if (loctm == NULL)
- return -1;
-
- st.wYear = (WORD)loctm->tm_year + 1900;
- st.wMonth = (WORD)loctm->tm_mon + 1;
- st.wDayOfWeek = (WORD)loctm->tm_wday;
- st.wDay = (WORD)loctm->tm_mday;
- st.wHour = (WORD)loctm->tm_hour;
- st.wMinute = (WORD)loctm->tm_min;
- st.wSecond = (WORD)loctm->tm_sec;
- st.wMilliseconds = 0;
- if (!SystemTimeToFileTime(&st, &locft) ||
- !LocalFileTimeToFileTime(&locft, &modft))
- return -1;
-
- if (isWinNT < 0)
- isWinNT = (GetVersion() < 0x80000000) ? 1 : 0;
- hFile = CreateFile(fname, GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
- (isWinNT ? FILE_FLAG_BACKUP_SEMANTICS : 0),
- NULL);
- if (hFile == INVALID_HANDLE_VALUE)
- return -1;
- result = SetFileTime(hFile, NULL, NULL, &modft) ? 0 : -1;
- CloseHandle(hFile);
- return result;
-#else
- struct utimbuf settime;
-
- settime.actime = settime.modtime = ftime;
- return utime(fname,&settime);
-#endif
-}
-
-
-/* push file attributes */
-
-void push_attr(struct attr_item **list,char *fname,int mode,time_t time)
-{
- struct attr_item *item;
-
- item = (struct attr_item *)malloc(sizeof(struct attr_item));
- if (item == NULL)
- error("Out of memory");
- item->fname = strdup(fname);
- item->mode = mode;
- item->time = time;
- item->next = *list;
- *list = item;
-}
-
-
-/* restore file attributes */
-
-void restore_attr(struct attr_item **list)
-{
- struct attr_item *item, *prev;
-
- for (item = *list; item != NULL; )
- {
- setfiletime(item->fname,item->time);
- chmod(item->fname,item->mode);
- prev = item;
- item = item->next;
- free(prev);
- }
- *list = NULL;
-}
-
-
-/* match regular expression */
-
-#define ISSPECIAL(c) (((c) == '*') || ((c) == '/'))
-
-int ExprMatch (char *string,char *expr)
-{
- while (1)
- {
- if (ISSPECIAL(*expr))
- {
- if (*expr == '/')
- {
- if (*string != '\\' && *string != '/')
- return 0;
- string ++; expr++;
- }
- else if (*expr == '*')
- {
- if (*expr ++ == 0)
- return 1;
- while (*++string != *expr)
- if (*string == 0)
- return 0;
- }
- }
- else
- {
- if (*string != *expr)
- return 0;
- if (*expr++ == 0)
- return 1;
- string++;
- }
- }
-}
-
-
-/* recursive mkdir */
-/* abort on ENOENT; ignore other errors like "directory already exists" */
-/* return 1 if OK */
-/* 0 on error */
-
-int makedir (char *newdir)
-{
- char *buffer = strdup(newdir);
- char *p;
- int len = strlen(buffer);
-
- if (len <= 0) {
- free(buffer);
- return 0;
- }
- if (buffer[len-1] == '/') {
- buffer[len-1] = '\0';
- }
- if (mkdir(buffer, 0755) == 0)
- {
- free(buffer);
- return 1;
- }
-
- p = buffer+1;
- while (1)
- {
- char hold;
-
- while(*p && *p != '\\' && *p != '/')
- p++;
- hold = *p;
- *p = 0;
- if ((mkdir(buffer, 0755) == -1) && (errno == ENOENT))
- {
- fprintf(stderr,"%s: Couldn't create directory %s\n",prog,buffer);
- free(buffer);
- return 0;
- }
- if (hold == 0)
- break;
- *p++ = hold;
- }
- free(buffer);
- return 1;
-}
-
-
-int matchname (int arg,int argc,char **argv,char *fname)
-{
- if (arg == argc) /* no arguments given (untgz tgzarchive) */
- return 1;
-
- while (arg < argc)
- if (ExprMatch(fname,argv[arg++]))
- return 1;
-
- return 0; /* ignore this for the moment being */
-}
-
-
-/* tar file list or extract */
-
-int tar (gzFile in,int action,int arg,int argc,char **argv)
-{
- union tar_buffer buffer;
- int len;
- int err;
- int getheader = 1;
- int remaining = 0;
- FILE *outfile = NULL;
- char fname[BLOCKSIZE];
- int tarmode;
- time_t tartime;
- struct attr_item *attributes = NULL;
-
- if (action == TGZ_LIST)
- printf(" date time size file\n"
- " ---------- -------- --------- -------------------------------------\n");
- while (1)
- {
- len = gzread(in, &buffer, BLOCKSIZE);
- if (len < 0)
- error(gzerror(in, &err));
- /*
- * Always expect complete blocks to process
- * the tar information.
- */
- if (len != BLOCKSIZE)
- {
- action = TGZ_INVALID; /* force error exit */
- remaining = 0; /* force I/O cleanup */
- }
-
- /*
- * If we have to get a tar header
- */
- if (getheader >= 1)
- {
- /*
- * if we met the end of the tar
- * or the end-of-tar block,
- * we are done
- */
- if (len == 0 || buffer.header.name[0] == 0)
- break;
-
- tarmode = getoct(buffer.header.mode,8);
- tartime = (time_t)getoct(buffer.header.mtime,12);
- if (tarmode == -1 || tartime == (time_t)-1)
- {
- buffer.header.name[0] = 0;
- action = TGZ_INVALID;
- }
-
- if (getheader == 1)
- {
- strncpy(fname,buffer.header.name,SHORTNAMESIZE);
- if (fname[SHORTNAMESIZE-1] != 0)
- fname[SHORTNAMESIZE] = 0;
- }
- else
- {
- /*
- * The file name is longer than SHORTNAMESIZE
- */
- if (strncmp(fname,buffer.header.name,SHORTNAMESIZE-1) != 0)
- error("bad long name");
- getheader = 1;
- }
-
- /*
- * Act according to the type flag
- */
- switch (buffer.header.typeflag)
- {
- case DIRTYPE:
- if (action == TGZ_LIST)
- printf(" %s <dir> %s\n",strtime(&tartime),fname);
- if (action == TGZ_EXTRACT)
- {
- makedir(fname);
- push_attr(&attributes,fname,tarmode,tartime);
- }
- break;
- case REGTYPE:
- case AREGTYPE:
- remaining = getoct(buffer.header.size,12);
- if (remaining == -1)
- {
- action = TGZ_INVALID;
- break;
- }
- if (action == TGZ_LIST)
- printf(" %s %9d %s\n",strtime(&tartime),remaining,fname);
- else if (action == TGZ_EXTRACT)
- {
- if (matchname(arg,argc,argv,fname))
- {
- outfile = fopen(fname,"wb");
- if (outfile == NULL) {
- /* try creating directory */
- char *p = strrchr(fname, '/');
- if (p != NULL) {
- *p = '\0';
- makedir(fname);
- *p = '/';
- outfile = fopen(fname,"wb");
- }
- }
- if (outfile != NULL)
- printf("Extracting %s\n",fname);
- else
- fprintf(stderr, "%s: Couldn't create %s",prog,fname);
- }
- else
- outfile = NULL;
- }
- getheader = 0;
- break;
- case GNUTYPE_LONGLINK:
- case GNUTYPE_LONGNAME:
- remaining = getoct(buffer.header.size,12);
- if (remaining < 0 || remaining >= BLOCKSIZE)
- {
- action = TGZ_INVALID;
- break;
- }
- len = gzread(in, fname, BLOCKSIZE);
- if (len < 0)
- error(gzerror(in, &err));
- if (fname[BLOCKSIZE-1] != 0 || (int)strlen(fname) > remaining)
- {
- action = TGZ_INVALID;
- break;
- }
- getheader = 2;
- break;
- default:
- if (action == TGZ_LIST)
- printf(" %s <---> %s\n",strtime(&tartime),fname);
- break;
- }
- }
- else
- {
- unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining;
-
- if (outfile != NULL)
- {
- if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes)
- {
- fprintf(stderr,
- "%s: Error writing %s -- skipping\n",prog,fname);
- fclose(outfile);
- outfile = NULL;
- remove(fname);
- }
- }
- remaining -= bytes;
- }
-
- if (remaining == 0)
- {
- getheader = 1;
- if (outfile != NULL)
- {
- fclose(outfile);
- outfile = NULL;
- if (action != TGZ_INVALID)
- push_attr(&attributes,fname,tarmode,tartime);
- }
- }
-
- /*
- * Abandon if errors are found
- */
- if (action == TGZ_INVALID)
- {
- error("broken archive");
- break;
- }
- }
-
- /*
- * Restore file modes and time stamps
- */
- restore_attr(&attributes);
-
- if (gzclose(in) != Z_OK)
- error("failed gzclose");
-
- return 0;
-}
-
-
-/* ============================================================ */
-
-void help(int exitval)
-{
- printf("untgz version 0.2.1\n"
- " using zlib version %s\n\n",
- zlibVersion());
- printf("Usage: untgz file.tgz extract all files\n"
- " untgz file.tgz fname ... extract selected files\n"
- " untgz -l file.tgz list archive contents\n"
- " untgz -h display this help\n");
- exit(exitval);
-}
-
-void error(const char *msg)
-{
- fprintf(stderr, "%s: %s\n", prog, msg);
- exit(1);
-}
-
-
-/* ============================================================ */
-
-#if defined(WIN32) && defined(__GNUC__)
-int _CRT_glob = 0; /* disable argument globbing in MinGW */
-#endif
-
-int main(int argc,char **argv)
-{
- int action = TGZ_EXTRACT;
- int arg = 1;
- char *TGZfile;
- gzFile *f;
-
- prog = strrchr(argv[0],'\\');
- if (prog == NULL)
- {
- prog = strrchr(argv[0],'/');
- if (prog == NULL)
- {
- prog = strrchr(argv[0],':');
- if (prog == NULL)
- prog = argv[0];
- else
- prog++;
- }
- else
- prog++;
- }
- else
- prog++;
-
- if (argc == 1)
- help(0);
-
- if (strcmp(argv[arg],"-l") == 0)
- {
- action = TGZ_LIST;
- if (argc == ++arg)
- help(0);
- }
- else if (strcmp(argv[arg],"-h") == 0)
- {
- help(0);
- }
-
- if ((TGZfile = TGZfname(argv[arg])) == NULL)
- TGZnotfound(argv[arg]);
-
- ++arg;
- if ((action == TGZ_LIST) && (arg != argc))
- help(1);
-
-/*
- * Process the TGZ file
- */
- switch(action)
- {
- case TGZ_LIST:
- case TGZ_EXTRACT:
- f = gzopen(TGZfile,"rb");
- if (f == NULL)
- {
- fprintf(stderr,"%s: Couldn't gzopen %s\n",prog,TGZfile);
- return 1;
- }
- exit(tar(f, action, arg, argc, argv));
- break;
-
- default:
- error("Unknown option");
- exit(1);
- }
-
- return 0;
-}
diff --git a/source4/lib/zlib/contrib/vstudio/readme.txt b/source4/lib/zlib/contrib/vstudio/readme.txt
deleted file mode 100644
index 16159f9cd0..0000000000
--- a/source4/lib/zlib/contrib/vstudio/readme.txt
+++ /dev/null
@@ -1,73 +0,0 @@
-Building instructions for the DLL versions of Zlib 1.2.3
-========================================================
-
-This directory contains projects that build zlib and minizip using
-Microsoft Visual C++ 7.0/7.1, and Visual C++ .
-
-You don't need to build these projects yourself. You can download the
-binaries from:
- http://www.winimage.com/zLibDll
-
-More information can be found at this site.
-
-
-Build instructions for Visual Studio 7.x (32 bits)
---------------------------------------------------
-- Uncompress current zlib, including all contrib/* files
-- Download the crtdll library from
- http://www.winimage.com/zLibDll/crtdll.zip
- Unzip crtdll.zip to extract crtdll.lib on contrib\vstudio\vc7.
-- Open contrib\vstudio\vc7\zlibvc.sln with Microsoft Visual C++ 7.x
- (Visual Studio .Net 2002 or 2003).
-
-Build instructions for Visual Studio 2005 (32 bits or 64 bits)
---------------------------------------------------------------
-- Uncompress current zlib, including all contrib/* files
-- For 32 bits only: download the crtdll library from
- http://www.winimage.com/zLibDll/crtdll.zip
- Unzip crtdll.zip to extract crtdll.lib on contrib\vstudio\vc8.
-- Open contrib\vstudio\vc8\zlibvc.sln with Microsoft Visual C++ 8.0
-
-Build instructions for Visual Studio 2005 64 bits, PSDK compiler
-----------------------------------------------------------------
-at the time of writing this text file, Visual Studio 2005 (and
- Microsoft Visual C++ 8.0) is on the beta 2 stage.
-Using you can get the free 64 bits compiler from Platform SDK,
- which is NOT a beta, and compile using the Visual studio 2005 IDE
-see http://www.winimage.com/misc/sdk64onvs2005/ for instruction
-
-- Uncompress current zlib, including all contrib/* files
-- start Visual Studio 2005 from a platform SDK command prompt, using
- the /useenv switch
-- Open contrib\vstudio\vc8\zlibvc.sln with Microsoft Visual C++ 8.0
-
-
-Important
----------
-- To use zlibwapi.dll in your application, you must define the
- macro ZLIB_WINAPI when compiling your application's source files.
-
-
-Additional notes
-----------------
-- This DLL, named zlibwapi.dll, is compatible to the old zlib.dll built
- by Gilles Vollant from the zlib 1.1.x sources, and distributed at
- http://www.winimage.com/zLibDll
- It uses the WINAPI calling convention for the exported functions, and
- includes the minizip functionality. If your application needs that
- particular build of zlib.dll, you can rename zlibwapi.dll to zlib.dll.
-
-- The new DLL was renamed because there exist several incompatible
- versions of zlib.dll on the Internet.
-
-- There is also an official DLL build of zlib, named zlib1.dll. This one
- is exporting the functions using the CDECL convention. See the file
- win32\DLL_FAQ.txt found in this zlib distribution.
-
-- There used to be a ZLIB_DLL macro in zlib 1.1.x, but now this symbol
- has a slightly different effect. To avoid compatibility problems, do
- not define it here.
-
-
-Gilles Vollant
-info@winimage.com
diff --git a/source4/lib/zlib/contrib/vstudio/vc7/miniunz.vcproj b/source4/lib/zlib/contrib/vstudio/vc7/miniunz.vcproj
deleted file mode 100644
index ad5117c845..0000000000
--- a/source4/lib/zlib/contrib/vstudio/vc7/miniunz.vcproj
+++ /dev/null
@@ -1,126 +0,0 @@
-<?xml version="1.0" encoding = "Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="7.00"
- Name="miniunz"
- ProjectGUID="{C52F9E7B-498A-42BE-8DB4-85A15694382A}"
- Keyword="Win32Proj">
- <Platforms>
- <Platform
- Name="Win32"/>
- </Platforms>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="Debug"
- IntermediateDirectory="Debug"
- ConfigurationType="1"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE"
- MinimalRebuild="TRUE"
- BasicRuntimeChecks="3"
- RuntimeLibrary="5"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="TRUE"
- DebugInformationFormat="4"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)/miniunz.exe"
- LinkIncremental="2"
- GenerateDebugInformation="TRUE"
- ProgramDatabaseFile="$(OutDir)/miniunz.pdb"
- SubSystem="1"
- TargetMachine="1"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release"
- ConfigurationType="1"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- OmitFramePointers="TRUE"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE"
- StringPooling="TRUE"
- RuntimeLibrary="4"
- EnableFunctionLevelLinking="TRUE"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="TRUE"
- DebugInformationFormat="3"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)/miniunz.exe"
- LinkIncremental="1"
- GenerateDebugInformation="TRUE"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- OptimizeForWindows98="1"
- TargetMachine="1"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- </Configuration>
- </Configurations>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
- <File
- RelativePath="..\..\minizip\miniunz.c">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc">
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
- </Filter>
- <File
- RelativePath="ReleaseDll\zlibwapi.lib">
- </File>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/source4/lib/zlib/contrib/vstudio/vc7/minizip.vcproj b/source4/lib/zlib/contrib/vstudio/vc7/minizip.vcproj
deleted file mode 100644
index fb5b6320d5..0000000000
--- a/source4/lib/zlib/contrib/vstudio/vc7/minizip.vcproj
+++ /dev/null
@@ -1,126 +0,0 @@
-<?xml version="1.0" encoding = "Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="7.00"
- Name="minizip"
- ProjectGUID="{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}"
- Keyword="Win32Proj">
- <Platforms>
- <Platform
- Name="Win32"/>
- </Platforms>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="Debug"
- IntermediateDirectory="Debug"
- ConfigurationType="1"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE"
- MinimalRebuild="TRUE"
- BasicRuntimeChecks="3"
- RuntimeLibrary="5"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="TRUE"
- DebugInformationFormat="4"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)/minizip.exe"
- LinkIncremental="2"
- GenerateDebugInformation="TRUE"
- ProgramDatabaseFile="$(OutDir)/minizip.pdb"
- SubSystem="1"
- TargetMachine="1"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release"
- ConfigurationType="1"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- OmitFramePointers="TRUE"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE"
- StringPooling="TRUE"
- RuntimeLibrary="4"
- EnableFunctionLevelLinking="TRUE"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="TRUE"
- DebugInformationFormat="3"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)/minizip.exe"
- LinkIncremental="1"
- GenerateDebugInformation="TRUE"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- OptimizeForWindows98="1"
- TargetMachine="1"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- </Configuration>
- </Configurations>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
- <File
- RelativePath="..\..\minizip\minizip.c">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc">
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
- </Filter>
- <File
- RelativePath="ReleaseDll\zlibwapi.lib">
- </File>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/source4/lib/zlib/contrib/vstudio/vc7/testzlib.vcproj b/source4/lib/zlib/contrib/vstudio/vc7/testzlib.vcproj
deleted file mode 100644
index 97bc3e8c86..0000000000
--- a/source4/lib/zlib/contrib/vstudio/vc7/testzlib.vcproj
+++ /dev/null
@@ -1,126 +0,0 @@
-<?xml version="1.0" encoding = "Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="7.00"
- Name="testZlibDll"
- ProjectGUID="{AA6666AA-E09F-4135-9C0C-4FE50C3C654C}"
- Keyword="Win32Proj">
- <Platforms>
- <Platform
- Name="Win32"/>
- </Platforms>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="Debug"
- IntermediateDirectory="Debug"
- ConfigurationType="1"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\.."
- PreprocessorDefinitions="WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE"
- MinimalRebuild="TRUE"
- BasicRuntimeChecks="3"
- RuntimeLibrary="5"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="TRUE"
- DebugInformationFormat="4"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)/testzlib.exe"
- LinkIncremental="2"
- GenerateDebugInformation="TRUE"
- ProgramDatabaseFile="$(OutDir)/testzlib.pdb"
- SubSystem="1"
- TargetMachine="1"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release"
- ConfigurationType="1"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- OmitFramePointers="TRUE"
- AdditionalIncludeDirectories="..\..\.."
- PreprocessorDefinitions="WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE"
- StringPooling="TRUE"
- RuntimeLibrary="4"
- EnableFunctionLevelLinking="TRUE"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="TRUE"
- DebugInformationFormat="3"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)/testzlib.exe"
- LinkIncremental="1"
- GenerateDebugInformation="TRUE"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- OptimizeForWindows98="1"
- TargetMachine="1"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- </Configuration>
- </Configurations>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
- <File
- RelativePath="..\..\testzlib\testzlib.c">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc">
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
- </Filter>
- <File
- RelativePath="ReleaseDll\zlibwapi.lib">
- </File>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/source4/lib/zlib/contrib/vstudio/vc7/zlib.rc b/source4/lib/zlib/contrib/vstudio/vc7/zlib.rc
deleted file mode 100644
index 72cb8b4c31..0000000000
--- a/source4/lib/zlib/contrib/vstudio/vc7/zlib.rc
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <windows.h>
-
-#define IDR_VERSION1 1
-IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
- FILEVERSION 1,2,3,0
- PRODUCTVERSION 1,2,3,0
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
- FILEFLAGS 0
- FILEOS VOS_DOS_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE 0 // not used
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904E4"
- //language ID = U.S. English, char set = Windows, Multilingual
-
- BEGIN
- VALUE "FileDescription", "zlib data compression library\0"
- VALUE "FileVersion", "1.2.3.0\0"
- VALUE "InternalName", "zlib\0"
- VALUE "OriginalFilename", "zlib.dll\0"
- VALUE "ProductName", "ZLib.DLL\0"
- VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
- VALUE "LegalCopyright", "(C) 1995-2003 Jean-loup Gailly & Mark Adler\0"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x0409, 1252
- END
-END
diff --git a/source4/lib/zlib/contrib/vstudio/vc7/zlibstat.vcproj b/source4/lib/zlib/contrib/vstudio/vc7/zlibstat.vcproj
deleted file mode 100644
index 766d7a4d6e..0000000000
--- a/source4/lib/zlib/contrib/vstudio/vc7/zlibstat.vcproj
+++ /dev/null
@@ -1,246 +0,0 @@
-<?xml version="1.0" encoding = "Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="7.00"
- Name="zlibstat"
- SccProjectName=""
- SccLocalPath="">
- <Platforms>
- <Platform
- Name="Win32"/>
- </Platforms>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory=".\zlibstatDebug"
- IntermediateDirectory=".\zlibstatDebug"
- ConfigurationType="4"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="FALSE">
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32;ZLIB_WINAPI"
- ExceptionHandling="FALSE"
- RuntimeLibrary="5"
- PrecompiledHeaderFile=".\zlibstatDebug/zlibstat.pch"
- AssemblerListingLocation=".\zlibstatDebug/"
- ObjectFile=".\zlibstatDebug/"
- ProgramDataBaseFileName=".\zlibstatDebug/"
- WarningLevel="3"
- SuppressStartupBanner="TRUE"
- DebugInformationFormat="1"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLibrarianTool"
- AdditionalOptions="/NODEFAULTLIB "
- OutputFile=".\zlibstatDebug\zlibstat.lib"
- SuppressStartupBanner="TRUE"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1036"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- </Configuration>
- <Configuration
- Name="ReleaseAxp|Win32"
- OutputDirectory=".\zlibsta0"
- IntermediateDirectory=".\zlibsta0"
- ConfigurationType="4"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="FALSE">
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32;ZLIB_WINAPI"
- StringPooling="TRUE"
- ExceptionHandling="FALSE"
- RuntimeLibrary="4"
- EnableFunctionLevelLinking="TRUE"
- PrecompiledHeaderFile=".\zlibsta0/zlibstat.pch"
- AssemblerListingLocation=".\zlibsta0/"
- ObjectFile=".\zlibsta0/"
- ProgramDataBaseFileName=".\zlibsta0/"
- WarningLevel="3"
- SuppressStartupBanner="TRUE"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLibrarianTool"
- AdditionalOptions="/NODEFAULTLIB "
- OutputFile=".\zlibsta0\zlibstat.lib"
- SuppressStartupBanner="TRUE"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory=".\zlibstat"
- IntermediateDirectory=".\zlibstat"
- ConfigurationType="4"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="FALSE">
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32;ZLIB_WINAPI;ASMV;ASMINF"
- StringPooling="TRUE"
- ExceptionHandling="FALSE"
- RuntimeLibrary="4"
- EnableFunctionLevelLinking="TRUE"
- PrecompiledHeaderFile=".\zlibstat/zlibstat.pch"
- AssemblerListingLocation=".\zlibstat/"
- ObjectFile=".\zlibstat/"
- ProgramDataBaseFileName=".\zlibstat/"
- WarningLevel="3"
- SuppressStartupBanner="TRUE"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLibrarianTool"
- AdditionalOptions="..\..\masmx86\gvmat32.obj ..\..\masmx86\inffas32.obj /NODEFAULTLIB "
- OutputFile=".\zlibstat\zlibstat.lib"
- SuppressStartupBanner="TRUE"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1036"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- </Configuration>
- <Configuration
- Name="ReleaseWithoutAsm|Win32"
- OutputDirectory="zlibstatWithoutAsm"
- IntermediateDirectory="zlibstatWithoutAsm"
- ConfigurationType="4"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="FALSE">
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32;ZLIB_WINAPI"
- StringPooling="TRUE"
- ExceptionHandling="FALSE"
- RuntimeLibrary="4"
- EnableFunctionLevelLinking="TRUE"
- PrecompiledHeaderFile=".\zlibstat/zlibstat.pch"
- AssemblerListingLocation=".\zlibstatWithoutAsm/"
- ObjectFile=".\zlibstatWithoutAsm/"
- ProgramDataBaseFileName=".\zlibstatWithoutAsm/"
- WarningLevel="3"
- SuppressStartupBanner="TRUE"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLibrarianTool"
- AdditionalOptions=" /NODEFAULTLIB "
- OutputFile=".\zlibstatWithoutAsm\zlibstat.lib"
- SuppressStartupBanner="TRUE"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1036"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- </Configuration>
- </Configurations>
- <Files>
- <Filter
- Name="Source Files"
- Filter="">
- <File
- RelativePath="..\..\..\adler32.c">
- </File>
- <File
- RelativePath="..\..\..\compress.c">
- </File>
- <File
- RelativePath="..\..\..\crc32.c">
- </File>
- <File
- RelativePath="..\..\..\deflate.c">
- </File>
- <File
- RelativePath="..\..\masmx86\gvmat32c.c">
- </File>
- <File
- RelativePath="..\..\..\gzio.c">
- </File>
- <File
- RelativePath="..\..\..\infback.c">
- </File>
- <File
- RelativePath="..\..\..\inffast.c">
- </File>
- <File
- RelativePath="..\..\..\inflate.c">
- </File>
- <File
- RelativePath="..\..\..\inftrees.c">
- </File>
- <File
- RelativePath="..\..\minizip\ioapi.c">
- </File>
- <File
- RelativePath="..\..\..\trees.c">
- </File>
- <File
- RelativePath="..\..\..\uncompr.c">
- </File>
- <File
- RelativePath="..\..\minizip\unzip.c">
- </File>
- <File
- RelativePath="..\..\minizip\zip.c">
- </File>
- <File
- RelativePath=".\zlib.rc">
- </File>
- <File
- RelativePath=".\zlibvc.def">
- </File>
- <File
- RelativePath="..\..\..\zutil.c">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/source4/lib/zlib/contrib/vstudio/vc7/zlibvc.def b/source4/lib/zlib/contrib/vstudio/vc7/zlibvc.def
deleted file mode 100644
index a40e71541f..0000000000
--- a/source4/lib/zlib/contrib/vstudio/vc7/zlibvc.def
+++ /dev/null
@@ -1,92 +0,0 @@
-
-VERSION 1.23
-
-HEAPSIZE 1048576,8192
-
-EXPORTS
- adler32 @1
- compress @2
- crc32 @3
- deflate @4
- deflateCopy @5
- deflateEnd @6
- deflateInit2_ @7
- deflateInit_ @8
- deflateParams @9
- deflateReset @10
- deflateSetDictionary @11
- gzclose @12
- gzdopen @13
- gzerror @14
- gzflush @15
- gzopen @16
- gzread @17
- gzwrite @18
- inflate @19
- inflateEnd @20
- inflateInit2_ @21
- inflateInit_ @22
- inflateReset @23
- inflateSetDictionary @24
- inflateSync @25
- uncompress @26
- zlibVersion @27
- gzprintf @28
- gzputc @29
- gzgetc @30
- gzseek @31
- gzrewind @32
- gztell @33
- gzeof @34
- gzsetparams @35
- zError @36
- inflateSyncPoint @37
- get_crc_table @38
- compress2 @39
- gzputs @40
- gzgets @41
- inflateCopy @42
- inflateBackInit_ @43
- inflateBack @44
- inflateBackEnd @45
- compressBound @46
- deflateBound @47
- gzclearerr @48
- gzungetc @49
- zlibCompileFlags @50
- deflatePrime @51
-
- unzOpen @61
- unzClose @62
- unzGetGlobalInfo @63
- unzGetCurrentFileInfo @64
- unzGoToFirstFile @65
- unzGoToNextFile @66
- unzOpenCurrentFile @67
- unzReadCurrentFile @68
- unzOpenCurrentFile3 @69
- unztell @70
- unzeof @71
- unzCloseCurrentFile @72
- unzGetGlobalComment @73
- unzStringFileNameCompare @74
- unzLocateFile @75
- unzGetLocalExtrafield @76
- unzOpen2 @77
- unzOpenCurrentFile2 @78
- unzOpenCurrentFilePassword @79
-
- zipOpen @80
- zipOpenNewFileInZip @81
- zipWriteInFileInZip @82
- zipCloseFileInZip @83
- zipClose @84
- zipOpenNewFileInZip2 @86
- zipCloseFileInZipRaw @87
- zipOpen2 @88
- zipOpenNewFileInZip3 @89
-
- unzGetFilePos @100
- unzGoToFilePos @101
-
- fill_win32_filefunc @110
diff --git a/source4/lib/zlib/contrib/vstudio/vc7/zlibvc.sln b/source4/lib/zlib/contrib/vstudio/vc7/zlibvc.sln
deleted file mode 100644
index 927b42b7bd..0000000000
--- a/source4/lib/zlib/contrib/vstudio/vc7/zlibvc.sln
+++ /dev/null
@@ -1,78 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 7.00
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testZlibDll", "testzlib.vcproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654C}"
-EndProject
-Global
- GlobalSection(SolutionConfiguration) = preSolution
- ConfigName.0 = Debug
- ConfigName.1 = Release
- ConfigName.2 = ReleaseAxp
- ConfigName.3 = ReleaseWithoutAsm
- ConfigName.4 = ReleaseWithoutCrtdll
- EndGlobalSection
- GlobalSection(ProjectDependencies) = postSolution
- EndGlobalSection
- GlobalSection(ProjectConfiguration) = postSolution
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug.ActiveCfg = Debug|Win32
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug.Build.0 = Debug|Win32
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release.ActiveCfg = Release|Win32
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release.Build.0 = Release|Win32
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseAxp.ActiveCfg = ReleaseAxp|Win32
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseAxp.Build.0 = ReleaseAxp|Win32
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm.ActiveCfg = ReleaseWithoutAsm|Win32
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm.Build.0 = ReleaseWithoutAsm|Win32
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutCrtdll.ActiveCfg = ReleaseAxp|Win32
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutCrtdll.Build.0 = ReleaseAxp|Win32
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug.ActiveCfg = Debug|Win32
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug.Build.0 = Debug|Win32
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release.ActiveCfg = Release|Win32
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release.Build.0 = Release|Win32
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseAxp.ActiveCfg = ReleaseAxp|Win32
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseAxp.Build.0 = ReleaseAxp|Win32
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm.ActiveCfg = ReleaseWithoutAsm|Win32
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm.Build.0 = ReleaseWithoutAsm|Win32
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutCrtdll.ActiveCfg = ReleaseWithoutCrtdll|Win32
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutCrtdll.Build.0 = ReleaseWithoutCrtdll|Win32
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug.ActiveCfg = Debug|Win32
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug.Build.0 = Debug|Win32
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release.ActiveCfg = Release|Win32
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release.Build.0 = Release|Win32
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseAxp.ActiveCfg = Release|Win32
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseAxp.Build.0 = Release|Win32
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm.ActiveCfg = Release|Win32
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm.Build.0 = Release|Win32
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutCrtdll.ActiveCfg = Release|Win32
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutCrtdll.Build.0 = Release|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug.ActiveCfg = Debug|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug.Build.0 = Debug|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release.ActiveCfg = Release|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release.Build.0 = Release|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseAxp.ActiveCfg = Release|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseAxp.Build.0 = Release|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm.ActiveCfg = Release|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm.Build.0 = Release|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutCrtdll.ActiveCfg = Release|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutCrtdll.Build.0 = Release|Win32
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.Debug.ActiveCfg = Debug|Win32
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.Debug.Build.0 = Debug|Win32
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.Release.ActiveCfg = Release|Win32
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.Release.Build.0 = Release|Win32
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.ReleaseAxp.ActiveCfg = Release|Win32
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.ReleaseAxp.Build.0 = Release|Win32
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.ReleaseWithoutAsm.ActiveCfg = Release|Win32
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.ReleaseWithoutAsm.Build.0 = Release|Win32
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.ReleaseWithoutCrtdll.ActiveCfg = Release|Win32
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.ReleaseWithoutCrtdll.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- EndGlobalSection
- GlobalSection(ExtensibilityAddIns) = postSolution
- EndGlobalSection
-EndGlobal
diff --git a/source4/lib/zlib/contrib/vstudio/vc7/zlibvc.vcproj b/source4/lib/zlib/contrib/vstudio/vc7/zlibvc.vcproj
deleted file mode 100644
index 8533b49475..0000000000
--- a/source4/lib/zlib/contrib/vstudio/vc7/zlibvc.vcproj
+++ /dev/null
@@ -1,445 +0,0 @@
-<?xml version="1.0" encoding = "Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="7.00"
- Name="zlibvc"
- SccProjectName=""
- SccLocalPath="">
- <Platforms>
- <Platform
- Name="Win32"/>
- </Platforms>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory=".\DebugDll"
- IntermediateDirectory=".\DebugDll"
- ConfigurationType="2"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="FALSE">
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32,ZLIB_WINAPI,ASMV,ASMINF"
- ExceptionHandling="FALSE"
- RuntimeLibrary="1"
- PrecompiledHeaderFile=".\DebugDll/zlibvc.pch"
- AssemblerListingLocation=".\DebugDll/"
- ObjectFile=".\DebugDll/"
- ProgramDataBaseFileName=".\DebugDll/"
- WarningLevel="3"
- SuppressStartupBanner="TRUE"
- DebugInformationFormat="4"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/MACHINE:I386"
- AdditionalDependencies="..\..\masmx86\gvmat32.obj ..\..\masmx86\inffas32.obj"
- OutputFile=".\DebugDll\zlibwapi.dll"
- LinkIncremental="2"
- SuppressStartupBanner="TRUE"
- ModuleDefinitionFile=".\zlibvc.def"
- GenerateDebugInformation="TRUE"
- ProgramDatabaseFile=".\DebugDll/zlibwapi.pdb"
- SubSystem="2"
- ImportLibrary=".\DebugDll/zlibwapi.lib"/>
- <Tool
- Name="VCMIDLTool"
- PreprocessorDefinitions="_DEBUG"
- MkTypLibCompatible="TRUE"
- SuppressStartupBanner="TRUE"
- TargetEnvironment="1"
- TypeLibraryName=".\DebugDll/zlibvc.tlb"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG"
- Culture="1036"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- </Configuration>
- <Configuration
- Name="ReleaseWithoutAsm|Win32"
- OutputDirectory=".\zlibDllWithoutAsm"
- IntermediateDirectory=".\zlibDllWithoutAsm"
- ConfigurationType="2"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="FALSE"
- WholeProgramOptimization="TRUE">
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32,ZLIB_WINAPI"
- StringPooling="TRUE"
- ExceptionHandling="FALSE"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="TRUE"
- PrecompiledHeaderFile=".\zlibDllWithoutAsm/zlibvc.pch"
- AssemblerOutput="2"
- AssemblerListingLocation=".\zlibDllWithoutAsm/"
- ObjectFile=".\zlibDllWithoutAsm/"
- ProgramDataBaseFileName=".\zlibDllWithoutAsm/"
- BrowseInformation="1"
- WarningLevel="3"
- SuppressStartupBanner="TRUE"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/MACHINE:I386"
- AdditionalDependencies="crtdll.lib"
- OutputFile=".\zlibDllWithoutAsm\zlibwapi.dll"
- LinkIncremental="1"
- SuppressStartupBanner="TRUE"
- IgnoreAllDefaultLibraries="TRUE"
- ModuleDefinitionFile=".\zlibvc.def"
- ProgramDatabaseFile=".\zlibDllWithoutAsm/zlibwapi.pdb"
- GenerateMapFile="TRUE"
- MapFileName=".\zlibDllWithoutAsm/zlibwapi.map"
- SubSystem="2"
- OptimizeForWindows98="1"
- ImportLibrary=".\zlibDllWithoutAsm/zlibwapi.lib"/>
- <Tool
- Name="VCMIDLTool"
- PreprocessorDefinitions="NDEBUG"
- MkTypLibCompatible="TRUE"
- SuppressStartupBanner="TRUE"
- TargetEnvironment="1"
- TypeLibraryName=".\zlibDllWithoutAsm/zlibvc.tlb"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
- Culture="1036"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- </Configuration>
- <Configuration
- Name="ReleaseWithoutCrtdll|Win32"
- OutputDirectory=".\zlibDllWithoutCrtDll"
- IntermediateDirectory=".\zlibDllWithoutCrtDll"
- ConfigurationType="2"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="FALSE"
- WholeProgramOptimization="TRUE">
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32,ZLIB_WINAPI,ASMV,ASMINF"
- StringPooling="TRUE"
- ExceptionHandling="FALSE"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="TRUE"
- PrecompiledHeaderFile=".\zlibDllWithoutCrtDll/zlibvc.pch"
- AssemblerOutput="2"
- AssemblerListingLocation=".\zlibDllWithoutCrtDll/"
- ObjectFile=".\zlibDllWithoutCrtDll/"
- ProgramDataBaseFileName=".\zlibDllWithoutCrtDll/"
- BrowseInformation="1"
- WarningLevel="3"
- SuppressStartupBanner="TRUE"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/MACHINE:I386"
- AdditionalDependencies="..\..\masmx86\gvmat32.obj ..\..\masmx86\inffas32.obj "
- OutputFile=".\zlibDllWithoutCrtDll\zlibwapi.dll"
- LinkIncremental="1"
- SuppressStartupBanner="TRUE"
- IgnoreAllDefaultLibraries="FALSE"
- ModuleDefinitionFile=".\zlibvc.def"
- ProgramDatabaseFile=".\zlibDllWithoutCrtDll/zlibwapi.pdb"
- GenerateMapFile="TRUE"
- MapFileName=".\zlibDllWithoutCrtDll/zlibwapi.map"
- SubSystem="2"
- OptimizeForWindows98="1"
- ImportLibrary=".\zlibDllWithoutCrtDll/zlibwapi.lib"/>
- <Tool
- Name="VCMIDLTool"
- PreprocessorDefinitions="NDEBUG"
- MkTypLibCompatible="TRUE"
- SuppressStartupBanner="TRUE"
- TargetEnvironment="1"
- TypeLibraryName=".\zlibDllWithoutCrtDll/zlibvc.tlb"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
- Culture="1036"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- </Configuration>
- <Configuration
- Name="ReleaseAxp|Win32"
- OutputDirectory=".\zlibvc__"
- IntermediateDirectory=".\zlibvc__"
- ConfigurationType="2"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="FALSE"
- WholeProgramOptimization="TRUE">
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32,ZLIB_WINAPI"
- StringPooling="TRUE"
- ExceptionHandling="FALSE"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="TRUE"
- PrecompiledHeaderFile=".\zlibvc__/zlibvc.pch"
- AssemblerOutput="2"
- AssemblerListingLocation=".\zlibvc__/"
- ObjectFile=".\zlibvc__/"
- ProgramDataBaseFileName=".\zlibvc__/"
- BrowseInformation="1"
- WarningLevel="3"
- SuppressStartupBanner="TRUE"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="crtdll.lib"
- OutputFile="zlibvc__\zlibwapi.dll"
- LinkIncremental="1"
- SuppressStartupBanner="TRUE"
- IgnoreAllDefaultLibraries="TRUE"
- ModuleDefinitionFile=".\zlibvc.def"
- ProgramDatabaseFile=".\zlibvc__/zlibwapi.pdb"
- GenerateMapFile="TRUE"
- MapFileName=".\zlibvc__/zlibwapi.map"
- SubSystem="2"
- ImportLibrary=".\zlibvc__/zlibwapi.lib"/>
- <Tool
- Name="VCMIDLTool"
- PreprocessorDefinitions="NDEBUG"
- MkTypLibCompatible="TRUE"
- SuppressStartupBanner="TRUE"
- TargetEnvironment="1"
- TypeLibraryName=".\zlibvc__/zlibvc.tlb"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
- Culture="1036"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory=".\ReleaseDll"
- IntermediateDirectory=".\ReleaseDll"
- ConfigurationType="2"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="FALSE"
- WholeProgramOptimization="TRUE">
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32,ZLIB_WINAPI,ASMV,ASMINF"
- StringPooling="TRUE"
- ExceptionHandling="FALSE"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="TRUE"
- PrecompiledHeaderFile=".\ReleaseDll/zlibvc.pch"
- AssemblerOutput="2"
- AssemblerListingLocation=".\ReleaseDll/"
- ObjectFile=".\ReleaseDll/"
- ProgramDataBaseFileName=".\ReleaseDll/"
- BrowseInformation="1"
- WarningLevel="3"
- SuppressStartupBanner="TRUE"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/MACHINE:I386"
- AdditionalDependencies="..\..\masmx86\gvmat32.obj ..\..\masmx86\inffas32.obj crtdll.lib"
- OutputFile=".\ReleaseDll\zlibwapi.dll"
- LinkIncremental="1"
- SuppressStartupBanner="TRUE"
- IgnoreAllDefaultLibraries="TRUE"
- ModuleDefinitionFile=".\zlibvc.def"
- ProgramDatabaseFile=".\ReleaseDll/zlibwapi.pdb"
- GenerateMapFile="TRUE"
- MapFileName=".\ReleaseDll/zlibwapi.map"
- SubSystem="2"
- OptimizeForWindows98="1"
- ImportLibrary=".\ReleaseDll/zlibwapi.lib"/>
- <Tool
- Name="VCMIDLTool"
- PreprocessorDefinitions="NDEBUG"
- MkTypLibCompatible="TRUE"
- SuppressStartupBanner="TRUE"
- TargetEnvironment="1"
- TypeLibraryName=".\Release/zlibvc.tlb"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
- Culture="1036"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- </Configuration>
- </Configurations>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90">
- <File
- RelativePath="..\..\..\adler32.c">
- </File>
- <File
- RelativePath="..\..\..\compress.c">
- </File>
- <File
- RelativePath="..\..\..\crc32.c">
- </File>
- <File
- RelativePath="..\..\..\deflate.c">
- </File>
- <File
- RelativePath="..\..\masmx86\gvmat32c.c">
- <FileConfiguration
- Name="ReleaseWithoutAsm|Win32"
- ExcludedFromBuild="TRUE">
- <Tool
- Name="VCCLCompilerTool"/>
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\..\gzio.c">
- </File>
- <File
- RelativePath="..\..\..\infback.c">
- </File>
- <File
- RelativePath="..\..\..\inffast.c">
- </File>
- <File
- RelativePath="..\..\..\inflate.c">
- </File>
- <File
- RelativePath="..\..\..\inftrees.c">
- </File>
- <File
- RelativePath="..\..\minizip\ioapi.c">
- </File>
- <File
- RelativePath="..\..\minizip\iowin32.c">
- </File>
- <File
- RelativePath="..\..\..\trees.c">
- </File>
- <File
- RelativePath="..\..\..\uncompr.c">
- </File>
- <File
- RelativePath="..\..\minizip\unzip.c">
- <FileConfiguration
- Name="Release|Win32">
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions="ZLIB_INTERNAL"/>
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\minizip\zip.c">
- <FileConfiguration
- Name="Release|Win32">
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions="ZLIB_INTERNAL"/>
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\zlib.rc">
- </File>
- <File
- RelativePath=".\zlibvc.def">
- </File>
- <File
- RelativePath="..\..\..\zutil.c">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;fi;fd">
- <File
- RelativePath="..\..\..\deflate.h">
- </File>
- <File
- RelativePath="..\..\..\infblock.h">
- </File>
- <File
- RelativePath="..\..\..\infcodes.h">
- </File>
- <File
- RelativePath="..\..\..\inffast.h">
- </File>
- <File
- RelativePath="..\..\..\inftrees.h">
- </File>
- <File
- RelativePath="..\..\..\infutil.h">
- </File>
- <File
- RelativePath="..\..\..\zconf.h">
- </File>
- <File
- RelativePath="..\..\..\zlib.h">
- </File>
- <File
- RelativePath="..\..\..\zutil.h">
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe">
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/source4/lib/zlib/contrib/vstudio/vc8/miniunz.vcproj b/source4/lib/zlib/contrib/vstudio/vc8/miniunz.vcproj
deleted file mode 100644
index 4af53e8a31..0000000000
--- a/source4/lib/zlib/contrib/vstudio/vc8/miniunz.vcproj
+++ /dev/null
@@ -1,566 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8,00"
- Name="miniunz"
- ProjectGUID="{C52F9E7B-498A-42BE-8DB4-85A15694382A}"
- Keyword="Win32Proj"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- <Platform
- Name="Itanium"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="x86\MiniUnzip$(ConfigurationName)"
- IntermediateDirectory="x86\MiniUnzip$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE"
- MinimalRebuild="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="1"
- BufferSecurityCheck="false"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="x86\ZlibDllDebug\zlibwapi.lib"
- OutputFile="$(OutDir)/miniunz.exe"
- LinkIncremental="2"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/miniunz.pdb"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="x64\MiniUnzip$(ConfigurationName)"
- IntermediateDirectory="x64\MiniUnzip$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64"
- MinimalRebuild="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="3"
- BufferSecurityCheck="false"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="x64\ZlibDllDebug\zlibwapi.lib"
- OutputFile="$(OutDir)/miniunz.exe"
- LinkIncremental="2"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/miniunz.pdb"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|Itanium"
- OutputDirectory="ia64\MiniUnzip$(ConfigurationName)"
- IntermediateDirectory="ia64\MiniUnzip$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="2"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64"
- MinimalRebuild="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="3"
- BufferSecurityCheck="false"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ia64\ZlibDllDebug\zlibwapi.lib"
- OutputFile="$(OutDir)/miniunz.exe"
- LinkIncremental="2"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/miniunz.pdb"
- SubSystem="1"
- TargetMachine="5"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="x86\MiniUnzip$(ConfigurationName)"
- IntermediateDirectory="x86\MiniUnzip$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- OmitFramePointers="true"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE"
- StringPooling="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="0"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="x86\ZlibDllRelease\zlibwapi.lib"
- OutputFile="$(OutDir)/miniunz.exe"
- LinkIncremental="1"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- OptimizeForWindows98="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="x64\MiniUnzip$(ConfigurationName)"
- IntermediateDirectory="x64\MiniUnzip$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- OmitFramePointers="true"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64"
- StringPooling="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="x64\ZlibDllRelease\zlibwapi.lib"
- OutputFile="$(OutDir)/miniunz.exe"
- LinkIncremental="1"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- OptimizeForWindows98="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Itanium"
- OutputDirectory="ia64\MiniUnzip$(ConfigurationName)"
- IntermediateDirectory="ia64\MiniUnzip$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="2"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- OmitFramePointers="true"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64"
- StringPooling="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ia64\ZlibDllRelease\zlibwapi.lib"
- OutputFile="$(OutDir)/miniunz.exe"
- LinkIncremental="1"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- OptimizeForWindows98="1"
- TargetMachine="5"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"
- >
- <File
- RelativePath="..\..\minizip\miniunz.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc"
- >
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
- >
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/source4/lib/zlib/contrib/vstudio/vc8/minizip.vcproj b/source4/lib/zlib/contrib/vstudio/vc8/minizip.vcproj
deleted file mode 100644
index 85f64c4d2a..0000000000
--- a/source4/lib/zlib/contrib/vstudio/vc8/minizip.vcproj
+++ /dev/null
@@ -1,563 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8,00"
- Name="minizip"
- ProjectGUID="{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}"
- Keyword="Win32Proj"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- <Platform
- Name="Itanium"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="x86\MiniZip$(ConfigurationName)"
- IntermediateDirectory="x86\MiniZip$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE"
- MinimalRebuild="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="1"
- BufferSecurityCheck="false"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="x86\ZlibDllDebug\zlibwapi.lib"
- OutputFile="$(OutDir)/minizip.exe"
- LinkIncremental="2"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/minizip.pdb"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="x64\$(ConfigurationName)"
- IntermediateDirectory="x64\$(ConfigurationName)"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64"
- MinimalRebuild="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="3"
- BufferSecurityCheck="false"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="x64\ZlibDllDebug\zlibwapi.lib"
- OutputFile="$(OutDir)/minizip.exe"
- LinkIncremental="2"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/minizip.pdb"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|Itanium"
- OutputDirectory="ia64\$(ConfigurationName)"
- IntermediateDirectory="ia64\$(ConfigurationName)"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="2"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64"
- MinimalRebuild="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="3"
- BufferSecurityCheck="false"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ia64\ZlibDllDebug\zlibwapi.lib"
- OutputFile="$(OutDir)/minizip.exe"
- LinkIncremental="2"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/minizip.pdb"
- SubSystem="1"
- TargetMachine="5"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="x86\MiniZip$(ConfigurationName)"
- IntermediateDirectory="x86\MiniZip$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- OmitFramePointers="true"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE"
- StringPooling="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="0"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="x86\ZlibDllRelease\zlibwapi.lib"
- OutputFile="$(OutDir)/minizip.exe"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- OptimizeForWindows98="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="x64\$(ConfigurationName)"
- IntermediateDirectory="x64\$(ConfigurationName)"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- OmitFramePointers="true"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64"
- StringPooling="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="x64\ZlibDllRelease\zlibwapi.lib"
- OutputFile="$(OutDir)/minizip.exe"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- OptimizeForWindows98="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Itanium"
- OutputDirectory="ia64\$(ConfigurationName)"
- IntermediateDirectory="ia64\$(ConfigurationName)"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="2"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- OmitFramePointers="true"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64"
- StringPooling="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ia64\ZlibDllRelease\zlibwapi.lib"
- OutputFile="$(OutDir)/minizip.exe"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- OptimizeForWindows98="1"
- TargetMachine="5"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"
- >
- <File
- RelativePath="..\..\minizip\minizip.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc"
- >
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
- >
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/source4/lib/zlib/contrib/vstudio/vc8/testzlib.vcproj b/source4/lib/zlib/contrib/vstudio/vc8/testzlib.vcproj
deleted file mode 100644
index 68c3539911..0000000000
--- a/source4/lib/zlib/contrib/vstudio/vc8/testzlib.vcproj
+++ /dev/null
@@ -1,948 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8,00"
- Name="testzlib"
- ProjectGUID="{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}"
- RootNamespace="testzlib"
- Keyword="Win32Proj"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- <Platform
- Name="Itanium"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="x86\TestZlib$(ConfigurationName)"
- IntermediateDirectory="x86\TestZlib$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\.."
- PreprocessorDefinitions="ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE"
- MinimalRebuild="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="1"
- BufferSecurityCheck="false"
- UsePrecompiledHeader="0"
- AssemblerOutput="4"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="..\..\masmx86\gvmat32.obj ..\..\masmx86\inffas32.obj"
- OutputFile="$(OutDir)/testzlib.exe"
- LinkIncremental="2"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/testzlib.pdb"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="x64\TestZlib$(ConfigurationName)"
- IntermediateDirectory="x64\TestZlib$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\.."
- PreprocessorDefinitions="ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE"
- BasicRuntimeChecks="0"
- RuntimeLibrary="3"
- BufferSecurityCheck="false"
- AssemblerListingLocation="$(IntDir)\"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="..\..\masmx64\gvmat64.obj ..\..\masmx64\inffasx64.obj"
- GenerateManifest="false"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|Itanium"
- OutputDirectory="ia64\TestZlib$(ConfigurationName)"
- IntermediateDirectory="ia64\TestZlib$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="2"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\.."
- PreprocessorDefinitions="ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;WIN64"
- MinimalRebuild="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="3"
- BufferSecurityCheck="false"
- UsePrecompiledHeader="0"
- AssemblerOutput="4"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)/testzlib.exe"
- LinkIncremental="2"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/testzlib.pdb"
- SubSystem="1"
- TargetMachine="5"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="ReleaseWithoutAsm|Win32"
- OutputDirectory="x86\TestZlib$(ConfigurationName)"
- IntermediateDirectory="x86\TestZlib$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- OmitFramePointers="true"
- AdditionalIncludeDirectories="..\..\.."
- PreprocessorDefinitions="WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE"
- StringPooling="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="0"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)/testzlib.exe"
- LinkIncremental="1"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- OptimizeForWindows98="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="ReleaseWithoutAsm|x64"
- OutputDirectory="x64\TestZlib$(ConfigurationName)"
- IntermediateDirectory="x64\TestZlib$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\.."
- PreprocessorDefinitions="WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE"
- BasicRuntimeChecks="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- AssemblerListingLocation="$(IntDir)\"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies=""
- GenerateManifest="false"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="ReleaseWithoutAsm|Itanium"
- OutputDirectory="ia64\TestZlib$(ConfigurationName)"
- IntermediateDirectory="ia64\TestZlib$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="2"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- OmitFramePointers="true"
- AdditionalIncludeDirectories="..\..\.."
- PreprocessorDefinitions="ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;WIN64"
- StringPooling="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)/testzlib.exe"
- LinkIncremental="1"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- OptimizeForWindows98="1"
- TargetMachine="5"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="x86\TestZlib$(ConfigurationName)"
- IntermediateDirectory="x86\TestZlib$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- OmitFramePointers="true"
- AdditionalIncludeDirectories="..\..\.."
- PreprocessorDefinitions="ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE"
- StringPooling="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="0"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="..\..\masmx86\gvmat32.obj ..\..\masmx86\inffas32.obj"
- OutputFile="$(OutDir)/testzlib.exe"
- LinkIncremental="1"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- OptimizeForWindows98="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="x64\TestZlib$(ConfigurationName)"
- IntermediateDirectory="x64\TestZlib$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\.."
- PreprocessorDefinitions="ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE"
- BasicRuntimeChecks="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- AssemblerListingLocation="$(IntDir)\"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="..\..\masmx64\gvmat64.obj ..\..\masmx64\inffasx64.obj"
- GenerateManifest="false"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Itanium"
- OutputDirectory="ia64\TestZlib$(ConfigurationName)"
- IntermediateDirectory="ia64\TestZlib$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="2"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- OmitFramePointers="true"
- AdditionalIncludeDirectories="..\..\.."
- PreprocessorDefinitions="ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;WIN64"
- StringPooling="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)/testzlib.exe"
- LinkIncremental="1"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- OptimizeForWindows98="1"
- TargetMachine="5"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"
- >
- <File
- RelativePath="..\..\..\adler32.c"
- >
- </File>
- <File
- RelativePath="..\..\..\compress.c"
- >
- </File>
- <File
- RelativePath="..\..\..\crc32.c"
- >
- </File>
- <File
- RelativePath="..\..\..\deflate.c"
- >
- </File>
- <File
- RelativePath="..\..\masmx86\gvmat32c.c"
- >
- <FileConfiguration
- Name="Debug|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="ReleaseWithoutAsm|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="ReleaseWithoutAsm|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win64 (AMD64)"
- ExcludedFromBuild="TRUE"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win64 (AMD64)"
- ExcludedFromBuild="TRUE"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="ReleaseAsm|Win64 (AMD64)"
- ExcludedFromBuild="TRUE"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\..\infback.c"
- >
- </File>
- <File
- RelativePath="..\..\masmx64\inffas8664.c"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="ReleaseWithoutAsm|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="ReleaseWithoutAsm|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\..\inffast.c"
- >
- </File>
- <File
- RelativePath="..\..\..\inflate.c"
- >
- </File>
- <File
- RelativePath="..\..\..\inftrees.c"
- >
- </File>
- <File
- RelativePath="..\..\testzlib\testzlib.c"
- >
- </File>
- <File
- RelativePath="..\..\..\trees.c"
- >
- </File>
- <File
- RelativePath="..\..\..\uncompr.c"
- >
- </File>
- <File
- RelativePath="..\..\..\zutil.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc"
- >
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
- >
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/source4/lib/zlib/contrib/vstudio/vc8/testzlibdll.vcproj b/source4/lib/zlib/contrib/vstudio/vc8/testzlibdll.vcproj
deleted file mode 100644
index f38ab5e08a..0000000000
--- a/source4/lib/zlib/contrib/vstudio/vc8/testzlibdll.vcproj
+++ /dev/null
@@ -1,567 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8,00"
- Name="TestZlibDll"
- ProjectGUID="{C52F9E7B-498A-42BE-8DB4-85A15694366A}"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- <Platform
- Name="Itanium"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="x86\TestZlibDll$(ConfigurationName)"
- IntermediateDirectory="x86\TestZlibDll$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE"
- MinimalRebuild="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="1"
- BufferSecurityCheck="false"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="x86\ZlibDllDebug\zlibwapi.lib"
- OutputFile="$(OutDir)/testzlib.exe"
- LinkIncremental="2"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/testzlib.pdb"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="x64\TestZlibDll$(ConfigurationName)"
- IntermediateDirectory="x64\TestZlibDll$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64"
- MinimalRebuild="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="3"
- BufferSecurityCheck="false"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="x64\ZlibDllDebug\zlibwapi.lib"
- OutputFile="$(OutDir)/testzlib.exe"
- LinkIncremental="2"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/testzlib.pdb"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|Itanium"
- OutputDirectory="ia64\TestZlibDll$(ConfigurationName)"
- IntermediateDirectory="ia64\TestZlibDll$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="2"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64"
- MinimalRebuild="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="3"
- BufferSecurityCheck="false"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ia64\ZlibDllDebug\zlibwapi.lib"
- OutputFile="$(OutDir)/testzlib.exe"
- LinkIncremental="2"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/testzlib.pdb"
- SubSystem="1"
- TargetMachine="5"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="x86\TestZlibDll$(ConfigurationName)"
- IntermediateDirectory="x86\TestZlibDll$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- OmitFramePointers="true"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE"
- StringPooling="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="0"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="x86\ZlibDllRelease\zlibwapi.lib"
- OutputFile="$(OutDir)/testzlib.exe"
- LinkIncremental="1"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- OptimizeForWindows98="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="x64\TestZlibDll$(ConfigurationName)"
- IntermediateDirectory="x64\TestZlibDll$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- OmitFramePointers="true"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64"
- StringPooling="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="x64\ZlibDllRelease\zlibwapi.lib"
- OutputFile="$(OutDir)/testzlib.exe"
- LinkIncremental="1"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- OptimizeForWindows98="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Itanium"
- OutputDirectory="ia64\TestZlibDll$(ConfigurationName)"
- IntermediateDirectory="ia64\TestZlibDll$(ConfigurationName)\Tmp"
- ConfigurationType="1"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="2"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- OmitFramePointers="true"
- AdditionalIncludeDirectories="..\..\..;..\..\minizip"
- PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64"
- StringPooling="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- AssemblerListingLocation="$(IntDir)\"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ia64\ZlibDllRelease\zlibwapi.lib"
- OutputFile="$(OutDir)/testzlib.exe"
- LinkIncremental="1"
- GenerateManifest="false"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- OptimizeForWindows98="1"
- TargetMachine="5"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"
- >
- <File
- RelativePath="..\..\testzlib\testzlib.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc"
- >
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
- >
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/source4/lib/zlib/contrib/vstudio/vc8/zlib.rc b/source4/lib/zlib/contrib/vstudio/vc8/zlib.rc
deleted file mode 100644
index 72cb8b4c31..0000000000
--- a/source4/lib/zlib/contrib/vstudio/vc8/zlib.rc
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <windows.h>
-
-#define IDR_VERSION1 1
-IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
- FILEVERSION 1,2,3,0
- PRODUCTVERSION 1,2,3,0
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
- FILEFLAGS 0
- FILEOS VOS_DOS_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE 0 // not used
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904E4"
- //language ID = U.S. English, char set = Windows, Multilingual
-
- BEGIN
- VALUE "FileDescription", "zlib data compression library\0"
- VALUE "FileVersion", "1.2.3.0\0"
- VALUE "InternalName", "zlib\0"
- VALUE "OriginalFilename", "zlib.dll\0"
- VALUE "ProductName", "ZLib.DLL\0"
- VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
- VALUE "LegalCopyright", "(C) 1995-2003 Jean-loup Gailly & Mark Adler\0"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x0409, 1252
- END
-END
diff --git a/source4/lib/zlib/contrib/vstudio/vc8/zlibstat.vcproj b/source4/lib/zlib/contrib/vstudio/vc8/zlibstat.vcproj
deleted file mode 100644
index fb97037acf..0000000000
--- a/source4/lib/zlib/contrib/vstudio/vc8/zlibstat.vcproj
+++ /dev/null
@@ -1,870 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8,00"
- Name="zlibstat"
- ProjectGUID="{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- <Platform
- Name="Itanium"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="x86\ZlibStat$(ConfigurationName)"
- IntermediateDirectory="x86\ZlibStat$(ConfigurationName)\Tmp"
- ConfigurationType="4"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE"
- ExceptionHandling="0"
- RuntimeLibrary="1"
- BufferSecurityCheck="false"
- PrecompiledHeaderFile="$(IntDir)/zlibstat.pch"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- WarningLevel="3"
- SuppressStartupBanner="true"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="1"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- AdditionalOptions="/MACHINE:X86 /NODEFAULTLIB"
- OutputFile="$(OutDir)\zlibstat.lib"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="x64\ZlibStat$(ConfigurationName)"
- IntermediateDirectory="x64\ZlibStat$(ConfigurationName)\Tmp"
- ConfigurationType="4"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;WIN64"
- ExceptionHandling="0"
- RuntimeLibrary="3"
- BufferSecurityCheck="false"
- PrecompiledHeaderFile="$(IntDir)/zlibstat.pch"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- WarningLevel="3"
- SuppressStartupBanner="true"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="1"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- AdditionalOptions="/MACHINE:AMD64 /NODEFAULTLIB"
- OutputFile="$(OutDir)\zlibstat.lib"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|Itanium"
- OutputDirectory="ia64\ZlibStat$(ConfigurationName)"
- IntermediateDirectory="ia64\ZlibStat$(ConfigurationName)\Tmp"
- ConfigurationType="4"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="2"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;WIN64"
- ExceptionHandling="0"
- RuntimeLibrary="3"
- BufferSecurityCheck="false"
- PrecompiledHeaderFile="$(IntDir)/zlibstat.pch"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- WarningLevel="3"
- SuppressStartupBanner="true"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="1"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- AdditionalOptions="/MACHINE:IA64 /NODEFAULTLIB"
- OutputFile="$(OutDir)\zlibstat.lib"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="x86\ZlibStat$(ConfigurationName)"
- IntermediateDirectory="x86\ZlibStat$(ConfigurationName)\Tmp"
- ConfigurationType="4"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ASMV;ASMINF"
- StringPooling="true"
- ExceptionHandling="0"
- RuntimeLibrary="0"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- PrecompiledHeaderFile="$(IntDir)/zlibstat.pch"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- WarningLevel="3"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- AdditionalOptions="/MACHINE:X86 /NODEFAULTLIB"
- AdditionalDependencies="..\..\masmx86\gvmat32.obj ..\..\masmx86\inffas32.obj "
- OutputFile="$(OutDir)\zlibstat.lib"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="x64\ZlibStat$(ConfigurationName)"
- IntermediateDirectory="x64\ZlibStat$(ConfigurationName)\Tmp"
- ConfigurationType="4"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ASMV;ASMINF;WIN64"
- StringPooling="true"
- ExceptionHandling="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- PrecompiledHeaderFile="$(IntDir)/zlibstat.pch"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- WarningLevel="3"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- AdditionalOptions="/MACHINE:AMD64 /NODEFAULTLIB"
- AdditionalDependencies="..\..\masmx64\gvmat64.obj ..\..\masmx64\inffasx64.obj "
- OutputFile="$(OutDir)\zlibstat.lib"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Itanium"
- OutputDirectory="ia64\ZlibStat$(ConfigurationName)"
- IntermediateDirectory="ia64\ZlibStat$(ConfigurationName)\Tmp"
- ConfigurationType="4"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="2"
- />
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;WIN64"
- StringPooling="true"
- ExceptionHandling="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- PrecompiledHeaderFile="$(IntDir)/zlibstat.pch"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- WarningLevel="3"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- AdditionalOptions="/MACHINE:IA64 /NODEFAULTLIB"
- OutputFile="$(OutDir)\zlibstat.lib"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="ReleaseWithoutAsm|Win32"
- OutputDirectory="x86\ZlibStat$(ConfigurationName)"
- IntermediateDirectory="x86\ZlibStat$(ConfigurationName)\Tmp"
- ConfigurationType="4"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE"
- StringPooling="true"
- ExceptionHandling="0"
- RuntimeLibrary="0"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- PrecompiledHeaderFile="$(IntDir)/zlibstat.pch"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- WarningLevel="3"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- AdditionalOptions="/MACHINE:X86 /NODEFAULTLIB"
- OutputFile="$(OutDir)\zlibstat.lib"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="ReleaseWithoutAsm|x64"
- OutputDirectory="x64\ZlibStat$(ConfigurationName)"
- IntermediateDirectory="x64\ZlibStat$(ConfigurationName)\Tmp"
- ConfigurationType="4"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;WIN64"
- StringPooling="true"
- ExceptionHandling="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- PrecompiledHeaderFile="$(IntDir)/zlibstat.pch"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- WarningLevel="3"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- AdditionalOptions="/MACHINE:AMD64 /NODEFAULTLIB"
- OutputFile="$(OutDir)\zlibstat.lib"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="ReleaseWithoutAsm|Itanium"
- OutputDirectory="ia64\ZlibStat$(ConfigurationName)"
- IntermediateDirectory="ia64\ZlibStat$(ConfigurationName)\Tmp"
- ConfigurationType="4"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="2"
- />
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;WIN64"
- StringPooling="true"
- ExceptionHandling="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- PrecompiledHeaderFile="$(IntDir)/zlibstat.pch"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- WarningLevel="3"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- AdditionalOptions="/MACHINE:IA64 /NODEFAULTLIB"
- OutputFile="$(OutDir)\zlibstat.lib"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- >
- <File
- RelativePath="..\..\..\adler32.c"
- >
- </File>
- <File
- RelativePath="..\..\..\compress.c"
- >
- </File>
- <File
- RelativePath="..\..\..\crc32.c"
- >
- </File>
- <File
- RelativePath="..\..\..\deflate.c"
- >
- </File>
- <File
- RelativePath="..\..\masmx86\gvmat32c.c"
- >
- <FileConfiguration
- Name="Debug|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="ReleaseWithoutAsm|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="ReleaseWithoutAsm|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\..\gzio.c"
- >
- </File>
- <File
- RelativePath="..\..\..\infback.c"
- >
- </File>
- <File
- RelativePath="..\..\masmx64\inffas8664.c"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="ReleaseWithoutAsm|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="ReleaseWithoutAsm|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\..\inffast.c"
- >
- </File>
- <File
- RelativePath="..\..\..\inflate.c"
- >
- </File>
- <File
- RelativePath="..\..\..\inftrees.c"
- >
- </File>
- <File
- RelativePath="..\..\minizip\ioapi.c"
- >
- </File>
- <File
- RelativePath="..\..\..\trees.c"
- >
- </File>
- <File
- RelativePath="..\..\..\uncompr.c"
- >
- </File>
- <File
- RelativePath="..\..\minizip\unzip.c"
- >
- </File>
- <File
- RelativePath="..\..\minizip\zip.c"
- >
- </File>
- <File
- RelativePath=".\zlib.rc"
- >
- </File>
- <File
- RelativePath=".\zlibvc.def"
- >
- </File>
- <File
- RelativePath="..\..\..\zutil.c"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/source4/lib/zlib/contrib/vstudio/vc8/zlibvc.def b/source4/lib/zlib/contrib/vstudio/vc8/zlibvc.def
deleted file mode 100644
index a40e71541f..0000000000
--- a/source4/lib/zlib/contrib/vstudio/vc8/zlibvc.def
+++ /dev/null
@@ -1,92 +0,0 @@
-
-VERSION 1.23
-
-HEAPSIZE 1048576,8192
-
-EXPORTS
- adler32 @1
- compress @2
- crc32 @3
- deflate @4
- deflateCopy @5
- deflateEnd @6
- deflateInit2_ @7
- deflateInit_ @8
- deflateParams @9
- deflateReset @10
- deflateSetDictionary @11
- gzclose @12
- gzdopen @13
- gzerror @14
- gzflush @15
- gzopen @16
- gzread @17
- gzwrite @18
- inflate @19
- inflateEnd @20
- inflateInit2_ @21
- inflateInit_ @22
- inflateReset @23
- inflateSetDictionary @24
- inflateSync @25
- uncompress @26
- zlibVersion @27
- gzprintf @28
- gzputc @29
- gzgetc @30
- gzseek @31
- gzrewind @32
- gztell @33
- gzeof @34
- gzsetparams @35
- zError @36
- inflateSyncPoint @37
- get_crc_table @38
- compress2 @39
- gzputs @40
- gzgets @41
- inflateCopy @42
- inflateBackInit_ @43
- inflateBack @44
- inflateBackEnd @45
- compressBound @46
- deflateBound @47
- gzclearerr @48
- gzungetc @49
- zlibCompileFlags @50
- deflatePrime @51
-
- unzOpen @61
- unzClose @62
- unzGetGlobalInfo @63
- unzGetCurrentFileInfo @64
- unzGoToFirstFile @65
- unzGoToNextFile @66
- unzOpenCurrentFile @67
- unzReadCurrentFile @68
- unzOpenCurrentFile3 @69
- unztell @70
- unzeof @71
- unzCloseCurrentFile @72
- unzGetGlobalComment @73
- unzStringFileNameCompare @74
- unzLocateFile @75
- unzGetLocalExtrafield @76
- unzOpen2 @77
- unzOpenCurrentFile2 @78
- unzOpenCurrentFilePassword @79
-
- zipOpen @80
- zipOpenNewFileInZip @81
- zipWriteInFileInZip @82
- zipCloseFileInZip @83
- zipClose @84
- zipOpenNewFileInZip2 @86
- zipCloseFileInZipRaw @87
- zipOpen2 @88
- zipOpenNewFileInZip3 @89
-
- unzGetFilePos @100
- unzGoToFilePos @101
-
- fill_win32_filefunc @110
diff --git a/source4/lib/zlib/contrib/vstudio/vc8/zlibvc.sln b/source4/lib/zlib/contrib/vstudio/vc8/zlibvc.sln
deleted file mode 100644
index a815a5549f..0000000000
--- a/source4/lib/zlib/contrib/vstudio/vc8/zlibvc.sln
+++ /dev/null
@@ -1,144 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestZlibDll", "testzlibdll.vcproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}"
- ProjectSection(ProjectDependencies) = postProject
- {8FD826F8-3739-44E6-8CC8-997122E53B8D} = {8FD826F8-3739-44E6-8CC8-997122E53B8D}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}"
- ProjectSection(ProjectDependencies) = postProject
- {8FD826F8-3739-44E6-8CC8-997122E53B8D} = {8FD826F8-3739-44E6-8CC8-997122E53B8D}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}"
- ProjectSection(ProjectDependencies) = postProject
- {8FD826F8-3739-44E6-8CC8-997122E53B8D} = {8FD826F8-3739-44E6-8CC8-997122E53B8D}
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Itanium = Debug|Itanium
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Itanium = Release|Itanium
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- ReleaseWithoutAsm|Itanium = ReleaseWithoutAsm|Itanium
- ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32
- ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.ActiveCfg = Debug|Itanium
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.Build.0 = Debug|Itanium
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.ActiveCfg = Release|Itanium
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.Build.0 = Release|Itanium
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = ReleaseWithoutAsm|x64
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = ReleaseWithoutAsm|x64
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64
- {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.ActiveCfg = Debug|Itanium
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.Build.0 = Debug|Itanium
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.ActiveCfg = Release|Itanium
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.Build.0 = Release|Itanium
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64
- {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Itanium
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.Build.0 = Debug|Itanium
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Itanium
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.Build.0 = Release|Itanium
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64
- {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64
- {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.ActiveCfg = Debug|Itanium
- {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.Build.0 = Debug|Itanium
- {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64
- {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64
- {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.ActiveCfg = Release|Itanium
- {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.Build.0 = Release|Itanium
- {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64
- {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64
- {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium
- {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium
- {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Itanium
- {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|Itanium
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Itanium
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.Build.0 = Debug|Itanium
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Itanium
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.Build.0 = Release|Itanium
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Itanium
- {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|Itanium
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.ActiveCfg = Debug|Itanium
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.Build.0 = Debug|Itanium
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.ActiveCfg = Release|Itanium
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.Build.0 = Release|Itanium
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Itanium
- {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|Itanium
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/source4/lib/zlib/contrib/vstudio/vc8/zlibvc.vcproj b/source4/lib/zlib/contrib/vstudio/vc8/zlibvc.vcproj
deleted file mode 100644
index e717011df7..0000000000
--- a/source4/lib/zlib/contrib/vstudio/vc8/zlibvc.vcproj
+++ /dev/null
@@ -1,1219 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8,00"
- Name="zlibvc"
- ProjectGUID="{8FD826F8-3739-44E6-8CC8-997122E53B8D}"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- <Platform
- Name="Itanium"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="x86\ZlibDll$(ConfigurationName)"
- IntermediateDirectory="x86\ZlibDll$(ConfigurationName)\Tmp"
- ConfigurationType="2"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- PreprocessorDefinitions="_DEBUG"
- MkTypLibCompatible="true"
- SuppressStartupBanner="true"
- TargetEnvironment="1"
- TypeLibraryName="$(OutDir)/zlibvc.tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32,_CRT_SECURE_NO_DEPRECATE,ZLIB_WINAPI,ASMV,ASMINF"
- ExceptionHandling="0"
- RuntimeLibrary="1"
- BufferSecurityCheck="false"
- PrecompiledHeaderFile="$(IntDir)/zlibvc.pch"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- BrowseInformation="0"
- WarningLevel="3"
- SuppressStartupBanner="true"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/MACHINE:I386"
- AdditionalDependencies="..\..\masmx86\gvmat32.obj ..\..\masmx86\inffas32.obj"
- OutputFile="$(OutDir)\zlibwapi.dll"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- GenerateManifest="false"
- ModuleDefinitionFile=".\zlibvc.def"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/zlibwapi.pdb"
- GenerateMapFile="true"
- MapFileName="$(OutDir)/zlibwapi.map"
- SubSystem="2"
- ImportLibrary="$(OutDir)/zlibwapi.lib"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="x64\ZlibDll$(ConfigurationName)"
- IntermediateDirectory="x64\ZlibDll$(ConfigurationName)\Tmp"
- ConfigurationType="2"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- PreprocessorDefinitions="_DEBUG"
- MkTypLibCompatible="true"
- SuppressStartupBanner="true"
- TargetEnvironment="3"
- TypeLibraryName="$(OutDir)/zlibvc.tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32,_CRT_SECURE_NO_DEPRECATE,ZLIB_WINAPI,ASMV,ASMINF;WIN64"
- ExceptionHandling="0"
- RuntimeLibrary="3"
- BufferSecurityCheck="false"
- PrecompiledHeaderFile="$(IntDir)/zlibvc.pch"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- BrowseInformation="0"
- WarningLevel="3"
- SuppressStartupBanner="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="..\..\masmx64\gvmat64.obj ..\..\masmx64\inffasx64.obj "
- OutputFile="$(OutDir)\zlibwapi.dll"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- GenerateManifest="false"
- ModuleDefinitionFile=".\zlibvc.def"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/zlibwapi.pdb"
- GenerateMapFile="true"
- MapFileName="$(OutDir)/zlibwapi.map"
- SubSystem="2"
- ImportLibrary="$(OutDir)/zlibwapi.lib"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|Itanium"
- OutputDirectory="ia64\ZlibDll$(ConfigurationName)"
- IntermediateDirectory="ia64\ZlibDll$(ConfigurationName)\Tmp"
- ConfigurationType="2"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- PreprocessorDefinitions="_DEBUG"
- MkTypLibCompatible="true"
- SuppressStartupBanner="true"
- TargetEnvironment="2"
- TypeLibraryName="$(OutDir)/zlibvc.tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;WIN64"
- ExceptionHandling="0"
- RuntimeLibrary="3"
- BufferSecurityCheck="false"
- PrecompiledHeaderFile="$(IntDir)/zlibvc.pch"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- BrowseInformation="0"
- WarningLevel="3"
- SuppressStartupBanner="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\zlibwapi.dll"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- GenerateManifest="false"
- ModuleDefinitionFile=".\zlibvc.def"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/zlibwapi.pdb"
- GenerateMapFile="true"
- MapFileName="$(OutDir)/zlibwapi.map"
- SubSystem="2"
- ImportLibrary="$(OutDir)/zlibwapi.lib"
- TargetMachine="5"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="ReleaseWithoutAsm|Win32"
- OutputDirectory="x86\ZlibDll$(ConfigurationName)"
- IntermediateDirectory="x86\ZlibDll$(ConfigurationName)\Tmp"
- ConfigurationType="2"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- PreprocessorDefinitions="NDEBUG"
- MkTypLibCompatible="true"
- SuppressStartupBanner="true"
- TargetEnvironment="1"
- TypeLibraryName="$(OutDir)/zlibvc.tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32,_CRT_SECURE_NO_DEPRECATE,ZLIB_WINAPI"
- StringPooling="true"
- ExceptionHandling="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- PrecompiledHeaderFile="$(IntDir)/zlibvc.pch"
- AssemblerOutput="2"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- BrowseInformation="0"
- WarningLevel="3"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/MACHINE:I386"
- OutputFile="$(OutDir)\zlibwapi.dll"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- GenerateManifest="false"
- IgnoreAllDefaultLibraries="false"
- ModuleDefinitionFile=".\zlibvc.def"
- ProgramDatabaseFile="$(OutDir)/zlibwapi.pdb"
- GenerateMapFile="true"
- MapFileName="$(OutDir)/zlibwapi.map"
- SubSystem="2"
- OptimizeForWindows98="1"
- ImportLibrary="$(OutDir)/zlibwapi.lib"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="ReleaseWithoutAsm|x64"
- OutputDirectory="x64\ZlibDll$(ConfigurationName)"
- IntermediateDirectory="x64\ZlibDll$(ConfigurationName)\Tmp"
- ConfigurationType="2"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- PreprocessorDefinitions="NDEBUG"
- MkTypLibCompatible="true"
- SuppressStartupBanner="true"
- TargetEnvironment="3"
- TypeLibraryName="$(OutDir)/zlibvc.tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32,_CRT_SECURE_NO_DEPRECATE,ZLIB_WINAPI;WIN64"
- StringPooling="true"
- ExceptionHandling="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- PrecompiledHeaderFile="$(IntDir)/zlibvc.pch"
- AssemblerOutput="2"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- BrowseInformation="0"
- WarningLevel="3"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\zlibwapi.dll"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- GenerateManifest="false"
- IgnoreAllDefaultLibraries="false"
- ModuleDefinitionFile=".\zlibvc.def"
- ProgramDatabaseFile="$(OutDir)/zlibwapi.pdb"
- GenerateMapFile="true"
- MapFileName="$(OutDir)/zlibwapi.map"
- SubSystem="2"
- OptimizeForWindows98="1"
- ImportLibrary="$(OutDir)/zlibwapi.lib"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="ReleaseWithoutAsm|Itanium"
- OutputDirectory="ia64\ZlibDll$(ConfigurationName)"
- IntermediateDirectory="ia64\ZlibDll$(ConfigurationName)\Tmp"
- ConfigurationType="2"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- PreprocessorDefinitions="NDEBUG"
- MkTypLibCompatible="true"
- SuppressStartupBanner="true"
- TargetEnvironment="2"
- TypeLibraryName="$(OutDir)/zlibvc.tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32,_CRT_SECURE_NO_DEPRECATE,ZLIB_WINAPI;WIN64"
- StringPooling="true"
- ExceptionHandling="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- PrecompiledHeaderFile="$(IntDir)/zlibvc.pch"
- AssemblerOutput="2"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- BrowseInformation="0"
- WarningLevel="3"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\zlibwapi.dll"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- GenerateManifest="false"
- IgnoreAllDefaultLibraries="false"
- ModuleDefinitionFile=".\zlibvc.def"
- ProgramDatabaseFile="$(OutDir)/zlibwapi.pdb"
- GenerateMapFile="true"
- MapFileName="$(OutDir)/zlibwapi.map"
- SubSystem="2"
- OptimizeForWindows98="1"
- ImportLibrary="$(OutDir)/zlibwapi.lib"
- TargetMachine="5"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="x86\ZlibDll$(ConfigurationName)"
- IntermediateDirectory="x86\ZlibDll$(ConfigurationName)\Tmp"
- ConfigurationType="2"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- PreprocessorDefinitions="NDEBUG"
- MkTypLibCompatible="true"
- SuppressStartupBanner="true"
- TargetEnvironment="1"
- TypeLibraryName="$(OutDir)/zlibvc.tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;ASMV;ASMINF"
- StringPooling="true"
- ExceptionHandling="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- PrecompiledHeaderFile="$(IntDir)/zlibvc.pch"
- AssemblerOutput="2"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- BrowseInformation="0"
- WarningLevel="3"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/MACHINE:I386"
- AdditionalDependencies="..\..\masmx86\gvmat32.obj ..\..\masmx86\inffas32.obj "
- OutputFile="$(OutDir)\zlibwapi.dll"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- GenerateManifest="false"
- IgnoreAllDefaultLibraries="false"
- ModuleDefinitionFile=".\zlibvc.def"
- ProgramDatabaseFile="$(OutDir)/zlibwapi.pdb"
- GenerateMapFile="true"
- MapFileName="$(OutDir)/zlibwapi.map"
- SubSystem="2"
- OptimizeForWindows98="1"
- ImportLibrary="$(OutDir)/zlibwapi.lib"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="x64\ZlibDll$(ConfigurationName)"
- IntermediateDirectory="x64\ZlibDll$(ConfigurationName)\Tmp"
- ConfigurationType="2"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- PreprocessorDefinitions="NDEBUG"
- MkTypLibCompatible="true"
- SuppressStartupBanner="true"
- TargetEnvironment="3"
- TypeLibraryName="$(OutDir)/zlibvc.tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;ASMV;ASMINF;WIN64"
- StringPooling="true"
- ExceptionHandling="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- PrecompiledHeaderFile="$(IntDir)/zlibvc.pch"
- AssemblerOutput="2"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- BrowseInformation="0"
- WarningLevel="3"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="..\..\masmx64\gvmat64.obj ..\..\masmx64\inffasx64.obj "
- OutputFile="$(OutDir)\zlibwapi.dll"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- GenerateManifest="false"
- IgnoreAllDefaultLibraries="false"
- ModuleDefinitionFile=".\zlibvc.def"
- ProgramDatabaseFile="$(OutDir)/zlibwapi.pdb"
- GenerateMapFile="true"
- MapFileName="$(OutDir)/zlibwapi.map"
- SubSystem="2"
- OptimizeForWindows98="1"
- ImportLibrary="$(OutDir)/zlibwapi.lib"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Itanium"
- OutputDirectory="ia64\ZlibDll$(ConfigurationName)"
- IntermediateDirectory="ia64\ZlibDll$(ConfigurationName)\Tmp"
- ConfigurationType="2"
- InheritedPropertySheets="UpgradeFromVC70.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- PreprocessorDefinitions="NDEBUG"
- MkTypLibCompatible="true"
- SuppressStartupBanner="true"
- TargetEnvironment="2"
- TypeLibraryName="$(OutDir)/zlibvc.tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..;..\..\masmx86"
- PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;WIN64"
- StringPooling="true"
- ExceptionHandling="0"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="true"
- PrecompiledHeaderFile="$(IntDir)/zlibvc.pch"
- AssemblerOutput="2"
- AssemblerListingLocation="$(IntDir)\"
- ObjectFile="$(IntDir)\"
- ProgramDataBaseFileName="$(OutDir)\"
- BrowseInformation="0"
- WarningLevel="3"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
- Culture="1036"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\zlibwapi.dll"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- GenerateManifest="false"
- IgnoreAllDefaultLibraries="false"
- ModuleDefinitionFile=".\zlibvc.def"
- ProgramDatabaseFile="$(OutDir)/zlibwapi.pdb"
- GenerateMapFile="true"
- MapFileName="$(OutDir)/zlibwapi.map"
- SubSystem="2"
- OptimizeForWindows98="1"
- ImportLibrary="$(OutDir)/zlibwapi.lib"
- TargetMachine="5"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
- >
- <File
- RelativePath="..\..\..\adler32.c"
- >
- </File>
- <File
- RelativePath="..\..\..\compress.c"
- >
- </File>
- <File
- RelativePath="..\..\..\crc32.c"
- >
- </File>
- <File
- RelativePath="..\..\..\deflate.c"
- >
- </File>
- <File
- RelativePath="..\..\masmx86\gvmat32c.c"
- >
- <FileConfiguration
- Name="Debug|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="ReleaseWithoutAsm|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="ReleaseWithoutAsm|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="ReleaseWithoutAsm|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\..\gzio.c"
- >
- </File>
- <File
- RelativePath="..\..\..\infback.c"
- >
- </File>
- <File
- RelativePath="..\..\masmx64\inffas8664.c"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="ReleaseWithoutAsm|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="ReleaseWithoutAsm|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Itanium"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\..\inffast.c"
- >
- </File>
- <File
- RelativePath="..\..\..\inflate.c"
- >
- </File>
- <File
- RelativePath="..\..\..\inftrees.c"
- >
- </File>
- <File
- RelativePath="..\..\minizip\ioapi.c"
- >
- </File>
- <File
- RelativePath="..\..\minizip\iowin32.c"
- >
- </File>
- <File
- RelativePath="..\..\..\trees.c"
- >
- </File>
- <File
- RelativePath="..\..\..\uncompr.c"
- >
- </File>
- <File
- RelativePath="..\..\minizip\unzip.c"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions="ZLIB_INTERNAL"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions="ZLIB_INTERNAL"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Itanium"
- >
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions="ZLIB_INTERNAL"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\minizip\zip.c"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions="ZLIB_INTERNAL"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions="ZLIB_INTERNAL"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Itanium"
- >
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions="ZLIB_INTERNAL"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\zlib.rc"
- >
- </File>
- <File
- RelativePath=".\zlibvc.def"
- >
- </File>
- <File
- RelativePath="..\..\..\zutil.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;fi;fd"
- >
- <File
- RelativePath="..\..\..\deflate.h"
- >
- </File>
- <File
- RelativePath="..\..\..\infblock.h"
- >
- </File>
- <File
- RelativePath="..\..\..\infcodes.h"
- >
- </File>
- <File
- RelativePath="..\..\..\inffast.h"
- >
- </File>
- <File
- RelativePath="..\..\..\inftrees.h"
- >
- </File>
- <File
- RelativePath="..\..\..\infutil.h"
- >
- </File>
- <File
- RelativePath="..\..\..\zconf.h"
- >
- </File>
- <File
- RelativePath="..\..\..\zlib.h"
- >
- </File>
- <File
- RelativePath="..\..\..\zutil.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
- >
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/source4/lib/zlib/crc32.c b/source4/lib/zlib/crc32.c
deleted file mode 100644
index 4d6e699e60..0000000000
--- a/source4/lib/zlib/crc32.c
+++ /dev/null
@@ -1,423 +0,0 @@
-/* crc32.c -- compute the CRC-32 of a data stream
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- *
- * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
- * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
- * tables for updating the shift register in one step with three exclusive-ors
- * instead of four steps with four exclusive-ors. This results in about a
- * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
- */
-
-/* @(#) $Id$ */
-
-#include "zutil.h" /* for STDC and FAR definitions */
-
-/*
- Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
- protection on the static variables used to control the first-use generation
- of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
- first call get_crc_table() to initialize the tables before allowing more than
- one thread to use crc32().
- */
-
-#ifdef MAKECRCH
-# include <stdio.h>
-# ifndef DYNAMIC_CRC_TABLE
-# define DYNAMIC_CRC_TABLE
-# endif /* !DYNAMIC_CRC_TABLE */
-#endif /* MAKECRCH */
-
-#define local static
-
-/* Find a four-byte integer type for crc32_little() and crc32_big(). */
-#ifndef NOBYFOUR
-# ifdef STDC /* need ANSI C limits.h to determine sizes */
-# include <limits.h>
-# define BYFOUR
-# if (UINT_MAX == 0xffffffffUL)
- typedef unsigned int u4;
-# else
-# if (ULONG_MAX == 0xffffffffUL)
- typedef unsigned long u4;
-# else
-# if (USHRT_MAX == 0xffffffffUL)
- typedef unsigned short u4;
-# else
-# undef BYFOUR /* can't find a four-byte integer type! */
-# endif
-# endif
-# endif
-# endif /* STDC */
-#endif /* !NOBYFOUR */
-
-/* Definitions for doing the crc four data bytes at a time. */
-#ifdef BYFOUR
-# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
- (((w)&0xff00)<<8)+(((w)&0xff)<<24))
- local unsigned long crc32_little OF((unsigned long,
- const unsigned char FAR *, unsigned));
- local unsigned long crc32_big OF((unsigned long,
- const unsigned char FAR *, unsigned));
-# define TBLS 8
-#else
-# define TBLS 1
-#endif /* BYFOUR */
-
-/* Local functions for crc concatenation */
-local unsigned long gf2_matrix_times OF((unsigned long *mat,
- unsigned long vec));
-local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
-
-#ifdef DYNAMIC_CRC_TABLE
-
-local volatile int crc_table_empty = 1;
-local unsigned long FAR crc_table[TBLS][256];
-local void make_crc_table OF((void));
-#ifdef MAKECRCH
- local void write_table OF((FILE *, const unsigned long FAR *));
-#endif /* MAKECRCH */
-/*
- Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
- x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
-
- Polynomials over GF(2) are represented in binary, one bit per coefficient,
- with the lowest powers in the most significant bit. Then adding polynomials
- is just exclusive-or, and multiplying a polynomial by x is a right shift by
- one. If we call the above polynomial p, and represent a byte as the
- polynomial q, also with the lowest power in the most significant bit (so the
- byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
- where a mod b means the remainder after dividing a by b.
-
- This calculation is done using the shift-register method of multiplying and
- taking the remainder. The register is initialized to zero, and for each
- incoming bit, x^32 is added mod p to the register if the bit is a one (where
- x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
- x (which is shifting right by one and adding x^32 mod p if the bit shifted
- out is a one). We start with the highest power (least significant bit) of
- q and repeat for all eight bits of q.
-
- The first table is simply the CRC of all possible eight bit values. This is
- all the information needed to generate CRCs on data a byte at a time for all
- combinations of CRC register values and incoming bytes. The remaining tables
- allow for word-at-a-time CRC calculation for both big-endian and little-
- endian machines, where a word is four bytes.
-*/
-local void make_crc_table()
-{
- unsigned long c;
- int n, k;
- unsigned long poly; /* polynomial exclusive-or pattern */
- /* terms of polynomial defining this crc (except x^32): */
- static volatile int first = 1; /* flag to limit concurrent making */
- static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
-
- /* See if another task is already doing this (not thread-safe, but better
- than nothing -- significantly reduces duration of vulnerability in
- case the advice about DYNAMIC_CRC_TABLE is ignored) */
- if (first) {
- first = 0;
-
- /* make exclusive-or pattern from polynomial (0xedb88320UL) */
- poly = 0UL;
- for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
- poly |= 1UL << (31 - p[n]);
-
- /* generate a crc for every 8-bit value */
- for (n = 0; n < 256; n++) {
- c = (unsigned long)n;
- for (k = 0; k < 8; k++)
- c = c & 1 ? poly ^ (c >> 1) : c >> 1;
- crc_table[0][n] = c;
- }
-
-#ifdef BYFOUR
- /* generate crc for each value followed by one, two, and three zeros,
- and then the byte reversal of those as well as the first table */
- for (n = 0; n < 256; n++) {
- c = crc_table[0][n];
- crc_table[4][n] = REV(c);
- for (k = 1; k < 4; k++) {
- c = crc_table[0][c & 0xff] ^ (c >> 8);
- crc_table[k][n] = c;
- crc_table[k + 4][n] = REV(c);
- }
- }
-#endif /* BYFOUR */
-
- crc_table_empty = 0;
- }
- else { /* not first */
- /* wait for the other guy to finish (not efficient, but rare) */
- while (crc_table_empty)
- ;
- }
-
-#ifdef MAKECRCH
- /* write out CRC tables to crc32.h */
- {
- FILE *out;
-
- out = fopen("crc32.h", "w");
- if (out == NULL) return;
- fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
- fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
- fprintf(out, "local const unsigned long FAR ");
- fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
- write_table(out, crc_table[0]);
-# ifdef BYFOUR
- fprintf(out, "#ifdef BYFOUR\n");
- for (k = 1; k < 8; k++) {
- fprintf(out, " },\n {\n");
- write_table(out, crc_table[k]);
- }
- fprintf(out, "#endif\n");
-# endif /* BYFOUR */
- fprintf(out, " }\n};\n");
- fclose(out);
- }
-#endif /* MAKECRCH */
-}
-
-#ifdef MAKECRCH
-local void write_table(out, table)
- FILE *out;
- const unsigned long FAR *table;
-{
- int n;
-
- for (n = 0; n < 256; n++)
- fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n],
- n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
-}
-#endif /* MAKECRCH */
-
-#else /* !DYNAMIC_CRC_TABLE */
-/* ========================================================================
- * Tables of CRC-32s of all single-byte values, made by make_crc_table().
- */
-#include "crc32.h"
-#endif /* DYNAMIC_CRC_TABLE */
-
-/* =========================================================================
- * This function can be used by asm versions of crc32()
- */
-const unsigned long FAR * ZEXPORT get_crc_table()
-{
-#ifdef DYNAMIC_CRC_TABLE
- if (crc_table_empty)
- make_crc_table();
-#endif /* DYNAMIC_CRC_TABLE */
- return (const unsigned long FAR *)crc_table;
-}
-
-/* ========================================================================= */
-#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
-#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
-
-/* ========================================================================= */
-unsigned long ZEXPORT crc32(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
-{
- if (buf == Z_NULL) return 0UL;
-
-#ifdef DYNAMIC_CRC_TABLE
- if (crc_table_empty)
- make_crc_table();
-#endif /* DYNAMIC_CRC_TABLE */
-
-#ifdef BYFOUR
- if (sizeof(void *) == sizeof(ptrdiff_t)) {
- u4 endian;
-
- endian = 1;
- if (*((unsigned char *)(&endian)))
- return crc32_little(crc, buf, len);
- else
- return crc32_big(crc, buf, len);
- }
-#endif /* BYFOUR */
- crc = crc ^ 0xffffffffUL;
- while (len >= 8) {
- DO8;
- len -= 8;
- }
- if (len) do {
- DO1;
- } while (--len);
- return crc ^ 0xffffffffUL;
-}
-
-#ifdef BYFOUR
-
-/* ========================================================================= */
-#define DOLIT4 c ^= *buf4++; \
- c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
- crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
-#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
-
-/* ========================================================================= */
-local unsigned long crc32_little(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
-{
- register u4 c;
- register const u4 FAR *buf4;
-
- c = (u4)crc;
- c = ~c;
- while (len && ((ptrdiff_t)buf & 3)) {
- c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
- len--;
- }
-
- buf4 = (const u4 FAR *)(const void FAR *)buf;
- while (len >= 32) {
- DOLIT32;
- len -= 32;
- }
- while (len >= 4) {
- DOLIT4;
- len -= 4;
- }
- buf = (const unsigned char FAR *)buf4;
-
- if (len) do {
- c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
- } while (--len);
- c = ~c;
- return (unsigned long)c;
-}
-
-/* ========================================================================= */
-#define DOBIG4 c ^= *++buf4; \
- c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
- crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
-#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
-
-/* ========================================================================= */
-local unsigned long crc32_big(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
-{
- register u4 c;
- register const u4 FAR *buf4;
-
- c = REV((u4)crc);
- c = ~c;
- while (len && ((ptrdiff_t)buf & 3)) {
- c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
- len--;
- }
-
- buf4 = (const u4 FAR *)(const void FAR *)buf;
- buf4--;
- while (len >= 32) {
- DOBIG32;
- len -= 32;
- }
- while (len >= 4) {
- DOBIG4;
- len -= 4;
- }
- buf4++;
- buf = (const unsigned char FAR *)buf4;
-
- if (len) do {
- c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
- } while (--len);
- c = ~c;
- return (unsigned long)(REV(c));
-}
-
-#endif /* BYFOUR */
-
-#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
-
-/* ========================================================================= */
-local unsigned long gf2_matrix_times(mat, vec)
- unsigned long *mat;
- unsigned long vec;
-{
- unsigned long sum;
-
- sum = 0;
- while (vec) {
- if (vec & 1)
- sum ^= *mat;
- vec >>= 1;
- mat++;
- }
- return sum;
-}
-
-/* ========================================================================= */
-local void gf2_matrix_square(square, mat)
- unsigned long *square;
- unsigned long *mat;
-{
- int n;
-
- for (n = 0; n < GF2_DIM; n++)
- square[n] = gf2_matrix_times(mat, mat[n]);
-}
-
-/* ========================================================================= */
-uLong ZEXPORT crc32_combine(crc1, crc2, len2)
- uLong crc1;
- uLong crc2;
- z_off_t len2;
-{
- int n;
- unsigned long row;
- unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */
- unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */
-
- /* degenerate case */
- if (len2 == 0)
- return crc1;
-
- /* put operator for one zero bit in odd */
- odd[0] = 0xedb88320L; /* CRC-32 polynomial */
- row = 1;
- for (n = 1; n < GF2_DIM; n++) {
- odd[n] = row;
- row <<= 1;
- }
-
- /* put operator for two zero bits in even */
- gf2_matrix_square(even, odd);
-
- /* put operator for four zero bits in odd */
- gf2_matrix_square(odd, even);
-
- /* apply len2 zeros to crc1 (first square will put the operator for one
- zero byte, eight zero bits, in even) */
- do {
- /* apply zeros operator for this bit of len2 */
- gf2_matrix_square(even, odd);
- if (len2 & 1)
- crc1 = gf2_matrix_times(even, crc1);
- len2 >>= 1;
-
- /* if no more bits set, then done */
- if (len2 == 0)
- break;
-
- /* another iteration of the loop with odd and even swapped */
- gf2_matrix_square(odd, even);
- if (len2 & 1)
- crc1 = gf2_matrix_times(odd, crc1);
- len2 >>= 1;
-
- /* if no more bits set, then done */
- } while (len2 != 0);
-
- /* return combined crc */
- crc1 ^= crc2;
- return crc1;
-}
diff --git a/source4/lib/zlib/crc32.h b/source4/lib/zlib/crc32.h
deleted file mode 100644
index 8053b6117c..0000000000
--- a/source4/lib/zlib/crc32.h
+++ /dev/null
@@ -1,441 +0,0 @@
-/* crc32.h -- tables for rapid CRC calculation
- * Generated automatically by crc32.c
- */
-
-local const unsigned long FAR crc_table[TBLS][256] =
-{
- {
- 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
- 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
- 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
- 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
- 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
- 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
- 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
- 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
- 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
- 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
- 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
- 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
- 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
- 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
- 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
- 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
- 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
- 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
- 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
- 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
- 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
- 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
- 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
- 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
- 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
- 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
- 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
- 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
- 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
- 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
- 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
- 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
- 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
- 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
- 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
- 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
- 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
- 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
- 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
- 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
- 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
- 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
- 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
- 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
- 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
- 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
- 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
- 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
- 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
- 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
- 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
- 0x2d02ef8dUL
-#ifdef BYFOUR
- },
- {
- 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,
- 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,
- 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,
- 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,
- 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,
- 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,
- 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,
- 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,
- 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,
- 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,
- 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,
- 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,
- 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,
- 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,
- 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,
- 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,
- 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,
- 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,
- 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,
- 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,
- 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,
- 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,
- 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,
- 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,
- 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,
- 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,
- 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,
- 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,
- 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,
- 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,
- 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,
- 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,
- 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,
- 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,
- 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,
- 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,
- 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,
- 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,
- 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,
- 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,
- 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,
- 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,
- 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,
- 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,
- 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,
- 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,
- 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,
- 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,
- 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,
- 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,
- 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,
- 0x9324fd72UL
- },
- {
- 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,
- 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,
- 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,
- 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,
- 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,
- 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,
- 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,
- 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,
- 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,
- 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,
- 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,
- 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,
- 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,
- 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,
- 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,
- 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,
- 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,
- 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,
- 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,
- 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,
- 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,
- 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,
- 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,
- 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,
- 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,
- 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,
- 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,
- 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,
- 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,
- 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,
- 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,
- 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,
- 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,
- 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,
- 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,
- 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,
- 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,
- 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,
- 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,
- 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,
- 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,
- 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,
- 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,
- 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,
- 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,
- 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,
- 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,
- 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,
- 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,
- 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,
- 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,
- 0xbe9834edUL
- },
- {
- 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,
- 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,
- 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,
- 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,
- 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,
- 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,
- 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,
- 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,
- 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,
- 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,
- 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,
- 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,
- 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,
- 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,
- 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,
- 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,
- 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,
- 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,
- 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,
- 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,
- 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,
- 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,
- 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,
- 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,
- 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,
- 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,
- 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,
- 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,
- 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,
- 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,
- 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,
- 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,
- 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,
- 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,
- 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,
- 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,
- 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,
- 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,
- 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,
- 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,
- 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,
- 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,
- 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,
- 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,
- 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,
- 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,
- 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,
- 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,
- 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,
- 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,
- 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,
- 0xde0506f1UL
- },
- {
- 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,
- 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,
- 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,
- 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,
- 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,
- 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,
- 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,
- 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,
- 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,
- 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,
- 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,
- 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,
- 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,
- 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,
- 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,
- 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,
- 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,
- 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,
- 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,
- 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,
- 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,
- 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,
- 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,
- 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,
- 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,
- 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,
- 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,
- 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,
- 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,
- 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,
- 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,
- 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,
- 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,
- 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,
- 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,
- 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,
- 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,
- 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,
- 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,
- 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,
- 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,
- 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,
- 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,
- 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,
- 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,
- 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,
- 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,
- 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,
- 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,
- 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,
- 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,
- 0x8def022dUL
- },
- {
- 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,
- 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,
- 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,
- 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,
- 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,
- 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,
- 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,
- 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,
- 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,
- 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,
- 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,
- 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,
- 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,
- 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,
- 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,
- 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,
- 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,
- 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,
- 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,
- 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,
- 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,
- 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,
- 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,
- 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,
- 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,
- 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,
- 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,
- 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,
- 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,
- 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,
- 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,
- 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,
- 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,
- 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,
- 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,
- 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,
- 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,
- 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,
- 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,
- 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,
- 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,
- 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,
- 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,
- 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,
- 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,
- 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,
- 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,
- 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,
- 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,
- 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,
- 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,
- 0x72fd2493UL
- },
- {
- 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,
- 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,
- 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,
- 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,
- 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,
- 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,
- 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,
- 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,
- 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,
- 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,
- 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,
- 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,
- 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,
- 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,
- 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,
- 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,
- 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,
- 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,
- 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,
- 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,
- 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,
- 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,
- 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,
- 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,
- 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,
- 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,
- 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,
- 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,
- 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,
- 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,
- 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,
- 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,
- 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,
- 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,
- 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,
- 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,
- 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,
- 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,
- 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,
- 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,
- 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,
- 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,
- 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,
- 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,
- 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,
- 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,
- 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,
- 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,
- 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,
- 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,
- 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,
- 0xed3498beUL
- },
- {
- 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,
- 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,
- 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,
- 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,
- 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,
- 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,
- 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,
- 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,
- 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,
- 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,
- 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,
- 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,
- 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,
- 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,
- 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,
- 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,
- 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,
- 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,
- 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,
- 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,
- 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,
- 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,
- 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,
- 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,
- 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,
- 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,
- 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,
- 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,
- 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,
- 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,
- 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,
- 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,
- 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,
- 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,
- 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,
- 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,
- 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,
- 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,
- 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,
- 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,
- 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,
- 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,
- 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,
- 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,
- 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,
- 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,
- 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,
- 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,
- 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,
- 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,
- 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,
- 0xf10605deUL
-#endif
- }
-};
diff --git a/source4/lib/zlib/deflate.c b/source4/lib/zlib/deflate.c
deleted file mode 100644
index 2720aab911..0000000000
--- a/source4/lib/zlib/deflate.c
+++ /dev/null
@@ -1,1736 +0,0 @@
-/* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * ALGORITHM
- *
- * The "deflation" process depends on being able to identify portions
- * of the input text which are identical to earlier input (within a
- * sliding window trailing behind the input currently being processed).
- *
- * The most straightforward technique turns out to be the fastest for
- * most input files: try all possible matches and select the longest.
- * The key feature of this algorithm is that insertions into the string
- * dictionary are very simple and thus fast, and deletions are avoided
- * completely. Insertions are performed at each input character, whereas
- * string matches are performed only when the previous match ends. So it
- * is preferable to spend more time in matches to allow very fast string
- * insertions and avoid deletions. The matching algorithm for small
- * strings is inspired from that of Rabin & Karp. A brute force approach
- * is used to find longer strings when a small match has been found.
- * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze
- * (by Leonid Broukhis).
- * A previous version of this file used a more sophisticated algorithm
- * (by Fiala and Greene) which is guaranteed to run in linear amortized
- * time, but has a larger average cost, uses more memory and is patented.
- * However the F&G algorithm may be faster for some highly redundant
- * files if the parameter max_chain_length (described below) is too large.
- *
- * ACKNOWLEDGEMENTS
- *
- * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
- * I found it in 'freeze' written by Leonid Broukhis.
- * Thanks to many people for bug reports and testing.
- *
- * REFERENCES
- *
- * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
- * Available in http://www.ietf.org/rfc/rfc1951.txt
- *
- * A description of the Rabin and Karp algorithm is given in the book
- * "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
- *
- * Fiala,E.R., and Greene,D.H.
- * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
- *
- */
-
-/* @(#) $Id$ */
-
-#include "deflate.h"
-
-const char deflate_copyright[] =
- " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly ";
-/*
- If you use the zlib library in a product, an acknowledgment is welcome
- in the documentation of your product. If for some reason you cannot
- include such an acknowledgment, I would appreciate that you keep this
- copyright string in the executable of your product.
- */
-
-/* ===========================================================================
- * Function prototypes.
- */
-typedef enum {
- need_more, /* block not completed, need more input or more output */
- block_done, /* block flush performed */
- finish_started, /* finish started, need only more output at next deflate */
- finish_done /* finish done, accept no more input or output */
-} block_state;
-
-typedef block_state (*compress_func) OF((deflate_state *s, int flush));
-/* Compression function. Returns the block state after the call. */
-
-local void fill_window OF((deflate_state *s));
-local block_state deflate_stored OF((deflate_state *s, int flush));
-local block_state deflate_fast OF((deflate_state *s, int flush));
-#ifndef FASTEST
-local block_state deflate_slow OF((deflate_state *s, int flush));
-#endif
-local void lm_init OF((deflate_state *s));
-local void putShortMSB OF((deflate_state *s, uInt b));
-local void flush_pending OF((z_streamp strm));
-local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
-#ifndef FASTEST
-#ifdef ASMV
- void match_init OF((void)); /* asm code initialization */
- uInt longest_match OF((deflate_state *s, IPos cur_match));
-#else
-local uInt longest_match OF((deflate_state *s, IPos cur_match));
-#endif
-#endif
-local uInt longest_match_fast OF((deflate_state *s, IPos cur_match));
-
-#ifdef DEBUG
-local void check_match OF((deflate_state *s, IPos start, IPos match,
- int length));
-#endif
-
-/* ===========================================================================
- * Local data
- */
-
-#define NIL 0
-/* Tail of hash chains */
-
-#ifndef TOO_FAR
-# define TOO_FAR 4096
-#endif
-/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
-
-#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
-/* Minimum amount of lookahead, except at the end of the input file.
- * See deflate.c for comments about the MIN_MATCH+1.
- */
-
-/* Values for max_lazy_match, good_match and max_chain_length, depending on
- * the desired pack level (0..9). The values given below have been tuned to
- * exclude worst case performance for pathological files. Better values may be
- * found for specific files.
- */
-typedef struct config_s {
- ush good_length; /* reduce lazy search above this match length */
- ush max_lazy; /* do not perform lazy search above this match length */
- ush nice_length; /* quit search above this match length */
- ush max_chain;
- compress_func func;
-} config;
-
-#ifdef FASTEST
-local const config configuration_table[2] = {
-/* good lazy nice chain */
-/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
-/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */
-#else
-local const config configuration_table[10] = {
-/* good lazy nice chain */
-/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
-/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */
-/* 2 */ {4, 5, 16, 8, deflate_fast},
-/* 3 */ {4, 6, 32, 32, deflate_fast},
-
-/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */
-/* 5 */ {8, 16, 32, 32, deflate_slow},
-/* 6 */ {8, 16, 128, 128, deflate_slow},
-/* 7 */ {8, 32, 128, 256, deflate_slow},
-/* 8 */ {32, 128, 258, 1024, deflate_slow},
-/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */
-#endif
-
-/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
- * For deflate_fast() (levels <= 3) good is ignored and lazy has a different
- * meaning.
- */
-
-#ifndef NO_DUMMY_DECL
-struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
-#endif
-
-/* ===========================================================================
- * Update a hash value with the given input byte
- * IN assertion: all calls to to UPDATE_HASH are made with consecutive
- * input characters, so that a running hash key can be computed from the
- * previous key instead of complete recalculation each time.
- */
-#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
-
-
-/* ===========================================================================
- * Insert string str in the dictionary and set match_head to the previous head
- * of the hash chain (the most recent string with same hash key). Return
- * the previous length of the hash chain.
- * If this file is compiled with -DFASTEST, the compression level is forced
- * to 1, and no hash chains are maintained.
- * IN assertion: all calls to to INSERT_STRING are made with consecutive
- * input characters and the first MIN_MATCH bytes of str are valid
- * (except for the last MIN_MATCH-1 bytes of the input file).
- */
-#ifdef FASTEST
-#define INSERT_STRING(s, str, match_head) \
- (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
- match_head = s->head[s->ins_h], \
- s->head[s->ins_h] = (Pos)(str))
-#else
-#define INSERT_STRING(s, str, match_head) \
- (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
- match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \
- s->head[s->ins_h] = (Pos)(str))
-#endif
-
-/* ===========================================================================
- * Initialize the hash table (avoiding 64K overflow for 16 bit systems).
- * prev[] will be initialized on the fly.
- */
-#define CLEAR_HASH(s) \
- s->head[s->hash_size-1] = NIL; \
- zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
-
-/* ========================================================================= */
-int ZEXPORT deflateInit_(strm, level, version, stream_size)
- z_streamp strm;
- int level;
- const char *version;
- int stream_size;
-{
- return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
- Z_DEFAULT_STRATEGY, version, stream_size);
- /* To do: ignore strm->next_in if we use it as window */
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
- version, stream_size)
- z_streamp strm;
- int level;
- int method;
- int windowBits;
- int memLevel;
- int strategy;
- const char *version;
- int stream_size;
-{
- deflate_state *s;
- int wrap = 1;
- static const char my_version[] = ZLIB_VERSION;
-
- ushf *overlay;
- /* We overlay pending_buf and d_buf+l_buf. This works since the average
- * output size for (length,distance) codes is <= 24 bits.
- */
-
- if (version == Z_NULL || version[0] != my_version[0] ||
- stream_size != sizeof(z_stream)) {
- return Z_VERSION_ERROR;
- }
- if (strm == Z_NULL) return Z_STREAM_ERROR;
-
- strm->msg = Z_NULL;
- if (strm->zalloc == (alloc_func)0) {
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
- }
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
-
-#ifdef FASTEST
- if (level != 0) level = 1;
-#else
- if (level == Z_DEFAULT_COMPRESSION) level = 6;
-#endif
-
- if (windowBits < 0) { /* suppress zlib wrapper */
- wrap = 0;
- windowBits = -windowBits;
- }
-#ifdef GZIP
- else if (windowBits > 15) {
- wrap = 2; /* write gzip wrapper instead */
- windowBits -= 16;
- }
-#endif
- if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
- windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
- strategy < 0 || strategy > Z_FIXED) {
- return Z_STREAM_ERROR;
- }
- if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
- s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
- if (s == Z_NULL) return Z_MEM_ERROR;
- strm->state = (struct internal_state FAR *)s;
- s->strm = strm;
-
- s->wrap = wrap;
- s->gzhead = Z_NULL;
- s->w_bits = windowBits;
- s->w_size = 1 << s->w_bits;
- s->w_mask = s->w_size - 1;
-
- s->hash_bits = memLevel + 7;
- s->hash_size = 1 << s->hash_bits;
- s->hash_mask = s->hash_size - 1;
- s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
-
- s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
- s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
- s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
-
- s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
-
- overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
- s->pending_buf = (uchf *) overlay;
- s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
-
- if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
- s->pending_buf == Z_NULL) {
- s->status = FINISH_STATE;
- strm->msg = ERR_MSG(Z_MEM_ERROR);
- deflateEnd (strm);
- return Z_MEM_ERROR;
- }
- s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
- s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
-
- s->level = level;
- s->strategy = strategy;
- s->method = (Byte)method;
-
- return deflateReset(strm);
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
- z_streamp strm;
- const Bytef *dictionary;
- uInt dictLength;
-{
- deflate_state *s;
- uInt length = dictLength;
- uInt n;
- IPos hash_head = 0;
-
- if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
- strm->state->wrap == 2 ||
- (strm->state->wrap == 1 && strm->state->status != INIT_STATE))
- return Z_STREAM_ERROR;
-
- s = strm->state;
- if (s->wrap)
- strm->adler = adler32(strm->adler, dictionary, dictLength);
-
- if (length < MIN_MATCH) return Z_OK;
- if (length > MAX_DIST(s)) {
- length = MAX_DIST(s);
- dictionary += dictLength - length; /* use the tail of the dictionary */
- }
- zmemcpy(s->window, dictionary, length);
- s->strstart = length;
- s->block_start = (long)length;
-
- /* Insert all strings in the hash table (except for the last two bytes).
- * s->lookahead stays null, so s->ins_h will be recomputed at the next
- * call of fill_window.
- */
- s->ins_h = s->window[0];
- UPDATE_HASH(s, s->ins_h, s->window[1]);
- for (n = 0; n <= length - MIN_MATCH; n++) {
- INSERT_STRING(s, n, hash_head);
- }
- if (hash_head) hash_head = 0; /* to make compiler happy */
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateReset (strm)
- z_streamp strm;
-{
- deflate_state *s;
-
- if (strm == Z_NULL || strm->state == Z_NULL ||
- strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
- return Z_STREAM_ERROR;
- }
-
- strm->total_in = strm->total_out = 0;
- strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
- strm->data_type = Z_UNKNOWN;
-
- s = (deflate_state *)strm->state;
- s->pending = 0;
- s->pending_out = s->pending_buf;
-
- if (s->wrap < 0) {
- s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
- }
- s->status = s->wrap ? INIT_STATE : BUSY_STATE;
- strm->adler =
-#ifdef GZIP
- s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
-#endif
- adler32(0L, Z_NULL, 0);
- s->last_flush = Z_NO_FLUSH;
-
- _tr_init(s);
- lm_init(s);
-
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateSetHeader (strm, head)
- z_streamp strm;
- gz_headerp head;
-{
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- if (strm->state->wrap != 2) return Z_STREAM_ERROR;
- strm->state->gzhead = head;
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflatePrime (strm, bits, value)
- z_streamp strm;
- int bits;
- int value;
-{
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- strm->state->bi_valid = bits;
- strm->state->bi_buf = (ush)(value & ((1 << bits) - 1));
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateParams(strm, level, strategy)
- z_streamp strm;
- int level;
- int strategy;
-{
- deflate_state *s;
- compress_func func;
- int err = Z_OK;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- s = strm->state;
-
-#ifdef FASTEST
- if (level != 0) level = 1;
-#else
- if (level == Z_DEFAULT_COMPRESSION) level = 6;
-#endif
- if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
- return Z_STREAM_ERROR;
- }
- func = configuration_table[s->level].func;
-
- if (func != configuration_table[level].func && strm->total_in != 0) {
- /* Flush the last buffer: */
- err = deflate(strm, Z_PARTIAL_FLUSH);
- }
- if (s->level != level) {
- s->level = level;
- s->max_lazy_match = configuration_table[level].max_lazy;
- s->good_match = configuration_table[level].good_length;
- s->nice_match = configuration_table[level].nice_length;
- s->max_chain_length = configuration_table[level].max_chain;
- }
- s->strategy = strategy;
- return err;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
- z_streamp strm;
- int good_length;
- int max_lazy;
- int nice_length;
- int max_chain;
-{
- deflate_state *s;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- s = strm->state;
- s->good_match = good_length;
- s->max_lazy_match = max_lazy;
- s->nice_match = nice_length;
- s->max_chain_length = max_chain;
- return Z_OK;
-}
-
-/* =========================================================================
- * For the default windowBits of 15 and memLevel of 8, this function returns
- * a close to exact, as well as small, upper bound on the compressed size.
- * They are coded as constants here for a reason--if the #define's are
- * changed, then this function needs to be changed as well. The return
- * value for 15 and 8 only works for those exact settings.
- *
- * For any setting other than those defaults for windowBits and memLevel,
- * the value returned is a conservative worst case for the maximum expansion
- * resulting from using fixed blocks instead of stored blocks, which deflate
- * can emit on compressed data for some combinations of the parameters.
- *
- * This function could be more sophisticated to provide closer upper bounds
- * for every combination of windowBits and memLevel, as well as wrap.
- * But even the conservative upper bound of about 14% expansion does not
- * seem onerous for output buffer allocation.
- */
-uLong ZEXPORT deflateBound(strm, sourceLen)
- z_streamp strm;
- uLong sourceLen;
-{
- deflate_state *s;
- uLong destLen;
-
- /* conservative upper bound */
- destLen = sourceLen +
- ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11;
-
- /* if can't get parameters, return conservative bound */
- if (strm == Z_NULL || strm->state == Z_NULL)
- return destLen;
-
- /* if not default parameters, return conservative bound */
- s = strm->state;
- if (s->w_bits != 15 || s->hash_bits != 8 + 7)
- return destLen;
-
- /* default settings: return tight bound for that case */
- return compressBound(sourceLen);
-}
-
-/* =========================================================================
- * Put a short in the pending buffer. The 16-bit value is put in MSB order.
- * IN assertion: the stream state is correct and there is enough room in
- * pending_buf.
- */
-local void putShortMSB (s, b)
- deflate_state *s;
- uInt b;
-{
- put_byte(s, (Byte)(b >> 8));
- put_byte(s, (Byte)(b & 0xff));
-}
-
-/* =========================================================================
- * Flush as much pending output as possible. All deflate() output goes
- * through this function so some applications may wish to modify it
- * to avoid allocating a large strm->next_out buffer and copying into it.
- * (See also read_buf()).
- */
-local void flush_pending(strm)
- z_streamp strm;
-{
- unsigned len = strm->state->pending;
-
- if (len > strm->avail_out) len = strm->avail_out;
- if (len == 0) return;
-
- zmemcpy(strm->next_out, strm->state->pending_out, len);
- strm->next_out += len;
- strm->state->pending_out += len;
- strm->total_out += len;
- strm->avail_out -= len;
- strm->state->pending -= len;
- if (strm->state->pending == 0) {
- strm->state->pending_out = strm->state->pending_buf;
- }
-}
-
-/* ========================================================================= */
-int ZEXPORT deflate (strm, flush)
- z_streamp strm;
- int flush;
-{
- int old_flush; /* value of flush param for previous deflate call */
- deflate_state *s;
-
- if (strm == Z_NULL || strm->state == Z_NULL ||
- flush > Z_FINISH || flush < 0) {
- return Z_STREAM_ERROR;
- }
- s = strm->state;
-
- if (strm->next_out == Z_NULL ||
- (strm->next_in == Z_NULL && strm->avail_in != 0) ||
- (s->status == FINISH_STATE && flush != Z_FINISH)) {
- ERR_RETURN(strm, Z_STREAM_ERROR);
- }
- if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
-
- s->strm = strm; /* just in case */
- old_flush = s->last_flush;
- s->last_flush = flush;
-
- /* Write the header */
- if (s->status == INIT_STATE) {
-#ifdef GZIP
- if (s->wrap == 2) {
- strm->adler = crc32(0L, Z_NULL, 0);
- put_byte(s, 31);
- put_byte(s, 139);
- put_byte(s, 8);
- if (s->gzhead == NULL) {
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, s->level == 9 ? 2 :
- (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
- 4 : 0));
- put_byte(s, OS_CODE);
- s->status = BUSY_STATE;
- }
- else {
- put_byte(s, (s->gzhead->text ? 1 : 0) +
- (s->gzhead->hcrc ? 2 : 0) +
- (s->gzhead->extra == Z_NULL ? 0 : 4) +
- (s->gzhead->name == Z_NULL ? 0 : 8) +
- (s->gzhead->comment == Z_NULL ? 0 : 16)
- );
- put_byte(s, (Byte)(s->gzhead->time & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
- put_byte(s, s->level == 9 ? 2 :
- (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
- 4 : 0));
- put_byte(s, s->gzhead->os & 0xff);
- if (s->gzhead->extra != NULL) {
- put_byte(s, s->gzhead->extra_len & 0xff);
- put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
- }
- if (s->gzhead->hcrc)
- strm->adler = crc32(strm->adler, s->pending_buf,
- s->pending);
- s->gzindex = 0;
- s->status = EXTRA_STATE;
- }
- }
- else
-#endif
- {
- uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
- uInt level_flags;
-
- if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
- level_flags = 0;
- else if (s->level < 6)
- level_flags = 1;
- else if (s->level == 6)
- level_flags = 2;
- else
- level_flags = 3;
- header |= (level_flags << 6);
- if (s->strstart != 0) header |= PRESET_DICT;
- header += 31 - (header % 31);
-
- s->status = BUSY_STATE;
- putShortMSB(s, header);
-
- /* Save the adler32 of the preset dictionary: */
- if (s->strstart != 0) {
- putShortMSB(s, (uInt)(strm->adler >> 16));
- putShortMSB(s, (uInt)(strm->adler & 0xffff));
- }
- strm->adler = adler32(0L, Z_NULL, 0);
- }
- }
-#ifdef GZIP
- if (s->status == EXTRA_STATE) {
- if (s->gzhead->extra != NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
-
- while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
- if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size)
- break;
- }
- put_byte(s, s->gzhead->extra[s->gzindex]);
- s->gzindex++;
- }
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (s->gzindex == s->gzhead->extra_len) {
- s->gzindex = 0;
- s->status = NAME_STATE;
- }
- }
- else
- s->status = NAME_STATE;
- }
- if (s->status == NAME_STATE) {
- if (s->gzhead->name != NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
- int val;
-
- do {
- if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size) {
- val = 1;
- break;
- }
- }
- val = s->gzhead->name[s->gzindex++];
- put_byte(s, val);
- } while (val != 0);
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (val == 0) {
- s->gzindex = 0;
- s->status = COMMENT_STATE;
- }
- }
- else
- s->status = COMMENT_STATE;
- }
- if (s->status == COMMENT_STATE) {
- if (s->gzhead->comment != NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
- int val;
-
- do {
- if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size) {
- val = 1;
- break;
- }
- }
- val = s->gzhead->comment[s->gzindex++];
- put_byte(s, val);
- } while (val != 0);
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (val == 0)
- s->status = HCRC_STATE;
- }
- else
- s->status = HCRC_STATE;
- }
- if (s->status == HCRC_STATE) {
- if (s->gzhead->hcrc) {
- if (s->pending + 2 > s->pending_buf_size)
- flush_pending(strm);
- if (s->pending + 2 <= s->pending_buf_size) {
- put_byte(s, (Byte)(strm->adler & 0xff));
- put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
- strm->adler = crc32(0L, Z_NULL, 0);
- s->status = BUSY_STATE;
- }
- }
- else
- s->status = BUSY_STATE;
- }
-#endif
-
- /* Flush as much pending output as possible */
- if (s->pending != 0) {
- flush_pending(strm);
- if (strm->avail_out == 0) {
- /* Since avail_out is 0, deflate will be called again with
- * more output space, but possibly with both pending and
- * avail_in equal to zero. There won't be anything to do,
- * but this is not an error situation so make sure we
- * return OK instead of BUF_ERROR at next call of deflate:
- */
- s->last_flush = -1;
- return Z_OK;
- }
-
- /* Make sure there is something to do and avoid duplicate consecutive
- * flushes. For repeated and useless calls with Z_FINISH, we keep
- * returning Z_STREAM_END instead of Z_BUF_ERROR.
- */
- } else if (strm->avail_in == 0 && flush <= old_flush &&
- flush != Z_FINISH) {
- ERR_RETURN(strm, Z_BUF_ERROR);
- }
-
- /* User must not provide more input after the first FINISH: */
- if (s->status == FINISH_STATE && strm->avail_in != 0) {
- ERR_RETURN(strm, Z_BUF_ERROR);
- }
-
- /* Start a new block or continue the current one.
- */
- if (strm->avail_in != 0 || s->lookahead != 0 ||
- (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
- block_state bstate;
-
- bstate = (*(configuration_table[s->level].func))(s, flush);
-
- if (bstate == finish_started || bstate == finish_done) {
- s->status = FINISH_STATE;
- }
- if (bstate == need_more || bstate == finish_started) {
- if (strm->avail_out == 0) {
- s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
- }
- return Z_OK;
- /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
- * of deflate should use the same flush parameter to make sure
- * that the flush is complete. So we don't have to output an
- * empty block here, this will be done at next call. This also
- * ensures that for a very small output buffer, we emit at most
- * one empty block.
- */
- }
- if (bstate == block_done) {
- if (flush == Z_PARTIAL_FLUSH) {
- _tr_align(s);
- } else { /* FULL_FLUSH or SYNC_FLUSH */
- _tr_stored_block(s, (char*)0, 0L, 0);
- /* For a full flush, this empty block will be recognized
- * as a special marker by inflate_sync().
- */
- if (flush == Z_FULL_FLUSH) {
- CLEAR_HASH(s); /* forget history */
- }
- }
- flush_pending(strm);
- if (strm->avail_out == 0) {
- s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
- return Z_OK;
- }
- }
- }
- Assert(strm->avail_out > 0, "bug2");
-
- if (flush != Z_FINISH) return Z_OK;
- if (s->wrap <= 0) return Z_STREAM_END;
-
- /* Write the trailer */
-#ifdef GZIP
- if (s->wrap == 2) {
- put_byte(s, (Byte)(strm->adler & 0xff));
- put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
- put_byte(s, (Byte)((strm->adler >> 16) & 0xff));
- put_byte(s, (Byte)((strm->adler >> 24) & 0xff));
- put_byte(s, (Byte)(strm->total_in & 0xff));
- put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));
- put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));
- put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));
- }
- else
-#endif
- {
- putShortMSB(s, (uInt)(strm->adler >> 16));
- putShortMSB(s, (uInt)(strm->adler & 0xffff));
- }
- flush_pending(strm);
- /* If avail_out is zero, the application will call deflate again
- * to flush the rest.
- */
- if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
- return s->pending != 0 ? Z_OK : Z_STREAM_END;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateEnd (strm)
- z_streamp strm;
-{
- int status;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-
- status = strm->state->status;
- if (status != INIT_STATE &&
- status != EXTRA_STATE &&
- status != NAME_STATE &&
- status != COMMENT_STATE &&
- status != HCRC_STATE &&
- status != BUSY_STATE &&
- status != FINISH_STATE) {
- return Z_STREAM_ERROR;
- }
-
- /* Deallocate in reverse order of allocations: */
- TRY_FREE(strm, strm->state->pending_buf);
- TRY_FREE(strm, strm->state->head);
- TRY_FREE(strm, strm->state->prev);
- TRY_FREE(strm, strm->state->window);
-
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
-
- return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
-}
-
-/* =========================================================================
- * Copy the source state to the destination state.
- * To simplify the source, this is not supported for 16-bit MSDOS (which
- * doesn't have enough memory anyway to duplicate compression states).
- */
-int ZEXPORT deflateCopy (dest, source)
- z_streamp dest;
- z_streamp source;
-{
-#ifdef MAXSEG_64K
- return Z_STREAM_ERROR;
-#else
- deflate_state *ds;
- deflate_state *ss;
- ushf *overlay;
-
-
- if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
- return Z_STREAM_ERROR;
- }
-
- ss = source->state;
-
- zmemcpy(dest, source, sizeof(z_stream));
-
- ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
- if (ds == Z_NULL) return Z_MEM_ERROR;
- dest->state = (struct internal_state FAR *) ds;
- zmemcpy(ds, ss, sizeof(deflate_state));
- ds->strm = dest;
-
- ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
- ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
- ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
- overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
- ds->pending_buf = (uchf *) overlay;
-
- if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
- ds->pending_buf == Z_NULL) {
- deflateEnd (dest);
- return Z_MEM_ERROR;
- }
- /* following zmemcpy do not work for 16-bit MSDOS */
- zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
- zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos));
- zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
- zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
-
- ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
- ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
- ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
-
- ds->l_desc.dyn_tree = ds->dyn_ltree;
- ds->d_desc.dyn_tree = ds->dyn_dtree;
- ds->bl_desc.dyn_tree = ds->bl_tree;
-
- return Z_OK;
-#endif /* MAXSEG_64K */
-}
-
-/* ===========================================================================
- * Read a new buffer from the current input stream, update the adler32
- * and total number of bytes read. All deflate() input goes through
- * this function so some applications may wish to modify it to avoid
- * allocating a large strm->next_in buffer and copying from it.
- * (See also flush_pending()).
- */
-local int read_buf(strm, buf, size)
- z_streamp strm;
- Bytef *buf;
- unsigned size;
-{
- unsigned len = strm->avail_in;
-
- if (len > size) len = size;
- if (len == 0) return 0;
-
- strm->avail_in -= len;
-
- if (strm->state->wrap == 1) {
- strm->adler = adler32(strm->adler, strm->next_in, len);
- }
-#ifdef GZIP
- else if (strm->state->wrap == 2) {
- strm->adler = crc32(strm->adler, strm->next_in, len);
- }
-#endif
- zmemcpy(buf, strm->next_in, len);
- strm->next_in += len;
- strm->total_in += len;
-
- return (int)len;
-}
-
-/* ===========================================================================
- * Initialize the "longest match" routines for a new zlib stream
- */
-local void lm_init (s)
- deflate_state *s;
-{
- s->window_size = (ulg)2L*s->w_size;
-
- CLEAR_HASH(s);
-
- /* Set the default configuration parameters:
- */
- s->max_lazy_match = configuration_table[s->level].max_lazy;
- s->good_match = configuration_table[s->level].good_length;
- s->nice_match = configuration_table[s->level].nice_length;
- s->max_chain_length = configuration_table[s->level].max_chain;
-
- s->strstart = 0;
- s->block_start = 0L;
- s->lookahead = 0;
- s->match_length = s->prev_length = MIN_MATCH-1;
- s->match_available = 0;
- s->ins_h = 0;
-#ifndef FASTEST
-#ifdef ASMV
- match_init(); /* initialize the asm code */
-#endif
-#endif
-}
-
-#ifndef FASTEST
-/* ===========================================================================
- * Set match_start to the longest match starting at the given string and
- * return its length. Matches shorter or equal to prev_length are discarded,
- * in which case the result is equal to prev_length and match_start is
- * garbage.
- * IN assertions: cur_match is the head of the hash chain for the current
- * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
- * OUT assertion: the match length is not greater than s->lookahead.
- */
-#ifndef ASMV
-/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
- * match.S. The code will be functionally equivalent.
- */
-local uInt longest_match(s, cur_match)
- deflate_state *s;
- IPos cur_match; /* current match */
-{
- unsigned chain_length = s->max_chain_length;/* max hash chain length */
- register Bytef *scan = s->window + s->strstart; /* current string */
- register Bytef *match; /* matched string */
- register int len; /* length of current match */
- int best_len = s->prev_length; /* best match length so far */
- int nice_match = s->nice_match; /* stop if match long enough */
- IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
- s->strstart - (IPos)MAX_DIST(s) : NIL;
- /* Stop when cur_match becomes <= limit. To simplify the code,
- * we prevent matches with the string of window index 0.
- */
- Posf *prev = s->prev;
- uInt wmask = s->w_mask;
-
-#ifdef UNALIGNED_OK
- /* Compare two bytes at a time. Note: this is not always beneficial.
- * Try with and without -DUNALIGNED_OK to check.
- */
- register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
- register ush scan_start = *(ushf*)scan;
- register ush scan_end = *(ushf*)(scan+best_len-1);
-#else
- register Bytef *strend = s->window + s->strstart + MAX_MATCH;
- register Byte scan_end1 = scan[best_len-1];
- register Byte scan_end = scan[best_len];
-#endif
-
- /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
- * It is easy to get rid of this optimization if necessary.
- */
- Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
-
- /* Do not waste too much time if we already have a good match: */
- if (s->prev_length >= s->good_match) {
- chain_length >>= 2;
- }
- /* Do not look for matches beyond the end of the input. This is necessary
- * to make deflate deterministic.
- */
- if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
-
- Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
-
- do {
- Assert(cur_match < s->strstart, "no future");
- match = s->window + cur_match;
-
- /* Skip to next match if the match length cannot increase
- * or if the match length is less than 2. Note that the checks below
- * for insufficient lookahead only occur occasionally for performance
- * reasons. Therefore uninitialized memory will be accessed, and
- * conditional jumps will be made that depend on those values.
- * However the length of the match is limited to the lookahead, so
- * the output of deflate is not affected by the uninitialized values.
- */
-#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
- /* This code assumes sizeof(unsigned short) == 2. Do not use
- * UNALIGNED_OK if your compiler uses a different size.
- */
- if (*(ushf*)(match+best_len-1) != scan_end ||
- *(ushf*)match != scan_start) continue;
-
- /* It is not necessary to compare scan[2] and match[2] since they are
- * always equal when the other bytes match, given that the hash keys
- * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
- * strstart+3, +5, ... up to strstart+257. We check for insufficient
- * lookahead only every 4th comparison; the 128th check will be made
- * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
- * necessary to put more guard bytes at the end of the window, or
- * to check more often for insufficient lookahead.
- */
- Assert(scan[2] == match[2], "scan[2]?");
- scan++, match++;
- do {
- } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- scan < strend);
- /* The funny "do {}" generates better code on most compilers */
-
- /* Here, scan <= window+strstart+257 */
- Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
- if (*scan == *match) scan++;
-
- len = (MAX_MATCH - 1) - (int)(strend-scan);
- scan = strend - (MAX_MATCH-1);
-
-#else /* UNALIGNED_OK */
-
- if (match[best_len] != scan_end ||
- match[best_len-1] != scan_end1 ||
- *match != *scan ||
- *++match != scan[1]) continue;
-
- /* The check at best_len-1 can be removed because it will be made
- * again later. (This heuristic is not always a win.)
- * It is not necessary to compare scan[2] and match[2] since they
- * are always equal when the other bytes match, given that
- * the hash keys are equal and that HASH_BITS >= 8.
- */
- scan += 2, match++;
- Assert(*scan == *match, "match[2]?");
-
- /* We check for insufficient lookahead only every 8th comparison;
- * the 256th check will be made at strstart+258.
- */
- do {
- } while (*++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- scan < strend);
-
- Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
-
- len = MAX_MATCH - (int)(strend - scan);
- scan = strend - MAX_MATCH;
-
-#endif /* UNALIGNED_OK */
-
- if (len > best_len) {
- s->match_start = cur_match;
- best_len = len;
- if (len >= nice_match) break;
-#ifdef UNALIGNED_OK
- scan_end = *(ushf*)(scan+best_len-1);
-#else
- scan_end1 = scan[best_len-1];
- scan_end = scan[best_len];
-#endif
- }
- } while ((cur_match = prev[cur_match & wmask]) > limit
- && --chain_length != 0);
-
- if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
- return s->lookahead;
-}
-#endif /* ASMV */
-#endif /* FASTEST */
-
-/* ---------------------------------------------------------------------------
- * Optimized version for level == 1 or strategy == Z_RLE only
- */
-local uInt longest_match_fast(s, cur_match)
- deflate_state *s;
- IPos cur_match; /* current match */
-{
- register Bytef *scan = s->window + s->strstart; /* current string */
- register Bytef *match; /* matched string */
- register int len; /* length of current match */
- register Bytef *strend = s->window + s->strstart + MAX_MATCH;
-
- /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
- * It is easy to get rid of this optimization if necessary.
- */
- Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
-
- Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
-
- Assert(cur_match < s->strstart, "no future");
-
- match = s->window + cur_match;
-
- /* Return failure if the match length is less than 2:
- */
- if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
-
- /* The check at best_len-1 can be removed because it will be made
- * again later. (This heuristic is not always a win.)
- * It is not necessary to compare scan[2] and match[2] since they
- * are always equal when the other bytes match, given that
- * the hash keys are equal and that HASH_BITS >= 8.
- */
- scan += 2, match += 2;
- Assert(*scan == *match, "match[2]?");
-
- /* We check for insufficient lookahead only every 8th comparison;
- * the 256th check will be made at strstart+258.
- */
- do {
- } while (*++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- scan < strend);
-
- Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
-
- len = MAX_MATCH - (int)(strend - scan);
-
- if (len < MIN_MATCH) return MIN_MATCH - 1;
-
- s->match_start = cur_match;
- return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
-}
-
-#ifdef DEBUG
-#define EQUAL 0
-/* result of memcmp for equal strings */
-
-/* ===========================================================================
- * Check that the match at match_start is indeed a match.
- */
-local void check_match(s, start, match, length)
- deflate_state *s;
- IPos start, match;
- int length;
-{
- /* check that the match is indeed a match */
- if (zmemcmp(s->window + match,
- s->window + start, length) != EQUAL) {
- fprintf(stderr, " start %u, match %u, length %d\n",
- start, match, length);
- do {
- fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
- } while (--length != 0);
- z_error("invalid match");
- }
- if (z_verbose > 1) {
- fprintf(stderr,"\\[%d,%d]", start-match, length);
- do { putc(s->window[start++], stderr); } while (--length != 0);
- }
-}
-#else
-# define check_match(s, start, match, length)
-#endif /* DEBUG */
-
-/* ===========================================================================
- * Fill the window when the lookahead becomes insufficient.
- * Updates strstart and lookahead.
- *
- * IN assertion: lookahead < MIN_LOOKAHEAD
- * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
- * At least one byte has been read, or avail_in == 0; reads are
- * performed for at least two bytes (required for the zip translate_eol
- * option -- not supported here).
- */
-local void fill_window(s)
- deflate_state *s;
-{
- register unsigned n, m;
- register Posf *p;
- unsigned more; /* Amount of free space at the end of the window. */
- uInt wsize = s->w_size;
-
- do {
- more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
-
- /* Deal with !@#$% 64K limit: */
- if (sizeof(int) <= 2) {
- if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
- more = wsize;
-
- } else if (more == (unsigned)(-1)) {
- /* Very unlikely, but possible on 16 bit machine if
- * strstart == 0 && lookahead == 1 (input done a byte at time)
- */
- more--;
- }
- }
-
- /* If the window is almost full and there is insufficient lookahead,
- * move the upper half to the lower one to make room in the upper half.
- */
- if (s->strstart >= wsize+MAX_DIST(s)) {
-
- zmemcpy(s->window, s->window+wsize, (unsigned)wsize);
- s->match_start -= wsize;
- s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
- s->block_start -= (long) wsize;
-
- /* Slide the hash table (could be avoided with 32 bit values
- at the expense of memory usage). We slide even when level == 0
- to keep the hash table consistent if we switch back to level > 0
- later. (Using level 0 permanently is not an optimal usage of
- zlib, so we don't care about this pathological case.)
- */
- /* %%% avoid this when Z_RLE */
- n = s->hash_size;
- p = &s->head[n];
- do {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- } while (--n);
-
- n = wsize;
-#ifndef FASTEST
- p = &s->prev[n];
- do {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- /* If n is not on any hash chain, prev[n] is garbage but
- * its value will never be used.
- */
- } while (--n);
-#endif
- more += wsize;
- }
- if (s->strm->avail_in == 0) return;
-
- /* If there was no sliding:
- * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
- * more == window_size - lookahead - strstart
- * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
- * => more >= window_size - 2*WSIZE + 2
- * In the BIG_MEM or MMAP case (not yet supported),
- * window_size == input_size + MIN_LOOKAHEAD &&
- * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
- * Otherwise, window_size == 2*WSIZE so more >= 2.
- * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
- */
- Assert(more >= 2, "more < 2");
-
- n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
- s->lookahead += n;
-
- /* Initialize the hash value now that we have some input: */
- if (s->lookahead >= MIN_MATCH) {
- s->ins_h = s->window[s->strstart];
- UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
-#if MIN_MATCH != 3
- Call UPDATE_HASH() MIN_MATCH-3 more times
-#endif
- }
- /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
- * but this is not important since only literal bytes will be emitted.
- */
-
- } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
-}
-
-/* ===========================================================================
- * Flush the current block, with given end-of-file flag.
- * IN assertion: strstart is set to the end of the current match.
- */
-#define FLUSH_BLOCK_ONLY(s, eof) { \
- _tr_flush_block(s, (s->block_start >= 0L ? \
- (charf *)&s->window[(unsigned)s->block_start] : \
- (charf *)Z_NULL), \
- (ulg)((long)s->strstart - s->block_start), \
- (eof)); \
- s->block_start = s->strstart; \
- flush_pending(s->strm); \
- Tracev((stderr,"[FLUSH]")); \
-}
-
-/* Same but force premature exit if necessary. */
-#define FLUSH_BLOCK(s, eof) { \
- FLUSH_BLOCK_ONLY(s, eof); \
- if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \
-}
-
-/* ===========================================================================
- * Copy without compression as much as possible from the input stream, return
- * the current block state.
- * This function does not insert new strings in the dictionary since
- * uncompressible data is probably not useful. This function is used
- * only for the level=0 compression option.
- * NOTE: this function should be optimized to avoid extra copying from
- * window to pending_buf.
- */
-local block_state deflate_stored(s, flush)
- deflate_state *s;
- int flush;
-{
- /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
- * to pending_buf_size, and each stored block has a 5 byte header:
- */
- ulg max_block_size = 0xffff;
- ulg max_start;
-
- if (max_block_size > s->pending_buf_size - 5) {
- max_block_size = s->pending_buf_size - 5;
- }
-
- /* Copy as much as possible from input to output: */
- for (;;) {
- /* Fill the window as much as possible: */
- if (s->lookahead <= 1) {
-
- Assert(s->strstart < s->w_size+MAX_DIST(s) ||
- s->block_start >= (long)s->w_size, "slide too late");
-
- fill_window(s);
- if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
-
- if (s->lookahead == 0) break; /* flush the current block */
- }
- Assert(s->block_start >= 0L, "block gone");
-
- s->strstart += s->lookahead;
- s->lookahead = 0;
-
- /* Emit a stored block if pending_buf will be full: */
- max_start = s->block_start + max_block_size;
- if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
- /* strstart == 0 is possible when wraparound on 16-bit machine */
- s->lookahead = (uInt)(s->strstart - max_start);
- s->strstart = (uInt)max_start;
- FLUSH_BLOCK(s, 0);
- }
- /* Flush if we may have to slide, otherwise block_start may become
- * negative and the data will be gone:
- */
- if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
- FLUSH_BLOCK(s, 0);
- }
- }
- FLUSH_BLOCK(s, flush == Z_FINISH);
- return flush == Z_FINISH ? finish_done : block_done;
-}
-
-/* ===========================================================================
- * Compress as much as possible from the input stream, return the current
- * block state.
- * This function does not perform lazy evaluation of matches and inserts
- * new strings in the dictionary only for unmatched strings or for short
- * matches. It is used only for the fast compression options.
- */
-local block_state deflate_fast(s, flush)
- deflate_state *s;
- int flush;
-{
- IPos hash_head = NIL; /* head of the hash chain */
- int bflush; /* set if current block must be flushed */
-
- for (;;) {
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the next match, plus MIN_MATCH bytes to insert the
- * string following the next match.
- */
- if (s->lookahead < MIN_LOOKAHEAD) {
- fill_window(s);
- if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
- return need_more;
- }
- if (s->lookahead == 0) break; /* flush the current block */
- }
-
- /* Insert the string window[strstart .. strstart+2] in the
- * dictionary, and set hash_head to the head of the hash chain:
- */
- if (s->lookahead >= MIN_MATCH) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
-
- /* Find the longest match, discarding those <= prev_length.
- * At this point we have always match_length < MIN_MATCH
- */
- if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
- /* To simplify the code, we prevent matches with the string
- * of window index 0 (in particular we have to avoid a match
- * of the string with itself at the start of the input file).
- */
-#ifdef FASTEST
- if ((s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) ||
- (s->strategy == Z_RLE && s->strstart - hash_head == 1)) {
- s->match_length = longest_match_fast (s, hash_head);
- }
-#else
- if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
- s->match_length = longest_match (s, hash_head);
- } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
- s->match_length = longest_match_fast (s, hash_head);
- }
-#endif
- /* longest_match() or longest_match_fast() sets match_start */
- }
- if (s->match_length >= MIN_MATCH) {
- check_match(s, s->strstart, s->match_start, s->match_length);
-
- _tr_tally_dist(s, s->strstart - s->match_start,
- s->match_length - MIN_MATCH, bflush);
-
- s->lookahead -= s->match_length;
-
- /* Insert new strings in the hash table only if the match length
- * is not too large. This saves time but degrades compression.
- */
-#ifndef FASTEST
- if (s->match_length <= s->max_insert_length &&
- s->lookahead >= MIN_MATCH) {
- s->match_length--; /* string at strstart already in table */
- do {
- s->strstart++;
- INSERT_STRING(s, s->strstart, hash_head);
- /* strstart never exceeds WSIZE-MAX_MATCH, so there are
- * always MIN_MATCH bytes ahead.
- */
- } while (--s->match_length != 0);
- s->strstart++;
- } else
-#endif
- {
- s->strstart += s->match_length;
- s->match_length = 0;
- s->ins_h = s->window[s->strstart];
- UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
-#if MIN_MATCH != 3
- Call UPDATE_HASH() MIN_MATCH-3 more times
-#endif
- /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
- * matter since it will be recomputed at next deflate call.
- */
- }
- } else {
- /* No match, output a literal byte */
- Tracevv((stderr,"%c", s->window[s->strstart]));
- _tr_tally_lit (s, s->window[s->strstart], bflush);
- s->lookahead--;
- s->strstart++;
- }
- if (bflush) FLUSH_BLOCK(s, 0);
- }
- FLUSH_BLOCK(s, flush == Z_FINISH);
- return flush == Z_FINISH ? finish_done : block_done;
-}
-
-#ifndef FASTEST
-/* ===========================================================================
- * Same as above, but achieves better compression. We use a lazy
- * evaluation for matches: a match is finally adopted only if there is
- * no better match at the next window position.
- */
-local block_state deflate_slow(s, flush)
- deflate_state *s;
- int flush;
-{
- IPos hash_head = NIL; /* head of hash chain */
- int bflush; /* set if current block must be flushed */
-
- /* Process the input block. */
- for (;;) {
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the next match, plus MIN_MATCH bytes to insert the
- * string following the next match.
- */
- if (s->lookahead < MIN_LOOKAHEAD) {
- fill_window(s);
- if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
- return need_more;
- }
- if (s->lookahead == 0) break; /* flush the current block */
- }
-
- /* Insert the string window[strstart .. strstart+2] in the
- * dictionary, and set hash_head to the head of the hash chain:
- */
- if (s->lookahead >= MIN_MATCH) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
-
- /* Find the longest match, discarding those <= prev_length.
- */
- s->prev_length = s->match_length, s->prev_match = s->match_start;
- s->match_length = MIN_MATCH-1;
-
- if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
- s->strstart - hash_head <= MAX_DIST(s)) {
- /* To simplify the code, we prevent matches with the string
- * of window index 0 (in particular we have to avoid a match
- * of the string with itself at the start of the input file).
- */
- if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
- s->match_length = longest_match (s, hash_head);
- } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
- s->match_length = longest_match_fast (s, hash_head);
- }
- /* longest_match() or longest_match_fast() sets match_start */
-
- if (s->match_length <= 5 && (s->strategy == Z_FILTERED
-#if TOO_FAR <= 32767
- || (s->match_length == MIN_MATCH &&
- s->strstart - s->match_start > TOO_FAR)
-#endif
- )) {
-
- /* If prev_match is also MIN_MATCH, match_start is garbage
- * but we will ignore the current match anyway.
- */
- s->match_length = MIN_MATCH-1;
- }
- }
- /* If there was a match at the previous step and the current
- * match is not better, output the previous match:
- */
- if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
- uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
- /* Do not insert strings in hash table beyond this. */
-
- check_match(s, s->strstart-1, s->prev_match, s->prev_length);
-
- _tr_tally_dist(s, s->strstart -1 - s->prev_match,
- s->prev_length - MIN_MATCH, bflush);
-
- /* Insert in hash table all strings up to the end of the match.
- * strstart-1 and strstart are already inserted. If there is not
- * enough lookahead, the last two strings are not inserted in
- * the hash table.
- */
- s->lookahead -= s->prev_length-1;
- s->prev_length -= 2;
- do {
- if (++s->strstart <= max_insert) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
- } while (--s->prev_length != 0);
- s->match_available = 0;
- s->match_length = MIN_MATCH-1;
- s->strstart++;
-
- if (bflush) FLUSH_BLOCK(s, 0);
-
- } else if (s->match_available) {
- /* If there was no match at the previous position, output a
- * single literal. If there was a match but the current match
- * is longer, truncate the previous match to a single literal.
- */
- Tracevv((stderr,"%c", s->window[s->strstart-1]));
- _tr_tally_lit(s, s->window[s->strstart-1], bflush);
- if (bflush) {
- FLUSH_BLOCK_ONLY(s, 0);
- }
- s->strstart++;
- s->lookahead--;
- if (s->strm->avail_out == 0) return need_more;
- } else {
- /* There is no previous match to compare with, wait for
- * the next step to decide.
- */
- s->match_available = 1;
- s->strstart++;
- s->lookahead--;
- }
- }
- Assert (flush != Z_NO_FLUSH, "no flush?");
- if (s->match_available) {
- Tracevv((stderr,"%c", s->window[s->strstart-1]));
- _tr_tally_lit(s, s->window[s->strstart-1], bflush);
- s->match_available = 0;
- }
- FLUSH_BLOCK(s, flush == Z_FINISH);
- return flush == Z_FINISH ? finish_done : block_done;
-}
-#endif /* FASTEST */
-
-#if 0
-/* ===========================================================================
- * For Z_RLE, simply look for runs of bytes, generate matches only of distance
- * one. Do not maintain a hash table. (It will be regenerated if this run of
- * deflate switches away from Z_RLE.)
- */
-local block_state deflate_rle(s, flush)
- deflate_state *s;
- int flush;
-{
- int bflush; /* set if current block must be flushed */
- uInt run; /* length of run */
- uInt max; /* maximum length of run */
- uInt prev; /* byte at distance one to match */
- Bytef *scan; /* scan for end of run */
-
- for (;;) {
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the longest encodable run.
- */
- if (s->lookahead < MAX_MATCH) {
- fill_window(s);
- if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) {
- return need_more;
- }
- if (s->lookahead == 0) break; /* flush the current block */
- }
-
- /* See how many times the previous byte repeats */
- run = 0;
- if (s->strstart > 0) { /* if there is a previous byte, that is */
- max = s->lookahead < MAX_MATCH ? s->lookahead : MAX_MATCH;
- scan = s->window + s->strstart - 1;
- prev = *scan++;
- do {
- if (*scan++ != prev)
- break;
- } while (++run < max);
- }
-
- /* Emit match if have run of MIN_MATCH or longer, else emit literal */
- if (run >= MIN_MATCH) {
- check_match(s, s->strstart, s->strstart - 1, run);
- _tr_tally_dist(s, 1, run - MIN_MATCH, bflush);
- s->lookahead -= run;
- s->strstart += run;
- } else {
- /* No match, output a literal byte */
- Tracevv((stderr,"%c", s->window[s->strstart]));
- _tr_tally_lit (s, s->window[s->strstart], bflush);
- s->lookahead--;
- s->strstart++;
- }
- if (bflush) FLUSH_BLOCK(s, 0);
- }
- FLUSH_BLOCK(s, flush == Z_FINISH);
- return flush == Z_FINISH ? finish_done : block_done;
-}
-#endif
diff --git a/source4/lib/zlib/deflate.h b/source4/lib/zlib/deflate.h
deleted file mode 100644
index 05a5ab3a2c..0000000000
--- a/source4/lib/zlib/deflate.h
+++ /dev/null
@@ -1,331 +0,0 @@
-/* deflate.h -- internal compression state
- * Copyright (C) 1995-2004 Jean-loup Gailly
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* @(#) $Id$ */
-
-#ifndef DEFLATE_H
-#define DEFLATE_H
-
-#include "zutil.h"
-
-/* define NO_GZIP when compiling if you want to disable gzip header and
- trailer creation by deflate(). NO_GZIP would be used to avoid linking in
- the crc code when it is not needed. For shared libraries, gzip encoding
- should be left enabled. */
-#ifndef NO_GZIP
-# define GZIP
-#endif
-
-/* ===========================================================================
- * Internal compression state.
- */
-
-#define LENGTH_CODES 29
-/* number of length codes, not counting the special END_BLOCK code */
-
-#define LITERALS 256
-/* number of literal bytes 0..255 */
-
-#define L_CODES (LITERALS+1+LENGTH_CODES)
-/* number of Literal or Length codes, including the END_BLOCK code */
-
-#define D_CODES 30
-/* number of distance codes */
-
-#define BL_CODES 19
-/* number of codes used to transfer the bit lengths */
-
-#define HEAP_SIZE (2*L_CODES+1)
-/* maximum heap size */
-
-#define MAX_BITS 15
-/* All codes must not exceed MAX_BITS bits */
-
-#define INIT_STATE 42
-#define EXTRA_STATE 69
-#define NAME_STATE 73
-#define COMMENT_STATE 91
-#define HCRC_STATE 103
-#define BUSY_STATE 113
-#define FINISH_STATE 666
-/* Stream status */
-
-
-/* Data structure describing a single value and its code string. */
-typedef struct ct_data_s {
- union {
- ush freq; /* frequency count */
- ush code; /* bit string */
- } fc;
- union {
- ush dad; /* father node in Huffman tree */
- ush len; /* length of bit string */
- } dl;
-} FAR ct_data;
-
-#define Freq fc.freq
-#define Code fc.code
-#define Dad dl.dad
-#define Len dl.len
-
-typedef struct static_tree_desc_s static_tree_desc;
-
-typedef struct tree_desc_s {
- ct_data *dyn_tree; /* the dynamic tree */
- int max_code; /* largest code with non zero frequency */
- static_tree_desc *stat_desc; /* the corresponding static tree */
-} FAR tree_desc;
-
-typedef ush Pos;
-typedef Pos FAR Posf;
-typedef unsigned IPos;
-
-/* A Pos is an index in the character window. We use short instead of int to
- * save space in the various tables. IPos is used only for parameter passing.
- */
-
-typedef struct internal_state {
- z_streamp strm; /* pointer back to this zlib stream */
- int status; /* as the name implies */
- Bytef *pending_buf; /* output still pending */
- ulg pending_buf_size; /* size of pending_buf */
- Bytef *pending_out; /* next pending byte to output to the stream */
- uInt pending; /* nb of bytes in the pending buffer */
- int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
- gz_headerp gzhead; /* gzip header information to write */
- uInt gzindex; /* where in extra, name, or comment */
- Byte method; /* STORED (for zip only) or DEFLATED */
- int last_flush; /* value of flush param for previous deflate call */
-
- /* used by deflate.c: */
-
- uInt w_size; /* LZ77 window size (32K by default) */
- uInt w_bits; /* log2(w_size) (8..16) */
- uInt w_mask; /* w_size - 1 */
-
- Bytef *window;
- /* Sliding window. Input bytes are read into the second half of the window,
- * and move to the first half later to keep a dictionary of at least wSize
- * bytes. With this organization, matches are limited to a distance of
- * wSize-MAX_MATCH bytes, but this ensures that IO is always
- * performed with a length multiple of the block size. Also, it limits
- * the window size to 64K, which is quite useful on MSDOS.
- * To do: use the user input buffer as sliding window.
- */
-
- ulg window_size;
- /* Actual size of window: 2*wSize, except when the user input buffer
- * is directly used as sliding window.
- */
-
- Posf *prev;
- /* Link to older string with same hash index. To limit the size of this
- * array to 64K, this link is maintained only for the last 32K strings.
- * An index in this array is thus a window index modulo 32K.
- */
-
- Posf *head; /* Heads of the hash chains or NIL. */
-
- uInt ins_h; /* hash index of string to be inserted */
- uInt hash_size; /* number of elements in hash table */
- uInt hash_bits; /* log2(hash_size) */
- uInt hash_mask; /* hash_size-1 */
-
- uInt hash_shift;
- /* Number of bits by which ins_h must be shifted at each input
- * step. It must be such that after MIN_MATCH steps, the oldest
- * byte no longer takes part in the hash key, that is:
- * hash_shift * MIN_MATCH >= hash_bits
- */
-
- long block_start;
- /* Window position at the beginning of the current output block. Gets
- * negative when the window is moved backwards.
- */
-
- uInt match_length; /* length of best match */
- IPos prev_match; /* previous match */
- int match_available; /* set if previous match exists */
- uInt strstart; /* start of string to insert */
- uInt match_start; /* start of matching string */
- uInt lookahead; /* number of valid bytes ahead in window */
-
- uInt prev_length;
- /* Length of the best match at previous step. Matches not greater than this
- * are discarded. This is used in the lazy match evaluation.
- */
-
- uInt max_chain_length;
- /* To speed up deflation, hash chains are never searched beyond this
- * length. A higher limit improves compression ratio but degrades the
- * speed.
- */
-
- uInt max_lazy_match;
- /* Attempt to find a better match only when the current match is strictly
- * smaller than this value. This mechanism is used only for compression
- * levels >= 4.
- */
-# define max_insert_length max_lazy_match
- /* Insert new strings in the hash table only if the match length is not
- * greater than this length. This saves time but degrades compression.
- * max_insert_length is used only for compression levels <= 3.
- */
-
- int level; /* compression level (1..9) */
- int strategy; /* favor or force Huffman coding*/
-
- uInt good_match;
- /* Use a faster search when the previous match is longer than this */
-
- int nice_match; /* Stop searching when current match exceeds this */
-
- /* used by trees.c: */
- /* Didn't use ct_data typedef below to supress compiler warning */
- struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
- struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
- struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
-
- struct tree_desc_s l_desc; /* desc. for literal tree */
- struct tree_desc_s d_desc; /* desc. for distance tree */
- struct tree_desc_s bl_desc; /* desc. for bit length tree */
-
- ush bl_count[MAX_BITS+1];
- /* number of codes at each bit length for an optimal tree */
-
- int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
- int heap_len; /* number of elements in the heap */
- int heap_max; /* element of largest frequency */
- /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
- * The same heap array is used to build all trees.
- */
-
- uch depth[2*L_CODES+1];
- /* Depth of each subtree used as tie breaker for trees of equal frequency
- */
-
- uchf *l_buf; /* buffer for literals or lengths */
-
- uInt lit_bufsize;
- /* Size of match buffer for literals/lengths. There are 4 reasons for
- * limiting lit_bufsize to 64K:
- * - frequencies can be kept in 16 bit counters
- * - if compression is not successful for the first block, all input
- * data is still in the window so we can still emit a stored block even
- * when input comes from standard input. (This can also be done for
- * all blocks if lit_bufsize is not greater than 32K.)
- * - if compression is not successful for a file smaller than 64K, we can
- * even emit a stored file instead of a stored block (saving 5 bytes).
- * This is applicable only for zip (not gzip or zlib).
- * - creating new Huffman trees less frequently may not provide fast
- * adaptation to changes in the input data statistics. (Take for
- * example a binary file with poorly compressible code followed by
- * a highly compressible string table.) Smaller buffer sizes give
- * fast adaptation but have of course the overhead of transmitting
- * trees more frequently.
- * - I can't count above 4
- */
-
- uInt last_lit; /* running index in l_buf */
-
- ushf *d_buf;
- /* Buffer for distances. To simplify the code, d_buf and l_buf have
- * the same number of elements. To use different lengths, an extra flag
- * array would be necessary.
- */
-
- ulg opt_len; /* bit length of current block with optimal trees */
- ulg static_len; /* bit length of current block with static trees */
- uInt matches; /* number of string matches in current block */
- int last_eob_len; /* bit length of EOB code for last block */
-
-#ifdef DEBUG
- ulg compressed_len; /* total bit length of compressed file mod 2^32 */
- ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
-#endif
-
- ush bi_buf;
- /* Output buffer. bits are inserted starting at the bottom (least
- * significant bits).
- */
- int bi_valid;
- /* Number of valid bits in bi_buf. All bits above the last valid bit
- * are always zero.
- */
-
-} FAR deflate_state;
-
-/* Output a byte on the stream.
- * IN assertion: there is enough room in pending_buf.
- */
-#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
-
-
-#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
-/* Minimum amount of lookahead, except at the end of the input file.
- * See deflate.c for comments about the MIN_MATCH+1.
- */
-
-#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
-/* In order to simplify the code, particularly on 16 bit machines, match
- * distances are limited to MAX_DIST instead of WSIZE.
- */
-
- /* in trees.c */
-void _tr_init OF((deflate_state *s));
-int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
-void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
- int eof));
-void _tr_align OF((deflate_state *s));
-void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
- int eof));
-
-#define d_code(dist) \
- ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
-/* Mapping from a distance to a distance code. dist is the distance - 1 and
- * must not have side effects. _dist_code[256] and _dist_code[257] are never
- * used.
- */
-
-#ifndef DEBUG
-/* Inline versions of _tr_tally for speed: */
-
-#if defined(GEN_TREES_H) || !defined(STDC)
- extern uch _length_code[];
- extern uch _dist_code[];
-#else
- extern const uch _length_code[];
- extern const uch _dist_code[];
-#endif
-
-# define _tr_tally_lit(s, c, flush) \
- { uch cc = (c); \
- s->d_buf[s->last_lit] = 0; \
- s->l_buf[s->last_lit++] = cc; \
- s->dyn_ltree[cc].Freq++; \
- flush = (s->last_lit == s->lit_bufsize-1); \
- }
-# define _tr_tally_dist(s, distance, length, flush) \
- { uch len = (length); \
- ush dist = (distance); \
- s->d_buf[s->last_lit] = dist; \
- s->l_buf[s->last_lit++] = len; \
- dist--; \
- s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
- s->dyn_dtree[d_code(dist)].Freq++; \
- flush = (s->last_lit == s->lit_bufsize-1); \
- }
-#else
-# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
-# define _tr_tally_dist(s, distance, length, flush) \
- flush = _tr_tally(s, distance, length)
-#endif
-
-#endif /* DEFLATE_H */
diff --git a/source4/lib/zlib/example.c b/source4/lib/zlib/example.c
deleted file mode 100644
index 6c8a0ee763..0000000000
--- a/source4/lib/zlib/example.c
+++ /dev/null
@@ -1,565 +0,0 @@
-/* example.c -- usage example of the zlib compression library
- * Copyright (C) 1995-2004 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#include <stdio.h>
-#include "zlib.h"
-
-#ifdef STDC
-# include <string.h>
-# include <stdlib.h>
-#endif
-
-#if defined(VMS) || defined(RISCOS)
-# define TESTFILE "foo-gz"
-#else
-# define TESTFILE "foo.gz"
-#endif
-
-#define CHECK_ERR(err, msg) { \
- if (err != Z_OK) { \
- fprintf(stderr, "%s error: %d\n", msg, err); \
- exit(1); \
- } \
-}
-
-const char hello[] = "hello, hello!";
-/* "hello world" would be more standard, but the repeated "hello"
- * stresses the compression code better, sorry...
- */
-
-const char dictionary[] = "hello";
-uLong dictId; /* Adler32 value of the dictionary */
-
-void test_compress OF((Byte *compr, uLong comprLen,
- Byte *uncompr, uLong uncomprLen));
-void test_gzio OF((const char *fname,
- Byte *uncompr, uLong uncomprLen));
-void test_deflate OF((Byte *compr, uLong comprLen));
-void test_inflate OF((Byte *compr, uLong comprLen,
- Byte *uncompr, uLong uncomprLen));
-void test_large_deflate OF((Byte *compr, uLong comprLen,
- Byte *uncompr, uLong uncomprLen));
-void test_large_inflate OF((Byte *compr, uLong comprLen,
- Byte *uncompr, uLong uncomprLen));
-void test_flush OF((Byte *compr, uLong *comprLen));
-void test_sync OF((Byte *compr, uLong comprLen,
- Byte *uncompr, uLong uncomprLen));
-void test_dict_deflate OF((Byte *compr, uLong comprLen));
-void test_dict_inflate OF((Byte *compr, uLong comprLen,
- Byte *uncompr, uLong uncomprLen));
-int main OF((int argc, char *argv[]));
-
-/* ===========================================================================
- * Test compress() and uncompress()
- */
-void test_compress(compr, comprLen, uncompr, uncomprLen)
- Byte *compr, *uncompr;
- uLong comprLen, uncomprLen;
-{
- int err;
- uLong len = (uLong)strlen(hello)+1;
-
- err = compress(compr, &comprLen, (const Bytef*)hello, len);
- CHECK_ERR(err, "compress");
-
- strcpy((char*)uncompr, "garbage");
-
- err = uncompress(uncompr, &uncomprLen, compr, comprLen);
- CHECK_ERR(err, "uncompress");
-
- if (strcmp((char*)uncompr, hello)) {
- fprintf(stderr, "bad uncompress\n");
- exit(1);
- } else {
- printf("uncompress(): %s\n", (char *)uncompr);
- }
-}
-
-/* ===========================================================================
- * Test read/write of .gz files
- */
-void test_gzio(fname, uncompr, uncomprLen)
- const char *fname; /* compressed file name */
- Byte *uncompr;
- uLong uncomprLen;
-{
-#ifdef NO_GZCOMPRESS
- fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
-#else
- int err;
- int len = (int)strlen(hello)+1;
- gzFile file;
- z_off_t pos;
-
- file = gzopen(fname, "wb");
- if (file == NULL) {
- fprintf(stderr, "gzopen error\n");
- exit(1);
- }
- gzputc(file, 'h');
- if (gzputs(file, "ello") != 4) {
- fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err));
- exit(1);
- }
- if (gzprintf(file, ", %s!", "hello") != 8) {
- fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err));
- exit(1);
- }
- gzseek(file, 1L, SEEK_CUR); /* add one zero byte */
- gzclose(file);
-
- file = gzopen(fname, "rb");
- if (file == NULL) {
- fprintf(stderr, "gzopen error\n");
- exit(1);
- }
- strcpy((char*)uncompr, "garbage");
-
- if (gzread(file, uncompr, (unsigned)uncomprLen) != len) {
- fprintf(stderr, "gzread err: %s\n", gzerror(file, &err));
- exit(1);
- }
- if (strcmp((char*)uncompr, hello)) {
- fprintf(stderr, "bad gzread: %s\n", (char*)uncompr);
- exit(1);
- } else {
- printf("gzread(): %s\n", (char*)uncompr);
- }
-
- pos = gzseek(file, -8L, SEEK_CUR);
- if (pos != 6 || gztell(file) != pos) {
- fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
- (long)pos, (long)gztell(file));
- exit(1);
- }
-
- if (gzgetc(file) != ' ') {
- fprintf(stderr, "gzgetc error\n");
- exit(1);
- }
-
- if (gzungetc(' ', file) != ' ') {
- fprintf(stderr, "gzungetc error\n");
- exit(1);
- }
-
- gzgets(file, (char*)uncompr, (int)uncomprLen);
- if (strlen((char*)uncompr) != 7) { /* " hello!" */
- fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err));
- exit(1);
- }
- if (strcmp((char*)uncompr, hello + 6)) {
- fprintf(stderr, "bad gzgets after gzseek\n");
- exit(1);
- } else {
- printf("gzgets() after gzseek: %s\n", (char*)uncompr);
- }
-
- gzclose(file);
-#endif
-}
-
-/* ===========================================================================
- * Test deflate() with small buffers
- */
-void test_deflate(compr, comprLen)
- Byte *compr;
- uLong comprLen;
-{
- z_stream c_stream; /* compression stream */
- int err;
- uLong len = (uLong)strlen(hello)+1;
-
- c_stream.zalloc = (alloc_func)0;
- c_stream.zfree = (free_func)0;
- c_stream.opaque = (voidpf)0;
-
- err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
- CHECK_ERR(err, "deflateInit");
-
- c_stream.next_in = (Bytef*)hello;
- c_stream.next_out = compr;
-
- while (c_stream.total_in != len && c_stream.total_out < comprLen) {
- c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */
- err = deflate(&c_stream, Z_NO_FLUSH);
- CHECK_ERR(err, "deflate");
- }
- /* Finish the stream, still forcing small buffers: */
- for (;;) {
- c_stream.avail_out = 1;
- err = deflate(&c_stream, Z_FINISH);
- if (err == Z_STREAM_END) break;
- CHECK_ERR(err, "deflate");
- }
-
- err = deflateEnd(&c_stream);
- CHECK_ERR(err, "deflateEnd");
-}
-
-/* ===========================================================================
- * Test inflate() with small buffers
- */
-void test_inflate(compr, comprLen, uncompr, uncomprLen)
- Byte *compr, *uncompr;
- uLong comprLen, uncomprLen;
-{
- int err;
- z_stream d_stream; /* decompression stream */
-
- strcpy((char*)uncompr, "garbage");
-
- d_stream.zalloc = (alloc_func)0;
- d_stream.zfree = (free_func)0;
- d_stream.opaque = (voidpf)0;
-
- d_stream.next_in = compr;
- d_stream.avail_in = 0;
- d_stream.next_out = uncompr;
-
- err = inflateInit(&d_stream);
- CHECK_ERR(err, "inflateInit");
-
- while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) {
- d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */
- err = inflate(&d_stream, Z_NO_FLUSH);
- if (err == Z_STREAM_END) break;
- CHECK_ERR(err, "inflate");
- }
-
- err = inflateEnd(&d_stream);
- CHECK_ERR(err, "inflateEnd");
-
- if (strcmp((char*)uncompr, hello)) {
- fprintf(stderr, "bad inflate\n");
- exit(1);
- } else {
- printf("inflate(): %s\n", (char *)uncompr);
- }
-}
-
-/* ===========================================================================
- * Test deflate() with large buffers and dynamic change of compression level
- */
-void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
- Byte *compr, *uncompr;
- uLong comprLen, uncomprLen;
-{
- z_stream c_stream; /* compression stream */
- int err;
-
- c_stream.zalloc = (alloc_func)0;
- c_stream.zfree = (free_func)0;
- c_stream.opaque = (voidpf)0;
-
- err = deflateInit(&c_stream, Z_BEST_SPEED);
- CHECK_ERR(err, "deflateInit");
-
- c_stream.next_out = compr;
- c_stream.avail_out = (uInt)comprLen;
-
- /* At this point, uncompr is still mostly zeroes, so it should compress
- * very well:
- */
- c_stream.next_in = uncompr;
- c_stream.avail_in = (uInt)uncomprLen;
- err = deflate(&c_stream, Z_NO_FLUSH);
- CHECK_ERR(err, "deflate");
- if (c_stream.avail_in != 0) {
- fprintf(stderr, "deflate not greedy\n");
- exit(1);
- }
-
- /* Feed in already compressed data and switch to no compression: */
- deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
- c_stream.next_in = compr;
- c_stream.avail_in = (uInt)comprLen/2;
- err = deflate(&c_stream, Z_NO_FLUSH);
- CHECK_ERR(err, "deflate");
-
- /* Switch back to compressing mode: */
- deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED);
- c_stream.next_in = uncompr;
- c_stream.avail_in = (uInt)uncomprLen;
- err = deflate(&c_stream, Z_NO_FLUSH);
- CHECK_ERR(err, "deflate");
-
- err = deflate(&c_stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- fprintf(stderr, "deflate should report Z_STREAM_END\n");
- exit(1);
- }
- err = deflateEnd(&c_stream);
- CHECK_ERR(err, "deflateEnd");
-}
-
-/* ===========================================================================
- * Test inflate() with large buffers
- */
-void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
- Byte *compr, *uncompr;
- uLong comprLen, uncomprLen;
-{
- int err;
- z_stream d_stream; /* decompression stream */
-
- strcpy((char*)uncompr, "garbage");
-
- d_stream.zalloc = (alloc_func)0;
- d_stream.zfree = (free_func)0;
- d_stream.opaque = (voidpf)0;
-
- d_stream.next_in = compr;
- d_stream.avail_in = (uInt)comprLen;
-
- err = inflateInit(&d_stream);
- CHECK_ERR(err, "inflateInit");
-
- for (;;) {
- d_stream.next_out = uncompr; /* discard the output */
- d_stream.avail_out = (uInt)uncomprLen;
- err = inflate(&d_stream, Z_NO_FLUSH);
- if (err == Z_STREAM_END) break;
- CHECK_ERR(err, "large inflate");
- }
-
- err = inflateEnd(&d_stream);
- CHECK_ERR(err, "inflateEnd");
-
- if (d_stream.total_out != 2*uncomprLen + comprLen/2) {
- fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out);
- exit(1);
- } else {
- printf("large_inflate(): OK\n");
- }
-}
-
-/* ===========================================================================
- * Test deflate() with full flush
- */
-void test_flush(compr, comprLen)
- Byte *compr;
- uLong *comprLen;
-{
- z_stream c_stream; /* compression stream */
- int err;
- uInt len = (uInt)strlen(hello)+1;
-
- c_stream.zalloc = (alloc_func)0;
- c_stream.zfree = (free_func)0;
- c_stream.opaque = (voidpf)0;
-
- err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
- CHECK_ERR(err, "deflateInit");
-
- c_stream.next_in = (Bytef*)hello;
- c_stream.next_out = compr;
- c_stream.avail_in = 3;
- c_stream.avail_out = (uInt)*comprLen;
- err = deflate(&c_stream, Z_FULL_FLUSH);
- CHECK_ERR(err, "deflate");
-
- compr[3]++; /* force an error in first compressed block */
- c_stream.avail_in = len - 3;
-
- err = deflate(&c_stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- CHECK_ERR(err, "deflate");
- }
- err = deflateEnd(&c_stream);
- CHECK_ERR(err, "deflateEnd");
-
- *comprLen = c_stream.total_out;
-}
-
-/* ===========================================================================
- * Test inflateSync()
- */
-void test_sync(compr, comprLen, uncompr, uncomprLen)
- Byte *compr, *uncompr;
- uLong comprLen, uncomprLen;
-{
- int err;
- z_stream d_stream; /* decompression stream */
-
- strcpy((char*)uncompr, "garbage");
-
- d_stream.zalloc = (alloc_func)0;
- d_stream.zfree = (free_func)0;
- d_stream.opaque = (voidpf)0;
-
- d_stream.next_in = compr;
- d_stream.avail_in = 2; /* just read the zlib header */
-
- err = inflateInit(&d_stream);
- CHECK_ERR(err, "inflateInit");
-
- d_stream.next_out = uncompr;
- d_stream.avail_out = (uInt)uncomprLen;
-
- inflate(&d_stream, Z_NO_FLUSH);
- CHECK_ERR(err, "inflate");
-
- d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */
- err = inflateSync(&d_stream); /* but skip the damaged part */
- CHECK_ERR(err, "inflateSync");
-
- err = inflate(&d_stream, Z_FINISH);
- if (err != Z_DATA_ERROR) {
- fprintf(stderr, "inflate should report DATA_ERROR\n");
- /* Because of incorrect adler32 */
- exit(1);
- }
- err = inflateEnd(&d_stream);
- CHECK_ERR(err, "inflateEnd");
-
- printf("after inflateSync(): hel%s\n", (char *)uncompr);
-}
-
-/* ===========================================================================
- * Test deflate() with preset dictionary
- */
-void test_dict_deflate(compr, comprLen)
- Byte *compr;
- uLong comprLen;
-{
- z_stream c_stream; /* compression stream */
- int err;
-
- c_stream.zalloc = (alloc_func)0;
- c_stream.zfree = (free_func)0;
- c_stream.opaque = (voidpf)0;
-
- err = deflateInit(&c_stream, Z_BEST_COMPRESSION);
- CHECK_ERR(err, "deflateInit");
-
- err = deflateSetDictionary(&c_stream,
- (const Bytef*)dictionary, sizeof(dictionary));
- CHECK_ERR(err, "deflateSetDictionary");
-
- dictId = c_stream.adler;
- c_stream.next_out = compr;
- c_stream.avail_out = (uInt)comprLen;
-
- c_stream.next_in = (Bytef*)hello;
- c_stream.avail_in = (uInt)strlen(hello)+1;
-
- err = deflate(&c_stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- fprintf(stderr, "deflate should report Z_STREAM_END\n");
- exit(1);
- }
- err = deflateEnd(&c_stream);
- CHECK_ERR(err, "deflateEnd");
-}
-
-/* ===========================================================================
- * Test inflate() with a preset dictionary
- */
-void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
- Byte *compr, *uncompr;
- uLong comprLen, uncomprLen;
-{
- int err;
- z_stream d_stream; /* decompression stream */
-
- strcpy((char*)uncompr, "garbage");
-
- d_stream.zalloc = (alloc_func)0;
- d_stream.zfree = (free_func)0;
- d_stream.opaque = (voidpf)0;
-
- d_stream.next_in = compr;
- d_stream.avail_in = (uInt)comprLen;
-
- err = inflateInit(&d_stream);
- CHECK_ERR(err, "inflateInit");
-
- d_stream.next_out = uncompr;
- d_stream.avail_out = (uInt)uncomprLen;
-
- for (;;) {
- err = inflate(&d_stream, Z_NO_FLUSH);
- if (err == Z_STREAM_END) break;
- if (err == Z_NEED_DICT) {
- if (d_stream.adler != dictId) {
- fprintf(stderr, "unexpected dictionary");
- exit(1);
- }
- err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary,
- sizeof(dictionary));
- }
- CHECK_ERR(err, "inflate with dict");
- }
-
- err = inflateEnd(&d_stream);
- CHECK_ERR(err, "inflateEnd");
-
- if (strcmp((char*)uncompr, hello)) {
- fprintf(stderr, "bad inflate with dict\n");
- exit(1);
- } else {
- printf("inflate with dictionary: %s\n", (char *)uncompr);
- }
-}
-
-/* ===========================================================================
- * Usage: example [output.gz [input.gz]]
- */
-
-int main(argc, argv)
- int argc;
- char *argv[];
-{
- Byte *compr, *uncompr;
- uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
- uLong uncomprLen = comprLen;
- static const char* myVersion = ZLIB_VERSION;
-
- if (zlibVersion()[0] != myVersion[0]) {
- fprintf(stderr, "incompatible zlib version\n");
- exit(1);
-
- } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) {
- fprintf(stderr, "warning: different zlib version\n");
- }
-
- printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n",
- ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags());
-
- compr = (Byte*)calloc((uInt)comprLen, 1);
- uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
- /* compr and uncompr are cleared to avoid reading uninitialized
- * data and to ensure that uncompr compresses well.
- */
- if (compr == Z_NULL || uncompr == Z_NULL) {
- printf("out of memory\n");
- exit(1);
- }
- test_compress(compr, comprLen, uncompr, uncomprLen);
-
- test_gzio((argc > 1 ? argv[1] : TESTFILE),
- uncompr, uncomprLen);
-
- test_deflate(compr, comprLen);
- test_inflate(compr, comprLen, uncompr, uncomprLen);
-
- test_large_deflate(compr, comprLen, uncompr, uncomprLen);
- test_large_inflate(compr, comprLen, uncompr, uncomprLen);
-
- test_flush(compr, &comprLen);
- test_sync(compr, comprLen, uncompr, uncomprLen);
- comprLen = uncomprLen;
-
- test_dict_deflate(compr, comprLen);
- test_dict_inflate(compr, comprLen, uncompr, uncomprLen);
-
- free(compr);
- free(uncompr);
-
- return 0;
-}
diff --git a/source4/lib/zlib/examples/README.examples b/source4/lib/zlib/examples/README.examples
deleted file mode 100644
index 5632d7a4cc..0000000000
--- a/source4/lib/zlib/examples/README.examples
+++ /dev/null
@@ -1,42 +0,0 @@
-This directory contains examples of the use of zlib.
-
-fitblk.c
- compress just enough input to nearly fill a requested output size
- - zlib isn't designed to do this, but fitblk does it anyway
-
-gun.c
- uncompress a gzip file
- - illustrates the use of inflateBack() for high speed file-to-file
- decompression using call-back functions
- - is approximately twice as fast as gzip -d
- - also provides Unix uncompress functionality, again twice as fast
-
-gzappend.c
- append to a gzip file
- - illustrates the use of the Z_BLOCK flush parameter for inflate()
- - illustrates the use of deflatePrime() to start at any bit
-
-gzjoin.c
- join gzip files without recalculating the crc or recompressing
- - illustrates the use of the Z_BLOCK flush parameter for inflate()
- - illustrates the use of crc32_combine()
-
-gzlog.c
-gzlog.h
- efficiently maintain a message log file in gzip format
- - illustrates use of raw deflate and Z_SYNC_FLUSH
- - illustrates use of gzip header extra field
-
-zlib_how.html
- painfully comprehensive description of zpipe.c (see below)
- - describes in excruciating detail the use of deflate() and inflate()
-
-zpipe.c
- reads and writes zlib streams from stdin to stdout
- - illustrates the proper use of deflate() and inflate()
- - deeply commented in zlib_how.html (see above)
-
-zran.c
- index a zlib or gzip stream and randomly access it
- - illustrates the use of Z_BLOCK, inflatePrime(), and
- inflateSetDictionary() to provide random access
diff --git a/source4/lib/zlib/examples/fitblk.c b/source4/lib/zlib/examples/fitblk.c
deleted file mode 100644
index c61de5c996..0000000000
--- a/source4/lib/zlib/examples/fitblk.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/* fitblk.c: example of fitting compressed output to a specified size
- Not copyrighted -- provided to the public domain
- Version 1.1 25 November 2004 Mark Adler */
-
-/* Version history:
- 1.0 24 Nov 2004 First version
- 1.1 25 Nov 2004 Change deflateInit2() to deflateInit()
- Use fixed-size, stack-allocated raw buffers
- Simplify code moving compression to subroutines
- Use assert() for internal errors
- Add detailed description of approach
- */
-
-/* Approach to just fitting a requested compressed size:
-
- fitblk performs three compression passes on a portion of the input
- data in order to determine how much of that input will compress to
- nearly the requested output block size. The first pass generates
- enough deflate blocks to produce output to fill the requested
- output size plus a specfied excess amount (see the EXCESS define
- below). The last deflate block may go quite a bit past that, but
- is discarded. The second pass decompresses and recompresses just
- the compressed data that fit in the requested plus excess sized
- buffer. The deflate process is terminated after that amount of
- input, which is less than the amount consumed on the first pass.
- The last deflate block of the result will be of a comparable size
- to the final product, so that the header for that deflate block and
- the compression ratio for that block will be about the same as in
- the final product. The third compression pass decompresses the
- result of the second step, but only the compressed data up to the
- requested size minus an amount to allow the compressed stream to
- complete (see the MARGIN define below). That will result in a
- final compressed stream whose length is less than or equal to the
- requested size. Assuming sufficient input and a requested size
- greater than a few hundred bytes, the shortfall will typically be
- less than ten bytes.
-
- If the input is short enough that the first compression completes
- before filling the requested output size, then that compressed
- stream is return with no recompression.
-
- EXCESS is chosen to be just greater than the shortfall seen in a
- two pass approach similar to the above. That shortfall is due to
- the last deflate block compressing more efficiently with a smaller
- header on the second pass. EXCESS is set to be large enough so
- that there is enough uncompressed data for the second pass to fill
- out the requested size, and small enough so that the final deflate
- block of the second pass will be close in size to the final deflate
- block of the third and final pass. MARGIN is chosen to be just
- large enough to assure that the final compression has enough room
- to complete in all cases.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include "zlib.h"
-
-#define local static
-
-/* print nastygram and leave */
-local void quit(char *why)
-{
- fprintf(stderr, "fitblk abort: %s\n", why);
- exit(1);
-}
-
-#define RAWLEN 4096 /* intermediate uncompressed buffer size */
-
-/* compress from file to def until provided buffer is full or end of
- input reached; return last deflate() return value, or Z_ERRNO if
- there was read error on the file */
-local int partcompress(FILE *in, z_streamp def)
-{
- int ret, flush;
- unsigned char raw[RAWLEN];
-
- flush = Z_NO_FLUSH;
- do {
- def->avail_in = fread(raw, 1, RAWLEN, in);
- if (ferror(in))
- return Z_ERRNO;
- def->next_in = raw;
- if (feof(in))
- flush = Z_FINISH;
- ret = deflate(def, flush);
- assert(ret != Z_STREAM_ERROR);
- } while (def->avail_out != 0 && flush == Z_NO_FLUSH);
- return ret;
-}
-
-/* recompress from inf's input to def's output; the input for inf and
- the output for def are set in those structures before calling;
- return last deflate() return value, or Z_MEM_ERROR if inflate()
- was not able to allocate enough memory when it needed to */
-local int recompress(z_streamp inf, z_streamp def)
-{
- int ret, flush;
- unsigned char raw[RAWLEN];
-
- flush = Z_NO_FLUSH;
- do {
- /* decompress */
- inf->avail_out = RAWLEN;
- inf->next_out = raw;
- ret = inflate(inf, Z_NO_FLUSH);
- assert(ret != Z_STREAM_ERROR && ret != Z_DATA_ERROR &&
- ret != Z_NEED_DICT);
- if (ret == Z_MEM_ERROR)
- return ret;
-
- /* compress what was decompresed until done or no room */
- def->avail_in = RAWLEN - inf->avail_out;
- def->next_in = raw;
- if (inf->avail_out != 0)
- flush = Z_FINISH;
- ret = deflate(def, flush);
- assert(ret != Z_STREAM_ERROR);
- } while (ret != Z_STREAM_END && def->avail_out != 0);
- return ret;
-}
-
-#define EXCESS 256 /* empirically determined stream overage */
-#define MARGIN 8 /* amount to back off for completion */
-
-/* compress from stdin to fixed-size block on stdout */
-int main(int argc, char **argv)
-{
- int ret; /* return code */
- unsigned size; /* requested fixed output block size */
- unsigned have; /* bytes written by deflate() call */
- unsigned char *blk; /* intermediate and final stream */
- unsigned char *tmp; /* close to desired size stream */
- z_stream def, inf; /* zlib deflate and inflate states */
-
- /* get requested output size */
- if (argc != 2)
- quit("need one argument: size of output block");
- ret = strtol(argv[1], argv + 1, 10);
- if (argv[1][0] != 0)
- quit("argument must be a number");
- if (ret < 8) /* 8 is minimum zlib stream size */
- quit("need positive size of 8 or greater");
- size = (unsigned)ret;
-
- /* allocate memory for buffers and compression engine */
- blk = malloc(size + EXCESS);
- def.zalloc = Z_NULL;
- def.zfree = Z_NULL;
- def.opaque = Z_NULL;
- ret = deflateInit(&def, Z_DEFAULT_COMPRESSION);
- if (ret != Z_OK || blk == NULL)
- quit("out of memory");
-
- /* compress from stdin until output full, or no more input */
- def.avail_out = size + EXCESS;
- def.next_out = blk;
- ret = partcompress(stdin, &def);
- if (ret == Z_ERRNO)
- quit("error reading input");
-
- /* if it all fit, then size was undersubscribed -- done! */
- if (ret == Z_STREAM_END && def.avail_out >= EXCESS) {
- /* write block to stdout */
- have = size + EXCESS - def.avail_out;
- if (fwrite(blk, 1, have, stdout) != have || ferror(stdout))
- quit("error writing output");
-
- /* clean up and print results to stderr */
- ret = deflateEnd(&def);
- assert(ret != Z_STREAM_ERROR);
- free(blk);
- fprintf(stderr,
- "%u bytes unused out of %u requested (all input)\n",
- size - have, size);
- return 0;
- }
-
- /* it didn't all fit -- set up for recompression */
- inf.zalloc = Z_NULL;
- inf.zfree = Z_NULL;
- inf.opaque = Z_NULL;
- inf.avail_in = 0;
- inf.next_in = Z_NULL;
- ret = inflateInit(&inf);
- tmp = malloc(size + EXCESS);
- if (ret != Z_OK || tmp == NULL)
- quit("out of memory");
- ret = deflateReset(&def);
- assert(ret != Z_STREAM_ERROR);
-
- /* do first recompression close to the right amount */
- inf.avail_in = size + EXCESS;
- inf.next_in = blk;
- def.avail_out = size + EXCESS;
- def.next_out = tmp;
- ret = recompress(&inf, &def);
- if (ret == Z_MEM_ERROR)
- quit("out of memory");
-
- /* set up for next reocmpression */
- ret = inflateReset(&inf);
- assert(ret != Z_STREAM_ERROR);
- ret = deflateReset(&def);
- assert(ret != Z_STREAM_ERROR);
-
- /* do second and final recompression (third compression) */
- inf.avail_in = size - MARGIN; /* assure stream will complete */
- inf.next_in = tmp;
- def.avail_out = size;
- def.next_out = blk;
- ret = recompress(&inf, &def);
- if (ret == Z_MEM_ERROR)
- quit("out of memory");
- assert(ret == Z_STREAM_END); /* otherwise MARGIN too small */
-
- /* done -- write block to stdout */
- have = size - def.avail_out;
- if (fwrite(blk, 1, have, stdout) != have || ferror(stdout))
- quit("error writing output");
-
- /* clean up and print results to stderr */
- free(tmp);
- ret = inflateEnd(&inf);
- assert(ret != Z_STREAM_ERROR);
- ret = deflateEnd(&def);
- assert(ret != Z_STREAM_ERROR);
- free(blk);
- fprintf(stderr,
- "%u bytes unused out of %u requested (%lu input)\n",
- size - have, size, def.total_in);
- return 0;
-}
diff --git a/source4/lib/zlib/examples/gun.c b/source4/lib/zlib/examples/gun.c
deleted file mode 100644
index bfec590a00..0000000000
--- a/source4/lib/zlib/examples/gun.c
+++ /dev/null
@@ -1,693 +0,0 @@
-/* gun.c -- simple gunzip to give an example of the use of inflateBack()
- * Copyright (C) 2003, 2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- Version 1.3 12 June 2005 Mark Adler */
-
-/* Version history:
- 1.0 16 Feb 2003 First version for testing of inflateBack()
- 1.1 21 Feb 2005 Decompress concatenated gzip streams
- Remove use of "this" variable (C++ keyword)
- Fix return value for in()
- Improve allocation failure checking
- Add typecasting for void * structures
- Add -h option for command version and usage
- Add a bunch of comments
- 1.2 20 Mar 2005 Add Unix compress (LZW) decompression
- Copy file attributes from input file to output file
- 1.3 12 Jun 2005 Add casts for error messages [Oberhumer]
- */
-
-/*
- gun [ -t ] [ name ... ]
-
- decompresses the data in the named gzip files. If no arguments are given,
- gun will decompress from stdin to stdout. The names must end in .gz, -gz,
- .z, -z, _z, or .Z. The uncompressed data will be written to a file name
- with the suffix stripped. On success, the original file is deleted. On
- failure, the output file is deleted. For most failures, the command will
- continue to process the remaining names on the command line. A memory
- allocation failure will abort the command. If -t is specified, then the
- listed files or stdin will be tested as gzip files for integrity (without
- checking for a proper suffix), no output will be written, and no files
- will be deleted.
-
- Like gzip, gun allows concatenated gzip streams and will decompress them,
- writing all of the uncompressed data to the output. Unlike gzip, gun allows
- an empty file on input, and will produce no error writing an empty output
- file.
-
- gun will also decompress files made by Unix compress, which uses LZW
- compression. These files are automatically detected by virtue of their
- magic header bytes. Since the end of Unix compress stream is marked by the
- end-of-file, they cannot be concantenated. If a Unix compress stream is
- encountered in an input file, it is the last stream in that file.
-
- Like gunzip and uncompress, the file attributes of the orignal compressed
- file are maintained in the final uncompressed file, to the extent that the
- user permissions allow it.
-
- On my Mac OS X PowerPC G4, gun is almost twice as fast as gunzip (version
- 1.2.4) is on the same file, when gun is linked with zlib 1.2.2. Also the
- LZW decompression provided by gun is about twice as fast as the standard
- Unix uncompress command.
- */
-
-/* external functions and related types and constants */
-#include <stdio.h> /* fprintf() */
-#include <stdlib.h> /* malloc(), free() */
-#include <string.h> /* strerror(), strcmp(), strlen(), memcpy() */
-#include <errno.h> /* errno */
-#include <fcntl.h> /* open() */
-#include <unistd.h> /* read(), write(), close(), chown(), unlink() */
-#include <sys/types.h>
-#include <sys/stat.h> /* stat(), chmod() */
-#include <utime.h> /* utime() */
-#include "zlib.h" /* inflateBackInit(), inflateBack(), */
- /* inflateBackEnd(), crc32() */
-
-/* function declaration */
-#define local static
-
-/* buffer constants */
-#define SIZE 32768U /* input and output buffer sizes */
-#define PIECE 16384 /* limits i/o chunks for 16-bit int case */
-
-/* structure for infback() to pass to input function in() -- it maintains the
- input file and a buffer of size SIZE */
-struct ind {
- int infile;
- unsigned char *inbuf;
-};
-
-/* Load input buffer, assumed to be empty, and return bytes loaded and a
- pointer to them. read() is called until the buffer is full, or until it
- returns end-of-file or error. Return 0 on error. */
-local unsigned in(void *in_desc, unsigned char **buf)
-{
- int ret;
- unsigned len;
- unsigned char *next;
- struct ind *me = (struct ind *)in_desc;
-
- next = me->inbuf;
- *buf = next;
- len = 0;
- do {
- ret = PIECE;
- if ((unsigned)ret > SIZE - len)
- ret = (int)(SIZE - len);
- ret = (int)read(me->infile, next, ret);
- if (ret == -1) {
- len = 0;
- break;
- }
- next += ret;
- len += ret;
- } while (ret != 0 && len < SIZE);
- return len;
-}
-
-/* structure for infback() to pass to output function out() -- it maintains the
- output file, a running CRC-32 check on the output and the total number of
- bytes output, both for checking against the gzip trailer. (The length in
- the gzip trailer is stored modulo 2^32, so it's ok if a long is 32 bits and
- the output is greater than 4 GB.) */
-struct outd {
- int outfile;
- int check; /* true if checking crc and total */
- unsigned long crc;
- unsigned long total;
-};
-
-/* Write output buffer and update the CRC-32 and total bytes written. write()
- is called until all of the output is written or an error is encountered.
- On success out() returns 0. For a write failure, out() returns 1. If the
- output file descriptor is -1, then nothing is written.
- */
-local int out(void *out_desc, unsigned char *buf, unsigned len)
-{
- int ret;
- struct outd *me = (struct outd *)out_desc;
-
- if (me->check) {
- me->crc = crc32(me->crc, buf, len);
- me->total += len;
- }
- if (me->outfile != -1)
- do {
- ret = PIECE;
- if ((unsigned)ret > len)
- ret = (int)len;
- ret = (int)write(me->outfile, buf, ret);
- if (ret == -1)
- return 1;
- buf += ret;
- len -= ret;
- } while (len != 0);
- return 0;
-}
-
-/* next input byte macro for use inside lunpipe() and gunpipe() */
-#define NEXT() (have ? 0 : (have = in(indp, &next)), \
- last = have ? (have--, (int)(*next++)) : -1)
-
-/* memory for gunpipe() and lunpipe() --
- the first 256 entries of prefix[] and suffix[] are never used, could
- have offset the index, but it's faster to waste the memory */
-unsigned char inbuf[SIZE]; /* input buffer */
-unsigned char outbuf[SIZE]; /* output buffer */
-unsigned short prefix[65536]; /* index to LZW prefix string */
-unsigned char suffix[65536]; /* one-character LZW suffix */
-unsigned char match[65280 + 2]; /* buffer for reversed match or gzip
- 32K sliding window */
-
-/* throw out what's left in the current bits byte buffer (this is a vestigial
- aspect of the compressed data format derived from an implementation that
- made use of a special VAX machine instruction!) */
-#define FLUSHCODE() \
- do { \
- left = 0; \
- rem = 0; \
- if (chunk > have) { \
- chunk -= have; \
- have = 0; \
- if (NEXT() == -1) \
- break; \
- chunk--; \
- if (chunk > have) { \
- chunk = have = 0; \
- break; \
- } \
- } \
- have -= chunk; \
- next += chunk; \
- chunk = 0; \
- } while (0)
-
-/* Decompress a compress (LZW) file from indp to outfile. The compress magic
- header (two bytes) has already been read and verified. There are have bytes
- of buffered input at next. strm is used for passing error information back
- to gunpipe().
-
- lunpipe() will return Z_OK on success, Z_BUF_ERROR for an unexpected end of
- file, read error, or write error (a write error indicated by strm->next_in
- not equal to Z_NULL), or Z_DATA_ERROR for invalid input.
- */
-local int lunpipe(unsigned have, unsigned char *next, struct ind *indp,
- int outfile, z_stream *strm)
-{
- int last; /* last byte read by NEXT(), or -1 if EOF */
- int chunk; /* bytes left in current chunk */
- int left; /* bits left in rem */
- unsigned rem; /* unused bits from input */
- int bits; /* current bits per code */
- unsigned code; /* code, table traversal index */
- unsigned mask; /* mask for current bits codes */
- int max; /* maximum bits per code for this stream */
- int flags; /* compress flags, then block compress flag */
- unsigned end; /* last valid entry in prefix/suffix tables */
- unsigned temp; /* current code */
- unsigned prev; /* previous code */
- unsigned final; /* last character written for previous code */
- unsigned stack; /* next position for reversed string */
- unsigned outcnt; /* bytes in output buffer */
- struct outd outd; /* output structure */
-
- /* set up output */
- outd.outfile = outfile;
- outd.check = 0;
-
- /* process remainder of compress header -- a flags byte */
- flags = NEXT();
- if (last == -1)
- return Z_BUF_ERROR;
- if (flags & 0x60) {
- strm->msg = (char *)"unknown lzw flags set";
- return Z_DATA_ERROR;
- }
- max = flags & 0x1f;
- if (max < 9 || max > 16) {
- strm->msg = (char *)"lzw bits out of range";
- return Z_DATA_ERROR;
- }
- if (max == 9) /* 9 doesn't really mean 9 */
- max = 10;
- flags &= 0x80; /* true if block compress */
-
- /* clear table */
- bits = 9;
- mask = 0x1ff;
- end = flags ? 256 : 255;
-
- /* set up: get first 9-bit code, which is the first decompressed byte, but
- don't create a table entry until the next code */
- if (NEXT() == -1) /* no compressed data is ok */
- return Z_OK;
- final = prev = (unsigned)last; /* low 8 bits of code */
- if (NEXT() == -1) /* missing a bit */
- return Z_BUF_ERROR;
- if (last & 1) { /* code must be < 256 */
- strm->msg = (char *)"invalid lzw code";
- return Z_DATA_ERROR;
- }
- rem = (unsigned)last >> 1; /* remaining 7 bits */
- left = 7;
- chunk = bits - 2; /* 7 bytes left in this chunk */
- outbuf[0] = (unsigned char)final; /* write first decompressed byte */
- outcnt = 1;
-
- /* decode codes */
- stack = 0;
- for (;;) {
- /* if the table will be full after this, increment the code size */
- if (end >= mask && bits < max) {
- FLUSHCODE();
- bits++;
- mask <<= 1;
- mask++;
- }
-
- /* get a code of length bits */
- if (chunk == 0) /* decrement chunk modulo bits */
- chunk = bits;
- code = rem; /* low bits of code */
- if (NEXT() == -1) { /* EOF is end of compressed data */
- /* write remaining buffered output */
- if (outcnt && out(&outd, outbuf, outcnt)) {
- strm->next_in = outbuf; /* signal write error */
- return Z_BUF_ERROR;
- }
- return Z_OK;
- }
- code += (unsigned)last << left; /* middle (or high) bits of code */
- left += 8;
- chunk--;
- if (bits > left) { /* need more bits */
- if (NEXT() == -1) /* can't end in middle of code */
- return Z_BUF_ERROR;
- code += (unsigned)last << left; /* high bits of code */
- left += 8;
- chunk--;
- }
- code &= mask; /* mask to current code length */
- left -= bits; /* number of unused bits */
- rem = (unsigned)last >> (8 - left); /* unused bits from last byte */
-
- /* process clear code (256) */
- if (code == 256 && flags) {
- FLUSHCODE();
- bits = 9; /* initialize bits and mask */
- mask = 0x1ff;
- end = 255; /* empty table */
- continue; /* get next code */
- }
-
- /* special code to reuse last match */
- temp = code; /* save the current code */
- if (code > end) {
- /* Be picky on the allowed code here, and make sure that the code
- we drop through (prev) will be a valid index so that random
- input does not cause an exception. The code != end + 1 check is
- empirically derived, and not checked in the original uncompress
- code. If this ever causes a problem, that check could be safely
- removed. Leaving this check in greatly improves gun's ability
- to detect random or corrupted input after a compress header.
- In any case, the prev > end check must be retained. */
- if (code != end + 1 || prev > end) {
- strm->msg = (char *)"invalid lzw code";
- return Z_DATA_ERROR;
- }
- match[stack++] = (unsigned char)final;
- code = prev;
- }
-
- /* walk through linked list to generate output in reverse order */
- while (code >= 256) {
- match[stack++] = suffix[code];
- code = prefix[code];
- }
- match[stack++] = (unsigned char)code;
- final = code;
-
- /* link new table entry */
- if (end < mask) {
- end++;
- prefix[end] = (unsigned short)prev;
- suffix[end] = (unsigned char)final;
- }
-
- /* set previous code for next iteration */
- prev = temp;
-
- /* write output in forward order */
- while (stack > SIZE - outcnt) {
- while (outcnt < SIZE)
- outbuf[outcnt++] = match[--stack];
- if (out(&outd, outbuf, outcnt)) {
- strm->next_in = outbuf; /* signal write error */
- return Z_BUF_ERROR;
- }
- outcnt = 0;
- }
- do {
- outbuf[outcnt++] = match[--stack];
- } while (stack);
-
- /* loop for next code with final and prev as the last match, rem and
- left provide the first 0..7 bits of the next code, end is the last
- valid table entry */
- }
-}
-
-/* Decompress a gzip file from infile to outfile. strm is assumed to have been
- successfully initialized with inflateBackInit(). The input file may consist
- of a series of gzip streams, in which case all of them will be decompressed
- to the output file. If outfile is -1, then the gzip stream(s) integrity is
- checked and nothing is written.
-
- The return value is a zlib error code: Z_MEM_ERROR if out of memory,
- Z_DATA_ERROR if the header or the compressed data is invalid, or if the
- trailer CRC-32 check or length doesn't match, Z_BUF_ERROR if the input ends
- prematurely or a write error occurs, or Z_ERRNO if junk (not a another gzip
- stream) follows a valid gzip stream.
- */
-local int gunpipe(z_stream *strm, int infile, int outfile)
-{
- int ret, first, last;
- unsigned have, flags, len;
- unsigned char *next;
- struct ind ind, *indp;
- struct outd outd;
-
- /* setup input buffer */
- ind.infile = infile;
- ind.inbuf = inbuf;
- indp = &ind;
-
- /* decompress concatenated gzip streams */
- have = 0; /* no input data read in yet */
- first = 1; /* looking for first gzip header */
- strm->next_in = Z_NULL; /* so Z_BUF_ERROR means EOF */
- for (;;) {
- /* look for the two magic header bytes for a gzip stream */
- if (NEXT() == -1) {
- ret = Z_OK;
- break; /* empty gzip stream is ok */
- }
- if (last != 31 || (NEXT() != 139 && last != 157)) {
- strm->msg = (char *)"incorrect header check";
- ret = first ? Z_DATA_ERROR : Z_ERRNO;
- break; /* not a gzip or compress header */
- }
- first = 0; /* next non-header is junk */
-
- /* process a compress (LZW) file -- can't be concatenated after this */
- if (last == 157) {
- ret = lunpipe(have, next, indp, outfile, strm);
- break;
- }
-
- /* process remainder of gzip header */
- ret = Z_BUF_ERROR;
- if (NEXT() != 8) { /* only deflate method allowed */
- if (last == -1) break;
- strm->msg = (char *)"unknown compression method";
- ret = Z_DATA_ERROR;
- break;
- }
- flags = NEXT(); /* header flags */
- NEXT(); /* discard mod time, xflgs, os */
- NEXT();
- NEXT();
- NEXT();
- NEXT();
- NEXT();
- if (last == -1) break;
- if (flags & 0xe0) {
- strm->msg = (char *)"unknown header flags set";
- ret = Z_DATA_ERROR;
- break;
- }
- if (flags & 4) { /* extra field */
- len = NEXT();
- len += (unsigned)(NEXT()) << 8;
- if (last == -1) break;
- while (len > have) {
- len -= have;
- have = 0;
- if (NEXT() == -1) break;
- len--;
- }
- if (last == -1) break;
- have -= len;
- next += len;
- }
- if (flags & 8) /* file name */
- while (NEXT() != 0 && last != -1)
- ;
- if (flags & 16) /* comment */
- while (NEXT() != 0 && last != -1)
- ;
- if (flags & 2) { /* header crc */
- NEXT();
- NEXT();
- }
- if (last == -1) break;
-
- /* set up output */
- outd.outfile = outfile;
- outd.check = 1;
- outd.crc = crc32(0L, Z_NULL, 0);
- outd.total = 0;
-
- /* decompress data to output */
- strm->next_in = next;
- strm->avail_in = have;
- ret = inflateBack(strm, in, indp, out, &outd);
- if (ret != Z_STREAM_END) break;
- next = strm->next_in;
- have = strm->avail_in;
- strm->next_in = Z_NULL; /* so Z_BUF_ERROR means EOF */
-
- /* check trailer */
- ret = Z_BUF_ERROR;
- if (NEXT() != (outd.crc & 0xff) ||
- NEXT() != ((outd.crc >> 8) & 0xff) ||
- NEXT() != ((outd.crc >> 16) & 0xff) ||
- NEXT() != ((outd.crc >> 24) & 0xff)) {
- /* crc error */
- if (last != -1) {
- strm->msg = (char *)"incorrect data check";
- ret = Z_DATA_ERROR;
- }
- break;
- }
- if (NEXT() != (outd.total & 0xff) ||
- NEXT() != ((outd.total >> 8) & 0xff) ||
- NEXT() != ((outd.total >> 16) & 0xff) ||
- NEXT() != ((outd.total >> 24) & 0xff)) {
- /* length error */
- if (last != -1) {
- strm->msg = (char *)"incorrect length check";
- ret = Z_DATA_ERROR;
- }
- break;
- }
-
- /* go back and look for another gzip stream */
- }
-
- /* clean up and return */
- return ret;
-}
-
-/* Copy file attributes, from -> to, as best we can. This is best effort, so
- no errors are reported. The mode bits, including suid, sgid, and the sticky
- bit are copied (if allowed), the owner's user id and group id are copied
- (again if allowed), and the access and modify times are copied. */
-local void copymeta(char *from, char *to)
-{
- struct stat was;
- struct utimbuf when;
-
- /* get all of from's Unix meta data, return if not a regular file */
- if (stat(from, &was) != 0 || (was.st_mode & S_IFMT) != S_IFREG)
- return;
-
- /* set to's mode bits, ignore errors */
- (void)chmod(to, was.st_mode & 07777);
-
- /* copy owner's user and group, ignore errors */
- (void)chown(to, was.st_uid, was.st_gid);
-
- /* copy access and modify times, ignore errors */
- when.actime = was.st_atime;
- when.modtime = was.st_mtime;
- (void)utime(to, &when);
-}
-
-/* Decompress the file inname to the file outnname, of if test is true, just
- decompress without writing and check the gzip trailer for integrity. If
- inname is NULL or an empty string, read from stdin. If outname is NULL or
- an empty string, write to stdout. strm is a pre-initialized inflateBack
- structure. When appropriate, copy the file attributes from inname to
- outname.
-
- gunzip() returns 1 if there is an out-of-memory error or an unexpected
- return code from gunpipe(). Otherwise it returns 0.
- */
-local int gunzip(z_stream *strm, char *inname, char *outname, int test)
-{
- int ret;
- int infile, outfile;
-
- /* open files */
- if (inname == NULL || *inname == 0) {
- inname = "-";
- infile = 0; /* stdin */
- }
- else {
- infile = open(inname, O_RDONLY, 0);
- if (infile == -1) {
- fprintf(stderr, "gun cannot open %s\n", inname);
- return 0;
- }
- }
- if (test)
- outfile = -1;
- else if (outname == NULL || *outname == 0) {
- outname = "-";
- outfile = 1; /* stdout */
- }
- else {
- outfile = open(outname, O_CREAT | O_TRUNC | O_WRONLY, 0666);
- if (outfile == -1) {
- close(infile);
- fprintf(stderr, "gun cannot create %s\n", outname);
- return 0;
- }
- }
- errno = 0;
-
- /* decompress */
- ret = gunpipe(strm, infile, outfile);
- if (outfile > 2) close(outfile);
- if (infile > 2) close(infile);
-
- /* interpret result */
- switch (ret) {
- case Z_OK:
- case Z_ERRNO:
- if (infile > 2 && outfile > 2) {
- copymeta(inname, outname); /* copy attributes */
- unlink(inname);
- }
- if (ret == Z_ERRNO)
- fprintf(stderr, "gun warning: trailing garbage ignored in %s\n",
- inname);
- break;
- case Z_DATA_ERROR:
- if (outfile > 2) unlink(outname);
- fprintf(stderr, "gun data error on %s: %s\n", inname, strm->msg);
- break;
- case Z_MEM_ERROR:
- if (outfile > 2) unlink(outname);
- fprintf(stderr, "gun out of memory error--aborting\n");
- return 1;
- case Z_BUF_ERROR:
- if (outfile > 2) unlink(outname);
- if (strm->next_in != Z_NULL) {
- fprintf(stderr, "gun write error on %s: %s\n",
- outname, strerror(errno));
- }
- else if (errno) {
- fprintf(stderr, "gun read error on %s: %s\n",
- inname, strerror(errno));
- }
- else {
- fprintf(stderr, "gun unexpected end of file on %s\n",
- inname);
- }
- break;
- default:
- if (outfile > 2) unlink(outname);
- fprintf(stderr, "gun internal error--aborting\n");
- return 1;
- }
- return 0;
-}
-
-/* Process the gun command line arguments. See the command syntax near the
- beginning of this source file. */
-int main(int argc, char **argv)
-{
- int ret, len, test;
- char *outname;
- unsigned char *window;
- z_stream strm;
-
- /* initialize inflateBack state for repeated use */
- window = match; /* reuse LZW match buffer */
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- strm.opaque = Z_NULL;
- ret = inflateBackInit(&strm, 15, window);
- if (ret != Z_OK) {
- fprintf(stderr, "gun out of memory error--aborting\n");
- return 1;
- }
-
- /* decompress each file to the same name with the suffix removed */
- argc--;
- argv++;
- test = 0;
- if (argc && strcmp(*argv, "-h") == 0) {
- fprintf(stderr, "gun 1.3 (12 Jun 2005)\n");
- fprintf(stderr, "Copyright (c) 2005 Mark Adler\n");
- fprintf(stderr, "usage: gun [-t] [file1.gz [file2.Z ...]]\n");
- return 0;
- }
- if (argc && strcmp(*argv, "-t") == 0) {
- test = 1;
- argc--;
- argv++;
- }
- if (argc)
- do {
- if (test)
- outname = NULL;
- else {
- len = (int)strlen(*argv);
- if (strcmp(*argv + len - 3, ".gz") == 0 ||
- strcmp(*argv + len - 3, "-gz") == 0)
- len -= 3;
- else if (strcmp(*argv + len - 2, ".z") == 0 ||
- strcmp(*argv + len - 2, "-z") == 0 ||
- strcmp(*argv + len - 2, "_z") == 0 ||
- strcmp(*argv + len - 2, ".Z") == 0)
- len -= 2;
- else {
- fprintf(stderr, "gun error: no gz type on %s--skipping\n",
- *argv);
- continue;
- }
- outname = malloc(len + 1);
- if (outname == NULL) {
- fprintf(stderr, "gun out of memory error--aborting\n");
- ret = 1;
- break;
- }
- memcpy(outname, *argv, len);
- outname[len] = 0;
- }
- ret = gunzip(&strm, *argv, outname, test);
- if (outname != NULL) free(outname);
- if (ret) break;
- } while (argv++, --argc);
- else
- ret = gunzip(&strm, NULL, NULL, test);
-
- /* clean up */
- inflateBackEnd(&strm);
- return ret;
-}
diff --git a/source4/lib/zlib/examples/gzappend.c b/source4/lib/zlib/examples/gzappend.c
deleted file mode 100644
index e9e878e116..0000000000
--- a/source4/lib/zlib/examples/gzappend.c
+++ /dev/null
@@ -1,500 +0,0 @@
-/* gzappend -- command to append to a gzip file
-
- Copyright (C) 2003 Mark Adler, all rights reserved
- version 1.1, 4 Nov 2003
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the author be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Mark Adler madler@alumni.caltech.edu
- */
-
-/*
- * Change history:
- *
- * 1.0 19 Oct 2003 - First version
- * 1.1 4 Nov 2003 - Expand and clarify some comments and notes
- * - Add version and copyright to help
- * - Send help to stdout instead of stderr
- * - Add some preemptive typecasts
- * - Add L to constants in lseek() calls
- * - Remove some debugging information in error messages
- * - Use new data_type definition for zlib 1.2.1
- * - Simplfy and unify file operations
- * - Finish off gzip file in gztack()
- * - Use deflatePrime() instead of adding empty blocks
- * - Keep gzip file clean on appended file read errors
- * - Use in-place rotate instead of auxiliary buffer
- * (Why you ask? Because it was fun to write!)
- */
-
-/*
- gzappend takes a gzip file and appends to it, compressing files from the
- command line or data from stdin. The gzip file is written to directly, to
- avoid copying that file, in case it's large. Note that this results in the
- unfriendly behavior that if gzappend fails, the gzip file is corrupted.
-
- This program was written to illustrate the use of the new Z_BLOCK option of
- zlib 1.2.x's inflate() function. This option returns from inflate() at each
- block boundary to facilitate locating and modifying the last block bit at
- the start of the final deflate block. Also whether using Z_BLOCK or not,
- another required feature of zlib 1.2.x is that inflate() now provides the
- number of unusued bits in the last input byte used. gzappend will not work
- with versions of zlib earlier than 1.2.1.
-
- gzappend first decompresses the gzip file internally, discarding all but
- the last 32K of uncompressed data, and noting the location of the last block
- bit and the number of unused bits in the last byte of the compressed data.
- The gzip trailer containing the CRC-32 and length of the uncompressed data
- is verified. This trailer will be later overwritten.
-
- Then the last block bit is cleared by seeking back in the file and rewriting
- the byte that contains it. Seeking forward, the last byte of the compressed
- data is saved along with the number of unused bits to initialize deflate.
-
- A deflate process is initialized, using the last 32K of the uncompressed
- data from the gzip file to initialize the dictionary. If the total
- uncompressed data was less than 32K, then all of it is used to initialize
- the dictionary. The deflate output bit buffer is also initialized with the
- last bits from the original deflate stream. From here on, the data to
- append is simply compressed using deflate, and written to the gzip file.
- When that is complete, the new CRC-32 and uncompressed length are written
- as the trailer of the gzip file.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include "zlib.h"
-
-#define local static
-#define LGCHUNK 14
-#define CHUNK (1U << LGCHUNK)
-#define DSIZE 32768U
-
-/* print an error message and terminate with extreme prejudice */
-local void bye(char *msg1, char *msg2)
-{
- fprintf(stderr, "gzappend error: %s%s\n", msg1, msg2);
- exit(1);
-}
-
-/* return the greatest common divisor of a and b using Euclid's algorithm,
- modified to be fast when one argument much greater than the other, and
- coded to avoid unnecessary swapping */
-local unsigned gcd(unsigned a, unsigned b)
-{
- unsigned c;
-
- while (a && b)
- if (a > b) {
- c = b;
- while (a - c >= c)
- c <<= 1;
- a -= c;
- }
- else {
- c = a;
- while (b - c >= c)
- c <<= 1;
- b -= c;
- }
- return a + b;
-}
-
-/* rotate list[0..len-1] left by rot positions, in place */
-local void rotate(unsigned char *list, unsigned len, unsigned rot)
-{
- unsigned char tmp;
- unsigned cycles;
- unsigned char *start, *last, *to, *from;
-
- /* normalize rot and handle degenerate cases */
- if (len < 2) return;
- if (rot >= len) rot %= len;
- if (rot == 0) return;
-
- /* pointer to last entry in list */
- last = list + (len - 1);
-
- /* do simple left shift by one */
- if (rot == 1) {
- tmp = *list;
- memcpy(list, list + 1, len - 1);
- *last = tmp;
- return;
- }
-
- /* do simple right shift by one */
- if (rot == len - 1) {
- tmp = *last;
- memmove(list + 1, list, len - 1);
- *list = tmp;
- return;
- }
-
- /* otherwise do rotate as a set of cycles in place */
- cycles = gcd(len, rot); /* number of cycles */
- do {
- start = from = list + cycles; /* start index is arbitrary */
- tmp = *from; /* save entry to be overwritten */
- for (;;) {
- to = from; /* next step in cycle */
- from += rot; /* go right rot positions */
- if (from > last) from -= len; /* (pointer better not wrap) */
- if (from == start) break; /* all but one shifted */
- *to = *from; /* shift left */
- }
- *to = tmp; /* complete the circle */
- } while (--cycles);
-}
-
-/* structure for gzip file read operations */
-typedef struct {
- int fd; /* file descriptor */
- int size; /* 1 << size is bytes in buf */
- unsigned left; /* bytes available at next */
- unsigned char *buf; /* buffer */
- unsigned char *next; /* next byte in buffer */
- char *name; /* file name for error messages */
-} file;
-
-/* reload buffer */
-local int readin(file *in)
-{
- int len;
-
- len = read(in->fd, in->buf, 1 << in->size);
- if (len == -1) bye("error reading ", in->name);
- in->left = (unsigned)len;
- in->next = in->buf;
- return len;
-}
-
-/* read from file in, exit if end-of-file */
-local int readmore(file *in)
-{
- if (readin(in) == 0) bye("unexpected end of ", in->name);
- return 0;
-}
-
-#define read1(in) (in->left == 0 ? readmore(in) : 0, \
- in->left--, *(in->next)++)
-
-/* skip over n bytes of in */
-local void skip(file *in, unsigned n)
-{
- unsigned bypass;
-
- if (n > in->left) {
- n -= in->left;
- bypass = n & ~((1U << in->size) - 1);
- if (bypass) {
- if (lseek(in->fd, (off_t)bypass, SEEK_CUR) == -1)
- bye("seeking ", in->name);
- n -= bypass;
- }
- readmore(in);
- if (n > in->left)
- bye("unexpected end of ", in->name);
- }
- in->left -= n;
- in->next += n;
-}
-
-/* read a four-byte unsigned integer, little-endian, from in */
-unsigned long read4(file *in)
-{
- unsigned long val;
-
- val = read1(in);
- val += (unsigned)read1(in) << 8;
- val += (unsigned long)read1(in) << 16;
- val += (unsigned long)read1(in) << 24;
- return val;
-}
-
-/* skip over gzip header */
-local void gzheader(file *in)
-{
- int flags;
- unsigned n;
-
- if (read1(in) != 31 || read1(in) != 139) bye(in->name, " not a gzip file");
- if (read1(in) != 8) bye("unknown compression method in", in->name);
- flags = read1(in);
- if (flags & 0xe0) bye("unknown header flags set in", in->name);
- skip(in, 6);
- if (flags & 4) {
- n = read1(in);
- n += (unsigned)(read1(in)) << 8;
- skip(in, n);
- }
- if (flags & 8) while (read1(in) != 0) ;
- if (flags & 16) while (read1(in) != 0) ;
- if (flags & 2) skip(in, 2);
-}
-
-/* decompress gzip file "name", return strm with a deflate stream ready to
- continue compression of the data in the gzip file, and return a file
- descriptor pointing to where to write the compressed data -- the deflate
- stream is initialized to compress using level "level" */
-local int gzscan(char *name, z_stream *strm, int level)
-{
- int ret, lastbit, left, full;
- unsigned have;
- unsigned long crc, tot;
- unsigned char *window;
- off_t lastoff, end;
- file gz;
-
- /* open gzip file */
- gz.name = name;
- gz.fd = open(name, O_RDWR, 0);
- if (gz.fd == -1) bye("cannot open ", name);
- gz.buf = malloc(CHUNK);
- if (gz.buf == NULL) bye("out of memory", "");
- gz.size = LGCHUNK;
- gz.left = 0;
-
- /* skip gzip header */
- gzheader(&gz);
-
- /* prepare to decompress */
- window = malloc(DSIZE);
- if (window == NULL) bye("out of memory", "");
- strm->zalloc = Z_NULL;
- strm->zfree = Z_NULL;
- strm->opaque = Z_NULL;
- ret = inflateInit2(strm, -15);
- if (ret != Z_OK) bye("out of memory", " or library mismatch");
-
- /* decompress the deflate stream, saving append information */
- lastbit = 0;
- lastoff = lseek(gz.fd, 0L, SEEK_CUR) - gz.left;
- left = 0;
- strm->avail_in = gz.left;
- strm->next_in = gz.next;
- crc = crc32(0L, Z_NULL, 0);
- have = full = 0;
- do {
- /* if needed, get more input */
- if (strm->avail_in == 0) {
- readmore(&gz);
- strm->avail_in = gz.left;
- strm->next_in = gz.next;
- }
-
- /* set up output to next available section of sliding window */
- strm->avail_out = DSIZE - have;
- strm->next_out = window + have;
-
- /* inflate and check for errors */
- ret = inflate(strm, Z_BLOCK);
- if (ret == Z_STREAM_ERROR) bye("internal stream error!", "");
- if (ret == Z_MEM_ERROR) bye("out of memory", "");
- if (ret == Z_DATA_ERROR)
- bye("invalid compressed data--format violated in", name);
-
- /* update crc and sliding window pointer */
- crc = crc32(crc, window + have, DSIZE - have - strm->avail_out);
- if (strm->avail_out)
- have = DSIZE - strm->avail_out;
- else {
- have = 0;
- full = 1;
- }
-
- /* process end of block */
- if (strm->data_type & 128) {
- if (strm->data_type & 64)
- left = strm->data_type & 0x1f;
- else {
- lastbit = strm->data_type & 0x1f;
- lastoff = lseek(gz.fd, 0L, SEEK_CUR) - strm->avail_in;
- }
- }
- } while (ret != Z_STREAM_END);
- inflateEnd(strm);
- gz.left = strm->avail_in;
- gz.next = strm->next_in;
-
- /* save the location of the end of the compressed data */
- end = lseek(gz.fd, 0L, SEEK_CUR) - gz.left;
-
- /* check gzip trailer and save total for deflate */
- if (crc != read4(&gz))
- bye("invalid compressed data--crc mismatch in ", name);
- tot = strm->total_out;
- if ((tot & 0xffffffffUL) != read4(&gz))
- bye("invalid compressed data--length mismatch in", name);
-
- /* if not at end of file, warn */
- if (gz.left || readin(&gz))
- fprintf(stderr,
- "gzappend warning: junk at end of gzip file overwritten\n");
-
- /* clear last block bit */
- lseek(gz.fd, lastoff - (lastbit != 0), SEEK_SET);
- if (read(gz.fd, gz.buf, 1) != 1) bye("reading after seek on ", name);
- *gz.buf = (unsigned char)(*gz.buf ^ (1 << ((8 - lastbit) & 7)));
- lseek(gz.fd, -1L, SEEK_CUR);
- if (write(gz.fd, gz.buf, 1) != 1) bye("writing after seek to ", name);
-
- /* if window wrapped, build dictionary from window by rotating */
- if (full) {
- rotate(window, DSIZE, have);
- have = DSIZE;
- }
-
- /* set up deflate stream with window, crc, total_in, and leftover bits */
- ret = deflateInit2(strm, level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);
- if (ret != Z_OK) bye("out of memory", "");
- deflateSetDictionary(strm, window, have);
- strm->adler = crc;
- strm->total_in = tot;
- if (left) {
- lseek(gz.fd, --end, SEEK_SET);
- if (read(gz.fd, gz.buf, 1) != 1) bye("reading after seek on ", name);
- deflatePrime(strm, 8 - left, *gz.buf);
- }
- lseek(gz.fd, end, SEEK_SET);
-
- /* clean up and return */
- free(window);
- free(gz.buf);
- return gz.fd;
-}
-
-/* append file "name" to gzip file gd using deflate stream strm -- if last
- is true, then finish off the deflate stream at the end */
-local void gztack(char *name, int gd, z_stream *strm, int last)
-{
- int fd, len, ret;
- unsigned left;
- unsigned char *in, *out;
-
- /* open file to compress and append */
- fd = 0;
- if (name != NULL) {
- fd = open(name, O_RDONLY, 0);
- if (fd == -1)
- fprintf(stderr, "gzappend warning: %s not found, skipping ...\n",
- name);
- }
-
- /* allocate buffers */
- in = fd == -1 ? NULL : malloc(CHUNK);
- out = malloc(CHUNK);
- if (out == NULL) bye("out of memory", "");
-
- /* compress input file and append to gzip file */
- do {
- /* get more input */
- len = fd == -1 ? 0 : read(fd, in, CHUNK);
- if (len == -1) {
- fprintf(stderr,
- "gzappend warning: error reading %s, skipping rest ...\n",
- name);
- len = 0;
- }
- strm->avail_in = (unsigned)len;
- strm->next_in = in;
- if (len) strm->adler = crc32(strm->adler, in, (unsigned)len);
-
- /* compress and write all available output */
- do {
- strm->avail_out = CHUNK;
- strm->next_out = out;
- ret = deflate(strm, last && len == 0 ? Z_FINISH : Z_NO_FLUSH);
- left = CHUNK - strm->avail_out;
- while (left) {
- len = write(gd, out + CHUNK - strm->avail_out - left, left);
- if (len == -1) bye("writing gzip file", "");
- left -= (unsigned)len;
- }
- } while (strm->avail_out == 0 && ret != Z_STREAM_END);
- } while (len != 0);
-
- /* write trailer after last entry */
- if (last) {
- deflateEnd(strm);
- out[0] = (unsigned char)(strm->adler);
- out[1] = (unsigned char)(strm->adler >> 8);
- out[2] = (unsigned char)(strm->adler >> 16);
- out[3] = (unsigned char)(strm->adler >> 24);
- out[4] = (unsigned char)(strm->total_in);
- out[5] = (unsigned char)(strm->total_in >> 8);
- out[6] = (unsigned char)(strm->total_in >> 16);
- out[7] = (unsigned char)(strm->total_in >> 24);
- len = 8;
- do {
- ret = write(gd, out + 8 - len, len);
- if (ret == -1) bye("writing gzip file", "");
- len -= ret;
- } while (len);
- close(gd);
- }
-
- /* clean up and return */
- free(out);
- if (in != NULL) free(in);
- if (fd > 0) close(fd);
-}
-
-/* process the compression level option if present, scan the gzip file, and
- append the specified files, or append the data from stdin if no other file
- names are provided on the command line -- the gzip file must be writable
- and seekable */
-int main(int argc, char **argv)
-{
- int gd, level;
- z_stream strm;
-
- /* ignore command name */
- argv++;
-
- /* provide usage if no arguments */
- if (*argv == NULL) {
- printf("gzappend 1.1 (4 Nov 2003) Copyright (C) 2003 Mark Adler\n");
- printf(
- "usage: gzappend [-level] file.gz [ addthis [ andthis ... ]]\n");
- return 0;
- }
-
- /* set compression level */
- level = Z_DEFAULT_COMPRESSION;
- if (argv[0][0] == '-') {
- if (argv[0][1] < '0' || argv[0][1] > '9' || argv[0][2] != 0)
- bye("invalid compression level", "");
- level = argv[0][1] - '0';
- if (*++argv == NULL) bye("no gzip file name after options", "");
- }
-
- /* prepare to append to gzip file */
- gd = gzscan(*argv++, &strm, level);
-
- /* append files on command line, or from stdin if none */
- if (*argv == NULL)
- gztack(NULL, gd, &strm, 1);
- else
- do {
- gztack(*argv, gd, &strm, argv[1] == NULL);
- } while (*++argv != NULL);
- return 0;
-}
diff --git a/source4/lib/zlib/examples/gzjoin.c b/source4/lib/zlib/examples/gzjoin.c
deleted file mode 100644
index 129347ce3c..0000000000
--- a/source4/lib/zlib/examples/gzjoin.c
+++ /dev/null
@@ -1,448 +0,0 @@
-/* gzjoin -- command to join gzip files into one gzip file
-
- Copyright (C) 2004 Mark Adler, all rights reserved
- version 1.0, 11 Dec 2004
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the author be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Mark Adler madler@alumni.caltech.edu
- */
-
-/*
- * Change history:
- *
- * 1.0 11 Dec 2004 - First version
- * 1.1 12 Jun 2005 - Changed ssize_t to long for portability
- */
-
-/*
- gzjoin takes one or more gzip files on the command line and writes out a
- single gzip file that will uncompress to the concatenation of the
- uncompressed data from the individual gzip files. gzjoin does this without
- having to recompress any of the data and without having to calculate a new
- crc32 for the concatenated uncompressed data. gzjoin does however have to
- decompress all of the input data in order to find the bits in the compressed
- data that need to be modified to concatenate the streams.
-
- gzjoin does not do an integrity check on the input gzip files other than
- checking the gzip header and decompressing the compressed data. They are
- otherwise assumed to be complete and correct.
-
- Each joint between gzip files removes at least 18 bytes of previous trailer
- and subsequent header, and inserts an average of about three bytes to the
- compressed data in order to connect the streams. The output gzip file
- has a minimal ten-byte gzip header with no file name or modification time.
-
- This program was written to illustrate the use of the Z_BLOCK option of
- inflate() and the crc32_combine() function. gzjoin will not compile with
- versions of zlib earlier than 1.2.3.
- */
-
-#include <stdio.h> /* fputs(), fprintf(), fwrite(), putc() */
-#include <stdlib.h> /* exit(), malloc(), free() */
-#include <fcntl.h> /* open() */
-#include <unistd.h> /* close(), read(), lseek() */
-#include "zlib.h"
- /* crc32(), crc32_combine(), inflateInit2(), inflate(), inflateEnd() */
-
-#define local static
-
-/* exit with an error (return a value to allow use in an expression) */
-local int bail(char *why1, char *why2)
-{
- fprintf(stderr, "gzjoin error: %s%s, output incomplete\n", why1, why2);
- exit(1);
- return 0;
-}
-
-/* -- simple buffered file input with access to the buffer -- */
-
-#define CHUNK 32768 /* must be a power of two and fit in unsigned */
-
-/* bin buffered input file type */
-typedef struct {
- char *name; /* name of file for error messages */
- int fd; /* file descriptor */
- unsigned left; /* bytes remaining at next */
- unsigned char *next; /* next byte to read */
- unsigned char *buf; /* allocated buffer of length CHUNK */
-} bin;
-
-/* close a buffered file and free allocated memory */
-local void bclose(bin *in)
-{
- if (in != NULL) {
- if (in->fd != -1)
- close(in->fd);
- if (in->buf != NULL)
- free(in->buf);
- free(in);
- }
-}
-
-/* open a buffered file for input, return a pointer to type bin, or NULL on
- failure */
-local bin *bopen(char *name)
-{
- bin *in;
-
- in = malloc(sizeof(bin));
- if (in == NULL)
- return NULL;
- in->buf = malloc(CHUNK);
- in->fd = open(name, O_RDONLY, 0);
- if (in->buf == NULL || in->fd == -1) {
- bclose(in);
- return NULL;
- }
- in->left = 0;
- in->next = in->buf;
- in->name = name;
- return in;
-}
-
-/* load buffer from file, return -1 on read error, 0 or 1 on success, with
- 1 indicating that end-of-file was reached */
-local int bload(bin *in)
-{
- long len;
-
- if (in == NULL)
- return -1;
- if (in->left != 0)
- return 0;
- in->next = in->buf;
- do {
- len = (long)read(in->fd, in->buf + in->left, CHUNK - in->left);
- if (len < 0)
- return -1;
- in->left += (unsigned)len;
- } while (len != 0 && in->left < CHUNK);
- return len == 0 ? 1 : 0;
-}
-
-/* get a byte from the file, bail if end of file */
-#define bget(in) (in->left ? 0 : bload(in), \
- in->left ? (in->left--, *(in->next)++) : \
- bail("unexpected end of file on ", in->name))
-
-/* get a four-byte little-endian unsigned integer from file */
-local unsigned long bget4(bin *in)
-{
- unsigned long val;
-
- val = bget(in);
- val += (unsigned long)(bget(in)) << 8;
- val += (unsigned long)(bget(in)) << 16;
- val += (unsigned long)(bget(in)) << 24;
- return val;
-}
-
-/* skip bytes in file */
-local void bskip(bin *in, unsigned skip)
-{
- /* check pointer */
- if (in == NULL)
- return;
-
- /* easy case -- skip bytes in buffer */
- if (skip <= in->left) {
- in->left -= skip;
- in->next += skip;
- return;
- }
-
- /* skip what's in buffer, discard buffer contents */
- skip -= in->left;
- in->left = 0;
-
- /* seek past multiples of CHUNK bytes */
- if (skip > CHUNK) {
- unsigned left;
-
- left = skip & (CHUNK - 1);
- if (left == 0) {
- /* exact number of chunks: seek all the way minus one byte to check
- for end-of-file with a read */
- lseek(in->fd, skip - 1, SEEK_CUR);
- if (read(in->fd, in->buf, 1) != 1)
- bail("unexpected end of file on ", in->name);
- return;
- }
-
- /* skip the integral chunks, update skip with remainder */
- lseek(in->fd, skip - left, SEEK_CUR);
- skip = left;
- }
-
- /* read more input and skip remainder */
- bload(in);
- if (skip > in->left)
- bail("unexpected end of file on ", in->name);
- in->left -= skip;
- in->next += skip;
-}
-
-/* -- end of buffered input functions -- */
-
-/* skip the gzip header from file in */
-local void gzhead(bin *in)
-{
- int flags;
-
- /* verify gzip magic header and compression method */
- if (bget(in) != 0x1f || bget(in) != 0x8b || bget(in) != 8)
- bail(in->name, " is not a valid gzip file");
-
- /* get and verify flags */
- flags = bget(in);
- if ((flags & 0xe0) != 0)
- bail("unknown reserved bits set in ", in->name);
-
- /* skip modification time, extra flags, and os */
- bskip(in, 6);
-
- /* skip extra field if present */
- if (flags & 4) {
- unsigned len;
-
- len = bget(in);
- len += (unsigned)(bget(in)) << 8;
- bskip(in, len);
- }
-
- /* skip file name if present */
- if (flags & 8)
- while (bget(in) != 0)
- ;
-
- /* skip comment if present */
- if (flags & 16)
- while (bget(in) != 0)
- ;
-
- /* skip header crc if present */
- if (flags & 2)
- bskip(in, 2);
-}
-
-/* write a four-byte little-endian unsigned integer to out */
-local void put4(unsigned long val, FILE *out)
-{
- putc(val & 0xff, out);
- putc((val >> 8) & 0xff, out);
- putc((val >> 16) & 0xff, out);
- putc((val >> 24) & 0xff, out);
-}
-
-/* Load up zlib stream from buffered input, bail if end of file */
-local void zpull(z_streamp strm, bin *in)
-{
- if (in->left == 0)
- bload(in);
- if (in->left == 0)
- bail("unexpected end of file on ", in->name);
- strm->avail_in = in->left;
- strm->next_in = in->next;
-}
-
-/* Write header for gzip file to out and initialize trailer. */
-local void gzinit(unsigned long *crc, unsigned long *tot, FILE *out)
-{
- fwrite("\x1f\x8b\x08\0\0\0\0\0\0\xff", 1, 10, out);
- *crc = crc32(0L, Z_NULL, 0);
- *tot = 0;
-}
-
-/* Copy the compressed data from name, zeroing the last block bit of the last
- block if clr is true, and adding empty blocks as needed to get to a byte
- boundary. If clr is false, then the last block becomes the last block of
- the output, and the gzip trailer is written. crc and tot maintains the
- crc and length (modulo 2^32) of the output for the trailer. The resulting
- gzip file is written to out. gzinit() must be called before the first call
- of gzcopy() to write the gzip header and to initialize crc and tot. */
-local void gzcopy(char *name, int clr, unsigned long *crc, unsigned long *tot,
- FILE *out)
-{
- int ret; /* return value from zlib functions */
- int pos; /* where the "last block" bit is in byte */
- int last; /* true if processing the last block */
- bin *in; /* buffered input file */
- unsigned char *start; /* start of compressed data in buffer */
- unsigned char *junk; /* buffer for uncompressed data -- discarded */
- z_off_t len; /* length of uncompressed data (support > 4 GB) */
- z_stream strm; /* zlib inflate stream */
-
- /* open gzip file and skip header */
- in = bopen(name);
- if (in == NULL)
- bail("could not open ", name);
- gzhead(in);
-
- /* allocate buffer for uncompressed data and initialize raw inflate
- stream */
- junk = malloc(CHUNK);
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- strm.opaque = Z_NULL;
- strm.avail_in = 0;
- strm.next_in = Z_NULL;
- ret = inflateInit2(&strm, -15);
- if (junk == NULL || ret != Z_OK)
- bail("out of memory", "");
-
- /* inflate and copy compressed data, clear last-block bit if requested */
- len = 0;
- zpull(&strm, in);
- start = strm.next_in;
- last = start[0] & 1;
- if (last && clr)
- start[0] &= ~1;
- strm.avail_out = 0;
- for (;;) {
- /* if input used and output done, write used input and get more */
- if (strm.avail_in == 0 && strm.avail_out != 0) {
- fwrite(start, 1, strm.next_in - start, out);
- start = in->buf;
- in->left = 0;
- zpull(&strm, in);
- }
-
- /* decompress -- return early when end-of-block reached */
- strm.avail_out = CHUNK;
- strm.next_out = junk;
- ret = inflate(&strm, Z_BLOCK);
- switch (ret) {
- case Z_MEM_ERROR:
- bail("out of memory", "");
- case Z_DATA_ERROR:
- bail("invalid compressed data in ", in->name);
- }
-
- /* update length of uncompressed data */
- len += CHUNK - strm.avail_out;
-
- /* check for block boundary (only get this when block copied out) */
- if (strm.data_type & 128) {
- /* if that was the last block, then done */
- if (last)
- break;
-
- /* number of unused bits in last byte */
- pos = strm.data_type & 7;
-
- /* find the next last-block bit */
- if (pos != 0) {
- /* next last-block bit is in last used byte */
- pos = 0x100 >> pos;
- last = strm.next_in[-1] & pos;
- if (last && clr)
- strm.next_in[-1] &= ~pos;
- }
- else {
- /* next last-block bit is in next unused byte */
- if (strm.avail_in == 0) {
- /* don't have that byte yet -- get it */
- fwrite(start, 1, strm.next_in - start, out);
- start = in->buf;
- in->left = 0;
- zpull(&strm, in);
- }
- last = strm.next_in[0] & 1;
- if (last && clr)
- strm.next_in[0] &= ~1;
- }
- }
- }
-
- /* update buffer with unused input */
- in->left = strm.avail_in;
- in->next = strm.next_in;
-
- /* copy used input, write empty blocks to get to byte boundary */
- pos = strm.data_type & 7;
- fwrite(start, 1, in->next - start - 1, out);
- last = in->next[-1];
- if (pos == 0 || !clr)
- /* already at byte boundary, or last file: write last byte */
- putc(last, out);
- else {
- /* append empty blocks to last byte */
- last &= ((0x100 >> pos) - 1); /* assure unused bits are zero */
- if (pos & 1) {
- /* odd -- append an empty stored block */
- putc(last, out);
- if (pos == 1)
- putc(0, out); /* two more bits in block header */
- fwrite("\0\0\xff\xff", 1, 4, out);
- }
- else {
- /* even -- append 1, 2, or 3 empty fixed blocks */
- switch (pos) {
- case 6:
- putc(last | 8, out);
- last = 0;
- case 4:
- putc(last | 0x20, out);
- last = 0;
- case 2:
- putc(last | 0x80, out);
- putc(0, out);
- }
- }
- }
-
- /* update crc and tot */
- *crc = crc32_combine(*crc, bget4(in), len);
- *tot += (unsigned long)len;
-
- /* clean up */
- inflateEnd(&strm);
- free(junk);
- bclose(in);
-
- /* write trailer if this is the last gzip file */
- if (!clr) {
- put4(*crc, out);
- put4(*tot, out);
- }
-}
-
-/* join the gzip files on the command line, write result to stdout */
-int main(int argc, char **argv)
-{
- unsigned long crc, tot; /* running crc and total uncompressed length */
-
- /* skip command name */
- argc--;
- argv++;
-
- /* show usage if no arguments */
- if (argc == 0) {
- fputs("gzjoin usage: gzjoin f1.gz [f2.gz [f3.gz ...]] > fjoin.gz\n",
- stderr);
- return 0;
- }
-
- /* join gzip files on command line and write to stdout */
- gzinit(&crc, &tot, stdout);
- while (argc--)
- gzcopy(*argv++, argc, &crc, &tot, stdout);
-
- /* done */
- return 0;
-}
diff --git a/source4/lib/zlib/examples/gzlog.c b/source4/lib/zlib/examples/gzlog.c
deleted file mode 100644
index f71f817c8b..0000000000
--- a/source4/lib/zlib/examples/gzlog.c
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * gzlog.c
- * Copyright (C) 2004 Mark Adler
- * For conditions of distribution and use, see copyright notice in gzlog.h
- * version 1.0, 26 Nov 2004
- *
- */
-
-#include <string.h> /* memcmp() */
-#include <stdlib.h> /* malloc(), free(), NULL */
-#include <sys/types.h> /* size_t, off_t */
-#include <unistd.h> /* read(), close(), sleep(), ftruncate(), */
- /* lseek() */
-#include <fcntl.h> /* open() */
-#include <sys/file.h> /* flock() */
-#include "zlib.h" /* deflateInit2(), deflate(), deflateEnd() */
-
-#include "gzlog.h" /* interface */
-#define local static
-
-/* log object structure */
-typedef struct {
- int id; /* object identifier */
- int fd; /* log file descriptor */
- off_t extra; /* offset of extra "ap" subfield */
- off_t mark_off; /* offset of marked data */
- off_t last_off; /* offset of last block */
- unsigned long crc; /* uncompressed crc */
- unsigned long len; /* uncompressed length (modulo 2^32) */
- unsigned stored; /* length of current stored block */
-} gz_log;
-
-#define GZLOGID 19334 /* gz_log object identifier */
-
-#define LOCK_RETRY 1 /* retry lock once a second */
-#define LOCK_PATIENCE 1200 /* try about twenty minutes before forcing */
-
-/* acquire a lock on a file */
-local int lock(int fd)
-{
- int patience;
-
- /* try to lock every LOCK_RETRY seconds for LOCK_PATIENCE seconds */
- patience = LOCK_PATIENCE;
- do {
- if (flock(fd, LOCK_EX + LOCK_NB) == 0)
- return 0;
- (void)sleep(LOCK_RETRY);
- patience -= LOCK_RETRY;
- } while (patience > 0);
-
- /* we've run out of patience -- give up */
- return -1;
-}
-
-/* release lock */
-local void unlock(int fd)
-{
- (void)flock(fd, LOCK_UN);
-}
-
-/* release a log object */
-local void log_clean(gz_log *log)
-{
- unlock(log->fd);
- (void)close(log->fd);
- free(log);
-}
-
-/* read an unsigned long from a byte buffer little-endian */
-local unsigned long make_ulg(unsigned char *buf)
-{
- int n;
- unsigned long val;
-
- val = (unsigned long)(*buf++);
- for (n = 8; n < 32; n += 8)
- val += (unsigned long)(*buf++) << n;
- return val;
-}
-
-/* read an off_t from a byte buffer little-endian */
-local off_t make_off(unsigned char *buf)
-{
- int n;
- off_t val;
-
- val = (off_t)(*buf++);
- for (n = 8; n < 64; n += 8)
- val += (off_t)(*buf++) << n;
- return val;
-}
-
-/* write an unsigned long little-endian to byte buffer */
-local void dice_ulg(unsigned long val, unsigned char *buf)
-{
- int n;
-
- for (n = 0; n < 4; n++) {
- *buf++ = val & 0xff;
- val >>= 8;
- }
-}
-
-/* write an off_t little-endian to byte buffer */
-local void dice_off(off_t val, unsigned char *buf)
-{
- int n;
-
- for (n = 0; n < 8; n++) {
- *buf++ = val & 0xff;
- val >>= 8;
- }
-}
-
-/* initial, empty gzip file for appending */
-local char empty_gz[] = {
- 0x1f, 0x8b, /* magic gzip id */
- 8, /* compression method is deflate */
- 4, /* there is an extra field */
- 0, 0, 0, 0, /* no modification time provided */
- 0, 0xff, /* no extra flags, no OS */
- 20, 0, 'a', 'p', 16, 0, /* extra field with "ap" subfield */
- 32, 0, 0, 0, 0, 0, 0, 0, /* offset of uncompressed data */
- 32, 0, 0, 0, 0, 0, 0, 0, /* offset of last block */
- 1, 0, 0, 0xff, 0xff, /* empty stored block (last) */
- 0, 0, 0, 0, /* crc */
- 0, 0, 0, 0 /* uncompressed length */
-};
-
-/* initialize a log object with locking */
-void *gzlog_open(char *path)
-{
- unsigned xlen;
- unsigned char temp[20];
- unsigned sub_len;
- int good;
- gz_log *log;
-
- /* allocate log structure */
- log = malloc(sizeof(gz_log));
- if (log == NULL)
- return NULL;
- log->id = GZLOGID;
-
- /* open file, creating it if necessary, and locking it */
- log->fd = open(path, O_RDWR | O_CREAT, 0600);
- if (log->fd < 0) {
- free(log);
- return NULL;
- }
- if (lock(log->fd)) {
- close(log->fd);
- free(log);
- return NULL;
- }
-
- /* if file is empty, write new gzip stream */
- if (lseek(log->fd, 0, SEEK_END) == 0) {
- if (write(log->fd, empty_gz, sizeof(empty_gz)) != sizeof(empty_gz)) {
- log_clean(log);
- return NULL;
- }
- }
-
- /* check gzip header */
- (void)lseek(log->fd, 0, SEEK_SET);
- if (read(log->fd, temp, 12) != 12 || temp[0] != 0x1f ||
- temp[1] != 0x8b || temp[2] != 8 || (temp[3] & 4) == 0) {
- log_clean(log);
- return NULL;
- }
-
- /* process extra field to find "ap" sub-field */
- xlen = temp[10] + (temp[11] << 8);
- good = 0;
- while (xlen) {
- if (xlen < 4 || read(log->fd, temp, 4) != 4)
- break;
- sub_len = temp[2];
- sub_len += temp[3] << 8;
- xlen -= 4;
- if (memcmp(temp, "ap", 2) == 0 && sub_len == 16) {
- good = 1;
- break;
- }
- if (xlen < sub_len)
- break;
- (void)lseek(log->fd, sub_len, SEEK_CUR);
- xlen -= sub_len;
- }
- if (!good) {
- log_clean(log);
- return NULL;
- }
-
- /* read in "ap" sub-field */
- log->extra = lseek(log->fd, 0, SEEK_CUR);
- if (read(log->fd, temp, 16) != 16) {
- log_clean(log);
- return NULL;
- }
- log->mark_off = make_off(temp);
- log->last_off = make_off(temp + 8);
-
- /* get crc, length of gzip file */
- (void)lseek(log->fd, log->last_off, SEEK_SET);
- if (read(log->fd, temp, 13) != 13 ||
- memcmp(temp, "\001\000\000\377\377", 5) != 0) {
- log_clean(log);
- return NULL;
- }
- log->crc = make_ulg(temp + 5);
- log->len = make_ulg(temp + 9);
-
- /* set up to write over empty last block */
- (void)lseek(log->fd, log->last_off + 5, SEEK_SET);
- log->stored = 0;
- return (void *)log;
-}
-
-/* maximum amount to put in a stored block before starting a new one */
-#define MAX_BLOCK 16384
-
-/* write a block to a log object */
-int gzlog_write(void *obj, char *data, size_t len)
-{
- size_t some;
- unsigned char temp[5];
- gz_log *log;
-
- /* check object */
- log = (gz_log *)obj;
- if (log == NULL || log->id != GZLOGID)
- return 1;
-
- /* write stored blocks until all of the input is written */
- do {
- some = MAX_BLOCK - log->stored;
- if (some > len)
- some = len;
- if (write(log->fd, data, some) != some)
- return 1;
- log->crc = crc32(log->crc, data, some);
- log->len += some;
- len -= some;
- data += some;
- log->stored += some;
-
- /* if the stored block is full, end it and start another */
- if (log->stored == MAX_BLOCK) {
- (void)lseek(log->fd, log->last_off, SEEK_SET);
- temp[0] = 0;
- dice_ulg(log->stored + ((unsigned long)(~log->stored) << 16),
- temp + 1);
- if (write(log->fd, temp, 5) != 5)
- return 1;
- log->last_off = lseek(log->fd, log->stored, SEEK_CUR);
- (void)lseek(log->fd, 5, SEEK_CUR);
- log->stored = 0;
- }
- } while (len);
- return 0;
-}
-
-/* recompress the remaining stored deflate data in place */
-local int recomp(gz_log *log)
-{
- z_stream strm;
- size_t len, max;
- unsigned char *in;
- unsigned char *out;
- unsigned char temp[16];
-
- /* allocate space and read it all in (it's around 1 MB) */
- len = log->last_off - log->mark_off;
- max = len + (len >> 12) + (len >> 14) + 11;
- out = malloc(max);
- if (out == NULL)
- return 1;
- in = malloc(len);
- if (in == NULL) {
- free(out);
- return 1;
- }
- (void)lseek(log->fd, log->mark_off, SEEK_SET);
- if (read(log->fd, in, len) != len) {
- free(in);
- free(out);
- return 1;
- }
-
- /* recompress in memory, decoding stored data as we go */
- /* note: this assumes that unsigned is four bytes or more */
- /* consider not making that assumption */
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- strm.opaque = Z_NULL;
- if (deflateInit2(&strm, Z_BEST_COMPRESSION, Z_DEFLATED, -15, 8,
- Z_DEFAULT_STRATEGY) != Z_OK) {
- free(in);
- free(out);
- return 1;
- }
- strm.next_in = in;
- strm.avail_out = max;
- strm.next_out = out;
- while (len >= 5) {
- if (strm.next_in[0] != 0)
- break;
- strm.avail_in = strm.next_in[1] + (strm.next_in[2] << 8);
- strm.next_in += 5;
- len -= 5;
- if (strm.avail_in != 0) {
- if (len < strm.avail_in)
- break;
- len -= strm.avail_in;
- (void)deflate(&strm, Z_NO_FLUSH);
- if (strm.avail_in != 0 || strm.avail_out == 0)
- break;
- }
- }
- (void)deflate(&strm, Z_SYNC_FLUSH);
- (void)deflateEnd(&strm);
- free(in);
- if (len != 0 || strm.avail_out == 0) {
- free(out);
- return 1;
- }
-
- /* overwrite stored data with compressed data */
- (void)lseek(log->fd, log->mark_off, SEEK_SET);
- len = max - strm.avail_out;
- if (write(log->fd, out, len) != len) {
- free(out);
- return 1;
- }
- free(out);
-
- /* write last empty block, crc, and length */
- log->mark_off = log->last_off = lseek(log->fd, 0, SEEK_CUR);
- temp[0] = 1;
- dice_ulg(0xffffL << 16, temp + 1);
- dice_ulg(log->crc, temp + 5);
- dice_ulg(log->len, temp + 9);
- if (write(log->fd, temp, 13) != 13)
- return 1;
-
- /* truncate file to discard remaining stored data and old trailer */
- ftruncate(log->fd, lseek(log->fd, 0, SEEK_CUR));
-
- /* update extra field to point to new last empty block */
- (void)lseek(log->fd, log->extra, SEEK_SET);
- dice_off(log->mark_off, temp);
- dice_off(log->last_off, temp + 8);
- if (write(log->fd, temp, 16) != 16)
- return 1;
- return 0;
-}
-
-/* maximum accumulation of stored blocks before compressing */
-#define MAX_STORED 1048576
-
-/* close log object */
-int gzlog_close(void *obj)
-{
- unsigned char temp[8];
- gz_log *log;
-
- /* check object */
- log = (gz_log *)obj;
- if (log == NULL || log->id != GZLOGID)
- return 1;
-
- /* go to start of most recent block being written */
- (void)lseek(log->fd, log->last_off, SEEK_SET);
-
- /* if some stuff was put there, update block */
- if (log->stored) {
- temp[0] = 0;
- dice_ulg(log->stored + ((unsigned long)(~log->stored) << 16),
- temp + 1);
- if (write(log->fd, temp, 5) != 5)
- return 1;
- log->last_off = lseek(log->fd, log->stored, SEEK_CUR);
- }
-
- /* write last block (empty) */
- if (write(log->fd, "\001\000\000\377\377", 5) != 5)
- return 1;
-
- /* write updated crc and uncompressed length */
- dice_ulg(log->crc, temp);
- dice_ulg(log->len, temp + 4);
- if (write(log->fd, temp, 8) != 8)
- return 1;
-
- /* put offset of that last block in gzip extra block */
- (void)lseek(log->fd, log->extra + 8, SEEK_SET);
- dice_off(log->last_off, temp);
- if (write(log->fd, temp, 8) != 8)
- return 1;
-
- /* if more than 1 MB stored, then time to compress it */
- if (log->last_off - log->mark_off > MAX_STORED) {
- if (recomp(log))
- return 1;
- }
-
- /* unlock and close file */
- log_clean(log);
- return 0;
-}
diff --git a/source4/lib/zlib/examples/gzlog.h b/source4/lib/zlib/examples/gzlog.h
deleted file mode 100644
index a800bd5391..0000000000
--- a/source4/lib/zlib/examples/gzlog.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* gzlog.h
- Copyright (C) 2004 Mark Adler, all rights reserved
- version 1.0, 26 Nov 2004
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the author be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Mark Adler madler@alumni.caltech.edu
- */
-
-/*
- The gzlog object allows writing short messages to a gzipped log file,
- opening the log file locked for small bursts, and then closing it. The log
- object works by appending stored data to the gzip file until 1 MB has been
- accumulated. At that time, the stored data is compressed, and replaces the
- uncompressed data in the file. The log file is truncated to its new size at
- that time. After closing, the log file is always valid gzip file that can
- decompressed to recover what was written.
-
- A gzip header "extra" field contains two file offsets for appending. The
- first points to just after the last compressed data. The second points to
- the last stored block in the deflate stream, which is empty. All of the
- data between those pointers is uncompressed.
- */
-
-/* Open a gzlog object, creating the log file if it does not exist. Return
- NULL on error. Note that gzlog_open() could take a long time to return if
- there is difficulty in locking the file. */
-void *gzlog_open(char *path);
-
-/* Write to a gzlog object. Return non-zero on error. This function will
- simply write data to the file uncompressed. Compression of the data
- will not occur until gzlog_close() is called. It is expected that
- gzlog_write() is used for a short message, and then gzlog_close() is
- called. If a large amount of data is to be written, then the application
- should write no more than 1 MB at a time with gzlog_write() before
- calling gzlog_close() and then gzlog_open() again. */
-int gzlog_write(void *log, char *data, size_t len);
-
-/* Close a gzlog object. Return non-zero on error. The log file is locked
- until this function is called. This function will compress stored data
- at the end of the gzip file if at least 1 MB has been accumulated. Note
- that the file will not be a valid gzip file until this function completes.
- */
-int gzlog_close(void *log);
diff --git a/source4/lib/zlib/examples/zlib_how.html b/source4/lib/zlib/examples/zlib_how.html
deleted file mode 100644
index 40998dbf08..0000000000
--- a/source4/lib/zlib/examples/zlib_how.html
+++ /dev/null
@@ -1,523 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
- "http://www.w3.org/TR/REC-html40/loose.dtd">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-<title>zlib Usage Example</title>
-<!-- Copyright (c) 2004 Mark Adler. -->
-</head>
-<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#00A000">
-<h2 align="center"> zlib Usage Example </h2>
-We often get questions about how the <tt>deflate()</tt> and <tt>inflate()</tt> functions should be used.
-Users wonder when they should provide more input, when they should use more output,
-what to do with a <tt>Z_BUF_ERROR</tt>, how to make sure the process terminates properly, and
-so on. So for those who have read <tt>zlib.h</tt> (a few times), and
-would like further edification, below is an annotated example in C of simple routines to compress and decompress
-from an input file to an output file using <tt>deflate()</tt> and <tt>inflate()</tt> respectively. The
-annotations are interspersed between lines of the code. So please read between the lines.
-We hope this helps explain some of the intricacies of <em>zlib</em>.
-<p>
-Without further adieu, here is the program <a href="zpipe.c"><tt>zpipe.c</tt></a>:
-<pre><b>
-/* zpipe.c: example of proper use of zlib's inflate() and deflate()
- Not copyrighted -- provided to the public domain
- Version 1.2 9 November 2004 Mark Adler */
-
-/* Version history:
- 1.0 30 Oct 2004 First version
- 1.1 8 Nov 2004 Add void casting for unused return values
- Use switch statement for inflate() return values
- 1.2 9 Nov 2004 Add assertions to document zlib guarantees
- */
-</b></pre><!-- -->
-We now include the header files for the required definitions. From
-<tt>stdio.h</tt> we use <tt>fopen()</tt>, <tt>fread()</tt>, <tt>fwrite()</tt>,
-<tt>feof()</tt>, <tt>ferror()</tt>, and <tt>fclose()</tt> for file i/o, and
-<tt>fputs()</tt> for error messages. From <tt>string.h</tt> we use
-<tt>strcmp()</tt> for command line argument processing.
-From <tt>assert.h</tt> we use the <tt>assert()</tt> macro.
-From <tt>zlib.h</tt>
-we use the basic compression functions <tt>deflateInit()</tt>,
-<tt>deflate()</tt>, and <tt>deflateEnd()</tt>, and the basic decompression
-functions <tt>inflateInit()</tt>, <tt>inflate()</tt>, and
-<tt>inflateEnd()</tt>.
-<pre><b>
-#include &lt;stdio.h&gt;
-#include &lt;string.h&gt;
-#include &lt;assert.h&gt;
-#include "zlib.h"
-</b></pre><!-- -->
-<tt>CHUNK</tt> is simply the buffer size for feeding data to and pulling data
-from the <em>zlib</em> routines. Larger buffer sizes would be more efficient,
-especially for <tt>inflate()</tt>. If the memory is available, buffers sizes
-on the order of 128K or 256K bytes should be used.
-<pre><b>
-#define CHUNK 16384
-</b></pre><!-- -->
-The <tt>def()</tt> routine compresses data from an input file to an output file. The output data
-will be in the <em>zlib</em> format, which is different from the <em>gzip</em> or <em>zip</em>
-formats. The <em>zlib</em> format has a very small header of only two bytes to identify it as
-a <em>zlib</em> stream and to provide decoding information, and a four-byte trailer with a fast
-check value to verify the integrity of the uncompressed data after decoding.
-<pre><b>
-/* Compress from file source to file dest until EOF on source.
- def() returns Z_OK on success, Z_MEM_ERROR if memory could not be
- allocated for processing, Z_STREAM_ERROR if an invalid compression
- level is supplied, Z_VERSION_ERROR if the version of zlib.h and the
- version of the library linked do not match, or Z_ERRNO if there is
- an error reading or writing the files. */
-int def(FILE *source, FILE *dest, int level)
-{
-</b></pre>
-Here are the local variables for <tt>def()</tt>. <tt>ret</tt> will be used for <em>zlib</em>
-return codes. <tt>flush</tt> will keep track of the current flushing state for <tt>deflate()</tt>,
-which is either no flushing, or flush to completion after the end of the input file is reached.
-<tt>have</tt> is the amount of data returned from <tt>deflate()</tt>. The <tt>strm</tt> structure
-is used to pass information to and from the <em>zlib</em> routines, and to maintain the
-<tt>deflate()</tt> state. <tt>in</tt> and <tt>out</tt> are the input and output buffers for
-<tt>deflate()</tt>.
-<pre><b>
- int ret, flush;
- unsigned have;
- z_stream strm;
- char in[CHUNK];
- char out[CHUNK];
-</b></pre><!-- -->
-The first thing we do is to initialize the <em>zlib</em> state for compression using
-<tt>deflateInit()</tt>. This must be done before the first use of <tt>deflate()</tt>.
-The <tt>zalloc</tt>, <tt>zfree</tt>, and <tt>opaque</tt> fields in the <tt>strm</tt>
-structure must be initialized before calling <tt>deflateInit()</tt>. Here they are
-set to the <em>zlib</em> constant <tt>Z_NULL</tt> to request that <em>zlib</em> use
-the default memory allocation routines. An application may also choose to provide
-custom memory allocation routines here. <tt>deflateInit()</tt> will allocate on the
-order of 256K bytes for the internal state.
-(See <a href="zlib_tech.html"><em>zlib Technical Details</em></a>.)
-<p>
-<tt>deflateInit()</tt> is called with a pointer to the structure to be initialized and
-the compression level, which is an integer in the range of -1 to 9. Lower compression
-levels result in faster execution, but less compression. Higher levels result in
-greater compression, but slower execution. The <em>zlib</em> constant Z_DEFAULT_COMPRESSION,
-equal to -1,
-provides a good compromise between compression and speed and is equivalent to level 6.
-Level 0 actually does no compression at all, and in fact expands the data slightly to produce
-the <em>zlib</em> format (it is not a byte-for-byte copy of the input).
-More advanced applications of <em>zlib</em>
-may use <tt>deflateInit2()</tt> here instead. Such an application may want to reduce how
-much memory will be used, at some price in compression. Or it may need to request a
-<em>gzip</em> header and trailer instead of a <em>zlib</em> header and trailer, or raw
-encoding with no header or trailer at all.
-<p>
-We must check the return value of <tt>deflateInit()</tt> against the <em>zlib</em> constant
-<tt>Z_OK</tt> to make sure that it was able to
-allocate memory for the internal state, and that the provided arguments were valid.
-<tt>deflateInit()</tt> will also check that the version of <em>zlib</em> that the <tt>zlib.h</tt>
-file came from matches the version of <em>zlib</em> actually linked with the program. This
-is especially important for environments in which <em>zlib</em> is a shared library.
-<p>
-Note that an application can initialize multiple, independent <em>zlib</em> streams, which can
-operate in parallel. The state information maintained in the structure allows the <em>zlib</em>
-routines to be reentrant.
-<pre><b>
- /* allocate deflate state */
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- strm.opaque = Z_NULL;
- ret = deflateInit(&amp;strm, level);
- if (ret != Z_OK)
- return ret;
-</b></pre><!-- -->
-With the pleasantries out of the way, now we can get down to business. The outer <tt>do</tt>-loop
-reads all of the input file and exits at the bottom of the loop once end-of-file is reached.
-This loop contains the only call of <tt>deflate()</tt>. So we must make sure that all of the
-input data has been processed and that all of the output data has been generated and consumed
-before we fall out of the loop at the bottom.
-<pre><b>
- /* compress until end of file */
- do {
-</b></pre>
-We start off by reading data from the input file. The number of bytes read is put directly
-into <tt>avail_in</tt>, and a pointer to those bytes is put into <tt>next_in</tt>. We also
-check to see if end-of-file on the input has been reached. If we are at the end of file, then <tt>flush</tt> is set to the
-<em>zlib</em> constant <tt>Z_FINISH</tt>, which is later passed to <tt>deflate()</tt> to
-indicate that this is the last chunk of input data to compress. We need to use <tt>feof()</tt>
-to check for end-of-file as opposed to seeing if fewer than <tt>CHUNK</tt> bytes have been read. The
-reason is that if the input file length is an exact multiple of <tt>CHUNK</tt>, we will miss
-the fact that we got to the end-of-file, and not know to tell <tt>deflate()</tt> to finish
-up the compressed stream. If we are not yet at the end of the input, then the <em>zlib</em>
-constant <tt>Z_NO_FLUSH</tt> will be passed to <tt>deflate</tt> to indicate that we are still
-in the middle of the uncompressed data.
-<p>
-If there is an error in reading from the input file, the process is aborted with
-<tt>deflateEnd()</tt> being called to free the allocated <em>zlib</em> state before returning
-the error. We wouldn't want a memory leak, now would we? <tt>deflateEnd()</tt> can be called
-at any time after the state has been initialized. Once that's done, <tt>deflateInit()</tt> (or
-<tt>deflateInit2()</tt>) would have to be called to start a new compression process. There is
-no point here in checking the <tt>deflateEnd()</tt> return code. The deallocation can't fail.
-<pre><b>
- strm.avail_in = fread(in, 1, CHUNK, source);
- if (ferror(source)) {
- (void)deflateEnd(&amp;strm);
- return Z_ERRNO;
- }
- flush = feof(source) ? Z_FINISH : Z_NO_FLUSH;
- strm.next_in = in;
-</b></pre><!-- -->
-The inner <tt>do</tt>-loop passes our chunk of input data to <tt>deflate()</tt>, and then
-keeps calling <tt>deflate()</tt> until it is done producing output. Once there is no more
-new output, <tt>deflate()</tt> is guaranteed to have consumed all of the input, i.e.,
-<tt>avail_in</tt> will be zero.
-<pre><b>
- /* run deflate() on input until output buffer not full, finish
- compression if all of source has been read in */
- do {
-</b></pre>
-Output space is provided to <tt>deflate()</tt> by setting <tt>avail_out</tt> to the number
-of available output bytes and <tt>next_out</tt> to a pointer to that space.
-<pre><b>
- strm.avail_out = CHUNK;
- strm.next_out = out;
-</b></pre>
-Now we call the compression engine itself, <tt>deflate()</tt>. It takes as many of the
-<tt>avail_in</tt> bytes at <tt>next_in</tt> as it can process, and writes as many as
-<tt>avail_out</tt> bytes to <tt>next_out</tt>. Those counters and pointers are then
-updated past the input data consumed and the output data written. It is the amount of
-output space available that may limit how much input is consumed.
-Hence the inner loop to make sure that
-all of the input is consumed by providing more output space each time. Since <tt>avail_in</tt>
-and <tt>next_in</tt> are updated by <tt>deflate()</tt>, we don't have to mess with those
-between <tt>deflate()</tt> calls until it's all used up.
-<p>
-The parameters to <tt>deflate()</tt> are a pointer to the <tt>strm</tt> structure containing
-the input and output information and the internal compression engine state, and a parameter
-indicating whether and how to flush data to the output. Normally <tt>deflate</tt> will consume
-several K bytes of input data before producing any output (except for the header), in order
-to accumulate statistics on the data for optimum compression. It will then put out a burst of
-compressed data, and proceed to consume more input before the next burst. Eventually,
-<tt>deflate()</tt>
-must be told to terminate the stream, complete the compression with provided input data, and
-write out the trailer check value. <tt>deflate()</tt> will continue to compress normally as long
-as the flush parameter is <tt>Z_NO_FLUSH</tt>. Once the <tt>Z_FINISH</tt> parameter is provided,
-<tt>deflate()</tt> will begin to complete the compressed output stream. However depending on how
-much output space is provided, <tt>deflate()</tt> may have to be called several times until it
-has provided the complete compressed stream, even after it has consumed all of the input. The flush
-parameter must continue to be <tt>Z_FINISH</tt> for those subsequent calls.
-<p>
-There are other values of the flush parameter that are used in more advanced applications. You can
-force <tt>deflate()</tt> to produce a burst of output that encodes all of the input data provided
-so far, even if it wouldn't have otherwise, for example to control data latency on a link with
-compressed data. You can also ask that <tt>deflate()</tt> do that as well as erase any history up to
-that point so that what follows can be decompressed independently, for example for random access
-applications. Both requests will degrade compression by an amount depending on how often such
-requests are made.
-<p>
-<tt>deflate()</tt> has a return value that can indicate errors, yet we do not check it here. Why
-not? Well, it turns out that <tt>deflate()</tt> can do no wrong here. Let's go through
-<tt>deflate()</tt>'s return values and dispense with them one by one. The possible values are
-<tt>Z_OK</tt>, <tt>Z_STREAM_END</tt>, <tt>Z_STREAM_ERROR</tt>, or <tt>Z_BUF_ERROR</tt>. <tt>Z_OK</tt>
-is, well, ok. <tt>Z_STREAM_END</tt> is also ok and will be returned for the last call of
-<tt>deflate()</tt>. This is already guaranteed by calling <tt>deflate()</tt> with <tt>Z_FINISH</tt>
-until it has no more output. <tt>Z_STREAM_ERROR</tt> is only possible if the stream is not
-initialized properly, but we did initialize it properly. There is no harm in checking for
-<tt>Z_STREAM_ERROR</tt> here, for example to check for the possibility that some
-other part of the application inadvertently clobbered the memory containing the <em>zlib</em> state.
-<tt>Z_BUF_ERROR</tt> will be explained further below, but
-suffice it to say that this is simply an indication that <tt>deflate()</tt> could not consume
-more input or produce more output. <tt>deflate()</tt> can be called again with more output space
-or more available input, which it will be in this code.
-<pre><b>
- ret = deflate(&amp;strm, flush); /* no bad return value */
- assert(ret != Z_STREAM_ERROR); /* state not clobbered */
-</b></pre>
-Now we compute how much output <tt>deflate()</tt> provided on the last call, which is the
-difference between how much space was provided before the call, and how much output space
-is still available after the call. Then that data, if any, is written to the output file.
-We can then reuse the output buffer for the next call of <tt>deflate()</tt>. Again if there
-is a file i/o error, we call <tt>deflateEnd()</tt> before returning to avoid a memory leak.
-<pre><b>
- have = CHUNK - strm.avail_out;
- if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
- (void)deflateEnd(&amp;strm);
- return Z_ERRNO;
- }
-</b></pre>
-The inner <tt>do</tt>-loop is repeated until the last <tt>deflate()</tt> call fails to fill the
-provided output buffer. Then we know that <tt>deflate()</tt> has done as much as it can with
-the provided input, and that all of that input has been consumed. We can then fall out of this
-loop and reuse the input buffer.
-<p>
-The way we tell that <tt>deflate()</tt> has no more output is by seeing that it did not fill
-the output buffer, leaving <tt>avail_out</tt> greater than zero. However suppose that
-<tt>deflate()</tt> has no more output, but just so happened to exactly fill the output buffer!
-<tt>avail_out</tt> is zero, and we can't tell that <tt>deflate()</tt> has done all it can.
-As far as we know, <tt>deflate()</tt>
-has more output for us. So we call it again. But now <tt>deflate()</tt> produces no output
-at all, and <tt>avail_out</tt> remains unchanged as <tt>CHUNK</tt>. That <tt>deflate()</tt> call
-wasn't able to do anything, either consume input or produce output, and so it returns
-<tt>Z_BUF_ERROR</tt>. (See, I told you I'd cover this later.) However this is not a problem at
-all. Now we finally have the desired indication that <tt>deflate()</tt> is really done,
-and so we drop out of the inner loop to provide more input to <tt>deflate()</tt>.
-<p>
-With <tt>flush</tt> set to <tt>Z_FINISH</tt>, this final set of <tt>deflate()</tt> calls will
-complete the output stream. Once that is done, subsequent calls of <tt>deflate()</tt> would return
-<tt>Z_STREAM_ERROR</tt> if the flush parameter is not <tt>Z_FINISH</tt>, and do no more processing
-until the state is reinitialized.
-<p>
-Some applications of <em>zlib</em> have two loops that call <tt>deflate()</tt>
-instead of the single inner loop we have here. The first loop would call
-without flushing and feed all of the data to <tt>deflate()</tt>. The second loop would call
-<tt>deflate()</tt> with no more
-data and the <tt>Z_FINISH</tt> parameter to complete the process. As you can see from this
-example, that can be avoided by simply keeping track of the current flush state.
-<pre><b>
- } while (strm.avail_out == 0);
- assert(strm.avail_in == 0); /* all input will be used */
-</b></pre><!-- -->
-Now we check to see if we have already processed all of the input file. That information was
-saved in the <tt>flush</tt> variable, so we see if that was set to <tt>Z_FINISH</tt>. If so,
-then we're done and we fall out of the outer loop. We're guaranteed to get <tt>Z_STREAM_END</tt>
-from the last <tt>deflate()</tt> call, since we ran it until the last chunk of input was
-consumed and all of the output was generated.
-<pre><b>
- /* done when last data in file processed */
- } while (flush != Z_FINISH);
- assert(ret == Z_STREAM_END); /* stream will be complete */
-</b></pre><!-- -->
-The process is complete, but we still need to deallocate the state to avoid a memory leak
-(or rather more like a memory hemorrhage if you didn't do this). Then
-finally we can return with a happy return value.
-<pre><b>
- /* clean up and return */
- (void)deflateEnd(&amp;strm);
- return Z_OK;
-}
-</b></pre><!-- -->
-Now we do the same thing for decompression in the <tt>inf()</tt> routine. <tt>inf()</tt>
-decompresses what is hopefully a valid <em>zlib</em> stream from the input file and writes the
-uncompressed data to the output file. Much of the discussion above for <tt>def()</tt>
-applies to <tt>inf()</tt> as well, so the discussion here will focus on the differences between
-the two.
-<pre><b>
-/* Decompress from file source to file dest until stream ends or EOF.
- inf() returns Z_OK on success, Z_MEM_ERROR if memory could not be
- allocated for processing, Z_DATA_ERROR if the deflate data is
- invalid or incomplete, Z_VERSION_ERROR if the version of zlib.h and
- the version of the library linked do not match, or Z_ERRNO if there
- is an error reading or writing the files. */
-int inf(FILE *source, FILE *dest)
-{
-</b></pre>
-The local variables have the same functionality as they do for <tt>def()</tt>. The
-only difference is that there is no <tt>flush</tt> variable, since <tt>inflate()</tt>
-can tell from the <em>zlib</em> stream itself when the stream is complete.
-<pre><b>
- int ret;
- unsigned have;
- z_stream strm;
- char in[CHUNK];
- char out[CHUNK];
-</b></pre><!-- -->
-The initialization of the state is the same, except that there is no compression level,
-of course, and two more elements of the structure are initialized. <tt>avail_in</tt>
-and <tt>next_in</tt> must be initialized before calling <tt>inflateInit()</tt>. This
-is because the application has the option to provide the start of the zlib stream in
-order for <tt>inflateInit()</tt> to have access to information about the compression
-method to aid in memory allocation. In the current implementation of <em>zlib</em>
-(up through versions 1.2.x), the method-dependent memory allocations are deferred to the first call of
-<tt>inflate()</tt> anyway. However those fields must be initialized since later versions
-of <em>zlib</em> that provide more compression methods may take advantage of this interface.
-In any case, no decompression is performed by <tt>inflateInit()</tt>, so the
-<tt>avail_out</tt> and <tt>next_out</tt> fields do not need to be initialized before calling.
-<p>
-Here <tt>avail_in</tt> is set to zero and <tt>next_in</tt> is set to <tt>Z_NULL</tt> to
-indicate that no input data is being provided.
-<pre><b>
- /* allocate inflate state */
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- strm.opaque = Z_NULL;
- strm.avail_in = 0;
- strm.next_in = Z_NULL;
- ret = inflateInit(&amp;strm);
- if (ret != Z_OK)
- return ret;
-</b></pre><!-- -->
-The outer <tt>do</tt>-loop decompresses input until <tt>inflate()</tt> indicates
-that it has reached the end of the compressed data and has produced all of the uncompressed
-output. This is in contrast to <tt>def()</tt> which processes all of the input file.
-If end-of-file is reached before the compressed data self-terminates, then the compressed
-data is incomplete and an error is returned.
-<pre><b>
- /* decompress until deflate stream ends or end of file */
- do {
-</b></pre>
-We read input data and set the <tt>strm</tt> structure accordingly. If we've reached the
-end of the input file, then we leave the outer loop and report an error, since the
-compressed data is incomplete. Note that we may read more data than is eventually consumed
-by <tt>inflate()</tt>, if the input file continues past the <em>zlib</em> stream.
-For applications where <em>zlib</em> streams are embedded in other data, this routine would
-need to be modified to return the unused data, or at least indicate how much of the input
-data was not used, so the application would know where to pick up after the <em>zlib</em> stream.
-<pre><b>
- strm.avail_in = fread(in, 1, CHUNK, source);
- if (ferror(source)) {
- (void)inflateEnd(&amp;strm);
- return Z_ERRNO;
- }
- if (strm.avail_in == 0)
- break;
- strm.next_in = in;
-</b></pre><!-- -->
-The inner <tt>do</tt>-loop has the same function it did in <tt>def()</tt>, which is to
-keep calling <tt>inflate()</tt> until has generated all of the output it can with the
-provided input.
-<pre><b>
- /* run inflate() on input until output buffer not full */
- do {
-</b></pre>
-Just like in <tt>def()</tt>, the same output space is provided for each call of <tt>inflate()</tt>.
-<pre><b>
- strm.avail_out = CHUNK;
- strm.next_out = out;
-</b></pre>
-Now we run the decompression engine itself. There is no need to adjust the flush parameter, since
-the <em>zlib</em> format is self-terminating. The main difference here is that there are
-return values that we need to pay attention to. <tt>Z_DATA_ERROR</tt>
-indicates that <tt>inflate()</tt> detected an error in the <em>zlib</em> compressed data format,
-which means that either the data is not a <em>zlib</em> stream to begin with, or that the data was
-corrupted somewhere along the way since it was compressed. The other error to be processed is
-<tt>Z_MEM_ERROR</tt>, which can occur since memory allocation is deferred until <tt>inflate()</tt>
-needs it, unlike <tt>deflate()</tt>, whose memory is allocated at the start by <tt>deflateInit()</tt>.
-<p>
-Advanced applications may use
-<tt>deflateSetDictionary()</tt> to prime <tt>deflate()</tt> with a set of likely data to improve the
-first 32K or so of compression. This is noted in the <em>zlib</em> header, so <tt>inflate()</tt>
-requests that that dictionary be provided before it can start to decompress. Without the dictionary,
-correct decompression is not possible. For this routine, we have no idea what the dictionary is,
-so the <tt>Z_NEED_DICT</tt> indication is converted to a <tt>Z_DATA_ERROR</tt>.
-<p>
-<tt>inflate()</tt> can also return <tt>Z_STREAM_ERROR</tt>, which should not be possible here,
-but could be checked for as noted above for <tt>def()</tt>. <tt>Z_BUF_ERROR</tt> does not need to be
-checked for here, for the same reasons noted for <tt>def()</tt>. <tt>Z_STREAM_END</tt> will be
-checked for later.
-<pre><b>
- ret = inflate(&amp;strm, Z_NO_FLUSH);
- assert(ret != Z_STREAM_ERROR); /* state not clobbered */
- switch (ret) {
- case Z_NEED_DICT:
- ret = Z_DATA_ERROR; /* and fall through */
- case Z_DATA_ERROR:
- case Z_MEM_ERROR:
- (void)inflateEnd(&amp;strm);
- return ret;
- }
-</b></pre>
-The output of <tt>inflate()</tt> is handled identically to that of <tt>deflate()</tt>.
-<pre><b>
- have = CHUNK - strm.avail_out;
- if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
- (void)inflateEnd(&amp;strm);
- return Z_ERRNO;
- }
-</b></pre>
-The inner <tt>do</tt>-loop ends when <tt>inflate()</tt> has no more output as indicated
-by not filling the output buffer, just as for <tt>deflate()</tt>. In this case, we cannot
-assert that <tt>strm.avail_in</tt> will be zero, since the deflate stream may end before the file
-does.
-<pre><b>
- } while (strm.avail_out == 0);
-</b></pre><!-- -->
-The outer <tt>do</tt>-loop ends when <tt>inflate()</tt> reports that it has reached the
-end of the input <em>zlib</em> stream, has completed the decompression and integrity
-check, and has provided all of the output. This is indicated by the <tt>inflate()</tt>
-return value <tt>Z_STREAM_END</tt>. The inner loop is guaranteed to leave <tt>ret</tt>
-equal to <tt>Z_STREAM_END</tt> if the last chunk of the input file read contained the end
-of the <em>zlib</em> stream. So if the return value is not <tt>Z_STREAM_END</tt>, the
-loop continues to read more input.
-<pre><b>
- /* done when inflate() says it's done */
- } while (ret != Z_STREAM_END);
-</b></pre><!-- -->
-At this point, decompression successfully completed, or we broke out of the loop due to no
-more data being available from the input file. If the last <tt>inflate()</tt> return value
-is not <tt>Z_STREAM_END</tt>, then the <em>zlib</em> stream was incomplete and a data error
-is returned. Otherwise, we return with a happy return value. Of course, <tt>inflateEnd()</tt>
-is called first to avoid a memory leak.
-<pre><b>
- /* clean up and return */
- (void)inflateEnd(&amp;strm);
- return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
-}
-</b></pre><!-- -->
-That ends the routines that directly use <em>zlib</em>. The following routines make this
-a command-line program by running data through the above routines from <tt>stdin</tt> to
-<tt>stdout</tt>, and handling any errors reported by <tt>def()</tt> or <tt>inf()</tt>.
-<p>
-<tt>zerr()</tt> is used to interpret the possible error codes from <tt>def()</tt>
-and <tt>inf()</tt>, as detailed in their comments above, and print out an error message.
-Note that these are only a subset of the possible return values from <tt>deflate()</tt>
-and <tt>inflate()</tt>.
-<pre><b>
-/* report a zlib or i/o error */
-void zerr(int ret)
-{
- fputs("zpipe: ", stderr);
- switch (ret) {
- case Z_ERRNO:
- if (ferror(stdin))
- fputs("error reading stdin\n", stderr);
- if (ferror(stdout))
- fputs("error writing stdout\n", stderr);
- break;
- case Z_STREAM_ERROR:
- fputs("invalid compression level\n", stderr);
- break;
- case Z_DATA_ERROR:
- fputs("invalid or incomplete deflate data\n", stderr);
- break;
- case Z_MEM_ERROR:
- fputs("out of memory\n", stderr);
- break;
- case Z_VERSION_ERROR:
- fputs("zlib version mismatch!\n", stderr);
- }
-}
-</b></pre><!-- -->
-Here is the <tt>main()</tt> routine used to test <tt>def()</tt> and <tt>inf()</tt>. The
-<tt>zpipe</tt> command is simply a compression pipe from <tt>stdin</tt> to <tt>stdout</tt>, if
-no arguments are given, or it is a decompression pipe if <tt>zpipe -d</tt> is used. If any other
-arguments are provided, no compression or decompression is performed. Instead a usage
-message is displayed. Examples are <tt>zpipe < foo.txt > foo.txt.z</tt> to compress, and
-<tt>zpipe -d < foo.txt.z > foo.txt</tt> to decompress.
-<pre><b>
-/* compress or decompress from stdin to stdout */
-int main(int argc, char **argv)
-{
- int ret;
-
- /* do compression if no arguments */
- if (argc == 1) {
- ret = def(stdin, stdout, Z_DEFAULT_COMPRESSION);
- if (ret != Z_OK)
- zerr(ret);
- return ret;
- }
-
- /* do decompression if -d specified */
- else if (argc == 2 &amp;&amp; strcmp(argv[1], "-d") == 0) {
- ret = inf(stdin, stdout);
- if (ret != Z_OK)
- zerr(ret);
- return ret;
- }
-
- /* otherwise, report usage */
- else {
- fputs("zpipe usage: zpipe [-d] &lt; source &gt; dest\n", stderr);
- return 1;
- }
-}
-</b></pre>
-<hr>
-<i>Copyright (c) 2004 by Mark Adler<br>Last modified 13 November 2004</i>
-</body>
-</html>
diff --git a/source4/lib/zlib/examples/zpipe.c b/source4/lib/zlib/examples/zpipe.c
deleted file mode 100644
index 26abb56a9c..0000000000
--- a/source4/lib/zlib/examples/zpipe.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/* zpipe.c: example of proper use of zlib's inflate() and deflate()
- Not copyrighted -- provided to the public domain
- Version 1.2 9 November 2004 Mark Adler */
-
-/* Version history:
- 1.0 30 Oct 2004 First version
- 1.1 8 Nov 2004 Add void casting for unused return values
- Use switch statement for inflate() return values
- 1.2 9 Nov 2004 Add assertions to document zlib guarantees
- 1.3 6 Apr 2005 Remove incorrect assertion in inf()
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include "zlib.h"
-
-#define CHUNK 16384
-
-/* Compress from file source to file dest until EOF on source.
- def() returns Z_OK on success, Z_MEM_ERROR if memory could not be
- allocated for processing, Z_STREAM_ERROR if an invalid compression
- level is supplied, Z_VERSION_ERROR if the version of zlib.h and the
- version of the library linked do not match, or Z_ERRNO if there is
- an error reading or writing the files. */
-int def(FILE *source, FILE *dest, int level)
-{
- int ret, flush;
- unsigned have;
- z_stream strm;
- char in[CHUNK];
- char out[CHUNK];
-
- /* allocate deflate state */
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- strm.opaque = Z_NULL;
- ret = deflateInit(&strm, level);
- if (ret != Z_OK)
- return ret;
-
- /* compress until end of file */
- do {
- strm.avail_in = fread(in, 1, CHUNK, source);
- if (ferror(source)) {
- (void)deflateEnd(&strm);
- return Z_ERRNO;
- }
- flush = feof(source) ? Z_FINISH : Z_NO_FLUSH;
- strm.next_in = in;
-
- /* run deflate() on input until output buffer not full, finish
- compression if all of source has been read in */
- do {
- strm.avail_out = CHUNK;
- strm.next_out = out;
- ret = deflate(&strm, flush); /* no bad return value */
- assert(ret != Z_STREAM_ERROR); /* state not clobbered */
- have = CHUNK - strm.avail_out;
- if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
- (void)deflateEnd(&strm);
- return Z_ERRNO;
- }
- } while (strm.avail_out == 0);
- assert(strm.avail_in == 0); /* all input will be used */
-
- /* done when last data in file processed */
- } while (flush != Z_FINISH);
- assert(ret == Z_STREAM_END); /* stream will be complete */
-
- /* clean up and return */
- (void)deflateEnd(&strm);
- return Z_OK;
-}
-
-/* Decompress from file source to file dest until stream ends or EOF.
- inf() returns Z_OK on success, Z_MEM_ERROR if memory could not be
- allocated for processing, Z_DATA_ERROR if the deflate data is
- invalid or incomplete, Z_VERSION_ERROR if the version of zlib.h and
- the version of the library linked do not match, or Z_ERRNO if there
- is an error reading or writing the files. */
-int inf(FILE *source, FILE *dest)
-{
- int ret;
- unsigned have;
- z_stream strm;
- char in[CHUNK];
- char out[CHUNK];
-
- /* allocate inflate state */
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- strm.opaque = Z_NULL;
- strm.avail_in = 0;
- strm.next_in = Z_NULL;
- ret = inflateInit(&strm);
- if (ret != Z_OK)
- return ret;
-
- /* decompress until deflate stream ends or end of file */
- do {
- strm.avail_in = fread(in, 1, CHUNK, source);
- if (ferror(source)) {
- (void)inflateEnd(&strm);
- return Z_ERRNO;
- }
- if (strm.avail_in == 0)
- break;
- strm.next_in = in;
-
- /* run inflate() on input until output buffer not full */
- do {
- strm.avail_out = CHUNK;
- strm.next_out = out;
- ret = inflate(&strm, Z_NO_FLUSH);
- assert(ret != Z_STREAM_ERROR); /* state not clobbered */
- switch (ret) {
- case Z_NEED_DICT:
- ret = Z_DATA_ERROR; /* and fall through */
- case Z_DATA_ERROR:
- case Z_MEM_ERROR:
- (void)inflateEnd(&strm);
- return ret;
- }
- have = CHUNK - strm.avail_out;
- if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
- (void)inflateEnd(&strm);
- return Z_ERRNO;
- }
- } while (strm.avail_out == 0);
-
- /* done when inflate() says it's done */
- } while (ret != Z_STREAM_END);
-
- /* clean up and return */
- (void)inflateEnd(&strm);
- return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
-}
-
-/* report a zlib or i/o error */
-void zerr(int ret)
-{
- fputs("zpipe: ", stderr);
- switch (ret) {
- case Z_ERRNO:
- if (ferror(stdin))
- fputs("error reading stdin\n", stderr);
- if (ferror(stdout))
- fputs("error writing stdout\n", stderr);
- break;
- case Z_STREAM_ERROR:
- fputs("invalid compression level\n", stderr);
- break;
- case Z_DATA_ERROR:
- fputs("invalid or incomplete deflate data\n", stderr);
- break;
- case Z_MEM_ERROR:
- fputs("out of memory\n", stderr);
- break;
- case Z_VERSION_ERROR:
- fputs("zlib version mismatch!\n", stderr);
- }
-}
-
-/* compress or decompress from stdin to stdout */
-int main(int argc, char **argv)
-{
- int ret;
-
- /* do compression if no arguments */
- if (argc == 1) {
- ret = def(stdin, stdout, Z_DEFAULT_COMPRESSION);
- if (ret != Z_OK)
- zerr(ret);
- return ret;
- }
-
- /* do decompression if -d specified */
- else if (argc == 2 && strcmp(argv[1], "-d") == 0) {
- ret = inf(stdin, stdout);
- if (ret != Z_OK)
- zerr(ret);
- return ret;
- }
-
- /* otherwise, report usage */
- else {
- fputs("zpipe usage: zpipe [-d] < source > dest\n", stderr);
- return 1;
- }
-}
diff --git a/source4/lib/zlib/examples/zran.c b/source4/lib/zlib/examples/zran.c
deleted file mode 100644
index 8c7717eb2c..0000000000
--- a/source4/lib/zlib/examples/zran.c
+++ /dev/null
@@ -1,404 +0,0 @@
-/* zran.c -- example of zlib/gzip stream indexing and random access
- * Copyright (C) 2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- Version 1.0 29 May 2005 Mark Adler */
-
-/* Illustrate the use of Z_BLOCK, inflatePrime(), and inflateSetDictionary()
- for random access of a compressed file. A file containing a zlib or gzip
- stream is provided on the command line. The compressed stream is decoded in
- its entirety, and an index built with access points about every SPAN bytes
- in the uncompressed output. The compressed file is left open, and can then
- be read randomly, having to decompress on the average SPAN/2 uncompressed
- bytes before getting to the desired block of data.
-
- An access point can be created at the start of any deflate block, by saving
- the starting file offset and bit of that block, and the 32K bytes of
- uncompressed data that precede that block. Also the uncompressed offset of
- that block is saved to provide a referece for locating a desired starting
- point in the uncompressed stream. build_index() works by decompressing the
- input zlib or gzip stream a block at a time, and at the end of each block
- deciding if enough uncompressed data has gone by to justify the creation of
- a new access point. If so, that point is saved in a data structure that
- grows as needed to accommodate the points.
-
- To use the index, an offset in the uncompressed data is provided, for which
- the latest accees point at or preceding that offset is located in the index.
- The input file is positioned to the specified location in the index, and if
- necessary the first few bits of the compressed data is read from the file.
- inflate is initialized with those bits and the 32K of uncompressed data, and
- the decompression then proceeds until the desired offset in the file is
- reached. Then the decompression continues to read the desired uncompressed
- data from the file.
-
- Another approach would be to generate the index on demand. In that case,
- requests for random access reads from the compressed data would try to use
- the index, but if a read far enough past the end of the index is required,
- then further index entries would be generated and added.
-
- There is some fair bit of overhead to starting inflation for the random
- access, mainly copying the 32K byte dictionary. So if small pieces of the
- file are being accessed, it would make sense to implement a cache to hold
- some lookahead and avoid many calls to extract() for small lengths.
-
- Another way to build an index would be to use inflateCopy(). That would
- not be constrained to have access points at block boundaries, but requires
- more memory per access point, and also cannot be saved to file due to the
- use of pointers in the state. The approach here allows for storage of the
- index in a file.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "zlib.h"
-
-#define local static
-
-#define SPAN 1048576L /* desired distance between access points */
-#define WINSIZE 32768U /* sliding window size */
-#define CHUNK 16384 /* file input buffer size */
-
-/* access point entry */
-struct point {
- off_t out; /* corresponding offset in uncompressed data */
- off_t in; /* offset in input file of first full byte */
- int bits; /* number of bits (1-7) from byte at in - 1, or 0 */
- unsigned char window[WINSIZE]; /* preceding 32K of uncompressed data */
-};
-
-/* access point list */
-struct access {
- int have; /* number of list entries filled in */
- int size; /* number of list entries allocated */
- struct point *list; /* allocated list */
-};
-
-/* Deallocate an index built by build_index() */
-local void free_index(struct access *index)
-{
- if (index != NULL) {
- free(index->list);
- free(index);
- }
-}
-
-/* Add an entry to the access point list. If out of memory, deallocate the
- existing list and return NULL. */
-local struct access *addpoint(struct access *index, int bits,
- off_t in, off_t out, unsigned left, unsigned char *window)
-{
- struct point *next;
-
- /* if list is empty, create it (start with eight points) */
- if (index == NULL) {
- index = malloc(sizeof(struct access));
- if (index == NULL) return NULL;
- index->list = malloc(sizeof(struct point) << 3);
- if (index->list == NULL) {
- free(index);
- return NULL;
- }
- index->size = 8;
- index->have = 0;
- }
-
- /* if list is full, make it bigger */
- else if (index->have == index->size) {
- index->size <<= 1;
- next = realloc(index->list, sizeof(struct point) * index->size);
- if (next == NULL) {
- free_index(index);
- return NULL;
- }
- index->list = next;
- }
-
- /* fill in entry and increment how many we have */
- next = index->list + index->have;
- next->bits = bits;
- next->in = in;
- next->out = out;
- if (left)
- memcpy(next->window, window + WINSIZE - left, left);
- if (left < WINSIZE)
- memcpy(next->window + left, window, WINSIZE - left);
- index->have++;
-
- /* return list, possibly reallocated */
- return index;
-}
-
-/* Make one entire pass through the compressed stream and build an index, with
- access points about every span bytes of uncompressed output -- span is
- chosen to balance the speed of random access against the memory requirements
- of the list, about 32K bytes per access point. Note that data after the end
- of the first zlib or gzip stream in the file is ignored. build_index()
- returns the number of access points on success (>= 1), Z_MEM_ERROR for out
- of memory, Z_DATA_ERROR for an error in the input file, or Z_ERRNO for a
- file read error. On success, *built points to the resulting index. */
-local int build_index(FILE *in, off_t span, struct access **built)
-{
- int ret;
- off_t totin, totout; /* our own total counters to avoid 4GB limit */
- off_t last; /* totout value of last access point */
- struct access *index; /* access points being generated */
- z_stream strm;
- unsigned char input[CHUNK];
- unsigned char window[WINSIZE];
-
- /* initialize inflate */
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- strm.opaque = Z_NULL;
- strm.avail_in = 0;
- strm.next_in = Z_NULL;
- ret = inflateInit2(&strm, 47); /* automatic zlib or gzip decoding */
- if (ret != Z_OK)
- return ret;
-
- /* inflate the input, maintain a sliding window, and build an index -- this
- also validates the integrity of the compressed data using the check
- information at the end of the gzip or zlib stream */
- totin = totout = last = 0;
- index = NULL; /* will be allocated by first addpoint() */
- strm.avail_out = 0;
- do {
- /* get some compressed data from input file */
- strm.avail_in = fread(input, 1, CHUNK, in);
- if (ferror(in)) {
- ret = Z_ERRNO;
- goto build_index_error;
- }
- if (strm.avail_in == 0) {
- ret = Z_DATA_ERROR;
- goto build_index_error;
- }
- strm.next_in = input;
-
- /* process all of that, or until end of stream */
- do {
- /* reset sliding window if necessary */
- if (strm.avail_out == 0) {
- strm.avail_out = WINSIZE;
- strm.next_out = window;
- }
-
- /* inflate until out of input, output, or at end of block --
- update the total input and output counters */
- totin += strm.avail_in;
- totout += strm.avail_out;
- ret = inflate(&strm, Z_BLOCK); /* return at end of block */
- totin -= strm.avail_in;
- totout -= strm.avail_out;
- if (ret == Z_NEED_DICT)
- ret = Z_DATA_ERROR;
- if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR)
- goto build_index_error;
- if (ret == Z_STREAM_END)
- break;
-
- /* if at end of block, consider adding an index entry (note that if
- data_type indicates an end-of-block, then all of the
- uncompressed data from that block has been delivered, and none
- of the compressed data after that block has been consumed,
- except for up to seven bits) -- the totout == 0 provides an
- entry point after the zlib or gzip header, and assures that the
- index always has at least one access point; we avoid creating an
- access point after the last block by checking bit 6 of data_type
- */
- if ((strm.data_type & 128) && !(strm.data_type & 64) &&
- (totout == 0 || totout - last > span)) {
- index = addpoint(index, strm.data_type & 7, totin,
- totout, strm.avail_out, window);
- if (index == NULL) {
- ret = Z_MEM_ERROR;
- goto build_index_error;
- }
- last = totout;
- }
- } while (strm.avail_in != 0);
- } while (ret != Z_STREAM_END);
-
- /* clean up and return index (release unused entries in list) */
- (void)inflateEnd(&strm);
- index = realloc(index, sizeof(struct point) * index->have);
- index->size = index->have;
- *built = index;
- return index->size;
-
- /* return error */
- build_index_error:
- (void)inflateEnd(&strm);
- if (index != NULL)
- free_index(index);
- return ret;
-}
-
-/* Use the index to read len bytes from offset into buf, return bytes read or
- negative for error (Z_DATA_ERROR or Z_MEM_ERROR). If data is requested past
- the end of the uncompressed data, then extract() will return a value less
- than len, indicating how much as actually read into buf. This function
- should not return a data error unless the file was modified since the index
- was generated. extract() may also return Z_ERRNO if there is an error on
- reading or seeking the input file. */
-local int extract(FILE *in, struct access *index, off_t offset,
- unsigned char *buf, int len)
-{
- int ret, skip;
- z_stream strm;
- struct point *here;
- unsigned char input[CHUNK];
- unsigned char discard[WINSIZE];
-
- /* proceed only if something reasonable to do */
- if (len < 0)
- return 0;
-
- /* find where in stream to start */
- here = index->list;
- ret = index->have;
- while (--ret && here[1].out <= offset)
- here++;
-
- /* initialize file and inflate state to start there */
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- strm.opaque = Z_NULL;
- strm.avail_in = 0;
- strm.next_in = Z_NULL;
- ret = inflateInit2(&strm, -15); /* raw inflate */
- if (ret != Z_OK)
- return ret;
- ret = fseeko(in, here->in - (here->bits ? 1 : 0), SEEK_SET);
- if (ret == -1)
- goto extract_ret;
- if (here->bits) {
- ret = getc(in);
- if (ret == -1) {
- ret = ferror(in) ? Z_ERRNO : Z_DATA_ERROR;
- goto extract_ret;
- }
- (void)inflatePrime(&strm, here->bits, ret >> (8 - here->bits));
- }
- (void)inflateSetDictionary(&strm, here->window, WINSIZE);
-
- /* skip uncompressed bytes until offset reached, then satisfy request */
- offset -= here->out;
- strm.avail_in = 0;
- skip = 1; /* while skipping to offset */
- do {
- /* define where to put uncompressed data, and how much */
- if (offset == 0 && skip) { /* at offset now */
- strm.avail_out = len;
- strm.next_out = buf;
- skip = 0; /* only do this once */
- }
- if (offset > WINSIZE) { /* skip WINSIZE bytes */
- strm.avail_out = WINSIZE;
- strm.next_out = discard;
- offset -= WINSIZE;
- }
- else if (offset != 0) { /* last skip */
- strm.avail_out = (unsigned)offset;
- strm.next_out = discard;
- offset = 0;
- }
-
- /* uncompress until avail_out filled, or end of stream */
- do {
- if (strm.avail_in == 0) {
- strm.avail_in = fread(input, 1, CHUNK, in);
- if (ferror(in)) {
- ret = Z_ERRNO;
- goto extract_ret;
- }
- if (strm.avail_in == 0) {
- ret = Z_DATA_ERROR;
- goto extract_ret;
- }
- strm.next_in = input;
- }
- ret = inflate(&strm, Z_NO_FLUSH); /* normal inflate */
- if (ret == Z_NEED_DICT)
- ret = Z_DATA_ERROR;
- if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR)
- goto extract_ret;
- if (ret == Z_STREAM_END)
- break;
- } while (strm.avail_out != 0);
-
- /* if reach end of stream, then don't keep trying to get more */
- if (ret == Z_STREAM_END)
- break;
-
- /* do until offset reached and requested data read, or stream ends */
- } while (skip);
-
- /* compute number of uncompressed bytes read after offset */
- ret = skip ? 0 : len - strm.avail_out;
-
- /* clean up and return bytes read or error */
- extract_ret:
- (void)inflateEnd(&strm);
- return ret;
-}
-
-/* Demonstrate the use of build_index() and extract() by processing the file
- provided on the command line, and the extracting 16K from about 2/3rds of
- the way through the uncompressed output, and writing that to stdout. */
-int main(int argc, char **argv)
-{
- int len;
- off_t offset;
- FILE *in;
- struct access *index;
- unsigned char buf[CHUNK];
-
- /* open input file */
- if (argc != 2) {
- fprintf(stderr, "usage: zran file.gz\n");
- return 1;
- }
- in = fopen(argv[1], "rb");
- if (in == NULL) {
- fprintf(stderr, "zran: could not open %s for reading\n", argv[1]);
- return 1;
- }
-
- /* build index */
- len = build_index(in, SPAN, &index);
- if (len < 0) {
- fclose(in);
- switch (len) {
- case Z_MEM_ERROR:
- fprintf(stderr, "zran: out of memory\n");
- break;
- case Z_DATA_ERROR:
- fprintf(stderr, "zran: compressed data error in %s\n", argv[1]);
- break;
- case Z_ERRNO:
- fprintf(stderr, "zran: read error on %s\n", argv[1]);
- break;
- default:
- fprintf(stderr, "zran: error %d while building index\n", len);
- }
- return 1;
- }
- fprintf(stderr, "zran: built index with %d access points\n", len);
-
- /* use index by reading some bytes from an arbitrary offset */
- offset = (index->list[index->have - 1].out << 1) / 3;
- len = extract(in, index, offset, buf, CHUNK);
- if (len < 0)
- fprintf(stderr, "zran: extraction failed: %s error\n",
- len == Z_MEM_ERROR ? "out of memory" : "input corrupted");
- else {
- fwrite(buf, 1, len, stdout);
- fprintf(stderr, "zran: extracted %d bytes at %llu\n", len, offset);
- }
-
- /* clean up and exit */
- free_index(index);
- fclose(in);
- return 0;
-}
diff --git a/source4/lib/zlib/gzio.c b/source4/lib/zlib/gzio.c
deleted file mode 100644
index 0b51297936..0000000000
--- a/source4/lib/zlib/gzio.c
+++ /dev/null
@@ -1,1024 +0,0 @@
-/* gzio.c -- IO on .gz files
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- *
- * Compile this file with -DNO_GZCOMPRESS to avoid the compression code.
- */
-
-/* @(#) $Id$ */
-
-#include "zutil.h"
-
-#ifdef NO_DEFLATE /* for compatibility with old definition */
-# define NO_GZCOMPRESS
-#endif
-
-#ifndef NO_DUMMY_DECL
-struct internal_state {int dummy;}; /* for buggy compilers */
-#endif
-
-#ifndef Z_BUFSIZE
-# ifdef MAXSEG_64K
-# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */
-# else
-# define Z_BUFSIZE 16384
-# endif
-#endif
-#ifndef Z_PRINTF_BUFSIZE
-# define Z_PRINTF_BUFSIZE 4096
-#endif
-
-#ifdef __MVS__
-# pragma map (fdopen , "\174\174FDOPEN")
- FILE *fdopen(int, const char *);
-#endif
-
-#ifndef STDC
-extern voidp malloc OF((uInt size));
-extern void free OF((voidpf ptr));
-#endif
-
-#define ALLOC(size) malloc(size)
-#define TRYFREE(p) {if (p) free(p);}
-
-static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
-
-/* gzip flag byte */
-/*#define ASCII_FLAG 0x01 *//* bit 0 set: file probably ascii text */
-#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
-#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
-#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
-#define COMMENT 0x10 /* bit 4 set: file comment present */
-#define RESERVED 0xE0 /* bits 5..7: reserved */
-
-typedef struct gz_stream {
- z_stream stream;
- int z_err; /* error code for last stream operation */
- int z_eof; /* set if end of input file */
- FILE *file; /* .gz file */
- Byte *inbuf; /* input buffer */
- Byte *outbuf; /* output buffer */
- uLong crc; /* crc32 of uncompressed data */
- char *msg; /* error message */
- char *path; /* path name for debugging only */
- int transparent; /* 1 if input file is not a .gz file */
- char mode; /* 'w' or 'r' */
- z_off_t start; /* start of compressed data in file (header skipped) */
- z_off_t in; /* bytes into deflate or inflate */
- z_off_t out; /* bytes out of deflate or inflate */
- int back; /* one character push-back */
- int last; /* true if push-back is last character */
-} gz_stream;
-
-
-local gzFile gz_open OF((const char *path, const char *mode, int fd));
-local int do_flush OF((gzFile file, int flush));
-local int get_byte OF((gz_stream *s));
-local void check_header OF((gz_stream *s));
-local int destroy OF((gz_stream *s));
-local void putLong OF((FILE *file, uLong x));
-local uLong getLong OF((gz_stream *s));
-
-/* ===========================================================================
- Opens a gzip (.gz) file for reading or writing. The mode parameter
- is as in fopen ("rb" or "wb"). The file is given either by file descriptor
- or path name (if fd == -1).
- gz_open returns NULL if the file could not be opened or if there was
- insufficient memory to allocate the (de)compression state; errno
- can be checked to distinguish the two cases (if errno is zero, the
- zlib error is Z_MEM_ERROR).
-*/
-local gzFile gz_open (path, mode, fd)
- const char *path;
- const char *mode;
- int fd;
-{
- int err;
- int level = Z_DEFAULT_COMPRESSION; /* compression level */
- int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */
- const char *p = mode;
- gz_stream *s;
- char fmode[80]; /* copy of mode, without the compression level */
- char *m = fmode;
-
- if (!path || !mode) return Z_NULL;
-
- s = (gz_stream *)ALLOC(sizeof(gz_stream));
- if (!s) return Z_NULL;
-
- s->stream.zalloc = (alloc_func)0;
- s->stream.zfree = (free_func)0;
- s->stream.opaque = (voidpf)0;
- s->stream.next_in = s->inbuf = Z_NULL;
- s->stream.next_out = s->outbuf = Z_NULL;
- s->stream.avail_in = s->stream.avail_out = 0;
- s->file = NULL;
- s->z_err = Z_OK;
- s->z_eof = 0;
- s->in = 0;
- s->out = 0;
- s->back = EOF;
- s->crc = crc32(0L, Z_NULL, 0);
- s->msg = NULL;
- s->transparent = 0;
-
- s->path = (char*)ALLOC(strlen(path)+1);
- if (s->path == NULL) {
- return destroy(s), (gzFile)Z_NULL;
- }
- strcpy(s->path, path); /* do this early for debugging */
-
- s->mode = '\0';
- do {
- if (*p == 'r') s->mode = 'r';
- if (*p == 'w' || *p == 'a') s->mode = 'w';
- if (*p >= '0' && *p <= '9') {
- level = *p - '0';
- } else if (*p == 'f') {
- strategy = Z_FILTERED;
- } else if (*p == 'h') {
- strategy = Z_HUFFMAN_ONLY;
- } else if (*p == 'R') {
- strategy = Z_RLE;
- } else {
- *m++ = *p; /* copy the mode */
- }
- } while (*p++ && m != fmode + sizeof(fmode));
- if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL;
-
- if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
- err = Z_STREAM_ERROR;
-#else
- err = deflateInit2(&(s->stream), level,
- Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy);
- /* windowBits is passed < 0 to suppress zlib header */
-
- s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
-#endif
- if (err != Z_OK || s->outbuf == Z_NULL) {
- return destroy(s), (gzFile)Z_NULL;
- }
- } else {
- s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE);
-
- err = inflateInit2(&(s->stream), -MAX_WBITS);
- /* windowBits is passed < 0 to tell that there is no zlib header.
- * Note that in this case inflate *requires* an extra "dummy" byte
- * after the compressed stream in order to complete decompression and
- * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are
- * present after the compressed stream.
- */
- if (err != Z_OK || s->inbuf == Z_NULL) {
- return destroy(s), (gzFile)Z_NULL;
- }
- }
- s->stream.avail_out = Z_BUFSIZE;
-
- errno = 0;
- s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);
-
- if (s->file == NULL) {
- return destroy(s), (gzFile)Z_NULL;
- }
- if (s->mode == 'w') {
- /* Write a very simple .gz header:
- */
- fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
- Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE);
- s->start = 10L;
- /* We use 10L instead of ftell(s->file) to because ftell causes an
- * fflush on some systems. This version of the library doesn't use
- * start anyway in write mode, so this initialization is not
- * necessary.
- */
- } else {
- check_header(s); /* skip the .gz header */
- s->start = ftell(s->file) - s->stream.avail_in;
- }
-
- return (gzFile)s;
-}
-
-/* ===========================================================================
- Opens a gzip (.gz) file for reading or writing.
-*/
-gzFile ZEXPORT gzopen (path, mode)
- const char *path;
- const char *mode;
-{
- return gz_open (path, mode, -1);
-}
-
-/* ===========================================================================
- Associate a gzFile with the file descriptor fd. fd is not dup'ed here
- to mimic the behavio(u)r of fdopen.
-*/
-gzFile ZEXPORT gzdopen (fd, mode)
- int fd;
- const char *mode;
-{
- char name[46]; /* allow for up to 128-bit integers */
-
- if (fd < 0) return (gzFile)Z_NULL;
- sprintf(name, "<fd:%d>", fd); /* for debugging */
-
- return gz_open (name, mode, fd);
-}
-
-/* ===========================================================================
- * Update the compression level and strategy
- */
-int ZEXPORT gzsetparams (file, level, strategy)
- gzFile file;
- int level;
- int strategy;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
-
- /* Make room to allow flushing */
- if (s->stream.avail_out == 0) {
-
- s->stream.next_out = s->outbuf;
- if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
- s->z_err = Z_ERRNO;
- }
- s->stream.avail_out = Z_BUFSIZE;
- }
-
- return deflateParams (&(s->stream), level, strategy);
-}
-
-/* ===========================================================================
- Read a byte from a gz_stream; update next_in and avail_in. Return EOF
- for end of file.
- IN assertion: the stream s has been sucessfully opened for reading.
-*/
-local int get_byte(s)
- gz_stream *s;
-{
- if (s->z_eof) return EOF;
- if (s->stream.avail_in == 0) {
- errno = 0;
- s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
- if (s->stream.avail_in == 0) {
- s->z_eof = 1;
- if (ferror(s->file)) s->z_err = Z_ERRNO;
- return EOF;
- }
- s->stream.next_in = s->inbuf;
- }
- s->stream.avail_in--;
- return *(s->stream.next_in)++;
-}
-
-/* ===========================================================================
- Check the gzip header of a gz_stream opened for reading. Set the stream
- mode to transparent if the gzip magic header is not present; set s->err
- to Z_DATA_ERROR if the magic header is present but the rest of the header
- is incorrect.
- IN assertion: the stream s has already been created sucessfully;
- s->stream.avail_in is zero for the first time, but may be non-zero
- for concatenated .gz files.
-*/
-local void check_header(s)
- gz_stream *s;
-{
- int method; /* method byte */
- int flags; /* flags byte */
- uInt len;
- int c;
-
- /* Assure two bytes in the buffer so we can peek ahead -- handle case
- where first byte of header is at the end of the buffer after the last
- gzip segment */
- len = s->stream.avail_in;
- if (len < 2) {
- if (len) s->inbuf[0] = s->stream.next_in[0];
- errno = 0;
- len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
- if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO;
- s->stream.avail_in += len;
- s->stream.next_in = s->inbuf;
- if (s->stream.avail_in < 2) {
- s->transparent = s->stream.avail_in;
- return;
- }
- }
-
- /* Peek ahead to check the gzip magic header */
- if (s->stream.next_in[0] != gz_magic[0] ||
- s->stream.next_in[1] != gz_magic[1]) {
- s->transparent = 1;
- return;
- }
- s->stream.avail_in -= 2;
- s->stream.next_in += 2;
-
- /* Check the rest of the gzip header */
- method = get_byte(s);
- flags = get_byte(s);
- if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
- s->z_err = Z_DATA_ERROR;
- return;
- }
-
- /* Discard time, xflags and OS code: */
- for (len = 0; len < 6; len++) (void)get_byte(s);
-
- if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
- len = (uInt)get_byte(s);
- len += ((uInt)get_byte(s))<<8;
- /* len is garbage if EOF but the loop below will quit anyway */
- while (len-- != 0 && get_byte(s) != EOF) ;
- }
- if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
- while ((c = get_byte(s)) != 0 && c != EOF) ;
- }
- if ((flags & COMMENT) != 0) { /* skip the .gz file comment */
- while ((c = get_byte(s)) != 0 && c != EOF) ;
- }
- if ((flags & HEAD_CRC) != 0) { /* skip the header crc */
- for (len = 0; len < 2; len++) (void)get_byte(s);
- }
- s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
-}
-
- /* ===========================================================================
- * Cleanup then free the given gz_stream. Return a zlib error code.
- Try freeing in the reverse order of allocations.
- */
-local int destroy (s)
- gz_stream *s;
-{
- int err = Z_OK;
-
- if (!s) return Z_STREAM_ERROR;
-
- TRYFREE(s->msg);
-
- if (s->stream.state != NULL) {
- if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
- err = Z_STREAM_ERROR;
-#else
- err = deflateEnd(&(s->stream));
-#endif
- } else if (s->mode == 'r') {
- err = inflateEnd(&(s->stream));
- }
- }
- if (s->file != NULL && fclose(s->file)) {
-#ifdef ESPIPE
- if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */
-#endif
- err = Z_ERRNO;
- }
- if (s->z_err < 0) err = s->z_err;
-
- TRYFREE(s->inbuf);
- TRYFREE(s->outbuf);
- TRYFREE(s->path);
- TRYFREE(s);
- return err;
-}
-
-/* ===========================================================================
- Reads the given number of uncompressed bytes from the compressed file.
- gzread returns the number of bytes actually read (0 for end of file).
-*/
-int ZEXPORT gzread (file, buf, len)
- gzFile file;
- voidp buf;
- unsigned len;
-{
- gz_stream *s = (gz_stream*)file;
- Bytef *start = (Bytef*)buf; /* starting point for crc computation */
- Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */
-
- if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR;
-
- if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1;
- if (s->z_err == Z_STREAM_END) return 0; /* EOF */
-
- next_out = (Byte*)buf;
- s->stream.next_out = (Bytef*)buf;
- s->stream.avail_out = len;
-
- if (s->stream.avail_out && s->back != EOF) {
- *next_out++ = s->back;
- s->stream.next_out++;
- s->stream.avail_out--;
- s->back = EOF;
- s->out++;
- start++;
- if (s->last) {
- s->z_err = Z_STREAM_END;
- return 1;
- }
- }
-
- while (s->stream.avail_out != 0) {
-
- if (s->transparent) {
- /* Copy first the lookahead bytes: */
- uInt n = s->stream.avail_in;
- if (n > s->stream.avail_out) n = s->stream.avail_out;
- if (n > 0) {
- zmemcpy(s->stream.next_out, s->stream.next_in, n);
- next_out += n;
- s->stream.next_out = next_out;
- s->stream.next_in += n;
- s->stream.avail_out -= n;
- s->stream.avail_in -= n;
- }
- if (s->stream.avail_out > 0) {
- s->stream.avail_out -=
- (uInt)fread(next_out, 1, s->stream.avail_out, s->file);
- }
- len -= s->stream.avail_out;
- s->in += len;
- s->out += len;
- if (len == 0) s->z_eof = 1;
- return (int)len;
- }
- if (s->stream.avail_in == 0 && !s->z_eof) {
-
- errno = 0;
- s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
- if (s->stream.avail_in == 0) {
- s->z_eof = 1;
- if (ferror(s->file)) {
- s->z_err = Z_ERRNO;
- break;
- }
- }
- s->stream.next_in = s->inbuf;
- }
- s->in += s->stream.avail_in;
- s->out += s->stream.avail_out;
- s->z_err = inflate(&(s->stream), Z_NO_FLUSH);
- s->in -= s->stream.avail_in;
- s->out -= s->stream.avail_out;
-
- if (s->z_err == Z_STREAM_END) {
- /* Check CRC and original size */
- s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
- start = s->stream.next_out;
-
- if (getLong(s) != s->crc) {
- s->z_err = Z_DATA_ERROR;
- } else {
- (void)getLong(s);
- /* The uncompressed length returned by above getlong() may be
- * different from s->out in case of concatenated .gz files.
- * Check for such files:
- */
- check_header(s);
- if (s->z_err == Z_OK) {
- inflateReset(&(s->stream));
- s->crc = crc32(0L, Z_NULL, 0);
- }
- }
- }
- if (s->z_err != Z_OK || s->z_eof) break;
- }
- s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
-
- if (len == s->stream.avail_out &&
- (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO))
- return -1;
- return (int)(len - s->stream.avail_out);
-}
-
-
-/* ===========================================================================
- Reads one byte from the compressed file. gzgetc returns this byte
- or -1 in case of end of file or error.
-*/
-int ZEXPORT gzgetc(file)
- gzFile file;
-{
- unsigned char c;
-
- return gzread(file, &c, 1) == 1 ? c : -1;
-}
-
-
-/* ===========================================================================
- Push one byte back onto the stream.
-*/
-int ZEXPORT gzungetc(c, file)
- int c;
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF;
- s->back = c;
- s->out--;
- s->last = (s->z_err == Z_STREAM_END);
- if (s->last) s->z_err = Z_OK;
- s->z_eof = 0;
- return c;
-}
-
-
-/* ===========================================================================
- Reads bytes from the compressed file until len-1 characters are
- read, or a newline character is read and transferred to buf, or an
- end-of-file condition is encountered. The string is then terminated
- with a null character.
- gzgets returns buf, or Z_NULL in case of error.
-
- The current implementation is not optimized at all.
-*/
-char * ZEXPORT gzgets(file, buf, len)
- gzFile file;
- char *buf;
- int len;
-{
- char *b = buf;
- if (buf == Z_NULL || len <= 0) return Z_NULL;
-
- while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ;
- *buf = '\0';
- return b == buf && len > 0 ? Z_NULL : b;
-}
-
-
-#ifndef NO_GZCOMPRESS
-/* ===========================================================================
- Writes the given number of uncompressed bytes into the compressed file.
- gzwrite returns the number of bytes actually written (0 in case of error).
-*/
-int ZEXPORT gzwrite (file, buf, len)
- gzFile file;
- voidpc buf;
- unsigned len;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
-
- s->stream.next_in = (const Bytef*)buf;
- s->stream.avail_in = len;
-
- while (s->stream.avail_in != 0) {
-
- if (s->stream.avail_out == 0) {
-
- s->stream.next_out = s->outbuf;
- if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
- s->z_err = Z_ERRNO;
- break;
- }
- s->stream.avail_out = Z_BUFSIZE;
- }
- s->in += s->stream.avail_in;
- s->out += s->stream.avail_out;
- s->z_err = deflate(&(s->stream), Z_NO_FLUSH);
- s->in -= s->stream.avail_in;
- s->out -= s->stream.avail_out;
- if (s->z_err != Z_OK) break;
- }
- s->crc = crc32(s->crc, (const Bytef *)buf, len);
-
- return (int)(len - s->stream.avail_in);
-}
-
-
-/* ===========================================================================
- Converts, formats, and writes the args to the compressed file under
- control of the format string, as in fprintf. gzprintf returns the number of
- uncompressed bytes actually written (0 in case of error).
-*/
-#ifdef STDC
-#include <stdarg.h>
-
-int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
-{
- char buf[Z_PRINTF_BUFSIZE];
- va_list va;
- int len;
-
- buf[sizeof(buf) - 1] = 0;
- va_start(va, format);
-#ifdef NO_vsnprintf
-# ifdef HAS_vsprintf_void
- (void)vsprintf(buf, format, va);
- va_end(va);
- for (len = 0; len < sizeof(buf); len++)
- if (buf[len] == 0) break;
-# else
- len = vsprintf(buf, format, va);
- va_end(va);
-# endif
-#else
-# ifdef HAS_vsnprintf_void
- (void)vsnprintf(buf, sizeof(buf), format, va);
- va_end(va);
- len = strlen(buf);
-# else
- len = vsnprintf(buf, sizeof(buf), format, va);
- va_end(va);
-# endif
-#endif
- if (len <= 0 || len >= (int)sizeof(buf) || buf[sizeof(buf) - 1] != 0)
- return 0;
- return gzwrite(file, buf, (unsigned)len);
-}
-#else /* not ANSI C */
-
-int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
- a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
- gzFile file;
- const char *format;
- int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
- a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
-{
- char buf[Z_PRINTF_BUFSIZE];
- int len;
-
- buf[sizeof(buf) - 1] = 0;
-#ifdef NO_snprintf
-# ifdef HAS_sprintf_void
- sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
- for (len = 0; len < sizeof(buf); len++)
- if (buf[len] == 0) break;
-# else
- len = sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
-# endif
-#else
-# ifdef HAS_snprintf_void
- snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
- len = strlen(buf);
-# else
- len = snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
-# endif
-#endif
- if (len <= 0 || len >= sizeof(buf) || buf[sizeof(buf) - 1] != 0)
- return 0;
- return gzwrite(file, buf, len);
-}
-#endif
-
-/* ===========================================================================
- Writes c, converted to an unsigned char, into the compressed file.
- gzputc returns the value that was written, or -1 in case of error.
-*/
-int ZEXPORT gzputc(file, c)
- gzFile file;
- int c;
-{
- unsigned char cc = (unsigned char) c; /* required for big endian systems */
-
- return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1;
-}
-
-
-/* ===========================================================================
- Writes the given null-terminated string to the compressed file, excluding
- the terminating null character.
- gzputs returns the number of characters written, or -1 in case of error.
-*/
-int ZEXPORT gzputs(file, s)
- gzFile file;
- const char *s;
-{
- return gzwrite(file, (voidpc)s, (unsigned)strlen(s));
-}
-
-
-/* ===========================================================================
- Flushes all pending output into the compressed file. The parameter
- flush is as in the deflate() function.
-*/
-local int do_flush (file, flush)
- gzFile file;
- int flush;
-{
- uInt len;
- int done = 0;
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
-
- s->stream.avail_in = 0; /* should be zero already anyway */
-
- for (;;) {
- len = Z_BUFSIZE - s->stream.avail_out;
-
- if (len != 0) {
- if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) {
- s->z_err = Z_ERRNO;
- return Z_ERRNO;
- }
- s->stream.next_out = s->outbuf;
- s->stream.avail_out = Z_BUFSIZE;
- }
- if (done) break;
- s->out += s->stream.avail_out;
- s->z_err = deflate(&(s->stream), flush);
- s->out -= s->stream.avail_out;
-
- /* Ignore the second of two consecutive flushes: */
- if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK;
-
- /* deflate has finished flushing only when it hasn't used up
- * all the available space in the output buffer:
- */
- done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END);
-
- if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break;
- }
- return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
-}
-
-int ZEXPORT gzflush (file, flush)
- gzFile file;
- int flush;
-{
- gz_stream *s = (gz_stream*)file;
- int err = do_flush (file, flush);
-
- if (err) return err;
- fflush(s->file);
- return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
-}
-#endif /* NO_GZCOMPRESS */
-
-/* ===========================================================================
- Sets the starting position for the next gzread or gzwrite on the given
- compressed file. The offset represents a number of bytes in the
- gzseek returns the resulting offset location as measured in bytes from
- the beginning of the uncompressed stream, or -1 in case of error.
- SEEK_END is not implemented, returns error.
- In this version of the library, gzseek can be extremely slow.
-*/
-z_off_t ZEXPORT gzseek (file, offset, whence)
- gzFile file;
- z_off_t offset;
- int whence;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || whence == SEEK_END ||
- s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) {
- return -1L;
- }
-
- if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
- return -1L;
-#else
- if (whence == SEEK_SET) {
- offset -= s->in;
- }
- if (offset < 0) return -1L;
-
- /* At this point, offset is the number of zero bytes to write. */
- if (s->inbuf == Z_NULL) {
- s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */
- if (s->inbuf == Z_NULL) return -1L;
- zmemzero(s->inbuf, Z_BUFSIZE);
- }
- while (offset > 0) {
- uInt size = Z_BUFSIZE;
- if (offset < Z_BUFSIZE) size = (uInt)offset;
-
- size = gzwrite(file, s->inbuf, size);
- if (size == 0) return -1L;
-
- offset -= size;
- }
- return s->in;
-#endif
- }
- /* Rest of function is for reading only */
-
- /* compute absolute position */
- if (whence == SEEK_CUR) {
- offset += s->out;
- }
- if (offset < 0) return -1L;
-
- if (s->transparent) {
- /* map to fseek */
- s->back = EOF;
- s->stream.avail_in = 0;
- s->stream.next_in = s->inbuf;
- if (fseek(s->file, offset, SEEK_SET) < 0) return -1L;
-
- s->in = s->out = offset;
- return offset;
- }
-
- /* For a negative seek, rewind and use positive seek */
- if (offset >= s->out) {
- offset -= s->out;
- } else if (gzrewind(file) < 0) {
- return -1L;
- }
- /* offset is now the number of bytes to skip. */
-
- if (offset != 0 && s->outbuf == Z_NULL) {
- s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
- if (s->outbuf == Z_NULL) return -1L;
- }
- if (offset && s->back != EOF) {
- s->back = EOF;
- s->out++;
- offset--;
- if (s->last) s->z_err = Z_STREAM_END;
- }
- while (offset > 0) {
- int size = Z_BUFSIZE;
- if (offset < Z_BUFSIZE) size = (int)offset;
-
- size = gzread(file, s->outbuf, (uInt)size);
- if (size <= 0) return -1L;
- offset -= size;
- }
- return s->out;
-}
-
-/* ===========================================================================
- Rewinds input file.
-*/
-int ZEXPORT gzrewind (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'r') return -1;
-
- s->z_err = Z_OK;
- s->z_eof = 0;
- s->back = EOF;
- s->stream.avail_in = 0;
- s->stream.next_in = s->inbuf;
- s->crc = crc32(0L, Z_NULL, 0);
- if (!s->transparent) (void)inflateReset(&s->stream);
- s->in = 0;
- s->out = 0;
- return fseek(s->file, s->start, SEEK_SET);
-}
-
-/* ===========================================================================
- Returns the starting position for the next gzread or gzwrite on the
- given compressed file. This position represents a number of bytes in the
- uncompressed data stream.
-*/
-z_off_t ZEXPORT gztell (file)
- gzFile file;
-{
- return gzseek(file, 0L, SEEK_CUR);
-}
-
-/* ===========================================================================
- Returns 1 when EOF has previously been detected reading the given
- input stream, otherwise zero.
-*/
-int ZEXPORT gzeof (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- /* With concatenated compressed files that can have embedded
- * crc trailers, z_eof is no longer the only/best indicator of EOF
- * on a gz_stream. Handle end-of-stream error explicitly here.
- */
- if (s == NULL || s->mode != 'r') return 0;
- if (s->z_eof) return 1;
- return s->z_err == Z_STREAM_END;
-}
-
-/* ===========================================================================
- Returns 1 if reading and doing so transparently, otherwise zero.
-*/
-int ZEXPORT gzdirect (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'r') return 0;
- return s->transparent;
-}
-
-/* ===========================================================================
- Outputs a long in LSB order to the given file
-*/
-local void putLong (file, x)
- FILE *file;
- uLong x;
-{
- int n;
- for (n = 0; n < 4; n++) {
- fputc((int)(x & 0xff), file);
- x >>= 8;
- }
-}
-
-/* ===========================================================================
- Reads a long in LSB order from the given gz_stream. Sets z_err in case
- of error.
-*/
-local uLong getLong (s)
- gz_stream *s;
-{
- uLong x = (uLong)get_byte(s);
- int c;
-
- x += ((uLong)get_byte(s))<<8;
- x += ((uLong)get_byte(s))<<16;
- c = get_byte(s);
- if (c == EOF) s->z_err = Z_DATA_ERROR;
- x += ((uLong)c)<<24;
- return x;
-}
-
-/* ===========================================================================
- Flushes all pending output if necessary, closes the compressed file
- and deallocates all the (de)compression state.
-*/
-int ZEXPORT gzclose (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL) return Z_STREAM_ERROR;
-
- if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
- return Z_STREAM_ERROR;
-#else
- if (do_flush (file, Z_FINISH) != Z_OK)
- return destroy((gz_stream*)file);
-
- putLong (s->file, s->crc);
- putLong (s->file, (uLong)(s->in & 0xffffffff));
-#endif
- }
- return destroy((gz_stream*)file);
-}
-
-#ifdef STDC
-# define zstrerror(errnum) strerror(errnum)
-#else
-# define zstrerror(errnum) ""
-#endif
-
-/* ===========================================================================
- Returns the error message for the last error which occurred on the
- given compressed file. errnum is set to zlib error number. If an
- error occurred in the file system and not in the compression library,
- errnum is set to Z_ERRNO and the application may consult errno
- to get the exact error code.
-*/
-const char * ZEXPORT gzerror (file, errnum)
- gzFile file;
- int *errnum;
-{
- const char *m;
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL) {
- *errnum = Z_STREAM_ERROR;
- return (const char*)ERR_MSG(Z_STREAM_ERROR);
- }
- *errnum = s->z_err;
- if (*errnum == Z_OK) return (const char*)"";
-
- m = (*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
-
- if (m == NULL || *m == '\0') m = ERR_MSG(s->z_err);
-
- TRYFREE(s->msg);
- s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3);
- if (s->msg == Z_NULL) return (const char*)ERR_MSG(Z_MEM_ERROR);
- strcpy(s->msg, s->path);
- strcat(s->msg, ": ");
- strcat(s->msg, m);
- return (const char*)s->msg;
-}
-
-/* ===========================================================================
- Clear the error and end-of-file flags, and do the same for the real file.
-*/
-void ZEXPORT gzclearerr (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL) return;
- if (s->z_err != Z_STREAM_END) s->z_err = Z_OK;
- s->z_eof = 0;
- clearerr(s->file);
-}
diff --git a/source4/lib/zlib/infback.c b/source4/lib/zlib/infback.c
deleted file mode 100644
index 5680937f34..0000000000
--- a/source4/lib/zlib/infback.c
+++ /dev/null
@@ -1,623 +0,0 @@
-/* infback.c -- inflate using a call-back interface
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- This code is largely copied from inflate.c. Normally either infback.o or
- inflate.o would be linked into an application--not both. The interface
- with inffast.c is retained so that optimized assembler-coded versions of
- inflate_fast() can be used with either inflate.c or infback.c.
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-/* function prototypes */
-local void fixedtables OF((struct inflate_state FAR *state));
-
-/*
- strm provides memory allocation functions in zalloc and zfree, or
- Z_NULL to use the library memory allocation functions.
-
- windowBits is in the range 8..15, and window is a user-supplied
- window and output buffer that is 2**windowBits bytes.
- */
-int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
-z_streamp strm;
-int windowBits;
-unsigned char FAR *window;
-const char *version;
-int stream_size;
-{
- struct inflate_state FAR *state;
-
- if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
- stream_size != (int)(sizeof(z_stream)))
- return Z_VERSION_ERROR;
- if (strm == Z_NULL || window == Z_NULL ||
- windowBits < 8 || windowBits > 15)
- return Z_STREAM_ERROR;
- strm->msg = Z_NULL; /* in case we return an error */
- if (strm->zalloc == (alloc_func)0) {
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
- }
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
- state = (struct inflate_state FAR *)ZALLOC(strm, 1,
- sizeof(struct inflate_state));
- if (state == Z_NULL) return Z_MEM_ERROR;
- Tracev((stderr, "inflate: allocated\n"));
- strm->state = (struct internal_state FAR *)state;
- state->dmax = 32768U;
- state->wbits = windowBits;
- state->wsize = 1U << windowBits;
- state->window = window;
- state->write = 0;
- state->whave = 0;
- return Z_OK;
-}
-
-/*
- Return state with length and distance decoding tables and index sizes set to
- fixed code decoding. Normally this returns fixed tables from inffixed.h.
- If BUILDFIXED is defined, then instead this routine builds the tables the
- first time it's called, and returns those tables the first time and
- thereafter. This reduces the size of the code by about 2K bytes, in
- exchange for a little execution time. However, BUILDFIXED should not be
- used for threaded applications, since the rewriting of the tables and virgin
- may not be thread-safe.
- */
-local void fixedtables(state)
-struct inflate_state FAR *state;
-{
-#ifdef BUILDFIXED
- static int virgin = 1;
- static code *lenfix, *distfix;
- static code fixed[544];
-
- /* build fixed huffman tables if first call (may not be thread safe) */
- if (virgin) {
- unsigned sym, bits;
- static code *next;
-
- /* literal/length table */
- sym = 0;
- while (sym < 144) state->lens[sym++] = 8;
- while (sym < 256) state->lens[sym++] = 9;
- while (sym < 280) state->lens[sym++] = 7;
- while (sym < 288) state->lens[sym++] = 8;
- next = fixed;
- lenfix = next;
- bits = 9;
- inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
-
- /* distance table */
- sym = 0;
- while (sym < 32) state->lens[sym++] = 5;
- distfix = next;
- bits = 5;
- inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
-
- /* do this just once */
- virgin = 0;
- }
-#else /* !BUILDFIXED */
-# include "inffixed.h"
-#endif /* BUILDFIXED */
- state->lencode = lenfix;
- state->lenbits = 9;
- state->distcode = distfix;
- state->distbits = 5;
-}
-
-/* Macros for inflateBack(): */
-
-/* Load returned state from inflate_fast() */
-#define LOAD() \
- do { \
- put = strm->next_out; \
- left = strm->avail_out; \
- next = strm->next_in; \
- have = strm->avail_in; \
- hold = state->hold; \
- bits = state->bits; \
- } while (0)
-
-/* Set state from registers for inflate_fast() */
-#define RESTORE() \
- do { \
- strm->next_out = put; \
- strm->avail_out = left; \
- strm->next_in = next; \
- strm->avail_in = have; \
- state->hold = hold; \
- state->bits = bits; \
- } while (0)
-
-/* Clear the input bit accumulator */
-#define INITBITS() \
- do { \
- hold = 0; \
- bits = 0; \
- } while (0)
-
-/* Assure that some input is available. If input is requested, but denied,
- then return a Z_BUF_ERROR from inflateBack(). */
-#define PULL() \
- do { \
- if (have == 0) { \
- have = in(in_desc, &next); \
- if (have == 0) { \
- next = Z_NULL; \
- ret = Z_BUF_ERROR; \
- goto inf_leave; \
- } \
- } \
- } while (0)
-
-/* Get a byte of input into the bit accumulator, or return from inflateBack()
- with an error if there is no input available. */
-#define PULLBYTE() \
- do { \
- PULL(); \
- have--; \
- hold += (unsigned long)(*next++) << bits; \
- bits += 8; \
- } while (0)
-
-/* Assure that there are at least n bits in the bit accumulator. If there is
- not enough available input to do that, then return from inflateBack() with
- an error. */
-#define NEEDBITS(n) \
- do { \
- while (bits < (unsigned)(n)) \
- PULLBYTE(); \
- } while (0)
-
-/* Return the low n bits of the bit accumulator (n < 16) */
-#define BITS(n) \
- ((unsigned)hold & ((1U << (n)) - 1))
-
-/* Remove n bits from the bit accumulator */
-#define DROPBITS(n) \
- do { \
- hold >>= (n); \
- bits -= (unsigned)(n); \
- } while (0)
-
-/* Remove zero to seven bits as needed to go to a byte boundary */
-#define BYTEBITS() \
- do { \
- hold >>= bits & 7; \
- bits -= bits & 7; \
- } while (0)
-
-/* Assure that some output space is available, by writing out the window
- if it's full. If the write fails, return from inflateBack() with a
- Z_BUF_ERROR. */
-#define ROOM() \
- do { \
- if (left == 0) { \
- put = state->window; \
- left = state->wsize; \
- state->whave = left; \
- if (out(out_desc, put, left)) { \
- ret = Z_BUF_ERROR; \
- goto inf_leave; \
- } \
- } \
- } while (0)
-
-/*
- strm provides the memory allocation functions and window buffer on input,
- and provides information on the unused input on return. For Z_DATA_ERROR
- returns, strm will also provide an error message.
-
- in() and out() are the call-back input and output functions. When
- inflateBack() needs more input, it calls in(). When inflateBack() has
- filled the window with output, or when it completes with data in the
- window, it calls out() to write out the data. The application must not
- change the provided input until in() is called again or inflateBack()
- returns. The application must not change the window/output buffer until
- inflateBack() returns.
-
- in() and out() are called with a descriptor parameter provided in the
- inflateBack() call. This parameter can be a structure that provides the
- information required to do the read or write, as well as accumulated
- information on the input and output such as totals and check values.
-
- in() should return zero on failure. out() should return non-zero on
- failure. If either in() or out() fails, than inflateBack() returns a
- Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it
- was in() or out() that caused in the error. Otherwise, inflateBack()
- returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format
- error, or Z_MEM_ERROR if it could not allocate memory for the state.
- inflateBack() can also return Z_STREAM_ERROR if the input parameters
- are not correct, i.e. strm is Z_NULL or the state was not initialized.
- */
-int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
-z_streamp strm;
-in_func in;
-void FAR *in_desc;
-out_func out;
-void FAR *out_desc;
-{
- struct inflate_state FAR *state;
- unsigned const char FAR *next; /* next input */
- unsigned char FAR *put; /* next output */
- unsigned have, left; /* available input and output */
- unsigned long hold; /* bit buffer */
- unsigned bits; /* bits in bit buffer */
- unsigned copy; /* number of stored or match bytes to copy */
- unsigned char FAR *from; /* where to copy match bytes from */
- code this; /* current decoding table entry */
- code last; /* parent table entry */
- unsigned len; /* length to copy for repeats, bits to drop */
- int ret; /* return code */
- static const unsigned short order[19] = /* permutation of code lengths */
- {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
- /* Check that the strm exists and that the state was initialized */
- if (strm == Z_NULL || strm->state == Z_NULL)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
-
- /* Reset the state */
- strm->msg = Z_NULL;
- state->mode = TYPE;
- state->last = 0;
- state->whave = 0;
- next = strm->next_in;
- have = next != Z_NULL ? strm->avail_in : 0;
- hold = 0;
- bits = 0;
- put = state->window;
- left = state->wsize;
-
- /* Inflate until end of block marked as last */
- for (;;)
- switch (state->mode) {
- case TYPE:
- /* determine and dispatch block type */
- if (state->last) {
- BYTEBITS();
- state->mode = DONE;
- break;
- }
- NEEDBITS(3);
- state->last = BITS(1);
- DROPBITS(1);
- switch (BITS(2)) {
- case 0: /* stored block */
- Tracev((stderr, "inflate: stored block%s\n",
- state->last ? " (last)" : ""));
- state->mode = STORED;
- break;
- case 1: /* fixed block */
- fixedtables(state);
- Tracev((stderr, "inflate: fixed codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = LEN; /* decode codes */
- break;
- case 2: /* dynamic block */
- Tracev((stderr, "inflate: dynamic codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = TABLE;
- break;
- case 3:
- strm->msg = "invalid block type";
- state->mode = BAD;
- }
- DROPBITS(2);
- break;
-
- case STORED:
- /* get and verify stored block length */
- BYTEBITS(); /* go to byte boundary */
- NEEDBITS(32);
- if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
- strm->msg = "invalid stored block lengths";
- state->mode = BAD;
- break;
- }
- state->length = (unsigned)hold & 0xffff;
- Tracev((stderr, "inflate: stored length %u\n",
- state->length));
- INITBITS();
-
- /* copy stored block from input to output */
- while (state->length != 0) {
- copy = state->length;
- PULL();
- ROOM();
- if (copy > have) copy = have;
- if (copy > left) copy = left;
- zmemcpy(put, next, copy);
- have -= copy;
- next += copy;
- left -= copy;
- put += copy;
- state->length -= copy;
- }
- Tracev((stderr, "inflate: stored end\n"));
- state->mode = TYPE;
- break;
-
- case TABLE:
- /* get dynamic table entries descriptor */
- NEEDBITS(14);
- state->nlen = BITS(5) + 257;
- DROPBITS(5);
- state->ndist = BITS(5) + 1;
- DROPBITS(5);
- state->ncode = BITS(4) + 4;
- DROPBITS(4);
-#ifndef PKZIP_BUG_WORKAROUND
- if (state->nlen > 286 || state->ndist > 30) {
- strm->msg = "too many length or distance symbols";
- state->mode = BAD;
- break;
- }
-#endif
- Tracev((stderr, "inflate: table sizes ok\n"));
-
- /* get code length code lengths (not a typo) */
- state->have = 0;
- while (state->have < state->ncode) {
- NEEDBITS(3);
- state->lens[order[state->have++]] = (unsigned short)BITS(3);
- DROPBITS(3);
- }
- while (state->have < 19)
- state->lens[order[state->have++]] = 0;
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 7;
- ret = inflate_table(CODES, state->lens, 19, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = "invalid code lengths set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: code lengths ok\n"));
-
- /* get length and distance code code lengths */
- state->have = 0;
- while (state->have < state->nlen + state->ndist) {
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.val < 16) {
- NEEDBITS(this.bits);
- DROPBITS(this.bits);
- state->lens[state->have++] = this.val;
- }
- else {
- if (this.val == 16) {
- NEEDBITS(this.bits + 2);
- DROPBITS(this.bits);
- if (state->have == 0) {
- strm->msg = "invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- len = (unsigned)(state->lens[state->have - 1]);
- copy = 3 + BITS(2);
- DROPBITS(2);
- }
- else if (this.val == 17) {
- NEEDBITS(this.bits + 3);
- DROPBITS(this.bits);
- len = 0;
- copy = 3 + BITS(3);
- DROPBITS(3);
- }
- else {
- NEEDBITS(this.bits + 7);
- DROPBITS(this.bits);
- len = 0;
- copy = 11 + BITS(7);
- DROPBITS(7);
- }
- if (state->have + copy > state->nlen + state->ndist) {
- strm->msg = "invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- while (copy--)
- state->lens[state->have++] = (unsigned short)len;
- }
- }
-
- /* handle error breaks in while */
- if (state->mode == BAD) break;
-
- /* build code tables */
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 9;
- ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = "invalid literal/lengths set";
- state->mode = BAD;
- break;
- }
- state->distcode = (code const FAR *)(state->next);
- state->distbits = 6;
- ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
- &(state->next), &(state->distbits), state->work);
- if (ret) {
- strm->msg = "invalid distances set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: codes ok\n"));
- state->mode = LEN;
-
- case LEN:
- /* use inflate_fast() if we have enough input and output */
- if (have >= 6 && left >= 258) {
- RESTORE();
- if (state->whave < state->wsize)
- state->whave = state->wsize - left;
- inflate_fast(strm, state->wsize);
- LOAD();
- break;
- }
-
- /* get a literal, length, or end-of-block code */
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.op && (this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->lencode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- state->length = (unsigned)this.val;
-
- /* process literal */
- if (this.op == 0) {
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- ROOM();
- *put++ = (unsigned char)(state->length);
- left--;
- state->mode = LEN;
- break;
- }
-
- /* process end of block */
- if (this.op & 32) {
- Tracevv((stderr, "inflate: end of block\n"));
- state->mode = TYPE;
- break;
- }
-
- /* invalid code */
- if (this.op & 64) {
- strm->msg = "invalid literal/length code";
- state->mode = BAD;
- break;
- }
-
- /* length code -- get extra bits, if any */
- state->extra = (unsigned)(this.op) & 15;
- if (state->extra != 0) {
- NEEDBITS(state->extra);
- state->length += BITS(state->extra);
- DROPBITS(state->extra);
- }
- Tracevv((stderr, "inflate: length %u\n", state->length));
-
- /* get distance code */
- for (;;) {
- this = state->distcode[BITS(state->distbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if ((this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->distcode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- if (this.op & 64) {
- strm->msg = "invalid distance code";
- state->mode = BAD;
- break;
- }
- state->offset = (unsigned)this.val;
-
- /* get distance extra bits, if any */
- state->extra = (unsigned)(this.op) & 15;
- if (state->extra != 0) {
- NEEDBITS(state->extra);
- state->offset += BITS(state->extra);
- DROPBITS(state->extra);
- }
- if (state->offset > state->wsize - (state->whave < state->wsize ?
- left : 0)) {
- strm->msg = "invalid distance too far back";
- state->mode = BAD;
- break;
- }
- Tracevv((stderr, "inflate: distance %u\n", state->offset));
-
- /* copy match from window to output */
- do {
- ROOM();
- copy = state->wsize - state->offset;
- if (copy < left) {
- from = put + copy;
- copy = left - copy;
- }
- else {
- from = put - state->offset;
- copy = left;
- }
- if (copy > state->length) copy = state->length;
- state->length -= copy;
- left -= copy;
- do {
- *put++ = *from++;
- } while (--copy);
- } while (state->length != 0);
- break;
-
- case DONE:
- /* inflate stream terminated properly -- write leftover output */
- ret = Z_STREAM_END;
- if (left < state->wsize) {
- if (out(out_desc, state->window, state->wsize - left))
- ret = Z_BUF_ERROR;
- }
- goto inf_leave;
-
- case BAD:
- ret = Z_DATA_ERROR;
- goto inf_leave;
-
- default: /* can't happen, but makes compilers happy */
- ret = Z_STREAM_ERROR;
- goto inf_leave;
- }
-
- /* Return unused input */
- inf_leave:
- strm->next_in = next;
- strm->avail_in = have;
- return ret;
-}
-
-int ZEXPORT inflateBackEnd(strm)
-z_streamp strm;
-{
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
- Tracev((stderr, "inflate: end\n"));
- return Z_OK;
-}
diff --git a/source4/lib/zlib/inffast.c b/source4/lib/zlib/inffast.c
deleted file mode 100644
index bfc727694a..0000000000
--- a/source4/lib/zlib/inffast.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/* inffast.c -- fast decoding
- * Copyright (C) 1995-2004 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-#ifndef ASMINF
-
-/* Allow machine dependent optimization for post-increment or pre-increment.
- Based on testing to date,
- Pre-increment preferred for:
- - PowerPC G3 (Adler)
- - MIPS R5000 (Randers-Pehrson)
- Post-increment preferred for:
- - none
- No measurable difference:
- - Pentium III (Anderson)
- - M68060 (Nikl)
- */
-#ifdef POSTINC
-# define OFF 0
-# define PUP(a) *(a)++
-#else
-# define OFF 1
-# define PUP(a) *++(a)
-#endif
-
-/*
- Decode literal, length, and distance codes and write out the resulting
- literal and match bytes until either not enough input or output is
- available, an end-of-block is encountered, or a data error is encountered.
- When large enough input and output buffers are supplied to inflate(), for
- example, a 16K input buffer and a 64K output buffer, more than 95% of the
- inflate execution time is spent in this routine.
-
- Entry assumptions:
-
- state->mode == LEN
- strm->avail_in >= 6
- strm->avail_out >= 258
- start >= strm->avail_out
- state->bits < 8
-
- On return, state->mode is one of:
-
- LEN -- ran out of enough output space or enough available input
- TYPE -- reached end of block code, inflate() to interpret next block
- BAD -- error in block data
-
- Notes:
-
- - The maximum input bits used by a length/distance pair is 15 bits for the
- length code, 5 bits for the length extra, 15 bits for the distance code,
- and 13 bits for the distance extra. This totals 48 bits, or six bytes.
- Therefore if strm->avail_in >= 6, then there is enough input to avoid
- checking for available input while decoding.
-
- - The maximum bytes that a single length/distance pair can output is 258
- bytes, which is the maximum length that can be coded. inflate_fast()
- requires strm->avail_out >= 258 for each loop to avoid checking for
- output space.
- */
-void inflate_fast(strm, start)
-z_streamp strm;
-unsigned start; /* inflate()'s starting value for strm->avail_out */
-{
- struct inflate_state FAR *state;
- unsigned const char FAR *in; /* local strm->next_in */
- unsigned const char FAR *last; /* while in < last, enough input available */
- unsigned char FAR *out; /* local strm->next_out */
- unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
- unsigned char FAR *end; /* while out < end, enough space available */
-#ifdef INFLATE_STRICT
- unsigned dmax; /* maximum distance from zlib header */
-#endif
- unsigned wsize; /* window size or zero if not using window */
- unsigned whave; /* valid bytes in the window */
- unsigned write; /* window write index */
- unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
- unsigned long hold; /* local strm->hold */
- unsigned bits; /* local strm->bits */
- code const FAR *lcode; /* local strm->lencode */
- code const FAR *dcode; /* local strm->distcode */
- unsigned lmask; /* mask for first level of length codes */
- unsigned dmask; /* mask for first level of distance codes */
- code this; /* retrieved table entry */
- unsigned op; /* code bits, operation, extra bits, or */
- /* window position, window bytes to copy */
- unsigned len; /* match length, unused bytes */
- unsigned dist; /* match distance */
- unsigned char FAR *from; /* where to copy match from */
-
- /* copy state to local variables */
- state = (struct inflate_state FAR *)strm->state;
- in = strm->next_in - OFF;
- last = in + (strm->avail_in - 5);
- out = strm->next_out - OFF;
- beg = out - (start - strm->avail_out);
- end = out + (strm->avail_out - 257);
-#ifdef INFLATE_STRICT
- dmax = state->dmax;
-#endif
- wsize = state->wsize;
- whave = state->whave;
- write = state->write;
- window = state->window;
- hold = state->hold;
- bits = state->bits;
- lcode = state->lencode;
- dcode = state->distcode;
- lmask = (1U << state->lenbits) - 1;
- dmask = (1U << state->distbits) - 1;
-
- /* decode literals and length/distances until end-of-block or not enough
- input data or output space */
- do {
- if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- this = lcode[hold & lmask];
- dolen:
- op = (unsigned)(this.bits);
- hold >>= op;
- bits -= op;
- op = (unsigned)(this.op);
- if (op == 0) { /* literal */
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- PUP(out) = (unsigned char)(this.val);
- }
- else if (op & 16) { /* length base */
- len = (unsigned)(this.val);
- op &= 15; /* number of extra bits */
- if (op) {
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- len += (unsigned)hold & ((1U << op) - 1);
- hold >>= op;
- bits -= op;
- }
- Tracevv((stderr, "inflate: length %u\n", len));
- if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- this = dcode[hold & dmask];
- dodist:
- op = (unsigned)(this.bits);
- hold >>= op;
- bits -= op;
- op = (unsigned)(this.op);
- if (op & 16) { /* distance base */
- dist = (unsigned)(this.val);
- op &= 15; /* number of extra bits */
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- }
- dist += (unsigned)hold & ((1U << op) - 1);
-#ifdef INFLATE_STRICT
- if (dist > dmax) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
-#endif
- hold >>= op;
- bits -= op;
- Tracevv((stderr, "inflate: distance %u\n", dist));
- op = (unsigned)(out - beg); /* max distance in output */
- if (dist > op) { /* see if copy from window */
- op = dist - op; /* distance back in window */
- if (op > whave) {
- strm->msg = "invalid distance too far back";
- state->mode = BAD;
- break;
- }
- from = window - OFF;
- if (write == 0) { /* very common case */
- from += wsize - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- else if (write < op) { /* wrap around window */
- from += wsize + write - op;
- op -= write;
- if (op < len) { /* some from end of window */
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = window - OFF;
- if (write < len) { /* some from start of window */
- op = write;
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- }
- else { /* contiguous in window */
- from += write - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- while (len > 2) {
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- len -= 3;
- }
- if (len) {
- PUP(out) = PUP(from);
- if (len > 1)
- PUP(out) = PUP(from);
- }
- }
- else {
- from = out - dist; /* copy direct from output */
- do { /* minimum length is three */
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- len -= 3;
- } while (len > 2);
- if (len) {
- PUP(out) = PUP(from);
- if (len > 1)
- PUP(out) = PUP(from);
- }
- }
- }
- else if ((op & 64) == 0) { /* 2nd level distance code */
- this = dcode[this.val + (hold & ((1U << op) - 1))];
- goto dodist;
- }
- else {
- strm->msg = "invalid distance code";
- state->mode = BAD;
- break;
- }
- }
- else if ((op & 64) == 0) { /* 2nd level length code */
- this = lcode[this.val + (hold & ((1U << op) - 1))];
- goto dolen;
- }
- else if (op & 32) { /* end-of-block */
- Tracevv((stderr, "inflate: end of block\n"));
- state->mode = TYPE;
- break;
- }
- else {
- strm->msg = "invalid literal/length code";
- state->mode = BAD;
- break;
- }
- } while (in < last && out < end);
-
- /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
- len = bits >> 3;
- in -= len;
- bits -= len << 3;
- hold &= (1U << bits) - 1;
-
- /* update state and return */
- strm->next_in = in + OFF;
- strm->next_out = out + OFF;
- strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
- strm->avail_out = (unsigned)(out < end ?
- 257 + (end - out) : 257 - (out - end));
- state->hold = hold;
- state->bits = bits;
- return;
-}
-
-/*
- inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
- - Using bit fields for code structure
- - Different op definition to avoid & for extra bits (do & for table bits)
- - Three separate decoding do-loops for direct, window, and write == 0
- - Special case for distance > 1 copies to do overlapped load and store copy
- - Explicit branch predictions (based on measured branch probabilities)
- - Deferring match copy and interspersed it with decoding subsequent codes
- - Swapping literal/length else
- - Swapping window/direct else
- - Larger unrolled copy loops (three is about right)
- - Moving len -= 3 statement into middle of loop
- */
-
-#endif /* !ASMINF */
diff --git a/source4/lib/zlib/inffast.h b/source4/lib/zlib/inffast.h
deleted file mode 100644
index 1e88d2d97b..0000000000
--- a/source4/lib/zlib/inffast.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* inffast.h -- header to use inffast.c
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-void inflate_fast OF((z_streamp strm, unsigned start));
diff --git a/source4/lib/zlib/inffixed.h b/source4/lib/zlib/inffixed.h
deleted file mode 100644
index 75ed4b5978..0000000000
--- a/source4/lib/zlib/inffixed.h
+++ /dev/null
@@ -1,94 +0,0 @@
- /* inffixed.h -- table for decoding fixed codes
- * Generated automatically by makefixed().
- */
-
- /* WARNING: this file should *not* be used by applications. It
- is part of the implementation of the compression library and
- is subject to change. Applications should only use zlib.h.
- */
-
- static const code lenfix[512] = {
- {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
- {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
- {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
- {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
- {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
- {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
- {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
- {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
- {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
- {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
- {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
- {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
- {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
- {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
- {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
- {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
- {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
- {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
- {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
- {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
- {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
- {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
- {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
- {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
- {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
- {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
- {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
- {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
- {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
- {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
- {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
- {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
- {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
- {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
- {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
- {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
- {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
- {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
- {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
- {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
- {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
- {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
- {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
- {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
- {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
- {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
- {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
- {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
- {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
- {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
- {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
- {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
- {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
- {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
- {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
- {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
- {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
- {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
- {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
- {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
- {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
- {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
- {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
- {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
- {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
- {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
- {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
- {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
- {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
- {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
- {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
- {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
- {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
- {0,9,255}
- };
-
- static const code distfix[32] = {
- {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
- {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
- {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
- {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
- {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
- {22,5,193},{64,5,0}
- };
diff --git a/source4/lib/zlib/inflate.c b/source4/lib/zlib/inflate.c
deleted file mode 100644
index ccbfac804d..0000000000
--- a/source4/lib/zlib/inflate.c
+++ /dev/null
@@ -1,1368 +0,0 @@
-/* inflate.c -- zlib decompression
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * Change history:
- *
- * 1.2.beta0 24 Nov 2002
- * - First version -- complete rewrite of inflate to simplify code, avoid
- * creation of window when not needed, minimize use of window when it is
- * needed, make inffast.c even faster, implement gzip decoding, and to
- * improve code readability and style over the previous zlib inflate code
- *
- * 1.2.beta1 25 Nov 2002
- * - Use pointers for available input and output checking in inffast.c
- * - Remove input and output counters in inffast.c
- * - Change inffast.c entry and loop from avail_in >= 7 to >= 6
- * - Remove unnecessary second byte pull from length extra in inffast.c
- * - Unroll direct copy to three copies per loop in inffast.c
- *
- * 1.2.beta2 4 Dec 2002
- * - Change external routine names to reduce potential conflicts
- * - Correct filename to inffixed.h for fixed tables in inflate.c
- * - Make hbuf[] unsigned char to match parameter type in inflate.c
- * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset)
- * to avoid negation problem on Alphas (64 bit) in inflate.c
- *
- * 1.2.beta3 22 Dec 2002
- * - Add comments on state->bits assertion in inffast.c
- * - Add comments on op field in inftrees.h
- * - Fix bug in reuse of allocated window after inflateReset()
- * - Remove bit fields--back to byte structure for speed
- * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths
- * - Change post-increments to pre-increments in inflate_fast(), PPC biased?
- * - Add compile time option, POSTINC, to use post-increments instead (Intel?)
- * - Make MATCH copy in inflate() much faster for when inflate_fast() not used
- * - Use local copies of stream next and avail values, as well as local bit
- * buffer and bit count in inflate()--for speed when inflate_fast() not used
- *
- * 1.2.beta4 1 Jan 2003
- * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings
- * - Move a comment on output buffer sizes from inffast.c to inflate.c
- * - Add comments in inffast.c to introduce the inflate_fast() routine
- * - Rearrange window copies in inflate_fast() for speed and simplification
- * - Unroll last copy for window match in inflate_fast()
- * - Use local copies of window variables in inflate_fast() for speed
- * - Pull out common write == 0 case for speed in inflate_fast()
- * - Make op and len in inflate_fast() unsigned for consistency
- * - Add FAR to lcode and dcode declarations in inflate_fast()
- * - Simplified bad distance check in inflate_fast()
- * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new
- * source file infback.c to provide a call-back interface to inflate for
- * programs like gzip and unzip -- uses window as output buffer to avoid
- * window copying
- *
- * 1.2.beta5 1 Jan 2003
- * - Improved inflateBack() interface to allow the caller to provide initial
- * input in strm.
- * - Fixed stored blocks bug in inflateBack()
- *
- * 1.2.beta6 4 Jan 2003
- * - Added comments in inffast.c on effectiveness of POSTINC
- * - Typecasting all around to reduce compiler warnings
- * - Changed loops from while (1) or do {} while (1) to for (;;), again to
- * make compilers happy
- * - Changed type of window in inflateBackInit() to unsigned char *
- *
- * 1.2.beta7 27 Jan 2003
- * - Changed many types to unsigned or unsigned short to avoid warnings
- * - Added inflateCopy() function
- *
- * 1.2.0 9 Mar 2003
- * - Changed inflateBack() interface to provide separate opaque descriptors
- * for the in() and out() functions
- * - Changed inflateBack() argument and in_func typedef to swap the length
- * and buffer address return values for the input function
- * - Check next_in and next_out for Z_NULL on entry to inflate()
- *
- * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-#ifdef MAKEFIXED
-# ifndef BUILDFIXED
-# define BUILDFIXED
-# endif
-#endif
-
-/* function prototypes */
-local void fixedtables OF((struct inflate_state FAR *state));
-local int updatewindow OF((z_streamp strm, unsigned out));
-#ifdef BUILDFIXED
- void makefixed OF((void));
-#endif
-local unsigned syncsearch OF((unsigned FAR *have, unsigned const char FAR *buf,
- unsigned len));
-
-int ZEXPORT inflateReset(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- strm->total_in = strm->total_out = state->total = 0;
- strm->msg = Z_NULL;
- strm->adler = 1; /* to support ill-conceived Java test suite */
- state->mode = HEAD;
- state->last = 0;
- state->havedict = 0;
- state->dmax = 32768U;
- state->head = Z_NULL;
- state->wsize = 0;
- state->whave = 0;
- state->write = 0;
- state->hold = 0;
- state->bits = 0;
- state->lencode = state->distcode = state->next = state->codes;
- Tracev((stderr, "inflate: reset\n"));
- return Z_OK;
-}
-
-int ZEXPORT inflatePrime(strm, bits, value)
-z_streamp strm;
-int bits;
-int value;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
- value &= (1L << bits) - 1;
- state->hold += value << state->bits;
- state->bits += bits;
- return Z_OK;
-}
-
-int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
-z_streamp strm;
-int windowBits;
-const char *version;
-int stream_size;
-{
- struct inflate_state FAR *state;
-
- if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
- stream_size != (int)(sizeof(z_stream)))
- return Z_VERSION_ERROR;
- if (strm == Z_NULL) return Z_STREAM_ERROR;
- strm->msg = Z_NULL; /* in case we return an error */
- if (strm->zalloc == (alloc_func)0) {
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
- }
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
- state = (struct inflate_state FAR *)
- ZALLOC(strm, 1, sizeof(struct inflate_state));
- if (state == Z_NULL) return Z_MEM_ERROR;
- Tracev((stderr, "inflate: allocated\n"));
- strm->state = (struct internal_state FAR *)state;
- if (windowBits < 0) {
- state->wrap = 0;
- windowBits = -windowBits;
- }
- else {
- state->wrap = (windowBits >> 4) + 1;
-#ifdef GUNZIP
- if (windowBits < 48) windowBits &= 15;
-#endif
- }
- if (windowBits < 8 || windowBits > 15) {
- ZFREE(strm, state);
- strm->state = Z_NULL;
- return Z_STREAM_ERROR;
- }
- state->wbits = (unsigned)windowBits;
- state->window = Z_NULL;
- return inflateReset(strm);
-}
-
-int ZEXPORT inflateInit_(strm, version, stream_size)
-z_streamp strm;
-const char *version;
-int stream_size;
-{
- return inflateInit2_(strm, DEF_WBITS, version, stream_size);
-}
-
-/*
- Return state with length and distance decoding tables and index sizes set to
- fixed code decoding. Normally this returns fixed tables from inffixed.h.
- If BUILDFIXED is defined, then instead this routine builds the tables the
- first time it's called, and returns those tables the first time and
- thereafter. This reduces the size of the code by about 2K bytes, in
- exchange for a little execution time. However, BUILDFIXED should not be
- used for threaded applications, since the rewriting of the tables and virgin
- may not be thread-safe.
- */
-local void fixedtables(state)
-struct inflate_state FAR *state;
-{
-#ifdef BUILDFIXED
- static int virgin = 1;
- static code *lenfix, *distfix;
- static code fixed[544];
-
- /* build fixed huffman tables if first call (may not be thread safe) */
- if (virgin) {
- unsigned sym, bits;
- static code *next;
-
- /* literal/length table */
- sym = 0;
- while (sym < 144) state->lens[sym++] = 8;
- while (sym < 256) state->lens[sym++] = 9;
- while (sym < 280) state->lens[sym++] = 7;
- while (sym < 288) state->lens[sym++] = 8;
- next = fixed;
- lenfix = next;
- bits = 9;
- inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
-
- /* distance table */
- sym = 0;
- while (sym < 32) state->lens[sym++] = 5;
- distfix = next;
- bits = 5;
- inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
-
- /* do this just once */
- virgin = 0;
- }
-#else /* !BUILDFIXED */
-# include "inffixed.h"
-#endif /* BUILDFIXED */
- state->lencode = lenfix;
- state->lenbits = 9;
- state->distcode = distfix;
- state->distbits = 5;
-}
-
-#ifdef MAKEFIXED
-#include <stdio.h>
-
-/*
- Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also
- defines BUILDFIXED, so the tables are built on the fly. makefixed() writes
- those tables to stdout, which would be piped to inffixed.h. A small program
- can simply call makefixed to do this:
-
- void makefixed(void);
-
- int main(void)
- {
- makefixed();
- return 0;
- }
-
- Then that can be linked with zlib built with MAKEFIXED defined and run:
-
- a.out > inffixed.h
- */
-void makefixed()
-{
- unsigned low, size;
- struct inflate_state state;
-
- fixedtables(&state);
- puts(" /* inffixed.h -- table for decoding fixed codes");
- puts(" * Generated automatically by makefixed().");
- puts(" */");
- puts("");
- puts(" /* WARNING: this file should *not* be used by applications.");
- puts(" It is part of the implementation of this library and is");
- puts(" subject to change. Applications should only use zlib.h.");
- puts(" */");
- puts("");
- size = 1U << 9;
- printf(" static const code lenfix[%u] = {", size);
- low = 0;
- for (;;) {
- if ((low % 7) == 0) printf("\n ");
- printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits,
- state.lencode[low].val);
- if (++low == size) break;
- putchar(',');
- }
- puts("\n };");
- size = 1U << 5;
- printf("\n static const code distfix[%u] = {", size);
- low = 0;
- for (;;) {
- if ((low % 6) == 0) printf("\n ");
- printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
- state.distcode[low].val);
- if (++low == size) break;
- putchar(',');
- }
- puts("\n };");
-}
-#endif /* MAKEFIXED */
-
-/*
- Update the window with the last wsize (normally 32K) bytes written before
- returning. If window does not exist yet, create it. This is only called
- when a window is already in use, or when output has been written during this
- inflate call, but the end of the deflate stream has not been reached yet.
- It is also called to create a window for dictionary data when a dictionary
- is loaded.
-
- Providing output buffers larger than 32K to inflate() should provide a speed
- advantage, since only the last 32K of output is copied to the sliding window
- upon return from inflate(), and since all distances after the first 32K of
- output will fall in the output data, making match copies simpler and faster.
- The advantage may be dependent on the size of the processor's data caches.
- */
-local int updatewindow(strm, out)
-z_streamp strm;
-unsigned out;
-{
- struct inflate_state FAR *state;
- unsigned copy, dist;
-
- state = (struct inflate_state FAR *)strm->state;
-
- /* if it hasn't been done already, allocate space for the window */
- if (state->window == Z_NULL) {
- state->window = (unsigned char FAR *)
- ZALLOC(strm, 1U << state->wbits,
- sizeof(unsigned char));
- if (state->window == Z_NULL) return 1;
- }
-
- /* if window not in use yet, initialize */
- if (state->wsize == 0) {
- state->wsize = 1U << state->wbits;
- state->write = 0;
- state->whave = 0;
- }
-
- /* copy state->wsize or less output bytes into the circular window */
- copy = out - strm->avail_out;
- if (copy >= state->wsize) {
- zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
- state->write = 0;
- state->whave = state->wsize;
- }
- else {
- dist = state->wsize - state->write;
- if (dist > copy) dist = copy;
- zmemcpy(state->window + state->write, strm->next_out - copy, dist);
- copy -= dist;
- if (copy) {
- zmemcpy(state->window, strm->next_out - copy, copy);
- state->write = copy;
- state->whave = state->wsize;
- }
- else {
- state->write += dist;
- if (state->write == state->wsize) state->write = 0;
- if (state->whave < state->wsize) state->whave += dist;
- }
- }
- return 0;
-}
-
-/* Macros for inflate(): */
-
-/* check function to use adler32() for zlib or crc32() for gzip */
-#ifdef GUNZIP
-# define UPDATE(check, buf, len) \
- (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
-#else
-# define UPDATE(check, buf, len) adler32(check, buf, len)
-#endif
-
-/* check macros for header crc */
-#ifdef GUNZIP
-# define CRC2(check, word) \
- do { \
- hbuf[0] = (unsigned char)(word); \
- hbuf[1] = (unsigned char)((word) >> 8); \
- check = crc32(check, hbuf, 2); \
- } while (0)
-
-# define CRC4(check, word) \
- do { \
- hbuf[0] = (unsigned char)(word); \
- hbuf[1] = (unsigned char)((word) >> 8); \
- hbuf[2] = (unsigned char)((word) >> 16); \
- hbuf[3] = (unsigned char)((word) >> 24); \
- check = crc32(check, hbuf, 4); \
- } while (0)
-#endif
-
-/* Load registers with state in inflate() for speed */
-#define LOAD() \
- do { \
- put = strm->next_out; \
- left = strm->avail_out; \
- next = strm->next_in; \
- have = strm->avail_in; \
- hold = state->hold; \
- bits = state->bits; \
- } while (0)
-
-/* Restore state from registers in inflate() */
-#define RESTORE() \
- do { \
- strm->next_out = put; \
- strm->avail_out = left; \
- strm->next_in = next; \
- strm->avail_in = have; \
- state->hold = hold; \
- state->bits = bits; \
- } while (0)
-
-/* Clear the input bit accumulator */
-#define INITBITS() \
- do { \
- hold = 0; \
- bits = 0; \
- } while (0)
-
-/* Get a byte of input into the bit accumulator, or return from inflate()
- if there is no input available. */
-#define PULLBYTE() \
- do { \
- if (have == 0) goto inf_leave; \
- have--; \
- hold += (unsigned long)(*next++) << bits; \
- bits += 8; \
- } while (0)
-
-/* Assure that there are at least n bits in the bit accumulator. If there is
- not enough available input to do that, then return from inflate(). */
-#define NEEDBITS(n) \
- do { \
- while (bits < (unsigned)(n)) \
- PULLBYTE(); \
- } while (0)
-
-/* Return the low n bits of the bit accumulator (n < 16) */
-#define BITS(n) \
- ((unsigned)hold & ((1U << (n)) - 1))
-
-/* Remove n bits from the bit accumulator */
-#define DROPBITS(n) \
- do { \
- hold >>= (n); \
- bits -= (unsigned)(n); \
- } while (0)
-
-/* Remove zero to seven bits as needed to go to a byte boundary */
-#define BYTEBITS() \
- do { \
- hold >>= bits & 7; \
- bits -= bits & 7; \
- } while (0)
-
-/* Reverse the bytes in a 32-bit value */
-#define REVERSE(q) \
- ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
- (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
-
-/*
- inflate() uses a state machine to process as much input data and generate as
- much output data as possible before returning. The state machine is
- structured roughly as follows:
-
- for (;;) switch (state) {
- ...
- case STATEn:
- if (not enough input data or output space to make progress)
- return;
- ... make progress ...
- state = STATEm;
- break;
- ...
- }
-
- so when inflate() is called again, the same case is attempted again, and
- if the appropriate resources are provided, the machine proceeds to the
- next state. The NEEDBITS() macro is usually the way the state evaluates
- whether it can proceed or should return. NEEDBITS() does the return if
- the requested bits are not available. The typical use of the BITS macros
- is:
-
- NEEDBITS(n);
- ... do something with BITS(n) ...
- DROPBITS(n);
-
- where NEEDBITS(n) either returns from inflate() if there isn't enough
- input left to load n bits into the accumulator, or it continues. BITS(n)
- gives the low n bits in the accumulator. When done, DROPBITS(n) drops
- the low n bits off the accumulator. INITBITS() clears the accumulator
- and sets the number of available bits to zero. BYTEBITS() discards just
- enough bits to put the accumulator on a byte boundary. After BYTEBITS()
- and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.
-
- NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return
- if there is no input available. The decoding of variable length codes uses
- PULLBYTE() directly in order to pull just enough bytes to decode the next
- code, and no more.
-
- Some states loop until they get enough input, making sure that enough
- state information is maintained to continue the loop where it left off
- if NEEDBITS() returns in the loop. For example, want, need, and keep
- would all have to actually be part of the saved state in case NEEDBITS()
- returns:
-
- case STATEw:
- while (want < need) {
- NEEDBITS(n);
- keep[want++] = BITS(n);
- DROPBITS(n);
- }
- state = STATEx;
- case STATEx:
-
- As shown above, if the next state is also the next case, then the break
- is omitted.
-
- A state may also return if there is not enough output space available to
- complete that state. Those states are copying stored data, writing a
- literal byte, and copying a matching string.
-
- When returning, a "goto inf_leave" is used to update the total counters,
- update the check value, and determine whether any progress has been made
- during that inflate() call in order to return the proper return code.
- Progress is defined as a change in either strm->avail_in or strm->avail_out.
- When there is a window, goto inf_leave will update the window with the last
- output written. If a goto inf_leave occurs in the middle of decompression
- and there is no window currently, goto inf_leave will create one and copy
- output to the window for the next call of inflate().
-
- In this implementation, the flush parameter of inflate() only affects the
- return code (per zlib.h). inflate() always writes as much as possible to
- strm->next_out, given the space available and the provided input--the effect
- documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers
- the allocation of and copying into a sliding window until necessary, which
- provides the effect documented in zlib.h for Z_FINISH when the entire input
- stream available. So the only thing the flush parameter actually does is:
- when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it
- will return Z_BUF_ERROR if it has not reached the end of the stream.
- */
-
-int ZEXPORT inflate(strm, flush)
-z_streamp strm;
-int flush;
-{
- struct inflate_state FAR *state;
- unsigned const char FAR *next; /* next input */
- unsigned char FAR *put; /* next output */
- unsigned have, left; /* available input and output */
- unsigned long hold; /* bit buffer */
- unsigned bits; /* bits in bit buffer */
- unsigned in, out; /* save starting available input and output */
- unsigned copy; /* number of stored or match bytes to copy */
- unsigned char FAR *from; /* where to copy match bytes from */
- code this; /* current decoding table entry */
- code last; /* parent table entry */
- unsigned len; /* length to copy for repeats, bits to drop */
- int ret; /* return code */
-#ifdef GUNZIP
- unsigned char hbuf[4]; /* buffer for gzip header crc calculation */
-#endif
- static const unsigned short order[19] = /* permutation of code lengths */
- {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
- if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
- (strm->next_in == Z_NULL && strm->avail_in != 0))
- return Z_STREAM_ERROR;
-
- state = (struct inflate_state FAR *)strm->state;
- if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */
- LOAD();
- in = have;
- out = left;
- ret = Z_OK;
- for (;;)
- switch (state->mode) {
- case HEAD:
- if (state->wrap == 0) {
- state->mode = TYPEDO;
- break;
- }
- NEEDBITS(16);
-#ifdef GUNZIP
- if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
- state->check = crc32(0L, Z_NULL, 0);
- CRC2(state->check, hold);
- INITBITS();
- state->mode = FLAGS;
- break;
- }
- state->flags = 0; /* expect zlib header */
- if (state->head != Z_NULL)
- state->head->done = -1;
- if (!(state->wrap & 1) || /* check if zlib header allowed */
-#else
- if (
-#endif
- ((BITS(8) << 8) + (hold >> 8)) % 31) {
- strm->msg = "incorrect header check";
- state->mode = BAD;
- break;
- }
- if (BITS(4) != Z_DEFLATED) {
- strm->msg = "unknown compression method";
- state->mode = BAD;
- break;
- }
- DROPBITS(4);
- len = BITS(4) + 8;
- if (len > state->wbits) {
- strm->msg = "invalid window size";
- state->mode = BAD;
- break;
- }
- state->dmax = 1U << len;
- Tracev((stderr, "inflate: zlib header ok\n"));
- strm->adler = state->check = adler32(0L, Z_NULL, 0);
- state->mode = hold & 0x200 ? DICTID : TYPE;
- INITBITS();
- break;
-#ifdef GUNZIP
- case FLAGS:
- NEEDBITS(16);
- state->flags = (int)(hold);
- if ((state->flags & 0xff) != Z_DEFLATED) {
- strm->msg = "unknown compression method";
- state->mode = BAD;
- break;
- }
- if (state->flags & 0xe000) {
- strm->msg = "unknown header flags set";
- state->mode = BAD;
- break;
- }
- if (state->head != Z_NULL)
- state->head->text = (int)((hold >> 8) & 1);
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- state->mode = TIME;
- case TIME:
- NEEDBITS(32);
- if (state->head != Z_NULL)
- state->head->time = hold;
- if (state->flags & 0x0200) CRC4(state->check, hold);
- INITBITS();
- state->mode = OS;
- case OS:
- NEEDBITS(16);
- if (state->head != Z_NULL) {
- state->head->xflags = (int)(hold & 0xff);
- state->head->os = (int)(hold >> 8);
- }
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- state->mode = EXLEN;
- case EXLEN:
- if (state->flags & 0x0400) {
- NEEDBITS(16);
- state->length = (unsigned)(hold);
- if (state->head != Z_NULL)
- state->head->extra_len = (unsigned)hold;
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- }
- else if (state->head != Z_NULL)
- state->head->extra = Z_NULL;
- state->mode = EXTRA;
- case EXTRA:
- if (state->flags & 0x0400) {
- copy = state->length;
- if (copy > have) copy = have;
- if (copy) {
- if (state->head != Z_NULL &&
- state->head->extra != Z_NULL) {
- len = state->head->extra_len - state->length;
- zmemcpy(state->head->extra + len, next,
- len + copy > state->head->extra_max ?
- state->head->extra_max - len : copy);
- }
- if (state->flags & 0x0200)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- state->length -= copy;
- }
- if (state->length) goto inf_leave;
- }
- state->length = 0;
- state->mode = NAME;
- case NAME:
- if (state->flags & 0x0800) {
- if (have == 0) goto inf_leave;
- copy = 0;
- do {
- len = (unsigned)(next[copy++]);
- if (state->head != Z_NULL &&
- state->head->name != Z_NULL &&
- state->length < state->head->name_max)
- state->head->name[state->length++] = len;
- } while (len && copy < have);
- if (state->flags & 0x0200)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- if (len) goto inf_leave;
- }
- else if (state->head != Z_NULL)
- state->head->name = Z_NULL;
- state->length = 0;
- state->mode = COMMENT;
- case COMMENT:
- if (state->flags & 0x1000) {
- if (have == 0) goto inf_leave;
- copy = 0;
- do {
- len = (unsigned)(next[copy++]);
- if (state->head != Z_NULL &&
- state->head->comment != Z_NULL &&
- state->length < state->head->comm_max)
- state->head->comment[state->length++] = len;
- } while (len && copy < have);
- if (state->flags & 0x0200)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- if (len) goto inf_leave;
- }
- else if (state->head != Z_NULL)
- state->head->comment = Z_NULL;
- state->mode = HCRC;
- case HCRC:
- if (state->flags & 0x0200) {
- NEEDBITS(16);
- if (hold != (state->check & 0xffff)) {
- strm->msg = "header crc mismatch";
- state->mode = BAD;
- break;
- }
- INITBITS();
- }
- if (state->head != Z_NULL) {
- state->head->hcrc = (int)((state->flags >> 9) & 1);
- state->head->done = 1;
- }
- strm->adler = state->check = crc32(0L, Z_NULL, 0);
- state->mode = TYPE;
- break;
-#endif
- case DICTID:
- NEEDBITS(32);
- strm->adler = state->check = REVERSE(hold);
- INITBITS();
- state->mode = DICT;
- case DICT:
- if (state->havedict == 0) {
- RESTORE();
- return Z_NEED_DICT;
- }
- strm->adler = state->check = adler32(0L, Z_NULL, 0);
- state->mode = TYPE;
- case TYPE:
- if (flush == Z_BLOCK) goto inf_leave;
- case TYPEDO:
- if (state->last) {
- BYTEBITS();
- state->mode = CHECK;
- break;
- }
- NEEDBITS(3);
- state->last = BITS(1);
- DROPBITS(1);
- switch (BITS(2)) {
- case 0: /* stored block */
- Tracev((stderr, "inflate: stored block%s\n",
- state->last ? " (last)" : ""));
- state->mode = STORED;
- break;
- case 1: /* fixed block */
- fixedtables(state);
- Tracev((stderr, "inflate: fixed codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = LEN; /* decode codes */
- break;
- case 2: /* dynamic block */
- Tracev((stderr, "inflate: dynamic codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = TABLE;
- break;
- case 3:
- strm->msg = "invalid block type";
- state->mode = BAD;
- }
- DROPBITS(2);
- break;
- case STORED:
- BYTEBITS(); /* go to byte boundary */
- NEEDBITS(32);
- if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
- strm->msg = "invalid stored block lengths";
- state->mode = BAD;
- break;
- }
- state->length = (unsigned)hold & 0xffff;
- Tracev((stderr, "inflate: stored length %u\n",
- state->length));
- INITBITS();
- state->mode = COPY;
- case COPY:
- copy = state->length;
- if (copy) {
- if (copy > have) copy = have;
- if (copy > left) copy = left;
- if (copy == 0) goto inf_leave;
- zmemcpy(put, next, copy);
- have -= copy;
- next += copy;
- left -= copy;
- put += copy;
- state->length -= copy;
- break;
- }
- Tracev((stderr, "inflate: stored end\n"));
- state->mode = TYPE;
- break;
- case TABLE:
- NEEDBITS(14);
- state->nlen = BITS(5) + 257;
- DROPBITS(5);
- state->ndist = BITS(5) + 1;
- DROPBITS(5);
- state->ncode = BITS(4) + 4;
- DROPBITS(4);
-#ifndef PKZIP_BUG_WORKAROUND
- if (state->nlen > 286 || state->ndist > 30) {
- strm->msg = "too many length or distance symbols";
- state->mode = BAD;
- break;
- }
-#endif
- Tracev((stderr, "inflate: table sizes ok\n"));
- state->have = 0;
- state->mode = LENLENS;
- case LENLENS:
- while (state->have < state->ncode) {
- NEEDBITS(3);
- state->lens[order[state->have++]] = (unsigned short)BITS(3);
- DROPBITS(3);
- }
- while (state->have < 19)
- state->lens[order[state->have++]] = 0;
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 7;
- ret = inflate_table(CODES, state->lens, 19, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = "invalid code lengths set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: code lengths ok\n"));
- state->have = 0;
- state->mode = CODELENS;
- case CODELENS:
- while (state->have < state->nlen + state->ndist) {
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.val < 16) {
- NEEDBITS(this.bits);
- DROPBITS(this.bits);
- state->lens[state->have++] = this.val;
- }
- else {
- if (this.val == 16) {
- NEEDBITS(this.bits + 2);
- DROPBITS(this.bits);
- if (state->have == 0) {
- strm->msg = "invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- len = state->lens[state->have - 1];
- copy = 3 + BITS(2);
- DROPBITS(2);
- }
- else if (this.val == 17) {
- NEEDBITS(this.bits + 3);
- DROPBITS(this.bits);
- len = 0;
- copy = 3 + BITS(3);
- DROPBITS(3);
- }
- else {
- NEEDBITS(this.bits + 7);
- DROPBITS(this.bits);
- len = 0;
- copy = 11 + BITS(7);
- DROPBITS(7);
- }
- if (state->have + copy > state->nlen + state->ndist) {
- strm->msg = "invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- while (copy--)
- state->lens[state->have++] = (unsigned short)len;
- }
- }
-
- /* handle error breaks in while */
- if (state->mode == BAD) break;
-
- /* build code tables */
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 9;
- ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = "invalid literal/lengths set";
- state->mode = BAD;
- break;
- }
- state->distcode = (code const FAR *)(state->next);
- state->distbits = 6;
- ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
- &(state->next), &(state->distbits), state->work);
- if (ret) {
- strm->msg = "invalid distances set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: codes ok\n"));
- state->mode = LEN;
- case LEN:
- if (have >= 6 && left >= 258) {
- RESTORE();
- inflate_fast(strm, out);
- LOAD();
- break;
- }
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.op && (this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->lencode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- state->length = (unsigned)this.val;
- if ((int)(this.op) == 0) {
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- state->mode = LIT;
- break;
- }
- if (this.op & 32) {
- Tracevv((stderr, "inflate: end of block\n"));
- state->mode = TYPE;
- break;
- }
- if (this.op & 64) {
- strm->msg = "invalid literal/length code";
- state->mode = BAD;
- break;
- }
- state->extra = (unsigned)(this.op) & 15;
- state->mode = LENEXT;
- case LENEXT:
- if (state->extra) {
- NEEDBITS(state->extra);
- state->length += BITS(state->extra);
- DROPBITS(state->extra);
- }
- Tracevv((stderr, "inflate: length %u\n", state->length));
- state->mode = DIST;
- case DIST:
- for (;;) {
- this = state->distcode[BITS(state->distbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if ((this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->distcode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- if (this.op & 64) {
- strm->msg = "invalid distance code";
- state->mode = BAD;
- break;
- }
- state->offset = (unsigned)this.val;
- state->extra = (unsigned)(this.op) & 15;
- state->mode = DISTEXT;
- case DISTEXT:
- if (state->extra) {
- NEEDBITS(state->extra);
- state->offset += BITS(state->extra);
- DROPBITS(state->extra);
- }
-#ifdef INFLATE_STRICT
- if (state->offset > state->dmax) {
- strm->msg = "invalid distance too far back";
- state->mode = BAD;
- break;
- }
-#endif
- if (state->offset > state->whave + out - left) {
- strm->msg = "invalid distance too far back";
- state->mode = BAD;
- break;
- }
- Tracevv((stderr, "inflate: distance %u\n", state->offset));
- state->mode = MATCH;
- case MATCH:
- if (left == 0) goto inf_leave;
- copy = out - left;
- if (state->offset > copy) { /* copy from window */
- copy = state->offset - copy;
- if (copy > state->write) {
- copy -= state->write;
- from = state->window + (state->wsize - copy);
- }
- else
- from = state->window + (state->write - copy);
- if (copy > state->length) copy = state->length;
- }
- else { /* copy from output */
- from = put - state->offset;
- copy = state->length;
- }
- if (copy > left) copy = left;
- left -= copy;
- state->length -= copy;
- do {
- *put++ = *from++;
- } while (--copy);
- if (state->length == 0) state->mode = LEN;
- break;
- case LIT:
- if (left == 0) goto inf_leave;
- *put++ = (unsigned char)(state->length);
- left--;
- state->mode = LEN;
- break;
- case CHECK:
- if (state->wrap) {
- NEEDBITS(32);
- out -= left;
- strm->total_out += out;
- state->total += out;
- if (out)
- strm->adler = state->check =
- UPDATE(state->check, put - out, out);
- out = left;
- if ((
-#ifdef GUNZIP
- state->flags ? hold :
-#endif
- REVERSE(hold)) != state->check) {
- strm->msg = "incorrect data check";
- state->mode = BAD;
- break;
- }
- INITBITS();
- Tracev((stderr, "inflate: check matches trailer\n"));
- }
-#ifdef GUNZIP
- state->mode = LENGTH;
- case LENGTH:
- if (state->wrap && state->flags) {
- NEEDBITS(32);
- if (hold != (state->total & 0xffffffffUL)) {
- strm->msg = "incorrect length check";
- state->mode = BAD;
- break;
- }
- INITBITS();
- Tracev((stderr, "inflate: length matches trailer\n"));
- }
-#endif
- state->mode = DONE;
- case DONE:
- ret = Z_STREAM_END;
- goto inf_leave;
- case BAD:
- ret = Z_DATA_ERROR;
- goto inf_leave;
- case MEM:
- return Z_MEM_ERROR;
- case SYNC:
- default:
- return Z_STREAM_ERROR;
- }
-
- /*
- Return from inflate(), updating the total counts and the check value.
- If there was no progress during the inflate() call, return a buffer
- error. Call updatewindow() to create and/or update the window state.
- Note: a memory error from inflate() is non-recoverable.
- */
- inf_leave:
- RESTORE();
- if (state->wsize || (state->mode < CHECK && out != strm->avail_out))
- if (updatewindow(strm, out)) {
- state->mode = MEM;
- return Z_MEM_ERROR;
- }
- in -= strm->avail_in;
- out -= strm->avail_out;
- strm->total_in += in;
- strm->total_out += out;
- state->total += out;
- if (state->wrap && out)
- strm->adler = state->check =
- UPDATE(state->check, strm->next_out - out, out);
- strm->data_type = state->bits + (state->last ? 64 : 0) +
- (state->mode == TYPE ? 128 : 0);
- if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
- ret = Z_BUF_ERROR;
- return ret;
-}
-
-int ZEXPORT inflateEnd(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (state->window != Z_NULL) ZFREE(strm, state->window);
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
- Tracev((stderr, "inflate: end\n"));
- return Z_OK;
-}
-
-int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
-z_streamp strm;
-const Bytef *dictionary;
-uInt dictLength;
-{
- struct inflate_state FAR *state;
- unsigned long id;
-
- /* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (state->wrap != 0 && state->mode != DICT)
- return Z_STREAM_ERROR;
-
- /* check for correct dictionary id */
- if (state->mode == DICT) {
- id = adler32(0L, Z_NULL, 0);
- id = adler32(id, dictionary, dictLength);
- if (id != state->check)
- return Z_DATA_ERROR;
- }
-
- /* copy dictionary to window */
- if (updatewindow(strm, strm->avail_out)) {
- state->mode = MEM;
- return Z_MEM_ERROR;
- }
- if (dictLength > state->wsize) {
- zmemcpy(state->window, dictionary + dictLength - state->wsize,
- state->wsize);
- state->whave = state->wsize;
- }
- else {
- zmemcpy(state->window + state->wsize - dictLength, dictionary,
- dictLength);
- state->whave = dictLength;
- }
- state->havedict = 1;
- Tracev((stderr, "inflate: dictionary set\n"));
- return Z_OK;
-}
-
-int ZEXPORT inflateGetHeader(strm, head)
-z_streamp strm;
-gz_headerp head;
-{
- struct inflate_state FAR *state;
-
- /* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
-
- /* save header structure */
- state->head = head;
- head->done = 0;
- return Z_OK;
-}
-
-/*
- Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found
- or when out of input. When called, *have is the number of pattern bytes
- found in order so far, in 0..3. On return *have is updated to the new
- state. If on return *have equals four, then the pattern was found and the
- return value is how many bytes were read including the last byte of the
- pattern. If *have is less than four, then the pattern has not been found
- yet and the return value is len. In the latter case, syncsearch() can be
- called again with more data and the *have state. *have is initialized to
- zero for the first call.
- */
-local unsigned syncsearch(have, buf, len)
-unsigned FAR *have;
-unsigned const char FAR *buf;
-unsigned len;
-{
- unsigned got;
- unsigned next;
-
- got = *have;
- next = 0;
- while (next < len && got < 4) {
- if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
- got++;
- else if (buf[next])
- got = 0;
- else
- got = 4 - got;
- next++;
- }
- *have = got;
- return next;
-}
-
-int ZEXPORT inflateSync(strm)
-z_streamp strm;
-{
- unsigned len; /* number of bytes to look at or looked at */
- unsigned long in, out; /* temporary to save total_in and total_out */
- unsigned char buf[4]; /* to restore bit buffer to byte string */
- struct inflate_state FAR *state;
-
- /* check parameters */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
-
- /* if first time, start search in bit buffer */
- if (state->mode != SYNC) {
- state->mode = SYNC;
- state->hold <<= state->bits & 7;
- state->bits -= state->bits & 7;
- len = 0;
- while (state->bits >= 8) {
- buf[len++] = (unsigned char)(state->hold);
- state->hold >>= 8;
- state->bits -= 8;
- }
- state->have = 0;
- syncsearch(&(state->have), buf, len);
- }
-
- /* search available input */
- len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
- strm->avail_in -= len;
- strm->next_in += len;
- strm->total_in += len;
-
- /* return no joy or set up to restart inflate() on a new block */
- if (state->have != 4) return Z_DATA_ERROR;
- in = strm->total_in; out = strm->total_out;
- inflateReset(strm);
- strm->total_in = in; strm->total_out = out;
- state->mode = TYPE;
- return Z_OK;
-}
-
-/*
- Returns true if inflate is currently at the end of a block generated by
- Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
- implementation to provide an additional safety check. PPP uses
- Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored
- block. When decompressing, PPP checks that at the end of input packet,
- inflate is waiting for these length bytes.
- */
-int ZEXPORT inflateSyncPoint(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- return state->mode == STORED && state->bits == 0;
-}
-
-int ZEXPORT inflateCopy(dest, source)
-z_streamp dest;
-z_streamp source;
-{
- struct inflate_state FAR *state;
- struct inflate_state FAR *copy;
- unsigned char FAR *window;
- unsigned wsize;
-
- /* check input */
- if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
- source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)source->state;
-
- /* allocate space */
- copy = (struct inflate_state FAR *)
- ZALLOC(source, 1, sizeof(struct inflate_state));
- if (copy == Z_NULL) return Z_MEM_ERROR;
- window = Z_NULL;
- if (state->window != Z_NULL) {
- window = (unsigned char FAR *)
- ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
- if (window == Z_NULL) {
- ZFREE(source, copy);
- return Z_MEM_ERROR;
- }
- }
-
- /* copy state */
- zmemcpy(dest, source, sizeof(z_stream));
- zmemcpy(copy, state, sizeof(struct inflate_state));
- if (state->lencode >= state->codes &&
- state->lencode <= state->codes + ENOUGH - 1) {
- copy->lencode = copy->codes + (state->lencode - state->codes);
- copy->distcode = copy->codes + (state->distcode - state->codes);
- }
- copy->next = copy->codes + (state->next - state->codes);
- if (window != Z_NULL) {
- wsize = 1U << state->wbits;
- zmemcpy(window, state->window, wsize);
- }
- copy->window = window;
- dest->state = (struct internal_state FAR *)copy;
- return Z_OK;
-}
diff --git a/source4/lib/zlib/inflate.h b/source4/lib/zlib/inflate.h
deleted file mode 100644
index 07bd3e78a7..0000000000
--- a/source4/lib/zlib/inflate.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* inflate.h -- internal inflate state definition
- * Copyright (C) 1995-2004 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* define NO_GZIP when compiling if you want to disable gzip header and
- trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
- the crc code when it is not needed. For shared libraries, gzip decoding
- should be left enabled. */
-#ifndef NO_GZIP
-# define GUNZIP
-#endif
-
-/* Possible inflate modes between inflate() calls */
-typedef enum {
- HEAD, /* i: waiting for magic header */
- FLAGS, /* i: waiting for method and flags (gzip) */
- TIME, /* i: waiting for modification time (gzip) */
- OS, /* i: waiting for extra flags and operating system (gzip) */
- EXLEN, /* i: waiting for extra length (gzip) */
- EXTRA, /* i: waiting for extra bytes (gzip) */
- NAME, /* i: waiting for end of file name (gzip) */
- COMMENT, /* i: waiting for end of comment (gzip) */
- HCRC, /* i: waiting for header crc (gzip) */
- DICTID, /* i: waiting for dictionary check value */
- DICT, /* waiting for inflateSetDictionary() call */
- TYPE, /* i: waiting for type bits, including last-flag bit */
- TYPEDO, /* i: same, but skip check to exit inflate on new block */
- STORED, /* i: waiting for stored size (length and complement) */
- COPY, /* i/o: waiting for input or output to copy stored block */
- TABLE, /* i: waiting for dynamic block table lengths */
- LENLENS, /* i: waiting for code length code lengths */
- CODELENS, /* i: waiting for length/lit and distance code lengths */
- LEN, /* i: waiting for length/lit code */
- LENEXT, /* i: waiting for length extra bits */
- DIST, /* i: waiting for distance code */
- DISTEXT, /* i: waiting for distance extra bits */
- MATCH, /* o: waiting for output space to copy string */
- LIT, /* o: waiting for output space to write literal */
- CHECK, /* i: waiting for 32-bit check value */
- LENGTH, /* i: waiting for 32-bit length (gzip) */
- DONE, /* finished check, done -- remain here until reset */
- BAD, /* got a data error -- remain here until reset */
- MEM, /* got an inflate() memory error -- remain here until reset */
- SYNC /* looking for synchronization bytes to restart inflate() */
-} inflate_mode;
-
-/*
- State transitions between above modes -
-
- (most modes can go to the BAD or MEM mode -- not shown for clarity)
-
- Process header:
- HEAD -> (gzip) or (zlib)
- (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
- NAME -> COMMENT -> HCRC -> TYPE
- (zlib) -> DICTID or TYPE
- DICTID -> DICT -> TYPE
- Read deflate blocks:
- TYPE -> STORED or TABLE or LEN or CHECK
- STORED -> COPY -> TYPE
- TABLE -> LENLENS -> CODELENS -> LEN
- Read deflate codes:
- LEN -> LENEXT or LIT or TYPE
- LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
- LIT -> LEN
- Process trailer:
- CHECK -> LENGTH -> DONE
- */
-
-/* state maintained between inflate() calls. Approximately 7K bytes. */
-struct inflate_state {
- inflate_mode mode; /* current inflate mode */
- int last; /* true if processing last block */
- int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
- int havedict; /* true if dictionary provided */
- int flags; /* gzip header method and flags (0 if zlib) */
- unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
- unsigned long check; /* protected copy of check value */
- unsigned long total; /* protected copy of output count */
- gz_headerp head; /* where to save gzip header information */
- /* sliding window */
- unsigned wbits; /* log base 2 of requested window size */
- unsigned wsize; /* window size or zero if not using window */
- unsigned whave; /* valid bytes in the window */
- unsigned write; /* window write index */
- unsigned char FAR *window; /* allocated sliding window, if needed */
- /* bit accumulator */
- unsigned long hold; /* input bit accumulator */
- unsigned bits; /* number of bits in "in" */
- /* for string and stored block copying */
- unsigned length; /* literal or length of data to copy */
- unsigned offset; /* distance back to copy string from */
- /* for table and code decoding */
- unsigned extra; /* extra bits needed */
- /* fixed and dynamic code tables */
- code const FAR *lencode; /* starting table for length/literal codes */
- code const FAR *distcode; /* starting table for distance codes */
- unsigned lenbits; /* index bits for lencode */
- unsigned distbits; /* index bits for distcode */
- /* dynamic table building */
- unsigned ncode; /* number of code length code lengths */
- unsigned nlen; /* number of length code lengths */
- unsigned ndist; /* number of distance code lengths */
- unsigned have; /* number of code lengths in lens[] */
- code FAR *next; /* next available space in codes[] */
- unsigned short lens[320]; /* temporary storage for code lengths */
- unsigned short work[288]; /* work area for code table building */
- code codes[ENOUGH]; /* space for code tables */
-};
diff --git a/source4/lib/zlib/inftrees.c b/source4/lib/zlib/inftrees.c
deleted file mode 100644
index 8a9c13ff03..0000000000
--- a/source4/lib/zlib/inftrees.c
+++ /dev/null
@@ -1,329 +0,0 @@
-/* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-
-#define MAXBITS 15
-
-const char inflate_copyright[] =
- " inflate 1.2.3 Copyright 1995-2005 Mark Adler ";
-/*
- If you use the zlib library in a product, an acknowledgment is welcome
- in the documentation of your product. If for some reason you cannot
- include such an acknowledgment, I would appreciate that you keep this
- copyright string in the executable of your product.
- */
-
-/*
- Build a set of tables to decode the provided canonical Huffman code.
- The code lengths are lens[0..codes-1]. The result starts at *table,
- whose indices are 0..2^bits-1. work is a writable array of at least
- lens shorts, which is used as a work area. type is the type of code
- to be generated, CODES, LENS, or DISTS. On return, zero is success,
- -1 is an invalid code, and +1 means that ENOUGH isn't enough. table
- on return points to the next available entry's address. bits is the
- requested root table index bits, and on return it is the actual root
- table index bits. It will differ if the request is greater than the
- longest code or if it is less than the shortest code.
- */
-int inflate_table(type, lens, codes, table, bits, work)
-codetype type;
-unsigned short FAR *lens;
-unsigned codes;
-code FAR * FAR *table;
-unsigned FAR *bits;
-unsigned short FAR *work;
-{
- unsigned len; /* a code's length in bits */
- unsigned sym; /* index of code symbols */
- unsigned min, max; /* minimum and maximum code lengths */
- unsigned root; /* number of index bits for root table */
- unsigned curr; /* number of index bits for current table */
- unsigned drop; /* code bits to drop for sub-table */
- int left; /* number of prefix codes available */
- unsigned used; /* code entries in table used */
- unsigned huff; /* Huffman code */
- unsigned incr; /* for incrementing code, index */
- unsigned fill; /* index for replicating entries */
- unsigned low; /* low bits for current root entry */
- unsigned mask; /* mask for low root bits */
- code this; /* table entry for duplication */
- code FAR *next; /* next available space in table */
- const unsigned short FAR *base; /* base value table to use */
- const unsigned short FAR *extra; /* extra bits table to use */
- int end; /* use base and extra for symbol > end */
- unsigned short count[MAXBITS+1]; /* number of codes of each length */
- unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
- static const unsigned short lbase[31] = { /* Length codes 257..285 base */
- 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 unsigned short lext[31] = { /* Length codes 257..285 extra */
- 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
- 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196};
- static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
- 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, 0, 0};
- static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
- 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
- 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
- 28, 28, 29, 29, 64, 64};
-
- /*
- Process a set of code lengths to create a canonical Huffman code. The
- code lengths are lens[0..codes-1]. Each length corresponds to the
- symbols 0..codes-1. The Huffman code is generated by first sorting the
- symbols by length from short to long, and retaining the symbol order
- for codes with equal lengths. Then the code starts with all zero bits
- for the first code of the shortest length, and the codes are integer
- increments for the same length, and zeros are appended as the length
- increases. For the deflate format, these bits are stored backwards
- from their more natural integer increment ordering, and so when the
- decoding tables are built in the large loop below, the integer codes
- are incremented backwards.
-
- This routine assumes, but does not check, that all of the entries in
- lens[] are in the range 0..MAXBITS. The caller must assure this.
- 1..MAXBITS is interpreted as that code length. zero means that that
- symbol does not occur in this code.
-
- The codes are sorted by computing a count of codes for each length,
- creating from that a table of starting indices for each length in the
- sorted table, and then entering the symbols in order in the sorted
- table. The sorted table is work[], with that space being provided by
- the caller.
-
- The length counts are used for other purposes as well, i.e. finding
- the minimum and maximum length codes, determining if there are any
- codes at all, checking for a valid set of lengths, and looking ahead
- at length counts to determine sub-table sizes when building the
- decoding tables.
- */
-
- /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
- for (len = 0; len <= MAXBITS; len++)
- count[len] = 0;
- for (sym = 0; sym < codes; sym++)
- count[lens[sym]]++;
-
- /* bound code lengths, force root to be within code lengths */
- root = *bits;
- for (max = MAXBITS; max >= 1; max--)
- if (count[max] != 0) break;
- if (root > max) root = max;
- if (max == 0) { /* no symbols to code at all */
- this.op = (unsigned char)64; /* invalid code marker */
- this.bits = (unsigned char)1;
- this.val = (unsigned short)0;
- *(*table)++ = this; /* make a table to force an error */
- *(*table)++ = this;
- *bits = 1;
- return 0; /* no symbols, but wait for decoding to report error */
- }
- for (min = 1; min <= MAXBITS; min++)
- if (count[min] != 0) break;
- if (root < min) root = min;
-
- /* check for an over-subscribed or incomplete set of lengths */
- left = 1;
- for (len = 1; len <= MAXBITS; len++) {
- left <<= 1;
- left -= count[len];
- if (left < 0) return -1; /* over-subscribed */
- }
- if (left > 0 && (type == CODES || max != 1))
- return -1; /* incomplete set */
-
- /* generate offsets into symbol table for each length for sorting */
- offs[1] = 0;
- for (len = 1; len < MAXBITS; len++)
- offs[len + 1] = offs[len] + count[len];
-
- /* sort symbols by length, by symbol order within each length */
- for (sym = 0; sym < codes; sym++)
- if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
-
- /*
- Create and fill in decoding tables. In this loop, the table being
- filled is at next and has curr index bits. The code being used is huff
- with length len. That code is converted to an index by dropping drop
- bits off of the bottom. For codes where len is less than drop + curr,
- those top drop + curr - len bits are incremented through all values to
- fill the table with replicated entries.
-
- root is the number of index bits for the root table. When len exceeds
- root, sub-tables are created pointed to by the root entry with an index
- of the low root bits of huff. This is saved in low to check for when a
- new sub-table should be started. drop is zero when the root table is
- being filled, and drop is root when sub-tables are being filled.
-
- When a new sub-table is needed, it is necessary to look ahead in the
- code lengths to determine what size sub-table is needed. The length
- counts are used for this, and so count[] is decremented as codes are
- entered in the tables.
-
- used keeps track of how many table entries have been allocated from the
- provided *table space. It is checked when a LENS table is being made
- against the space in *table, ENOUGH, minus the maximum space needed by
- the worst case distance code, MAXD. This should never happen, but the
- sufficiency of ENOUGH has not been proven exhaustively, hence the check.
- This assumes that when type == LENS, bits == 9.
-
- sym increments through all symbols, and the loop terminates when
- all codes of length max, i.e. all codes, have been processed. This
- routine permits incomplete codes, so another loop after this one fills
- in the rest of the decoding tables with invalid code markers.
- */
-
- /* set up for code type */
- switch (type) {
- case CODES:
- base = extra = work; /* dummy value--not used */
- end = 19;
- break;
- case LENS:
- base = lbase;
- base -= 257;
- extra = lext;
- extra -= 257;
- end = 256;
- break;
- default: /* DISTS */
- base = dbase;
- extra = dext;
- end = -1;
- }
-
- /* initialize state for loop */
- huff = 0; /* starting code */
- sym = 0; /* starting code symbol */
- len = min; /* starting code length */
- next = *table; /* current table to fill in */
- curr = root; /* current table index bits */
- drop = 0; /* current bits to drop from code for index */
- low = (unsigned)(-1); /* trigger new sub-table when len > root */
- used = 1U << root; /* use root table entries */
- mask = used - 1; /* mask for comparing low */
-
- /* check available table space */
- if (type == LENS && used >= ENOUGH - MAXD)
- return 1;
-
- /* process all codes and make table entries */
- for (;;) {
- /* create table entry */
- this.bits = (unsigned char)(len - drop);
- if ((int)(work[sym]) < end) {
- this.op = (unsigned char)0;
- this.val = work[sym];
- }
- else if ((int)(work[sym]) > end) {
- this.op = (unsigned char)(extra[work[sym]]);
- this.val = base[work[sym]];
- }
- else {
- this.op = (unsigned char)(32 + 64); /* end of block */
- this.val = 0;
- }
-
- /* replicate for those indices with low len bits equal to huff */
- incr = 1U << (len - drop);
- fill = 1U << curr;
- min = fill; /* save offset to next table */
- do {
- fill -= incr;
- next[(huff >> drop) + fill] = this;
- } while (fill != 0);
-
- /* backwards increment the len-bit code huff */
- incr = 1U << (len - 1);
- while (huff & incr)
- incr >>= 1;
- if (incr != 0) {
- huff &= incr - 1;
- huff += incr;
- }
- else
- huff = 0;
-
- /* go to next symbol, update count, len */
- sym++;
- if (--(count[len]) == 0) {
- if (len == max) break;
- len = lens[work[sym]];
- }
-
- /* create new sub-table if needed */
- if (len > root && (huff & mask) != low) {
- /* if first time, transition to sub-tables */
- if (drop == 0)
- drop = root;
-
- /* increment past last table */
- next += min; /* here min is 1 << curr */
-
- /* determine length of next table */
- curr = len - drop;
- left = (int)(1 << curr);
- while (curr + drop < max) {
- left -= count[curr + drop];
- if (left <= 0) break;
- curr++;
- left <<= 1;
- }
-
- /* check for enough space */
- used += 1U << curr;
- if (type == LENS && used >= ENOUGH - MAXD)
- return 1;
-
- /* point entry in root table to sub-table */
- low = huff & mask;
- (*table)[low].op = (unsigned char)curr;
- (*table)[low].bits = (unsigned char)root;
- (*table)[low].val = (unsigned short)(next - *table);
- }
- }
-
- /*
- Fill in rest of table for incomplete codes. This loop is similar to the
- loop above in incrementing huff for table indices. It is assumed that
- len is equal to curr + drop, so there is no loop needed to increment
- through high index bits. When the current sub-table is filled, the loop
- drops back to the root table to fill in any remaining entries there.
- */
- this.op = (unsigned char)64; /* invalid code marker */
- this.bits = (unsigned char)(len - drop);
- this.val = (unsigned short)0;
- while (huff != 0) {
- /* when done with sub-table, drop back to root table */
- if (drop != 0 && (huff & mask) != low) {
- drop = 0;
- len = root;
- next = *table;
- this.bits = (unsigned char)len;
- }
-
- /* put invalid code marker in table */
- next[huff >> drop] = this;
-
- /* backwards increment the len-bit code huff */
- incr = 1U << (len - 1);
- while (huff & incr)
- incr >>= 1;
- if (incr != 0) {
- huff &= incr - 1;
- huff += incr;
- }
- else
- huff = 0;
- }
-
- /* set return parameters */
- *table += used;
- *bits = root;
- return 0;
-}
diff --git a/source4/lib/zlib/inftrees.h b/source4/lib/zlib/inftrees.h
deleted file mode 100644
index b1104c87e7..0000000000
--- a/source4/lib/zlib/inftrees.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* inftrees.h -- header to use inftrees.c
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* Structure for decoding tables. Each entry provides either the
- information needed to do the operation requested by the code that
- indexed that table entry, or it provides a pointer to another
- table that indexes more bits of the code. op indicates whether
- the entry is a pointer to another table, a literal, a length or
- distance, an end-of-block, or an invalid code. For a table
- pointer, the low four bits of op is the number of index bits of
- that table. For a length or distance, the low four bits of op
- is the number of extra bits to get after the code. bits is
- the number of bits in this code or part of the code to drop off
- of the bit buffer. val is the actual byte to output in the case
- of a literal, the base length or distance, or the offset from
- the current table to the next table. Each entry is four bytes. */
-typedef struct {
- unsigned char op; /* operation, extra bits, table bits */
- unsigned char bits; /* bits in this part of the code */
- unsigned short val; /* offset in table or code value */
-} code;
-
-/* op values as set by inflate_table():
- 00000000 - literal
- 0000tttt - table link, tttt != 0 is the number of table index bits
- 0001eeee - length or distance, eeee is the number of extra bits
- 01100000 - end of block
- 01000000 - invalid code
- */
-
-/* Maximum size of dynamic tree. The maximum found in a long but non-
- exhaustive search was 1444 code structures (852 for length/literals
- and 592 for distances, the latter actually the result of an
- exhaustive search). The true maximum is not known, but the value
- below is more than safe. */
-#define ENOUGH 2048
-#define MAXD 592
-
-/* Type of code to build for inftable() */
-typedef enum {
- CODES,
- LENS,
- DISTS
-} codetype;
-
-extern int inflate_table OF((codetype type, unsigned short FAR *lens,
- unsigned codes, code FAR * FAR *table,
- unsigned FAR *bits, unsigned short FAR *work));
diff --git a/source4/lib/zlib/make_vms.com b/source4/lib/zlib/make_vms.com
deleted file mode 100644
index c2a1fb54b2..0000000000
--- a/source4/lib/zlib/make_vms.com
+++ /dev/null
@@ -1,461 +0,0 @@
-$! make libz under VMS written by
-$! Martin P.J. Zinser
-$! <zinser@zinser.no-ip.info or zinser@sysdev.deutsche-boerse.com>
-$!
-$ on error then goto err_exit
-$!
-$!
-$! Just some general constants...
-$!
-$ true = 1
-$ false = 0
-$ tmpnam = "temp_" + f$getjpi("","pid")
-$ SAY = "WRITE SYS$OUTPUT"
-$!
-$! Setup variables holding "config" information
-$!
-$ Make = ""
-$ name = "Zlib"
-$ version = "?.?.?"
-$ v_string = "ZLIB_VERSION"
-$ v_file = "zlib.h"
-$ ccopt = ""
-$ lopts = ""
-$ linkonly = false
-$ optfile = name + ".opt"
-$ its_decc = false
-$ its_vaxc = false
-$ its_gnuc = false
-$ axp = f$getsyi("HW_MODEL").ge.1024
-$ s_case = false
-$! Check for MMK/MMS
-$!
-$ If F$Search ("Sys$System:MMS.EXE") .nes. "" Then Make = "MMS"
-$ If F$Type (MMK) .eqs. "STRING" Then Make = "MMK"
-$!
-$!
-$ gosub find_version
-$!
-$ gosub check_opts
-$!
-$! Look for the compiler used
-$!
-$ gosub check_compiler
-$ if its_decc
-$ then
-$ ccopt = "/prefix=all" + ccopt
-$ if f$trnlnm("SYS") .eqs. ""
-$ then
-$ if axp
-$ then
-$ define sys sys$library:
-$ else
-$ ccopt = "/decc" + ccopt
-$ define sys decc$library_include:
-$ endif
-$ endif
-$ endif
-$ if its_vaxc .or. its_gnuc
-$ then
-$ if f$trnlnm("SYS").eqs."" then define sys sys$library:
-$ endif
-$!
-$! Build the thing plain or with mms
-$!
-$ write sys$output "Compiling Zlib sources ..."
-$ if make.eqs.""
-$ then
-$ dele example.obj;*,minigzip.obj;*
-$ CALL MAKE adler32.OBJ "CC ''CCOPT' adler32" -
- adler32.c zlib.h zconf.h
-$ CALL MAKE compress.OBJ "CC ''CCOPT' compress" -
- compress.c zlib.h zconf.h
-$ CALL MAKE crc32.OBJ "CC ''CCOPT' crc32" -
- crc32.c zlib.h zconf.h
-$ CALL MAKE deflate.OBJ "CC ''CCOPT' deflate" -
- deflate.c deflate.h zutil.h zlib.h zconf.h
-$ CALL MAKE gzio.OBJ "CC ''CCOPT' gzio" -
- gzio.c zutil.h zlib.h zconf.h
-$ CALL MAKE infback.OBJ "CC ''CCOPT' infback" -
- infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h
-$ CALL MAKE inffast.OBJ "CC ''CCOPT' inffast" -
- inffast.c zutil.h zlib.h zconf.h inffast.h
-$ CALL MAKE inflate.OBJ "CC ''CCOPT' inflate" -
- inflate.c zutil.h zlib.h zconf.h infblock.h
-$ CALL MAKE inftrees.OBJ "CC ''CCOPT' inftrees" -
- inftrees.c zutil.h zlib.h zconf.h inftrees.h
-$ CALL MAKE trees.OBJ "CC ''CCOPT' trees" -
- trees.c deflate.h zutil.h zlib.h zconf.h
-$ CALL MAKE uncompr.OBJ "CC ''CCOPT' uncompr" -
- uncompr.c zlib.h zconf.h
-$ CALL MAKE zutil.OBJ "CC ''CCOPT' zutil" -
- zutil.c zutil.h zlib.h zconf.h
-$ write sys$output "Building Zlib ..."
-$ CALL MAKE libz.OLB "lib/crea libz.olb *.obj" *.OBJ
-$ write sys$output "Building example..."
-$ CALL MAKE example.OBJ "CC ''CCOPT' example" -
- example.c zlib.h zconf.h
-$ call make example.exe "LINK example,libz.olb/lib" example.obj libz.olb
-$ if f$search("x11vms:xvmsutils.olb") .nes. ""
-$ then
-$ write sys$output "Building minigzip..."
-$ CALL MAKE minigzip.OBJ "CC ''CCOPT' minigzip" -
- minigzip.c zlib.h zconf.h
-$ call make minigzip.exe -
- "LINK minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib" -
- minigzip.obj libz.olb
-$ endif
-$ else
-$ gosub crea_mms
-$ SAY "Make ''name' ''version' with ''Make' "
-$ 'make'
-$ endif
-$!
-$! Alpha gets a shareable image
-$!
-$ If axp
-$ Then
-$ gosub crea_olist
-$ write sys$output "Creating libzshr.exe"
-$ call anal_obj_axp modules.opt _link.opt
-$ if s_case
-$ then
-$ open/append optf modules.opt
-$ write optf "case_sensitive=YES"
-$ close optf
-$ endif
-$ LINK_'lopts'/SHARE=libzshr.exe modules.opt/opt,_link.opt/opt
-$ endif
-$ write sys$output "Zlib build completed"
-$ exit
-$CC_ERR:
-$ write sys$output "C compiler required to build ''name'"
-$ goto err_exit
-$ERR_EXIT:
-$ set message/facil/ident/sever/text
-$ write sys$output "Exiting..."
-$ exit 2
-$!
-$!
-$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES
-$ V = 'F$Verify(0)
-$! P1 = What we are trying to make
-$! P2 = Command to make it
-$! P3 - P8 What it depends on
-$
-$ If F$Search(P1) .Eqs. "" Then Goto Makeit
-$ Time = F$CvTime(F$File(P1,"RDT"))
-$arg=3
-$Loop:
-$ Argument = P'arg
-$ If Argument .Eqs. "" Then Goto Exit
-$ El=0
-$Loop2:
-$ File = F$Element(El," ",Argument)
-$ If File .Eqs. " " Then Goto Endl
-$ AFile = ""
-$Loop3:
-$ OFile = AFile
-$ AFile = F$Search(File)
-$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl
-$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit
-$ Goto Loop3
-$NextEL:
-$ El = El + 1
-$ Goto Loop2
-$EndL:
-$ arg=arg+1
-$ If arg .Le. 8 Then Goto Loop
-$ Goto Exit
-$
-$Makeit:
-$ VV=F$VERIFY(0)
-$ write sys$output P2
-$ 'P2
-$ VV='F$Verify(VV)
-$Exit:
-$ If V Then Set Verify
-$ENDSUBROUTINE
-$!------------------------------------------------------------------------------
-$!
-$! Check command line options and set symbols accordingly
-$!
-$ CHECK_OPTS:
-$ i = 1
-$ OPT_LOOP:
-$ if i .lt. 9
-$ then
-$ cparm = f$edit(p'i',"upcase")
-$ if cparm .eqs. "DEBUG"
-$ then
-$ ccopt = ccopt + "/noopt/deb"
-$ lopts = lopts + "/deb"
-$ endif
-$ if f$locate("CCOPT=",cparm) .lt. f$length(cparm)
-$ then
-$ start = f$locate("=",cparm) + 1
-$ len = f$length(cparm) - start
-$ ccopt = ccopt + f$extract(start,len,cparm)
-$ if f$locate("AS_IS",f$edit(ccopt,"UPCASE")) .lt. f$length(ccopt) -
- then s_case = true
-$ endif
-$ if cparm .eqs. "LINK" then linkonly = true
-$ if f$locate("LOPTS=",cparm) .lt. f$length(cparm)
-$ then
-$ start = f$locate("=",cparm) + 1
-$ len = f$length(cparm) - start
-$ lopts = lopts + f$extract(start,len,cparm)
-$ endif
-$ if f$locate("CC=",cparm) .lt. f$length(cparm)
-$ then
-$ start = f$locate("=",cparm) + 1
-$ len = f$length(cparm) - start
-$ cc_com = f$extract(start,len,cparm)
- if (cc_com .nes. "DECC") .and. -
- (cc_com .nes. "VAXC") .and. -
- (cc_com .nes. "GNUC")
-$ then
-$ write sys$output "Unsupported compiler choice ''cc_com' ignored"
-$ write sys$output "Use DECC, VAXC, or GNUC instead"
-$ else
-$ if cc_com .eqs. "DECC" then its_decc = true
-$ if cc_com .eqs. "VAXC" then its_vaxc = true
-$ if cc_com .eqs. "GNUC" then its_gnuc = true
-$ endif
-$ endif
-$ if f$locate("MAKE=",cparm) .lt. f$length(cparm)
-$ then
-$ start = f$locate("=",cparm) + 1
-$ len = f$length(cparm) - start
-$ mmks = f$extract(start,len,cparm)
-$ if (mmks .eqs. "MMK") .or. (mmks .eqs. "MMS")
-$ then
-$ make = mmks
-$ else
-$ write sys$output "Unsupported make choice ''mmks' ignored"
-$ write sys$output "Use MMK or MMS instead"
-$ endif
-$ endif
-$ i = i + 1
-$ goto opt_loop
-$ endif
-$ return
-$!------------------------------------------------------------------------------
-$!
-$! Look for the compiler used
-$!
-$CHECK_COMPILER:
-$ if (.not. (its_decc .or. its_vaxc .or. its_gnuc))
-$ then
-$ its_decc = (f$search("SYS$SYSTEM:DECC$COMPILER.EXE") .nes. "")
-$ its_vaxc = .not. its_decc .and. (F$Search("SYS$System:VAXC.Exe") .nes. "")
-$ its_gnuc = .not. (its_decc .or. its_vaxc) .and. (f$trnlnm("gnu_cc") .nes. "")
-$ endif
-$!
-$! Exit if no compiler available
-$!
-$ if (.not. (its_decc .or. its_vaxc .or. its_gnuc))
-$ then goto CC_ERR
-$ else
-$ if its_decc then write sys$output "CC compiler check ... Compaq C"
-$ if its_vaxc then write sys$output "CC compiler check ... VAX C"
-$ if its_gnuc then write sys$output "CC compiler check ... GNU C"
-$ endif
-$ return
-$!------------------------------------------------------------------------------
-$!
-$! If MMS/MMK are available dump out the descrip.mms if required
-$!
-$CREA_MMS:
-$ write sys$output "Creating descrip.mms..."
-$ create descrip.mms
-$ open/append out descrip.mms
-$ copy sys$input: out
-$ deck
-# descrip.mms: MMS description file for building zlib on VMS
-# written by Martin P.J. Zinser
-# <zinser@zinser.no-ip.info or zinser@sysdev.deutsche-boerse.com>
-
-OBJS = adler32.obj, compress.obj, crc32.obj, gzio.obj, uncompr.obj, infback.obj\
- deflate.obj, trees.obj, zutil.obj, inflate.obj, \
- inftrees.obj, inffast.obj
-
-$ eod
-$ write out "CFLAGS=", ccopt
-$ write out "LOPTS=", lopts
-$ copy sys$input: out
-$ deck
-
-all : example.exe minigzip.exe libz.olb
- @ write sys$output " Example applications available"
-
-libz.olb : libz.olb($(OBJS))
- @ write sys$output " libz available"
-
-example.exe : example.obj libz.olb
- link $(LOPTS) example,libz.olb/lib
-
-minigzip.exe : minigzip.obj libz.olb
- link $(LOPTS) minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib
-
-clean :
- delete *.obj;*,libz.olb;*,*.opt;*,*.exe;*
-
-
-# Other dependencies.
-adler32.obj : adler32.c zutil.h zlib.h zconf.h
-compress.obj : compress.c zlib.h zconf.h
-crc32.obj : crc32.c zutil.h zlib.h zconf.h
-deflate.obj : deflate.c deflate.h zutil.h zlib.h zconf.h
-example.obj : example.c zlib.h zconf.h
-gzio.obj : gzio.c zutil.h zlib.h zconf.h
-inffast.obj : inffast.c zutil.h zlib.h zconf.h inftrees.h inffast.h
-inflate.obj : inflate.c zutil.h zlib.h zconf.h
-inftrees.obj : inftrees.c zutil.h zlib.h zconf.h inftrees.h
-minigzip.obj : minigzip.c zlib.h zconf.h
-trees.obj : trees.c deflate.h zutil.h zlib.h zconf.h
-uncompr.obj : uncompr.c zlib.h zconf.h
-zutil.obj : zutil.c zutil.h zlib.h zconf.h
-infback.obj : infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h
-$ eod
-$ close out
-$ return
-$!------------------------------------------------------------------------------
-$!
-$! Read list of core library sources from makefile.in and create options
-$! needed to build shareable image
-$!
-$CREA_OLIST:
-$ open/read min makefile.in
-$ open/write mod modules.opt
-$ src_check = "OBJS ="
-$MRLOOP:
-$ read/end=mrdone min rec
-$ if (f$extract(0,6,rec) .nes. src_check) then goto mrloop
-$ rec = rec - src_check
-$ gosub extra_filnam
-$ if (f$element(1,"\",rec) .eqs. "\") then goto mrdone
-$MRSLOOP:
-$ read/end=mrdone min rec
-$ gosub extra_filnam
-$ if (f$element(1,"\",rec) .nes. "\") then goto mrsloop
-$MRDONE:
-$ close min
-$ close mod
-$ return
-$!------------------------------------------------------------------------------
-$!
-$! Take record extracted in crea_olist and split it into single filenames
-$!
-$EXTRA_FILNAM:
-$ myrec = f$edit(rec - "\", "trim,compress")
-$ i = 0
-$FELOOP:
-$ srcfil = f$element(i," ", myrec)
-$ if (srcfil .nes. " ")
-$ then
-$ write mod f$parse(srcfil,,,"NAME"), ".obj"
-$ i = i + 1
-$ goto feloop
-$ endif
-$ return
-$!------------------------------------------------------------------------------
-$!
-$! Find current Zlib version number
-$!
-$FIND_VERSION:
-$ open/read h_in 'v_file'
-$hloop:
-$ read/end=hdone h_in rec
-$ rec = f$edit(rec,"TRIM")
-$ if (f$extract(0,1,rec) .nes. "#") then goto hloop
-$ rec = f$edit(rec - "#", "TRIM")
-$ if f$element(0," ",rec) .nes. "define" then goto hloop
-$ if f$element(1," ",rec) .eqs. v_string
-$ then
-$ version = 'f$element(2," ",rec)'
-$ goto hdone
-$ endif
-$ goto hloop
-$hdone:
-$ close h_in
-$ return
-$!------------------------------------------------------------------------------
-$!
-$! Analyze Object files for OpenVMS AXP to extract Procedure and Data
-$! information to build a symbol vector for a shareable image
-$! All the "brains" of this logic was suggested by Hartmut Becker
-$! (Hartmut.Becker@compaq.com). All the bugs were introduced by me
-$! (zinser@decus.de), so if you do have problem reports please do not
-$! bother Hartmut/HP, but get in touch with me
-$!
-$ ANAL_OBJ_AXP: Subroutine
-$ V = 'F$Verify(0)
-$ SAY := "WRITE_ SYS$OUTPUT"
-$
-$ IF F$SEARCH("''P1'") .EQS. ""
-$ THEN
-$ SAY "ANAL_OBJ_AXP-E-NOSUCHFILE: Error, inputfile ''p1' not available"
-$ goto exit_aa
-$ ENDIF
-$ IF "''P2'" .EQS. ""
-$ THEN
-$ SAY "ANAL_OBJ_AXP: Error, no output file provided"
-$ goto exit_aa
-$ ENDIF
-$
-$ open/read in 'p1
-$ create a.tmp
-$ open/append atmp a.tmp
-$ loop:
-$ read/end=end_loop in line
-$ f= f$search(line)
-$ if f .eqs. ""
-$ then
-$ write sys$output "ANAL_OBJ_AXP-w-nosuchfile, ''line'"
-$ goto loop
-$ endif
-$ define/user sys$output nl:
-$ define/user sys$error nl:
-$ anal/obj/gsd 'f /out=x.tmp
-$ open/read xtmp x.tmp
-$ XLOOP:
-$ read/end=end_xloop xtmp xline
-$ xline = f$edit(xline,"compress")
-$ write atmp xline
-$ goto xloop
-$ END_XLOOP:
-$ close xtmp
-$ goto loop
-$ end_loop:
-$ close in
-$ close atmp
-$ if f$search("a.tmp") .eqs. "" -
- then $ exit
-$ ! all global definitions
-$ search a.tmp "symbol:","EGSY$V_DEF 1","EGSY$V_NORM 1"/out=b.tmp
-$ ! all procedures
-$ search b.tmp "EGSY$V_NORM 1"/wind=(0,1) /out=c.tmp
-$ search c.tmp "symbol:"/out=d.tmp
-$ define/user sys$output nl:
-$ edito/edt/command=sys$input d.tmp
-sub/symbol: "/symbol_vector=(/whole
-sub/"/=PROCEDURE)/whole
-exit
-$ ! all data
-$ search b.tmp "EGSY$V_DEF 1"/wind=(0,1) /out=e.tmp
-$ search e.tmp "symbol:"/out=f.tmp
-$ define/user sys$output nl:
-$ edito/edt/command=sys$input f.tmp
-sub/symbol: "/symbol_vector=(/whole
-sub/"/=DATA)/whole
-exit
-$ sort/nodupl d.tmp,f.tmp 'p2'
-$ delete a.tmp;*,b.tmp;*,c.tmp;*,d.tmp;*,e.tmp;*,f.tmp;*
-$ if f$search("x.tmp") .nes. "" -
- then $ delete x.tmp;*
-$!
-$ EXIT_AA:
-$ if V then set verify
-$ endsubroutine
-$!------------------------------------------------------------------------------
diff --git a/source4/lib/zlib/minigzip.c b/source4/lib/zlib/minigzip.c
deleted file mode 100644
index 4524b96a1d..0000000000
--- a/source4/lib/zlib/minigzip.c
+++ /dev/null
@@ -1,322 +0,0 @@
-/* minigzip.c -- simulate gzip using the zlib compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * minigzip is a minimal implementation of the gzip utility. This is
- * only an example of using zlib and isn't meant to replace the
- * full-featured gzip. No attempt is made to deal with file systems
- * limiting names to 14 or 8+3 characters, etc... Error checking is
- * very limited. So use minigzip only for testing; use gzip for the
- * real thing. On MSDOS, use only on file names without extension
- * or in pipe mode.
- */
-
-/* @(#) $Id$ */
-
-#include <stdio.h>
-#include "zlib.h"
-
-#ifdef STDC
-# include <string.h>
-# include <stdlib.h>
-#endif
-
-#ifdef USE_MMAP
-# include <sys/types.h>
-# include <sys/mman.h>
-# include <sys/stat.h>
-#endif
-
-#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
-# include <fcntl.h>
-# include <io.h>
-# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
-#else
-# define SET_BINARY_MODE(file)
-#endif
-
-#ifdef VMS
-# define unlink delete
-# define GZ_SUFFIX "-gz"
-#endif
-#ifdef RISCOS
-# define unlink remove
-# define GZ_SUFFIX "-gz"
-# define fileno(file) file->__file
-#endif
-#if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
-# include <unix.h> /* for fileno */
-#endif
-
-#ifndef WIN32 /* unlink already in stdio.h for WIN32 */
- extern int unlink OF((const char *));
-#endif
-
-#ifndef GZ_SUFFIX
-# define GZ_SUFFIX ".gz"
-#endif
-#define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1)
-
-#define BUFLEN 16384
-#define MAX_NAME_LEN 1024
-
-#ifdef MAXSEG_64K
-# define local static
- /* Needed for systems with limitation on stack size. */
-#else
-# define local
-#endif
-
-char *prog;
-
-void error OF((const char *msg));
-void gz_compress OF((FILE *in, gzFile out));
-#ifdef USE_MMAP
-int gz_compress_mmap OF((FILE *in, gzFile out));
-#endif
-void gz_uncompress OF((gzFile in, FILE *out));
-void file_compress OF((char *file, char *mode));
-void file_uncompress OF((char *file));
-int main OF((int argc, char *argv[]));
-
-/* ===========================================================================
- * Display error message and exit
- */
-void error(msg)
- const char *msg;
-{
- fprintf(stderr, "%s: %s\n", prog, msg);
- exit(1);
-}
-
-/* ===========================================================================
- * Compress input to output then close both files.
- */
-
-void gz_compress(in, out)
- FILE *in;
- gzFile out;
-{
- local char buf[BUFLEN];
- int len;
- int err;
-
-#ifdef USE_MMAP
- /* Try first compressing with mmap. If mmap fails (minigzip used in a
- * pipe), use the normal fread loop.
- */
- if (gz_compress_mmap(in, out) == Z_OK) return;
-#endif
- for (;;) {
- len = (int)fread(buf, 1, sizeof(buf), in);
- if (ferror(in)) {
- perror("fread");
- exit(1);
- }
- if (len == 0) break;
-
- if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err));
- }
- fclose(in);
- if (gzclose(out) != Z_OK) error("failed gzclose");
-}
-
-#ifdef USE_MMAP /* MMAP version, Miguel Albrecht <malbrech@eso.org> */
-
-/* Try compressing the input file at once using mmap. Return Z_OK if
- * if success, Z_ERRNO otherwise.
- */
-int gz_compress_mmap(in, out)
- FILE *in;
- gzFile out;
-{
- int len;
- int err;
- int ifd = fileno(in);
- caddr_t buf; /* mmap'ed buffer for the entire input file */
- off_t buf_len; /* length of the input file */
- struct stat sb;
-
- /* Determine the size of the file, needed for mmap: */
- if (fstat(ifd, &sb) < 0) return Z_ERRNO;
- buf_len = sb.st_size;
- if (buf_len <= 0) return Z_ERRNO;
-
- /* Now do the actual mmap: */
- buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0);
- if (buf == (caddr_t)(-1)) return Z_ERRNO;
-
- /* Compress the whole file at once: */
- len = gzwrite(out, (char *)buf, (unsigned)buf_len);
-
- if (len != (int)buf_len) error(gzerror(out, &err));
-
- munmap(buf, buf_len);
- fclose(in);
- if (gzclose(out) != Z_OK) error("failed gzclose");
- return Z_OK;
-}
-#endif /* USE_MMAP */
-
-/* ===========================================================================
- * Uncompress input to output then close both files.
- */
-void gz_uncompress(in, out)
- gzFile in;
- FILE *out;
-{
- local char buf[BUFLEN];
- int len;
- int err;
-
- for (;;) {
- len = gzread(in, buf, sizeof(buf));
- if (len < 0) error (gzerror(in, &err));
- if (len == 0) break;
-
- if ((int)fwrite(buf, 1, (unsigned)len, out) != len) {
- error("failed fwrite");
- }
- }
- if (fclose(out)) error("failed fclose");
-
- if (gzclose(in) != Z_OK) error("failed gzclose");
-}
-
-
-/* ===========================================================================
- * Compress the given file: create a corresponding .gz file and remove the
- * original.
- */
-void file_compress(file, mode)
- char *file;
- char *mode;
-{
- local char outfile[MAX_NAME_LEN];
- FILE *in;
- gzFile out;
-
- strcpy(outfile, file);
- strcat(outfile, GZ_SUFFIX);
-
- in = fopen(file, "rb");
- if (in == NULL) {
- perror(file);
- exit(1);
- }
- out = gzopen(outfile, mode);
- if (out == NULL) {
- fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile);
- exit(1);
- }
- gz_compress(in, out);
-
- unlink(file);
-}
-
-
-/* ===========================================================================
- * Uncompress the given file and remove the original.
- */
-void file_uncompress(file)
- char *file;
-{
- local char buf[MAX_NAME_LEN];
- char *infile, *outfile;
- FILE *out;
- gzFile in;
- uInt len = (uInt)strlen(file);
-
- strcpy(buf, file);
-
- if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) {
- infile = file;
- outfile = buf;
- outfile[len-3] = '\0';
- } else {
- outfile = file;
- infile = buf;
- strcat(infile, GZ_SUFFIX);
- }
- in = gzopen(infile, "rb");
- if (in == NULL) {
- fprintf(stderr, "%s: can't gzopen %s\n", prog, infile);
- exit(1);
- }
- out = fopen(outfile, "wb");
- if (out == NULL) {
- perror(file);
- exit(1);
- }
-
- gz_uncompress(in, out);
-
- unlink(infile);
-}
-
-
-/* ===========================================================================
- * Usage: minigzip [-d] [-f] [-h] [-r] [-1 to -9] [files...]
- * -d : decompress
- * -f : compress with Z_FILTERED
- * -h : compress with Z_HUFFMAN_ONLY
- * -r : compress with Z_RLE
- * -1 to -9 : compression level
- */
-
-int main(argc, argv)
- int argc;
- char *argv[];
-{
- int uncompr = 0;
- gzFile file;
- char outmode[20];
-
- strcpy(outmode, "wb6 ");
-
- prog = argv[0];
- argc--, argv++;
-
- while (argc > 0) {
- if (strcmp(*argv, "-d") == 0)
- uncompr = 1;
- else if (strcmp(*argv, "-f") == 0)
- outmode[3] = 'f';
- else if (strcmp(*argv, "-h") == 0)
- outmode[3] = 'h';
- else if (strcmp(*argv, "-r") == 0)
- outmode[3] = 'R';
- else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' &&
- (*argv)[2] == 0)
- outmode[2] = (*argv)[1];
- else
- break;
- argc--, argv++;
- }
- if (outmode[3] == ' ')
- outmode[3] = 0;
- if (argc == 0) {
- SET_BINARY_MODE(stdin);
- SET_BINARY_MODE(stdout);
- if (uncompr) {
- file = gzdopen(fileno(stdin), "rb");
- if (file == NULL) error("can't gzdopen stdin");
- gz_uncompress(file, stdout);
- } else {
- file = gzdopen(fileno(stdout), outmode);
- if (file == NULL) error("can't gzdopen stdout");
- gz_compress(stdin, file);
- }
- } else {
- do {
- if (uncompr) {
- file_uncompress(*argv);
- } else {
- file_compress(*argv, outmode);
- }
- } while (argv++, --argc);
- }
- return 0;
-}
diff --git a/source4/lib/zlib/msdos/Makefile.bor b/source4/lib/zlib/msdos/Makefile.bor
deleted file mode 100644
index 8f8132d122..0000000000
--- a/source4/lib/zlib/msdos/Makefile.bor
+++ /dev/null
@@ -1,109 +0,0 @@
-# Makefile for zlib
-# Borland C++
-# Last updated: 15-Mar-2003
-
-# To use, do "make -fmakefile.bor"
-# To compile in small model, set below: MODEL=s
-
-# WARNING: the small model is supported but only for small values of
-# MAX_WBITS and MAX_MEM_LEVEL. For example:
-# -DMAX_WBITS=11 -DDEF_WBITS=11 -DMAX_MEM_LEVEL=3
-# If you wish to reduce the memory requirements (default 256K for big
-# objects plus a few K), you can add to the LOC macro below:
-# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14
-# See zconf.h for details about the memory requirements.
-
-# ------------ Turbo C++, Borland C++ ------------
-
-# Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7)
-# should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added
-# to the declaration of LOC here:
-LOC = $(LOCAL_ZLIB)
-
-# type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc.
-CPU_TYP = 0
-
-# memory model: one of s, m, c, l (small, medium, compact, large)
-MODEL=l
-
-# replace bcc with tcc for Turbo C++ 1.0, with bcc32 for the 32 bit version
-CC=bcc
-LD=bcc
-AR=tlib
-
-# compiler flags
-# replace "-O2" by "-O -G -a -d" for Turbo C++ 1.0
-CFLAGS=-O2 -Z -m$(MODEL) $(LOC)
-
-LDFLAGS=-m$(MODEL) -f-
-
-
-# variables
-ZLIB_LIB = zlib_$(MODEL).lib
-
-OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj
-OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj
-OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj
-OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj
-
-
-# targets
-all: $(ZLIB_LIB) example.exe minigzip.exe
-
-.c.obj:
- $(CC) -c $(CFLAGS) $*.c
-
-adler32.obj: adler32.c zlib.h zconf.h
-
-compress.obj: compress.c zlib.h zconf.h
-
-crc32.obj: crc32.c zlib.h zconf.h crc32.h
-
-deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h
-
-gzio.obj: gzio.c zutil.h zlib.h zconf.h
-
-infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h inffixed.h
-
-inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h
-
-inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h inffixed.h
-
-inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h
-
-trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h
-
-uncompr.obj: uncompr.c zlib.h zconf.h
-
-zutil.obj: zutil.c zutil.h zlib.h zconf.h
-
-example.obj: example.c zlib.h zconf.h
-
-minigzip.obj: minigzip.c zlib.h zconf.h
-
-
-# the command line is cut to fit in the MS-DOS 128 byte limit:
-$(ZLIB_LIB): $(OBJ1) $(OBJ2)
- -del $(ZLIB_LIB)
- $(AR) $(ZLIB_LIB) $(OBJP1)
- $(AR) $(ZLIB_LIB) $(OBJP2)
-
-example.exe: example.obj $(ZLIB_LIB)
- $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB)
-
-minigzip.exe: minigzip.obj $(ZLIB_LIB)
- $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB)
-
-test: example.exe minigzip.exe
- example
- echo hello world | minigzip | minigzip -d
-
-clean:
- -del *.obj
- -del *.lib
- -del *.exe
- -del zlib_*.bak
- -del foo.gz
diff --git a/source4/lib/zlib/msdos/Makefile.dj2 b/source4/lib/zlib/msdos/Makefile.dj2
deleted file mode 100644
index 283d1d9616..0000000000
--- a/source4/lib/zlib/msdos/Makefile.dj2
+++ /dev/null
@@ -1,104 +0,0 @@
-# Makefile for zlib. Modified for djgpp v2.0 by F. J. Donahoe, 3/15/96.
-# Copyright (C) 1995-1998 Jean-loup Gailly.
-# For conditions of distribution and use, see copyright notice in zlib.h
-
-# To compile, or to compile and test, type:
-#
-# make -fmakefile.dj2; make test -fmakefile.dj2
-#
-# To install libz.a, zconf.h and zlib.h in the djgpp directories, type:
-#
-# make install -fmakefile.dj2
-#
-# after first defining LIBRARY_PATH and INCLUDE_PATH in djgpp.env as
-# in the sample below if the pattern of the DJGPP distribution is to
-# be followed. Remember that, while <sp>'es around <=> are ignored in
-# makefiles, they are *not* in batch files or in djgpp.env.
-# - - - - -
-# [make]
-# INCLUDE_PATH=%\>;INCLUDE_PATH%%\DJDIR%\include
-# LIBRARY_PATH=%\>;LIBRARY_PATH%%\DJDIR%\lib
-# BUTT=-m486
-# - - - - -
-# Alternately, these variables may be defined below, overriding the values
-# in djgpp.env, as
-# INCLUDE_PATH=c:\usr\include
-# LIBRARY_PATH=c:\usr\lib
-
-CC=gcc
-
-#CFLAGS=-MMD -O
-#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
-#CFLAGS=-MMD -g -DDEBUG
-CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
- -Wstrict-prototypes -Wmissing-prototypes
-
-# If cp.exe is available, replace "copy /Y" with "cp -fp" .
-CP=copy /Y
-# If gnu install.exe is available, replace $(CP) with ginstall.
-INSTALL=$(CP)
-# The default value of RM is "rm -f." If "rm.exe" is found, comment out:
-RM=del
-LDLIBS=-L. -lz
-LD=$(CC) -s -o
-LDSHARED=$(CC)
-
-INCL=zlib.h zconf.h
-LIBS=libz.a
-
-AR=ar rcs
-
-prefix=/usr/local
-exec_prefix = $(prefix)
-
-OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
- zutil.o inflate.o infback.o inftrees.o inffast.o
-
-OBJA =
-# to use the asm code: make OBJA=match.o
-
-TEST_OBJS = example.o minigzip.o
-
-all: example.exe minigzip.exe
-
-check: test
-test: all
- ./example
- echo hello world | .\minigzip | .\minigzip -d
-
-%.o : %.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-libz.a: $(OBJS) $(OBJA)
- $(AR) $@ $(OBJS) $(OBJA)
-
-%.exe : %.o $(LIBS)
- $(LD) $@ $< $(LDLIBS)
-
-# INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env .
-
-.PHONY : uninstall clean
-
-install: $(INCL) $(LIBS)
- -@if not exist $(INCLUDE_PATH)\nul mkdir $(INCLUDE_PATH)
- -@if not exist $(LIBRARY_PATH)\nul mkdir $(LIBRARY_PATH)
- $(INSTALL) zlib.h $(INCLUDE_PATH)
- $(INSTALL) zconf.h $(INCLUDE_PATH)
- $(INSTALL) libz.a $(LIBRARY_PATH)
-
-uninstall:
- $(RM) $(INCLUDE_PATH)\zlib.h
- $(RM) $(INCLUDE_PATH)\zconf.h
- $(RM) $(LIBRARY_PATH)\libz.a
-
-clean:
- $(RM) *.d
- $(RM) *.o
- $(RM) *.exe
- $(RM) libz.a
- $(RM) foo.gz
-
-DEPS := $(wildcard *.d)
-ifneq ($(DEPS),)
-include $(DEPS)
-endif
diff --git a/source4/lib/zlib/msdos/Makefile.emx b/source4/lib/zlib/msdos/Makefile.emx
deleted file mode 100644
index ed4c31fbbd..0000000000
--- a/source4/lib/zlib/msdos/Makefile.emx
+++ /dev/null
@@ -1,69 +0,0 @@
-# Makefile for zlib. Modified for emx 0.9c by Chr. Spieler, 6/17/98.
-# Copyright (C) 1995-1998 Jean-loup Gailly.
-# For conditions of distribution and use, see copyright notice in zlib.h
-
-# To compile, or to compile and test, type:
-#
-# make -fmakefile.emx; make test -fmakefile.emx
-#
-
-CC=gcc
-
-#CFLAGS=-MMD -O
-#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
-#CFLAGS=-MMD -g -DDEBUG
-CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
- -Wstrict-prototypes -Wmissing-prototypes
-
-# If cp.exe is available, replace "copy /Y" with "cp -fp" .
-CP=copy /Y
-# If gnu install.exe is available, replace $(CP) with ginstall.
-INSTALL=$(CP)
-# The default value of RM is "rm -f." If "rm.exe" is found, comment out:
-RM=del
-LDLIBS=-L. -lzlib
-LD=$(CC) -s -o
-LDSHARED=$(CC)
-
-INCL=zlib.h zconf.h
-LIBS=zlib.a
-
-AR=ar rcs
-
-prefix=/usr/local
-exec_prefix = $(prefix)
-
-OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
- zutil.o inflate.o infback.o inftrees.o inffast.o
-
-TEST_OBJS = example.o minigzip.o
-
-all: example.exe minigzip.exe
-
-test: all
- ./example
- echo hello world | .\minigzip | .\minigzip -d
-
-%.o : %.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-zlib.a: $(OBJS)
- $(AR) $@ $(OBJS)
-
-%.exe : %.o $(LIBS)
- $(LD) $@ $< $(LDLIBS)
-
-
-.PHONY : clean
-
-clean:
- $(RM) *.d
- $(RM) *.o
- $(RM) *.exe
- $(RM) zlib.a
- $(RM) foo.gz
-
-DEPS := $(wildcard *.d)
-ifneq ($(DEPS),)
-include $(DEPS)
-endif
diff --git a/source4/lib/zlib/msdos/Makefile.msc b/source4/lib/zlib/msdos/Makefile.msc
deleted file mode 100644
index b8fc665efb..0000000000
--- a/source4/lib/zlib/msdos/Makefile.msc
+++ /dev/null
@@ -1,106 +0,0 @@
-# Makefile for zlib
-# Microsoft C 5.1 or later
-# Last updated: 19-Mar-2003
-
-# To use, do "make makefile.msc"
-# To compile in small model, set below: MODEL=S
-
-# If you wish to reduce the memory requirements (default 256K for big
-# objects plus a few K), you can add to the LOC macro below:
-# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14
-# See zconf.h for details about the memory requirements.
-
-# ------------- Microsoft C 5.1 and later -------------
-
-# Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7)
-# should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added
-# to the declaration of LOC here:
-LOC = $(LOCAL_ZLIB)
-
-# Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc.
-CPU_TYP = 0
-
-# Memory model: one of S, M, C, L (small, medium, compact, large)
-MODEL=L
-
-CC=cl
-CFLAGS=-nologo -A$(MODEL) -G$(CPU_TYP) -W3 -Oait -Gs $(LOC)
-#-Ox generates bad code with MSC 5.1
-LIB_CFLAGS=-Zl $(CFLAGS)
-
-LD=link
-LDFLAGS=/noi/e/st:0x1500/noe/farcall/packcode
-# "/farcall/packcode" are only useful for `large code' memory models
-# but should be a "no-op" for small code models.
-
-
-# variables
-ZLIB_LIB = zlib_$(MODEL).lib
-
-OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj
-OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj
-
-
-# targets
-all: $(ZLIB_LIB) example.exe minigzip.exe
-
-.c.obj:
- $(CC) -c $(LIB_CFLAGS) $*.c
-
-adler32.obj: adler32.c zlib.h zconf.h
-
-compress.obj: compress.c zlib.h zconf.h
-
-crc32.obj: crc32.c zlib.h zconf.h crc32.h
-
-deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h
-
-gzio.obj: gzio.c zutil.h zlib.h zconf.h
-
-infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h inffixed.h
-
-inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h
-
-inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h inffixed.h
-
-inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h
-
-trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h
-
-uncompr.obj: uncompr.c zlib.h zconf.h
-
-zutil.obj: zutil.c zutil.h zlib.h zconf.h
-
-example.obj: example.c zlib.h zconf.h
- $(CC) -c $(CFLAGS) $*.c
-
-minigzip.obj: minigzip.c zlib.h zconf.h
- $(CC) -c $(CFLAGS) $*.c
-
-
-# the command line is cut to fit in the MS-DOS 128 byte limit:
-$(ZLIB_LIB): $(OBJ1) $(OBJ2)
- if exist $(ZLIB_LIB) del $(ZLIB_LIB)
- lib $(ZLIB_LIB) $(OBJ1);
- lib $(ZLIB_LIB) $(OBJ2);
-
-example.exe: example.obj $(ZLIB_LIB)
- $(LD) $(LDFLAGS) example.obj,,,$(ZLIB_LIB);
-
-minigzip.exe: minigzip.obj $(ZLIB_LIB)
- $(LD) $(LDFLAGS) minigzip.obj,,,$(ZLIB_LIB);
-
-test: example.exe minigzip.exe
- example
- echo hello world | minigzip | minigzip -d
-
-clean:
- -del *.obj
- -del *.lib
- -del *.exe
- -del *.map
- -del zlib_*.bak
- -del foo.gz
diff --git a/source4/lib/zlib/msdos/Makefile.tc b/source4/lib/zlib/msdos/Makefile.tc
deleted file mode 100644
index 480750ade2..0000000000
--- a/source4/lib/zlib/msdos/Makefile.tc
+++ /dev/null
@@ -1,94 +0,0 @@
-# Makefile for zlib
-# Turbo C 2.01, Turbo C++ 1.01
-# Last updated: 15-Mar-2003
-
-# To use, do "make -fmakefile.tc"
-# To compile in small model, set below: MODEL=s
-
-# WARNING: the small model is supported but only for small values of
-# MAX_WBITS and MAX_MEM_LEVEL. For example:
-# -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
-# If you wish to reduce the memory requirements (default 256K for big
-# objects plus a few K), you can add to CFLAGS below:
-# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14
-# See zconf.h for details about the memory requirements.
-
-# ------------ Turbo C 2.01, Turbo C++ 1.01 ------------
-MODEL=l
-CC=tcc
-LD=tcc
-AR=tlib
-# CFLAGS=-O2 -G -Z -m$(MODEL) -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
-CFLAGS=-O2 -G -Z -m$(MODEL)
-LDFLAGS=-m$(MODEL) -f-
-
-
-# variables
-ZLIB_LIB = zlib_$(MODEL).lib
-
-OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj
-OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj
-OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj
-OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj
-
-
-# targets
-all: $(ZLIB_LIB) example.exe minigzip.exe
-
-.c.obj:
- $(CC) -c $(CFLAGS) $*.c
-
-adler32.obj: adler32.c zlib.h zconf.h
-
-compress.obj: compress.c zlib.h zconf.h
-
-crc32.obj: crc32.c zlib.h zconf.h crc32.h
-
-deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h
-
-gzio.obj: gzio.c zutil.h zlib.h zconf.h
-
-infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h inffixed.h
-
-inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h
-
-inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h inffixed.h
-
-inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h
-
-trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h
-
-uncompr.obj: uncompr.c zlib.h zconf.h
-
-zutil.obj: zutil.c zutil.h zlib.h zconf.h
-
-example.obj: example.c zlib.h zconf.h
-
-minigzip.obj: minigzip.c zlib.h zconf.h
-
-
-# the command line is cut to fit in the MS-DOS 128 byte limit:
-$(ZLIB_LIB): $(OBJ1) $(OBJ2)
- -del $(ZLIB_LIB)
- $(AR) $(ZLIB_LIB) $(OBJP1)
- $(AR) $(ZLIB_LIB) $(OBJP2)
-
-example.exe: example.obj $(ZLIB_LIB)
- $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB)
-
-minigzip.exe: minigzip.obj $(ZLIB_LIB)
- $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB)
-
-test: example.exe minigzip.exe
- example
- echo hello world | minigzip | minigzip -d
-
-clean:
- -del *.obj
- -del *.lib
- -del *.exe
- -del zlib_*.bak
- -del foo.gz
diff --git a/source4/lib/zlib/old/Makefile.riscos b/source4/lib/zlib/old/Makefile.riscos
deleted file mode 100644
index 57e29d3fba..0000000000
--- a/source4/lib/zlib/old/Makefile.riscos
+++ /dev/null
@@ -1,151 +0,0 @@
-# Project: zlib_1_03
-# Patched for zlib 1.1.2 rw@shadow.org.uk 19980430
-# test works out-of-the-box, installs `somewhere' on demand
-
-# Toolflags:
-CCflags = -c -depend !Depend -IC: -g -throwback -DRISCOS -fah
-C++flags = -c -depend !Depend -IC: -throwback
-Linkflags = -aif -c++ -o $@
-ObjAsmflags = -throwback -NoCache -depend !Depend
-CMHGflags =
-LibFileflags = -c -l -o $@
-Squeezeflags = -o $@
-
-# change the line below to where _you_ want the library installed.
-libdest = lib:zlib
-
-# Final targets:
-@.lib: @.o.adler32 @.o.compress @.o.crc32 @.o.deflate @.o.gzio \
- @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil @.o.trees \
- @.o.uncompr @.o.zutil
- LibFile $(LibFileflags) @.o.adler32 @.o.compress @.o.crc32 @.o.deflate \
- @.o.gzio @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil \
- @.o.trees @.o.uncompr @.o.zutil
-test: @.minigzip @.example @.lib
- @copy @.lib @.libc A~C~DF~L~N~P~Q~RS~TV
- @echo running tests: hang on.
- @/@.minigzip -f -9 libc
- @/@.minigzip -d libc-gz
- @/@.minigzip -f -1 libc
- @/@.minigzip -d libc-gz
- @/@.minigzip -h -9 libc
- @/@.minigzip -d libc-gz
- @/@.minigzip -h -1 libc
- @/@.minigzip -d libc-gz
- @/@.minigzip -9 libc
- @/@.minigzip -d libc-gz
- @/@.minigzip -1 libc
- @/@.minigzip -d libc-gz
- @diff @.lib @.libc
- @echo that should have reported '@.lib and @.libc identical' if you have diff.
- @/@.example @.fred @.fred
- @echo that will have given lots of hello!'s.
-
-@.minigzip: @.o.minigzip @.lib C:o.Stubs
- Link $(Linkflags) @.o.minigzip @.lib C:o.Stubs
-@.example: @.o.example @.lib C:o.Stubs
- Link $(Linkflags) @.o.example @.lib C:o.Stubs
-
-install: @.lib
- cdir $(libdest)
- cdir $(libdest).h
- @copy @.h.zlib $(libdest).h.zlib A~C~DF~L~N~P~Q~RS~TV
- @copy @.h.zconf $(libdest).h.zconf A~C~DF~L~N~P~Q~RS~TV
- @copy @.lib $(libdest).lib A~C~DF~L~N~P~Q~RS~TV
- @echo okay, installed zlib in $(libdest)
-
-clean:; remove @.minigzip
- remove @.example
- remove @.libc
- -wipe @.o.* F~r~cV
- remove @.fred
-
-# User-editable dependencies:
-.c.o:
- cc $(ccflags) -o $@ $<
-
-# Static dependencies:
-
-# Dynamic dependencies:
-o.example: c.example
-o.example: h.zlib
-o.example: h.zconf
-o.minigzip: c.minigzip
-o.minigzip: h.zlib
-o.minigzip: h.zconf
-o.adler32: c.adler32
-o.adler32: h.zlib
-o.adler32: h.zconf
-o.compress: c.compress
-o.compress: h.zlib
-o.compress: h.zconf
-o.crc32: c.crc32
-o.crc32: h.zlib
-o.crc32: h.zconf
-o.deflate: c.deflate
-o.deflate: h.deflate
-o.deflate: h.zutil
-o.deflate: h.zlib
-o.deflate: h.zconf
-o.gzio: c.gzio
-o.gzio: h.zutil
-o.gzio: h.zlib
-o.gzio: h.zconf
-o.infblock: c.infblock
-o.infblock: h.zutil
-o.infblock: h.zlib
-o.infblock: h.zconf
-o.infblock: h.infblock
-o.infblock: h.inftrees
-o.infblock: h.infcodes
-o.infblock: h.infutil
-o.infcodes: c.infcodes
-o.infcodes: h.zutil
-o.infcodes: h.zlib
-o.infcodes: h.zconf
-o.infcodes: h.inftrees
-o.infcodes: h.infblock
-o.infcodes: h.infcodes
-o.infcodes: h.infutil
-o.infcodes: h.inffast
-o.inffast: c.inffast
-o.inffast: h.zutil
-o.inffast: h.zlib
-o.inffast: h.zconf
-o.inffast: h.inftrees
-o.inffast: h.infblock
-o.inffast: h.infcodes
-o.inffast: h.infutil
-o.inffast: h.inffast
-o.inflate: c.inflate
-o.inflate: h.zutil
-o.inflate: h.zlib
-o.inflate: h.zconf
-o.inflate: h.infblock
-o.inftrees: c.inftrees
-o.inftrees: h.zutil
-o.inftrees: h.zlib
-o.inftrees: h.zconf
-o.inftrees: h.inftrees
-o.inftrees: h.inffixed
-o.infutil: c.infutil
-o.infutil: h.zutil
-o.infutil: h.zlib
-o.infutil: h.zconf
-o.infutil: h.infblock
-o.infutil: h.inftrees
-o.infutil: h.infcodes
-o.infutil: h.infutil
-o.trees: c.trees
-o.trees: h.deflate
-o.trees: h.zutil
-o.trees: h.zlib
-o.trees: h.zconf
-o.trees: h.trees
-o.uncompr: c.uncompr
-o.uncompr: h.zlib
-o.uncompr: h.zconf
-o.zutil: c.zutil
-o.zutil: h.zutil
-o.zutil: h.zlib
-o.zutil: h.zconf
diff --git a/source4/lib/zlib/old/README b/source4/lib/zlib/old/README
deleted file mode 100644
index 800bf07982..0000000000
--- a/source4/lib/zlib/old/README
+++ /dev/null
@@ -1,3 +0,0 @@
-This directory contains files that have not been updated for zlib 1.2.x
-
-(Volunteers are encouraged to help clean this up. Thanks.)
diff --git a/source4/lib/zlib/old/descrip.mms b/source4/lib/zlib/old/descrip.mms
deleted file mode 100644
index 7066da5b55..0000000000
--- a/source4/lib/zlib/old/descrip.mms
+++ /dev/null
@@ -1,48 +0,0 @@
-# descrip.mms: MMS description file for building zlib on VMS
-# written by Martin P.J. Zinser <m.zinser@gsi.de>
-
-cc_defs =
-c_deb =
-
-.ifdef __DECC__
-pref = /prefix=all
-.endif
-
-OBJS = adler32.obj, compress.obj, crc32.obj, gzio.obj, uncompr.obj,\
- deflate.obj, trees.obj, zutil.obj, inflate.obj, infblock.obj,\
- inftrees.obj, infcodes.obj, infutil.obj, inffast.obj
-
-CFLAGS= $(C_DEB) $(CC_DEFS) $(PREF)
-
-all : example.exe minigzip.exe
- @ write sys$output " Example applications available"
-libz.olb : libz.olb($(OBJS))
- @ write sys$output " libz available"
-
-example.exe : example.obj libz.olb
- link example,libz.olb/lib
-
-minigzip.exe : minigzip.obj libz.olb
- link minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib
-
-clean :
- delete *.obj;*,libz.olb;*
-
-
-# Other dependencies.
-adler32.obj : zutil.h zlib.h zconf.h
-compress.obj : zlib.h zconf.h
-crc32.obj : zutil.h zlib.h zconf.h
-deflate.obj : deflate.h zutil.h zlib.h zconf.h
-example.obj : zlib.h zconf.h
-gzio.obj : zutil.h zlib.h zconf.h
-infblock.obj : zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h
-infcodes.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h infcodes.h inffast.h
-inffast.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h
-inflate.obj : zutil.h zlib.h zconf.h infblock.h
-inftrees.obj : zutil.h zlib.h zconf.h inftrees.h
-infutil.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h
-minigzip.obj : zlib.h zconf.h
-trees.obj : deflate.h zutil.h zlib.h zconf.h
-uncompr.obj : zlib.h zconf.h
-zutil.obj : zutil.h zlib.h zconf.h
diff --git a/source4/lib/zlib/old/os2/Makefile.os2 b/source4/lib/zlib/old/os2/Makefile.os2
deleted file mode 100644
index a105aaa5bb..0000000000
--- a/source4/lib/zlib/old/os2/Makefile.os2
+++ /dev/null
@@ -1,136 +0,0 @@
-# Makefile for zlib under OS/2 using GCC (PGCC)
-# For conditions of distribution and use, see copyright notice in zlib.h
-
-# To compile and test, type:
-# cp Makefile.os2 ..
-# cd ..
-# make -f Makefile.os2 test
-
-# This makefile will build a static library z.lib, a shared library
-# z.dll and a import library zdll.lib. You can use either z.lib or
-# zdll.lib by specifying either -lz or -lzdll on gcc's command line
-
-CC=gcc -Zomf -s
-
-CFLAGS=-O6 -Wall
-#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
-#CFLAGS=-g -DDEBUG
-#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
-# -Wstrict-prototypes -Wmissing-prototypes
-
-#################### BUG WARNING: #####################
-## infcodes.c hits a bug in pgcc-1.0, so you have to use either
-## -O# where # <= 4 or one of (-fno-ommit-frame-pointer or -fno-force-mem)
-## This bug is reportedly fixed in pgcc >1.0, but this was not tested
-CFLAGS+=-fno-force-mem
-
-LDFLAGS=-s -L. -lzdll -Zcrtdll
-LDSHARED=$(CC) -s -Zomf -Zdll -Zcrtdll
-
-VER=1.1.0
-ZLIB=z.lib
-SHAREDLIB=z.dll
-SHAREDLIBIMP=zdll.lib
-LIBS=$(ZLIB) $(SHAREDLIB) $(SHAREDLIBIMP)
-
-AR=emxomfar cr
-IMPLIB=emximp
-RANLIB=echo
-TAR=tar
-SHELL=bash
-
-prefix=/usr/local
-exec_prefix = $(prefix)
-
-OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
- zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
-
-TEST_OBJS = example.o minigzip.o
-
-DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] *.[ch] descrip.mms \
- algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \
- nt/Makefile.nt nt/zlib.dnt contrib/README.contrib contrib/*.txt \
- contrib/asm386/*.asm contrib/asm386/*.c \
- contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/iostream/*.cpp \
- contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \
- contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32
-
-all: example.exe minigzip.exe
-
-test: all
- @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
- echo hello world | ./minigzip | ./minigzip -d || \
- echo ' *** minigzip test FAILED ***' ; \
- if ./example; then \
- echo ' *** zlib test OK ***'; \
- else \
- echo ' *** zlib test FAILED ***'; \
- fi
-
-$(ZLIB): $(OBJS)
- $(AR) $@ $(OBJS)
- -@ ($(RANLIB) $@ || true) >/dev/null 2>&1
-
-$(SHAREDLIB): $(OBJS) os2/z.def
- $(LDSHARED) -o $@ $^
-
-$(SHAREDLIBIMP): os2/z.def
- $(IMPLIB) -o $@ $^
-
-example.exe: example.o $(LIBS)
- $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
-
-minigzip.exe: minigzip.o $(LIBS)
- $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
-
-clean:
- rm -f *.o *~ example minigzip libz.a libz.so* foo.gz
-
-distclean: clean
-
-zip:
- mv Makefile Makefile~; cp -p Makefile.in Makefile
- rm -f test.c ztest*.c
- v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
- zip -ul9 zlib$$v $(DISTFILES)
- mv Makefile~ Makefile
-
-dist:
- mv Makefile Makefile~; cp -p Makefile.in Makefile
- rm -f test.c ztest*.c
- d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
- rm -f $$d.tar.gz; \
- if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \
- files=""; \
- for f in $(DISTFILES); do files="$$files $$d/$$f"; done; \
- cd ..; \
- GZIP=-9 $(TAR) chofz $$d/$$d.tar.gz $$files; \
- if test ! -d $$d; then rm -f $$d; fi
- mv Makefile~ Makefile
-
-tags:
- etags *.[ch]
-
-depend:
- makedepend -- $(CFLAGS) -- *.[ch]
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-adler32.o: zlib.h zconf.h
-compress.o: zlib.h zconf.h
-crc32.o: zlib.h zconf.h
-deflate.o: deflate.h zutil.h zlib.h zconf.h
-example.o: zlib.h zconf.h
-gzio.o: zutil.h zlib.h zconf.h
-infblock.o: infblock.h inftrees.h infcodes.h infutil.h zutil.h zlib.h zconf.h
-infcodes.o: zutil.h zlib.h zconf.h
-infcodes.o: inftrees.h infblock.h infcodes.h infutil.h inffast.h
-inffast.o: zutil.h zlib.h zconf.h inftrees.h
-inffast.o: infblock.h infcodes.h infutil.h inffast.h
-inflate.o: zutil.h zlib.h zconf.h infblock.h
-inftrees.o: zutil.h zlib.h zconf.h inftrees.h
-infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h
-minigzip.o: zlib.h zconf.h
-trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
-uncompr.o: zlib.h zconf.h
-zutil.o: zutil.h zlib.h zconf.h
diff --git a/source4/lib/zlib/old/os2/zlib.def b/source4/lib/zlib/old/os2/zlib.def
deleted file mode 100644
index 4c753f1a3b..0000000000
--- a/source4/lib/zlib/old/os2/zlib.def
+++ /dev/null
@@ -1,51 +0,0 @@
-;
-; Slightly modified version of ../nt/zlib.dnt :-)
-;
-
-LIBRARY Z
-DESCRIPTION "Zlib compression library for OS/2"
-CODE PRELOAD MOVEABLE DISCARDABLE
-DATA PRELOAD MOVEABLE MULTIPLE
-
-EXPORTS
- adler32
- compress
- crc32
- deflate
- deflateCopy
- deflateEnd
- deflateInit2_
- deflateInit_
- deflateParams
- deflateReset
- deflateSetDictionary
- gzclose
- gzdopen
- gzerror
- gzflush
- gzopen
- gzread
- gzwrite
- inflate
- inflateEnd
- inflateInit2_
- inflateInit_
- inflateReset
- inflateSetDictionary
- inflateSync
- uncompress
- zlibVersion
- gzprintf
- gzputc
- gzgetc
- gzseek
- gzrewind
- gztell
- gzeof
- gzsetparams
- zError
- inflateSyncPoint
- get_crc_table
- compress2
- gzputs
- gzgets
diff --git a/source4/lib/zlib/old/visual-basic.txt b/source4/lib/zlib/old/visual-basic.txt
deleted file mode 100644
index 57efe58124..0000000000
--- a/source4/lib/zlib/old/visual-basic.txt
+++ /dev/null
@@ -1,160 +0,0 @@
-See below some functions declarations for Visual Basic.
-
-Frequently Asked Question:
-
-Q: Each time I use the compress function I get the -5 error (not enough
- room in the output buffer).
-
-A: Make sure that the length of the compressed buffer is passed by
- reference ("as any"), not by value ("as long"). Also check that
- before the call of compress this length is equal to the total size of
- the compressed buffer and not zero.
-
-
-From: "Jon Caruana" <jon-net@usa.net>
-Subject: Re: How to port zlib declares to vb?
-Date: Mon, 28 Oct 1996 18:33:03 -0600
-
-Got the answer! (I haven't had time to check this but it's what I got, and
-looks correct):
-
-He has the following routines working:
- compress
- uncompress
- gzopen
- gzwrite
- gzread
- gzclose
-
-Declares follow: (Quoted from Carlos Rios <c_rios@sonda.cl>, in Vb4 form)
-
-#If Win16 Then 'Use Win16 calls.
-Declare Function compress Lib "ZLIB.DLL" (ByVal compr As
- String, comprLen As Any, ByVal buf As String, ByVal buflen
- As Long) As Integer
-Declare Function uncompress Lib "ZLIB.DLL" (ByVal uncompr
- As String, uncomprLen As Any, ByVal compr As String, ByVal
- lcompr As Long) As Integer
-Declare Function gzopen Lib "ZLIB.DLL" (ByVal filePath As
- String, ByVal mode As String) As Long
-Declare Function gzread Lib "ZLIB.DLL" (ByVal file As
- Long, ByVal uncompr As String, ByVal uncomprLen As Integer)
- As Integer
-Declare Function gzwrite Lib "ZLIB.DLL" (ByVal file As
- Long, ByVal uncompr As String, ByVal uncomprLen As Integer)
- As Integer
-Declare Function gzclose Lib "ZLIB.DLL" (ByVal file As
- Long) As Integer
-#Else
-Declare Function compress Lib "ZLIB32.DLL"
- (ByVal compr As String, comprLen As Any, ByVal buf As
- String, ByVal buflen As Long) As Integer
-Declare Function uncompress Lib "ZLIB32.DLL"
- (ByVal uncompr As String, uncomprLen As Any, ByVal compr As
- String, ByVal lcompr As Long) As Long
-Declare Function gzopen Lib "ZLIB32.DLL"
- (ByVal file As String, ByVal mode As String) As Long
-Declare Function gzread Lib "ZLIB32.DLL"
- (ByVal file As Long, ByVal uncompr As String, ByVal
- uncomprLen As Long) As Long
-Declare Function gzwrite Lib "ZLIB32.DLL"
- (ByVal file As Long, ByVal uncompr As String, ByVal
- uncomprLen As Long) As Long
-Declare Function gzclose Lib "ZLIB32.DLL"
- (ByVal file As Long) As Long
-#End If
-
--Jon Caruana
-jon-net@usa.net
-Microsoft Sitebuilder Network Level 1 Member - HTML Writer's Guild Member
-
-
-Here is another example from Michael <michael_borgsys@hotmail.com> that he
-says conforms to the VB guidelines, and that solves the problem of not
-knowing the uncompressed size by storing it at the end of the file:
-
-'Calling the functions:
-'bracket meaning: <parameter> [optional] {Range of possible values}
-'Call subCompressFile(<path with filename to compress> [, <path with
-filename to write to>, [level of compression {1..9}]])
-'Call subUncompressFile(<path with filename to compress>)
-
-Option Explicit
-Private lngpvtPcnSml As Long 'Stores value for 'lngPercentSmaller'
-Private Const SUCCESS As Long = 0
-Private Const strFilExt As String = ".cpr"
-Private Declare Function lngfncCpr Lib "zlib.dll" Alias "compress2" (ByRef
-dest As Any, ByRef destLen As Any, ByRef src As Any, ByVal srcLen As Long,
-ByVal level As Integer) As Long
-Private Declare Function lngfncUcp Lib "zlib.dll" Alias "uncompress" (ByRef
-dest As Any, ByRef destLen As Any, ByRef src As Any, ByVal srcLen As Long)
-As Long
-
-Public Sub subCompressFile(ByVal strargOriFilPth As String, Optional ByVal
-strargCprFilPth As String, Optional ByVal intLvl As Integer = 9)
- Dim strCprPth As String
- Dim lngOriSiz As Long
- Dim lngCprSiz As Long
- Dim bytaryOri() As Byte
- Dim bytaryCpr() As Byte
- lngOriSiz = FileLen(strargOriFilPth)
- ReDim bytaryOri(lngOriSiz - 1)
- Open strargOriFilPth For Binary Access Read As #1
- Get #1, , bytaryOri()
- Close #1
- strCprPth = IIf(strargCprFilPth = "", strargOriFilPth, strargCprFilPth)
-'Select file path and name
- strCprPth = strCprPth & IIf(Right(strCprPth, Len(strFilExt)) =
-strFilExt, "", strFilExt) 'Add file extension if not exists
- lngCprSiz = (lngOriSiz * 1.01) + 12 'Compression needs temporary a bit
-more space then original file size
- ReDim bytaryCpr(lngCprSiz - 1)
- If lngfncCpr(bytaryCpr(0), lngCprSiz, bytaryOri(0), lngOriSiz, intLvl) =
-SUCCESS Then
- lngpvtPcnSml = (1# - (lngCprSiz / lngOriSiz)) * 100
- ReDim Preserve bytaryCpr(lngCprSiz - 1)
- Open strCprPth For Binary Access Write As #1
- Put #1, , bytaryCpr()
- Put #1, , lngOriSiz 'Add the the original size value to the end
-(last 4 bytes)
- Close #1
- Else
- MsgBox "Compression error"
- End If
- Erase bytaryCpr
- Erase bytaryOri
-End Sub
-
-Public Sub subUncompressFile(ByVal strargFilPth As String)
- Dim bytaryCpr() As Byte
- Dim bytaryOri() As Byte
- Dim lngOriSiz As Long
- Dim lngCprSiz As Long
- Dim strOriPth As String
- lngCprSiz = FileLen(strargFilPth)
- ReDim bytaryCpr(lngCprSiz - 1)
- Open strargFilPth For Binary Access Read As #1
- Get #1, , bytaryCpr()
- Close #1
- 'Read the original file size value:
- lngOriSiz = bytaryCpr(lngCprSiz - 1) * (2 ^ 24) _
- + bytaryCpr(lngCprSiz - 2) * (2 ^ 16) _
- + bytaryCpr(lngCprSiz - 3) * (2 ^ 8) _
- + bytaryCpr(lngCprSiz - 4)
- ReDim Preserve bytaryCpr(lngCprSiz - 5) 'Cut of the original size value
- ReDim bytaryOri(lngOriSiz - 1)
- If lngfncUcp(bytaryOri(0), lngOriSiz, bytaryCpr(0), lngCprSiz) = SUCCESS
-Then
- strOriPth = Left(strargFilPth, Len(strargFilPth) - Len(strFilExt))
- Open strOriPth For Binary Access Write As #1
- Put #1, , bytaryOri()
- Close #1
- Else
- MsgBox "Uncompression error"
- End If
- Erase bytaryCpr
- Erase bytaryOri
-End Sub
-Public Property Get lngPercentSmaller() As Long
- lngPercentSmaller = lngpvtPcnSml
-End Property
diff --git a/source4/lib/zlib/old/zlib.html b/source4/lib/zlib/old/zlib.html
deleted file mode 100644
index 8c1b190c38..0000000000
--- a/source4/lib/zlib/old/zlib.html
+++ /dev/null
@@ -1,971 +0,0 @@
-<html>
-<head>
- <title>
- zlib general purpose compression library version 1.1.4
- </title>
-</head>
-<body bgcolor="White" text="Black" vlink="Red" alink="Navy" link="Red">
-<!-- background="zlibbg.gif" -->
-
-<h1> zlib 1.1.4 Manual </h1>
-<hr>
-<a name="Contents"><h2>Contents</h2>
-<ol type="I">
-<li> <a href="#Prologue">Prologue</a>
-<li> <a href="#Introduction">Introduction</a>
-<li> <a href="#Utility functions">Utility functions</a>
-<li> <a href="#Basic functions">Basic functions</a>
-<li> <a href="#Advanced functions">Advanced functions</a>
-<li> <a href="#Constants">Constants</a>
-<li> <a href="#struct z_stream_s">struct z_stream_s</a>
-<li> <a href="#Checksum functions">Checksum functions</a>
-<li> <a href="#Misc">Misc</a>
-</ol>
-<hr>
-<a name="Prologue"><h2> Prologue </h2>
- 'zlib' general purpose compression library version 1.1.4, March 11th, 2002
- <p>
- Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler
- <p>
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
- <p>
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
- <ol>
- <li> The origin of this software must not be misrepresented ; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- <li> Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- <li> This notice may not be removed or altered from any source distribution.
- </ol>
-
- <dl>
- <dt>Jean-loup Gailly
- <dd><a href="mailto:jloup@gzip.org">jloup@gzip.org</a>
- <dt>Mark Adler
- <dd><a href="mailto:madler@alumni.caltech.edu">madler@alumni.caltech.edu</a>
- </dl>
-
- The data format used by the zlib library is described by RFCs (Request for
- Comments) 1950 to 1952 in the files
- <a href="ftp://ds.internic.net/rfc/rfc1950.txt">
- ftp://ds.internic.net/rfc/rfc1950.txt </a>
- (zlib format),
- <a href="ftp://ds.internic.net/rfc/rfc1951.txt">
- rfc1951.txt </a>
- (<a href="#deflate">deflate</a> format) and
- <a href="ftp://ds.internic.net/rfc/rfc1952.txt">
- rfc1952.txt </a>
- (gzip format).
- <p>
- This manual is converted from zlib.h by
- <a href="mailto:piaip@csie.ntu.edu.tw"> piaip </a>
- <p>
- Visit <a href="http://ftp.cdrom.com/pub/infozip/zlib/">
- http://ftp.cdrom.com/pub/infozip/zlib/</a>
- for the official zlib web page.
- <p>
-
-<hr>
-<a name="Introduction"><h2> Introduction </h2>
- The 'zlib' compression library provides in-memory compression and
- decompression functions, including integrity checks of the uncompressed
- data. This version of the library supports only one compression method
- (deflation) but other algorithms will be added later and will have the same
- stream interface.
- <p>
-
- Compression can be done in a single step if the buffers are large
- enough (for example if an input file is mmap'ed), or can be done by
- repeated calls of the compression function. In the latter case, the
- application must provide more input and/or consume the output
- (providing more output space) before each call.
- <p>
-
- The library also supports reading and writing files in gzip (.gz) format
- with an interface similar to that of stdio.
- <p>
-
- The library does not install any signal handler. The decoder checks
- the consistency of the compressed data, so the library should never
- crash even in case of corrupted input.
- <p>
-
-<hr>
-<a name="Utility functions"><h2> Utility functions </h2>
- The following utility functions are implemented on top of the
- <a href="#Basic functions">basic stream-oriented functions</a>.
- To simplify the interface, some
- default options are assumed (compression level and memory usage,
- standard memory allocation functions). The source code of these
- utility functions can easily be modified if you need special options.
-<h3> Function list </h3>
-<ul>
-<li> int <a href="#compress">compress</a> (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
-<li> int <a href="#compress2">compress2</a> (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level);
-<li> int <a href="#uncompress">uncompress</a> (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
-<li> typedef voidp gzFile;
-<li> gzFile <a href="#gzopen">gzopen</a> (const char *path, const char *mode);
-<li> gzFile <a href="#gzdopen">gzdopen</a> (int fd, const char *mode);
-<li> int <a href="#gzsetparams">gzsetparams</a> (gzFile file, int level, int strategy);
-<li> int <a href="#gzread">gzread</a> (gzFile file, voidp buf, unsigned len);
-<li> int <a href="#gzwrite">gzwrite</a> (gzFile file, const voidp buf, unsigned len);
-<li> int VA <a href="#gzprintf">gzprintf</a> (gzFile file, const char *format, ...);
-<li> int <a href="#gzputs">gzputs</a> (gzFile file, const char *s);
-<li> char * <a href="#gzgets">gzgets</a> (gzFile file, char *buf, int len);
-<li> int <a href="#gzputc">gzputc</a> (gzFile file, int c);
-<li> int <a href="#gzgetc">gzgetc</a> (gzFile file);
-<li> int <a href="#gzflush">gzflush</a> (gzFile file, int flush);
-<li> z_off_t <a href="#gzseek">gzseek</a> (gzFile file, z_off_t offset, int whence);
-<li> z_off_t <a href="#gztell">gztell</a> (gzFile file);
-<li> int <a href="#gzrewind">gzrewind</a> (gzFile file);
-<li> int <a href="#gzeof">gzeof</a> (gzFile file);
-<li> int <a href="#gzclose">gzclose</a> (gzFile file);
-<li> const char * <a href="#gzerror">gzerror</a> (gzFile file, int *errnum);
-</ul>
-<h3> Function description </h3>
-<dl>
-<font color="Blue"><dt> int <a name="compress">compress</a> (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);</font>
-<dd>
- Compresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be at least 0.1% larger than
- sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
- compressed buffer.<p>
- This function can be used to <a href="#compress">compress</a> a whole file at once if the
- input file is mmap'ed.<p>
- <a href="#compress">compress</a> returns <a href="#Z_OK">Z_OK</a> if success, <a href="#Z_MEM_ERROR">Z_MEM_ERROR</a> if there was not
- enough memory, <a href="#Z_BUF_ERROR">Z_BUF_ERROR</a> if there was not enough room in the output
- buffer.<p>
-
-<font color="Blue"><dt> int <a name="compress2">compress2</a> (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level);</font>
-<dd>
- Compresses the source buffer into the destination buffer. The level
- parameter has the same meaning as in <a href="#deflateInit">deflateInit</a>. sourceLen is the byte
- length of the source buffer. Upon entry, destLen is the total size of the
- destination buffer, which must be at least 0.1% larger than sourceLen plus
- 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
- <p>
-
- <a href="#compress2">compress2</a> returns <a href="#Z_OK">Z_OK</a> if success, <a href="#Z_MEM_ERROR">Z_MEM_ERROR</a> if there was not enough
- memory, <a href="#Z_BUF_ERROR">Z_BUF_ERROR</a> if there was not enough room in the output buffer,
- <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if the level parameter is invalid.
- <p>
-
-<font color="Blue"><dt> int <a name="uncompress">uncompress</a> (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);</font>
-<dd>
- Decompresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be large enough to hold the
- entire uncompressed data. (The size of the uncompressed data must have
- been saved previously by the compressor and transmitted to the decompressor
- by some mechanism outside the scope of this compression library.)
- Upon exit, destLen is the actual size of the compressed buffer. <p>
- This function can be used to decompress a whole file at once if the
- input file is mmap'ed.
- <p>
-
- <a href="#uncompress">uncompress</a> returns <a href="#Z_OK">Z_OK</a> if success, <a href="#Z_MEM_ERROR">Z_MEM_ERROR</a> if there was not
- enough memory, <a href="#Z_BUF_ERROR">Z_BUF_ERROR</a> if there was not enough room in the output
- buffer, or <a href="#Z_DATA_ERROR">Z_DATA_ERROR</a> if the input data was corrupted.
- <p>
-
-<dt> typedef voidp gzFile;
-<dd> <p>
-
-<font color="Blue"><dt> gzFile <a name="gzopen">gzopen</a> (const char *path, const char *mode);</font>
-<dd>
- Opens a gzip (.gz) file for reading or writing. The mode parameter
- is as in fopen ("rb" or "wb") but can also include a compression level
- ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
- Huffman only compression as in "wb1h". (See the description
- of <a href="#deflateInit2">deflateInit2</a> for more information about the strategy parameter.)
- <p>
-
- <a href="#gzopen">gzopen</a> can be used to read a file which is not in gzip format ; in this
- case <a href="#gzread">gzread</a> will directly read from the file without decompression.
- <p>
-
- <a href="#gzopen">gzopen</a> returns NULL if the file could not be opened or if there was
- insufficient memory to allocate the (de)compression <a href="#state">state</a> ; errno
- can be checked to distinguish the two cases (if errno is zero, the
- zlib error is <a href="#Z_MEM_ERROR">Z_MEM_ERROR</a>).
- <p>
-
-<font color="Blue"><dt> gzFile <a name="gzdopen">gzdopen</a> (int fd, const char *mode);</font>
-<dd>
- <a href="#gzdopen">gzdopen</a>() associates a gzFile with the file descriptor fd. File
- descriptors are obtained from calls like open, dup, creat, pipe or
- fileno (in the file has been previously opened with fopen).
- The mode parameter is as in <a href="#gzopen">gzopen</a>.
- <p>
- The next call of <a href="#gzclose">gzclose</a> on the returned gzFile will also close the
- file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
- descriptor fd. If you want to keep fd open, use <a href="#gzdopen">gzdopen</a>(dup(fd), mode).
- <p>
- <a href="#gzdopen">gzdopen</a> returns NULL if there was insufficient memory to allocate
- the (de)compression <a href="#state">state</a>.
- <p>
-
-<font color="Blue"><dt> int <a name="gzsetparams">gzsetparams</a> (gzFile file, int level, int strategy);</font>
-<dd>
- Dynamically update the compression level or strategy. See the description
- of <a href="#deflateInit2">deflateInit2</a> for the meaning of these parameters.
- <p>
- <a href="#gzsetparams">gzsetparams</a> returns <a href="#Z_OK">Z_OK</a> if success, or <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if the file was not
- opened for writing.
- <p>
-
-<font color="Blue"><dt> int <a name="gzread">gzread</a> (gzFile file, voidp buf, unsigned len);</font>
-<dd>
- Reads the given number of uncompressed bytes from the compressed file.
- If the input file was not in gzip format, <a href="#gzread">gzread</a> copies the given number
- of bytes into the buffer.
- <p>
- <a href="#gzread">gzread</a> returns the number of uncompressed bytes actually read (0 for
- end of file, -1 for error).
- <p>
-
-<font color="Blue"><dt> int <a name="gzwrite">gzwrite</a> (gzFile file, const voidp buf, unsigned len);</font>
-<dd>
- Writes the given number of uncompressed bytes into the compressed file.
- <a href="#gzwrite">gzwrite</a> returns the number of uncompressed bytes actually written
- (0 in case of error).
- <p>
-
-<font color="Blue"><dt> int VA <a name="gzprintf">gzprintf</a> (gzFile file, const char *format, ...);</font>
-<dd>
- Converts, formats, and writes the args to the compressed file under
- control of the format string, as in fprintf. <a href="#gzprintf">gzprintf</a> returns the number of
- uncompressed bytes actually written (0 in case of error).
- <p>
-
-<font color="Blue"><dt> int <a name="gzputs">gzputs</a> (gzFile file, const char *s);</font>
-<dd>
- Writes the given null-terminated string to the compressed file, excluding
- the terminating null character.
- <p>
- <a href="#gzputs">gzputs</a> returns the number of characters written, or -1 in case of error.
- <p>
-
-<font color="Blue"><dt> char * <a name="gzgets">gzgets</a> (gzFile file, char *buf, int len);</font>
-<dd>
- Reads bytes from the compressed file until len-1 characters are read, or
- a newline character is read and transferred to buf, or an end-of-file
- condition is encountered. The string is then terminated with a null
- character.
- <p>
- <a href="#gzgets">gzgets</a> returns buf, or <a href="#Z_NULL">Z_NULL</a> in case of error.
- <p>
-
-<font color="Blue"><dt> int <a name="gzputc">gzputc</a> (gzFile file, int c);</font>
-<dd>
- Writes c, converted to an unsigned char, into the compressed file.
- <a href="#gzputc">gzputc</a> returns the value that was written, or -1 in case of error.
- <p>
-
-<font color="Blue"><dt> int <a name="gzgetc">gzgetc</a> (gzFile file);</font>
-<dd>
- Reads one byte from the compressed file. <a href="#gzgetc">gzgetc</a> returns this byte
- or -1 in case of end of file or error.
- <p>
-
-<font color="Blue"><dt> int <a name="gzflush">gzflush</a> (gzFile file, int flush);</font>
-<dd>
- Flushes all pending output into the compressed file. The parameter
- flush is as in the <a href="#deflate">deflate</a>() function. The return value is the zlib
- error number (see function <a href="#gzerror">gzerror</a> below). <a href="#gzflush">gzflush</a> returns <a href="#Z_OK">Z_OK</a> if
- the flush parameter is <a href="#Z_FINISH">Z_FINISH</a> and all output could be flushed.
- <p>
- <a href="#gzflush">gzflush</a> should be called only when strictly necessary because it can
- degrade compression.
- <p>
-
-<font color="Blue"><dt> z_off_t <a name="gzseek">gzseek</a> (gzFile file, z_off_t offset, int whence);</font>
-<dd>
- Sets the starting position for the next <a href="#gzread">gzread</a> or <a href="#gzwrite">gzwrite</a> on the
- given compressed file. The offset represents a number of bytes in the
- uncompressed data stream. The whence parameter is defined as in lseek(2);
- the value SEEK_END is not supported.
- <p>
- If the file is opened for reading, this function is emulated but can be
- extremely slow. If the file is opened for writing, only forward seeks are
- supported ; <a href="#gzseek">gzseek</a> then compresses a sequence of zeroes up to the new
- starting position.
- <p>
- <a href="#gzseek">gzseek</a> returns the resulting offset location as measured in bytes from
- the beginning of the uncompressed stream, or -1 in case of error, in
- particular if the file is opened for writing and the new starting position
- would be before the current position.
- <p>
-
-<font color="Blue"><dt> int <a name="gzrewind">gzrewind</a> (gzFile file);</font>
-<dd>
- Rewinds the given file. This function is supported only for reading.
- <p>
- <a href="#gzrewind">gzrewind</a>(file) is equivalent to (int)<a href="#gzseek">gzseek</a>(file, 0L, SEEK_SET)
- <p>
-
-<font color="Blue"><dt> z_off_t <a name="gztell">gztell</a> (gzFile file);</font>
-<dd>
- Returns the starting position for the next <a href="#gzread">gzread</a> or <a href="#gzwrite">gzwrite</a> on the
- given compressed file. This position represents a number of bytes in the
- uncompressed data stream.
- <p>
-
- <a href="#gztell">gztell</a>(file) is equivalent to <a href="#gzseek">gzseek</a>(file, 0L, SEEK_CUR)
- <p>
-
-<font color="Blue"><dt> int <a name="gzeof">gzeof</a> (gzFile file);</font>
-<dd>
- Returns 1 when EOF has previously been detected reading the given
- input stream, otherwise zero.
- <p>
-
-<font color="Blue"><dt> int <a name="gzclose">gzclose</a> (gzFile file);</font>
-<dd>
- Flushes all pending output if necessary, closes the compressed file
- and deallocates all the (de)compression <a href="#state">state</a>. The return value is the zlib
- error number (see function <a href="#gzerror">gzerror</a> below).
- <p>
-
-<font color="Blue"><dt> const char * <a name="gzerror">gzerror</a> (gzFile file, int *errnum);</font>
-<dd>
- Returns the error message for the last error which occurred on the
- given compressed file. errnum is set to zlib error number. If an
- error occurred in the file system and not in the compression library,
- errnum is set to <a href="#Z_ERRNO">Z_ERRNO</a> and the application may consult errno
- to get the exact error code.
- <p>
-</dl>
-<hr>
-<a name="Basic functions"><h2> Basic functions </h2>
-<h3> Function list </h3>
-<ul>
-<li> const char * <a href="#zlibVersion">zlibVersion</a> (void);
-<li> int <a href="#deflateInit">deflateInit</a> (<a href="#z_streamp">z_streamp</a> strm, int level);
-<li> int <a href="#deflate">deflate</a> (<a href="#z_streamp">z_streamp</a> strm, int flush);
-<li> int <a href="#deflateEnd">deflateEnd</a> (<a href="#z_streamp">z_streamp</a> strm);
-<li> int <a href="#inflateInit">inflateInit</a> (<a href="#z_streamp">z_streamp</a> strm);
-<li> int <a href="#inflate">inflate</a> (<a href="#z_streamp">z_streamp</a> strm, int flush);
-<li> int <a href="#inflateEnd">inflateEnd</a> (<a href="#z_streamp">z_streamp</a> strm);
-</ul>
-
-<h3> Function description </h3>
-<dl>
-<font color="Blue"><dt> const char * <a name="zlibVersion">zlibVersion</a> (void);</font>
-<dd> The application can compare <a href="#zlibVersion">zlibVersion</a> and ZLIB_VERSION for consistency.
- If the first character differs, the library code actually used is
- not compatible with the zlib.h header file used by the application.
- This check is automatically made by <a href="#deflateInit">deflateInit</a> and <a href="#inflateInit">inflateInit</a>.
- <p>
-
-<font color="Blue"><dt> int <a name="deflateInit">deflateInit</a> (<a href="#z_streamp">z_streamp</a> strm, int level);</font>
-<dd>
- Initializes the internal stream <a href="#state">state</a> for compression. The fields
- <a href="#zalloc">zalloc</a>, <a href="#zfree">zfree</a> and <a href="#opaque">opaque</a> must be initialized before by the caller.
- If <a href="#zalloc">zalloc</a> and <a href="#zfree">zfree</a> are set to <a href="#Z_NULL">Z_NULL</a>, <a href="#deflateInit">deflateInit</a> updates them to
- use default allocation functions.
- <p>
-
- The compression level must be <a href="#Z_DEFAULT_COMPRESSION">Z_DEFAULT_COMPRESSION</a>, or between 0 and 9:
- 1 gives best speed, 9 gives best compression, 0 gives no compression at
- all (the input data is simply copied a block at a time).
- <p>
-
- <a href="#Z_DEFAULT_COMPRESSION">Z_DEFAULT_COMPRESSION</a> requests a default compromise between speed and
- compression (currently equivalent to level 6).
- <p>
-
- <a href="#deflateInit">deflateInit</a> returns <a href="#Z_OK">Z_OK</a> if success, <a href="#Z_MEM_ERROR">Z_MEM_ERROR</a> if there was not
- enough memory, <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if level is not a valid compression level,
- <a href="#Z_VERSION_ERROR">Z_VERSION_ERROR</a> if the zlib library version (<a href="#zlib_version">zlib_version</a>) is incompatible
- with the version assumed by the caller (ZLIB_VERSION).
- <a href="#msg">msg</a> is set to null if there is no error message. <a href="#deflateInit">deflateInit</a> does not
- perform any compression: this will be done by <a href="#deflate">deflate</a>().
- <p>
-
-<font color="Blue"><dt> int <a name="deflate">deflate</a> (<a href="#z_streamp">z_streamp</a> strm, int flush);</font>
-<dd>
- <a href="#deflate">deflate</a> compresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may introduce some
- output latency (reading input without producing any output) except when
- forced to flush.<p>
-
- The detailed semantics are as follows. <a href="#deflate">deflate</a> performs one or both of the
- following actions:
-
- <ul>
- <li> Compress more input starting at <a href="#next_in">next_in</a> and update <a href="#next_in">next_in</a> and <a href="#avail_in">avail_in</a>
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), <a href="#next_in">next_in</a> and <a href="#avail_in">avail_in</a> are updated and
- processing will resume at this point for the next call of <a href="#deflate">deflate</a>().
-
- <li>
- Provide more output starting at <a href="#next_out">next_out</a> and update <a href="#next_out">next_out</a> and <a href="#avail_out">avail_out</a>
- accordingly. This action is forced if the parameter flush is non zero.
- Forcing flush frequently degrades the compression ratio, so this parameter
- should be set only when necessary (in interactive applications).
- Some output may be provided even if flush is not set.
- </ul> <p>
-
- Before the call of <a href="#deflate">deflate</a>(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming
- more output, and updating <a href="#avail_in">avail_in</a> or <a href="#avail_out">avail_out</a> accordingly ; <a href="#avail_out">avail_out</a>
- should never be zero before the call. The application can consume the
- compressed output when it wants, for example when the output buffer is full
- (<a href="#avail_out">avail_out</a> == 0), or after each call of <a href="#deflate">deflate</a>(). If <a href="#deflate">deflate</a> returns <a href="#Z_OK">Z_OK</a>
- and with zero <a href="#avail_out">avail_out</a>, it must be called again after making room in the
- output buffer because there might be more output pending.
- <p>
-
- If the parameter flush is set to <a href="#Z_SYNC_FLUSH">Z_SYNC_FLUSH</a>, all pending output is
- flushed to the output buffer and the output is aligned on a byte boundary, so
- that the decompressor can get all input data available so far. (In particular
- <a href="#avail_in">avail_in</a> is zero after the call if enough output space has been provided
- before the call.) Flushing may degrade compression for some compression
- algorithms and so it should be used only when necessary.
- <p>
-
- If flush is set to <a href="#Z_FULL_FLUSH">Z_FULL_FLUSH</a>, all output is flushed as with
- <a href="#Z_SYNC_FLUSH">Z_SYNC_FLUSH</a>, and the compression <a href="#state">state</a> is reset so that decompression can
- restart from this point if previous compressed data has been damaged or if
- random access is desired. Using <a href="#Z_FULL_FLUSH">Z_FULL_FLUSH</a> too often can seriously degrade
- the compression.
- <p>
-
- If <a href="#deflate">deflate</a> returns with <a href="#avail_out">avail_out</a> == 0, this function must be called again
- with the same value of the flush parameter and more output space (updated
- <a href="#avail_out">avail_out</a>), until the flush is complete (<a href="#deflate">deflate</a> returns with non-zero
- <a href="#avail_out">avail_out</a>).
- <p>
-
- If the parameter flush is set to <a href="#Z_FINISH">Z_FINISH</a>, pending input is processed,
- pending output is flushed and <a href="#deflate">deflate</a> returns with <a href="#Z_STREAM_END">Z_STREAM_END</a> if there
- was enough output space ; if <a href="#deflate">deflate</a> returns with <a href="#Z_OK">Z_OK</a>, this function must be
- called again with <a href="#Z_FINISH">Z_FINISH</a> and more output space (updated <a href="#avail_out">avail_out</a>) but no
- more input data, until it returns with <a href="#Z_STREAM_END">Z_STREAM_END</a> or an error. After
- <a href="#deflate">deflate</a> has returned <a href="#Z_STREAM_END">Z_STREAM_END</a>, the only possible operations on the
- stream are <a href="#deflateReset">deflateReset</a> or <a href="#deflateEnd">deflateEnd</a>.
- <p>
-
- <a href="#Z_FINISH">Z_FINISH</a> can be used immediately after <a href="#deflateInit">deflateInit</a> if all the compression
- is to be done in a single step. In this case, <a href="#avail_out">avail_out</a> must be at least
- 0.1% larger than <a href="#avail_in">avail_in</a> plus 12 bytes. If <a href="#deflate">deflate</a> does not return
- <a href="#Z_STREAM_END">Z_STREAM_END</a>, then it must be called again as described above.
- <p>
-
- <a href="#deflate">deflate</a>() sets strm-&gt <a href="#adler">adler</a> to the <a href="#adler32">adler32</a> checksum of all input read
- so far (that is, <a href="#total_in">total_in</a> bytes).
- <p>
-
- <a href="#deflate">deflate</a>() may update <a href="#data_type">data_type</a> if it can make a good guess about
- the input data type (<a href="#Z_ASCII">Z_ASCII</a> or <a href="#Z_BINARY">Z_BINARY</a>). In doubt, the data is considered
- binary. This field is only for information purposes and does not affect
- the compression algorithm in any manner.
- <p>
-
- <a href="#deflate">deflate</a>() returns <a href="#Z_OK">Z_OK</a> if some progress has been made (more input
- processed or more output produced), <a href="#Z_STREAM_END">Z_STREAM_END</a> if all input has been
- consumed and all output has been produced (only when flush is set to
- <a href="#Z_FINISH">Z_FINISH</a>), <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if the stream <a href="#state">state</a> was inconsistent (for example
- if <a href="#next_in">next_in</a> or <a href="#next_out">next_out</a> was NULL), <a href="#Z_BUF_ERROR">Z_BUF_ERROR</a> if no progress is possible
- (for example <a href="#avail_in">avail_in</a> or <a href="#avail_out">avail_out</a> was zero).
- <p>
-
-<font color="Blue"><dt> int <a name="deflateEnd">deflateEnd</a> (<a href="#z_streamp">z_streamp</a> strm);</font>
-<dd>
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any
- pending output.
- <p>
-
- <a href="#deflateEnd">deflateEnd</a> returns <a href="#Z_OK">Z_OK</a> if success, <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if the
- stream <a href="#state">state</a> was inconsistent, <a href="#Z_DATA_ERROR">Z_DATA_ERROR</a> if the stream was freed
- prematurely (some input or output was discarded). In the error case,
- <a href="#msg">msg</a> may be set but then points to a static string (which must not be
- deallocated).
- <p>
-
-<font color="Blue"><dt> int <a name="inflateInit">inflateInit</a> (<a href="#z_streamp">z_streamp</a> strm);</font>
-<dd>
- Initializes the internal stream <a href="#state">state</a> for decompression. The fields
- <a href="#next_in">next_in</a>, <a href="#avail_in">avail_in</a>, <a href="#zalloc">zalloc</a>, <a href="#zfree">zfree</a> and <a href="#opaque">opaque</a> must be initialized before by
- the caller. If <a href="#next_in">next_in</a> is not <a href="#Z_NULL">Z_NULL</a> and <a href="#avail_in">avail_in</a> is large enough (the exact
- value depends on the compression method), <a href="#inflateInit">inflateInit</a> determines the
- compression method from the zlib header and allocates all data structures
- accordingly ; otherwise the allocation will be deferred to the first call of
- <a href="#inflate">inflate</a>. If <a href="#zalloc">zalloc</a> and <a href="#zfree">zfree</a> are set to <a href="#Z_NULL">Z_NULL</a>, <a href="#inflateInit">inflateInit</a> updates them to
- use default allocation functions.
- <p>
-
- <a href="#inflateInit">inflateInit</a> returns <a href="#Z_OK">Z_OK</a> if success, <a href="#Z_MEM_ERROR">Z_MEM_ERROR</a> if there was not enough
- memory, <a href="#Z_VERSION_ERROR">Z_VERSION_ERROR</a> if the zlib library version is incompatible with the
- version assumed by the caller. <a href="#msg">msg</a> is set to null if there is no error
- message. <a href="#inflateInit">inflateInit</a> does not perform any decompression apart from reading
- the zlib header if present: this will be done by <a href="#inflate">inflate</a>(). (So <a href="#next_in">next_in</a> and
- <a href="#avail_in">avail_in</a> may be modified, but <a href="#next_out">next_out</a> and <a href="#avail_out">avail_out</a> are unchanged.)
- <p>
-
-<font color="Blue"><dt> int <a name="inflate">inflate</a> (<a href="#z_streamp">z_streamp</a> strm, int flush);</font>
-<dd>
- <a href="#inflate">inflate</a> decompresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may some
- introduce some output latency (reading input without producing any output)
- except when forced to flush.
- <p>
-
- The detailed semantics are as follows. <a href="#inflate">inflate</a> performs one or both of the
- following actions:
-
- <ul>
- <li> Decompress more input starting at <a href="#next_in">next_in</a> and update <a href="#next_in">next_in</a> and <a href="#avail_in">avail_in</a>
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), <a href="#next_in">next_in</a> is updated and processing
- will resume at this point for the next call of <a href="#inflate">inflate</a>().
-
- <li> Provide more output starting at <a href="#next_out">next_out</a> and update <a href="#next_out">next_out</a> and
- <a href="#avail_out">avail_out</a> accordingly. <a href="#inflate">inflate</a>() provides as much output as possible,
- until there is no more input data or no more space in the output buffer
- (see below about the flush parameter).
- </ul> <p>
-
- Before the call of <a href="#inflate">inflate</a>(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming
- more output, and updating the next_* and avail_* values accordingly.
- The application can consume the uncompressed output when it wants, for
- example when the output buffer is full (<a href="#avail_out">avail_out</a> == 0), or after each
- call of <a href="#inflate">inflate</a>(). If <a href="#inflate">inflate</a> returns <a href="#Z_OK">Z_OK</a> and with zero <a href="#avail_out">avail_out</a>, it
- must be called again after making room in the output buffer because there
- might be more output pending.
- <p>
-
- If the parameter flush is set to <a href="#Z_SYNC_FLUSH">Z_SYNC_FLUSH</a>, <a href="#inflate">inflate</a> flushes as much
- output as possible to the output buffer. The flushing behavior of <a href="#inflate">inflate</a> is
- not specified for values of the flush parameter other than <a href="#Z_SYNC_FLUSH">Z_SYNC_FLUSH</a>
- and <a href="#Z_FINISH">Z_FINISH</a>, but the current implementation actually flushes as much output
- as possible anyway.
- <p>
-
- <a href="#inflate">inflate</a>() should normally be called until it returns <a href="#Z_STREAM_END">Z_STREAM_END</a> or an
- error. However if all decompression is to be performed in a single step
- (a single call of <a href="#inflate">inflate</a>), the parameter flush should be set to
- <a href="#Z_FINISH">Z_FINISH</a>. In this case all pending input is processed and all pending
- output is flushed ; <a href="#avail_out">avail_out</a> must be large enough to hold all the
- uncompressed data. (The size of the uncompressed data may have been saved
- by the compressor for this purpose.) The next operation on this stream must
- be <a href="#inflateEnd">inflateEnd</a> to deallocate the decompression <a href="#state">state</a>. The use of <a href="#Z_FINISH">Z_FINISH</a>
- is never required, but can be used to inform <a href="#inflate">inflate</a> that a faster routine
- may be used for the single <a href="#inflate">inflate</a>() call.
- <p>
-
- If a preset dictionary is needed at this point (see <a href="#inflateSetDictionary">inflateSetDictionary</a>
- below), <a href="#inflate">inflate</a> sets strm-<a href="#adler">adler</a> to the <a href="#adler32">adler32</a> checksum of the
- dictionary chosen by the compressor and returns <a href="#Z_NEED_DICT">Z_NEED_DICT</a> ; otherwise
- it sets strm-&gt <a href="#adler">adler</a> to the <a href="#adler32">adler32</a> checksum of all output produced
- so far (that is, <a href="#total_out">total_out</a> bytes) and returns <a href="#Z_OK">Z_OK</a>, <a href="#Z_STREAM_END">Z_STREAM_END</a> or
- an error code as described below. At the end of the stream, <a href="#inflate">inflate</a>()
- checks that its computed <a href="#adler32">adler32</a> checksum is equal to that saved by the
- compressor and returns <a href="#Z_STREAM_END">Z_STREAM_END</a> only if the checksum is correct.
- <p>
-
- <a href="#inflate">inflate</a>() returns <a href="#Z_OK">Z_OK</a> if some progress has been made (more input processed
- or more output produced), <a href="#Z_STREAM_END">Z_STREAM_END</a> if the end of the compressed data has
- been reached and all uncompressed output has been produced, <a href="#Z_NEED_DICT">Z_NEED_DICT</a> if a
- preset dictionary is needed at this point, <a href="#Z_DATA_ERROR">Z_DATA_ERROR</a> if the input data was
- corrupted (input stream not conforming to the zlib format or incorrect
- <a href="#adler32">adler32</a> checksum), <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if the stream structure was inconsistent
- (for example if <a href="#next_in">next_in</a> or <a href="#next_out">next_out</a> was NULL), <a href="#Z_MEM_ERROR">Z_MEM_ERROR</a> if there was not
- enough memory, <a href="#Z_BUF_ERROR">Z_BUF_ERROR</a> if no progress is possible or if there was not
- enough room in the output buffer when <a href="#Z_FINISH">Z_FINISH</a> is used. In the <a href="#Z_DATA_ERROR">Z_DATA_ERROR</a>
- case, the application may then call <a href="#inflateSync">inflateSync</a> to look for a good
- compression block.
- <p>
-
-<font color="Blue"><dt> int <a name="inflateEnd">inflateEnd</a> (<a href="#z_streamp">z_streamp</a> strm);</font>
-<dd>
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any
- pending output.
- <p>
-
- <a href="#inflateEnd">inflateEnd</a> returns <a href="#Z_OK">Z_OK</a> if success, <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if the stream <a href="#state">state</a>
- was inconsistent. In the error case, <a href="#msg">msg</a> may be set but then points to a
- static string (which must not be deallocated).
-</dl>
-<hr>
-<a name="Advanced functions"><h2> Advanced functions </h2>
- The following functions are needed only in some special applications.
-<h3> Function list </h3>
-<ul>
-<li> int <a href="#deflateInit2">deflateInit2</a> (<a href="#z_streamp">z_streamp</a> strm,
-<li> int <a href="#deflateSetDictionary">deflateSetDictionary</a> (<a href="#z_streamp">z_streamp</a> strm, const Bytef *dictionary, uInt dictLength);
-<li> int <a href="#deflateCopy">deflateCopy</a> (<a href="#z_streamp">z_streamp</a> dest, <a href="#z_streamp">z_streamp</a> source);
-<li> int <a href="#deflateReset">deflateReset</a> (<a href="#z_streamp">z_streamp</a> strm);
-<li> int <a href="#deflateParams">deflateParams</a> (<a href="#z_streamp">z_streamp</a> strm, int level, int strategy);
-<li> int <a href="#inflateInit2">inflateInit2</a> (<a href="#z_streamp">z_streamp</a> strm, int windowBits);
-<li> int <a href="#inflateSetDictionary">inflateSetDictionary</a> (<a href="#z_streamp">z_streamp</a> strm, const Bytef *dictionary, uInt dictLength);
-<li> int <a href="#inflateSync">inflateSync</a> (<a href="#z_streamp">z_streamp</a> strm);
-<li> int <a href="#inflateReset">inflateReset</a> (<a href="#z_streamp">z_streamp</a> strm);
-
-</ul>
-<h3> Function description </h3>
-<dl>
-<font color="Blue"><dt> int <a name="deflateInit2">deflateInit2</a> (<a href="#z_streamp">z_streamp</a> strm, int level, int method, int windowBits, int memLevel, int strategy);</font>
-
-<dd> This is another version of <a href="#deflateInit">deflateInit</a> with more compression options. The
- fields <a href="#next_in">next_in</a>, <a href="#zalloc">zalloc</a>, <a href="#zfree">zfree</a> and <a href="#opaque">opaque</a> must be initialized before by
- the caller.<p>
-
- The method parameter is the compression method. It must be <a href="#Z_DEFLATED">Z_DEFLATED</a> in
- this version of the library.<p>
-
- The windowBits parameter is the base two logarithm of the window size
- (the size of the history buffer). It should be in the range 8..15 for this
- version of the library. Larger values of this parameter result in better
- compression at the expense of memory usage. The default value is 15 if
- <a href="#deflateInit">deflateInit</a> is used instead.<p>
-
- The memLevel parameter specifies how much memory should be allocated
- for the internal compression <a href="#state">state</a>. memLevel=1 uses minimum memory but
- is slow and reduces compression ratio ; memLevel=9 uses maximum memory
- for optimal speed. The default value is 8. See zconf.h for total memory
- usage as a function of windowBits and memLevel.<p>
-
- The strategy parameter is used to tune the compression algorithm. Use the
- value <a href="#Z_DEFAULT_STRATEGY">Z_DEFAULT_STRATEGY</a> for normal data, <a href="#Z_FILTERED">Z_FILTERED</a> for data produced by a
- filter (or predictor), or <a href="#Z_HUFFMAN_ONLY">Z_HUFFMAN_ONLY</a> to force Huffman encoding only (no
- string match). Filtered data consists mostly of small values with a
- somewhat random distribution. In this case, the compression algorithm is
- tuned to <a href="#compress">compress</a> them better. The effect of <a href="#Z_FILTERED">Z_FILTERED</a> is to force more
- Huffman coding and less string matching ; it is somewhat intermediate
- between Z_DEFAULT and <a href="#Z_HUFFMAN_ONLY">Z_HUFFMAN_ONLY</a>. The strategy parameter only affects
- the compression ratio but not the correctness of the compressed output even
- if it is not set appropriately.<p>
-
- <a href="#deflateInit2">deflateInit2</a> returns <a href="#Z_OK">Z_OK</a> if success, <a href="#Z_MEM_ERROR">Z_MEM_ERROR</a> if there was not enough
- memory, <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if a parameter is invalid (such as an invalid
- method). <a href="#msg">msg</a> is set to null if there is no error message. <a href="#deflateInit2">deflateInit2</a> does
- not perform any compression: this will be done by <a href="#deflate">deflate</a>().<p>
-
-<font color="Blue"><dt> int <a name="deflateSetDictionary">deflateSetDictionary</a> (<a href="#z_streamp">z_streamp</a> strm, const Bytef *dictionary, uInt dictLength);</font>
-<dd>
- Initializes the compression dictionary from the given byte sequence
- without producing any compressed output. This function must be called
- immediately after <a href="#deflateInit">deflateInit</a>, <a href="#deflateInit2">deflateInit2</a> or <a href="#deflateReset">deflateReset</a>, before any
- call of <a href="#deflate">deflate</a>. The compressor and decompressor must use exactly the same
- dictionary (see <a href="#inflateSetDictionary">inflateSetDictionary</a>).<p>
-
- The dictionary should consist of strings (byte sequences) that are likely
- to be encountered later in the data to be compressed, with the most commonly
- used strings preferably put towards the end of the dictionary. Using a
- dictionary is most useful when the data to be compressed is short and can be
- predicted with good accuracy ; the data can then be compressed better than
- with the default empty dictionary.<p>
-
- Depending on the size of the compression data structures selected by
- <a href="#deflateInit">deflateInit</a> or <a href="#deflateInit2">deflateInit2</a>, a part of the dictionary may in effect be
- discarded, for example if the dictionary is larger than the window size in
- <a href="#deflate">deflate</a> or deflate2. Thus the strings most likely to be useful should be
- put at the end of the dictionary, not at the front.<p>
-
- Upon return of this function, strm-&gt <a href="#adler">adler</a> is set to the Adler32 value
- of the dictionary ; the decompressor may later use this value to determine
- which dictionary has been used by the compressor. (The Adler32 value
- applies to the whole dictionary even if only a subset of the dictionary is
- actually used by the compressor.)<p>
-
- <a href="#deflateSetDictionary">deflateSetDictionary</a> returns <a href="#Z_OK">Z_OK</a> if success, or <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if a
- parameter is invalid (such as NULL dictionary) or the stream <a href="#state">state</a> is
- inconsistent (for example if <a href="#deflate">deflate</a> has already been called for this stream
- or if the compression method is bsort). <a href="#deflateSetDictionary">deflateSetDictionary</a> does not
- perform any compression: this will be done by <a href="#deflate">deflate</a>().<p>
-
-<font color="Blue"><dt> int <a name="deflateCopy">deflateCopy</a> (<a href="#z_streamp">z_streamp</a> dest, <a href="#z_streamp">z_streamp</a> source);</font>
-<dd>
- Sets the destination stream as a complete copy of the source stream.<p>
-
- This function can be useful when several compression strategies will be
- tried, for example when there are several ways of pre-processing the input
- data with a filter. The streams that will be discarded should then be freed
- by calling <a href="#deflateEnd">deflateEnd</a>. Note that <a href="#deflateCopy">deflateCopy</a> duplicates the internal
- compression <a href="#state">state</a> which can be quite large, so this strategy is slow and
- can consume lots of memory.<p>
-
- <a href="#deflateCopy">deflateCopy</a> returns <a href="#Z_OK">Z_OK</a> if success, <a href="#Z_MEM_ERROR">Z_MEM_ERROR</a> if there was not
- enough memory, <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if the source stream <a href="#state">state</a> was inconsistent
- (such as <a href="#zalloc">zalloc</a> being NULL). <a href="#msg">msg</a> is left unchanged in both source and
- destination.<p>
-
-<font color="Blue"><dt> int <a name="deflateReset">deflateReset</a> (<a href="#z_streamp">z_streamp</a> strm);</font>
-<dd> This function is equivalent to <a href="#deflateEnd">deflateEnd</a> followed by <a href="#deflateInit">deflateInit</a>,
- but does not free and reallocate all the internal compression <a href="#state">state</a>.
- The stream will keep the same compression level and any other attributes
- that may have been set by <a href="#deflateInit2">deflateInit2</a>.<p>
-
- <a href="#deflateReset">deflateReset</a> returns <a href="#Z_OK">Z_OK</a> if success, or <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if the source
- stream <a href="#state">state</a> was inconsistent (such as <a href="#zalloc">zalloc</a> or <a href="#state">state</a> being NULL).<p>
-
-<font color="Blue"><dt> int <a name="deflateParams">deflateParams</a> (<a href="#z_streamp">z_streamp</a> strm, int level, int strategy);</font>
-<dd>
- Dynamically update the compression level and compression strategy. The
- interpretation of level and strategy is as in <a href="#deflateInit2">deflateInit2</a>. This can be
- used to switch between compression and straight copy of the input data, or
- to switch to a different kind of input data requiring a different
- strategy. If the compression level is changed, the input available so far
- is compressed with the old level (and may be flushed); the new level will
- take effect only at the next call of <a href="#deflate">deflate</a>().<p>
-
- Before the call of <a href="#deflateParams">deflateParams</a>, the stream <a href="#state">state</a> must be set as for
- a call of <a href="#deflate">deflate</a>(), since the currently available input may have to
- be compressed and flushed. In particular, strm-&gt <a href="#avail_out">avail_out</a> must be
- non-zero.<p>
-
- <a href="#deflateParams">deflateParams</a> returns <a href="#Z_OK">Z_OK</a> if success, <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if the source
- stream <a href="#state">state</a> was inconsistent or if a parameter was invalid, <a href="#Z_BUF_ERROR">Z_BUF_ERROR</a>
- if strm-&gtavail_out was zero.<p>
-
-<font color="Blue"><dt> int <a name="inflateInit2">inflateInit2</a> (<a href="#z_streamp">z_streamp</a> strm, int windowBits);</font>
-
-<dd> This is another version of <a href="#inflateInit">inflateInit</a> with an extra parameter. The
- fields <a href="#next_in">next_in</a>, <a href="#avail_in">avail_in</a>, <a href="#zalloc">zalloc</a>, <a href="#zfree">zfree</a> and <a href="#opaque">opaque</a> must be initialized
- before by the caller.<p>
-
- The windowBits parameter is the base two logarithm of the maximum window
- size (the size of the history buffer). It should be in the range 8..15 for
- this version of the library. The default value is 15 if <a href="#inflateInit">inflateInit</a> is used
- instead. If a compressed stream with a larger window size is given as
- input, <a href="#inflate">inflate</a>() will return with the error code <a href="#Z_DATA_ERROR">Z_DATA_ERROR</a> instead of
- trying to allocate a larger window.<p>
-
- <a href="#inflateInit2">inflateInit2</a> returns <a href="#Z_OK">Z_OK</a> if success, <a href="#Z_MEM_ERROR">Z_MEM_ERROR</a> if there was not enough
- memory, <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if a parameter is invalid (such as a negative
- memLevel). <a href="#msg">msg</a> is set to null if there is no error message. <a href="#inflateInit2">inflateInit2</a>
- does not perform any decompression apart from reading the zlib header if
- present: this will be done by <a href="#inflate">inflate</a>(). (So <a href="#next_in">next_in</a> and <a href="#avail_in">avail_in</a> may be
- modified, but <a href="#next_out">next_out</a> and <a href="#avail_out">avail_out</a> are unchanged.)<p>
-
-<font color="Blue"><dt> int <a name="inflateSetDictionary">inflateSetDictionary</a> (<a href="#z_streamp">z_streamp</a> strm, const Bytef *dictionary, uInt dictLength);</font>
-<dd>
- Initializes the decompression dictionary from the given uncompressed byte
- sequence. This function must be called immediately after a call of <a href="#inflate">inflate</a>
- if this call returned <a href="#Z_NEED_DICT">Z_NEED_DICT</a>. The dictionary chosen by the compressor
- can be determined from the Adler32 value returned by this call of
- <a href="#inflate">inflate</a>. The compressor and decompressor must use exactly the same
- dictionary (see <a href="#deflateSetDictionary">deflateSetDictionary</a>).<p>
-
- <a href="#inflateSetDictionary">inflateSetDictionary</a> returns <a href="#Z_OK">Z_OK</a> if success, <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if a
- parameter is invalid (such as NULL dictionary) or the stream <a href="#state">state</a> is
- inconsistent, <a href="#Z_DATA_ERROR">Z_DATA_ERROR</a> if the given dictionary doesn't match the
- expected one (incorrect Adler32 value). <a href="#inflateSetDictionary">inflateSetDictionary</a> does not
- perform any decompression: this will be done by subsequent calls of
- <a href="#inflate">inflate</a>().<p>
-
-<font color="Blue"><dt> int <a name="inflateSync">inflateSync</a> (<a href="#z_streamp">z_streamp</a> strm);</font>
-
-<dd> Skips invalid compressed data until a full flush point (see above the
- description of <a href="#deflate">deflate</a> with <a href="#Z_FULL_FLUSH">Z_FULL_FLUSH</a>) can be found, or until all
- available input is skipped. No output is provided.<p>
-
- <a href="#inflateSync">inflateSync</a> returns <a href="#Z_OK">Z_OK</a> if a full flush point has been found, <a href="#Z_BUF_ERROR">Z_BUF_ERROR</a>
- if no more input was provided, <a href="#Z_DATA_ERROR">Z_DATA_ERROR</a> if no flush point has been found,
- or <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if the stream structure was inconsistent. In the success
- case, the application may save the current current value of <a href="#total_in">total_in</a> which
- indicates where valid compressed data was found. In the error case, the
- application may repeatedly call <a href="#inflateSync">inflateSync</a>, providing more input each time,
- until success or end of the input data.<p>
-
-<font color="Blue"><dt> int <a name="inflateReset">inflateReset</a> (<a href="#z_streamp">z_streamp</a> strm);</font>
-<dd>
- This function is equivalent to <a href="#inflateEnd">inflateEnd</a> followed by <a href="#inflateInit">inflateInit</a>,
- but does not free and reallocate all the internal decompression <a href="#state">state</a>.
- The stream will keep attributes that may have been set by <a href="#inflateInit2">inflateInit2</a>.
- <p>
-
- <a href="#inflateReset">inflateReset</a> returns <a href="#Z_OK">Z_OK</a> if success, or <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if the source
- stream <a href="#state">state</a> was inconsistent (such as <a href="#zalloc">zalloc</a> or <a href="#state">state</a> being NULL).
- <p>
-</dl>
-
-<hr>
-<a name="Checksum functions"><h2> Checksum functions </h2>
- These functions are not related to compression but are exported
- anyway because they might be useful in applications using the
- compression library.
-<h3> Function list </h3>
-<ul>
-<li> uLong <a href="#adler32">adler32</a> (uLong <a href="#adler">adler</a>, const Bytef *buf, uInt len);
-<li> uLong <a href="#crc32">crc32</a> (uLong crc, const Bytef *buf, uInt len);
-</ul>
-<h3> Function description </h3>
-<dl>
-<font color="Blue"><dt> uLong <a name="adler32">adler32</a> (uLong <a href="#adler">adler</a>, const Bytef *buf, uInt len);</font>
-<dd>
- Update a running Adler-32 checksum with the bytes buf[0..len-1] and
- return the updated checksum. If buf is NULL, this function returns
- the required initial value for the checksum.
- <p>
- An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
- much faster. Usage example:
- <pre>
-
- uLong <a href="#adler">adler</a> = <a href="#adler32">adler32</a>(0L, <a href="#Z_NULL">Z_NULL</a>, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- <a href="#adler">adler</a> = <a href="#adler32">adler32</a>(<a href="#adler">adler</a>, buffer, length);
- }
- if (<a href="#adler">adler</a> != original_adler) error();
- </pre>
-
-<font color="Blue"><dt> uLong <a name="crc32">crc32</a> (uLong crc, const Bytef *buf, uInt len);</font>
-<dd>
- Update a running crc with the bytes buf[0..len-1] and return the updated
- crc. If buf is NULL, this function returns the required initial value
- for the crc. Pre- and post-conditioning (one's complement) is performed
- within this function so it shouldn't be done by the application.
- Usage example:
- <pre>
-
- uLong crc = <a href="#crc32">crc32</a>(0L, <a href="#Z_NULL">Z_NULL</a>, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- crc = <a href="#crc32">crc32</a>(crc, buffer, length);
- }
- if (crc != original_crc) error();
- </pre>
-</dl>
-<hr>
-<a name="struct z_stream_s"><h2> struct z_stream_s </h2>
-<font color="Blue">
-<a name="z_stream_s">
-<pre>
-typedef struct z_stream_s {
- Bytef *<a name="next_in">next_in</a>; /* next input byte */
- uInt <a name="avail_in">avail_in</a>; /* number of bytes available at <a href="#next_in">next_in</a> */
- uLong <a name="total_in">total_in</a>; /* total nb of input bytes read so far */
-
- Bytef *<a name="next_out">next_out</a>; /* next output byte should be put there */
- uInt <a name="avail_out">avail_out</a>; /* remaining free space at <a href="#next_out">next_out</a> */
- uLong <a name="total_out">total_out</a>; /* total nb of bytes output so far */
-
- char *<a name="msg">msg</a>; /* last error message, NULL if no error */
- struct internal_state FAR *<a name="state">state</a>; /* not visible by applications */
-
- alloc_func <a name="zalloc">zalloc</a>; /* used to allocate the internal <a href="#state">state</a> */
- free_func <a name="zfree">zfree</a>; /* used to free the internal <a href="#state">state</a> */
- voidpf <a name="opaque">opaque</a>; /* private data object passed to <a href="#zalloc">zalloc</a> and <a href="#zfree">zfree</a> */
-
- int <a name="data_type">data_type</a>; /* best guess about the data type: ascii or binary */
- uLong <a name="adler">adler</a>; /* <a href="#adler32">adler32</a> value of the uncompressed data */
- uLong <a name="reserved">reserved</a>; /* <a href="#reserved">reserved</a> for future use */
-} <a href="#z_stream_s">z_stream</a> ;
-
-typedef <a href="#z_stream_s">z_stream</a> FAR * <a name="z_streamp">z_streamp</a>; ÿ
-</pre>
-</font>
- The application must update <a href="#next_in">next_in</a> and <a href="#avail_in">avail_in</a> when <a href="#avail_in">avail_in</a> has
- dropped to zero. It must update <a href="#next_out">next_out</a> and <a href="#avail_out">avail_out</a> when <a href="#avail_out">avail_out</a>
- has dropped to zero. The application must initialize <a href="#zalloc">zalloc</a>, <a href="#zfree">zfree</a> and
- <a href="#opaque">opaque</a> before calling the init function. All other fields are set by the
- compression library and must not be updated by the application. <p>
-
- The <a href="#opaque">opaque</a> value provided by the application will be passed as the first
- parameter for calls of <a href="#zalloc">zalloc</a> and <a href="#zfree">zfree</a>. This can be useful for custom
- memory management. The compression library attaches no meaning to the
- <a href="#opaque">opaque</a> value. <p>
-
- <a href="#zalloc">zalloc</a> must return <a href="#Z_NULL">Z_NULL</a> if there is not enough memory for the object.
- If zlib is used in a multi-threaded application, <a href="#zalloc">zalloc</a> and <a href="#zfree">zfree</a> must be
- thread safe. <p>
-
- On 16-bit systems, the functions <a href="#zalloc">zalloc</a> and <a href="#zfree">zfree</a> must be able to allocate
- exactly 65536 bytes, but will not be required to allocate more than this
- if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
- pointers returned by <a href="#zalloc">zalloc</a> for objects of exactly 65536 bytes *must*
- have their offset normalized to zero. The default allocation function
- provided by this library ensures this (see zutil.c). To reduce memory
- requirements and avoid any allocation of 64K objects, at the expense of
- compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
- <p>
-
- The fields <a href="#total_in">total_in</a> and <a href="#total_out">total_out</a> can be used for statistics or
- progress reports. After compression, <a href="#total_in">total_in</a> holds the total size of
- the uncompressed data and may be saved for use in the decompressor
- (particularly if the decompressor wants to decompress everything in
- a single step). <p>
-
-<hr>
-<a name="Constants"><h2> Constants </h2>
-<font color="Blue">
-<pre>
-#define <a name="Z_NO_FLUSH">Z_NO_FLUSH</a> 0
-#define <a name="Z_PARTIAL_FLUSH">Z_PARTIAL_FLUSH</a> 1
- /* will be removed, use <a href="#Z_SYNC_FLUSH">Z_SYNC_FLUSH</a> instead */
-#define <a name="Z_SYNC_FLUSH">Z_SYNC_FLUSH</a> 2
-#define <a name="Z_FULL_FLUSH">Z_FULL_FLUSH</a> 3
-#define <a name="Z_FINISH">Z_FINISH</a> 4
-/* Allowed flush values ; see <a href="#deflate">deflate</a>() below for details */
-
-#define <a name="Z_OK">Z_OK</a> 0
-#define <a name="Z_STREAM_END">Z_STREAM_END</a> 1
-#define <a name="Z_NEED_DICT">Z_NEED_DICT</a> 2
-#define <a name="Z_ERRNO">Z_ERRNO</a> (-1)
-#define <a name="Z_STREAM_ERROR">Z_STREAM_ERROR</a> (-2)
-#define <a name="Z_DATA_ERROR">Z_DATA_ERROR</a> (-3)
-#define <a name="Z_MEM_ERROR">Z_MEM_ERROR</a> (-4)
-#define <a name="Z_BUF_ERROR">Z_BUF_ERROR</a> (-5)
-#define <a name="Z_VERSION_ERROR">Z_VERSION_ERROR</a> (-6)
-/* Return codes for the compression/decompression functions. Negative
- * values are errors, positive values are used for special but normal events.
- */
-
-#define <a name="Z_NO_COMPRESSION">Z_NO_COMPRESSION</a> 0
-#define <a name="Z_BEST_SPEED">Z_BEST_SPEED</a> 1
-#define <a name="Z_BEST_COMPRESSION">Z_BEST_COMPRESSION</a> 9
-#define <a name="Z_DEFAULT_COMPRESSION">Z_DEFAULT_COMPRESSION</a> (-1)
-/* compression levels */
-
-#define <a name="Z_FILTERED">Z_FILTERED</a> 1
-#define <a name="Z_HUFFMAN_ONLY">Z_HUFFMAN_ONLY</a> 2
-#define <a name="Z_DEFAULT_STRATEGY">Z_DEFAULT_STRATEGY</a> 0
-/* compression strategy ; see <a href="#deflateInit2">deflateInit2</a>() below for details */
-
-#define <a name="Z_BINARY">Z_BINARY</a> 0
-#define <a name="Z_ASCII">Z_ASCII</a> 1
-#define <a name="Z_UNKNOWN">Z_UNKNOWN</a> 2
-/* Possible values of the <a href="#data_type">data_type</a> field */
-
-#define <a name="Z_DEFLATED">Z_DEFLATED</a> 8
-/* The <a href="#deflate">deflate</a> compression method (the only one supported in this version) */
-
-#define <a name="Z_NULL">Z_NULL</a> 0 /* for initializing <a href="#zalloc">zalloc</a>, <a href="#zfree">zfree</a>, <a href="#opaque">opaque</a> */
-
-#define <a name="zlib_version">zlib_version</a> <a href="#zlibVersion">zlibVersion</a>()
-/* for compatibility with versions less than 1.0.2 */
-</pre>
-</font>
-
-<hr>
-<a name="Misc"><h2> Misc </h2>
- <a href="#deflateInit">deflateInit</a> and <a href="#inflateInit">inflateInit</a> are macros to allow checking the zlib version
- and the compiler's view of <a href="#z_stream_s">z_stream</a>.
- <p>
- Other functions:
- <dl>
- <font color="Blue"><dt> const char * <a name="zError">zError</a> (int err);</font>
- <font color="Blue"><dt> int <a name="inflateSyncPoint">inflateSyncPoint</a> (<a href="#z_streamp">z_streamp</a> z);</font>
- <font color="Blue"><dt> const uLongf * <a name="get_crc_table">get_crc_table</a> (void);</font>
- </dl>
- <hr>
- <font size="-1">
- Last update: Wed Oct 13 20:42:34 1999<br>
- piapi@csie.ntu.edu.tw
- </font>
-
-</body>
-</html>
diff --git a/source4/lib/zlib/projects/README.projects b/source4/lib/zlib/projects/README.projects
deleted file mode 100644
index 1c029e4a34..0000000000
--- a/source4/lib/zlib/projects/README.projects
+++ /dev/null
@@ -1,41 +0,0 @@
-This directory contains project files for building zlib under various
-Integrated Development Environments (IDE).
-
-If you wish to submit a new project to this directory, you should comply
-to the following requirements. Otherwise (e.g. if you wish to integrate
-a custom piece of code that changes the zlib interface or its behavior),
-please consider submitting the project to the contrib directory.
-
-
-Requirements
-============
-
-- The project must build zlib using the source files from the official
- zlib source distribution, exclusively.
-
-- If the project produces redistributable builds (e.g. shared objects
- or DLL files), these builds must be compatible to those produced by
- makefiles, if such makefiles exist in the zlib distribution.
- In particular, if the project produces a DLL build for the Win32
- platform, this build must comply to the officially-ammended Win32 DLL
- Application Binary Interface (ABI), described in win32/DLL_FAQ.txt.
-
-- The project may provide additional build targets, which depend on
- 3rd-party (unofficially-supported) software, present in the contrib
- directory. For example, it is possible to provide an "ASM build",
- besides the officially-supported build, and have ASM source files
- among its dependencies.
-
-- If there are significant differences between the project files created
- by different versions of an IDE (e.g. Visual C++ 6.0 vs. 7.0), the name
- of the project directory should contain the version number of the IDE
- for which the project is intended (e.g. "visualc6" for Visual C++ 6.0,
- or "visualc7" for Visual C++ 7.0 and 7.1).
-
-
-Current projects
-================
-
-visualc6/ by Simon-Pierre Cadieux <methodex@methodex.ca>
- and Cosmin Truta <cosmint@cs.ubbcluj.ro>
- Project for Microsoft Visual C++ 6.0
diff --git a/source4/lib/zlib/projects/visualc6/README.txt b/source4/lib/zlib/projects/visualc6/README.txt
deleted file mode 100644
index d0296c272c..0000000000
--- a/source4/lib/zlib/projects/visualc6/README.txt
+++ /dev/null
@@ -1,73 +0,0 @@
-Microsoft Developer Studio Project Files, Format Version 6.00 for zlib.
-
-Copyright (C) 2000-2004 Simon-Pierre Cadieux.
-Copyright (C) 2004 Cosmin Truta.
-For conditions of distribution and use, see copyright notice in zlib.h.
-
-
-This project builds the zlib binaries as follows:
-
-* Win32_DLL_Release\zlib1.dll DLL build
-* Win32_DLL_Debug\zlib1d.dll DLL build (debug version)
-* Win32_DLL_ASM_Release\zlib1.dll DLL build using ASM code
-* Win32_DLL_ASM_Debug\zlib1d.dll DLL build using ASM code (debug version)
-* Win32_LIB_Release\zlib.lib static build
-* Win32_LIB_Debug\zlibd.lib static build (debug version)
-* Win32_LIB_ASM_Release\zlib.lib static build using ASM code
-* Win32_LIB_ASM_Debug\zlibd.lib static build using ASM code (debug version)
-
-
-For more information regarding the DLL builds, please see the DLL FAQ
-in ..\..\win32\DLL_FAQ.txt.
-
-
-To build and test:
-
-1) On the main menu, select "File | Open Workspace".
- Open "zlib.dsw".
-
-2) Select "Build | Set Active Configuration".
- Choose the configuration you wish to build.
-
-3) Select "Build | Clean".
-
-4) Select "Build | Build ... (F7)". Ignore warning messages about
- not being able to find certain include files (e.g. alloc.h).
-
-5) If you built one of the sample programs (example or minigzip),
- select "Build | Execute ... (Ctrl+F5)".
-
-
-To use:
-
-1) Select "Project | Settings (Alt+F7)".
- Make note of the configuration names used in your project.
- Usually, these names are "Win32 Release" and "Win32 Debug".
-
-2) In the Workspace window, select the "FileView" tab.
- Right-click on the root item "Workspace '...'".
- Select "Insert Project into Workspace".
- Switch on the checkbox "Dependency of:", and select the name
- of your project. Open "zlib.dsp".
-
-3) Select "Build | Configurations".
- For each configuration of your project:
- 3.1) Choose the zlib configuration you wish to use.
- 3.2) Click on "Add".
- 3.3) Set the new zlib configuration name to the name used by
- the configuration from the current iteration.
-
-4) Select "Build | Set Active Configuration".
- Choose the configuration you wish to build.
-
-5) Select "Build | Build ... (F7)".
-
-6) If you built an executable program, select
- "Build | Execute ... (Ctrl+F5)".
-
-
-Note:
-
-To build the ASM-enabled code, you need Microsoft Assembler
-(ML.EXE). You can get it by downloading and installing the
-latest Processor Pack for Visual C++ 6.0.
diff --git a/source4/lib/zlib/projects/visualc6/example.dsp b/source4/lib/zlib/projects/visualc6/example.dsp
deleted file mode 100644
index e072a37ff0..0000000000
--- a/source4/lib/zlib/projects/visualc6/example.dsp
+++ /dev/null
@@ -1,278 +0,0 @@
-# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=example - Win32 LIB Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "example.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 LIB Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "example - Win32 DLL Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "example - Win32 DLL Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE "example - Win32 DLL ASM Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "example - Win32 DLL ASM Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE "example - Win32 LIB Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "example - Win32 LIB Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE "example - Win32 LIB ASM Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "example - Win32 LIB ASM Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "example - Win32 DLL Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "example___Win32_DLL_Release"
-# PROP BASE Intermediate_Dir "example___Win32_DLL_Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Win32_DLL_Release"
-# PROP Intermediate_Dir "Win32_DLL_Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "example - Win32 DLL Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "example___Win32_DLL_Debug"
-# PROP BASE Intermediate_Dir "example___Win32_DLL_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Win32_DLL_Debug"
-# PROP Intermediate_Dir "Win32_DLL_Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ELSEIF "$(CFG)" == "example - Win32 DLL ASM Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "example___Win32_DLL_ASM_Release"
-# PROP BASE Intermediate_Dir "example___Win32_DLL_ASM_Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Win32_DLL_ASM_Release"
-# PROP Intermediate_Dir "Win32_DLL_ASM_Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "example - Win32 DLL ASM Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "example___Win32_DLL_ASM_Debug"
-# PROP BASE Intermediate_Dir "example___Win32_DLL_ASM_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Win32_DLL_ASM_Debug"
-# PROP Intermediate_Dir "Win32_DLL_ASM_Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ELSEIF "$(CFG)" == "example - Win32 LIB Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "example___Win32_LIB_Release"
-# PROP BASE Intermediate_Dir "example___Win32_LIB_Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Win32_LIB_Release"
-# PROP Intermediate_Dir "Win32_LIB_Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "example - Win32 LIB Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "example___Win32_LIB_Debug"
-# PROP BASE Intermediate_Dir "example___Win32_LIB_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Win32_LIB_Debug"
-# PROP Intermediate_Dir "Win32_LIB_Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ELSEIF "$(CFG)" == "example - Win32 LIB ASM Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "example___Win32_LIB_ASM_Release"
-# PROP BASE Intermediate_Dir "example___Win32_LIB_ASM_Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Win32_LIB_ASM_Release"
-# PROP Intermediate_Dir "Win32_LIB_ASM_Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "example - Win32 LIB ASM Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "example___Win32_LIB_ASM_Debug"
-# PROP BASE Intermediate_Dir "example___Win32_LIB_ASM_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Win32_LIB_ASM_Debug"
-# PROP Intermediate_Dir "Win32_LIB_ASM_Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "example - Win32 DLL Release"
-# Name "example - Win32 DLL Debug"
-# Name "example - Win32 DLL ASM Release"
-# Name "example - Win32 DLL ASM Debug"
-# Name "example - Win32 LIB Release"
-# Name "example - Win32 LIB Debug"
-# Name "example - Win32 LIB ASM Release"
-# Name "example - Win32 LIB ASM Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\..\example.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=..\..\zconf.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\zlib.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/source4/lib/zlib/projects/visualc6/minigzip.dsp b/source4/lib/zlib/projects/visualc6/minigzip.dsp
deleted file mode 100644
index f32024eaf5..0000000000
--- a/source4/lib/zlib/projects/visualc6/minigzip.dsp
+++ /dev/null
@@ -1,278 +0,0 @@
-# Microsoft Developer Studio Project File - Name="minigzip" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=minigzip - Win32 LIB Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "minigzip.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "minigzip.mak" CFG="minigzip - Win32 LIB Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "minigzip - Win32 DLL Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "minigzip - Win32 DLL Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE "minigzip - Win32 DLL ASM Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "minigzip - Win32 DLL ASM Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE "minigzip - Win32 LIB Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "minigzip - Win32 LIB Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE "minigzip - Win32 LIB ASM Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "minigzip - Win32 LIB ASM Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "minigzip - Win32 DLL Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "minigzip___Win32_DLL_Release"
-# PROP BASE Intermediate_Dir "minigzip___Win32_DLL_Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Win32_DLL_Release"
-# PROP Intermediate_Dir "Win32_DLL_Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "minigzip - Win32 DLL Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "minigzip___Win32_DLL_Debug"
-# PROP BASE Intermediate_Dir "minigzip___Win32_DLL_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Win32_DLL_Debug"
-# PROP Intermediate_Dir "Win32_DLL_Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ELSEIF "$(CFG)" == "minigzip - Win32 DLL ASM Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "minigzip___Win32_DLL_ASM_Release"
-# PROP BASE Intermediate_Dir "minigzip___Win32_DLL_ASM_Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Win32_DLL_ASM_Release"
-# PROP Intermediate_Dir "Win32_DLL_ASM_Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "minigzip - Win32 DLL ASM Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "minigzip___Win32_DLL_ASM_Debug"
-# PROP BASE Intermediate_Dir "minigzip___Win32_DLL_ASM_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Win32_DLL_ASM_Debug"
-# PROP Intermediate_Dir "Win32_DLL_ASM_Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ELSEIF "$(CFG)" == "minigzip - Win32 LIB Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "minigzip___Win32_LIB_Release"
-# PROP BASE Intermediate_Dir "minigzip___Win32_LIB_Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Win32_LIB_Release"
-# PROP Intermediate_Dir "Win32_LIB_Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "minigzip - Win32 LIB Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "minigzip___Win32_LIB_Debug"
-# PROP BASE Intermediate_Dir "minigzip___Win32_LIB_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Win32_LIB_Debug"
-# PROP Intermediate_Dir "Win32_LIB_Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ELSEIF "$(CFG)" == "minigzip - Win32 LIB ASM Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "minigzip___Win32_LIB_ASM_Release"
-# PROP BASE Intermediate_Dir "minigzip___Win32_LIB_ASM_Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Win32_LIB_ASM_Release"
-# PROP Intermediate_Dir "Win32_LIB_ASM_Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "minigzip - Win32 LIB ASM Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "minigzip___Win32_LIB_ASM_Debug"
-# PROP BASE Intermediate_Dir "minigzip___Win32_LIB_ASM_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Win32_LIB_ASM_Debug"
-# PROP Intermediate_Dir "Win32_LIB_ASM_Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "minigzip - Win32 DLL Release"
-# Name "minigzip - Win32 DLL Debug"
-# Name "minigzip - Win32 DLL ASM Release"
-# Name "minigzip - Win32 DLL ASM Debug"
-# Name "minigzip - Win32 LIB Release"
-# Name "minigzip - Win32 LIB Debug"
-# Name "minigzip - Win32 LIB ASM Release"
-# Name "minigzip - Win32 LIB ASM Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\..\minigzip.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=..\..\zconf.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\zlib.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/source4/lib/zlib/projects/visualc6/zlib.dsp b/source4/lib/zlib/projects/visualc6/zlib.dsp
deleted file mode 100644
index 0fe0604ccd..0000000000
--- a/source4/lib/zlib/projects/visualc6/zlib.dsp
+++ /dev/null
@@ -1,609 +0,0 @@
-# Microsoft Developer Studio Project File - Name="zlib" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=zlib - Win32 LIB Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "zlib.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "zlib.mak" CFG="zlib - Win32 LIB Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "zlib - Win32 DLL Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "zlib - Win32 DLL Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "zlib - Win32 DLL ASM Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "zlib - Win32 DLL ASM Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "zlib - Win32 LIB Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "zlib - Win32 LIB Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE "zlib - Win32 LIB ASM Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "zlib - Win32 LIB ASM Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-
-!IF "$(CFG)" == "zlib - Win32 DLL Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "zlib___Win32_DLL_Release"
-# PROP BASE Intermediate_Dir "zlib___Win32_DLL_Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Win32_DLL_Release"
-# PROP Intermediate_Dir "Win32_DLL_Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-CPP=cl.exe
-# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT BASE CPP /YX /Yc /Yu
-# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT CPP /YX /Yc /Yu
-MTL=midl.exe
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 /nologo /dll /machine:I386 /out:"Win32_DLL_Release\zlib1.dll"
-
-!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "zlib___Win32_DLL_Debug"
-# PROP BASE Intermediate_Dir "zlib___Win32_DLL_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Win32_DLL_Debug"
-# PROP Intermediate_Dir "Win32_DLL_Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-CPP=cl.exe
-# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT BASE CPP /YX /Yc /Yu
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT CPP /YX /Yc /Yu
-MTL=midl.exe
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /dll /debug /machine:I386 /out:"Win32_DLL_Debug\zlib1d.dll" /pdbtype:sept
-
-!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "zlib___Win32_DLL_ASM_Release"
-# PROP BASE Intermediate_Dir "zlib___Win32_DLL_ASM_Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Win32_DLL_ASM_Release"
-# PROP Intermediate_Dir "Win32_DLL_ASM_Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-CPP=cl.exe
-# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT BASE CPP /YX /Yc /Yu
-# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "ASMV" /D "ASMINF" /FD /c
-# SUBTRACT CPP /YX /Yc /Yu
-MTL=midl.exe
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 /nologo /dll /machine:I386 /out:"Win32_DLL_ASM_Release\zlib1.dll"
-
-!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "zlib___Win32_DLL_ASM_Debug"
-# PROP BASE Intermediate_Dir "zlib___Win32_DLL_ASM_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Win32_DLL_ASM_Debug"
-# PROP Intermediate_Dir "Win32_DLL_ASM_Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-CPP=cl.exe
-# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT BASE CPP /YX /Yc /Yu
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "ASMV" /D "ASMINF" /FD /GZ /c
-# SUBTRACT CPP /YX /Yc /Yu
-MTL=midl.exe
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /dll /debug /machine:I386 /out:"Win32_DLL_ASM_Debug\zlib1d.dll" /pdbtype:sept
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "zlib___Win32_LIB_Release"
-# PROP BASE Intermediate_Dir "zlib___Win32_LIB_Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Win32_LIB_Release"
-# PROP Intermediate_Dir "Win32_LIB_Release"
-# PROP Target_Dir ""
-CPP=cl.exe
-# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT BASE CPP /YX /Yc /Yu
-# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT CPP /YX /Yc /Yu
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "zlib___Win32_LIB_Debug"
-# PROP BASE Intermediate_Dir "zlib___Win32_LIB_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Win32_LIB_Debug"
-# PROP Intermediate_Dir "Win32_LIB_Debug"
-# PROP Target_Dir ""
-CPP=cl.exe
-# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT BASE CPP /YX /Yc /Yu
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT CPP /YX /Yc /Yu
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"Win32_LIB_Debug\zlibd.lib"
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "zlib___Win32_LIB_ASM_Release"
-# PROP BASE Intermediate_Dir "zlib___Win32_LIB_ASM_Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Win32_LIB_ASM_Release"
-# PROP Intermediate_Dir "Win32_LIB_ASM_Release"
-# PROP Target_Dir ""
-CPP=cl.exe
-# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
-# SUBTRACT BASE CPP /YX /Yc /Yu
-# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "ASMV" /D "ASMINF" /FD /c
-# SUBTRACT CPP /YX /Yc /Yu
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "zlib___Win32_LIB_ASM_Debug"
-# PROP BASE Intermediate_Dir "zlib___Win32_LIB_ASM_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Win32_LIB_ASM_Debug"
-# PROP Intermediate_Dir "Win32_LIB_ASM_Debug"
-# PROP Target_Dir ""
-CPP=cl.exe
-# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-# SUBTRACT BASE CPP /YX /Yc /Yu
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "ASMV" /D "ASMINF" /FD /GZ /c
-# SUBTRACT CPP /YX /Yc /Yu
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"Win32_LIB_ASM_Debug\zlibd.lib"
-
-!ENDIF
-
-# Begin Target
-
-# Name "zlib - Win32 DLL Release"
-# Name "zlib - Win32 DLL Debug"
-# Name "zlib - Win32 DLL ASM Release"
-# Name "zlib - Win32 DLL ASM Debug"
-# Name "zlib - Win32 LIB Release"
-# Name "zlib - Win32 LIB Debug"
-# Name "zlib - Win32 LIB ASM Release"
-# Name "zlib - Win32 LIB ASM Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\..\adler32.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\compress.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\crc32.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\deflate.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\gzio.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\infback.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\inffast.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\inflate.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\inftrees.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\trees.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\uncompr.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\win32\zlib.def
-
-!IF "$(CFG)" == "zlib - Win32 DLL Release"
-
-!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug"
-
-!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release"
-
-!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug"
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB Release"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug"
-
-# PROP Exclude_From_Build 1
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\zutil.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=..\..\crc32.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\deflate.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\inffast.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\inffixed.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\inflate.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\inftrees.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\trees.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\zconf.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\zlib.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\zutil.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# Begin Source File
-
-SOURCE=..\..\win32\zlib1.rc
-# End Source File
-# End Group
-# Begin Group "Assembler Files (Unsupported)"
-
-# PROP Default_Filter "asm;obj;c;cpp;cxx;h;hpp;hxx"
-# Begin Source File
-
-SOURCE=..\..\contrib\masmx86\gvmat32.asm
-
-!IF "$(CFG)" == "zlib - Win32 DLL Release"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release"
-
-# Begin Custom Build - Assembling...
-IntDir=.\Win32_DLL_ASM_Release
-InputPath=..\..\contrib\masmx86\gvmat32.asm
-InputName=gvmat32
-
-"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- ml.exe /nologo /c /coff /Cx /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)"
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug"
-
-# Begin Custom Build - Assembling...
-IntDir=.\Win32_DLL_ASM_Debug
-InputPath=..\..\contrib\masmx86\gvmat32.asm
-InputName=gvmat32
-
-"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- ml.exe /nologo /c /coff /Cx /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)"
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB Release"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release"
-
-# Begin Custom Build - Assembling...
-IntDir=.\Win32_LIB_ASM_Release
-InputPath=..\..\contrib\masmx86\gvmat32.asm
-InputName=gvmat32
-
-"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- ml.exe /nologo /c /coff /Cx /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)"
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug"
-
-# Begin Custom Build - Assembling...
-IntDir=.\Win32_LIB_ASM_Debug
-InputPath=..\..\contrib\masmx86\gvmat32.asm
-InputName=gvmat32
-
-"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- ml.exe /nologo /c /coff /Cx /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)"
-
-# End Custom Build
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\contrib\masmx86\gvmat32c.c
-
-!IF "$(CFG)" == "zlib - Win32 DLL Release"
-
-# PROP Exclude_From_Build 1
-# ADD CPP /I "..\.."
-
-!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug"
-
-# PROP Exclude_From_Build 1
-# ADD CPP /I "..\.."
-
-!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release"
-
-# ADD CPP /I "..\.."
-
-!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug"
-
-# ADD CPP /I "..\.."
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB Release"
-
-# PROP Exclude_From_Build 1
-# ADD CPP /I "..\.."
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug"
-
-# PROP Exclude_From_Build 1
-# ADD CPP /I "..\.."
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release"
-
-# ADD CPP /I "..\.."
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug"
-
-# ADD CPP /I "..\.."
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\contrib\masmx86\inffas32.asm
-
-!IF "$(CFG)" == "zlib - Win32 DLL Release"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release"
-
-# Begin Custom Build - Assembling...
-IntDir=.\Win32_DLL_ASM_Release
-InputPath=..\..\contrib\masmx86\inffas32.asm
-InputName=inffas32
-
-"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- ml.exe /nologo /c /coff /Cx /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)"
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug"
-
-# Begin Custom Build - Assembling...
-IntDir=.\Win32_DLL_ASM_Debug
-InputPath=..\..\contrib\masmx86\inffas32.asm
-InputName=inffas32
-
-"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- ml.exe /nologo /c /coff /Cx /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)"
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB Release"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release"
-
-# Begin Custom Build - Assembling...
-IntDir=.\Win32_LIB_ASM_Release
-InputPath=..\..\contrib\masmx86\inffas32.asm
-InputName=inffas32
-
-"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- ml.exe /nologo /c /coff /Cx /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)"
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug"
-
-# Begin Custom Build - Assembling...
-IntDir=.\Win32_LIB_ASM_Debug
-InputPath=..\..\contrib\masmx86\inffas32.asm
-InputName=inffas32
-
-"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- ml.exe /nologo /c /coff /Cx /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)"
-
-# End Custom Build
-
-!ENDIF
-
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=.\README.txt
-# End Source File
-# End Target
-# End Project
diff --git a/source4/lib/zlib/projects/visualc6/zlib.dsw b/source4/lib/zlib/projects/visualc6/zlib.dsw
deleted file mode 100644
index 3a771fce07..0000000000
--- a/source4/lib/zlib/projects/visualc6/zlib.dsw
+++ /dev/null
@@ -1,59 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "example"=.\example.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name zlib
- End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "minigzip"=.\minigzip.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name zlib
- End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "zlib"=.\zlib.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/source4/lib/zlib/qnx/package.qpg b/source4/lib/zlib/qnx/package.qpg
deleted file mode 100644
index 8a4a47c723..0000000000
--- a/source4/lib/zlib/qnx/package.qpg
+++ /dev/null
@@ -1,141 +0,0 @@
-<QPG:Generation>
- <QPG:Options>
- <QPG:User unattended="no" verbosity="2" listfiles="yes"/>
- <QPG:Defaults type="qnx_package"/>
- <QPG:Source></QPG:Source>
- <QPG:Release number="+"/>
- <QPG:Build></QPG:Build>
- <QPG:FileSorting strip="yes"/>
- <QPG:Package targets="combine"/>
- <QPG:Repository generate="yes"/>
- <QPG:FinalDir></QPG:FinalDir>
- <QPG:Cleanup></QPG:Cleanup>
- </QPG:Options>
-
- <QPG:Responsible>
- <QPG:Company></QPG:Company>
- <QPG:Department></QPG:Department>
- <QPG:Group></QPG:Group>
- <QPG:Team></QPG:Team>
- <QPG:Employee></QPG:Employee>
- <QPG:EmailAddress></QPG:EmailAddress>
- </QPG:Responsible>
-
- <QPG:Values>
- <QPG:Files>
- <QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/>
- <QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/>
- <QPG:Add file="../libz.so.1.2.3" install="/opt/lib/" user="root:bin" permission="644"/>
- <QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.3"/>
- <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.3"/>
- <QPG:Add file="../libz.so.1.2.3" install="/opt/lib/" component="slib"/>
- </QPG:Files>
-
- <QPG:PackageFilter>
- <QPM:PackageManifest>
- <QPM:PackageDescription>
- <QPM:PackageType>Library</QPM:PackageType>
- <QPM:PackageReleaseNotes></QPM:PackageReleaseNotes>
- <QPM:PackageReleaseUrgency>Medium</QPM:PackageReleaseUrgency>
- <QPM:PackageRepository></QPM:PackageRepository>
- <QPM:FileVersion>2.0</QPM:FileVersion>
- </QPM:PackageDescription>
-
- <QPM:ProductDescription>
- <QPM:ProductName>zlib</QPM:ProductName>
- <QPM:ProductIdentifier>zlib</QPM:ProductIdentifier>
- <QPM:ProductEmail>alain.bonnefoy@icbt.com</QPM:ProductEmail>
- <QPM:VendorName>Public</QPM:VendorName>
- <QPM:VendorInstallName>public</QPM:VendorInstallName>
- <QPM:VendorURL>www.gzip.org/zlib</QPM:VendorURL>
- <QPM:VendorEmbedURL></QPM:VendorEmbedURL>
- <QPM:VendorEmail></QPM:VendorEmail>
- <QPM:AuthorName>Jean-Loup Gailly,Mark Adler</QPM:AuthorName>
- <QPM:AuthorURL>www.gzip.org/zlib</QPM:AuthorURL>
- <QPM:AuthorEmbedURL></QPM:AuthorEmbedURL>
- <QPM:AuthorEmail>zlib@gzip.org</QPM:AuthorEmail>
- <QPM:ProductIconSmall></QPM:ProductIconSmall>
- <QPM:ProductIconLarge></QPM:ProductIconLarge>
- <QPM:ProductDescriptionShort>A massively spiffy yet delicately unobtrusive compression library.</QPM:ProductDescriptionShort>
- <QPM:ProductDescriptionLong>zlib is designed to be a free, general-purpose, legally unencumbered, lossless data compression library for use on virtually any computer hardware and operating system.</QPM:ProductDescriptionLong>
- <QPM:ProductDescriptionURL>http://www.gzip.org/zlib</QPM:ProductDescriptionURL>
- <QPM:ProductDescriptionEmbedURL></QPM:ProductDescriptionEmbedURL>
- </QPM:ProductDescription>
-
- <QPM:ReleaseDescription>
- <QPM:ReleaseVersion>1.2.3</QPM:ReleaseVersion>
- <QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency>
- <QPM:ReleaseStability>Stable</QPM:ReleaseStability>
- <QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor>
- <QPM:ReleaseNoteMajor></QPM:ReleaseNoteMajor>
- <QPM:ExcludeCountries>
- <QPM:Country></QPM:Country>
- </QPM:ExcludeCountries>
-
- <QPM:ReleaseCopyright>No License</QPM:ReleaseCopyright>
- </QPM:ReleaseDescription>
-
- <QPM:ContentDescription>
- <QPM:ContentTopic xmlmultiple="true">Software Development/Libraries and Extensions/C Libraries</QPM:ContentTopic>
- <QPM:ContentKeyword>zlib,compression</QPM:ContentKeyword>
- <QPM:TargetOS>qnx6</QPM:TargetOS>
- <QPM:HostOS>qnx6</QPM:HostOS>
- <QPM:DisplayEnvironment xmlmultiple="true">None</QPM:DisplayEnvironment>
- <QPM:TargetAudience xmlmultiple="true">Developer</QPM:TargetAudience>
- </QPM:ContentDescription>
- </QPM:PackageManifest>
- </QPG:PackageFilter>
-
- <QPG:PackageFilter proc="none" target="none">
- <QPM:PackageManifest>
- <QPM:ProductInstallationDependencies>
- <QPM:ProductRequirements></QPM:ProductRequirements>
- </QPM:ProductInstallationDependencies>
-
- <QPM:ProductInstallationProcedure>
- <QPM:Script xmlmultiple="true">
- <QPM:ScriptName></QPM:ScriptName>
- <QPM:ScriptType>Install</QPM:ScriptType>
- <QPM:ScriptTiming>Post</QPM:ScriptTiming>
- <QPM:ScriptBlocking>No</QPM:ScriptBlocking>
- <QPM:ScriptResult>Ignore</QPM:ScriptResult>
- <QPM:ShortDescription></QPM:ShortDescription>
- <QPM:UseBinaries>No</QPM:UseBinaries>
- <QPM:Priority>Optional</QPM:Priority>
- </QPM:Script>
- </QPM:ProductInstallationProcedure>
- </QPM:PackageManifest>
-
- <QPM:Launch>
- </QPM:Launch>
- </QPG:PackageFilter>
-
- <QPG:PackageFilter type="core" component="none">
- <QPM:PackageManifest>
- <QPM:ProductInstallationProcedure>
- <QPM:OrderDependency xmlmultiple="true">
- <QPM:Order>InstallOver</QPM:Order>
- <QPM:Product>zlib</QPM:Product>
- </QPM:OrderDependency>
- </QPM:ProductInstallationProcedure>
- </QPM:PackageManifest>
-
- <QPM:Launch>
- </QPM:Launch>
- </QPG:PackageFilter>
-
- <QPG:PackageFilter type="core" component="dev">
- <QPM:PackageManifest>
- <QPM:ProductInstallationProcedure>
- <QPM:OrderDependency xmlmultiple="true">
- <QPM:Order>InstallOver</QPM:Order>
- <QPM:Product>zlib-dev</QPM:Product>
- </QPM:OrderDependency>
- </QPM:ProductInstallationProcedure>
- </QPM:PackageManifest>
-
- <QPM:Launch>
- </QPM:Launch>
- </QPG:PackageFilter>
- </QPG:Values>
-</QPG:Generation>
diff --git a/source4/lib/zlib/trees.c b/source4/lib/zlib/trees.c
deleted file mode 100644
index eb55679adc..0000000000
--- a/source4/lib/zlib/trees.c
+++ /dev/null
@@ -1,1219 +0,0 @@
-/* trees.c -- output deflated data using Huffman coding
- * Copyright (C) 1995-2005 Jean-loup Gailly
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * ALGORITHM
- *
- * The "deflation" process uses several Huffman trees. The more
- * common source values are represented by shorter bit sequences.
- *
- * Each code tree is stored in a compressed form which is itself
- * a Huffman encoding of the lengths of all the code strings (in
- * ascending order by source values). The actual code strings are
- * reconstructed from the lengths in the inflate process, as described
- * in the deflate specification.
- *
- * REFERENCES
- *
- * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification".
- * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc
- *
- * Storer, James A.
- * Data Compression: Methods and Theory, pp. 49-50.
- * Computer Science Press, 1988. ISBN 0-7167-8156-5.
- *
- * Sedgewick, R.
- * Algorithms, p290.
- * Addison-Wesley, 1983. ISBN 0-201-06672-6.
- */
-
-/* @(#) $Id$ */
-
-/* #define GEN_TREES_H */
-
-#include "deflate.h"
-
-#ifdef DEBUG
-# include <ctype.h>
-#endif
-
-/* ===========================================================================
- * Constants
- */
-
-#define MAX_BL_BITS 7
-/* Bit length codes must not exceed MAX_BL_BITS bits */
-
-#define END_BLOCK 256
-/* end of block literal code */
-
-#define REP_3_6 16
-/* repeat previous bit length 3-6 times (2 bits of repeat count) */
-
-#define REPZ_3_10 17
-/* repeat a zero length 3-10 times (3 bits of repeat count) */
-
-#define REPZ_11_138 18
-/* repeat a zero length 11-138 times (7 bits of repeat count) */
-
-local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
- = {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};
-
-local const int extra_dbits[D_CODES] /* extra bits for each distance code */
- = {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};
-
-local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */
- = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
-
-local const uch bl_order[BL_CODES]
- = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
-/* The lengths of the bit length codes are sent in order of decreasing
- * probability, to avoid transmitting the lengths for unused bit length codes.
- */
-
-#define Buf_size (8 * 2*sizeof(char))
-/* Number of bits used within bi_buf. (bi_buf might be implemented on
- * more than 16 bits on some systems.)
- */
-
-/* ===========================================================================
- * Local data. These are initialized only once.
- */
-
-#define DIST_CODE_LEN 512 /* see definition of array dist_code below */
-
-#if defined(GEN_TREES_H) || !defined(STDC)
-/* non ANSI compilers may not accept trees.h */
-
-local ct_data static_ltree[L_CODES+2];
-/* The static literal tree. Since the bit lengths are imposed, there is no
- * need for the L_CODES extra codes used during heap construction. However
- * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
- * below).
- */
-
-local ct_data static_dtree[D_CODES];
-/* The static distance tree. (Actually a trivial tree since all codes use
- * 5 bits.)
- */
-
-uch _dist_code[DIST_CODE_LEN];
-/* Distance codes. The first 256 values correspond to the distances
- * 3 .. 258, the last 256 values correspond to the top 8 bits of
- * the 15 bit distances.
- */
-
-uch _length_code[MAX_MATCH-MIN_MATCH+1];
-/* length code for each normalized match length (0 == MIN_MATCH) */
-
-local int base_length[LENGTH_CODES];
-/* First normalized length for each code (0 = MIN_MATCH) */
-
-local int base_dist[D_CODES];
-/* First normalized distance for each code (0 = distance of 1) */
-
-#else
-# include "trees.h"
-#endif /* GEN_TREES_H */
-
-struct static_tree_desc_s {
- const ct_data *static_tree; /* static tree or NULL */
- const intf *extra_bits; /* extra bits for each code or NULL */
- int extra_base; /* base index for extra_bits */
- int elems; /* max number of elements in the tree */
- int max_length; /* max bit length for the codes */
-};
-
-local static_tree_desc static_l_desc =
-{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
-
-local static_tree_desc static_d_desc =
-{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
-
-local static_tree_desc static_bl_desc =
-{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
-
-/* ===========================================================================
- * Local (static) routines in this file.
- */
-
-local void tr_static_init OF((void));
-local void init_block OF((deflate_state *s));
-local void pqdownheap OF((deflate_state *s, ct_data *tree, int k));
-local void gen_bitlen OF((deflate_state *s, tree_desc *desc));
-local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count));
-local void build_tree OF((deflate_state *s, tree_desc *desc));
-local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code));
-local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
-local int build_bl_tree OF((deflate_state *s));
-local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
- int blcodes));
-local void compress_block OF((deflate_state *s, const ct_data *ltree,
- const ct_data *dtree));
-local void set_data_type OF((deflate_state *s));
-local unsigned bi_reverse OF((unsigned value, int length));
-local void bi_windup OF((deflate_state *s));
-local void bi_flush OF((deflate_state *s));
-local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
- int header));
-
-#ifdef GEN_TREES_H
-local void gen_trees_header OF((void));
-#endif
-
-#ifndef DEBUG
-# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
- /* Send a code of the given tree. c and tree must not have side effects */
-
-#else /* DEBUG */
-# define send_code(s, c, tree) \
- { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
- send_bits(s, tree[c].Code, tree[c].Len); }
-#endif
-
-/* ===========================================================================
- * Output a short LSB first on the stream.
- * IN assertion: there is enough room in pendingBuf.
- */
-#define put_short(s, w) { \
- put_byte(s, (uch)((w) & 0xff)); \
- put_byte(s, (uch)((ush)(w) >> 8)); \
-}
-
-/* ===========================================================================
- * Send a value on a given number of bits.
- * IN assertion: length <= 16 and value fits in length bits.
- */
-#ifdef DEBUG
-local void send_bits OF((deflate_state *s, int value, int length));
-
-local void send_bits(s, value, length)
- deflate_state *s;
- int value; /* value to send */
- int length; /* number of bits */
-{
- Tracevv((stderr," l %2d v %4x ", length, value));
- Assert(length > 0 && length <= 15, "invalid length");
- s->bits_sent += (ulg)length;
-
- /* If not enough room in bi_buf, use (valid) bits from bi_buf and
- * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
- * unused bits in value.
- */
- if (s->bi_valid > (int)Buf_size - length) {
- s->bi_buf |= (value << s->bi_valid);
- put_short(s, s->bi_buf);
- s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
- s->bi_valid += length - Buf_size;
- } else {
- s->bi_buf |= value << s->bi_valid;
- s->bi_valid += length;
- }
-}
-#else /* !DEBUG */
-
-#define send_bits(s, value, length) \
-{ int len = length;\
- if (s->bi_valid > (int)Buf_size - len) {\
- int val = value;\
- s->bi_buf |= (val << s->bi_valid);\
- put_short(s, s->bi_buf);\
- s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
- s->bi_valid += len - Buf_size;\
- } else {\
- s->bi_buf |= (value) << s->bi_valid;\
- s->bi_valid += len;\
- }\
-}
-#endif /* DEBUG */
-
-
-/* the arguments must not have side effects */
-
-/* ===========================================================================
- * Initialize the various 'constant' tables.
- */
-local void tr_static_init()
-{
-#if defined(GEN_TREES_H) || !defined(STDC)
- static int static_init_done = 0;
- int n; /* iterates over tree elements */
- int bits; /* bit counter */
- int length; /* length value */
- int code; /* code value */
- int dist; /* distance index */
- ush bl_count[MAX_BITS+1];
- /* number of codes at each bit length for an optimal tree */
-
- if (static_init_done) return;
-
- /* For some embedded targets, global variables are not initialized: */
- static_l_desc.static_tree = static_ltree;
- static_l_desc.extra_bits = extra_lbits;
- static_d_desc.static_tree = static_dtree;
- static_d_desc.extra_bits = extra_dbits;
- static_bl_desc.extra_bits = extra_blbits;
-
- /* Initialize the mapping length (0..255) -> length code (0..28) */
- length = 0;
- for (code = 0; code < LENGTH_CODES-1; code++) {
- base_length[code] = length;
- for (n = 0; n < (1<<extra_lbits[code]); n++) {
- _length_code[length++] = (uch)code;
- }
- }
- Assert (length == 256, "tr_static_init: length != 256");
- /* Note that the length 255 (match length 258) can be represented
- * in two different ways: code 284 + 5 bits or code 285, so we
- * overwrite length_code[255] to use the best encoding:
- */
- _length_code[length-1] = (uch)code;
-
- /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
- dist = 0;
- for (code = 0 ; code < 16; code++) {
- base_dist[code] = dist;
- for (n = 0; n < (1<<extra_dbits[code]); n++) {
- _dist_code[dist++] = (uch)code;
- }
- }
- Assert (dist == 256, "tr_static_init: dist != 256");
- dist >>= 7; /* from now on, all distances are divided by 128 */
- for ( ; code < D_CODES; code++) {
- base_dist[code] = dist << 7;
- for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
- _dist_code[256 + dist++] = (uch)code;
- }
- }
- Assert (dist == 256, "tr_static_init: 256+dist != 512");
-
- /* Construct the codes of the static literal tree */
- for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
- n = 0;
- while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
- while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
- while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
- while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
- /* Codes 286 and 287 do not exist, but we must include them in the
- * tree construction to get a canonical Huffman tree (longest code
- * all ones)
- */
- gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count);
-
- /* The static distance tree is trivial: */
- for (n = 0; n < D_CODES; n++) {
- static_dtree[n].Len = 5;
- static_dtree[n].Code = bi_reverse((unsigned)n, 5);
- }
- static_init_done = 1;
-
-# ifdef GEN_TREES_H
- gen_trees_header();
-# endif
-#endif /* defined(GEN_TREES_H) || !defined(STDC) */
-}
-
-/* ===========================================================================
- * Genererate the file trees.h describing the static trees.
- */
-#ifdef GEN_TREES_H
-# ifndef DEBUG
-# include <stdio.h>
-# endif
-
-# define SEPARATOR(i, last, width) \
- ((i) == (last)? "\n};\n\n" : \
- ((i) % (width) == (width)-1 ? ",\n" : ", "))
-
-void gen_trees_header()
-{
- FILE *header = fopen("trees.h", "w");
- int i;
-
- Assert (header != NULL, "Can't open trees.h");
- fprintf(header,
- "/* header created automatically with -DGEN_TREES_H */\n\n");
-
- fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n");
- for (i = 0; i < L_CODES+2; i++) {
- fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code,
- static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
- }
-
- fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n");
- for (i = 0; i < D_CODES; i++) {
- fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code,
- static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
- }
-
- fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n");
- for (i = 0; i < DIST_CODE_LEN; i++) {
- fprintf(header, "%2u%s", _dist_code[i],
- SEPARATOR(i, DIST_CODE_LEN-1, 20));
- }
-
- fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
- for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
- fprintf(header, "%2u%s", _length_code[i],
- SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
- }
-
- fprintf(header, "local const int base_length[LENGTH_CODES] = {\n");
- for (i = 0; i < LENGTH_CODES; i++) {
- fprintf(header, "%1u%s", base_length[i],
- SEPARATOR(i, LENGTH_CODES-1, 20));
- }
-
- fprintf(header, "local const int base_dist[D_CODES] = {\n");
- for (i = 0; i < D_CODES; i++) {
- fprintf(header, "%5u%s", base_dist[i],
- SEPARATOR(i, D_CODES-1, 10));
- }
-
- fclose(header);
-}
-#endif /* GEN_TREES_H */
-
-/* ===========================================================================
- * Initialize the tree data structures for a new zlib stream.
- */
-void _tr_init(s)
- deflate_state *s;
-{
- tr_static_init();
-
- s->l_desc.dyn_tree = s->dyn_ltree;
- s->l_desc.stat_desc = &static_l_desc;
-
- s->d_desc.dyn_tree = s->dyn_dtree;
- s->d_desc.stat_desc = &static_d_desc;
-
- s->bl_desc.dyn_tree = s->bl_tree;
- s->bl_desc.stat_desc = &static_bl_desc;
-
- s->bi_buf = 0;
- s->bi_valid = 0;
- s->last_eob_len = 8; /* enough lookahead for inflate */
-#ifdef DEBUG
- s->compressed_len = 0L;
- s->bits_sent = 0L;
-#endif
-
- /* Initialize the first block of the first file: */
- init_block(s);
-}
-
-/* ===========================================================================
- * Initialize a new block.
- */
-local void init_block(s)
- deflate_state *s;
-{
- int n; /* iterates over tree elements */
-
- /* Initialize the trees. */
- for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
- for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
- for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
-
- s->dyn_ltree[END_BLOCK].Freq = 1;
- s->opt_len = s->static_len = 0L;
- s->last_lit = s->matches = 0;
-}
-
-#define SMALLEST 1
-/* Index within the heap array of least frequent node in the Huffman tree */
-
-
-/* ===========================================================================
- * Remove the smallest element from the heap and recreate the heap with
- * one less element. Updates heap and heap_len.
- */
-#define pqremove(s, tree, top) \
-{\
- top = s->heap[SMALLEST]; \
- s->heap[SMALLEST] = s->heap[s->heap_len--]; \
- pqdownheap(s, tree, SMALLEST); \
-}
-
-/* ===========================================================================
- * Compares to subtrees, using the tree depth as tie breaker when
- * the subtrees have equal frequency. This minimizes the worst case length.
- */
-#define smaller(tree, n, m, depth) \
- (tree[n].Freq < tree[m].Freq || \
- (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
-
-/* ===========================================================================
- * Restore the heap property by moving down the tree starting at node k,
- * exchanging a node with the smallest of its two sons if necessary, stopping
- * when the heap property is re-established (each father smaller than its
- * two sons).
- */
-local void pqdownheap(s, tree, k)
- deflate_state *s;
- ct_data *tree; /* the tree to restore */
- int k; /* node to move down */
-{
- int v = s->heap[k];
- int j = k << 1; /* left son of k */
- while (j <= s->heap_len) {
- /* Set j to the smallest of the two sons: */
- if (j < s->heap_len &&
- smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
- j++;
- }
- /* Exit if v is smaller than both sons */
- if (smaller(tree, v, s->heap[j], s->depth)) break;
-
- /* Exchange v with the smallest son */
- s->heap[k] = s->heap[j]; k = j;
-
- /* And continue down the tree, setting j to the left son of k */
- j <<= 1;
- }
- s->heap[k] = v;
-}
-
-/* ===========================================================================
- * Compute the optimal bit lengths for a tree and update the total bit length
- * for the current block.
- * IN assertion: the fields freq and dad are set, heap[heap_max] and
- * above are the tree nodes sorted by increasing frequency.
- * OUT assertions: the field len is set to the optimal bit length, the
- * array bl_count contains the frequencies for each bit length.
- * The length opt_len is updated; static_len is also updated if stree is
- * not null.
- */
-local void gen_bitlen(s, desc)
- deflate_state *s;
- tree_desc *desc; /* the tree descriptor */
-{
- ct_data *tree = desc->dyn_tree;
- int max_code = desc->max_code;
- const ct_data *stree = desc->stat_desc->static_tree;
- const intf *extra = desc->stat_desc->extra_bits;
- int base = desc->stat_desc->extra_base;
- int max_length = desc->stat_desc->max_length;
- int h; /* heap index */
- int n, m; /* iterate over the tree elements */
- int bits; /* bit length */
- int xbits; /* extra bits */
- ush f; /* frequency */
- int overflow = 0; /* number of elements with bit length too large */
-
- for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;
-
- /* In a first pass, compute the optimal bit lengths (which may
- * overflow in the case of the bit length tree).
- */
- tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
-
- for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
- n = s->heap[h];
- bits = tree[tree[n].Dad].Len + 1;
- if (bits > max_length) bits = max_length, overflow++;
- tree[n].Len = (ush)bits;
- /* We overwrite tree[n].Dad which is no longer needed */
-
- if (n > max_code) continue; /* not a leaf node */
-
- s->bl_count[bits]++;
- xbits = 0;
- if (n >= base) xbits = extra[n-base];
- f = tree[n].Freq;
- s->opt_len += (ulg)f * (bits + xbits);
- if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
- }
- if (overflow == 0) return;
-
- Trace((stderr,"\nbit length overflow\n"));
- /* This happens for example on obj2 and pic of the Calgary corpus */
-
- /* Find the first bit length which could increase: */
- do {
- bits = max_length-1;
- while (s->bl_count[bits] == 0) bits--;
- s->bl_count[bits]--; /* move one leaf down the tree */
- s->bl_count[bits+1] += 2; /* move one overflow item as its brother */
- s->bl_count[max_length]--;
- /* The brother of the overflow item also moves one step up,
- * but this does not affect bl_count[max_length]
- */
- overflow -= 2;
- } while (overflow > 0);
-
- /* Now recompute all bit lengths, scanning in increasing frequency.
- * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
- * lengths instead of fixing only the wrong ones. This idea is taken
- * from 'ar' written by Haruhiko Okumura.)
- */
- for (bits = max_length; bits != 0; bits--) {
- n = s->bl_count[bits];
- while (n != 0) {
- m = s->heap[--h];
- if (m > max_code) continue;
- if ((unsigned) tree[m].Len != (unsigned) bits) {
- Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
- s->opt_len += ((long)bits - (long)tree[m].Len)
- *(long)tree[m].Freq;
- tree[m].Len = (ush)bits;
- }
- n--;
- }
- }
-}
-
-/* ===========================================================================
- * Generate the codes for a given tree and bit counts (which need not be
- * optimal).
- * IN assertion: the array bl_count contains the bit length statistics for
- * the given tree and the field len is set for all tree elements.
- * OUT assertion: the field code is set for all tree elements of non
- * zero code length.
- */
-local void gen_codes (tree, max_code, bl_count)
- ct_data *tree; /* the tree to decorate */
- int max_code; /* largest code with non zero frequency */
- ushf *bl_count; /* number of codes at each bit length */
-{
- ush next_code[MAX_BITS+1]; /* next code value for each bit length */
- ush code = 0; /* running code value */
- int bits; /* bit index */
- int n; /* code index */
-
- /* The distribution counts are first used to generate the code values
- * without bit reversal.
- */
- for (bits = 1; bits <= MAX_BITS; bits++) {
- next_code[bits] = code = (code + bl_count[bits-1]) << 1;
- }
- /* Check that the bit counts in bl_count are consistent. The last code
- * must be all ones.
- */
- Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
- "inconsistent bit counts");
- Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
-
- for (n = 0; n <= max_code; n++) {
- int len = tree[n].Len;
- if (len == 0) continue;
- /* Now reverse the bits */
- tree[n].Code = bi_reverse(next_code[len]++, len);
-
- Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
- n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
- }
-}
-
-/* ===========================================================================
- * Construct one Huffman tree and assigns the code bit strings and lengths.
- * Update the total bit length for the current block.
- * IN assertion: the field freq is set for all tree elements.
- * OUT assertions: the fields len and code are set to the optimal bit length
- * and corresponding code. The length opt_len is updated; static_len is
- * also updated if stree is not null. The field max_code is set.
- */
-local void build_tree(s, desc)
- deflate_state *s;
- tree_desc *desc; /* the tree descriptor */
-{
- ct_data *tree = desc->dyn_tree;
- const ct_data *stree = desc->stat_desc->static_tree;
- int elems = desc->stat_desc->elems;
- int n, m; /* iterate over heap elements */
- int max_code = -1; /* largest code with non zero frequency */
- int node; /* new node being created */
-
- /* Construct the initial heap, with least frequent element in
- * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
- * heap[0] is not used.
- */
- s->heap_len = 0, s->heap_max = HEAP_SIZE;
-
- for (n = 0; n < elems; n++) {
- if (tree[n].Freq != 0) {
- s->heap[++(s->heap_len)] = max_code = n;
- s->depth[n] = 0;
- } else {
- tree[n].Len = 0;
- }
- }
-
- /* The pkzip format requires that at least one distance code exists,
- * and that at least one bit should be sent even if there is only one
- * possible code. So to avoid special checks later on we force at least
- * two codes of non zero frequency.
- */
- while (s->heap_len < 2) {
- node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
- tree[node].Freq = 1;
- s->depth[node] = 0;
- s->opt_len--; if (stree) s->static_len -= stree[node].Len;
- /* node is 0 or 1 so it does not have extra bits */
- }
- desc->max_code = max_code;
-
- /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
- * establish sub-heaps of increasing lengths:
- */
- for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
-
- /* Construct the Huffman tree by repeatedly combining the least two
- * frequent nodes.
- */
- node = elems; /* next internal node of the tree */
- do {
- pqremove(s, tree, n); /* n = node of least frequency */
- m = s->heap[SMALLEST]; /* m = node of next least frequency */
-
- s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
- s->heap[--(s->heap_max)] = m;
-
- /* Create a new node father of n and m */
- tree[node].Freq = tree[n].Freq + tree[m].Freq;
- s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ?
- s->depth[n] : s->depth[m]) + 1);
- tree[n].Dad = tree[m].Dad = (ush)node;
-#ifdef DUMP_BL_TREE
- if (tree == s->bl_tree) {
- fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)",
- node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
- }
-#endif
- /* and insert the new node in the heap */
- s->heap[SMALLEST] = node++;
- pqdownheap(s, tree, SMALLEST);
-
- } while (s->heap_len >= 2);
-
- s->heap[--(s->heap_max)] = s->heap[SMALLEST];
-
- /* At this point, the fields freq and dad are set. We can now
- * generate the bit lengths.
- */
- gen_bitlen(s, (tree_desc *)desc);
-
- /* The field len is now set, we can generate the bit codes */
- gen_codes ((ct_data *)tree, max_code, s->bl_count);
-}
-
-/* ===========================================================================
- * Scan a literal or distance tree to determine the frequencies of the codes
- * in the bit length tree.
- */
-local void scan_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
-{
- int n; /* iterates over all tree elements */
- int prevlen = -1; /* last emitted length */
- int curlen; /* length of current code */
- int nextlen = tree[0].Len; /* length of next code */
- int count = 0; /* repeat count of the current code */
- int max_count = 7; /* max repeat count */
- int min_count = 4; /* min repeat count */
-
- if (nextlen == 0) max_count = 138, min_count = 3;
- tree[max_code+1].Len = (ush)0xffff; /* guard */
-
- for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
- if (++count < max_count && curlen == nextlen) {
- continue;
- } else if (count < min_count) {
- s->bl_tree[curlen].Freq += count;
- } else if (curlen != 0) {
- if (curlen != prevlen) s->bl_tree[curlen].Freq++;
- s->bl_tree[REP_3_6].Freq++;
- } else if (count <= 10) {
- s->bl_tree[REPZ_3_10].Freq++;
- } else {
- s->bl_tree[REPZ_11_138].Freq++;
- }
- count = 0; prevlen = curlen;
- if (nextlen == 0) {
- max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
- max_count = 6, min_count = 3;
- } else {
- max_count = 7, min_count = 4;
- }
- }
-}
-
-/* ===========================================================================
- * Send a literal or distance tree in compressed form, using the codes in
- * bl_tree.
- */
-local void send_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
-{
- int n; /* iterates over all tree elements */
- int prevlen = -1; /* last emitted length */
- int curlen; /* length of current code */
- int nextlen = tree[0].Len; /* length of next code */
- int count = 0; /* repeat count of the current code */
- int max_count = 7; /* max repeat count */
- int min_count = 4; /* min repeat count */
-
- /* tree[max_code+1].Len = -1; */ /* guard already set */
- if (nextlen == 0) max_count = 138, min_count = 3;
-
- for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
- if (++count < max_count && curlen == nextlen) {
- continue;
- } else if (count < min_count) {
- do { send_code(s, curlen, s->bl_tree); } while (--count != 0);
-
- } else if (curlen != 0) {
- if (curlen != prevlen) {
- send_code(s, curlen, s->bl_tree); count--;
- }
- Assert(count >= 3 && count <= 6, " 3_6?");
- send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
-
- } else if (count <= 10) {
- send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
-
- } else {
- send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
- }
- count = 0; prevlen = curlen;
- if (nextlen == 0) {
- max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
- max_count = 6, min_count = 3;
- } else {
- max_count = 7, min_count = 4;
- }
- }
-}
-
-/* ===========================================================================
- * Construct the Huffman tree for the bit lengths and return the index in
- * bl_order of the last bit length code to send.
- */
-local int build_bl_tree(s)
- deflate_state *s;
-{
- int max_blindex; /* index of last bit length code of non zero freq */
-
- /* Determine the bit length frequencies for literal and distance trees */
- scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
- scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
-
- /* Build the bit length tree: */
- build_tree(s, (tree_desc *)(&(s->bl_desc)));
- /* opt_len now includes the length of the tree representations, except
- * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
- */
-
- /* Determine the number of bit length codes to send. The pkzip format
- * requires that at least 4 bit length codes be sent. (appnote.txt says
- * 3 but the actual value used is 4.)
- */
- for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
- if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
- }
- /* Update opt_len to include the bit length tree and counts */
- s->opt_len += 3*(max_blindex+1) + 5+5+4;
- Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
- s->opt_len, s->static_len));
-
- return max_blindex;
-}
-
-/* ===========================================================================
- * Send the header for a block using dynamic Huffman trees: the counts, the
- * lengths of the bit length codes, the literal tree and the distance tree.
- * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
- */
-local void send_all_trees(s, lcodes, dcodes, blcodes)
- deflate_state *s;
- int lcodes, dcodes, blcodes; /* number of codes for each tree */
-{
- int rank; /* index in bl_order */
-
- Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
- Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
- "too many codes");
- Tracev((stderr, "\nbl counts: "));
- send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */
- send_bits(s, dcodes-1, 5);
- send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */
- for (rank = 0; rank < blcodes; rank++) {
- Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
- send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
- }
- Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
-
- send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
- Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
-
- send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
- Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
-}
-
-/* ===========================================================================
- * Send a stored block
- */
-void _tr_stored_block(s, buf, stored_len, eof)
- deflate_state *s;
- charf *buf; /* input block */
- ulg stored_len; /* length of input block */
- int eof; /* true if this is the last block for a file */
-{
- send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */
-#ifdef DEBUG
- s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
- s->compressed_len += (stored_len + 4) << 3;
-#endif
- copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
-}
-
-/* ===========================================================================
- * Send one empty static block to give enough lookahead for inflate.
- * This takes 10 bits, of which 7 may remain in the bit buffer.
- * The current inflate code requires 9 bits of lookahead. If the
- * last two codes for the previous block (real code plus EOB) were coded
- * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode
- * the last real code. In this case we send two empty static blocks instead
- * of one. (There are no problems if the previous block is stored or fixed.)
- * To simplify the code, we assume the worst case of last real code encoded
- * on one bit only.
- */
-void _tr_align(s)
- deflate_state *s;
-{
- send_bits(s, STATIC_TREES<<1, 3);
- send_code(s, END_BLOCK, static_ltree);
-#ifdef DEBUG
- s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
-#endif
- bi_flush(s);
- /* Of the 10 bits for the empty block, we have already sent
- * (10 - bi_valid) bits. The lookahead for the last real code (before
- * the EOB of the previous block) was thus at least one plus the length
- * of the EOB plus what we have just sent of the empty static block.
- */
- if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
- send_bits(s, STATIC_TREES<<1, 3);
- send_code(s, END_BLOCK, static_ltree);
-#ifdef DEBUG
- s->compressed_len += 10L;
-#endif
- bi_flush(s);
- }
- s->last_eob_len = 7;
-}
-
-/* ===========================================================================
- * Determine the best encoding for the current block: dynamic trees, static
- * trees or store, and output the encoded block to the zip file.
- */
-void _tr_flush_block(s, buf, stored_len, eof)
- deflate_state *s;
- charf *buf; /* input block, or NULL if too old */
- ulg stored_len; /* length of input block */
- int eof; /* true if this is the last block for a file */
-{
- ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
- int max_blindex = 0; /* index of last bit length code of non zero freq */
-
- /* Build the Huffman trees unless a stored block is forced */
- if (s->level > 0) {
-
- /* Check if the file is binary or text */
- if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN)
- set_data_type(s);
-
- /* Construct the literal and distance trees */
- build_tree(s, (tree_desc *)(&(s->l_desc)));
- Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
- s->static_len));
-
- build_tree(s, (tree_desc *)(&(s->d_desc)));
- Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
- s->static_len));
- /* At this point, opt_len and static_len are the total bit lengths of
- * the compressed block data, excluding the tree representations.
- */
-
- /* Build the bit length tree for the above two trees, and get the index
- * in bl_order of the last bit length code to send.
- */
- max_blindex = build_bl_tree(s);
-
- /* Determine the best encoding. Compute the block lengths in bytes. */
- opt_lenb = (s->opt_len+3+7)>>3;
- static_lenb = (s->static_len+3+7)>>3;
-
- Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
- opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
- s->last_lit));
-
- if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
-
- } else {
- Assert(buf != (char*)0, "lost buf");
- opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
- }
-
-#ifdef FORCE_STORED
- if (buf != (char*)0) { /* force stored block */
-#else
- if (stored_len+4 <= opt_lenb && buf != (char*)0) {
- /* 4: two words for the lengths */
-#endif
- /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
- * Otherwise we can't have processed more than WSIZE input bytes since
- * the last block flush, because compression would have been
- * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
- * transform a block into a stored block.
- */
- _tr_stored_block(s, buf, stored_len, eof);
-
-#ifdef FORCE_STATIC
- } else if (static_lenb >= 0) { /* force static trees */
-#else
- } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
-#endif
- send_bits(s, (STATIC_TREES<<1)+eof, 3);
- compress_block(s, static_ltree, static_dtree);
-#ifdef DEBUG
- s->compressed_len += 3 + s->static_len;
-#endif
- } else {
- send_bits(s, (DYN_TREES<<1)+eof, 3);
- send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
- max_blindex+1);
- compress_block(s, s->dyn_ltree, s->dyn_dtree);
-#ifdef DEBUG
- s->compressed_len += 3 + s->opt_len;
-#endif
- }
- Assert (s->compressed_len == s->bits_sent, "bad compressed size");
- /* The above check is made mod 2^32, for files larger than 512 MB
- * and uLong implemented on 32 bits.
- */
- init_block(s);
-
- if (eof) {
- bi_windup(s);
-#ifdef DEBUG
- s->compressed_len += 7; /* align on byte boundary */
-#endif
- }
- Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
- s->compressed_len-7*eof));
-}
-
-/* ===========================================================================
- * Save the match info and tally the frequency counts. Return true if
- * the current block must be flushed.
- */
-int _tr_tally (s, dist, lc)
- deflate_state *s;
- unsigned dist; /* distance of matched string */
- unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
-{
- s->d_buf[s->last_lit] = (ush)dist;
- s->l_buf[s->last_lit++] = (uch)lc;
- if (dist == 0) {
- /* lc is the unmatched char */
- s->dyn_ltree[lc].Freq++;
- } else {
- s->matches++;
- /* Here, lc is the match length - MIN_MATCH */
- dist--; /* dist = match distance - 1 */
- Assert((ush)dist < (ush)MAX_DIST(s) &&
- (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
- (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
-
- s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
- s->dyn_dtree[d_code(dist)].Freq++;
- }
-
-#ifdef TRUNCATE_BLOCK
- /* Try to guess if it is profitable to stop the current block here */
- if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
- /* Compute an upper bound for the compressed length */
- ulg out_length = (ulg)s->last_lit*8L;
- ulg in_length = (ulg)((long)s->strstart - s->block_start);
- int dcode;
- for (dcode = 0; dcode < D_CODES; dcode++) {
- out_length += (ulg)s->dyn_dtree[dcode].Freq *
- (5L+extra_dbits[dcode]);
- }
- out_length >>= 3;
- Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
- s->last_lit, in_length, out_length,
- 100L - out_length*100L/in_length));
- if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
- }
-#endif
- return (s->last_lit == s->lit_bufsize-1);
- /* We avoid equality with lit_bufsize because of wraparound at 64K
- * on 16 bit machines and because stored blocks are restricted to
- * 64K-1 bytes.
- */
-}
-
-/* ===========================================================================
- * Send the block data compressed using the given Huffman trees
- */
-local void compress_block(s, ltree, dtree)
- deflate_state *s;
- const ct_data *ltree; /* literal tree */
- const ct_data *dtree; /* distance tree */
-{
- unsigned dist; /* distance of matched string */
- int lc; /* match length or unmatched char (if dist == 0) */
- unsigned lx = 0; /* running index in l_buf */
- unsigned code; /* the code to send */
- int extra; /* number of extra bits to send */
-
- if (s->last_lit != 0) do {
- dist = s->d_buf[lx];
- lc = s->l_buf[lx++];
- if (dist == 0) {
- send_code(s, lc, ltree); /* send a literal byte */
- Tracecv(isgraph(lc), (stderr," '%c' ", lc));
- } else {
- /* Here, lc is the match length - MIN_MATCH */
- code = _length_code[lc];
- send_code(s, code+LITERALS+1, ltree); /* send the length code */
- extra = extra_lbits[code];
- if (extra != 0) {
- lc -= base_length[code];
- send_bits(s, lc, extra); /* send the extra length bits */
- }
- dist--; /* dist is now the match distance - 1 */
- code = d_code(dist);
- Assert (code < D_CODES, "bad d_code");
-
- send_code(s, code, dtree); /* send the distance code */
- extra = extra_dbits[code];
- if (extra != 0) {
- dist -= base_dist[code];
- send_bits(s, dist, extra); /* send the extra distance bits */
- }
- } /* literal or match pair ? */
-
- /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
- Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
- "pendingBuf overflow");
-
- } while (lx < s->last_lit);
-
- send_code(s, END_BLOCK, ltree);
- s->last_eob_len = ltree[END_BLOCK].Len;
-}
-
-/* ===========================================================================
- * Set the data type to BINARY or TEXT, using a crude approximation:
- * set it to Z_TEXT if all symbols are either printable characters (33 to 255)
- * or white spaces (9 to 13, or 32); or set it to Z_BINARY otherwise.
- * IN assertion: the fields Freq of dyn_ltree are set.
- */
-local void set_data_type(s)
- deflate_state *s;
-{
- int n;
-
- for (n = 0; n < 9; n++)
- if (s->dyn_ltree[n].Freq != 0)
- break;
- if (n == 9)
- for (n = 14; n < 32; n++)
- if (s->dyn_ltree[n].Freq != 0)
- break;
- s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY;
-}
-
-/* ===========================================================================
- * Reverse the first len bits of a code, using straightforward code (a faster
- * method would use a table)
- * IN assertion: 1 <= len <= 15
- */
-local unsigned bi_reverse(code, len)
- unsigned code; /* the value to invert */
- int len; /* its bit length */
-{
- register unsigned res = 0;
- do {
- res |= code & 1;
- code >>= 1, res <<= 1;
- } while (--len > 0);
- return res >> 1;
-}
-
-/* ===========================================================================
- * Flush the bit buffer, keeping at most 7 bits in it.
- */
-local void bi_flush(s)
- deflate_state *s;
-{
- if (s->bi_valid == 16) {
- put_short(s, s->bi_buf);
- s->bi_buf = 0;
- s->bi_valid = 0;
- } else if (s->bi_valid >= 8) {
- put_byte(s, (Byte)s->bi_buf);
- s->bi_buf >>= 8;
- s->bi_valid -= 8;
- }
-}
-
-/* ===========================================================================
- * Flush the bit buffer and align the output on a byte boundary
- */
-local void bi_windup(s)
- deflate_state *s;
-{
- if (s->bi_valid > 8) {
- put_short(s, s->bi_buf);
- } else if (s->bi_valid > 0) {
- put_byte(s, (Byte)s->bi_buf);
- }
- s->bi_buf = 0;
- s->bi_valid = 0;
-#ifdef DEBUG
- s->bits_sent = (s->bits_sent+7) & ~7;
-#endif
-}
-
-/* ===========================================================================
- * Copy a stored block, storing first the length and its
- * one's complement if requested.
- */
-local void copy_block(s, buf, len, header)
- deflate_state *s;
- charf *buf; /* the input data */
- unsigned len; /* its length */
- int header; /* true if block header must be written */
-{
- bi_windup(s); /* align on byte boundary */
- s->last_eob_len = 8; /* enough lookahead for inflate */
-
- if (header) {
- put_short(s, (ush)len);
- put_short(s, (ush)~len);
-#ifdef DEBUG
- s->bits_sent += 2*16;
-#endif
- }
-#ifdef DEBUG
- s->bits_sent += (ulg)len<<3;
-#endif
- while (len--) {
- put_byte(s, *buf++);
- }
-}
diff --git a/source4/lib/zlib/trees.h b/source4/lib/zlib/trees.h
deleted file mode 100644
index 72facf900f..0000000000
--- a/source4/lib/zlib/trees.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/* header created automatically with -DGEN_TREES_H */
-
-local const ct_data static_ltree[L_CODES+2] = {
-{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
-{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
-{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
-{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
-{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
-{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
-{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
-{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
-{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
-{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
-{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
-{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
-{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
-{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
-{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
-{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
-{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
-{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
-{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
-{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
-{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
-{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
-{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
-{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
-{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
-{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
-{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
-{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
-{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
-{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
-{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
-{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
-{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
-{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
-{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
-{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
-{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
-{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
-{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
-{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
-{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
-{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
-{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
-{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
-{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
-{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
-{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
-{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
-{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
-{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
-{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
-{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
-{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
-{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
-{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
-{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
-{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
-{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
-};
-
-local const ct_data static_dtree[D_CODES] = {
-{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
-{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
-{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
-{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
-{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
-{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
-};
-
-const uch _dist_code[DIST_CODE_LEN] = {
- 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
- 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
-10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
-12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
-13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
-13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
-18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
-23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
-};
-
-const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
-13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
-17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
-19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
-22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
-23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
-25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
-};
-
-local const int base_length[LENGTH_CODES] = {
-0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
-64, 80, 96, 112, 128, 160, 192, 224, 0
-};
-
-local const int base_dist[D_CODES] = {
- 0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
- 32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
- 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
-};
-
diff --git a/source4/lib/zlib/uncompr.c b/source4/lib/zlib/uncompr.c
deleted file mode 100644
index a052f22e74..0000000000
--- a/source4/lib/zlib/uncompr.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* uncompr.c -- decompress a memory buffer
- * Copyright (C) 1995-2003 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#include "zutil.h"
-
-/* ===========================================================================
- Decompresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be large enough to hold the
- entire uncompressed data. (The size of the uncompressed data must have
- been saved previously by the compressor and transmitted to the decompressor
- by some mechanism outside the scope of this compression library.)
- Upon exit, destLen is the actual size of the compressed buffer.
- This function can be used to decompress a whole file at once if the
- input file is mmap'ed.
-
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer, or Z_DATA_ERROR if the input data was corrupted.
-*/
-int ZEXPORT uncompress (dest, destLen, source, sourceLen)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
-{
- z_stream stream;
- int err;
-
- stream.next_in = source;
- stream.avail_in = (uInt)sourceLen;
- /* Check for source > 64K on 16-bit machine: */
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
-
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
-
- err = inflateInit(&stream);
- if (err != Z_OK) return err;
-
- err = inflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- inflateEnd(&stream);
- if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
- return Z_DATA_ERROR;
- return err;
- }
- *destLen = stream.total_out;
-
- err = inflateEnd(&stream);
- return err;
-}
diff --git a/source4/lib/zlib/win32/DLL_FAQ.txt b/source4/lib/zlib/win32/DLL_FAQ.txt
deleted file mode 100644
index fb18e07118..0000000000
--- a/source4/lib/zlib/win32/DLL_FAQ.txt
+++ /dev/null
@@ -1,397 +0,0 @@
-
- Frequently Asked Questions about ZLIB1.DLL
-
-
-This document describes the design, the rationale, and the usage
-of the official DLL build of zlib, named ZLIB1.DLL. If you have
-general questions about zlib, you should see the file "FAQ" found
-in the zlib distribution, or at the following location:
- http://www.gzip.org/zlib/zlib_faq.html
-
-
- 1. What is ZLIB1.DLL, and how can I get it?
-
- - ZLIB1.DLL is the official build of zlib as a DLL.
- (Please remark the character '1' in the name.)
-
- Pointers to a precompiled ZLIB1.DLL can be found in the zlib
- web site at:
- http://www.zlib.org/
-
- Applications that link to ZLIB1.DLL can rely on the following
- specification:
-
- * The exported symbols are exclusively defined in the source
- files "zlib.h" and "zlib.def", found in an official zlib
- source distribution.
- * The symbols are exported by name, not by ordinal.
- * The exported names are undecorated.
- * The calling convention of functions is "C" (CDECL).
- * The ZLIB1.DLL binary is linked to MSVCRT.DLL.
-
- The archive in which ZLIB1.DLL is bundled contains compiled
- test programs that must run with a valid build of ZLIB1.DLL.
- It is recommended to download the prebuilt DLL from the zlib
- web site, instead of building it yourself, to avoid potential
- incompatibilities that could be introduced by your compiler
- and build settings. If you do build the DLL yourself, please
- make sure that it complies with all the above requirements,
- and it runs with the precompiled test programs, bundled with
- the original ZLIB1.DLL distribution.
-
- If, for any reason, you need to build an incompatible DLL,
- please use a different file name.
-
-
- 2. Why did you change the name of the DLL to ZLIB1.DLL?
- What happened to the old ZLIB.DLL?
-
- - The old ZLIB.DLL, built from zlib-1.1.4 or earlier, required
- compilation settings that were incompatible to those used by
- a static build. The DLL settings were supposed to be enabled
- by defining the macro ZLIB_DLL, before including "zlib.h".
- Incorrect handling of this macro was silently accepted at
- build time, resulting in two major problems:
-
- * ZLIB_DLL was missing from the old makefile. When building
- the DLL, not all people added it to the build options. In
- consequence, incompatible incarnations of ZLIB.DLL started
- to circulate around the net.
-
- * When switching from using the static library to using the
- DLL, applications had to define the ZLIB_DLL macro and
- to recompile all the sources that contained calls to zlib
- functions. Failure to do so resulted in creating binaries
- that were unable to run with the official ZLIB.DLL build.
-
- The only possible solution that we could foresee was to make
- a binary-incompatible change in the DLL interface, in order to
- remove the dependency on the ZLIB_DLL macro, and to release
- the new DLL under a different name.
-
- We chose the name ZLIB1.DLL, where '1' indicates the major
- zlib version number. We hope that we will not have to break
- the binary compatibility again, at least not as long as the
- zlib-1.x series will last.
-
- There is still a ZLIB_DLL macro, that can trigger a more
- efficient build and use of the DLL, but compatibility no
- longer dependents on it.
-
-
- 3. Can I build ZLIB.DLL from the new zlib sources, and replace
- an old ZLIB.DLL, that was built from zlib-1.1.4 or earlier?
-
- - In principle, you can do it by assigning calling convention
- keywords to the macros ZEXPORT and ZEXPORTVA. In practice,
- it depends on what you mean by "an old ZLIB.DLL", because the
- old DLL exists in several mutually-incompatible versions.
- You have to find out first what kind of calling convention is
- being used in your particular ZLIB.DLL build, and to use the
- same one in the new build. If you don't know what this is all
- about, you might be better off if you would just leave the old
- DLL intact.
-
-
- 4. Can I compile my application using the new zlib interface, and
- link it to an old ZLIB.DLL, that was built from zlib-1.1.4 or
- earlier?
-
- - The official answer is "no"; the real answer depends again on
- what kind of ZLIB.DLL you have. Even if you are lucky, this
- course of action is unreliable.
-
- If you rebuild your application and you intend to use a newer
- version of zlib (post- 1.1.4), it is strongly recommended to
- link it to the new ZLIB1.DLL.
-
-
- 5. Why are the zlib symbols exported by name, and not by ordinal?
-
- - Although exporting symbols by ordinal is a little faster, it
- is risky. Any single glitch in the maintenance or use of the
- DEF file that contains the ordinals can result in incompatible
- builds and frustrating crashes. Simply put, the benefits of
- exporting symbols by ordinal do not justify the risks.
-
- Technically, it should be possible to maintain ordinals in
- the DEF file, and still export the symbols by name. Ordinals
- exist in every DLL, and even if the dynamic linking performed
- at the DLL startup is searching for names, ordinals serve as
- hints, for a faster name lookup. However, if the DEF file
- contains ordinals, the Microsoft linker automatically builds
- an implib that will cause the executables linked to it to use
- those ordinals, and not the names. It is interesting to
- notice that the GNU linker for Win32 does not suffer from this
- problem.
-
- It is possible to avoid the DEF file if the exported symbols
- are accompanied by a "__declspec(dllexport)" attribute in the
- source files. You can do this in zlib by predefining the
- ZLIB_DLL macro.
-
-
- 6. I see that the ZLIB1.DLL functions use the "C" (CDECL) calling
- convention. Why not use the STDCALL convention?
- STDCALL is the standard convention in Win32, and I need it in
- my Visual Basic project!
-
- (For readability, we use CDECL to refer to the convention
- triggered by the "__cdecl" keyword, STDCALL to refer to
- the convention triggered by "__stdcall", and FASTCALL to
- refer to the convention triggered by "__fastcall".)
-
- - Most of the native Windows API functions (without varargs) use
- indeed the WINAPI convention (which translates to STDCALL in
- Win32), but the standard C functions use CDECL. If a user
- application is intrinsically tied to the Windows API (e.g.
- it calls native Windows API functions such as CreateFile()),
- sometimes it makes sense to decorate its own functions with
- WINAPI. But if ANSI C or POSIX portability is a goal (e.g.
- it calls standard C functions such as fopen()), it is not a
- sound decision to request the inclusion of <windows.h>, or to
- use non-ANSI constructs, for the sole purpose to make the user
- functions STDCALL-able.
-
- The functionality offered by zlib is not in the category of
- "Windows functionality", but is more like "C functionality".
-
- Technically, STDCALL is not bad; in fact, it is slightly
- faster than CDECL, and it works with variable-argument
- functions, just like CDECL. It is unfortunate that, in spite
- of using STDCALL in the Windows API, it is not the default
- convention used by the C compilers that run under Windows.
- The roots of the problem reside deep inside the unsafety of
- the K&R-style function prototypes, where the argument types
- are not specified; but that is another story for another day.
-
- The remaining fact is that CDECL is the default convention.
- Even if an explicit convention is hard-coded into the function
- prototypes inside C headers, problems may appear. The
- necessity to expose the convention in users' callbacks is one
- of these problems.
-
- The calling convention issues are also important when using
- zlib in other programming languages. Some of them, like Ada
- (GNAT) and Fortran (GNU G77), have C bindings implemented
- initially on Unix, and relying on the C calling convention.
- On the other hand, the pre- .NET versions of Microsoft Visual
- Basic require STDCALL, while Borland Delphi prefers, although
- it does not require, FASTCALL.
-
- In fairness to all possible uses of zlib outside the C
- programming language, we choose the default "C" convention.
- Anyone interested in different bindings or conventions is
- encouraged to maintain specialized projects. The "contrib/"
- directory from the zlib distribution already holds a couple
- of foreign bindings, such as Ada, C++, and Delphi.
-
-
- 7. I need a DLL for my Visual Basic project. What can I do?
-
- - Define the ZLIB_WINAPI macro before including "zlib.h", when
- building both the DLL and the user application (except that
- you don't need to define anything when using the DLL in Visual
- Basic). The ZLIB_WINAPI macro will switch on the WINAPI
- (STDCALL) convention. The name of this DLL must be different
- than the official ZLIB1.DLL.
-
- Gilles Vollant has contributed a build named ZLIBWAPI.DLL,
- with the ZLIB_WINAPI macro turned on, and with the minizip
- functionality built in. For more information, please read
- the notes inside "contrib/vstudio/readme.txt", found in the
- zlib distribution.
-
-
- 8. I need to use zlib in my Microsoft .NET project. What can I
- do?
-
- - Henrik Ravn has contributed a .NET wrapper around zlib. Look
- into contrib/dotzlib/, inside the zlib distribution.
-
-
- 9. If my application uses ZLIB1.DLL, should I link it to
- MSVCRT.DLL? Why?
-
- - It is not required, but it is recommended to link your
- application to MSVCRT.DLL, if it uses ZLIB1.DLL.
-
- The executables (.EXE, .DLL, etc.) that are involved in the
- same process and are using the C run-time library (i.e. they
- are calling standard C functions), must link to the same
- library. There are several libraries in the Win32 system:
- CRTDLL.DLL, MSVCRT.DLL, the static C libraries, etc.
- Since ZLIB1.DLL is linked to MSVCRT.DLL, the executables that
- depend on it should also be linked to MSVCRT.DLL.
-
-
-10. Why are you saying that ZLIB1.DLL and my application should
- be linked to the same C run-time (CRT) library? I linked my
- application and my DLLs to different C libraries (e.g. my
- application to a static library, and my DLLs to MSVCRT.DLL),
- and everything works fine.
-
- - If a user library invokes only pure Win32 API (accessible via
- <windows.h> and the related headers), its DLL build will work
- in any context. But if this library invokes standard C API,
- things get more complicated.
-
- There is a single Win32 library in a Win32 system. Every
- function in this library resides in a single DLL module, that
- is safe to call from anywhere. On the other hand, there are
- multiple versions of the C library, and each of them has its
- own separate internal state. Standalone executables and user
- DLLs that call standard C functions must link to a C run-time
- (CRT) library, be it static or shared (DLL). Intermixing
- occurs when an executable (not necessarily standalone) and a
- DLL are linked to different CRTs, and both are running in the
- same process.
-
- Intermixing multiple CRTs is possible, as long as their
- internal states are kept intact. The Microsoft Knowledge Base
- articles KB94248 "HOWTO: Use the C Run-Time" and KB140584
- "HOWTO: Link with the Correct C Run-Time (CRT) Library"
- mention the potential problems raised by intermixing.
-
- If intermixing works for you, it's because your application
- and DLLs are avoiding the corruption of each of the CRTs'
- internal states, maybe by careful design, or maybe by fortune.
-
- Also note that linking ZLIB1.DLL to non-Microsoft CRTs, such
- as those provided by Borland, raises similar problems.
-
-
-11. Why are you linking ZLIB1.DLL to MSVCRT.DLL?
-
- - MSVCRT.DLL exists on every Windows 95 with a new service pack
- installed, or with Microsoft Internet Explorer 4 or later, and
- on all other Windows 4.x or later (Windows 98, Windows NT 4,
- or later). It is freely distributable; if not present in the
- system, it can be downloaded from Microsoft or from other
- software provider for free.
-
- The fact that MSVCRT.DLL does not exist on a virgin Windows 95
- is not so problematic. Windows 95 is scarcely found nowadays,
- Microsoft ended its support a long time ago, and many recent
- applications from various vendors, including Microsoft, do not
- even run on it. Furthermore, no serious user should run
- Windows 95 without a proper update installed.
-
-
-12. Why are you not linking ZLIB1.DLL to
- <<my favorite C run-time library>> ?
-
- - We considered and abandoned the following alternatives:
-
- * Linking ZLIB1.DLL to a static C library (LIBC.LIB, or
- LIBCMT.LIB) is not a good option. People are using the DLL
- mainly to save disk space. If you are linking your program
- to a static C library, you may as well consider linking zlib
- in statically, too.
-
- * Linking ZLIB1.DLL to CRTDLL.DLL looks appealing, because
- CRTDLL.DLL is present on every Win32 installation.
- Unfortunately, it has a series of problems: it does not
- work properly with Microsoft's C++ libraries, it does not
- provide support for 64-bit file offsets, (and so on...),
- and Microsoft discontinued its support a long time ago.
-
- * Linking ZLIB1.DLL to MSVCR70.DLL or MSVCR71.DLL, supplied
- with the Microsoft .NET platform, and Visual C++ 7.0/7.1,
- raises problems related to the status of ZLIB1.DLL as a
- system component. According to the Microsoft Knowledge Base
- article KB326922 "INFO: Redistribution of the Shared C
- Runtime Component in Visual C++ .NET", MSVCR70.DLL and
- MSVCR71.DLL are not supposed to function as system DLLs,
- because they may clash with MSVCRT.DLL. Instead, the
- application's installer is supposed to put these DLLs
- (if needed) in the application's private directory.
- If ZLIB1.DLL depends on a non-system runtime, it cannot
- function as a redistributable system component.
-
- * Linking ZLIB1.DLL to non-Microsoft runtimes, such as
- Borland's, or Cygwin's, raises problems related to the
- reliable presence of these runtimes on Win32 systems.
- It's easier to let the DLL build of zlib up to the people
- who distribute these runtimes, and who may proceed as
- explained in the answer to Question 14.
-
-
-13. If ZLIB1.DLL cannot be linked to MSVCR70.DLL or MSVCR71.DLL,
- how can I build/use ZLIB1.DLL in Microsoft Visual C++ 7.0
- (Visual Studio .NET) or newer?
-
- - Due to the problems explained in the Microsoft Knowledge Base
- article KB326922 (see the previous answer), the C runtime that
- comes with the VC7 environment is no longer considered a
- system component. That is, it should not be assumed that this
- runtime exists, or may be installed in a system directory.
- Since ZLIB1.DLL is supposed to be a system component, it may
- not depend on a non-system component.
-
- In order to link ZLIB1.DLL and your application to MSVCRT.DLL
- in VC7, you need the library of Visual C++ 6.0 or older. If
- you don't have this library at hand, it's probably best not to
- use ZLIB1.DLL.
-
- We are hoping that, in the future, Microsoft will provide a
- way to build applications linked to a proper system runtime,
- from the Visual C++ environment. Until then, you have a
- couple of alternatives, such as linking zlib in statically.
- If your application requires dynamic linking, you may proceed
- as explained in the answer to Question 14.
-
-
-14. I need to link my own DLL build to a CRT different than
- MSVCRT.DLL. What can I do?
-
- - Feel free to rebuild the DLL from the zlib sources, and link
- it the way you want. You should, however, clearly state that
- your build is unofficial. You should give it a different file
- name, and/or install it in a private directory that can be
- accessed by your application only, and is not visible to the
- others (e.g. it's not in the SYSTEM or the SYSTEM32 directory,
- and it's not in the PATH). Otherwise, your build may clash
- with applications that link to the official build.
-
- For example, in Cygwin, zlib is linked to the Cygwin runtime
- CYGWIN1.DLL, and it is distributed under the name CYGZ.DLL.
-
-
-15. May I include additional pieces of code that I find useful,
- link them in ZLIB1.DLL, and export them?
-
- - No. A legitimate build of ZLIB1.DLL must not include code
- that does not originate from the official zlib source code.
- But you can make your own private DLL build, under a different
- file name, as suggested in the previous answer.
-
- For example, zlib is a part of the VCL library, distributed
- with Borland Delphi and C++ Builder. The DLL build of VCL
- is a redistributable file, named VCLxx.DLL.
-
-
-16. May I remove some functionality out of ZLIB1.DLL, by enabling
- macros like NO_GZCOMPRESS or NO_GZIP at compile time?
-
- - No. A legitimate build of ZLIB1.DLL must provide the complete
- zlib functionality, as implemented in the official zlib source
- code. But you can make your own private DLL build, under a
- different file name, as suggested in the previous answer.
-
-
-17. I made my own ZLIB1.DLL build. Can I test it for compliance?
-
- - We prefer that you download the official DLL from the zlib
- web site. If you need something peculiar from this DLL, you
- can send your suggestion to the zlib mailing list.
-
- However, in case you do rebuild the DLL yourself, you can run
- it with the test programs found in the DLL distribution.
- Running these test programs is not a guarantee of compliance,
- but a failure can imply a detected problem.
-
-**
-
-This document is written and maintained by
-Cosmin Truta <cosmint@cs.ubbcluj.ro>
diff --git a/source4/lib/zlib/win32/Makefile.bor b/source4/lib/zlib/win32/Makefile.bor
deleted file mode 100644
index b802519ca3..0000000000
--- a/source4/lib/zlib/win32/Makefile.bor
+++ /dev/null
@@ -1,107 +0,0 @@
-# Makefile for zlib
-# Borland C++ for Win32
-#
-# Updated for zlib 1.2.x by Cosmin Truta, 11-Mar-2003
-# Last updated: 28-Aug-2003
-#
-# Usage:
-# make -f win32/Makefile.bor
-# make -f win32/Makefile.bor LOCAL_ZLIB=-DASMV OBJA=match.obj OBJPA=+match.obj
-
-# ------------ Borland C++ ------------
-
-# Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7)
-# should be added to the environment via "set LOCAL_ZLIB=-DFOO" or
-# added to the declaration of LOC here:
-LOC = $(LOCAL_ZLIB)
-
-CC = bcc32
-AS = bcc32
-LD = bcc32
-AR = tlib
-CFLAGS = -a -d -k- -O2 $(LOC)
-ASFLAGS = $(LOC)
-LDFLAGS = $(LOC)
-
-
-# variables
-ZLIB_LIB = zlib.lib
-
-OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj
-OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj
-#OBJA =
-OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj
-OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj
-#OBJPA=
-
-
-# targets
-all: $(ZLIB_LIB) example.exe minigzip.exe
-
-.c.obj:
- $(CC) -c $(CFLAGS) $<
-
-.asm.obj:
- $(AS) -c $(ASFLAGS) $<
-
-adler32.obj: adler32.c zlib.h zconf.h
-
-compress.obj: compress.c zlib.h zconf.h
-
-crc32.obj: crc32.c zlib.h zconf.h crc32.h
-
-deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h
-
-gzio.obj: gzio.c zutil.h zlib.h zconf.h
-
-infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h inffixed.h
-
-inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h
-
-inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h inffixed.h
-
-inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h
-
-trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h
-
-uncompr.obj: uncompr.c zlib.h zconf.h
-
-zutil.obj: zutil.c zutil.h zlib.h zconf.h
-
-example.obj: example.c zlib.h zconf.h
-
-minigzip.obj: minigzip.c zlib.h zconf.h
-
-
-# For the sake of the old Borland make,
-# the command line is cut to fit in the MS-DOS 128 byte limit:
-$(ZLIB_LIB): $(OBJ1) $(OBJ2) $(OBJA)
- -del $(ZLIB_LIB)
- $(AR) $(ZLIB_LIB) $(OBJP1)
- $(AR) $(ZLIB_LIB) $(OBJP2)
- $(AR) $(ZLIB_LIB) $(OBJPA)
-
-
-# testing
-test: example.exe minigzip.exe
- example
- echo hello world | minigzip | minigzip -d
-
-example.exe: example.obj $(ZLIB_LIB)
- $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB)
-
-minigzip.exe: minigzip.obj $(ZLIB_LIB)
- $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB)
-
-
-# cleanup
-clean:
- -del *.obj
- -del *.lib
- -del *.exe
- -del *.tds
- -del zlib.bak
- -del foo.gz
diff --git a/source4/lib/zlib/win32/Makefile.emx b/source4/lib/zlib/win32/Makefile.emx
deleted file mode 100644
index 7b08424ced..0000000000
--- a/source4/lib/zlib/win32/Makefile.emx
+++ /dev/null
@@ -1,69 +0,0 @@
-# Makefile for zlib. Modified for emx/rsxnt by Chr. Spieler, 6/16/98.
-# Copyright (C) 1995-1998 Jean-loup Gailly.
-# For conditions of distribution and use, see copyright notice in zlib.h
-
-# To compile, or to compile and test, type:
-#
-# make -fmakefile.emx; make test -fmakefile.emx
-#
-
-CC=gcc -Zwin32
-
-#CFLAGS=-MMD -O
-#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
-#CFLAGS=-MMD -g -DDEBUG
-CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
- -Wstrict-prototypes -Wmissing-prototypes
-
-# If cp.exe is available, replace "copy /Y" with "cp -fp" .
-CP=copy /Y
-# If gnu install.exe is available, replace $(CP) with ginstall.
-INSTALL=$(CP)
-# The default value of RM is "rm -f." If "rm.exe" is found, comment out:
-RM=del
-LDLIBS=-L. -lzlib
-LD=$(CC) -s -o
-LDSHARED=$(CC)
-
-INCL=zlib.h zconf.h
-LIBS=zlib.a
-
-AR=ar rcs
-
-prefix=/usr/local
-exec_prefix = $(prefix)
-
-OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
- zutil.o inflate.o infback.o inftrees.o inffast.o
-
-TEST_OBJS = example.o minigzip.o
-
-all: example.exe minigzip.exe
-
-test: all
- ./example
- echo hello world | .\minigzip | .\minigzip -d
-
-%.o : %.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-zlib.a: $(OBJS)
- $(AR) $@ $(OBJS)
-
-%.exe : %.o $(LIBS)
- $(LD) $@ $< $(LDLIBS)
-
-
-.PHONY : clean
-
-clean:
- $(RM) *.d
- $(RM) *.o
- $(RM) *.exe
- $(RM) zlib.a
- $(RM) foo.gz
-
-DEPS := $(wildcard *.d)
-ifneq ($(DEPS),)
-include $(DEPS)
-endif
diff --git a/source4/lib/zlib/win32/Makefile.gcc b/source4/lib/zlib/win32/Makefile.gcc
deleted file mode 100644
index 62a8430156..0000000000
--- a/source4/lib/zlib/win32/Makefile.gcc
+++ /dev/null
@@ -1,141 +0,0 @@
-# Makefile for zlib, derived from Makefile.dj2.
-# Modified for mingw32 by C. Spieler, 6/16/98.
-# Updated for zlib 1.2.x by Christian Spieler and Cosmin Truta, Mar-2003.
-# Last updated: 1-Aug-2003.
-# Tested under Cygwin and MinGW.
-
-# Copyright (C) 1995-2003 Jean-loup Gailly.
-# For conditions of distribution and use, see copyright notice in zlib.h
-
-# To compile, or to compile and test, type:
-#
-# make -fmakefile.gcc; make test testdll -fmakefile.gcc
-#
-# To use the asm code, type:
-# cp contrib/asm?86/match.S ./match.S
-# make LOC=-DASMV OBJA=match.o -fmakefile.gcc
-#
-# To install libz.a, zconf.h and zlib.h in the system directories, type:
-#
-# make install -fmakefile.gcc
-
-# Note:
-# If the platform is *not* MinGW (e.g. it is Cygwin or UWIN),
-# the DLL name should be changed from "zlib1.dll".
-
-STATICLIB = libz.a
-SHAREDLIB = zlib1.dll
-IMPLIB = libzdll.a
-
-#LOC = -DASMV
-#LOC = -DDEBUG -g
-
-CC = gcc
-CFLAGS = $(LOC) -O3 -Wall
-
-AS = $(CC)
-ASFLAGS = $(LOC) -Wall
-
-LD = $(CC)
-LDFLAGS = $(LOC) -s
-
-AR = ar
-ARFLAGS = rcs
-
-RC = windres
-RCFLAGS = --define GCC_WINDRES
-
-CP = cp -fp
-# If GNU install is available, replace $(CP) with install.
-INSTALL = $(CP)
-RM = rm -f
-
-prefix = /usr/local
-exec_prefix = $(prefix)
-
-OBJS = adler32.o compress.o crc32.o deflate.o gzio.o infback.o \
- inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
-OBJA =
-
-all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) example minigzip example_d minigzip_d
-
-test: example minigzip
- ./example
- echo hello world | ./minigzip | ./minigzip -d
-
-testdll: example_d minigzip_d
- ./example_d
- echo hello world | ./minigzip_d | ./minigzip_d -d
-
-.c.o:
- $(CC) $(CFLAGS) -c -o $@ $<
-
-.S.o:
- $(AS) $(ASFLAGS) -c -o $@ $<
-
-$(STATICLIB): $(OBJS) $(OBJA)
- $(AR) $(ARFLAGS) $@ $(OBJS) $(OBJA)
-
-$(IMPLIB): $(SHAREDLIB)
-
-$(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlibrc.o
- dllwrap --driver-name $(CC) --def win32/zlib.def \
- --implib $(IMPLIB) -o $@ $(OBJS) $(OBJA) zlibrc.o
- strip $@
-
-example: example.o $(STATICLIB)
- $(LD) $(LDFLAGS) -o $@ example.o $(STATICLIB)
-
-minigzip: minigzip.o $(STATICLIB)
- $(LD) $(LDFLAGS) -o $@ minigzip.o $(STATICLIB)
-
-example_d: example.o $(IMPLIB)
- $(LD) $(LDFLAGS) -o $@ example.o $(IMPLIB)
-
-minigzip_d: minigzip.o $(IMPLIB)
- $(LD) $(LDFLAGS) -o $@ minigzip.o $(IMPLIB)
-
-zlibrc.o: win32/zlib1.rc
- $(RC) $(RCFLAGS) -o $@ win32/zlib1.rc
-
-
-# INCLUDE_PATH and LIBRARY_PATH must be set.
-
-.PHONY: install uninstall clean
-
-install: zlib.h zconf.h $(LIB)
- -@if not exist $(INCLUDE_PATH)/nul mkdir $(INCLUDE_PATH)
- -@if not exist $(LIBRARY_PATH)/nul mkdir $(LIBRARY_PATH)
- -$(INSTALL) zlib.h $(INCLUDE_PATH)
- -$(INSTALL) zconf.h $(INCLUDE_PATH)
- -$(INSTALL) $(STATICLIB) $(LIBRARY_PATH)
- -$(INSTALL) $(IMPLIB) $(LIBRARY_PATH)
-
-uninstall:
- -$(RM) $(INCLUDE_PATH)/zlib.h
- -$(RM) $(INCLUDE_PATH)/zconf.h
- -$(RM) $(LIBRARY_PATH)/$(STATICLIB)
- -$(RM) $(LIBRARY_PATH)/$(IMPLIB)
-
-clean:
- -$(RM) $(STATICLIB)
- -$(RM) $(SHAREDLIB)
- -$(RM) $(IMPLIB)
- -$(RM) *.o
- -$(RM) *.exe
- -$(RM) foo.gz
-
-adler32.o: zlib.h zconf.h
-compress.o: zlib.h zconf.h
-crc32.o: crc32.h zlib.h zconf.h
-deflate.o: deflate.h zutil.h zlib.h zconf.h
-example.o: zlib.h zconf.h
-gzio.o: zutil.h zlib.h zconf.h
-inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
-inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
-infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
-inftrees.o: zutil.h zlib.h zconf.h inftrees.h
-minigzip.o: zlib.h zconf.h
-trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
-uncompr.o: zlib.h zconf.h
-zutil.o: zutil.h zlib.h zconf.h
diff --git a/source4/lib/zlib/win32/Makefile.msc b/source4/lib/zlib/win32/Makefile.msc
deleted file mode 100644
index 528ecaaf24..0000000000
--- a/source4/lib/zlib/win32/Makefile.msc
+++ /dev/null
@@ -1,126 +0,0 @@
-# Makefile for zlib -- Microsoft (Visual) C
-#
-# Authors:
-# Cosmin Truta, 11-Mar-2003
-# Christian Spieler, 19-Mar-2003
-#
-# Last updated:
-# Cosmin Truta, 27-Aug-2003
-#
-# Usage:
-# nmake -f win32/Makefile.msc (standard build)
-# nmake -f win32/Makefile.msc LOC=-DFOO (nonstandard build)
-# nmake -f win32/Makefile.msc LOC=-DASMV OBJA=match.obj (use ASM code)
-
-
-# optional build flags
-LOC =
-
-
-# variables
-STATICLIB = zlib.lib
-SHAREDLIB = zlib1.dll
-IMPLIB = zdll.lib
-
-CC = cl
-AS = ml
-LD = link
-AR = lib
-RC = rc
-CFLAGS = -nologo -MD -O2 $(LOC)
-ASFLAGS = -coff
-LDFLAGS = -nologo -release
-ARFLAGS = -nologo
-RCFLAGS = /dWIN32 /r
-
-OBJS = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj \
- inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj
-OBJA =
-
-
-# targets
-all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \
- example.exe minigzip.exe example_d.exe minigzip_d.exe
-
-$(STATICLIB): $(OBJS) $(OBJA)
- $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(OBJA)
-
-$(IMPLIB): $(SHAREDLIB)
-
-$(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlib1.res
- $(LD) $(LDFLAGS) -def:win32/zlib.def -dll -implib:$(IMPLIB) \
- -out:$@ $(OBJS) $(OBJA) zlib1.res
-
-example.exe: example.obj $(STATICLIB)
- $(LD) $(LDFLAGS) example.obj $(STATICLIB)
-
-minigzip.exe: minigzip.obj $(STATICLIB)
- $(LD) $(LDFLAGS) minigzip.obj $(STATICLIB)
-
-example_d.exe: example.obj $(IMPLIB)
- $(LD) $(LDFLAGS) -out:$@ example.obj $(IMPLIB)
-
-minigzip_d.exe: minigzip.obj $(IMPLIB)
- $(LD) $(LDFLAGS) -out:$@ minigzip.obj $(IMPLIB)
-
-.c.obj:
- $(CC) -c $(CFLAGS) $<
-
-.asm.obj:
- $(AS) -c $(ASFLAGS) $<
-
-adler32.obj: adler32.c zlib.h zconf.h
-
-compress.obj: compress.c zlib.h zconf.h
-
-crc32.obj: crc32.c zlib.h zconf.h crc32.h
-
-deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h
-
-gzio.obj: gzio.c zutil.h zlib.h zconf.h
-
-infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h inffixed.h
-
-inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h
-
-inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
- inffast.h inffixed.h
-
-inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h
-
-trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h
-
-uncompr.obj: uncompr.c zlib.h zconf.h
-
-zutil.obj: zutil.c zutil.h zlib.h zconf.h
-
-example.obj: example.c zlib.h zconf.h
-
-minigzip.obj: minigzip.c zlib.h zconf.h
-
-zlib1.res: win32/zlib1.rc
- $(RC) $(RCFLAGS) /fo$@ win32/zlib1.rc
-
-
-# testing
-test: example.exe minigzip.exe
- example
- echo hello world | minigzip | minigzip -d
-
-testdll: example_d.exe minigzip_d.exe
- example_d
- echo hello world | minigzip_d | minigzip_d -d
-
-
-# cleanup
-clean:
- -del $(STATICLIB)
- -del $(SHAREDLIB)
- -del $(IMPLIB)
- -del *.obj
- -del *.res
- -del *.exp
- -del *.exe
- -del foo.gz
diff --git a/source4/lib/zlib/win32/VisualC.txt b/source4/lib/zlib/win32/VisualC.txt
deleted file mode 100644
index 579a5fc9e0..0000000000
--- a/source4/lib/zlib/win32/VisualC.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-
-To build zlib using the Microsoft Visual C++ environment,
-use the appropriate project from the projects/ directory.
diff --git a/source4/lib/zlib/win32/zlib.def b/source4/lib/zlib/win32/zlib.def
deleted file mode 100644
index a47cbc10ca..0000000000
--- a/source4/lib/zlib/win32/zlib.def
+++ /dev/null
@@ -1,60 +0,0 @@
-LIBRARY
-; zlib data compression library
-
-EXPORTS
-; basic functions
- zlibVersion
- deflate
- deflateEnd
- inflate
- inflateEnd
-; advanced functions
- deflateSetDictionary
- deflateCopy
- deflateReset
- deflateParams
- deflateBound
- deflatePrime
- inflateSetDictionary
- inflateSync
- inflateCopy
- inflateReset
- inflateBack
- inflateBackEnd
- zlibCompileFlags
-; utility functions
- compress
- compress2
- compressBound
- uncompress
- gzopen
- gzdopen
- gzsetparams
- gzread
- gzwrite
- gzprintf
- gzputs
- gzgets
- gzputc
- gzgetc
- gzungetc
- gzflush
- gzseek
- gzrewind
- gztell
- gzeof
- gzclose
- gzerror
- gzclearerr
-; checksum functions
- adler32
- crc32
-; various hacks, don't look :)
- deflateInit_
- deflateInit2_
- inflateInit_
- inflateInit2_
- inflateBackInit_
- inflateSyncPoint
- get_crc_table
- zError
diff --git a/source4/lib/zlib/win32/zlib1.rc b/source4/lib/zlib/win32/zlib1.rc
deleted file mode 100644
index 99025c9742..0000000000
--- a/source4/lib/zlib/win32/zlib1.rc
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <windows.h>
-
-#ifdef GCC_WINDRES
-VS_VERSION_INFO VERSIONINFO
-#else
-VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
-#endif
- FILEVERSION 1,2,2,0
- PRODUCTVERSION 1,2,2,0
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS 1
-#else
- FILEFLAGS 0
-#endif
- FILEOS VOS_DOS_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE 0 // not used
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904E4"
- //language ID = U.S. English, char set = Windows, Multilingual
- BEGIN
- VALUE "FileDescription", "zlib data compression library\0"
- VALUE "FileVersion", "1.2.3\0"
- VALUE "InternalName", "zlib1.dll\0"
- VALUE "LegalCopyright", "(C) 1995-2004 Jean-loup Gailly & Mark Adler\0"
- VALUE "OriginalFilename", "zlib1.dll\0"
- VALUE "ProductName", "zlib\0"
- VALUE "ProductVersion", "1.2.3\0"
- VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x0409, 1252
- END
-END
diff --git a/source4/lib/zlib/zconf.h b/source4/lib/zlib/zconf.h
deleted file mode 100644
index 3742ad4106..0000000000
--- a/source4/lib/zlib/zconf.h
+++ /dev/null
@@ -1,335 +0,0 @@
-/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#include "replace.h"
-#define Z_PREFIX
-
-#ifndef ZCONF_H
-#define ZCONF_H
-
-/*
- * If you *really* need a unique prefix for all types and library functions,
- * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
- */
-#ifdef Z_PREFIX
-# define deflateInit_ z_deflateInit_
-# define deflate z_deflate
-# define deflateEnd z_deflateEnd
-# define inflateInit_ z_inflateInit_
-# define inflate z_inflate
-# define inflateEnd z_inflateEnd
-# define deflateInit2_ z_deflateInit2_
-# define deflateSetDictionary z_deflateSetDictionary
-# define deflateCopy z_deflateCopy
-# define deflateReset z_deflateReset
-# define deflateParams z_deflateParams
-# define deflateBound z_deflateBound
-# define deflatePrime z_deflatePrime
-# define inflateInit2_ z_inflateInit2_
-# define inflateSetDictionary z_inflateSetDictionary
-# define inflateSync z_inflateSync
-# define inflateSyncPoint z_inflateSyncPoint
-# define inflateCopy z_inflateCopy
-# define inflateReset z_inflateReset
-# define inflateBack z_inflateBack
-# define inflateBackEnd z_inflateBackEnd
-# define compress z_compress
-# define compress2 z_compress2
-# define compressBound z_compressBound
-# define uncompress z_uncompress
-# define adler32 z_adler32
-# define crc32 z_crc32
-# define get_crc_table z_get_crc_table
-# define zError z_zError
-
-# define alloc_func z_alloc_func
-# define free_func z_free_func
-# define in_func z_in_func
-# define out_func z_out_func
-# define Byte z_Byte
-# define uInt z_uInt
-# define uLong z_uLong
-# define Bytef z_Bytef
-# define charf z_charf
-# define intf z_intf
-# define uIntf z_uIntf
-# define uLongf z_uLongf
-# define voidpf z_voidpf
-# define voidp z_voidp
-#endif
-
-#if defined(__MSDOS__) && !defined(MSDOS)
-# define MSDOS
-#endif
-#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
-# define OS2
-#endif
-#if defined(_WINDOWS) && !defined(WINDOWS)
-# define WINDOWS
-#endif
-#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
-# ifndef WIN32
-# define WIN32
-# endif
-#endif
-#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
-# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
-# ifndef SYS16BIT
-# define SYS16BIT
-# endif
-# endif
-#endif
-
-/*
- * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
- * than 64k bytes at a time (needed on systems with 16-bit int).
- */
-#ifdef SYS16BIT
-# define MAXSEG_64K
-#endif
-#ifdef MSDOS
-# define UNALIGNED_OK
-#endif
-
-#ifdef __STDC_VERSION__
-# ifndef STDC
-# define STDC
-# endif
-# if __STDC_VERSION__ >= 199901L
-# ifndef STDC99
-# define STDC99
-# endif
-# endif
-#endif
-#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
-# define STDC
-#endif
-
-#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
-# define STDC
-#endif
-
-#ifndef STDC
-# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
-# define const /* note: need a more gentle solution here */
-# endif
-#endif
-
-/* Some Mac compilers merge all .h files incorrectly: */
-#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
-# define NO_DUMMY_DECL
-#endif
-
-/* Maximum value for memLevel in deflateInit2 */
-#ifndef MAX_MEM_LEVEL
-# ifdef MAXSEG_64K
-# define MAX_MEM_LEVEL 8
-# else
-# define MAX_MEM_LEVEL 9
-# endif
-#endif
-
-/* Maximum value for windowBits in deflateInit2 and inflateInit2.
- * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
- * created by gzip. (Files created by minigzip can still be extracted by
- * gzip.)
- */
-#ifndef MAX_WBITS
-# define MAX_WBITS 15 /* 32K LZ77 window */
-#endif
-
-/* The memory requirements for deflate are (in bytes):
- (1 << (windowBits+2)) + (1 << (memLevel+9))
- that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
- plus a few kilobytes for small objects. For example, if you want to reduce
- the default memory requirements from 256K to 128K, compile with
- make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
- Of course this will generally degrade compression (there's no free lunch).
-
- The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
- for small objects.
-*/
-
- /* Type declarations */
-
-#ifndef OF /* function prototypes */
-# ifdef STDC
-# define OF(args) args
-# else
-# define OF(args) ()
-# endif
-#endif
-
-/* The following definitions for FAR are needed only for MSDOS mixed
- * model programming (small or medium model with some far allocations).
- * This was tested only with MSC; for other MSDOS compilers you may have
- * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
- * just define FAR to be empty.
- */
-#ifdef SYS16BIT
-# if defined(M_I86SM) || defined(M_I86MM)
- /* MSC small or medium model */
-# define SMALL_MEDIUM
-# ifdef _MSC_VER
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-# if (defined(__SMALL__) || defined(__MEDIUM__))
- /* Turbo C small or medium model */
-# define SMALL_MEDIUM
-# ifdef __BORLANDC__
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-#endif
-
-#if defined(WINDOWS) || defined(WIN32)
- /* If building or using zlib as a DLL, define ZLIB_DLL.
- * This is not mandatory, but it offers a little performance increase.
- */
-# ifdef ZLIB_DLL
-# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
-# ifdef ZLIB_INTERNAL
-# define ZEXTERN extern __declspec(dllexport)
-# else
-# define ZEXTERN extern __declspec(dllimport)
-# endif
-# endif
-# endif /* ZLIB_DLL */
- /* If building or using zlib with the WINAPI/WINAPIV calling convention,
- * define ZLIB_WINAPI.
- * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
- */
-# ifdef ZLIB_WINAPI
-# ifdef FAR
-# undef FAR
-# endif
-# include <windows.h>
- /* No need for _export, use ZLIB.DEF instead. */
- /* For complete Windows compatibility, use WINAPI, not __stdcall. */
-# define ZEXPORT WINAPI
-# ifdef WIN32
-# define ZEXPORTVA WINAPIV
-# else
-# define ZEXPORTVA FAR CDECL
-# endif
-# endif
-#endif
-
-#if defined (__BEOS__)
-# ifdef ZLIB_DLL
-# ifdef ZLIB_INTERNAL
-# define ZEXPORT __declspec(dllexport)
-# define ZEXPORTVA __declspec(dllexport)
-# else
-# define ZEXPORT __declspec(dllimport)
-# define ZEXPORTVA __declspec(dllimport)
-# endif
-# endif
-#endif
-
-#ifndef ZEXTERN
-# define ZEXTERN extern
-#endif
-#ifndef ZEXPORT
-# define ZEXPORT
-#endif
-#ifndef ZEXPORTVA
-# define ZEXPORTVA
-#endif
-
-#ifndef FAR
-# define FAR
-#endif
-
-#if !defined(__MACTYPES__)
-typedef unsigned char Byte; /* 8 bits */
-#endif
-typedef unsigned int uInt; /* 16 bits or more */
-typedef unsigned long uLong; /* 32 bits or more */
-
-#ifdef SMALL_MEDIUM
- /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
-# define Bytef Byte FAR
-#else
- typedef Byte FAR Bytef;
-#endif
-typedef char FAR charf;
-typedef int FAR intf;
-typedef uInt FAR uIntf;
-typedef uLong FAR uLongf;
-
-#ifdef STDC
- typedef void const *voidpc;
- typedef void FAR *voidpf;
- typedef void *voidp;
-#else
- typedef Byte const *voidpc;
- typedef Byte FAR *voidpf;
- typedef Byte *voidp;
-#endif
-
-#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
-# include <sys/types.h> /* for off_t */
-# include <unistd.h> /* for SEEK_* and off_t */
-# ifdef VMS
-# include <unixio.h> /* for off_t */
-# endif
-# define z_off_t off_t
-#endif
-#ifndef SEEK_SET
-# define SEEK_SET 0 /* Seek from beginning of file. */
-# define SEEK_CUR 1 /* Seek from current position. */
-# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
-#endif
-#ifndef z_off_t
-# define z_off_t long
-#endif
-
-#if defined(__OS400__)
-# define NO_vsnprintf
-#endif
-
-#if defined(__MVS__)
-# define NO_vsnprintf
-# ifdef FAR
-# undef FAR
-# endif
-#endif
-
-/* MVS linker does not support external names larger than 8 bytes */
-#if defined(__MVS__)
-# pragma map(deflateInit_,"DEIN")
-# pragma map(deflateInit2_,"DEIN2")
-# pragma map(deflateEnd,"DEEND")
-# pragma map(deflateBound,"DEBND")
-# pragma map(inflateInit_,"ININ")
-# pragma map(inflateInit2_,"ININ2")
-# pragma map(inflateEnd,"INEND")
-# pragma map(inflateSync,"INSY")
-# pragma map(inflateSetDictionary,"INSEDI")
-# pragma map(compressBound,"CMBND")
-# pragma map(inflate_table,"INTABL")
-# pragma map(inflate_fast,"INFA")
-# pragma map(inflate_copyright,"INCOPY")
-#endif
-
-#endif /* ZCONF_H */
diff --git a/source4/lib/zlib/zconf.in.h b/source4/lib/zlib/zconf.in.h
deleted file mode 100644
index 03a9431c8b..0000000000
--- a/source4/lib/zlib/zconf.in.h
+++ /dev/null
@@ -1,332 +0,0 @@
-/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#ifndef ZCONF_H
-#define ZCONF_H
-
-/*
- * If you *really* need a unique prefix for all types and library functions,
- * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
- */
-#ifdef Z_PREFIX
-# define deflateInit_ z_deflateInit_
-# define deflate z_deflate
-# define deflateEnd z_deflateEnd
-# define inflateInit_ z_inflateInit_
-# define inflate z_inflate
-# define inflateEnd z_inflateEnd
-# define deflateInit2_ z_deflateInit2_
-# define deflateSetDictionary z_deflateSetDictionary
-# define deflateCopy z_deflateCopy
-# define deflateReset z_deflateReset
-# define deflateParams z_deflateParams
-# define deflateBound z_deflateBound
-# define deflatePrime z_deflatePrime
-# define inflateInit2_ z_inflateInit2_
-# define inflateSetDictionary z_inflateSetDictionary
-# define inflateSync z_inflateSync
-# define inflateSyncPoint z_inflateSyncPoint
-# define inflateCopy z_inflateCopy
-# define inflateReset z_inflateReset
-# define inflateBack z_inflateBack
-# define inflateBackEnd z_inflateBackEnd
-# define compress z_compress
-# define compress2 z_compress2
-# define compressBound z_compressBound
-# define uncompress z_uncompress
-# define adler32 z_adler32
-# define crc32 z_crc32
-# define get_crc_table z_get_crc_table
-# define zError z_zError
-
-# define alloc_func z_alloc_func
-# define free_func z_free_func
-# define in_func z_in_func
-# define out_func z_out_func
-# define Byte z_Byte
-# define uInt z_uInt
-# define uLong z_uLong
-# define Bytef z_Bytef
-# define charf z_charf
-# define intf z_intf
-# define uIntf z_uIntf
-# define uLongf z_uLongf
-# define voidpf z_voidpf
-# define voidp z_voidp
-#endif
-
-#if defined(__MSDOS__) && !defined(MSDOS)
-# define MSDOS
-#endif
-#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
-# define OS2
-#endif
-#if defined(_WINDOWS) && !defined(WINDOWS)
-# define WINDOWS
-#endif
-#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
-# ifndef WIN32
-# define WIN32
-# endif
-#endif
-#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
-# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
-# ifndef SYS16BIT
-# define SYS16BIT
-# endif
-# endif
-#endif
-
-/*
- * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
- * than 64k bytes at a time (needed on systems with 16-bit int).
- */
-#ifdef SYS16BIT
-# define MAXSEG_64K
-#endif
-#ifdef MSDOS
-# define UNALIGNED_OK
-#endif
-
-#ifdef __STDC_VERSION__
-# ifndef STDC
-# define STDC
-# endif
-# if __STDC_VERSION__ >= 199901L
-# ifndef STDC99
-# define STDC99
-# endif
-# endif
-#endif
-#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
-# define STDC
-#endif
-
-#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
-# define STDC
-#endif
-
-#ifndef STDC
-# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
-# define const /* note: need a more gentle solution here */
-# endif
-#endif
-
-/* Some Mac compilers merge all .h files incorrectly: */
-#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
-# define NO_DUMMY_DECL
-#endif
-
-/* Maximum value for memLevel in deflateInit2 */
-#ifndef MAX_MEM_LEVEL
-# ifdef MAXSEG_64K
-# define MAX_MEM_LEVEL 8
-# else
-# define MAX_MEM_LEVEL 9
-# endif
-#endif
-
-/* Maximum value for windowBits in deflateInit2 and inflateInit2.
- * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
- * created by gzip. (Files created by minigzip can still be extracted by
- * gzip.)
- */
-#ifndef MAX_WBITS
-# define MAX_WBITS 15 /* 32K LZ77 window */
-#endif
-
-/* The memory requirements for deflate are (in bytes):
- (1 << (windowBits+2)) + (1 << (memLevel+9))
- that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
- plus a few kilobytes for small objects. For example, if you want to reduce
- the default memory requirements from 256K to 128K, compile with
- make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
- Of course this will generally degrade compression (there's no free lunch).
-
- The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
- for small objects.
-*/
-
- /* Type declarations */
-
-#ifndef OF /* function prototypes */
-# ifdef STDC
-# define OF(args) args
-# else
-# define OF(args) ()
-# endif
-#endif
-
-/* The following definitions for FAR are needed only for MSDOS mixed
- * model programming (small or medium model with some far allocations).
- * This was tested only with MSC; for other MSDOS compilers you may have
- * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
- * just define FAR to be empty.
- */
-#ifdef SYS16BIT
-# if defined(M_I86SM) || defined(M_I86MM)
- /* MSC small or medium model */
-# define SMALL_MEDIUM
-# ifdef _MSC_VER
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-# if (defined(__SMALL__) || defined(__MEDIUM__))
- /* Turbo C small or medium model */
-# define SMALL_MEDIUM
-# ifdef __BORLANDC__
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-#endif
-
-#if defined(WINDOWS) || defined(WIN32)
- /* If building or using zlib as a DLL, define ZLIB_DLL.
- * This is not mandatory, but it offers a little performance increase.
- */
-# ifdef ZLIB_DLL
-# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
-# ifdef ZLIB_INTERNAL
-# define ZEXTERN extern __declspec(dllexport)
-# else
-# define ZEXTERN extern __declspec(dllimport)
-# endif
-# endif
-# endif /* ZLIB_DLL */
- /* If building or using zlib with the WINAPI/WINAPIV calling convention,
- * define ZLIB_WINAPI.
- * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
- */
-# ifdef ZLIB_WINAPI
-# ifdef FAR
-# undef FAR
-# endif
-# include <windows.h>
- /* No need for _export, use ZLIB.DEF instead. */
- /* For complete Windows compatibility, use WINAPI, not __stdcall. */
-# define ZEXPORT WINAPI
-# ifdef WIN32
-# define ZEXPORTVA WINAPIV
-# else
-# define ZEXPORTVA FAR CDECL
-# endif
-# endif
-#endif
-
-#if defined (__BEOS__)
-# ifdef ZLIB_DLL
-# ifdef ZLIB_INTERNAL
-# define ZEXPORT __declspec(dllexport)
-# define ZEXPORTVA __declspec(dllexport)
-# else
-# define ZEXPORT __declspec(dllimport)
-# define ZEXPORTVA __declspec(dllimport)
-# endif
-# endif
-#endif
-
-#ifndef ZEXTERN
-# define ZEXTERN extern
-#endif
-#ifndef ZEXPORT
-# define ZEXPORT
-#endif
-#ifndef ZEXPORTVA
-# define ZEXPORTVA
-#endif
-
-#ifndef FAR
-# define FAR
-#endif
-
-#if !defined(__MACTYPES__)
-typedef unsigned char Byte; /* 8 bits */
-#endif
-typedef unsigned int uInt; /* 16 bits or more */
-typedef unsigned long uLong; /* 32 bits or more */
-
-#ifdef SMALL_MEDIUM
- /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
-# define Bytef Byte FAR
-#else
- typedef Byte FAR Bytef;
-#endif
-typedef char FAR charf;
-typedef int FAR intf;
-typedef uInt FAR uIntf;
-typedef uLong FAR uLongf;
-
-#ifdef STDC
- typedef void const *voidpc;
- typedef void FAR *voidpf;
- typedef void *voidp;
-#else
- typedef Byte const *voidpc;
- typedef Byte FAR *voidpf;
- typedef Byte *voidp;
-#endif
-
-#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
-# include <sys/types.h> /* for off_t */
-# include <unistd.h> /* for SEEK_* and off_t */
-# ifdef VMS
-# include <unixio.h> /* for off_t */
-# endif
-# define z_off_t off_t
-#endif
-#ifndef SEEK_SET
-# define SEEK_SET 0 /* Seek from beginning of file. */
-# define SEEK_CUR 1 /* Seek from current position. */
-# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
-#endif
-#ifndef z_off_t
-# define z_off_t long
-#endif
-
-#if defined(__OS400__)
-# define NO_vsnprintf
-#endif
-
-#if defined(__MVS__)
-# define NO_vsnprintf
-# ifdef FAR
-# undef FAR
-# endif
-#endif
-
-/* MVS linker does not support external names larger than 8 bytes */
-#if defined(__MVS__)
-# pragma map(deflateInit_,"DEIN")
-# pragma map(deflateInit2_,"DEIN2")
-# pragma map(deflateEnd,"DEEND")
-# pragma map(deflateBound,"DEBND")
-# pragma map(inflateInit_,"ININ")
-# pragma map(inflateInit2_,"ININ2")
-# pragma map(inflateEnd,"INEND")
-# pragma map(inflateSync,"INSY")
-# pragma map(inflateSetDictionary,"INSEDI")
-# pragma map(compressBound,"CMBND")
-# pragma map(inflate_table,"INTABL")
-# pragma map(inflate_fast,"INFA")
-# pragma map(inflate_copyright,"INCOPY")
-#endif
-
-#endif /* ZCONF_H */
diff --git a/source4/lib/zlib/zlib.h b/source4/lib/zlib/zlib.h
deleted file mode 100644
index a660031e94..0000000000
--- a/source4/lib/zlib/zlib.h
+++ /dev/null
@@ -1,1374 +0,0 @@
-/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.2.3, July 18th, 2005
-
- Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Jean-loup Gailly Mark Adler
- jloup@gzip.org madler@alumni.caltech.edu
-
-
- The data format used by the zlib library is described by RFCs (Request for
- Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
- (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
-*/
-
-#ifndef ZLIB_H
-#define ZLIB_H
-
-#include "zconf.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define ZLIB_VERSION "1.2.3.1.Samba"
-#define ZLIB_VERNUM 0x1231
-/*
- * Modified for Samba by Stefan Metzmacher <metze@samba.org> 2008
- *
- * inflateReset2() added and compiler warnings fixed
- */
-
-
-/*
- The 'zlib' compression library provides in-memory compression and
- decompression functions, including integrity checks of the uncompressed
- data. This version of the library supports only one compression method
- (deflation) but other algorithms will be added later and will have the same
- stream interface.
-
- Compression can be done in a single step if the buffers are large
- enough (for example if an input file is mmap'ed), or can be done by
- repeated calls of the compression function. In the latter case, the
- application must provide more input and/or consume the output
- (providing more output space) before each call.
-
- The compressed data format used by default by the in-memory functions is
- the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
- around a deflate stream, which is itself documented in RFC 1951.
-
- The library also supports reading and writing files in gzip (.gz) format
- with an interface similar to that of stdio using the functions that start
- with "gz". The gzip format is different from the zlib format. gzip is a
- gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
-
- This library can optionally read and write gzip streams in memory as well.
-
- The zlib format was designed to be compact and fast for use in memory
- and on communications channels. The gzip format was designed for single-
- file compression on file systems, has a larger header than zlib to maintain
- directory information, and uses a different, slower check method than zlib.
-
- The library does not install any signal handler. The decoder checks
- the consistency of the compressed data, so the library should never
- crash even in case of corrupted input.
-*/
-
-typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
-typedef void (*free_func) OF((voidpf opaque, voidpf address));
-
-struct internal_state;
-
-typedef struct z_stream_s {
- const Bytef *next_in; /* next input byte */
- uInt avail_in; /* number of bytes available at next_in */
- uLong total_in; /* total nb of input bytes read so far */
-
- Bytef *next_out; /* next output byte should be put there */
- uInt avail_out; /* remaining free space at next_out */
- uLong total_out; /* total nb of bytes output so far */
-
- const char *msg; /* last error message, NULL if no error */
- struct internal_state FAR *state; /* not visible by applications */
-
- alloc_func zalloc; /* used to allocate the internal state */
- free_func zfree; /* used to free the internal state */
- voidpf opaque; /* private data object passed to zalloc and zfree */
-
- int data_type; /* best guess about the data type: binary or text */
- uLong adler; /* adler32 value of the uncompressed data */
- uLong reserved; /* reserved for future use */
-} z_stream;
-
-typedef z_stream FAR *z_streamp;
-
-/*
- gzip header information passed to and from zlib routines. See RFC 1952
- for more details on the meanings of these fields.
-*/
-typedef struct gz_header_s {
- int text; /* true if compressed data believed to be text */
- uLong time; /* modification time */
- int xflags; /* extra flags (not used when writing a gzip file) */
- int os; /* operating system */
- Bytef *extra; /* pointer to extra field or Z_NULL if none */
- uInt extra_len; /* extra field length (valid if extra != Z_NULL) */
- uInt extra_max; /* space at extra (only when reading header) */
- Bytef *name; /* pointer to zero-terminated file name or Z_NULL */
- uInt name_max; /* space at name (only when reading header) */
- Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */
- uInt comm_max; /* space at comment (only when reading header) */
- int hcrc; /* true if there was or will be a header crc */
- int done; /* true when done reading gzip header (not used
- when writing a gzip file) */
-} gz_header;
-
-typedef gz_header FAR *gz_headerp;
-
-/*
- The application must update next_in and avail_in when avail_in has
- dropped to zero. It must update next_out and avail_out when avail_out
- has dropped to zero. The application must initialize zalloc, zfree and
- opaque before calling the init function. All other fields are set by the
- compression library and must not be updated by the application.
-
- The opaque value provided by the application will be passed as the first
- parameter for calls of zalloc and zfree. This can be useful for custom
- memory management. The compression library attaches no meaning to the
- opaque value.
-
- zalloc must return Z_NULL if there is not enough memory for the object.
- If zlib is used in a multi-threaded application, zalloc and zfree must be
- thread safe.
-
- On 16-bit systems, the functions zalloc and zfree must be able to allocate
- exactly 65536 bytes, but will not be required to allocate more than this
- if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
- pointers returned by zalloc for objects of exactly 65536 bytes *must*
- have their offset normalized to zero. The default allocation function
- provided by this library ensures this (see zutil.c). To reduce memory
- requirements and avoid any allocation of 64K objects, at the expense of
- compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
-
- The fields total_in and total_out can be used for statistics or
- progress reports. After compression, total_in holds the total size of
- the uncompressed data and may be saved for use in the decompressor
- (particularly if the decompressor wants to decompress everything in
- a single step).
-*/
-
- /* constants */
-
-#define Z_NO_FLUSH 0
-#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
-#define Z_SYNC_FLUSH 2
-#define Z_FULL_FLUSH 3
-#define Z_FINISH 4
-#define Z_BLOCK 5
-/* Allowed flush values; see deflate() and inflate() below for details */
-
-#define Z_OK 0
-#define Z_STREAM_END 1
-#define Z_NEED_DICT 2
-#define Z_ERRNO (-1)
-#define Z_STREAM_ERROR (-2)
-#define Z_DATA_ERROR (-3)
-#define Z_MEM_ERROR (-4)
-#define Z_BUF_ERROR (-5)
-#define Z_VERSION_ERROR (-6)
-/* Return codes for the compression/decompression functions. Negative
- * values are errors, positive values are used for special but normal events.
- */
-
-#define Z_NO_COMPRESSION 0
-#define Z_BEST_SPEED 1
-#define Z_BEST_COMPRESSION 9
-#define Z_DEFAULT_COMPRESSION (-1)
-/* compression levels */
-
-#define Z_FILTERED 1
-#define Z_HUFFMAN_ONLY 2
-#define Z_RLE 3
-#define Z_FIXED 4
-#define Z_DEFAULT_STRATEGY 0
-/* compression strategy; see deflateInit2() below for details */
-
-#define Z_BINARY 0
-#define Z_TEXT 1
-#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */
-#define Z_UNKNOWN 2
-/* Possible values of the data_type field (though see inflate()) */
-
-#define Z_DEFLATED 8
-/* The deflate compression method (the only one supported in this version) */
-
-#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
-
-#define zlib_version zlibVersion()
-/* for compatibility with versions < 1.0.2 */
-
-#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 _Z_PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
-#else
-#define _Z_PRINTF_ATTRIBUTE(a1, a2)
-#endif
-
- /* basic functions */
-
-ZEXTERN const char * ZEXPORT zlibVersion OF((void));
-/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
- If the first character differs, the library code actually used is
- not compatible with the zlib.h header file used by the application.
- This check is automatically made by deflateInit and inflateInit.
- */
-
-/*
-ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
-
- Initializes the internal stream state for compression. The fields
- zalloc, zfree and opaque must be initialized before by the caller.
- If zalloc and zfree are set to Z_NULL, deflateInit updates them to
- use default allocation functions.
-
- The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
- 1 gives best speed, 9 gives best compression, 0 gives no compression at
- all (the input data is simply copied a block at a time).
- Z_DEFAULT_COMPRESSION requests a default compromise between speed and
- compression (currently equivalent to level 6).
-
- deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if level is not a valid compression level,
- Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
- with the version assumed by the caller (ZLIB_VERSION).
- msg is set to null if there is no error message. deflateInit does not
- perform any compression: this will be done by deflate().
-*/
-
-
-ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
-/*
- deflate compresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may introduce some
- output latency (reading input without producing any output) except when
- forced to flush.
-
- The detailed semantics are as follows. deflate performs one or both of the
- following actions:
-
- - Compress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in and avail_in are updated and
- processing will resume at this point for the next call of deflate().
-
- - Provide more output starting at next_out and update next_out and avail_out
- accordingly. This action is forced if the parameter flush is non zero.
- Forcing flush frequently degrades the compression ratio, so this parameter
- should be set only when necessary (in interactive applications).
- Some output may be provided even if flush is not set.
-
- Before the call of deflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming
- more output, and updating avail_in or avail_out accordingly; avail_out
- should never be zero before the call. The application can consume the
- compressed output when it wants, for example when the output buffer is full
- (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
- and with zero avail_out, it must be called again after making room in the
- output buffer because there might be more output pending.
-
- Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
- decide how much data to accumualte before producing output, in order to
- maximize compression.
-
- If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
- flushed to the output buffer and the output is aligned on a byte boundary, so
- that the decompressor can get all input data available so far. (In particular
- avail_in is zero after the call if enough output space has been provided
- before the call.) Flushing may degrade compression for some compression
- algorithms and so it should be used only when necessary.
-
- If flush is set to Z_FULL_FLUSH, all output is flushed as with
- Z_SYNC_FLUSH, and the compression state is reset so that decompression can
- restart from this point if previous compressed data has been damaged or if
- random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
- compression.
-
- If deflate returns with avail_out == 0, this function must be called again
- with the same value of the flush parameter and more output space (updated
- avail_out), until the flush is complete (deflate returns with non-zero
- avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
- avail_out is greater than six to avoid repeated flush markers due to
- avail_out == 0 on return.
-
- If the parameter flush is set to Z_FINISH, pending input is processed,
- pending output is flushed and deflate returns with Z_STREAM_END if there
- was enough output space; if deflate returns with Z_OK, this function must be
- called again with Z_FINISH and more output space (updated avail_out) but no
- more input data, until it returns with Z_STREAM_END or an error. After
- deflate has returned Z_STREAM_END, the only possible operations on the
- stream are deflateReset or deflateEnd.
-
- Z_FINISH can be used immediately after deflateInit if all the compression
- is to be done in a single step. In this case, avail_out must be at least
- the value returned by deflateBound (see below). If deflate does not return
- Z_STREAM_END, then it must be called again as described above.
-
- deflate() sets strm->adler to the adler32 checksum of all input read
- so far (that is, total_in bytes).
-
- deflate() may update strm->data_type if it can make a good guess about
- the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered
- binary. This field is only for information purposes and does not affect
- the compression algorithm in any manner.
-
- deflate() returns Z_OK if some progress has been made (more input
- processed or more output produced), Z_STREAM_END if all input has been
- consumed and all output has been produced (only when flush is set to
- Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
- if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
- (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not
- fatal, and deflate() can be called again with more input and more output
- space to continue compressing.
-*/
-
-
-ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
-/*
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any
- pending output.
-
- deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
- stream state was inconsistent, Z_DATA_ERROR if the stream was freed
- prematurely (some input or output was discarded). In the error case,
- msg may be set but then points to a static string (which must not be
- deallocated).
-*/
-
-
-/*
-ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
-
- Initializes the internal stream state for decompression. The fields
- next_in, avail_in, zalloc, zfree and opaque must be initialized before by
- the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
- value depends on the compression method), inflateInit determines the
- compression method from the zlib header and allocates all data structures
- accordingly; otherwise the allocation will be deferred to the first call of
- inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
- use default allocation functions.
-
- inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
- version assumed by the caller. msg is set to null if there is no error
- message. inflateInit does not perform any decompression apart from reading
- the zlib header if present: this will be done by inflate(). (So next_in and
- avail_in may be modified, but next_out and avail_out are unchanged.)
-*/
-
-
-ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
-/*
- inflate decompresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may introduce
- some output latency (reading input without producing any output) except when
- forced to flush.
-
- The detailed semantics are as follows. inflate performs one or both of the
- following actions:
-
- - Decompress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in is updated and processing
- will resume at this point for the next call of inflate().
-
- - Provide more output starting at next_out and update next_out and avail_out
- accordingly. inflate() provides as much output as possible, until there
- is no more input data or no more space in the output buffer (see below
- about the flush parameter).
-
- Before the call of inflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming
- more output, and updating the next_* and avail_* values accordingly.
- The application can consume the uncompressed output when it wants, for
- example when the output buffer is full (avail_out == 0), or after each
- call of inflate(). If inflate returns Z_OK and with zero avail_out, it
- must be called again after making room in the output buffer because there
- might be more output pending.
-
- The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH,
- Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much
- output as possible to the output buffer. Z_BLOCK requests that inflate() stop
- if and when it gets to the next deflate block boundary. When decoding the
- zlib or gzip format, this will cause inflate() to return immediately after
- the header and before the first block. When doing a raw inflate, inflate()
- will go ahead and process the first block, and will return when it gets to
- the end of that block, or when it runs out of data.
-
- The Z_BLOCK option assists in appending to or combining deflate streams.
- Also to assist in this, on return inflate() will set strm->data_type to the
- number of unused bits in the last byte taken from strm->next_in, plus 64
- if inflate() is currently decoding the last block in the deflate stream,
- plus 128 if inflate() returned immediately after decoding an end-of-block
- code or decoding the complete header up to just before the first byte of the
- deflate stream. The end-of-block will not be indicated until all of the
- uncompressed data from that block has been written to strm->next_out. The
- number of unused bits may in general be greater than seven, except when
- bit 7 of data_type is set, in which case the number of unused bits will be
- less than eight.
-
- inflate() should normally be called until it returns Z_STREAM_END or an
- error. However if all decompression is to be performed in a single step
- (a single call of inflate), the parameter flush should be set to
- Z_FINISH. In this case all pending input is processed and all pending
- output is flushed; avail_out must be large enough to hold all the
- uncompressed data. (The size of the uncompressed data may have been saved
- by the compressor for this purpose.) The next operation on this stream must
- be inflateEnd to deallocate the decompression state. The use of Z_FINISH
- is never required, but can be used to inform inflate that a faster approach
- may be used for the single inflate() call.
-
- In this implementation, inflate() always flushes as much output as
- possible to the output buffer, and always uses the faster approach on the
- first call. So the only effect of the flush parameter in this implementation
- is on the return value of inflate(), as noted below, or when it returns early
- because Z_BLOCK is used.
-
- If a preset dictionary is needed after this call (see inflateSetDictionary
- below), inflate sets strm->adler to the adler32 checksum of the dictionary
- chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
- strm->adler to the adler32 checksum of all output produced so far (that is,
- total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
- below. At the end of the stream, inflate() checks that its computed adler32
- checksum is equal to that saved by the compressor and returns Z_STREAM_END
- only if the checksum is correct.
-
- inflate() will decompress and check either zlib-wrapped or gzip-wrapped
- deflate data. The header type is detected automatically. Any information
- contained in the gzip header is not retained, so applications that need that
- information should instead use raw inflate, see inflateInit2() below, or
- inflateBack() and perform their own processing of the gzip header and
- trailer.
-
- inflate() returns Z_OK if some progress has been made (more input processed
- or more output produced), Z_STREAM_END if the end of the compressed data has
- been reached and all uncompressed output has been produced, Z_NEED_DICT if a
- preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
- corrupted (input stream not conforming to the zlib format or incorrect check
- value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
- if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory,
- Z_BUF_ERROR if no progress is possible or if there was not enough room in the
- output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
- inflate() can be called again with more input and more output space to
- continue decompressing. If Z_DATA_ERROR is returned, the application may then
- call inflateSync() to look for a good compression block if a partial recovery
- of the data is desired.
-*/
-
-
-ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
-/*
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any
- pending output.
-
- inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
- was inconsistent. In the error case, msg may be set but then points to a
- static string (which must not be deallocated).
-*/
-
- /* Advanced functions */
-
-/*
- The following functions are needed only in some special applications.
-*/
-
-/*
-ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
- int level,
- int method,
- int windowBits,
- int memLevel,
- int strategy));
-
- This is another version of deflateInit with more compression options. The
- fields next_in, zalloc, zfree and opaque must be initialized before by
- the caller.
-
- The method parameter is the compression method. It must be Z_DEFLATED in
- this version of the library.
-
- The windowBits parameter is the base two logarithm of the window size
- (the size of the history buffer). It should be in the range 8..15 for this
- version of the library. Larger values of this parameter result in better
- compression at the expense of memory usage. The default value is 15 if
- deflateInit is used instead.
-
- windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
- determines the window size. deflate() will then generate raw deflate data
- with no zlib header or trailer, and will not compute an adler32 check value.
-
- windowBits can also be greater than 15 for optional gzip encoding. Add
- 16 to windowBits to write a simple gzip header and trailer around the
- compressed data instead of a zlib wrapper. The gzip header will have no
- file name, no extra data, no comment, no modification time (set to zero),
- no header crc, and the operating system will be set to 255 (unknown). If a
- gzip stream is being written, strm->adler is a crc32 instead of an adler32.
-
- The memLevel parameter specifies how much memory should be allocated
- for the internal compression state. memLevel=1 uses minimum memory but
- is slow and reduces compression ratio; memLevel=9 uses maximum memory
- for optimal speed. The default value is 8. See zconf.h for total memory
- usage as a function of windowBits and memLevel.
-
- The strategy parameter is used to tune the compression algorithm. Use the
- value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
- filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
- string match), or Z_RLE to limit match distances to one (run-length
- encoding). Filtered data consists mostly of small values with a somewhat
- random distribution. In this case, the compression algorithm is tuned to
- compress them better. The effect of Z_FILTERED is to force more Huffman
- coding and less string matching; it is somewhat intermediate between
- Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as
- Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy
- parameter only affects the compression ratio but not the correctness of the
- compressed output even if it is not set appropriately. Z_FIXED prevents the
- use of dynamic Huffman codes, allowing for a simpler decoder for special
- applications.
-
- deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
- method). msg is set to null if there is no error message. deflateInit2 does
- not perform any compression: this will be done by deflate().
-*/
-
-ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
-/*
- Initializes the compression dictionary from the given byte sequence
- without producing any compressed output. This function must be called
- immediately after deflateInit, deflateInit2 or deflateReset, before any
- call of deflate. The compressor and decompressor must use exactly the same
- dictionary (see inflateSetDictionary).
-
- The dictionary should consist of strings (byte sequences) that are likely
- to be encountered later in the data to be compressed, with the most commonly
- used strings preferably put towards the end of the dictionary. Using a
- dictionary is most useful when the data to be compressed is short and can be
- predicted with good accuracy; the data can then be compressed better than
- with the default empty dictionary.
-
- Depending on the size of the compression data structures selected by
- deflateInit or deflateInit2, a part of the dictionary may in effect be
- discarded, for example if the dictionary is larger than the window size in
- deflate or deflate2. Thus the strings most likely to be useful should be
- put at the end of the dictionary, not at the front. In addition, the
- current implementation of deflate will use at most the window size minus
- 262 bytes of the provided dictionary.
-
- Upon return of this function, strm->adler is set to the adler32 value
- of the dictionary; the decompressor may later use this value to determine
- which dictionary has been used by the compressor. (The adler32 value
- applies to the whole dictionary even if only a subset of the dictionary is
- actually used by the compressor.) If a raw deflate was requested, then the
- adler32 value is not computed and strm->adler is not set.
-
- deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
- parameter is invalid (such as NULL dictionary) or the stream state is
- inconsistent (for example if deflate has already been called for this stream
- or if the compression method is bsort). deflateSetDictionary does not
- perform any compression: this will be done by deflate().
-*/
-
-ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
- z_streamp source));
-/*
- Sets the destination stream as a complete copy of the source stream.
-
- This function can be useful when several compression strategies will be
- tried, for example when there are several ways of pre-processing the input
- data with a filter. The streams that will be discarded should then be freed
- by calling deflateEnd. Note that deflateCopy duplicates the internal
- compression state which can be quite large, so this strategy is slow and
- can consume lots of memory.
-
- deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
- (such as zalloc being NULL). msg is left unchanged in both source and
- destination.
-*/
-
-ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
-/*
- This function is equivalent to deflateEnd followed by deflateInit,
- but does not free and reallocate all the internal compression state.
- The stream will keep the same compression level and any other attributes
- that may have been set by deflateInit2.
-
- deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being NULL).
-*/
-
-ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
- int level,
- int strategy));
-/*
- Dynamically update the compression level and compression strategy. The
- interpretation of level and strategy is as in deflateInit2. This can be
- used to switch between compression and straight copy of the input data, or
- to switch to a different kind of input data requiring a different
- strategy. If the compression level is changed, the input available so far
- is compressed with the old level (and may be flushed); the new level will
- take effect only at the next call of deflate().
-
- Before the call of deflateParams, the stream state must be set as for
- a call of deflate(), since the currently available input may have to
- be compressed and flushed. In particular, strm->avail_out must be non-zero.
-
- deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
- stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
- if strm->avail_out was zero.
-*/
-
-ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
- int good_length,
- int max_lazy,
- int nice_length,
- int max_chain));
-/*
- Fine tune deflate's internal compression parameters. This should only be
- used by someone who understands the algorithm used by zlib's deflate for
- searching for the best matching string, and even then only by the most
- fanatic optimizer trying to squeeze out the last compressed bit for their
- specific input data. Read the deflate.c source code for the meaning of the
- max_lazy, good_length, nice_length, and max_chain parameters.
-
- deflateTune() can be called after deflateInit() or deflateInit2(), and
- returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
- */
-
-ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
- uLong sourceLen));
-/*
- deflateBound() returns an upper bound on the compressed size after
- deflation of sourceLen bytes. It must be called after deflateInit()
- or deflateInit2(). This would be used to allocate an output buffer
- for deflation in a single pass, and so would be called before deflate().
-*/
-
-ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
- int bits,
- int value));
-/*
- deflatePrime() inserts bits in the deflate output stream. The intent
- is that this function is used to start off the deflate output with the
- bits leftover from a previous deflate stream when appending to it. As such,
- this function can only be used for raw deflate, and must be used before the
- first deflate() call after a deflateInit2() or deflateReset(). bits must be
- less than or equal to 16, and that many of the least significant bits of
- value will be inserted in the output.
-
- deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
- gz_headerp head));
-/*
- deflateSetHeader() provides gzip header information for when a gzip
- stream is requested by deflateInit2(). deflateSetHeader() may be called
- after deflateInit2() or deflateReset() and before the first call of
- deflate(). The text, time, os, extra field, name, and comment information
- in the provided gz_header structure are written to the gzip header (xflag is
- ignored -- the extra flags are set according to the compression level). The
- caller must assure that, if not Z_NULL, name and comment are terminated with
- a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
- available there. If hcrc is true, a gzip header crc is included. Note that
- the current versions of the command-line version of gzip (up through version
- 1.3.x) do not support header crc's, and will report that it is a "multi-part
- gzip file" and give up.
-
- If deflateSetHeader is not used, the default gzip header has text false,
- the time set to zero, and os set to 255, with no extra, name, or comment
- fields. The gzip header is returned to the default state by deflateReset().
-
- deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-/*
-ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
- int windowBits));
-
- This is another version of inflateInit with an extra parameter. The
- fields next_in, avail_in, zalloc, zfree and opaque must be initialized
- before by the caller.
-
- The windowBits parameter is the base two logarithm of the maximum window
- size (the size of the history buffer). It should be in the range 8..15 for
- this version of the library. The default value is 15 if inflateInit is used
- instead. windowBits must be greater than or equal to the windowBits value
- provided to deflateInit2() while compressing, or it must be equal to 15 if
- deflateInit2() was not used. If a compressed stream with a larger window
- size is given as input, inflate() will return with the error code
- Z_DATA_ERROR instead of trying to allocate a larger window.
-
- windowBits can also be -8..-15 for raw inflate. In this case, -windowBits
- determines the window size. inflate() will then process raw deflate data,
- not looking for a zlib or gzip header, not generating a check value, and not
- looking for any check values for comparison at the end of the stream. This
- is for use with other formats that use the deflate compressed data format
- such as zip. Those formats provide their own check values. If a custom
- format is developed using the raw deflate format for compressed data, it is
- recommended that a check value such as an adler32 or a crc32 be applied to
- the uncompressed data as is done in the zlib, gzip, and zip formats. For
- most applications, the zlib format should be used as is. Note that comments
- above on the use in deflateInit2() applies to the magnitude of windowBits.
-
- windowBits can also be greater than 15 for optional gzip decoding. Add
- 32 to windowBits to enable zlib and gzip decoding with automatic header
- detection, or add 16 to decode only the gzip format (the zlib format will
- return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is
- a crc32 instead of an adler32.
-
- inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg
- is set to null if there is no error message. inflateInit2 does not perform
- any decompression apart from reading the zlib header if present: this will
- be done by inflate(). (So next_in and avail_in may be modified, but next_out
- and avail_out are unchanged.)
-*/
-
-ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
-/*
- Initializes the decompression dictionary from the given uncompressed byte
- sequence. This function must be called immediately after a call of inflate,
- if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
- can be determined from the adler32 value returned by that call of inflate.
- The compressor and decompressor must use exactly the same dictionary (see
- deflateSetDictionary). For raw inflate, this function can be called
- immediately after inflateInit2() or inflateReset() and before any call of
- inflate() to set the dictionary. The application must insure that the
- dictionary that was used for compression is provided.
-
- inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
- parameter is invalid (such as NULL dictionary) or the stream state is
- inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
- expected one (incorrect adler32 value). inflateSetDictionary does not
- perform any decompression: this will be done by subsequent calls of
- inflate().
-*/
-
-ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
-/*
- Skips invalid compressed data until a full flush point (see above the
- description of deflate with Z_FULL_FLUSH) can be found, or until all
- available input is skipped. No output is provided.
-
- inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
- if no more input was provided, Z_DATA_ERROR if no flush point has been found,
- or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
- case, the application may save the current current value of total_in which
- indicates where valid compressed data was found. In the error case, the
- application may repeatedly call inflateSync, providing more input each time,
- until success or end of the input data.
-*/
-
-ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
- z_streamp source));
-/*
- Sets the destination stream as a complete copy of the source stream.
-
- This function can be useful when randomly accessing a large stream. The
- first pass through the stream can periodically record the inflate state,
- allowing restarting inflate at those points when randomly accessing the
- stream.
-
- inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
- (such as zalloc being NULL). msg is left unchanged in both source and
- destination.
-*/
-
-ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
-/*
- This function is equivalent to inflateEnd followed by inflateInit,
- but does not free and reallocate all the internal decompression state.
- The stream will keep attributes that may have been set by inflateInit2.
-
- inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being NULL).
-*/
-
-ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
- int bits,
- int value));
-/*
- This function inserts bits in the inflate input stream. The intent is
- that this function is used to start inflating at a bit position in the
- middle of a byte. The provided bits will be used before any bytes are used
- from next_in. This function should only be used with raw inflate, and
- should be used before the first inflate() call after inflateInit2() or
- inflateReset(). bits must be less than or equal to 16, and that many of the
- least significant bits of value will be inserted in the input.
-
- inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
- gz_headerp head));
-/*
- inflateGetHeader() requests that gzip header information be stored in the
- provided gz_header structure. inflateGetHeader() may be called after
- inflateInit2() or inflateReset(), and before the first call of inflate().
- As inflate() processes the gzip stream, head->done is zero until the header
- is completed, at which time head->done is set to one. If a zlib stream is
- being decoded, then head->done is set to -1 to indicate that there will be
- no gzip header information forthcoming. Note that Z_BLOCK can be used to
- force inflate() to return immediately after header processing is complete
- and before any actual data is decompressed.
-
- The text, time, xflags, and os fields are filled in with the gzip header
- contents. hcrc is set to true if there is a header CRC. (The header CRC
- was valid if done is set to one.) If extra is not Z_NULL, then extra_max
- contains the maximum number of bytes to write to extra. Once done is true,
- extra_len contains the actual extra field length, and extra contains the
- extra field, or that field truncated if extra_max is less than extra_len.
- If name is not Z_NULL, then up to name_max characters are written there,
- terminated with a zero unless the length is greater than name_max. If
- comment is not Z_NULL, then up to comm_max characters are written there,
- terminated with a zero unless the length is greater than comm_max. When
- any of extra, name, or comment are not Z_NULL and the respective field is
- not present in the header, then that field is set to Z_NULL to signal its
- absence. This allows the use of deflateSetHeader() with the returned
- structure to duplicate the header. However if those fields are set to
- allocated memory, then the application will need to save those pointers
- elsewhere so that they can be eventually freed.
-
- If inflateGetHeader is not used, then the header information is simply
- discarded. The header is always checked for validity, including the header
- CRC if present. inflateReset() will reset the process to discard the header
- information. The application would need to call inflateGetHeader() again to
- retrieve the header from the next gzip stream.
-
- inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-/*
-ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
- unsigned char FAR *window));
-
- Initialize the internal stream state for decompression using inflateBack()
- calls. The fields zalloc, zfree and opaque in strm must be initialized
- before the call. If zalloc and zfree are Z_NULL, then the default library-
- derived memory allocation routines are used. windowBits is the base two
- logarithm of the window size, in the range 8..15. window is a caller
- supplied buffer of that size. Except for special applications where it is
- assured that deflate was used with small window sizes, windowBits must be 15
- and a 32K byte window must be supplied to be able to decompress general
- deflate streams.
-
- See inflateBack() for the usage of these routines.
-
- inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
- the paramaters are invalid, Z_MEM_ERROR if the internal state could not
- be allocated, or Z_VERSION_ERROR if the version of the library does not
- match the version of the header file.
-*/
-
-typedef unsigned (*in_func) OF((void FAR *, unsigned const char FAR * FAR *));
-typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
-
-ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
- in_func in, void FAR *in_desc,
- out_func out, void FAR *out_desc));
-/*
- inflateBack() does a raw inflate with a single call using a call-back
- interface for input and output. This is more efficient than inflate() for
- file i/o applications in that it avoids copying between the output and the
- sliding window by simply making the window itself the output buffer. This
- function trusts the application to not change the output buffer passed by
- the output function, at least until inflateBack() returns.
-
- inflateBackInit() must be called first to allocate the internal state
- and to initialize the state with the user-provided window buffer.
- inflateBack() may then be used multiple times to inflate a complete, raw
- deflate stream with each call. inflateBackEnd() is then called to free
- the allocated state.
-
- A raw deflate stream is one with no zlib or gzip header or trailer.
- This routine would normally be used in a utility that reads zip or gzip
- files and writes out uncompressed files. The utility would decode the
- header and process the trailer on its own, hence this routine expects
- only the raw deflate stream to decompress. This is different from the
- normal behavior of inflate(), which expects either a zlib or gzip header and
- trailer around the deflate stream.
-
- inflateBack() uses two subroutines supplied by the caller that are then
- called by inflateBack() for input and output. inflateBack() calls those
- routines until it reads a complete deflate stream and writes out all of the
- uncompressed data, or until it encounters an error. The function's
- parameters and return types are defined above in the in_func and out_func
- typedefs. inflateBack() will call in(in_desc, &buf) which should return the
- number of bytes of provided input, and a pointer to that input in buf. If
- there is no input available, in() must return zero--buf is ignored in that
- case--and inflateBack() will return a buffer error. inflateBack() will call
- out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out()
- should return zero on success, or non-zero on failure. If out() returns
- non-zero, inflateBack() will return with an error. Neither in() nor out()
- are permitted to change the contents of the window provided to
- inflateBackInit(), which is also the buffer that out() uses to write from.
- The length written by out() will be at most the window size. Any non-zero
- amount of input may be provided by in().
-
- For convenience, inflateBack() can be provided input on the first call by
- setting strm->next_in and strm->avail_in. If that input is exhausted, then
- in() will be called. Therefore strm->next_in must be initialized before
- calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called
- immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in
- must also be initialized, and then if strm->avail_in is not zero, input will
- initially be taken from strm->next_in[0 .. strm->avail_in - 1].
-
- The in_desc and out_desc parameters of inflateBack() is passed as the
- first parameter of in() and out() respectively when they are called. These
- descriptors can be optionally used to pass any information that the caller-
- supplied in() and out() functions need to do their job.
-
- On return, inflateBack() will set strm->next_in and strm->avail_in to
- pass back any unused input that was provided by the last in() call. The
- return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
- if in() or out() returned an error, Z_DATA_ERROR if there was a format
- error in the deflate stream (in which case strm->msg is set to indicate the
- nature of the error), or Z_STREAM_ERROR if the stream was not properly
- initialized. In the case of Z_BUF_ERROR, an input or output error can be
- distinguished using strm->next_in which will be Z_NULL only if in() returned
- an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to
- out() returning non-zero. (in() will always be called before out(), so
- strm->next_in is assured to be defined if out() returns non-zero.) Note
- that inflateBack() cannot return Z_OK.
-*/
-
-ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
-/*
- All memory allocated by inflateBackInit() is freed.
-
- inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
- state was inconsistent.
-*/
-
-ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
-/* Return flags indicating compile-time options.
-
- Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
- 1.0: size of uInt
- 3.2: size of uLong
- 5.4: size of voidpf (pointer)
- 7.6: size of z_off_t
-
- Compiler, assembler, and debug options:
- 8: DEBUG
- 9: ASMV or ASMINF -- use ASM code
- 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
- 11: 0 (reserved)
-
- One-time table building (smaller code, but not thread-safe if true):
- 12: BUILDFIXED -- build static block decoding tables when needed
- 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
- 14,15: 0 (reserved)
-
- Library content (indicates missing functionality):
- 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
- deflate code when not needed)
- 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
- and decode gzip streams (to avoid linking crc code)
- 18-19: 0 (reserved)
-
- Operation variations (changes in library functionality):
- 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
- 21: FASTEST -- deflate algorithm with only one, lowest compression level
- 22,23: 0 (reserved)
-
- The sprintf variant used by gzprintf (zero is best):
- 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
- 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
- 26: 0 = returns value, 1 = void -- 1 means inferred string length returned
-
- Remainder:
- 27-31: 0 (reserved)
- */
-
-
- /* utility functions */
-
-/*
- The following utility functions are implemented on top of the
- basic stream-oriented functions. To simplify the interface, some
- default options are assumed (compression level and memory usage,
- standard memory allocation functions). The source code of these
- utility functions can easily be modified if you need special options.
-*/
-
-ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
-/*
- Compresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be at least the value returned
- by compressBound(sourceLen). Upon exit, destLen is the actual size of the
- compressed buffer.
- This function can be used to compress a whole file at once if the
- input file is mmap'ed.
- compress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer.
-*/
-
-ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen,
- int level));
-/*
- Compresses the source buffer into the destination buffer. The level
- parameter has the same meaning as in deflateInit. sourceLen is the byte
- length of the source buffer. Upon entry, destLen is the total size of the
- destination buffer, which must be at least the value returned by
- compressBound(sourceLen). Upon exit, destLen is the actual size of the
- compressed buffer.
-
- compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_BUF_ERROR if there was not enough room in the output buffer,
- Z_STREAM_ERROR if the level parameter is invalid.
-*/
-
-ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
-/*
- compressBound() returns an upper bound on the compressed size after
- compress() or compress2() on sourceLen bytes. It would be used before
- a compress() or compress2() call to allocate the destination buffer.
-*/
-
-ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
-/*
- Decompresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be large enough to hold the
- entire uncompressed data. (The size of the uncompressed data must have
- been saved previously by the compressor and transmitted to the decompressor
- by some mechanism outside the scope of this compression library.)
- Upon exit, destLen is the actual size of the compressed buffer.
- This function can be used to decompress a whole file at once if the
- input file is mmap'ed.
-
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
-*/
-
-
-typedef voidp gzFile;
-
-ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
-/*
- Opens a gzip (.gz) file for reading or writing. The mode parameter
- is as in fopen ("rb" or "wb") but can also include a compression level
- ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
- Huffman only compression as in "wb1h", or 'R' for run-length encoding
- as in "wb1R". (See the description of deflateInit2 for more information
- about the strategy parameter.)
-
- gzopen can be used to read a file which is not in gzip format; in this
- case gzread will directly read from the file without decompression.
-
- gzopen returns NULL if the file could not be opened or if there was
- insufficient memory to allocate the (de)compression state; errno
- can be checked to distinguish the two cases (if errno is zero, the
- zlib error is Z_MEM_ERROR). */
-
-ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
-/*
- gzdopen() associates a gzFile with the file descriptor fd. File
- descriptors are obtained from calls like open, dup, creat, pipe or
- fileno (in the file has been previously opened with fopen).
- The mode parameter is as in gzopen.
- The next call of gzclose on the returned gzFile will also close the
- file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
- descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
- gzdopen returns NULL if there was insufficient memory to allocate
- the (de)compression state.
-*/
-
-ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
-/*
- Dynamically update the compression level or strategy. See the description
- of deflateInit2 for the meaning of these parameters.
- gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
- opened for writing.
-*/
-
-ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
-/*
- Reads the given number of uncompressed bytes from the compressed file.
- If the input file was not in gzip format, gzread copies the given number
- of bytes into the buffer.
- gzread returns the number of uncompressed bytes actually read (0 for
- end of file, -1 for error). */
-
-ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
- voidpc buf, unsigned len));
-/*
- Writes the given number of uncompressed bytes into the compressed file.
- gzwrite returns the number of uncompressed bytes actually written
- (0 in case of error).
-*/
-
-ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...))
- _Z_PRINTF_ATTRIBUTE(2, 3);
-/*
- Converts, formats, and writes the args to the compressed file under
- control of the format string, as in fprintf. gzprintf returns the number of
- uncompressed bytes actually written (0 in case of error). The number of
- uncompressed bytes written is limited to 4095. The caller should assure that
- this limit is not exceeded. If it is exceeded, then gzprintf() will return
- return an error (0) with nothing written. In this case, there may also be a
- buffer overflow with unpredictable consequences, which is possible only if
- zlib was compiled with the insecure functions sprintf() or vsprintf()
- because the secure snprintf() or vsnprintf() functions were not available.
-*/
-
-ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
-/*
- Writes the given null-terminated string to the compressed file, excluding
- the terminating null character.
- gzputs returns the number of characters written, or -1 in case of error.
-*/
-
-ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
-/*
- Reads bytes from the compressed file until len-1 characters are read, or
- a newline character is read and transferred to buf, or an end-of-file
- condition is encountered. The string is then terminated with a null
- character.
- gzgets returns buf, or Z_NULL in case of error.
-*/
-
-ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
-/*
- Writes c, converted to an unsigned char, into the compressed file.
- gzputc returns the value that was written, or -1 in case of error.
-*/
-
-ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
-/*
- Reads one byte from the compressed file. gzgetc returns this byte
- or -1 in case of end of file or error.
-*/
-
-ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
-/*
- Push one character back onto the stream to be read again later.
- Only one character of push-back is allowed. gzungetc() returns the
- character pushed, or -1 on failure. gzungetc() will fail if a
- character has been pushed but not read yet, or if c is -1. The pushed
- character will be discarded if the stream is repositioned with gzseek()
- or gzrewind().
-*/
-
-ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
-/*
- Flushes all pending output into the compressed file. The parameter
- flush is as in the deflate() function. The return value is the zlib
- error number (see function gzerror below). gzflush returns Z_OK if
- the flush parameter is Z_FINISH and all output could be flushed.
- gzflush should be called only when strictly necessary because it can
- degrade compression.
-*/
-
-ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
- z_off_t offset, int whence));
-/*
- Sets the starting position for the next gzread or gzwrite on the
- given compressed file. The offset represents a number of bytes in the
- uncompressed data stream. The whence parameter is defined as in lseek(2);
- the value SEEK_END is not supported.
- If the file is opened for reading, this function is emulated but can be
- extremely slow. If the file is opened for writing, only forward seeks are
- supported; gzseek then compresses a sequence of zeroes up to the new
- starting position.
-
- gzseek returns the resulting offset location as measured in bytes from
- the beginning of the uncompressed stream, or -1 in case of error, in
- particular if the file is opened for writing and the new starting position
- would be before the current position.
-*/
-
-ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
-/*
- Rewinds the given file. This function is supported only for reading.
-
- gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
-*/
-
-ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
-/*
- Returns the starting position for the next gzread or gzwrite on the
- given compressed file. This position represents a number of bytes in the
- uncompressed data stream.
-
- gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
-*/
-
-ZEXTERN int ZEXPORT gzeof OF((gzFile file));
-/*
- Returns 1 when EOF has previously been detected reading the given
- input stream, otherwise zero.
-*/
-
-ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
-/*
- Returns 1 if file is being read directly without decompression, otherwise
- zero.
-*/
-
-ZEXTERN int ZEXPORT gzclose OF((gzFile file));
-/*
- Flushes all pending output if necessary, closes the compressed file
- and deallocates all the (de)compression state. The return value is the zlib
- error number (see function gzerror below).
-*/
-
-ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
-/*
- Returns the error message for the last error which occurred on the
- given compressed file. errnum is set to zlib error number. If an
- error occurred in the file system and not in the compression library,
- errnum is set to Z_ERRNO and the application may consult errno
- to get the exact error code.
-*/
-
-ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
-/*
- Clears the error and end-of-file flags for file. This is analogous to the
- clearerr() function in stdio. This is useful for continuing to read a gzip
- file that is being written concurrently.
-*/
-
- /* checksum functions */
-
-/*
- These functions are not related to compression but are exported
- anyway because they might be useful in applications using the
- compression library.
-*/
-
-ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
-/*
- Update a running Adler-32 checksum with the bytes buf[0..len-1] and
- return the updated checksum. If buf is NULL, this function returns
- the required initial value for the checksum.
- An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
- much faster. Usage example:
-
- uLong adler = adler32(0L, Z_NULL, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- adler = adler32(adler, buffer, length);
- }
- if (adler != original_adler) error();
-*/
-
-ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
- z_off_t len2));
-/*
- Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
- and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
- each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
- seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.
-*/
-
-ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
-/*
- Update a running CRC-32 with the bytes buf[0..len-1] and return the
- updated CRC-32. If buf is NULL, this function returns the required initial
- value for the for the crc. Pre- and post-conditioning (one's complement) is
- performed within this function so it shouldn't be done by the application.
- Usage example:
-
- uLong crc = crc32(0L, Z_NULL, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- crc = crc32(crc, buffer, length);
- }
- if (crc != original_crc) error();
-*/
-
-ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
-
-/*
- Combine two CRC-32 check values into one. For two sequences of bytes,
- seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
- calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
- check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
- len2.
-*/
-
-
- /* various hacks, don't look :) */
-
-/* deflateInit and inflateInit are macros to allow checking the zlib version
- * and the compiler's view of z_stream:
- */
-ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
- int windowBits, int memLevel,
- int strategy, const char *version,
- int stream_size));
-ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
- unsigned char FAR *window,
- const char *version,
- int stream_size));
-#define deflateInit(strm, level) \
- deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
-#define inflateInit(strm) \
- inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
-#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
- deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
- (strategy), ZLIB_VERSION, sizeof(z_stream))
-#define inflateInit2(strm, windowBits) \
- inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
-#define inflateBackInit(strm, windowBits, window) \
- inflateBackInit_((strm), (windowBits), (window), \
- ZLIB_VERSION, sizeof(z_stream))
-
-
-#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
- struct internal_state {int dummy;}; /* hack for buggy compilers */
-#endif
-
-ZEXTERN const char * ZEXPORT zError OF((int));
-ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
-ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ZLIB_H */
diff --git a/source4/lib/zlib/zutil.c b/source4/lib/zlib/zutil.c
deleted file mode 100644
index d55f5948a3..0000000000
--- a/source4/lib/zlib/zutil.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/* zutil.c -- target dependent utility functions for the compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#include "zutil.h"
-
-#ifndef NO_DUMMY_DECL
-struct internal_state {int dummy;}; /* for buggy compilers */
-#endif
-
-const char * const z_errmsg[10] = {
-"need dictionary", /* Z_NEED_DICT 2 */
-"stream end", /* Z_STREAM_END 1 */
-"", /* Z_OK 0 */
-"file error", /* Z_ERRNO (-1) */
-"stream error", /* Z_STREAM_ERROR (-2) */
-"data error", /* Z_DATA_ERROR (-3) */
-"insufficient memory", /* Z_MEM_ERROR (-4) */
-"buffer error", /* Z_BUF_ERROR (-5) */
-"incompatible version",/* Z_VERSION_ERROR (-6) */
-""};
-
-
-const char * ZEXPORT zlibVersion()
-{
- return ZLIB_VERSION;
-}
-
-uLong ZEXPORT zlibCompileFlags()
-{
- uLong flags;
-
- flags = 0;
- switch (sizeof(uInt)) {
- case 2: break;
- case 4: flags += 1; break;
- case 8: flags += 2; break;
- default: flags += 3;
- }
- switch (sizeof(uLong)) {
- case 2: break;
- case 4: flags += 1 << 2; break;
- case 8: flags += 2 << 2; break;
- default: flags += 3 << 2;
- }
- switch (sizeof(voidpf)) {
- case 2: break;
- case 4: flags += 1 << 4; break;
- case 8: flags += 2 << 4; break;
- default: flags += 3 << 4;
- }
- switch (sizeof(z_off_t)) {
- case 2: break;
- case 4: flags += 1 << 6; break;
- case 8: flags += 2 << 6; break;
- default: flags += 3 << 6;
- }
-#ifdef DEBUG
- flags += 1 << 8;
-#endif
-#if defined(ASMV) || defined(ASMINF)
- flags += 1 << 9;
-#endif
-#ifdef ZLIB_WINAPI
- flags += 1 << 10;
-#endif
-#ifdef BUILDFIXED
- flags += 1 << 12;
-#endif
-#ifdef DYNAMIC_CRC_TABLE
- flags += 1 << 13;
-#endif
-#ifdef NO_GZCOMPRESS
- flags += 1L << 16;
-#endif
-#ifdef NO_GZIP
- flags += 1L << 17;
-#endif
-#ifdef PKZIP_BUG_WORKAROUND
- flags += 1L << 20;
-#endif
-#ifdef FASTEST
- flags += 1L << 21;
-#endif
-#ifdef STDC
-# ifdef NO_vsnprintf
- flags += 1L << 25;
-# ifdef HAS_vsprintf_void
- flags += 1L << 26;
-# endif
-# else
-# ifdef HAS_vsnprintf_void
- flags += 1L << 26;
-# endif
-# endif
-#else
- flags += 1L << 24;
-# ifdef NO_snprintf
- flags += 1L << 25;
-# ifdef HAS_sprintf_void
- flags += 1L << 26;
-# endif
-# else
-# ifdef HAS_snprintf_void
- flags += 1L << 26;
-# endif
-# endif
-#endif
- return flags;
-}
-
-#ifdef DEBUG
-
-# ifndef verbose
-# define verbose 0
-# endif
-int z_verbose = verbose;
-
-void z_error (m)
- char *m;
-{
- fprintf(stderr, "%s\n", m);
- exit(1);
-}
-#endif
-
-/* exported to allow conversion of error code to string for compress() and
- * uncompress()
- */
-const char * ZEXPORT zError(err)
- int err;
-{
- return ERR_MSG(err);
-}
-
-#if defined(_WIN32_WCE)
- /* The Microsoft C Run-Time Library for Windows CE doesn't have
- * errno. We define it as a global variable to simplify porting.
- * Its value is always 0 and should not be used.
- */
- int errno = 0;
-#endif
-
-#ifndef HAVE_MEMCPY
-
-void zmemcpy(dest, source, len)
- Bytef* dest;
- const Bytef* source;
- uInt len;
-{
- if (len == 0) return;
- do {
- *dest++ = *source++; /* ??? to be unrolled */
- } while (--len != 0);
-}
-
-int zmemcmp(s1, s2, len)
- const Bytef* s1;
- const Bytef* s2;
- uInt len;
-{
- uInt j;
-
- for (j = 0; j < len; j++) {
- if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
- }
- return 0;
-}
-
-void zmemzero(dest, len)
- Bytef* dest;
- uInt len;
-{
- if (len == 0) return;
- do {
- *dest++ = 0; /* ??? to be unrolled */
- } while (--len != 0);
-}
-#endif
-
-
-#ifdef SYS16BIT
-
-#ifdef __TURBOC__
-/* Turbo C in 16-bit mode */
-
-# define MY_ZCALLOC
-
-/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
- * and farmalloc(64K) returns a pointer with an offset of 8, so we
- * must fix the pointer. Warning: the pointer must be put back to its
- * original form in order to free it, use zcfree().
- */
-
-#define MAX_PTR 10
-/* 10*64K = 640K */
-
-local int next_ptr = 0;
-
-typedef struct ptr_table_s {
- voidpf org_ptr;
- voidpf new_ptr;
-} ptr_table;
-
-local ptr_table table[MAX_PTR];
-/* This table is used to remember the original form of pointers
- * to large buffers (64K). Such pointers are normalized with a zero offset.
- * Since MSDOS is not a preemptive multitasking OS, this table is not
- * protected from concurrent access. This hack doesn't work anyway on
- * a protected system like OS/2. Use Microsoft C instead.
- */
-
-voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
-{
- voidpf buf = opaque; /* just to make some compilers happy */
- ulg bsize = (ulg)items*size;
-
- /* If we allocate less than 65520 bytes, we assume that farmalloc
- * will return a usable pointer which doesn't have to be normalized.
- */
- if (bsize < 65520L) {
- buf = farmalloc(bsize);
- if (*(ush*)&buf != 0) return buf;
- } else {
- buf = farmalloc(bsize + 16L);
- }
- if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
- table[next_ptr].org_ptr = buf;
-
- /* Normalize the pointer to seg:0 */
- *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
- *(ush*)&buf = 0;
- table[next_ptr++].new_ptr = buf;
- return buf;
-}
-
-void zcfree (voidpf opaque, voidpf ptr)
-{
- int n;
- if (*(ush*)&ptr != 0) { /* object < 64K */
- farfree(ptr);
- return;
- }
- /* Find the original pointer */
- for (n = 0; n < next_ptr; n++) {
- if (ptr != table[n].new_ptr) continue;
-
- farfree(table[n].org_ptr);
- while (++n < next_ptr) {
- table[n-1] = table[n];
- }
- next_ptr--;
- return;
- }
- ptr = opaque; /* just to make some compilers happy */
- Assert(0, "zcfree: ptr not found");
-}
-
-#endif /* __TURBOC__ */
-
-
-#ifdef M_I86
-/* Microsoft C in 16-bit mode */
-
-# define MY_ZCALLOC
-
-#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
-# define _halloc halloc
-# define _hfree hfree
-#endif
-
-voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
-{
- if (opaque) opaque = 0; /* to make compiler happy */
- return _halloc((long)items, size);
-}
-
-void zcfree (voidpf opaque, voidpf ptr)
-{
- if (opaque) opaque = 0; /* to make compiler happy */
- _hfree(ptr);
-}
-
-#endif /* M_I86 */
-
-#endif /* SYS16BIT */
-
-
-#ifndef MY_ZCALLOC /* Any system without a special alloc function */
-
-#ifndef STDC
-extern voidp malloc OF((uInt size));
-extern voidp calloc OF((uInt items, uInt size));
-extern void free OF((voidpf ptr));
-#endif
-
-voidpf zcalloc (opaque, items, size)
- voidpf opaque;
- unsigned items;
- unsigned size;
-{
- if (opaque) items += size - size; /* make compiler happy */
- return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
- (voidpf)calloc(items, size);
-}
-
-void zcfree (opaque, ptr)
- voidpf opaque;
- voidpf ptr;
-{
- free(ptr);
- if (opaque) return; /* make compiler happy */
-}
-
-#endif /* MY_ZCALLOC */
diff --git a/source4/lib/zlib/zutil.h b/source4/lib/zlib/zutil.h
deleted file mode 100644
index edd8e0acbb..0000000000
--- a/source4/lib/zlib/zutil.h
+++ /dev/null
@@ -1,269 +0,0 @@
-/* zutil.h -- internal interface and configuration of the compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* @(#) $Id$ */
-
-#ifndef ZUTIL_H
-#define ZUTIL_H
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-#ifdef STDC
-# ifndef _WIN32_WCE
-# include <stddef.h>
-# endif
-# include <string.h>
-# include <stdlib.h>
-#endif
-#ifdef NO_ERRNO_H
-# ifdef _WIN32_WCE
- /* The Microsoft C Run-Time Library for Windows CE doesn't have
- * errno. We define it as a global variable to simplify porting.
- * Its value is always 0 and should not be used. We rename it to
- * avoid conflict with other libraries that use the same workaround.
- */
-# define errno z_errno
-# endif
- extern int errno;
-#else
-# ifndef _WIN32_WCE
-# include <errno.h>
-# endif
-#endif
-
-#ifndef local
-# define local static
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
-typedef unsigned char uch;
-typedef uch FAR uchf;
-typedef unsigned short ush;
-typedef ush FAR ushf;
-typedef unsigned long ulg;
-
-extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
-/* (size given to avoid silly warnings with Visual C++) */
-
-#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
-
-#define ERR_RETURN(strm,err) \
- return (strm->msg = ERR_MSG(err), (err))
-/* To be used only when the state is known to be valid */
-
- /* common constants */
-
-#ifndef DEF_WBITS
-# define DEF_WBITS MAX_WBITS
-#endif
-/* default windowBits for decompression. MAX_WBITS is for compression only */
-
-#if MAX_MEM_LEVEL >= 8
-# define DEF_MEM_LEVEL 8
-#else
-# define DEF_MEM_LEVEL MAX_MEM_LEVEL
-#endif
-/* default memLevel */
-
-#define STORED_BLOCK 0
-#define STATIC_TREES 1
-#define DYN_TREES 2
-/* The three kinds of block type */
-
-#define MIN_MATCH 3
-#define MAX_MATCH 258
-/* The minimum and maximum match lengths */
-
-#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
-
- /* target dependencies */
-
-#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
-# define OS_CODE 0x00
-# if defined(__TURBOC__) || defined(__BORLANDC__)
-# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
- /* Allow compilation with ANSI keywords only enabled */
- void _Cdecl farfree( void *block );
- void *_Cdecl farmalloc( unsigned long nbytes );
-# else
-# include <alloc.h>
-# endif
-# else /* MSC or DJGPP */
-# include <malloc.h>
-# endif
-#endif
-
-#ifdef AMIGA
-# define OS_CODE 0x01
-#endif
-
-#if defined(VAXC) || defined(VMS)
-# define OS_CODE 0x02
-# define F_OPEN(name, mode) \
- fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
-#endif
-
-#if defined(ATARI) || defined(atarist)
-# define OS_CODE 0x05
-#endif
-
-#ifdef OS2
-# define OS_CODE 0x06
-# ifdef M_I86
- #include <malloc.h>
-# endif
-#endif
-
-#if defined(MACOS) || defined(TARGET_OS_MAC)
-# define OS_CODE 0x07
-# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
-# include <unix.h> /* for fdopen */
-# else
-# ifndef fdopen
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# endif
-# endif
-#endif
-
-#ifdef TOPS20
-# define OS_CODE 0x0a
-#endif
-
-#ifdef WIN32
-# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
-# define OS_CODE 0x0b
-# endif
-#endif
-
-#ifdef __50SERIES /* Prime/PRIMOS */
-# define OS_CODE 0x0f
-#endif
-
-#if defined(_BEOS_) || defined(RISCOS)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-#endif
-
-#if (defined(_MSC_VER) && (_MSC_VER > 600))
-# if defined(_WIN32_WCE)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# ifndef _PTRDIFF_T_DEFINED
- typedef int ptrdiff_t;
-# define _PTRDIFF_T_DEFINED
-# endif
-# else
-# define fdopen(fd,type) _fdopen(fd,type)
-# endif
-#endif
-
- /* common defaults */
-
-#ifndef OS_CODE
-# define OS_CODE 0x03 /* assume Unix */
-#endif
-
-#ifndef F_OPEN
-# define F_OPEN(name, mode) fopen((name), (mode))
-#endif
-
- /* functions */
-
-#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
-# ifndef HAVE_VSNPRINTF
-# define HAVE_VSNPRINTF
-# endif
-#endif
-#if defined(__CYGWIN__)
-# ifndef HAVE_VSNPRINTF
-# define HAVE_VSNPRINTF
-# endif
-#endif
-#ifndef HAVE_VSNPRINTF
-# ifdef MSDOS
- /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
- but for now we just assume it doesn't. */
-# define NO_vsnprintf
-# endif
-# ifdef __TURBOC__
-# define NO_vsnprintf
-# endif
-# ifdef WIN32
- /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
-# if !defined(vsnprintf) && !defined(NO_vsnprintf)
-# define vsnprintf _vsnprintf
-# endif
-# endif
-# ifdef __SASC
-# define NO_vsnprintf
-# endif
-#endif
-#ifdef VMS
-# define NO_vsnprintf
-#endif
-
-#if defined(pyr)
-# define NO_MEMCPY
-#endif
-#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
- /* Use our own functions for small and medium model with MSC <= 5.0.
- * You may have to use the same strategy for Borland C (untested).
- * The __SC__ check is for Symantec.
- */
-# define NO_MEMCPY
-#endif
-#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
-# define HAVE_MEMCPY
-#endif
-#ifdef HAVE_MEMCPY
-# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
-# define zmemcpy _fmemcpy
-# define zmemcmp _fmemcmp
-# define zmemzero(dest, len) _fmemset(dest, 0, len)
-# else
-# define zmemcpy memcpy
-# define zmemcmp memcmp
-# define zmemzero(dest, len) memset(dest, 0, len)
-# endif
-#else
- extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
- extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
- extern void zmemzero OF((Bytef* dest, uInt len));
-#endif
-
-/* Diagnostic functions */
-#ifdef DEBUG
-# include <stdio.h>
- extern int z_verbose;
- extern void z_error OF((char *m));
-# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
-# define Trace(x) {if (z_verbose>=0) fprintf x ;}
-# define Tracev(x) {if (z_verbose>0) fprintf x ;}
-# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
-# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
-# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
-#else
-# define Assert(cond,msg)
-# define Trace(x)
-# define Tracev(x)
-# define Tracevv(x)
-# define Tracec(c,x)
-# define Tracecv(c,x)
-#endif
-
-
-voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
-void zcfree OF((voidpf opaque, voidpf ptr));
-
-#define ZALLOC(strm, items, size) \
- (*((strm)->zalloc))((strm)->opaque, (items), (size))
-#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
-#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
-
-#endif /* ZUTIL_H */