summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikas Gorur <vikas@zresearch.com>2009-02-18 17:36:07 +0530
committerVikas Gorur <vikas@zresearch.com>2009-02-18 17:36:07 +0530
commit77adf4cd648dce41f89469dd185deec6b6b53a0b (patch)
tree02e155a5753b398ee572b45793f889b538efab6b
parentf3b2e6580e5663292ee113c741343c8a43ee133f (diff)
Added all files
-rw-r--r--AUTHORS3
-rw-r--r--COPYING674
-rw-r--r--ChangeLog1
-rw-r--r--INSTALL32
-rw-r--r--Makefile.am15
-rw-r--r--NEWS1
-rw-r--r--README9
-rw-r--r--THANKS3
-rw-r--r--argp-standalone/Makefile.am38
-rw-r--r--argp-standalone/acinclude.m41084
-rw-r--r--argp-standalone/argp-ba.c26
-rw-r--r--argp-standalone/argp-eexst.c36
-rw-r--r--argp-standalone/argp-fmtstream.c475
-rw-r--r--argp-standalone/argp-fmtstream.h319
-rw-r--r--argp-standalone/argp-help.c1849
-rw-r--r--argp-standalone/argp-namefrob.h96
-rw-r--r--argp-standalone/argp-parse.c1305
-rw-r--r--argp-standalone/argp-pv.c25
-rw-r--r--argp-standalone/argp-pvh.c32
-rw-r--r--argp-standalone/argp.h602
-rwxr-xr-xargp-standalone/autogen.sh6
-rw-r--r--argp-standalone/configure.ac100
-rw-r--r--argp-standalone/mempcpy.c21
-rw-r--r--argp-standalone/strcasecmp.c28
-rw-r--r--argp-standalone/strchrnul.c23
-rw-r--r--argp-standalone/strndup.c34
-rw-r--r--argp-standalone/vsnprintf.c839
-rw-r--r--auth/Makefile.am3
-rw-r--r--auth/addr/Makefile.am3
-rw-r--r--auth/addr/src/Makefile.am12
-rw-r--r--auth/addr/src/addr.c208
-rw-r--r--auth/login/Makefile.am3
-rw-r--r--auth/login/src/Makefile.am13
-rw-r--r--auth/login/src/login.c100
-rwxr-xr-xautogen.sh8
-rw-r--r--booster/Makefile.am1
-rw-r--r--booster/src/Makefile.am17
-rw-r--r--booster/src/booster.c920
-rwxr-xr-xcommit.sh6
-rw-r--r--configure.ac554
-rw-r--r--doc/Makefile.am11
-rw-r--r--doc/authentication.txt112
-rw-r--r--doc/booster.txt54
-rw-r--r--doc/coding-standard.pdfbin0 -> 68627 bytes
-rw-r--r--doc/coding-standard.tex361
-rw-r--r--doc/errno.list.bsd.txt376
-rw-r--r--doc/errno.list.linux.txt1586
-rw-r--r--doc/errno.list.macosx.txt1513
-rw-r--r--doc/errno.list.solaris.txt206
-rw-r--r--doc/examples/Makefile.am8
-rw-r--r--doc/examples/README13
-rw-r--r--doc/examples/filter.vol23
-rw-r--r--doc/examples/io-cache.vol25
-rw-r--r--doc/examples/io-threads.vol21
-rw-r--r--doc/examples/posix-locks.vol20
-rw-r--r--doc/examples/protocol-client.vol17
-rw-r--r--doc/examples/protocol-server.vol25
-rw-r--r--doc/examples/read-ahead.vol22
-rw-r--r--doc/examples/replicate.vol119
-rw-r--r--doc/examples/stripe.vol121
-rw-r--r--doc/examples/trace.vol16
-rw-r--r--doc/examples/trash.vol20
-rw-r--r--doc/examples/unify.vol178
-rw-r--r--doc/examples/write-behind.vol26
-rw-r--r--doc/get_put_api_using_xattr.txt22
-rw-r--r--doc/glusterfs.8139
-rw-r--r--doc/glusterfs.vol.sample61
-rw-r--r--doc/glusterfsd.vol.sample47
-rw-r--r--doc/hacker-guide/Makefile.am8
-rw-r--r--doc/hacker-guide/adding-fops.txt33
-rw-r--r--doc/hacker-guide/bdb.txt70
-rw-r--r--doc/hacker-guide/call-stub.txt1033
-rw-r--r--doc/hacker-guide/hacker-guide.tex312
-rw-r--r--doc/hacker-guide/posix.txt59
-rw-r--r--doc/hacker-guide/replicate.txt206
-rw-r--r--doc/hacker-guide/write-behind.txt45
-rw-r--r--doc/handling-options.txt13
-rw-r--r--doc/mac-related-xattrs.txt21
-rw-r--r--doc/porting_guide.txt45
-rw-r--r--doc/qa/qa-client.vol170
-rw-r--r--doc/qa/qa-high-avail-client.vol17
-rw-r--r--doc/qa/qa-high-avail-server.vol346
-rw-r--r--doc/qa/qa-server.vol284
-rw-r--r--doc/replicate.lyx797
-rw-r--r--doc/replicate.pdfbin0 -> 109057 bytes
-rw-r--r--doc/solaris-related-xattrs.txt44
-rw-r--r--doc/translator-options.txt221
-rw-r--r--doc/user-guide/Makefile.am1
-rw-r--r--doc/user-guide/advanced-stripe.odgbin0 -> 12648 bytes
-rw-r--r--doc/user-guide/advanced-stripe.pdfbin0 -> 13382 bytes
-rw-r--r--doc/user-guide/colonO-icon.jpgbin0 -> 779 bytes
-rw-r--r--doc/user-guide/fdl.texi454
-rw-r--r--doc/user-guide/fuse.odgbin0 -> 13190 bytes
-rw-r--r--doc/user-guide/fuse.pdfbin0 -> 14948 bytes
-rw-r--r--doc/user-guide/ha.odgbin0 -> 37290 bytes
-rw-r--r--doc/user-guide/ha.pdfbin0 -> 19403 bytes
-rw-r--r--doc/user-guide/stripe.odgbin0 -> 10188 bytes
-rw-r--r--doc/user-guide/stripe.pdfbin0 -> 11941 bytes
-rw-r--r--doc/user-guide/unify.odgbin0 -> 12955 bytes
-rw-r--r--doc/user-guide/unify.pdfbin0 -> 18969 bytes
-rw-r--r--doc/user-guide/user-guide.info2698
-rw-r--r--doc/user-guide/user-guide.pdfbin0 -> 353986 bytes
-rw-r--r--doc/user-guide/user-guide.texi2226
-rw-r--r--doc/user-guide/xlator.odgbin0 -> 12169 bytes
-rw-r--r--doc/user-guide/xlator.pdfbin0 -> 14358 bytes
-rw-r--r--extras/Makefile.am13
-rw-r--r--extras/Portfile26
-rw-r--r--extras/benchmarking/Makefile.am7
-rw-r--r--extras/benchmarking/README18
-rw-r--r--extras/benchmarking/glfs-bm.c619
-rwxr-xr-xextras/benchmarking/launch-script.sh18
-rwxr-xr-xextras/benchmarking/local-script.sh26
-rw-r--r--extras/glusterfs-mode.el112
-rw-r--r--extras/glusterfs.vim211
-rw-r--r--extras/init.d/Makefile.am9
-rwxr-xr-xextras/init.d/glusterfs-server100
-rw-r--r--extras/init.d/glusterfs-server.plist.in15
-rwxr-xr-xextras/init.d/glusterfsd110
-rwxr-xr-xextras/specgen.scm98
-rw-r--r--extras/stripe-merge.c48
-rw-r--r--extras/test/Makefile.am3
-rw-r--r--extras/test/rdd.c457
-rw-r--r--glusterfs-guts/Makefile.am1
-rw-r--r--glusterfs-guts/src/Makefile.am17
-rw-r--r--glusterfs-guts/src/fuse-bridge.c2724
-rw-r--r--glusterfs-guts/src/fuse-extra.c137
-rw-r--r--glusterfs-guts/src/fuse-extra.h38
-rw-r--r--glusterfs-guts/src/fuse_kernel.h380
-rw-r--r--glusterfs-guts/src/glusterfs-fuse.h58
-rw-r--r--glusterfs-guts/src/glusterfs-guts.c400
-rw-r--r--glusterfs-guts/src/glusterfs-guts.h62
-rw-r--r--glusterfs-guts/src/guts-extra.c18
-rw-r--r--glusterfs-guts/src/guts-lowlevel.h86
-rw-r--r--glusterfs-guts/src/guts-parse.c217
-rw-r--r--glusterfs-guts/src/guts-parse.h140
-rw-r--r--glusterfs-guts/src/guts-replay.c834
-rw-r--r--glusterfs-guts/src/guts-replay.h33
-rw-r--r--glusterfs-guts/src/guts-tables.c248
-rw-r--r--glusterfs-guts/src/guts-tables.h80
-rw-r--r--glusterfs-guts/src/guts-trace.c650
-rw-r--r--glusterfs-guts/src/guts-trace.h54
-rw-r--r--glusterfs.spec.in256
-rw-r--r--glusterfsd/Makefile.am3
-rw-r--r--glusterfsd/src/Makefile.am24
-rw-r--r--glusterfsd/src/fetch-spec.c266
-rw-r--r--glusterfsd/src/glusterfsd.c1123
-rw-r--r--glusterfsd/src/glusterfsd.h78
-rw-r--r--libglusterfs/Makefile.am3
-rw-r--r--libglusterfs/src/Makefile.am21
-rw-r--r--libglusterfs/src/authenticate.c240
-rw-r--r--libglusterfs/src/authenticate.h61
-rw-r--r--libglusterfs/src/byte-order.h150
-rw-r--r--libglusterfs/src/call-stub.c3822
-rw-r--r--libglusterfs/src/call-stub.h1104
-rw-r--r--libglusterfs/src/common-utils.c1349
-rw-r--r--libglusterfs/src/common-utils.h313
-rw-r--r--libglusterfs/src/compat-errno.c938
-rw-r--r--libglusterfs/src/compat-errno.h240
-rw-r--r--libglusterfs/src/compat.c383
-rw-r--r--libglusterfs/src/compat.h356
-rw-r--r--libglusterfs/src/defaults.c1388
-rw-r--r--libglusterfs/src/defaults.h273
-rw-r--r--libglusterfs/src/dict.c2243
-rw-r--r--libglusterfs/src/dict.h179
-rw-r--r--libglusterfs/src/event.c978
-rw-r--r--libglusterfs/src/event.h90
-rw-r--r--libglusterfs/src/fd.c611
-rw-r--r--libglusterfs/src/fd.h107
-rw-r--r--libglusterfs/src/gf-dirent.c157
-rw-r--r--libglusterfs/src/gf-dirent.h60
-rw-r--r--libglusterfs/src/glusterfs.h277
-rw-r--r--libglusterfs/src/hashfn.c89
-rw-r--r--libglusterfs/src/hashfn.h33
-rw-r--r--libglusterfs/src/inode.c1174
-rw-r--r--libglusterfs/src/inode.h160
-rw-r--r--libglusterfs/src/list.h154
-rw-r--r--libglusterfs/src/locking.h49
-rw-r--r--libglusterfs/src/logging.c207
-rw-r--r--libglusterfs/src/logging.h132
-rw-r--r--libglusterfs/src/mem-pool.c174
-rw-r--r--libglusterfs/src/mem-pool.h54
-rw-r--r--libglusterfs/src/protocol.h777
-rw-r--r--libglusterfs/src/revision.h1
-rw-r--r--libglusterfs/src/scheduler.c80
-rw-r--r--libglusterfs/src/scheduler.h40
-rw-r--r--libglusterfs/src/spec.l94
-rw-r--r--libglusterfs/src/spec.y613
-rw-r--r--libglusterfs/src/stack.h266
-rw-r--r--libglusterfs/src/timer.c220
-rw-r--r--libglusterfs/src/timer.h68
-rw-r--r--libglusterfs/src/transport.c339
-rw-r--r--libglusterfs/src/transport.h85
-rw-r--r--libglusterfs/src/xlator.c728
-rw-r--r--libglusterfs/src/xlator.h842
-rw-r--r--libglusterfsclient/Makefile.am3
-rw-r--r--libglusterfsclient/src/Makefile.am16
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient-internals.h144
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c3146
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.h279
-rw-r--r--mod_glusterfs/Makefile.am3
-rw-r--r--mod_glusterfs/apache/1.3/Makefile.am3
-rw-r--r--mod_glusterfs/apache/1.3/src/Makefile.am30
-rw-r--r--mod_glusterfs/apache/1.3/src/README.txt107
-rw-r--r--mod_glusterfs/apache/1.3/src/mod_glusterfs.c514
-rw-r--r--mod_glusterfs/apache/2.2/Makefile.am3
-rw-r--r--mod_glusterfs/apache/2.2/src/Makefile.am31
-rw-r--r--mod_glusterfs/apache/2.2/src/README.txt105
-rw-r--r--mod_glusterfs/apache/2.2/src/mod_glusterfs.c3536
-rw-r--r--mod_glusterfs/apache/Makefile.am10
-rw-r--r--mod_glusterfs/lighttpd/1.4/Makefile.am3
-rw-r--r--mod_glusterfs/lighttpd/1.4/Makefile.am.diff29
-rw-r--r--mod_glusterfs/lighttpd/1.4/README.txt57
-rw-r--r--mod_glusterfs/lighttpd/1.4/mod_glusterfs.c1709
-rw-r--r--mod_glusterfs/lighttpd/1.4/mod_glusterfs.h29
-rw-r--r--mod_glusterfs/lighttpd/1.5/Makefile.am3
-rw-r--r--mod_glusterfs/lighttpd/1.5/Makefile.am.diff29
-rw-r--r--mod_glusterfs/lighttpd/1.5/README.txt57
-rw-r--r--mod_glusterfs/lighttpd/1.5/mod_glusterfs.c1476
-rw-r--r--mod_glusterfs/lighttpd/1.5/mod_glusterfs.h29
-rw-r--r--mod_glusterfs/lighttpd/Makefile.am3
-rw-r--r--scheduler/Makefile.am3
-rw-r--r--scheduler/alu/Makefile.am3
-rw-r--r--scheduler/alu/src/Makefile.am14
-rw-r--r--scheduler/alu/src/alu.c993
-rw-r--r--scheduler/alu/src/alu.h89
-rw-r--r--scheduler/nufa/Makefile.am3
-rw-r--r--scheduler/nufa/src/Makefile.am12
-rw-r--r--scheduler/nufa/src/nufa.c403
-rw-r--r--scheduler/random/Makefile.am3
-rw-r--r--scheduler/random/src/Makefile.am14
-rw-r--r--scheduler/random/src/random.c283
-rw-r--r--scheduler/random/src/random.h46
-rw-r--r--scheduler/rr/Makefile.am3
-rw-r--r--scheduler/rr/src/Makefile.am13
-rw-r--r--scheduler/rr/src/rr-options.c256
-rw-r--r--scheduler/rr/src/rr-options.h34
-rw-r--r--scheduler/rr/src/rr.c565
-rw-r--r--scheduler/rr/src/rr.h70
-rw-r--r--scheduler/switch/Makefile.am3
-rw-r--r--scheduler/switch/src/Makefile.am12
-rw-r--r--scheduler/switch/src/switch.c398
-rw-r--r--transport/Makefile.am3
-rw-r--r--transport/ib-verbs/Makefile.am1
-rw-r--r--transport/ib-verbs/src/Makefile.am15
-rw-r--r--transport/ib-verbs/src/ib-verbs.c2392
-rw-r--r--transport/ib-verbs/src/ib-verbs.h215
-rw-r--r--transport/ib-verbs/src/name.c682
-rw-r--r--transport/ib-verbs/src/name.h47
-rw-r--r--transport/socket/Makefile.am1
-rw-r--r--transport/socket/src/Makefile.am14
-rw-r--r--transport/socket/src/name.c677
-rw-r--r--transport/socket/src/name.h44
-rw-r--r--transport/socket/src/socket.c1370
-rw-r--r--transport/socket/src/socket.h106
-rw-r--r--xlators/Makefile.am3
-rw-r--r--xlators/bindings/Makefile.am1
-rw-r--r--xlators/bindings/python/Makefile.am1
-rw-r--r--xlators/bindings/python/src/Makefile.am19
-rw-r--r--xlators/bindings/python/src/gluster.py47
-rw-r--r--xlators/bindings/python/src/glusterstack.py55
-rw-r--r--xlators/bindings/python/src/glustertypes.py167
-rw-r--r--xlators/bindings/python/src/python.c235
-rw-r--r--xlators/bindings/python/src/testxlator.py56
-rw-r--r--xlators/cluster/Makefile.am3
-rw-r--r--xlators/cluster/afr/Makefile.am3
-rw-r--r--xlators/cluster/afr/src/Makefile.am20
-rw-r--r--xlators/cluster/afr/src/afr-dir-read.c345
-rw-r--r--xlators/cluster/afr/src/afr-dir-read.h47
-rw-r--r--xlators/cluster/afr/src/afr-dir-write.c1786
-rw-r--r--xlators/cluster/afr/src/afr-dir-write.h59
-rw-r--r--xlators/cluster/afr/src/afr-inode-read.c721
-rw-r--r--xlators/cluster/afr/src/afr-inode-read.h47
-rw-r--r--xlators/cluster/afr/src/afr-inode-write.c2024
-rw-r--r--xlators/cluster/afr/src/afr-inode-write.h63
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c1073
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.h66
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-data.c1030
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-entry.c2038
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-metadata.c791
-rw-r--r--xlators/cluster/afr/src/afr-self-heal.h52
-rw-r--r--xlators/cluster/afr/src/afr-transaction.c957
-rw-r--r--xlators/cluster/afr/src/afr-transaction.h36
-rw-r--r--xlators/cluster/afr/src/afr.c2338
-rw-r--r--xlators/cluster/afr/src/afr.h523
-rw-r--r--xlators/cluster/dht/Makefile.am1
-rw-r--r--xlators/cluster/dht/src/Makefile.am30
-rw-r--r--xlators/cluster/dht/src/dht-common.c3470
-rw-r--r--xlators/cluster/dht/src/dht-common.h212
-rw-r--r--xlators/cluster/dht/src/dht-hashfn-tea.c146
-rw-r--r--xlators/cluster/dht/src/dht-hashfn.c88
-rw-r--r--xlators/cluster/dht/src/dht-helper.c326
-rw-r--r--xlators/cluster/dht/src/dht-layout.c543
-rw-r--r--xlators/cluster/dht/src/dht-linkfile.c224
-rw-r--r--xlators/cluster/dht/src/dht-rename.c562
-rw-r--r--xlators/cluster/dht/src/dht-selfheal.c460
-rw-r--r--xlators/cluster/dht/src/dht.c222
-rw-r--r--xlators/cluster/dht/src/nufa.c684
-rw-r--r--xlators/cluster/ha/Makefile.am3
-rw-r--r--xlators/cluster/ha/src/Makefile.am15
-rw-r--r--xlators/cluster/ha/src/ha-helpers.c191
-rw-r--r--xlators/cluster/ha/src/ha.c3479
-rw-r--r--xlators/cluster/ha/src/ha.h59
-rw-r--r--xlators/cluster/map/Makefile.am3
-rw-r--r--xlators/cluster/map/src/Makefile.am15
-rw-r--r--xlators/cluster/map/src/map-helper.c357
-rw-r--r--xlators/cluster/map/src/map.c2193
-rw-r--r--xlators/cluster/map/src/map.h76
-rw-r--r--xlators/cluster/stripe/Makefile.am3
-rw-r--r--xlators/cluster/stripe/src/Makefile.am14
-rw-r--r--xlators/cluster/stripe/src/stripe.c3286
-rw-r--r--xlators/cluster/unify/Makefile.am3
-rw-r--r--xlators/cluster/unify/src/Makefile.am16
-rw-r--r--xlators/cluster/unify/src/unify-self-heal.c1225
-rw-r--r--xlators/cluster/unify/src/unify.c4451
-rw-r--r--xlators/cluster/unify/src/unify.h132
-rw-r--r--xlators/debug/Makefile.am3
-rw-r--r--xlators/debug/error-gen/Makefile.am3
-rw-r--r--xlators/debug/error-gen/src/Makefile.am14
-rw-r--r--xlators/debug/error-gen/src/error-gen.c1780
-rw-r--r--xlators/debug/trace/Makefile.am3
-rw-r--r--xlators/debug/trace/src/Makefile.am14
-rw-r--r--xlators/debug/trace/src/trace.c2321
-rw-r--r--xlators/encryption/Makefile.am3
-rw-r--r--xlators/encryption/rot-13/Makefile.am3
-rw-r--r--xlators/encryption/rot-13/src/Makefile.am14
-rw-r--r--xlators/encryption/rot-13/src/rot-13.c200
-rw-r--r--xlators/encryption/rot-13/src/rot-13.h33
-rw-r--r--xlators/features/Makefile.am3
-rw-r--r--xlators/features/filter/Makefile.am3
-rw-r--r--xlators/features/filter/src/Makefile.am13
-rw-r--r--xlators/features/filter/src/filter.c1768
-rw-r--r--xlators/features/locks/Makefile.am3
-rw-r--r--xlators/features/locks/src/Makefile.am20
-rw-r--r--xlators/features/locks/src/common.c561
-rw-r--r--xlators/features/locks/src/common.h59
-rw-r--r--xlators/features/locks/src/internal.c762
-rw-r--r--xlators/features/locks/src/locks.h111
-rw-r--r--xlators/features/locks/src/posix.c834
-rw-r--r--xlators/features/locks/tests/unit-test.c75
-rw-r--r--xlators/features/path-convertor/Makefile.am3
-rw-r--r--xlators/features/path-convertor/src/Makefile.am14
-rw-r--r--xlators/features/path-convertor/src/path.c1217
-rw-r--r--xlators/features/quota/Makefile.am3
-rw-r--r--xlators/features/quota/src/Makefile.am13
-rw-r--r--xlators/features/quota/src/quota.c1056
-rw-r--r--xlators/features/trash/Makefile.am3
-rw-r--r--xlators/features/trash/src/Makefile.am13
-rw-r--r--xlators/features/trash/src/trash.c596
-rw-r--r--xlators/meta/Makefile.am1
-rw-r--r--xlators/meta/src/Makefile.am10
-rw-r--r--xlators/meta/src/meta.c1285
-rw-r--r--xlators/meta/src/meta.h48
-rw-r--r--xlators/meta/src/misc.c67
-rw-r--r--xlators/meta/src/misc.h31
-rw-r--r--xlators/meta/src/tree.c176
-rw-r--r--xlators/meta/src/tree.h35
-rw-r--r--xlators/meta/src/view.c258
-rw-r--r--xlators/meta/src/view.h32
-rw-r--r--xlators/mount/Makefile.am3
-rw-r--r--xlators/mount/fuse/Makefile.am3
-rw-r--r--xlators/mount/fuse/src/Makefile.am14
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c2859
-rw-r--r--xlators/mount/fuse/src/fuse-extra.c137
-rw-r--r--xlators/mount/fuse/src/fuse-extra.h42
-rw-r--r--xlators/mount/fuse/utils/Makefile.am10
-rwxr-xr-xxlators/mount/fuse/utils/mount.glusterfs.in152
-rwxr-xr-xxlators/mount/fuse/utils/mount_glusterfs.in181
-rw-r--r--xlators/performance/Makefile.am3
-rw-r--r--xlators/performance/io-cache/Makefile.am3
-rw-r--r--xlators/performance/io-cache/src/Makefile.am14
-rw-r--r--xlators/performance/io-cache/src/io-cache.c1478
-rw-r--r--xlators/performance/io-cache/src/io-cache.h330
-rw-r--r--xlators/performance/io-cache/src/ioc-inode.c201
-rw-r--r--xlators/performance/io-cache/src/page.c778
-rw-r--r--xlators/performance/io-threads/Makefile.am3
-rw-r--r--xlators/performance/io-threads/src/Makefile.am14
-rw-r--r--xlators/performance/io-threads/src/io-threads.c1254
-rw-r--r--xlators/performance/io-threads/src/io-threads.h99
-rw-r--r--xlators/performance/read-ahead/Makefile.am3
-rw-r--r--xlators/performance/read-ahead/src/Makefile.am14
-rw-r--r--xlators/performance/read-ahead/src/page.c487
-rw-r--r--xlators/performance/read-ahead/src/read-ahead.c890
-rw-r--r--xlators/performance/read-ahead/src/read-ahead.h194
-rw-r--r--xlators/performance/stat-prefetch/Makefile.am1
-rw-r--r--xlators/performance/stat-prefetch/src/Makefile.am11
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.c508
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.h32
-rw-r--r--xlators/performance/symlink-cache/Makefile.am3
-rw-r--r--xlators/performance/symlink-cache/src/Makefile.am12
-rw-r--r--xlators/performance/symlink-cache/src/symlink-cache.c399
-rw-r--r--xlators/performance/write-behind/Makefile.am3
-rw-r--r--xlators/performance/write-behind/src/Makefile.am12
-rw-r--r--xlators/performance/write-behind/src/write-behind.c1444
-rw-r--r--xlators/protocol/Makefile.am3
-rw-r--r--xlators/protocol/client/Makefile.am3
-rw-r--r--xlators/protocol/client/src/Makefile.am16
-rw-r--r--xlators/protocol/client/src/client-protocol.c6671
-rw-r--r--xlators/protocol/client/src/client-protocol.h173
-rw-r--r--xlators/protocol/client/src/saved-frames.c178
-rw-r--r--xlators/protocol/client/src/saved-frames.h74
-rw-r--r--xlators/protocol/server/Makefile.am3
-rw-r--r--xlators/protocol/server/src/Makefile.am18
-rw-r--r--xlators/protocol/server/src/server-dentry.c413
-rw-r--r--xlators/protocol/server/src/server-helpers.c586
-rw-r--r--xlators/protocol/server/src/server-helpers.h77
-rw-r--r--xlators/protocol/server/src/server-protocol.c7984
-rw-r--r--xlators/protocol/server/src/server-protocol.h143
-rw-r--r--xlators/storage/Makefile.am3
-rw-r--r--xlators/storage/bdb/Makefile.am3
-rw-r--r--xlators/storage/bdb/src/Makefile.am18
-rw-r--r--xlators/storage/bdb/src/bctx.c394
-rw-r--r--xlators/storage/bdb/src/bdb-ll.c1455
-rw-r--r--xlators/storage/bdb/src/bdb.c3371
-rw-r--r--xlators/storage/bdb/src/bdb.h439
-rw-r--r--xlators/storage/posix/Makefile.am3
-rw-r--r--xlators/storage/posix/src/Makefile.am17
-rw-r--r--xlators/storage/posix/src/posix.c3715
-rw-r--r--xlators/storage/posix/src/posix.h110
-rw-r--r--xlators/storage/posix/src/xattr-cache.c521
-rw-r--r--xlators/storage/posix/src/xattr-cache.h65
420 files changed, 164055 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..d9abdcd
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,3 @@
+CORE TEAM:
+* Please visit http://www.gluster.org/core-team.php for complete list
+ of contributors.
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..94a9ed0
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..800cdf3
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1 @@
+ChangeLog is maintained by "tla changelog".
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..88e2899
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,32 @@
+Installation Instructions
+*************************
+
+Run ./configure after untaring the package.
+
+ bash# ./configure
+ GlusterFS configure summary
+ ===========================
+ FUSE client : yes
+ Infiniband verbs : yes
+ epoll IO multiplex : yes
+ Berkeley-DB : yes
+ libglusterfsclient : yes
+ mod_glusterfs : yes
+ argp-standalone : no
+
+The configure summary will tell you what all components will be built with
+GlusterFS. Other than 'argp-standalone' if something else says 'no', that
+feature in GlusterFS will not be built. 'argp-standalone' package will only
+be used if the system doesn't have a proper argp package installed.
+
+Now just run 'make' and later run 'make install' to install the package.
+
+ bash# make
+ bash# make install
+
+Installation complete :-)
+
+ bash# glusterfs --version
+
+Make sure your version is the latest from the release, and the one you
+just installed :-)
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..6c7988a
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,15 @@
+EXTRA_DIST = autogen.sh COPYING INSTALL README AUTHORS THANKS NEWS glusterfs.spec
+
+SUBDIRS = argp-standalone libglusterfs $(LIBGLUSTERFSCLIENT_SUBDIR) xlators scheduler transport auth glusterfsd $(MOD_GLUSTERFS_SUBDIR) $(GF_BOOSTER_SUBDIR) doc extras
+
+CLEANFILES =
+
+tlaclean: distclean
+ find . -name Makefile.in -exec rm -f {} \;
+ find . -name Makefile -exec rm -f {} \;
+ find . -name mount.glusterfs -exec rm -f {} \;
+ rm -fr autom4te.cache
+ rm -f missing aclocal.m4 config.h.in config.guess config.sub ltmain.sh install-sh configure depcomp
+ rm -fr argp-standalone/autom4te.cache
+ rm -f argp-standalone/aclocal.m4 argp-standalone/config.h.in argp-standalone/configure argp-standalone/depcomp argp-standalone/install-sh argp-standalone/missing
+ rm -fr mod_glusterfs/apache-1.3/src/.deps transport/ib-verbs/src/.deps
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..39a37cd
--- /dev/null
+++ b/NEWS
@@ -0,0 +1 @@
+Please visit http://www.gluster.org/news.php for news updates.
diff --git a/README b/README
new file mode 100644
index 0000000..8c6cb42
--- /dev/null
+++ b/README
@@ -0,0 +1,9 @@
+GlusterFS is a powerful network/cluster filesystem. Posix compliant. You
+can keep scaling your storage beyond peta bytes as your demand increases.
+
+GlusterFS natively supports Infiniband verbs calls to do RDMA between remote
+machine to get the maximum I/O throughput.
+
+It has on the fly replication and striping as inbuilt options.
+
+Please visit http://www.gluster.org/glusterfs.php for more info.
diff --git a/THANKS b/THANKS
new file mode 100644
index 0000000..5e86b41
--- /dev/null
+++ b/THANKS
@@ -0,0 +1,3 @@
+
+* http://www.gluster.org/glusterfs-thanks.php
+
diff --git a/argp-standalone/Makefile.am b/argp-standalone/Makefile.am
new file mode 100644
index 0000000..4775d48
--- /dev/null
+++ b/argp-standalone/Makefile.am
@@ -0,0 +1,38 @@
+# From glibc
+
+# Copyright (C) 1997, 2003, 2004 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 Library General Public License as
+# published by the Free Software Foundation; either version 2 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 Library General Public
+# License along with the GNU C Library; see the file COPYING.LIB. If
+# not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+AUTOMAKE_OPTIONS = foreign
+SUBDIRS = .
+
+LIBOBJS = @LIBOBJS@
+
+noinst_LIBRARIES = libargp.a
+
+noinst_HEADERS = argp.h argp-fmtstream.h argp-namefrob.h
+
+EXTRA_DIST = mempcpy.c strchrnul.c strndup.c strcasecmp.c vsnprintf.c autogen.sh
+
+# Leaves out argp-fs-xinl.c and argp-xinl.c
+libargp_a_SOURCES = argp-ba.c argp-eexst.c argp-fmtstream.c \
+ argp-help.c argp-parse.c argp-pv.c \
+ argp-pvh.c
+
+libargp_a_LIBADD = $(LIBOBJS)
+
+
diff --git a/argp-standalone/acinclude.m4 b/argp-standalone/acinclude.m4
new file mode 100644
index 0000000..fb61e95
--- /dev/null
+++ b/argp-standalone/acinclude.m4
@@ -0,0 +1,1084 @@
+dnl Try to detect the type of the third arg to getsockname() et al
+AC_DEFUN([LSH_TYPE_SOCKLEN_T],
+[AH_TEMPLATE([socklen_t], [Length type used by getsockopt])
+AC_CACHE_CHECK([for socklen_t in sys/socket.h], ac_cv_type_socklen_t,
+[AC_EGREP_HEADER(socklen_t, sys/socket.h,
+ [ac_cv_type_socklen_t=yes], [ac_cv_type_socklen_t=no])])
+if test $ac_cv_type_socklen_t = no; then
+ AC_MSG_CHECKING(for AIX)
+ AC_EGREP_CPP(yes, [
+#ifdef _AIX
+ yes
+#endif
+],[
+AC_MSG_RESULT(yes)
+AC_DEFINE(socklen_t, size_t)
+],[
+AC_MSG_RESULT(no)
+AC_DEFINE(socklen_t, int)
+])
+fi
+])
+
+dnl Choose cc flags for compiling position independent code
+AC_DEFUN([LSH_CCPIC],
+[AC_MSG_CHECKING(CCPIC)
+AC_CACHE_VAL(lsh_cv_sys_ccpic,[
+ if test -z "$CCPIC" ; then
+ if test "$GCC" = yes ; then
+ case `uname -sr` in
+ BSD/OS*)
+ case `uname -r` in
+ 4.*) CCPIC="-fPIC";;
+ *) CCPIC="";;
+ esac
+ ;;
+ Darwin*)
+ CCPIC="-fPIC"
+ ;;
+ SunOS\ 5.*)
+ # Could also use -fPIC, if there are a large number of symbol reference
+ CCPIC="-fPIC"
+ ;;
+ CYGWIN*)
+ CCPIC=""
+ ;;
+ *)
+ CCPIC="-fpic"
+ ;;
+ esac
+ else
+ case `uname -sr` in
+ Darwin*)
+ CCPIC="-fPIC"
+ ;;
+ IRIX*)
+ CCPIC="-share"
+ ;;
+ hp*|HP*) CCPIC="+z"; ;;
+ FreeBSD*) CCPIC="-fpic";;
+ SCO_SV*) CCPIC="-KPIC -dy -Bdynamic";;
+ UnixWare*|OpenUNIX*) CCPIC="-KPIC -dy -Bdynamic";;
+ Solaris*) CCPIC="-KPIC -Bdynamic";;
+ Windows_NT*) CCPIC="-shared" ;;
+ esac
+ fi
+ fi
+ OLD_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $CCPIC"
+ AC_TRY_COMPILE([], [exit(0);],
+ lsh_cv_sys_ccpic="$CCPIC", lsh_cv_sys_ccpic='')
+ CFLAGS="$OLD_CFLAGS"
+])
+CCPIC="$lsh_cv_sys_ccpic"
+AC_MSG_RESULT($CCPIC)
+AC_SUBST([CCPIC])])
+
+dnl LSH_PATH_ADD(path-id, directory)
+AC_DEFUN([LSH_PATH_ADD],
+[AC_MSG_CHECKING($2)
+ac_exists=no
+if test -d "$2/." ; then
+ ac_real_dir=`cd $2 && pwd`
+ if test -n "$ac_real_dir" ; then
+ ac_exists=yes
+ for old in $1_REAL_DIRS ; do
+ ac_found=no
+ if test x$ac_real_dir = x$old ; then
+ ac_found=yes;
+ break;
+ fi
+ done
+ if test $ac_found = yes ; then
+ AC_MSG_RESULT(already added)
+ else
+ AC_MSG_RESULT(added)
+ # LDFLAGS="$LDFLAGS -L $2"
+ $1_REAL_DIRS="$ac_real_dir [$]$1_REAL_DIRS"
+ $1_DIRS="$2 [$]$1_DIRS"
+ fi
+ fi
+fi
+if test $ac_exists = no ; then
+ AC_MSG_RESULT(not found)
+fi
+])
+
+dnl LSH_RPATH_ADD(dir)
+AC_DEFUN([LSH_RPATH_ADD], [LSH_PATH_ADD(RPATH_CANDIDATE, $1)])
+
+dnl LSH_RPATH_INIT(candidates)
+AC_DEFUN([LSH_RPATH_INIT],
+[AC_MSG_CHECKING([for -R flag])
+RPATHFLAG=''
+case `uname -sr` in
+ OSF1\ V4.*)
+ RPATHFLAG="-rpath "
+ ;;
+ IRIX\ 6.*)
+ RPATHFLAG="-rpath "
+ ;;
+ IRIX\ 5.*)
+ RPATHFLAG="-rpath "
+ ;;
+ SunOS\ 5.*)
+ if test "$TCC" = "yes"; then
+ # tcc doesn't know about -R
+ RPATHFLAG="-Wl,-R,"
+ else
+ RPATHFLAG=-R
+ fi
+ ;;
+ Linux\ 2.*)
+ RPATHFLAG="-Wl,-rpath,"
+ ;;
+ *)
+ :
+ ;;
+esac
+
+if test x$RPATHFLAG = x ; then
+ AC_MSG_RESULT(none)
+else
+ AC_MSG_RESULT([using $RPATHFLAG])
+fi
+
+RPATH_CANDIDATE_REAL_DIRS=''
+RPATH_CANDIDATE_DIRS=''
+
+AC_MSG_RESULT([Searching for libraries])
+
+for d in $1 ; do
+ LSH_RPATH_ADD($d)
+done
+])
+
+dnl Try to execute a main program, and if it fails, try adding some
+dnl -R flag.
+dnl LSH_RPATH_FIX
+AC_DEFUN([LSH_RPATH_FIX],
+[if test $cross_compiling = no -a "x$RPATHFLAG" != x ; then
+ ac_success=no
+ AC_TRY_RUN([int main(int argc, char **argv) { return 0; }],
+ ac_success=yes, ac_success=no, :)
+
+ if test $ac_success = no ; then
+ AC_MSG_CHECKING([Running simple test program failed. Trying -R flags])
+dnl echo RPATH_CANDIDATE_DIRS = $RPATH_CANDIDATE_DIRS
+ ac_remaining_dirs=''
+ ac_rpath_save_LDFLAGS="$LDFLAGS"
+ for d in $RPATH_CANDIDATE_DIRS ; do
+ if test $ac_success = yes ; then
+ ac_remaining_dirs="$ac_remaining_dirs $d"
+ else
+ LDFLAGS="$RPATHFLAG$d $LDFLAGS"
+dnl echo LDFLAGS = $LDFLAGS
+ AC_TRY_RUN([int main(int argc, char **argv) { return 0; }],
+ [ac_success=yes
+ ac_rpath_save_LDFLAGS="$LDFLAGS"
+ AC_MSG_RESULT([adding $RPATHFLAG$d])
+ ],
+ [ac_remaining_dirs="$ac_remaining_dirs $d"], :)
+ LDFLAGS="$ac_rpath_save_LDFLAGS"
+ fi
+ done
+ RPATH_CANDIDATE_DIRS=$ac_remaining_dirs
+ fi
+ if test $ac_success = no ; then
+ AC_MSG_RESULT(failed)
+ fi
+fi
+])
+
+dnl Like AC_CHECK_LIB, but uses $KRB_LIBS rather than $LIBS.
+dnl LSH_CHECK_KRB_LIB(LIBRARY, FUNCTION, [, ACTION-IF-FOUND [,
+dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
+
+AC_DEFUN([LSH_CHECK_KRB_LIB],
+[AC_CHECK_LIB([$1], [$2],
+ ifelse([$3], ,
+ [[ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ AC_DEFINE_UNQUOTED($ac_tr_lib)
+ KRB_LIBS="-l$1 $KRB_LIBS"
+ ]], [$3]),
+ ifelse([$4], , , [$4
+])dnl
+, [$5 $KRB_LIBS])
+])
+
+dnl LSH_LIB_ARGP(ACTION-IF-OK, ACTION-IF-BAD)
+AC_DEFUN([LSH_LIB_ARGP],
+[ ac_argp_save_LIBS="$LIBS"
+ ac_argp_save_LDFLAGS="$LDFLAGS"
+ ac_argp_ok=no
+ # First check if we can link with argp.
+ AC_SEARCH_LIBS(argp_parse, argp,
+ [ LSH_RPATH_FIX
+ AC_CACHE_CHECK([for working argp],
+ lsh_cv_lib_argp_works,
+ [ AC_TRY_RUN(
+[#include <argp.h>
+#include <stdlib.h>
+
+static const struct argp_option
+options[] =
+{
+ { NULL, 0, NULL, 0, NULL, 0 }
+};
+
+struct child_state
+{
+ int n;
+};
+
+static error_t
+child_parser(int key, char *arg, struct argp_state *state)
+{
+ struct child_state *input = (struct child_state *) state->input;
+
+ switch(key)
+ {
+ default:
+ return ARGP_ERR_UNKNOWN;
+ case ARGP_KEY_END:
+ if (!input->n)
+ input->n = 1;
+ break;
+ }
+ return 0;
+}
+
+const struct argp child_argp =
+{
+ options,
+ child_parser,
+ NULL, NULL, NULL, NULL, NULL
+};
+
+struct main_state
+{
+ struct child_state child;
+ int m;
+};
+
+static error_t
+main_parser(int key, char *arg, struct argp_state *state)
+{
+ struct main_state *input = (struct main_state *) state->input;
+
+ switch(key)
+ {
+ default:
+ return ARGP_ERR_UNKNOWN;
+ case ARGP_KEY_INIT:
+ state->child_inputs[0] = &input->child;
+ break;
+ case ARGP_KEY_END:
+ if (!input->m)
+ input->m = input->child.n;
+
+ break;
+ }
+ return 0;
+}
+
+static const struct argp_child
+main_children[] =
+{
+ { &child_argp, 0, "", 0 },
+ { NULL, 0, NULL, 0}
+};
+
+static const struct argp
+main_argp =
+{ options, main_parser,
+ NULL,
+ NULL,
+ main_children,
+ NULL, NULL
+};
+
+int main(int argc, char **argv)
+{
+ struct main_state input = { { 0 }, 0 };
+ char *v[2] = { "foo", NULL };
+
+ argp_parse(&main_argp, 1, v, 0, NULL, &input);
+
+ if ( (input.m == 1) && (input.child.n == 1) )
+ return 0;
+ else
+ return 1;
+}
+], lsh_cv_lib_argp_works=yes,
+ lsh_cv_lib_argp_works=no,
+ lsh_cv_lib_argp_works=no)])
+
+ if test x$lsh_cv_lib_argp_works = xyes ; then
+ ac_argp_ok=yes
+ else
+ # Reset link flags
+ LIBS="$ac_argp_save_LIBS"
+ LDFLAGS="$ac_argp_save_LDFLAGS"
+ fi])
+
+ if test x$ac_argp_ok = xyes ; then
+ ifelse([$1],, true, [$1])
+ else
+ ifelse([$2],, true, [$2])
+ fi
+])
+
+dnl LSH_GCC_ATTRIBUTES
+dnl Check for gcc's __attribute__ construction
+
+AC_DEFUN([LSH_GCC_ATTRIBUTES],
+[AC_CACHE_CHECK(for __attribute__,
+ lsh_cv_c_attribute,
+[ AC_TRY_COMPILE([
+#include <stdlib.h>
+],
+[
+static void foo(void) __attribute__ ((noreturn));
+
+static void __attribute__ ((noreturn))
+foo(void)
+{
+ exit(1);
+}
+],
+lsh_cv_c_attribute=yes,
+lsh_cv_c_attribute=no)])
+
+AH_TEMPLATE([HAVE_GCC_ATTRIBUTE], [Define if the compiler understands __attribute__])
+if test "x$lsh_cv_c_attribute" = "xyes"; then
+ AC_DEFINE(HAVE_GCC_ATTRIBUTE)
+fi
+
+AH_BOTTOM(
+[#if __GNUC__ || HAVE_GCC_ATTRIBUTE
+# define NORETURN __attribute__ ((__noreturn__))
+# define PRINTF_STYLE(f, a) __attribute__ ((__format__ (__printf__, f, a)))
+# define UNUSED __attribute__ ((__unused__))
+#else
+# define NORETURN
+# define PRINTF_STYLE(f, a)
+# define UNUSED
+#endif
+])])
+
+AC_DEFUN([LSH_GCC_FUNCTION_NAME],
+[# Check for gcc's __FUNCTION__ variable
+AH_TEMPLATE([HAVE_GCC_FUNCTION],
+ [Define if the compiler understands __FUNCTION__])
+AH_BOTTOM(
+[#if HAVE_GCC_FUNCTION
+# define FUNCTION_NAME __FUNCTION__
+#else
+# define FUNCTION_NAME "Unknown"
+#endif
+])
+
+AC_CACHE_CHECK(for __FUNCTION__,
+ lsh_cv_c_FUNCTION,
+ [ AC_TRY_COMPILE(,
+ [ #if __GNUC__ == 3
+ # error __FUNCTION__ is broken in gcc-3
+ #endif
+ void foo(void) { char c = __FUNCTION__[0]; } ],
+ lsh_cv_c_FUNCTION=yes,
+ lsh_cv_c_FUNCTION=no)])
+
+if test "x$lsh_cv_c_FUNCTION" = "xyes"; then
+ AC_DEFINE(HAVE_GCC_FUNCTION)
+fi
+])
+
+# Check for alloca, and include the standard blurb in config.h
+AC_DEFUN([LSH_FUNC_ALLOCA],
+[AC_FUNC_ALLOCA
+AC_CHECK_HEADERS([malloc.h])
+AH_BOTTOM(
+[/* 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
+#else /* defined __GNUC__ */
+# if HAVE_ALLOCA_H
+# include <alloca.h>
+# endif
+#endif
+/* Needed for alloca on windows */
+#if HAVE_MALLOC_H
+# include <malloc.h>
+#endif
+])])
+
+AC_DEFUN([LSH_FUNC_STRERROR],
+[AC_CHECK_FUNCS(strerror)
+AH_BOTTOM(
+[#if HAVE_STRERROR
+#define STRERROR strerror
+#else
+#define STRERROR(x) (sys_errlist[x])
+#endif
+])])
+
+AC_DEFUN([LSH_FUNC_STRSIGNAL],
+[AC_CHECK_FUNCS(strsignal)
+AC_CHECK_DECLS([sys_siglist, _sys_siglist])
+AH_BOTTOM(
+[#if HAVE_STRSIGNAL
+# define STRSIGNAL strsignal
+#else /* !HAVE_STRSIGNAL */
+# if HAVE_DECL_SYS_SIGLIST
+# define STRSIGNAL(x) (sys_siglist[x])
+# else
+# if HAVE_DECL__SYS_SIGLIST
+# define STRSIGNAL(x) (_sys_siglist[x])
+# else
+# define STRSIGNAL(x) "Unknown signal"
+# if __GNUC__
+# warning Using dummy STRSIGNAL
+# endif
+# endif
+# endif
+#endif /* !HAVE_STRSIGNAL */
+])])
+
+dnl LSH_MAKE_CONDITIONAL(symbol, test)
+AC_DEFUN([LSH_MAKE_CONDITIONAL],
+[if $2 ; then
+ IF_$1=''
+ UNLESS_$1='# '
+else
+ IF_$1='# '
+ UNLESS_$1=''
+fi
+AC_SUBST(IF_$1)
+AC_SUBST(UNLESS_$1)])
+
+dnl LSH_DEPENDENCY_TRACKING
+
+dnl Defines compiler flags DEP_FLAGS to generate dependency
+dnl information, and DEP_PROCESS that is any shell commands needed for
+dnl massaging the dependency information further. Dependencies are
+dnl generated as a side effect of compilation. Dependency files
+dnl themselves are not treated as targets.
+
+AC_DEFUN([LSH_DEPENDENCY_TRACKING],
+[AC_ARG_ENABLE(dependency_tracking,
+ AC_HELP_STRING([--disable-dependency-tracking],
+ [Disable dependency tracking. Dependency tracking doesn't work with BSD make]),,
+ [enable_dependency_tracking=yes])
+
+DEP_FLAGS=''
+DEP_PROCESS='true'
+if test x$enable_dependency_tracking = xyes ; then
+ if test x$GCC = xyes ; then
+ gcc_version=`gcc --version | head -1`
+ case "$gcc_version" in
+ 2.*|*[[!0-9.]]2.*)
+ enable_dependency_tracking=no
+ AC_MSG_WARN([Dependency tracking disabled, gcc-3.x is needed])
+ ;;
+ *)
+ DEP_FLAGS='-MT $[]@ -MD -MP -MF $[]@.d'
+ DEP_PROCESS='true'
+ ;;
+ esac
+ else
+ enable_dependency_tracking=no
+ AC_MSG_WARN([Dependency tracking disabled])
+ fi
+fi
+
+if test x$enable_dependency_tracking = xyes ; then
+ DEP_INCLUDE='include '
+else
+ DEP_INCLUDE='# '
+fi
+
+AC_SUBST([DEP_INCLUDE])
+AC_SUBST([DEP_FLAGS])
+AC_SUBST([DEP_PROCESS])])
+
+dnl @synopsis AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEADERS-TO-CHECK])]
+dnl
+dnl the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
+dnl existence of an include file <stdint.h> that defines a set of
+dnl typedefs, especially uint8_t,int32_t,uintptr_t.
+dnl Many older installations will not provide this file, but some will
+dnl have the very same definitions in <inttypes.h>. In other enviroments
+dnl we can use the inet-types in <sys/types.h> which would define the
+dnl typedefs int8_t and u_int8_t respectivly.
+dnl
+dnl This macros will create a local "_stdint.h" or the headerfile given as
+dnl an argument. In many cases that file will just "#include <stdint.h>"
+dnl or "#include <inttypes.h>", while in other environments it will provide
+dnl the set of basic 'stdint's definitions/typedefs:
+dnl int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t
+dnl int_least32_t.. int_fast32_t.. intmax_t
+dnl which may or may not rely on the definitions of other files,
+dnl or using the AC_CHECK_SIZEOF macro to determine the actual
+dnl sizeof each type.
+dnl
+dnl if your header files require the stdint-types you will want to create an
+dnl installable file mylib-int.h that all your other installable header
+dnl may include. So if you have a library package named "mylib", just use
+dnl AX_CREATE_STDINT_H(mylib-int.h)
+dnl in configure.ac and go to install that very header file in Makefile.am
+dnl along with the other headers (mylib.h) - and the mylib-specific headers
+dnl can simply use "#include <mylib-int.h>" to obtain the stdint-types.
+dnl
+dnl Remember, if the system already had a valid <stdint.h>, the generated
+dnl file will include it directly. No need for fuzzy HAVE_STDINT_H things...
+dnl
+dnl @, (status: used on new platforms) (see http://ac-archive.sf.net/gstdint/)
+dnl @version $Id: acinclude.m4,v 1.27 2004/11/23 21:27:35 nisse Exp $
+dnl @author Guido Draheim <guidod@gmx.de>
+
+AC_DEFUN([AX_CREATE_STDINT_H],
+[# ------ AX CREATE STDINT H -------------------------------------
+AC_MSG_CHECKING([for stdint types])
+ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`
+# try to shortcircuit - if the default include path of the compiler
+# can find a "stdint.h" header then we assume that all compilers can.
+AC_CACHE_VAL([ac_cv_header_stdint_t],[
+old_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS=""
+old_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS=""
+old_CFLAGS="$CFLAGS" ; CFLAGS=""
+AC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;],
+[ac_cv_stdint_result="(assuming C99 compatible system)"
+ ac_cv_header_stdint_t="stdint.h"; ],
+[ac_cv_header_stdint_t=""])
+CXXFLAGS="$old_CXXFLAGS"
+CPPFLAGS="$old_CPPFLAGS"
+CFLAGS="$old_CFLAGS" ])
+
+v="... $ac_cv_header_stdint_h"
+if test "$ac_stdint_h" = "stdint.h" ; then
+ AC_MSG_RESULT([(are you sure you want them in ./stdint.h?)])
+elif test "$ac_stdint_h" = "inttypes.h" ; then
+ AC_MSG_RESULT([(are you sure you want them in ./inttypes.h?)])
+elif test "_$ac_cv_header_stdint_t" = "_" ; then
+ AC_MSG_RESULT([(putting them into $ac_stdint_h)$v])
+else
+ ac_cv_header_stdint="$ac_cv_header_stdint_t"
+ AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)])
+fi
+
+if test "_$ac_cv_header_stdint_t" = "_" ; then # can not shortcircuit..
+
+dnl .....intro message done, now do a few system checks.....
+dnl btw, all CHECK_TYPE macros do automatically "DEFINE" a type, therefore
+dnl we use the autoconf implementation detail _AC CHECK_TYPE_NEW instead
+
+inttype_headers=`echo $2 | sed -e 's/,/ /g'`
+
+ac_cv_stdint_result="(no helpful system typedefs seen)"
+AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[
+ ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h)
+ AC_MSG_RESULT([(..)])
+ for i in stdint.h inttypes.h sys/inttypes.h $inttype_headers ; do
+ unset ac_cv_type_uintptr_t
+ unset ac_cv_type_uint64_t
+ _AC_CHECK_TYPE_NEW(uintptr_t,[ac_cv_header_stdint_x=$i],dnl
+ continue,[#include <$i>])
+ AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
+ ac_cv_stdint_result="(seen uintptr_t$and64 in $i)"
+ break;
+ done
+ AC_MSG_CHECKING([for stdint uintptr_t])
+ ])
+
+if test "_$ac_cv_header_stdint_x" = "_" ; then
+AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[
+ ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h)
+ AC_MSG_RESULT([(..)])
+ for i in inttypes.h sys/inttypes.h stdint.h $inttype_headers ; do
+ unset ac_cv_type_uint32_t
+ unset ac_cv_type_uint64_t
+ AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],dnl
+ continue,[#include <$i>])
+ AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
+ ac_cv_stdint_result="(seen uint32_t$and64 in $i)"
+ break;
+ done
+ AC_MSG_CHECKING([for stdint uint32_t])
+ ])
+fi
+
+if test "_$ac_cv_header_stdint_x" = "_" ; then
+if test "_$ac_cv_header_stdint_o" = "_" ; then
+AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[
+ ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h)
+ AC_MSG_RESULT([(..)])
+ for i in sys/types.h inttypes.h sys/inttypes.h $inttype_headers ; do
+ unset ac_cv_type_u_int32_t
+ unset ac_cv_type_u_int64_t
+ AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],dnl
+ continue,[#include <$i>])
+ AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>])
+ ac_cv_stdint_result="(seen u_int32_t$and64 in $i)"
+ break;
+ done
+ AC_MSG_CHECKING([for stdint u_int32_t])
+ ])
+fi fi
+
+dnl if there was no good C99 header file, do some typedef checks...
+if test "_$ac_cv_header_stdint_x" = "_" ; then
+ AC_MSG_CHECKING([for stdint datatype model])
+ AC_MSG_RESULT([(..)])
+ AC_CHECK_SIZEOF(char)
+ AC_CHECK_SIZEOF(short)
+ AC_CHECK_SIZEOF(int)
+ AC_CHECK_SIZEOF(long)
+ AC_CHECK_SIZEOF(void*)
+ ac_cv_stdint_char_model=""
+ ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_char"
+ ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_short"
+ ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_int"
+ ac_cv_stdint_long_model=""
+ ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_int"
+ ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_long"
+ ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_voidp"
+ name="$ac_cv_stdint_long_model"
+ case "$ac_cv_stdint_char_model/$ac_cv_stdint_long_model" in
+ 122/242) name="$name, IP16 (standard 16bit machine)" ;;
+ 122/244) name="$name, LP32 (standard 32bit mac/win)" ;;
+ 122/*) name="$name (unusual int16 model)" ;;
+ 124/444) name="$name, ILP32 (standard 32bit unixish)" ;;
+ 124/488) name="$name, LP64 (standard 64bit unixish)" ;;
+ 124/448) name="$name, LLP64 (unusual 64bit unixish)" ;;
+ 124/*) name="$name (unusual int32 model)" ;;
+ 128/888) name="$name, ILP64 (unusual 64bit numeric)" ;;
+ 128/*) name="$name (unusual int64 model)" ;;
+ 222/*|444/*) name="$name (unusual dsptype)" ;;
+ *) name="$name (very unusal model)" ;;
+ esac
+ AC_MSG_RESULT([combined for stdint datatype model... $name])
+fi
+
+if test "_$ac_cv_header_stdint_x" != "_" ; then
+ ac_cv_header_stdint="$ac_cv_header_stdint_x"
+elif test "_$ac_cv_header_stdint_o" != "_" ; then
+ ac_cv_header_stdint="$ac_cv_header_stdint_o"
+elif test "_$ac_cv_header_stdint_u" != "_" ; then
+ ac_cv_header_stdint="$ac_cv_header_stdint_u"
+else
+ ac_cv_header_stdint="stddef.h"
+fi
+
+AC_MSG_CHECKING([for extra inttypes in chosen header])
+AC_MSG_RESULT([($ac_cv_header_stdint)])
+dnl see if int_least and int_fast types are present in _this_ header.
+unset ac_cv_type_int_least32_t
+unset ac_cv_type_int_fast32_t
+AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])
+AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])
+AC_CHECK_TYPE(intmax_t,,,[#include <$ac_cv_header_stdint>])
+
+fi # shortcircut to system "stdint.h"
+# ------------------ PREPARE VARIABLES ------------------------------
+if test "$GCC" = "yes" ; then
+ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1`
+else
+ac_cv_stdint_message="using $CC"
+fi
+
+AC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl
+$ac_cv_stdint_result])
+
+# ----------------- DONE inttypes.h checks START header -------------
+AC_CONFIG_COMMANDS([$ac_stdint_h],[
+AC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h)
+ac_stdint=$tmp/_stdint.h
+
+echo "#ifndef" $_ac_stdint_h >$ac_stdint
+echo "#define" $_ac_stdint_h "1" >>$ac_stdint
+echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint
+echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint
+echo "/* generated $ac_cv_stdint_message */" >>$ac_stdint
+if test "_$ac_cv_header_stdint_t" != "_" ; then
+echo "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint
+fi
+
+cat >>$ac_stdint <<STDINT_EOF
+
+/* ................... shortcircuit part ........................... */
+
+#if defined HAVE_STDINT_H || defined _STDINT_HAVE_STDINT_H
+#include <stdint.h>
+#else
+#include <stddef.h>
+
+/* .................... configured part ............................ */
+
+STDINT_EOF
+
+echo "/* whether we have a C99 compatible stdint header file */" >>$ac_stdint
+if test "_$ac_cv_header_stdint_x" != "_" ; then
+ ac_header="$ac_cv_header_stdint_x"
+ echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdint
+else
+ echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint
+fi
+
+echo "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdint
+if test "_$ac_cv_header_stdint_o" != "_" ; then
+ ac_header="$ac_cv_header_stdint_o"
+ echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdint
+else
+ echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint
+fi
+
+echo "/* whether we have a BSD compatible inet types header */" >>$ac_stdint
+if test "_$ac_cv_header_stdint_u" != "_" ; then
+ ac_header="$ac_cv_header_stdint_u"
+ echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdint
+else
+ echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint
+fi
+
+echo "" >>$ac_stdint
+
+if test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then
+ echo "#include <$ac_header>" >>$ac_stdint
+ echo "" >>$ac_stdint
+fi fi
+
+echo "/* which 64bit typedef has been found */" >>$ac_stdint
+if test "$ac_cv_type_uint64_t" = "yes" ; then
+echo "#define _STDINT_HAVE_UINT64_T" "1" >>$ac_stdint
+else
+echo "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint
+fi
+if test "$ac_cv_type_u_int64_t" = "yes" ; then
+echo "#define _STDINT_HAVE_U_INT64_T" "1" >>$ac_stdint
+else
+echo "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint
+fi
+echo "" >>$ac_stdint
+
+echo "/* which type model has been detected */" >>$ac_stdint
+if test "_$ac_cv_stdint_char_model" != "_" ; then
+echo "#define _STDINT_CHAR_MODEL" "$ac_cv_stdint_char_model" >>$ac_stdint
+echo "#define _STDINT_LONG_MODEL" "$ac_cv_stdint_long_model" >>$ac_stdint
+else
+echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint
+echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint
+fi
+echo "" >>$ac_stdint
+
+echo "/* whether int_least types were detected */" >>$ac_stdint
+if test "$ac_cv_type_int_least32_t" = "yes"; then
+echo "#define _STDINT_HAVE_INT_LEAST32_T" "1" >>$ac_stdint
+else
+echo "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint
+fi
+echo "/* whether int_fast types were detected */" >>$ac_stdint
+if test "$ac_cv_type_int_fast32_t" = "yes"; then
+echo "#define _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdint
+else
+echo "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint
+fi
+echo "/* whether intmax_t type was detected */" >>$ac_stdint
+if test "$ac_cv_type_intmax_t" = "yes"; then
+echo "#define _STDINT_HAVE_INTMAX_T" "1" >>$ac_stdint
+else
+echo "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint
+fi
+echo "" >>$ac_stdint
+
+ cat >>$ac_stdint <<STDINT_EOF
+/* .................... detections part ............................ */
+
+/* whether we need to define bitspecific types from compiler base types */
+#ifndef _STDINT_HEADER_INTPTR
+#ifndef _STDINT_HEADER_UINT32
+#ifndef _STDINT_HEADER_U_INT32
+#define _STDINT_NEED_INT_MODEL_T
+#else
+#define _STDINT_HAVE_U_INT_TYPES
+#endif
+#endif
+#endif
+
+#ifdef _STDINT_HAVE_U_INT_TYPES
+#undef _STDINT_NEED_INT_MODEL_T
+#endif
+
+#ifdef _STDINT_CHAR_MODEL
+#if _STDINT_CHAR_MODEL+0 == 122 || _STDINT_CHAR_MODEL+0 == 124
+#ifndef _STDINT_BYTE_MODEL
+#define _STDINT_BYTE_MODEL 12
+#endif
+#endif
+#endif
+
+#ifndef _STDINT_HAVE_INT_LEAST32_T
+#define _STDINT_NEED_INT_LEAST_T
+#endif
+
+#ifndef _STDINT_HAVE_INT_FAST32_T
+#define _STDINT_NEED_INT_FAST_T
+#endif
+
+#ifndef _STDINT_HEADER_INTPTR
+#define _STDINT_NEED_INTPTR_T
+#ifndef _STDINT_HAVE_INTMAX_T
+#define _STDINT_NEED_INTMAX_T
+#endif
+#endif
+
+
+/* .................... definition part ............................ */
+
+/* some system headers have good uint64_t */
+#ifndef _HAVE_UINT64_T
+#if defined _STDINT_HAVE_UINT64_T || defined HAVE_UINT64_T
+#define _HAVE_UINT64_T
+#elif defined _STDINT_HAVE_U_INT64_T || defined HAVE_U_INT64_T
+#define _HAVE_UINT64_T
+typedef u_int64_t uint64_t;
+#endif
+#endif
+
+#ifndef _HAVE_UINT64_T
+/* .. here are some common heuristics using compiler runtime specifics */
+#if defined __STDC_VERSION__ && defined __STDC_VERSION__ >= 199901L
+#define _HAVE_UINT64_T
+typedef long long int64_t;
+typedef unsigned long long uint64_t;
+
+#elif !defined __STRICT_ANSI__
+#if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
+#define _HAVE_UINT64_T
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+
+#elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__
+/* note: all ELF-systems seem to have loff-support which needs 64-bit */
+#if !defined _NO_LONGLONG
+#define _HAVE_UINT64_T
+typedef long long int64_t;
+typedef unsigned long long uint64_t;
+#endif
+
+#elif defined __alpha || (defined __mips && defined _ABIN32)
+#if !defined _NO_LONGLONG
+typedef long int64_t;
+typedef unsigned long uint64_t;
+#endif
+ /* compiler/cpu type to define int64_t */
+#endif
+#endif
+#endif
+
+#if defined _STDINT_HAVE_U_INT_TYPES
+/* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */
+typedef u_int8_t uint8_t;
+typedef u_int16_t uint16_t;
+typedef u_int32_t uint32_t;
+
+/* glibc compatibility */
+#ifndef __int8_t_defined
+#define __int8_t_defined
+#endif
+#endif
+
+#ifdef _STDINT_NEED_INT_MODEL_T
+/* we must guess all the basic types. Apart from byte-adressable system, */
+/* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */
+/* (btw, those nibble-addressable systems are way off, or so we assume) */
+
+dnl /* have a look at "64bit and data size neutrality" at */
+dnl /* http://unix.org/version2/whatsnew/login_64bit.html */
+dnl /* (the shorthand "ILP" types always have a "P" part) */
+
+#if defined _STDINT_BYTE_MODEL
+#if _STDINT_LONG_MODEL+0 == 242
+/* 2:4:2 = IP16 = a normal 16-bit system */
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned long uint32_t;
+#ifndef __int8_t_defined
+#define __int8_t_defined
+typedef char int8_t;
+typedef short int16_t;
+typedef long int32_t;
+#endif
+#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444
+/* 2:4:4 = LP32 = a 32-bit system derived from a 16-bit */
+/* 4:4:4 = ILP32 = a normal 32-bit system */
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+#ifndef __int8_t_defined
+#define __int8_t_defined
+typedef char int8_t;
+typedef short int16_t;
+typedef int int32_t;
+#endif
+#elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488
+/* 4:8:4 = IP32 = a 32-bit system prepared for 64-bit */
+/* 4:8:8 = LP64 = a normal 64-bit system */
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+#ifndef __int8_t_defined
+#define __int8_t_defined
+typedef char int8_t;
+typedef short int16_t;
+typedef int int32_t;
+#endif
+/* this system has a "long" of 64bit */
+#ifndef _HAVE_UINT64_T
+#define _HAVE_UINT64_T
+typedef unsigned long uint64_t;
+typedef long int64_t;
+#endif
+#elif _STDINT_LONG_MODEL+0 == 448
+/* LLP64 a 64-bit system derived from a 32-bit system */
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+#ifndef __int8_t_defined
+#define __int8_t_defined
+typedef char int8_t;
+typedef short int16_t;
+typedef int int32_t;
+#endif
+/* assuming the system has a "long long" */
+#ifndef _HAVE_UINT64_T
+#define _HAVE_UINT64_T
+typedef unsigned long long uint64_t;
+typedef long long int64_t;
+#endif
+#else
+#define _STDINT_NO_INT32_T
+#endif
+#else
+#define _STDINT_NO_INT8_T
+#define _STDINT_NO_INT32_T
+#endif
+#endif
+
+/*
+ * quote from SunOS-5.8 sys/inttypes.h:
+ * Use at your own risk. As of February 1996, the committee is squarely
+ * behind the fixed sized types; the "least" and "fast" types are still being
+ * discussed. The probability that the "fast" types may be removed before
+ * the standard is finalized is high enough that they are not currently
+ * implemented.
+ */
+
+#if defined _STDINT_NEED_INT_LEAST_T
+typedef int8_t int_least8_t;
+typedef int16_t int_least16_t;
+typedef int32_t int_least32_t;
+#ifdef _HAVE_UINT64_T
+typedef int64_t int_least64_t;
+#endif
+
+typedef uint8_t uint_least8_t;
+typedef uint16_t uint_least16_t;
+typedef uint32_t uint_least32_t;
+#ifdef _HAVE_UINT64_T
+typedef uint64_t uint_least64_t;
+#endif
+ /* least types */
+#endif
+
+#if defined _STDINT_NEED_INT_FAST_T
+typedef int8_t int_fast8_t;
+typedef int int_fast16_t;
+typedef int32_t int_fast32_t;
+#ifdef _HAVE_UINT64_T
+typedef int64_t int_fast64_t;
+#endif
+
+typedef uint8_t uint_fast8_t;
+typedef unsigned uint_fast16_t;
+typedef uint32_t uint_fast32_t;
+#ifdef _HAVE_UINT64_T
+typedef uint64_t uint_fast64_t;
+#endif
+ /* fast types */
+#endif
+
+#ifdef _STDINT_NEED_INTMAX_T
+#ifdef _HAVE_UINT64_T
+typedef int64_t intmax_t;
+typedef uint64_t uintmax_t;
+#else
+typedef long intmax_t;
+typedef unsigned long uintmax_t;
+#endif
+#endif
+
+#ifdef _STDINT_NEED_INTPTR_T
+#ifndef __intptr_t_defined
+#define __intptr_t_defined
+/* we encourage using "long" to store pointer values, never use "int" ! */
+#if _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484
+typedef unsinged int uintptr_t;
+typedef int intptr_t;
+#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444
+typedef unsigned long uintptr_t;
+typedef long intptr_t;
+#elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T
+typedef uint64_t uintptr_t;
+typedef int64_t intptr_t;
+#else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */
+typedef unsigned long uintptr_t;
+typedef long intptr_t;
+#endif
+#endif
+#endif
+
+ /* shortcircuit*/
+#endif
+ /* once */
+#endif
+#endif
+STDINT_EOF
+ if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then
+ AC_MSG_NOTICE([$ac_stdint_h is unchanged])
+ else
+ ac_dir=`AS_DIRNAME(["$ac_stdint_h"])`
+ AS_MKDIR_P(["$ac_dir"])
+ rm -f $ac_stdint_h
+ mv $ac_stdint $ac_stdint_h
+ fi
+],[# variables for create stdint.h replacement
+PACKAGE="$PACKAGE"
+VERSION="$VERSION"
+ac_stdint_h="$ac_stdint_h"
+_ac_stdint_h=AS_TR_CPP(_$PACKAGE-$ac_stdint_h)
+ac_cv_stdint_message="$ac_cv_stdint_message"
+ac_cv_header_stdint_t="$ac_cv_header_stdint_t"
+ac_cv_header_stdint_x="$ac_cv_header_stdint_x"
+ac_cv_header_stdint_o="$ac_cv_header_stdint_o"
+ac_cv_header_stdint_u="$ac_cv_header_stdint_u"
+ac_cv_type_uint64_t="$ac_cv_type_uint64_t"
+ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t"
+ac_cv_stdint_char_model="$ac_cv_stdint_char_model"
+ac_cv_stdint_long_model="$ac_cv_stdint_long_model"
+ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t"
+ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t"
+ac_cv_type_intmax_t="$ac_cv_type_intmax_t"
+])
+])
diff --git a/argp-standalone/argp-ba.c b/argp-standalone/argp-ba.c
new file mode 100644
index 0000000..0d3958c
--- /dev/null
+++ b/argp-standalone/argp-ba.c
@@ -0,0 +1,26 @@
+/* Default definition for ARGP_PROGRAM_BUG_ADDRESS.
+ Copyright (C) 1996, 1997, 1999, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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 Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* If set by the user program, it should point to string that is the
+ bug-reporting address for the program. It will be printed by argp_help if
+ the ARGP_HELP_BUG_ADDR flag is set (as it is by various standard help
+ messages), embedded in a sentence that says something like `Report bugs to
+ ADDR.'. */
+const char *argp_program_bug_address = 0;
diff --git a/argp-standalone/argp-eexst.c b/argp-standalone/argp-eexst.c
new file mode 100644
index 0000000..46b2784
--- /dev/null
+++ b/argp-standalone/argp-eexst.c
@@ -0,0 +1,36 @@
+/* Default definition for ARGP_ERR_EXIT_STATUS
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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 Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if HAVE_SYSEXITS_H
+# include <sysexits.h>
+#else
+# define EX_USAGE 64
+#endif
+
+#include "argp.h"
+
+/* The exit status that argp will use when exiting due to a parsing error.
+ If not defined or set by the user program, this defaults to EX_USAGE from
+ <sysexits.h>. */
+error_t argp_err_exit_status = EX_USAGE;
diff --git a/argp-standalone/argp-fmtstream.c b/argp-standalone/argp-fmtstream.c
new file mode 100644
index 0000000..7f79285
--- /dev/null
+++ b/argp-standalone/argp-fmtstream.c
@@ -0,0 +1,475 @@
+/* Word-wrapping and line-truncating streams
+ Copyright (C) 1997, 1998, 1999, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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 Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* This package emulates glibc `line_wrap_stream' semantics for systems that
+ don't have that. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <ctype.h>
+
+#include "argp-fmtstream.h"
+#include "argp-namefrob.h"
+
+#ifndef ARGP_FMTSTREAM_USE_LINEWRAP
+
+#ifndef isblank
+#define isblank(ch) ((ch)==' ' || (ch)=='\t')
+#endif
+
+#if defined _LIBC && defined USE_IN_LIBIO
+# include <libio/libioP.h>
+# define __vsnprintf(s, l, f, a) _IO_vsnprintf (s, l, f, a)
+#endif
+
+#define INIT_BUF_SIZE 200
+#define PRINTF_SIZE_GUESS 150
+
+/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
+ written on it with LMARGIN spaces and limits them to RMARGIN columns
+ total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
+ replacing the whitespace before them with a newline and WMARGIN spaces.
+ Otherwise, chars beyond RMARGIN are simply dropped until a newline.
+ Returns NULL if there was an error. */
+argp_fmtstream_t
+__argp_make_fmtstream (FILE *stream,
+ size_t lmargin, size_t rmargin, ssize_t wmargin)
+{
+ argp_fmtstream_t fs = malloc (sizeof (struct argp_fmtstream));
+ if (fs)
+ {
+ fs->stream = stream;
+
+ fs->lmargin = lmargin;
+ fs->rmargin = rmargin;
+ fs->wmargin = wmargin;
+ fs->point_col = 0;
+ fs->point_offs = 0;
+
+ fs->buf = malloc (INIT_BUF_SIZE);
+ if (! fs->buf)
+ {
+ free (fs);
+ fs = 0;
+ }
+ else
+ {
+ fs->p = fs->buf;
+ fs->end = fs->buf + INIT_BUF_SIZE;
+ }
+ }
+
+ return fs;
+}
+#ifdef weak_alias
+weak_alias (__argp_make_fmtstream, argp_make_fmtstream)
+#endif
+
+/* Flush FS to its stream, and free it (but don't close the stream). */
+void
+__argp_fmtstream_free (argp_fmtstream_t fs)
+{
+ __argp_fmtstream_update (fs);
+ if (fs->p > fs->buf)
+ FWRITE_UNLOCKED (fs->buf, 1, fs->p - fs->buf, fs->stream);
+ free (fs->buf);
+ free (fs);
+}
+#ifdef weak_alias
+weak_alias (__argp_fmtstream_free, argp_fmtstream_free)
+#endif
+
+/* Process FS's buffer so that line wrapping is done from POINT_OFFS to the
+ end of its buffer. This code is mostly from glibc stdio/linewrap.c. */
+void
+__argp_fmtstream_update (argp_fmtstream_t fs)
+{
+ char *buf, *nl;
+ size_t len;
+
+ /* Scan the buffer for newlines. */
+ buf = fs->buf + fs->point_offs;
+ while (buf < fs->p)
+ {
+ size_t r;
+
+ if (fs->point_col == 0 && fs->lmargin != 0)
+ {
+ /* We are starting a new line. Print spaces to the left margin. */
+ const size_t pad = fs->lmargin;
+ if (fs->p + pad < fs->end)
+ {
+ /* We can fit in them in the buffer by moving the
+ buffer text up and filling in the beginning. */
+ memmove (buf + pad, buf, fs->p - buf);
+ fs->p += pad; /* Compensate for bigger buffer. */
+ memset (buf, ' ', pad); /* Fill in the spaces. */
+ buf += pad; /* Don't bother searching them. */
+ }
+ else
+ {
+ /* No buffer space for spaces. Must flush. */
+ size_t i;
+ for (i = 0; i < pad; i++)
+ PUTC_UNLOCKED (' ', fs->stream);
+ }
+ fs->point_col = pad;
+ }
+
+ len = fs->p - buf;
+ nl = memchr (buf, '\n', len);
+
+ if (fs->point_col < 0)
+ fs->point_col = 0;
+
+ if (!nl)
+ {
+ /* The buffer ends in a partial line. */
+
+ if (fs->point_col + len < fs->rmargin)
+ {
+ /* The remaining buffer text is a partial line and fits
+ within the maximum line width. Advance point for the
+ characters to be written and stop scanning. */
+ fs->point_col += len;
+ break;
+ }
+ else
+ /* Set the end-of-line pointer for the code below to
+ the end of the buffer. */
+ nl = fs->p;
+ }
+ else if (fs->point_col + (nl - buf) < (ssize_t) fs->rmargin)
+ {
+ /* The buffer contains a full line that fits within the maximum
+ line width. Reset point and scan the next line. */
+ fs->point_col = 0;
+ buf = nl + 1;
+ continue;
+ }
+
+ /* This line is too long. */
+ r = fs->rmargin - 1;
+
+ if (fs->wmargin < 0)
+ {
+ /* Truncate the line by overwriting the excess with the
+ newline and anything after it in the buffer. */
+ if (nl < fs->p)
+ {
+ memmove (buf + (r - fs->point_col), nl, fs->p - nl);
+ fs->p -= buf + (r - fs->point_col) - nl;
+ /* Reset point for the next line and start scanning it. */
+ fs->point_col = 0;
+ buf += r + 1; /* Skip full line plus \n. */
+ }
+ else
+ {
+ /* The buffer ends with a partial line that is beyond the
+ maximum line width. Advance point for the characters
+ written, and discard those past the max from the buffer. */
+ fs->point_col += len;
+ fs->p -= fs->point_col - r;
+ break;
+ }
+ }
+ else
+ {
+ /* Do word wrap. Go to the column just past the maximum line
+ width and scan back for the beginning of the word there.
+ Then insert a line break. */
+
+ char *p, *nextline;
+ int i;
+
+ p = buf + (r + 1 - fs->point_col);
+ while (p >= buf && !isblank (*p))
+ --p;
+ nextline = p + 1; /* This will begin the next line. */
+
+ if (nextline > buf)
+ {
+ /* Swallow separating blanks. */
+ if (p >= buf)
+ do
+ --p;
+ while (p >= buf && isblank (*p));
+ nl = p + 1; /* The newline will replace the first blank. */
+ }
+ else
+ {
+ /* A single word that is greater than the maximum line width.
+ Oh well. Put it on an overlong line by itself. */
+ p = buf + (r + 1 - fs->point_col);
+ /* Find the end of the long word. */
+ do
+ ++p;
+ while (p < nl && !isblank (*p));
+ if (p == nl)
+ {
+ /* It already ends a line. No fussing required. */
+ fs->point_col = 0;
+ buf = nl + 1;
+ continue;
+ }
+ /* We will move the newline to replace the first blank. */
+ nl = p;
+ /* Swallow separating blanks. */
+ do
+ ++p;
+ while (isblank (*p));
+ /* The next line will start here. */
+ nextline = p;
+ }
+
+ /* Note: There are a bunch of tests below for
+ NEXTLINE == BUF + LEN + 1; this case is where NL happens to fall
+ at the end of the buffer, and NEXTLINE is in fact empty (and so
+ we need not be careful to maintain its contents). */
+
+ if (nextline == buf + len + 1
+ ? fs->end - nl < fs->wmargin + 1
+ : nextline - (nl + 1) < fs->wmargin)
+ {
+ /* The margin needs more blanks than we removed. */
+ if (fs->end - fs->p > fs->wmargin + 1)
+ /* Make some space for them. */
+ {
+ size_t mv = fs->p - nextline;
+ memmove (nl + 1 + fs->wmargin, nextline, mv);
+ nextline = nl + 1 + fs->wmargin;
+ len = nextline + mv - buf;
+ *nl++ = '\n';
+ }
+ else
+ /* Output the first line so we can use the space. */
+ {
+ if (nl > fs->buf)
+ FWRITE_UNLOCKED (fs->buf, 1, nl - fs->buf, fs->stream);
+ PUTC_UNLOCKED ('\n', fs->stream);
+ len += buf - fs->buf;
+ nl = buf = fs->buf;
+ }
+ }
+ else
+ /* We can fit the newline and blanks in before
+ the next word. */
+ *nl++ = '\n';
+
+ if (nextline - nl >= fs->wmargin
+ || (nextline == buf + len + 1 && fs->end - nextline >= fs->wmargin))
+ /* Add blanks up to the wrap margin column. */
+ for (i = 0; i < fs->wmargin; ++i)
+ *nl++ = ' ';
+ else
+ for (i = 0; i < fs->wmargin; ++i)
+ PUTC_UNLOCKED (' ', fs->stream);
+
+ /* Copy the tail of the original buffer into the current buffer
+ position. */
+ if (nl < nextline)
+ memmove (nl, nextline, buf + len - nextline);
+ len -= nextline - buf;
+
+ /* Continue the scan on the remaining lines in the buffer. */
+ buf = nl;
+
+ /* Restore bufp to include all the remaining text. */
+ fs->p = nl + len;
+
+ /* Reset the counter of what has been output this line. If wmargin
+ is 0, we want to avoid the lmargin getting added, so we set
+ point_col to a magic value of -1 in that case. */
+ fs->point_col = fs->wmargin ? fs->wmargin : -1;
+ }
+ }
+
+ /* Remember that we've scanned as far as the end of the buffer. */
+ fs->point_offs = fs->p - fs->buf;
+}
+
+/* Ensure that FS has space for AMOUNT more bytes in its buffer, either by
+ growing the buffer, or by flushing it. True is returned iff we succeed. */
+int
+__argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
+{
+ if ((size_t) (fs->end - fs->p) < amount)
+ {
+ ssize_t wrote;
+
+ /* Flush FS's buffer. */
+ __argp_fmtstream_update (fs);
+
+ wrote = FWRITE_UNLOCKED (fs->buf, 1, fs->p - fs->buf, fs->stream);
+ if (wrote == fs->p - fs->buf)
+ {
+ fs->p = fs->buf;
+ fs->point_offs = 0;
+ }
+ else
+ {
+ fs->p -= wrote;
+ fs->point_offs -= wrote;
+ memmove (fs->buf, fs->buf + wrote, fs->p - fs->buf);
+ return 0;
+ }
+
+ if ((size_t) (fs->end - fs->buf) < amount)
+ /* Gotta grow the buffer. */
+ {
+ size_t new_size = fs->end - fs->buf + amount;
+ char *new_buf = realloc (fs->buf, new_size);
+
+ if (! new_buf)
+ {
+ __set_errno (ENOMEM);
+ return 0;
+ }
+
+ fs->buf = new_buf;
+ fs->end = new_buf + new_size;
+ fs->p = fs->buf;
+ }
+ }
+
+ return 1;
+}
+
+ssize_t
+__argp_fmtstream_printf (struct argp_fmtstream *fs, const char *fmt, ...)
+{
+ size_t out;
+ size_t avail;
+ size_t size_guess = PRINTF_SIZE_GUESS; /* How much space to reserve. */
+
+ do
+ {
+ va_list args;
+
+ if (! __argp_fmtstream_ensure (fs, size_guess))
+ return -1;
+
+ va_start (args, fmt);
+ avail = fs->end - fs->p;
+ out = __vsnprintf (fs->p, avail, fmt, args);
+ va_end (args);
+ if (out >= avail)
+ size_guess = out + 1;
+ }
+ while (out >= avail);
+
+ fs->p += out;
+
+ return out;
+}
+#ifdef weak_alias
+weak_alias (__argp_fmtstream_printf, argp_fmtstream_printf)
+#endif
+
+/* Duplicate the inline definitions in argp-fmtstream.h, for compilers
+ * that don't do inlining. */
+size_t
+__argp_fmtstream_write (argp_fmtstream_t __fs,
+ __const char *__str, size_t __len)
+{
+ if (__fs->p + __len <= __fs->end || __argp_fmtstream_ensure (__fs, __len))
+ {
+ memcpy (__fs->p, __str, __len);
+ __fs->p += __len;
+ return __len;
+ }
+ else
+ return 0;
+}
+
+int
+__argp_fmtstream_puts (argp_fmtstream_t __fs, __const char *__str)
+{
+ size_t __len = strlen (__str);
+ if (__len)
+ {
+ size_t __wrote = __argp_fmtstream_write (__fs, __str, __len);
+ return __wrote == __len ? 0 : -1;
+ }
+ else
+ return 0;
+}
+
+int
+__argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch)
+{
+ if (__fs->p < __fs->end || __argp_fmtstream_ensure (__fs, 1))
+ return *__fs->p++ = __ch;
+ else
+ return EOF;
+}
+
+/* Set __FS's left margin to __LMARGIN and return the old value. */
+size_t
+__argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin)
+{
+ size_t __old;
+ if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+ __argp_fmtstream_update (__fs);
+ __old = __fs->lmargin;
+ __fs->lmargin = __lmargin;
+ return __old;
+}
+
+/* Set __FS's right margin to __RMARGIN and return the old value. */
+size_t
+__argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin)
+{
+ size_t __old;
+ if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+ __argp_fmtstream_update (__fs);
+ __old = __fs->rmargin;
+ __fs->rmargin = __rmargin;
+ return __old;
+}
+
+/* Set FS's wrap margin to __WMARGIN and return the old value. */
+size_t
+__argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin)
+{
+ size_t __old;
+ if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+ __argp_fmtstream_update (__fs);
+ __old = __fs->wmargin;
+ __fs->wmargin = __wmargin;
+ return __old;
+}
+
+/* Return the column number of the current output point in __FS. */
+size_t
+__argp_fmtstream_point (argp_fmtstream_t __fs)
+{
+ if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+ __argp_fmtstream_update (__fs);
+ return __fs->point_col >= 0 ? __fs->point_col : 0;
+}
+
+#endif /* !ARGP_FMTSTREAM_USE_LINEWRAP */
diff --git a/argp-standalone/argp-fmtstream.h b/argp-standalone/argp-fmtstream.h
new file mode 100644
index 0000000..e797b11
--- /dev/null
+++ b/argp-standalone/argp-fmtstream.h
@@ -0,0 +1,319 @@
+/* Word-wrapping and line-truncating streams.
+ Copyright (C) 1997, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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 Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* This package emulates glibc `line_wrap_stream' semantics for systems that
+ don't have that. If the system does have it, it is just a wrapper for
+ that. This header file is only used internally while compiling argp, and
+ shouldn't be installed. */
+
+#ifndef _ARGP_FMTSTREAM_H
+#define _ARGP_FMTSTREAM_H
+
+#include <stdio.h>
+#include <string.h>
+
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#else
+/* This is a kludge to make the code compile on windows. Perhaps it
+ would be better to just replace ssize_t with int through out the
+ code. */
+# define ssize_t int
+#endif
+
+#if _LIBC || (defined (HAVE_FLOCKFILE) && defined(HAVE_PUTC_UNLOCKED) \
+ && defined (HAVE_FPUTS_UNLOCKED) && defined (HAVE_FWRITE_UNLOCKED) )
+/* Use locking funxtions */
+# define FLOCKFILE(f) flockfile(f)
+# define FUNLOCKFILE(f) funlockfile(f)
+# define PUTC_UNLOCKED(c, f) putc_unlocked((c), (f))
+# define FPUTS_UNLOCKED(s, f) fputs_unlocked((s), (f))
+# define FWRITE_UNLOCKED(b, s, n, f) fwrite_unlocked((b), (s), (n), (f))
+#else
+/* Disable stdio locking */
+# define FLOCKFILE(f)
+# define FUNLOCKFILE(f)
+# define PUTC_UNLOCKED(c, f) putc((c), (f))
+# define FPUTS_UNLOCKED(s, f) fputs((s), (f))
+# define FWRITE_UNLOCKED(b, s, n, f) fwrite((b), (s), (n), (f))
+#endif /* No thread safe i/o */
+
+#if (_LIBC - 0 && !defined (USE_IN_LIBIO)) \
+ || (defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H))
+/* line_wrap_stream is available, so use that. */
+#define ARGP_FMTSTREAM_USE_LINEWRAP
+#endif
+
+#ifdef ARGP_FMTSTREAM_USE_LINEWRAP
+/* Just be a simple wrapper for line_wrap_stream; the semantics are
+ *slightly* different, as line_wrap_stream doesn't actually make a new
+ object, it just modifies the given stream (reversibly) to do
+ line-wrapping. Since we control who uses this code, it doesn't matter. */
+
+#include <linewrap.h>
+
+typedef FILE *argp_fmtstream_t;
+
+#define argp_make_fmtstream line_wrap_stream
+#define __argp_make_fmtstream line_wrap_stream
+#define argp_fmtstream_free line_unwrap_stream
+#define __argp_fmtstream_free line_unwrap_stream
+
+#define __argp_fmtstream_putc(fs,ch) putc(ch,fs)
+#define argp_fmtstream_putc(fs,ch) putc(ch,fs)
+#define __argp_fmtstream_puts(fs,str) fputs(str,fs)
+#define argp_fmtstream_puts(fs,str) fputs(str,fs)
+#define __argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
+#define argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
+#define __argp_fmtstream_printf fprintf
+#define argp_fmtstream_printf fprintf
+
+#define __argp_fmtstream_lmargin line_wrap_lmargin
+#define argp_fmtstream_lmargin line_wrap_lmargin
+#define __argp_fmtstream_set_lmargin line_wrap_set_lmargin
+#define argp_fmtstream_set_lmargin line_wrap_set_lmargin
+#define __argp_fmtstream_rmargin line_wrap_rmargin
+#define argp_fmtstream_rmargin line_wrap_rmargin
+#define __argp_fmtstream_set_rmargin line_wrap_set_rmargin
+#define argp_fmtstream_set_rmargin line_wrap_set_rmargin
+#define __argp_fmtstream_wmargin line_wrap_wmargin
+#define argp_fmtstream_wmargin line_wrap_wmargin
+#define __argp_fmtstream_set_wmargin line_wrap_set_wmargin
+#define argp_fmtstream_set_wmargin line_wrap_set_wmargin
+#define __argp_fmtstream_point line_wrap_point
+#define argp_fmtstream_point line_wrap_point
+
+#else /* !ARGP_FMTSTREAM_USE_LINEWRAP */
+/* Guess we have to define our own version. */
+
+#ifndef __const
+#define __const const
+#endif
+
+
+struct argp_fmtstream
+{
+ FILE *stream; /* The stream we're outputting to. */
+
+ size_t lmargin, rmargin; /* Left and right margins. */
+ ssize_t wmargin; /* Margin to wrap to, or -1 to truncate. */
+
+ /* Point in buffer to which we've processed for wrapping, but not output. */
+ size_t point_offs;
+ /* Output column at POINT_OFFS, or -1 meaning 0 but don't add lmargin. */
+ ssize_t point_col;
+
+ char *buf; /* Output buffer. */
+ char *p; /* Current end of text in BUF. */
+ char *end; /* Absolute end of BUF. */
+};
+
+typedef struct argp_fmtstream *argp_fmtstream_t;
+
+/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
+ written on it with LMARGIN spaces and limits them to RMARGIN columns
+ total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
+ replacing the whitespace before them with a newline and WMARGIN spaces.
+ Otherwise, chars beyond RMARGIN are simply dropped until a newline.
+ Returns NULL if there was an error. */
+extern argp_fmtstream_t __argp_make_fmtstream (FILE *__stream,
+ size_t __lmargin,
+ size_t __rmargin,
+ ssize_t __wmargin);
+extern argp_fmtstream_t argp_make_fmtstream (FILE *__stream,
+ size_t __lmargin,
+ size_t __rmargin,
+ ssize_t __wmargin);
+
+/* Flush __FS to its stream, and free it (but don't close the stream). */
+extern void __argp_fmtstream_free (argp_fmtstream_t __fs);
+extern void argp_fmtstream_free (argp_fmtstream_t __fs);
+
+extern ssize_t __argp_fmtstream_printf (argp_fmtstream_t __fs,
+ __const char *__fmt, ...)
+ PRINTF_STYLE(2,3);
+extern ssize_t argp_fmtstream_printf (argp_fmtstream_t __fs,
+ __const char *__fmt, ...)
+ PRINTF_STYLE(2,3);
+
+extern int __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
+extern int argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
+
+extern int __argp_fmtstream_puts (argp_fmtstream_t __fs, __const char *__str);
+extern int argp_fmtstream_puts (argp_fmtstream_t __fs, __const char *__str);
+
+extern size_t __argp_fmtstream_write (argp_fmtstream_t __fs,
+ __const char *__str, size_t __len);
+extern size_t argp_fmtstream_write (argp_fmtstream_t __fs,
+ __const char *__str, size_t __len);
+
+/* Access macros for various bits of state. */
+#define argp_fmtstream_lmargin(__fs) ((__fs)->lmargin)
+#define argp_fmtstream_rmargin(__fs) ((__fs)->rmargin)
+#define argp_fmtstream_wmargin(__fs) ((__fs)->wmargin)
+#define __argp_fmtstream_lmargin argp_fmtstream_lmargin
+#define __argp_fmtstream_rmargin argp_fmtstream_rmargin
+#define __argp_fmtstream_wmargin argp_fmtstream_wmargin
+
+/* Set __FS's left margin to LMARGIN and return the old value. */
+extern size_t argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
+ size_t __lmargin);
+extern size_t __argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
+ size_t __lmargin);
+
+/* Set __FS's right margin to __RMARGIN and return the old value. */
+extern size_t argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
+ size_t __rmargin);
+extern size_t __argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
+ size_t __rmargin);
+
+/* Set __FS's wrap margin to __WMARGIN and return the old value. */
+extern size_t argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
+ size_t __wmargin);
+extern size_t __argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
+ size_t __wmargin);
+
+/* Return the column number of the current output point in __FS. */
+extern size_t argp_fmtstream_point (argp_fmtstream_t __fs);
+extern size_t __argp_fmtstream_point (argp_fmtstream_t __fs);
+
+/* Internal routines. */
+extern void _argp_fmtstream_update (argp_fmtstream_t __fs);
+extern void __argp_fmtstream_update (argp_fmtstream_t __fs);
+extern int _argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
+extern int __argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
+
+#ifdef __OPTIMIZE__
+/* Inline versions of above routines. */
+
+#if !_LIBC
+#define __argp_fmtstream_putc argp_fmtstream_putc
+#define __argp_fmtstream_puts argp_fmtstream_puts
+#define __argp_fmtstream_write argp_fmtstream_write
+#define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin
+#define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin
+#define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin
+#define __argp_fmtstream_point argp_fmtstream_point
+#define __argp_fmtstream_update _argp_fmtstream_update
+#define __argp_fmtstream_ensure _argp_fmtstream_ensure
+#endif
+
+#ifndef ARGP_FS_EI
+#define ARGP_FS_EI extern inline
+#endif
+
+ARGP_FS_EI size_t
+__argp_fmtstream_write (argp_fmtstream_t __fs,
+ __const char *__str, size_t __len)
+{
+ if (__fs->p + __len <= __fs->end || __argp_fmtstream_ensure (__fs, __len))
+ {
+ memcpy (__fs->p, __str, __len);
+ __fs->p += __len;
+ return __len;
+ }
+ else
+ return 0;
+}
+
+ARGP_FS_EI int
+__argp_fmtstream_puts (argp_fmtstream_t __fs, __const char *__str)
+{
+ size_t __len = strlen (__str);
+ if (__len)
+ {
+ size_t __wrote = __argp_fmtstream_write (__fs, __str, __len);
+ return __wrote == __len ? 0 : -1;
+ }
+ else
+ return 0;
+}
+
+ARGP_FS_EI int
+__argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch)
+{
+ if (__fs->p < __fs->end || __argp_fmtstream_ensure (__fs, 1))
+ return *__fs->p++ = __ch;
+ else
+ return EOF;
+}
+
+/* Set __FS's left margin to __LMARGIN and return the old value. */
+ARGP_FS_EI size_t
+__argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin)
+{
+ size_t __old;
+ if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+ __argp_fmtstream_update (__fs);
+ __old = __fs->lmargin;
+ __fs->lmargin = __lmargin;
+ return __old;
+}
+
+/* Set __FS's right margin to __RMARGIN and return the old value. */
+ARGP_FS_EI size_t
+__argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin)
+{
+ size_t __old;
+ if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+ __argp_fmtstream_update (__fs);
+ __old = __fs->rmargin;
+ __fs->rmargin = __rmargin;
+ return __old;
+}
+
+/* Set FS's wrap margin to __WMARGIN and return the old value. */
+ARGP_FS_EI size_t
+__argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin)
+{
+ size_t __old;
+ if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+ __argp_fmtstream_update (__fs);
+ __old = __fs->wmargin;
+ __fs->wmargin = __wmargin;
+ return __old;
+}
+
+/* Return the column number of the current output point in __FS. */
+ARGP_FS_EI size_t
+__argp_fmtstream_point (argp_fmtstream_t __fs)
+{
+ if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+ __argp_fmtstream_update (__fs);
+ return __fs->point_col >= 0 ? __fs->point_col : 0;
+}
+
+#if !_LIBC
+#undef __argp_fmtstream_putc
+#undef __argp_fmtstream_puts
+#undef __argp_fmtstream_write
+#undef __argp_fmtstream_set_lmargin
+#undef __argp_fmtstream_set_rmargin
+#undef __argp_fmtstream_set_wmargin
+#undef __argp_fmtstream_point
+#undef __argp_fmtstream_update
+#undef __argp_fmtstream_ensure
+#endif
+
+#endif /* __OPTIMIZE__ */
+
+#endif /* ARGP_FMTSTREAM_USE_LINEWRAP */
+
+#endif /* argp-fmtstream.h */
diff --git a/argp-standalone/argp-help.c b/argp-standalone/argp-help.c
new file mode 100644
index 0000000..ced78c4
--- /dev/null
+++ b/argp-standalone/argp-help.c
@@ -0,0 +1,1849 @@
+/* Hierarchial argument parsing help output
+ Copyright (C) 1995,96,97,98,99,2000, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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 Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <ctype.h>
+#if HAVE_MALLOC_H
+/* Needed, for alloca on windows */
+# include <malloc.h>
+#endif
+
+#ifndef _
+/* This is for other GNU distributions with internationalized messages. */
+# if defined HAVE_LIBINTL_H || defined _LIBC
+# include <libintl.h>
+# ifdef _LIBC
+# undef dgettext
+# define dgettext(domain, msgid) __dcgettext (domain, msgid, LC_MESSAGES)
+# endif
+# else
+# define dgettext(domain, msgid) (msgid)
+# endif
+#endif
+
+#include "argp.h"
+#include "argp-fmtstream.h"
+#include "argp-namefrob.h"
+
+
+#ifndef _LIBC
+# ifndef __strchrnul
+# define __strchrnul strchrnul
+# endif
+# ifndef __mempcpy
+# define __mempcpy mempcpy
+# endif
+/* We need to use a different name, as __strndup is likely a macro. */
+# define STRNDUP strndup
+# if HAVE_STRERROR
+# define STRERROR strerror
+# else
+# define STRERROR(x) (sys_errlist[x])
+# endif
+#else /* _LIBC */
+# define FLOCKFILE __flockfile
+# define FUNLOCKFILE __funlockfile
+# define STRNDUP __strndup
+# define STRERROR strerror
+#endif
+
+#if !_LIBC
+# if !HAVE_STRNDUP
+char *strndup (const char *s, size_t size);
+# endif /* !HAVE_STRNDUP */
+
+# if !HAVE_MEMPCPY
+void *mempcpy (void *to, const void *from, size_t size);
+# endif /* !HAVE_MEMPCPY */
+
+# if !HAVE_STRCHRNUL
+char *strchrnul(const char *s, int c);
+# endif /* !HAVE_STRCHRNUL */
+
+# if !HAVE_STRCASECMP
+int strcasecmp(const char *s1, const char *s2);
+#endif
+
+#endif /* !_LIBC */
+
+
+/* User-selectable (using an environment variable) formatting parameters.
+
+ These may be specified in an environment variable called `ARGP_HELP_FMT',
+ with a contents like: VAR1=VAL1,VAR2=VAL2,BOOLVAR2,no-BOOLVAR2
+ Where VALn must be a positive integer. The list of variables is in the
+ UPARAM_NAMES vector, below. */
+
+/* Default parameters. */
+#define DUP_ARGS 0 /* True if option argument can be duplicated. */
+#define DUP_ARGS_NOTE 1 /* True to print a note about duplicate args. */
+#define SHORT_OPT_COL 2 /* column in which short options start */
+#define LONG_OPT_COL 6 /* column in which long options start */
+#define DOC_OPT_COL 2 /* column in which doc options start */
+#define OPT_DOC_COL 29 /* column in which option text starts */
+#define HEADER_COL 1 /* column in which group headers are printed */
+#define USAGE_INDENT 12 /* indentation of wrapped usage lines */
+#define RMARGIN 79 /* right margin used for wrapping */
+
+/* User-selectable (using an environment variable) formatting parameters.
+ They must all be of type `int' for the parsing code to work. */
+struct uparams
+{
+ /* If true, arguments for an option are shown with both short and long
+ options, even when a given option has both, e.g. `-x ARG, --longx=ARG'.
+ If false, then if an option has both, the argument is only shown with
+ the long one, e.g., `-x, --longx=ARG', and a message indicating that
+ this really means both is printed below the options. */
+ int dup_args;
+
+ /* This is true if when DUP_ARGS is false, and some duplicate arguments have
+ been suppressed, an explanatory message should be printed. */
+ int dup_args_note;
+
+ /* Various output columns. */
+ int short_opt_col;
+ int long_opt_col;
+ int doc_opt_col;
+ int opt_doc_col;
+ int header_col;
+ int usage_indent;
+ int rmargin;
+
+ int valid; /* True when the values in here are valid. */
+};
+
+/* This is a global variable, as user options are only ever read once. */
+static struct uparams uparams = {
+ DUP_ARGS, DUP_ARGS_NOTE,
+ SHORT_OPT_COL, LONG_OPT_COL, DOC_OPT_COL, OPT_DOC_COL, HEADER_COL,
+ USAGE_INDENT, RMARGIN,
+ 0
+};
+
+/* A particular uparam, and what the user name is. */
+struct uparam_name
+{
+ const char *name; /* User name. */
+ int is_bool; /* Whether it's `boolean'. */
+ size_t uparams_offs; /* Location of the (int) field in UPARAMS. */
+};
+
+/* The name-field mappings we know about. */
+static const struct uparam_name uparam_names[] =
+{
+ { "dup-args", 1, offsetof (struct uparams, dup_args) },
+ { "dup-args-note", 1, offsetof (struct uparams, dup_args_note) },
+ { "short-opt-col", 0, offsetof (struct uparams, short_opt_col) },
+ { "long-opt-col", 0, offsetof (struct uparams, long_opt_col) },
+ { "doc-opt-col", 0, offsetof (struct uparams, doc_opt_col) },
+ { "opt-doc-col", 0, offsetof (struct uparams, opt_doc_col) },
+ { "header-col", 0, offsetof (struct uparams, header_col) },
+ { "usage-indent", 0, offsetof (struct uparams, usage_indent) },
+ { "rmargin", 0, offsetof (struct uparams, rmargin) },
+ { 0, 0, 0 }
+};
+
+/* Read user options from the environment, and fill in UPARAMS appropiately. */
+static void
+fill_in_uparams (const struct argp_state *state)
+{
+
+ const char *var = getenv ("ARGP_HELP_FMT");
+
+#define SKIPWS(p) do { while (isspace (*p)) p++; } while (0);
+
+ if (var)
+ /* Parse var. */
+ while (*var)
+ {
+ SKIPWS (var);
+
+ if (isalpha (*var))
+ {
+ size_t var_len;
+ const struct uparam_name *un;
+ int unspec = 0, val = 0;
+ const char *arg = var;
+
+ while (isalnum (*arg) || *arg == '-' || *arg == '_')
+ arg++;
+ var_len = arg - var;
+
+ SKIPWS (arg);
+
+ if (*arg == '\0' || *arg == ',')
+ unspec = 1;
+ else if (*arg == '=')
+ {
+ arg++;
+ SKIPWS (arg);
+ }
+
+ if (unspec)
+ {
+ if (var[0] == 'n' && var[1] == 'o' && var[2] == '-')
+ {
+ val = 0;
+ var += 3;
+ var_len -= 3;
+ }
+ else
+ val = 1;
+ }
+ else if (isdigit (*arg))
+ {
+ val = atoi (arg);
+ while (isdigit (*arg))
+ arg++;
+ SKIPWS (arg);
+ }
+
+ for (un = uparam_names; un->name; un++)
+ if (strlen (un->name) == var_len
+ && strncmp (var, un->name, var_len) == 0)
+ {
+ if (unspec && !un->is_bool)
+ __argp_failure (state, 0, 0,
+ dgettext (state->root_argp->argp_domain, "\
+%.*s: ARGP_HELP_FMT parameter requires a value"),
+ (int) var_len, var);
+ else
+ *(int *)((char *)&uparams + un->uparams_offs) = val;
+ break;
+ }
+ if (! un->name)
+ __argp_failure (state, 0, 0,
+ dgettext (state->root_argp->argp_domain, "\
+%.*s: Unknown ARGP_HELP_FMT parameter"),
+ (int) var_len, var);
+
+ var = arg;
+ if (*var == ',')
+ var++;
+ }
+ else if (*var)
+ {
+ __argp_failure (state, 0, 0,
+ dgettext (state->root_argp->argp_domain,
+ "Garbage in ARGP_HELP_FMT: %s"), var);
+ break;
+ }
+ }
+}
+
+/* Returns true if OPT hasn't been marked invisible. Visibility only affects
+ whether OPT is displayed or used in sorting, not option shadowing. */
+#define ovisible(opt) (! ((opt)->flags & OPTION_HIDDEN))
+
+/* Returns true if OPT is an alias for an earlier option. */
+#define oalias(opt) ((opt)->flags & OPTION_ALIAS)
+
+/* Returns true if OPT is an documentation-only entry. */
+#define odoc(opt) ((opt)->flags & OPTION_DOC)
+
+/* Returns true if OPT is the end-of-list marker for a list of options. */
+#define oend(opt) __option_is_end (opt)
+
+/* Returns true if OPT has a short option. */
+#define oshort(opt) __option_is_short (opt)
+
+/*
+ The help format for a particular option is like:
+
+ -xARG, -yARG, --long1=ARG, --long2=ARG Documentation...
+
+ Where ARG will be omitted if there's no argument, for this option, or
+ will be surrounded by "[" and "]" appropiately if the argument is
+ optional. The documentation string is word-wrapped appropiately, and if
+ the list of options is long enough, it will be started on a separate line.
+ If there are no short options for a given option, the first long option is
+ indented slighly in a way that's supposed to make most long options appear
+ to be in a separate column.
+
+ For example, the following output (from ps):
+
+ -p PID, --pid=PID List the process PID
+ --pgrp=PGRP List processes in the process group PGRP
+ -P, -x, --no-parent Include processes without parents
+ -Q, --all-fields Don't elide unusable fields (normally if there's
+ some reason ps can't print a field for any
+ process, it's removed from the output entirely)
+ -r, --reverse, --gratuitously-long-reverse-option
+ Reverse the order of any sort
+ --session[=SID] Add the processes from the session SID (which
+ defaults to the sid of the current process)
+
+ Here are some more options:
+ -f ZOT, --foonly=ZOT Glork a foonly
+ -z, --zaza Snit a zar
+
+ -?, --help Give this help list
+ --usage Give a short usage message
+ -V, --version Print program version
+
+ The struct argp_option array for the above could look like:
+
+ {
+ {"pid", 'p', "PID", 0, "List the process PID"},
+ {"pgrp", OPT_PGRP, "PGRP", 0, "List processes in the process group PGRP"},
+ {"no-parent", 'P', 0, 0, "Include processes without parents"},
+ {0, 'x', 0, OPTION_ALIAS},
+ {"all-fields",'Q', 0, 0, "Don't elide unusable fields (normally"
+ " if there's some reason ps can't"
+ " print a field for any process, it's"
+ " removed from the output entirely)" },
+ {"reverse", 'r', 0, 0, "Reverse the order of any sort"},
+ {"gratuitously-long-reverse-option", 0, 0, OPTION_ALIAS},
+ {"session", OPT_SESS, "SID", OPTION_ARG_OPTIONAL,
+ "Add the processes from the session"
+ " SID (which defaults to the sid of"
+ " the current process)" },
+
+ {0,0,0,0, "Here are some more options:"},
+ {"foonly", 'f', "ZOT", 0, "Glork a foonly"},
+ {"zaza", 'z', 0, 0, "Snit a zar"},
+
+ {0}
+ }
+
+ Note that the last three options are automatically supplied by argp_parse,
+ unless you tell it not to with ARGP_NO_HELP.
+
+*/
+
+/* Returns true if CH occurs between BEG and END. */
+static int
+find_char (char ch, char *beg, char *end)
+{
+ while (beg < end)
+ if (*beg == ch)
+ return 1;
+ else
+ beg++;
+ return 0;
+}
+
+struct hol_cluster; /* fwd decl */
+
+struct hol_entry
+{
+ /* First option. */
+ const struct argp_option *opt;
+ /* Number of options (including aliases). */
+ unsigned num;
+
+ /* A pointers into the HOL's short_options field, to the first short option
+ letter for this entry. The order of the characters following this point
+ corresponds to the order of options pointed to by OPT, and there are at
+ most NUM. A short option recorded in a option following OPT is only
+ valid if it occurs in the right place in SHORT_OPTIONS (otherwise it's
+ probably been shadowed by some other entry). */
+ char *short_options;
+
+ /* Entries are sorted by their group first, in the order:
+ 1, 2, ..., n, 0, -m, ..., -2, -1
+ and then alphabetically within each group. The default is 0. */
+ int group;
+
+ /* The cluster of options this entry belongs to, or 0 if none. */
+ struct hol_cluster *cluster;
+
+ /* The argp from which this option came. */
+ const struct argp *argp;
+};
+
+/* A cluster of entries to reflect the argp tree structure. */
+struct hol_cluster
+{
+ /* A descriptive header printed before options in this cluster. */
+ const char *header;
+
+ /* Used to order clusters within the same group with the same parent,
+ according to the order in which they occurred in the parent argp's child
+ list. */
+ int index;
+
+ /* How to sort this cluster with respect to options and other clusters at the
+ same depth (clusters always follow options in the same group). */
+ int group;
+
+ /* The cluster to which this cluster belongs, or 0 if it's at the base
+ level. */
+ struct hol_cluster *parent;
+
+ /* The argp from which this cluster is (eventually) derived. */
+ const struct argp *argp;
+
+ /* The distance this cluster is from the root. */
+ int depth;
+
+ /* Clusters in a given hol are kept in a linked list, to make freeing them
+ possible. */
+ struct hol_cluster *next;
+};
+
+/* A list of options for help. */
+struct hol
+{
+ /* An array of hol_entry's. */
+ struct hol_entry *entries;
+ /* The number of entries in this hol. If this field is zero, the others
+ are undefined. */
+ unsigned num_entries;
+
+ /* A string containing all short options in this HOL. Each entry contains
+ pointers into this string, so the order can't be messed with blindly. */
+ char *short_options;
+
+ /* Clusters of entries in this hol. */
+ struct hol_cluster *clusters;
+};
+
+/* Create a struct hol from the options in ARGP. CLUSTER is the
+ hol_cluster in which these entries occur, or 0, if at the root. */
+static struct hol *
+make_hol (const struct argp *argp, struct hol_cluster *cluster)
+{
+ char *so;
+ const struct argp_option *o;
+ const struct argp_option *opts = argp->options;
+ struct hol_entry *entry;
+ unsigned num_short_options = 0;
+ struct hol *hol = malloc (sizeof (struct hol));
+
+ assert (hol);
+
+ hol->num_entries = 0;
+ hol->clusters = 0;
+
+ if (opts)
+ {
+ int cur_group = 0;
+
+ /* The first option must not be an alias. */
+ assert (! oalias (opts));
+
+ /* Calculate the space needed. */
+ for (o = opts; ! oend (o); o++)
+ {
+ if (! oalias (o))
+ hol->num_entries++;
+ if (oshort (o))
+ num_short_options++; /* This is an upper bound. */
+ }
+
+ hol->entries = malloc (sizeof (struct hol_entry) * hol->num_entries);
+ hol->short_options = malloc (num_short_options + 1);
+
+ assert (hol->entries && hol->short_options);
+
+ /* Fill in the entries. */
+ so = hol->short_options;
+ for (o = opts, entry = hol->entries; ! oend (o); entry++)
+ {
+ entry->opt = o;
+ entry->num = 0;
+ entry->short_options = so;
+ entry->group = cur_group =
+ o->group
+ ? o->group
+ : ((!o->name && !o->key)
+ ? cur_group + 1
+ : cur_group);
+ entry->cluster = cluster;
+ entry->argp = argp;
+
+ do
+ {
+ entry->num++;
+ if (oshort (o) && ! find_char (o->key, hol->short_options, so))
+ /* O has a valid short option which hasn't already been used.*/
+ *so++ = o->key;
+ o++;
+ }
+ while (! oend (o) && oalias (o));
+ }
+ *so = '\0'; /* null terminated so we can find the length */
+ }
+
+ return hol;
+}
+
+/* Add a new cluster to HOL, with the given GROUP and HEADER (taken from the
+ associated argp child list entry), INDEX, and PARENT, and return a pointer
+ to it. ARGP is the argp that this cluster results from. */
+static struct hol_cluster *
+hol_add_cluster (struct hol *hol, int group, const char *header, int index,
+ struct hol_cluster *parent, const struct argp *argp)
+{
+ struct hol_cluster *cl = malloc (sizeof (struct hol_cluster));
+ if (cl)
+ {
+ cl->group = group;
+ cl->header = header;
+
+ cl->index = index;
+ cl->parent = parent;
+ cl->argp = argp;
+ cl->depth = parent ? parent->depth + 1 : 0;
+
+ cl->next = hol->clusters;
+ hol->clusters = cl;
+ }
+ return cl;
+}
+
+/* Free HOL and any resources it uses. */
+static void
+hol_free (struct hol *hol)
+{
+ struct hol_cluster *cl = hol->clusters;
+
+ while (cl)
+ {
+ struct hol_cluster *next = cl->next;
+ free (cl);
+ cl = next;
+ }
+
+ if (hol->num_entries > 0)
+ {
+ free (hol->entries);
+ free (hol->short_options);
+ }
+
+ free (hol);
+}
+
+static inline int
+hol_entry_short_iterate (const struct hol_entry *entry,
+ int (*func)(const struct argp_option *opt,
+ const struct argp_option *real,
+ const char *domain, void *cookie),
+ const char *domain, void *cookie)
+{
+ unsigned nopts;
+ int val = 0;
+ const struct argp_option *opt, *real = entry->opt;
+ char *so = entry->short_options;
+
+ for (opt = real, nopts = entry->num; nopts > 0 && !val; opt++, nopts--)
+ if (oshort (opt) && *so == opt->key)
+ {
+ if (!oalias (opt))
+ real = opt;
+ if (ovisible (opt))
+ val = (*func)(opt, real, domain, cookie);
+ so++;
+ }
+
+ return val;
+}
+
+static inline int
+hol_entry_long_iterate (const struct hol_entry *entry,
+ int (*func)(const struct argp_option *opt,
+ const struct argp_option *real,
+ const char *domain, void *cookie),
+ const char *domain, void *cookie)
+{
+ unsigned nopts;
+ int val = 0;
+ const struct argp_option *opt, *real = entry->opt;
+
+ for (opt = real, nopts = entry->num; nopts > 0 && !val; opt++, nopts--)
+ if (opt->name)
+ {
+ if (!oalias (opt))
+ real = opt;
+ if (ovisible (opt))
+ val = (*func)(opt, real, domain, cookie);
+ }
+
+ return val;
+}
+
+/* Iterator that returns true for the first short option. */
+static inline int
+until_short (const struct argp_option *opt, const struct argp_option *real UNUSED,
+ const char *domain UNUSED, void *cookie UNUSED)
+{
+ return oshort (opt) ? opt->key : 0;
+}
+
+/* Returns the first valid short option in ENTRY, or 0 if there is none. */
+static char
+hol_entry_first_short (const struct hol_entry *entry)
+{
+ return hol_entry_short_iterate (entry, until_short,
+ entry->argp->argp_domain, 0);
+}
+
+/* Returns the first valid long option in ENTRY, or 0 if there is none. */
+static const char *
+hol_entry_first_long (const struct hol_entry *entry)
+{
+ const struct argp_option *opt;
+ unsigned num;
+ for (opt = entry->opt, num = entry->num; num > 0; opt++, num--)
+ if (opt->name && ovisible (opt))
+ return opt->name;
+ return 0;
+}
+
+/* Returns the entry in HOL with the long option name NAME, or 0 if there is
+ none. */
+static struct hol_entry *
+hol_find_entry (struct hol *hol, const char *name)
+{
+ struct hol_entry *entry = hol->entries;
+ unsigned num_entries = hol->num_entries;
+
+ while (num_entries-- > 0)
+ {
+ const struct argp_option *opt = entry->opt;
+ unsigned num_opts = entry->num;
+
+ while (num_opts-- > 0)
+ if (opt->name && ovisible (opt) && strcmp (opt->name, name) == 0)
+ return entry;
+ else
+ opt++;
+
+ entry++;
+ }
+
+ return 0;
+}
+
+/* If an entry with the long option NAME occurs in HOL, set it's special
+ sort position to GROUP. */
+static void
+hol_set_group (struct hol *hol, const char *name, int group)
+{
+ struct hol_entry *entry = hol_find_entry (hol, name);
+ if (entry)
+ entry->group = group;
+}
+
+/* Order by group: 0, 1, 2, ..., n, -m, ..., -2, -1.
+ EQ is what to return if GROUP1 and GROUP2 are the same. */
+static int
+group_cmp (int group1, int group2, int eq)
+{
+ if (group1 == group2)
+ return eq;
+ else if ((group1 < 0 && group2 < 0) || (group1 >= 0 && group2 >= 0))
+ return group1 - group2;
+ else
+ return group2 - group1;
+}
+
+/* Compare clusters CL1 & CL2 by the order that they should appear in
+ output. */
+static int
+hol_cluster_cmp (const struct hol_cluster *cl1, const struct hol_cluster *cl2)
+{
+ /* If one cluster is deeper than the other, use its ancestor at the same
+ level, so that finding the common ancestor is straightforward. */
+ while (cl1->depth < cl2->depth)
+ cl1 = cl1->parent;
+ while (cl2->depth < cl1->depth)
+ cl2 = cl2->parent;
+
+ /* Now reduce both clusters to their ancestors at the point where both have
+ a common parent; these can be directly compared. */
+ while (cl1->parent != cl2->parent)
+ cl1 = cl1->parent, cl2 = cl2->parent;
+
+ return group_cmp (cl1->group, cl2->group, cl2->index - cl1->index);
+}
+
+/* Return the ancestor of CL that's just below the root (i.e., has a parent
+ of 0). */
+static struct hol_cluster *
+hol_cluster_base (struct hol_cluster *cl)
+{
+ while (cl->parent)
+ cl = cl->parent;
+ return cl;
+}
+
+/* Return true if CL1 is a child of CL2. */
+static int
+hol_cluster_is_child (const struct hol_cluster *cl1,
+ const struct hol_cluster *cl2)
+{
+ while (cl1 && cl1 != cl2)
+ cl1 = cl1->parent;
+ return cl1 == cl2;
+}
+
+/* Given the name of a OPTION_DOC option, modifies NAME to start at the tail
+ that should be used for comparisons, and returns true iff it should be
+ treated as a non-option. */
+
+/* FIXME: Can we use unsigned char * for the argument? */
+static int
+canon_doc_option (const char **name)
+{
+ int non_opt;
+ /* Skip initial whitespace. */
+ while (isspace ( (unsigned char) **name))
+ (*name)++;
+ /* Decide whether this looks like an option (leading `-') or not. */
+ non_opt = (**name != '-');
+ /* Skip until part of name used for sorting. */
+ while (**name && !isalnum ( (unsigned char) **name))
+ (*name)++;
+ return non_opt;
+}
+
+/* Order ENTRY1 & ENTRY2 by the order which they should appear in a help
+ listing. */
+static int
+hol_entry_cmp (const struct hol_entry *entry1,
+ const struct hol_entry *entry2)
+{
+ /* The group numbers by which the entries should be ordered; if either is
+ in a cluster, then this is just the group within the cluster. */
+ int group1 = entry1->group, group2 = entry2->group;
+
+ if (entry1->cluster != entry2->cluster)
+ {
+ /* The entries are not within the same cluster, so we can't compare them
+ directly, we have to use the appropiate clustering level too. */
+ if (! entry1->cluster)
+ /* ENTRY1 is at the `base level', not in a cluster, so we have to
+ compare it's group number with that of the base cluster in which
+ ENTRY2 resides. Note that if they're in the same group, the
+ clustered option always comes laster. */
+ return group_cmp (group1, hol_cluster_base (entry2->cluster)->group, -1);
+ else if (! entry2->cluster)
+ /* Likewise, but ENTRY2's not in a cluster. */
+ return group_cmp (hol_cluster_base (entry1->cluster)->group, group2, 1);
+ else
+ /* Both entries are in clusters, we can just compare the clusters. */
+ return hol_cluster_cmp (entry1->cluster, entry2->cluster);
+ }
+ else if (group1 == group2)
+ /* The entries are both in the same cluster and group, so compare them
+ alphabetically. */
+ {
+ int short1 = hol_entry_first_short (entry1);
+ int short2 = hol_entry_first_short (entry2);
+ int doc1 = odoc (entry1->opt);
+ int doc2 = odoc (entry2->opt);
+ /* FIXME: Can we use unsigned char * instead? */
+ const char *long1 = hol_entry_first_long (entry1);
+ const char *long2 = hol_entry_first_long (entry2);
+
+ if (doc1)
+ doc1 = canon_doc_option (&long1);
+ if (doc2)
+ doc2 = canon_doc_option (&long2);
+
+ if (doc1 != doc2)
+ /* `documentation' options always follow normal options (or
+ documentation options that *look* like normal options). */
+ return doc1 - doc2;
+ else if (!short1 && !short2 && long1 && long2)
+ /* Only long options. */
+ return __strcasecmp (long1, long2);
+ else
+ /* Compare short/short, long/short, short/long, using the first
+ character of long options. Entries without *any* valid
+ options (such as options with OPTION_HIDDEN set) will be put
+ first, but as they're not displayed, it doesn't matter where
+ they are. */
+ {
+ unsigned char first1 = short1 ? short1 : long1 ? *long1 : 0;
+ unsigned char first2 = short2 ? short2 : long2 ? *long2 : 0;
+#ifdef _tolower
+ int lower_cmp = _tolower (first1) - _tolower (first2);
+#else
+ int lower_cmp = tolower (first1) - tolower (first2);
+#endif
+ /* Compare ignoring case, except when the options are both the
+ same letter, in which case lower-case always comes first. */
+ /* NOTE: The subtraction below does the right thing
+ even with eight-bit chars: first1 and first2 are
+ converted to int *before* the subtraction. */
+ return lower_cmp ? lower_cmp : first2 - first1;
+ }
+ }
+ else
+ /* Within the same cluster, but not the same group, so just compare
+ groups. */
+ return group_cmp (group1, group2, 0);
+}
+
+/* Version of hol_entry_cmp with correct signature for qsort. */
+static int
+hol_entry_qcmp (const void *entry1_v, const void *entry2_v)
+{
+ return hol_entry_cmp (entry1_v, entry2_v);
+}
+
+/* Sort HOL by group and alphabetically by option name (with short options
+ taking precedence over long). Since the sorting is for display purposes
+ only, the shadowing of options isn't effected. */
+static void
+hol_sort (struct hol *hol)
+{
+ if (hol->num_entries > 0)
+ qsort (hol->entries, hol->num_entries, sizeof (struct hol_entry),
+ hol_entry_qcmp);
+}
+
+/* Append MORE to HOL, destroying MORE in the process. Options in HOL shadow
+ any in MORE with the same name. */
+static void
+hol_append (struct hol *hol, struct hol *more)
+{
+ struct hol_cluster **cl_end = &hol->clusters;
+
+ /* Steal MORE's cluster list, and add it to the end of HOL's. */
+ while (*cl_end)
+ cl_end = &(*cl_end)->next;
+ *cl_end = more->clusters;
+ more->clusters = 0;
+
+ /* Merge entries. */
+ if (more->num_entries > 0)
+ {
+ if (hol->num_entries == 0)
+ {
+ hol->num_entries = more->num_entries;
+ hol->entries = more->entries;
+ hol->short_options = more->short_options;
+ more->num_entries = 0; /* Mark MORE's fields as invalid. */
+ }
+ else
+ /* Append the entries in MORE to those in HOL, taking care to only add
+ non-shadowed SHORT_OPTIONS values. */
+ {
+ unsigned left;
+ char *so, *more_so;
+ struct hol_entry *e;
+ unsigned num_entries = hol->num_entries + more->num_entries;
+ struct hol_entry *entries =
+ malloc (num_entries * sizeof (struct hol_entry));
+ unsigned hol_so_len = strlen (hol->short_options);
+ char *short_options =
+ malloc (hol_so_len + strlen (more->short_options) + 1);
+
+ __mempcpy (__mempcpy (entries, hol->entries,
+ hol->num_entries * sizeof (struct hol_entry)),
+ more->entries,
+ more->num_entries * sizeof (struct hol_entry));
+
+ __mempcpy (short_options, hol->short_options, hol_so_len);
+
+ /* Fix up the short options pointers from HOL. */
+ for (e = entries, left = hol->num_entries; left > 0; e++, left--)
+ e->short_options += (short_options - hol->short_options);
+
+ /* Now add the short options from MORE, fixing up its entries
+ too. */
+ so = short_options + hol_so_len;
+ more_so = more->short_options;
+ for (left = more->num_entries; left > 0; e++, left--)
+ {
+ int opts_left;
+ const struct argp_option *opt;
+
+ e->short_options = so;
+
+ for (opts_left = e->num, opt = e->opt; opts_left; opt++, opts_left--)
+ {
+ int ch = *more_so;
+ if (oshort (opt) && ch == opt->key)
+ /* The next short option in MORE_SO, CH, is from OPT. */
+ {
+ if (! find_char (ch, short_options,
+ short_options + hol_so_len))
+ /* The short option CH isn't shadowed by HOL's options,
+ so add it to the sum. */
+ *so++ = ch;
+ more_so++;
+ }
+ }
+ }
+
+ *so = '\0';
+
+ free (hol->entries);
+ free (hol->short_options);
+
+ hol->entries = entries;
+ hol->num_entries = num_entries;
+ hol->short_options = short_options;
+ }
+ }
+
+ hol_free (more);
+}
+
+/* Inserts enough spaces to make sure STREAM is at column COL. */
+static void
+indent_to (argp_fmtstream_t stream, unsigned col)
+{
+ int needed = col - __argp_fmtstream_point (stream);
+ while (needed-- > 0)
+ __argp_fmtstream_putc (stream, ' ');
+}
+
+/* Output to STREAM either a space, or a newline if there isn't room for at
+ least ENSURE characters before the right margin. */
+static void
+space (argp_fmtstream_t stream, size_t ensure)
+{
+ if (__argp_fmtstream_point (stream) + ensure
+ >= __argp_fmtstream_rmargin (stream))
+ __argp_fmtstream_putc (stream, '\n');
+ else
+ __argp_fmtstream_putc (stream, ' ');
+}
+
+/* If the option REAL has an argument, we print it in using the printf
+ format REQ_FMT or OPT_FMT depending on whether it's a required or
+ optional argument. */
+static void
+arg (const struct argp_option *real, const char *req_fmt, const char *opt_fmt,
+ const char *domain UNUSED, argp_fmtstream_t stream)
+{
+ if (real->arg)
+ {
+ if (real->flags & OPTION_ARG_OPTIONAL)
+ __argp_fmtstream_printf (stream, opt_fmt,
+ dgettext (domain, real->arg));
+ else
+ __argp_fmtstream_printf (stream, req_fmt,
+ dgettext (domain, real->arg));
+ }
+}
+
+/* Helper functions for hol_entry_help. */
+
+/* State used during the execution of hol_help. */
+struct hol_help_state
+{
+ /* PREV_ENTRY should contain the previous entry printed, or 0. */
+ struct hol_entry *prev_entry;
+
+ /* If an entry is in a different group from the previous one, and SEP_GROUPS
+ is true, then a blank line will be printed before any output. */
+ int sep_groups;
+
+ /* True if a duplicate option argument was suppressed (only ever set if
+ UPARAMS.dup_args is false). */
+ int suppressed_dup_arg;
+};
+
+/* Some state used while printing a help entry (used to communicate with
+ helper functions). See the doc for hol_entry_help for more info, as most
+ of the fields are copied from its arguments. */
+struct pentry_state
+{
+ const struct hol_entry *entry;
+ argp_fmtstream_t stream;
+ struct hol_help_state *hhstate;
+
+ /* True if nothing's been printed so far. */
+ int first;
+
+ /* If non-zero, the state that was used to print this help. */
+ const struct argp_state *state;
+};
+
+/* If a user doc filter should be applied to DOC, do so. */
+static const char *
+filter_doc (const char *doc, int key, const struct argp *argp,
+ const struct argp_state *state)
+{
+ if (argp->help_filter)
+ /* We must apply a user filter to this output. */
+ {
+ void *input = __argp_input (argp, state);
+ return (*argp->help_filter) (key, doc, input);
+ }
+ else
+ /* No filter. */
+ return doc;
+}
+
+/* Prints STR as a header line, with the margin lines set appropiately, and
+ notes the fact that groups should be separated with a blank line. ARGP is
+ the argp that should dictate any user doc filtering to take place. Note
+ that the previous wrap margin isn't restored, but the left margin is reset
+ to 0. */
+static void
+print_header (const char *str, const struct argp *argp,
+ struct pentry_state *pest)
+{
+ const char *tstr = dgettext (argp->argp_domain, str);
+ const char *fstr = filter_doc (tstr, ARGP_KEY_HELP_HEADER, argp, pest->state);
+
+ if (fstr)
+ {
+ if (*fstr)
+ {
+ if (pest->hhstate->prev_entry)
+ /* Precede with a blank line. */
+ __argp_fmtstream_putc (pest->stream, '\n');
+ indent_to (pest->stream, uparams.header_col);
+ __argp_fmtstream_set_lmargin (pest->stream, uparams.header_col);
+ __argp_fmtstream_set_wmargin (pest->stream, uparams.header_col);
+ __argp_fmtstream_puts (pest->stream, fstr);
+ __argp_fmtstream_set_lmargin (pest->stream, 0);
+ __argp_fmtstream_putc (pest->stream, '\n');
+ }
+
+ pest->hhstate->sep_groups = 1; /* Separate subsequent groups. */
+ }
+
+ if (fstr != tstr)
+ free ((char *) fstr);
+}
+
+/* Inserts a comma if this isn't the first item on the line, and then makes
+ sure we're at least to column COL. If this *is* the first item on a line,
+ prints any pending whitespace/headers that should precede this line. Also
+ clears FIRST. */
+static void
+comma (unsigned col, struct pentry_state *pest)
+{
+ if (pest->first)
+ {
+ const struct hol_entry *pe = pest->hhstate->prev_entry;
+ const struct hol_cluster *cl = pest->entry->cluster;
+
+ if (pest->hhstate->sep_groups && pe && pest->entry->group != pe->group)
+ __argp_fmtstream_putc (pest->stream, '\n');
+
+ if (cl && cl->header && *cl->header
+ && (!pe
+ || (pe->cluster != cl
+ && !hol_cluster_is_child (pe->cluster, cl))))
+ /* If we're changing clusters, then this must be the start of the
+ ENTRY's cluster unless that is an ancestor of the previous one
+ (in which case we had just popped into a sub-cluster for a bit).
+ If so, then print the cluster's header line. */
+ {
+ int old_wm = __argp_fmtstream_wmargin (pest->stream);
+ print_header (cl->header, cl->argp, pest);
+ __argp_fmtstream_set_wmargin (pest->stream, old_wm);
+ }
+
+ pest->first = 0;
+ }
+ else
+ __argp_fmtstream_puts (pest->stream, ", ");
+
+ indent_to (pest->stream, col);
+}
+
+/* Print help for ENTRY to STREAM. */
+static void
+hol_entry_help (struct hol_entry *entry, const struct argp_state *state,
+ argp_fmtstream_t stream, struct hol_help_state *hhstate)
+{
+ unsigned num;
+ const struct argp_option *real = entry->opt, *opt;
+ char *so = entry->short_options;
+ int have_long_opt = 0; /* We have any long options. */
+ /* Saved margins. */
+ int old_lm = __argp_fmtstream_set_lmargin (stream, 0);
+ int old_wm = __argp_fmtstream_wmargin (stream);
+ /* PEST is a state block holding some of our variables that we'd like to
+ share with helper functions. */
+
+ /* Decent initializers are a GNU extension, so don't use it here. */
+ struct pentry_state pest;
+ pest.entry = entry;
+ pest.stream = stream;
+ pest.hhstate = hhstate;
+ pest.first = 1;
+ pest.state = state;
+
+ if (! odoc (real))
+ for (opt = real, num = entry->num; num > 0; opt++, num--)
+ if (opt->name && ovisible (opt))
+ {
+ have_long_opt = 1;
+ break;
+ }
+
+ /* First emit short options. */
+ __argp_fmtstream_set_wmargin (stream, uparams.short_opt_col); /* For truly bizarre cases. */
+ for (opt = real, num = entry->num; num > 0; opt++, num--)
+ if (oshort (opt) && opt->key == *so)
+ /* OPT has a valid (non shadowed) short option. */
+ {
+ if (ovisible (opt))
+ {
+ comma (uparams.short_opt_col, &pest);
+ __argp_fmtstream_putc (stream, '-');
+ __argp_fmtstream_putc (stream, *so);
+ if (!have_long_opt || uparams.dup_args)
+ arg (real, " %s", "[%s]", state->root_argp->argp_domain, stream);
+ else if (real->arg)
+ hhstate->suppressed_dup_arg = 1;
+ }
+ so++;
+ }
+
+ /* Now, long options. */
+ if (odoc (real))
+ /* A `documentation' option. */
+ {
+ __argp_fmtstream_set_wmargin (stream, uparams.doc_opt_col);
+ for (opt = real, num = entry->num; num > 0; opt++, num--)
+ if (opt->name && ovisible (opt))
+ {
+ comma (uparams.doc_opt_col, &pest);
+ /* Calling gettext here isn't quite right, since sorting will
+ have been done on the original; but documentation options
+ should be pretty rare anyway... */
+ __argp_fmtstream_puts (stream,
+ dgettext (state->root_argp->argp_domain,
+ opt->name));
+ }
+ }
+ else
+ /* A real long option. */
+ {
+ int first_long_opt = 1;
+
+ __argp_fmtstream_set_wmargin (stream, uparams.long_opt_col);
+ for (opt = real, num = entry->num; num > 0; opt++, num--)
+ if (opt->name && ovisible (opt))
+ {
+ comma (uparams.long_opt_col, &pest);
+ __argp_fmtstream_printf (stream, "--%s", opt->name);
+ if (first_long_opt || uparams.dup_args)
+ arg (real, "=%s", "[=%s]", state->root_argp->argp_domain,
+ stream);
+ else if (real->arg)
+ hhstate->suppressed_dup_arg = 1;
+ }
+ }
+
+ /* Next, documentation strings. */
+ __argp_fmtstream_set_lmargin (stream, 0);
+
+ if (pest.first)
+ {
+ /* Didn't print any switches, what's up? */
+ if (!oshort (real) && !real->name)
+ /* This is a group header, print it nicely. */
+ print_header (real->doc, entry->argp, &pest);
+ else
+ /* Just a totally shadowed option or null header; print nothing. */
+ goto cleanup; /* Just return, after cleaning up. */
+ }
+ else
+ {
+ const char *tstr = real->doc ? dgettext (state->root_argp->argp_domain,
+ real->doc) : 0;
+ const char *fstr = filter_doc (tstr, real->key, entry->argp, state);
+ if (fstr && *fstr)
+ {
+ unsigned int col = __argp_fmtstream_point (stream);
+
+ __argp_fmtstream_set_lmargin (stream, uparams.opt_doc_col);
+ __argp_fmtstream_set_wmargin (stream, uparams.opt_doc_col);
+
+ if (col > (unsigned int) (uparams.opt_doc_col + 3))
+ __argp_fmtstream_putc (stream, '\n');
+ else if (col >= (unsigned int) uparams.opt_doc_col)
+ __argp_fmtstream_puts (stream, " ");
+ else
+ indent_to (stream, uparams.opt_doc_col);
+
+ __argp_fmtstream_puts (stream, fstr);
+ }
+ if (fstr && fstr != tstr)
+ free ((char *) fstr);
+
+ /* Reset the left margin. */
+ __argp_fmtstream_set_lmargin (stream, 0);
+ __argp_fmtstream_putc (stream, '\n');
+ }
+
+ hhstate->prev_entry = entry;
+
+cleanup:
+ __argp_fmtstream_set_lmargin (stream, old_lm);
+ __argp_fmtstream_set_wmargin (stream, old_wm);
+}
+
+/* Output a long help message about the options in HOL to STREAM. */
+static void
+hol_help (struct hol *hol, const struct argp_state *state,
+ argp_fmtstream_t stream)
+{
+ unsigned num;
+ struct hol_entry *entry;
+ struct hol_help_state hhstate = { 0, 0, 0 };
+
+ for (entry = hol->entries, num = hol->num_entries; num > 0; entry++, num--)
+ hol_entry_help (entry, state, stream, &hhstate);
+
+ if (hhstate.suppressed_dup_arg && uparams.dup_args_note)
+ {
+ const char *tstr = dgettext (state->root_argp->argp_domain, "\
+Mandatory or optional arguments to long options are also mandatory or \
+optional for any corresponding short options.");
+ const char *fstr = filter_doc (tstr, ARGP_KEY_HELP_DUP_ARGS_NOTE,
+ state ? state->root_argp : 0, state);
+ if (fstr && *fstr)
+ {
+ __argp_fmtstream_putc (stream, '\n');
+ __argp_fmtstream_puts (stream, fstr);
+ __argp_fmtstream_putc (stream, '\n');
+ }
+ if (fstr && fstr != tstr)
+ free ((char *) fstr);
+ }
+}
+
+/* Helper functions for hol_usage. */
+
+/* If OPT is a short option without an arg, append its key to the string
+ pointer pointer to by COOKIE, and advance the pointer. */
+static int
+add_argless_short_opt (const struct argp_option *opt,
+ const struct argp_option *real,
+ const char *domain UNUSED, void *cookie)
+{
+ char **snao_end = cookie;
+ if (!(opt->arg || real->arg)
+ && !((opt->flags | real->flags) & OPTION_NO_USAGE))
+ *(*snao_end)++ = opt->key;
+ return 0;
+}
+
+/* If OPT is a short option with an arg, output a usage entry for it to the
+ stream pointed at by COOKIE. */
+static int
+usage_argful_short_opt (const struct argp_option *opt,
+ const struct argp_option *real,
+ const char *domain UNUSED, void *cookie)
+{
+ argp_fmtstream_t stream = cookie;
+ const char *arg = opt->arg;
+ int flags = opt->flags | real->flags;
+
+ if (! arg)
+ arg = real->arg;
+
+ if (arg && !(flags & OPTION_NO_USAGE))
+ {
+ arg = dgettext (domain, arg);
+
+ if (flags & OPTION_ARG_OPTIONAL)
+ __argp_fmtstream_printf (stream, " [-%c[%s]]", opt->key, arg);
+ else
+ {
+ /* Manually do line wrapping so that it (probably) won't
+ get wrapped at the embedded space. */
+ space (stream, 6 + strlen (arg));
+ __argp_fmtstream_printf (stream, "[-%c %s]", opt->key, arg);
+ }
+ }
+
+ return 0;
+}
+
+/* Output a usage entry for the long option opt to the stream pointed at by
+ COOKIE. */
+static int
+usage_long_opt (const struct argp_option *opt,
+ const struct argp_option *real,
+ const char *domain UNUSED, void *cookie)
+{
+ argp_fmtstream_t stream = cookie;
+ const char *arg = opt->arg;
+ int flags = opt->flags | real->flags;
+
+ if (! arg)
+ arg = real->arg;
+
+ if (! (flags & OPTION_NO_USAGE))
+ {
+ if (arg)
+ {
+ arg = dgettext (domain, arg);
+ if (flags & OPTION_ARG_OPTIONAL)
+ __argp_fmtstream_printf (stream, " [--%s[=%s]]", opt->name, arg);
+ else
+ __argp_fmtstream_printf (stream, " [--%s=%s]", opt->name, arg);
+ }
+ else
+ __argp_fmtstream_printf (stream, " [--%s]", opt->name);
+ }
+
+ return 0;
+}
+
+/* Print a short usage description for the arguments in HOL to STREAM. */
+static void
+hol_usage (struct hol *hol, argp_fmtstream_t stream)
+{
+ if (hol->num_entries > 0)
+ {
+ unsigned nentries;
+ struct hol_entry *entry;
+ char *short_no_arg_opts = alloca (strlen (hol->short_options) + 1);
+ char *snao_end = short_no_arg_opts;
+
+ /* First we put a list of short options without arguments. */
+ for (entry = hol->entries, nentries = hol->num_entries
+ ; nentries > 0
+ ; entry++, nentries--)
+ hol_entry_short_iterate (entry, add_argless_short_opt,
+ entry->argp->argp_domain, &snao_end);
+ if (snao_end > short_no_arg_opts)
+ {
+ *snao_end++ = 0;
+ __argp_fmtstream_printf (stream, " [-%s]", short_no_arg_opts);
+ }
+
+ /* Now a list of short options *with* arguments. */
+ for (entry = hol->entries, nentries = hol->num_entries
+ ; nentries > 0
+ ; entry++, nentries--)
+ hol_entry_short_iterate (entry, usage_argful_short_opt,
+ entry->argp->argp_domain, stream);
+
+ /* Finally, a list of long options (whew!). */
+ for (entry = hol->entries, nentries = hol->num_entries
+ ; nentries > 0
+ ; entry++, nentries--)
+ hol_entry_long_iterate (entry, usage_long_opt,
+ entry->argp->argp_domain, stream);
+ }
+}
+
+/* Make a HOL containing all levels of options in ARGP. CLUSTER is the
+ cluster in which ARGP's entries should be clustered, or 0. */
+static struct hol *
+argp_hol (const struct argp *argp, struct hol_cluster *cluster)
+{
+ const struct argp_child *child = argp->children;
+ struct hol *hol = make_hol (argp, cluster);
+ if (child)
+ while (child->argp)
+ {
+ struct hol_cluster *child_cluster =
+ ((child->group || child->header)
+ /* Put CHILD->argp within its own cluster. */
+ ? hol_add_cluster (hol, child->group, child->header,
+ child - argp->children, cluster, argp)
+ /* Just merge it into the parent's cluster. */
+ : cluster);
+ hol_append (hol, argp_hol (child->argp, child_cluster)) ;
+ child++;
+ }
+ return hol;
+}
+
+/* Calculate how many different levels with alternative args strings exist in
+ ARGP. */
+static size_t
+argp_args_levels (const struct argp *argp)
+{
+ size_t levels = 0;
+ const struct argp_child *child = argp->children;
+
+ if (argp->args_doc && strchr (argp->args_doc, '\n'))
+ levels++;
+
+ if (child)
+ while (child->argp)
+ levels += argp_args_levels ((child++)->argp);
+
+ return levels;
+}
+
+/* Print all the non-option args documented in ARGP to STREAM. Any output is
+ preceded by a space. LEVELS is a pointer to a byte vector the length
+ returned by argp_args_levels; it should be initialized to zero, and
+ updated by this routine for the next call if ADVANCE is true. True is
+ returned as long as there are more patterns to output. */
+static int
+argp_args_usage (const struct argp *argp, const struct argp_state *state,
+ char **levels, int advance, argp_fmtstream_t stream)
+{
+ char *our_level = *levels;
+ int multiple = 0;
+ const struct argp_child *child = argp->children;
+ const char *tdoc = dgettext (argp->argp_domain, argp->args_doc), *nl = 0;
+ const char *fdoc = filter_doc (tdoc, ARGP_KEY_HELP_ARGS_DOC, argp, state);
+
+ if (fdoc)
+ {
+ const char *cp = fdoc;
+ nl = __strchrnul (cp, '\n');
+ if (*nl != '\0')
+ /* This is a `multi-level' args doc; advance to the correct position
+ as determined by our state in LEVELS, and update LEVELS. */
+ {
+ int i;
+ multiple = 1;
+ for (i = 0; i < *our_level; i++)
+ cp = nl + 1, nl = __strchrnul (cp, '\n');
+ (*levels)++;
+ }
+
+ /* Manually do line wrapping so that it (probably) won't get wrapped at
+ any embedded spaces. */
+ space (stream, 1 + nl - cp);
+
+ __argp_fmtstream_write (stream, cp, nl - cp);
+ }
+ if (fdoc && fdoc != tdoc)
+ free ((char *)fdoc); /* Free user's modified doc string. */
+
+ if (child)
+ while (child->argp)
+ advance = !argp_args_usage ((child++)->argp, state, levels, advance, stream);
+
+ if (advance && multiple)
+ {
+ /* Need to increment our level. */
+ if (*nl)
+ /* There's more we can do here. */
+ {
+ (*our_level)++;
+ advance = 0; /* Our parent shouldn't advance also. */
+ }
+ else if (*our_level > 0)
+ /* We had multiple levels, but used them up; reset to zero. */
+ *our_level = 0;
+ }
+
+ return !advance;
+}
+
+/* Print the documentation for ARGP to STREAM; if POST is false, then
+ everything preceeding a `\v' character in the documentation strings (or
+ the whole string, for those with none) is printed, otherwise, everything
+ following the `\v' character (nothing for strings without). Each separate
+ bit of documentation is separated a blank line, and if PRE_BLANK is true,
+ then the first is as well. If FIRST_ONLY is true, only the first
+ occurrence is output. Returns true if anything was output. */
+static int
+argp_doc (const struct argp *argp, const struct argp_state *state,
+ int post, int pre_blank, int first_only,
+ argp_fmtstream_t stream)
+{
+ const char *text;
+ const char *inp_text;
+ void *input = 0;
+ int anything = 0;
+ size_t inp_text_limit = 0;
+ const char *doc = dgettext (argp->argp_domain, argp->doc);
+ const struct argp_child *child = argp->children;
+
+ if (doc)
+ {
+ char *vt = strchr (doc, '\v');
+ inp_text = post ? (vt ? vt + 1 : 0) : doc;
+ inp_text_limit = (!post && vt) ? (vt - doc) : 0;
+ }
+ else
+ inp_text = 0;
+
+ if (argp->help_filter)
+ /* We have to filter the doc strings. */
+ {
+ if (inp_text_limit)
+ /* Copy INP_TEXT so that it's nul-terminated. */
+ inp_text = STRNDUP (inp_text, inp_text_limit);
+ input = __argp_input (argp, state);
+ text =
+ (*argp->help_filter) (post
+ ? ARGP_KEY_HELP_POST_DOC
+ : ARGP_KEY_HELP_PRE_DOC,
+ inp_text, input);
+ }
+ else
+ text = (const char *) inp_text;
+
+ if (text)
+ {
+ if (pre_blank)
+ __argp_fmtstream_putc (stream, '\n');
+
+ if (text == inp_text && inp_text_limit)
+ __argp_fmtstream_write (stream, inp_text, inp_text_limit);
+ else
+ __argp_fmtstream_puts (stream, text);
+
+ if (__argp_fmtstream_point (stream) > __argp_fmtstream_lmargin (stream))
+ __argp_fmtstream_putc (stream, '\n');
+
+ anything = 1;
+ }
+
+ if (text && text != inp_text)
+ free ((char *) text); /* Free TEXT returned from the help filter. */
+ if (inp_text && inp_text_limit && argp->help_filter)
+ free ((char *) inp_text); /* We copied INP_TEXT, so free it now. */
+
+ if (post && argp->help_filter)
+ /* Now see if we have to output a ARGP_KEY_HELP_EXTRA text. */
+ {
+ text = (*argp->help_filter) (ARGP_KEY_HELP_EXTRA, 0, input);
+ if (text)
+ {
+ if (anything || pre_blank)
+ __argp_fmtstream_putc (stream, '\n');
+ __argp_fmtstream_puts (stream, text);
+ free ((char *) text);
+ if (__argp_fmtstream_point (stream)
+ > __argp_fmtstream_lmargin (stream))
+ __argp_fmtstream_putc (stream, '\n');
+ anything = 1;
+ }
+ }
+
+ if (child)
+ while (child->argp && !(first_only && anything))
+ anything |=
+ argp_doc ((child++)->argp, state,
+ post, anything || pre_blank, first_only,
+ stream);
+
+ return anything;
+}
+
+/* Output a usage message for ARGP to STREAM. If called from
+ argp_state_help, STATE is the relevent parsing state. FLAGS are from the
+ set ARGP_HELP_*. NAME is what to use wherever a `program name' is
+ needed. */
+
+static void
+_help (const struct argp *argp, const struct argp_state *state, FILE *stream,
+ unsigned flags, const char *name)
+{
+ int anything = 0; /* Whether we've output anything. */
+ struct hol *hol = 0;
+ argp_fmtstream_t fs;
+
+ if (! stream)
+ return;
+
+ FLOCKFILE (stream);
+
+ if (! uparams.valid)
+ fill_in_uparams (state);
+
+ fs = __argp_make_fmtstream (stream, 0, uparams.rmargin, 0);
+ if (! fs)
+ {
+ FUNLOCKFILE (stream);
+ return;
+ }
+
+ if (flags & (ARGP_HELP_USAGE | ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG))
+ {
+ hol = argp_hol (argp, 0);
+
+ /* If present, these options always come last. */
+ hol_set_group (hol, "help", -1);
+ hol_set_group (hol, "version", -1);
+
+ hol_sort (hol);
+ }
+
+ if (flags & (ARGP_HELP_USAGE | ARGP_HELP_SHORT_USAGE))
+ /* Print a short `Usage:' message. */
+ {
+ int first_pattern = 1, more_patterns;
+ size_t num_pattern_levels = argp_args_levels (argp);
+ char *pattern_levels = alloca (num_pattern_levels);
+
+ memset (pattern_levels, 0, num_pattern_levels);
+
+ do
+ {
+ int old_lm;
+ int old_wm = __argp_fmtstream_set_wmargin (fs, uparams.usage_indent);
+ char *levels = pattern_levels;
+
+ if (first_pattern)
+ __argp_fmtstream_printf (fs, "%s %s",
+ dgettext (argp->argp_domain, "Usage:"),
+ name);
+ else
+ __argp_fmtstream_printf (fs, "%s %s",
+ dgettext (argp->argp_domain, " or: "),
+ name);
+
+ /* We set the lmargin as well as the wmargin, because hol_usage
+ manually wraps options with newline to avoid annoying breaks. */
+ old_lm = __argp_fmtstream_set_lmargin (fs, uparams.usage_indent);
+
+ if (flags & ARGP_HELP_SHORT_USAGE)
+ /* Just show where the options go. */
+ {
+ if (hol->num_entries > 0)
+ __argp_fmtstream_puts (fs, dgettext (argp->argp_domain,
+ " [OPTION...]"));
+ }
+ else
+ /* Actually print the options. */
+ {
+ hol_usage (hol, fs);
+ flags |= ARGP_HELP_SHORT_USAGE; /* But only do so once. */
+ }
+
+ more_patterns = argp_args_usage (argp, state, &levels, 1, fs);
+
+ __argp_fmtstream_set_wmargin (fs, old_wm);
+ __argp_fmtstream_set_lmargin (fs, old_lm);
+
+ __argp_fmtstream_putc (fs, '\n');
+ anything = 1;
+
+ first_pattern = 0;
+ }
+ while (more_patterns);
+ }
+
+ if (flags & ARGP_HELP_PRE_DOC)
+ anything |= argp_doc (argp, state, 0, 0, 1, fs);
+
+ if (flags & ARGP_HELP_SEE)
+ {
+ __argp_fmtstream_printf (fs, dgettext (argp->argp_domain, "\
+Try `%s --help' or `%s --usage' for more information.\n"),
+ name, name);
+ anything = 1;
+ }
+
+ if (flags & ARGP_HELP_LONG)
+ /* Print a long, detailed help message. */
+ {
+ /* Print info about all the options. */
+ if (hol->num_entries > 0)
+ {
+ if (anything)
+ __argp_fmtstream_putc (fs, '\n');
+ hol_help (hol, state, fs);
+ anything = 1;
+ }
+ }
+
+ if (flags & ARGP_HELP_POST_DOC)
+ /* Print any documentation strings at the end. */
+ anything |= argp_doc (argp, state, 1, anything, 0, fs);
+
+ if ((flags & ARGP_HELP_BUG_ADDR) && argp_program_bug_address)
+ {
+ if (anything)
+ __argp_fmtstream_putc (fs, '\n');
+ __argp_fmtstream_printf (fs, dgettext (argp->argp_domain,
+ "Report bugs to %s.\n"),
+ argp_program_bug_address);
+ anything = 1;
+ }
+
+ FUNLOCKFILE (stream);
+
+ if (hol)
+ hol_free (hol);
+
+ __argp_fmtstream_free (fs);
+}
+
+/* Output a usage message for ARGP to STREAM. FLAGS are from the set
+ ARGP_HELP_*. NAME is what to use wherever a `program name' is needed. */
+void __argp_help (const struct argp *argp, FILE *stream,
+ unsigned flags, char *name)
+{
+ _help (argp, 0, stream, flags, name);
+}
+#ifdef weak_alias
+weak_alias (__argp_help, argp_help)
+#endif
+
+char *__argp_basename(char *name)
+{
+ char *short_name = strrchr(name, '/');
+ return short_name ? short_name + 1 : name;
+}
+
+char *
+__argp_short_program_name(const struct argp_state *state)
+{
+ if (state)
+ return state->name;
+#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
+ return program_invocation_short_name;
+#elif HAVE_DECL_PROGRAM_INVOCATION_NAME
+ return __argp_basename(program_invocation_name);
+#else /* !HAVE_DECL_PROGRAM_INVOCATION_NAME */
+ /* FIXME: What now? Miles suggests that it is better to use NULL,
+ but currently the value is passed on directly to fputs_unlocked,
+ so that requires more changes. */
+# if __GNUC__
+ return "";
+# endif /* __GNUC__ */
+#endif /* !HAVE_DECL_PROGRAM_INVOCATION_NAME */
+}
+
+/* Output, if appropriate, a usage message for STATE to STREAM. FLAGS are
+ from the set ARGP_HELP_*. */
+void
+__argp_state_help (const struct argp_state *state, FILE *stream, unsigned flags)
+{
+ if ((!state || ! (state->flags & ARGP_NO_ERRS)) && stream)
+ {
+ if (state && (state->flags & ARGP_LONG_ONLY))
+ flags |= ARGP_HELP_LONG_ONLY;
+
+ _help (state ? state->root_argp : 0, state, stream, flags,
+ __argp_short_program_name(state));
+
+ if (!state || ! (state->flags & ARGP_NO_EXIT))
+ {
+ if (flags & ARGP_HELP_EXIT_ERR)
+ exit (argp_err_exit_status);
+ if (flags & ARGP_HELP_EXIT_OK)
+ exit (0);
+ }
+ }
+}
+#ifdef weak_alias
+weak_alias (__argp_state_help, argp_state_help)
+#endif
+
+/* If appropriate, print the printf string FMT and following args, preceded
+ by the program name and `:', to stderr, and followed by a `Try ... --help'
+ message, then exit (1). */
+void
+__argp_error (const struct argp_state *state, const char *fmt, ...)
+{
+ if (!state || !(state->flags & ARGP_NO_ERRS))
+ {
+ FILE *stream = state ? state->err_stream : stderr;
+
+ if (stream)
+ {
+ va_list ap;
+
+ FLOCKFILE (stream);
+
+ FPUTS_UNLOCKED (__argp_short_program_name(state),
+ stream);
+ PUTC_UNLOCKED (':', stream);
+ PUTC_UNLOCKED (' ', stream);
+
+ va_start (ap, fmt);
+ vfprintf (stream, fmt, ap);
+ va_end (ap);
+
+ PUTC_UNLOCKED ('\n', stream);
+
+ __argp_state_help (state, stream, ARGP_HELP_STD_ERR);
+
+ FUNLOCKFILE (stream);
+ }
+ }
+}
+#ifdef weak_alias
+weak_alias (__argp_error, argp_error)
+#endif
+
+/* Similar to the standard gnu error-reporting function error(), but will
+ respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print
+ to STATE->err_stream. This is useful for argument parsing code that is
+ shared between program startup (when exiting is desired) and runtime
+ option parsing (when typically an error code is returned instead). The
+ difference between this function and argp_error is that the latter is for
+ *parsing errors*, and the former is for other problems that occur during
+ parsing but don't reflect a (syntactic) problem with the input. */
+void
+__argp_failure (const struct argp_state *state, int status, int errnum,
+ const char *fmt, ...)
+{
+ if (!state || !(state->flags & ARGP_NO_ERRS))
+ {
+ FILE *stream = state ? state->err_stream : stderr;
+
+ if (stream)
+ {
+ FLOCKFILE (stream);
+
+ FPUTS_UNLOCKED (__argp_short_program_name(state),
+ stream);
+
+ if (fmt)
+ {
+ va_list ap;
+
+ PUTC_UNLOCKED (':', stream);
+ PUTC_UNLOCKED (' ', stream);
+
+ va_start (ap, fmt);
+ vfprintf (stream, fmt, ap);
+ va_end (ap);
+ }
+
+ if (errnum)
+ {
+ PUTC_UNLOCKED (':', stream);
+ PUTC_UNLOCKED (' ', stream);
+ fputs (STRERROR (errnum), stream);
+ }
+
+ PUTC_UNLOCKED ('\n', stream);
+
+ FUNLOCKFILE (stream);
+
+ if (status && (!state || !(state->flags & ARGP_NO_EXIT)))
+ exit (status);
+ }
+ }
+}
+#ifdef weak_alias
+weak_alias (__argp_failure, argp_failure)
+#endif
diff --git a/argp-standalone/argp-namefrob.h b/argp-standalone/argp-namefrob.h
new file mode 100644
index 0000000..0ce1148
--- /dev/null
+++ b/argp-standalone/argp-namefrob.h
@@ -0,0 +1,96 @@
+/* Name frobnication for compiling argp outside of glibc
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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 Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#if !_LIBC
+/* This code is written for inclusion in gnu-libc, and uses names in the
+ namespace reserved for libc. If we're not compiling in libc, define those
+ names to be the normal ones instead. */
+
+/* argp-parse functions */
+#undef __argp_parse
+#define __argp_parse argp_parse
+#undef __option_is_end
+#define __option_is_end _option_is_end
+#undef __option_is_short
+#define __option_is_short _option_is_short
+#undef __argp_input
+#define __argp_input _argp_input
+
+/* argp-help functions */
+#undef __argp_help
+#define __argp_help argp_help
+#undef __argp_error
+#define __argp_error argp_error
+#undef __argp_failure
+#define __argp_failure argp_failure
+#undef __argp_state_help
+#define __argp_state_help argp_state_help
+#undef __argp_usage
+#define __argp_usage argp_usage
+#undef __argp_basename
+#define __argp_basename _argp_basename
+#undef __argp_short_program_name
+#define __argp_short_program_name _argp_short_program_name
+
+/* argp-fmtstream functions */
+#undef __argp_make_fmtstream
+#define __argp_make_fmtstream argp_make_fmtstream
+#undef __argp_fmtstream_free
+#define __argp_fmtstream_free argp_fmtstream_free
+#undef __argp_fmtstream_putc
+#define __argp_fmtstream_putc argp_fmtstream_putc
+#undef __argp_fmtstream_puts
+#define __argp_fmtstream_puts argp_fmtstream_puts
+#undef __argp_fmtstream_write
+#define __argp_fmtstream_write argp_fmtstream_write
+#undef __argp_fmtstream_printf
+#define __argp_fmtstream_printf argp_fmtstream_printf
+#undef __argp_fmtstream_set_lmargin
+#define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin
+#undef __argp_fmtstream_set_rmargin
+#define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin
+#undef __argp_fmtstream_set_wmargin
+#define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin
+#undef __argp_fmtstream_point
+#define __argp_fmtstream_point argp_fmtstream_point
+#undef __argp_fmtstream_update
+#define __argp_fmtstream_update _argp_fmtstream_update
+#undef __argp_fmtstream_ensure
+#define __argp_fmtstream_ensure _argp_fmtstream_ensure
+#undef __argp_fmtstream_lmargin
+#define __argp_fmtstream_lmargin argp_fmtstream_lmargin
+#undef __argp_fmtstream_rmargin
+#define __argp_fmtstream_rmargin argp_fmtstream_rmargin
+#undef __argp_fmtstream_wmargin
+#define __argp_fmtstream_wmargin argp_fmtstream_wmargin
+
+/* normal libc functions we call */
+#undef __sleep
+#define __sleep sleep
+#undef __strcasecmp
+#define __strcasecmp strcasecmp
+#undef __vsnprintf
+#define __vsnprintf vsnprintf
+
+#endif /* !_LIBC */
+
+#ifndef __set_errno
+#define __set_errno(e) (errno = (e))
+#endif
diff --git a/argp-standalone/argp-parse.c b/argp-standalone/argp-parse.c
new file mode 100644
index 0000000..78f7bf1
--- /dev/null
+++ b/argp-standalone/argp-parse.c
@@ -0,0 +1,1305 @@
+/* Hierarchial argument parsing
+ Copyright (C) 1995, 96, 97, 98, 99, 2000,2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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 Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <limits.h>
+#include <assert.h>
+
+#if HAVE_MALLOC_H
+/* Needed, for alloca on windows */
+# include <malloc.h>
+#endif
+
+#ifndef _
+/* This is for other GNU distributions with internationalized messages.
+ When compiling libc, the _ macro is predefined. */
+# if defined HAVE_LIBINTL_H || defined _LIBC
+# include <libintl.h>
+# ifdef _LIBC
+# undef dgettext
+# define dgettext(domain, msgid) __dcgettext (domain, msgid, LC_MESSAGES)
+# endif
+# else
+# define dgettext(domain, msgid) (msgid)
+# define gettext(msgid) (msgid)
+# endif
+#endif
+#ifndef N_
+# define N_(msgid) (msgid)
+#endif
+
+#if _LIBC - 0
+#include <bits/libc-lock.h>
+#else
+#ifdef HAVE_CTHREADS_H
+#include <cthreads.h>
+#endif
+#endif /* _LIBC */
+
+#include "argp.h"
+#include "argp-namefrob.h"
+
+
+/* The meta-argument used to prevent any further arguments being interpreted
+ as options. */
+#define QUOTE "--"
+
+/* EZ alias for ARGP_ERR_UNKNOWN. */
+#define EBADKEY ARGP_ERR_UNKNOWN
+
+
+/* Default options. */
+
+/* When argp is given the --HANG switch, _ARGP_HANG is set and argp will sleep
+ for one second intervals, decrementing _ARGP_HANG until it's zero. Thus
+ you can force the program to continue by attaching a debugger and setting
+ it to 0 yourself. */
+volatile int _argp_hang;
+
+#define OPT_PROGNAME -2
+#define OPT_USAGE -3
+#if HAVE_SLEEP && HAVE_GETPID
+#define OPT_HANG -4
+#endif
+
+static const struct argp_option argp_default_options[] =
+{
+ {"help", '?', 0, 0, N_("Give this help list"), -1},
+ {"usage", OPT_USAGE, 0, 0, N_("Give a short usage message"), 0 },
+ {"program-name",OPT_PROGNAME,"NAME", OPTION_HIDDEN,
+ N_("Set the program name"), 0},
+#if OPT_HANG
+ {"HANG", OPT_HANG, "SECS", OPTION_ARG_OPTIONAL | OPTION_HIDDEN,
+ N_("Hang for SECS seconds (default 3600)"), 0 },
+#endif
+ {0, 0, 0, 0, 0, 0}
+};
+
+static error_t
+argp_default_parser (int key, char *arg, struct argp_state *state)
+{
+ switch (key)
+ {
+ case '?':
+ __argp_state_help (state, state->out_stream, ARGP_HELP_STD_HELP);
+ break;
+ case OPT_USAGE:
+ __argp_state_help (state, state->out_stream,
+ ARGP_HELP_USAGE | ARGP_HELP_EXIT_OK);
+ break;
+
+ case OPT_PROGNAME: /* Set the program name. */
+#if HAVE_DECL_PROGRAM_INVOCATION_NAME
+ program_invocation_name = arg;
+#endif
+ /* [Note that some systems only have PROGRAM_INVOCATION_SHORT_NAME (aka
+ __PROGNAME), in which case, PROGRAM_INVOCATION_NAME is just defined
+ to be that, so we have to be a bit careful here.] */
+
+ /* Update what we use for messages. */
+
+ state->name = __argp_basename(arg);
+
+#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
+ program_invocation_short_name = state->name;
+#endif
+
+ if ((state->flags & (ARGP_PARSE_ARGV0 | ARGP_NO_ERRS))
+ == ARGP_PARSE_ARGV0)
+ /* Update what getopt uses too. */
+ state->argv[0] = arg;
+
+ break;
+
+#if OPT_HANG
+ case OPT_HANG:
+ _argp_hang = atoi (arg ? arg : "3600");
+ fprintf(state->err_stream, "%s: pid = %ld\n",
+ state->name, (long) getpid());
+ while (_argp_hang-- > 0)
+ __sleep (1);
+ break;
+#endif
+
+ default:
+ return EBADKEY;
+ }
+ return 0;
+}
+
+static const struct argp argp_default_argp =
+ {argp_default_options, &argp_default_parser, NULL, NULL, NULL, NULL, "libc"};
+
+
+static const struct argp_option argp_version_options[] =
+{
+ {"version", 'V', 0, 0, N_("Print program version"), -1},
+ {0, 0, 0, 0, 0, 0 }
+};
+
+static error_t
+argp_version_parser (int key, char *arg UNUSED, struct argp_state *state)
+{
+ switch (key)
+ {
+ case 'V':
+ if (argp_program_version_hook)
+ (*argp_program_version_hook) (state->out_stream, state);
+ else if (argp_program_version)
+ fprintf (state->out_stream, "%s\n", argp_program_version);
+ else
+ __argp_error (state, dgettext (state->root_argp->argp_domain,
+ "(PROGRAM ERROR) No version known!?"));
+ if (! (state->flags & ARGP_NO_EXIT))
+ exit (0);
+ break;
+ default:
+ return EBADKEY;
+ }
+ return 0;
+}
+
+static const struct argp argp_version_argp =
+ {argp_version_options, &argp_version_parser, NULL, NULL, NULL, NULL, "libc"};
+
+
+
+/* The state of a `group' during parsing. Each group corresponds to a
+ particular argp structure from the tree of such descending from the top
+ level argp passed to argp_parse. */
+struct group
+{
+ /* This group's parsing function. */
+ argp_parser_t parser;
+
+ /* Which argp this group is from. */
+ const struct argp *argp;
+
+ /* The number of non-option args sucessfully handled by this parser. */
+ unsigned args_processed;
+
+ /* This group's parser's parent's group. */
+ struct group *parent;
+ unsigned parent_index; /* And the our position in the parent. */
+
+ /* These fields are swapped into and out of the state structure when
+ calling this group's parser. */
+ void *input, **child_inputs;
+ void *hook;
+};
+
+/* Call GROUP's parser with KEY and ARG, swapping any group-specific info
+ from STATE before calling, and back into state afterwards. If GROUP has
+ no parser, EBADKEY is returned. */
+static error_t
+group_parse (struct group *group, struct argp_state *state, int key, char *arg)
+{
+ if (group->parser)
+ {
+ error_t err;
+ state->hook = group->hook;
+ state->input = group->input;
+ state->child_inputs = group->child_inputs;
+ state->arg_num = group->args_processed;
+ err = (*group->parser)(key, arg, state);
+ group->hook = state->hook;
+ return err;
+ }
+ else
+ return EBADKEY;
+}
+
+struct parser
+{
+ const struct argp *argp;
+
+ const char *posixly_correct;
+
+ /* True if there are only no-option arguments left, which are just
+ passed verbatim with ARGP_KEY_ARG. This is set if we encounter a
+ quote, or the end of the proper options, but may be cleared again
+ if the user moves the next argument pointer backwards. */
+ int args_only;
+
+ /* Describe how to deal with options that follow non-option ARGV-elements.
+
+ If the caller did not specify anything, the default is
+ REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is
+ defined, PERMUTE otherwise.
+
+ REQUIRE_ORDER means don't recognize them as options; stop option
+ processing when the first non-option is seen. This is what Unix
+ does. This mode of operation is selected by either setting the
+ environment variable POSIXLY_CORRECT, or using `+' as the first
+ character of the list of option characters.
+
+ PERMUTE is the default. We permute the contents of ARGV as we
+ scan, so that eventually all the non-options are at the end. This
+ allows options to be given in any order, even with programs that
+ were not written to expect this.
+
+ RETURN_IN_ORDER is an option available to programs that were
+ written to expect options and other ARGV-elements in any order
+ and that care about the ordering of the two. We describe each
+ non-option ARGV-element as if it were the argument of an option
+ with character code 1. Using `-' as the first character of the
+ list of option characters selects this mode of operation.
+
+ */
+ enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering;
+
+ /* A segment of non-option arguments that have been skipped for
+ later processing, after all options. `first_nonopt' is the index
+ in ARGV of the first of them; `last_nonopt' is the index after
+ the last of them.
+
+ If quoted or args_only is non-zero, this segment should be empty. */
+
+ /* FIXME: I'd prefer to use unsigned, but it's more consistent to
+ use the same type as for state.next. */
+ int first_nonopt;
+ int last_nonopt;
+
+ /* String of all recognized short options. Needed for ARGP_LONG_ONLY. */
+ /* FIXME: Perhaps change to a pointer to a suitable bitmap instead? */
+ char *short_opts;
+
+ /* For parsing combined short options. */
+ char *nextchar;
+
+ /* States of the various parsing groups. */
+ struct group *groups;
+ /* The end of the GROUPS array. */
+ struct group *egroup;
+ /* An vector containing storage for the CHILD_INPUTS field in all groups. */
+ void **child_inputs;
+
+ /* State block supplied to parsing routines. */
+ struct argp_state state;
+
+ /* Memory used by this parser. */
+ void *storage;
+};
+
+/* Search for a group defining a short option. */
+static const struct argp_option *
+find_short_option(struct parser *parser, int key, struct group **p)
+{
+ struct group *group;
+
+ assert(key >= 0);
+ assert(isascii(key));
+
+ for (group = parser->groups; group < parser->egroup; group++)
+ {
+ const struct argp_option *opts;
+
+ for (opts = group->argp->options; !__option_is_end(opts); opts++)
+ if (opts->key == key)
+ {
+ *p = group;
+ return opts;
+ }
+ }
+ return NULL;
+}
+
+enum match_result { MATCH_EXACT, MATCH_PARTIAL, MATCH_NO };
+
+/* If defined, allow complete.el-like abbreviations of long options. */
+#ifndef ARGP_COMPLETE
+#define ARGP_COMPLETE 0
+#endif
+
+/* Matches an encountern long-option argument ARG against an option NAME.
+ * ARG is terminated by NUL or '='. */
+static enum match_result
+match_option(const char *arg, const char *name)
+{
+ unsigned i, j;
+ for (i = j = 0;; i++, j++)
+ {
+ switch(arg[i])
+ {
+ case '\0':
+ case '=':
+ return name[j] ? MATCH_PARTIAL : MATCH_EXACT;
+#if ARGP_COMPLETE
+ case '-':
+ while (name[j] != '-')
+ if (!name[j++])
+ return MATCH_NO;
+ break;
+#endif
+ default:
+ if (arg[i] != name[j])
+ return MATCH_NO;
+ }
+ }
+}
+
+static const struct argp_option *
+find_long_option(struct parser *parser,
+ const char *arg,
+ struct group **p)
+{
+ struct group *group;
+
+ /* Partial match found so far. */
+ struct group *matched_group = NULL;
+ const struct argp_option *matched_option = NULL;
+
+ /* Number of partial matches. */
+ int num_partial = 0;
+
+ for (group = parser->groups; group < parser->egroup; group++)
+ {
+ const struct argp_option *opts;
+
+ for (opts = group->argp->options; !__option_is_end(opts); opts++)
+ {
+ if (!opts->name)
+ continue;
+ switch (match_option(arg, opts->name))
+ {
+ case MATCH_NO:
+ break;
+ case MATCH_PARTIAL:
+ num_partial++;
+
+ matched_group = group;
+ matched_option = opts;
+
+ break;
+ case MATCH_EXACT:
+ /* Exact match. */
+ *p = group;
+ return opts;
+ }
+ }
+ }
+ if (num_partial == 1)
+ {
+ *p = matched_group;
+ return matched_option;
+ }
+
+ return NULL;
+}
+
+
+/* The next usable entries in the various parser tables being filled in by
+ convert_options. */
+struct parser_convert_state
+{
+ struct parser *parser;
+ char *short_end;
+ void **child_inputs_end;
+};
+
+/* Initialize GROUP from ARGP. If CVT->SHORT_END is non-NULL, short
+ options are recorded in the short options string. Returns the next
+ unused group entry. CVT holds state used during the conversion. */
+static struct group *
+convert_options (const struct argp *argp,
+ struct group *parent, unsigned parent_index,
+ struct group *group, struct parser_convert_state *cvt)
+{
+ const struct argp_option *opt = argp->options;
+ const struct argp_child *children = argp->children;
+
+ if (opt || argp->parser)
+ {
+ /* This parser needs a group. */
+ if (cvt->short_end)
+ {
+ /* Record any short options. */
+ for ( ; !__option_is_end (opt); opt++)
+ if (__option_is_short(opt))
+ *cvt->short_end++ = opt->key;
+ }
+
+ group->parser = argp->parser;
+ group->argp = argp;
+ group->args_processed = 0;
+ group->parent = parent;
+ group->parent_index = parent_index;
+ group->input = 0;
+ group->hook = 0;
+ group->child_inputs = 0;
+
+ if (children)
+ /* Assign GROUP's CHILD_INPUTS field some space from
+ CVT->child_inputs_end.*/
+ {
+ unsigned num_children = 0;
+ while (children[num_children].argp)
+ num_children++;
+ group->child_inputs = cvt->child_inputs_end;
+ cvt->child_inputs_end += num_children;
+ }
+ parent = group++;
+ }
+ else
+ parent = 0;
+
+ if (children)
+ {
+ unsigned index = 0;
+ while (children->argp)
+ group =
+ convert_options (children++->argp, parent, index++, group, cvt);
+ }
+
+ return group;
+}
+/* Allocate and initialize the group structures, so that they are
+ ordered as if by traversing the corresponding argp parser tree in
+ pre-order. Also build the list of short options, if that is needed. */
+static void
+parser_convert (struct parser *parser, const struct argp *argp)
+{
+ struct parser_convert_state cvt;
+
+ cvt.parser = parser;
+ cvt.short_end = parser->short_opts;
+ cvt.child_inputs_end = parser->child_inputs;
+
+ parser->argp = argp;
+
+ if (argp)
+ parser->egroup = convert_options (argp, 0, 0, parser->groups, &cvt);
+ else
+ parser->egroup = parser->groups; /* No parsers at all! */
+
+ if (parser->short_opts)
+ *cvt.short_end ='\0';
+}
+
+/* Lengths of various parser fields which we will allocated. */
+struct parser_sizes
+{
+ /* Needed only ARGP_LONG_ONLY */
+ size_t short_len; /* Number of short options. */
+
+ size_t num_groups; /* Group structures we allocate. */
+ size_t num_child_inputs; /* Child input slots. */
+};
+
+/* For ARGP, increments the NUM_GROUPS field in SZS by the total
+ number of argp structures descended from it, and the SHORT_LEN by
+ the total number of short options. */
+static void
+calc_sizes (const struct argp *argp, struct parser_sizes *szs)
+{
+ const struct argp_child *child = argp->children;
+ const struct argp_option *opt = argp->options;
+
+ if (opt || argp->parser)
+ {
+ /* This parser needs a group. */
+ szs->num_groups++;
+ if (opt)
+ {
+ while (__option_is_short (opt++))
+ szs->short_len++;
+ }
+ }
+
+ if (child)
+ while (child->argp)
+ {
+ calc_sizes ((child++)->argp, szs);
+ szs->num_child_inputs++;
+ }
+}
+
+/* Initializes PARSER to parse ARGP in a manner described by FLAGS. */
+static error_t
+parser_init (struct parser *parser, const struct argp *argp,
+ int argc, char **argv, int flags, void *input)
+{
+ error_t err = 0;
+ struct group *group;
+ struct parser_sizes szs;
+
+ parser->posixly_correct = getenv ("POSIXLY_CORRECT");
+
+ if (flags & ARGP_IN_ORDER)
+ parser->ordering = RETURN_IN_ORDER;
+ else if (flags & ARGP_NO_ARGS)
+ parser->ordering = REQUIRE_ORDER;
+ else if (parser->posixly_correct)
+ parser->ordering = REQUIRE_ORDER;
+ else
+ parser->ordering = PERMUTE;
+
+ szs.short_len = 0;
+ szs.num_groups = 0;
+ szs.num_child_inputs = 0;
+
+ if (argp)
+ calc_sizes (argp, &szs);
+
+ if (!(flags & ARGP_LONG_ONLY))
+ /* We have no use for the short option array. */
+ szs.short_len = 0;
+
+ /* Lengths of the various bits of storage used by PARSER. */
+#define GLEN (szs.num_groups + 1) * sizeof (struct group)
+#define CLEN (szs.num_child_inputs * sizeof (void *))
+#define SLEN (szs.short_len + 1)
+#define STORAGE(offset) ((void *) (((char *) parser->storage) + (offset)))
+
+ parser->storage = malloc (GLEN + CLEN + SLEN);
+ if (! parser->storage)
+ return ENOMEM;
+
+ parser->groups = parser->storage;
+
+ parser->child_inputs = STORAGE(GLEN);
+ memset (parser->child_inputs, 0, szs.num_child_inputs * sizeof (void *));
+
+ if (flags & ARGP_LONG_ONLY)
+ parser->short_opts = STORAGE(GLEN + CLEN);
+ else
+ parser->short_opts = NULL;
+
+ parser_convert (parser, argp);
+
+ memset (&parser->state, 0, sizeof (struct argp_state));
+
+ parser->state.root_argp = parser->argp;
+ parser->state.argc = argc;
+ parser->state.argv = argv;
+ parser->state.flags = flags;
+ parser->state.err_stream = stderr;
+ parser->state.out_stream = stdout;
+ parser->state.pstate = parser;
+
+ parser->args_only = 0;
+ parser->nextchar = NULL;
+ parser->first_nonopt = parser->last_nonopt = 0;
+
+ /* Call each parser for the first time, giving it a chance to propagate
+ values to child parsers. */
+ if (parser->groups < parser->egroup)
+ parser->groups->input = input;
+ for (group = parser->groups;
+ group < parser->egroup && (!err || err == EBADKEY);
+ group++)
+ {
+ if (group->parent)
+ /* If a child parser, get the initial input value from the parent. */
+ group->input = group->parent->child_inputs[group->parent_index];
+
+ if (!group->parser
+ && group->argp->children && group->argp->children->argp)
+ /* For the special case where no parsing function is supplied for an
+ argp, propagate its input to its first child, if any (this just
+ makes very simple wrapper argps more convenient). */
+ group->child_inputs[0] = group->input;
+
+ err = group_parse (group, &parser->state, ARGP_KEY_INIT, 0);
+ }
+ if (err == EBADKEY)
+ err = 0; /* Some parser didn't understand. */
+
+ if (err)
+ return err;
+
+ if (argv[0] && !(parser->state.flags & ARGP_PARSE_ARGV0))
+ /* There's an argv[0]; use it for messages. */
+ {
+ parser->state.name = __argp_basename(argv[0]);
+
+ /* Don't parse it as an argument. */
+ parser->state.next = 1;
+ }
+ else
+ parser->state.name = __argp_short_program_name(NULL);
+
+ return 0;
+}
+
+/* Free any storage consumed by PARSER (but not PARSER itself). */
+static error_t
+parser_finalize (struct parser *parser,
+ error_t err, int arg_ebadkey, int *end_index)
+{
+ struct group *group;
+
+ if (err == EBADKEY && arg_ebadkey)
+ /* Suppress errors generated by unparsed arguments. */
+ err = 0;
+
+ if (! err)
+ {
+ if (parser->state.next == parser->state.argc)
+ /* We successfully parsed all arguments! Call all the parsers again,
+ just a few more times... */
+ {
+ for (group = parser->groups;
+ group < parser->egroup && (!err || err==EBADKEY);
+ group++)
+ if (group->args_processed == 0)
+ err = group_parse (group, &parser->state, ARGP_KEY_NO_ARGS, 0);
+ for (group = parser->egroup - 1;
+ group >= parser->groups && (!err || err==EBADKEY);
+ group--)
+ err = group_parse (group, &parser->state, ARGP_KEY_END, 0);
+
+ if (err == EBADKEY)
+ err = 0; /* Some parser didn't understand. */
+
+ /* Tell the user that all arguments are parsed. */
+ if (end_index)
+ *end_index = parser->state.next;
+ }
+ else if (end_index)
+ /* Return any remaining arguments to the user. */
+ *end_index = parser->state.next;
+ else
+ /* No way to return the remaining arguments, they must be bogus. */
+ {
+ if (!(parser->state.flags & ARGP_NO_ERRS)
+ && parser->state.err_stream)
+ fprintf (parser->state.err_stream,
+ dgettext (parser->argp->argp_domain,
+ "%s: Too many arguments\n"),
+ parser->state.name);
+ err = EBADKEY;
+ }
+ }
+
+ /* Okay, we're all done, with either an error or success; call the parsers
+ to indicate which one. */
+
+ if (err)
+ {
+ /* Maybe print an error message. */
+ if (err == EBADKEY)
+ /* An appropriate message describing what the error was should have
+ been printed earlier. */
+ __argp_state_help (&parser->state, parser->state.err_stream,
+ ARGP_HELP_STD_ERR);
+
+ /* Since we didn't exit, give each parser an error indication. */
+ for (group = parser->groups; group < parser->egroup; group++)
+ group_parse (group, &parser->state, ARGP_KEY_ERROR, 0);
+ }
+ else
+ /* Notify parsers of success, and propagate back values from parsers. */
+ {
+ /* We pass over the groups in reverse order so that child groups are
+ given a chance to do there processing before passing back a value to
+ the parent. */
+ for (group = parser->egroup - 1
+ ; group >= parser->groups && (!err || err == EBADKEY)
+ ; group--)
+ err = group_parse (group, &parser->state, ARGP_KEY_SUCCESS, 0);
+ if (err == EBADKEY)
+ err = 0; /* Some parser didn't understand. */
+ }
+
+ /* Call parsers once more, to do any final cleanup. Errors are ignored. */
+ for (group = parser->egroup - 1; group >= parser->groups; group--)
+ group_parse (group, &parser->state, ARGP_KEY_FINI, 0);
+
+ if (err == EBADKEY)
+ err = EINVAL;
+
+ free (parser->storage);
+
+ return err;
+}
+
+/* Call the user parsers to parse the non-option argument VAL, at the
+ current position, returning any error. The state NEXT pointer
+ should point to the argument; this function will adjust it
+ correctly to reflect however many args actually end up being
+ consumed. */
+static error_t
+parser_parse_arg (struct parser *parser, char *val)
+{
+ /* Save the starting value of NEXT */
+ int index = parser->state.next;
+ error_t err = EBADKEY;
+ struct group *group;
+ int key = 0; /* Which of ARGP_KEY_ARG[S] we used. */
+
+ /* Try to parse the argument in each parser. */
+ for (group = parser->groups
+ ; group < parser->egroup && err == EBADKEY
+ ; group++)
+ {
+ parser->state.next++; /* For ARGP_KEY_ARG, consume the arg. */
+ key = ARGP_KEY_ARG;
+ err = group_parse (group, &parser->state, key, val);
+
+ if (err == EBADKEY)
+ /* This parser doesn't like ARGP_KEY_ARG; try ARGP_KEY_ARGS instead. */
+ {
+ parser->state.next--; /* For ARGP_KEY_ARGS, put back the arg. */
+ key = ARGP_KEY_ARGS;
+ err = group_parse (group, &parser->state, key, 0);
+ }
+ }
+
+ if (! err)
+ {
+ if (key == ARGP_KEY_ARGS)
+ /* The default for ARGP_KEY_ARGS is to assume that if NEXT isn't
+ changed by the user, *all* arguments should be considered
+ consumed. */
+ parser->state.next = parser->state.argc;
+
+ if (parser->state.next > index)
+ /* Remember that we successfully processed a non-option
+ argument -- but only if the user hasn't gotten tricky and set
+ the clock back. */
+ (--group)->args_processed += (parser->state.next - index);
+ else
+ /* The user wants to reparse some args, so try looking for options again. */
+ parser->args_only = 0;
+ }
+
+ return err;
+}
+
+/* Exchange two adjacent subsequences of ARGV.
+ One subsequence is elements [first_nonopt,last_nonopt)
+ which contains all the non-options that have been skipped so far.
+ The other is elements [last_nonopt,next), which contains all
+ the options processed since those non-options were skipped.
+
+ `first_nonopt' and `last_nonopt' are relocated so that they describe
+ the new indices of the non-options in ARGV after they are moved. */
+
+static void
+exchange (struct parser *parser)
+{
+ int bottom = parser->first_nonopt;
+ int middle = parser->last_nonopt;
+ int top = parser->state.next;
+ char **argv = parser->state.argv;
+
+ char *tem;
+
+ /* Exchange the shorter segment with the far end of the longer segment.
+ That puts the shorter segment into the right place.
+ It leaves the longer segment in the right place overall,
+ but it consists of two parts that need to be swapped next. */
+
+ while (top > middle && middle > bottom)
+ {
+ if (top - middle > middle - bottom)
+ {
+ /* Bottom segment is the short one. */
+ int len = middle - bottom;
+ register int i;
+
+ /* Swap it with the top part of the top segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[top - (middle - bottom) + i];
+ argv[top - (middle - bottom) + i] = tem;
+ }
+ /* Exclude the moved bottom segment from further swapping. */
+ top -= len;
+ }
+ else
+ {
+ /* Top segment is the short one. */
+ int len = top - middle;
+ register int i;
+
+ /* Swap it with the bottom part of the bottom segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[middle + i];
+ argv[middle + i] = tem;
+ }
+ /* Exclude the moved top segment from further swapping. */
+ bottom += len;
+ }
+ }
+
+ /* Update records for the slots the non-options now occupy. */
+
+ parser->first_nonopt += (parser->state.next - parser->last_nonopt);
+ parser->last_nonopt = parser->state.next;
+}
+
+
+
+enum arg_type { ARG_ARG, ARG_SHORT_OPTION,
+ ARG_LONG_OPTION, ARG_LONG_ONLY_OPTION,
+ ARG_QUOTE };
+
+static enum arg_type
+classify_arg(struct parser *parser, char *arg, char **opt)
+{
+ if (arg[0] == '-')
+ /* Looks like an option... */
+ switch (arg[1])
+ {
+ case '\0':
+ /* "-" is not an option. */
+ return ARG_ARG;
+ case '-':
+ /* Long option, or quote. */
+ if (!arg[2])
+ return ARG_QUOTE;
+
+ /* A long option. */
+ if (opt)
+ *opt = arg + 2;
+ return ARG_LONG_OPTION;
+
+ default:
+ /* Short option. But if ARGP_LONG_ONLY, it can also be a long option. */
+
+ if (opt)
+ *opt = arg + 1;
+
+ if (parser->state.flags & ARGP_LONG_ONLY)
+ {
+ /* Rules from getopt.c:
+
+ If long_only and the ARGV-element has the form "-f",
+ where f is a valid short option, don't consider it an
+ abbreviated form of a long option that starts with f.
+ Otherwise there would be no way to give the -f short
+ option.
+
+ On the other hand, if there's a long option "fubar" and
+ the ARGV-element is "-fu", do consider that an
+ abbreviation of the long option, just like "--fu", and
+ not "-f" with arg "u".
+
+ This distinction seems to be the most useful approach. */
+
+ assert(parser->short_opts);
+
+ if (arg[2] || !strchr(parser->short_opts, arg[1]))
+ return ARG_LONG_ONLY_OPTION;
+ }
+
+ return ARG_SHORT_OPTION;
+ }
+
+ else
+ return ARG_ARG;
+}
+
+/* Parse the next argument in PARSER (as indicated by PARSER->state.next).
+ Any error from the parsers is returned, and *ARGP_EBADKEY indicates
+ whether a value of EBADKEY is due to an unrecognized argument (which is
+ generally not fatal). */
+static error_t
+parser_parse_next (struct parser *parser, int *arg_ebadkey)
+{
+ if (parser->state.quoted && parser->state.next < parser->state.quoted)
+ /* The next argument pointer has been moved to before the quoted
+ region, so pretend we never saw the quoting `--', and start
+ looking for options again. If the `--' is still there we'll just
+ process it one more time. */
+ parser->state.quoted = parser->args_only = 0;
+
+ /* Give FIRST_NONOPT & LAST_NONOPT rational values if NEXT has been
+ moved back by the user (who may also have changed the arguments). */
+ if (parser->last_nonopt > parser->state.next)
+ parser->last_nonopt = parser->state.next;
+ if (parser->first_nonopt > parser->state.next)
+ parser->first_nonopt = parser->state.next;
+
+ if (parser->nextchar)
+ /* Deal with short options. */
+ {
+ struct group *group;
+ char c;
+ const struct argp_option *option;
+ char *value = NULL;;
+
+ assert(!parser->args_only);
+
+ c = *parser->nextchar++;
+
+ option = find_short_option(parser, c, &group);
+ if (!option)
+ {
+ if (parser->posixly_correct)
+ /* 1003.2 specifies the format of this message. */
+ fprintf (parser->state.err_stream,
+ dgettext(parser->state.root_argp->argp_domain,
+ "%s: illegal option -- %c\n"),
+ parser->state.name, c);
+ else
+ fprintf (parser->state.err_stream,
+ dgettext(parser->state.root_argp->argp_domain,
+ "%s: invalid option -- %c\n"),
+ parser->state.name, c);
+
+ *arg_ebadkey = 0;
+ return EBADKEY;
+ }
+
+ if (!*parser->nextchar)
+ parser->nextchar = NULL;
+
+ if (option->arg)
+ {
+ value = parser->nextchar;
+ parser->nextchar = NULL;
+
+ if (!value
+ && !(option->flags & OPTION_ARG_OPTIONAL))
+ /* We need an mandatory argument. */
+ {
+ if (parser->state.next == parser->state.argc)
+ /* Missing argument */
+ {
+ /* 1003.2 specifies the format of this message. */
+ fprintf (parser->state.err_stream,
+ dgettext(parser->state.root_argp->argp_domain,
+ "%s: option requires an argument -- %c\n"),
+ parser->state.name, c);
+
+ *arg_ebadkey = 0;
+ return EBADKEY;
+ }
+ value = parser->state.argv[parser->state.next++];
+ }
+ }
+ return group_parse(group, &parser->state,
+ option->key, value);
+ }
+ else
+ /* Advance to the next ARGV-element. */
+ {
+ if (parser->args_only)
+ {
+ *arg_ebadkey = 1;
+ if (parser->state.next >= parser->state.argc)
+ /* We're done. */
+ return EBADKEY;
+ else
+ return parser_parse_arg(parser,
+ parser->state.argv[parser->state.next]);
+ }
+
+ if (parser->state.next >= parser->state.argc)
+ /* Almost done. If there are non-options that we skipped
+ previously, we should process them now. */
+ {
+ *arg_ebadkey = 1;
+ if (parser->first_nonopt != parser->last_nonopt)
+ {
+ exchange(parser);
+
+ /* Start processing the arguments we skipped previously. */
+ parser->state.next = parser->first_nonopt;
+
+ parser->first_nonopt = parser->last_nonopt = 0;
+
+ parser->args_only = 1;
+ return 0;
+ }
+ else
+ /* Indicate that we're really done. */
+ return EBADKEY;
+ }
+ else
+ /* Look for options. */
+ {
+ char *arg = parser->state.argv[parser->state.next];
+
+ char *optstart;
+ enum arg_type token = classify_arg(parser, arg, &optstart);
+
+ switch (token)
+ {
+ case ARG_ARG:
+ switch (parser->ordering)
+ {
+ case PERMUTE:
+ if (parser->first_nonopt == parser->last_nonopt)
+ /* Skipped sequence is empty; start a new one. */
+ parser->first_nonopt = parser->last_nonopt = parser->state.next;
+
+ else if (parser->last_nonopt != parser->state.next)
+ /* We have a non-empty skipped sequence, and
+ we're not at the end-point, so move it. */
+ exchange(parser);
+
+ assert(parser->last_nonopt == parser->state.next);
+
+ /* Skip this argument for now. */
+ parser->state.next++;
+ parser->last_nonopt = parser->state.next;
+
+ return 0;
+
+ case REQUIRE_ORDER:
+ /* Implicit quote before the first argument. */
+ parser->args_only = 1;
+ return 0;
+
+ case RETURN_IN_ORDER:
+ *arg_ebadkey = 1;
+ return parser_parse_arg(parser, arg);
+
+ default:
+ abort();
+ }
+ case ARG_QUOTE:
+ /* Skip it, then exchange with any previous non-options. */
+ parser->state.next++;
+ assert (parser->last_nonopt != parser->state.next);
+
+ if (parser->first_nonopt != parser->last_nonopt)
+ {
+ exchange(parser);
+
+ /* Start processing the skipped and the quoted
+ arguments. */
+
+ parser->state.quoted = parser->state.next = parser->first_nonopt;
+
+ /* Also empty the skipped-list, to avoid confusion
+ if the user resets the next pointer. */
+ parser->first_nonopt = parser->last_nonopt = 0;
+ }
+ else
+ parser->state.quoted = parser->state.next;
+
+ parser->args_only = 1;
+ return 0;
+
+ case ARG_LONG_ONLY_OPTION:
+ case ARG_LONG_OPTION:
+ {
+ struct group *group;
+ const struct argp_option *option;
+ char *value;
+
+ parser->state.next++;
+ option = find_long_option(parser, optstart, &group);
+
+ if (!option)
+ {
+ /* NOTE: This includes any "=something" in the output. */
+ fprintf (parser->state.err_stream,
+ dgettext(parser->state.root_argp->argp_domain,
+ "%s: unrecognized option `%s'\n"),
+ parser->state.name, arg);
+ *arg_ebadkey = 0;
+ return EBADKEY;
+ }
+
+ value = strchr(optstart, '=');
+ if (value)
+ value++;
+
+ if (value && !option->arg)
+ /* Unexpected argument. */
+ {
+ if (token == ARG_LONG_OPTION)
+ /* --option */
+ fprintf (parser->state.err_stream,
+ dgettext(parser->state.root_argp->argp_domain,
+ "%s: option `--%s' doesn't allow an argument\n"),
+ parser->state.name, option->name);
+ else
+ /* +option or -option */
+ fprintf (parser->state.err_stream,
+ dgettext(parser->state.root_argp->argp_domain,
+ "%s: option `%c%s' doesn't allow an argument\n"),
+ parser->state.name, arg[0], option->name);
+
+ *arg_ebadkey = 0;
+ return EBADKEY;
+ }
+
+ if (option->arg && !value
+ && !(option->flags & OPTION_ARG_OPTIONAL))
+ /* We need an mandatory argument. */
+ {
+ if (parser->state.next == parser->state.argc)
+ /* Missing argument */
+ {
+ if (token == ARG_LONG_OPTION)
+ /* --option */
+ fprintf (parser->state.err_stream,
+ dgettext(parser->state.root_argp->argp_domain,
+ "%s: option `--%s' requires an argument\n"),
+ parser->state.name, option->name);
+ else
+ /* +option or -option */
+ fprintf (parser->state.err_stream,
+ dgettext(parser->state.root_argp->argp_domain,
+ "%s: option `%c%s' requires an argument\n"),
+ parser->state.name, arg[0], option->name);
+
+ *arg_ebadkey = 0;
+ return EBADKEY;
+ }
+
+ value = parser->state.argv[parser->state.next++];
+ }
+ *arg_ebadkey = 0;
+ return group_parse(group, &parser->state,
+ option->key, value);
+ }
+ case ARG_SHORT_OPTION:
+ parser->state.next++;
+ parser->nextchar = optstart;
+ return 0;
+
+ default:
+ abort();
+ }
+ }
+ }
+}
+
+/* Parse the options strings in ARGC & ARGV according to the argp in ARGP.
+ FLAGS is one of the ARGP_ flags above. If END_INDEX is non-NULL, the
+ index in ARGV of the first unparsed option is returned in it. If an
+ unknown option is present, EINVAL is returned; if some parser routine
+ returned a non-zero value, it is returned; otherwise 0 is returned. */
+error_t
+__argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags,
+ int *end_index, void *input)
+{
+ error_t err;
+ struct parser parser;
+
+ /* If true, then err == EBADKEY is a result of a non-option argument failing
+ to be parsed (which in some cases isn't actually an error). */
+ int arg_ebadkey = 0;
+
+ if (! (flags & ARGP_NO_HELP))
+ /* Add our own options. */
+ {
+ struct argp_child *child = alloca (4 * sizeof (struct argp_child));
+ struct argp *top_argp = alloca (sizeof (struct argp));
+
+ /* TOP_ARGP has no options, it just serves to group the user & default
+ argps. */
+ memset (top_argp, 0, sizeof (*top_argp));
+ top_argp->children = child;
+
+ memset (child, 0, 4 * sizeof (struct argp_child));
+
+ if (argp)
+ (child++)->argp = argp;
+ (child++)->argp = &argp_default_argp;
+ if (argp_program_version || argp_program_version_hook)
+ (child++)->argp = &argp_version_argp;
+ child->argp = 0;
+
+ argp = top_argp;
+ }
+
+ /* Construct a parser for these arguments. */
+ err = parser_init (&parser, argp, argc, argv, flags, input);
+
+ if (! err)
+ /* Parse! */
+ {
+ while (! err)
+ err = parser_parse_next (&parser, &arg_ebadkey);
+ err = parser_finalize (&parser, err, arg_ebadkey, end_index);
+ }
+
+ return err;
+}
+#ifdef weak_alias
+weak_alias (__argp_parse, argp_parse)
+#endif
+
+/* Return the input field for ARGP in the parser corresponding to STATE; used
+ by the help routines. */
+void *
+__argp_input (const struct argp *argp, const struct argp_state *state)
+{
+ if (state)
+ {
+ struct group *group;
+ struct parser *parser = state->pstate;
+
+ for (group = parser->groups; group < parser->egroup; group++)
+ if (group->argp == argp)
+ return group->input;
+ }
+
+ return 0;
+}
+#ifdef weak_alias
+weak_alias (__argp_input, _argp_input)
+#endif
+
+/* Defined here, in case a user is not inlining the definitions in
+ * argp.h */
+void
+__argp_usage (__const struct argp_state *__state)
+{
+ __argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE);
+}
+
+int
+__option_is_short (__const struct argp_option *__opt)
+{
+ if (__opt->flags & OPTION_DOC)
+ return 0;
+ else
+ {
+ int __key = __opt->key;
+ /* FIXME: whether or not a particular key implies a short option
+ * ought not to be locale dependent. */
+ return __key > 0 && isprint (__key);
+ }
+}
+
+int
+__option_is_end (__const struct argp_option *__opt)
+{
+ return !__opt->key && !__opt->name && !__opt->doc && !__opt->group;
+}
diff --git a/argp-standalone/argp-pv.c b/argp-standalone/argp-pv.c
new file mode 100644
index 0000000..d7d374a
--- /dev/null
+++ b/argp-standalone/argp-pv.c
@@ -0,0 +1,25 @@
+/* Default definition for ARGP_PROGRAM_VERSION.
+ Copyright (C) 1996, 1997, 1999, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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 Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* If set by the user program to a non-zero value, then a default option
+ --version is added (unless the ARGP_NO_HELP flag is used), which will
+ print this this string followed by a newline and exit (unless the
+ ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
+const char *argp_program_version = 0;
diff --git a/argp-standalone/argp-pvh.c b/argp-standalone/argp-pvh.c
new file mode 100644
index 0000000..829a1cd
--- /dev/null
+++ b/argp-standalone/argp-pvh.c
@@ -0,0 +1,32 @@
+/* Default definition for ARGP_PROGRAM_VERSION_HOOK.
+ Copyright (C) 1996, 1997, 1999, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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 Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "argp.h"
+
+/* If set by the user program to a non-zero value, then a default option
+ --version is added (unless the ARGP_NO_HELP flag is used), which calls
+ this function with a stream to print the version to and a pointer to the
+ current parsing state, and then exits (unless the ARGP_NO_EXIT flag is
+ used). This variable takes precedent over ARGP_PROGRAM_VERSION. */
+void (*argp_program_version_hook) (FILE *stream, struct argp_state *state) = 0;
diff --git a/argp-standalone/argp.h b/argp-standalone/argp.h
new file mode 100644
index 0000000..29d3dfe
--- /dev/null
+++ b/argp-standalone/argp.h
@@ -0,0 +1,602 @@
+/* Hierarchial argument parsing.
+ Copyright (C) 1995, 96, 97, 98, 99, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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 Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _ARGP_H
+#define _ARGP_H
+
+#include <stdio.h>
+#include <ctype.h>
+
+#define __need_error_t
+#include <errno.h>
+
+#ifndef __THROW
+# define __THROW
+#endif
+
+#ifndef __const
+# define __const const
+#endif
+
+#ifndef __error_t_defined
+typedef int error_t;
+# define __error_t_defined
+#endif
+
+/* FIXME: What's the right way to check for __restrict? Sun's cc seems
+ not to have it. Perhaps it's easiest to just delete the use of
+ __restrict from the prototypes. */
+#ifndef __restrict
+# ifndef __GNUC___
+# define __restrict
+# endif
+#endif
+
+/* NOTE: We can't use the autoconf tests, since this is supposed to be
+ an installed header file and argp's config.h is of course not
+ installed. */
+#ifndef PRINTF_STYLE
+# if __GNUC__ >= 2
+# define PRINTF_STYLE(f, a) __attribute__ ((__format__ (__printf__, f, a)))
+# else
+# define PRINTF_STYLE(f, a)
+# endif
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* A description of a particular option. A pointer to an array of
+ these is passed in the OPTIONS field of an argp structure. Each option
+ entry can correspond to one long option and/or one short option; more
+ names for the same option can be added by following an entry in an option
+ array with options having the OPTION_ALIAS flag set. */
+struct argp_option
+{
+ /* The long option name. For more than one name for the same option, you
+ can use following options with the OPTION_ALIAS flag set. */
+ __const char *name;
+
+ /* What key is returned for this option. If > 0 and printable, then it's
+ also accepted as a short option. */
+ int key;
+
+ /* If non-NULL, this is the name of the argument associated with this
+ option, which is required unless the OPTION_ARG_OPTIONAL flag is set. */
+ __const char *arg;
+
+ /* OPTION_ flags. */
+ int flags;
+
+ /* The doc string for this option. If both NAME and KEY are 0, This string
+ will be printed outdented from the normal option column, making it
+ useful as a group header (it will be the first thing printed in its
+ group); in this usage, it's conventional to end the string with a `:'. */
+ __const char *doc;
+
+ /* The group this option is in. In a long help message, options are sorted
+ alphabetically within each group, and the groups presented in the order
+ 0, 1, 2, ..., n, -m, ..., -2, -1. Every entry in an options array with
+ if this field 0 will inherit the group number of the previous entry, or
+ zero if it's the first one, unless its a group header (NAME and KEY both
+ 0), in which case, the previous entry + 1 is the default. Automagic
+ options such as --help are put into group -1. */
+ int group;
+};
+
+/* The argument associated with this option is optional. */
+#define OPTION_ARG_OPTIONAL 0x1
+
+/* This option isn't displayed in any help messages. */
+#define OPTION_HIDDEN 0x2
+
+/* This option is an alias for the closest previous non-alias option. This
+ means that it will be displayed in the same help entry, and will inherit
+ fields other than NAME and KEY from the aliased option. */
+#define OPTION_ALIAS 0x4
+
+/* This option isn't actually an option (and so should be ignored by the
+ actual option parser), but rather an arbitrary piece of documentation that
+ should be displayed in much the same manner as the options. If this flag
+ is set, then the option NAME field is displayed unmodified (e.g., no `--'
+ prefix is added) at the left-margin (where a *short* option would normally
+ be displayed), and the documentation string in the normal place. For
+ purposes of sorting, any leading whitespace and puncuation is ignored,
+ except that if the first non-whitespace character is not `-', this entry
+ is displayed after all options (and OPTION_DOC entries with a leading `-')
+ in the same group. */
+#define OPTION_DOC 0x8
+
+/* This option shouldn't be included in `long' usage messages (but is still
+ included in help messages). This is mainly intended for options that are
+ completely documented in an argp's ARGS_DOC field, in which case including
+ the option in the generic usage list would be redundant. For instance,
+ if ARGS_DOC is "FOO BAR\n-x BLAH", and the `-x' option's purpose is to
+ distinguish these two cases, -x should probably be marked
+ OPTION_NO_USAGE. */
+#define OPTION_NO_USAGE 0x10
+
+struct argp; /* fwd declare this type */
+struct argp_state; /* " */
+struct argp_child; /* " */
+
+/* The type of a pointer to an argp parsing function. */
+typedef error_t (*argp_parser_t) (int key, char *arg,
+ struct argp_state *state);
+
+/* What to return for unrecognized keys. For special ARGP_KEY_ keys, such
+ returns will simply be ignored. For user keys, this error will be turned
+ into EINVAL (if the call to argp_parse is such that errors are propagated
+ back to the user instead of exiting); returning EINVAL itself would result
+ in an immediate stop to parsing in *all* cases. */
+#define ARGP_ERR_UNKNOWN E2BIG /* Hurd should never need E2BIG. XXX */
+
+/* Special values for the KEY argument to an argument parsing function.
+ ARGP_ERR_UNKNOWN should be returned if they aren't understood.
+
+ The sequence of keys to a parsing function is either (where each
+ uppercased word should be prefixed by `ARGP_KEY_' and opt is a user key):
+
+ INIT opt... NO_ARGS END SUCCESS -- No non-option arguments at all
+ or INIT (opt | ARG)... END SUCCESS -- All non-option args parsed
+ or INIT (opt | ARG)... SUCCESS -- Some non-option arg unrecognized
+
+ The third case is where every parser returned ARGP_KEY_UNKNOWN for an
+ argument, in which case parsing stops at that argument (returning the
+ unparsed arguments to the caller of argp_parse if requested, or stopping
+ with an error message if not).
+
+ If an error occurs (either detected by argp, or because the parsing
+ function returned an error value), then the parser is called with
+ ARGP_KEY_ERROR, and no further calls are made. */
+
+/* This is not an option at all, but rather a command line argument. If a
+ parser receiving this key returns success, the fact is recorded, and the
+ ARGP_KEY_NO_ARGS case won't be used. HOWEVER, if while processing the
+ argument, a parser function decrements the NEXT field of the state it's
+ passed, the option won't be considered processed; this is to allow you to
+ actually modify the argument (perhaps into an option), and have it
+ processed again. */
+#define ARGP_KEY_ARG 0
+/* There are remaining arguments not parsed by any parser, which may be found
+ starting at (STATE->argv + STATE->next). If success is returned, but
+ STATE->next left untouched, it's assumed that all arguments were consume,
+ otherwise, the parser should adjust STATE->next to reflect any arguments
+ consumed. */
+#define ARGP_KEY_ARGS 0x1000006
+/* There are no more command line arguments at all. */
+#define ARGP_KEY_END 0x1000001
+/* Because it's common to want to do some special processing if there aren't
+ any non-option args, user parsers are called with this key if they didn't
+ successfully process any non-option arguments. Called just before
+ ARGP_KEY_END (where more general validity checks on previously parsed
+ arguments can take place). */
+#define ARGP_KEY_NO_ARGS 0x1000002
+/* Passed in before any parsing is done. Afterwards, the values of each
+ element of the CHILD_INPUT field, if any, in the state structure is
+ copied to each child's state to be the initial value of the INPUT field. */
+#define ARGP_KEY_INIT 0x1000003
+/* Use after all other keys, including SUCCESS & END. */
+#define ARGP_KEY_FINI 0x1000007
+/* Passed in when parsing has successfully been completed (even if there are
+ still arguments remaining). */
+#define ARGP_KEY_SUCCESS 0x1000004
+/* Passed in if an error occurs. */
+#define ARGP_KEY_ERROR 0x1000005
+
+/* An argp structure contains a set of options declarations, a function to
+ deal with parsing one, documentation string, a possible vector of child
+ argp's, and perhaps a function to filter help output. When actually
+ parsing options, getopt is called with the union of all the argp
+ structures chained together through their CHILD pointers, with conflicts
+ being resolved in favor of the first occurrence in the chain. */
+struct argp
+{
+ /* An array of argp_option structures, terminated by an entry with both
+ NAME and KEY having a value of 0. */
+ __const struct argp_option *options;
+
+ /* What to do with an option from this structure. KEY is the key
+ associated with the option, and ARG is any associated argument (NULL if
+ none was supplied). If KEY isn't understood, ARGP_ERR_UNKNOWN should be
+ returned. If a non-zero, non-ARGP_ERR_UNKNOWN value is returned, then
+ parsing is stopped immediately, and that value is returned from
+ argp_parse(). For special (non-user-supplied) values of KEY, see the
+ ARGP_KEY_ definitions below. */
+ argp_parser_t parser;
+
+ /* A string describing what other arguments are wanted by this program. It
+ is only used by argp_usage to print the `Usage:' message. If it
+ contains newlines, the strings separated by them are considered
+ alternative usage patterns, and printed on separate lines (lines after
+ the first are prefix by ` or: ' instead of `Usage:'). */
+ __const char *args_doc;
+
+ /* If non-NULL, a string containing extra text to be printed before and
+ after the options in a long help message (separated by a vertical tab
+ `\v' character). */
+ __const char *doc;
+
+ /* A vector of argp_children structures, terminated by a member with a 0
+ argp field, pointing to child argps should be parsed with this one. Any
+ conflicts are resolved in favor of this argp, or early argps in the
+ CHILDREN list. This field is useful if you use libraries that supply
+ their own argp structure, which you want to use in conjunction with your
+ own. */
+ __const struct argp_child *children;
+
+ /* If non-zero, this should be a function to filter the output of help
+ messages. KEY is either a key from an option, in which case TEXT is
+ that option's help text, or a special key from the ARGP_KEY_HELP_
+ defines, below, describing which other help text TEXT is. The function
+ should return either TEXT, if it should be used as-is, a replacement
+ string, which should be malloced, and will be freed by argp, or NULL,
+ meaning `print nothing'. The value for TEXT is *after* any translation
+ has been done, so if any of the replacement text also needs translation,
+ that should be done by the filter function. INPUT is either the input
+ supplied to argp_parse, or NULL, if argp_help was called directly. */
+ char *(*help_filter) (int __key, __const char *__text, void *__input);
+
+ /* If non-zero the strings used in the argp library are translated using
+ the domain described by this string. Otherwise the currently installed
+ default domain is used. */
+ const char *argp_domain;
+};
+
+/* Possible KEY arguments to a help filter function. */
+#define ARGP_KEY_HELP_PRE_DOC 0x2000001 /* Help text preceeding options. */
+#define ARGP_KEY_HELP_POST_DOC 0x2000002 /* Help text following options. */
+#define ARGP_KEY_HELP_HEADER 0x2000003 /* Option header string. */
+#define ARGP_KEY_HELP_EXTRA 0x2000004 /* After all other documentation;
+ TEXT is NULL for this key. */
+/* Explanatory note emitted when duplicate option arguments have been
+ suppressed. */
+#define ARGP_KEY_HELP_DUP_ARGS_NOTE 0x2000005
+#define ARGP_KEY_HELP_ARGS_DOC 0x2000006 /* Argument doc string. */
+
+/* When an argp has a non-zero CHILDREN field, it should point to a vector of
+ argp_child structures, each of which describes a subsidiary argp. */
+struct argp_child
+{
+ /* The child parser. */
+ __const struct argp *argp;
+
+ /* Flags for this child. */
+ int flags;
+
+ /* If non-zero, an optional header to be printed in help output before the
+ child options. As a side-effect, a non-zero value forces the child
+ options to be grouped together; to achieve this effect without actually
+ printing a header string, use a value of "". */
+ __const char *header;
+
+ /* Where to group the child options relative to the other (`consolidated')
+ options in the parent argp; the values are the same as the GROUP field
+ in argp_option structs, but all child-groupings follow parent options at
+ a particular group level. If both this field and HEADER are zero, then
+ they aren't grouped at all, but rather merged with the parent options
+ (merging the child's grouping levels with the parents). */
+ int group;
+};
+
+/* Parsing state. This is provided to parsing functions called by argp,
+ which may examine and, as noted, modify fields. */
+struct argp_state
+{
+ /* The top level ARGP being parsed. */
+ __const struct argp *root_argp;
+
+ /* The argument vector being parsed. May be modified. */
+ int argc;
+ char **argv;
+
+ /* The index in ARGV of the next arg that to be parsed. May be modified. */
+ int next;
+
+ /* The flags supplied to argp_parse. May be modified. */
+ unsigned flags;
+
+ /* While calling a parsing function with a key of ARGP_KEY_ARG, this is the
+ number of the current arg, starting at zero, and incremented after each
+ such call returns. At all other times, this is the number of such
+ arguments that have been processed. */
+ unsigned arg_num;
+
+ /* If non-zero, the index in ARGV of the first argument following a special
+ `--' argument (which prevents anything following being interpreted as an
+ option). Only set once argument parsing has proceeded past this point. */
+ int quoted;
+
+ /* An arbitrary pointer passed in from the user. */
+ void *input;
+ /* Values to pass to child parsers. This vector will be the same length as
+ the number of children for the current parser. */
+ void **child_inputs;
+
+ /* For the parser's use. Initialized to 0. */
+ void *hook;
+
+ /* The name used when printing messages. This is initialized to ARGV[0],
+ or PROGRAM_INVOCATION_NAME if that is unavailable. */
+ char *name;
+
+ /* Streams used when argp prints something. */
+ FILE *err_stream; /* For errors; initialized to stderr. */
+ FILE *out_stream; /* For information; initialized to stdout. */
+
+ void *pstate; /* Private, for use by argp. */
+};
+
+/* Flags for argp_parse (note that the defaults are those that are
+ convenient for program command line parsing): */
+
+/* Don't ignore the first element of ARGV. Normally (and always unless
+ ARGP_NO_ERRS is set) the first element of the argument vector is
+ skipped for option parsing purposes, as it corresponds to the program name
+ in a command line. */
+#define ARGP_PARSE_ARGV0 0x01
+
+/* Don't print error messages for unknown options to stderr; unless this flag
+ is set, ARGP_PARSE_ARGV0 is ignored, as ARGV[0] is used as the program
+ name in the error messages. This flag implies ARGP_NO_EXIT (on the
+ assumption that silent exiting upon errors is bad behaviour). */
+#define ARGP_NO_ERRS 0x02
+
+/* Don't parse any non-option args. Normally non-option args are parsed by
+ calling the parse functions with a key of ARGP_KEY_ARG, and the actual arg
+ as the value. Since it's impossible to know which parse function wants to
+ handle it, each one is called in turn, until one returns 0 or an error
+ other than ARGP_ERR_UNKNOWN; if an argument is handled by no one, the
+ argp_parse returns prematurely (but with a return value of 0). If all
+ args have been parsed without error, all parsing functions are called one
+ last time with a key of ARGP_KEY_END. This flag needn't normally be set,
+ as the normal behavior is to stop parsing as soon as some argument can't
+ be handled. */
+#define ARGP_NO_ARGS 0x04
+
+/* Parse options and arguments in the same order they occur on the command
+ line -- normally they're rearranged so that all options come first. */
+#define ARGP_IN_ORDER 0x08
+
+/* Don't provide the standard long option --help, which causes usage and
+ option help information to be output to stdout, and exit (0) called. */
+#define ARGP_NO_HELP 0x10
+
+/* Don't exit on errors (they may still result in error messages). */
+#define ARGP_NO_EXIT 0x20
+
+/* Use the gnu getopt `long-only' rules for parsing arguments. */
+#define ARGP_LONG_ONLY 0x40
+
+/* Turns off any message-printing/exiting options. */
+#define ARGP_SILENT (ARGP_NO_EXIT | ARGP_NO_ERRS | ARGP_NO_HELP)
+
+/* Parse the options strings in ARGC & ARGV according to the options in ARGP.
+ FLAGS is one of the ARGP_ flags above. If ARG_INDEX is non-NULL, the
+ index in ARGV of the first unparsed option is returned in it. If an
+ unknown option is present, ARGP_ERR_UNKNOWN is returned; if some parser
+ routine returned a non-zero value, it is returned; otherwise 0 is
+ returned. This function may also call exit unless the ARGP_NO_HELP flag
+ is set. INPUT is a pointer to a value to be passed in to the parser. */
+extern error_t argp_parse (__const struct argp *__restrict argp,
+ int argc, char **__restrict argv,
+ unsigned flags, int *__restrict arg_index,
+ void *__restrict input) __THROW;
+extern error_t __argp_parse (__const struct argp *__restrict argp,
+ int argc, char **__restrict argv,
+ unsigned flags, int *__restrict arg_index,
+ void *__restrict input) __THROW;
+
+/* Global variables. */
+
+/* If defined or set by the user program to a non-zero value, then a default
+ option --version is added (unless the ARGP_NO_HELP flag is used), which
+ will print this string followed by a newline and exit (unless the
+ ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
+extern __const char *argp_program_version;
+
+/* If defined or set by the user program to a non-zero value, then a default
+ option --version is added (unless the ARGP_NO_HELP flag is used), which
+ calls this function with a stream to print the version to and a pointer to
+ the current parsing state, and then exits (unless the ARGP_NO_EXIT flag is
+ used). This variable takes precedent over ARGP_PROGRAM_VERSION. */
+extern void (*argp_program_version_hook) (FILE *__restrict __stream,
+ struct argp_state *__restrict
+ __state);
+
+/* If defined or set by the user program, it should point to string that is
+ the bug-reporting address for the program. It will be printed by
+ argp_help if the ARGP_HELP_BUG_ADDR flag is set (as it is by various
+ standard help messages), embedded in a sentence that says something like
+ `Report bugs to ADDR.'. */
+extern __const char *argp_program_bug_address;
+
+/* The exit status that argp will use when exiting due to a parsing error.
+ If not defined or set by the user program, this defaults to EX_USAGE from
+ <sysexits.h>. */
+extern error_t argp_err_exit_status;
+
+/* Flags for argp_help. */
+#define ARGP_HELP_USAGE 0x01 /* a Usage: message. */
+#define ARGP_HELP_SHORT_USAGE 0x02 /* " but don't actually print options. */
+#define ARGP_HELP_SEE 0x04 /* a `Try ... for more help' message. */
+#define ARGP_HELP_LONG 0x08 /* a long help message. */
+#define ARGP_HELP_PRE_DOC 0x10 /* doc string preceding long help. */
+#define ARGP_HELP_POST_DOC 0x20 /* doc string following long help. */
+#define ARGP_HELP_DOC (ARGP_HELP_PRE_DOC | ARGP_HELP_POST_DOC)
+#define ARGP_HELP_BUG_ADDR 0x40 /* bug report address */
+#define ARGP_HELP_LONG_ONLY 0x80 /* modify output appropriately to
+ reflect ARGP_LONG_ONLY mode. */
+
+/* These ARGP_HELP flags are only understood by argp_state_help. */
+#define ARGP_HELP_EXIT_ERR 0x100 /* Call exit(1) instead of returning. */
+#define ARGP_HELP_EXIT_OK 0x200 /* Call exit(0) instead of returning. */
+
+/* The standard thing to do after a program command line parsing error, if an
+ error message has already been printed. */
+#define ARGP_HELP_STD_ERR \
+ (ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR)
+/* The standard thing to do after a program command line parsing error, if no
+ more specific error message has been printed. */
+#define ARGP_HELP_STD_USAGE \
+ (ARGP_HELP_SHORT_USAGE | ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR)
+/* The standard thing to do in response to a --help option. */
+#define ARGP_HELP_STD_HELP \
+ (ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG | ARGP_HELP_EXIT_OK \
+ | ARGP_HELP_DOC | ARGP_HELP_BUG_ADDR)
+
+/* Output a usage message for ARGP to STREAM. FLAGS are from the set
+ ARGP_HELP_*. */
+extern void argp_help (__const struct argp *__restrict __argp,
+ FILE *__restrict __stream,
+ unsigned __flags, char *__restrict __name) __THROW;
+extern void __argp_help (__const struct argp *__restrict __argp,
+ FILE *__restrict __stream, unsigned __flags,
+ char *__name) __THROW;
+
+/* The following routines are intended to be called from within an argp
+ parsing routine (thus taking an argp_state structure as the first
+ argument). They may or may not print an error message and exit, depending
+ on the flags in STATE -- in any case, the caller should be prepared for
+ them *not* to exit, and should return an appropiate error after calling
+ them. [argp_usage & argp_error should probably be called argp_state_...,
+ but they're used often enough that they should be short] */
+
+/* Output, if appropriate, a usage message for STATE to STREAM. FLAGS are
+ from the set ARGP_HELP_*. */
+extern void argp_state_help (__const struct argp_state *__restrict __state,
+ FILE *__restrict __stream,
+ unsigned int __flags) __THROW;
+extern void __argp_state_help (__const struct argp_state *__restrict __state,
+ FILE *__restrict __stream,
+ unsigned int __flags) __THROW;
+
+/* Possibly output the standard usage message for ARGP to stderr and exit. */
+extern void argp_usage (__const struct argp_state *__state) __THROW;
+extern void __argp_usage (__const struct argp_state *__state) __THROW;
+
+/* If appropriate, print the printf string FMT and following args, preceded
+ by the program name and `:', to stderr, and followed by a `Try ... --help'
+ message, then exit (1). */
+extern void argp_error (__const struct argp_state *__restrict __state,
+ __const char *__restrict __fmt, ...) __THROW
+ PRINTF_STYLE(2,3);
+extern void __argp_error (__const struct argp_state *__restrict __state,
+ __const char *__restrict __fmt, ...) __THROW
+ PRINTF_STYLE(2,3);
+
+/* Similar to the standard gnu error-reporting function error(), but will
+ respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print
+ to STATE->err_stream. This is useful for argument parsing code that is
+ shared between program startup (when exiting is desired) and runtime
+ option parsing (when typically an error code is returned instead). The
+ difference between this function and argp_error is that the latter is for
+ *parsing errors*, and the former is for other problems that occur during
+ parsing but don't reflect a (syntactic) problem with the input. */
+extern void argp_failure (__const struct argp_state *__restrict __state,
+ int __status, int __errnum,
+ __const char *__restrict __fmt, ...) __THROW
+ PRINTF_STYLE(4,5);
+extern void __argp_failure (__const struct argp_state *__restrict __state,
+ int __status, int __errnum,
+ __const char *__restrict __fmt, ...) __THROW
+ PRINTF_STYLE(4,5);
+
+/* Returns true if the option OPT is a valid short option. */
+extern int _option_is_short (__const struct argp_option *__opt) __THROW;
+extern int __option_is_short (__const struct argp_option *__opt) __THROW;
+
+/* Returns true if the option OPT is in fact the last (unused) entry in an
+ options array. */
+extern int _option_is_end (__const struct argp_option *__opt) __THROW;
+extern int __option_is_end (__const struct argp_option *__opt) __THROW;
+
+/* Return the input field for ARGP in the parser corresponding to STATE; used
+ by the help routines. */
+extern void *_argp_input (__const struct argp *__restrict __argp,
+ __const struct argp_state *__restrict __state)
+ __THROW;
+extern void *__argp_input (__const struct argp *__restrict __argp,
+ __const struct argp_state *__restrict __state)
+ __THROW;
+
+/* Used for extracting the program name from argv[0] */
+extern char *_argp_basename(char *name) __THROW;
+extern char *__argp_basename(char *name) __THROW;
+
+/* Getting the program name given an argp state */
+extern char *
+_argp_short_program_name(const struct argp_state *state) __THROW;
+extern char *
+__argp_short_program_name(const struct argp_state *state) __THROW;
+
+
+#ifdef __USE_EXTERN_INLINES
+
+# if !_LIBC
+# define __argp_usage argp_usage
+# define __argp_state_help argp_state_help
+# define __option_is_short _option_is_short
+# define __option_is_end _option_is_end
+# endif
+
+# ifndef ARGP_EI
+# define ARGP_EI extern __inline__
+# endif
+
+ARGP_EI void
+__argp_usage (__const struct argp_state *__state)
+{
+ __argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE);
+}
+
+ARGP_EI int
+__option_is_short (__const struct argp_option *__opt)
+{
+ if (__opt->flags & OPTION_DOC)
+ return 0;
+ else
+ {
+ int __key = __opt->key;
+ return __key > 0 && isprint (__key);
+ }
+}
+
+ARGP_EI int
+__option_is_end (__const struct argp_option *__opt)
+{
+ return !__opt->key && !__opt->name && !__opt->doc && !__opt->group;
+}
+
+# if !_LIBC
+# undef __argp_usage
+# undef __argp_state_help
+# undef __option_is_short
+# undef __option_is_end
+# endif
+#endif /* Use extern inlines. */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* argp.h */
diff --git a/argp-standalone/autogen.sh b/argp-standalone/autogen.sh
new file mode 100755
index 0000000..8337353
--- /dev/null
+++ b/argp-standalone/autogen.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+aclocal -I .
+autoheader
+autoconf
+automake --add-missing --copy --foreign
diff --git a/argp-standalone/configure.ac b/argp-standalone/configure.ac
new file mode 100644
index 0000000..fe54d5a
--- /dev/null
+++ b/argp-standalone/configure.ac
@@ -0,0 +1,100 @@
+dnl Process this file with autoconf to produce a configure script.
+
+dnl This configure.ac is only for building a standalone argp library.
+AC_INIT([argp], [standalone-1.3])
+AC_PREREQ(2.54)
+AC_CONFIG_SRCDIR([argp-ba.c])
+# Needed to stop autoconf from looking for files in parent directories.
+AC_CONFIG_AUX_DIR([.])
+
+AM_INIT_AUTOMAKE
+AM_CONFIG_HEADER(config.h)
+
+# GNU libc defaults to supplying the ISO C library functions only. The
+# _GNU_SOURCE define enables these extensions, in particular we want
+# errno.h to declare program_invocation_name. Enable it on all
+# systems; no problems have been reported with it so far.
+AC_GNU_SOURCE
+
+# Checks for programs.
+AC_PROG_CC
+AC_PROG_MAKE_SET
+AC_PROG_RANLIB
+AM_PROG_CC_STDC
+
+if test "x$am_cv_prog_cc_stdc" = xno ; then
+ AC_ERROR([the C compiler doesn't handle ANSI-C])
+fi
+
+# Checks for libraries.
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS(limits.h malloc.h unistd.h sysexits.h stdarg.h)
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_C_INLINE
+AC_TYPE_SIZE_T
+
+LSH_GCC_ATTRIBUTES
+
+# Checks for library functions.
+AC_FUNC_ALLOCA
+AC_FUNC_VPRINTF
+AC_CHECK_FUNCS(strerror sleep getpid snprintf)
+
+AC_REPLACE_FUNCS(mempcpy strndup strchrnul strcasecmp vsnprintf)
+
+dnl ARGP_CHECK_FUNC(includes, function-call [, if-found [, if-not-found]])
+AC_DEFUN([ARGP_CHECK_FUNC],
+ [AS_VAR_PUSHDEF([ac_func], m4_substr([$2], 0, m4_index([$2], [(])))
+ AS_VAR_PUSHDEF([ac_var], [ac_cv_func_call_]ac_func)
+ AH_TEMPLATE(AS_TR_CPP(HAVE_[]ac_func),
+ [Define to 1 if you have the `]ac_func[' function.])
+ AC_CACHE_CHECK([for $2], ac_var,
+ [AC_TRY_LINK([$1], [$2],
+ [AS_VAR_SET(ac_var, yes)],
+ [AS_VAR_SET(ac_var, no)])])
+ if test AS_VAR_GET(ac_var) = yes ; then
+ ifelse([$3],,
+ [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]ac_func))],
+ [$3
+])
+ else
+ ifelse([$4],, true, [$4])
+ fi
+ AS_VAR_POPDEF([ac_var])
+ AS_VAR_POPDEF([ac_func])
+ ])
+
+# At least on freebsd, putc_unlocked is a macro, so the standard
+# AC_CHECK_FUNCS doesn't work well.
+ARGP_CHECK_FUNC([#include <stdio.h>], [putc_unlocked('x', stdout)])
+
+AC_CHECK_FUNCS(flockfile)
+AC_CHECK_FUNCS(fputs_unlocked fwrite_unlocked)
+
+# Used only by argp-test.c, so don't use AC_REPLACE_FUNCS.
+AC_CHECK_FUNCS(strdup asprintf)
+
+AC_CHECK_DECLS([program_invocation_name, program_invocation_short_name],
+ [], [], [[#include <errno.h>]])
+
+# Set these flags *last*, or else the test programs won't compile
+if test x$GCC = xyes ; then
+ # Using -ggdb3 makes (some versions of) Redhat's gcc-2.96 dump core
+ if "$CC" --version | grep '^2\.96$' 1>/dev/null 2>&1; then
+ true
+ else
+ CFLAGS="$CFLAGS -ggdb3"
+ fi
+ CFLAGS="$CFLAGS -Wall -W \
+ -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes \
+ -Waggregate-return \
+ -Wpointer-arith -Wbad-function-cast -Wnested-externs"
+fi
+
+CPPFLAGS="$CPPFLAGS -I$srcdir"
+
+AC_OUTPUT(Makefile)
diff --git a/argp-standalone/mempcpy.c b/argp-standalone/mempcpy.c
new file mode 100644
index 0000000..21d8bd2
--- /dev/null
+++ b/argp-standalone/mempcpy.c
@@ -0,0 +1,21 @@
+/* strndup.c
+ *
+ */
+
+/* Written by Niels Möller <nisse@lysator.liu.se>
+ *
+ * This file is hereby placed in the public domain.
+ */
+
+#include <string.h>
+
+void *
+mempcpy (void *, const void *, size_t) ;
+
+void *
+mempcpy (void *to, const void *from, size_t size)
+{
+ memcpy(to, from, size);
+ return (char *) to + size;
+}
+
diff --git a/argp-standalone/strcasecmp.c b/argp-standalone/strcasecmp.c
new file mode 100644
index 0000000..bcad7a2
--- /dev/null
+++ b/argp-standalone/strcasecmp.c
@@ -0,0 +1,28 @@
+/* strcasecmp.c
+ *
+ */
+
+/* Written by Niels Möller <nisse@lysator.liu.se>
+ *
+ * This file is hereby placed in the public domain.
+ */
+
+#include <ctype.h>
+
+int strcasecmp(const char *s1, const char *s2)
+{
+ unsigned i;
+
+ for (i = 0; s1[i] && s2[i]; i++)
+ {
+ unsigned char c1 = tolower( (unsigned char) s1[i]);
+ unsigned char c2 = tolower( (unsigned char) s2[i]);
+
+ if (c1 < c2)
+ return -1;
+ else if (c1 > c2)
+ return 1;
+ }
+
+ return !s2[i] - !s1[i];
+}
diff --git a/argp-standalone/strchrnul.c b/argp-standalone/strchrnul.c
new file mode 100644
index 0000000..ee4145e
--- /dev/null
+++ b/argp-standalone/strchrnul.c
@@ -0,0 +1,23 @@
+/* strchrnul.c
+ *
+ */
+
+/* Written by Niels Möller <nisse@lysator.liu.se>
+ *
+ * This file is hereby placed in the public domain.
+ */
+
+/* FIXME: What is this function supposed to do? My guess is that it is
+ * like strchr, but returns a pointer to the NUL character, not a NULL
+ * pointer, if the character isn't found. */
+
+char *strchrnul(const char *, int );
+
+char *strchrnul(const char *s, int c)
+{
+ const char *p = s;
+ while (*p && (*p != c))
+ p++;
+
+ return (char *) p;
+}
diff --git a/argp-standalone/strndup.c b/argp-standalone/strndup.c
new file mode 100644
index 0000000..4147b7a
--- /dev/null
+++ b/argp-standalone/strndup.c
@@ -0,0 +1,34 @@
+/* strndup.c
+ *
+ */
+
+/* Written by Niels Möller <nisse@lysator.liu.se>
+ *
+ * This file is hereby placed in the public domain.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+char *
+strndup (const char *, size_t);
+
+char *
+strndup (const char *s, size_t size)
+{
+ char *r;
+ char *end = memchr(s, 0, size);
+
+ if (end)
+ /* Length + 1 */
+ size = end - s + 1;
+
+ r = malloc(size);
+
+ if (size)
+ {
+ memcpy(r, s, size-1);
+ r[size-1] = '\0';
+ }
+ return r;
+}
diff --git a/argp-standalone/vsnprintf.c b/argp-standalone/vsnprintf.c
new file mode 100644
index 0000000..e9b5f19
--- /dev/null
+++ b/argp-standalone/vsnprintf.c
@@ -0,0 +1,839 @@
+/* Copied from http://www.fiction.net/blong/programs/snprintf.c */
+
+/*
+ * 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
+ *
+ * Russ Allbery <rra@stanford.edu> 2000-08-26
+ * fixed return value to comply with C99
+ * fixed handling of snprintf(NULL, ...)
+ *
+ * Niels Möller <nisse@lysator.liu.se> 2004-03-05
+ * fixed calls to isdigit to use unsigned char.
+ * fixed calls to va_arg; short arguments are always passed as int.
+ *
+ **************************************************************/
+
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
+
+#include <string.h>
+#include <ctype.h>
+#include <sys/types.h>
+
+/* Define this as a fall through, HAVE_STDARG_H is probably already set */
+
+#define HAVE_VARARGS_H
+
+
+/* varargs declarations: */
+
+#if defined(HAVE_STDARG_H)
+# include <stdarg.h>
+# define HAVE_STDARGS /* let's hope that works everywhere (mj) */
+# define VA_LOCAL_DECL va_list ap
+# define VA_START(f) va_start(ap, f)
+# define VA_SHIFT(v,t) ; /* no-op for ANSI */
+# define VA_END va_end(ap)
+#else
+# if defined(HAVE_VARARGS_H)
+# include <varargs.h>
+# undef HAVE_STDARGS
+# define VA_LOCAL_DECL va_list ap
+# define VA_START(f) va_start(ap) /* f is ignored! */
+# define VA_SHIFT(v,t) v = va_arg(ap,t)
+# define VA_END va_end(ap)
+# else
+/*XX ** NO VARARGS ** XX*/
+# endif
+#endif
+
+#ifdef HAVE_LONG_DOUBLE
+#define LDOUBLE long double
+#else
+#define LDOUBLE double
+#endif
+
+int snprintf (char *str, size_t count, const char *fmt, ...);
+int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
+
+static int dopr (char *buffer, size_t maxlen, const char *format,
+ va_list args);
+static int fmtstr (char *buffer, size_t *currlen, size_t maxlen,
+ char *value, int flags, int min, int max);
+static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
+ long value, int base, int min, int max, int flags);
+static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
+ LDOUBLE fvalue, int min, int max, int flags);
+static int dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c );
+
+/*
+ * 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_SHORT 1
+#define DP_C_LONG 2
+#define DP_C_LDOUBLE 3
+
+#define char_to_int(p) (p - '0')
+#define MAX(p,q) ((p >= q) ? p : q)
+#define MIN(p,q) ((p <= q) ? p : q)
+
+static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
+{
+ unsigned char ch;
+ long value;
+ LDOUBLE fvalue;
+ char *strvalue;
+ int min;
+ int max;
+ int state;
+ int flags;
+ int cflags;
+ int total;
+ size_t currlen;
+
+ state = DP_S_DEFAULT;
+ currlen = flags = cflags = min = 0;
+ max = -1;
+ ch = *format++;
+ total = 0;
+
+ while (state != DP_S_DONE)
+ {
+ if (ch == '\0')
+ state = DP_S_DONE;
+
+ switch(state)
+ {
+ case DP_S_DEFAULT:
+ if (ch == '%')
+ state = DP_S_FLAGS;
+ else
+ total += dopr_outch (buffer, &currlen, maxlen, ch);
+ ch = *format++;
+ break;
+ case DP_S_FLAGS:
+ switch (ch)
+ {
+ case '-':
+ flags |= DP_F_MINUS;
+ ch = *format++;
+ break;
+ case '+':
+ flags |= DP_F_PLUS;
+ ch = *format++;
+ break;
+ case ' ':
+ flags |= DP_F_SPACE;
+ ch = *format++;
+ break;
+ case '#':
+ flags |= DP_F_NUM;
+ ch = *format++;
+ break;
+ case '0':
+ flags |= DP_F_ZERO;
+ ch = *format++;
+ break;
+ default:
+ state = DP_S_MIN;
+ break;
+ }
+ break;
+ case DP_S_MIN:
+ if (isdigit(ch))
+ {
+ min = 10*min + char_to_int (ch);
+ ch = *format++;
+ }
+ else if (ch == '*')
+ {
+ min = va_arg (args, int);
+ ch = *format++;
+ state = DP_S_DOT;
+ }
+ else
+ 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(ch))
+ {
+ if (max < 0)
+ max = 0;
+ max = 10*max + char_to_int (ch);
+ ch = *format++;
+ }
+ else if (ch == '*')
+ {
+ max = va_arg (args, int);
+ ch = *format++;
+ state = DP_S_MOD;
+ }
+ else
+ state = DP_S_MOD;
+ break;
+ case DP_S_MOD:
+ /* Currently, we don't support Long Long, bummer */
+ switch (ch)
+ {
+ case 'h':
+ cflags = DP_C_SHORT;
+ ch = *format++;
+ break;
+ case 'l':
+ cflags = DP_C_LONG;
+ ch = *format++;
+ break;
+ case 'L':
+ cflags = DP_C_LDOUBLE;
+ ch = *format++;
+ break;
+ default:
+ break;
+ }
+ state = DP_S_CONV;
+ break;
+ case DP_S_CONV:
+ switch (ch)
+ {
+ case 'd':
+ case 'i':
+ if (cflags == DP_C_SHORT)
+ value = (short) va_arg (args, int);
+ else if (cflags == DP_C_LONG)
+ value = va_arg (args, long int);
+ else
+ value = va_arg (args, int);
+ total += fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
+ break;
+ case 'o':
+ flags |= DP_F_UNSIGNED;
+ if (cflags == DP_C_SHORT)
+ value = (unsigned short) va_arg (args, unsigned);
+ else if (cflags == DP_C_LONG)
+ value = va_arg (args, unsigned long int);
+ else
+ value = va_arg (args, unsigned int);
+ total += fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags);
+ break;
+ case 'u':
+ flags |= DP_F_UNSIGNED;
+ if (cflags == DP_C_SHORT)
+ value = (unsigned short) va_arg (args, unsigned);
+ else if (cflags == DP_C_LONG)
+ value = va_arg (args, unsigned long int);
+ else
+ value = va_arg (args, unsigned int);
+ total += fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
+ break;
+ case 'X':
+ flags |= DP_F_UP;
+ case 'x':
+ flags |= DP_F_UNSIGNED;
+ if (cflags == DP_C_SHORT)
+ value = (unsigned short) va_arg (args, unsigned);
+ else if (cflags == DP_C_LONG)
+ value = va_arg (args, unsigned long int);
+ else
+ value = va_arg (args, unsigned int);
+ total += fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags);
+ break;
+ case 'f':
+ if (cflags == DP_C_LDOUBLE)
+ fvalue = va_arg (args, LDOUBLE);
+ else
+ fvalue = va_arg (args, double);
+ /* um, floating point? */
+ total += fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags);
+ break;
+ case 'E':
+ flags |= DP_F_UP;
+ case 'e':
+ if (cflags == DP_C_LDOUBLE)
+ fvalue = va_arg (args, LDOUBLE);
+ else
+ fvalue = va_arg (args, double);
+ break;
+ case 'G':
+ flags |= DP_F_UP;
+ case 'g':
+ if (cflags == DP_C_LDOUBLE)
+ fvalue = va_arg (args, LDOUBLE);
+ else
+ fvalue = va_arg (args, double);
+ break;
+ case 'c':
+ total += dopr_outch (buffer, &currlen, maxlen, va_arg (args, int));
+ break;
+ case 's':
+ strvalue = va_arg (args, char *);
+ total += fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max);
+ break;
+ case 'p':
+ strvalue = va_arg (args, void *);
+ total += fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min,
+ max, flags);
+ break;
+ case 'n':
+ if (cflags == DP_C_SHORT)
+ {
+ short int *num;
+ num = va_arg (args, short int *);
+ *num = currlen;
+ }
+ else if (cflags == DP_C_LONG)
+ {
+ long int *num;
+ num = va_arg (args, long int *);
+ *num = currlen;
+ }
+ else
+ {
+ int *num;
+ num = va_arg (args, int *);
+ *num = currlen;
+ }
+ break;
+ case '%':
+ total += dopr_outch (buffer, &currlen, maxlen, ch);
+ break;
+ case 'w':
+ /* not supported yet, treat as next char */
+ ch = *format++;
+ break;
+ default:
+ /* Unknown, skip */
+ break;
+ }
+ ch = *format++;
+ state = DP_S_DEFAULT;
+ flags = cflags = min = 0;
+ max = -1;
+ break;
+ case DP_S_DONE:
+ break;
+ default:
+ /* hmm? */
+ break; /* some picky compilers need this */
+ }
+ }
+ if (buffer != NULL)
+ {
+ if (currlen < maxlen - 1)
+ buffer[currlen] = '\0';
+ else
+ buffer[maxlen - 1] = '\0';
+ }
+ return total;
+}
+
+static int 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;
+ int total = 0;
+
+ if (value == 0)
+ {
+ value = "<NULL>";
+ }
+
+ for (strln = 0; value[strln]; ++strln); /* strlen */
+ if (max >= 0 && max < strln)
+ strln = max;
+ padlen = min - strln;
+ if (padlen < 0)
+ padlen = 0;
+ if (flags & DP_F_MINUS)
+ padlen = -padlen; /* Left Justify */
+
+ while (padlen > 0)
+ {
+ total += dopr_outch (buffer, currlen, maxlen, ' ');
+ --padlen;
+ }
+ while (*value && ((max < 0) || (cnt < max)))
+ {
+ total += dopr_outch (buffer, currlen, maxlen, *value++);
+ ++cnt;
+ }
+ while (padlen < 0)
+ {
+ total += dopr_outch (buffer, currlen, maxlen, ' ');
+ ++padlen;
+ }
+ return total;
+}
+
+/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
+
+static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
+ long value, int base, int min, int max, int flags)
+{
+ int signvalue = 0;
+ unsigned long uvalue;
+ char convert[20];
+ int place = 0;
+ int spadlen = 0; /* amount to space pad */
+ int zpadlen = 0; /* amount to zero pad */
+ int caps = 0;
+ int total = 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
+ dprint (1, (debugfile, "zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
+ zpadlen, spadlen, min, max, place));
+#endif
+
+ /* Spaces */
+ while (spadlen > 0)
+ {
+ total += dopr_outch (buffer, currlen, maxlen, ' ');
+ --spadlen;
+ }
+
+ /* Sign */
+ if (signvalue)
+ total += dopr_outch (buffer, currlen, maxlen, signvalue);
+
+ /* Zeros */
+ if (zpadlen > 0)
+ {
+ while (zpadlen > 0)
+ {
+ total += dopr_outch (buffer, currlen, maxlen, '0');
+ --zpadlen;
+ }
+ }
+
+ /* Digits */
+ while (place > 0)
+ total += dopr_outch (buffer, currlen, maxlen, convert[--place]);
+
+ /* Left Justified spaces */
+ while (spadlen < 0) {
+ total += dopr_outch (buffer, currlen, maxlen, ' ');
+ ++spadlen;
+ }
+
+ return total;
+}
+
+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 long round (LDOUBLE value)
+{
+ long intpart;
+
+ intpart = value;
+ value = value - intpart;
+ if (value >= 0.5)
+ intpart++;
+
+ return intpart;
+}
+
+static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
+ LDOUBLE fvalue, int min, int max, int flags)
+{
+ int signvalue = 0;
+ LDOUBLE ufvalue;
+ char iconvert[20];
+ char fconvert[20];
+ int iplace = 0;
+ int fplace = 0;
+ int padlen = 0; /* amount to pad */
+ int zpadlen = 0;
+ int caps = 0;
+ int total = 0;
+ long intpart;
+ long fracpart;
+
+ /*
+ * 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
+
+ intpart = ufvalue;
+
+ /*
+ * 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
+ */
+ fracpart = round ((pow10 (max)) * (ufvalue - intpart));
+
+ if (fracpart >= pow10 (max))
+ {
+ intpart++;
+ fracpart -= pow10 (max);
+ }
+
+#ifdef DEBUG_SNPRINTF
+ dprint (1, (debugfile, "fmtfp: %f =? %d.%d\n", fvalue, intpart, fracpart));
+#endif
+
+ /* Convert integer part */
+ do {
+ iconvert[iplace++] =
+ (caps? "0123456789ABCDEF":"0123456789abcdef")[intpart % 10];
+ intpart = (intpart / 10);
+ } while(intpart && (iplace < 20));
+ if (iplace == 20) iplace--;
+ iconvert[iplace] = 0;
+
+ /* Convert fractional part */
+ do {
+ fconvert[fplace++] =
+ (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10];
+ fracpart = (fracpart / 10);
+ } while(fracpart && (fplace < 20));
+ if (fplace == 20) 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)
+ {
+ total += dopr_outch (buffer, currlen, maxlen, signvalue);
+ --padlen;
+ signvalue = 0;
+ }
+ while (padlen > 0)
+ {
+ total += dopr_outch (buffer, currlen, maxlen, '0');
+ --padlen;
+ }
+ }
+ while (padlen > 0)
+ {
+ total += dopr_outch (buffer, currlen, maxlen, ' ');
+ --padlen;
+ }
+ if (signvalue)
+ total += dopr_outch (buffer, currlen, maxlen, signvalue);
+
+ while (iplace > 0)
+ total += dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]);
+
+ /*
+ * Decimal point. This should probably use locale to find the correct
+ * char to print out.
+ */
+ if (max > 0)
+ {
+ total += dopr_outch (buffer, currlen, maxlen, '.');
+
+ while (fplace > 0)
+ total += dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
+ }
+
+ while (zpadlen > 0)
+ {
+ total += dopr_outch (buffer, currlen, maxlen, '0');
+ --zpadlen;
+ }
+
+ while (padlen < 0)
+ {
+ total += dopr_outch (buffer, currlen, maxlen, ' ');
+ ++padlen;
+ }
+
+ return total;
+}
+
+static int dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c)
+{
+ if (*currlen + 1 < maxlen)
+ buffer[(*currlen)++] = c;
+ return 1;
+}
+
+#ifndef HAVE_VSNPRINTF
+int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
+{
+ if (str != NULL)
+ str[0] = 0;
+ return dopr(str, count, fmt, args);
+}
+#endif /* !HAVE_VSNPRINTF */
+
+#ifndef HAVE_SNPRINTF
+/* VARARGS3 */
+#ifdef HAVE_STDARGS
+int snprintf (char *str,size_t count,const char *fmt,...)
+#else
+int snprintf (va_alist) va_dcl
+#endif
+{
+#ifndef HAVE_STDARGS
+ char *str;
+ size_t count;
+ char *fmt;
+#endif
+ VA_LOCAL_DECL;
+ int total;
+
+ VA_START (fmt);
+ VA_SHIFT (str, char *);
+ VA_SHIFT (count, size_t );
+ VA_SHIFT (fmt, char *);
+ total = vsnprintf(str, count, fmt, ap);
+ VA_END;
+ return total;
+}
+#endif /* !HAVE_SNPRINTF */
+
+#ifdef TEST_SNPRINTF
+#ifndef LONG_STRING
+#define LONG_STRING 1024
+#endif
+int main (void)
+{
+ char buf1[LONG_STRING];
+ char buf2[LONG_STRING];
+ char *fp_fmt[] = {
+ "%-1.5f",
+ "%1.5f",
+ "%123.9f",
+ "%10.5f",
+ "% 10.5f",
+ "%+22.9f",
+ "%+4.9f",
+ "%01.3f",
+ "%4f",
+ "%3.1f",
+ "%3.2f",
+ "%.0f",
+ "%.1f",
+ NULL
+ };
+ double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996,
+ 0.9996, 1.996, 4.136, 0};
+ char *int_fmt[] = {
+ "%-1.5d",
+ "%1.5d",
+ "%123.9d",
+ "%5.5d",
+ "%10.5d",
+ "% 10.5d",
+ "%+22.33d",
+ "%01.3d",
+ "%4d",
+ NULL
+ };
+ long int_nums[] = { -1, 134, 91340, 341, 0203, 0};
+ int x, y;
+ int fail = 0;
+ int num = 0;
+
+ printf ("Testing snprintf format codes against system sprintf...\n");
+
+ for (x = 0; fp_fmt[x] != NULL ; x++)
+ for (y = 0; fp_nums[y] != 0 ; y++)
+ {
+ snprintf (buf1, sizeof (buf1), fp_fmt[x], fp_nums[y]);
+ sprintf (buf2, fp_fmt[x], fp_nums[y]);
+ if (strcmp (buf1, buf2))
+ {
+ printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n",
+ fp_fmt[x], buf1, buf2);
+ fail++;
+ }
+ num++;
+ }
+
+ for (x = 0; int_fmt[x] != NULL ; x++)
+ for (y = 0; int_nums[y] != 0 ; y++)
+ {
+ snprintf (buf1, sizeof (buf1), int_fmt[x], int_nums[y]);
+ sprintf (buf2, int_fmt[x], int_nums[y]);
+ if (strcmp (buf1, buf2))
+ {
+ printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n",
+ int_fmt[x], buf1, buf2);
+ fail++;
+ }
+ num++;
+ }
+ printf ("%d tests failed out of %d.\n", fail, num);
+}
+#endif /* SNPRINTF_TEST */
+
+#endif /* !HAVE_SNPRINTF */
diff --git a/auth/Makefile.am b/auth/Makefile.am
new file mode 100644
index 0000000..6bd54ee
--- /dev/null
+++ b/auth/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS = addr login
+
+CLEANFILES =
diff --git a/auth/addr/Makefile.am b/auth/addr/Makefile.am
new file mode 100644
index 0000000..d471a3f
--- /dev/null
+++ b/auth/addr/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS = src
+
+CLEANFILES =
diff --git a/auth/addr/src/Makefile.am b/auth/addr/src/Makefile.am
new file mode 100644
index 0000000..cca4061
--- /dev/null
+++ b/auth/addr/src/Makefile.am
@@ -0,0 +1,12 @@
+auth_LTLIBRARIES = addr.la
+authdir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/auth
+
+addr_la_LDFLAGS = -module -avoidversion
+
+addr_la_SOURCES = addr.c
+addr_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
+
+AM_CFLAGS = -fPIC -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -Wall -D$(GF_HOST_OS)\
+ -I$(top_srcdir)/libglusterfs/src -shared -nostartfiles $(GF_CFLAGS)
+
+CLEANFILES =
diff --git a/auth/addr/src/addr.c b/auth/addr/src/addr.c
new file mode 100644
index 0000000..0b248b4
--- /dev/null
+++ b/auth/addr/src/addr.c
@@ -0,0 +1,208 @@
+/*
+ Copyright (c) 2007, 2008 Z RESEARCH, Inc. <http://www.zresearch.com>
+ This file is part of GlusterFS.
+
+ GlusterFS 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.
+
+ GlusterFS 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 _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include <fnmatch.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include "authenticate.h"
+#include "dict.h"
+
+#define ADDR_DELIMITER " ,"
+#define PRIVILAGED_PORT_CIELING 1024
+
+#ifndef AF_INET_SDP
+#define AF_INET_SDP 27
+#endif
+
+auth_result_t
+gf_auth (dict_t *input_params, dict_t *config_params)
+{
+ char *name = NULL;
+ char *searchstr = NULL;
+ char peer_addr[UNIX_PATH_MAX];
+ data_t *peer_info_data = NULL;
+ peer_info_t *peer_info = NULL;
+ data_t *allow_addr = NULL, *reject_addr = NULL;
+ char is_inet_sdp = 0;
+
+ name = data_to_str (dict_get (input_params, "remote-subvolume"));
+ if (!name) {
+ gf_log ("authenticate/addr",
+ GF_LOG_ERROR,
+ "remote-subvolume not specified");
+ return AUTH_DONT_CARE;
+ }
+
+ asprintf (&searchstr, "auth.addr.%s.allow", name);
+ allow_addr = dict_get (config_params,
+ searchstr);
+ free (searchstr);
+
+ asprintf (&searchstr, "auth.addr.%s.reject", name);
+ reject_addr = dict_get (config_params,
+ searchstr);
+ free (searchstr);
+
+ if (!allow_addr) {
+ /* TODO: backword compatibility */
+ asprintf (&searchstr, "auth.ip.%s.allow", name);
+ allow_addr = dict_get (config_params, searchstr);
+ free (searchstr);
+ }
+
+ if (!(allow_addr || reject_addr)) {
+ gf_log ("auth/addr", GF_LOG_DEBUG,
+ "none of the options auth.addr.%s.allow or "
+ "auth.addr.%s.reject specified, returning auth_dont_care",
+ name, name);
+ return AUTH_DONT_CARE;
+ }
+
+ peer_info_data = dict_get (input_params, "peer-info");
+ if (!peer_info_data) {
+ gf_log ("authenticate/addr",
+ GF_LOG_ERROR,
+ "peer-info not present");
+ return AUTH_DONT_CARE;
+ }
+
+ peer_info = data_to_ptr (peer_info_data);
+
+ switch (((struct sockaddr *) &peer_info->sockaddr)->sa_family)
+ {
+ case AF_INET_SDP:
+ is_inet_sdp = 1;
+ ((struct sockaddr *) &peer_info->sockaddr)->sa_family = AF_INET;
+
+ case AF_INET:
+ case AF_INET6:
+ {
+ char *service;
+ uint16_t peer_port;
+ strcpy (peer_addr, peer_info->identifier);
+ service = strrchr (peer_addr, ':');
+ *service = '\0';
+ service ++;
+
+ if (is_inet_sdp) {
+ ((struct sockaddr *) &peer_info->sockaddr)->sa_family = AF_INET_SDP;
+ }
+
+ peer_port = atoi (service);
+ if (peer_port >= PRIVILAGED_PORT_CIELING) {
+ gf_log ("auth/addr", GF_LOG_ERROR,
+ "client is bound to port %d which is not privilaged",
+ peer_port);
+ return AUTH_DONT_CARE;
+ }
+ break;
+
+ case AF_UNIX:
+ strcpy (peer_addr, peer_info->identifier);
+ break;
+
+ default:
+ gf_log ("authenticate/addr", GF_LOG_ERROR,
+ "unknown address family %d",
+ ((struct sockaddr *) &peer_info->sockaddr)->sa_family);
+ return AUTH_DONT_CARE;
+ }
+ }
+
+ if (reject_addr) {
+ char *addr_str = NULL;
+ char *tmp;
+ char *addr_cpy = strdup (reject_addr->data);
+
+ addr_str = strtok_r (addr_cpy, ADDR_DELIMITER, &tmp);
+
+ while (addr_str) {
+ char negate = 0, match =0;
+ gf_log (name, GF_LOG_DEBUG,
+ "rejected = \"%s\", received addr = \"%s\"",
+ addr_str, peer_addr);
+ if (addr_str[0] == '!') {
+ negate = 1;
+ addr_str++;
+ }
+
+ match = fnmatch (addr_str,
+ peer_addr,
+ 0);
+ if (negate ? match : !match) {
+ free (addr_cpy);
+ return AUTH_REJECT;
+ }
+ addr_str = strtok_r (NULL, ADDR_DELIMITER, &tmp);
+ }
+ free (addr_cpy);
+ }
+
+ if (allow_addr) {
+ char *addr_str = NULL;
+ char *tmp;
+ char *addr_cpy = strdup (allow_addr->data);
+
+ addr_str = strtok_r (addr_cpy, ADDR_DELIMITER, &tmp);
+
+ while (addr_str) {
+ char negate = 0, match = 0;
+ gf_log (name, GF_LOG_DEBUG,
+ "allowed = \"%s\", received addr = \"%s\"",
+ addr_str, peer_addr);
+ if (addr_str[0] == '!') {
+ negate = 1;
+ addr_str++;
+ }
+
+ match = fnmatch (addr_str,
+ peer_addr,
+ 0);
+
+ if (negate ? match : !match) {
+ free (addr_cpy);
+ return AUTH_ACCEPT;
+ }
+ addr_str = strtok_r (NULL, ADDR_DELIMITER, &tmp);
+ }
+ free (addr_cpy);
+ }
+
+ return AUTH_DONT_CARE;
+}
+
+struct volume_options options[] = {
+ { .key = {"auth.addr.*.allow"},
+ .type = GF_OPTION_TYPE_ANY
+ },
+ { .key = {"auth.addr.*.reject"},
+ .type = GF_OPTION_TYPE_ANY
+ },
+ /* Backword compatibility */
+ { .key = {"auth.ip.*.allow"},
+ .type = GF_OPTION_TYPE_ANY
+ },
+ { .key = {NULL} }
+};
diff --git a/auth/login/Makefile.am b/auth/login/Makefile.am
new file mode 100644
index 0000000..d471a3f
--- /dev/null
+++ b/auth/login/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS = src
+
+CLEANFILES =
diff --git a/auth/login/src/Makefile.am b/auth/login/src/Makefile.am
new file mode 100644
index 0000000..eb7b990
--- /dev/null
+++ b/auth/login/src/Makefile.am
@@ -0,0 +1,13 @@
+auth_LTLIBRARIES = login.la
+authdir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/auth
+
+login_la_LDFLAGS = -module -avoidversion
+
+login_la_SOURCES = login.c
+login_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
+
+
+AM_CFLAGS = -fPIC -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -Wall -D$(GF_HOST_OS)\
+ -I$(top_srcdir)/libglusterfs/src -shared -nostartfiles $(GF_CFLAGS)
+
+CLEANFILES =
diff --git a/auth/login/src/login.c b/auth/login/src/login.c
new file mode 100644
index 0000000..88c9f82
--- /dev/null
+++ b/auth/login/src/login.c
@@ -0,0 +1,100 @@
+/*
+ Copyright (c) 2007, 2008 Z RESEARCH, Inc. <http://www.zresearch.com>
+ This file is part of GlusterFS.
+
+ GlusterFS 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.
+
+ GlusterFS 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 _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include <fnmatch.h>
+#include "authenticate.h"
+
+auth_result_t gf_auth (dict_t *input_params, dict_t *config_params)
+{
+ char *username = NULL, *password = NULL;
+ data_t *allow_user = NULL, *username_data = NULL, *password_data = NULL;
+ int32_t result = AUTH_DONT_CARE;
+ char *brick_name = NULL, *searchstr = NULL;
+
+ username_data = dict_get (input_params, "username");
+ if (!username_data)
+ return AUTH_DONT_CARE;
+
+ username = data_to_str (username_data);
+
+ password_data = dict_get (input_params, "password");
+ if (!password_data)
+ return AUTH_DONT_CARE;
+
+ password = data_to_str (password_data);
+
+ brick_name = data_to_str (dict_get (input_params, "remote-subvolume"));
+ if (!brick_name) {
+ gf_log ("auth/login",
+ GF_LOG_ERROR,
+ "remote-subvolume not specified");
+ return AUTH_REJECT;
+ }
+
+ asprintf (&searchstr, "auth.login.%s.allow", brick_name);
+ allow_user = dict_get (config_params,
+ searchstr);
+ free (searchstr);
+
+ if (allow_user) {
+ char *username_str = NULL;
+ char *tmp;
+ char *username_cpy = strdup (allow_user->data);
+
+ username_str = strtok_r (username_cpy, " ,", &tmp);
+
+ while (username_str) {
+ data_t *passwd_data = NULL;
+ if (!fnmatch (username_str,
+ username,
+ 0)) {
+ asprintf (&searchstr, "auth.login.%s.password", username);
+ passwd_data = dict_get (config_params, searchstr);
+ if (!passwd_data) {
+ gf_log ("auth/login",
+ GF_LOG_DEBUG,
+ "wrong username/password combination");
+ result = AUTH_REJECT;
+ }
+ else
+ result = !strcmp (data_to_str (passwd_data), password) ? AUTH_ACCEPT : AUTH_REJECT;
+ break;
+ }
+ username_str = strtok_r (NULL, " ,", &tmp);
+ }
+ free (username_cpy);
+ }
+
+ return result;
+}
+
+struct volume_options options[] = {
+ { .key = {"auth.login.*.allow"},
+ .type = GF_OPTION_TYPE_ANY
+ },
+ { .key = {"auth.login.*.password"},
+ .type = GF_OPTION_TYPE_ANY
+ },
+ { .key = {NULL} }
+};
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..e20408b
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+aclocal
+autoheader
+(libtoolize --automake --copy --force || glibtoolize --automake --copy --force)
+autoconf
+automake --add-missing --copy --foreign
+cd argp-standalone;./autogen.sh
diff --git a/booster/Makefile.am b/booster/Makefile.am
new file mode 100644
index 0000000..e1c45f3
--- /dev/null
+++ b/booster/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS=src \ No newline at end of file
diff --git a/booster/src/Makefile.am b/booster/src/Makefile.am
new file mode 100644
index 0000000..9b6e77f
--- /dev/null
+++ b/booster/src/Makefile.am
@@ -0,0 +1,17 @@
+xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/performance
+
+ldpreload_PROGRAMS = glusterfs-booster.so
+ldpreloaddir = $(libdir)/glusterfs/
+glusterfs_booster_so_SOURCES = booster.c
+glusterfs_booster_so_CFLAGS = -I$(top_srcdir)/libglusterfsclient/src/ -D_GNU_SOURCE -D$(GF_HOST_OS) -fPIC -Wall \
+ -pthread $(GF_BOOSTER_CFLAGS)
+glusterfs_booster_so_CPPFLAGS = -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE \
+ -I$(top_srcdir)/libglusterfsclient/src \
+ -I$(top_srcdir)/libglusterfs/src -DDATADIR=\"$(localstatedir)\" \
+ -DCONFDIR=\"$(sysconfdir)/glusterfs\"
+glusterfs_booster_so_LDFLAGS = -shared -nostartfiles
+glusterfs_booster_so_LDADD = -L$(top_builddir)/libglusterfs/src -lglusterfs \
+ -L$(top_builddir)/libglusterfsclient/src -lglusterfsclient
+
+CLEANFILES =
+
diff --git a/booster/src/booster.c b/booster/src/booster.c
new file mode 100644
index 0000000..cf5f788
--- /dev/null
+++ b/booster/src/booster.c
@@ -0,0 +1,920 @@
+/*
+ Copyright (c) 2007, 2008 Z RESEARCH, Inc. <http://www.zresearch.com>
+ This file is part of GlusterFS.
+
+ GlusterFS 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.
+
+ GlusterFS 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 _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include <dlfcn.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/uio.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <libglusterfsclient.h>
+#include <list.h>
+#include <pthread.h>
+#include <fcntl.h>
+#include <sys/xattr.h>
+#include <string.h>
+#include <assert.h>
+
+#ifndef GF_UNIT_KB
+#define GF_UNIT_KB 1024
+#endif
+
+#ifndef UNIX_PATH_MAX
+#define UNIX_PATH_MAX 108
+#endif
+
+struct _inode;
+struct _dict;
+struct _fd {
+ pid_t pid;
+ struct list_head inode_list;
+ struct _inode *inode;
+ struct _dict *ctx;
+ int32_t refcount;
+};
+
+typedef struct _fdtable fdtable_t;
+typedef struct _fd fd_t;
+
+
+inline void
+gf_fd_put (struct _fdtable *fdtable, int64_t fd);
+
+struct _fd *
+gf_fd_fdptr_get (struct _fdtable *fdtable, int64_t fd);
+
+struct _fdtable *
+gf_fd_fdtable_alloc (void);
+
+void
+gf_fd_fdtable_destroy (struct _fdtable *);
+
+int32_t
+gf_fd_unused_get (struct _fdtable *fdtable, struct _fd *fdptr);
+
+int32_t
+gf_fd_unused_get2 (struct _fdtable *fdtable, struct _fd *fdptr, int64_t fd);
+
+void
+fd_unref (struct _fd *fd);
+
+fd_t *
+fd_ref (struct _fd *fd);
+
+pid_t
+getpid (void);
+
+ssize_t
+write (int fd, const void *buf, size_t count);
+
+/* open, open64, creat */
+static int (*real_open) (const char *pathname, int flags, ...);
+static int (*real_open64) (const char *pathname, int flags, ...);
+static int (*real_creat) (const char *pathname, mode_t mode);
+
+/* read, readv, pread, pread64 */
+static ssize_t (*real_read) (int fd, void *buf, size_t count);
+static ssize_t (*real_readv) (int fd, const struct iovec *vector, int count);
+static ssize_t (*real_pread) (int fd, void *buf, size_t count, unsigned long offset);
+static ssize_t (*real_pread64) (int fd, void *buf, size_t count, uint64_t offset);
+
+/* write, writev, pwrite, pwrite64 */
+static ssize_t (*real_write) (int fd, const void *buf, size_t count);
+static ssize_t (*real_writev) (int fd, const struct iovec *vector, int count);
+static ssize_t (*real_pwrite) (int fd, const void *buf, size_t count, unsigned long offset);
+static ssize_t (*real_pwrite64) (int fd, const void *buf, size_t count, uint64_t offset);
+
+/* lseek, llseek, lseek64 */
+static off_t (*real_lseek) (int fildes, unsigned long offset, int whence);
+static off_t (*real_lseek64) (int fildes, uint64_t offset, int whence);
+
+/* close */
+static int (*real_close) (int fd);
+
+/* dup dup2 */
+static int (*real_dup) (int fd);
+static int (*real_dup2) (int oldfd, int newfd);
+
+static pid_t (*real_fork) (void);
+
+#define RESOLVE(sym) do { \
+ if (!real_##sym) \
+ real_##sym = dlsym (RTLD_NEXT, #sym); \
+ } while (0)
+
+/*TODO: set proper value */
+#define MOUNT_HASH_SIZE 256
+
+struct booster_mount {
+ dev_t st_dev;
+ libglusterfs_handle_t handle;
+ struct list_head device_list;
+};
+typedef struct booster_mount booster_mount_t;
+
+struct booster_mount_table {
+ pthread_mutex_t lock;
+ struct list_head *mounts;
+ int32_t hash_size;
+};
+typedef struct booster_mount_table booster_mount_table_t;
+
+static fdtable_t *booster_glfs_fdtable = NULL;
+static booster_mount_table_t *booster_mount_table = NULL;
+
+static int32_t
+booster_put_handle (booster_mount_table_t *table,
+ dev_t st_dev,
+ libglusterfs_handle_t handle)
+{
+ int32_t hash = 0;
+ booster_mount_t *mount = NULL, *tmp = NULL;
+ int32_t ret = 0;
+
+ mount = calloc (1, sizeof (*mount));
+ if (!mount) {
+ return -1;
+ }
+
+ // ERR_ABORT (mount);
+ INIT_LIST_HEAD (&mount->device_list);
+ mount->st_dev = st_dev;
+ mount->handle = handle;
+
+ hash = st_dev % table->hash_size;
+
+ pthread_mutex_lock (&table->lock);
+ {
+ list_for_each_entry (tmp, &table->mounts[hash], device_list) {
+ if (tmp->st_dev == st_dev) {
+ ret = -1;
+ errno = EEXIST;
+ goto unlock;
+ }
+ }
+
+ list_add (&mount->device_list, &table->mounts[hash]);
+ }
+unlock:
+ pthread_mutex_unlock (&table->lock);
+
+ return ret;
+}
+
+
+static inline long
+booster_get_glfs_fd (fdtable_t *fdtable, int fd)
+{
+ fd_t *glfs_fd = NULL;
+
+ glfs_fd = gf_fd_fdptr_get (fdtable, fd);
+ return (long) glfs_fd;
+}
+
+
+static inline void
+booster_put_glfs_fd (long glfs_fd)
+{
+ fd_unref ((fd_t *)glfs_fd);
+}
+
+
+static inline int32_t
+booster_get_unused_fd (fdtable_t *fdtable, long glfs_fd, int fd)
+{
+ int32_t ret = -1;
+ ret = gf_fd_unused_get2 (fdtable, (fd_t *)glfs_fd, fd);
+ return ret;
+}
+
+
+static inline void
+booster_put_fd (fdtable_t *fdtable, int fd)
+{
+ gf_fd_put (fdtable, fd);
+}
+
+
+static libglusterfs_handle_t
+booster_get_handle (booster_mount_table_t *table, dev_t st_dev)
+{
+ int32_t hash = 0;
+ booster_mount_t *mount = NULL;
+ libglusterfs_handle_t handle = NULL;
+
+ hash = st_dev % table->hash_size;
+
+ pthread_mutex_lock (&table->lock);
+ {
+ list_for_each_entry (mount, &table->mounts[hash], device_list) {
+ if (mount->st_dev == st_dev) {
+ handle = mount->handle;
+ break;
+ }
+ }
+ }
+ pthread_mutex_unlock (&table->lock);
+
+ return handle;
+}
+
+
+void
+do_open (int fd, int flags, mode_t mode)
+{
+ char *specfile = NULL;
+ libglusterfs_handle_t handle;
+ int32_t file_size;
+ struct stat st = {0,};
+ int32_t ret = -1;
+
+ ret = fstat (fd, &st);
+ if (ret == -1) {
+ return;
+ }
+
+ if (!booster_mount_table) {
+ return;
+ }
+
+ handle = booster_get_handle (booster_mount_table, st.st_dev);
+ if (!handle) {
+ FILE *specfp = NULL;
+
+ glusterfs_init_ctx_t ctx = {
+ .loglevel = "critical",
+ .lookup_timeout = 600,
+ .stat_timeout = 600,
+ };
+
+ file_size = fgetxattr (fd, "user.glusterfs-booster-volfile", NULL, 0);
+ if (file_size == -1) {
+ return;
+ }
+
+ specfile = calloc (1, file_size);
+ if (!specfile) {
+ fprintf (stderr, "cannot allocate memory: %s\n", strerror (errno));
+ return;
+ }
+
+ ret = fgetxattr (fd, "user.glusterfs-booster-volfile", specfile, file_size);
+ if (ret == -1) {
+ free (specfile);
+ return ;
+ }
+
+ specfp = tmpfile ();
+ if (!specfp) {
+ free (specfile);
+ return;
+ }
+
+ ret = fwrite (specfile, file_size, 1, specfp);
+ if (ret != 1) {
+ fclose (specfp);
+ free (specfile);
+ }
+
+ fseek (specfp, 0L, SEEK_SET);
+
+ ctx.logfile = getenv ("GLFS_BOOSTER_LOGFILE");
+ ctx.specfp = specfp;
+
+ handle = glusterfs_init (&ctx);
+
+ free (specfile);
+ fclose (specfp);
+
+ if (!handle) {
+ return;
+ }
+
+ ret = booster_put_handle (booster_mount_table, st.st_dev, handle);
+ if (ret == -1) {
+ glusterfs_fini (handle);
+ if (errno != EEXIST) {
+ return;
+ }
+ }
+ }
+
+ if (handle) {
+ long glfs_fd;
+ char path [UNIX_PATH_MAX];
+ ret = fgetxattr (fd, "user.glusterfs-booster-path", path, UNIX_PATH_MAX);
+ if (ret == -1) {
+ return;
+ }
+
+ glfs_fd = glusterfs_open (handle, path, flags, mode);
+ if (glfs_fd) {
+ ret = booster_get_unused_fd (booster_glfs_fdtable, glfs_fd, fd);
+ if (ret == -1) {
+ glusterfs_close (glfs_fd);
+ return;
+ }
+ }
+ }
+
+ return;
+}
+
+#ifndef __USE_FILE_OFFSET64
+int
+open (const char *pathname, int flags, ...)
+{
+ int ret;
+ mode_t mode = 0;
+ va_list ap;
+
+ if (flags & O_CREAT) {
+ va_start (ap, flags);
+ mode = va_arg (ap, mode_t);
+ va_end (ap);
+
+ ret = real_open (pathname, flags, mode);
+ } else {
+ ret = real_open (pathname, flags);
+ }
+
+ if (ret != -1) {
+ flags &= ~ O_CREAT;
+ do_open (ret, flags, mode);
+ }
+
+ return ret;
+}
+#endif
+
+#if defined (__USE_LARGEFILE64) || !defined (__USE_FILE_OFFSET64)
+int
+open64 (const char *pathname, int flags, ...)
+{
+ int ret;
+ mode_t mode = 0;
+ va_list ap;
+
+ if (flags & O_CREAT) {
+ va_start (ap, flags);
+ mode = va_arg (ap, mode_t);
+ va_end (ap);
+
+ ret = real_open64 (pathname, flags, mode);
+ } else {
+ ret = real_open64 (pathname, flags);
+ }
+
+ if (ret != -1) {
+ flags &= ~O_CREAT;
+ do_open (ret, flags, mode);
+ }
+
+ return ret;
+}
+#endif
+
+int
+creat (const char *pathname, mode_t mode)
+{
+ int ret;
+
+ ret = real_creat (pathname, mode);
+
+ if (ret != -1) {
+ do_open (ret, O_WRONLY | O_TRUNC, mode);
+ }
+
+ return ret;
+}
+
+
+/* pread */
+
+ssize_t
+pread (int fd, void *buf, size_t count, unsigned long offset)
+{
+ ssize_t ret;
+ long glfs_fd = 0;
+
+ glfs_fd = booster_get_glfs_fd (booster_glfs_fdtable, fd);
+ if (!glfs_fd) {
+ ret = real_pread (fd, buf, count, offset);
+ } else {
+ ret = glusterfs_pread (glfs_fd, buf, count, offset);
+ if (ret == -1) {
+ ret = real_pread (fd, buf, count, offset);
+ }
+ booster_put_glfs_fd (glfs_fd);
+ }
+
+ return ret;
+}
+
+
+ssize_t
+pread64 (int fd, void *buf, size_t count, uint64_t offset)
+{
+ ssize_t ret;
+ long glfs_fd = 0;
+
+ glfs_fd = booster_get_glfs_fd (booster_glfs_fdtable, fd);
+ if (!glfs_fd) {
+ ret = real_pread (fd, buf, count, offset);
+ } else {
+ ret = glusterfs_pread (glfs_fd, buf, count, offset);
+ if (ret == -1) {
+ ret = real_pread (fd, buf, count, offset);
+ }
+ }
+
+ return ret;
+}
+
+
+ssize_t
+read (int fd, void *buf, size_t count)
+{
+ int ret;
+ long glfs_fd;
+
+ glfs_fd = booster_get_glfs_fd (booster_glfs_fdtable, fd);
+ if (!glfs_fd) {
+ ret = real_read (fd, buf, count);
+ } else {
+ uint64_t offset = 0;
+ offset = real_lseek64 (fd, 0L, SEEK_CUR);
+ if ((int64_t)offset != -1) {
+ ret = glusterfs_lseek (glfs_fd, offset, SEEK_SET);
+ if (ret != -1) {
+ ret = glusterfs_read (glfs_fd, buf, count);
+ }
+ } else {
+ ret = -1;
+ }
+
+ if (ret == -1) {
+ ret = real_read (fd, buf, count);
+ }
+
+ if (ret > 0 && ((int64_t) offset) >= 0) {
+ real_lseek64 (fd, ret + offset, SEEK_SET);
+ }
+
+ booster_put_glfs_fd (glfs_fd);
+ }
+
+ return ret;
+}
+
+
+ssize_t
+readv (int fd, const struct iovec *vector, int count)
+{
+ int ret;
+ long glfs_fd = 0;
+
+ glfs_fd = booster_get_glfs_fd (booster_glfs_fdtable, fd);
+ if (!glfs_fd) {
+ ret = real_readv (fd, vector, count);
+ } else {
+ uint64_t offset = 0;
+ offset = real_lseek64 (fd, 0L, SEEK_CUR);
+ if ((int64_t)offset != -1) {
+ ret = glusterfs_lseek (glfs_fd, offset, SEEK_SET);
+ if (ret != -1) {
+ ret = glusterfs_readv (glfs_fd, vector, count);
+ }
+ } else {
+ ret = -1;
+ }
+
+ ret = glusterfs_readv (glfs_fd, vector, count);
+ if (ret > 0) {
+ real_lseek64 (fd, offset + ret, SEEK_SET);
+ }
+
+ booster_put_glfs_fd (glfs_fd);
+ }
+
+ return ret;
+}
+
+
+ssize_t
+write (int fd, const void *buf, size_t count)
+{
+ int ret;
+ long glfs_fd = 0;
+
+ glfs_fd = booster_get_glfs_fd (booster_glfs_fdtable, fd);
+
+ if (!glfs_fd) {
+ ret = real_write (fd, buf, count);
+ } else {
+ uint64_t offset = 0;
+ offset = real_lseek64 (fd, 0L, SEEK_CUR);
+ if (((int64_t) offset) != -1) {
+ ret = glusterfs_lseek (glfs_fd, offset, SEEK_SET);
+ if (ret != -1) {
+ ret = glusterfs_write (glfs_fd, buf, count);
+ }
+ } else {
+ ret = -1;
+ }
+
+ if (ret == -1) {
+ ret = real_write (fd, buf, count);
+ }
+
+ if (ret > 0 && ((int64_t) offset) >= 0) {
+ real_lseek64 (fd, offset + ret, SEEK_SET);
+ }
+ booster_put_glfs_fd (glfs_fd);
+ }
+
+ return ret;
+}
+
+ssize_t
+writev (int fd, const struct iovec *vector, int count)
+{
+ int ret = 0;
+ long glfs_fd = 0;
+
+ glfs_fd = booster_get_glfs_fd (booster_glfs_fdtable, fd);
+
+ if (!glfs_fd) {
+ ret = real_writev (fd, vector, count);
+ } else {
+ uint64_t offset = 0;
+ offset = real_lseek64 (fd, 0L, SEEK_CUR);
+
+ if (((int64_t) offset) != -1) {
+ ret = glusterfs_lseek (glfs_fd, offset, SEEK_SET);
+ if (ret != -1) {
+ ret = glusterfs_writev (glfs_fd, vector, count);
+ }
+ } else {
+ ret = -1;
+ }
+
+/* ret = glusterfs_writev (glfs_fd, vector, count); */
+ if (ret == -1) {
+ ret = real_writev (fd, vector, count);
+ }
+
+ if (ret > 0 && ((int64_t)offset) >= 0) {
+ real_lseek64 (fd, offset + ret, SEEK_SET);
+ }
+
+ booster_put_glfs_fd (glfs_fd);
+ }
+
+ return ret;
+}
+
+
+ssize_t
+pwrite (int fd, const void *buf, size_t count, unsigned long offset)
+{
+ int ret;
+ long glfs_fd = 0;
+
+ assert (real_pwrite != NULL);
+
+ glfs_fd = booster_get_glfs_fd (booster_glfs_fdtable, fd);
+
+ if (!glfs_fd) {
+ ret = real_pwrite (fd, buf, count, offset);
+ } else {
+ ret = glusterfs_pwrite (glfs_fd, buf, count, offset);
+ if (ret == -1) {
+ ret = real_pwrite (fd, buf, count, offset);
+ }
+ booster_put_glfs_fd (glfs_fd);
+ }
+
+ return ret;
+}
+
+
+ssize_t
+pwrite64 (int fd, const void *buf, size_t count, uint64_t offset)
+{
+ int ret;
+ long glfs_fd = 0;
+
+ glfs_fd = booster_get_glfs_fd (booster_glfs_fdtable, fd);
+
+ if (!glfs_fd) {
+ ret = real_pwrite64 (fd, buf, count, offset);
+ } else {
+ ret = glusterfs_pwrite (glfs_fd, buf, count, offset);
+ if (ret == -1) {
+ ret = real_pwrite64 (fd, buf, count, offset);
+ }
+ }
+
+ return ret;
+}
+
+
+int
+close (int fd)
+{
+ int ret = -1;
+ long glfs_fd = 0;
+/* struct stat st = {0,}; */
+
+/* ret = fstat (fd, &st);
+ if (ret != -1) {
+ libglusterfs_handle_t handle = 0;
+ handle = booster_get_handle (booster_mount_table, st.st_dev);
+ if (handle) { */
+ glfs_fd = booster_get_glfs_fd (booster_glfs_fdtable, fd);
+
+ if (glfs_fd) {
+ booster_put_fd (booster_glfs_fdtable, fd);
+ ret = glusterfs_close (glfs_fd);
+ booster_put_glfs_fd (glfs_fd);
+ }
+/*}
+ }*/
+
+ ret = real_close (fd);
+
+ return ret;
+}
+
+#ifndef _LSEEK_DECLARED
+#define _LSEEK_DECLARED
+off_t
+lseek (int filedes, unsigned long offset, int whence)
+{
+ int ret;
+ long glfs_fd = 0;
+
+ ret = real_lseek (filedes, offset, whence);
+
+ glfs_fd = booster_get_glfs_fd (booster_glfs_fdtable, filedes);
+ if (glfs_fd) {
+ ret = glusterfs_lseek (glfs_fd, offset, whence);
+ booster_put_glfs_fd (glfs_fd);
+ }
+
+ return ret;
+}
+#endif
+
+off_t
+lseek64 (int filedes, uint64_t offset, int whence)
+{
+ int ret;
+ long glfs_fd = 0;
+
+ ret = real_lseek64 (filedes, offset, whence);
+
+ glfs_fd = booster_get_glfs_fd (booster_glfs_fdtable, filedes);
+ if (glfs_fd) {
+ ret = glusterfs_lseek (glfs_fd, offset, whence);
+ booster_put_glfs_fd (glfs_fd);
+ }
+
+ return ret;
+}
+
+int
+dup (int oldfd)
+{
+ int ret = -1, new_fd = -1;
+ long glfs_fd = 0;
+
+ glfs_fd = booster_get_glfs_fd (booster_glfs_fdtable, oldfd);
+ new_fd = real_dup (oldfd);
+
+ if (new_fd >=0 && glfs_fd) {
+ ret = booster_get_unused_fd (booster_glfs_fdtable, glfs_fd, new_fd);
+ fd_ref ((fd_t *)glfs_fd);
+ if (ret == -1) {
+ real_close (new_fd);
+ }
+ }
+
+ if (glfs_fd) {
+ booster_put_glfs_fd (glfs_fd);
+ }
+
+ return new_fd;
+}
+
+
+int
+dup2 (int oldfd, int newfd)
+{
+ int ret = -1;
+ long old_glfs_fd = 0, new_glfs_fd = 0;
+
+ if (oldfd == newfd) {
+ return newfd;
+ }
+
+ old_glfs_fd = booster_get_glfs_fd (booster_glfs_fdtable, oldfd);
+ new_glfs_fd = booster_get_glfs_fd (booster_glfs_fdtable, newfd);
+
+ ret = real_dup2 (oldfd, newfd);
+ if (ret >= 0) {
+ if (new_glfs_fd) {
+ glusterfs_close (new_glfs_fd);
+ booster_put_glfs_fd (new_glfs_fd);
+ booster_put_fd (booster_glfs_fdtable, newfd);
+ new_glfs_fd = 0;
+ }
+
+ if (old_glfs_fd) {
+ ret = booster_get_unused_fd (booster_glfs_fdtable, old_glfs_fd, newfd);
+ fd_ref ((fd_t *)old_glfs_fd);
+ if (ret == -1) {
+ real_close (newfd);
+ }
+ }
+ }
+
+ if (old_glfs_fd) {
+ booster_put_glfs_fd (old_glfs_fd);
+ }
+
+ if (new_glfs_fd) {
+ booster_put_glfs_fd (new_glfs_fd);
+ }
+
+ return ret;
+}
+
+
+#define MOUNT_TABLE_HASH_SIZE 256
+
+
+static int
+booster_init (void)
+{
+ int i = 0;
+ booster_glfs_fdtable = gf_fd_fdtable_alloc ();
+ if (!booster_glfs_fdtable) {
+ fprintf (stderr, "cannot allocate fdtable: %s\n", strerror (errno));
+ goto err;
+ }
+
+ booster_mount_table = calloc (1, sizeof (*booster_mount_table));
+ if (!booster_mount_table) {
+ fprintf (stderr, "cannot allocate memory: %s\n", strerror (errno));
+ goto err;
+ }
+
+ pthread_mutex_init (&booster_mount_table->lock, NULL);
+ booster_mount_table->hash_size = MOUNT_TABLE_HASH_SIZE;
+ booster_mount_table->mounts = calloc (booster_mount_table->hash_size, sizeof (*booster_mount_table->mounts));
+ if (!booster_mount_table->mounts) {
+ fprintf (stderr, "cannot allocate memory: %s\n", strerror (errno));
+ goto err;
+ }
+
+ for (i = 0; i < booster_mount_table->hash_size; i++)
+ {
+ INIT_LIST_HEAD (&booster_mount_table->mounts[i]);
+ }
+
+ return 0;
+
+err:
+ if (booster_glfs_fdtable) {
+ gf_fd_fdtable_destroy (booster_glfs_fdtable);
+ booster_glfs_fdtable = NULL;
+ }
+
+ if (booster_mount_table) {
+ if (booster_mount_table->mounts) {
+ free (booster_mount_table->mounts);
+ }
+
+ free (booster_mount_table);
+ booster_mount_table = NULL;
+ }
+ return -1;
+}
+
+
+static void
+booster_cleanup (void)
+{
+ int i;
+ booster_mount_t *mount = NULL, *tmp = NULL;
+
+ /* gf_fd_fdtable_destroy (booster_glfs_fdtable);*/
+ /*for (i=0; i < booster_glfs_fdtable->max_fds; i++) {
+ if (booster_glfs_fdtable->fds[i]) {
+ fd_t *fd = booster_glfs_fdtable->fds[i];
+ free (fd);
+ }
+ }*/
+
+ free (booster_glfs_fdtable);
+ booster_glfs_fdtable = NULL;
+
+ pthread_mutex_lock (&booster_mount_table->lock);
+ {
+ for (i = 0; i < booster_mount_table->hash_size; i++)
+ {
+ list_for_each_entry_safe (mount, tmp,
+ &booster_mount_table->mounts[i], device_list) {
+ list_del (&mount->device_list);
+ glusterfs_fini (mount->handle);
+ free (mount);
+ }
+ }
+ free (booster_mount_table->mounts);
+ }
+ pthread_mutex_unlock (&booster_mount_table->lock);
+
+ glusterfs_reset ();
+ free (booster_mount_table);
+ booster_mount_table = NULL;
+}
+
+
+
+pid_t
+fork (void)
+{
+ pid_t pid = 0;
+ char child = 0;
+
+ glusterfs_log_lock ();
+ {
+ pid = real_fork ();
+ }
+ glusterfs_log_unlock ();
+
+ child = (pid == 0);
+ if (child) {
+ booster_cleanup ();
+ booster_init ();
+ }
+
+ return pid;
+}
+
+
+void
+_init (void)
+{
+ booster_init ();
+
+ RESOLVE (open);
+ RESOLVE (open64);
+ RESOLVE (creat);
+
+ RESOLVE (read);
+ RESOLVE (readv);
+ RESOLVE (pread);
+ RESOLVE (pread64);
+
+ RESOLVE (write);
+ RESOLVE (writev);
+ RESOLVE (pwrite);
+ RESOLVE (pwrite64);
+
+ RESOLVE (lseek);
+ RESOLVE (lseek64);
+
+ RESOLVE (close);
+
+ RESOLVE (dup);
+ RESOLVE (dup2);
+
+ RESOLVE (fork);
+}
+
diff --git a/commit.sh b/commit.sh
new file mode 100755
index 0000000..2631895
--- /dev/null
+++ b/commit.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+export EDITOR="emacs"
+#TLA_REVISION=$(expr 1 + $(cat ./libglusterfs/src/revision.h | cut -f 8 -d '-' | sed -e 's/"//'))
+#sed -i "s/AC_INIT.*/AC_INIT([glusterfs],[2.0.0tla${TLA_REVISION}],[gluster-users@gluster.org])/g" ./configure.ac
+tla commit --write-revision ./libglusterfs/src/revision.h:'#define GLUSTERFS_REPOSITORY_REVISION "%s"' "$@"
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..6fb7838
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,554 @@
+dnl Copyright (c) 2006, 2007, 2008 Z RESEARCH, Inc. <http://www.zresearch.com>
+dnl This file is part of GlusterFS.
+dnl
+dnl GlusterFS is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl GlusterFS is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+AC_INIT([glusterfs],[2.0.0tla],[gluster-users@gluster.org])
+
+AM_INIT_AUTOMAKE
+
+AM_CONFIG_HEADER([config.h])
+
+AC_CONFIG_FILES([Makefile
+ libglusterfs/Makefile
+ libglusterfs/src/Makefile
+ libglusterfsclient/Makefile
+ libglusterfsclient/src/Makefile
+ mod_glusterfs/Makefile
+ mod_glusterfs/apache/Makefile
+ mod_glusterfs/apache/1.3/Makefile
+ mod_glusterfs/apache/1.3/src/Makefile
+ mod_glusterfs/apache/2.2/Makefile
+ mod_glusterfs/apache/2.2/src/Makefile
+ mod_glusterfs/lighttpd/Makefile
+ mod_glusterfs/lighttpd/1.4/Makefile
+ mod_glusterfs/lighttpd/1.5/Makefile
+ glusterfsd/Makefile
+ glusterfsd/src/Makefile
+ booster/Makefile
+ booster/src/Makefile
+ xlators/Makefile
+ xlators/mount/Makefile
+ xlators/mount/fuse/Makefile
+ xlators/mount/fuse/src/Makefile
+ xlators/mount/fuse/utils/mount.glusterfs
+ xlators/mount/fuse/utils/mount_glusterfs
+ xlators/mount/fuse/utils/Makefile
+ xlators/storage/Makefile
+ xlators/storage/posix/Makefile
+ xlators/storage/posix/src/Makefile
+ xlators/storage/bdb/Makefile
+ xlators/storage/bdb/src/Makefile
+ xlators/cluster/Makefile
+ xlators/cluster/unify/Makefile
+ xlators/cluster/unify/src/Makefile
+ xlators/cluster/afr/Makefile
+ xlators/cluster/afr/src/Makefile
+ xlators/cluster/stripe/Makefile
+ xlators/cluster/stripe/src/Makefile
+ xlators/cluster/dht/Makefile
+ xlators/cluster/dht/src/Makefile
+ xlators/cluster/ha/Makefile
+ xlators/cluster/ha/src/Makefile
+ xlators/cluster/map/Makefile
+ xlators/cluster/map/src/Makefile
+ xlators/performance/Makefile
+ xlators/performance/write-behind/Makefile
+ xlators/performance/write-behind/src/Makefile
+ xlators/performance/read-ahead/Makefile
+ xlators/performance/read-ahead/src/Makefile
+ xlators/performance/io-threads/Makefile
+ xlators/performance/io-threads/src/Makefile
+ xlators/performance/io-cache/Makefile
+ xlators/performance/io-cache/src/Makefile
+ xlators/performance/symlink-cache/Makefile
+ xlators/performance/symlink-cache/src/Makefile
+ xlators/debug/Makefile
+ xlators/debug/trace/Makefile
+ xlators/debug/trace/src/Makefile
+ xlators/debug/error-gen/Makefile
+ xlators/debug/error-gen/src/Makefile
+ xlators/protocol/Makefile
+ xlators/protocol/client/Makefile
+ xlators/protocol/client/src/Makefile
+ xlators/protocol/server/Makefile
+ xlators/protocol/server/src/Makefile
+ xlators/features/Makefile
+ xlators/features/locks/Makefile
+ xlators/features/locks/src/Makefile
+ xlators/features/path-convertor/Makefile
+ xlators/features/path-convertor/src/Makefile
+ xlators/features/trash/Makefile
+ xlators/features/trash/src/Makefile
+ xlators/features/filter/Makefile
+ xlators/features/filter/src/Makefile
+ xlators/features/quota/Makefile
+ xlators/features/quota/src/Makefile
+ xlators/encryption/Makefile
+ xlators/encryption/rot-13/Makefile
+ xlators/encryption/rot-13/src/Makefile
+ scheduler/Makefile
+ scheduler/alu/Makefile
+ scheduler/alu/src/Makefile
+ scheduler/random/Makefile
+ scheduler/random/src/Makefile
+ scheduler/nufa/Makefile
+ scheduler/nufa/src/Makefile
+ scheduler/rr/Makefile
+ scheduler/rr/src/Makefile
+ scheduler/switch/Makefile
+ scheduler/switch/src/Makefile
+ transport/Makefile
+ transport/socket/Makefile
+ transport/socket/src/Makefile
+ transport/ib-verbs/Makefile
+ transport/ib-verbs/src/Makefile
+ auth/Makefile
+ auth/addr/Makefile
+ auth/addr/src/Makefile
+ auth/login/Makefile
+ auth/login/src/Makefile
+ doc/Makefile
+ doc/examples/Makefile
+ doc/hacker-guide/Makefile
+ doc/user-guide/Makefile
+ extras/Makefile
+ extras/init.d/Makefile
+ extras/init.d/glusterfs-server.plist
+ extras/benchmarking/Makefile
+ extras/test/Makefile
+ glusterfs.spec])
+
+AC_CANONICAL_HOST
+
+AC_PROG_CC
+AC_PROG_LIBTOOL
+
+# LEX needs a check
+AC_PROG_LEX
+if test "x${LEX}" != "xflex" -a "x${FLEX}" != "xlex"; then
+ AC_MSG_ERROR([Flex or lex required to build glusterfs.])
+fi
+
+# YACC needs a check
+AC_PROG_YACC
+if test "x${YACC}" = "xbyacc" -o "x${YACC}" = "xyacc" -o "x${YACC}" = "x"; then
+ AC_MSG_ERROR([GNU Bison required to build glusterfs.])
+fi
+
+AC_CHECK_TOOL([LD],[ld])
+
+AC_CHECK_LIB([pthread], [pthread_mutex_init], , AC_MSG_ERROR([Posix threads library is required to build glusterfs]))
+
+AC_CHECK_FUNC([dlopen], [has_dlopen=yes], AC_CHECK_LIB([dl], [dlopen], , AC_MSG_ERROR([Dynamic linking library required to build glusterfs])))
+
+
+AC_CHECK_HEADERS([sys/xattr.h])
+
+AC_CHECK_HEADERS([sys/extattr.h])
+
+dnl Mac OS X does not have spinlocks
+AC_CHECK_FUNC([pthread_spin_init], [have_spinlock=yes])
+if test "x${have_spinlock}" = "xyes"; then
+ AC_DEFINE(HAVE_SPINLOCK, 1, [define if found spinlock])
+fi
+AC_SUBST(HAVE_SPINLOCK)
+
+dnl some os may not have GNU defined strnlen function
+AC_CHECK_FUNC([strnlen], [have_strnlen=yes])
+if test "x${have_strnlen}" = "xyes"; then
+ AC_DEFINE(HAVE_STRNLEN, 1, [define if found strnlen])
+fi
+AC_SUBST(HAVE_STRNLEN)
+
+
+AC_CHECK_FUNC([setfsuid], [have_setfsuid=yes])
+AC_CHECK_FUNC([setfsgid], [have_setfsgid=yes])
+
+if test "x${have_setfsuid}" = "xyes" -a "x${have_setfsgid}" = "xyes"; then
+ AC_DEFINE(HAVE_SET_FSID, 1, [define if found setfsuid setfsgid])
+fi
+
+
+# LIBGLUSTERFSCLIENT section
+AC_ARG_ENABLE([libglusterfsclient],
+ AC_HELP_STRING([--disable-libglusterfsclient],
+ [Do not build libglusterfsclient]))
+
+BUILD_LIBGLUSTERFSCLIENT="no"
+
+if test "x$enable_libglusterfsclient" != "xno"; then
+ LIBGLUSTERFSCLIENT_SUBDIR="libglusterfsclient"
+ BUILD_LIBGLUSTERFSCLIENT="yes"
+fi
+
+AC_SUBST(LIBGLUSTERFSCLIENT_SUBDIR)
+# end LIBGLUSTERFSCLIENT section
+
+
+# MOD_GLUSTERFS section
+AC_ARG_ENABLE([mod_glusterfs],
+ AC_HELP_STRING([--disable-mod_glusterfs],
+ [Do not build glusterfs module for webserver. Currently supported module is for apache/1.3.x]))
+
+if test "x$enable_mod_glusterfs" != "xno"; then
+ AC_ARG_WITH([apxs],
+ AC_HELP_STRING([--with-apxs],
+ [directory containing apxs binary]))
+ if test "x$with_apxs" != "x"; then
+ APXS_BIN=$with_apxs
+ else
+ APXS_BIN="$PATH"
+ fi
+ AC_CHECK_TOOL([APXS],[apxs], ["no"], [$APXS_BIN])
+ if test "X$APXS" = "Xno"; then
+ HAVE_APXS="no";
+ else
+ if test "x$with_apxs" != "x"; then
+ APXS="$with_apxs/apxs";
+ fi
+ HAVE_APXS="yes";
+ fi
+
+ HAVE_LIBGLUSTERFSCLIENT="no";
+ if test "x$BUILD_LIBGLUSTERFSCLIENT" = "xyes"; then
+ HAVE_LIBGLUSTERFSCLIENT="yes";
+ fi
+
+ AC_ARG_WITH([apxspath],
+ AC_HELP_STRING([--with-apxspath],
+ [Path to apxs binary]))
+
+ AC_ARG_WITH([apachepath],
+ AC_HELP_STRING([--with-apachepath],
+ [Path to apache binary]))
+fi
+
+if test "x$enable_mod_glusterfs" = "xyes" -a "x$HAVE_APXS" = "xno"; then
+ echo "apxs is required to build mod_glusterfs. Use --with-apxs to specify path to apxs. If mod_glusterfs is not required, do not pass --enable-mod_glusterfs option to configure "
+ exit 1
+fi
+
+if test "x$enable_mod_glusterfs" = "xyes" -a "x$HAVE_LIBGLUSTERFSCLIENT" = "xno"; then
+ echo "libglusterfsclient is required to build mod_glusterfs. Do not specify --disable-libglusterfsclient to configure script. If mod_glusterfs is not required, do not pass --enable-mod_glusterfs option to configure "
+ exit 1
+fi
+
+BUILD_MOD_GLUSTERFS=no
+MOD_GLUSTERFS_HTTPD_VERSION=""
+
+if test "x$enable_mod_glusterfs" != "xno" -a "x$HAVE_APXS" = "xyes" -a "x$HAVE_LIBGLUSTERFSCLIENT" = "xyes"; then
+ BUILD_MOD_GLUSTERFS="yes";
+ MOD_GLUSTERFS_SUBDIR="mod_glusterfs";
+fi
+
+if test "x$BUILD_MOD_GLUSTERFS" = "xyes"; then
+ HTTPD_BIN_DIR=`$APXS -q SBINDIR`
+ MOD_GLUSTERFS_HTTPD_VERSION=`$HTTPD_BIN_DIR/httpd -V | head -1 | awk "{print $3}" | sed 's/[[^0-9.]]//g' | sed 's/\(.*\..*\)\..*/\1/'`
+fi
+
+if test "x$with_apxspath" != "x"; then
+ APXS_MANUAL=$with_apxspath
+fi
+
+if test "x$with_apachepath" != "x"; then
+ HTTPD_MANUAL=$with_apachepath
+fi
+
+if test "x$enable_mod_glusterfs" != "xno" -a "x$with_apxspath" != "x" -a "x$with_apachepath" != "x"; then
+ BUILD_MOD_GLUSTERFS="yes";
+ MOD_GLUSTERFS_SUBDIR="mod_glusterfs";
+ APACHE_MANUAL=yes
+fi
+
+if test "x$APACHE_MANUAL" = "xyes"; then
+ HTTPD_BIN_DIR=`$APXS_MANUAL -q SBINDIR`
+ MOD_GLUSTERFS_HTTPD_VERSION=`$HTTPD_MANUAL -V | head -1 | awk "{print $3}" | sed 's/[[^0-9.]]//g' | sed 's/\(.*\..*\)\..*/\1/'`
+ APXS=$APXS_MANUAL
+fi
+
+AC_SUBST(MOD_GLUSTERFS_SUBDIR)
+AC_SUBST(APXS)
+AC_SUBST(MOD_GLUSTERFS_HTTPD_VERSION)
+# end MOD_GLUSTERFS section
+
+
+# FUSE section
+# TODO: make a clean version check of libfuse
+AC_ARG_ENABLE([fuse-client],
+ AC_HELP_STRING([--disable-fuse-client],
+ [Do not build the fuse client. NOTE: you cannot mount glusterfs without the client]))
+
+if test "x$enable_fuse_client" != "xno"; then
+ AC_CHECK_LIB([fuse],
+ [fuse_req_interrupt_func],
+ [HAVE_LIBFUSE="yes"],
+ [HAVE_LIBFUSE="no"])
+fi
+
+if test "x$enable_fuse_client" = "xyes" -a "x$HAVE_LIBFUSE" = "xno"; then
+ echo "FUSE requested but not found."
+ exit 1
+fi
+
+BUILD_FUSE_CLIENT=no
+if test "x$enable_fuse_client" != "xno" -a "x$HAVE_LIBFUSE" = "xyes"; then
+ FUSE_CLIENT_SUBDIR=fuse
+ BUILD_FUSE_CLIENT="yes"
+fi
+
+AC_SUBST(FUSE_CLIENT_SUBDIR)
+# end FUSE section
+
+
+# EPOLL section
+AC_ARG_ENABLE([epoll],
+ AC_HELP_STRING([--disable-epoll],
+ [Use poll instead of epoll.]))
+
+BUILD_EPOLL=no
+if test "x$enable_epoll" != "xno"; then
+ AC_CHECK_HEADERS([sys/epoll.h],
+ [BUILD_EPOLL=yes],
+ [BUILD_EPOLL=no])
+fi
+# end EPOLL section
+
+
+# IBVERBS section
+AC_ARG_ENABLE([ibverbs],
+ AC_HELP_STRING([--disable-ibverbs],
+ [Do not build the ibverbs transport]))
+
+if test "x$enable_ibverbs" != "xno"; then
+ AC_CHECK_LIB([ibverbs],
+ [ibv_get_device_list],
+ [HAVE_LIBIBVERBS="yes"],
+ [HAVE_LIBIBVERBS="no"])
+fi
+
+if test "x$enable_ibverbs" = "xyes" -a "x$HAVE_LIBIBVERBS" = "xno"; then
+ echo "ibverbs requested but not found."
+ exit 1
+fi
+
+
+BUILD_IBVERBS=no
+if test "x$enable_ibverbs" != "xno" -a "x$HAVE_LIBIBVERBS" = "xyes"; then
+ IBVERBS_SUBDIR=ib-verbs
+ BUILD_IBVERBS=yes
+fi
+
+AC_SUBST(IBVERBS_SUBDIR)
+# end IBVERBS section
+
+
+# Berkely-DB section
+# storage/bdb requires Berkeley-DB version 4.6.21 or higher
+_GLFS_DB_VERSION_MAJOR=4
+_GLFS_DB_VERSION_MINOR=6
+_GLFS_DB_VERSION_PATCH=21
+AC_ARG_ENABLE([db],
+ AC_HELP_STRING([--disable-bdb],
+ [Do not build the Berkeley-DB translator]))
+
+if test "x$enable_bdb" != "xno"; then
+ AC_CHECK_HEADERS([db.h],
+ [HAVE_BDB="yes"],
+ [HAVE_BDB="no"])
+ if test "x$HAVE_BDB" = "xyes"; then
+ AC_CHECK_LIB([db],
+ [db_create],
+ [HAVE_BDB="yes"],
+ [HAVE_BDB="no"])
+ fi
+
+ if test "x$HAVE_BDB" = "xyes"; then
+ AC_TRY_COMPILE([#include <db.h>],
+ #if (DB_VERSION_MAJOR < $_GLFS_DB_VERSION_MAJOR) ||\
+ (DB_VERSION_MAJOR == $_GLFS_DB_VERSION_MAJOR && \
+ DB_VERSION_MINOR < $_GLFS_DB_VERSION_MINOR) || \
+ (DB_VERSION_MAJOR == $_GLFS_DB_VERSION_MAJOR && \
+ DB_VERSION_MINOR == $_GLFS_DB_VERSION_MINOR && \
+ DB_VERSION_PATCH < $_GLFS_DB_VERSION_PATCH)
+ #error "bdb older than required"
+ #endif
+ ,
+ [HAVE_BDB_VERSION="yes"],
+ [HAVE_BDB_VERSION="no"])
+
+ dnl check for DB->stat having 4 arguments.
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <db.h>]],
+ [[DB *bdb; bdb->stat (NULL, NULL, NULL, 0);]])],
+ [HAVE_BDB_VERSION=yes], [HAVE_BDB_VERSION=no])
+
+ dnl check for DBC->c_get presence.
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <db.h>]],
+ [[DBC *cursor; cursor->get (NULL, NULL, NULL, 0);]])],
+ [HAVE_BDB_CURSOR_GET=yes], [HAVE_BDB_CURSOR_GET=no])
+
+ fi
+fi
+
+if test "x$HAVE_BDB_CURSOR_GET" = "xyes" -a "x$HAVE_BDB_VERSION" = "xyes"; then
+ AC_DEFINE(HAVE_BDB_CURSOR_GET, 1, [Berkeley-DB version has cursor->get()])
+fi
+
+if test "x$enable_bdb" = "xyes" -a "x$HAVE_BDB" = "xno" -a "x$HAVE_BDB_VERSION" = "xno" -a "x$HAVE_BDB_CURSOR_GET" = "xno"; then
+ echo "Berkeley-DB requested but not found. glusterfs bdb feature requires db version 4.6.21 or higher"
+ exit 1
+fi
+
+
+BUILD_BDB=no
+if test "x$enable_bdb" != "xno" -a "x$HAVE_BDB" = "xyes"; then
+ BDB_SUBDIR=bdb
+ BUILD_BDB=yes
+fi
+
+
+
+AC_SUBST(BDB_SUBDIR)
+# end BDB section
+
+dnl FreeBSD > 5 has execinfo as a Ported library for giving a workaround
+dnl solution to GCC backtrace functionality
+
+AC_CHECK_HEADERS([execinfo.h], [have_backtrace=yes],
+ AC_CHECK_LIB([execinfo], [backtrace], [have_backtrace=yes]))
+dnl AC_MSG_ERROR([libexecinfo not found libexecinfo required.])))
+
+if test "x${have_backtrace}" = "xyes"; then
+ AC_DEFINE(HAVE_BACKTRACE, 1, [define if found backtrace])
+fi
+AC_SUBST(HAVE_BACKTRACE)
+
+dnl glusterfs prints memory usage to stderr by sending it SIGUSR1
+AC_CHECK_FUNC([malloc_stats], [have_malloc_stats=yes])
+if test "x${have_malloc_stats}" = "xyes"; then
+ AC_DEFINE(HAVE_MALLOC_STATS, 1, [define if found malloc_stats])
+fi
+AC_SUBST(HAVE_MALLOC_STATS)
+
+dnl Linux, Solaris, Cygwin
+AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec])
+dnl FreeBSD, NetBSD
+AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec])
+
+dnl Check for argp
+AC_CHECK_HEADER([argp.h], AC_DEFINE(HAVE_ARGP, 1, [have argp]))
+AC_CONFIG_SUBDIRS(argp-standalone)
+BUILD_ARGP_STANDALONE=no
+if test "x${ac_cv_header_argp_h}" = "xno"; then
+ BUILD_ARGP_STANDALONE=yes
+ ARGP_STANDALONE_CPPFLAGS='-I${top_srcdir}/argp-standalone'
+ ARGP_STANDALONE_LDADD='${top_builddir}/argp-standalone/libargp.a'
+fi
+
+AC_SUBST(ARGP_STANDALONE_CPPFLAGS)
+AC_SUBST(ARGP_STANDALONE_LDADD)
+
+AC_CHECK_HEADER([malloc.h], AC_DEFINE(HAVE_MALLOC_H, 1, [have malloc.h]))
+
+AC_CHECK_FUNC([llistxattr], [have_llistxattr=yes])
+if test "x${have_llistxattr}" = "xyes"; then
+ AC_DEFINE(HAVE_LLISTXATTR, 1, [define if llistxattr exists])
+fi
+
+AC_CHECK_FUNC([fdatasync], [have_fdatasync=yes])
+if test "x${have_fdatasync}" = "xyes"; then
+ AC_DEFINE(HAVE_FDATASYNC, 1, [define if fdatasync exists])
+fi
+
+GF_HOST_OS=""
+GF_LDFLAGS="-rdynamic"
+
+if test "x$HAVE_LIBGLUSTERFSCLIENT" = "xyes"; then
+ GF_BOOSTER_SUBDIR="booster"
+fi
+
+GF_FUSE_LDADD="-lfuse"
+case $host_os in
+ linux*)
+ dnl GF_LINUX_HOST_OS=1
+ GF_HOST_OS="GF_LINUX_HOST_OS"
+ GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS}"
+ GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
+ GF_LDADD="${ARGP_STANDALONE_LDADD}"
+ ;;
+ solaris*)
+ GF_HOST_OS="GF_SOLARIS_HOST_OS"
+ GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D_REENTRANT"
+ GF_LDFLAGS=""
+ GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
+ GF_LDADD="${ARGP_STANDALONE_LDADD}"
+ GF_GLUSTERFS_LDFLAGS="-lnsl -lresolv -lsocket"
+ GF_BOOSTER_SUBDIR=""
+ ;;
+ *bsd*)
+ GF_HOST_OS="GF_BSD_HOST_OS"
+ GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS}"
+ GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
+ GF_LDADD="${ARGP_STANDALONE_LDADD}"
+ if test "x$ac_cv_header_execinfo_h" = "xyes"; then
+ GF_GLUSTERFS_LDFLAGS="-lexecinfo"
+ fi
+ GF_FUSE_LDADD="-liconv -lfuse"
+ BUILD_MOD_GLUSTERFS=no
+ MOD_GLUSTERFS_SUBDIR=""
+ BUILD_LIBGLUSTERFSCLIENT=no
+ LIBGLUSTERFSCLIENT_SUBDIR=""
+ GF_BOOSTER_SUBDIR=""
+ ;;
+ darwin*)
+ GF_HOST_OS="GF_DARWIN_HOST_OS"
+ LIBTOOL=glibtool
+ GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D__DARWIN_64_BIT_INO_T -bundle -undefined suppress -flat_namespace"
+ GF_GLUSTERFS_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D__DARWIN_64_BIT_INO_T -undefined suppress -flat_namespace"
+ GF_LDADD="${ARGP_STANDALONE_LDADD}"
+ GF_FUSE_LDADD="-liconv -lfuse_ino64"
+ BUILD_MOD_GLUSTERFS=no
+ MOD_GLUSTERFS_SUBDIR=""
+ BUILD_LIBGLUSTERFSCLIENT=no
+ LIBGLUSTERFSCLIENT_SUBDIR=""
+ GF_BOOSTER_SUBDIR=""
+ ;;
+esac
+
+AC_SUBST(GF_HOST_OS)
+AC_SUBST(GF_GLUSTERFS_LDFLAGS)
+AC_SUBST(GF_GLUSTERFS_CFLAGS)
+AC_SUBST(GF_CFLAGS)
+AC_SUBST(GF_LDFLAGS)
+AC_SUBST(GF_LDADD)
+AC_SUBST(GF_FUSE_LDADD)
+AC_SUBST(GF_BOOSTER_SUBDIR)
+
+AM_CONDITIONAL([GF_DARWIN_HOST_OS], test "${GF_HOST_OS}" = "GF_DARWIN_HOST_OS")
+
+AC_OUTPUT
+
+exec >&2
+
+echo
+echo "GlusterFS configure summary"
+echo "==========================="
+echo "FUSE client : $BUILD_FUSE_CLIENT"
+echo "Infiniband verbs : $BUILD_IBVERBS"
+echo "epoll IO multiplex : $BUILD_EPOLL"
+echo "Berkeley-DB : $BUILD_BDB"
+echo "libglusterfsclient : $BUILD_LIBGLUSTERFSCLIENT"
+echo "mod_glusterfs : $BUILD_MOD_GLUSTERFS ($MOD_GLUSTERFS_HTTPD_VERSION)"
+echo "argp-standalone : $BUILD_ARGP_STANDALONE"
+echo
diff --git a/doc/Makefile.am b/doc/Makefile.am
new file mode 100644
index 0000000..83f8832
--- /dev/null
+++ b/doc/Makefile.am
@@ -0,0 +1,11 @@
+EXTRA_DIST = glusterfs.vol.sample glusterfsd.vol.sample glusterfs.8 \
+ porting_guide.txt authentication.txt coding-standard.pdf get_put_api_using_xattr.txt \
+ translator-options.txt mac-related-xattrs.txt replicate.pdf
+SUBDIRS = examples hacker-guide user-guide
+
+voldir = $(sysconfdir)/glusterfs
+vol_DATA = glusterfs.vol.sample glusterfsd.vol.sample
+
+man8_MANS = glusterfs.8
+
+CLEANFILES =
diff --git a/doc/authentication.txt b/doc/authentication.txt
new file mode 100644
index 0000000..70aafd9
--- /dev/null
+++ b/doc/authentication.txt
@@ -0,0 +1,112 @@
+
+* Authentication is provided by two modules addr and login. Login based authentication uses username/password from client for authentication. Each module returns either ACCEPT, REJCET or DONT_CARE. DONT_CARE is returned if the input authentication information to the module is not concerned to its working. The theory behind authentication is that "none of the auth modules should return REJECT and atleast one of them should return ACCEPT"
+
+* Currently all the authentication related information is passed un-encrypted over the network from client to server.
+
+----------------------------------------------------------------------------------------------------
+* options provided in protocol/client:
+ * for username/password based authentication:
+ option username <username>
+ option password <password>
+ * client can have only one set of username/password
+ * for addr based authentication:
+ * no options required in protocol/client. Client has to bind to privileged port (port < 1024 ) which means the process in which protocol/client is loaded has to be run as root.
+
+----------------------------------------------------------------------------------------------------
+* options provided in protocol/server:
+ * for username/password based authentication:
+ option auth.login.<brick>.allow [comma seperated list of usernames using which clients can connect to volume <brick>]
+ option auth.login.<username>.password <password> #specify password <password> for username <username>
+ * for addr based authentication:
+ option auth.addr.<brick>.allow [comma seperated list of ip-addresses/unix-paths from which clients are allowed to connect to volume <brick>]
+ option auth.addr.<brick>.reject [comma seperated list of ip-addresses/unix-paths from which clients are not allowed to connect to volume <brick>]
+ * negation operator '!' is used to invert the sense of matching.
+ Eg., option auth.addr.brick.allow !a.b.c.d #do not allow client from a.b.c.d to connect to volume brick
+ option auth.addr.brick.reject !w.x.y.z #allow client from w.x.y.z to connect to volume brick
+ * wildcard '*' can be used to match any ip-address/unix-path
+
+----------------------------------------------------------------------------------------------------
+
+* Usecases:
+
+* username/password based authentication only
+ protocol/client:
+ option username foo
+ option password foo-password
+ option remote-subvolume foo-brick
+
+ protocol/server:
+ option auth.login.foo-brick.allow foo,who #,other users allowed to connect to foo-brick
+ option auth.login.foo.password foo-password
+ option auth.login.who.password who-password
+
+ * in protocol/server, dont specify ip from which client is connecting in auth.addr.foo-brick.reject list
+
+****************************************************************************************************
+
+* ip based authentication only
+ protocol/client:
+ option remote-subvolume foo-brick
+ * Client is connecting from a.b.c.d
+
+ protocol/server:
+ option auth.addr.foo-brick.allow a.b.c.d,e.f.g.h,i.j.k.l #, other ip addresses from which clients are allowed to connect to foo-brick
+
+****************************************************************************************************
+* ip and username/password based authentication
+ * allow only "user foo from a.b.c.d"
+ protocol/client:
+ option username foo
+ option password foo-password
+ option remote-subvolume foo-brick
+
+ protocol/server:
+ option auth.login.foo-brick.allow foo
+ option auth.login.foo.password foo-password
+ option auth.addr.foo-brick.reject !a.b.c.d
+
+ * allow only "user foo" from a.b.c.d i.e., only user foo is allowed from a.b.c.d, but anyone is allowed from ip addresses other than a.b.c.d
+ protocol/client:
+ option username foo
+ option password foo-password
+ option remote-subvolume foo-brick
+
+ protocol/server:
+ option auth.login.foo-brick.allow foo
+ option auth.login.foo.password foo-password
+ option auth.addr.foo-brick.allow !a.b.c.d
+
+ * reject only "user shoo from a.b.c.d"
+ protcol/client:
+ option remote-subvolume shoo-brick
+
+ protocol/server:
+ # observe that no "option auth.login.shoo-brick.allow shoo" given
+ # Also other users from a.b.c.d have to be explicitly allowed using auth.login.shoo-brick.allow ...
+ option auth.addr.shoo-brick.allow !a.b.c.d
+
+ * reject only "user shoo" from a.b.c.d i.e., user shoo from a.b.c.d has to be rejected.
+ * same as reject only "user shoo from a.b.c.d" above, but rules have to be added whether to allow ip addresses (and users from those ips) other than a.b.c.d
+
+****************************************************************************************************
+
+* ip or username/password based authentication
+
+ * allow user foo or clients from a.b.c.d
+ protocol/client:
+ option remote-subvolume foo-brick
+
+ protocol/server:
+ option auth.login.foo-brick.allow foo
+ option auth.login.foo.password foo-password
+ option auth.addr.foo-brick.allow a.b.c.d
+
+ * reject user shoo or clients from a.b.c.d
+ protocol/client:
+ option remote-subvolume shoo-brick
+
+ protocol/server:
+ option auth.login.shoo-brick.allow <usernames other than shoo>
+ #for each username mentioned in the above <usernames other than shoo> list, specify password as below
+ option auth.login.<username other than shoo>.password password
+ option auth.addr.shoo-brick.reject a.b.c.d
diff --git a/doc/booster.txt b/doc/booster.txt
new file mode 100644
index 0000000..684ac89
--- /dev/null
+++ b/doc/booster.txt
@@ -0,0 +1,54 @@
+Introduction
+============
+* booster is a LD_PRELOADable library which boosts read/write performance by bypassing fuse for
+ read() and write() calls.
+
+Requirements
+============
+* fetch volfile from glusterfs.
+* identify whether multiple files are from the same mount point. If so, use only one context.
+
+Design
+======
+* for a getxattr, along with other attributes, fuse returns following attributes.
+ * contents of client volume-file.
+ * mount point.
+
+* LD_PRELOADed booster.so maintains an hash table storing mount-points and libglusterfsclient handles
+ so that handles are reused for files from same mount point.
+
+* it also maintains a fdtable. fdtable maps the fd (integer) returned to application to fd (pointer to fd struct)
+ used by libglusterfsclient. application is returned the same fd as the one returned from libc apis.
+
+* During fork, these tables are overwritten to enable creation of fresh glusterfs context in child.
+
+Working
+=======
+* application willing to use booster LD_PRELOADs booster.so which is a wrapper library implementing
+ open, read and write.
+
+* application should specify the path to logfile through the environment variable GLFS_BOOSTER_LOGFILE. If
+ not specified, logging is done to /dev/stderr.
+
+* open call does,
+ * real_open on the file.
+ * fgetxattr(fd).
+ * store the volume-file content got in the dictionary to a temparory file.
+ * look in the hashtable for the mount-point, if already present get the libglusterfsclient handle from the
+ hashtable. Otherwise get a new handle from libglusterfsclient (be careful about mount point not present in
+ the hashtable and multiple glusterfs_inits running simultaneously for the same mount-point there by using
+ multiple handles for the same mount point).
+ * real_close (fd).
+ * delete temporary volume-volfile.
+ * glusterfs_open (handle, path, mode).
+ * store the fd returned by glusterfs_open in the fdtable at the same index as the fd returned by real_open.
+ * return the index as fd.
+
+* read/write calls do,
+ * get the libglusterfsclient fd from fdtable.
+ * if found use glusterfs_read/glusterfs_write, else use real_read/real_write.
+
+* close call does,
+ * remove the fd from the fdtable.
+
+* other calls use real_calls.
diff --git a/doc/coding-standard.pdf b/doc/coding-standard.pdf
new file mode 100644
index 0000000..bc9cb56
--- /dev/null
+++ b/doc/coding-standard.pdf
Binary files differ
diff --git a/doc/coding-standard.tex b/doc/coding-standard.tex
new file mode 100644
index 0000000..ed9d920
--- /dev/null
+++ b/doc/coding-standard.tex
@@ -0,0 +1,361 @@
+\documentclass{article}[12pt]
+\usepackage{color}
+
+\begin{document}
+
+
+\hrule
+\begin{center}\textbf{\Large{GlusterFS Coding Standards}}\end{center}
+\begin{center}\textbf{\large{\textcolor{red}{Z} Research}}\end{center}
+\begin{center}{July 14, 2008}\end{center}
+\hrule
+
+\vspace{8ex}
+
+\section*{$\bullet$ Structure definitions should have a comment per member}
+
+Every member in a structure definition must have a comment about its
+purpose. The comment should be descriptive without being overly verbose.
+
+\vspace{2ex}
+\textsl{Bad}:
+
+\begin{verbatim}
+ gf_lock_t lock; /* lock */
+\end{verbatim}
+
+\textsl{Good}:
+
+\begin{verbatim}
+ DBTYPE access_mode; /* access mode for accessing
+ * the databases, can be
+ * DB_HASH, DB_BTREE
+ * (option access-mode <mode>)
+ */
+\end{verbatim}
+
+\section*{$\bullet$ Declare all variables at the beginning of the function}
+All local variables in a function must be declared immediately after the
+opening brace. This makes it easy to keep track of memory that needs to be freed
+during exit. It also helps debugging, since gdb cannot handle variables
+declared inside loops or other such blocks.
+
+\section*{$\bullet$ Always initialize local variables}
+Every local variable should be initialized to a sensible default value
+at the point of its declaration. All pointers should be initialized to NULL,
+and all integers should be zero or (if it makes sense) an error value.
+
+\vspace{2ex}
+
+\textsl{Good}:
+
+\begin{verbatim}
+ int ret = 0;
+ char *databuf = NULL;
+ int _fd = -1;
+\end{verbatim}
+
+\section*{$\bullet$ Initialization should always be done with a constant value}
+Never use a non-constant expression as the initialization value for a variable.
+
+\vspace{2ex}
+
+\textsl{Bad}:
+
+\begin{verbatim}
+ pid_t pid = frame->root->pid;
+ char *databuf = malloc (1024);
+\end{verbatim}
+
+\section*{$\bullet$ Validate all arguments to a function}
+All pointer arguments to a function must be checked for \texttt{NULL}.
+A macro named \texttt{VALIDATE} (in \texttt{common-utils.h})
+takes one argument, and if it is \texttt{NULL}, writes a log message and
+jumps to a label called \texttt{err} after setting op\_ret and op\_errno
+appropriately. It is recommended to use this template.
+
+\vspace{2ex}
+
+\textsl{Good}:
+
+\begin{verbatim}
+ VALIDATE(frame);
+ VALIDATE(this);
+ VALIDATE(inode);
+\end{verbatim}
+
+\section*{$\bullet$ Never rely on precedence of operators}
+Never write code that relies on the precedence of operators to execute
+correctly. Such code can be hard to read and someone else might not
+know the precedence of operators as accurately as you do.
+\vspace{2ex}
+
+\textsl{Bad}:
+
+\begin{verbatim}
+ if (op_ret == -1 && errno != ENOENT)
+\end{verbatim}
+
+\textsl{Good}:
+
+\begin{verbatim}
+ if ((op_ret == -1) && (errno != ENOENT))
+\end{verbatim}
+
+\section*{$\bullet$ Use exactly matching types}
+Use a variable of the exact type declared in the manual to hold the
+return value of a function. Do not use an ``equivalent'' type.
+
+\vspace{2ex}
+
+\textsl{Bad}:
+
+\begin{verbatim}
+ int len = strlen (path);
+\end{verbatim}
+
+\textsl{Good}:
+
+\begin{verbatim}
+ size_t len = strlen (path);
+\end{verbatim}
+
+\section*{$\bullet$ Never write code such as \texttt{foo->bar->baz}; check every pointer}
+Do not write code that blindly follows a chain of pointer
+references. Any pointer in the chain may be \texttt{NULL} and thus
+cause a crash. Verify that each pointer is non-null before following
+it.
+
+\section*{$\bullet$ Check return value of all functions and system calls}
+The return value of all system calls and API functions must be checked
+for success or failure.
+
+\vspace{2ex}
+\textsl{Bad}:
+
+\begin{verbatim}
+ close (fd);
+\end{verbatim}
+
+\textsl{Good}:
+
+\begin{verbatim}
+ op_ret = close (_fd);
+ if (op_ret == -1) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "close on file %s failed (%s)", real_path,
+ strerror (errno));
+ op_errno = errno;
+ goto out;
+ }
+\end{verbatim}
+
+
+\section*{$\bullet$ Gracefully handle failure of malloc}
+GlusterFS should never crash or exit due to lack of memory. If a
+memory allocation fails, the call should be unwound and an error
+returned to the user.
+
+\section*{$\bullet$ Use result args and reserve the return value to indicate success or failure}
+The return value of every functions must indicate success or failure (unless
+it is impossible for the function to fail --- e.g., boolean functions). If
+the function needs to return additional data, it must be returned using a
+result (pointer) argument.
+
+\vspace{2ex}
+\textsl{Bad}:
+
+\begin{verbatim}
+ int32_t dict_get_int32 (dict_t *this, char *key);
+\end{verbatim}
+
+\textsl{Good}:
+
+\begin{verbatim}
+ int dict_get_int32 (dict_t *this, char *key, int32_t *val);
+\end{verbatim}
+
+\section*{$\bullet$ Always use the `n' versions of string functions}
+Unless impossible, use the length-limited versions of the string functions.
+
+\vspace{2ex}
+\textsl{Bad}:
+
+\begin{verbatim}
+ strcpy (entry_path, real_path);
+\end{verbatim}
+
+\textsl{Good}:
+
+\begin{verbatim}
+ strncpy (entry_path, real_path, entry_path_len);
+\end{verbatim}
+
+\section*{$\bullet$ No dead or commented code}
+There must be no dead code (code to which control can never be passed) or
+commented out code in the codebase.
+
+\section*{$\bullet$ Only one unwind and return per function}
+There must be only one exit out of a function. \texttt{UNWIND} and return
+should happen at only point in the function.
+
+\section*{$\bullet$ Keep functions small}
+Try to keep functions small. Two to three screenfulls (80 lines per screen) is
+considered a reasonable limit. If a function is very long, try splitting it
+into many little helper functions.
+
+\vspace{2ex}
+\textsl{Example for a helper function}:
+\begin{verbatim}
+ static int
+ same_owner (posix_lock_t *l1, posix_lock_t *l2)
+ {
+ return ((l1->client_pid == l2->client_pid) &&
+ (l1->transport == l2->transport));
+ }
+\end{verbatim}
+
+\section*{Style issues}
+
+\subsection*{Brace placement}
+Use K\&R/Linux style of brace placement for blocks.
+
+\textsl{Example}:
+\begin{verbatim}
+ int some_function (...)
+ {
+ if (...) {
+ /* ... */
+ } else if (...) {
+ /* ... */
+ } else {
+ /* ... */
+ }
+
+ do {
+ /* ... */
+ } while (cond);
+ }
+\end{verbatim}
+
+\subsection*{Indentation}
+Use \textbf{eight} spaces for indenting blocks. Ensure that your
+file contains only spaces and not tab characters. You can do this
+in Emacs by selecting the entire file (\texttt{C-x h}) and
+running \texttt{M-x untabify}.
+
+To make Emacs indent lines automatically by eight spaces, add this
+line to your \texttt{.emacs}:
+
+\begin{verbatim}
+ (add-hook 'c-mode-hook (lambda () (c-set-style "linux")))
+\end{verbatim}
+
+\subsection*{Comments}
+Write a comment before every function describing its purpose (one-line),
+its arguments, and its return value. Mention whether it is an internal
+function or an exported function.
+
+Write a comment before every structure describing its purpose, and
+write comments about each of its members.
+
+Follow the style shown below for comments, since such comments
+can then be automatically extracted by doxygen to generate
+documentation.
+
+\textsl{Example}:
+\begin{verbatim}
+/**
+ * hash_name -hash function for filenames
+ * @par: parent inode number
+ * @name: basename of inode
+ * @mod: number of buckets in the hashtable
+ *
+ * @return: success: bucket number
+ * failure: -1
+ *
+ * Not for external use.
+ */
+\end{verbatim}
+
+\subsection*{Indicating critical sections}
+To clearly show regions of code which execute with locks held, use
+the following format:
+
+\begin{verbatim}
+ pthread_mutex_lock (&mutex);
+ {
+ /* code */
+ }
+ pthread_mutex_unlock (&mutex);
+\end{verbatim}
+
+\section*{A skeleton fop function}
+This is the recommended template for any fop. In the beginning come
+the initializations. After that, the `success' control flow should be
+linear. Any error conditions should cause a \texttt{goto} to a single
+point, \texttt{out}. At that point, the code should detect the error
+that has occured and do appropriate cleanup.
+
+\begin{verbatim}
+int32_t
+sample_fop (call_frame_t *frame,
+ xlator_t *this,
+ ...)
+{
+ char * var1 = NULL;
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
+ DIR * dir = NULL;
+ struct posix_fd * pfd = NULL;
+
+ VALIDATE_OR_GOTO (frame, out);
+ VALIDATE_OR_GOTO (this, out);
+
+ /* other validations */
+
+ dir = opendir (...);
+
+ if (dir == NULL) {
+ op_errno = errno;
+ gf_log (this->name, GF_LOG_ERROR,
+ "opendir failed on %s (%s)", loc->path,
+ strerror (op_errno));
+ goto out;
+ }
+
+ /* another system call */
+ if (...) {
+ op_errno = ENOMEM;
+ gf_log (this->name, GF_LOG_ERROR,
+ "out of memory :(");
+ goto out;
+ }
+
+ /* ... */
+
+ out:
+ if (op_ret == -1) {
+
+ /* check for all the cleanup that needs to be
+ done */
+
+ if (dir) {
+ closedir (dir);
+ dir = NULL;
+ }
+
+ if (pfd) {
+ if (pfd->path)
+ FREE (pfd->path);
+ FREE (pfd);
+ pfd = NULL;
+ }
+ }
+
+ STACK_UNWIND (frame, op_ret, op_errno, fd);
+ return 0;
+}
+\end{verbatim}
+
+\end{document}
diff --git a/doc/errno.list.bsd.txt b/doc/errno.list.bsd.txt
new file mode 100644
index 0000000..350af25
--- /dev/null
+++ b/doc/errno.list.bsd.txt
@@ -0,0 +1,376 @@
+/*-
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * 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.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ * @(#)errno.h 8.5 (Berkeley) 1/21/94
+ * $FreeBSD: src/sys/sys/errno.h,v 1.28 2005/04/02 12:33:28 das Exp $
+ */
+
+#ifndef _SYS_ERRNO_H_
+#define _SYS_ERRNO_H_
+
+#ifndef _KERNEL
+#include <sys/cdefs.h>
+__BEGIN_DECLS
+int * __error(void);
+__END_DECLS
+#define errno (* __error())
+#endif
+
+#define EPERM 1 /* Operation not permitted */
+#define ENOENT 2 /* No such file or directory */
+#define ESRCH 3 /* No such process */
+#define EINTR 4 /* Interrupted system call */
+#define EIO 5 /* Input/output error */
+#define ENXIO 6 /* Device not configured */
+#define E2BIG 7 /* Argument list too long */
+#define ENOEXEC 8 /* Exec format error */
+#define EBADF 9 /* Bad file descriptor */
+#define ECHILD 10 /* No child processes */
+#define EDEADLK 11 /* Resource deadlock avoided */
+ /* 11 was EAGAIN */
+#define ENOMEM 12 /* Cannot allocate memory */
+#define EACCES 13 /* Permission denied */
+#define EFAULT 14 /* Bad address */
+#ifndef _POSIX_SOURCE
+#define ENOTBLK 15 /* Block device required */
+#endif
+#define EBUSY 16 /* Device busy */
+#define EEXIST 17 /* File exists */
+#define EXDEV 18 /* Cross-device link */
+#define ENODEV 19 /* Operation not supported by device */
+#define ENOTDIR 20 /* Not a directory */
+#define EISDIR 21 /* Is a directory */
+#define EINVAL 22 /* Invalid argument */
+#define ENFILE 23 /* Too many open files in system */
+#define EMFILE 24 /* Too many open files */
+#define ENOTTY 25 /* Inappropriate ioctl for device */
+#ifndef _POSIX_SOURCE
+#define ETXTBSY 26 /* Text file busy */
+#endif
+#define EFBIG 27 /* File too large */
+#define ENOSPC 28 /* No space left on device */
+#define ESPIPE 29 /* Illegal seek */
+#define EROFS 30 /* Read-only filesystem */
+#define EMLINK 31 /* Too many links */
+#define EPIPE 32 /* Broken pipe */
+
+/* math software */
+#define EDOM 33 /* Numerical argument out of domain */
+#define ERANGE 34 /* Result too large */
+
+/* non-blocking and interrupt i/o */
+#define EAGAIN 35 /* Resource temporarily unavailable */
+#ifndef _POSIX_SOURCE
+#define EWOULDBLOCK EAGAIN /* Operation would block */
+#define EINPROGRESS 36 /* Operation now in progress */
+#define EALREADY 37 /* Operation already in progress */
+
+/* ipc/network software -- argument errors */
+#define ENOTSOCK 38 /* Socket operation on non-socket */
+#define EDESTADDRREQ 39 /* Destination address required */
+#define EMSGSIZE 40 /* Message too long */
+#define EPROTOTYPE 41 /* Protocol wrong type for socket */
+#define ENOPROTOOPT 42 /* Protocol not available */
+#define EPROTONOSUPPORT 43 /* Protocol not supported */
+#define ESOCKTNOSUPPORT 44 /* Socket type not supported */
+#define EOPNOTSUPP 45 /* Operation not supported */
+#define ENOTSUP EOPNOTSUPP /* Operation not supported */
+#define EPFNOSUPPORT 46 /* Protocol family not supported */
+#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */
+#define EADDRINUSE 48 /* Address already in use */
+#define EADDRNOTAVAIL 49 /* Can't assign requested address */
+
+/* ipc/network software -- operational errors */
+#define ENETDOWN 50 /* Network is down */
+#define ENETUNREACH 51 /* Network is unreachable */
+#define ENETRESET 52 /* Network dropped connection on reset */
+#define ECONNABORTED 53 /* Software caused connection abort */
+#define ECONNRESET 54 /* Connection reset by peer */
+#define ENOBUFS 55 /* No buffer space available */
+#define EISCONN 56 /* Socket is already connected */
+#define ENOTCONN 57 /* Socket is not connected */
+#define ESHUTDOWN 58 /* Can't send after socket shutdown */
+#define ETOOMANYREFS 59 /* Too many references: can't splice */
+#define ETIMEDOUT 60 /* Operation timed out */
+#define ECONNREFUSED 61 /* Connection refused */
+
+#define ELOOP 62 /* Too many levels of symbolic links */
+#endif /* _POSIX_SOURCE */
+#define ENAMETOOLONG 63 /* File name too long */
+
+/* should be rearranged */
+#ifndef _POSIX_SOURCE
+#define EHOSTDOWN 64 /* Host is down */
+#define EHOSTUNREACH 65 /* No route to host */
+#endif /* _POSIX_SOURCE */
+#define ENOTEMPTY 66 /* Directory not empty */
+
+/* quotas & mush */
+#ifndef _POSIX_SOURCE
+#define EPROCLIM 67 /* Too many processes */
+#define EUSERS 68 /* Too many users */
+#define EDQUOT 69 /* Disc quota exceeded */
+
+/* Network File System */
+#define ESTALE 70 /* Stale NFS file handle */
+#define EREMOTE 71 /* Too many levels of remote in path */
+#define EBADRPC 72 /* RPC struct is bad */
+#define ERPCMISMATCH 73 /* RPC version wrong */
+#define EPROGUNAVAIL 74 /* RPC prog. not avail */
+#define EPROGMISMATCH 75 /* Program version wrong */
+#define EPROCUNAVAIL 76 /* Bad procedure for program */
+#endif /* _POSIX_SOURCE */
+
+#define ENOLCK 77 /* No locks available */
+#define ENOSYS 78 /* Function not implemented */
+
+#ifndef _POSIX_SOURCE
+#define EFTYPE 79 /* Inappropriate file type or format */
+#define EAUTH 80 /* Authentication error */
+#define ENEEDAUTH 81 /* Need authenticator */
+#define EIDRM 82 /* Identifier removed */
+#define ENOMSG 83 /* No message of desired type */
+#define EOVERFLOW 84 /* Value too large to be stored in data type */
+#define ECANCELED 85 /* Operation canceled */
+#define EILSEQ 86 /* Illegal byte sequence */
+#define ENOATTR 87 /* Attribute not found */
+
+#define EDOOFUS 88 /* Programming error */
+#endif /* _POSIX_SOURCE */
+
+#define EBADMSG 89 /* Bad message */
+#define EMULTIHOP 90 /* Multihop attempted */
+#define ENOLINK 91 /* Link has been severed */
+#define EPROTO 92 /* Protocol error */
+
+#ifndef _POSIX_SOURCE
+#define ELAST 92 /* Must be equal largest errno */
+#endif /* _POSIX_SOURCE */
+
+#ifdef _KERNEL
+/* pseudo-errors returned inside kernel to modify return to process */
+#define ERESTART (-1) /* restart syscall */
+#define EJUSTRETURN (-2) /* don't modify regs, just return */
+#define ENOIOCTL (-3) /* ioctl not handled by this layer */
+#define EDIRIOCTL (-4) /* do direct ioctl in GEOM */
+#endif
+
+#endif
+/*-
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * 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.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ * @(#)errno.h 8.5 (Berkeley) 1/21/94
+ * $FreeBSD: src/sys/sys/errno.h,v 1.28 2005/04/02 12:33:28 das Exp $
+ */
+
+#ifndef _SYS_ERRNO_H_
+#define _SYS_ERRNO_H_
+
+#ifndef _KERNEL
+#include <sys/cdefs.h>
+__BEGIN_DECLS
+int * __error(void);
+__END_DECLS
+#define errno (* __error())
+#endif
+
+#define EPERM 1 /* Operation not permitted */
+#define ENOENT 2 /* No such file or directory */
+#define ESRCH 3 /* No such process */
+#define EINTR 4 /* Interrupted system call */
+#define EIO 5 /* Input/output error */
+#define ENXIO 6 /* Device not configured */
+#define E2BIG 7 /* Argument list too long */
+#define ENOEXEC 8 /* Exec format error */
+#define EBADF 9 /* Bad file descriptor */
+#define ECHILD 10 /* No child processes */
+#define EDEADLK 11 /* Resource deadlock avoided */
+ /* 11 was EAGAIN */
+#define ENOMEM 12 /* Cannot allocate memory */
+#define EACCES 13 /* Permission denied */
+#define EFAULT 14 /* Bad address */
+#ifndef _POSIX_SOURCE
+#define ENOTBLK 15 /* Block device required */
+#endif
+#define EBUSY 16 /* Device busy */
+#define EEXIST 17 /* File exists */
+#define EXDEV 18 /* Cross-device link */
+#define ENODEV 19 /* Operation not supported by device */
+#define ENOTDIR 20 /* Not a directory */
+#define EISDIR 21 /* Is a directory */
+#define EINVAL 22 /* Invalid argument */
+#define ENFILE 23 /* Too many open files in system */
+#define EMFILE 24 /* Too many open files */
+#define ENOTTY 25 /* Inappropriate ioctl for device */
+#ifndef _POSIX_SOURCE
+#define ETXTBSY 26 /* Text file busy */
+#endif
+#define EFBIG 27 /* File too large */
+#define ENOSPC 28 /* No space left on device */
+#define ESPIPE 29 /* Illegal seek */
+#define EROFS 30 /* Read-only filesystem */
+#define EMLINK 31 /* Too many links */
+#define EPIPE 32 /* Broken pipe */
+
+/* math software */
+#define EDOM 33 /* Numerical argument out of domain */
+#define ERANGE 34 /* Result too large */
+
+/* non-blocking and interrupt i/o */
+#define EAGAIN 35 /* Resource temporarily unavailable */
+#ifndef _POSIX_SOURCE
+#define EWOULDBLOCK EAGAIN /* Operation would block */
+#define EINPROGRESS 36 /* Operation now in progress */
+#define EALREADY 37 /* Operation already in progress */
+
+/* ipc/network software -- argument errors */
+#define ENOTSOCK 38 /* Socket operation on non-socket */
+#define EDESTADDRREQ 39 /* Destination address required */
+#define EMSGSIZE 40 /* Message too long */
+#define EPROTOTYPE 41 /* Protocol wrong type for socket */
+#define ENOPROTOOPT 42 /* Protocol not available */
+#define EPROTONOSUPPORT 43 /* Protocol not supported */
+#define ESOCKTNOSUPPORT 44 /* Socket type not supported */
+#define EOPNOTSUPP 45 /* Operation not supported */
+#define ENOTSUP EOPNOTSUPP /* Operation not supported */
+#define EPFNOSUPPORT 46 /* Protocol family not supported */
+#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */
+#define EADDRINUSE 48 /* Address already in use */
+#define EADDRNOTAVAIL 49 /* Can't assign requested address */
+
+/* ipc/network software -- operational errors */
+#define ENETDOWN 50 /* Network is down */
+#define ENETUNREACH 51 /* Network is unreachable */
+#define ENETRESET 52 /* Network dropped connection on reset */
+#define ECONNABORTED 53 /* Software caused connection abort */
+#define ECONNRESET 54 /* Connection reset by peer */
+#define ENOBUFS 55 /* No buffer space available */
+#define EISCONN 56 /* Socket is already connected */
+#define ENOTCONN 57 /* Socket is not connected */
+#define ESHUTDOWN 58 /* Can't send after socket shutdown */
+#define ETOOMANYREFS 59 /* Too many references: can't splice */
+#define ETIMEDOUT 60 /* Operation timed out */
+#define ECONNREFUSED 61 /* Connection refused */
+
+#define ELOOP 62 /* Too many levels of symbolic links */
+#endif /* _POSIX_SOURCE */
+#define ENAMETOOLONG 63 /* File name too long */
+
+/* should be rearranged */
+#ifndef _POSIX_SOURCE
+#define EHOSTDOWN 64 /* Host is down */
+#define EHOSTUNREACH 65 /* No route to host */
+#endif /* _POSIX_SOURCE */
+#define ENOTEMPTY 66 /* Directory not empty */
+
+/* quotas & mush */
+#ifndef _POSIX_SOURCE
+#define EPROCLIM 67 /* Too many processes */
+#define EUSERS 68 /* Too many users */
+#define EDQUOT 69 /* Disc quota exceeded */
+
+/* Network File System */
+#define ESTALE 70 /* Stale NFS file handle */
+#define EREMOTE 71 /* Too many levels of remote in path */
+#define EBADRPC 72 /* RPC struct is bad */
+#define ERPCMISMATCH 73 /* RPC version wrong */
+#define EPROGUNAVAIL 74 /* RPC prog. not avail */
+#define EPROGMISMATCH 75 /* Program version wrong */
+#define EPROCUNAVAIL 76 /* Bad procedure for program */
+#endif /* _POSIX_SOURCE */
+
+#define ENOLCK 77 /* No locks available */
+#define ENOSYS 78 /* Function not implemented */
+
+#ifndef _POSIX_SOURCE
+#define EFTYPE 79 /* Inappropriate file type or format */
+#define EAUTH 80 /* Authentication error */
+#define ENEEDAUTH 81 /* Need authenticator */
+#define EIDRM 82 /* Identifier removed */
+#define ENOMSG 83 /* No message of desired type */
+#define EOVERFLOW 84 /* Value too large to be stored in data type */
+#define ECANCELED 85 /* Operation canceled */
+#define EILSEQ 86 /* Illegal byte sequence */
+#define ENOATTR 87 /* Attribute not found */
+
+#define EDOOFUS 88 /* Programming error */
+#endif /* _POSIX_SOURCE */
+
+#define EBADMSG 89 /* Bad message */
+#define EMULTIHOP 90 /* Multihop attempted */
+#define ENOLINK 91 /* Link has been severed */
+#define EPROTO 92 /* Protocol error */
+
+#ifndef _POSIX_SOURCE
+#define ELAST 92 /* Must be equal largest errno */
+#endif /* _POSIX_SOURCE */
+
+#ifdef _KERNEL
+/* pseudo-errors returned inside kernel to modify return to process */
+#define ERESTART (-1) /* restart syscall */
+#define EJUSTRETURN (-2) /* don't modify regs, just return */
+#define ENOIOCTL (-3) /* ioctl not handled by this layer */
+#define EDIRIOCTL (-4) /* do direct ioctl in GEOM */
+#endif
+
+#endif
diff --git a/doc/errno.list.linux.txt b/doc/errno.list.linux.txt
new file mode 100644
index 0000000..baa5079
--- /dev/null
+++ b/doc/errno.list.linux.txt
@@ -0,0 +1,1586 @@
+#define ICONV_SUPPORTS_ERRNO 1
+#include <errno.h>
+/* Error constants. Linux specific version.
+ Copyright (C) 1996, 1997, 1998, 1999, 2005 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 2.1 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
+ Lesser 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; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifdef _ERRNO_H
+
+# undef EDOM
+# undef EILSEQ
+# undef ERANGE
+# include <linux/errno.h>
+
+/* Linux has no ENOTSUP error code. */
+# define ENOTSUP EOPNOTSUPP
+
+/* Older Linux versions also had no ECANCELED error code. */
+# ifndef ECANCELED
+# define ECANCELED 125
+# endif
+
+/* Support for error codes to support robust mutexes was added later, too. */
+# ifndef EOWNERDEAD
+# define EOWNERDEAD 130
+# define ENOTRECOVERABLE 131
+# endif
+
+# ifndef __ASSEMBLER__
+/* Function to get address of global `errno' variable. */
+extern int *__errno_location (void) __THROW __attribute__ ((__const__));
+
+# if !defined _LIBC || defined _LIBC_REENTRANT
+/* When using threads, errno is a per-thread value. */
+# define errno (*__errno_location ())
+# endif
+# endif /* !__ASSEMBLER__ */
+#endif /* _ERRNO_H */
+
+#if !defined _ERRNO_H && defined __need_Emath
+/* This is ugly but the kernel header is not clean enough. We must
+ define only the values EDOM, EILSEQ and ERANGE in case __need_Emath is
+ defined. */
+# define EDOM 33 /* Math argument out of domain of function. */
+# define EILSEQ 84 /* Illegal byte sequence. */
+# define ERANGE 34 /* Math result not representable. */
+#endif /* !_ERRNO_H && __need_Emath */
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef APR_ERRNO_H
+#define APR_ERRNO_H
+
+/**
+ * @file apr_errno.h
+ * @brief APR Error Codes
+ */
+
+#include "apr.h"
+
+#if APR_HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @defgroup apr_errno Error Codes
+ * @ingroup APR
+ * @{
+ */
+
+/**
+ * Type for specifying an error or status code.
+ */
+typedef int apr_status_t;
+
+/**
+ * Return a human readable string describing the specified error.
+ * @param statcode The error code the get a string for.
+ * @param buf A buffer to hold the error string.
+ * @param bufsize Size of the buffer to hold the string.
+ */
+APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf,
+ apr_size_t bufsize);
+
+#if defined(DOXYGEN)
+/**
+ * @def APR_FROM_OS_ERROR(os_err_type syserr)
+ * Fold a platform specific error into an apr_status_t code.
+ * @return apr_status_t
+ * @param e The platform os error code.
+ * @warning macro implementation; the syserr argument may be evaluated
+ * multiple times.
+ */
+#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
+
+/**
+ * @def APR_TO_OS_ERROR(apr_status_t statcode)
+ * @return os_err_type
+ * Fold an apr_status_t code back to the native platform defined error.
+ * @param e The apr_status_t folded platform os error code.
+ * @warning macro implementation; the statcode argument may be evaluated
+ * multiple times. If the statcode was not created by apr_get_os_error
+ * or APR_FROM_OS_ERROR, the results are undefined.
+ */
+#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
+
+/** @def apr_get_os_error()
+ * @return apr_status_t the last platform error, folded into apr_status_t, on most platforms
+ * @remark This retrieves errno, or calls a GetLastError() style function, and
+ * folds it with APR_FROM_OS_ERROR. Some platforms (such as OS2) have no
+ * such mechanism, so this call may be unsupported. Do NOT use this
+ * call for socket errors from socket, send, recv etc!
+ */
+
+/** @def apr_set_os_error(e)
+ * Reset the last platform error, unfolded from an apr_status_t, on some platforms
+ * @param e The OS error folded in a prior call to APR_FROM_OS_ERROR()
+ * @warning This is a macro implementation; the statcode argument may be evaluated
+ * multiple times. If the statcode was not created by apr_get_os_error
+ * or APR_FROM_OS_ERROR, the results are undefined. This macro sets
+ * errno, or calls a SetLastError() style function, unfolding statcode
+ * with APR_TO_OS_ERROR. Some platforms (such as OS2) have no such
+ * mechanism, so this call may be unsupported.
+ */
+
+/** @def apr_get_netos_error()
+ * Return the last socket error, folded into apr_status_t, on all platforms
+ * @remark This retrieves errno or calls a GetLastSocketError() style function,
+ * and folds it with APR_FROM_OS_ERROR.
+ */
+
+/** @def apr_set_netos_error(e)
+ * Reset the last socket error, unfolded from an apr_status_t
+ * @param e The socket error folded in a prior call to APR_FROM_OS_ERROR()
+ * @warning This is a macro implementation; the statcode argument may be evaluated
+ * multiple times. If the statcode was not created by apr_get_os_error
+ * or APR_FROM_OS_ERROR, the results are undefined. This macro sets
+ * errno, or calls a WSASetLastError() style function, unfolding
+ * socketcode with APR_TO_OS_ERROR.
+ */
+
+#endif /* defined(DOXYGEN) */
+
+/**
+ * APR_OS_START_ERROR is where the APR specific error values start.
+ */
+#define APR_OS_START_ERROR 20000
+/**
+ * APR_OS_ERRSPACE_SIZE is the maximum number of errors you can fit
+ * into one of the error/status ranges below -- except for
+ * APR_OS_START_USERERR, which see.
+ */
+#define APR_OS_ERRSPACE_SIZE 50000
+/**
+ * APR_OS_START_STATUS is where the APR specific status codes start.
+ */
+#define APR_OS_START_STATUS (APR_OS_START_ERROR + APR_OS_ERRSPACE_SIZE)
+/**
+ * APR_OS_START_USERERR are reserved for applications that use APR that
+ * layer their own error codes along with APR's. Note that the
+ * error immediately following this one is set ten times farther
+ * away than usual, so that users of apr have a lot of room in
+ * which to declare custom error codes.
+ */
+#define APR_OS_START_USERERR (APR_OS_START_STATUS + APR_OS_ERRSPACE_SIZE)
+/**
+ * APR_OS_START_USEERR is obsolete, defined for compatibility only.
+ * Use APR_OS_START_USERERR instead.
+ */
+#define APR_OS_START_USEERR APR_OS_START_USERERR
+/**
+ * APR_OS_START_CANONERR is where APR versions of errno values are defined
+ * on systems which don't have the corresponding errno.
+ */
+#define APR_OS_START_CANONERR (APR_OS_START_USERERR \
+ + (APR_OS_ERRSPACE_SIZE * 10))
+/**
+ * APR_OS_START_EAIERR folds EAI_ error codes from getaddrinfo() into
+ * apr_status_t values.
+ */
+#define APR_OS_START_EAIERR (APR_OS_START_CANONERR + APR_OS_ERRSPACE_SIZE)
+/**
+ * APR_OS_START_SYSERR folds platform-specific system error values into
+ * apr_status_t values.
+ */
+#define APR_OS_START_SYSERR (APR_OS_START_EAIERR + APR_OS_ERRSPACE_SIZE)
+
+/** no error. */
+#define APR_SUCCESS 0
+
+/**
+ * @defgroup APR_Error APR Error Values
+ * <PRE>
+ * <b>APR ERROR VALUES</b>
+ * APR_ENOSTAT APR was unable to perform a stat on the file
+ * APR_ENOPOOL APR was not provided a pool with which to allocate memory
+ * APR_EBADDATE APR was given an invalid date
+ * APR_EINVALSOCK APR was given an invalid socket
+ * APR_ENOPROC APR was not given a process structure
+ * APR_ENOTIME APR was not given a time structure
+ * APR_ENODIR APR was not given a directory structure
+ * APR_ENOLOCK APR was not given a lock structure
+ * APR_ENOPOLL APR was not given a poll structure
+ * APR_ENOSOCKET APR was not given a socket
+ * APR_ENOTHREAD APR was not given a thread structure
+ * APR_ENOTHDKEY APR was not given a thread key structure
+ * APR_ENOSHMAVAIL There is no more shared memory available
+ * APR_EDSOOPEN APR was unable to open the dso object. For more
+ * information call apr_dso_error().
+ * APR_EGENERAL General failure (specific information not available)
+ * APR_EBADIP The specified IP address is invalid
+ * APR_EBADMASK The specified netmask is invalid
+ * APR_ESYMNOTFOUND Could not find the requested symbol
+ * </PRE>
+ *
+ * <PRE>
+ * <b>APR STATUS VALUES</b>
+ * APR_INCHILD Program is currently executing in the child
+ * APR_INPARENT Program is currently executing in the parent
+ * APR_DETACH The thread is detached
+ * APR_NOTDETACH The thread is not detached
+ * APR_CHILD_DONE The child has finished executing
+ * APR_CHILD_NOTDONE The child has not finished executing
+ * APR_TIMEUP The operation did not finish before the timeout
+ * APR_INCOMPLETE The operation was incomplete although some processing
+ * was performed and the results are partially valid
+ * APR_BADCH Getopt found an option not in the option string
+ * APR_BADARG Getopt found an option that is missing an argument
+ * and an argument was specified in the option string
+ * APR_EOF APR has encountered the end of the file
+ * APR_NOTFOUND APR was unable to find the socket in the poll structure
+ * APR_ANONYMOUS APR is using anonymous shared memory
+ * APR_FILEBASED APR is using a file name as the key to the shared memory
+ * APR_KEYBASED APR is using a shared key as the key to the shared memory
+ * APR_EINIT Ininitalizer value. If no option has been found, but
+ * the status variable requires a value, this should be used
+ * APR_ENOTIMPL The APR function has not been implemented on this
+ * platform, either because nobody has gotten to it yet,
+ * or the function is impossible on this platform.
+ * APR_EMISMATCH Two passwords do not match.
+ * APR_EABSOLUTE The given path was absolute.
+ * APR_ERELATIVE The given path was relative.
+ * APR_EINCOMPLETE The given path was neither relative nor absolute.
+ * APR_EABOVEROOT The given path was above the root path.
+ * APR_EBUSY The given lock was busy.
+ * APR_EPROC_UNKNOWN The given process wasn't recognized by APR
+ * </PRE>
+ * @{
+ */
+/** @see APR_STATUS_IS_ENOSTAT */
+#define APR_ENOSTAT (APR_OS_START_ERROR + 1)
+/** @see APR_STATUS_IS_ENOPOOL */
+#define APR_ENOPOOL (APR_OS_START_ERROR + 2)
+/* empty slot: +3 */
+/** @see APR_STATUS_IS_EBADDATE */
+#define APR_EBADDATE (APR_OS_START_ERROR + 4)
+/** @see APR_STATUS_IS_EINVALSOCK */
+#define APR_EINVALSOCK (APR_OS_START_ERROR + 5)
+/** @see APR_STATUS_IS_ENOPROC */
+#define APR_ENOPROC (APR_OS_START_ERROR + 6)
+/** @see APR_STATUS_IS_ENOTIME */
+#define APR_ENOTIME (APR_OS_START_ERROR + 7)
+/** @see APR_STATUS_IS_ENODIR */
+#define APR_ENODIR (APR_OS_START_ERROR + 8)
+/** @see APR_STATUS_IS_ENOLOCK */
+#define APR_ENOLOCK (APR_OS_START_ERROR + 9)
+/** @see APR_STATUS_IS_ENOPOLL */
+#define APR_ENOPOLL (APR_OS_START_ERROR + 10)
+/** @see APR_STATUS_IS_ENOSOCKET */
+#define APR_ENOSOCKET (APR_OS_START_ERROR + 11)
+/** @see APR_STATUS_IS_ENOTHREAD */
+#define APR_ENOTHREAD (APR_OS_START_ERROR + 12)
+/** @see APR_STATUS_IS_ENOTHDKEY */
+#define APR_ENOTHDKEY (APR_OS_START_ERROR + 13)
+/** @see APR_STATUS_IS_EGENERAL */
+#define APR_EGENERAL (APR_OS_START_ERROR + 14)
+/** @see APR_STATUS_IS_ENOSHMAVAIL */
+#define APR_ENOSHMAVAIL (APR_OS_START_ERROR + 15)
+/** @see APR_STATUS_IS_EBADIP */
+#define APR_EBADIP (APR_OS_START_ERROR + 16)
+/** @see APR_STATUS_IS_EBADMASK */
+#define APR_EBADMASK (APR_OS_START_ERROR + 17)
+/* empty slot: +18 */
+/** @see APR_STATUS_IS_EDSOPEN */
+#define APR_EDSOOPEN (APR_OS_START_ERROR + 19)
+/** @see APR_STATUS_IS_EABSOLUTE */
+#define APR_EABSOLUTE (APR_OS_START_ERROR + 20)
+/** @see APR_STATUS_IS_ERELATIVE */
+#define APR_ERELATIVE (APR_OS_START_ERROR + 21)
+/** @see APR_STATUS_IS_EINCOMPLETE */
+#define APR_EINCOMPLETE (APR_OS_START_ERROR + 22)
+/** @see APR_STATUS_IS_EABOVEROOT */
+#define APR_EABOVEROOT (APR_OS_START_ERROR + 23)
+/** @see APR_STATUS_IS_EBADPATH */
+#define APR_EBADPATH (APR_OS_START_ERROR + 24)
+/** @see APR_STATUS_IS_EPATHWILD */
+#define APR_EPATHWILD (APR_OS_START_ERROR + 25)
+/** @see APR_STATUS_IS_ESYMNOTFOUND */
+#define APR_ESYMNOTFOUND (APR_OS_START_ERROR + 26)
+/** @see APR_STATUS_IS_EPROC_UNKNOWN */
+#define APR_EPROC_UNKNOWN (APR_OS_START_ERROR + 27)
+/** @see APR_STATUS_IS_ENOTENOUGHENTROPY */
+#define APR_ENOTENOUGHENTROPY (APR_OS_START_ERROR + 28)
+/** @} */
+
+/**
+ * @defgroup APR_STATUS_IS Status Value Tests
+ * @warning For any particular error condition, more than one of these tests
+ * may match. This is because platform-specific error codes may not
+ * always match the semantics of the POSIX codes these tests (and the
+ * corresponding APR error codes) are named after. A notable example
+ * are the APR_STATUS_IS_ENOENT and APR_STATUS_IS_ENOTDIR tests on
+ * Win32 platforms. The programmer should always be aware of this and
+ * adjust the order of the tests accordingly.
+ * @{
+ */
+/**
+ * APR was unable to perform a stat on the file
+ * @warning always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_ENOSTAT(s) ((s) == APR_ENOSTAT)
+/**
+ * APR was not provided a pool with which to allocate memory
+ * @warning always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_ENOPOOL(s) ((s) == APR_ENOPOOL)
+/** APR was given an invalid date */
+#define APR_STATUS_IS_EBADDATE(s) ((s) == APR_EBADDATE)
+/** APR was given an invalid socket */
+#define APR_STATUS_IS_EINVALSOCK(s) ((s) == APR_EINVALSOCK)
+/** APR was not given a process structure */
+#define APR_STATUS_IS_ENOPROC(s) ((s) == APR_ENOPROC)
+/** APR was not given a time structure */
+#define APR_STATUS_IS_ENOTIME(s) ((s) == APR_ENOTIME)
+/** APR was not given a directory structure */
+#define APR_STATUS_IS_ENODIR(s) ((s) == APR_ENODIR)
+/** APR was not given a lock structure */
+#define APR_STATUS_IS_ENOLOCK(s) ((s) == APR_ENOLOCK)
+/** APR was not given a poll structure */
+#define APR_STATUS_IS_ENOPOLL(s) ((s) == APR_ENOPOLL)
+/** APR was not given a socket */
+#define APR_STATUS_IS_ENOSOCKET(s) ((s) == APR_ENOSOCKET)
+/** APR was not given a thread structure */
+#define APR_STATUS_IS_ENOTHREAD(s) ((s) == APR_ENOTHREAD)
+/** APR was not given a thread key structure */
+#define APR_STATUS_IS_ENOTHDKEY(s) ((s) == APR_ENOTHDKEY)
+/** Generic Error which can not be put into another spot */
+#define APR_STATUS_IS_EGENERAL(s) ((s) == APR_EGENERAL)
+/** There is no more shared memory available */
+#define APR_STATUS_IS_ENOSHMAVAIL(s) ((s) == APR_ENOSHMAVAIL)
+/** The specified IP address is invalid */
+#define APR_STATUS_IS_EBADIP(s) ((s) == APR_EBADIP)
+/** The specified netmask is invalid */
+#define APR_STATUS_IS_EBADMASK(s) ((s) == APR_EBADMASK)
+/* empty slot: +18 */
+/**
+ * APR was unable to open the dso object.
+ * For more information call apr_dso_error().
+ */
+#if defined(WIN32)
+#define APR_STATUS_IS_EDSOOPEN(s) ((s) == APR_EDSOOPEN \
+ || APR_TO_OS_ERROR(s) == ERROR_MOD_NOT_FOUND)
+#else
+#define APR_STATUS_IS_EDSOOPEN(s) ((s) == APR_EDSOOPEN)
+#endif
+/** The given path was absolute. */
+#define APR_STATUS_IS_EABSOLUTE(s) ((s) == APR_EABSOLUTE)
+/** The given path was relative. */
+#define APR_STATUS_IS_ERELATIVE(s) ((s) == APR_ERELATIVE)
+/** The given path was neither relative nor absolute. */
+#define APR_STATUS_IS_EINCOMPLETE(s) ((s) == APR_EINCOMPLETE)
+/** The given path was above the root path. */
+#define APR_STATUS_IS_EABOVEROOT(s) ((s) == APR_EABOVEROOT)
+/** The given path was bad. */
+#define APR_STATUS_IS_EBADPATH(s) ((s) == APR_EBADPATH)
+/** The given path contained wildcards. */
+#define APR_STATUS_IS_EPATHWILD(s) ((s) == APR_EPATHWILD)
+/** Could not find the requested symbol.
+ * For more information call apr_dso_error().
+ */
+#if defined(WIN32)
+#define APR_STATUS_IS_ESYMNOTFOUND(s) ((s) == APR_ESYMNOTFOUND \
+ || APR_TO_OS_ERROR(s) == ERROR_PROC_NOT_FOUND)
+#else
+#define APR_STATUS_IS_ESYMNOTFOUND(s) ((s) == APR_ESYMNOTFOUND)
+#endif
+/** The given process was not recognized by APR. */
+#define APR_STATUS_IS_EPROC_UNKNOWN(s) ((s) == APR_EPROC_UNKNOWN)
+
+/** APR could not gather enough entropy to continue. */
+#define APR_STATUS_IS_ENOTENOUGHENTROPY(s) ((s) == APR_ENOTENOUGHENTROPY)
+
+/** @} */
+
+/**
+ * @addtogroup APR_Error
+ * @{
+ */
+/** @see APR_STATUS_IS_INCHILD */
+#define APR_INCHILD (APR_OS_START_STATUS + 1)
+/** @see APR_STATUS_IS_INPARENT */
+#define APR_INPARENT (APR_OS_START_STATUS + 2)
+/** @see APR_STATUS_IS_DETACH */
+#define APR_DETACH (APR_OS_START_STATUS + 3)
+/** @see APR_STATUS_IS_NOTDETACH */
+#define APR_NOTDETACH (APR_OS_START_STATUS + 4)
+/** @see APR_STATUS_IS_CHILD_DONE */
+#define APR_CHILD_DONE (APR_OS_START_STATUS + 5)
+/** @see APR_STATUS_IS_CHILD_NOTDONE */
+#define APR_CHILD_NOTDONE (APR_OS_START_STATUS + 6)
+/** @see APR_STATUS_IS_TIMEUP */
+#define APR_TIMEUP (APR_OS_START_STATUS + 7)
+/** @see APR_STATUS_IS_INCOMPLETE */
+#define APR_INCOMPLETE (APR_OS_START_STATUS + 8)
+/* empty slot: +9 */
+/* empty slot: +10 */
+/* empty slot: +11 */
+/** @see APR_STATUS_IS_BADCH */
+#define APR_BADCH (APR_OS_START_STATUS + 12)
+/** @see APR_STATUS_IS_BADARG */
+#define APR_BADARG (APR_OS_START_STATUS + 13)
+/** @see APR_STATUS_IS_EOF */
+#define APR_EOF (APR_OS_START_STATUS + 14)
+/** @see APR_STATUS_IS_NOTFOUND */
+#define APR_NOTFOUND (APR_OS_START_STATUS + 15)
+/* empty slot: +16 */
+/* empty slot: +17 */
+/* empty slot: +18 */
+/** @see APR_STATUS_IS_ANONYMOUS */
+#define APR_ANONYMOUS (APR_OS_START_STATUS + 19)
+/** @see APR_STATUS_IS_FILEBASED */
+#define APR_FILEBASED (APR_OS_START_STATUS + 20)
+/** @see APR_STATUS_IS_KEYBASED */
+#define APR_KEYBASED (APR_OS_START_STATUS + 21)
+/** @see APR_STATUS_IS_EINIT */
+#define APR_EINIT (APR_OS_START_STATUS + 22)
+/** @see APR_STATUS_IS_ENOTIMPL */
+#define APR_ENOTIMPL (APR_OS_START_STATUS + 23)
+/** @see APR_STATUS_IS_EMISMATCH */
+#define APR_EMISMATCH (APR_OS_START_STATUS + 24)
+/** @see APR_STATUS_IS_EBUSY */
+#define APR_EBUSY (APR_OS_START_STATUS + 25)
+/** @} */
+
+/**
+ * @addtogroup APR_STATUS_IS
+ * @{
+ */
+/**
+ * Program is currently executing in the child
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code */
+#define APR_STATUS_IS_INCHILD(s) ((s) == APR_INCHILD)
+/**
+ * Program is currently executing in the parent
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_INPARENT(s) ((s) == APR_INPARENT)
+/**
+ * The thread is detached
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_DETACH(s) ((s) == APR_DETACH)
+/**
+ * The thread is not detached
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_NOTDETACH(s) ((s) == APR_NOTDETACH)
+/**
+ * The child has finished executing
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_CHILD_DONE(s) ((s) == APR_CHILD_DONE)
+/**
+ * The child has not finished executing
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_CHILD_NOTDONE(s) ((s) == APR_CHILD_NOTDONE)
+/**
+ * The operation did not finish before the timeout
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP)
+/**
+ * The operation was incomplete although some processing was performed
+ * and the results are partially valid.
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_INCOMPLETE(s) ((s) == APR_INCOMPLETE)
+/* empty slot: +9 */
+/* empty slot: +10 */
+/* empty slot: +11 */
+/**
+ * Getopt found an option not in the option string
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_BADCH(s) ((s) == APR_BADCH)
+/**
+ * Getopt found an option not in the option string and an argument was
+ * specified in the option string
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_BADARG(s) ((s) == APR_BADARG)
+/**
+ * APR has encountered the end of the file
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_EOF(s) ((s) == APR_EOF)
+/**
+ * APR was unable to find the socket in the poll structure
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_NOTFOUND(s) ((s) == APR_NOTFOUND)
+/* empty slot: +16 */
+/* empty slot: +17 */
+/* empty slot: +18 */
+/**
+ * APR is using anonymous shared memory
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_ANONYMOUS(s) ((s) == APR_ANONYMOUS)
+/**
+ * APR is using a file name as the key to the shared memory
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_FILEBASED(s) ((s) == APR_FILEBASED)
+/**
+ * APR is using a shared key as the key to the shared memory
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_KEYBASED(s) ((s) == APR_KEYBASED)
+/**
+ * Ininitalizer value. If no option has been found, but
+ * the status variable requires a value, this should be used
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_EINIT(s) ((s) == APR_EINIT)
+/**
+ * The APR function has not been implemented on this
+ * platform, either because nobody has gotten to it yet,
+ * or the function is impossible on this platform.
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_ENOTIMPL(s) ((s) == APR_ENOTIMPL)
+/**
+ * Two passwords do not match.
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_EMISMATCH(s) ((s) == APR_EMISMATCH)
+/**
+ * The given lock was busy
+ * @warning always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_EBUSY(s) ((s) == APR_EBUSY)
+
+/** @} */
+
+/**
+ * @addtogroup APR_Error APR Error Values
+ * @{
+ */
+/* APR CANONICAL ERROR VALUES */
+/** @see APR_STATUS_IS_EACCES */
+#ifdef EACCES
+#define APR_EACCES EACCES
+#else
+#define APR_EACCES (APR_OS_START_CANONERR + 1)
+#endif
+
+/** @see APR_STATUS_IS_EXIST */
+#ifdef EEXIST
+#define APR_EEXIST EEXIST
+#else
+#define APR_EEXIST (APR_OS_START_CANONERR + 2)
+#endif
+
+/** @see APR_STATUS_IS_ENAMETOOLONG */
+#ifdef ENAMETOOLONG
+#define APR_ENAMETOOLONG ENAMETOOLONG
+#else
+#define APR_ENAMETOOLONG (APR_OS_START_CANONERR + 3)
+#endif
+
+/** @see APR_STATUS_IS_ENOENT */
+#ifdef ENOENT
+#define APR_ENOENT ENOENT
+#else
+#define APR_ENOENT (APR_OS_START_CANONERR + 4)
+#endif
+
+/** @see APR_STATUS_IS_ENOTDIR */
+#ifdef ENOTDIR
+#define APR_ENOTDIR ENOTDIR
+#else
+#define APR_ENOTDIR (APR_OS_START_CANONERR + 5)
+#endif
+
+/** @see APR_STATUS_IS_ENOSPC */
+#ifdef ENOSPC
+#define APR_ENOSPC ENOSPC
+#else
+#define APR_ENOSPC (APR_OS_START_CANONERR + 6)
+#endif
+
+/** @see APR_STATUS_IS_ENOMEM */
+#ifdef ENOMEM
+#define APR_ENOMEM ENOMEM
+#else
+#define APR_ENOMEM (APR_OS_START_CANONERR + 7)
+#endif
+
+/** @see APR_STATUS_IS_EMFILE */
+#ifdef EMFILE
+#define APR_EMFILE EMFILE
+#else
+#define APR_EMFILE (APR_OS_START_CANONERR + 8)
+#endif
+
+/** @see APR_STATUS_IS_ENFILE */
+#ifdef ENFILE
+#define APR_ENFILE ENFILE
+#else
+#define APR_ENFILE (APR_OS_START_CANONERR + 9)
+#endif
+
+/** @see APR_STATUS_IS_EBADF */
+#ifdef EBADF
+#define APR_EBADF EBADF
+#else
+#define APR_EBADF (APR_OS_START_CANONERR + 10)
+#endif
+
+/** @see APR_STATUS_IS_EINVAL */
+#ifdef EINVAL
+#define APR_EINVAL EINVAL
+#else
+#define APR_EINVAL (APR_OS_START_CANONERR + 11)
+#endif
+
+/** @see APR_STATUS_IS_ESPIPE */
+#ifdef ESPIPE
+#define APR_ESPIPE ESPIPE
+#else
+#define APR_ESPIPE (APR_OS_START_CANONERR + 12)
+#endif
+
+/**
+ * @see APR_STATUS_IS_EAGAIN
+ * @warning use APR_STATUS_IS_EAGAIN instead of just testing this value
+ */
+#ifdef EAGAIN
+#define APR_EAGAIN EAGAIN
+#elif defined(EWOULDBLOCK)
+#define APR_EAGAIN EWOULDBLOCK
+#else
+#define APR_EAGAIN (APR_OS_START_CANONERR + 13)
+#endif
+
+/** @see APR_STATUS_IS_EINTR */
+#ifdef EINTR
+#define APR_EINTR EINTR
+#else
+#define APR_EINTR (APR_OS_START_CANONERR + 14)
+#endif
+
+/** @see APR_STATUS_IS_ENOTSOCK */
+#ifdef ENOTSOCK
+#define APR_ENOTSOCK ENOTSOCK
+#else
+#define APR_ENOTSOCK (APR_OS_START_CANONERR + 15)
+#endif
+
+/** @see APR_STATUS_IS_ECONNREFUSED */
+#ifdef ECONNREFUSED
+#define APR_ECONNREFUSED ECONNREFUSED
+#else
+#define APR_ECONNREFUSED (APR_OS_START_CANONERR + 16)
+#endif
+
+/** @see APR_STATUS_IS_EINPROGRESS */
+#ifdef EINPROGRESS
+#define APR_EINPROGRESS EINPROGRESS
+#else
+#define APR_EINPROGRESS (APR_OS_START_CANONERR + 17)
+#endif
+
+/**
+ * @see APR_STATUS_IS_ECONNABORTED
+ * @warning use APR_STATUS_IS_ECONNABORTED instead of just testing this value
+ */
+
+#ifdef ECONNABORTED
+#define APR_ECONNABORTED ECONNABORTED
+#else
+#define APR_ECONNABORTED (APR_OS_START_CANONERR + 18)
+#endif
+
+/** @see APR_STATUS_IS_ECONNRESET */
+#ifdef ECONNRESET
+#define APR_ECONNRESET ECONNRESET
+#else
+#define APR_ECONNRESET (APR_OS_START_CANONERR + 19)
+#endif
+
+/** @see APR_STATUS_IS_ETIMEDOUT
+ * @deprecated */
+#ifdef ETIMEDOUT
+#define APR_ETIMEDOUT ETIMEDOUT
+#else
+#define APR_ETIMEDOUT (APR_OS_START_CANONERR + 20)
+#endif
+
+/** @see APR_STATUS_IS_EHOSTUNREACH */
+#ifdef EHOSTUNREACH
+#define APR_EHOSTUNREACH EHOSTUNREACH
+#else
+#define APR_EHOSTUNREACH (APR_OS_START_CANONERR + 21)
+#endif
+
+/** @see APR_STATUS_IS_ENETUNREACH */
+#ifdef ENETUNREACH
+#define APR_ENETUNREACH ENETUNREACH
+#else
+#define APR_ENETUNREACH (APR_OS_START_CANONERR + 22)
+#endif
+
+/** @see APR_STATUS_IS_EFTYPE */
+#ifdef EFTYPE
+#define APR_EFTYPE EFTYPE
+#else
+#define APR_EFTYPE (APR_OS_START_CANONERR + 23)
+#endif
+
+/** @see APR_STATUS_IS_EPIPE */
+#ifdef EPIPE
+#define APR_EPIPE EPIPE
+#else
+#define APR_EPIPE (APR_OS_START_CANONERR + 24)
+#endif
+
+/** @see APR_STATUS_IS_EXDEV */
+#ifdef EXDEV
+#define APR_EXDEV EXDEV
+#else
+#define APR_EXDEV (APR_OS_START_CANONERR + 25)
+#endif
+
+/** @see APR_STATUS_IS_ENOTEMPTY */
+#ifdef ENOTEMPTY
+#define APR_ENOTEMPTY ENOTEMPTY
+#else
+#define APR_ENOTEMPTY (APR_OS_START_CANONERR + 26)
+#endif
+
+/** @} */
+
+#if defined(OS2) && !defined(DOXYGEN)
+
+#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
+#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
+
+#define INCL_DOSERRORS
+#define INCL_DOS
+
+/* Leave these undefined.
+ * OS2 doesn't rely on the errno concept.
+ * The API calls always return a result codes which
+ * should be filtered through APR_FROM_OS_ERROR().
+ *
+ * #define apr_get_os_error() (APR_FROM_OS_ERROR(GetLastError()))
+ * #define apr_set_os_error(e) (SetLastError(APR_TO_OS_ERROR(e)))
+ */
+
+/* A special case, only socket calls require this;
+ */
+#define apr_get_netos_error() (APR_FROM_OS_ERROR(errno))
+#define apr_set_netos_error(e) (errno = APR_TO_OS_ERROR(e))
+
+/* And this needs to be greped away for good:
+ */
+#define APR_OS2_STATUS(e) (APR_FROM_OS_ERROR(e))
+
+/* These can't sit in a private header, so in spite of the extra size,
+ * they need to be made available here.
+ */
+#define SOCBASEERR 10000
+#define SOCEPERM (SOCBASEERR+1) /* Not owner */
+#define SOCESRCH (SOCBASEERR+3) /* No such process */
+#define SOCEINTR (SOCBASEERR+4) /* Interrupted system call */
+#define SOCENXIO (SOCBASEERR+6) /* No such device or address */
+#define SOCEBADF (SOCBASEERR+9) /* Bad file number */
+#define SOCEACCES (SOCBASEERR+13) /* Permission denied */
+#define SOCEFAULT (SOCBASEERR+14) /* Bad address */
+#define SOCEINVAL (SOCBASEERR+22) /* Invalid argument */
+#define SOCEMFILE (SOCBASEERR+24) /* Too many open files */
+#define SOCEPIPE (SOCBASEERR+32) /* Broken pipe */
+#define SOCEOS2ERR (SOCBASEERR+100) /* OS/2 Error */
+#define SOCEWOULDBLOCK (SOCBASEERR+35) /* Operation would block */
+#define SOCEINPROGRESS (SOCBASEERR+36) /* Operation now in progress */
+#define SOCEALREADY (SOCBASEERR+37) /* Operation already in progress */
+#define SOCENOTSOCK (SOCBASEERR+38) /* Socket operation on non-socket */
+#define SOCEDESTADDRREQ (SOCBASEERR+39) /* Destination address required */
+#define SOCEMSGSIZE (SOCBASEERR+40) /* Message too long */
+#define SOCEPROTOTYPE (SOCBASEERR+41) /* Protocol wrong type for socket */
+#define SOCENOPROTOOPT (SOCBASEERR+42) /* Protocol not available */
+#define SOCEPROTONOSUPPORT (SOCBASEERR+43) /* Protocol not supported */
+#define SOCESOCKTNOSUPPORT (SOCBASEERR+44) /* Socket type not supported */
+#define SOCEOPNOTSUPP (SOCBASEERR+45) /* Operation not supported on socket */
+#define SOCEPFNOSUPPORT (SOCBASEERR+46) /* Protocol family not supported */
+#define SOCEAFNOSUPPORT (SOCBASEERR+47) /* Address family not supported by protocol family */
+#define SOCEADDRINUSE (SOCBASEERR+48) /* Address already in use */
+#define SOCEADDRNOTAVAIL (SOCBASEERR+49) /* Can't assign requested address */
+#define SOCENETDOWN (SOCBASEERR+50) /* Network is down */
+#define SOCENETUNREACH (SOCBASEERR+51) /* Network is unreachable */
+#define SOCENETRESET (SOCBASEERR+52) /* Network dropped connection on reset */
+#define SOCECONNABORTED (SOCBASEERR+53) /* Software caused connection abort */
+#define SOCECONNRESET (SOCBASEERR+54) /* Connection reset by peer */
+#define SOCENOBUFS (SOCBASEERR+55) /* No buffer space available */
+#define SOCEISCONN (SOCBASEERR+56) /* Socket is already connected */
+#define SOCENOTCONN (SOCBASEERR+57) /* Socket is not connected */
+#define SOCESHUTDOWN (SOCBASEERR+58) /* Can't send after socket shutdown */
+#define SOCETOOMANYREFS (SOCBASEERR+59) /* Too many references: can't splice */
+#define SOCETIMEDOUT (SOCBASEERR+60) /* Connection timed out */
+#define SOCECONNREFUSED (SOCBASEERR+61) /* Connection refused */
+#define SOCELOOP (SOCBASEERR+62) /* Too many levels of symbolic links */
+#define SOCENAMETOOLONG (SOCBASEERR+63) /* File name too long */
+#define SOCEHOSTDOWN (SOCBASEERR+64) /* Host is down */
+#define SOCEHOSTUNREACH (SOCBASEERR+65) /* No route to host */
+#define SOCENOTEMPTY (SOCBASEERR+66) /* Directory not empty */
+
+/* APR CANONICAL ERROR TESTS */
+#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES \
+ || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \
+ || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION)
+#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST \
+ || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \
+ || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \
+ || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS \
+ || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED)
+#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG \
+ || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \
+ || (s) == APR_OS_START_SYSERR + SOCENAMETOOLONG)
+#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \
+ || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \
+ || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
+ || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES \
+ || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED)
+#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR)
+#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC \
+ || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL)
+#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM)
+#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE \
+ || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES)
+#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE)
+#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE)
+#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION)
+#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE \
+ || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
+#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \
+ || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \
+ || (s) == APR_OS_START_SYSERR + SOCEWOULDBLOCK \
+ || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION)
+#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \
+ || (s) == APR_OS_START_SYSERR + SOCEINTR)
+#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \
+ || (s) == APR_OS_START_SYSERR + SOCENOTSOCK)
+#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \
+ || (s) == APR_OS_START_SYSERR + SOCECONNREFUSED)
+#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \
+ || (s) == APR_OS_START_SYSERR + SOCEINPROGRESS)
+#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \
+ || (s) == APR_OS_START_SYSERR + SOCECONNABORTED)
+#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \
+ || (s) == APR_OS_START_SYSERR + SOCECONNRESET)
+/* XXX deprecated */
+#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \
+ || (s) == APR_OS_START_SYSERR + SOCETIMEDOUT)
+#undef APR_STATUS_IS_TIMEUP
+#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP \
+ || (s) == APR_OS_START_SYSERR + SOCETIMEDOUT)
+#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \
+ || (s) == APR_OS_START_SYSERR + SOCEHOSTUNREACH)
+#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \
+ || (s) == APR_OS_START_SYSERR + SOCENETUNREACH)
+#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE)
+#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE \
+ || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE \
+ || (s) == APR_OS_START_SYSERR + SOCEPIPE)
+#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV \
+ || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE)
+#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY \
+ || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY \
+ || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED)
+
+/*
+ Sorry, too tired to wrap this up for OS2... feel free to
+ fit the following into their best matches.
+
+ { ERROR_NO_SIGNAL_SENT, ESRCH },
+ { SOCEALREADY, EALREADY },
+ { SOCEDESTADDRREQ, EDESTADDRREQ },
+ { SOCEMSGSIZE, EMSGSIZE },
+ { SOCEPROTOTYPE, EPROTOTYPE },
+ { SOCENOPROTOOPT, ENOPROTOOPT },
+ { SOCEPROTONOSUPPORT, EPROTONOSUPPORT },
+ { SOCESOCKTNOSUPPORT, ESOCKTNOSUPPORT },
+ { SOCEOPNOTSUPP, EOPNOTSUPP },
+ { SOCEPFNOSUPPORT, EPFNOSUPPORT },
+ { SOCEAFNOSUPPORT, EAFNOSUPPORT },
+ { SOCEADDRINUSE, EADDRINUSE },
+ { SOCEADDRNOTAVAIL, EADDRNOTAVAIL },
+ { SOCENETDOWN, ENETDOWN },
+ { SOCENETRESET, ENETRESET },
+ { SOCENOBUFS, ENOBUFS },
+ { SOCEISCONN, EISCONN },
+ { SOCENOTCONN, ENOTCONN },
+ { SOCESHUTDOWN, ESHUTDOWN },
+ { SOCETOOMANYREFS, ETOOMANYREFS },
+ { SOCELOOP, ELOOP },
+ { SOCEHOSTDOWN, EHOSTDOWN },
+ { SOCENOTEMPTY, ENOTEMPTY },
+ { SOCEPIPE, EPIPE }
+*/
+
+#elif defined(WIN32) && !defined(DOXYGEN) /* !defined(OS2) */
+
+#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
+#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
+
+#define apr_get_os_error() (APR_FROM_OS_ERROR(GetLastError()))
+#define apr_set_os_error(e) (SetLastError(APR_TO_OS_ERROR(e)))
+
+/* A special case, only socket calls require this:
+ */
+#define apr_get_netos_error() (APR_FROM_OS_ERROR(WSAGetLastError()))
+#define apr_set_netos_error(e) (WSASetLastError(APR_TO_OS_ERROR(e)))
+
+/* APR CANONICAL ERROR TESTS */
+#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES \
+ || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \
+ || (s) == APR_OS_START_SYSERR + ERROR_CANNOT_MAKE \
+ || (s) == APR_OS_START_SYSERR + ERROR_CURRENT_DIRECTORY \
+ || (s) == APR_OS_START_SYSERR + ERROR_DRIVE_LOCKED \
+ || (s) == APR_OS_START_SYSERR + ERROR_FAIL_I24 \
+ || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \
+ || (s) == APR_OS_START_SYSERR + ERROR_LOCK_FAILED \
+ || (s) == APR_OS_START_SYSERR + ERROR_NOT_LOCKED \
+ || (s) == APR_OS_START_SYSERR + ERROR_NETWORK_ACCESS_DENIED \
+ || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION)
+#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST \
+ || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \
+ || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS)
+#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG \
+ || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \
+ || (s) == APR_OS_START_SYSERR + WSAENAMETOOLONG)
+#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \
+ || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \
+ || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
+ || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \
+ || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES)
+#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR \
+ || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
+ || (s) == APR_OS_START_SYSERR + ERROR_BAD_NETPATH \
+ || (s) == APR_OS_START_SYSERR + ERROR_BAD_NET_NAME \
+ || (s) == APR_OS_START_SYSERR + ERROR_BAD_PATHNAME \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DRIVE)
+#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC \
+ || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL)
+#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM \
+ || (s) == APR_OS_START_SYSERR + ERROR_ARENA_TRASHED \
+ || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_MEMORY \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_BLOCK \
+ || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_QUOTA \
+ || (s) == APR_OS_START_SYSERR + ERROR_OUTOFMEMORY)
+#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE \
+ || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES)
+#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE)
+#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_TARGET_HANDLE)
+#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_ACCESS \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DATA \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \
+ || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
+#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE \
+ || (s) == APR_OS_START_SYSERR + ERROR_SEEK_ON_DEVICE \
+ || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
+#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \
+ || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \
+ || (s) == APR_OS_START_SYSERR + ERROR_NO_PROC_SLOTS \
+ || (s) == APR_OS_START_SYSERR + ERROR_NESTING_NOT_ALLOWED \
+ || (s) == APR_OS_START_SYSERR + ERROR_MAX_THRDS_REACHED \
+ || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \
+ || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK)
+#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \
+ || (s) == APR_OS_START_SYSERR + WSAEINTR)
+#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \
+ || (s) == APR_OS_START_SYSERR + WSAENOTSOCK)
+#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \
+ || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED)
+#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \
+ || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS)
+#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \
+ || (s) == APR_OS_START_SYSERR + WSAECONNABORTED)
+#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \
+ || (s) == APR_OS_START_SYSERR + ERROR_NETNAME_DELETED \
+ || (s) == APR_OS_START_SYSERR + WSAECONNRESET)
+/* XXX deprecated */
+#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \
+ || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
+ || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
+#undef APR_STATUS_IS_TIMEUP
+#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP \
+ || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
+ || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
+#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \
+ || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH)
+#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \
+ || (s) == APR_OS_START_SYSERR + WSAENETUNREACH)
+#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE \
+ || (s) == APR_OS_START_SYSERR + ERROR_EXE_MACHINE_TYPE_MISMATCH \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DLL \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_MODULETYPE \
+ || (s) == APR_OS_START_SYSERR + ERROR_BAD_EXE_FORMAT \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_EXE_SIGNATURE \
+ || (s) == APR_OS_START_SYSERR + ERROR_FILE_CORRUPT \
+ || (s) == APR_OS_START_SYSERR + ERROR_BAD_FORMAT)
+#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE \
+ || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE)
+#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV \
+ || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE)
+#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY \
+ || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY)
+
+#elif defined(NETWARE) && defined(USE_WINSOCK) && !defined(DOXYGEN) /* !defined(OS2) && !defined(WIN32) */
+
+#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
+#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
+
+#define apr_get_os_error() (errno)
+#define apr_set_os_error(e) (errno = (e))
+
+/* A special case, only socket calls require this: */
+#define apr_get_netos_error() (APR_FROM_OS_ERROR(WSAGetLastError()))
+#define apr_set_netos_error(e) (WSASetLastError(APR_TO_OS_ERROR(e)))
+
+/* APR CANONICAL ERROR TESTS */
+#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES)
+#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST)
+#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG)
+#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT)
+#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR)
+#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC)
+#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM)
+#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE)
+#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE)
+#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF)
+#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL)
+#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE)
+
+#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \
+ || (s) == EWOULDBLOCK \
+ || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK)
+#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \
+ || (s) == APR_OS_START_SYSERR + WSAEINTR)
+#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \
+ || (s) == APR_OS_START_SYSERR + WSAENOTSOCK)
+#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \
+ || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED)
+#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \
+ || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS)
+#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \
+ || (s) == APR_OS_START_SYSERR + WSAECONNABORTED)
+#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \
+ || (s) == APR_OS_START_SYSERR + WSAECONNRESET)
+/* XXX deprecated */
+#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \
+ || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
+ || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
+#undef APR_STATUS_IS_TIMEUP
+#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP \
+ || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
+ || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
+#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \
+ || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH)
+#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \
+ || (s) == APR_OS_START_SYSERR + WSAENETUNREACH)
+#define APR_STATUS_IS_ENETDOWN(s) ((s) == APR_OS_START_SYSERR + WSAENETDOWN)
+#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE)
+#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE)
+#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV)
+#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY)
+
+#else /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */
+
+/*
+ * os error codes are clib error codes
+ */
+#define APR_FROM_OS_ERROR(e) (e)
+#define APR_TO_OS_ERROR(e) (e)
+
+#define apr_get_os_error() (errno)
+#define apr_set_os_error(e) (errno = (e))
+
+/* A special case, only socket calls require this:
+ */
+#define apr_get_netos_error() (errno)
+#define apr_set_netos_error(e) (errno = (e))
+
+/**
+ * @addtogroup APR_STATUS_IS
+ * @{
+ */
+
+/** permission denied */
+#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES)
+/** file exists */
+#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST)
+/** path name is too long */
+#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG)
+/**
+ * no such file or directory
+ * @remark
+ * EMVSCATLG can be returned by the automounter on z/OS for
+ * paths which do not exist.
+ */
+#ifdef EMVSCATLG
+#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \
+ || (s) == EMVSCATLG)
+#else
+#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT)
+#endif
+/** not a directory */
+#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR)
+/** no space left on device */
+#ifdef EDQUOT
+#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC \
+ || (s) == EDQUOT)
+#else
+#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC)
+#endif
+/** not enough memory */
+#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM)
+/** too many open files */
+#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE)
+/** file table overflow */
+#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE)
+/** bad file # */
+#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF)
+/** invalid argument */
+#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL)
+/** illegal seek */
+#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE)
+
+/** operation would block */
+#if !defined(EWOULDBLOCK) || !defined(EAGAIN)
+#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN)
+#elif (EWOULDBLOCK == EAGAIN)
+#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN)
+#else
+#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \
+ || (s) == EWOULDBLOCK)
+#endif
+
+/** interrupted system call */
+#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR)
+/** socket operation on a non-socket */
+#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK)
+/** Connection Refused */
+#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED)
+/** operation now in progress */
+#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS)
+
+/**
+ * Software caused connection abort
+ * @remark
+ * EPROTO on certain older kernels really means ECONNABORTED, so we need to
+ * ignore it for them. See discussion in new-httpd archives nh.9701 & nh.9603
+ *
+ * There is potentially a bug in Solaris 2.x x<6, and other boxes that
+ * implement tcp sockets in userland (i.e. on top of STREAMS). On these
+ * systems, EPROTO can actually result in a fatal loop. See PR#981 for
+ * example. It's hard to handle both uses of EPROTO.
+ */
+#ifdef EPROTO
+#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \
+ || (s) == EPROTO)
+#else
+#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED)
+#endif
+
+/** Connection Reset by peer */
+#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET)
+/** Operation timed out
+ * @deprecated */
+#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT)
+/** no route to host */
+#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH)
+/** network is unreachable */
+#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH)
+/** inappropiate file type or format */
+#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE)
+/** broken pipe */
+#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE)
+/** cross device link */
+#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV)
+/** Directory Not Empty */
+#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY || \
+ (s) == APR_EEXIST)
+/** @} */
+
+#endif /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ! APR_ERRNO_H */
+#ifndef _LINUX_ERRNO_H
+#define _LINUX_ERRNO_H
+
+#include <asm/errno.h>
+
+#ifdef __KERNEL__
+
+/* Should never be seen by user programs */
+#define ERESTARTSYS 512
+#define ERESTARTNOINTR 513
+#define ERESTARTNOHAND 514 /* restart if no handler.. */
+#define ENOIOCTLCMD 515 /* No ioctl command */
+#define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */
+
+/* Defined for the NFSv3 protocol */
+#define EBADHANDLE 521 /* Illegal NFS file handle */
+#define ENOTSYNC 522 /* Update synchronization mismatch */
+#define EBADCOOKIE 523 /* Cookie is stale */
+#define ENOTSUPP 524 /* Operation is not supported */
+#define ETOOSMALL 525 /* Buffer or request is too small */
+#define ESERVERFAULT 526 /* An untranslatable error occurred */
+#define EBADTYPE 527 /* Type not supported by server */
+#define EJUKEBOX 528 /* Request initiated, but will not complete before timeout */
+#define EIOCBQUEUED 529 /* iocb queued, will get completion event */
+#define EIOCBRETRY 530 /* iocb queued, will trigger a retry */
+
+#endif
+
+#endif
+// Copyright (c) 1994 James Clark
+// See the file COPYING for copying permission.
+
+#ifndef ErrnoMessageArg_INCLUDED
+#define ErrnoMessageArg_INCLUDED 1
+
+#include "MessageArg.h"
+#include "rtti.h"
+
+#ifdef SP_NAMESPACE
+namespace SP_NAMESPACE {
+#endif
+
+class SP_API ErrnoMessageArg : public OtherMessageArg {
+ RTTI_CLASS
+public:
+ ErrnoMessageArg(int errnum) : errno_(errnum) { }
+ MessageArg *copy() const;
+ // errno might be a macro so we must use a different name
+ int errnum() const;
+private:
+ int errno_;
+};
+
+inline
+int ErrnoMessageArg::errnum() const
+{
+ return errno_;
+}
+
+#ifdef SP_NAMESPACE
+}
+#endif
+
+#endif /* not ErrnoMessageArg_INCLUDED */
+/* Copyright (C) 1991,92,93,94,95,96,97,2002 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 2.1 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
+ Lesser 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; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/*
+ * ISO C99 Standard: 7.5 Errors <errno.h>
+ */
+
+#ifndef _ERRNO_H
+
+/* The includer defined __need_Emath if he wants only the definitions
+ of EDOM and ERANGE, and not everything else. */
+#ifndef __need_Emath
+# define _ERRNO_H 1
+# include <features.h>
+#endif
+
+__BEGIN_DECLS
+
+/* Get the error number constants from the system-specific file.
+ This file will test __need_Emath and _ERRNO_H. */
+#include <bits/errno.h>
+#undef __need_Emath
+
+#ifdef _ERRNO_H
+
+/* Declare the `errno' variable, unless it's defined as a macro by
+ bits/errno.h. This is the case in GNU, where it is a per-thread
+ variable. This redeclaration using the macro still works, but it
+ will be a function declaration without a prototype and may trigger
+ a -Wstrict-prototypes warning. */
+#ifndef errno
+extern int errno;
+#endif
+
+#ifdef __USE_GNU
+
+/* The full and simple forms of the name with which the program was
+ invoked. These variables are set up automatically at startup based on
+ the value of ARGV[0] (this works only if you use GNU ld). */
+extern char *program_invocation_name, *program_invocation_short_name;
+#endif /* __USE_GNU */
+#endif /* _ERRNO_H */
+
+__END_DECLS
+
+#endif /* _ERRNO_H */
+
+/* The Hurd <bits/errno.h> defines `error_t' as an enumerated type so
+ that printing `error_t' values in the debugger shows the names. We
+ might need this definition sometimes even if this file was included
+ before. */
+#if defined __USE_GNU || defined __need_error_t
+# ifndef __error_t_defined
+typedef int error_t;
+# define __error_t_defined 1
+# endif
+# undef __need_error_t
+#endif
+#ifndef _I386_ERRNO_H
+#define _I386_ERRNO_H
+
+#include <asm-generic/errno.h>
+
+#endif
+#ifndef _ASM_GENERIC_ERRNO_BASE_H
+#define _ASM_GENERIC_ERRNO_BASE_H
+
+#define EPERM 1 /* Operation not permitted */
+#define ENOENT 2 /* No such file or directory */
+#define ESRCH 3 /* No such process */
+#define EINTR 4 /* Interrupted system call */
+#define EIO 5 /* I/O error */
+#define ENXIO 6 /* No such device or address */
+#define E2BIG 7 /* Argument list too long */
+#define ENOEXEC 8 /* Exec format error */
+#define EBADF 9 /* Bad file number */
+#define ECHILD 10 /* No child processes */
+#define EAGAIN 11 /* Try again */
+#define ENOMEM 12 /* Out of memory */
+#define EACCES 13 /* Permission denied */
+#define EFAULT 14 /* Bad address */
+#define ENOTBLK 15 /* Block device required */
+#define EBUSY 16 /* Device or resource busy */
+#define EEXIST 17 /* File exists */
+#define EXDEV 18 /* Cross-device link */
+#define ENODEV 19 /* No such device */
+#define ENOTDIR 20 /* Not a directory */
+#define EISDIR 21 /* Is a directory */
+#define EINVAL 22 /* Invalid argument */
+#define ENFILE 23 /* File table overflow */
+#define EMFILE 24 /* Too many open files */
+#define ENOTTY 25 /* Not a typewriter */
+#define ETXTBSY 26 /* Text file busy */
+#define EFBIG 27 /* File too large */
+#define ENOSPC 28 /* No space left on device */
+#define ESPIPE 29 /* Illegal seek */
+#define EROFS 30 /* Read-only file system */
+#define EMLINK 31 /* Too many links */
+#define EPIPE 32 /* Broken pipe */
+#define EDOM 33 /* Math argument out of domain of func */
+#define ERANGE 34 /* Math result not representable */
+
+#endif
+#ifndef _ASM_GENERIC_ERRNO_H
+#define _ASM_GENERIC_ERRNO_H
+
+#include <asm-generic/errno-base.h>
+
+#define EDEADLK 35 /* Resource deadlock would occur */
+#define ENAMETOOLONG 36 /* File name too long */
+#define ENOLCK 37 /* No record locks available */
+#define ENOSYS 38 /* Function not implemented */
+#define ENOTEMPTY 39 /* Directory not empty */
+#define ELOOP 40 /* Too many symbolic links encountered */
+#define EWOULDBLOCK EAGAIN /* Operation would block */
+#define ENOMSG 42 /* No message of desired type */
+#define EIDRM 43 /* Identifier removed */
+#define ECHRNG 44 /* Channel number out of range */
+#define EL2NSYNC 45 /* Level 2 not synchronized */
+#define EL3HLT 46 /* Level 3 halted */
+#define EL3RST 47 /* Level 3 reset */
+#define ELNRNG 48 /* Link number out of range */
+#define EUNATCH 49 /* Protocol driver not attached */
+#define ENOCSI 50 /* No CSI structure available */
+#define EL2HLT 51 /* Level 2 halted */
+#define EBADE 52 /* Invalid exchange */
+#define EBADR 53 /* Invalid request descriptor */
+#define EXFULL 54 /* Exchange full */
+#define ENOANO 55 /* No anode */
+#define EBADRQC 56 /* Invalid request code */
+#define EBADSLT 57 /* Invalid slot */
+
+#define EDEADLOCK EDEADLK
+
+#define EBFONT 59 /* Bad font file format */
+#define ENOSTR 60 /* Device not a stream */
+#define ENODATA 61 /* No data available */
+#define ETIME 62 /* Timer expired */
+#define ENOSR 63 /* Out of streams resources */
+#define ENONET 64 /* Machine is not on the network */
+#define ENOPKG 65 /* Package not installed */
+#define EREMOTE 66 /* Object is remote */
+#define ENOLINK 67 /* Link has been severed */
+#define EADV 68 /* Advertise error */
+#define ESRMNT 69 /* Srmount error */
+#define ECOMM 70 /* Communication error on send */
+#define EPROTO 71 /* Protocol error */
+#define EMULTIHOP 72 /* Multihop attempted */
+#define EDOTDOT 73 /* RFS specific error */
+#define EBADMSG 74 /* Not a data message */
+#define EOVERFLOW 75 /* Value too large for defined data type */
+#define ENOTUNIQ 76 /* Name not unique on network */
+#define EBADFD 77 /* File descriptor in bad state */
+#define EREMCHG 78 /* Remote address changed */
+#define ELIBACC 79 /* Can not access a needed shared library */
+#define ELIBBAD 80 /* Accessing a corrupted shared library */
+#define ELIBSCN 81 /* .lib section in a.out corrupted */
+#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
+#define ELIBEXEC 83 /* Cannot exec a shared library directly */
+#define EILSEQ 84 /* Illegal byte sequence */
+#define ERESTART 85 /* Interrupted system call should be restarted */
+#define ESTRPIPE 86 /* Streams pipe error */
+#define EUSERS 87 /* Too many users */
+#define ENOTSOCK 88 /* Socket operation on non-socket */
+#define EDESTADDRREQ 89 /* Destination address required */
+#define EMSGSIZE 90 /* Message too long */
+#define EPROTOTYPE 91 /* Protocol wrong type for socket */
+#define ENOPROTOOPT 92 /* Protocol not available */
+#define EPROTONOSUPPORT 93 /* Protocol not supported */
+#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
+#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
+#define EPFNOSUPPORT 96 /* Protocol family not supported */
+#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
+#define EADDRINUSE 98 /* Address already in use */
+#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
+#define ENETDOWN 100 /* Network is down */
+#define ENETUNREACH 101 /* Network is unreachable */
+#define ENETRESET 102 /* Network dropped connection because of reset */
+#define ECONNABORTED 103 /* Software caused connection abort */
+#define ECONNRESET 104 /* Connection reset by peer */
+#define ENOBUFS 105 /* No buffer space available */
+#define EISCONN 106 /* Transport endpoint is already connected */
+#define ENOTCONN 107 /* Transport endpoint is not connected */
+#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
+#define ETOOMANYREFS 109 /* Too many references: cannot splice */
+#define ETIMEDOUT 110 /* Connection timed out */
+#define ECONNREFUSED 111 /* Connection refused */
+#define EHOSTDOWN 112 /* Host is down */
+#define EHOSTUNREACH 113 /* No route to host */
+#define EALREADY 114 /* Operation already in progress */
+#define EINPROGRESS 115 /* Operation now in progress */
+#define ESTALE 116 /* Stale NFS file handle */
+#define EUCLEAN 117 /* Structure needs cleaning */
+#define ENOTNAM 118 /* Not a XENIX named type file */
+#define ENAVAIL 119 /* No XENIX semaphores available */
+#define EISNAM 120 /* Is a named type file */
+#define EREMOTEIO 121 /* Remote I/O error */
+#define EDQUOT 122 /* Quota exceeded */
+
+#define ENOMEDIUM 123 /* No medium found */
+#define EMEDIUMTYPE 124 /* Wrong medium type */
+#define ECANCELED 125 /* Operation Canceled */
+#define ENOKEY 126 /* Required key not available */
+#define EKEYEXPIRED 127 /* Key has expired */
+#define EKEYREVOKED 128 /* Key has been revoked */
+#define EKEYREJECTED 129 /* Key was rejected by service */
+
+/* for robust mutexes */
+#define EOWNERDEAD 130 /* Owner died */
+#define ENOTRECOVERABLE 131 /* State not recoverable */
+
+#endif
diff --git a/doc/errno.list.macosx.txt b/doc/errno.list.macosx.txt
new file mode 100644
index 0000000..728753a
--- /dev/null
+++ b/doc/errno.list.macosx.txt
@@ -0,0 +1,1513 @@
+/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef APR_ERRNO_H
+#define APR_ERRNO_H
+
+/**
+ * @file apr_errno.h
+ * @brief APR Error Codes
+ */
+
+#include "apr.h"
+
+#if APR_HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @defgroup apr_errno Error Codes
+ * @ingroup APR
+ * @{
+ */
+
+/**
+ * Type for specifying an error or status code.
+ */
+typedef int apr_status_t;
+
+/**
+ * Return a human readable string describing the specified error.
+ * @param statcode The error code the get a string for.
+ * @param buf A buffer to hold the error string.
+ * @param bufsize Size of the buffer to hold the string.
+ */
+APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf,
+ apr_size_t bufsize);
+
+#if defined(DOXYGEN)
+/**
+ * @def APR_FROM_OS_ERROR(os_err_type syserr)
+ * Fold a platform specific error into an apr_status_t code.
+ * @return apr_status_t
+ * @param e The platform os error code.
+ * @warning macro implementation; the syserr argument may be evaluated
+ * multiple times.
+ */
+#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
+
+/**
+ * @def APR_TO_OS_ERROR(apr_status_t statcode)
+ * @return os_err_type
+ * Fold an apr_status_t code back to the native platform defined error.
+ * @param e The apr_status_t folded platform os error code.
+ * @warning macro implementation; the statcode argument may be evaluated
+ * multiple times. If the statcode was not created by apr_get_os_error
+ * or APR_FROM_OS_ERROR, the results are undefined.
+ */
+#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
+
+/** @def apr_get_os_error()
+ * @return apr_status_t the last platform error, folded into apr_status_t, on most platforms
+ * @remark This retrieves errno, or calls a GetLastError() style function, and
+ * folds it with APR_FROM_OS_ERROR. Some platforms (such as OS2) have no
+ * such mechanism, so this call may be unsupported. Do NOT use this
+ * call for socket errors from socket, send, recv etc!
+ */
+
+/** @def apr_set_os_error(e)
+ * Reset the last platform error, unfolded from an apr_status_t, on some platforms
+ * @param e The OS error folded in a prior call to APR_FROM_OS_ERROR()
+ * @warning This is a macro implementation; the statcode argument may be evaluated
+ * multiple times. If the statcode was not created by apr_get_os_error
+ * or APR_FROM_OS_ERROR, the results are undefined. This macro sets
+ * errno, or calls a SetLastError() style function, unfolding statcode
+ * with APR_TO_OS_ERROR. Some platforms (such as OS2) have no such
+ * mechanism, so this call may be unsupported.
+ */
+
+/** @def apr_get_netos_error()
+ * Return the last socket error, folded into apr_status_t, on all platforms
+ * @remark This retrieves errno or calls a GetLastSocketError() style function,
+ * and folds it with APR_FROM_OS_ERROR.
+ */
+
+/** @def apr_set_netos_error(e)
+ * Reset the last socket error, unfolded from an apr_status_t
+ * @param e The socket error folded in a prior call to APR_FROM_OS_ERROR()
+ * @warning This is a macro implementation; the statcode argument may be evaluated
+ * multiple times. If the statcode was not created by apr_get_os_error
+ * or APR_FROM_OS_ERROR, the results are undefined. This macro sets
+ * errno, or calls a WSASetLastError() style function, unfolding
+ * socketcode with APR_TO_OS_ERROR.
+ */
+
+#endif /* defined(DOXYGEN) */
+
+/**
+ * APR_OS_START_ERROR is where the APR specific error values start.
+ */
+#define APR_OS_START_ERROR 20000
+/**
+ * APR_OS_ERRSPACE_SIZE is the maximum number of errors you can fit
+ * into one of the error/status ranges below -- except for
+ * APR_OS_START_USERERR, which see.
+ */
+#define APR_OS_ERRSPACE_SIZE 50000
+/**
+ * APR_OS_START_STATUS is where the APR specific status codes start.
+ */
+#define APR_OS_START_STATUS (APR_OS_START_ERROR + APR_OS_ERRSPACE_SIZE)
+/**
+ * APR_OS_START_USERERR are reserved for applications that use APR that
+ * layer their own error codes along with APR's. Note that the
+ * error immediately following this one is set ten times farther
+ * away than usual, so that users of apr have a lot of room in
+ * which to declare custom error codes.
+ */
+#define APR_OS_START_USERERR (APR_OS_START_STATUS + APR_OS_ERRSPACE_SIZE)
+/**
+ * APR_OS_START_USEERR is obsolete, defined for compatibility only.
+ * Use APR_OS_START_USERERR instead.
+ */
+#define APR_OS_START_USEERR APR_OS_START_USERERR
+/**
+ * APR_OS_START_CANONERR is where APR versions of errno values are defined
+ * on systems which don't have the corresponding errno.
+ */
+#define APR_OS_START_CANONERR (APR_OS_START_USERERR \
+ + (APR_OS_ERRSPACE_SIZE * 10))
+/**
+ * APR_OS_START_EAIERR folds EAI_ error codes from getaddrinfo() into
+ * apr_status_t values.
+ */
+#define APR_OS_START_EAIERR (APR_OS_START_CANONERR + APR_OS_ERRSPACE_SIZE)
+/**
+ * APR_OS_START_SYSERR folds platform-specific system error values into
+ * apr_status_t values.
+ */
+#define APR_OS_START_SYSERR (APR_OS_START_EAIERR + APR_OS_ERRSPACE_SIZE)
+
+/** no error. */
+#define APR_SUCCESS 0
+
+/**
+ * @defgroup APR_Error APR Error Values
+ * <PRE>
+ * <b>APR ERROR VALUES</b>
+ * APR_ENOSTAT APR was unable to perform a stat on the file
+ * APR_ENOPOOL APR was not provided a pool with which to allocate memory
+ * APR_EBADDATE APR was given an invalid date
+ * APR_EINVALSOCK APR was given an invalid socket
+ * APR_ENOPROC APR was not given a process structure
+ * APR_ENOTIME APR was not given a time structure
+ * APR_ENODIR APR was not given a directory structure
+ * APR_ENOLOCK APR was not given a lock structure
+ * APR_ENOPOLL APR was not given a poll structure
+ * APR_ENOSOCKET APR was not given a socket
+ * APR_ENOTHREAD APR was not given a thread structure
+ * APR_ENOTHDKEY APR was not given a thread key structure
+ * APR_ENOSHMAVAIL There is no more shared memory available
+ * APR_EDSOOPEN APR was unable to open the dso object. For more
+ * information call apr_dso_error().
+ * APR_EGENERAL General failure (specific information not available)
+ * APR_EBADIP The specified IP address is invalid
+ * APR_EBADMASK The specified netmask is invalid
+ * APR_ESYMNOTFOUND Could not find the requested symbol
+ * </PRE>
+ *
+ * <PRE>
+ * <b>APR STATUS VALUES</b>
+ * APR_INCHILD Program is currently executing in the child
+ * APR_INPARENT Program is currently executing in the parent
+ * APR_DETACH The thread is detached
+ * APR_NOTDETACH The thread is not detached
+ * APR_CHILD_DONE The child has finished executing
+ * APR_CHILD_NOTDONE The child has not finished executing
+ * APR_TIMEUP The operation did not finish before the timeout
+ * APR_INCOMPLETE The operation was incomplete although some processing
+ * was performed and the results are partially valid
+ * APR_BADCH Getopt found an option not in the option string
+ * APR_BADARG Getopt found an option that is missing an argument
+ * and an argument was specified in the option string
+ * APR_EOF APR has encountered the end of the file
+ * APR_NOTFOUND APR was unable to find the socket in the poll structure
+ * APR_ANONYMOUS APR is using anonymous shared memory
+ * APR_FILEBASED APR is using a file name as the key to the shared memory
+ * APR_KEYBASED APR is using a shared key as the key to the shared memory
+ * APR_EINIT Ininitalizer value. If no option has been found, but
+ * the status variable requires a value, this should be used
+ * APR_ENOTIMPL The APR function has not been implemented on this
+ * platform, either because nobody has gotten to it yet,
+ * or the function is impossible on this platform.
+ * APR_EMISMATCH Two passwords do not match.
+ * APR_EABSOLUTE The given path was absolute.
+ * APR_ERELATIVE The given path was relative.
+ * APR_EINCOMPLETE The given path was neither relative nor absolute.
+ * APR_EABOVEROOT The given path was above the root path.
+ * APR_EBUSY The given lock was busy.
+ * APR_EPROC_UNKNOWN The given process wasn't recognized by APR
+ * </PRE>
+ * @{
+ */
+/** @see APR_STATUS_IS_ENOSTAT */
+#define APR_ENOSTAT (APR_OS_START_ERROR + 1)
+/** @see APR_STATUS_IS_ENOPOOL */
+#define APR_ENOPOOL (APR_OS_START_ERROR + 2)
+/* empty slot: +3 */
+/** @see APR_STATUS_IS_EBADDATE */
+#define APR_EBADDATE (APR_OS_START_ERROR + 4)
+/** @see APR_STATUS_IS_EINVALSOCK */
+#define APR_EINVALSOCK (APR_OS_START_ERROR + 5)
+/** @see APR_STATUS_IS_ENOPROC */
+#define APR_ENOPROC (APR_OS_START_ERROR + 6)
+/** @see APR_STATUS_IS_ENOTIME */
+#define APR_ENOTIME (APR_OS_START_ERROR + 7)
+/** @see APR_STATUS_IS_ENODIR */
+#define APR_ENODIR (APR_OS_START_ERROR + 8)
+/** @see APR_STATUS_IS_ENOLOCK */
+#define APR_ENOLOCK (APR_OS_START_ERROR + 9)
+/** @see APR_STATUS_IS_ENOPOLL */
+#define APR_ENOPOLL (APR_OS_START_ERROR + 10)
+/** @see APR_STATUS_IS_ENOSOCKET */
+#define APR_ENOSOCKET (APR_OS_START_ERROR + 11)
+/** @see APR_STATUS_IS_ENOTHREAD */
+#define APR_ENOTHREAD (APR_OS_START_ERROR + 12)
+/** @see APR_STATUS_IS_ENOTHDKEY */
+#define APR_ENOTHDKEY (APR_OS_START_ERROR + 13)
+/** @see APR_STATUS_IS_EGENERAL */
+#define APR_EGENERAL (APR_OS_START_ERROR + 14)
+/** @see APR_STATUS_IS_ENOSHMAVAIL */
+#define APR_ENOSHMAVAIL (APR_OS_START_ERROR + 15)
+/** @see APR_STATUS_IS_EBADIP */
+#define APR_EBADIP (APR_OS_START_ERROR + 16)
+/** @see APR_STATUS_IS_EBADMASK */
+#define APR_EBADMASK (APR_OS_START_ERROR + 17)
+/* empty slot: +18 */
+/** @see APR_STATUS_IS_EDSOPEN */
+#define APR_EDSOOPEN (APR_OS_START_ERROR + 19)
+/** @see APR_STATUS_IS_EABSOLUTE */
+#define APR_EABSOLUTE (APR_OS_START_ERROR + 20)
+/** @see APR_STATUS_IS_ERELATIVE */
+#define APR_ERELATIVE (APR_OS_START_ERROR + 21)
+/** @see APR_STATUS_IS_EINCOMPLETE */
+#define APR_EINCOMPLETE (APR_OS_START_ERROR + 22)
+/** @see APR_STATUS_IS_EABOVEROOT */
+#define APR_EABOVEROOT (APR_OS_START_ERROR + 23)
+/** @see APR_STATUS_IS_EBADPATH */
+#define APR_EBADPATH (APR_OS_START_ERROR + 24)
+/** @see APR_STATUS_IS_EPATHWILD */
+#define APR_EPATHWILD (APR_OS_START_ERROR + 25)
+/** @see APR_STATUS_IS_ESYMNOTFOUND */
+#define APR_ESYMNOTFOUND (APR_OS_START_ERROR + 26)
+/** @see APR_STATUS_IS_EPROC_UNKNOWN */
+#define APR_EPROC_UNKNOWN (APR_OS_START_ERROR + 27)
+/** @see APR_STATUS_IS_ENOTENOUGHENTROPY */
+#define APR_ENOTENOUGHENTROPY (APR_OS_START_ERROR + 28)
+/** @} */
+
+/**
+ * @defgroup APR_STATUS_IS Status Value Tests
+ * @warning For any particular error condition, more than one of these tests
+ * may match. This is because platform-specific error codes may not
+ * always match the semantics of the POSIX codes these tests (and the
+ * corresponding APR error codes) are named after. A notable example
+ * are the APR_STATUS_IS_ENOENT and APR_STATUS_IS_ENOTDIR tests on
+ * Win32 platforms. The programmer should always be aware of this and
+ * adjust the order of the tests accordingly.
+ * @{
+ */
+/**
+ * APR was unable to perform a stat on the file
+ * @warning always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_ENOSTAT(s) ((s) == APR_ENOSTAT)
+/**
+ * APR was not provided a pool with which to allocate memory
+ * @warning always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_ENOPOOL(s) ((s) == APR_ENOPOOL)
+/** APR was given an invalid date */
+#define APR_STATUS_IS_EBADDATE(s) ((s) == APR_EBADDATE)
+/** APR was given an invalid socket */
+#define APR_STATUS_IS_EINVALSOCK(s) ((s) == APR_EINVALSOCK)
+/** APR was not given a process structure */
+#define APR_STATUS_IS_ENOPROC(s) ((s) == APR_ENOPROC)
+/** APR was not given a time structure */
+#define APR_STATUS_IS_ENOTIME(s) ((s) == APR_ENOTIME)
+/** APR was not given a directory structure */
+#define APR_STATUS_IS_ENODIR(s) ((s) == APR_ENODIR)
+/** APR was not given a lock structure */
+#define APR_STATUS_IS_ENOLOCK(s) ((s) == APR_ENOLOCK)
+/** APR was not given a poll structure */
+#define APR_STATUS_IS_ENOPOLL(s) ((s) == APR_ENOPOLL)
+/** APR was not given a socket */
+#define APR_STATUS_IS_ENOSOCKET(s) ((s) == APR_ENOSOCKET)
+/** APR was not given a thread structure */
+#define APR_STATUS_IS_ENOTHREAD(s) ((s) == APR_ENOTHREAD)
+/** APR was not given a thread key structure */
+#define APR_STATUS_IS_ENOTHDKEY(s) ((s) == APR_ENOTHDKEY)
+/** Generic Error which can not be put into another spot */
+#define APR_STATUS_IS_EGENERAL(s) ((s) == APR_EGENERAL)
+/** There is no more shared memory available */
+#define APR_STATUS_IS_ENOSHMAVAIL(s) ((s) == APR_ENOSHMAVAIL)
+/** The specified IP address is invalid */
+#define APR_STATUS_IS_EBADIP(s) ((s) == APR_EBADIP)
+/** The specified netmask is invalid */
+#define APR_STATUS_IS_EBADMASK(s) ((s) == APR_EBADMASK)
+/* empty slot: +18 */
+/**
+ * APR was unable to open the dso object.
+ * For more information call apr_dso_error().
+ */
+#if defined(WIN32)
+#define APR_STATUS_IS_EDSOOPEN(s) ((s) == APR_EDSOOPEN \
+ || APR_TO_OS_ERROR(s) == ERROR_MOD_NOT_FOUND)
+#else
+#define APR_STATUS_IS_EDSOOPEN(s) ((s) == APR_EDSOOPEN)
+#endif
+/** The given path was absolute. */
+#define APR_STATUS_IS_EABSOLUTE(s) ((s) == APR_EABSOLUTE)
+/** The given path was relative. */
+#define APR_STATUS_IS_ERELATIVE(s) ((s) == APR_ERELATIVE)
+/** The given path was neither relative nor absolute. */
+#define APR_STATUS_IS_EINCOMPLETE(s) ((s) == APR_EINCOMPLETE)
+/** The given path was above the root path. */
+#define APR_STATUS_IS_EABOVEROOT(s) ((s) == APR_EABOVEROOT)
+/** The given path was bad. */
+#define APR_STATUS_IS_EBADPATH(s) ((s) == APR_EBADPATH)
+/** The given path contained wildcards. */
+#define APR_STATUS_IS_EPATHWILD(s) ((s) == APR_EPATHWILD)
+/** Could not find the requested symbol.
+ * For more information call apr_dso_error().
+ */
+#if defined(WIN32)
+#define APR_STATUS_IS_ESYMNOTFOUND(s) ((s) == APR_ESYMNOTFOUND \
+ || APR_TO_OS_ERROR(s) == ERROR_PROC_NOT_FOUND)
+#else
+#define APR_STATUS_IS_ESYMNOTFOUND(s) ((s) == APR_ESYMNOTFOUND)
+#endif
+/** The given process was not recognized by APR. */
+#define APR_STATUS_IS_EPROC_UNKNOWN(s) ((s) == APR_EPROC_UNKNOWN)
+
+/** APR could not gather enough entropy to continue. */
+#define APR_STATUS_IS_ENOTENOUGHENTROPY(s) ((s) == APR_ENOTENOUGHENTROPY)
+
+/** @} */
+
+/**
+ * @addtogroup APR_Error
+ * @{
+ */
+/** @see APR_STATUS_IS_INCHILD */
+#define APR_INCHILD (APR_OS_START_STATUS + 1)
+/** @see APR_STATUS_IS_INPARENT */
+#define APR_INPARENT (APR_OS_START_STATUS + 2)
+/** @see APR_STATUS_IS_DETACH */
+#define APR_DETACH (APR_OS_START_STATUS + 3)
+/** @see APR_STATUS_IS_NOTDETACH */
+#define APR_NOTDETACH (APR_OS_START_STATUS + 4)
+/** @see APR_STATUS_IS_CHILD_DONE */
+#define APR_CHILD_DONE (APR_OS_START_STATUS + 5)
+/** @see APR_STATUS_IS_CHILD_NOTDONE */
+#define APR_CHILD_NOTDONE (APR_OS_START_STATUS + 6)
+/** @see APR_STATUS_IS_TIMEUP */
+#define APR_TIMEUP (APR_OS_START_STATUS + 7)
+/** @see APR_STATUS_IS_INCOMPLETE */
+#define APR_INCOMPLETE (APR_OS_START_STATUS + 8)
+/* empty slot: +9 */
+/* empty slot: +10 */
+/* empty slot: +11 */
+/** @see APR_STATUS_IS_BADCH */
+#define APR_BADCH (APR_OS_START_STATUS + 12)
+/** @see APR_STATUS_IS_BADARG */
+#define APR_BADARG (APR_OS_START_STATUS + 13)
+/** @see APR_STATUS_IS_EOF */
+#define APR_EOF (APR_OS_START_STATUS + 14)
+/** @see APR_STATUS_IS_NOTFOUND */
+#define APR_NOTFOUND (APR_OS_START_STATUS + 15)
+/* empty slot: +16 */
+/* empty slot: +17 */
+/* empty slot: +18 */
+/** @see APR_STATUS_IS_ANONYMOUS */
+#define APR_ANONYMOUS (APR_OS_START_STATUS + 19)
+/** @see APR_STATUS_IS_FILEBASED */
+#define APR_FILEBASED (APR_OS_START_STATUS + 20)
+/** @see APR_STATUS_IS_KEYBASED */
+#define APR_KEYBASED (APR_OS_START_STATUS + 21)
+/** @see APR_STATUS_IS_EINIT */
+#define APR_EINIT (APR_OS_START_STATUS + 22)
+/** @see APR_STATUS_IS_ENOTIMPL */
+#define APR_ENOTIMPL (APR_OS_START_STATUS + 23)
+/** @see APR_STATUS_IS_EMISMATCH */
+#define APR_EMISMATCH (APR_OS_START_STATUS + 24)
+/** @see APR_STATUS_IS_EBUSY */
+#define APR_EBUSY (APR_OS_START_STATUS + 25)
+/** @} */
+
+/**
+ * @addtogroup APR_STATUS_IS
+ * @{
+ */
+/**
+ * Program is currently executing in the child
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code */
+#define APR_STATUS_IS_INCHILD(s) ((s) == APR_INCHILD)
+/**
+ * Program is currently executing in the parent
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_INPARENT(s) ((s) == APR_INPARENT)
+/**
+ * The thread is detached
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_DETACH(s) ((s) == APR_DETACH)
+/**
+ * The thread is not detached
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_NOTDETACH(s) ((s) == APR_NOTDETACH)
+/**
+ * The child has finished executing
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_CHILD_DONE(s) ((s) == APR_CHILD_DONE)
+/**
+ * The child has not finished executing
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_CHILD_NOTDONE(s) ((s) == APR_CHILD_NOTDONE)
+/**
+ * The operation did not finish before the timeout
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP)
+/**
+ * The operation was incomplete although some processing was performed
+ * and the results are partially valid.
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_INCOMPLETE(s) ((s) == APR_INCOMPLETE)
+/* empty slot: +9 */
+/* empty slot: +10 */
+/* empty slot: +11 */
+/**
+ * Getopt found an option not in the option string
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_BADCH(s) ((s) == APR_BADCH)
+/**
+ * Getopt found an option not in the option string and an argument was
+ * specified in the option string
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_BADARG(s) ((s) == APR_BADARG)
+/**
+ * APR has encountered the end of the file
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_EOF(s) ((s) == APR_EOF)
+/**
+ * APR was unable to find the socket in the poll structure
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_NOTFOUND(s) ((s) == APR_NOTFOUND)
+/* empty slot: +16 */
+/* empty slot: +17 */
+/* empty slot: +18 */
+/**
+ * APR is using anonymous shared memory
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_ANONYMOUS(s) ((s) == APR_ANONYMOUS)
+/**
+ * APR is using a file name as the key to the shared memory
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_FILEBASED(s) ((s) == APR_FILEBASED)
+/**
+ * APR is using a shared key as the key to the shared memory
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_KEYBASED(s) ((s) == APR_KEYBASED)
+/**
+ * Ininitalizer value. If no option has been found, but
+ * the status variable requires a value, this should be used
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_EINIT(s) ((s) == APR_EINIT)
+/**
+ * The APR function has not been implemented on this
+ * platform, either because nobody has gotten to it yet,
+ * or the function is impossible on this platform.
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_ENOTIMPL(s) ((s) == APR_ENOTIMPL)
+/**
+ * Two passwords do not match.
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_EMISMATCH(s) ((s) == APR_EMISMATCH)
+/**
+ * The given lock was busy
+ * @warning always use this test, as platform-specific variances may meet this
+ * more than one error code
+ */
+#define APR_STATUS_IS_EBUSY(s) ((s) == APR_EBUSY)
+
+/** @} */
+
+/**
+ * @addtogroup APR_Error APR Error Values
+ * @{
+ */
+/* APR CANONICAL ERROR VALUES */
+/** @see APR_STATUS_IS_EACCES */
+#ifdef EACCES
+#define APR_EACCES EACCES
+#else
+#define APR_EACCES (APR_OS_START_CANONERR + 1)
+#endif
+
+/** @see APR_STATUS_IS_EXIST */
+#ifdef EEXIST
+#define APR_EEXIST EEXIST
+#else
+#define APR_EEXIST (APR_OS_START_CANONERR + 2)
+#endif
+
+/** @see APR_STATUS_IS_ENAMETOOLONG */
+#ifdef ENAMETOOLONG
+#define APR_ENAMETOOLONG ENAMETOOLONG
+#else
+#define APR_ENAMETOOLONG (APR_OS_START_CANONERR + 3)
+#endif
+
+/** @see APR_STATUS_IS_ENOENT */
+#ifdef ENOENT
+#define APR_ENOENT ENOENT
+#else
+#define APR_ENOENT (APR_OS_START_CANONERR + 4)
+#endif
+
+/** @see APR_STATUS_IS_ENOTDIR */
+#ifdef ENOTDIR
+#define APR_ENOTDIR ENOTDIR
+#else
+#define APR_ENOTDIR (APR_OS_START_CANONERR + 5)
+#endif
+
+/** @see APR_STATUS_IS_ENOSPC */
+#ifdef ENOSPC
+#define APR_ENOSPC ENOSPC
+#else
+#define APR_ENOSPC (APR_OS_START_CANONERR + 6)
+#endif
+
+/** @see APR_STATUS_IS_ENOMEM */
+#ifdef ENOMEM
+#define APR_ENOMEM ENOMEM
+#else
+#define APR_ENOMEM (APR_OS_START_CANONERR + 7)
+#endif
+
+/** @see APR_STATUS_IS_EMFILE */
+#ifdef EMFILE
+#define APR_EMFILE EMFILE
+#else
+#define APR_EMFILE (APR_OS_START_CANONERR + 8)
+#endif
+
+/** @see APR_STATUS_IS_ENFILE */
+#ifdef ENFILE
+#define APR_ENFILE ENFILE
+#else
+#define APR_ENFILE (APR_OS_START_CANONERR + 9)
+#endif
+
+/** @see APR_STATUS_IS_EBADF */
+#ifdef EBADF
+#define APR_EBADF EBADF
+#else
+#define APR_EBADF (APR_OS_START_CANONERR + 10)
+#endif
+
+/** @see APR_STATUS_IS_EINVAL */
+#ifdef EINVAL
+#define APR_EINVAL EINVAL
+#else
+#define APR_EINVAL (APR_OS_START_CANONERR + 11)
+#endif
+
+/** @see APR_STATUS_IS_ESPIPE */
+#ifdef ESPIPE
+#define APR_ESPIPE ESPIPE
+#else
+#define APR_ESPIPE (APR_OS_START_CANONERR + 12)
+#endif
+
+/**
+ * @see APR_STATUS_IS_EAGAIN
+ * @warning use APR_STATUS_IS_EAGAIN instead of just testing this value
+ */
+#ifdef EAGAIN
+#define APR_EAGAIN EAGAIN
+#elif defined(EWOULDBLOCK)
+#define APR_EAGAIN EWOULDBLOCK
+#else
+#define APR_EAGAIN (APR_OS_START_CANONERR + 13)
+#endif
+
+/** @see APR_STATUS_IS_EINTR */
+#ifdef EINTR
+#define APR_EINTR EINTR
+#else
+#define APR_EINTR (APR_OS_START_CANONERR + 14)
+#endif
+
+/** @see APR_STATUS_IS_ENOTSOCK */
+#ifdef ENOTSOCK
+#define APR_ENOTSOCK ENOTSOCK
+#else
+#define APR_ENOTSOCK (APR_OS_START_CANONERR + 15)
+#endif
+
+/** @see APR_STATUS_IS_ECONNREFUSED */
+#ifdef ECONNREFUSED
+#define APR_ECONNREFUSED ECONNREFUSED
+#else
+#define APR_ECONNREFUSED (APR_OS_START_CANONERR + 16)
+#endif
+
+/** @see APR_STATUS_IS_EINPROGRESS */
+#ifdef EINPROGRESS
+#define APR_EINPROGRESS EINPROGRESS
+#else
+#define APR_EINPROGRESS (APR_OS_START_CANONERR + 17)
+#endif
+
+/**
+ * @see APR_STATUS_IS_ECONNABORTED
+ * @warning use APR_STATUS_IS_ECONNABORTED instead of just testing this value
+ */
+
+#ifdef ECONNABORTED
+#define APR_ECONNABORTED ECONNABORTED
+#else
+#define APR_ECONNABORTED (APR_OS_START_CANONERR + 18)
+#endif
+
+/** @see APR_STATUS_IS_ECONNRESET */
+#ifdef ECONNRESET
+#define APR_ECONNRESET ECONNRESET
+#else
+#define APR_ECONNRESET (APR_OS_START_CANONERR + 19)
+#endif
+
+/** @see APR_STATUS_IS_ETIMEDOUT
+ * @deprecated */
+#ifdef ETIMEDOUT
+#define APR_ETIMEDOUT ETIMEDOUT
+#else
+#define APR_ETIMEDOUT (APR_OS_START_CANONERR + 20)
+#endif
+
+/** @see APR_STATUS_IS_EHOSTUNREACH */
+#ifdef EHOSTUNREACH
+#define APR_EHOSTUNREACH EHOSTUNREACH
+#else
+#define APR_EHOSTUNREACH (APR_OS_START_CANONERR + 21)
+#endif
+
+/** @see APR_STATUS_IS_ENETUNREACH */
+#ifdef ENETUNREACH
+#define APR_ENETUNREACH ENETUNREACH
+#else
+#define APR_ENETUNREACH (APR_OS_START_CANONERR + 22)
+#endif
+
+/** @see APR_STATUS_IS_EFTYPE */
+#ifdef EFTYPE
+#define APR_EFTYPE EFTYPE
+#else
+#define APR_EFTYPE (APR_OS_START_CANONERR + 23)
+#endif
+
+/** @see APR_STATUS_IS_EPIPE */
+#ifdef EPIPE
+#define APR_EPIPE EPIPE
+#else
+#define APR_EPIPE (APR_OS_START_CANONERR + 24)
+#endif
+
+/** @see APR_STATUS_IS_EXDEV */
+#ifdef EXDEV
+#define APR_EXDEV EXDEV
+#else
+#define APR_EXDEV (APR_OS_START_CANONERR + 25)
+#endif
+
+/** @see APR_STATUS_IS_ENOTEMPTY */
+#ifdef ENOTEMPTY
+#define APR_ENOTEMPTY ENOTEMPTY
+#else
+#define APR_ENOTEMPTY (APR_OS_START_CANONERR + 26)
+#endif
+
+/** @} */
+
+#if defined(OS2) && !defined(DOXYGEN)
+
+#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
+#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
+
+#define INCL_DOSERRORS
+#define INCL_DOS
+
+/* Leave these undefined.
+ * OS2 doesn't rely on the errno concept.
+ * The API calls always return a result codes which
+ * should be filtered through APR_FROM_OS_ERROR().
+ *
+ * #define apr_get_os_error() (APR_FROM_OS_ERROR(GetLastError()))
+ * #define apr_set_os_error(e) (SetLastError(APR_TO_OS_ERROR(e)))
+ */
+
+/* A special case, only socket calls require this;
+ */
+#define apr_get_netos_error() (APR_FROM_OS_ERROR(errno))
+#define apr_set_netos_error(e) (errno = APR_TO_OS_ERROR(e))
+
+/* And this needs to be greped away for good:
+ */
+#define APR_OS2_STATUS(e) (APR_FROM_OS_ERROR(e))
+
+/* These can't sit in a private header, so in spite of the extra size,
+ * they need to be made available here.
+ */
+#define SOCBASEERR 10000
+#define SOCEPERM (SOCBASEERR+1) /* Not owner */
+#define SOCESRCH (SOCBASEERR+3) /* No such process */
+#define SOCEINTR (SOCBASEERR+4) /* Interrupted system call */
+#define SOCENXIO (SOCBASEERR+6) /* No such device or address */
+#define SOCEBADF (SOCBASEERR+9) /* Bad file number */
+#define SOCEACCES (SOCBASEERR+13) /* Permission denied */
+#define SOCEFAULT (SOCBASEERR+14) /* Bad address */
+#define SOCEINVAL (SOCBASEERR+22) /* Invalid argument */
+#define SOCEMFILE (SOCBASEERR+24) /* Too many open files */
+#define SOCEPIPE (SOCBASEERR+32) /* Broken pipe */
+#define SOCEOS2ERR (SOCBASEERR+100) /* OS/2 Error */
+#define SOCEWOULDBLOCK (SOCBASEERR+35) /* Operation would block */
+#define SOCEINPROGRESS (SOCBASEERR+36) /* Operation now in progress */
+#define SOCEALREADY (SOCBASEERR+37) /* Operation already in progress */
+#define SOCENOTSOCK (SOCBASEERR+38) /* Socket operation on non-socket */
+#define SOCEDESTADDRREQ (SOCBASEERR+39) /* Destination address required */
+#define SOCEMSGSIZE (SOCBASEERR+40) /* Message too long */
+#define SOCEPROTOTYPE (SOCBASEERR+41) /* Protocol wrong type for socket */
+#define SOCENOPROTOOPT (SOCBASEERR+42) /* Protocol not available */
+#define SOCEPROTONOSUPPORT (SOCBASEERR+43) /* Protocol not supported */
+#define SOCESOCKTNOSUPPORT (SOCBASEERR+44) /* Socket type not supported */
+#define SOCEOPNOTSUPP (SOCBASEERR+45) /* Operation not supported on socket */
+#define SOCEPFNOSUPPORT (SOCBASEERR+46) /* Protocol family not supported */
+#define SOCEAFNOSUPPORT (SOCBASEERR+47) /* Address family not supported by protocol family */
+#define SOCEADDRINUSE (SOCBASEERR+48) /* Address already in use */
+#define SOCEADDRNOTAVAIL (SOCBASEERR+49) /* Can't assign requested address */
+#define SOCENETDOWN (SOCBASEERR+50) /* Network is down */
+#define SOCENETUNREACH (SOCBASEERR+51) /* Network is unreachable */
+#define SOCENETRESET (SOCBASEERR+52) /* Network dropped connection on reset */
+#define SOCECONNABORTED (SOCBASEERR+53) /* Software caused connection abort */
+#define SOCECONNRESET (SOCBASEERR+54) /* Connection reset by peer */
+#define SOCENOBUFS (SOCBASEERR+55) /* No buffer space available */
+#define SOCEISCONN (SOCBASEERR+56) /* Socket is already connected */
+#define SOCENOTCONN (SOCBASEERR+57) /* Socket is not connected */
+#define SOCESHUTDOWN (SOCBASEERR+58) /* Can't send after socket shutdown */
+#define SOCETOOMANYREFS (SOCBASEERR+59) /* Too many references: can't splice */
+#define SOCETIMEDOUT (SOCBASEERR+60) /* Connection timed out */
+#define SOCECONNREFUSED (SOCBASEERR+61) /* Connection refused */
+#define SOCELOOP (SOCBASEERR+62) /* Too many levels of symbolic links */
+#define SOCENAMETOOLONG (SOCBASEERR+63) /* File name too long */
+#define SOCEHOSTDOWN (SOCBASEERR+64) /* Host is down */
+#define SOCEHOSTUNREACH (SOCBASEERR+65) /* No route to host */
+#define SOCENOTEMPTY (SOCBASEERR+66) /* Directory not empty */
+
+/* APR CANONICAL ERROR TESTS */
+#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES \
+ || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \
+ || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION)
+#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST \
+ || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \
+ || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \
+ || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS \
+ || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED)
+#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG \
+ || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \
+ || (s) == APR_OS_START_SYSERR + SOCENAMETOOLONG)
+#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \
+ || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \
+ || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
+ || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES \
+ || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED)
+#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR)
+#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC \
+ || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL)
+#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM)
+#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE \
+ || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES)
+#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE)
+#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE)
+#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION)
+#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE \
+ || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
+#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \
+ || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \
+ || (s) == APR_OS_START_SYSERR + SOCEWOULDBLOCK \
+ || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION)
+#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \
+ || (s) == APR_OS_START_SYSERR + SOCEINTR)
+#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \
+ || (s) == APR_OS_START_SYSERR + SOCENOTSOCK)
+#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \
+ || (s) == APR_OS_START_SYSERR + SOCECONNREFUSED)
+#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \
+ || (s) == APR_OS_START_SYSERR + SOCEINPROGRESS)
+#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \
+ || (s) == APR_OS_START_SYSERR + SOCECONNABORTED)
+#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \
+ || (s) == APR_OS_START_SYSERR + SOCECONNRESET)
+/* XXX deprecated */
+#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \
+ || (s) == APR_OS_START_SYSERR + SOCETIMEDOUT)
+#undef APR_STATUS_IS_TIMEUP
+#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP \
+ || (s) == APR_OS_START_SYSERR + SOCETIMEDOUT)
+#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \
+ || (s) == APR_OS_START_SYSERR + SOCEHOSTUNREACH)
+#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \
+ || (s) == APR_OS_START_SYSERR + SOCENETUNREACH)
+#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE)
+#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE \
+ || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE \
+ || (s) == APR_OS_START_SYSERR + SOCEPIPE)
+#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV \
+ || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE)
+#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY \
+ || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY \
+ || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED)
+
+/*
+ Sorry, too tired to wrap this up for OS2... feel free to
+ fit the following into their best matches.
+
+ { ERROR_NO_SIGNAL_SENT, ESRCH },
+ { SOCEALREADY, EALREADY },
+ { SOCEDESTADDRREQ, EDESTADDRREQ },
+ { SOCEMSGSIZE, EMSGSIZE },
+ { SOCEPROTOTYPE, EPROTOTYPE },
+ { SOCENOPROTOOPT, ENOPROTOOPT },
+ { SOCEPROTONOSUPPORT, EPROTONOSUPPORT },
+ { SOCESOCKTNOSUPPORT, ESOCKTNOSUPPORT },
+ { SOCEOPNOTSUPP, EOPNOTSUPP },
+ { SOCEPFNOSUPPORT, EPFNOSUPPORT },
+ { SOCEAFNOSUPPORT, EAFNOSUPPORT },
+ { SOCEADDRINUSE, EADDRINUSE },
+ { SOCEADDRNOTAVAIL, EADDRNOTAVAIL },
+ { SOCENETDOWN, ENETDOWN },
+ { SOCENETRESET, ENETRESET },
+ { SOCENOBUFS, ENOBUFS },
+ { SOCEISCONN, EISCONN },
+ { SOCENOTCONN, ENOTCONN },
+ { SOCESHUTDOWN, ESHUTDOWN },
+ { SOCETOOMANYREFS, ETOOMANYREFS },
+ { SOCELOOP, ELOOP },
+ { SOCEHOSTDOWN, EHOSTDOWN },
+ { SOCENOTEMPTY, ENOTEMPTY },
+ { SOCEPIPE, EPIPE }
+*/
+
+#elif defined(WIN32) && !defined(DOXYGEN) /* !defined(OS2) */
+
+#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
+#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
+
+#define apr_get_os_error() (APR_FROM_OS_ERROR(GetLastError()))
+#define apr_set_os_error(e) (SetLastError(APR_TO_OS_ERROR(e)))
+
+/* A special case, only socket calls require this:
+ */
+#define apr_get_netos_error() (APR_FROM_OS_ERROR(WSAGetLastError()))
+#define apr_set_netos_error(e) (WSASetLastError(APR_TO_OS_ERROR(e)))
+
+/* APR CANONICAL ERROR TESTS */
+#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES \
+ || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \
+ || (s) == APR_OS_START_SYSERR + ERROR_CANNOT_MAKE \
+ || (s) == APR_OS_START_SYSERR + ERROR_CURRENT_DIRECTORY \
+ || (s) == APR_OS_START_SYSERR + ERROR_DRIVE_LOCKED \
+ || (s) == APR_OS_START_SYSERR + ERROR_FAIL_I24 \
+ || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \
+ || (s) == APR_OS_START_SYSERR + ERROR_LOCK_FAILED \
+ || (s) == APR_OS_START_SYSERR + ERROR_NOT_LOCKED \
+ || (s) == APR_OS_START_SYSERR + ERROR_NETWORK_ACCESS_DENIED \
+ || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION)
+#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST \
+ || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \
+ || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS)
+#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG \
+ || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \
+ || (s) == APR_OS_START_SYSERR + WSAENAMETOOLONG)
+#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \
+ || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \
+ || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
+ || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \
+ || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES)
+#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR \
+ || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
+ || (s) == APR_OS_START_SYSERR + ERROR_BAD_NETPATH \
+ || (s) == APR_OS_START_SYSERR + ERROR_BAD_NET_NAME \
+ || (s) == APR_OS_START_SYSERR + ERROR_BAD_PATHNAME \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DRIVE)
+#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC \
+ || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL)
+#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM \
+ || (s) == APR_OS_START_SYSERR + ERROR_ARENA_TRASHED \
+ || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_MEMORY \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_BLOCK \
+ || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_QUOTA \
+ || (s) == APR_OS_START_SYSERR + ERROR_OUTOFMEMORY)
+#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE \
+ || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES)
+#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE)
+#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_TARGET_HANDLE)
+#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_ACCESS \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DATA \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \
+ || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
+#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE \
+ || (s) == APR_OS_START_SYSERR + ERROR_SEEK_ON_DEVICE \
+ || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
+#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \
+ || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \
+ || (s) == APR_OS_START_SYSERR + ERROR_NO_PROC_SLOTS \
+ || (s) == APR_OS_START_SYSERR + ERROR_NESTING_NOT_ALLOWED \
+ || (s) == APR_OS_START_SYSERR + ERROR_MAX_THRDS_REACHED \
+ || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \
+ || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK)
+#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \
+ || (s) == APR_OS_START_SYSERR + WSAEINTR)
+#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \
+ || (s) == APR_OS_START_SYSERR + WSAENOTSOCK)
+#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \
+ || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED)
+#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \
+ || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS)
+#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \
+ || (s) == APR_OS_START_SYSERR + WSAECONNABORTED)
+#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \
+ || (s) == APR_OS_START_SYSERR + ERROR_NETNAME_DELETED \
+ || (s) == APR_OS_START_SYSERR + WSAECONNRESET)
+/* XXX deprecated */
+#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \
+ || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
+ || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
+#undef APR_STATUS_IS_TIMEUP
+#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP \
+ || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
+ || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
+#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \
+ || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH)
+#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \
+ || (s) == APR_OS_START_SYSERR + WSAENETUNREACH)
+#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE \
+ || (s) == APR_OS_START_SYSERR + ERROR_EXE_MACHINE_TYPE_MISMATCH \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DLL \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_MODULETYPE \
+ || (s) == APR_OS_START_SYSERR + ERROR_BAD_EXE_FORMAT \
+ || (s) == APR_OS_START_SYSERR + ERROR_INVALID_EXE_SIGNATURE \
+ || (s) == APR_OS_START_SYSERR + ERROR_FILE_CORRUPT \
+ || (s) == APR_OS_START_SYSERR + ERROR_BAD_FORMAT)
+#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE \
+ || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE)
+#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV \
+ || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE)
+#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY \
+ || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY)
+
+#elif defined(NETWARE) && defined(USE_WINSOCK) && !defined(DOXYGEN) /* !defined(OS2) && !defined(WIN32) */
+
+#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
+#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
+
+#define apr_get_os_error() (errno)
+#define apr_set_os_error(e) (errno = (e))
+
+/* A special case, only socket calls require this: */
+#define apr_get_netos_error() (APR_FROM_OS_ERROR(WSAGetLastError()))
+#define apr_set_netos_error(e) (WSASetLastError(APR_TO_OS_ERROR(e)))
+
+/* APR CANONICAL ERROR TESTS */
+#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES)
+#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST)
+#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG)
+#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT)
+#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR)
+#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC)
+#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM)
+#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE)
+#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE)
+#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF)
+#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL)
+#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE)
+
+#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \
+ || (s) == EWOULDBLOCK \
+ || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK)
+#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \
+ || (s) == APR_OS_START_SYSERR + WSAEINTR)
+#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \
+ || (s) == APR_OS_START_SYSERR + WSAENOTSOCK)
+#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \
+ || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED)
+#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \
+ || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS)
+#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \
+ || (s) == APR_OS_START_SYSERR + WSAECONNABORTED)
+#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \
+ || (s) == APR_OS_START_SYSERR + WSAECONNRESET)
+/* XXX deprecated */
+#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \
+ || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
+ || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
+#undef APR_STATUS_IS_TIMEUP
+#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP \
+ || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
+ || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
+#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \
+ || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH)
+#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \
+ || (s) == APR_OS_START_SYSERR + WSAENETUNREACH)
+#define APR_STATUS_IS_ENETDOWN(s) ((s) == APR_OS_START_SYSERR + WSAENETDOWN)
+#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE)
+#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE)
+#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV)
+#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY)
+
+#else /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */
+
+/*
+ * os error codes are clib error codes
+ */
+#define APR_FROM_OS_ERROR(e) (e)
+#define APR_TO_OS_ERROR(e) (e)
+
+#define apr_get_os_error() (errno)
+#define apr_set_os_error(e) (errno = (e))
+
+/* A special case, only socket calls require this:
+ */
+#define apr_get_netos_error() (errno)
+#define apr_set_netos_error(e) (errno = (e))
+
+/**
+ * @addtogroup APR_STATUS_IS
+ * @{
+ */
+
+/** permission denied */
+#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES)
+/** file exists */
+#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST)
+/** path name is too long */
+#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG)
+/**
+ * no such file or directory
+ * @remark
+ * EMVSCATLG can be returned by the automounter on z/OS for
+ * paths which do not exist.
+ */
+#ifdef EMVSCATLG
+#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \
+ || (s) == EMVSCATLG)
+#else
+#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT)
+#endif
+/** not a directory */
+#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR)
+/** no space left on device */
+#ifdef EDQUOT
+#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC \
+ || (s) == EDQUOT)
+#else
+#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC)
+#endif
+/** not enough memory */
+#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM)
+/** too many open files */
+#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE)
+/** file table overflow */
+#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE)
+/** bad file # */
+#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF)
+/** invalid argument */
+#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL)
+/** illegal seek */
+#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE)
+
+/** operation would block */
+#if !defined(EWOULDBLOCK) || !defined(EAGAIN)
+#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN)
+#elif (EWOULDBLOCK == EAGAIN)
+#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN)
+#else
+#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \
+ || (s) == EWOULDBLOCK)
+#endif
+
+/** interrupted system call */
+#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR)
+/** socket operation on a non-socket */
+#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK)
+/** Connection Refused */
+#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED)
+/** operation now in progress */
+#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS)
+
+/**
+ * Software caused connection abort
+ * @remark
+ * EPROTO on certain older kernels really means ECONNABORTED, so we need to
+ * ignore it for them. See discussion in new-httpd archives nh.9701 & nh.9603
+ *
+ * There is potentially a bug in Solaris 2.x x<6, and other boxes that
+ * implement tcp sockets in userland (i.e. on top of STREAMS). On these
+ * systems, EPROTO can actually result in a fatal loop. See PR#981 for
+ * example. It's hard to handle both uses of EPROTO.
+ */
+#ifdef EPROTO
+#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \
+ || (s) == EPROTO)
+#else
+#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED)
+#endif
+
+/** Connection Reset by peer */
+#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET)
+/** Operation timed out
+ * @deprecated */
+#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT)
+/** no route to host */
+#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH)
+/** network is unreachable */
+#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH)
+/** inappropiate file type or format */
+#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE)
+/** broken pipe */
+#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE)
+/** cross device link */
+#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV)
+/** Directory Not Empty */
+#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY || \
+ (s) == APR_EEXIST)
+/** @} */
+
+#endif /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ! APR_ERRNO_H */
+/*
+ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+#include <sys/errno.h>
+
+
+/*
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ */
+/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ * @(#)errno.h 8.5 (Berkeley) 1/21/94
+ */
+
+#ifndef _SYS_ERRNO_H_
+#define _SYS_ERRNO_H_
+
+#include <sys/cdefs.h>
+__BEGIN_DECLS
+extern int * __error(void);
+#define errno (*__error())
+__END_DECLS
+
+/*
+ * Error codes
+ */
+
+#define EPERM 1 /* Operation not permitted */
+#define ENOENT 2 /* No such file or directory */
+#define ESRCH 3 /* No such process */
+#define EINTR 4 /* Interrupted system call */
+#define EIO 5 /* Input/output error */
+#define ENXIO 6 /* Device not configured */
+#define E2BIG 7 /* Argument list too long */
+#define ENOEXEC 8 /* Exec format error */
+#define EBADF 9 /* Bad file descriptor */
+#define ECHILD 10 /* No child processes */
+#define EDEADLK 11 /* Resource deadlock avoided */
+ /* 11 was EAGAIN */
+#define ENOMEM 12 /* Cannot allocate memory */
+#define EACCES 13 /* Permission denied */
+#define EFAULT 14 /* Bad address */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#define ENOTBLK 15 /* Block device required */
+#endif
+#define EBUSY 16 /* Device / Resource busy */
+#define EEXIST 17 /* File exists */
+#define EXDEV 18 /* Cross-device link */
+#define ENODEV 19 /* Operation not supported by device */
+#define ENOTDIR 20 /* Not a directory */
+#define EISDIR 21 /* Is a directory */
+#define EINVAL 22 /* Invalid argument */
+#define ENFILE 23 /* Too many open files in system */
+#define EMFILE 24 /* Too many open files */
+#define ENOTTY 25 /* Inappropriate ioctl for device */
+#define ETXTBSY 26 /* Text file busy */
+#define EFBIG 27 /* File too large */
+#define ENOSPC 28 /* No space left on device */
+#define ESPIPE 29 /* Illegal seek */
+#define EROFS 30 /* Read-only file system */
+#define EMLINK 31 /* Too many links */
+#define EPIPE 32 /* Broken pipe */
+
+/* math software */
+#define EDOM 33 /* Numerical argument out of domain */
+#define ERANGE 34 /* Result too large */
+
+/* non-blocking and interrupt i/o */
+#define EAGAIN 35 /* Resource temporarily unavailable */
+#define EWOULDBLOCK EAGAIN /* Operation would block */
+#define EINPROGRESS 36 /* Operation now in progress */
+#define EALREADY 37 /* Operation already in progress */
+
+/* ipc/network software -- argument errors */
+#define ENOTSOCK 38 /* Socket operation on non-socket */
+#define EDESTADDRREQ 39 /* Destination address required */
+#define EMSGSIZE 40 /* Message too long */
+#define EPROTOTYPE 41 /* Protocol wrong type for socket */
+#define ENOPROTOOPT 42 /* Protocol not available */
+#define EPROTONOSUPPORT 43 /* Protocol not supported */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#define ESOCKTNOSUPPORT 44 /* Socket type not supported */
+#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
+#define ENOTSUP 45 /* Operation not supported */
+#if !__DARWIN_UNIX03 && !defined(KERNEL)
+/*
+ * This is the same for binary and source copmpatability, unless compiling
+ * the kernel itself, or compiling __DARWIN_UNIX03; if compiling for the
+ * kernel, the correct value will be returned. If compiling non-POSIX
+ * source, the kernel return value will be converted by a stub in libc, and
+ * if compiling source with __DARWIN_UNIX03, the conversion in libc is not
+ * done, and the caller gets the expected (discrete) value.
+ */
+#define EOPNOTSUPP ENOTSUP /* Operation not supported on socket */
+#endif /* !__DARWIN_UNIX03 && !KERNEL */
+
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#define EPFNOSUPPORT 46 /* Protocol family not supported */
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
+#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */
+#define EADDRINUSE 48 /* Address already in use */
+#define EADDRNOTAVAIL 49 /* Can't assign requested address */
+
+/* ipc/network software -- operational errors */
+#define ENETDOWN 50 /* Network is down */
+#define ENETUNREACH 51 /* Network is unreachable */
+#define ENETRESET 52 /* Network dropped connection on reset */
+#define ECONNABORTED 53 /* Software caused connection abort */
+#define ECONNRESET 54 /* Connection reset by peer */
+#define ENOBUFS 55 /* No buffer space available */
+#define EISCONN 56 /* Socket is already connected */
+#define ENOTCONN 57 /* Socket is not connected */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#define ESHUTDOWN 58 /* Can't send after socket shutdown */
+#define ETOOMANYREFS 59 /* Too many references: can't splice */
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
+#define ETIMEDOUT 60 /* Operation timed out */
+#define ECONNREFUSED 61 /* Connection refused */
+
+#define ELOOP 62 /* Too many levels of symbolic links */
+#define ENAMETOOLONG 63 /* File name too long */
+
+/* should be rearranged */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#define EHOSTDOWN 64 /* Host is down */
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
+#define EHOSTUNREACH 65 /* No route to host */
+#define ENOTEMPTY 66 /* Directory not empty */
+
+/* quotas & mush */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#define EPROCLIM 67 /* Too many processes */
+#define EUSERS 68 /* Too many users */
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
+#define EDQUOT 69 /* Disc quota exceeded */
+
+/* Network File System */
+#define ESTALE 70 /* Stale NFS file handle */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#define EREMOTE 71 /* Too many levels of remote in path */
+#define EBADRPC 72 /* RPC struct is bad */
+#define ERPCMISMATCH 73 /* RPC version wrong */
+#define EPROGUNAVAIL 74 /* RPC prog. not avail */
+#define EPROGMISMATCH 75 /* Program version wrong */
+#define EPROCUNAVAIL 76 /* Bad procedure for program */
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
+
+#define ENOLCK 77 /* No locks available */
+#define ENOSYS 78 /* Function not implemented */
+
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#define EFTYPE 79 /* Inappropriate file type or format */
+#define EAUTH 80 /* Authentication error */
+#define ENEEDAUTH 81 /* Need authenticator */
+
+/* Intelligent device errors */
+#define EPWROFF 82 /* Device power is off */
+#define EDEVERR 83 /* Device error, e.g. paper out */
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
+
+#define EOVERFLOW 84 /* Value too large to be stored in data type */
+
+/* Program loading errors */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#define EBADEXEC 85 /* Bad executable */
+#define EBADARCH 86 /* Bad CPU type in executable */
+#define ESHLIBVERS 87 /* Shared library version mismatch */
+#define EBADMACHO 88 /* Malformed Macho file */
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
+
+#define ECANCELED 89 /* Operation canceled */
+
+#define EIDRM 90 /* Identifier removed */
+#define ENOMSG 91 /* No message of desired type */
+#define EILSEQ 92 /* Illegal byte sequence */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#define ENOATTR 93 /* Attribute not found */
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
+
+#define EBADMSG 94 /* Bad message */
+#define EMULTIHOP 95 /* Reserved */
+#define ENODATA 96 /* No message available on STREAM */
+#define ENOLINK 97 /* Reserved */
+#define ENOSR 98 /* No STREAM resources */
+#define ENOSTR 99 /* Not a STREAM */
+#define EPROTO 100 /* Protocol error */
+#define ETIME 101 /* STREAM ioctl timeout */
+
+#if __DARWIN_UNIX03 || defined(KERNEL)
+/* This value is only discrete when compiling __DARWIN_UNIX03, or KERNEL */
+#define EOPNOTSUPP 102 /* Operation not supported on socket */
+#endif /* __DARWIN_UNIX03 || KERNEL */
+
+#define ENOPOLICY 103 /* No such policy registered */
+
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#define ELAST 103 /* Must be equal largest errno */
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
+
+#endif /* _SYS_ERRNO_H_ */
diff --git a/doc/errno.list.solaris.txt b/doc/errno.list.solaris.txt
new file mode 100644
index 0000000..23601e9
--- /dev/null
+++ b/doc/errno.list.solaris.txt
@@ -0,0 +1,206 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+/*
+ * University Copyright- Copyright (c) 1982, 1986, 1988
+ * The Regents of the University of California
+ * All Rights Reserved
+ *
+ * University Acknowledgment- Portions of this document are derived from
+ * software developed by the University of California, Berkeley, and its
+ * contributors.
+ */
+
+#ifndef _SYS_ERRNO_H
+#define _SYS_ERRNO_H
+
+#pragma ident "@(#)errno.h 1.22 05/06/08 SMI"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Error codes
+ */
+
+#define EPERM 1 /* Not super-user */
+#define ENOENT 2 /* No such file or directory */
+#define ESRCH 3 /* No such process */
+#define EINTR 4 /* interrupted system call */
+#define EIO 5 /* I/O error */
+#define ENXIO 6 /* No such device or address */
+#define E2BIG 7 /* Arg list too long */
+#define ENOEXEC 8 /* Exec format error */
+#define EBADF 9 /* Bad file number */
+#define ECHILD 10 /* No children */
+#define EAGAIN 11 /* Resource temporarily unavailable */
+#define ENOMEM 12 /* Not enough core */
+#define EACCES 13 /* Permission denied */
+#define EFAULT 14 /* Bad address */
+#define ENOTBLK 15 /* Block device required */
+#define EBUSY 16 /* Mount device busy */
+#define EEXIST 17 /* File exists */
+#define EXDEV 18 /* Cross-device link */
+#define ENODEV 19 /* No such device */
+#define ENOTDIR 20 /* Not a directory */
+#define EISDIR 21 /* Is a directory */
+#define EINVAL 22 /* Invalid argument */
+#define ENFILE 23 /* File table overflow */
+#define EMFILE 24 /* Too many open files */
+#define ENOTTY 25 /* Inappropriate ioctl for device */
+#define ETXTBSY 26 /* Text file busy */
+#define EFBIG 27 /* File too large */
+#define ENOSPC 28 /* No space left on device */
+#define ESPIPE 29 /* Illegal seek */
+#define EROFS 30 /* Read only file system */
+#define EMLINK 31 /* Too many links */
+#define EPIPE 32 /* Broken pipe */
+#define EDOM 33 /* Math arg out of domain of func */
+#define ERANGE 34 /* Math result not representable */
+#define ENOMSG 35 /* No message of desired type */
+#define EIDRM 36 /* Identifier removed */
+#define ECHRNG 37 /* Channel number out of range */
+#define EL2NSYNC 38 /* Level 2 not synchronized */
+#define EL3HLT 39 /* Level 3 halted */
+#define EL3RST 40 /* Level 3 reset */
+#define ELNRNG 41 /* Link number out of range */
+#define EUNATCH 42 /* Protocol driver not attached */
+#define ENOCSI 43 /* No CSI structure available */
+#define EL2HLT 44 /* Level 2 halted */
+#define EDEADLK 45 /* Deadlock condition. */
+#define ENOLCK 46 /* No record locks available. */
+#define ECANCELED 47 /* Operation canceled */
+#define ENOTSUP 48 /* Operation not supported */
+
+/* Filesystem Quotas */
+#define EDQUOT 49 /* Disc quota exceeded */
+
+/* Convergent Error Returns */
+#define EBADE 50 /* invalid exchange */
+#define EBADR 51 /* invalid request descriptor */
+#define EXFULL 52 /* exchange full */
+#define ENOANO 53 /* no anode */
+#define EBADRQC 54 /* invalid request code */
+#define EBADSLT 55 /* invalid slot */
+#define EDEADLOCK 56 /* file locking deadlock error */
+
+#define EBFONT 57 /* bad font file fmt */
+
+/* Interprocess Robust Locks */
+#define EOWNERDEAD 58 /* process died with the lock */
+#define ENOTRECOVERABLE 59 /* lock is not recoverable */
+
+/* stream problems */
+#define ENOSTR 60 /* Device not a stream */
+#define ENODATA 61 /* no data (for no delay io) */
+#define ETIME 62 /* timer expired */
+#define ENOSR 63 /* out of streams resources */
+
+#define ENONET 64 /* Machine is not on the network */
+#define ENOPKG 65 /* Package not installed */
+#define EREMOTE 66 /* The object is remote */
+#define ENOLINK 67 /* the link has been severed */
+#define EADV 68 /* advertise error */
+#define ESRMNT 69 /* srmount error */
+
+#define ECOMM 70 /* Communication error on send */
+#define EPROTO 71 /* Protocol error */
+
+/* Interprocess Robust Locks */
+#define ELOCKUNMAPPED 72 /* locked lock was unmapped */
+
+#define ENOTACTIVE 73 /* Facility is not active */
+#define EMULTIHOP 74 /* multihop attempted */
+#define EBADMSG 77 /* trying to read unreadable message */
+#define ENAMETOOLONG 78 /* path name is too long */
+#define EOVERFLOW 79 /* value too large to be stored in data type */
+#define ENOTUNIQ 80 /* given log. name not unique */
+#define EBADFD 81 /* f.d. invalid for this operation */
+#define EREMCHG 82 /* Remote address changed */
+
+/* shared library problems */
+#define ELIBACC 83 /* Can't access a needed shared lib. */
+#define ELIBBAD 84 /* Accessing a corrupted shared lib. */
+#define ELIBSCN 85 /* .lib section in a.out corrupted. */
+#define ELIBMAX 86 /* Attempting to link in too many libs. */
+#define ELIBEXEC 87 /* Attempting to exec a shared library. */
+#define EILSEQ 88 /* Illegal byte sequence. */
+#define ENOSYS 89 /* Unsupported file system operation */
+#define ELOOP 90 /* Symbolic link loop */
+#define ERESTART 91 /* Restartable system call */
+#define ESTRPIPE 92 /* if pipe/FIFO, don't sleep in stream head */
+#define ENOTEMPTY 93 /* directory not empty */
+#define EUSERS 94 /* Too many users (for UFS) */
+
+/* BSD Networking Software */
+ /* argument errors */
+#define ENOTSOCK 95 /* Socket operation on non-socket */
+#define EDESTADDRREQ 96 /* Destination address required */
+#define EMSGSIZE 97 /* Message too long */
+#define EPROTOTYPE 98 /* Protocol wrong type for socket */
+#define ENOPROTOOPT 99 /* Protocol not available */
+#define EPROTONOSUPPORT 120 /* Protocol not supported */
+#define ESOCKTNOSUPPORT 121 /* Socket type not supported */
+#define EOPNOTSUPP 122 /* Operation not supported on socket */
+#define EPFNOSUPPORT 123 /* Protocol family not supported */
+#define EAFNOSUPPORT 124 /* Address family not supported by */
+ /* protocol family */
+#define EADDRINUSE 125 /* Address already in use */
+#define EADDRNOTAVAIL 126 /* Can't assign requested address */
+ /* operational errors */
+#define ENETDOWN 127 /* Network is down */
+#define ENETUNREACH 128 /* Network is unreachable */
+#define ENETRESET 129 /* Network dropped connection because */
+ /* of reset */
+#define ECONNABORTED 130 /* Software caused connection abort */
+#define ECONNRESET 131 /* Connection reset by peer */
+#define ENOBUFS 132 /* No buffer space available */
+#define EISCONN 133 /* Socket is already connected */
+#define ENOTCONN 134 /* Socket is not connected */
+/* XENIX has 135 - 142 */
+#define ESHUTDOWN 143 /* Can't send after socket shutdown */
+#define ETOOMANYREFS 144 /* Too many references: can't splice */
+#define ETIMEDOUT 145 /* Connection timed out */
+#define ECONNREFUSED 146 /* Connection refused */
+#define EHOSTDOWN 147 /* Host is down */
+#define EHOSTUNREACH 148 /* No route to host */
+#define EWOULDBLOCK EAGAIN
+#define EALREADY 149 /* operation already in progress */
+#define EINPROGRESS 150 /* operation now in progress */
+
+/* SUN Network File System */
+#define ESTALE 151 /* Stale NFS file handle */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_ERRNO_H */
diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
new file mode 100644
index 0000000..b4c93f4
--- /dev/null
+++ b/doc/examples/Makefile.am
@@ -0,0 +1,8 @@
+EXTRA = README unify.vol replicate.vol stripe.vol protocol-client.vol protocol-server.vol posix-locks.vol trash.vol write-behind.vol io-threads.vol io-cache.vol read-ahead.vol filter.vol trace.vol
+EXTRA_DIST = $(EXTRA)
+
+docdir = $(datadir)/doc/$(PACKAGE_NAME)
+Examplesdir = $(docdir)/examples
+Examples_DATA = $(EXTRA)
+
+CLEANFILES =
diff --git a/doc/examples/README b/doc/examples/README
new file mode 100644
index 0000000..4d472ac
--- /dev/null
+++ b/doc/examples/README
@@ -0,0 +1,13 @@
+GlusterFS's translator feature is very flexible and there are quite a lot of ways one
+can configure their filesystem to behave like.
+
+Volume Specification is a way in which GlusterFS understands how it has to work, based
+on what is written there.
+
+Going through the following URLs may give you more idea about all these.
+
+* http://www.gluster.org/docs/index.php/GlusterFS
+* http://www.gluster.org/docs/index.php/GlusterFS_Volume_Specification
+* http://www.gluster.org/docs/index.php/GlusterFS_Translators
+
+Mail us any doubts, suggestions on 'gluster-devel(at)nongnu.org'
diff --git a/doc/examples/filter.vol b/doc/examples/filter.vol
new file mode 100644
index 0000000..ca5c598
--- /dev/null
+++ b/doc/examples/filter.vol
@@ -0,0 +1,23 @@
+volume client
+ type protocol/client
+ option transport-type tcp # for TCP/IP transport
+ option remote-host 192.168.1.10 # IP address of the remote brick
+ option remote-subvolume brick # name of the remote volume
+end-volume
+
+## In normal clustered storage type, any of the cluster translators can come here.
+#
+# Definition of other clients
+#
+# Definition of cluster translator (may be unify, afr, or unify over afr)
+#
+
+### 'Filter' translator is used on client side (or server side according to needs). This traslator makes all the below translators, (or say volumes) as read-only. Hence if one wants a 'read-only' filesystem, using filter as the top most volume will make it really fast as the fops are returned from this level itself.
+
+volume filter-ro
+ type features/filter
+ option root-squashing enable
+# option completely-read-only yes
+# translate-uid 1-99=0
+ subvolumes client
+end-volume \ No newline at end of file
diff --git a/doc/examples/io-cache.vol b/doc/examples/io-cache.vol
new file mode 100644
index 0000000..5f3eca4
--- /dev/null
+++ b/doc/examples/io-cache.vol
@@ -0,0 +1,25 @@
+volume client
+ type protocol/client
+ option transport-type tcp # for TCP/IP transport
+ option remote-host 192.168.1.10 # IP address of the remote brick
+ option remote-subvolume brick # name of the remote volume
+end-volume
+
+## In normal clustered storage type, any of the cluster translators can come here.
+#
+# Definition of other clients
+#
+# Definition of cluster translator (may be unify, replicate, or unify over replicate)
+#
+
+### 'IO-Cache' translator is best used on client side when a filesystem has file which are not modified frequently but read several times. For example, while compiling a kernel, *.h files are read while compiling every *.c file, in these case, io-cache translator comes very handy, as it keeps the whole file content in the cache, and serves from the cache.
+# One can provide the priority of the cache too.
+
+volume ioc
+ type performance/io-cache
+ subvolumes client # In this example it is 'client' you may have to change it according to your spec file.
+ option page-size 1MB # 128KB is default
+ option cache-size 64MB # 32MB is default
+ option force-revalidate-timeout 5 # 1second is default
+ option priority *.html:2,*:1 # default is *:0
+end-volume
diff --git a/doc/examples/io-threads.vol b/doc/examples/io-threads.vol
new file mode 100644
index 0000000..9954724
--- /dev/null
+++ b/doc/examples/io-threads.vol
@@ -0,0 +1,21 @@
+
+volume brick
+ type storage/posix # POSIX FS translator
+ option directory /home/export # Export this directory
+end-volume
+
+### 'IO-threads' translator gives a threading behaviour to File I/O calls. All other normal fops are having default behaviour. Loading this on server side helps to reduce the contension of network. (Which is assumed as a GlusterFS hang).
+# One can load it in client side to reduce the latency involved in case of a slow network, when loaded below write-behind.
+volume iot
+ type performance/io-threads
+ subvolumes brick
+ option thread-count 4 # default value is 1
+end-volume
+
+volume server
+ type protocol/server
+ subvolumes iot brick
+ option transport-type tcp # For TCP/IP transport
+ option auth.addr.brick.allow 192.168.* # Allow access to "brick" volume
+ option auth.addr.iot.allow 192.168.* # Allow access to "p-locks" volume
+end-volume
diff --git a/doc/examples/posix-locks.vol b/doc/examples/posix-locks.vol
new file mode 100644
index 0000000..b9c9e7a
--- /dev/null
+++ b/doc/examples/posix-locks.vol
@@ -0,0 +1,20 @@
+
+volume brick
+ type storage/posix # POSIX FS translator
+ option directory /home/export # Export this directory
+end-volume
+
+### 'Posix-locks' feature should be added on the server side (as posix volume as subvolume) because it contains the actual file.
+volume p-locks
+ type features/posix-locks
+ subvolumes brick
+ option mandatory on
+end-volume
+
+volume server
+ type protocol/server
+ subvolumes p-locks brick
+ option transport-type tcp
+ option auth.addr.brick.allow 192.168.* # Allow access to "brick" volume
+ option auth.addr.p-locks.allow 192.168.* # Allow access to "p-locks" volume
+end-volume
diff --git a/doc/examples/protocol-client.vol b/doc/examples/protocol-client.vol
new file mode 100644
index 0000000..43108f2
--- /dev/null
+++ b/doc/examples/protocol-client.vol
@@ -0,0 +1,17 @@
+volume client
+ type protocol/client
+ option transport-type tcp # for TCP/IP transport
+# option transport-type ib-sdp # for Infiniband transport
+ option remote-host 192.168.1.10 # IP address of the remote brick
+# option transport.socket.remote-port 6996 # default server port is 6996
+
+# option transport-type ib-verbs # for Infiniband verbs transport
+# option transport.ib-verbs.work-request-send-size 1048576
+# option transport.ib-verbs.work-request-send-count 16
+# option transport.ib-verbs.work-request-recv-size 1048576
+# option transport.ib-verbs.work-request-recv-count 16
+# option transport.ib-verbs.remote-port 6996 # default server port is 6996
+
+ option remote-subvolume brick # name of the remote volume
+# option transport-timeout 30 # default value is 120seconds
+end-volume
diff --git a/doc/examples/protocol-server.vol b/doc/examples/protocol-server.vol
new file mode 100644
index 0000000..8847751
--- /dev/null
+++ b/doc/examples/protocol-server.vol
@@ -0,0 +1,25 @@
+
+### Export volume "brick" with the contents of "/home/export" directory.
+volume brick
+ type storage/posix # POSIX FS translator
+ option directory /home/export # Export this directory
+end-volume
+
+### Add network serving capability to above brick.
+volume server
+ type protocol/server
+ option transport-type tcp # For TCP/IP transport
+# option transport.socket.listen-port 6996 # Default is 6996
+
+# option transport-type ib-verbs # For Infiniband Verbs transport
+# option transport.ib-verbs.work-request-send-size 131072
+# option transport.ib-verbs.work-request-send-count 64
+# option transport.ib-verbs.work-request-recv-size 131072
+# option transport.ib-verbs.work-request-recv-count 64
+# option transport.ib-verbs.listen-port 6996 # Default is 6996
+
+# option bind-address 192.168.1.10 # Default is to listen on all interfaces
+# option client-volume-filename /etc/glusterfs/glusterfs-client.vol
+ subvolumes brick
+ option auth.addr.brick.allow 192.168.* # Allow access to "brick" volume
+end-volume
diff --git a/doc/examples/read-ahead.vol b/doc/examples/read-ahead.vol
new file mode 100644
index 0000000..3ce0d95
--- /dev/null
+++ b/doc/examples/read-ahead.vol
@@ -0,0 +1,22 @@
+volume client
+ type protocol/client
+ option transport-type tcp # for TCP/IP transport
+ option remote-host 192.168.1.10 # IP address of the remote brick
+ option remote-subvolume brick # name of the remote volume
+end-volume
+
+## In normal clustered storage type, any of the cluster translators can come here.
+#
+# Definition of other clients
+#
+# Definition of cluster translator (may be unify, replicate, or unify over replicate)
+#
+
+### 'Read-Ahead' translator is best utilized on client side, as it prefetches the file contents when the first read() call is issued.
+volume ra
+ type performance/read-ahead
+ subvolumes client # In this example it is 'client' you may have to change it according to your spec file.
+ option page-size 1MB # default is 256KB
+ option page-count 4 # default is 2
+ option force-atime-update no # defalut is 'no'
+end-volume
diff --git a/doc/examples/replicate.vol b/doc/examples/replicate.vol
new file mode 100644
index 0000000..8c95414
--- /dev/null
+++ b/doc/examples/replicate.vol
@@ -0,0 +1,119 @@
+### 'NOTE'
+# This file has both server spec and client spec to get an understanding of stripe's spec file. Hence can't be used as it is, as a GlusterFS spec file.
+# One need to seperate out server spec and client spec to get it working.
+
+#=========================================================================
+
+# **** server1 spec file ****
+
+### Export volume "brick" with the contents of "/home/export" directory.
+volume posix1
+ type storage/posix # POSIX FS translator
+ option directory /home/export1 # Export this directory
+end-volume
+
+### Add POSIX record locking support to the storage brick
+volume brick1
+ type features/posix-locks
+ option mandatory on # enables mandatory locking on all files
+ subvolumes posix1
+end-volume
+
+### Add network serving capability to above brick.
+volume server
+ type protocol/server
+ option transport-type tcp # For TCP/IP transport
+ option transport.socket.listen-port 6996 # Default is 6996
+# option client-volume-filename /etc/glusterfs/glusterfs-client.vol
+ subvolumes brick1
+ option auth.addr.brick1.allow * # access to "brick" volume
+end-volume
+
+
+#=========================================================================
+
+# **** server2 spec file ****
+volume posix2
+ type storage/posix # POSIX FS translator
+ option directory /home/export2 # Export this directory
+end-volume
+
+### Add POSIX record locking support to the storage brick
+volume brick2
+ type features/posix-locks
+ option mandatory on # enables mandatory locking on all files
+ subvolumes posix2
+end-volume
+
+### Add network serving capability to above brick.
+volume server
+ type protocol/server
+ option transport-type tcp # For TCP/IP transport
+ option transport.socket.listen-port 6997 # Default is 6996
+ subvolumes brick2
+ option auth.addr.brick2.allow * # Allow access to "brick" volume
+end-volume
+
+
+#=========================================================================
+
+# **** server3 spec file ****
+
+volume posix3
+ type storage/posix # POSIX FS translator
+ option directory /home/export3 # Export this directory
+end-volume
+
+### Add POSIX record locking support to the storage brick
+volume brick3
+ type features/posix-locks
+ option mandatory on # enables mandatory locking on all files
+ subvolumes posix3
+end-volume
+
+### Add network serving capability to above brick.
+volume server
+ type protocol/server
+ option transport-type tcp # For TCP/IP transport
+ option transport.socket.listen-port 6998 # Default is 6996
+ subvolumes brick3
+ option auth.addr.brick3.allow * # access to "brick" volume
+end-volume
+
+
+#=========================================================================
+
+# **** Clustered Client config file ****
+
+### Add client feature and attach to remote subvolume of server1
+volume client1
+ type protocol/client
+ option transport-type tcp # for TCP/IP transport
+ option remote-host 127.0.0.1 # IP address of the remote brick
+ option transport.socket.remote-port 6996 # default server port is 6996
+ option remote-subvolume brick1 # name of the remote volume
+end-volume
+
+### Add client feature and attach to remote subvolume of server2
+volume client2
+ type protocol/client
+ option transport-type tcp # for TCP/IP transport
+ option remote-host 127.0.0.1 # IP address of the remote brick
+ option transport.socket.remote-port 6997 # default server port is 6996
+ option remote-subvolume brick2 # name of the remote volume
+end-volume
+
+volume client3
+ type protocol/client
+ option transport-type tcp # for TCP/IP transport
+ option remote-host 127.0.0.1 # IP address of the remote brick
+ option transport.socket.remote-port 6998 # default server port is 6996
+ option remote-subvolume brick3 # name of the remote volume
+end-volume
+
+## Add replicate feature.
+volume replicate
+ type cluster/replicate
+ subvolumes client1 client2 client3
+end-volume
+
diff --git a/doc/examples/stripe.vol b/doc/examples/stripe.vol
new file mode 100644
index 0000000..ea24cf8
--- /dev/null
+++ b/doc/examples/stripe.vol
@@ -0,0 +1,121 @@
+
+### 'NOTE'
+# This file has both server spec and client spec to get an understanding of stripe's spec file. Hence can't be used as it is, as a GlusterFS spec file.
+# One need to seperate out server spec and client spec to get it working.
+
+#=========================================================================
+
+# **** server1 spec file ****
+
+### Export volume "brick" with the contents of "/home/export" directory.
+volume posix1
+ type storage/posix # POSIX FS translator
+ option directory /home/export1 # Export this directory
+end-volume
+
+### Add POSIX record locking support to the storage brick
+volume brick1
+ type features/posix-locks
+ option mandatory on # enables mandatory locking on all files
+ subvolumes posix1
+end-volume
+
+### Add network serving capability to above brick.
+volume server
+ type protocol/server
+ option transport-type tcp # For TCP/IP transport
+ option transport.socket.listen-port 6996 # Default is 6996
+# option client-volume-filename /etc/glusterfs/glusterfs-client.vol
+ subvolumes brick1
+ option auth.addr.brick1.allow * # access to "brick" volume
+end-volume
+
+
+#=========================================================================
+
+# **** server2 spec file ****
+volume posix2
+ type storage/posix # POSIX FS translator
+ option directory /home/export2 # Export this directory
+end-volume
+
+### Add POSIX record locking support to the storage brick
+volume brick2
+ type features/posix-locks
+ option mandatory on # enables mandatory locking on all files
+ subvolumes posix2
+end-volume
+
+### Add network serving capability to above brick.
+volume server
+ type protocol/server
+ option transport-type tcp # For TCP/IP transport
+ option transport.socket.listen-port 6997 # Default is 6996
+ subvolumes brick2
+ option auth.addr.brick2.allow * # Allow access to "brick" volume
+end-volume
+
+
+#=========================================================================
+
+# **** server3 spec file ****
+
+volume posix3
+ type storage/posix # POSIX FS translator
+ option directory /home/export3 # Export this directory
+end-volume
+
+### Add POSIX record locking support to the storage brick
+volume brick3
+ type features/posix-locks
+ option mandatory on # enables mandatory locking on all files
+ subvolumes posix3
+end-volume
+
+### Add network serving capability to above brick.
+volume server
+ type protocol/server
+ option transport-type tcp # For TCP/IP transport
+ option transport.socket.listen-port 6998 # Default is 6996
+ subvolumes brick3
+ option auth.addr.brick3.allow * # access to "brick" volume
+end-volume
+
+
+#=========================================================================
+
+# **** Clustered Client config file ****
+
+### Add client feature and attach to remote subvolume of server1
+volume client1
+ type protocol/client
+ option transport-type tcp # for TCP/IP transport
+ option remote-host 127.0.0.1 # IP address of the remote brick
+ option transport.socket.remote-port 6996 # default server port is 6996
+ option remote-subvolume brick1 # name of the remote volume
+end-volume
+
+### Add client feature and attach to remote subvolume of server2
+volume client2
+ type protocol/client
+ option transport-type tcp # for TCP/IP transport
+ option remote-host 127.0.0.1 # IP address of the remote brick
+ option transport.socket.remote-port 6997 # default server port is 6996
+ option remote-subvolume brick2 # name of the remote volume
+end-volume
+
+volume client3
+ type protocol/client
+ option transport-type tcp # for TCP/IP transport
+ option remote-host 127.0.0.1 # IP address of the remote brick
+ option transport.socket.remote-port 6998 # default server port is 6996
+ option remote-subvolume brick3 # name of the remote volume
+end-volume
+
+## Add Stripe Feature.
+volume stripe
+ type cluster/stripe
+ subvolumes client1 client2 client3
+ option block-size 1MB
+end-volume
+
diff --git a/doc/examples/trace.vol b/doc/examples/trace.vol
new file mode 100644
index 0000000..3f4864d
--- /dev/null
+++ b/doc/examples/trace.vol
@@ -0,0 +1,16 @@
+volume client
+ type protocol/client
+ option transport-type tcp # for TCP/IP transport
+ option remote-host 192.168.1.10 # IP address of the remote brick
+ option remote-subvolume brick # name of the remote volume
+end-volume
+
+### 'Trace' translator is a very handy debug tool for GlusterFS, as it can be loaded between any of the two volumes without changing the behaviour of the filesystem.
+# On client side it can be the top most volume in spec (like now) to understand what calls are made on FUSE filesystem, when a mounted filesystem is accessed.
+
+volume trace
+ type debug/trace
+ subvolumes client
+end-volume
+
+# 'NOTE:' By loading 'debug/trace' translator, filesystem will be very slow as it logs each and every calls to the log file.
diff --git a/doc/examples/trash.vol b/doc/examples/trash.vol
new file mode 100644
index 0000000..16e71be
--- /dev/null
+++ b/doc/examples/trash.vol
@@ -0,0 +1,20 @@
+
+volume brick
+ type storage/posix # POSIX FS translator
+ option directory /home/export # Export this directory
+end-volume
+
+### 'Trash' translator is best used on server side as it just renames the deleted file inside 'trash-dir', and it makes 4 seperate fops for one unlink call.
+volume trashcan
+ type features/trash
+ subvolumes brick
+ option trash-dir /.trashcan
+end-volume
+
+volume server
+ type protocol/server
+ subvolumes trashcan brick
+ option transport-type tcp # For TCP/IP transport
+ option auth.addr.brick.allow 192.168.* # Allow access to "brick" volume
+ option auth.addr.trashcan.allow 192.168.* # Allow access to "p-locks" volume
+end-volume
diff --git a/doc/examples/unify.vol b/doc/examples/unify.vol
new file mode 100644
index 0000000..4f7415a
--- /dev/null
+++ b/doc/examples/unify.vol
@@ -0,0 +1,178 @@
+### 'NOTE'
+# This file has both server spec and client spec to get an understanding of stripe's spec file. Hence can't be used as it is, as a GlusterFS spec file.
+# One need to seperate out server spec and client spec to get it working.
+
+
+#=========================================================================
+
+# **** server1 spec file ****
+
+### Export volume "brick" with the contents of "/home/export" directory.
+volume posix1
+ type storage/posix # POSIX FS translator
+ option directory /home/export1 # Export this directory
+end-volume
+
+### Add POSIX record locking support to the storage brick
+volume brick1
+ type features/posix-locks
+ option mandatory on # enables mandatory locking on all files
+ subvolumes posix1
+end-volume
+
+### Add network serving capability to above brick.
+volume server
+ type protocol/server
+ option transport-type tcp # For TCP/IP transport
+ option transport.socket.listen-port 6996 # Default is 6996
+# option client-volume-filename /etc/glusterfs/glusterfs-client.vol
+ subvolumes brick1
+ option auth.addr.brick1.allow * # access to "brick" volume
+end-volume
+
+
+#=========================================================================
+
+# **** server2 spec file ****
+volume posix2
+ type storage/posix # POSIX FS translator
+ option directory /home/export2 # Export this directory
+end-volume
+
+### Add POSIX record locking support to the storage brick
+volume brick2
+ type features/posix-locks
+ option mandatory on # enables mandatory locking on all files
+ subvolumes posix2
+end-volume
+
+### Add network serving capability to above brick.
+volume server
+ type protocol/server
+ option transport-type tcp # For TCP/IP transport
+ option transport.socket.listen-port 6997 # Default is 6996
+ subvolumes brick2
+ option auth.addr.brick2.allow * # Allow access to "brick" volume
+end-volume
+
+
+#=========================================================================
+
+# **** server3 spec file ****
+
+volume posix3
+ type storage/posix # POSIX FS translator
+ option directory /home/export3 # Export this directory
+end-volume
+
+### Add POSIX record locking support to the storage brick
+volume brick3
+ type features/posix-locks
+ option mandatory on # enables mandatory locking on all files
+ subvolumes posix3
+end-volume
+
+### Add network serving capability to above brick.
+volume server
+ type protocol/server
+ option transport-type tcp # For TCP/IP transport
+ option transport.socket.listen-port 6998 # Default is 6996
+ subvolumes brick3
+ option auth.addr.brick3.allow * # access to "brick" volume
+end-volume
+
+#=========================================================================
+
+# *** server for namespace ***
+### Export volume "brick" with the contents of "/home/export" directory.
+volume brick-ns
+ type storage/posix # POSIX FS translator
+ option directory /home/export-ns # Export this directory
+end-volume
+
+volume server
+ type protocol/server
+ option transport-type tcp # For TCP/IP transport
+ option transport.socket.listen-port 6999 # Default is 6996
+ subvolumes brick-ns
+ option auth.addr.brick-ns.allow * # access to "brick" volume
+end-volume
+
+
+#=========================================================================
+
+# **** Clustered Client config file ****
+
+### Add client feature and attach to remote subvolume of server1
+volume client1
+ type protocol/client
+ option transport-type tcp # for TCP/IP transport
+# option transport-type ib-sdp # for Infiniband transport
+ option remote-host 127.0.0.1 # IP address of the remote brick
+ option transport.socket.remote-port 6996 # default server port is 6996
+ option remote-subvolume brick1 # name of the remote volume
+end-volume
+
+### Add client feature and attach to remote subvolume of server2
+volume client2
+ type protocol/client
+ option transport-type tcp # for TCP/IP transport
+# option transport-type ib-sdp # for Infiniband transport
+ option remote-host 127.0.0.1 # IP address of the remote brick
+ option transport.socket.remote-port 6997 # default server port is 6996
+ option remote-subvolume brick2 # name of the remote volume
+end-volume
+
+volume client3
+ type protocol/client
+ option transport-type tcp # for TCP/IP transport
+# option transport-type ib-sdp # for Infiniband transport
+ option remote-host 127.0.0.1 # IP address of the remote brick
+ option transport.socket.remote-port 6998 # default server port is 6996
+ option remote-subvolume brick3 # name of the remote volume
+end-volume
+
+
+volume client-ns
+ type protocol/client
+ option transport-type tcp # for TCP/IP transport
+# option transport-type ib-sdp # for Infiniband transport
+ option remote-host 127.0.0.1 # IP address of the remote brick
+ option transport.socket.remote-port 6999 # default server port is 6996
+ option remote-subvolume brick-ns # name of the remote volume
+end-volume
+
+### Add unify feature to cluster the servers. Associate an
+### appropriate scheduler that matches your I/O demand.
+volume bricks
+ type cluster/unify
+ option namespace client-ns # this will not be storage child of unify.
+ subvolumes client1 client2 client3
+### ** ALU Scheduler Option **
+ option self-heal background # foreground off # default is foreground
+ option scheduler alu
+ option alu.limits.min-free-disk 5% #%
+ option alu.limits.max-open-files 10000
+ option alu.order disk-usage:read-usage:write-usage:open-files-usage:disk-speed-usage
+ option alu.disk-usage.entry-threshold 2GB
+ option alu.disk-usage.exit-threshold 128MB
+ option alu.open-files-usage.entry-threshold 1024
+ option alu.open-files-usage.exit-threshold 32
+ option alu.read-usage.entry-threshold 20 #%
+ option alu.read-usage.exit-threshold 4 #%
+ option alu.write-usage.entry-threshold 20 #%
+ option alu.write-usage.exit-threshold 4 #%
+ option alu.disk-speed-usage.entry-threshold 0 # DO NOT SET IT. SPEED IS CONSTANT!!!.
+ option alu.disk-speed-usage.exit-threshold 0 # DO NOT SET IT. SPEED IS CONSTANT!!!.
+ option alu.stat-refresh.interval 10sec
+ option alu.stat-refresh.num-file-create 10
+### ** Random Scheduler **
+# option scheduler random
+### ** NUFA Scheduler **
+# option scheduler nufa
+# option nufa.local-volume-name posix1
+### ** Round Robin (RR) Scheduler **
+# option scheduler rr
+# option rr.limits.min-free-disk 5% #%
+end-volume
+
diff --git a/doc/examples/write-behind.vol b/doc/examples/write-behind.vol
new file mode 100644
index 0000000..9c6bae1
--- /dev/null
+++ b/doc/examples/write-behind.vol
@@ -0,0 +1,26 @@
+volume client
+ type protocol/client
+ option transport-type tcp # for TCP/IP transport
+ option remote-host 192.168.1.10 # IP address of the remote brick
+ option remote-subvolume brick # name of the remote volume
+end-volume
+
+## In normal clustered storage type, any of the cluster translators can come here.
+#
+# Definition of other clients
+#
+# Definition of cluster translator (may be unify, replicate, or unify over replicate)
+#
+
+
+### 'Write-behind' translator is a performance booster for write operation. Best used on client side, as its main intension is to reduce the network latency caused for each write operation.
+
+volume wb
+ type performance/write-behind
+ subvolumes client # In this example it is 'client' you may have to change it according to your spec file.
+ option flush-behind on # default value is 'off'
+ option window-size 2MB
+ option aggregate-size 1MB # default value is 0
+ option enable_O_SYNC no # default is no
+ option disable-for-first-nbytes 128KB #default is 1
+end-volume
diff --git a/doc/get_put_api_using_xattr.txt b/doc/get_put_api_using_xattr.txt
new file mode 100644
index 0000000..58951f5
--- /dev/null
+++ b/doc/get_put_api_using_xattr.txt
@@ -0,0 +1,22 @@
+GlusterFS get/put API interface provided through extended attributes:
+
+API usage:
+ int put(dirpath/filename, data): setfattr -n glusterfs.file.<filename> -v <data> <dirpath>
+ void *get(dirpath/filename): getfattr -n glusterfs.file.<filename> <dirpath>
+
+
+internals:
+* unify handling setxattr/getxattr
+ - setxattr
+ unify's setxattr forwards setxattr call to all the child nodes with XATTR_REPLACE flag, except namespace. setxattr will succeeds only on the child node on which the file already exists. if the setxattr operation fails on all child nodes, it indicates that the file does not already exist on any of the child nodes. unify follows the same rules as it follows for create, but using setxattr call itself with XATTR_CREATE flag. unify sends a setxattr to namespace first, with zero length data. if namespace setxattr succeeds, unify schedules setxattr to one of the child nodes.
+
+ - getxattr
+ unify's getxattr forwards getxattr call to all the child nodes. wait for completion of operation on all the child nodes, and returns success if getxattr succeeded one child node.
+
+* posix handling setxattr/getxattr
+ - setxattr
+ posix setxattr does a open with O_CREAT|O_TRUNC on the <path>/<name>, writes value of the setxattr as data into the file and closes the file. when data is null, posix setxattr avoids doing write. file is closed after write.
+
+ - getxattr
+ posix getxattr does open with O_RDONLY on the <path>/<name>, reads the complete content of the file. file is closed after read.
+
diff --git a/doc/glusterfs.8 b/doc/glusterfs.8
new file mode 100644
index 0000000..46c596a
--- /dev/null
+++ b/doc/glusterfs.8
@@ -0,0 +1,139 @@
+.\" Copyright (c) 2008 Z RESEARCH, Inc. <http://www.zresearch.com>
+.\" This file is part of GlusterFS.
+.\"
+.\" GlusterFS 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.
+.\"
+.\" GlusterFS 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
+.\" long with this program. If not, see
+.\" <http://www.gnu.org/licenses/>.
+.\"
+.\" :O
+.\"
+.TH GlusterFS 8 ":O Cluster Filesystem" "07 December 2008" "Z Research Inc."
+.SH NAME
+GlusterFS \- Clustered Filesystem.
+.SH SYNOPSYS
+.B glusterfs
+.I [options] [mountpoint]
+.PP
+.SH DESCRIPTION
+GlusterFS is a clustered file-system capable of scaling to several peta-bytes. It aggregates various storage bricks over Infiniband RDMA or TCP/IP interconnect into one large parallel network file system. Storage bricks can be made of any commodity hardware such as x86-64 server with SATA-II RAID and Infiniband HBA.
+GlusterFS is fully POSIX compliant FileSystem. On client side, it has dependency on FUSE package, on server side, it works seemlessly on different OSes. (Currently supported on GNU/Linux, Mac OSX, FreeBSD, OpenSolaris).
+.SH OPTIONS
+.PP
+Mandatory or optional arguments to long options are also mandatory or optional
+for any corresponding short options.
+.SS "Basic options"
+.PP
+.TP
+
+\fB\-f, \fB\-\-volfile=VOLUME-FILE\fR
+File to use as VOLUME-FILE [default:/etc/glusterfs/glusterfs.vol]
+.TP
+\fB\-l, \fB\-\-log\-file=LOGFILE\fR
+File to use for logging [default:/var/log/glusterfs/glusterfs.log]
+.TP
+\fB\-L, \fB\-\-log\-level=LOGLEVEL\fR
+Logging severity. Valid options are DEBUG, WARNING, ERROR, CRITICAL
+and NONE [default: WARNING]
+.TP
+\fB\-s, \fB\-\-volfile\-server=SERVER\fR
+Server to get the volume from. This option overrides \fB\-\-volfile option
+
+.SS "Advanced options"
+.PP
+.TP
+
+\fB\-\-debug\fR
+Run in debug mode. This option sets \fB\-\-no\-daemon\fR, \fB\-\-log\-level\fR to DEBUG
+and \fB\-\-log\-file\fR to console
+.TP
+\fB\-N, \fB\-\-no\-daemon\fR
+Run in foreground
+.TP
+\fB\-p, \fB\-\-pid\-file=PIDFILE\fR
+File to use as pid file
+.TP
+\fB\-\-volfile\-id=KEY\fR
+KEY of the volume file to be fetched from server
+.TP
+\fB\-\-volfile\-server\-port=PORT\fR
+Port number of volfile server
+.TP
+\fB\-\-volfile\-server\-transport=TRANSPORT\fR
+Transport type to get volume file from server [default: socket]
+.TP
+\fB\-\-volume\-name=VOLUME\-NAME\fR
+Volume name to be used for MOUNT-POINT [default: top most volume in
+VOLUME-FILE]
+.TP
+\fB\-\-xlator\-option=VOLUME\-NAME.OPTION=VALUE\fR
+Add/override a translator option for a volume with the specified value
+
+
+.SS "Fuse options"
+.PP
+.TP
+
+\fB\-\-attribute\-timeout=SECONDS\fR
+Set attribute timeout to SECONDS for inodes in fuse kernel module [default: 1]
+.TP
+\fB\-\-entry\-timeout=SECONDS\fR
+Set entry timeout to SECONDS in fuse kernel module [default: 1]
+.TP
+\fB\-\-disable\-direct\-io\-mode\fR
+Disable direct I/O mode in fuse kernel module
+.TP
+
+.SS "Miscellaneous Options"
+.PP
+.TP