summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CODING_STANDARDS149
-rw-r--r--CREDITS3
-rw-r--r--ChangeLog185
-rw-r--r--ChangeLog.3860
-rw-r--r--ChangeLog.TODO75
-rw-r--r--FUNCTION_LIST.txt538
-rw-r--r--INSTALL186
-rw-r--r--LICENSE70
-rw-r--r--MODULES_STATUS20
-rw-r--r--Makefile.in234
-rw-r--r--README-BCMATH17
-rw-r--r--README.QNX57
-rw-r--r--TSRM/Makefile.am4
-rw-r--r--TSRM/TSRM.c424
-rw-r--r--TSRM/TSRM.dsp100
-rw-r--r--TSRM/TSRM.h99
-rwxr-xr-xTSRM/buildconf24
-rw-r--r--TSRM/configure.in24
-rw-r--r--TSRM/tsrm_config.h.in15
-rw-r--r--acconfig.h.in118
-rw-r--r--acinclude.m4217
-rw-r--r--apMakefile.libdir4
-rw-r--r--apMakefile.tmpl77
-rw-r--r--apidoc-zend.txt276
-rw-r--r--apidoc.txt492
-rw-r--r--build-defs.h.in90
-rwxr-xr-xbuildconf135
-rw-r--r--calendar.mak244
-rw-r--r--cgi_main.c501
-rw-r--r--configure.in.in1017
-rw-r--r--crypt.mak204
-rw-r--r--dbase.mak234
-rw-r--r--dbm.mak201
-rw-r--r--dlist.c421
-rw-r--r--dlist.h137
-rw-r--r--ext/Makefile.am10
-rw-r--r--ext/apache/Makefile.am6
-rw-r--r--ext/apache/apache.c449
-rw-r--r--ext/apache/config.m45
-rw-r--r--ext/aspell/Makefile.am6
-rw-r--r--ext/aspell/aspell.c204
-rw-r--r--ext/aspell/config.h.stub4
-rw-r--r--ext/aspell/config.m428
-rw-r--r--ext/aspell/php3_aspell.h54
-rw-r--r--ext/bcmath/Makefile.am5
-rw-r--r--ext/bcmath/bcmath.c434
-rw-r--r--ext/bcmath/config.h.stub2
-rw-r--r--ext/bcmath/config.m420
-rw-r--r--ext/bcmath/php3_bcmath.h64
-rw-r--r--ext/bcmath/setup.stub6
-rw-r--r--ext/com/php3_COM.h24
-rw-r--r--ext/dav/Makefile.am6
-rw-r--r--ext/dav/config.h.stub2
-rw-r--r--ext/dav/config.m429
-rw-r--r--ext/dav/dav.c289
-rw-r--r--ext/dav/php3_dav.h66
-rw-r--r--ext/dav/setup.stub2
-rw-r--r--ext/db/Makefile.am6
-rw-r--r--ext/db/config.h.stub5
-rw-r--r--ext/db/config.m453
-rw-r--r--ext/db/db.c1163
-rw-r--r--ext/db/php3_db.h95
-rw-r--r--ext/dba/Makefile.am7
-rw-r--r--ext/dba/config.h.stub17
-rw-r--r--ext/dba/config.m4210
-rw-r--r--ext/dba/dba.c479
-rw-r--r--ext/dba/dba_cdb.c220
-rw-r--r--ext/dba/dba_db2.c207
-rw-r--r--ext/dba/dba_dbm.c190
-rw-r--r--ext/dba/dba_gdbm.c189
-rw-r--r--ext/dba/dba_ndbm.c169
-rw-r--r--ext/dba/php3_cdb.h12
-rw-r--r--ext/dba/php3_db2.h12
-rw-r--r--ext/dba/php3_dba.h115
-rw-r--r--ext/dba/php3_dbm.h12
-rw-r--r--ext/dba/php3_gdbm.h12
-rw-r--r--ext/dba/php3_ndbm.h12
-rw-r--r--ext/dba/setup.stub6
-rw-r--r--ext/dbase/Makefile.am5
-rw-r--r--ext/dbase/config.h.stub3
-rw-r--r--ext/dbase/config.m421
-rw-r--r--ext/dbase/dbase.c752
-rw-r--r--ext/dbase/dbf.h94
-rw-r--r--ext/dbase/dbf_head.c261
-rw-r--r--ext/dbase/dbf_head.h9
-rw-r--r--ext/dbase/dbf_misc.c168
-rw-r--r--ext/dbase/dbf_misc.h13
-rw-r--r--ext/dbase/dbf_ndx.c183
-rw-r--r--ext/dbase/dbf_ndx.h98
-rw-r--r--ext/dbase/dbf_rec.c182
-rw-r--r--ext/dbase/dbf_rec.h10
-rw-r--r--ext/dbase/php_dbase.h55
-rw-r--r--ext/dbase/setup.stub4
-rw-r--r--ext/ereg/ereg.c650
-rw-r--r--ext/ereg/php_ereg.h71
-rw-r--r--ext/ereg/php_regex.h14
-rw-r--r--ext/ereg/regex/COPYRIGHT20
-rw-r--r--ext/ereg/regex/Makefile.in145
-rw-r--r--ext/ereg/regex/README32
-rw-r--r--ext/ereg/regex/WHATSNEW92
-rw-r--r--ext/ereg/regex/cclass.h31
-rw-r--r--ext/ereg/regex/cname.h102
-rw-r--r--ext/ereg/regex/debug.c242
-rw-r--r--ext/ereg/regex/debug.ih14
-rw-r--r--ext/ereg/regex/engine.c1019
-rw-r--r--ext/ereg/regex/engine.ih35
-rw-r--r--ext/ereg/regex/main.c510
-rw-r--r--ext/ereg/regex/main.ih19
-rw-r--r--ext/ereg/regex/mkh76
-rw-r--r--ext/ereg/regex/regcomp.c1546
-rw-r--r--ext/ereg/regex/regcomp.ih48
-rw-r--r--ext/ereg/regex/regerror.c124
-rw-r--r--ext/ereg/regex/regerror.ih12
-rw-r--r--ext/ereg/regex/regex.3502
-rw-r--r--ext/ereg/regex/regex.7233
-rw-r--r--ext/ereg/regex/regex.dsp106
-rw-r--r--ext/ereg/regex/regex.dsw29
-rw-r--r--ext/ereg/regex/regex.h79
-rw-r--r--ext/ereg/regex/regex.mak304
-rw-r--r--ext/ereg/regex/regex2.h138
-rw-r--r--ext/ereg/regex/regexec.c140
-rw-r--r--ext/ereg/regex/regfree.c37
-rw-r--r--ext/ereg/regex/split.c316
-rw-r--r--ext/ereg/regex/tests475
-rw-r--r--ext/ereg/regex/utils.h22
-rwxr-xr-xext/ext_skel73
-rw-r--r--ext/fdf/Makefile.am6
-rw-r--r--ext/fdf/config.h.stub2
-rw-r--r--ext/fdf/config.m439
-rw-r--r--ext/fdf/fdf.c570
-rw-r--r--ext/fdf/php3_fdf.h65
-rw-r--r--ext/fdf/setup.stub7
-rw-r--r--ext/filepro/Makefile.am6
-rw-r--r--ext/filepro/config.h.stub2
-rw-r--r--ext/filepro/config.m417
-rw-r--r--ext/filepro/filepro.c540
-rw-r--r--ext/filepro/php_filepro.h58
-rw-r--r--ext/filepro/setup.stub5
-rw-r--r--ext/ftp/Makefile.am5
-rw-r--r--ext/ftp/config.h.stub2
-rw-r--r--ext/ftp/config.m418
-rw-r--r--ext/ftp/ftp.c727
-rw-r--r--ext/ftp/ftp.h131
-rw-r--r--ext/ftp/php_ftp.c631
-rw-r--r--ext/ftp/php_ftp.h38
-rw-r--r--ext/gd/Makefile.am17
-rw-r--r--ext/gd/config.h.stub9
-rw-r--r--ext/gd/config.m4166
-rw-r--r--ext/gd/gd.c1809
-rw-r--r--ext/gd/gdcache.c201
-rw-r--r--ext/gd/gdcache.h87
-rw-r--r--ext/gd/gdttf.c878
-rw-r--r--ext/gd/gdttf.h16
-rw-r--r--ext/gd/php3_gd.h108
-rw-r--r--ext/gd/setup.stub6
-rw-r--r--ext/gettext/Makefile.am6
-rw-r--r--ext/gettext/config.h.stub3
-rw-r--r--ext/gettext/config.m445
-rw-r--r--ext/gettext/gettext.c158
-rw-r--r--ext/gettext/php3_gettext.h57
-rw-r--r--ext/gettext/setup.stub6
-rw-r--r--ext/hyperwave/Makefile.am6
-rw-r--r--ext/hyperwave/config.h.stub2
-rw-r--r--ext/hyperwave/config.m418
-rw-r--r--ext/hyperwave/debug.h194
-rw-r--r--ext/hyperwave/hg_comm.c4859
-rw-r--r--ext/hyperwave/hg_comm.h212
-rw-r--r--ext/hyperwave/hw.c3678
-rw-r--r--ext/hyperwave/hw_error.h117
-rw-r--r--ext/hyperwave/php3_hyperwave.h165
-rw-r--r--ext/hyperwave/setup.stub6
-rw-r--r--ext/icap/Makefile.am6
-rw-r--r--ext/icap/config.h.stub2
-rw-r--r--ext/icap/config.m425
-rw-r--r--ext/icap/php3_icap.c955
-rw-r--r--ext/icap/php3_icap.h57
-rw-r--r--ext/imap/Makefile.am6
-rw-r--r--ext/imap/config.h.stub2
-rw-r--r--ext/imap/config.m463
-rw-r--r--ext/imap/imap.c2692
-rw-r--r--ext/imap/imap.h86
-rw-r--r--ext/imap/setup.stub7
-rw-r--r--ext/informix/Makefile.am15
-rw-r--r--ext/informix/config.h.stub9
-rw-r--r--ext/informix/config.m480
-rw-r--r--ext/informix/ifx.ec4734
-rw-r--r--ext/informix/php_informix.h223
-rw-r--r--ext/informix/setup.stub9
-rw-r--r--ext/interbase/Makefile.am6
-rw-r--r--ext/interbase/config.h.stub3
-rw-r--r--ext/interbase/config.m429
-rw-r--r--ext/interbase/interbase.c1117
-rw-r--r--ext/interbase/php3_interbase.h111
-rw-r--r--ext/interbase/setup.stub7
-rw-r--r--ext/ldap/Makefile.am6
-rw-r--r--ext/ldap/config.h.stub2
-rw-r--r--ext/ldap/config.m481
-rw-r--r--ext/ldap/ldap.c1300
-rw-r--r--ext/ldap/php3_ldap.h127
-rw-r--r--ext/ldap/setup.stub8
-rw-r--r--ext/mcal/Makefile.am6
-rw-r--r--ext/mcal/config.h.stub2
-rw-r--r--ext/mcal/config.m425
-rw-r--r--ext/mcal/php3_mcal.c1642
-rw-r--r--ext/mcal/php3_mcal.h86
-rw-r--r--ext/mcrypt/Makefile.am6
-rw-r--r--ext/mcrypt/config.h.stub2
-rw-r--r--ext/mcrypt/config.m431
-rw-r--r--ext/mcrypt/mcrypt.c356
-rw-r--r--ext/mcrypt/php_mcrypt.h30
-rw-r--r--ext/mcrypt/setup.stub6
-rw-r--r--ext/mhash/Makefile.am6
-rw-r--r--ext/mhash/config.h.stub2
-rw-r--r--ext/mhash/config.m431
-rw-r--r--ext/mhash/mhash.c142
-rw-r--r--ext/mhash/php_mhash.h26
-rw-r--r--ext/mhash/setup.stub6
-rw-r--r--ext/msql/Makefile.am6
-rw-r--r--ext/msql/config.h.stub2
-rw-r--r--ext/msql/config.m446
-rw-r--r--ext/msql/php_msql.c1312
-rw-r--r--ext/msql/php_msql.h99
-rw-r--r--ext/msql/setup.stub11
-rw-r--r--ext/mysql/Makefile.am15
-rw-r--r--ext/mysql/Readme_w32.txt14
-rw-r--r--ext/mysql/config.h.stub3
-rw-r--r--ext/mysql/config.m479
-rw-r--r--ext/mysql/mysql.dsp171
-rw-r--r--ext/mysql/php_mysql.c1813
-rw-r--r--ext/mysql/php_mysql.h122
-rw-r--r--ext/mysql/setup.stub7
-rw-r--r--ext/oci8/Makefile.am6
-rw-r--r--ext/oci8/config.h.stub4
-rw-r--r--ext/oci8/config.m4174
-rw-r--r--ext/oci8/oci8.c3620
-rw-r--r--ext/oci8/php3_oci8.h210
-rw-r--r--ext/oci8/setup.stub6
-rw-r--r--ext/odbc/Makefile.am4
-rw-r--r--ext/odbc/config.h.stub9
-rw-r--r--ext/odbc/config.m4290
-rw-r--r--ext/odbc/php3_velocis.h109
-rw-r--r--ext/odbc/php_odbc.c2067
-rw-r--r--ext/odbc/php_odbc.h275
-rw-r--r--ext/odbc/setup.stub89
-rw-r--r--ext/odbc/velocis.c648
-rw-r--r--ext/oracle/Makefile.am5
-rw-r--r--ext/oracle/config.h.stub2
-rw-r--r--ext/oracle/config.m4172
-rw-r--r--ext/oracle/oracle.c1944
-rw-r--r--ext/oracle/oracle_hack.c24
-rw-r--r--ext/oracle/php3_oracle.h147
-rw-r--r--ext/oracle/setup.stub9
-rw-r--r--ext/pcre/Makefile.am6
-rw-r--r--ext/pcre/config.h.stub4
-rw-r--r--ext/pcre/config.m458
-rw-r--r--ext/pcre/config0.m458
-rw-r--r--ext/pcre/pcrelib/ChangeLog519
-rw-r--r--ext/pcre/pcrelib/LICENCE32
-rw-r--r--ext/pcre/pcrelib/Makefile.am2
-rw-r--r--ext/pcre/pcrelib/README416
-rwxr-xr-xext/pcre/pcrelib/RunTest94
-rw-r--r--ext/pcre/pcrelib/Tech.Notes239
-rw-r--r--ext/pcre/pcrelib/chartables.c146
-rw-r--r--ext/pcre/pcrelib/dftables.c146
-rw-r--r--ext/pcre/pcrelib/dll.mk60
-rw-r--r--ext/pcre/pcrelib/get.c189
-rw-r--r--ext/pcre/pcrelib/internal.h343
-rw-r--r--ext/pcre/pcrelib/maketables.c113
-rw-r--r--ext/pcre/pcrelib/pcre.31499
-rw-r--r--ext/pcre/pcrelib/pcre.3.html1973
-rw-r--r--ext/pcre/pcrelib/pcre.3.txt1739
-rw-r--r--ext/pcre/pcrelib/pcre.c4477
-rw-r--r--ext/pcre/pcrelib/pcre.def19
-rw-r--r--ext/pcre/pcrelib/pcre.h94
-rw-r--r--ext/pcre/pcrelib/pcreposix.3141
-rw-r--r--ext/pcre/pcrelib/pcreposix.3.html182
-rw-r--r--ext/pcre/pcrelib/pcreposix.3.txt150
-rw-r--r--ext/pcre/pcrelib/pcreposix.c250
-rw-r--r--ext/pcre/pcrelib/pcreposix.h82
-rw-r--r--ext/pcre/pcrelib/pcretest.c1010
-rwxr-xr-xext/pcre/pcrelib/perltest143
-rw-r--r--ext/pcre/pcrelib/pgrep.176
-rw-r--r--ext/pcre/pcrelib/pgrep.1.html105
-rw-r--r--ext/pcre/pcrelib/pgrep.1.txt86
-rw-r--r--ext/pcre/pcrelib/pgrep.c225
-rw-r--r--ext/pcre/pcrelib/study.c397
-rw-r--r--ext/pcre/pcrelib/testinput11890
-rw-r--r--ext/pcre/pcrelib/testinput2589
-rw-r--r--ext/pcre/pcrelib/testinput31692
-rw-r--r--ext/pcre/pcrelib/testinput464
-rw-r--r--ext/pcre/pcrelib/testoutput12887
-rw-r--r--ext/pcre/pcrelib/testoutput21624
-rw-r--r--ext/pcre/pcrelib/testoutput32929
-rw-r--r--ext/pcre/pcrelib/testoutput4115
-rw-r--r--ext/pcre/php_pcre.c1197
-rw-r--r--ext/pcre/php_pcre.h96
-rw-r--r--ext/pcre/setup.stub6
-rw-r--r--ext/pdf/Makefile.am6
-rw-r--r--ext/pdf/config.h.stub3
-rw-r--r--ext/pdf/config.m490
-rw-r--r--ext/pdf/pdf.c2452
-rw-r--r--ext/pdf/php3_pdf.h122
-rw-r--r--ext/pdf/setup.stub7
-rw-r--r--ext/pgsql/Makefile.am16
-rw-r--r--ext/pgsql/config.h.stub8
-rw-r--r--ext/pgsql/config.m465
-rw-r--r--ext/pgsql/pgsql.c1473
-rw-r--r--ext/pgsql/php3_pgsql.h121
-rw-r--r--ext/pgsql/setup.stub8
-rw-r--r--ext/rpc/com/COM.c949
-rw-r--r--ext/rpc/com/php3_COM.h24
-rw-r--r--ext/session/Makefile.am6
-rw-r--r--ext/session/config.h.stub4
-rw-r--r--ext/session/config.m442
-rw-r--r--ext/session/mod_files.c258
-rw-r--r--ext/session/mod_files.h38
-rw-r--r--ext/session/mod_files.sh16
-rw-r--r--ext/session/mod_mm.c342
-rw-r--r--ext/session/mod_mm.h52
-rw-r--r--ext/session/mod_user.c186
-rw-r--r--ext/session/mod_user.h39
-rw-r--r--ext/session/modules.c15
-rw-r--r--ext/session/php_session.h157
-rw-r--r--ext/session/session.c937
-rw-r--r--ext/session/setup.stub6
-rw-r--r--ext/snmp/Makefile.am15
-rw-r--r--ext/snmp/config.h.stub4
-rw-r--r--ext/snmp/config.m480
-rw-r--r--ext/snmp/php3_snmp.h54
-rw-r--r--ext/snmp/snmp.c385
-rw-r--r--ext/snmp/winsnmp.c228
-rw-r--r--ext/standard/Makefile.am17
-rw-r--r--ext/standard/base64.c193
-rw-r--r--ext/standard/base64.h47
-rw-r--r--ext/standard/basic_functions.c3313
-rw-r--r--ext/standard/basic_functions.h155
-rw-r--r--ext/standard/browscap.c124
-rw-r--r--ext/standard/config.h.stub14
-rw-r--r--ext/standard/config.m4123
-rw-r--r--ext/standard/crypt.c189
-rw-r--r--ext/standard/cyr_convert.c290
-rw-r--r--ext/standard/cyr_convert.h40
-rw-r--r--ext/standard/datetime.c658
-rw-r--r--ext/standard/datetime.h52
-rw-r--r--ext/standard/dir.c277
-rw-r--r--ext/standard/dl.c181
-rw-r--r--ext/standard/dl.h61
-rw-r--r--ext/standard/dns.c318
-rw-r--r--ext/standard/dns.h53
-rw-r--r--ext/standard/exec.c415
-rw-r--r--ext/standard/exec.h43
-rw-r--r--ext/standard/file.c1669
-rw-r--r--ext/standard/file.h74
-rw-r--r--ext/standard/filestat.c606
-rw-r--r--ext/standard/flock_compat.c219
-rw-r--r--ext/standard/flock_compat.h28
-rw-r--r--ext/standard/formatted_print.c589
-rw-r--r--ext/standard/fsock.c749
-rw-r--r--ext/standard/fsock.h80
-rw-r--r--ext/standard/global.h62
-rw-r--r--ext/standard/head.c585
-rw-r--r--ext/standard/head.h67
-rw-r--r--ext/standard/html.c119
-rw-r--r--ext/standard/html.h38
-rw-r--r--ext/standard/image.c384
-rw-r--r--ext/standard/info.c504
-rw-r--r--ext/standard/info.h67
-rw-r--r--ext/standard/iptc.c387
-rw-r--r--ext/standard/lcg.c98
-rw-r--r--ext/standard/link.c193
-rw-r--r--ext/standard/mail.c172
-rw-r--r--ext/standard/math.c700
-rw-r--r--ext/standard/md5.c392
-rw-r--r--ext/standard/md5.h71
-rw-r--r--ext/standard/metaphone.c475
-rw-r--r--ext/standard/microtime.c142
-rw-r--r--ext/standard/microtime.h39
-rw-r--r--ext/standard/pack.c874
-rw-r--r--ext/standard/pack.h44
-rw-r--r--ext/standard/pageinfo.c146
-rw-r--r--ext/standard/pageinfo.h11
-rw-r--r--ext/standard/parsedate.y919
-rw-r--r--ext/standard/php3_browscap.h45
-rw-r--r--ext/standard/php3_crypt.h15
-rw-r--r--ext/standard/php3_dir.h50
-rw-r--r--ext/standard/php3_filestat.h68
-rw-r--r--ext/standard/php3_iptc.h39
-rw-r--r--ext/standard/php3_link.h41
-rw-r--r--ext/standard/php3_mail.h49
-rw-r--r--ext/standard/php3_standard.h75
-rw-r--r--ext/standard/php3_string.h109
-rw-r--r--ext/standard/php3_syslog.h53
-rw-r--r--ext/standard/php3_var.h42
-rw-r--r--ext/standard/php_image.h26
-rw-r--r--ext/standard/php_lcg.h43
-rw-r--r--ext/standard/php_metaphone.h27
-rw-r--r--ext/standard/phpdir.h44
-rw-r--r--ext/standard/phpmath.h70
-rw-r--r--ext/standard/post.c400
-rw-r--r--ext/standard/post.h45
-rw-r--r--ext/standard/quot_print.c98
-rw-r--r--ext/standard/quot_print.h37
-rw-r--r--ext/standard/rand.c374
-rw-r--r--ext/standard/reg.c650
-rw-r--r--ext/standard/reg.h71
-rw-r--r--ext/standard/soundex.c119
-rw-r--r--ext/standard/string.c1992
-rw-r--r--ext/standard/syslog.c283
-rw-r--r--ext/standard/type.c96
-rw-r--r--ext/standard/type.h41
-rw-r--r--ext/standard/uniqid.c98
-rw-r--r--ext/standard/uniqid.h37
-rw-r--r--ext/standard/url.c422
-rw-r--r--ext/standard/url.h60
-rw-r--r--ext/standard/url_scanner.c470
-rw-r--r--ext/standard/url_scanner.h25
-rw-r--r--ext/standard/url_scanner.re185
-rw-r--r--ext/standard/var.c494
-rw-r--r--ext/sybase/Makefile.am6
-rw-r--r--ext/sybase/config.h.stub4
-rw-r--r--ext/sybase/config.m431
-rw-r--r--ext/sybase/php3_sybase.h143
-rw-r--r--ext/sybase/setup.stub11
-rw-r--r--ext/sybase/sybase.c1231
-rw-r--r--ext/sybase_ct/Makefile.am6
-rw-r--r--ext/sybase_ct/config.h.stub4
-rw-r--r--ext/sybase_ct/config.m442
-rw-r--r--ext/sybase_ct/php_sybase_ct.c1566
-rw-r--r--ext/sybase_ct/php_sybase_ct.h124
-rw-r--r--ext/sybase_ct/setup.stub6
-rw-r--r--ext/sysvsem/Makefile.am6
-rw-r--r--ext/sysvsem/config.h.stub7
-rw-r--r--ext/sysvsem/config.m437
-rw-r--r--ext/sysvsem/php3_sysvsem.h76
-rw-r--r--ext/sysvsem/setup.stub5
-rw-r--r--ext/sysvsem/sysvsem.c352
-rw-r--r--ext/sysvshm/Makefile.am6
-rw-r--r--ext/sysvshm/config.h.stub3
-rw-r--r--ext/sysvshm/config.m417
-rw-r--r--ext/sysvshm/php3_sysvshm.h103
-rw-r--r--ext/sysvshm/setup.stub5
-rw-r--r--ext/sysvshm/sysvshm.c450
-rw-r--r--ext/wddx/Makefile.am6
-rw-r--r--ext/wddx/config.h.stub2
-rw-r--r--ext/wddx/config.m420
-rw-r--r--ext/wddx/php_wddx.h59
-rw-r--r--ext/wddx/php_wddx_api.h54
-rw-r--r--ext/wddx/setup.stub6
-rw-r--r--ext/wddx/wddx.c848
-rw-r--r--ext/xml/Makefile.am15
-rw-r--r--ext/xml/config.h.stub4
-rw-r--r--ext/xml/config.m470
-rw-r--r--ext/xml/php3_xml.h161
-rw-r--r--ext/xml/xml.c1485
-rw-r--r--ext/yp/Makefile.am6
-rw-r--r--ext/yp/config.h.stub5
-rw-r--r--ext/yp/config.m429
-rw-r--r--ext/yp/php3_yp.h62
-rw-r--r--ext/yp/setup.stub6
-rw-r--r--ext/yp/yp.c180
-rw-r--r--ext/zlib/Makefile.am6
-rw-r--r--ext/zlib/config.h.stub2
-rw-r--r--ext/zlib/config.m438
-rw-r--r--ext/zlib/php3_zlib.h79
-rw-r--r--ext/zlib/setup.stub7
-rw-r--r--ext/zlib/zlib.c730
-rw-r--r--fhttpd.c185
-rw-r--r--filepro.mak194
-rw-r--r--footer7
-rw-r--r--gd.mak214
-rw-r--r--genif.pl24
-rw-r--r--genif.sh40
-rw-r--r--getopt.c170
-rw-r--r--header29
-rw-r--r--hyperwave.mak214
-rw-r--r--imap4.mak194
-rw-r--r--install-sh238
-rw-r--r--ldap.mak194
-rw-r--r--libphp4.module.in7
-rw-r--r--main.h52
-rw-r--r--main/SAPI.c333
-rw-r--r--main/SAPI.h167
-rw-r--r--main/alloca.c490
-rw-r--r--main/config.w32.h313
-rw-r--r--main/configuration-parser.y438
-rw-r--r--main/configuration-scanner.l179
-rw-r--r--main/fopen_wrappers.c1003
-rw-r--r--main/fopen_wrappers.h93
-rw-r--r--main/internal_functions.c.in138
-rw-r--r--main/internal_functions_registry.h46
-rw-r--r--main/internal_functions_win32.c140
-rw-r--r--main/logos.h942
-rw-r--r--main/main.c1235
-rw-r--r--main/php.h380
-rw-r--r--main/php3_compat.h92
-rw-r--r--main/php_content_types.c25
-rw-r--r--main/php_content_types.h6
-rw-r--r--main/php_globals.h107
-rw-r--r--main/php_ini.c460
-rw-r--r--main/php_ini.h148
-rw-r--r--main/php_regex.h14
-rw-r--r--main/php_version.h3
-rw-r--r--main/rfc1867.c268
-rw-r--r--main/rfc1867.h12
-rw-r--r--main/safe_mode.c144
-rw-r--r--main/safe_mode.h7
-rw-r--r--main/snprintf.c934
-rw-r--r--main/snprintf.h45
-rw-r--r--main/strlcat.c75
-rw-r--r--main/strlcpy.c72
-rw-r--r--main/win95nt.h74
-rwxr-xr-xmakeall.bat13
-rwxr-xr-xmakedist143
-rwxr-xr-xmakeparser.bat4
-rw-r--r--mod_php4.c603
-rw-r--r--mod_php4.exp1
-rw-r--r--mod_php4.h49
-rw-r--r--msql.mak194
-rw-r--r--msql1.mak212
-rwxr-xr-xmtparser.bat4
-rw-r--r--mysql.mak197
-rw-r--r--output.c232
-rw-r--r--output.h37
-rw-r--r--php.ini-dist288
-rw-r--r--php.map4
-rw-r--r--php3_realpath.c275
-rw-r--r--php3_realpath.h30
-rw-r--r--php3_sprintf.c42
-rw-r--r--php4.dsp101
-rw-r--r--php4.dsw59
-rw-r--r--php4.gifbin2123 -> 0 bytes
-rw-r--r--php4.spec.in48
-rw-r--r--php4dll.dsp901
-rw-r--r--php4dllts.dsp873
-rw-r--r--php4ext.dsw29
-rw-r--r--php4ts.dsp101
-rw-r--r--php4ts.dsw92
-rw-r--r--php_custom_build.mak269
-rw-r--r--php_getopt.h9
-rw-r--r--regex/COPYRIGHT20
-rw-r--r--regex/Makefile.in145
-rw-r--r--regex/README32
-rw-r--r--regex/WHATSNEW92
-rw-r--r--regex/cclass.h31
-rw-r--r--regex/cname.h102
-rw-r--r--regex/debug.c242
-rw-r--r--regex/debug.ih14
-rw-r--r--regex/engine.c1019
-rw-r--r--regex/engine.ih35
-rw-r--r--regex/main.c510
-rw-r--r--regex/main.ih19
-rw-r--r--regex/mkh76
-rw-r--r--regex/regcomp.c1546
-rw-r--r--regex/regcomp.ih48
-rw-r--r--regex/regerror.c124
-rw-r--r--regex/regerror.ih12
-rw-r--r--regex/regex.3502
-rw-r--r--regex/regex.7233
-rw-r--r--regex/regex.dsp106
-rw-r--r--regex/regex.dsw29
-rw-r--r--regex/regex.h79
-rw-r--r--regex/regex.mak304
-rw-r--r--regex/regex2.h138
-rw-r--r--regex/regexec.c140
-rw-r--r--regex/regfree.c37
-rw-r--r--regex/split.c316
-rw-r--r--regex/tests475
-rw-r--r--regex/utils.h22
-rw-r--r--request_info.c102
-rw-r--r--request_info.h43
-rwxr-xr-xscripts/apache/apconf-conv.sh24
-rwxr-xr-xscripts/apache/aphtaccess-conv.sh24
-rw-r--r--scripts/apache/conffix.awk23
-rw-r--r--scripts/apache/htaccessfix.awk23
-rwxr-xr-xscripts/armerge83
-rwxr-xr-xscripts/config-stubs7
-rwxr-xr-xscripts/conv_proto30
-rwxr-xr-xscripts/mkextlib.in17
-rwxr-xr-xscripts/preconfig37
-rw-r--r--setup370
-rw-r--r--snmp.mak194
-rw-r--r--stamp-h.in0
-rw-r--r--tests/foo5
-rw-r--r--tests/foo23
-rw-r--r--tests/foo343
-rw-r--r--tests/foo441
-rw-r--r--tests/recurse21
-rw-r--r--tests/test.php416
-rw-r--r--tests/test.pl34
-rw-r--r--tests/test_class_inheritance29
-rw-r--r--tests/testarray21
-rw-r--r--tests/testarray.pl5
-rw-r--r--tests/testarray25
-rw-r--r--tests/testarray2.pl3
-rw-r--r--tests/testclassfunc10
-rw-r--r--tests/testcom9
-rw-r--r--tests/testfe21
-rw-r--r--tests/testfunc36
-rw-r--r--tests/testfunc.pl20
-rw-r--r--tests/testfunc219
-rw-r--r--tests/testfunc2.pl22
-rw-r--r--tests/testfuncref8
-rw-r--r--tests/testinclude5
-rw-r--r--tests/testobj32
-rw-r--r--win32/flock.c83
-rw-r--r--win32/flock.h11
-rw-r--r--win32/grp.h31
-rw-r--r--win32/param.h16
-rw-r--r--win32/php_modules.dsw41
-rw-r--r--win32/php_registry.h7
-rw-r--r--win32/pwd.c74
-rw-r--r--win32/pwd.h57
-rw-r--r--win32/readdir.c112
-rw-r--r--win32/readdir.h38
-rw-r--r--win32/registry.c74
-rw-r--r--win32/sendmail.c501
-rw-r--r--win32/sendmail.h46
-rw-r--r--win32/signal.h16
-rw-r--r--win32/syslog.h73
-rw-r--r--win32/time.c153
-rw-r--r--win32/time.h40
-rw-r--r--win32/unistd.h1
-rw-r--r--win32/wfile.c17
-rw-r--r--win32/wfile.h16
-rw-r--r--win32/winutil.c21
-rw-r--r--win32/winutil.h1
-rw-r--r--win32/wsyslog.c122
-rw-r--r--zlib.mak194
628 files changed, 0 insertions, 157740 deletions
diff --git a/CODING_STANDARDS b/CODING_STANDARDS
deleted file mode 100644
index 477cad33c9..0000000000
--- a/CODING_STANDARDS
+++ /dev/null
@@ -1,149 +0,0 @@
-PHP Coding Standards
-====================
-
-
-This file lists several standards that any programmer, adding or changing
-code in PHP, should follow. Since this file was added at a very late
-stage of the development of PHP v3.0, the code base does not (yet) fully
-follow it, but it's going in that general direction.
-This is an initial version - it'll most probably grow as time passes.
-
-
-Code Implementation
--------------------
-
-[1] Functions that are given pointers to resources should not free them
-
-For instance, function int mail(char *to, char *from) should NOT free
-to and/or from.
-Exceptions:
-
- - The function's designated behavior is freeing that resource. E.g. efree()
- - The function is given a boolean argument, that controls whether or not
- the function may free its arguments (if true - the function must free its
- arguments, if false - it must not)
- - Low-level parser routines, that are tightly integrated with the token
- cache and the bison code for minimum memory copying overhead.
-
-[2] Functions that are tightly integrated with other functions within the
- same module, and rely on each other non-trivial behavior, should be
- documented as such and declared 'static'. They should be avoided if
- possible.
-
-[3] Use definitions and macros whenever possible, so that constants have
- meaningful names and can be easily manipulated. The only exceptions
- to this rule are 0 and 1, when used as false and true (respectively).
- Any other use of a numeric constant to specify different behavior
- or actions should be done through a #define.
-
-[4] When writing functions that deal with strings, be sure to remember
- that PHP holds the length property of each string, and that it
- shouldn't be calculated with strlen(). Write your functions in a such
- a way so that they'll take advantage of the length property, both
- for efficiency and in order for them to be binary-safe.
- Functions that change strings and obtain their new lengths while
- doing so, should return that new length, so it doesn't have to be
- recalculated with strlen() (e.g. _php3_addslashes())
-
-[5] Use php3_error() to report any errors/warnings during code execution.
- Use descriptive error messages, and try to avoid using identical
- error strings for different stages of an error. For example,
- if in order to obtain a URL you have to parse the URL, connect,
- and retreive the text, assuming something can go wrong at each
- of these stages, don't report an error "Unable to get URL"
- on all of them, but instead, write something like "Unable
- to parse URL", "Unable to connect to URL server" and "Unable
- to fetch URL text", respectively.
-
-[6] NEVER USE strncat(). If you're absolutely sure you know what you're doing,
- check its man page again, and only then, consider using it, and even then,
- try avoiding it.
-
-
-Naming Conventions
-------------------
-
-[1] Function names for user functions implementation should be prefixed with
- "php3_", and followed by a word or an underscore-delimited list of words,
- in lowercase letters, that describes the function.
-
-[2] Function names used by user functions implementations should be prefixed
- with "_php3_", and followed by a word or an underscore-delimited list of
- words, in lowercase letters, that describes the function. If applicable,
- they should be declared 'static'.
-
-[3] Variable names must be meaningful. One letter variable names must be
- avoided, except for places where the variable has no real meaning or
- a trivial meaning (e.g. for (i=0; i<100; i++) ...).
-
-[4] Variable names should be in lowercase; Use underscores to seperate
- between words.
-
-
-
-Syntax and indentation
-----------------------
-
-[1] Never use C++ style comments (i.e. // comment). Always use C-style
- comments instead. PHP is written in C, and is aimed at compiling
- under any ANSI-C compliant compiler. Even though many compilers
- accept C++-style comments in C code, you have to ensure that your
- code would compile with other compilers as well.
- The only exception to this rule is code that is Win32-specific,
- because the Win32 port is MS-Visual C++ specific, and this compiler
- is known to accept C++-style comments in C code.
-
-[2] Use K&R-style. Of course, we can't and don't want to
- force anybody to use a style she's not used to, but
- at the very least, when you write code that goes into the core
- of PHP or one of its standard modules, please maintain the K&R
- style. This applies to just about everything, starting with
- indentation and comment styles and up to function decleration
- syntax.
-
-[3] Be generous with whitespace and braces. Always prefer
- if (foo) {
- bar;
- }
- to
- if(foo)bar;
-
- Keep one empty line between the variable decleration section and
- the statements in a block, as well as between logical statement
- groups in a block. Maintain at least one empty line between
- two functions, preferably two.
-
-Documentation and Folding Hooks
--------------------------------
-
-In order to make sure that the online documentation stays in line with
-the code, each user-level function should have its user-level function
-prototype before it along with a brief one-line description of what the
-function does. It would look like this:
-
-/* {{{ proto int abs(int number)
- Return the absolute value of the number */
-void php3_abs(INTERNAL_FUNCTION_PARAMETERS) {
- ...
-}
-/* }}} */
-
-The {{{ symbols are the default folding symbols for the folding mode in
-Emacs. vim will soon have support for folding as well. Folding is very
-useful when dealing with large files because you can scroll through the
-file quickly and just unfold the function you wish to work on. The }}}
-at the end of each function marks the end of the fold, and should be on
-a separate line.
-
-The "proto" keyword there is just a helper for the doc/genfuncsummary script
-which generates a full function summary. Having this keyword in front of the
-function prototypes allows us to put folds elsewhere in the code without
-messing up the function summary.
-
-Optional arguments are written like this:
-
-/* {{{ proto object imap_header(int stream_id, int msg_no [, int from_length [, int subject_length [, string default_host]]])
-
-And yes, please keep everything on a single line, even if that line is massive.
-
-
diff --git a/CREDITS b/CREDITS
deleted file mode 100644
index dbb3f0bcea..0000000000
--- a/CREDITS
+++ /dev/null
@@ -1,3 +0,0 @@
-For the list of people who've put work into PHP 4.0, please see
-http://www.php.net/version4/credits.php
-
diff --git a/ChangeLog b/ChangeLog
deleted file mode 100644
index 64f9118095..0000000000
--- a/ChangeLog
+++ /dev/null
@@ -1,185 +0,0 @@
-PHP 4.0 CHANGE LOG ChangeLog
-|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-
-?? ?? 1999, Version 4.0 Beta 3
-- Upgraded var_dump() to take multiple arguments (Andrey)
-- Resourcified XML (Thies)
-- Fixed a memory leak in the Apache per-directory directives handler (Zeev)
-- Added array_count_values() function. (Thies)
-- snmp, pgsql, mysql and gd modules can be built as dynamically loaded
- modules (Greg)
-- OCI8 fix for fetching empty LOBs (Thies)
-- Added user-level callbacks for session module (Sascha)
-- Added support for unknown POST content types (Zeev)
-- Added "wddx" serialization handler for session module (Sascha)
- (automatically enabled, if you compile with --with-wddx)
-- Fixed unserializing objects (Thies)
-- PHP 4.0 now serializes Objects as 'O' (not understood by PHP 3.0), but
- unserializes PHP 3.0 serialized objects as expected. (Thies)
-- Made serialize/unserialize work on classes. If the class is known at
- unserialize() time, you'll get back a fully working object! (Thies)
-- Reworked preg_* functions according to the new PCRE API, which also made
- them behave much more like Perl ones (Andrey)
-- Made it possible to specify external location of PCRE library (Andrey)
-- Updated bundled PCRE library to version 2.08 (Andrey)
-- count()/is_array/is_object... speedups. (Thies)
-- OCI8 supports appending and positioning when saving LOBs (Thies)
-- Added metaphone support (Thies)
-- OCI8 doesn't use define callbacks any longer. (Thies)
-- OCI8 Driver now supports LOBs like PHP 3.0. (Thies)
-- var_dump now dumps the properties of an object (Thies)
-- Rewrote the GET/POST/Cookie data reader to support multi-dimensional
- arrays! (Zeev)
-- Renamed allow_builtin_links to expose_php (defaults to On). This directive
- tells PHP whether it may expose its existence to the outside world, e.g.
- by adding itself to the Web server header (Zeev)
-- Added support for transparent session id propagation (Sascha)
-- Made WDDX serialize object properties properly (Andrey)
-- Fixed WDDX mem leak when undefined variable is passed in
- for serialization (Andrey)
-- Added session_unset() function (Andrey)
-- Fixed double session globals shutdown crash (Andrey)
-- Fixed crash related to ignore_user_abort ini entry (Andrey)
-- Added support for external entropy sources for session id creation
- (on Unices /dev/random and /dev/urandom) (Sascha)
-- Added gpc_globals variable directive to php.ini. By default it is On, but
- if it is set to Off, GET, POST and Cookie variables will not be inserted
- to the global scope. Mostly makes sense when coupled with track_vars (Zeev)
-- Added versioning support for shared library (Sascha)
- This allows concurrent use of PHP 3.0 and PHP 4.0 as Apache modules. See
- the end of the INSTALL file for more information.
-- Added second parameter to array_keys which specifies search value
- for which the key should be returned (Andrey)
-- Resourcified Informix driver (Danny)
-- New resource handling for odbc, renamed to php_odbc.[ch]
-- Make set_time_limit() work on Unix (Rasmus)
-- Added connection handling support (Rasmus)
-- Improved the Sybase-CT module to make use of resources (Zeev)
-- Improved the mSQL module to make use of resources (Zeev)
-- Changed mysql_query() and mysql_db_query() to return false in case of saving
- the result set data fails (Zeev)
-- Improved the resource mechanism - resources were not getting freed as soon
- as they could (Zeev)
-- Added shared memory module for session data storage (Sascha)
-- Fixed session.auto_start (Sascha)
-- Fixed several problems with output buffering and HEAD requests (Zeev)
-- Fixed HTTP Status code issue with ISAPI module (Zeev)
-- Fixed a problem that prevented $GLOBALS from working properly (Zeev, Zend
- library)
-- Ported newest GetImageSize (Thies)
-- Added session compile support in Win32 (Andi)
-- Added -d switch to the CGI binary that allows overriding php.ini values
- from the command line (Zeev)
-- Fixed a crash that would occur if wddx_deserialize did not receive
- a valid packet (Andrey)
-- Fixed a bugglet when redefining a class at run-time (Andi, Zend library)
-- Fixed sem_get() on AIX (Sascha)
-- Fixed fopen() to work with URL's in Win32 (Andi & Zeev)
-- Fixed include_path for Win32 (Andi, Zend library)
-- Fixed bug in ISAPI header sending function (Charles)
-- Fixed memory leak when using undefined values (Andi & Zeev, Zend library)
-- Added output_buffering directive to php.ini, to enable output buffering
- for all PHP scripts - default is off (Zeev).
-- Fixed some more class inheritance issues (Zeev, Zend library)
-- Fixed Apache build wrt to shared modules on FreeBSD/Linux (Sascha)
-- Added session.extern_referer_chk which checks whether session ids were
- referred to by an external site and eliminates them (Sascha)
-- Improved session id generation (Sascha)
-- Improved speed of uniqid() by using the combined LCG and removing
- the extra usleep() (Sascha)
-- Introduced general combined linear congruential generator (Sascha)
-- Made ldap_close back into an alias for ldap_unbind (Andrey)
-- OciFetchInto now resets the returned array in all cases (Thies)
-- Fixed mysql_errno() to work with recent versions of MySQL (Zeev)
-- Fixed a problem with define() and boolean values (Zeev)
-- Fixed inclusion of gd/freetype functions (Sascha)
-- Fixed persistency of MHASH_* constants (Sascha)
-- Oracle is now ZTS-Safe (Thies)
-- Fixed flushing of cached information to disk in DBA's DB2 module (Sascha)
-- OCI8 is now ZTS-Safe (Thies)
-- Fixed is_writeable/is_writable problem; they are both defined now (Andrey)
-- Imported PHP 3.0 diskfreespace() function (Thies)
-- Fixed thread-safety issues in the MySQL module (Zeev)
-- Fixed thread-safe support for dynamic modules (Zeev)
-- Fixed Sybase CT build process (Zeev)
-
-August 9 1999, Version 4.0 Beta 2
-- Fixed a problem when sending HTTP/1.x header lines using header() (Zeev)
-- Win32 builds now include the ODBC module built-in (Zeev)
-- Fixed SYSV-SHM interface (Thies).
-- Updated hyperwave module, made it thread safe
-- Updated pdflib module, version 0.6 of pdflib no longer supported
-- Updated fdf module
-- Built-in phpinfo() links are now turned off by default. They can be turned
- on using the allow_builtin_links INI directive (Zeev)
-- Changed phpinfo() to list modules that have no info function (Zeev)
-- Modified array_walk() function so that the userland callback is passed
- a key and possible user data in addition to the value (Andrey)
-- Fixed ldap_search(), ldap_read() and ldap_list() (Zeev)
-- Fixed Apache information in phpinfo() (sam@breakfree.com)
-- Improved register_shutdown_function() - you may now supply arguments that
- will be passed to the shutdown function (Zeev)
-- Improved call_user_func() and call_user_method() - they now support passing
- arguments by reference (Zeev)
-- Fixed usort() and uksort() (Zeev)
-- Fixed md5() in the Apache module (Thies)
-- Introduced build process for dynamic modules (Stig)
-- Improved ISAPI module to supprt large server variables (Zeev)
-- Imported PHP 3.0 fixes for problem with PHP as a dynamic module and Redhat
- libc2.1 in zlib module (Stefan)
-- Fixed sybase_fetch_object() (Zeev)
-- Made the IMAP module work with PHP 4.0 (Zeev)
-- Fixed a problem with include()/require() of URLs (Sascha, Zeev)
-- Fixed a bug in implode() that caused it to corrupt its arguments (Zeev)
-- Added get_class($obj), get_parent_class($obj) and method_exists($obj,"name")
- (Andi & Zeev)
-- Fixed various inheritance problems (Andi & Zeev, Zend library)
-- Children now inherit their parent's constructor, if they do not supply a
- constructor of their own.
-- Fixed runtime inheritance of classes (parent methods/properties were
- overriding their children) (Zeev, Zend library)
-- Fixed backwards incompatibility with the "new" operator (Andi, Zend library)
-- Fixed bugs in uksort() and ksort() sort ordering (Andrey)
-- Fixed a memory leak when using assignment-op operators with lvalue of type
- string (Zeev, Zend library)
-- Fixed a problem in inheritance from classes that are defined in include()d
- files (Zeev, Zend library)
-- Fixed a problem with the PHP error handler that could result in a crash
- on certain operating systems (Zeev)
-- Apache php_flag values only recognized 'On' (case sensitive) - changed
- to case insensitive (Zeev)
-- Fixed a memory leak with switch statement containing return statements
- (Andi & Zeev, Zend library)
-- Fixed a crash problem in switch statements that had a string offset
- as a conditional (Andi & Zeev, Zend library)
-- Imported PHP 3.0 fixes for rand() and mt_rand() (Rasmus)
-- Added function entries for strip_tags() and similar_text() (Andrey)
-- Fixed a bug in WDDX that would cause a crash if a number was passed in
- instead of a variable name (Andrey)
-- Ported strtotime() function from PHP 3.0 (Andrey)
-- Merged in gdttf stuff from PHP 3.0 (Sascha)
-- buildconf now checks your installation (Stig)
-- XML module now built dynamically with --with-xml=shared (Stig)
-- Added a check for freetype.h - fixed build on RedHat 6.0 (Zeev)
-- Fixed array_walk() to work in PHP 4.0 (Andrey)
-- Ported all remaining date() format options from PHP 3.0 (Andrey)
-- $php_errormsg now works (Andrey)
-- Added locale support for Perl Compatible Regexp functions (Andrey)
-- Informix module ported (Danny)
-- Removed --with-shared-apache (Sascha)
-- Added patch for reverse lookup table in base64_decode (Sascha)
- Submitted by bfranklin@dct.com
-- Merged in PHP 3.0 version of str_replace (Sascha)
-- Added DBA module (Sascha)
-- Added session id detection within REQUEST_URI (Sascha)
-- Merged in HP-UX/ANSI compatibility switch from PHP 3.0 (Sascha)
-- Fixed rpath handling for utilitites built during Apache build (Sascha)
-- Added missing E_ error level constants (Zeev, Zend library)
-- Fixed a bug in sending multiple HTTP Cookies under Apache (Zeev)
-- Fixed implicit connect on the MySQL, mSQL, PostgreSQL and Sybase
- modules (Zeev)
-- Gave PHP 4.0's SNMP extension all the functionality of PHP 3.0.12 (SteveL)
-
-
-July 19 1999, Version 4.0 Beta 1
-- First public beta of PHP 4.0
diff --git a/ChangeLog.3 b/ChangeLog.3
deleted file mode 100644
index 7e87251faf..0000000000
--- a/ChangeLog.3
+++ /dev/null
@@ -1,860 +0,0 @@
-PHP 3.0 CHANGE LOG ChangeLog
-|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-
-December 24 1998, Version 3.0.6
-- Fix GetImageSize() to work with non-standard jpg images
-- Add Mersenne Twister functions (mt_rand, mt_srand, etc)
-- Add str_replace() function
-- Add chunk_split() function
-- Fixed a bug in the memory limit code, in cases where $php_errormsg was
- also used.
-- Add iptcparse() function
-- Adobe FDF supported
-- getallheaders() NULL string fix <michale@utko.fee.vutbr.cz>
-- Add all configuration directives to phpinfo() page
-- Functions pack() and unpack() rewritten to be binary and buffer overrun
- safe and behave like the Perl functions for all implemented format codes.
-- Ensured that msql_error() will not return error messages generated by
- previously-run scripts.
-- Add base_convert() function
-- Make sprintf() and printf() output binary safe
-- Made gzgetc binary safe
-- Add convert_cyr_string() and quoted_printable_decode() functions
-- Fix ldap_free_result() core dump bug
-- Add support for current OpenLDAP-2.0-devel library
-- Add php3_asp_tags directive so it can be set from Apache config files
-- Added UTF-8 support in the XML extension
-- Make rand(min,max) safer on older platforms where the low-order bits have
- short cycles.
-- Added new pdf (Portable Document Format) module
-- Added an XML parsing extension using James Clark's "expat" library
-- Optimized parts of the token cache code.
-- Terminate on out-of-memory errors. Until now, PHP could crash in out of
- memory situations (clean-up, no real effect).
-- Unterminated comments in include files were being reported with the wrong line
- number. Fixed.
-- Added ImageCopy() and ImageColorDeallocate(). ImageCopy() is about
- 20% faster than ImageCopyResized(). ImageColorDeallocate() marks
- palette entries free for reuse (by <mka@satama.com>).
-- In the CGI version, it was impossible to access resources (e.g. SQL links,
- images) from user-defined shutdown functions. Fixed.
-- Added optional third parameter to strpos() to specify the offset to
- start searching from.
-- Fixed a crash bug in unset() when unsetting illegal variables (rare).
-- Made ImageInterlace and ImageTransparentColor parameters optional, and made
- them return the current/new settings.
-- Optimized GetImageSize() <thies@digicol.de>.
-- Made odbc_autocommit() without args return status
-- Added connect workaround for OpenLink ODBC
-- Added minimal InterBase support. Tested only on 4.0 & Linux.
-- Fixed some memory leaks and bogus error messages in the URL handler of
- the various file open functions. Should only affect error handling
- in bad URLs.
-
-October 5 1998 Version 3.0.5
-- mysql_field_flags now reports all MySQL flags and the result is suitable
- for automatic parsing. Compatibility warning: The result format has
- changed. If you have scripts parsing the result of this function, you
- may need to adapt them.
-- Made nl2br() binary safe (not that it's of much use).
-- Fixed a bug in the API function getThis(). It affected mostly the dir
- functions, if nested within objects.
-- Fixed a problem in require() in conjunction with switch(), and in some other
- cases. Also fixed an identical problem with the call_user_function() API
- function.
-- Removed -lpthread when compiling with MySQL support. It caused various
- serious problems when compiled into Apache.
-- Add serialize() and unserialize() functions from jkl@njet.net
-- Fix in_addr_t check for systems with in_addr_t in netinet/in.h
-- Add atan2() function
-
-September 22 1998 Version 3.0.4
-- Added uksort() - array key sort using a user defined comparison function.
-- Added 'j' support to date() - generates the day of the month, without
- possible leading zeros.
-- Added support for multiple crypt() encryptions if the system supports it
-- Added optional support for ASP-style <% %> and <%= tags
-- Fixed data loss problems with very large numeric array indices on 64-bit
- platforms (e.g. DEC UNIX).
-- 2 cursor_type parameters for ifx_query() and ifx_prepare changed
- to 1 (bitmask). Added a few constants for use in Informix module.
-- Added php3.ini option ifx.charasvarchar. If set, trailing blanks
- are stripped from fixed-length char columns. (Makes life easier
- for people using Informix SE.)
-- Static SNMP module which compiles with ucd-snmp 3.5.2
-- fixed imap_header & header_info from crashing when a header line
- is > 1024 characters.
-- Added patch for rfc822_parse_adr to return an array of objects instead
- of a single object.
-- Informix Online 7.x & SE 7.x support now fairly complete and stable
-- Add dbase_get_record_with_names() function
-- Added a special case for open_basedir. When open_basedir is set to "."
- the directory in which the script is stored will be used as basedir.
-- Include alloca.c in the distribution for platforms without alloca().
-- Improved stripping of URL passwords from error messages - the length of the
- username/password isn't obvious now, and all protocols are handled properly
- (most importantly, http).
-- Copying objects that had member functions with static variables produced
- undetermined results. Fixed.
-- Added function lstat() and cleaned up the status functions,
- added tests for file status functions (this may break on some plattforms)
-- Fixed is_link() - it was returning always false.
-- Fixed apache_note() - it was corrupting memory.
-- New Function. void get_meta_tags(string filename); Parses filename until
- closing head tag and turns all meta tags into variables prefixed with 'meta_'.
- The below meta tag would produce $meta_test="some string here"
- <meta name="test" content="some string here">
-- Generalized some internal functions in order to better support calling
- user-level functions from C code. Fixes a few sporadic problems related
- to constructors inside eval() and more.
-- Fixed an endless loop in explode(), strstr() and strpos() in case of an
- invalid empty delimiter.
-- rand() now accepts two optional arguments, which denote the requested range
- of the generated number. E.g., rand(3,7) would generate a random number
- between 3 and 7.
-- Added M_PI constant.
-- Added deg2rad() and rad2deg() for converting radians<->degrees.
-- ImageArc() misbehaved when given negative angles, fixed.
-- Fixed a bug in ereg() that may have caused buglets under some circumstances.
-- Added imap_status
-- Shutdown functions, registered via register_shutdown_function(), could never
- generate output in the Apache module version. Fixed.
-- Brought IMAP docs into sync with acutal imap code
-- imap_fetchstructure now takes in optional flags
-- Fix potential core dumps in imap_append and imap_fetchtext_full
-- Fix problem in SetCookie() function related to long cookies
-- Add uasort() function to go along with usort (like sort() and asort())
-- Add port number to Host header as per section 14.23 of the HTTP 1.1 RFC
-- Fix imap_reopen to only take 2 arguments with an optional 3rd flags arg
-- Add optional 2nd argument to imap_close
-- Add CL_EXPUNGE flag to imap_open() flags
-- Fix 4th arg on imap_append(). It was getting converted to a long by mistake.
-- Fix shutdown warning in the LDAP module
-- *COMPATIBILITY WARNING* imap_fetchstructure() "parametres" object and property
- name changed to "parameters" to match the documentation and to be consistent
- with the rest of the API.
-- Delete uploaded temporary files automatically at the end of a request
-- Add upload_max_filesize and correponsing php3_upload_max_filesize directive
- to control the maximum size of an uploaded file. Setting this to 0 would
- completely eliminate file uploads.
-- Force $PHP_SELF to PATH_INFO value when running in CGI FORCE_CGI_REDIRECT mode
-- Add apache_lookup_uri() function which does an internal sub-request lookup
- and returns an object containing the request_rec fields for the URI. (Yes,
- you have to be a bit of a gearhead to figure this one out)
-- Fix a few signed char problems causing functions like ucfirst() not to work
- correctly with non-English charsets
-- md5() function not binary safe - fixed
-
-August 15 1998 Version 3.0.3
-- Changed the name of fopen_basedir to open_basedir, to be a little more
- accurate about what it does.
-- Added Hyperwave module
-- Added config-option (php3_)enable_dl <on/off>. This enables/disables the
- dl() function. In safe-mode dl() is always disabled.
-- Auto-prepended files were crashing under some circumstances - fixed.
-- Win32 mail fixes provided by walton@nordicdms.com
-- Comparing between arrays and/or objects now generates a warning (it always
- returns false, as it used to; no comparison is made)
-- Fixed a bug in the syntax highlighting code, that made ending-double-quotes
- appear twice under certain circumstances.
-- Fix bug in filetype() function related to symlinks
-- Started integrating Informix SE support to PHP configure/makefile setup.
-- gdttf roundoff fixes from ellson@lucent.com
-- Added initial Informix SE support files from Danny Heijl - This code still
- needs to be integrated into the PHP configure/makefile setup and the code
- itself needs more work.
-- return in the global scope now terminates the execution of the current file.
-- Added the ability to register shutdown function(s), via
- register_shutdown_function($function_name).
-- Clean up const warnings
-- Add write support to ftp fopen wrappers
-- Add strspn() and strcspn() functions
-- On systems without strerror use Apache version if compiling as Apache module
-- The PHP start tag was being ignored under some circumstances - fixed.
-- The db, dbase and filepro functions are now Safe-Mode aware.
-- Added config-option (php3_)fopen_basedir <path>. This limits the directory-
- tree scripts can open files in to <path>.
-- Fixed pg_loreadall that didn't always return all the contents in a PostgreSQL
- large object. Also, doesn't pass through anything if method is HEAD.
-- configure fix to create target Apache module dir
-- Fix core dump in imageTTFtext() function
-- Added static IMAP support
-- Syntax highlighting was generating additional whitespace - fixed.
-- Added ucwords. Works like ucfirst, but works on all words within a string.
-- Added array_walk() - apply user function to every element of an array
-- Added usort() - array sort that accepts a user defined comparison function!
-- Added the ability to call user-level functions and object methods on demand
- from the C source using a completely generalized, slick API function.
- Miracles do happen every once in a while.
-- Added constructors. Don't even squeek about destructors! :) (we mean that)
-- Make pg_lowrite() binary safe
-- Fixed mod_charset option in ./setup
-- Fixed rewinddir() and dir()::rewind() under Win32 (they didn't work before).
-- Add Win32 COM support! By-name referencing is supported using the IDispatch
- interface (automation). Available functions - COM_Load(), COM_Invoke(),
- COM_PropGet() and COM_PropSet().
-
-July 20 1998 Version 3.0.2a
-- Fix a quirk in the configuration file parser, the endless fountain of joy
- and fun.
-- Fix a bug in the API function add_method() that made dir() crash.
-
-July 18 1998 Version 3.0.2
-- Compile cleanups for *BSD
-- Add support for the OpenLink ODBC Drivers
-- Add PHP_SELF, PHP_AUTH_* and HTTP_*_VARS PHP variables to phpinfo() output
-- Add workaround for broken makes
-- Add Apache 1.3.1 support (some Apache header files were moved around)
-- Added apache_note() function.
-- Fix order of system libraries and detect libresolv correctly
-- Fixed a bug in the Sybase-DB module. Several numeric field types were
- getting truncated when having large values.
-- Added testpages for unified odbc
-- Fix php -s seg fault when filename was missing
-- Made getdate() without args default to current time
-- Added ImageColorResolve() and some fixes to the freetype support.
-- Added strcasecmp()
-- Added error_prepend_string and error_append_string .ini and .conf directives
- to make it possible to configure the look of error messages displayed by PHP
- to some extent
-- Added E_ERROR, E_WARNING, E_NOTICE, E_PARSE and E_ALL constants, that can be
- used in conjunction with error_reporting()
- (e.g. error_reporting(E_ERROR|E_WARNING|E_NOTICE);
-- Fixed a crash problem with classes that contained function(s) with default
- values.
-- Fixed a problem in the browscap module. Browscap files weren't being read
- properly.
-- Fix -L path in libphp4.module to make ApacheSSL compile without errors
-- Fix StripSlashes so it correctly decodes a \0 to a NUL
-
-July 04 1998 Version 3.0.1
-- echo/print of empty strings don't trigger sending the header anymore.
-- Implemented shift left and shift right operators (<< and >>)
-- Compile fix for cc on HP-UX.
-- Look for beta-version Solid libraries as well.
-- Make GD module show more info in phpinfo().
-- Compile fix for NextStep 3.0.
-- Fix for Oracle extension on OSF/1.
-- Fix gd 1.3 bug in ImageColorAt().
-- pg_loread() hopefully handles binary data now.
-- Turned off some warnings in dns.c
-- Added ImageTTFBBox() and made ImageTTFText() return bounding box.
-- Added constants for Ora_Bind()'s modes.
-- Renamed all hash_*() routines to _php3_hash_*() to avoid clashes with other
- libraries.
-- Changed uodbc default LONG behaviour: longreadlen 4096 bytes, binmode 1.
- The module now actually uses the php.ini settings.
-- New PostgreSQL functions: pg_fetch_row(), pg_fetch_array()
- and pg_fetch_object()
-- Fix a segmentation fault when calling invalid functions in certain
- circumstances
-- Fix bug that caused link-related functions to not pay attention to
- run-time safe mode setting (it was using whatever was set at compile time).
-- Fix bug in exec() function when used in safe mode
-
-June 6 1998 Version 3.0
-- Add checkdnsrr function (check availability DNS records)
-- Add getmxrr function (get MX hostnames and weights)
-- Fixed bug in nl2br() function
-- Fix for an RC5 related problem in the Sybase module, when dealing
- with very long data types.
-- Speed up string concatenation by roughly a factor of 2
-- Add escape-handling to date function
-- Make base64 functions binary safe
-- Add strrpos function to complement strpos function added in RC5
-- Add ltrim function (strips only at the start of string)
-- Add rtrim as an alias to chop() for completeness sake
-- Add trim function (similar to chop, except it strips at the start as well)
-- Added 2 optional args to fsockopen function - errno and errstr
-- Fixed bug in split() function related to leading matches
-- Fixed problem in error_log() function (thanks to Jan Legenhausen)
-- empty("0") was returning true - fixed
-- Removed the old sybsql module. Use the new sybase_*() functions instead.
-- Several fixes to the configuration file parser
-- LDAP fixes - fixed return values on several functions
-
-May 23 1998 Version 3.0RC5
-- The BC math library functions now compile in by default.
-- Fixed a bug in virtual() and other types of SSI's (e.g. <!--#exec). Under
- certain circumstances, this used to result in random problems.
-- Fixed a bug in virtual(). It was misbehaving if it was called before any
- other output.
-- Added mysql.default_port, mysql.default_host, mysql.default_user and
- mysql.default_password ini-file directives.
-- Improved handling of the MySQL default port. It now honors /etc/services
- and $MYSQL_TCP_PORT.
-- Fixed a crash in opening of broken ftp:// URLs, and improved error reporting
- in opening of URLs.
-- Fixed several non-critical scanner issues with syntax highlighting mode and
- the <script language=php> tag.
-- Fixed fseek on windows. (windows only): fseek will not return proper results
- on files opened as text mode. PHP uses binary mode as the default for file
- operations, but this can be overiden by fopen. Do not open files in text
- mode and use fseek on them!
-- Add strpos() function
-- Added zlib module, requires zlib >= 1.0.9
-- Improved the module API implementation. Dynamic modules may now register
- persistent resources (not that it makes much sense, but at least PHP
- won't crash). The API itself remains unchanged.
-- bcmod() wasn't always behaving like modulus should behave (it was behaving
- exactly like GNU bc's % operator). Fixed.
-- Changed the Sybase-DB module to always return strings, instead of auto-typing
- result sets. This was done for consistency with the other database modules,
- and in order to avoid overflows due to the platform-dependant limitations
- of the numeric data types of PHP. You can turn compatability mode on using
- the sybase.compatability_mode directive in the php3.ini file.
-- Fixed problems with the TINYINT field in the Sybase-CT module.
-- Applied some small speed optimizations to the Sybase-DB module querying code.
-- Added 'numeric' and 'type' properties to the object returned by
- sybase_fetch_field().
-- The 'new' operator doesn't accept all expressions anymore. Instead, it
- accepts a class name, or a variable reference (scalar, array element, etc).
-- Add ora_numcols() function
-- Add ora_do() and ora_fetch_into() functions to Oracle driver
-- Add persistent connection support to Oracle driver
-- Make Oracle driver clean up open connections and open cursors automatically
-- Added fread() and fwrite() that properly handle binary data.
-- Add Ora_ColumnSize() to Oracle code
-- The string "0" means FALSE again. This was done in order to maintain type
- conversion consistency.
-- Added solid_fetch_prev() for fetching the previous result row from Solid.
-- Huge integers are now automatically converted to floating point numbers
- (that have a wider range).
-- Floating point numbers are now displayed using scientific notation when
- they're extremely big or extremely small. The 'precision' php3.ini directive
- no longer designates the number of decimal digits, but rather, the maximum
- number of significant digits required.
-- Added support for scientific notation for floating point numbers (e.g. 1E7)
- throughout the entire language.
-- Fixed a potential/probable memory corruption problem with HEAD request
- handling.
-- Using un-encapsulated strings now generates a NOTICE-level warning
- (e.g. $a = foo; instead of $a = "foo";)
-- Added defined("name") function to check if a certain constant is defined
- or not.
-- Support new Apache mechanism for setting SERVER_SUBVERSION
-- Added PHP_OS and PHP_VERSION constants
-- Added the ability to define constants in runtime! Constants are script-wide,
- (there's no scope, once the constant is defined, it's valid everywhere).
- Syntax is define("name", $value [, $case_insensitive]). 'name' can be any name
- that is a valid variable name, *without* the $ prefix. 'value' can be
- any *scalar* value. If the optional 'case_insensitive' parameter is 1,
- then the constant is created case-insensitive (the default is case
- sensitive). Note: define() is currently *NOT* supported in preprocessed
- scripts.
-- Added general support for constants. The Syslog constants (e.g.
- LOG_ERR, LOG_CRIT, etc.) should be accessed as constants from now on (that
- is, without a $ prefix). You can still set define_syslog_variables to On
- in the php3.ini file if you want to define the various $ variables. The
- default for this directive in the php3.ini-dist file has been changed to
- Off.
-- The configuration file path variable now expands . and .. into their
- respective directories. You can obtain the path of the php3.ini file
- that was used by printing get_cfg_var("cfg_file_path").
-- Fixed a crash-recovery parser crash ($a=7; $a[3]+=5;)
-- Add gmmktime() function
-- Fixed a crash with implode() and empty arrays.
-- Fixed a bug that, under fairly rare circumstances, caused PHP not to
- recognize if(), require() and other statements as statements, and
- to complain about them as being unsupported functions.
-- Beautified php3.ini-dist and added more comments to it. Also changed
- the behavior of the configuration file parser to be brighter about
- the various constants (TRUE/FALSE/ON/OFF etc).
-- Fixed a bug in openlog() - the specified device name was being mangled.
-- Memory leaks were sometimes reported erroneously - fixed.
-- Improved the convertor to handle some quirks of the PHP/FI 2 parser with
- comments.
-- Fixed number_format() to properly handle negative numbers, and optimized it
- a bit.
-- Fixed static variables inside class member functions. Note that using such
- static variables inside member functions usually defeats the purpose of
- objects, so it is not recommended.
-- Fixed a bug in fpassthru() (the file was being closed twice).
-- Added strftime().
-- Add set_socket_blocking() function to control blocking on socket fd's
-- The sendmail_path in php3.ini was being ignored - fixed.
-- Fixed a bug with file upload, with files that contained the MIME boundary
- inside them.
-- Fixed a bug with form variables of type array, with spaces in their
- index (e.g. name="foo[bar bar]").
-- gd-1.3 autodetect and support
-- Year 2000 compliance is now togglable from the php3.ini file. Setting PHP
- to be y2k compliant effects the way it creates cookies, and means it'll
- NOT work with many browsers out there that are not y2k compliant! For
- that reason, the default for this option is off.
-- safe mode / fix from monti@vesatec.com
-- Integrated the FreeType support in the GD extension.
-- Added --with-gd=DIR and --without-gd options to configure
-
-April 18 1998 Version 3.0 Release Candidate 4
-- Auto-prepended and auto-appended files were reporting the wrong filename
- in errors and in __FILE__ - fixed.
-- Fix GPC problem related to mixed scalar and array vars with the same name
-- Made putenv() Apache-safe. Environment variables may no longer leak in
- between requests.
-- The trailing semicolon is no longer required in class declarations.
-- Fixed a memory leak in the (array) and (object) operators under certain
- conditions.
-- <script> tags weren't working unless short tags were enabled - Fixed.
-- Fixed a bug in certain array indices that weren't treated as numbers
- even though they looked like numbers (e.g. "10", "20").
-- Changes to support renamed API functions in Apache-1.3
-- Fixed the -p and -e command line switches
-- Fix a segfault when calling command line version without parameters
-- Fix for feof() when used on a socket
-- Fix off-by-one error in fgets() when used on a socket
-- Fix bug in ImageSetPixel() (Thanks to ecain@Phosphor.net)
-
-March 31 1998 Version 3.0 Release Candidate 3
-- Tiny bugfix for magic_quotes_sybase
-- Fix Apache build problems introduced in RC2
-- $a["0"]==$a[0] fix
-- Apache-1.3 build changes to support 100% automatic builds and shared library
- module builds. See INSTALL file.
-
-March 30 1998 Version 3.0 Release Candidate 2
-- Changed the socket implementation under UNIX to not use FILE pointers, in
- order to work around the buggy Solaris libc (and possibly buggy libc's
- in other platforms).
-- Fixed a bug in min() and max() with certain arrays.
-- *WARNING* Move Apache 1.3 php3 file install to src/modules/php4 instead of
- src/modules/extra. Make sure you change your AddModule line correctly
- in your Apache Configuration file. This change is to take advantage of
- new Apache-1.3 configuration mechanism which makes it easier to build an
- Apache server with PHP automatically enabled. It will also help building
- a shared library module version of PHP soon.
-- Fixed a crash bug with auto-appended files.
-- Made --enable-discard-path work on all Unix servers #!/path/php CGI scripts
- should now work everywhere. I have tested on Apache, WN and Netscape 2.0
-- Made $a["123"] and $a[123] be identical. $a["0123"] is still different,
- though.
-- Added 'precision' ini directive, to set the number of decimal digits
- displayed for floating point numbers (default - 6).
-- Made integer/integer divisions evaluate to floating point numbers when
- applicable (e.g., 5/2==2.5(float), but 4/2==2(int))
-- Get rid of reliance on tied streams and move all socket reads and writes
- to recv/send calls
-- Cleaned up head.c a bit and fixed CGI SetCookie order problem
-- Changed default variable parsing order to Get-Cookie-Post (GPC)
-- Fixed setup so it has all configure options and defaults.
-- Added optional decimal point and thousands seperator to number_format()
- e.g., number_format(1500,2,',','.') == 1.500,00
-- Fixed cgi bug in windows that prevented files from being parsed on many
- systems and servers.
-
-March 23 1998 Version 3.0 Release Candidate
-- Added support for the Raima database (ALPHA)
-- Fixed a bug in persistent PostgreSQL links and the connection-string method.
-- Added EXTENSION_STATUS file, that specifies the stability and status of
- every module in the distribution.
-- Added optional parameters to user functions with default values, variables
- that are forced to be passed by reference and variables that can be
- optionally passed by reference. The ini file directive
- 'ignore_missing_userfunc_args' is no longer supported.
-- Added fhttpd support (by Alex Belits)
-- Improved performance by approximately 20-30%.
-- Added mysql_error(), mysql_errno() (if available) and msql_error().
- Errors coming back from the database backend no longer issue warnings.
- Instead, use these functions to retreive the error.
-- Patched count(), each(), prev(), next(), reset() and end() to work around
- the implementation side effects of unset(). As far as the users are
- concerned, this should be transparent now (even though it's slower now,
- until it's thoroughly fixed in 3.1).
-- Added number_format(). number_format(2499,2)=='2,499.00'.
-- error_reporting() now sets the error reporting level to the supplied
- argument, without any interpretations.
-- Fixed a lookahead parser bug that occured under rare circumstances.
-- Change the comparison operators to compare numeric strings as numbers. If
- you want to compare them as strings, you can use the new C-like strcmp()
-- Fixed Ora_GetColumn() bug when fetching strings
-- Added Ora_ColumnName() and Ora_ColumnType()
-- Preliminary LONG and LONG RAW support in Oracle extension
-- Add \123 and \xAB style octal and hex escapes to "" and `` strings
-- Add "-c" command line flag for specifying path to php3.ini file
-- Improved list() so that elements can be skipped, for example:
- list($name,,,$realname) = explode(":",fgets($passwd_file));
-- Fixed a tiny bug in the hash initialization which caused excessive use of
- memory. Report and fix by short@k332.feld.cvut.cz
-- Fixed strtolower() and strtoupper() to work with 8-bit chars
-- Fixed to compile and run on SunOS 4.1
-- Fixed a crash in soundex() of an empty string
-- Fixed parse_str() - it wasn't always defining the right variables,
- and didn't work with arrays.
-- Made [m,My]SQL create/drop database functions return success status
-- Fixed some memory leak/crash problems in the Adabas module
-- Added each() in order to allow for easy and correct array traversing.
-- Make Apache module version respect LOCALE setting
-- Add support for Apache 1.3b6+ ap_config.h file
-- Fixed a nasty corruption bug in eval() and show_source() that resulted in
- script termination (e.g. eval("exit();").
-- Fixed a syntax highlighting problem with keywords used as variable
- names.
-- Fixed a possible crash and/or file descriptor leak
-- Fixed line number being off by one in #! shell style execution
-- Made it possible to disable auto_prepend/append with "none" filename
-- Allow safe CGI calling through #!php style scripts
-
-March 2 1998 Version 3.0b6
-- Made [s]printf handle %ld
-- Changed CGI version to only open regular files as input script
-- Added ignore_missing_userfunc_args directive to suppress warnings messages
- about missing arguments to user-defined functions
-- Added Postgres function - pg_cmdtuples(), by Vladimir Litovka
-- Disabled command line options if used as CGI
-- Changed CGI version to use PATH_TRANSLATED as the script file name
-- Link with solid shared library instead of static one
-- Fixed a crash with functions that aren't being called correctly
-- Fixed file descriptor leak in auto-prepend/append
-- Imap module is usable. See README in dl/imap.
-
-February 24 1998 Version 3.0b5
-- Made the URL aware file functions be enabled by default
-- Fixed an unlikely crash bug in the parser, with uninitialized array elements
- which are refered to as objects.
-- Fixed several fields that were being incorrectly read in Sybase CT.
-- Fix Apache-1.3 related SIGHUP problem which was preventing php3.ini from
- getting re-read on a SIGHUP
-- *** WARNING *** Downwards incompatible change: The plus operator (+) is not
- longer overloaded as concatenation for strings. Instead, it converts its
- arguments to numbers and performs numeric addition.
-- Add Stig and Tin's bdf2gdfont script to extra/gd directory
-- Added join() as an alias to implode()
-- Made implode() accept arguments in the order used by explode() as well
-- Made $php_errormsg local in function calls
-- Fixed Apache configuration directive bugs
-- Added a number of .ini directives to Apache .conf directive list
-- Fixed a 'memory leak' with strtok()
-- echo/print now handle binary data correctly.
-- NEW now accepts any expression for the class name argument.
-- Add ImageDashedLine() GD function
-- Add arg_separator .ini directive so the '&' GET method separator can be
- changed to ';' for example. Corresponding php3_arg_separator Apache .conf
- directive works as well.
-- Walked around an implementation side effect of switch(). <? switch(expr) { ?>
- now works.
-- Added memory caching, resulting in a significant performance boost
-- Added support for for(): .. endfor; loops
-- Added a new predicate - empty($var). Returns true if $var is not set,
- or is FALSE. Returns false otherwise.
-- Added is_integer() (same as is_long()) and is_real() (same as is_double()).
-- Added sizeof() as an alias to the count() function
-- Added --enable-force-cgi-redirect, to prevent the CGI from working if
- someone directly accesses PHP not through Apache's CGI redirect
- (off by default).
-- Fixed marking of deleted dBase records. Noticed by Simon Gornall
- <simon@oyster.co.uk>.
-- Fixed fixed "%%" bug in [s]printf
-- Fixed a UMR (initialized memory read) in the Oracle code
-- Potential fix for mysql-related SIGPIPE problem which caused httpd to spin
-- Made PHP responsive to the Apache link status (stop executing if the link
- dies).
-- Fixed a crash bug with StrongHold and secure pages
-- Fixed StrongHold installation
-- Optimized the function call sequence a bit.
-- Fixed Sybase/CT date/datetime/money fields work to correctly.
-- Fixed Apache module startup problems - php3_module_startup should only be
- called once.
-- Fixed ord() with characters >127
-- Fixed bug in file_exists() function
-- Fixed stripslashes() to remove the escaping quote (instead of backslash)
- in case magic_quotes_sybase is true.
-- Also make echo and print automatically remove trailing decimal zeros.
-- Added htmlentities(), currently handling only ISO-8859-1 entities
-- "0" is no longer considered false, the only string which is false is the
- empty string "".
-- Added 'true' and 'false' keywords
-- Added 'xor' (logical exclusive or)
-- Automatic conversion from double to string removes decimal trailing zeros.
-- Added arsort() and rsort() to sort in descending order.
-- Turned on "XLATOPT_NOCNV" by default for uODBC/Solid.
-- Added support for a port number in the mysql_(p)connect() functions
-- Fixed a file descriptor leak in the configuration parser.
-- Fixed a few buglets with syntax highlighting with certain language keywords
-- Added functions to control minimum severity level of Sybase messages to
- display.
-- Added highlight_string() - behaves like highlight_file(), only instead
- of highlighting a file, it syntax highlights the contents of its
- argument.
-- Renamed show_source() to highlight_file(). show_source() is still
- supported for downwards compatability.
-- Fixed a bug in class inheritence - member functions with upper case
- letters in their names couldn't be redefined.
-- Made chown(), chgrp() and chmod() return TRUE/FALSE instead of 0/-1.
-
-February 02 1998 Version 3.0b4
-- Fixed a segfault bug in one of the unified ODBC error messages.
-- Set default file modes to binary on Win32 (solved a lot of bs)
-- Fixed file copy on Win32
-- MIME file uploads fixed on Win32
-- Added contributed icons by Colin Viebrock (undex extra/icons)
-- Fixed the debugger enough to call it "beta code".
-- Fixed some leaks in the Oracle module, tidied up the code a bit.
-- Added __FILE__ and __LINE__ which evaluate to the currently parsed file
- and currently parsed line respectively.
-- Added ImageColorAt(), ImageColorSet(), ImageColorsForIndex(), and
- ImageColorsTotal() to allow manipulating the palette of GIF images.
-- Rename '--enable-url-includes' option to '--enable-url-fopen-wrapper' to
- better describe what it does, and pay attention to the setting.
-- Added optional parameter to the file(), readfile() and fopen() functions
- to look for files located in the include path.
-- Fixed bug that allowed the file() and readfile() to open files in the
- include path inadvertantly.
-- Fixed a (documented) bug in printf()/sprintf() with hard limited strings
- and alignment (e.g. %-.20s).
-- Optimized several quoted string routines.
-- Added error_log ini directive to select where errors get logged when
- log_errors is turned on or the error_log() function is used.
-- Added the ability to direct errors to log files instead of or in addition
- to the script output. Use the new display_errors and log_errors
- php3.ini directives.
-- Made environment variables uneraseable by POST/GET/Cookie variables.
-- Fixed a bug in the elseif() construct. The expression was being evaluated
- even if a previous if/elseif already evaluated to true and got executed.
-- Fixed a bug in the exit code parameter of system()
-- Tighten up all exec() related functions in safe mode
-- Added error_log() function to log messages to the server error log, or
- stderr for the CGI version.
-- Added support for a general memory limit of scripts.
-- Fixed a segfault bug that occured under certain circumstances with shell
- escapes ($foo = `...`)
-- Made keywords be valid property names of objects.
-- Fixed a segfault bug when creating new objects of an unknown class.
-- Fixed a problem with the maximum execution time limit, that may have
- prevented this feature from working on certain platforms.
-- PHP would now warn you with E_NOTICE about unknown escape characters,
- e.g. "\f". It would still be considered as a backslash followed by f,
- but the proper way of writing this is "\\f" or '\f'.
-- Added support for ${...} inside encapsulated strings. Supported: ${foo},
- ${foo[bar]}, ${foo[0]}, ${$foo[$bar]}, ${$foo->bar} and ${$foo}
-- Fixed a bug in automatic persistent link reconnect of the Sybase/DB module.
- Thanks to Steve Willer for finding that 'stealth' bug!
-- Fixed a crash bug in the GET/POST/Cookie parser in case of regular
- and array variables with the same name.
-- Added round() function.
-- Can't use encapsed strings as variable names anymore, ie. $"blah blah".
-- Fixed bug in gethostby*() functions that resulted in a core dump.
- (Noticed by torben@coastnet.com.)
-- Fixed bug in dbase_get_record that prevented number and date fields
- from being properly decoded. (Thanks again to colins@infofind.com.)
-- Make dbase_get_record include a 'deleted' field that indicates whether
- that record had been marked for deletion.
-- Fixed bug in dbase library that stomped on the deleted flag of the first
- record in the file if it was set. (Thanks to colins@infofind.com.)
-- Fixed putenv() to not report a memory leak and possibly prevent a bug
- from that memory being freed.
-- Added setlocale()
-- Added pg_fieldisnull() (by Stephan Duehr)
-- Changed pg_exec() to always return a result identifier on succees
-- Solid linking fixes (tries to find the right library)
-- Fixed a but with date() and the 'w' element.
-- Tried to eliminate unimportant memory leak notifications.
-- Made min() and max() backwards compatible and able to handle doubles.
-- Add fgetc() function
-- Fixed bug in getmyuid(), getmyinode() and getlastmod(). Thanks to
- khim@sch57.msk.ru for pointing this out.
-- Fixed http:// URL includes with no path specified send request for /.
-- Added GetAllHeaders() (Apache-only)
-- Added workaround that made the Image text functions 8-bit clean
-- Made snmp internally compilable for Win32 (not the unix one though),
- only adds 2k to binary size, so no reason not to have it there.
-- Fixed ldap loading on Win32
-- Fixed MySQL Info function on Win32 platform
-- Fixed compilation of syntax highlighting mode
-
-January 17 1998 Version 3.0b3
-- Added mysql support under windows ;) happy happy joy joy
-- Fixed dbase.dll for Win32 to actualy load now.
-- Enhanced the convertor to recognize ?> as a php-close-block as well.
-- Fixed potential SetCookie() core dumps
-- Changed print to be an expression instead of a statement. That means you can
- now do stuff like foobar() or print("Unable to foobar!"). echo has NOT been
- changed.
-- Removed the flex optimization flags to reduce the size of the scanner
-- Added memory leak logging into apache log files (apache module only)
-- Fixed a nasty bug in one of the internal stacks. This may have caused
- random crashes in several occassions.
-- Fixed bug in ImageGif() making it hang sometimes
-- Added ImageLoadFont(), ImageFontWidth() and ImageFontHeight()
-- error_reporting() now returns the old error reporting level
-- Fixed url includes/opens not working under Win32
-- Fixed errorneous handling of multipart/form-data input
-- Added rawurlencode(), rawurldecode() and changed urlencode() and urldecode()
- a bit too.
-- Fixed a bug in [s]printf, sign was forgotten for doubles.
-- Fixed a segfault bug in pg_fieldprtlen(), and made it accept field names
- in addition to field offsets.
-- Made the setup script a little more user-friendly.
-- Added is_long(), is_double(), is_string(), is_array() and is_object()
-- Fixed a bug in freeing of mSQL results.
-- Improved pg_exec() to properly return true or false with queries that don't
- return rows (i.e. insert, update, create, etc)
-- Added get_cfg_var() to enable checking cfg file directives from within
- a script.
-- Fixed a bug with urlencode() and characters 0x80-0xff
-- Changed the behaviour of ereg_replace to more intuitive. The
- backslashes other than valid existing back references in the second
- argument are no more evaluated as escape sequences.
-- Fixed a bug in the configuration file loader and safe mode.
-- Fixed a bug with configuration variables taken from the environment.
-- Added <script language=php> </script> as PHP open/close tags, to allow
- the use of editors such as Microsoft Frontpage.
-- Fixed a bug in the default php3.ini directory - it wasn't defaulting to
- /usr/local/lib properly.
-- Added support for \r\n line endings
-- Fixed a bug that may have prevented POST method variables from working
- with certain scripts when using the CGI version.
-- Convertor: Added support for single-quoted strings
-- Fixed segfault bug in the Adabas module, with queries that don't return
- rows (update, insert, etc).
-
-December 22 1997 Version 3.0b2
-- Changed variable type conversions that do not specify base to always use
- base 10. "010" is no more 8, it is 10. Use intval ($x, 0) to get C-style
- octal and hex numbers recognized.
-- Fixed a possible segfault bug in several functions, when using the concat
- operator and possibly other operators/functions.
-- # is no longer accepted as a comment in php3.ini. Use ; instead.
-- Added browscap support
-- Configuration file directives are now case-sensitive
-- Fixed msql_tablename() and msql_dbname()
-- Added a PHP/FI 2.0 -> PHP 3.0 convertor
-- Added support for shell/perl-style single quotes
-- Added support for execution of external programs using backquotes ($a=`ls -l`)
-- fixed mail() on windows, also fixed memory leaks in mail on windows
-- added sendmail_from to handle return route on windows
-- Changed the way the config file is searched. The file name is now
- php3.ini (hardcoded), and it'll be looked for in: local directory, $PHPRC
- and builtin path designated by ./configure under UNIX or Windows directory
- under Windows.
-- Fixed ereg_replace replacing empty matches and a one off buffer overflow
-- Fixed File upload on windows platform
-- Fixed a bug that caused 'HTTP/1.1 100 Continue' messages with
- Internet Explorer 4.0 and certain scripts that receive POST variables
-- Get/POST/Cookie data variables are from now *ALWAYS* strings. If you want
- to use them in integer/real context, you must explicitly change their types.
- This was done in order to avoid possible loss of data when doing these
- conversions automatically.
-- Variables named as keywords are now allowed (e.g. $function, $class, etc)
-- Fixed a problem with msql() and mysql() with NULL fields
-- Fixed a segfault bug with class declarations
-- Fixed bugs with FOR loops and include() from within eval()
-- Changed include() to be executed conditionally. PHP-3.0 efficient
- unconditional include is now require()
-
-December 08 1997 Version 3.0b1
-- Switched to public beta test phase
-- Generalized unset() and isset() to work on any type of variables, including
- specific array indices or object properties (e.g., unset($a[4]) now works).
-- Added support for object references inside encapsulated strings
- (for example, 'echo "Username: $user->name"' now works)
-- Added arbitary precision math support (basic operations with
- unlimited range numbers, and support for unlimited decimal digits)
-- Apache module can now handle preprocessed scripts (by using:
- AddType application/x-httpd-php3-preprocessed .php3p
- in the Apache configuration)
-- Made settype() pass its first parameter by value. Improved it to be able
- to convert to arrays and objects (originally by Steve Willer)
-- Implemented CPU time limit on scripts when setitimer() is available
-- Computed field names in the Sybase/CT and Sybase/DB modules are now named
- computed, computed1, computed2, ...
-- Added Sybase/CT client/server message handlers and updated the Sybase/DB ones
-- Made the regexp function automatically take arguments by reference
- when necessary
-- Added builtin support for auto append and prepend in the parser level
-- Improved the Sybase/CT sybase_query(). Should be more stable now, and
- hopefully work with a wider range of queries. It's difficult to work
- without docs, though, so it may still not be 100% right...
-- Changed error messages to show error type, file and line with bold
-- Added support for autoprepend and autoprepend
-- Added some more warning flags if gcc is used
-
-December 03 1997 Version 3.0a4
-- Improved the internal functions API - no need to explicitly pass
- parameters by reference to internal functions that specifically
- require them, e.g. sort(), ksort(), reset(), count(), etc.
- This is *STILL* downwards compatible with the previous alphas,
- in the sense that you can explicitly pass the arguments by reference
- if you want to.
-- use srandom/random instead of srand/rand if available
-- Added [m,My]sql_listfields() for downwards compatability
-- -p now replaces .php3 extension with .php3p (otherwise it adds .php3p)
-- Added C++ style comments (// comment)
-- Fixed # commenting to terminate at a close PHP tag
-- Added \0 back reference for full string match to *reg*_replace and
- added backslash escaping to replace string
-- Fixed a few bugs in the Sybase DB-library module.
-- Added Sybase CT-library support. It should be considered experimental.
- Syntax is identical to the one of the DB-library. Allows people to
- connect to MS-SQL servers from Linux without having to pay for a
- library!
-- Beautified phpinfo()
-- Add ImageColorClosest() and ImageColorExact() GD functions
-- Make all .ini directives work as Apache .conf directives as well
-- Added PHP2-like File() function with PHP3 URL support
-- Upgraded the Sybase interface. It's practically MySQL compatible now!
- Among other things, added sybase_fetch_array() and sybase_fetch_object().
-- Fixed problem in multi dimensional array handling and self modifying
- operators (+=, -=, etc).
-- Safe Mode file open implementation
-- SVR3 portability problem fix
-
-November 23 1997 Version 3.0a3
-- Made the global statement behave like PHP 2 with undefined variables
-- Added msql_fetch_object() and msql_fetch_array()
-- Switched between the 1st and 2nd parameters to explode(), so that it acts
- like split()
-- Fixed passthru(), exec() and system() functions
-- Implemented second optional parameter to intval() to specify conversion base
- (The default is to assume you want to do a base 10 conversion.)
-- Implemented SQL safe mode for MySQL
-- Read UploadTmpDir from php3.ini instead of apache conf files
-- Added mysql_fetch_object() and mysql_fetch_array()
-- Changed function->old_function. function is now an alias to cfunction.
-- Split the magic_quotes directive to get/post/data and other
-- Added generic copy() function
-- Added a $GLOBALS[] array, which contains all global variables
-- Fix broken getimagesize() function
-- Made mysql_fetch_field() and msql_fetch_field() optionally accept a 2nd argument
-- Fixed mysql_data_seek() and msql_data_seek()
-- Changed list assignment to list(...) and array init to array(...)
-- Made <?php_track_vars?> work
-- cgi when not in debug mode uses regular malloc(), free() functions now
-- Added preliminary support for perl-style list assignments
-- Fixed a bug in mysql_result() and msql_result() when specifying table
-- renamed internal error-handling function and levels
-- Added basename and dirname functions similar to sh counterparts
-- Added base64_encode() and base64_decode()
-- Support Basic authorization for http url includes
-- Added parse_url() function to extract url components
-- Made it possible to use anonymous ftp on URL includes
-- Fixed url includes to handle different URLs better
-- Fixed mysql_field*() functions
-- Made mysql_connect() smarter, after a mysql_close() (applies to msql and pgsql too)
-
-November 6 1997 Version 3.0a2
-- Fixed a segfault bug caused by non-persistent connect in [m,My,Postgres]SQL modules
-- Fix command line argument handling
-- Made empty array list assignments work ($a=({});)
-- Made '$' escaping optional when a variable name parsing isn't possible
-- Added support for mysql_[p]connect(host) and mysql_[p]connect(host,user)
-- New layout in phpinfo()
-- Update Oracle extension to use php3_list functions
-- Add includepath support
-- Add #!php shell script escape support
-- Change name of CGI/command line version from php3.cgi to php
-- Add SNMP extension
-- show_source() support
-- Parsing of command-line args for CGI version
-- Support for backreferences in ereg_replace
-- Support for hexadecimal numbers directly at the scanner level
-- Support octal numbers directly at the scanner level
-- Fixed problem with huge html files (with little or no php code)
-- Fix eval() empty string argument core dump
-- renamed 'install' to 'setup' to be more accurate and avoid name conflict
-- Fixed Oracle compilation
-- Fixed mSQL 1.0 compilation
-- Fixed a problem in the mSQL, MySQL and PostgresSQL drivers and NULL fields.
-- Fixed the GLOBAL statement to be able to declare an array.
-
-October 29 1997 Version 3.0a1
-- Start with excellent new parser from Andi and Zeev
diff --git a/ChangeLog.TODO b/ChangeLog.TODO
deleted file mode 100644
index 17b9223544..0000000000
--- a/ChangeLog.TODO
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-This is the ChangeLog from PHP3 as of Apr 12 1999.
-
-Entries should be removed from this file, if you transfer changes
-over to PHP4.
-
-============================================================================
-
-?? 1999, Version 3.0.8
-- added Oracle-OCI8 persistent connections
-- fixed OCIDefineByName crash.
-- fixed some NULL-column related problems in OCI8-module.
-- Some Informix driver improvements.
-- PUT method support (mlemos@acm.org)
-- Fix parameter count problem in odbc_setoption()
-- Really fix implode() this time. The fix in 3.0.7 was bogus
-- Make fgetss() slightly smarter
-- Add strip_tags() which uses the fgetss state-machine but acts on a string
-
-March 1 1999, Version 3.0.7
-- Added pdf_put_image and pdf_execute_image
-- Initial work on an ImageMagick module - doesn't do anything yet
-- Make configure script detect Netscape's LDAP SDK automagically
-- Fixed Oracle-OCI8 module for windows.
-- Add OCIRowCount function. (Number of affected rows for update-statements)
-- Add OCIDefineByName function.
-- Change the behaviour of open_basedir. It's now possible to supply more
- than one directory. open_basedir paths from parent directories are now
- automatically inherited.
-- fix rand() and mt_rand() to make the ranges work correctly
-- htmlspecialchars() and htmlentities() are now binary safe.
-- Add extract() function.
-- Oracle-OCI8 driver now supports BLOBS/CLOBS and IN/OUT binding of local php
- variables.
-- Clean up apxs build
-- Add INSTALL.REDHAT file to walk RedHat users through the install
-- Add function_exists() function.
-- Add another version of WDDX module
- (we need to pick a single implementation here)
-- Fixed includes for iODBC to support both the old and the new LGPL version
-- Fix implode() bug - When imploding an array that contained unset() elements
- it wasn't correctly skipping past these
-- Add connection_status() function. This returns the raw bitfield which
- indicates whether the script terminated due to a user abort, a timeout
- or normally. Note that if ignore_user_abort is enabled, then both the
- timeout state and the user abort state can be active
-- Add connection_timeout() function. This one can be called in a shutdown
- function to tell you if you got there because of a timeout
-- Add ignore_user_abort() function and .ini/.conf directive of same name
-- Fix connection abort detection code - It should now work reliably with
- Apache. Also added a user-level connection_aborted() function designed to
- let people check whether the user aborted the connection in a user-level
- shutdown function.
-- Add pfsockopen() function
-- Improvements in FreeType support: Macintosh fonts work, and non-antialiased
- output is considerably cleaner <mka@satama.com>
-- Fixed checkdate() function, range of valid years is now 0 to 32767
-- hw_insertdocument() returns object id now
-- Add pdf_open() warning in configure and documentation
-- Add diskfreespace() function
-- Added aspell support
-- Iptcparse would sometimes find a wrong tag.
-- Force var_dump() to output headers
-- Add optional 3th parameter to ora_fetchinto.
-- Serialize and var_dump no longer show array elements that
- have been unset.
-- Add IptcEmbed() function (can replace an APP13-Marker in a JPEG file)
-- Add OCI8 module for Windows
-- Fix bug in pdf_close() function
-- Add WDDX support (see http://www.wddx.org for more info)
-- Add similar_text() function
-- Introduce simple regex compilation cache
-
-
diff --git a/FUNCTION_LIST.txt b/FUNCTION_LIST.txt
deleted file mode 100644
index 2d567f7be6..0000000000
--- a/FUNCTION_LIST.txt
+++ /dev/null
@@ -1,538 +0,0 @@
-Functions:
-
-Functions marked with 'u' do not work, or may not work correctly under windows.
-
-basic_functions
- include
- _include
- isset
-
- intval
- doubleval
- strval
- short_tags
- sleep
-u usleep
- ksort
- asort
- sort
- count
- chr
- ord
- flush
- end
- prev
- next
- reset
- current
- key
- gettype
- settype
- min
- max
-
- addslashes
- chop
- pos
-
- fsockopen
- getimagesize
- htmlspecialchars
- md5
-
- parse_url
-
- parse_str
- phpinfo
- phpversion
- strlen
- strtok
- strtoupper
- strtolower
- strchr
- basename
- dirname
- stripslashes
- strstr
- strrchr
- substr
- quotemeta
- urlencode
- urldecode
- ucfirst
- strtr
- sprintf
- printf
-
- exec
- system
- escapeshellcmd
- passthru
-
- soundex
-
- rand
- srand
- getrandmax
- gethostbyaddr
- gethostbyname
- explode
- implode
- error_reporting
- clearstatcache
-
- get_current_user
- getmyuid
- getmypid
-u getmyinode
- getlastmod
-
- base64_decode
- base64_encode
-
- abs
- ceil
- floor
- sin
- cos
- tan
- asin
- acos
- atan
- pi
- pow
- exp
- log
- log10
- sqrt
- bindec
- hexdec
- octdec
- decbin
- decoct
- dechex
-
- getenv
- putenv
-
- time
- mktime
- date
- gmdate
- getdate
- checkdate
- microtime
- uniqid
-
-u linkinfo
-u readlink
-u symlink
-u link
-u unlink
-
-
-bcmath_functions
- bcadd
- bcsub
- bcmul
- bcdiv
- bcmod
- bcpow
- bcsqrt
- bcscale
- bccomp
-
-dir_functions
- opendir
- closedir
- chdir
- rewinddir
- readdir
- dir
-
-dl_functions
- dl(string module_name); dynamicly load a module
-
-dns_functions
- gethostbyaddr
- gethostbyname
-
-file_functions
- pclose
- popen
- readfile
- rewind
- rmdir
- umask
- fclose
- feof
- fgets
- fgetss
- fopen
- fpassthru
- fseek
- ftell
- fputs
- mkdir
- rename
- copy
- tempnam
- file
-
-filestat_functions
- fileatime
- filectime
-u filegroup
-u fileinode
- filemtime
-u fileowner
- fileperms
- filesize
- filetype
- stat
-u chown
-u chgrp
-u chmod
- touch
- file_exists
- is_executable
- is_dir
- is_readable
- is_writeable
-u is_link
-
-header_functions
- setcookie
- header
-
-mail_functions
- mail
-
-reg_functions
- ereg
- ereg_replace
- eregi
- eregi_replace
- split
- sql_regcase
-
-syslog_functions (writes to event log on win NT)
- openlog
- syslog
- closelog
-
-The following are optional modules and may or may not be compiled into php, or may be compiled as a loadable module.
-
-odbc_functions (obsolete, use uodbc below)
- sqlconnect
- sqldisconnect
- sqlfetch
- sqlexecdirect
- sqlgetdata
- sqlfree
- sqlrowcount
-
-uodbc_functions
- (int) odbc_autocommit($connection_id, $OnOff)
- (void) odbc_close($connection_id)
- (void) odbc_close_all(void)
- (int) odbc_commit($connection_id)
- (int) odbc_connect($dsn, $user, $password)
- (int) odbc_pconnect($dsn, $user, $password)
- (string) odbc_cursor($result_id)
- (int) odbc_do($connection_id, $query_string)
- (int) odbc_exec($connection_id, $query_string)
- (int) odbc_prepare($connection_id, $query_string)
- (int) odbc_execute($result_id, $array)
- (int) odbc_fetch_row($result_id, $row_number)
- (int) odbc_fetch_into($result_id, $row_number, $array_ptr)
- (int) odbc_field_len($result_id, $field_number)
- (string) odbc_field_name($result_id, $field_number)
- (string) odbc_field_type($result_id, $field)
- (int) odbc_free_result($result_id)
- (int) odbc_num_fields($result_id)
- (int) odbc_num_rows($result_id)
- (string) odbc_result($result_id, $field)
- (int) odbc_result_all($result_id, $format)
- (int) odbc_rollback($connection_id)
-
-msql_functions
- msql_connect
- msql_pconnect
- msql_close
- msql_select_db
- msql_create_db
- msql_drop_db
- msql_query
- msql
- msql_list_dbs
- msql_list_tables
- msql_list_fields
- msql_result
- msql_num_rows
- msql_num_fields
- msql_fetch_row
- msql_fetch_array
- msql_fetch_object
- msql_data_seek
- msql_fetch_field
- msql_field_seek
- msql_free_result
- msql_fieldname
- msql_fieldtable
- msql_fieldlen
- msql_fieldtype
- msql_fieldflags
- msql_regcase
- /* for downwards compatability */
- msql_selectdb
- msql_createdb
- msql_dropdb
- msql_freeresult
- msql_numfields
- msql_numrows
- msql_listdbs
- msql_listtables
- msql_listfields
- msql_dbname
- msql_tablename
-
-ldap_functions
- ldap_connect
- ldap_bind
- ldap_unbind
- ldap_read
- ldap_list
- ldap_search
- ldap_free_result
- ldap_count_entries
- ldap_first_entry
- ldap_next_entry
- ldap_get_entries
- ldap_free_entry
- ldap_first_attribute
- ldap_next_attribute
- ldap_get_attributes
- ldap_get_values
- ldap_get_dn
- ldap_dn2ufn
- ldap_add
- ldap_delete
- ldap_modify
-
-gd_functions
- imagearc
- imagechar
- imagecharup
- imagecolorallocate
- imagecolorclosest
- imagecolorexact
- imagecolortransparent
- imagecopyresized
- imagecreate
- imagecreatefromgif
- imagedestroy
- imagefill
- imagefilledpolygon
- imagefilledrectangle
- imagefilltoborder
- imagegif
- imageinterlace
- imageline
- imagepolygon
- imagerectangle
- imagesetpixel
- imagestring
- imagestringup
- imagesx
- imagesy
-
-filepro_functions
- filepro
- filepro_rowcount
- filepro_fieldname
- filepro_fieldtype
- filepro_fieldwidth
- filepro_fieldcount
- filepro_retrieve
-
-dbm_functions
- dblist
- dbmopen
- dbmclose
- dbminsert
- dbmfetch
- dbmreplace
- dbmexists
- dbmdelete
- dbmfirstkey
- dbmnextkey
-
-dbase_functions
- dbase_open
- dbase_create
- dbase_close
- dbase_numrecords
- dbase_numfields
- dbase_add_record
- dbase_get_record
- dbase_delete_record
- dbase_pack
-
-calendar_functions
- jdtogregorian
- gregoriantojd
- jdtojulian
- juliantojd
- jdtojewish
- jewishtojd
- jdtofrench
- frenchtojd
- jddayofweek
- jdmonthname
-
-adabas_functions
-(int) ada_afetch($result_id, $rownumber, $result array)
-(int) ada_autocommit($connection_id, $OnOff)
-(void) ada_close($connection_id)
- ada_closeall
-(int) ada_commit($connection_id)
-(int) ada_connect($dsn, $user, $password)
-(int) ada_exec($connection_id, $query_string)
-(int) ada_fetchrow($result_id, $row?number)
- ada_fieldlen
-(string) ada_fieldname($result_id, $field_number)
-(string) ada_fieldtype($result_id, $field)
-(int) ada_freeresult($result_id)
-(int) ada_numfields($result_id)
-(int) ada_numrows($result_id)
-(string) ada_result($result_id, $field)
-(int) ada_resultall($result_id, $format)
-(int) ada_rollback($connection_id)
-***(int) ada_fieldnum($result_id, $field_name) (this function is not in adabase.c
-
-crypt_functions
- crypt
-
-mysql_functions
- mysql_connect
- mysql_pconnect
- mysql_close
- mysql_select_db
- mysql_create_db
- mysql_drop_db
- mysql_query
- mysql
- mysql_list_dbs
- mysql_list_tables
- mysql_list_fields
- mysql_affected_rows
- mysql_insert_id
- mysql_result
- mysql_num_rows
- mysql_num_fields
- mysql_fetch_row
- mysql_fetch_array
- mysql_fetch_object
- mysql_data_seek
- mysql_fetch_lengths
- mysql_fetch_field
- mysql_field_seek
- mysql_free_result
- mysql_fieldname
- mysql_fieldtable
- mysql_fieldlen
- mysql_fieldtype
- mysql_fieldflags
- /* for downwards compatability */
- mysql_selectdb
- mysql_createdb
- mysql_dropdb
- mysql_freeresult
- mysql_numfields
- mysql_numrows
- mysql_listdbs
- mysql_listtables
- mysql_listfields
- mysql_dbname
- mysql_tablename
-
-oracle_functions
- ora_close
- ora_commit
- ora_commitoff
- ora_commiton
- ora_error
- ora_errorcode
- ora_exec
- ora_fetch
- ora_getcolumn
- ora_logoff
- ora_logon
- ora_open
- ora_parse
- ora_rollback
-
-pgsql_functions
- pg_connect
- pg_pconnect
- pg_close
- pg_dbname
- pg_errormessage
- pg_options
- pg_port
- pg_tty
- pg_host
- pg_exec
- pg_numrows
- pg_numfields
- pg_fieldname
- pg_fieldsize
- pg_fieldtype
- pg_fieldnum
- pg_result
- pg_fieldprtlen
- pg_getlastoid
- pg_freeresult
- pg_locreate
- pg_lounlink
- pg_loopen
- pg_loclose
- pg_loread
- pg_lowrite
- pg_loreadall
-
-sybase_functions
- sybase_connect
- sybase_pconnect
- sybase_close
- sybase_select_db
- sybase_query
- sybase_free_result
- sybase_get_last_message
- sybase_num_rows
- sybase_num_fields
- sybase_fetch_row
- sybase_fetch_array
- sybase_fetch_object
- sybase_data_seek
- sybase_fetch_field
- sybase_field_seek
- sybase_result
-
-sybase_old_functions
- sybsql_seek
- sybsql_exit
- sybsql_dbuse
- sybsql_query
- sybsql_isrow
- sybsql_result
- sybsql_connect
- sybsql_nextrow
- sybsql_numrows
- sybsql_getfield
- sybsql_numfields
- sybsql_fieldname
- sybsql_result_all
- sybsql_checkconnect
-
diff --git a/INSTALL b/INSTALL
deleted file mode 100644
index 3ad1f25a95..0000000000
--- a/INSTALL
+++ /dev/null
@@ -1,186 +0,0 @@
-Installation Instructions for PHP 4.0
--------------------------------------
-
-For the impatient here is a quick set of steps that will build PHP as
-an Apache module for Apache 1.3.x with MySQL support. A more verbose
-explanation follows.
-
-
-QUICK INSTALL
-
-$ gunzip -c apache_1.3.x.tar.gz | tar xf -
-$ cd apache_1.3.x
-$ ./configure
-$ cd ..
-
-$ gunzip -c php-4.0.x.tar.gz | tar xf -
-$ cd php-4.0.x
-$ ./configure --with-mysql --with-apache=../apache_1.3.x --enable-track-vars
-$ make
-$ make install
-
-$ cd ../apache_1.3.x
-$ ./configure --prefix=/www --activate-module=src/modules/php4/libphp4.a
- (The above line is correct! Yes, we know libphp4.a does not exist at this
- stage. It isn't supposed to. It will be created.)
-make
- (you should now have an httpd binary which you can copy to your Apache bin dir)
-cd ../php-4.0.x
-cp php.ini-dist /usr/local/lib/php.ini
-You can edit /usr/local/lib/php.ini file to set PHP options.
-Edit your httpd.conf or srm.conf file and add:
- AddType application/x-httpd-php .php
-
-
-VERBOSE INSTALL
-
-Installing PHP can be done in four simple steps:
-
-1. Unpack your distribution file.
-
- You will have downloaded a file named something like php4xn.tar.gz.
- Unzip this file with a command like: gunzip php4xn.tar.gz
-
- Next you have to untar it with: tar -xvf php4xn.tar
-
- This will create a php-4.0.x directory. cd into this new directory.
-
-2. Configure PHP.
-
- You now have to choose the options you would like. There are quite
- a few of them. To see a list, type: ./configure --help
-
- You can also use the supplied 'setup' script, which will ask you
- a series of questions and automatically run the configure script
- for you.
-
- The only options that you are likely to want to use are the ones in
- the last section entitled, "--enable and --with options recognized:"
-
- A popular choice is to build the Apache module version. You need
- to know where the source code directory for your Apache server is
- located. Then use an option like: --with-apache=/usr/local/src/apache
- if that is your Apache source code directory. If you only specify
- --with-apache, then it will default to look for your Apache source
- in /usr/local/etc/httpd.
-
- NOTE: The directory you specify should be the top-level of the
- unpacked Apache (or Stronghold) distribution. The configure program
- will automatically look for httpd.h in different directories under that
- location depending on which version of Apache, including Stronghold,
- you are running.
-
- For MySQL support, since newer versions of MySQL installs its various
- components under /usr/local, this is the default. If you have
- changed the location you can specify it with: --with-mysql=/opt/local
- for example. Otherwise just use: --with-mysql
-
- *NOTE* If you are using Apache 1.3b6 or later, you should run the
- Apache Configure script at least once before compiling PHP. It
- doesn't matter how you have Apache configured at this point.
-
-3. Compile and install the files. Simply type: make install
-
- For the Apache module version this will copy the appropriate files
- to the src/modules/php4 directory in your Apache distribution if
- you are using Apache 1.3.x. If you are still running Apache 1.2.x
- these files will be copied directly to the main src directory.
-
- For Apache 1.3b6 and later, you can use the new APACI configuration
- mechanism. To automatically build Apache with PHP support, use:
-
- cd apache_1.3.x
- ./configure --prefix=/<path>/apache \
- --activate-module=src/modules/php4/libphp4.a
- make
- make install
-
- If you do not wish to use this new configuration tool, the old
- install procedure (src/Configure) will work fine.
-
- If you are using the old Apache ./Configure script, you will have to
- edit the Apache src/Configuration file manually. If you do not have
- this file, copy Configuration.tmpl to Configuration.
-
- For Apache 1.3.x add:
-
- AddModule modules/php4/libphp4.a
-
- For Apache 1.3.x don't do anything else. Just add this line and then
- run "./Configure" followed by "make".
-
- For Apache 1.2.x add:
-
- Module php4_module mod_php4.o
-
- For Apache 1.2.x you will also have to look in the libphp4.module file,
- which was copied to the src directory. The EXTRA_LIBS line in the Apache
- Configuration file needs to be set to use the same libs as specified on
- the LIBS line in libphp4.module. You also need to make sure to add
- "-L." to the beginning of the EXTRA_LIBS line.
-
- So, as an example, your EXTRA_LIBS line might look like:
-
- EXTRA_LIBS=-L. -lphp4 -lgdbm -ldb -L/usr/local/mysql/lib -lmysqlclient
-
- NOTE: You should not enclose the EXTRA_LIBS line in double-quotes, as it
- is in the libphp4.module file.
-
- Also, look at the RULE_WANTHSREGEX setting in the libphp4.module file
- and set the WANTHSREGEX directive accordingly in your Configuration file.
- This last step applies to versions of Apache prior to 1.3b3.
-
- This is a bit of a hassle, but should serve as incentive to move to
- Apache 1.3.x where this step has been eliminated.
-
- Once you are satisfied with your Configuration settings, type: ./Configure
- If you get errors, chances are that you forgot a library or made a typo
- somewhere. Re-edit Configuration and try again. If it goes well,
- type: make
-
-4. Setting up the server.
-
- You should now have a new httpd binary. Shut down your existing server,
- if you have one, and copy this new binary overtop of it. Perhaps make
- a backup of your previous one first. Then edit your conf/srm.conf file
- and add the line:
-
- AddType application/x-httpd-php .php
-
- There is also an interesting feature which can be quite instructive and
- helpful while debugging. That is the option of having colour syntax
- highlighting. To enable this, add the following line:
-
- AddType application/x-httpd-php-source .phps
-
- Any file ending in .phps will now be displayed with full colour syntax
- highlighting instead of being executed.
-
- When you are finished making changes to your srm.conf file, you can
- start up your server.
-
-USING PHP3 AND PHP4 AS CONCURRENT APACHE MODULES
-
- Recent operating systems provide the ability to perform versioning and
- scoping. This features make it possible to let PHP3 and PHP4 run as
- concurrent modules in one Apache server.
-
- This feature is known to work on the following platforms:
-
- - Linux with recent binutils (binutils 2.9.1.0.25 tested)
- - Solaris 2.5 or better
- - FreeBSD (3.2, 4.0 tested)
-
- To enable it, configure PHP3 and PHP4 to use APXS (--with-apxs) and the
- necessary link extensions (--enable-versioning). Otherwise, all standard
- installations instructions apply. For example:
-
- $ ./configure \
- --with-apxs=/apache/bin/apxs \
- --enable-versioning \
- --with-mysql \
- --enable-track-vars
-
- If this also works on your platform or if you know a way to do it, please
- report it to our bug database at http://bugs.php.net
-
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index bb0d0c6e2d..0000000000
--- a/LICENSE
+++ /dev/null
@@ -1,70 +0,0 @@
---------------------------------------------------------------------
- The PHP License, version 2.01
-Copyright (c) 1999 The PHP Group. All rights reserved.
---------------------------------------------------------------------
-
-Redistribution and use in source and binary forms, with or without
-modification, is 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. The name "PHP" must not be used to endorse or promote products
- derived from this software without prior permission from the
- PHP Group. This does not apply to add-on libraries or tools
- that work in conjunction with PHP. In such a case the PHP
- name may be used to indicate that the product supports PHP.
-
- 4. The PHP Group may publish revised and/or new versions of the
- license from time to time. Each version will be given a
- distinguishing version number.
- Once covered code has been published under a particular version
- of the license, you may always continue to use it under the
- terms of that version. You may also choose to use such covered
- code under the terms of any subsequent version of the license
- published by the PHP Group. No one other than the PHP Group has
- the right to modify the terms applicable to covered code created
- under this License.
-
- 5. Redistributions of any form whatsoever must retain the following
- acknowledgment:
- "This product includes PHP, freely available from
- http://www.php.net/".
-
- 6. Permission to freely distribute and use Zend as an integrated
- part of PHP is granted, under the conditions of version 0.91
- of the Zend License.
- The license is bundled with the Zend engine, and is available
- at http://www.zend.com/license/0_91.txt, or by contacting
- license@zend.com.
-
-
-
-THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
-ANY EXPRESSED 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 PHP
-DEVELOPMENT TEAM OR ITS 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.
-
---------------------------------------------------------------------
-
-This software consists of voluntary contributions made by many
-individuals on behalf of the PHP Group.
-
-The PHP Group can be contacted via Email at php-group@php.net.
-
-For more information on the PHP Group and the PHP project,
-please see <http://www.php.net>.
diff --git a/MODULES_STATUS b/MODULES_STATUS
deleted file mode 100644
index 8c49b2116f..0000000000
--- a/MODULES_STATUS
+++ /dev/null
@@ -1,20 +0,0 @@
-Module Status
------- ------
-MySQL Working
-COM Working
-WDDX Working
-PCRE Working
-DBA Working
-mcrypt Working
-mhash Working
-dbase Working
-aspell Working
-imap Working
-ldap Working
-oci8 Working (but no blob-support yet)
-oracle Working
-iptc Working
-informix Working
-zlib Working
-sysvshm Working
-odbc Working (except for persistent connections)
diff --git a/Makefile.in b/Makefile.in
deleted file mode 100644
index 7e8d6faee3..0000000000
--- a/Makefile.in
+++ /dev/null
@@ -1,234 +0,0 @@
-# +----------------------------------------------------------------------+
-# | PHP HTML Embedded Scripting Language Version 4.0 |
-# +----------------------------------------------------------------------+
-# | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
-# +----------------------------------------------------------------------+
-# | This program is free software; you can redistribute it and/or modify |
-# | it under the terms of one of the following licenses: |
-# | |
-# | A) the GNU General Public License as published by the Free Software |
-# | Foundation; either version 2 of the License, or (at your option) |
-# | any later version. |
-# | |
-# | B) the PHP License as published by the PHP Development Team and |
-# | included in the distribution in the file: LICENSE |
-# | |
-# | 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 both licenses referred to here. |
-# | If you did not, or have any questions about PHP licensing, please |
-# | contact core@php.net. |
-# +----------------------------------------------------------------------+
-
-#
-# $Id$
-#
-
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-srcdir = @srcdir@
-VPATH = @srcdir@
-bindir = @bindir@
-
-top_builddir = .
-
-ZEND_DIR = $(srcdir)/libzend
-SUBDIRS=libzend ext @TSRM_DIR@
-
-PACKAGE = @PACKAGE@
-VERSION = @VERSION@
-LN_S = @LN_S@
-CC = @CC@
-AR = ar rc
-BINNAME = @BINNAME@
-INSTALL_IT = @INSTALL_IT@
-EXTRA_LIBS = @EXTRA_LIBS@
-EXT_LIBS = @EXT_LIBS@
-INCLUDES = @INCLUDES@
-INCLUDE = -I$(srcdir) -I. -I$(ZEND_DIR) -I$(srcdir)/TSRM $(INCLUDES)
-PROF_CFLAGS =
-CFLAGS_SHLIB = @CFLAGS_SHLIB@
-LDFLAGS_SHLIB = @LDFLAGS_SHLIB@
-LDFLAGS_SHLIB_EXPORT = @LDFLAGS_SHLIB_EXPORT@
-CPPFLAGS = @CPPFLAGS@
-DEFS = @DEFS@
-CFLAGS = @CFLAGS@ @DEBUG_CFLAGS@ $(PROF_CFLAGS)
-COMPILE = $(CC) $(CFLAGS) $(CFLAGS_SHLIB) $(CPPFLAGS) $(INCLUDE) $(DEFS) @STRONGHOLD@
-LDFLAGS = @VERSION_SCRIPT@ @RPATHS@ @LDFLAGS@ $(LDFLAGS_SHLIB) $(LDFLAGS_SHLIB_EXPORT) -L$(ZEND_DIR)
-REGCFLAGS = $(CFLAGS)
-RANLIB = @RANLIB@
-YACC = @YACC@
-MAINT = @MAINT@
-APXS = @APXS@
-APXS_LDFLAGS = $(EXTRA_LIBS) $(LIBS)
-APXS_EXP = @APXS_EXP@
-WARNING_LEVEL = @WARNING_LEVEL@
-LEX_CFLAGS = -w$(WARNING_LEVEL) @LEX_CFLAGS@
-EXT_SHARED = @EXT_SHARED@
-LIBOBJS=@LIBOBJS@
-
-SOURCE = main.c internal_functions.c snprintf.c php3_sprintf.c \
- configuration-parser.c configuration-scanner.c request_info.c \
- safe_mode.c fopen-wrappers.c php3_realpath.c alloca.c output.c \
- php_ini.c SAPI.c cgi_main.c rfc1867.c dlist.c php_content_types.c
-OBJS = $(SOURCE:.c=.o) $(LIBOBJS)
-PHPLIBS = -Llibzend -lzend -Lext -lphpext
-LIBS = $(PHPLIBS) $(EXTRA_LIBS) @LIBS@
-
-all: $(BINNAME)
-
-all-recursive clean-recursive distclean-recursive \
-maintainer-clean-depend-recursive:
- @set fnord $(MAKEFLAGS); amf=$$2; \
- for subdir in $(SUBDIRS); do \
- target=`echo $@ | sed s/-recursive//`; \
- echo "Making $$target in $$subdir"; \
- (cd $$subdir && $(MAKE) $$target) || fail=yes; \
- done && test -z "$$fail"
-
-# CGI binary or fhttpd module
-php: all-recursive $(OBJS) @REGEX_LIB@ @FHTTPD_LIB@ @TSRM_LIB@
- $(CC) $(CFLAGS) -o $(BINNAME) $(LDFLAGS) $(OBJS) $(LIBS)
-
-# Apache modules
-libphp4.a libmodphp4.a: all-recursive $(OBJS) @REGEX_LIB@
- $(AR) $@.tmp $(OBJS)
- $(srcdir)/scripts/armerge $@ $@.tmp ext/libphpext.a libzend/libzend.a @TSRM_LIB@
- @rm -f $@.tmp
- $(RANLIB) $(BINNAME)
-
-# Apache modules
-libmodphp4-so.a: all-recursive $(OBJS) @REGEX_LIB@
- $(AR) $@.tmp $(OBJS)
- $(srcdir)/scripts/armerge $@ $@.tmp ext/libphpext.a libzend/libzend.a @TSRM_LIB@
- @rm -f $@.tmp
- $(RANLIB) libmodphp4-so.a
-
-# Apache 1.3 shared module
-libphp4.so: $(srcdir)/mod_php4.c libmodphp4-so.a @REGEX_LIB@
- -@test -f ./mod_php4.c || test -L ./mod_php4.c || $(LN_S) $(srcdir)/mod_php4.c ./mod_php4.c
- -@test -f ./mod_php4.c || test -h ./mod_php4.c || $(LN_S) $(srcdir)/mod_php4.c ./mod_php4.c
- $(APXS) $(INCLUDE) -c -o libphp4.so @VERSION_SCRIPT@ @RPATHS@ ./mod_php4.c libmodphp4-so.a $(APXS_LDFLAGS) $(APXS_EXP)
-
-regex/libregex.a:
- (cd regex; $(MAKE) lib)
-
-configuration-parser.h configuration-parser.c: $(srcdir)/configuration-parser.y
- bison -p cfg -v -d $(srcdir)/configuration-parser.y -o configuration-parser.c
-
-configuration-scanner.o: configuration-scanner.c
- $(COMPILE) $(LEX_CFLAGS) -c configuration-scanner.c
-
-configuration-scanner.c: $(srcdir)/configuration-scanner.l
- flex -Pcfg -oconfiguration-scanner.c -i $(srcdir)/configuration-scanner.l
-
-clean: clean-recursive
- -rm -f libphp4.a libmodphp4.a libphp4.so php *.o
- -rm -f test/php.desc test/php.in test/php.out test/php.test
- -rm -f test/a.tmp test/b.tmp test/test.dbm*
-
-distclean: clean distclean-recursive
- -rm -f *-parser.[ch] *-scanner.c *.output
- -rm -f config.status config.cache config.log
- -rm -f Makefile Makefile.depend php_config.h build-defs.h
- -rm -f libphp4.module stamp-h buildconf.stamp
- -rm -f regex/*.o regex/*.a regex/*.ih
- -rm -f doc/checkdoc doc/funcparse doc/version.ent
- -rm -f do-conf test/test.log
- -rm -f doc/Makefile regex/Makefile
-
-distdir = $(PACKAGE)-$(VERSION)
-top_distdir = $(distdir)
-
-dist: distdir
- -chmod -R a+r $(distdir)
- tar chozf $(distdir).tar.gz $(distdir)
- -rm -rf $(distdir)
-
-distdir:
- -rm -rf $(distdir)
- files=`echo *` ;\
- mkdir $(distdir) ;\
- for file in $$files ; do \
- d=$(srcdir); \
- if test -d $$d/$$file ; then \
- cp -pr $$d/$$file $(distdir)/$$file; \
- else \
- test -f $(distdir)/$$file \
- || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
- || cp -p $$d/$$file $(distdir)/$$file || :; \
- fi; \
- done
- (cd $(distdir) ; $(MAKE) distclean)
- cd $(distdir)/libzend ;\
- flex -Pzend -ozend-scanner.c -i zend-scanner.l ;\
- bison -p zend -v -d zend-parser.y -o zend-parser.c
- cd $(distdir) ;\
- flex -Pcfg -oconfiguration-scanner.c -i configuration-scanner.l ;\
- bison -p cfg -v -d configuration-parser.y -o configuration-parser.c
- find $(distdir) -name CVS -o -name .cvsignore | xargs rm -rf
-
-maintainer-clean-depend: maintainer-clean-depend-recursive
-
-bench: $(BINNAME)
- ./$(BINNAME) -c. tests/bench.phtml
-
-# can't use a single rule for this because 'test' is a directory
-test: regression
-regression check: $(BINNAME)
- cd test && ./testall
-
-config.status: configure
- ./config.status --recheck
-
-build-defs.h php_config.h: stamp-h
-stamp-h: php_config.h.in config.status
- CONFIG_FILES='build-defs.h stamp-h' ./config.status
-
-Makefile: Makefile.in config.status
- CONFIG_FILES=$@ CONFIG_HEADERS= ./config.status
-
-#
-# You must use '--enable-maintainer-mode' with configure to enable
-# these rules, which requires autoconf be installed.
-#
-configure: @MAINT@ configure.in aclocal.m4
- cd $(srcdir) && autoconf
-
-php_config.h.in: @MAINT@ stamp-h.in
-stamp-h.in: configure.in aclocal.m4 acconfig.h
- cd ${srcdir} && autoheader && touch ${srcdir}/stamp-h.in
-
-install: install-recursive $(BINNAME)
- $(INSTALL_IT)
-
-install-recursive:
- if test "$(EXT_SHARED)" != ""; then \
- for dir in X $(EXT_SHARED); do \
- test -d ext/$$dir && (cd ext/$$dir; $(MAKE) install); \
- done; \
- fi
-
-indent: clean
- indent -v -kr -cli4 -ts4 \
- -T pval -T HashTable -T Bucket -T Token -T TokenCache -T TokenCacheManager \
- -T switch_expr -T internal_function -T control_structure_data \
- -T MemoryHashTable -T MemoryBucket \
- -T pvalue_value -T Stack *.c *.h
- rm -f *~
-
-.c.o:
- $(COMPILE) -c $<
-
-parser-scanner: configuration-parser.c configuration-scanner.c
-
-depend: parser-scanner
- $(CC) $(CFLAGS) -MM $(SOURCE) | perl -pe 's|regex/regex.h||;' > Makefile.depend
- $(CC) $(CFLAGS) -MM $(FUNCTIONS_SOURCE) | perl -pe 's|^(.+\.o)|functions/$$1|; s|regex/regex.h||;' >> Makefile.depend
-
-# Local Variables:
-# tab-width: 4
-# End:
diff --git a/README-BCMATH b/README-BCMATH
deleted file mode 100644
index 7d5bac19a6..0000000000
--- a/README-BCMATH
+++ /dev/null
@@ -1,17 +0,0 @@
-How to install PHP with the BCMath arbitrary precision math library?
---------------------------------------------------------------------
-
-Due to license restrictions, the BC math library can no longer be distributed
-along with PHP. The BC math library is distributed under the restrictive
-GNU Public License, and PHP is no longer distributed under that license, but
-under a less restrictive license, the PHP License.
-
-If you want to enable BC math support (recommended), all you have to do is
-simply download http://www.php.net/extra/number4.tar.gz, and untar it on the
-top level php4 directory.
-
-A typical way of doing this would be (assuming that you have lynx):
-cd ~/php4
-lynx -dump -source http://www.php.net/extra/number4.tar.gz | gzip -d | tar xvf -
-
-The PHP Group
diff --git a/README.QNX b/README.QNX
deleted file mode 100644
index d70d2e5d8b..0000000000
--- a/README.QNX
+++ /dev/null
@@ -1,57 +0,0 @@
-QNX4 Installation Notes
------------------------
-
-NOTE: General installation instructions are in the INSTALL file
-
-
-1. To compile and test PHP3 you have to grab, compile and install:
- - GNU dbm library or another db library;
- - GNU bison (1.25 or later; 1.25 tested);
- - GNU flex (any version supporting -o and -P options; 2.5.4 tested);
- - GNU diffutils (any version supporting -w option; 2.7 tested);
-
-2. To use CVS version you may need also:
- - GNU CVS (1.9 tested);
- - GNU autoconf (2.12 tested);
- - GNU m4 (1.3 or later preferable; 1.4 tested);
-
-3. To run configure define -lunix in command line:
- LDFLAGS=-lunix ./configure
-
-4. To use Sybase SQL Anywhere define ODBC_QNX and CUSTOM_ODBC_LIBS in
- command line and run configure with --with-custom-odbc:
- CFLAGS=-DODBC_QNX LDFLAGS=-lunix CUSTOM_ODBC_LIBS="-ldblib -lodbc" ./configure --with-custom-odbc=/usr/lib/sqlany50
- If you have SQL Anywhere version 5.5.00, then you have to add
- CFLAGS=-DSQLANY_BUG
- to workaround its SQLFreeEnv() bug. Other versions has not been tested,
- so try without this flag first.
-
-5. To build the Apache module, you may have to hardcode an include path for
- alloc.h in your Apache base directory:
- - APACHE_DIRECTORY/src/httpd.h:
- change #include "alloc.h"
- to #include "APACHE_DIRECTORY/src/alloc.h"
- Unless you want to use system regex library, you have to hardcode also
- a path to regex.h:
- - APACHE_DIRECTORY/src/conf.h:
- change #include <regex.h>
- to #include "APACHE_DIRECTORY/src/regex/regex.h"
- I don't know so far why this required for QNX, may be it is Watcom
- compiler problem.
-
- If you building Apache module with SQL Anywhere support, you'll get
- symbol conflict with BOOL. It is defined in Apache (httpd.h) and in
- SQL Anywhere (odbc.h). This has nothing to do with PHP, so you have to
- fix it yourself someway.
-
-6. With above precautions, it should compile as is and pass regression
- tests completely:
- make
- make check
- make install
-
- Don't bother me unless you really sure you made that all but it
- still doesn't work.
-
-June 28, 1998
-Igor Kovalenko -- owl@infomarket.ru
diff --git a/TSRM/Makefile.am b/TSRM/Makefile.am
deleted file mode 100644
index 6bea4e8cc6..0000000000
--- a/TSRM/Makefile.am
+++ /dev/null
@@ -1,4 +0,0 @@
-## process this file with automake to produce Makefile.am
-AUTOMAKE_OPTIONS=foreign
-lib_LIBRARIES=libtsrm.a
-libtsrm_a_SOURCES = TSRM.c
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c
deleted file mode 100644
index 8178d37035..0000000000
--- a/TSRM/TSRM.c
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | Thread Safe Resource Manager |
- +----------------------------------------------------------------------+
- | Copyright (c) 1998, 1999 Zeev Suraski |
- +----------------------------------------------------------------------+
- | This source file is subject to the Zend license, that is bundled |
- | with this package in the file LICENSE. If you did not receive a |
- | copy of the Zend license, please mail us at zend@zend.com so we can |
- | send you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
-*/
-
-
-#include "TSRM.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#if HAVE_STDARG_H
-#include <stdarg.h>
-#endif
-
-typedef struct _tsrm_tls_entry tsrm_tls_entry;
-
-struct _tsrm_tls_entry {
- void **storage;
- int count;
- THREAD_T thread_id;
- tsrm_tls_entry *next;
-};
-
-
-typedef struct {
- size_t size;
- void (*ctor)(void *resource);
- void (*dtor)(void *resource);
-} tsrm_resource_type;
-
-
-/* The memory manager table */
-static tsrm_tls_entry **tsrm_tls_table;
-static int tsrm_tls_table_size;
-static ts_rsrc_id id_count;
-
-/* The resource sizes table */
-static tsrm_resource_type *resource_types_table;
-static int resource_types_table_size;
-
-
-static MUTEX_T tsmm_mutex; /* thread-safe memory manager mutex */
-
-/* New thread handlers */
-static void (*tsrm_new_thread_begin_handler)();
-static void (*tsrm_new_thread_end_handler)();
-
-/* Debug support */
-static int tsrm_debug(const char *format, ...);
-static int tsrm_debug_status;
-
-
-/* Startup TSRM (call once for the entire process) */
-TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_status)
-{
- tsrm_tls_table_size = expected_threads;
- tsrm_tls_table = (tsrm_tls_entry **) calloc(tsrm_tls_table_size, sizeof(tsrm_tls_entry *));
- if (!tsrm_tls_table) {
- return 0;
- }
- id_count=0;
-
- resource_types_table_size = expected_resources;
- resource_types_table = (tsrm_resource_type *) calloc(resource_types_table_size, sizeof(tsrm_resource_type));
- if (!resource_types_table) {
- free(tsrm_tls_table);
- return 0;
- }
-
- tsmm_mutex = tsrm_mutex_alloc();
-
- tsrm_new_thread_begin_handler = tsrm_new_thread_end_handler = NULL;
-
- tsrm_debug_status = debug_status;
-
- tsrm_debug("Started up TSRM, %d expected threads, %d expected resources\n", expected_threads, expected_resources);
- return 1;
-}
-
-
-/* Shutdown TSRM (call once for the entire process) */
-TSRM_API void tsrm_shutdown()
-{
- int i;
-
- if (tsrm_tls_table) {
- for (i=0; i<tsrm_tls_table_size; i++) {
- tsrm_tls_entry *p = tsrm_tls_table[i], *next_p;
-
- while (p) {
- int j;
-
- next_p = p->next;
- for (j=0; j<id_count; j++) {
- free(p->storage[j]);
- }
- free(p->storage);
- free(p);
- p = next_p;
- }
- }
- free(tsrm_tls_table);
- }
- if (resource_types_table) {
- free(resource_types_table);
- }
- tsrm_mutex_free(tsmm_mutex);
- tsrm_debug("Shutdown TSRM\n");
-}
-
-
-/* allocates a new thread-safe-resource id */
-TSRM_API ts_rsrc_id ts_allocate_id(size_t size, void (*ctor)(void *resource), void (*dtor)(void *resource))
-{
- ts_rsrc_id new_id;
- int i;
-
- tsrm_debug("Obtaining a new resource id, %d bytes\n", size);
-
- tsrm_mutex_lock(tsmm_mutex);
-
- /* obtain a resource id */
- new_id = id_count++;
- tsrm_debug("Obtained resource id %d\n", new_id);
-
- /* store the new resource type in the resource sizes table */
- if (resource_types_table_size < id_count) {
- resource_types_table = (tsrm_resource_type *) realloc(resource_types_table, sizeof(tsrm_resource_type)*id_count);
- if (!resource_types_table) {
- return -1;
- }
- resource_types_table_size = id_count;
- }
- resource_types_table[new_id].size = size;
- resource_types_table[new_id].ctor = ctor;
- resource_types_table[new_id].dtor = dtor;
-
- /* enlarge the arrays for the already active threads */
- for (i=0; i<tsrm_tls_table_size; i++) {
- tsrm_tls_entry *p = tsrm_tls_table[i];
-
- while (p) {
- if (p->count < id_count) {
- int j;
-
- p->storage = (void *) realloc(p->storage, sizeof(void *)*id_count);
- for (j=p->count; j<id_count; j++) {
- p->storage[j] = (void *) malloc(resource_types_table[j].size);
- if (resource_types_table[j].ctor) {
- resource_types_table[j].ctor(p->storage[j]);
- }
- }
- p->count = id_count;
- }
- p = p->next;
- }
- }
- tsrm_mutex_unlock(tsmm_mutex);
-
- tsrm_debug("Successfully allocated new resource id %d\n", new_id);
- return new_id;
-}
-
-
-static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_T thread_id)
-{
- int i;
-
- if (tsrm_new_thread_begin_handler) {
- tsrm_new_thread_begin_handler(thread_id);
- }
-
- (*thread_resources_ptr) = (tsrm_tls_entry *) malloc(sizeof(tsrm_tls_entry));
- (*thread_resources_ptr)->storage = (void **) malloc(sizeof(void *)*id_count);
- (*thread_resources_ptr)->count = id_count;
- (*thread_resources_ptr)->thread_id = thread_id;
- (*thread_resources_ptr)->next = NULL;
- for (i=0; i<id_count; i++) {
- (*thread_resources_ptr)->storage[i] = (void *) malloc(resource_types_table[i].size);
- if (resource_types_table[i].ctor) {
- resource_types_table[i].ctor((*thread_resources_ptr)->storage[i]);
- }
- }
- if (tsrm_new_thread_end_handler) {
- tsrm_new_thread_end_handler(thread_id);
- }
-}
-
-
-/* fetches the requested resource for the current thread */
-void *ts_resource(ts_rsrc_id id)
-{
- THREAD_T thread_id = tsrm_thread_id();
- int hash_value;
- tsrm_tls_entry *thread_resources;
- void *resource;
-
- tsrm_debug("Fetching resource id %d for thread %ld\n", id, (long) thread_id);
- tsrm_mutex_lock(tsmm_mutex);
-
- hash_value = THREAD_HASH_OF(thread_id, tsrm_tls_table_size);
- thread_resources = tsrm_tls_table[hash_value];
-
- if (!thread_resources) {
- allocate_new_resource(&tsrm_tls_table[hash_value], thread_id);
- thread_resources = tsrm_tls_table[hash_value];
- } else {
- do {
- if (thread_resources->thread_id == thread_id) {
- break;
- }
- if (thread_resources->next) {
- thread_resources = thread_resources->next;
- } else {
- allocate_new_resource(&thread_resources->next, thread_id);
- thread_resources = thread_resources->next;
- break;
- }
- } while (thread_resources);
- }
-
- resource = thread_resources->storage[id];
-
- tsrm_mutex_unlock(tsmm_mutex);
-
- tsrm_debug("Successfully fetched resource id %d for thread id %ld - %x\n", id, (long) thread_id, (long) resource);
- return resource;
-}
-
-
-/* frees all resources allocated for the current thread */
-void ts_free_thread()
-{
- THREAD_T thread_id = tsrm_thread_id();
- int hash_value;
- tsrm_tls_entry *thread_resources;
- tsrm_tls_entry *last=NULL;
-
- tsrm_mutex_lock(tsmm_mutex);
- hash_value = THREAD_HASH_OF(thread_id, tsrm_tls_table_size);
- thread_resources = tsrm_tls_table[hash_value];
-
- while (thread_resources) {
- if (thread_resources->thread_id == thread_id) {
- int i;
-
- for (i=0; i<thread_resources->count; i++) {
- if (resource_types_table[i].dtor) {
- resource_types_table[i].dtor(thread_resources->storage[i]);
- }
- free(thread_resources->storage[i]);
- }
- free(thread_resources->storage);
- if (last) {
- last->next = thread_resources->next;
- } else {
- tsrm_tls_table[hash_value]=NULL;
- }
- free(thread_resources);
- break;
- }
- if (thread_resources->next) {
- last = thread_resources;
- }
- thread_resources = thread_resources->next;
- }
- tsrm_mutex_unlock(tsmm_mutex);
-}
-
-
-/* deallocates all occurrences of a given id */
-void ts_free_id(ts_rsrc_id id)
-{
-}
-
-
-
-
-/*
- * Utility Functions
- */
-
-/* Obtain the current thread id */
-TSRM_API THREAD_T tsrm_thread_id(void)
-{
-#ifdef WIN32
- return GetCurrentThreadId();
-#elif defined(PTHREADS)
- return pthread_self();
-#elif defined(NSAPI)
- return systhread_current();
-#elif defined(PI3WEB)
- return PIThread_getCurrent();
-#endif
-}
-
-
-/* Allocate a mutex */
-TSRM_API MUTEX_T tsrm_mutex_alloc( void )
-{
- MUTEX_T mutexp;
-
-#ifdef WIN32
- mutexp = CreateMutex(NULL,FALSE,NULL);
-#elif defined(PTHREADS)
- mutexp = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
- pthread_mutex_init(mutexp,NULL);
-#elif defined(NSAPI)
- mutexp = crit_init();
-#elif defined(PI3WEB)
- mutexp = PIPlatform_allocLocalMutex();
-#endif
-#ifdef THR_DEBUG
- printf("Mutex created thread: %d\n",mythreadid());
-#endif
- return( mutexp );
-}
-
-
-/* Free a mutex */
-TSRM_API void tsrm_mutex_free( MUTEX_T mutexp )
-{
- if (mutexp) {
-#ifdef WIN32
- CloseHandle(mutexp);
-#elif defined(PTHREADS)
- free(mutexp);
-#elif defined(NSAPI)
- crit_terminate(mutexp);
-#elif defined(PI3WEB)
- PISync_delete(mutexp)
-#endif
- }
-#ifdef THR_DEBUG
- printf("Mutex freed thread: %d\n",mythreadid());
-#endif
-}
-
-
-/* Lock a mutex */
-TSRM_API int tsrm_mutex_lock( MUTEX_T mutexp )
-{
- //tsrm_debug("Mutex locked thread: %ld\n",tsrm_thread_id());
-#ifdef WIN32
- return WaitForSingleObject(mutexp,1000);
-#elif defined(PTHREADS)
- return pthread_mutex_lock(mutexp);
-#elif defined(NSAPI)
- return crit_enter(mutexp);
-#elif defined(PI3WEB)
- return PISync_lock(mutexp);
-#endif
-}
-
-
-/* Unlock a mutex */
-TSRM_API int tsrm_mutex_unlock( MUTEX_T mutexp )
-{
- //tsrm_debug("Mutex unlocked thread: %ld\n",tsrm_thread_id());
-#ifdef WIN32
- return ReleaseMutex(mutexp);
-#elif defined(PTHREADS)
- return pthread_mutex_unlock(mutexp);
-#elif defined(NSAPI)
- return crit_exit(mutexp);
-#elif defined(PI3WEB)
- return PISync_unlock(mutexp);
-#endif
-}
-
-
-TSRM_API void *tsrm_set_new_thread_begin_handler(void (*new_thread_begin_handler)(THREAD_T thread_id))
-{
- void *retval = (void *) tsrm_new_thread_begin_handler;
-
- tsrm_new_thread_begin_handler = new_thread_begin_handler;
- return retval;
-}
-
-
-TSRM_API void *tsrm_set_new_thread_end_handler(void (*new_thread_end_handler)(THREAD_T thread_id))
-{
- void *retval = (void *) tsrm_new_thread_end_handler;
-
- tsrm_new_thread_end_handler = new_thread_end_handler;
- return retval;
-}
-
-
-
-/*
- * Debug support
- */
-
-static int tsrm_debug(const char *format, ...)
-{
- if (tsrm_debug_status) {
- va_list args;
- int size;
-
- va_start(args, format);
- size = vprintf(format, args);
- va_end(args);
- return size;
- } else {
- return 0;
- }
-}
-
-
-void tsrm_debug_set(int status)
-{
- tsrm_debug_status = status;
-}
diff --git a/TSRM/TSRM.dsp b/TSRM/TSRM.dsp
deleted file mode 100644
index 7b284ab3eb..0000000000
--- a/TSRM/TSRM.dsp
+++ /dev/null
@@ -1,100 +0,0 @@
-# Microsoft Developer Studio Project File - Name="TSRM" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=TSRM - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "TSRM.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "TSRM.mak" CFG="TSRM - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "TSRM - Win32 Debug_TS" (based on "Win32 (x86) Static Library")
-!MESSAGE "TSRM - Win32 Release_TS" (based on "Win32 (x86) Static Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "TSRM - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "TSRM___Win32_Debug_TS"
-# PROP BASE Intermediate_Dir "TSRM___Win32_Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "C:\Projects\TSRM" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /D "_DEBUG" /D "TSRM_EXPORTS" /D "WIN32" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x40d /d "_DEBUG"
-# ADD RSC /l 0x40d /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF "$(CFG)" == "TSRM - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "TSRM___Win32_Release_TS"
-# PROP BASE Intermediate_Dir "TSRM___Win32_Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "TSRM_EXPORTS" /YX /FD /c
-# ADD BASE RSC /l 0x40d /d "NDEBUG"
-# ADD RSC /l 0x40d /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ENDIF
-
-# Begin Target
-
-# Name "TSRM - Win32 Debug_TS"
-# Name "TSRM - Win32 Release_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\TSRM.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\TSRM.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h
deleted file mode 100644
index 6addd6c230..0000000000
--- a/TSRM/TSRM.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | Thread Safe Resource Manager |
- +----------------------------------------------------------------------+
- | Copyright (c) 1998, 1999 Zeev Suraski |
- +----------------------------------------------------------------------+
- | This source file is subject to the Zend license, that is bundled |
- | with this package in the file LICENSE. If you did not receive a |
- | copy of the Zend license, please mail us at zend@zend.com so we can |
- | send you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
-*/
-
-
-#ifndef _TSRM_H
-#define _TSRM_H
-
-#ifdef HAVE_CONFIG_H
-# include "tsrm_config.h"
-#endif
-
-#if WIN32||WINNT
-# include <windows.h>
-#elif defined(PTHREADS)
-# include <pthread.h>
-#endif
-
-typedef int ts_rsrc_id;
-
-#if WIN32||WINNT
-# ifdef TSRM_EXPORTS
-# define TSRM_API __declspec(dllexport)
-# else
-# define TSRM_API __declspec(dllimport)
-# endif
-#else
-# define TSRM_API
-#endif
-
-
-/* Define THREAD_T and MUTEX_T */
-#if defined(WIN32)
-# define THREAD_T DWORD
-# define MUTEX_T void *
-#elif defined(PTHREADS)
-# define THREAD_T pthread_t
-# define MUTEX_T pthread_mutex_t *
-#elif defined(NSAPI)
-# define THREAD_T SYS_THREAD
-# define MUTEX_T CRITICAL
-#elif defined(PI3WEB)
-# define THREAD_T PIThread *
-# define MUTEX_T PISync *
-#endif
-
-
-#define THREAD_HASH_OF(thr,ts) thr%ts
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* startup/shutdown */
-TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_status);
-TSRM_API void tsrm_shutdown();
-
-/* allocates a new thread-safe-resource id */
-TSRM_API ts_rsrc_id ts_allocate_id(size_t size, void (*ctor)(void *resource), void (*dtor)(void *resource));
-
-/* fetches the requested resource for the current thread */
-TSRM_API void *ts_resource(ts_rsrc_id id);
-
-/* frees all resources allocated for the current thread */
-TSRM_API void ts_free_thread();
-
-/* deallocates all occurrences of a given id */
-TSRM_API void ts_free_id(ts_rsrc_id id);
-
-
-/* Debug support */
-TSRM_API void tsrm_debug_set(int status);
-
-/* utility functions */
-TSRM_API THREAD_T tsrm_thread_id(void);
-TSRM_API MUTEX_T tsrm_mutex_alloc(void);
-TSRM_API void tsrm_mutex_free(MUTEX_T mutexp);
-TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp);
-TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp);
-
-TSRM_API void *tsrm_set_new_thread_begin_handler(void (*new_thread_begin_handler)(THREAD_T thread_id));
-TSRM_API void *tsrm_set_new_thread_end_handler(void (*new_thread_end_handler)(THREAD_T thread_id));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _TSRM_H */
diff --git a/TSRM/buildconf b/TSRM/buildconf
deleted file mode 100755
index 60251e105b..0000000000
--- a/TSRM/buildconf
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-mv aclocal.m4 aclocal.m4.old 2>/dev/null
-aclocal
-if cmp aclocal.m4.old aclocal.m4 > /dev/null 2>&1; then
- echo "buildconf: keeping ${1}aclocal.m4"
- mv aclocal.m4.old aclocal.m4
-else
- echo "buildconf: created or modified ${1}aclocal.m4"
-fi
-
-#autoheader
-
-automake --add-missing --include-deps
-
-mv configure configure.old 2>/dev/null
-autoconf
-if cmp configure.old configure > /dev/null 2>&1; then
- echo "buildconf: keeping ${1}configure"
- mv configure.old configure
-else
- echo "buildconf: created or modified ${1}configure"
-fi
-
diff --git a/TSRM/configure.in b/TSRM/configure.in
deleted file mode 100644
index 4d4bd2e298..0000000000
--- a/TSRM/configure.in
+++ /dev/null
@@ -1,24 +0,0 @@
-dnl $Id$
-dnl
-dnl Minimalistic configure.in for TSRM.
-dnl
-
-AC_INIT(TSRM.c)
-AM_INIT_AUTOMAKE(TSRM, 1.0)
-AM_CONFIG_HEADER(tsrm_config.h)
-
-AC_PROG_CC
-AC_PROG_CC_C_O
-AC_PROG_RANLIB
-
-AC_CHECK_LIB(pthread, pthread_create, [
- AC_DEFINE(PTHREADS)
- LIBS="$LIBS -lpthread"
-],[
- AC_MSG_ERROR(You need pthreads to build TSRM.)
-])
-
-AC_CHECK_HEADERS(stdarg.h)
-
-AC_OUTPUT(Makefile)
-
diff --git a/TSRM/tsrm_config.h.in b/TSRM/tsrm_config.h.in
deleted file mode 100644
index 414851122c..0000000000
--- a/TSRM/tsrm_config.h.in
+++ /dev/null
@@ -1,15 +0,0 @@
-/* tsrm_config.h.in. Generated automatically from configure.in by autoheader. */
-
-/* Define if your C compiler doesn't accept -c and -o together. */
-#undef NO_MINUS_C_MINUS_O
-
-#undef PTHREADS
-
-/* Define if you have the <stdarg.h> header file. */
-#undef HAVE_STDARG_H
-
-#ifdef DEFINE_TSRM_VERSION
-# undef PACKAGE
-# undef VERSION
-#endif
-
diff --git a/acconfig.h.in b/acconfig.h.in
deleted file mode 100644
index 9d5f579304..0000000000
--- a/acconfig.h.in
+++ /dev/null
@@ -1,118 +0,0 @@
-/* This is the default configuration file to read -*- C -*- */
-
-/* these are defined by automake */
-#undef PACKAGE
-#undef VERSION
-
-#undef HAVE_STRUCT_FLOCK
-#undef HAVE_TM_GMTOFF
-
-#define CONFIGURATION_FILE_PATH "php.ini"
-#define USE_CONFIG_FILE 1
-
-#undef HAVE_DMALLOC
-
-/* Some global constants defined by conigure */
-#undef PHP_BUILD_DATE
-#undef PHP_OS
-#undef PHP_UNAME
-
-/* define uint by configure if it is missed (QNX and BSD derived) */
-#undef uint
-
-/* define ulong by configure if it is missed (most probably is) */
-#undef ulong
-
-/* type check for in_addr_t */
-#undef in_addr_t
-
-/* Define if you have dirent.h but opendir() resides in libc rather than in libdir */
-/* This will cause HAVE_DIRENT_H defined twice sometimes, but it should be problem */
-#undef HAVE_DIRENT_H
-
-/* Define if you have the resolv library (-lresolv). */
-#undef HAVE_LIBRESOLV
-
-/* Define if you have the pam library (-lpam). */
-#define HAVE_LIBPAM 0
-
-/* Define if you have the bind library (-lbind). */
-#define HAVE_LIBBIND 0
-
-/* Define if you have Netscape LDAP instead of umich ldap or openldap*/
-#define HAVE_NSLDAP 0
-
-/* Define if you want safe mode enabled by default. */
-#define PHP_SAFE_MODE 0
-
-/* Set to the path to the dir containing safe mode executables */
-#define PHP_SAFE_MODE_EXEC_DIR /usr/local/php/bin
-
-/* Define if you want POST/GET/Cookie track variables by default */
-#define PHP_TRACK_VARS 0
-
-/* Undefine if you want stricter XML/SGML compliance by default */
-/* (this disables "<?expression?>" by default) */
-#define DEFAULT_SHORT_OPEN_TAG 1
-
-/* Undefine if you do not want PHP by default to escape "'" */
-/* in GET/POST/Cookie data */
-#define MAGIC_QUOTES 1
-
-/* Define both of these if you want the bundled REGEX library */
-#define REGEX 0
-#define HSREGEX 0
-
-/* Define if you have and want to use libnsl */
-#undef HAVE_LIBNSL
-
-/* Define if you have and want to use libsocket */
-#undef HAVE_LIBSOCKET
-
-/* Define if you have the sendmail program available */
-#define HAVE_SENDMAIL 0
-
-/* Define if you are compiling PHP as an Apache module */
-#define APACHE 0
-
-/* Define if you are compiling PHP as an Apache module with mod_charset patch applied (aka Russian Apache)*/
-#define USE_TRANSFER_TABLES 0
-
-/* Define if you are compiling PHP as an fhttpd module */
-#define FHTTPD 0
-
-/* Define if your Apache creates an ap_config.h header file (only 1.3b6 and later) */
-#define HAVE_AP_CONFIG_H 0
-
-/* Define if your Apache has src/include/compat.h */
-#define HAVE_OLD_COMPAT_H 0
-
-/* Define if your Apache has src/include/ap_compat.h */
-#define HAVE_AP_COMPAT_H 0
-
-#ifndef DEBUG /* should be set to ZEND_DEBUG */
-#define DEBUG 0
-#endif
-
-/* Define if you want to enable PHP RPC (experimental) */
-#define PHP_RPC 0
-
-/* Define if you want to prevent the CGI from working unless REDIRECT_STATUS is defined in the environment */
-#define FORCE_CGI_REDIRECT 0
-
-/* Define if you want to prevent the CGI from using path_info and path_translated */
-#define DISCARD_PATH 0
-
-/* Define if you want include() and other functions to be able to open
- * http and ftp URLs as files.
- */
-#define PHP3_URL_FOPEN 0
-
-/* Define if you have broken header files like SunOS 4 */
-#define MISSING_FCLOSE_DECL 0
-
-/* Define if you have broken sprintf function like SunOS 4 */
-#define BROKEN_SPRINTF 0
-
-/* Define to compile PHP/Zend thread safe */
-#undef ZTS
diff --git a/acinclude.m4 b/acinclude.m4
deleted file mode 100644
index fd9ed6cd18..0000000000
--- a/acinclude.m4
+++ /dev/null
@@ -1,217 +0,0 @@
-dnl $Id$
-dnl
-dnl This file contains local autoconf functions.
-
-dnl
-dnl AC_PHP_ONCE(namespace, variable, code)
-dnl
-dnl execute code, if variable is not set in namespace
-dnl
-AC_DEFUN(AC_PHP_ONCE,[
- unique=`echo $ac_n "$2$ac_c" | tr -c -d a-zA-Z0-9`
- cmd="echo $ac_n \"\$$1$unique$ac_c\""
- if test -n "$unique" && test "`eval $cmd`" = "" ; then
- eval "$1$unique=set"
- $3
- fi
-])
-
-dnl
-dnl AC_EXPAND_PATH(path, variable)
-dnl
-dnl expands path to an absolute path and assigns it to variable
-dnl
-AC_DEFUN(AC_EXPAND_PATH,[
- if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then
- $2="$1"
- else
- $2="`pwd`/$1"
- fi
-])
-
-dnl
-dnl AC_ADD_LIBPATH(path)
-dnl
-dnl add a library to linkpath/runpath
-dnl
-AC_DEFUN(AC_ADD_LIBPATH,[
- AC_EXPAND_PATH($1, ai_p)
- AC_PHP_ONCE(LIBPATH, $ai_p, [
- EXTRA_LIBS="$EXTRA_LIBS -L$ai_p"
- if test -n "$APXS" ; then
- RPATHS="$RPATHS ${apxs_runpath_switch}$ai_p'"
- else
- RPATHS="$RPATHS ${ld_runpath_switch}$ai_p"
- fi
- ])
-])
-
-dnl
-dnl AC_ADD_INCLUDE(path)
-dnl
-dnl add a include path
-dnl
-AC_DEFUN(AC_ADD_INCLUDE,[
- AC_EXPAND_PATH($1, ai_p)
- AC_PHP_ONCE(INCLUDEPATH, $ai_p, [
- INCLUDES="$INCLUDES -I$ai_p"
- ])
-])
-
-dnl
-dnl AC_ADD_LIBRARY(library)
-dnl
-dnl add a library to the link line
-dnl
-AC_DEFUN(AC_ADD_LIBRARY,[
- AC_PHP_ONCE(LIBRARY, $1, [
- EXTRA_LIBS="$EXTRA_LIBS -l$1"
- ])
-])
-
-dnl
-dnl AC_ADD_LIBRARY_WITH_PATH(library, path)
-dnl
-dnl add a library to the link line and path to linkpath/runpath
-dnl
-AC_DEFUN(AC_ADD_LIBRARY_WITH_PATH,[
- AC_ADD_LIBPATH($2)
- AC_ADD_LIBRARY($1)
-])
-
-
-AC_DEFUN(AM_SET_LIBTOOL_VARIABLE,[
- LIBTOOL='$(SHELL) $(top_builddir)/libtool $1'
-])
-
-dnl
-dnl Check for cc option
-dnl
-AC_DEFUN(AC_CHECK_CC_OPTION,[
- echo "main(){return 0;}" > conftest.$ac_ext
- opt="$1"
- var=`echo $ac_n "$opt$ac_c"|tr -c a-zA-Z0-9 _`
- AC_MSG_CHECKING([if compiler supports -$1 really])
- ac_php_compile="${CC-cc} -$opt -o conftest $CFLAGS $CPPFLAGS conftest.$ac_ext 2>&1"
- if eval $ac_php_compile 2>&1 | egrep "$opt" > /dev/null 2>&1 ; then
- eval php_cc_$var=no
- AC_MSG_RESULT(no)
- else
- if eval ./conftest 2>/dev/null ; then
- eval php_cc_$var=yes
- AC_MSG_RESULT(yes)
- else
- eval php_cc_$var=no
- AC_MSG_RESULT(no)
- fi
- fi
-])
-
-
-dnl
-dnl See if we have broken header files like SunOS has.
-dnl
-AC_DEFUN(AC_MISSING_FCLOSE_DECL,[
- AC_MSG_CHECKING([for fclose declaration])
- AC_TRY_COMPILE([#include <stdio.h>],[int (*func)() = fclose],[
- AC_DEFINE(MISSING_FCLOSE_DECL,0)
- AC_MSG_RESULT(ok)
- ],[
- AC_DEFINE(MISSING_FCLOSE_DECL,1)
- AC_MSG_RESULT(missing)
- ])
-])
-
-dnl
-dnl Check for broken sprintf()
-dnl
-AC_DEFUN(AC_BROKEN_SPRINTF,[
- AC_MSG_CHECKING([for broken sprintf])
- AC_TRY_RUN([main() { char buf[20]; exit (sprintf(buf,"testing 123")!=11); }],[
- AC_DEFINE(BROKEN_SPRINTF,0)
- AC_MSG_RESULT(ok)
- ],[
- AC_DEFINE(BROKEN_SPRINTF,1)
- AC_MSG_RESULT(broken)
- ],[
- AC_DEFINE(BROKEN_SPRINTF,0)
- AC_MSG_RESULT(cannot check, guessing ok)
- ])
-])
-
-dnl
-dnl Stuff to do when setting up a new extension.
-dnl XXX have to change the hardcoding of ".a" when we want to be able
-dnl to make dynamic libraries as well.
-dnl
-AC_DEFUN(PHP_EXTENSION,[
- if test -d "$cwd/$srcdir/ext/$1" ; then
- EXT_SUBDIRS="$EXT_SUBDIRS $1"
- if test "$2" != "shared" -a "$2" != "yes"; then
- _extlib="libphpext_$1.a"
- EXT_LIBS="$EXT_LIBS $1/$_extlib"
- EXTINFO_DEPS="$EXTINFO_DEPS ../ext/$1/extinfo.c.stub"
- EXT_STATIC="$EXT_STATIC $1"
- else
- EXT_SHARED="$EXT_SHARED $1"
- fi
-dnl EXT_INCLUDE_CODE="\#include \"ext/$1/php3_$1.h\"\\n$EXT_INCLUDE_CODE"
-dnl EXT_MODULE_PTRS="phpext_$1_ptr, $EXT_MODULE_PTRS"
-dnl "
- fi
-])
-
-AC_SUBST(EXT_SUBDIRS)
-AC_SUBST(EXT_STATIC)
-AC_SUBST(EXT_SHARED)
-AC_SUBST(EXT_LIBS)
-AC_SUBST(EXTINFO_DEPS)
-dnl AC_SUBST(EXT_INCLUDE_CODE)
-dnl AC_SUBST(EXT_MODULES_PTRS)
-
-dnl
-dnl Solaris requires main code to be position independent in order
-dnl to let shared objects find symbols. Weird. Ugly.
-dnl
-dnl Must be run after all --with-NN options that let the user
-dnl choose dynamic extensions, and after the gcc test.
-dnl
-AC_DEFUN(PHP_SOLARIS_PIC_WEIRDNESS,[
- AC_MSG_CHECKING(whether -fPIC is required)
- if test "$EXT_SHARED" != ""; then
- os=`uname -sr 2>/dev/null`
- case "$os" in
- "SunOS 5.6"|"SunOS 5.7")
- case "$CC" in
- gcc*|egcs*) CFLAGS="$CFLAGS -fPIC";;
- *) CFLAGS="$CFLAGS -fpic";;
- esac
- AC_MSG_RESULT(yes);;
- *)
- AC_MSG_RESULT(no);;
- esac
- else
- AC_MSG_RESULT(no)
- fi
-])
-
-dnl
-dnl Checks whether $withval is "shared" or starts with "shared,XXX"
-dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff
-dnl from $withval.
-dnl
-AC_DEFUN(PHP_WITH_SHARED,[
- case $withval in
- shared)
- shared=yes
- withval=yes
- ;;
- shared,*)
- shared=yes
- withval=`echo $withval | sed -e 's/^shared,//'`
- ;;
- *)
- shared=no
- ;;
- esac
-])
diff --git a/apMakefile.libdir b/apMakefile.libdir
deleted file mode 100644
index 7b5254013a..0000000000
--- a/apMakefile.libdir
+++ /dev/null
@@ -1,4 +0,0 @@
-This is a place-holder which indicates to Configure that it shouldn't
-provide the default targets when building the Makefile in this directory.
-Instead it'll just prepend all the important variable definitions, and
-copy the Makefile.tmpl onto the end.
diff --git a/apMakefile.tmpl b/apMakefile.tmpl
deleted file mode 100644
index e396f65051..0000000000
--- a/apMakefile.tmpl
+++ /dev/null
@@ -1,77 +0,0 @@
-##
-## Apache 1.3 Makefile template for PHP 4.0 Module
-## [src/modules/php4/Makefile.tmpl]
-##
-
-# the parametrized target
-LIB=libphp4.$(LIBEXT)
-
-# objects for building the static library
-OBJS=mod_php4.o
-OBJS_LIB=libmodphp4.a
-
-# objects for building the shared object library
-SHLIB_OBJS=mod_php4.so-o
-SHLIB_OBJS_LIB=libmodphp4-so.a
-
-# the general targets
-all: lib
-lib: $(LIB)
-
-# build the static library by merging the object files
-libphp4.a: $(OBJS) $(OBJS_LIB)
- cp $(OBJS_LIB) $@
- ar r $@ $(OBJS)
- $(RANLIB) $@
-
-# ugly hack to support older Apache-1.3 betas that don't set $LIBEXT
-libphp4.: $(OBJS) $(OBJS_LIB)
- cp $(OBJS_LIB) $@
- ar r $@ $(OBJS)
- $(RANLIB) $@
- cp libphp4. libphp4.a
-
-# build the shared object library by linking the object files
-libphp4.so: $(SHLIB_OBJS) $(SHLIB_OBJS_LIB)
- rm -f $@
- $(LD_SHLIB) $(LDFLAGS_SHLIB) -o $@ $(SHLIB_OBJS) $(SHLIB_OBJS_LIB) $(LIBS)
-
-# 1. extension .o for shared objects cannot be used here because
-# first these files aren't still shared objects and second we
-# have to use a different name to trigger the different
-# implicit Make rule
-# 2. extension -so.o (as used elsewhere) cannot be used because
-# the suffix feature of Make really wants just .x, so we use
-# extension .so-o
-.SUFFIXES: .o .so-o
-.c.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(SPACER) $<
-.c.so-o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(CFLAGS_SHLIB) $(SPACER) $< && mv $*.o $*.so-o
-
-# cleanup
-clean:
- -rm -f $(OBJS) $(SHLIB_OBJS) $(LIB)
-
-# We really don't expect end users to use this rule. It works only with
-# gcc, and rebuilds Makefile.tmpl. You have to re-run Configure after
-# using it.
-depend:
- cp Makefile.tmpl Makefile.tmpl.bak \
- && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.tmpl > Makefile.new \
- && gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \
- && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' Makefile.new \
- > Makefile.tmpl \
- && rm Makefile.new
-
-#Dependencies
-
-$(OBJS): Makefile
-
-# DO NOT REMOVE
-mod_php4.o: mod_php4.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \
- $(INCDIR)/alloc.h $(INCDIR)/buff.h \
- $(INCDIR)/http_config.h \
- $(INCDIR)/http_core.h $(INCDIR)/http_main.h \
- $(INCDIR)/http_protocol.h $(INCDIR)/http_request.h \
- $(INCDIR)/http_log.h $(INCDIR)/util_script.h mod_php4.h
diff --git a/apidoc-zend.txt b/apidoc-zend.txt
deleted file mode 100644
index 4667ed501a..0000000000
--- a/apidoc-zend.txt
+++ /dev/null
@@ -1,276 +0,0 @@
-Following is a merge of two letters I sent to php4beta@lists.php.net,
-describing the changes in API between PHP 3.0 and PHP 4.0 (Zend).
-This file is by no means thorough documentation of the PHP API,
-and is intended for developers who are familiar with the PHP 3.0 API,
-and want to port their code to PHP 4.0, or take advantage of its new
-features. For highlights about the PHP 3.0 API, consult apidoc.txt.
-
-Zeev
-
---------------------------------------------------------------------------
-
-I'm going to try to list the important changes in API and programming
-techniques that are involved in developing modules for PHP4/Zend, as
-opposed to PHP3. Listing the whole PHP4 API is way beyond my scope here,
-it's mostly a 'diff' from the apidoc.txt, which you're all pretty familiar
-with.
-An important note that I neglected to mention yesterday - the php4 tree is
-based on the php 3.0.5 tree, plus all 3.0.6 patches hand-patched into it.
-Notably, it does NOT include any 3.0.7 patches. All of those have to be
-reapplied, with extreme care - modules should be safe to patch (mostly),
-but anything that touches the core or main.c will almost definitely require
-changes in order to work properly.
-
-[1] Symbol Tables
-
-One of the major changes in Zend involves changing the way symbols tables
-work. Zend enforces reference counting on all values and resources. This
-required changes in the semantics of the hash tables that implement symbol
-tables. Instead of storing pval in the hashes, we now store pval *. All
-of the API functions in Zend were changed in a way that this change is
-completely transparent. However, if you've used 'low level' hash functions
-to access or update elements in symbol tables, your code will require
-changes. Following are two simple examples, one demonstrates the
-difference between PHP3 and Zend when reading a symbol's value, and the
-other demonstrates the difference when writing a value.
-
-php3_read()
-{
- pval *foo;
-
- _php3_hash_find(ht, "foo", sizeof("foo"), &foo);
- /* foo->type is the type and foo->value is the value */
-}
-
-
-php4_read()
-{
- pval **foo;
-
- _php3_hash_find(ht, "foo", sizeof("foo"), &foo);
- /* (*foo)->type is the type and (*foo)->value is the value */
-}
-
----
-
-php3_write()
-{
- pval newval;
-
- newval.type = ...;
- newval.value = ...;
- _php3_hash_update(ht, "bar", sizeof("bar"), &newval, sizeof(pval), NULL);
-}
-
-php4_write()
-{
- pval *newval = (pval *) emalloc(sizeof(pval));
-
- newval->refcount=1;
- newval->is_ref=0;
- newval->type = ...;
- newval->value = ...;
- _php3_hash_update(ht, "bar", sizeof("bar"), &newval, sizeof(pval *), NULL);
-}
-
-
-[2] Resources
-
-One of the 'cute' things about the reference counting support is that it
-completely eliminates the problem of resource leaking. A simple loop that
-included '$result = mysql_query(...)' in PHP leaked unless the user
-remembered to run mysql_free($result) at the end of the loop body, and
-nobody really did. In order to take advantage of the automatic resource
-deallocation upon destruction, there's virtually one small change you need
-to conduct. Change the result type of a resource that you want to destroy
-itself as soon as its no longer referenced (just about any resource I can
-think of) as IS_RESOURCE, instead of as IS_LONG. The rest is magic.
-
-A special treatment is required for SQL modules that follow MySQL's
-approach for having the link handle as an optional argument. Modules that
-follow the MySQL module model, store the last opened link in a global
-variable, that they use in case the user neglects to explicitly specify a
-link handle. Due to the way referenec counting works, this global
-reference is just like any other reference, and must increase that SQL link
-resource's reference count (otherwise, it will be closed prematurely).
-Simply, when you set the default link to a certain link, increase that
-link's reference count by calling zend_list_addref().
-As always, the MySQL module is the one used to demonstrate 'new
-technology'. You can look around it and look for IS_RESOURCE, as well as
-zend_list_addref(), to see a clear example of how the new API should be used.
-
-
-[3] Thread safety issues
-
-I'm not going to say that Zend was designed with thread safety in mind, but
-from some point, we've decided upon several guidelines that would make the
-move to thread safety much, much easier. Generally, we've followed the PHP
-3.1 approach of moving global variables to a structure, and encapsulating
-all global variable references within macros. There are three main
-differences:
-1. We grouped related globals in a single structure, instead of grouping
-all globals in one structure.
-2. We've used much, much shorter macro names to increase the readability
-of the source code.
-3. Regardless of whether we're compiling in thread safe mode or not, all
-global variables are *always* stored in a structure. For example, you
-would never have a global variable 'foo', instead, it'll be a property of a
-global structure, for example, compiler_globals.foo. That makes
-development much, much easier, since your code will simply not compile
-unless you remember to put the necessary macro around foo.
-
-To write code that'll be thread safe in the future (when we release our
-thread safe memory manager and work on integrating it), you can take a look
-at zend_globals.h. Essentially, two sets of macros are defined, one for
-thread safe mode, and one for thread unsafe mode. All global references
-are encapsulated within ???G(varname), where ??? is the appropriate prefix
-for your structure (for example, so far we have CG(), EG() and AG(), which
-stand for the compiler, executor and memory allocator, respectively).
-When compiling with thread safety enabled, each function that makes use of
-a ???G() macro, must obtain the pointer to its copy of the structure. It
-can do so in one of two forms:
-1. It can receive it as an argument.
-2. It can fetch it.
-
-Obviously, the first method is preferable since it's much quicker.
-However, it's not always possible to send the structure all the way to a
-particular function, or it may simply bloat the code too much in some
-cases. Functions that receive the globals as an argument, should look like
-this:
-
-rettype functioname(???LS_D) <-- a function with no arguments
-rettype functioname(type arg1, ..., type argn ???LS_DC) <-- a funciton with
-arguments
-
-Calls to such functions should look like this:
-functionname(???LS_C) <-- a function with no arguments
-functionname(arg1, ..., argn ???LS_CC) <-- a function with arguments
-
-LS stands for 'Local Storage', _C stands for Call and _CC stands for Call
-Comma, _D stands for Declaration and _DC stands for Declaration Comma.
-Note that there's NO comma between the last argument and ???LS_DC or ???LS_CC.
-
-In general, every module that makes use of globals should use this approach
-if it plans to be thread safe.
-
-
-[4] Generalized INI support
-
-The code comes to solve several issues:
-
-a. The ugly long block of code in main.c that reads values from the
-cfg_hash into php3_ini.
-b. Get rid of php3_ini. The performance penalty of copying it around all
-the time in the Apache module probably wasn't too high, but
-psychologically, it annoyed me :)
-c. Get rid of the ugly code in mod_php4.c, that also reads values from
-Apache directives and puts them into the php3_ini structure.
-d. Generalize all the code so that you only have to add an entry in one
-single place and get it automatically supported in php3.ini, Apache, Win32
-registry, runtime function ini_get() and ini_alter() and any future method
-we might have.
-e. Allow users to easily override *ANY* php3.ini value, except for ones
-they're not supposed to, of course.
-
-I'm happy to say that I think I pretty much reached all goals. php_ini.c
-implements a mechanism that lets you add your INI entry in a single place,
-with a default value in case there's no php3.ini value. What you get by
-using this mechanism:
-
-1. Automatic initialization from php3.ini if available, or from the
-default value if not.
-2. Automatic support in ini_alter(). That means a user can change the
-value for this INI entry at runtime, without you having to add in a single
-line of code, and definitely no additional function (for example, in PHP3,
-we had to add in special dedicated functions, like
-set_magic_quotes_runtime() or the likes - no need for that anymore).
-3. Automatic support in Apache .conf files.
-4. No need for a global php3_ini-like variable that'll store all that
-info. You can directly access each INI entry by name, in runtime. 'Sure,
-that's not revolutionary, it's just slow' is probably what some of you
-think - which is true, but, you can also register a callback function that
-is called each time your INI entry is changed, if you wish to store it in a
-cached location for intensive use.
-5. Ability to access the current active value for a given INI entry, and
-the 'master' value.
-
-Of course, (2) and (3) are only applicable in some cases. Some entries
-shouldn't be overriden by users in runtime or through Apache .conf files -
-you can, of course, mark them as such.
-
-
-So, enough hype, how does it work.
-
-Essentially:
-
-static PHP_INI_MH(OnChangeBar); /* declare a message handler for a change
-in "bar" */
-
-PHP_INI_BEGIN()
- PHP_INI_ENTRY("foo", "1", PHP_INI_ALL, NULL, NULL)
- PHP_INI_ENTRY("bar", "bah", PHP_INI_SYSTEM, OnChangeBar, NULL)
-PHP_INI_END()
-
-static PHP_INI_MH(OnChangeBar)
-{
- a_global_var_for_bar = new_value;
- return SUCCESS;
-}
-
-int whatever_minit(INIT_FUNC_ARGS)
-{
- ...
- REGISTER_INI_ENTRIES();
- ...
-}
-
-
-int whatever_mshutdown(SHUTDOWN_FUNC_ARGS)
-{
- ...
- UNREGISTER_INI_ENTRIES();
- ...
-}
-
-
-and that's it. Here's what it does. As you can probably guess, this code
-registers two INI entries - "foo" and "bar". They're given defaults "1"
-and "bah" respectively - note that all defaults are always given as
-strings. That doesn't reduce your ability to use integer values, simply
-specify them as strings. "foo" is marked so that it can be changed by
-anyone at any time (PHP_INI_ALL), whereas "foo" is marked so it can be
-changed only at startup in the php3.ini only, presumably, by the system
-administrator (PHP_INI_SYSTEM).
-When "foo" changes, no function is called. Access to it is done using the
-macros INI_INT("foo"), INI_FLT("foo") or INI_STR("foo"), which return a
-long, double or char * respectively (strings that are returned aren't
-duplicated - if they're manipulated, you must duplicate them first). You
-can also access the original value (the 'master' value, in case one of them
-was overriden by a user) using another pair of macros:
-INI_ORIG_INT("foo"), INI_ORIG_FLT("foo") and INI_ORIG_STR("foo").
-
-When "bar" changes, a special message handler is called, OnBarChange().
-Always declare those message handlers using PHP_INI_MH(), as they might
-change in the future. Message handlers are called as soon as an ini entry
-initializes or changes, and allow you to cache a certain INI value in a
-quick C structure. In this example, whenever "bar" changes, the new value
-is stored in a_global_var_for_bar, which is a global char * pointer,
-quickly accessible from other functions. Things get a bit more complicated
-when you want to implement a thread-safe module, but it's doable as well.
-Message handlers may return SUCCESS to acknowledge the new value, or
-FAILURE to reject it. That enables you to reject invalid values for some
-INI entries if you want. Finally, you can have a pointer passed to your
-message handler - that's the fifth argument to PHP_INI_ENTRY(). It is
-passed as mh_arg to the message handler.
-
-Remember that for certain values, there's really no reason to mess with a
-callback function. A perfect example for this are the syntax highlight
-colors, which no longer have a dedicated global C slot that stores them,
-but instead, are fetched from the php_ini hash on demand.
-
-"As always", for a perfect working example of this mechanism, consult
-functions/mysql.c. This module uses the new INI entry mechanism, and was
-also converted to be thread safe in general, and in its php_ini support in
-particular. Converting your modules to look like this for thread safety
-isn't a bad idea (not necessarily now, but in the long run).
-
diff --git a/apidoc.txt b/apidoc.txt
deleted file mode 100644
index 34eac2896c..0000000000
--- a/apidoc.txt
+++ /dev/null
@@ -1,492 +0,0 @@
-PHP Version 3.0 API Documentation
-
-Table of Contents
------------------
- 1. Function Prototype
- 2. Function Arguments
- 3. Variable number of function arguments
- 4. Using the function arguments
- 5. Memory management in functions
- 6. Setting variables in the symbol table
- 7. Returning values from functions
- 8. Returning 'complex' values from functions (arrays or objects)
- 9. Using the resource list
-10. Using the persistent resource table
-11. Adding runtime configuration directives
------------------
-
-1. Function Prototype
-
- All functions look like this:
-
- PHP_FUNCTION(foo) {
-
- }
-
- Even if your function doesn't take any arguments, this is how it is
- called.
-
------------------
-
-2. Function Arguments
-
- Arguments are always of type pval. This type contains a union which
- has the actual type of the argument. So, if your function takes two
- arguments, you would do something like the following at the top of your
- function:
-
- pval *arg1, *arg2;
- if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&arg1,&arg2)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- NOTE: Arguments can be passed either by value or by reference. In both
- cases you will need to pass &(pval *) to getParameters. If you want to
- check if the n'th parameter was sent to you by reference or not, you can
- use the function, ParameterPassedByReference(ht,n). It will return either
- 1 or 0.
-
- When you change any of the passed parameters, whether they are sent by
- reference or by value, you can either start over with the parameter by
- calling pval_destructor on it, or if it's an ARRAY you want to add to,
- you can use functions similar to the ones in internal_functions.h which
- manipulate return_value as an ARRAY.
-
- Also if you change a parameter to IS_STRING make sure you first assign
- the new estrdup'ed string and the string length, and only later change the
- type to IS_STRING. If you change the string of a parameter which already
- IS_STRING or IS_ARRAY you should run pval_destructor on it first.
-
------------------
-
-3. Variable number of function arguments
-
- A function can take a variable number of arguments. If your function can
- take either 2 or 3 arguments, use the following:
-
- pval *arg1, *arg2, *arg3;
- int arg_count = ARG_COUNT(ht);
-
- if (arg_count<2 || arg_count>3 ||
- getParameters(ht,arg_count,&arg1,&arg2,&arg3)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
-------------------
-
-4. Using the function arguments
-
- The type of each argument is stored in the pval type field:
-
-
- This type can be any of the following:
-
- IS_STRING String
- IS_DOUBLE Double-precision floating point
- IS_LONG Long
- IS_ARRAY Array
-
- IS_EMPTY ??
- IS_USER_FUNCTION ??
- IS_INTERNAL_FUNCTION ?? (if some of these cannot be passed to a
- function - delete)
- IS_CLASS ??
- IS_OBJECT ??
-
- If you get an argument of one type and would like to use it as another,
- or if you just want to force the argument to be of a certain type, you
- can use one of the following conversion functions:
-
- convert_to_long(arg1);
- convert_to_double(arg1);
- convert_to_string(arg1);
- convert_to_boolean_long(arg1); If the string is "" or "0" it
- becomes 0, 1 otherwise
- convert_string_to_number(arg1); Converts string to either LONG or
- DOUBLE depending on string
-
- These function all do in-place conversion. They do not return anything.
-
- The actual argument is stored in a union.
-
- For type IS_STRING, use arg1->value.str.val
- IS_LONG arg1->value.lval
- IS_DOUBLE arg1->value.dval
-
--------------------
-
-5. Memory management in functions
-
- Any memory needed by a function should be allocated with either emalloc()
- or estrdup(). These are memory handling abstraction functions that look
- and smell like the normal malloc() and strdup() functions. Memory should
- be freed with efree().
-
- There are two kinds of memory in this program. Memory which is returned
- to the parser in a variable and memory which you need for temporary
- storage in your internal function. When you assign a string to a
- variable which is returned to the parser you need to make sure you first
- allocate the memory with either emalloc or estrdup. This memory
- should NEVER be freed by you, unless you later, in the same function
- overwrite your original assignment (this kind of programming practice is
- not good though).
-
- For any temporary/permanent memory you need in your functions/library you
- should use the three emalloc(), estrdup(), and efree() functions. They
- behave EXACTLY like their counterpart functions. Anything you emalloc()
- or estrdup() you have to efree() at some point or another, unless it's
- supposed to stick around until the end of the program, otherwise there
- will be a memory leak. The meaning of "the functions behave exactly like
- their counterparts" is if you efree() something which was not
- emalloc()'ed nor estrdup()'ed you might get a segmentation fault. So
- please take care and free all of your wasted memory. One of the biggest
- improvements in PHP 3.0 will hopefully be the memory management.
-
- If you compile with "-DDEBUG", PHP3 will print out a list of all
- memory that was allocated using emalloc() and estrdup() but never
- freed with efree() when it is done running the specified script.
-
--------------------
-
-6. Setting variables in the symbol table
-
- A number of macros are available which make it easier to set a variable
- in the symbol table:
-
- SET_VAR_STRING(name,value) **
- SET_VAR_DOUBLE(name,value)
- SET_VAR_LONG(name,value)
-
- ** Be careful here. The value part must be malloc'ed manually because
- the memory management code will try to free this pointer later. Do
- not pass statically allocated memory into a SET_VAR_STRING
-
- Symbol tables in PHP 3.0 are implemented as hash tables. At any given time,
- &symbol_table is a pointer to the 'main' symbol table, and active_symbol_table
- points to the currently active symbol table (these may be identical like in
- startup, or different, if you're inside a function).
-
- The following examples use 'active_symbol_table'. You should replace it with
- &symbol_table if you specifically want to work with the 'main' symbol table.
- Also, the same funcions may be applied to arrays, as explained below.
-
- * To check whether a variable named $foo already exists in a symbol table:
- if (hash_exists(active_symbol_table,"foo",sizeof("foo"))) { exists... }
- else { doesn't exist }
-
- * If you also need to get the type of the variable, you can use:
- hash_find(active_symbol_table,"foo",sizeof("foo"),&pvalue);
- check(pvalue.type);
-
- Arrays in PHP 3.0 are implemented using the same hashtables as symbol tables.
- This means the two above functions can also be used to check variables
- inside arrays.
-
- If you want to define a new array in a symbol table, you should do this:
-
- 1. Possibly check it exists and abort, using hash_exists()
- or hash_find().
- 2. Code:
-
- pval arr;
-
- if (array_init(&arr) == FAILURE) { failed... };
- hash_update(active_symbol_table,"foo",sizeof("foo"),&arr,sizeof(pval),NULL);
-
- This code declares a new array, named $foo, in the active symbol table.
- This array is empty.
-
- Here's how to add new entries to it:
-
- pval entry;
-
- entry.type = IS_LONG;
- entry.value.lval = 5;
-
- hash_update(arr.value.ht,"bar",sizeof("bar"),&entry,sizeof(pval),NULL); /* defines $foo["bar"] = 5 */
- hash_index_update(arr.value.ht,7,&entry,sizeof(pval),NULL); /* defines $foo[7] = 5 */
- hash_next_index_insert(arr.value.ht,&entry,sizeof(pval),NULL); /* defines the next free place in $foo[],
- * $foo[8], to be 5 (works like php2)
- */
-
- If you'd like to modify a value that you inserted to a hash, you must first retreive it from the hash. To
- prevent that overhead, you can supply a pval ** to the hash add function, and it'll be updated with the
- pval * address of the inserted element inside the hash. If that value is NULL (like in all of the
- above examples) - that parameter is ignored.
-
- hash_next_index_insert() works more or less using the same logic
- "$foo[] = bar;" works in PHP 2.0.
-
- If you are building an array to return from a function, you can initialize
- the array just like above by doing:
-
- if (array_init(return_value) == FAILURE) { failed...; }
-
- and then adding values with the helper functions:
-
- add_next_index_long(return_value,long_value);
- add_next_index_double(return_value,double_value);
- add_next_index_string(return_value,estrdup(string_value));
-
- Of course, if the adding isn't done right after the array
- initialization, you'd probably have to look for the array first:
-
- pval *arr;
-
- if (hash_find(active_symbol_table,"foo",sizeof("foo"),(void **)&arr)==FAILURE) { can't find... }
- else { use arr->value.ht... }
-
- Note that hash_find receives a pointer to a pval pointer, and
- not a pval pointer.
-
- Just about any hash function returns SUCCESS or FAILURE (except for
- hash_exists() that returns a boolean truth value).
-
--------------------
-
-7. Returning 'simple' values from functions (integers, floats or strings)
-
- A number of macros are available to make it easier to return things from
- functions:
-
- These set the return value and return from the function:
-
- RETURN_FALSE
- RETURN_TRUE
- RETURN_LONG(l)
- RETURN_STRING(s,dup) If dup is true, duplicates the string
- RETURN_STRINGL(s,l,dup) Return string (s) specifying length (l).
- RETURN_DOUBLE(d)
-
- These only set the return value:
-
- RETVAL_FALSE
- RETVAL_TRUE
- RETVAL_LONG(l)
- RETVAL_STRING(s,dup) If dup is true, duplicates the string
- RETVAL_STRINGL(s,l,dup) Return string (s) specifying length (l).
- RETVAL_DOUBLE(d)
-
- The string macros above will all estrdup() the passed 's' argument,
- so you can safely free the argument after calling the macro, or
- alternatively use statically allocated memory.
-
- If your function returns boolean success/error responses, always use
- RETURN_TRUE and RETURN_FALSE respectively.
-
--------------------
-
-8. Returning 'complex' values from functions (arrays or objects)
-
- Your function can also return a complex data type such as an object
- or an array.
-
- Returning an object:
-
- 1. Call object_init(return_value).
- 2. Fill it up with values:
-
- add_property_long(return_value,property_name,l) Add a property named 'property_name', of type long, equals to 'l'
- add_property_double(return_value,property_name,d) Same, only a double
- add_property_string(return_value,property_name,str) Same, only a string
- add_property_stringl(return_value,property_name,str,l) Add a property named 'property_name', of type string, string is 'str' with length 'l'
-
- 3. Possibly, register functions for this object. In order to
- obtain values from the object, the function would have to fetch
- "this" from the active_symbol_table. Its type should be IS_OBJECT,
- and it's basically a regular hash table (i.e., you can use regular
- hash functions on .value.ht). The actual registration of the
- function can be done using:
-
- add_method(return_value,function_name,function_ptr)
-
-
- Returning an array:
-
- 1. Call array_init(return_value).
- 2. Fill it up with values:
-
- add_assoc_long(return_value,key,l) add associative entry with key 'key' and long value 'l'
- add_assoc_double(return_value,key,d)
- add_assoc_string(return_value,key,str)
- add_assoc_stringl(return_value,key,str,length) specify the string length
-
- add_index_long(return_value,index,l) add entry in index 'index' with long value 'l'
- add_index_double(return_value,index,d)
- add_index_string(return_value,index,str)
- add_index_stringl(return_value,index,str,length) specify the string length
-
- add_next_index_long(return_value,l) add an array entry in the next free offset with long value 'l'
- add_next_index_double(return_value,d)
- add_next_index_string(return_value,str)
- add_next_index_stringl(return_value,str,length) specify the string length
-
--------------------
-
-9. Using the resource list
-
- PHP 3.0 has a standard way of dealing with various types of resources,
- that replaces all of the local linked lists in PHP 2.0.
-
- Available functions:
-
- php3_list_insert(ptr, type) returns the 'id' of the newly inserted resource
- php3_list_delete(id) delete the resource with the specified id
- php3_list_find(id,*type) returns the pointer of the resource with the specified id, updates 'type' to the resource's type
-
- Typically, these functions are used for SQL drivers but they can be
- used for anything else, and are used, for instance, for maintaining
- file descriptors.
-
- Typical list code would look like this:
-
- Adding a new resource:
-
- RESOURCE *resource;
-
- ...allocate memory for resource and acquire resource...
- /* add a new resource to the list */
- return_value->value.lval = php3_list_insert((void *) resource, LE_RESOURCE_TYPE);
- return_value->type = IS_LONG;
-
- Using an existing resource:
-
- pval *resource_id;
- RESOURCE *resource;
- int type;
-
- convert_to_long(resource_id);
- resource = php3_list_find(resource_id->value.lval, &type);
- if (type != LE_RESOURCE_TYPE) {
- php3_error(E_WARNING,"resource index %d has the wrong type",resource_id->value.lval);
- RETURN_FALSE;
- }
- ...use resource...
-
- Deleting an existing resource:
-
- pval *resource_id;
- RESOURCE *resource;
- int type;
-
- convert_to_long(resource_id);
- php3_list_delete(resource_id->value.lval);
-
-
- The resource types should be registered in php3_list.h, in enum
- list_entry_type. In addition, one should add shutdown code for any
- new resource type defined, in list.c's list_entry_destructor() (even if
- you don't have anything to do on shutdown, you must add an empty case).
-
--------------------
-
-10. Using the persistent resource table
-
- PHP 3.0 has a standard way of storing persistent resources (i.e.,
- resources that are kept in between hits). The first module to use
- this feature was the MySQL module, and mSQL followed it, so one can
- get the general impression of how a persistent resource should be
- used by reading mysql.c. The functions you should look at are:
- php3_mysql_do_connect()
- php3_mysql_connect()
- php3_mysql_pconnect()
-
- The general idea of persistence modules is this:
- 1. Code all of your module to work with the regular resource list
- mentioned in section (9).
- 2. Code extra connect functions that check if the resource already
- exists in the persistent resource list. If it does, register it
- as in the regular resource list as a pointer to the persistent
- resource list (because of 1., the rest of the code
- should work immediately). If it doesn't, then create it, add it
- to the persistent resource list AND add a pointer to it from the
- regular resource list, so all of the code would work since it's
- in the regular resource list, but on the next connect, the
- resource would be found in the persistent resource list and be
- used without having to recreate it.
- You should register these resources with a different type (e.g.
- LE_MYSQL_LINK for non-persistent link and LE_MYSQL_PLINK for
- a persistent link).
-
- If you read mysql.c, you'll notice that except for the more complex
- connect function, nothing in the rest of the module has to be changed.
-
- The very same interface exists for the regular resource list and the
- persistent resource list, only 'list' is replaced with 'plist':
-
- php3_plist_insert(ptr, type) returns the 'id' of the newly inserted resource
- php3_plist_delete(id) delete the resource with the specified id
- php3_plist_find(id,*type) returns the pointer of the resource with the specified id, updates 'type' to the resource's type
-
- However, it's more than likely that these functions would prove
- to be useless for you when trying to implement a persistent module.
- Typically, one would want to use the fact that the persistent resource
- list is really a hash table. For instance, in the MySQL/mSQL modules,
- when there's a pconnect() call (persistent connect), the function
- builds a string out of the host/user/passwd that were passed to the
- function, and hashes the SQL link with this string as a key. The next
- time someone calls a pconnect() with the same host/user/passwd, the
- same key would be generated, and the function would find the SQL link
- in the persistent list.
-
- Until further documented, you should look at mysql.c or msql.c to
- see how one should use the plist's hash table abilities.
-
- One important thing to note: resources going into the persistent
- resource list must *NOT* be allocated with PHP's memory manager, i.e.,
- they should NOT be created with emalloc(), estrdup(), etc. Rather,
- one should use the regular malloc(), strdup(), etc. The reason for
- this is simple - at the end of the request (end of the hit), every
- memory chunk that was allocated using PHP's memory manager is deleted.
- Since the persistent list isn't supposed to be erased at the end
- of a request, one mustn't use PHP's memory manager for allocating
- resources that go to it.
-
- Shutting down persistent resources:
-
- When you register resource that's going to be in the persistent list,
- you should add destructors to it both in the non-persistent list
- and in the persistent list.
- The destructor in the non-persistent list destructor shouldn't do anything.
- The one in the persistent list destructor should properly free any
- resources obtained by that type (e.g. memory, SQL links, etc). Just like
- with the non-persistent resources, you *MUST* add destructors for every
- resource, even it requires no destructotion and the destructor would
- be empty.
- Remember, since emalloc() and friends aren't to be used in conjunction
- with the persistent list, you mustn't use efree() here either.
-
--------------------
-
-11. Adding runtime configuration directives
-
-Many of the features of PHP3 can be configured at runtime. These
-configuration directives can appear in either the designated php3.ini
-file, or in the case of the Apache module version in the Apache .conf
-files. The advantage of having them in the Apache .conf files is that
-they can be configured on a per-directory basis. This means that one
-directory may have a certain safemodeexecdir for example, while another
-directory may have another. This configuration granularity is especially
-handy when a server supports multiple virtual hosts.
-
-The steps required to add a new directive:
-
- 1. Add directive to php3_ini_structure struct in mod_php4.h.
-
- 2. In main.c, edit the php3_module_startup function and add the
- appropriate cfg_get_string() or cfg_get_long() call.
-
- 3. Add the directive, restrictions and a comment to the php3_commands
- structure in mod_php4.c. Note the restrictions part. RSRC_CONF are
- directives that can only be present in the actual Apache .conf files.
- Any OR_OPTIONS directives can be present anywhere, include normal
- .htaccess files.
-
- 4. In either php3take1handler() or php3flaghandler() add the appropriate
- entry for your directive.
-
- 5. In the configuration section of the _php3_info() function in
- functions/info.c you need to add your new directive.
-
- 6. And last, you of course have to use your new directive somewhere.
- It will be addressable as php3_ini.directive
diff --git a/build-defs.h.in b/build-defs.h.in
deleted file mode 100644
index 3095d6e874..0000000000
--- a/build-defs.h.in
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- C -*-
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Stig Sæther Bakken <ssb@guardian.no> |
- +----------------------------------------------------------------------+
- */
-
-#define PHP_ADA_INCLUDE ""
-#define PHP_ADA_LFLAGS ""
-#define PHP_ADA_LIBS ""
-#define PHP_APACHE_INCLUDE ""
-#define PHP_APACHE_TARGET ""
-#define PHP_FHTTPD_INCLUDE ""
-#define PHP_FHTTPD_LIB ""
-#define PHP_FHTTPD_TARGET ""
-#define PHP_BINNAME "@BINNAME@"
-#define PHP_CFLAGS "@CFLAGS@"
-#define PHP_DBASE_LIB ""
-#define PHP_DEBUG "@DEBUG_CFLAGS@"
-#define PHP_GDBM_INCLUDE ""
-#define PHP_HSREGEX ""
-#define PHP_IBASE_INCLUDE ""
-#define PHP_IBASE_LFLAGS ""
-#define PHP_IBASE_LIBS ""
-#define PHP_IFX_INCLUDE ""
-#define PHP_IFX_LFLAGS ""
-#define PHP_IFX_LIBS ""
-#define PHP_INSTALL_IT "@INSTALL_IT@"
-#define PHP_IODBC_INCLUDE ""
-#define PHP_IODBC_LFLAGS ""
-#define PHP_IODBC_LIBS ""
-#define PHP_MSQL_INCLUDE ""
-#define PHP_MSQL_LFLAGS ""
-#define PHP_MSQL_LIBS ""
-#define PHP_MYSQL_INCLUDE ""
-#define PHP_MYSQL_LFLAGS ""
-#define PHP_MYSQL_LIBS ""
-#define PHP_ODBC_TYPE "@ODBC_TYPE@"
-#define PHP_ODBC_INCLUDE "@ODBC_INCLUDE@"
-#define PHP_ODBC_LFLAGS "@ODBC_LFLAGS@"
-#define PHP_ODBC_LIBS "@ODBC_LIBS@"
-#define PHP_ORACLE_HOME ""
-#define PHP_ORACLE_INCLUDE ""
-#define PHP_ORACLE_LFLAGS ""
-#define PHP_ORACLE_LIBS ""
-#define PHP_ORACLE_SHLIBS ""
-#define PHP_ORACLE_STLIBS ""
-#define PHP_ORACLE_VERSION ""
-#define PHP_PGSQL_INCLUDE ""
-#define PHP_PGSQL_LFLAGS ""
-#define PHP_PGSQL_LIBS ""
-#define PHP_PROG_SENDMAIL "@PROG_SENDMAIL@"
-#define PHP_REGEX_LIB ""
-#define PHP_SOLID_INCLUDE ""
-#define PHP_SOLID_LIBS ""
-#define PHP_EMPRESS_INCLUDE ""
-#define PHP_EMPRESS_LIBS ""
-#define PHP_SYBASE_INCLUDE ""
-#define PHP_SYBASE_LFLAGS ""
-#define PHP_SYBASE_LIBS ""
-#define PHP_DBM_TYPE ""
-#define PHP_DBM_LIB ""
-#define PHP_LDAP_LFLAGS ""
-#define PHP_LDAP_INCLUDE ""
-#define PHP_LDAP_LIBS ""
-#define PHP_VELOCIS_INCLUDE ""
-#define PHP_VELOCIS_LIBS ""
-
diff --git a/buildconf b/buildconf
deleted file mode 100755
index 7863af8605..0000000000
--- a/buildconf
+++ /dev/null
@@ -1,135 +0,0 @@
-#!/bin/sh
-
-supplied_flag=$1
-
-# do some version checking for the tools we use
-if test "$1" = "--force"; then
- shift
-# this is a posix correct "test -nt"
-elif test "`ls -t buildconf buildconf.stamp 2>/dev/null |head -1`" != "buildconf"; then
- :
-else
- echo "buildconf: checking installation..."
-
- # autoconf 2.13 or newer
- ac_version=`autoconf --version 2>/dev/null|head -1|sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
- if test "$ac_version" = ""; then
- echo "buildconf: autoconf not found."
- echo " You need autoconf version 2.13 or newer installed"
- echo " to build PHP from CVS."
- exit 1
- fi
- IFS=.; set $ac_version; IFS=' '
- if test "$1" = "2" -a "$2" -lt "13" || test "$1" -lt "2"; then
- echo "buildconf: autoconf version $ac_version found."
- echo " You need autoconf version 2.13 or newer installed"
- echo " to build PHP from CVS."
- exit 1
- else
- echo "buildconf: autoconf version $ac_version (ok)"
- fi
-
- # automake 1.4 or newer
- am_version=`automake --version 2>/dev/null|head -1|sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
- if test "$am_version" = ""; then
- echo "buildconf: automake not found."
- echo " You need automake version 1.4 or newer installed"
- echo " to build PHP from CVS."
- exit 1
- fi
- IFS=.; set $am_version; IFS=' '
- if test "$1" = "1" -a "$2" -lt "4" || test "$1" -lt "1"; then
- echo "buildconf: automake version $am_version found."
- echo " You need automake version 1.4 or newer installed"
- echo " to build PHP from CVS."
- exit 1
- else
- echo "buildconf: automake version $am_version (ok)"
- fi
-
- # libtool 1.3.3 or newer
- lt_pversion=`libtool --version 2>/dev/null|sed -e 's/^[^0-9]*//' -e 's/[- ].*//'`
- if test "$lt_pversion" = ""; then
- echo "buildconf: libtool not found."
- echo " You need libtool version 1.3 or newer installed"
- echo " to build PHP from CVS."
- exit 1
- fi
- lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$/.\1/'`
- IFS=.; set $lt_version; IFS=' '
- if test "$1" -gt "1" || test "$2" -gt "3" || test "$2" = "3" -a "$3" -ge "3"
- then
- echo "buildconf: libtool version $lt_pversion (ok)"
- else
- echo "buildconf: libtool version $lt_pversion found."
- echo " You need libtool version 1.3.3 or newer installed"
- echo " to build PHP from CVS."
- exit 1
- fi
-
- touch buildconf.stamp
-fi
-
-if test "$supplied_flag" = "--copy"; then
- automake_flags=--copy
-fi
-
-if test ! -d libzend; then
- if test -d ../libzend; then
- echo "buildconf: linking ../libzend to ./libzend"
- ln -s ../libzend .
- else
- echo "buildconf: can not find libzend"
- echo " libzend should be installed in . or .., how to fetch:"
- echo ""
- echo " cvs -d :pserver:cvsread@cvs.zend.com:/repository login"
- echo " (password \"zend\")"
- echo " cvs -d :pserver:cvsread@cvs.zend.com:/repository co libzend"
- echo ""
- exit 1
- fi
-fi
-if test ! -d TSRM; then
- if test -d ../TSRM; then
- echo "buildconf: linking ../TSRM to ./TSRM"
- ln -s ../TSRM .
- else
- echo "buildconf: can not find TSRM"
- echo " TSRM should be installed in . or .., how to fetch:"
- echo ""
- echo " cvs -d :pserver:cvsread@cvs.zend.com:/repository login"
- echo " (password \"zend\")"
- echo " cvs -d :pserver:cvsread@cvs.zend.com:/repository co TSRM"
- echo ""
- exit 1
- fi
-fi
-
-./scripts/preconfig
-
-libtoolize --automake $automake_flags --force
-
-mv aclocal.m4 aclocal.m4.old 2>/dev/null
-aclocal
-if cmp aclocal.m4.old aclocal.m4 > /dev/null 2>&1; then
- echo "buildconf: keeping aclocal.m4"
- mv aclocal.m4.old aclocal.m4
-else
- echo "buildconf: created or modified aclocal.m4"
-fi
-
-autoheader
-
-automake --add-missing --include-deps $automake_flags
-
-mv configure configure.old 2>/dev/null
-autoconf
-if cmp configure.old configure > /dev/null 2>&1; then
- echo "buildconf: keeping configure"
- mv configure.old configure
-else
- echo "buildconf: created or modified configure"
-fi
-
-(cd libzend; ./buildconf libzend/)
-(cd TSRM; ./buildconf TSRM/)
diff --git a/calendar.mak b/calendar.mak
deleted file mode 100644
index f82afc2f6c..0000000000
--- a/calendar.mak
+++ /dev/null
@@ -1,244 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on calendar.dsp
-!IF "$(CFG)" == ""
-CFG=calendar - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to calendar - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "calendar - Win32 Release" && "$(CFG)" != "calendar - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "calendar.mak" CFG="calendar - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "calendar - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "calendar - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-!IF "$(CFG)" == "calendar - Win32 Release"
-
-OUTDIR=.\module_release
-INTDIR=.\module_release
-# Begin Custom Macros
-OutDir=.\module_release
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_calendar.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\calendar.obj"
- -@erase "$(INTDIR)\dow.obj"
- -@erase "$(INTDIR)\french.obj"
- -@erase "$(INTDIR)\gregor.obj"
- -@erase "$(INTDIR)\jewish.obj"
- -@erase "$(INTDIR)\julian.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(OUTDIR)\php3_calendar.dll"
- -@erase "$(OUTDIR)\php3_calendar.exp"
- -@erase "$(OUTDIR)\php3_calendar.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "./" /I "../" /D "NDEBUG" /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\calendar.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\calendar.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:1 /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\php3_calendar.pdb" /machine:I386 /out:"$(OUTDIR)\php3_calendar.dll" /implib:"$(OUTDIR)\php3_calendar.lib" /libpath:"cgi_release"
-LINK32_OBJS= \
- "$(INTDIR)\calendar.obj" \
- "$(INTDIR)\dow.obj" \
- "$(INTDIR)\french.obj" \
- "$(INTDIR)\gregor.obj" \
- "$(INTDIR)\jewish.obj" \
- "$(INTDIR)\julian.obj"
-
-"$(OUTDIR)\php3_calendar.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "calendar - Win32 Debug"
-
-OUTDIR=.\module_debug
-INTDIR=.\module_debug
-# Begin Custom Macros
-OutDir=.\module_debug
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_calendar.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\calendar.obj"
- -@erase "$(INTDIR)\dow.obj"
- -@erase "$(INTDIR)\french.obj"
- -@erase "$(INTDIR)\gregor.obj"
- -@erase "$(INTDIR)\jewish.obj"
- -@erase "$(INTDIR)\julian.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(INTDIR)\vc60.pdb"
- -@erase "$(OUTDIR)\php3_calendar.dll"
- -@erase "$(OUTDIR)\php3_calendar.exp"
- -@erase "$(OUTDIR)\php3_calendar.ilk"
- -@erase "$(OUTDIR)\php3_calendar.lib"
- -@erase "$(OUTDIR)\php3_calendar.pdb"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "./" /I "../" /D "DEBUG" /D "_DEBUG" /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\calendar.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\calendar.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:1 /subsystem:windows /dll /incremental:yes /pdb:"$(OUTDIR)\php3_calendar.pdb" /debug /machine:I386 /out:"$(OUTDIR)\php3_calendar.dll" /implib:"$(OUTDIR)\php3_calendar.lib" /pdbtype:sept /libpath:"cgi_debug"
-LINK32_OBJS= \
- "$(INTDIR)\calendar.obj" \
- "$(INTDIR)\dow.obj" \
- "$(INTDIR)\french.obj" \
- "$(INTDIR)\gregor.obj" \
- "$(INTDIR)\jewish.obj" \
- "$(INTDIR)\julian.obj"
-
-"$(OUTDIR)\php3_calendar.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF
-
-
-!IF "$(NO_EXTERNAL_DEPS)" != "1"
-!IF EXISTS("calendar.dep")
-!INCLUDE "calendar.dep"
-!ELSE
-!MESSAGE Warning: cannot find "calendar.dep"
-!ENDIF
-!ENDIF
-
-
-!IF "$(CFG)" == "calendar - Win32 Release" || "$(CFG)" == "calendar - Win32 Debug"
-SOURCE=.\dl\calendar\calendar.c
-
-"$(INTDIR)\calendar.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\dl\calendar\dow.c
-
-"$(INTDIR)\dow.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\dl\calendar\french.c
-
-"$(INTDIR)\french.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\dl\calendar\gregor.c
-
-"$(INTDIR)\gregor.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\dl\calendar\jewish.c
-
-"$(INTDIR)\jewish.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\dl\calendar\julian.c
-
-"$(INTDIR)\julian.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-
-!ENDIF
-
diff --git a/cgi_main.c b/cgi_main.c
deleted file mode 100644
index 4a165b80c5..0000000000
--- a/cgi_main.c
+++ /dev/null
@@ -1,501 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Stig Bakken <ssb@fast.no> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
-*/
-
-
-#include "php.h"
-#include "php_globals.h"
-
-#include "SAPI.h"
-
-#if CGI_BINARY
-
-#include <stdio.h>
-#include "php.h"
-#ifdef MSVC5
-#include "win32/time.h"
-#include "win32/signal.h"
-#include <process.h>
-#else
-#include "build-defs.h"
-#endif
-#if HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#if HAVE_SIGNAL_H
-#include <signal.h>
-#endif
-#if HAVE_SETLOCALE
-#include <locale.h>
-#endif
-#include "zend.h"
-#include "php_ini.h"
-#include "php_globals.h"
-#include "main.h"
-#include "fopen-wrappers.h"
-#include "ext/standard/php3_standard.h"
-#include "snprintf.h"
-#if WIN32|WINNT
-#include <io.h>
-#include <fcntl.h>
-#include "win32/syslog.h"
-#include "win32/php_registry.h"
-#else
-#include <syslog.h>
-#endif
-
-#include "zend_compile.h"
-#include "zend_execute.h"
-#include "zend_highlight.h"
-#include "zend_indent.h"
-
-
-#if USE_SAPI
-#include "serverapi/sapi.h"
-void *gLock;
-#ifndef THREAD_SAFE
-struct sapi_request_info *sapi_rqst;
-#endif
-#endif
-
-#if MSVC5 || !defined(HAVE_GETOPT)
-#include "php_getopt.h"
-#endif
-
-PHPAPI extern char *php3_ini_path;
-
-#define PHP_MODE_STANDARD 1
-#define PHP_MODE_HIGHLIGHT 2
-#define PHP_MODE_INDENT 3
-
-PHPAPI extern char *optarg;
-PHPAPI extern int optind;
-
-
-static int zend_cgibin_ub_write(const char *str, uint str_length)
-{
- return fwrite(str, 1, str_length, stdout);
-}
-
-
-static void sapi_cgi_send_header(sapi_header_struct *sapi_header, void *server_context)
-{
- if (sapi_header) {
- PHPWRITE_H(sapi_header->header, sapi_header->header_len);
- }
- PHPWRITE_H("\r\n", 2);
-}
-
-
-static int sapi_cgi_read_post(char *buffer, uint count_bytes SLS_DC)
-{
- uint read_bytes=0, tmp_read_bytes;
-
- count_bytes = MIN(count_bytes, SG(request_info).content_length-SG(read_post_bytes));
- while (read_bytes < count_bytes) {
- tmp_read_bytes = read(0, buffer+read_bytes, count_bytes-read_bytes);
- if (tmp_read_bytes<=0) {
- break;
- }
- read_bytes += tmp_read_bytes;
- }
- return read_bytes;
-}
-
-
-static char *sapi_cgi_read_cookies(SLS_D)
-{
- return getenv("HTTP_COOKIE");
-}
-
-
-static sapi_module_struct sapi_module = {
- "PHP Language", /* name */
-
- php_module_startup, /* startup */
- php_module_shutdown_wrapper, /* shutdown */
-
- zend_cgibin_ub_write, /* unbuffered write */
-
- php_error, /* error handler */
-
- NULL, /* header handler */
- NULL, /* send headers handler */
- sapi_cgi_send_header, /* send header handler */
-
- sapi_cgi_read_post, /* read POST data */
- sapi_cgi_read_cookies, /* read Cookies */
-
- STANDARD_SAPI_MODULE_PROPERTIES
-};
-
-
-static void php_cgi_usage(char *argv0)
-{
- char *prog;
-
- prog = strrchr(argv0, '/');
- if (prog) {
- prog++;
- } else {
- prog = "php";
- }
-
- php_printf("Usage: %s [-q] [-h]"
- " [-s]"
- " [-v] [-i] [-f <file>] | "
- "{<file> [args...]}\n"
- " -q Quiet-mode. Suppress HTTP Header output.\n"
- " -s Display colour syntax highlighted source.\n"
- " -f<file> Parse <file>. Implies `-q'\n"
- " -v Version number\n"
- " -c<path> Look for php.ini file in this directory\n"
-#if SUPPORT_INTERACTIVE
- " -a Run interactively\n"
-#endif
- " -d foo[=bar] Define INI entry foo with value 'bar'\n"
- " -e Generate extended information for debugger/profiler\n"
- " -i PHP information\n"
- " -h This help\n", prog);
-}
-
-
-static void init_request_info(SLS_D)
-{
- char *content_length = getenv("CONTENT_LENGTH");
-
- SG(request_info).request_method = getenv("REQUEST_METHOD");
- SG(request_info).query_string = getenv("QUERY_STRING");
- SG(request_info).request_uri = getenv("PATH_INFO");
- SG(request_info).path_translated = NULL; /* we have to update it later, when we have that information */
- SG(request_info).content_type = getenv("CONTENT_TYPE");
- SG(request_info).content_length = (content_length?atoi(content_length):0);
-
- /* CGI does not support HTTP authentication */
- SG(request_info).auth_user = NULL;
- SG(request_info).auth_password = NULL;
-}
-
-
-void define_command_line_ini_entry(char *arg)
-{
- char *name, *value;
-
- name = arg;
- value = strchr(arg, '=');
- if (value) {
- *value = 0;
- value++;
- } else {
- value = "1";
- }
- php_alter_ini_entry(name, strlen(name), value, strlen(value), PHP_INI_SYSTEM);
-}
-
-
-int main(int argc, char *argv[])
-{
- int cgi = 0, c, i, len;
- zend_file_handle file_handle;
- char *s;
-/* temporary locals */
- int cgi_started=0;
- int behavior=PHP_MODE_STANDARD;
- int no_headers=0;
-#if SUPPORT_INTERACTIVE
- int interactive=0;
-#endif
-/* end of temporary locals */
-#ifdef ZTS
- zend_compiler_globals *compiler_globals;
- zend_executor_globals *executor_globals;
- php_core_globals *core_globals;
- sapi_globals_struct *sapi_globals;
-#endif
-
-
-#ifndef ZTS
- if (setjmp(EG(bailout))!=0) {
- return -1;
- }
-#endif
-
-#ifdef ZTS
- tsrm_startup(1,1,0);
-#endif
-
- sapi_startup(&sapi_module);
-
-#if WIN32|WINNT
- _fmode = _O_BINARY; /*sets default for file streams to binary */
- setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */
- setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */
- setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */
-#endif
-
-
- /* Make sure we detect we are a cgi - a bit redundancy here,
- but the default case is that we have to check only the first one. */
- if (getenv("SERVER_SOFTWARE")
- || getenv("SERVER_NAME")
- || getenv("GATEWAY_INTERFACE")
- || getenv("REQUEST_METHOD")) {
- cgi = 1;
- if (argc > 1)
- request_info.php_argv0 = strdup(argv[1]);
- else request_info.php_argv0 = NULL;
-#if FORCE_CGI_REDIRECT
- if (!getenv("REDIRECT_STATUS")) {
- PUTS("<b>Security Alert!</b> PHP CGI cannot be accessed directly.\n\
-\n\
-<P>This PHP CGI binary was compiled with force-cgi-redirect enabled. This\n\
-means that a page will only be served up if the REDIRECT_STATUS CGI variable is\n\
-set. This variable is set, for example, by Apache's Action directive redirect.\n\
-<P>You may disable this restriction by recompiling the PHP binary with the\n\
---disable-force-cgi-redirect switch. If you do this and you have your PHP CGI\n\
-binary accessible somewhere in your web tree, people will be able to circumvent\n\
-.htaccess security by loading files through the PHP parser. A good way around\n\
-this is to define doc_root in your php.ini file to something other than your\n\
-top-level DOCUMENT_ROOT. This way you can separate the part of your web space\n\n\
-which uses PHP from the normal part using .htaccess security. If you do not have\n\
-any .htaccess restrictions anywhere on your site you can leave doc_root undefined.\n\
-\n");
-
- /* remove that detailed explanation some time */
-
- return FAILURE;
- }
-#endif /* FORCE_CGI_REDIRECT */
- }
-
- if (php_module_startup(&sapi_module)==FAILURE) {
- return FAILURE;
- }
-#ifdef ZTS
- compiler_globals = ts_resource(compiler_globals_id);
- executor_globals = ts_resource(executor_globals_id);
- core_globals = ts_resource(core_globals_id);
- sapi_globals = ts_resource(sapi_globals_id);
- if (setjmp(EG(bailout))!=0) {
- return -1;
- }
-#endif
-
- SG(request_info).path_translated = NULL;
- init_request_info(SLS_C);
- SG(server_context) = (void *) 1; /* avoid server_context==NULL checks */
- CG(extended_info) = 0;
-
- if (!cgi) { /* never execute the arguments if you are a CGI */
- request_info.php_argv0 = NULL;
- while ((c = getopt(argc, argv, "c:d:qvisnaeh?vf:")) != -1) {
- switch (c) {
- case 'f':
- if (!cgi_started){
- if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) {
- php_module_shutdown();
- return FAILURE;
- }
- }
- if (no_headers) {
- SG(headers_sent) = 1;
- }
- cgi_started=1;
- SG(request_info).path_translated = estrdup(optarg);
- /* break missing intentionally */
- case 'q':
- no_headers = 1;
- break;
- case 'v':
- if (!cgi_started) {
- if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) {
- php_module_shutdown();
- return FAILURE;
- }
- }
- if (no_headers) {
- SG(headers_sent) = 1;
- }
- php_printf("%s\n", PHP_VERSION);
- exit(1);
- break;
- case 'i':
- if (!cgi_started) {
- if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) {
- php_module_shutdown();
- return FAILURE;
- }
- }
- if (no_headers) {
- SG(headers_sent) = 1;
- }
- cgi_started=1;
- php_print_info(0xFFFFFFFF);
- exit(1);
- break;
- case 's':
- behavior=PHP_MODE_HIGHLIGHT;
- break;
- case 'n':
- behavior=PHP_MODE_INDENT;
- break;
- case 'c':
- php3_ini_path = strdup(optarg); /* intentional leak */
- break;
- case 'a':
-#if SUPPORT_INTERACTIVE
- printf("Interactive mode enabled\n\n");
- interactive=1;
-#else
- printf("Interactive mode not supported!\n\n");
-#endif
- break;
- case 'e':
- CG(extended_info) = 1;
- break;
- case 'h':
- case '?':
- php_output_startup();
- SG(headers_sent) = 1;
- php_cgi_usage(argv[0]);
- exit(1);
- break;
- case 'd':
- define_command_line_ini_entry(optarg);
- break;
- default:
- break;
- }
- }
- } /* not cgi */
-
-#if SUPPORT_INTERACTIVE
- EG(interactive) = interactive;
-#endif
-
- if (!cgi_started) {
- if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) {
- php_module_shutdown();
- return FAILURE;
- }
- }
- if (no_headers) {
- SG(headers_sent) = 1;
- }
- file_handle.filename = "-";
- file_handle.type = ZEND_HANDLE_FP;
- file_handle.handle.fp = stdin;
-
-
- if (!cgi) {
- if (!SG(request_info).query_string) {
- for (i = optind, len = 0; i < argc; i++)
- len += strlen(argv[i]) + 1;
-
- s = malloc(len + 1); /* leak - but only for command line version, so ok */
- *s = '\0'; /* we are pretending it came from the environment */
- for (i = optind, len = 0; i < argc; i++) {
- strcat(s, argv[i]);
- if (i < (argc - 1))
- strcat(s, "+");
- }
- SG(request_info).query_string = s;
- }
- if (!SG(request_info).path_translated && argc > optind)
- SG(request_info).path_translated = argv[optind];
- }
- /* If for some reason the CGI interface is not setting the
- PATH_TRANSLATED correctly, SG(request_info).path_translated is NULL.
- We still call php3_fopen_for_parser, because if you set doc_root
- or user_dir configuration directives, PATH_INFO is used to construct
- the filename as a side effect of php3_fopen_for_parser.
- */
- if(cgi) {
- SG(request_info).path_translated = getenv("PATH_TRANSLATED");
- }
- if (cgi || SG(request_info).path_translated) {
- file_handle.handle.fp = php3_fopen_for_parser();
- file_handle.filename = SG(request_info).path_translated;
- }
-
- if (cgi && !file_handle.handle.fp) {
- PUTS("No input file specified.\n");
-#if 0 /* this is here for debuging under windows */
- if (argc) {
- i = 0;
- php_printf("\nargc %d\n",argc);
- while (i <= argc) {
- php_printf("%s\n",argv[i]);
- i++;
- }
- }
-#endif
- php_request_shutdown((void *) 0);
- php_module_shutdown();
- return FAILURE;
- } else if (file_handle.handle.fp && file_handle.handle.fp!=stdin) {
- /* #!php support */
- c = fgetc(file_handle.handle.fp);
- if (c == '#') {
- while (c != 10 && c != 13) {
- c = fgetc(file_handle.handle.fp); /* skip to end of line */
- }
- CG(zend_lineno)++;
- } else {
- rewind(file_handle.handle.fp);
- }
- }
-
- switch (behavior) {
- case PHP_MODE_STANDARD:
- php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC);
- break;
- case PHP_MODE_HIGHLIGHT: {
- zend_syntax_highlighter_ini syntax_highlighter_ini;
-
- if (open_file_for_scanning(&file_handle CLS_CC)==SUCCESS) {
- php_get_highlight_struct(&syntax_highlighter_ini);
- zend_highlight(&syntax_highlighter_ini);
- fclose(file_handle.handle.fp);
- }
- return 0;
- }
- break;
- case PHP_MODE_INDENT:
- open_file_for_scanning(&file_handle CLS_CC);
- zend_indent();
- fclose(file_handle.handle.fp);
- return 0;
- break;
- }
-
- php3_header(); /* Make sure headers have been sent */
- php_request_shutdown((void *) 0);
- php_module_shutdown();
-#ifdef ZTS
- tsrm_shutdown();
-#endif
- return SUCCESS;
-}
-
-
-#endif
diff --git a/configure.in.in b/configure.in.in
deleted file mode 100644
index 11791d5994..0000000000
--- a/configure.in.in
+++ /dev/null
@@ -1,1017 +0,0 @@
-dnl $Id$ -*- sh -*-
-dnl Process this file with autoconf to produce a configure script.
-
-divert(0)
-AC_INIT(main.c)
-recurse=yes
-for arg in $@; do
- case $arg in
- ## This is to prevent "./config.status --recheck" from
- ## running configure in libzend again.
- --no-recursion) recurse=no;;
- --enable-thread-safety) threadsafe=yes;;
- *) ;;
- esac
-done
-
-if test "$with_shared_apache" != "no" && test -n "$with_shared_apache" ; then
- echo ""
- echo "ERROR: --with-shared-apache is not supported."
- echo " Please read INSTALL.DSO for instructions on using APXS."
- exit 1
-fi
-
-cwd=`pwd`
-cachefile=$cwd/config.cache
-
-if test "$recurse" = "yes"; then
- (set -x; test -d libzend || mkdir libzend ; cd libzend; $cwd/$srcdir/libzend/configure --cache-file=$cachefile $@)
- if test "$threadsafe" = "yes"; then
- (set -x; test -d TSRM || mkdir TSRM; cd TSRM; $cwd/$srcdir/TSRM/configure --cache-file=$cachefile $@)
- fi
- (set -x; cd $srcdir; sh ltconfig --disable-static --enable-dlopen --cache-file=$cachefile ltmain.sh)
-fi
-
-dnl ## Diversion 1 is the initial checking of OS features, programs,
-dnl ## libraries and so on.
-
-dnl ## In diversion 2 we check for compile-time options to the PHP
-dnl ## core and how to deal with different system dependencies. This
-dnl ## includes what regex library is used and whether debugging or short
-dnl ## tags are enabled, and the default behaviour of php.ini options.
-dnl ## This is also where an SAPI interface is selected (choosing between
-dnl ## Apache module, CGI etc.)
-
-dnl ## In diversion 3 we check which extensions should be compiled.
-dnl ## All of these are normally in the extension directories.
-
-dnl ## Diversion 4 is the last one. Here we generate files and clean up.
-
-divert(1)
-
-dnl ## This is where the version number is changed from now on!
-AM_INIT_AUTOMAKE(php, 4.0B3-dev)
-
-PHP_VERSION=$VERSION
-echo "/* automatically generated by configure */" > php_version.h.new
-echo "/* edit configure.in.in to change version number */" >> php_version.h.new
-echo "#define PHP_VERSION \"$PHP_VERSION\"" >> php_version.h.new
-cmp php_version.h.new php_version.h >/dev/null 2>&1
-if test $? -ne 0 ; then
- rm -f php_version.h && mv php_version.h.new php_version.h && \
- echo 'Updated php_version.h'
-else
- rm -f php_version.h.new
-fi
-AC_SUBST(PHP_VERSION)
-
-AM_CONFIG_HEADER(php_config.h)
-AM_MAINTAINER_MODE
-
-dnl We want this one before the checks, so the checks can modify CFLAGS.
-test -z "$CFLAGS" && auto_cflags=1
-
-dnl If we're using cc on HP-UX, add -Ae -D_HPUX_SOURCE [obsolete]
-dnl if test -n "$auto_cflags" && test "`uname -s 2>/dev/null`" = "HP-UX"; then
-dnl test -n "$GCC" || CFLAGS="-Ae $CFLAGS -D_HPUX_SOURCE"
-dnl fi
-
-dnl Checks for programs.
-AM_PROG_LIBTOOL
-AM_SET_LIBTOOL_VARIABLE([--silent])
-AC_PROG_YACC
-if test "$YACC" != "bison -y"; then
- AC_MSG_WARN(You will need bison if you want to regenerate the PHP parsers.)
-else
- AC_MSG_CHECKING(bison version)
- oldIFS=$IFS; IFS=.
- set `bison -V | sed -e 's/^GNU Bison version //'`
- IFS=$oldIFS
- if test "$1" = "1" -a "$2" -lt "25"; then
- AC_MSG_WARN(Bison 1.25 or newer needed to regenerate parsers (found $1.$2).)
- fi
- AC_MSG_RESULT($1.$2 (ok))
-fi
-
-dnl ## there has to be a better way...
-dnl## OLDLIBS=$LIBS; LIBS=""
-AC_PROG_CC
-dnl## LIBS=$OLDLIBS
-
-AM_PROG_CC_STDC
-
-AC_PROG_RANLIB
-AC_PROG_CC_C_O
-AC_PROG_LN_S
-AC_PATH_PROG(PERL_PATH, perl)
-
-
-dnl Make flex scanners use const if they can, even if __STDC__ is not
-dnl true, for compilers like Sun's that only set __STDC__ true in
-dnl "limit-to-ANSI-standard" mode, not in "ANSI-compatible" mode
-AC_C_CONST
-if test "$ac_cv_c_const" = "yes" ; then
- LEX_CFLAGS="-DYY_USE_CONST"
-fi
-AC_SUBST(LEX_CFLAGS)
-
-dnl Hack to work around a Mac OS X cpp problem
-dnl Known versions needing this workaround are 5.3 and 5.4
-if test "$ac_cv_prog_gcc" = "yes" -a "`uname -s`" = "Rhapsody"; then
- CPPFLAGS="$CPPFLAGS -traditional-cpp"
-fi
-
-if test "`uname -sv`" = "AIX 4" -a "$GCC" != "yes"; then
- APXS_EXP="-bE:mod_php4.exp"
-fi
-AC_SUBST(APXS_EXP)
-
-dnl Ugly hack to get around a problem with gcc on AIX.
-if test "$CC" = "gcc" -a "$ac_cv_prog_cc_g" = "yes" -a \
- "`uname -sv`" = "AIX 4"; then
- CFLAGS=`echo $CFLAGS | sed -e 's/-g//'`
-fi
-
-dnl check for -R, etc. switch
-AC_MSG_CHECKING(if compiler supports -R)
-AC_CACHE_VAL(php_cv_cc_dashr,[
- SAVE_LIBS="${LIBS}"
- LIBS="-R /usr/lib ${LIBS}"
- AC_TRY_LINK([], [], php_cv_cc_dashr=yes, php_cv_cc_dashr=no)
- LIBS="${SAVE_LIBS}"])
-AC_MSG_RESULT($php_cv_cc_dashr)
-if test $php_cv_cc_dashr = "yes"; then
- ld_runpath_switch="-R"
- apxs_runpath_switch="-Wl,-R'"
-else
- AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
- AC_CACHE_VAL(php_cv_cc_rpath,[
- SAVE_LIBS="${LIBS}"
- LIBS="-Wl,-rpath,/usr/lib ${LIBS}"
- AC_TRY_LINK([], [], php_cv_cc_rpath=yes, php_cv_cc_rpath=no)
- LIBS="${SAVE_LIBS}"])
- AC_MSG_RESULT($php_cv_cc_rpath)
- if test $php_cv_cc_rpath = "yes"; then
- ld_runpath_switch="-Wl,-rpath,"
- apxs_runpath_switch="-Wl,'-rpath "
- else
- dnl something innocuous
- ld_runpath_switch="-L"
- apxs_runpath_switch="-L'"
- fi
-fi
-
-AC_MSG_CHECKING([if compiler supports -Wl,--version-script])
-AC_CACHE_VAL(php_cv_cc_vscript,[
- SLIBS=$LIBS
- LIBS="-Wl,--version-script=$srcdir/php.map $LIBS"
- AC_TRY_LINK([],[],php_cv_cc_vscript=yes,php_cv_cc_vscript=no)
- LIBS=$SLIBS ])
-AC_MSG_RESULT($php_cv_cc_vscript)
-
-
-dnl Check compiler support for -rdynamic
-AC_MSG_CHECKING(if compiler supports -rdynamic)
-AC_CACHE_VAL(php_cc_rdynamic,[
- SAVE_LIBS="${LIBS}"
- LIBS="-rdynamic ${LIBS}"
- AC_TRY_LINK([], [], php_cc_rdynamic=yes, php_cc_rdynamic=no)
- LIBS="${SAVE_LIBS}"])
-AC_MSG_RESULT($php_cc_rdynamic)
-if test $php_cc_rdynamic = "yes"; then
- AC_CHECK_CC_OPTION(rdynamic)
-fi
-if test $php_cc_rdynamic = "yes"; then
- LDFLAGS="${LDFLAGS} -rdynamic"
- RDYNAMIC_LFLAGS="-rdynamic"
-else
- RDYNAMIC_LFLAGS=""
-fi
-AC_SUBST(RDYNAMIC_LFLAGS)
-
-dnl AC_PROG_INSTALL
-AC_PATH_PROG(PROG_SENDMAIL, sendmail, /usr/lib/sendmail, $PATH /usr/bin /usr/sbin /usr/etc /etc /usr/ucblib)
-if test -n "$PROG_SENDMAIL"; then
- AC_DEFINE(HAVE_SENDMAIL)
-fi
-
-dnl
-dnl Check for /usr/pkg/{lib,include} which is where NetBSD puts binary
-dnl and source packages. This should be harmless on other OSs.
-dnl
-if test -d /usr/pkg/include -a -d /usr/pkg/lib ; then
- CFLAGS="$CFLAGS -I/usr/pkg/include"
- LDFLAGS="$LDFLAGS -L/usr/pkg/lib"
-fi
-
-INCLUDES="-I\$(top_builddir)/libzend -I\$(top_builddir)/TSRM"
-AC_SUBST(INCLUDES)
-
-AC_CHECK_LIB(nsl, gethostname, [
- LIBS="-lnsl $LIBS"
- AC_DEFINE(HAVE_LIBNSL) ], [])
-
-AC_CHECK_LIB(c, socket, [:], [
- AC_CHECK_LIB(socket, socket, [
- LIBS="-lsocket $LIBS"
- AC_DEFINE(HAVE_LIBSOCKET) ], []) ])
-
-AC_CHECK_LIB(c, gethostbyaddr, [:], [
- AC_CHECK_LIB(nsl, gethostbyaddr, [
- LIBS="-lnsl $LIBS"
- AC_DEFINE(HAVE_LIBNSL) ], []) ])
-
-AC_CHECK_LIB(c, crypt, [:], [
- AC_CHECK_LIB(crypt, crypt, [
- LIBS="-lcrypt $LIBS"
- AC_DEFINE(HAVE_LIBCRYPT) ], []) ])
-
-dnl The sin may be in a library which need not be specifed
-dnl as well as res_search resides in libsocket
-AC_CHECK_LIB(c, sin, [:], [
- AC_CHECK_LIB(m, sin) ])
-
-dnl The res_search may be in libsocket as well, and if it is
-dnl make sure to check for dn_skipname in libresolv, or if res_search
-dnl is in neither of these libs, still check for dn_skipname in libresolv
-AC_CHECK_LIB(socket, res_search, [
- AC_CHECK_LIB(resolv, dn_skipname)
- AC_CHECK_LIB(resolv, __dn_skipname)
- LIBS="$LIBS -lsocket"
- AC_DEFINE(HAVE_LIBSOCKET) ], [
- AC_CHECK_LIB(resolv, res_search, [
- LIBS="$LIBS -lresolv"
- AC_DEFINE(HAVE_LIBRESOLV)
- ], [
- AC_CHECK_LIB(resolv, dn_skipname)
- AC_CHECK_LIB(resolv, __dn_skipname)
- ])
-])
-
-dnl Checks for header files.
-AC_HEADER_STDC
-
-dnl In QNX opendir resides in libc but dirent.h is still required
-if test "`uname -s 2>/dev/null`" != "QNX"; then
- AC_HEADER_DIRENT
-else
- AC_CHECK_HEADERS(dirent.h)
-fi
-AC_MISSING_FCLOSE_DECL
-dnl QNX requires unix.h to allow functions in libunix to work properly
-AC_CHECK_HEADERS(
-arpa/inet.h \
-crypt.h \
-dlfcn.h \
-fcntl.h \
-grp.h \
-limits.h \
-locale.h \
-memory.h \
-netinet/in.h \
-pwd.h \
-signal.h \
-stdarg.h \
-stdlib.h \
-string.h \
-sys/file.h \
-sys/mman.h \
-sys/select.h \
-sys/socket.h \
-sys/statfs.h \
-sys/statvfs.h \
-sys/time.h \
-sys/types.h \
-sys/varargs.h \
-sys/wait.h \
-syslog.h \
-unistd.h \
-unix.h \
-)
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_STRUCT_TM
-AC_STRUCT_TIMEZONE
-
-AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
-[AC_TRY_COMPILE([#include <sys/types.h>
-#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;],
- ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])
-
-if test "$ac_cv_struct_tm_gmtoff" = yes; then
- AC_DEFINE(HAVE_TM_GMTOFF)
-fi
-
-AC_CACHE_CHECK(for struct flock,php_struct_flock,
- AC_TRY_COMPILE([
-#include <unistd.h>
-#include <fcntl.h>
- ],
- [struct flock x;],
- [
- php_struct_flock=yes
- ],[
- php_struct_flock=no
- ])
-)
-if test "$php_struct_flock" = "yes" ; then
- AC_DEFINE(HAVE_STRUCT_FLOCK, 1)
-else
- AC_DEFINE(HAVE_STRUCT_FLOCK, 0)
-fi
-
-AC_CHECK_SIZEOF(long, 8)
-AC_CHECK_SIZEOF(int, 4)
-
-dnl Check for members of the stat structure
-AC_STRUCT_ST_BLKSIZE
-dnl AC_STRUCT_ST_BLOCKS will screw QNX because fileblocks.o does not exists
-dnl The WARNING_LEVEL required because cc in QNX hates -w option without an argument
-if test "`uname -s 2>/dev/null`" != "QNX"; then
- AC_STRUCT_ST_BLOCKS
-else
- AC_MSG_WARN(warnings level for cc set to 0)
- WARNING_LEVEL=0
- AC_SUBST(WARNING_LEVEL)
-fi
-AC_STRUCT_ST_RDEV
-
-dnl Checks for types
-AC_TYPE_SIZE_T
-AC_TYPE_UID_T
-dnl This is required for QNX and may be some BSD derived systems
-AC_CHECK_TYPE( uint, unsigned int )
-AC_CHECK_TYPE( ulong, unsigned long )
-
-dnl Checks for library functions.
-AC_FUNC_VPRINTF
-AC_CHECK_FUNCS(memcpy memmove strdup strerror strcasecmp strstr flock lockf putenv tempnam usleep setlocale gettimeofday setvbuf srand48 lrand48 srandom random link symlink regcomp getlogin cuserid vsnprintf snprintf gcvt utime crypt rint setitimer unsetenv strftime setsockopt tzset shutdown inet_aton statvfs statfs mmap)
-AC_REPLACE_FUNCS(strlcat strlcpy)
-AC_FUNC_UTIME_NULL
-AC_FUNC_ALLOCA
-dnl## OLDLIBS=$LIBS; LIBS=""
-dnl This is also defined/used in libzend. To avoid a redefinition
-dnl we use that version
-dnl AC_BROKEN_SPRINTF
-dnl## LIBS=$OLDLIBS
-AC_REPLACE_FUNCS(getopt)
-
-dnl AIX keeps in_addr_t in /usr/include/netinet/in.h
-dnl AC_MSG_CHECKING(for in_addr_t)
-AC_CACHE_VAL(ac_cv_type_$1,
-[AC_EGREP_CPP(dnl
-changequote(<<,>>)dnl
-<<in_addr_t[^a-zA-Z_0-9]>>dnl
-changequote([,]), [#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif], ac_cv_type_in_addr_t=yes, ac_cv_type_in_addr_t=no)])dnl
-
-dnl AC_MSG_RESULT($ac_cv_type_in_addr_t)
-if test $ac_cv_type_in_addr_t = no; then
- AC_DEFINE(in_addr_t, u_int)
-fi
-
-divert(2)
-
-abs_srcdir=`(cd $srcdir; pwd)`
-abs_builddir=`pwd`
-AC_SUBST(abs_srcdir)
-AC_SUBST(abs_builddir)
-
-AC_MSG_CHECKING(for Apache module support via DSO through APXS)
-AC_ARG_WITH(apxs,
-[ --with-apxs[=FILE] Build shared Apache module. FILE is the optional
- pathname to the Apache apxs tool; defaults to "apxs".
- (This option needs Perl installed)],
-[
- if test "$withval" = "yes"; then
- withval=apxs
- fi
- AC_EXPAND_PATH($withval, APXS)
- APXS_LDFLAGS="@SYBASE_LFLAGS@ @SYBASE_LIBS@ @SYBASE_CT_LFLAGS@ @SYBASE_CT_LIBS@"
- APXS_INCLUDEDIR=`$APXS -q INCLUDEDIR`
- if test -d "$APXS_INCLUDEDIR/xml" ; then
- XML_INCLUDE="$APXS_INCLUDEDIR/xml"
- fi
- APACHE_INCLUDE="-I$APXS_INCLUDEDIR"
- BINNAME=libphp4.so
- INSTALL_IT="\$(APXS) -i -a -n php4 $BINNAME"
- CFLAGS_SHLIB=`perl -V:cccdlflags | cut -d\' -f2`
- LDFLAGS_SHLIB=`perl -V:lddlflags | cut -d\' -f2`
- LDFLAGS_SHLIB_EXPORT=`perl -V:ccdlflags | cut -d\' -f2`
- PHP_LIBS=
- STRONGHOLD=
- INCLUDES="$INCLUDES $APACHE_INCLUDE"
- AC_DEFINE(APACHE)
- AC_SUBST(APXS)
- AC_SUBST(APXS_LDFLAGS)
- AC_SUBST(BINNAME)
- AC_SUBST(INSTALL_IT)
- AC_SUBST(PHP_LIBS)
- AC_SUBST(APACHE_INCLUDE)
- AC_DEFINE(HAVE_AP_CONFIG_H)
- AC_DEFINE(HAVE_AP_COMPAT_H)
- AC_MSG_RESULT(yes)
-],[
- AC_MSG_RESULT(no)
-])
-
-versioning="no"
-AC_MSG_CHECKING(whether to enable versioning)
-AC_ARG_ENABLE(versioning,
-[ --enable-versioning Take advantage of versioning and scoping.
- See INSTALL for more information],
-[
- if test "$enableval" = "yes" ; then
- case "`uname -sr`" in
- "SunOS 5"*)
- VERSION_SCRIPT="-Wl,'-M $abs_srcdir/php.map'"
- ;;
- *)
- if test "$php_cv_cc_vscript" = "yes" ; then
- VERSION_SCRIPT="-Wl,--version-script=$abs_srcdir/php.map"
- else
- AC_MSG_ERROR(versioning is not supported on your OS)
- fi
- ;;
- esac
- versioning="yes"
- fi
-])
-AC_MSG_RESULT($versioning)
-AC_SUBST(VERSION_SCRIPT)
-
-
-APACHE_INSTALL_FILES="$srcdir/mod_php4.* libphp4.module"
-
-if test "$BINNAME" != "libmodphp4-so.a"; then
-if test "$BINNAME" != "libphp4.so"; then
-AC_MSG_CHECKING(for Apache module support)
-AC_ARG_WITH(apache,
-[ --with-apache[=DIR] Build Apache module. DIR is the top-level Apache
- build directory, defaults to /usr/local/etc/httpd.],
-[
- if test "$withval" = "yes"; then
- # Apache's default directory
- withval=/usr/local/etc/httpd
- fi
- if test "$withval" != "no"; then
-# For Apache 1.2.x
- AC_EXPAND_PATH($withval, withval)
- if test -f $withval/src/httpd.h; then
- APACHE_INCLUDE=-I$withval/src
- APACHE_TARGET=$withval/src
- BINNAME=libphp4.a
- INSTALL_IT="mkdir -p $APACHE_TARGET; cp $BINNAME $APACHE_INSTALL_FILES $APACHE_TARGET"
- PHP_LIBS="-L. -lphp3"
- AC_DEFINE(APACHE)
- AC_MSG_RESULT(yes - Apache 1.2.x)
- STRONGHOLD=
- if test -f $withval/src/ap_config.h; then
- AC_DEFINE(HAVE_AP_CONFIG_H)
- fi
-# For Apache 1.3.x
- elif test -f $withval/src/main/httpd.h; then
- APACHE_INCLUDE="-I$withval/src/main -I$withval/src/os/unix -I$withval/src/ap"
- APACHE_TARGET=$withval/src/modules/php4
- if test ! -d $APACHE_TARGET; then
- mkdir $APACHE_TARGET
- fi
- BINNAME=libmodphp4.a
- INSTALL_IT="mkdir -p $APACHE_TARGET; cp $BINNAME $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
- PHP_LIBS="-Lmodules/php4 -L../modules/php4 -L../../modules/php4 -lmodphp4"
- AC_DEFINE(APACHE)
- AC_MSG_RESULT(yes - Apache 1.3.x)
- STRONGHOLD=
- if test -f $withval/src/include/ap_config.h; then
- AC_DEFINE(HAVE_AP_CONFIG_H)
- fi
- if test -f $withval/src/include/ap_compat.h; then
- AC_DEFINE(HAVE_AP_COMPAT_H)
- if test ! -f $withval/src/include/ap_config_auto.h; then
- AC_MSG_ERROR(Please run Apache's configure or src/Configure program once and try again)
- fi
- else
- if test -f $withval/src/include/compat.h; then
- AC_DEFINE(HAVE_OLD_COMPAT_H)
- fi
- fi
-# Also for Apache 1.3.x
- elif test -f $withval/src/include/httpd.h; then
- APACHE_INCLUDE="-I$withval/src/include -I$withval/src/os/unix"
- APACHE_TARGET=$withval/src/modules/php4
- if test -d $withval/src/lib/expat-lite ; then
- XML_INCLUDE=$withval/src/lib/expat-lite
- fi
- if test ! -d $APACHE_TARGET; then
- mkdir $APACHE_TARGET
- fi
- BINNAME=libmodphp4.a
- PHP_LIBS="-Lmodules/php4 -L../modules/php4 -L../../modules/php4 -lmodphp4"
- INSTALL_IT="mkdir -p $APACHE_TARGET; cp $BINNAME $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
- AC_DEFINE(APACHE)
- AC_MSG_RESULT(yes - Apache 1.3.x)
- STRONGHOLD=
- if test -f $withval/src/include/ap_config.h; then
- AC_DEFINE(HAVE_AP_CONFIG_H)
- fi
- if test -f $withval/src/include/ap_compat.h; then
- AC_DEFINE(HAVE_AP_COMPAT_H)
- if test ! -f $withval/src/include/ap_config_auto.h; then
- AC_MSG_ERROR(Please run Apache's configure or src/Configure program once and try again)
- fi
- else
- if test -f $withval/src/include/compat.h; then
- AC_DEFINE(HAVE_OLD_COMPAT_H)
- fi
- fi
-# For StrongHold 2.2
- elif test -f $withval/apache/httpd.h; then
- APACHE_INCLUDE=-"I$withval/apache -I$withval/ssl/include"
- APACHE_TARGET=$withval/apache
- BINNAME=libmodphp4.a
- PHP_LIBS="-Lmodules/php4 -L../modules/php4 -L../../modules/php4 -lmodphp4"
- INSTALL_IT="mkdir -p $APACHE_TARGET; cp $BINNAME $APACHE_INSTALL_FILES $APACHE_TARGET"
- STRONGHOLD=-DSTRONGHOLD=1
- AC_DEFINE(APACHE)
- AC_MSG_RESULT(yes - StrongHold)
- if test -f $withval/apache/ap_config.h; then
- AC_DEFINE(HAVE_AP_CONFIG_H)
- fi
- if test -f $withval/src/ap_compat.h; then
- AC_DEFINE(HAVE_AP_COMPAT_H)
- if test ! -f $withval/src/include/ap_config_auto.h; then
- AC_MSG_ERROR(Please run Apache's configure or src/Configure program once and try again)
- fi
- else
- if test -f $withval/src/compat.h; then
- AC_DEFINE(HAVE_OLD_COMPAT_H)
- fi
- fi
- else
- AC_MSG_RESULT(no)
- AC_MSG_ERROR(Invalid Apache directory - unable to find httpd.h under $withval)
- fi
- else
- AC_MSG_RESULT(no)
- BINNAME=php
- INSTALL_IT="cp $BINNAME \$(bindir)"
- fi
-],[
- AC_MSG_RESULT(no)
- BINNAME=php
- INSTALL_IT="cp $BINNAME \$(bindir)"
-])
-INCLUDES="$INCLUDES $APACHE_INCLUDE"
-dnl## AC_SUBST(APACHE_INCLUDE)
-AC_SUBST(APACHE_TARGET)
-AC_SUBST(INSTALL_IT)
-AC_SUBST(BINNAME)
-AC_SUBST(STRONGHOLD)
-AC_SUBST(PHP_LIBS)
-fi
-fi
-
-AC_MSG_CHECKING(whether to use bundled regex library)
-AC_ARG_WITH(system-regex,
-[ --with-system-regex Do not use the bundled regex library],
-[
- if test -n "$APXS"; then
- if test -n "`$APXS -q CFLAGS | grep USE_HSREGEX`"; then
- HSREGEX=yes
- else
- HSREGEX=no
- fi
- else
- if test "$withval" = "no"; then
- HSREGEX=yes
- else
- HSREGEX=no
- fi
- fi
-],[
- if test -n "$APXS"; then
- if test -n "`$APXS -q CFLAGS | grep USE_HSREGEX`"; then
- HSREGEX=yes
- else
- HSREGEX=no
- fi
- else
- HSREGEX=yes
- fi
-])
-AC_MSG_RESULT($HSREGEX)
-
-if test "$HSREGEX" = "yes"; then
- REGEX_LIB=regex/libregex.a
- EXTRA_LIBS="-L$abs_builddir/regex -lregex $EXTRA_LIBS"
- AC_DEFINE(HSREGEX)
- AC_DEFINE(REGEX,1)
-else
- REGEX_LIB=
- AC_DEFINE(REGEX,0)
-fi
-
-AC_SUBST(REGEX_LIB)
-AC_SUBST(HSREGEX)
-
-AC_MSG_CHECKING(for mod_charset compatibility option)
-AC_ARG_WITH(mod_charset,
-[ --with-mod_charset Enable transfer tables for mod_charset (Rus Apache).],
-[
- AC_MSG_RESULT(yes)
- AC_DEFINE(USE_TRANSFER_TABLES)
-],[
- AC_MSG_RESULT(no)
-])
-
-AC_MSG_CHECKING(for fhttpd module support)
-AC_ARG_WITH(fhttpd,
-[ --with-fhttpd[=DIR] Build fhttpd module. DIR is the fhttpd sources
- directory, defaults to /usr/local/src/fhttpd.],
-[
- if test "$withval" = "yes"; then
- # fhttpd source directory
- withval=/usr/local/src/fhttpd
- fi
- if test "$withval" != "no"; then
-# For fhttpd 0.3.x
- if test -f $withval/servproc.h; then
- FHTTPD_INCLUDE=-I$withval/
- FHTTPD_LIB=$withval/servproc.o
- FHTTPD_TARGET=$withval/
- BINNAME=php
- AC_DEFINE(FHTTPD)
- AC_MSG_RESULT(yes - fhttpd 0.3.x)
- else
- AC_MSG_RESULT(no)
- AC_MSG_ERROR(Invalid fhttpd directory - unable to find servproc.h under $withval)
- fi
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-INCLUDES="$INCLUDES $FHTTPD_INCLUDE"
-dnl## AC_SUBST(FHTTPD_INCLUDE)
-AC_SUBST(FHTTPD_LIB)
-AC_SUBST(FHTTPD_TARGET)
-
-
-AC_MSG_CHECKING(whether to use a configuration file)
-AC_ARG_WITH(config-file-path,
-[ --with-config-file-path=PATH
- Sets the path in which to look for php.ini.
- defaults to /usr/local/lib],
-[
- if test "$withval" = "yes"; then
- AC_DEFINE_UNQUOTED(CONFIGURATION_FILE_PATH, "/usr/local/lib")
- AC_DEFINE(USE_CONFIG_FILE, 1)
- AC_MSG_RESULT(yes)
- else
- if test "$withval" != "no"; then
- AC_DEFINE_UNQUOTED(CONFIGURATION_FILE_PATH, "$withval")
- AC_DEFINE(USE_CONFIG_FILE, 1)
- AC_MSG_RESULT(yes)
- else
- AC_DEFINE(CONFIGURATION_FILE_PATH, 0)
- AC_DEFINE(USE_CONFIG_FILE, 0)
- AC_MSG_RESULT(no)
- fi
- fi
-],[
- AC_DEFINE_UNQUOTED(CONFIGURATION_FILE_PATH, "/usr/local/lib")
- AC_DEFINE(USE_CONFIG_FILE, 1)
- AC_MSG_RESULT(yes)
-])
-
-
-AC_MSG_CHECKING(whether to include debugging symbols)
-AC_ARG_ENABLE(debug,
-[ --disable-debug Compile without debugging symbols],
-[
- if test "$enableval" = "yes"; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(DEBUG,1)
- PHP_DEBUG=1
- DEBUG_CFLAGS="-g"
- test -n "$GCC" && DEBUG_CFLAGS="$DEBUG_CFLAGS -Wall"
- test -n "$GCC" && test "$USE_MAINTAINER_MODE" = "yes" && \
- DEBUG_CFLAGS="$DEBUG_CFLAGS -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations"
- else
- AC_MSG_RESULT(no)
- AC_DEFINE(DEBUG,0)
- PHP_DEBUG=0
- DEBUG_CFLAGS=""
- fi
-],[
- AC_MSG_RESULT(yes)
- AC_DEFINE(DEBUG,1)
- PHP_DEBUG=1
- DEBUG_CFLAGS="-g"
-])
-AC_SUBST(DEBUG_CFLAGS)
-AC_SUBST(PHP_DEBUG)
-CFLAGS="$CFLAGS $DEBUG_CFLAGS"
-
-
-AC_MSG_CHECKING(whether to enable safe mode by default)
-AC_ARG_ENABLE(safe-mode,
-[ --enable-safe-mode Enable safe mode by default.],
-[
- if test "$enableval" = "yes"; then
- AC_DEFINE(PHP_SAFE_MODE, 1)
- AC_MSG_RESULT(yes)
- else
- AC_DEFINE(PHP_SAFE_MODE, 0)
- AC_MSG_RESULT(no)
- fi
-],[
- AC_DEFINE(PHP_SAFE_MODE, 0)
- AC_MSG_RESULT(no)
-])
-
-
-AC_MSG_CHECKING(for safe mode exec dir)
-AC_ARG_WITH(exec-dir,
-[ --with-exec-dir[=DIR] Only allow executables in DIR when in safe mode
- defaults to /usr/local/php/bin],
-[
- if test "$withval" != "no"; then
- if test "$withval" = "yes"; then
- AC_DEFINE(PHP_SAFE_MODE_EXEC_DIR,"/usr/local/php/bin")
- AC_MSG_RESULT(/usr/local/php/bin)
- else
- AC_DEFINE_UNQUOTED(PHP_SAFE_MODE_EXEC_DIR,"$withval")
- AC_MSG_RESULT($withval)
- fi
- else
- AC_DEFINE(PHP_SAFE_MODE_EXEC_DIR,"/usr/local/php/bin")
- AC_MSG_RESULT(/usr/local/php/bin)
- fi
-],[
- AC_DEFINE(PHP_SAFE_MODE_EXEC_DIR,"/usr/local/php/bin")
- AC_MSG_RESULT(/usr/local/php/bin)
-])
-
-
-AC_MSG_CHECKING(whether to enable track_vars variables by default)
-AC_ARG_ENABLE(track-vars,
-[ --enable-track-vars Enable GET/POST/Cookie track variables by default.],
-[
- if test "$enableval" = "yes"; then
- AC_DEFINE(PHP_TRACK_VARS, 1)
- AC_MSG_RESULT(yes)
- else
- AC_DEFINE(PHP_TRACK_VARS, 0)
- AC_MSG_RESULT(no)
- fi
-],[
- AC_DEFINE(PHP_TRACK_VARS, 0)
- AC_MSG_RESULT(no)
-])
-
-
-AC_MSG_CHECKING(whether to enable magic quotes by default)
-AC_ARG_ENABLE(magic-quotes,
-[ --enable-magic-quotes Enable magic quotes by default.],
-[
- if test "$enableval" = "yes"; then
- AC_DEFINE(MAGIC_QUOTES, 1)
- AC_MSG_RESULT(yes)
- else
- AC_DEFINE(MAGIC_QUOTES, 0)
- AC_MSG_RESULT(no)
- fi
-],[
- AC_DEFINE(MAGIC_QUOTES, 0)
- AC_MSG_RESULT(no)
-])
-
-
-AC_MSG_CHECKING(whether to build PHP thread-safe)
-AC_ARG_ENABLE(thread-safety,
-[ --enable-thread-safety Whether to build PHP thread-safe.],[
- TSRM_LIB='TSRM/libtsrm.a'
- TSRM_DIR=TSRM
- AC_DEFINE(ZTS)
-],[
- TSRM_DIR=""
-])
-AC_SUBST(TSRM_DIR)
-AC_SUBST(TSRM_LIB)
-
-dnl AC_MSG_CHECKING(whether to enable PHP RPC support)
-dnl AC_ARG_ENABLE(php-rpc,
-dnl [ --enable-php-rpc Compile with PHP RPC support.],
-dnl [
-dnl if test "$enableval" = "yes"; then
-dnl AC_DEFINE(PHP_RPC, 1)
-dnl AC_MSG_RESULT(yes)
-dnl else
-dnl AC_DEFINE(PHP_RPC, 0)
-dnl AC_MSG_RESULT(no)
-dnl fi
-dnl ],[
-dnl AC_DEFINE(PHP_RPC, 0)
-dnl AC_MSG_RESULT(no)
-dnl ])
-
-if test "$BINNAME" = "php"; then
-AC_MSG_CHECKING(whether to force Apache CGI redirect)
-AC_ARG_ENABLE(force-cgi-redirect,
-[ --enable-force-cgi-redirect
- Enable the security check for internal server
- redirects. You should use this if you are
- running the CGI version with Apache. ],
-[
- if test "$enableval" = "yes"; then
- AC_DEFINE(FORCE_CGI_REDIRECT, 1)
- AC_MSG_RESULT(yes)
- REDIRECT=1
- else
- AC_DEFINE(FORCE_CGI_REDIRECT, 0)
- AC_MSG_RESULT(no)
- REDIRECT=0
- fi
-],[
- AC_DEFINE(FORCE_CGI_REDIRECT, 0)
- AC_MSG_RESULT(no)
- REDIRECT=0
-])
-
-AC_MSG_CHECKING(whether to discard path_info + path_translated)
-AC_ARG_ENABLE(discard_path,
-[ --enable-discard-path If this is enabled, the PHP CGI binary
- can safely be placed outside of the
- web tree and people will not be able
- to circumvent .htaccess security. ],
-[
- if test "$enableval" = "yes"; then
- AC_DEFINE(DISCARD_PATH, 1)
- AC_MSG_RESULT(yes)
- DISCARD_PATH=1
- else
- AC_DEFINE(DISCARD_PATH, 0)
- AC_MSG_RESULT(no)
- DISCARD_PATH=0
- fi
-],[
- AC_DEFINE(DISCARD_PATH, 0)
- AC_MSG_RESULT(no)
- DISCARD_PATH=0
-])
-fi
-
-AC_MSG_CHECKING(whether to enable short tags by default)
-AC_ARG_ENABLE(short-tags,
-[ --disable-short-tags Disable the short-form <? start tag by default.],
-[
- if test "$enableval" = "no"; then
- AC_DEFINE(DEFAULT_SHORT_OPEN_TAG, 0)
- AC_MSG_RESULT(no)
- else
- AC_DEFINE(DEFAULT_SHORT_OPEN_TAG, 1)
- AC_MSG_RESULT(yes)
- fi
-],[
- AC_DEFINE(DEFAULT_SHORT_OPEN_TAG, 1)
- AC_MSG_RESULT(yes)
-])
-
-AC_MSG_CHECKING(whether to enable the URL-aware fopen wrapper)
-AC_ARG_ENABLE(url-fopen-wrapper,
-[ --disable-url-fopen-wrapper
- Disable the URL-aware fopen wrapper that allows
- accessing files via http or ftp.],
-[
- if test "$enableval" = "yes"; then
- AC_DEFINE(PHP3_URL_FOPEN, 1)
- AC_MSG_RESULT(yes)
- else
- AC_DEFINE(PHP3_URL_FOPEN, 0)
- AC_MSG_RESULT(no)
- fi
-],[
- AC_DEFINE(PHP3_URL_FOPEN, 1)
- AC_MSG_RESULT(yes)
-])
-
-DMALLOC_RESULT=no
-AC_MSG_CHECKING(whether to enable dmalloc)
-AC_ARG_ENABLE(dmalloc,
-[ --enable-dmalloc Enable dmalloc],
-[
- if test "$enableval" = "yes" ; then
- AC_DEFINE(HAVE_DMALLOC, 1)
- AC_ADD_LIBRARY(dmalloc)
- CFLAGS="$CFLAGS -DDMALLOC_FUNC_CHECK"
- DMALLOC_RESULT=yes
- fi
-])
-AC_MSG_RESULT($DMALLOC_RESULT)
-
-divert(3)
-
-AC_SUBST(EXTRA_LIBS)
-
-# reading config stubs
-esyscmd(./scripts/config-stubs)
-
-
-divert(4)
-
-dnl If we're using gcc and the user hasn't specified CFLAGS, add -O2.
-test -n "$auto_cflags" && test -n "$GCC" && CFLAGS="$CFLAGS -O2"
-
-dnl *** Commented out - generates slow code and consumes a lot of
-dnl *** resources during compilation - we need to figure out how
-dnl *** to supply it only when absolutely necessary
-dnl If we are using gcc add -fpic to make dl() work on some platforms
-dnl test -n "$GCC" && CFLAGS="$CFLAGS -fpic"
-
-dnl add -fPIC option on Solaris if we are building dynamic extensions
-PHP_SOLARIS_PIC_WEIRDNESS
-
-AC_SUBST(CFLAGS)
-AC_SUBST(PROG_SENDMAIL)
-AC_SUBST(CFLAGS_SHLIB)
-AC_SUBST(LDFLAGS_SHLIB)
-AC_SUBST(LDFLAGS_SHLIB_EXPORT)
-AC_SUBST(RPATHS)
-
-PHP_BUILD_DATE=`date '+%Y-%m-%d'`
-AC_SUBST(PHP_BUILD_DATE)
-AC_DEFINE_UNQUOTED(PHP_BUILD_DATE,"$PHP_BUILD_DATE")
-PHP_UNAME=`uname -a`
-AC_DEFINE_UNQUOTED(PHP_UNAME,"$PHP_UNAME")
-PHP_OS=`uname`
-AC_DEFINE_UNQUOTED(PHP_OS,"$PHP_OS")
-
-AC_OUTPUT(Makefile libphp4.module php4.spec
- scripts/mkextlib regex/Makefile
- @@EXT_MAKEFILES@@ build-defs.h, [
-], [
-
-if test ! -f $srcdir/ext/bcmath/number.c; then
- echo "creating number.c"
- echo "/* Dummy File */" > $srcdir/ext/bcmath/number.c
- echo "creating number.h"
- echo "/* Dummy File */" > $srcdir/ext/bcmath/number.h
-fi
-
-if test "" = ""; then
-
- chmod +x scripts/mkextlib
- # Hacking while airborne considered harmful.
- #
- echo "creating internal_functions.c"
- extensions=\`grep '^s.@EXT_STATIC@' \$0|sed -e 's/^.*@% *//' -e 's/%.*$//'\`
- mv -f internal_functions.c internal_functions.c.old 2>/dev/null
- sh $srcdir/genif.sh $srcdir/internal_functions.c.in $srcdir \$extensions > internal_functions.c
- if cmp internal_functions.c.old internal_functions.c > /dev/null 2>&1; then
- echo "internal_functions.c is unchanged"
- mv internal_functions.c.old internal_functions.c
- else
- rm -f internal_functions.c.old
- fi
-
- # Warn about CGI version with no extra security options.
- if test "$BINNAME" = "php"; then
- if test "$REDIRECT" = "0"; then
- if test "$DISCARD_PATH" = "0"; then
- echo "+--------------------------------------------------------------------+"
- echo "| Warning: |"
- echo "| You will be compiling the CGI version of PHP without any |"
- echo "| redirection checking. By putting this cgi binary somewhere in |"
- echo "| your web space, users may be able to circumvent existing .htaccess |"
- echo "| security by loading files directly through the parser. See |"
- echo "| http://www.php.net/manual/config-security.php3 for more details. |"
- fi
- fi
- fi
-
- echo "+--------------------------------------------------------------------+"
- echo "| License: |"
- echo "| This software is subject to the PHP License, available in this |"
- echo "| distribution in the file LICENSE. By continuing this installation |"
- echo "| process, you are bound by the terms of this license agreement. |"
- echo "| If you do not agree with the terms of this license, you must abort |"
- echo "| the installation process at this point. |"
- echo "+--------------------------------------------------------------------+"
-
-fi
-
-])
-
-divert
-
-# Local Variables:
-# tab-width: 4
-# End:
diff --git a/crypt.mak b/crypt.mak
deleted file mode 100644
index 9488b28710..0000000000
--- a/crypt.mak
+++ /dev/null
@@ -1,204 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on crypt.dsp
-!IF "$(CFG)" == ""
-CFG=crypt - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to crypt - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "crypt - Win32 Release" && "$(CFG)" != "crypt - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "crypt.mak" CFG="crypt - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "crypt - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "crypt - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-!IF "$(CFG)" == "crypt - Win32 Release"
-
-OUTDIR=.\module_Release
-INTDIR=.\module_Release
-# Begin Custom Macros
-OutDir=.\module_Release
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_crypt.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\crypt.obj"
- -@erase "$(INTDIR)\sflcryp.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(OUTDIR)\php3_crypt.dll"
- -@erase "$(OUTDIR)\php3_crypt.exp"
- -@erase "$(OUTDIR)\php3_crypt.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "./" /I "../" /D HAVE_SFLCRYPT=1 /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\crypt.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\crypt.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\php3_crypt.pdb" /machine:I386 /out:"$(OUTDIR)\php3_crypt.dll" /implib:"$(OUTDIR)\php3_crypt.lib" /libpath:"cgi_release"
-LINK32_OBJS= \
- "$(INTDIR)\crypt.obj" \
- "$(INTDIR)\sflcryp.obj"
-
-"$(OUTDIR)\php3_crypt.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "crypt - Win32 Debug"
-
-OUTDIR=.\module_debug
-INTDIR=.\module_debug
-# Begin Custom Macros
-OutDir=.\module_debug
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_crypt.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\crypt.obj"
- -@erase "$(INTDIR)\sflcryp.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(INTDIR)\vc60.pdb"
- -@erase "$(OUTDIR)\php3_crypt.dll"
- -@erase "$(OUTDIR)\php3_crypt.exp"
- -@erase "$(OUTDIR)\php3_crypt.ilk"
- -@erase "$(OUTDIR)\php3_crypt.lib"
- -@erase "$(OUTDIR)\php3_crypt.pdb"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "./" /I "../" /I "../../" /D HAVE_SFLCRYPT=1 /D "DEBUG" /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\crypt.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\crypt.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:yes /pdb:"$(OUTDIR)\php3_crypt.pdb" /debug /machine:I386 /out:"$(OUTDIR)\php3_crypt.dll" /implib:"$(OUTDIR)\php3_crypt.lib" /pdbtype:sept /libpath:"cgi_debug"
-LINK32_OBJS= \
- "$(INTDIR)\crypt.obj" \
- "$(INTDIR)\sflcryp.obj"
-
-"$(OUTDIR)\php3_crypt.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF
-
-
-!IF "$(NO_EXTERNAL_DEPS)" != "1"
-!IF EXISTS("crypt.dep")
-!INCLUDE "crypt.dep"
-!ELSE
-!MESSAGE Warning: cannot find "crypt.dep"
-!ENDIF
-!ENDIF
-
-
-!IF "$(CFG)" == "crypt - Win32 Release" || "$(CFG)" == "crypt - Win32 Debug"
-SOURCE=.\dl\crypt\crypt.c
-
-"$(INTDIR)\crypt.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\dl\crypt\sflcryp.c
-
-"$(INTDIR)\sflcryp.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-
-!ENDIF
-
diff --git a/dbase.mak b/dbase.mak
deleted file mode 100644
index d1dfd306c9..0000000000
--- a/dbase.mak
+++ /dev/null
@@ -1,234 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on dbase.dsp
-!IF "$(CFG)" == ""
-CFG=dbase - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to dbase - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "dbase - Win32 Release" && "$(CFG)" != "dbase - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "dbase.mak" CFG="dbase - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "dbase - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "dbase - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-!IF "$(CFG)" == "dbase - Win32 Release"
-
-OUTDIR=.\module_release
-INTDIR=.\module_release
-# Begin Custom Macros
-OutDir=.\module_release
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_dbase.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\dbase.obj"
- -@erase "$(INTDIR)\dbf_head.obj"
- -@erase "$(INTDIR)\dbf_misc.obj"
- -@erase "$(INTDIR)\dbf_ndx.obj"
- -@erase "$(INTDIR)\dbf_rec.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(OUTDIR)\php3_dbase.dll"
- -@erase "$(OUTDIR)\php3_dbase.exp"
- -@erase "$(OUTDIR)\php3_dbase.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "dbase\\" /I "./" /I "../" /D DBASE=1 /D "NDEBUG" /D "THREAD_SAFE" /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\dbase.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\dbase.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:3 /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\php3_dbase.pdb" /machine:I386 /out:"$(OUTDIR)\php3_dbase.dll" /implib:"$(OUTDIR)\php3_dbase.lib" /libpath:"cgi_release"
-LINK32_OBJS= \
- "$(INTDIR)\dbase.obj" \
- "$(INTDIR)\dbf_head.obj" \
- "$(INTDIR)\dbf_misc.obj" \
- "$(INTDIR)\dbf_ndx.obj" \
- "$(INTDIR)\dbf_rec.obj"
-
-"$(OUTDIR)\php3_dbase.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "dbase - Win32 Debug"
-
-OUTDIR=.\module_debug
-INTDIR=.\module_debug
-# Begin Custom Macros
-OutDir=.\module_debug
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_dbase.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\dbase.obj"
- -@erase "$(INTDIR)\dbf_head.obj"
- -@erase "$(INTDIR)\dbf_misc.obj"
- -@erase "$(INTDIR)\dbf_ndx.obj"
- -@erase "$(INTDIR)\dbf_rec.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(INTDIR)\vc60.pdb"
- -@erase "$(OUTDIR)\php3_dbase.dll"
- -@erase "$(OUTDIR)\php3_dbase.exp"
- -@erase "$(OUTDIR)\php3_dbase.ilk"
- -@erase "$(OUTDIR)\php3_dbase.lib"
- -@erase "$(OUTDIR)\php3_dbase.pdb"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "dbase\\" /I "./" /I "../" /D DBASE=1 /D "DEBUG" /D "_DEBUG" /D "THREAD_SAFE" /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\dbase.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\dbase.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:3 /subsystem:windows /dll /incremental:yes /pdb:"$(OUTDIR)\php3_dbase.pdb" /debug /machine:I386 /out:"$(OUTDIR)\php3_dbase.dll" /implib:"$(OUTDIR)\php3_dbase.lib" /pdbtype:sept /libpath:"cgi_debug"
-LINK32_OBJS= \
- "$(INTDIR)\dbase.obj" \
- "$(INTDIR)\dbf_head.obj" \
- "$(INTDIR)\dbf_misc.obj" \
- "$(INTDIR)\dbf_ndx.obj" \
- "$(INTDIR)\dbf_rec.obj"
-
-"$(OUTDIR)\php3_dbase.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF
-
-
-!IF "$(NO_EXTERNAL_DEPS)" != "1"
-!IF EXISTS("dbase.dep")
-!INCLUDE "dbase.dep"
-!ELSE
-!MESSAGE Warning: cannot find "dbase.dep"
-!ENDIF
-!ENDIF
-
-
-!IF "$(CFG)" == "dbase - Win32 Release" || "$(CFG)" == "dbase - Win32 Debug"
-SOURCE=.\functions\dbase.c
-
-"$(INTDIR)\dbase.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\dbase\dbf_head.c
-
-"$(INTDIR)\dbf_head.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\dbase\dbf_misc.c
-
-"$(INTDIR)\dbf_misc.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\dbase\dbf_ndx.c
-
-"$(INTDIR)\dbf_ndx.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\dbase\dbf_rec.c
-
-"$(INTDIR)\dbf_rec.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-
-!ENDIF
-
diff --git a/dbm.mak b/dbm.mak
deleted file mode 100644
index 3931f58b68..0000000000
--- a/dbm.mak
+++ /dev/null
@@ -1,201 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on dbm.dsp
-!IF "$(CFG)" == ""
-CFG=dbm - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to dbm - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "dbm - Win32 Release" && "$(CFG)" != "dbm - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "dbm.mak" CFG="dbm - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "dbm - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "dbm - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-!IF "$(CFG)" == "dbm - Win32 Release"
-
-OUTDIR=.\module_release
-INTDIR=.\module_release
-# Begin Custom Macros
-OutDir=.\module_release
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_dbm.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\db.obj"
- -@erase "$(INTDIR)\flock.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(OUTDIR)\php3_dbm.dll"
- -@erase "$(OUTDIR)\php3_dbm.exp"
- -@erase "$(OUTDIR)\php3_dbm.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "./" /I "../" /I "../../include" /D NDBM=1 /D GDBM=0 /D BSD2=1 /D "NDEBUG" /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\dbm.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\dbm.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib libdb.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:2 /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\php3_dbm.pdb" /machine:I386 /out:"$(OUTDIR)\php3_dbm.dll" /implib:"$(OUTDIR)\php3_dbm.lib" /libpath:"..\..\lib" /libpath:"cgi_release"
-LINK32_OBJS= \
- "$(INTDIR)\db.obj" \
- "$(INTDIR)\flock.obj"
-
-"$(OUTDIR)\php3_dbm.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "dbm - Win32 Debug"
-
-OUTDIR=.\module_debug
-INTDIR=.\module_debug
-
-ALL : "c:\php3\php3_dbm.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\db.obj"
- -@erase "$(INTDIR)\flock.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(INTDIR)\vc60.pdb"
- -@erase "$(OUTDIR)\php3_dbm.exp"
- -@erase "$(OUTDIR)\php3_dbm.lib"
- -@erase "$(OUTDIR)\php3_dbm.pdb"
- -@erase "c:\php3\php3_dbm.dll"
- -@erase "c:\php3\php3_dbm.ilk"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "./" /I "../" /I "../../include" /D NDBM=1 /D GDBM=0 /D BSD2=1 /D "DEBUG" /D "_DEBUG" /D COMPILE_DL=1 /D "MSVC5" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\dbm.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\dbm.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib libdb.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:2 /subsystem:windows /dll /incremental:yes /pdb:"$(OUTDIR)\php3_dbm.pdb" /debug /machine:I386 /out:"c:\php3/php3_dbm.dll" /implib:"$(OUTDIR)\php3_dbm.lib" /pdbtype:sept /libpath:"..\..\lib" /libpath:"cgi_debug"
-LINK32_OBJS= \
- "$(INTDIR)\db.obj" \
- "$(INTDIR)\flock.obj"
-
-"c:\php3\php3_dbm.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF
-
-
-!IF "$(NO_EXTERNAL_DEPS)" != "1"
-!IF EXISTS("dbm.dep")
-!INCLUDE "dbm.dep"
-!ELSE
-!MESSAGE Warning: cannot find "dbm.dep"
-!ENDIF
-!ENDIF
-
-
-!IF "$(CFG)" == "dbm - Win32 Release" || "$(CFG)" == "dbm - Win32 Debug"
-SOURCE=.\functions\db.c
-
-"$(INTDIR)\db.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\win32\flock.c
-
-"$(INTDIR)\flock.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-
-!ENDIF
-
diff --git a/dlist.c b/dlist.c
deleted file mode 100644
index ea707fc6fb..0000000000
--- a/dlist.c
+++ /dev/null
@@ -1,421 +0,0 @@
-/****************************************************************************
-*
-* Copyright (C) 1991 Kendall Bennett.
-* All rights reserved.
-*
-* Filename: $RCSfile$
-* Version: $Revision$
-*
-* Language: ANSI C
-* Environment: any
-*
-* Description: Module to implement doubly linked lists. Includes a routine
-* to peform a mergesort on the doubly linked list.
-*
-* $Id$
-*
-* Revision History:
-* -----------------
-*
-* $Log$
-* Revision 1.1 1999/07/19 18:58:44 andrey
-* Moving dlist stuff into core.
-*
-* Revision 1.2 1999/05/11 00:01:42 zeev
-* * Get Apache to work. POST doesn't work yet.
-* * There are now -I directives for the absolute path of php4, php4/libzend and the builddir for
-* the Apache module, so we can #include any php/Zend header.
-* * Rename config.h to php_config.h
-*
-* Revision 1.1 1999/04/21 23:11:20 ssb
-* moved apache, com and hyperwave into ext/
-*
-* Revision 1.1.1.1 1999/04/07 21:03:31 zeev
-* PHP 4.0
-*
-* Revision 1.1.1.1 1999/03/17 04:29:11 andi
-* PHP4
-*
-* Revision 1.1.1.1 1998/12/21 07:56:22 andi
-* Trying to start the zend CVS tree
-*
-* Revision 1.1 1998/08/12 09:29:16 steinm
-* First version of Hyperwave module.
-*
-* Revision 1.5 91/12/31 19:39:49 kjb
-* Modified include file directories.
-*
-* Revision 1.4 91/10/28 03:16:39 kjb
-* Ported to the Iris.
-*
-* Revision 1.3 91/09/27 03:09:18 kjb
-* Cosmetic change.
-*
-* Revision 1.2 91/09/03 18:27:42 ROOT_DOS
-* Ported to UNIX.
-*
-* Revision 1.1 91/09/01 18:35:23 ROOT_DOS
-* Initial revision
-*
-****************************************************************************/
-
-#ifndef MSVC5
-#include "php_config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include "dlist.h"
-
-#define PUBLIC
-#define PRIVATE static
-
-PUBLIC void *dlst_newnode(int size)
-/****************************************************************************
-*
-* Function: dlst_newnode
-* Parameters: size - Amount of memory to allocate for node
-* Returns: Pointer to the allocated node's user space.
-*
-* Description: Allocates the memory required for a node, adding a small
-* header at the start of the node. We return a reference to
-* the user space of the node, as if it had been allocated via
-* malloc().
-*
-****************************************************************************/
-{
- PHP_DLST_BUCKET *node;
-
- if ( !(node = (PHP_DLST_BUCKET*)malloc(size + sizeof(PHP_DLST_BUCKET))) ) {
- fprintf(stderr,"Not enough memory to allocate list node.\n");
-/* raise(SIGABRT);*/
- return NULL;
- }
-
- return PHP_DLST_USERSPACE(node); /* Return pointer to user space */
-}
-
-PUBLIC void dlst_freenode(void *node)
-/****************************************************************************
-*
-* Function: dlst_freenode
-* Parameters: node - Node to free.
-*
-* Description: Frees a node previously allocated with lst_newnode().
-*
-****************************************************************************/
-{
- free(PHP_DLST_HEADER(node));
-}
-
-PUBLIC DLIST *dlst_init(void)
-/****************************************************************************
-*
-* Function: dlst_init
-* Returns: Pointer to a newly created list.
-*
-* Description: Initialises a list and returns a pointer to it.
-*
-****************************************************************************/
-{
- DLIST *l;
-
- if ((l = (DLIST*)malloc(sizeof(DLIST))) != NULL) {
- l->count = 0;
- l->head = &(l->hz[0]);
- l->z = &(l->hz[1]);
- l->head->next = l->z->next = l->z;
- l->z->prev = l->head->prev = l->head;
- }
- else {
- fprintf(stderr,"Insufficient memory to allocate list\n");
- /*raise(SIGABRT);*/
- return NULL;
- }
-
- return l;
-}
-
-PUBLIC void dlst_kill(DLIST *l,void (*freeNode)(void *node))
-/****************************************************************************
-*
-* Function: dlst_kill
-* Parameters: l - List to kill
-* freeNode - Pointer to user routine to free a node
-*
-* Description: Kills the list l, by deleting all of the elements contained
-* within the list one by one and then deleting the list
-* itself. Note that we call the user supplied routine
-* (*freeNode)() to free each list node. This allows the user
-* program to perform any extra processing needed to kill each
-* node (if each node contains pointers to other items on the
-* heap for example). If no extra processing is required, just
-* pass the address of dlst_freenode(), ie:
-*
-* dlst_kill(myList,dlst_freenode);
-*
-****************************************************************************/
-{
- PHP_DLST_BUCKET *n,*p;
-
- n = l->head->next;
- while (n != l->z) { /* Free all nodes in list */
- p = n;
- n = n->next;
- (*freeNode)(PHP_DLST_USERSPACE(p));
- }
- free(l); /* Free the list itself */
-}
-
-PUBLIC void dlst_insertafter(DLIST *l,void *node,void *after)
-/****************************************************************************
-*
-* Function: lst_insertafter
-* Parameters: l - List to insert node into
-* node - Pointer to user space of node to insert
-* after - Pointer to user space of node to insert node after
-*
-* Description: Inserts a new node into the list after the node 'after'. To
-* insert a new node at the beginning of the list, user the
-* macro PHP_DLST_HEAD in place of 'after'. ie:
-*
-* dlst_insertafter(mylist,node,PHP_DLST_HEAD(mylist));
-*
-****************************************************************************/
-{
- PHP_DLST_BUCKET *n = PHP_DLST_HEADER(node),*a = PHP_DLST_HEADER(after);
-
- n->next = a->next;
- a->next = n;
- n->prev = a;
- n->next->prev = n;
- l->count++;
-}
-
-PUBLIC void *dlst_deletenext(DLIST *l,void *node)
-/****************************************************************************
-*
-* Function: lst_deletenext
-* Parameters: l - List to delete node from.
-* node - Node to delete the next node from
-* Returns: Pointer to the deleted node's userspace.
-*
-* Description: Removes the node AFTER 'node' from the list l.
-*
-****************************************************************************/
-{
- PHP_DLST_BUCKET *n = PHP_DLST_HEADER(node);
-
- node = PHP_DLST_USERSPACE(n->next);
- n->next->next->prev = n;
- n->next = n->next->next;
- l->count--;
- return node;
-}
-
-PUBLIC void *dlst_first(DLIST *l)
-/****************************************************************************
-*
-* Function: dlst_first
-* Parameters: l - List to obtain first node from
-* Returns: Pointer to first node in list, NULL if list is empty.
-*
-* Description: Returns a pointer to the user space of the first node in
-* the list. If the list is empty, we return NULL.
-*
-****************************************************************************/
-{
- PHP_DLST_BUCKET *n;
-
- n = l->head->next;
- return (n == l->z ? NULL : PHP_DLST_USERSPACE(n));
-}
-
-PUBLIC void *dlst_last(DLIST *l)
-/****************************************************************************
-*
-* Function: dlst_last
-* Parameters: l - List to obtain last node from
-* Returns: Pointer to last node in list, NULL if list is empty.
-*
-* Description: Returns a pointer to the user space of the last node in
-* the list. If the list is empty, we return NULL.
-*
-****************************************************************************/
-{
- PHP_DLST_BUCKET *n;
-
- n = l->z->prev;
- return (n == l->head ? NULL : PHP_DLST_USERSPACE(n));
-}
-
-PUBLIC void *dlst_next(void *prev)
-/****************************************************************************
-*
-* Function: dlst_next
-* Parameters: prev - Previous node in list to obtain next node from
-* Returns: Pointer to the next node in the list, NULL at end of list.
-*
-* Description: Returns a pointer to the user space of the next node in the
-* list given a pointer to the user space of the previous node.
-* If we have reached the end of the list, we return NULL. The
-* end of the list is detected when the next pointer of a node
-* points back to itself, as does the dummy last node's next
-* pointer. This enables us to detect the end of the list
-* without needed access to the list data structure itself.
-*
-* NOTE: We do no checking to ensure that 'prev' is NOT a
-* NULL pointer.
-*
-****************************************************************************/
-{
- PHP_DLST_BUCKET *n = PHP_DLST_HEADER(prev);
-
- n = n->next;
- return (n == n->next ? NULL : PHP_DLST_USERSPACE(n));
-}
-
-PUBLIC void *dlst_prev(void *next)
-/****************************************************************************
-*
-* Function: dlst_prev
-* Parameters: next - Next node in list to obtain previous node from
-* Returns: Pointer to the previous node in the list, NULL at start list.
-*
-* Description: Returns a pointer to the user space of the prev node in the
-* list given a pointer to the user space of the next node.
-* If we have reached the start of the list, we return NULL. The
-* start of the list is detected when the prev pointer of a node
-* points back to itself, as does the dummy head node's prev
-* pointer. This enables us to detect the start of the list
-* without needed access to the list data structure itself.
-*
-* NOTE: We do no checking to ensure that 'next' is NOT a
-* NULL pointer.
-*
-****************************************************************************/
-{
- PHP_DLST_BUCKET *n = PHP_DLST_HEADER(next);
-
- n = n->prev;
- return (n == n->prev ? NULL : PHP_DLST_USERSPACE(n));
-}
-
-/* Static globals required by merge() */
-
-static PHP_DLST_BUCKET *z;
-static int (*cmp)(void*,void*);
-
-PRIVATE PHP_DLST_BUCKET *merge(PHP_DLST_BUCKET *a,PHP_DLST_BUCKET *b,PHP_DLST_BUCKET **end)
-/****************************************************************************
-*
-* Function: merge
-* Parameters: a,b - Sublist's to merge
-* Returns: Pointer to the merged sublists.
-*
-* Description: Merges two sorted lists of nodes together into a single
-* sorted list.
-*
-****************************************************************************/
-{
- PHP_DLST_BUCKET *c;
-
- /* Go through the lists, merging them together in sorted order */
-
- c = z;
- while (a != z && b != z) {
- if ((*cmp)(PHP_DLST_USERSPACE(a),PHP_DLST_USERSPACE(b)) <= 0) {
- c->next = a; c = a; a = a->next;
- }
- else {
- c->next = b; c = b; b = b->next;
- }
- };
-
- /* If one of the lists is not exhausted, then re-attach it to the end
- * of the newly merged list
- */
-
- if (a != z) c->next = a;
- if (b != z) c->next = b;
-
- /* Set *end to point to the end of the newly merged list */
-
- while (c->next != z) c = c->next;
- *end = c;
-
- /* Determine the start of the merged lists, and reset z to point to
- * itself
- */
-
- c = z->next; z->next = z;
- return c;
-}
-
-PUBLIC void dlst_mergesort(DLIST *l,int (*cmp_func)(void*,void*))
-/****************************************************************************
-*
-* Function: dlst_mergesort
-* Parameters: l - List to merge sort
-* cmp_func - Function to compare two user spaces
-*
-* Description: Mergesort's all the nodes in the list. 'cmp' must point to
-* a comparison function that can compare the user spaces of
-* two different nodes. 'cmp' should work the same as
-* strcmp(), in terms of the values it returns. Rather than
-* waste processing time keeping the previous pointers up to
-* date while performing the mergesort, we simply run through
-* the list at the end of the sort to fix the previous pointers.
-*
-****************************************************************************/
-{
- int i,N;
- PHP_DLST_BUCKET *a,*b; /* Pointers to sublists to merge */
- PHP_DLST_BUCKET *c; /* Pointer to end of sorted sublists */
- PHP_DLST_BUCKET *head; /* Pointer to dummy head node for list */
- PHP_DLST_BUCKET *todo; /* Pointer to sublists yet to be sorted */
- PHP_DLST_BUCKET *t; /* Temporary */
-
- /* Set up globals required by merge() and pointer to head */
-
- z = l->z; cmp = cmp_func; head = l->head;
-
- for (N = 1,a = z; a != head->next; N = N + N) {
- todo = head->next; c = head;
- while (todo != z) {
-
- /* Build first sublist to be merged, and splice from main list
- */
-
- a = t = todo;
- for (i = 1; i < N; i++) t = t->next;
- b = t->next; t->next = z; t = b;
-
- /* Build second sublist to be merged and splice from main list
- */
-
- for (i = 1; i < N; i++) t = t->next;
- todo = t->next; t->next = z;
-
- /* Merge the two sublists created, and set 'c' to point to the
- * end of the newly merged sublists.
- */
-
- c->next = merge(a,b,&t); c = t;
- }
- }
-
- /* Fix the previous pointers for the list */
-
- a = b = l->head;
- b = b->next;
- while (1) {
- b->prev = a;
- if (b == z)
- break;
- a = a->next;
- b = b->next;
- }
-}
-
diff --git a/dlist.h b/dlist.h
deleted file mode 100644
index 7381bb6554..0000000000
--- a/dlist.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-*
-* Copyright (C) 1991 Kendall Bennett.
-* All rights reserved.
-*
-* Filename: $RCSfile$
-* Version: $Revision$
-*
-* Language: ANSI C
-* Environment: any
-*
-* Description: Header file for doubly linked list routines.
-*
-* $Id$
-*
-* Revision History:
-* -----------------
-*
-* $Log$
-* Revision 1.1 1999/04/21 23:11:20 ssb
-* moved apache, com and hyperwave into ext/
-*
-* Revision 1.1.1.1 1999/04/07 21:03:20 zeev
-* PHP 4.0
-*
-* Revision 1.1.1.1 1999/03/17 04:29:11 andi
-* PHP4
-*
-* Revision 1.1.1.1 1998/12/21 07:56:22 andi
-* Trying to start the zend CVS tree
-*
-* Revision 1.2 1998/08/14 15:51:12 shane
-* Some work on getting hyperwave to work on windows. hg_comm needs a lot of work.
-*
-* Mainly, signals, fnctl, bzero, bcopy, etc are not portable functions. Most of this
-* will have to be rewriten for windows.
-*
-* Revision 1.1 1998/08/12 09:29:16 steinm
-* First version of Hyperwave module.
-*
-* Revision 1.5 91/12/31 19:40:54 kjb
-*
-* Modified include files directories.
-*
-* Revision 1.4 91/09/27 03:10:41 kjb
-* Added compatibility with C++.
-*
-* Revision 1.3 91/09/26 10:07:16 kjb
-* Took out extern references
-*
-* Revision 1.2 91/09/01 19:37:20 ROOT_DOS
-* Changed DLST_TAIL macro so that it returns a pointer to the REAL last
-* node of the list, not the dummy last node (l->z).
-*
-* Revision 1.1 91/09/01 18:38:23 ROOT_DOS
-* Initial revision
-*
-****************************************************************************/
-
-#ifndef __DLIST_H
-#define __DLIST_H
-
-#ifndef __DEBUG_H
-/*#include "debug.h"*/
-#endif
-
-/*---------------------- Macros and type definitions ----------------------*/
-
-typedef struct PHP_DLST_BUCKET {
- struct PHP_DLST_BUCKET *next;
- struct PHP_DLST_BUCKET *prev;
- } PHP_DLST_BUCKET;
-
-/* necessary for AIX 4.2.x */
-
-#ifdef hz
-#undef hz
-#endif
-
-typedef struct {
- int count; /* Number of elements currently in list */
- PHP_DLST_BUCKET *head; /* Pointer to head element of list */
- PHP_DLST_BUCKET *z; /* Pointer to last node of list */
- PHP_DLST_BUCKET hz[2]; /* Space for head and z nodes */
- } DLIST;
-
-/* Return a pointer to the user space given the address of the header of
- * a node.
- */
-
-#define PHP_DLST_USERSPACE(h) ((void*)((PHP_DLST_BUCKET*)(h) + 1))
-
-/* Return a pointer to the header of a node, given the address of the
- * user space.
- */
-
-#define PHP_DLST_HEADER(n) ((PHP_DLST_BUCKET*)(n) - 1)
-
-/* Return a pointer to the user space of the list's head node. This user
- * space does not actually exist, but it is useful to be able to address
- * it to enable insertion at the start of the list.
- */
-
-#define PHP_DLST_HEAD(l) PHP_DLST_USERSPACE((l)->head)
-
-/* Return a pointer to the user space of the last node in list. */
-
-#define PHP_DLST_TAIL(l) PHP_DLST_USERSPACE((l)->z->prev)
-
-/* Determine if a list is empty
- */
-
-#define PHP_DLST_EMPTY(l) ((l)->count == 0)
-
-/*-------------------------- Function Prototypes --------------------------*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void *dlst_newnode(int size);
-void dlst_freenode(void *node);
-DLIST *dlst_init(void);
-void dlst_kill(DLIST *l,void (*freeNode)(void *node));
-void dlst_insertafter(DLIST *l,void *node,void *after);
-void *dlst_deletenext(DLIST *l,void *node);
-void *dlst_first(DLIST *l);
-void *dlst_last(DLIST *l);
-void *dlst_next(void *prev);
-void *dlst_prev(void *next);
-void dlst_mergesort(DLIST *l,int (*cmp_func)(void*,void*));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/ext/Makefile.am b/ext/Makefile.am
deleted file mode 100644
index 8833023226..0000000000
--- a/ext/Makefile.am
+++ /dev/null
@@ -1,10 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-SUBDIRS = @EXT_SUBDIRS@
-EXT_STATIC = @EXT_STATIC@
-
-noinst_LIBRARIES=libphpext.a
-
-libphpext.a: @EXT_LIBS@
- top_srcdir=$(top_srcdir) $(top_builddir)/scripts/mkextlib $@ $(EXT_STATIC)
- @test "`uname -s`" = "Rhapsody" && $(RANLIB) $@ || exit 0
diff --git a/ext/apache/Makefile.am b/ext/apache/Makefile.am
deleted file mode 100644
index c9006e13bb..0000000000
--- a/ext/apache/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_apache.a
-libphpext_apache_a_SOURCES=apache.c
-
diff --git a/ext/apache/apache.c b/ext/apache/apache.c
deleted file mode 100644
index da439f58ed..0000000000
--- a/ext/apache/apache.c
+++ /dev/null
@@ -1,449 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Stig Sæther Bakken <ssb@guardian.no> |
- | David Sklar <sklar@student.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-#include "php.h"
-#include "ext/standard/head.h"
-#include "php_globals.h"
-#include "php_ini.h"
-#include "SAPI.h"
-#include "mod_php4.h"
-#include "ext/standard/info.h"
-
-#include <stdlib.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <string.h>
-#include <errno.h>
-#include <ctype.h>
-
-#if APACHE
-#include "http_request.h"
-#include "build-defs.h"
-
-#define SECTION(name) PUTS("<hr><h2>" name "</h2>\n")
-
-extern module *top_module;
-
-PHP_FUNCTION(virtual);
-PHP_FUNCTION(getallheaders);
-PHP_FUNCTION(apachelog);
-PHP_FUNCTION(apache_note);
-PHP_FUNCTION(apache_lookup_uri);
-
-PHP_MINFO_FUNCTION(apache);
-
-function_entry apache_functions[] = {
- PHP_FE(virtual, NULL)
- PHP_FE(getallheaders, NULL)
- PHP_FE(apache_note, NULL)
- PHP_FE(apache_lookup_uri, NULL)
- {NULL, NULL, NULL}
-};
-
-
-static PHP_INI_MH(OnChangeApacheInt)
-{
- long *p;
- char *base = (char *) &php_apache_info;
-
- p = (long *) (base+(size_t) mh_arg1);
-
- if (new_value) {
- *p = atoi(new_value);
- return SUCCESS;
- } else {
- return FAILURE;
- }
-}
-
-
-static PHP_INI_MH(OnChangeApacheString)
-{
- char **p;
- char *base = (char *) &php_apache_info;
-
- p = (char **) (base+(size_t) mh_arg1);
-
- if (new_value) {
- *p = new_value;
- return SUCCESS;
- } else {
- return FAILURE;
- }
-}
-
-PHP_INI_BEGIN()
- PHP_INI_ENTRY1("xbithack", "0", PHP_INI_ALL, OnChangeApacheInt, (void *) XtOffsetOf(php_apache_info_struct, xbithack))
- PHP_INI_ENTRY1("engine", "1", PHP_INI_ALL, OnChangeApacheInt, (void *) XtOffsetOf(php_apache_info_struct, engine))
- PHP_INI_ENTRY1("last_modified", "0", PHP_INI_ALL, OnChangeApacheInt, (void *) XtOffsetOf(php_apache_info_struct, last_modified))
- PHP_INI_ENTRY1("dav_script", NULL, PHP_INI_ALL, OnChangeApacheString, (void *) XtOffsetOf(php_apache_info_struct, dav_script))
-PHP_INI_END()
-
-
-static PHP_MINIT_FUNCTION(apache)
-{
- REGISTER_INI_ENTRIES();
- return SUCCESS;
-}
-
-
-static PHP_MSHUTDOWN_FUNCTION(apache)
-{
- UNREGISTER_INI_ENTRIES();
- return SUCCESS;
-}
-
-
-php3_module_entry apache_module_entry = {
- "Apache", apache_functions, PHP_MINIT(apache), PHP_MSHUTDOWN(apache), NULL, NULL, PHP_MINFO(apache), STANDARD_MODULE_PROPERTIES
-};
-
-/* {{{ proto string apache_note(string note_name [, string note_value])
- Get and set Apache request notes */
-PHP_FUNCTION(apache_note)
-{
- pval *arg_name,*arg_val;
- char *note_val;
- int arg_count = ARG_COUNT(ht);
- SLS_FETCH();
-
- if (arg_count<1 || arg_count>2 ||
- getParameters(ht,arg_count,&arg_name,&arg_val) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(arg_name);
- note_val = (char *) table_get(((request_rec *) SG(server_context))->notes,arg_name->value.str.val);
-
- if (arg_count == 2) {
- convert_to_string(arg_val);
- table_set(((request_rec *) SG(server_context))->notes,arg_name->value.str.val,arg_val->value.str.val);
- }
-
- if (note_val) {
- RETURN_STRING(note_val,1);
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-PHP_MINFO_FUNCTION(apache)
-{
- module *modp = NULL;
- char output_buf[128];
-#if !defined(WIN32) && !defined(WINNT)
- char name[64];
- char *p;
-#endif
- server_rec *serv;
- extern char server_root[MAX_STRING_LEN];
- extern uid_t user_id;
- extern char *user_name;
- extern gid_t group_id;
- extern int max_requests_per_child;
- SLS_FETCH();
-
- serv = ((request_rec *) SG(server_context))->server;
-
- PUTS("<table border=5 width=\"600\">\n");
- php_info_print_table_header(2, "Entry", "Value");
-#if WIN32|WINNT
- PUTS("Apache for Windows 95/NT<br>");
-#else
- php_info_print_table_row(2, "APACHE_INCLUDE", PHP_APACHE_INCLUDE);
- php_info_print_table_row(2, "APACHE_TARGET", PHP_APACHE_TARGET);
-#endif
- php_info_print_table_row(2, "Apache Version", SERVER_VERSION);
-#ifdef APACHE_RELEASE
- sprintf(output_buf, "%d", APACHE_RELEASE);
- php_info_print_table_row(2, "Apache Release", output_buf);
-#endif
- sprintf(output_buf, "%d", MODULE_MAGIC_NUMBER);
- php_info_print_table_row(2, "Apache API Version", output_buf);
- sprintf(output_buf, "%s:%u", serv->server_hostname,serv->port);
- php_info_print_table_row(2, "Hostname/Port", output_buf);
-#if !defined(WIN32) && !defined(WINNT)
- sprintf(output_buf, "%s(%d)/%d", user_name,(int)user_id,(int)group_id);
- php_info_print_table_row(2, "User/Group", output_buf);
- sprintf(output_buf, "per child: %d<br>keep alive: %s<br>max per connection: %d",max_requests_per_child,serv->keep_alive ? "on":"off", serv->keep_alive_max);
- php_info_print_table_row(2, "Max Requests", output_buf);
-#endif
- sprintf(output_buf, "connection: %d<br>keep-alive: %d",serv->timeout,serv->keep_alive_timeout);
- php_info_print_table_row(2, "Timeouts", output_buf);
-#if !defined(WIN32) && !defined(WINNT)
- php_info_print_table_row(2, "Server Root", server_root);
-
-
- PUTS("<tr><td valign=\"top\" bgcolor=\"" PHP_ENTRY_NAME_COLOR "\">Loaded modules</td><td bgcolor=\"" PHP_CONTENTS_COLOR "\">");
- for(modp = top_module; modp; modp = modp->next) {
- strlcpy(name, modp->name, sizeof(name));
- if ((p = strrchr(name, '.'))) {
- *p='\0'; /* Cut off ugly .c extensions on module names */
- }
- PUTS(name);
- if (modp->next) {
- PUTS(", ");
- }
- }
-#endif
- PUTS("</td></tr>\n");
- PUTS("</table>\n");
-
-
- {
- register int i;
- array_header *arr;
- table_entry *elts;
- request_rec *r;
- SLS_FETCH();
-
- r = ((request_rec *) SG(server_context));
- arr = table_elts(r->subprocess_env);
- elts = (table_entry *)arr->elts;
-
- SECTION("Apache Environment");
- PUTS("<table border=5 width=\"600\">\n");
- php_info_print_table_header(2, "Variable", "Value");
- for (i=0; i < arr->nelts; i++) {
- php_info_print_table_row(2, elts[i].key, elts[i].val);
- }
- PUTS("</table>\n");
- }
-
- {
- array_header *env_arr;
- table_entry *env;
- int i;
- request_rec *r;
- SLS_FETCH();
-
- r = ((request_rec *) SG(server_context));
- SECTION("HTTP Headers Information");
- PUTS("<table border=5 width=\"600\">\n");
- PUTS(" <tr><th colspan=2 bgcolor=\"" PHP_HEADER_COLOR "\">HTTP Request Headers</th></tr>\n");
- php_info_print_table_row(2, "HTTP Request", r->the_request);
- env_arr = table_elts(r->headers_in);
- env = (table_entry *)env_arr->elts;
- for (i = 0; i < env_arr->nelts; ++i) {
- if (env[i].key) {
- php_info_print_table_row(2, env[i].key, env[i].val);
- }
- }
- PUTS(" <tr><th colspan=2 bgcolor=\"" PHP_HEADER_COLOR "\">HTTP Response Headers</th></tr>\n");
- env_arr = table_elts(r->headers_out);
- env = (table_entry *)env_arr->elts;
- for(i = 0; i < env_arr->nelts; ++i) {
- if (env[i].key) {
- php_info_print_table_row(2, env[i].key, env[i].val);
- }
- }
- PUTS("</table>\n\n");
- }
-
-}
-
-/* This function is equivalent to <!--#include virtual...-->
- * in mod_include. It does an Apache sub-request. It is useful
- * for including CGI scripts or .shtml files, or anything else
- * that you'd parse through Apache (for .phtml files, you'd probably
- * want to use <?Include>. This only works when PHP is compiled
- * as an Apache module, since it uses the Apache API for doing
- * sub requests.
- */
-/* {{{ proto int virtual(string filename)
- Perform an Apache sub-request */
-PHP_FUNCTION(virtual)
-{
- pval *filename;
- request_rec *rr = NULL;
- SLS_FETCH();
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&filename) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(filename);
-
- if (!(rr = sub_req_lookup_uri (filename->value.str.val, ((request_rec *) SG(server_context))))) {
- php_error(E_WARNING, "Unable to include '%s' - URI lookup failed", filename->value.str.val);
- if (rr) destroy_sub_req (rr);
- RETURN_FALSE;
- }
-
- if (rr->status != 200) {
- php_error(E_WARNING, "Unable to include '%s' - error finding URI", filename->value.str.val);
- if (rr) destroy_sub_req (rr);
- RETURN_FALSE;
- }
-
- /* Cannot include another PHP file because of global conflicts */
- if (rr->content_type &&
- !strcmp(rr->content_type, PHP3_MIME_TYPE)) {
- php_error(E_WARNING, "Cannot include a PHP file "
- "(use <code>&lt;?include \"%s\"&gt;</code> instead)", filename->value.str.val);
- if (rr) destroy_sub_req (rr);
- RETURN_FALSE;
- }
-
- if (run_sub_req(rr)) {
- php_error(E_WARNING, "Unable to include '%s' - request execution failed", filename->value.str.val);
- if (rr) destroy_sub_req (rr);
- RETURN_FALSE;
- } else {
- if (rr) destroy_sub_req (rr);
- RETURN_TRUE;
- }
-}
-/* }}} */
-
-/* {{{ proto array getallheaders(void)
- Fetch all HTTP request headers */
-PHP_FUNCTION(getallheaders)
-{
- array_header *env_arr;
- table_entry *tenv;
- int i;
- SLS_FETCH();
- PLS_FETCH();
-
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
- env_arr = table_elts(((request_rec *) SG(server_context))->headers_in);
- tenv = (table_entry *)env_arr->elts;
- for (i = 0; i < env_arr->nelts; ++i) {
- if (!tenv[i].key ||
- (PG(safe_mode) &&
- !strncasecmp(tenv[i].key, "authorization", 13))) {
- continue;
- }
- if (add_assoc_string(return_value, tenv[i].key,(tenv[i].val==NULL) ? "" : tenv[i].val, 1)==FAILURE) {
- RETURN_FALSE;
- }
- }
-}
-/* }}} */
-
-/* {{{ proto class apache_lookup_uri(string URI)
- Perform a partial request of the given URI to obtain information about it */
-PHP_FUNCTION(apache_lookup_uri)
-{
- pval *filename;
- request_rec *rr=NULL;
- SLS_FETCH();
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&filename) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(filename);
-
- if(!(rr = sub_req_lookup_uri(filename->value.str.val, ((request_rec *) SG(server_context))))) {
- php_error(E_WARNING, "URI lookup failed", filename->value.str.val);
- RETURN_FALSE;
- }
- object_init(return_value);
- add_property_long(return_value,"status",rr->status);
- if (rr->the_request) {
- add_property_string(return_value,"the_request",rr->the_request,1);
- }
- if (rr->status_line) {
- add_property_string(return_value,"status_line",(char *)rr->status_line,1);
- }
- if (rr->method) {
- add_property_string(return_value,"method",(char *)rr->method,1);
- }
- if (rr->content_type) {
- add_property_string(return_value,"content_type",(char *)rr->content_type,1);
- }
- if (rr->handler) {
- add_property_string(return_value,"handler",(char *)rr->handler,1);
- }
- if (rr->uri) {
- add_property_string(return_value,"uri",rr->uri,1);
- }
- if (rr->filename) {
- add_property_string(return_value,"filename",rr->filename,1);
- }
- if (rr->path_info) {
- add_property_string(return_value,"path_info",rr->path_info,1);
- }
- if (rr->args) {
- add_property_string(return_value,"args",rr->args,1);
- }
- if (rr->boundary) {
- add_property_string(return_value,"boundary",rr->boundary,1);
- }
- add_property_long(return_value,"no_cache",rr->no_cache);
- add_property_long(return_value,"no_local_copy",rr->no_local_copy);
- add_property_long(return_value,"allowed",rr->allowed);
- add_property_long(return_value,"sent_bodyct",rr->sent_bodyct);
- add_property_long(return_value,"bytes_sent",rr->bytes_sent);
- add_property_long(return_value,"byterange",rr->byterange);
- add_property_long(return_value,"clength",rr->clength);
-
-#if MODULE_MAGIC_NUMBER >= 19980324
- if (rr->unparsed_uri) {
- add_property_string(return_value,"unparsed_uri",rr->unparsed_uri,1);
- }
- if(rr->mtime) {
- add_property_long(return_value,"mtime",rr->mtime);
- }
-#endif
- if(rr->request_time) {
- add_property_long(return_value,"request_time",rr->request_time);
- }
-
- destroy_sub_req(rr);
-}
-/* }}} */
-
-#if 0
-This function is most likely a bad idea. Just playing with it for now.
-
-PHP_FUNCTION(apache_exec_uri)
-{
- pval *filename;
- request_rec *rr=NULL;
- SLS_FETCH();
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&filename) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(filename);
-
- if(!(rr = ap_sub_req_lookup_uri(filename->value.str.val, ((request_rec *) SG(server_context))))) {
- php_error(E_WARNING, "URI lookup failed", filename->value.str.val);
- RETURN_FALSE;
- }
- RETVAL_LONG(ap_run_sub_req(rr));
- ap_destroy_sub_req(rr);
-}
-#endif
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/apache/config.m4 b/ext/apache/config.m4
deleted file mode 100644
index e878cdbb8b..0000000000
--- a/ext/apache/config.m4
+++ /dev/null
@@ -1,5 +0,0 @@
-dnl $Id$
-
-if test -n "$APACHE_INCLUDE"; then
- PHP_EXTENSION(apache)
-fi
diff --git a/ext/aspell/Makefile.am b/ext/aspell/Makefile.am
deleted file mode 100644
index 2d739171f7..0000000000
--- a/ext/aspell/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_aspell.a
-libphpext_aspell_a_SOURCES=aspell.c
-
diff --git a/ext/aspell/aspell.c b/ext/aspell/aspell.c
deleted file mode 100644
index fcfb33cbce..0000000000
--- a/ext/aspell/aspell.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-#if defined(COMPILE_DL)
-#include "phpdl.h"
-#endif
-#include <stdlib.h>
-#include <ctype.h>
-#include <stdio.h>
-
-#if HAVE_ASPELL
-
-#include "php3_aspell.h"
-#if APACHE
-# ifndef DEBUG
-# undef palloc
-# endif
-#endif
-#include <aspell-c.h>
-
-function_entry aspell_functions[] = {
- PHP_FE(aspell_new, NULL)
- PHP_FE(aspell_check, NULL)
- PHP_FE(aspell_check_raw, NULL)
- PHP_FE(aspell_suggest, NULL)
- {NULL, NULL, NULL}
-};
-
-static int le_aspell;
-
-php3_module_entry aspell_module_entry = {
- "Aspell", aspell_functions, PHP_MINIT(aspell), NULL, NULL, NULL, PHP_MINFO(aspell), STANDARD_MODULE_PROPERTIES
-};
-
-
-#if COMPILE_DL
-DLEXPORT php3_module_entry *get_module(void) { return &aspell_module_entry; }
-#endif
-
-PHP_MINIT_FUNCTION(aspell)
-{
- le_aspell = register_list_destructors(php3_aspell_close,NULL);
- return SUCCESS;
-
-}
-void php3_aspell_close(aspell *sc)
-{
- aspell_free(sc);
-}
-
-/* {{{ proto int aspell_new(string master[, string personal])
- Load a dictionary */
-PHP_FUNCTION(aspell_new)
-{
- pval *master, *personal;
- int argc;
- aspell *sc;
- int ind;
-
- argc = ARG_COUNT(ht);
- if (argc < 1 || argc > 2 || getParameters(ht, argc, &master,&personal) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(master);
- if(argc==2)
- {
- convert_to_string(personal) ;
- sc=aspell_new(master->value.str.val,personal->value.str.val);
- }
- else
- sc=aspell_new(master->value.str.val,"");
-
- ind = php3_list_insert(sc, le_aspell);
- RETURN_LONG(ind);
-}
-/* }}} */
-
-
-/* {{{ proto array aspell_suggest(aspell int,string word)
- Return array of Suggestions */
-PHP_FUNCTION(aspell_suggest)
-{
- pval *scin, *word;
- int argc;
- aspell *sc;
- int ind,type;
- aspellSuggestions *sug;
- size_t i;
-
-
- argc = ARG_COUNT(ht);
- if (argc != 2 || getParameters(ht, argc, &scin,&word) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(scin);
- convert_to_string(word);
- sc= (aspell *) php3_list_find(scin->value.lval, &type);
- if(!sc)
- {
- php_error(E_WARNING, "%d is not a ASPELL result index", scin->value.lval);
- RETURN_FALSE;
- }
-
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
-
- sug = aspell_suggest(sc, word->value.str.val);
- for (i = 0; i != sug->size; ++i) {
- add_next_index_string(return_value,(char *)sug->data[i],1);
- }
- aspell_free_suggestions(sug);
-}
-/* }}} */
-
-/* {{{ proto int aspell_check(aspell int,string word)
- Return if word is valid */
-PHP_FUNCTION(aspell_check)
-{
- int type;
- pval *scin,*word;
- aspell *sc;
-
- int argc;
- argc = ARG_COUNT(ht);
- if (argc != 2 || getParameters(ht, argc, &scin,&word) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(scin);
- convert_to_string(word);
- sc= (aspell *) php3_list_find(scin->value.lval, &type);
- if(!sc)
- {
- php_error(E_WARNING, "%d is not a ASPELL result index", scin->value.lval);
- RETURN_FALSE;
- }
- if (aspell_check(sc, word->value.str.val))
- {
- RETURN_TRUE;
- }
- else
- {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int aspell_check_raw(aspell int,string word)
- Return if word is valid, ignoring case or trying to trim it in any way*/
-PHP_FUNCTION(aspell_check_raw)
-{
- pval *scin,*word;
- int type;
- int argc;
- aspell *sc;
-
- argc = ARG_COUNT(ht);
- if (argc != 2 || getParameters(ht, argc, &scin,&word) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(scin);
- convert_to_string(word);
- sc= (aspell *) php3_list_find(scin->value.lval, &type);
- if(!sc)
- {
- php_error(E_WARNING, "%d is not a ASPELL result index", scin->value.lval);
- RETURN_FALSE;
- }
- if (aspell_check_raw(sc, word->value.str.val))
- {
- RETURN_TRUE;
- }
- else
- {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-PHP_MINFO_FUNCTION(aspell)
-{
- php_printf("ASpell support enabled");
-
-}
-
-#endif
diff --git a/ext/aspell/config.h.stub b/ext/aspell/config.h.stub
deleted file mode 100644
index 4be31d352a..0000000000
--- a/ext/aspell/config.h.stub
+++ /dev/null
@@ -1,4 +0,0 @@
-/* Define if you want the ASPELL interface */
-#ifndef HAVE_ASPELL
-#define HAVE_ASPELL 0
-#endif
diff --git a/ext/aspell/config.m4 b/ext/aspell/config.m4
deleted file mode 100644
index bfec9c4223..0000000000
--- a/ext/aspell/config.m4
+++ /dev/null
@@ -1,28 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(for ASPELL support)
-AC_ARG_WITH(aspell,
-[ --with-aspell[=DIR] Include ASPELL support.],
-[
- if test "$withval" != "no"; then
- if test "$withval" = "yes"; then
- ASPELL_DIR=/usr/local
- else
- ASPELL_DIR=$withval
- fi
-
- AC_ADD_INCLUDE($ASPELL_DIR/include)
- AC_ADD_LIBRARY_WITH_PATH(aspell, $ASPELL_DIR/lib)
-
- if test ! -f "$ASPELL_DIR/include/aspell-c.h"; then
- AC_MSG_ERROR(Could not find aspell-c.h in $ASPELL_DIR/include - please copy it manually from the aspell sources to $ASPELL_DIR/include)
- fi
- AC_DEFINE(HAVE_ASPELL)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(aspell)
- else
- AC_MSG_ERROR(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
diff --git a/ext/aspell/php3_aspell.h b/ext/aspell/php3_aspell.h
deleted file mode 100644
index d0c8b35a82..0000000000
--- a/ext/aspell/php3_aspell.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _ASPELL_H
-#define _ASPELL_H
-#if HAVE_ASPELL
-extern php3_module_entry aspell_module_entry;
-#define aspell_module_ptr &aspell_module_entry
-
-extern PHP_MINIT_FUNCTION(aspell);
-extern PHP_MINFO_FUNCTION(aspell);
-extern void php3_aspell_close();
-
-PHP_FUNCTION(aspell_new);
-PHP_FUNCTION(aspell_check);
-PHP_FUNCTION(aspell_check_raw);
-PHP_FUNCTION(aspell_suggest);
-
-#else
-#define aspell_module_ptr NULL
-#endif
-
-#define phpext_aspell_ptr aspell_module_ptr
-
-#endif /* _ASPELL_H */
diff --git a/ext/bcmath/Makefile.am b/ext/bcmath/Makefile.am
deleted file mode 100644
index b5f9acdee0..0000000000
--- a/ext/bcmath/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_bcmath.a
-libphpext_bcmath_a_SOURCES=bcmath.c number.c
diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c
deleted file mode 100644
index d4a7032376..0000000000
--- a/ext/bcmath/bcmath.c
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Andi Gutmans <andi@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-#include "php.h"
-
-#if WITH_BCMATH
-
-#include "number.h"
-#include "php3_bcmath.h"
-
-function_entry bcmath_functions[] = {
- PHP_FE(bcadd, NULL)
- PHP_FE(bcsub, NULL)
- PHP_FE(bcmul, NULL)
- PHP_FE(bcdiv, NULL)
- PHP_FE(bcmod, NULL)
- PHP_FE(bcpow, NULL)
- PHP_FE(bcsqrt, NULL)
- PHP_FE(bcscale, NULL)
- PHP_FE(bccomp, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry bcmath_module_entry = {
- "bcmath", bcmath_functions, NULL, NULL, PHP_RINIT(bcmath), PHP_RSHUTDOWN(bcmath), NULL, STANDARD_MODULE_PROPERTIES
-};
-
-#if COMPILE_DL
-php3_module_entry *get_module() { return &bcmath_module_entry; };
-#endif
-
-#ifndef THREAD_SAFE
-static long bc_precision;
-#endif
-
-PHP_RINIT_FUNCTION(bcmath)
-{
- init_numbers();
- if (cfg_get_long("bcmath.scale",&bc_precision)==FAILURE) {
- bc_precision=0;
- }
- return SUCCESS;
-}
-
-PHP_RSHUTDOWN_FUNCTION(bcmath)
-{
- destruct_numbers();
- return SUCCESS;
-}
-
-/* {{{ proto string bcadd(string left_operand, string right_operand [, int scale])
- Returns the sum of two arbitrary precision numbers */
-PHP_FUNCTION(bcadd)
-{
- pval *left, *right,*scale_param;
- bc_num first, second, result;
- int scale=bc_precision;
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &left, &right) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 3:
- if (getParameters(ht, 3, &left, &right, &scale_param) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(scale_param);
- scale = (int) scale_param->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
- convert_to_string(left);
- convert_to_string(right);
- init_num(&first);
- init_num(&second);
- init_num(&result);
- str2num(&first,left->value.str.val,scale);
- str2num(&second,right->value.str.val,scale);
- bc_add (first,second,&result, scale);
- return_value->value.str.val = num2str(result);
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
- free_num(&first);
- free_num(&second);
- free_num(&result);
- return;
-}
-/* }}} */
-
-/* {{{ proto string bcsub(string left_operand, string right_operand [, int scale])
- Returns the difference between two arbitrary precision numbers (subtration) */
-PHP_FUNCTION(bcsub)
-{
- pval *left, *right,*scale_param;
- bc_num first, second, result;
- int scale=bc_precision;
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &left, &right) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 3:
- if (getParameters(ht, 3, &left, &right, &scale_param) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(scale_param);
- scale = (int) scale_param->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
- convert_to_string(left);
- convert_to_string(right);
- init_num(&first);
- init_num(&second);
- init_num(&result);
- str2num(&first,left->value.str.val,scale);
- str2num(&second,right->value.str.val,scale);
- bc_sub (first,second,&result, scale);
- return_value->value.str.val = num2str(result);
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
- free_num(&first);
- free_num(&second);
- free_num(&result);
- return;
-}
-/* }}} */
-
-/* {{{ proto string bcmul(string left_operand, string right_operand [, int scale])
- Returns the multiplication of two arbitrary precision numbers */
-PHP_FUNCTION(bcmul)
-{
- pval *left, *right,*scale_param;
- bc_num first, second, result;
- int scale=bc_precision;
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &left, &right) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 3:
- if (getParameters(ht, 3, &left, &right, &scale_param) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(scale_param);
- scale = (int) scale_param->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
- convert_to_string(left);
- convert_to_string(right);
- init_num(&first);
- init_num(&second);
- init_num(&result);
- str2num(&first,left->value.str.val,scale);
- str2num(&second,right->value.str.val,scale);
- bc_multiply (first,second,&result, scale);
- return_value->value.str.val = num2str(result);
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
- free_num(&first);
- free_num(&second);
- free_num(&result);
- return;
-}
-/* }}} */
-
-/* {{{ proto string bcdiv(string left_operand, string right_operand [, int scale])
- Returns the quotient of two arbitrary precision numbers (division) */
-PHP_FUNCTION(bcdiv)
-{
- pval *left, *right,*scale_param;
- bc_num first, second, result;
- int scale=bc_precision;
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &left, &right) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 3:
- if (getParameters(ht, 3, &left, &right, &scale_param) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(scale_param);
- scale = (int) scale_param->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
- convert_to_string(left);
- convert_to_string(right);
- init_num(&first);
- init_num(&second);
- init_num(&result);
- str2num(&first,left->value.str.val,scale);
- str2num(&second,right->value.str.val,scale);
- switch (bc_divide (first,second,&result, scale)) {
- case 0: /* OK */
- return_value->value.str.val = num2str(result);
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
- break;
- case -1: /* division by zero */
- php_error(E_WARNING,"Division by zero");
- break;
- }
- free_num(&first);
- free_num(&second);
- free_num(&result);
- return;
-}
-/* }}} */
-
-/* {{{ proto string bcmod(string left_operand, string right_operand)
- Returns the modulus of the two arbitrary precision operands */
-PHP_FUNCTION(bcmod)
-{
- pval *left, *right;
- bc_num first, second, result;
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &left, &right) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
- convert_to_string(left);
- convert_to_string(right);
- init_num(&first);
- init_num(&second);
- init_num(&result);
- str2num(&first,left->value.str.val,0);
- str2num(&second,right->value.str.val,0);
- switch (bc_modulo(first,second,&result, 0)) {
- case 0:
- return_value->value.str.val = num2str(result);
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
- break;
- case -1:
- php_error(E_WARNING,"Division by zero");
- break;
- }
- free_num(&first);
- free_num(&second);
- free_num(&result);
- return;
-}
-/* }}} */
-
-/* {{{ proto string bcpow(string x, string y [, int scale])
- Returns the value of an arbitrary precision number raised to the power of another */
-PHP_FUNCTION(bcpow)
-{
- pval *left, *right,*scale_param;
- bc_num first, second, result;
- int scale=bc_precision;
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &left, &right) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 3:
- if (getParameters(ht, 3, &left, &right, &scale_param) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(scale_param);
- scale = (int) scale_param->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
- convert_to_string(left);
- convert_to_string(right);
- init_num(&first);
- init_num(&second);
- init_num(&result);
- str2num(&first,left->value.str.val,scale);
- str2num(&second,right->value.str.val,scale);
- bc_raise (first,second,&result, scale);
- return_value->value.str.val = num2str(result);
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
- free_num(&first);
- free_num(&second);
- free_num(&result);
- return;
-}
-/* }}} */
-
-/* {{{ proto string bcsqrt(string operand [, int scale])
- Returns the square root of an arbitray precision number */
-PHP_FUNCTION(bcsqrt)
-{
- pval *left,*scale_param;
- bc_num result;
- int scale=bc_precision;
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &left) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 2:
- if (getParameters(ht, 2, &left, &scale_param) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(scale_param);
- scale = (int) scale_param->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
- convert_to_string(left);
- init_num(&result);
- str2num(&result,left->value.str.val,scale);
- if (bc_sqrt (&result, scale) != 0) {
- return_value->value.str.val = num2str(result);
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
- } else {
- php_error(E_WARNING,"Square root of negative number");
- }
- free_num(&result);
- return;
-}
-/* }}} */
-
-/* {{{ proto string bccomp(string left_operand, string right_operand [, int scale])
- Compares two arbitrary precision numbers */
-PHP_FUNCTION(bccomp)
-{
- pval *left, *right, *scale_param;
- bc_num first, second;
- int scale=bc_precision;
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &left, &right) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 3:
- if (getParameters(ht, 3, &left, &right, &scale_param) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(scale_param);
- scale = (int) scale_param->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- convert_to_string(left);
- convert_to_string(right);
- init_num(&first);
- init_num(&second);
-
- str2num(&first,left->value.str.val,scale);
- str2num(&second,right->value.str.val,scale);
- return_value->value.lval = bc_compare(first,second);
- return_value->type = IS_LONG;
-
- free_num(&first);
- free_num(&second);
- return;
-}
-/* }}} */
-
-/* {{{ proto string bcscale(int scale)
- Sets default scale parameter for all bc math functions */
-PHP_FUNCTION(bcscale)
-{
- pval *new_scale;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &new_scale)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(new_scale);
- bc_precision = new_scale->value.lval;
- RETURN_TRUE;
-}
-/* }}} */
-
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/bcmath/config.h.stub b/ext/bcmath/config.h.stub
deleted file mode 100644
index 6346c81f10..0000000000
--- a/ext/bcmath/config.h.stub
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Define if you want to enable bc style precision math support */
-#define WITH_BCMATH 0
diff --git a/ext/bcmath/config.m4 b/ext/bcmath/config.m4
deleted file mode 100644
index 960d3863f6..0000000000
--- a/ext/bcmath/config.m4
+++ /dev/null
@@ -1,20 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(whether to enable bc style precision math functions)
-AC_ARG_ENABLE(bcmath,
-[ --enable-bcmath Compile with bc style precision math functions.
- Read README-BCMATH for instructions on how to
- get this module installed. ],
-[
- if test "$enableval" = "yes"; then
- AC_DEFINE(WITH_BCMATH, 1)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(bcmath)
- else
- AC_DEFINE(WITH_BCMATH, 0)
- AC_MSG_RESULT(no)
- fi
-],[
- AC_DEFINE(WITH_BCMATH, 0)
- AC_MSG_RESULT(no)
-])
diff --git a/ext/bcmath/php3_bcmath.h b/ext/bcmath/php3_bcmath.h
deleted file mode 100644
index a6007e60d1..0000000000
--- a/ext/bcmath/php3_bcmath.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Andi Gutmans <andi@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _PHP3_BCMATH_H
-#define _PHP3_BCMATH_H
-
-#if COMPILE_DL
-#undef WITH_BCMATH
-#define WITH_BCMATH 1
-#endif
-
-#if WITH_BCMATH
-
-extern php3_module_entry bcmath_module_entry;
-#define phpext_bcmath_ptr &bcmath_module_entry
-
-extern PHP_RINIT_FUNCTION(bcmath);
-extern PHP_RSHUTDOWN_FUNCTION(bcmath);
-PHP_FUNCTION(bcadd);
-PHP_FUNCTION(bcsub);
-PHP_FUNCTION(bcmul);
-PHP_FUNCTION(bcdiv);
-PHP_FUNCTION(bcmod);
-PHP_FUNCTION(bcpow);
-PHP_FUNCTION(bcsqrt);
-PHP_FUNCTION(bccomp);
-PHP_FUNCTION(bcscale);
-
-#else
-
-#define phpext_bcmath_ptr NULL
-
-#endif
-
-#endif /* _PHP3_BCMATH_H */
diff --git a/ext/bcmath/setup.stub b/ext/bcmath/setup.stub
deleted file mode 100644
index c1cf263ef5..0000000000
--- a/ext/bcmath/setup.stub
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Source$
-# $Id$
-
-define_option enable-bcmath 'Enable bc style precision math functions' yesno \
- yes \
-' Enables bc style arbitrary precision math functions.'
diff --git a/ext/com/php3_COM.h b/ext/com/php3_COM.h
deleted file mode 100644
index 60b7e06e97..0000000000
--- a/ext/com/php3_COM.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef _PHP3_COM_H
-#define _PHP3_COM_H
-
-#if WIN32|WINNT
-
-extern PHP_MINIT_FUNCTION(COM);
-extern PHP_MSHUTDOWN_FUNCTION(COM);
-PHP_FUNCTION(COM_load);
-PHP_FUNCTION(COM_invoke);
-
-PHP_FUNCTION(com_propget);
-PHP_FUNCTION(com_propput);
-extern php3_module_entry COM_module_entry;
-#define COM_module_ptr &COM_module_entry
-
-#else
-
-#define COM_module_ptr NULL
-
-#endif /* Win32|WINNT */
-
-#define phpext_COM_ptr COM_module_ptr
-
-#endif /* _PHP3_COM_H */
diff --git a/ext/dav/Makefile.am b/ext/dav/Makefile.am
deleted file mode 100644
index 58f9fe1009..0000000000
--- a/ext/dav/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_dav.a
-libphpext_dav_a_SOURCES=dav.c
-
diff --git a/ext/dav/config.h.stub b/ext/dav/config.h.stub
deleted file mode 100644
index 90a0bc1de4..0000000000
--- a/ext/dav/config.h.stub
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Define to compile with mod_dav support */
-#define HAVE_MOD_DAV 0
diff --git a/ext/dav/config.m4 b/ext/dav/config.m4
deleted file mode 100644
index c2b83adbc7..0000000000
--- a/ext/dav/config.m4
+++ /dev/null
@@ -1,29 +0,0 @@
-dnl $Id$
-dnl config.m4 for extension dav
-dnl don't forget to call PHP_EXTENSION(dav)
-
-AC_MSG_CHECKING(whether to enable DAV support through mod_dav)
-AC_ARG_WITH(mod-dav,
-[ --with-mod-dav=DIR Include DAV support through Apache's mod_dav,
- DIR is mod_dav's installation directory (Apache
- module version only!)],
-[
- if test "$withval" = "yes"; then
- AC_MSG_ERROR(Must give parameter to --with-mod-dav!)
- else
- if test "$withval" != "no"; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_MOD_DAV, 1)
- CFLAGS="$CFLAGS -DHAVE_MOD_DAV -I$withval"
- INCLUDES="$INCLUDES -I$withval"
- PHP_EXTENSION(dav)
- else
- AC_MSG_RESULT(no)
- AC_DEFINE(HAVE_MOD_DAV, 0)
- fi
- fi
-],[
- AC_MSG_RESULT(no)
- AC_DEFINE(HAVE_MOD_DAV, 0)
-])
-
diff --git a/ext/dav/dav.c b/ext/dav/dav.c
deleted file mode 100644
index 5ca8a39012..0000000000
--- a/ext/dav/dav.c
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Stig Sæther Bakken <ssb@guardian.no> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#define IS_EXT_MODULE
-#if COMPILE_DL
-# if PHP_31
-# include "../phpdl.h"
-# else
-# include "dl/phpdl.h"
-# endif
-#endif
-#include "php.h"
-#include "php3_dav.h"
-
-#if defined(THREAD_SAFE) && !PHP_31
-# undef THREAD_SAFE
-#endif
-
-#if HAVE_MOD_DAV
-
-# include "mod_dav.h"
-# include "phpdav.h"
-# include "variables.h"
-
-/* {{{ thread safety stuff */
-
-# ifdef THREAD_SAFE
-# define DAV_GLOBAL(a) phpdav_globals->a
-# define DAV_TLS_VARS phpdav_global_struct *phpdav_globals = TlsGetValue(PHPDAVTls);
-
-void *phpdav_mutex;
-DWORD PHPDAVTls;
-static int numthreads=0;
-
-typedef struct phpdav_global_struct {
- phpdav_module php3_dav_module;
-} phpdav_global_struct;
-
-# else /* !defined(THREAD_SAFE) */
-# define DAV_GLOBAL(a) a
-# define DAV_TLS_VARS
-
-phpdav_module php3_dav_module;
-
-# endif /* defined(THREAD_SAFE) */
-
-# define DAV_HANDLER(a) DAV_GLOBAL(php3_dav_module).a##_handler
-# define DAV_SET_HANDLER(a,b) \
- dav_set_handler(&DAV_GLOBAL(php3_dav_module).a##_handler,(b))
-
-
-/* }}} */
-/* {{{ dynamically loadable module stuff */
-
-# if COMPILE_DL
-DLEXPORT php3_module_entry *get_module() { return &phpdav_module_entry; };
-# endif /* COMPILE_DL */
-
-/* }}} */
-/* {{{ function prototypes */
-
-int php3_minit_phpdav(INIT_FUNC_ARGS);
-int php3_rinit_phpdav(INIT_FUNC_ARGS);
-int php3_mshutdown_phpdav(SHUTDOWN_FUNC_ARGS);
-int php3_rshutdown_phpdav(SHUTDOWN_FUNC_ARGS);
-void php3_info_phpdav(ZEND_MODULE_INFO_FUNC_ARGS);
-
-/* }}} */
-/* {{{ extension definition structures */
-
-function_entry phpdav_functions[] = {
- PHP_FE(dav_set_mkcol_handlers, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry phpdav_module_entry = {
- "DAV", /* extension name */
- phpdav_functions, /* extension function list */
- php3_minit_phpdav, /* extension-wide startup function */
- php3_mshutdown_phpdav, /* extension-wide shutdown function */
- php3_rinit_phpdav, /* per-request startup function */
- php3_rshutdown_phpdav, /* per-request shutdown function */
- php3_info_phpdav, /* information function */
- STANDARD_MODULE_PROPERTIES
-};
-
-/* }}} */
-/* {{{ startup, shutdown and info functions */
-
- /* {{{ php3_minit_phpdav */
-
-int php3_minit_phpdav(INIT_FUNC_ARGS)
-{
-#if defined(THREAD_SAFE)
- phpdav_global_struct *phpdav_globals;
- PHP3_MUTEX_ALLOC(phpdav_mutex);
- PHP3_MUTEX_LOCK(phpdav_mutex);
- numthreads++;
- if (numthreads==1){
- if (!PHP3_TLS_PROC_STARTUP(PHPDAVTls)){
- PHP3_MUTEX_UNLOCK(phpdav_mutex);
- PHP3_MUTEX_FREE(phpdav_mutex);
- return FAILURE;
- }
- }
- PHP3_MUTEX_UNLOCK(phdpav_mutex);
- if(!PHP3_TLS_THREAD_INIT(PHPDAVTls,phpdav_globals,phpdav_global_struct)){
- PHP3_MUTEX_FREE(phpdav_mutex);
- return FAILURE;
- }
-#endif
- return SUCCESS;
-}
-
-/* }}} */
- /* {{{ php3_rinit_phpdav */
-
-int php3_rinit_phpdav(INIT_FUNC_ARGS)
-{
- return SUCCESS;
-}
-
-/* }}} */
- /* {{{ php3_mshutdown_phpdav() */
-
-int php3_mshutdown_phpdav(SHUTDOWN_FUNC_ARGS)
-{
- DAV_TLS_VARS;
-#ifdef THREAD_SAFE
- PHP3_TLS_THREAD_FREE(phpdav_globals);
- PHP3_MUTEX_LOCK(phpdav_mutex);
- numthreads--;
- if (numthreads < 1) {
- PHP3_TLS_PROC_SHUTDOWN(PHPDAVTls);
- PHP3_MUTEX_UNLOCK(phpdav_mutex);
- PHP3_MUTEX_FREE(phpdav_mutex);
- return SUCCESS;
- }
- PHP3_MUTEX_UNLOCK(phpdav_mutex);
-#endif
- return SUCCESS;
-}
-
-/* }}} */
- /* {{{ php3_rshutdown_phpdav() */
-
-int php3_rshutdown_phpdav(SHUTDOWN_FUNC_ARGS)
-{
- if (DAV_HANDLER(mkcol_test)) {
- efree(DAV_HANDLER(mkcol_test));
- }
- if (DAV_HANDLER(mkcol_create)) {
- efree(DAV_HANDLER(mkcol_create));
- }
- return SUCCESS;
-}
-
-/* }}} */
- /* {{{ php3_info_phpdav() */
-
-void php3_info_phpdav(ZEND_MODULE_INFO_FUNC_ARGS)
-{
-}
-
-/* }}} */
-
-/* }}} */
-/* {{{ extension-internal functions */
-
- /* {{{ dav_set_handler() */
-
-static void
-dav_set_handler(char **nameBufp, pval *data)
-{
- if (data->value.str.len > 0) {
- if (*nameBufp != NULL) {
- efree(*nameBufp);
- }
- *nameBufp = php3i_pval_strdup(data);
- } else {
- if (*nameBufp != NULL) {
- efree(*nameBufp);
- }
- *nameBufp = NULL;
- }
-}
-
-/* }}} */
- /* {{{ dav_call_handler() */
-
-static int
-dav_call_handler(char *funcName, int argc, pval **argv)
-{
- if (funcName) {
- pval *retval, *func;
- int i, ret;
- HashTable *function_table;
-
- func = php3i_string_pval(funcName);
- retval = emalloc(sizeof(pval));
- function_table = php3i_get_function_table();
- if (call_user_function(function_table, NULL, func, retval, argc, argv) == FAILURE) {
- php3tls_pval_destructor(retval);
- efree(retval);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- php3tls_pval_destructor(func);
- efree(func);
- for (i = 0; i < argc; i++) {
- php3tls_pval_destructor(argv[i]);
- efree(argv[i]);
- }
- convert_to_long(retval);
- ret = retval->value.lval;
- efree(retval);
- return ret;
- }
- return DECLINED;
-}
-
-/* }}} */
-
-int phpdav_mkcol_test_handler(request_rec *r)
-{
- pval *arg;
-
- if (DAV_HANDLER(mkcol_test) == NULL) {
- return DECLINED;
- }
- arg = php3i_string_pval(r->filename);
- return dav_call_handler(DAV_HANDLER(mkcol_test), 1, &arg);
-}
-
-int phpdav_mkcol_create_handler(request_rec *r)
-{
- pval *arg;
-
- if (DAV_HANDLER(mkcol_create) == NULL) {
- return DECLINED;
- }
- arg = php3i_string_pval(r->filename);
- return dav_call_handler(DAV_HANDLER(mkcol_create), 1, &arg);
-}
-
-/* }}} */
-
-/************************* EXTENSION FUNCTIONS *************************/
-
-/* {{{ proto void dav_set_mkcol_handlers(string test, string create)
- Sets the function to test whether a DAV collection exists for MKCOL */
-PHP_FUNCTION(dav_set_mkcol_handlers)
-{
- pval *test, *create;
- DAV_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &test, &create) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- DAV_SET_HANDLER(mkcol_test, test);
- DAV_SET_HANDLER(mkcol_create, create);
- RETVAL_TRUE;
-}
-/* }}} */
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/dav/php3_dav.h b/ext/dav/php3_dav.h
deleted file mode 100644
index b1ab062de1..0000000000
--- a/ext/dav/php3_dav.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Stig Sæther Bakken <ssb@guardian.no> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id */
-
-#ifndef _PHP_DAV_H
-# define _PHP_DAV_H
-
-# if HAVE_MOD_DAV
-
-typedef struct {
- int foo;
- char *mkcol_test_handler;
- char *mkcol_create_handler;
-} phpdav_module;
-
-extern php3_module_entry phpdav_module_entry;
-# define phpdav_module_ptr &phpdav_module_entry
-
-int phpdav_mkcol_test_handler(request_rec *);
-
-PHP_FUNCTION(dav_set_mkcol_handlers);
-
-# else /* !HAVE_MOD_DAV */
-
-# define phpdav_module_ptr NULL
-
-# endif /* HAVE_MOD_DAV */
-
-#define phpext_dav_ptr phpdav_module_ptr
-
-#endif /* _PHP_DAV_H */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/dav/setup.stub b/ext/dav/setup.stub
deleted file mode 100644
index 881144c1ca..0000000000
--- a/ext/dav/setup.stub
+++ /dev/null
@@ -1,2 +0,0 @@
-# $Id$
-# This extension is still very much under construction.
diff --git a/ext/db/Makefile.am b/ext/db/Makefile.am
deleted file mode 100644
index c9dbfa4872..0000000000
--- a/ext/db/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_db.a
-libphpext_db_a_SOURCES=db.c
-
diff --git a/ext/db/config.h.stub b/ext/db/config.h.stub
deleted file mode 100644
index e952d61fac..0000000000
--- a/ext/db/config.h.stub
+++ /dev/null
@@ -1,5 +0,0 @@
-/* Define if you have an ndbm compatible library (-ldbm). */
-#define NDBM 0
-
-/* Define if you have the gdbm library (-lgdbm). */
-#define GDBM 0
diff --git a/ext/db/config.m4 b/ext/db/config.m4
deleted file mode 100644
index a87dbef89d..0000000000
--- a/ext/db/config.m4
+++ /dev/null
@@ -1,53 +0,0 @@
-dnl $Id$
-dnl config.m4 for extension db
-dnl don't forget to call PHP_EXTENSION(db)
-
-divert(1)
-
-# Checks for libraries.
-# Prefer gdbm, Berkeley DB and ndbm/dbm, in that order
-AC_DEFUN(AC_PREFERRED_DB_LIB,[
- AC_CHECK_LIB(gdbm, gdbm_open,[AC_DEFINE(GDBM) DBM_TYPE=gdbm; DBM_LIB=-lgdbm],
- [AC_CHECK_LIB(db, dbm_open,[AC_DEFINE(NDBM) DBM_TYPE=ndbm; DBM_LIB=-ldb],
- [AC_CHECK_LIB(c, dbm_open,[AC_DEFINE(NDBM) DBM_TYPE=ndbm; DBM_LIB=],
- [AC_CHECK_LIB(dbm, dbm_open,[AC_DEFINE(NDBM) DBM_TYPE=ndbm; DBM_LIB=-ldbm],
- [DBM_TYPE=""])])])])
- AC_MSG_CHECKING([preferred dbm library])
- if test "a$DBM_TYPE" = a; then
- AC_MSG_RESULT(none found)
- AC_MSG_WARN(No dbm library found - using built-in flatfile support)
- else
- AC_MSG_RESULT($DBM_TYPE chosen)
- fi
- AC_SUBST(DBM_LIB)
- AC_SUBST(DBM_TYPE)
-])
-
-AC_PREFERRED_DB_LIB
-
-divert(3)
-
-if test "$DBM_LIB" = "-lgdbm"; then
- AC_CHECK_HEADER(gdbm.h, [ GDBM_INCLUDE="" ], [
- AC_MSG_RESULT("Try /usr/local/include/gdbm.h");
- AC_CHECK_HEADER(/usr/local/include/gdbm.h, [ GDBM_INCLUDE="-I/usr/local/include" ],[
- AC_MSG_RESULT("Try /opt/local/include/gdbm.h");
- AC_CHECK_HEADER(/opt/local/include/gdbm.h, [ GDBM_INCLUDE="-I/opt/local/include" ],[
- dnl if in /usr/pkg/include, do not add anything. See above.
- AC_MSG_RESULT("Try /usr/pkg/include/gdbm.h");
- AC_CHECK_HEADER(/usr/pkg/include/gdbm.h, [ GDBM_INCLUDE="" ],[
- AC_MSG_RESULT("Giving up - You need to install gdbm.h somewhere");
- exit
- ])
- ])
- ])
- ])
-fi
-
-if test -n "$DBM_LIB"; then
- INCLUDES="$INCLUDES $GDBM_INCLUDE"
- EXTRA_LIBS="$EXTRA_LIBS $DBM_LIB"
-fi
-
-PHP_EXTENSION(db)
-
diff --git a/ext/db/db.c b/ext/db/db.c
deleted file mode 100644
index dbce69658a..0000000000
--- a/ext/db/db.c
+++ /dev/null
@@ -1,1163 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Jim Winstead <jimw@php.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-#define IS_EXT_MODULE
-#if COMPILE_DL
-#ifdef PHP_31
-# include "../phpdl.h"
-#else
-# ifdef THREAD_SAFE
-# undef THREAD_SAFE
-# endif
-# include "dl/phpdl.h"
-#endif
-#endif
-
-#if 0
-
-#include "php.h"
-#include "php_globals.h"
-#include "safe_mode.h"
-#include "fopen-wrappers.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef PHP_31
-#include "os/nt/flock.h"
-#else
-#if WIN32|WINNT
-#include "win32/flock.h"
-#else
-#include <sys/file.h>
-#endif
-#endif
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#if GDBM
-#include <gdbm.h>
-
-#define DBM_TYPE GDBM_FILE
-#define DBM_MODE_TYPE int
-#define DBM_WRITE_MODE GDBM_WRITER
-#define DBM_CREATE_MODE GDBM_WRCREAT
-#define DBM_NEW_MODE GDBM_NEWDB
-#define DBM_DEFAULT_MODE GDBM_READER
-#define DBM_OPEN(filename, mode) gdbm_open(filename, 512, mode, 0666, 0)
-#define DBM_CLOSE(dbf) gdbm_close(dbf)
-#define DBM_STORE(dbf, key, value, mode) gdbm_store(dbf, key, value, mode)
-#define DBM_FETCH(dbf, key) gdbm_fetch(dbf, key)
-#define DBM_EXISTS(dbf, key) gdbm_exists(dbf, key)
-#define DBM_DELETE(dbf, key) gdbm_delete(dbf, key)
-#define DBM_FIRSTKEY(dbf) gdbm_firstkey(dbf)
-#define DBM_NEXTKEY(dbf, key) gdbm_nextkey(dbf, key)
-
-#define DBM_INSERT GDBM_INSERT
-#define DBM_REPLACE GDBM_REPLACE
-#endif
-
-#if NDBM && !GDBM
-#if BSD2
-#define DB_DBM_HSEARCH 1
-#include <db.h>
-#else
-#include <ndbm.h>
-#endif
-
-#define DBM_TYPE DBM *
-#define DBM_MODE_TYPE int
-#define DBM_WRITE_MODE O_RDWR
-#define DBM_CREATE_MODE O_RDWR | O_APPEND | O_CREAT
-#define DBM_NEW_MODE O_RDWR | O_CREAT | O_TRUNC
-#define DBM_DEFAULT_MODE O_RDONLY
-#define DBM_OPEN(filename, mode) dbm_open(filename, mode, 0666)
-#define DBM_CLOSE(dbf) dbm_close(dbf)
-#define DBM_STORE(dbf, key, value, mode) dbm_store(dbf, key, value, mode)
-#define DBM_FETCH(dbf, key) dbm_fetch(dbf, key)
-#define DBM_EXISTS(dbf, key) _php3_dbm_exists(dbf, key)
-#define DBM_DELETE(dbf, key) dbm_delete(dbf, key)
-#define DBM_FIRSTKEY(dbf) dbm_firstkey(dbf)
-#define DBM_NEXTKEY(dbf, key) dbm_nextkey(dbf)
-
-static int _php3_dbm_exists(DBM *dbf, datum key_datum) {
- datum value_datum;
- int ret;
-
- value_datum = dbm_fetch(dbf, key_datum);
- if (value_datum.dptr)
- ret = 1;
- else
- ret = 0;
- return ret;
-}
-#endif
-
-#if !NDBM && !GDBM
-#define DBM_TYPE FILE *
-
-#define DBM_MODE_TYPE char *
-#define DBM_WRITE_MODE "r+b"
-#define DBM_CREATE_MODE "a+b"
-#define DBM_NEW_MODE "w+b"
-#define DBM_DEFAULT_MODE "r"
-#define DBM_OPEN(filename, mode) fopen(filename, mode)
-#define DBM_CLOSE(dbf) fclose(dbf)
-#define DBM_STORE(dbf, key, value, mode) flatfile_store(dbf, key, value, mode)
-#define DBM_FETCH(dbf, key) flatfile_fetch(dbf, key)
-#define DBM_EXISTS(dbf, key) flatfile_findkey(dbf, key)
-#define DBM_DELETE(dbf, key) flatfile_delete(dbf, key)
-#define DBM_FIRSTKEY(dbf) flatfile_firstkey(dbf)
-#define DBM_NEXTKEY(dbf, key) flatfile_nextkey(dbf)
-
-#define DBM_INSERT 0
-#define DBM_REPLACE 1
-
-typedef struct {
- char *dptr;
- int dsize;
-} datum;
-
-int flatfile_store(FILE *dbf, datum key, datum value, int mode);
-datum flatfile_fetch(FILE *dbf, datum key);
-int flatfile_findkey(FILE *dbf, datum key);
-int flatfile_delete(FILE *dbf, datum key);
-datum flatfile_firstkey(FILE *dbf);
-datum flatfile_nextkey(FILE *dbf);
-
-#endif
-
-#include "php3_db.h"
-#include "ext/standard/php3_string.h"
-
-#if THREAD_SAFE
-DWORD DbmTls;
-static int numthreads=0;
-
-typedef struct dbm_global_struct{
- int le_db;
-}dbm_global_struct;
-
-#define DBM_GLOBAL(a) dbm_globals->a
-#define DBM_TLS_VARS dbm_global_struct *dbm_globals = TlsGetValue(DbmTls);
-
-#else
-static int le_db;
-#define DBM_GLOBAL(a) a
-#define DBM_TLS_VARS
-#endif
-
-/*needed for blocking calls in windows*/
-void *dbm_mutex;
-
-dbm_info *_php3_finddbm(pval *id,HashTable *list)
-{
- list_entry *le;
- dbm_info *info;
- int numitems, i;
- int info_type;
- DBM_TLS_VARS;
-
- if (id->type == IS_STRING) {
- numitems = zend_hash_num_elements(list);
- for (i=1; i<=numitems; i++) {
- if (zend_hash_index_find(list, i, (void **) &le)==FAILURE) {
- continue;
- }
- if (le->type == DBM_GLOBAL(le_db)) {
- info = (dbm_info *)(le->ptr);
- if (!strcmp(info->filename, id->value.str.val)) {
- return (dbm_info *)(le->ptr);
- }
- }
- }
- }
-
- /* didn't find it as a database filename, try as a number */
- convert_to_long(id);
- info = php3_list_find(id->value.lval, &info_type);
- if (info_type != DBM_GLOBAL(le_db))
- return NULL;
- return info;
-}
-
-static char *php3_get_info_db(void)
-{
- static char temp1[128];
- static char temp[256];
-
- temp1[0]='\0';
- temp[0]='\0';
-
-#ifdef DB_VERSION_STRING /* using sleepycat dbm */
- strcat(temp,DB_VERSION_STRING);
-#endif
-
-#if GDBM
- sprintf(temp1,"%s",gdbm_version);
- strcat(temp,temp1);
-#endif
-
-#if NDBM && !GDBM
- strcat(temp,"ndbm support enabled");
-#endif
-
-#if !GDBM && !NDBM
- strcat(temp,"flat file support enabled");
-#endif
-
-#if NFS_HACK
- strcat(temp,"NFS hack in effect");
-#endif
-
- if (!*temp)
- strcat(temp,"No database support");
-
- return temp;
-}
-
-
-PHP_MINFO_FUNCTION(db)
-{
- php_printf(php3_get_info_db());
-}
-
-PHP_FUNCTION(dblist)
-{
- char *str = php3_get_info_db();
- RETURN_STRING(str,1);
-}
-
-
-PHP_FUNCTION(dbmopen) {
- pval *filename, *mode;
- dbm_info *info=NULL;
- int ret;
- DBM_TLS_VARS;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht,2,&filename,&mode)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(filename);
- convert_to_string(mode);
-
- info = _php3_dbmopen(filename->value.str.val, mode->value.str.val);
- if (info) {
- ret = php3_list_insert(info, DBM_GLOBAL(le_db));
- RETURN_LONG(ret);
- } else {
- RETURN_FALSE;
- }
-}
-
-dbm_info *_php3_dbmopen(char *filename, char *mode) {
- dbm_info *info;
- int ret, lock=0;
- char *lockfn = NULL;
- int lockfd = 0;
-
-#if NFS_HACK
- int last_try = 0;
- struct stat sb;
- int retries = 0;
-#endif
-
- DBM_TYPE dbf=NULL;
- DBM_MODE_TYPE imode;
-
- if (filename == NULL) {
- php_error(E_WARNING, "NULL filename passed to _php3_dbmopen()");
- return NULL;
- }
-
- if (PG(safe_mode) && (!_php3_checkuid(filename, 2))) {
- return NULL;
- }
-
- if (_php3_check_open_basedir(filename)) {
- return NULL;
- }
-
- switch (*mode) {
- case 'w':
- imode = DBM_WRITE_MODE;
- lock = 1;
- break;
- case 'c':
- imode = DBM_CREATE_MODE;
- lock = 1;
- break;
- case 'n':
- imode = DBM_NEW_MODE;
- lock = 1;
- break;
- default:
- imode = DBM_DEFAULT_MODE;
- lock = 0;
- break;
- }
-
- if (lock) {
- lockfn = emalloc(strlen(filename) + 5);
- strcpy(lockfn, filename);
- strcat(lockfn, ".lck");
-
-#if NFS_HACK
- while((last_try = stat(lockfn,&sb))==0) {
- retries++;
- sleep(1);
- if (retries>30) break;
- }
- if (last_try!=0) {
- lockfd = open(lockfn,O_RDWR|O_CREAT,0644);
- close(lockfd);
- } else {
- php_error(E_WARNING, "File appears to be locked [%s]\n",lockfn);
- return -1;
- }
-#else /* NFS_HACK */
-
- lockfd = open(lockfn,O_RDWR|O_CREAT,0644);
-
- if (lockfd) {
- flock(lockfd,LOCK_EX);
- close(lockfd);
- } else {
- php_error(E_WARNING, "Unable to establish lock: %s",filename);
- }
-#endif /* else NFS_HACK */
-
- }
-
- dbf = DBM_OPEN(filename, imode);
-
-#if !NDBM && !GDBM
- if (dbf) {
- setvbuf(dbf, NULL, _IONBF, 0);
- }
-#endif
-
- if (dbf) {
- info = (dbm_info *)emalloc(sizeof(dbm_info));
- if (!info) {
- php_error(E_ERROR, "problem allocating memory!");
- return NULL;
- }
-
- info->filename = estrdup(filename);
- info->lockfn = lockfn;
- info->lockfd = lockfd;
- info->dbf = dbf;
-
- return info;
- } else {
-#if GDBM
- php_error(E_WARNING, "dbmopen_gdbm(%s): %d [%s], %d [%s]",filename,gdbm_errno,gdbm_strerror(gdbm_errno),errno,strerror(errno));
- if (gdbm_errno)
- ret = gdbm_errno;
- else if (errno)
- ret = errno;
- else
- ret = -1;
-#else
-#if NDBM
-#if DEBUG
- php_error(E_WARNING, "dbmopen_ndbm(%s): errno = %d [%s]\n",filename,errno,strerror(errno));
-#endif
- if (errno) ret=errno;
- else ret = -1;
-#else
-#if DEBUG
- php_error(E_WARNING, "dbmopen_flatfile(%s): errno = %d [%s]\n",filename,errno,strerror(errno));
-#endif
- if (errno) ret=errno;
- else ret = -1;
-#endif
-#endif
-
-#if NFS_HACK
- if (lockfn) {
- unlink(lockfn);
- }
-#endif
- if (lockfn) efree(lockfn);
- }
-
- return NULL;
-}
-
-PHP_FUNCTION(dbmclose) {
- pval *id;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&id)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(id);
-
- if (php3_list_delete(id->value.lval) == SUCCESS) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-
-int _php3_dbmclose(dbm_info *info) {
- int ret = 0;
- DBM_TYPE dbf;
- int lockfd;
-
- dbf = info->dbf;
-
-#if NFS_HACK
- unlink(info->lockfn);
-#else
- if (info->lockfn) {
- lockfd = open(info->lockfn,O_RDWR,0644);
- flock(lockfd,LOCK_UN);
- close(lockfd);
- }
-#endif
-
- if (dbf)
- DBM_CLOSE(dbf);
-
- /* free the memory used by the dbm_info struct */
- if (info->filename) efree(info->filename);
- if (info->lockfn) efree(info->lockfn);
- efree(info);
-
- return(ret);
-}
-
-/*
- * ret = -1 means that database was opened for read-only
- * ret = 0 success
- * ret = 1 key already exists - nothing done
- */
-PHP_FUNCTION(dbminsert)
-{
- pval *id, *key, *value;
- dbm_info *info;
- int ret;
-
- if (ARG_COUNT(ht)!=3||getParameters(ht,3,&id,&key,&value) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(key);
- convert_to_string(value);
-
- info = _php3_finddbm(id,list);
- if (!info) {
- php_error(E_WARNING, "not a valid database identifier %d", id->value.lval);
- RETURN_FALSE;
- }
-
- ret = _php3_dbminsert(info, key->value.str.val, value->value.str.val);
- RETURN_LONG(ret);
-}
-
-int _php3_dbminsert(dbm_info *info, char *key, char *value) {
- datum key_datum, value_datum;
- int ret;
- DBM_TYPE dbf;
-
- php_stripslashes(key,NULL);
- php_stripslashes(value,NULL);
-
- value_datum.dptr = estrdup(value);
- value_datum.dsize = strlen(value);
-
- key_datum.dptr = estrdup(key);
- key_datum.dsize = strlen(key);
-#if GDBM_FIX
- key_datum.dsize++;
-#endif
-
- dbf = info->dbf;
- if (!dbf) {
- php_error(E_WARNING, "Unable to locate dbm file");
- return 1;
- }
-
- ret = DBM_STORE(dbf, key_datum, value_datum, DBM_INSERT);
-
- /* free the memory */
- efree(key_datum.dptr); efree(value_datum.dptr);
-
- return(ret);
-}
-
-PHP_FUNCTION(dbmreplace)
-{
- pval *id, *key, *value;
- dbm_info *info;
- int ret;
-
- if (ARG_COUNT(ht)!=3||getParameters(ht,3,&id,&key,&value) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(key);
- convert_to_string(value);
-
- info = _php3_finddbm(id,list);
- if (!info) {
- php_error(E_WARNING, "not a valid database identifier %d", id->value.lval);
- RETURN_FALSE;
- }
-
- ret = _php3_dbmreplace(info, key->value.str.val, value->value.str.val);
- RETURN_LONG(ret);
-}
-
-int _php3_dbmreplace(dbm_info *info, char *key, char *value) {
- DBM_TYPE dbf;
- int ret;
- datum key_datum, value_datum;
- PLS_FETCH();
-
- if (PG(magic_quotes_runtime)) {
- php_stripslashes(key,NULL);
- php_stripslashes(value,NULL);
- }
-
- value_datum.dptr = estrdup(value);
- value_datum.dsize = strlen(value);
-
- key_datum.dptr = estrdup(key);
- key_datum.dsize = strlen(key);
-#if GDBM_FIX
- key_datum.dsize++;
-#endif
-
- dbf = info->dbf;
- if (!dbf) {
- php_error(E_WARNING, "Unable to locate dbm file");
- return 1;
- }
-
- ret = DBM_STORE(dbf, key_datum, value_datum, DBM_REPLACE);
-
- /* free the memory */
- efree(key_datum.dptr); efree(value_datum.dptr);
-
- return(ret);
-}
-
-PHP_FUNCTION(dbmfetch)
-{
- pval *id, *key;
- dbm_info *info;
-
- if (ARG_COUNT(ht)!=2||getParameters(ht,2,&id,&key)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(key);
-
- info = _php3_finddbm(id,list);
- if (!info) {
- php_error(E_WARNING, "not a valid database identifier %d", id->value.lval);
- RETURN_FALSE;
- }
-
- return_value->value.str.val = _php3_dbmfetch(info, key->value.str.val);
- if (return_value->value.str.val) {
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
- } else {
- RETURN_FALSE;
- }
-}
-
-char *_php3_dbmfetch(dbm_info *info, char *key) {
- datum key_datum, value_datum;
- char *ret;
- DBM_TYPE dbf;
- PLS_FETCH();
-
- key_datum.dptr = key;
- key_datum.dsize = strlen(key);
-#if GDBM_FIX
- key_datum.dsize++;
-#endif
- value_datum.dptr = NULL;
- value_datum.dsize = 0;
-
- dbf = info->dbf;
- if (!dbf) {
- php_error(E_WARNING, "Unable to locate dbm file");
- return(NULL);
- }
-
- value_datum = DBM_FETCH(dbf, key_datum);
-
- if (value_datum.dptr) {
- ret = (char *)emalloc(sizeof(char) * value_datum.dsize + 1);
- strncpy(ret, value_datum.dptr, value_datum.dsize);
- ret[value_datum.dsize] = '\0';
-
-#if GDBM
-/* all but NDBM use malloc to allocate the content blocks, so we need to free it */
- free(value_datum.dptr);
-#else
-# if !NDBM
- efree(value_datum.dptr);
-# endif
-#endif
- }
- else
- ret = NULL;
-
- if (ret && PG(magic_quotes_runtime)) {
- ret = php_addslashes(ret, value_datum.dsize, NULL, 1);
- }
- return(ret);
-}
-
-
-PHP_FUNCTION(dbmexists)
-{
- pval *id, *key;
- dbm_info *info;
- int ret;
-
- if (ARG_COUNT(ht)!=2||getParameters(ht,2,&id,&key)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(key);
-
- info = _php3_finddbm(id,list);
- if (!info) {
- php_error(E_WARNING, "not a valid database identifier %d", id->value.lval);
- RETURN_FALSE;
- }
-
- ret = _php3_dbmexists(info, key->value.str.val);
- RETURN_LONG(ret);
-}
-
-int _php3_dbmexists(dbm_info *info, char *key) {
- datum key_datum;
- int ret;
- DBM_TYPE dbf;
-
- key_datum.dptr = key;
- key_datum.dsize = strlen(key);
-#if GDBM_FIX
- key_datum.dsize++;
-#endif
-
- dbf = info->dbf;
- if (!dbf) {
- php_error(E_WARNING, "Unable to locate dbm file");
- return(0);
- }
-
- ret = DBM_EXISTS(dbf, key_datum);
-
- return(ret);
-}
-
-PHP_FUNCTION(dbmdelete)
-{
- pval *id, *key;
- dbm_info *info;
- int ret;
-
- if (ARG_COUNT(ht)!=2||getParameters(ht,2,&id,&key)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(key);
-
- info = _php3_finddbm(id,list);
- if (!info) {
- php_error(E_WARNING, "not a valid database identifier %d", id->value.lval);
- RETURN_FALSE;
- }
-
- ret = _php3_dbmdelete(info, key->value.str.val);
- RETURN_LONG(ret);
-}
-
-int _php3_dbmdelete(dbm_info *info, char *key) {
- datum key_datum;
- int ret;
- DBM_TYPE dbf;
-
- key_datum.dptr = key;
- key_datum.dsize = strlen(key);
-#if GDBM_FIX
- key_datum.dsize++;
-#endif
-
- dbf = info->dbf;
- if (!dbf) {
- php_error(E_WARNING, "Unable to locate dbm file");
- return(0);
- }
-
- ret = DBM_DELETE(dbf, key_datum);
- return(ret);
-}
-
-PHP_FUNCTION(dbmfirstkey)
-{
- pval *id;
- dbm_info *info;
- char *ret;
-
- if (ARG_COUNT(ht)!=1||getParameters(ht,1,&id)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- info = _php3_finddbm(id,list);
- if (!info) {
- php_error(E_WARNING, "not a valid database identifier %d", id->value.lval);
- RETURN_FALSE;
- }
-
- ret = _php3_dbmfirstkey(info);
- if (!ret) {
- RETURN_FALSE;
- } else {
- return_value->value.str.val = ret;
- return_value->value.str.len = strlen(ret);
- return_value->type = IS_STRING;
- }
-}
-
-char *_php3_dbmfirstkey(dbm_info *info) {
- datum ret_datum;
- char *ret;
- DBM_TYPE dbf;
-
- dbf = info->dbf;
- if (!dbf) {
- php_error(E_WARNING, "Unable to locate dbm file");
- return(NULL);
- }
-
- /* explicitly zero-out ret_datum */
- ret_datum.dptr = NULL;
- ret_datum.dsize = 0;
-
- ret_datum = DBM_FIRSTKEY(dbf);
-
- if (!ret_datum.dptr)
- return NULL;
-
- ret = (char *)emalloc((ret_datum.dsize + 1) * sizeof(char));
- strncpy(ret, ret_datum.dptr, ret_datum.dsize);
- ret[ret_datum.dsize] = '\0';
-
-#if !NDBM & !GDBM
- efree(ret_datum.dptr);
-#endif
-
- return (ret);
-}
-
-PHP_FUNCTION(dbmnextkey)
-{
- pval *id, *key;
- dbm_info *info;
- char *ret;
-
- if (ARG_COUNT(ht)!=2||getParameters(ht,2,&id,&key)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(key);
-
- info = _php3_finddbm(id,list);
- if (!info) {
- php_error(E_WARNING, "not a valid database identifier %d", id->value.lval);
- RETURN_FALSE;
- }
-
- ret = _php3_dbmnextkey(info, key->value.str.val);
- if (!ret) {
- RETURN_FALSE;
- } else {
- return_value->value.str.val = ret;
- return_value->value.str.len = strlen(ret);
- return_value->type = IS_STRING;
- }
-}
-
-char *_php3_dbmnextkey(dbm_info *info, char *key) {
- datum key_datum, ret_datum;
- char *ret;
- DBM_TYPE dbf;
- PLS_FETCH();
-
- key_datum.dptr = key;
- key_datum.dsize = strlen(key);
-#if GDBM_FIX
- key_datum.dsize++;
-#endif
-
- dbf = info->dbf;
- if (!dbf) {
- php_error(E_WARNING, "Unable to locate dbm file");
- return(NULL);
- }
-
- /* explicitly zero-out ret_datum */
- ret_datum.dptr = NULL;
- ret_datum.dsize = 0;
-
- ret_datum = DBM_NEXTKEY(dbf, key_datum);
-
- if (ret_datum.dptr) {
- ret = (char *)emalloc(sizeof(char) * ret_datum.dsize + 1);
- strncpy(ret, ret_datum.dptr, ret_datum.dsize);
- ret[ret_datum.dsize] = '\0';
-#if GDBM
-/* GDBM uses malloc to allocate the value_datum block, so we need to free it */
- free(ret_datum.dptr);
-#else
-# if !NDBM
- efree(ret_datum.dptr);
-# endif
-#endif
- }
- else ret=NULL;
-
- if (ret && PG(magic_quotes_runtime)) {
- ret = php_addslashes(ret, ret_datum.dsize, NULL, 1);
- }
- return(ret);
-}
-
-
-#if !GDBM && !NDBM
-static long CurrentFlatFilePos = 0L;
-
-int flatfile_store(FILE *dbf, datum key_datum, datum value_datum, int mode) {
- int ret;
-
- if (mode == DBM_INSERT) {
- if (flatfile_findkey(dbf, key_datum)) {
- return 1;
- }
- fseek(dbf,0L,SEEK_END);
- fprintf(dbf,"%d\n",key_datum.dsize);
- fflush(dbf);
- ret = write(fileno(dbf),key_datum.dptr,key_datum.dsize);
- fprintf(dbf,"%d\n",value_datum.dsize);
- fflush(dbf);
- ret = write(fileno(dbf),value_datum.dptr,value_datum.dsize);
- } else { /* DBM_REPLACE */
- flatfile_delete(dbf,key_datum);
- fprintf(dbf,"%d\n",key_datum.dsize);
- fflush(dbf);
- ret = write(fileno(dbf),key_datum.dptr,key_datum.dsize);
- fprintf(dbf,"%d\n",value_datum.dsize);
- ret = write(fileno(dbf),value_datum.dptr,value_datum.dsize);
- }
-
- if (ret>0)
- ret=0;
- return ret;
-}
-
-datum flatfile_fetch(FILE *dbf, datum key_datum) {
- datum value_datum = {NULL, 0};
- int num=0, buf_size=1024;
- char *buf;
-
- if (flatfile_findkey(dbf,key_datum)) {
- buf = emalloc((buf_size+1) * sizeof(char));
- if (fgets(buf, 15, dbf)) {
- num = atoi(buf);
- if (num > buf_size) {
- buf_size+=num;
- buf = emalloc((buf_size+1)*sizeof(char));
- }
- read(fileno(dbf),buf,num);
- value_datum.dptr = buf;
- value_datum.dsize = num;
- }
- }
- return value_datum;
-}
-
-int flatfile_delete(FILE *dbf, datum key_datum) {
- char *key = key_datum.dptr;
- int size = key_datum.dsize;
-
- char *buf;
- int num, buf_size = 1024;
- long pos;
-
- rewind(dbf);
-
- buf = emalloc((buf_size + 1)*sizeof(char));
- while(!feof(dbf)) {
- /* read in the length of the key name */
- if (!fgets(buf, 15, dbf))
- break;
- num = atoi(buf);
- if (num > buf_size) {
- buf_size += num;
- if (buf) efree(buf);
- buf = emalloc((buf_size+1)*sizeof(char));
- }
- pos = ftell(dbf);
-
- /* read in the key name */
- num = fread(buf, sizeof(char), num, dbf);
- if (num<0) break;
- *(buf+num) = '\0';
-
- if (size == num && !memcmp(buf, key, size)) {
- fseek(dbf, pos, SEEK_SET);
- fputc(0, dbf);
- fflush(dbf);
- fseek(dbf, 0L, SEEK_END);
- if (buf) efree(buf);
- return SUCCESS;
- }
-
- /* read in the length of the value */
- if (!fgets(buf,15,dbf))
- break;
- num = atoi(buf);
- if (num > buf_size) {
- buf_size+=num;
- if (buf) efree(buf);
- buf = emalloc((buf_size+1)*sizeof(char));
- }
- /* read in the value */
- num = fread(buf, sizeof(char), num, dbf);
- if (num<0)
- break;
- }
- if (buf) efree(buf);
- return FAILURE;
-}
-
-int flatfile_findkey(FILE *dbf, datum key_datum) {
- char *buf = NULL;
- int num;
- int buf_size=1024;
- int ret=0;
- void *key = key_datum.dptr;
- int size = key_datum.dsize;
-
- rewind(dbf);
- buf = emalloc((buf_size+1)*sizeof(char));
- while (!feof(dbf)) {
- if (!fgets(buf,15,dbf)) break;
- num = atoi(buf);
- if (num > buf_size) {
- if (buf) efree(buf);
- buf_size+=num;
- buf = emalloc((buf_size+1)*sizeof(char));
- }
- num = fread(buf, sizeof(char), num, dbf);
- if (num<0) break;
- *(buf+num) = '\0';
- if (size == num) {
- if (!memcmp(buf,key,size)) {
- ret = 1;
- break;
- }
- }
- if (!fgets(buf,15,dbf))
- break;
- num = atoi(buf);
- if (num > buf_size) {
- if (buf) efree(buf);
- buf_size+=num;
- buf = emalloc((buf_size+1)*sizeof(char));
- }
- num = fread(buf, sizeof(char), num, dbf);
- if (num<0) break;
- *(buf+num) = '\0';
- }
- if (buf) efree(buf);
- return(ret);
-}
-
-datum flatfile_firstkey(FILE *dbf) {
- datum buf;
- int num;
- int buf_size=1024;
-
- rewind(dbf);
- buf.dptr = emalloc((buf_size+1)*sizeof(char));
- while(!feof(dbf)) {
- if (!fgets(buf.dptr,15,dbf)) break;
- num = atoi(buf.dptr);
- if (num > buf_size) {
- buf_size+=num;
- if (buf.dptr) efree(buf.dptr);
- buf.dptr = emalloc((buf_size+1)*sizeof(char));
- }
- num=read(fileno(dbf),buf.dptr,num);
- if (num<0) break;
- buf.dsize = num;
- if (*(buf.dptr)!=0) {
- CurrentFlatFilePos = ftell(dbf);
- return(buf);
- }
- if (!fgets(buf.dptr,15,dbf)) break;
- num = atoi(buf.dptr);
- if (num > buf_size) {
- buf_size+=num;
- if (buf.dptr) efree(buf.dptr);
- buf.dptr = emalloc((buf_size+1)*sizeof(char));
- }
- num=read(fileno(dbf),buf.dptr,num);
- if (num<0) break;
- }
- if (buf.dptr) efree(buf.dptr);
- buf.dptr = NULL;
- return(buf);
-}
-
-datum flatfile_nextkey(FILE *dbf) {
- datum buf;
- int num;
- int buf_size=1024;
-
- fseek(dbf,CurrentFlatFilePos,SEEK_SET);
- buf.dptr = emalloc((buf_size+1)*sizeof(char));
- while(!feof(dbf)) {
- if (!fgets(buf.dptr,15,dbf)) break;
- num = atoi(buf.dptr);
- if (num > buf_size) {
- buf_size+=num;
- if (buf.dptr) efree(buf.dptr);
- buf.dptr = emalloc((buf_size+1)*sizeof(char));
- }
- num=read(fileno(dbf),buf.dptr,num);
- if (num<0) break;
- if (!fgets(buf.dptr,15,dbf)) break;
- num = atoi(buf.dptr);
- if (num > buf_size) {
- buf_size+=num;
- if (buf.dptr) efree(buf.dptr);
- buf.dptr = emalloc((buf_size+1)*sizeof(char));
- }
- num=read(fileno(dbf),buf.dptr,num);
- if (num<0) break;
- buf.dsize = num;
- if (*(buf.dptr)!=0) {
- CurrentFlatFilePos = ftell(dbf);
- return(buf);
- }
- }
- if (buf.dptr) efree(buf.dptr);
- buf.dptr = NULL;
- return(buf);
-}
-#endif
-
-
-PHP_MINIT_FUNCTION(db)
-{
-#if defined(THREAD_SAFE)
- dbm_global_struct *dbm_globals;
- PHP3_MUTEX_ALLOC(dbm_mutex);
- PHP3_MUTEX_LOCK(dbm_mutex);
- numthreads++;
- if (numthreads==1){
- if (!PHP3_TLS_PROC_STARTUP(DbmTls)){
- PHP3_MUTEX_UNLOCK(dbm_mutex);
- PHP3_MUTEX_FREE(dbm_mutex);
- return FAILURE;
- }
- }
- PHP3_MUTEX_UNLOCK(dbm_mutex);
- if(!PHP3_TLS_THREAD_INIT(DbmTls,dbm_globals,dbm_global_struct)){
- PHP3_MUTEX_FREE(dbm_mutex);
- return FAILURE;
- }
-#endif
-
- DBM_GLOBAL(le_db) = register_list_destructors(_php3_dbmclose,NULL);
- return SUCCESS;
-}
-
-static PHP_MSHUTDOWN_FUNCTION(db)
-{
- DBM_TLS_VARS;
-#ifdef THREAD_SAFE
- PHP3_TLS_THREAD_FREE(dbm_globals);
- PHP3_MUTEX_LOCK(dbm_mutex);
- numthreads--;
- if (numthreads<1) {
- PHP3_TLS_PROC_SHUTDOWN(DbmTls);
- PHP3_MUTEX_UNLOCK(dbm_mutex);
- PHP3_MUTEX_FREE(dbm_mutex);
- return SUCCESS;
- }
- PHP3_MUTEX_UNLOCK(dbm_mutex);
-#endif
- return SUCCESS;
-}
-
-PHP_RINIT_FUNCTION(db)
-{
-#if !GDBM && !NDBM
- CurrentFlatFilePos = 0L;
-#endif
- return SUCCESS;
-}
-
-
-function_entry dbm_functions[] = {
- PHP_FE(dblist, NULL)
- PHP_FE(dbmopen, NULL)
- PHP_FE(dbmclose, NULL)
- PHP_FE(dbminsert, NULL)
- PHP_FE(dbmfetch, NULL)
- PHP_FE(dbmreplace, NULL)
- PHP_FE(dbmexists, NULL)
- PHP_FE(dbmdelete, NULL)
- PHP_FE(dbmfirstkey, NULL)
- PHP_FE(dbmnextkey, NULL)
- {NULL,NULL,NULL}
-};
-
-php3_module_entry dbm_module_entry = {
- "DBM", dbm_functions, PHP_MINIT(db), PHP_MSHUTDOWN(db), PHP_RINIT(db), NULL, PHP_MINFO(db), STANDARD_MODULE_PROPERTIES
-};
-
-#if COMPILE_DL
-DLEXPORT php3_module_entry *get_module(void) { return &dbm_module_entry; }
-#endif
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/db/php3_db.h b/ext/db/php3_db.h
deleted file mode 100644
index 17069e6bcd..0000000000
--- a/ext/db/php3_db.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Jim Winstead <jimw@php.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-
-#ifndef _PHP3_DB_H
-#define _PHP3_DB_H
-
-
-#ifndef DLEXPORT
-#define DLEXPORT
-#endif
-
-
-extern php3_module_entry dbm_module_entry;
-#define phpext_db_ptr &dbm_module_entry
-
-
-
-typedef struct dbm_info {
- char *filename;
- char *lockfn;
- int lockfd;
- void *dbf;
-} dbm_info;
-
-/*
- we're not going to bother with flatfile on win32
- because the dbm module will be external, and we
- do not want flatfile compiled staticly
-*/
-#if defined(MSVC5) && !defined(COMPILE_DL)
-#undef phpext_db_ptr
-#define phpext_db_ptr NULL
-#endif
-
-dbm_info *_php3_finddbm(pval *id,HashTable *list);
-int _php3_dbmclose(dbm_info *info);
-dbm_info *_php3_dbmopen(char *filename, char *mode);
-int _php3_dbminsert(dbm_info *info, char *key, char *value);
-char *_php3_dbmfetch(dbm_info *info, char *key);
-int _php3_dbmreplace(dbm_info *info, char *key, char *value);
-int _php3_dbmexists(dbm_info *info, char *key);
-int _php3_dbmdelete(dbm_info *info, char *key);
-char *_php3_dbmfirstkey(dbm_info *info);
-char *_php3_dbmnextkey(dbm_info *info, char *key);
-
-/* db file functions */
-PHP_MINIT_FUNCTION(db);
-PHP_RINIT_FUNCTION(db);
-PHP_MINFO_FUNCTION(db);
-
-PHP_FUNCTION(dblist);
-PHP_FUNCTION(dbmopen);
-PHP_FUNCTION(dbmclose);
-PHP_FUNCTION(dbminsert);
-PHP_FUNCTION(dbmfetch);
-PHP_FUNCTION(dbmreplace);
-PHP_FUNCTION(dbmexists);
-PHP_FUNCTION(dbmdelete);
-PHP_FUNCTION(dbmfirstkey);
-PHP_FUNCTION(dbmnextkey);
-
-#undef phpext_db_ptr
-#define phpext_db_ptr NULL
-
-#endif /* _PHP3_DB_H */
diff --git a/ext/dba/Makefile.am b/ext/dba/Makefile.am
deleted file mode 100644
index b609be3bf3..0000000000
--- a/ext/dba/Makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_dba.a
-libphpext_dba_a_SOURCES=dba.c dba_cdb.c dba_db2.c dba_dbm.c dba_gdbm.c \
- dba_ndbm.c
-
diff --git a/ext/dba/config.h.stub b/ext/dba/config.h.stub
deleted file mode 100644
index f65ae9b7fa..0000000000
--- a/ext/dba/config.h.stub
+++ /dev/null
@@ -1,17 +0,0 @@
-/* define if you want to use the dba extension */
-
-#define NDBM_DB1_NDBM_H 0
-#define NDBM_NDBM_H 0
-#define DB2_DB2_DB_H 0
-#define DB2_DB_DB2_H 0
-#define DB2_DB_H 0
-#define DB2_DB2_H 0
-#define HAVE_DBA 0
-#define DBA_GDBM 0
-#define DBA_NDBM 0
-#define DBA_DBOPEN 0
-#define DBA_DB2 0
-#define DBA_DBM 0
-#define DBA_CDB 0
-
-
diff --git a/ext/dba/config.m4 b/ext/dba/config.m4
deleted file mode 100644
index c3e9b60aa0..0000000000
--- a/ext/dba/config.m4
+++ /dev/null
@@ -1,210 +0,0 @@
-dnl $Id$
-dnl config.m4 for extension dba
-dnl don't forget to call PHP_EXTENSION(dba)
-
-AC_DEFUN(AC_TEMP_LDFLAGS,[
- old_LDFLAGS="$LDFLAGS"
- LDFLAGS="$1 $LDFLAGS"
- $2
- LDFLAGS="$old_LDFLAGS"
-])
-
-
-dnl Assign INCLUDE/LFLAGS from PREFIX
-AC_DEFUN(AC_DBA_STD_ASSIGN,[
- if test "$THIS_PREFIX" != "" -a "$THIS_PREFIX" != "/usr"; then
- THIS_INCLUDE="$THIS_PREFIX/include"
- THIS_LFLAGS="$THIS_PREFIX/lib"
- fi
-])
-
-dnl Standard check
-AC_DEFUN(AC_DBA_STD_CHECK,[
- THIS_RESULT="yes"
- if test "$THIS_PREFIX" != "/usr"; then
- if test "$THIS_INCLUDE" = "" ; then
- AC_MSG_ERROR(cannot find necessary header file(s))
- elif test "$THIS_LIBS" = "" ; then
- AC_MSG_ERROR(cannot find necessary library)
- fi
- fi
-])
-
-dnl Attach THIS_x to DBA_x
-AC_DEFUN(AC_DBA_STD_ATTACH,[
- AC_ADD_INCLUDE($THIS_INCLUDE)
- AC_ADD_LIBRARY_WITH_PATH($THIS_LIBS, $THIS_LFLAGS)
-
- THIS_INCLUDE=""
- THIS_LIBS=""
- THIS_LFLAGS=""
- THIS_PREFIX=""
-])
-
-dnl Print the result message
-AC_DEFUN(AC_DBA_STD_RESULT,[
- if test "$THIS_RESULT" = "yes"; then
- HAVE_DBA=1
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
- THIS_RESULT=""
-])
-
-
-
-AC_ARG_WITH(gdbm,
-[ --with-gdbm[=DIR] Include GDBM support],[
- if test "$withval" != "no"; then
- for i in /usr/local /usr $withval; do
- if test -f "$i/include/gdbm.h"; then
- THIS_PREFIX="$i"
- fi
- done
-
- unset ac_cv_lib_gdbm_gdbm_open
- AC_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[
- AC_CHECK_LIB(gdbm, gdbm_open, [AC_DEFINE(DBA_GDBM, 1) THIS_LIBS="gdbm"])
- ])
-
- AC_DBA_STD_ASSIGN
- AC_DBA_STD_CHECK
- AC_DBA_STD_ATTACH
- fi
-])
-AC_MSG_CHECKING(for GDBM support)
-AC_DBA_STD_RESULT
-
-AC_ARG_WITH(ndbm,
-[ --with-ndbm[=DIR] Include NDBM support],[
- if test "$withval" != "no"; then
- for i in /usr/local /usr $withval; do
- if test -f "$i/include/db1/ndbm.h" ; then
- THIS_PREFIX="$i"
- NDBM_EXTRA="NDBM_DB1_NDBM_H"
- elif test -f "$i/include/ndbm.h" ; then
- THIS_PREFIX="$i"
- NDBM_EXTRA="NDBM_NDBM_H"
- fi
- done
-
- if test "$NDBM_EXTRA" != ""; then
- eval "AC_DEFINE($NDBM_EXTRA, 1)"
- fi
-
- for LIB in db1 ndbm c; do
- AC_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[
- AC_CHECK_LIB($LIB, dbm_open, [AC_DEFINE(DBA_NDBM,1) THIS_LIBS="$LIB"])
- ])
- done
-
- AC_DBA_STD_ASSIGN
- AC_DBA_STD_CHECK
- AC_DBA_STD_ATTACH
- fi
-])
-AC_MSG_CHECKING(for NDBM support)
-AC_DBA_STD_RESULT
-
-AC_ARG_WITH(db2,
-[ --with-db2[=DIR] Include DB2 support],[
- if test "$withval" != "no"; then
- for i in /usr/local /usr /usr/BerkeleyDB $withval; do
- if test -f "$i/db2/db.h"; then
- THIS_PREFIX="$i"
- DB2_EXTRA="db2"
- elif test -f "$i/include/db2/db.h"; then
- THIS_PREFIX="$i"
- DB2_EXTRA="DB2_DB2_DB_H"
- elif test -f "$i/include/db/db2.h"; then
- THIS_PREFIX="$i"
- DB2_EXTRA="DB2_DB_DB2_H"
- elif test -f "$i/include/db2.h"; then
- THIS_PREFIX="$i"
- DB2_EXTRA="DB2_DB2_H"
- elif test -f "$i/include/db.h" ; then
- THIS_PREFIX="$i"
- DB2_EXTRA="DB2_DB_H"
- fi
- done
-
- if test "$DB2_EXTRA" = "db2" ; then
- DBA_INCLUDE="$DBA_INCLUDE -I$THIS_PREFIX/db2"
- DB2_EXTRA="DB2_DB_H"
- fi
-
- if test "$DB2_EXTRA" != ""; then
- eval "AC_DEFINE($DB2_EXTRA, 1)"
- fi
-
- for LIB in db db2 c; do
- AC_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[
- AC_CHECK_LIB($LIB, db_appinit, [AC_DEFINE(DBA_DB2,1) THIS_LIBS="$LIB"])
- ])
- done
-
- AC_DBA_STD_ASSIGN
- AC_DBA_STD_CHECK
- AC_DBA_STD_ATTACH
- fi
-])
-AC_MSG_CHECKING(for DB2 support)
-AC_DBA_STD_RESULT
-
-AC_ARG_WITH(dbm,
-[ --with-dbm[=DIR] Include DBM support],[
- if test "$withval" != "no"; then
- for i in /usr/local /usr $withval; do
- if test -f "$i/include/dbm.h" ; then
- THIS_PREFIX="$i"
- fi
- done
-
- for LIB in db1 dbm c; do
- AC_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[
- AC_CHECK_LIB($LIB, dbminit, [AC_DEFINE(DBA_DBM,1) THIS_LIBS="$LIB"])
- ])
- done
-
- AC_DBA_STD_ASSIGN
- AC_DBA_STD_CHECK
- AC_DBA_STD_ATTACH
- fi
-])
-AC_MSG_CHECKING(for DBM support)
-AC_DBA_STD_RESULT
-
-AC_ARG_WITH(cdb,
-[ --with-cdb[=DIR] Include CDB support],[
- if test "$withval" != "no"; then
- for i in /usr/local /usr $withval; do
- if test -f "$i/include/cdb.h" ; then
- THIS_PREFIX="$i"
- fi
- done
-
- for LIB in cdb c; do
- AC_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[
- AC_CHECK_LIB($LIB, cdb_bread, [AC_DEFINE(DBA_CDB,1) THIS_LIBS="$LIB"])
- ])
- done
-
- AC_DBA_STD_ASSIGN
- AC_DBA_STD_CHECK
- AC_DBA_STD_ATTACH
- fi
-])
-AC_MSG_CHECKING(for CDB support)
-AC_DBA_STD_RESULT
-
-AC_MSG_CHECKING(whether to enable DBA interface)
-if test "$HAVE_DBA" = "1"; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_DBA, 1)
- PHP_EXTENSION(dba)
-else
- AC_MSG_RESULT(no)
- AC_DEFINE(HAVE_DBA, 0)
-fi
-
diff --git a/ext/dba/dba.c b/ext/dba/dba.c
deleted file mode 100644
index d0b5a183fb..0000000000
--- a/ext/dba/dba.c
+++ /dev/null
@@ -1,479 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <sas@schell.de> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-
-#if HAVE_DBA
-
-#include "php3_dba.h"
-
-#include "php3_gdbm.h"
-#include "php3_ndbm.h"
-#include "php3_dbm.h"
-#include "php3_cdb.h"
-#include "php3_db2.h"
-
-function_entry dba_functions[] = {
- PHP_FE(dba_open, NULL)
- PHP_FE(dba_popen, NULL)
- PHP_FE(dba_close, NULL)
- PHP_FE(dba_delete, NULL)
- PHP_FE(dba_exists, NULL)
- PHP_FE(dba_fetch, NULL)
- PHP_FE(dba_insert, NULL)
- PHP_FE(dba_replace, NULL)
- PHP_FE(dba_firstkey, NULL)
- PHP_FE(dba_nextkey, NULL)
- PHP_FE(dba_optimize, NULL)
- PHP_FE(dba_sync, NULL)
- {NULL,NULL,NULL}
-};
-
-static PHP_MINIT_FUNCTION(dba);
-static PHP_MSHUTDOWN_FUNCTION(dba);
-static PHP_MINFO_FUNCTION(dba);
-
-php3_module_entry dba_module_entry = {
- "DataBase API", dba_functions,
- PHP_MINIT(dba),
- PHP_MSHUTDOWN(dba),
- NULL, NULL,
- PHP_MINFO(dba),
- STANDARD_MODULE_PROPERTIES
-};
-
-typedef struct dba_handler {
- char *name;
- int (*open)(dba_info *);
- void (*close)(dba_info *);
- char* (*fetch)(dba_info *, char *, int, int *);
- int (*update)(dba_info *, char *, int, char *, int, int);
- int (*exists)(dba_info *, char *, int);
- int (*delete)(dba_info *, char *, int);
- char* (*firstkey)(dba_info *, int *);
- char* (*nextkey)(dba_info *, int *);
- int (*optimize)(dba_info *);
- int (*sync)(dba_info *);
-} dba_handler;
-
-/* {{{ macromania */
-
-#define DBA_ID_PARS \
- pval **id; \
- dba_info *info = NULL; \
- int type, ac = ARG_COUNT(ht)
-
-/* these are used to get the standard arguments */
-
-#define DBA_GET1 \
- if(ac != 1 || getParametersEx(ac, &id) != SUCCESS) { \
- WRONG_PARAM_COUNT; \
- }
-
-#define DBA_GET2 \
- pval **key; \
- if(ac != 2 || getParametersEx(ac, &key, &id) != SUCCESS) { \
- WRONG_PARAM_COUNT; \
- } \
- convert_to_string_ex(key)
-
-#define DBA_IF_NOT_CORRECT_TYPE(link_id) \
- info = php3_list_find(link_id, &type); \
- if(!info || (type != GLOBAL(le_db) && type != GLOBAL(le_pdb)))
-
-#define DBA_ID_GET \
- convert_to_long_ex(id); \
- DBA_IF_NOT_CORRECT_TYPE((*id)->value.lval) { \
- php_error(E_WARNING, "Unable to find DBA identifier %d", \
- (*id)->value.lval); \
- RETURN_FALSE; \
- }
-
-#define DBA_ID_GET1 DBA_ID_PARS; DBA_GET1; DBA_ID_GET
-#define DBA_ID_GET2 DBA_ID_PARS; DBA_GET2; DBA_ID_GET
-
-/* a DBA handler must have specific routines */
-
-#define DBA_HND(x) \
-{\
- #x, dba_open_##x, dba_close_##x, dba_fetch_##x, dba_update_##x, \
- dba_exists_##x, dba_delete_##x, dba_firstkey_##x, dba_nextkey_##x, \
- dba_optimize_##x, dba_sync_##x \
-},
-
-/* check whether the user has write access */
-#define DBA_WRITE_CHECK \
- if(info->mode != DBA_WRITER && info->mode != DBA_TRUNC && info->mode != DBA_CREAT) { \
- php_error(E_WARNING, "you cannot perform a modification to a database without proper access"); \
- RETURN_FALSE; \
- }
-
-#define GLOBAL(a) a
-
-/* }}} */
-
-/* {{{ globals */
-
-static dba_handler handler[] = {
-#if DBA_GDBM
- DBA_HND(gdbm)
-#endif
-#if DBA_DBM
- DBA_HND(dbm)
-#endif
-#if DBA_NDBM
- DBA_HND(ndbm)
-#endif
-#if DBA_CDB
- DBA_HND(cdb)
-#endif
-#if DBA_DB2
- DBA_HND(db2)
-#endif
- { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
-};
-
-static int le_db;
-static int le_pdb;
-static HashTable ht_keys;
-/* }}} */
-
-/* {{{ helper routines */
- /* {{{ dba_close */
-
-static void dba_close(dba_info *info)
-{
- if(info->hnd) info->hnd->close(info);
- if(info->path) free(info->path);
- free(info);
-}
-/* }}} */
- /* {{{ php3_minit_dba */
-
-static PHP_MINIT_FUNCTION(dba)
-{
- zend_hash_init(&ht_keys, 0, NULL, NULL, 1);
- GLOBAL(le_db) = register_list_destructors(dba_close, NULL);
- GLOBAL(le_pdb) = register_list_destructors(NULL, dba_close);
- return SUCCESS;
-}
-/* }}} */
- /* {{{ php3_mshutdown_dba */
-
-static PHP_MSHUTDOWN_FUNCTION(dba)
-{
- zend_hash_destroy(&ht_keys);
- return SUCCESS;
-}
-/* }}} */
- /* {{{ php3_info_dba */
-
-static PHP_MINFO_FUNCTION(dba)
-{
- dba_handler *hptr;
-
- PUTS("V1 ($Id$)");
- for(hptr = handler; hptr->name; hptr++) {
- PUTS(" ");
- PUTS(hptr->name);
- }
-}
-/* }}} */
- /* {{{ _php3_dba_update */
-
-static void _php3_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode)
-{
- DBA_ID_PARS;
- pval **val, **key;
-
- if(ac != 3 || getParametersEx(ac, &key, &val, &id) != SUCCESS) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string_ex(key);
- convert_to_string_ex(val);
- DBA_ID_GET;
-
- DBA_WRITE_CHECK;
-
- if(info->hnd->update(info, VALLEN(key), VALLEN(val), mode) == SUCCESS)
- RETURN_TRUE;
- RETURN_FALSE;
-}
-/* }}} */
- /* {{{ _php3_dba_open */
-
-#define FREENOW if(args) efree(args); if(key) efree(key)
-
-static void _php3_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
-{
- pval ***args = (pval ***) NULL;
- int ac = ARG_COUNT(ht);
- dba_mode_t modenr;
- dba_info *info;
- dba_handler *hptr;
- char *key = NULL;
- int keylen = 0;
- int listid;
- int i;
-
- if(ac < 3) {
- WRONG_PARAM_COUNT;
- }
-
- /* we pass additional args to the respective handler */
- args = emalloc(ac * sizeof(pval *));
- if(getParametersArrayEx(ac, args) != SUCCESS) {
- FREENOW;
- WRONG_PARAM_COUNT;
- }
-
- /* we only take string arguments */
- for(i = 0; i < ac; i++) {
- convert_to_string_ex(args[i]);
- keylen += (*args[i])->value.str.len;
- }
-
- if(persistent) {
- /* calculate hash */
- key = emalloc(keylen);
- keylen = 0;
-
- for(i = 0; i < ac; i++) {
- memcpy(key+keylen,(*args[i])->value.str.val,(*args[i])->value.str.len);
- keylen += (*args[i])->value.str.len;
- }
-
- if(zend_hash_find(&ht_keys, key, keylen, (void **) &info) == SUCCESS) {
- FREENOW;
- RETURN_LONG(php3_list_insert(info, GLOBAL(le_pdb)));
- }
- }
-
- for(hptr = handler; hptr->name &&
- strcasecmp(hptr->name, (*args[2])->value.str.val); hptr++);
-
- if(!hptr->name) {
- php_error(E_WARNING, "no such handler: %s", (*args[2])->value.str.val);
- FREENOW;
- RETURN_FALSE;
- }
-
- switch((*args[1])->value.str.val[0]) {
- case 'c':
- modenr = DBA_CREAT;
- break;
- case 'w':
- modenr = DBA_WRITER;
- break;
- case 'r':
- modenr = DBA_READER;
- break;
- case 'n':
- modenr = DBA_TRUNC;
- break;
- default:
- php_error(E_WARNING,"illegal DBA mode: %s",(*args[1])->value.str.val);
- FREENOW;
- RETURN_FALSE;
- }
-
- info = malloc(sizeof(*info));
- memset(info, 0, sizeof(info));
- info->path = strdup((*args[0])->value.str.val);
- info->mode = modenr;
- info->argc = ac - 3;
- info->argv = args + 3;
- info->hnd = NULL;
-
- if(hptr->open(info) != SUCCESS) {
- dba_close(info);
- php_error(E_WARNING, "driver initialization failed");
- FREENOW;
- RETURN_FALSE;
- }
- info->hnd = hptr;
- info->argc = 0;
- info->argv = NULL;
-
- listid = php3_list_insert(info, persistent?GLOBAL(le_pdb):GLOBAL(le_db));
- if(persistent) {
- zend_hash_update(&ht_keys, key, keylen, info, sizeof(*info), NULL);
- }
-
- FREENOW;
- RETURN_LONG(listid);
-}
-#undef FREENOW
-/* }}} */
-/* }}} */
-
-/* {{{ proto int dba_popen(string path, string mode, string handlername[, ...])
- opens path using the specified handler in mode persistently */
-PHP_FUNCTION(dba_popen)
-{
- _php3_dba_open(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-/* {{{ proto int dba_open(string path, string mode, string handlername[, ...])
- opens path using the specified handler in mode*/
-PHP_FUNCTION(dba_open)
-{
- _php3_dba_open(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ proto void dba_close(int handle)
- closes database */
-PHP_FUNCTION(dba_close)
-{
- DBA_ID_GET1;
-
- php3_list_delete((*id)->value.lval);
-}
-/* }}} */
-
-/* {{{ proto bool dba_exists(string key, int handle)
- checks, if the specified key exists */
-PHP_FUNCTION(dba_exists)
-{
- DBA_ID_GET2;
-
- if(info->hnd->exists(info, VALLEN(key)) == SUCCESS) {
- RETURN_TRUE;
- }
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto string dba_fetch(string key, int handle)
- fetches the data associated with key */
-PHP_FUNCTION(dba_fetch)
-{
- char *val;
- int len = 0;
- DBA_ID_GET2;
-
- if((val = info->hnd->fetch(info, VALLEN(key), &len)) != NULL) {
- RETURN_STRINGL(val, len, 0);
- }
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto string dba_firstkey(int handle)
- resets the internal key pointer and returns the first key */
-PHP_FUNCTION(dba_firstkey)
-{
- char *fkey;
- int len;
- DBA_ID_GET1;
-
- fkey = info->hnd->firstkey(info, &len);
- if(fkey)
- RETURN_STRINGL(fkey, len, 0);
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto string dba_nextkey(int handle)
- returns the next key */
-PHP_FUNCTION(dba_nextkey)
-{
- char *nkey;
- int len;
- DBA_ID_GET1;
-
- nkey = info->hnd->nextkey(info, &len);
- if(nkey)
- RETURN_STRINGL(nkey, len, 0);
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto bool dba_delete(string key, int handle)
- deletes the entry associated with key */
-PHP_FUNCTION(dba_delete)
-{
- DBA_ID_GET2;
-
- DBA_WRITE_CHECK;
-
- if(info->hnd->delete(info, VALLEN(key)) == SUCCESS)
- RETURN_TRUE;
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto bool dba_insert(string key, string value, int handle)
- inserts value as key, returns false, if key exists already */
-PHP_FUNCTION(dba_insert)
-{
- _php3_dba_update(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-/* {{{ proto bool dba_replace(string key, string value, int handle)
- inserts value as key, replaces key, if key exists already */
-PHP_FUNCTION(dba_replace)
-{
- _php3_dba_update(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ proto bool dba_optimize(int handle)
- optimizes (e.g. clean up, vacuum) database */
-PHP_FUNCTION(dba_optimize)
-{
- DBA_ID_GET1;
-
- DBA_WRITE_CHECK;
- if(info->hnd->optimize(info) == SUCCESS) {
- RETURN_TRUE;
- }
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto bool dba_sync(int handle)
- synchronizes database */
-PHP_FUNCTION(dba_sync)
-{
- DBA_ID_GET1;
-
- if(info->hnd->sync(info) == SUCCESS) {
- RETURN_TRUE;
- }
- RETURN_FALSE;
-}
-/* }}} */
-
-#endif
diff --git a/ext/dba/dba_cdb.c b/ext/dba/dba_cdb.c
deleted file mode 100644
index 55683590c5..0000000000
--- a/ext/dba/dba_cdb.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <sas@schell.de> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-
-#if DBA_CDB
-#include "php3_cdb.h"
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <cdb.h>
-#include <cdbmake.h>
-
-#define CDB_INFO \
- dba_cdb *cdb = (dba_cdb *) info->dbf
-
-typedef struct {
- int fd;
- uint32 eod; /* size of constant database */
- uint32 pos; /* current position for traversing */
-} dba_cdb;
-
-DBA_OPEN_FUNC(cdb)
-{
- int gmode = 0;
- dba_cdb *cdb;
- dba_info *pinfo = (dba_info *) info;
-
- switch(info->mode) {
- case DBA_READER:
- gmode = O_RDONLY; break;
- /* currently not supported: */
-#if 0
- case DBA_WRITER:
- gmode = O_RDWR; break;
-#endif
- default:
- return FAILURE;
- }
-
- cdb = malloc(sizeof *cdb);
- memset(cdb, 0, sizeof *cdb);
-
- cdb->fd = open(info->path, gmode);
- if(cdb->fd < 0) {
- free(cdb);
- return FAILURE;
- }
-
- pinfo->dbf = cdb;
- return SUCCESS;
-}
-
-DBA_CLOSE_FUNC(cdb)
-{
- CDB_INFO;
-
- close(cdb->fd);
- free(cdb);
-}
-
-DBA_FETCH_FUNC(cdb)
-{
- CDB_INFO;
- int len;
- char *new = NULL;
-
- if(cdb_seek(cdb->fd, key, keylen, &len) == 1) {
- new = emalloc(len);
- read(cdb->fd, new, len);
- if(newlen) *newlen = len;
- }
-
- return new;
-}
-
-DBA_UPDATE_FUNC(cdb)
-{
- /* if anyone figures out cdbmake.c, let me know */
- return FAILURE;
-}
-
-DBA_EXISTS_FUNC(cdb)
-{
- CDB_INFO;
- int len;
-
- if(cdb_seek(cdb->fd, key, keylen, &len) == 1)
- return SUCCESS;
- return FAILURE;
-}
-
-DBA_DELETE_FUNC(cdb)
-{
- return FAILURE;
-}
-
-
-#define CREAD(n) if(read(cdb->fd, buf, n) < n) return NULL
-#define CSEEK(n) \
- if(n >= cdb->eod) return NULL; \
- if(lseek(cdb->fd, (off_t)n, SEEK_SET) != (off_t) n) return NULL
-
-DBA_FIRSTKEY_FUNC(cdb)
-{
- CDB_INFO;
- uint32 len;
- char buf[8];
- char *key;
-
- cdb->eod = -1;
- CSEEK(0);
- CREAD(4);
- cdb->eod = cdb_unpack(buf);
-
- CSEEK(2048);
- CREAD(8);
- len = cdb_unpack(buf);
-
- key = emalloc(len + 1);
- if(read(cdb->fd, key, len) < len) {
- efree(key);
- key = NULL;
- } else
- key[len] = '\0';
- /* header + klenlen + dlenlen + klen + dlen */
- cdb->pos = 2048 + 4 + 4 + len + cdb_unpack(buf + 4);
-
- return key;
-}
-
-DBA_NEXTKEY_FUNC(cdb)
-{
- CDB_INFO;
- uint32 len;
- char buf[8];
- char *nkey;
-
- CSEEK(cdb->pos);
- CREAD(8);
- len = cdb_unpack(buf);
-
- nkey = emalloc(len + 1);
- if(read(cdb->fd, nkey, len) < len) {
- efree(nkey);
- return NULL;
- }
- nkey[len] = '\0';
- if(newlen) *newlen = len;
-
- cdb->pos += 8 + len + cdb_unpack(buf + 4);
-
- return nkey;
-#if 0
- /* this code cdb_seeks and is thus slower than directly seeking
- in the file */
- CDB_INFO;
- char *nkey = NULL;
- uint32 len;
- char buf[8];
-
- if(cdb_seek(cdb->fd, key, keylen, &len) == 1) {
- if(lseek(cdb->fd, (off_t) len, SEEK_CUR) >= (off_t) cdb->eod)
- return NULL;
- CREAD(8);
- len = cdb_unpack(buf);
-
- nkey = emalloc(len + 1);
- if(read(cdb->fd, nkey, len) < len) {
- efree(nkey);
- nkey = NULL;
- } else
- nkey[len] = '\0';
- }
- return nkey;
-#endif
-}
-
-DBA_OPTIMIZE_FUNC(cdb)
-{
- return SUCCESS;
-}
-
-DBA_SYNC_FUNC(cdb)
-{
- /* this is read-only */
- return SUCCESS;
-}
-
-#endif
diff --git a/ext/dba/dba_db2.c b/ext/dba/dba_db2.c
deleted file mode 100644
index 77f010a7f2..0000000000
--- a/ext/dba/dba_db2.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <sas@schell.de> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-
-#if DBA_DB2
-#include "php3_db2.h"
-#include <sys/stat.h>
-
-#include <string.h>
-#if DB2_DB2_DB_H
-#include <db2/db.h>
-#elif DB2_DB_DB2_H
-#include <db/db2.h>
-#elif DB2_DB2_H
-#include <db2.h>
-#elif DB2_DB_H
-#include <db.h>
-#endif
-
-#define DB2_DATA dba_db2_data *dba = info->dbf
-#define DB2_GKEY \
- DBT gkey; \
- memset(&gkey, 0, sizeof(gkey)); \
- gkey.data = (char *) key; gkey.size = keylen
-
-typedef struct {
- DB *dbp;
- DBC *cursor;
-} dba_db2_data;
-
-DBA_OPEN_FUNC(db2)
-{
- DB *dbp;
- DBTYPE type;
- int gmode = 0;
- int filemode = 0644;
- struct stat check_stat;
-
- type = info->mode == DBA_READER ? DB_UNKNOWN :
- info->mode == DBA_TRUNC ? DB_BTREE :
- stat(info->path, &check_stat) ? DB_BTREE : DB_UNKNOWN;
-
- gmode = info->mode == DBA_READER ? DB_RDONLY :
- info->mode == DBA_CREAT ? DB_CREATE :
- info->mode == DBA_WRITER ? 0 :
- info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1;
-
- if(gmode == -1)
- return FAILURE;
-
- if(info->argc > 0) {
- convert_to_long_ex(info->argv[0]);
- filemode = (*info->argv[0])->value.lval;
- }
-
- if(!db_open(info->path, type, gmode, filemode, NULL, NULL, &dbp)) {
- info->dbf = malloc(sizeof(dba_db2_data));
- memset(info->dbf, 0, sizeof(dba_db2_data));
- ((dba_db2_data *) info->dbf)->dbp = dbp;
- return SUCCESS;
- }
- return FAILURE;
-}
-
-DBA_CLOSE_FUNC(db2)
-{
- DB2_DATA;
-
- if(dba->cursor) dba->cursor->c_close(dba->cursor);
- dba->dbp->close(dba->dbp, 0);
- free(dba);
-}
-
-DBA_FETCH_FUNC(db2)
-{
- DBT gval;
- char *new = NULL;
- DB2_DATA;
- DB2_GKEY;
-
- memset(&gval, 0, sizeof(gval));
- if(!dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) {
- if(newlen) *newlen = gval.size;
- new = estrndup(gval.data, gval.size);
- }
- return new;
-}
-
-DBA_UPDATE_FUNC(db2)
-{
- DBT gval;
- DB2_DATA;
- DB2_GKEY;
-
- memset(&gval, 0, sizeof(gval));
- gval.data = (char *) val;
- gval.size = vallen;
-
- if(!dba->dbp->put(dba->dbp, NULL, &gkey, &gval,
- mode == 1 ? DB_NOOVERWRITE : 0)) {
- return SUCCESS;
- }
- return FAILURE;
-}
-
-DBA_EXISTS_FUNC(db2)
-{
- DBT gval;
- DB2_DATA;
- DB2_GKEY;
-
- memset(&gval, 0, sizeof(gval));
- if(!dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) {
- return SUCCESS;
- }
- return FAILURE;
-}
-
-DBA_DELETE_FUNC(db2)
-{
- DB2_DATA;
- DB2_GKEY;
-
- return dba->dbp->del(dba->dbp, NULL, &gkey, 0) ? FAILURE : SUCCESS;
-}
-
-DBA_FIRSTKEY_FUNC(db2)
-{
- DB2_DATA;
-
- if(dba->cursor) {
- dba->cursor->c_close(dba->cursor);
- }
-
- dba->cursor = NULL;
-#if (DB_VERSION_MAJOR > 2) || (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR > 6) || (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 6 && DB_VERSION_PATCH >= 4)
- if(dba->dbp->cursor(dba->dbp, NULL, &dba->cursor, 0)) {
-#else
- if(dba->dbp->cursor(dba->dbp, NULL, &dba->cursor)) {
-#endif
- return NULL;
- }
-
- /* we should introduce something like PARAM_PASSTHRU... */
- return dba_nextkey_db2(info, newlen);
-}
-
-DBA_NEXTKEY_FUNC(db2)
-{
- DB2_DATA;
- DBT gkey, gval;
- char *nkey = NULL;
-
- memset(&gkey, 0, sizeof(gkey));
- memset(&gval, 0, sizeof(gval));
-
- if(!dba->cursor->c_get(dba->cursor, &gkey, &gval, DB_NEXT)) {
- if(gkey.data) {
- nkey = estrndup(gkey.data, gkey.size);
- if(newlen) *newlen = gkey.size;
- }
- }
- return nkey;
-}
-
-DBA_OPTIMIZE_FUNC(db2)
-{
- return SUCCESS;
-}
-
-DBA_SYNC_FUNC(db2)
-{
- DB2_DATA;
-
- return dba->dbp->sync(dba->dbp, 0) ? FAILURE : SUCCESS;
-}
-
-#endif
diff --git a/ext/dba/dba_dbm.c b/ext/dba/dba_dbm.c
deleted file mode 100644
index b8b4ea95f2..0000000000
--- a/ext/dba/dba_dbm.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <sas@schell.de> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-
-#if DBA_DBM
-#include "php3_dbm.h"
-
-#include <dbm.h>
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#define DBM_DATA dba_dbm_data *dba = info->dbf
-#define DBM_GKEY datum gkey; gkey.dptr = (char *) key; gkey.dsize = keylen
-
-#ifndef PATH_MAX
-#define PATH_MAX 255
-#endif
-
-#define TRUNC_IT(extension, mode) \
- snprintf(buf, PATH_MAX, "%s" extension, info->path); \
- buf[PATH_MAX] = '\0'; \
- if((fd = open(buf, O_CREAT | mode | O_WRONLY, filemode)) == -1) \
- return FAILURE; \
- close(fd);
-
-
-typedef struct {
- datum nextkey;
-} dba_dbm_data;
-
-DBA_OPEN_FUNC(dbm)
-{
- int fd;
- int filemode = 0644;
-
- if(info->argc > 0) {
- convert_to_long_ex(info->argv[0]);
- filemode = (*info->argv[0])->value.lval;
- }
-
- if(info->mode == DBA_TRUNC) {
- char buf[PATH_MAX + 1];
-
- /* dbm/ndbm original */
- TRUNC_IT(".pag", O_TRUNC);
- TRUNC_IT(".dir", O_TRUNC);
- }
-
- if(info->mode == DBA_CREAT) {
- char buf[PATH_MAX + 1];
-
- TRUNC_IT(".pag", 0);
- TRUNC_IT(".dir", 0);
- }
-
- if(dbminit((char *) info->path) == -1) {
- return FAILURE;
- }
-
- info->dbf = calloc(sizeof(dba_dbm_data), 1);
- return SUCCESS;
-}
-
-DBA_CLOSE_FUNC(dbm)
-{
- free(info->dbf);
- dbmclose();
-}
-
-DBA_FETCH_FUNC(dbm)
-{
- datum gval;
- char *new = NULL;
-
- DBM_GKEY;
- gval = fetch(gkey);
- if(gval.dptr) {
- if(newlen) *newlen = gval.dsize;
- new = estrndup(gval.dptr, gval.dsize);
- }
- return new;
-}
-
-DBA_UPDATE_FUNC(dbm)
-{
- datum gval;
-
- DBM_GKEY;
- gval.dptr = (char *) val;
- gval.dsize = vallen;
-
- return (store(gkey, gval) == -1 ? FAILURE : SUCCESS);
-}
-
-DBA_EXISTS_FUNC(dbm)
-{
- datum gval;
- DBM_GKEY;
-
- gval = fetch(gkey);
- if(gval.dptr) {
- return SUCCESS;
- }
- return FAILURE;
-}
-
-DBA_DELETE_FUNC(dbm)
-{
- DBM_GKEY;
- return(delete(gkey) == -1 ? FAILURE : SUCCESS);
-}
-
-DBA_FIRSTKEY_FUNC(dbm)
-{
- DBM_DATA;
- datum gkey;
- char *key = NULL;
-
- gkey = firstkey();
- if(gkey.dptr) {
- if(newlen) *newlen = gkey.dsize;
- key = estrndup(gkey.dptr, gkey.dsize);
- dba->nextkey = gkey;
- } else
- dba->nextkey.dptr = NULL;
- return key;
-}
-
-DBA_NEXTKEY_FUNC(dbm)
-{
- DBM_DATA;
- datum gkey;
- char *nkey = NULL;
-
- if(!dba->nextkey.dptr) return NULL;
-
- gkey = nextkey(dba->nextkey);
- if(gkey.dptr) {
- if(newlen) *newlen = gkey.dsize;
- nkey = estrndup(gkey.dptr, gkey.dsize);
- dba->nextkey = gkey;
- } else
- dba->nextkey.dptr = NULL;
- return nkey;
-}
-
-DBA_OPTIMIZE_FUNC(dbm)
-{
- /* dummy */
- return SUCCESS;
-}
-
-DBA_SYNC_FUNC(dbm)
-{
- return SUCCESS;
-}
-
-#endif
diff --git a/ext/dba/dba_gdbm.c b/ext/dba/dba_gdbm.c
deleted file mode 100644
index 6fde65ec73..0000000000
--- a/ext/dba/dba_gdbm.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <sas@schell.de> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-
-#if DBA_GDBM
-#include "php3_gdbm.h"
-
-#include <gdbm.h>
-
-#define GDBM_DATA dba_gdbm_data *dba = info->dbf
-#define GDBM_GKEY datum gkey; gkey.dptr = (char *) key; gkey.dsize = keylen
-
-typedef struct {
- GDBM_FILE dbf;
- datum nextkey;
-} dba_gdbm_data;
-
-DBA_OPEN_FUNC(gdbm)
-{
- GDBM_FILE dbf;
- int gmode = 0;
- int filemode = 0644;
-
- gmode = info->mode == DBA_READER ? GDBM_READER :
- info->mode == DBA_WRITER ? GDBM_WRITER :
- info->mode == DBA_CREAT ? GDBM_WRCREAT :
- info->mode == DBA_TRUNC ? GDBM_NEWDB : -1;
-
- if(gmode == -1)
- return FAILURE;
-
- if(info->argc > 0) {
- convert_to_long_ex(info->argv[0]);
- filemode = (*info->argv[0])->value.lval;
- }
-
- dbf = gdbm_open(info->path, 0, gmode, filemode, NULL);
-
- if(dbf) {
- info->dbf = malloc(sizeof(dba_gdbm_data));
- memset(info->dbf, 0, sizeof(dba_gdbm_data));
- ((dba_gdbm_data *) info->dbf)->dbf = dbf;
- return SUCCESS;
- }
- return FAILURE;
-}
-
-DBA_CLOSE_FUNC(gdbm)
-{
- GDBM_DATA;
-
- if(dba->nextkey.dptr) free(dba->nextkey.dptr);
- gdbm_close(dba->dbf);
- free(dba);
-}
-
-DBA_FETCH_FUNC(gdbm)
-{
- GDBM_DATA;
- datum gval;
- char *new = NULL;
-
- GDBM_GKEY;
- gval = gdbm_fetch(dba->dbf, gkey);
- if(gval.dptr) {
- if(newlen) *newlen = gval.dsize;
- new = estrndup(gval.dptr, gval.dsize);
- free(gval.dptr);
- }
- return new;
-}
-
-DBA_UPDATE_FUNC(gdbm)
-{
- datum gval;
- GDBM_DATA;
-
- GDBM_GKEY;
- gval.dptr = (char *) val;
- gval.dsize = vallen;
-
- if(gdbm_store(dba->dbf, gkey, gval,
- mode == 1 ? GDBM_INSERT : GDBM_REPLACE) == 0)
- return SUCCESS;
- printf("XXX %s\n", gdbm_strerror(gdbm_errno));
- return FAILURE;
-}
-
-DBA_EXISTS_FUNC(gdbm)
-{
- GDBM_DATA;
- GDBM_GKEY;
-
- return gdbm_exists(dba->dbf, gkey) ? SUCCESS : FAILURE;
-}
-
-DBA_DELETE_FUNC(gdbm)
-{
- GDBM_DATA;
- GDBM_GKEY;
-
- return gdbm_delete(dba->dbf, gkey) == -1 ? FAILURE : SUCCESS;
-}
-
-DBA_FIRSTKEY_FUNC(gdbm)
-{
- GDBM_DATA;
- datum gkey;
- char *key = NULL;
-
- if(dba->nextkey.dptr) {
- free(dba->nextkey.dptr);
- }
-
- gkey = gdbm_firstkey(dba->dbf);
- if(gkey.dptr) {
- key = estrndup(gkey.dptr, gkey.dsize);
- if(newlen) *newlen = gkey.dsize;
- dba->nextkey = gkey;
- } else {
- dba->nextkey.dptr = NULL;
- }
- return key;
-}
-
-DBA_NEXTKEY_FUNC(gdbm)
-{
- GDBM_DATA;
- char *nkey = NULL;
- datum gkey;
-
- if(!dba->nextkey.dptr) return NULL;
-
- gkey = gdbm_nextkey(dba->dbf, dba->nextkey);
- free(dba->nextkey.dptr);
- if(gkey.dptr) {
- nkey = estrndup(gkey.dptr, gkey.dsize);
- if(newlen) *newlen = gkey.dsize;
- dba->nextkey = gkey;
- } else {
- dba->nextkey.dptr = NULL;
- }
- return nkey;
-}
-
-DBA_OPTIMIZE_FUNC(gdbm)
-{
- GDBM_DATA;
- gdbm_reorganize(dba->dbf);
- return SUCCESS;
-}
-
-DBA_SYNC_FUNC(gdbm)
-{
- GDBM_DATA;
-
- gdbm_sync(dba->dbf);
- return SUCCESS;
-}
-#endif
diff --git a/ext/dba/dba_ndbm.c b/ext/dba/dba_ndbm.c
deleted file mode 100644
index 3c10868aab..0000000000
--- a/ext/dba/dba_ndbm.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <sas@schell.de> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-
-#if DBA_NDBM
-#include "php3_ndbm.h"
-
-#include <fcntl.h>
-
-#if NDBM_DB1_NDBM_H
-#include <db1/ndbm.h>
-#elif NDBM_NDBM_H
-#include <ndbm.h>
-#endif
-
-#define NDBM_GKEY datum gkey; gkey.dptr = (char *) key; gkey.dsize = keylen
-
-DBA_OPEN_FUNC(ndbm)
-{
- DBM *dbf;
- int gmode = 0;
- int filemode = 0644;
- dba_info *pinfo = (dba_info *) info;
-
- switch(info->mode) {
- case DBA_READER:
- gmode = O_RDONLY;
- break;
- case DBA_WRITER:
- gmode = O_RDWR;
- break;
- case DBA_CREAT:
- gmode = O_RDWR | O_CREAT;
- break;
- case DBA_TRUNC:
- gmode = O_RDWR | O_CREAT | O_TRUNC;
- break;
- default:
- return FAILURE;
- }
-
- if(info->argc > 0) {
- convert_to_long_ex(info->argv[0]);
- filemode = (*info->argv[0])->value.lval;
- }
-
- dbf = dbm_open(info->path, gmode, filemode);
-
- if(dbf) {
- pinfo->dbf = dbf;
- return SUCCESS;
- }
- return FAILURE;
-}
-
-DBA_CLOSE_FUNC(ndbm)
-{
- dbm_close(info->dbf);
-}
-
-DBA_FETCH_FUNC(ndbm)
-{
- datum gval;
- char *new = NULL;
-
- NDBM_GKEY;
- gval = dbm_fetch(info->dbf, gkey);
- if(gval.dptr) {
- if(newlen) *newlen = gval.dsize;
- new = estrndup(gval.dptr, gval.dsize);
- }
- return new;
-}
-
-DBA_UPDATE_FUNC(ndbm)
-{
- datum gval;
-
- NDBM_GKEY;
- gval.dptr = (char *) val;
- gval.dsize = vallen;
-
- if(!dbm_store(info->dbf, gkey, gval, mode == 1 ? DBM_INSERT : DBM_REPLACE))
- return SUCCESS;
- return FAILURE;
-}
-
-DBA_EXISTS_FUNC(ndbm)
-{
- datum gval;
- NDBM_GKEY;
- gval = dbm_fetch(info->dbf, gkey);
- if(gval.dptr) {
- return SUCCESS;
- }
- return FAILURE;
-}
-
-DBA_DELETE_FUNC(ndbm)
-{
- NDBM_GKEY;
- return(dbm_delete(info->dbf, gkey) == -1 ? FAILURE : SUCCESS);
-}
-
-DBA_FIRSTKEY_FUNC(ndbm)
-{
- datum gkey;
- char *key = NULL;
-
- gkey = dbm_firstkey(info->dbf);
- if(gkey.dptr) {
- if(newlen) *newlen = gkey.dsize;
- key = estrndup(gkey.dptr, gkey.dsize);
- }
- return key;
-}
-
-DBA_NEXTKEY_FUNC(ndbm)
-{
- datum gkey;
- char *nkey = NULL;
-
- gkey = dbm_nextkey(info->dbf);
- if(gkey.dptr) {
- if(newlen) *newlen = gkey.dsize;
- nkey = estrndup(gkey.dptr, gkey.dsize);
- }
- return nkey;
-}
-
-DBA_OPTIMIZE_FUNC(ndbm)
-{
- return SUCCESS;
-}
-
-DBA_SYNC_FUNC(ndbm)
-{
- return SUCCESS;
-}
-#endif
diff --git a/ext/dba/php3_cdb.h b/ext/dba/php3_cdb.h
deleted file mode 100644
index 162fa8bdb2..0000000000
--- a/ext/dba/php3_cdb.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _PHP3_CDB_H
-#define _PHP3_CDB_H
-
-#if DBA_CDB
-
-#include "php3_dba.h"
-
-DBA_FUNCS(cdb);
-
-#endif
-
-#endif
diff --git a/ext/dba/php3_db2.h b/ext/dba/php3_db2.h
deleted file mode 100644
index 0f8c458db9..0000000000
--- a/ext/dba/php3_db2.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _PHP3_DB2_H
-#define _PHP3_DB2_H
-
-#if DBA_DB2
-
-#include "php3_dba.h"
-
-DBA_FUNCS(db2);
-
-#endif
-
-#endif
diff --git a/ext/dba/php3_dba.h b/ext/dba/php3_dba.h
deleted file mode 100644
index 4a1470c503..0000000000
--- a/ext/dba/php3_dba.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <sas@schell.de> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _DBA_H
-#define _DBA_H
-
-#if HAVE_DBA
-
-typedef enum {
- DBA_READER = 1,
- DBA_WRITER,
- DBA_TRUNC,
- DBA_CREAT
-} dba_mode_t;
-
-typedef struct dba_info {
- /* public */
- void *dbf; /* ptr to private data or whatever */
- char *path;
- dba_mode_t mode;
- /* arg[cv] are only available when the dba_open handler is called! */
- int argc;
- pval ***argv;
- /* private */
- struct dba_handler *hnd;
-} dba_info;
-
-extern php3_module_entry dba_module_entry;
-#define dba_module_ptr &dba_module_entry
-
-/* common prototypes which must be supplied by modules */
-
-#define DBA_OPEN_FUNC(x) \
- int dba_open_##x(dba_info *info)
-#define DBA_CLOSE_FUNC(x) \
- void dba_close_##x(dba_info *info)
-#define DBA_FETCH_FUNC(x) \
- char *dba_fetch_##x(dba_info *info, char *key, int keylen, int *newlen)
-#define DBA_UPDATE_FUNC(x) \
- int dba_update_##x(dba_info *info, char *key, int keylen, char *val, int vallen, int mode)
-#define DBA_EXISTS_FUNC(x) \
- int dba_exists_##x(dba_info *info, char *key, int keylen)
-#define DBA_DELETE_FUNC(x) \
- int dba_delete_##x(dba_info *info, char *key, int keylen)
-#define DBA_FIRSTKEY_FUNC(x) \
- char *dba_firstkey_##x(dba_info *info, int *newlen)
-#define DBA_NEXTKEY_FUNC(x) \
- char *dba_nextkey_##x(dba_info *info, int *newlen)
-#define DBA_OPTIMIZE_FUNC(x) \
- int dba_optimize_##x(dba_info *info)
-#define DBA_SYNC_FUNC(x) \
- int dba_sync_##x(dba_info *info)
-
-#define DBA_FUNCS(x) \
- DBA_OPEN_FUNC(x); \
- DBA_CLOSE_FUNC(x); \
- DBA_FETCH_FUNC(x); \
- DBA_UPDATE_FUNC(x); \
- DBA_DELETE_FUNC(x); \
- DBA_EXISTS_FUNC(x); \
- DBA_FIRSTKEY_FUNC(x); \
- DBA_NEXTKEY_FUNC(x); \
- DBA_OPTIMIZE_FUNC(x); \
- DBA_SYNC_FUNC(x)
-
-#define VALLEN(p) (*p)->value.str.val, (*p)->value.str.len
-
-PHP_FUNCTION(dba_open);
-PHP_FUNCTION(dba_popen);
-PHP_FUNCTION(dba_close);
-PHP_FUNCTION(dba_firstkey);
-PHP_FUNCTION(dba_nextkey);
-PHP_FUNCTION(dba_replace);
-PHP_FUNCTION(dba_insert);
-PHP_FUNCTION(dba_delete);
-PHP_FUNCTION(dba_exists);
-PHP_FUNCTION(dba_fetch);
-PHP_FUNCTION(dba_optimize);
-PHP_FUNCTION(dba_sync);
-
-#else
-#define dba_module_ptr NULL
-#endif
-
-#define phpext_dba_ptr dba_module_ptr
-
-#endif
diff --git a/ext/dba/php3_dbm.h b/ext/dba/php3_dbm.h
deleted file mode 100644
index 5007c84b3e..0000000000
--- a/ext/dba/php3_dbm.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _PHP3_DBM_H
-#define _PHP3_DBM_H
-
-#if DBA_DBM
-
-#include "php3_dba.h"
-
-DBA_FUNCS(dbm);
-
-#endif
-
-#endif
diff --git a/ext/dba/php3_gdbm.h b/ext/dba/php3_gdbm.h
deleted file mode 100644
index 9a18b531d4..0000000000
--- a/ext/dba/php3_gdbm.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _PHP3_GDBM_H
-#define _PHP3_GDBM_H
-
-#if DBA_GDBM
-
-#include "php3_dba.h"
-
-DBA_FUNCS(gdbm);
-
-#endif
-
-#endif
diff --git a/ext/dba/php3_ndbm.h b/ext/dba/php3_ndbm.h
deleted file mode 100644
index 398b8e39a1..0000000000
--- a/ext/dba/php3_ndbm.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _PHP3_NDBM_H
-#define _PHP3_NDBM_H
-
-#if DBA_NDBM
-
-#include "php3_dba.h"
-
-DBA_FUNCS(ndbm);
-
-#endif
-
-#endif
diff --git a/ext/dba/setup.stub b/ext/dba/setup.stub
deleted file mode 100644
index 0df17de7d1..0000000000
--- a/ext/dba/setup.stub
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-dba 'dba support?' yesnodir no \
-' Whether to build the dba extension.'
-
diff --git a/ext/dbase/Makefile.am b/ext/dbase/Makefile.am
deleted file mode 100644
index c04a5ccb86..0000000000
--- a/ext/dbase/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-## Process this file with automake to produce Makefile.in -*- makefile -*-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_dbase.a
-libphpext_dbase_a_SOURCES=dbf_head.c dbf_rec.c dbf_misc.c dbf_ndx.c dbase.c
-
diff --git a/ext/dbase/config.h.stub b/ext/dbase/config.h.stub
deleted file mode 100644
index c8bf0adbe2..0000000000
--- a/ext/dbase/config.h.stub
+++ /dev/null
@@ -1,3 +0,0 @@
-/* Define if you want to use the supplied dbase library */
-#define DBASE 0
-
diff --git a/ext/dbase/config.m4 b/ext/dbase/config.m4
deleted file mode 100644
index 29f54923bf..0000000000
--- a/ext/dbase/config.m4
+++ /dev/null
@@ -1,21 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(whether to include the bundled dbase library)
-AC_ARG_WITH(dbase,
-[ --with-dbase Include the bundled dbase library],
-[
- if test "$withval" = "yes"; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(DBASE,1)
- PHP_EXTENSION(dbase)
- else
- AC_MSG_RESULT(no)
- AC_DEFINE(DBASE,0)
- DBASE_LIB=
- fi
-],[
- AC_MSG_RESULT(no)
- AC_DEFINE(DBASE,0)
- DBASE_LIB=
-])
-AC_SUBST(DBASE_LIB)
diff --git a/ext/dbase/dbase.c b/ext/dbase/dbase.c
deleted file mode 100644
index 196b25c191..0000000000
--- a/ext/dbase/dbase.c
+++ /dev/null
@@ -1,752 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Jim Winstead (jimw@php.net) |
- +----------------------------------------------------------------------+
- */
-#if defined(COMPILE_DL)
-#include "dl/phpdl.h"
-#endif
-
-#include <stdlib.h>
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#include "php.h"
-#include "safe_mode.h"
-#include "fopen-wrappers.h"
-#include "php_globals.h"
-
-#if DBASE
-#include "php_dbase.h"
-#include "dbf.h"
-#if defined(THREAD_SAFE)
-DWORD DbaseTls;
-static int numthreads=0;
-void *dbase_mutex;
-
-typedef struct dbase_global_struct{
- int le_dbhead;
-}dbase_global_struct;
-
-#define DBase_GLOBAL(a) dbase_globals->a
-
-#define DBase_TLS_VARS \
- dbase_global_struct *dbase_globals; \
- dbase_globals=TlsGetValue(DbaseTls);
-
-#else
-static int le_dbhead;
-#define DBase_GLOBAL(a) a
-#define DBase_TLS_VARS
-#endif
-
-#include <fcntl.h>
-#include <errno.h>
-
-
-static void _close_dbase(dbhead_t *dbhead)
-{
- close(dbhead->db_fd);
- free_dbf_head(dbhead);
-}
-
-
-PHP_MINIT_FUNCTION(dbase)
-{
-#if defined(THREAD_SAFE)
- dbase_global_struct *dbase_globals;
-#if !defined(COMPILE_DL)
- CREATE_MUTEX(dbase_mutex,"DBase_TLS");
- SET_MUTEX(dbase_mutex);
- numthreads++;
- if (numthreads==1){
- if ((DbaseTls=TlsAlloc())==0xFFFFFFFF){
- FREE_MUTEX(dbase_mutex);
- return 0;
- }}
- FREE_MUTEX(dbase_mutex);
-#endif
- dbase_globals = (dbase_global_struct *) LocalAlloc(LPTR, sizeof(dbase_global_struct));
- TlsSetValue(DbaseTls, (void *) dbase_globals);
-#endif
- DBase_GLOBAL(le_dbhead) = register_list_destructors(_close_dbase,NULL);
- return SUCCESS;
-}
-
-static PHP_MSHUTDOWN_FUNCTION(dbase)
-{
-#if defined(THREAD_SAFE)
- dbase_global_struct *dbase_globals;
- dbase_globals = TlsGetValue(DbaseTls);
- if (dbase_globals != 0)
- LocalFree((HLOCAL) dbase_globals);
-#if !defined(COMPILE_DL)
- SET_MUTEX(dbase_mutex);
- numthreads--;
- if (!numthreads){
- if (!TlsFree(DbaseTls)){
- FREE_MUTEX(dbase_mutex);
- return 0;
- }}
- FREE_MUTEX(dbase_mutex);
-#endif
-#endif
- return SUCCESS;
-}
-
-/* {{{ proto int dbase_open(string name, int mode)
- Opens a dBase-format database file */
-PHP_FUNCTION(dbase_open) {
- pval *dbf_name, *options;
- dbhead_t *dbh;
- int handle;
- DBase_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&dbf_name,&options)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(dbf_name);
- convert_to_long(options);
-
- if (PG(safe_mode) && (!_php3_checkuid(dbf_name->value.str.val, 2))) {
- RETURN_FALSE;
- }
-
- if (_php3_check_open_basedir(dbf_name->value.str.val)) {
- RETURN_FALSE;
- }
-
- dbh = dbf_open(dbf_name->value.str.val, options->value.lval);
- if (dbh == NULL) {
- php_error(E_WARNING, "unable to open database %s", dbf_name->value.str.val);
- RETURN_FALSE;
- }
-
- handle = php3_list_insert(dbh, DBase_GLOBAL(le_dbhead));
- RETURN_LONG(handle);
-}
-/* }}} */
-
-/* {{{ proto bool dbase_close(int identifier)
- Closes an open dBase-format database file */
-PHP_FUNCTION(dbase_close) {
- pval *dbh_id;
- dbhead_t *dbh;
- int dbh_type;
- DBase_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&dbh_id)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(dbh_id);
- dbh = php3_list_find(dbh_id->value.lval, &dbh_type);
- if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
- php_error(E_WARNING, "Unable to find database for identifier %d", dbh_id->value.lval);
- RETURN_FALSE;
- }
-
- php3_list_delete(dbh_id->value.lval);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int dbase_numrecords(int identifier)
- Returns the number of records in the database */
-PHP_FUNCTION(dbase_numrecords) {
- pval *dbh_id;
- dbhead_t *dbh;
- int dbh_type;
- DBase_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&dbh_id)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(dbh_id);
- dbh = php3_list_find(dbh_id->value.lval, &dbh_type);
- if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
- php_error(E_WARNING, "Unable to find database for identifier %d", dbh_id->value.lval);
- RETURN_FALSE;
- }
-
- RETURN_LONG(dbh->db_records);
-}
-/* }}} */
-
-/* {{{ proto int dbase_numfields(int identifier)
- Returns the number of fields (columns) in the database */
-PHP_FUNCTION(dbase_numfields) {
- pval *dbh_id;
- dbhead_t *dbh;
- int dbh_type;
- DBase_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&dbh_id)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(dbh_id);
- dbh = php3_list_find(dbh_id->value.lval, &dbh_type);
- if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
- php_error(E_WARNING, "Unable to find database for identifier %d", dbh_id->value.lval);
- RETURN_FALSE;
- }
-
- RETURN_LONG(dbh->db_nfields);
-}
-/* }}} */
-
-/* {{{ proto bool dbase_pack(int identifier)
- Packs the database (deletes records marked for deletion) */
-PHP_FUNCTION(dbase_pack) {
- pval *dbh_id;
- dbhead_t *dbh;
- int dbh_type;
- DBase_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&dbh_id)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(dbh_id);
- dbh = php3_list_find(dbh_id->value.lval, &dbh_type);
- if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
- php_error(E_WARNING, "Unable to find database for identifier %d", dbh_id->value.lval);
- RETURN_FALSE;
- }
-
- pack_dbf(dbh);
- put_dbf_info(dbh);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool dbase_add_record(int identifier, array data)
- Adds a record to the database */
-PHP_FUNCTION(dbase_add_record) {
- pval *dbh_id, *fields, *field;
- dbhead_t *dbh;
- int dbh_type;
-
- int num_fields;
- dbfield_t *dbf, *cur_f;
- char *cp, *t_cp;
- int i;
- DBase_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&dbh_id,&fields)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(dbh_id);
- if (fields->type != IS_ARRAY) {
- php_error(E_WARNING, "Expected array as second parameter");
- RETURN_FALSE;
- }
-
- dbh = php3_list_find(dbh_id->value.lval, &dbh_type);
- if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
- php_error(E_WARNING, "Unable to find database for identifier %d", dbh_id->value.lval);
- RETURN_FALSE;
- }
-
- num_fields = zend_hash_num_elements(fields->value.ht);
-
- if (num_fields != dbh->db_nfields) {
- php_error(E_WARNING, "Wrong number of fields specified");
- RETURN_FALSE;
- }
-
- cp = t_cp = (char *)emalloc(dbh->db_rlen + 1);
- if (!cp) {
- php_error(E_WARNING, "unable to allocate memory");
- RETURN_FALSE;
- }
- *t_cp++ = VALID_RECORD;
-
- dbf = dbh->db_fields;
- for (i = 0, cur_f = dbf; cur_f < &dbf[num_fields]; i++, cur_f++) {
- if (zend_hash_index_find(fields->value.ht, i, (void **)&field) == FAILURE) {
- php_error(E_WARNING, "unexpected error");
- efree(cp);
- RETURN_FALSE;
- }
- convert_to_string(field);
- sprintf(t_cp, cur_f->db_format, field->value.str.val);
- t_cp += cur_f->db_flen;
- }
-
- dbh->db_records++;
- if (put_dbf_record(dbh, dbh->db_records, cp) < 0) {
- php_error(E_WARNING, "unable to put record at %ld", dbh->db_records);
- efree(cp);
- RETURN_FALSE;
- }
-
- put_dbf_info(dbh);
- efree(cp);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool dbase_replace_record(int identifier, array data, int recnum)
- Replaces a record to the database */
-void php3_dbase_replace_record(INTERNAL_FUNCTION_PARAMETERS) {
- pval *dbh_id, *fields, *field, *recnum;
- dbhead_t *dbh;
- int dbh_type;
-
- int num_fields;
- dbfield_t *dbf, *cur_f;
- char *cp, *t_cp;
- int i;
- DBase_TLS_VARS;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht,3,&dbh_id,&fields,&recnum)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(dbh_id);
- convert_to_long(recnum);
- if (fields->type != IS_ARRAY) {
- php_error(E_WARNING, "Expected array as second parameter");
- RETURN_FALSE;
- }
-
- dbh = php3_list_find(dbh_id->value.lval, &dbh_type);
- if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
- php_error(E_WARNING, "Unable to find database for identifier %d", dbh_id->value.lval);
- RETURN_FALSE;
- }
-
- num_fields = zend_hash_num_elements(fields->value.ht);
-
- if (num_fields != dbh->db_nfields) {
- php_error(E_WARNING, "Wrong number of fields specified");
- RETURN_FALSE;
- }
-
- cp = t_cp = (char *)emalloc(dbh->db_rlen + 1);
- if (!cp) {
- php_error(E_WARNING, "unable to allocate memory");
- RETURN_FALSE;
- }
- *t_cp++ = VALID_RECORD;
-
- dbf = dbh->db_fields;
- for (i = 0, cur_f = dbf; cur_f < &dbf[num_fields]; i++, cur_f++) {
- if (zend_hash_index_find(fields->value.ht, i, (void **)&field) == FAILURE) {
- php_error(E_WARNING, "unexpected error");
- efree(cp);
- RETURN_FALSE;
- }
- convert_to_string(field);
- sprintf(t_cp, cur_f->db_format, field->value.str.val);
- t_cp += cur_f->db_flen;
- }
-
- if (put_dbf_record(dbh, recnum->value.lval, cp) < 0) {
- php_error(E_WARNING, "unable to put record at %ld", dbh->db_records);
- efree(cp);
- RETURN_FALSE;
- }
-
- put_dbf_info(dbh);
- efree(cp);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool dbase_delete_record(int identifier, int record)
- Marks a record to be deleted */
-PHP_FUNCTION(dbase_delete_record) {
- pval *dbh_id, *record;
- dbhead_t *dbh;
- int dbh_type;
- DBase_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&dbh_id,&record)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(dbh_id);
- convert_to_long(record);
-
- dbh = php3_list_find(dbh_id->value.lval, &dbh_type);
- if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
- php_error(E_WARNING, "Unable to find database for identifier %d", dbh_id->value.lval);
- RETURN_FALSE;
- }
-
- if (del_dbf_record(dbh, record->value.lval) < 0) {
- if (record->value.lval > dbh->db_records) {
- php_error(E_WARNING, "record %d out of bounds", record->value.lval);
- } else {
- php_error(E_WARNING, "unable to delete record %d", record->value.lval);
- }
- RETURN_FALSE;
- }
-
- put_dbf_info(dbh);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto array dbase_get_record(int identifier, int record)
- Returns an array representing a record from the database */
-PHP_FUNCTION(dbase_get_record) {
- pval *dbh_id, *record;
- dbhead_t *dbh;
- int dbh_type;
- dbfield_t *dbf, *cur_f;
- char *data, *fnp, *str_value;
- size_t cursize = 0;
- DBase_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&dbh_id,&record)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(dbh_id);
- convert_to_long(record);
-
- dbh = php3_list_find(dbh_id->value.lval, &dbh_type);
- if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
- php_error(E_WARNING, "Unable to find database for identifier %d", dbh_id->value.lval);
- RETURN_FALSE;
- }
-
- if ((data = get_dbf_record(dbh, record->value.lval)) == NULL) {
- php_error(E_WARNING, "Tried to read bad record %d", record->value.lval);
- RETURN_FALSE;
- }
-
- dbf = dbh->db_fields;
-
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
-
- fnp = NULL;
- for (cur_f = dbf; cur_f < &dbf[dbh->db_nfields]; cur_f++) {
- /* get the value */
- str_value = (char *)emalloc(cur_f->db_flen + 1);
-
- if(cursize <= cur_f->db_flen) {
- cursize = cur_f->db_flen + 1;
- fnp = erealloc(fnp, cursize);
- }
- snprintf(str_value, cursize, cur_f->db_format, get_field_val(data, cur_f, fnp));
-
- /* now convert it to the right php internal type */
- switch (cur_f->db_type) {
- case 'C':
- case 'D':
- add_next_index_string(return_value,str_value,1);
- break;
- case 'N': /* FALLS THROUGH */
- case 'L': /* FALLS THROUGH */
- if (cur_f->db_fdc == 0) {
- add_next_index_long(return_value, strtol(str_value, NULL, 10));
- } else {
- add_next_index_double(return_value, atof(str_value));
- }
- break;
- case 'M':
- /* this is a memo field. don't know how to deal with
- this yet */
- break;
- default:
- /* should deal with this in some way */
- break;
- }
- efree(str_value);
- }
- efree(fnp);
-
- /* mark whether this record was deleted */
- if (data[0] == '*') {
- add_assoc_long(return_value,"deleted",1);
- }
- else {
- add_assoc_long(return_value,"deleted",0);
- }
-
- free(data);
-}
-/* }}} */
-
-/* From Martin Kuba <makub@aida.inet.cz> */
-/* {{{ proto array dbase_get_record_with_names(int identifier, int record)
- Returns an associative array representing a record from the database */
-PHP_FUNCTION(dbase_get_record_with_names) {
- pval *dbh_id, *record;
- dbhead_t *dbh;
- int dbh_type;
- dbfield_t *dbf, *cur_f;
- char *data, *fnp, *str_value;
- DBase_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&dbh_id,&record)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(dbh_id);
- convert_to_long(record);
-
- dbh = php3_list_find(dbh_id->value.lval, &dbh_type);
- if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
- php_error(E_WARNING, "Unable to find database for identifier %d", dbh_id->value.lval);
- RETURN_FALSE;
- }
-
- if ((data = get_dbf_record(dbh, record->value.lval)) == NULL) {
- php_error(E_WARNING, "Tried to read bad record %d", record->value.lval);
- RETURN_FALSE;
- }
-
- dbf = dbh->db_fields;
-
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
-
- fnp = (char *)emalloc(dbh->db_rlen);
- for (cur_f = dbf; cur_f < &dbf[dbh->db_nfields]; cur_f++) {
- /* get the value */
- str_value = (char *)emalloc(cur_f->db_flen + 1);
- sprintf(str_value, cur_f->db_format, get_field_val(data, cur_f, fnp));
-
- /* now convert it to the right php internal type */
- switch (cur_f->db_type) {
- case 'C':
- case 'D':
- add_assoc_string(return_value,cur_f->db_fname,str_value,1);
- break;
- case 'N': /* FALLS THROUGH */
- case 'L': /* FALLS THROUGH */
- if (cur_f->db_fdc == 0) {
- add_assoc_long(return_value,cur_f->db_fname,strtol(str_value, NULL, 10));
- } else {
- add_assoc_double(return_value,cur_f->db_fname,atof(str_value));
- }
- break;
- case 'M':
- /* this is a memo field. don't know how to deal with this yet */
- break;
- default:
- /* should deal with this in some way */
- break;
- }
- efree(str_value);
- }
- efree(fnp);
-
- /* mark whether this record was deleted */
- if (data[0] == '*') {
- add_assoc_long(return_value,"deleted",1);
- } else {
- add_assoc_long(return_value,"deleted",0);
- }
-
- free(data);
-}
-/* }}} */
-
-/* {{{ proto bool dbase_create(string filename, array fields)
- Creates a new dBase-format database file */
-PHP_FUNCTION(dbase_create) {
- pval *filename, *fields, *field, *value;
- int fd;
- dbhead_t *dbh;
-
- int num_fields;
- dbfield_t *dbf, *cur_f;
- int i, rlen, handle;
- DBase_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&filename,&fields)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(filename);
-
- if (fields->type != IS_ARRAY) {
- php_error(E_WARNING, "Expected array as second parameter");
- RETURN_FALSE;
- }
-
- if (PG(safe_mode) && (!_php3_checkuid(filename->value.str.val, 2))) {
- RETURN_FALSE;
- }
-
- if (_php3_check_open_basedir(filename->value.str.val)) {
- RETURN_FALSE;
- }
-
- if ((fd = open(filename->value.str.val, O_BINARY|O_RDWR|O_CREAT, 0644)) < 0) {
- php_error(E_WARNING, "Unable to create database (%d): %s", errno, strerror(errno));
- RETURN_FALSE;
- }
-
- num_fields = zend_hash_num_elements(fields->value.ht);
-
- /* have to use regular malloc() because this gets free()d by
- code in the dbase library */
- dbh = (dbhead_t *)malloc(sizeof(dbhead_t));
- dbf = (dbfield_t *)malloc(sizeof(dbfield_t) * num_fields);
- if (!dbh || !dbf) {
- php_error(E_WARNING, "Unable to allocate memory for header info");
- RETURN_FALSE;
- }
-
- /* initialize the header structure */
- dbh->db_fields = dbf;
- dbh->db_fd = fd;
- dbh->db_dbt = DBH_TYPE_NORMAL;
- strcpy(dbh->db_date, "19930818");
- dbh->db_records = 0;
- dbh->db_nfields = num_fields;
- dbh->db_hlen = sizeof(struct dbf_dhead) + 2 + num_fields * sizeof(struct dbf_dfield);
-
- rlen = 1;
-
- for (i = 0, cur_f = dbf; i < num_fields; i++, cur_f++) {
- /* look up the first field */
- if (zend_hash_index_find(fields->value.ht, i, (void **)&field) == FAILURE) {
- php_error(E_WARNING, "unable to find field %d", i);
- free_dbf_head(dbh);
- RETURN_FALSE;
- }
-
- if (field->type != IS_ARRAY) {
- php_error(E_WARNING, "second parameter must be array of arrays");
- free_dbf_head(dbh);
- RETURN_FALSE;
- }
-
- /* field name */
- if (zend_hash_index_find(field->value.ht, 0, (void **)&value) == FAILURE) {
- php_error(E_WARNING, "expected field name as first element of list in field %d", i);
- free_dbf_head(dbh);
- RETURN_FALSE;
- }
- convert_to_string(value);
- if (value->value.str.len > 10 || value->value.str.len == 0) {
- php_error(E_WARNING, "invalid field name '%s' (must be non-empty and less than or equal to 10 characters)", value->value.str.val);
- free_dbf_head(dbh);
- RETURN_FALSE;
- }
- copy_crimp(cur_f->db_fname, value->value.str.val, value->value.str.len);
-
- /* field type */
- if (zend_hash_index_find(field->value.ht,1,(void **)&value) == FAILURE) {
- php_error(E_WARNING, "expected field type as sececond element of list in field %d", i);
- RETURN_FALSE;
- }
- convert_to_string(value);
- cur_f->db_type = toupper(*value->value.str.val);
-
- cur_f->db_fdc = 0;
-
- /* verify the field length */
- switch (cur_f->db_type) {
- case 'L':
- cur_f->db_flen = 1;
- break;
- case 'M':
- cur_f->db_flen = 9;
- dbh->db_dbt = DBH_TYPE_MEMO;
- /* should create the memo file here, probably */
- break;
- case 'D':
- cur_f->db_flen = 8;
- break;
- case 'N':
- case 'C':
- /* field length */
- if (zend_hash_index_find(field->value.ht,2,(void **)&value) == FAILURE) {
- php_error(E_WARNING, "expected field length as third element of list in field %d", i);
- free_dbf_head(dbh);
- RETURN_FALSE;
- }
- convert_to_long(value);
- cur_f->db_flen = value->value.lval;
-
- if (cur_f->db_type == 'N') {
- if (zend_hash_index_find(field->value.ht,3,(void **)&value) == FAILURE) {
- php_error(E_WARNING, "expected field precision as fourth element of list in field %d", i);
- free_dbf_head(dbh);
- RETURN_FALSE;
- }
- convert_to_long(value);
- cur_f->db_fdc = value->value.lval;
- }
- break;
- default:
- php_error(E_WARNING, "unknown field type '%c'", cur_f->db_type);
- }
- cur_f->db_foffset = rlen;
- rlen += cur_f->db_flen;
-
- cur_f->db_format = get_dbf_f_fmt(cur_f);
- }
-
- dbh->db_rlen = rlen;
- put_dbf_info(dbh);
-
- handle = php3_list_insert(dbh, DBase_GLOBAL(le_dbhead));
- RETURN_LONG(handle);
-}
-/* }}} */
-
-function_entry dbase_functions[] = {
- PHP_FE(dbase_open, NULL)
- PHP_FE(dbase_create, NULL)
- PHP_FE(dbase_close, NULL)
- PHP_FE(dbase_numrecords, NULL)
- PHP_FE(dbase_numfields, NULL)
- PHP_FE(dbase_add_record, NULL)
- PHP_FE(dbase_replace_record, NULL)
- PHP_FE(dbase_get_record, NULL)
- PHP_FE(dbase_get_record_with_names, NULL)
- PHP_FE(dbase_delete_record, NULL)
- PHP_FE(dbase_pack, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry dbase_module_entry = {
- "DBase", dbase_functions, PHP_MINIT(dbase), PHP_MSHUTDOWN(dbase), NULL, NULL, NULL, STANDARD_MODULE_PROPERTIES
-};
-
-
-#if defined(COMPILE_DL)
-DLEXPORT php3_module_entry *get_module(void) { return &dbase_module_entry; }
-
-#if (WIN32|WINNT) && defined(THREAD_SAFE)
-
-/*NOTE: You should have an odbc.def file where you
-export DllMain*/
-BOOL WINAPI DllMain(HANDLE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved)
-{
- return 1;
-}
-#endif
-#endif
-
-#endif
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/dbase/dbf.h b/ext/dbase/dbf.h
deleted file mode 100644
index 08bc70dd41..0000000000
--- a/ext/dbase/dbf.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 1991, 1992, 1993 Brad Eacker,
- * (Music, Intuition, Software, and Computers)
- * All Rights Reserved
- */
-
-/*
- * dbf header structure on disk (pc dbase III)
- *
- * Basic info taken from:
- * "File Formats for Popular PC Software"
- * Jeff Walden
- * (c) 1986 John Wiley & Sons, Inc.
- */
-
-#ifndef _DBF_H_
-#define _DBF_H_
-
-#include <stdlib.h>
-#include <string.h>
-#ifdef WIN32
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-/* So we can use O_BINARY on non-Win32 systems. */
-#if !defined(O_BINARY) && !defined(WIN32)
-#define O_BINARY (0)
-#endif
-
-struct dbf_dhead {
- char dbh_dbt; /* memo (dbt) file present */
- char dbh_date[3]; /* last update YY, MM, DD */
- char dbh_records[4]; /* number of records LE */
- char dbh_hlen[2]; /* header length LE */
- char dbh_rlen[2]; /* record length LE */
- char dbh_res[20]; /* padding */
-};
-#define DBH_DATE_YEAR 0 /* byte offset for year in dbh_date */
-#define DBH_DATE_MONTH 1
-#define DBH_DATE_DAY 2
-
-/*
- * field description on disk
- */
-
-#define DBF_NAMELEN 11
-
-struct dbf_dfield {
- char dbf_name[DBF_NAMELEN]; /* name of field */
- char dbf_type; /* type of field */
- char dbf_fda[4]; /* something for dbase III */
- char dbf_flen[2]; /* field length [and decimal if N] */
- char dbf_res[14]; /* padding */
-};
-
-struct db_field {
- char db_fname[DBF_NAMELEN+1]; /* 0 terminated */
- char db_type; /* type of field */
- int db_flen; /* length of field */
- int db_fdc; /* number of decimals in field */
-
- char *db_format; /* format for printing %s etc */
- int db_foffset; /* offset within record */
-};
-typedef struct db_field dbfield_t;
-
-struct db_head {
- int db_fd;
- unsigned char db_dbt; /* dbt present */
- char db_date[9]; /* date of last update in db format */
- long db_records; /* number of records */
- int db_hlen; /* header length */
- int db_rlen; /* record length */
-
- int db_nfields; /* number of fields */
- dbfield_t *db_fields; /* field info */
- char *db_name; /* name of dbf file */
- int db_cur_rec; /* current record */
-};
-typedef struct db_head dbhead_t;
-
-#define DBH_TYPE_NORMAL 0x03
-#define DBH_TYPE_MEMO 0x83
-
-#define VALID_RECORD ' '
-#define DELETED_RECORD '*'
-
-#include "dbf_head.h"
-#include "dbf_misc.h"
-#include "dbf_rec.h"
-
-#endif /* _DBF_H_ */
diff --git a/ext/dbase/dbf_head.c b/ext/dbase/dbf_head.c
deleted file mode 100644
index 1f104e3d81..0000000000
--- a/ext/dbase/dbf_head.c
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Copyright (c) 1991, 1992, 1993 Brad Eacker,
- * (Music, Intuition, Software, and Computers)
- * All Rights Reserved
- */
-
-#include <stdio.h>
-#include <fcntl.h>
-
-#include "dbf.h"
-
-void free_dbf_head(dbhead_t *dbh);
-int get_dbf_field(dbhead_t *dbh, dbfield_t *dbf);
-
-/*
- * get the header info from the file
- * basic header info & field descriptions
- */
-dbhead_t *get_dbf_head(int fd)
-{
- dbhead_t *dbh;
- struct dbf_dhead dbhead;
- dbfield_t *dbf, *cur_f;
- int ret, nfields, offset;
-
- if ((dbh = (dbhead_t *)malloc(sizeof(dbhead_t))) == NULL)
- return NULL;
- if (lseek(fd, 0, 0) < 0)
- return NULL;
- if ((ret = read(fd, &dbhead, sizeof(dbhead))) < 0)
- return NULL;
-
- /* build in core info */
- dbh->db_fd = fd;
- dbh->db_dbt = dbhead.dbh_dbt;
- dbh->db_records = get_long(dbhead.dbh_records);
- dbh->db_hlen = get_short(dbhead.dbh_hlen);
- dbh->db_rlen = get_short(dbhead.dbh_rlen);
-
- db_set_date(dbh->db_date, dbhead.dbh_date[DBH_DATE_YEAR] + 1900,
- dbhead.dbh_date[DBH_DATE_MONTH],
- dbhead.dbh_date[DBH_DATE_DAY]);
-
- dbh->db_nfields = nfields = (dbh->db_hlen - sizeof(struct dbf_dhead)) /
- sizeof(struct dbf_dfield);
-
- /* get all the field info */
- dbf = (dbfield_t *)malloc(sizeof(dbfield_t) * nfields);
-
- offset = 1;
- for (cur_f = dbf; cur_f < &dbf[nfields] ; cur_f++) {
- if (get_dbf_field(dbh, cur_f) < 0) {
- free_dbf_head(dbh);
- return NULL;
- }
- cur_f->db_foffset = offset;
- offset += cur_f->db_flen;
- }
- dbh->db_fields = dbf;
-
- return dbh;
-}
-
-/*
- * free up the header info built above
- */
-void free_dbf_head(dbhead_t *dbh)
-{
- dbfield_t *dbf, *cur_f;
- int nfields;
-
- dbf = dbh->db_fields;
- nfields = dbh->db_nfields;
- for (cur_f = dbf; cur_f < &dbf[nfields]; cur_f++) {
- if (cur_f->db_format) {
- free(cur_f->db_format);
- }
- }
-
- free(dbf);
- free(dbh);
-}
-
-/*
- * put out the header info
- */
-int put_dbf_head(dbhead_t *dbh)
-{
- int fd = dbh->db_fd;
- struct dbf_dhead dbhead;
- int ret;
-
- memset (&dbhead, 0, sizeof(dbhead));
-
- /* build on disk info */
- dbhead.dbh_dbt = dbh->db_dbt;
- put_long(dbhead.dbh_records, dbh->db_records);
- put_short(dbhead.dbh_hlen, dbh->db_hlen);
- put_short(dbhead.dbh_rlen, dbh->db_rlen);
-
- /* put the date spec'd into the on disk header */
- dbhead.dbh_date[DBH_DATE_YEAR] =(char)(db_date_year(dbh->db_date) -
- 1900);
- dbhead.dbh_date[DBH_DATE_MONTH]=(char)(db_date_month(dbh->db_date));
- dbhead.dbh_date[DBH_DATE_DAY] =(char)(db_date_day(dbh->db_date));
-
- if (lseek(fd, 0, 0) < 0)
- return -1;
- if ((ret = write(fd, &dbhead, sizeof(dbhead))) < 0)
- return -1;
- return ret;
-}
-
-/*
- * get a field off the disk from the current file offset
- */
-int get_dbf_field(dbhead_t *dbh, dbfield_t *dbf)
-{
- struct dbf_dfield dbfield;
- int ret;
-
- if ((ret = read(dbh->db_fd, &dbfield, sizeof(dbfield))) < 0) {
- return ret;
- }
-
- /* build the field name */
- copy_crimp(dbf->db_fname, dbfield.dbf_name, DBF_NAMELEN);
-
- dbf->db_type = dbfield.dbf_type;
- switch (dbf->db_type) {
- case 'N':
- dbf->db_flen = dbfield.dbf_flen[0];
- dbf->db_fdc = dbfield.dbf_flen[1];
- break;
- default:
- dbf->db_flen = get_short(dbfield.dbf_flen);
- }
-
- if ((dbf->db_format = get_dbf_f_fmt(dbf)) == NULL) {
- return 1;
- }
-
- return 0;
-}
-
-/*
- * put a field out on the disk at the current file offset
- */
-int put_dbf_field(dbhead_t *dbh, dbfield_t *dbf)
-{
- struct dbf_dfield dbfield;
- char *scp, *dcp;
- int ret;
-
- memset (&dbfield, 0, sizeof(dbfield));
-
- /* build the on disk field info */
- scp = dbf->db_fname; dcp = dbfield.dbf_name;
-
- strncpy(dbfield.dbf_name, dbf->db_fname, DBF_NAMELEN);
-
- dbfield.dbf_type = dbf->db_type;
- switch (dbf->db_type) {
- case 'N':
- dbfield.dbf_flen[0] = dbf->db_flen;
- dbfield.dbf_flen[1] = dbf->db_fdc;
- break;
- default:
- put_short(dbfield.dbf_flen, dbf->db_flen);
- }
-
- /* now write it out to disk */
- if ((ret = write(dbh->db_fd, &dbfield, sizeof(dbfield))) < 0) {
- return ret;
- }
- return 1;
-}
-
-/*
- * put out all the info at the top of the file...
- */
-static char end_stuff[2] = {0x0d, 0};
-
-void put_dbf_info(dbhead_t *dbh)
-{
- dbfield_t *dbf;
- char *cp;
- int fcnt;
-
- if ((cp = db_cur_date(NULL))) {
- strncpy(dbh->db_date, cp, 8);
- free(cp);
- }
- put_dbf_head(dbh);
- dbf = dbh->db_fields;
- for (fcnt = dbh->db_nfields; fcnt > 0; fcnt--, dbf++)
- put_dbf_field(dbh, dbf);
- write(dbh->db_fd, end_stuff, 1);
-}
-
-char *get_dbf_f_fmt(dbfield_t *dbf)
-{
- char format[100];
-
- /* build the field format for printf */
- switch (dbf->db_type) {
- case 'C':
- sprintf(format, "%%-%ds", dbf->db_flen);
- break;
- case 'N':
- case 'L':
- case 'D':
- sprintf(format, "%%%ds", dbf->db_flen);
- break;
- case 'M':
- strcpy(format, "%s");
- break;
- }
- return (char *)strdup(format);
-}
-
-dbhead_t *dbf_open(char *dp, int o_flags)
-{
- int fd;
- char *cp;
- dbhead_t *dbh;
-
- cp = dp;
- if ((fd = open(cp, o_flags|O_BINARY)) < 0) {
- cp = (char *)malloc(256);
- strcpy(cp, dp); strcat(cp, ".dbf");
- if ((fd = open(cp, o_flags)) < 0) {
- perror("open");
- return NULL;
- }
- }
-
- if ((dbh = get_dbf_head(fd)) == 0) {
- fprintf(stderr, "Unable to get header\n");
- return NULL;
- }
- dbh->db_name = cp;
- dbh->db_cur_rec = 0;
-
- return dbh;
-}
-
-void dbf_head_info(dbhead_t *dbh)
-{
- int nfields;
- dbfield_t *dbf, *cur_f;
-
- nfields = dbh->db_nfields;
- printf("# fields: %d, record len: %d, total records %ld\n",
- nfields, dbh->db_rlen, dbh->db_records);
- dbf = dbh->db_fields;
- for (cur_f = dbf; cur_f < &dbf[nfields] ; cur_f++) {
- printf("# %s, %c, %d, %d\n", cur_f->db_fname,
- cur_f->db_type, cur_f->db_flen, cur_f->db_fdc);
- }
-}
diff --git a/ext/dbase/dbf_head.h b/ext/dbase/dbf_head.h
deleted file mode 100644
index 1643151dd1..0000000000
--- a/ext/dbase/dbf_head.h
+++ /dev/null
@@ -1,9 +0,0 @@
-extern dbhead_t *get_dbf_head(int fd);
-void free_dbf_head(dbhead_t *dbh);
-extern int put_dbf_head(dbhead_t *dbh);
-extern int get_dbf_field(dbhead_t *dbh, dbfield_t *dbf);
-extern int put_dbf_field(dbhead_t *dbh, dbfield_t *dbf);
-void put_dbf_info(dbhead_t *dbh);
-extern char *get_dbf_f_fmt(dbfield_t *dbf);
-extern dbhead_t *dbf_open(char *dp, int o_flags);
-void dbf_head_info(dbhead_t *dbh);
diff --git a/ext/dbase/dbf_misc.c b/ext/dbase/dbf_misc.c
deleted file mode 100644
index 84573e47a4..0000000000
--- a/ext/dbase/dbf_misc.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 1991, 1992, 1993 Brad Eacker,
- * (Music, Intuition, Software, and Computers)
- * All Rights Reserved
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-
-#include "dbf_misc.h"
-
-/*
- * routine to change little endian long to host long
- */
-long get_long(char *cp)
-{
- int ret;
- unsigned char *source = (unsigned char *)cp;
-
- ret = *source++;
- ret += ((*source++)<<8);
- ret += ((*source++)<<16);
- ret += ((*source++)<<24);
-
- return ret;
-}
-
-void put_long(char *cp, long lval)
-{
- *cp++ = lval & 0xff;
- *cp++ = (lval >> 8) & 0xff;
- *cp++ = (lval >> 16) & 0xff;
- *cp++ = (lval >> 24) & 0xff;
-}
-
-/*
- * routine to change little endian short to host short
- */
-int get_short(char *cp)
-{
- int ret;
- unsigned char *source = (unsigned char *)cp;
-
- ret = *source++;
- ret += ((*source++)<<8);
-
- return ret;
-}
-
-void put_short(char *cp, int sval)
-{
- *cp++ = sval & 0xff;
- *cp++ = (sval >> 8) & 0xff;
-}
-
-double get_double(char *cp)
-{
- double ret;
- unsigned char *dp = (unsigned char *)&ret;
-
- dp[7] = *cp++;
- dp[6] = *cp++;
- dp[5] = *cp++;
- dp[4] = *cp++;
- dp[3] = *cp++;
- dp[2] = *cp++;
- dp[1] = *cp++;
- dp[0] = *cp++;
-
- return ret;
-}
-
-void put_double(char *cp, double fval)
-{
- unsigned char *dp = (unsigned char *)&fval;
-
- cp[7] = *dp++;
- cp[6] = *dp++;
- cp[5] = *dp++;
- cp[4] = *dp++;
- cp[3] = *dp++;
- cp[2] = *dp++;
- cp[1] = *dp++;
- cp[0] = *dp++;
-}
-
-void copy_fill(char *dp, char *sp, int len)
-{
- while (*sp && len > 0) {
- *dp++ = *sp++;
- len--;
- }
- while (len-- > 0)
- *dp++ = ' ';
-}
-
-void copy_crimp(char *dp, char *sp, int len)
-{
- while (len-- > 0) {
- *dp++ = *sp++;
- }
- *dp = 0;
- for (dp-- ; *dp == ' '; dp--) {
- *dp = 0;
- }
-
-}
-
-void db_set_date(char *cp, int year, int month, int day)
-{
- if (month > 12)
- month = 0;
- if (day > 31)
- day = 0;
- sprintf(cp, "%d", year);
- cp[4] = month / 10 + '0';
- cp[5] = month % 10 + '0';
- cp[6] = day / 10 + '0';
- cp[7] = day % 10 + '0';
- cp[8] = 0;
-}
-
-int db_date_year(char *cp)
-{
- int year, i;
-
- for (year = 0, i = 0; i < 4; i++)
- year = year * 10 + (cp[i] - '0');
- return year;
-}
-
-int db_date_month(char *cp)
-{
- int month, i;
-
- for (month = 0, i = 4; i < 6; i++)
- month = month * 10 + (cp[i] - '0');
- return month;
-}
-
-int db_date_day(char *cp)
-{
- int day, i;
-
- for (day = 0, i = 6; i < 8; i++)
- day = day * 10 + (cp[i] - '0');
- return day;
-}
-
-#include <time.h>
-
-char *db_cur_date(char *cp)
-{
- struct tm *ctm;
- time_t c_time;
-
- c_time = time((time_t *)NULL);
- ctm = localtime(&c_time);
- if (cp == NULL)
- cp = (char *)malloc(9);
-
- if (ctm == NULL || cp == NULL)
- return NULL;
-
- db_set_date(cp, ctm->tm_year + 1900, ctm->tm_mon + 1, ctm->tm_mday);
-
- return cp;
-}
diff --git a/ext/dbase/dbf_misc.h b/ext/dbase/dbf_misc.h
deleted file mode 100644
index 37fe8b0ea9..0000000000
--- a/ext/dbase/dbf_misc.h
+++ /dev/null
@@ -1,13 +0,0 @@
-void put_long(char *cp, long lval);
-extern long get_long(char *cp);
-extern int get_short(char *cp);
-void put_short(char *cp, int sval);
-void put_double(char *cp, double fval);
-extern double get_double(char *cp);
-void copy_fill(char *dp, char *sp, int len);
-void copy_crimp(char *dp, char *sp, int len);
-void db_set_date(char *cp, int year, int month, int day);
-extern int db_date_year(char *cp);
-extern int db_date_month(char *cp);
-extern int db_date_day(char *cp);
-extern char *db_cur_date(char *cp);
diff --git a/ext/dbase/dbf_ndx.c b/ext/dbase/dbf_ndx.c
deleted file mode 100644
index 9263b02b0c..0000000000
--- a/ext/dbase/dbf_ndx.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (c) 1991, 1992, 1993 Brad Eacker,
- * (Music, Intuition, Software, and Computers)
- * All Rights Reserved
- */
-
-#include <stdio.h>
-#include <fcntl.h>
-
-#include "dbf.h"
-#include "dbf_ndx.h"
-
-/*
- * get the ndx header for this file
- */
-ndx_header_t *ndx_get_header(int fd)
-{
- dndx_header_t *dp;
- ndx_header_t *np;
-
- if ((dp = (dndx_header_t *)malloc(NDX_PAGE_SZ)) == NULL)
- return NULL;
- if ((np = (ndx_header_t *)malloc(sizeof(ndx_header_t))) == NULL) {
- free(dp);
- return NULL;
- }
- if ((lseek(fd, 0, 0) < 0) || (read(fd, dp, NDX_PAGE_SZ) < 0)) {
- free(dp); free(np);
- return NULL;
- }
- np->ndx_hpage = dp;
- np->ndx_fd = fd;
- np->ndx_start_pg = get_long(dp->dndx_st_pg);
- np->ndx_total_pgs = get_long(dp->dndx_tot_pg);
- np->ndx_key_len = get_short(dp->dndx_key_len);
- np->ndx_keys_ppg = get_short(dp->dndx_keys_ppg);
- np->ndx_key_type = get_short(dp->dndx_key_type);
- np->ndx_key_size = get_long(dp->dndx_size_key);
- np->ndx_key_name = dp->dndx_key_name;
- np->ndx_unique = dp->dndx_unique;
-
- np->ndx_fp = NULL;
-
- return np;
-}
-
-static ndx_page_t *ndx_get_page(ndx_header_t *hp, int pageno)
-{
- ndx_page_t *fp;
- dndx_page_t *dp;
- ndx_record_t *rp;
-
-#if DEBUG
- printf("getting page %d", pageno);
-#endif
- if ((fp = (ndx_page_t *)malloc(sizeof(ndx_page_t))) == NULL)
- return NULL;
- if ((dp = (dndx_page_t *)malloc(NDX_PAGE_SZ)) == NULL) {
- free(fp);
- return NULL;
- }
- if ((rp = (ndx_record_t *)malloc(sizeof(ndx_record_t) * hp->ndx_keys_ppg)) == NULL) {
- free(dp); free(fp);
- return NULL;
- }
- fp->ndxp_page_data = dp;
- if ((lseek(hp->ndx_fd, pageno * NDX_PAGE_SZ, 0) < 0) ||
- (read(hp->ndx_fd, dp, NDX_PAGE_SZ) < 0)) {
- free(fp); free(dp);
- return NULL;
- }
- fp->ndxp_parent = NULL;
- fp->ndxp_page_no = pageno;
- fp->ndxp_num_keys = get_long(dp->dndxp_num_keys);
- memset(rp, 0, sizeof(ndx_record_t) * hp->ndx_keys_ppg);
- fp->ndxp_records = rp;
- fp->ndxp_header_p = hp;
-#if DEBUG
- printf(", n_keys %ld\n", fp->ndxp_num_keys);
-#endif
- return fp;
-}
-
-/*
- * get the first entry for this ndx
- */
-static ndx_page_t *ndx_get_first_pg(ndx_header_t *hp)
-{
- ndx_page_t *fp;
-
- if (hp->ndx_fp)
- return hp->ndx_fp;
- if ((fp = ndx_get_page(hp, hp->ndx_start_pg))) {
- hp->ndx_fp = fp;
- }
- return fp;
-}
-
-static ndx_record_t *ndx_get_record(ndx_page_t *fp, int rec_no)
-{
- ndx_record_t *rp;
- ndx_header_t *hp = fp->ndxp_header_p;
- struct dndx_record *drp;
-
-#if DEBUG
- printf("page %ld, rec %d: ", fp->ndxp_page_no, rec_no);
-#endif
- if (rec_no >= fp->ndxp_num_keys)
- return NULL;
- rp = &(fp->ndxp_records[rec_no]);
- if (!rp->ndxr_page) {
- rp->ndxr_page = fp;
- drp = (dndx_record_t *)((char *)&fp->ndxp_page_data->dndx_rp
- + rec_no * hp->ndx_key_size);
- rp->ndxr_left = get_long(drp->dndx_left_pg);
- rp->ndxr_rec = get_long(drp->dndx_dbf_rec);
- rp->ndxr_key_data = &drp->dndx_key_data;
- rp->ndxr_p_nrec = rec_no;
- }
-#if DEBUG
- printf("left %ld, dbf_rec %ld, data '%s'\n", rp->ndxr_left,
- rp->ndxr_rec, rp->ndxr_key_data);
-#endif
- return rp;
-}
-
-static ndx_record_t *ndx_scan_down(ndx_header_t *hp, ndx_page_t *fp, int recno)
-{
- ndx_page_t *np;
- ndx_record_t *rp;
-
- while ((rp = ndx_get_record(fp, recno)) && (rp->ndxr_rec == 0)) {
- np = ndx_get_page(hp, rp->ndxr_left);
- np->ndxp_parent = fp;
- np->ndxp_par_rno = recno;
- fp = np;
- recno = 0;
- }
- return rp;
-}
-
-static ndx_record_t *ndx_scan_up(ndx_header_t *hp, ndx_page_t *fp, int recno)
-{
- ndx_record_t *rp;
-
- if (fp == NULL)
- rp = NULL;
- else if (recno < fp->ndxp_num_keys) {
- rp = ndx_scan_down(hp, fp, recno);
- } else {
- rp = ndx_scan_up(hp, fp->ndxp_parent, fp->ndxp_par_rno + 1);
- }
- return rp;
-}
-
-ndx_record_t *ndx_get_first_rec(ndx_header_t *hp)
-{
- ndx_page_t *fp;
- ndx_record_t *rp = NULL;
-
- if ((fp = ndx_get_first_pg(hp))) {
- fp->ndxp_last_key = 0;
- rp = ndx_scan_down(hp, fp, 0);
- }
- hp->ndx_cur_rec = rp;
- return rp;
-}
-
-ndx_record_t *ndx_get_next_rec(ndx_header_t *hp, ndx_record_t *rp)
-{
- ndx_page_t *fp;
- int rec_no;
-
- fp = rp->ndxr_page;
- rec_no = rp->ndxr_p_nrec + 1;
- if (rec_no < fp->ndxp_num_keys) {
- rp = ndx_scan_down(hp, fp, rec_no);
- } else {
- rp = ndx_scan_up(hp, fp->ndxp_parent, fp->ndxp_par_rno + 1);
- }
- return rp;
-}
-
diff --git a/ext/dbase/dbf_ndx.h b/ext/dbase/dbf_ndx.h
deleted file mode 100644
index 3faff04025..0000000000
--- a/ext/dbase/dbf_ndx.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 1993 Brad Eacker,
- * (Music, Intuition, Software, and Computers)
- * All Rights Reserved
- */
-
-/*
- * dbf .ndx header structure on disk and in memory
- *
- * Basic info taken from:
- * "Clipper Programming Guide, 3rd Edition, Version 5.01"
- * by Rick Spence
- */
-
-#ifndef _DBF_NDX_H_
-#define _DBF_NDX_H_
-
-#include "dbf.h"
-
-#define NDX_PAGE_SZ 512
-
-/* on disk ndx header */
-struct dndx_header {
- char dndx_st_pg[4]; /* starting page number */
- char dndx_tot_pg[4]; /* total number of pages */
- char dndx_filler1[4]; /* space */
- char dndx_key_len[2]; /* key length */
- char dndx_keys_ppg[2]; /* number of keys per page */
- char dndx_key_type[2]; /* key type */
- char dndx_size_key[4]; /* size of the key record */
- char dndx_filler2; /* space */
- char dndx_unique; /* whether or not done with unique */
- char dndx_key_name[488]; /* string defining the key */
-};
-typedef struct dndx_header dndx_header_t;
-
-/* in memory ndx header */
-struct ndx_header {
- long ndx_start_pg;
- long ndx_total_pgs;
- unsigned short ndx_key_len;
- unsigned short ndx_keys_ppg;
- unsigned short ndx_key_type;
- char ndx_unique;
- long ndx_key_size;
- char *ndx_key_name;
- int ndx_fd;
- struct ndx_page *ndx_fp;
- dndx_header_t *ndx_hpage;
- struct ndx_record *ndx_cur_rec;
-};
-typedef struct ndx_header ndx_header_t;
-
-/* these are the possible values in the key type field */
-#define NDX_CHAR_TYPE 00
-#define NDX_NUM_TYPE 01
-
-/* on disk key record */
-struct dndx_record {
- char dndx_left_pg[4]; /* number of left page */
- char dndx_dbf_rec[4]; /* dbf record number */
- char dndx_key_data; /* key data */
-};
-typedef struct dndx_record dndx_record_t;
-
-struct ndx_record {
- long ndxr_left;
- long ndxr_rec;
- char *ndxr_key_data;
- struct ndx_page *ndxr_page; /* page pointer to where we are from*/
- int ndxr_p_nrec; /* number of the record within page */
-};
-typedef struct ndx_record ndx_record_t;
-
-struct dndx_page {
- char dndxp_num_keys[4]; /* number of keys on this page */
- struct dndx_record dndx_rp;
-};
-typedef struct dndx_page dndx_page_t;
-
-struct ndx_page {
- long ndxp_page_no;
- long ndxp_num_keys;
- dndx_page_t *ndxp_page_data;
- ndx_header_t *ndxp_header_p;
- long ndxp_last_key;
- struct ndx_page *ndxp_parent; /* parent page */
- int ndxp_par_rno; /* record number within parent */
- struct ndx_record *ndxp_records;
-};
-typedef struct ndx_page ndx_page_t;
-
-extern ndx_header_t *ndx_get_header(int);
-
-extern ndx_record_t *ndx_get_first_rec(ndx_header_t *);
-extern ndx_record_t *ndx_get_next_rec(ndx_header_t *, ndx_record_t *);
-
-#endif /* _DBF_NDX_H_ */
diff --git a/ext/dbase/dbf_rec.c b/ext/dbase/dbf_rec.c
deleted file mode 100644
index fa342005fb..0000000000
--- a/ext/dbase/dbf_rec.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (c) 1993 Brad Eacker,
- * (Music, Intuition, Software, and Computers)
- * All Rights Reserved
- */
-
-#include <stdio.h>
-#include <fcntl.h>
-
-#include "dbf.h"
-
-int get_piece(dbhead_t *dbh, long offset, char *cp, int len);
-int put_piece(dbhead_t *dbh, long offset, char *cp, int len);
-
-/*
- * get a record off the database
- */
-char *get_dbf_record(dbhead_t *dbh, long rec_num)
-{
- long offset;
- char *cp;
-
- if (rec_num > dbh->db_records) {
- return NULL;
- }
- if ((cp = (char *)malloc(dbh->db_rlen)) == NULL) {
- return NULL;
- }
-
- /* go to the correct spot on the file */
- offset = dbh->db_hlen + (rec_num - 1) * dbh->db_rlen;
- if (get_piece(dbh, offset, cp, dbh->db_rlen) != dbh->db_rlen) {
- free(cp);
- cp = NULL;
- }
- if (cp)
- dbh->db_cur_rec = rec_num;
- return cp;
-}
-
-int
-get_piece(dbhead_t *dbh, long offset, char *cp, int len)
-{
- /* go to the correct spot on the file */
- if ( lseek(dbh->db_fd, offset, 0) < 0 ) {
- return -1;
- }
-
- /* read the record into the allocated space */
- return read(dbh->db_fd, cp, len);
-}
-
-/*
- * put a record to the database
- */
-long put_dbf_record(dbhead_t *dbh, long rec_num, char *cp)
-{
- long offset;
-
- if (rec_num == 0) {
- rec_num = dbh->db_records;
- }
- if (rec_num > dbh->db_records) {
- return 0L;
- }
- /* go to the correct spot on the file */
- offset = dbh->db_hlen + (rec_num - 1) * dbh->db_rlen;
- if (put_piece(dbh, offset, cp, dbh->db_rlen) != dbh->db_rlen) {
- rec_num = -1;
- }
- return rec_num;
-}
-
-int put_piece(dbhead_t *dbh, long offset, char *cp, int len)
-{
- /* go to the correct spot on the file */
- if ( lseek(dbh->db_fd, offset, 0) < 0 ) {
- return -1;
- }
-
- /* write the record into the file */
- return write(dbh->db_fd, cp, len);
-}
-
-int del_dbf_record(dbhead_t *dbh, long rec_num)
-{
- int ret = 0;
- char *cp;
-
- if (rec_num > dbh->db_records)
- return -1;
- if ((cp = get_dbf_record(dbh, rec_num))) {
- *cp = DELETED_RECORD;
- ret = put_dbf_record(dbh, rec_num, cp);
- free(cp);
- }
- return ret;
-}
-
-void pack_dbf(dbhead_t *dbh)
-{
- long out_off, in_off;
- int rec_cnt, new_cnt;
- char *cp;
-
- if ((cp = (char *)malloc(dbh->db_rlen)) == NULL) {
- return;
- }
- in_off = out_off = dbh->db_hlen;
-
- new_cnt = 0;
- rec_cnt = dbh->db_records;
- while (rec_cnt > 0) {
- if (get_piece(dbh, in_off, cp, dbh->db_rlen) < 0)
- break;
-
- if (*cp != DELETED_RECORD) {
- /* write the record into the file */
- if (put_piece(dbh, out_off, cp, dbh->db_rlen) < 0)
- break;
- out_off += dbh->db_rlen;
- new_cnt++;
- }
- in_off += dbh->db_rlen;
- rec_cnt--;
- }
- free(cp);
- if (rec_cnt == 0)
- dbh->db_records = new_cnt;
-}
-
-/* routine to get a field from a record */
-char *get_field_val(char *rp, dbfield_t *fldp, char *cp)
-{
- int flen = fldp->db_flen;
-
- if ( !cp )
- cp = (char *)malloc(flen + 1);
- if ( cp ) {
- strncpy(cp, &rp[fldp->db_foffset], flen);
- cp[flen] = 0;
- }
- return cp;
-}
-
-void put_field_val(char *rp, dbfield_t *fldp, char *cp)
-{
- strncpy(&rp[fldp->db_foffset], cp, fldp->db_flen);
-}
-
-/*
- * output a record
- */
-void out_rec(dbhead_t *dbh, dbfield_t *dbf, char *cp)
-{
- dbfield_t *cur_f;
- int nfields = dbh->db_nfields;
- char *fnp = (char *)malloc(dbh->db_rlen);
-
- printf("%c", *cp);
- for (cur_f = dbf; cur_f < &dbf[nfields] ; cur_f++) {
- printf(" ");
- printf(cur_f->db_format, get_field_val(cp, cur_f, fnp));
- }
- printf("\n");
- free(fnp);
-}
-
-/* check for record validity */
-int is_valid_rec(char *cp)
-{
- if (cp && (*cp == VALID_RECORD))
- return 1;
- else
- return 0;
-}
-
-/* get the next record */
-char *dbf_get_next(dbhead_t *dbh)
-{
- return get_dbf_record(dbh, dbh->db_cur_rec + 1);
-}
diff --git a/ext/dbase/dbf_rec.h b/ext/dbase/dbf_rec.h
deleted file mode 100644
index 6407c702f6..0000000000
--- a/ext/dbase/dbf_rec.h
+++ /dev/null
@@ -1,10 +0,0 @@
-extern char *get_dbf_record(dbhead_t *dbh, long rec_num);
-extern long put_dbf_record(dbhead_t *dbh, long rec_num, char *cp);
-extern int put_piece(dbhead_t *dbh, long offset, char *cp, int len);
-extern int del_dbf_record(dbhead_t *dbh, long rec_num);
-void pack_dbf(dbhead_t *dbh);
-extern char *get_field_val(char *rp, dbfield_t *fldp, char *cp);
-void put_field_val(char *rp, dbfield_t *fldp, char *cp);
-void out_rec(dbhead_t *dbh, dbfield_t *dbf, char *cp);
-extern int is_valid_rec(char *cp);
-extern char *dbf_get_next(dbhead_t *dbh);
diff --git a/ext/dbase/php_dbase.h b/ext/dbase/php_dbase.h
deleted file mode 100644
index 1f083e7b3a..0000000000
--- a/ext/dbase/php_dbase.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Jim Winstead (jimw@php.net) |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _DBASE_H
-#define _DBASE_H
-#if DBASE
-extern php3_module_entry dbase_module_entry;
-#define dbase_module_ptr &dbase_module_entry
-
-extern PHP_MINIT_FUNCTION(dbase);
-PHP_FUNCTION(dbase_open);
-PHP_FUNCTION(dbase_create);
-PHP_FUNCTION(dbase_close);
-PHP_FUNCTION(dbase_numrecords);
-PHP_FUNCTION(dbase_numfields);
-PHP_FUNCTION(dbase_add_record);
-PHP_FUNCTION(dbase_get_record);
-PHP_FUNCTION(dbase_delete_record);
-PHP_FUNCTION(dbase_pack);
-PHP_FUNCTION(dbase_get_record_with_names);
-#else
-#define dbase_module_ptr NULL
-#endif
-
-#define phpext_dbase_ptr dbase_module_ptr
-
-#endif /* _DBASE_H */
diff --git a/ext/dbase/setup.stub b/ext/dbase/setup.stub
deleted file mode 100644
index 427ecf069d..0000000000
--- a/ext/dbase/setup.stub
+++ /dev/null
@@ -1,4 +0,0 @@
-# $Id$ -*- sh -*-
-
-define_option with-dbase 'dBase support? ' yesno no \
-' Whether to use the bundled dbase library.'
diff --git a/ext/ereg/ereg.c b/ext/ereg/ereg.c
deleted file mode 100644
index 6382cfd739..0000000000
--- a/ext/ereg/ereg.c
+++ /dev/null
@@ -1,650 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Jim Winstead <jimw@php.net> |
- | Jaakko Hyvätti <jaakko@hyvatti.iki.fi> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include <stdio.h>
-#include "php.h"
-#include "php3_string.h"
-#include "php_regex.h"
-#include "reg.h"
-
-unsigned char third_argument_force_ref[] = { 3, BYREF_NONE, BYREF_NONE, BYREF_FORCE };
-
-function_entry reg_functions[] = {
- PHP_FE(ereg, third_argument_force_ref)
- PHP_FE(ereg_replace, NULL)
- PHP_FE(eregi, third_argument_force_ref)
- PHP_FE(eregi_replace, NULL)
- PHP_FE(split, NULL)
- PHP_FALIAS(join, implode, NULL)
- PHP_FE(sql_regcase, NULL)
- {NULL, NULL, NULL}
-};
-
-
-static PHP_MINIT_FUNCTION(regex);
-static PHP_MSHUTDOWN_FUNCTION(regex);
-static PHP_MINFO_FUNCTION(regex);
-
-zend_module_entry regexp_module_entry = {
- "Regular Expressions",
- reg_functions,
- PHP_MINIT(regex), PHP_MSHUTDOWN(regex),
- NULL, NULL, PHP_MINFO(regex),
- STANDARD_MODULE_PROPERTIES
-};
-
-#ifdef ZTS
-int reg_globals_id;
-#else
-static php_reg_globals reg_globals;
-#endif
-
-typedef struct {
- regex_t preg;
- int cflags;
-} reg_cache;
-
-static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
-{
- int r = 0;
- int patlen = strlen(pattern);
- reg_cache *rc = NULL;
- REGLS_FETCH();
-
- if(zend_hash_find(&REG(ht_rc), (char *) pattern, patlen+1, (void **) &rc) == FAILURE ||
- rc->cflags != cflags) {
- r = regcomp(preg, pattern, cflags);
- if(!r) {
- reg_cache rcp;
-
- rcp.cflags = cflags;
- memcpy(&rcp.preg, preg, sizeof(*preg));
- zend_hash_update(&REG(ht_rc), (char *) pattern, patlen+1,
- (void *) &rcp, sizeof(rcp), NULL);
- }
- } else {
- memcpy(preg, &rc->preg, sizeof(*preg));
- }
-
- return r;
-}
-
-static int _free_reg_cache(reg_cache *rc)
-{
- regfree(&rc->preg);
- return 1;
-}
-
-#define regfree(a);
-#define regcomp(a,b,c) _php_regcomp(a,b,c)
-
-static void php_reg_init_globals(php_reg_globals *reg_globals)
-{
- zend_hash_init(&reg_globals->ht_rc, 0, NULL, (int (*)(void *)) _free_reg_cache, 1);
-}
-
-static PHP_MINIT_FUNCTION(regex)
-{
-#ifdef ZTS
- reg_globals_id = ts_allocate_id(sizeof(php_reg_globals), php_reg_init_globals, NULL);
-#else
- php_reg_init_globals(&reg_globals);
-#endif
-
- return SUCCESS;
-}
-
-static PHP_MSHUTDOWN_FUNCTION(regex)
-{
- REGLS_FETCH();
-
- zend_hash_destroy(&REG(ht_rc));
- return SUCCESS;
-}
-
-static PHP_MINFO_FUNCTION(regex)
-{
-#if HSREGEX
- PUTS("Bundled regex library enabled\n");
-#else
- PUTS("System regex library enabled\n");
-#endif
-}
-
-
-/* This is the maximum number of (..) constructs we'll generate from a
- call to ereg() or eregi() with the optional third argument. */
-#define NS 10
-
-/*
- * _php3_reg_eprint - convert error number to name
- */
-static void _php3_reg_eprint(int err, regex_t *re) {
- char *buf = NULL, *message = NULL;
- size_t len;
- size_t buf_len;
-
-#ifdef REG_ITOA
- /* get the length of the message */
- buf_len = regerror(REG_ITOA | err, re, NULL, 0);
- if (buf_len) {
- buf = (char *)emalloc(buf_len * sizeof(char));
- if (!buf) return; /* fail silently */
- /* finally, get the error message */
- regerror(REG_ITOA | err, re, buf, buf_len);
- }
-#else
- buf_len = 0;
-#endif
- len = regerror(err, re, NULL, 0);
- if (len) {
- message = (char *)emalloc((buf_len + len + 2) * sizeof(char));
- if (!message) {
- return; /* fail silently */
- }
- if (buf_len) {
- snprintf(message, buf_len, "%s: ", buf);
- buf_len += 1; /* so pointer math below works */
- }
- /* drop the message into place */
- regerror(err, re, message + buf_len, len);
-
- php_error(E_WARNING, "%s", message);
- }
-
- STR_FREE(buf);
- STR_FREE(message);
-}
-
-static void _php3_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
-{
- pval *regex, /* Regular expression */
- *findin, /* String to apply expression to */
- *array = NULL; /* Optional register array */
- regex_t re;
- regmatch_t subs[NS];
- int err, i, match_len, string_len;
- int copts = 0;
- off_t start, end;
- char *buf = NULL;
- char *string = NULL;
-
- if (icase)
- copts |= REG_ICASE;
-
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &regex, &findin) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- /* don't bother doing substring matching if we're not going
- to make use of the information */
- copts |= REG_NOSUB;
- break;
- case 3:
- if (getParameters(ht, 3, &regex, &findin, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- if (!ParameterPassedByReference(ht, 3)) {
- php_error(E_WARNING, "Array to be filled with values must be passed by reference.");
- RETURN_FALSE;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- }
-
-
- /* compile the regular expression from the supplied regex */
- if (regex->type == IS_STRING) {
- err = regcomp(&re, regex->value.str.val, REG_EXTENDED | copts);
- } else {
- /* we convert numbers to integers and treat them as a string */
- if (regex->type == IS_DOUBLE)
- convert_to_long(regex); /* get rid of decimal places */
- convert_to_string(regex);
- /* don't bother doing an extended regex with just a number */
- err = regcomp(&re, regex->value.str.val, copts);
- }
-
- if (err) {
- _php3_reg_eprint(err, &re);
- RETURN_FALSE;
- }
-
- /* make a copy of the string we're looking in */
- convert_to_string(findin);
- string = estrndup(findin->value.str.val, findin->value.str.len);
-
- /* actually execute the regular expression */
- err = regexec(&re, string, (size_t) NS, subs, 0);
- if (err && err != REG_NOMATCH) {
- _php3_reg_eprint(err, &re);
- regfree(&re);
- RETURN_FALSE;
- }
- match_len = 1;
-
- if (array && err != REG_NOMATCH) {
- match_len = (int) (subs[0].rm_eo - subs[0].rm_so);
- string_len = strlen(string) + 1;
-
- buf = emalloc(string_len);
- if (!buf) {
- php_error(E_WARNING, "Unable to allocate memory in _php3_ereg");
- RETURN_FALSE;
- }
-
- pval_destructor(array); /* start with clean array */
- array_init(array);
-
- for (i = 0; i < NS; i++) {
- start = subs[i].rm_so;
- end = subs[i].rm_eo;
- if (start != -1 && end > 0 && start < string_len && end < string_len && start < end) {
- add_index_stringl(array, i, string+start, end-start, 1);
- }
- }
- efree(buf);
- }
-
- efree(string);
- if (err == REG_NOMATCH) {
- RETVAL_FALSE;
- } else {
- if (match_len == 0)
- match_len = 1;
- RETVAL_LONG(match_len);
- }
- regfree(&re);
-}
-
-/* {{{ proto int ereg(string pattern, string string [, array registers])
- Regular expression match */
-PHP_FUNCTION(ereg)
-{
- _php3_ereg(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ proto int eregi(string pattern, string string [, array registers])
- Case-insensitive regular expression match */
-PHP_FUNCTION(eregi)
-{
- _php3_ereg(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-/* this is the meat and potatoes of regex replacement! */
-char *_php3_regreplace(const char *pattern, const char *replace, const char *string, int icase, int extended)
-{
- regex_t re;
- regmatch_t subs[NS];
-
- char *buf, /* buf is where we build the replaced string */
- *nbuf, /* nbuf is used when we grow the buffer */
- *walkbuf; /* used to walk buf when replacing backrefs */
- const char *walk; /* used to walk replacement string for backrefs */
- int buf_len;
- int pos, tmp, string_len, new_l;
- int err, copts = 0;
-
- string_len = strlen(string);
-
- if (icase)
- copts = REG_ICASE;
- if (extended)
- copts |= REG_EXTENDED;
- err = regcomp(&re, pattern, copts);
- if (err) {
- _php3_reg_eprint(err, &re);
- return ((char *) -1);
- }
-
- /* start with a buffer that is twice the size of the stringo
- we're doing replacements in */
- buf_len = 2 * string_len + 1;
- buf = emalloc(buf_len * sizeof(char));
- if (!buf) {
- php_error(E_WARNING, "Unable to allocate memory in _php3_regreplace");
- regfree(&re);
- return ((char *) -1);
- }
-
- err = pos = 0;
- buf[0] = '\0';
-
- while (!err) {
- err = regexec(&re, &string[pos], (size_t) NS, subs, (pos ? REG_NOTBOL : 0));
-
- if (err && err != REG_NOMATCH) {
- _php3_reg_eprint(err, &re);
- regfree(&re);
- return ((char *) -1);
- }
- if (!err) {
- /* backref replacement is done in two passes:
- 1) find out how long the string will be, and allocate buf
- 2) copy the part before match, replacement and backrefs to buf
-
- Jaakko Hyvätti <Jaakko.Hyvatti@iki.fi>
- */
-
- new_l = strlen(buf) + subs[0].rm_so; /* part before the match */
- walk = replace;
- while (*walk)
- if ('\\' == *walk
- && '0' <= walk[1] && '9' >= walk[1]
- && subs[walk[1] - '0'].rm_so > -1
- && subs[walk[1] - '0'].rm_eo > -1) {
- new_l += subs[walk[1] - '0'].rm_eo
- - subs[walk[1] - '0'].rm_so;
- walk += 2;
- } else {
- new_l++;
- walk++;
- }
-
- if (new_l + 1 > buf_len) {
- buf_len = 1 + buf_len + 2 * new_l;
- nbuf = emalloc(buf_len);
- strcpy(nbuf, buf);
- efree(buf);
- buf = nbuf;
- }
- tmp = strlen(buf);
- /* copy the part of the string before the match */
- strncat(buf, &string[pos], subs[0].rm_so);
-
- /* copy replacement and backrefs */
- walkbuf = &buf[tmp + subs[0].rm_so];
- walk = replace;
- while (*walk)
- if ('\\' == *walk
- && '0' <= walk[1] && '9' >= walk[1]
- && subs[walk[1] - '0'].rm_so > -1
- && subs[walk[1] - '0'].rm_eo > -1) {
- tmp = subs[walk[1] - '0'].rm_eo
- - subs[walk[1] - '0'].rm_so;
- memcpy (walkbuf,
- &string[pos + subs[walk[1] - '0'].rm_so],
- tmp);
- walkbuf += tmp;
- walk += 2;
- } else
- *walkbuf++ = *walk++;
- *walkbuf = '\0';
-
- /* and get ready to keep looking for replacements */
- if (subs[0].rm_so == subs[0].rm_eo) {
- if (subs[0].rm_so + pos >= string_len)
- break;
- new_l = strlen (buf) + 1;
- if (new_l + 1 > buf_len) {
- buf_len = 1 + buf_len + 2 * new_l;
- nbuf = emalloc(buf_len * sizeof(char));
- strcpy(nbuf, buf);
- efree(buf);
- buf = nbuf;
- }
- pos += subs[0].rm_eo + 1;
- buf [new_l-1] = string [pos-1];
- buf [new_l] = '\0';
- } else {
- pos += subs[0].rm_eo;
- }
- } else { /* REG_NOMATCH */
- new_l = strlen(buf) + strlen(&string[pos]);
- if (new_l + 1 > buf_len) {
- buf_len = new_l + 1; /* now we know exactly how long it is */
- nbuf = emalloc(buf_len * sizeof(char));
- strcpy(nbuf, buf);
- efree(buf);
- buf = nbuf;
- }
- /* stick that last bit of string on our output */
- strcat(buf, &string[pos]);
- }
- }
-
- /* don't want to leak memory .. */
- regfree(&re);
-
- /* whew. */
- return (buf);
-}
-
-static void _php3_eregreplace(INTERNAL_FUNCTION_PARAMETERS, int icase)
-{
- pval *arg_pattern,
- *arg_replace,
- *arg_string;
- char *pattern;
- char *string;
- char *replace;
- char *ret;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg_pattern, &arg_replace, &arg_string) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (arg_pattern->type == IS_STRING) {
- if (arg_pattern->value.str.val && arg_pattern->value.str.len)
- pattern = estrndup(arg_pattern->value.str.val,arg_pattern->value.str.len);
- else
- pattern = empty_string;
- } else {
- convert_to_long(arg_pattern);
- pattern = emalloc(2);
- pattern[0] = (char) arg_pattern->value.lval;
- pattern[1] = '\0';
- }
-
- if (arg_replace->type == IS_STRING) {
- if (arg_replace->value.str.val && arg_replace->value.str.len)
- replace = estrndup(arg_replace->value.str.val, arg_replace->value.str.len);
- else
- replace = empty_string;
- } else {
- convert_to_long(arg_replace);
- replace = emalloc(2);
- replace[0] = (char) arg_replace->value.lval;
- replace[1] = '\0';
- }
-
- convert_to_string(arg_string);
- if (arg_string->value.str.val && arg_string->value.str.len)
- string = estrndup(arg_string->value.str.val, arg_string->value.str.len);
- else
- string = empty_string;
-
- /* do the actual work */
- ret = _php3_regreplace(pattern, replace, string, icase, 1);
- if (ret == (char *) -1) {
- RETVAL_FALSE;
- } else {
- RETVAL_STRING(ret,1);
- STR_FREE(ret);
- }
- STR_FREE(string);
- STR_FREE(replace);
- STR_FREE(pattern);
-}
-
-/* {{{ proto string ereg_replace(string pattern, string string [, array registers])
- Replace regular expression */
-PHP_FUNCTION(ereg_replace)
-{
- _php3_eregreplace(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ proto string eregi_replace(string pattern, string string [, array registers])
- Case insensitive replace regular expression */
-PHP_FUNCTION(eregi_replace)
-{
- _php3_eregreplace(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-/* ("root", "passwd", "uid", "gid", "other:stuff:like:/bin/sh")
- = split(":", $passwd_file, 5); */
-/* {{{ proto array split(string pattern, string string [, int limit])
- split string into array by regular expression */
-PHP_FUNCTION(split)
-{
- pval *spliton, *str, *arg_count = NULL;
- regex_t re;
- regmatch_t subs[1];
- char *strp, *endp;
- int err, size, count;
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &spliton, &str) == FAILURE)
- WRONG_PARAM_COUNT;
- count = -1;
- break;
- case 3:
- if (getParameters(ht, 3, &spliton, &str, &arg_count) == FAILURE)
- WRONG_PARAM_COUNT;
- convert_to_long(arg_count);
- count = arg_count->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(spliton);
- convert_to_string(str);
-
- strp = str->value.str.val;
- endp = str->value.str.val + strlen(str->value.str.val);
-
- err = regcomp(&re, spliton->value.str.val, REG_EXTENDED);
- if (err) {
- php_error(E_WARNING, "unexpected regex error (%d)", err);
- RETURN_FALSE;
- }
-
- if (array_init(return_value) == FAILURE) {
- regfree(&re);
- RETURN_FALSE;
- }
-
- /* churn through str, generating array entries as we go */
- while ((count == -1 || count > 1) && !(err = regexec(&re, strp, 1, subs, 0))) {
- if (subs[0].rm_so == 0 && subs[0].rm_eo) {
- /* match is at start of string, return empty string */
- add_next_index_stringl(return_value, empty_string, 0, 1);
- /* skip ahead the length of the regex match */
- strp+=subs[0].rm_eo;
- } else if (subs[0].rm_so==0 && subs[0].rm_eo==0) {
- /* No more matches */
- regfree(&re);
- php_error(E_WARNING, "bad regular expression for split()");
- zend_hash_destroy(return_value->value.ht);
- efree(return_value->value.ht);
- RETURN_FALSE;
- } else {
- /* On a real match */
-
- /* make a copy of the substring */
- size = subs[0].rm_so;
-
- /* add it to the array */
- add_next_index_stringl(return_value, strp, size, 1);
-
- /* point at our new starting point */
- strp = strp + subs[0].rm_eo;
- }
-
- /* if we're only looking for a certain number of points,
- stop looking once we hit it */
- if (count != -1) {
- count--;
- }
- }
-
- /* see if we encountered an error */
- if (err && err != REG_NOMATCH) {
- php_error(E_WARNING, "unexpected regex error (%d)", err);
- regfree(&re);
- zend_hash_destroy(return_value->value.ht);
- efree(return_value->value.ht);
- RETURN_FALSE;
- }
-
- /* otherwise we just have one last element to add to the array */
- size = endp - strp;
-
- add_next_index_stringl(return_value, strp, size, 1);
-
- regfree(&re);
-
- return;
-}
-/* }}} */
-
-/* {{{ proto string sql_regcase(string string)
- Make regular expression for case insensitive match */
-PHPAPI PHP_FUNCTION(sql_regcase)
-{
- pval *string;
- char *tmp;
- unsigned char c;
- register int i, j;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &string)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(string);
-
- tmp = (char *) emalloc(string->value.str.len*4+1);
-
- for (i=j=0; i<string->value.str.len; i++) {
- c = (unsigned char) string->value.str.val[i];
- if(isalpha(c)) {
- tmp[j++] = '[';
- tmp[j++] = toupper(c);
- tmp[j++] = tolower(c);
- tmp[j++] = ']';
- } else {
- tmp[j++] = c;
- }
- }
- tmp[j]=0;
-
- tmp = erealloc(tmp, j + 1);
-
- RETVAL_STRINGL(tmp, j, 0);
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/ereg/php_ereg.h b/ext/ereg/php_ereg.h
deleted file mode 100644
index c261abf4d2..0000000000
--- a/ext/ereg/php_ereg.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _REG_H
-#define _REG_H
-
-extern php3_module_entry regexp_module_entry;
-#define regexp_module_ptr &regexp_module_entry
-
-char *_php3_regreplace(const char *pattern, const char *replace, const char *string, int icase, int extended);
-
-PHP_FUNCTION(ereg);
-PHP_FUNCTION(eregi);
-PHP_FUNCTION(eregi_replace);
-PHP_FUNCTION(ereg_replace);
-PHP_FUNCTION(split);
-PHPAPI PHP_FUNCTION(sql_regcase);
-
-typedef struct {
- HashTable ht_rc;
-} php_reg_globals;
-
-
-#ifdef ZTS
-#define REGLS_D php_reg_globals *reg_globals
-#define REGLS_DC , REGLS_D
-#define REGLS_C reg_globals
-#define REGLS_CC , REGLS_C
-#define REG(v) (reg_globals->v)
-#define REGLS_FETCH() php_reg_globals *reg_globals = ts_resource(reg_globals_id)
-#else
-#define REGLS_D
-#define REGLS_DC
-#define REGLS_C
-#define REGLS_CC
-#define REG(v) (reg_globals.v)
-#define REGLS_FETCH()
-#endif
-
-#define phpext_regex_ptr regexp_module_ptr
-
-#endif /* _REG_H */
diff --git a/ext/ereg/php_regex.h b/ext/ereg/php_regex.h
deleted file mode 100644
index 9ed80d84b8..0000000000
--- a/ext/ereg/php_regex.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef _PHP_REGEX_H
-#define _PHP_REGEX_H
-
-#if REGEX
-#include "regex/regex.h"
-#define _REGEX_H 1 /* this should stop Apache from loading the system version of regex.h */
-#define _RX_H 1 /* Try defining these for Linux to */
-#define __REGEXP_LIBRARY_H__ 1 /* avoid Apache including regex.h */
-#define _H_REGEX 1 /* This one is for AIX */
-#else
-#include <regex.h>
-#endif
-
-#endif /* _PHP_REGEX_H */
diff --git a/ext/ereg/regex/COPYRIGHT b/ext/ereg/regex/COPYRIGHT
deleted file mode 100644
index d43362fbfc..0000000000
--- a/ext/ereg/regex/COPYRIGHT
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright 1992, 1993, 1994 Henry Spencer. All rights reserved.
-This software is not subject to any license of the American Telephone
-and Telegraph Company or of the Regents of the University of California.
-
-Permission is granted to anyone to use this software for any purpose on
-any computer system, and to alter it and redistribute it, subject
-to the following restrictions:
-
-1. The author is not responsible for the consequences of use of this
- software, no matter how awful, even if they arise from flaws in it.
-
-2. The origin of this software must not be misrepresented, either by
- explicit claim or by omission. Since few users ever read sources,
- credits must appear in the documentation.
-
-3. Altered versions must be plainly marked as such, and must not be
- misrepresented as being the original software. Since few users
- ever read sources, credits must appear in the documentation.
-
-4. This notice may not be removed or altered.
diff --git a/ext/ereg/regex/Makefile.in b/ext/ereg/regex/Makefile.in
deleted file mode 100644
index 4561974b06..0000000000
--- a/ext/ereg/regex/Makefile.in
+++ /dev/null
@@ -1,145 +0,0 @@
-SHELL = /bin/sh
-
-srcdir=@srcdir@
-VPATH=@srcdir@
-
-CC=@CC@
-RANLIB=@RANLIB@
-
-# You probably want to take -DREDEBUG out of CFLAGS, and put something like
-# -O in, *after* testing (-DREDEBUG strengthens testing by enabling a lot of
-# internal assertion checking and some debugging facilities).
-# Put -Dconst= in for a pre-ANSI compiler.
-# Do not take -DPOSIX_MISTAKE out.
-# REGCFLAGS isn't important to you (it's for my use in some special contexts).
-CFLAGS=@CFLAGS@
-COMPILE=$(CC) $(CFLAGS) -I$(srcdir) -I. -DPOSIX_MISTAKE
-
-# If you have a pre-ANSI compiler, put -o into MKHFLAGS. If you want
-# the Berkeley __P macro, put -b in.
-MKHFLAGS=
-
-# Flags for linking but not compiling, if any.
-LDFLAGS=@LDFLAGS@
-
-# Extra libraries for linking, if any.
-LIBS=
-
-# Internal stuff, should not need changing.
-OBJPRODN=regcomp.o regexec.o regerror.o regfree.o
-OBJS=$(OBJPRODN) split.o debug.o main.o
-H=cclass.h cname.h regex2.h utils.h
-REGSRC=regcomp.c regerror.c regexec.c regfree.c
-ALLSRC=$(REGSRC) engine.c debug.c main.c split.c
-
-# Stuff that matters only if you're trying to lint the package.
-LINTFLAGS=-I. -Dstatic= -Dconst= -DREDEBUG
-LINTC=regcomp.c regexec.c regerror.c regfree.c debug.c main.c
-JUNKLINT=possible pointer alignment|null effect
-
-# arrangements to build forward-reference header files
-.SUFFIXES: .ih .h
-.c.ih:
- sh $(srcdir)/mkh $(MKHFLAGS) -p $< >$@
-
-.c.o:
- $(COMPILE) -c $<
-
-all lib: libregex.a
-
-libregex.a: $(OBJPRODN)
- rm -f libregex.a
- ar cr libregex.a $(OBJPRODN)
- $(RANLIB) libregex.a
-
-default: r
-
-purge:
- rm -f *.o
-
-# stuff to build regex.h
-REGEXH=regex.h
-REGEXHSRC=regex2.h $(REGSRC)
-$(REGEXH): $(REGEXHSRC) mkh
- sh $(srcdir)/./mkh $(MKHFLAGS) -i _REGEX_H_ $(REGEXHSRC) >regex.h
- #cmp -s regex.tmp regex.h 2>/dev/null || cp regex.tmp regex.h
- #rm -f regex.tmp
-
-# dependencies
-$(OBJPRODN) debug.o: utils.h regex.h regex2.h
-regcomp.o: cclass.h cname.h regcomp.ih
-regexec.o: engine.c engine.ih
-regerror.o: regerror.ih
-debug.o: debug.ih
-main.o: main.ih
-
-# tester
-re: $(OBJS)
- $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
-
-# regression test
-r: re tests
- ./re <tests
- ./re -el <tests
- ./re -er <tests
-
-# 57 variants, and other stuff, for development use -- not useful to you
-ra: ./re tests
- -./re <tests
- -./re -el <tests
- -./re -er <tests
-
-rx: ./re tests
- ./re -x <tests
- ./re -x -el <tests
- ./re -x -er <tests
-
-t: ./re tests
- -time ./re <tests
- -time ./re -cs <tests
- -time ./re -el <tests
- -time ./re -cs -el <tests
-
-l: $(LINTC)
- lint $(LINTFLAGS) -h $(LINTC) 2>&1 | egrep -v '$(JUNKLINT)' | tee lint
-
-fullprint:
- ti README WHATSNEW notes todo | list
- ti *.h | list
- list *.c
- list regex.3 regex.7
-
-print:
- ti README WHATSNEW notes todo | list
- ti *.h | list
- list reg*.c engine.c
-
-
-mf.tmp: Makefile
- sed '/^REGEXH=/s/=.*/=regex.h/' Makefile | sed '/#DEL$$/d' >$@
-
-DTRH=cclass.h cname.h regex2.h utils.h
-PRE=COPYRIGHT README WHATSNEW
-POST=mkh regex.3 regex.7 tests $(DTRH) $(ALLSRC) fake/*.[ch]
-FILES=$(PRE) Makefile $(POST)
-DTR=$(PRE) Makefile=mf.tmp $(POST)
-dtr: $(FILES) mf.tmp
- makedtr $(DTR) >$@
- rm mf.tmp
-
-cio: $(FILES)
- cio $(FILES)
-
-rdf: $(FILES)
- rcsdiff -c $(FILES) 2>&1 | p
-
-# various forms of cleanup
-tidy:
- rm -f junk* core core.* *.core dtr *.tmp lint
-
-clean: tidy
- rm -f *.o *.s re libregex.a
-
-# don't do this one unless you know what you're doing
-spotless: clean
- rm -f mkh regex.h
diff --git a/ext/ereg/regex/README b/ext/ereg/regex/README
deleted file mode 100644
index cea9b67b66..0000000000
--- a/ext/ereg/regex/README
+++ /dev/null
@@ -1,32 +0,0 @@
-alpha3.4 release.
-Thu Mar 17 23:17:18 EST 1994
-henry@zoo.toronto.edu
-
-See WHATSNEW for change listing.
-
-installation notes:
---------
-Read the comments at the beginning of Makefile before running.
-
-Utils.h contains some things that just might have to be modified on
-some systems, as well as a nested include (ugh) of <assert.h>.
-
-The "fake" directory contains quick-and-dirty fakes for some header
-files and routines that old systems may not have. Note also that
--DUSEBCOPY will make utils.h substitute bcopy() for memmove().
-
-After that, "make r" will build regcomp.o, regexec.o, regfree.o,
-and regerror.o (the actual routines), bundle them together into a test
-program, and run regression tests on them. No output is good output.
-
-"make lib" builds just the .o files for the actual routines (when
-you're happy with testing and have adjusted CFLAGS for production),
-and puts them together into libregex.a. You can pick up either the
-library or *.o ("make lib" makes sure there are no other .o files left
-around to confuse things).
-
-Main.c, debug.c, split.c are used for regression testing but are not part
-of the RE routines themselves.
-
-Regex.h goes in /usr/include. All other .h files are internal only.
---------
diff --git a/ext/ereg/regex/WHATSNEW b/ext/ereg/regex/WHATSNEW
deleted file mode 100644
index 6e82e1dae0..0000000000
--- a/ext/ereg/regex/WHATSNEW
+++ /dev/null
@@ -1,92 +0,0 @@
-New in alpha3.4: The complex bug alluded to below has been fixed (in a
-slightly kludgey temporary way that may hurt efficiency a bit; this is
-another "get it out the door for 4.4" release). The tests at the end of
-the tests file have accordingly been uncommented. The primary sign of
-the bug was that something like a?b matching ab matched b rather than ab.
-(The bug was essentially specific to this exact situation, else it would
-have shown up earlier.)
-
-New in alpha3.3: The definition of word boundaries has been altered
-slightly, to more closely match the usual programming notion that "_"
-is an alphabetic. Stuff used for pre-ANSI systems is now in a subdir,
-and the makefile no longer alludes to it in mysterious ways. The
-makefile has generally been cleaned up some. Fixes have been made
-(again!) so that the regression test will run without -DREDEBUG, at
-the cost of weaker checking. A workaround for a bug in some folks'
-<assert.h> has been added. And some more things have been added to
-tests, including a couple right at the end which are commented out
-because the code currently flunks them (complex bug; fix coming).
-Plus the usual minor cleanup.
-
-New in alpha3.2: Assorted bits of cleanup and portability improvement
-(the development base is now a BSDI system using GCC instead of an ancient
-Sun system, and the newer compiler exposed some glitches). Fix for a
-serious bug that affected REs using many [] (including REG_ICASE REs
-because of the way they are implemented), *sometimes*, depending on
-memory-allocation patterns. The header-file prototypes no longer name
-the parameters, avoiding possible name conflicts. The possibility that
-some clot has defined CHAR_MIN as (say) `-128' instead of `(-128)' is
-now handled gracefully. "uchar" is no longer used as an internal type
-name (too many people have the same idea). Still the same old lousy
-performance, alas.
-
-New in alpha3.1: Basically nothing, this release is just a bookkeeping
-convenience. Stay tuned.
-
-New in alpha3.0: Performance is no better, alas, but some fixes have been
-made and some functionality has been added. (This is basically the "get
-it out the door in time for 4.4" release.) One bug fix: regfree() didn't
-free the main internal structure (how embarrassing). It is now possible
-to put NULs in either the RE or the target string, using (resp.) a new
-REG_PEND flag and the old REG_STARTEND flag. The REG_NOSPEC flag to
-regcomp() makes all characters ordinary, so you can match a literal
-string easily (this will become more useful when performance improves!).
-There are now primitives to match beginnings and ends of words, although
-the syntax is disgusting and so is the implementation. The REG_ATOI
-debugging interface has changed a bit. And there has been considerable
-internal cleanup of various kinds.
-
-New in alpha2.3: Split change list out of README, and moved flags notes
-into Makefile. Macro-ized the name of regex(7) in regex(3), since it has
-to change for 4.4BSD. Cleanup work in engine.c, and some new regression
-tests to catch tricky cases thereof.
-
-New in alpha2.2: Out-of-date manpages updated. Regerror() acquires two
-small extensions -- REG_ITOA and REG_ATOI -- which avoid debugging kludges
-in my own test program and might be useful to others for similar purposes.
-The regression test will now compile (and run) without REDEBUG. The
-BRE \$ bug is fixed. Most uses of "uchar" are gone; it's all chars now.
-Char/uchar parameters are now written int/unsigned, to avoid possible
-portability problems with unpromoted parameters. Some unsigned casts have
-been introduced to minimize portability problems with shifting into sign
-bits.
-
-New in alpha2.1: Lots of little stuff, cleanup and fixes. The one big
-thing is that regex.h is now generated, using mkh, rather than being
-supplied in the distribution; due to circularities in dependencies,
-you have to build regex.h explicitly by "make h". The two known bugs
-have been fixed (and the regression test now checks for them), as has a
-problem with assertions not being suppressed in the absence of REDEBUG.
-No performance work yet.
-
-New in alpha2: Backslash-anything is an ordinary character, not an
-error (except, of course, for the handful of backslashed metacharacters
-in BREs), which should reduce script breakage. The regression test
-checks *where* null strings are supposed to match, and has generally
-been tightened up somewhat. Small bug fixes in parameter passing (not
-harmful, but technically errors) and some other areas. Debugging
-invoked by defining REDEBUG rather than not defining NDEBUG.
-
-New in alpha+3: full prototyping for internal routines, using a little
-helper program, mkh, which extracts prototypes given in stylized comments.
-More minor cleanup. Buglet fix: it's CHAR_BIT, not CHAR_BITS. Simple
-pre-screening of input when a literal string is known to be part of the
-RE; this does wonders for performance.
-
-New in alpha+2: minor bits of cleanup. Notably, the number "32" for the
-word width isn't hardwired into regexec.c any more, the public header
-file prototypes the functions if __STDC__ is defined, and some small typos
-in the manpages have been fixed.
-
-New in alpha+1: improvements to the manual pages, and an important
-extension, the REG_STARTEND option to regexec().
diff --git a/ext/ereg/regex/cclass.h b/ext/ereg/regex/cclass.h
deleted file mode 100644
index 727cbb9255..0000000000
--- a/ext/ereg/regex/cclass.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* character-class table */
-static struct cclass {
- char *name;
- char *chars;
- char *multis;
-} cclasses[] = {
- { "alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
-0123456789", "" },
- { "alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
- "" },
- { "blank", " \t", "" },
- { "cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\
-\25\26\27\30\31\32\33\34\35\36\37\177", "" },
- { "digit", "0123456789", "" },
- { "graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
-0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
- "" },
- { "lower", "abcdefghijklmnopqrstuvwxyz",
- "" },
- { "print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
-0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ",
- "" },
- { "punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
- "" },
- { "space", "\t\n\v\f\r ", "" },
- { "upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
- "" },
- { "xdigit", "0123456789ABCDEFabcdef",
- "" },
- { NULL, 0, "" }
-};
diff --git a/ext/ereg/regex/cname.h b/ext/ereg/regex/cname.h
deleted file mode 100644
index ff116e55e2..0000000000
--- a/ext/ereg/regex/cname.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* character-name table */
-static struct cname {
- char *name;
- char code;
-} cnames[] = {
- { "NUL", '\0' },
- { "SOH", '\001' },
- { "STX", '\002' },
- { "ETX", '\003' },
- { "EOT", '\004' },
- { "ENQ", '\005' },
- { "ACK", '\006' },
- { "BEL", '\007' },
- { "alert", '\007' },
- { "BS", '\010' },
- { "backspace", '\b' },
- { "HT", '\011' },
- { "tab", '\t' },
- { "LF", '\012' },
- { "newline", '\n' },
- { "VT", '\013' },
- { "vertical-tab", '\v' },
- { "FF", '\014' },
- { "form-feed", '\f' },
- { "CR", '\015' },
- { "carriage-return", '\r' },
- { "SO", '\016' },
- { "SI", '\017' },
- { "DLE", '\020' },
- { "DC1", '\021' },
- { "DC2", '\022' },
- { "DC3", '\023' },
- { "DC4", '\024' },
- { "NAK", '\025' },
- { "SYN", '\026' },
- { "ETB", '\027' },
- { "CAN", '\030' },
- { "EM", '\031' },
- { "SUB", '\032' },
- { "ESC", '\033' },
- { "IS4", '\034' },
- { "FS", '\034' },
- { "IS3", '\035' },
- { "GS", '\035' },
- { "IS2", '\036' },
- { "RS", '\036' },
- { "IS1", '\037' },
- { "US", '\037' },
- { "space", ' ' },
- { "exclamation-mark", '!' },
- { "quotation-mark", '"' },
- { "number-sign", '#' },
- { "dollar-sign", '$' },
- { "percent-sign", '%' },
- { "ampersand", '&' },
- { "apostrophe", '\'' },
- { "left-parenthesis", '(' },
- { "right-parenthesis", ')' },
- { "asterisk", '*' },
- { "plus-sign", '+' },
- { "comma", ',' },
- { "hyphen", '-' },
- { "hyphen-minus", '-' },
- { "period", '.' },
- { "full-stop", '.' },
- { "slash", '/' },
- { "solidus", '/' },
- { "zero", '0' },
- { "one", '1' },
- { "two", '2' },
- { "three", '3' },
- { "four", '4' },
- { "five", '5' },
- { "six", '6' },
- { "seven", '7' },
- { "eight", '8' },
- { "nine", '9' },
- { "colon", ':' },
- { "semicolon", ';' },
- { "less-than-sign", '<' },
- { "equals-sign", '=' },
- { "greater-than-sign", '>' },
- { "question-mark", '?' },
- { "commercial-at", '@' },
- { "left-square-bracket", '[' },
- { "backslash", '\\' },
- { "reverse-solidus", '\\' },
- { "right-square-bracket", ']' },
- { "circumflex", '^' },
- { "circumflex-accent", '^' },
- { "underscore", '_' },
- { "low-line", '_' },
- { "grave-accent", '`' },
- { "left-brace", '{' },
- { "left-curly-bracket", '{' },
- { "vertical-line", '|' },
- { "right-brace", '}' },
- { "right-curly-bracket", '}' },
- { "tilde", '~' },
- { "DEL", '\177' },
- { NULL, 0 }
-};
diff --git a/ext/ereg/regex/debug.c b/ext/ereg/regex/debug.c
deleted file mode 100644
index c0feaeb169..0000000000
--- a/ext/ereg/regex/debug.c
+++ /dev/null
@@ -1,242 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <regex.h>
-
-#include "utils.h"
-#include "regex2.h"
-#include "debug.ih"
-
-/*
- - regprint - print a regexp for debugging
- == void regprint(regex_t *r, FILE *d);
- */
-void
-regprint(r, d)
-regex_t *r;
-FILE *d;
-{
- register struct re_guts *g = r->re_g;
- register int i;
- register int c;
- register int last;
- int nincat[NC];
-
- fprintf(d, "%ld states, %d categories", (long)g->nstates,
- g->ncategories);
- fprintf(d, ", first %ld last %ld", (long)g->firststate,
- (long)g->laststate);
- if (g->iflags&USEBOL)
- fprintf(d, ", USEBOL");
- if (g->iflags&USEEOL)
- fprintf(d, ", USEEOL");
- if (g->iflags&BAD)
- fprintf(d, ", BAD");
- if (g->nsub > 0)
- fprintf(d, ", nsub=%ld", (long)g->nsub);
- if (g->must != NULL)
- fprintf(d, ", must(%ld) `%*s'", (long)g->mlen, (int)g->mlen,
- g->must);
- if (g->backrefs)
- fprintf(d, ", backrefs");
- if (g->nplus > 0)
- fprintf(d, ", nplus %ld", (long)g->nplus);
- fprintf(d, "\n");
- s_print(g, d);
- for (i = 0; i < g->ncategories; i++) {
- nincat[i] = 0;
- for (c = CHAR_MIN; c <= CHAR_MAX; c++)
- if (g->categories[c] == i)
- nincat[i]++;
- }
- fprintf(d, "cc0#%d", nincat[0]);
- for (i = 1; i < g->ncategories; i++)
- if (nincat[i] == 1) {
- for (c = CHAR_MIN; c <= CHAR_MAX; c++)
- if (g->categories[c] == i)
- break;
- fprintf(d, ", %d=%s", i, regchar(c));
- }
- fprintf(d, "\n");
- for (i = 1; i < g->ncategories; i++)
- if (nincat[i] != 1) {
- fprintf(d, "cc%d\t", i);
- last = -1;
- for (c = CHAR_MIN; c <= CHAR_MAX+1; c++) /* +1 does flush */
- if (c <= CHAR_MAX && g->categories[c] == i) {
- if (last < 0) {
- fprintf(d, "%s", regchar(c));
- last = c;
- }
- } else {
- if (last >= 0) {
- if (last != c-1)
- fprintf(d, "-%s",
- regchar(c-1));
- last = -1;
- }
- }
- fprintf(d, "\n");
- }
-}
-
-/*
- - s_print - print the strip for debugging
- == static void s_print(register struct re_guts *g, FILE *d);
- */
-static void
-s_print(g, d)
-register struct re_guts *g;
-FILE *d;
-{
- register sop *s;
- register cset *cs;
- register int i;
- register int done = 0;
- register sop opnd;
- register int col = 0;
- register int last;
- register sopno offset = 2;
-# define GAP() { if (offset % 5 == 0) { \
- if (col > 40) { \
- fprintf(d, "\n\t"); \
- col = 0; \
- } else { \
- fprintf(d, " "); \
- col++; \
- } \
- } else \
- col++; \
- offset++; \
- }
-
- if (OP(g->strip[0]) != OEND)
- fprintf(d, "missing initial OEND!\n");
- for (s = &g->strip[1]; !done; s++) {
- opnd = OPND(*s);
- switch (OP(*s)) {
- case OEND:
- fprintf(d, "\n");
- done = 1;
- break;
- case OCHAR:
- if (strchr("\\|()^$.[+*?{}!<> ", (char)opnd) != NULL)
- fprintf(d, "\\%c", (char)opnd);
- else
- fprintf(d, "%s", regchar((char)opnd));
- break;
- case OBOL:
- fprintf(d, "^");
- break;
- case OEOL:
- fprintf(d, "$");
- break;
- case OBOW:
- fprintf(d, "\\{");
- break;
- case OEOW:
- fprintf(d, "\\}");
- break;
- case OANY:
- fprintf(d, ".");
- break;
- case OANYOF:
- fprintf(d, "[(%ld)", (long)opnd);
- cs = &g->sets[opnd];
- last = -1;
- for (i = 0; i < g->csetsize+1; i++) /* +1 flushes */
- if (CHIN(cs, i) && i < g->csetsize) {
- if (last < 0) {
- fprintf(d, "%s", regchar(i));
- last = i;
- }
- } else {
- if (last >= 0) {
- if (last != i-1)
- fprintf(d, "-%s",
- regchar(i-1));
- last = -1;
- }
- }
- fprintf(d, "]");
- break;
- case OBACK_:
- fprintf(d, "(\\<%ld>", (long)opnd);
- break;
- case O_BACK:
- fprintf(d, "<%ld>\\)", (long)opnd);
- break;
- case OPLUS_:
- fprintf(d, "(+");
- if (OP(*(s+opnd)) != O_PLUS)
- fprintf(d, "<%ld>", (long)opnd);
- break;
- case O_PLUS:
- if (OP(*(s-opnd)) != OPLUS_)
- fprintf(d, "<%ld>", (long)opnd);
- fprintf(d, "+)");
- break;
- case OQUEST_:
- fprintf(d, "(?");
- if (OP(*(s+opnd)) != O_QUEST)
- fprintf(d, "<%ld>", (long)opnd);
- break;
- case O_QUEST:
- if (OP(*(s-opnd)) != OQUEST_)
- fprintf(d, "<%ld>", (long)opnd);
- fprintf(d, "?)");
- break;
- case OLPAREN:
- fprintf(d, "((<%ld>", (long)opnd);
- break;
- case ORPAREN:
- fprintf(d, "<%ld>))", (long)opnd);
- break;
- case OCH_:
- fprintf(d, "<");
- if (OP(*(s+opnd)) != OOR2)
- fprintf(d, "<%ld>", (long)opnd);
- break;
- case OOR1:
- if (OP(*(s-opnd)) != OOR1 && OP(*(s-opnd)) != OCH_)
- fprintf(d, "<%ld>", (long)opnd);
- fprintf(d, "|");
- break;
- case OOR2:
- fprintf(d, "|");
- if (OP(*(s+opnd)) != OOR2 && OP(*(s+opnd)) != O_CH)
- fprintf(d, "<%ld>", (long)opnd);
- break;
- case O_CH:
- if (OP(*(s-opnd)) != OOR1)
- fprintf(d, "<%ld>", (long)opnd);
- fprintf(d, ">");
- break;
- default:
- fprintf(d, "!%ld(%ld)!", OP(*s), opnd);
- break;
- }
- if (!done)
- GAP();
- }
-}
-
-/*
- - regchar - make a character printable
- == static char *regchar(int ch);
- */
-static char * /* -> representation */
-regchar(ch)
-int ch;
-{
- static char buf[10];
-
- if (isprint(ch) || ch == ' ')
- sprintf(buf, "%c", ch);
- else
- sprintf(buf, "\\%o", ch);
- return(buf);
-}
diff --git a/ext/ereg/regex/debug.ih b/ext/ereg/regex/debug.ih
deleted file mode 100644
index 5f40ff7917..0000000000
--- a/ext/ereg/regex/debug.ih
+++ /dev/null
@@ -1,14 +0,0 @@
-/* ========= begin header generated by ./mkh ========= */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* === debug.c === */
-void regprint(regex_t *r, FILE *d);
-static void s_print(register struct re_guts *g, FILE *d);
-static char *regchar(int ch);
-
-#ifdef __cplusplus
-}
-#endif
-/* ========= end header generated by ./mkh ========= */
diff --git a/ext/ereg/regex/engine.c b/ext/ereg/regex/engine.c
deleted file mode 100644
index 696774e1b3..0000000000
--- a/ext/ereg/regex/engine.c
+++ /dev/null
@@ -1,1019 +0,0 @@
-/*
- * The matching engine and friends. This file is #included by regexec.c
- * after suitable #defines of a variety of macros used herein, so that
- * different state representations can be used without duplicating masses
- * of code.
- */
-
-#ifdef SNAMES
-#define matcher smatcher
-#define fast sfast
-#define slow sslow
-#define dissect sdissect
-#define backref sbackref
-#define step sstep
-#define print sprint
-#define at sat
-#define match smat
-#endif
-#ifdef LNAMES
-#define matcher lmatcher
-#define fast lfast
-#define slow lslow
-#define dissect ldissect
-#define backref lbackref
-#define step lstep
-#define print lprint
-#define at lat
-#define match lmat
-#endif
-
-/* another structure passed up and down to avoid zillions of parameters */
-struct match {
- struct re_guts *g;
- int eflags;
- regmatch_t *pmatch; /* [nsub+1] (0 element unused) */
- char *offp; /* offsets work from here */
- char *beginp; /* start of string -- virtual NUL precedes */
- char *endp; /* end of string -- virtual NUL here */
- char *coldp; /* can be no match starting before here */
- char **lastpos; /* [nplus+1] */
- STATEVARS;
- states st; /* current states */
- states fresh; /* states for a fresh start */
- states tmp; /* temporary */
- states empty; /* empty set of states */
-};
-
-#include "engine.ih"
-
-#ifdef REDEBUG
-#define SP(t, s, c) print(m, t, s, c, stdout)
-#define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2)
-#define NOTE(str) { if (m->eflags&REG_TRACE) printf("=%s\n", (str)); }
-#else
-#define SP(t, s, c) /* nothing */
-#define AT(t, p1, p2, s1, s2) /* nothing */
-#define NOTE(s) /* nothing */
-#endif
-
-/*
- - matcher - the actual matching engine
- == static int matcher(register struct re_guts *g, char *string, \
- == size_t nmatch, regmatch_t pmatch[], int eflags);
- */
-static int /* 0 success, REG_NOMATCH failure */
-matcher(g, string, nmatch, pmatch, eflags)
-register struct re_guts *g;
-char *string;
-size_t nmatch;
-regmatch_t pmatch[];
-int eflags;
-{
- register char *endp;
- register unsigned int i;
- struct match mv;
- register struct match *m = &mv;
- register char *dp;
- register const sopno gf = g->firststate+1; /* +1 for OEND */
- register const sopno gl = g->laststate;
- char *start;
- char *stop;
-
- /* simplify the situation where possible */
- if (g->cflags&REG_NOSUB)
- nmatch = 0;
- if (eflags&REG_STARTEND) {
- start = string + pmatch[0].rm_so;
- stop = string + pmatch[0].rm_eo;
- } else {
- start = string;
- stop = start + strlen(start);
- }
- if (stop < start)
- return(REG_INVARG);
-
- /* prescreening; this does wonders for this rather slow code */
- if (g->must != NULL) {
- for (dp = start; dp < stop; dp++)
- if (*dp == g->must[0] && stop - dp >= g->mlen &&
- memcmp(dp, g->must, (size_t)g->mlen) == 0)
- break;
- if (dp == stop) /* we didn't find g->must */
- return(REG_NOMATCH);
- }
-
- /* match struct setup */
- m->g = g;
- m->eflags = eflags;
- m->pmatch = NULL;
- m->lastpos = NULL;
- m->offp = string;
- m->beginp = start;
- m->endp = stop;
- STATESETUP(m, 4);
- SETUP(m->st);
- SETUP(m->fresh);
- SETUP(m->tmp);
- SETUP(m->empty);
- CLEAR(m->empty);
-
- /* this loop does only one repetition except for backrefs */
- for (;;) {
- endp = fast(m, start, stop, gf, gl);
- if (endp == NULL) { /* a miss */
- STATETEARDOWN(m);
- return(REG_NOMATCH);
- }
- if (nmatch == 0 && !g->backrefs)
- break; /* no further info needed */
-
- /* where? */
- assert(m->coldp != NULL);
- for (;;) {
- NOTE("finding start");
- endp = slow(m, m->coldp, stop, gf, gl);
- if (endp != NULL)
- break;
- assert(m->coldp < m->endp);
- m->coldp++;
- }
- if (nmatch == 1 && !g->backrefs)
- break; /* no further info needed */
-
- /* oh my, he wants the subexpressions... */
- if (m->pmatch == NULL)
- m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) *
- sizeof(regmatch_t));
- if (m->pmatch == NULL) {
- STATETEARDOWN(m);
- return(REG_ESPACE);
- }
- for (i = 1; i <= m->g->nsub; i++)
- m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1;
- if (!g->backrefs && !(m->eflags&REG_BACKR)) {
- NOTE("dissecting");
- dp = dissect(m, m->coldp, endp, gf, gl);
- } else {
- if (g->nplus > 0 && m->lastpos == NULL)
- m->lastpos = (char **)malloc((g->nplus+1) *
- sizeof(char *));
- if (g->nplus > 0 && m->lastpos == NULL) {
- free(m->pmatch);
- STATETEARDOWN(m);
- return(REG_ESPACE);
- }
- NOTE("backref dissect");
- dp = backref(m, m->coldp, endp, gf, gl, (sopno)0);
- }
- if (dp != NULL)
- break;
-
- /* uh-oh... we couldn't find a subexpression-level match */
- assert(g->backrefs); /* must be back references doing it */
- assert(g->nplus == 0 || m->lastpos != NULL);
- for (;;) {
- if (dp != NULL || endp <= m->coldp)
- break; /* defeat */
- NOTE("backoff");
- endp = slow(m, m->coldp, endp-1, gf, gl);
- if (endp == NULL)
- break; /* defeat */
- /* try it on a shorter possibility */
-#ifndef NDEBUG
- for (i = 1; i <= m->g->nsub; i++) {
- assert(m->pmatch[i].rm_so == -1);
- assert(m->pmatch[i].rm_eo == -1);
- }
-#endif
- NOTE("backoff dissect");
- dp = backref(m, m->coldp, endp, gf, gl, (sopno)0);
- }
- assert(dp == NULL || dp == endp);
- if (dp != NULL) /* found a shorter one */
- break;
-
- /* despite initial appearances, there is no match here */
- NOTE("false alarm");
- start = m->coldp + 1; /* recycle starting later */
- assert(start <= stop);
- }
-
- /* fill in the details if requested */
- if (nmatch > 0) {
- pmatch[0].rm_so = m->coldp - m->offp;
- pmatch[0].rm_eo = endp - m->offp;
- }
- if (nmatch > 1) {
- assert(m->pmatch != NULL);
- for (i = 1; i < nmatch; i++)
- if (i <= m->g->nsub)
- pmatch[i] = m->pmatch[i];
- else {
- pmatch[i].rm_so = -1;
- pmatch[i].rm_eo = -1;
- }
- }
-
- if (m->pmatch != NULL)
- free((char *)m->pmatch);
- if (m->lastpos != NULL)
- free((char *)m->lastpos);
- STATETEARDOWN(m);
- return(0);
-}
-
-/*
- - dissect - figure out what matched what, no back references
- == static char *dissect(register struct match *m, char *start, \
- == char *stop, sopno startst, sopno stopst);
- */
-static char * /* == stop (success) always */
-dissect(m, start, stop, startst, stopst)
-register struct match *m;
-char *start;
-char *stop;
-sopno startst;
-sopno stopst;
-{
- register int i;
- register sopno ss; /* start sop of current subRE */
- register sopno es; /* end sop of current subRE */
- register char *sp; /* start of string matched by it */
- register char *stp; /* string matched by it cannot pass here */
- register char *rest; /* start of rest of string */
- register char *tail; /* string unmatched by rest of RE */
- register sopno ssub; /* start sop of subsubRE */
- register sopno esub; /* end sop of subsubRE */
- register char *ssp; /* start of string matched by subsubRE */
- register char *sep; /* end of string matched by subsubRE */
- register char *oldssp; /* previous ssp */
- register char *dp;
-
- AT("diss", start, stop, startst, stopst);
- sp = start;
- for (ss = startst; ss < stopst; ss = es) {
- /* identify end of subRE */
- es = ss;
- switch (OP(m->g->strip[es])) {
- case OPLUS_:
- case OQUEST_:
- es += OPND(m->g->strip[es]);
- break;
- case OCH_:
- while (OP(m->g->strip[es]) != O_CH)
- es += OPND(m->g->strip[es]);
- break;
- }
- es++;
-
- /* figure out what it matched */
- switch (OP(m->g->strip[ss])) {
- case OEND:
- assert(nope);
- break;
- case OCHAR:
- sp++;
- break;
- case OBOL:
- case OEOL:
- case OBOW:
- case OEOW:
- break;
- case OANY:
- case OANYOF:
- sp++;
- break;
- case OBACK_:
- case O_BACK:
- assert(nope);
- break;
- /* cases where length of match is hard to find */
- case OQUEST_:
- stp = stop;
- for (;;) {
- /* how long could this one be? */
- rest = slow(m, sp, stp, ss, es);
- assert(rest != NULL); /* it did match */
- /* could the rest match the rest? */
- tail = slow(m, rest, stop, es, stopst);
- if (tail == stop)
- break; /* yes! */
- /* no -- try a shorter match for this one */
- stp = rest - 1;
- assert(stp >= sp); /* it did work */
- }
- ssub = ss + 1;
- esub = es - 1;
- /* did innards match? */
- if (slow(m, sp, rest, ssub, esub) != NULL) {
- dp = dissect(m, sp, rest, ssub, esub);
- assert(dp == rest);
- } else /* no */
- assert(sp == rest);
- sp = rest;
- break;
- case OPLUS_:
- stp = stop;
- for (;;) {
- /* how long could this one be? */
- rest = slow(m, sp, stp, ss, es);
- assert(rest != NULL); /* it did match */
- /* could the rest match the rest? */
- tail = slow(m, rest, stop, es, stopst);
- if (tail == stop)
- break; /* yes! */
- /* no -- try a shorter match for this one */
- stp = rest - 1;
- assert(stp >= sp); /* it did work */
- }
- ssub = ss + 1;
- esub = es - 1;
- ssp = sp;
- oldssp = ssp;
- for (;;) { /* find last match of innards */
- sep = slow(m, ssp, rest, ssub, esub);
- if (sep == NULL || sep == ssp)
- break; /* failed or matched null */
- oldssp = ssp; /* on to next try */
- ssp = sep;
- }
- if (sep == NULL) {
- /* last successful match */
- sep = ssp;
- ssp = oldssp;
- }
- assert(sep == rest); /* must exhaust substring */
- assert(slow(m, ssp, sep, ssub, esub) == rest);
- dp = dissect(m, ssp, sep, ssub, esub);
- assert(dp == sep);
- sp = rest;
- break;
- case OCH_:
- stp = stop;
- for (;;) {
- /* how long could this one be? */
- rest = slow(m, sp, stp, ss, es);
- assert(rest != NULL); /* it did match */
- /* could the rest match the rest? */
- tail = slow(m, rest, stop, es, stopst);
- if (tail == stop)
- break; /* yes! */
- /* no -- try a shorter match for this one */
- stp = rest - 1;
- assert(stp >= sp); /* it did work */
- }
- ssub = ss + 1;
- esub = ss + OPND(m->g->strip[ss]) - 1;
- assert(OP(m->g->strip[esub]) == OOR1);
- for (;;) { /* find first matching branch */
- if (slow(m, sp, rest, ssub, esub) == rest)
- break; /* it matched all of it */
- /* that one missed, try next one */
- assert(OP(m->g->strip[esub]) == OOR1);
- esub++;
- assert(OP(m->g->strip[esub]) == OOR2);
- ssub = esub + 1;
- esub += OPND(m->g->strip[esub]);
- if (OP(m->g->strip[esub]) == OOR2)
- esub--;
- else
- assert(OP(m->g->strip[esub]) == O_CH);
- }
- dp = dissect(m, sp, rest, ssub, esub);
- assert(dp == rest);
- sp = rest;
- break;
- case O_PLUS:
- case O_QUEST:
- case OOR1:
- case OOR2:
- case O_CH:
- assert(nope);
- break;
- case OLPAREN:
- i = OPND(m->g->strip[ss]);
- assert(0 < i && i <= m->g->nsub);
- m->pmatch[i].rm_so = sp - m->offp;
- break;
- case ORPAREN:
- i = OPND(m->g->strip[ss]);
- assert(0 < i && i <= m->g->nsub);
- m->pmatch[i].rm_eo = sp - m->offp;
- break;
- default: /* uh oh */
- assert(nope);
- break;
- }
- }
-
- assert(sp == stop);
- return(sp);
-}
-
-/*
- - backref - figure out what matched what, figuring in back references
- == static char *backref(register struct match *m, char *start, \
- == char *stop, sopno startst, sopno stopst, sopno lev);
- */
-static char * /* == stop (success) or NULL (failure) */
-backref(m, start, stop, startst, stopst, lev)
-register struct match *m;
-char *start;
-char *stop;
-sopno startst;
-sopno stopst;
-sopno lev; /* PLUS nesting level */
-{
- register int i;
- register sopno ss; /* start sop of current subRE */
- register char *sp; /* start of string matched by it */
- register sopno ssub; /* start sop of subsubRE */
- register sopno esub; /* end sop of subsubRE */
- register char *ssp; /* start of string matched by subsubRE */
- register char *dp;
- register size_t len;
- register int hard;
- register sop s;
- register regoff_t offsave;
- register cset *cs;
-
- AT("back", start, stop, startst, stopst);
- sp = start;
-
- /* get as far as we can with easy stuff */
- hard = 0;
- for (ss = startst; !hard && ss < stopst; ss++)
- switch (OP(s = m->g->strip[ss])) {
- case OCHAR:
- if (sp == stop || *sp++ != (char)OPND(s))
- return(NULL);
- break;
- case OANY:
- if (sp == stop)
- return(NULL);
- sp++;
- break;
- case OANYOF:
- cs = &m->g->sets[OPND(s)];
- if (sp == stop || !CHIN(cs, *sp++))
- return(NULL);
- break;
- case OBOL:
- if ( (sp == m->beginp && !(m->eflags&REG_NOTBOL)) ||
- (sp < m->endp && *(sp-1) == '\n' &&
- (m->g->cflags&REG_NEWLINE)) )
- { /* yes */ }
- else
- return(NULL);
- break;
- case OEOL:
- if ( (sp == m->endp && !(m->eflags&REG_NOTEOL)) ||
- (sp < m->endp && *sp == '\n' &&
- (m->g->cflags&REG_NEWLINE)) )
- { /* yes */ }
- else
- return(NULL);
- break;
- case OBOW:
- if (( (sp == m->beginp && !(m->eflags&REG_NOTBOL)) ||
- (sp < m->endp && *(sp-1) == '\n' &&
- (m->g->cflags&REG_NEWLINE)) ||
- (sp > m->beginp &&
- !ISWORD(*(sp-1))) ) &&
- (sp < m->endp && ISWORD(*sp)) )
- { /* yes */ }
- else
- return(NULL);
- break;
- case OEOW:
- if (( (sp == m->endp && !(m->eflags&REG_NOTEOL)) ||
- (sp < m->endp && *sp == '\n' &&
- (m->g->cflags&REG_NEWLINE)) ||
- (sp < m->endp && !ISWORD(*sp)) ) &&
- (sp > m->beginp && ISWORD(*(sp-1))) )
- { /* yes */ }
- else
- return(NULL);
- break;
- case O_QUEST:
- break;
- case OOR1: /* matches null but needs to skip */
- ss++;
- s = m->g->strip[ss];
- do {
- assert(OP(s) == OOR2);
- ss += OPND(s);
- } while (OP(s = m->g->strip[ss]) != O_CH);
- /* note that the ss++ gets us past the O_CH */
- break;
- default: /* have to make a choice */
- hard = 1;
- break;
- }
- if (!hard) { /* that was it! */
- if (sp != stop)
- return(NULL);
- return(sp);
- }
- ss--; /* adjust for the for's final increment */
-
- /* the hard stuff */
- AT("hard", sp, stop, ss, stopst);
- s = m->g->strip[ss];
- switch (OP(s)) {
- case OBACK_: /* the vilest depths */
- i = OPND(s);
- assert(0 < i && i <= m->g->nsub);
- if (m->pmatch[i].rm_eo == -1)
- return(NULL);
- assert(m->pmatch[i].rm_so != -1);
- len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so;
- assert(stop - m->beginp >= len);
- if (sp > stop - len)
- return(NULL); /* not enough left to match */
- ssp = m->offp + m->pmatch[i].rm_so;
- if (memcmp(sp, ssp, len) != 0)
- return(NULL);
- while (m->g->strip[ss] != SOP(O_BACK, i))
- ss++;
- return(backref(m, sp+len, stop, ss+1, stopst, lev));
- break;
- case OQUEST_: /* to null or not */
- dp = backref(m, sp, stop, ss+1, stopst, lev);
- if (dp != NULL)
- return(dp); /* not */
- return(backref(m, sp, stop, ss+OPND(s)+1, stopst, lev));
- break;
- case OPLUS_:
- assert(m->lastpos != NULL);
- assert(lev+1 <= m->g->nplus);
- m->lastpos[lev+1] = sp;
- return(backref(m, sp, stop, ss+1, stopst, lev+1));
- break;
- case O_PLUS:
- if (sp == m->lastpos[lev]) /* last pass matched null */
- return(backref(m, sp, stop, ss+1, stopst, lev-1));
- /* try another pass */
- m->lastpos[lev] = sp;
- dp = backref(m, sp, stop, ss-OPND(s)+1, stopst, lev);
- if (dp == NULL)
- return(backref(m, sp, stop, ss+1, stopst, lev-1));
- else
- return(dp);
- break;
- case OCH_: /* find the right one, if any */
- ssub = ss + 1;
- esub = ss + OPND(s) - 1;
- assert(OP(m->g->strip[esub]) == OOR1);
- for (;;) { /* find first matching branch */
- dp = backref(m, sp, stop, ssub, esub, lev);
- if (dp != NULL)
- return(dp);
- /* that one missed, try next one */
- if (OP(m->g->strip[esub]) == O_CH)
- return(NULL); /* there is none */
- esub++;
- assert(OP(m->g->strip[esub]) == OOR2);
- ssub = esub + 1;
- esub += OPND(m->g->strip[esub]);
- if (OP(m->g->strip[esub]) == OOR2)
- esub--;
- else
- assert(OP(m->g->strip[esub]) == O_CH);
- }
- break;
- case OLPAREN: /* must undo assignment if rest fails */
- i = OPND(s);
- assert(0 < i && i <= m->g->nsub);
- offsave = m->pmatch[i].rm_so;
- m->pmatch[i].rm_so = sp - m->offp;
- dp = backref(m, sp, stop, ss+1, stopst, lev);
- if (dp != NULL)
- return(dp);
- m->pmatch[i].rm_so = offsave;
- return(NULL);
- break;
- case ORPAREN: /* must undo assignment if rest fails */
- i = OPND(s);
- assert(0 < i && i <= m->g->nsub);
- offsave = m->pmatch[i].rm_eo;
- m->pmatch[i].rm_eo = sp - m->offp;
- dp = backref(m, sp, stop, ss+1, stopst, lev);
- if (dp != NULL)
- return(dp);
- m->pmatch[i].rm_eo = offsave;
- return(NULL);
- break;
- default: /* uh oh */
- assert(nope);
- break;
- }
-
- /* "can't happen" */
- assert(nope);
- /* NOTREACHED */
- return( NULL );
-}
-
-/*
- - fast - step through the string at top speed
- == static char *fast(register struct match *m, char *start, \
- == char *stop, sopno startst, sopno stopst);
- */
-static char * /* where tentative match ended, or NULL */
-fast(m, start, stop, startst, stopst)
-register struct match *m;
-char *start;
-char *stop;
-sopno startst;
-sopno stopst;
-{
- register states st = m->st;
- register states fresh = m->fresh;
- register states tmp = m->tmp;
- register char *p = start;
- register int c = (start == m->beginp) ? OUT : *(start-1);
- register int lastc; /* previous c */
- register int flagch;
- register int i;
- register char *coldp; /* last p after which no match was underway */
-
- CLEAR(st);
- SET1(st, startst);
- st = step(m->g, startst, stopst, st, NOTHING, st);
- ASSIGN(fresh, st);
- SP("start", st, *p);
- coldp = NULL;
- for (;;) {
- /* next character */
- lastc = c;
- c = (p == m->endp) ? OUT : *p;
- if (EQ(st, fresh))
- coldp = p;
-
- /* is there an EOL and/or BOL between lastc and c? */
- flagch = '\0';
- i = 0;
- if ( (lastc == '\n' && m->g->cflags&REG_NEWLINE) ||
- (lastc == OUT && !(m->eflags&REG_NOTBOL)) ) {
- flagch = BOL;
- i = m->g->nbol;
- }
- if ( (c == '\n' && m->g->cflags&REG_NEWLINE) ||
- (c == OUT && !(m->eflags&REG_NOTEOL)) ) {
- flagch = (flagch == BOL) ? BOLEOL : EOL;
- i += m->g->neol;
- }
- if (i != 0) {
- for (; i > 0; i--)
- st = step(m->g, startst, stopst, st, flagch, st);
- SP("boleol", st, c);
- }
-
- /* how about a word boundary? */
- if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) &&
- (c != OUT && ISWORD(c)) ) {
- flagch = BOW;
- }
- if ( (lastc != OUT && ISWORD(lastc)) &&
- (flagch == EOL || (c != OUT && !ISWORD(c))) ) {
- flagch = EOW;
- }
- if (flagch == BOW || flagch == EOW) {
- st = step(m->g, startst, stopst, st, flagch, st);
- SP("boweow", st, c);
- }
-
- /* are we done? */
- if (ISSET(st, stopst) || p == stop)
- break; /* NOTE BREAK OUT */
-
- /* no, we must deal with this character */
- ASSIGN(tmp, st);
- ASSIGN(st, fresh);
- assert(c != OUT);
- st = step(m->g, startst, stopst, tmp, c, st);
- SP("aft", st, c);
- assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st));
- p++;
- }
-
- assert(coldp != NULL);
- m->coldp = coldp;
- if (ISSET(st, stopst))
- return(p+1);
- else
- return(NULL);
-}
-
-/*
- - slow - step through the string more deliberately
- == static char *slow(register struct match *m, char *start, \
- == char *stop, sopno startst, sopno stopst);
- */
-static char * /* where it ended */
-slow(m, start, stop, startst, stopst)
-register struct match *m;
-char *start;
-char *stop;
-sopno startst;
-sopno stopst;
-{
- register states st = m->st;
- register states empty = m->empty;
- register states tmp = m->tmp;
- register char *p = start;
- register int c = (start == m->beginp) ? OUT : *(start-1);
- register int lastc; /* previous c */
- register int flagch;
- register int i;
- register char *matchp; /* last p at which a match ended */
-
- AT("slow", start, stop, startst, stopst);
- CLEAR(st);
- SET1(st, startst);
- SP("sstart", st, *p);
- st = step(m->g, startst, stopst, st, NOTHING, st);
- matchp = NULL;
- for (;;) {
- /* next character */
- lastc = c;
- c = (p == m->endp) ? OUT : *p;
-
- /* is there an EOL and/or BOL between lastc and c? */
- flagch = '\0';
- i = 0;
- if ( (lastc == '\n' && m->g->cflags&REG_NEWLINE) ||
- (lastc == OUT && !(m->eflags&REG_NOTBOL)) ) {
- flagch = BOL;
- i = m->g->nbol;
- }
- if ( (c == '\n' && m->g->cflags&REG_NEWLINE) ||
- (c == OUT && !(m->eflags&REG_NOTEOL)) ) {
- flagch = (flagch == BOL) ? BOLEOL : EOL;
- i += m->g->neol;
- }
- if (i != 0) {
- for (; i > 0; i--)
- st = step(m->g, startst, stopst, st, flagch, st);
- SP("sboleol", st, c);
- }
-
- /* how about a word boundary? */
- if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) &&
- (c != OUT && ISWORD(c)) ) {
- flagch = BOW;
- }
- if ( (lastc != OUT && ISWORD(lastc)) &&
- (flagch == EOL || (c != OUT && !ISWORD(c))) ) {
- flagch = EOW;
- }
- if (flagch == BOW || flagch == EOW) {
- st = step(m->g, startst, stopst, st, flagch, st);
- SP("sboweow", st, c);
- }
-
- /* are we done? */
- if (ISSET(st, stopst))
- matchp = p;
- if (EQ(st, empty) || p == stop)
- break; /* NOTE BREAK OUT */
-
- /* no, we must deal with this character */
- ASSIGN(tmp, st);
- ASSIGN(st, empty);
- assert(c != OUT);
- st = step(m->g, startst, stopst, tmp, c, st);
- SP("saft", st, c);
- assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st));
- p++;
- }
-
- return(matchp);
-}
-
-
-/*
- - step - map set of states reachable before char to set reachable after
- == static states step(register struct re_guts *g, sopno start, sopno stop, \
- == register states bef, int ch, register states aft);
- == #define BOL (OUT+1)
- == #define EOL (BOL+1)
- == #define BOLEOL (BOL+2)
- == #define NOTHING (BOL+3)
- == #define BOW (BOL+4)
- == #define EOW (BOL+5)
- == #define CODEMAX (BOL+5) // highest code used
- == #define NONCHAR(c) ((c) > CHAR_MAX)
- == #define NNONCHAR (CODEMAX-CHAR_MAX)
- */
-static states
-step(g, start, stop, bef, ch, aft)
-register struct re_guts *g;
-sopno start; /* start state within strip */
-sopno stop; /* state after stop state within strip */
-register states bef; /* states reachable before */
-int ch; /* character or NONCHAR code */
-register states aft; /* states already known reachable after */
-{
- register cset *cs;
- register sop s;
- register sopno pc;
- register onestate here; /* note, macros know this name */
- register sopno look;
- register int i;
-
- for (pc = start, INIT(here, pc); pc != stop; pc++, INC(here)) {
- s = g->strip[pc];
- switch (OP(s)) {
- case OEND:
- assert(pc == stop-1);
- break;
- case OCHAR:
- /* only characters can match */
- assert(!NONCHAR(ch) || ch != (char)OPND(s));
- if (ch == (char)OPND(s))
- FWD(aft, bef, 1);
- break;
- case OBOL:
- if (ch == BOL || ch == BOLEOL)
- FWD(aft, bef, 1);
- break;
- case OEOL:
- if (ch == EOL || ch == BOLEOL)
- FWD(aft, bef, 1);
- break;
- case OBOW:
- if (ch == BOW)
- FWD(aft, bef, 1);
- break;
- case OEOW:
- if (ch == EOW)
- FWD(aft, bef, 1);
- break;
- case OANY:
- if (!NONCHAR(ch))
- FWD(aft, bef, 1);
- break;
- case OANYOF:
- cs = &g->sets[OPND(s)];
- if (!NONCHAR(ch) && CHIN(cs, ch))
- FWD(aft, bef, 1);
- break;
- case OBACK_: /* ignored here */
- case O_BACK:
- FWD(aft, aft, 1);
- break;
- case OPLUS_: /* forward, this is just an empty */
- FWD(aft, aft, 1);
- break;
- case O_PLUS: /* both forward and back */
- FWD(aft, aft, 1);
- i = ISSETBACK(aft, OPND(s));
- BACK(aft, aft, OPND(s));
- if (!i && ISSETBACK(aft, OPND(s))) {
- /* oho, must reconsider loop body */
- pc -= OPND(s) + 1;
- INIT(here, pc);
- }
- break;
- case OQUEST_: /* two branches, both forward */
- FWD(aft, aft, 1);
- FWD(aft, aft, OPND(s));
- break;
- case O_QUEST: /* just an empty */
- FWD(aft, aft, 1);
- break;
- case OLPAREN: /* not significant here */
- case ORPAREN:
- FWD(aft, aft, 1);
- break;
- case OCH_: /* mark the first two branches */
- FWD(aft, aft, 1);
- assert(OP(g->strip[pc+OPND(s)]) == OOR2);
- FWD(aft, aft, OPND(s));
- break;
- case OOR1: /* done a branch, find the O_CH */
- if (ISSTATEIN(aft, here)) {
- for (look = 1;
- OP(s = g->strip[pc+look]) != O_CH;
- look += OPND(s))
- assert(OP(s) == OOR2);
- FWD(aft, aft, look);
- }
- break;
- case OOR2: /* propagate OCH_'s marking */
- FWD(aft, aft, 1);
- if (OP(g->strip[pc+OPND(s)]) != O_CH) {
- assert(OP(g->strip[pc+OPND(s)]) == OOR2);
- FWD(aft, aft, OPND(s));
- }
- break;
- case O_CH: /* just empty */
- FWD(aft, aft, 1);
- break;
- default: /* ooooops... */
- assert(nope);
- break;
- }
- }
-
- return(aft);
-}
-
-#ifdef REDEBUG
-/*
- - print - print a set of states
- == #ifdef REDEBUG
- == static void print(struct match *m, char *caption, states st, \
- == int ch, FILE *d);
- == #endif
- */
-static void
-print(m, caption, st, ch, d)
-struct match *m;
-char *caption;
-states st;
-int ch;
-FILE *d;
-{
- register struct re_guts *g = m->g;
- register int i;
- register int first = 1;
-
- if (!(m->eflags&REG_TRACE))
- return;
-
- fprintf(d, "%s", caption);
- if (ch != '\0')
- fprintf(d, " %s", pchar(ch));
- for (i = 0; i < g->nstates; i++)
- if (ISSET(st, i)) {
- fprintf(d, "%s%d", (first) ? "\t" : ", ", i);
- first = 0;
- }
- fprintf(d, "\n");
-}
-
-/*
- - at - print current situation
- == #ifdef REDEBUG
- == static void at(struct match *m, char *title, char *start, char *stop, \
- == sopno startst, sopno stopst);
- == #endif
- */
-static void
-at(m, title, start, stop, startst, stopst)
-struct match *m;
-char *title;
-char *start;
-char *stop;
-sopno startst;
-sopno stopst;
-{
- if (!(m->eflags&REG_TRACE))
- return;
-
- printf("%s %s-", title, pchar(*start));
- printf("%s ", pchar(*stop));
- printf("%ld-%ld\n", (long)startst, (long)stopst);
-}
-
-#ifndef PCHARDONE
-#define PCHARDONE /* never again */
-/*
- - pchar - make a character printable
- == #ifdef REDEBUG
- == static char *pchar(int ch);
- == #endif
- *
- * Is this identical to regchar() over in debug.c? Well, yes. But a
- * duplicate here avoids having a debugging-capable regexec.o tied to
- * a matching debug.o, and this is convenient. It all disappears in
- * the non-debug compilation anyway, so it doesn't matter much.
- */
-static char * /* -> representation */
-pchar(ch)
-int ch;
-{
- static char pbuf[10];
-
- if (isprint(ch) || ch == ' ')
- sprintf(pbuf, "%c", ch);
- else
- sprintf(pbuf, "\\%o", ch);
- return(pbuf);
-}
-#endif
-#endif
-
-#undef matcher
-#undef fast
-#undef slow
-#undef dissect
-#undef backref
-#undef step
-#undef print
-#undef at
-#undef match
diff --git a/ext/ereg/regex/engine.ih b/ext/ereg/regex/engine.ih
deleted file mode 100644
index cc98334e75..0000000000
--- a/ext/ereg/regex/engine.ih
+++ /dev/null
@@ -1,35 +0,0 @@
-/* ========= begin header generated by ./mkh ========= */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* === engine.c === */
-static int matcher(register struct re_guts *g, char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
-static char *dissect(register struct match *m, char *start, char *stop, sopno startst, sopno stopst);
-static char *backref(register struct match *m, char *start, char *stop, sopno startst, sopno stopst, sopno lev);
-static char *fast(register struct match *m, char *start, char *stop, sopno startst, sopno stopst);
-static char *slow(register struct match *m, char *start, char *stop, sopno startst, sopno stopst);
-static states step(register struct re_guts *g, sopno start, sopno stop, register states bef, int ch, register states aft);
-#define BOL (OUT+1)
-#define EOL (BOL+1)
-#define BOLEOL (BOL+2)
-#define NOTHING (BOL+3)
-#define BOW (BOL+4)
-#define EOW (BOL+5)
-#define CODEMAX (BOL+5) /* highest code used */
-#define NONCHAR(c) ((c) > CHAR_MAX)
-#define NNONCHAR (CODEMAX-CHAR_MAX)
-#ifdef REDEBUG
-static void print(struct match *m, char *caption, states st, int ch, FILE *d);
-#endif
-#ifdef REDEBUG
-static void at(struct match *m, char *title, char *start, char *stop, sopno startst, sopno stopst);
-#endif
-#ifdef REDEBUG
-static char *pchar(int ch);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-/* ========= end header generated by ./mkh ========= */
diff --git a/ext/ereg/regex/main.c b/ext/ereg/regex/main.c
deleted file mode 100644
index 657338a2c1..0000000000
--- a/ext/ereg/regex/main.c
+++ /dev/null
@@ -1,510 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <regex.h>
-#include <assert.h>
-#include <stdlib.h>
-
-#include "main.ih"
-
-char *progname;
-int debug = 0;
-int line = 0;
-int status = 0;
-
-int copts = REG_EXTENDED;
-int eopts = 0;
-regoff_t startoff = 0;
-regoff_t endoff = 0;
-
-
-extern int split();
-extern void regprint();
-
-/*
- - main - do the simple case, hand off to regress() for regression
- */
-int main(argc, argv)
-int argc;
-char *argv[];
-{
- regex_t re;
-# define NS 10
- regmatch_t subs[NS];
- char erbuf[100];
- int err;
- size_t len;
- int c;
- int errflg = 0;
- register int i;
- extern int optind;
- extern char *optarg;
-
- progname = argv[0];
-
- while ((c = getopt(argc, argv, "c:e:S:E:x")) != EOF)
- switch (c) {
- case 'c': /* compile options */
- copts = options('c', optarg);
- break;
- case 'e': /* execute options */
- eopts = options('e', optarg);
- break;
- case 'S': /* start offset */
- startoff = (regoff_t)atoi(optarg);
- break;
- case 'E': /* end offset */
- endoff = (regoff_t)atoi(optarg);
- break;
- case 'x': /* Debugging. */
- debug++;
- break;
- case '?':
- default:
- errflg++;
- break;
- }
- if (errflg) {
- fprintf(stderr, "usage: %s ", progname);
- fprintf(stderr, "[-c copt][-C][-d] [re]\n");
- exit(2);
- }
-
- if (optind >= argc) {
- regress(stdin);
- exit(status);
- }
-
- err = regcomp(&re, argv[optind++], copts);
- if (err) {
- len = regerror(err, &re, erbuf, sizeof(erbuf));
- fprintf(stderr, "error %s, %d/%d `%s'\n",
- eprint(err), len, sizeof(erbuf), erbuf);
- exit(status);
- }
- regprint(&re, stdout);
-
- if (optind >= argc) {
- regfree(&re);
- exit(status);
- }
-
- if (eopts&REG_STARTEND) {
- subs[0].rm_so = startoff;
- subs[0].rm_eo = strlen(argv[optind]) - endoff;
- }
- err = regexec(&re, argv[optind], (size_t)NS, subs, eopts);
- if (err) {
- len = regerror(err, &re, erbuf, sizeof(erbuf));
- fprintf(stderr, "error %s, %d/%d `%s'\n",
- eprint(err), len, sizeof(erbuf), erbuf);
- exit(status);
- }
- if (!(copts&REG_NOSUB)) {
- len = (int)(subs[0].rm_eo - subs[0].rm_so);
- if (subs[0].rm_so != -1) {
- if (len != 0)
- printf("match `%.*s'\n", (int)len,
- argv[optind] + subs[0].rm_so);
- else
- printf("match `'@%.1s\n",
- argv[optind] + subs[0].rm_so);
- }
- for (i = 1; i < NS; i++)
- if (subs[i].rm_so != -1)
- printf("(%d) `%.*s'\n", i,
- (int)(subs[i].rm_eo - subs[i].rm_so),
- argv[optind] + subs[i].rm_so);
- }
- exit(status);
-}
-
-/*
- - regress - main loop of regression test
- == void regress(FILE *in);
- */
-void
-regress(in)
-FILE *in;
-{
- char inbuf[1000];
-# define MAXF 10
- char *f[MAXF];
- int nf;
- int i;
- char erbuf[100];
- size_t ne;
- char *badpat = "invalid regular expression";
-# define SHORT 10
- char *bpname = "REG_BADPAT";
- regex_t re;
-
- while (fgets(inbuf, sizeof(inbuf), in) != NULL) {
- line++;
- if (inbuf[0] == '#' || inbuf[0] == '\n')
- continue; /* NOTE CONTINUE */
- inbuf[strlen(inbuf)-1] = '\0'; /* get rid of stupid \n */
- if (debug)
- fprintf(stdout, "%d:\n", line);
- nf = split(inbuf, f, MAXF, "\t\t");
- if (nf < 3) {
- fprintf(stderr, "bad input, line %d\n", line);
- exit(1);
- }
- for (i = 0; i < nf; i++)
- if (strcmp(f[i], "\"\"") == 0)
- f[i] = "";
- if (nf <= 3)
- f[3] = NULL;
- if (nf <= 4)
- f[4] = NULL;
- try(f[0], f[1], f[2], f[3], f[4], options('c', f[1]));
- if (opt('&', f[1])) /* try with either type of RE */
- try(f[0], f[1], f[2], f[3], f[4],
- options('c', f[1]) &~ REG_EXTENDED);
- }
-
- ne = regerror(REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf));
- if (strcmp(erbuf, badpat) != 0 || ne != strlen(badpat)+1) {
- fprintf(stderr, "end: regerror() test gave `%s' not `%s'\n",
- erbuf, badpat);
- status = 1;
- }
- ne = regerror(REG_BADPAT, (regex_t *)NULL, erbuf, (size_t)SHORT);
- if (strncmp(erbuf, badpat, SHORT-1) != 0 || erbuf[SHORT-1] != '\0' ||
- ne != strlen(badpat)+1) {
- fprintf(stderr, "end: regerror() short test gave `%s' not `%.*s'\n",
- erbuf, SHORT-1, badpat);
- status = 1;
- }
- ne = regerror(REG_ITOA|REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf));
- if (strcmp(erbuf, bpname) != 0 || ne != strlen(bpname)+1) {
- fprintf(stderr, "end: regerror() ITOA test gave `%s' not `%s'\n",
- erbuf, bpname);
- status = 1;
- }
- re.re_endp = bpname;
- ne = regerror(REG_ATOI, &re, erbuf, sizeof(erbuf));
- if (atoi(erbuf) != (int)REG_BADPAT) {
- fprintf(stderr, "end: regerror() ATOI test gave `%s' not `%ld'\n",
- erbuf, (long)REG_BADPAT);
- status = 1;
- } else if (ne != strlen(erbuf)+1) {
- fprintf(stderr, "end: regerror() ATOI test len(`%s') = %ld\n",
- erbuf, (long)REG_BADPAT);
- status = 1;
- }
-}
-
-/*
- - try - try it, and report on problems
- == void try(char *f0, char *f1, char *f2, char *f3, char *f4, int opts);
- */
-void
-try(f0, f1, f2, f3, f4, opts)
-char *f0;
-char *f1;
-char *f2;
-char *f3;
-char *f4;
-int opts; /* may not match f1 */
-{
- regex_t re;
-# define NSUBS 10
- regmatch_t subs[NSUBS];
-# define NSHOULD 15
- char *should[NSHOULD];
- int nshould;
- char erbuf[100];
- int err;
- int len;
- char *type = (opts & REG_EXTENDED) ? "ERE" : "BRE";
- register int i;
- char *grump;
- char f0copy[1000];
- char f2copy[1000];
-
- strcpy(f0copy, f0);
- re.re_endp = (opts&REG_PEND) ? f0copy + strlen(f0copy) : NULL;
- fixstr(f0copy);
- err = regcomp(&re, f0copy, opts);
- if (err != 0 && (!opt('C', f1) || err != efind(f2))) {
- /* unexpected error or wrong error */
- len = regerror(err, &re, erbuf, sizeof(erbuf));
- fprintf(stderr, "%d: %s error %s, %d/%d `%s'\n",
- line, type, eprint(err), len,
- sizeof(erbuf), erbuf);
- status = 1;
- } else if (err == 0 && opt('C', f1)) {
- /* unexpected success */
- fprintf(stderr, "%d: %s should have given REG_%s\n",
- line, type, f2);
- status = 1;
- err = 1; /* so we won't try regexec */
- }
-
- if (err != 0) {
- regfree(&re);
- return;
- }
-
- strcpy(f2copy, f2);
- fixstr(f2copy);
-
- if (options('e', f1)&REG_STARTEND) {
- if (strchr(f2, '(') == NULL || strchr(f2, ')') == NULL)
- fprintf(stderr, "%d: bad STARTEND syntax\n", line);
- subs[0].rm_so = strchr(f2, '(') - f2 + 1;
- subs[0].rm_eo = strchr(f2, ')') - f2;
- }
- err = regexec(&re, f2copy, NSUBS, subs, options('e', f1));
-
- if (err != 0 && (f3 != NULL || err != REG_NOMATCH)) {
- /* unexpected error or wrong error */
- len = regerror(err, &re, erbuf, sizeof(erbuf));
- fprintf(stderr, "%d: %s exec error %s, %d/%d `%s'\n",
- line, type, eprint(err), len,
- sizeof(erbuf), erbuf);
- status = 1;
- } else if (err != 0) {
- /* nothing more to check */
- } else if (f3 == NULL) {
- /* unexpected success */
- fprintf(stderr, "%d: %s exec should have failed\n",
- line, type);
- status = 1;
- err = 1; /* just on principle */
- } else if (opts&REG_NOSUB) {
- /* nothing more to check */
- } else if ((grump = check(f2, subs[0], f3)) != NULL) {
- fprintf(stderr, "%d: %s %s\n", line, type, grump);
- status = 1;
- err = 1;
- }
-
- if (err != 0 || f4 == NULL) {
- regfree(&re);
- return;
- }
-
- for (i = 1; i < NSHOULD; i++)
- should[i] = NULL;
- nshould = split(f4, should+1, NSHOULD-1, ",");
- if (nshould == 0) {
- nshould = 1;
- should[1] = "";
- }
- for (i = 1; i < NSUBS; i++) {
- grump = check(f2, subs[i], should[i]);
- if (grump != NULL) {
- fprintf(stderr, "%d: %s $%d %s\n", line,
- type, i, grump);
- status = 1;
- err = 1;
- }
- }
-
- regfree(&re);
-}
-
-/*
- - options - pick options out of a regression-test string
- == int options(int type, char *s);
- */
-int
-options(type, s)
-int type; /* 'c' compile, 'e' exec */
-char *s;
-{
- register char *p;
- register int o = (type == 'c') ? copts : eopts;
- register char *legal = (type == 'c') ? "bisnmp" : "^$#tl";
-
- for (p = s; *p != '\0'; p++)
- if (strchr(legal, *p) != NULL)
- switch (*p) {
- case 'b':
- o &= ~REG_EXTENDED;
- break;
- case 'i':
- o |= REG_ICASE;
- break;
- case 's':
- o |= REG_NOSUB;
- break;
- case 'n':
- o |= REG_NEWLINE;
- break;
- case 'm':
- o &= ~REG_EXTENDED;
- o |= REG_NOSPEC;
- break;
- case 'p':
- o |= REG_PEND;
- break;
- case '^':
- o |= REG_NOTBOL;
- break;
- case '$':
- o |= REG_NOTEOL;
- break;
- case '#':
- o |= REG_STARTEND;
- break;
- case 't': /* trace */
- o |= REG_TRACE;
- break;
- case 'l': /* force long representation */
- o |= REG_LARGE;
- break;
- case 'r': /* force backref use */
- o |= REG_BACKR;
- break;
- }
- return(o);
-}
-
-/*
- - opt - is a particular option in a regression string?
- == int opt(int c, char *s);
- */
-int /* predicate */
-opt(c, s)
-int c;
-char *s;
-{
- return(strchr(s, c) != NULL);
-}
-
-/*
- - fixstr - transform magic characters in strings
- == void fixstr(register char *p);
- */
-void
-fixstr(p)
-register char *p;
-{
- if (p == NULL)
- return;
-
- for (; *p != '\0'; p++)
- if (*p == 'N')
- *p = '\n';
- else if (*p == 'T')
- *p = '\t';
- else if (*p == 'S')
- *p = ' ';
- else if (*p == 'Z')
- *p = '\0';
-}
-
-/*
- - check - check a substring match
- == char *check(char *str, regmatch_t sub, char *should);
- */
-char * /* NULL or complaint */
-check(str, sub, should)
-char *str;
-regmatch_t sub;
-char *should;
-{
- register int len;
- register int shlen;
- register char *p;
- static char grump[500];
- register char *at = NULL;
-
- if (should != NULL && strcmp(should, "-") == 0)
- should = NULL;
- if (should != NULL && should[0] == '@') {
- at = should + 1;
- should = "";
- }
-
- /* check rm_so and rm_eo for consistency */
- if (sub.rm_so > sub.rm_eo || (sub.rm_so == -1 && sub.rm_eo != -1) ||
- (sub.rm_so != -1 && sub.rm_eo == -1) ||
- (sub.rm_so != -1 && sub.rm_so < 0) ||
- (sub.rm_eo != -1 && sub.rm_eo < 0) ) {
- sprintf(grump, "start %ld end %ld", (long)sub.rm_so,
- (long)sub.rm_eo);
- return(grump);
- }
-
- /* check for no match */
- if (sub.rm_so == -1 && should == NULL)
- return(NULL);
- if (sub.rm_so == -1)
- return("did not match");
-
- /* check for in range */
- if (sub.rm_eo > strlen(str)) {
- sprintf(grump, "start %ld end %ld, past end of string",
- (long)sub.rm_so, (long)sub.rm_eo);
- return(grump);
- }
-
- len = (int)(sub.rm_eo - sub.rm_so);
- shlen = (int)strlen(should);
- p = str + sub.rm_so;
-
- /* check for not supposed to match */
- if (should == NULL) {
- sprintf(grump, "matched `%.*s'", len, p);
- return(grump);
- }
-
- /* check for wrong match */
- if (len != shlen || strncmp(p, should, (size_t)shlen) != 0) {
- sprintf(grump, "matched `%.*s' instead", len, p);
- return(grump);
- }
- if (shlen > 0)
- return(NULL);
-
- /* check null match in right place */
- if (at == NULL)
- return(NULL);
- shlen = strlen(at);
- if (shlen == 0)
- shlen = 1; /* force check for end-of-string */
- if (strncmp(p, at, shlen) != 0) {
- sprintf(grump, "matched null at `%.20s'", p);
- return(grump);
- }
- return(NULL);
-}
-
-/*
- - eprint - convert error number to name
- == static char *eprint(int err);
- */
-static char *
-eprint(err)
-int err;
-{
- static char epbuf[100];
- size_t len;
-
- len = regerror(REG_ITOA|err, (regex_t *)NULL, epbuf, sizeof(epbuf));
- assert(len <= sizeof(epbuf));
- return(epbuf);
-}
-
-/*
- - efind - convert error name to number
- == static int efind(char *name);
- */
-static int
-efind(name)
-char *name;
-{
- static char efbuf[100];
- regex_t re;
-
- sprintf(efbuf, "REG_%s", name);
- assert(strlen(efbuf) < sizeof(efbuf));
- re.re_endp = efbuf;
- (void) regerror(REG_ATOI, &re, efbuf, sizeof(efbuf));
- return(atoi(efbuf));
-}
diff --git a/ext/ereg/regex/main.ih b/ext/ereg/regex/main.ih
deleted file mode 100644
index 5a0118ac44..0000000000
--- a/ext/ereg/regex/main.ih
+++ /dev/null
@@ -1,19 +0,0 @@
-/* ========= begin header generated by ./mkh ========= */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* === main.c === */
-void regress(FILE *in);
-void try(char *f0, char *f1, char *f2, char *f3, char *f4, int opts);
-int options(int type, char *s);
-int opt(int c, char *s);
-void fixstr(register char *p);
-char *check(char *str, regmatch_t sub, char *should);
-static char *eprint(int err);
-static int efind(char *name);
-
-#ifdef __cplusplus
-}
-#endif
-/* ========= end header generated by ./mkh ========= */
diff --git a/ext/ereg/regex/mkh b/ext/ereg/regex/mkh
deleted file mode 100644
index 252b246c7b..0000000000
--- a/ext/ereg/regex/mkh
+++ /dev/null
@@ -1,76 +0,0 @@
-#! /bin/sh
-# mkh - pull headers out of C source
-PATH=/bin:/usr/bin ; export PATH
-
-# egrep pattern to pick out marked lines
-egrep='^ =([ ]|$)'
-
-# Sed program to process marked lines into lines for the header file.
-# The markers have already been removed. Two things are done here: removal
-# of backslashed newlines, and some fudging of comments. The first is done
-# because -o needs to have prototypes on one line to strip them down.
-# Getting comments into the output is tricky; we turn C++-style // comments
-# into /* */ comments, after altering any existing */'s to avoid trouble.
-peel=' /\\$/N
- /\\\n[ ]*/s///g
- /\/\//s;\*/;* /;g
- /\/\//s;//\(.*\);/*\1 */;'
-
-for a
-do
- case "$a" in
- -o) # old (pre-function-prototype) compiler
- # add code to comment out argument lists
- peel="$peel
- "'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1(/*\2*/);'
- shift
- ;;
- -b) # funny Berkeley __P macro
- peel="$peel
- "'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1 __P((\2));'
- shift
- ;;
- -s) # compiler doesn't like `static foo();'
- # add code to get rid of the `static'
- peel="$peel
- "'/^static[ ][^\/]*[a-zA-Z0-9_)](.*)/s;static.;;'
- shift
- ;;
- -p) # private declarations
- egrep='^ ==([ ]|$)'
- shift
- ;;
- -i) # wrap in #ifndef, argument is name
- ifndef="$2"
- shift ; shift
- ;;
- *) break
- ;;
- esac
-done
-
-if test " $ifndef" != " "
-then
- echo "#ifndef $ifndef"
- echo "#define $ifndef /* never again */"
-fi
-echo "/* ========= begin header generated by $0 ========= */"
-echo '#ifdef __cplusplus'
-echo 'extern "C" {'
-echo '#endif'
-for f
-do
- echo
- echo "/* === $f === */"
- egrep "$egrep" $f | sed 's/^ ==*[ ]//;s/^ ==*$//' | sed "$peel"
- echo
-done
-echo '#ifdef __cplusplus'
-echo '}'
-echo '#endif'
-echo "/* ========= end header generated by $0 ========= */"
-if test " $ifndef" != " "
-then
- echo "#endif"
-fi
-exit 0
diff --git a/ext/ereg/regex/regcomp.c b/ext/ereg/regex/regcomp.c
deleted file mode 100644
index 7f651bf845..0000000000
--- a/ext/ereg/regex/regcomp.c
+++ /dev/null
@@ -1,1546 +0,0 @@
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <regex.h>
-
-#include "utils.h"
-#include "regex2.h"
-
-#include "cclass.h"
-#include "cname.h"
-
-/*
- * parse structure, passed up and down to avoid global variables and
- * other clumsinesses
- */
-struct parse {
- char *next; /* next character in RE */
- char *end; /* end of string (-> NUL normally) */
- int error; /* has an error been seen? */
- sop *strip; /* malloced strip */
- sopno ssize; /* malloced strip size (allocated) */
- sopno slen; /* malloced strip length (used) */
- int ncsalloc; /* number of csets allocated */
- struct re_guts *g;
-# define NPAREN 10 /* we need to remember () 1-9 for back refs */
- sopno pbegin[NPAREN]; /* -> ( ([0] unused) */
- sopno pend[NPAREN]; /* -> ) ([0] unused) */
-};
-
-#include "regcomp.ih"
-
-static char nuls[10]; /* place to point scanner in event of error */
-
-/*
- * macros for use with parse structure
- * BEWARE: these know that the parse structure is named `p' !!!
- */
-#define PEEK() (*p->next)
-#define PEEK2() (*(p->next+1))
-#define MORE() (p->next < p->end)
-#define MORE2() (p->next+1 < p->end)
-#define SEE(c) (MORE() && PEEK() == (c))
-#define SEETWO(a, b) (MORE() && MORE2() && PEEK() == (a) && PEEK2() == (b))
-#define EAT(c) ((SEE(c)) ? (NEXT1(), 1) : 0)
-#define EATTWO(a, b) ((SEETWO(a, b)) ? (NEXT2(), 1) : 0)
-#define NEXT1() (p->next++)
-#define NEXT2() (p->next += 2)
-#define NEXTn(n) (p->next += (n))
-#define GETNEXT() (*p->next++)
-#define SETERROR(e) seterr(p, (e))
-#define REQUIRE(co, e) ((void)((co) || SETERROR(e)))
-#define MUSTSEE(c, e) (REQUIRE(MORE() && PEEK() == (c), e))
-#define MUSTEAT(c, e) (REQUIRE(MORE() && GETNEXT() == (c), e))
-#define MUSTNOTSEE(c, e) (REQUIRE(!MORE() || PEEK() != (c), e))
-#define EMIT(op, sopnd) doemit(p, (sop)(op), (size_t)(sopnd))
-#define INSERT(op, pos) doinsert(p, (sop)(op), HERE()-(pos)+1, pos)
-#define AHEAD(pos) dofwd(p, pos, HERE()-(pos))
-#define ASTERN(sop, pos) EMIT(sop, HERE()-pos)
-#define HERE() (p->slen)
-#define THERE() (p->slen - 1)
-#define THERETHERE() (p->slen - 2)
-#define DROP(n) (p->slen -= (n))
-
-#ifndef NDEBUG
-static int never = 0; /* for use in asserts; shuts lint up */
-#else
-#define never 0 /* some <assert.h>s have bugs too */
-#endif
-
-/*
- - regcomp - interface for parser and compilation
- = API_EXPORT(int) regcomp(regex_t *, const char *, int);
- = #define REG_BASIC 0000
- = #define REG_EXTENDED 0001
- = #define REG_ICASE 0002
- = #define REG_NOSUB 0004
- = #define REG_NEWLINE 0010
- = #define REG_NOSPEC 0020
- = #define REG_PEND 0040
- = #define REG_DUMP 0200
- */
-API_EXPORT(int) /* 0 success, otherwise REG_something */
-regcomp(preg, pattern, cflags)
-regex_t *preg;
-const char *pattern;
-int cflags;
-{
- struct parse pa;
- register struct re_guts *g;
- register struct parse *p = &pa;
- register int i;
- register size_t len;
-#ifdef REDEBUG
-# define GOODFLAGS(f) (f)
-#else
-# define GOODFLAGS(f) ((f)&~REG_DUMP)
-#endif
-
- cflags = GOODFLAGS(cflags);
- if ((cflags&REG_EXTENDED) && (cflags&REG_NOSPEC))
- return(REG_INVARG);
-
- if (cflags&REG_PEND) {
- if (preg->re_endp < pattern)
- return(REG_INVARG);
- len = preg->re_endp - pattern;
- } else
- len = strlen((char *)pattern);
-
- /* do the mallocs early so failure handling is easy */
- g = (struct re_guts *)malloc(sizeof(struct re_guts) +
- (NC-1)*sizeof(cat_t));
- if (g == NULL)
- return(REG_ESPACE);
- p->ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */
- p->strip = (sop *)malloc(p->ssize * sizeof(sop));
- p->slen = 0;
- if (p->strip == NULL) {
- free((char *)g);
- return(REG_ESPACE);
- }
-
- /* set things up */
- p->g = g;
- p->next = (char *)pattern; /* convenience; we do not modify it */
- p->end = p->next + len;
- p->error = 0;
- p->ncsalloc = 0;
- for (i = 0; i < NPAREN; i++) {
- p->pbegin[i] = 0;
- p->pend[i] = 0;
- }
- g->csetsize = NC;
- g->sets = NULL;
- g->setbits = NULL;
- g->ncsets = 0;
- g->cflags = cflags;
- g->iflags = 0;
- g->nbol = 0;
- g->neol = 0;
- g->must = NULL;
- g->mlen = 0;
- g->nsub = 0;
- g->ncategories = 1; /* category 0 is "everything else" */
- g->categories = &g->catspace[-(CHAR_MIN)];
- (void) memset((char *)g->catspace, 0, NC*sizeof(cat_t));
- g->backrefs = 0;
-
- /* do it */
- EMIT(OEND, 0);
- g->firststate = THERE();
- if (cflags&REG_EXTENDED)
- p_ere(p, OUT);
- else if (cflags&REG_NOSPEC)
- p_str(p);
- else
- p_bre(p, OUT, OUT);
- EMIT(OEND, 0);
- g->laststate = THERE();
-
- /* tidy up loose ends and fill things in */
- categorize(p, g);
- stripsnug(p, g);
- findmust(p, g);
- g->nplus = pluscount(p, g);
- g->magic = MAGIC2;
- preg->re_nsub = g->nsub;
- preg->re_g = g;
- preg->re_magic = MAGIC1;
-#ifndef REDEBUG
- /* not debugging, so can't rely on the assert() in regexec() */
- if (g->iflags&BAD)
- SETERROR(REG_ASSERT);
-#endif
-
- /* win or lose, we're done */
- if (p->error != 0) /* lose */
- regfree(preg);
- return(p->error);
-}
-
-/*
- - p_ere - ERE parser top level, concatenation and alternation
- == static void p_ere(register struct parse *p, int stop);
- */
-static void
-p_ere(p, stop)
-register struct parse *p;
-int stop; /* character this ERE should end at */
-{
- register char c;
- register sopno prevback = 0;
- register sopno prevfwd = 0;
- register sopno conc;
- register int first = 1; /* is this the first alternative? */
-
- for (;;) {
- /* do a bunch of concatenated expressions */
- conc = HERE();
- while (MORE() && (c = PEEK()) != '|' && c != stop)
- p_ere_exp(p);
- REQUIRE(HERE() != conc, REG_EMPTY); /* require nonempty */
-
- if (!EAT('|'))
- break; /* NOTE BREAK OUT */
-
- if (first) {
- INSERT(OCH_, conc); /* offset is wrong */
- prevfwd = conc;
- prevback = conc;
- first = 0;
- }
- ASTERN(OOR1, prevback);
- prevback = THERE();
- AHEAD(prevfwd); /* fix previous offset */
- prevfwd = HERE();
- EMIT(OOR2, 0); /* offset is very wrong */
- }
-
- if (!first) { /* tail-end fixups */
- AHEAD(prevfwd);
- ASTERN(O_CH, prevback);
- }
-
- assert(!MORE() || SEE(stop));
-}
-
-/*
- - p_ere_exp - parse one subERE, an atom possibly followed by a repetition op
- == static void p_ere_exp(register struct parse *p);
- */
-static void
-p_ere_exp(p)
-register struct parse *p;
-{
- register char c;
- register sopno pos;
- register int count;
- register int count2;
- register sopno subno;
- int wascaret = 0;
-
- assert(MORE()); /* caller should have ensured this */
- c = GETNEXT();
-
- pos = HERE();
- switch (c) {
- case '(':
- REQUIRE(MORE(), REG_EPAREN);
- p->g->nsub++;
- subno = p->g->nsub;
- if (subno < NPAREN)
- p->pbegin[subno] = HERE();
- EMIT(OLPAREN, subno);
- if (!SEE(')'))
- p_ere(p, ')');
- if (subno < NPAREN) {
- p->pend[subno] = HERE();
- assert(p->pend[subno] != 0);
- }
- EMIT(ORPAREN, subno);
- MUSTEAT(')', REG_EPAREN);
- break;
-#ifndef POSIX_MISTAKE
- case ')': /* happens only if no current unmatched ( */
- /*
- * You may ask, why the ifndef? Because I didn't notice
- * this until slightly too late for 1003.2, and none of the
- * other 1003.2 regular-expression reviewers noticed it at
- * all. So an unmatched ) is legal POSIX, at least until
- * we can get it fixed.
- */
- SETERROR(REG_EPAREN);
- break;
-#endif
- case '^':
- EMIT(OBOL, 0);
- p->g->iflags |= USEBOL;
- p->g->nbol++;
- wascaret = 1;
- break;
- case '$':
- EMIT(OEOL, 0);
- p->g->iflags |= USEEOL;
- p->g->neol++;
- break;
- case '|':
- SETERROR(REG_EMPTY);
- break;
- case '*':
- case '+':
- case '?':
- SETERROR(REG_BADRPT);
- break;
- case '.':
- if (p->g->cflags&REG_NEWLINE)
- nonnewline(p);
- else
- EMIT(OANY, 0);
- break;
- case '[':
- p_bracket(p);
- break;
- case '\\':
- REQUIRE(MORE(), REG_EESCAPE);
- c = GETNEXT();
- ordinary(p, c);
- break;
- case '{': /* okay as ordinary except if digit follows */
- REQUIRE(!MORE() || !isdigit(PEEK()), REG_BADRPT);
- /* FALLTHROUGH */
- default:
- ordinary(p, c);
- break;
- }
-
- if (!MORE())
- return;
- c = PEEK();
- /* we call { a repetition if followed by a digit */
- if (!( c == '*' || c == '+' || c == '?' ||
- (c == '{' && MORE2() && isdigit(PEEK2())) ))
- return; /* no repetition, we're done */
- NEXT1();
-
- REQUIRE(!wascaret, REG_BADRPT);
- switch (c) {
- case '*': /* implemented as +? */
- /* this case does not require the (y|) trick, noKLUDGE */
- INSERT(OPLUS_, pos);
- ASTERN(O_PLUS, pos);
- INSERT(OQUEST_, pos);
- ASTERN(O_QUEST, pos);
- break;
- case '+':
- INSERT(OPLUS_, pos);
- ASTERN(O_PLUS, pos);
- break;
- case '?':
- /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
- INSERT(OCH_, pos); /* offset slightly wrong */
- ASTERN(OOR1, pos); /* this one's right */
- AHEAD(pos); /* fix the OCH_ */
- EMIT(OOR2, 0); /* offset very wrong... */
- AHEAD(THERE()); /* ...so fix it */
- ASTERN(O_CH, THERETHERE());
- break;
- case '{':
- count = p_count(p);
- if (EAT(',')) {
- if (isdigit(PEEK())) {
- count2 = p_count(p);
- REQUIRE(count <= count2, REG_BADBR);
- } else /* single number with comma */
- count2 = INFINITY;
- } else /* just a single number */
- count2 = count;
- repeat(p, pos, count, count2);
- if (!EAT('}')) { /* error heuristics */
- while (MORE() && PEEK() != '}')
- NEXT1();
- REQUIRE(MORE(), REG_EBRACE);
- SETERROR(REG_BADBR);
- }
- break;
- }
-
- if (!MORE())
- return;
- c = PEEK();
- if (!( c == '*' || c == '+' || c == '?' ||
- (c == '{' && MORE2() && isdigit(PEEK2())) ) )
- return;
- SETERROR(REG_BADRPT);
-}
-
-/*
- - p_str - string (no metacharacters) "parser"
- == static void p_str(register struct parse *p);
- */
-static void
-p_str(p)
-register struct parse *p;
-{
- REQUIRE(MORE(), REG_EMPTY);
- while (MORE())
- ordinary(p, GETNEXT());
-}
-
-/*
- - p_bre - BRE parser top level, anchoring and concatenation
- == static void p_bre(register struct parse *p, register int end1, \
- == register int end2);
- * Giving end1 as OUT essentially eliminates the end1/end2 check.
- *
- * This implementation is a bit of a kludge, in that a trailing $ is first
- * taken as an ordinary character and then revised to be an anchor. The
- * only undesirable side effect is that '$' gets included as a character
- * category in such cases. This is fairly harmless; not worth fixing.
- * The amount of lookahead needed to avoid this kludge is excessive.
- */
-static void
-p_bre(p, end1, end2)
-register struct parse *p;
-register int end1; /* first terminating character */
-register int end2; /* second terminating character */
-{
- register sopno start = HERE();
- register int first = 1; /* first subexpression? */
- register int wasdollar = 0;
-
- if (EAT('^')) {
- EMIT(OBOL, 0);
- p->g->iflags |= USEBOL;
- p->g->nbol++;
- }
- while (MORE() && !SEETWO(end1, end2)) {
- wasdollar = p_simp_re(p, first);
- first = 0;
- }
- if (wasdollar) { /* oops, that was a trailing anchor */
- DROP(1);
- EMIT(OEOL, 0);
- p->g->iflags |= USEEOL;
- p->g->neol++;
- }
-
- REQUIRE(HERE() != start, REG_EMPTY); /* require nonempty */
-}
-
-/*
- - p_simp_re - parse a simple RE, an atom possibly followed by a repetition
- == static int p_simp_re(register struct parse *p, int starordinary);
- */
-static int /* was the simple RE an unbackslashed $? */
-p_simp_re(p, starordinary)
-register struct parse *p;
-int starordinary; /* is a leading * an ordinary character? */
-{
- register int c;
- register int count;
- register int count2;
- register sopno pos;
- register int i;
- register sopno subno;
-# define BACKSL (1<<CHAR_BIT)
-
- pos = HERE(); /* repetion op, if any, covers from here */
-
- assert(MORE()); /* caller should have ensured this */
- c = GETNEXT();
- if (c == '\\') {
- REQUIRE(MORE(), REG_EESCAPE);
- c = BACKSL | (unsigned char)GETNEXT();
- }
- switch (c) {
- case '.':
- if (p->g->cflags&REG_NEWLINE)
- nonnewline(p);
- else
- EMIT(OANY, 0);
- break;
- case '[':
- p_bracket(p);
- break;
- case BACKSL|'{':
- SETERROR(REG_BADRPT);
- break;
- case BACKSL|'(':
- p->g->nsub++;
- subno = p->g->nsub;
- if (subno < NPAREN)
- p->pbegin[subno] = HERE();
- EMIT(OLPAREN, subno);
- /* the MORE here is an error heuristic */
- if (MORE() && !SEETWO('\\', ')'))
- p_bre(p, '\\', ')');
- if (subno < NPAREN) {
- p->pend[subno] = HERE();
- assert(p->pend[subno] != 0);
- }
- EMIT(ORPAREN, subno);
- REQUIRE(EATTWO('\\', ')'), REG_EPAREN);
- break;
- case BACKSL|')': /* should not get here -- must be user */
- case BACKSL|'}':
- SETERROR(REG_EPAREN);
- break;
- case BACKSL|'1':
- case BACKSL|'2':
- case BACKSL|'3':
- case BACKSL|'4':
- case BACKSL|'5':
- case BACKSL|'6':
- case BACKSL|'7':
- case BACKSL|'8':
- case BACKSL|'9':
- i = (c&~BACKSL) - '0';
- assert(i < NPAREN);
- if (p->pend[i] != 0) {
- assert(i <= p->g->nsub);
- EMIT(OBACK_, i);
- assert(p->pbegin[i] != 0);
- assert(OP(p->strip[p->pbegin[i]]) == OLPAREN);
- assert(OP(p->strip[p->pend[i]]) == ORPAREN);
- (void) dupl(p, p->pbegin[i]+1, p->pend[i]);
- EMIT(O_BACK, i);
- } else
- SETERROR(REG_ESUBREG);
- p->g->backrefs = 1;
- break;
- case '*':
- REQUIRE(starordinary, REG_BADRPT);
- /* FALLTHROUGH */
- default:
- ordinary(p, c &~ BACKSL);
- break;
- }
-
- if (EAT('*')) { /* implemented as +? */
- /* this case does not require the (y|) trick, noKLUDGE */
- INSERT(OPLUS_, pos);
- ASTERN(O_PLUS, pos);
- INSERT(OQUEST_, pos);
- ASTERN(O_QUEST, pos);
- } else if (EATTWO('\\', '{')) {
- count = p_count(p);
- if (EAT(',')) {
- if (MORE() && isdigit(PEEK())) {
- count2 = p_count(p);
- REQUIRE(count <= count2, REG_BADBR);
- } else /* single number with comma */
- count2 = INFINITY;
- } else /* just a single number */
- count2 = count;
- repeat(p, pos, count, count2);
- if (!EATTWO('\\', '}')) { /* error heuristics */
- while (MORE() && !SEETWO('\\', '}'))
- NEXT1();
- REQUIRE(MORE(), REG_EBRACE);
- SETERROR(REG_BADBR);
- }
- } else if (c == (unsigned char)'$') /* $ (but not \$) ends it */
- return(1);
-
- return(0);
-}
-
-/*
- - p_count - parse a repetition count
- == static int p_count(register struct parse *p);
- */
-static int /* the value */
-p_count(p)
-register struct parse *p;
-{
- register int count = 0;
- register int ndigits = 0;
-
- while (MORE() && isdigit(PEEK()) && count <= DUPMAX) {
- count = count*10 + (GETNEXT() - '0');
- ndigits++;
- }
-
- REQUIRE(ndigits > 0 && count <= DUPMAX, REG_BADBR);
- return(count);
-}
-
-/*
- - p_bracket - parse a bracketed character list
- == static void p_bracket(register struct parse *p);
- *
- * Note a significant property of this code: if the allocset() did SETERROR,
- * no set operations are done.
- */
-static void
-p_bracket(p)
-register struct parse *p;
-{
- register cset *cs = allocset(p);
- register int invert = 0;
-
- /* Dept of Truly Sickening Special-Case Kludges */
- if (p->next + 5 < p->end && strncmp(p->next, "[:<:]]", 6) == 0) {
- EMIT(OBOW, 0);
- NEXTn(6);
- return;
- }
- if (p->next + 5 < p->end && strncmp(p->next, "[:>:]]", 6) == 0) {
- EMIT(OEOW, 0);
- NEXTn(6);
- return;
- }
-
- if (EAT('^'))
- invert++; /* make note to invert set at end */
- if (EAT(']'))
- CHadd(cs, ']');
- else if (EAT('-'))
- CHadd(cs, '-');
- while (MORE() && PEEK() != ']' && !SEETWO('-', ']'))
- p_b_term(p, cs);
- if (EAT('-'))
- CHadd(cs, '-');
- MUSTEAT(']', REG_EBRACK);
-
- if (p->error != 0) /* don't mess things up further */
- return;
-
- if (p->g->cflags&REG_ICASE) {
- register int i;
- register int ci;
-
- for (i = p->g->csetsize - 1; i >= 0; i--)
- if (CHIN(cs, i) && isalpha(i)) {
- ci = othercase(i);
- if (ci != i)
- CHadd(cs, ci);
- }
- if (cs->multis != NULL)
- mccase(p, cs);
- }
- if (invert) {
- register int i;
-
- for (i = p->g->csetsize - 1; i >= 0; i--)
- if (CHIN(cs, i))
- CHsub(cs, i);
- else
- CHadd(cs, i);
- if (p->g->cflags&REG_NEWLINE)
- CHsub(cs, '\n');
- if (cs->multis != NULL)
- mcinvert(p, cs);
- }
-
- assert(cs->multis == NULL); /* xxx */
-
- if (nch(p, cs) == 1) { /* optimize singleton sets */
- ordinary(p, firstch(p, cs));
- freeset(p, cs);
- } else
- EMIT(OANYOF, freezeset(p, cs));
-}
-
-/*
- - p_b_term - parse one term of a bracketed character list
- == static void p_b_term(register struct parse *p, register cset *cs);
- */
-static void
-p_b_term(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register char c;
- register char start, finish;
- register int i;
-
- /* classify what we've got */
- switch ((MORE()) ? PEEK() : '\0') {
- case '[':
- c = (MORE2()) ? PEEK2() : '\0';
- break;
- case '-':
- SETERROR(REG_ERANGE);
- return; /* NOTE RETURN */
- break;
- default:
- c = '\0';
- break;
- }
-
- switch (c) {
- case ':': /* character class */
- NEXT2();
- REQUIRE(MORE(), REG_EBRACK);
- c = PEEK();
- REQUIRE(c != '-' && c != ']', REG_ECTYPE);
- p_b_cclass(p, cs);
- REQUIRE(MORE(), REG_EBRACK);
- REQUIRE(EATTWO(':', ']'), REG_ECTYPE);
- break;
- case '=': /* equivalence class */
- NEXT2();
- REQUIRE(MORE(), REG_EBRACK);
- c = PEEK();
- REQUIRE(c != '-' && c != ']', REG_ECOLLATE);
- p_b_eclass(p, cs);
- REQUIRE(MORE(), REG_EBRACK);
- REQUIRE(EATTWO('=', ']'), REG_ECOLLATE);
- break;
- default: /* symbol, ordinary character, or range */
-/* xxx revision needed for multichar stuff */
- start = p_b_symbol(p);
- if (SEE('-') && MORE2() && PEEK2() != ']') {
- /* range */
- NEXT1();
- if (EAT('-'))
- finish = '-';
- else
- finish = p_b_symbol(p);
- } else
- finish = start;
-/* xxx what about signed chars here... */
- REQUIRE(start <= finish, REG_ERANGE);
- for (i = start; i <= finish; i++)
- CHadd(cs, i);
- break;
- }
-}
-
-/*
- - p_b_cclass - parse a character-class name and deal with it
- == static void p_b_cclass(register struct parse *p, register cset *cs);
- */
-static void
-p_b_cclass(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register char *sp = p->next;
- register struct cclass *cp;
- register size_t len;
- register char *u;
- register char c;
-
- while (MORE() && isalpha(PEEK()))
- NEXT1();
- len = p->next - sp;
- for (cp = cclasses; cp->name != NULL; cp++)
- if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0')
- break;
- if (cp->name == NULL) {
- /* oops, didn't find it */
- SETERROR(REG_ECTYPE);
- return;
- }
-
- u = cp->chars;
- while ((c = *u++) != '\0')
- CHadd(cs, c);
- for (u = cp->multis; *u != '\0'; u += strlen(u) + 1)
- MCadd(p, cs, u);
-}
-
-/*
- - p_b_eclass - parse an equivalence-class name and deal with it
- == static void p_b_eclass(register struct parse *p, register cset *cs);
- *
- * This implementation is incomplete. xxx
- */
-static void
-p_b_eclass(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register char c;
-
- c = p_b_coll_elem(p, '=');
- CHadd(cs, c);
-}
-
-/*
- - p_b_symbol - parse a character or [..]ed multicharacter collating symbol
- == static char p_b_symbol(register struct parse *p);
- */
-static char /* value of symbol */
-p_b_symbol(p)
-register struct parse *p;
-{
- register char value;
-
- REQUIRE(MORE(), REG_EBRACK);
- if (!EATTWO('[', '.'))
- return(GETNEXT());
-
- /* collating symbol */
- value = p_b_coll_elem(p, '.');
- REQUIRE(EATTWO('.', ']'), REG_ECOLLATE);
- return(value);
-}
-
-/*
- - p_b_coll_elem - parse a collating-element name and look it up
- == static char p_b_coll_elem(register struct parse *p, int endc);
- */
-static char /* value of collating element */
-p_b_coll_elem(p, endc)
-register struct parse *p;
-int endc; /* name ended by endc,']' */
-{
- register char *sp = p->next;
- register struct cname *cp;
- register int len;
-
- while (MORE() && !SEETWO(endc, ']'))
- NEXT1();
- if (!MORE()) {
- SETERROR(REG_EBRACK);
- return(0);
- }
- len = p->next - sp;
- for (cp = cnames; cp->name != NULL; cp++)
- if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0')
- return(cp->code); /* known name */
- if (len == 1)
- return(*sp); /* single character */
- SETERROR(REG_ECOLLATE); /* neither */
- return(0);
-}
-
-/*
- - othercase - return the case counterpart of an alphabetic
- == static char othercase(int ch);
- */
-static char /* if no counterpart, return ch */
-othercase(ch)
-int ch;
-{
- assert(isalpha(ch));
- if (isupper(ch))
- return(tolower(ch));
- else if (islower(ch))
- return(toupper(ch));
- else /* peculiar, but could happen */
- return(ch);
-}
-
-/*
- - bothcases - emit a dualcase version of a two-case character
- == static void bothcases(register struct parse *p, int ch);
- *
- * Boy, is this implementation ever a kludge...
- */
-static void
-bothcases(p, ch)
-register struct parse *p;
-int ch;
-{
- register char *oldnext = p->next;
- register char *oldend = p->end;
- char bracket[3];
-
- assert(othercase(ch) != ch); /* p_bracket() would recurse */
- p->next = bracket;
- p->end = bracket+2;
- bracket[0] = ch;
- bracket[1] = ']';
- bracket[2] = '\0';
- p_bracket(p);
- assert(p->next == bracket+2);
- p->next = oldnext;
- p->end = oldend;
-}
-
-/*
- - ordinary - emit an ordinary character
- == static void ordinary(register struct parse *p, register int ch);
- */
-static void
-ordinary(p, ch)
-register struct parse *p;
-register int ch;
-{
- register cat_t *cap = p->g->categories;
-
- if ((p->g->cflags&REG_ICASE) && isalpha(ch) && othercase(ch) != ch)
- bothcases(p, ch);
- else {
- EMIT(OCHAR, (unsigned char)ch);
- if (cap[ch] == 0)
- cap[ch] = p->g->ncategories++;
- }
-}
-
-/*
- - nonnewline - emit REG_NEWLINE version of OANY
- == static void nonnewline(register struct parse *p);
- *
- * Boy, is this implementation ever a kludge...
- */
-static void
-nonnewline(p)
-register struct parse *p;
-{
- register char *oldnext = p->next;
- register char *oldend = p->end;
- char bracket[4];
-
- p->next = bracket;
- p->end = bracket+3;
- bracket[0] = '^';
- bracket[1] = '\n';
- bracket[2] = ']';
- bracket[3] = '\0';
- p_bracket(p);
- assert(p->next == bracket+3);
- p->next = oldnext;
- p->end = oldend;
-}
-
-/*
- - repeat - generate code for a bounded repetition, recursively if needed
- == static void repeat(register struct parse *p, sopno start, int from, int to);
- */
-static void
-repeat(p, start, from, to)
-register struct parse *p;
-sopno start; /* operand from here to end of strip */
-int from; /* repeated from this number */
-int to; /* to this number of times (maybe INFINITY) */
-{
- register sopno finish = HERE();
-# define N 2
-# define INF 3
-# define REP(f, t) ((f)*8 + (t))
-# define MAP(n) (((n) <= 1) ? (n) : ((n) == INFINITY) ? INF : N)
- register sopno copy;
-
- if (p->error != 0) /* head off possible runaway recursion */
- return;
-
- assert(from <= to);
-
- switch (REP(MAP(from), MAP(to))) {
- case REP(0, 0): /* must be user doing this */
- DROP(finish-start); /* drop the operand */
- break;
- case REP(0, 1): /* as x{1,1}? */
- case REP(0, N): /* as x{1,n}? */
- case REP(0, INF): /* as x{1,}? */
- /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
- INSERT(OCH_, start); /* offset is wrong... */
- repeat(p, start+1, 1, to);
- ASTERN(OOR1, start);
- AHEAD(start); /* ... fix it */
- EMIT(OOR2, 0);
- AHEAD(THERE());
- ASTERN(O_CH, THERETHERE());
- break;
- case REP(1, 1): /* trivial case */
- /* done */
- break;
- case REP(1, N): /* as x?x{1,n-1} */
- /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
- INSERT(OCH_, start);
- ASTERN(OOR1, start);
- AHEAD(start);
- EMIT(OOR2, 0); /* offset very wrong... */
- AHEAD(THERE()); /* ...so fix it */
- ASTERN(O_CH, THERETHERE());
- copy = dupl(p, start+1, finish+1);
- assert(copy == finish+4);
- repeat(p, copy, 1, to-1);
- break;
- case REP(1, INF): /* as x+ */
- INSERT(OPLUS_, start);
- ASTERN(O_PLUS, start);
- break;
- case REP(N, N): /* as xx{m-1,n-1} */
- copy = dupl(p, start, finish);
- repeat(p, copy, from-1, to-1);
- break;
- case REP(N, INF): /* as xx{n-1,INF} */
- copy = dupl(p, start, finish);
- repeat(p, copy, from-1, to);
- break;
- default: /* "can't happen" */
- SETERROR(REG_ASSERT); /* just in case */
- break;
- }
-}
-
-/*
- - seterr - set an error condition
- == static int seterr(register struct parse *p, int e);
- */
-static int /* useless but makes type checking happy */
-seterr(p, e)
-register struct parse *p;
-int e;
-{
- if (p->error == 0) /* keep earliest error condition */
- p->error = e;
- p->next = nuls; /* try to bring things to a halt */
- p->end = nuls;
- return(0); /* make the return value well-defined */
-}
-
-/*
- - allocset - allocate a set of characters for []
- == static cset *allocset(register struct parse *p);
- */
-static cset *
-allocset(p)
-register struct parse *p;
-{
- register int no = p->g->ncsets++;
- register size_t nc;
- register size_t nbytes;
- register cset *cs;
- register size_t css = (size_t)p->g->csetsize;
- register int i;
-
- if (no >= p->ncsalloc) { /* need another column of space */
- p->ncsalloc += CHAR_BIT;
- nc = p->ncsalloc;
- assert(nc % CHAR_BIT == 0);
- nbytes = nc / CHAR_BIT * css;
- if (p->g->sets == NULL)
- p->g->sets = (cset *)malloc(nc * sizeof(cset));
- else
- p->g->sets = (cset *)realloc((char *)p->g->sets,
- nc * sizeof(cset));
- if (p->g->setbits == NULL)
- p->g->setbits = (uch *)malloc(nbytes);
- else {
- p->g->setbits = (uch *)realloc((char *)p->g->setbits,
- nbytes);
- /* xxx this isn't right if setbits is now NULL */
- for (i = 0; i < no; i++)
- p->g->sets[i].ptr = p->g->setbits + css*(i/CHAR_BIT);
- }
- if (p->g->sets != NULL && p->g->setbits != NULL)
- (void) memset((char *)p->g->setbits + (nbytes - css),
- 0, css);
- else {
- no = 0;
- SETERROR(REG_ESPACE);
- /* caller's responsibility not to do set ops */
- }
- }
-
- assert(p->g->sets != NULL); /* xxx */
- cs = &p->g->sets[no];
- cs->ptr = p->g->setbits + css*((no)/CHAR_BIT);
- cs->mask = 1 << ((no) % CHAR_BIT);
- cs->hash = 0;
- cs->smultis = 0;
- cs->multis = NULL;
-
- return(cs);
-}
-
-/*
- - freeset - free a now-unused set
- == static void freeset(register struct parse *p, register cset *cs);
- */
-static void
-freeset(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register unsigned int i;
- register cset *top = &p->g->sets[p->g->ncsets];
- register size_t css = (size_t)p->g->csetsize;
-
- for (i = 0; i < css; i++)
- CHsub(cs, i);
- if (cs == top-1) /* recover only the easy case */
- p->g->ncsets--;
-}
-
-/*
- - freezeset - final processing on a set of characters
- == static int freezeset(register struct parse *p, register cset *cs);
- *
- * The main task here is merging identical sets. This is usually a waste
- * of time (although the hash code minimizes the overhead), but can win
- * big if REG_ICASE is being used. REG_ICASE, by the way, is why the hash
- * is done using addition rather than xor -- all ASCII [aA] sets xor to
- * the same value!
- */
-static int /* set number */
-freezeset(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register uch h = cs->hash;
- register unsigned int i;
- register cset *top = &p->g->sets[p->g->ncsets];
- register cset *cs2;
- register size_t css = (size_t)p->g->csetsize;
-
- /* look for an earlier one which is the same */
- for (cs2 = &p->g->sets[0]; cs2 < top; cs2++)
- if (cs2->hash == h && cs2 != cs) {
- /* maybe */
- for (i = 0; i < css; i++)
- if (!!CHIN(cs2, i) != !!CHIN(cs, i))
- break; /* no */
- if (i == css)
- break; /* yes */
- }
-
- if (cs2 < top) { /* found one */
- freeset(p, cs);
- cs = cs2;
- }
-
- return((int)(cs - p->g->sets));
-}
-
-/*
- - firstch - return first character in a set (which must have at least one)
- == static int firstch(register struct parse *p, register cset *cs);
- */
-static int /* character; there is no "none" value */
-firstch(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register unsigned int i;
- register size_t css = (size_t)p->g->csetsize;
-
- for (i = 0; i < css; i++)
- if (CHIN(cs, i))
- return((char)i);
- assert(never);
- return(0); /* arbitrary */
-}
-
-/*
- - nch - number of characters in a set
- == static int nch(register struct parse *p, register cset *cs);
- */
-static int
-nch(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register unsigned int i;
- register size_t css = (size_t)p->g->csetsize;
- register int n = 0;
-
- for (i = 0; i < css; i++)
- if (CHIN(cs, i))
- n++;
- return(n);
-}
-
-/*
- - mcadd - add a collating element to a cset
- == static void mcadd(register struct parse *p, register cset *cs, \
- == register char *cp);
- */
-static void
-mcadd(p, cs, cp)
-register struct parse *p;
-register cset *cs;
-register char *cp;
-{
- register size_t oldend = cs->smultis;
-
- cs->smultis += strlen(cp) + 1;
- if (cs->multis == NULL)
- cs->multis = malloc(cs->smultis);
- else
- cs->multis = realloc(cs->multis, cs->smultis);
- if (cs->multis == NULL) {
- SETERROR(REG_ESPACE);
- return;
- }
-
- (void) strcpy(cs->multis + oldend - 1, cp);
- cs->multis[cs->smultis - 1] = '\0';
-}
-
-
-/*
- - mcinvert - invert the list of collating elements in a cset
- == static void mcinvert(register struct parse *p, register cset *cs);
- *
- * This would have to know the set of possibilities. Implementation
- * is deferred.
- */
-static void
-mcinvert(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- assert(cs->multis == NULL); /* xxx */
-}
-
-/*
- - mccase - add case counterparts of the list of collating elements in a cset
- == static void mccase(register struct parse *p, register cset *cs);
- *
- * This would have to know the set of possibilities. Implementation
- * is deferred.
- */
-static void
-mccase(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- assert(cs->multis == NULL); /* xxx */
-}
-
-/*
- - isinsets - is this character in any sets?
- == static int isinsets(register struct re_guts *g, int c);
- */
-static int /* predicate */
-isinsets(g, c)
-register struct re_guts *g;
-int c;
-{
- register uch *col;
- register int i;
- register int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT;
- register unsigned uc = (unsigned char)c;
-
- for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize)
- if (col[uc] != 0)
- return(1);
- return(0);
-}
-
-/*
- - samesets - are these two characters in exactly the same sets?
- == static int samesets(register struct re_guts *g, int c1, int c2);
- */
-static int /* predicate */
-samesets(g, c1, c2)
-register struct re_guts *g;
-int c1;
-int c2;
-{
- register uch *col;
- register int i;
- register int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT;
- register unsigned uc1 = (unsigned char)c1;
- register unsigned uc2 = (unsigned char)c2;
-
- for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize)
- if (col[uc1] != col[uc2])
- return(0);
- return(1);
-}
-
-/*
- - categorize - sort out character categories
- == static void categorize(struct parse *p, register struct re_guts *g);
- */
-static void
-categorize(p, g)
-struct parse *p;
-register struct re_guts *g;
-{
- register cat_t *cats = g->categories;
- register int c;
- register int c2;
- register cat_t cat;
-
- /* avoid making error situations worse */
- if (p->error != 0)
- return;
-
- for (c = CHAR_MIN; c <= CHAR_MAX; c++)
- if (cats[c] == 0 && isinsets(g, c)) {
- cat = g->ncategories++;
- cats[c] = cat;
- for (c2 = c+1; c2 <= CHAR_MAX; c2++)
- if (cats[c2] == 0 && samesets(g, c, c2))
- cats[c2] = cat;
- }
-}
-
-/*
- - dupl - emit a duplicate of a bunch of sops
- == static sopno dupl(register struct parse *p, sopno start, sopno finish);
- */
-static sopno /* start of duplicate */
-dupl(p, start, finish)
-register struct parse *p;
-sopno start; /* from here */
-sopno finish; /* to this less one */
-{
- register sopno ret = HERE();
- register sopno len = finish - start;
-
- assert(finish >= start);
- if (len == 0)
- return(ret);
- enlarge(p, p->ssize + len); /* this many unexpected additions */
- assert(p->ssize >= p->slen + len);
- (void) memcpy((char *)(p->strip + p->slen),
- (char *)(p->strip + start), (size_t)len*sizeof(sop));
- p->slen += len;
- return(ret);
-}
-
-/*
- - doemit - emit a strip operator
- == static void doemit(register struct parse *p, sop op, size_t opnd);
- *
- * It might seem better to implement this as a macro with a function as
- * hard-case backup, but it's just too big and messy unless there are
- * some changes to the data structures. Maybe later.
- */
-static void
-doemit(p, op, opnd)
-register struct parse *p;
-sop op;
-size_t opnd;
-{
- /* avoid making error situations worse */
- if (p->error != 0)
- return;
-
- /* deal with oversize operands ("can't happen", more or less) */
- assert(opnd < 1<<OPSHIFT);
-
- /* deal with undersized strip */
- if (p->slen >= p->ssize)
- enlarge(p, (p->ssize+1) / 2 * 3); /* +50% */
- assert(p->slen < p->ssize);
-
- /* finally, it's all reduced to the easy case */
- p->strip[p->slen++] = SOP(op, opnd);
-}
-
-/*
- - doinsert - insert a sop into the strip
- == static void doinsert(register struct parse *p, sop op, size_t opnd, sopno pos);
- */
-static void
-doinsert(p, op, opnd, pos)
-register struct parse *p;
-sop op;
-size_t opnd;
-sopno pos;
-{
- register sopno sn;
- register sop s;
- register int i;
-
- /* avoid making error situations worse */
- if (p->error != 0)
- return;
-
- sn = HERE();
- EMIT(op, opnd); /* do checks, ensure space */
- assert(HERE() == sn+1);
- s = p->strip[sn];
-
- /* adjust paren pointers */
- assert(pos > 0);
- for (i = 1; i < NPAREN; i++) {
- if (p->pbegin[i] >= pos) {
- p->pbegin[i]++;
- }
- if (p->pend[i] >= pos) {
- p->pend[i]++;
- }
- }
-
- memmove((char *)&p->strip[pos+1], (char *)&p->strip[pos],
- (HERE()-pos-1)*sizeof(sop));
- p->strip[pos] = s;
-}
-
-/*
- - dofwd - complete a forward reference
- == static void dofwd(register struct parse *p, sopno pos, sop value);
- */
-static void
-dofwd(p, pos, value)
-register struct parse *p;
-register sopno pos;
-sop value;
-{
- /* avoid making error situations worse */
- if (p->error != 0)
- return;
-
- assert(value < 1<<OPSHIFT);
- p->strip[pos] = OP(p->strip[pos]) | value;
-}
-
-/*
- - enlarge - enlarge the strip
- == static void enlarge(register struct parse *p, sopno size);
- */
-static void
-enlarge(p, size)
-register struct parse *p;
-register sopno size;
-{
- register sop *sp;
-
- if (p->ssize >= size)
- return;
-
- sp = (sop *)realloc(p->strip, size*sizeof(sop));
- if (sp == NULL) {
- SETERROR(REG_ESPACE);
- return;
- }
- p->strip = sp;
- p->ssize = size;
-}
-
-/*
- - stripsnug - compact the strip
- == static void stripsnug(register struct parse *p, register struct re_guts *g);
- */
-static void
-stripsnug(p, g)
-register struct parse *p;
-register struct re_guts *g;
-{
- g->nstates = p->slen;
- g->strip = (sop *)realloc((char *)p->strip, p->slen * sizeof(sop));
- if (g->strip == NULL) {
- SETERROR(REG_ESPACE);
- g->strip = p->strip;
- }
-}
-
-/*
- - findmust - fill in must and mlen with longest mandatory literal string
- == static void findmust(register struct parse *p, register struct re_guts *g);
- *
- * This algorithm could do fancy things like analyzing the operands of |
- * for common subsequences. Someday. This code is simple and finds most
- * of the interesting cases.
- *
- * Note that must and mlen got initialized during setup.
- */
-static void
-findmust(p, g)
-struct parse *p;
-register struct re_guts *g;
-{
- register sop *scan;
- sop *start = NULL;
- register sop *newstart = NULL;
- register sopno newlen;
- register sop s;
- register char *cp;
- register sopno i;
-
- /* avoid making error situations worse */
- if (p->error != 0)
- return;
-
- /* find the longest OCHAR sequence in strip */
- newlen = 0;
- scan = g->strip + 1;
- do {
- s = *scan++;
- switch (OP(s)) {
- case OCHAR: /* sequence member */
- if (newlen == 0) /* new sequence */
- newstart = scan - 1;
- newlen++;
- break;
- case OPLUS_: /* things that don't break one */
- case OLPAREN:
- case ORPAREN:
- break;
- case OQUEST_: /* things that must be skipped */
- case OCH_:
- scan--;
- do {
- scan += OPND(s);
- s = *scan;
- /* assert() interferes w debug printouts */
- if (OP(s) != O_QUEST && OP(s) != O_CH &&
- OP(s) != OOR2) {
- g->iflags |= BAD;
- return;
- }
- } while (OP(s) != O_QUEST && OP(s) != O_CH);
- /* fallthrough */
- default: /* things that break a sequence */
- if (newlen > g->mlen) { /* ends one */
- start = newstart;
- g->mlen = newlen;
- }
- newlen = 0;
- break;
- }
- } while (OP(s) != OEND);
-
- if (g->mlen == 0) /* there isn't one */
- return;
-
- /* turn it into a character string */
- g->must = malloc((size_t)g->mlen + 1);
- if (g->must == NULL) { /* argh; just forget it */
- g->mlen = 0;
- return;
- }
- cp = g->must;
- scan = start;
- for (i = g->mlen; i > 0; i--) {
- while (OP(s = *scan++) != OCHAR)
- continue;
- assert(cp < g->must + g->mlen);
- *cp++ = (char)OPND(s);
- }
- assert(cp == g->must + g->mlen);
- *cp++ = '\0'; /* just on general principles */
-}
-
-/*
- - pluscount - count + nesting
- == static sopno pluscount(register struct parse *p, register struct re_guts *g);
- */
-static sopno /* nesting depth */
-pluscount(p, g)
-struct parse *p;
-register struct re_guts *g;
-{
- register sop *scan;
- register sop s;
- register sopno plusnest = 0;
- register sopno maxnest = 0;
-
- if (p->error != 0)
- return(0); /* there may not be an OEND */
-
- scan = g->strip + 1;
- do {
- s = *scan++;
- switch (OP(s)) {
- case OPLUS_:
- plusnest++;
- break;
- case O_PLUS:
- if (plusnest > maxnest)
- maxnest = plusnest;
- plusnest--;
- break;
- }
- } while (OP(s) != OEND);
- if (plusnest != 0)
- g->iflags |= BAD;
- return(maxnest);
-}
diff --git a/ext/ereg/regex/regcomp.ih b/ext/ereg/regex/regcomp.ih
deleted file mode 100644
index f0eeb5f02d..0000000000
--- a/ext/ereg/regex/regcomp.ih
+++ /dev/null
@@ -1,48 +0,0 @@
-/* ========= begin header generated by ./mkh ========= */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* === regcomp.c === */
-static void p_ere(register struct parse *p, int stop);
-static void p_ere_exp(register struct parse *p);
-static void p_str(register struct parse *p);
-static void p_bre(register struct parse *p, register int end1, register int end2);
-static int p_simp_re(register struct parse *p, int starordinary);
-static int p_count(register struct parse *p);
-static void p_bracket(register struct parse *p);
-static void p_b_term(register struct parse *p, register cset *cs);
-static void p_b_cclass(register struct parse *p, register cset *cs);
-static void p_b_eclass(register struct parse *p, register cset *cs);
-static char p_b_symbol(register struct parse *p);
-static char p_b_coll_elem(register struct parse *p, int endc);
-static char othercase(int ch);
-static void bothcases(register struct parse *p, int ch);
-static void ordinary(register struct parse *p, register int ch);
-static void nonnewline(register struct parse *p);
-static void repeat(register struct parse *p, sopno start, int from, int to);
-static int seterr(register struct parse *p, int e);
-static cset *allocset(register struct parse *p);
-static void freeset(register struct parse *p, register cset *cs);
-static int freezeset(register struct parse *p, register cset *cs);
-static int firstch(register struct parse *p, register cset *cs);
-static int nch(register struct parse *p, register cset *cs);
-static void mcadd(register struct parse *p, register cset *cs, register char *cp);
-static void mcinvert(register struct parse *p, register cset *cs);
-static void mccase(register struct parse *p, register cset *cs);
-static int isinsets(register struct re_guts *g, int c);
-static int samesets(register struct re_guts *g, int c1, int c2);
-static void categorize(struct parse *p, register struct re_guts *g);
-static sopno dupl(register struct parse *p, sopno start, sopno finish);
-static void doemit(register struct parse *p, sop op, size_t opnd);
-static void doinsert(register struct parse *p, sop op, size_t opnd, sopno pos);
-static void dofwd(register struct parse *p, sopno pos, sop value);
-static void enlarge(register struct parse *p, sopno size);
-static void stripsnug(register struct parse *p, register struct re_guts *g);
-static void findmust(register struct parse *p, register struct re_guts *g);
-static sopno pluscount(register struct parse *p, register struct re_guts *g);
-
-#ifdef __cplusplus
-}
-#endif
-/* ========= end header generated by ./mkh ========= */
diff --git a/ext/ereg/regex/regerror.c b/ext/ereg/regex/regerror.c
deleted file mode 100644
index 12edd4e164..0000000000
--- a/ext/ereg/regex/regerror.c
+++ /dev/null
@@ -1,124 +0,0 @@
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <regex.h>
-
-#include "utils.h"
-#include "regerror.ih"
-
-/*
- = #define REG_NOMATCH 1
- = #define REG_BADPAT 2
- = #define REG_ECOLLATE 3
- = #define REG_ECTYPE 4
- = #define REG_EESCAPE 5
- = #define REG_ESUBREG 6
- = #define REG_EBRACK 7
- = #define REG_EPAREN 8
- = #define REG_EBRACE 9
- = #define REG_BADBR 10
- = #define REG_ERANGE 11
- = #define REG_ESPACE 12
- = #define REG_BADRPT 13
- = #define REG_EMPTY 14
- = #define REG_ASSERT 15
- = #define REG_INVARG 16
- = #define REG_ATOI 255 // convert name to number (!)
- = #define REG_ITOA 0400 // convert number to name (!)
- */
-static struct rerr {
- int code;
- char *name;
- char *explain;
-} rerrs[] = {
- { REG_NOMATCH, "REG_NOMATCH", "regexec() failed to match" },
- { REG_BADPAT, "REG_BADPAT", "invalid regular expression" },
- { REG_ECOLLATE, "REG_ECOLLATE", "invalid collating element" },
- { REG_ECTYPE, "REG_ECTYPE", "invalid character class" },
- { REG_EESCAPE, "REG_EESCAPE", "trailing backslash (\\)" },
- { REG_ESUBREG, "REG_ESUBREG", "invalid backreference number" },
- { REG_EBRACK, "REG_EBRACK", "brackets ([ ]) not balanced" },
- { REG_EPAREN, "REG_EPAREN", "parentheses not balanced" },
- { REG_EBRACE, "REG_EBRACE", "braces not balanced" },
- { REG_BADBR, "REG_BADBR", "invalid repetition count(s)" },
- { REG_ERANGE, "REG_ERANGE", "invalid character range" },
- { REG_ESPACE, "REG_ESPACE", "out of memory" },
- { REG_BADRPT, "REG_BADRPT", "repetition-operator operand invalid" },
- { REG_EMPTY, "REG_EMPTY", "empty (sub)expression" },
- { REG_ASSERT, "REG_ASSERT", "\"can't happen\" -- you found a bug" },
- { REG_INVARG, "REG_INVARG", "invalid argument to regex routine" },
- { 0, "", "*** unknown regexp error code ***" }
-};
-
-/*
- - regerror - the interface to error numbers
- = API_EXPORT(size_t) regerror(int, const regex_t *, char *, size_t);
- */
-/* ARGSUSED */
-API_EXPORT(size_t)
-regerror(errcode, preg, errbuf, errbuf_size)
-int errcode;
-const regex_t *preg;
-char *errbuf;
-size_t errbuf_size;
-{
- register struct rerr *r;
- register size_t len;
- register int target = errcode &~ REG_ITOA;
- register char *s;
- char convbuf[50];
-
- if (errcode == REG_ATOI)
- s = regatoi(preg, convbuf);
- else {
- for (r = rerrs; r->code != 0; r++)
- if (r->code == target)
- break;
-
- if (errcode&REG_ITOA) {
- if (r->code != 0)
- (void) strcpy(convbuf, r->name);
- else
- sprintf(convbuf, "REG_0x%x", target);
- assert(strlen(convbuf) < sizeof(convbuf));
- s = convbuf;
- } else
- s = r->explain;
- }
-
- len = strlen(s) + 1;
- if (errbuf_size > 0) {
- if (errbuf_size > len)
- (void) strcpy(errbuf, s);
- else {
- (void) strncpy(errbuf, s, errbuf_size-1);
- errbuf[errbuf_size-1] = '\0';
- }
- }
-
- return(len);
-}
-
-/*
- - regatoi - internal routine to implement REG_ATOI
- == static char *regatoi(const regex_t *preg, char *localbuf);
- */
-static char *
-regatoi(preg, localbuf)
-const regex_t *preg;
-char *localbuf;
-{
- register struct rerr *r;
-
- for (r = rerrs; r->code != 0; r++)
- if (strcmp(r->name, preg->re_endp) == 0)
- break;
- if (r->code == 0)
- return("0");
-
- sprintf(localbuf, "%d", r->code);
- return(localbuf);
-}
diff --git a/ext/ereg/regex/regerror.ih b/ext/ereg/regex/regerror.ih
deleted file mode 100644
index 2cb668c24f..0000000000
--- a/ext/ereg/regex/regerror.ih
+++ /dev/null
@@ -1,12 +0,0 @@
-/* ========= begin header generated by ./mkh ========= */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* === regerror.c === */
-static char *regatoi(const regex_t *preg, char *localbuf);
-
-#ifdef __cplusplus
-}
-#endif
-/* ========= end header generated by ./mkh ========= */
diff --git a/ext/ereg/regex/regex.3 b/ext/ereg/regex/regex.3
deleted file mode 100644
index 100c8a7f71..0000000000
--- a/ext/ereg/regex/regex.3
+++ /dev/null
@@ -1,502 +0,0 @@
-.TH REGEX 3 "17 May 1993"
-.BY "Henry Spencer"
-.de ZR
-.\" one other place knows this name: the SEE ALSO section
-.IR regex (7) \\$1
-..
-.SH NAME
-regcomp, regexec, regerror, regfree \- regular-expression library
-.SH SYNOPSIS
-.ft B
-.\".na
-#include <sys/types.h>
-.br
-#include <regex.h>
-.HP 10
-int regcomp(regex_t\ *preg, const\ char\ *pattern, int\ cflags);
-.HP
-int\ regexec(const\ regex_t\ *preg, const\ char\ *string,
-size_t\ nmatch, regmatch_t\ pmatch[], int\ eflags);
-.HP
-size_t\ regerror(int\ errcode, const\ regex_t\ *preg,
-char\ *errbuf, size_t\ errbuf_size);
-.HP
-void\ regfree(regex_t\ *preg);
-.\".ad
-.ft
-.SH DESCRIPTION
-These routines implement POSIX 1003.2 regular expressions (``RE''s);
-see
-.ZR .
-.I Regcomp
-compiles an RE written as a string into an internal form,
-.I regexec
-matches that internal form against a string and reports results,
-.I regerror
-transforms error codes from either into human-readable messages,
-and
-.I regfree
-frees any dynamically-allocated storage used by the internal form
-of an RE.
-.PP
-The header
-.I <regex.h>
-declares two structure types,
-.I regex_t
-and
-.IR regmatch_t ,
-the former for compiled internal forms and the latter for match reporting.
-It also declares the four functions,
-a type
-.IR regoff_t ,
-and a number of constants with names starting with ``REG_''.
-.PP
-.I Regcomp
-compiles the regular expression contained in the
-.I pattern
-string,
-subject to the flags in
-.IR cflags ,
-and places the results in the
-.I regex_t
-structure pointed to by
-.IR preg .
-.I Cflags
-is the bitwise OR of zero or more of the following flags:
-.IP REG_EXTENDED \w'REG_EXTENDED'u+2n
-Compile modern (``extended'') REs,
-rather than the obsolete (``basic'') REs that
-are the default.
-.IP REG_BASIC
-This is a synonym for 0,
-provided as a counterpart to REG_EXTENDED to improve readability.
-.IP REG_NOSPEC
-Compile with recognition of all special characters turned off.
-All characters are thus considered ordinary,
-so the ``RE'' is a literal string.
-This is an extension,
-compatible with but not specified by POSIX 1003.2,
-and should be used with
-caution in software intended to be portable to other systems.
-REG_EXTENDED and REG_NOSPEC may not be used
-in the same call to
-.IR regcomp .
-.IP REG_ICASE
-Compile for matching that ignores upper/lower case distinctions.
-See
-.ZR .
-.IP REG_NOSUB
-Compile for matching that need only report success or failure,
-not what was matched.
-.IP REG_NEWLINE
-Compile for newline-sensitive matching.
-By default, newline is a completely ordinary character with no special
-meaning in either REs or strings.
-With this flag,
-`[^' bracket expressions and `.' never match newline,
-a `^' anchor matches the null string after any newline in the string
-in addition to its normal function,
-and the `$' anchor matches the null string before any newline in the
-string in addition to its normal function.
-.IP REG_PEND
-The regular expression ends,
-not at the first NUL,
-but just before the character pointed to by the
-.I re_endp
-member of the structure pointed to by
-.IR preg .
-The
-.I re_endp
-member is of type
-.IR const\ char\ * .
-This flag permits inclusion of NULs in the RE;
-they are considered ordinary characters.
-This is an extension,
-compatible with but not specified by POSIX 1003.2,
-and should be used with
-caution in software intended to be portable to other systems.
-.PP
-When successful,
-.I regcomp
-returns 0 and fills in the structure pointed to by
-.IR preg .
-One member of that structure
-(other than
-.IR re_endp )
-is publicized:
-.IR re_nsub ,
-of type
-.IR size_t ,
-contains the number of parenthesized subexpressions within the RE
-(except that the value of this member is undefined if the
-REG_NOSUB flag was used).
-If
-.I regcomp
-fails, it returns a non-zero error code;
-see DIAGNOSTICS.
-.PP
-.I Regexec
-matches the compiled RE pointed to by
-.I preg
-against the
-.IR string ,
-subject to the flags in
-.IR eflags ,
-and reports results using
-.IR nmatch ,
-.IR pmatch ,
-and the returned value.
-The RE must have been compiled by a previous invocation of
-.IR regcomp .
-The compiled form is not altered during execution of
-.IR regexec ,
-so a single compiled RE can be used simultaneously by multiple threads.
-.PP
-By default,
-the NUL-terminated string pointed to by
-.I string
-is considered to be the text of an entire line, minus any terminating
-newline.
-The
-.I eflags
-argument is the bitwise OR of zero or more of the following flags:
-.IP REG_NOTBOL \w'REG_STARTEND'u+2n
-The first character of
-the string
-is not the beginning of a line, so the `^' anchor should not match before it.
-This does not affect the behavior of newlines under REG_NEWLINE.
-.IP REG_NOTEOL
-The NUL terminating
-the string
-does not end a line, so the `$' anchor should not match before it.
-This does not affect the behavior of newlines under REG_NEWLINE.
-.IP REG_STARTEND
-The string is considered to start at
-\fIstring\fR\ + \fIpmatch\fR[0].\fIrm_so\fR
-and to have a terminating NUL located at
-\fIstring\fR\ + \fIpmatch\fR[0].\fIrm_eo\fR
-(there need not actually be a NUL at that location),
-regardless of the value of
-.IR nmatch .
-See below for the definition of
-.IR pmatch
-and
-.IR nmatch .
-This is an extension,
-compatible with but not specified by POSIX 1003.2,
-and should be used with
-caution in software intended to be portable to other systems.
-Note that a non-zero \fIrm_so\fR does not imply REG_NOTBOL;
-REG_STARTEND affects only the location of the string,
-not how it is matched.
-.PP
-See
-.ZR
-for a discussion of what is matched in situations where an RE or a
-portion thereof could match any of several substrings of
-.IR string .
-.PP
-Normally,
-.I regexec
-returns 0 for success and the non-zero code REG_NOMATCH for failure.
-Other non-zero error codes may be returned in exceptional situations;
-see DIAGNOSTICS.
-.PP
-If REG_NOSUB was specified in the compilation of the RE,
-or if
-.I nmatch
-is 0,
-.I regexec
-ignores the
-.I pmatch
-argument (but see below for the case where REG_STARTEND is specified).
-Otherwise,
-.I pmatch
-points to an array of
-.I nmatch
-structures of type
-.IR regmatch_t .
-Such a structure has at least the members
-.I rm_so
-and
-.IR rm_eo ,
-both of type
-.I regoff_t
-(a signed arithmetic type at least as large as an
-.I off_t
-and a
-.IR ssize_t ),
-containing respectively the offset of the first character of a substring
-and the offset of the first character after the end of the substring.
-Offsets are measured from the beginning of the
-.I string
-argument given to
-.IR regexec .
-An empty substring is denoted by equal offsets,
-both indicating the character following the empty substring.
-.PP
-The 0th member of the
-.I pmatch
-array is filled in to indicate what substring of
-.I string
-was matched by the entire RE.
-Remaining members report what substring was matched by parenthesized
-subexpressions within the RE;
-member
-.I i
-reports subexpression
-.IR i ,
-with subexpressions counted (starting at 1) by the order of their opening
-parentheses in the RE, left to right.
-Unused entries in the array\(emcorresponding either to subexpressions that
-did not participate in the match at all, or to subexpressions that do not
-exist in the RE (that is, \fIi\fR\ > \fIpreg\fR\->\fIre_nsub\fR)\(emhave both
-.I rm_so
-and
-.I rm_eo
-set to \-1.
-If a subexpression participated in the match several times,
-the reported substring is the last one it matched.
-(Note, as an example in particular, that when the RE `(b*)+' matches `bbb',
-the parenthesized subexpression matches each of the three `b's and then
-an infinite number of empty strings following the last `b',
-so the reported substring is one of the empties.)
-.PP
-If REG_STARTEND is specified,
-.I pmatch
-must point to at least one
-.I regmatch_t
-(even if
-.I nmatch
-is 0 or REG_NOSUB was specified),
-to hold the input offsets for REG_STARTEND.
-Use for output is still entirely controlled by
-.IR nmatch ;
-if
-.I nmatch
-is 0 or REG_NOSUB was specified,
-the value of
-.IR pmatch [0]
-will not be changed by a successful
-.IR regexec .
-.PP
-.I Regerror
-maps a non-zero
-.I errcode
-from either
-.I regcomp
-or
-.I regexec
-to a human-readable, printable message.
-If
-.I preg
-is non-NULL,
-the error code should have arisen from use of
-the
-.I regex_t
-pointed to by
-.IR preg ,
-and if the error code came from
-.IR regcomp ,
-it should have been the result from the most recent
-.I regcomp
-using that
-.IR regex_t .
-.RI ( Regerror
-may be able to supply a more detailed message using information
-from the
-.IR regex_t .)
-.I Regerror
-places the NUL-terminated message into the buffer pointed to by
-.IR errbuf ,
-limiting the length (including the NUL) to at most
-.I errbuf_size
-bytes.
-If the whole message won't fit,
-as much of it as will fit before the terminating NUL is supplied.
-In any case,
-the returned value is the size of buffer needed to hold the whole
-message (including terminating NUL).
-If
-.I errbuf_size
-is 0,
-.I errbuf
-is ignored but the return value is still correct.
-.PP
-If the
-.I errcode
-given to
-.I regerror
-is first ORed with REG_ITOA,
-the ``message'' that results is the printable name of the error code,
-e.g. ``REG_NOMATCH'',
-rather than an explanation thereof.
-If
-.I errcode
-is REG_ATOI,
-then
-.I preg
-shall be non-NULL and the
-.I re_endp
-member of the structure it points to
-must point to the printable name of an error code;
-in this case, the result in
-.I errbuf
-is the decimal digits of
-the numeric value of the error code
-(0 if the name is not recognized).
-REG_ITOA and REG_ATOI are intended primarily as debugging facilities;
-they are extensions,
-compatible with but not specified by POSIX 1003.2,
-and should be used with
-caution in software intended to be portable to other systems.
-Be warned also that they are considered experimental and changes are possible.
-.PP
-.I Regfree
-frees any dynamically-allocated storage associated with the compiled RE
-pointed to by
-.IR preg .
-The remaining
-.I regex_t
-is no longer a valid compiled RE
-and the effect of supplying it to
-.I regexec
-or
-.I regerror
-is undefined.
-.PP
-None of these functions references global variables except for tables
-of constants;
-all are safe for use from multiple threads if the arguments are safe.
-.SH IMPLEMENTATION CHOICES
-There are a number of decisions that 1003.2 leaves up to the implementor,
-either by explicitly saying ``undefined'' or by virtue of them being
-forbidden by the RE grammar.
-This implementation treats them as follows.
-.PP
-See
-.ZR
-for a discussion of the definition of case-independent matching.
-.PP
-There is no particular limit on the length of REs,
-except insofar as memory is limited.
-Memory usage is approximately linear in RE size, and largely insensitive
-to RE complexity, except for bounded repetitions.
-See BUGS for one short RE using them
-that will run almost any system out of memory.
-.PP
-A backslashed character other than one specifically given a magic meaning
-by 1003.2 (such magic meanings occur only in obsolete [``basic''] REs)
-is taken as an ordinary character.
-.PP
-Any unmatched [ is a REG_EBRACK error.
-.PP
-Equivalence classes cannot begin or end bracket-expression ranges.
-The endpoint of one range cannot begin another.
-.PP
-RE_DUP_MAX, the limit on repetition counts in bounded repetitions, is 255.
-.PP
-A repetition operator (?, *, +, or bounds) cannot follow another
-repetition operator.
-A repetition operator cannot begin an expression or subexpression
-or follow `^' or `|'.
-.PP
-`|' cannot appear first or last in a (sub)expression or after another `|',
-i.e. an operand of `|' cannot be an empty subexpression.
-An empty parenthesized subexpression, `()', is legal and matches an
-empty (sub)string.
-An empty string is not a legal RE.
-.PP
-A `{' followed by a digit is considered the beginning of bounds for a
-bounded repetition, which must then follow the syntax for bounds.
-A `{' \fInot\fR followed by a digit is considered an ordinary character.
-.PP
-`^' and `$' beginning and ending subexpressions in obsolete (``basic'')
-REs are anchors, not ordinary characters.
-.SH SEE ALSO
-grep(1), regex(7)
-.PP
-POSIX 1003.2, sections 2.8 (Regular Expression Notation)
-and
-B.5 (C Binding for Regular Expression Matching).
-.SH DIAGNOSTICS
-Non-zero error codes from
-.I regcomp
-and
-.I regexec
-include the following:
-.PP
-.nf
-.ta \w'REG_ECOLLATE'u+3n
-REG_NOMATCH regexec() failed to match
-REG_BADPAT invalid regular expression
-REG_ECOLLATE invalid collating element
-REG_ECTYPE invalid character class
-REG_EESCAPE \e applied to unescapable character
-REG_ESUBREG invalid backreference number
-REG_EBRACK brackets [ ] not balanced
-REG_EPAREN parentheses ( ) not balanced
-REG_EBRACE braces { } not balanced
-REG_BADBR invalid repetition count(s) in { }
-REG_ERANGE invalid character range in [ ]
-REG_ESPACE ran out of memory
-REG_BADRPT ?, *, or + operand invalid
-REG_EMPTY empty (sub)expression
-REG_ASSERT ``can't happen''\(emyou found a bug
-REG_INVARG invalid argument, e.g. negative-length string
-.fi
-.SH HISTORY
-Written by Henry Spencer at University of Toronto,
-henry@zoo.toronto.edu.
-.SH BUGS
-This is an alpha release with known defects.
-Please report problems.
-.PP
-There is one known functionality bug.
-The implementation of internationalization is incomplete:
-the locale is always assumed to be the default one of 1003.2,
-and only the collating elements etc. of that locale are available.
-.PP
-The back-reference code is subtle and doubts linger about its correctness
-in complex cases.
-.PP
-.I Regexec
-performance is poor.
-This will improve with later releases.
-.I Nmatch
-exceeding 0 is expensive;
-.I nmatch
-exceeding 1 is worse.
-.I Regexec
-is largely insensitive to RE complexity \fIexcept\fR that back
-references are massively expensive.
-RE length does matter; in particular, there is a strong speed bonus
-for keeping RE length under about 30 characters,
-with most special characters counting roughly double.
-.PP
-.I Regcomp
-implements bounded repetitions by macro expansion,
-which is costly in time and space if counts are large
-or bounded repetitions are nested.
-An RE like, say,
-`((((a{1,100}){1,100}){1,100}){1,100}){1,100}'
-will (eventually) run almost any existing machine out of swap space.
-.PP
-There are suspected problems with response to obscure error conditions.
-Notably,
-certain kinds of internal overflow,
-produced only by truly enormous REs or by multiply nested bounded repetitions,
-are probably not handled well.
-.PP
-Due to a mistake in 1003.2, things like `a)b' are legal REs because `)' is
-a special character only in the presence of a previous unmatched `('.
-This can't be fixed until the spec is fixed.
-.PP
-The standard's definition of back references is vague.
-For example, does
-`a\e(\e(b\e)*\e2\e)*d' match `abbbd'?
-Until the standard is clarified,
-behavior in such cases should not be relied on.
-.PP
-The implementation of word-boundary matching is a bit of a kludge,
-and bugs may lurk in combinations of word-boundary matching and anchoring.
diff --git a/ext/ereg/regex/regex.7 b/ext/ereg/regex/regex.7
deleted file mode 100644
index d89012bda1..0000000000
--- a/ext/ereg/regex/regex.7
+++ /dev/null
@@ -1,233 +0,0 @@
-.TH REGEX 7 "7 Feb 1994"
-.BY "Henry Spencer"
-.SH NAME
-regex \- POSIX 1003.2 regular expressions
-.SH DESCRIPTION
-Regular expressions (``RE''s),
-as defined in POSIX 1003.2, come in two forms:
-modern REs (roughly those of
-.IR egrep ;
-1003.2 calls these ``extended'' REs)
-and obsolete REs (roughly those of
-.IR ed ;
-1003.2 ``basic'' REs).
-Obsolete REs mostly exist for backward compatibility in some old programs;
-they will be discussed at the end.
-1003.2 leaves some aspects of RE syntax and semantics open;
-`\(dg' marks decisions on these aspects that
-may not be fully portable to other 1003.2 implementations.
-.PP
-A (modern) RE is one\(dg or more non-empty\(dg \fIbranches\fR,
-separated by `|'.
-It matches anything that matches one of the branches.
-.PP
-A branch is one\(dg or more \fIpieces\fR, concatenated.
-It matches a match for the first, followed by a match for the second, etc.
-.PP
-A piece is an \fIatom\fR possibly followed
-by a single\(dg `*', `+', `?', or \fIbound\fR.
-An atom followed by `*' matches a sequence of 0 or more matches of the atom.
-An atom followed by `+' matches a sequence of 1 or more matches of the atom.
-An atom followed by `?' matches a sequence of 0 or 1 matches of the atom.
-.PP
-A \fIbound\fR is `{' followed by an unsigned decimal integer,
-possibly followed by `,'
-possibly followed by another unsigned decimal integer,
-always followed by `}'.
-The integers must lie between 0 and RE_DUP_MAX (255\(dg) inclusive,
-and if there are two of them, the first may not exceed the second.
-An atom followed by a bound containing one integer \fIi\fR
-and no comma matches
-a sequence of exactly \fIi\fR matches of the atom.
-An atom followed by a bound
-containing one integer \fIi\fR and a comma matches
-a sequence of \fIi\fR or more matches of the atom.
-An atom followed by a bound
-containing two integers \fIi\fR and \fIj\fR matches
-a sequence of \fIi\fR through \fIj\fR (inclusive) matches of the atom.
-.PP
-An atom is a regular expression enclosed in `()' (matching a match for the
-regular expression),
-an empty set of `()' (matching the null string)\(dg,
-a \fIbracket expression\fR (see below), `.'
-(matching any single character), `^' (matching the null string at the
-beginning of a line), `$' (matching the null string at the
-end of a line), a `\e' followed by one of the characters
-`^.[$()|*+?{\e'
-(matching that character taken as an ordinary character),
-a `\e' followed by any other character\(dg
-(matching that character taken as an ordinary character,
-as if the `\e' had not been present\(dg),
-or a single character with no other significance (matching that character).
-A `{' followed by a character other than a digit is an ordinary
-character, not the beginning of a bound\(dg.
-It is illegal to end an RE with `\e'.
-.PP
-A \fIbracket expression\fR is a list of characters enclosed in `[]'.
-It normally matches any single character from the list (but see below).
-If the list begins with `^',
-it matches any single character
-(but see below) \fInot\fR from the rest of the list.
-If two characters in the list are separated by `\-', this is shorthand
-for the full \fIrange\fR of characters between those two (inclusive) in the
-collating sequence,
-e.g. `[0-9]' in ASCII matches any decimal digit.
-It is illegal\(dg for two ranges to share an
-endpoint, e.g. `a-c-e'.
-Ranges are very collating-sequence-dependent,
-and portable programs should avoid relying on them.
-.PP
-To include a literal `]' in the list, make it the first character
-(following a possible `^').
-To include a literal `\-', make it the first or last character,
-or the second endpoint of a range.
-To use a literal `\-' as the first endpoint of a range,
-enclose it in `[.' and `.]' to make it a collating element (see below).
-With the exception of these and some combinations using `[' (see next
-paragraphs), all other special characters, including `\e', lose their
-special significance within a bracket expression.
-.PP
-Within a bracket expression, a collating element (a character,
-a multi-character sequence that collates as if it were a single character,
-or a collating-sequence name for either)
-enclosed in `[.' and `.]' stands for the
-sequence of characters of that collating element.
-The sequence is a single element of the bracket expression's list.
-A bracket expression containing a multi-character collating element
-can thus match more than one character,
-e.g. if the collating sequence includes a `ch' collating element,
-then the RE `[[.ch.]]*c' matches the first five characters
-of `chchcc'.
-.PP
-Within a bracket expression, a collating element enclosed in `[=' and
-`=]' is an equivalence class, standing for the sequences of characters
-of all collating elements equivalent to that one, including itself.
-(If there are no other equivalent collating elements,
-the treatment is as if the enclosing delimiters were `[.' and `.]'.)
-For example, if o and \o'o^' are the members of an equivalence class,
-then `[[=o=]]', `[[=\o'o^'=]]', and `[o\o'o^']' are all synonymous.
-An equivalence class may not\(dg be an endpoint
-of a range.
-.PP
-Within a bracket expression, the name of a \fIcharacter class\fR enclosed
-in `[:' and `:]' stands for the list of all characters belonging to that
-class.
-Standard character class names are:
-.PP
-.RS
-.nf
-.ta 3c 6c 9c
-alnum digit punct
-alpha graph space
-blank lower upper
-cntrl print xdigit
-.fi
-.RE
-.PP
-These stand for the character classes defined in
-.IR ctype (3).
-A locale may provide others.
-A character class may not be used as an endpoint of a range.
-.PP
-There are two special cases\(dg of bracket expressions:
-the bracket expressions `[[:<:]]' and `[[:>:]]' match the null string at
-the beginning and end of a word respectively.
-A word is defined as a sequence of
-word characters
-which is neither preceded nor followed by
-word characters.
-A word character is an
-.I alnum
-character (as defined by
-.IR ctype (3))
-or an underscore.
-This is an extension,
-compatible with but not specified by POSIX 1003.2,
-and should be used with
-caution in software intended to be portable to other systems.
-.PP
-In the event that an RE could match more than one substring of a given
-string,
-the RE matches the one starting earliest in the string.
-If the RE could match more than one substring starting at that point,
-it matches the longest.
-Subexpressions also match the longest possible substrings, subject to
-the constraint that the whole match be as long as possible,
-with subexpressions starting earlier in the RE taking priority over
-ones starting later.
-Note that higher-level subexpressions thus take priority over
-their lower-level component subexpressions.
-.PP
-Match lengths are measured in characters, not collating elements.
-A null string is considered longer than no match at all.
-For example,
-`bb*' matches the three middle characters of `abbbc',
-`(wee|week)(knights|nights)' matches all ten characters of `weeknights',
-when `(.*).*' is matched against `abc' the parenthesized subexpression
-matches all three characters, and
-when `(a*)*' is matched against `bc' both the whole RE and the parenthesized
-subexpression match the null string.
-.PP
-If case-independent matching is specified,
-the effect is much as if all case distinctions had vanished from the
-alphabet.
-When an alphabetic that exists in multiple cases appears as an
-ordinary character outside a bracket expression, it is effectively
-transformed into a bracket expression containing both cases,
-e.g. `x' becomes `[xX]'.
-When it appears inside a bracket expression, all case counterparts
-of it are added to the bracket expression, so that (e.g.) `[x]'
-becomes `[xX]' and `[^x]' becomes `[^xX]'.
-.PP
-No particular limit is imposed on the length of REs\(dg.
-Programs intended to be portable should not employ REs longer
-than 256 bytes,
-as an implementation can refuse to accept such REs and remain
-POSIX-compliant.
-.PP
-Obsolete (``basic'') regular expressions differ in several respects.
-`|', `+', and `?' are ordinary characters and there is no equivalent
-for their functionality.
-The delimiters for bounds are `\e{' and `\e}',
-with `{' and `}' by themselves ordinary characters.
-The parentheses for nested subexpressions are `\e(' and `\e)',
-with `(' and `)' by themselves ordinary characters.
-`^' is an ordinary character except at the beginning of the
-RE or\(dg the beginning of a parenthesized subexpression,
-`$' is an ordinary character except at the end of the
-RE or\(dg the end of a parenthesized subexpression,
-and `*' is an ordinary character if it appears at the beginning of the
-RE or the beginning of a parenthesized subexpression
-(after a possible leading `^').
-Finally, there is one new type of atom, a \fIback reference\fR:
-`\e' followed by a non-zero decimal digit \fId\fR
-matches the same sequence of characters
-matched by the \fId\fRth parenthesized subexpression
-(numbering subexpressions by the positions of their opening parentheses,
-left to right),
-so that (e.g.) `\e([bc]\e)\e1' matches `bb' or `cc' but not `bc'.
-.SH SEE ALSO
-regex(3)
-.PP
-POSIX 1003.2, section 2.8 (Regular Expression Notation).
-.SH BUGS
-Having two kinds of REs is a botch.
-.PP
-The current 1003.2 spec says that `)' is an ordinary character in
-the absence of an unmatched `(';
-this was an unintentional result of a wording error,
-and change is likely.
-Avoid relying on it.
-.PP
-Back references are a dreadful botch,
-posing major problems for efficient implementations.
-They are also somewhat vaguely defined
-(does
-`a\e(\e(b\e)*\e2\e)*d' match `abbbd'?).
-Avoid using them.
-.PP
-1003.2's specification of case-independent matching is vague.
-The ``one case implies all cases'' definition given above
-is current consensus among implementors as to the right interpretation.
-.PP
-The syntax for word boundaries is incredibly ugly.
diff --git a/ext/ereg/regex/regex.dsp b/ext/ereg/regex/regex.dsp
deleted file mode 100644
index e8f1ad4299..0000000000
--- a/ext/ereg/regex/regex.dsp
+++ /dev/null
@@ -1,106 +0,0 @@
-# Microsoft Developer Studio Project File - Name="regex" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=regex - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "regex.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "regex.mak" CFG="regex - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "regex - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "regex - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "regex - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-
-!ELSEIF "$(CFG)" == "regex - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "." /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "regex - Win32 Release"
-# Name "regex - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\regcomp.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\regerror.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\regexec.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\regfree.c
-# End Source File
-# End Target
-# End Project
diff --git a/ext/ereg/regex/regex.dsw b/ext/ereg/regex/regex.dsw
deleted file mode 100644
index 7b7df8126c..0000000000
--- a/ext/ereg/regex/regex.dsw
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 5.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "regex"=.\regex.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/ext/ereg/regex/regex.h b/ext/ereg/regex/regex.h
deleted file mode 100644
index 5645eb6aa3..0000000000
--- a/ext/ereg/regex/regex.h
+++ /dev/null
@@ -1,79 +0,0 @@
-#ifndef _REGEX_H_
-#define _REGEX_H_ /* never again */
-/* ========= begin header generated by ././mkh ========= */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* === regex2.h === */
-#ifdef WIN32
-#define API_EXPORT(type) __declspec(dllexport) type __stdcall
-#else
-#define API_EXPORT(type) type
-#endif
-
-typedef off_t regoff_t;
-typedef struct {
- int re_magic;
- size_t re_nsub; /* number of parenthesized subexpressions */
- const char *re_endp; /* end pointer for REG_PEND */
- struct re_guts *re_g; /* none of your business :-) */
-} regex_t;
-typedef struct {
- regoff_t rm_so; /* start of match */
- regoff_t rm_eo; /* end of match */
-} regmatch_t;
-
-
-/* === regcomp.c === */
-API_EXPORT(int) regcomp(regex_t *, const char *, int);
-#define REG_BASIC 0000
-#define REG_EXTENDED 0001
-#define REG_ICASE 0002
-#define REG_NOSUB 0004
-#define REG_NEWLINE 0010
-#define REG_NOSPEC 0020
-#define REG_PEND 0040
-#define REG_DUMP 0200
-
-
-/* === regerror.c === */
-#define REG_NOMATCH 1
-#define REG_BADPAT 2
-#define REG_ECOLLATE 3
-#define REG_ECTYPE 4
-#define REG_EESCAPE 5
-#define REG_ESUBREG 6
-#define REG_EBRACK 7
-#define REG_EPAREN 8
-#define REG_EBRACE 9
-#define REG_BADBR 10
-#define REG_ERANGE 11
-#define REG_ESPACE 12
-#define REG_BADRPT 13
-#define REG_EMPTY 14
-#define REG_ASSERT 15
-#define REG_INVARG 16
-#define REG_ATOI 255 /* convert name to number (!) */
-#define REG_ITOA 0400 /* convert number to name (!) */
-API_EXPORT(size_t) regerror(int, const regex_t *, char *, size_t);
-
-
-/* === regexec.c === */
-API_EXPORT(int) regexec(const regex_t *, const char *, size_t, regmatch_t [], int);
-#define REG_NOTBOL 00001
-#define REG_NOTEOL 00002
-#define REG_STARTEND 00004
-#define REG_TRACE 00400 /* tracing of execution */
-#define REG_LARGE 01000 /* force large representation */
-#define REG_BACKR 02000 /* force use of backref code */
-
-
-/* === regfree.c === */
-API_EXPORT(void) regfree(regex_t *);
-
-#ifdef __cplusplus
-}
-#endif
-/* ========= end header generated by ././mkh ========= */
-#endif
diff --git a/ext/ereg/regex/regex.mak b/ext/ereg/regex/regex.mak
deleted file mode 100644
index b87ded340b..0000000000
--- a/ext/ereg/regex/regex.mak
+++ /dev/null
@@ -1,304 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on regex.dsp
-!IF "$(CFG)" == ""
-CFG=regex - Win32 Release
-!MESSAGE No configuration specified. Defaulting to regex - Win32 Release.
-!ENDIF
-
-!IF "$(CFG)" != "regex - Win32 Release" && "$(CFG)" != "regex - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "regex.mak" CFG="regex - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "regex - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "regex - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-CPP=cl.exe
-
-!IF "$(CFG)" == "regex - Win32 Release"
-
-OUTDIR=.\Release
-INTDIR=.\Release
-# Begin Custom Macros
-OutDir=.\.\Release
-# End Custom Macros
-
-!IF "$(RECURSE)" == "0"
-
-ALL : "$(OUTDIR)\regex.lib"
-
-!ELSE
-
-ALL : "$(OUTDIR)\regex.lib"
-
-!ENDIF
-
-CLEAN :
- -@erase "$(INTDIR)\regcomp.obj"
- -@erase "$(INTDIR)\regerror.obj"
- -@erase "$(INTDIR)\regexec.obj"
- -@erase "$(INTDIR)\regfree.obj"
- -@erase "$(INTDIR)\vc50.idb"
- -@erase "$(OUTDIR)\regex.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "." /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
- /Fp"$(INTDIR)\regex.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-CPP_OBJS=.\Release/
-CPP_SBRS=.
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\regex.bsc"
-BSC32_SBRS= \
-
-LIB32=link.exe -lib
-LIB32_FLAGS=/nologo /out:"$(OUTDIR)\regex.lib"
-LIB32_OBJS= \
- "$(INTDIR)\regcomp.obj" \
- "$(INTDIR)\regerror.obj" \
- "$(INTDIR)\regexec.obj" \
- "$(INTDIR)\regfree.obj"
-
-"$(OUTDIR)\regex.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
- $(LIB32) @<<
- $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "regex - Win32 Debug"
-
-OUTDIR=.\Debug
-INTDIR=.\Debug
-# Begin Custom Macros
-OutDir=.\.\Debug
-# End Custom Macros
-
-!IF "$(RECURSE)" == "0"
-
-ALL : "$(OUTDIR)\regex.lib" "$(OUTDIR)\regex.bsc"
-
-!ELSE
-
-ALL : "$(OUTDIR)\regex.lib" "$(OUTDIR)\regex.bsc"
-
-!ENDIF
-
-CLEAN :
- -@erase "$(INTDIR)\regcomp.obj"
- -@erase "$(INTDIR)\regcomp.sbr"
- -@erase "$(INTDIR)\regerror.obj"
- -@erase "$(INTDIR)\regerror.sbr"
- -@erase "$(INTDIR)\regexec.obj"
- -@erase "$(INTDIR)\regexec.sbr"
- -@erase "$(INTDIR)\regfree.obj"
- -@erase "$(INTDIR)\regfree.sbr"
- -@erase "$(INTDIR)\vc50.idb"
- -@erase "$(OUTDIR)\regex.bsc"
- -@erase "$(OUTDIR)\regex.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP_PROJ=/nologo /MDd /W3 /GX /Z7 /Od /I "." /D "WIN32" /D "_DEBUG" /D\
- "_WINDOWS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\regex.pch" /YX /Fo"$(INTDIR)\\"\
- /Fd"$(INTDIR)\\" /FD /c
-CPP_OBJS=.\Debug/
-CPP_SBRS=.\Debug/
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\regex.bsc"
-BSC32_SBRS= \
- "$(INTDIR)\regcomp.sbr" \
- "$(INTDIR)\regerror.sbr" \
- "$(INTDIR)\regexec.sbr" \
- "$(INTDIR)\regfree.sbr"
-
-"$(OUTDIR)\regex.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
- $(BSC32) @<<
- $(BSC32_FLAGS) $(BSC32_SBRS)
-<<
-
-LIB32=link.exe -lib
-LIB32_FLAGS=/nologo /out:"$(OUTDIR)\regex.lib"
-LIB32_OBJS= \
- "$(INTDIR)\regcomp.obj" \
- "$(INTDIR)\regerror.obj" \
- "$(INTDIR)\regexec.obj" \
- "$(INTDIR)\regfree.obj"
-
-"$(OUTDIR)\regex.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
- $(LIB32) @<<
- $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
-<<
-
-!ENDIF
-
-.c{$(CPP_OBJS)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(CPP_OBJS)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(CPP_OBJS)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(CPP_SBRS)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(CPP_SBRS)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(CPP_SBRS)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-
-!IF "$(CFG)" == "regex - Win32 Release" || "$(CFG)" == "regex - Win32 Debug"
-SOURCE=.\regcomp.c
-
-!IF "$(CFG)" == "regex - Win32 Release"
-
-DEP_CPP_REGCO=\
- ".\cclass.h"\
- ".\cname.h"\
- ".\regcomp.ih"\
- ".\regex.h"\
- ".\regex2.h"\
- ".\utils.h"\
-
-
-"$(INTDIR)\regcomp.obj" : $(SOURCE) $(DEP_CPP_REGCO) "$(INTDIR)"
-
-
-!ELSEIF "$(CFG)" == "regex - Win32 Debug"
-
-DEP_CPP_REGCO=\
- ".\cclass.h"\
- ".\cname.h"\
- ".\regcomp.ih"\
- ".\regex.h"\
- ".\regex2.h"\
- ".\utils.h"\
- {$(INCLUDE)}"sys\types.h"\
-
-
-"$(INTDIR)\regcomp.obj" "$(INTDIR)\regcomp.sbr" : $(SOURCE) $(DEP_CPP_REGCO)\
- "$(INTDIR)"
-
-
-!ENDIF
-
-SOURCE=.\regerror.c
-
-!IF "$(CFG)" == "regex - Win32 Release"
-
-DEP_CPP_REGER=\
- ".\regerror.ih"\
- ".\regex.h"\
- ".\utils.h"\
-
-
-"$(INTDIR)\regerror.obj" : $(SOURCE) $(DEP_CPP_REGER) "$(INTDIR)"
-
-
-!ELSEIF "$(CFG)" == "regex - Win32 Debug"
-
-DEP_CPP_REGER=\
- ".\regerror.ih"\
- ".\regex.h"\
- ".\utils.h"\
- {$(INCLUDE)}"sys\types.h"\
-
-
-"$(INTDIR)\regerror.obj" "$(INTDIR)\regerror.sbr" : $(SOURCE) $(DEP_CPP_REGER)\
- "$(INTDIR)"
-
-
-!ENDIF
-
-SOURCE=.\regexec.c
-
-!IF "$(CFG)" == "regex - Win32 Release"
-
-DEP_CPP_REGEX=\
- ".\engine.c"\
- ".\engine.ih"\
- ".\regex.h"\
- ".\regex2.h"\
- ".\utils.h"\
-
-
-"$(INTDIR)\regexec.obj" : $(SOURCE) $(DEP_CPP_REGEX) "$(INTDIR)"
-
-
-!ELSEIF "$(CFG)" == "regex - Win32 Debug"
-
-DEP_CPP_REGEX=\
- ".\engine.c"\
- ".\engine.ih"\
- ".\regex.h"\
- ".\regex2.h"\
- ".\utils.h"\
- {$(INCLUDE)}"sys\types.h"\
-
-
-"$(INTDIR)\regexec.obj" "$(INTDIR)\regexec.sbr" : $(SOURCE) $(DEP_CPP_REGEX)\
- "$(INTDIR)"
-
-
-!ENDIF
-
-SOURCE=.\regfree.c
-
-!IF "$(CFG)" == "regex - Win32 Release"
-
-DEP_CPP_REGFR=\
- ".\regex.h"\
- ".\regex2.h"\
- ".\utils.h"\
-
-
-"$(INTDIR)\regfree.obj" : $(SOURCE) $(DEP_CPP_REGFR) "$(INTDIR)"
-
-
-!ELSEIF "$(CFG)" == "regex - Win32 Debug"
-
-DEP_CPP_REGFR=\
- ".\regex.h"\
- ".\regex2.h"\
- ".\utils.h"\
- {$(INCLUDE)}"sys\types.h"\
-
-
-"$(INTDIR)\regfree.obj" "$(INTDIR)\regfree.sbr" : $(SOURCE) $(DEP_CPP_REGFR)\
- "$(INTDIR)"
-
-
-!ENDIF
-
-SOURCE=.\engine.c
-
-!ENDIF
-
diff --git a/ext/ereg/regex/regex2.h b/ext/ereg/regex/regex2.h
deleted file mode 100644
index 3e8c0d65c4..0000000000
--- a/ext/ereg/regex/regex2.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * First, the stuff that ends up in the outside-world include file
- = #ifdef WIN32
- = #define API_EXPORT(type) __declspec(dllexport) type __stdcall
- = #else
- = #define API_EXPORT(type) type
- = #endif
- =
- = typedef off_t regoff_t;
- = typedef struct {
- = int re_magic;
- = size_t re_nsub; // number of parenthesized subexpressions
- = const char *re_endp; // end pointer for REG_PEND
- = struct re_guts *re_g; // none of your business :-)
- = } regex_t;
- = typedef struct {
- = regoff_t rm_so; // start of match
- = regoff_t rm_eo; // end of match
- = } regmatch_t;
- */
-/*
- * internals of regex_t
- */
-#define MAGIC1 ((('r'^0200)<<8) | 'e')
-
-/*
- * The internal representation is a *strip*, a sequence of
- * operators ending with an endmarker. (Some terminology etc. is a
- * historical relic of earlier versions which used multiple strips.)
- * Certain oddities in the representation are there to permit running
- * the machinery backwards; in particular, any deviation from sequential
- * flow must be marked at both its source and its destination. Some
- * fine points:
- *
- * - OPLUS_ and O_PLUS are *inside* the loop they create.
- * - OQUEST_ and O_QUEST are *outside* the bypass they create.
- * - OCH_ and O_CH are *outside* the multi-way branch they create, while
- * OOR1 and OOR2 are respectively the end and the beginning of one of
- * the branches. Note that there is an implicit OOR2 following OCH_
- * and an implicit OOR1 preceding O_CH.
- *
- * In state representations, an operator's bit is on to signify a state
- * immediately *preceding* "execution" of that operator.
- */
-typedef unsigned long sop; /* strip operator */
-typedef long sopno;
-#define OPRMASK 0xf8000000
-#define OPDMASK 0x07ffffff
-#define OPSHIFT ((unsigned)27)
-#define OP(n) ((n)&OPRMASK)
-#define OPND(n) ((n)&OPDMASK)
-#define SOP(op, opnd) ((op)|(opnd))
-/* operators meaning operand */
-/* (back, fwd are offsets) */
-#define OEND (1<<OPSHIFT) /* endmarker - */
-#define OCHAR (2<<OPSHIFT) /* character unsigned char */
-#define OBOL (3<<OPSHIFT) /* left anchor - */
-#define OEOL (4<<OPSHIFT) /* right anchor - */
-#define OANY (5<<OPSHIFT) /* . - */
-#define OANYOF (6<<OPSHIFT) /* [...] set number */
-#define OBACK_ (7<<OPSHIFT) /* begin \d paren number */
-#define O_BACK (8<<OPSHIFT) /* end \d paren number */
-#define OPLUS_ (9<<OPSHIFT) /* + prefix fwd to suffix */
-#define O_PLUS (10<<OPSHIFT) /* + suffix back to prefix */
-#define OQUEST_ (11<<OPSHIFT) /* ? prefix fwd to suffix */
-#define O_QUEST (12<<OPSHIFT) /* ? suffix back to prefix */
-#define OLPAREN (13<<OPSHIFT) /* ( fwd to ) */
-#define ORPAREN (14<<OPSHIFT) /* ) back to ( */
-#define OCH_ (15<<OPSHIFT) /* begin choice fwd to OOR2 */
-#define OOR1 (16u<<OPSHIFT) /* | pt. 1 back to OOR1 or OCH_ */
-#define OOR2 (17u<<OPSHIFT) /* | pt. 2 fwd to OOR2 or O_CH */
-#define O_CH (18u<<OPSHIFT) /* end choice back to OOR1 */
-#define OBOW (19u<<OPSHIFT) /* begin word - */
-#define OEOW (20u<<OPSHIFT) /* end word - */
-
-/*
- * Structure for [] character-set representation. Character sets are
- * done as bit vectors, grouped 8 to a byte vector for compactness.
- * The individual set therefore has both a pointer to the byte vector
- * and a mask to pick out the relevant bit of each byte. A hash code
- * simplifies testing whether two sets could be identical.
- *
- * This will get trickier for multicharacter collating elements. As
- * preliminary hooks for dealing with such things, we also carry along
- * a string of multi-character elements, and decide the size of the
- * vectors at run time.
- */
-typedef struct {
- uch *ptr; /* -> uch [csetsize] */
- uch mask; /* bit within array */
- uch hash; /* hash code */
- size_t smultis;
- char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */
-} cset;
-/* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */
-#define CHadd(cs, c) ((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c))
-#define CHsub(cs, c) ((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c))
-#define CHIN(cs, c) ((cs)->ptr[(uch)(c)] & (cs)->mask)
-#define MCadd(p, cs, cp) mcadd(p, cs, cp) /* regcomp() internal fns */
-
-/* stuff for character categories */
-typedef unsigned char cat_t;
-
-/*
- * main compiled-expression structure
- */
-struct re_guts {
- int magic;
-# define MAGIC2 ((('R'^0200)<<8)|'E')
- sop *strip; /* malloced area for strip */
- int csetsize; /* number of bits in a cset vector */
- int ncsets; /* number of csets in use */
- cset *sets; /* -> cset [ncsets] */
- uch *setbits; /* -> uch[csetsize][ncsets/CHAR_BIT] */
- int cflags; /* copy of regcomp() cflags argument */
- sopno nstates; /* = number of sops */
- sopno firststate; /* the initial OEND (normally 0) */
- sopno laststate; /* the final OEND */
- int iflags; /* internal flags */
-# define USEBOL 01 /* used ^ */
-# define USEEOL 02 /* used $ */
-# define BAD 04 /* something wrong */
- int nbol; /* number of ^ used */
- int neol; /* number of $ used */
- int ncategories; /* how many character categories */
- cat_t *categories; /* ->catspace[-CHAR_MIN] */
- char *must; /* match must contain this string */
- int mlen; /* length of must */
- size_t nsub; /* copy of re_nsub */
- int backrefs; /* does it use back references? */
- sopno nplus; /* how deep does it nest +s? */
- /* catspace must be last */
- cat_t catspace[1]; /* actually [NC] */
-};
-
-/* misc utilities */
-#define OUT (CHAR_MAX+1) /* a non-character value */
-#define ISWORD(c) (isalnum(c) || (c) == '_')
diff --git a/ext/ereg/regex/regexec.c b/ext/ereg/regex/regexec.c
deleted file mode 100644
index a552f5a394..0000000000
--- a/ext/ereg/regex/regexec.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * the outer shell of regexec()
- *
- * This file includes engine.c *twice*, after muchos fiddling with the
- * macros that code uses. This lets the same code operate on two different
- * representations for state sets.
- */
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <ctype.h>
-#include <regex.h>
-
-#include "utils.h"
-#include "regex2.h"
-
-#ifndef NDEBUG
-static int nope = 0; /* for use in asserts; shuts lint up */
-#endif
-
-/* macros for manipulating states, small version */
-#define states long
-#define states1 states /* for later use in regexec() decision */
-#define CLEAR(v) ((v) = 0)
-#define SET0(v, n) ((v) &= ~(1 << (n)))
-#define SET1(v, n) ((v) |= 1 << (n))
-#define ISSET(v, n) ((v) & (1 << (n)))
-#define ASSIGN(d, s) ((d) = (s))
-#define EQ(a, b) ((a) == (b))
-#define STATEVARS int dummy /* dummy version */
-#define STATESETUP(m, n) /* nothing */
-#define STATETEARDOWN(m) /* nothing */
-#define SETUP(v) ((v) = 0)
-#define onestate int
-#define INIT(o, n) ((o) = (unsigned)1 << (n))
-#define INC(o) ((o) <<= 1)
-#define ISSTATEIN(v, o) ((v) & (o))
-/* some abbreviations; note that some of these know variable names! */
-/* do "if I'm here, I can also be there" etc without branches */
-#define FWD(dst, src, n) ((dst) |= ((unsigned)(src)&(here)) << (n))
-#define BACK(dst, src, n) ((dst) |= ((unsigned)(src)&(here)) >> (n))
-#define ISSETBACK(v, n) ((v) & ((unsigned)here >> (n)))
-/* function names */
-#define SNAMES /* engine.c looks after details */
-
-#include "engine.c"
-
-/* now undo things */
-#undef states
-#undef CLEAR
-#undef SET0
-#undef SET1
-#undef ISSET
-#undef ASSIGN
-#undef EQ
-#undef STATEVARS
-#undef STATESETUP
-#undef STATETEARDOWN
-#undef SETUP
-#undef onestate
-#undef INIT
-#undef INC
-#undef ISSTATEIN
-#undef FWD
-#undef BACK
-#undef ISSETBACK
-#undef SNAMES
-
-/* macros for manipulating states, large version */
-#define states char *
-#define CLEAR(v) memset(v, 0, m->g->nstates)
-#define SET0(v, n) ((v)[n] = 0)
-#define SET1(v, n) ((v)[n] = 1)
-#define ISSET(v, n) ((v)[n])
-#define ASSIGN(d, s) memcpy(d, s, m->g->nstates)
-#define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0)
-#define STATEVARS int vn; char *space
-#define STATESETUP(m, nv) { (m)->space = malloc((nv)*(m)->g->nstates); \
- if ((m)->space == NULL) return(REG_ESPACE); \
- (m)->vn = 0; }
-#define STATETEARDOWN(m) { free((m)->space); }
-#define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates])
-#define onestate int
-#define INIT(o, n) ((o) = (n))
-#define INC(o) ((o)++)
-#define ISSTATEIN(v, o) ((v)[o])
-/* some abbreviations; note that some of these know variable names! */
-/* do "if I'm here, I can also be there" etc without branches */
-#define FWD(dst, src, n) ((dst)[here+(n)] |= (src)[here])
-#define BACK(dst, src, n) ((dst)[here-(n)] |= (src)[here])
-#define ISSETBACK(v, n) ((v)[here - (n)])
-/* function names */
-#define LNAMES /* flag */
-
-#include "engine.c"
-
-/*
- - regexec - interface for matching
- = API_EXPORT(int) regexec(const regex_t *, const char *, size_t, \
- = regmatch_t [], int);
- = #define REG_NOTBOL 00001
- = #define REG_NOTEOL 00002
- = #define REG_STARTEND 00004
- = #define REG_TRACE 00400 // tracing of execution
- = #define REG_LARGE 01000 // force large representation
- = #define REG_BACKR 02000 // force use of backref code
- *
- * We put this here so we can exploit knowledge of the state representation
- * when choosing which matcher to call. Also, by this point the matchers
- * have been prototyped.
- */
-API_EXPORT(int) /* 0 success, REG_NOMATCH failure */
-regexec(preg, string, nmatch, pmatch, eflags)
-const regex_t *preg;
-const char *string;
-size_t nmatch;
-regmatch_t pmatch[];
-int eflags;
-{
- register struct re_guts *g = preg->re_g;
-#ifdef REDEBUG
-# define GOODFLAGS(f) (f)
-#else
-# define GOODFLAGS(f) ((f)&(REG_NOTBOL|REG_NOTEOL|REG_STARTEND))
-#endif
-
- if (preg->re_magic != MAGIC1 || g->magic != MAGIC2)
- return(REG_BADPAT);
- assert(!(g->iflags&BAD));
- if (g->iflags&BAD) /* backstop for no-debug case */
- return(REG_BADPAT);
- eflags = GOODFLAGS(eflags);
-
- if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags&REG_LARGE))
- return(smatcher(g, (char *)string, nmatch, pmatch, eflags));
- else
- return(lmatcher(g, (char *)string, nmatch, pmatch, eflags));
-}
diff --git a/ext/ereg/regex/regfree.c b/ext/ereg/regex/regfree.c
deleted file mode 100644
index 9fd618a13b..0000000000
--- a/ext/ereg/regex/regfree.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <regex.h>
-
-#include "utils.h"
-#include "regex2.h"
-
-/*
- - regfree - free everything
- = API_EXPORT(void) regfree(regex_t *);
- */
-API_EXPORT(void)
-regfree(preg)
-regex_t *preg;
-{
- register struct re_guts *g;
-
- if (preg->re_magic != MAGIC1) /* oops */
- return; /* nice to complain, but hard */
-
- g = preg->re_g;
- if (g == NULL || g->magic != MAGIC2) /* oops again */
- return;
- preg->re_magic = 0; /* mark it invalid */
- g->magic = 0; /* mark it invalid */
-
- if (g->strip != NULL)
- free((char *)g->strip);
- if (g->sets != NULL)
- free((char *)g->sets);
- if (g->setbits != NULL)
- free((char *)g->setbits);
- if (g->must != NULL)
- free(g->must);
- free((char *)g);
-}
diff --git a/ext/ereg/regex/split.c b/ext/ereg/regex/split.c
deleted file mode 100644
index 188bdb775b..0000000000
--- a/ext/ereg/regex/split.c
+++ /dev/null
@@ -1,316 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-
-/*
- - split - divide a string into fields, like awk split()
- = int split(char *string, char *fields[], int nfields, char *sep);
- */
-int /* number of fields, including overflow */
-split(string, fields, nfields, sep)
-char *string;
-char *fields[]; /* list is not NULL-terminated */
-int nfields; /* number of entries available in fields[] */
-char *sep; /* "" white, "c" single char, "ab" [ab]+ */
-{
- register char *p = string;
- register char c; /* latest character */
- register char sepc = sep[0];
- register char sepc2;
- register int fn;
- register char **fp = fields;
- register char *sepp;
- register int trimtrail;
-
- /* white space */
- if (sepc == '\0') {
- while ((c = *p++) == ' ' || c == '\t')
- continue;
- p--;
- trimtrail = 1;
- sep = " \t"; /* note, code below knows this is 2 long */
- sepc = ' ';
- } else
- trimtrail = 0;
- sepc2 = sep[1]; /* now we can safely pick this up */
-
- /* catch empties */
- if (*p == '\0')
- return(0);
-
- /* single separator */
- if (sepc2 == '\0') {
- fn = nfields;
- for (;;) {
- *fp++ = p;
- fn--;
- if (fn == 0)
- break;
- while ((c = *p++) != sepc)
- if (c == '\0')
- return(nfields - fn);
- *(p-1) = '\0';
- }
- /* we have overflowed the fields vector -- just count them */
- fn = nfields;
- for (;;) {
- while ((c = *p++) != sepc)
- if (c == '\0')
- return(fn);
- fn++;
- }
- /* not reached */
- }
-
- /* two separators */
- if (sep[2] == '\0') {
- fn = nfields;
- for (;;) {
- *fp++ = p;
- fn--;
- while ((c = *p++) != sepc && c != sepc2)
- if (c == '\0') {
- if (trimtrail && **(fp-1) == '\0')
- fn++;
- return(nfields - fn);
- }
- if (fn == 0)
- break;
- *(p-1) = '\0';
- while ((c = *p++) == sepc || c == sepc2)
- continue;
- p--;
- }
- /* we have overflowed the fields vector -- just count them */
- fn = nfields;
- while (c != '\0') {
- while ((c = *p++) == sepc || c == sepc2)
- continue;
- p--;
- fn++;
- while ((c = *p++) != '\0' && c != sepc && c != sepc2)
- continue;
- }
- /* might have to trim trailing white space */
- if (trimtrail) {
- p--;
- while ((c = *--p) == sepc || c == sepc2)
- continue;
- p++;
- if (*p != '\0') {
- if (fn == nfields+1)
- *p = '\0';
- fn--;
- }
- }
- return(fn);
- }
-
- /* n separators */
- fn = 0;
- for (;;) {
- if (fn < nfields)
- *fp++ = p;
- fn++;
- for (;;) {
- c = *p++;
- if (c == '\0')
- return(fn);
- sepp = sep;
- while ((sepc = *sepp++) != '\0' && sepc != c)
- continue;
- if (sepc != '\0') /* it was a separator */
- break;
- }
- if (fn < nfields)
- *(p-1) = '\0';
- for (;;) {
- c = *p++;
- sepp = sep;
- while ((sepc = *sepp++) != '\0' && sepc != c)
- continue;
- if (sepc == '\0') /* it wasn't a separator */
- break;
- }
- p--;
- }
-
- /* not reached */
-}
-
-#ifdef TEST_SPLIT
-
-
-/*
- * test program
- * pgm runs regression
- * pgm sep splits stdin lines by sep
- * pgm str sep splits str by sep
- * pgm str sep n splits str by sep n times
- */
-int
-main(argc, argv)
-int argc;
-char *argv[];
-{
- char buf[512];
- register int n;
-# define MNF 10
- char *fields[MNF];
-
- if (argc > 4)
- for (n = atoi(argv[3]); n > 0; n--) {
- (void) strcpy(buf, argv[1]);
- }
- else if (argc > 3)
- for (n = atoi(argv[3]); n > 0; n--) {
- (void) strcpy(buf, argv[1]);
- (void) split(buf, fields, MNF, argv[2]);
- }
- else if (argc > 2)
- dosplit(argv[1], argv[2]);
- else if (argc > 1)
- while (fgets(buf, sizeof(buf), stdin) != NULL) {
- buf[strlen(buf)-1] = '\0'; /* stomp newline */
- dosplit(buf, argv[1]);
- }
- else
- regress();
-
- exit(0);
-}
-
-dosplit(string, seps)
-char *string;
-char *seps;
-{
-# define NF 5
- char *fields[NF];
- register int nf;
-
- nf = split(string, fields, NF, seps);
- print(nf, NF, fields);
-}
-
-print(nf, nfp, fields)
-int nf;
-int nfp;
-char *fields[];
-{
- register int fn;
- register int bound;
-
- bound = (nf > nfp) ? nfp : nf;
- printf("%d:\t", nf);
- for (fn = 0; fn < bound; fn++)
- printf("\"%s\"%s", fields[fn], (fn+1 < nf) ? ", " : "\n");
-}
-
-#define RNF 5 /* some table entries know this */
-struct {
- char *str;
- char *seps;
- int nf;
- char *fi[RNF];
-} tests[] = {
- "", " ", 0, { "" },
- " ", " ", 2, { "", "" },
- "x", " ", 1, { "x" },
- "xy", " ", 1, { "xy" },
- "x y", " ", 2, { "x", "y" },
- "abc def g ", " ", 5, { "abc", "def", "", "g", "" },
- " a bcd", " ", 4, { "", "", "a", "bcd" },
- "a b c d e f", " ", 6, { "a", "b", "c", "d", "e f" },
- " a b c d ", " ", 6, { "", "a", "b", "c", "d " },
-
- "", " _", 0, { "" },
- " ", " _", 2, { "", "" },
- "x", " _", 1, { "x" },
- "x y", " _", 2, { "x", "y" },
- "ab _ cd", " _", 2, { "ab", "cd" },
- " a_b c ", " _", 5, { "", "a", "b", "c", "" },
- "a b c_d e f", " _", 6, { "a", "b", "c", "d", "e f" },
- " a b c d ", " _", 6, { "", "a", "b", "c", "d " },
-
- "", " _~", 0, { "" },
- " ", " _~", 2, { "", "" },
- "x", " _~", 1, { "x" },
- "x y", " _~", 2, { "x", "y" },
- "ab _~ cd", " _~", 2, { "ab", "cd" },
- " a_b c~", " _~", 5, { "", "a", "b", "c", "" },
- "a b_c d~e f", " _~", 6, { "a", "b", "c", "d", "e f" },
- "~a b c d ", " _~", 6, { "", "a", "b", "c", "d " },
-
- "", " _~-", 0, { "" },
- " ", " _~-", 2, { "", "" },
- "x", " _~-", 1, { "x" },
- "x y", " _~-", 2, { "x", "y" },
- "ab _~- cd", " _~-", 2, { "ab", "cd" },
- " a_b c~", " _~-", 5, { "", "a", "b", "c", "" },
- "a b_c-d~e f", " _~-", 6, { "a", "b", "c", "d", "e f" },
- "~a-b c d ", " _~-", 6, { "", "a", "b", "c", "d " },
-
- "", " ", 0, { "" },
- " ", " ", 2, { "", "" },
- "x", " ", 1, { "x" },
- "xy", " ", 1, { "xy" },
- "x y", " ", 2, { "x", "y" },
- "abc def g ", " ", 4, { "abc", "def", "g", "" },
- " a bcd", " ", 3, { "", "a", "bcd" },
- "a b c d e f", " ", 6, { "a", "b", "c", "d", "e f" },
- " a b c d ", " ", 6, { "", "a", "b", "c", "d " },
-
- "", "", 0, { "" },
- " ", "", 0, { "" },
- "x", "", 1, { "x" },
- "xy", "", 1, { "xy" },
- "x y", "", 2, { "x", "y" },
- "abc def g ", "", 3, { "abc", "def", "g" },
- "\t a bcd", "", 2, { "a", "bcd" },
- " a \tb\t c ", "", 3, { "a", "b", "c" },
- "a b c d e ", "", 5, { "a", "b", "c", "d", "e" },
- "a b\tc d e f", "", 6, { "a", "b", "c", "d", "e f" },
- " a b c d e f ", "", 6, { "a", "b", "c", "d", "e f " },
-
- NULL, NULL, 0, { NULL },
-};
-
-regress()
-{
- char buf[512];
- register int n;
- char *fields[RNF+1];
- register int nf;
- register int i;
- register int printit;
- register char *f;
-
- for (n = 0; tests[n].str != NULL; n++) {
- (void) strcpy(buf, tests[n].str);
- fields[RNF] = NULL;
- nf = split(buf, fields, RNF, tests[n].seps);
- printit = 0;
- if (nf != tests[n].nf) {
- printf("split `%s' by `%s' gave %d fields, not %d\n",
- tests[n].str, tests[n].seps, nf, tests[n].nf);
- printit = 1;
- } else if (fields[RNF] != NULL) {
- printf("split() went beyond array end\n");
- printit = 1;
- } else {
- for (i = 0; i < nf && i < RNF; i++) {
- f = fields[i];
- if (f == NULL)
- f = "(NULL)";
- if (strcmp(f, tests[n].fi[i]) != 0) {
- printf("split `%s' by `%s', field %d is `%s', not `%s'\n",
- tests[n].str, tests[n].seps,
- i, fields[i], tests[n].fi[i]);
- printit = 1;
- }
- }
- }
- if (printit)
- print(nf, RNF, fields);
- }
-}
-#endif
diff --git a/ext/ereg/regex/tests b/ext/ereg/regex/tests
deleted file mode 100644
index c05846177f..0000000000
--- a/ext/ereg/regex/tests
+++ /dev/null
@@ -1,475 +0,0 @@
-# regular expression test set
-# Lines are at least three fields, separated by one or more tabs. "" stands
-# for an empty field. First field is an RE. Second field is flags. If
-# C flag given, regcomp() is expected to fail, and the third field is the
-# error name (minus the leading REG_).
-#
-# Otherwise it is expected to succeed, and the third field is the string to
-# try matching it against. If there is no fourth field, the match is
-# expected to fail. If there is a fourth field, it is the substring that
-# the RE is expected to match. If there is a fifth field, it is a comma-
-# separated list of what the subexpressions should match, with - indicating
-# no match for that one. In both the fourth and fifth fields, a (sub)field
-# starting with @ indicates that the (sub)expression is expected to match
-# a null string followed by the stuff after the @; this provides a way to
-# test where null strings match. The character `N' in REs and strings
-# is newline, `S' is space, `T' is tab, `Z' is NUL.
-#
-# The full list of flags:
-# - placeholder, does nothing
-# b RE is a BRE, not an ERE
-# & try it as both an ERE and a BRE
-# C regcomp() error expected, third field is error name
-# i REG_ICASE
-# m ("mundane") REG_NOSPEC
-# s REG_NOSUB (not really testable)
-# n REG_NEWLINE
-# ^ REG_NOTBOL
-# $ REG_NOTEOL
-# # REG_STARTEND (see below)
-# p REG_PEND
-#
-# For REG_STARTEND, the start/end offsets are those of the substring
-# enclosed in ().
-
-# basics
-a & a a
-abc & abc abc
-abc|de - abc abc
-a|b|c - abc a
-
-# parentheses and perversions thereof
-a(b)c - abc abc
-a\(b\)c b abc abc
-a( C EPAREN
-a( b a( a(
-a\( - a( a(
-a\( bC EPAREN
-a\(b bC EPAREN
-a(b C EPAREN
-a(b b a(b a(b
-# gag me with a right parenthesis -- 1003.2 goofed here (my fault, partly)
-a) - a) a)
-) - ) )
-# end gagging (in a just world, those *should* give EPAREN)
-a) b a) a)
-a\) bC EPAREN
-\) bC EPAREN
-a()b - ab ab
-a\(\)b b ab ab
-
-# anchoring and REG_NEWLINE
-^abc$ & abc abc
-a^b - a^b
-a^b b a^b a^b
-a$b - a$b
-a$b b a$b a$b
-^ & abc @abc
-$ & abc @
-^$ & "" @
-$^ - "" @
-\($\)\(^\) b "" @
-# stop retching, those are legitimate (although disgusting)
-^^ - "" @
-$$ - "" @
-b$ & abNc
-b$ &n abNc b
-^b$ & aNbNc
-^b$ &n aNbNc b
-^$ &n aNNb @Nb
-^$ n abc
-^$ n abcN @
-$^ n aNNb @Nb
-\($\)\(^\) bn aNNb @Nb
-^^ n^ aNNb @Nb
-$$ n aNNb @NN
-^a ^ a
-a$ $ a
-^a ^n aNb
-^b ^n aNb b
-a$ $n bNa
-b$ $n bNa b
-a*(^b$)c* - b b
-a*\(^b$\)c* b b b
-
-# certain syntax errors and non-errors
-| C EMPTY
-| b | |
-* C BADRPT
-* b * *
-+ C BADRPT
-? C BADRPT
-"" &C EMPTY
-() - abc @abc
-\(\) b abc @abc
-a||b C EMPTY
-|ab C EMPTY
-ab| C EMPTY
-(|a)b C EMPTY
-(a|)b C EMPTY
-(*a) C BADRPT
-(+a) C BADRPT
-(?a) C BADRPT
-({1}a) C BADRPT
-\(\{1\}a\) bC BADRPT
-(a|*b) C BADRPT
-(a|+b) C BADRPT
-(a|?b) C BADRPT
-(a|{1}b) C BADRPT
-^* C BADRPT
-^* b * *
-^+ C BADRPT
-^? C BADRPT
-^{1} C BADRPT
-^\{1\} bC BADRPT
-
-# metacharacters, backslashes
-a.c & abc abc
-a[bc]d & abd abd
-a\*c & a*c a*c
-a\\b & a\b a\b
-a\\\*b & a\*b a\*b
-a\bc & abc abc
-a\ &C EESCAPE
-a\\bc & a\bc a\bc
-\{ bC BADRPT
-a\[b & a[b a[b
-a[b &C EBRACK
-# trailing $ is a peculiar special case for the BRE code
-a$ & a a
-a$ & a$
-a\$ & a
-a\$ & a$ a$
-a\\$ & a
-a\\$ & a$
-a\\$ & a\$
-a\\$ & a\ a\
-
-# back references, ugh
-a\(b\)\2c bC ESUBREG
-a\(b\1\)c bC ESUBREG
-a\(b*\)c\1d b abbcbbd abbcbbd bb
-a\(b*\)c\1d b abbcbd
-a\(b*\)c\1d b abbcbbbd
-^\(.\)\1 b abc
-a\([bc]\)\1d b abcdabbd abbd b
-a\(\([bc]\)\2\)*d b abbccd abbccd
-a\(\([bc]\)\2\)*d b abbcbd
-# actually, this next one probably ought to fail, but the spec is unclear
-a\(\(b\)*\2\)*d b abbbd abbbd
-# here is a case that no NFA implementation does right
-\(ab*\)[ab]*\1 b ababaaa ababaaa a
-# check out normal matching in the presence of back refs
-\(a\)\1bcd b aabcd aabcd
-\(a\)\1bc*d b aabcd aabcd
-\(a\)\1bc*d b aabd aabd
-\(a\)\1bc*d b aabcccd aabcccd
-\(a\)\1bc*[ce]d b aabcccd aabcccd
-^\(a\)\1b\(c\)*cd$ b aabcccd aabcccd
-
-# ordinary repetitions
-ab*c & abc abc
-ab+c - abc abc
-ab?c - abc abc
-a\(*\)b b a*b a*b
-a\(**\)b b ab ab
-a\(***\)b bC BADRPT
-*a b *a *a
-**a b a a
-***a bC BADRPT
-
-# the dreaded bounded repetitions
-{ & { {
-{abc & {abc {abc
-{1 C BADRPT
-{1} C BADRPT
-a{b & a{b a{b
-a{1}b - ab ab
-a\{1\}b b ab ab
-a{1,}b - ab ab
-a\{1,\}b b ab ab
-a{1,2}b - aab aab
-a\{1,2\}b b aab aab
-a{1 C EBRACE
-a\{1 bC EBRACE
-a{1a C EBRACE
-a\{1a bC EBRACE
-a{1a} C BADBR
-a\{1a\} bC BADBR
-a{,2} - a{,2} a{,2}
-a\{,2\} bC BADBR
-a{,} - a{,} a{,}
-a\{,\} bC BADBR
-a{1,x} C BADBR
-a\{1,x\} bC BADBR
-a{1,x C EBRACE
-a\{1,x bC EBRACE
-a{300} C BADBR
-a\{300\} bC BADBR
-a{1,0} C BADBR
-a\{1,0\} bC BADBR
-ab{0,0}c - abcac ac
-ab\{0,0\}c b abcac ac
-ab{0,1}c - abcac abc
-ab\{0,1\}c b abcac abc
-ab{0,3}c - abbcac abbc
-ab\{0,3\}c b abbcac abbc
-ab{1,1}c - acabc abc
-ab\{1,1\}c b acabc abc
-ab{1,3}c - acabc abc
-ab\{1,3\}c b acabc abc
-ab{2,2}c - abcabbc abbc
-ab\{2,2\}c b abcabbc abbc
-ab{2,4}c - abcabbc abbc
-ab\{2,4\}c b abcabbc abbc
-((a{1,10}){1,10}){1,10} - a a a,a
-
-# multiple repetitions
-a** &C BADRPT
-a++ C BADRPT
-a?? C BADRPT
-a*+ C BADRPT
-a*? C BADRPT
-a+* C BADRPT
-a+? C BADRPT
-a?* C BADRPT
-a?+ C BADRPT
-a{1}{1} C BADRPT
-a*{1} C BADRPT
-a+{1} C BADRPT
-a?{1} C BADRPT
-a{1}* C BADRPT
-a{1}+ C BADRPT
-a{1}? C BADRPT
-a*{b} - a{b} a{b}
-a\{1\}\{1\} bC BADRPT
-a*\{1\} bC BADRPT
-a\{1\}* bC BADRPT
-
-# brackets, and numerous perversions thereof
-a[b]c & abc abc
-a[ab]c & abc abc
-a[^ab]c & adc adc
-a[]b]c & a]c a]c
-a[[b]c & a[c a[c
-a[-b]c & a-c a-c
-a[^]b]c & adc adc
-a[^-b]c & adc adc
-a[b-]c & a-c a-c
-a[b &C EBRACK
-a[] &C EBRACK
-a[1-3]c & a2c a2c
-a[3-1]c &C ERANGE
-a[1-3-5]c &C ERANGE
-a[[.-.]--]c & a-c a-c
-a[1- &C ERANGE
-a[[. &C EBRACK
-a[[.x &C EBRACK
-a[[.x. &C EBRACK
-a[[.x.] &C EBRACK
-a[[.x.]] & ax ax
-a[[.x,.]] &C ECOLLATE
-a[[.one.]]b & a1b a1b
-a[[.notdef.]]b &C ECOLLATE
-a[[.].]]b & a]b a]b
-a[[:alpha:]]c & abc abc
-a[[:notdef:]]c &C ECTYPE
-a[[: &C EBRACK
-a[[:alpha &C EBRACK
-a[[:alpha:] &C EBRACK
-a[[:alpha,:] &C ECTYPE
-a[[:]:]]b &C ECTYPE
-a[[:-:]]b &C ECTYPE
-a[[:alph:]] &C ECTYPE
-a[[:alphabet:]] &C ECTYPE
-[[:alnum:]]+ - -%@a0X- a0X
-[[:alpha:]]+ - -%@aX0- aX
-[[:blank:]]+ - aSSTb SST
-[[:cntrl:]]+ - aNTb NT
-[[:digit:]]+ - a019b 019
-[[:graph:]]+ - Sa%bS a%b
-[[:lower:]]+ - AabC ab
-[[:print:]]+ - NaSbN aSb
-[[:punct:]]+ - S%-&T %-&
-[[:space:]]+ - aSNTb SNT
-[[:upper:]]+ - aBCd BC
-[[:xdigit:]]+ - p0f3Cq 0f3C
-a[[=b=]]c & abc abc
-a[[= &C EBRACK
-a[[=b &C EBRACK
-a[[=b= &C EBRACK
-a[[=b=] &C EBRACK
-a[[=b,=]] &C ECOLLATE
-a[[=one=]]b & a1b a1b
-
-# complexities
-a(((b)))c - abc abc
-a(b|(c))d - abd abd
-a(b*|c)d - abbd abbd
-# just gotta have one DFA-buster, of course
-a[ab]{20} - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab
-# and an inline expansion in case somebody gets tricky
-a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab] - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab
-# and in case somebody just slips in an NFA...
-a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night) - aaaaabaaaabaaaabaaaabweeknights aaaaabaaaabaaaabaaaabweeknights
-# fish for anomalies as the number of states passes 32
-12345678901234567890123456789 - a12345678901234567890123456789b 12345678901234567890123456789
-123456789012345678901234567890 - a123456789012345678901234567890b 123456789012345678901234567890
-1234567890123456789012345678901 - a1234567890123456789012345678901b 1234567890123456789012345678901
-12345678901234567890123456789012 - a12345678901234567890123456789012b 12345678901234567890123456789012
-123456789012345678901234567890123 - a123456789012345678901234567890123b 123456789012345678901234567890123
-# and one really big one, beyond any plausible word width
-1234567890123456789012345678901234567890123456789012345678901234567890 - a1234567890123456789012345678901234567890123456789012345678901234567890b 1234567890123456789012345678901234567890123456789012345678901234567890
-# fish for problems as brackets go past 8
-[ab][cd][ef][gh][ij][kl][mn] - xacegikmoq acegikm
-[ab][cd][ef][gh][ij][kl][mn][op] - xacegikmoq acegikmo
-[ab][cd][ef][gh][ij][kl][mn][op][qr] - xacegikmoqy acegikmoq
-[ab][cd][ef][gh][ij][kl][mn][op][q] - xacegikmoqy acegikmoq
-
-# subtleties of matching
-abc & xabcy abc
-a\(b\)?c\1d b acd
-aBc i Abc Abc
-a[Bc]*d i abBCcd abBCcd
-0[[:upper:]]1 &i 0a1 0a1
-0[[:lower:]]1 &i 0A1 0A1
-a[^b]c &i abc
-a[^b]c &i aBc
-a[^b]c &i adc adc
-[a]b[c] - abc abc
-[a]b[a] - aba aba
-[abc]b[abc] - abc abc
-[abc]b[abd] - abd abd
-a(b?c)+d - accd accd
-(wee|week)(knights|night) - weeknights weeknights
-(we|wee|week|frob)(knights|night|day) - weeknights weeknights
-a[bc]d - xyzaaabcaababdacd abd
-a[ab]c - aaabc abc
-abc s abc abc
-a* & b @b
-
-# Let's have some fun -- try to match a C comment.
-# first the obvious, which looks okay at first glance...
-/\*.*\*/ - /*x*/ /*x*/
-# but...
-/\*.*\*/ - /*x*/y/*z*/ /*x*/y/*z*/
-# okay, we must not match */ inside; try to do that...
-/\*([^*]|\*[^/])*\*/ - /*x*/ /*x*/
-/\*([^*]|\*[^/])*\*/ - /*x*/y/*z*/ /*x*/
-# but...
-/\*([^*]|\*[^/])*\*/ - /*x**/y/*z*/ /*x**/y/*z*/
-# and a still fancier version, which does it right (I think)...
-/\*([^*]|\*+[^*/])*\*+/ - /*x*/ /*x*/
-/\*([^*]|\*+[^*/])*\*+/ - /*x*/y/*z*/ /*x*/
-/\*([^*]|\*+[^*/])*\*+/ - /*x**/y/*z*/ /*x**/
-/\*([^*]|\*+[^*/])*\*+/ - /*x****/y/*z*/ /*x****/
-/\*([^*]|\*+[^*/])*\*+/ - /*x**x*/y/*z*/ /*x**x*/
-/\*([^*]|\*+[^*/])*\*+/ - /*x***x/y/*z*/ /*x***x/y/*z*/
-
-# subexpressions
-a(b)(c)d - abcd abcd b,c
-a(((b)))c - abc abc b,b,b
-a(b|(c))d - abd abd b,-
-a(b*|c|e)d - abbd abbd bb
-a(b*|c|e)d - acd acd c
-a(b*|c|e)d - ad ad @d
-a(b?)c - abc abc b
-a(b?)c - ac ac @c
-a(b+)c - abc abc b
-a(b+)c - abbbc abbbc bbb
-a(b*)c - ac ac @c
-(a|ab)(bc([de]+)f|cde) - abcdef abcdef a,bcdef,de
-# the regression tester only asks for 9 subexpressions
-a(b)(c)(d)(e)(f)(g)(h)(i)(j)k - abcdefghijk abcdefghijk b,c,d,e,f,g,h,i,j
-a(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)l - abcdefghijkl abcdefghijkl b,c,d,e,f,g,h,i,j,k
-a([bc]?)c - abc abc b
-a([bc]?)c - ac ac @c
-a([bc]+)c - abc abc b
-a([bc]+)c - abcc abcc bc
-a([bc]+)bc - abcbc abcbc bc
-a(bb+|b)b - abb abb b
-a(bbb+|bb+|b)b - abb abb b
-a(bbb+|bb+|b)b - abbb abbb bb
-a(bbb+|bb+|b)bb - abbb abbb b
-(.*).* - abcdef abcdef abcdef
-(a*)* - bc @b @b
-
-# do we get the right subexpression when it is used more than once?
-a(b|c)*d - ad ad -
-a(b|c)*d - abcd abcd c
-a(b|c)+d - abd abd b
-a(b|c)+d - abcd abcd c
-a(b|c?)+d - ad ad @d
-a(b|c?)+d - abcd abcd @d
-a(b|c){0,0}d - ad ad -
-a(b|c){0,1}d - ad ad -
-a(b|c){0,1}d - abd abd b
-a(b|c){0,2}d - ad ad -
-a(b|c){0,2}d - abcd abcd c
-a(b|c){0,}d - ad ad -
-a(b|c){0,}d - abcd abcd c
-a(b|c){1,1}d - abd abd b
-a(b|c){1,1}d - acd acd c
-a(b|c){1,2}d - abd abd b
-a(b|c){1,2}d - abcd abcd c
-a(b|c){1,}d - abd abd b
-a(b|c){1,}d - abcd abcd c
-a(b|c){2,2}d - acbd acbd b
-a(b|c){2,2}d - abcd abcd c
-a(b|c){2,4}d - abcd abcd c
-a(b|c){2,4}d - abcbd abcbd b
-a(b|c){2,4}d - abcbcd abcbcd c
-a(b|c){2,}d - abcd abcd c
-a(b|c){2,}d - abcbd abcbd b
-a(b+|((c)*))+d - abd abd @d,@d,-
-a(b+|((c)*))+d - abcd abcd @d,@d,-
-
-# check out the STARTEND option
-[abc] &# a(b)c b
-[abc] &# a(d)c
-[abc] &# a(bc)d b
-[abc] &# a(dc)d c
-. &# a()c
-b.*c &# b(bc)c bc
-b.* &# b(bc)c bc
-.*c &# b(bc)c bc
-
-# plain strings, with the NOSPEC flag
-abc m abc abc
-abc m xabcy abc
-abc m xyz
-a*b m aba*b a*b
-a*b m ab
-"" mC EMPTY
-
-# cases involving NULs
-aZb & a a
-aZb &p a
-aZb &p# (aZb) aZb
-aZ*b &p# (ab) ab
-a.b &# (aZb) aZb
-a.* &# (aZb)c aZb
-
-# word boundaries (ick)
-[[:<:]]a & a a
-[[:<:]]a & ba
-[[:<:]]a & -a a
-a[[:>:]] & a a
-a[[:>:]] & ab
-a[[:>:]] & a- a
-[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc abc
-[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc-q abc
-[[:<:]]a.c[[:>:]] & axc-dayc-dazce-abc axc
-[[:<:]]b.c[[:>:]] & a_bxc-byc_d-bzc-q bzc
-[[:<:]].x..[[:>:]] & y_xa_-_xb_y-_xc_-axdc _xc_
-[[:<:]]a_b[[:>:]] & x_a_b
-
-# past problems, and suspected problems
-(A[1])|(A[2])|(A[3])|(A[4])|(A[5])|(A[6])|(A[7])|(A[8])|(A[9])|(A[A]) - A1 A1
-abcdefghijklmnop i abcdefghijklmnop abcdefghijklmnop
-abcdefghijklmnopqrstuv i abcdefghijklmnopqrstuv abcdefghijklmnopqrstuv
-(ALAK)|(ALT[AB])|(CC[123]1)|(CM[123]1)|(GAMC)|(LC[23][EO ])|(SEM[1234])|(SL[ES][12])|(SLWW)|(SLF )|(SLDT)|(VWH[12])|(WH[34][EW])|(WP1[ESN]) - CC11 CC11
-CC[13]1|a{21}[23][EO][123][Es][12]a{15}aa[34][EW]aaaaaaa[X]a - CC11 CC11
-Char \([a-z0-9_]*\)\[.* b Char xyz[k Char xyz[k xyz
-a?b - ab ab
--\{0,1\}[0-9]*$ b -5 -5
diff --git a/ext/ereg/regex/utils.h b/ext/ereg/regex/utils.h
deleted file mode 100644
index f271f759b1..0000000000
--- a/ext/ereg/regex/utils.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* utility definitions */
-#ifndef _POSIX2_RE_DUP_MAX
-#define _POSIX2_RE_DUP_MAX 255
-#endif
-
-#define DUPMAX _POSIX2_RE_DUP_MAX /* xxx is this right? */
-#define INFINITY (DUPMAX + 1)
-#define NC (CHAR_MAX - CHAR_MIN + 1)
-typedef unsigned char uch;
-
-/* switch off assertions (if not already off) if no REDEBUG */
-#ifndef REDEBUG
-#ifndef NDEBUG
-#define NDEBUG /* no assertions please */
-#endif
-#endif
-#include <assert.h>
-
-/* for old systems with bcopy() but no memmove() */
-#ifdef USEBCOPY
-#define memmove(d, s, c) bcopy(s, d, c)
-#endif
diff --git a/ext/ext_skel b/ext/ext_skel
deleted file mode 100755
index 30ea4fafd9..0000000000
--- a/ext/ext_skel
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/bin/sh
-
-extname="$1"
-EXTNAME=`echo $1|tr a-z A-Z`
-
-function givup() {
- echo $*
- exit 1
-}
-
-if test "$extname" = ""; then
- givup "usage: $0 extension-name"
-fi
-
-if test -d "$extname" ; then
- givup "Directory $extname already exists."
-fi
-
-echo "Creating directory"
-
-mkdir $extname || givup "Cannot create directory $extname"
-
-cd $extname
-chmod 755 .
-
-echo -n "Creating basic files:"
-
-echo -n " config.m4"
-cat >config.m4 <<eof
-dnl \$Id\$
-dnl config.m4 for extension $extname
-dnl don't forget to call PHP_EXTENSION($extname)
-
-eof
-
-echo -n " setup.stub"
-cat >setup.stub <<eof
-# \$Source\$
-# \$Id\$
-
-define_option with-$extname '$extname support?' yesnodir no \\
-' Whether to build the $extname extension.'
-
-eof
-
-echo -n " Makefile.am"
-cat >Makefile.am <<eof
-# \$Id\$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_$extname.a
-libphpext_${extname}_a_SOURCES=$extname.c
-
-eof
-
-
-echo -n " .cvsignore"
-cat >.cvsignore <<eof
-.deps
-Makefile.in
-Makefile
-eof
-
-echo -n " config.h.stub"
-cat >config.h.stub<<eof
-/* define if you want to use the $extname extension */
-/* #undef HAVE_LIB$EXTNAME */
-eof
-
-chmod 644 *
-
-echo " [done]."
-
diff --git a/ext/fdf/Makefile.am b/ext/fdf/Makefile.am
deleted file mode 100644
index 91e9efef83..0000000000
--- a/ext/fdf/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_fdf.a
-libphpext_fdf_a_SOURCES=fdf.c
-
diff --git a/ext/fdf/config.h.stub b/ext/fdf/config.h.stub
deleted file mode 100644
index de2cdd917d..0000000000
--- a/ext/fdf/config.h.stub
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Define if you have the fdftk library */
-#define HAVE_FDFLIB 0
diff --git a/ext/fdf/config.m4 b/ext/fdf/config.m4
deleted file mode 100644
index ba1d6f7dd2..0000000000
--- a/ext/fdf/config.m4
+++ /dev/null
@@ -1,39 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(whether to include fdftk support)
-AC_ARG_WITH(fdftk,
-[ --with-fdftk[=DIR] Include fdftk support.
- DIR is the fdftk lib install directory,
- defaults to /usr/local.],
-[
- case "$withval" in
- no)
- AC_MSG_RESULT(no) ;;
- yes)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(fdf)
- AC_CHECK_LIB(FdfTk, FDFOpen, [
- AC_DEFINE(HAVE_FDFLIB)
- EXTRA_LIBS="$EXTRA_LIBS -lFdfTk"
- ],[AC_MSG_ERROR(fdftk module requires fdftk 2.0)])
- ;;
- *)
- test -f $withval/include/Fdftk.h && FDFLIB_INCLUDE="-I$withval/include"
- if test -n "$FDFLIB_INCLUDE" ; then
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(fdf)
- old_LIBS=$LIBS
- LIBS="$LIBS -L$withval/lib"
- AC_CHECK_LIB(FdfTk, FDFOpen, [
- AC_DEFINE(HAVE_FDFLIB)
- EXTRA_LIBS="$EXTRA_LIBS -L$withval/lib -lFdfTk"
- ],[AC_MSG_ERROR(fdftk module requires ftftk lib 2.0.)])
- LIBS=$old_LIBS
- INCLUDES="$INCLUDES $FDFLIB_INCLUDE"
- else
- AC_MSG_RESULT(no)
- fi ;;
- esac
-],[
- AC_MSG_RESULT(no)
-])
diff --git a/ext/fdf/fdf.c b/ext/fdf/fdf.c
deleted file mode 100644
index 6417ce1789..0000000000
--- a/ext/fdf/fdf.c
+++ /dev/null
@@ -1,570 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Uwe Steinmann <Uwe.Steinmann@fernuni-hagen.de> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/* FdfTk lib 2.0 is a Complete C/C++ FDF Toolkit available from
- http://beta1.adobe.com/ada/acrosdk/forms.html. */
-
-/* Note that there is no code from the FdfTk lib in this file */
-
-#if !PHP_31 && defined(THREAD_SAFE)
-#undef THREAD_SAFE
-#endif
-
-#include "php.h"
-#include "ext/standard/head.h"
-#include <math.h>
-#include "php3_fdf.h"
-
-#if HAVE_SYS_WAIT_H
-# include <sys/wait.h>
-#endif
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#if WIN32|WINNT
-# include <io.h>
-# include <fcntl.h>
-#endif
-
-#if HAVE_FDFLIB
-
-#ifdef THREAD_SAFE
-DWORD FDFlibTls;
-static int numthreads=0;
-
-typedef struct fdflib_global_struct{
- int le_fdf;
-} fdflib_global_struct;
-
-# define FDF_GLOBAL(a) fdflib_globals->a
-# define FDF_TLS_VARS fdflib_global_struct *fdflib_globals=TlsGetValue(FDFlibTls)
-
-#else
-# define FDF_GLOBAL(a) a
-# define FDF_TLS_VARS
-int le_fdf_info;
-int le_fdf;
-#endif
-
-function_entry fdf_functions[] = {
- PHP_FE(fdf_open, NULL)
- PHP_FE(fdf_create, NULL)
- PHP_FE(fdf_close, NULL)
- PHP_FE(fdf_save, NULL)
- PHP_FE(fdf_get_value, NULL)
- PHP_FE(fdf_set_value, NULL)
- PHP_FE(fdf_next_field_name, NULL)
- PHP_FE(fdf_set_ap, NULL)
- PHP_FE(fdf_set_status, NULL)
- PHP_FE(fdf_get_status, NULL)
- PHP_FE(fdf_set_file, NULL)
- PHP_FE(fdf_get_file, NULL)
- PHP_FE(fdf_add_template, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry fdf_module_entry = {
- "fdf", fdf_functions, PHP_MINIT(fdf), PHP_MSHUTDOWN(fdf), NULL, NULL,
- PHP_MINFO(fdf), STANDARD_MODULE_PROPERTIES
-};
-
-#if COMPILE_DL
-#include "dl/phpdl.h"
-DLEXPORT php3_module_entry *get_module(void) { return &fdf_module_entry; }
-#endif
-
-static void phpi_FDFClose(FDFDoc fdf) {
- (void)FDFClose(fdf);
-}
-
-PHP_MINIT_FUNCTION(fdf)
-{
- FDFErc err;
- FDF_GLOBAL(le_fdf) = register_list_destructors(phpi_FDFClose, NULL);
- err = FDFInitialize();
- if(err == FDFErcOK)
- return SUCCESS;
- return FAILURE;
-}
-
-PHP_MINFO_FUNCTION(fdf)
-{
- /* need to use a PHPAPI function here because it is external module in windows */
- php_printf("FdfTk Version %s", FDFGetVersion());
-}
-
-PHP_MSHUTDOWN_FUNCTION(fdf)
-{
- FDFErc err;
- err = FDFFinalize();
- if(err == FDFErcOK)
- return SUCCESS;
- return FAILURE;
-}
-
-/* {{{ proto int fdf_open(string filename)
- Opens a new fdf document */
-PHP_FUNCTION(fdf_open) {
- pval *file;
- int id, type;
- FDFDoc fdf;
- FDFErc err;
- FDF_TLS_VARS;
-
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &file) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(file);
-
- err = FDFOpen(file->value.str.val, 0, &fdf);
- if(err != FDFErcOK)
- printf("Aiii, error\n");
- if(!fdf)
- RETURN_FALSE;
-
- id = php3_list_insert(fdf,FDF_GLOBAL(le_fdf));
- RETURN_LONG(id);
-} /* }}} */
-
-/* {{{ proto void fdf_close(int fdfdoc)
- Closes the fdf document */
-PHP_FUNCTION(fdf_close) {
- pval *arg1;
- int id, type;
- FDFDoc fdf;
- FDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- fdf = php3_list_find(id,&type);
- if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
-/* FDFClose(fdf); */
- php3_list_delete(id);
-
- RETURN_TRUE;
-} /* }}} */
-
-/* {{{ proto void fdf_create(void)
- Creates a new fdf document */
-PHP_FUNCTION(fdf_create) {
- int id, type;
- FDFDoc fdf;
- FDFErc err;
- FDF_TLS_VARS;
-
- err = FDFCreate(&fdf);
- if(err != FDFErcOK)
- printf("Aiii, error\n");
- if(!fdf)
- RETURN_FALSE;
-
- id = php3_list_insert(fdf,FDF_GLOBAL(le_fdf));
- RETURN_LONG(id);
-}
-/* }}} */
-
-/* {{{ proto void fdf_get_value(int fdfdoc, string fieldname)
- Gets the value of a field as string */
-PHP_FUNCTION(fdf_get_value) {
- pval *arg1, *arg2;
- int id, type;
- ASInt32 nr;
- char *buffer;
- FDFDoc fdf;
- FDFErc err;
- FDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- id=arg1->value.lval;
- fdf = php3_list_find(id,&type);
- if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- err = FDFGetValue(fdf, arg2->value.str.val, NULL, 0, &nr);
- if(err != FDFErcOK)
- printf("Aiii, error\n");
- buffer = emalloc(nr);
- err = FDFGetValue(fdf, arg2->value.str.val, buffer, nr, &nr);
- if(err != FDFErcOK)
- printf("Aiii, error\n");
-
- RETURN_STRING(buffer, 0);
-}
-/* }}} */
-
-/* {{{ proto void fdf_set_value(int fdfdoc, string fieldname, string value, int isName)
- Sets the value of a field */
-PHP_FUNCTION(fdf_set_value) {
- pval *arg1, *arg2, *arg3, *arg4;
- int id, type;
- FDFDoc fdf;
- FDFErc err;
- FDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- convert_to_string(arg3);
- convert_to_long(arg4);
- id=arg1->value.lval;
- fdf = php3_list_find(id,&type);
- if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- err = FDFSetValue(fdf, arg2->value.str.val, arg3->value.str.val, (ASBool) arg4->value.lval);
- if(err != FDFErcOK)
- printf("Aiii, error\n");
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void fdf_next_field_name(int fdfdoc [, string fieldname])
- Gets the name of the next field name or the first field name */
-PHP_FUNCTION(fdf_next_field_name) {
- pval *argv[2];
- int id, type, argc;
- ASInt32 nr;
- char *buffer, *fieldname;
- FDFDoc fdf;
- FDFErc err;
- FDF_TLS_VARS;
-
- argc = ARG_COUNT(ht);
- if((argc > 2) || (argc < 1))
- WRONG_PARAM_COUNT;
-
- if (getParametersArray(ht, argc, argv) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(argv[0]);
- if(argc == 2) {
- convert_to_string(argv[1]);
- fieldname = argv[1]->value.str.val;
- } else {
- fieldname = NULL;
- }
- id=argv[0]->value.lval;
- fdf = php3_list_find(id,&type);
- if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- err = FDFNextFieldName(fdf, fieldname, NULL, 0, &nr);
- if(err != FDFErcOK)
- printf("Aiii, error\n");
- if(nr == 0)
- RETURN_STRING(empty_string, 1);
-
- buffer = emalloc(nr);
- err = FDFNextFieldName(fdf, fieldname, buffer, nr, &nr);
- if(err != FDFErcOK)
- printf("Aiii, error\n");
-
- RETURN_STRING(buffer, 0);
-}
-/* }}} */
-
-/* {{{ proto void fdf_set_ap(int fdfdoc, string fieldname, int face, string filename, int pagenr)
- Sets the value of a field */
-PHP_FUNCTION(fdf_set_ap) {
- pval *arg1, *arg2, *arg3, *arg4, *arg5;
- int id, type;
- FDFDoc fdf;
- FDFErc err;
- FDFAppFace face;
- FDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 5 || getParameters(ht, 5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- convert_to_long(arg3);
- convert_to_string(arg4);
- convert_to_long(arg5);
- id=arg1->value.lval;
- fdf = php3_list_find(id,&type);
- if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- switch(arg3->value.lval) {
- case 1:
- face = FDFNormalAP;
- break;
- case 2:
- face = FDFRolloverAP;
- break;
- case 3:
- face = FDFDownAP;
- break;
- default:
- face = FDFNormalAP;
- }
-
- err = FDFSetAP(fdf, arg2->value.str.val, face, NULL, arg4->value.str.val, (ASInt32) arg5->value.lval);
- if(err != FDFErcOK)
- printf("Aiii, error\n");
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void fdf_set_status(int fdfdoc, string status)
- Sets the value in the /Status key. */
-PHP_FUNCTION(fdf_set_status) {
- pval *arg1, *arg2;
- int id, type;
- ASInt32 nr;
- FDFDoc fdf;
- FDFErc err;
- FDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- id=arg1->value.lval;
- fdf = php3_list_find(id,&type);
- if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- err = FDFSetStatus(fdf, arg2->value.str.val);
- if(err != FDFErcOK)
- printf("Aiii, error\n");
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void fdf_get_status(int fdfdoc)
- Gets the value in the /Status key. */
-PHP_FUNCTION(fdf_get_status) {
- pval *arg1;
- int id, type;
- ASInt32 nr;
- char *buf;
- FDFDoc fdf;
- FDFErc err;
- FDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- fdf = php3_list_find(id,&type);
- if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- err = FDFGetStatus(fdf, NULL, 0, &nr);
- if(err != FDFErcOK)
- printf("Aiii, error\n");
- if(nr == 0)
- RETURN_STRING(empty_string, 1);
- buf = emalloc(nr);
- err = FDFGetStatus(fdf, buf, nr, &nr);
- if(err != FDFErcOK)
- printf("Aiii, error\n");
-
- RETURN_STRING(buf, 0);
-}
-/* }}} */
-
-/* {{{ proto void fdf_set_file(int fdfdoc, string filename)
- Sets the value of the FDF's /F key */
-PHP_FUNCTION(fdf_set_file) {
- pval *arg1, *arg2;
- int id, type;
- FDFDoc fdf;
- FDFErc err;
- FDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- id=arg1->value.lval;
- fdf = php3_list_find(id,&type);
- if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- err = FDFSetFile(fdf, arg2->value.str.val);
- if(err != FDFErcOK)
- printf("Aiii, error\n");
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void fdf_get_file(int fdfdoc)
- Gets the value in the /F key. */
-PHP_FUNCTION(fdf_get_file) {
- pval *arg1;
- int id, type;
- ASInt32 nr;
- char *buf;
- FDFDoc fdf;
- FDFErc err;
- FDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- fdf = php3_list_find(id,&type);
- if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- err = FDFGetFile(fdf, NULL, 0, &nr);
- if(err != FDFErcOK)
- printf("Aiii, error\n");
- if(nr == 0)
- RETURN_STRING(empty_string, 1);
- buf = emalloc(nr);
- err = FDFGetFile(fdf, buf, nr, &nr);
- if(err != FDFErcOK)
- printf("Aiii, error\n");
-
- RETURN_STRING(buf, 0);
-}
-/* }}} */
-
-/* {{{ proto void fdf_save(int fdfdoc, string filename)
- Writes out an FDF file. */
-PHP_FUNCTION(fdf_save) {
- pval *arg1, *arg2;
- int id, type;
- FDFDoc fdf;
- FDFErc err;
- FDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- id=arg1->value.lval;
- fdf = php3_list_find(id,&type);
- if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- err = FDFSave(fdf, arg2->value.str.val);
- if(err != FDFErcOK)
- printf("Aiii, error\n");
-
- RETURN_TRUE;
-} /* }}} */
-
-/* {{{ proto void fdf_add_template(int fdfdoc, int newpage, string filename, string template, int rename)
- Adds a template to the FDF*/
-PHP_FUNCTION(fdf_add_template) {
- pval *arg1, *arg2, *arg3, *arg4, *arg5;
- int id, type;
- FDFDoc fdf;
- FDFErc err;
- pdfFileSpecRec filespec;
- FDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 5 || getParameters(ht, 5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_long(arg2);
- convert_to_string(arg3);
- convert_to_string(arg4);
- convert_to_long(arg5);
- id=arg1->value.lval;
- fdf = php3_list_find(id,&type);
- if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- filespec.FS = NULL;
- filespec.F = arg3->value.str.val;
- filespec.Mac = NULL;
- filespec.DOS = NULL;
- filespec.Unix = NULL;
- filespec.ID[0] = NULL;
- filespec.ID[1] = NULL;
- filespec.bVolatile = false;
- err = FDFAddTemplate(fdf, arg2->value.lval, &filespec, arg4->value.str.val, arg5->value.lval);
- if(err != FDFErcOK)
- printf("Aiii, error\n");
-
- RETURN_TRUE;
-}
-/* }}} */
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/fdf/php3_fdf.h b/ext/fdf/php3_fdf.h
deleted file mode 100644
index dd8a560839..0000000000
--- a/ext/fdf/php3_fdf.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Uwe Steinmann |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#ifndef _PHP3_FDF_H
-#define _PHP3_FDF_H
-
-#if HAVE_FDFLIB
-#if WIN32|WINNT
-#else
-#define UNIX_DEV
-#endif
-
-#include <FdfTk.h>
-
-extern php3_module_entry fdf_module_entry;
-#define phpext_fdf_ptr &fdf_module_entry
-
-extern PHP_MINIT_FUNCTION(fdf);
-extern PHP_MSHUTDOWN_FUNCTION(fdf);
-PHP_MINFO_FUNCTION(fdf);
-
-PHP_FUNCTION(fdf_open);
-PHP_FUNCTION(fdf_close);
-PHP_FUNCTION(fdf_create);
-PHP_FUNCTION(fdf_save);
-PHP_FUNCTION(fdf_get_value);
-PHP_FUNCTION(fdf_set_value);
-PHP_FUNCTION(fdf_next_field_name);
-PHP_FUNCTION(fdf_set_ap);
-PHP_FUNCTION(fdf_get_status);
-PHP_FUNCTION(fdf_set_status);
-PHP_FUNCTION(fdf_set_file);
-PHP_FUNCTION(fdf_get_file);
-PHP_FUNCTION(fdf_add_template);
-#else
-#define phpext_fdf_ptr NULL
-#endif
-#endif /* _PHP3_FDF_H */
diff --git a/ext/fdf/setup.stub b/ext/fdf/setup.stub
deleted file mode 100644
index 9637713bde..0000000000
--- a/ext/fdf/setup.stub
+++ /dev/null
@@ -1,7 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-fdftk 'Acrobat Forms (Ftf Toolkit 2.0) support? ' yesnodir \
- 'no /usr/local ftktk install' \
-' Whether to use the Ftf Toolkit support to write/read .fdf-files.\n
- Tested for version 2.0!'
diff --git a/ext/filepro/Makefile.am b/ext/filepro/Makefile.am
deleted file mode 100644
index ff539050be..0000000000
--- a/ext/filepro/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_filepro.a
-libphpext_filepro_a_SOURCES=filepro.c
-
diff --git a/ext/filepro/config.h.stub b/ext/filepro/config.h.stub
deleted file mode 100644
index 0a273b1502..0000000000
--- a/ext/filepro/config.h.stub
+++ /dev/null
@@ -1,2 +0,0 @@
-#define HAVE_FILEPRO 0
-
diff --git a/ext/filepro/config.m4 b/ext/filepro/config.m4
deleted file mode 100644
index 2c0fd3b43b..0000000000
--- a/ext/filepro/config.m4
+++ /dev/null
@@ -1,17 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(whether to include the bundled filePro support)
-AC_ARG_WITH(filepro,
-[ --with-filepro Include the bundled read-only filePro support],[
- if test "$withval" != "no"; then
- AC_DEFINE(HAVE_FILEPRO, 1)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(filepro)
- else
- AC_DEFINE(HAVE_FILEPRO, 0)
- AC_MSG_RESULT(no)
- fi
-],[
- AC_DEFINE(HAVE_FILEPRO, 0)
- AC_MSG_RESULT(no)
-])
diff --git a/ext/filepro/filepro.c b/ext/filepro/filepro.c
deleted file mode 100644
index 83a63e8f3e..0000000000
--- a/ext/filepro/filepro.c
+++ /dev/null
@@ -1,540 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Chad Robinson <chadr@brttech.com> |
- +----------------------------------------------------------------------+
-
- filePro 4.x support developed by Chad Robinson, chadr@brttech.com
- Contact Chad Robinson at BRT Technical Services Corp. for details.
- filePro is a registered trademark by Fiserv, Inc. This file contains
- no code or information that is not freely available from the filePro
- web site at http://www.fileproplus.com/
-
- */
-
-#include "php.h"
-#include "safe_mode.h"
-#include "fopen-wrappers.h"
-#include <string.h>
-#if MSVC5
-#include <windows.h>
-#else
-#include <sys/param.h>
-#endif
-#include <errno.h>
-#include "php_globals.h"
-
-#include "php_filepro.h"
-#if HAVE_FILEPRO
-
-typedef struct fp_field {
- char *name;
- char *format;
- int width;
- struct fp_field *next;
-} FP_FIELD;
-
-#ifdef THREAD_SAFE
-DWORD FPTls;
-static int numthreads=0;
-
-typedef struct fp_global_struct{
- char *fp_database;
- signed int fp_fcount;
- signed int fp_keysize;
- FP_FIELD *fp_fieldlist;
-}fp_global_struct;
-
-#define FP_GLOBAL(a) fp_globals->a
-
-#define FP_TLS_VARS \
- fp_global_struct *fp_globals; \
- fp_globals=TlsGetValue(FPTls);
-
-#else
-#define FP_GLOBAL(a) a
-#define FP_TLS_VARS
-static char *fp_database = NULL; /* Database directory */
-static signed int fp_fcount = -1; /* Column count */
-static signed int fp_keysize = -1; /* Size of key records */
-static FP_FIELD *fp_fieldlist = NULL; /* List of fields */
-#endif
-
-
-PHP_MINIT_FUNCTION(filepro)
-{
-#ifdef THREAD_SAFE
- fp_global_struct *fp_globals;
-#if !COMPILE_DL
- CREATE_MUTEX(fp_mutex,"FP_TLS");
- SET_MUTEX(fp_mutex);
- numthreads++;
- if (numthreads==1){
- if ((FPTls=TlsAlloc())==0xFFFFFFFF){
- FREE_MUTEX(fp_mutex);
- return 0;
- }}
- FREE_MUTEX(fp_mutex);
-#endif
- fp_globals = (fp_global_struct *) LocalAlloc(LPTR, sizeof(fp_global_struct));
- TlsSetValue(FPTls, (void *) fp_globals);
-#endif
- FP_GLOBAL(fp_database)=NULL;
- FP_GLOBAL(fp_fcount)=-1;
- FP_GLOBAL(fp_keysize)=-1;
- FP_GLOBAL(fp_fieldlist)=NULL;
-
- return SUCCESS;
-}
-
-PHP_MSHUTDOWN_FUNCTION(filepro)
-{
-#ifdef THREAD_SAFE
- fp_global_struct *fp_globals;
- fp_globals = TlsGetValue(FPTls);
- if (fp_globals != 0)
- LocalFree((HLOCAL) fp_globals);
-#if !COMPILE_DL
- SET_MUTEX(fp_mutex);
- numthreads--;
- if (!numthreads){
- if (!TlsFree(FPTls)){
- FREE_MUTEX(fp_mutex);
- return 0;
- }}
- FREE_MUTEX(fp_mutex);
-#endif
-#endif
- return SUCCESS;
-}
-
-
-function_entry filepro_functions[] = {
- PHP_FE(filepro, NULL)
- PHP_FE(filepro_rowcount, NULL)
- PHP_FE(filepro_fieldname, NULL)
- PHP_FE(filepro_fieldtype, NULL)
- PHP_FE(filepro_fieldwidth, NULL)
- PHP_FE(filepro_fieldcount, NULL)
- PHP_FE(filepro_retrieve, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry filepro_module_entry = {
- "FilePro", filepro_functions, PHP_MINIT(filepro), PHP_MSHUTDOWN(filepro), NULL, NULL, NULL, STANDARD_MODULE_PROPERTIES
-};
-
-
-#if COMPILE_DL
-#include "dl/phpdl.h"
-DLEXPORT php3_module_entry *get_module(void) { return &filepro_module_entry; }
-#if (WIN32|WINNT) && defined(THREAD_SAFE)
-
-/*NOTE: You should have an odbc.def file where you
-export DllMain*/
-BOOL WINAPI DllMain(HANDLE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved)
-{
- switch( ul_reason_for_call ) {
- case DLL_PROCESS_ATTACH:
- if ((FPTls=TlsAlloc())==0xFFFFFFFF){
- return 0;
- }
- break;
- case DLL_THREAD_ATTACH:
- break;
- case DLL_THREAD_DETACH:
- break;
- case DLL_PROCESS_DETACH:
- if (!TlsFree(FPTls)){
- return 0;
- }
- break;
- }
- return 1;
-}
-#endif
-#endif
-
-/*
- * LONG filePro(STRING directory)
- *
- * Read and verify the map file. We store the field count and field info
- * internally, which means we become unstable if you modify the table while
- * a user is using it! We cannot lock anything since Web connections don't
- * provide the ability to later unlock what we locked. Be smart, be safe.
- */
-PHP_FUNCTION(filepro)
-{
- pval *dir;
- FILE *fp;
- char workbuf[256]; /* FIX - should really be the max filename length */
- char readbuf[256];
- int i;
- FP_FIELD *new_field, *tmp;
- FP_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &dir) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(dir);
-
- /* FIX - we should really check and free these if they are used! */
- FP_GLOBAL(fp_database) = NULL;
- FP_GLOBAL(fp_fieldlist) = NULL;
- FP_GLOBAL(fp_fcount) = -1;
- FP_GLOBAL(fp_keysize) = -1;
-
- sprintf(workbuf, "%s/map", dir->value.str.val);
-
- if (PG(safe_mode) && (!_php3_checkuid(workbuf, 2))) {
- RETURN_FALSE;
- }
-
- if (_php3_check_open_basedir(workbuf)) {
- RETURN_FALSE;
- }
-
- if (!(fp = fopen(workbuf, "r"))) {
- php_error(E_WARNING, "filePro: cannot open map: [%d] %s",
- errno, strerror(errno));
- RETURN_FALSE;
- }
- if (!fgets(readbuf, 250, fp)) {
- fclose(fp);
- php_error(E_WARNING, "filePro: cannot read map: [%d] %s",
- errno, strerror(errno));
- RETURN_FALSE;
- }
-
- /* Get the field count, assume the file is readable! */
- if (strcmp(strtok(readbuf, ":"), "map")) {
- php_error(E_WARNING, "filePro: map file corrupt or encrypted");
- RETURN_FALSE;
- }
- FP_GLOBAL(fp_keysize) = atoi(strtok(NULL, ":"));
- strtok(NULL, ":");
- FP_GLOBAL(fp_fcount) = atoi(strtok(NULL, ":"));
-
- /* Read in the fields themselves */
- for (i = 0; i < FP_GLOBAL(fp_fcount); i++) {
- if (!fgets(readbuf, 250, fp)) {
- fclose(fp);
- php_error(E_WARNING, "filePro: cannot read map: [%d] %s",
- errno, strerror(errno));
- RETURN_FALSE;
- }
- new_field = emalloc(sizeof(FP_FIELD));
- new_field->next = NULL;
- new_field->name = estrdup(strtok(readbuf, ":"));
- new_field->width = atoi(strtok(NULL, ":"));
- new_field->format = estrdup(strtok(NULL, ":"));
-
- /* Store in forward-order to save time later */
- if (!FP_GLOBAL(fp_fieldlist)) {
- FP_GLOBAL(fp_fieldlist) = new_field;
- } else {
- for (tmp = FP_GLOBAL(fp_fieldlist); tmp; tmp = tmp->next) {
- if (!tmp->next) {
- tmp->next = new_field;
- tmp = new_field;
- }
- }
- }
- }
- fclose(fp);
-
- FP_GLOBAL(fp_database) = estrndup(dir->value.str.val,dir->value.str.len);
-
- RETVAL_TRUE;
-}
-
-
-/*
- * LONG filePro_rowcount(void)
- *
- * Count the used rows in the database. filePro just marks deleted records
- * as deleted; they are not removed. Since no counts are maintained we need
- * to go in and count records ourselves. <sigh>
- *
- * Errors return false, success returns the row count.
- */
-PHP_FUNCTION(filepro_rowcount)
-{
- FILE *fp;
- char workbuf[MAXPATHLEN];
- char readbuf[256];
- int recsize = 0, records = 0;
- FP_TLS_VARS;
-
- if (ARG_COUNT(ht) != 0) {
- WRONG_PARAM_COUNT;
- }
-
- if (!FP_GLOBAL(fp_database)) {
- php_error(E_WARNING,
- "filePro: must set database directory first!\n");
- RETURN_FALSE;
- }
-
- recsize = FP_GLOBAL(fp_keysize) + 19; /* 20 bytes system info -1 to save time later */
-
- /* Now read the records in, moving forward recsize-1 bytes each time */
- sprintf(workbuf, "%s/key", FP_GLOBAL(fp_database));
-
- if (PG(safe_mode) && (!_php3_checkuid(workbuf, 2))) {
- RETURN_FALSE;
- }
-
- if (_php3_check_open_basedir(workbuf)) {
- RETURN_FALSE;
- }
-
- if (!(fp = fopen(workbuf, "r"))) {
- php_error(E_WARNING, "filePro: cannot open key: [%d] %s",
- errno, strerror(errno));
- RETURN_FALSE;
- }
- while (!feof(fp)) {
- if (fread(readbuf, 1, 1, fp) == 1) {
- if (readbuf[0])
- records++;
- fseek(fp, recsize, SEEK_CUR);
- }
- }
- fclose(fp);
-
- RETVAL_LONG(records);
-}
-
-
-/*
- * STRING filePro_fieldname(LONG field_number)
- *
- * Errors return false, success returns the name of the field.
- */
-PHP_FUNCTION(filepro_fieldname)
-{
- pval *fno;
- FP_FIELD *lp;
- int i;
- FP_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &fno) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(fno);
-
- if (!FP_GLOBAL(fp_database)) {
- php_error(E_WARNING,
- "filePro: must set database directory first!\n");
- RETURN_FALSE;
- }
-
- for (i = 0, lp = FP_GLOBAL(fp_fieldlist); lp; lp = lp->next, i++) {
- if (i == fno->value.lval) {
- RETURN_STRING(lp->name,1);
- }
- }
-
- php_error(E_WARNING,
- "filePro: unable to locate field number %d.\n",
- fno->value.lval);
-
- RETVAL_FALSE;
-}
-
-
-/*
- * STRING filePro_fieldtype(LONG field_number)
- *
- * Errors return false, success returns the type (edit) of the field
- */
-PHP_FUNCTION(filepro_fieldtype)
-{
- pval *fno;
- FP_FIELD *lp;
- int i;
- FP_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &fno) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(fno);
-
- if (!FP_GLOBAL(fp_database)) {
- php_error(E_WARNING,
- "filePro: must set database directory first!\n");
- RETURN_FALSE;
- }
-
- for (i = 0, lp = FP_GLOBAL(fp_fieldlist); lp; lp = lp->next, i++) {
- if (i == fno->value.lval) {
- RETURN_STRING(lp->format,1);
- }
- }
- php_error(E_WARNING,
- "filePro: unable to locate field number %d.\n",
- fno->value.lval);
- RETVAL_FALSE;
-}
-
-
-/*
- * STRING filePro_fieldwidth(int field_number)
- *
- * Errors return false, success returns the character width of the field.
- */
-PHP_FUNCTION(filepro_fieldwidth)
-{
- pval *fno;
- FP_FIELD *lp;
- int i;
- FP_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &fno) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(fno);
-
- if (!FP_GLOBAL(fp_database)) {
- php_error(E_WARNING,
- "filePro: must set database directory first!\n");
- RETURN_FALSE;
- }
-
- for (i = 0, lp = FP_GLOBAL(fp_fieldlist); lp; lp = lp->next, i++) {
- if (i == fno->value.lval) {
- RETURN_LONG(lp->width);
- }
- }
- php_error(E_WARNING,
- "filePro: unable to locate field number %d.\n",
- fno->value.lval);
- RETVAL_FALSE;
-}
-
-
-/*
- * LONG filePro_fieldcount(void)
- *
- * Errors return false, success returns the field count.
- */
-PHP_FUNCTION(filepro_fieldcount)
-{
- FP_TLS_VARS;
-
- if (ARG_COUNT(ht) != 0) {
- WRONG_PARAM_COUNT;
- }
-
- if (!FP_GLOBAL(fp_database)) {
- php_error(E_WARNING,
- "filePro: must set database directory first!\n");
- RETURN_FALSE;
- }
-
- /* Read in the first line from the map file */
- RETVAL_LONG(FP_GLOBAL(fp_fcount));
-}
-
-
-/*
- * STRING filePro_retrieve(int row_number, int field_number)
- *
- * Errors return false, success returns the datum.
- */
-PHP_FUNCTION(filepro_retrieve)
-{
- pval *rno, *fno;
- FP_FIELD *lp;
- FILE *fp;
- char workbuf[MAXPATHLEN];
- char readbuf[1024]; /* FIX - Work out better buffering! */
- int i, fnum, rnum;
- long offset;
- FP_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &rno, &fno) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (!FP_GLOBAL(fp_database)) {
- php_error(E_WARNING,
- "filePro: must set database directory first!\n");
- RETURN_FALSE;
- }
-
- convert_to_long(rno);
- convert_to_long(fno);
-
- fnum = fno->value.lval;
- rnum = rno->value.lval;
-
- if (rnum < 0 || fnum < 0 || fnum >= FP_GLOBAL(fp_fcount)) {
- php_error(E_WARNING, "filepro: parameters out of range");
- RETURN_FALSE;
- }
-
- offset = (rnum + 1) * (FP_GLOBAL(fp_keysize) + 20) + 20; /* Record location */
- for (i = 0, lp = FP_GLOBAL(fp_fieldlist); lp && i < fnum; lp = lp->next, i++) {
- offset += lp->width;
- }
- if (!lp) {
- php_error(E_WARNING, "filePro: cannot locate field");
- RETURN_FALSE;
- }
-
- /* Now read the record in */
- sprintf(workbuf, "%s/key", FP_GLOBAL(fp_database));
-
- if (PG(safe_mode) && (!_php3_checkuid(workbuf, 2))) {
- RETURN_FALSE;
- }
-
- if (_php3_check_open_basedir(workbuf)) {
- RETURN_FALSE;
- }
-
- if (!(fp = fopen(workbuf, "r"))) {
- php_error(E_WARNING, "filePro: cannot open key: [%d] %s",
- errno, strerror(errno));
- fclose(fp);
- RETURN_FALSE;
- }
- fseek(fp, offset, SEEK_SET);
- if (fread(readbuf, lp->width, 1, fp) != 1) {
- php_error(E_WARNING, "filePro: cannot read data: [%d] %s",
- errno, strerror(errno));
- fclose(fp);
- RETURN_FALSE;
- }
- readbuf[lp->width] = '\0';
- fclose(fp);
- RETURN_STRING(readbuf,1);
-}
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/filepro/php_filepro.h b/ext/filepro/php_filepro.h
deleted file mode 100644
index 850eeb8dcd..0000000000
--- a/ext/filepro/php_filepro.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Chad Robinson <chadr@brttech.com> |
- +----------------------------------------------------------------------+
-
- filePro 4.x support developed by Chad Robinson, chadr@brttech.com
- Contact Chad Robinson at BRT Technical Services Corp. for details.
- filePro is a registered trademark by Fiserv, Inc. This file contains
- no code or information that is not freely available from the filePro
- web site at http://www.fileproplus.com/
-
- */
-
-/* $Id$ */
-
-#ifndef _FILEPRO_H
-#define _FILEPRO_H
-#if HAVE_FILEPRO
-extern php3_module_entry filepro_module_entry;
-#define phpext_filepro_ptr &filepro_module_entry
-
-PHP_FUNCTION(filepro);
-PHP_FUNCTION(filepro_rowcount);
-PHP_FUNCTION(filepro_fieldname);
-PHP_FUNCTION(filepro_fieldtype);
-PHP_FUNCTION(filepro_fieldwidth);
-PHP_FUNCTION(filepro_fieldcount);
-PHP_FUNCTION(filepro_retrieve);
-
-extern PHP_MINIT_FUNCTION(filepro);
-extern PHP_MSHUTDOWN_FUNCTION(filepro);
-#else
-#define phpext_filepro_ptr NULL
-#endif
-#endif /* _FILEPRO_H */
diff --git a/ext/filepro/setup.stub b/ext/filepro/setup.stub
deleted file mode 100644
index 7107744f02..0000000000
--- a/ext/filepro/setup.stub
+++ /dev/null
@@ -1,5 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-filepro 'filePro support? ' yesno no \
-' Whether to use the bundled filePro library. Read-access only.'
diff --git a/ext/ftp/Makefile.am b/ext/ftp/Makefile.am
deleted file mode 100644
index ea032672b0..0000000000
--- a/ext/ftp/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_ftp.a
-libphpext_ftp_a_SOURCES=php_ftp.c ftp.c
diff --git a/ext/ftp/config.h.stub b/ext/ftp/config.h.stub
deleted file mode 100644
index d63248456c..0000000000
--- a/ext/ftp/config.h.stub
+++ /dev/null
@@ -1,2 +0,0 @@
-/* define if you want to use the ftp extension */
-#define HAVE_FTP 0
diff --git a/ext/ftp/config.m4 b/ext/ftp/config.m4
deleted file mode 100644
index 7b01e6b54d..0000000000
--- a/ext/ftp/config.m4
+++ /dev/null
@@ -1,18 +0,0 @@
-dnl $Id$
-dnl config.m4 for extension ftp
-dnl don't forget to call PHP_EXTENSION(ftp)
-
-AC_MSG_CHECKING(for FTP support)
-AC_ARG_WITH(ftp,
-[ --with-ftp Include FTP support.],
-[
- if test "$withval" != "no"; then
- AC_DEFINE(HAVE_FTP)
- PHP_EXTENSION(ftp)
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c
deleted file mode 100644
index 502022ad24..0000000000
--- a/ext/ftp/ftp.c
+++ /dev/null
@@ -1,727 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: |
- | Andrew Skalski <askalski@chek.com> |
- +----------------------------------------------------------------------+
- */
-
-#include "php.h"
-
-#if HAVE_FTP
-
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include "ftp.h"
-
-
-/* reads an ftp response, returns true on success, false on error */
-static int ftp_getresp(ftpbuf_t *ftp);
-
-/* sets the ftp transfer type */
-static int ftp_type(ftpbuf_t *ftp, ftptype_t type);
-
-/* opens up a port for ftp transfer */
-static databuf_t* ftp_port(ftpbuf_t *ftp);
-
-/* accepts the data connection, returns updated data buffer */
-static databuf_t* data_accept(databuf_t *data);
-
-/* closes the data connection, returns NULL */
-static databuf_t* data_close(databuf_t *data);
-
-/* generic file lister */
-static char** ftp_genlist(ftpbuf_t *ftp,
- const char *cmd, const char *path);
-
-
-ftpbuf_t*
-ftp_open(const char *host, short port)
-{
- int fd = -1;
- ftpbuf_t *ftp;
- struct sockaddr_in addr;
- struct hostent *he;
- int size;
-
-
- /* set up the address */
- if ((he = gethostbyname(host)) == NULL) {
- herror("gethostbyname");
- return NULL;
- }
-
- memset(&addr, 0, sizeof(addr));
- memcpy(&addr.sin_addr, he->h_addr, he->h_length);
- addr.sin_port = port ? port : htons(21);
-
-
- /* alloc the ftp structure */
- ftp = calloc(1, sizeof(*ftp));
- if (ftp == NULL) {
- perror("calloc");
- return NULL;
- }
-
- /* connect */
- if ((fd = socket(PF_INET, SOCK_STREAM, 0)) == -1) {
- perror("socket");
- goto bail;
- }
-
- if (connect(fd, (struct sockaddr*) &addr, sizeof(addr)) == -1) {
- perror("connect");
- goto bail;
- }
-
- size = sizeof(addr);
- if (getsockname(fd, (struct sockaddr*) &addr, &size) == -1) {
- perror("getsockname");
- goto bail;
- }
-
- ftp->localaddr = addr.sin_addr;
-
- if ((ftp->fp = fdopen(fd, "r+")) == NULL) {
- perror("fdopen");
- goto bail;
- }
-
- if (!ftp_getresp(ftp) || ftp->resp != 220) {
- goto bail;
- }
-
- return ftp;
-
-bail:
- if (ftp->fp)
- fclose(ftp->fp);
- else if (fd != -1)
- close(fd);
- free(ftp);
- return NULL;
-}
-
-
-ftpbuf_t*
-ftp_close(ftpbuf_t *ftp)
-{
- if (ftp == NULL)
- return NULL;
- if (ftp->fp)
- fclose(ftp->fp);
- ftp_gc(ftp);
- free(ftp);
- return NULL;
-}
-
-
-void
-ftp_gc(ftpbuf_t *ftp)
-{
- if (ftp == NULL)
- return;
-
- free(ftp->pwd);
- ftp->pwd = NULL;
- free(ftp->syst);
- ftp->syst = NULL;
-}
-
-
-int
-ftp_quit(ftpbuf_t *ftp)
-{
- if (ftp == NULL)
- return 0;
-
- fprintf(ftp->fp, "QUIT\r\n");
- if (!ftp_getresp(ftp) || ftp->resp != 221)
- return 0;
-
- free(ftp->pwd);
- ftp->pwd = NULL;
-
- return 1;
-}
-
-
-int
-ftp_login(ftpbuf_t *ftp, const char *user, const char *pass)
-{
- if (ftp == NULL)
- return 0;
-
- fprintf(ftp->fp, "USER %s\r\n", user);
- if (!ftp_getresp(ftp))
- return 0;
- if (ftp->resp == 230)
- return 1;
- if (ftp->resp != 331)
- return 0;
- fprintf(ftp->fp, "PASS %s\r\n", pass);
- if (!ftp_getresp(ftp))
- return 0;
- return (ftp->resp == 230);
-}
-
-
-int
-ftp_reinit(ftpbuf_t *ftp)
-{
- if (ftp == NULL)
- return 0;
-
- ftp_gc(ftp);
-
- fprintf(ftp->fp, "REIN\r\n");
- if (!ftp_getresp(ftp) || ftp->resp != 220)
- return 0;
-
- return 1;
-}
-
-
-const char*
-ftp_syst(ftpbuf_t *ftp)
-{
- char *syst, *end;
-
- if (ftp == NULL)
- return NULL;
-
- /* default to cached value */
- if (ftp->syst)
- return ftp->syst;
-
- fprintf(ftp->fp, "SYST\r\n");
- if (!ftp_getresp(ftp) || ftp->resp != 215)
- return NULL;
-
- syst = ftp->inbuf;
- if ((end = strchr(syst, ' ')))
- *end = 0;
- ftp->syst = strdup(syst);
- if (end)
- *end = ' ';
-
- return ftp->syst;
-}
-
-
-const char*
-ftp_pwd(ftpbuf_t *ftp)
-{
- char *pwd, *end;
-
- if (ftp == NULL)
- return NULL;
-
- /* default to cached value */
- if (ftp->pwd)
- return ftp->pwd;
-
- fprintf(ftp->fp, "PWD\r\n");
- if (!ftp_getresp(ftp) || ftp->resp != 257)
- return NULL;
-
- /* copy out the pwd from response */
- if ((pwd = strchr(ftp->inbuf, '"')) == NULL)
- return NULL;
- end = strrchr(++pwd, '"');
- *end = 0;
- ftp->pwd = strdup(pwd);
- *end = '"';
-
- return ftp->pwd;
-}
-
-
-int
-ftp_chdir(ftpbuf_t *ftp, const char *dir)
-{
- if (ftp == NULL)
- return 0;
-
- free(ftp->pwd);
- ftp->pwd = NULL;
-
- fprintf(ftp->fp, "CWD %s\r\n", dir);
- if (!ftp_getresp(ftp) || ftp->resp != 250)
- return 0;
-
- return 1;
-}
-
-
-int
-ftp_cdup(ftpbuf_t *ftp)
-{
- if (ftp == NULL)
- return 0;
-
- free(ftp->pwd);
- ftp->pwd = NULL;
-
- fprintf(ftp->fp, "CDUP\r\n");
- if (!ftp_getresp(ftp) || ftp->resp != 250)
- return 0;
-
- return 1;
-}
-
-
-char*
-ftp_mkdir(ftpbuf_t *ftp, const char *dir)
-{
- char *mkd, *end;
-
- if (ftp == NULL)
- return NULL;
-
- fprintf(ftp->fp, "MKD %s\r\n", dir);
- if (!ftp_getresp(ftp) || ftp->resp != 257)
- return NULL;
-
- /* copy out the dir from response */
- if ((mkd = strchr(ftp->inbuf, '"')) == NULL)
- return NULL;
- end = strrchr(++mkd, '"');
- *end = 0;
- mkd = strdup(mkd);
- *end = '"';
-
- return mkd;
-}
-
-
-int
-ftp_rmdir(ftpbuf_t *ftp, const char *dir)
-{
- if (ftp == NULL)
- return 0;
-
- fprintf(ftp->fp, "RMD %s\r\n", dir);
- if (!ftp_getresp(ftp) || ftp->resp != 250)
- return 0;
-
- return 1;
-}
-
-
-char**
-ftp_nlist(ftpbuf_t *ftp, const char *path)
-{
- return ftp_genlist(ftp, "NLST", path);
-}
-
-
-char**
-ftp_list(ftpbuf_t *ftp, const char *path)
-{
- return ftp_genlist(ftp, "LIST", path);
-}
-
-
-int
-ftp_getresp(ftpbuf_t *ftp)
-{
- char tag[4];
- int ch;
- char *buf;
- char *ptr;
-
- if (ftp == NULL)
- return 0;
- buf = ftp->inbuf;
- ftp->resp = 0;
-
- do {
- if (!fread(tag, 4, 1, ftp->fp))
- return 0;
-
- if (tag[3] == '-') {
- while ((ch = getc(ftp->fp)) != '\n')
- if (ch == EOF) {
- return 0;
- }
- }
- else if (tag[3] == ' ') {
- ptr = fgets(buf, FTP_BUFSIZE, ftp->fp);
- if (!ptr || !(ptr = strchr(buf, '\n')))
- return 0;
- if (ptr > buf && ptr[-1] == '\r')
- ptr--;
- *ptr = 0;
- }
- else {
- return 0;
- }
- } while (tag[3] == '-');
-
-
- /* translate the tag */
- if (!isdigit(tag[0]) || !isdigit(tag[1]) || !isdigit(tag[2]))
- return 0;
-
- ftp->resp = 100 * (tag[0] - '0') +
- 10 * (tag[1] - '0') +
- (tag[2] - '0');
- return 1;
-}
-
-
-int
-ftp_type(ftpbuf_t *ftp, ftptype_t type)
-{
- char typechar;
-
- if (ftp == NULL)
- return 0;
-
- if (type == ftp->type)
- return 1;
-
- if (type == FTPTYPE_ASCII)
- typechar = 'A';
- else if (type == FTPTYPE_IMAGE)
- typechar = 'I';
- else
- return 0;
-
- fprintf(ftp->fp, "TYPE %c\r\n", typechar);
- if (!ftp_getresp(ftp) || ftp->resp != 200)
- return 0;
-
- ftp->type = type;
-
- return 1;
-}
-
-
-int
-ftp_get(ftpbuf_t *ftp, FILE *outfp, const char *path, ftptype_t type)
-{
- databuf_t *data = NULL;
- int ch, lastch;
-
- if (ftp == NULL)
- return 0;
-
- if (!ftp_type(ftp, type))
- goto bail;
-
- if ((data = ftp_port(ftp)) == NULL)
- goto bail;
-
- fprintf(ftp->fp, "RETR %s\r\n", path);
- if (!ftp_getresp(ftp) || ftp->resp != 150)
- goto bail;
-
- if ((data = data_accept(data)) == NULL)
- goto bail;
-
- lastch = 0;
- while ((ch = getc(data->fp)) != EOF) {
- if (type == FTPTYPE_ASCII) {
- if (lastch == '\r' && ch != '\n')
- putc('\r', outfp);
- if (ch != '\r')
- putc(ch, outfp);
- lastch = ch;
- }
- else {
- putc(ch, outfp);
- }
- }
- if (type == FTPTYPE_ASCII && lastch == '\r')
- putc('\r', outfp);
-
- if (ferror(data->fp) || ferror(outfp))
- goto bail;
-
- data = data_close(data);
-
- if (!ftp_getresp(ftp) || ftp->resp != 226)
- goto bail;
-
- return 1;
-bail:
- data_close(data);
- return 0;
-}
-
-
-int
-ftp_put(ftpbuf_t *ftp, const char *path, FILE *infp, ftptype_t type)
-{
- databuf_t *data = NULL;
- int ch;
-
- if (ftp == NULL)
- return 0;
-
- if (!ftp_type(ftp, type))
- goto bail;
-
- if ((data = ftp_port(ftp)) == NULL)
- goto bail;
-
- fprintf(ftp->fp, "STOR %s\r\n", path);
- if (!ftp_getresp(ftp) || ftp->resp != 150)
- goto bail;
-
- if ((data = data_accept(data)) == NULL)
- goto bail;
-
- while ((ch = getc(infp)) != EOF) {
- if (type == FTPTYPE_ASCII && ch == '\n')
- putc('\r', data->fp);
- putc(ch, data->fp);
- }
-
- if (ferror(data->fp) || ferror(infp))
- goto bail;
-
- data = data_close(data);
-
- if (!ftp_getresp(ftp) || ftp->resp != 226)
- goto bail;
-
- return 1;
-bail:
- data_close(data);
- return 0;
-}
-
-
-databuf_t*
-ftp_port(ftpbuf_t *ftp)
-{
- int fd = -1;
- databuf_t *data;
- struct sockaddr_in addr;
- int size;
- union {
- unsigned long l[1];
- unsigned short s[2];
- unsigned char c[4];
- } ipbox;
-
- /* alloc the data structure */
- data = calloc(1, sizeof(*data));
- if (data == NULL) {
- perror("calloc");
- return NULL;
- }
- data->listener = -1;
- data->type = ftp->type;
-
- /* bind/listen */
- if ((fd = socket(PF_INET, SOCK_STREAM, 0)) == -1) {
- perror("socket");
- goto bail;
- }
-
- /* bind to a local address */
- memset(&addr, 0, sizeof(addr));
- addr.sin_addr.s_addr = INADDR_ANY;
- addr.sin_port = 0;
-
- if (bind(fd, (struct sockaddr*) &addr, sizeof(addr)) == -1) {
- perror("bind");
- goto bail;
- }
-
- size = sizeof(addr);
- if (getsockname(fd, (struct sockaddr*) &addr, &size) == -1) {
- perror("getsockname");
- goto bail;
- }
-
- if (listen(fd, 5) == -1) {
- perror("listen");
- goto bail;
- }
-
- data->listener = fd;
-
- /* send the PORT */
- ipbox.l[0] = ftp->localaddr.s_addr;
- fprintf(ftp->fp, "PORT %u,%u,%u,%u,",
- ipbox.c[0], ipbox.c[1], ipbox.c[2], ipbox.c[3]);
- ipbox.s[0] = addr.sin_port;
- fprintf(ftp->fp, "%u,%u\r\n",
- ipbox.c[0], ipbox.c[1]);
-
- if (!ftp_getresp(ftp) || ftp->resp != 200)
- goto bail;
-
- return data;
-
-bail:
- if (fd != -1)
- close(fd);
- free(data);
- return NULL;
-}
-
-
-databuf_t*
-data_accept(databuf_t *data)
-{
- struct sockaddr_in addr;
- int size;
- int fd;
-
- size = sizeof(addr);
- fd = accept(data->listener, (struct sockaddr*) &addr, &size);
- close(data->listener);
- data->listener = -1;
-
- if (fd == -1) {
- free(data);
- return NULL;
- }
-
- if ((data->fp = fdopen(fd, "r+")) == NULL) {
- close(fd);
- free(data);
- return NULL;
- }
-
- return data;
-}
-
-
-databuf_t*
-data_close(databuf_t *data)
-{
- if (data == NULL)
- return NULL;
- if (data->listener != -1)
- close(data->listener);
- if (data->fp)
- fclose(data->fp);
- free(data);
- return NULL;
-}
-
-
-char**
-ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path)
-{
- FILE *tmpfp = NULL;
- databuf_t *data = NULL;
- int ch, lastch;
- int size;
- int lines;
- char **ret = NULL;
- char **entry;
- char *text;
-
-
- if ((tmpfp = tmpfile()) == NULL)
- return NULL;
-
- if (!ftp_type(ftp, FTPTYPE_ASCII))
- goto bail;
-
- if ((data = ftp_port(ftp)) == NULL)
- goto bail;
-
- if (path)
- fprintf(ftp->fp, "%s %s\r\n", cmd, path);
- else
- fprintf(ftp->fp, "%s\r\n", cmd);
- if (!ftp_getresp(ftp) || ftp->resp != 150)
- goto bail;
-
- /* pull data buffer into tmpfile */
- if ((data = data_accept(data)) == NULL)
- goto bail;
-
- size = 0;
- lines = 0;
- lastch = 0;
- while ((ch = getc(data->fp)) != EOF) {
- if (ch == '\n' && lastch == '\r')
- lines++;
- else
- size++;
- putc(ch, tmpfp);
- lastch = ch;
- }
- data = data_close(data);
-
- if (ferror(tmpfp))
- goto bail;
-
- rewind(tmpfp);
-
- ret = malloc((lines + 1) * sizeof(char**) + size * sizeof(char*));
- if (ret == NULL) {
- perror("malloc");
- goto bail;
- }
-
- entry = ret;
- text = (char*) (ret + lines + 1);
- *entry = text;
- lastch = 0;
- while ((ch = getc(tmpfp)) != EOF) {
- if (ch == '\n' && lastch == '\r') {
- *(text - 1) = 0;
- *++entry = text;
- }
- else {
- *text++ = ch;
- }
- lastch = ch;
- }
- *entry = NULL;
-
- if (ferror(tmpfp))
- goto bail;
-
- fclose(tmpfp);
-
- if (!ftp_getresp(ftp) || ftp->resp != 226) {
- free(ret);
- return NULL;
- }
-
- return ret;
-bail:
- data_close(data);
- fclose(tmpfp);
- free(ret);
- return NULL;
-}
-
-#endif /* HAVE_FTP */
diff --git a/ext/ftp/ftp.h b/ext/ftp/ftp.h
deleted file mode 100644
index f9a2cf549c..0000000000
--- a/ext/ftp/ftp.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: |
- | Andrew Skalski <askalski@chek.com> |
- +----------------------------------------------------------------------+
- */
-
-#ifndef _FTP_H
-#define _FTP_H
-
-#include <stdio.h>
-#include <netinet/in.h>
-
-
-#define FTP_BUFSIZE 4096
-
-typedef enum ftptype {
- FTPTYPE_ASCII,
- FTPTYPE_IMAGE,
-} ftptype_t;
-
-typedef struct ftpbuf
-{
- FILE *fp; /* control connection */
- struct in_addr localaddr; /* local inet address */
- int resp; /* last response code */
- char inbuf[FTP_BUFSIZE]; /* last response text */
- char *pwd; /* cached pwd */
- char *syst; /* cached system type */
- ftptype_t type; /* current transfer type */
-} ftpbuf_t;
-
-typedef struct databuf
-{
- int listener; /* listener socket */
- FILE *fp; /* data connection */
- ftptype_t type; /* transfer type */
-} databuf_t;
-
-
-/* open a FTP connection, returns ftpbuf (NULL on error)
- * port is the ftp port in network byte order, or 0 for the default
- */
-ftpbuf_t* ftp_open(const char *host, short port);
-
-/* quits from the ftp session (it still needs to be closed)
- * return true on success, false on error
- */
-int ftp_quit(ftpbuf_t *ftp);
-
-/* frees up any cached data held in the ftp buffer */
-void ftp_gc(ftpbuf_t *ftp);
-
-/* close the FTP connection and return NULL */
-ftpbuf_t* ftp_close(ftpbuf_t *ftp);
-
-/* logs into the FTP server, returns true on success, false on error */
-int ftp_login(ftpbuf_t *ftp, const char *user, const char *pass);
-
-/* reinitializes the connection, returns true on success, false on error */
-int ftp_reinit(ftpbuf_t *ftp);
-
-/* returns the remote system type (NULL on error) */
-const char* ftp_syst(ftpbuf_t *ftp);
-
-/* returns the present working directory (NULL on error) */
-const char* ftp_pwd(ftpbuf_t *ftp);
-
-/* changes directories, return true on success, false on error */
-int ftp_chdir(ftpbuf_t *ftp, const char *dir);
-
-/* changes to parent directory, return true on success, false on error */
-int ftp_cdup(ftpbuf_t *ftp);
-
-/* creates a directory, return the directory name on success, NULL on error.
- * the return value must be freed
- */
-char* ftp_mkdir(ftpbuf_t *ftp, const char *dir);
-
-/* removes a directory, return true on success, false on error */
-int ftp_rmdir(ftpbuf_t *ftp, const char *dir);
-
-/* returns a NULL-terminated array of filenames in the given path
- * or NULL on error. the return array must be freed (but don't
- * free the array elements)
- */
-char** ftp_nlist(ftpbuf_t *ftp, const char *path);
-
-/* returns a NULL-terminated array of lines returned by the ftp
- * LIST command for the given path or NULL on error. the return
- * array must be freed (but don't
- * free the array elements)
- */
-char** ftp_list(ftpbuf_t *ftp, const char *path);
-
-/* retrieves a file and saves its contents to outfp
- * returns true on success, false on error
- */
-int ftp_get(ftpbuf_t *ftp, FILE *outfp, const char *path,
- ftptype_t type);
-
-/* stores the data from infp as a file on the remote server
- * returns true on success, false on error
- */
-int ftp_put(ftpbuf_t *ftp, const char *path, FILE *infp,
- ftptype_t type);
-
-#endif
diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c
deleted file mode 100644
index cd3b019193..0000000000
--- a/ext/ftp/php_ftp.c
+++ /dev/null
@@ -1,631 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: |
- | Andrew Skalski <askalski@chek.com> |
- +----------------------------------------------------------------------+
- */
-
-#include "php.h"
-#include "php_globals.h"
-
-#if HAVE_FTP
-
-#include "php_ftp.h"
-#include "ftp.h"
-
-static int le_ftpbuf;
-
-
-function_entry php3_ftp_functions[] = {
- PHP_FE(ftp_connect, NULL)
- PHP_FE(ftp_login, NULL)
- PHP_FE(ftp_pwd, NULL)
- PHP_FE(ftp_cdup, NULL)
- PHP_FE(ftp_chdir, NULL)
- PHP_FE(ftp_mkdir, NULL)
- PHP_FE(ftp_rmdir, NULL)
- PHP_FE(ftp_nlist, NULL)
- PHP_FE(ftp_listraw, NULL)
- PHP_FE(ftp_systype, NULL)
- PHP_FE(ftp_get, NULL)
- PHP_FE(ftp_put, NULL)
- PHP_FE(ftp_quit, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry php3_ftp_module_entry = {
- "FTP Functions",
- php3_ftp_functions,
- PHP_MINIT(ftp),
- NULL,
- NULL,
- NULL,
- NULL,
- STANDARD_MODULE_PROPERTIES
-};
-
-static void ftp_destructor_ftpbuf(ftpbuf_t *ftp)
-{
- ftp_close(ftp);
-}
-
-PHP_MINIT_FUNCTION(ftp)
-{
- le_ftpbuf = register_list_destructors(ftp_destructor_ftpbuf, NULL);
- REGISTER_MAIN_LONG_CONSTANT("FTP_ASCII", FTPTYPE_ASCII,
- CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("FTP_BINARY", FTPTYPE_IMAGE,
- CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("FTP_IMAGE", FTPTYPE_IMAGE,
- CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("FTP_TEXT", FTPTYPE_ASCII,
- CONST_PERSISTENT | CONST_CS);
- return SUCCESS;
-}
-
-/* {{{ proto int ftp_connect(string host)
- Open a FTP stream */
-PHP_FUNCTION(ftp_connect)
-{
- pval *arg1;
- int id;
- ftpbuf_t *ftp;
-
- /* arg1 - hostname
- */
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(arg1);
-
- /* connect */
- ftp = ftp_open(arg1->value.str.val, 0);
- if (ftp == NULL) {
- php_error(E_WARNING, "ftp_connect: %s", ftp->inbuf);
- RETURN_FALSE;
- }
-
- id = php3_list_insert(ftp, le_ftpbuf);
- RETURN_LONG(id);
-}
-/* }}} */
-
-/* {{{ proto int ftp_login(int stream, string username, string password)
- Logs into the FTP server. */
-PHP_FUNCTION(ftp_login)
-{
- pval *arg1, *arg2, *arg3;
- int id, type;
- ftpbuf_t *ftp;
-
- /* arg1 - ftp
- * arg2 - username
- * arg3 - password
- */
- if ( ARG_COUNT(ht) != 3 ||
- getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- convert_to_string(arg3);
-
- id = arg1->value.lval;
- ftp = php3_list_find(id, &type);
- if (!ftp || type != le_ftpbuf) {
- php_error(E_WARNING, "Unable to find ftpbuf %d", id);
- RETURN_FALSE;
- }
-
- /* log in */
- if (!ftp_login(ftp, arg2->value.str.val, arg3->value.str.val)) {
- php_error(E_WARNING, "ftp_login: %s", ftp->inbuf);
- RETURN_FALSE;
- }
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto string ftp_pwd(int stream)
- Returns the present working directory. */
-PHP_FUNCTION(ftp_pwd)
-{
- pval *arg1;
- int id, type;
- ftpbuf_t *ftp;
- const char *pwd;
-
- /* arg1 - ftp
- */
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
-
- id = arg1->value.lval;
- ftp = php3_list_find(id, &type);
- if (!ftp || type != le_ftpbuf) {
- php_error(E_WARNING, "Unable to find ftpbuf %d", id);
- RETURN_FALSE;
- }
-
- pwd = ftp_pwd(ftp);
- if (pwd == NULL) {
- php_error(E_WARNING, "ftp_pwd: %s", ftp->inbuf);
- RETURN_FALSE;
- }
-
- RETURN_STRING((char*) pwd, 1);
-}
-/* }}} */
-
-/* {{{ proto int ftp_cdup(int stream)
- Changes to the parent directory */
-PHP_FUNCTION(ftp_cdup)
-{
- pval *arg1;
- int id, type;
- ftpbuf_t *ftp;
-
- /* arg1 - ftp
- */
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
-
- id = arg1->value.lval;
- ftp = php3_list_find(id, &type);
- if (!ftp || type != le_ftpbuf) {
- php_error(E_WARNING, "Unable to find ftpbuf %d", id);
- RETURN_FALSE;
- }
-
- if (!ftp_cdup(ftp)) {
- php_error(E_WARNING, "ftp_cdup: %s", ftp->inbuf);
- RETURN_FALSE;
- }
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int ftp_chdir(int stream, string directory)
- Changes directories */
-PHP_FUNCTION(ftp_chdir)
-{
- pval *arg1, *arg2;
- int id, type;
- ftpbuf_t *ftp;
-
- /* arg1 - ftp
- * arg2 - directory
- */
- if ( ARG_COUNT(ht) != 2 ||
- getParameters(ht, 2, &arg1, &arg2) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
-
- id = arg1->value.lval;
- ftp = php3_list_find(id, &type);
- if (!ftp || type != le_ftpbuf) {
- php_error(E_WARNING, "Unable to find ftpbuf %d", id);
- RETURN_FALSE;
- }
-
- /* change directories */
- if (!ftp_chdir(ftp, arg2->value.str.val)) {
- php_error(E_WARNING, "ftp_chdir: %s", ftp->inbuf);
- RETURN_FALSE;
- }
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto string ftp_mkdir(int stream, string directory)
- Creates a directory */
-PHP_FUNCTION(ftp_mkdir)
-{
- pval *arg1, *arg2;
- int id, type;
- ftpbuf_t *ftp;
- char *ret, *tmp;
-
- /* arg1 - ftp
- * arg2 - directory
- */
- if ( ARG_COUNT(ht) != 2 ||
- getParameters(ht, 2, &arg1, &arg2) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
-
- id = arg1->value.lval;
- ftp = php3_list_find(id, &type);
- if (!ftp || type != le_ftpbuf) {
- php_error(E_WARNING, "Unable to find ftpbuf %d", id);
- RETURN_FALSE;
- }
-
- /* change directories */
- tmp = ftp_mkdir(ftp, arg2->value.str.val);
- if (tmp == NULL) {
- php_error(E_WARNING, "ftp_mkdir: %s", ftp->inbuf);
- RETURN_FALSE;
- }
-
- if ((ret = estrdup(tmp)) == NULL) {
- free(tmp);
- php_error(E_WARNING, "estrdup failed");
- RETURN_FALSE;
- }
-
- RETURN_STRING(ret, 0);
-}
-/* }}} */
-
-/* {{{ proto int ftp_rmdir(int stream, string directory)
- Removes a directory */
-PHP_FUNCTION(ftp_rmdir)
-{
- pval *arg1, *arg2;
- int id, type;
- ftpbuf_t *ftp;
-
- /* arg1 - ftp
- * arg2 - directory
- */
- if ( ARG_COUNT(ht) != 2 ||
- getParameters(ht, 2, &arg1, &arg2) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
-
- id = arg1->value.lval;
- ftp = php3_list_find(id, &type);
- if (!ftp || type != le_ftpbuf) {
- php_error(E_WARNING, "Unable to find ftpbuf %d", id);
- RETURN_FALSE;
- }
-
- /* change directories */
- if (!ftp_rmdir(ftp, arg2->value.str.val)) {
- php_error(E_WARNING, "ftp_rmdir: %s", ftp->inbuf);
- RETURN_FALSE;
- }
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto array ftp_nlist(int stream, string directory)
- Returns an array of filenames in the given directory */
-PHP_FUNCTION(ftp_nlist)
-{
- pval *arg1, *arg2;
- int id, type;
- ftpbuf_t *ftp;
- char **nlist, **ptr;
-
- /* arg1 - ftp
- * arg2 - directory
- */
- if ( ARG_COUNT(ht) != 2 ||
- getParameters(ht, 2, &arg1, &arg2) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
-
- id = arg1->value.lval;
- ftp = php3_list_find(id, &type);
- if (!ftp || type != le_ftpbuf) {
- php_error(E_WARNING, "Unable to find ftpbuf %d", id);
- RETURN_FALSE;
- }
-
- /* get list of files */
- nlist = ftp_nlist(ftp, arg2->value.str.val);
- if (nlist == NULL) {
- RETURN_FALSE;
- }
-
- array_init(return_value);
- for (ptr = nlist; *ptr; ptr++)
- add_next_index_string(return_value, *ptr, 1);
- free(nlist);
-}
-/* }}} */
-
-/* {{{ proto array ftp_listraw(int stream, string directory)
- Returns a detailed listing of a directory as an array of output lines */
-PHP_FUNCTION(ftp_listraw)
-{
- pval *arg1, *arg2;
- int id, type;
- ftpbuf_t *ftp;
- char **llist, **ptr;
-
- /* arg1 - ftp
- * arg2 - directory
- */
- if ( ARG_COUNT(ht) != 2 ||
- getParameters(ht, 2, &arg1, &arg2) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
-
- id = arg1->value.lval;
- ftp = php3_list_find(id, &type);
- if (!ftp || type != le_ftpbuf) {
- php_error(E_WARNING, "Unable to find ftpbuf %d", id);
- RETURN_FALSE;
- }
-
- /* get directory listing */
- llist = ftp_list(ftp, arg2->value.str.val);
- if (llist == NULL) {
- RETURN_FALSE;
- }
-
- array_init(return_value);
- for (ptr = llist; *ptr; ptr++)
- add_next_index_string(return_value, *ptr, 1);
- free(llist);
-}
-/* }}} */
-
-/* {{{ proto string ftp_systype(int stream)
- Returns the system type identifier */
-PHP_FUNCTION(ftp_systype)
-{
- pval *arg1;
- int id, type;
- ftpbuf_t *ftp;
- const char *syst;
-
-
- /* arg1 - ftp
- * arg2 - directory
- */
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
-
- id = arg1->value.lval;
- ftp = php3_list_find(id, &type);
- if (!ftp || type != le_ftpbuf) {
- php_error(E_WARNING, "Unable to find ftpbuf %d", id);
- RETURN_FALSE;
- }
-
- syst = ftp_syst(ftp);
- if (syst == NULL) {
- php_error(E_WARNING, "ftp_syst: %s", ftp->inbuf);
- RETURN_FALSE;
- }
-
- RETURN_STRING((char*) syst, 1);
-}
-/* }}} */
-
-/* {{{ proto int ftp_get(int stream, string local_file, string remote_file, int mode)
- Retrieves a file from the FTP server. */
-PHP_FUNCTION(ftp_get)
-{
- pval *arg1, *arg2, *arg3, *arg4;
- int id, type;
- ftpbuf_t *ftp;
- ftptype_t xtype;
- FILE *outfp, *tmpfp;
- int ch;
-
-
- /* arg1 - ftp
- * arg2 - destination (local) file
- * arg3 - source (remote) file
- * arg4 - transfer mode
- */
- if ( ARG_COUNT(ht) != 4 ||
- getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- convert_to_string(arg3);
- convert_to_long(arg4);
-
- id = arg1->value.lval;
- ftp = php3_list_find(id, &type);
- if (!ftp || type != le_ftpbuf) {
- php_error(E_WARNING, "Unable to find ftpbuf %d", id);
- RETURN_FALSE;
- }
-
- if ( arg4->value.lval != FTPTYPE_ASCII &&
- arg4->value.lval != FTPTYPE_IMAGE)
- {
- php_error(E_WARNING, "arg4 must be FTP_ASCII or FTP_IMAGE");
- RETURN_FALSE;
- }
-
- xtype = arg4->value.lval;
-
- /* get to temporary file, so if there is an error, no existing
- * file gets clobbered
- */
- if ((tmpfp = tmpfile()) == NULL) {
- php_error(E_WARNING, "error opening tmpfile");
- RETURN_FALSE;
- }
-
- if ( !ftp_get(ftp, tmpfp, arg3->value.str.val, xtype) ||
- ferror(tmpfp))
- {
- fclose(tmpfp);
- php_error(E_WARNING, "ftp_get: %s", ftp->inbuf);
- RETURN_FALSE;
- }
-
- if ((outfp = fopen(arg2->value.str.val, "w")) == NULL) {
- fclose(tmpfp);
- php_error(E_WARNING, "error opening %s", arg2->value.str.val);
- RETURN_FALSE;
- }
-
- rewind(tmpfp);
- while ((ch = getc(tmpfp)) != EOF)
- putc(ch, outfp);
-
- if (ferror(tmpfp) || ferror(outfp)) {
- fclose(tmpfp);
- fclose(outfp);
- php_error(E_WARNING, "error writing %s", arg2->value.str.val);
- RETURN_FALSE;
- }
-
- fclose(tmpfp);
- fclose(outfp);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int ftp_put(int stream, string remote_file, string local_file, int mode)
- Stores a file on the FTP server */
-PHP_FUNCTION(ftp_put)
-{
- pval *arg1, *arg2, *arg3, *arg4;
- int id, type;
- ftpbuf_t *ftp;
- ftptype_t xtype;
- FILE *infp;
-
-
- /* arg1 - ftp
- * arg2 - destination (remote) file
- * arg3 - source (local) file
- * arg4 - transfer mode
- */
- if ( ARG_COUNT(ht) != 4 ||
- getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- convert_to_string(arg3);
- convert_to_long(arg4);
-
- id = arg1->value.lval;
- ftp = php3_list_find(id, &type);
- if (!ftp || type != le_ftpbuf) {
- php_error(E_WARNING, "Unable to find ftpbuf %d", id);
- RETURN_FALSE;
- }
-
- if ( arg4->value.lval != FTPTYPE_ASCII &&
- arg4->value.lval != FTPTYPE_IMAGE)
- {
- php_error(E_WARNING, "arg4 must be FTP_ASCII or FTP_IMAGE");
- RETURN_FALSE;
- }
-
- xtype = arg4->value.lval;
-
- if ((infp = fopen(arg3->value.str.val, "r")) == NULL) {
- php_error(E_WARNING, "error opening %s", arg3->value.str.val);
- RETURN_FALSE;
- }
- if ( !ftp_put(ftp, arg2->value.str.val, infp, xtype) ||
- ferror(infp))
- {
- fclose(infp);
- php_error(E_WARNING, "ftp_put: %s", ftp->inbuf);
- RETURN_FALSE;
- }
- fclose(infp);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int ftp_quit(int stream)
- Closes the FTP stream */
-PHP_FUNCTION(ftp_quit)
-{
- pval *arg1;
- int id, type;
- ftpbuf_t *ftp;
-
- /* arg1 - ftp
- */
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id = arg1->value.lval;
- ftp = php3_list_find(id, &type);
- if (!ftp || type != le_ftpbuf) {
- php_error(E_WARNING, "Unable to find ftpbuf %d", id);
- RETURN_FALSE;
- }
-
- php3_list_delete(id);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-#endif /* HAVE_FTP */
diff --git a/ext/ftp/php_ftp.h b/ext/ftp/php_ftp.h
deleted file mode 100644
index 1a71ba70a1..0000000000
--- a/ext/ftp/php_ftp.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* $Id$ */
-
-#ifndef _INCLUDED_FTP_H
-#define _INCLUDED_FTP_H
-
-#if COMPILE_DL
-#undef HAVE_FTP
-#define HAVE_FTP 1
-#endif
-
-#if HAVE_FTP
-
-extern php3_module_entry php3_ftp_module_entry;
-#define php3_ftp_module_ptr &php3_ftp_module_entry
-
-extern PHP_MINIT_FUNCTION(ftp);
-
-PHP_FUNCTION(ftp_connect);
-PHP_FUNCTION(ftp_login);
-PHP_FUNCTION(ftp_pwd);
-PHP_FUNCTION(ftp_cdup);
-PHP_FUNCTION(ftp_chdir);
-PHP_FUNCTION(ftp_mkdir);
-PHP_FUNCTION(ftp_rmdir);
-PHP_FUNCTION(ftp_nlist);
-PHP_FUNCTION(ftp_listraw);
-PHP_FUNCTION(ftp_systype);
-PHP_FUNCTION(ftp_get);
-PHP_FUNCTION(ftp_put);
-PHP_FUNCTION(ftp_quit);
-
-#define phpext_ftp_ptr php3_ftp_module_ptr
-
-#else
-#define php3_ftp_module_ptr NULL
-#endif /* HAVE_FTP */
-
-#endif
diff --git a/ext/gd/Makefile.am b/ext/gd/Makefile.am
deleted file mode 100644
index 6483056bfa..0000000000
--- a/ext/gd/Makefile.am
+++ /dev/null
@@ -1,17 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-phplibdir=$(libdir)/php
-
-SRC=gd.c gdcache.c gdttf.c
-INCLUDES=@INCLUDES@ @GD_INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=@GD_STATIC@
-EXTRA_LIBRARIES=libphpext_gd.a
-libphpext_gd_a_SOURCES=$(SRC)
-
-phplib_LTLIBRARIES=@GD_SHARED@
-EXTRA_LTLIBRARIES=gd.la
-gd_la_SOURCES=$(SRC)
-gd_la_LIBADD=@GD_LFLAGS@ @GD_LIBS@
-gd_la_LDFLAGS=-avoid-version -module -rpath $(phplibdir)
-EXTRA_LIBS=
-
diff --git a/ext/gd/config.h.stub b/ext/gd/config.h.stub
deleted file mode 100644
index db06b056cd..0000000000
--- a/ext/gd/config.h.stub
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Define if you have the gd library (-lgd). */
-#define HAVE_LIBGD 0
-
-/* Define if you have the gd version 1.3 library (-lgd). */
-#define HAVE_LIBGD13 0
-
-#undef FREETYPE_4BIT_ANTIALIAS_HACK
-#undef HAVE_LIBFREETYPE
-#undef HAVE_LIBTTF
diff --git a/ext/gd/config.m4 b/ext/gd/config.m4
deleted file mode 100644
index 9b4b54ca7a..0000000000
--- a/ext/gd/config.m4
+++ /dev/null
@@ -1,166 +0,0 @@
-AC_MSG_CHECKING(whether to include GD support)
-AC_ARG_WITH(gd,
-[ --without-gd Disable GD support.
- --with-gd[=DIR] Include GD support (DIR is GD's install dir).
- Set DIR to "shared" to build as a dl, or
- "shared,DIR" to build as a dl and still specify DIR.],
-[
- case $withval in
- shared)
- shared=yes
- withval=yes
- ;;
- shared,*)
- shared=yes
- withval=`echo $withval | sed -e 's/^shared,//'`
- ;;
- *)
- shared=no
- ;;
- esac
-
- case "$withval" in
- no)
- AC_MSG_RESULT(no) ;;
- yes)
- AC_DEFINE(HAVE_LIBGD)
- if test "$shared" = "yes"; then
- AC_MSG_RESULT(yes (shared))
- GD_LIBS="-lgd"
- else
- AC_MSG_RESULT(yes (static))
- AC_ADD_LIBRARY(gd)
- fi
- AC_CHECK_LIB(gd, gdImageString16, [ AC_DEFINE(HAVE_LIBGD13) ])
- ac_cv_lib_gd_gdImageLine=yes
- ;;
- *)
-dnl A whole whack of possible places where this might be
- test -f $withval/include/gd1.3/gd.h && GD_INCLUDE="$withval/include/gd1.3"
- test -f $withval/include/gd/gd.h && GD_INCLUDE="$withval/include/gd"
- test -f $withval/include/gd.h && GD_INCLUDE="$withval/include"
- test -f $withval/gd1.3/gd.h && GD_INCLUDE="$withval/gd1.3"
- test -f $withval/gd/gd.h && GD_INCLUDE="$withval/gd"
- test -f $withval/gd.h && GD_INCLUDE="$withval"
-
- test -f $withval/lib/libgd.so && GD_LIB="$withval/lib"
- test -f $withval/lib/gd/libgd.so && GD_LIB="$withval/lib/gd"
- test -f $withval/lib/gd1.3/libgd.so && GD_LIB="$withval/lib/gd1.3"
- test -f $withval/libgd.so && GD_LIB="$withval"
- test -f $withval/gd/libgd.so && GD_LIB="$withval/gd"
- test -f $withval/gd1.3/libgd.so && GD_LIB="$withval/gd1.3"
-
- test -f $withval/lib/libgd.a && GD_LIB="$withval/lib"
- test -f $withval/lib/gd/libgd.a && GD_LIB="$withval/lib/gd"
- test -f $withval/lib/gd1.3/libgd.a && GD_LIB="$withval/lib/gd1.3"
- test -f $withval/libgd.a && GD_LIB="$withval"
- test -f $withval/gd/libgd.a && GD_LIB="$withval/gd"
- test -f $withval/gd1.3/libgd.a && GD_LIB="$withval/gd1.3"
-
- if test -n "$GD_INCLUDE" && test -n "$GD_LIB" ; then
- AC_DEFINE(HAVE_LIBGD)
- if test "$shared" != "yes"; then
- AC_MSG_RESULT(yes (static))
- AC_ADD_LIBRARY_WITH_PATH(gd, $GD_LIB)
- else
- AC_MSG_RESULT(yes (shared))
- GD_LIBS="-lgd"
- GD_LFLAGS="-L$GD_LIB"
- fi
- AC_CHECK_LIB(gd, gdImageString16, [ AC_DEFINE(HAVE_LIBGD13) ])
- ac_cv_lib_gd_gdImageLine=yes
- else
- AC_MSG_ERROR([Unable to find libgd.(a|so) anywhere under $withval])
- fi ;;
- esac
-],[
- AC_CHECK_LIB(gd, gdImageLine)
- AC_CHECK_LIB(gd, gdImageString16, [ AC_DEFINE(HAVE_LIBGD13) ])
-])
-if test "$ac_cv_lib_gd_gdImageLine" = "yes"; then
- CHECK_TTF="yes"
- AC_ARG_WITH(ttf,
- [ --with-ttf[=DIR] Include Freetype support],[
- if test $withval = "no" ; then
- CHECK_TTF=""
- else
- CHECK_TTF="$withval"
- fi
- ])
-
- AC_MSG_CHECKING(whether to include ttf support)
- if test -n "$CHECK_TTF" ; then
- for i in /usr /usr/local "$CHECK_TTF" ; do
- if test -f "$i/include/truetype.h" ; then
- FREETYPE_DIR="$i"
- fi
- if test -f "$i/include/freetype.h" ; then
- TTF_DIR="$i"
- fi
- done
- if test -n "$FREETYPE_DIR" ; then
- AC_DEFINE(HAVE_LIBFREETYPE)
- if test "$shared" != "yes"; then
- AC_ADD_LIBRARY_WITH_PATH(freetype, $FREETYPE_DIR/lib)
- AC_ADD_INCLUDE($FREETYPE_DIR/include)
- else
- GD_LIBS="$GD_LIBS -lfreetype"
- GD_LFLAGS="$GD_LFLAGS -L$FREETYPE_DIR/lib"
- GD_INCLUDES="$GD_INCLUDES -I$FREETYPE_DIR/include"
- fi
- AC_MSG_RESULT(yes)
- else
- if test -n "$TTF_DIR" ; then
- AC_DEFINE(HAVE_LIBTTF)
- if test "$shared" != "yes"; then
- AC_ADD_LIBRARY_WITH_PATH(ttf, $TTF_DIR/lib)
- AC_ADD_INCLUDE($TTF_DIR/include)
- else
- GD_LIBS="$GD_LIBS -lttf"
- GD_LFLAGS="$GD_LFLAGS -L$TTF_DIR/lib"
- GD_INCLUDES="$GD_INCLUDES -I$TTF_DIR/include"
- fi
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
- fi
- else
- AC_MSG_RESULT(no)
- fi
-
- if test -f /usr/pkg/include/gd/gd.h -a -z "$GD_INCLUDE" ; then
- GD_INCLUDE="/usr/pkg/include/gd"
- fi
-
- AC_MSG_CHECKING(whether to enable 4bit antialias hack with FreeType2)
- AC_ARG_ENABLE(freetype-4bit-antialias-hack,
- [ --enable-freetype-4bit-antialias-hack
- Include support for FreeType2 (experimental).],[
- if test "$enableval" = "yes" ; then
- AC_DEFINE(FREETYPE_4BIT_ANTIALIAS_HACK, 1)
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
- ],[
- AC_MSG_RESULT(no)
- ])
-
- PHP_EXTENSION(gd, $shared)
- if test "$shared" != "yes"; then
- AC_ADD_INCLUDE($GD_INCLUDE)
- GD_STATIC="libphpext_gd.a"
- else
- if test -n "$GD_INCLUDE"; then
- GD_INCLUDES="$GD_INCLUDES -I$GD_INCLUDE"
- fi
- GD_SHARED="gd.la"
- fi
-fi
-
-AC_SUBST(GD_LFLAGS)
-AC_SUBST(GD_LIBS)
-AC_SUBST(GD_INCLUDES)
-AC_SUBST(GD_STATIC)
-AC_SUBST(GD_SHARED)
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
deleted file mode 100644
index a0a7eb9fe9..0000000000
--- a/ext/gd/gd.c
+++ /dev/null
@@ -1,1809 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Stig Bakken <ssb@guardian.no> |
- | Jim Winstead <jimw@php.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
- Cold Spring Harbor Labs. */
-
-/* Note that there is no code from the gd package in this file */
-
-#ifdef PIC
-# define COMPILE_DL 1
-#endif
-
-#include "php.h"
-#include "ext/standard/head.h"
-#include <math.h>
-#include "SAPI.h"
-#include "php3_gd.h"
-
-#if HAVE_SYS_WAIT_H
-# include <sys/wait.h>
-#endif
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#if WIN32|WINNT
-# include <io.h>
-# include <fcntl.h>
-#endif
-
-#if HAVE_LIBGD
-#include <gd.h>
-#include <gdfontt.h> /* 1 Tiny font */
-#include <gdfonts.h> /* 2 Small font */
-#include <gdfontmb.h> /* 3 Medium bold font */
-#include <gdfontl.h> /* 4 Large font */
-#include <gdfontg.h> /* 5 Giant font */
-#ifdef ENABLE_GD_TTF
-# include "gdttf.h"
-#endif
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-#ifdef ENABLE_GD_TTF
-static void php3_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int);
-#endif
-
-#ifdef THREAD_SAFE
-DWORD GDlibTls;
-static int numthreads=0;
-void *gdlib_mutex=NULL;
-
-typedef struct gdlib_global_struct{
- int le_gd;
- int le_gd_font;
-} gdlib_global_struct;
-
-# define GD_GLOBAL(a) gdlib_globals->a
-# define GD_TLS_VARS gdlib_global_struct *gdlib_globals = TlsGetValue(GDlibTls);
-
-#else
-# define GD_GLOBAL(a) a
-# define GD_TLS_VARS
-int le_gd;
-int le_gd_font;
-#endif
-
-function_entry gd_functions[] = {
- PHP_FE(imagearc, NULL)
- PHP_FE(imagechar, NULL)
- PHP_FE(imagecharup, NULL)
- PHP_FE(imagecolorallocate, NULL)
- PHP_FE(imagecolorat, NULL)
- PHP_FE(imagecolorclosest, NULL)
- PHP_FE(imagecolordeallocate, NULL)
- PHP_FE(imagecolorresolve, NULL)
- PHP_FE(imagecolorexact, NULL)
- PHP_FE(imagecolorset, NULL)
- PHP_FE(imagecolortransparent, NULL)
- PHP_FE(imagecolorstotal, NULL)
- PHP_FE(imagecolorsforindex, NULL)
- PHP_FE(imagecopy, NULL)
- PHP_FE(imagecopyresized, NULL)
- PHP_FE(imagecreate, NULL)
- PHP_FE(imagecreatefromgif, NULL)
- PHP_FE(imagedestroy, NULL)
- PHP_FE(imagefill, NULL)
- PHP_FE(imagefilledpolygon, NULL)
- PHP_FE(imagefilledrectangle, NULL)
- PHP_FE(imagefilltoborder, NULL)
- PHP_FE(imagefontwidth, NULL)
- PHP_FE(imagefontheight, NULL)
- PHP_FE(imagegif, NULL)
- PHP_FE(imageinterlace, NULL)
- PHP_FE(imageline, NULL)
- PHP_FE(imageloadfont, NULL)
- PHP_FE(imagepolygon, NULL)
- PHP_FE(imagerectangle, NULL)
- PHP_FE(imagesetpixel, NULL)
- PHP_FE(imagestring, NULL)
- PHP_FE(imagestringup, NULL)
- PHP_FE(imagesx, NULL)
- PHP_FE(imagesy, NULL)
- PHP_FE(imagedashedline, NULL)
-#ifdef ENABLE_GD_TTF
- PHP_FE(imagettfbbox, NULL)
- PHP_FE(imagettftext, NULL)
-#endif
- {NULL, NULL, NULL}
-};
-
-php3_module_entry gd_module_entry = {
- "gd", gd_functions, PHP_MINIT(gd), PHP_MSHUTDOWN(gd), NULL, NULL, PHP_MINFO(gd), STANDARD_MODULE_PROPERTIES
-};
-
-#if COMPILE_DL
-# if PHP_31
-# include "../phpdl.h"
-# else
-# include "dl/phpdl.h"
-# endif
-DLEXPORT php3_module_entry *get_module(void) { return &gd_module_entry; }
-#endif
-
-
-#define PolyMaxPoints 256
-
-
-PHP_MINIT_FUNCTION(gd)
-{
-#if defined(THREAD_SAFE)
- gdlib_global_struct *gdlib_globals;
- PHP3_MUTEX_ALLOC(gdlib_mutex);
- PHP3_MUTEX_LOCK(gdlib_mutex);
- numthreads++;
- if (numthreads==1){
- if (!PHP3_TLS_PROC_STARTUP(GDlibTls)){
- PHP3_MUTEX_UNLOCK(gdlib_mutex);
- PHP3_MUTEX_FREE(gdlib_mutex);
- return FAILURE;
- }
- }
- PHP3_MUTEX_UNLOCK(gdlib_mutex);
- if(!PHP3_TLS_THREAD_INIT(GDlibTls,gdlib_globals,gdlib_global_struct)){
- PHP3_MUTEX_FREE(gdlib_mutex);
- return FAILURE;
- }
-#endif
- GD_GLOBAL(le_gd) = register_list_destructors(gdImageDestroy, NULL);
- GD_GLOBAL(le_gd_font) = register_list_destructors(php3_free_gd_font, NULL);
- return SUCCESS;
-}
-
-PHP_MINFO_FUNCTION(gd)
-{
- /* need to use a PHPAPI function here because it is external module in windows */
-#if HAVE_LIBGD13
- php_printf("Version 1.3");
-#else
- php_printf("Version 1.2");
-#endif
-#ifdef ENABLE_GD_TTF
- php_printf(" with FreeType support");
-#endif
-}
-
-PHP_MSHUTDOWN_FUNCTION(gd)
-{
- GD_TLS_VARS;
-#ifdef THREAD_SAFE
- PHP3_TLS_THREAD_FREE(gdlib_globals);
- PHP3_MUTEX_LOCK(gdlib_mutex);
- numthreads--;
- if (numthreads<1) {
- PHP3_TLS_PROC_SHUTDOWN(GDlibTls);
- PHP3_MUTEX_UNLOCK(gdlib_mutex);
- PHP3_MUTEX_FREE(gdlib_mutex);
- return SUCCESS;
- }
- PHP3_MUTEX_UNLOCK(gdlib_mutex);
-#endif
- return SUCCESS;
-}
-
-/* Need this for cpdf. See also comment in file.c php3i_get_le_fp() */
-PHPAPI int phpi_get_le_gd(void){
- GD_TLS_VARS;
- return GD_GLOBAL(le_gd);
-}
-
-/********************************************************************/
-/* gdImageColorResolve is a replacement for the old fragment: */
-/* */
-/* if ((color=gdImageColorExact(im,R,G,B)) < 0) */
-/* if ((color=gdImageColorAllocate(im,R,G,B)) < 0) */
-/* color=gdImageColorClosest(im,R,G,B); */
-/* */
-/* in a single function */
-
-int
-gdImageColorResolve(gdImagePtr im, int r, int g, int b)
-{
- int c;
- int ct = -1;
- int op = -1;
- long rd, gd, bd, dist;
- long mindist = 3*255*255; /* init to max poss dist */
-
- for (c = 0; c < im->colorsTotal; c++) {
- if (im->open[c]) {
- op = c; /* Save open slot */
- continue; /* Color not in use */
- }
- rd = (long)(im->red [c] - r);
- gd = (long)(im->green[c] - g);
- bd = (long)(im->blue [c] - b);
- dist = rd * rd + gd * gd + bd * bd;
- if (dist < mindist) {
- if (dist == 0) {
- return c; /* Return exact match color */
- }
- mindist = dist;
- ct = c;
- }
- }
- /* no exact match. We now know closest, but first try to allocate exact */
- if (op == -1) {
- op = im->colorsTotal;
- if (op == gdMaxColors) { /* No room for more colors */
- return ct; /* Return closest available color */
- }
- im->colorsTotal++;
- }
- im->red [op] = r;
- im->green[op] = g;
- im->blue [op] = b;
- im->open [op] = 0;
- return op; /* Return newly allocated color */
-}
-
-void php3_free_gd_font(gdFontPtr fp)
-{
- if (fp->data) {
- efree(fp->data);
- }
- efree(fp);
-}
-
-/* {{{ proto int imageloadfont(string filename)
-Load a new font */
-PHP_FUNCTION(imageloadfont) {
- pval *file;
- int hdr_size = sizeof(gdFont) - sizeof(char *);
- int ind, body_size, n=0, b;
- gdFontPtr font;
- FILE *fp;
- int issock=0, socketd=0;
- GD_TLS_VARS;
-
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &file) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(file);
-
-#if WIN32|WINNT
- fp = fopen(file->value.str.val, "rb");
-#else
- fp = php3_fopen_wrapper(file->value.str.val, "r", IGNORE_PATH|IGNORE_URL_WIN, &issock, &socketd);
-#endif
- if (fp == NULL) {
- php_error(E_WARNING, "ImageFontLoad: unable to open file");
- RETURN_FALSE;
- }
-
- /* Only supports a architecture-dependent binary dump format
- * at the moment.
- * The file format is like this on machines with 32-byte integers:
- *
- * byte 0-3: (int) number of characters in the font
- * byte 4-7: (int) value of first character in the font (often 32, space)
- * byte 8-11: (int) pixel width of each character
- * byte 12-15: (int) pixel height of each character
- * bytes 16-: (char) array with character data, one byte per pixel
- * in each character, for a total of
- * (nchars*width*height) bytes.
- */
- font = (gdFontPtr)emalloc(sizeof(gdFont));
- b = 0;
- while (b < hdr_size && (n = fread(&font[b], 1, hdr_size - b, fp)))
- b += n;
- if (!n) {
- fclose(fp);
- efree(font);
- if (feof(fp)) {
- php_error(E_WARNING, "ImageFontLoad: end of file while reading header");
- } else {
- php_error(E_WARNING, "ImageFontLoad: error while reading header");
- }
- RETURN_FALSE;
- }
- body_size = font->w * font->h * font->nchars;
- font->data = emalloc(body_size);
- b = 0;
- while (b < body_size && (n = fread(&font->data[b], 1, body_size - b, fp)))
- b += n;
- if (!n) {
- fclose(fp);
- efree(font->data);
- efree(font);
- if (feof(fp)) {
- php_error(E_WARNING, "ImageFontLoad: end of file while reading body");
- } else {
- php_error(E_WARNING, "ImageFontLoad: error while reading body");
- }
- RETURN_FALSE;
- }
- fclose(fp);
-
- /* Adding 5 to the font index so we will never have font indices
- * that overlap with the old fonts (with indices 1-5). The first
- * list index given out is always 1.
- */
- ind = 5 + php3_list_insert(font, GD_GLOBAL(le_gd_font));
-
- RETURN_LONG(ind);
-}
-/* }}} */
-
-/* {{{ proto int imagecreate(int x_size, int y_size)
-Create a new image */
-PHP_FUNCTION(imagecreate)
-{
- pval *x_size, *y_size;
- int ind;
- gdImagePtr im;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &x_size, &y_size) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(x_size);
- convert_to_long(y_size);
-
- im = gdImageCreate(x_size->value.lval, y_size->value.lval);
- ind = php3_list_insert(im, GD_GLOBAL(le_gd));
-
- RETURN_LONG(ind);
-}
-/* }}} */
-
-/* {{{ proto int imagecreatefromgif(string filename)
-Create a new image from file or URL */
-PHP_FUNCTION(imagecreatefromgif )
-{
- pval *file;
- int ind;
- gdImagePtr im;
- char *fn=NULL;
- FILE *fp;
- int issock=0, socketd=0;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &file) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(file);
-
- fn = file->value.str.val;
-
-#if WIN32|WINNT
- fp = fopen(file->value.str.val, "rb");
-#else
- fp = php3_fopen_wrapper(file->value.str.val, "r", IGNORE_PATH|IGNORE_URL_WIN, &issock, &socketd);
-#endif
- if (!fp) {
- php3_strip_url_passwd(fn);
- php_error(E_WARNING,
- "ImageCreateFromGif: Unable to open %s for reading", fn);
- RETURN_FALSE;
- }
-
- im = gdImageCreateFromGif (fp);
-
- fflush(fp);
- fclose(fp);
-
- ind = php3_list_insert(im, GD_GLOBAL(le_gd));
-
- RETURN_LONG(ind);
-}
-/* }}} */
-
-/* {{{ proto int imagedestroy(int im)
-Destroy an image */
-PHP_FUNCTION(imagedestroy)
-{
- pval *imgind;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &imgind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(imgind);
-
- php3_list_delete(imgind->value.lval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int imagecolorallocate(int im, int red, int green, int blue)
-Allocate a color for an image */
-PHP_FUNCTION(imagecolorallocate)
-{
- pval *imgind, *red, *green, *blue;
- int ind, ind_type;
- int col;
- int r, g, b;
- gdImagePtr im;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &imgind, &red,
- &green, &blue) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(imgind);
- convert_to_long(red);
- convert_to_long(green);
- convert_to_long(blue);
-
- ind = imgind->value.lval;
- r = red->value.lval;
- g = green->value.lval;
- b = blue->value.lval;
-
- im = php3_list_find(ind, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "ImageColorAllocate: Unable to find image pointer");
- RETURN_FALSE;
- }
- col = gdImageColorAllocate(im, r, g, b);
- RETURN_LONG(col);
-}
-/* }}} */
-
-/* im, x, y */
-/* {{{ proto int imagecolorat(int im, int x, int y)
-Get the index of the color of a pixel */
-PHP_FUNCTION(imagecolorat)
-{
- pval *imgind, *x, *y;
- int ind, ind_type;
- gdImagePtr im;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &imgind, &x, &y) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(imgind);
- convert_to_long(x);
- convert_to_long(y);
-
- ind = imgind->value.lval;
-
- im = php3_list_find(ind, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "ImageColorAt: Unable to find image pointer");
- RETURN_FALSE;
- }
- if (gdImageBoundsSafe(im, x->value.lval, y->value.lval)) {
-#if HAVE_LIBGD13
- RETURN_LONG(im->pixels[y->value.lval][x->value.lval]);
-#else
- RETURN_LONG(im->pixels[x->value.lval][y->value.lval]);
-#endif
- }
- else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int imagecolorclosest(int im, int red, int green, int blue)
-Get the index of the closest color to the specified color */
-PHP_FUNCTION(imagecolorclosest)
-{
- pval *imgind, *red, *green, *blue;
- int ind, ind_type;
- int col;
- int r, g, b;
- gdImagePtr im;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &imgind, &red,
- &green, &blue) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(imgind);
- convert_to_long(red);
- convert_to_long(green);
- convert_to_long(blue);
-
- ind = imgind->value.lval;
- r = red->value.lval;
- g = green->value.lval;
- b = blue->value.lval;
-
- im = php3_list_find(ind, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "ImageColorClosest: Unable to find image pointer");
- RETURN_FALSE;
- }
- col = gdImageColorClosest(im, r, g, b);
- RETURN_LONG(col);
-}
-/* }}} */
-
-/* {{{ proto int imagecolordeallocate(int im, int index)
-De-allocate a color for an image */
-PHP_FUNCTION(imagecolordeallocate)
-{
- pval *imgind, *index;
- int ind, ind_type, col;
- gdImagePtr im;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &imgind, &index) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(imgind);
- convert_to_long(index);
- ind = imgind->value.lval;
- col = index->value.lval;
-
- im = php3_list_find(ind, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "ImageColorDeallocate: Unable to find image pointer");
- RETURN_FALSE;
- }
-
- if (col >= 0 && col < gdImageColorsTotal(im)) {
- gdImageColorDeallocate(im, col);
- RETURN_TRUE;
- }
- else {
- php_error(E_WARNING, "Color index out of range");
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int imagecolorresolve(int im, int red, int green, int blue)
-Get the index of the specified color or its closest possible alternative */
-PHP_FUNCTION(imagecolorresolve)
-{
- pval *imgind, *red, *green, *blue;
- int ind, ind_type;
- int col;
- int r, g, b;
- gdImagePtr im;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &imgind, &red,
- &green, &blue) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(imgind);
- convert_to_long(red);
- convert_to_long(green);
- convert_to_long(blue);
-
- ind = imgind->value.lval;
- r = red->value.lval;
- g = green->value.lval;
- b = blue->value.lval;
-
- im = php3_list_find(ind, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "ImageColorResolve: Unable to find image pointer");
- RETURN_FALSE;
- }
- col = gdImageColorResolve(im, r, g, b);
- RETURN_LONG(col);
-}
-/* }}} */
-
-/* {{{ proto int imagecolorexact(int im, int red, int green, int blue)
-Get the index of the specified color */
-PHP_FUNCTION(imagecolorexact)
-{
- pval *imgind, *red, *green, *blue;
- int ind, ind_type;
- int col;
- int r, g, b;
- gdImagePtr im;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &imgind, &red,
- &green, &blue) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(imgind);
- convert_to_long(red);
- convert_to_long(green);
- convert_to_long(blue);
-
- ind = imgind->value.lval;
- r = red->value.lval;
- g = green->value.lval;
- b = blue->value.lval;
-
- im = php3_list_find(ind, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "ImageColorExact: Unable to find image pointer");
- RETURN_FALSE;
- }
- col = gdImageColorExact(im, r, g, b);
- RETURN_LONG(col);
-}
-/* }}} */
-
-/* {{{ proto int imagecolorset(int im, int col, int red, int green, int blue)
-Set the color for the specified palette index */
-PHP_FUNCTION(imagecolorset)
-{
- pval *imgind, *color, *red, *green, *blue;
- int ind, ind_type;
- int col;
- int r, g, b;
- gdImagePtr im;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 5 || getParameters(ht, 5, &imgind, &color, &red, &green, &blue) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(imgind);
- convert_to_long(color);
- convert_to_long(red);
- convert_to_long(green);
- convert_to_long(blue);
-
- ind = imgind->value.lval;
- col = color->value.lval;
- r = red->value.lval;
- g = green->value.lval;
- b = blue->value.lval;
-
- im = php3_list_find(ind, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "ImageColorSet: Unable to find image pointer");
- RETURN_FALSE;
- }
- if (col >= 0 && col < gdImageColorsTotal(im)) {
- im->red[col] = r;
- im->green[col] = g;
- im->blue[col] = b;
- }
- else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto array imagecolorsforindex(int im, int col)
-Get the colors for an index */
-PHP_FUNCTION(imagecolorsforindex)
-{
- pval *imgind, *index;
- int col, ind, ind_type;
- gdImagePtr im;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &imgind, &index) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(imgind);
- convert_to_long(index);
- ind = imgind->value.lval;
- col = index->value.lval;
-
- im = php3_list_find(ind, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "ImageColorsForIndex: Unable to find image pointer");
- RETURN_FALSE;
- }
-
- if (col >= 0 && col < gdImageColorsTotal(im)) {
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
- add_assoc_long(return_value,"red",im->red[col]);
- add_assoc_long(return_value,"green",im->green[col]);
- add_assoc_long(return_value,"blue",im->blue[col]);
- }
- else {
- php_error(E_WARNING, "Color index out of range");
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int imagegif(int im, string filename)
-Output image to browser or file */
-PHP_FUNCTION(imagegif )
-{
- pval *imgind, *file;
- gdImagePtr im;
- char *fn=NULL;
- FILE *fp;
- int argc;
- int ind_type;
- int output=1;
- GD_TLS_VARS;
-
- argc = ARG_COUNT(ht);
- if (argc < 1 || argc > 2 || getParameters(ht, argc, &imgind, &file) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(imgind);
-
- if (argc == 2) {
- convert_to_string(file);
- fn = file->value.str.val;
- if (!fn || fn == empty_string || _php3_check_open_basedir(fn)) {
- php_error(E_WARNING, "ImageGif: Invalid filename");
- RETURN_FALSE;
- }
- }
-
- im = php3_list_find(imgind->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "ImageGif: unable to find image pointer");
- RETURN_FALSE;
- }
-
- if (argc == 2) {
- fp = fopen(fn, "wb");
- if (!fp) {
- php_error(E_WARNING, "ImageGif: unable to open %s for writing", fn);
- RETURN_FALSE;
- }
- gdImageGif (im,fp);
- fflush(fp);
- fclose(fp);
- }
- else {
- int b;
- FILE *tmp;
- char buf[4096];
-
- tmp = tmpfile();
- if (tmp == NULL) {
- php_error(E_WARNING, "Unable to open temporary file");
- RETURN_FALSE;
- }
-
- output = php3_header();
-
- if (output) {
- SLS_FETCH();
-
- gdImageGif (im, tmp);
- fseek(tmp, 0, SEEK_SET);
-#if APACHE && defined(CHARSET_EBCDIC)
- /* This is a binary file already: avoid EBCDIC->ASCII conversion */
- ap_bsetflag(((request_rec *) SG(server_context))->connection->client, B_EBCDIC2ASCII, 0);
-#endif
- while ((b = fread(buf, 1, sizeof(buf), tmp)) > 0) {
- php3_write(buf, b);
- }
- }
-
- fclose(tmp);
- /* the temporary file is automatically deleted */
- }
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int imagesetpixel(int im, int x, int y, int col)
-Set a single pixel */
-PHP_FUNCTION(imagesetpixel)
-{
- pval *imarg, *xarg, *yarg, *colarg;
- gdImagePtr im;
- int col, y, x;
- int ind_type;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 4 ||
- getParameters(ht, 4, &imarg, &xarg, &yarg, &colarg) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(imarg);
- convert_to_long(xarg);
- convert_to_long(yarg);
- convert_to_long(colarg);
-
- col = colarg->value.lval;
- y = yarg->value.lval;
- x = xarg->value.lval;
-
- im = php3_list_find(imarg->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- gdImageSetPixel(im,x,y,col);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* im, x1, y1, x2, y2, col */
-/* {{{ proto int imageline(int im, int x1, int y1, int x2, int y2, int col)
-Draw a line */
-PHP_FUNCTION(imageline)
-{
- pval *IM, *COL, *X1, *Y1, *X2, *Y2;
- gdImagePtr im;
- int col, y2, x2, y1, x1;
- int ind_type;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 6 ||
- getParameters(ht, 6, &IM, &X1, &Y1, &X2, &Y2, &COL) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(IM);
- convert_to_long(X1);
- convert_to_long(Y1);
- convert_to_long(X2);
- convert_to_long(Y2);
- convert_to_long(COL);
-
- x1 = X1->value.lval;
- y1 = Y1->value.lval;
- x2 = X2->value.lval;
- y2 = Y2->value.lval;
- col = COL->value.lval;
-
- im = php3_list_find(IM->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- gdImageLine(im,x1,y1,x2,y2,col);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int imagedashedline(int im, int x1, int y1, int x2, int y2, int col)
-Draw a dashed line */
-PHP_FUNCTION(imagedashedline)
-{
- pval *IM, *COL, *X1, *Y1, *X2, *Y2;
- gdImagePtr im;
- int col, y2, x2, y1, x1;
- int ind_type;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 6 || getParameters(ht, 6, &IM, &X1, &Y1, &X2, &Y2, &COL) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(IM);
- convert_to_long(X1);
- convert_to_long(Y1);
- convert_to_long(X2);
- convert_to_long(Y2);
- convert_to_long(COL);
-
- x1 = X1->value.lval;
- y1 = Y1->value.lval;
- x2 = X2->value.lval;
- y2 = Y2->value.lval;
- col = COL->value.lval;
-
- im = php3_list_find(IM->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- gdImageDashedLine(im,x1,y1,x2,y2,col);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* im, x1, y1, x2, y2, col */
-/* {{{ proto int imagerectangle(int im, int x1, int y1, int x2, int y2, int col)
-Draw a rectangle */
-PHP_FUNCTION(imagerectangle)
-{
- pval *IM, *COL, *X1, *Y1, *X2, *Y2;
- gdImagePtr im;
- int col, y2, x2, y1, x1;
- int ind_type;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 6 ||
- getParameters(ht, 6, &IM, &X1, &Y1, &X2, &Y2, &COL) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(IM);
- convert_to_long(X1);
- convert_to_long(Y1);
- convert_to_long(X2);
- convert_to_long(Y2);
- convert_to_long(COL);
-
- x1 = X1->value.lval;
- y1 = Y1->value.lval;
- x2 = X2->value.lval;
- y2 = Y2->value.lval;
- col = COL->value.lval;
-
- im = php3_list_find(IM->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- gdImageRectangle(im,x1,y1,x2,y2,col);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* im, x1, y1, x2, y2, col */
-/* {{{ proto int imagefilledrectangle(int im, int x1, int y1, int x2, int y2, int col)
-Draw a filled rectangle */
-PHP_FUNCTION(imagefilledrectangle)
-{
- pval *IM, *COL, *X1, *Y1, *X2, *Y2;
- gdImagePtr im;
- int col, y2, x2, y1, x1;
- int ind_type;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 6 ||
- getParameters(ht, 6, &IM, &X1, &Y1, &X2, &Y2, &COL) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(IM);
- convert_to_long(X1);
- convert_to_long(Y1);
- convert_to_long(X2);
- convert_to_long(Y2);
- convert_to_long(COL);
-
- x1 = X1->value.lval;
- y1 = Y1->value.lval;
- x2 = X2->value.lval;
- y2 = Y2->value.lval;
- col = COL->value.lval;
-
- im = php3_list_find(IM->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- gdImageFilledRectangle(im,x1,y1,x2,y2,col);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int imagearc(int im, int cx, int cy, int w, int h, int s, int e, int col)
-Draw a partial ellipse */
-PHP_FUNCTION(imagearc)
-{
- pval *COL, *E, *ST, *H, *W, *CY, *CX, *IM;
- gdImagePtr im;
- int col, e, st, h, w, cy, cx;
- int ind_type;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 8 ||
- getParameters(ht, 8, &IM, &CX, &CY, &W, &H, &ST, &E, &COL) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(IM);
- convert_to_long(CX);
- convert_to_long(CY);
- convert_to_long(W);
- convert_to_long(H);
- convert_to_long(ST);
- convert_to_long(E);
- convert_to_long(COL);
-
- col = COL->value.lval;
- e = E->value.lval;
- st = ST->value.lval;
- h = H->value.lval;
- w = W->value.lval;
- cy = CY->value.lval;
- cx = CX->value.lval;
-
- if (e < 0) {
- e %= 360;
- }
- if (st < 0) {
- st %= 360;
- }
-
- im = php3_list_find(IM->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- gdImageArc(im,cx,cy,w,h,st,e,col);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* im, x, y, border, col */
-/* {{{ proto int imagefilltoborder(int im, int x, int y, int border, int col)
-Flood fill to specific color */
-PHP_FUNCTION(imagefilltoborder)
-{
- pval *IM, *X, *Y, *BORDER, *COL;
- gdImagePtr im;
- int col, border, y, x;
- int ind_type;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 5 ||
- getParameters(ht, 5, &IM, &X, &Y, &BORDER, &COL) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(IM);
- convert_to_long(X);
- convert_to_long(Y);
- convert_to_long(BORDER);
- convert_to_long(COL);
-
- col = COL->value.lval;
- border = BORDER->value.lval;
- y = Y->value.lval;
- x = X->value.lval;
-
- im = php3_list_find(IM->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- gdImageFillToBorder(im,x,y,border,col);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* im, x, y, col */
-/* {{{ proto int imagefill(int im, int x, int y, int col)
-Flood fill */
-PHP_FUNCTION(imagefill)
-{
- pval *IM, *X, *Y, *COL;
- gdImagePtr im;
- int col, y, x;
- int ind_type;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 4 ||
- getParameters(ht, 4, &IM, &X, &Y, &COL) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(IM);
- convert_to_long(X);
- convert_to_long(Y);
- convert_to_long(COL);
-
- col = COL->value.lval;
- y = Y->value.lval;
- x = X->value.lval;
-
- im = php3_list_find(IM->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- gdImageFill(im,x,y,col);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int imagecolorstotal(int im)
-Find out the number of colors in an image's palette */
-PHP_FUNCTION(imagecolorstotal)
-{
- pval *IM;
- gdImagePtr im;
- int ind_type;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &IM) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(IM);
-
- im = php3_list_find(IM->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- RETURN_LONG(gdImageColorsTotal(im));
-}
-/* }}} */
-
-/* im, col */
-/* {{{ proto int imagecolortransparent(int im [, int col])
-Define a color as transparent */
-PHP_FUNCTION(imagecolortransparent)
-{
- pval *IM, *COL = NULL;
- gdImagePtr im;
- int col;
- int ind_type;
- GD_TLS_VARS;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &IM) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 2:
- if (getParameters(ht, 2, &IM, &COL) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(COL);
- break;
- default:
- WRONG_PARAM_COUNT;
- }
- convert_to_long(IM);
-
- im = php3_list_find(IM->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- if (COL != NULL) {
- col = COL->value.lval;
- gdImageColorTransparent(im,col);
- }
- col = gdImageGetTransparent(im);
- RETURN_LONG(col);
-}
-/* }}} */
-
-/* im, interlace */
-/* {{{ proto int imageinterlace(int im [, int interlace])
-Enable or disable interlace */
-PHP_FUNCTION(imageinterlace)
-{
- pval *IM, *INT = NULL;
- gdImagePtr im;
- int interlace;
- int ind_type;
- GD_TLS_VARS;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &IM) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 2:
- if (getParameters(ht, 2, &IM, &INT) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(INT);
- break;
- default:
- WRONG_PARAM_COUNT;
- }
- convert_to_long(IM);
-
- im = php3_list_find(IM->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- if (INT != NULL) {
- interlace = INT->value.lval;
- gdImageInterlace(im,interlace);
- }
- interlace = gdImageGetInterlaced(im);
- RETURN_LONG(interlace);
-}
-/* }}} */
-
-/* arg = 0 normal polygon
- arg = 1 filled polygon */
-/* im, points, num_points, col */
-static void _php3_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled) {
- pval *IM, *POINTS, *NPOINTS, *COL, **var;
- gdImagePtr im;
- gdPoint points[PolyMaxPoints];
- int npoints, col, nelem, i;
- int ind_type;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 4 ||
- getParameters(ht, 4, &IM, &POINTS, &NPOINTS, &COL) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(IM);
- convert_to_long(NPOINTS);
- convert_to_long(COL);
-
- npoints = NPOINTS->value.lval;
- col = COL->value.lval;
-
- im = php3_list_find(IM->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- if (POINTS->type != IS_ARRAY) {
- php_error(E_WARNING, "2nd argument to imagepolygon not an array");
- RETURN_FALSE;
- }
-
-/*
- ** we shouldn't need this check, should we? **
-
- if (!ParameterPassedByReference(ht, 2)) {
- php_error(E_WARNING, "2nd argument to imagepolygon not passed by reference");
- RETURN_FALSE;
- }
-*/
-
- nelem = zend_hash_num_elements(POINTS->value.ht);
- if (nelem < 6) {
- php_error(E_WARNING,
- "you must have at least 3 points in your array");
- RETURN_FALSE;
- }
-
- if (nelem < npoints * 2) {
- php_error(E_WARNING,
- "trying to use %d points in array with only %d points",
- npoints, nelem/2);
- RETURN_FALSE;
- }
-
- if (npoints > PolyMaxPoints) {
- php_error(E_WARNING, "maximum %d points", PolyMaxPoints);
- RETURN_FALSE;
- }
-
- for (i = 0; i < npoints; i++) {
- if (zend_hash_index_find(POINTS->value.ht, (i * 2), (void **)&var) == SUCCESS) {
- SEPARATE_ZVAL(var);
- convert_to_long(*var);
- points[i].x = (*var)->value.lval;
- }
- if (zend_hash_index_find(POINTS->value.ht, (i * 2) + 1, (void **)&var) == SUCCESS) {
- SEPARATE_ZVAL(var);
- convert_to_long(*var);
- points[i].y = (*var)->value.lval;
- }
- }
-
- if (filled) {
- gdImageFilledPolygon(im, points, npoints, col);
- }
- else {
- gdImagePolygon(im, points, npoints, col);
- }
-
- RETURN_TRUE;
-}
-
-
-/* {{{ proto int imagepolygon(int im, array point, int num_points, int col)
-Draw a polygon */
-PHP_FUNCTION(imagepolygon)
-{
- _php3_imagepolygon(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ proto int imagefilledpolygon(int im, array point, int num_points, int col)
-Draw a filled polygon */
-PHP_FUNCTION(imagefilledpolygon)
-{
- _php3_imagepolygon(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-
-static gdFontPtr _php3_find_gd_font(int size)
-{
- gdFontPtr font;
- int ind_type;
- GD_TLS_VARS;
-
- switch (size) {
- case 1:
- font = gdFontTiny;
- break;
- case 2:
- font = gdFontSmall;
- break;
- case 3:
- font = gdFontMediumBold;
- break;
- case 4:
- font = gdFontLarge;
- break;
- case 5:
- font = gdFontGiant;
- break;
- default:
- font = php3_list_find(size - 5, &ind_type);
- if (!font || ind_type != GD_GLOBAL(le_gd_font)) {
- if (size < 1) {
- font = gdFontTiny;
- } else {
- font = gdFontGiant;
- }
- }
- break;
- }
-
- return font;
-}
-
-
-/*
- * arg = 0 ImageFontWidth
- * arg = 1 ImageFontHeight
- */
-static void _php3_imagefontsize(INTERNAL_FUNCTION_PARAMETERS, int arg)
-{
- pval *SIZE;
- gdFontPtr font;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &SIZE) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(SIZE);
- font = _php3_find_gd_font(SIZE->value.lval);
- RETURN_LONG(arg ? font->h : font->w);
-}
-
-
-/* {{{ proto int imagefontwidth(int font)
-Get font width */
-PHP_FUNCTION(imagefontwidth)
-{
- _php3_imagefontsize(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ proto int imagefontheight(int font)
-Get font height */
-PHP_FUNCTION(imagefontheight)
-{
- _php3_imagefontsize(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-
-/* workaround for a bug in gd 1.2 */
-void _php3_gdimagecharup(gdImagePtr im, gdFontPtr f, int x, int y, int c,
- int color)
-{
- int cx, cy, px, py, fline;
- cx = 0;
- cy = 0;
- if ((c < f->offset) || (c >= (f->offset + f->nchars))) {
- return;
- }
- fline = (c - f->offset) * f->h * f->w;
- for (py = y; (py > (y - f->w)); py--) {
- for (px = x; (px < (x + f->h)); px++) {
- if (f->data[fline + cy * f->w + cx]) {
- gdImageSetPixel(im, px, py, color);
- }
- cy++;
- }
- cy = 0;
- cx++;
- }
-}
-
-/*
- * arg = 0 ImageChar
- * arg = 1 ImageCharUp
- * arg = 2 ImageString
- * arg = 3 ImageStringUp
- */
-static void _php3_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode) {
- pval *IM, *SIZE, *X, *Y, *C, *COL;
- gdImagePtr im;
- int ch = 0, col, x, y, size, i, l = 0;
- unsigned char *string = NULL;
- int ind_type;
- gdFontPtr font;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 6 ||
- getParameters(ht, 6, &IM, &SIZE, &X, &Y, &C, &COL) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(IM);
- convert_to_long(SIZE);
- convert_to_long(X);
- convert_to_long(Y);
- convert_to_string(C);
- convert_to_long(COL);
-
- col = COL->value.lval;
-
- if (mode < 2) {
- ch = (int)((unsigned char)*(C->value.str.val));
- } else {
- string = (unsigned char *) estrndup(C->value.str.val,C->value.str.len);
- l = strlen(string);
- }
-
- y = Y->value.lval;
- x = X->value.lval;
- size = SIZE->value.lval;
-
- im = php3_list_find(IM->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- if (string) {
- efree(string);
- }
- RETURN_FALSE;
- }
-
- font = _php3_find_gd_font(size);
-
- switch(mode) {
- case 0:
- gdImageChar(im, font, x, y, ch, col);
- break;
- case 1:
- _php3_gdimagecharup(im, font, x, y, ch, col);
- break;
- case 2:
- for (i = 0; (i < l); i++) {
- gdImageChar(im, font, x, y, (int)((unsigned char)string[i]),
- col);
- x += font->w;
- }
- break;
- case 3: {
- for (i = 0; (i < l); i++) {
- /* _php3_gdimagecharup(im, font, x, y, (int)string[i], col); */
- gdImageCharUp(im, font, x, y, (int)string[i], col);
- y -= font->w;
- }
- break;
- }
- }
- if (string) {
- efree(string);
- }
- RETURN_TRUE;
-}
-
-/* {{{ proto int imagechar(int im, int font, int x, int y, string c, int col)
-Draw a character */
-PHP_FUNCTION(imagechar) {
- _php3_imagechar(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ proto int imagecharup(int im, int font, int x, int y, string c, int col)
-Draw a character rotated 90 degrees counter-clockwise */
-PHP_FUNCTION(imagecharup) {
- _php3_imagechar(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-/* {{{ proto int imagestring(int im, int font, int x, int y, string str, int col)
-Draw a string horizontally */
-PHP_FUNCTION(imagestring) {
- _php3_imagechar(INTERNAL_FUNCTION_PARAM_PASSTHRU, 2);
-}
-/* }}} */
-
-/* {{{ proto int imagestringup(int im, int font, int x, int y, string str, int col)
-Draw a string vertically - rotated 90 degrees counter-clockwise */
-PHP_FUNCTION(imagestringup) {
- _php3_imagechar(INTERNAL_FUNCTION_PARAM_PASSTHRU, 3);
-}
-/* }}} */
-
-/* {{{ proto int imagecopy(int dst_im, int src_im, int dstX, int dstY, int srcX, int srcY, int srcW, int srcH)
-Copy part of an image */
-PHP_FUNCTION(imagecopy)
-{
- pval *SIM, *DIM, *SX, *SY, *SW, *SH, *DX, *DY;
- gdImagePtr im_dst;
- gdImagePtr im_src;
- int srcH, srcW, srcY, srcX, dstY, dstX;
- int ind_type;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 8 ||
- getParameters(ht, 8, &DIM, &SIM, &DX, &DY, &SX, &SY, &SW, &SH)
- == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(SIM);
- convert_to_long(DIM);
- convert_to_long(SX);
- convert_to_long(SY);
- convert_to_long(SW);
- convert_to_long(SH);
- convert_to_long(DX);
- convert_to_long(DY);
-
- srcX = SX->value.lval;
- srcY = SY->value.lval;
- srcH = SH->value.lval;
- srcW = SW->value.lval;
- dstX = DX->value.lval;
- dstY = DY->value.lval;
-
- im_src = php3_list_find(SIM->value.lval, &ind_type);
- if (!im_src || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- im_dst = php3_list_find(DIM->value.lval, &ind_type);
- if (!im_dst || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- gdImageCopy(im_dst, im_src, dstX, dstY, srcX, srcY, srcW, srcH);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int imagecopyresized(int dst_im, int src_im, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);
-Copy and resize part of an image */
-PHP_FUNCTION(imagecopyresized)
-{
- pval *SIM, *DIM, *SX, *SY, *SW, *SH, *DX, *DY, *DW, *DH;
- gdImagePtr im_dst;
- gdImagePtr im_src;
- int srcH, srcW, dstH, dstW, srcY, srcX, dstY, dstX;
- int ind_type;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 10 ||
- getParameters(ht, 10, &DIM, &SIM, &DX, &DY, &SX, &SY, &DW, &DH,
- &SW, &SH) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(SIM);
- convert_to_long(DIM);
- convert_to_long(SX);
- convert_to_long(SY);
- convert_to_long(SW);
- convert_to_long(SH);
- convert_to_long(DX);
- convert_to_long(DY);
- convert_to_long(DW);
- convert_to_long(DH);
-
- srcX = SX->value.lval;
- srcY = SY->value.lval;
- srcH = SH->value.lval;
- srcW = SW->value.lval;
- dstX = DX->value.lval;
- dstY = DY->value.lval;
- dstH = DH->value.lval;
- dstW = DW->value.lval;
-
- im_src = php3_list_find(SIM->value.lval, &ind_type);
- if (!im_src || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- im_dst = php3_list_find(DIM->value.lval, &ind_type);
- if (!im_dst || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- gdImageCopyResized(im_dst, im_src, dstX, dstY, srcX, srcY, dstW, dstH,
- srcW, srcH);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int imagesx(int im)
-Get image width */
-PHP_FUNCTION(imagesx)
-{
- pval *IM;
- gdImagePtr im;
- int ind_type;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &IM) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- im = php3_list_find(IM->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- RETURN_LONG(gdImageSX(im));
-}
-/* }}} */
-
-/* {{{ proto int imagesy(int im)
-Get image height */
-PHP_FUNCTION(imagesy)
-{
- pval *IM;
- gdImagePtr im;
- int ind_type;
- GD_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &IM) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- im = php3_list_find(IM->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
-
- RETURN_LONG(gdImageSY(im));
-}
-/* }}} */
-
-#ifdef ENABLE_GD_TTF
-
-#define TTFTEXT_DRAW 0
-#define TTFTEXT_BBOX 1
-
-/* {{{ proto array imagettfbbox(int size, int angle, string font_file, string text)
-Give the bounding box of a text using TrueType fonts */
-PHP_FUNCTION(imagettfbbox)
-{
- php3_imagettftext_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, TTFTEXT_BBOX);
-}
-/* }}} */
-
-/* {{{ proto array imagettftext(int im, int size, int angle, int x, int y, int col, string font_file, string text)
-Write text to the image using a TrueType font */
-PHP_FUNCTION(imagettftext)
-{
- php3_imagettftext_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, TTFTEXT_DRAW);
-}
-/* }}} */
-
-static
-void php3_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode)
-{
- pval *IM, *PTSIZE, *ANGLE, *X, *Y, *C, *FONTNAME, *COL;
- gdImagePtr im;
- int col, x, y, l=0, i;
- int brect[8];
- double ptsize, angle;
- unsigned char *string = NULL, *fontname = NULL;
- int ind_type;
- char *error;
-
- GD_TLS_VARS;
-
- if (mode == TTFTEXT_BBOX) {
- if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &PTSIZE, &ANGLE, &FONTNAME, &C) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- } else {
- if (ARG_COUNT(ht) != 8 || getParameters(ht, 8, &IM, &PTSIZE, &ANGLE, &X, &Y, &COL, &FONTNAME, &C) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- }
-
- convert_to_double(PTSIZE);
- convert_to_double(ANGLE);
- convert_to_string(FONTNAME);
- convert_to_string(C);
- if (mode == TTFTEXT_BBOX) {
- im = NULL;
- col = x = y = -1;
- } else {
- convert_to_long(X);
- convert_to_long(Y);
- convert_to_long(IM);
- convert_to_long(COL);
- col = COL->value.lval;
- y = Y->value.lval;
- x = X->value.lval;
- im = php3_list_find(IM->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "Unable to find image pointer");
- RETURN_FALSE;
- }
- }
-
- ptsize = PTSIZE->value.dval;
- angle = ANGLE->value.dval * (M_PI/180); /* convert to radians */
-
- string = (unsigned char *) C->value.str.val;
- l = strlen(string);
- fontname = (unsigned char *) FONTNAME->value.str.val;
-
- error = gdttf(im, brect, col, fontname, ptsize, angle, x, y, string);
-
- if (error) {
- php_error(E_WARNING, error);
- RETURN_FALSE;
- }
-
-
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
-
- /* return array with the text's bounding box */
- for (i = 0; i < 8; i++) {
- add_next_index_long(return_value, brect[i]);
- }
-}
-#endif
-#endif
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/gd/gdcache.c b/ext/gd/gdcache.c
deleted file mode 100644
index b89f5610ac..0000000000
--- a/ext/gd/gdcache.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * $Id$
- *
- * Caches of pointers to user structs in which the least-recently-used
- * element is replaced in the event of a cache miss after the cache has
- * reached a given size.
- *
- * John Ellson (ellson@lucent.com) Oct 31, 1997
- *
- * Test this with:
- * gcc -o gdcache -g -Wall -DTEST gdcache.c
- *
- * The cache is implemented by a singly-linked list of elements
- * each containing a pointer to a user struct that is being managed by
- * the cache.
- *
- * The head structure has a pointer to the most-recently-used
- * element, and elements are moved to this position in the list each
- * time they are used. The head also contains pointers to three
- * user defined functions:
- * - a function to test if a cached userdata matches some keydata
- * - a function to provide a new userdata struct to the cache
- * if there has been a cache miss.
- * - a function to release a userdata struct when it is
- * no longer being managed by the cache
- *
- * In the event of a cache miss the cache is allowed to grow up to
- * a specified maximum size. After the maximum size is reached then
- * the least-recently-used element is discarded to make room for the
- * new. The most-recently-returned value is always left at the
- * beginning of the list after retrieval.
- *
- * In the current implementation the cache is traversed by a linear
- * search from most-recent to least-recent. This linear search
- * probably limits the usefulness of this implementation to cache
- * sizes of a few tens of elements.
- */
-
-/* This just seems unessacary */
-#if (WIN32|WINNT)
-#define ENABLE_GD_TTF
-#else
-#include "php_config.h"
-#endif
-#if HAVE_LIBTTF|HAVE_LIBFREETYPE
-
-#include "gdcache.h"
-
-/*********************************************************/
-/* implementation */
-/*********************************************************/
-
-
-/* create a new cache */
-gdCache_head_t *
-gdCacheCreate(
- int size,
- gdCacheTestFn_t gdCacheTest,
- gdCacheFetchFn_t gdCacheFetch,
- gdCacheReleaseFn_t gdCacheRelease )
-{
- gdCache_head_t *head;
-
- head = (gdCache_head_t *)malloc(sizeof(gdCache_head_t));
- head->mru = NULL;
- head->size = size;
- head->gdCacheTest = gdCacheTest;
- head->gdCacheFetch = gdCacheFetch;
- head->gdCacheRelease = gdCacheRelease;
- return head;
-}
-
-void
-gdCacheDelete( gdCache_head_t *head )
-{
- gdCache_element_t *elem, *prev;
-
- elem = head->mru;
- while(elem) {
- (*(head->gdCacheRelease))(elem->userdata);
- prev = elem;
- elem = elem->next;
- free((char *)prev);
- }
- free((char *)head);
-}
-
-void *
-gdCacheGet( gdCache_head_t *head, void *keydata )
-{
- int i=0;
- gdCache_element_t *elem, *prev = NULL, *prevprev = NULL;
- void *userdata;
-
- elem = head->mru;
- while(elem) {
- if ((*(head->gdCacheTest))(elem->userdata, keydata)) {
- if (i) { /* if not already most-recently-used */
- /* relink to top of list */
- prev->next = elem->next;
- elem->next = head->mru;
- head->mru = elem;
- }
- return elem->userdata;
- }
- prevprev = prev;
- prev = elem;
- elem = elem->next;
- i++;
- }
- userdata = (*(head->gdCacheFetch))(&(head->error), keydata);
- if (! userdata) {
- /* if there was an error in the fetch then don't cache */
- return NULL;
- }
- if (i < head->size) { /* cache still growing - add new elem */
- elem = (gdCache_element_t *)malloc(sizeof(gdCache_element_t));
- }
- else { /* cache full - replace least-recently-used */
- /* preveprev becomes new end of list */
- prevprev->next = NULL;
- elem = prev;
- (*(head->gdCacheRelease))(elem->userdata);
- }
- /* relink to top of list */
- elem->next = head->mru;
- head->mru = elem;
- elem->userdata = userdata;
- return userdata;
-}
-
-
-
-/*********************************************************/
-/* test stub */
-/*********************************************************/
-
-
-#ifdef GDCACHE_TEST
-
-#include <stdio.h>
-
-typedef struct {
- int key;
- int value;
-} key_value_t;
-
-static int
-cacheTest( void *map, void *key )
-{
- return (((key_value_t *)map)->key == *(int *)key);
-}
-
-static void *
-cacheFetch( char **error, void *key )
-{
- key_value_t *map;
-
- map = (key_value_t *)malloc(sizeof(key_value_t));
- map->key = *(int *)key;
- map->value = 3;
-
- *error = NULL;
- return (void *)map;
-}
-
-static void
-cacheRelease( void *map)
-{
- free( (char *)map );
-}
-
-int
-main(char *argv[], int argc)
-{
- gdCache_head_t *cacheTable;
- int elem, key;
-
- cacheTable = gdCacheCreate(3, cacheTest, cacheFetch, cacheRelease);
-
- key = 20;
- elem = *(int *)gdCacheGet(cacheTable, &key);
- key = 30;
- elem = *(int *)gdCacheGet(cacheTable, &key);
- key = 40;
- elem = *(int *)gdCacheGet(cacheTable, &key);
- key = 50;
- elem = *(int *)gdCacheGet(cacheTable, &key);
- key = 30;
- elem = *(int *)gdCacheGet(cacheTable, &key);
- key = 30;
- elem = *(int *)gdCacheGet(cacheTable, &key);
-
- gdCacheDelete(cacheTable);
-
- return 0;
-}
-
-#endif
-
-#endif /* ENABLE_GD_TTF */
diff --git a/ext/gd/gdcache.h b/ext/gd/gdcache.h
deleted file mode 100644
index cdfbf71f95..0000000000
--- a/ext/gd/gdcache.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * $Id$
- *
- * Caches of pointers to user structs in which the least-recently-used
- * element is replaced in the event of a cache miss after the cache has
- * reached a given size.
- *
- * John Ellson (ellson@lucent.com) Oct 31, 1997
- *
- * Test this with:
- * gcc -o gdcache -g -Wall -DTEST gdcache.c
- *
- * The cache is implemented by a singly-linked list of elements
- * each containing a pointer to a user struct that is being managed by
- * the cache.
- *
- * The head structure has a pointer to the most-recently-used
- * element, and elements are moved to this position in the list each
- * time they are used. The head also contains pointers to three
- * user defined functions:
- * - a function to test if a cached userdata matches some keydata
- * - a function to provide a new userdata struct to the cache
- * if there has been a cache miss.
- * - a function to release a userdata struct when it is
- * no longer being managed by the cache
- *
- * In the event of a cache miss the cache is allowed to grow up to
- * a specified maximum size. After the maximum size is reached then
- * the least-recently-used element is discarded to make room for the
- * new. The most-recently-returned value is always left at the
- * beginning of the list after retrieval.
- *
- * In the current implementation the cache is traversed by a linear
- * search from most-recent to least-recent. This linear search
- * probably limits the usefulness of this implementation to cache
- * sizes of a few tens of elements.
- */
-
-/*********************************************************/
-/* header */
-/*********************************************************/
-
-#ifndef _OSD_POSIX
-#include <malloc.h>
-#else
-#include <stdlib.h> /* BS2000/OSD defines malloc() & friends in stdlib.h */
-#endif
-#ifndef NULL
-#define NULL (void *)0
-#endif
-
-/* user defined function templates */
-typedef int (*gdCacheTestFn_t)(void *userdata, void *keydata);
-typedef void *(*gdCacheFetchFn_t)(char **error, void *keydata);
-typedef void (*gdCacheReleaseFn_t)(void *userdata);
-
-/* element structure */
-typedef struct gdCache_element_s gdCache_element_t;
-struct gdCache_element_s {
- gdCache_element_t *next;
- void *userdata;
-};
-
-/* head structure */
-typedef struct gdCache_head_s gdCache_head_t;
-struct gdCache_head_s {
- gdCache_element_t *mru;
- int size;
- char *error;
- gdCacheTestFn_t gdCacheTest;
- gdCacheFetchFn_t gdCacheFetch;
- gdCacheReleaseFn_t gdCacheRelease;
-};
-
-/* function templates */
-gdCache_head_t *
-gdCacheCreate(
- int size,
- gdCacheTestFn_t gdCacheTest,
- gdCacheFetchFn_t gdCacheFetch,
- gdCacheReleaseFn_t gdCacheRelease );
-
-void
-gdCacheDelete( gdCache_head_t *head );
-
-void *
-gdCacheGet( gdCache_head_t *head, void *keydata );
diff --git a/ext/gd/gdttf.c b/ext/gd/gdttf.c
deleted file mode 100644
index f2c1a03a9a..0000000000
--- a/ext/gd/gdttf.c
+++ /dev/null
@@ -1,878 +0,0 @@
-/* gd interface to freetype library */
-/* */
-/* John Ellson ellson@lucent.com */
-
-/* $Id$ */
-
-#if WIN32|WINNT
-#include "config.w32.h"
-#else
-#include "php_config.h"
-#endif
-#if HAVE_LIBTTF|HAVE_LIBFREETYPE
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <gd.h>
-#include "gdttf.h"
-#include "gdcache.h"
-#if HAVE_LIBFREETYPE
-#include <truetype.h>
-#else
-#include <freetype.h>
-#endif
-
-/* number of fonts cached before least recently used is replaced */
-#define FONTCACHESIZE 6
-
-/* number of character glyphs cached per font before
- least-recently-used is replaced */
-#define GLYPHCACHESIZE 120
-
-/* number of bitmaps cached per glyph before
- least-recently-used is replaced */
-#define BITMAPCACHESIZE 8
-
-/* number of antialias color lookups cached */
-#if FREETYPE_4BIT_ANTIALIAS_HACK
-#define TWEENCOLORCACHESIZE 128
-#else
-#define TWEENCOLORCACHESIZE 32
-#endif
-
-/* ptsize below which anti-aliasing is ineffective */
-#define MINANTIALIASPTSIZE 0
-
-/* display resolution - (Not really. This has to be 72 or hinting is wrong) */
-#define RESOLUTION 72
-
-/* Number of colors used for anti-aliasing */
-#if FREETYPE_4BIT_ANTIALIAS_HACK
-#define NUMCOLORS 16
-#else
-#define NUMCOLORS 4
-#endif
-
-/* Line separation as a factor of font height.
- No space between if LINESPACE = 1.00
- Line separation will be rounded up to next pixel row*/
-#define LINESPACE 1.05
-
-#ifndef TRUE
-#define FALSE 0
-#define TRUE !FALSE
-#endif
-
-#define MAX(a,b) ((a)>(b)?(a):(b))
-#define MIN(a,b) ((a)<(b)?(a):(b))
-
-typedef struct {
- char *fontname; /* key */
- double ptsize; /* key */
- double angle; /* key */
- double sin_a, cos_a;
- TT_Engine *engine;
- TT_Face face;
- TT_Face_Properties properties;
- TT_Instance instance;
- TT_CharMap char_map;
- TT_Matrix matrix;
- TT_Instance_Metrics imetrics;
- gdCache_head_t *glyphCache;
-} font_t;
-
-typedef struct {
- char *fontname; /* key */
- double ptsize; /* key */
- double angle; /* key */
- TT_Engine *engine;
-} fontkey_t;
-
-typedef struct {
- int character; /* key */
- int hinting; /* key */
- TT_Glyph glyph;
- TT_Glyph_Metrics metrics;
- TT_Outline outline;
- TT_Pos oldx, oldy;
- TT_Raster_Map Bit;
- int gray_render;
- int xmin, xmax, ymin, ymax;
- gdCache_head_t *bitmapCache;
-} glyph_t;
-
-typedef struct {
- int character; /* key */
- int hinting; /* key */
- int gray_render;
- font_t *font;
-} glyphkey_t;
-
-typedef struct {
- int xoffset; /* key */
- int yoffset; /* key */
- char *bitmap;
-} bitmap_t;
-
-typedef struct {
- int xoffset; /* key */
- int yoffset; /* key */
- glyph_t *glyph;
-} bitmapkey_t;
-
-typedef struct {
- unsigned char pixel; /* key */
- unsigned char bgcolor; /* key */
- int fgcolor; /* key */ /* -ve means no antialias */
- gdImagePtr im; /* key */
- unsigned char tweencolor;
-} tweencolor_t;
-
-typedef struct {
- unsigned char pixel; /* key */
- unsigned char bgcolor; /* key */
- int fgcolor; /* key */ /* -ve means no antialias */
- gdImagePtr im; /* key */
-} tweencolorkey_t;
-
-/* forward declarations so that glyphCache can be initialized by font code */
-static int glyphTest ( void *element, void *key );
-static void *glyphFetch ( char **error, void *key );
-static void glyphRelease( void *element );
-
-/* forward declarations so that bitmapCache can be initialized by glyph code */
-static int bitmapTest ( void *element, void *key );
-static void *bitmapFetch ( char **error, void *key );
-static void bitmapRelease( void *element );
-
-/* local prototype */
-char *gdttfchar(gdImage *im, int fg, font_t *font, int x, int y, TT_F26Dot6 x1, TT_F26Dot6 y1, TT_F26Dot6 *advance, TT_BBox **bbox, char **next);
-
-/* This prototype is missing from gd.h */
-/* FIXME Since when does GD have this function??? My copy of 1.3 doesnt
-int gdImageColorResolve(gdImagePtr im, int r, int g, int b);
-*/
-
-/********************************************************************/
-/* gdImageColorResolve is a replacement for the old fragment: */
-/* */
-/* if ((color=gdImageColorExact(im,R,G,B)) < 0) */
-/* if ((color=gdImageColorAllocate(im,R,G,B)) < 0) */
-/* color=gdImageColorClosest(im,R,G,B); */
-/* */
-/* in a single function */
-
-static int
-gdImageColorResolve(gdImagePtr im, int r, int g, int b)
-{
- int c;
- int ct = -1;
- int op = -1;
- long rd, gd, bd, dist;
- long mindist = 3*255*255; /* init to max poss dist */
-
- for (c = 0; c < im->colorsTotal; c++) {
- if (im->open[c]) {
- op = c; /* Save open slot */
- continue; /* Color not in use */
- }
- rd = (long)(im->red [c] - r);
- gd = (long)(im->green[c] - g);
- bd = (long)(im->blue [c] - b);
- dist = rd * rd + gd * gd + bd * bd;
- if (dist < mindist) {
- if (dist == 0) {
- return c; /* Return exact match color */
- }
- mindist = dist;
- ct = c;
- }
- }
- /* no exact match. We now know closest, but first try to allocate exact */
- if (op == -1) {
- op = im->colorsTotal;
- if (op == gdMaxColors) { /* No room for more colors */
- return ct; /* Return closest available color */
- }
- im->colorsTotal++;
- }
- im->red [op] = r;
- im->green[op] = g;
- im->blue [op] = b;
- im->open [op] = 0;
- return op; /* Return newly allocated color */
-}
-
-/********************************************************************
- * gdTcl_UtfToUniChar is borrowed from ...
- */
-/*
- * tclUtf.c --
- *
- * Routines for manipulating UTF-8 strings.
- *
- * Copyright (c) 1997-1998 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * SCCS: @(#) tclUtf.c 1.25 98/01/28 18:02:43
- */
-
-/*
- *---------------------------------------------------------------------------
- *
- * gdTcl_UtfToUniChar --
- *
- * Extract the Tcl_UniChar represented by the UTF-8 string. Bad
- * UTF-8 sequences are converted to valid Tcl_UniChars and processing
- * continues. Equivalent to Plan 9 chartorune().
- *
- * The caller must ensure that the source buffer is long enough that
- * this routine does not run off the end and dereference non-existent
- * memory looking for trail bytes. If the source buffer is known to
- * be '\0' terminated, this cannot happen. Otherwise, the caller
- * should call Tcl_UtfCharComplete() before calling this routine to
- * ensure that enough bytes remain in the string.
- *
- * Results:
- * *chPtr is filled with the Tcl_UniChar, and the return value is the
- * number of bytes from the UTF-8 string that were consumed.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-#ifndef CHARSET_EBCDIC
-#define ASC(ch) (ch)
-#else /*CHARSET_EBCDIC*/
-#define ASC(ch) os_toascii[(unsigned char) (ch)]
-#endif /*CHARSET_EBCDIC*/
-
-#define Tcl_UniChar int
-#define TCL_UTF_MAX 3
-static int
-gdTcl_UtfToUniChar(char *str, Tcl_UniChar *chPtr)
-/* str is the UTF8 next character pointer */
-/* chPtr is the int for the result */
-{
- int byte;
-
- /* HTML4.0 entities in decimal form, e.g. &#197; */
- byte = *((unsigned char *) str);
- if (byte == '&') {
- int i, n=0;
-
- byte = *((unsigned char *) (str+1));
- if (byte == '#') {
- for (i = 2; i < 8; i++) {
- byte = *((unsigned char *) (str+i));
- if (byte >= '0' && byte <= '9') {
- n = (n * 10) + (byte - '0');
- }
- else
- break;
- }
- if (byte == ';') {
- *chPtr = (Tcl_UniChar) n;
- return ++i;
- }
- }
- }
-
- /*
- * Unroll 1 to 3 byte UTF-8 sequences, use loop to handle longer ones.
- */
-
- byte = ASC(*((unsigned char *) str));
- if (byte < 0xC0) {
- /*
- * Handles properly formed UTF-8 characters between 0x01 and 0x7F.
- * Also treats \0 and naked trail bytes 0x80 to 0xBF as valid
- * characters representing themselves.
- */
-
- *chPtr = (Tcl_UniChar) byte;
- return 1;
- } else if (byte < 0xE0) {
- if ((ASC(str[1]) & 0xC0) == 0x80) {
- /*
- * Two-byte-character lead-byte followed by a trail-byte.
- */
-
- *chPtr = (Tcl_UniChar) (((byte & 0x1F) << 6) | (ASC(str[1]) & 0x3F));
- return 2;
- }
- /*
- * A two-byte-character lead-byte not followed by trail-byte
- * represents itself.
- */
-
- *chPtr = (Tcl_UniChar) byte;
- return 1;
- } else if (byte < 0xF0) {
- if (((ASC(str[1]) & 0xC0) == 0x80) && ((ASC(str[2]) & 0xC0) == 0x80)) {
- /*
- * Three-byte-character lead byte followed by two trail bytes.
- */
-
- *chPtr = (Tcl_UniChar) (((byte & 0x0F) << 12)
- | ((ASC(str[1]) & 0x3F) << 6) | (ASC(str[2]) & 0x3F));
- return 3;
- }
- /*
- * A three-byte-character lead-byte not followed by two trail-bytes
- * represents itself.
- */
-
- *chPtr = (Tcl_UniChar) byte;
- return 1;
- }
-#if TCL_UTF_MAX > 3
- else {
- int ch, total, trail;
-
- total = totalBytes[byte];
- trail = total - 1;
- if (trail > 0) {
- ch = byte & (0x3F >> trail);
- do {
- str++;
- if ((ASC(*str) & 0xC0) != 0x80) {
- *chPtr = byte;
- return 1;
- }
- ch <<= 6;
- ch |= (ASC(*str) & 0x3F);
- trail--;
- } while (trail > 0);
- *chPtr = ch;
- return total;
- }
- }
-#endif
-
- *chPtr = (Tcl_UniChar) byte;
- return 1;
-}
-
-/********************************************************************/
-/* font cache functions */
-
-static int
-fontTest ( void *element, void *key )
-{
- font_t *a=(font_t *)element;
- fontkey_t *b=(fontkey_t *)key;
-
- return ( strcmp(a->fontname, b->fontname) == 0
- && a->ptsize == b->ptsize
- && a->angle == b->angle);
-}
-
-static void *
-fontFetch ( char **error, void *key )
-{
- TT_Error err;
- font_t *a;
- fontkey_t *b=(fontkey_t *)key;
- int i, n;
- short platform, encoding;
-
- a = (font_t *)malloc(sizeof(font_t));
- a->fontname = (char *)malloc(strlen(b->fontname) + 1);
- strcpy(a->fontname,b->fontname);
- a->ptsize = b->ptsize;
- a->angle = b->angle;
- a->sin_a = sin(a->angle);
- a->cos_a = cos(a->angle);
- a->engine = b->engine;
- if ((err = TT_Open_Face(*b->engine, a->fontname, &a->face))) {
-#if HAVE_LIBFREETYPE
- if (err == 0x008) { /* The FT2 oldapi is missing this code */
-#else
- if (err == TT_Err_Could_Not_Open_File) {
-#endif
- *error = "Could not find/open font";
- }
- else {
- *error = "Could not read font";
- }
- return NULL;
- }
- /* get face properties and allocate preload arrays */
- TT_Get_Face_Properties(a->face, &a->properties);
-
- /* create instance */
- if (TT_New_Instance(a->face, &a->instance)) {
- *error = "Could not create face instance";
- return NULL;
- }
-
- if (TT_Set_Instance_Resolutions(a->instance, RESOLUTION, RESOLUTION)) {
- *error = "Could not set device resolutions";
- return NULL;
- }
-
- if (TT_Set_Instance_CharSize(a->instance, (TT_F26Dot6)(a->ptsize*64))) {
- *error = "Could not set character size";
- return NULL;
- }
-
- TT_Get_Instance_Metrics(a->instance, &a->imetrics);
-
- /* First, look for a Unicode charmap */
- n = TT_Get_CharMap_Count(a->face);
-
- for (i = 0; i < n; i++) {
- TT_Get_CharMap_ID(a->face, i, &platform, &encoding);
- if ((platform == 3 && encoding == 1) ||
- (platform == 2 && encoding == 1) ||
- (platform == 0)) {
- TT_Get_CharMap(a->face, i, &a->char_map);
- i = n+1;
- }
- }
-
- if (i == n) {
- *error = "Sorry, but this font doesn't contain any Unicode mapping table";
- return NULL;
- }
-
- a->matrix.xx = (TT_Fixed) (a->cos_a * (1<<16));
- a->matrix.yx = (TT_Fixed) (a->sin_a * (1<<16));
- a->matrix.xy = - a->matrix.yx;
- a->matrix.yy = a->matrix.xx;
-
- a->glyphCache = gdCacheCreate( GLYPHCACHESIZE,
- glyphTest, glyphFetch, glyphRelease);
-
- return (void *)a;
-}
-
-static void
-fontRelease( void *element )
-{
- font_t *a=(font_t *)element;
-
- gdCacheDelete(a->glyphCache);
- TT_Done_Instance(a->instance);
- TT_Close_Face(a->face);
- free(a->fontname);
- free( (char *)element );
-}
-
-/********************************************************************/
-/* glyph cache functions */
-
-static int
-glyphTest ( void *element, void *key )
-{
- glyph_t *a=(glyph_t *)element;
- glyphkey_t *b=(glyphkey_t *)key;
-
- return (a->character == b->character
- && a->hinting == b->hinting
- && a->gray_render == b->gray_render);
-}
-
-static void *
-glyphFetch ( char **error, void *key )
-{
- glyph_t *a;
- glyphkey_t *b=(glyphkey_t *)key;
- short glyph_code;
- int flags, err;
- int crect[8], xmin, xmax, ymin, ymax;
- double cos_a, sin_a;
-
- a = (glyph_t *)malloc(sizeof(glyph_t));
- a->character = b->character;
- a->hinting = b->hinting;
- a->gray_render = b->gray_render;
- a->oldx = a->oldy = 0;
-
- /* create glyph container */
- if ((TT_New_Glyph(b->font->face, &a->glyph))) {
- *error = "Could not create glyph container";
- return NULL;
- }
-
- flags = TTLOAD_SCALE_GLYPH;
- if (a->hinting && b->font->angle == 0.0) {
- flags |= TTLOAD_HINT_GLYPH;
- }
- glyph_code = TT_Char_Index(b->font->char_map, a->character);
- if ((err=TT_Load_Glyph(b->font->instance, a->glyph, glyph_code, flags))) {
- *error = "TT_Load_Glyph problem";
- return NULL;
- }
-
- TT_Get_Glyph_Metrics(a->glyph, &a->metrics);
- if (b->font->angle != 0.0) {
- TT_Get_Glyph_Outline(a->glyph, &a->outline);
- TT_Transform_Outline(&a->outline, &b->font->matrix);
- }
-
- /* calculate bitmap size */
- xmin = a->metrics.bbox.xMin -64;
- ymin = a->metrics.bbox.yMin -64;
- xmax = a->metrics.bbox.xMax +64;
- ymax = a->metrics.bbox.yMax +64;
-
- cos_a = b->font->cos_a;
- sin_a = b->font->sin_a;
- crect[0] = (int)(xmin * cos_a - ymin * sin_a);
- crect[1] = (int)(xmin * sin_a + ymin * cos_a);
- crect[2] = (int)(xmax * cos_a - ymin * sin_a);
- crect[3] = (int)(xmax * sin_a + ymin * cos_a);
- crect[4] = (int)(xmax * cos_a - ymax * sin_a);
- crect[5] = (int)(xmax * sin_a + ymax * cos_a);
- crect[6] = (int)(xmin * cos_a - ymax * sin_a);
- crect[7] = (int)(xmin * sin_a + ymax * cos_a);
- a->xmin = MIN(MIN(crect[0],crect[2]),MIN(crect[4],crect[6]));
- a->xmax = MAX(MAX(crect[0],crect[2]),MAX(crect[4],crect[6]));
- a->ymin = MIN(MIN(crect[1],crect[3]),MIN(crect[5],crect[7]));
- a->ymax = MAX(MAX(crect[1],crect[3]),MAX(crect[5],crect[7]));
-
- /* allocate bitmap large enough for character */
- a->Bit.rows = (a->ymax - a->ymin + 32 + 64) / 64;
- a->Bit.width = (a->xmax - a->xmin + 32 + 64) / 64;
- a->Bit.flow = TT_Flow_Up;
- if (a->gray_render) {
- a->Bit.cols = a->Bit.width; /* 1 byte per pixel */
- }
- else {
- a->Bit.cols = (a->Bit.width + 7) / 8; /* 1 bit per pixel */
- }
- a->Bit.cols = (a->Bit.cols + 3) & ~3; /* pad to 32 bits */
- a->Bit.size = a->Bit.rows * a->Bit.cols; /* # of bytes in buffer */
- a->Bit.bitmap = NULL;
-
- a->bitmapCache = gdCacheCreate( BITMAPCACHESIZE,
- bitmapTest, bitmapFetch, bitmapRelease);
-
- return (void *)a;
-}
-
-static void
-glyphRelease( void *element )
-{
- glyph_t *a=(glyph_t *)element;
-
- gdCacheDelete(a->bitmapCache);
- TT_Done_Glyph( a->glyph );
- free( (char *)element );
-}
-
-/********************************************************************/
-/* bitmap cache functions */
-
-static int
-bitmapTest ( void *element, void *key )
-{
- bitmap_t *a=(bitmap_t *)element;
- bitmapkey_t *b=(bitmapkey_t *)key;
-
- if (a->xoffset == b->xoffset && a->yoffset == b->yoffset) {
- b->glyph->Bit.bitmap = a->bitmap;
- return TRUE;
- }
- return FALSE;
-}
-
-static void *
-bitmapFetch ( char **error, void *key )
-{
- bitmap_t *a;
- bitmapkey_t *b=(bitmapkey_t *)key;
-
- a = (bitmap_t *)malloc(sizeof(bitmap_t));
- a->xoffset = b->xoffset;
- a->yoffset = b->yoffset;
-
- b->glyph->Bit.bitmap = a->bitmap = (char *)malloc(b->glyph->Bit.size);
- memset(a->bitmap, 0, b->glyph->Bit.size);
- /* render glyph */
- if (b->glyph->gray_render) {
- TT_Get_Glyph_Pixmap(b->glyph->glyph, &b->glyph->Bit,
- a->xoffset, a->yoffset);
- }
- else {
- TT_Get_Glyph_Bitmap(b->glyph->glyph, &b->glyph->Bit,
- a->xoffset, a->yoffset);
- }
- return (void *)a;
-}
-
-static void
-bitmapRelease( void *element )
-{
- bitmap_t *a=(bitmap_t *)element;
-
- free( a->bitmap );
- free( (char *)element );
-}
-
-/********************************************************************/
-/* tweencolor cache functions */
-
-static int
-tweenColorTest (void *element, void *key)
-{
- tweencolor_t *a=(tweencolor_t *)element;
- tweencolorkey_t *b=(tweencolorkey_t *)key;
-
- return (a->pixel == b->pixel
- && a->bgcolor == b->bgcolor
- && a->fgcolor == b->fgcolor
- && a->im == b->im);
-}
-
-static void *
-tweenColorFetch (char **error, void *key)
-{
- tweencolor_t *a;
- tweencolorkey_t *b=(tweencolorkey_t *)key;
- int pixel, npixel, bg, fg;
- gdImagePtr im;
-
- a = (tweencolor_t *)malloc(sizeof(tweencolor_t));
- pixel = a->pixel = b->pixel;
- bg = a->bgcolor = b->bgcolor;
- fg = a->fgcolor = b->fgcolor;
- im = b->im;
-
- /* if fg is specified by a negative color idx, then don't antialias */
- if (fg <0) {
- a->tweencolor = -fg;
- } else {
- npixel = NUMCOLORS - pixel;
- a->tweencolor = gdImageColorResolve(im,
- (pixel * im->red [fg] + npixel * im->red [bg]) / NUMCOLORS,
- (pixel * im->green[fg] + npixel * im->green[bg]) / NUMCOLORS,
- (pixel * im->blue [fg] + npixel * im->blue [bg]) / NUMCOLORS);
- }
- *error = NULL;
- return (void *)a;
-}
-
-static void
-tweenColorRelease(void *element)
-{
- free((char *)element);
-}
-
-/********************************************************************/
-/* gdttfchar - render one character onto a gd image */
-
-static int OneTime=0;
-static gdCache_head_t *tweenColorCache;
-
-char *
-gdttfchar(gdImage *im, int fg, font_t *font,
- int x, int y, /* string start pos in pixels */
- TT_F26Dot6 x1, TT_F26Dot6 y1, /* char start offset (*64) from x,y */
- TT_F26Dot6 *advance,
- TT_BBox **bbox,
- char **next)
-{
- int pc, ch, len;
- int row, col;
- int x2, y2; /* char start pos in pixels */
- int x3, y3; /* current pixel pos */
- unsigned char *pixel;
-
- glyph_t *glyph;
- glyphkey_t glyphkey;
- bitmapkey_t bitmapkey;
- tweencolor_t *tweencolor;
- tweencolorkey_t tweencolorkey;
-
- /****** set up tweenColorCache on first call ************/
- if (! OneTime) {
- tweenColorCache = gdCacheCreate(TWEENCOLORCACHESIZE,
- tweenColorTest, tweenColorFetch, tweenColorRelease);
- OneTime++;
- }
- /**************/
-
- len = gdTcl_UtfToUniChar(*next, &ch);
- *next += len;
-
- glyphkey.character = ch;
- glyphkey.hinting = 1;
- /* if fg is specified by a negative color idx, then don't antialias */
- glyphkey.gray_render = ((font->ptsize < MINANTIALIASPTSIZE) || (fg <0))?FALSE:TRUE;
- glyphkey.font = font;
- glyph = (glyph_t *)gdCacheGet(font->glyphCache, &glyphkey);
- if (! glyph)
- return font->glyphCache->error;
-
- *bbox = &glyph->metrics.bbox;
- *advance = glyph->metrics.advance;
-
- /* if null *im, or invalid color, then assume user just wants brect */
- if (!im || fg > 255 || fg < -255)
- return (char *)NULL;
-
- /* render (via cache) a bitmap for the current fractional offset */
- bitmapkey.xoffset = ((x1+32) & 63) - 32 - ((glyph->xmin+32) & -64);
- bitmapkey.yoffset = ((y1+32) & 63) - 32 - ((glyph->ymin+32) & -64);
- bitmapkey.glyph = glyph;
- gdCacheGet(glyph->bitmapCache, &bitmapkey);
-
- /* copy to gif, mapping colors */
- x2 = x + (((glyph->xmin+32) & -64) + ((x1+32) & -64)) / 64;
- y2 = y - (((glyph->ymin+32) & -64) + ((y1+32) & -64)) / 64;
- tweencolorkey.fgcolor = fg;
- tweencolorkey.im = im;
- for (row = 0; row < glyph->Bit.rows; row++) {
- if (glyph->gray_render)
- pc = row * glyph->Bit.cols;
- else
- pc = row * glyph->Bit.cols * 8;
- y3 = y2 - row;
- if (y3 >= im->sy || y3 < 0) continue;
- for (col = 0; col < glyph->Bit.width; col++, pc++) {
- if (glyph->gray_render) {
- tweencolorkey.pixel =
- *((unsigned char *)(glyph->Bit.bitmap) + pc);
- } else {
- tweencolorkey.pixel =
- (((*((unsigned char *)(glyph->Bit.bitmap) + pc/8))
- <<(pc%8))&128)?4:0;
- }
- /* if not background */
- if (tweencolorkey.pixel > 0) {
- x3 = x2 + col;
- if (x3 >= im->sx || x3 < 0) continue;
-#if HAVE_LIBGD13
- pixel = &im->pixels[y3][x3];
-#else
- pixel = &im->pixels[x3][y3];
-#endif
- tweencolorkey.bgcolor = *pixel;
- tweencolor = (tweencolor_t *)gdCacheGet(
- tweenColorCache, &tweencolorkey);
- *pixel = tweencolor->tweencolor;
- }
- }
- }
- return (char *)NULL;
-}
-
-/********************************************************************/
-/* gdttf - render a utf8 string onto a gd image */
-
-char *
-gdttf(gdImage *im, int *brect, int fg, char *fontname,
- double ptsize, double angle, int x, int y, char *string)
-{
- TT_F26Dot6 ur_x=0, ur_y=0, ll_x=0, ll_y=0;
- TT_F26Dot6 advance_x, advance_y, advance, x1, y1;
- TT_BBox *bbox;
- double sin_a, cos_a;
- int i=0, ch;
- font_t *font;
- fontkey_t fontkey;
- char *error, *next;
-
- /****** initialize font engine on first call ************/
- static gdCache_head_t *fontCache;
- static TT_Engine engine;
-
- if (! fontCache) {
- if (TT_Init_FreeType(&engine)) {
- return "Failure to initialize font engine";
- }
- fontCache = gdCacheCreate( FONTCACHESIZE,
- fontTest, fontFetch, fontRelease);
- }
- /**************/
-
- /* get the font (via font cache) */
- fontkey.fontname = fontname;
- fontkey.ptsize = ptsize;
- fontkey.angle = angle;
- fontkey.engine = &engine;
- font = (font_t *)gdCacheGet(fontCache, &fontkey);
- if (! font) {
- return fontCache->error;
- }
- sin_a = font->sin_a;
- cos_a = font->cos_a;
- advance_x = advance_y = 0;
-
- next=string;
- while (*next) {
- ch = *next;
-
- /* carriage returns */
- if (ch == '\r') {
- advance_x = 0;
- next++;
- continue;
- }
- /* newlines */
- if (ch == '\n') {
- advance_y -= (TT_F26Dot6)(font->imetrics.y_ppem * LINESPACE * 64);
- advance_y = (advance_y-32) & -64; /* round to next pixel row */
- next++;
- continue;
- }
-
- x1 = (TT_F26Dot6)(advance_x * cos_a - advance_y * sin_a);
- y1 = (TT_F26Dot6)(advance_x * sin_a + advance_y * cos_a);
-
- if ((error=gdttfchar(im, fg, font, x, y, x1, y1, &advance, &bbox, &next)))
- return error;
-
- if (! i++) { /* if first character, init BB corner values */
- ll_x = bbox->xMin;
- ll_y = bbox->yMin;
- ur_x = bbox->xMax;
- ur_y = bbox->yMax;
- }
- else {
- if (! advance_x) ll_x = MIN(bbox->xMin, ll_x);
- ll_y = MIN(advance_y + bbox->yMin, ll_y);
- ur_x = MAX(advance_x + bbox->xMax, ur_x);
- if (! advance_y) ur_y = MAX(bbox->yMax, ur_y);
- }
- advance_x += advance;
- }
-
- /* rotate bounding rectangle */
- brect[0] = (int)(ll_x * cos_a - ll_y * sin_a);
- brect[1] = (int)(ll_x * sin_a + ll_y * cos_a);
- brect[2] = (int)(ur_x * cos_a - ll_y * sin_a);
- brect[3] = (int)(ur_x * sin_a + ll_y * cos_a);
- brect[4] = (int)(ur_x * cos_a - ur_y * sin_a);
- brect[5] = (int)(ur_x * sin_a + ur_y * cos_a);
- brect[6] = (int)(ll_x * cos_a - ur_y * sin_a);
- brect[7] = (int)(ll_x * sin_a + ur_y * cos_a);
-
- /* scale, round and offset brect */
- i = 0;
- while (i<8) {
- brect[i] = x + (brect[i] + 32) / 64;
- i++;
- brect[i] = y - (brect[i] + 32) / 64;
- i++;
- }
-
- return (char *)NULL;
-}
-
-#endif /* HAVE_LIBTTF|HAVE_LIBFREETYPE */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/gd/gdttf.h b/ext/gd/gdttf.h
deleted file mode 100644
index 86a5eca1fe..0000000000
--- a/ext/gd/gdttf.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* $Id$ */
-
-#ifdef _OSD_POSIX
-#ifndef APACHE
-#error On this EBCDIC platform, PHP3 is only supported as an Apache module.
-#else /*APACHE*/
-#ifndef CHARSET_EBCDIC
-#define CHARSET_EBCDIC /* this machine uses EBCDIC, not ASCII! */
-#endif
-#include "ebcdic.h"
-#endif /*APACHE*/
-#endif /*_OSD_POSIX*/
-
-char * gdttf(gdImage *im, int *brect, int fg, char *fontname,
- double ptsize, double angle, int x, int y, char *string);
-
diff --git a/ext/gd/php3_gd.h b/ext/gd/php3_gd.h
deleted file mode 100644
index d15ff9b9e7..0000000000
--- a/ext/gd/php3_gd.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Stig Bakken <ssb@guardian.no> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _PHP3_GD_H
-#define _PHP3_GD_H
-
-
-#if HAVE_LIBTTF|HAVE_LIBFREETYPE
-#define ENABLE_GD_TTF
-#endif
-
-#if COMPILE_DL
-#undef HAVE_LIBGD
-#define HAVE_LIBGD 1
-#endif
-
-#if HAVE_LIBGD
-
-#include <gd.h>
-
-extern php3_module_entry gd_module_entry;
-#define phpext_gd_ptr &gd_module_entry
-
-/* gd.c functions */
-PHP_MINFO_FUNCTION(gd);
-extern PHP_MINIT_FUNCTION(gd);
-extern PHP_MSHUTDOWN_FUNCTION(gd);
-
-extern int gdImageColorResolve(gdImagePtr, int, int, int);
-PHP_FUNCTION(imagearc);
-PHP_FUNCTION(imagechar);
-PHP_FUNCTION(imagecharup);
-PHP_FUNCTION(imagecolorallocate);
-PHP_FUNCTION(imagecolorat);
-PHP_FUNCTION(imagecolorclosest);
-PHP_FUNCTION(imagecolordeallocate);
-PHP_FUNCTION(imagecolorresolve);
-PHP_FUNCTION(imagecolorexact);
-PHP_FUNCTION(imagecolorset);
-PHP_FUNCTION(imagecolorstotal);
-PHP_FUNCTION(imagecolorsforindex);
-PHP_FUNCTION(imagecolortransparent);
-PHP_FUNCTION(imagecopy);
-PHP_FUNCTION(imagecopyresized);
-PHP_FUNCTION(imagecreate);
-PHP_FUNCTION(imagecreatefromgif );
-PHP_FUNCTION(imagedestroy);
-PHP_FUNCTION(imagefill);
-PHP_FUNCTION(imagefilledpolygon);
-PHP_FUNCTION(imagefilledrectangle);
-PHP_FUNCTION(imagefilltoborder);
-PHP_FUNCTION(imagefontwidth);
-PHP_FUNCTION(imagefontheight);
-PHP_FUNCTION(imagegif );
-PHP_FUNCTION(imageinterlace);
-PHP_FUNCTION(imageline);
-PHP_FUNCTION(imageloadfont);
-PHP_FUNCTION(imagepolygon);
-PHP_FUNCTION(imagerectangle);
-PHP_FUNCTION(imagesetpixel);
-PHP_FUNCTION(imagestring);
-PHP_FUNCTION(imagestringup);
-PHP_FUNCTION(imagesx);
-PHP_FUNCTION(imagesy);
-void php3_free_gd_font(gdFontPtr);
-void _php3_gdimagecharup(gdImagePtr, gdFontPtr, int, int, int, int);
-PHP_FUNCTION(imagedashedline);
-#ifdef ENABLE_GD_TTF
-PHP_FUNCTION(imagettfbbox);
-PHP_FUNCTION(imagettftext);
-#endif
-#else
-
-#define phpext_gd_ptr NULL
-
-#endif
-
-#endif /* _PHP3_GD_H */
diff --git a/ext/gd/setup.stub b/ext/gd/setup.stub
deleted file mode 100644
index 64668ae0fb..0000000000
--- a/ext/gd/setup.stub
+++ /dev/null
@@ -1,6 +0,0 @@
-define_option with-gd 'GD support?' yesnodir \
- "yes /usr GD install" \
-' Whether to include GD support. If PHP can find the GD libraries\n
- on your system, it will be included automatically. You should enter\n
- something here if you do not want to include GD support or if you\n
- have installed GD in some unusual directory.'
diff --git a/ext/gettext/Makefile.am b/ext/gettext/Makefile.am
deleted file mode 100644
index 295ca2c889..0000000000
--- a/ext/gettext/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_gettext.a
-libphpext_gettext_a_SOURCES=gettext.c
-
diff --git a/ext/gettext/config.h.stub b/ext/gettext/config.h.stub
deleted file mode 100644
index 54fe1349ce..0000000000
--- a/ext/gettext/config.h.stub
+++ /dev/null
@@ -1,3 +0,0 @@
-/* define if you want to use the gettext extension */
-
-#define HAVE_LIBINTL 0
diff --git a/ext/gettext/config.m4 b/ext/gettext/config.m4
deleted file mode 100644
index b14673527a..0000000000
--- a/ext/gettext/config.m4
+++ /dev/null
@@ -1,45 +0,0 @@
-dnl $Id$
-dnl config.m4 for extension gettext
-dnl don't forget to call PHP_EXTENSION(gettext)
-
-AC_MSG_CHECKING(whether to include GNU gettext support)
-AC_ARG_WITH(gettext,
-[ --with-gettext[=DIR] Include GNU gettext support. DIR is the gettext
- install directory, defaults to /usr/local],
-[
- if test "$withval" != "no"; then
- if test "$withval" = "yes"; then
- GETTEXT_INCDIR=/usr/local/include
- test -f /usr/local/include/libintl.h && GETTEXT_INCDIR=/usr/local/include/
- GETTEXT_LIBDIR=/usr/local/lib
- else
- GETTEXT_INCDIR=$withval/include
- test -f $withval/include/libintl.h && GETTEXT_INCDIR=$withval/include
- GETTEXT_LIBDIR=$withval/lib
- fi
- GETTEXT_INCLUDE=-I$GETTEXT_INCDIR
- GETTEXT_LFLAGS=-L$GETTEXT_LIBDIR
- O_CPPFLAGS="$CPPFLAGS"
- O_LDFLAGS=$LDFLAGS
- CPPFLAGS="$CPPFLAGS -I$GETTEXT_INCDIR"
- LDFLAGS="$LDFLAGS -L$GETTEXT_LIBDIR"
- GETTEXT_LIBS=
- AC_MSG_RESULT(yes)
- AC_CHECK_LIB(intl, bindtextdomain, GETTEXT_LIBS="-lintl",[
- AC_CHECK_LIB(c, bindtextdomain, GETTEXT_LIBS=,[
- AC_MSG_ERROR(Unable to find required gettext library)
- ],)
- ],)
-
- AC_DEFINE(HAVE_LIBINTL)
- PHP_EXTENSION(gettext)
-
- EXTRA_LIBS="$EXTRA_LIBS $GETTEXT_LFLAGS $GETTEXT_LIBS"
- INCLUDES="$INCLUDES $GETTEXT_INCLUDE"
-
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
diff --git a/ext/gettext/gettext.c b/ext/gettext/gettext.c
deleted file mode 100644
index 6eb422daf1..0000000000
--- a/ext/gettext/gettext.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Alex Plotnick <alex@wgate.com> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include <stdio.h>
-#include "php.h"
-#include "php3_gettext.h"
-
-#if HAVE_LIBINTL
-
-#include <libintl.h>
-
-function_entry php3_gettext_functions[] = {
- PHP_FE(textdomain, NULL)
- PHP_FE(gettext, NULL)
- PHP_FALIAS(_, gettext, NULL)
- PHP_FE(dgettext, NULL)
- PHP_FE(dcgettext, NULL)
- PHP_FE(bindtextdomain, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry php3_gettext_module_entry = {
- "gettext", php3_gettext_functions, NULL, NULL, NULL, NULL, PHP_MINFO(gettext), STANDARD_MODULE_PROPERTIES
-};
-
-PHP_MINFO_FUNCTION(gettext)
-{
- php_printf("GNU gettext support active.");
-}
-
-PHP_FUNCTION(textdomain)
-{
- pval *domain;
- char *domain_name, *retval;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &domain) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(domain);
-
- if (strcmp(domain->value.str.val, "")
- && strcmp(domain->value.str.val, "0"))
- {
- domain_name = domain->value.str.val;
- } else {
- domain_name = NULL;
- }
-
- retval = textdomain(domain_name);
-
- RETURN_STRING(retval, 1);
-}
-
-PHP_FUNCTION(gettext)
-{
- pval *msgid;
- char *msgstr;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &msgid) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(msgid);
-
- msgstr = gettext(msgid->value.str.val);
-
- RETURN_STRING(msgstr, 1);
-}
-
-PHP_FUNCTION(dgettext)
-{
- pval *domain_name, *msgid;
- char *msgstr;
-
- if (ARG_COUNT(ht) != 2
- || getParameters(ht, 2, &domain_name, &msgid) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(domain_name);
- convert_to_string(msgid);
-
- msgstr = dgettext(domain_name->value.str.val, msgid->value.str.val);
-
- RETURN_STRING(msgstr, 1);
-}
-
-PHP_FUNCTION(dcgettext)
-{
- pval *domain_name, *msgid, *category;
- char *msgstr;
-
- if (ARG_COUNT(ht) != 3
- || getParameters(ht, 3, &domain_name, &msgid, &category) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(domain_name);
- convert_to_string(msgid);
- convert_to_long(category);
-
- msgstr = dcgettext(domain_name->value.str.val,
- msgid->value.str.val,
- category->value.lval);
-
- RETURN_STRING(msgstr, 1);
-}
-
-PHP_FUNCTION(bindtextdomain)
-{
- pval *domain_name, *dir;
- char *retval, *dir_name;
-
- if (ARG_COUNT(ht) != 2
- || getParameters(ht, 2, &domain_name, &dir) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(domain_name);
- convert_to_string(dir);
-
- if (strcmp(dir->value.str.val, "")
- && strcmp(dir->value.str.val, "0"))
- {
- dir_name = dir->value.str.val;
- } else {
- dir_name = NULL;
- }
-
- retval = bindtextdomain(domain_name->value.str.val, dir_name);
-
- RETURN_STRING(retval, 1);
-}
-
-#endif /* HAVE_LIBINTL */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/gettext/php3_gettext.h b/ext/gettext/php3_gettext.h
deleted file mode 100644
index e01d041b94..0000000000
--- a/ext/gettext/php3_gettext.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Author: Alex Plotnick <alex@wgate.com> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _GETTEXT_H
-#define _GETTEXT_H
-
-#if HAVE_LIBINTL
-#ifndef INIT_FUNC_ARGS
-#include "modules.h"
-#endif
-
-extern php3_module_entry php3_gettext_module_entry;
-#define gettext_module_ptr &php3_gettext_module_entry
-
-PHP_MINFO_FUNCTION(gettext);
-
-PHP_FUNCTION(textdomain);
-PHP_FUNCTION(gettext);
-PHP_FUNCTION(dgettext);
-PHP_FUNCTION(dcgettext);
-PHP_FUNCTION(bindtextdomain);
-
-#else
-#define gettext_module_ptr NULL
-#endif /* HAVE_LIBINTL */
-
-#define phpext_gettext_ptr gettext_module_ptr
-
-#endif /* _GETTEXT_H */
diff --git a/ext/gettext/setup.stub b/ext/gettext/setup.stub
deleted file mode 100644
index cc9fdd43c8..0000000000
--- a/ext/gettext/setup.stub
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-define_option with-gettext 'gettext support?' yesnodir \
- "yes /usr/local" \
-' Whether to include gettext support.'
-
diff --git a/ext/hyperwave/Makefile.am b/ext/hyperwave/Makefile.am
deleted file mode 100644
index c5be33e128..0000000000
--- a/ext/hyperwave/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_hyperwave.a
-libphpext_hyperwave_a_SOURCES=hw.c hg_comm.c
-
diff --git a/ext/hyperwave/config.h.stub b/ext/hyperwave/config.h.stub
deleted file mode 100644
index d8e8bf43ab..0000000000
--- a/ext/hyperwave/config.h.stub
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Define if you want Hyperwave support */
-#define HYPERWAVE 0
diff --git a/ext/hyperwave/config.m4 b/ext/hyperwave/config.m4
deleted file mode 100644
index ef48f24954..0000000000
--- a/ext/hyperwave/config.m4
+++ /dev/null
@@ -1,18 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(for Hyperwave support)
-AC_ARG_WITH(hyperwave,
-[ --with-hyperwave Include Hyperwave support],
-[
- if test "$withval" != "no"; then
- AC_DEFINE(HYPERWAVE,1)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(hyperwave)
- else
- AC_DEFINE(HYPERWAVE,0)
- AC_MSG_RESULT(no)
- fi
-],[
- AC_DEFINE(HYPERWAVE,0)
- AC_MSG_RESULT(no)
-])
diff --git a/ext/hyperwave/debug.h b/ext/hyperwave/debug.h
deleted file mode 100644
index 7b6756a5ab..0000000000
--- a/ext/hyperwave/debug.h
+++ /dev/null
@@ -1,194 +0,0 @@
-/****************************************************************************
-*
-* Copyright (C) 1991 Kendall Bennett.
-* All rights reserved.
-*
-* Filename: $RCSfile$
-* Version: $Revision$
-*
-* Language: ANSI C
-* Environment: any
-*
-* Description: General header file for portable code.
-*
-* $Id$
-*
-* Revision History:
-* -----------------
-*
-* $Log$
-* Revision 1.1.1.1 1999/04/07 21:03:29 zeev
-* PHP 4.0
-*
-* Revision 1.1.1.1 1999/03/17 04:29:10 andi
-* PHP4
-*
-* Revision 1.1.1.1 1998/12/21 07:56:22 andi
-* Trying to start the zend CVS tree
-*
-* Revision 1.1 1998/08/12 09:29:16 steinm
-* First version of Hyperwave module.
-*
-* Revision 1.6 92/03/15 12:51:48 kjb
-* Added MK_FP macro and ushort typedef.
-*
-* Revision 1.5 91/10/28 03:17:33 kjb
-* Ported to the Iris.
-*
-* Revision 1.4 91/09/26 15:29:02 kjb
-* Added stuff for the SGI Iris 4D.
-*
-* Revision 1.3 91/09/26 10:07:04 kjb
-* Added general typedef stuff.
-*
-* Revision 1.2 91/09/03 18:19:14 ROOT_DOS
-* Added a few defines that are supplied by <dir.h> for UNIX compatibility.
-*
-* Revision 1.1 91/08/16 13:19:06 ROOT_DOS
-* Initial revision
-*
-****************************************************************************/
-
-#ifndef __DEBUG_H
-#define __DEBUG_H
-
-#ifdef DEBUG
-# define D(x) x
-#else
-# define D(x)
-#endif
-
-#define PRIVATE static
-#define PUBLIC
-
-#ifdef __MSDOS__ /* Compiling for MSDOS */
-# define MS(x) x
-# define UX(x)
-# define IR(x)
-# define _8086 /* We know we have an 8086 type processor */
-#if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
-# define LDATA
-# define NULL 0L
-#else
-# define NULL 0
-#endif
-#else __MSDOS__
-#ifdef __IRIS4D__ /* Compiling for the SGI Iris 4D */
-# define MS(x)
-# define UX(x) x /* The Iris is a UNIX machine */
-# define IR(x) x
-# define O_BINARY 0 /* no binary input mode in UNIX open() */
-# define MAXFILE 255 /* These are defined in <dir.h>, but */
-# define MAXDIR 255 /* on UNIX machines, we just define */
-# define MAXPATH 255 /* them all to be the same size */
-# define far /* Near and far do not exist under */
-# define near /* UNIX or the Iris. */
-# define NULL ((void *)0)
-#else __IRIS4D__ /* Assume UNIX compilation */
-# define MS(x)
-# define UX(x) x
-# define IR(x)
-# define O_BINARY 0 /* no binary input mode in UNIX open() */
-# define MAXFILE 255 /* These are defined in <dir.h>, but */
-# define MAXDIR 255 /* on UNIX machines, we just define */
-# define MAXPATH 255 /* them all to be the same size */
-# define far /* Near and far do not exist under */
-# define near /* UNIX or the Iris. */
-# ifndef NULL
-# define NULL ((void *)0)
-# endif
-#endif __IRIS4D__
-#endif __MSDOS__
-
-/****************************************************************************
-*
-* SEG(p) Evaluates to the segment portion of an 8086 address.
-* OFF(p) Evaluates to the offset portion of an 8086 address.
-* FP(s,o) Creates a far pointer given a segment offset pair.
-* PHYS(p) Evaluates to a long holding a physical address
-*
-****************************************************************************/
-
-#ifdef _8086
-# define SEG(p) ( ((unsigned *)&(void far *)(p))[1] )
-# define OFF(p) ( (unsigned)(p) )
-# define FP(s,o) ( (void far *)( ((unsigned long)s << 16) + \
- (unsigned long)o ))
-# define PHYS(p) ( (unsigned long)OFF(p) + \
- ((unsigned long)SEG(p) << 4))
-#else
-# define PHYS(p) (p)
-#endif _8086
-
-/****************************************************************************
-*
-* NUMELE(array) Evaluates to the array size in elements
-* LASTELE(array) Evaluates to a pointer to the last element
-* INBOUNDS(array,p) Evaluates to true if p points into the array
-* RANGE(a,b,c) Evaluates to true if a <= b <= c
-* max(a,b) Evaluates to a or b, whichever is larger
-* min(a,b) Evaluates to a or b, whichever is smaller
-* ABS(a) Evaluates to the absolute value of a
-* NBITS(type) Returns the number of bits in a variable of the
-* indicated type
-* MAXINT Evaluates to the value of the largest signed integer
-*
-****************************************************************************/
-
-#define NUMELE(a) (sizeof(a)/sizeof(*(a)))
-#define LASTELE(a) ((a) + (NUMELE(a)-1))
-#ifdef LDATA
-#define TOOHIGH(a,p) ((long)PHYS(p) - (long)PHYS(a) > (long)(NUMELE(a)-1))
-#define TOOLOW(a,p) ((long)PHYS(p) - (long)PHYS(a) < 0)
-#else
-#define TOOHIGH(a,p) ((long)(p) - (long)(a) > (long)(NUMELE(a)-1))
-#define TOOLOW(a,p) ((long)(p) - (long)(a) < 0)
-#endif
-#define INBOUNDS(a,p) ( ! (TOOHIGH(a,p) || TOOLOW(a,p)) )
-
-#define _IS(t,x) (((t)1 << (x)) != 0) /* Evaluates true if the width of */
- /* variable of type t is < x. */
- /* The != 0 assures that the */
- /* answer is 1 or 0 */
-
-#define NBITS(t) (4 * (1 + _IS(t,4) + _IS(t,8) + _IS(t,12) + _IS(t,16) \
- + _IS(t,20) + _IS(t,24) + _IS(t,28) + _IS(t,32)))
-
-#define MAXINT (((unsigned)~0) >> 1)
-
-#ifndef MAX
-# define MAX(a,b) ( ((a) > (b)) ? (a) : (b))
-#endif
-#ifndef MIN
-# define MIN(a,b) ( ((a) < (b)) ? (a) : (b))
-#endif
-#ifndef ABS
-# define ABS(a) ((a) >= 0 ? (a) : -(a))
-#endif
-
-#define RANGE(a,b,c) ( (a) <= (b) && (b) <= (c) )
-
-/* General typedefs */
-
-#ifndef __GENDEFS
-#define __GENDEFS
-typedef void *ptr;
-typedef void near *nearptr;
-typedef void far *farptr;
-/*typedef unsigned char uchar;
-typedef unsigned short ushort;
-typedef unsigned int uint;
-typedef unsigned long ulong;*/
-typedef int bool;
-#endif __GENDEFS
-
-/* Boolean truth values */
-
-#define false 0
-#define true 1
-#define FALSE 0
-#define TRUE 1
-#define NO 0
-#define YES 1
-
-#endif __DEBUG_H
diff --git a/ext/hyperwave/hg_comm.c b/ext/hyperwave/hg_comm.c
deleted file mode 100644
index 89b78ebdef..0000000000
--- a/ext/hyperwave/hg_comm.c
+++ /dev/null
@@ -1,4859 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Uwe Steinmann |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/* #define HW_DEBUG */
-
-#include <stdlib.h>
-#include "php.h"
-#include "php_globals.h"
-#include "SAPI.h"
-
-#if HYPERWAVE
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#if WIN32|WINNT
-# include <winsock2.h>
-# define EWOULDBLOCK WSAEWOULDBLOCK
-# define ETIMEDOUT WSAETIMEDOUT
-# define bcopy memcpy
-# define bzero(a,b) memset(a,0,b)
-#else
-# include <sys/socket.h>
-# include <netinet/in.h>
-# include <netdb.h>
-# include <unistd.h>
-# include <sys/param.h>
-#endif
-#include <fcntl.h>
-#include <errno.h>
-#include "hg_comm.h"
-#include "dlist.h"
-#include "ext/standard/head.h"
-
-static int set_nonblocking(int fd);
-static int set_blocking(int fd);
-
-static int hg_read_exact(int sockfd, char *buf, int size);
-static int hg_read(int sockfd, char *buf, int size);
-static int hg_write(int sockfd, char *buf, int size);
-
-static int send_hg_msg(int sockfd, hg_msg *msg, int length);
-static void build_msg_header(hg_msg *msg, int length, int version_msgid, int msg_type);
-static char *build_msg_int(char *buf, int val);
-static char *build_msg_str(char *buf, char *str);
-static int swap(int val);
-
-
-int version = HW_VERSION;
-/* F_DISTRIBUTED has the effect that all object ids are
- virtual. This means whenever an object is requested a
- new id is generated for this session. Wavemaster and
- Harmony set this flag. How do I know? tcpdump tells
- a lot if investigate the output.
- int version = HW_VERSION | F_DISTRIBUTED; */
-/* int version = HW_VERSION | F_DISTRIBUTED | F_COMPRESSED; */
-static int msgid = 1;
-static int sock_flags = -1;
-static int non_blocking = 0;
-static int swap_on = 0;
-static int rtimeout = 40;
-static int wtimeout = 40;
-static int lowerror = 0;
-
-/***********************************************************************
-* Function fnInsStr() *
-* *
-* Insert string in string at position. The old string will be freed *
-* with efree!!! The new string is allocated with malloc. *
-* Parameter: string *str: string in which insstr is to be inserted *
-* int pos: Position where string is to inserted (0=first) *
-* string *insstr: string to be inserted *
-* Return: pointer to new string or NULL. If NULL is returned the *
-* memory for the old string has not been freed. *
-***********************************************************************/
-char *fnInsStr(char *str, int pos, char *insstr)
-{
- char *newstr, *ptr;
-
- if((str == NULL) || (insstr == NULL))
- return NULL;
- if(pos > (int)strlen(str))
- return NULL;
-
- if(insstr[0] == '\0')
- return str;
-
- if(NULL == (newstr = malloc(strlen(str) + strlen(insstr) + 1))) {
- lowerror = LE_MALLOC;
- return NULL;
- }
-
- ptr = newstr;
- memcpy(newstr, str, pos);
- ptr += pos;
- strcpy(ptr, insstr);
- ptr += strlen(insstr);
- strcpy(ptr, str+pos);
-
- free(str);
- return newstr;
-}
-
-/***********************************************************************
-* Function fnAddAnchor() *
-* *
-* Inserts new anchor into anchor list. *
-* Parameter: DLIST pList: Anchor list *
-* int objectID: object ID of Anchor *
-* int start: start position *
-* int end: end position *
-* Return: Pointer to new anchor, NULL if error *
-***********************************************************************/
-ANCHOR *fnAddAnchor(DLIST *pAnchorList,
- int objectID,
- int start, int end)
-{
- ANCHOR *cur_ptr;
-
- if((cur_ptr = (ANCHOR *) dlst_newnode(sizeof(ANCHOR))) == NULL) {
- return NULL;
- }
-
- memset(cur_ptr, 0, sizeof(ANCHOR));
- cur_ptr->start = start;
- cur_ptr->end = end;
- cur_ptr->id = objectID;
- cur_ptr->destdocname = NULL;
- cur_ptr->nameanchor = NULL;
- cur_ptr->link = NULL;
- cur_ptr->tagattr = NULL;
- cur_ptr->htmlattr = NULL;
- cur_ptr->codebase = NULL;
- cur_ptr->code = NULL;
- cur_ptr->keyword = NULL;
- cur_ptr->fragment = NULL;
-
- dlst_insertafter(pAnchorList, cur_ptr, PHP_DLST_HEAD(pAnchorList));
-
- return(cur_ptr);
-}
-
-/***********************************************************************
-* Function fnDeleteAnchor() *
-* *
-* Inserts new anchor into anchor list. *
-* Parameter: ptr: pointer to node *
-* Return: void *
-***********************************************************************/
-void fnDeleteAnchor(ANCHOR *ptr)
-{
-
- if(ptr->destdocname) efree(ptr->destdocname);
- if(ptr->nameanchor) efree(ptr->nameanchor);
- if(ptr->link) efree(ptr->link);
- if(ptr->tagattr) efree(ptr->tagattr);
- if(ptr->htmlattr) efree(ptr->htmlattr);
- if(ptr->codebase) efree(ptr->codebase);
- if(ptr->code) efree(ptr->code);
- if(ptr->keyword) efree(ptr->keyword);
- if(ptr->fragment) efree(ptr->fragment);
-
- dlst_freenode(ptr);
-}
-
-/***********************************************************************
-* Function fnCmpAnchors() *
-* *
-* Compares to Anchors by its start position *
-* Parameter: ANCHOR a1: First Anchor *
-* ANCHOR a2: Second Anchor *
-* Return: As strcmp *
-***********************************************************************/
-int fnCmpAnchors(ANCHOR *a1, ANCHOR *a2)
-{
- if(a1->start < a2->start)
- return -1;
- if(a1->start == a2->start) {
- /* It's importent to check this case as well, because a link with
- a bigger end has to be inserted first.
- */
- if(a1->end < a2->end)
- return -1;
- /* If both start and end are equal (yes, it is possible)
- we will Src Anchor before a Dest anchor. There has been
- a case where an IMG was surrounded by a NAME which was
- surrounded by a HREF. In such a case the HREF doesn't
- work.
- */
- if(a1->end == a2->end) {
- if(a1->tanchor > a2->tanchor)
- return -1;
- }
- }
-
- return 1;
-}
-
-/***********************************************************************
-* Function fnCreateAnchorList() *
-* *
-* Returns a list of Anchors converted from an object record *
-* Parameter: char **anchors: object records of anchors *
-* char **dest: object records of destinations *
-* int ancount: number of anchors *
-* Return: List of Anchors, NULL if error *
-***********************************************************************/
-DLIST *fnCreateAnchorList(char **anchors, char **docofanchorrec, char **reldestrec, int ancount, int anchormode)
-{
- int start, end, i, destid, anchordestid, objectID;
- ANCHOR *cur_ptr = NULL;
- DLIST *pAnchorList = dlst_init();
-
- for(i=ancount-1; i>=0; i--) {
- char *object = NULL;
- char *docofanchorptr = NULL;
- char *reldestptr = NULL;
- char *str, *str1, link[200];
-
- if(NULL != anchors[i]) {
- object = anchors[i];
- docofanchorptr = docofanchorrec[i];
- reldestptr = reldestrec[i];
-
- /* Determine Position. Doesn't matter if Src or Dest
- The Position field should always be there. Though there
- are case in which the position has no meaning, e.g. if
- a document is annotated and the annotation text doesn't
- contain a link of type annotation,
- In such a case the Position has the value 'invisible' */
- str = strstr(object, "Position");
- str += 9;
- if(0 != strncmp(str, "invisible", 9)) {
- sscanf(str, "0x%X 0x%X", &start, &end);
-
- /* Determine ObjectID */
- objectID = 0;
- if(NULL != (str = strstr(object, "ObjectID"))) {
- str += 9;
- sscanf(str, "0x%X", &objectID);
- }
-
- cur_ptr = fnAddAnchor(pAnchorList, objectID, start, end);
-
- /* Determine Type of Anchor */
- str = strstr(object, "TAnchor");
- str += 8;
- if(*str == 'S') {
- char destdocname[200];
- char nameanchor[200];
- cur_ptr->tanchor = 1;
-
- cur_ptr->destdocname = NULL;
- if(NULL != (str = strstr(object, "Dest"))) {
- char *tempptr;
-
- /* No need to care about the value of Dest, because we take the info
- from docofanchorptr.
- Since the anchor has a destination there are two possibilities.
- 1. The destination is an anchor or
- 2. or the destination is a document already.
- In both cases docofanchorptr has the proper info because GETDOCBYANCHOR
- is such a nice message.
- */
- switch(anchormode) {
- case 0:
- tempptr = docofanchorptr;
- break;
- default:
- tempptr = reldestptr;
- }
- if(NULL != tempptr) {
- /* It's always nice to deal with names, so let's first check
- for a name. If there is none we take the ObjectID.
- */
- if(NULL != (str = strstr(tempptr, "Name="))) {
- str += 5;
- } else if(NULL != (str = strstr(tempptr, "ObjectID="))) {
- str += 9;
- }
- if(sscanf(str, "%s\n", destdocname)) {
- cur_ptr->destdocname = estrdup(destdocname);
- }
- destid = 0;
- if(NULL != (str = strstr(tempptr, "ObjectID="))) {
- str += 9;
- sscanf(str, "0x%X", &destid);
- }
- }
- }
-
- /* Get the Id of the anchor destination and the document id that belongs
- to that anchor. We need that soon in order to determine if the anchor
- points to a document or a dest anchor in a document.
- */
- anchordestid = 0;
- if(NULL != (str = strstr(object, "Dest="))) {
- str += 5;
- sscanf(str, "0x%X", &anchordestid);
- }
-
- /* if anchordestid != destid then the destination is an anchor in a document whose
- name (objectID) is already in destdocname. We will have to extend the link
- by '#...'
- */
- cur_ptr->nameanchor = NULL;
- if(anchordestid != destid) {
- if(NULL != (str = strstr(object, "Dest="))) {
- str += 5;
- if(sscanf(str, "%s\n", nameanchor))
- cur_ptr->nameanchor = estrdup(nameanchor);
- }
- }
-
- if(!cur_ptr->destdocname) {
- cur_ptr->link = NULL;
- if(NULL != (str = strstr(object, "Hint=URL:"))) {
- str += 9;
- if(sscanf(str, "%s\n", link))
- cur_ptr->link = estrdup(link);
- } else if(NULL != (str = strstr(object, "Hint="))) {
- str += 5;
- if(sscanf(str, "%s\n", link))
- cur_ptr->link = estrdup(link);
- }
- }
-
- cur_ptr->fragment = NULL;
- if(NULL != (str = strstr(object, "Fragment="))) {
- str += 9;
- if(sscanf(str, "%s\n", link))
- cur_ptr->fragment = estrdup(link);
- }
-
- cur_ptr->htmlattr = NULL;
- if(NULL != (str = strstr(object, "HtmlAttr="))) {
- str += 9;
- str1 = str;
- while((*str1 != '\n') && (*str1 != '\0'))
- str1++;
- cur_ptr->htmlattr = emalloc(str1 - str + 1);
- strncpy(cur_ptr->htmlattr, str, str1 - str);
- cur_ptr->htmlattr[str1 - str] = '\0';
- }
-
- if(NULL != (str = strstr(object, "LinkType="))) {
- str += 9;
- if(strncmp(str, "background", 10) == 0)
- cur_ptr->linktype=HW_BACKGROUND_LINK;
- else
- if(strncmp(str, "intag", 5) == 0) {
- cur_ptr->linktype=HW_INTAG_LINK;
- cur_ptr->tagattr = NULL;
- if(NULL != (str = strstr(object, "TagAttr="))) {
- str += 8;
- str1 = str;
- while((*str1 != '\n') && (*str1 != '\0'))
- str1++;
- cur_ptr->tagattr = emalloc(str1 - str + 1);
- memcpy(cur_ptr->tagattr, str, str1 - str);
- cur_ptr->tagattr[str1 - str] = '\0';
- }
- } else
- if(strncmp(str, "applet", 6) == 0) {
- cur_ptr->linktype=HW_APPLET_LINK;
- cur_ptr->codebase = NULL;
- if(NULL != (str = strstr(object, "CodeBase="))) {
- str += 9;
- str1 = str;
- while((*str1 != '\n') && (*str1 != '\0'))
- str1++;
- cur_ptr->codebase = emalloc(str1 - str + 1);
- memcpy(cur_ptr->codebase, str, str1 - str);
- cur_ptr->codebase[str1 - str] = '\0';
- }
- cur_ptr->code = NULL;
- if(NULL != (str = strstr(object, "Code="))) {
- str += 5;
- str1 = str;
- while((*str1 != '\n') && (*str1 != '\0'))
- str1++;
- cur_ptr->code = emalloc(str1 - str + 1);
- memcpy(cur_ptr->code, str, str1 - str);
- cur_ptr->code[str1 - str] = '\0';
- }
- } else
- cur_ptr->linktype=HW_DEFAULT_LINK;
- } else
- cur_ptr->linktype=HW_DEFAULT_LINK;
-
- } else { /* Destination Anchor */
- char nameanchor[200];
-
- cur_ptr->tanchor = 2;
- cur_ptr->link = NULL;
-
- /* Here is the only additional info for the name attribute */
- cur_ptr->nameanchor = NULL;
- if(NULL != (str = strstr(object, "ObjectID="))) {
- str += 9;
- if(sscanf(str, "%s\n", nameanchor))
- cur_ptr->nameanchor = estrdup(nameanchor);
- }
-
- cur_ptr->keyword = NULL;
- if(NULL != (str = strstr(object, "Keyword="))) {
- str += 8;
- if(sscanf(str, "%s\n", nameanchor))
- cur_ptr->keyword = estrdup(nameanchor);
- }
-
- }
-
- efree(anchors[i]);
- if(docofanchorrec[i]) efree(docofanchorrec[i]);
- if(reldestrec[i]) efree(reldestrec[i]);
- }
- }
- }
- return pAnchorList;
-}
-
-/***********************************************************************
-* Function fnInsAnchorsIntoText() *
-* *
-* Returns the text document with all anchors inserted form list *
-* Parameter: char *text: text without anchors *
-* DList *pAnchorList: list of anchors *
-* Return: Text with anchors *
-***********************************************************************/
-#define BUFFERLEN 200
-char *fnInsAnchorsIntoText(char *text, DLIST *pAnchorList, char **bodytag, char *urlprefix) {
- ANCHOR *cur_ptr;
- char bgstr[BUFFERLEN], istr[BUFFERLEN];
- char *scriptname;
- char *newtext;
- int offset = 0;
- int laststart=0;
-
-/* The following is very tricky and depends on how rewriting is setup on your webserver.
- If you skip the scriptname in the url you will have to map each hyperwave name to http://<hwname>.
- This may not always be a good idea. The best solution is probably to provide a prefix for such
- a case which is an optional parameter to hw_gettext hw_pipedocument.
-*/
- if(urlprefix) {
- scriptname = urlprefix;
- } else {
-#if APACHE
- {
- int j;
- array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env);
- table_entry *elts = (table_entry *)arr->elts;
-
- for (j=0; j < arr->nelts; j++) {
- if(0 == strcmp(elts[j].key, "SCRIPT_NAME"))
- break;
- }
- scriptname = elts[j].val;
- }
-#else
- scriptname = getenv("SCRIPT_FILENAME");
-#endif
- }
-
- newtext = text;
- bgstr[0] = '\0';
- dlst_mergesort(pAnchorList, fnCmpAnchors);
-
- cur_ptr = (ANCHOR *) dlst_last(pAnchorList);
- while(NULL != cur_ptr) {
- istr[0] = '\0';
- if(cur_ptr->tanchor == 1) { /* Src Anchor */
- if(laststart >= cur_ptr->end)
- offset = 0;
- if((cur_ptr->link != NULL) && (cur_ptr->link[0] != '\0')) {
- /* The link is only set if the Link points to an external document */
- switch(cur_ptr->linktype) {
- case HW_BACKGROUND_LINK:
- snprintf(bgstr, BUFFERLEN, " background='%s'", cur_ptr->link);
- break;
- case HW_INTAG_LINK:
- snprintf(istr, BUFFERLEN, " %s='%s'", cur_ptr->tagattr, cur_ptr->link);
- offset -= 4; /* because there is no closing tag </A> */
-/* laststart = cur_ptr->start; */
- break;
- case HW_APPLET_LINK:
- if(cur_ptr->codebase)
- snprintf(istr, BUFFERLEN, " CODEBASE='%s' CODE='%s'", cur_ptr->codebase, cur_ptr->code);
- else
- snprintf(istr, BUFFERLEN, " CODEBASE='/' CODE='%s'", cur_ptr->code);
- break;
- default:
- newtext = fnInsStr(newtext, cur_ptr->end+offset, "</A>");
- snprintf(istr, BUFFERLEN, "<A HREF='%s' %s>", cur_ptr->link, cur_ptr->htmlattr == NULL ? "" : cur_ptr->htmlattr);
- }
- } else {
- switch(cur_ptr->linktype) {
- case HW_BACKGROUND_LINK:
- if(NULL != cur_ptr->destdocname)
- snprintf(bgstr, BUFFERLEN, " background='%s/%s'", scriptname == NULL ? "" : scriptname, cur_ptr->destdocname);
- else
- bgstr[0] = '\0';
- break;
- case HW_INTAG_LINK:
- if(cur_ptr->fragment)
-/* snprintf(istr, BUFFERLEN, " %s='%s/%s#%s'", cur_ptr->tagattr, scriptname == NULL ? "." : scriptname, cur_ptr->destdocname, cur_ptr->fragment);*/
- snprintf(istr, BUFFERLEN, " %s='#%s'", cur_ptr->tagattr, cur_ptr->fragment);
- else
- snprintf(istr, BUFFERLEN, " %s='%s/%s'", cur_ptr->tagattr, scriptname == NULL ? "." : scriptname, cur_ptr->destdocname);
- offset -= 4; /* because there is no closing tag </A> */
-/* laststart = cur_ptr->start; */
- break;
- case HW_APPLET_LINK:
- if(cur_ptr->codebase)
-/* snprintf(istr, BUFFERLEN, " CODEBASE='%s%s' CODE='%s'", scriptname == NULL ? "" : scriptname, cur_ptr->codebase, cur_ptr->code); */
- snprintf(istr, BUFFERLEN, " CODEBASE='%s' CODE='%s'", cur_ptr->codebase, cur_ptr->code);
- else
- snprintf(istr, BUFFERLEN, " CODEBASE='/' CODE='%s'", cur_ptr->code);
- break;
- default:
- newtext = fnInsStr(newtext, cur_ptr->end+offset, "</A>");
-
- if(cur_ptr->nameanchor)
- snprintf(istr, BUFFERLEN, "<A HREF='%s/%s#%s' %s>", scriptname == NULL ? "schade" : scriptname, cur_ptr->destdocname, cur_ptr->nameanchor, cur_ptr->htmlattr == NULL ? "" : cur_ptr->htmlattr);
- else
- if(cur_ptr->fragment)
- snprintf(istr, BUFFERLEN, "<A HREF='%s/%s#%s' %s>", scriptname == NULL ? "" : scriptname, cur_ptr->destdocname, cur_ptr->fragment, cur_ptr->htmlattr == NULL ? "" : cur_ptr->htmlattr);
- else
- snprintf(istr, BUFFERLEN, "<A HREF='%s/%s' %s>", scriptname == NULL ? "" : scriptname, cur_ptr->destdocname, cur_ptr->htmlattr == NULL ? "" : cur_ptr->htmlattr);
- }
- }
- newtext = fnInsStr(newtext, cur_ptr->start, istr);
- /* In case there are several TAGS nested, we accumulate the offset
- You wonder what the 4 means? It's the length of </A> */
- offset += strlen(istr) + 4;
- laststart = cur_ptr->start;
- } else {
- if(laststart >= cur_ptr->end)
- offset = 0;
- newtext = fnInsStr(newtext, cur_ptr->end+offset, "</a>");
-
- /* If we have a keyword, we assume we had a fragment which has been used
- instead of the destdocname
- */
- if(cur_ptr->keyword)
- snprintf(istr, BUFFERLEN, "<A NAME='%s'>", cur_ptr->keyword);
- else if(cur_ptr->nameanchor)
- snprintf(istr, BUFFERLEN, "<A NAME='%s'>", cur_ptr->nameanchor);
- newtext = fnInsStr(newtext, cur_ptr->start, istr);
- /* In case there are several TAGS nested, we accumulate the offset
- You wonder what the 4 means? It's the length of </A> */
- offset += strlen(istr) + 4;
- laststart = cur_ptr->start;
- }
- cur_ptr = (ANCHOR *) dlst_prev(cur_ptr);
- }
- snprintf(istr, BUFFERLEN, "<BODY %s>", bgstr);
- *bodytag = estrdup(istr);
- return(newtext);
-}
-#undef BUFFERLEN
-
-/***********************************************************************
-* Function fnAttributeValue() *
-* *
-* Returns the value of an attribute *
-* Parameter: char *object: object record *
-* char *attrname: attribute name *
-* Return: char*: attribute value, NULL if name not found *
-***********************************************************************/
-char *fnAttributeValue(char *object, char *attrname)
-{
- char *str, *str1, *attrvalue;
- int len;
-
- str = strstr(object, attrname);
- if(NULL == str)
- return(NULL);
- str += strlen(attrname);
- str++;
- str1 = str;
- while((*str1 != '\0') && (*str1 != '\n'))
- str1++;
- len = str1 - str;
- if(NULL == (attrvalue = emalloc(len+1))) {
- lowerror = LE_MALLOC;
- return NULL;
- }
- memcpy(attrvalue, str, len);
- attrvalue[len] = '\0';
- return(attrvalue);
-}
-
-/***********************************************************************
-* Function fnAttributeCompare() *
-* *
-* Checks if an attribute in an objrec has a certain value *
-* Parameter: char *object: object record *
-* char *attrname: attribute name *
-* char *value: value of attribute *
-* Return: char*: as strcmp *
-***********************************************************************/
-int fnAttributeCompare(char *object, char *attrname, char *value)
-{
- char *str, *str1;
- int len;
-
- if((NULL == object) || (NULL == attrname) || (NULL == value))
- return -2;
-
- /* Find the attribute Name and make sure it is followed by
- a '=' sign and preceded by a '\n';
- */
- str = strstr(object, attrname);
- if((NULL == str) ||
- (str[strlen(attrname)] != '=') ||
- (str[-1] != '\n')) {
- return(-2);
- }
- str += strlen(attrname); /* skip the attribute name */
- str++; /* skip the equal sign */
-
- /* Search for end of attribute value */
- str1 = str;
- while((*str1 != '\0') && (*str1 != '\n'))
- str1++;
- len = str1 - str;
- return(strncmp(str, value, len));
-}
-
-/*********************************************************************
-* Function fnCOpenDataCon() *
-* *
-* Opens data connection on client side. This function is called *
-* right after the client has requested any data from the server *
-* Parameter: int sockfd: socket of control connection *
-* int *port: port of control und data connection *
-* Return : sockfd on success, <0 if error *
-*********************************************************************/
-static int fnCOpenDataCon(int sockfd, int *port)
- {
- int fd;
- struct sockaddr_in serv_addr;
- int len;
- int option = 1;
-
-/* len = sizeof(com_addr);
- if(getsockname(sockfd, (struct sockaddr *) &com_addr, &len) < 0)
- {
- return(-1);
- }
-
- *port = htons(com_addr.sin_port); */
-
- /*
- ** Open a TCP socket (an Internet stream socket)
- */
- if((fd = socket(AF_INET, SOCK_STREAM, 0)) == SOCK_ERR)
- {
- return(-1);
- }
-
- /*
- ** Make sure that address may be reused
- */
-#if defined(SUN) || (WIN32|WINNT)
- setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&option, sizeof(option));
-#else
- setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option));
-#endif
-
- /*
- ** Open connection aktiv
- ** Let bind() select a port number
- */
- bzero((char *) &serv_addr, sizeof(serv_addr));
- if(bind(fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
- {
- return(-1);
- }
-
- /*
- ** Get the port number bind selected
- */
- len = sizeof (serv_addr);
- if(getsockname(fd, (struct sockaddr *)&serv_addr, &len) < 0)
- {
- return(-1);
- }
- *port = ntohs(serv_addr.sin_port);
-
- listen(fd, 5);
-
- return(fd);
- }
-
-/*======================================================================
- *
- * Read/write routines with timeout detection.
- *
- * Usage: write_to(fd, buffer, n, timeout)
- * read_to(fd, buffer, n, timeout)
- *
- * David Chavez
- * Engineering Services & Software
- * 7841 New Salem Street
- * San Diego, CA 92126
- * USA
- *
- * dec@essw.com
- *
- *====================================================================*/
-#if WIN32|WINNT
-#include <time.h>
-#else
-#include <sys/fcntl.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#endif
-#include <errno.h>
-#include <signal.h>
-
-#if !(WIN32|WINNT)
-static sigset_t newmask, oldmask, zeromask;
-#endif
-
-static int set_noblock(int fd)
-{
-#if WIN32|WINNT
- u_long argp=1;
-
- return ioctlsocket (fd, FIONBIO , &argp);
-#else
-
- sigemptyset(&zeromask);
- sigemptyset(&newmask);
- sigaddset(&newmask, SIGHUP);
- sigaddset(&newmask, SIGUSR1);
- sigaddset(&newmask, SIGUSR2);
- if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0) return -1;
-
- return fcntl(fd, F_SETFL, O_NONBLOCK | O_NDELAY /* | FNBIO*/);
-#endif
-}
-
-int write_to(int fd, void *buffer, int n, int timeout)
-{
- int nrem, nw;
- char *bptr;
- int error;
-#if defined(SYSV) || (WIN32|WINNT)
- int width = 20;
-#else
- int width = getdtablesize();
-#endif
- fd_set writefds;
- struct timeval select_timeout;
-
- select_timeout.tv_sec = timeout;
-#if WIN32|WINNT
- select_timeout.tv_usec = 0;
-#else /* is this just a typo? */
- select_timeout.tv_usec = 0.;
-#endif
-
- /* Set fd to non-blocking */
-
- if (set_noblock(fd) != 0) return -1;
-
- /* Write to fd until no more can be written */
-
- FD_ZERO(&writefds);
-
- FD_SET((unsigned int)fd, &writefds);
-
- for( nrem = n, bptr = buffer; nrem;)
- {
- if(( error = select(width,
- (fd_set *) 0,
- &writefds,
- (fd_set *) 0,
- &select_timeout)) <= 0 && errno != EINTR) break;
-
- if(errno != EINTR && ( nw = write(fd, bptr, nrem)) <= 0) {
- /*
- * check for error number - and keep trying to
- * write
- */
- if(errno == EWOULDBLOCK || errno == EAGAIN || errno == EINTR)
- {
- continue;
- }
- else
- {
- error = nw;
- break;
- }
- } else {
- nrem -= nw;
- bptr += nw;
- }
- }
-#if !(WIN32|WINNT)
- if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0) return -1;
-#endif
- if( ! error ) {
- errno = ETIMEDOUT;
- return(-2);
- } else if (error < 0) {
- return(error);
- } else {
- return(n);
- }
-}
-
-int read_to(int fd, char *buffer, int n, int timeout)
- {
- int nrem, nread, nr;
- char *bptr;
- int error;
-
-#if defined(SYSV) || (WIN32|WINNT)
- int width = 20;
-#else
- int width = getdtablesize();
-#endif
- fd_set readfds;
- struct timeval select_timeout;
-
- select_timeout.tv_sec = timeout;
-#if WIN32|WINNT
- select_timeout.tv_usec = 0;
-#else
- select_timeout.tv_usec = 0.;
-#endif
-
- /* Set fd to non-blocking */
-
- if (set_noblock(fd) != 0) return -1;
-
- FD_ZERO(&readfds);
-
- FD_SET((unsigned int)fd, &readfds);
-
- for( nrem = n, bptr = buffer, nread = 0; nrem;)
- {
- if(( error = select(width,
- &readfds,
- (fd_set *) 0,
- (fd_set *) 0,
- &select_timeout)) <= 0 && errno != EINTR) break;
-
- if(errno != EINTR && (nr = read (fd, bptr, nrem)) < 0)
- {
- /*
- * check for error number - and keep trying to
- * read
- */
- if(errno == EWOULDBLOCK || errno == EAGAIN || errno == EINTR)
- {
- continue;
- }
- else
- {
- error = nr;
- break;
- }
- }
- else if(nr == 0)
- {
- break;
- }
- else
- {
- nread += nr;
- bptr += nr;
- nrem -= nr;
- }
- }
-
-#if !(WIN32|WINNT)
- if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0) return -1;
-#endif
- if( ! error )
- {
- errno = ETIMEDOUT;
- return(-2);
- }
- else if ( error < 0)
- {
- return(-1);
- }
- else
- {
- return(nread);
- }
- }
-
-void set_swap(int do_swap)
-{
- swap_on = do_swap;
-}
-
-/***********************************************************************
-* Function open_hg_connection() *
-* *
-***********************************************************************/
-int open_hg_connection(char *server_name, int port)
-{
- int sockfd;
- int option = 1;
- struct sockaddr_in server_addr;
- struct hostent *hp;
- if ( (hp = gethostbyname(server_name)) == NULL ) {
- return(-1);
- }
-
- bzero((char *)&server_addr, sizeof(server_addr));
- server_addr.sin_family = AF_INET;
- if ( port != 0 )
- server_addr.sin_port = htons(port);
- else
- server_addr.sin_port = htons(HG_SERVER_PORT);
- bcopy(hp->h_addr, (char *) &server_addr.sin_addr, hp->h_length);
-
- if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) == SOCK_ERR ) {
- return(-2);
- }
-
-#if defined(SUN) || (WIN32|WINNT)
- setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&option, sizeof(option));
-#else
- setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option));
-#endif /* SUN */
-
- if (connect(sockfd, (struct sockaddr *) &server_addr, sizeof(server_addr)) < 0) {
- HWSOCK_FCLOSE(sockfd);
- return(-3);
- }
-
-#if !(WIN32|WINNT)
- if ( (sock_flags = fcntl(sockfd, F_GETFL, 0)) == -1 )
-#endif
-
- if ( set_nonblocking(sockfd) == -1 ) {
- HWSOCK_FCLOSE(sockfd);
- return(-4);
- }
-
- return(sockfd);
-}
-
-
-/***********************************************************************
-* Function initialize_hg_connection() *
-* *
-***********************************************************************/
-int initialize_hg_connection(int sockfd, int *do_swap, int *version, char **userdata, char **server_string, char *username, char *password)
-{
- char buf, c;
- char *tmp;
- hg_msg *ready_msg, *retmsg, msg;
- int i = 0x01;
- int length;
-
- *do_swap = 0;
- buf = 'T';
- if ( hg_write(sockfd, &buf, 1) == -1 ) {
- return(-2);
- }
-
- if ( hg_read_exact(sockfd, &buf, 1) == -1 ) {
- return(-3);
- }
- if ( buf == 'F' ) {
- return(-4);
- }
- if ( buf != 'T' ) {
- return(-5);
- }
-
- buf = c = ( *(char *)&i ) ? 'l' : 'B';
- if ( hg_write(sockfd, &buf, 1) == -1 ) {
- return(-6);
- }
- if ( hg_read_exact(sockfd, &buf, 1) == -1 ) {
- return(-7);
- }
- if ( c != buf ) {
- swap_on = 1;
- *do_swap = 1;
- } else {
- swap_on = 0;
- *do_swap = 0;
- }
-
- if ( send_ready(sockfd) == -1) {
- return(-8);
- }
-
- /* Receive return from Ready message */
- if ( (ready_msg = recv_ready(sockfd)) == NULL ) {
- return(-9);
- }
-
- if ((ready_msg->version_msgid & F_VERSION) < HW_VERSION)
- return(-8);
- *version = ready_msg->version_msgid;
- *server_string = strdup(ready_msg->buf+4);
- efree(ready_msg->buf);
- efree(ready_msg);
-
- /* If we have a username and password then do the identification. */
- if((NULL != username) && (NULL != password)) {
- length = HEADER_LENGTH + sizeof(int) + strlen(username) + 1 + strlen(password) + 1;
-
- build_msg_header(&msg, length, msgid++, IDENTIFY_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, 0);
- tmp = build_msg_str(tmp, username);
- tmp = build_msg_str(tmp, password);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-10);
- }
- efree(msg.buf);
- }
-
- if((NULL != username) && (NULL != password)) {
- /* Receive return form identify message */
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL )
- return(-11);
-
- *userdata = retmsg->buf;
- efree(retmsg);
- }
-
- return(0);
-}
-
-
-static int set_nonblocking(int fd)
-{
-#if WIN32|WINNT
- unsigned int argp=0;
-
-/* if ( sock_flags == -1 )
- getsockopt (fd, SOL_SOCKET, optname, optval, optlen);
-*/ if(ioctlsocket (fd, FIONBIO , &argp) == -1)
- return(-1);
-#else
- if ( sock_flags == -1 )
- sock_flags = fcntl(fd, F_GETFL, 0);
- if ( fcntl(fd, F_SETFL, O_NONBLOCK) == -1 )
- return(-1);
-#endif
- non_blocking = 1;
- return(0);
-}
-
-
-static int set_blocking(int fd)
-{
-#if WIN32|WINNT
- unsigned int argp=1;
-
- if(ioctlsocket (fd, FIONBIO , &argp) == -1)
- return(-1);
-#else
- if ( fcntl(fd, F_SETFL, sock_flags) == -1 )
- return(-1);
-#endif
- return(0);
-}
-
-
-static int hg_read_exact(int sockfd, char *buf, int size)
-{
- int len = 0;
-
- len = read_to(sockfd, (void *) buf, size, rtimeout);
- if ( len < 0 )
- return -1;
- return(0);
-}
-
-
-static int hg_read(int sockfd, char *buf, int size)
-{
- int try = 0;
- int len = 0;
-
- if ( !non_blocking )
- set_nonblocking(sockfd);
- while ( len == 0 ) {
- len = recv(sockfd, (void *) buf, size, 0);
- if ( len == -1 ) {
- if ( (errno == EAGAIN) || (errno == EWOULDBLOCK) ) {
- if ( ++try > 5 )
- return(-1);
- sleep(1);
- }
- else return(-1);
- }
- }
- return(len);
-}
-
-
-static int hg_write(int sockfd, char *buf, int size)
-{
- int try = 0;
- int len = 0;
-
- if ( !non_blocking )
- set_nonblocking(sockfd);
- while ( size > 0 ) {
- len = send(sockfd, (void *) buf, size, 0);
- if ( len == -1 ) {
- if ( (errno == EAGAIN) || (errno == EWOULDBLOCK) ) {
- if ( ++try > 5 )
- return(-1);
- sleep(1);
- }
- else return(-1);
- }
- else {
- size -= len;
- buf += len;
- try = 0;
- }
- }
- return(0);
-}
-
-
-hg_msg *recv_hg_msg(int sockfd)
-{
- hg_msg *msg;
-
- if ( (msg = (hg_msg *)emalloc(sizeof(hg_msg))) == NULL ) {
-/* php3_printf("recv_hg_msg"); */
- lowerror = LE_MALLOC;
- return(NULL);
- }
-
- if ( hg_read_exact(sockfd, (char *)&(msg->length), 4) == -1 ) {
-/* php3_printf("recv_hg_msg: hg_read (1) returned -1\n"); */
- efree(msg);
- return(NULL);
- }
-
- if ( hg_read_exact(sockfd, (char *)&(msg->version_msgid), 4) == -1 ) {
-/* php3_printf("recv_hg_msg: hg_read (2) returned -1\n"); */
- efree(msg);
- return(NULL);
- }
-
- if ( hg_read_exact(sockfd, (char *)&(msg->msg_type), 4) == -1 ) {
-/* php3_printf("recv_hg_msg: hg_read (3) returned -1\n"); */
- efree(msg);
- return(NULL);
- }
-
- if ( msg->length > HEADER_LENGTH ) {
- if ( (msg->buf = (char *) emalloc(msg->length-HEADER_LENGTH)) == NULL ) {
-/* php3_printf("recv_hg_msg"); */
- lowerror = LE_MALLOC;
- efree(msg);
- return(NULL);
- }
- if ( hg_read_exact(sockfd, msg->buf, msg->length-HEADER_LENGTH) == -1 ) {
-/* php3_printf("recv_hg_msg: hg_read (4) returned -1\n"); */
- efree(msg->buf);
- efree(msg);
- return(NULL);
- }
- }
- else
- msg->buf = NULL;
-
-#ifdef HW_DEBUG
- php3_printf("<B> Recv msg: </B>type = %d -- id = %d<BR>\n", msg->msg_type, msg->version_msgid);
-#endif
- return(msg);
-}
-
-
-hg_msg *recv_ready(int sockfd)
-{
- hg_msg *ready_msg;
-
- if ( (ready_msg = recv_hg_msg(sockfd)) == NULL ) {
-/* php3_printf("recv_ready: recv_hg_msg returned NULL\n"); */
- return(NULL);
- }
- if ( ready_msg->msg_type != READY_MESSAGE ) {
-/* php3_printf("recv_ready: recv_hg_msg returned wrong message: %d, %d \n", ready_msg->length, ready_msg->msg_type); */
- efree(ready_msg);
- return(NULL);
- }
-
- return(ready_msg);
-}
-
-
-hg_msg *recv_command(int sockfd)
-{
- hg_msg *comm_msg;
-
- if ( (comm_msg = recv_hg_msg(sockfd)) == NULL ) {
-/* fprintf(stderr, "recv_command: recv_hg_msg returned NULL\n"); */
- return(NULL);
- }
- if ( comm_msg->msg_type != COMMAND_MESSAGE ) {
-/* fprintf(stderr, "recv_command: recv_hg_msg returned wrong message\n"); */
- return(NULL);
- }
-
- return(comm_msg);
-}
-
-int send_dummy(int sockfd, hw_objectID objectID, int msgid, char **attributes)
-{
- hg_msg msg, *retmsg;
- int length, error;
- char *tmp;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, msgid);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- *attributes = NULL;
- return(-1);
- }
-
- if(0 == (int) *(retmsg->buf)) {
- *attributes = estrdup(retmsg->buf+sizeof(int));
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- error = *((int *) retmsg->buf);
- *attributes = NULL;
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-
- return(0);
-}
-
-static int bh_send_deleteobject(int sockfd, hw_objectID objectID) {
- hg_msg msg;
- int length;
- char *tmp;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, DELETEOBJECT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
- efree(msg.buf);
-
- return(msgid-1);
-}
-
-static int uh_send_deleteobject(int sockfd) {
- hg_msg *retmsg;
- int error;
-
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- return(-1);
- }
-
- if(NULL == retmsg->buf) {
- efree(retmsg);
- return -1;
- }
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return(error);
-}
-
-int send_deleteobject(int sockfd, hw_objectID objectID)
-{
- if(0 > bh_send_deleteobject(sockfd, objectID))
- return -1;
- return(uh_send_deleteobject(sockfd));
-}
-
-static int bh_send_changeobject(int sockfd, hw_objectID objectID, char *mod) {
- hg_msg msg;
- int length;
- char *tmp;
-
- length = HEADER_LENGTH + sizeof(hw_objectID) + strlen(mod) + 1;
-
- build_msg_header(&msg, length, msgid++, CHANGEOBJECT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
- tmp = build_msg_str(tmp, mod);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
- efree(msg.buf);
-
- return(msgid-1);
-}
-
-static int uh_send_changeobject(int sockfd) {
- hg_msg *retmsg;
- int error;
-
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- return(-1);
- }
-
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return(error);
-}
-
-int send_changeobject(int sockfd, hw_objectID objectID, char *modification)
-{
- if(0 > bh_send_changeobject(sockfd, objectID, modification))
- return -1;
- return(uh_send_changeobject(sockfd));
-}
-
-int send_groupchangeobject(int sockfd, hw_objectID objectID, char *modification)
-{
- hw_objectID *childIDs;
- int count, i, error;
-
- if(0 == (error = send_lock(sockfd, objectID))) {
- send_changeobject(sockfd, objectID, modification);
- send_unlock(sockfd, objectID);
- }/* else
- fprintf(stderr, "Could not lock 0x%X (error = %d)\n", objectID, error); */
-
- if(0 == send_children(sockfd, objectID, &childIDs, &count)) {
-/* fprintf(stderr, "Changing Children of 0x%X\n", objectID); */
- for(i=0; i<count; i++)
- if(0 > send_groupchangeobject(sockfd, childIDs[i], modification))
-/* fprintf(stderr, "Cannot change 0x%X\n", objectID) */;
- if(childIDs)
- efree(childIDs);
- }/* else
- fprintf(stderr, "No Children of 0x%X\n", objectID); */
- return(0);
-}
-
-static int bh_send_getobject(int sockfd, hw_objectID objectID) {
- hg_msg msg;
- int length;
- char *tmp;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETOBJECT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
- efree(msg.buf);
-
- return(msgid-1);
-}
-
-static int uh_send_getobject(int sockfd, char **attributes) {
- hg_msg *retmsg;
- int error;
-
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- *attributes = NULL;
- return(-1);
- }
-
- if(0 == (int) *(retmsg->buf)) {
- *attributes = estrdup(retmsg->buf+sizeof(int));
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- error = *((int *) retmsg->buf);
- *attributes = NULL;
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-
- return(0);
-}
-
-int send_getobject(int sockfd, hw_objectID objectID, char **attributes)
-{
- if(0 > bh_send_getobject(sockfd, objectID))
- return -1;
- return(uh_send_getobject(sockfd, attributes));
-}
-
-int send_getandlock(int sockfd, hw_objectID objectID, char **attributes)
-{
- hg_msg msg, *retmsg;
- int length, error;
- char *tmp;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETANDLOCK_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- *attributes = NULL;
- return(-1);
- }
-
- if(0 == (error = (int) *(retmsg->buf))) {
- *attributes = estrdup(retmsg->buf+sizeof(int));
- } else {
- *attributes = NULL;
- }
-
- efree(retmsg->buf);
- efree(retmsg);
- return error;
-}
-
-int send_lock(int sockfd, hw_objectID objectID)
-{
- hg_msg msg, *retmsg;
- int length, error;
- char *tmp;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETANDLOCK_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- return(-1);
- }
-
- error = *((int *) retmsg->buf);
-
- efree(retmsg->buf);
- efree(retmsg);
- return error;
-}
-
-int send_insertobject(int sockfd, char *objrec, char *parms, hw_objectID *objectID)
-{
- hg_msg msg, *retmsg;
- int length, error;
- char *tmp;
- int *ptr;
-
- length = HEADER_LENGTH + strlen(objrec) + 1 + strlen(parms) + 1;
-
- build_msg_header(&msg, length, msgid++, INSERTOBJECT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_str(msg.buf, objrec);
- tmp = build_msg_str(tmp, parms);
-/*fprintf(stderr,"objrec = %s, parms = %s\n", objrec, parms); */
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- *objectID = 0;
- return(-1);
- }
-
- ptr = (int *) retmsg->buf;
- if(0 == (error = *ptr)) {
- ptr++;
- *objectID = *ptr;
- } else {
- *objectID = 0;
- }
- efree(retmsg->buf);
- efree(retmsg);
- return error;
-}
-
-int send_unlock(int sockfd, hw_objectID objectID)
-{
- hg_msg msg;
- int length, error;
- char *tmp;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, UNLOCK_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- return 0;
-}
-
-int send_incollections(int sockfd, int retcol, int cobjids, hw_objectID *objectIDs, int ccollids, hw_objectID *collIDs, int *count, hw_objectID **retIDs)
-{
- hg_msg msg, *retmsg;
- int length, error;
- char *tmp;
- int *ptr, *ptr1, i;
-
- length = HEADER_LENGTH + sizeof(hw_objectID) + (cobjids + ccollids) * sizeof(hw_objectID) + 2 * sizeof(int);
-
- build_msg_header(&msg, length, msgid++, INCOLLECTIONS_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- lowerror = LE_MALLOC;
- return(-3);
- }
-
- tmp = build_msg_int(msg.buf, retcol);
- tmp = build_msg_int(tmp, cobjids);
- for(i=0; i<cobjids; i++)
- tmp = build_msg_int(tmp, objectIDs[i]);
- tmp = build_msg_int(tmp, ccollids);
- for(i=0; i<ccollids; i++)
- tmp = build_msg_int(tmp, collIDs[i]);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-2);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if(retmsg == NULL) {
- return(-1);
- }
-
- ptr = (int *) retmsg->buf;
- if(ptr == NULL) {
- if(retmsg) efree(retmsg);
- return -1;
- }
- if(*ptr++ == 0) {
- *count = *ptr;
- ptr++;
- if(NULL != (*retIDs = emalloc(*count * sizeof(hw_objectID)))) {
- ptr1 = *retIDs;
- for(i=0; i<*count; ptr++, i++)
- ptr1[i] = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *((int *) retmsg->buf);
- if(retmsg->buf) efree(retmsg->buf);
- if(retmsg) efree(retmsg);
- return error;
- }
- return(0);
-}
-
-
-int send_inscoll(int sockfd, hw_objectID objectID, char *objrec, hw_objectID *new_objectID)
-{
- hg_msg msg, *retmsg;
- int length, error;
- char *tmp;
- int *ptr;
-
- length = HEADER_LENGTH + sizeof(hw_objectID) + strlen(objrec) + 1;
-
- build_msg_header(&msg, length, msgid++, INSCOLL_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- lowerror = LE_MALLOC;
- return(-3);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
- tmp = build_msg_str(tmp, objrec);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-2);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if(retmsg == NULL) {
- return(-1);
- }
-
- ptr = (int *) retmsg->buf;
- if(0 != (error = *ptr)) {
- efree(retmsg->buf);
- efree(retmsg);
- *new_objectID = 0;
- return error;
- }
-
- ptr++;
- *new_objectID = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- return 0;
-}
-
-int send_insdoc(int sockfd, hw_objectID objectID, char *objrec, char *text, hw_objectID *new_objectID)
-{
- hg_msg msg, *retmsg;
- int length, error;
- char *tmp;
- int *ptr;
-
- length = HEADER_LENGTH + sizeof(hw_objectID) + strlen(objrec) + 1;
- if(text) {
- length += strlen(text);
- length++;
- }
-
- build_msg_header(&msg, length, msgid++, INSDOC_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- lowerror = LE_MALLOC;
- return(-3);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
- tmp = build_msg_str(tmp, objrec);
- if(text)
- tmp = build_msg_str(tmp, text);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-2);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if(retmsg == NULL) {
- return(-1);
- }
-
- ptr = (int *) retmsg->buf;
- if(0 != (error = *ptr)) {
- efree(retmsg->buf);
- efree(retmsg);
- *new_objectID = 0;
- return error;
- }
-
- ptr++;
- *new_objectID = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- return 0;
-}
-
-int send_getdestforanchorsobj(int sockfd, char **anchorrec, char ***destrec, int count);
-int send_getreldestforanchorsobj(int sockfd, char **anchorrec, char ***reldestrec, int count, int rootID, int thisID);
-
-int send_gettext(int sockfd, hw_objectID objectID, int mode, int rootid, char **objattr, char **bodytag, char **text, int *count, char *urlprefix)
-{
- hg_msg msg, *retmsg;
- int length, *ptr, ancount, error;
- char *tmp, *attributes, *documenttype;
- char **anchors;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETOBJECT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if(retmsg == NULL) {
- attributes = NULL;
- return(-1);
- }
-
- ptr = (int *) retmsg->buf;
- if(*ptr == 0) {
- attributes = estrdup(retmsg->buf+sizeof(int));
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- error = *ptr;
- attributes = NULL;
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-
- length = HEADER_LENGTH + strlen(attributes) + 1;
- build_msg_header(&msg, length, msgid++, GETTEXT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_str(msg.buf, attributes);
-
- documenttype = fnAttributeValue(attributes, "DocumentType");
- *objattr = strdup(attributes);
- efree(attributes);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if (retmsg == NULL) {
- *text = NULL;
- return(-1);
- }
-
- ptr = (int *) retmsg->buf;
- if(*ptr == 0) {
- ptr++;
- *count = retmsg->length-HEADER_LENGTH-sizeof(int);
- if(NULL != (*text = malloc(*count + 1))) {
- memcpy(*text, retmsg->buf+sizeof(int), *count);
-/* *text[*count] = 0; */
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- *text = NULL;
- return(error);
- }
- efree(retmsg->buf);
- efree(retmsg);
-
- if((documenttype != NULL) && (strcmp(documenttype, "Image") != 0)) {
- if(send_getanchorsobj(sockfd, objectID, &anchors, &ancount) == 0) {
- char **destrec, **reldestrec;
- DLIST *pAnchorList;
-
- send_getdestforanchorsobj(sockfd, anchors, &destrec, ancount);
- send_getreldestforanchorsobj(sockfd, anchors, &reldestrec, ancount, rootid, objectID);
- pAnchorList = fnCreateAnchorList(anchors, destrec, reldestrec, ancount, mode);
- /* Free only the array, the objrecs has been freed in fnCreateAnchorList() */
- if(anchors) efree(anchors);
- if(destrec) efree(destrec);
- if(reldestrec) efree(reldestrec);
-
- if(pAnchorList != NULL) {
- char *newtext;
- char *body;
-
- newtext = fnInsAnchorsIntoText(*text, pAnchorList, &body, urlprefix);
- dlst_kill(pAnchorList, fnDeleteAnchor);
- *bodytag = strdup(body);
- efree(body);
- *text = newtext;
- *count = strlen(newtext);
- }
- }
- }
-
- if(documenttype) efree(documenttype);
- return(0);
-}
-
-int send_edittext(int sockfd, char *objattr, char *text)
-{
- hg_msg msg, *retmsg;
- int length, *ptr, error;
- char *tmp, *path, *objid;
- hw_objectID objectID;
-
- objid = fnAttributeValue(objattr, "ObjectID");
- if(objid == NULL)
- return(-1);
- if(!sscanf(objid, "0x%x", &objectID))
- return(-2);
-
- path = fnAttributeValue(objattr, "Path");
- if(path == NULL)
- return(-3);
-
- length = HEADER_LENGTH + sizeof(hw_objectID) + strlen(path) + 1 + 1 + strlen(text) + 1;
- build_msg_header(&msg, length, msgid++, EDITTEXT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- lowerror = LE_MALLOC;
- return(-4);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
- tmp = build_msg_str(tmp, path);
- tmp = build_msg_str(tmp, "");
- tmp = build_msg_str(tmp, text);
-
- if(path) efree(path);
- if(objid) efree(objid);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-5);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if (retmsg == NULL) {
- *text = '\0';
- return(-6);
- }
-
- ptr = (int *) retmsg->buf;
- error = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- return(error);
-}
-
-int send_getcgi(int sockfd, hw_objectID objectID, char *cgi_env_str, char **objattr, char **text, int *count)
-{
- hg_msg msg, *retmsg;
- int length, *ptr, error, new_attr_len;
- char *tmp, *attributes, *new_attr;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETOBJECT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if(retmsg == NULL) {
- attributes = NULL;
- return(-1);
- }
-
- ptr = (int *) retmsg->buf;
- if(*ptr == 0) {
- attributes = estrdup(retmsg->buf+sizeof(int));
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- error = *ptr;
- attributes = NULL;
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-
- new_attr_len = strlen(attributes) + strlen(cgi_env_str) + 2;
- new_attr = malloc(new_attr_len);
- strcpy(new_attr, attributes);
- strcat(new_attr, cgi_env_str);
- length = HEADER_LENGTH + strlen(new_attr) + 1 + sizeof(int);
- build_msg_header(&msg, length, msgid++, GETCGI_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_str(msg.buf, new_attr);
- tmp = build_msg_int(tmp, 0);
-
- *objattr = strdup(attributes);
- efree(attributes);
- free(new_attr);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if (retmsg == NULL) {
- *text = NULL;
- return(-1);
- }
-
- /* Attention: It looks like the documentation is not quite right.
- According to the docs the buffer starts with an integer which
- is followed by the output of the cgi script. This seems not to
- be true. There is another integer right after the error.
- The output of the cgi script is also preceded by the 'Content-type'
- header. */
- ptr = (int *) retmsg->buf;
- if(*ptr++ == 1024) {
- *count = *ptr++;
- if(NULL != (*text = malloc(*count + 1))) {
- memcpy(*text, ptr, *count);
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *ptr + 1024; /* move errors to >2024 */
- efree(retmsg->buf);
- efree(retmsg);
- *text = NULL;
- return(error);
- }
- efree(retmsg->buf);
- efree(retmsg);
-
- return(0);
-}
-
-int send_getremote(int sockfd, hw_objectID objectID, char **objattr, char **text, int *count)
-{
- hg_msg msg, *retmsg;
- int length, *ptr, error;
- char *tmp, *attributes;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETOBJECT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if(retmsg == NULL) {
- attributes = NULL;
- return(-1);
- }
-
- ptr = (int *) retmsg->buf;
- if(*ptr == 0) {
- attributes = estrdup(retmsg->buf+sizeof(int));
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- error = *ptr;
- attributes = NULL;
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-
- length = HEADER_LENGTH + strlen(attributes) + 1 + sizeof(int);
- build_msg_header(&msg, length, msgid++, GETREMOTE_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_str(msg.buf, attributes);
- tmp = build_msg_int(tmp, 0);
-
- *objattr = strdup(attributes);
- efree(attributes);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if (retmsg == NULL) {
- *text = NULL;
- return(-1);
- }
-
- ptr = (int *) retmsg->buf;
- if(*ptr == 1024) {
- *count = retmsg->length-HEADER_LENGTH-sizeof(int)-sizeof(int);
- if(NULL != (*text = malloc(*count + 1))) {
- memcpy(*text, ptr+2, *count);
-/* *text[*count] = 0; */
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *ptr + 1024; /* move errors to >2024 */
- efree(retmsg->buf);
- efree(retmsg);
- *text = NULL;
- return(error);
- }
- efree(retmsg->buf);
- efree(retmsg);
-
- return(0);
-}
-
-int send_getremotechildren(int sockfd, char *attributes, char **text, int **childIDs, int *count)
-{
- hg_msg msg, *retmsg;
- int length, *ptr, *ptr1, error;
- char *tmp;
-
-/* length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETOBJECT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if(retmsg == NULL) {
- attributes = NULL;
- return(-1);
- }
-
- ptr = (int *) retmsg->buf;
- if(*ptr == 0) {
- attributes = estrdup(retmsg->buf+sizeof(int));
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- error = *ptr;
- attributes = NULL;
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-*/
- length = HEADER_LENGTH + strlen(attributes) + 1 + sizeof(int);
- build_msg_header(&msg, length, msgid++, GETREMOTECHILDREN_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_str(msg.buf, attributes);
- tmp = build_msg_int(tmp, 0);
-
-/* efree(attributes); */
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if (retmsg == NULL) {
- *childIDs = NULL;
- return(-1);
- }
- ptr = (int *) retmsg->buf;
- if(*ptr++ == 1024) {
- int i, remlen, sum;
- *count = *ptr;
- ptr++;
- if(NULL != (*childIDs = emalloc(*count * sizeof(hw_objectID)))) {
- ptr1 = *childIDs;
- sum = 0;
- for(i=0; i<*count; ptr++, i++) {
- ptr1[i] = *ptr;
- sum += *ptr;
- }
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- remlen = retmsg->length - HEADER_LENGTH - *count * sizeof(int) - 2 * sizeof(int);
-/*ptr1[i-1] = remlen; */
-/*ptr1[i-2] = sum; */
-/*ptr1[i-3] = *count; */
- if(NULL != (*text = emalloc(remlen + 1))) {
- memcpy(*text, ptr, remlen);
- } else {
- efree(childIDs);
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- *childIDs = NULL;
- *text = NULL;
- return error;
- }
- return(0);
-}
-
-int send_mvcpdocscollscoll(int sockfd, hw_objectID *objectIDs, int count, int from, int dest, int cpmv, int doccoll)
-{
- hg_msg msg, *retmsg;
- int length, i, error;
- char *tmp;
-
- if(count <= 0)
- return 0;
-
- /* HEADER_LENGTH + cpmv + from + dest + count + nr of obj */
- length = HEADER_LENGTH + sizeof(hw_objectID) + sizeof(hw_objectID) + sizeof(hw_objectID) + sizeof(hw_objectID) + count * sizeof(hw_objectID);
-
- switch(doccoll) {
- case DOCUMENT:
- build_msg_header(&msg, length, msgid++, MVCPDOCSCOLL_MESSAGE);
- break;
- case COLLECTION:
- build_msg_header(&msg, length, msgid++, MVCPCOLLSCOLL_MESSAGE);
- break;
- }
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, cpmv);
- tmp = build_msg_int(tmp, from);
- tmp = build_msg_int(tmp, dest);
- tmp = build_msg_int(tmp, count);
- for(i=0; i<count;i++)
- tmp = build_msg_int(tmp,objectIDs[i]);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- return(-1);
- }
-
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return(error);
-}
-
-int send_docbyanchor(int sockfd, hw_objectID objectID, hw_objectID *anchorID)
-{
- hg_msg msg, *retmsg;
- int length, error;
- char *tmp;
- int *ptr;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETDOCBYANCHOR_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- return(-1);
- }
-
- ptr = (int *) retmsg->buf;
- error = *ptr++;
- if(error == 0) {
- *anchorID = *ptr;
- } else {
- *anchorID = 0;
- }
- efree(retmsg->buf);
- efree(retmsg);
- return error;
-}
-
-int send_docbyanchorobj(int sockfd, hw_objectID objectID, char **objrec)
-{
- hg_msg msg, *retmsg;
- int length, error;
- char *tmp;
- int *ptr, anchorID;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETDOCBYANCHOR_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- return(-1);
- }
-
- ptr = (int *) retmsg->buf;
- error = *ptr++;
- if(error == 0) {
- anchorID = *ptr;
- } else {
- anchorID = 0;
- }
- efree(retmsg->buf);
- efree(retmsg);
-
- if(0 > bh_send_getobject(sockfd, anchorID))
- return -1;
- return(uh_send_getobject(sockfd, objrec));
-}
-
-int send_children(int sockfd, hw_objectID objectID, hw_objectID **childIDs, int *count)
-{
- hg_msg msg, *retmsg;
- int length, i, error;
- char *tmp;
- int *ptr, *ptr1;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, CHILDREN_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if (-1 == send_hg_msg(sockfd, &msg, length)) {
- efree(msg.buf);
- return(-2);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- return(-3);
- }
-
- ptr = (int *) retmsg->buf;
- if(ptr == NULL) {
- if(retmsg) efree(retmsg);
- return -1;
- }
- if(*ptr++ == 0) {
- *count = *ptr++;
- if(NULL != (*childIDs = emalloc(*count * sizeof(hw_objectID)))) {
- ptr1 = *childIDs;
- for(i=0; i<*count; ptr++, i++)
- ptr1[i] = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-
- return(0);
-}
-
-int send_childrenobj(int sockfd, hw_objectID objectID, char ***childrec, int *count)
-{
- hg_msg msg, *retmsg;
- int length, i, error;
- char *tmp, **objptr;
- int *childIDs = NULL;
- int *ptr;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, CHILDREN_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL )
- return(-1);
-
- ptr = (int *) retmsg->buf;
- if(ptr == NULL) {
- if(retmsg) efree(retmsg);
- return -1;
- }
- if(*ptr++ == 0) {
- *count = *ptr++;
- if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
- for(i=0; i<*count; ptr++, i++)
- childIDs[i] = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-
- /* Now get for each child collection the object record */
- for(i=0; i<*count; i++) {
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
- build_msg_header(&msg, length, childIDs[i], GETOBJECT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- efree(childIDs);
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, childIDs[i]);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(childIDs);
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- }
- efree(childIDs);
-
- if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
- /* if emalloc fails, get at least all remaining messages from server */
- for(i=0; i<*count; i++) {
- retmsg = recv_hg_msg(sockfd);
- efree(retmsg->buf);
- efree(retmsg);
- }
- *childrec = NULL;
- lowerror = LE_MALLOC;
- return(-1);
- } else {
- *childrec = objptr;
-
- for(i=0; i<*count; i++) {
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg != NULL ) {
- if(0 == (int) *(retmsg->buf)) {
- *objptr = estrdup(retmsg->buf+sizeof(int));
- objptr++;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- *objptr = NULL;
- objptr++;
- efree(retmsg->buf);
- efree(retmsg);
- }
- }
- }
- }
-
- return(0);
-}
-
-int send_getchildcoll(int sockfd, hw_objectID objectID, hw_objectID **childIDs, int *count)
-{
- hg_msg msg, *retmsg;
- int length, error;
- char *tmp;
- int *ptr, i, *ptr1;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETCHILDCOLL_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- return(-1);
- }
-
- ptr = (int *) retmsg->buf;
- if(ptr == NULL) {
- if(retmsg) efree(retmsg);
- return -1;
- }
- if(*ptr++ == 0) {
- *count = *ptr++;
- if(NULL != (*childIDs = emalloc(*count * sizeof(hw_objectID)))) {
- ptr1 = *childIDs;
- for(i=0; i<*count; ptr++, i++)
- ptr1[i] = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-
- return(0);
-}
-
-int send_getchildcollobj(int sockfd, hw_objectID objectID, char ***childrec, int *count)
-{
- hg_msg msg, *retmsg;
- int length, i, error;
- char *tmp, **objptr;
- int *childIDs = NULL;
- int *ptr;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETCHILDCOLL_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL )
- return(-1);
-
- ptr = (int *) retmsg->buf;
- if(ptr == NULL) {
- if(retmsg) efree(retmsg);
- return -1;
- }
- if(*ptr++ == 0) {
- *count = *ptr++;
- if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
- for(i=0; i<*count; ptr++, i++)
- childIDs[i] = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-
- /* Now get for each child collection the object record */
- for(i=0; i<*count; i++) {
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
- build_msg_header(&msg, length, childIDs[i], GETOBJECT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- efree(childIDs);
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, childIDs[i]);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(childIDs);
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- }
- efree(childIDs);
-
- if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
- /* if emalloc fails, get at least all remaining messages from server */
- for(i=0; i<*count; i++) {
- retmsg = recv_hg_msg(sockfd);
- efree(retmsg->buf);
- efree(retmsg);
- }
- *childrec = NULL;
- lowerror = LE_MALLOC;
- return(-1);
- } else {
- *childrec = objptr;
-
- for(i=0; i<*count; i++) {
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg != NULL ) {
- if(0 == (int) *(retmsg->buf)) {
- *objptr = estrdup(retmsg->buf+sizeof(int));
- objptr++;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- *objptr = NULL;
- objptr++;
- efree(retmsg->buf);
- efree(retmsg);
- }
- }
- }
- }
-
- return(0);
-}
-
-int send_getchilddoccoll(int sockfd, hw_objectID objectID, hw_objectID **childIDs, int *count)
-{
- hg_msg msg, *retmsg;
- int length, error;
- char *tmp;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETCHILDDOCCOLL_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- } else {
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg != NULL ) {
- int *ptr, i, *ptr1;
-
- ptr = (int *) retmsg->buf;
- if(ptr == NULL) {
- if(retmsg) efree(retmsg);
- return -1;
- }
- if(*ptr++ == 0) {
- *count = *ptr++;
- if(NULL != (*childIDs = emalloc(*count * sizeof(hw_objectID)))) {
- ptr1 = *childIDs;
- for(i=0; i<*count; ptr++, i++)
- ptr1[i] = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
- }
- }
-
- return(0);
-
-}
-
-int send_getchilddoccollobj(int sockfd, hw_objectID objectID, hw_objrec ***childrec, int *count)
-{
- hg_msg msg, *retmsg;
- int length, i, error;
- char *tmp, **objptr;
- int *childIDs = NULL;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETCHILDDOCCOLL_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
- efree(msg.buf);
-
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg != NULL ) {
- int *ptr, i;
-
- ptr = (int *) retmsg->buf;
- if(ptr == NULL) {
- if(retmsg->buf) efree(retmsg->buf);
- return -1;
- }
- if(*ptr++ == 0) {
- *count = *ptr++;
- if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
- for(i=0; i<*count; ptr++, i++)
- childIDs[i] = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
- }
-
- /* Now get for each child collection the object record */
- for(i=0; i<*count; i++) {
- length = HEADER_LENGTH + sizeof(hw_objectID);
- build_msg_header(&msg, length, childIDs[i], GETOBJECT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, childIDs[i]);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- }
-
- if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
- /* if emalloc fails, get at least all remaining messages from server */
- for(i=0; i<*count; i++) {
- retmsg = recv_hg_msg(sockfd);
- efree(retmsg->buf);
- efree(retmsg);
- }
- *childrec = NULL;
- lowerror = LE_MALLOC;
- return(-1);
- } else {
- *childrec = objptr;
-
- for(i=0; i<*count; i++) {
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg != NULL ) {
- if(0 == (int) *(retmsg->buf)) {
- *objptr = estrdup(retmsg->buf+sizeof(int));
- objptr++;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- *objptr = NULL;
- objptr++;
- efree(retmsg->buf);
- efree(retmsg);
- }
- }
- }
- }
-
- return(0);
-}
-
-int send_getanchors(int sockfd, hw_objectID objectID, int **anchorIDs, int *count)
-{
- hg_msg msg, *retmsg;
- int length, error;
- char *tmp;
- int *ptr, i, *ptr1;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETANCHORS_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
- efree(msg.buf);
-
- if (NULL == (retmsg = recv_hg_msg(sockfd)))
- return(-1);
-
- ptr = (int *) retmsg->buf;
- if(ptr == NULL) {
- if(retmsg) efree(retmsg);
- return -1;
- }
- if(*ptr++ == 0) {
- *count = *ptr++;
- if(NULL != (*anchorIDs = emalloc(*count * sizeof(hw_objectID)))) {
- ptr1 = *anchorIDs;
- for(i=0; i<*count; ptr++, i++)
- ptr1[i] = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-
- return(0);
-}
-
-int send_getanchorsobj(int sockfd, hw_objectID objectID, char ***childrec, int *count)
-{
- hg_msg msg, *retmsg;
- int length, error;
- char *tmp;
- int *ptr, i, *ptr1;
- int *anchorIDs = NULL;
- char **objptr;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, 50, GETANCHORS_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
- efree(msg.buf);
-
- if (NULL == (retmsg = recv_hg_msg(sockfd)))
- return(-1);
-
- ptr = (int *) retmsg->buf;
- if(ptr == NULL) {
- if(retmsg) efree(retmsg);
- return -1;
- }
- if(*ptr++ == 0) {
- *count = *ptr++;
- if(NULL != (anchorIDs = emalloc(*count * sizeof(hw_objectID)))) {
- ptr1 = anchorIDs;
- for(i=0; i<*count; ptr++, i++)
- ptr1[i] = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-
- /* Now get for each anchor the object record */
- for(i=0; i<*count; i++) {
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
- build_msg_header(&msg, length, anchorIDs[i], GETOBJECT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, anchorIDs[i]);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- }
- if(anchorIDs) efree(anchorIDs);
-
- if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
- /* if emalloc fails, get at least all remaining messages from server */
- for(i=0; i<*count; i++) {
- retmsg = recv_hg_msg(sockfd);
- efree(retmsg->buf);
- efree(retmsg);
- }
- *childrec = NULL;
- lowerror = LE_MALLOC;
- return(-1);
- } else {
- *childrec = objptr;
-
- for(i=0; i<*count; i++) {
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg != NULL ) {
- if(0 == (int) *(retmsg->buf)) {
- *objptr = estrdup(retmsg->buf+sizeof(int));
- objptr++;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- *objptr = NULL;
- objptr++;
- efree(retmsg->buf);
- efree(retmsg);
- }
- }
- }
- }
-
- return(0);
-}
-
-int send_getdestforanchorsobj(int sockfd, char **anchorrec, char ***destrec, int count)
-{
- int i;
- char *objptr, **destptr;
- char *str;
- int objectID;
-
- if(NULL == (destptr = (char **) emalloc(count * sizeof(hw_objrec *)))) {
- lowerror = LE_MALLOC;
- return -1;
- }
-
- /* Now get for each anchor the object record of its destination */
- for(i=0; i<count; i++) {
- /* if you retrieve the anchors you sometimes get more than actually accessible.
- This happens for the object 0x29a9c. */
- if((NULL != anchorrec[i]) && (NULL != (str = fnAttributeValue(anchorrec[i], "Dest")))) {
- sscanf(str, "0x%x", &objectID);
- efree(str);
-
- if(0 > send_docbyanchorobj(sockfd, objectID, &objptr)) {
- efree(destptr);
- return -1;
- }
- destptr[i] = objptr;
- /* if we can't get the object rec of the dest, than this document
- is probably not accessible for us. For later functions simply
- set anchorrec[i] to NULL */
- if(destptr[i] == NULL) {
- if(anchorrec[i]) efree(anchorrec[i]);
- anchorrec[i] = NULL;
- }
- } else {
- destptr[i] = NULL;
- }
- }
- *destrec = destptr;
-
- return(0);
-}
-
-int send_getreldestforanchorsobj(int sockfd, char **anchorrec, char ***reldestrec, int count, int rootID, int thisID)
-{
- int i;
- char *docofanchorptr, **reldestptr;
- char *str;
- int destobjectID;
-
- if(NULL == (reldestptr = (char **) emalloc(count * sizeof(char *)))) {
- lowerror = LE_MALLOC;
- return -1;
- }
-
- /* Now get for each anchor the object record of its destination */
- for(i=0; i<count; i++) {
- /* if you retrieve the anchors you sometimes get more than actually accessible.
- */
- if((NULL != anchorrec[i]) && (NULL != (str = fnAttributeValue(anchorrec[i], "Dest")))) {
- sscanf(str, "0x%x", &destobjectID);
- efree(str);
-
- if(0 > send_docbyanchorobj(sockfd, destobjectID, &docofanchorptr)) {
- efree(reldestptr);
- return -1;
- }
- reldestptr[i] = docofanchorptr;
- /* if we can't get the object rec of the dest, than this document
- is probably not accessible for us. For later functions simply
- set anchorrec[i] to NULL */
- if(reldestptr[i] == NULL) {
- if(anchorrec[i]) efree(anchorrec[i]);
- anchorrec[i] = NULL;
- } else {
- int j, *retthisIDs, *retdestIDs, equaltill, mincount, countthis, countdest, destdocid;
- char destdocname[200];
- char anchorstr[300];
- char temp[200];
- char *strptr;
-
- if(NULL != (str = strstr(docofanchorptr, "Name="))) {
- str += 5;
- sscanf(str, "%s\n", destdocname);
- }
- if(NULL != (str = strstr(docofanchorptr, "ObjectID="))) {
- str += 9;
- sscanf(str, "0x%X", &destdocid);
- }
-
- send_incollections(sockfd, 1, 1, &thisID, 1, &rootID, &countthis, &retthisIDs);
- send_incollections(sockfd, 1, 1, &destdocid, 1, &rootID, &countdest, &retdestIDs);
-
-/*
-fprintf(stderr, "%d: ", thisID);
-for(k=0; k<countthis; k++)
- fprintf(stderr,"%d, ", retthisIDs[k]);
-fprintf(stderr,"\n");
-fprintf(stderr,"%d: ", destdocid);
-for(k=0; k<countdest; k++)
- fprintf(stderr,"%d: %d, ", destdocid, retdestIDs[k]);
-fprintf(stderr,"\n");
-*/
-
- mincount = (countthis < countdest) ? countthis : countdest;
- for(j=0; (j<mincount) && (retthisIDs[j]==retdestIDs[j]); j++)
- ;
- equaltill = j;
- strcpy(anchorstr, "Name=");
- for(j=equaltill; j<countthis; j++)
- strcat(anchorstr, "../");
- strcat(anchorstr, "./");
- for(j=equaltill; j<countdest; j++) {
- char *temprec, tempname[100];
- send_getobject(sockfd, retdestIDs[j], &temprec);
- if(NULL != (str = strstr(temprec, "Name="))) {
- str += 5;
- sscanf(str, "%s\n", tempname);
- } else if(NULL != (str = strstr(temprec, "ObjectID="))) {
- str += 9;
- sscanf(str, "%s\n", tempname);
- }
-
- sprintf(temp, "%s", tempname);
- strptr = temp;
- while(*strptr != '\0') {
- if(*strptr == '/')
- *strptr = '_';
- strptr++;
- }
-/* fprintf(stderr, "Adding '%s' to '%s'\n", temp, anchorstr); */
- strcat(anchorstr, temp);
- strcat(anchorstr, "/");
-/* fprintf(stderr, "Is now '%s'\n", anchorstr); */
- efree(temprec);
- }
- /* if the anchor destination is a collection it may not be added anymore. */
- if(destdocid != retdestIDs[countdest-1]) {
- strptr = destdocname;
- while(*strptr != '\0') {
- if(*strptr == '/')
- *strptr = '_';
- strptr++;
- }
- strcat(anchorstr, destdocname);
- } else {
- strcat(anchorstr, "index.html");
- }
- strcat(anchorstr, "\n");
- sprintf(temp, "ObjectID=0x%x", destdocid);
- strcat(anchorstr, temp);
-/* fprintf(stderr, "%s\n", anchorstr); */
- efree(retthisIDs);
- efree(retdestIDs);
- reldestptr[i] = estrdup(anchorstr);
- }
- } else {
- reldestptr[i] = NULL;
- }
- }
- *reldestrec = reldestptr;
-
- return(0);
-}
-
-int fn_findpath(int sockfd, int *retIDs, int count, int id) {
- int *pathIDs;
- int *parentIDs, pcount, pid;
- int u, j, i;
-
- if(NULL == (pathIDs = emalloc(count * sizeof(int)))) {
- lowerror = LE_MALLOC;
- return -1;
- }
- u = count-1;
- pid = id;
- pcount = 1;
- /* FIXME but parentIDs is not set at this point, why checking it? */
- while((u >= 0) && (pcount != 0) && (parentIDs != NULL) && (pid != 0)) {
-/*fprintf(stderr, "Get parents for %d\n", pid); */
- if(0 != send_getparents(sockfd, pid, &parentIDs, &pcount)) {
- efree(pathIDs);
- return -1;
- }
- pid = 0;
- for(i=0; i<pcount; i++) {
- for(j=0; j<count; j++) {
- if(parentIDs[i] == retIDs[j]) {
- pathIDs[u--] = retIDs[j];
- pid = retIDs[j];
- }
- }
- }
- if(pid == 0)
- fprintf(stderr, "parent not found in list\n");
- if(parentIDs) efree(parentIDs);
- }
-/*fprintf(stderr, "sorted path: "); */
- for(i=0; i<count; i++) {
- retIDs[i] = pathIDs[i];
-/*fprintf(stderr, "%d, ", retIDs[i]); */
- }
-/*fprintf(stderr, "\n"); */
- efree(pathIDs);
- return 0;
-}
-
-/********************************************************************
-* function getrellink() *
-* *
-* Returns the link to point from document with ID sourceID to *
-* document with id destID. *
-********************************************************************/
-int getrellink(int sockfd, int rootID, int thisID, int destID, char **reldeststr) {
- int i, j, k, *retthisIDs, *retdestIDs, equaltill, count, mincount, countthis, countdest;
- char anchorstr[300];
- char temp[200];
- char *strptr;
-
- send_incollections(sockfd, 1, 1, &thisID, 1, &rootID, &countthis, &retthisIDs);
- send_incollections(sockfd, 1, 1, &destID, 1, &rootID, &countdest, &retdestIDs);
-
-
-fprintf(stderr, "%d: ", thisID);
-for(k=0; k<countthis; k++)
- fprintf(stderr,"%d, ", retthisIDs[k]);
-fprintf(stderr,"\n");
-fprintf(stderr,"%d: ", destID);
-for(k=0; k<countdest; k++)
- fprintf(stderr,"%d, ", retdestIDs[k]);
-fprintf(stderr,"\n");
-
- /*
- ** The message incollections returned a list of collections
- ** in which the destID or thisID is contained. Unfortunately
- ** this list ist not the path for the destID or thisID, but
- ** a sorted list of collection IDs. If for example you are
- ** looking for an ID 20 which has a path 1 -> 5 -> 4 -> 20
- ** (this means: 20 is child of 4, 4 is child of 5, 5 is child
- ** of 1) it will return 1,4,5 instead of 1,5,4
- ** Consequently, we have to create the correct path, by checking
- ** for the parents and identifying it in the list.
- ** But there is another problem. If the id for which the list of
- ** of collection is generated is a colletion itself, it will
- ** show up in the list as well. In order to make the algorithmn
- ** work proberly it has to be the last member of the list.
- */
- for(i=0; i<countdest; i++)
- if(retdestIDs[i] == destID) {
- retdestIDs[i] = retdestIDs[countdest-1];
- retdestIDs[countdest-1] = destID;
- }
- count = (retdestIDs[countdest-1] == destID) ? countdest-1 : countdest;
- if(0 != fn_findpath(sockfd, retdestIDs, count, destID)) {
- efree(retthisIDs);
- efree(retdestIDs);
- return -1;
- }
- for(i=0; i<countthis; i++)
- if(retthisIDs[i] == thisID) {
- retthisIDs[i] = retthisIDs[countthis-1];
- retthisIDs[countthis-1] = thisID;
- }
- count = (retthisIDs[countthis-1] == thisID) ? countthis-1 : countthis;
- if(0 != fn_findpath(sockfd, retthisIDs, count, thisID)) {
- efree(retthisIDs);
- efree(retdestIDs);
- return -1;
- }
-
- mincount = (countthis < countdest) ? countthis : countdest;
-fprintf(stderr,"mincount = %d\n", mincount);
- for(j=0; (j<mincount) && (retthisIDs[j]==retdestIDs[j]); j++)
- ;
- equaltill = j;
-fprintf(stderr, "first unequal = %d\n", j);
- strcpy(anchorstr, "");
- for(j=equaltill; j<countthis; j++)
- strcat(anchorstr, "../");
- strcat(anchorstr, "./");
- for(j=equaltill; j<countdest; j++) {
- char *temprec, *str, tempname[100];
- if(0 == send_getobject(sockfd, retdestIDs[j], &temprec)) {
- if(NULL != (str = strstr(temprec, "Name="))) {
- str += 5;
- sscanf(str, "%s\n", tempname);
- } else if(NULL != (str = strstr(temprec, "ObjectID="))) {
- str += 9;
- sscanf(str, "%s\n", tempname);
- }
-
- sprintf(temp, "%s", tempname);
- strptr = temp;
- while(*strptr != '\0') {
- if(*strptr == '/')
- *strptr = '_';
- strptr++;
- }
-fprintf(stderr, "Adding '%s' (%d) to '%s'\n", temp, retdestIDs[j], anchorstr);
- strcat(anchorstr, temp);
- strcat(anchorstr, "/");
-fprintf(stderr, "Is now '%s'\n", anchorstr);
- efree(temprec);
- } else {
- strcat(anchorstr, "No access/");
- }
- }
- /* if the anchor destination is a collection it may not be added anymore. */
- if(destID != retdestIDs[countdest-1]) {
- char destdocname[100], *str;
- send_getobject(sockfd, destID, &str);
- if(NULL != (strptr = strstr(str, "Name="))) {
- strptr += 5;
- sscanf(strptr, "%s\n", destdocname);
- }
- strptr = destdocname;
- while(*strptr != '\0') {
- if(*strptr == '/')
- *strptr = '_';
- strptr++;
- }
- strcat(anchorstr, destdocname);
- efree(str);
- } else {
-/* strcat(anchorstr, "index.html"); */
- }
-/*fprintf(stderr, "%s\n", anchorstr); */
- efree(retthisIDs);
- efree(retdestIDs);
- *reldeststr = estrdup(anchorstr);
- return 0;
-}
-
-int send_identify(int sockfd, char *name, char *passwd, char **userdata) {
- hg_msg msg, *retmsg;
- int length;
- char *tmp;
-
- length = HEADER_LENGTH + sizeof(int) + strlen(name) + 1 + strlen(passwd) + 1;
-
- build_msg_header(&msg, length, msgid++, IDENTIFY_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, 0);
- tmp = build_msg_str(tmp, name);
- tmp = build_msg_str(tmp, passwd);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL )
- return(-1);
-
- *userdata = (char *) retmsg->buf;
- efree(retmsg);
-
- return(0);
-}
-
-int send_objectbyidquery(int sockfd, hw_objectID *IDs, int *count, char *query, char ***objrecs)
-{
- hg_msg msg, *retmsg;
- int length, error;
- char *tmp, *str;
- int *ptr, i, *ptr1;
- int *offsets, *childIDs;
- char **childrec;
-
- length = HEADER_LENGTH + sizeof(int) + sizeof(int) + *count * sizeof(hw_objectID);
- if(query)
- length = length + strlen(query) + 1;
-
- build_msg_header(&msg, length, msgid++, OBJECTBYIDQUERY_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, 1);
- tmp = build_msg_int(tmp, *count);
- for(i=0; i<*count; i++)
- tmp = build_msg_int(tmp, IDs[i]);
- if(query)
- tmp = build_msg_str(tmp, query);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL )
- return(-1);
-
- ptr = (int *) retmsg->buf;
- if(ptr == NULL) {
- if(retmsg) efree(retmsg);
- return -1;
- }
- if(*ptr++ != 0) {
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-
- *count = *ptr++;
- if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
- ptr1 = childIDs;
- for(i=0; i<*count; ptr++, i++)
- ptr1[i] = *ptr;
- if(NULL != (offsets = emalloc(*count * sizeof(int)))) {
- ptr1 = offsets;
- for(i=0; i<*count; ptr++, i++)
- ptr1[i] = *ptr;
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- efree(childIDs);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- str = (char *)ptr;
- if(NULL == (childrec = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
- efree(offsets);
- efree(childIDs);
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- } else {
- for(i=0; i<*count; i++) {
- childrec[i] = estrdup(str);
- str += offsets[i];
- }
- *objrecs = childrec;
- }
-
- efree(retmsg->buf);
- efree(retmsg);
- efree(childIDs);
- efree(offsets);
- return(0);
-}
-
-int send_getobjbyquery(int sockfd, char *query, int maxhits, hw_objectID **childIDs, int *count)
-{
- hg_msg msg, *retmsg;
- int length, error;
- char *tmp;
- int *ptr, i, *ptr1;
-
- length = HEADER_LENGTH + strlen(query) + 1;
-
- build_msg_header(&msg, length, msgid++, GETOBJBYQUERY_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_str(msg.buf, query);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL )
- return(-1);
-
- ptr = (int *) retmsg->buf;
- if(ptr == NULL) {
- if(retmsg) efree(retmsg);
- return -1;
- }
- if(*ptr++ == 0) {
- *count = (*ptr < maxhits) ? *ptr : maxhits;
- ptr++;
- if(NULL != (*childIDs = emalloc(*count * sizeof(hw_objectID)))) {
- ptr1 = *childIDs;
- for(i=0; i<*count; ptr++, i++)
- ptr1[i] = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
- return(0);
-}
-
-int send_getobjbyqueryobj(int sockfd, char *query, int maxhits, char ***childrec, int *count)
-{
- hg_msg msg, *retmsg;
- int length, i, error;
- char *tmp;
- int *childIDs = NULL;
- char **objptr;
- int *ptr, *ptr1;
-
- length = HEADER_LENGTH + strlen(query) + 1;
-
- build_msg_header(&msg, length, msgid++, GETOBJBYQUERY_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_str(msg.buf, query);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL )
- return(-1);
-
- ptr = (int *) retmsg->buf;
- if(ptr == NULL) {
- if(retmsg) efree(retmsg);
- return -1;
- }
- if(*ptr++ == 0) {
- *count = (*ptr < maxhits) ? *ptr : maxhits;
- ptr++;
- if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
- ptr1 = childIDs;
- for(i=0; i<*count; ptr++, i++)
- ptr1[i] = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-
- /* Now get for each child collection the object record */
- for(i=0; i<*count; i++) {
- length = HEADER_LENGTH + sizeof(hw_objectID);
- build_msg_header(&msg, length, childIDs[i], GETOBJECT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- efree(childIDs);
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, childIDs[i]);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- efree(childIDs);
- return(-1);
- }
-
- efree(msg.buf);
- }
- efree(childIDs);
-
- if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
- /* if emalloc fails, get at least all remaining messages from server */
- for(i=0; i<*count; i++) {
- retmsg = recv_hg_msg(sockfd);
- efree(retmsg->buf);
- efree(retmsg);
- }
- *childrec = NULL;
- lowerror = LE_MALLOC;
- return(-1);
- } else {
- *childrec = objptr;
-
- for(i=0; i<*count; i++) {
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg != NULL ) {
- if(0 == (int) *(retmsg->buf)) {
- *objptr = estrdup(retmsg->buf+sizeof(int));
- objptr++;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- *objptr = NULL;
- objptr++;
- efree(retmsg->buf);
- efree(retmsg);
- }
- }
- }
- }
-
- return(0);
-}
-
-int send_getobjbyquerycoll(int sockfd, hw_objectID collID, char *query, int maxhits, hw_objectID **childIDs, int *count)
-{
- hg_msg msg, *retmsg;
- int length, error;
- char *tmp;
- int *ptr, i, *ptr1;
-
- length = HEADER_LENGTH + strlen(query) + 1 + sizeof(int) + sizeof(collID);
-
- build_msg_header(&msg, length, msgid++, GETOBJBYQUERYCOLL_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, 1);
- tmp = build_msg_int(tmp, collID);
- tmp = build_msg_str(tmp, query);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL )
- return(-1);
-
- ptr = (int *) retmsg->buf;
- if(ptr == NULL) {
- if(retmsg) efree(retmsg);
- return -1;
- }
- if(*ptr++ == 0) {
- *count = (*ptr < maxhits) ? *ptr : maxhits;
- ptr++;
- if(NULL != (*childIDs = emalloc(*count * sizeof(hw_objectID)))) {
- ptr1 = *childIDs;
- for(i=0; i<*count; ptr++, i++)
- ptr1[i] = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
- return(0);
-}
-
-int send_getobjbyquerycollobj(int sockfd, hw_objectID collID, char *query, int maxhits, char ***childrec, int *count)
-{
- hg_msg msg, *retmsg;
- int length, i, error;
- char *tmp;
- hw_objectID *childIDs = NULL;
- char **objptr;
- int *ptr, *ptr1;
-
- length = HEADER_LENGTH + strlen(query) + 1 + sizeof(int) + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETOBJBYQUERYCOLL_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, 1);
- tmp = build_msg_int(tmp, collID);
- tmp = build_msg_str(tmp, query);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL )
- return -1;
-
- ptr = (int *) retmsg->buf;
- if(ptr == NULL) {
- if(retmsg) efree(retmsg);
- return -1;
- }
- if(*ptr++ == 0) {
- *count = (*ptr < maxhits) ? *ptr : maxhits;
- ptr++;
- if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
- ptr1 = childIDs;
- for(i=0; i<*count; ptr++, i++)
- ptr1[i] = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-
- /* Now get for each child collection the object record */
- for(i=0; i<*count; i++) {
- length = HEADER_LENGTH + sizeof(hw_objectID);
- build_msg_header(&msg, length, childIDs[i], GETOBJECT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- efree(childIDs);
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, childIDs[i]);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- efree(childIDs);
- return(-1);
- }
-
- efree(msg.buf);
- }
- efree(childIDs);
-
- if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
- /* if emalloc fails, get at least all remaining messages from server */
- for(i=0; i<*count; i++) {
- retmsg = recv_hg_msg(sockfd);
- efree(retmsg->buf);
- efree(retmsg);
- }
- *childrec = NULL;
- lowerror = LE_MALLOC;
- return(-1);
- } else {
- *childrec = objptr;
-
- for(i=0; i<*count; i++) {
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg != NULL ) {
- if(0 == (int) *(retmsg->buf)) {
- *objptr = estrdup(retmsg->buf+sizeof(int));
- objptr++;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- *objptr = NULL;
- objptr++;
- efree(retmsg->buf);
- efree(retmsg);
- }
- }
- }
- }
-
- return(0);
-}
-
-int send_getparents(int sockfd, hw_objectID objectID, hw_objectID **childIDs, int *count)
-{
- hg_msg msg, *retmsg;
- int length, i, error;
- char *tmp;
- int *ptr, *ptr1;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETPARENT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if (-1 == send_hg_msg(sockfd, &msg, length)) {
- efree(msg.buf);
- return(-2);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- return(-3);
- }
-
- ptr = (int *) retmsg->buf;
- if(ptr == NULL) {
- if(retmsg) efree(retmsg);
- return -1;
- }
- if(*ptr++ == 0) {
- *count = *ptr++;
- if(NULL != (*childIDs = emalloc(*count * sizeof(hw_objectID)))) {
- ptr1 = *childIDs;
- for(i=0; i<*count; ptr++, i++)
- ptr1[i] = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-
- return(0);
-}
-
-int send_getparentsobj(int sockfd, hw_objectID objectID, char ***childrec, int *count)
-{
- hg_msg msg, *retmsg;
- int length, i, error;
- char *tmp;
- hw_objectID *childIDs = NULL;
- char **objptr;
- int *ptr;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETPARENT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if (-1 == send_hg_msg(sockfd, &msg, length)) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- return(-1);
- }
-
- ptr = (int *) retmsg->buf;
- if(ptr == NULL) {
- if(retmsg) efree(retmsg);
- return -1;
- }
- if(*ptr++ == 0) {
- *count = *ptr++;
- if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
- for(i=0; i<*count; ptr++, i++)
- childIDs[i] = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-
- /* Now get for each parent the object record */
- for(i=0; i<*count; i++) {
- length = HEADER_LENGTH + sizeof(hw_objectID);
- build_msg_header(&msg, length, childIDs[i], GETOBJECT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, childIDs[i]);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- }
- efree(childIDs);
-
- if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
- /* if emalloc fails, get at least all remaining messages from server */
- for(i=0; i<*count; i++) {
- retmsg = recv_hg_msg(sockfd);
- efree(retmsg->buf);
- efree(retmsg);
- }
- *childrec = NULL;
- lowerror = LE_MALLOC;
- return(-1);
- } else {
- *childrec = objptr;
-
- for(i=0; i<*count; i++) {
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg != NULL ) {
- if(0 == (int) *(retmsg->buf)) {
- *objptr = estrdup(retmsg->buf+sizeof(int));
- objptr++;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- *objptr = NULL;
- objptr++;
- efree(retmsg->buf);
- efree(retmsg);
- }
- }
- }
- }
- return(0);
-}
-
-int send_pipedocument(int sockfd, char *host, hw_objectID objectID, int mode, int rootid, char **objattr, char **bodytag, char **text, int *count, char *urlprefix)
-{
- hg_msg msg, *retmsg;
- int length, len;
- char *tmp, header[80], *head_ptr, *sizestr;
- struct sockaddr_in serv_addr;
- struct hostent *hostptr;
- char *hostip = NULL;
- char *attributes = NULL;
- char *documenttype;
- char **anchors;
- int newfd, fd, port, size, error, ancount;
- int *ptr;
-
- if(-1 == (fd = fnCOpenDataCon(sockfd, &port))) {
- /* not set yet efree(msg.buf); */
- return(-1);
- }
-
- /*
- ** Get information about host
- */
- if(host) {
- if((hostptr = gethostbyname(host)) == NULL) {
- php3_error(E_WARNING, "gethostbyname failed for %s", host);
- HWSOCK_FCLOSE(fd);
- return(-2);
- }
- } else {
- HWSOCK_FCLOSE(fd);
- return(-2);
- }
-
- switch(hostptr->h_addrtype) {
- struct in_addr *ptr1;
- char *ptr;
- case AF_INET:
- ptr = hostptr->h_addr_list[0];
- ptr1 = (struct in_addr *) ptr;
- hostip = inet_ntoa(*ptr1);
- break;
- default:
- HWSOCK_FCLOSE(fd);
- return(-3);
- break;
- }
-
- /* Bottom half of send_getobject */
- if(0 > bh_send_getobject(sockfd, objectID)) {
- HWSOCK_FCLOSE(fd);
- return -4;
- }
-
- /* Upper half of send_getobject */
- if(0 > (error = uh_send_getobject(sockfd, &attributes))) {
- HWSOCK_FCLOSE(fd);
- return error;
- }
-
- length = HEADER_LENGTH + sizeof(hw_objectID) + sizeof(int) + strlen(hostip) + 1 + strlen("Refno=0x12345678") + 1;
- build_msg_header(&msg, length, msgid++, PIPEDOCUMENT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- if(attributes) efree(attributes);
- lowerror = LE_MALLOC;
- return(-5);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
- tmp = build_msg_int(tmp, port);
- tmp = build_msg_str(tmp, hostip);
- tmp = build_msg_str(tmp, "Refno=0x12345678");
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- if(attributes) efree(attributes);
- efree(msg.buf);
- HWSOCK_FCLOSE(fd);
- return(-6);
- }
- efree(msg.buf);
-
- /* Just check if the command was understood */
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- if(attributes) efree(attributes);
- HWSOCK_FCLOSE(fd);
- return(-7);
- }
-
- ptr = (int *) retmsg->buf;
- if((ptr == NULL) || (*ptr != 0)) {
- error = *ptr;
- if(retmsg->buf) efree(retmsg->buf);
- efree(retmsg);
- if(attributes) efree(attributes);
- HWSOCK_FCLOSE(fd);
- return(error);
- }
-
- efree(retmsg->buf);
- efree(retmsg);
-
- /* passively open the data connection. The HG server is probably
- already waiting for us.
- */
- len = sizeof(serv_addr);
- if((newfd = accept(fd, (struct sockaddr *) &serv_addr, &len)) < 0) {
-/* php3_printf("client: can't open data connection to server\n"); */
- if(attributes) efree(attributes);
- HWSOCK_FCLOSE(fd);
- return(-8);
- } else {
- HWSOCK_FCLOSE(fd);
- }
-
- /* First of all read the header */
- head_ptr = header;
- while((read_to(newfd, head_ptr, 1, rtimeout) == 1) && (*head_ptr != '\0')) {
- head_ptr++;
- }
-
- /* Let's see how big the document is and read it into var text */
- sizestr = strstr(header, "sz=");
- if(sizestr) {
- sizestr += 3;
- sscanf(sizestr, "%d\n", &size);
- *count = size;
- if((size != 0) && (NULL != (*text = malloc(size+1)))) {
- read_to(newfd, *text, size, rtimeout);
- (*text)[size] = '\0';
- }
- } else {
- *text = NULL;
- }
-
- /* close the data connection */
- HWSOCK_FCLOSE(newfd);
-
- documenttype = fnAttributeValue(attributes, "DocumentType");
-
- /* Make a copy with strdup (not estrdup), because we want to
- keep the attributes in hw_document struct.
- */
- *objattr = strdup(attributes);
- efree(attributes);
-
- if((documenttype != NULL) && (!strcmp(documenttype, "text") != 0)) {
- if(send_getanchorsobj(sockfd, objectID, &anchors, &ancount) == 0) {
- char **destrec, **reldestrec;
- DLIST *pAnchorList = NULL;
-
- send_getdestforanchorsobj(sockfd, anchors, &destrec, ancount);
- send_getreldestforanchorsobj(sockfd, anchors, &reldestrec, ancount, rootid, objectID);
- pAnchorList = fnCreateAnchorList(anchors, destrec, reldestrec, ancount, mode);
- /* Free only the array, the objrecs has been freed in fnCreateAnchorList() */
- if(anchors) efree(anchors);
- if(destrec) efree(destrec);
- if(reldestrec) efree(reldestrec);
-
- if(pAnchorList != NULL) {
- char *newtext;
- char *body;
-
- newtext = fnInsAnchorsIntoText(*text, pAnchorList, &body, urlprefix);
- dlst_kill(pAnchorList, fnDeleteAnchor);
- *bodytag = strdup(body);
- efree(body);
- *text = newtext;
- *count = strlen(newtext);
- }
- }
- } else {
- *bodytag = NULL;
- }
-
- if(documenttype) efree(documenttype);
- return(0);
-}
-
-int send_pipecgi(int sockfd, char *host, hw_objectID objectID, char *cgi_env_str, char **objattr, char **text, int *count)
-{
- hg_msg msg, *retmsg;
- int length, len, new_attr_len;
- char *tmp, header[80], *head_ptr, *sizestr;
- struct sockaddr_in serv_addr;
- struct hostent *hostptr;
- char *hostip = NULL;
- char *attributes = NULL;
- char *documenttype, *new_attr;
- int newfd, fd, port, size, error;
- int *ptr;
-
- if(-1 == (fd = fnCOpenDataCon(sockfd, &port))) {
- /* not set yet? efree(msg.buf); */
- return(-1);
- }
-
- /*
- ** Get information about host
- */
- if(host) {
- if((hostptr = gethostbyname(host)) == NULL) {
- php3_error(E_WARNING, "gethostbyname failed for %s", host);
- HWSOCK_FCLOSE(fd);
- return(-1);
- }
- } else {
- HWSOCK_FCLOSE(fd);
- return(-1);
- }
-
- switch(hostptr->h_addrtype) {
- struct in_addr *ptr1;
- char *ptr;
- case AF_INET:
- ptr = hostptr->h_addr_list[0];
- ptr1 = (struct in_addr *) ptr;
- hostip = inet_ntoa(*ptr1);
- break;
- default:
-/* php3_printf(stderr, "unknown address type\n"); */
- break;
- }
-
- /* Bottom half of send_getobject */
- if(0 > bh_send_getobject(sockfd, objectID)) {
- HWSOCK_FCLOSE(fd);
- return -1;
- }
-
- /* Upper half of send_getobject */
- if(0 > (error = uh_send_getobject(sockfd, &attributes))) {
- HWSOCK_FCLOSE(fd);
- return error;
- }
-
- new_attr_len = strlen(attributes) + strlen(cgi_env_str) + 2;
- new_attr = malloc(new_attr_len);
- strcpy(new_attr, attributes);
- strcat(new_attr, cgi_env_str);
- length = HEADER_LENGTH + strlen(new_attr) + 1 + sizeof(int) + strlen(hostip) + 1 + sizeof(int) + sizeof(int);
- build_msg_header(&msg, length, msgid++, PIPECGI_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- if(attributes) efree(attributes);
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_str(msg.buf, hostip);
- tmp = build_msg_int(tmp, port);
- tmp = build_msg_str(tmp, new_attr);
- tmp = build_msg_int(tmp, 1);
- tmp = build_msg_int(tmp, 0x12345678);
- free(new_attr);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- if(attributes) efree(attributes);
- efree(msg.buf);
- HWSOCK_FCLOSE(fd);
- return(-1);
- }
- efree(msg.buf);
-
- /* Just check if the command was understood */
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- if(attributes) efree(attributes);
- HWSOCK_FCLOSE(fd);
- return(-1);
- }
-
- ptr = (int *) retmsg->buf;
- if((ptr == NULL) || (*ptr != 0)) {
- if(retmsg->buf) efree(retmsg->buf);
- efree(retmsg);
- if(attributes) efree(attributes);
- HWSOCK_FCLOSE(fd);
- return(-1);
- }
-
- efree(retmsg->buf);
- efree(retmsg);
-
- /* passively open the data connection. The HG server is probably
- already waiting for us.
- */
- len = sizeof(serv_addr);
- if((newfd = accept(fd, (struct sockaddr *) &serv_addr, &len)) < 0) {
- if(attributes) efree(attributes);
- HWSOCK_FCLOSE(fd);
- return(-1);
- } else {
- HWSOCK_FCLOSE(fd);
- }
-
- /* First of all read the header */
- head_ptr = header;
- while((read_to(newfd, head_ptr, 1, rtimeout) == 1) && (*head_ptr != '\0')) {
- head_ptr++;
- }
-
- /* Let's see how big the document is and read it into var text */
- sizestr = strstr(header, "sz=");
- if(sizestr) {
- sizestr += 3;
- sscanf(sizestr, "%d\n", &size);
- *count = size;
- if((size != 0) && (NULL != (*text = malloc(size+1)))) {
- read_to(newfd, *text, size, rtimeout);
- }
- } else {
- *text = NULL;
- }
-
- /* close the data connection */
- HWSOCK_FCLOSE(newfd);
-
- documenttype = fnAttributeValue(attributes, "DocumentType");
-
- /* Make a copy with strdup (not estrdup), because we want to
- keep the attributes in hw_document struct.
- */
- *objattr = strdup(attributes);
- efree(attributes);
-
- if(documenttype) efree(documenttype);
- return(0);
-}
-
-int send_putdocument(int sockfd, char *host, hw_objectID parentID, char *objectRec, char *text, int count, hw_objectID *objectID)
-{
- hg_msg msg, *retmsg;
- int length, len;
- char *tmp, header[80], parms[30], *head_ptr;
- struct sockaddr_in serv_addr;
- struct hostent *hostptr;
- char *hostip = NULL;
- int newfd, fd, port, error;
- int *ptr;
-
- /* First of all we have to insert the document record */
- sprintf(parms, "Parent=0x%x", parentID);
- length = HEADER_LENGTH + strlen(objectRec) + 1 + strlen(parms) + 1;
-
- build_msg_header(&msg, length, msgid++, INSERTOBJECT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_str(msg.buf, objectRec);
- tmp = build_msg_str(tmp, parms);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- return(-1);
- }
-
- ptr = (int *) retmsg->buf;
- if(0 == (error = *ptr)) {
- ptr++;
- *objectID = *ptr;
- } else {
- if(retmsg->buf) efree(retmsg->buf);
- efree(retmsg);
- return(error);
- }
-
- efree(retmsg->buf);
- efree(retmsg);
-
- /*
- ** Get information about host
- */
- if(host) {
- if((hostptr = gethostbyname(host)) == NULL) {
- php3_error(E_WARNING, "gethostbyname failed for %s", host);
- /* close(fd); fd is not set yet */
- return(-1);
- }
- } else {
- /* close(fd); fd is not set yet */
- return(-1);
- }
-
- switch(hostptr->h_addrtype) {
- struct in_addr *ptr1;
- char *ptr;
- case AF_INET:
- ptr = hostptr->h_addr_list[0];
- ptr1 = (struct in_addr *) ptr;
- hostip = inet_ntoa(*ptr1);
- break;
- default:
-/* fprintf(stderr, "unknown address type\n"); */
- break;
- }
-
- if(-1 == (fd = fnCOpenDataCon(sockfd, &port))) {
- efree(msg.buf);
- return(-1);
- }
-
- /* Start building the PUTDOCUMENT message. I works even if
- the Refno is skipped. I guess the path can be omitted too. */
- length = HEADER_LENGTH + sizeof(hw_objectID) + sizeof(int) + strlen(hostip) + 1 + strlen("Hyperwave") + 1+ strlen("Refno=0x12345678") + 1;
-
- build_msg_header(&msg, length, msgid++, PUTDOCUMENT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, *objectID);
- tmp = build_msg_int(tmp, port);
- tmp = build_msg_str(tmp, hostip);
- tmp = build_msg_str(tmp, "Hyperwave");
- tmp = build_msg_str(tmp, "Refno=0x12345678");
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- HWSOCK_FCLOSE(fd);
- return(-1);
- }
- efree(msg.buf);
-
- /* passively open the data connection. The HG server is probably
- already waiting for us.
- */
- len = sizeof(serv_addr);
- if((newfd = accept(fd, (struct sockaddr *) &serv_addr, &len)) < 0) {
- HWSOCK_FCLOSE(fd);
- return(-1);
- } else {
- HWSOCK_FCLOSE(fd);
- }
-
- /* First of all write the header. According to the documentation
- there should be a header first. Well, after some investigation
- with tcpdump I found out, that Harmony and wavemaster don't
- sent it. The also do not sent the Refno in the PUTDOCUMENT msg.
- Anyway, we sent both. */
- head_ptr = header;
- sprintf(header, "HGHDR\nsz=%d\nref=12345678\n", count);
- len = strlen(header) + 1;
- if(len != write_to(newfd, header, len, wtimeout)) {
- HWSOCK_FCLOSE(newfd);
- return(-1);
- }
-
- /* And now the document */
- if(count != write_to(newfd, text, count, wtimeout)) {
- HWSOCK_FCLOSE(newfd);
- return(-1);
- }
-
- /* The data connection has to be close before the return
- msg can be read. The server will not sent it before. */
- HWSOCK_FCLOSE(newfd);
-
- /* Just check if the command was understood */
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- HWSOCK_FCLOSE(fd);
- return(-1);
- }
-
- ptr = (int *) retmsg->buf;
- if((ptr == NULL) || (*ptr != 0)) {
- if(retmsg->buf) efree(retmsg->buf);
- efree(retmsg);
- HWSOCK_FCLOSE(fd);
- return(-1);
- }
-
- efree(retmsg->buf);
- efree(retmsg);
-
- return(0);
-}
-
-int send_getsrcbydest(int sockfd, hw_objectID objectID, char ***childrec, int *count)
-{
- hg_msg msg, *retmsg;
- int length, i, error;
- char *tmp;
- int *childIDs = NULL;
- char **objptr;
- int *ptr, *ptr1;
-
- length = HEADER_LENGTH + sizeof(hw_objectID);
-
- build_msg_header(&msg, length, msgid++, GETSRCBYDEST_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, objectID);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL )
- return(-1);
-
- ptr = (int *) retmsg->buf;
- if(ptr == NULL) {
- if(retmsg) efree(retmsg);
- return -1;
- }
- if(*ptr++ == 0) {
- *count = *ptr;
- ptr++;
- if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
- ptr1 = childIDs;
- for(i=0; i<*count; ptr++, i++)
- ptr1[i] = *ptr;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- efree(retmsg->buf);
- efree(retmsg);
- lowerror = LE_MALLOC;
- return(-1);
- }
- } else {
- error = *((int *) retmsg->buf);
- efree(retmsg->buf);
- efree(retmsg);
- return error;
- }
-
- /* Now get for each source the object record */
- for(i=0; i<*count; i++) {
- length = HEADER_LENGTH + sizeof(hw_objectID);
- build_msg_header(&msg, length, childIDs[i], GETOBJECT_MESSAGE);
-
- if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- efree(childIDs);
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- tmp = build_msg_int(msg.buf, childIDs[i]);
-
- if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
- efree(childIDs);
- efree(msg.buf);
- return(-1);
- }
-
- efree(msg.buf);
- }
- efree(childIDs);
-
- if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
- /* if emalloc fails, get at least all remaining messages from server */
- for(i=0; i<*count; i++) {
- retmsg = recv_hg_msg(sockfd);
- efree(retmsg->buf);
- efree(retmsg);
- }
- *childrec = NULL;
- lowerror = LE_MALLOC;
- return(-1);
- } else {
- *childrec = objptr;
-
- for(i=0; i<*count; i++) {
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg != NULL ) {
- if(0 == (int) *(retmsg->buf)) {
- *objptr = estrdup(retmsg->buf+sizeof(int));
- objptr++;
- efree(retmsg->buf);
- efree(retmsg);
- } else {
- *objptr = NULL;
- objptr++;
- efree(retmsg->buf);
- efree(retmsg);
- }
- }
- }
- }
-
- return(0);
-}
-
-#define BUFFERLEN 200
-char *get_hw_info(hw_connection *conn) {
- char temp[BUFFERLEN];
- int len;
- struct sockaddr_in serv_addr;
-
- len = sizeof (serv_addr);
- if(getsockname(conn->socket, (struct sockaddr *)&serv_addr, &len) < 0)
- return(NULL);
-
- snprintf(temp, BUFFERLEN, "%s, %s, %d, %s, %d, %d", conn->server_string, conn->hostname,
- conn->version, conn->username,
- serv_addr.sin_port, conn->swap_on);
- return(estrdup(temp));
-}
-#undef BUFFERLEN
-
-static int send_hg_msg(int sockfd, hg_msg *msg, int length)
-{
- char *buf, *tmp;
-
-#ifdef HW_DEBUG
- php3_printf("<B>Sending msg: </B>type = %d -- id = %d<BR>\n", msg->msg_type, msg->version_msgid);
-#endif
- if ( length < HEADER_LENGTH ) {
-/* fprintf(stderr, "send_hg_msg: bad msg\n"); */
- return(-1);
- }
-
- if ( (tmp = buf = (char *)emalloc(length)) == NULL ) {
-/* perror("send_hg_msg"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
- memcpy(tmp, (char *) &(msg->length), 4);
- tmp += 4;
- memcpy(tmp, (char *) &(msg->version_msgid), 4);
- tmp += 4;
- memcpy(tmp, (char *) &(msg->msg_type), 4);
- if ( msg->length > HEADER_LENGTH ) {
- tmp += 4;
- memcpy(tmp, msg->buf, length-HEADER_LENGTH);
- }
-
- if ( hg_write(sockfd, buf, length) == -1 ) {
- efree(buf);
- return(-1);
- }
-
- efree(buf);
- return(0);
-}
-
-
-int send_ready(int sockfd)
-{
- hg_msg ready_msg;
-
- build_msg_header(&ready_msg, HEADER_LENGTH, version, READY_MESSAGE);
- ready_msg.buf = NULL;
-
- if ( send_hg_msg(sockfd, &ready_msg, HEADER_LENGTH) == -1 ) {
- return(-1);
- }
-
- return(0);
-}
-
-
-int send_command(int sockfd, int command, char **answer)
-{
- hg_msg comm_msg, *retmsg;
- char *comm_str, *tmp;
- int respond = 1;
- int length;
-
- if ( command == STAT_COMMAND )
- comm_str = STAT_COMMAND_STR;
- else
- comm_str = WHO_COMMAND_STR;
- length = HEADER_LENGTH + sizeof(respond) + strlen(comm_str) + 1;
-
- build_msg_header(&comm_msg, length, msgid++, COMMAND_MESSAGE);
-
- if ( (comm_msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-/* perror("send_command"); */
- lowerror = LE_MALLOC;
- return(-1);
- }
-
-
- tmp = build_msg_int(comm_msg.buf, respond);
- tmp = build_msg_str(tmp, comm_str);
-
-
- if ( send_hg_msg(sockfd, &comm_msg, length) == -1 ) {
- efree(comm_msg.buf);
- return(-1);
- }
- efree(comm_msg.buf);
-
- /* Just check if the command was understood */
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- return(-1);
- }
-
- *answer = retmsg->buf;
- efree(retmsg);
-
- return(0);
-}
-
-
-static void build_msg_header(hg_msg *msg, int length, int version_msgid, int msg_type)
-{
- if ( swap_on ) {
- msg->length = swap(length);
- msg->version_msgid = swap(version_msgid);
- msg->msg_type = swap(msg_type);
- }
- else {
- msg->length = length;
- msg->version_msgid = version_msgid;
- msg->msg_type = msg_type;
- }
-}
-
-
-static char *build_msg_int(char *buf, int val) {
- int tmp;
-
-#ifdef HW_DEBUG
- php3_printf(" Added int to header: <B>%d</B><BR>\n", val);
-#endif
- tmp = swap_on ? swap(val) : val;
- memcpy(buf, (char *)&tmp, 4);
-
- return(buf+4);
-}
-
-
-static char *build_msg_str(char *buf, char *str)
-{
- int len = strlen(str)+1;
-
-#ifdef HW_DEBUG
- php3_printf(" Added str to header: <B>%s</B> (%d)<BR>\n", str, strlen(str));
-#endif
-
- memcpy(buf, str, len);
-
- return(buf+len);
-}
-
-
-static int swap(int val)
-{
- int tmp;
-
- ((char*)&tmp)[0] = ((char*)&val)[3];
- ((char*)&tmp)[1] = ((char*)&val)[2];
- ((char*)&tmp)[2] = ((char*)&val)[1];
- ((char*)&tmp)[3] = ((char*)&val)[0];
-
- return(tmp);
-}
-
-
-void close_hg_connection(int sockfd)
-{
- shutdown(sockfd, 2);
- HWSOCK_FCLOSE(sockfd);
-}
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * End:
- */
-
diff --git a/ext/hyperwave/hg_comm.h b/ext/hyperwave/hg_comm.h
deleted file mode 100644
index 047bb855a1..0000000000
--- a/ext/hyperwave/hg_comm.h
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of the GNU General Public License as published by |
- | the Free Software Foundation; either version 2 of the License, or |
- | (at your option) any later version. |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with this program; if not, write to the Free Software |
- | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _HG_COMM_H
-#define _HG_COMM_H
-
-#if HYPERWAVE
-
-#include "hw_error.h"
-#define HG_SERVER_PORT 418
-
-#define F_DISTRIBUTED 0x80000000
-#define F_COMPRESSED 0x40000000
-#define F_VERSION 0x00003fff
-#define HW_VERSION 717L /* 7.17 */
-
-#define HEADER_LENGTH 12
-
-#define STAT_COMMAND_STR "stat"
-#define WHO_COMMAND_STR "who"
-#define STAT_COMMAND 1
-#define WHO_COMMAND 2
-
-#define GETDOCBYANCHOR_MESSAGE 2
-#define GETCHILDCOLL_MESSAGE 3
-#define GETPARENT_MESSAGE 4
-#define GETCHILDDOCCOLL_MESSAGE 5
-#define GETOBJECT_MESSAGE 7
-#define GETANCHORS_MESSAGE 8
-#define GETOBJBYQUERY_MESSAGE 9
-#define GETOBJBYQUERYCOLL_MESSAGE 10
-#define OBJECTBYIDQUERY_MESSAGE 11
-#define GETTEXT_MESSAGE 12
-#define INSDOC_MESSAGE 14
-#define INSCOLL_MESSAGE 17
-#define GETSRCBYDEST_MESSAGE 19
-#define MVCPDOCSCOLL_MESSAGE 22
-#define MVCPCOLLSCOLL_MESSAGE 23
-#define IDENTIFY_MESSAGE 24
-#define READY_MESSAGE 25
-#define COMMAND_MESSAGE 26
-#define CHANGEOBJECT_MESSAGE 27
-#define EDITTEXT_MESSAGE 28
-#define GETANDLOCK_MESSAGE 29
-#define UNLOCK_MESSAGE 30
-#define INCOLLECTIONS_MESSAGE 31
-#define INSERTOBJECT_MESSAGE 32
-#define PIPEDOCUMENT_MESSAGE 36
-#define DELETEOBJECT_MESSAGE 37
-#define PUTDOCUMENT_MESSAGE 38
-#define GETREMOTE_MESSAGE 39
-#define GETREMOTECHILDREN_MESSAGE 40
-#define CHILDREN_MESSAGE 44
-#define GETCGI_MESSAGE 45
-#define PIPECGI_MESSAGE 46
-
-#define HW_DEFAULT_LINK 0
-#define HW_IMAGE_LINK 1
-#define HW_BACKGROUND_LINK 2
-#define HW_INTAG_LINK 3
-#define HW_APPLET_LINK 4
-
-#define COPY 0
-#define MOVE 1
-#define DOCUMENT 0
-#define COLLECTION 1
-
-
-#if WIN32|WINNT
-# define SOCK_ERR INVALID_SOCKET
-# define SOCK_CONN_ERR SOCKET_ERROR
-# define HWSOCK_FCLOSE(s) closesocket(s)
-#else
-# define SOCK_ERR -1
-# define SOCK_CONN_ERR -1
-# define HWSOCK_FCLOSE(s) close(s)
-#endif
-
-
-/* Low error messages */
-#define LE_MALLOC -1
-
-typedef struct {
- int id; /* object ID of anchor */
- int tanchor; /* Type of anchor. Can be 1=Src, 2=Dest */
- int start; /* start of anchor */
- int end; /* end of anchor */
- char *nameanchor; /* name tag attribute of destination document */
- /* if anchor is of type Src the following are used as well */
- char *destdocname; /* name of destination document */
- char *link; /* url for external destination */
- int linktype; /* type of link. see above */
- char *tagattr; /* more attributes of tag, like Border=0 */
- char *htmlattr; /* */
- char *codebase; /* codebase of applet */
- char *code; /* code of applet */
- char *fragment; /* name link of Src */
-
- /* if anchor is of type Dest the following are used as well */
- char *keyword; /* name link of Dest */
- } ANCHOR;
-
-typedef struct {
- int length;
- int version_msgid;
- int msg_type;
- char *buf;
-} hg_msg;
-
-typedef struct {
- int socket;
- int swap_on;
- int version;
- char *server_string;
- char *hostname;
- char *username;
- int lasterror;
- int linkroot;
-} hw_connection;
-
-typedef int hw_objectID;
-typedef char hw_objrec;
-
-extern void set_swap(int do_swap);
-extern int open_hg_connection(char *server_name, int port);
-extern void close_hg_connection(int sockfd);
-extern int initialize_hg_connection(int sockfd, int *do_swap, int *version, char **userdata, char **server_string, char *username, char *password);
-
-extern int send_ready(int sockfd);
-extern int send_command(int sockfd, int command, char **answer);
-
-extern hg_msg *recv_hg_msg(int sockfd);
-extern hg_msg *recv_ready(int sockfd);
-extern hg_msg *recv_command(int sockfd);
-
-extern char *fnInsStr(char *str, int pos, char *insstr);
-extern int fnAttributeCompare(char *object, char *attrname, char *value);
-extern int getrellink(int sockfd, int rootID, int thisID, int destID, char **reldesstr);
-
-extern int send_deleteobject(int sockfd, hw_objectID objectID);
-extern int send_changeobject(int sockfd, hw_objectID objectID, char *mod);
-extern int send_groupchangeobject(int sockfd, hw_objectID objectID, char *mod);
-extern int send_getobject(int sockfd, hw_objectID objectID, char **attributes);
-extern int send_getandlock(int sockfd, hw_objectID objectID, char **attributes);
-extern int send_lock(int sockfd, hw_objectID objectID);
-extern int send_unlock(int sockfd, hw_objectID objectID);
-extern int send_gettext(int sockfd, hw_objectID objectID, int mode, int rootid, char **objattr, char **bodytag, char **text, int *count, char *urlprefix);
-extern int send_edittext(int sockfd, char *objattr, char *text);
-extern int send_getcgi(int sockfd, hw_objectID objectID, char *cgi_env_str, char **objattr, char **text, int *count);
-extern int send_getremote(int sockfd, hw_objectID objectID, char **objattr, char **text, int *count);
-extern int send_getremotechildren(int sockfd, char *attributes, char **text, int **childIDs, int *count);
-extern int send_docbyanchor(int sockfd, hw_objectID objectID, hw_objectID *anchorID);
-extern int send_docbyanchorobj(int sockfd, hw_objectID objectID, char **objrec);
-extern int send_mvcpdocscollscoll(int sockfd, hw_objectID *objectIDs, int count, int from, int dest, int cpmv, int docscoll);
-extern int send_childrenobj(int sockfd, hw_objectID objectID, char ***childrec, int *count);
-extern int send_getchildcoll(int sockfd, int objectID, hw_objectID **childIDs, int *count);
-extern int send_getchildcollobj(int sockfd, hw_objectID objectID, hw_objrec ***childrec, int *count);
-extern int send_getchilddoccoll(int sockfd, hw_objectID objectID, hw_objectID **childIDs, int *count);
-extern int send_getchilddoccollobj(int sockfd, hw_objectID objectID, hw_objrec ***childrec, int *count);
-extern int send_getanchors(int sockfd, hw_objectID objectID, hw_objectID **anchorIDs, int *count);
-extern int send_getanchorsobj(int sockfd, hw_objectID objectID, char ***childrec, int *count);
-extern int send_objectbyidquery(int sockfd, hw_objectID *IDs, int *count, char *query, char ***objrecs);
-extern int send_getobjbyquery(int sockfd, char *query, int maxhits, hw_objectID **childIDs, int *count);
-extern int send_getobjbyqueryobj(int sockfd, char *query, int maxhits, char ***childrec, int *count);
-extern int send_getobjbyquerycoll(int sockfd, hw_objectID collID, char *query, int maxhits, hw_objectID **childIDs, int *count);
-extern int send_getobjbyquerycollobj(int sockfd, hw_objectID collID, char *query, int maxhits, char ***childrec, int *count);
-extern int send_identify(int sockfd, char *name, char *passwd, char **userdata);
-extern int send_getparents(int sockfd, hw_objectID objectID, hw_objectID **childIDs, int *count);
-extern int send_children(int sockfd, hw_objectID objectID, hw_objectID **childIDs, int *count);
-extern int send_getparentsobj(int sockfd, hw_objectID objectID, char ***childrec, int *count);
-extern int send_pipedocument(int sockfd, char *hostname, hw_objectID objectID, int mode, int rootid, char** objattr, char **bodytag, char **text, int *count, char *urlprefix);
-extern int send_pipecgi(int sockfd, char *host, hw_objectID objectID, char *cgi_env_str, char **objattr, char **text, int *count);
-extern int send_putdocument(int sockfd, char *hostname, hw_objectID parentID, char *objectRec, char *text, int count, hw_objectID *objectID);
-extern int send_inscoll(int sockfd, hw_objectID objectID, char *objrec, hw_objectID *new_objectID);
-extern int send_insertobject(int sockfd, char *objrec, char *parms, hw_objectID *objectID);
-extern int send_insdoc(int sockfd, hw_objectID objectID, char *objrec, char *text, hw_objectID *new_objectID);
-extern int send_incollections(int sockfd, int retcol, int cobjids, hw_objectID *objectIDs, int ccollids, hw_objectID *collIDs, int *count, hw_objectID **retIDs);
-extern int send_getsrcbydest(int sockfd, hw_objectID objid, char ***childrec, int *count);
-extern int send_dummy(int sockfd, hw_objectID objectID, int msgid, char **attributes);
-extern char *get_hw_info(hw_connection *conn);
-
-#define send_mvcpdocscoll(sockfd,objectIDs,count,from,dest,mvcp) \
- send_mvcpdocscollscoll(sockfd,objectIDs,count,from,dest,mvcp,DOCUMENT)
-#define send_mvcpcollscoll(sockfd,objectIDs,count,from,dest,mvcp) \
- send_mvcpdocscollscoll(sockfd,objectIDs,count,from,dest,mvcp,COLLECTION)
-
-#endif
-#endif
diff --git a/ext/hyperwave/hw.c b/ext/hyperwave/hw.c
deleted file mode 100644
index 8b4e13702f..0000000000
--- a/ext/hyperwave/hw.c
+++ /dev/null
@@ -1,3678 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Uwe Steinmann |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-#if COMPILE_DL
-#include "dl/phpdl.h"
-#endif
-
-#include <stdlib.h>
-#include <errno.h>
-
-#include "php.h"
-#include "php_globals.h"
-#include "ext/standard/php3_standard.h"
-#include "ext/standard/head.h"
-#include "ext/standard/info.h"
-#include "SAPI.h"
-
-#if WIN32|WINNT
-#include <winsock.h>
-#else
-#include "build-defs.h"
-#endif
-
-#if HYPERWAVE
-
-#include "php_ini.h"
-#include "php3_hyperwave.h"
-
-//hw_module php3_hw_module;
-
-#define HW_ATTR_NONE 1
-#define HW_ATTR_LANG 2
-#define HW_ATTR_NR 3
-
-function_entry hw_functions[] = {
- PHP_FE(hw_connect, NULL)
- PHP_FE(hw_pconnect, NULL)
- PHP_FE(hw_close, NULL)
- PHP_FE(hw_root, NULL)
- PHP_FE(hw_info, NULL)
- PHP_FE(hw_connection_info, NULL)
- PHP_FE(hw_error, NULL)
- PHP_FE(hw_errormsg, NULL)
- PHP_FE(hw_getparentsobj, NULL)
- PHP_FE(hw_getparents, NULL)
- PHP_FE(hw_children, NULL)
- PHP_FE(hw_childrenobj, NULL)
- PHP_FE(hw_getchildcoll, NULL)
- PHP_FE(hw_getchildcollobj, NULL)
- PHP_FE(hw_getobject, NULL)
- PHP_FE(hw_getandlock, NULL)
- PHP_FE(hw_unlock, NULL)
- PHP_FE(hw_gettext, NULL)
- PHP_FE(hw_edittext, NULL)
- PHP_FE(hw_getcgi, NULL)
- PHP_FE(hw_getremote, NULL)
- PHP_FE(hw_getremotechildren, NULL)
- PHP_FE(hw_pipedocument, NULL)
- PHP_FE(hw_pipecgi, NULL)
- PHP_FE(hw_insertdocument, NULL)
- PHP_FE(hw_mv, NULL)
- PHP_FE(hw_cp, NULL)
- PHP_FE(hw_deleteobject, NULL)
- PHP_FE(hw_changeobject, NULL)
- PHP_FE(hw_modifyobject, NULL)
- PHP_FE(hw_docbyanchor, NULL)
- PHP_FE(hw_docbyanchorobj, NULL)
- PHP_FE(hw_getobjectbyquery, NULL)
- PHP_FE(hw_getobjectbyqueryobj, NULL)
- PHP_FE(hw_getobjectbyquerycoll, NULL)
- PHP_FE(hw_getobjectbyquerycollobj, NULL)
- PHP_FE(hw_getchilddoccoll, NULL)
- PHP_FE(hw_getchilddoccollobj, NULL)
- PHP_FE(hw_getanchors, NULL)
- PHP_FE(hw_getanchorsobj, NULL)
- PHP_FE(hw_getusername, NULL)
- PHP_FE(hw_setlinkroot, NULL)
- PHP_FE(hw_identify, NULL)
- PHP_FE(hw_free_document, NULL)
- PHP_FE(hw_new_document, NULL)
- PHP_FE(hw_output_document, NULL)
- PHP_FE(hw_document_size, NULL)
- PHP_FE(hw_document_attributes, NULL)
- PHP_FE(hw_document_bodytag, NULL)
- PHP_FE(hw_document_content, NULL)
- PHP_FE(hw_document_setcontent, NULL)
- PHP_FE(hw_objrec2array, NULL)
- PHP_FE(hw_array2objrec, NULL)
- PHP_FE(hw_incollections, NULL)
- PHP_FE(hw_inscoll, NULL)
- PHP_FE(hw_insertobject, NULL)
- PHP_FE(hw_insdoc, NULL)
- PHP_FE(hw_getsrcbydestobj, NULL)
- PHP_FE(hw_getrellink, NULL)
- PHP_FE(hw_who, NULL)
- PHP_FE(hw_stat, NULL)
- PHP_FE(hw_dummy, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry hw_module_entry = {
- "HyperWave", hw_functions, PHP_MINIT(hw), PHP_MSHUTDOWN(hw), NULL, NULL, PHP_MINFO(hw), 0, 0, 0, NULL
-};
-
-#ifdef ZTS
-int hw_globals_id;
-#else
-PHP_HW_API php_hw_globals hw_globals;
-#endif
-
-#ifdef COMPILE_DL
-DLEXPORT php3_module_entry *get_module(void) { return &hw_module_entry; }
-#endif
-
-void print_msg(hg_msg *msg, char *str, int txt);
-
-#if COMPILE_DL
-DLEXPORT php3_module_entry *get_module(void) { return &hw_module_entry; }
-#endif
-
-void _close_hw_link(hw_connection *conn)
-{
- if(conn->hostname)
- free(conn->hostname);
- if(conn->username)
- free(conn->username);
- close(conn->socket);
- free(conn);
- HwSG(num_links)--;
-}
-
-void _close_hw_plink(hw_connection *conn)
-{
- if(conn->hostname)
- free(conn->hostname);
- if(conn->username)
- free(conn->username);
- close(conn->socket);
- free(conn);
- HwSG(num_links)--;
- HwSG(num_persistent)--;
-}
-
-void _free_hw_document(hw_document *doc)
-{
- if(doc->data)
- free(doc->data);
- if(doc->attributes)
- free(doc->attributes);
- if(doc->bodytag)
- free(doc->bodytag);
- free(doc);
-}
-
-#ifdef ZTS
-static void php_hw_init_globals(php_hw_globals *hw_globals)
-{
- HwSG(num_persistent) = 0;
-}
-#endif
-
-static PHP_INI_MH(OnHyperwavePort) {
- HwSLS_FETCH();
-
- if (new_value==NULL) {
- HwSG(default_port) = HG_SERVER_PORT;
- } else {
- HwSG(default_port) = atoi(new_value);
- }
- return SUCCESS;
-}
-
-PHP_INI_BEGIN()
- STD_PHP_INI_ENTRY("hyerwave.allow_persistent", "0", PHP_INI_SYSTEM, OnUpdateInt, allow_persistent, php_hw_globals, hw_globals)
- PHP_INI_ENTRY("hyperwave.default_port", "418", PHP_INI_ALL, OnHyperwavePort)
-PHP_INI_END()
-
-PHP_MINIT_FUNCTION(hw) {
-
-#ifdef ZTS
- hw_globals_id = ts_allocate_id(sizeof(php_hw_globals), php_hw_init_globals, NULL);
-#else
- HwSG(num_persistent)=0;
-#endif
- REGISTER_INI_ENTRIES();
- HwSG(le_socketp) = register_list_destructors(_close_hw_link,NULL);
- HwSG(le_psocketp) = register_list_destructors(NULL,_close_hw_plink);
- HwSG(le_document) = register_list_destructors(_free_hw_document,NULL);
- hw_module_entry.type = type;
-
-// REGISTER_LONG_CONSTANT("HW_ATTR_LANG", HW_ATTR_LANG, CONST_CS | CONST_PERSISTENT);
-// REGISTER_LONG_CONSTANT("HW_ATTR_NR", HW_ATTR_NR, CONST_CS | CONST_PERSISTENT);
-// REGISTER_LONG_CONSTANT("HW_ATTR_NONE", HW_ATTR_NONE, CONST_CS | CONST_PERSISTENT);
- return SUCCESS;
-}
-
-PHP_MSHUTDOWN_FUNCTION(hw)
-{
- UNREGISTER_INI_ENTRIES();
- return SUCCESS;
-}
-
-/* creates an array in return value and frees all memory
- * Also adds as an assoc. array at the end of the return array with
- * statistics.
- */
-int make_return_objrec(pval **return_value, char **objrecs, int count)
-{
- zval *stat_arr;
- int i;
- int hidden, collhead, fullcollhead, total;
- int collheadnr, fullcollheadnr;
-
- if (array_init(*return_value) == FAILURE) {
- /* Ups, failed! Let's at least free the memory */
- for(i=0; i<count; i++)
- efree(objrecs[i]);
- efree(objrecs);
- return -1;
- }
-
- hidden = collhead = fullcollhead = total = 0;
- collheadnr = fullcollheadnr = -1;
- for(i=0; i<count; i++) {
- /* Fill the array with entries. No need to free objrecs[i], since
- * it is not duplicated in add_next_index_string().
- */
- if(NULL != objrecs[i]) {
- if(0 == fnAttributeCompare(objrecs[i], "PresentationHints", "Hidden"))
- hidden++;
- if(0 == fnAttributeCompare(objrecs[i], "PresentationHints", "CollectionHead")) {
- collhead++;
- collheadnr = total;
- }
- if(0 == fnAttributeCompare(objrecs[i], "PresentationHints", "FullCollectionHead")) {
- fullcollhead++;
- fullcollheadnr = total;
- }
- total++;
- add_next_index_string(*return_value, objrecs[i], 0);
- }
- }
- efree(objrecs);
-
- /* Array for statistics */
- MAKE_STD_ZVAL(stat_arr);
- if (array_init(stat_arr) == FAILURE) {
- return -1;
- }
-
- add_assoc_long(stat_arr, "Hidden", hidden);
- add_assoc_long(stat_arr, "CollectionHead", collhead);
- add_assoc_long(stat_arr, "FullCollectionHead", fullcollhead);
- add_assoc_long(stat_arr, "Total", total);
- add_assoc_long(stat_arr, "CollectionHeadNr", collheadnr);
- add_assoc_long(stat_arr, "FullCollectionHeadNr", fullcollheadnr);
-
- /* Add the stat array */
- zend_hash_next_index_insert((*return_value)->value.ht, &stat_arr, sizeof(zval), NULL);
-
- return 0;
-}
-
-/*
-** creates an array return value from object record
-*/
-int make2_return_array_from_objrec(pval **return_value, char *objrec, zval *sarr) {
- char *attrname, *str, *temp, language[3];
- int i, count;
- zval *spec_arr;
-
- /* Create an array with an entry containing specs for each attribute
- and fill in the specs for Title, Description, Keyword, Group.
- If an array is passed as the last argument use it instead.
- */
- if(NULL != sarr) {
- spec_arr = sarr;
- } else {
- MAKE_STD_ZVAL(spec_arr);
- array_init(spec_arr);
- add_assoc_long(spec_arr, "Title", HW_ATTR_LANG);
- add_assoc_long(spec_arr, "Description", HW_ATTR_LANG);
- add_assoc_long(spec_arr, "Keyword", HW_ATTR_LANG);
- add_assoc_long(spec_arr, "Group", HW_ATTR_NONE);
- }
-
- if (array_init(*return_value) == FAILURE) {
- (*return_value)->type = IS_STRING;
- (*return_value)->value.str.val = empty_string;
- (*return_value)->value.str.len = 0;
- return -1;
- }
-
- /* Loop through the attributes of object record and check
- if the attribute has a specification. If it has the value
- is added to array in spec record. If not it is added straight
- to the return_value array.
- */
- temp = estrdup(objrec);
- attrname = strtok(temp, "\n");
- while(attrname != NULL) {
- zval *data, **dataptr;
- long spec;
- str = attrname;
-
- /* Check if a specification is available.
- If it isn't available then insert the attribute as
- a string into the return array
- */
- while((*str != '=') && (*str != '\0'))
- str++;
- *str = '\0';
- str++;
- if(zend_hash_find(spec_arr->value.ht, attrname, strlen(attrname)+1, (void **) &dataptr) == FAILURE) {
- add_assoc_string(*return_value, attrname, str, 1);
- } else {
- zval *newarr;
- data = *dataptr;
- spec = data->value.lval;
-
- if(zend_hash_find((*return_value)->value.ht, attrname, strlen(attrname)+1, (void **) &dataptr) == FAILURE) {
- MAKE_STD_ZVAL(newarr);
- array_init(newarr);
- zend_hash_add((*return_value)->value.ht, attrname, strlen(attrname)+1, &newarr, sizeof(zval *), NULL);
- } else {
- newarr = *dataptr;
- }
-
- switch(spec) {
- case HW_ATTR_LANG:
- if(str[2] == ':') {
- str[2] = '\0';
- strcpy(language, str);
- str += 3;
- } else
- strcpy(language, "xx");
-
- add_assoc_string(newarr, language, str, 1);
- break;
- case HW_ATTR_NR:
- if(str[1] == ':') {
- str[1] = '\0';
- strcpy(language, str);
- str += 2;
- } else
- strcpy(language, "x");
-
- add_assoc_string(newarr, language, str, 1);
- break;
- case HW_ATTR_NONE:
- add_next_index_string(newarr, str, 1);
- break;
- }
- }
-
- attrname = strtok(NULL, "\n");
- }
- efree(temp);
-
- return(0);
-}
-
-int make_return_array_from_objrec(pval **return_value, char *objrec) {
- char *attrname, *str, *temp, language[3], *title;
- int iTitle, iDesc, iKeyword, iGroup;
- zval *title_arr;
- zval *desc_arr;
- zval *keyword_arr;
- zval *group_arr;
- int hasTitle = 0;
- int hasDescription = 0;
- int hasKeyword = 0;
- int hasGroup = 0;
-
- MAKE_STD_ZVAL(title_arr);
- MAKE_STD_ZVAL(desc_arr);
- MAKE_STD_ZVAL(keyword_arr);
- MAKE_STD_ZVAL(group_arr);
-
- if (array_init(*return_value) == FAILURE) {
- (*return_value)->type = IS_STRING;
- (*return_value)->value.str.val = empty_string;
- (*return_value)->value.str.len = 0;
- return -1;
- }
-
- /* Fill Array of titles, descriptions and keywords */
- temp = estrdup(objrec);
- attrname = strtok(temp, "\n");
- while(attrname != NULL) {
- str = attrname;
- iTitle = 0;
- iDesc = 0;
- iKeyword = 0;
- iGroup = 0;
- if(0 == strncmp(attrname, "Title=", 6)) {
- if ((hasTitle == 0) && (array_init(title_arr) == FAILURE)) {
- return -1;
- }
- hasTitle = 1;
- str += 6;
- iTitle = 1;
- } else if(0 == strncmp(attrname, "Description=", 12)) {
- if ((hasDescription == 0) && (array_init(desc_arr) == FAILURE)) {
- return -1;
- }
- hasDescription = 1;
- str += 12;
- iDesc = 1;
- } else if(0 == strncmp(attrname, "Keyword=", 8)) {
- if ((hasKeyword == 0) && (array_init(keyword_arr) == FAILURE)) {
- return -1;
- }
- hasKeyword = 1;
- str += 8;
- iKeyword = 1;
- } else if(0 == strncmp(attrname, "Group=", 6)) {
- if ((hasGroup == 0) && (array_init(group_arr) == FAILURE)) {
- return -1;
- }
- hasGroup = 1;
- str += 6;
- iGroup = 1;
- }
- if(iTitle || iDesc || iKeyword) { /* Poor error check if end of string */
- if(str[2] == ':') {
- str[2] = '\0';
- strcpy(language, str);
- str += 3;
- } else
- strcpy(language, "xx");
-
- title = str;
- if(iTitle)
- add_assoc_string(title_arr, language, title, 1);
- else if(iDesc)
- add_assoc_string(desc_arr, language, title, 1);
- else if(iKeyword)
- add_assoc_string(keyword_arr, language, title, 1);
- } else if(iGroup) {
- if(iGroup)
- add_next_index_string(group_arr, str, 1);
- }
- attrname = strtok(NULL, "\n");
- }
- efree(temp);
-
- /* Add the title array, if we have one */
- if(hasTitle) {
- zend_hash_update((*return_value)->value.ht, "Title", 6, &title_arr, sizeof(zval *), NULL);
-
- } else {
- efree(title_arr);
- }
-
-
- if(hasDescription) {
- /* Add the description array, if we have one */
- zend_hash_update((*return_value)->value.ht, "Description", 12, &desc_arr, sizeof(zval *), NULL);
-
- } else {
- efree(desc_arr);
- }
-
- if(hasKeyword) {
- /* Add the keyword array, if we have one */
- zend_hash_update((*return_value)->value.ht, "Keyword", 8, &keyword_arr, sizeof(zval *), NULL);
-
- } else {
- efree(keyword_arr);
- }
-
- if(hasGroup) {
- /* Add the Group array, if we have one */
- zend_hash_update((*return_value)->value.ht, "Group", 6, &group_arr, sizeof(zval *), NULL);
-
- } else {
- efree(group_arr);
- }
-
- /* All other attributes. Make a another copy first */
- temp = estrdup(objrec);
- attrname = strtok(temp, "\n");
- while(attrname != NULL) {
- str = attrname;
- /* We don't want to insert titles, descr., keywords a second time */
- if((0 != strncmp(attrname, "Title=", 6)) &&
- (0 != strncmp(attrname, "Description=", 12)) &&
- (0 != strncmp(attrname, "Group=", 6)) &&
- (0 != strncmp(attrname, "Keyword=", 8))) {
- while((*str != '=') && (*str != '\0'))
- str++;
- *str = '\0';
- str++;
- add_assoc_string(*return_value, attrname, str, 1);
- }
- attrname = strtok(NULL, "\n");
- }
- efree(temp);
-
- return(0);
-}
-
-#define BUFFERLEN 1024
-static char * make_objrec_from_array(HashTable *lht) {
- int i, count, keytype;
- ulong length;
- char *key, str[BUFFERLEN], *objrec = NULL;
- zval *keydata, **keydataptr;
-
- if(NULL == lht)
- return NULL;
-
- if(0 == (count = zend_hash_num_elements(lht)))
- return NULL;
-
- zend_hash_internal_pointer_reset(lht);
- objrec = malloc(1);
- *objrec = '\0';
- for(i=0; i<count; i++) {
- keytype = zend_hash_get_current_key(lht, &key, &length);
-// if(HASH_KEY_IS_STRING == keytype) {
- zend_hash_get_current_data(lht, (void **) &keydataptr);
- keydata = *keydataptr;
- switch(keydata->type) {
- case IS_STRING:
- if(HASH_KEY_IS_STRING == keytype)
- snprintf(str, BUFFERLEN, "%s=%s\n", key, keydata->value.str.val);
- else
- snprintf(str, BUFFERLEN, "%s\n", keydata->value.str.val);
- break;
- case IS_LONG:
- if(HASH_KEY_IS_STRING == keytype)
- snprintf(str, BUFFERLEN, "%s=0x%lX\n", key, keydata->value.lval);
- else
- snprintf(str, BUFFERLEN, "0x%lX\n", keydata->value.lval);
- break;
- case IS_ARRAY: {
- int i, len, keylen, count;
- char *strarr, *ptr, *ptr1;
- count = zend_hash_num_elements(keydata->value.ht);
- if(count > 0) {
- strarr = make_objrec_from_array(keydata->value.ht);
- len = strlen(strarr) - 1;
- keylen = strlen(key);
- if(NULL == (ptr = malloc(len + 1 + count*(keylen+1)))) {
- free(objrec);
- return(NULL);
- }
- ptr1 = ptr;
- *ptr1 = '\0';
- strcpy(ptr1, key);
- ptr1 += keylen;
- *ptr1++ = '=';
- for(i=0; i<len; i++) {
- *ptr1++ = strarr[i];
- if(strarr[i] == '\n') {
- strcpy(ptr1, key);
- ptr1 += keylen;
- *ptr1++ = '=';
- } else if(strarr[i] == '=')
- ptr1[-1] = ':';
- }
- *ptr1++ = '\n';
- *ptr1 = '\0';
- strlcpy(str, ptr, sizeof(str));
- }
- break;
- }
- }
- if(HASH_KEY_IS_STRING == keytype) efree(key);
- objrec = realloc(objrec, strlen(objrec)+strlen(str)+1);
- strcat(objrec, str);
-// }
- zend_hash_move_forward(lht);
- }
- return objrec;
-}
-#undef BUFFERLEN
-
-static int * make_ints_from_array(HashTable *lht) {
- int i, count;
- int *objids = NULL;
- zval **keydata;
-
- if(NULL == lht)
- return NULL;
-
- if(0 == (count = zend_hash_num_elements(lht)))
- return NULL;
-
- zend_hash_internal_pointer_reset(lht);
- if(NULL == (objids = emalloc(count*sizeof(int))))
- return NULL;
- for(i=0; i<count; i++) {
- zend_hash_get_current_data(lht, (void **) &keydata);
- switch((*keydata)->type) {
- case IS_LONG:
- objids[i] = (*keydata)->value.lval;
- break;
- default:
- objids[i] = 0;
- }
- zend_hash_move_forward(lht);
- }
- return objids;
-}
-
-#define BUFFERLEN 30
-static void php3_hw_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
-{
- pval *argv[4];
- int argc;
- int sockfd;
- int port = 0;
- char *host = NULL;
- char *userdata = NULL;
- char *server_string = NULL;
- char *username = NULL;
- char *password = NULL;
- char *hashed_details;
- char *str = NULL;
- char buffer[BUFFERLEN];
- int hashed_details_length;
- hw_connection *ptr;
- int do_swap;
- int version = 0;
-
- argc = ARG_COUNT(ht);
- switch(argc) {
- case 2:
- case 4:
- if (getParametersArray(ht, argc, argv) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- }
-
- /* Host: */
- convert_to_string(argv[0]);
- host = (char *) estrndup(argv[0]->value.str.val,argv[0]->value.str.len);
-
- /* Port: */
- convert_to_long(argv[1]);
- port = argv[1]->value.lval;
-
- /* Username and Password */
- if(argc > 2) {
- /* Username */
- convert_to_string(argv[2]);
- username = (char *) estrndup(argv[2]->value.str.val,argv[2]->value.str.len);
- /* Password */
- convert_to_string(argv[3]);
- password = (char *) estrndup(argv[3]->value.str.val,argv[3]->value.str.len);
- }
-
- /* Create identifier string for connection */
- snprintf(buffer, BUFFERLEN, "%d", port);
- hashed_details_length = strlen(host)+strlen(buffer)+8;
- if(NULL == (hashed_details = (char *) emalloc(hashed_details_length+1))) {
- if(host) efree(host);
- if(password) efree(password);
- if(username) efree(username);
- php_error(E_ERROR, "Could not get memory for connection details");
- RETURN_FALSE;
- }
- sprintf(hashed_details, "hw_%s_%d", host, port);
-
- if (persistent) {
- list_entry *le;
-
- /* try to find if we already have this link in our persistent list */
- if (zend_hash_find(plist, hashed_details, hashed_details_length+1, (void **) &le)==FAILURE) {
- list_entry new_le;
-
- if (HwSG(max_links)!=-1 && HwSG(num_links)>=HwSG(max_links)) {
- php_error(E_ERROR,"Hyperwave: Too many open links (%d)",HwSG(num_links));
- if(host) efree(host);
- if(username) efree(username);
- if(password) efree(password);
- efree(hashed_details);
- RETURN_FALSE;
- }
- if (HwSG(max_persistent!=-1) && HwSG(num_persistent)>=HwSG(max_persistent)) {
- php_error(E_ERROR,"Hyperwave: Too many open persistent links (%d)",HwSG(num_persistent));
- if(host) efree(host);
- if(username) efree(username);
- if(password) efree(password);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- if ( (sockfd = open_hg_connection(host, port)) < 0 ) {
- php_error(E_ERROR, "Could not open connection to %s, Port: %d (retval=%d, errno=%d)", host, port, sockfd, errno);
- if(host) efree(host);
- if(username) efree(username);
- if(password) efree(password);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- if(NULL == (ptr = malloc(sizeof(hw_connection)))) {
- php_error(E_ERROR, "Could not get memory for connection structure");
- if(host) efree(host);
- if(username) efree(username);
- if(password) efree(password);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- if(0 != (ptr->lasterror = initialize_hg_connection(sockfd, &do_swap, &version, &userdata, &server_string, username, password))) {
- php_error(E_ERROR, "Could not initalize hyperwave connection");
- if(host) efree(host);
- if(username) efree(username);
- if(password) efree(password);
- if(userdata) efree(userdata);
- if(server_string) free(server_string);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- if(username) efree(username);
- if(password) efree(password);
-
- ptr->version = version;
- ptr->server_string = server_string;
- ptr->socket = sockfd;
- ptr->swap_on = do_swap;
- ptr->linkroot = 0;
- ptr->hostname = strdup(host);
- ptr->username = strdup("anonymous");
-
- new_le.ptr = (void *) ptr;
- new_le.type = HwSG(le_psocketp);
-
- if (zend_hash_update(plist,hashed_details,hashed_details_length+1,(void *) &new_le, sizeof(list_entry), NULL)==FAILURE) {
- php_error(E_ERROR, "Could not hash table with connection details");
- if(host) efree(host);
- if(username) efree(username);
- if(password) efree(password);
- if(server_string) free(server_string);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- HwSG(num_links)++;
- HwSG(num_persistent)++;
- } else {
- /*php_printf("Found already open connection\n"); */
- if (le->type != HwSG(le_psocketp)) {
- RETURN_FALSE;
- }
- ptr = le->ptr;
- }
-
- return_value->value.lval = php3_list_insert(ptr,HwSG(le_psocketp));
- return_value->type = IS_LONG;
-
- } else {
- list_entry *index_ptr,new_index_ptr;
-
- /* first we check the hash for the hashed_details key. if it exists,
- * it should point us to the right offset where the actual hyperwave link sits.
- * if it doesn't, open a new hyperwave link, add it to the resource list,
- * and add a pointer to it with hashed_details as the key.
- */
- if (zend_hash_find(list,hashed_details,hashed_details_length+1,(void **) &index_ptr)==SUCCESS) {
- int type,link;
- void *ptr;
-
- if (index_ptr->type != le_index_ptr) {
- RETURN_FALSE;
- }
- link = (int) index_ptr->ptr;
- ptr = (hw_connection *) php3_list_find(link,&type); /* check if the link is still there */
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- return_value->value.lval = HwSG(default_link) = link;
- return_value->type = IS_LONG;
- efree(hashed_details);
- if(username) efree(username);
- if(password) efree(password);
- if(host) efree(host);
- return;
- } else {
- zend_hash_del(list,hashed_details,hashed_details_length+1);
- }
- }
-
- if ( (sockfd = open_hg_connection(host, port)) < 0 ) {
- php_error(E_ERROR, "Could not open connection to %s, Port: %d (retval=%d", host, port, sockfd);
- if(host) efree(host);
- if(username) efree(username);
- if(password) efree(password);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- if(NULL == (ptr = malloc(sizeof(hw_connection)))) {
- if(host) efree(host);
- if(username) efree(username);
- if(password) efree(password);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- if(0 != (ptr->lasterror = initialize_hg_connection(sockfd, &do_swap, &version, &userdata, &server_string, username, password))) {
- php_error(E_ERROR, "Could not initalize hyperwave connection");
- if(host) efree(host);
- if(username) efree(username);
- if(password) efree(password);
- if(userdata) efree(userdata);
- if(server_string) free(server_string);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- if(username) efree(username);
- if(password) efree(password);
-
- ptr->version = version;
- ptr->server_string = server_string;
- ptr->socket = sockfd;
- ptr->swap_on = do_swap;
- ptr->linkroot = 0;
- ptr->hostname = strdup(host);
- ptr->username = strdup("anonymous");
-
- return_value->value.lval = php3_list_insert(ptr,HwSG(le_socketp));
- return_value->type = IS_LONG;
-
- new_index_ptr.ptr = (void *) return_value->value.lval;
- new_index_ptr.type = le_index_ptr;
- if (zend_hash_update(list,hashed_details,hashed_details_length+1,(void *) &new_index_ptr, sizeof(list_entry), NULL)==FAILURE) {
- php_error(E_ERROR, "Could not update connection details in hash table");
- if(host) efree(host);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- }
-
- efree(hashed_details);
- if(host) efree(host);
- HwSG(default_link)=return_value->value.lval;
-
- /* At this point we have a working connection. If userdata was given
- we are also indentified.
- If there is no userdata because hw_connect was called without username
- and password, we don't evaluate userdata.
- */
- if(NULL == userdata)
- return;
-
- if(ptr->username) free(ptr->username);
- str = userdata;
- while((*str != 0) && (*str != ' '))
- str++;
- if(*str != '\0')
- ptr->username = strdup(++str);
- else
- ptr->username = NULL;
- efree(userdata);
-}
-#undef BUFFERLEN
-
-/* Start of user level functions */
-/* ***************************** */
-/* {{{ proto int hw_connect(string host, int port [string username [, string password]])
- Connect to the Hyperwave server */
-PHP_FUNCTION(hw_connect)
-{
- php3_hw_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
-}
-/* }}} */
-
-/* {{{ proto int hw_pconnect(string host, int port [string username [, string password]])
- Connect to the Hyperwave server persistent */
-PHP_FUNCTION(hw_pconnect)
-{
- php3_hw_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
-}
-/* }}} */
-
-/* {{{ proto void hw_close(int link)
- Close connection to Hyperwave server */
-PHP_FUNCTION(hw_close) {
- pval *arg1;
- int id, type;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- id=arg1->value.lval;
- ptr = php3_list_find(id,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
- php3_list_delete(id);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void hw_info(int link)
- Outputs info string */
-PHP_FUNCTION(hw_info)
-{
- pval *arg1;
- int id, type;
- hw_connection *ptr;
- char *str;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- id=arg1->value.lval;
- ptr = php3_list_find(id,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
- if(NULL != (str = get_hw_info(ptr))) {
- /*
- php_printf("%s\n", str);
- efree(str);
- */
- return_value->value.str.len = strlen(str);
- return_value->value.str.val = str;
- return_value->type = IS_STRING;
- return;
- }
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto int hw_error(int link)
- Returns last error number */
-PHP_FUNCTION(hw_error)
-{
- pval *arg1;
- int id, type;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- id=arg1->value.lval;
- ptr = php3_list_find(id,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
- RETURN_LONG(ptr->lasterror);
-}
-/* }}} */
-
-/* {{{ proto string hw_errormsg(int link)
- Returns last error message */
-PHP_FUNCTION(hw_errormsg)
-{
- pval *arg1;
- int id, type;
- hw_connection *ptr;
- char errstr[100];
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- id=arg1->value.lval;
- ptr = php3_list_find(id,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- switch(ptr->lasterror) {
- case 0:
- sprintf(errstr, "No error");
- break;
- case NOACCESS:
- sprintf(errstr, "No access");
- break;
- case NODOCS:
- sprintf(errstr, "No documents");
- break;
- case NONAME:
- sprintf(errstr, "No collection name");
- break;
- case NODOC:
- sprintf(errstr, "Object is not a document");
- break;
- case NOOBJ:
- sprintf(errstr, "No object received");
- break;
- case NOCOLLS:
- sprintf(errstr, "No collections received");
- break;
- case DBSTUBNG:
- sprintf(errstr, "Connection to low-level database failed");
- break;
- case NOTFOUND:
- sprintf(errstr, "Object not found");
- break;
- case EXIST:
- sprintf(errstr, "Collection already exists");
- break;
- case FATHERDEL:
- sprintf(errstr, "parent collection disappeared");
- break;
- case FATHNOCOLL:
- sprintf(errstr, "parent collection not a collection");
- break;
- case NOTEMPTY:
- sprintf(errstr, "Collection not empty");
- break;
- case DESTNOCOLL:
- sprintf(errstr, "Destination not a collection");
- break;
- case SRCEQDEST:
- sprintf(errstr, "Source equals destination");
- break;
- case REQPEND:
- sprintf(errstr, "Request pending");
- break;
- case TIMEOUT:
- sprintf(errstr, "Timeout");
- break;
- case NAMENOTUNIQUE:
- sprintf(errstr, "Name not unique");
- break;
- case WRITESTOPPED:
- sprintf(errstr, "Database now read-only; try again later");
- break;
- case LOCKED:
- sprintf(errstr, "Object locked; try again later");
- break;
- case NOTREMOVED:
- sprintf(errstr, "Attribute not removed");
- break;
- case CHANGEBASEFLD:
- sprintf(errstr, "Change of base-attribute");
- break;
- case FLDEXISTS:
- sprintf(errstr, "Attribute exists");
- break;
- case NOLANGUAGE:
- sprintf(errstr, "No or unknown language specified");
- break;
- default:
- sprintf(errstr, "Unknown error: %d", ptr->lasterror);
- }
- RETURN_STRING(errstr, 1);
-}
-/* }}} */
-
-/* {{{ proto int hw_root(void)
- Returns object id of root collection */
-PHP_FUNCTION(hw_root)
-{
- return_value->value.lval = 0;
- return_value->type = IS_LONG;
-}
-/* }}} */
-
-char *php3_hw_command(INTERNAL_FUNCTION_PARAMETERS, int comm) {
- pval *arg1;
- int link, type;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- return NULL;
- }
- convert_to_long(arg1);
- link=arg1->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",link);
- return NULL;
- }
-
- set_swap(ptr->swap_on);
- {
- char *object = NULL;
- if (0 != (ptr->lasterror = send_command(ptr->socket, comm, &object)))
- return NULL;
-
- return object;
- }
-}
-
-/* {{{ proto string hw_stat(int link)
- Returns status string */
-PHP_FUNCTION(hw_stat) {
- char *object;
-
- object = php3_hw_command(INTERNAL_FUNCTION_PARAM_PASSTHRU, STAT_COMMAND);
- if(object == NULL)
- RETURN_FALSE;
-
- return_value->value.str.val = object;
- return_value->value.str.len = strlen(object);
- return_value->type = IS_STRING;
-}
-/* }}} */
-
-/* {{{ proto array hw_who(int link)
- Returns names and info of users loged in */
-PHP_FUNCTION(hw_who) {
- zval *user_arr;
- char *object, *ptr, *temp, *attrname;
- int i;
-
- object = php3_hw_command(INTERNAL_FUNCTION_PARAM_PASSTHRU, WHO_COMMAND);
- if(object == NULL)
- RETURN_FALSE;
-
- ptr = object;
-
-php_printf("%s\n", ptr);
- /* Skip first two lines, they just contain:
- Users in Database
-
- */
- while((*ptr != '\0') && (*ptr != '\n'))
- ptr++;
- while((*ptr != '\0') && (*ptr != '\n'))
- ptr++;
- if(*ptr == '\0') {
- efree(object);
- RETURN_FALSE;
- }
-
- if (array_init(return_value) == FAILURE) {
- efree(object);
- RETURN_FALSE;
- }
-
- temp = estrdup(ptr);
- attrname = strtok(temp, "\n");
- i = 0;
- while(attrname != NULL) {
- char *name;
-
- user_arr = (zval *) emalloc(sizeof(zval));
- if (array_init(user_arr) == FAILURE) {
- efree(object);
- RETURN_FALSE;
- }
-
- ptr = attrname;
- if(*ptr++ == '*')
- add_assoc_long(user_arr, "self", 1);
- else
- add_assoc_long(user_arr, "self", 0);
-
- ptr++;
- name = ptr;
- while((*ptr != '\0') && (*ptr != ' '))
- ptr++;
- *ptr = '\0';
- add_assoc_string(user_arr, "id", name, 1);
-
- ptr++;
- name = ptr;
- while((*ptr != '\0') && (*ptr != ' '))
- ptr++;
- *ptr = '\0';
- add_assoc_string(user_arr, "name", name, 1);
-
- ptr++;
- while((*ptr != '\0') && (*ptr == ' '))
- ptr++;
-
- name = ptr;
- while((*ptr != '\0') && (*ptr != ' '))
- ptr++;
- *ptr = '\0';
- add_assoc_string(user_arr, "system", name, 1);
-
- ptr++;
- while((*ptr != '\0') && (*ptr == ' '))
- ptr++;
-
- name = ptr;
- while((*ptr != '\0') && (*ptr != ' '))
- ptr++;
- *ptr = '\0';
- add_assoc_string(user_arr, "onSinceDate", name, 1);
-
- ptr++;
- while((*ptr != '\0') && (*ptr == ' '))
- ptr++;
-
- name = ptr;
- while((*ptr != '\0') && (*ptr != ' '))
- ptr++;
- *ptr = '\0';
- add_assoc_string(user_arr, "onSinceTime", name, 1);
-
- ptr++;
- while((*ptr != '\0') && (*ptr == ' '))
- ptr++;
-
- name = ptr;
- while((*ptr != '\0') && (*ptr != ' '))
- ptr++;
- *ptr = '\0';
- add_assoc_string(user_arr, "TotalTime", name, 1);
-
- /* Add the user array */
- zend_hash_index_update(return_value->value.ht, i++, &user_arr, sizeof(pval), NULL);
-
- attrname = strtok(NULL, "\n");
- }
- efree(temp);
- efree(object);
-
-}
-/* }}} */
-
-/* {{{ proto string hw_dummy(int link, int id, int msgid)
- ??? */
-PHP_FUNCTION(hw_dummy) {
- pval *arg1, *arg2, *arg3;
- int link, id, type, msgid;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- convert_to_long(arg3);
- link=arg1->value.lval;
- id=arg2->value.lval;
- msgid=arg3->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- {
- char *object = NULL;
- if (0 != (ptr->lasterror = send_dummy(ptr->socket, id, msgid, &object)))
- RETURN_FALSE;
-
-php_printf("%s", object);
- return_value->value.str.val = object;
- return_value->value.str.len = strlen(object);
- return_value->type = IS_STRING;
- }
-}
-/* }}} */
-
-/* {{{ proto string hw_getobject(int link, int objid)
- Returns object record */
-PHP_FUNCTION(hw_getobject) {
- pval *argv[3];
- int argc, link, id, type, multi;
- hw_connection *ptr;
-
- argc = ARG_COUNT(ht);
- if(argc < 2 || argc > 3)
- WRONG_PARAM_COUNT;
- if (getParametersArray(ht, argc, argv) == FAILURE)
- WRONG_PARAM_COUNT;
-
- convert_to_long(argv[0]);
- if(argv[1]->type == IS_ARRAY) {
- multi = 1;
- convert_to_array(argv[1]);
- } else {
- multi = 0;
- convert_to_long(argv[1]);
- }
-
- if(argc == 3) {
- convert_to_string(argv[2]);
- }
-
- link=argv[0]->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- if(multi) {
- char **objects = NULL;
- int count, *ids, i;
- HashTable *lht;
- zval **keydata;
-
- lht = argv[1]->value.ht;
- if(0 == (count = zend_hash_num_elements(lht)))
- RETURN_FALSE;
- ids = emalloc(count * sizeof(hw_objectID));
-
- zend_hash_internal_pointer_reset(lht);
- for(i=0; i<count; i++) {
- zend_hash_get_current_data(lht, (void **) &keydata);
- switch((*keydata)->type) {
- case IS_LONG:
- ids[i] = (*keydata)->value.lval;
- break;
- default:
- ids[i] = (*keydata)->value.lval;
- }
- zend_hash_move_forward(lht);
- }
-
- if (0 != (ptr->lasterror = send_objectbyidquery(ptr->socket, ids, &count, argv[2]->value.str.val, &objects))) {
- efree(ids);
- RETURN_FALSE;
- }
- efree(ids);
- if (array_init(return_value) == FAILURE) {
- efree(objects);
- RETURN_FALSE;
- }
-
- for(i=0; i<count; i++) {
- add_index_string(return_value, i, objects[i], 0);
- }
- efree(objects);
-
- } else {
- char *object = NULL;
- id=argv[1]->value.lval;
- if (0 != (ptr->lasterror = send_getobject(ptr->socket, id, &object)))
- RETURN_FALSE;
-
- RETURN_STRING(object, 0);
- }
-}
-/* }}} */
-
-/* {{{ proto int hw_insertobject(int link, string objrec, string parms)
- Inserts an object */
-PHP_FUNCTION(hw_insertobject) {
- pval *arg1, *arg2, *arg3;
- int link, type;
- char *objrec, *parms;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_string(arg2);
- convert_to_string(arg3);
- link=arg1->value.lval;
- objrec=arg2->value.str.val;
- parms=arg3->value.str.val;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",link);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- {
- int objid;
- if (0 != (ptr->lasterror = send_insertobject(ptr->socket, objrec, parms, &objid)))
- RETURN_FALSE;
-
- RETURN_LONG(objid);
- }
-}
-/* }}} */
-
-/* {{{ proto string hw_getandlock(int link, int objid)
- Returns object record and locks object */
-PHP_FUNCTION(hw_getandlock) {
- pval *arg1, *arg2;
- int link, id, type;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- {
- char *object = NULL;
- if (0 != (ptr->lasterror = send_getandlock(ptr->socket, id, &object)))
- RETURN_FALSE;
-
- RETURN_STRING(object, 0);
- }
-}
-/* }}} */
-
-/* {{{ proto void hw_unlock(int link, int objid)
- Unlocks object */
-PHP_FUNCTION(hw_unlock) {
- pval *arg1, *arg2;
- int link, id, type;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- if (0 != (ptr->lasterror = send_unlock(ptr->socket, id)))
- RETURN_FALSE;
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void hw_deleteobject(int link, int objid)
- Deletes object */
-PHP_FUNCTION(hw_deleteobject) {
- pval *arg1, *arg2;
- int link, id, type;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- if (0 != (ptr->lasterror = send_deleteobject(ptr->socket, id)))
- RETURN_FALSE;
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void hw_changeobject(int link, int objid, array attributes)
- Changes attributes of an object (obsolete) */
-#define BUFFERLEN 200
-PHP_FUNCTION(hw_changeobject) {
- pval *arg1, *arg2, *arg3;
- int link, id, type, i;
- hw_connection *ptr;
- char *modification, *oldobjrec, buf[BUFFERLEN];
- char *tmp;
- HashTable *newobjarr;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1); /* Connection */
- convert_to_long(arg2); /* object ID */
- convert_to_array(arg3); /* Array with new attributes */
- link=arg1->value.lval;
- id=arg2->value.lval;
- newobjarr=arg3->value.ht;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- /* get the old object record */
- if(0 != (ptr->lasterror = send_getandlock(ptr->socket, id, &oldobjrec)))
- RETURN_FALSE;
-
- zend_hash_internal_pointer_reset(newobjarr);
- modification = strdup("");
- for(i=0; i<zend_hash_num_elements(newobjarr); i++) {
- char *key, *str, *str1, newattribute[BUFFERLEN];
- pval *data, **dataptr;
- int j, noinsert=1;
- ulong ind;
-
- zend_hash_get_current_key(newobjarr, &key, &ind);
- zend_hash_get_current_data(newobjarr, (void *) &dataptr);
- data = *dataptr;
- switch(data->type) {
- case IS_STRING:
- if(strlen(data->value.str.val) == 0)
- snprintf(newattribute, BUFFERLEN, "rem %s", key);
- else
- snprintf(newattribute, BUFFERLEN, "add %s=%s", key, data->value.str.val);
- noinsert = 0;
- break;
- default:
- newattribute[0] = '\0';
- }
- if(!noinsert) {
- modification = fnInsStr(modification, 0, "\\");
- modification = fnInsStr(modification, 0, newattribute);
-/* modification = fnInsStr(modification, 0, "add "); */
-
- /* Retrieve the old attribute from object record */
- if(NULL != (str = strstr(oldobjrec, key))) {
- str1 = str;
- j = 0;
- while((str1 != NULL) && (*str1 != '\n') && (j < BUFFERLEN-1)) {
- buf[j++] = *str1++;
- }
- buf[j] = '\0';
- modification = fnInsStr(modification, 0, "\\");
- modification = fnInsStr(modification, 0, buf);
- modification = fnInsStr(modification, 0, "rem ");
- }
- }
- efree(key);
- zend_hash_move_forward(newobjarr);
- }
- efree(oldobjrec);
-
- set_swap(ptr->swap_on);
- modification[strlen(modification)-1] = '\0';
- if (0 != (ptr->lasterror = send_changeobject(ptr->socket, id, modification))) {
- free(modification);
- send_unlock(ptr->socket, id);
- RETURN_FALSE;
- }
- free(modification);
- if (0 != (ptr->lasterror = send_unlock(ptr->socket, id))) {
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-#undef BUFFERLEN
-/* }}} */
-
-/* {{{ proto void hw_modifyobject(int link, int objid, array remattributes, array addattributes, [int mode])
- Modifies attributes of an object */
-#define BUFFERLEN 200
-PHP_FUNCTION(hw_modifyobject) {
- pval *argv[5];
- int argc;
- int link, id, type, i, mode;
- hw_connection *ptr;
- char *modification;
- HashTable *remobjarr, *addobjarr;
-
- argc = ARG_COUNT(ht);
- if((argc > 5) || (argc < 4))
- WRONG_PARAM_COUNT;
-
- if (getParametersArray(ht, argc, argv) == FAILURE)
- if(argc < 4) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(argv[0]); /* Connection */
- convert_to_long(argv[1]); /* object ID */
- convert_to_array(argv[2]); /* Array with attributes to remove */
- convert_to_array(argv[3]); /* Array with attributes to add */
- if(argc == 5) {
- convert_to_long(argv[4]);
- mode = argv[4]->value.lval;
- } else
- mode = 0;
- link=argv[0]->value.lval;
- id=argv[1]->value.lval;
- remobjarr=argv[2]->value.ht;
- addobjarr=argv[3]->value.ht;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- modification = strdup("");
- if(addobjarr != NULL) {
- zend_hash_internal_pointer_reset(addobjarr);
- for(i=0; i<zend_hash_num_elements(addobjarr); i++) {
- char *key, addattribute[BUFFERLEN];
- zval *data, **dataptr;
- int noinsert=1;
- ulong ind;
-
- zend_hash_get_current_key(addobjarr, &key, &ind);
- zend_hash_get_current_data(addobjarr, (void *) &dataptr);
- data = *dataptr;
- switch(data->type) {
- case IS_STRING:
- if(strlen(data->value.str.val) > 0) {
- snprintf(addattribute, BUFFERLEN, "add %s=%s", key, data->value.str.val);
-/* fprintf(stderr, "add: %s\n", addattribute); */
- noinsert = 0;
- }
- break;
- case IS_ARRAY: {
- int i, len, keylen, count;
- char *strarr, *ptr, *ptr1;
- count = zend_hash_num_elements(data->value.ht);
- if(count > 0) {
- strarr = make_objrec_from_array(data->value.ht);
- len = strlen(strarr) - 1;
- keylen = strlen(key);
- if(NULL == (ptr = malloc(len + 1 + count*(keylen+1+4)))) {
- if(modification)
- free(modification);
- RETURN_FALSE;
- }
- ptr1 = ptr;
- *ptr1 = '\0';
- strcpy(ptr1, "add ");
- ptr1 += 4;
- strcpy(ptr1, key);
- ptr1 += keylen;
- *ptr1++ = '=';
- for(i=0; i<len; i++) {
- *ptr1++ = strarr[i];
- if(strarr[i] == '\n') {
- ptr1[-1] = '\\';
- strcpy(ptr1, "add ");
- ptr1 += 4;
- strcpy(ptr1, key);
- ptr1 += keylen;
- *ptr1++ = '=';
- } else if(strarr[i] == '=')
- ptr1[-1] = ':';
- }
- *ptr1 = '\0';
- strlcpy(addattribute, ptr, sizeof(addattribute));
- noinsert = 0;
- }
- break;
- }
- }
- if(!noinsert) {
- modification = fnInsStr(modification, 0, "\\");
- modification = fnInsStr(modification, 0, addattribute);
- }
- efree(key);
- zend_hash_move_forward(addobjarr);
- }
- }
-
- if(remobjarr != NULL) {
- int nr;
- zend_hash_internal_pointer_reset(remobjarr);
- nr = zend_hash_num_elements(remobjarr);
- for(i=0; i<nr; i++) {
- char *key, remattribute[BUFFERLEN];
- zval *data, **dataptr;
- int noinsert=1;
- ulong ind;
-
- zend_hash_get_current_key(remobjarr, &key, &ind);
- zend_hash_get_current_data(remobjarr, (void *) &dataptr);
- data = *dataptr;
- switch(data->type) {
- case IS_STRING:
- if(strlen(data->value.str.val) > 0) {
- snprintf(remattribute, BUFFERLEN, "rem %s=%s", key, data->value.str.val);
- noinsert = 0;
- } else {
- snprintf(remattribute, BUFFERLEN, "rem %s", key);
- noinsert = 0;
- }
- break;
- case IS_ARRAY: {
- int i, len, keylen, count;
- char *strarr, *ptr, *ptr1;
- count = zend_hash_num_elements(data->value.ht);
- if(count > 0) {
- strarr = make_objrec_from_array(data->value.ht);
- len = strlen(strarr) - 1;
- keylen = strlen(key);
- if(NULL == (ptr = malloc(len + 1 + count*(keylen+1+4)))) {
- if(modification)
- free(modification);
- RETURN_FALSE;
- }
- ptr1 = ptr;
- *ptr1 = '\0';
- strcpy(ptr1, "rem ");
- ptr1 += 4;
- strcpy(ptr1, key);
- ptr1 += keylen;
- *ptr1++ = '=';
- for(i=0; i<len; i++) {
- *ptr1++ = strarr[i];
- if(strarr[i] == '\n') {
- ptr1[-1] = '\\';
- strcpy(ptr1, "rem ");
- ptr1 += 4;
- strcpy(ptr1, key);
- ptr1 += keylen;
- *ptr1++ = '=';
- } else if(strarr[i] == '=')
- ptr1[-1] = ':';
- }
- *ptr1++ = '\n';
- *ptr1 = '\0';
- strlcpy(remattribute, ptr, sizeof(remattribute));
- noinsert = 0;
- }
- break;
- }
- }
- if(!noinsert) {
- modification = fnInsStr(modification, 0, "\\");
- modification = fnInsStr(modification, 0, remattribute);
- }
- efree(key);
- zend_hash_move_forward(remobjarr);
- }
- }
-
- set_swap(ptr->swap_on);
- modification[strlen(modification)-1] = '\0';
- if(strlen(modification) == 0) {
- ptr->lasterror = 0;
- free(modification);
- RETURN_TRUE;
- }
-/* fprintf(stderr, "modifyobject: %s\n", modification); */
- switch(mode) {
- case 0:
- if (0 == (ptr->lasterror = send_lock(ptr->socket, id))) {
- if (0 == (ptr->lasterror = send_changeobject(ptr->socket, id, modification))) {
- if (0 != (ptr->lasterror = send_unlock(ptr->socket, id))) {
- php_error(E_WARNING,"Aiii, Changeobject failed and couldn't unlock object (id = 0x%X)", id);
- free(modification);
- RETURN_FALSE;
- }
- free(modification);
- RETURN_FALSE;
- } else {
- send_unlock(ptr->socket, id);
- free(modification);
- RETURN_FALSE;
- }
- } else {
- php_error(E_WARNING,"Could not lock object (id = 0x%X)", id);
- free(modification);
- RETURN_FALSE;
- }
- break;
- case 1:
-/* WARNING: send_groupchangobject() only works right, if each attribute
- can be modified. Doing a changeobject recursively often tries to
- modify objects which cannot be modified e.g. because an attribute cannot
- be removed. In such a case no further modification on that object is done.
- Doing a 'rem Rights\add Rights=R:a' will fail completely if the attribute
- Rights is not there already. The object locking is done in send_groupchangeobject();
-*/
- if (0 != (ptr->lasterror = send_groupchangeobject(ptr->socket, id, modification))) {
- free(modification);
- RETURN_FALSE;
- }
- break;
- default:
- php_error(E_WARNING,"hw_modifyobject: Mode must be 0 or 1 (recursive)");
- }
- free(modification);
- RETURN_TRUE;
-}
-#undef BUFFERLEN
-/* }}} */
-
-void php3_hw_mvcp(INTERNAL_FUNCTION_PARAMETERS, int mvcp) {
- pval *arg1, *arg2, *arg3, *arg4;
- int link, type, dest=0, from=0, count;
- HashTable *src_arr;
- hw_connection *ptr;
- int collIDcount, docIDcount, i, *docIDs, *collIDs;
-
- switch(mvcp) {
- case MOVE: /* Move also has fromID */
- if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE)
- WRONG_PARAM_COUNT;
- break;
- case COPY:
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE)
- WRONG_PARAM_COUNT;
- break;
- }
- convert_to_long(arg1);
- convert_to_array(arg2);
- convert_to_long(arg3);
- link=arg1->value.lval;
- src_arr=arg2->value.ht;
- switch(mvcp) {
- case MOVE: /* Move also has fromID, which is arg3 --> arg4 becomes destID */
- convert_to_long(arg4);
- from=arg3->value.lval;
- dest=arg4->value.lval;
- break;
- case COPY: /* No fromID for Copy needed --> arg3 is destID */
- dest=arg3->value.lval;
- from = 0;
- break;
- }
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",link);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
-
- count = zend_hash_num_elements(src_arr);
- if(NULL == (collIDs = emalloc(count * sizeof(int)))) {
- RETURN_FALSE;
- }
-
- if(NULL == (docIDs = emalloc(count * sizeof(int)))) {
- efree(collIDs);
- RETURN_FALSE;
- }
-
- collIDcount = docIDcount = 0;
- zend_hash_internal_pointer_reset(src_arr);
- for(i=0; i<count; i++) {
- char *objrec;
- zval *keydata, **keydataptr;
- zend_hash_get_current_data(src_arr, (void **) &keydataptr);
- keydata = *keydataptr;
- if(keydata->type == IS_LONG) {
- if(0 != (ptr->lasterror = send_getobject(ptr->socket, keydata->value.lval, &objrec))) {
- efree(collIDs);
- efree(docIDs);
- RETURN_FALSE;
- }
- if(0 == fnAttributeCompare(objrec, "DocumentType", "collection"))
- collIDs[collIDcount++] = keydata->value.lval;
- else
- docIDs[docIDcount++] = keydata->value.lval;
- efree(objrec);
- }
- zend_hash_move_forward(src_arr);
- }
-
- if (0 != (ptr->lasterror = send_mvcpdocscoll(ptr->socket, docIDs, docIDcount, from, dest, mvcp))) {
- efree(collIDs);
- efree(docIDs);
- RETURN_FALSE;
- }
-
- if (0 != (ptr->lasterror = send_mvcpcollscoll(ptr->socket, collIDs, collIDcount, from, dest, mvcp))) {
- efree(collIDs);
- efree(docIDs);
- RETURN_FALSE;
- }
-
- efree(collIDs);
- efree(docIDs);
-
- RETURN_LONG(docIDcount + collIDcount);
-}
-
-/* {{{ proto void hw_mv(int link, array objrec, int from, int dest)
- Moves object */
-PHP_FUNCTION(hw_mv) {
- php3_hw_mvcp(INTERNAL_FUNCTION_PARAM_PASSTHRU, MOVE);
-}
-/* }}} */
-
-/* {{{ proto void hw_cp(int link, array objrec, int dest)
- Copies object */
-PHP_FUNCTION(hw_cp) {
- php3_hw_mvcp(INTERNAL_FUNCTION_PARAM_PASSTHRU, COPY);
-}
-/* }}} */
-
-/* {{{ proto hwdoc hw_gettext(int link, int objid[, int rootid])
- Returns text document. Links are relative to rootid if given */
-PHP_FUNCTION(hw_gettext) {
- pval *argv[3];
- int argc, link, id, type, mode;
- int rootid = 0;
- char *urlprefix;
- hw_document *doc;
- hw_connection *ptr;
-
- argc = ARG_COUNT(ht);
- if((argc > 3) || (argc < 2))
- WRONG_PARAM_COUNT;
-
- if (getParametersArray(ht, argc, argv) == FAILURE)
- RETURN_FALSE;
-
- convert_to_long(argv[0]);
- convert_to_long(argv[1]);
- mode = 0;
- urlprefix = NULL;
- if(argc == 3) {
- switch(argv[2]->type) {
- case IS_LONG:
- convert_to_long(argv[2]);
- rootid = argv[2]->value.lval;
- mode = 1;
- break;
- case IS_STRING:
- convert_to_string(argv[2]);
- urlprefix = argv[2]->value.str.val;
- break;
- }
- }
- link=argv[0]->value.lval;
- id=argv[1]->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- {
- char *object = NULL;
- char *attributes = NULL;
- char *bodytag = NULL;
- int count;
- /* !!!! memory for object and attributes is allocated with malloc !!!! */
- if (0 != (ptr->lasterror = send_gettext(ptr->socket, id, mode, rootid, &attributes, &bodytag, &object, &count, urlprefix)))
- RETURN_FALSE;
- doc = malloc(sizeof(hw_document));
- doc->data = object;
- doc->attributes = attributes;
- doc->bodytag = bodytag;
- doc->size = count;
- return_value->value.lval = php3_list_insert(doc,HwSG(le_document));
- return_value->type = IS_LONG;
- }
-}
-/* }}} */
-
-/* {{{ proto void hw_edittext(int link, hwdoc doc)
- Modifies text document */
-PHP_FUNCTION(hw_edittext) {
- pval *arg1, *arg2;
- int link, doc, type;
- hw_connection *ptr;
- hw_document *docptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- ptr = php3_list_find(link,&type);
-
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find socket identifier %d",link);
- RETURN_FALSE;
- }
-
- doc=arg2->value.lval;
- docptr = php3_list_find(doc,&type);
-
- if(!docptr || (type!=HwSG(le_document))) {
- php_error(E_WARNING,"Unable to find document identifier %d", doc);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- {
- if (0 != (ptr->lasterror = send_edittext(ptr->socket, docptr->attributes, docptr->data))) {
- RETURN_FALSE;
- }
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto hwdoc hw_getcgi(int link, int objid)
- Returns the output of a cgi script */
-#define BUFFERLEN 1000
-/* FIX ME: The buffer cgi_env_str should be allocated dynamically */
-PHP_FUNCTION(hw_getcgi) {
- pval *arg1, *arg2;
- int link, id, type;
- hw_document *doc;
- hw_connection *ptr;
- char cgi_env_str[BUFFERLEN];
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- {
- char *object = NULL;
- char *attributes = NULL;
- int count;
-
- /* Here is another undocument function of Hyperwave.
- If you call a cgi script with getcgi-message, you will
- have to provide the complete cgi enviroment, since it is
- only known to the webserver (or wavemaster). This is done
- by extending the object record with the following incomplete
- string. It should contain any enviroment variable a cgi script
- requires.
- */
-#if (WIN32|WINNT)
- snprintf(cgi_env_str, BUFFERLEN, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s",
- getenv("REQUEST_METHOD"),
- getenv("PATH_INFO"),
- getenv("QUERY_STRING"));
-#else
- snprintf(cgi_env_str, BUFFERLEN, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s",
- SG(request_info).request_method,
- SG(request_info).request_uri,
- SG(request_info).query_string);
-#endif
- /* !!!! memory for object and attributes is allocated with malloc !!!! */
- if (0 != (ptr->lasterror = send_getcgi(ptr->socket, id, cgi_env_str, &attributes, &object, &count)))
- RETURN_FALSE;
- doc = malloc(sizeof(hw_document));
- doc->data = object;
- doc->attributes = attributes;
- doc->bodytag = NULL;
- doc->size = count;
- return_value->value.lval = php3_list_insert(doc,HwSG(le_document));
- return_value->type = IS_LONG;
- }
-}
-#undef BUFFERLEN
-/* }}} */
-
-/* {{{ proto int hw_getremote(int link, int objid)
- Returns the content of a remote document */
-PHP_FUNCTION(hw_getremote) {
- pval *arg1, *arg2;
- int link, id, type;
- hw_document *doc;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- {
- char *object = NULL;
- char *attributes = NULL;
- int count;
- /* !!!! memory for object and attributes is allocated with malloc !!!! */
- if (0 != (ptr->lasterror = send_getremote(ptr->socket, id, &attributes, &object, &count)))
- RETURN_FALSE;
- doc = malloc(sizeof(hw_document));
- doc->data = object;
- doc->attributes = attributes;
- doc->bodytag = NULL;
- doc->size = count;
- return_value->value.lval = php3_list_insert(doc,HwSG(le_document));
- return_value->type = IS_LONG;
- }
-}
-/* }}} */
-
-/* {{{ proto [array|int] hw_getremotechildren(int link, string objrec)
- Returns the remote document or an array of object records */
-PHP_FUNCTION(hw_getremotechildren) {
- pval *arg1, *arg2;
- int link, type, i;
- hw_connection *ptr;
- char *objrec;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_string(arg2);
- link=arg1->value.lval;
- objrec=arg2->value.str.val;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d", link);
- RETURN_FALSE;
- }
- set_swap(ptr->swap_on);
- {
- int count, *offsets;
- char *remainder, *ptr1;
- if (0 != (ptr->lasterror = send_getremotechildren(ptr->socket, objrec, &remainder, &offsets, &count)))
- RETURN_FALSE;
-
-/*
-for(i=0;i<count;i++)
- php_printf("offset[%d] = %d--\n", i, offsets[i]);
-php_printf("count = %d, remainder = <HR>%s---<HR>", count, remainder);
-*/
- /* The remainder depends on the number of returned objects and
- whether the MimeType of the object to retrieve is set. If
- the MimeType is set the result will start with the
- HTTP header 'Content-type: mimetype', otherwise it will be
- a list of object records and therefore starts with
- 'ObjectID=0'. In the first case the offset and count are somewhat
- strange. Quite often count had a value of 6 which appears to be
- meaningless, but if you sum up the offsets you get the length
- of the remainder which is the lenght of the document.
- The document must have been chopped up into 6 pieces, each ending
- with 'ServerId=0xYYYYYYYY'.
- In the second case the offset contains the lenght of
- each object record; count contains the number of object records.
- Even if a remote object has children
- (several sql statements) but the MimeType is set, it will
- return a document in the format of MimeType. On the other
- hand a remote object does not have any children but just
- returns a docuement will not be shown unless the MimeType
- is set. It returns the pure object record of the object without
- the SQLStatement attribute. Quite senseless.
- Though, this behavior depends on how the hgi gateway in Hyperwave
- is implemented.
- */
- if(strncmp(remainder, "ObjectID=0 ", 10)) {
- hw_document *doc;
- char *ptr;
- int i, j, len;
- /* For some reason there is always the string
- 'SeverId=0xYYYYYYYY' at the end, so we cut it off.
- The document may as well be divided into several pieces
- and each of them has the ServerId at the end.
- The following will put the pieces back together and
- strip the ServerId. count contains the number of pieces.
- */
- for(i=0, len=0; i<count; i++)
- len += offsets[i]-18;
-/*fprintf(stderr,"len = %d\n", len); */
- doc = malloc(sizeof(hw_document));
- doc->data = malloc(len+1);
- ptr = doc->data;
- for(i=0, j=0; i<count; i++) {
- memcpy((char *)ptr, (char *)&remainder[j], offsets[i]-18);
-/*fprintf(stderr,"rem = %s\n", &remainder[j]); */
- j += offsets[i];
- ptr += offsets[i] - 18;
- }
- *ptr = '\0';
- doc->attributes = strdup(objrec);
- doc->bodytag = NULL;
- doc->size = strlen(doc->data);
- return_value->value.lval = php3_list_insert(doc,HwSG(le_document));
- return_value->type = IS_LONG;
- } else {
- if (array_init(return_value) == FAILURE) {
- efree(offsets);
- RETURN_FALSE;
- }
-
- ptr1 = remainder;
- for(i=0; i<count; i++) {
- *(ptr1+offsets[i]-1) = '\0';
- add_index_string(return_value, i, ptr1, 1);
- ptr1 += offsets[i];
- }
- }
-
- efree(offsets);
- efree(remainder);
- }
-}
-/* }}} */
-
-/* {{{ proto void hw_setlinkroot(int link, int rootid)
- Set the id to which links are calculated */
-PHP_FUNCTION(hw_setlinkroot) {
- pval *arg1, *arg2;
- int link, type, rootid;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link = arg1->value.lval;
- rootid = arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",link);
- RETURN_FALSE;
- }
-
- ptr->linkroot = rootid;
- RETURN_LONG(rootid);
-}
-/* }}} */
-
-/* {{{ proto hwdoc hw_pipedocument(int link, int objid)
- Returns document */
-PHP_FUNCTION(hw_pipedocument) {
- pval *argv[3];
- int link, id, type, argc, mode;
- int rootid = 0;
- hw_connection *ptr;
- hw_document *doc;
-#if APACHE
- server_rec *serv = ((request_rec *) SG(server_context))->server;
-#endif
-
- argc = ARG_COUNT(ht);
- if((argc > 2) || (argc < 2))
- WRONG_PARAM_COUNT;
-
- if (getParametersArray(ht, argc, argv) == FAILURE)
- RETURN_FALSE;
-
- convert_to_long(argv[0]);
- convert_to_long(argv[1]);
-/* if(argc == 3) {
- convert_to_long(argv[2]);
- rootid = argv[2]->value.lval;
- if(rootid != 0)
- mode = 1;
- }
-*/ link=argv[0]->value.lval;
- id=argv[1]->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d", link);
- RETURN_FALSE;
- }
-
- mode = 0;
- if(ptr->linkroot > 0)
- mode = 1;
- rootid = ptr->linkroot;
-
- set_swap(ptr->swap_on);
- {
- char *object = NULL;
- char *attributes = NULL;
- char *bodytag = NULL;
- int count;
- /* !!!! memory for object, bodytag and attributes is allocated with malloc !!!! */
- if (0 != (ptr->lasterror = send_pipedocument(ptr->socket,
-#if APACHE
- serv->server_hostname,
-#else
- getenv("HOSTNAME"),
-#endif
- id, mode, rootid, &attributes, &bodytag, &object, &count, NULL)))
- RETURN_FALSE;
-
- doc = malloc(sizeof(hw_document));
- doc->data = object;
- doc->attributes = attributes;
- doc->bodytag = bodytag;
- doc->size = count;
-/* fprintf(stderr, "size = %d\n", count); */
- return_value->value.lval = php3_list_insert(doc,HwSG(le_document));
- return_value->type = IS_LONG;
- }
-}
-/* }}} */
-
-/* {{{ proto hwdoc hw_pipecgi(int link, int objid)
- Returns output of cgi script */
-#define BUFFERLEN 1000
-/* FIX ME: The buffer cgi_env_str should be allocated dynamically */
-PHP_FUNCTION(hw_pipecgi) {
- pval *arg1, *arg2;
- int link, id, type;
- hw_connection *ptr;
- hw_document *doc;
- char cgi_env_str[1000];
-#if APACHE
- server_rec *serv = ((request_rec *) SG(server_context))->server;
-#endif
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- {
- char *object = NULL;
- char *attributes = NULL;
- int count;
-
-#if (WIN32|WINNT)
- snprintf(cgi_env_str, BUFFERLEN, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s",
- getenv("REQUEST_METHOD"),
- getenv("PATH_INFO"),
- getenv("QUERY_STRING"));
-#else
- snprintf(cgi_env_str, BUFFERLEN, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s",
- SG(request_info).request_method,
- SG(request_info).request_uri,
- SG(request_info).query_string);
-#endif
- /* !!!! memory for object, bodytag and attributes is allocated with malloc !!!! */
- if (0 != (ptr->lasterror = send_pipecgi(ptr->socket,
-#if APACHE
- serv->server_hostname,
-#else
- getenv("HOSTNAME"),
-#endif
- id, cgi_env_str, &attributes, &object, &count)))
- RETURN_FALSE;
-
- doc = malloc(sizeof(hw_document));
- doc->data = object;
- doc->attributes = attributes;
- doc->bodytag = NULL;
- doc->size = count;
- return_value->value.lval = php3_list_insert(doc,HwSG(le_document));
- return_value->type = IS_LONG;
- }
-}
-#undef BUFFERLEN
-/* }}} */
-
-/* {{{ proto void hw_insertdocument(int link, int parentid, hwdoc doc)
- Insert new document */
-PHP_FUNCTION(hw_insertdocument) {
- pval *arg1, *arg2, *arg3;
- int link, id, doc, type;
- hw_connection *ptr;
- hw_document *docptr;
- hw_objectID objid;
-#if APACHE
- server_rec *serv = ((request_rec *) SG(server_context))->server;
-#endif
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- convert_to_long(arg3);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find connection identifier %d",link);
- RETURN_FALSE;
- }
-
- doc=arg3->value.lval;
- docptr = php3_list_find(doc,&type);
- if(!docptr || (type!=HwSG(le_document))) {
- php_error(E_WARNING,"Unable to find document identifier %d",doc);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- {
- if (0 != (ptr->lasterror = send_putdocument(ptr->socket,
-#if APACHE
- serv->server_hostname,
-#else
- getenv("HOSTNAME"),
-#endif
- id, docptr->attributes, docptr->data, docptr->size, &objid))) {
- RETURN_FALSE;
- }
- }
- RETURN_LONG(objid);
-}
-/* }}} */
-
-/* {{{ proto hwdoc hw_new_document(string objrec, string data, int size)
- Create a new document */
-PHP_FUNCTION(hw_new_document) {
- pval *arg1, *arg2, *arg3;
- char *ptr;
- hw_document *doc;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(arg1);
- convert_to_string(arg2);
- convert_to_long(arg3);
-
- doc = malloc(sizeof(hw_document));
- if(NULL == doc)
- RETURN_FALSE;
- doc->data = malloc(arg3->value.lval+1);
- if(NULL == doc->data) {
- free(doc);
- RETURN_FALSE;
- }
- memcpy(doc->data, arg2->value.str.val, arg3->value.lval);
- ptr = doc->data;
- ptr[arg3->value.lval] = '\0';
- doc->attributes = strdup(arg1->value.str.val);
- doc->bodytag = NULL;
- doc->size = arg3->value.lval;
- return_value->value.lval = php3_list_insert(doc,HwSG(le_document));
- return_value->type = IS_LONG;
-}
-/* }}} */
-
-/* {{{ proto void hw_free_document(hwdoc doc)
- Frees memory of document */
-PHP_FUNCTION(hw_free_document) {
- pval *arg1;
- int id, type;
- hw_document *ptr;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- id=arg1->value.lval;
- ptr = php3_list_find(id,&type);
- if(!ptr || (type!=HwSG(le_document))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
- php3_list_delete(id);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void hw_outputdocument(hwdoc doc)
- An alias for hw_output_document */
-/* }}} */
-
-/* {{{ proto void hw_output_document(hwdoc doc)
- Prints document */
-PHP_FUNCTION(hw_output_document) {
- pval *arg1;
- int id, type;
- hw_document *ptr;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- id=arg1->value.lval;
- ptr = php3_list_find(id,&type);
- if(!ptr || (type!=HwSG(le_document))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- php3_header();
- php3_write(ptr->data, ptr->size);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto string hw_documentbodytag(hwdoc doc [, string prefix])
- An alias for hw_document_bodytag */
-/* }}} */
-
-/* {{{ proto string hw_document_bodytag(hwdoc doc [, string prefix])
- Return bodytag prefixed by prefix */
-PHP_FUNCTION(hw_document_bodytag) {
- pval *argv[2];
- int id, type, argc;
- hw_document *ptr;
- char *temp, *str = NULL;
-
- argc = ARG_COUNT(ht);
- if((argc > 2) || (argc < 1))
- WRONG_PARAM_COUNT;
-
- if (getParametersArray(ht, argc, argv) == FAILURE)
- RETURN_FALSE;
-
- convert_to_long(argv[0]);
- id=argv[0]->value.lval;
- ptr = php3_list_find(id,&type);
- if(!ptr || (type!=HwSG(le_document))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- if(argc == 2) {
- convert_to_string(argv[1]);
- str=argv[1]->value.str.val;
- }
-
- if(str != NULL) {
- temp = emalloc(argv[1]->value.str.len + strlen(ptr->bodytag) + 2);
- strcpy(temp, ptr->bodytag);
- strcpy(temp+strlen(ptr->bodytag)-1, str);
- strcpy(temp+strlen(ptr->bodytag)-1+argv[1]->value.str.len, ">\n");
- RETURN_STRING(temp, 0);
- } else {
- RETURN_STRING(ptr->bodytag, 1);
- }
-}
-/* }}} */
-
-/* {{{ proto string hw_document_content(hwdoc doc)
- Returns content of document */
-PHP_FUNCTION(hw_document_content) {
- pval *argv[1];
- int id, type, argc;
- hw_document *ptr;
-
- argc = ARG_COUNT(ht);
- if(argc != 1)
- WRONG_PARAM_COUNT;
-
- if (getParametersArray(ht, argc, argv) == FAILURE)
- RETURN_FALSE;
-
- convert_to_long(argv[0]);
- id=argv[0]->value.lval;
- ptr = php3_list_find(id,&type);
- if(!ptr || (type!=HwSG(le_document))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- RETURN_STRING(ptr->data, 1);
-}
-/* }}} */
-
-/* {{{ proto int hw_document_setcontent(hwdoc doc, string content)
- Sets/replaces content of document */
-PHP_FUNCTION(hw_document_setcontent) {
- pval *argv[2];
- int id, type, argc;
- hw_document *ptr;
- char *str;
-
- argc = ARG_COUNT(ht);
- if(argc != 2)
- WRONG_PARAM_COUNT;
-
- if (getParametersArray(ht, argc, argv) == FAILURE)
- RETURN_FALSE;
-
- convert_to_long(argv[0]);
- convert_to_string(argv[1]);
- id=argv[0]->value.lval;
- ptr = php3_list_find(id,&type);
- if(!ptr || (type!=HwSG(le_document))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- str = ptr->data;
- if(NULL != (ptr->data = strdup(argv[1]->value.str.val))) {
- ptr->size = strlen(ptr->data);
- free(str);
- RETURN_TRUE;
- } else {
- ptr->data = str;
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int hw_documentsize(hwdoc doc)
- An alias for hw_document_size */
-/* }}} */
-
-/* {{{ proto int hw_document_size(hwdoc doc)
- Returns size of document */
-PHP_FUNCTION(hw_document_size) {
- pval *arg1;
- int id, type;
- hw_document *ptr;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- id=arg1->value.lval;
- ptr = php3_list_find(id,&type);
- if(!ptr || (type!=HwSG(le_document))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- RETURN_LONG(ptr->size);
-}
-/* }}} */
-
-/* {{{ proto string hw_documentattributes(hwdoc doc)
- An alias for hw_document_attributes */
-/* }}} */
-
-/* {{{ proto string hw_document_attributes(hwdoc doc)
- Returns object record of document */
-PHP_FUNCTION(hw_document_attributes) {
- pval *arg1;
- int id, type;
- hw_document *ptr;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- id=arg1->value.lval;
- ptr = php3_list_find(id,&type);
- if(!ptr || (type!=HwSG(le_document))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- RETURN_STRING(ptr->attributes, 1);
-/* make_return_array_from_objrec(&return_value, ptr->attributes); */
-}
-/* }}} */
-
-/* {{{ proto array hw_getparentsobj(int link, int objid)
- Returns array of parent object records */
-PHP_FUNCTION(hw_getparentsobj) {
- pval *arg1, *arg2;
- int link, id, type;
- int count;
- char **childObjRecs = NULL;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
-
- if (0 != (ptr->lasterror = send_getparentsobj(ptr->socket, id, &childObjRecs, &count))) {
- php_error(E_WARNING, "send_command (getparentsobj) returned %d\n", ptr->lasterror);
- RETURN_FALSE;
- }
-
- /* create return value and free all memory */
- if( 0 > make_return_objrec(&return_value, childObjRecs, count))
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto array hw_getparents(int link, int objid)
- Returns array of parent object ids */
-PHP_FUNCTION(hw_getparents) {
- pval *arg1, *arg2;
- int link, id, type;
- int count;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- {
- int *childIDs = NULL;
- int i;
-
- if (0 != (ptr->lasterror = send_getparents(ptr->socket, id, &childIDs, &count))) {
- php_error(E_WARNING, "send_command (getparents) returned %d\n", ptr->lasterror);
- RETURN_FALSE;
- }
-
- if (array_init(return_value) == FAILURE) {
- efree(childIDs);
- RETURN_FALSE;
- }
-
- for(i=0; i<count; i++) {
- add_index_long(return_value, i, childIDs[i]);
- }
- efree(childIDs);
- }
-
-}
-/* }}} */
-
-/* {{{ proto array hw_children(int link, int objid)
- Returns array of children object ids */
-PHP_FUNCTION(hw_children) {
- pval *arg1, *arg2;
- int link, id, type;
- int count;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- {
- int *childIDs = NULL;
- int i;
-
- if (0 != (ptr->lasterror = send_children(ptr->socket, id, &childIDs, &count))){
- php_error(E_WARNING, "send_command (getchildcoll) returned %d\n", ptr->lasterror);
- RETURN_FALSE;
- }
-
- if (array_init(return_value) == FAILURE) {
- efree(childIDs);
- RETURN_FALSE;
- }
-
- for(i=0; i<count; i++) {
- add_index_long(return_value, i, childIDs[i]);
- }
- efree(childIDs);
- }
-
-}
-/* }}} */
-
-/* {{{ proto array hw_childrenobj(int link, int objid)
- Returns array of children object records */
-PHP_FUNCTION(hw_childrenobj) {
- pval *arg1, *arg2;
- int link, id, type;
- int count;
- char **childObjRecs = NULL;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
-
- if (0 != (ptr->lasterror = send_childrenobj(ptr->socket, id, &childObjRecs, &count))) {
- php_error(E_WARNING, "send_command (getchildcollobj) returned %d\n", ptr->lasterror);
- RETURN_FALSE;
- }
-
- /* create return value and free all memory */
- if( 0 > make_return_objrec(&return_value, childObjRecs, count))
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto array hw_getchildcoll(int link, int objid)
- Returns array of child collection object ids */
-PHP_FUNCTION(hw_getchildcoll) {
- pval *arg1, *arg2;
- int link, id, type;
- int count;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- {
- int *childIDs = NULL;
- int i;
-
- if (0 != (ptr->lasterror = send_getchildcoll(ptr->socket, id, &childIDs, &count))){
- php_error(E_WARNING, "send_command (getchildcoll) returned %d\n", ptr->lasterror);
- RETURN_FALSE;
- }
-
- if (array_init(return_value) == FAILURE) {
- efree(childIDs);
- RETURN_FALSE;
- }
-
- for(i=0; i<count; i++) {
- add_index_long(return_value, i, childIDs[i]);
- }
- efree(childIDs);
- }
-
-}
-/* }}} */
-
-/* {{{ proto array hw_getchildcollobj(int link, int objid)
- Returns array of child collection object records */
-PHP_FUNCTION(hw_getchildcollobj) {
- pval *arg1, *arg2;
- int link, id, type;
- int count;
- char **childObjRecs = NULL;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
-
- if (0 != (ptr->lasterror = send_getchildcollobj(ptr->socket, id, &childObjRecs, &count))) {
- php_error(E_WARNING, "send_command (getchildcollobj) returned %d\n", ptr->lasterror);
- RETURN_FALSE;
- }
-
- /* create return value and free all memory */
- if( 0 > make_return_objrec(&return_value, childObjRecs, count))
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto int hw_docbyanchor(int link, int anchorid)
- Returns objid of document belonging to anchorid */
-PHP_FUNCTION(hw_docbyanchor) {
- pval *arg1, *arg2;
- int link, id, type;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- {
- int objectID;
- if (0 != (ptr->lasterror = send_docbyanchor(ptr->socket, id, &objectID)))
- RETURN_FALSE;
-
- RETURN_LONG(objectID);
- }
-}
-/* }}} */
-
-/* {{{ proto array hw_docbyanchorobj(int link, int anchorid)
- Returns object record of document belonging to anchorid */
-PHP_FUNCTION(hw_docbyanchorobj) {
- pval *arg1, *arg2;
- int link, id, type;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- {
- char *object = NULL;
- if (0 != (ptr->lasterror = send_docbyanchorobj(ptr->socket, id, &object)))
- RETURN_FALSE;
-
- RETURN_STRING(object, 0);
- /*
- make_return_array_from_objrec(&return_value, object);
- efree(object);
- */
- }
-}
-/* }}} */
-
-/* {{{ proto array hw_getobjectbyquery(int link, string query, int maxhits)
- Search for query and return maxhits objids */
-PHP_FUNCTION(hw_getobjectbyquery) {
- pval *arg1, *arg2, *arg3;
- int link, type, maxhits;
- char *query;
- int count, i;
- int *childIDs = NULL;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_string(arg2);
- convert_to_long(arg3);
- link=arg1->value.lval;
- query=arg2->value.str.val;
- maxhits=arg3->value.lval;
- if (maxhits < 0) maxhits=0x7FFFFFFF;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",link);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- if (0 != (ptr->lasterror = send_getobjbyquery(ptr->socket, query, maxhits, &childIDs, &count))) {
- php_error(E_WARNING, "send_command (getobjectbyquery) returned %d\n", ptr->lasterror);
- RETURN_FALSE;
- }
-
- if (array_init(return_value) == FAILURE) {
- efree(childIDs);
- RETURN_FALSE;
- }
-
- for(i=0; i<count; i++)
- add_index_long(return_value, i, childIDs[i]);
- efree(childIDs);
-}
-/* }}} */
-
-/* {{{ proto array hw_getobjectbyqueryobj(int link, string query, int maxhits)
- Search for query and return maxhits object records */
-PHP_FUNCTION(hw_getobjectbyqueryobj) {
- pval *arg1, *arg2, *arg3;
- int link, type, maxhits;
- char *query;
- int count;
- char **childObjRecs = NULL;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_string(arg2);
- convert_to_long(arg3);
- link=arg1->value.lval;
- query=arg2->value.str.val;
- maxhits=arg3->value.lval;
- if (maxhits < 0) maxhits=0x7FFFFFFF;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",link);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- if (0 != (ptr->lasterror = send_getobjbyqueryobj(ptr->socket, query, maxhits, &childObjRecs, &count))) {
- php_error(E_WARNING, "send_command (getobjectbyqueryobj) returned %d\n", ptr->lasterror);
- RETURN_FALSE;
- }
-
- /* create return value and free all memory */
- if( 0 > make_return_objrec(&return_value, childObjRecs, count))
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto array hw_getobjectbyquerycoll(int link, int collid, string query, int maxhits)
- Search for query in collection and return maxhits objids */
-PHP_FUNCTION(hw_getobjectbyquerycoll) {
- pval *arg1, *arg2, *arg3, *arg4;
- int link, id, type, maxhits;
- char *query;
- int count, i;
- hw_connection *ptr;
- int *childIDs = NULL;
-
- if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- convert_to_string(arg3);
- convert_to_long(arg4);
- link=arg1->value.lval;
- id=arg2->value.lval;
- query=arg3->value.str.val;
- maxhits=arg4->value.lval;
- if (maxhits < 0) maxhits=0x7FFFFFFF;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- if (0 != (ptr->lasterror = send_getobjbyquerycoll(ptr->socket, id, query, maxhits, &childIDs, &count))) {
- php_error(E_WARNING, "send_command (getobjectbyquerycoll) returned %d\n", ptr->lasterror);
- RETURN_FALSE;
- }
-
- if (array_init(return_value) == FAILURE) {
- efree(childIDs);
- RETURN_FALSE;
- }
-
- for(i=0; i<count; i++)
- add_index_long(return_value, i, childIDs[i]);
- efree(childIDs);
-}
-/* }}} */
-
-/* {{{ proto array hw_getobjectbyquerycollobj(int link, int collid, string query, int maxhits)
- Search for query in collection and return maxhits object records */
-PHP_FUNCTION(hw_getobjectbyquerycollobj) {
- pval *arg1, *arg2, *arg3, *arg4;
- int link, id, type, maxhits;
- char *query;
- int count;
- hw_connection *ptr;
- char **childObjRecs = NULL;
-
- if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- convert_to_string(arg3);
- convert_to_long(arg4);
- link=arg1->value.lval;
- id=arg2->value.lval;
- query=arg3->value.str.val;
- maxhits=arg4->value.lval;
- if (maxhits < 0) maxhits=0x7FFFFFFF;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- if (0 != (ptr->lasterror = send_getobjbyquerycollobj(ptr->socket, id, query, maxhits, &childObjRecs, &count))) {
- php_error(E_WARNING, "send_command (getobjectbyquerycollobj) returned %d\n", ptr->lasterror);
- RETURN_FALSE;
- }
-
- /* create return value and free all memory */
- if( 0 > make_return_objrec(&return_value, childObjRecs, count))
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto array hw_getchilddoccoll(int link, int objid)
- Returns all children ids which are documents */
-PHP_FUNCTION(hw_getchilddoccoll) {
- pval *arg1, *arg2;
- int link, id, type;
- int count, i;
- int *childIDs = NULL;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- if (0 != (ptr->lasterror = send_getchilddoccoll(ptr->socket, id, &childIDs, &count))) {
- php_error(E_WARNING, "send_command (getchilddoccoll) returned %d\n", ptr->lasterror);
- RETURN_FALSE;
- }
-
- if (array_init(return_value) == FAILURE) {
- efree(childIDs);
- RETURN_FALSE;
- }
-
- for(i=0; i<count; i++)
- add_index_long(return_value, i, childIDs[i]);
- efree(childIDs);
-}
-/* }}} */
-
-/* {{{ proto array hw_getchilddoccollobj(int link, int objid)
- Returns all children object records which are documents */
-PHP_FUNCTION(hw_getchilddoccollobj) {
- pval *arg1, *arg2;
- int link, id, type;
- int count;
- char **childObjRecs = NULL;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- if (0 != (ptr->lasterror = send_getchilddoccollobj(ptr->socket, id, &childObjRecs, &count))) {
- php_error(E_WARNING, "send_command (getchilddoccollobj) returned %d\n", ptr->lasterror);
- RETURN_FALSE;
- }
-
- /* create return value and free all memory */
- if( 0 > make_return_objrec(&return_value, childObjRecs, count))
- RETURN_FALSE;
-
-}
-/* }}} */
-
-/* {{{ proto array hw_getanchors(int link, int objid)
- Return all anchors of object */
-PHP_FUNCTION(hw_getanchors) {
- pval *arg1, *arg2;
- int link, id, type;
- int count, i;
- int *anchorIDs = NULL;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- if (0 != (ptr->lasterror = send_getanchors(ptr->socket, id, &anchorIDs, &count))) {
- php_error(E_WARNING, "send_command (getanchors) returned %d\n", ptr->lasterror);
- RETURN_FALSE;
- }
-
- if (array_init(return_value) == FAILURE) {
- efree(anchorIDs);
- RETURN_FALSE;
- }
-
- for(i=0; i<count; i++)
- add_index_long(return_value, i, anchorIDs[i]);
- efree(anchorIDs);
-}
-/* }}} */
-
-/* {{{ proto array hw_getanchorsobj(int link, int objid)
- Return all object records of anchors of object */
-PHP_FUNCTION(hw_getanchorsobj) {
- pval *arg1, *arg2;
- int link, id, type;
- int count;
- char **anchorObjRecs = NULL;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = (hw_connection *) php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- if (0 != (ptr->lasterror = send_getanchorsobj(ptr->socket, id, &anchorObjRecs, &count))) {
- php_error(E_WARNING, "send_command (getanchors) returned %d\n", ptr->lasterror);
- RETURN_FALSE;
- }
-
- /* create return value and free all memory */
- if( 0 > make_return_objrec(&return_value, anchorObjRecs, count))
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto string hw_getusername(int link)
- Returns the current user name */
-PHP_FUNCTION(hw_getusername) {
- pval *arg1;
- int link, type;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- link = arg1->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",link);
- RETURN_FALSE;
- }
-
- return_value->value.str.val = estrdup(ptr->username);
- return_value->value.str.len = strlen(ptr->username);
- return_value->type = IS_STRING;
-}
-/* }}} */
-
-/* {{{ proto void hw_identify(int link, string username, string password)
- Identifies at Hyperwave server */
-PHP_FUNCTION(hw_identify) {
- pval *arg1, *arg2, *arg3;
- int link, type;
- char *name, *passwd, *userdata;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_string(arg2);
- convert_to_string(arg3);
- link = arg1->value.lval;
- name=arg2->value.str.val;
- passwd=arg3->value.str.val;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",link);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- {
- char *str;
-
- if (0 != (ptr->lasterror = send_identify(ptr->socket, name, passwd, &userdata))) {
- php_error(E_WARNING, "send_identify returned %d\n", ptr->lasterror);
- if(ptr->username) free(ptr->username);
- ptr->username = NULL;
- RETURN_FALSE;
- }
-
- return_value->value.str.val = userdata;
- return_value->value.str.len = strlen(userdata);
- return_value->type = IS_STRING;
- if(ptr->username) free(ptr->username);
- str = userdata;
- while((*str != 0) && (*str != ' '))
- str++;
- if(*str != '\0')
- ptr->username = strdup(++str);
- else
- ptr->username = NULL;
- }
-}
-/* }}} */
-
-/* {{{ proto array hw_objrec2array(string objrec)
- Returns object array of object record*/
-PHP_FUNCTION(hw_objrec2array) {
- zval *arg1, *arg2;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if(getParameters(ht, 1, &arg1) == FAILURE)
- WRONG_PARAM_COUNT;
- arg2 = NULL;
- break;
- case 2:
- if(getParameters(ht, 2, &arg1, &arg2) == FAILURE)
- WRONG_PARAM_COUNT;
- convert_to_array(arg2);
- break;
- default:
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg1);
- make2_return_array_from_objrec(&return_value, arg1->value.str.val, arg2);
-}
-/* }}} */
-
-/* {{{ proto string hw_array2objrec(array objarr)
- Returns object record of object array */
-PHP_FUNCTION(hw_array2objrec) {
- pval *arg1;
- char *objrec, *retobj;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_array(arg1);
- objrec = make_objrec_from_array(arg1->value.ht);
- if(objrec) {
- retobj = estrdup(objrec);
- free(objrec);
- RETURN_STRING(retobj, 0);
- } else
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto array hw_incollections(int link, array objids, array collids, int para)
- Returns object ids which are in collections */
-PHP_FUNCTION(hw_incollections) {
- pval *arg1, *arg2, *arg3, *arg4;
- int type, link, i;
- hw_connection *ptr;
- int cobjids, ccollids, *objectIDs, *collIDs, cretids, *retIDs, retcoll;
-
- if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_array(arg2);
- convert_to_array(arg3);
- convert_to_long(arg4);
- link = arg1->value.lval;
- retcoll=arg4->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",link);
- RETURN_FALSE;
- }
-
- cobjids = zend_hash_num_elements(arg2->value.ht);
- if(NULL == (objectIDs = make_ints_from_array(arg2->value.ht))) {
- php_error(E_WARNING, "Could not create Int Array from Array\n");
- RETURN_FALSE;
- }
-
- ccollids = zend_hash_num_elements(arg3->value.ht);
- if(NULL == (collIDs = make_ints_from_array(arg3->value.ht))) {
- php_error(E_WARNING, "Could not create Int Array from Array\n");
- efree(objectIDs);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- if (0 != (ptr->lasterror = send_incollections(ptr->socket, retcoll,
- cobjids, objectIDs,
- ccollids, collIDs,
- &cretids, &retIDs))) {
- if(objectIDs) efree(objectIDs);
- if(collIDs) efree(collIDs);
- RETURN_FALSE;
- }
-
- if(objectIDs) efree(objectIDs);
- if(collIDs) efree(collIDs);
-
- if (array_init(return_value) == FAILURE) {
- efree(retIDs);
- RETURN_FALSE;
- }
-
- for(i=0; i<cretids; i++)
- add_index_long(return_value, i, retIDs[i]);
- efree(retIDs);
-
-}
-/* }}} */
-
-/* {{{ proto void hw_inscoll(int link, int parentid, array objarr)
- Inserts collection */
-PHP_FUNCTION(hw_inscoll) {
- pval *arg1, *arg2, *arg3;
- char *objrec;
- int id, newid, type, link;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- convert_to_array(arg3);
- link = arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",link);
- RETURN_FALSE;
- }
-
- if(NULL == (objrec = make_objrec_from_array(arg3->value.ht))) {
- php_error(E_WARNING, "Could not create Object Record from Array\n");
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- if (0 != (ptr->lasterror = send_inscoll(ptr->socket, id, objrec, &newid))) {
- if(objrec) free(objrec);
- RETURN_FALSE;
- }
-
- if(objrec) free(objrec);
- RETURN_LONG(newid);
-}
-/* }}} */
-
-/* {{{ proto void hw_insdoc(int link, int parentid, string objrec [, string text])
- Inserts document */
-PHP_FUNCTION(hw_insdoc) {
- pval *argv[4];
- char *objrec, *text;
- int id, newid, type, link, argc;
- hw_connection *ptr;
-
- argc = ARG_COUNT(ht);
- if((argc < 3) || (argc > 4))
- WRONG_PARAM_COUNT;
-
- if (getParametersArray(ht, argc, argv) == FAILURE)
- WRONG_PARAM_COUNT;
-
- convert_to_long(argv[0]);
- convert_to_long(argv[1]);
- convert_to_string(argv[2]);
- if(argc == 4) {
- convert_to_string(argv[3]);
- text = argv[3]->value.str.val;
- } else {
- text = NULL;
- }
- link = argv[0]->value.lval;
- id = argv[1]->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",link);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- objrec = argv[2]->value.str.val;
- if (0 != (ptr->lasterror = send_insdoc(ptr->socket, id, objrec, text, &newid))) {
- RETURN_FALSE;
- }
-
- RETURN_LONG(newid);
-}
-/* }}} */
-
-/* {{{ proto int hw_getsrcbydestobj(int link, int destid)
- Returns object id of source docuent by destination anchor */
-PHP_FUNCTION(hw_getsrcbydestobj) {
- pval *arg1, *arg2;
- int link, type, id;
- int count;
- char **childObjRecs = NULL;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- link=arg1->value.lval;
- id=arg2->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",link);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- if (0 != (ptr->lasterror = send_getsrcbydest(ptr->socket, id, &childObjRecs, &count))) {
- php_error(E_WARNING, "send_command (getsrcbydest) returned %d\n", ptr->lasterror);
- RETURN_FALSE;
- }
-
- /* create return value and free all memory */
- if( 0 > make_return_objrec(&return_value, childObjRecs, count))
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto string hw_getrellink(int link, int rootid, int sourceid, int destid)
- Get link form source to dest relative to rootid */
-PHP_FUNCTION(hw_getrellink) {
- pval *arg1, *arg2, *arg3, *arg4;
- int link, type;
- int rootid, destid, sourceid;
- char *anchorstr;
- hw_connection *ptr;
-
- if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- convert_to_long(arg3);
- convert_to_long(arg4);
- link=arg1->value.lval;
- rootid=arg2->value.lval;
- sourceid=arg3->value.lval;
- destid=arg4->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",link);
- RETURN_FALSE;
- }
-
- set_swap(ptr->swap_on);
- if (0 != (ptr->lasterror = getrellink(ptr->socket, rootid, sourceid, destid, &anchorstr))) {
- php_error(E_WARNING, "command (getrellink) returned %d\n", ptr->lasterror);
- RETURN_FALSE;
- }
-
- RETURN_STRING(anchorstr, 0);
-}
-/* }}} */
-
-
-PHP_MINFO_FUNCTION(hw)
-{
- php_printf("HG-CSP Version: 7.17<BR>\n");
- DISPLAY_INI_ENTRIES();
-}
-
-/* {{{ proto void hw_connection_info(int link)
- Prints information about the connection to Hyperwave server */
-PHP_FUNCTION(hw_connection_info)
-{
- pval *arg1;
- hw_connection *ptr;
- int link, type;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- link=arg1->value.lval;
- ptr = php3_list_find(link,&type);
- if(!ptr || (type!=HwSG(le_socketp) && type!=HwSG(le_psocketp))) {
- php_error(E_WARNING,"Unable to find file identifier %d",link);
- RETURN_FALSE;
- }
-
- php_printf("Hyperwave Info:\nhost=%s,\nserver string=%s\nversion=%d\nswap=%d\n", ptr->hostname, ptr->server_string, ptr->version, ptr->swap_on);
-}
-/* }}} */
-
-void print_msg(hg_msg *msg, char *str, int txt)
-{
- char *ptr;
- int i;
-
- fprintf(stdout, "\nprint_msg: >>%s<<\n", str);
- fprintf(stdout, "print_msg: length = %d\n", msg->length);
- fprintf(stdout, "print_msg: msgid = %d\n", msg->version_msgid);
- fprintf(stdout, "print_msg: msg_type = %d\n", msg->msg_type);
- if ( msg->length > HEADER_LENGTH ) {
- ptr = msg->buf;
- for ( i = 0; i < msg->length-HEADER_LENGTH; i++ ) {
- if ( *ptr == '\n' )
- fprintf(stdout, "%c", *ptr++);
- else if ( iscntrl(*ptr) )
- {fprintf(stdout, "."); ptr++;}
- else
- fprintf(stdout, "%c", *ptr++);
- }
- }
- fprintf(stdout, "\n\n");
-}
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/hyperwave/hw_error.h b/ext/hyperwave/hw_error.h
deleted file mode 100644
index 6c782a12f5..0000000000
--- a/ext/hyperwave/hw_error.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of the GNU General Public License as published by |
- | the Free Software Foundation; either version 2 of the License, or |
- | (at your option) any later version. |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with this program; if not, write to the Free Software |
- | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-#ifndef _HW_ERROR_H
-#define _HW_ERROR_H
-
-#if HYPERWAVE
-
-#define NOACCESS 1 /* Access denied */
-#define NODOCS 2 /* No documents */
-#define NONAME 3 /* No collection name */
-#define NODOC 4 /* Object is not a document */
-#define NOOBJ 5 /* No object received */
-#define NOCOLLS 6 /* No collections received */
-#define DBSTUBNG 7 /* Connection to low-level database failed */
-#define NOTFOUND 8 /* Object not found */
-#define EXIST 9 /* Collection already exists */
-#define FATHERDEL 10 /* parent collection disappeared */
-#define FATHNOCOLL 11 /* parent collection not a collection */
-#define NOTEMPTY 12 /* Collection not empty */
-#define DESTNOCOLL 13 /* Destination not a collection */
-#define SRCEQDEST 14 /* Source equals destination */
-#define REQPEND 15 /* Request pending */
-#define TIMEOUT 16 /* Timeout */
-#define NAMENOTUNIQUE 17 /* Name not unique */
-#define WRITESTOPPED 18 /* Database now read-only; try again later */
-#define LOCKED 19 /* Object locked; try again later */
-#define CHANGEBASEFLD 20 /* Change of base-attribute */
-#define NOTREMOVED 21 /* Attribute not removed */
-#define FLDEXISTS 22 /* Attribute exists */
-#define CMDSYNTAX 23 /* Syntax error in command */
-#define NOLANGUAGE 24 /* No or unknown language specified */
-#define WRGTYPE 25 /* Wrong type in object */
-#define WRGVERSION 26 /* Client version too old */
-#define CONNECTION 27 /* No connection to other server */
-#define SYNC 28 /* Synchronization error */
-#define NOPATH 29 /* No path entry */
-#define WRGPATH 30 /* Wrong path entry */
-#define PASSWD 31 /* Wrong password (server-to-server server authentication) */
-#define LC_NO_MORE_USERS 32 /* No more users for license */
-#define LC_NO_MORE_DOCS 33 /* No more documents for this session and license */
-#define RSERV_NRESP 34 /* Remote server not responding */
-#define Q_OVERFLOW 35 /* Query overflow */
-#define USR_BREAK 36 /* Break by user */
-#define N_IMPL 37 /* Not implemented */
-#define WRG_VALUE 38 /* Wrong value */
-#define INSUFF_FUNDS 39 /* Insufficient funds */
-#define REORG 40 /* Reorganization in progress */
-#define USER_LIMIT 41 /* Limit of simultaneous users reached */
-#define FTCONNECT 513 /* No connection to fulltext server */
-#define FTTIMEOUT 514 /* Connection timed out */
-#define FTINDEX 515 /* Something wrong with fulltext index */
-#define FTSYNTAX 516 /* Query syntax error */
-#define REQUESTPENDING 1025 /* Request pending */
-#define NOCONNECTION 1026 /* No connection to document server */
-#define WRONGVERSION 1027 /* Wrong protocol version */
-#define NOTINITIALIZED 1028 /* Not initialized */
-#define BADREQUEST 1029 /* Bad request */
-#define BADLRN 1030 /* Bad document number */
-#define OPENSTORE_WRITE 1031 /* Cannot write to local store */
-#define OPENSTORE_READ 1032 /* Cannot read from local store */
-#define READSTORE 1033 /* Store read error */
-#define WRITESTORE 1034 /* Write error */
-#define CLOSESTORE 1035 /* Close error */
-#define BADPATH 1036 /* Bad path */
-#define NOPATHDC 1037 /* No path */
-#define OPENFILE 1038 /* Cannot open file */
-#define READFILE 1039 /* Cannot read from file // same */
-#define WRITEFILE 1040 /* Cannot write to file */
-#define CONNECTCLIENT 1041 /* Could not connect to client */
-#define ACCEPT 1042 /* Could not accept connection */
-#define READSOCKET 1043 /* Could not read from socket */
-#define WRITESOCKET 1044 /* Could not write to socket */
-#define TOOMUCHDATA 1046 /* Received too much data */
-#define TOOFEWDATA 1047 /* Received too few data // ... */
-#define NOTIMPLEMENTED 1049 /* Not implemented */
-#define USERBREAK 1050 /* User break */
-#define INTERNAL 1051 /* Internal error */
-#define INVALIDOBJECT 1052 /* Invalid object */
-#define JOBTIMEOUT 1053 /* Job timed out */
-#define OPENPORT 1054 /* Cannot open port // ... for several resons */
-#define NODATA 1055 /* Received no data */
-#define NOPORT 1056 /* No port to handle this request */
-#define NOTCACHED 1057 /* Document not cached */
-#define BADCACHETYPE 1058 /* Bad cache type */
-#define OPENCACHE_WRITE 1059 /* Cannot write to cache */
-#define OPENCACHE_READ 1060 /* Cannot read from cache // same */
-#define NOSOURCE 1061 /* Do not know what to read */
-#define CLOSECACHE 1062 /* Could not insert into cache */
-#define CONNECTREMOTE 1063 /* Could not connect to remote server */
-#define LOCKREFUSED 1064 /* Lock refused // could not lock the stores */
-
-#endif
-#endif
diff --git a/ext/hyperwave/php3_hyperwave.h b/ext/hyperwave/php3_hyperwave.h
deleted file mode 100644
index f911c56fbb..0000000000
--- a/ext/hyperwave/php3_hyperwave.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of the GNU General Public License as published by |
- | the Free Software Foundation; either version 2 of the License, or |
- | (at your option) any later version. |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with this program; if not, write to the Free Software |
- | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _HW_H
-#define _HW_H
-
-#if COMPILE_DL
-#undef HYPERWAVE
-#define HYPERWAVE 1
-#endif
-
-#if WIN32||WINNT
-#define PHP_HW_API __declspec(dllexport)
-#else
-#define PHP_HW_API
-#endif
-
-#if HYPERWAVE
-#ifndef DLEXPORT
-#define DLEXPORT
-#endif
-
-#ifdef ZTS
-#include "TSRM.h"
-#endif
-
-#include "hg_comm.h"
-
-extern php3_module_entry hw_module_entry;
-#define hw_module_ptr &hw_module_entry
-
-typedef struct {
- long default_link;
- long default_port;
- long num_links,num_persistent;
- long max_links,max_persistent;
- long allow_persistent;
- int le_socketp, le_psocketp, le_document;
-} php_hw_globals;
-
-#ifdef ZTS
-# define HwSLS_D php_hw_globals *hw_globals
-# define HwSLS_DC , HwSLS_D
-# define HwSLS_C hw_globals
-# define HwSLS_CC , HwSLS_C
-# define HwSG(v) (hw_globals->v)
-# define HwSLS_FETCH() php_hw_globals *hw_globals = ts_resource(hw_globals_id)
-#else
-# define HwSLS_D
-# define HwSLS_DC
-# define HwSLS_C
-# define HwSLS_CC
-# define HwSG(v) (hw_globals.v)
-# define HwSLS_FETCH()
-extern PHP_HW_API php_hw_globals hw_globals;
-#endif
-
-//extern hw_module php3_hw_module;
-
-typedef struct {
- int size;
- char *data;
- char *attributes;
- char *bodytag;
-} hw_document;
-
-extern hw_connection php3_hw_connection;
-
-extern PHP_MINIT_FUNCTION(hw);
-extern PHP_MSHUTDOWN_FUNCTION(hw);
-PHP_MINFO_FUNCTION(hw);
-
-PHP_FUNCTION(hw_connect);
-PHP_FUNCTION(hw_pconnect);
-PHP_FUNCTION(hw_close);
-PHP_FUNCTION(hw_root);
-PHP_FUNCTION(hw_info);
-PHP_FUNCTION(hw_error);
-PHP_FUNCTION(hw_errormsg);
-PHP_FUNCTION(hw_mv);
-PHP_FUNCTION(hw_cp);
-PHP_FUNCTION(hw_deleteobject);
-PHP_FUNCTION(hw_changeobject);
-PHP_FUNCTION(hw_modifyobject);
-PHP_FUNCTION(hw_getparents);
-PHP_FUNCTION(hw_getparentsobj);
-PHP_FUNCTION(hw_children);
-PHP_FUNCTION(hw_childrenobj);
-PHP_FUNCTION(hw_getchildcoll);
-PHP_FUNCTION(hw_getchildcollobj);
-PHP_FUNCTION(hw_getobject);
-PHP_FUNCTION(hw_getandlock);
-PHP_FUNCTION(hw_unlock);
-PHP_FUNCTION(hw_gettext);
-PHP_FUNCTION(hw_edittext);
-PHP_FUNCTION(hw_getcgi);
-PHP_FUNCTION(hw_getremote);
-PHP_FUNCTION(hw_getremotechildren);
-PHP_FUNCTION(hw_pipedocument);
-PHP_FUNCTION(hw_pipecgi);
-PHP_FUNCTION(hw_insertdocument);
-PHP_FUNCTION(hw_docbyanchorobj);
-PHP_FUNCTION(hw_docbyanchor);
-PHP_FUNCTION(hw_getobjectbyquery);
-PHP_FUNCTION(hw_getobjectbyqueryobj);
-PHP_FUNCTION(hw_getobjectbyquerycoll);
-PHP_FUNCTION(hw_getobjectbyquerycollobj);
-PHP_FUNCTION(hw_getchilddoccoll);
-PHP_FUNCTION(hw_getchilddoccollobj);
-PHP_FUNCTION(hw_getanchors);
-PHP_FUNCTION(hw_getanchorsobj);
-PHP_FUNCTION(hw_getusername);
-PHP_FUNCTION(hw_setlinkroot);
-PHP_FUNCTION(hw_inscoll);
-PHP_FUNCTION(hw_incollections);
-PHP_FUNCTION(hw_insertobject);
-PHP_FUNCTION(hw_insdoc);
-PHP_FUNCTION(hw_identify);
-PHP_FUNCTION(hw_free_document);
-PHP_FUNCTION(hw_new_document);
-PHP_FUNCTION(hw_output_document);
-PHP_FUNCTION(hw_document_size);
-PHP_FUNCTION(hw_document_attributes);
-PHP_FUNCTION(hw_document_bodytag);
-PHP_FUNCTION(hw_document_content);
-PHP_FUNCTION(hw_document_setcontent);
-PHP_FUNCTION(hw_objrec2array);
-PHP_FUNCTION(hw_array2objrec);
-PHP_FUNCTION(hw_connection_info);
-PHP_FUNCTION(hw_getsrcbydestobj);
-PHP_FUNCTION(hw_getrellink);
-PHP_FUNCTION(hw_dummy);
-PHP_FUNCTION(hw_who);
-PHP_FUNCTION(hw_stat);
-
-#else
-#define hw_module_ptr NULL
-#endif /* HYPERWAVE */
-#define phpext_hyperwave_ptr hw_module_ptr
-#endif /* _HW_H */
-
diff --git a/ext/hyperwave/setup.stub b/ext/hyperwave/setup.stub
deleted file mode 100644
index 51099054d1..0000000000
--- a/ext/hyperwave/setup.stub
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-hyperwave 'Hyperwave support?' yesno no \
-' Whether to build with Hyperwave support. More\n
- information about Hyperwave can be found at http://www.hyperwave.com.'
diff --git a/ext/icap/Makefile.am b/ext/icap/Makefile.am
deleted file mode 100644
index 3322c1ccf8..0000000000
--- a/ext/icap/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_icap.a
-libphpext_icap_a_SOURCES=php3_icap.c
-
diff --git a/ext/icap/config.h.stub b/ext/icap/config.h.stub
deleted file mode 100644
index 0d5247a428..0000000000
--- a/ext/icap/config.h.stub
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Define if you want the ICAP extension */
-#define HAVE_ICAP 0
diff --git a/ext/icap/config.m4 b/ext/icap/config.m4
deleted file mode 100644
index c22a52ddc1..0000000000
--- a/ext/icap/config.m4
+++ /dev/null
@@ -1,25 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(for ICAP support)
-AC_ARG_WITH(icap,
-[ --with-icap[=DIR] Include ICAP support.],
-[
- if test "$withval" != "no"; then
- if test "$withval" = "yes"; then
- ICAP_DIR=/usr/local
- else
- ICAP_DIR=$withval
- fi
-
- AC_ADD_INCLUDE($ICAP_DIR)
- AC_ADD_LIBRARY_WITH_PATH(icap, $ICAP_DIR)
- AC_DEFINE(HAVE_ICAP)
- PHP_EXTENSION(icap)
- AC_MSG_RESULT(yes)
- else
- AC_MSG_ERROR(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-
diff --git a/ext/icap/php3_icap.c b/ext/icap/php3_icap.c
deleted file mode 100644
index 5c63c30a85..0000000000
--- a/ext/icap/php3_icap.c
+++ /dev/null
@@ -1,955 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: |
- | Mark Musone <musone@chek.com> |
- +----------------------------------------------------------------------+
- */
-
-#define ICAP1
-
-#ifdef ERROR
-#undef ERROR
-#endif
-
-#include "php.h"
-
-#if COMPILE_DL
-#include "dl/phpdl.h"
-#endif
-
-#if HAVE_ICAP
-
-#include <time.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <signal.h>
-#include <stdarg.h>
-#include "cal.h"
-#include "php3_icap.h"
-#include "modules.h"
-#if (WIN32|WINNT)
-#include "winsock.h"
-#endif
-CALSTREAM *cal_open();
-CALSTREAM *cal_close_it ();
-CALSTREAM *cal_close_full ();
-
-
-typedef struct php3_icap_le_struct {
- CALSTREAM *icap_stream;
- long flags;
-} pils;
-
-
-typedef struct cal_list
-{
-u_int32_t uid;
-struct cal_list *next;
-} cal_list_t;
-
-static cal_list_t *g_cal_list=NULL;
-static cal_list_t *g_cal_list_end=NULL;
-/*
- * this array should be set up as:
- * {"PHPScriptFunctionName",dllFunctionName,1}
- */
-
-function_entry icap_functions[] = {
- {"icap_open", php3_icap_open, NULL},
- {"icap_popen", php3_icap_popen, NULL},
- {"icap_reopen", php3_icap_reopen, NULL},
- {"icap_fetch_event", php3_icap_fetch_event, NULL},
- {"icap_list_events", php3_icap_list_events, NULL},
- {"icap_list_alarms", php3_icap_list_alarms, NULL},
- {"icap_create_calendar", php3_icap_create_calendar, NULL},
- {"icap_rename_calendar", php3_icap_rename_calendar, NULL},
- {"icap_delete_calendar", php3_icap_delete_calendar, NULL},
- {"icap_delete_event", php3_icap_delete_event, NULL},
- {"icap_store_event", php3_icap_store_event, NULL},
- {"icap_snooze", php3_icap_snooze, NULL},
- {NULL, NULL, NULL}
-};
-
-
-php3_module_entry php3_icap_module_entry = {
- CALVER, icap_functions, PHP_MINIT(icap), NULL, NULL, NULL, PHP_MINFO(icap), 0, 0, 0, NULL
-};
-
-
-#if COMPILE_DL
-DLEXPORT php3_module_entry *get_module(void) { return &php3_icap_module_entry; }
-#endif
-
-/*
- I believe since this global is used ONLY within this module,
- and nothing will link to this module, we can use the simple
- thread local_ storage
-*/
-int le_icap;
-#ifdef OP_RELOGIN
-/* AJS: persistent connection type */
-int le_picap;
-#endif
-char icap_user[80]="";
-char icap_password[80]="";
-
-CALSTREAM *cal_close_it (pils *icap_le_struct)
-{
- CALSTREAM *ret;
- ret = cal_close (icap_le_struct->icap_stream,0);
- efree(icap_le_struct);
- return ret;
-}
-
-
-PHP_MINFO_FUNCTION(icap)
-{
- php3_printf("Icap Support enabled<br>");
- php3_printf("<table>");
- php3_printf("<tr><td>Icap Version:</td>");
- php3_printf("<td>%s</td>",CALVER);
- php3_printf("</tr></table>");
-}
-
-PHP_MINIT_FUNCTION(icap)
-{
-
- le_icap = register_list_destructors(cal_close_it,NULL);
-
- return SUCCESS;
-}
-
-
-static int add_assoc_object(pval *arg, char *key, pval *tmp)
-{
- HashTable *symtable;
-
- if (arg->type == IS_OBJECT) {
- symtable = arg->value.obj.properties;
- } else {
- symtable = arg->value.ht;
- }
- return zend_hash_update(symtable, key, strlen(key)+1, (void *) &tmp, sizeof(pval *), NULL);
-}
-
-
-void php3_icap_do_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
-{
- pval *calendar;
- pval *user;
- pval *passwd;
- pval *options;
- CALSTREAM *icap_stream;
- pils *icap_le_struct;
- long flags=0;
- long cl_flags=0;
- int ind;
- int myargc=ARG_COUNT(ht);
-
-
- if (myargc <3 || myargc >4 || getParameters(ht, myargc, &calendar,&user,&passwd,&options) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(calendar);
- convert_to_string(user);
- convert_to_string(passwd);
- strcpy(icap_user,user->value.str.val);
- strcpy(icap_password,passwd->value.str.val);
- if(myargc ==4) {
- convert_to_long(options);
- flags=options->value.lval;
- }
- icap_stream = cal_open(NULL,calendar->value.str.val,0);
- if (!icap_stream) {
- php3_error(E_WARNING,"Couldn't open stream %s\n",calendar->value.str.val);
- RETURN_FALSE;
- }
-
- icap_le_struct = emalloc(sizeof(pils));
- icap_le_struct->icap_stream = icap_stream;
- icap_le_struct->flags = 0;
- ind = php3_list_insert(icap_le_struct, le_icap);
- RETURN_LONG(ind);
-}
-
-
-
-
-/* {{{ proto int icap_close(int stream_id [, int options])
- Close an ICAP stream */
-void php3_icap_close(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *options, *streamind;
- int ind, ind_type;
- pils *icap_le_struct=NULL;
- int myargcount=ARG_COUNT(ht);
- long flags = 0;
-
- if (myargcount < 1 || myargcount > 2 || getParameters(ht, myargcount, &streamind, &options) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(streamind);
- ind = streamind->value.lval;
- icap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!icap_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- if(myargcount==2) {
- convert_to_long(options);
- flags = options->value.lval;
- icap_le_struct->flags = flags;
- }
- php3_list_delete(ind);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-
-
-
-
-
-
-/* {{{ proto int icap_open(string calendar, string user, string password [, int options])
- Open an ICAP stream to a calendar */
-void php3_icap_open(INTERNAL_FUNCTION_PARAMETERS)
-{
- php3_icap_do_open(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-
-/* {{{ proto int icap_reopen(int stream_id, string calendar [, int options])
- Reopen ICAP stream to new calendar */
-void php3_icap_reopen(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind;
- pval *calendar;
- pval *options;
- CALSTREAM *icap_stream;
- pils *icap_le_struct;
- int ind, ind_type;
- long flags=0;
- long cl_flags=0;
- int myargc=ARG_COUNT(ht);
-
- if (myargc<2 || myargc>3 || getParameters(ht,myargc,&streamind, &calendar, &options) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- ind = streamind->value.lval;
- icap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!icap_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- convert_to_string(calendar);
- if(myargc == 3) {
- convert_to_long(options);
- flags = options->value.lval;
- icap_le_struct->flags = cl_flags;
- }
- // icap_stream = cal_connect(calendar->value.str.val);
- // cal_login(icap_stream, calendar->value.str.val);
- if (icap_stream == NULL) {
- php3_error(E_WARNING,"Couldn't re-open stream\n");
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/* {{{ proto int icap_expunge(int stream_id)
- Delete all messages marked for deletion */
-void php3_icap_expunge(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind;
- int ind, ind_type;
- pval *start,*end;
- pils *icap_le_struct;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &streamind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
-
- ind = streamind->value.lval;
-
- icap_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!icap_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
-/* cal_expunge (icap_le_struct->icap_stream);
-*/
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int icap_fetch_event(int stream_id,int eventid, [int options])
- Fetch an event*/
-void php3_icap_fetch_event(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*eventid,*start,*end,*options=NULL;
- int ind, ind_type;
- pils *icap_le_struct=NULL;
- CALEVENT *myevent;
- int myargcount=ARG_COUNT(ht);
-
- if (myargcount < 1 || myargcount > 3 || getParameters(ht, myargcount, &streamind, &eventid,&options) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(streamind);
- convert_to_long(eventid);
- ind = streamind->value.lval;
- icap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!icap_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- if(myargcount==3) {
- convert_to_long(options);
- }
- cal_fetch(icap_le_struct->icap_stream,eventid->value.lval,&myevent);
-
- object_init(return_value);
- add_property_long(return_value,"id",myevent->id);
- add_property_long(return_value,"public",myevent->public);
- MAKE_STD_ZVAL(start);
- object_init(start);
- if(myevent->start.has_date)
- {
- add_property_long(start,"year",myevent->start.year);
- add_property_long(start,"month",myevent->start.mon);
- add_property_long(start,"mday",myevent->start.mday);
- }
- if(myevent->start.has_time)
- {
- add_property_long(start,"hour",myevent->start.hour);
- add_property_long(start,"min",myevent->start.min);
- add_property_long(start,"sec",myevent->start.sec);
- }
- add_assoc_object(return_value, "start",start);
-
- MAKE_STD_ZVAL(end);
- object_init(end);
- if(myevent->end.has_date)
- {
- add_property_long(end,"year",myevent->end.year);
- add_property_long(end,"month",myevent->end.mon);
- add_property_long(end,"mday",myevent->end.mday);
- }
- if(myevent->end.has_time)
- {
- add_property_long(end,"hour",myevent->end.hour);
- add_property_long(end,"min",myevent->end.min);
- add_property_long(end,"sec",myevent->end.sec);
- }
- add_assoc_object(return_value, "end",end);
-
- add_property_string(return_value,"category",myevent->category,1);
- add_property_string(return_value,"title",myevent->title,1);
- add_property_string(return_value,"description",myevent->description,1);
- add_property_long(return_value,"alarm",myevent->alarm);
-}
-/* }}} */
-
-/* {{{ proto array icap_list_events(int stream_id,int begindate, [int enddate])
- Returns list of UIDs for that day or range of days */
-void php3_icap_list_events(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*begindate,*enddate;
- pval **pvalue;
- int ind, ind_type;
- unsigned long i;
- char *t;
- int icap_folders=0;
- unsigned int msgno;
- pils *icap_le_struct;
- cal_list_t *my_cal_list;
- datetime_t begincal,endcal;
- int myargc;
- myargc=ARG_COUNT(ht);
- if (myargc <2 || myargc > 3 || getParameters(ht,myargc,&streamind,&begindate,&enddate) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_array(begindate);
- if(myargc == 3) convert_to_array(enddate);
- ind = streamind->value.lval;
-
- icap_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!icap_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- /* Initialize return array */
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
- begincal.has_time=0;
- endcal.has_time=0;
- if(_php3_hash_find(begindate->value.ht,"year",sizeof("year"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- begincal.year=(*pvalue)->value.lval;
- }
- if(_php3_hash_find(begindate->value.ht,"month",sizeof("month"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- begincal.mon=(*pvalue)->value.lval;
- }
- if(_php3_hash_find(begindate->value.ht,"day",sizeof("day"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- begincal.mday=(*pvalue)->value.lval;
- }
-if(myargc == 3)
- {
- if(_php3_hash_find(enddate->value.ht,"year",sizeof("year"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- endcal.year=(*pvalue)->value.lval;
- }
- if(_php3_hash_find(enddate->value.ht,"month",sizeof("month"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- endcal.mon=(*pvalue)->value.lval;
- }
- if(_php3_hash_find(enddate->value.ht,"day",sizeof("day"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- endcal.mday=(*pvalue)->value.lval;
- }
- }
-
-
-g_cal_list=NULL;
- cal_search_range(icap_le_struct->icap_stream,&begincal,&endcal);
- my_cal_list=g_cal_list;
- while(my_cal_list != NULL)
- {
- add_next_index_long(return_value,my_cal_list->uid);
- my_cal_list=my_cal_list->next;
- free(g_cal_list);
- g_cal_list=my_cal_list;
- }
-}
-/* }}} */
-
-
-/* {{{ proto string icap_create_calendar(int stream_id, string calendar)
- Create a new calendar*/
-
-void php3_icap_create_calendar(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind, *calendar;
- int ind, ind_type;
- pils *icap_le_struct;
- int myargc=ARG_COUNT(ht);
- if (myargc <1 || myargc > 2 || getParameters(ht,myargc,&streamind,&calendar) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(calendar);
- ind = streamind->value.lval;
-
- icap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!icap_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-/*
- if (icap_create(icap_le_struct->icap_stream,calendar->value.str.val))
- {
- RETURN_TRUE;
- }
- else
- {
- RETURN_FALSE;
- }
-*/
-}
-/* }}} */
-
-
-/* {{{ proto string icap_rename(int stream_id, string src_calendar, string dest_calendar)
- Rename a calendar*/
-void php3_icap_rename_calendar(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind, *src_calendar,*dest_calendar;
- int ind, ind_type;
- pils *icap_le_struct;
- int myargc=ARG_COUNT(ht);
- if (myargc <2 || myargc > 3 || getParameters(ht,myargc,&streamind,&src_calendar,&dest_calendar) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(src_calendar);
- convert_to_string(dest_calendar);
- ind = streamind->value.lval;
-
- icap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!icap_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-/*
- if(icap_rename(icap_le_struct->icap_stream,src_calendar->value.str.val,dest_calendar->value.str.val)) {RETURN_TRUE;}
- else {RETURN_FALSE; }
-*/
-}
-/* }}} */
-
-
-
-
-/* {{{ proto int icap_reopen(int stream_id, array date, array time)
- list alarms for a given time */
-void php3_icap_list_alarms(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind, *date,*time;
- pval **pvalue;
- datetime_t mydate;
- int ind, ind_type;
- pils *icap_le_struct;
- int icap_folders=0;
- unsigned int msgno;
- cal_list_t *my_cal_list;
-
- int myargc=ARG_COUNT(ht);
- if (myargc != 3 || getParameters(ht,myargc,&streamind,&date,&time) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_array(date);
- convert_to_array(time);
- ind = streamind->value.lval;
-
- icap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!icap_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
- mydate.has_date=1;
- mydate.has_time=1;
- if(_php3_hash_find(date->value.ht,"year",sizeof("year"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- mydate.year=(*pvalue)->value.lval;
- }
- if(_php3_hash_find(date->value.ht,"month",sizeof("month"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- mydate.mon=(*pvalue)->value.lval;
- }
- if(_php3_hash_find(date->value.ht,"day",sizeof("day"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- mydate.mday=(*pvalue)->value.lval;
- }
-
- if(_php3_hash_find(time->value.ht,"hour",sizeof("hour"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- mydate.hour=(*pvalue)->value.lval;
- }
- if(_php3_hash_find(time->value.ht,"minute",sizeof("minute"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- mydate.min=(*pvalue)->value.lval;
- }
- mydate.sec=0;
- g_cal_list=NULL;
- cal_search_alarm(icap_le_struct->icap_stream,&mydate);
- my_cal_list=g_cal_list;
- while(my_cal_list != NULL)
- {
- add_next_index_long(return_value,my_cal_list->uid);
- my_cal_list=my_cal_list->next;
- free(g_cal_list);
- g_cal_list=my_cal_list;
- }
-
-
-}
-/* }}} */
-
-
-/* {{{ proto string icap_delete_calendar(int stream_id, string calendar)
- Delete calendar*/
-void php3_icap_delete_calendar(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind, *calendar;
- int ind, ind_type;
- pils *icap_le_struct;
- int myargc=ARG_COUNT(ht);
- if (myargc <1 || myargc > 2 || getParameters(ht,myargc,&streamind,&calendar) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(calendar);
- ind = streamind->value.lval;
-
- icap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!icap_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- if (icap_delete_calendar(icap_le_struct->icap_stream,calendar->value.str.val))
- {
- RETURN_TRUE;
- }
- else
- {
- RETURN_FALSE;
- }
-
-}
-/* }}} */
-
-
-/* {{{ proto string icap_delete_event(int stream_id, int uid)
- Delete event*/
-void php3_icap_delete_event(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind, *uid;
- int ind, ind_type;
- pils *icap_le_struct;
- int myargc=ARG_COUNT(ht);
- if (myargc <1 || myargc > 2 || getParameters(ht,myargc,&streamind,&uid) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(uid);
- ind = streamind->value.lval;
-
- icap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!icap_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- if (cal_remove(icap_le_struct->icap_stream,uid->value.lval))
- {
- RETURN_TRUE;
- }
- else
- {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto string icap_delete_calendar(int stream_id, int uid)
- Delete event*/
-icap_delete_calendar(){
- return 1;
-}
-/* }}} */
-
-void php3_icap_popen(INTERNAL_FUNCTION_PARAMETERS){
-}
-
-
-/* {{{ proto string icap_store_event(int stream_id, object event)
- Store an event*/
-void php3_icap_store_event(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*storeobject;
- int ind, ind_type;
- unsigned long i;
- char *t;
- int icap_folders=0;
- unsigned int msgno;
- pils *icap_le_struct;
- pval **pvalue,**temppvalue;
- cal_list_t *my_cal_list;
- int myargc;
- unsigned long uid;
- CALEVENT *myevent;
- myargc=ARG_COUNT(ht);
- if (myargc !=2 || getParameters(ht,myargc,&streamind,&storeobject) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_array(storeobject);
-
- ind = streamind->value.lval;
-
- icap_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!icap_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- /* Initialize return array */
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
- myevent=calevent_new();
- if(_php3_hash_find(storeobject->value.ht,"uid",sizeof("uid"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- myevent->id=(*pvalue)->value.lval;
- }
- if(_php3_hash_find(storeobject->value.ht,"public",sizeof("public"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- myevent->public=(*pvalue)->value.lval;
- }
- if(_php3_hash_find(storeobject->value.ht,"category",sizeof("category"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- myevent->category=strdup((*pvalue)->value.str.val);
- }
- if(_php3_hash_find(storeobject->value.ht,"title",sizeof("title"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- myevent->title=strdup((*pvalue)->value.str.val);
- }
- if(_php3_hash_find(storeobject->value.ht,"description",sizeof("description"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- myevent->description=strdup((*pvalue)->value.str.val);
- }
-
- if(_php3_hash_find(storeobject->value.ht,"alarm",sizeof("alarm"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- myevent->alarm=(*pvalue)->value.lval;
- }
-
-
- if(_php3_hash_find(storeobject->value.ht,"start",sizeof("start"),(void **) &temppvalue)== SUCCESS){
- SEPARATE_ZVAL(temppvalue);
- convert_to_array(*temppvalue);
-
- if(_php3_hash_find((*temppvalue)->value.ht,"year",sizeof("year"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- myevent->start.year=(*pvalue)->value.lval;
- }
- if(_php3_hash_find((*temppvalue)->value.ht,"month",sizeof("month"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- myevent->start.mon=(*pvalue)->value.lval;
- }
- if(_php3_hash_find((*temppvalue)->value.ht,"mday",sizeof("mday"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- myevent->start.mday=(*pvalue)->value.lval;
- }
- if(_php3_hash_find((*temppvalue)->value.ht,"hour",sizeof("hour"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- myevent->start.hour=(*pvalue)->value.lval;
- }
- if(_php3_hash_find((*temppvalue)->value.ht,"min",sizeof("min"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- myevent->start.min=(*pvalue)->value.lval;
- }
- if(_php3_hash_find((*temppvalue)->value.ht,"sec",sizeof("sec"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- myevent->start.sec=(*pvalue)->value.lval;
- }
- myevent->start.has_date=true;
- }
-
- if(_php3_hash_find(storeobject->value.ht,"end",sizeof("end"),(void **) &temppvalue)== SUCCESS){
- SEPARATE_ZVAL(temppvalue);
- convert_to_array(*temppvalue);
-
- if(_php3_hash_find((*temppvalue)->value.ht,"year",sizeof("year"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- myevent->end.year=(*pvalue)->value.lval;
- }
- if(_php3_hash_find((*temppvalue)->value.ht,"month",sizeof("month"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- myevent->end.mon=(*pvalue)->value.lval;
- }
- if(_php3_hash_find((*temppvalue)->value.ht,"mday",sizeof("mday"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- myevent->end.mday=(*pvalue)->value.lval;
- }
- if(_php3_hash_find((*temppvalue)->value.ht,"hour",sizeof("hour"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- myevent->end.hour=(*pvalue)->value.lval;
- }
- if(_php3_hash_find((*temppvalue)->value.ht,"min",sizeof("min"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- myevent->end.min=(*pvalue)->value.lval;
- }
- if(_php3_hash_find((*temppvalue)->value.ht,"sec",sizeof("sec"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- myevent->end.sec=(*pvalue)->value.lval;
- }
- myevent->end.has_date=true;
- }
-
- cal_append(icap_le_struct->icap_stream,"INBOX",&uid,myevent);
- calevent_free(myevent);
- RETURN_LONG(uid);
-}
-/* }}} */
-
-
-/* {{{ proto string icap_snooze(int stream_id, int uid)
- Snooze an alarm*/
-void php3_icap_snooze(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*uid;
- int ind, ind_type;
- pils *icap_le_struct;
- pval **pvalue;
- int myargc;
- myargc=ARG_COUNT(ht);
- if (myargc !=2 || getParameters(ht,myargc,&streamind,&uid) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(uid);
-
- ind = streamind->value.lval;
-
- icap_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!icap_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- if(cal_snooze(icap_le_struct->icap_stream,uid->value.lval))
- {
- RETURN_TRUE;
- }
- else
- {
- RETURN_FALSE;
- }
-
-
-}
-/* }}} */
-
-
-/* Interfaces to callbacks */
-
-
-void cc_searched (unsigned long cal_uid)
-{
-
- if(g_cal_list==NULL)
- {
- g_cal_list=malloc(sizeof(struct cal_list));
- g_cal_list->uid=cal_uid;
- g_cal_list->next=NULL;
- g_cal_list_end=g_cal_list;
- }
- else
- {
- g_cal_list_end->next=malloc(sizeof(struct cal_list));
- g_cal_list_end=g_cal_list_end->next;
- g_cal_list_end->uid=cal_uid;
- g_cal_list_end->next=NULL;
- }
-}
-
-
-
-
-
-
-void cc_appended(u_int32_t uid)
-{
-
-}
-
-
-void cc_fetched(const CALEVENT *event)
-{
-
-}
-
-
-void cc_login(const char **user, const char **pwd)
-{
-
-*user=icap_user;
-*pwd=icap_password;
-}
-
-
-void cc_vlog(const char *fmt,va_list ap)
-{
-}
-void cc_vdlog(const char *fmt,va_list ap)
-{
-}
-
-#endif
-
-
-/*
- * Local_ variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
-
-
diff --git a/ext/icap/php3_icap.h b/ext/icap/php3_icap.h
deleted file mode 100644
index f7e1b06b54..0000000000
--- a/ext/icap/php3_icap.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* $Id$ */
-
-#ifndef _INCLUDED_ICAP_H
-#define _INCLUDED_ICAP_H
-
-#if COMPILE_DL
-#undef HAVE_ICAP
-#define HAVE_ICAP 1
-#endif
-
-#if HAVE_ICAP
-
-#ifdef THREAD_SAFE
-#include "tls.h"
-#endif
-#ifndef MSVC5
-#include "build-defs.h"
-#endif
-
-extern PHP_MINIT_FUNCTION(icap);
-PHP_MINFO_FUNCTION(icap);
-
-/* Functions accessable to PHP */
-extern php3_module_entry php3_icap_module_entry;
-#define php3_icap_module_ptr &php3_icap_module_entry
-#define phpext_icap_ptr php3_icap_module_ptr
-
-extern int icap_init_request(INIT_FUNC_ARGS);
-extern int icap_end_request(void);
-void php3_icap_open(INTERNAL_FUNCTION_PARAMETERS);
-void php3_icap_popen(INTERNAL_FUNCTION_PARAMETERS);
-void php3_icap_reopen(INTERNAL_FUNCTION_PARAMETERS);
-void php3_icap_close(INTERNAL_FUNCTION_PARAMETERS);
-void php3_icap_fetch_event(INTERNAL_FUNCTION_PARAMETERS);
-void php3_icap_list_events(INTERNAL_FUNCTION_PARAMETERS);
-void php3_icap_create_calendar(INTERNAL_FUNCTION_PARAMETERS);
-void php3_icap_rename_calendar(INTERNAL_FUNCTION_PARAMETERS);
-void php3_icap_delete_calendar(INTERNAL_FUNCTION_PARAMETERS);
-void php3_icap_store_event(INTERNAL_FUNCTION_PARAMETERS);
-void php3_icap_delete_event(INTERNAL_FUNCTION_PARAMETERS);
-void php3_icap_snooze(INTERNAL_FUNCTION_PARAMETERS);
-void php3_icap_list_alarms(INTERNAL_FUNCTION_PARAMETERS);
-
-
-
-
-
-#else
-#define php3_icap_module_ptr NULL
-#endif /* HAVE_ICAP */
-
-
-#endif
-
-
-
-
diff --git a/ext/imap/Makefile.am b/ext/imap/Makefile.am
deleted file mode 100644
index 51e2641464..0000000000
--- a/ext/imap/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_imap.a
-libphpext_imap_a_SOURCES=imap.c
-
diff --git a/ext/imap/config.h.stub b/ext/imap/config.h.stub
deleted file mode 100644
index d225ffa092..0000000000
--- a/ext/imap/config.h.stub
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Define if you want the IMAP extension */
-#define HAVE_IMAP 0
diff --git a/ext/imap/config.m4 b/ext/imap/config.m4
deleted file mode 100644
index 9eec8c0ad1..0000000000
--- a/ext/imap/config.m4
+++ /dev/null
@@ -1,63 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(for IMAP support)
-AC_ARG_WITH(imap,
-[ --with-imap[=DIR] Include IMAP support. DIR is the IMAP include
- and c-client.a directory.],
-[
- if test "$withval" = "yes"; then
- if test -f /usr/local/include/mail.h; then
- withval=/usr/local
- elif test -f /usr/include/mail.h; then
- withval=/usr
- elif test -f /usr/include/imap/mail.h; then
- withval=/usr
- elif test -f /usr/include/c-client/mail.h; then
- withval=/usr
- fi
- fi
- if test "$withval" != "no" && test "$withval" != "yes"; then
- IMAP_DIR=$withval
- if test -f $IMAP_DIR/include/imap/mail.h; then
- IMAP_INC_DIR=$IMAP_DIR/include/imap
- elif test -f $IMAP_DIR/include/c-client/mail.h; then
- IMAP_INC_DIR=$IMAP_DIR/include/c-client
- else
- IMAP_INC_DIR=$withval/include
- fi
- if test ! -f $IMAP_INC_DIR/mail.h; then
- AC_MSG_ERROR(could not find mail.h in $IMAP_INC_DIR !)
- fi
- if test ! -f $IMAP_INC_DIR/rfc822.h; then
- AC_MSG_ERROR(could not find rfc822.h in $IMAP_INC_DIR !)
- fi
- if test ! -f $IMAP_INC_DIR/linkage.h; then
- AC_MSG_ERROR(could not find linkage.h in $IMAP_INC_DIR !)
- fi
- if test -f $IMAP_DIR/lib/libimap.a; then
- IMAP_LIBDIR="$IMAP_DIR/lib"
- IMAP_LIB="imap"
- elif test ! -f $IMAP_DIR/lib/libc-client.a; then
- if test ! -f $IMAP_DIR/lib/libc-client4.so; then
- AC_MSG_ERROR(You need to copy or link $IMAP_DIR/lib/c-client.a to $IMAP_DIR/lib/libc-client.a)
- else
- IMAP_LIBDIR="$IMAP_DIR/lib"
- IMAP_LIB="c-client4"
- fi
- else
- IMAP_LIBDIR="$IMAP_DIR/lib"
- IMAP_LIB="c-client"
- fi
- AC_ADD_LIBRARY_WITH_PATH($IMAP_LIB, $IMAP_LIBDIR)
- AC_ADD_INCLUDE($IMAP_INC_DIR)
- AC_DEFINE(HAVE_IMAP)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(imap)
- else
- AC_MSG_ERROR(could not find imap library!)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-
-
diff --git a/ext/imap/imap.c b/ext/imap/imap.c
deleted file mode 100644
index 37e78c989f..0000000000
--- a/ext/imap/imap.c
+++ /dev/null
@@ -1,2692 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rex Logan <veebert@dimensional.com> |
- | Mark Musone <musone@afterfive.com> |
- | Brian Wang <brian@vividnet.com> |
- | Kaj-Michael Lang <milang@tal.org> |
- | Antoni Pamies Olive <toni@readysoft.net> |
- | Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | PHP 4.0 updates: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#define IMAP41
-
-#ifdef ERROR
-#undef ERROR
-#endif
-
-#include "php.h"
-
-#if COMPILE_DL
-#include "dl/phpdl.h"
-#endif
-
-#if HAVE_IMAP
-
-#include <time.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <signal.h>
-#include "imap.h"
-#include "mail.h"
-#include "rfc822.h"
-#include "modules.h"
-#if (WIN32|WINNT)
-#include "winsock.h"
-#endif
-
-#ifdef IMAP41
-#define LSIZE text.size
-#define LTEXT text.data
-#define DTYPE int
-#define CONTENT_PART nested.part
-#define CONTENT_MSG_BODY nested.msg->body
-#define IMAPVER "Imap 4R1"
-#else
-#define LSIZE size
-#define LTEXT text
-#define DTYPE char
-#define CONTENT_PART contents.part
-#define CONTENT_MSG_BODY contents.msg.body
-#define IMAPVER "Imap 4"
-#endif
-
-#define PHP_EXPUNGE 32768
-
-/*
- * this array should be set up as:
- * {"PHPScriptFunctionName",dllFunctionName,1}
- */
-
-/* type casts left out, put here to remove warnings in
- msvc
-*/
-void rfc822_date(char *date);
-extern char *cpystr(const char *string);
-extern unsigned long find_rightmost_bit (unsigned long *valptr);
-void fs_give (void **block);
-void *fs_get (size_t size);
-int add_assoc_object(pval *arg, char *key, pval *tmp);
-int add_next_index_object(pval *arg, pval *tmp);
-void imap_add_body( pval *arg, BODY *body );
-
-typedef struct php3_imap_le_struct {
- MAILSTREAM *imap_stream;
- long flags;
-} pils;
-
-MAILSTREAM *mail_close_it (pils *imap_le_struct);
-
-function_entry imap_functions[] = {
- {"imap_open", php3_imap_open, NULL},
- {"imap_reopen", php3_imap_reopen, NULL},
- {"imap_num_msg", php3_imap_num_msg, NULL},
- {"imap_num_recent", php3_imap_num_recent, NULL},
- {"imap_headers", php3_imap_headers, NULL},
- {"imap_header", php3_imap_headerinfo, NULL},
- {"imap_headerinfo", php3_imap_headerinfo, NULL},
- {"imap_body", php3_imap_body, NULL},
- {"imap_fetchstructure", php3_imap_fetchstructure, NULL},
- {"imap_fetchbody", php3_imap_fetchbody, NULL},
- {"imap_expunge", php3_imap_expunge, NULL},
- {"imap_delete", php3_imap_delete, NULL},
- {"imap_undelete", php3_imap_undelete, NULL},
- {"imap_check", php3_imap_check, NULL},
- {"imap_close", php3_imap_close, NULL},
- {"imap_mail_copy", php3_imap_mail_copy, NULL},
- {"imap_mail_move", php3_imap_mail_move, NULL},
- {"imap_createmailbox", php3_imap_createmailbox, NULL},
- {"imap_renamemailbox", php3_imap_renamemailbox, NULL},
- {"imap_deletemailbox", php3_imap_deletemailbox, NULL},
- {"imap_listmailbox", php3_imap_list, NULL},
- {"imap_scanmailbox", php3_imap_listscan, NULL},
- {"imap_listsubscribed", php3_imap_lsub, NULL},
- {"imap_subscribe", php3_imap_subscribe, NULL},
- {"imap_unsubscribe", php3_imap_unsubscribe, NULL},
- {"imap_append", php3_imap_append, NULL},
- {"imap_ping", php3_imap_ping, NULL},
- {"imap_base64", php3_imap_base64, NULL},
- {"imap_qprint", php3_imap_qprint, NULL},
- {"imap_8bit", php3_imap_8bit, NULL},
- {"imap_binary", php3_imap_binary, NULL},
- {"imap_mailboxmsginfo", php3_imap_mailboxmsginfo, NULL},
- {"imap_rfc822_write_address", php3_imap_rfc822_write_address, NULL},
- {"imap_rfc822_parse_adrlist", php3_imap_rfc822_parse_adrlist, NULL},
- {"imap_setflag_full", php3_imap_setflag_full, NULL},
- {"imap_clearflag_full", php3_imap_clearflag_full, NULL},
- {"imap_sort", php3_imap_sort, NULL},
- {"imap_fetchheader", php3_imap_fetchheader, NULL},
- {"imap_fetchtext", php3_imap_body, NULL},
- {"imap_uid", php3_imap_uid, NULL},
- {"imap_msgno",php3_imap_msgno, NULL},
- {"imap_list", php3_imap_list, NULL},
- {"imap_scan", php3_imap_listscan, NULL},
- {"imap_lsub", php3_imap_lsub, NULL},
- {"imap_create", php3_imap_createmailbox, NULL},
- {"imap_rename", php3_imap_renamemailbox, NULL},
- {"imap_status", php3_imap_status, NULL},
- {"imap_bodystruct", php3_imap_bodystruct, NULL},
- {"imap_fetch_overview", php3_imap_fetch_overview, NULL},
- {"imap_mail_compose", php3_imap_mail_compose, NULL},
- {NULL, NULL, NULL}
-};
-
-
-php3_module_entry php3_imap_module_entry = {
- IMAPVER, imap_functions, PHP_MINIT(imap), NULL, NULL, NULL,PHP_MINFO(imap), 0, 0, 0, NULL
-};
-
-
-#if COMPILE_DL
-DLEXPORT php3_module_entry *get_module(void) { return &php3_imap_module_entry; }
-#endif
-
-/*
- I beleive since this global is used ONLY within this module,
- and nothing will link to this module, we can use the simple
- thread local storage
-*/
-int le_imap;
-char imap_user[80]="";
-char imap_password[80]="";
-STRINGLIST *imap_folders=NIL;
-STRINGLIST *imap_sfolders=NIL;
-long status_flags;
-unsigned long status_messages;
-unsigned long status_recent;
-unsigned long status_unseen;
-unsigned long status_uidnext;
-unsigned long status_uidvalidity;
-
-MAILSTREAM *mail_close_it (pils *imap_le_struct)
-{
- MAILSTREAM *ret;
- ret = mail_close_full (imap_le_struct->imap_stream,imap_le_struct->flags);
- efree(imap_le_struct);
- return ret;
-}
-
-static int add_assoc_object(pval *arg, char *key, pval *tmp)
-{
- HashTable *symtable;
-
- if (arg->type == IS_OBJECT) {
- symtable = arg->value.obj.properties;
- } else {
- symtable = arg->value.ht;
- }
- return zend_hash_update(symtable, key, strlen(key)+1, (void *) &tmp, sizeof(pval *), NULL);
-}
-
-inline int add_next_index_object(pval *arg, pval *tmp)
-{
- HashTable *symtable;
-
- if (arg->type == IS_OBJECT) {
- symtable = arg->value.obj.properties;
- } else {
- symtable = arg->value.ht;
- }
-
- return zend_hash_next_index_insert(symtable, (void *) &tmp, sizeof(pval *), NULL);
-}
-
-
-PHP_MINFO_FUNCTION(imap)
-{
- php_printf("Imap Support enabled<br>");
- php_printf("<table>");
- php_printf("<tr><td>Imap c-client Version:</td>");
-#ifdef IMAP41
- php_printf("<td>Imap 4.1</td>");
-#else
- php_printf("<td>Imap 4.0</td>");
-#endif
- php_printf("</tr></table>");
-}
-
-PHP_MINIT_FUNCTION(imap)
-{
-#if !(WIN32|WINNT)
- mail_link(&unixdriver); /* link in the unix driver */
-#endif
- mail_link (&imapdriver); /* link in the imap driver */
- mail_link (&nntpdriver); /* link in the nntp driver */
- mail_link (&pop3driver); /* link in the pop3 driver */
-#if !(WIN32|WINNT)
- mail_link (&mhdriver); /* link in the mh driver */
- mail_link (&mxdriver); /* link in the mx driver */
-#endif
- mail_link (&mbxdriver); /* link in the mbx driver */
- mail_link (&tenexdriver); /* link in the tenex driver */
- mail_link (&mtxdriver); /* link in the mtx driver */
-#if !(WIN32|WINNT)
- mail_link (&mmdfdriver); /* link in the mmdf driver */
- mail_link (&newsdriver); /* link in the news driver */
- mail_link (&philedriver); /* link in the phile driver */
-#endif
- mail_link (&dummydriver); /* link in the dummy driver */
- auth_link (&auth_log); /* link in the log authenticator */
- /* lets allow NIL */
-
- REGISTER_MAIN_LONG_CONSTANT("NIL", NIL, CONST_PERSISTENT | CONST_CS);
-
-
- /* Open Options */
-
- REGISTER_MAIN_LONG_CONSTANT("OP_DEBUG", OP_DEBUG, CONST_PERSISTENT | CONST_CS);
- /* debug protocol negotiations */
-
- REGISTER_MAIN_LONG_CONSTANT("OP_READONLY", OP_READONLY, CONST_PERSISTENT | CONST_CS);
- /* read-only open */
-
- REGISTER_MAIN_LONG_CONSTANT("OP_ANONYMOUS", OP_ANONYMOUS, CONST_PERSISTENT | CONST_CS);
- /* anonymous open of newsgroup */
-
- REGISTER_MAIN_LONG_CONSTANT("OP_SHORTCACHE", OP_SHORTCACHE, CONST_PERSISTENT | CONST_CS);
-
- /* short (elt-only) caching */
-
- REGISTER_MAIN_LONG_CONSTANT("OP_SILENT", OP_SILENT, CONST_PERSISTENT | CONST_CS);
- /* don't pass up events (internal use) */
- REGISTER_MAIN_LONG_CONSTANT("OP_PROTOTYPE", OP_PROTOTYPE, CONST_PERSISTENT | CONST_CS);
- /* return driver prototype */
- REGISTER_MAIN_LONG_CONSTANT("OP_HALFOPEN", OP_HALFOPEN, CONST_PERSISTENT | CONST_CS);
- /* half-open (IMAP connect but no select) */
-
- REGISTER_MAIN_LONG_CONSTANT("OP_EXPUNGE", OP_EXPUNGE, CONST_PERSISTENT | CONST_CS);
- /* silently expunge recycle stream */
-
- REGISTER_MAIN_LONG_CONSTANT("OP_SECURE", OP_SECURE, CONST_PERSISTENT | CONST_CS);
- /* don't do non-secure authentication */
-
- /*
- PHP re-assigns CL_EXPUNGE a custom value that can be used as part of the imap_open() bitfield
- because it seems like a good idea to be able to indicate that the mailbox should be
- automatically expunged during imap_open in case the script get interrupted and it doesn't get
- to the imap_close() where this option is normally placed. If the c-client library adds other
- options and the value for this one conflicts, simply make PHP_EXPUNGE higher at the top of
- this file
- */
- REGISTER_MAIN_LONG_CONSTANT("CL_EXPUNGE", PHP_EXPUNGE, CONST_PERSISTENT | CONST_CS);
- /* expunge silently */
-
-
- /* Fetch options */
-
- REGISTER_MAIN_LONG_CONSTANT("FT_UID", FT_UID, CONST_PERSISTENT | CONST_CS);
- /* argument is a UID */
- REGISTER_MAIN_LONG_CONSTANT("FT_PEEK", FT_PEEK, CONST_PERSISTENT | CONST_CS);
- /* peek at data */
- REGISTER_MAIN_LONG_CONSTANT("FT_NOT", FT_NOT, CONST_PERSISTENT | CONST_CS);
- /* NOT flag for header lines fetch */
- REGISTER_MAIN_LONG_CONSTANT("FT_INTERNAL", FT_INTERNAL, CONST_PERSISTENT | CONST_CS);
- /* text can be internal strings */
- REGISTER_MAIN_LONG_CONSTANT("FT_PREFETCHTEXT", FT_PREFETCHTEXT, CONST_PERSISTENT | CONST_CS);
- /* IMAP prefetch text when fetching header */
-
-
- /* Flagging options */
-
- REGISTER_MAIN_LONG_CONSTANT("ST_UID", ST_UID, CONST_PERSISTENT | CONST_CS);
- /* argument is a UID sequence */
- REGISTER_MAIN_LONG_CONSTANT("ST_SILENT", ST_SILENT, CONST_PERSISTENT | CONST_CS);
- /* don't return results */
- REGISTER_MAIN_LONG_CONSTANT("ST_SET", ST_SET, CONST_PERSISTENT | CONST_CS);
- /* set vs. clear */
-
- /* Copy options */
-
- REGISTER_MAIN_LONG_CONSTANT("CP_UID", CP_UID, CONST_PERSISTENT | CONST_CS);
- /* argument is a UID sequence */
- REGISTER_MAIN_LONG_CONSTANT("CP_MOVE", CP_MOVE, CONST_PERSISTENT | CONST_CS);
- /* delete from source after copying */
-
-
- /* Search/sort options */
-
- REGISTER_MAIN_LONG_CONSTANT("SE_UID", SE_UID, CONST_PERSISTENT | CONST_CS);
- /* return UID */
- REGISTER_MAIN_LONG_CONSTANT("SE_FREE", SE_FREE, CONST_PERSISTENT | CONST_CS);
- /* free search program after finished */
- REGISTER_MAIN_LONG_CONSTANT("SE_NOPREFETCH", SE_NOPREFETCH, CONST_PERSISTENT | CONST_CS);
- /* no search prefetching */
- REGISTER_MAIN_LONG_CONSTANT("SO_FREE", SO_FREE, CONST_PERSISTENT | CONST_CS);
- /* free sort program after finished */
- REGISTER_MAIN_LONG_CONSTANT("SO_NOSERVER", SO_NOSERVER, CONST_PERSISTENT | CONST_CS);
- /* don't do server-based sort */
-
- /* Status options */
-
- REGISTER_MAIN_LONG_CONSTANT("SA_MESSAGES",SA_MESSAGES , CONST_PERSISTENT | CONST_CS);
- /* number of messages */
- REGISTER_MAIN_LONG_CONSTANT("SA_RECENT", SA_RECENT, CONST_PERSISTENT | CONST_CS);
- /* number of recent messages */
- REGISTER_MAIN_LONG_CONSTANT("SA_UNSEEN",SA_UNSEEN , CONST_PERSISTENT | CONST_CS);
- /* number of unseen messages */
- REGISTER_MAIN_LONG_CONSTANT("SA_UIDNEXT", SA_UIDNEXT, CONST_PERSISTENT | CONST_CS);
- /* next UID to be assigned */
- REGISTER_MAIN_LONG_CONSTANT("SA_UIDVALIDITY",SA_UIDVALIDITY , CONST_PERSISTENT | CONST_CS);
- /* UID validity value */
-
-
- /* Bits for mm_list() and mm_lsub() */
-
- REGISTER_MAIN_LONG_CONSTANT("LATT_NOINFERIORS",LATT_NOINFERIORS , CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("LATT_NOSELECT", LATT_NOSELECT, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("LATT_MARKED", LATT_MARKED, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("LATT_UNMARKED",LATT_UNMARKED , CONST_PERSISTENT | CONST_CS);
-
-
- /* Sort functions */
-
- REGISTER_MAIN_LONG_CONSTANT("SORTDATE",SORTDATE , CONST_PERSISTENT | CONST_CS);
- /* date */
- REGISTER_MAIN_LONG_CONSTANT("SORTARRIVAL",SORTARRIVAL , CONST_PERSISTENT | CONST_CS);
- /* arrival date */
- REGISTER_MAIN_LONG_CONSTANT("SORTFROM",SORTFROM , CONST_PERSISTENT | CONST_CS);
- /* from */
- REGISTER_MAIN_LONG_CONSTANT("SORTSUBJECT",SORTSUBJECT , CONST_PERSISTENT | CONST_CS);
- /* subject */
- REGISTER_MAIN_LONG_CONSTANT("SORTTO",SORTTO , CONST_PERSISTENT | CONST_CS);
- /* to */
- REGISTER_MAIN_LONG_CONSTANT("SORTCC",SORTCC , CONST_PERSISTENT | CONST_CS);
- /* cc */
- REGISTER_MAIN_LONG_CONSTANT("SORTSIZE",SORTSIZE , CONST_PERSISTENT | CONST_CS);
- /* size */
-
- REGISTER_MAIN_LONG_CONSTANT("TYPETEXT",TYPETEXT , CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("TYPEMULTIPART",TYPEMULTIPART , CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("TYPEMESSAGE",TYPEMESSAGE , CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("TYPEAPPLICATION",TYPEAPPLICATION , CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("TYPEAUDIO",TYPEAUDIO , CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("TYPEIMAGE",TYPEIMAGE , CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("TYPEVIDEO",TYPEVIDEO , CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("TYPEOTHER",TYPEOTHER , CONST_PERSISTENT | CONST_CS);
- /* TYPETEXT unformatted text
- TYPEMULTIPART multiple part
- TYPEMESSAGE encapsulated message
- TYPEAPPLICATION application data
- TYPEAUDIO audio
- TYPEIMAGE static image (GIF, JPEG, etc.)
- TYPEVIDEO video
- TYPEOTHER unknown
- */
- REGISTER_MAIN_LONG_CONSTANT("ENC7BIT",ENC7BIT , CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("ENC8BIT",ENC8BIT , CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("ENCBINARY",ENCBINARY , CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("ENCBASE64",ENCBASE64, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("ENCQUOTEDPRINTABLE",ENCQUOTEDPRINTABLE , CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("ENCOTHER",ENCOTHER , CONST_PERSISTENT | CONST_CS);
- /*
- ENC7BIT 7 bit SMTP semantic data
- ENC8BIT 8 bit SMTP semantic data
- ENCBINARY 8 bit binary data
- ENCBASE64 base-64 encoded data
- ENCQUOTEDPRINTABLE human-readable 8-as-7 bit data
- ENCOTHER unknown
- */
-
- le_imap = register_list_destructors(mail_close_it,NULL);
- return SUCCESS;
-}
-
-/* {{{ proto int imap_open(string mailbox, string user, string password [, int options])
- Open an IMAP stream to a mailbox */
-PHP_FUNCTION(imap_open)
-{
- pval *mailbox;
- pval *user;
- pval *passwd;
- pval *options;
- MAILSTREAM *imap_stream;
- pils *imap_le_struct;
- long flags=NIL;
- long cl_flags=NIL;
-
- int ind;
- int myargc=ARG_COUNT(ht);
-
- if (myargc <3 || myargc >4 || getParameters(ht, myargc, &mailbox,&user,&passwd,&options) == FAILURE) {
- WRONG_PARAM_COUNT;
- } else {
- convert_to_string(mailbox);
- convert_to_string(user);
- convert_to_string(passwd);
- if(myargc ==4) {
- convert_to_long(options);
- flags = options->value.lval;
- if(flags & PHP_EXPUNGE) {
- cl_flags = CL_EXPUNGE;
- flags ^= PHP_EXPUNGE;
- }
- }
- strcpy(imap_user,user->value.str.val);
- strcpy(imap_password,passwd->value.str.val);
- imap_stream = NIL;
- imap_stream = mail_open(imap_stream,mailbox->value.str.val,flags);
-
- if (imap_stream == NIL){
- php_error(E_WARNING,"Couldn't open stream %s\n",mailbox->value.str.val);
- RETURN_FALSE;
- }
- /* Note that if we ever come up with a persistent imap stream, the persistent version of this
- struct needs to be malloc'ed and not emalloc'ed */
- imap_le_struct = emalloc(sizeof(pils));
- imap_le_struct->imap_stream = imap_stream;
- imap_le_struct->flags = cl_flags;
- ind = php3_list_insert(imap_le_struct, le_imap);
-
- RETURN_LONG(ind);
- }
- return;
-}
-/* }}} */
-
-/* {{{ proto int imap_reopen(int stream_id, string mailbox [, int options])
- Reopen IMAP stream to new mailbox */
-PHP_FUNCTION(imap_reopen)
-{
- pval *streamind;
- pval *mailbox;
- pval *options;
- MAILSTREAM *imap_stream;
- pils *imap_le_struct;
- int ind, ind_type;
- long flags=NIL;
- long cl_flags=NIL;
- int myargc=ARG_COUNT(ht);
-
- if (myargc<2 || myargc>3 || getParameters(ht,myargc,&streamind, &mailbox, &options) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- ind = streamind->value.lval;
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- convert_to_string(mailbox);
- if(myargc == 3) {
- convert_to_long(options);
- flags = options->value.lval;
- if(flags & PHP_EXPUNGE) {
- cl_flags = CL_EXPUNGE;
- flags ^= PHP_EXPUNGE;
- }
- imap_le_struct->flags = cl_flags;
- }
- imap_stream = mail_open(imap_le_struct->imap_stream, mailbox->value.str.val, flags);
- if (imap_stream == NIL) {
- php_error(E_WARNING,"Couldn't re-open stream\n");
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int imap_append(int stream_id, string folder, string message [, string flags])
- Append a string message to a specified mailbox */
-PHP_FUNCTION(imap_append)
-{
- pval *streamind,*folder, *message,*flags;
- int ind, ind_type;
- pils *imap_le_struct;
- STRING st;
- int myargc=ARG_COUNT(ht);
-
- if ( myargc < 3 || myargc > 4 || getParameters( ht, myargc, &streamind, &folder, &message,&flags) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(folder);
- convert_to_string(message);
- if (myargc == 4) convert_to_string(flags);
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find( ind, &ind_type );
-
- if ( !imap_le_struct || ind_type != le_imap ) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- INIT (&st,mail_string,(void *) message->value.str.val,message->value.str.len);
- if(mail_append_full(imap_le_struct->imap_stream, folder->value.str.val,myargc==4?flags->value.str.val:NIL,NIL,&st)) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto imap_num_msg(int stream_id)
- Gives the number of messages in the current mailbox */
-PHP_FUNCTION(imap_num_msg)
-{
- pval *streamind;
- int ind, ind_type;
- pils *imap_le_struct;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &streamind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- RETURN_LONG(imap_le_struct->imap_stream->nmsgs);
-}
-/* }}} */
-
-/* {{{ proto int imap_ping(int stream_id)
- Check if the IMAP stream is still active */
-PHP_FUNCTION(imap_ping)
-{
- pval *streamind;
- int ind, ind_type;
- pils *imap_le_struct;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &streamind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long( streamind );
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find( ind, &ind_type );
- if ( !imap_le_struct || ind_type != le_imap ) {
- php_error( E_WARNING, "Unable to find stream pointer" );
- RETURN_FALSE;
- }
- RETURN_LONG( mail_ping( imap_le_struct->imap_stream ) );
-}
-/* }}} */
-
-/* {{{ proto int imap_num_recent(int stream_id)
- Gives the number of recent messages in current mailbox */
-PHP_FUNCTION(imap_num_recent)
-{
- pval *streamind;
- int ind, ind_type;
- pils *imap_le_struct;
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &streamind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(streamind);
- ind = streamind->value.lval;
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- RETURN_LONG(imap_le_struct->imap_stream->recent);
-}
-/* }}} */
-
-/* {{{ proto int imap_expunge(int stream_id)
- Delete all messages marked for deletion */
-PHP_FUNCTION(imap_expunge)
-{
- pval *streamind;
- int ind, ind_type;
- pils *imap_le_struct;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &streamind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- mail_expunge (imap_le_struct->imap_stream);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int imap_close(int stream_id [, int options])
- Close an IMAP stream */
-PHP_FUNCTION(imap_close)
-{
- pval *options, *streamind;
- int ind, ind_type;
- pils *imap_le_struct=NULL;
- int myargcount=ARG_COUNT(ht);
- long flags = NIL;
-
- if (myargcount < 1 || myargcount > 2 || getParameters(ht, myargcount, &streamind, &options) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(streamind);
- ind = streamind->value.lval;
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- if(myargcount==2) {
- convert_to_long(options);
- flags = options->value.lval;
- /* Do the translation from PHP's internal PHP_EXPUNGE define to c-client's CL_EXPUNGE */
- if(flags & PHP_EXPUNGE) {
- flags ^= PHP_EXPUNGE;
- flags |= CL_EXPUNGE;
- }
- imap_le_struct->flags = flags;
- }
- php3_list_delete(ind);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto array imap_headers(int stream_id)
- Returns headers for all messages in a mailbox */
-PHP_FUNCTION(imap_headers)
-{
- pval *streamind;
- int ind, ind_type;
- unsigned long i;
- char *t;
- unsigned int msgno;
- pils *imap_le_struct;
- char tmp[MAILTMPLEN];
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &streamind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- /* Initialize return array */
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
-
- for (msgno = 1; msgno <= imap_le_struct->imap_stream->nmsgs; msgno++) {
- MESSAGECACHE * cache = mail_elt (imap_le_struct->imap_stream,msgno);
- mail_fetchstructure (imap_le_struct->imap_stream,msgno,NIL);
- tmp[0] = cache->recent ? (cache->seen ? 'R': 'N') : ' ';
- tmp[1] = (cache->recent | cache->seen) ? ' ' : 'U';
- tmp[2] = cache->flagged ? 'F' : ' ';
- tmp[3] = cache->answered ? 'A' : ' ';
- tmp[4] = cache->deleted ? 'D' : ' ';
- sprintf (tmp+5,"%4ld) ",cache->msgno);
- mail_date (tmp+11,cache);
- tmp[17] = ' ';
- tmp[18] = '\0';
- mail_fetchfrom (tmp+18,imap_le_struct->imap_stream,msgno,(long) 20);
- strcat (tmp," ");
- if ((i = cache->user_flags)) {
- strcat (tmp,"{");
- while (i) {
- strcat (tmp,imap_le_struct->imap_stream->user_flags[find_rightmost_bit (&i)]);
- if (i) strcat (tmp," ");
- }
- strcat (tmp,"} ");
- }
- mail_fetchsubject(t=tmp+strlen(tmp),imap_le_struct->imap_stream,msgno,(long)25);
- sprintf (t+=strlen(t)," (%ld chars)",cache->rfc822_size);
- add_next_index_string(return_value,tmp,1);
- }
-}
-/* }}} */
-
-/* {{{ proto imap_body(int stream_id, int msg_no [, int options])
- Read the message body */
-PHP_FUNCTION(imap_body)
-{
- pval *streamind, * msgno, *flags;
- int ind, ind_type;
- pils *imap_le_struct;
- int myargc=ARG_COUNT(ht);
- if (myargc <2 || myargc > 3 || getParameters(ht,myargc,&streamind,&msgno,&flags) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(msgno);
- if(myargc == 3) convert_to_long(flags);
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- RETVAL_STRING(mail_fetchtext_full (imap_le_struct->imap_stream,msgno->value.lval,NIL,myargc == 3 ? flags->value.lval : NIL),1);
-}
-/* }}} */
-
-/* v--- add proto here when this function is done */
-/* {{{ string imap_fetchtext_full(int stream_id, int msg_no [, int options])
- Read the body of a message*/
-PHP_FUNCTION(imap_fetchtext_full)
-{
- pval *streamind, * msgno, *flags;
- int ind, ind_type;
- pils *imap_le_struct;
- int myargcount = ARG_COUNT(ht);
- if (myargcount >3 || myargcount <2 || getParameters(ht,myargcount,&streamind,&msgno,&flags) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(msgno);
- if (myargcount == 3) convert_to_long(flags);
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- RETVAL_STRING(mail_fetchtext_full (imap_le_struct->imap_stream,msgno->value.lval,NIL,myargcount==3?flags->value.lval:NIL),1);
-}
-/* }}} */
-
-/* {{{ proto int imap_mail_copy(int stream_id, int msg_no, string mailbox [, int options])
- Copy specified message to a mailbox */
-PHP_FUNCTION(imap_mail_copy)
-{
- pval *streamind,*seq, *folder, *options;
- int ind, ind_type;
- pils *imap_le_struct;
- int myargcount = ARG_COUNT(ht);
- if (myargcount > 4 || myargcount < 3
- || getParameters(ht,myargcount,&streamind,&seq,&folder,&options) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(seq);
- convert_to_string(folder);
- if(myargcount == 4) convert_to_long(options);
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- if ( mail_copy_full(imap_le_struct->imap_stream,seq->value.str.val,folder->value.str.val,myargcount == 4 ? options->value.lval : NIL)==T ) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto imap_mail_move(int stream_id, int msg_no, string mailbox)
- Move specified message to a mailbox */
-PHP_FUNCTION(imap_mail_move)
-{
- pval *streamind,*seq, *folder;
- int ind, ind_type;
- pils *imap_le_struct;
-
- if (ARG_COUNT(ht)!=3
- || getParameters(ht,3,&streamind,&seq,&folder) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(seq);
- convert_to_string(folder);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- if ( mail_move(imap_le_struct->imap_stream,seq->value.str.val,folder->value.str.val)==T ) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int imap_createmailbox(int stream_id, string mailbox)
- Create a new mailbox */
-PHP_FUNCTION(imap_createmailbox)
-{
- pval *streamind, *folder;
- int ind, ind_type;
- pils *imap_le_struct;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht,2,&streamind,&folder) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(folder);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- if ( mail_create(imap_le_struct->imap_stream,folder->value.str.val)==T ) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int imap_renamemailbox(int stream_id, string old_name, string new_name)
- Rename a mailbox */
-PHP_FUNCTION(imap_renamemailbox)
-{
- pval *streamind, *old, *new;
- int ind, ind_type;
- pils *imap_le_struct;
-
- if (ARG_COUNT(ht)!=3 || getParameters(ht,3,&streamind,&old,&new)==FAILURE){
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(old);
- convert_to_string(new);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- if ( mail_rename(imap_le_struct->imap_stream,old->value.str.val,new->value.str.val)==T ) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto imap_deletemailbox(int stream_id, string mailbox)
- Delete a mailbox */
-PHP_FUNCTION(imap_deletemailbox)
-{
- pval *streamind, *folder;
- int ind, ind_type;
- pils *imap_le_struct;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht,2,&streamind,&folder) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(folder);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- if ( mail_delete(imap_le_struct->imap_stream,folder->value.str.val)==T ) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto array imap_list(int stream_id, string ref, string pattern)
- Read the list of mailboxes */
-PHP_FUNCTION(imap_list)
-{
- pval *streamind, *ref, *pat;
- int ind, ind_type;
- pils *imap_le_struct;
- STRINGLIST *cur=NIL;
-
- if (ARG_COUNT(ht)!=3
- || getParameters(ht,3,&streamind,&ref,&pat) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(ref);
- convert_to_string(pat);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- imap_folders = NIL;
- mail_list(imap_le_struct->imap_stream,ref->value.str.val,pat->value.str.val);
- if (imap_folders == NIL) {
- RETURN_FALSE;
- }
- array_init(return_value);
- cur=imap_folders;
- while (cur != NIL ) {
- add_next_index_string(return_value,cur->LTEXT,1);
- cur=cur->next;
- }
- mail_free_stringlist (&imap_folders);
-}
-/* }}} */
-
-/* {{{ proto imap_scan(int stream_id, string ref, string pattern, string content)
- Read list of mailboxes containing a certain string */
-PHP_FUNCTION(imap_listscan)
-{
- pval *streamind, *ref, *pat, *content;
- int ind, ind_type;
- pils *imap_le_struct;
- STRINGLIST *cur=NIL;
-
- if (ARG_COUNT(ht)!=4 || getParameters(ht,4,&streamind,&ref,&pat,&content) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(ref);
- convert_to_string(pat);
- convert_to_string(content);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- imap_folders = NIL;
- mail_scan(imap_le_struct->imap_stream,ref->value.str.val,pat->value.str.val,content->value.str.val);
- if (imap_folders == NIL) {
- RETURN_FALSE;
- }
- array_init(return_value);
- cur=imap_folders;
- while (cur != NIL ) {
- add_next_index_string(return_value,cur->LTEXT,1);
- cur=cur->next;
- }
- mail_free_stringlist (&imap_folders);
-}
-/* }}} */
-
-/* {{{ proto object imap_check(int stream_id)
- Get mailbox properties */
-PHP_FUNCTION(imap_check)
-{
- pval *streamind;
- int ind, ind_type;
- pils *imap_le_struct;
- char date[50];
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht,1,&streamind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- if (mail_ping (imap_le_struct->imap_stream) == NIL ) {
- RETURN_FALSE;
- }
- if (imap_le_struct->imap_stream && imap_le_struct->imap_stream->mailbox) {
- rfc822_date (date);
- object_init(return_value);
- add_property_string(return_value,"Date",date,1);
- add_property_string(return_value,"Driver",imap_le_struct->imap_stream->dtb->name,1);
- add_property_string(return_value,"Mailbox",imap_le_struct->imap_stream->mailbox,1);
- add_property_long(return_value,"Nmsgs",imap_le_struct->imap_stream->nmsgs);
- add_property_long(return_value,"Recent",imap_le_struct->imap_stream->recent);
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int imap_delete(int stream_id, int msg_no)
- Mark a message for deletion */
-PHP_FUNCTION(imap_delete)
-{
- pval *streamind, * msgno;
- int ind, ind_type;
- pils *imap_le_struct;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht,2,&streamind,&msgno) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(msgno);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- mail_setflag(imap_le_struct->imap_stream,msgno->value.str.val,"\\DELETED");
- RETVAL_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int imap_undelete(int stream_id, int msg_no)
- Remove the delete flag from a message */
-PHP_FUNCTION(imap_undelete)
-{
- pval *streamind, * msgno;
- int ind, ind_type;
- pils *imap_le_struct;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht,2,&streamind,&msgno) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(msgno);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- mail_clearflag (imap_le_struct->imap_stream,msgno->value.str.val,"\\DELETED");
- RETVAL_TRUE;
-}
-/* }}} */
-
-/* {{{ proto object imap_header(int stream_id, int msg_no [, int from_length [, int subject_length [, string default_host]]])
- Read the header of the message */
-PHP_FUNCTION(imap_headerinfo)
-{
- pval *streamind, *msgno, *to, *tovals, *from, *fromvals, *reply_to, *reply_tovals, *sender;
- pval *fromlength;
- pval *subjectlength;
- pval *sendervals, *return_path, *return_pathvals;
- pval *cc, *ccvals, *bcc, *bccvals;
- pval *defaulthost;
- int ind, ind_type;
- unsigned long length;
- pils *imap_le_struct;
- MESSAGECACHE * cache;
- char *mystring;
- char dummy[2000];
- char fulladdress[MAILTMPLEN],tempaddress[MAILTMPLEN];
- ENVELOPE *en;
- ADDRESS *addresstmp,*addresstmp2;
- int myargc;
-
- myargc=ARG_COUNT(ht);
- if (myargc<2 || myargc>5 || getParameters(ht,myargc,&streamind,&msgno,&fromlength,&subjectlength,&defaulthost)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(streamind);
- convert_to_long(msgno);
- if(myargc >= 3) convert_to_long(fromlength); else fromlength=0x00;;
- if(myargc >= 4) convert_to_long(subjectlength); else subjectlength=0x00;
- if(myargc == 5) convert_to_string(defaulthost);
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- if(msgno->value.lval && msgno->value.lval <= imap_le_struct->imap_stream->nmsgs && mail_fetchstructure (imap_le_struct->imap_stream,msgno->value.lval,NIL))
- cache = mail_elt (imap_le_struct->imap_stream,msgno->value.lval);
- else
- RETURN_FALSE;
- object_init(return_value);
-
-
- mystring=mail_fetchheader_full(imap_le_struct->imap_stream,msgno->value.lval,NIL,&length,NIL);
- if(myargc ==5)
- rfc822_parse_msg (&en,NULL,mystring,length,NULL,defaulthost->value.str.val,NIL);
- else
- rfc822_parse_msg (&en,NULL,mystring,length,NULL,"UNKNOWN",NIL);
-
- if (en->remail) add_property_string(return_value,"remail",en->remail,1);
- if (en->date) add_property_string(return_value,"date",en->date,1);
- if (en->date) add_property_string(return_value,"Date",en->date,1);
- if (en->subject)add_property_string(return_value,"subject",en->subject,1);
- if (en->subject)add_property_string(return_value,"Subject",en->subject,1);
- if (en->in_reply_to)add_property_string(return_value,"in_reply_to",en->in_reply_to,1);
- if (en->message_id)add_property_string(return_value,"message_id",en->message_id,1);
- if (en->newsgroups)add_property_string(return_value,"newsgroups",en->newsgroups,1);
- if (en->followup_to)add_property_string(return_value,"followup_to",en->followup_to,1);
- if (en->references)add_property_string(return_value,"references",en->references,1);
-
- if(en->to) {
- int ok=1;
- addresstmp=en->to;
- fulladdress[0]=0x00;
-
- while(ok && addresstmp) { /* while length < 1000 and we are not at the end of the list */
- addresstmp2=addresstmp->next; /* save the pointer to the next address */
- addresstmp->next=NULL; /* make this address the only one now. */
- tempaddress[0]=0x00; /* reset tempaddress buffer */
- rfc822_write_address(tempaddress,addresstmp); /* ok, write the address into tempaddress string */
- if((strlen(tempaddress) + strlen(fulladdress)) < 1000) { /* is the new address + total address < 1000 */
- if(strlen(fulladdress)) strcat(fulladdress,","); /* put in a comma */
- strcat(fulladdress,tempaddress); /* put in the new address */
- } else { /* no */
- ok=0; /* stop looping */
- strcat(fulladdress,", ...");
- }
- addresstmp=addresstmp2; /* reset the pointer to the next address first! */
- }
-
- if(fulladdress) add_property_string( return_value, "toaddress", fulladdress, 1);
- addresstmp=en->to;
- MAKE_STD_ZVAL(to);
- array_init(to);
- do {
- MAKE_STD_ZVAL(tovals);
- object_init(tovals);
- if(addresstmp->personal) add_property_string(tovals, "personal", addresstmp->personal, 1);
- if(addresstmp->adl) add_property_string(tovals, "adl", addresstmp->adl, 1);
- if(addresstmp->mailbox) add_property_string(tovals, "mailbox", addresstmp->mailbox, 1);
- if(addresstmp->host) add_property_string(tovals, "host", addresstmp->host, 1);
- add_next_index_object(to, tovals);
- } while ( (addresstmp = addresstmp->next) );
- add_assoc_object(return_value, "to", to);
- }
-
- if(en->from) {
- int ok=1;
- addresstmp=en->from;
- fulladdress[0]=0x00;
-
- while(ok && addresstmp) { /* while length < 1000 and we are not at the end of the list */
- addresstmp2=addresstmp->next; /* save the pointer to the next address */
- addresstmp->next=NULL; /* make this address the only one now. */
- tempaddress[0]=0x00; /* reset tempaddress buffer */
- rfc822_write_address(tempaddress,addresstmp); /* ok, write the address into tempaddress string */
- if((strlen(tempaddress) + strlen(fulladdress)) < 1000) { /* is the new address + total address < 1000 */
- if(strlen(fulladdress)) strcat(fulladdress,","); /* put in a comma */
- strcat(fulladdress,tempaddress); /* put in the new address */
- } else { /* no */
- ok=0; /* stop looping */
- strcat(fulladdress,", ...");
- }
- addresstmp=addresstmp2; /* reset the pointer to the next address first! */
- }
-
- if(fulladdress) add_property_string( return_value, "fromaddress", fulladdress, 1);
- addresstmp=en->from;
- MAKE_STD_ZVAL(from);
- array_init(from);
- do {
- MAKE_STD_ZVAL(fromvals);
- object_init(fromvals);
- if(addresstmp->personal) add_property_string(fromvals, "personal", addresstmp->personal, 1);
- if(addresstmp->adl) add_property_string(fromvals, "adl", addresstmp->adl, 1);
- if(addresstmp->mailbox) add_property_string(fromvals, "mailbox", addresstmp->mailbox, 1);
- if(addresstmp->host) add_property_string(fromvals, "host", addresstmp->host, 1);
- add_next_index_object(from, fromvals);
- } while ( (addresstmp = addresstmp->next) );
- add_assoc_object( return_value, "from", from );
- }
-
- if(en->cc) {
- int ok=1;
- addresstmp=en->cc;
- fulladdress[0]=0x00;
-
- while(ok && addresstmp) { /* while length < 1000 and we are not at the end of the list */
- addresstmp2=addresstmp->next; /* save the pointer to the next address */
- addresstmp->next=NULL; /* make this address the only one now. */
- tempaddress[0]=0x00; /* reset tempaddress buffer */
- rfc822_write_address(tempaddress,addresstmp); /* ok, write the address into tempaddress string */
- if((strlen(tempaddress) + strlen(fulladdress)) < 1000) { /* is the new address + total address < 1000 */
- if(strlen(fulladdress)) strcat(fulladdress,","); /* put in a comma */
- strcat(fulladdress,tempaddress); /* put in the new address */
- } else { /* no */
- ok=0; /* stop looping */
- strcat(fulladdress,", ...");
- }
- addresstmp=addresstmp2; /* reset the pointer to the next address first! */
- }
-
- if(fulladdress) add_property_string( return_value, "ccaddress", fulladdress, 1);
- addresstmp=en->cc;
- MAKE_STD_ZVAL(cc);
- array_init(cc);
- do {
- MAKE_STD_ZVAL(ccvals);
- object_init(ccvals);
- if(addresstmp->personal) add_property_string(ccvals, "personal", addresstmp->personal, 1);
- if(addresstmp->adl) add_property_string(ccvals, "adl", addresstmp->adl, 1);
- if(addresstmp->mailbox) add_property_string(ccvals, "mailbox", addresstmp->mailbox, 1);
- if(addresstmp->host) add_property_string(ccvals, "host", addresstmp->host, 1);
- add_next_index_object(cc, ccvals);
- } while ( (addresstmp = addresstmp->next) );
- add_assoc_object(return_value, "cc", cc);
- }
-
- if(en->bcc) {
- int ok=1;
- addresstmp=en->bcc;
- fulladdress[0]=0x00;
- while(ok && addresstmp) { /* while length < 1000 and we are not at the end of the list */
- addresstmp2=addresstmp->next; /* save the pointer to the next address */
- addresstmp->next=NULL; /* make this address the only one now. */
- tempaddress[0]=0x00; /* reset tempaddress buffer */
- rfc822_write_address(tempaddress,addresstmp); /* ok, write the address into tempaddress string */
- if((strlen(tempaddress) + strlen(fulladdress)) < 1000) { /* is the new address + total address < 1000 */
- if(strlen(fulladdress)) strcat(fulladdress,","); /* put in a comma */
- strcat(fulladdress,tempaddress); /* put in the new address */
- } else { /* no */
- ok=0; /* stop looping */
- strcat(fulladdress,", ...");
- }
- addresstmp=addresstmp2; /* reset the pointer to the next address first! */
- }
-
- if(fulladdress) add_property_string( return_value, "bccaddress", fulladdress, 1);
- addresstmp=en->bcc;
- MAKE_STD_ZVAL(bcc);
- array_init(bcc);
- do {
- MAKE_STD_ZVAL(bccvals);
- object_init(bccvals);
- if(addresstmp->personal) add_property_string(bccvals, "personal", addresstmp->personal, 1);
- if(addresstmp->adl) add_property_string(bccvals, "adl", addresstmp->adl, 1);
- if(addresstmp->mailbox) add_property_string(bccvals, "mailbox", addresstmp->mailbox, 1);
- if(addresstmp->host) add_property_string(bccvals, "host", addresstmp->host, 1);
- add_next_index_object(bcc, bccvals);
- } while ( (addresstmp = addresstmp->next) );
- add_assoc_object( return_value, "bcc", bcc );
- }
-
- if(en->reply_to) {
- int ok=1;
- addresstmp=en->reply_to;
- fulladdress[0]=0x00;
- while(ok && addresstmp) { /* while length < 1000 and we are not at the end of the list */
- addresstmp2=addresstmp->next; /* save the pointer to the next address */
- addresstmp->next=NULL; /* make this address the only one now. */
- tempaddress[0]=0x00; /* reset tempaddress buffer */
- rfc822_write_address(tempaddress,addresstmp); /* ok, write the address into tempaddress string */
- if((strlen(tempaddress) + strlen(fulladdress)) < 1000) { /* is the new address + total address < 1000 */
- if(strlen(fulladdress)) strcat(fulladdress,","); /* put in a comma */
- strcat(fulladdress,tempaddress); /* put in the new address */
- } else { /* no */
- ok=0; /* stop looping */
- strcat(fulladdress,", ...");
- }
- addresstmp=addresstmp2; /* reset the pointer to the next address first! */
- }
-
- if(fulladdress) add_property_string( return_value, "reply_toaddress", fulladdress, 1);
- addresstmp=en->reply_to;
- MAKE_STD_ZVAL(reply_to);
- array_init(reply_to);
- do {
- MAKE_STD_ZVAL(reply_tovals);
- object_init(reply_tovals);
- if(addresstmp->personal) add_property_string(reply_tovals, "personal", addresstmp->personal, 1);
- if(addresstmp->adl) add_property_string(reply_tovals, "adl", addresstmp->adl, 1);
- if(addresstmp->mailbox) add_property_string(reply_tovals, "mailbox", addresstmp->mailbox, 1);
- if(addresstmp->host) add_property_string(reply_tovals, "host", addresstmp->host, 1);
- add_next_index_object(reply_to, reply_tovals );
- } while ( (addresstmp = addresstmp->next) );
- add_assoc_object( return_value, "reply_to", reply_to );
- }
-
- if(en->sender) {
- int ok=1;
- addresstmp=en->sender;
- fulladdress[0]=0x00;
- while(ok && addresstmp) { /* while length < 1000 and we are not at the end of the list */
- addresstmp2=addresstmp->next; /* save the pointer to the next address */
- addresstmp->next=NULL; /* make this address the only one now. */
- tempaddress[0]=0x00; /* reset tempaddress buffer */
- rfc822_write_address(tempaddress,addresstmp); /* ok, write the address into tempaddress string */
- if((strlen(tempaddress) + strlen(fulladdress)) < 1000) { /* is the new address + total address < 1000 */
- if(strlen(fulladdress)) strcat(fulladdress,","); /* put in a comma */
- strcat(fulladdress,tempaddress); /* put in the new address */
- } else { /* no */
- ok=0; /* stop looping */
- strcat(fulladdress,", ...");
- }
- addresstmp=addresstmp2; /* reset the pointer to the next address first! */
- }
-
- if(fulladdress) add_property_string( return_value, "senderaddress", fulladdress, 1);
- addresstmp=en->sender;
- MAKE_STD_ZVAL(sender);
- array_init(sender);
- do {
- MAKE_STD_ZVAL(sendervals);
- object_init(sendervals);
- if(addresstmp->personal) add_property_string(sendervals, "personal", addresstmp->personal, 1);
- if(addresstmp->adl) add_property_string(sendervals, "adl", addresstmp->adl, 1);
- if(addresstmp->mailbox) add_property_string(sendervals, "mailbox", addresstmp->mailbox, 1);
- if(addresstmp->host) add_property_string(sendervals, "host", addresstmp->host, 1);
- add_next_index_object(sender, sendervals );
- } while ( (addresstmp = addresstmp->next) );
- add_assoc_object( return_value, "sender", sender );
- }
-
- if(en->return_path) {
- int ok=1;
- addresstmp=en->return_path;
- fulladdress[0]=0x00;
- while(ok && addresstmp) { /* while length < 1000 and we are not at the end of the list */
- addresstmp2=addresstmp->next; /* save the pointer to the next address */
- addresstmp->next=NULL; /* make this address the only one now. */
- tempaddress[0]=0x00; /* reset tempaddress buffer */
- rfc822_write_address(tempaddress,addresstmp); /* ok, write the address into tempaddress string */
- if((strlen(tempaddress) + strlen(fulladdress)) < 1000) { /* is the new address + total address < 1000 */
- if(strlen(fulladdress)) strcat(fulladdress,","); /* put in a comma */
- strcat(fulladdress,tempaddress); /* put in the new address */
- } else { /* no */
- ok=0; /* stop looping */
- strcat(fulladdress,", ...");
- }
- addresstmp=addresstmp2; /* reset the pointer to the next address first! */
- }
-
- if(fulladdress) add_property_string( return_value, "return_pathaddress", fulladdress, 1);
- addresstmp=en->return_path;
- MAKE_STD_ZVAL(return_path);
- array_init(return_path);
- do {
- MAKE_STD_ZVAL(return_pathvals);
- object_init(return_pathvals);
- if(addresstmp->personal) add_property_string(return_pathvals, "personal", addresstmp->personal, 1);
- if(addresstmp->adl) add_property_string(return_pathvals, "adl", addresstmp->adl, 1);
- if(addresstmp->mailbox) add_property_string(return_pathvals, "mailbox", addresstmp->mailbox, 1);
- if(addresstmp->host) add_property_string(return_pathvals, "host", addresstmp->host, 1);
- add_next_index_object(return_path, return_pathvals );
- } while ( (addresstmp = addresstmp->next) );
- add_assoc_object( return_value, "return_path", return_path );
- }
- add_property_string(return_value,"Recent",cache->recent ? (cache->seen ? "R": "N") : " ",1);
- add_property_string(return_value,"Unseen",(cache->recent | cache->seen) ? " " : "U",1);
- add_property_string(return_value,"Flagged",cache->flagged ? "F" : " ",1);
- add_property_string(return_value,"Answered",cache->answered ? "A" : " ",1);
- add_property_string(return_value,"Deleted",cache->deleted ? "D" : " ",1);
- sprintf (dummy,"%4ld",cache->msgno);
- add_property_string(return_value,"Msgno",dummy,1);
- mail_date (dummy,cache);
- add_property_string(return_value,"MailDate",dummy,1);
- sprintf (dummy,"%ld",cache->rfc822_size);
- add_property_string(return_value,"Size",dummy,1);
- add_property_long(return_value,"udate",mail_longdate(cache));
-
- if(en->from && fromlength) {
- fulladdress[0]=0x00;
- mail_fetchfrom(fulladdress,imap_le_struct->imap_stream,msgno->value.lval,fromlength->value.lval);
- add_property_string(return_value,"fetchfrom",fulladdress,1);
- }
- if(en->subject && subjectlength) {
- fulladdress[0]=0x00;
- mail_fetchsubject(fulladdress,imap_le_struct->imap_stream,msgno->value.lval,subjectlength->value.lval);
- add_property_string(return_value,"fetchsubject",fulladdress,1);
- }
-}
-/* }}} */
-
-
-/* KMLANG */
-/* {{{ proto array imap_lsub(int stream_id, string ref, string pattern)
- Return a list of subscribed mailboxes */
-PHP_FUNCTION(imap_lsub)
-{
- pval *streamind, *ref, *pat;
- int ind, ind_type;
- pils *imap_le_struct;
- STRINGLIST *cur=NIL;
-
- if (ARG_COUNT(ht)!=3 || getParameters(ht,3,&streamind,&ref,&pat) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(ref);
- convert_to_string(pat);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- imap_sfolders = NIL;
- mail_lsub(imap_le_struct->imap_stream,ref->value.str.val,pat->value.str.val);
- if (imap_sfolders == NIL) {
- RETURN_FALSE;
- }
- array_init(return_value);
- cur=imap_sfolders;
- while (cur != NIL ) {
- add_next_index_string(return_value,cur->LTEXT,1);
- cur=cur->next;
- }
- mail_free_stringlist (&imap_sfolders);
-}
-/* }}} */
-
-/* {{{ proto int imap_subscribe(int stream_id, string mailbox)
- Subscribe to a mailbox */
-PHP_FUNCTION(imap_subscribe)
-{
- pval *streamind, *folder;
- int ind, ind_type;
- pils *imap_le_struct;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht,2,&streamind,&folder) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(folder);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- if ( mail_subscribe(imap_le_struct->imap_stream,folder->value.str.val)==T ) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int imap_unsubscribe(int stream_id, string mailbox)
- Unsubscribe from a mailbox */
-PHP_FUNCTION(imap_unsubscribe)
-{
- pval *streamind, *folder;
- int ind, ind_type;
- pils *imap_le_struct;
- int myargc=ARG_COUNT(ht);
- if (myargc !=2 || getParameters(ht,myargc,&streamind,&folder) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(folder);
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- if ( mail_unsubscribe(imap_le_struct->imap_stream,folder->value.str.val)==T ) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-void imap_add_body( pval *arg, BODY *body )
-{
- pval *parametres, *param, *dparametres, *dparam;
- PARAMETER *par, *dpar;
- PART *part;
-
- if(body->type) add_property_long( arg, "type", body->type );
- if(body->encoding) add_property_long( arg, "encoding", body->encoding );
-
- if ( body->subtype ){
- add_property_long( arg, "ifsubtype", 1 );
- add_property_string( arg, "subtype", body->subtype, 1 );
- } else {
- add_property_long( arg, "ifsubtype", 0 );
- }
-
- if ( body->description ){
- add_property_long( arg, "ifdescription", 1 );
- add_property_string( arg, "description", body->description, 1 );
- } else {
- add_property_long( arg, "ifdescription", 0 );
- }
- if ( body->id ){
- add_property_long( arg, "ifid", 1 );
- if(body->description) add_property_string( arg, "id", body->description, 1 );
- } else {
- add_property_long( arg, "ifid", 0 );
- }
-
- if(body->size.lines) add_property_long( arg, "lines", body->size.lines );
- if(body->size.bytes) add_property_long( arg, "bytes", body->size.bytes );
-#ifdef IMAP41
- if ( body->disposition.type ){
- add_property_long( arg, "ifdisposition", 1);
- add_property_string( arg, "disposition", body->disposition.type, 1);
- } else {
- add_property_long( arg, "ifdisposition", 0);
- }
-
- if ( body->disposition.parameter ) {
- dpar = body->disposition.parameter;
- add_property_long( arg, "ifdparameters", 1);
- MAKE_STD_ZVAL(dparametres);
- array_init(dparametres);
- do {
- MAKE_STD_ZVAL(dparam);
- object_init(dparam);
- add_property_string(dparam, "attribute", dpar->attribute, 1);
- add_property_string(dparam, "value", dpar->value, 1);
- add_next_index_object(dparametres, dparam );
- } while ( (dpar = dpar->next) );
- add_assoc_object( arg, "dparameters", dparametres );
- } else {
- add_property_long( arg, "ifdparameters", 0);
- }
-#endif
-
- if ( (par = body->parameter) ) {
- add_property_long( arg, "ifparameters", 1 );
-
- MAKE_STD_ZVAL(parametres);
- array_init(parametres);
- do {
- MAKE_STD_ZVAL(param);
- object_init(param);
- if(par->attribute) add_property_string(param, "attribute", par->attribute, 1 );
- if(par->value) add_property_string(param, "value", par->value, 1 );
-
- add_next_index_object(parametres, param);
- } while ( (par = par->next) );
- } else {
- MAKE_STD_ZVAL(parametres);
- object_init(parametres);
- add_property_long( arg, "ifparameters", 0 );
- }
- add_assoc_object( arg, "parameters", parametres );
-
- /* multipart message ? */
-
- if ( body->type == TYPEMULTIPART ) {
- MAKE_STD_ZVAL(parametres);
- array_init(parametres);
- for ( part = body->CONTENT_PART; part; part = part->next ) {
- MAKE_STD_ZVAL(param);
- object_init(param);
- imap_add_body(param, &part->body );
- add_next_index_object(parametres, param );
- }
- add_assoc_object( arg, "parts", parametres );
- }
-
- /* encapsulated message ? */
-
- if ((body->type == TYPEMESSAGE) && (!strcasecmp(body->subtype, "rfc822"))) {
- body=body->CONTENT_MSG_BODY;
- MAKE_STD_ZVAL(parametres);
- array_init(parametres);
- MAKE_STD_ZVAL(param);
- object_init(param);
- imap_add_body(param, body);
- add_next_index_object(parametres, param );
- add_assoc_object( arg, "parts", parametres );
- }
-}
-
-/* {{{ proto object imap_fetchstructure(int stream_id, int msg_no [, int options])
- Read the full structure of a message */
-PHP_FUNCTION(imap_fetchstructure)
-{
- pval *streamind, *msgno,*flags;
- int ind, ind_type;
- pils *imap_le_struct;
- BODY *body;
- int myargc=ARG_COUNT(ht);
- if ( myargc < 2 || myargc > 3 || getParameters( ht, myargc, &streamind, &msgno ,&flags) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long( streamind );
- convert_to_long( msgno );
- if(myargc == 3) convert_to_long(flags);
- object_init(return_value);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find( ind, &ind_type );
-
- if ( !imap_le_struct || ind_type != le_imap ) {
- php_error( E_WARNING, "Unable to find stream pointer" );
- RETURN_FALSE;
- }
-
- mail_fetchstructure_full( imap_le_struct->imap_stream, msgno->value.lval, &body ,myargc == 3 ? flags->value.lval : NIL);
-
- if ( !body ) {
- php_error( E_WARNING, "No body information available" );
- RETURN_FALSE;
- }
-
- imap_add_body( return_value, body );
-}
-/* }}} */
-
-/* {{{ proto string imap_fetchbody(int stream_id, int msg_no, int section [, int options])
- Get a specific body section */
-PHP_FUNCTION(imap_fetchbody)
-{
- pval *streamind, *msgno, *sec,*flags;
- int ind, ind_type;
- pils *imap_le_struct;
- char *body;
- unsigned long len;
- int myargc=ARG_COUNT(ht);
- if(myargc < 3 || myargc >4 || getParameters( ht, myargc, &streamind, &msgno, &sec,&flags ) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long( streamind );
- convert_to_long( msgno );
- convert_to_string( sec );
- if(myargc == 4) convert_to_long(flags);
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find( ind, &ind_type );
-
- if ( !imap_le_struct || ind_type != le_imap ) {
- php_error( E_WARNING, "Unable to find stream pointer" );
- RETURN_FALSE;
- }
-
- body = mail_fetchbody_full( imap_le_struct->imap_stream, msgno->value.lval, sec->value.str.val, &len,myargc == 4 ? flags->value.lval : NIL );
-
- if ( !body ) {
- php_error( E_WARNING, "No body information available" );
- RETURN_FALSE;
- }
- RETVAL_STRINGL( body ,len,1);
-}
-/* }}} */
-
-/* {{{ proto string imap_base64(string text)
- Decode BASE64 encoded text */
-PHP_FUNCTION(imap_base64)
-{
- pval *text;
- char *decode;
- unsigned long newlength;
- if ( ARG_COUNT(ht) != 1 || getParameters( ht, 1, &text) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string( text );
- object_init(return_value);
-
- decode = (char *) rfc822_base64((unsigned char *) text->value.str.val, text->value.str.len,&newlength);
- RETVAL_STRINGL(decode,newlength,1);
-}
-/* }}} */
-
-/* {{{ proto string imap_qprint(string text)
- Convert a quoted-printable string to an 8-bit string */
-PHP_FUNCTION(imap_qprint)
-{
- pval *text;
- char *decode;
- unsigned long newlength;
- if ( ARG_COUNT(ht) != 1 || getParameters( ht, 1, &text) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string( text );
- object_init(return_value);
-
- decode = (char *) rfc822_qprint((unsigned char *) text->value.str.val, text->value.str.len,&newlength);
- RETVAL_STRINGL(decode,newlength,1);
-}
-/* }}} */
-
-/* {{{ proto string imap_8bit(string text)
- Convert an 8-bit string to a quoted-printable string */
-PHP_FUNCTION(imap_8bit)
-{
- pval *text;
- char *decode;
- unsigned long newlength;
- if ( ARG_COUNT(ht) != 1 || getParameters( ht, 1, &text) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string( text );
- object_init(return_value);
-
- decode = (char *) rfc822_8bit((unsigned char *) text->value.str.val, text->value.str.len,&newlength);
- RETVAL_STRINGL(decode,newlength,1);
-}
-/* }}} */
-
-/* {{{ proto string imap_binary(string text)
- Convert an 8bit string to a base64 string */
-PHP_FUNCTION(imap_binary)
-{
- pval *text;
- unsigned long len;
- if ( ARG_COUNT(ht) != 1 || getParameters( ht, 1, &text) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(text);
- RETVAL_STRINGL(rfc822_binary(text->value.str.val,text->value.str.len,&len),len,1);
-}
-/* }}} */
-
-/* {{{ proto array imap_mailboxmsginfo(int stream_id)
- Returns info about the current mailbox in an associative array */
-PHP_FUNCTION(imap_mailboxmsginfo)
-{
- pval *streamind;
- char date[50];
- int ind, ind_type;
- unsigned int msgno;
- pils *imap_le_struct;
- unsigned unreadmsg,msize;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &streamind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if(!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- /* Initialize return array */
- if(object_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
-
- unreadmsg = 0;
- msize = 0;
- for (msgno = 1; msgno <= imap_le_struct->imap_stream->nmsgs; msgno++) {
- MESSAGECACHE * cache = mail_elt (imap_le_struct->imap_stream,msgno);
- mail_fetchstructure (imap_le_struct->imap_stream,msgno,NIL);
- unreadmsg = cache->recent ? (cache->seen ? unreadmsg : unreadmsg++) : unreadmsg;
- unreadmsg = (cache->recent | cache->seen) ? unreadmsg : unreadmsg++;
- msize = msize + cache->rfc822_size;
- }
- add_property_long(return_value,"Unread",unreadmsg);
- add_property_long(return_value,"Nmsgs",imap_le_struct->imap_stream->nmsgs);
- add_property_long(return_value,"Size",msize);
- rfc822_date (date);
- add_property_string(return_value,"Date",date,1);
- add_property_string(return_value,"Driver",imap_le_struct->imap_stream->dtb->name,1);
- add_property_string(return_value,"Mailbox",imap_le_struct->imap_stream->mailbox,1);
- add_property_long(return_value,"Recent",imap_le_struct->imap_stream->recent);
-}
-/* }}} */
-
-/* {{{ proto string imap_rfc822_write_address(string mailbox, string host, string personal)
- Returns a properly formatted email address given the mailbox, host, and personal info */
-PHP_FUNCTION(imap_rfc822_write_address)
-{
- pval *mailbox,*host,*personal;
- ADDRESS *addr;
- char string[MAILTMPLEN];
- int argc;
- argc=ARG_COUNT(ht);
- if ( argc != 3 || getParameters( ht, argc, &mailbox,&host,&personal) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(mailbox);
- convert_to_string(host);
- convert_to_string(personal);
- addr=mail_newaddr();
- if(mailbox) addr->mailbox = cpystr(mailbox->value.str.val);
- if(host) addr->host = cpystr(host->value.str.val);
- if(personal) addr->personal = cpystr(personal->value.str.val);
- addr->next=NIL;
- addr->error=NIL;
- addr->adl=NIL;
- string[0]=0x00;
-
- rfc822_write_address(string,addr);
- RETVAL_STRING(string,1);
-}
-/* }}} */
-
-/* {{{ proto array imap_rfc822_parse_adrlist(string address_string, string default_host)
- Parses an address string */
-PHP_FUNCTION(imap_rfc822_parse_adrlist)
-{
- pval *string,*defaulthost,*tovals;
- ADDRESS *addresstmp;
- ENVELOPE *env;
- int argc;
-
- env=mail_newenvelope();
- argc=ARG_COUNT(ht);
- if ( argc != 2 || getParameters( ht, argc, &string,&defaulthost) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(string);
- convert_to_string(defaulthost);
- rfc822_parse_adrlist(&env->to,string->value.str.val,defaulthost->value.str.val);
- if(array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
- addresstmp=env->to;
- if(addresstmp) do {
- MAKE_STD_ZVAL(tovals);
- object_init(tovals);
- if(addresstmp->mailbox) add_property_string(tovals,"mailbox",addresstmp->mailbox,1);
- if(addresstmp->host) add_property_string(tovals,"host",addresstmp->host,1);
- if(addresstmp->personal) add_property_string(tovals,"personal",addresstmp->personal,1);
- if(addresstmp->adl) add_property_string(tovals,"adl",addresstmp->adl,1);
- add_next_index_object(return_value, tovals);
- } while ((addresstmp = addresstmp->next));
-}
-/* }}} */
-
-/* {{{ proto int imap_setflag_full(int stream_id, string sequence, string flag [, int options])
- Sets flags on messages */
-PHP_FUNCTION(imap_setflag_full)
-{
- pval *streamind;
- pval *sequence;
- pval *flag;
- pval *flags;
- int ind,ind_type;
- pils *imap_le_struct;
- int myargc=ARG_COUNT(ht);
-
- if (myargc < 3 || myargc > 4 || getParameters(ht, myargc, &streamind,&sequence,&flag,&flags) ==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(streamind);
- convert_to_string(sequence);
- convert_to_string(flag);
- if(myargc==4) convert_to_long(flags);
-
- ind = streamind->value.lval;
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if(!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- mail_setflag_full(imap_le_struct->imap_stream,sequence->value.str.val,flag->value.str.val,myargc == 4 ? flags->value.lval : NIL);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto imap_clearflag_full(int stream_id, string sequence, string flag [, int options])
- Clears flags on messages */
-PHP_FUNCTION(imap_clearflag_full)
-{
- pval *streamind;
- pval *sequence;
- pval *flag;
- pval *flags;
- int ind,ind_type;
- pils *imap_le_struct;
- int myargc=ARG_COUNT(ht);
- if (myargc < 3 || myargc > 4 || getParameters(ht, myargc, &streamind,&sequence,&flag,&flags) ==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(streamind);
- convert_to_string(sequence);
- convert_to_string(flag);
- if(myargc==4) convert_to_long(flags);
- ind = streamind->value.lval;
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if(!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- mail_clearflag_full(imap_le_struct->imap_stream,sequence->value.str.val,flag->value.str.val,myargc == 4 ? flags->value.lval : NIL);
-}
-/* }}} */
-
-/* {{{ proto array imap_sort(int stream_id, int criteria, int reverse [, int options])
- Sort an array of message headers */
-PHP_FUNCTION(imap_sort)
-{
- pval *streamind;
- pval *pgm;
- pval *rev;
- pval *flags;
- int ind,ind_type;
- unsigned long *slst,*sl;
- SORTPGM *mypgm=NIL;
- SEARCHPGM *spg=NIL;
- pils *imap_le_struct;
- int myargc=ARG_COUNT(ht);
- if (myargc < 3 || myargc > 4 || getParameters(ht, myargc, &streamind,&pgm,&rev,&flags) ==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(streamind);
- convert_to_long(rev);
- convert_to_long(pgm);
- if(pgm->value.lval>SORTSIZE) {
- php_error(E_WARNING, "Unrecognized sort criteria");
- RETURN_FALSE;
- }
- if(myargc==4) convert_to_long(flags);
-
- ind = streamind->value.lval;
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if(!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- spg = mail_newsearchpgm();
- mypgm=mail_newsortpgm();
- mypgm->reverse=rev->value.lval;
- mypgm->function=pgm->value.lval;
- mypgm->next=NIL;
-
- array_init(return_value);
- slst=mail_sort(imap_le_struct->imap_stream,NIL,spg,mypgm,myargc == 4 ? flags->value.lval:NIL);
-
-
- for (sl = slst; *sl; sl++) {
- add_next_index_long(return_value,*sl);
- }
- fs_give ((void **) &slst);
-
-}
-/* }}} */
-
-/* {{{ proto string imap_fetchheader(int stream_id, int msg_no [, int options])
- Get the full unfiltered header for a message */
-PHP_FUNCTION(imap_fetchheader)
-{
- pval *streamind, * msgno, * flags;
- int ind, ind_type;
- pils *imap_le_struct;
- int myargc = ARG_COUNT(ht);
- if (myargc < 2 || myargc > 3 || getParameters(ht,myargc,&streamind,&msgno,&flags) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(msgno);
- if(myargc == 3) convert_to_long(flags);
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- RETVAL_STRING(mail_fetchheader_full (imap_le_struct->imap_stream,msgno->value.lval,NIL,NIL,myargc == 3 ? flags->value.lval : NIL),1);
-
-}
-/* }}} */
-
-/* {{{ proto int imap_uid(int stream_id, int msg_no)
- Get the unique message id associated with a standard sequential message number */
-PHP_FUNCTION(imap_uid)
-{
- pval *streamind, *msgno;
- int ind, ind_type;
- pils *imap_le_struct;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&streamind,&msgno) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(msgno);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- RETURN_LONG(mail_uid(imap_le_struct->imap_stream, msgno->value.lval));
-}
-/* }}} */
-
-/* {{{ proto int imap_msgno(int stream_id, int unique_msg_id)
- Get the sequence number associated with a UID */
-PHP_FUNCTION(imap_msgno)
-{
- pval *streamind, *msgno;
- int ind, ind_type;
- pils *imap_le_struct;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&streamind,&msgno) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(msgno);
-
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- RETURN_LONG(mail_msgno(imap_le_struct->imap_stream, msgno->value.lval));
-}
-/* }}} */
-
-/* {{{ proto object imap_status(int stream_id, string mailbox, int options)
- Get status info from a mailbox */
-PHP_FUNCTION(imap_status)
-{
- pval *streamind, *mbx, *flags;
- int ind, ind_type;
- pils *imap_le_struct;
- int myargc=ARG_COUNT(ht);
- if (myargc != 3 || getParameters(ht,myargc,&streamind,&mbx,&flags) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(mbx);
- convert_to_long(flags);
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- if(object_init(return_value) == FAILURE){
- RETURN_FALSE;
- }
- if(mail_status(imap_le_struct->imap_stream, mbx->value.str.val, flags->value.lval))
- {
- add_property_long(return_value,"flags",status_flags);
- if(status_flags & SA_MESSAGES) add_property_long(return_value,"messages",status_messages);
- if(status_flags & SA_RECENT) add_property_long(return_value,"recent",status_recent);
- if(status_flags & SA_UNSEEN) add_property_long(return_value,"unseen",status_unseen);
- if(status_flags & SA_UIDNEXT) add_property_long(return_value,"uidnext",status_uidnext);
- if(status_flags & SA_UIDVALIDITY) add_property_long(return_value,"uidvalidity",status_uidvalidity);
- }
- else
- {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto object imap_bodystruct(int stream_id, int msg_no, int section)
- Read the structure of a specified body section of a specific message */
-PHP_FUNCTION(imap_bodystruct)
-{
- pval *streamind, *msg, *section;
- int ind, ind_type;
- pils *imap_le_struct;
- pval *parametres, *param, *dparametres, *dparam;
- PARAMETER *par, *dpar;
- BODY *body;
- int myargc=ARG_COUNT(ht);
-
- if (myargc != 3 || getParameters(ht,myargc,&streamind,&msg,&section) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(msg);
- convert_to_string(section);
- ind = streamind->value.lval;
-
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- if(object_init(return_value) == FAILURE){
- RETURN_FALSE;
- }
-
- body=mail_body(imap_le_struct->imap_stream, msg->value.lval, section->value.str.val);
- if(body->type) add_property_long( return_value, "type", body->type );
- if(body->encoding) add_property_long( return_value, "encoding", body->encoding );
-
- if ( body->subtype ){
- add_property_long( return_value, "ifsubtype", 1 );
- add_property_string( return_value, "subtype", body->subtype, 1 );
- } else {
- add_property_long( return_value, "ifsubtype", 0 );
- }
-
- if ( body->description ){
- add_property_long( return_value, "ifdescription", 1 );
- add_property_string( return_value, "description", body->description, 1 );
- } else {
- add_property_long( return_value, "ifdescription", 0 );
- }
- if ( body->id ){
- add_property_long( return_value, "ifid", 1 );
- if(body->description) add_property_string( return_value, "id", body->description, 1 );
- } else {
- add_property_long( return_value, "ifid", 0 );
- }
-
- if(body->size.lines) add_property_long( return_value, "lines", body->size.lines );
- if(body->size.bytes) add_property_long( return_value, "bytes", body->size.bytes );
-#ifdef IMAP41
- if ( body->disposition.type ){
- add_property_long( return_value, "ifdisposition", 1);
- add_property_string( return_value, "disposition", body->disposition.type, 1);
- } else {
- add_property_long( return_value, "ifdisposition", 0);
- }
-
- if ( body->disposition.parameter ) {
- dpar = body->disposition.parameter;
- add_property_long( return_value, "ifdparameters", 1);
- MAKE_STD_ZVAL(dparametres);
- array_init(dparametres);
- do {
- MAKE_STD_ZVAL(dparam);
- object_init(dparam);
- add_property_string(dparam, "attribute", dpar->attribute, 1);
- add_property_string(dparam, "value", dpar->value, 1);
- add_next_index_object(dparametres, dparam );
- } while ( (dpar = dpar->next) );
- add_assoc_object( return_value, "dparameters", dparametres );
- } else {
- add_property_long( return_value, "ifdparameters", 0);
- }
-#endif
-
- if ( (par = body->parameter) ) {
- add_property_long( return_value, "ifparameters", 1 );
-
- MAKE_STD_ZVAL(parametres);
- array_init(parametres);
- do {
- MAKE_STD_ZVAL(param);
- object_init(param);
- if(par->attribute) add_property_string(param, "attribute", par->attribute, 1 );
- if(par->value) add_property_string(param, "value", par->value, 1 );
-
- add_next_index_object(parametres, param );
- } while ( (par = par->next) );
- } else {
- MAKE_STD_ZVAL(parametres);
- object_init(parametres);
- add_property_long( return_value, "ifparameters", 0 );
- }
- add_assoc_object( return_value, "parameters", parametres );
-}
-/* }}} */
-
-/* {{{ proto array imap_fetch_overview(int stream_id, int msg_no)
- Read an overview of the information in the headers of the given message */
-PHP_FUNCTION(imap_fetch_overview)
-{
- pval *streamind, *sequence;
- int ind, ind_type;
- pils *imap_le_struct;
- pval *myoverview;
- char address[MAILTMPLEN];
- int myargc=ARG_COUNT(ht);
-
- if (myargc != 2 || getParameters(ht,myargc,&streamind,&sequence) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(sequence);
-
- ind = streamind->value.lval;
- imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!imap_le_struct || ind_type != le_imap) {
- php_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- array_init(return_value);
- if (mail_uid_sequence (imap_le_struct->imap_stream,(char *)sequence)) {
- MESSAGECACHE *elt;
- ENVELOPE *env;
- unsigned long i;
-
- for (i = 1; i <= imap_le_struct->imap_stream->nmsgs; i++) {
- if (((elt = mail_elt (imap_le_struct->imap_stream,i))->sequence) &&
- (env = mail_fetch_structure (imap_le_struct->imap_stream,i,NIL,NIL))) {
- MAKE_STD_ZVAL(myoverview);
- object_init(myoverview);
- add_property_string(myoverview,"subject",env->subject,1);
- env->from->next=NULL;
- rfc822_write_address(address,env->from);
- add_property_string(myoverview,"from",address,1);
- add_property_string(myoverview,"date",env->date,1);
- add_property_string(myoverview,"message_id",env->message_id,1);
- add_property_string(myoverview,"references",env->references,1);
- add_property_long(myoverview,"size",elt->rfc822_size);
- add_property_long(myoverview,"uid",mail_uid(imap_le_struct->imap_stream,i));
- add_property_long(myoverview,"msgno",i);
- add_property_long(myoverview,"recent",elt->recent);
- add_property_long(myoverview,"flagged",elt->flagged);
- add_property_long(myoverview,"answered",elt->answered);
- add_property_long(myoverview,"deleted",elt->deleted);
- add_property_long(myoverview,"seen",elt->seen);
- add_next_index_object(return_value,myoverview);
- }
- }
- }
-}
-
-/* }}} */
-
-/* {{{ proto string imap_mail_compose(array envelope, array body)
- Create a MIME message based on given envelope and body sections */
-PHP_FUNCTION(imap_mail_compose)
-{
- pval *envelope, *body;
- char *key;
- pval *data,**pvalue;
- ulong ind;
- char *cookie = NIL;
- ENVELOPE *env;
- BODY *bod=NULL,*topbod=NULL;
- PART *mypart=NULL,*toppart=NULL,*part;
- PARAMETER *param;
- char tmp[8*MAILTMPLEN],*mystring=NULL,*t,*tempstring;
- int myargc=ARG_COUNT(ht);
-
- if (myargc != 2 || getParameters(ht,myargc,&envelope,&body) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_array(envelope);
- convert_to_array(body);
- env=mail_newenvelope();
- if(zend_hash_find(envelope->value.ht,"remail",sizeof("remail"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- env->remail=cpystr((*pvalue)->value.str.val);
- }
-
- if(zend_hash_find(envelope->value.ht,"return_path",sizeof("return_path"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- rfc822_parse_adrlist (&env->return_path,(*pvalue)->value.str.val,"NO HOST");
- }
- if(zend_hash_find(envelope->value.ht,"date",sizeof("date"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- env->date=cpystr((*pvalue)->value.str.val);
- }
- if(zend_hash_find(envelope->value.ht,"from",sizeof("from"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- rfc822_parse_adrlist (&env->from,(*pvalue)->value.str.val,"NO HOST");
- }
- if(zend_hash_find(envelope->value.ht,"reply_to",sizeof("reply_to"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- rfc822_parse_adrlist (&env->reply_to,(*pvalue)->value.str.val,"NO HOST");
- }
- if(zend_hash_find(envelope->value.ht,"to",sizeof("to"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- rfc822_parse_adrlist (&env->to,(*pvalue)->value.str.val,"NO HOST");
- }
- if(zend_hash_find(envelope->value.ht,"cc",sizeof("cc"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- rfc822_parse_adrlist (&env->cc,(*pvalue)->value.str.val,"NO HOST");
- }
- if(zend_hash_find(envelope->value.ht,"bcc",sizeof("bcc"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- rfc822_parse_adrlist (&env->bcc,(*pvalue)->value.str.val,"NO HOST");
- }
- if(zend_hash_find(envelope->value.ht,"message_id",sizeof("message_id"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- env->message_id=cpystr((*pvalue)->value.str.val);
- }
-
- zend_hash_internal_pointer_reset(body->value.ht);
- zend_hash_get_current_key(body->value.ht, &key, &ind);
- zend_hash_get_current_data(body->value.ht, (void **) &data);
- if(data->type == IS_ARRAY) {
- bod=mail_newbody();
- topbod=bod;
- if(zend_hash_find(data->value.ht,"type",sizeof("type"),(void **) &pvalue)== SUCCESS) {
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- bod->type = (*pvalue)->value.lval;
- }
- if(zend_hash_find(data->value.ht,"encoding",sizeof("encoding"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- bod->encoding = (*pvalue)->value.lval;
- }
- if(zend_hash_find(data->value.ht,"subtype",sizeof("subtype"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- bod->subtype = cpystr((*pvalue)->value.str.val);
- }
- if(zend_hash_find(data->value.ht,"id",sizeof("id"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- bod->id = cpystr((*pvalue)->value.str.val);
- }
- if(zend_hash_find(data->value.ht,"contents.data",sizeof("contents.data"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- bod->contents.text.data=(char *)fs_get((*pvalue)->value.str.len);
- memcpy(bod->contents.text.data,(*pvalue)->value.str.val,(*pvalue)->value.str.len+1);
- bod->contents.text.size = (*pvalue)->value.str.len;
- }
- if(zend_hash_find(data->value.ht,"lines",sizeof("lines"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- bod->size.lines = (*pvalue)->value.lval;
- }
- if(zend_hash_find(data->value.ht,"bytes",sizeof("bytes"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- bod->size.bytes = (*pvalue)->value.lval;
- }
- if(zend_hash_find(data->value.ht,"md5",sizeof("md5"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- bod->md5 = cpystr((*pvalue)->value.str.val);
- }
- }
- zend_hash_move_forward(body->value.ht);
- while(zend_hash_get_current_data(body->value.ht, (void **) &data)==SUCCESS) {
- zend_hash_get_current_key(body->value.ht, &key, &ind);
- if(data->type == IS_ARRAY) {
- if(!toppart) {
- bod->nested.part=mail_newbody_part();
- mypart=bod->nested.part;
- toppart=mypart;
- bod=&mypart->body;
- } else {
- mypart->next=mail_newbody_part();
- mypart=mypart->next;
- bod=&mypart->body;
- }
- if(zend_hash_find(data->value.ht,"type",sizeof("type"),(void **) &pvalue)== SUCCESS) {
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- bod->type = (*pvalue)->value.lval;
- }
- if(zend_hash_find(data->value.ht,"encoding",sizeof("encoding"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- bod->encoding = (*pvalue)->value.lval;
- }
- if(zend_hash_find(data->value.ht,"subtype",sizeof("subtype"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- bod->subtype=cpystr((*pvalue)->value.str.val);
- }
- if(zend_hash_find(data->value.ht,"id",sizeof("id"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- bod->id=cpystr((*pvalue)->value.str.val);
- }
- if(zend_hash_find(data->value.ht,"contents.data",sizeof("contents.data"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- bod->contents.text.data=(char *)fs_get((*pvalue)->value.str.len);
- memcpy(bod->contents.text.data,(*pvalue)->value.str.val,(*pvalue)->value.str.len+1);
- bod->contents.text.size=(*pvalue)->value.str.len;
- }
- if(zend_hash_find(data->value.ht,"lines",sizeof("lines"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- bod->size.lines=(*pvalue)->value.lval;
- }
- if(zend_hash_find(data->value.ht,"bytes",sizeof("bytes"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_long(*pvalue);
- bod->size.bytes=(*pvalue)->value.lval;
- }
- if(zend_hash_find(data->value.ht,"md5",sizeof("md5"),(void **) &pvalue)== SUCCESS){
- SEPARATE_ZVAL(pvalue);
- convert_to_string(*pvalue);
- bod->md5=cpystr((*pvalue)->value.str.val);
- }
- zend_hash_move_forward(body->value.ht);
- }
- }
-
- rfc822_encode_body_7bit (env,topbod);
- rfc822_header (tmp,env,topbod);
- mystring=emalloc(strlen(tmp)+1);
- strcpy(mystring,tmp);
-
- bod=topbod;
- switch (bod->type) {
- case TYPEMULTIPART: /* multipart gets special handling */
- part = bod->nested.part; /* first body part */
- /* find cookie */
- for (param = bod->parameter; param && !cookie; param = param->next) {
- if (!strcmp (param->attribute,"BOUNDARY")) {
- cookie = param->value;
- }
- }
- if (!cookie) {
- cookie = "-"; /* yucky default */
- }
- do { /* for each part */
- /* build cookie */
- sprintf (t=tmp,"--%s\015\012",cookie);
- /* append mini-header */
- rfc822_write_body_header (&t,&part->body);
- strcat (t,"\015\012"); /* write terminating blank line */
- /* output cookie, mini-header, and contents */
- tempstring=emalloc(strlen(mystring)+strlen(tmp)+1);
- strcpy(tempstring,mystring);
- efree(mystring);
- mystring=tempstring;
- strcat(mystring,tmp);
-
- bod=&part->body;
-
- tempstring=emalloc(strlen(bod->contents.text.data)+strlen(mystring)+1);
- strcpy(tempstring,mystring);
- efree(mystring);
- mystring=tempstring;
- strcat(mystring,bod->contents.text.data);
-
- } while ((part = part->next));/* until done */
- /* output trailing cookie */
-
- sprintf(tmp,"--%s--",cookie);
- tempstring=emalloc(strlen(tmp)+strlen(mystring)+1);
- strcpy(tempstring,mystring);
- efree(mystring);
- mystring=tempstring;
- strcat(mystring,tmp);
- break;
- default: /* all else is text now */
- tempstring=emalloc(strlen(bod->contents.text.data)+strlen(mystring)+1);
- strcpy(tempstring,mystring);
- efree(mystring);
- mystring=tempstring;
- strcat(mystring,bod->contents.text.data);
- break;
- }
-
- RETURN_STRINGL(mystring,strlen(mystring),1);
-}
-/* }}} */
-
-
-
-/* Interfaces to C-client */
-
-
-void mm_searched (MAILSTREAM *stream,unsigned long number)
-{
-}
-
-
-void mm_exists (MAILSTREAM *stream,unsigned long number)
-{
-}
-
-
-void mm_expunged (MAILSTREAM *stream,unsigned long number)
-{
-}
-
-
-void mm_flags (MAILSTREAM *stream,unsigned long number)
-{
-}
-
-
-void mm_notify (MAILSTREAM *stream,char *string,long errflg)
-{
-}
-
-void mm_list (MAILSTREAM *stream,DTYPE delimiter,char *mailbox,long attributes)
-{
- STRINGLIST *cur=NIL;
- if(!(attributes & LATT_NOSELECT)) {
- if (imap_folders == NIL) {
- imap_folders=mail_newstringlist();
- imap_folders->LSIZE=strlen(imap_folders->LTEXT=cpystr(mailbox));
- imap_folders->next=NIL;
- } else {
- cur=imap_folders;
- while (cur->next != NIL ) {
- cur=cur->next;
- }
- cur->next=mail_newstringlist ();
- cur=cur->next;
- cur->LSIZE = strlen (cur->LTEXT = cpystr (mailbox));
- cur->next = NIL;
- }
- }
-}
-
-void mm_lsub (MAILSTREAM *stream,DTYPE delimiter,char *mailbox,long attributes)
-{
- STRINGLIST *cur=NIL;
- if (imap_sfolders == NIL) {
- imap_sfolders=mail_newstringlist();
- imap_sfolders->LSIZE=strlen(imap_sfolders->LTEXT=cpystr(mailbox));
- imap_sfolders->next=NIL;
- } else {
- cur=imap_sfolders;
- while (cur->next != NIL ) {
- cur=cur->next;
- }
- cur->next=mail_newstringlist ();
- cur=cur->next;
- cur->LSIZE = strlen (cur->LTEXT = cpystr (mailbox));
- cur->next = NIL;
- }
-}
-
-void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
-{
-status_flags=status->flags;
- if(status_flags & SA_MESSAGES) status_messages=status->messages;
- if(status_flags & SA_RECENT) status_recent=status->recent;
- if(status_flags & SA_UNSEEN) status_unseen=status->unseen;
- if(status_flags & SA_UIDNEXT) status_uidnext=status->uidnext;
- if(status_flags & SA_UIDVALIDITY) status_uidvalidity=status->uidvalidity;
-
-}
-
-void mm_log (char *string,long errflg)
-{
- switch ((short) errflg) {
- case NIL:
- /* php_error(E_NOTICE,string); messages */
- break;
- case PARSE:
- case WARN:
- php_error(E_WARNING,string); /* warnings */
- break;
- case ERROR:
- php_error(E_NOTICE,string); /* errors */
- break;
- }
-}
-
-void mm_dlog (char *string)
-{
- php_error(E_NOTICE,string);
-}
-
-void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
-{
- if (*mb->user) {
- strcpy (user,mb->user);
- } else {
- strcpy (user,imap_user);
- }
- strcpy (pwd,imap_password);
-}
-
-
-void mm_critical (MAILSTREAM *stream)
-{
-}
-
-
-void mm_nocritical (MAILSTREAM *stream)
-{
-}
-
-
-long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
-{
- return 1;
-}
-
-
-void mm_fatal (char *string)
-{
-}
-
-#endif
diff --git a/ext/imap/imap.h b/ext/imap/imap.h
deleted file mode 100644
index cf89e029c2..0000000000
--- a/ext/imap/imap.h
+++ /dev/null
@@ -1,86 +0,0 @@
-#ifndef _INCLUDED_IMAP_H
-#define _INCLUDED_IMAP_H
-
-#if COMPILE_DL
-#undef HAVE_IMAP
-#define HAVE_IMAP 1
-#endif
-
-#if HAVE_IMAP
-
-#ifndef MSVC5
-#include "build-defs.h"
-#endif
-
-/* Functions accessable to PHP */
-extern php3_module_entry php3_imap_module_entry;
-#define php3_imap_module_ptr &php3_imap_module_entry
-
-extern PHP_MINIT_FUNCTION(imap);
-PHP_MINFO_FUNCTION(imap);
-PHP_FUNCTION(imap_open);
-PHP_FUNCTION(imap_reopen);
-PHP_FUNCTION(imap_close);
-PHP_FUNCTION(imap_num_msg);
-PHP_FUNCTION(imap_headers);
-PHP_FUNCTION(imap_body);
-PHP_FUNCTION(imap_expunge);
-PHP_FUNCTION(imap_delete);
-PHP_FUNCTION(imap_undelete);
-PHP_FUNCTION(imap_check);
-PHP_FUNCTION(imap_headerinfo);
-PHP_FUNCTION(imap_mail_copy);
-PHP_FUNCTION(imap_mail_move);
-PHP_FUNCTION(imap_createmailbox);
-PHP_FUNCTION(imap_renamemailbox);
-PHP_FUNCTION(imap_deletemailbox);
-PHP_FUNCTION(imap_list);
-PHP_FUNCTION(imap_listscan);
-PHP_FUNCTION(imap_lsub);
-PHP_FUNCTION(imap_subscribe);
-PHP_FUNCTION(imap_unsubscribe);
-PHP_FUNCTION(imap_num_recent);
-PHP_FUNCTION(imap_fetchstructure);
-PHP_FUNCTION(imap_fetchbody);
-PHP_FUNCTION(imap_append);
-PHP_FUNCTION(imap_ping);
-PHP_FUNCTION(imap_base64);
-PHP_FUNCTION(imap_qprint);
-PHP_FUNCTION(imap_8bit);
-PHP_FUNCTION(imap_binary);
-PHP_FUNCTION(imap_mailboxmsginfo);
-PHP_FUNCTION(imap_rfc822_write_address);
-PHP_FUNCTION(imap_rfc822_parse_adrlist);
-PHP_FUNCTION(imap_setflag_full);
-PHP_FUNCTION(imap_clearflag_full);
-PHP_FUNCTION(imap_sort);
-PHP_FUNCTION(imap_fetchtext);
-PHP_FUNCTION(imap_fetchheader);
-PHP_FUNCTION(imap_uid);
-PHP_FUNCTION(imap_msgno);
-PHP_FUNCTION(imap_fetchtext_full);
-PHP_FUNCTION(imap_status);
-PHP_FUNCTION(imap_bodystruct);
-PHP_FUNCTION(imap_fetch_overview);
-PHP_FUNCTION(imap_mail_compose);
-
-#else
-#define php3_imap_module_ptr NULL
-#endif /* HAVE_IMAP */
-
-#endif
-
-
-
-
-
-
-#define phpext_imap_ptr php3_imap_module_ptr
-
-
-
-
-
-
-
-
diff --git a/ext/imap/setup.stub b/ext/imap/setup.stub
deleted file mode 100644
index afc77dd90e..0000000000
--- a/ext/imap/setup.stub
+++ /dev/null
@@ -1,7 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-imap 'IMAP support?' yesnodir \
- 'no /usr/local/imap IMAP base install' \
-' Whether to build with IMAP (Internet Message Access Protocol)\n
- support.\n'
diff --git a/ext/informix/Makefile.am b/ext/informix/Makefile.am
deleted file mode 100644
index 18b8a4fd08..0000000000
--- a/ext/informix/Makefile.am
+++ /dev/null
@@ -1,15 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_informix.a
-libphpext_informix_a_SOURCES=ifx.c
-
-ifx.c: ifx.ec
- (if test -d @INFORMIXDIR@; then \
- esql -e @IFX_ESQL_FLAGS@ ifx.ec; \
- else \
- touch ifx.c; \
- fi)
-
-clean:
- -rm -f ifx.c
diff --git a/ext/informix/config.h.stub b/ext/informix/config.h.stub
deleted file mode 100644
index a61d630e4d..0000000000
--- a/ext/informix/config.h.stub
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef HAVE_IFX
-#define HAVE_IFX 0
-#endif
-#ifndef HAVE_IFX_IUS
-#define HAVE_IFX_IUS 0
-#endif
-#ifndef IFX_VERSION
-#define IFX_VERSION 0
-#endif
diff --git a/ext/informix/config.m4 b/ext/informix/config.m4
deleted file mode 100644
index 4ef3b5878e..0000000000
--- a/ext/informix/config.m4
+++ /dev/null
@@ -1,80 +0,0 @@
-dnl $Id$
-
-divert(3)
-
-AC_MSG_CHECKING(for Informix support)
-AC_ARG_WITH(informix,
-[ --with-informix[=DIR] Include Informix support. DIR is the Informix base
- install directory, defaults to ${INFORMIXDIR:-nothing}.],
-[
- if test "$withval" != "no"; then
- if test "$INFORMIXDIR" = ""; then
- INFORMIX_WARNING="
-WARNING: You asked for Informix support, but don't have \\\$INFORMIXDIR
- environment value set up. Configuring and compiling Informix
- support to PHP3 is impossible and has been turned off. Please
- try again after setting up your environment."
- AC_MSG_RESULT(no)
- else
- if test "$withval" = "yes"; then
- IFX_INCDIR=$INFORMIXDIR/incl/esql
- IFX_LIBDIR="-L$INFORMIXDIR/lib -L$INFORMIXDIR/lib/esql"
- else
- IFX_INCDIR=$withval/incl/esql
- IFX_LIBDIR="-L$withval/lib -L$withval/lib/esql"
- if test "$withval" != "$INFORMIXDIR"; then
- INFORMIX_WARNING="
-WARNING: You specified Informix base install directory that is different
- than your \\\$INFORMIXDIR environment variable. You'd better know
- exactly what you are doing."
- fi
- fi
- IFX_INCLUDE=-I$IFX_INCDIR
- IFX_LFLAGS=$IFX_LIBDIR
- if test -z "$IFX_LIBS"; then
- IFX_LIBS=`esql -libs | sed -e 's/-lm$//'`
- dnl -lm twice otherwise?
- IFX_LIBS=`echo $IFX_LIBS | sed -e 's/Libraries to be used://g' -e 's/esql: error -55923: No source or object file\.//g'`
- dnl Seems to get rid of newlines.
- dnl According to Perls DBD-Informix, might contain these strings.
- else
- dnl Allow override to use static and/or threaded libs
- IFX_LIBS="$IFX_LIBS"
- fi
- CFLAGS="$CFLAGS $IFX_INCLUDE"
- LDFLAGS="$LDFLAGS $IFX_LFLAGS"
-
- if test "`uname -s 2>/dev/null`" = "AIX"; then
- CFLAGS="$CFLAGS -D__H_LOCALEDEF"
- fi
- AC_DEFINE(HAVE_IFX)
- AC_MSG_CHECKING([Informix version])
- IFX_VERSION=[`esql -V | sed -ne '1 s/^[^0-9]*\([0-9]\)\.\([0-9]*\).*/\1\2/p'`]
- if test $IFX_VERSION -ge "900"; then
- AC_DEFINE(HAVE_IFX_IUS)
- IFX_ESQL_FLAGS="-EDHAVE_IFX_IUS"
- else
- IFX_ESQL_FLAGS="-EUHAVE_IFX_IUS"
- fi
- AC_SUBST(IFX_ESQL_FLAGS)
- AC_DEFINE_UNQUOTED(IFX_VERSION, $IFX_VERSION)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(informix)
- EXTRA_LIBS="$EXTRA_LIBS $IFX_LIBS $IFX_LFLAGS"
- INCLUDES="$INCLUDES $IFX_INCLUDE"
- fi
- else
- INFORMIXDIR=
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-AC_SUBST(INFORMIXDIR)
-
-divert(5)
-
-dnl Warn if Informix support was requested but environment is not set up correctly.
-if test "$INFORMIX_WARNING" != ""; then
- echo "$INFORMIX_WARNING"
-fi
diff --git a/ext/informix/ifx.ec b/ext/informix/ifx.ec
deleted file mode 100644
index 90e8726797..0000000000
--- a/ext/informix/ifx.ec
+++ /dev/null
@@ -1,4734 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Danny Heijl <Danny.Heijl@cevi.be> : initial cut (ODS 7.2x) |
- | PHP4 port |
- | Christian Cartus <chc@idgruppe.de> : blobs, and IUS 9 |
- | Jouni Ahto <jah@mork.net> : configuration stuff |
- | Based on the MySQL code by: Zeev Suraski <zeev@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-
-/* -------------------------------------------------------------------
- * if you want a function reference : "grep '^\*\*' ifx.ec" will give
- * you a very short one
- * -------------------------------------------------------------------
-*/
-
-/* TODO:
- *
- * ? Safe mode implementation
- */
-
-
-#if defined(COMPILE_DL)
-#include "dl/phpdl.h"
-#endif
-
-
-#include "php.h"
-#include "php_globals.h"
-#include "ext/standard/php3_standard.h"
-#include "php_informix.h"
-#include "php_globals.h"
-
-
-#if WIN32|WINNT
-#include <winsock.h>
-#else
-#include "build-defs.h"
-
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#include <netdb.h>
-#include <netinet/in.h>
-#endif
-
-#include "php_ini.h"
-
-
-#if HAVE_IFX
-
- /* local function prototypes */
-static void php3_ifx_set_default_link(int id);
-static long php3_intifx_getType(long id, HashTable *list);
-static long php3_intifx_create_blob(long type, long mode, char* param, long len, HashTable *list);
-static long php3_intifx_free_blob(long id, HashTable *list);
-static long php3_intifx2_free_blob(long id, HashTable *list);
-static long php3_intifx_get_blob(long bid, HashTable *list, char** content);
-static long php3_intifx_update_blob(long bid, char* param, long len, HashTable *list);
-static loc_t *php3_intifx_get_blobloc(long bid, HashTable *list);
-static char* php3_intifx_create_tmpfile(long bid);
-static long php3_intifx_copy_blob(long bid, HashTable *list);
-static char* php3_intifx_null();
-static long php3_intifx_create_char(char* param, long len, HashTable *list);
-static long php3_intifx_free_char(long id, HashTable *list);
-static long php3_intifx_update_char(long bid, char* param, long len, HashTable *list);
-static long php3_intifx_get_char(long bid, HashTable *list, char** content);
-#if HAVE_IFX_IUS
-static long php3_intifxus_create_slob(long create_mode, HashTable *list);
-static long php3_intifxus_free_slob(long bid, HashTable *list);
-static long php3_intifxus_close_slob(long bid, HashTable *list);
-static long php3_intifxus_open_slob(long bid, long create_mode, HashTable *list);
-static long php3_intifxus_new_slob(HashTable *list);
-static ifx_lo_t *php3_intifxus_get_slobloc(long bid, HashTable *list);
-#endif
-
-#ifndef CLIENT_SQLI_VER /* 7.10 on (at least) AIX is missing this */
-#define CLIENT_SQLI_VER IFX_VERSION
-#endif
-
-#define TYPE_BLBYTE 0
-#define TYPE_BLTEXT 1
-#define TYPE_SLOB 2
-#define TYPE_CHAR 3
-
-
-#define BLMODE_INMEM 0
-#define BLMODE_INFILE 1
-
-
-#define IFX_SCROLL 1
-#define IFX_HOLD 2
-
-EXEC SQL include locator;
-EXEC SQL include sqltypes;
-EXEC SQL include sqlstype;
-
-#include <errno.h>
-
-typedef char IFX[128];
-
-#define SAFE_STRING(s) ((s)?(s):"")
-
-function_entry ifx_functions[] = {
- PHP_FE(ifx_connect, NULL)
- PHP_FE(ifx_pconnect, NULL)
- PHP_FE(ifx_close, NULL)
- PHP_FE(ifx_query, NULL)
- PHP_FE(ifx_prepare, NULL)
- PHP_FE(ifx_do, NULL)
- PHP_FE(ifx_error, NULL)
- PHP_FE(ifx_errormsg, NULL)
- PHP_FE(ifx_affected_rows, NULL)
- PHP_FE(ifx_num_rows, NULL)
- PHP_FE(ifx_num_fields, NULL)
- PHP_FE(ifx_fetch_row, NULL)
- PHP_FE(ifx_free_result, NULL)
- PHP_FE(ifx_htmltbl_result, NULL)
- PHP_FE(ifx_fieldtypes, NULL)
- PHP_FE(ifx_fieldproperties, NULL)
- PHP_FE(ifx_getsqlca, NULL)
-
- PHP_FE(ifx_create_blob, NULL)
- PHP_FE(ifx_free_blob, NULL)
- PHP_FE(ifx_get_blob, NULL)
- PHP_FE(ifx_update_blob, NULL)
- PHP_FE(ifx_copy_blob, NULL)
- PHP_FE(ifx_textasvarchar, NULL)
- PHP_FE(ifx_byteasvarchar, NULL)
- PHP_FE(ifx_nullformat, NULL)
- PHP_FE(ifx_blobinfile_mode, NULL)
-
- PHP_FE(ifx_create_char, NULL)
- PHP_FE(ifx_free_char, NULL)
- PHP_FE(ifx_get_char, NULL)
- PHP_FE(ifx_update_char, NULL)
-
-$ifdef HAVE_IFX_IUS;
- PHP_FE(ifxus_create_slob, NULL)
- PHP_FE(ifxus_close_slob, NULL)
- PHP_FE(ifxus_open_slob, NULL)
- PHP_FE(ifxus_free_slob, NULL)
- PHP_FE(ifxus_read_slob, NULL)
- PHP_FE(ifxus_write_slob, NULL)
- PHP_FE(ifxus_seek_slob, NULL)
- PHP_FE(ifxus_tell_slob, NULL)
-$endif;
-
- {NULL, NULL, NULL}
-};
-
-php3_module_entry ifx_module_entry = {
- "Informix",
- ifx_functions,
- PHP_MINIT(ifx),
- PHP_MSHUTDOWN(ifx),
- PHP_RINIT(ifx),
- NULL,
- PHP_MINFO(ifx),
- STANDARD_MODULE_PROPERTIES
-};
-
-#ifdef COMPILE_DL
-DLEXPORT php3_module_entry *get_module(void) { return &ifx_module_entry; }
-#if 0
-BOOL WINAPI DllMain(HANDLE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved)
-{
- return 1;
-}
-#endif
-#endif
-
-#ifdef ZTS
-int ifx_globals_id;
-#else
-PHP_IFX_API php_ifx_globals ifx_globals;
-#endif
-
-
-#define CHECK_LINK(link) { \
- if (link==0) { \
- php_error(E_WARNING, \
- "Informix: A link to the server could not be established"); \
- RETURN_FALSE; \
- } \
- }
-
-#define DUP 1
-
-EXEC SQL DEFINE IFX_SUCCESS 0;
-EXEC SQL DEFINE IFX_WARNING 1;
-EXEC SQL DEFINE IFX_ERROR -1;
-EXEC SQL DEFINE IFX_NODATA 100;
-
-static int ifx_check()
-{
- int _ifx_check;
-
- _ifx_check = IFX_ERROR;
-
- if (SQLSTATE[0] == '0') {
- switch (SQLSTATE[1]) {
- case '0':
- _ifx_check = IFX_SUCCESS;
- break;
- case '1':
- _ifx_check = IFX_WARNING;
- break;
- case '2':
- _ifx_check = IFX_NODATA;
- break;
- default :
- _ifx_check = IFX_ERROR;
- break;
- }
- }
-
- return _ifx_check;
-}
-
-static char *ifx_error(ifx)
- EXEC SQL BEGIN DECLARE SECTION;
- PARAMETER char *ifx;
- EXEC SQL END DECLARE SECTION;
-{
- char *ifx_err_msg;
- char c;
- int errorcode;
-
- IFXLS_FETCH();
-
- if (IFXG(sv_sqlcode) == 0)
- errorcode = SQLCODE;
- else
- errorcode = IFXG(sv_sqlcode);
-
- switch (ifx_check()) {
- case IFX_SUCCESS:
- c = ' ';
- break;
- case IFX_WARNING:
- c = 'W';
- break;
- case IFX_ERROR:
- c = 'E';
- break;
- case IFX_NODATA:
- c = 'N';
- break;
- default:
- c = '?';
- break;
- }
- ifx_err_msg = emalloc(64);
- sprintf(ifx_err_msg,"%c [SQLSTATE=%c%c %c%c%c SQLCODE=%d]",
- c,
- SQLSTATE[0],
- SQLSTATE[1],
- SQLSTATE[2],
- SQLSTATE[3],
- SQLSTATE[4],
- errorcode);
- return(ifx_err_msg);
-}
-
-
-
-static void _close_ifx_link(link)
- EXEC SQL BEGIN DECLARE SECTION;
- PARAMETER char *link;
- EXEC SQL END DECLARE SECTION;
-{
-
- IFXLS_FETCH();
-
- EXEC SQL SET CONNECTION :link;
- EXEC SQL DISCONNECT CURRENT;
- efree(link);
- IFXG(num_links)--;
-}
-
-static void _close_ifx_plink(link)
-EXEC SQL BEGIN DECLARE SECTION;
- PARAMETER char *link;
-EXEC SQL END DECLARE SECTION;
-{
-
- IFXLS_FETCH();
-
- EXEC SQL SET CONNECTION :link;
- EXEC SQL DISCONNECT CURRENT;
-
- free(link);
- IFXG(num_persistent)--;
- IFXG(num_links)--;
-}
-
-static void ifx_free_result(a_result_id)
-char *a_result_id;
-{
- return;
-}
-
-static PHP_INI_DISP(display_link_numbers)
-{
- char *value;
-
- if (type==PHP_INI_DISPLAY_ORIG && ini_entry->modified) {
- value = ini_entry->orig_value;
- } else {
- if (ini_entry->value) {
- value = ini_entry->value;
- } else {
- value = NULL;
- }
- }
- if (value) {
- if (atoi(value)==-1) {
- PUTS("Unlimited");
- } else {
- php_printf("%s", value);
- }
- }
-}
-
-
-
-
-PHP_INI_BEGIN()
- STD_PHP_INI_BOOLEAN("ifx.allow_persistent", "1", PHP_INI_SYSTEM,
- OnUpdateInt, allow_persistent, php_ifx_globals, ifx_globals)
- STD_PHP_INI_ENTRY_EX("ifx.max_persistent", "-1", PHP_INI_SYSTEM,
- OnUpdateInt, max_persistent, php_ifx_globals, ifx_globals,
- display_link_numbers)
- STD_PHP_INI_ENTRY_EX("ifx.max_links", "-1", PHP_INI_SYSTEM,
- OnUpdateInt, max_links, php_ifx_globals, ifx_globals,
- display_link_numbers)
- STD_PHP_INI_ENTRY("ifx.default_host", NULL, PHP_INI_SYSTEM,
- OnUpdateString, default_host, php_ifx_globals, ifx_globals)
- STD_PHP_INI_ENTRY("ifx.default_user", NULL, PHP_INI_SYSTEM,
- OnUpdateString, default_user, php_ifx_globals, ifx_globals)
- STD_PHP_INI_ENTRY("ifx.default_password", NULL, PHP_INI_SYSTEM,
- OnUpdateString, default_password, php_ifx_globals, ifx_globals)
- STD_PHP_INI_ENTRY("ifx.blobinfile", "1", PHP_INI_ALL,
- OnUpdateInt, blobinfile, php_ifx_globals, ifx_globals)
- STD_PHP_INI_ENTRY("ifx.textasvarchar", "0", PHP_INI_ALL,
- OnUpdateInt, textasvarchar, php_ifx_globals, ifx_globals)
- STD_PHP_INI_ENTRY("ifx.byteasvarchar", "0", PHP_INI_ALL,
- OnUpdateInt, byteasvarchar, php_ifx_globals, ifx_globals)
- STD_PHP_INI_ENTRY("ifx.charasvarchar", "0", PHP_INI_ALL,
- OnUpdateInt, charasvarchar, php_ifx_globals, ifx_globals)
- STD_PHP_INI_ENTRY("ifx.nullformat", "0", PHP_INI_ALL,
- OnUpdateInt, nullformat, php_ifx_globals, ifx_globals)
-PHP_INI_END()
-
-PHP_MINIT_FUNCTION(ifx)
-{
- ELS_FETCH();
-
-#ifdef ZTS
- ifx_globals_id = ts_allocate_id(sizeof(php_ifx_globals), php_ifx_init_globals, NULL);
-#else
- IFXG(num_persistent)=0;
-#endif
-
- REGISTER_INI_ENTRIES();
-
- IFXG(nullvalue) = malloc(1);
- IFXG(nullvalue)[0] = 0;
- IFXG(nullstring) = malloc(5);
- strcpy(IFXG(nullstring), "NULL");
-
- IFXG(num_persistent)=0;
- IFXG(sv_sqlcode)=0;
-
- IFXG(le_result) = register_list_destructors(ifx_free_result,NULL);
- IFXG(le_idresult) = register_list_destructors(ifx_free_result,NULL);
- IFXG(le_link) = register_list_destructors(_close_ifx_link,NULL);
- IFXG(le_plink) = register_list_destructors(NULL,_close_ifx_plink);
-
-#if 0
- printf("Registered: %d,%d,%d\n",
- IFXG(le_result),
- IFXG(le_link),
- IFXG(le_plink));
-#endif
-
- ifx_module_entry.type = type;
-
- REGISTER_LONG_CONSTANT("IFX_SCROLL", IFX_SCROLL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("IFX_HOLD", IFX_HOLD, CONST_CS | CONST_PERSISTENT);
-$ifdef HAVE_IFX_IUS;
- REGISTER_LONG_CONSTANT("IFX_LO_RDONLY", LO_RDONLY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("IFX_LO_WRONLY", LO_WRONLY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("IFX_LO_APPEND", LO_APPEND, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("IFX_LO_RDWR", LO_RDWR, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("IFX_LO_BUFFER", LO_BUFFER, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("IFX_LO_NOBUFFER", LO_NOBUFFER, CONST_CS | CONST_PERSISTENT);
-$endif;
-
- return SUCCESS;
-}
-
-
-PHP_MSHUTDOWN_FUNCTION(ifx)
-{
-
- UNREGISTER_INI_ENTRIES();
- return SUCCESS;
-
-}
-
-PHP_RINIT_FUNCTION(ifx)
-{
- IFXLS_FETCH();
-
- IFXG(default_link)=-1;
- IFXG(num_links) = IFXG(num_persistent);
- return SUCCESS;
-}
-
-PHP_MINFO_FUNCTION(ifx)
-{
- char buf[32];
- char maxp[16],maxl[16];
-
- IFXLS_FETCH();
-
-
- if (IFXG(max_persistent)==-1) {
- strcpy(maxp,"Unlimited");
- } else {
- snprintf(maxp,15,"%ld",IFXG(max_persistent));
- maxp[15]=0;
- }
- if (IFXG(max_links)==-1) {
- strcpy(maxl,"Unlimited");
- } else {
- snprintf(maxl,15,"%ld",IFXG(max_links));
- maxl[15]=0;
- }
-
- DISPLAY_INI_ENTRIES();
-
- php_printf("<table border=\"5\" width=\"600\">\n");
- php_info_print_table_header(2, "Key", "Value");
- sprintf(buf, "%ld", IFXG(num_persistent));
- php_info_print_table_row(2, "Persistent links : ", buf);
- sprintf(buf, "%ld", IFXG(num_links));
- php_info_print_table_row(2, "Total links : ", buf);
- sprintf(buf, "%02.2f", (double)(CLIENT_SQLI_VER/100.0));
- php_info_print_table_row(2, "Client API Version: ", buf);
- php_printf("</table>\n");
-}
-
-static void php3_ifx_set_default_link(int id)
-{
-
- IFXLS_FETCH();
-
- if (IFXG(default_link) != -1) {
- zend_list_delete(IFXG(default_link));
- }
- IFXG(default_link) = id;
- zend_list_addref(id);
-
-}
-
-/* ----------------------------------------------------------------------
-** int ifx_(p)connect(string $database,string $userid,string $password)
-**
-** connects to $database (db@server syntax) using $userid and $password
-**
-** returns a connection id on success or FALSE one error
-** ----------------------------------------------------------------------
-*/
-
-static void php3_ifx_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
-{
-
- EXEC SQL BEGIN DECLARE SECTION;
- char *user,*passwd,*host;
- char *ifx;
- EXEC SQL END DECLARE SECTION;
-
- char *hashed_details;
- int hashed_details_length;
- IFXLS_FETCH();
- PLS_FETCH();
-
- if (PG(sql_safe_mode)) {
- if (ARG_COUNT(ht)>0) {
- php_error(E_NOTICE,
- "SQL safe mode in effect - ignoring host/user/password information");
- }
- host = passwd = NULL;
- user = _php3_get_current_user();
- hashed_details_length = strlen(user)+3+3;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details,"ifx__%s_",user);
- } else {
- host = IFXG(default_host);
- user = IFXG(default_user);
- passwd = IFXG(default_password);
-
- switch(ARG_COUNT(ht)) {
- case 0: /* defaults */
- break;
- case 1: {
- pval *yyhost;
-
- if (getParameters(ht, 1, &yyhost)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(yyhost);
- host = yyhost->value.str.val;
- }
- break;
- case 2: {
- pval *yyhost,*yyuser;
-
- if (getParameters(ht, 2, &yyhost, &yyuser)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(yyhost);
- convert_to_string(yyuser);
- host = yyhost->value.str.val;
- user = yyuser->value.str.val;
- }
- break;
- case 3: {
- pval *yyhost,*yyuser,*yypasswd;
-
- if (getParameters(ht, 3, &yyhost, &yyuser, &yypasswd) == FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(yyhost);
- convert_to_string(yyuser);
- convert_to_string(yypasswd);
- host = yyhost->value.str.val;
- user = yyuser->value.str.val;
- passwd = yypasswd->value.str.val;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
- hashed_details_length = sizeof("ifx___")-1 +
- strlen(SAFE_STRING(host))+
- strlen(SAFE_STRING(user))+
- strlen(SAFE_STRING(passwd));
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details,"ifx_%s_%s_%s",
- SAFE_STRING(host),
- SAFE_STRING(user),
- SAFE_STRING(passwd));
- }
-
-
- IFXG(sv_sqlcode) = 0;
-
- if (!IFXG(allow_persistent)) {
- persistent=0;
- }
- if (persistent) {
- list_entry *le;
-
- /* try to find if we already have this link in our persistent list */
- if (zend_hash_find(plist, hashed_details, hashed_details_length+1,
- (void **) &le)==FAILURE) { /* we don't */
- list_entry new_le;
-
- if (IFXG(max_links)!=-1 &&
- IFXG(num_links) >=
- IFXG(max_links)) {
- php_error(E_WARNING,
- "Informix: Too many open links (%d)",
- IFXG(num_links));
- efree(hashed_details);
- RETURN_FALSE;
- }
- if (IFXG(max_persistent)!=-1 &&
- IFXG(num_persistent) >=
- IFXG(max_persistent)) {
- php_error(E_WARNING,
- "Informix: Too many open persistent links (%d)",
- IFXG(num_persistent));
- efree(hashed_details);
- RETURN_FALSE;
- }
- /* create the link */
- ifx = (char *)malloc(sizeof(IFX));
- IFXG(connectionid)++;
- sprintf(ifx,"%s%x",
- user,
- IFXG(connectionid));
-
- EXEC SQL CONNECT TO :host AS :ifx
- USER :user USING :passwd
- WITH CONCURRENT TRANSACTION;
-
- if (ifx_check() == IFX_ERROR) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,ifx_error(ifx));
- free(ifx);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- /* hash it up */
- new_le.type = IFXG(le_plink);
- new_le.ptr = ifx;
- if (zend_hash_update(plist, hashed_details,
- hashed_details_length+1,
- (void *) &new_le, sizeof(list_entry), NULL)==FAILURE) {
- free(ifx);
- efree(hashed_details);
- RETURN_FALSE;
- }
- IFXG(num_persistent)++;
- IFXG(num_links)++;
- } else { /* we do */
- if (le->type != IFXG(le_plink)) {
- RETURN_FALSE;
- }
- /* ensure that the link did not die */
- ifx = le->ptr;
- EXEC SQL SET CONNECTION :ifx;
- if (ifx_check() == IFX_ERROR) {
- /* the link died */
- ifx = le->ptr; /* reconnect silently */
- EXEC SQL CONNECT TO :host AS :ifx
- USER :user USING :passwd
- WITH CONCURRENT TRANSACTION;
-
- if (ifx_check() == IFX_ERROR) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,
- "Informix: Link to server lost, unable to reconnect (%s)",
- ifx_error(ifx));
- zend_hash_del(plist, hashed_details,
- hashed_details_length+1);
- efree(hashed_details);
- RETURN_FALSE;
- }
- }
- ifx = le->ptr;
- }
- ZEND_REGISTER_RESOURCE(return_value, ifx, IFXG(le_plink));
- } else { /* non persistent */
- list_entry *index_ptr,new_index_ptr;
-
- /* first we check the hash for the hashed_details key. if it exists,
- * it should point us to the right offset where the actual ifx link sits.
- * if it doesn't, open a new ifx link, add it to the resource list,
- * and add a pointer to it with hashed_details as the key.
- */
- if (zend_hash_find(list,hashed_details,hashed_details_length+1,
- (void **) &index_ptr) == SUCCESS) {
- int type,link;
- void *ptr;
-
- if (index_ptr->type != le_index_ptr) {
- RETURN_FALSE;
- }
- link = (int) index_ptr->ptr;
- ptr = zend_list_find(link,&type); /* check if the link is still there */
- if (ptr && (type==IFXG(le_link) || type==IFXG(le_plink))) {
- zend_list_addref(link);
- return_value->value.lval = link;
- php3_ifx_set_default_link(link);
- return_value->type = IS_RESOURCE;
- efree(hashed_details);
- return;
- } else {
- zend_hash_del(list,hashed_details,hashed_details_length+1);
- }
- }
- if (IFXG(max_links) != -1 &&
- IFXG(num_links) >=
- IFXG(max_links)) {
- php_error(E_WARNING,
- "Informix: Too many open links (%d)",
- IFXG(num_links));
- efree(hashed_details);
- RETURN_FALSE;
- }
- ifx = (char *) emalloc(sizeof(IFX));
- IFXG(connectionid)++;
- sprintf(ifx,"connec%x",
- IFXG(connectionid));
-
- EXEC SQL CONNECT TO :host AS :ifx
- USER :user USING :passwd
- WITH CONCURRENT TRANSACTION;
- if (ifx_check() == IFX_ERROR) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"ifx_pconnect : %s", ifx_error(ifx));
- efree(hashed_details);
- efree(ifx);
- RETURN_FALSE;
- }
-
- /* add it to the list */
- ZEND_REGISTER_RESOURCE(return_value, ifx, IFXG(le_link));
-
- /* add it to the hash */
- new_index_ptr.ptr = (void *) return_value->value.lval;
- new_index_ptr.type = le_index_ptr;
- if (zend_hash_update(list,
- hashed_details,
- hashed_details_length+1,
- (void *) &new_index_ptr,
- sizeof(list_entry), NULL) == FAILURE) {
- efree(hashed_details);
- RETURN_FALSE;
- }
- IFXG(num_links)++;
- }
- efree(hashed_details);
- php3_ifx_set_default_link(return_value->value.lval);
-}
-
-
-/* {{{ proto int ifx_connect([string database[, string userid[, string password]]])
- connects to database using userid/password, returns connection id */
-PHP_FUNCTION(ifx_connect)
-{
- php3_ifx_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
-}
-/* }}} */
-
-/* {{{ proto int ifx_pconnect([string database[, string userid[, string password]]])
- connects to database using userid/password, returns connection id */
-PHP_FUNCTION(ifx_pconnect)
-{
- php3_ifx_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
-}
-/* }}} */
-
-static int php3_ifx_get_default_link(INTERNAL_FUNCTION_PARAMETERS)
-{
- IFXLS_FETCH();
-
- if (IFXG(default_link)==-1) { /* no link opened yet, implicitly open one */
- ht = 0;
- php3_ifx_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
- }
- return IFXG(default_link);
-}
-
-/* ----------------------------------------------------------------------
-** int ifx_close(int $connid)
-**
-** closes connection $connid
-** always returns TRUE
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifx_close(int connid)
- close informix connection */
-PHP_FUNCTION(ifx_close)
-{
- pval *ifx_link;
- int id;
-
-EXEC SQL BEGIN DECLARE SECTION;
- char *ifx;
-EXEC SQL END DECLARE SECTION;
-
- IFXLS_FETCH();
-
-
-
- id = -1;
-
- switch (ARG_COUNT(ht)) {
- case 0:
- id = IFXG(default_link);
- break;
- case 1:
- if (getParameters(ht, 1, &ifx_link)==FAILURE) {
- RETURN_FALSE;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- IFXG(sv_sqlcode) = 0;
-
- ifx = zend_fetch_resource_ex(ifx_link, id, "IFX link", 2, IFXG(le_link), IFXG(le_plink));
- ZEND_VERIFY_RESOURCE(ifx);
-
- EXEC SQL SET CONNECTION :ifx;
- EXEC SQL close database;
- EXEC SQL DISCONNECT CURRENT;
-
- zend_list_delete(id);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* ----------------------------------------------------------------------
-** int ifx_query(string $query, int $connid,
-** int $cursortype, $blobidarray)
-** $cursortype and $blobidarray are optional
-**
-** executes query $query on connection $connid
-** for select queries a cursor is declared and opened
-** non-select queries are "execute immediate"
-** select queries accept an optional cursortype param:
-** IFX_SCROLL, IFX_HOLD (or'ed mask)
-** non-select queries accept an optional "blobarryid" parameter
-** blobsupport: mark the blob-column(s) with ? in the insert/update query
-** and add a blob-id-array-functionparameter
-** select queries return "blob-ids" for blob columns
-** except if text/byteasvarchar is set
-** example: ifx_query("insert into catalog (stock_num, manu_code,
-** cat_descr,cat_picture) values(1,'HRO',?,?)",$cid,$bidarray);
-**
-** returns a "result id" on success or FALSE on error
-** also sets "affected_rows for retrieval by ifx_affected_rows()
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifx_query(string query, int connid, [int cursortype], [array idarray])
- perform a query on a given connection */
-PHP_FUNCTION(ifx_query)
-{
- pval *query,*ifx_link, *cursortype, *dummy;
- int id;
- IFX_RES *Ifx_Result;
-
-EXEC SQL BEGIN DECLARE SECTION;
- char *ifx; /* connection ID */
- char cursorid[32]; /* query cursor id */
- char statemid[32]; /* statement id */
- char descrpid[32]; /* descriptor id */
- char *statement; /* query text */
- int fieldcount; /* field count */
- int i; /* field index */
- short fieldtype;
- loc_t *locator;
- int loc_t_type=CLOCATORTYPE; /* WORKAROUND:TYPE=CLOCATORTYPE doesn't work, */
- int sqlchar_type=SQLCHAR; /* don't ask me, why. */
- char *char_tmp;
- long len;
- int indicator;
-$ifdef HAVE_IFX_IUS;
- fixed binary 'blob' ifx_lo_t *slocator;
-$endif;
-
-EXEC SQL END DECLARE SECTION;
-
- char *blobfilename;
- int locind;
- int ctype;
- int affected_rows;
- long sqlerrd[6];
- int e;
- int query_type;
- int cursoryproc;
-
- IFXLS_FETCH();
-
- if(ARG_COUNT(ht)<2) {
- WRONG_PARAM_COUNT;
- }
-
- IFXG(sv_sqlcode) = 0;
-
- /* get the first 2 parameters,
- php4 insists on the correct number of arguments */
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &query, &ifx_link)==FAILURE)
- RETURN_FALSE;
- break;
- case 3:
- if (getParameters(ht, 3, &query, &ifx_link, &dummy)==FAILURE)
- RETURN_FALSE;
- break;
- case 4:
- if (getParameters(ht, 4, &query, &ifx_link, &dummy, &dummy)==FAILURE)
- RETURN_FALSE;
- break;
- }
-
- id = -1;
- ifx = zend_fetch_resource_ex(ifx_link, id, "IFX link", 2, IFXG(le_link), IFXG(le_plink));
- ZEND_VERIFY_RESOURCE(ifx);
-
-
- affected_rows = -1; /* invalid */
-
- convert_to_string(query);
-
- statement = query->value.str.val;
- IFXG(cursorid)++;
- sprintf(statemid, "statem%x", IFXG(cursorid));
- sprintf(cursorid, "cursor%x", IFXG(cursorid));
- sprintf(descrpid, "descrp%x", IFXG(cursorid));
-
- EXEC SQL set connection :ifx;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Set connection %s fails (%s)",
- ifx,
- ifx_error(ifx));
- RETURN_FALSE;
- }
- EXEC SQL PREPARE :statemid FROM :statement;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Prepare fails (%s)",
- ifx_error(ifx));
- RETURN_FALSE;
- }
-
- affected_rows = sqlca.sqlerrd[0]; /* save estimated affected rows */
- for (e = 0; e < 6; e++) sqlerrd[e] = sqlca.sqlerrd[e];
-
- EXEC SQL ALLOCATE DESCRIPTOR :descrpid WITH MAX 256;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Allocate desciptor <%s> fails (%s)",
- descrpid,
- ifx_error(ifx));
- EXEC SQL free :statemid;
- RETURN_FALSE;
- }
- EXEC SQL DESCRIBE :statemid USING SQL DESCRIPTOR :descrpid;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Describe fails (%s)",
- ifx_error(ifx));
- EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
- EXEC SQL free :statemid;
- RETURN_FALSE;
- }
-
- query_type = sqlca.sqlcode;
-
- Ifx_Result = (IFX_RES *)emalloc(sizeof(IFX_RES));
- if (Ifx_Result == NULL) {
- php_error(E_WARNING,"Out of memory allocating IFX_RES");
- EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
- EXEC SQL free :statemid;
- RETURN_FALSE;
- }
-
- /* initialize result data structure */
-
- Ifx_Result->rowid = 0;
- strcpy(Ifx_Result->connecid, ifx);
- strcpy(Ifx_Result->descrpid, descrpid);
- for (i = 0; i < MAX_RESID; ++i)
- Ifx_Result->res_id[i] = -1;
-
- cursoryproc = 0;
- if (query_type == SQ_EXECPROC) {
- EXEC SQL GET DESCRIPTOR :descrpid :i = COUNT;
- if (i > 0) {
- cursoryproc = 1;
- }
- }
-
- Ifx_Result->iscursory = -1; /* prevent ifx_do */
- Ifx_Result->paramquery=0;
-
- if ((query_type != 0) && (!cursoryproc)) { /* NO RESULT SET */
- /* ##
- ## NONSELECT-STATEMENT
- ##
- */
- pval *pblobidarr, **tmp;
-
- Ifx_Result->iscursory = 0;
-
- strcpy(Ifx_Result->cursorid, "");
- strcpy(Ifx_Result->descrpid, descrpid);
- strcpy(Ifx_Result->statemid, statemid);
-
- if(ARG_COUNT(ht)>3) {
- WRONG_PARAM_COUNT;
- }
-
- if(ARG_COUNT(ht)==3) {
- if (getParameters(ht, 3, &dummy, &dummy, &pblobidarr) == FAILURE) {
- php_error(E_WARNING,"Can't get blob array param");
- EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
- EXEC SQL free :statemid;
- efree(Ifx_Result);
- RETURN_FALSE;
- }
- if (pblobidarr->type != IS_ARRAY) {
- php_error(E_WARNING,"blob-parameter not an array");
- EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
- EXEC SQL free :statemid;
- efree(Ifx_Result);
- RETURN_FALSE;
- }
-
- zend_hash_internal_pointer_reset(pblobidarr->value.ht);
- i=1;
- while (zend_hash_get_current_data(pblobidarr->value.ht,
- (void **) &tmp) == SUCCESS) {
- convert_to_long(*tmp);
- if ((query_type == SQ_UPDATE) || (query_type == SQ_UPDALL)) {
- EXEC SQL SET DESCRIPTOR :descrpid COUNT = :i;
- }
- /* TEXT/BYTE */
- if(php3_intifx_getType((int)(*tmp)->value.lval,list)==TYPE_BLTEXT || php3_intifx_getType((int)(*tmp)->value.lval,list)==TYPE_BLBYTE) {
- locator=php3_intifx_get_blobloc((int)((*tmp)->value.lval),list);
- if(locator==NULL) {
- php_error(E_WARNING,"%d is not a Informix blob-result index",
- (int)((*tmp)->value.lval));
- EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
- EXEC SQL free :statemid;
- efree(Ifx_Result);
- RETURN_FALSE;
- }
- if(locator->loc_loctype==LOCFNAME) {
- locator->loc_oflags=LOC_RONLY;
- }
- EXEC SQL SET DESCRIPTOR :descrpid VALUE :i
- DATA= :*locator,
- TYPE= :loc_t_type;
- }
-
- /* CHAR */
- if(php3_intifx_getType((int)(*tmp)->value.lval,list)==TYPE_CHAR) {
- len=php3_intifx_get_char((int)((*tmp)->value.lval),list,&char_tmp);
- indicator=0;
- if(char_tmp==NULL || len<0)
- indicator=-1;
- len++;
- EXEC SQL SET DESCRIPTOR :descrpid VALUE :i
- DATA= :char_tmp,
- LENGTH= :len,
- INDICATOR= :indicator,
- TYPE= :sqlchar_type;
- }
-
-
- i++;
- zend_hash_move_forward(pblobidarr->value.ht);
- }
- Ifx_Result->paramquery=1;
- EXEC SQL EXECUTE :statemid USING SQL DESCRIPTOR :descrpid;
- } else {
- EXEC SQL EXECUTE :statemid;
- }
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Execute immediate fails : %s (%s)",
- statement,
- ifx_error(ifx));
- efree(Ifx_Result);
- EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
- EXEC SQL free :statemid;
- RETURN_FALSE;
- }
- Ifx_Result->affected_rows = sqlca.sqlerrd[2]; /* really affected */
- for (e = 0; e < 6; e++) Ifx_Result->sqlerrd[e] = sqlca.sqlerrd[e];
- } else {
- /* ##
- ** SELECT-STATEMENT
- **
- */
-
- ctype = 0; /* preset */
-
- switch(ARG_COUNT(ht)) {
- case 2:
- break;
- case 3:
- if (getParameters(ht, 3,
- &dummy,
- &dummy,
- &cursortype)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(cursortype);
- ctype = cursortype->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
-
-
- Ifx_Result->affected_rows = affected_rows; /* saved estimated from prepare */
- for (e = 0; e < 6; e++) Ifx_Result->sqlerrd[e] = sqlerrd[e];
-
- EXEC SQL GET DESCRIPTOR :descrpid :fieldcount = COUNT;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Can not get descriptor %s (%s)",
- descrpid,
- ifx_error(ifx));
- EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
- EXEC SQL free :statemid;
- efree(Ifx_Result);
- RETURN_FALSE;
- }
- Ifx_Result->numcols = fieldcount;
-
- Ifx_Result->isscroll = Ifx_Result->ishold = 0;
- if (ctype & IFX_SCROLL)
- Ifx_Result->isscroll = 1;
- if (ctype & IFX_HOLD)
- Ifx_Result->ishold = 1;
-
- if (Ifx_Result->isscroll)
- if (Ifx_Result->ishold)
- EXEC SQL DECLARE :cursorid SCROLL CURSOR WITH HOLD FOR :statemid;
- else
- EXEC SQL DECLARE :cursorid SCROLL CURSOR FOR :statemid;
- else
- if (Ifx_Result->ishold)
- EXEC SQL DECLARE :cursorid CURSOR WITH HOLD FOR :statemid;
- else
- EXEC SQL DECLARE :cursorid CURSOR FOR :statemid;
-
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Declare cursor fails (%s)", ifx_error(ifx));
- efree(Ifx_Result);
- EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
- EXEC SQL free :statemid;
- RETURN_FALSE;
- }
- EXEC SQL OPEN :cursorid;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Open cursor fails (%s)", ifx_error(ifx));
- efree(Ifx_Result);
- EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
- EXEC SQL free :statemid;
- EXEC SQL free :cursorid;
- RETURN_FALSE;
- }
- strcpy(Ifx_Result->cursorid, cursorid);
- strcpy(Ifx_Result->descrpid, descrpid);
- strcpy(Ifx_Result->statemid, statemid);
-
- /* check for text/blob columns */
-
-
- locind = 0;
- for (i = 1; i <= fieldcount; ++i) {
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :fieldtype = TYPE;
- if (
- (fieldtype == SQLTEXT) || (fieldtype == SQLBYTES)
-$ifdef HAVE_IFX_IUS;
- || (fieldtype==SQLUDTFIXED)
-$endif;
- ) {
-
- int bid = 0;
- if(fieldtype==SQLTEXT) {
- bid=php3_intifx_create_blob(TYPE_BLTEXT,BLMODE_INMEM,"",-1,list);
- locator=php3_intifx_get_blobloc(bid,list);
- EXEC SQL SET DESCRIPTOR :descrpid VALUE :i DATA = :*locator;
- }
- if(fieldtype==SQLBYTES) {
- if(IFXG(blobinfile)==0) {
- bid=php3_intifx_create_blob(TYPE_BLBYTE,BLMODE_INMEM,"",-1,list);
- locator=php3_intifx_get_blobloc(bid,list);
- } else {
- blobfilename=php3_intifx_create_tmpfile(i);
- bid=php3_intifx_create_blob(
- TYPE_BLBYTE,BLMODE_INFILE,
- blobfilename,strlen(blobfilename),list);
- locator=php3_intifx_get_blobloc(bid,list);
- locator->loc_oflags=LOC_WONLY;
- }
- EXEC SQL SET DESCRIPTOR :descrpid VALUE :i DATA = :*locator;
- }
-$ifdef HAVE_IFX_IUS;
- if(fieldtype==SQLUDTFIXED) {
- bid=php3_intifxus_new_slob(list);
- slocator=php3_intifxus_get_slobloc(bid,list);
- EXEC SQL SET DESCRIPTOR :descrpid VALUE :i DATA = :*slocator;
- }
-$endif;
- Ifx_Result->res_id[locind]=bid;
- ++locind;
- }
- }
-
- }
-
- ZEND_REGISTER_RESOURCE(return_value, Ifx_Result, IFXG(le_result));
-}
-/* }}} */
-
-
-/* ----------------------------------------------------------------------
-** int ifx_prepare(string $query, int $connid,
-** int $cursortype, array $blobidarry)
-**
-** $hold, $scroll are optional and valid only for select queries
-** $blobidarray is optional, an array of blob id's
-**
-** prepares query $query on connection $connid
-** select queries accept an optional cursortype param: IFX_SCROLL, IFX_HOLD (or'ed mask)
-** blobsupport: mark the blob-column with ? and add a blob-id-functionparameter
-** example: ifx_query("insert into catalog (stock_num, manu_code ,cat_descr,
-** cat_picture) values(1,'HRO',?,?)",$cid,$bid1,$bid2);
-**
-** returns a "result id" on success or FALSE on error
-** also sets "affected_rows for retrieval by ifx_affected_rows
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifx_prepare(string query, int connid, [int cursortype], [array idarray])
- prepare a query on a given connection */
-PHP_FUNCTION(ifx_prepare)
-{
-
- pval *query,*ifx_link, *cursortype, *dummy;
- int id;
- IFX_RES *Ifx_Result;
-
-EXEC SQL BEGIN DECLARE SECTION;
- char *ifx; /* connection ID */
- char cursorid[32]; /* query cursor id */
- char statemid[32]; /* statement id */
- char descrpid[32]; /* descriptor id */
- char *statement; /* query text */
- int fieldcount; /* field count */
- int i; /* field index */
- loc_t *locator;
- int loc_t_type=CLOCATORTYPE; /* WORKAROUND: TYPE=CLOCATORTYPE doesn't work, */
- int sqlchar_type=SQLCHAR; /* don't ask me, why. */
- char *char_tmp;
- long len;
- int indicator;
- long sqlerrd[6];
- int e;
-
-
-EXEC SQL END DECLARE SECTION;
-
- int ctype;
- int affected_rows;
- int query_type;
- int cursoryproc;
-
- IFXLS_FETCH();
-
- if(ARG_COUNT(ht)<2) {
- WRONG_PARAM_COUNT;
- }
-
- IFXG(sv_sqlcode) = 0;
-
- /* get the first 2 parameters,
- php4 insists on the correct number of arguments */
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &query, &ifx_link)==FAILURE)
- RETURN_FALSE;
- break;
- case 3:
- if (getParameters(ht, 3, &query, &ifx_link, &dummy)==FAILURE)
- RETURN_FALSE;
- break;
- case 4:
- if (getParameters(ht, 4, &query, &ifx_link, &dummy, &dummy)==FAILURE)
- RETURN_FALSE;
- break;
- }
-
- id = -1;
- ifx = zend_fetch_resource_ex(ifx_link, id, "IFX link", 2, IFXG(le_link), IFXG(le_plink));
- ZEND_VERIFY_RESOURCE(ifx);
-
- affected_rows = -1; /* invalid */
-
-
- convert_to_string(query);
-
- statement = query->value.str.val;
- IFXG(cursorid)++;
- sprintf(statemid, "statem%x", IFXG(cursorid));
- sprintf(cursorid, "cursor%x", IFXG(cursorid));
- sprintf(descrpid, "descrp%x", IFXG(cursorid));
-
- EXEC SQL set connection :ifx;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Set connection %s fails (%s)",
- ifx,
- ifx_error(ifx));
- RETURN_FALSE;
- }
- EXEC SQL PREPARE :statemid FROM :statement;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Prepare fails (%s)",
- ifx_error(ifx));
- RETURN_FALSE;
- }
- affected_rows = sqlca.sqlerrd[0]; /* save estimated affected rows */
- for (e = 0; e < 6; e++) sqlerrd[e] = sqlca.sqlerrd[e];
- EXEC SQL ALLOCATE DESCRIPTOR :descrpid WITH MAX 256;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Allocate desciptor <%s> fails (%s)",
- descrpid,
- ifx_error(ifx));
- EXEC SQL free :statemid;
- RETURN_FALSE;
- }
- EXEC SQL DESCRIBE :statemid USING SQL DESCRIPTOR :descrpid;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Describe fails (%s)",
- ifx_error(ifx));
- EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
- EXEC SQL free :statemid;
- RETURN_FALSE;
- }
-
- query_type = sqlca.sqlcode;
-
- Ifx_Result = (IFX_RES *)emalloc(sizeof(IFX_RES));
- if (Ifx_Result == NULL) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Out of memory allocating IFX_RES");
- EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
- EXEC SQL free :statemid;
- RETURN_FALSE;
- }
-
- /* initialize result data structure */
-
- Ifx_Result->rowid = 0;
- strcpy(Ifx_Result->connecid, ifx);
- strcpy(Ifx_Result->descrpid, descrpid);
- strcpy(Ifx_Result->statemid, statemid);
- for (i = 0; i < MAX_RESID; ++i)
- Ifx_Result->res_id[i] = -1;
-
- cursoryproc = 0;
- if (query_type == SQ_EXECPROC) {
- EXEC SQL GET DESCRIPTOR :descrpid :i = COUNT;
- if (i > 0) {
- cursoryproc = 1;
- }
- }
-
- Ifx_Result->iscursory = -1; /* prevent ifx_do */
- Ifx_Result->paramquery=0;
-
- if ((query_type != 0) && (!cursoryproc)) { /* NO RESULT SET */
- /* ##
- ## NONSELECT-STATEMENT
- ##
- */
- pval *pblobidarr, **tmp;
-
- Ifx_Result->iscursory = 0;
-
- strcpy(Ifx_Result->cursorid, cursorid);
- strcpy(Ifx_Result->cursorid, "");
- strcpy(Ifx_Result->descrpid, descrpid);
-
-
- if(ARG_COUNT(ht)>3) {
- WRONG_PARAM_COUNT;
- }
- if(ARG_COUNT(ht)==3) {
- Ifx_Result->paramquery=1;
- if (getParameters(ht, 3, &dummy, &dummy,&pblobidarr) == FAILURE) {
- php_error(E_WARNING,"Can't get blob array param");
- EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
- EXEC SQL free :statemid;
- efree(Ifx_Result);
- RETURN_FALSE;
- }
- if(pblobidarr->type != IS_ARRAY) {
- php_error(E_WARNING,"blob-parameter not an array");
- EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
- EXEC SQL free :statemid;
- efree(Ifx_Result);
- RETURN_FALSE;
- }
- zend_hash_internal_pointer_reset(pblobidarr->value.ht);
- i=1;
- while (zend_hash_get_current_data(pblobidarr->value.ht,
- (void **) &tmp) == SUCCESS) {
- convert_to_long(*tmp);
- if ((query_type == SQ_UPDATE) || (query_type == SQ_UPDALL)) {
- EXEC SQL SET DESCRIPTOR :descrpid COUNT = :i;
- }
- /* TEXT/BYTE */
- if(php3_intifx_getType((int)((*tmp)->value.lval),list)==TYPE_BLTEXT || php3_intifx_getType((int)((*tmp)->value.lval),list)==TYPE_BLBYTE) {
- locator=php3_intifx_get_blobloc((int)((*tmp)->value.lval),list);
- if(locator==NULL) {
- php_error(E_WARNING,"%d is not a Informix blob-result index",
- (int)((*tmp)->value.lval));
- EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
- EXEC SQL free :statemid;
- efree(Ifx_Result);
- RETURN_FALSE;
- }
- if(locator->loc_loctype==LOCFNAME) {
- locator->loc_oflags=LOC_RONLY;
- }
- EXEC SQL SET DESCRIPTOR :descrpid VALUE :i
- DATA= :*locator,
- TYPE=:loc_t_type;
- }
- /* CHAR */
- if(php3_intifx_getType((int)((*tmp)->value.lval),list)==TYPE_CHAR) {
- len=php3_intifx_get_char((int)((*tmp)->value.lval),list,&char_tmp);
- indicator=0;
- if(char_tmp==NULL || len<0)
- indicator=-1;
- len++;
- EXEC SQL SET DESCRIPTOR :descrpid VALUE :i
- DATA= :char_tmp,
- LENGTH= :len,
- INDICATOR= :indicator,
- TYPE= :sqlchar_type;
- }
-
- i++;
- zend_hash_move_forward(pblobidarr->value.ht);
- } /* while */
- } /* if paramquery */
- Ifx_Result->affected_rows = affected_rows; /* saved estimated from prepare */
- for (e = 0; e < 6; e++) Ifx_Result->sqlerrd[e] = sqlerrd[e];
- } else {
- /* ##
- ** SELECT-STATEMENT
- **
- */
-
- ctype = 0;; /* preset */
-
- switch(ARG_COUNT(ht)) {
- case 2:
- break;
- case 3:
- if (getParameters(ht, 3,
- &dummy,
- &dummy,
- &cursortype)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(cursortype);
- ctype = cursortype->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- } /* case */
- strcpy(Ifx_Result->cursorid, cursorid);
-
- Ifx_Result->iscursory = 1;
- Ifx_Result->affected_rows = affected_rows; /* saved estimated from prepare */
- for (e = 0; e < 6; e++) Ifx_Result->sqlerrd[e] = sqlerrd[e];
- EXEC SQL GET DESCRIPTOR :descrpid :fieldcount = COUNT;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Can not get descriptor %s (%s)",
- descrpid,
- ifx_error(ifx));
- EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
- EXEC SQL free :statemid;
- efree(Ifx_Result);
- RETURN_FALSE;
- }
- Ifx_Result->numcols = fieldcount;
-
- Ifx_Result->isscroll = Ifx_Result->ishold = 0;
- if (ctype & IFX_SCROLL)
- Ifx_Result->isscroll = 1;
- if (ctype & IFX_HOLD)
- Ifx_Result->ishold = 1;
-
- } /* if select */
-
- ZEND_REGISTER_RESOURCE(return_value, Ifx_Result, IFXG(le_result));
-
-}
-/* }}} */
-
-/* ----------------------------------------------------------------------
-** int ifx_do(int $resultid)
-**
-** executes a previously prepared query or opens a cursor for it
-**
-** returns TRUE on success, false on error
-** does NOT free $resultid on error !!!
-**
-** also sets (real) affected_rows for non-select statements
-** for retrieval by ifx_affected_rows
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifx_do(int resultid)
- executes a previously prepared query or opens a cursor for it */
-PHP_FUNCTION(ifx_do)
-{
- pval *result;
- IFX_RES *Ifx_Result;
-
-EXEC SQL BEGIN DECLARE SECTION;
- char *ifx; /* connection ID */
- char *cursorid; /* query cursor id */
- char *statemid; /* statement id */
- char *descrpid; /* descriptor id */
- int fieldcount; /* field count */
- int i; /* field index */
- short fieldtype;
- loc_t *locator;
-
- int e;
-
-$ifdef HAVE_IFX_IUS;
- fixed binary 'blob' ifx_lo_t *slocator;
-$endif;
-
-EXEC SQL END DECLARE SECTION;
-
- int locind;
- char *blobfilename;
-
- IFXLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 0:
- WRONG_PARAM_COUNT;
- break;
- case 1:
- if (getParameters(ht, 1, &result)==FAILURE) {
- RETURN_FALSE;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
-
- IFXG(sv_sqlcode) = 0;
-
- ifx = Ifx_Result->connecid;
- cursorid = Ifx_Result->cursorid;
- statemid = Ifx_Result->statemid;
- descrpid = Ifx_Result->descrpid;
- fieldcount = Ifx_Result->numcols;
-
- EXEC SQL set connection :ifx;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Set connection %s fails (%s)",
- ifx,
- ifx_error(ifx));
- RETURN_FALSE;
- }
-
- if (Ifx_Result->iscursory < 0) {
- php_error(E_WARNING, "Resultindex %d is not a prepared query",
- result->value.lval);
- RETURN_FALSE;
- }
- if (Ifx_Result->iscursory==0) { /* execute immediate */
- if(Ifx_Result->paramquery!=0) {
- EXEC SQL EXECUTE :statemid USING SQL DESCRIPTOR :descrpid;
- } else {
- EXEC SQL EXECUTE :statemid;
- }
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Execute immediate fails : %s ",
- ifx_error(ifx));
- RETURN_FALSE;
- }
- Ifx_Result->affected_rows = sqlca.sqlerrd[2]; /* really affected */
- for (e = 0; e < 6; e++) Ifx_Result->sqlerrd[e] = sqlca.sqlerrd[e];
- } else { /* open cursor */
- if (Ifx_Result->isscroll)
- if (Ifx_Result->ishold)
- EXEC SQL DECLARE :cursorid SCROLL CURSOR WITH HOLD FOR :statemid;
- else
- EXEC SQL DECLARE :cursorid SCROLL CURSOR FOR :statemid;
- else
- if (Ifx_Result->ishold)
- EXEC SQL DECLARE :cursorid CURSOR WITH HOLD FOR :statemid;
- else
- EXEC SQL DECLARE :cursorid CURSOR FOR :statemid;
-
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Declare cursor fails (%s)", ifx_error(ifx));
- RETURN_FALSE;
- }
- EXEC SQL OPEN :cursorid;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Open cursor fails (%s)", ifx_error(ifx));
- RETURN_FALSE;
- }
-
- /* check for text/blob columns */
-
-
- locind = 0;
- for (i = 1; i <= fieldcount; ++i) {
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :fieldtype = TYPE;
- if (
- (fieldtype == SQLTEXT) || (fieldtype == SQLBYTES)
-$ifdef HAVE_IFX_IUS;
- || (fieldtype==SQLUDTFIXED)
-$endif;
- ) {
-
- int bid = 0;
- if(fieldtype==SQLTEXT) {
- bid=php3_intifx_create_blob(TYPE_BLTEXT,BLMODE_INMEM,"",-1,list);
- locator=php3_intifx_get_blobloc(bid,list);
- EXEC SQL SET DESCRIPTOR :descrpid VALUE :i DATA = :*locator;
- }
- if(fieldtype==SQLBYTES) {
- if(IFXG(blobinfile)==0) {
- bid=php3_intifx_create_blob(TYPE_BLBYTE,BLMODE_INMEM,"",-1,list);
- locator=php3_intifx_get_blobloc(bid,list);
- } else {
- blobfilename=php3_intifx_create_tmpfile(i);
- bid=php3_intifx_create_blob(
- TYPE_BLBYTE,BLMODE_INFILE,
- blobfilename,strlen(blobfilename),list);
- locator=php3_intifx_get_blobloc(bid,list);
- locator->loc_oflags=LOC_WONLY;
- }
- EXEC SQL SET DESCRIPTOR :descrpid VALUE :i DATA = :*locator;
- }
-$ifdef HAVE_IFX_IUS;
- if(fieldtype==SQLUDTFIXED) {
- bid=php3_intifxus_new_slob(list);
- slocator=php3_intifxus_get_slobloc(bid,list);
- EXEC SQL SET DESCRIPTOR :descrpid VALUE :i DATA = :*slocator;
- }
-$endif;
- Ifx_Result->res_id[locind]=bid;
- ++locind;
- }
- }
-
- } /* end open cursor */
-
- RETURN_TRUE;
-
-}
-/* }}} */
-
-
-
-
-/* ----------------------------------------------------------------------
-** string ifx_error([int connection_id]);
-**
-** returns the Informix error codes (SQLSTATE & SQLCODE)
-**
-** connection id is not checked, but remains for compatibility
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto string ifx_error();
- returns the Informix error codes (SQLSTATE & SQLCODE) */
-PHP_FUNCTION(ifx_error)
-{
- pval *ifx_link;
- int id;
- IFXLS_FETCH();
-
-
- switch(ARG_COUNT(ht)) {
- case 0:
- id = IFXG(default_link);
- break;
- case 1:
- if (getParameters(ht, 1, &ifx_link)==FAILURE) {
- RETURN_FALSE;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- RETURN_STRING(ifx_error(0),0); /* ifx_error returns emalloced string */
-}
-/* }}} */
-
-/* ----------------------------------------------------------------------
-** string ifx_errormsg([int errorcode])
-**
-** returns the Informix errormessage associated with
-** the most recent Informix error if SQLCODE is nonzero, or,
-** when the optional "errocode" param is present, the errormessage
-** corresponding to "errorcode".
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto string ifx_errormsg([int errorcode])
- returns the Informix errormessage associated with */
-PHP_FUNCTION(ifx_errormsg)
-{
- pval *errcode;
-
- int ifx_errorcode;
- int msglen, maxmsglen;
- char *ifx_errmsg;
- char * returnmsg;
-
- IFXLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 0:
- if (IFXG(sv_sqlcode) == 0)
- ifx_errorcode = SQLCODE;
- else
- ifx_errorcode = IFXG(sv_sqlcode);
- break;
- case 1:
- if (getParameters(ht, 1, &errcode)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(errcode);
- ifx_errorcode = errcode->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- maxmsglen = 255;
- ifx_errmsg = (char *)malloc(maxmsglen+1);
- if (ifx_errorcode != 0) {
- rgetlmsg(ifx_errorcode, ifx_errmsg, maxmsglen, &msglen);
- if (msglen > maxmsglen) {
- maxmsglen = msglen + 1;
- free(ifx_errmsg);
- ifx_errmsg = (char *)malloc(maxmsglen + 1);
- rgetlmsg(ifx_errorcode, ifx_errmsg, maxmsglen, &msglen);
- }
- } else {
- ifx_errmsg[0] = 0;
- }
-
- returnmsg = (char *) emalloc(strlen(ifx_errmsg) + 128);
- sprintf(returnmsg,ifx_errmsg, sqlca.sqlerrm);
- free(ifx_errmsg);
-
- RETURN_STRING(returnmsg,0); /* do not dup, emalloced ! */
-}
-/* }}} */
-
-/* --------------------------------------------------------------
-** int ifx_affected_rows(int $resultid)
-**
-** returns the number of rows affected by query $resultid
-**
-** for selects : estimated number of rows (sqlerrd[0])
-** for insert/update/delete : real number (sqlerrd[2])
-** ---------------------------------------------------------------
-*/
-
-/* {{{ proto int ifx_affected_rows(int resultid)
- returns the number of rows affected by query identified by resultid */
-PHP_FUNCTION(ifx_affected_rows)
-{
- pval *result;
- IFX_RES *Ifx_Result;
-
- IFXLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 0:
- WRONG_PARAM_COUNT;
- break;
- case 1:
- if (getParameters(ht, 1, &result)==FAILURE) {
- RETURN_FALSE;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- IFXG(sv_sqlcode )= 0;
-
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
-
- return_value->value.lval = Ifx_Result->affected_rows;
- return_value->type = IS_LONG;
-}
-/* }}} */
-
-/* ----------------------------------------------------------------------
-** array ifx_fetch_row(int $resultid, [mixed $position])
-**
-** fetches the next row, or if using a scroll cursor, and $position
-** is present, the row as given in $position, into an associative
-** array with the fieldnames as key
-**
-** returns FALSE on error
-**
-** $position can be : "FIRST", "NEXT", "LAST", "PREVIOUS", "CURRENT"
-** or an absolute row number
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto array ifx_fetch_row(int resultid, [mixed position])
- fetches the next row or <position> row if using a scroll cursor */
-PHP_FUNCTION(ifx_fetch_row)
-{
- pval *result, *position;
- IFX_RES *Ifx_Result;
-
-EXEC SQL BEGIN DECLARE SECTION;
- char *ifx; /* connection ID */
- char *cursorid; /* query cursor id */
- char *statemid; /* statement id */
- char *descrpid; /* descriptor id */
- int fieldcount; /* field count */
- int i; /* an index */
- char fieldname[64]; /* fieldname */
- short fieldtype; /* field type */
- int fieldleng; /* field length */
-
-$ifdef HAVE_IFX_IUS;
- ifx_int8_t int8_var;
- lvarchar *lvar_tmp;
-$endif;
-
- short indicator;
- int int_data;
- char *char_data;
- long date_data;
- interval intvl_data = {0};
- datetime dt_data = {0};
- decimal dec_data = {0};
- short short_data;
- loc_t *locator_b;
-
-$ifdef HAVE_IFX_IUS;
- fixed binary 'blob' ifx_lo_t *slocator;
-$endif;
-
- float float_data;
- double double_data;
- int fetch_row;
-EXEC SQL END DECLARE SECTION;
-
- int num_fields;
- int locind,bid,bid_b;
-
- char string_data[256];
- long long_data;
- char *p;
- char *blobfilename;
-
- char *fetch_pos;
-
- char *nullstr;
-
- IFXLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 0:
- WRONG_PARAM_COUNT;
- break;
- case 1:
- if (getParameters(ht, 1, &result)==FAILURE) {
- RETURN_FALSE;
- }
- fetch_pos = NULL;
- fetch_row = 0;
- break;
- case 2:
- if (getParameters(ht, 2, &result, &position)==FAILURE) {
- RETURN_FALSE;
- }
- if (position->type != IS_STRING) {
- fetch_pos = NULL;
- fetch_row = position->value.lval;
- } else {
- fetch_pos = position->value.str.val;
- fetch_row = 0;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
-
- nullstr=php3_intifx_null();
-
- IFXG(sv_sqlcode) = 0;
-
- if (strcmp(Ifx_Result->cursorid,"") == 0) {
- php_error(E_WARNING,"Not a select cursor !");
- RETURN_FALSE;
- }
-
- ifx = Ifx_Result->connecid;
- cursorid = Ifx_Result->cursorid;
- statemid = Ifx_Result->statemid;
- descrpid = Ifx_Result->descrpid;
- fieldcount = Ifx_Result->numcols;
-
- EXEC SQL set connection :ifx;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Set connection %s fails (%s)",
- ifx,
- ifx_error(ifx));
- RETURN_FALSE;
- }
-
-
- if (! Ifx_Result->isscroll) {
- EXEC SQL FETCH :cursorid USING SQL DESCRIPTOR :descrpid;
- } else {
- if (fetch_pos == NULL) {
- if (fetch_row != 0) {
- EXEC SQL FETCH ABSOLUTE :fetch_row
- :cursorid USING SQL DESCRIPTOR :descrpid;
- } else {
- EXEC SQL FETCH NEXT :cursorid USING SQL DESCRIPTOR :descrpid;
- }
- } else {
- if (strcasecmp(fetch_pos,"NEXT") == 0) {
- EXEC SQL FETCH NEXT :cursorid USING SQL DESCRIPTOR :descrpid;
- } else {
- if (strcasecmp(fetch_pos,"PREVIOUS") == 0) {
- EXEC SQL FETCH PREVIOUS :cursorid USING SQL DESCRIPTOR :descrpid;
- } else {
- if (strcasecmp(fetch_pos,"FIRST") == 0) {
- EXEC SQL FETCH FIRST :cursorid USING SQL DESCRIPTOR :descrpid;
- } else {
- if (strcasecmp(fetch_pos,"LAST") == 0) {
- EXEC SQL FETCH LAST :cursorid USING SQL DESCRIPTOR :descrpid;
- } else {
- if (strcasecmp(fetch_pos,"CURRENT") == 0) {
- EXEC SQL FETCH CURRENT :cursorid USING SQL DESCRIPTOR :descrpid;
- } else {
- php_error(E_WARNING, "invalid positioning arg on fetch");
- }}}}}
- }
- }
- if(SQLCODE!=-451) {
- switch (ifx_check()) {
- case IFX_ERROR:
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,
- "Can not fetch row on cursor %s (%s)",
- ifx_error(ifx),
- cursorid);
- RETURN_FALSE;
- break;
- case IFX_NODATA:
- RETURN_FALSE;
- break;
- default:
- break;
- }
- }
- Ifx_Result->rowid++;
-
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
- num_fields = fieldcount;
-
- locind = 0;
- for (i = 1; i <= num_fields; i++) {
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :fieldtype = TYPE,
- :fieldname = NAME,
- :fieldleng = LENGTH,
- :indicator = INDICATOR;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Get descriptor (field # %d) fails (%s)",
- i,
- ifx_error(ifx));
- RETURN_FALSE;
- }
-
- p = fieldname; /* rtrim fieldname */
- while ((*p != ' ') && (p < &fieldname[sizeof(fieldname) - 1])) ++p;
- *p = 0;
-
- if (strcmp("(expression)", fieldname) == 0) /* stored proc */
- sprintf(fieldname, "[Expr_%d]", i);
-
- if (indicator == -1) { /* NULL */
- if((IFXG(textasvarchar)==0
- && fieldtype==SQLTEXT)
- || (IFXG(byteasvarchar)==0
- && fieldtype==SQLBYTES)) {
-
- bid_b=Ifx_Result->res_id[locind];
- bid=php3_intifx_copy_blob(bid_b, list);
- php3_intifx_update_blob(bid,nullstr,strlen(nullstr),list);
- add_assoc_long(return_value,fieldname,bid);
- ++locind;
- continue;
- }
- if (
- (fieldtype==SQLTEXT) || (fieldtype==SQLBYTES)
-$ifdef HAVE_IFX_IUS;
- || (fieldtype==SQLUDTFIXED)
-$endif;
- ) {
- ++locind;
- }
- add_assoc_string(return_value, fieldname, nullstr, DUP);
- continue;
- } /* NULL */
- switch (fieldtype) {
- case SQLSERIAL :
- case SQLINT :
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :int_data = DATA;
- long_data = int_data;
- sprintf(string_data,"%ld", long_data);
- add_assoc_string(return_value, fieldname, string_data, DUP);
- break;
- case SQLSMINT :
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :short_data = DATA;
- long_data = short_data;
- sprintf(string_data,"%ld", long_data);
- add_assoc_string(return_value, fieldname, string_data, DUP);
- break;
- case SQLDECIMAL :
- case SQLMONEY :
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :dec_data = DATA;
- memset(string_data, 0x20, 64);
- dectoasc(&dec_data, string_data, 63, -1);
- for (p =string_data; *p != ' '; ++p) ;
- *p = 0;
- add_assoc_string(return_value, fieldname, string_data, DUP);
- break;
- case SQLSMFLOAT :
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :float_data = DATA;
- double_data = float_data;
- sprintf(string_data,"%17.17g", double_data);
- add_assoc_string(return_value, fieldname, string_data, DUP);
- break;
- case SQLFLOAT :
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :double_data = DATA;
- sprintf(string_data,"%17.17g", double_data);
- add_assoc_string(return_value, fieldname, string_data, DUP);
- break;
- case SQLDATE :
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :date_data = DATA;
- rdatestr(date_data, string_data);
- add_assoc_string(return_value, fieldname, string_data, DUP);
- break;
- case SQLDTIME :
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :dt_data = DATA;
- dttoasc(&dt_data, string_data);
- add_assoc_string(return_value, fieldname, string_data, DUP);
- break;
- case SQLINTERVAL:
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :intvl_data = DATA;
- intoasc(&intvl_data, string_data);
- add_assoc_string(return_value, fieldname, string_data, DUP);
- break;
-
-$ifdef HAVE_IFX_IUS;
- case SQLSERIAL8 :
- case SQLINT8 :
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :int8_var = DATA;
- ifx_int8toasc(&int8_var,string_data,200);
- add_assoc_string(return_value, fieldname, string_data, DUP);
- break;
- case SQLLVARCHAR:
- ifx_var_flag(&lvar_tmp,1);
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :lvar_tmp = DATA;
-
- fieldleng=ifx_var_getlen(&lvar_tmp);
- if ((char_data = (char *)emalloc(fieldleng + 1)) == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
- memcpy(char_data,ifx_var_getdata(&lvar_tmp),fieldleng);
- ifx_var_dealloc(&lvar_tmp);
- add_assoc_stringl(return_value, fieldname, char_data, fieldleng,0);
- break;
- case SQLBOOL:
-$endif;
- case SQLVCHAR :
- case SQLNVCHAR :
- case SQLCHAR :
- case SQLNCHAR :
- if ((char_data = (char *)emalloc(fieldleng + 1)) == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :char_data = DATA;
- if (IFXG(charasvarchar) != 0
- && (fieldtype == SQLCHAR || fieldtype == SQLNCHAR)) {
- ldchar(char_data, fieldleng, char_data);
- }
- add_assoc_string(return_value, fieldname, char_data, DUP);
- efree(char_data);
- char_data = NULL;
- break;
-
-$ifdef HAVE_IFX_IUS;
- case SQLUDTFIXED :
- bid_b=Ifx_Result->res_id[locind];
- add_assoc_long(return_value,fieldname,bid_b);
-
- bid=php3_intifxus_new_slob(list);
- slocator=php3_intifxus_get_slobloc(bid,list);
- EXEC SQL SET DESCRIPTOR :descrpid VALUE :i DATA = :*slocator;
- Ifx_Result->res_id[locind]=bid;
- ++locind;
- break;
-$endif;
-
- case SQLBYTES :
- case SQLTEXT : /* NULL has already been dealt with */
- bid_b=Ifx_Result->res_id[locind];
- locator_b=php3_intifx_get_blobloc(bid_b,list);
- ++locind;
-
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :*locator_b = DATA;
- if (locator_b->loc_status < 0) { /* blob too large */
- php_error(E_WARNING,"no memory (%d bytes) for blob",
- locator_b->loc_bufsize);
- RETURN_FALSE;
- }
- /* copy blob */
- bid=php3_intifx_copy_blob(bid_b, list);
- /* and generate new tempfile for next row */
- if(locator_b->loc_loctype==LOCFNAME) {
- blobfilename=php3_intifx_create_tmpfile(bid_b);
- php3_intifx_update_blob(bid_b,blobfilename,strlen(blobfilename),list);
- efree(blobfilename);
- EXEC SQL SET DESCRIPTOR :descrpid VALUE :i
- DATA= :*locator_b;
- }
-
- /* return blob as VARCHAR ? */
- /* note that in case of "blobinfile" */
- /* you get the file name */
- /* a new one for every row ! */
- if((IFXG(textasvarchar)!=0
- && fieldtype==SQLTEXT)
- || (IFXG(byteasvarchar)!=0
- && fieldtype==SQLBYTES)) {
- char *content;
- long lg;
- lg=php3_intifx_get_blob(bid, list, &content);
- if(content==NULL || lg<0) {
- add_assoc_string(return_value,fieldname,nullstr,DUP);
- } else {
- add_assoc_stringl(return_value,fieldname,content,lg,DUP);
- }
- php3_intifx_free_blob(bid, list);
- break;
- }
- /* no, return as blob id */
- add_assoc_long(return_value,fieldname,bid);
- break;
- default :
- sprintf(string_data,"ESQL/C : %s : unsupported field type[%d]",
- fieldname,
- fieldleng);
- add_assoc_string(return_value, fieldname, string_data, DUP);
- break;
- }
-
- continue;
- }
-
-}
-/* }}} */
-
-
-
-/* ----------------------------------------------------------------------
-** int ifx_htmltbl_result(int $resultid, [string $htmltableoptions])
-**
-** formats all rows of the $resultid query into a html table
-** the optional second argument is a string of <table> tag options
-**
-** returns the number of rows printed or FALSE on error
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifx_htmltbl_result(int resultid, [string htmltableoptions])
- formats all rows of the $resultid query into a html table */
-PHP_FUNCTION(ifx_htmltbl_result)
-{
- pval *result, *arg2;
- IFX_RES *Ifx_Result;
-
-EXEC SQL BEGIN DECLARE SECTION;
- char *ifx; /* connection ID */
- char *cursorid; /* query cursor id */
- char *statemid; /* statement id */
- char *descrpid; /* descriptor id */
- int fieldcount; /* field count */
- int i; /* an index */
- char fieldname[64]; /* fieldname */
- short fieldtype; /* field type */
- int fieldleng; /* field length */
-
-$ifdef HAVE_IFX_IUS;
- ifx_int8_t int8_var;
- lvarchar *lvar_tmp;
-$endif;
-
- short indicator;
- int int_data;
- char *char_data = NULL;
- long date_data;
- interval intvl_data = {0};
- datetime dt_data = {0};
- decimal dec_data = {0};
- short short_data;
- float float_data;
- double double_data;
- loc_t *locator_b;
-EXEC SQL END DECLARE SECTION;
-
-
- char *content;
- char *copy_content;
- long lg;
-
- char *nullstr;
-
- int num_fields;
-
- char string_data[256];
- long long_data;
- char *p;
- int locind,bid_b;
- char *table_options;
- int moredata;
-
- IFXLS_FETCH();
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &result)==FAILURE) {
- RETURN_FALSE;
- }
- table_options = NULL;
- break;
- case 2:
- if (getParameters(ht, 2, &result, &arg2)==FAILURE) {
- RETURN_FALSE;
- }
- table_options = arg2->value.str.val;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- IFXG(sv_sqlcode) = 0;
-
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
-
- if (strcmp(Ifx_Result->cursorid,"") == 0) {
- php_error(E_WARNING,"Not a select cursor !");
- RETURN_FALSE;
- }
-
- ifx = Ifx_Result->connecid;
- cursorid = Ifx_Result->cursorid;
- statemid = Ifx_Result->statemid;
- descrpid = Ifx_Result->descrpid;
- fieldcount = Ifx_Result->numcols;
-
- EXEC SQL set connection :ifx;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Set connection %s fails (%s)",
- ifx,
- ifx_error(ifx));
- RETURN_FALSE;
- }
-
-
- /* try to fetch the first row */
- EXEC SQL FETCH :cursorid USING SQL DESCRIPTOR :descrpid;
- switch (ifx_check()) {
- case IFX_ERROR:
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,
- "Can not fetch next row on cursor %s (%s)",
- ifx_error(ifx),
- cursorid);
- RETURN_FALSE;
- break;
- case IFX_NODATA:
- moredata = 0;
- break;
- default:
- Ifx_Result->rowid = moredata = 1;
- break;
- }
-
- if(! moredata) {
- php_printf("<h2>No rows found</h2>\n");
- RETURN_LONG(0);
- }
- num_fields = fieldcount;
- nullstr = php3_intifx_null();
-
- /* start table tag */
- if (table_options == NULL)
- php_printf("<table><tr>");
- else
- php_printf("<table %s><tr>", table_options);
-
- /* table headings */
- for (i = 1; i <= num_fields; i++) {
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :fieldname = NAME;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Get descriptor (field # %d) fails (%s)",
- i,
- ifx_error(ifx));
- RETURN_FALSE;
- }
-
- p = fieldname; /* Capitalize and rtrim fieldname */
- *p = toupper(*p);
- while ((*p != ' ') && (p < &fieldname[sizeof(fieldname) - 1])) ++p;
- *p = 0;
- if (strcmp("(expression)", fieldname) == 0) /* stored proc */
- sprintf(fieldname, "[Expr_%d]", i);
-
- php_printf("<th>%s</th>", fieldname);
- }
- php_printf("</tr>\n");
-
- /* start spitting out rows untill none left */
- while (moredata) {
- php_printf("<tr>");
- locind = 0;
- for (i = 1; i <= num_fields; i++) {
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :fieldtype = TYPE,
- :fieldleng = LENGTH,
- :indicator = INDICATOR;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Get descriptor (field # %d) fails (%s)",
- i,
- ifx_error(ifx));
- RETURN_FALSE;
- }
-
- if (indicator == -1) { /* NULL */
- if(fieldtype==SQLTEXT || fieldtype==SQLBYTES) {
- ++locind;
- }
- php_printf("<td>%s</td>", nullstr);
- continue;
- }
- switch (fieldtype) {
- case SQLSERIAL :
- case SQLINT :
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :int_data = DATA;
- long_data = int_data;
- sprintf(string_data,"%ld", long_data);
- php_printf("<td>%s</td>", string_data);
- break;
- case SQLSMINT :
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :short_data = DATA;
- long_data = short_data;
- sprintf(string_data,"%ld", long_data);
- php_printf("<td>%s</td>", string_data);
- break;
- case SQLDECIMAL :
- case SQLMONEY :
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :dec_data = DATA;
- memset(string_data, 0x20, 64);
- dectoasc(&dec_data, string_data, 63, -1);
- for (p =string_data; *p != ' '; ++p) ;
- *p = 0;
- php_printf("<td>%s</td>", string_data);
- break;
- case SQLSMFLOAT :
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :float_data = DATA;
- double_data = float_data;
- sprintf(string_data,"%17.17g", double_data);
- php_printf("<td>%s</td>", string_data);
- break;
- case SQLFLOAT :
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :double_data = DATA;
- sprintf(string_data,"%17.17g", double_data);
- php_printf("<td>%s</td>", string_data);
- break;
- case SQLDATE :
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :date_data = DATA;
- rdatestr(date_data, string_data);
- php_printf("<td>%s</td>", string_data);
- break;
- case SQLDTIME :
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :dt_data = DATA;
- dttoasc(&dt_data, string_data);
- php_printf("<td>%s</td>", string_data);
- break;
- case SQLINTERVAL:
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :intvl_data = DATA;
- intoasc(&intvl_data, string_data);
- php_printf("<td>%s</td>", string_data);
- break;
-$ifdef HAVE_IFX_IUS;
- case SQLSERIAL8:
- case SQLINT8 :
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :int8_var = DATA;
- ifx_int8toasc(&int8_var,string_data,200);
- php_printf("<td>%s</td>", string_data);
- break;
- case SQLLVARCHAR:
- ifx_var_flag(&lvar_tmp,1);
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :lvar_tmp = DATA;
-
- fieldleng=ifx_var_getlen(&lvar_tmp);
- if ((char_data = (char *)emalloc(fieldleng + 1)) == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
- memcpy(char_data,ifx_var_getdata(&lvar_tmp),fieldleng);
- ifx_var_dealloc(&lvar_tmp);
- add_assoc_stringl(return_value, fieldname, char_data, fieldleng,0);
- break;
-
- case SQLBOOL :
-$endif;
- case SQLCHAR :
- case SQLVCHAR :
- case SQLNCHAR :
- case SQLNVCHAR :
- if ((char_data = (char *)emalloc(fieldleng + 1)) == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :char_data = DATA;
- if (IFXG(charasvarchar) != 0
- && (fieldtype == SQLCHAR || fieldtype == SQLNCHAR)) {
- ldchar(char_data, fieldleng, char_data);
- }
- php_printf("<td>%s</td>", char_data);
- efree(char_data);
- char_data = NULL;
- break;
- case SQLTEXT :
- /* NULL has already been dealt with */
- /* treated always as a long VARCHAR here */
- /* if blobinbfile, too bad */
- bid_b=Ifx_Result->res_id[locind];
- ++locind;
-
- locator_b=php3_intifx_get_blobloc(bid_b,list);
-
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i
- :*locator_b = DATA;
- if (locator_b->loc_status < 0) { /* blob too large */
- php_error(E_WARNING,"no memory (%d bytes) for blob",
- locator_b->loc_bufsize);
- RETURN_FALSE;
- }
-
- /* get blob contents */
- lg=php3_intifx_get_blob(bid_b, list, &content);
-
- if(content==NULL || lg<0) {
- php_printf("<td>%s</td>", nullstr);
- } else {
- /* need an extra byte for string terminator */
- copy_content = malloc(lg + 1);
- if (copy_content == NULL) {
- php_error(E_WARNING,"no memory for TEXT column");
- RETURN_FALSE;
- }
- memcpy(copy_content, content, lg);
- copy_content[lg]=0;
- php_printf("<td>%s</td>", copy_content);
- free(copy_content);
- }
- break;
-
- case SQLBYTES :
- ++locind;
- php_printf("<td>(BYTE)</td>");
- break;
- default :
- sprintf(string_data,
- "ESQL/C : %s : unsupported field type[%d]",
- fieldname,
- fieldleng);
- php_printf("<td>%s</td>", string_data);
- break;
- }
-
- continue;
- }
- php_printf("</tr>\n");
- /* fetch next row */
- EXEC SQL FETCH :cursorid USING SQL DESCRIPTOR :descrpid;
- switch (ifx_check()) {
- case IFX_ERROR:
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,
- "Can not fetch next row on cursor %s (%s)",
- ifx_error(ifx),
- cursorid);
- RETURN_FALSE;
- break;
- case IFX_NODATA:
- moredata = 0;
- break;
- default:
- break;
- }
- Ifx_Result->rowid++;
-
- } /* endwhile (moredata); */
- php_printf("</table>\n");
- RETURN_LONG(Ifx_Result->rowid);
-
-}
-/* }}} */
-
-/* ----------------------------------------------------------------------
-** array ifx_fieldtypes(int $resultid)
-**
-** returns an associative array with fieldnames as key
-** and SQL fieldtypes as data for query $resultid
-**
-** returns FALSE on error
-** ----------------------------------------------------------------------
-*/
-
-
-/* {{{ proto array ifx_fieldtypes(int resultid)
- returns an associative array with fieldnames as key for query <resultid> */
-PHP_FUNCTION(ifx_fieldtypes)
-{
- pval *result, *arg2;
- IFX_RES *Ifx_Result;
-
-EXEC SQL BEGIN DECLARE SECTION;
- char *ifx; /* connection ID */
- char *cursorid; /* query cursor id */
- char *statemid; /* statement id */
- char *descrpid; /* descriptor id */
- int fieldcount; /* field count */
- int i; /* an index */
- char fieldname[64]; /* fieldname */
- short fieldtype; /* field type */
-
- char *char_data = NULL;
-
-EXEC SQL END DECLARE SECTION;
-
- int num_fields;
-
- char *p;
- char *table_options;
-
- IFXLS_FETCH();
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &result)==FAILURE) {
- RETURN_FALSE;
- }
- table_options = NULL;
- break;
- case 2:
- if (getParameters(ht, 2, &result, &arg2)==FAILURE) {
- RETURN_FALSE;
- }
- table_options = arg2->value.str.val;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- IFXG(sv_sqlcode) = 0;
-
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
-
- if (strcmp(Ifx_Result->cursorid,"") == 0) {
- php_error(E_WARNING,"Not a select cursor !");
- RETURN_FALSE;
- }
-
- ifx = Ifx_Result->connecid;
- cursorid = Ifx_Result->cursorid;
- statemid = Ifx_Result->statemid;
- descrpid = Ifx_Result->descrpid;
- fieldcount = Ifx_Result->numcols;
-
- EXEC SQL set connection :ifx;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Set connection %s fails (%s)",
- ifx,
- ifx_error(ifx));
- RETURN_FALSE;
- }
-
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
- num_fields = fieldcount;
- for (i = 1; i <= num_fields; i++) {
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :fieldname = NAME,
- :fieldtype = TYPE;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Get descriptor (field # %d) fails (%s)",
- i,
- ifx_error(ifx));
- RETURN_FALSE;
- }
-
- p = fieldname; /* rtrim fieldname */
- while ((*p != ' ') && (p < &fieldname[sizeof(fieldname) - 1])) ++p;
- *p = 0;
- if (strcmp("(expression)", fieldname) == 0) /* stored proc */
- sprintf(fieldname, "[Expr_%d]", i);
-
- switch (fieldtype) {
- case SQLSERIAL :
- char_data = "SQLSERIAL";
- break;
- case SQLINT :
- char_data = "SQLINT";
- break;
- case SQLSMINT :
- char_data = "SQLSMINT";
- break;
- case SQLDECIMAL :
- char_data = "SQLDECIMAL";
- break;
- case SQLMONEY :
- char_data = "SQLMONEY";
- break;
- case SQLSMFLOAT :
- char_data = "SQLSMFLOAT";
- break;
- case SQLFLOAT :
- char_data = "SQLFLOAT";
- break;
- case SQLDATE :
- char_data = "SQLDATE";
- break;
- case SQLDTIME :
- char_data = "SQLDTIME";
- break;
- case SQLINTERVAL:
- char_data = "SQLINTERVAL";
- break;
- case SQLCHAR :
- char_data = "SQLCHAR";
- break;
- case SQLVCHAR :
- char_data = "SQLVCHAR";
- break;
- case SQLNCHAR :
- char_data = "SQLNCHAR";
- break;
- case SQLNVCHAR :
- char_data = "SQLNVCHAR";
- break;
- case SQLTEXT :
- char_data = "SQLTEXT";
- break;
- case SQLBYTES :
- char_data = "SQLBYTES";
- break;
-$ifdef HAVE_IFX_IUS;
- case SQLUDTFIXED :
- char_data = "SQLUDTFIXED";
- break;
- case SQLBOOL :
- char_data = "SQLBOOL";
- break;
- case SQLINT8 :
- char_data = "SQLINT8";
- break;
- case SQLSERIAL8 :
- char_data = "SQLSERIAL8";
- break;
- case SQLLVARCHAR :
- char_data = "SQLLVARCHAR";
- break;
-$endif;
- default :
- char_data=emalloc(20);
- sprintf(char_data,"ESQL/C : %i",fieldtype);
- break;
- } /* switch (fieldtype) */
-
- add_assoc_string(return_value, fieldname, char_data, DUP);
-
- } /* for() */
-
-}
-/* }}} */
-
-/* ----------------------------------------------------------------------
-** array ifx_fieldproperties(int $resultid)
-**
-** returns an associative array with fieldnames as key
-** and SQL fieldproperties as data for query $resultid
-**
-** properties are encoded as : "SQLTYPE;length;precision;scale;ISNULLABLE"
-** where SQLTYPE = the Informix type like "SQLVCHAR" etc...
-** ISNULLABLE = "Y" or "N"
-**
-** returns FALSE on error
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto array ifx_fieldproperties(int resultid)
- returns an associative for query <resultid> array with fieldnames as key */
-PHP_FUNCTION(ifx_fieldproperties)
-{
- pval *result, *arg2;
- IFX_RES *Ifx_Result;
-
-EXEC SQL BEGIN DECLARE SECTION;
- char *ifx; /* connection ID */
- char *cursorid; /* query cursor id */
- char *statemid; /* statement id */
- char *descrpid; /* descriptor id */
- int fieldcount; /* field count */
- int i; /* an index */
- char fieldname[64]; /* fieldname */
- short fieldtype; /* field type */
- char *char_data = NULL;
- int size;
- int precision;
- int scale;
- int isnullable;
-EXEC SQL END DECLARE SECTION;
-
- int num_fields;
-
- char string_data[256];
- char *p;
- char *table_options;
-
- IFXLS_FETCH();
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &result)==FAILURE) {
- RETURN_FALSE;
- }
- table_options = NULL;
- break;
- case 2:
- if (getParameters(ht, 2, &result, &arg2)==FAILURE) {
- RETURN_FALSE;
- }
- table_options = arg2->value.str.val;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- IFXG(sv_sqlcode) = 0;
-
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
-
- if (strcmp(Ifx_Result->cursorid,"") == 0) {
- php_error(E_WARNING,"Not a select cursor !");
- RETURN_FALSE;
- }
-
- ifx = Ifx_Result->connecid;
- cursorid = Ifx_Result->cursorid;
- statemid = Ifx_Result->statemid;
- descrpid = Ifx_Result->descrpid;
- fieldcount = Ifx_Result->numcols;
-
- EXEC SQL set connection :ifx;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Set connection %s fails (%s)",
- ifx,
- ifx_error(ifx));
- RETURN_FALSE;
- }
-
-
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
- num_fields = fieldcount;
- for (i = 1; i <= num_fields; i++) {
- EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :fieldname = NAME,
- :fieldtype = TYPE,
- :size = LENGTH,
- :precision = PRECISION,
- :scale = SCALE,
- :isnullable = NULLABLE;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Get descriptor (field # %d) fails (%s)",
- i,
- ifx_error(ifx));
- RETURN_FALSE;
- }
-
- p = fieldname; /* rtrim fieldname */
- while ((*p != ' ') && (p < &fieldname[sizeof(fieldname) - 1])) ++p;
- *p = 0;
- if (strcmp("(expression)", fieldname) == 0) /* stored proc */
- sprintf(fieldname, "[Expr_%d]", i);
-
- switch (fieldtype) {
- case SQLSERIAL :
- char_data = "SQLSERIAL";
- break;
- case SQLINT :
- char_data = "SQLINT";
- break;
- case SQLSMINT :
- char_data = "SQLSMINT";
- break;
- case SQLDECIMAL :
- char_data = "SQLDECIMAL";
- break;
- case SQLMONEY :
- char_data = "SQLMONEY";
- break;
- case SQLSMFLOAT :
- char_data = "SQLSMFLOAT";
- break;
- case SQLFLOAT :
- char_data = "SQLFLOAT";
- break;
- case SQLDATE :
- char_data = "SQLDATE";
- break;
- case SQLDTIME :
- char_data = "SQLDTIME";
- break;
- case SQLINTERVAL:
- char_data = "SQLINTERVAL";
- break;
- case SQLCHAR :
- char_data = "SQLCHAR";
- break;
- case SQLVCHAR :
- char_data = "SQLVCHAR";
- break;
- case SQLTEXT :
- char_data = "SQLTEXT";
- break;
- case SQLBYTES :
- char_data = "SQLBYTES";
- break;
- case SQLNCHAR :
- char_data = "SQLNCHAR";
- break;
- case SQLNVCHAR :
- char_data = "SQLNVCHAR";
- break;
-$ifdef HAVE_IFX_IUS;
- case SQLUDTFIXED :
- char_data = "SQLUDTFIXED";
- break;
- case SQLBOOL :
- char_data = "SQLBOOL";
- break;
- case SQLINT8 :
- char_data = "SQLINT8";
- break;
- case SQLSERIAL8 :
- char_data = "SQLSERIAL8";
- break;
- case SQLLVARCHAR :
- char_data = "SQLLVARCHAR";
- break;
-$endif;
- default :
- char_data=emalloc(20);
- sprintf(char_data,"ESQL/C : %i",fieldtype);
- break;
- } /* switch (fieldtype) */
-
- sprintf(string_data,"%s;%d;%d;%d;%c",
- char_data,
- size,
- precision,
- scale,
- (isnullable?'Y':'N'));
- add_assoc_string(return_value, fieldname, string_data, DUP);
-
- } /* for() */
-
-}
-/* }}} */
-
-
-/* --------------------------------------------------------------
-** int ifx_num_rows(int $resultid)
-**
-** returns the number of rows already fetched for query $resultid
-**
-** ---------------------------------------------------------------
-*/
-
-/* {{{ proto int ifx_num_rows(int resultid)
- returns the number of rows already fetched for query identified by resultid */
-PHP_FUNCTION(ifx_num_rows)
-{
- pval *result;
- IFX_RES *Ifx_Result;
-
- IFXLS_FETCH();
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- IFXG(sv_sqlcode) = 0;
-
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
-
- return_value->value.lval = Ifx_Result->rowid;
- return_value->type = IS_LONG;
-}
-/* }}} */
-
-
-/* --------------------------------------------------------------
-** int ifx_getsqlca(int $resultid)
-**
-** returns the sqlerrd[] fields of the sqlca struct for query $resultid
-** following the prepare (select) or execute immediate (insert/update/execute procedure)
-**
-** ---------------------------------------------------------------
-*/
-
-/* {{{ proto int ifx_getsqlca(int $resultid)
- returns the sqlerrd[] fields of the sqlca struct for query $resultid */
-PHP_FUNCTION(ifx_getsqlca)
-{
- pval *result;
- IFX_RES *Ifx_Result;
-
- char fieldname[16];
- int e;
-
- IFXLS_FETCH();
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- IFXG(sv_sqlcode) = 0;
-
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
-
- /* create pseudo-row array to return */
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
- /* fill array with 6 fields sqlerrd0 .. sqlerrd5 */
- /* each ESQLC call saves these sqlca values */
- for (e = 0; e < 6; e++) {
- sprintf(fieldname,"sqlerrd%d", e);
- add_assoc_long(return_value, fieldname, Ifx_Result->sqlerrd[e]);
- }
-
-}
-/* }}} */
-
-
-
-/* ----------------------------------------------------------------------
-** int ifx_num_fields(int $resultid)
-**
-** returns the number of columns in query $resultid
-** or FALSE on error
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifx_num_fields(int resultid)
- returns the number of columns in query resultid */
-PHP_FUNCTION(ifx_num_fields)
-{
- pval *result;
- IFX_RES *Ifx_Result;
-
- IFXLS_FETCH();
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- IFXG(sv_sqlcode) = 0;
-
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
-
- return_value->value.lval = Ifx_Result->numcols;
- return_value->type = IS_LONG;
-}
-/* }}} */
-
-
-
-
-/* ----------------------------------------------------------------------
-** int ifx_free_result(int $resultid)
-**
-** releases resources for query associated with $resultid
-**
-** returns FALSE on error
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifx_free_result(int resultid)
- releases resources for query associated with resultid */
-PHP_FUNCTION(ifx_free_result)
-{
- pval *result;
- IFX_RES *Ifx_Result;
-
-EXEC SQL BEGIN DECLARE SECTION;
- char *ifx; /* connection ID */
- char *cursorid; /* query cursor id */
- char *statemid; /* statement id */
- char *descrpid; /* descriptor id */
-EXEC SQL END DECLARE SECTION;
-
- int i;
-
- IFXLS_FETCH();
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
-
- IFXG(sv_sqlcode = 0);
-
- for (i = 0; i < MAX_RESID; ++i) {
- if (Ifx_Result->res_id[i]>0) {
- php3_intifx2_free_blob(Ifx_Result->res_id[i],list);
- Ifx_Result->res_id[i]=-1;
- }
- }
-
- ifx = Ifx_Result->connecid;
- cursorid = Ifx_Result->cursorid;
- statemid = Ifx_Result->statemid;
- descrpid = Ifx_Result->descrpid;
-
- EXEC SQL set connection :ifx;
- if (ifx_check() < 0) {
- IFXG(sv_sqlcode) = SQLCODE;
- php_error(E_WARNING,"Set connection %s fails (%s)",
- ifx,
- ifx_error(ifx));
- RETURN_FALSE;
- }
-
-
- EXEC SQL free :statemid;
- if (strlen(cursorid) != 0) {
- EXEC SQL CLOSE :cursorid;
- EXEC SQL FREE :cursorid;
- }
-
-
- EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
-
- efree(Ifx_Result); /* this can be safely done now */
-
- zend_list_delete(result->value.lval);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-
-
-
-/* ----------------------------------------------------------------------
- * internal function
- * long php3_intifx_getType(long id, HashTable *list)
- *
- * returns the type of an id-object
- * bid: Id of object
- * list: internal hashlist of php3
- *
- * return -1 on error otherwise the type: TYPE_BLTEXT, TYPE_BLBYTE, TYPE_SLOB
- * ----------------------------------------------------------------------
-*/
-static long php3_intifx_getType(long id, HashTable *list) {
- IFX_IDRES *Ifx_res;
- int type;
-
- Ifx_res = (IFX_IDRES *) php3_list_find(id,&type);
- if (type!=IFXG(le_idresult)) {
- php_error(E_WARNING,"%d is not a Informix id-result index",
- id);
- return -1;
- }
- return Ifx_res->type;
- }
-
-
-
-
-/* ----------------------------------------------------------------------
-** int ifx_create_blob(int type, int mode, string param)
-**
-** creates a blob-object
-** type: 1=TEXT, 0=BYTE
-** mode: blob-object holds 0=the content in memory, 1=content in file
-** param: if mode=0: pointer to the content
-** mode=1: pointer to the filestring
-** return false on error otherwise the new Blob-Object-id
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifx_create_blob(int type, int mode, string param)
- creates a blob-object */
-PHP_FUNCTION(ifx_create_blob) {
- pval *pmode, *pparam,*ptype;
- long id;
- long mode,type;
-
- if (ARG_COUNT(ht)!=3 || getParameters(ht, 3, &ptype,&pmode,&pparam)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pmode);
- convert_to_string(pparam);
- convert_to_long(ptype);
-
- type=ptype->value.lval;
- if(type!=0)
- type=TYPE_BLTEXT;
- mode=pmode->value.lval;
- if(mode!=0)
- mode=BLMODE_INFILE;
-
- id=php3_intifx_create_blob(type,mode,pparam->value.str.val,pparam->value.str.len,list);
- if(id<0) {
- RETURN_FALSE;
- }
- RETURN_LONG(id);
-}
-/* }}} */
-
-/* ----------------------------------------------------------------------
- * internal function
- * long php3_intifx_create_blob(long type, long mode, char* param, long len, HashTable *list)
- *
- * creates an blob-object
- * type: 1=TEXT, 0=BYTE
- * mode: blob-object holds 0=the content in momory, 1=content in file
- * param: if mode=0: pointer to the content
- * mode=1: pointer to the filestring
- * len: length of param
- * list: internal hashlist of php3
- * return -1 on error otherwise the new Blob-Object-id
- * ----------------------------------------------------------------------
-*/
-static long php3_intifx_create_blob(long type, long mode, char* param, long len, HashTable *list) {
- IFX_IDRES *Ifx_blob;
-
-
- Ifx_blob=emalloc(sizeof(IFX_IDRES));
- if(Ifx_blob==NULL) {
- php_error(E_WARNING,"can't create blob-resource");
- return -1;
- }
-
- memset(Ifx_blob, 0, sizeof(IFX_IDRES));
-
- if(type==0 ) {
- Ifx_blob->type=TYPE_BLBYTE;
- } else {
- Ifx_blob->type=TYPE_BLTEXT;
- }
- Ifx_blob->BLOB.mode=(int)mode;
-
- if(mode==BLMODE_INMEM) {
- if(len>=0) {
- char *content=emalloc(len);
- if(content==NULL) {
- php_error(E_WARNING,"can't create blob-resource");
- return -1;
- }
- memcpy(content,param,len);
- Ifx_blob->BLOB.blob_data.loc_loctype=LOCMEMORY;
- Ifx_blob->BLOB.blob_data.loc_buffer=content;
- Ifx_blob->BLOB.blob_data.loc_bufsize=len;
- Ifx_blob->BLOB.blob_data.loc_size=len;
- Ifx_blob->BLOB.blob_data.loc_mflags=0;
- Ifx_blob->BLOB.blob_data.loc_oflags=0;
- } else {
- Ifx_blob->BLOB.blob_data.loc_loctype=LOCMEMORY;
- Ifx_blob->BLOB.blob_data.loc_buffer=NULL;
- Ifx_blob->BLOB.blob_data.loc_bufsize=-1;
- Ifx_blob->BLOB.blob_data.loc_size=-1;
- Ifx_blob->BLOB.blob_data.loc_mflags=0;
- Ifx_blob->BLOB.blob_data.loc_oflags=0;
- }
- } else { /* mode = BLMODE_INFILE */
- char *filename=emalloc(len+1);
- if(filename==NULL) {
- php_error(E_WARNING,"can't create blob-resource");
- return -1;
- }
- memcpy(filename,param,len);
- filename[len]=0;
- Ifx_blob->BLOB.blob_data.loc_loctype=LOCFNAME;
- Ifx_blob->BLOB.blob_data.loc_fname=filename;
- Ifx_blob->BLOB.blob_data.loc_oflags=LOC_WONLY;
- Ifx_blob->BLOB.blob_data.loc_size=-1;
- }
- return php3_list_insert(Ifx_blob,IFXG(le_idresult));
-}
-
-
-
-
-/* ----------------------------------------------------------------------
-** int ifx_copy_blob(int bid)
-**
-** duplicates the given blob-object
-** bid: Id of Blobobject
-**
-** return false on error otherwise the new Blob-Object-id
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifx_copy_blob(int bid)
- duplicates the given blob-object */
-PHP_FUNCTION(ifx_copy_blob) {
- pval *pbid;
- long newid;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pbid)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pbid);
-
- newid=php3_intifx_copy_blob(pbid->value.lval,list);
- if(newid<0) {
- RETURN_FALSE;
- }
-
- RETURN_LONG(newid);
-}
-/* }}} */
-
-
-
-/* ----------------------------------------------------------------------
- * internal function
- * long php3_intifx_copy_blob(long bid, HashTable *list)
- *
- * duplicates the given blob-object
- * bid: Id of Blobobject
- * list: internal hashlist of php3
- *
- * return -1 on error otherwise the new Blob-Object-id
- * ----------------------------------------------------------------------
-*/
-static long php3_intifx_copy_blob(long bid, HashTable *list) {
- IFX_IDRES *Ifx_blob, *Ifx_blob_orig;
- loc_t *locator, *locator_orig;
- int type;
-
- Ifx_blob_orig = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || !(Ifx_blob_orig->type==TYPE_BLBYTE || Ifx_blob_orig->type==TYPE_BLTEXT)) {
- php_error(E_WARNING,"%d is not a Informix blob-result index",
- bid);
- return -1;
- }
- Ifx_blob=emalloc(sizeof(IFX_IDRES));
- if(Ifx_blob==NULL) {
- php_error(E_WARNING,"can't create blob-resource");
- return -1;
- }
-
- memset(Ifx_blob, 0, sizeof(IFX_IDRES));
-
- Ifx_blob->type=Ifx_blob_orig->type;
- Ifx_blob->BLOB.mode=Ifx_blob_orig->BLOB.mode;
-
- locator=&(Ifx_blob->BLOB.blob_data);
- locator_orig=&(Ifx_blob_orig->BLOB.blob_data);
-
- if(Ifx_blob->BLOB.mode==BLMODE_INMEM) {
- char *content;
- if(locator_orig->loc_size>=0 && locator_orig->loc_buffer!=NULL) {
- if((content=emalloc(locator_orig->loc_size))==NULL) {
- php_error(E_WARNING,"can't create blob-resource");
- return -1;
- }
- memcpy(content,locator_orig->loc_buffer, locator_orig->loc_size);
- locator->loc_buffer=content;
- locator->loc_bufsize=locator_orig->loc_size;
- locator->loc_size=locator_orig->loc_size;
- } else {
- locator->loc_buffer=NULL;
- locator->loc_bufsize=-1;
- locator->loc_size=-1;
- }
- locator->loc_loctype=LOCMEMORY;
- locator->loc_mflags=0;
- locator->loc_oflags=0;
- } else { /* BLMODE_INFILE */
- char *filename;
-
- if((filename=emalloc(strlen(locator_orig->loc_fname)+1))==NULL) {
- php_error(E_WARNING,"can't create blob-resource");
- return -1;
- }
- strcpy(filename,locator_orig->loc_fname);
- locator->loc_loctype=LOCFNAME;
- locator->loc_fname=filename;
- locator->loc_size=-1;
- locator->loc_oflags=locator_orig->loc_oflags;
- }
-
- return php3_list_insert(Ifx_blob,IFXG(le_idresult));
-}
-
-
-
-/* ----------------------------------------------------------------------
-** int ifx_free_blob(int bid)
-**
-** deletes the blob-object
-** bid: Id of Blobobject
-** return false on error otherwise true
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifx_free_blob(int bid)
- deletes the blob-object */
-PHP_FUNCTION(ifx_free_blob) {
- pval *pid;
- long ret;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pid)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pid);
-
- ret=php3_intifx_free_blob(pid->value.lval,list);
- if(ret<0) {
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-/* ----------------------------------------------------------------------
- * internal function
- * long php3_intifx_free_blob(long bid, HashTable *list)
- *
- * deletes the blob-object
- * bid: Id of Blobobject
- * list: internal hashlist of php3
- *
- * return -1 on error otherwise 0
- * FREES BYTE-MEMORY WITH EFREE()
- * ----------------------------------------------------------------------
-*/
-static long php3_intifx_free_blob(long bid, HashTable *list) {
- IFX_IDRES *Ifx_blob;
- int type;
-
- Ifx_blob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
- php_error(E_WARNING,"%d is not a Informix blob-result index",
- bid);
- return -1;
- }
- if(Ifx_blob->BLOB.mode==BLMODE_INMEM) {
- if(Ifx_blob->BLOB.blob_data.loc_buffer==NULL
- || Ifx_blob->BLOB.blob_data.loc_size<=0) {;} else {
- efree(Ifx_blob->BLOB.blob_data.loc_buffer);
- }
- } else { /* BLMODE_INFILE */
- if(Ifx_blob->BLOB.blob_data.loc_fname!=NULL) {
- efree(Ifx_blob->BLOB.blob_data.loc_fname);
- }
- }
-
-
- php3_list_delete(bid);
- efree(Ifx_blob);
- return 0;
-}
-
-
-
-/* ----------------------------------------------------------------------
- * internal function
- * long php3_intifx2_free_blob(long bid, HashTable *list)
- *
- * deletes the blob-object
- * bid: Id of Blobobject
- * list: internal hashlist of php3
- *
- * return -1 on error otherwise 0
- * FREES BYTE-MEMORY WITH FREE(), for blob memory allocated by ESQL/C
- * use this for freeing blob-source after select (in ifx_free_result)
- * ----------------------------------------------------------------------
-*/
-static long php3_intifx2_free_blob(long bid, HashTable *list) {
- IFX_IDRES *Ifx_blob;
- int type;
-
- Ifx_blob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
- php_error(E_WARNING,"%d is not a Informix blob-result index",
- bid);
- return -1;
- }
-#if IFX_VERSION < 724 /* this Informix memory leak is fixed from 7.24 on */
- /* according to the current PERL DBD::Informix */
- /* and otherwise I get segmenation violations with 7.30 */
-
- if(Ifx_blob->BLOB.mode==BLMODE_INMEM) {
- if(Ifx_blob->BLOB.blob_data.loc_buffer==NULL ||
- Ifx_blob->BLOB.blob_data.loc_size<=0) {;} else {
- free(Ifx_blob->BLOB.blob_data.loc_buffer);
- }
- } else {
- if(Ifx_blob->BLOB.blob_data.loc_fname!=NULL) {
- efree(Ifx_blob->BLOB.blob_data.loc_fname);
- }
- }
-
-#endif
-
- php3_list_delete(bid);
- efree(Ifx_blob);
- return 0;
-}
-
-/* ----------------------------------------------------------------------
-** string ifx_get_blob(int bid)
-**
-** returns the content of the blob-object
-** bid: Id of Blobobject
-** return the content
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto string ifx_get_blob(int bid)
- returns the content of the blob-object */
-PHP_FUNCTION(ifx_get_blob) {
- pval *pbid;
- char *content;
- long len;
-
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pbid)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pbid);
-
- len=php3_intifx_get_blob(pbid->value.lval,list,&content);
- if(content==NULL || len<0) {
- RETURN_STRING(php3_intifx_null(),1);
- }
- RETURN_STRINGL(content,len,1);
-}
-/* }}} */
-
-
-/* ----------------------------------------------------------------------
- * internal function
- * long php3_intifx_get_blob(long bid, HashTable *list, char** content)
- *
- * returns the content of the blob-object
- * bid: Id of Blobobject
- * list: internal hashlist of php3
- *
- * return -1 on error
- * returns the pointer to the content in char** content and the amount of content in bytes
- * ----------------------------------------------------------------------
-*/
-static long php3_intifx_get_blob(long bid, HashTable *list, char** content) {
- IFX_IDRES *Ifx_blob;
- int type;
-
- Ifx_blob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
- php_error(E_WARNING,"%d is not a Informix blob-result index",
- bid);
- return -1;
- }
-
- if(Ifx_blob->BLOB.mode==BLMODE_INMEM) {
- *content=Ifx_blob->BLOB.blob_data.loc_buffer;
- return Ifx_blob->BLOB.blob_data.loc_size;
- }
- *content=Ifx_blob->BLOB.blob_data.loc_fname;
- return strlen(Ifx_blob->BLOB.blob_data.loc_fname);
-}
-
-
-/* ----------------------------------------------------------------------
- * internal function
- * loc_t *php3_intifx_get_blobloc(long bid, HashTable *list)
- *
- * returns the blob-locator-structur
- * bid: Id of Blobobject
- * list: internal hashlist of php3
- * return NULL on error or the pointer to the locator-structur
- * ----------------------------------------------------------------------
-*/
-static loc_t *php3_intifx_get_blobloc(long bid, HashTable *list) {
- IFX_IDRES *Ifx_blob;
- int type;
-
- Ifx_blob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
- php_error(E_WARNING,"%d is not a Informix blob-result index",
- bid);
- return NULL;
- }
-
- return &(Ifx_blob->BLOB.blob_data);
-}
-
-
-
-/* ----------------------------------------------------------------------
-** int update_blob(int bid, string content)
-**
-** updates the content of the blob-object
-** bid: Id of Blobobject
-** content: string of new data
-** return false on error otherwise true
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifx_update_blob(int bid, string content)
- updates the content of the blob-object */
-PHP_FUNCTION(ifx_update_blob) {
- pval *pbid,*pparam;
- long ret;
-
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &pbid,&pparam)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pbid);
- convert_to_string(pparam);
-
- ret=php3_intifx_update_blob(pbid->value.lval,
- pparam->value.str.val,
- pparam->value.str.len,
- list);
- if(ret<0) {
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/* ----------------------------------------------------------------------
- * internal function
- * long php3_intifx_update_blob(long bid, char* param, long len, HashTable *list)
- *
- * updates the content of the blob-object
- * bid: Id of Blobobject
- * param: string of new data
- * len: length of string
- * list: internal hashlist of php3
- * return nothing
- * ----------------------------------------------------------------------
-*/
-static long php3_intifx_update_blob(long bid, char* param, long len, HashTable *list) {
- IFX_IDRES *Ifx_blob;
- int type;
-
- Ifx_blob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
- php_error(E_WARNING,"%d is not a Informix blob-result index",
- bid);
- return -1;
- }
-
- if(Ifx_blob->BLOB.mode==BLMODE_INMEM) {
- char *content;
-
- if(Ifx_blob->BLOB.blob_data.loc_buffer!=NULL)
- efree(Ifx_blob->BLOB.blob_data.loc_buffer);
- if(len>=0) {
- if((content=emalloc(len))==NULL) {
- php_error(E_WARNING,"can't create blob-resource");
- return -1;
- }
- memcpy(content,param, len);
- Ifx_blob->BLOB.blob_data.loc_buffer=content;
- Ifx_blob->BLOB.blob_data.loc_bufsize=len;
- Ifx_blob->BLOB.blob_data.loc_size=len;
- } else {
- Ifx_blob->BLOB.blob_data.loc_buffer=NULL;
- Ifx_blob->BLOB.blob_data.loc_bufsize=-1;
- Ifx_blob->BLOB.blob_data.loc_size=-1;
- }
- Ifx_blob->BLOB.blob_data.loc_mflags=0;
- Ifx_blob->BLOB.blob_data.loc_oflags=0;
- } else {
- char *filename;
-
- if(Ifx_blob->BLOB.blob_data.loc_fname!=NULL)
- efree(Ifx_blob->BLOB.blob_data.loc_fname);
- if((filename=emalloc(len+1))==NULL) {
- php_error(E_WARNING,"can't create blob-resource");
- return -1;
- }
- memcpy(filename,param, len);
- filename[len]=0;
- Ifx_blob->BLOB.blob_data.loc_fname=filename;
- Ifx_blob->BLOB.blob_data.loc_size=-1;
- }
- return 0;
-}
-
-
-
-/*-------------------------------------------------
- * internal function
- *
- * php3_intifx_create_tmpfile(long bid)
- * creates a temporary file to store a blob in
- *-------------------------------------------------
-*/
-
-
-static char* php3_intifx_create_tmpfile(long bid) {
- char filename[10];
- char *blobdir;
- char *blobfile;
- char *retval;
-
- if ((blobdir = getenv("php3_blobdir")) == NULL)
- blobdir=".";
-
- sprintf(filename,"blb%d",(int)bid);
- blobfile=tempnam(blobdir,filename);
- free(blobdir);
- retval=emalloc(strlen(blobfile)+1);
- if(retval==NULL)
- return NULL;
- strcpy(retval,blobfile);
- free(blobfile);
- return retval;
-}
-
-
-
-
-/* ----------------------------------------------------------------------
-** void ifx_blobinfile_mode(int $mode)
-**
-** sets the default blob-mode for all select-queries
-** mode=0: save Byte-Blobs in momory
-** mode=1: save Byte-Blobs in a file
-** return nothing
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto void ifx_blobinfile_mode(int mode)
- sets the default blob-mode for all select-queries */
-PHP_FUNCTION(ifx_blobinfile_mode) {
- pval *pmode;
-
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pmode)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pmode);
-
- IFXG(blobinfile)=pmode->value.lval;
- RETURN_TRUE;
-}
-/* }}} */
-
-
-
-/* ----------------------------------------------------------------------
-** void ifx_textasvarchar(int $mode)
-**
-** sets the default text-mode for all select-queries
-** mode=0: select returns a blob-id
-** mode=1: select returns a varchar with text-content
-** return nothing
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto void ifx_textasvarchar(int mode)
- sets the default text-mode for all select-queries */
-PHP_FUNCTION(ifx_textasvarchar) {
- pval *pmode;
-
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pmode)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pmode);
-
- IFXG(textasvarchar)=pmode->value.lval;
- RETURN_TRUE;
-}
-/* }}} */
-
-
-
-/* ----------------------------------------------------------------------
-** void ifx_byteasvarchar(int $mode)
-**
-** sets the default byte-mode for all select-queries
-** mode=0: select returns a blob-id
-** mode=1: select returns a varchar with byte-content
-** return nothing
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto void ifx_byteasvarchar(int mode)
- sets the default byte-mode for all select-queries */
-PHP_FUNCTION(ifx_byteasvarchar) {
- pval *pmode;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pmode)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pmode);
-
- IFXG(byteasvarchar)=pmode->value.lval;
- RETURN_TRUE;
-}
-
-
-
-/* ----------------------------------------------------------------------
-** void ifx_nullformat(int $mode)
-**
-** sets the default return value of a NULL-value un a fetch-row
-** mode=0: return ""
-** mode=1: return "NULL"
-** return nothing
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto void ifx_nullformat(int mode)
- sets the default return value of a NULL-value un a fetch-row */
-PHP_FUNCTION(ifx_nullformat) {
- pval *pmode;
-
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pmode)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pmode);
-
- IFXG(nullformat)=pmode->value.lval;
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/* ----------------------------------------------------------------------
- * void php3_intifx_null()
- *
- * return the NULL-string depending on .nullformat
- * return "" or "NULL"
- * ----------------------------------------------------------------------
-*/
-static char* php3_intifx_null() {
- char* tmp;
-
- if(IFXG(nullformat)==0) {
- tmp=IFXG(nullvalue);
- } else {
- tmp=IFXG(nullstring);
- }
- return tmp;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-/* ----------------------------------------------------------------------
-** int ifx_create_char(string param)
-**
-** creates an char-object
-** param: content
-** return false on error otherwise the new char-Object-id
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifx_create_char(string param)
- creates a char-object */
-PHP_FUNCTION(ifx_create_char) {
- pval *pparam;
- long id;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pparam)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(pparam);
-
- id=php3_intifx_create_char(pparam->value.str.val,pparam->value.str.len,list);
- if(id<0) {
- RETURN_FALSE;
- }
- RETURN_LONG(id);
-}
-/* }}} */
-
-/* ----------------------------------------------------------------------
- * internal function
- * long php3_intifx_create_char(char* param, long len, HashTable *list)
- *
- * creates an char-object
- * param: content
- * len: length of param
- * list: internal hashlist of php3
- * return -1 on error otherwise the new char-Object-id
- * ----------------------------------------------------------------------
-*/
-static long php3_intifx_create_char(char* param, long len, HashTable *list) {
- IFX_IDRES *Ifx_char;
-
-
- Ifx_char=emalloc(sizeof(IFX_IDRES));
- if(Ifx_char==NULL) {
- php_error(E_WARNING,"can't create char-resource");
- return -1;
- }
-
- Ifx_char->type=TYPE_CHAR;
-
- if(param==NULL || len<0) {
- Ifx_char->CHAR.char_data=NULL;
- Ifx_char->CHAR.len=0;
- } else {
- Ifx_char->CHAR.char_data=emalloc(len+1);
- if(Ifx_char->CHAR.char_data==NULL) {
- efree(Ifx_char);
- php_error(E_WARNING,"can't create char-resource");
- return -1;
- }
- memcpy(Ifx_char->CHAR.char_data,param,len);
- Ifx_char->CHAR.char_data[len]=0;
- Ifx_char->CHAR.len=len;
- }
- return php3_list_insert(Ifx_char,IFXG(le_idresult));
-}
-
-/* ----------------------------------------------------------------------
-** string ifx_get_char(int bid)
-**
-** returns the content of the char-object
-** bid: Id of charobject
-** return the content
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto string ifx_get_char(int bid)
- returns the content of the char-object */
-PHP_FUNCTION(ifx_get_char) {
- pval *pbid;
- char *content;
- long len;
-
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pbid)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pbid);
-
- len=php3_intifx_get_char(pbid->value.lval,list,&content);
- if(content==NULL || len<0) {
- RETURN_STRING("",1);
- }
- RETURN_STRINGL(content,len,1);
-}
-/* }}} */
-
-
-/* ----------------------------------------------------------------------
- * internal function
- * long php3_intifx_get_char(long bid, HashTable *list, char** content)
- *
- * returns the content of the char-object
- * bid: Id of charobject
- * list: internal hashlist of php3
- *
- * return -1 on error
- * returns the pointer to the content in char** content and the amount of content in bytes
- * ----------------------------------------------------------------------
-*/
-static long php3_intifx_get_char(long bid, HashTable *list, char** content) {
- IFX_IDRES *Ifx_char;
- int type;
-
- Ifx_char = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) && !(Ifx_char->type==TYPE_CHAR)) {
- php_error(E_WARNING,"%d is not a Informix char-result index",
- bid);
- return -1;
- }
-
- *content=Ifx_char->CHAR.char_data;
- return Ifx_char->CHAR.len;
-}
-
-/* ----------------------------------------------------------------------
-** int ifx_free_char(int bid)
-**
-** deletes the char-object
-** bid: Id of charobject
-** return false on error otherwise true
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifx_free_char(int bid)
- deletes the char-object */
-PHP_FUNCTION(ifx_free_char) {
- pval *pid;
- long ret;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pid)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pid);
-
- ret=php3_intifx_free_char(pid->value.lval,list);
- if(ret<0) {
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-/* ----------------------------------------------------------------------
- * internal function
- * long php3_intifx_free_char(long bid, HashTable *list)
- *
- * deletes the char-object
- * bid: Id of Charobject
- * list: internal hashlist of php3
- *
- * return -1 on error otherwise 0
- * ----------------------------------------------------------------------
-*/
-static long php3_intifx_free_char(long bid, HashTable *list) {
- IFX_IDRES *Ifx_char;
- int type;
-
- Ifx_char = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) && !(Ifx_char->type==TYPE_CHAR)) {
- php_error(E_WARNING,"%d is not a Informix char-result index",
- bid);
- return -1;
- }
-
- if(Ifx_char->CHAR.char_data!=NULL) {
- efree(Ifx_char->CHAR.char_data);
- }
-
- php3_list_delete(bid);
- efree(Ifx_char);
- return 0;
-}
-
-/* ----------------------------------------------------------------------
-** int ifx_update_char(int bid, string content)
-**
-** updates the content of the char-object
-** bid: Id of charobject
-** content: string of new data
-** return false on error otherwise true
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifx_update_char(int bid, string content)
- updates the content of the char-object */
-PHP_FUNCTION(ifx_update_char) {
- pval *pbid,*pparam;
- long ret;
-
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &pbid,&pparam)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pbid);
- convert_to_string(pparam);
-
- ret=php3_intifx_update_char(pbid->value.lval,
- pparam->value.str.val,
- pparam->value.str.len,
- list);
- if(ret<0) {
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/* ----------------------------------------------------------------------
- * internal function
- * long php3_intifx_update_char(long bid, char* param, long len, HashTable *list)
- *
- * updates the content of the char-object
- * bid: Id of charobject
- * param: string of new data
- * len: length of string
- * list: internal hashlist of php3
- * return nothing
- * ----------------------------------------------------------------------
-*/
-static long php3_intifx_update_char(long bid, char* param, long len, HashTable *list) {
- IFX_IDRES *Ifx_char;
- int type;
-
- Ifx_char = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) && !(Ifx_char->type==TYPE_CHAR)) {
- php_error(E_WARNING,"%d is not a Informix char-result index",
- bid);
- return -1;
- }
-
- if(Ifx_char->CHAR.char_data!=NULL) {
- efree(Ifx_char->CHAR.char_data);
- }
- Ifx_char->CHAR.char_data=NULL;
- Ifx_char->CHAR.len=0;
-
- if(param==NULL || len<0) {
- Ifx_char->CHAR.char_data=NULL;
- Ifx_char->CHAR.len=0;
- } else {
- Ifx_char->CHAR.char_data=emalloc(len+1);
- if(Ifx_char->CHAR.char_data==NULL) {
- php_error(E_WARNING,"can't create char-resource");
- return -1;
- }
- memcpy(Ifx_char->CHAR.char_data,param,len);
- Ifx_char->CHAR.char_data[len]=0;
- Ifx_char->CHAR.len=len;
- }
- return 0;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-$ifdef HAVE_IFX_IUS;
-
-
-
-
-/* ----------------------------------------------------------------------
-** int ifxus_create_slob( int mode)
-**
-** creates an slob-object and opens it
-** mode: 1=LO_RDONLY, 2=LO_WRONLY, 4=LO_APPEND, 8=LO_RDWR, 16=LO_BUFFER, 32=LO_NOBUFFER -> or-mask
-** return false on error otherwise the new Slob-Object-id
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifxus_create_slob(int mode)
- creates a slob-object and opens it */
-PHP_FUNCTION(ifxus_create_slob) {
- pval *pmode;
- long id;
- long mode,create_mode;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pmode)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pmode);
-
- mode=pmode->value.lval;
-
- create_mode=0;
- if((mode&1) !=0)
- create_mode|=LO_RDONLY;
- if((mode&2) !=0)
- create_mode|=LO_WRONLY;
- if((mode&4) !=0)
- create_mode|=LO_APPEND;
- if((mode&8) !=0)
- create_mode|=LO_RDWR;
- if((mode&16) !=0)
- create_mode|=LO_BUFFER;
- if((mode&32) !=0)
- create_mode|=LO_NOBUFFER;
-
-
- id=php3_intifxus_create_slob(create_mode,list);
- if(id<0) {
- RETURN_FALSE;
- }
- RETURN_LONG(id);
-}
-/* }}} */
-
-/* ----------------------------------------------------------------------
- * internal function
- * long php3_intifx_create_slob(long create_mode, HashTable *list)
- *
- * creates an slob-object and opens it
- * mode: 1=LO_RDONLY, 2=LO_WRONLY, 4=LO_APPEND, 8=LO_RDWR, 16=LO_BUFFER, 32=LO_NOBUFFER -> or-mask
- * list: internal hashlist of php3
- * return -1 on error otherwise the new Blob-Object-id
- * ----------------------------------------------------------------------
-*/
-static long php3_intifxus_create_slob(long create_mode, HashTable *list) {
- IFX_IDRES *Ifx_slob;
- int errcode;
-
-
- Ifx_slob=emalloc(sizeof(IFX_IDRES));
- if(Ifx_slob==NULL) {
- php_error(E_WARNING,"can't create slob-resource");
- return -1;
- }
-
- errcode=ifx_lo_def_create_spec(&(Ifx_slob->SLOB.createspec));
- if(errcode<0) {
- php_error(E_WARNING,"can't create slob-resource");
- return -1;
- }
-
- Ifx_slob->type=TYPE_SLOB;
- Ifx_slob->SLOB.lofd=ifx_lo_create(Ifx_slob->SLOB.createspec,create_mode,&(Ifx_slob->SLOB.slob_data),&errcode);
- if(errcode<0 || Ifx_slob->SLOB.lofd<0) {
- php_error(E_WARNING,"can't create slob-resource");
- return -1;
- }
-
- return php3_list_insert(Ifx_slob,IFXG(le_idresult));
-}
-
-
-
-/* ----------------------------------------------------------------------
-** int ifxus_free_slob(int bid)
-**
-** deletes the slob-object
-** bid: Id of Slobobject
-** return false on error otherwise true
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifxus_free_slob(int bid)
- deletes the slob-object */
-PHP_FUNCTION(ifxus_free_slob) {
- pval *pid;
- long ret;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pid)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pid);
-
- ret=php3_intifxus_close_slob(pid->value.lval,list);
- if(ret<0) {
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-/* ----------------------------------------------------------------------
- * internal function
- * long php3_intifxus_free_slob(long bid, HashTable *list)
- *
- * deletes the slob-object
- * bid: Id of Slobobject
- * list: internal hashlist of php3
- *
- * return -1 on error otherwise 0
- * ----------------------------------------------------------------------
-*/
-static long php3_intifxus_free_slob(long bid, HashTable *list) {
- IFX_IDRES *Ifx_slob;
- int type;
-
- Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
- php_error(E_WARNING,"%d is not a Informix slob-result index",
- bid);
- return -1;
- }
-
-
- if(php3_intifxus_close_slob(bid, list)<0) {
- return -1;
- }
- if(Ifx_slob->SLOB.createspec!=NULL) {
- ifx_lo_spec_free(Ifx_slob->SLOB.createspec);
- Ifx_slob->SLOB.createspec=NULL;
- }
- efree(Ifx_slob);
- php3_list_delete(bid);
- return 0;
-}
-
-
-
-
-/* ----------------------------------------------------------------------
-** int ifxus_close_slob(int bid)
-**
-** deletes the slob-object
-** bid: Id of Slobobject
-** return false on error otherwise true
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifxus_close_slob(int bid)
- deletes the slob-object */
-PHP_FUNCTION(ifxus_close_slob) {
- pval *pid;
- long ret;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pid)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pid);
-
- ret=php3_intifxus_close_slob(pid->value.lval,list);
- if(ret<0) {
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-/* ----------------------------------------------------------------------
- * internal function
- * long php3_intifxus_close_slob(long bid, HashTable *list)
- *
- * deletes the slob-object
- * bid: Id of Slobobject
- * list: internal hashlist of php3
- *
- * return -1 on error otherwise 0
- * ----------------------------------------------------------------------
-*/
-static long php3_intifxus_close_slob(long bid, HashTable *list) {
- IFX_IDRES *Ifx_slob;
- int type;
-
- Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
- php_error(E_WARNING,"%d is not a Informix slob-result index",
- bid);
- return -1;
- }
-
-
- if(Ifx_slob->SLOB.lofd<0) {
- php_error(E_WARNING,"slob-resource already closed");
- return -1;
- }
-
- if(ifx_lo_close(Ifx_slob->SLOB.lofd)<0) {
- php_error(E_WARNING,"can't close slob-resource");
- return -1;
- }
-
- Ifx_slob->SLOB.lofd=-1;
- return 0;
-}
-
-
-
-
-
-/* ----------------------------------------------------------------------
-** int ifxus_open_slob(long bid, int mode)
-**
-** opens an slob-object
-** bid: existing slob-id
-** mode: 1=LO_RDONLY, 2=LO_WRONLY, 4=LO_APPEND, 8=LO_RDWR, 16=LO_BUFFER, 32=LO_NOBUFFER -> or-mask
-** return false on error otherwise the new Slob-Object-id
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifxus_open_slob(long bid, int mode)
- opens an slob-object */
-PHP_FUNCTION(ifxus_open_slob) {
- pval *pbid,*pmode;
- long mode,create_mode;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 1, &pbid,&pmode)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pmode);
- convert_to_long(pbid);
- mode=pmode->value.lval;
-
- create_mode=0;
- if((mode&1) !=0)
- create_mode|=LO_RDONLY;
- if((mode&2) !=0)
- create_mode|=LO_WRONLY;
- if((mode&4) !=0)
- create_mode|=LO_APPEND;
- if((mode&8) !=0)
- create_mode|=LO_RDWR;
- if((mode&16) !=0)
- create_mode|=LO_BUFFER;
- if((mode&32) !=0)
- create_mode|=LO_NOBUFFER;
-
- RETURN_LONG(php3_intifxus_open_slob(pbid->value.lval,create_mode,list));
-}
-/* }}} */
-
-
-/* ----------------------------------------------------------------------
- * internal function
- * long php3_intifx_open_slob(long bid,long create_mode, HashTable *list)
- *
- * opens an slob-object
- * mode: 1=LO_RDONLY, 2=LO_WRONLY, 4=LO_APPEND, 8=LO_RDWR, 16=LO_BUFFER, 32=LO_NOBUFFER -> or-mask
- * list: internal hashlist of php3
- * return -1 on error otherwise the new Blob-Object-id
- * ----------------------------------------------------------------------
-*/
-static long php3_intifxus_open_slob(long bid, long create_mode, HashTable *list) {
- IFX_IDRES *Ifx_slob;
- int errcode;
- int type;
-
-
- Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
- php_error(E_WARNING,"%d is not a Informix slob-result index",
- bid);
- return -1;
- }
-
- if(Ifx_slob->SLOB.lofd>0) {
- php_error(E_WARNING,"slob-resource already open");
- return -1;
- }
-
- Ifx_slob->SLOB.lofd=ifx_lo_open(&(Ifx_slob->SLOB.slob_data),create_mode,&errcode);
- if(errcode<0 || Ifx_slob->SLOB.lofd<0) {
- php_error(E_WARNING,"can't open slob-resource");
- return -1;
- }
-
- return 0;
-}
-
-
-
-
-
-
-
-/* ----------------------------------------------------------------------
- * internal function
- * long php3_intifxus_new_slob(HashTable *list)
- *
- * creates an slob-object but don't open it
- * list: internal hashlist of php3
- * return -1 on error otherwise the new slob-Object-id
- * ----------------------------------------------------------------------
-*/
-static long php3_intifxus_new_slob(HashTable *list) {
- IFX_IDRES *Ifx_slob;
-
-
- Ifx_slob=emalloc(sizeof(IFX_IDRES));
- if(Ifx_slob==NULL) {
- php_error(E_WARNING,"can't create slob-resource");
- return -1;
- }
-
- Ifx_slob->type=TYPE_SLOB;
- Ifx_slob->SLOB.lofd=-1;
- Ifx_slob->SLOB.createspec=NULL;
- return php3_list_insert(Ifx_slob,IFXG(le_idresult));
-}
-
-
-
-/* ----------------------------------------------------------------------
- * internal function
- * ifx_lo_t *php3_intifxus_get_slobloc(long bid, HashTable *list)
- *
- * retuens the ifx_lo_t-structure of a slob-object
- * list: internal hashlist of php3
- * return -1 on error otherwise the new Blob-Object-id
- * ----------------------------------------------------------------------
-*/
-static ifx_lo_t *php3_intifxus_get_slobloc(long bid, HashTable *list) {
- IFX_IDRES *Ifx_slob;
- int type;
-
- Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
- php_error(E_WARNING,"%d is not a Informix slob-result index",
- bid);
- return NULL;
- }
-
- return &(Ifx_slob->SLOB.slob_data);
-}
-
-
-
-
-
-
-
-/* ----------------------------------------------------------------------
-** int ifxus_tell_slob(long bid)
-**
-** returns the current file or seek position of an open slob-object
-** bid: existing slob-id
-** return false on error otherwise the seek-position
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifxus_tell_slob(long bid)
- returns the current file or seek position of an open slob-object */
-PHP_FUNCTION(ifxus_tell_slob) {
- pval *pbid;
- long bid;
- IFX_IDRES *Ifx_slob;
- ifx_int8_t akt_seek_pos;
- int type;
- long lakt_seek_pos;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pbid)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pbid);
- bid=pbid->value.lval;
- Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
- php_error(E_WARNING,"%d is not a Informix slob-result index",
- bid);
- RETURN_FALSE;
- }
-
- if(ifx_lo_tell(Ifx_slob->SLOB.lofd,&akt_seek_pos)<0) {
- php_error(E_WARNING,"can't perform tell-operation");
- RETURN_FALSE;
- }
-
- if(ifx_int8tolong(&akt_seek_pos,&lakt_seek_pos)<0) {
- php_error(E_WARNING,"seek-position to large for long");
- RETURN_FALSE;
- }
- RETURN_LONG(lakt_seek_pos);
-}
-/* }}} */
-
-
-
-/* ----------------------------------------------------------------------
-** int ifxus_seek_slob(long bid, int mode, long offset)
-**
-** sets the current file or seek position of an open slob-object
-** bid: existing slob-id
-** mode: 0=LO_SEEK_SET, 1=LO_SEEK_CUR, 2=LO_SEEK_END
-** offset: byte-offset
-** return false on error otherwise the seek-position
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifxus_seek_slob(long bid, int mode, long offset)
- sets the current file or seek position of an open slob-object */
-PHP_FUNCTION(ifxus_seek_slob) {
- pval *pbid, *pmode, *poffset;
- long bid,lakt_seek_pos;
- IFX_IDRES *Ifx_slob;
- ifx_int8_t akt_seek_pos,offset;
- int type,mode;
-
- if (ARG_COUNT(ht)!=3 || getParameters(ht, 3, &pbid, &pmode, &poffset)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pbid);
- convert_to_long(pmode);
- convert_to_long(poffset);
-
- bid=pbid->value.lval;
- Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
- php_error(E_WARNING,"%d is not a Informix slob-result index",
- bid);
- RETURN_FALSE;
- }
-
- mode=LO_SEEK_SET;
- if(pmode->value.lval==1) {
- mode=LO_SEEK_CUR;
- }
- if(pmode->value.lval==2) {
- mode=LO_SEEK_END;
- }
-
- ifx_int8cvlong(poffset->value.lval,&offset);
- if(ifx_lo_seek(Ifx_slob->SLOB.lofd,&offset, mode,&akt_seek_pos)<0) {
- php_error(E_WARNING,"can't perform seek-operation");
- RETURN_FALSE;
- }
-
- if(ifx_int8tolong(&akt_seek_pos,&lakt_seek_pos)<0) {
- php_error(E_WARNING,"seek-position to large for long");
- RETURN_FALSE;
- }
- RETURN_LONG(lakt_seek_pos);
-}
-/* }}} */
-
-
-
-
-/* ----------------------------------------------------------------------
-** int ifxus_read_slob(long bid, long nbytes)
-**
-** reads nbytes of the slob-object
-** bid: existing slob-id
-** nbytes: bytes zu read
-** return false on error otherwise the string
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifxus_read_slob(long bid, long nbytes)
- reads nbytes of the slob-object */
-PHP_FUNCTION(ifxus_read_slob) {
- pval *pbid, *pnbytes;
- long bid, nbytes;
- IFX_IDRES *Ifx_slob;
- int errcode,type;
- char *buffer;
-
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &pbid, &pnbytes)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pbid);
- convert_to_long(pnbytes);
-
- bid=pbid->value.lval;
- Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
- php_error(E_WARNING,"%d is not a Informix slob-result index",
- bid);
- RETURN_FALSE;
- }
-
- nbytes=pnbytes->value.lval;
- buffer=emalloc (nbytes);
- if(buffer==NULL) {
- php_error(E_WARNING,"cannot allocate memory");
- RETURN_FALSE;
- }
- if(ifx_lo_read(Ifx_slob->SLOB.lofd,buffer,nbytes,&errcode)<0) {
- efree(buffer);
- php_error(E_WARNING,"error during reading slob");
- RETURN_FALSE;
- }
-
- RETURN_STRINGL(buffer,nbytes,0);
-}
-/* }}} */
-
-
-/* ----------------------------------------------------------------------
-** int ifxus_write_slob(long bid, string content)
-**
-** writes a string into the slob-object
-** bid: existing slob-id
-** content: content to write
-** return false on error otherwise bytes written
-** ----------------------------------------------------------------------
-*/
-
-/* {{{ proto int ifxus_write_slob(long bid, string content)
- writes a string into the slob-object */
-PHP_FUNCTION(ifxus_write_slob) {
- pval *pbid, *pcontent;
- long bid, nbytes;
- IFX_IDRES *Ifx_slob;
- int errcode,type;
- char *buffer;
-
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &pbid, &pcontent)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pbid);
- convert_to_string(pcontent);
-
- bid=pbid->value.lval;
- Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
- php_error(E_WARNING,"%d is not a Informix slob-result index",
- bid);
- RETURN_FALSE;
- }
-
- buffer=pcontent->value.str.val;
- nbytes=pcontent->value.str.len;
- if(nbytes<=0) {
- php_error(E_WARNING,"string has no content");
- RETURN_FALSE;
- }
- if((nbytes=ifx_lo_write(Ifx_slob->SLOB.lofd,buffer,nbytes,&errcode))<0) {
- php_error(E_WARNING,"error during writing slob");
- RETURN_FALSE;
- }
-
- RETURN_LONG(nbytes);
-}
-/* }}} */
-
-$endif;
-
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/informix/php_informix.h b/ext/informix/php_informix.h
deleted file mode 100644
index 1f55eeb22e..0000000000
--- a/ext/informix/php_informix.h
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Danny Heijl <Danny.Heijl@cevi.be>, initial cut (ODS 7) |
- | Christian Cartus <chc@idgruppe.de>, blobs, and IUS 9 |
- | Jouni Ahto <jah@mork.net> : configuration stuff |
- | based on mysql code by: Zeev Suraski <zeev@php.net> |
- +----------------------------------------------------------------------+
- */
-
-
-#ifndef _PHP3_IFX_H
-#define _PHP3_IFX_H
-
-
-#if COMPILE_DL
-#undef HAVE_IFX
-#define HAVE_IFX 1
-#endif
-
-#if WIN32||WINNT
-#define PHP_IFX_API __declspec(dllexport)
-#else
-#define PHP_IFX_API
-#endif
-
-
-#if HAVE_IFX /* with Informix */
-
-#ifndef DLEXPORT
-#define DLEXPORT
-#endif
-
-#ifdef ZTS
-#include "TSRM.h"
-#endif
-
-extern php3_module_entry ifx_module_entry;
-#define ifx_module_ptr &ifx_module_entry
-
-
-#include "locator.h"
-#include "sqltypes.h"
-
-/* user functions */
-PHP_MINIT_FUNCTION(ifx);
-PHP_RINIT_FUNCTION(ifx);
-PHP_MSHUTDOWN_FUNCTION(ifx);
-PHP_MINFO_FUNCTION(ifx);
-/* functions common to all Informix versions */
-PHP_FUNCTION(ifx_connect);
-PHP_FUNCTION(ifx_pconnect);
-PHP_FUNCTION(ifx_close);
-PHP_FUNCTION(ifx_query);
-PHP_FUNCTION(ifx_prepare);
-PHP_FUNCTION(ifx_do);
-PHP_FUNCTION(ifx_error);
-PHP_FUNCTION(ifx_errormsg);
-PHP_FUNCTION(ifx_affected_rows);
-PHP_FUNCTION(ifx_num_rows);
-PHP_FUNCTION(ifx_num_fields);
-PHP_FUNCTION(ifx_fetch_row);
-PHP_FUNCTION(ifx_free_result);
-PHP_FUNCTION(ifx_htmltbl_result);
-PHP_FUNCTION(ifx_fieldtypes);
-PHP_FUNCTION(ifx_fieldproperties);
-PHP_FUNCTION(ifx_getsqlca);
-/* BLOB related stuff, IDS & IUS only */
-PHP_FUNCTION(ifx_create_blob);
-PHP_FUNCTION(ifx_free_blob) ;
-PHP_FUNCTION(ifx_get_blob);
-PHP_FUNCTION(ifx_update_blob);
-PHP_FUNCTION(ifx_blobinfile_mode);
-PHP_FUNCTION(ifx_copy_blob);
-PHP_FUNCTION(ifx_textasvarchar);
-PHP_FUNCTION(ifx_byteasvarchar);
-PHP_FUNCTION(ifx_nullformat);
-PHP_FUNCTION(ifx_create_char);
-PHP_FUNCTION(ifx_free_char) ;
-PHP_FUNCTION(ifx_update_char);
-PHP_FUNCTION(ifx_get_char);
-
-/* SLOB, CLOB : IUS only functions */
-#if HAVE_IFX_IUS
-PHP_FUNCTION(ifxus_create_slob);
-PHP_FUNCTION(ifxus_free_slob) ;
-PHP_FUNCTION(ifxus_close_slob) ;
-PHP_FUNCTION(ifxus_open_slob) ;
-PHP_FUNCTION(ifxus_read_slob);
-PHP_FUNCTION(ifxus_write_slob);
-PHP_FUNCTION(ifxus_seek_slob);
-PHP_FUNCTION(ifxus_tell_slob);
-#endif
-
-typedef struct {
- long default_link;
- long num_links,num_persistent;
- long max_links,max_persistent;
- long allow_persistent;
- int le_result,le_link,le_plink,le_idresult;
- char *default_host, *default_user, *default_password;
- int connectionid;
- int cursorid;
- int sv_sqlcode; /* saved informix SQLCODE value */
- long blobinfile; /* 0=save in memory, 1=save in file */
- long textasvarchar; /* 0=as id, 1=as varchar */
- long byteasvarchar; /* 0=as id, 1=as varchar */
- long charasvarchar; /* 0=don't strip trailing blanks, 1=strip */
- long nullformat; /* 0=NULL as "", 1= NULL as "NULL" */
- char *nullvalue; /* "" */
- char *nullstring; /* "NULL" */
-} php_ifx_globals; /* formerly "ifx_module" in the php3 version */
-
-#ifndef ZTS
-extern php_ifx_globals ifx_globals;
-#endif
-
-#ifdef ZTS
-# define IFXLS_D php_ifx_globals *ifx_globals
-# define IFXLS_DC , IFXLS_D
-# define IFXLS_C ifx_globals
-# define IFXLS_CC , IFXLS_C
-# define IFXG(v) (ifx_globals->v)
-# define IFXLS_FETCH() php_ifx_globals *ifx_globals = ts_resource(ifx_globals_id)
-# define IFX_TLS_VARS char *globals; IFXLS_FETCH(); globals = (char *)ifx_globals;
-#else
-# define IFXLS_D
-# define IFXLS_DC
-# define IFXLS_C
-# define IFXLS_CC
-# define IFXG(v) (ifx_globals.v)
-# define IFXLS_FETCH()
-# define IFX_TLS_VARS char *globals = (char *)&ifx_globals
-extern ZEND_API php_ifx_globals ifx_globals;
-#endif
-
-
-#define MAX_RESID 64
-#define BLOBINFILE 0 /* 0=in memory, 1=in file */
-
-/* query result set data */
-typedef struct ifx_res {
- char connecid[16];
- char cursorid[16];
- char descrpid[16];
- char statemid[16];
- int isscroll;
- int ishold;
- int iscursory;
- int paramquery;
- int numcols;
- int rowid;
- int affected_rows;
- long sqlerrd[6];
- int res_id[MAX_RESID];
-} IFX_RES;
-
-
-
-
-
-typedef struct _IFX_IDRES {
- int type;
- union {
- struct {
- int mode;
- loc_t blob_data;
- } BLOBRES;
- struct {
- char *char_data;
- int len;
- } CHARRES;
-#if HAVE_IFX_IUS
- struct {
- ifx_lo_t slob_data;
- ifx_lo_create_spec_t *createspec;
- int lofd;
- } SLOBRES;
-#endif
- } DATARES;
-} IFX_IDRES;
-
-
-
-#define BLOB DATARES.BLOBRES
-#define CHAR DATARES.CHARRES
-
-#if HAVE_IFX_IUS
-#define SLOB DATARES.SLOBRES
-#endif
-
-
-#else /* not HAVE_IFX */
-
-#define ifx_module_ptr NULL
-
-#endif
-
-#define phpext_informix_ptr ifx_module_ptr
-
-#endif /* _PHP3_IFX_H */
diff --git a/ext/informix/setup.stub b/ext/informix/setup.stub
deleted file mode 100644
index 9a9d1ad841..0000000000
--- a/ext/informix/setup.stub
+++ /dev/null
@@ -1,9 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-informix 'Informix support?' yesnodir \
- "no $INFORMIXDIR Informix home" \
-' Whether to build PHP with Informix support. If you have not set up your\n
- Informix environment, enter what $INFORMIXDIR is usually set to here.\n
- You MUST set $INFORMIXDIR before trying to compile!\n
- More info about Informix can be found at http://www.informix.com/.'
diff --git a/ext/interbase/Makefile.am b/ext/interbase/Makefile.am
deleted file mode 100644
index 494e3b9ef9..0000000000
--- a/ext/interbase/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_interbase.a
-libphpext_interbase_a_SOURCES=interbase.c
-
diff --git a/ext/interbase/config.h.stub b/ext/interbase/config.h.stub
deleted file mode 100644
index d54ee2a9d6..0000000000
--- a/ext/interbase/config.h.stub
+++ /dev/null
@@ -1,3 +0,0 @@
-#ifndef HAVE_IBASE
-#define HAVE_IBASE 0
-#endif
diff --git a/ext/interbase/config.m4 b/ext/interbase/config.m4
deleted file mode 100644
index 2328e25e1a..0000000000
--- a/ext/interbase/config.m4
+++ /dev/null
@@ -1,29 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(for InterBase support)
-AC_ARG_WITH(interbase,
-[ --with-interbase[=DIR] Include InterBase support. DIR is the InterBase base
- install directory, defaults to /usr/interbase],
-[
- if test "$withval" != "no"; then
- if test "$withval" = "yes"; then
- IBASE_INCDIR=/usr/interbase/include
- IBASE_LIBDIR=/usr/interbase/lib
- else
- IBASE_INCDIR=$withval/include
- IBASE_LIBDIR=$withval/lib
- fi
- IBASE_INCLUDE=-I$IBASE_INCDIR
- IBASE_LFLAGS=-L$IBASE_LIBDIR
- IBASE_LIBS="-lgds"
- AC_DEFINE(HAVE_IBASE)
- AC_MSG_RESULT(yes)
- EXTRA_LIBS="$EXTRA_LIBS $IBASE_LFLAGS $IBASE_LIBS"
- INCLUDES="$INCLUDES $IBASE_INCLUDE"
- PHP_EXTENSION(interbase)
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
diff --git a/ext/interbase/interbase.c b/ext/interbase/interbase.c
deleted file mode 100644
index 1f12608629..0000000000
--- a/ext/interbase/interbase.c
+++ /dev/null
@@ -1,1117 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Jouni Ahto <jah@cultnet.fi> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/* TODO: A lot... */
-
-#include "php.h"
-#include "php_config.h"
-#include "php3_interbase.h"
-
-#if HAVE_IBASE
-#include <ibase.h>
-#include <time.h>
-#include "php3_string.h"
-#include "php_globals.h"
-
-/* {{{ extension definition structures */
-function_entry ibase_functions[] = {
- PHP_FE(ibase_connect, NULL)
- PHP_FE(ibase_pconnect, NULL)
- PHP_FE(ibase_close, NULL)
- PHP_FE(ibase_query, NULL)
- PHP_FE(ibase_fetch_row, NULL)
- PHP_FE(ibase_free_result, NULL)
- PHP_FE(ibase_prepare, NULL)
- PHP_FE(ibase_bind, NULL)
- PHP_FE(ibase_execute, NULL)
- PHP_FE(ibase_free_query, NULL)
- PHP_FE(ibase_timefmt, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry ibase_module_entry =
-{
- "InterBase",
- ibase_functions,
- PHP_MINIT(ibase),
- NULL,
- PHP_RINIT(ibase),
- NULL,
- PHP_MINFO(ibase),
- STANDARD_MODULE_PROPERTIES
-};
-/* }}} */
-
-/* {{{ thread safety stuff */
-#if defined(THREAD_SAFE)
-typedef ibase_global_struct{
- ibase_module php3_ibase_module;
-} ibase_global_struct;
-
-#define IBASE_GLOBAL(a) ibase_globals->a
-
-#define IBASE_TLS_VARS \
- ibase_global_struct *ibase_globals; \
- ibase_globals=TlsGetValue(IBASETls);
-
-#else
-#define IBASE_GLOBAL(a) a
-#define IBASE_TLS_VARS
-ibase_module php3_ibase_module;
-#endif
-/* }}} */
-
-/* {{{ _php3_ibase_close_link() */
-static void _php3_ibase_close_link(isc_db_handle db)
-{
- ISC_STATUS status[20];
- IBASE_TLS_VARS;
-
- isc_detach_database(status, &db);
- IBASE_GLOBAL(php3_ibase_module).num_links--;
-}
-/* }}} */
-
-/* {{{ _php3_ibase_close_plink() */
-static void _php3_ibase_close_plink(isc_db_handle db)
-{
- ISC_STATUS status[20];
- IBASE_TLS_VARS;
-
- isc_detach_database(status, &db);
- php3_ibase_module.num_persistent--;
- php3_ibase_module.num_links--;
-}
-/* }}} */
-
-/* {{{ _php3_ibase_free_result() */
-static void _php3_ibase_free_result(ibase_result_handle *result)
-{
- int i;
- ISC_STATUS status[20];
- IBASE_TLS_VARS;
-
- if (!IBASE_GLOBAL(php3_ibase_module).manualtransactions && result->commitok) {
- isc_commit_transaction(status, &result->trans);
- }
- if (result->sqlda != NULL) {
- for (i = 0; i < result->sqlda->sqld; i++) {
- efree(result->sqlda->sqlvar[i].sqldata);
- efree(result->sqlda->sqlvar[i].sqlind);
- }
- efree(result->sqlda);
- }
- isc_dsql_free_statement(status, &result->result, DSQL_drop);
- efree(result);
-}
-/* }}} */
-
-/* {{{ _php3_ibase_free_query() */
-static void _php3_ibase_free_query(ibase_query_handle *query)
-{
- int i;
- ISC_STATUS status[20];
-
- if (query->sqlda != NULL) {
- if (query->alloced) {
- for (i = 0; i < query->sqlda->sqld; i++) {
- efree(query->sqlda->sqlvar[i].sqldata);
- efree(query->sqlda->sqlvar[i].sqlind);
- }
- }
- efree(query->sqlda);
- }
- isc_dsql_free_statement(status, &query->query, DSQL_drop);
- efree(query);
-}
-/* }}} */
-
-/* {{{ startup, shutdown and info functions */
-PHP_MINIT_FUNCTION(ibase)
-{
- IBASE_TLS_VARS;
-
- if (cfg_get_long("ibase.allow_persistent", &IBASE_GLOBAL(php3_ibase_module).allow_persistent) == FAILURE) {
- IBASE_GLOBAL(php3_ibase_module).allow_persistent = 1;
- }
- if (cfg_get_long("ibase.max_persistent", &IBASE_GLOBAL(php3_ibase_module).max_persistent) == FAILURE) {
- IBASE_GLOBAL(php3_ibase_module).max_persistent = -1;
- }
- if (cfg_get_long("ibase.max_links", &IBASE_GLOBAL(php3_ibase_module).max_links) == FAILURE) {
- IBASE_GLOBAL(php3_ibase_module).max_links = -1;
- }
- /*
- if (cfg_get_long("ibase.manualtransactions", &IBASE_GLOBAL(php3_ibase_module).manualtransactions) == FAILURE) {
- IBASE_GLOBAL(php3_ibase_module).manualtransactions = 0;
- }
- */
- IBASE_GLOBAL(php3_ibase_module).manualtransactions = 0;
- if (cfg_get_string("ibase.default_user", &IBASE_GLOBAL(php3_ibase_module).default_user) == FAILURE
- || IBASE_GLOBAL(php3_ibase_module).default_user[0] == 0) {
- IBASE_GLOBAL(php3_ibase_module).default_user = "";
- }
- if (cfg_get_string("ibase.default_password", &IBASE_GLOBAL(php3_ibase_module).default_password) == FAILURE
- || IBASE_GLOBAL(php3_ibase_module).default_password[0] == 0) {
- IBASE_GLOBAL(php3_ibase_module).default_password = "";
- }
- if (cfg_get_string("ibase.timeformat", &IBASE_GLOBAL(php3_ibase_module).timeformat) == FAILURE) {
- IBASE_GLOBAL(php3_ibase_module).timeformat = "%Y-%m-%d %H:%M:%S";
- }
- IBASE_GLOBAL(php3_ibase_module).num_persistent=0;
- IBASE_GLOBAL(php3_ibase_module).le_result = register_list_destructors(_php3_ibase_free_result, NULL);
- IBASE_GLOBAL(php3_ibase_module).le_query = register_list_destructors(_php3_ibase_free_query, NULL);
- IBASE_GLOBAL(php3_ibase_module).le_link = register_list_destructors(_php3_ibase_close_link, NULL);
- IBASE_GLOBAL(php3_ibase_module).le_plink = register_list_destructors(NULL, _php3_ibase_close_plink);
- return SUCCESS;
-}
-
-PHP_RINIT_FUNCTION(ibase)
-{
- IBASE_TLS_VARS;
-
- IBASE_GLOBAL(php3_ibase_module).default_link=-1;
- IBASE_GLOBAL(php3_ibase_module).num_links = php3_ibase_module.num_persistent;
- return SUCCESS;
-}
-
-/* TODO IF NEEDED
-
-int php3_mfinish_ibase(void)
-{
-}
-
-int php3_rfinish_ibase(void)
-{
-}
-*/
-
-PHP_MINFO_FUNCTION(ibase)
-{
- /* TODO */
-}
-/* }}} */
-
-/* {{{ _php_ibase_attach_db() */
-static int _php_ibase_attach_db(char *server, char *uname, int uname_len, char *passwd, int passwd_len, isc_db_handle *db)
-{
- ISC_STATUS status[20];
- int db_parbuf_len = 4;
- short foo = 4;
- char dpb[255], *db_parbuf;
-
- if (uname_len) {
- db_parbuf_len += uname_len + 2;
- }
-
- if (passwd_len) {
- db_parbuf_len += passwd_len + 2;
- }
-
- db_parbuf = dpb;
- *db_parbuf++ = isc_dpb_version1;
- *db_parbuf++ = isc_dpb_num_buffers;
- *db_parbuf++ = 1;
- *db_parbuf++ = 90;
-
- if (uname_len) {
- if (passwd_len) {
- isc_expand_dpb(&db_parbuf, &foo, isc_dpb_user_name, uname, isc_dpb_password, passwd, NULL);
- } else {
- isc_expand_dpb(&db_parbuf, &foo, isc_dpb_user_name, uname, NULL);
- }
- }
-
- isc_attach_database(status, strlen(server), server, db, db_parbuf_len, dpb);
-
- if (status[0] == 1 && status[1]) {
- php_error(E_WARNING,"Unable to connect to InterBase server: %s", "XXX");
- return 1;
- }
- return 0;
-}
-/* }}} */
-
-/* {{{ _php3_ibase_connect() */
-static void _php3_ibase_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
-{
- pval *server, *uname, *passwd;
-
- char *ib_server, *ib_uname, *ib_passwd;
- int ib_server_len, ib_uname_len, ib_passwd_len;
- isc_db_handle db_handle = NULL;
- char *hashed_details;
- int hashed_details_length;
- IBASE_TLS_VARS;
-
- ib_uname = IBASE_GLOBAL(php3_ibase_module).default_user;
- ib_passwd = IBASE_GLOBAL(php3_ibase_module).default_password;
- ib_uname_len = ib_uname ? strlen(ib_uname) : 0;
- ib_passwd_len = ib_passwd ? strlen(ib_passwd) : 0;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- {
- if (getParameters(ht, 1, &server) == FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(server);
- ib_server = server->value.str.val;
- ib_server_len = server->value.str.len;
- hashed_details_length = server->value.str.len+ib_uname_len+ib_passwd_len+5+3;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details, "ibase_%s_%s_%s", ib_server, ib_uname, ib_passwd);
- }
- break;
- case 2:
- {
- if (getParameters(ht, 2, &server, &uname) == FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(server);
- convert_to_string(uname);
- ib_server = server->value.str.val;
- ib_uname = uname->value.str.val;
- ib_server_len = server->value.str.len;
- ib_uname_len = uname->value.str.len;
- hashed_details_length = server->value.str.len+uname->value.str.len+ib_passwd_len+5+3;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details, "ibase_%s_%s_%s", ib_server, ib_uname, ib_passwd);
- }
- break;
- case 3:
- {
- if (getParameters(ht, 3, &server, &uname, &passwd) == FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(server);
- convert_to_string(uname);
- convert_to_string(passwd);
- ib_server = server->value.str.val;
- ib_uname = uname->value.str.val;
- ib_passwd = passwd->value.str.val;
- ib_server_len = server->value.str.len;
- ib_uname_len = uname->value.str.len;
- ib_passwd_len = passwd->value.str.len;
- hashed_details_length = server->value.str.len+uname->value.str.len+passwd->value.str.len+5+3;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details, "ibase_%s_%s_%s", ib_server, ib_uname, ib_passwd);
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- if (persistent) {
- list_entry *le;
-
- if (zend_hash_find(plist, hashed_details, hashed_details_length+1, (void **) &le)==FAILURE) {
- list_entry new_le;
-
- if (IBASE_GLOBAL(php3_ibase_module).max_links!=-1 && IBASE_GLOBAL(php3_ibase_module).num_links>=IBASE_GLOBAL(php3_ibase_module).max_links) {
- php_error(E_WARNING,"InterBase: Too many open links (%d)", IBASE_GLOBAL(php3_ibase_module).num_links);
- efree(hashed_details);
- RETURN_FALSE;
- }
- if (IBASE_GLOBAL(php3_ibase_module).max_persistent!=-1 && IBASE_GLOBAL(php3_ibase_module).num_persistent>=IBASE_GLOBAL(php3_ibase_module).max_persistent) {
- php_error(E_WARNING,"InterBase: Too many open persistent links (%d)", IBASE_GLOBAL(php3_ibase_module).num_persistent);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- /* create the link */
-
- if (_php_ibase_attach_db(ib_server, ib_uname, ib_uname_len, ib_passwd, ib_passwd_len, &db_handle)) {
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- /* hash it up */
- new_le.type = php3_ibase_module.le_plink;
- new_le.ptr = db_handle;
- if (zend_hash_update(plist, hashed_details, hashed_details_length+1, (void *) &new_le, sizeof(list_entry), NULL)==FAILURE) {
- efree(hashed_details);
- RETURN_FALSE;
- }
- IBASE_GLOBAL(php3_ibase_module).num_links++;
- IBASE_GLOBAL(php3_ibase_module).num_persistent++;
- } else {
- if (le->type != IBASE_GLOBAL(php3_ibase_module).le_plink) {
- RETURN_FALSE;
- }
- /* TODO: ensure that the link did not die */
-
- db_handle = (isc_db_handle) le->ptr;
- }
- return_value->value.lval = php3_list_insert(db_handle, IBASE_GLOBAL(php3_ibase_module).le_plink);
- return_value->type = IS_LONG;
- } else {
- list_entry *index_ptr, new_index_ptr;
-
- /* first we check the hash for the hashed_details key. if it exists,
- * it should point us to the right offset where the actual pgsql link sits.
- * if it doesn't, open a new pgsql link, add it to the resource list,
- * and add a pointer to it with hashed_details as the key.
- */
- if (zend_hash_find(list,hashed_details,hashed_details_length+1,(void **) &index_ptr)==SUCCESS) {
- int type,link;
- void *ptr;
-
- if (index_ptr->type != le_index_ptr) {
- RETURN_FALSE;
- }
- link = (int) index_ptr->ptr;
- ptr = php3_list_find(link,&type); /* check if the link is still there */
- if (ptr && (type==IBASE_GLOBAL(php3_ibase_module).le_link || type==IBASE_GLOBAL(php3_ibase_module).le_plink)) {
- return_value->value.lval = IBASE_GLOBAL(php3_ibase_module).default_link = link;
- return_value->type = IS_LONG;
- efree(hashed_details);
- return;
- } else {
- zend_hash_del(list,hashed_details,hashed_details_length+1);
- }
- }
- if (IBASE_GLOBAL(php3_ibase_module).max_links!=-1 && IBASE_GLOBAL(php3_ibase_module).num_links>=IBASE_GLOBAL(php3_ibase_module).max_links) {
- php_error(E_WARNING,"InterBase: Too many open links (%d)", IBASE_GLOBAL(php3_ibase_module).num_links);
- efree(hashed_details);
- RETURN_FALSE;
- }
- /* create the link */
-
- if (_php_ibase_attach_db(ib_server, ib_uname, ib_uname_len, ib_passwd, ib_passwd_len, &db_handle)) {
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- /* add it to the list */
- return_value->value.lval = php3_list_insert(db_handle, IBASE_GLOBAL(php3_ibase_module).le_link);
- return_value->type = IS_LONG;
-
- /* add it to the hash */
- new_index_ptr.ptr = (void *) return_value->value.lval;
- new_index_ptr.type = le_index_ptr;
- if (zend_hash_update(list,hashed_details,hashed_details_length+1,(void *) &new_index_ptr, sizeof(list_entry), NULL)==FAILURE) {
- efree(hashed_details);
- RETURN_FALSE;
- }
- IBASE_GLOBAL(php3_ibase_module).num_links++;
- }
- efree(hashed_details);
- IBASE_GLOBAL(php3_ibase_module).default_link=return_value->value.lval;
-}
-/* }}} */
-
-/* {{{ proto int ibase_connect(string database [, string username] [, string password])
- Open a connection to an InterBase database */
-PHP_FUNCTION(ibase_connect)
-{
- _php3_ibase_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ proto int ibase_pconnect(string database [, string username] [, string password])
- Open a persistent connection to an InterBase database */
-PHP_FUNCTION(ibase_pconnect)
-{
- _php3_ibase_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-/* {{{ proto int ibase_close([int link_identifier])
- Close an InterBase connection */
-PHP_FUNCTION(ibase_close)
-{
- pval *ibase_link;
- int id, type;
- isc_db_handle db_handle;
- IBASE_TLS_VARS;
-
- switch (ARG_COUNT(ht)) {
- case 0:
- id = IBASE_GLOBAL(php3_ibase_module).default_link;
- break;
- case 1:
- if (getParameters(ht, 1, &ibase_link) == FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(ibase_link);
- id = ibase_link->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- db_handle = (isc_db_handle) php3_list_find(id, &type);
- if (type!=IBASE_GLOBAL(php3_ibase_module).le_link && type!=IBASE_GLOBAL(php3_ibase_module).le_plink) {
- php_error(E_WARNING, "%d is not an InterBase link index",id);
- RETURN_FALSE;
- }
-
- php3_list_delete(ibase_link->value.lval);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ _php3_ibase_prepare() */
-static XSQLDA *_php3_ibase_prepare(isc_db_handle db, isc_tr_handle tr, isc_stmt_handle *query_handle, char *query)
-{
- ISC_STATUS status[20];
- XSQLDA *isqlda;
-
- isqlda = (XSQLDA *) emalloc(XSQLDA_LENGTH(0));
- isqlda->sqln = 0;
- isqlda->version = SQLDA_VERSION1;
-
- if (isc_dsql_allocate_statement(status, &db, query_handle)) {
- php_error(E_WARNING, "InterBase: couldn't allocate space for query");
- return NULL;
- }
-
- if (isc_dsql_prepare(status, &tr, query_handle, 0, query, 1, isqlda)) {
- php_error(E_WARNING, "InterBase: couldn't prepare query");
- return NULL;
- }
-
- /*
- * Check if query has placeholders and needs binding. If it has, allocate
- * input sqlda big enough and return it.
- */
-
-
- if (isc_dsql_describe_bind(status, query_handle, 1, isqlda)) {
- php_error(E_WARNING, "InterBase: couldn't describe placeholders in query");
- }
-
- if (isqlda->sqld > 1) {
- isqlda = (XSQLDA *) erealloc(isqlda, XSQLDA_LENGTH(isqlda->sqld));
- isqlda->sqln = isqlda->sqld;
- isqlda->version = SQLDA_VERSION1;
- if (isc_dsql_describe(status, query_handle, 1, isqlda)) {
- php_error(E_WARNING, "InterBase: couldn't describe query");
- }
- return isqlda;
- } else if (isqlda->sqld == 1) {
- return isqlda;
- } else {
- efree(isqlda);
- return NULL;
- }
-}
-/* }}} */
-
-/* {{{ _php3_ibase_execute() */
-static XSQLDA *_php3_ibase_execute(isc_tr_handle tr_handle, isc_stmt_handle query_handle, XSQLDA *isqlda, ISC_STATUS *status)
-{
- int i, coltype;
- static char query_info[] = { isc_info_sql_stmt_type };
- char info_buffer[18];
- short l;
- long query_type;
- XSQLDA *osqlda;
-
- /*
- * Find out what kind of query is to be executed.
- */
-
- if (!isc_dsql_sql_info(status, &query_handle, sizeof(query_info), query_info, sizeof(info_buffer), info_buffer)) {
- l = (short) isc_vax_integer((char ISC_FAR *) info_buffer + 1, 2);
- query_type = isc_vax_integer((char ISC_FAR *) info_buffer + 3, l);
- }
-
- if (query_type == isc_info_sql_stmt_select || query_type == isc_info_sql_stmt_select_for_upd) {
- /*
- * Select, need to allocate output sqlda and and prepare it for use.
- */
-
- osqlda = (XSQLDA *) emalloc(XSQLDA_LENGTH(0));
- osqlda->sqln = 0;
- osqlda->version = SQLDA_VERSION1;
-
- if (isc_dsql_describe(status, &query_handle, 1, osqlda)) {
- php_error(E_WARNING, "InterBase: couldn't describe query");
- }
-
- if (osqlda->sqld) {
- osqlda = (XSQLDA *) erealloc(osqlda, XSQLDA_LENGTH(osqlda->sqld));
- osqlda->sqln = osqlda->sqld;
- osqlda->version = SQLDA_VERSION1;
- if (isc_dsql_describe(status, &query_handle, 1, osqlda)) {
- php_error(E_WARNING, "InterBase: couldn't describe query");
- }
- }
- for (i = 0; i < osqlda->sqld; i++) {
- osqlda->sqlvar[i].sqlind = (short *) emalloc(sizeof(short));
- coltype = osqlda->sqlvar[i].sqltype & ~1;
- switch(coltype)
- {
- case SQL_TEXT:
- osqlda->sqlvar[i].sqldata = (char *) emalloc(sizeof(char)*(osqlda->sqlvar[i].sqllen));
- break;
- case SQL_VARYING:
- osqlda->sqlvar[i].sqldata = (char *) emalloc(sizeof(char)*(osqlda->sqlvar[i].sqllen+2));
- break;
- case SQL_SHORT:
- osqlda->sqlvar[i].sqldata = (char *) emalloc(sizeof(short));
- break;
- case SQL_LONG:
- osqlda->sqlvar[i].sqldata = (char *) emalloc(sizeof(long));
- break;
- case SQL_FLOAT:
- osqlda->sqlvar[i].sqldata = (char *) emalloc(sizeof(float));
- break;
- case SQL_DOUBLE:
- osqlda->sqlvar[i].sqldata = (char *) emalloc(sizeof(double));
- break;
- case SQL_DATE:
- osqlda->sqlvar[i].sqldata = (char *) emalloc(sizeof(ISC_QUAD));
- break;
- case SQL_BLOB:
- osqlda->sqlvar[i].sqldata = (char *) emalloc(sizeof(ISC_QUAD));
- break;
- case SQL_ARRAY:
- osqlda->sqlvar[i].sqldata = (char *) emalloc(sizeof(ISC_QUAD));
- break;
- }
- }
- if (isqlda == NULL) {
- if (isc_dsql_execute(status, &tr_handle, &query_handle, 1, NULL)) {
- php_error(E_WARNING, "InterBase: couldn't execute query");
- return NULL;
- } else {
- return osqlda;
- }
-
- } else {
- if (isc_dsql_execute2(status, &tr_handle, &query_handle, 1, isqlda, osqlda)) {
- php_error(E_WARNING, "InterBase: couldn't execute query");
- return NULL;
- } else {
- return osqlda;
- }
-
- }
- } else {
- /* Not select */
- if (isc_dsql_execute(status, &tr_handle, &query_handle, 1, isqlda)) {
- php_error(E_WARNING, "InterBase: couldn't execute query");
- }
- /*
- if (!php3_ibase_module.manualtransactions) {
- if(0) {
- isc_commit_transaction(status, tr_handle);
- } else {
- isc_rollback_transaction(status, tr_handle);
- }
- }
- */
- }
-
- return NULL;
-}
-/* }}} */
-
-/* {{{ proto int ibase_query([int link_identifier, ]string query)
- Execute a query (without parameter placeholders). */
-PHP_FUNCTION(ibase_query)
-{
- pval *query, *ibase_link;
- int id, type;
- isc_db_handle db_handle;
- isc_tr_handle tr_handle = NULL;
- isc_stmt_handle query_handle = NULL;
- ISC_STATUS status[20];
- XSQLDA *isqlda, *osqlda;
- ibase_result_handle *ibase_result;
- IBASE_TLS_VARS;
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &query) == FAILURE) {
- RETURN_FALSE;
- }
- id = IBASE_GLOBAL(php3_ibase_module).default_link;
- break;
- case 2:
- if (getParameters(ht, 2, &ibase_link, &query) == FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(ibase_link);
- id = ibase_link->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- db_handle = (isc_db_handle) php3_list_find(id, &type);
- if (type!=IBASE_GLOBAL(php3_ibase_module).le_link && type!=IBASE_GLOBAL(php3_ibase_module).le_plink) {
- php_error(E_WARNING, "%d is not an InterBase link index", id);
- RETURN_FALSE;
- }
-
- convert_to_string(query);
-
- if (!IBASE_GLOBAL(php3_ibase_module).manualtransactions) {
- if (isc_start_transaction(status, &tr_handle, 1, &db_handle, 0, NULL)) {
- php_error(E_WARNING, "InterBase: couldn't start transaction");
- RETURN_FALSE;
- }
- }
-
- isqlda = _php3_ibase_prepare(db_handle, tr_handle, &query_handle, query->value.str.val);
- if (isqlda != NULL) {
- isc_rollback_transaction(status, &tr_handle);
- isc_dsql_free_statement(status, &query_handle, DSQL_drop);
- php_error(E_WARNING, "InterBase: ibase_query doesn't support parameter placeholders in query");
- RETURN_FALSE;
- }
-
- osqlda = _php3_ibase_execute(tr_handle, query_handle, isqlda, status);
- if (osqlda != NULL) {
- ibase_result = (ibase_result_handle *) emalloc(sizeof(ibase_result_handle));
- ibase_result->result = query_handle;
- ibase_result->sqlda = osqlda;
- ibase_result->trans = tr_handle;
- ibase_result->commitok = 1;
- return_value->value.lval = php3_list_insert(ibase_result, php3_ibase_module.le_result);
- return_value->type = IS_LONG;
- } else {
- if (status[0] == 1 && status[1]) {
- if (!IBASE_GLOBAL(php3_ibase_module).manualtransactions) {
- isc_rollback_transaction(status, &tr_handle);
- isc_dsql_free_statement(status, &query_handle, DSQL_drop);
- RETURN_FALSE;
- }
- } else {
- if (!IBASE_GLOBAL(php3_ibase_module).manualtransactions) {
- isc_commit_transaction(status, &tr_handle);
- isc_dsql_free_statement(status, &query_handle, DSQL_drop);
- RETURN_FALSE;
- }
- }
- }
-}
-/* }}} */
-
-/* {{{ proto int ibase_fetch_row(int result)
- Fetch a row from the results of a query. */
-PHP_FUNCTION(ibase_fetch_row)
-{
- pval *result;
- pval *pval_ptr;
- int type;
- int i, coltype, collen;
- char string_data[255];
- char *fieldname;
- char *char_data;
- /*
- struct tm t;
- */
- ibase_result_handle *ibase_result;
- ISC_STATUS status[20];
- XSQLVAR *var;
- IBASE_VCHAR *vchar;
- IBASE_TLS_VARS;
- PLS_FETCH();
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(result);
- ibase_result = (ibase_result_handle *) php3_list_find(result->value.lval, &type);
-
- if (type!=IBASE_GLOBAL(php3_ibase_module).le_result) {
- php_error(E_WARNING,"%d is not an InterBase result index", result->value.lval);
- RETURN_FALSE;
- }
-
- if (ibase_result->sqlda == NULL) {
- php_error(E_WARNING,"InterBase: trying to fetch results from a non-select query");
- RETURN_FALSE;
- }
-
- var = ibase_result->sqlda->sqlvar;
-
- if (isc_dsql_fetch(status, &ibase_result->result, 1, ibase_result->sqlda) != 100L) {
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
-
- for (i = 0; i < ibase_result->sqlda->sqld; i++) {
- var[i].sqlname[var[i].sqlname_length] = '\0';
- fieldname = var[i].sqlname;
- if (*var[i].sqlind < 0) {
- /* XXX. Column is NULL. This is not the best idea to do, think something... */
- add_get_index_stringl(return_value, i, NULL, 0, (void **) &pval_ptr, 1);
- zend_hash_pointer_update(return_value->value.ht, fieldname, var[i].sqlname_length+1, pval_ptr);
- continue;
- }
- coltype = var[i].sqltype & ~1;
- switch(coltype) {
- case SQL_TEXT:
- {
- int len = var[i].sqllen;
- char_data = (char *)emalloc(sizeof(char)*(var[i].sqllen));
- collen = sprintf(char_data, "%*.*s", len, len, ibase_result->sqlda->sqlvar[i].sqldata);
- if (PG(magic_quotes_runtime)) {
- int newlen;
- char *tmp = php_addslashes(char_data, collen, &newlen, 0);
- add_get_index_stringl(return_value, i, tmp, newlen, (void **) &pval_ptr, 0);
- } else {
- add_get_index_stringl(return_value, i, char_data, collen, (void **) &pval_ptr, 1);
- }
- zend_hash_pointer_update(return_value->value.ht, fieldname, var[i].sqlname_length+1, pval_ptr);
- efree(char_data);
- }
- break;
- case SQL_VARYING:
- {
- vchar = (IBASE_VCHAR *) var[i].sqldata;
- char_data = (char *)emalloc(sizeof(char)*(vchar->var_len));
- collen = sprintf(char_data, "%*.*s", vchar->var_len, vchar->var_len, vchar->var_str);
- if (PG(magic_quotes_runtime)) {
- int newlen;
- char *tmp = php_addslashes(char_data, collen, &newlen, 0);
- add_get_index_stringl(return_value, i, tmp, newlen, (void **) &pval_ptr, 0);
- } else {
- add_get_index_stringl(return_value, i, char_data, collen, (void **) &pval_ptr, 1);
- }
- zend_hash_pointer_update(return_value->value.ht, fieldname, var[i].sqlname_length+1, pval_ptr);
- efree(char_data);
- }
- break;
- case SQL_SHORT:
- collen = sprintf(string_data, "%d", *(short *)(var[i].sqldata));
- add_get_index_stringl(return_value, i, string_data, collen, (void **) &pval_ptr, 1);
- zend_hash_pointer_update(return_value->value.ht, fieldname, var[i].sqlname_length+1, pval_ptr);
- break;
- case SQL_LONG:
- if (var[i].sqlscale) {
- int j, f = 1;
- float n;
- n = *(long *)(var[i].sqldata);
- for (j = 0; j < -var[i].sqlscale; j++)
- f *= 10;
- n /= f;
- collen = sprintf(string_data, "%.*f", -var[i].sqlscale, n);
-
- } else {
- collen = sprintf(string_data, "%ld", *(long *)(var[i].sqldata));
- }
- add_get_index_stringl(return_value, i, string_data, collen, (void **) &pval_ptr, 1);
- zend_hash_pointer_update(return_value->value.ht, fieldname, var[i].sqlname_length+1, pval_ptr);
- break;
- case SQL_FLOAT:
- collen = sprintf(string_data, "%f", *(float *)(var[i].sqldata));
- add_get_index_stringl(return_value, i, string_data, collen, (void **) &pval_ptr, 1);
- zend_hash_pointer_update(return_value->value.ht, fieldname, var[i].sqlname_length+1, pval_ptr);
- break;
- case SQL_DOUBLE:
- if (ibase_result->sqlda->sqlvar[i].sqlscale) {
- collen = sprintf(string_data, "%.*f", -var[i].sqlscale, *(double *)(var[i].sqldata));
- } else {
- collen = sprintf(string_data, "%f", *(double *)(var[i].sqldata));
- }
- add_get_index_stringl(return_value, i, string_data, collen, (void **) &pval_ptr, 1);
- zend_hash_pointer_update(return_value->value.ht, fieldname, var[i].sqlname_length+1, pval_ptr);
- break;
- case SQL_DATE: {
- struct tm *t;
- t = emalloc(sizeof(struct tm));
-
- isc_decode_date((ISC_QUAD *) var[i].sqldata, t);
- /*
-#if HAVE_STRFTIME
- collen = (int) strftime(string_data, 255, IBASE_GLOBAL(php3_ibase_module).timeformat, t);
-#else
- */
- collen = sprintf(string_data, "%4d-%02d-%02d %02d:%02d:%02d", t->tm_year+1900, t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
- /* #endif */
- add_get_index_stringl(return_value, i, string_data, collen, (void **) &pval_ptr, 1);
- zend_hash_pointer_update(return_value->value.ht, fieldname, var[i].sqlname_length+1, pval_ptr);
- efree(t);
- }
- break;
- case SQL_BLOB:
- case SQL_ARRAY:
- {
- /* TODO, currently just show the id */
- ISC_QUAD bid;
- bid = *(ISC_QUAD ISC_FAR *) var[i].sqldata;
- sprintf(string_data, "%lx:%lx", bid.isc_quad_high, bid.isc_quad_low);
- add_get_index_stringl(return_value, i, string_data, collen, (void **) &pval_ptr, 1);
- zend_hash_pointer_update(return_value->value.ht, fieldname, var[i].sqlname_length+1, pval_ptr);
- }
- break;
- default:
- break;
- }
- }
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int ibase_free_result(int result)
- Free the memory used by a result. */
-PHP_FUNCTION(ibase_free_result)
-{
- pval *result;
- ibase_result_handle *ibase_result;
- int type;
- IBASE_TLS_VARS;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(result);
- if (result->value.lval==0) {
- RETURN_FALSE;
- }
-
- ibase_result = (ibase_result_handle *) php3_list_find(result->value.lval,&type);
-
- if (type!=IBASE_GLOBAL(php3_ibase_module).le_result) {
- php_error(E_WARNING,"%d is not an InterBase result index",result->value.lval);
- RETURN_FALSE;
- }
- php3_list_delete(result->value.lval);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int ibase_prepare([int link_identifier, ]string query)
- Prepare a query for later binding of parameter placeholders and execution. */
-PHP_FUNCTION(ibase_prepare)
-{
- pval *query, *ibase_link;
- int id, type;
- isc_db_handle db_handle;
- isc_tr_handle tr_handle = NULL;
- isc_stmt_handle query_handle = NULL;
- ISC_STATUS status[20];
- XSQLDA *isqlda;
- ibase_query_handle *ibase_query;
- IBASE_TLS_VARS;
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &query) == FAILURE) {
- RETURN_FALSE;
- }
- id = IBASE_GLOBAL(php3_ibase_module).default_link;
- break;
- case 2:
- if (getParameters(ht, 2, &ibase_link, &query) == FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(ibase_link);
- id = ibase_link->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- db_handle = (isc_db_handle) php3_list_find(id, &type);
- if (type!=IBASE_GLOBAL(php3_ibase_module).le_link && type!=IBASE_GLOBAL(php3_ibase_module).le_plink) {
- php_error(E_WARNING, "%d is not an InterBase link index", id);
- RETURN_FALSE;
- }
-
- convert_to_string(query);
-
- if (!IBASE_GLOBAL(php3_ibase_module).manualtransactions) {
- if (isc_start_transaction(status, &tr_handle, 1, &db_handle, 0, NULL)) {
- php_error(E_WARNING, "InterBase: couldn't start transaction");
- RETURN_FALSE;
- }
- }
-
- isqlda = _php3_ibase_prepare(db_handle, tr_handle, &query_handle, query->value.str.val);
- ibase_query = (ibase_query_handle *) emalloc(sizeof(ibase_query_handle));
- ibase_query->query = query_handle;
- ibase_query->sqlda = isqlda;
- ibase_query->trans = tr_handle;
- ibase_query->alloced = 0;
- return_value->value.lval = php3_list_insert(ibase_query, php3_ibase_module.le_query);
- return_value->type = IS_LONG;
-}
-/* }}} */
-
-/* {{{ proto int ibase_bind (int query)
- Bind parameter placeholders in a previously prepared query. Still nonfunctional. */
-PHP_FUNCTION(ibase_bind)
-{
- pval *query;
- ibase_query_handle *ibase_query;
- int type;
- IBASE_TLS_VARS;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &query)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(query);
- if (query->value.lval==0) {
- RETURN_FALSE;
- }
-
- ibase_query = (ibase_query_handle *) php3_list_find(query->value.lval,&type);
-
- if (type!=IBASE_GLOBAL(php3_ibase_module).le_query) {
- php_error(E_WARNING,"%d is not an InterBase query index",query->value.lval);
- RETURN_FALSE;
- }
-
- if (ibase_query->sqlda == NULL) {
- php_error(E_WARNING,"InterBase: trying to bind a query having no parameter placeholders");
- RETURN_FALSE;
- }
-
- /* TODO
- for (i = 0; i < ibase_query->sqlda->sqld; i++) {
- ibase_query->sqlda->sqlvar[i].sqlind = (short *) emalloc(sizeof(short));
- coltype = ibase_query->sqlda->sqlvar[i].sqltype & ~1;
- switch(coltype)
- {
- case SQL_TEXT:
- break;
- case SQL_VARYING:
- break;
- case SQL_SHORT:
- break;
- case SQL_LONG:
- break;
- case SQL_FLOAT:
- break;
- case SQL_DOUBLE:
- break;
- case SQL_DATE:
- break;
- case SQL_BLOB:
- break;
- case SQL_ARRAY:
- break;
- }
- }
- */
-}
-/* }}} */
-
-/* {{{ proto int ibase_execute(int query)
- Execute a previously prepared (and possibly binded) query. */
-PHP_FUNCTION(ibase_execute)
-{
- pval *query;
- ibase_query_handle *ibase_query;
- ibase_result_handle *ibase_result;
- int type;
- ISC_STATUS status[20];
- XSQLDA *osqlda;
- IBASE_TLS_VARS;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &query)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(query);
- if (query->value.lval==0) {
- RETURN_FALSE;
- }
-
- ibase_query = (ibase_query_handle *) php3_list_find(query->value.lval,&type);
-
- if (type!=IBASE_GLOBAL(php3_ibase_module).le_query) {
- php_error(E_WARNING,"%d is not an InterBase query index", query->value.lval);
- RETURN_FALSE;
- }
-
- osqlda = _php3_ibase_execute(ibase_query->trans, ibase_query->query, ibase_query->sqlda, status);
- ibase_result = (ibase_result_handle *) emalloc(sizeof(ibase_result_handle));
- ibase_result->result = ibase_query->query;
- ibase_result->sqlda = osqlda;
- return_value->value.lval = php3_list_insert(ibase_result, IBASE_GLOBAL(php3_ibase_module).le_result);
- return_value->type = IS_LONG;
-}
-/* }}} */
-
-/* {{{ proto int ibase_free_query(int query)
- Free memory used by a query */
-PHP_FUNCTION(ibase_free_query)
-{
- pval *query;
- ibase_query_handle *ibase_query;
- int type;
- IBASE_TLS_VARS;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &query)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(query);
- if (query->value.lval==0) {
- RETURN_FALSE;
- }
-
- ibase_query = (ibase_query_handle *) php3_list_find(query->value.lval, &type);
-
- if (type!=IBASE_GLOBAL(php3_ibase_module).le_query) {
- php_error(E_WARNING,"%d is not an InterBase query index", query->value.lval);
- RETURN_FALSE;
- }
- php3_list_delete(query->value.lval);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int ibase_timefmt(string format)
- Sets the format of datetime columns returned from queries. Still nonfunctional. */
-PHP_FUNCTION(ibase_timefmt)
-{
- pval *pmode;
- IBASE_TLS_VARS;
-
-#if HAVE_STRFTIME
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pmode)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(pmode);
-
- RETURN_TRUE;
-#else
- php_error(E_WARNING,"InterBase: ibase_timefmt not supported on this platform");
- RETURN_FALSE;
-#endif
-}
-/* }}} */
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/interbase/php3_interbase.h b/ext/interbase/php3_interbase.h
deleted file mode 100644
index 30980e51da..0000000000
--- a/ext/interbase/php3_interbase.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Jouni Ahto <jah@cultnet.fi> |
- | |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _PHP3_IBASE_H
-#define _PHP3_IBASE_H
-
-#if COMPILE_DL
-#undef HAVE_IBASE
-#define HAVE_IBASE 1
-#endif
-
-#if HAVE_IBASE
-#include <ibase.h>
-
-extern php3_module_entry ibase_module_entry;
-#define php3_ibase_module_ptr &ibase_module_entry
-
-extern PHP_MINIT_FUNCTION(ibase);
-extern PHP_RINIT_FUNCTION(ibase);
-extern PHP_MSHUTDOWN_FUNCTION(ibase);
-PHP_MINFO_FUNCTION(ibase);
-
-PHP_FUNCTION(ibase_connect);
-PHP_FUNCTION(ibase_pconnect);
-PHP_FUNCTION(ibase_close);
-PHP_FUNCTION(ibase_query);
-PHP_FUNCTION(ibase_fetch_row);
-PHP_FUNCTION(ibase_free_result);
-PHP_FUNCTION(ibase_prepare);
-PHP_FUNCTION(ibase_bind);
-PHP_FUNCTION(ibase_execute);
-PHP_FUNCTION(ibase_free_query);
-PHP_FUNCTION(ibase_timefmt);
-
-typedef struct {
- long default_link;
- long num_links, num_persistent;
- long max_links, max_persistent;
- long allow_persistent;
- int le_link, le_plink, le_result, le_query;
- char *default_user, *default_password;
- long manualtransactions;
- char *timeformat;
-} ibase_module;
-
-typedef struct _php3_ibase_result {
- isc_stmt_handle result;
- isc_tr_handle trans;
- XSQLDA *sqlda;
- int commitok;
-} ibase_result_handle;
-
-typedef struct _php3_ibase_query {
- isc_stmt_handle query;
- isc_tr_handle trans;
- XSQLDA *sqlda;
- int alloced;
-} ibase_query_handle;
-
-typedef struct _php3_ibase_varchar {
- short var_len;
- char var_str[1];
-} IBASE_VCHAR;
-
-extern ibase_module php3_ibase_module;
-
-#else
-
-#define php3_ibase_module_ptr NULL
-
-#endif /* HAVE_IBASE */
-
-#define phpext_interbase_ptr php3_ibase_module_ptr
-
-#endif /* _PHP3_IBASE_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/interbase/setup.stub b/ext/interbase/setup.stub
deleted file mode 100644
index 3c6a41fe0f..0000000000
--- a/ext/interbase/setup.stub
+++ /dev/null
@@ -1,7 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-interbase 'InterBase support?' yesnodir \
- 'no /usr/interbase InterBase base install' \
-' Whether to build PHP with InterBase support. More\n
- information about InterBase can be found at http://www.interbase.com/.'
diff --git a/ext/ldap/Makefile.am b/ext/ldap/Makefile.am
deleted file mode 100644
index ca39511757..0000000000
--- a/ext/ldap/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_ldap.a
-libphpext_ldap_a_SOURCES=ldap.c
-
diff --git a/ext/ldap/config.h.stub b/ext/ldap/config.h.stub
deleted file mode 100644
index f0da3f0d5c..0000000000
--- a/ext/ldap/config.h.stub
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Define if you want the LDAP directory interface */
-#define HAVE_LDAP 0
diff --git a/ext/ldap/config.m4 b/ext/ldap/config.m4
deleted file mode 100644
index a3c1dcef4e..0000000000
--- a/ext/ldap/config.m4
+++ /dev/null
@@ -1,81 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(for LDAP support)
-AC_ARG_WITH(ldap,
-[ --with-ldap[=DIR] Include LDAP support. DIR is the LDAP base
- install directory, defaults to /usr/local/ldap],
-[
- if test "$withval" != "no"; then
- if test "$withval" = "yes"; then
- if test -f /usr/include/ldap.h; then
- LDAP_INCDIR=/usr/include
- LDAP_LIBDIR=/usr/lib
- elif test -f /usr/local/include/ldap.h; then
- LDAP_INCDIR=/usr/local/include
- LDAP_LIBDIR=/usr/local/lib
- elif test -f /usr/local/ldap/include/ldap.h; then
- LDAP_INCDIR=/usr/local/ldap/include
- LDAP_LIBDIR=/usr/local/ldap/lib
- elif test -f /usr/include/umich-ldap/ldap.h; then
- LDAP_INCDIR=/usr/include/umich-ldap
- LDAP_LIBDIR=/usr/lib
- else
- AC_MSG_RESULT(no)
- AC_MSG_ERROR(Unable to find ldap.h)
- fi
- else
- if test -f $withval/include/ldap.h; then
- LDAP_INCDIR=$withval/include
- LDAP_LIBDIR=$withval/lib
- else
- AC_MSG_RESULT(no)
- AC_MSG_ERROR(Unable to find $withval/include/ldap.h)
- fi
- fi
-
-dnl The Linux version of the SDK need -lpthread
-dnl I have tested Solaris, and it doesn't, but others may. Add
-dnl these here if necessary. -RL
-
- if test `uname` = "Linux"; then
- LDAP_PTHREAD="pthread"
- else
- LDAP_PTHREAD=
- fi
-
- if test -f $LDAP_LIBDIR/liblber.a; then
- LDAP_LIBS="-lldap -llber"
- AC_ADD_LIBRARY(ldap)
- AC_ADD_LIBRARY(lber)
- elif test -f $LDAP_LIBDIR/libldapssl30.so; then
- AC_ADD_LIBRARY(ldapssl30)
- AC_ADD_LIBRARY($LDAP_PTHREAD)
- AC_DEFINE(HAVE_NSLDAP)
- elif test -f $LDAP_LIBDIR/libldapssl30.sl; then
- AC_ADD_LIBRARY(ldapssl30)
- AC_DEFINE(HAVE_NSLDAP)
- elif test -f $LDAP_LIBDIR/libldap30.so; then
- AC_ADD_LIBRARY(ldap30)
- AC_ADD_LIBRARY($LDAP_PTHREAD)
- AC_DEFINE(HAVE_NSLDAP)
- elif test -f $LDAP_LIBDIR/libldap30.sl; then
- AC_ADD_LIBRARY(ldap30)
- AC_DEFINE(HAVE_NSLDAP)
- elif test -f $LDAP_LIBDIR/libumich_ldap.so; then
- AC_ADD_LIBRARY(umich_ldap)
- AC_ADD_LIBRARY(umich_lber)
- fi
-
- AC_ADD_INCLUDE($LDAP_INCDIR)
- AC_ADD_LIBPATH($LDAP_LIBDIR)
-
- AC_DEFINE(HAVE_LDAP)
-
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(ldap)
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
deleted file mode 100644
index 86d7dfa8f2..0000000000
--- a/ext/ldap/ldap.c
+++ /dev/null
@@ -1,1300 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Amitay Isaacs <amitay@w-o-i.com> |
- | Eric Warnke <ericw@albany.edu> |
- | Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Gerrit Thomson <334647@swin.edu.au> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-#define IS_EXT_MODULE
-
-#include "php.h"
-
-#if HAVE_LDAP
-
-#include "dl/phpdl.h"
-#include "ext/standard/dl.h"
-#include "php3_ldap.h"
-
-#if WIN32|WINNT
-#include <string.h>
-#if HAVE_NSLDAP
-#include <winsock.h>
-#endif
-#define strdup _strdup
-#undef WINDOWS
-#undef strcasecmp
-#undef strncasecmp
-#define WINSOCK 1
-#define __STDC__ 1
-#endif
-
-#include "ext/standard/php3_string.h"
-
-
-#if THREAD_SAFE & HAVE_NSLDAP
-#include "php3_threads.h"
-/* Structure for LDAP error values */
-#define LDAP_TLS_VARS ldap_module *PHP3_TLS_GET(ldapTLS,php3_ldap_module)
-#define LDAP_GLOBAL(a) php3_ldap_module->a
-#else
-#define LDAP_TLS_VARS
-#define LDAP_GLOBAL(a) php3_ldap_module.a
-ldap_module php3_ldap_module;
-#endif
-
-
-
-/*
- This is just a small subset of the functionality provided by the LDAP library. All the
- operations are synchronous. Referrals are not handled automatically.
-*/
-
-function_entry ldap_functions[] = {
- PHP_FE(ldap_connect, NULL)
- PHP_FALIAS(ldap_close, ldap_unbind, NULL)
- PHP_FE(ldap_bind, NULL)
- PHP_FE(ldap_unbind, NULL)
- PHP_FE(ldap_read, NULL)
- PHP_FE(ldap_list, NULL)
- PHP_FE(ldap_search, NULL)
- PHP_FE(ldap_free_result, NULL)
- PHP_FE(ldap_count_entries, NULL)
- PHP_FE(ldap_first_entry, NULL)
- PHP_FE(ldap_next_entry, NULL)
- PHP_FE(ldap_get_entries, NULL)
- PHP_FE(ldap_first_attribute, NULL)
- PHP_FE(ldap_next_attribute, NULL)
- PHP_FE(ldap_get_attributes, NULL)
- PHP_FE(ldap_get_values, NULL)
- PHP_FE(ldap_get_dn, NULL)
- PHP_FE(ldap_explode_dn, NULL)
- PHP_FE(ldap_dn2ufn, NULL)
- PHP_FE(ldap_add, NULL)
- PHP_FE(ldap_delete, NULL)
- PHP_FE(ldap_modify, NULL)
-/* additional functions for attribute based modifications, Gerrit Thomson */
- PHP_FE(ldap_mod_add, NULL)
- PHP_FE(ldap_mod_replace, NULL)
- PHP_FE(ldap_mod_del, NULL)
-/* end gjt mod */
- {NULL, NULL, NULL}
-};
-
-
-php3_module_entry ldap_module_entry = {
- "LDAP", ldap_functions, PHP_MINIT(ldap), PHP_MSHUTDOWN(ldap), NULL, NULL,
- PHP_MINFO(ldap), STANDARD_MODULE_PROPERTIES
-};
-
-
-
-#if COMPILE_DL
-DLEXPORT php3_module_entry *get_module(void ) { return &ldap_module_entry; }
-#endif
-
-
-#if 0 /* see my note in php3_ldap.h. smc */
-/* Function for setting thread-specific LDAP error values */
-static void php3_ldap_set_ld_error( int err, char *matched, char *errmsg, void *dummy )
-{
- LDAP_TLS_VARS;
-
- /* Set the error code returned by the LDAP operation */
- LDAP_GLOBAL(le_errno) = err;
- /* Specify the components of the DN that matched (if
- an "NO_SUCH_OBJECT" error occurred */
- if ( LDAP_GLOBAL(le_matched) != NULL ) {
- ldap_memfree( LDAP_GLOBAL(le_matched) );
- }
- LDAP_GLOBAL(le_matched) = matched;
- /* Specify the error message corresponding to the error code */
- if ( LDAP_GLOBAL(le_errmsg) != NULL ) {
- ldap_memfree( LDAP_GLOBAL(le_errmsg) );
- }
- LDAP_GLOBAL(le_errmsg) = errmsg;
-}
-
-/* Function for getting the thread-specific LDAP error values */
-static int php3_ldap_get_ld_error( char **matched, char **errmsg, void *dummy )
-{
- LDAP_TLS_VARS;
- /* Retrieve the error values */
- if ( matched != NULL ) {
- *matched = LDAP_GLOBAL(le_matched);
- }
- if ( errmsg != NULL ) {
- *errmsg = LDAP_GLOBAL(le_errmsg);
- }
- return( LDAP_GLOBAL(le_errno) );
-}
-
-/* Function for setting the value of the errno variable */
-static void php3_ldap_set_errno( int err )
-{
- errno = err;
-}
-
-/* Function for getting the value of the errno variable */
-static int php3_ldap_get_errno( void )
-{
- return( errno );
-}
-#endif /* THREAD_SAFE && NSLDAP */
-
-static void _close_ldap_link(LDAP *ld)
-{
- LDAP_TLS_VARS;
- ldap_unbind_s(ld);
- /* php_printf("Freeing ldap connection");*/
- LDAP_GLOBAL(num_links)--;
-}
-
-
-static void _free_ldap_result(LDAPMessage *result)
-{
- ldap_msgfree(result);
-}
-
-PHP_MINIT_FUNCTION(ldap)
-{
-#if defined(THREAD_SAFE)
- ldap_module *php3_ldap_module;
- PHP3_MUTEX_ALLOC(ldap_mutex);
- PHP3_MUTEX_LOCK(ldap_mutex);
- numthreads++;
- if (numthreads==1){
- if (!PHP3_TLS_PROC_STARTUP(ldapTLS)){
- PHP3_MUTEX_UNLOCK(ldap_mutex);
- PHP3_MUTEX_FREE(ldap_mutex);
- return 0;
- }
- }
- PHP3_MUTEX_UNLOCK(ldap_mutex);
- if(!PHP3_TLS_THREAD_INIT(ldapTLS,php3_ldap_module,ldap_module))
- return 0;
-#if 0 /*HAVE_NSLDAP*/
- /* Set up the ldap_thread_fns structure with pointers
- to the functions that you want called */
- memset( &LDAP_GLOBAL(tfns), '\0', sizeof(struct ldap_thread_fns) );
- /* Specify the functions that you want called */
- /* Call the my_mutex_alloc() function whenever mutexes
- need to be allocated */
- LDAP_GLOBAL(tfns).ltf_mutex_alloc = (void *(*)(void)) php3_mutex_alloc;
- /* Call the my_mutex_free() function whenever mutexes
- need to be destroyed */
- LDAP_GLOBAL(tfns).ltf_mutex_free = (void (*)(void *)) php3_mutex_free;
- /* Call the pthread_mutex_lock() function whenever a
- thread needs to lock a mutex. */
- LDAP_GLOBAL(tfns).ltf_mutex_lock = (int (*)(void *)) php3_mutex_lock;
- /* Call the pthread_mutex_unlock() function whenever a
- thread needs to unlock a mutex. */
- LDAP_GLOBAL(tfns).ltf_mutex_unlock = (int (*)(void *)) php3_mutex_unlock;
- /* Call the get_errno() function to get the value of errno */
- LDAP_GLOBAL(tfns).ltf_get_errno = php3_ldap_get_errno;
- /* Call the set_errno() function to set the value of errno */
- LDAP_GLOBAL(tfns).ltf_set_errno = php3_ldap_set_errno;
- /* Call the get_ld_error() function to get error values from
- calls to functions in the libldap library */
- LDAP_GLOBAL(tfns).ltf_get_lderrno = php3_ldap_get_ld_error;
- /* Call the set_ld_error() function to set error values for
- calls to functions in the libldap library */
- LDAP_GLOBAL(tfns).ltf_set_lderrno = php3_ldap_set_ld_error;
- /* Don't pass any extra parameter to the functions for
- getting and setting libldap function call errors */
- LDAP_GLOBAL(tfns).ltf_lderrno_arg = NULL;
-/* Set the session option that specifies the functions to call for multi-threaded clients */
- if (ldap_set_option( ld, LDAP_OPT_THREAD_FN_PTRS, (void *) &LDAP_GLOBAL(tfns))!= 0) {
- ldap_perror( ld, "ldap_set_option: thread pointers" );
- }
-#endif
-#endif
- if (cfg_get_long("ldap.max_links", &LDAP_GLOBAL(max_links)) == FAILURE) {
- LDAP_GLOBAL(max_links) = -1;
- }
-
- if (cfg_get_string("ldap.base_dn", &LDAP_GLOBAL(base_dn)) == FAILURE) {
- LDAP_GLOBAL(base_dn) = NULL;
- }
-
- LDAP_GLOBAL(le_result) = register_list_destructors(_free_ldap_result, NULL);
- LDAP_GLOBAL(le_link) = register_list_destructors(_close_ldap_link, NULL);
-
- /*FIXME is this safe in threaded environment? if so, please comment*/
- ldap_module_entry.type = type;
-
- return SUCCESS;
-}
-
-PHP_MSHUTDOWN_FUNCTION(ldap)
-{
-#ifdef THREAD_SAFE
- LDAP_TLS_VARS;
- PHP3_TLS_THREAD_FREE(php3_ldap_module);
- PHP3_MUTEX_LOCK(ldap_mutex);
- numthreads--;
- if (!numthreads) {
- PHP3_TLS_PROC_SHUTDOWN(ldapTLS);
- }
- PHP3_MUTEX_UNLOCK(ldap_mutex);
- PHP3_MUTEX_FREE(ldap_mutex);
-#endif
- return SUCCESS;
-}
-
-PHP_MINFO_FUNCTION(ldap)
-{
- char maxl[16];
-#if HAVE_NSLDAP
- LDAPVersion ver;
- double SDKVersion;
- /* Print version information */
- SDKVersion = ldap_version( &ver );
-#endif
- LDAP_TLS_VARS;
-
- if (LDAP_GLOBAL(max_links) == -1) {
- strcpy(maxl, "Unlimited");
- } else {
- snprintf(maxl, 15, "%ld", LDAP_GLOBAL(max_links));
- maxl[15] = 0;
- }
-
- php_printf("<table>"
- "<tr><td>Total links:</td><td>%d/%s</td></tr>\n"
- "<tr><td>RCS Version:</td><td>$Id$</td></tr>\n"
-#if HAVE_NSLDAP
- "<tr><td>SDK Version:</td><td>%f</td></tr>"
- "<tr><td>Highest LDAP Protocol Supported:</td><td>%f</td></tr>"
- "<tr><td>SSL Level Supported:</td><td>%f</td></tr>"
-#endif
- ,LDAP_GLOBAL(num_links),maxl
-#if HAVE_NSLDAP
- ,SDKVersion/100.0,ver.protocol_version/100.0,ver.SSL_version/100.0
-#endif
- );
-#if HAVE_NSLDAP
- if ( ver.security_level != LDAP_SECURITY_NONE ) {
- php_printf( "<tr><td>Level of encryption:</td><td>%d bits</td></tr>\n", ver.security_level );
- } else {
- php_printf( "<tr><td>SSL not enabled.</td><td></td></tr>\n" );
- }
-#endif
- php_printf("</table>\n");
-
-}
-
-/* {{{ proto int ldap_connect([string host [, int port]])
- Connect to an LDAP server */
-PHP_FUNCTION(ldap_connect)
-{
- char *host;
- int port;
- /* char *hashed_details;
- int hashed_details_length;*/
- LDAP *ldap;
- LDAP_TLS_VARS;
-
- switch(ARG_COUNT(ht)) {
- case 0:
- host = NULL;
- port = 0;
- /* hashed_details = estrndup("ldap_", 5);
- hashed_details_length = 4+1; */
- break;
-
- case 1: {
- pval *yyhost;
-
- if (getParameters(ht, 1, &yyhost) == FAILURE) {
- RETURN_FALSE;
- }
-
- convert_to_string(yyhost);
- host = yyhost->value.str.val;
- port = 389; /* Default port */
-
- /* hashed_details_length = yyhost->value.str.len+4+1;
- hashed_details = emalloc(hashed_details_length+1);
- sprintf(hashed_details, "ldap_%s", yyhost->value.str.val);*/
- }
- break;
-
- case 2: {
- pval *yyhost, *yyport;
-
- if (getParameters(ht, 2, &yyhost, &yyport) == FAILURE) {
- RETURN_FALSE;
- }
-
- convert_to_string(yyhost);
- host = yyhost->value.str.val;
- convert_to_long(yyport);
- port = yyport->value.lval;
-
- /* Do we need to take care of hosts running multiple LDAP servers ? */
- /* hashed_details_length = yyhost->value.str.len+4+1;
- hashed_details = emalloc(hashed_details_length+1);
- sprintf(hashed_details, "ldap_%s", yyhost->value.str.val);*/
- }
- break;
-
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- if (LDAP_GLOBAL(max_links)!=-1 && LDAP_GLOBAL(num_links)>=LDAP_GLOBAL(max_links)) {
- php_error(E_WARNING, "LDAP: Too many open links (%d)", LDAP_GLOBAL(num_links));
- RETURN_FALSE;
- }
-
- ldap = ldap_open(host,port);
- if ( ldap == NULL ) {
- RETURN_FALSE;
- } else {
- RETURN_LONG(php3_list_insert((void*)ldap,LDAP_GLOBAL(le_link)));
- }
-
-}
-/* }}} */
-
-
-static LDAP * _get_ldap_link(pval *link, HashTable *list)
-{
- LDAP *ldap;
- int type;
- LDAP_TLS_VARS;
-
- convert_to_long(link);
- ldap = (LDAP *) php3_list_find(link->value.lval, &type);
-
- if (!ldap || !(type == LDAP_GLOBAL(le_link))) {
- php_error(E_WARNING, "%d is not a LDAP link index", link->value.lval);
- return NULL;
- }
- return ldap;
-}
-
-
-static LDAPMessage * _get_ldap_result(pval *result, HashTable *list)
-{
- LDAPMessage *ldap_result;
- int type;
- LDAP_TLS_VARS;
-
- convert_to_long(result);
- ldap_result = (LDAPMessage *) php3_list_find(result->value.lval, &type);
-
- if (!ldap_result || type != LDAP_GLOBAL(le_result)) {
- php_error(E_WARNING, "%d is not a LDAP result index", result->value.lval);
- return NULL;
- }
-
- return ldap_result;
-}
-
-
-static LDAPMessage * _get_ldap_result_entry(pval *result, HashTable *list)
-{
- LDAPMessage *ldap_result_entry;
- int type;
- LDAP_TLS_VARS;
-
- convert_to_long(result);
- ldap_result_entry = (LDAPMessage *) php3_list_find(result->value.lval, &type);
-
- if (!ldap_result_entry || type != LDAP_GLOBAL(le_result_entry)) {
- php_error(E_WARNING, "%d is not a LDAP result entry index", result->value.lval);
- return NULL;
- }
-
- return ldap_result_entry;
-}
-
-
-static BerElement * _get_ber_entry(pval *berp, HashTable *list)
-{
- BerElement *ber;
- int type;
- LDAP_TLS_VARS;
-
- convert_to_long(berp);
- ber = (BerElement *) php3_list_find(berp->value.lval, &type);
-
- if ( type != LDAP_GLOBAL(le_ber_entry)) {
- php_error(E_WARNING, "%d is not a BerElement index", berp->value.lval);
- return NULL;
- }
-
- return ber;
-}
-
-#if 0
-PHP_FUNCTION(ber_free)
-{
- pval *berp;
-
- if ( getParameters(ht,1,&berp) == FAILURE ) RETURN_FALSE;
-
- php3_list_delete(berp->value.lval);
- RETURN_TRUE;
-}
-#endif
-
-/* {{{ proto int ldap_bind(int link [, string dn, string password])
- Bind to LDAP directory */
-PHP_FUNCTION(ldap_bind)
-{
- pval *link, *bind_rdn, *bind_pw;
- char *ldap_bind_rdn, *ldap_bind_pw;
- LDAP *ldap;
-
- switch(ARG_COUNT(ht)) {
- case 1: /* Anonymous Bind */
- if (getParameters(ht, 1, &link) == FAILURE) {
- RETURN_FALSE;
- }
-
- ldap_bind_rdn = NULL;
- ldap_bind_pw = NULL;
-
- break;
-
- case 3 :
- if (getParameters(ht, 3, &link, &bind_rdn, &bind_pw) == FAILURE) {
- RETURN_FALSE;
- }
-
- convert_to_string(bind_rdn);
- convert_to_string(bind_pw);
-
- ldap_bind_rdn = bind_rdn->value.str.val;
- ldap_bind_pw = bind_pw->value.str.val;
-
- break;
-
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- ldap = _get_ldap_link(link, list);
- if (ldap == NULL) RETURN_FALSE;
-
- if (ldap_bind_s(ldap, ldap_bind_rdn, ldap_bind_pw, LDAP_AUTH_SIMPLE) != LDAP_SUCCESS) {
-#if !HAVE_NSLDAP
-#if LDAP_API_VERSION > 2000
- /* New versions of OpenLDAP do it this way */
- php_error(E_WARNING,"LDAP: Unable to bind to server: %s",ldap_err2string(ldap_get_lderrno(ldap,NULL,NULL)));
-#else
- php_error(E_WARNING,"LDAP: Unable to bind to server: %s",ldap_err2string(ldap->ld_errno));
-#endif
-#endif
- RETURN_FALSE;
- } else {
- RETURN_TRUE;
- }
-}
-/* }}} */
-
-/* {{{ proto int ldap_unbind(int link)
- Unbind from LDAP directory */
-PHP_FUNCTION(ldap_unbind)
-{
- pval *link;
- LDAP *ldap;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &link) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(link);
-
- ldap = _get_ldap_link(link, list);
- if (ldap == NULL) RETURN_FALSE;
-
- php3_list_delete(link->value.lval);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-static void php3_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
-{
- pval *link, *base_dn, *filter, *attrs, **attr;
- char *ldap_base_dn, *ldap_filter;
- LDAP *ldap;
- char **ldap_attrs = NULL;
- int attrsonly;
- LDAPMessage *ldap_result;
- int num_attribs=0, i;
- LDAP_TLS_VARS;
-
- switch(ARG_COUNT(ht)) {
- case 3 :
- if (getParameters(ht, 3, &link, &base_dn, &filter) == FAILURE) {
- RETURN_FALSE;
- }
-
- convert_to_string(base_dn);
- convert_to_string(filter);
-
- ldap_base_dn = base_dn->value.str.val;
- ldap_filter = filter->value.str.val;
-
- break;
-
- case 4 :
- if (getParameters(ht, 4, &link, &base_dn, &filter, &attrs) == FAILURE) {
- RETURN_FALSE;
- }
-
- if (attrs->type != IS_ARRAY) {
- php_error(E_WARNING, "LDAP: Expected Array as last element");
- RETURN_FALSE;
- }
-
- convert_to_string(base_dn);
- convert_to_string(filter);
-
- ldap_base_dn = base_dn->value.str.val;
- ldap_filter = filter->value.str.val;
-
- num_attribs = zend_hash_num_elements(attrs->value.ht);
- if ((ldap_attrs = emalloc((num_attribs+1) * sizeof(char *))) == NULL) {
- php_error(E_WARNING, "LDAP: Could not allocate memory");
- RETURN_FALSE;
- return;
- }
-
- for(i=0; i<num_attribs; i++) {
- if (zend_hash_index_find(attrs->value.ht, i, (void **) &attr) == FAILURE) {
- php_error(E_WARNING, "LDAP: Array initialization wrong");
- RETURN_FALSE;
- return;
- }
- SEPARATE_ZVAL(attr);
- convert_to_string(*attr);
- ldap_attrs[i] = (*attr)->value.str.val;
- }
- ldap_attrs[num_attribs] = NULL;
-
- break;
-
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- /* fix to make null base_dn's work */
- if ( strlen(ldap_base_dn) < 1 ) {
- ldap_base_dn = NULL;
- }
-
- ldap = _get_ldap_link(link, list);
- if (ldap == NULL) RETURN_FALSE;
-
- /* Is it useful to only get the attributes ? */
- attrsonly = 0;
-
- /* We can possibly add the timeout value also */
-
- if (ldap_search_s(ldap, ldap_base_dn, scope, ldap_filter, ldap_attrs, attrsonly, &ldap_result) != LDAP_SUCCESS) {
-#if !HAVE_NSLDAP
-#if LDAP_API_VERSION > 2000
- php_error(E_WARNING,"LDAP: Unable to perform the search: %s",ldap_err2string(ldap_get_lderrno(ldap,NULL,NULL)));
-#else
- php_error(E_WARNING, "LDAP: Unable to perform the search: %s", ldap_err2string(ldap->ld_errno));
-#endif
-#endif
- RETVAL_FALSE;
- } else {
- RETVAL_LONG(php3_list_insert(ldap_result, LDAP_GLOBAL(le_result)));
- }
-
- if (ldap_attrs != NULL) {
- /* for(i=0; i<num_attribs; i++) efree(ldap_attrs[i]); */
- efree(ldap_attrs);
- }
- return;
-}
-
-/* {{{ proto int ldap_read(int link, string base_dn, string filter [, array attributes])
- Read an entry */
-PHP_FUNCTION(ldap_read)
-{
- php3_ldap_do_search(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_SCOPE_BASE);
-}
-/* }}} */
-
-/* {{{ proto int ldap_list(int link, string base_dn, string filter [, array attributes])
- Single-level search */
-PHP_FUNCTION(ldap_list)
-{
- php3_ldap_do_search(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_SCOPE_ONELEVEL);
-}
-/* }}} */
-
-
-/* {{{ proto int ldap_search(int link, string base_dn, string filter [, array attributes])
- Search LDAP tree under base_dn */
-PHP_FUNCTION(ldap_search)
-{
- php3_ldap_do_search(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_SCOPE_SUBTREE);
-}
-/* }}} */
-
-/* {{{ proto int ldap_free_result(int result)
- Free result memory */
-PHP_FUNCTION(ldap_free_result)
-{
- pval *result;
- LDAPMessage *ldap_result;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &result) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ldap_result = _get_ldap_result(result, list);
- if (ldap_result == NULL) {
- RETVAL_FALSE;
- } else {
- php3_list_delete(result->value.lval); /* Delete list entry and call registered destructor function */
- RETVAL_TRUE;
- }
- return;
-}
-/* }}} */
-
-/* {{{ proto int ldap_count_entries(int link, int result)
- Count the number of entries in a search result */
-PHP_FUNCTION(ldap_count_entries)
-{
- pval *result, *link;
- LDAP *ldap;
- LDAPMessage *ldap_result;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &result) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ldap = _get_ldap_link(link, list);
- if (ldap == NULL) RETURN_FALSE;
-
- ldap_result = _get_ldap_result(result, list);
- if (ldap_result == NULL) RETURN_FALSE;
-
- RETURN_LONG(ldap_count_entries(ldap, ldap_result));
-}
-/* }}} */
-
-/* {{{ proto int ldap_first_entry(int link, int result)
- Return first result id */
-PHP_FUNCTION(ldap_first_entry)
-{
- pval *result, *link;
- LDAP *ldap;
- LDAPMessage *ldap_result;
- LDAPMessage *ldap_result_entry;
- LDAP_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &result) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ldap = _get_ldap_link(link, list);
- if (ldap == NULL) RETURN_FALSE;
-
- ldap_result = _get_ldap_result(result, list);
- if (ldap_result == NULL) RETURN_FALSE;
-
- if ((ldap_result_entry = ldap_first_entry(ldap, ldap_result)) == NULL) {
- RETURN_FALSE;
- } else {
- RETURN_LONG(php3_list_insert(ldap_result_entry, LDAP_GLOBAL(le_result_entry)));
- }
-}
-/* }}} */
-
-/* {{{ proto int ldap_next_entry(int link, int entry)
- Get next result entry */
-PHP_FUNCTION(ldap_next_entry)
-{
- pval *result_entry, *link;
- LDAP *ldap;
- LDAPMessage *ldap_result_entry, *ldap_result_entry_next;
- LDAP_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &result_entry) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ldap = _get_ldap_link(link, list);
- if (ldap == NULL) RETURN_FALSE;
-
- ldap_result_entry = _get_ldap_result_entry(result_entry, list);
- if (ldap_result_entry == NULL) RETURN_FALSE;
-
- if ((ldap_result_entry_next = ldap_next_entry(ldap, ldap_result_entry)) == NULL) {
- RETURN_FALSE;
- } else {
- RETURN_LONG(php3_list_insert(ldap_result_entry_next, LDAP_GLOBAL(le_result_entry)));
- }
-}
-/* }}} */
-
-/* {{{ proto array ldap_get_entries(int link, int result)
- Get all result entries */
-PHP_FUNCTION(ldap_get_entries)
-{
- pval *link, *result;
- LDAPMessage *ldap_result, *ldap_result_entry;
- pval *tmp1, *tmp2;
- LDAP *ldap;
- int num_entries, num_attrib, num_values, i;
- int attr_count, entry_count;
- BerElement *ber;
- char *attribute;
- char **ldap_value;
- char *dn;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &result) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ldap = _get_ldap_link(link, list);
- if (ldap == NULL) RETURN_FALSE;
-
- ldap_result = _get_ldap_result(result, list);
- if (ldap_result == NULL) RETURN_FALSE;
-
- num_entries = ldap_count_entries(ldap, ldap_result);
-
- array_init(return_value);
- add_assoc_long(return_value, "count", num_entries);
-
- if (num_entries == 0) return;
-
- ldap_result_entry = ldap_first_entry(ldap, ldap_result);
- if (ldap_result_entry == NULL) RETURN_FALSE;
-
- entry_count = 0;
-
- while(ldap_result_entry != NULL) {
-
- num_attrib = 0;
- attribute = ldap_first_attribute(ldap, ldap_result_entry, &ber);
- if (attribute == NULL) RETURN_FALSE;
- while (attribute != NULL) {
- num_attrib++;
- attribute = ldap_next_attribute(ldap, ldap_result_entry, ber);
- }
-
- MAKE_STD_ZVAL(tmp1);
- array_init(tmp1);
-
- attr_count = 0;
- attribute = ldap_first_attribute(ldap, ldap_result_entry, &ber);
- while (attribute != NULL) {
- ldap_value = ldap_get_values(ldap, ldap_result_entry, attribute);
- num_values = ldap_count_values(ldap_value);
-
- MAKE_STD_ZVAL(tmp2);
- array_init(tmp2);
- add_assoc_long(tmp2, "count", num_values);
- for(i=0; i<num_values; i++) {
- add_index_string(tmp2, i, ldap_value[i], 1);
- }
- ldap_value_free(ldap_value);
-
- zend_hash_update(tmp1->value.ht, _php3_strtolower(attribute), strlen(attribute)+1, (void *) &tmp2, sizeof(pval *), NULL);
- add_index_string(tmp1, attr_count, attribute, 1);
-
- attr_count++;
- attribute = ldap_next_attribute(ldap, ldap_result_entry, ber);
- }
-
- add_assoc_long(tmp1, "count", num_attrib);
- dn = ldap_get_dn(ldap, ldap_result_entry);
- add_assoc_string(tmp1, "dn", dn, 1);
-
- zend_hash_index_update(return_value->value.ht, entry_count, (void *) &tmp1, sizeof(pval *), NULL);
-
- entry_count++;
- ldap_result_entry = ldap_next_entry(ldap, ldap_result_entry);
- }
-
- add_assoc_long(return_value, "count", num_entries);
-}
-/* }}} */
-
-/* {{{ proto string ldap_first_attribute(int link, int result, int ber)
- Return first attribute */
-PHP_FUNCTION(ldap_first_attribute)
-{
- pval *result,*link,*berp;
- LDAP *ldap;
- LDAPMessage *ldap_result_entry;
- BerElement *ber;
- char *attribute;
- LDAP_TLS_VARS;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &link, &result,&berp) == FAILURE || ParameterPassedByReference(ht,3)==0 ) {
- WRONG_PARAM_COUNT;
- }
-
- ldap = _get_ldap_link(link,list);
- if (ldap == NULL) RETURN_FALSE;
-
- ldap_result_entry = _get_ldap_result_entry(result,list);
- if (ldap_result_entry == NULL) RETURN_FALSE;
-
- if ((attribute = ldap_first_attribute(ldap, ldap_result_entry, &ber)) == NULL) {
- RETURN_FALSE;
- } else {
- /* brep is passed by ref so we do not have to account for memory */
- berp->type=IS_LONG;
- berp->value.lval=php3_list_insert(ber, LDAP_GLOBAL(le_ber_entry));
-
- RETVAL_STRING(attribute,1);
-#ifdef WINDOWS
- ldap_memfree(attribute);
-#endif
- }
-}
-/* }}} */
-
-/* {{{ proto string ldap_next_attribute(int link, int result, int ber)
- Get the next attribute in result */
-PHP_FUNCTION(ldap_next_attribute)
-{
- pval *result,*link,*berp;
- LDAP *ldap;
- LDAPMessage *ldap_result_entry;
- BerElement *ber;
- char *attribute;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &link, &result,&berp) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
-
- ldap = _get_ldap_link(link,list);
- if (ldap == NULL) RETURN_FALSE;
-
- ldap_result_entry = _get_ldap_result_entry(result,list);
- if (ldap_result_entry == NULL) RETURN_FALSE;
-
- ber = _get_ber_entry(berp,list);
-
- if ((attribute = ldap_next_attribute(ldap, ldap_result_entry, ber)) == NULL) {
- RETURN_FALSE;
- } else {
- RETVAL_STRING(attribute,1);
-#ifdef WINDOWS
- ldap_memfree(attribute);
-#endif
- }
-}
-/* }}} */
-
-/* {{{ proto array ldap_get_attributes(int link, int result)
- Get attributes from a search result entry */
-PHP_FUNCTION(ldap_get_attributes)
-{
- pval *link, *result_entry;
- pval *tmp;
- LDAP *ldap;
- LDAPMessage *ldap_result_entry;
- char *attribute;
- char **ldap_value;
- int i, count, num_values, num_attrib;
- BerElement *ber;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &result_entry) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ldap = _get_ldap_link(link, list);
- if (ldap == NULL) RETURN_FALSE;
-
- ldap_result_entry = _get_ldap_result_entry(result_entry, list);
- if (ldap_result_entry == NULL) RETURN_FALSE;
-
- num_attrib = 0;
- attribute = ldap_first_attribute(ldap, ldap_result_entry, &ber);
- if (attribute == NULL) RETURN_FALSE;
- while (attribute != NULL) {
- num_attrib++;
- attribute = ldap_next_attribute(ldap, ldap_result_entry, ber);
- }
-
- array_init(return_value);
-
- count=0;
- attribute = ldap_first_attribute(ldap, ldap_result_entry, &ber);
- while (attribute != NULL) {
- ldap_value = ldap_get_values(ldap, ldap_result_entry, attribute);
- num_values = ldap_count_values(ldap_value);
-
- MAKE_STD_ZVAL(tmp);
- array_init(tmp);
- add_assoc_long(tmp, "count", num_values);
- for(i=0; i<num_values; i++) {
- add_index_string(tmp, i, ldap_value[i], 1);
- }
- ldap_value_free(ldap_value);
-
- zend_hash_update(return_value->value.ht, attribute, strlen(attribute)+1, (void *) &tmp, sizeof(pval *), NULL);
- add_index_string(return_value, count, attribute, 1);
-
- count++;
- attribute = ldap_next_attribute(ldap, ldap_result_entry, ber);
- }
-
- add_assoc_long(return_value, "count", num_attrib);
-}
-/* }}} */
-
-/* {{{ proto array ldap_get_values(int link, int result, string attribute)
- Get all values from a result entry */
-PHP_FUNCTION(ldap_get_values)
-{
- pval *link, *result_entry, *attr;
- LDAP *ldap;
- LDAPMessage *ldap_result_entry;
- char *attribute;
- char **ldap_value;
- int i, num_values;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &link, &result_entry, &attr) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ldap = _get_ldap_link(link, list);
- if (ldap == NULL) RETURN_FALSE;
-
- ldap_result_entry = _get_ldap_result_entry(result_entry, list);
- if (ldap_result_entry == NULL) RETURN_FALSE;
-
- convert_to_string(attr);
- attribute = attr->value.str.val;
-
- if ((ldap_value = ldap_get_values(ldap, ldap_result_entry, attribute)) == NULL) {
-#if !HAVE_NSLDAP
-#if LDAP_API_VERSION > 2000
- php_error(E_WARNING, "LDAP: Cannot get the value(s) of attribute %s", ldap_err2string(ldap_get_lderrno(ldap,NULL,NULL)));
-#else
- php_error(E_WARNING, "LDAP: Cannot get the value(s) of attribute %s", ldap_err2string(ldap->ld_errno));
-#endif
-#endif
- RETURN_FALSE;
- }
-
- num_values = ldap_count_values(ldap_value);
-
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
-
- for(i=0; i<num_values; i++) {
- add_next_index_string(return_value, ldap_value[i], 1);
- }
-
- add_assoc_long(return_value, "count", num_values);
-
- ldap_value_free(ldap_value);
-}
-/* }}} */
-
-/* {{{ proto string ldap_get_dn(int link, int result)
- Get the DN of a result entry */
-PHP_FUNCTION(ldap_get_dn)
-{
- pval *link,*entryp;
- LDAP *ld;
- LDAPMessage *entry;
- char *text;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &entryp) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ld = _get_ldap_link(link, list);
- if (ld == NULL) RETURN_FALSE;
-
- entry = _get_ldap_result_entry(entryp, list);
- if (entry == NULL) RETURN_FALSE;
-
- text = ldap_get_dn(ld, entry);
- if ( text != NULL ) {
- RETVAL_STRING(text,1);
-#ifdef WINDOWS
- ldap_memfree(text);
-#endif
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto array ldap_explode_dn(string dn, int with_attrib)
- Splits DN into its component parts */
-PHP_FUNCTION(ldap_explode_dn)
-{
- pval *dn, *with_attrib;
- char **ldap_value;
- int i, count;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &dn, &with_attrib)== FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(dn);
- convert_to_long(with_attrib);
-
- ldap_value = ldap_explode_dn(dn->value.str.val, with_attrib->value.lval);
-
- i=0;
- while(ldap_value[i] != NULL) i++;
- count = i;
-
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
-
- add_assoc_long(return_value, "count", count);
- for(i=0; i<count; i++) {
- add_index_string(return_value, i, ldap_value[i], 1);
- }
-
- ldap_value_free(ldap_value);
-}
-/* }}} */
-
-/* {{{ proto string ldap_dn2ufn(string dn)
- Convert DN to User Friendly Naming format */
-PHP_FUNCTION(ldap_dn2ufn)
-{
- pval *dn;
- char *ufn;
-
- if (ARG_COUNT(ht) !=1 || getParameters(ht,1,&dn)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(dn);
-
- ufn = ldap_dn2ufn(dn->value.str.val);
-
- if (ufn !=NULL) {
- RETVAL_STRING(ufn,1);
-#ifdef WINDOWS
- ldap_memfree(ufn);
-#endif
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* added to fix use of ldap_modify_add for doing an ldap_add, gerrit thomson. */
-#define PHP_LD_FULL_ADD 0xff
-
-
-static void php3_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
-{
- pval *link, *dn, *entry, *value, *ivalue;
- LDAP *ldap;
- char *ldap_dn;
- LDAPMod **ldap_mods;
- int i, j, num_attribs, num_values;
- char *attribute;
- ulong index;
- int is_full_add=0; /* flag for full add operation so ldap_mod_add can be put back into oper, gerrit THomson */
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &link, &dn, &entry) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (entry->type != IS_ARRAY) {
- php_error(E_WARNING, "LDAP: Expected Array as the last element");
- RETURN_FALSE;
- }
-
- ldap = _get_ldap_link(link, list);
- if (ldap == NULL) RETURN_FALSE;
-
- convert_to_string(dn);
- ldap_dn = dn->value.str.val;
-
- num_attribs = zend_hash_num_elements(entry->value.ht);
-
- ldap_mods = emalloc((num_attribs+1) * sizeof(LDAPMod *));
-
- zend_hash_internal_pointer_reset(entry->value.ht);
- /* added by gerrit thomson to fix ldap_add using ldap_mod_add */
- if ( oper == PHP_LD_FULL_ADD )
- {
- oper = LDAP_MOD_ADD;
- is_full_add = 1;
- }
- /* end additional , gerrit thomson */
-
- for(i=0; i<num_attribs; i++) {
- ldap_mods[i] = emalloc(sizeof(LDAPMod));
-
- ldap_mods[i]->mod_op = oper;
-
- if (zend_hash_get_current_key(entry->value.ht, &attribute, &index) == HASH_KEY_IS_STRING) {
- ldap_mods[i]->mod_type = estrdup(attribute);
- efree(attribute);
- } else {
- php_error(E_WARNING, "LDAP: Unknown Attribute in the data");
- }
-
- zend_hash_get_current_data(entry->value.ht, (void **) &value);
-
- if (value->type != IS_ARRAY) {
- num_values = 1;
- } else {
- num_values = zend_hash_num_elements(value->value.ht);
- }
-
- ldap_mods[i]->mod_values = emalloc((num_values+1) * sizeof(char *));
-
-/* allow for arrays with one element, no allowance for arrays with none but probably not required, gerrit thomson. */
-/* if (num_values == 1) {*/
- if ((num_values == 1) && (value->type != IS_ARRAY)) {
- convert_to_string(value);
- ldap_mods[i]->mod_values[0] = value->value.str.val;
- } else {
- for(j=0; j<num_values; j++) {
- zend_hash_index_find(value->value.ht, j, (void **) &ivalue);
- convert_to_string(ivalue);
- ldap_mods[i]->mod_values[j] = ivalue->value.str.val;
- }
- }
- ldap_mods[i]->mod_values[num_values] = NULL;
-
- zend_hash_move_forward(entry->value.ht);
- }
- ldap_mods[num_attribs] = NULL;
-
-/* check flag to see if do_mod was called to perform full add , gerrit thomson */
-/* if (oper == LDAP_MOD_ADD) { */
- if (is_full_add == 1) {
- if (ldap_add_s(ldap, ldap_dn, ldap_mods) != LDAP_SUCCESS) {
- ldap_perror(ldap, "LDAP");
- php_error(E_WARNING, "LDAP: add operation could not be completed.");
- RETVAL_FALSE;
- } else RETVAL_TRUE;
- } else {
- if (ldap_modify_s(ldap, ldap_dn, ldap_mods) != LDAP_SUCCESS) {
- php_error(E_WARNING, "LDAP: modify operation could not be completed.");
- RETVAL_FALSE;
- } else RETVAL_TRUE;
- }
-
- for(i=0; i<num_attribs; i++) {
- efree(ldap_mods[i]->mod_type);
- efree(ldap_mods[i]->mod_values);
- efree(ldap_mods[i]);
- }
- efree(ldap_mods);
-
- return;
-}
-
-/* {{{ proto int ldap_add(int link, string dn, array entry)
- Add entries to LDAP directory */
-PHP_FUNCTION(ldap_add)
-{
- /* use a newly define parameter into the do_modify so ldap_mod_add can be used the way it is supposed to be used , Gerrit THomson */
- /* php3_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_ADD);*/
- php3_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_LD_FULL_ADD);
-}
-/* }}} */
-
-
-/* {{{ proto int ldap_modify(int link, string dn, array entry)
- Modify an LDAP entry */
-PHP_FUNCTION(ldap_modify)
-{
- php3_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_REPLACE);
-}
-/* }}} */
-
-
-/* three functions for attribute base modifications, gerrit Thomson */
-
-
-
-/* {{{ proto int ldap_mod_replace(int link, string dn, array entry)
- Replace attribute values with new ones */
-PHP_FUNCTION(ldap_mod_replace)
-{
- php3_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_REPLACE);}
-/* }}} */
-
-/* {{{ proto int ldap_mod_add(int link, string dn, array entry)
- Add attribute values to current */
-PHP_FUNCTION(ldap_mod_add)
-{
- php3_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_ADD);
-}
-/* }}} */
-
-/* {{{ proto int ldap_mod_del(int link, string dn, array entry)
- Delete attribute values */
-PHP_FUNCTION(ldap_mod_del)
-{
- php3_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_DELETE);
-}
-
-/* end of attribute based functions , gerrit thomson */
-
-
-/* {{{ proto int ldap_delete(int link, string dn)
- Delete an entry from a directory */
-PHP_FUNCTION(ldap_delete)
-{
- pval *link, *dn;
- LDAP *ldap;
- char *ldap_dn;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &dn) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ldap = _get_ldap_link(link, list);
- if (ldap == NULL) RETURN_FALSE;
-
- convert_to_string(dn);
- ldap_dn = dn->value.str.val;
-
- if (ldap_delete_s(ldap, ldap_dn) != LDAP_SUCCESS) {
- ldap_perror(ldap, "LDAP");
- RETURN_FALSE;
- }
-
- RETURN_TRUE;
-}
-/* }}} */
-
-#endif
diff --git a/ext/ldap/php3_ldap.h b/ext/ldap/php3_ldap.h
deleted file mode 100644
index 3e8b08f62e..0000000000
--- a/ext/ldap/php3_ldap.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Amitay Isaacs <amitay@w-o-i.com> |
- | Eric Warnke <ericw@albany.edu> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _PHP3_LDAP_H
-#define _PHP3_LDAP_H
-
-#if COMPILE_DL
-#undef HAVE_LDAP
-#define HAVE_LDAP 1
-#endif
-
-#if HAVE_LDAP
-#include <lber.h>
-#include <ldap.h>
-
-extern php3_module_entry ldap_module_entry;
-#define ldap_module_ptr &ldap_module_entry
-
-/* LDAP functions */
-PHP_MINIT_FUNCTION(ldap);
-PHP_MSHUTDOWN_FUNCTION(ldap);
-
-PHP_MINFO_FUNCTION(ldap);
-
-PHP_FUNCTION(ldap_connect);
-
-PHP_FUNCTION(ldap_bind);
-PHP_FUNCTION(ldap_unbind);
-
-PHP_FUNCTION(ldap_read);
-PHP_FUNCTION(ldap_list);
-PHP_FUNCTION(ldap_search);
-
-PHP_FUNCTION(ldap_free_result);
-PHP_FUNCTION(ldap_count_entries);
-
-PHP_FUNCTION(ldap_first_entry);
-PHP_FUNCTION(ldap_next_entry);
-PHP_FUNCTION(ldap_get_entries);
-#if 0
-PHP_FUNCTION(ldap_free_entry);
-#endif
-PHP_FUNCTION(ldap_first_attribute);
-PHP_FUNCTION(ldap_next_attribute);
-PHP_FUNCTION(ldap_get_attributes);
-
-PHP_FUNCTION(ldap_get_values);
-
-PHP_FUNCTION(ber_free);
-PHP_FUNCTION(ldap_get_dn);
-PHP_FUNCTION(ldap_explode_dn);
-PHP_FUNCTION(ldap_dn2ufn);
-
-PHP_FUNCTION(ldap_add);
-PHP_FUNCTION(ldap_delete);
-PHP_FUNCTION(ldap_modify);
-
-PHP_FUNCTION(ldap_mod_add);
-PHP_FUNCTION(ldap_mod_replace);
-PHP_FUNCTION(ldap_mod_del);
-
-typedef struct {
- long default_link;
- long num_links, max_links;
- char *base_dn;
- int le_result, le_result_entry, le_ber_entry;
- int le_link;
-
- /* I just found out that the thread safe features
- of the netscape ldap library are only required if
- multiple threads are accessing the same LDAP
- structure. Since we are not doing that, we do
- not need to use this feature. I am leaving the
- code here anyway just in case. smc
- */
-#if 0
- struct ldap_thread_fns tfns;
- int le_errno; /* Corresponds to the LDAP error code */
- char *le_matched; /* Matching components of the DN,
- if an NO_SUCH_OBJECT error occurred */
- char *le_errmsg; /* Error message */
-#endif
-} ldap_module;
-
-#ifndef THREAD_SAFE
-extern ldap_module php3_ldap_module;
-#endif
-
-#else
-
-#define ldap_module_ptr NULL
-
-#endif
-
-#define phpext_ldap_ptr ldap_module_ptr
-
-#endif /* _PHP3_LDAP_H */
diff --git a/ext/ldap/setup.stub b/ext/ldap/setup.stub
deleted file mode 100644
index 72182a28ef..0000000000
--- a/ext/ldap/setup.stub
+++ /dev/null
@@ -1,8 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-ldap 'LDAP support?' yesnodir \
- 'no /usr/local/ldap LDAP base install' \
-' Whether to build with LDAP (Lightweight Directory Access Protocol)\n
- support.\n
- More information about LDAP can be found in RFC1777 and RFC1778.'
diff --git a/ext/mcal/Makefile.am b/ext/mcal/Makefile.am
deleted file mode 100644
index 3ee9cdd58f..0000000000
--- a/ext/mcal/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_mcal.a
-libphpext_mcal_a_SOURCES=php3_mcal.c
-
diff --git a/ext/mcal/config.h.stub b/ext/mcal/config.h.stub
deleted file mode 100644
index fb51531c78..0000000000
--- a/ext/mcal/config.h.stub
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Define if you want the MCAL extension */
-#define HAVE_MCAL 0
diff --git a/ext/mcal/config.m4 b/ext/mcal/config.m4
deleted file mode 100644
index 914203e0ac..0000000000
--- a/ext/mcal/config.m4
+++ /dev/null
@@ -1,25 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(for MCAL support)
-AC_ARG_WITH(mcal,
-[ --with-mcal[=DIR] Include MCAL support.],
-[
- if test "$withval" != "no"; then
- if test "$withval" = "yes"; then
- MCAL_DIR=/usr/local
- else
- MCAL_DIR=$withval
- fi
-
- AC_ADD_INCLUDE($MCAL_DIR)
- AC_ADD_LIBRARY_WITH_PATH(mcal, $MCAL_DIR)
- AC_DEFINE(HAVE_MCAL)
- PHP_EXTENSION(mcal)
- AC_MSG_RESULT(yes)
- else
- AC_MSG_ERROR(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-
diff --git a/ext/mcal/php3_mcal.c b/ext/mcal/php3_mcal.c
deleted file mode 100644
index 4d0d8e2fbc..0000000000
--- a/ext/mcal/php3_mcal.c
+++ /dev/null
@@ -1,1642 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: |
- | Mark Musone <musone@chek.com> |
- +----------------------------------------------------------------------+
- */
-
-#define MCAL1
-
-#ifdef ERROR
-#undef ERROR
-#endif
-
-#include "php.h"
-#ifndef ZEND_VERSION
-#include "internal_functions.h"
-#endif
-
-#if COMPILE_DL
-#include "dl/phpdl.h"
-#endif
-
-#if HAVE_MCAL
-
-#include <time.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <signal.h>
-#include <stdarg.h>
-#ifndef ZEND_VERSION
-#include "php3_list.h"
-#endif
-#include "mcal.h"
-#include "php3_mcal.h"
-#include "modules.h"
-#if (WIN32|WINNT)
-#include "winsock.h"
-#endif
-CALSTREAM *cal_open();
-CALSTREAM *cal_close_it ();
-CALSTREAM *cal_close_full ();
-
-
-typedef struct php3_mcal_le_struct {
- CALSTREAM *mcal_stream;
- long public;
- CALEVENT *event;
- long flags;
-} pils;
-
-
-typedef struct cal_list
-{
-u_int32_t uid;
-struct cal_list *next;
-} cal_list_t;
-
-static cal_list_t *g_cal_list=NULL;
-static cal_list_t *g_cal_list_end=NULL;
-/*
- * this array should be set up as:
- * {"PHPScriptFunctionName",dllFunctionName,1}
- */
-
-function_entry mcal_functions[] = {
-PHP_FE(mcal_open,NULL)
-PHP_FE(mcal_close,NULL)
-PHP_FE(mcal_popen,NULL)
-PHP_FE(mcal_reopen,NULL)
-PHP_FE(mcal_fetch_event,NULL)
-PHP_FE(mcal_list_events,NULL)
-PHP_FE(mcal_list_alarms,NULL)
-PHP_FE(mcal_create_calendar,NULL)
-PHP_FE(mcal_rename_calendar,NULL)
-PHP_FE(mcal_delete_calendar,NULL)
-PHP_FE(mcal_delete_event,NULL)
-PHP_FE(mcal_store_event,NULL)
-PHP_FE(mcal_snooze,NULL)
-PHP_FE(mcal_event_set_category,NULL)
-PHP_FE(mcal_event_set_title,NULL)
-PHP_FE(mcal_event_set_description,NULL)
-PHP_FE(mcal_event_set_start,NULL)
-PHP_FE(mcal_event_set_end,NULL)
-PHP_FE(mcal_event_set_alarm,NULL)
-PHP_FE(mcal_event_set_class,NULL)
-PHP_FE(mcal_is_leap_year,NULL)
-PHP_FE(mcal_days_in_month,NULL)
-PHP_FE(mcal_date_valid,NULL)
-PHP_FE(mcal_time_valid,NULL)
-PHP_FE(mcal_day_of_week,NULL)
-PHP_FE(mcal_day_of_year,NULL)
-PHP_FE(mcal_date_compare,NULL)
-PHP_FE(mcal_event_init,NULL)
-PHP_FE(mcal_next_recurrence,NULL)
-PHP_FE(mcal_event_set_recur_daily,NULL)
-PHP_FE(mcal_event_set_recur_weekly,NULL)
-PHP_FE(mcal_event_set_recur_monthly_mday,NULL)
-PHP_FE(mcal_event_set_recur_monthly_wday,NULL)
-PHP_FE(mcal_event_set_recur_yearly,NULL)
-PHP_FE(mcal_fetch_current_stream_event,NULL)
- {NULL, NULL, NULL}
-};
-
-#ifdef ZEND_VERSION
-php3_module_entry php3_mcal_module_entry = {
- CALVER, mcal_functions, PHP_MINIT(mcal), NULL, NULL, NULL, PHP_MINFO(mcal), 0, 0, 0, NULL
-};
-#else
-php3_module_entry php3_mcal_module_entry = {"mcal", mcal_functions, PHP_MINIT_FUNCTION, NULL, NULL, NULL, PHP_MINFO_FUNCTION, 0, 0, 0, NULL};
-#endif
-
-#if COMPILE_DL
-DLEXPORT php3_module_entry *get_module(void) { return &php3_mcal_module_entry; }
-#endif
-
-/*
- I believe since this global is used ONLY within this module,
- and nothing will link to this module, we can use the simple
- thread local_ storage
-*/
-int le_mcal;
-char mcal_user[80]="";
-char mcal_password[80]="";
-
-CALSTREAM *cal_close_it (pils *mcal_le_struct)
-{
- CALSTREAM *ret;
- ret = cal_close (mcal_le_struct->mcal_stream,0);
- efree(mcal_le_struct);
- return ret;
-}
-
-
-#ifdef ZEND_VERSION
-PHP_MINFO_FUNCTION(mcal)
-#else
-void PHP_MINFO_FUNCTION(void)
-#endif
-{
- php3_printf("Mcal Support enabled<br>");
- php3_printf("<table>");
- php3_printf("<tr><td>Mcal Version:</td>");
- php3_printf("<td>%s</td>",CALVER);
- php3_printf("</tr></table>");
-}
-
-#ifdef ZEND_VERSION
-PHP_MINIT_FUNCTION(mcal)
-#else
-int PHP_MINIT_FUNCTION(INIT_FUNC_ARGS)
-#endif
-{
-
- le_mcal = register_list_destructors(cal_close_it,NULL);
-
- REGISTER_MAIN_LONG_CONSTANT("MCAL_SUNDAY",SUNDAY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_MONDAY",MONDAY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_TUESDAY",TUESDAY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_WEDNESDAY",WEDNESDAY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_THURSDAY",THURSDAY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_FRIDAY",FRIDAY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_SATURDAY",SATURDAY, CONST_PERSISTENT | CONST_CS);
-
- REGISTER_MAIN_LONG_CONSTANT("MCAL_JANUARY",JANUARY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_FEBRUARY",FEBRUARY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_MARCH",MARCH, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_APRIL",APRIL, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_MAY",MAY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_JUNE",JUNE, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_JULY",JULY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_AUGUST",AUGUST, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_SEPTEMBER",SEPTEMBER, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_OCTOBER",OCTOBER, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_NOVEMBER",NOVEMBER, CONST_PERSISTENT | CONST_CS);
-
-
- REGISTER_MAIN_LONG_CONSTANT("MCAL_RECUR_NONE",RECUR_NONE, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_RECUR_DAILY",RECUR_DAILY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_RECUR_WEEKLY",RECUR_WEEKLY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_RECUR_MONTHLY_MDAY",RECUR_MONTHLY_MDAY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_RECUR_MONTHLY_WDAY",RECUR_MONTHLY_WDAY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_RECUR_YEARLY",RECUR_YEARLY, CONST_PERSISTENT | CONST_CS);
-
-
- REGISTER_MAIN_LONG_CONSTANT("MCAL_M_SUNDAY",M_SUNDAY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_M_MONDAY",M_MONDAY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_M_TUESDAY",M_TUESDAY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_M_WEDNESDAY",M_WEDNESDAY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_M_THURSDAY",M_THURSDAY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_M_FRIDAY",M_FRIDAY, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_M_SATURDAY",M_SATURDAY, CONST_PERSISTENT | CONST_CS);
-
- REGISTER_MAIN_LONG_CONSTANT("MCAL_M_WEEKDAYS",M_WEEKDAYS, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_M_WEEKEND",M_WEEKEND, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("MCAL_M_ALLDAYS",M_ALLDAYS, CONST_PERSISTENT | CONST_CS);
-
-
- return SUCCESS;
-}
-
-
-static int add_assoc_object(pval *arg, char *key, pval tmp)
-{
-#ifdef ZEND_VERSION
- HashTable *symtable;
-
- if (arg->type == IS_OBJECT) {
- symtable = arg->value.obj.properties;
- } else {
- symtable = arg->value.ht;
- }
- return zend_hash_update(symtable, key, strlen(key)+1, (void *) &tmp, sizeof(pval *), NULL);
-#else
- return _php3_hash_update(arg->value.ht, key, strlen(key)+1, (void *) &tmp, sizeof(pval), NULL);
-#endif
-}
-
-
-void php3_mcal_do_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
-{
- pval *calendar;
- pval *user;
- pval *passwd;
- pval *options;
- CALSTREAM *mcal_stream;
- pils *mcal_le_struct;
- long flags=0;
- int ind;
- int myargc=ARG_COUNT(ht);
-
-
- if (myargc <3 || myargc >4 || getParameters(ht, myargc, &calendar,&user,&passwd,&options) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(calendar);
- convert_to_string(user);
- convert_to_string(passwd);
- strcpy(mcal_user,user->value.str.val);
- strcpy(mcal_password,passwd->value.str.val);
- if(myargc ==4) {
- convert_to_long(options);
- flags=options->value.lval;
- php3_printf("option is: %d\n",options->value.lval);
- }
- mcal_stream = cal_open(NULL,calendar->value.str.val,0);
- if (!mcal_stream) {
- php3_error(E_WARNING,"Couldn't open stream %s\n",calendar->value.str.val);
- RETURN_FALSE;
- }
-
- mcal_le_struct = emalloc(sizeof(pils));
- mcal_le_struct->mcal_stream = mcal_stream;
- mcal_le_struct->event=calevent_new();
-
- ind = php3_list_insert(mcal_le_struct, le_mcal);
- RETURN_LONG(ind);
-}
-
-
-
-
-/* {{{ proto int mcal_close(int stream_id [, int options])
- Close an MCAL stream */
-void php3_mcal_close(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *options, *streamind;
- int ind, ind_type;
- pils *mcal_le_struct=NULL;
- int myargcount=ARG_COUNT(ht);
- long flags = 0;
-
- if (myargcount < 1 || myargcount > 2 || getParameters(ht, myargcount, &streamind, &options) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(streamind);
- ind = streamind->value.lval;
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- if(myargcount==2) {
- convert_to_long(options);
- flags = options->value.lval;
- mcal_le_struct->flags = flags;
- }
- php3_list_delete(ind);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-
-
-
-
-
-
-/* {{{ proto int mcal_open(string calendar, string user, string password [, int options])
- Open an MCAL stream to a calendar */
-void php3_mcal_open(INTERNAL_FUNCTION_PARAMETERS)
-{
- php3_mcal_do_open(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-
-/* {{{ proto int mcal_reopen(int stream_id, string calendar [, int options])
- Reopen MCAL stream to new calendar */
-void php3_mcal_reopen(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind;
- pval *calendar;
- pval *options;
- CALSTREAM *mcal_stream=NULL;
- pils *mcal_le_struct;
- int ind, ind_type;
- long flags=0;
- long cl_flags=0;
- int myargc=ARG_COUNT(ht);
-
- if (myargc<2 || myargc>3 || getParameters(ht,myargc,&streamind, &calendar, &options) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- ind = streamind->value.lval;
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- convert_to_string(calendar);
- if(myargc == 3) {
- convert_to_long(options);
- flags = options->value.lval;
- mcal_le_struct->flags = cl_flags;
- }
- if (mcal_stream == NULL) {
- php3_error(E_WARNING,"Couldn't re-open stream\n");
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/* {{{ proto int mcal_expunge(int stream_id)
- Delete all messages marked for deletion */
-void php3_mcal_expunge(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind;
- int ind, ind_type;
- pils *mcal_le_struct;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &streamind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
-
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
-/* cal_expunge (mcal_le_struct->mcal_stream);
-*/
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int mcal_fetch_event(int stream_id,int eventid, [int options])
- Fetch an event*/
-void php3_mcal_fetch_event(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*eventid,*options=NULL;
- int ind, ind_type;
- pils *mcal_le_struct=NULL;
- CALEVENT *myevent;
- int myargcount=ARG_COUNT(ht);
-
- if (myargcount < 1 || myargcount > 3 || getParameters(ht, myargcount, &streamind, &eventid,&options) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(streamind);
- convert_to_long(eventid);
- ind = streamind->value.lval;
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- if(myargcount==3) {
- convert_to_long(options);
- }
- cal_fetch(mcal_le_struct->mcal_stream,eventid->value.lval,&myevent);
- if(myevent == NULL)
- {
- RETURN_FALSE;
- }
- calevent_free(mcal_le_struct->event);
- mcal_le_struct->event=myevent;
- make_event_object(return_value,mcal_le_struct->event);
-
-}
-/* }}} */
-
-/* {{{ proto object mcal_fetch_current_stream_event(int stream_id)
- Fetch the current event stored in the stream's event structure*/
-void php3_mcal_fetch_current_stream_event(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind;
- int ind, ind_type;
- pils *mcal_le_struct=NULL;
- int myargcount=ARG_COUNT(ht);
-
- if (myargcount != 1 || getParameters(ht, myargcount, &streamind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(streamind);
- ind = streamind->value.lval;
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- make_event_object(return_value,mcal_le_struct->event);
-
-}
-/* }}} */
-
-
-
-void make_event_object(pval *mypvalue,CALEVENT *event)
-{
- pval start,end,recurend;
- object_init(mypvalue);
- add_property_long(mypvalue,"id",event->id);
- add_property_long(mypvalue,"public",event->public);
- object_init(&start);
-
- if(event->start.has_date)
- {
- add_property_long(&start,"year",event->start.year);
- add_property_long(&start,"month",event->start.mon);
- add_property_long(&start,"mday",event->start.mday);
- }
- if(event->start.has_time)
- {
- add_property_long(&start,"hour",event->start.hour);
- add_property_long(&start,"min",event->start.min);
- add_property_long(&start,"sec",event->start.sec);
- }
-
-
- add_assoc_object(mypvalue, "start",start);
-
- object_init(&end);
- if(event->end.has_date)
- {
- add_property_long(&end,"year",event->end.year);
- add_property_long(&end,"month",event->end.mon);
- add_property_long(&end,"mday",event->end.mday);
- }
- if(event->end.has_time)
- {
- add_property_long(&end,"hour",event->end.hour);
- add_property_long(&end,"min",event->end.min);
- add_property_long(&end,"sec",event->end.sec);
- }
- add_assoc_object(mypvalue, "end",end);
-
-
- add_property_string(mypvalue,"category",event->category,1);
- add_property_string(mypvalue,"title",event->title,1);
- add_property_string(mypvalue,"description",event->description,1);
- add_property_long(mypvalue,"alarm",event->alarm);
- add_property_long(mypvalue,"recur_type",event->recur_type);
- add_property_long(mypvalue,"recur_interval",event->recur_interval);
- object_init(&recurend);
- if(event->recur_enddate.has_date)
- {
- add_property_long(&recurend,"year",event->recur_enddate.year);
- add_property_long(&recurend,"month",event->recur_enddate.mon);
- add_property_long(&recurend,"mday",event->recur_enddate.mday);
- }
- if(event->recur_enddate.has_time)
- {
- add_property_long(&recurend,"hour",event->recur_enddate.hour);
- add_property_long(&recurend,"min",event->recur_enddate.min);
- add_property_long(&recurend,"sec",event->recur_enddate.sec);
- }
- add_assoc_object(mypvalue, "recur_enddate",recurend);
- add_property_long(mypvalue,"recur_data",event->recur_data.weekly_wday);
-}
-
-
-
-/* {{{ proto array mcal_list_events(int stream_id,object begindate, [object enddate])
- Returns list of UIDs for that day or range of days */
-void php3_mcal_list_events(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*startyear,*startmonth,*startday;
- pval *endyear,*endmonth,*endday;
-#ifdef ZEND_VERSION
- pval **pvalue;
-#else
- pval *pvalue;
-#endif
- int ind, ind_type;
- pils *mcal_le_struct;
- cal_list_t *my_cal_list;
- int myargc;
- datetime_t startdate=DT_INIT;
- datetime_t enddate=DT_INIT;
- myargc=ARG_COUNT(ht);
- if (myargc !=1 || getParameters(ht,myargc,&streamind,&startyear,&startmonth,&startday,&endyear,&endmonth,&endday) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- /* Initialize return array */
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
-
-
- if(myargc ==7)
- {
- convert_to_long(startyear);
- convert_to_long(startmonth);
- convert_to_long(startday);
- convert_to_long(endyear);
- convert_to_long(endmonth);
- convert_to_long(endday);
- dt_setdate(&startdate,startyear->value.lval,startmonth->value.lval,startday->value.lval);
- dt_setdate(&enddate,endyear->value.lval,endmonth->value.lval,endday->value.lval);
- }
- else
- {
- startdate=mcal_le_struct->event->start;
- enddate=mcal_le_struct->event->end;
- }
-
- g_cal_list=NULL;
- cal_search_range(mcal_le_struct->mcal_stream,&startdate,&enddate);
- my_cal_list=g_cal_list;
- while(my_cal_list != NULL)
- {
- add_next_index_long(return_value,my_cal_list->uid);
- my_cal_list=my_cal_list->next;
- free(g_cal_list);
- g_cal_list=my_cal_list;
- }
-}
-/* }}} */
-
-
-/* {{{ proto string mcal_create_calendar(int stream_id, string calendar)
- Create a new calendar*/
-
-void php3_mcal_create_calendar(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind, *calendar;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc=ARG_COUNT(ht);
- if (myargc <1 || myargc > 2 || getParameters(ht,myargc,&streamind,&calendar) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(calendar);
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-/*
- if (mcal_create(mcal_le_struct->mcal_stream,calendar->value.str.val))
- {
- RETURN_TRUE;
- }
- else
- {
- RETURN_FALSE;
- }
-*/
-}
-/* }}} */
-
-
-/* {{{ proto string mcal_rename(int stream_id, string src_calendar, string dest_calendar)
- Rename a calendar*/
-void php3_mcal_rename_calendar(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind, *src_calendar,*dest_calendar;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc=ARG_COUNT(ht);
- if (myargc <2 || myargc > 3 || getParameters(ht,myargc,&streamind,&src_calendar,&dest_calendar) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(src_calendar);
- convert_to_string(dest_calendar);
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-/*
- if(mcal_rename(mcal_le_struct->mcal_stream,src_calendar->value.str.val,dest_calendar->value.str.val)) {RETURN_TRUE;}
- else {RETURN_FALSE; }
-*/
-}
-/* }}} */
-
-
-
-
-/* {{{ proto int mcal_reopen(int stream_id, array date, array time)
- list alarms for a given time */
-void php3_mcal_list_alarms(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind, *year,*month,*day,*hour,*min,*sec;
-#ifdef ZEND_VERSION
- pval **pvalue;
-#else
- pval *pvalue;
-#endif
- datetime_t mydate=DT_INIT;
- int ind, ind_type;
- pils *mcal_le_struct;
- cal_list_t *my_cal_list;
- int myargc=ARG_COUNT(ht);
- if (myargc != 1 || myargc !=7 || getParameters(ht,myargc,&streamind,&year,&month,&day,&hour,&min,&sec) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
-
- if(myargc ==7)
- {
- convert_to_long(year);
- convert_to_long(month);
- convert_to_long(day);
- convert_to_long(hour);
- convert_to_long(min);
- convert_to_long(sec);
- dt_setdate(&mydate,year->value.lval,month->value.lval,day->value.lval);
- dt_setdate(&mydate,hour->value.lval,min->value.lval,sec->value.lval);
- }
- else
- {
- mydate=mcal_le_struct->event->start;
- }
- g_cal_list=NULL;
- cal_search_alarm(mcal_le_struct->mcal_stream,&mydate);
- my_cal_list=g_cal_list;
- while(my_cal_list != NULL)
- {
- add_next_index_long(return_value,my_cal_list->uid);
- my_cal_list=my_cal_list->next;
- free(g_cal_list);
- g_cal_list=my_cal_list;
- }
-}
-/* }}} */
-
-
-/* {{{ proto string mcal_delete_calendar(int stream_id, string calendar)
- Delete calendar*/
-void php3_mcal_delete_calendar(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind, *calendar;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc=ARG_COUNT(ht);
- if (myargc <1 || myargc > 2 || getParameters(ht,myargc,&streamind,&calendar) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(calendar);
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- /* if (mcal_delete_calendar(mcal_le_struct->mcal_stream,calendar->value.str.val))
- {
- RETURN_TRUE;
- }
- else
- {
- RETURN_FALSE;
- }
- */
-}
-/* }}} */
-
-
-/* {{{ proto string mcal_delete_event(int stream_id, int uid)
- Delete event*/
-void php3_mcal_delete_event(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind, *uid;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc=ARG_COUNT(ht);
- if (myargc <1 || myargc > 2 || getParameters(ht,myargc,&streamind,&uid) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(uid);
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- if (cal_remove(mcal_le_struct->mcal_stream,uid->value.lval))
- {
- RETURN_TRUE;
- }
- else
- {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-
-void php3_mcal_popen(INTERNAL_FUNCTION_PARAMETERS){
-}
-
-
-/* {{{ proto string mcal_store_event(int stream_id, object event)
- Store an event*/
-void php3_mcal_store_event(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*storeobject;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc;
- unsigned long uid;
- CALEVENT *myevent;
- myargc=ARG_COUNT(ht);
- if (myargc !=1 || getParameters(ht,myargc,&streamind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
-
-
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- /* Initialize return array */
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
- myevent=mcal_le_struct->event;
- cal_append(mcal_le_struct->mcal_stream,"INBOX",&uid,myevent);
- calevent_free(myevent);
- RETURN_LONG(uid);
-}
-/* }}} */
-
-
-/* {{{ proto string mcal_snooze(int stream_id, int uid)
- Snooze an alarm*/
-void php3_mcal_snooze(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*uid;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc;
- myargc=ARG_COUNT(ht);
- if (myargc !=2 || getParameters(ht,myargc,&streamind,&uid) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(uid);
-
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
- if(cal_snooze(mcal_le_struct->mcal_stream,uid->value.lval))
- {
- RETURN_TRUE;
- }
- else
- {
- RETURN_FALSE;
- }
-
-
-}
-/* }}} */
-
-
-/* {{{ proto string mcal_event_set_category(int stream_id, string category)
- attach a category to an event*/
-void php3_mcal_event_set_category(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*category;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc;
- myargc=ARG_COUNT(ht);
- if (myargc !=2 || getParameters(ht,myargc,&streamind,&category) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(category);
-
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- mcal_le_struct->event->category=strdup(category->value.str.val);
-}
- /* }}} */
-
-/* {{{ proto string mcal_event_set_title(int stream_id, string title)
- attach a title to an event*/
-void php3_mcal_event_set_title(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*title;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc;
- myargc=ARG_COUNT(ht);
- if (myargc !=2 || getParameters(ht,myargc,&streamind,&title) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(title);
-
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- mcal_le_struct->event->title=strdup(title->value.str.val);
-}
- /* }}} */
-
-/* {{{ proto string mcal_event_set_description(int stream_id, string description)
- attach a description to an event*/
-void php3_mcal_event_set_description(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*description;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc;
- myargc=ARG_COUNT(ht);
- if (myargc !=2 || getParameters(ht,myargc,&streamind,&description) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_string(description);
-
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- mcal_le_struct->event->description=strdup(description->value.str.val);
-}
- /* }}} */
-
-/* {{{ proto string mcal_event_set_start(int stream_id, int year,int month, int day, [[[int hour],int min],int sec])
- attach a start datetime to an event*/
-void php3_mcal_event_set_start(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*year,*month,*date,*hour,*min,*sec;
- int ind, ind_type;
- int myhour=0,mymin=0,mysec=0;
- pils *mcal_le_struct;
- int myargc;
- myargc=ARG_COUNT(ht);
- if (myargc <4 || getParameters(ht,myargc,&streamind,&year,&month,&date,&hour,&min,&sec) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(year);
- convert_to_long(month);
- convert_to_long(date);
- if(myargc > 4) convert_to_long(hour);
- if(myargc > 5) convert_to_long(min);
- if(myargc > 6) convert_to_long(sec);
-
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
-
- dt_setdate(&(mcal_le_struct->event->start),year->value.lval,month->value.lval,date->value.lval);
-
- if(myargc > 4) myhour=hour->value.lval;
- if(myargc > 5) mymin=min->value.lval;
- if(myargc > 6) mysec=sec->value.lval;
- if(myargc >4) dt_settime(&(mcal_le_struct->event->start),myhour,mymin,mysec);
-
-}
- /* }}} */
-
-/* {{{ proto string mcal_event_set_end(int stream_id, int year,int month, int day, [[[int hour],int min],int sec])
- attach an end datetime to an event*/
-void php3_mcal_event_set_end(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*year,*month,*date,*hour,*min,*sec;
- int ind, ind_type;
- int myhour,mymin,mysec;
- pils *mcal_le_struct;
- int myargc;
- myargc=ARG_COUNT(ht);
- if (myargc <4 || getParameters(ht,myargc,&streamind,&year,&month,&date,&hour,&min,&sec) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(year);
- convert_to_long(month);
- convert_to_long(date);
- if(myargc > 4) convert_to_long(hour);
- if(myargc > 5) convert_to_long(min);
- if(myargc > 6) convert_to_long(sec);
-
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
-
- dt_setdate(&(mcal_le_struct->event->end),year->value.lval,month->value.lval,date->value.lval);
-
- if(myargc > 4) myhour=hour->value.lval;
- if(myargc > 5) mymin=min->value.lval;
- if(myargc > 6) mysec=sec->value.lval;
- if(myargc >4) dt_settime(&(mcal_le_struct->event->end),myhour,mymin,mysec);
-}
- /* }}} */
-
-/* {{{ proto int mcal_event_set_alarm(int stream_id, int alarm)
- add an alarm to the streams global event */
-void php3_mcal_event_set_alarm(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*alarm;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc;
- myargc=ARG_COUNT(ht);
- if (myargc !=2 || getParameters(ht,myargc,&streamind,&alarm) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(alarm);
-
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- mcal_le_struct->event->alarm=alarm->value.lval;
-}
- /* }}} */
-
-/* {{{ proto int mcal_event_init(int stream_id)
- initialize a streams global event */
-void php3_mcal_event_init(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc;
- myargc=ARG_COUNT(ht);
- if (myargc !=1 || getParameters(ht,myargc,&streamind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
-
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- php3_event_init(mcal_le_struct);
-}
- /* }}} */
-
-void php3_event_init(struct php3_mcal_le_struct *mystruct)
-{
- calevent_free(mystruct->event);
- mystruct->event=calevent_new();
-}
-
-
-/* {{{ proto int mcal_event_set_class(int stream_id, int class)
- add an class to the streams global event */
-void php3_mcal_event_set_class(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*class;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc;
- myargc=ARG_COUNT(ht);
- if (myargc !=2 || getParameters(ht,myargc,&streamind,&class) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(class);
-
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- mcal_le_struct->event->public=class->value.lval;
-}
- /* }}} */
-
-
-
-/* {{{ proto bool mcal_is_leap_year(int year)
- returns true if year is a leap year, false if not */
-void php3_mcal_is_leap_year(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *year;
- int myargc;
- myargc=ARG_COUNT(ht);
- if (myargc !=1 || getParameters(ht,myargc,&year) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(year);
- if(isleapyear(year->value.lval))
- {
- RETURN_TRUE;
- }
- else
- {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int mcal_days_in_month(int month,bool leap_year)
- returns the number of days in the given month, needs to know if the year is a leap year or not */
-void php3_mcal_days_in_month(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *month,*leap;
- int myargc;
- myargc=ARG_COUNT(ht);
- if (myargc !=2 || getParameters(ht,myargc,&month,&leap) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(month);
- convert_to_long(leap);
- convert_to_boolean(leap);
- RETURN_LONG(daysinmonth(month->value.lval,leap->value.lval));
-}
-/* }}} */
-
-
-/* {{{ proto bool mcal_date_valid(int year,int month,int day)
- returns true if the date is a valid date */
-void php3_mcal_date_valid(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *year,*month,*day;
- int myargc;
- myargc=ARG_COUNT(ht);
- if (myargc !=3 || getParameters(ht,myargc,&year,&month,&day) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(year);
- convert_to_long(month);
- convert_to_long(day);
- if(datevalid(year->value.lval,month->value.lval,day->value.lval))
- {
- RETURN_TRUE;
- }
- else
- {
- RETURN_FALSE;
- }
-}
-
-/* }}} */
-
-
-/* {{{ proto bool mcal_time_valid(int hour,int min,int sec)
- returns true if the time is a valid time */
-void php3_mcal_time_valid(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *hour,*min,*sec;
- int myargc;
- myargc=ARG_COUNT(ht);
- if (myargc !=3 || getParameters(ht,myargc,&hour,&min,&sec) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(hour);
- convert_to_long(min);
- convert_to_long(sec);
- if(timevalid(hour->value.lval,min->value.lval,sec->value.lval))
- {
- RETURN_TRUE;
- }
- else
- {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int mcal_day_of_week(int year,int month,int day)
- returns the day of the week of the given date */
-void php3_mcal_day_of_week(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *year,*month,*day;
- int myargc;
- datetime_t mydate;
- myargc=ARG_COUNT(ht);
- if (myargc !=3 || getParameters(ht,myargc,&year,&month,&day) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(year);
- convert_to_long(month);
- convert_to_long(day);
- dt_init(&mydate);
- dt_setdate(&mydate,year->value.lval,month->value.lval, day->value.lval);
-
- RETURN_LONG(dt_dayofweek(&mydate));
-}
-/* }}} */
-
-/* {{{ proto int mcal_day_of_year(int year,int month,int day)
- returns the day of the year of the given date */
-void php3_mcal_day_of_year(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *year,*month,*day;
- int myargc;
- datetime_t mydate;
- myargc=ARG_COUNT(ht);
- if (myargc !=3 || getParameters(ht,myargc,&year,&month,&day) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(year);
- convert_to_long(month);
- convert_to_long(day);
- dt_init(&mydate);
- dt_setdate(&mydate,year->value.lval,month->value.lval, day->value.lval);
-
- RETURN_LONG(dt_dayofyear(&mydate));
-}
-
-
-
-
-/* {{{ proto int mcal_day_of_week(int ayear,int amonth,int aday,int byear,int bmonth,int bday)
- returns <0, 0, >0 if a<b, a==b, a>b respectively */
-void php3_mcal_date_compare(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *ayear,*amonth,*aday;
- pval *byear,*bmonth,*bday;
- int myargc;
- datetime_t myadate,mybdate;
- myargc=ARG_COUNT(ht);
- if (myargc !=6 || getParameters(ht,myargc,&ayear,&amonth,&aday,&byear,&bmonth,&bday) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(ayear);
- convert_to_long(amonth);
- convert_to_long(aday);
- convert_to_long(byear);
- convert_to_long(bmonth);
- convert_to_long(bday);
- dt_init(&myadate);
- dt_init(&mybdate);
- dt_setdate(&myadate,ayear->value.lval,amonth->value.lval, aday->value.lval);
- dt_setdate(&mybdate,byear->value.lval,bmonth->value.lval, bday->value.lval);
-
- RETURN_LONG(dt_compare(&myadate,&mybdate));
-}
-
-
-/* }}} */
-
-
-/* {{{ proto object mcal_next_recurrence(int stream_id, int weekstart,array next)
- returns an object filled with the next date the event occurs, on or
- after the supplied date. Returns empty date field if event does not
- occur or something is invalid.
- */
-void php3_mcal_next_recurrence(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*weekstart,*next,*pvalue;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc;
- datetime_t mydate;
- CALEVENT *myevent=NULL;
- myargc=ARG_COUNT(ht);
- if (myargc !=3 || getParameters(ht,myargc,&streamind,&weekstart,&next) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(weekstart);
- convert_to_array(next);
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
-
-
- if(_php3_hash_find(next->value.ht,"year",sizeof("year"),(void **) &pvalue)== SUCCESS){
-
- convert_to_long(pvalue);
- mydate.year=(pvalue)->value.lval;
- }
- if(_php3_hash_find(next->value.ht,"month",sizeof("month"),(void **) &pvalue)== SUCCESS){
-
- convert_to_long(pvalue);
- mydate.mon=(pvalue)->value.lval;
- }
- if(_php3_hash_find(next->value.ht,"mday",sizeof("mday"),(void **) &pvalue)== SUCCESS){
-
- convert_to_long(pvalue);
- mydate.mday=(pvalue)->value.lval;
- }
- if(_php3_hash_find(next->value.ht,"hour",sizeof("hour"),(void **) &pvalue)== SUCCESS){
-
- convert_to_long(pvalue);
- mydate.hour=(pvalue)->value.lval;
- }
- if(_php3_hash_find(next->value.ht,"min",sizeof("min"),(void **) &pvalue)== SUCCESS){
-
- convert_to_long(pvalue);
- mydate.min=(pvalue)->value.lval;
- }
- if(_php3_hash_find(next->value.ht,"sec",sizeof("sec"),(void **) &pvalue)== SUCCESS){
-
- convert_to_long(pvalue);
- mydate.sec=(pvalue)->value.lval;
-
- }
-
- calevent_next_recurrence(mcal_le_struct->event,&mydate,weekstart->value.lval);
- object_init(return_value);
- if(mydate.has_date)
- {
- add_property_long(return_value,"year",mydate.year);
- add_property_long(return_value,"month",mydate.mon);
- add_property_long(return_value,"mday",mydate.mday);
- }
- if(mydate.has_time)
- {
- add_property_long(return_value,"hour",mydate.hour);
- add_property_long(return_value,"min",mydate.min);
- add_property_long(return_value,"sec",mydate.sec);
- }
-}
- /* }}} */
-
-
-
-/* {{{ proto string mcal_event_set_recur_daily(int stream_id,int year,int month,int day,int hour,int min,int sec,int interval
- create a daily recurrence */
-void php3_mcal_event_set_recur_daily(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*year,*month,*day,*hour,*min,*sec,*interval;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc;
- datetime_t endtime=DT_INIT;
- myargc=ARG_COUNT(ht);
- if (myargc !=8 || getParameters(ht,myargc,&streamind,&year,&month,&day,&hour,&min,&sec,&interval) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(year);
- convert_to_long(month);
- convert_to_long(day);
- convert_to_long(hour);
- convert_to_long(min);
- convert_to_long(sec);
- convert_to_long(interval);
-
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- dt_setdate(&endtime,year->value.lval,month->value.lval,day->value.lval);
- dt_settime(&endtime,hour->value.lval,min->value.lval,sec->value.lval);
- calevent_recur_daily(mcal_le_struct->event, &endtime,
- interval->value.lval);
-
-}
- /* }}} */
-
-/* {{{ proto string mcal_event_set_recur_weekly(int stream_id,int year,int month,int day,int hour,int min,int sec,int interval, int weekdays)
-create a weekly recurrence */
-void php3_mcal_event_set_recur_weekly(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*year,*month,*day,*hour,*min,*sec,*interval,*weekdays;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc;
- datetime_t endtime=DT_INIT;
- myargc=ARG_COUNT(ht);
- if (myargc !=4 || getParameters(ht,myargc,&streamind,&year,&month,&day,&hour,&min,&sec,&interval,&weekdays) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(year);
- convert_to_long(month);
- convert_to_long(day);
- convert_to_long(hour);
- convert_to_long(min);
- convert_to_long(sec);
- convert_to_long(interval);
- convert_to_long(weekdays);
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- dt_setdate(&endtime,year->value.lval,month->value.lval,day->value.lval);
- dt_settime(&endtime,hour->value.lval,min->value.lval,sec->value.lval);
- calevent_recur_weekly(mcal_le_struct->event, &endtime,
- interval->value.lval,weekdays->value.lval);
-
-}
- /* }}} */
-
-/* {{{ proto string mcal_event_set_recur_monthly_mday(int stream_id,int year,int month,int day,int hour,int min,int sec,int interval)
- create a monthly by day recurrence */
-void php3_mcal_event_set_recur_monthly_mday(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*year,*month,*day,*hour,*min,*sec,*interval;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc;
- datetime_t endtime=DT_INIT;
- myargc=ARG_COUNT(ht);
- if (myargc !=8 || getParameters(ht,myargc,&streamind,&year,&month,&day,&hour,&min,&sec,&interval) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(year);
- convert_to_long(month);
- convert_to_long(day);
- convert_to_long(hour);
- convert_to_long(min);
- convert_to_long(sec);
- convert_to_long(interval);
-
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- dt_setdate(&endtime,year->value.lval,month->value.lval,day->value.lval);
- dt_settime(&endtime,hour->value.lval,min->value.lval,sec->value.lval);
- calevent_recur_monthly_mday(mcal_le_struct->event, &endtime,
- interval->value.lval);
-
-}
- /* }}} */
-
-/* {{{ proto string mcal_event_set_recur_monthly_wday(int stream_id,int year,int month,int day,int hour,int min,int sec,int interval)
- create a monthy by week recurrence */
-void php3_mcal_event_set_recur_monthly_wday(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*year,*month,*day,*hour,*min,*sec,*interval;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc;
- datetime_t endtime=DT_INIT;
- myargc=ARG_COUNT(ht);
- if (myargc !=8 || getParameters(ht,myargc,&streamind,&year,&month,&day,&hour,&min,&sec,&interval) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(year);
- convert_to_long(month);
- convert_to_long(day);
- convert_to_long(hour);
- convert_to_long(min);
- convert_to_long(sec);
- convert_to_long(interval);
-
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- dt_setdate(&endtime,year->value.lval,month->value.lval,day->value.lval);
- dt_settime(&endtime,hour->value.lval,min->value.lval,sec->value.lval);
- calevent_recur_monthly_wday(mcal_le_struct->event, &endtime,
- interval->value.lval);
-
-}
- /* }}} */
-
-/* {{{ proto string mcal_event_set_recur_yearly(int stream_id,int year,int month,int day,int hour,int min,int sec,int interval)
- create a yearly recurrence */
-void php3_mcal_event_set_recur_yearly(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *streamind,*year,*month,*day,*hour,*min,*sec,*interval;
- int ind, ind_type;
- pils *mcal_le_struct;
- int myargc;
- datetime_t endtime=DT_INIT;
- myargc=ARG_COUNT(ht);
- if (myargc !=8 || getParameters(ht,myargc,&streamind,&year,&month,&day,&hour,&min,&sec,&interval) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(streamind);
- convert_to_long(year);
- convert_to_long(month);
- convert_to_long(day);
- convert_to_long(hour);
- convert_to_long(min);
- convert_to_long(sec);
- convert_to_long(interval);
-
- ind = streamind->value.lval;
-
- mcal_le_struct = (pils *)php3_list_find(ind, &ind_type);
-
- if (!mcal_le_struct ) {
- php3_error(E_WARNING, "Unable to find stream pointer");
- RETURN_FALSE;
- }
- dt_setdate(&endtime,year->value.lval,month->value.lval,day->value.lval);
- dt_settime(&endtime,hour->value.lval,min->value.lval,sec->value.lval);
- calevent_recur_yearly(mcal_le_struct->event, &endtime,
- interval->value.lval);
-
-}
- /* }}} */
-
-
-/* Interfaces to callbacks */
-
-
-
-void cc_searched (unsigned long cal_uid)
-{
- if(g_cal_list==NULL)
- {
- g_cal_list=malloc(sizeof(struct cal_list));
- g_cal_list->uid=cal_uid;
- g_cal_list->next=NULL;
- g_cal_list_end=g_cal_list;
- }
- else
- {
- g_cal_list_end->next=malloc(sizeof(struct cal_list));
- g_cal_list_end=g_cal_list_end->next;
- g_cal_list_end->uid=cal_uid;
- g_cal_list_end->next=NULL;
- }
-}
-
-
-
-
-
-
-void cc_appended(u_int32_t uid)
-{
-
-}
-
-
-void cc_fetched(const CALEVENT *event)
-{
-
-}
-
-
-void cc_login(const char **user, const char **pwd)
-{
-
-*user=mcal_user;
-*pwd=mcal_password;
-}
-
-
-void cc_vlog(const char *fmt,va_list ap)
-{
-}
-void cc_vdlog(const char *fmt,va_list ap)
-{
-}
-
-#endif
-
-
-/*
- * Local_ variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
-
-
diff --git a/ext/mcal/php3_mcal.h b/ext/mcal/php3_mcal.h
deleted file mode 100644
index b519725cc5..0000000000
--- a/ext/mcal/php3_mcal.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* $Id$ */
-
-#ifndef _INCLUDED_MCAL_H
-#define _INCLUDED_MCAL_H
-
-#if COMPILE_DL
-#undef HAVE_MCAL
-#define HAVE_MCAL 1
-#endif
-
-#if HAVE_MCAL
-
-#ifdef THREAD_SAFE
-#include "tls.h"
-#endif
-#ifndef MSVC5
-#include "build-defs.h"
-#endif
-
-/* Functions accessable to PHP */
-//extern php3_module_entry php3_mcal_module_entry;
-extern php3_module_entry php3_mcal_module_entry;
-#define php3_mcal_module_ptr &php3_mcal_module_entry
-#define phpext_mcal_ptr php3_mcal_module_ptr
-
-#ifdef ZEND_VERSION
-extern PHP_MINIT_FUNCTION(mcal);
-PHP_MINFO_FUNCTION(mcal);
-#else
-extern int PHP_MINIT_FUNCTION(INIT_FUNC_ARGS);
-extern void PHP_MINFO_FUNCTION(void);
-#endif
-
-
-extern int mcal_init_request(INIT_FUNC_ARGS);
-extern int mcal_end_request(void);
-void make_event_object();
-void php3_event_init();
-
-void php3_mcal_open(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_popen(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_reopen(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_close(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_fetch_event(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_list_events(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_create_calendar(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_rename_calendar(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_delete_calendar(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_store_event(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_delete_event(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_snooze(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_list_alarms(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_event_set_category(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_event_set_title(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_event_set_description(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_event_set_start(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_event_set_end(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_event_set_alarm(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_event_set_class(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_is_leap_year(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_days_in_month(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_date_valid(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_time_valid(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_day_of_week(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_day_of_year(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_date_compare(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_event_init(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_next_recurrence(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_event_set_recur_daily(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_event_set_recur_weekly(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_event_set_recur_monthly_mday(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_event_set_recur_monthly_wday(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_event_set_recur_yearly(INTERNAL_FUNCTION_PARAMETERS);
-void php3_mcal_fetch_current_stream_event(INTERNAL_FUNCTION_PARAMETERS);
-
-
-#else
-#define php3_mcal_module_ptr NULL
-#endif /* HAVE_MCAL */
-
-
-#endif
-
-
-
-
diff --git a/ext/mcrypt/Makefile.am b/ext/mcrypt/Makefile.am
deleted file mode 100644
index 01baf80148..0000000000
--- a/ext/mcrypt/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_mcrypt.a
-libphpext_mcrypt_a_SOURCES=mcrypt.c
-
diff --git a/ext/mcrypt/config.h.stub b/ext/mcrypt/config.h.stub
deleted file mode 100644
index 28fbe03ae2..0000000000
--- a/ext/mcrypt/config.h.stub
+++ /dev/null
@@ -1,2 +0,0 @@
-/* define if you want to use the mcrypt extension */
-#undef HAVE_LIBMCRYPT
diff --git a/ext/mcrypt/config.m4 b/ext/mcrypt/config.m4
deleted file mode 100644
index 530e118a04..0000000000
--- a/ext/mcrypt/config.m4
+++ /dev/null
@@ -1,31 +0,0 @@
-dnl $Id$
-dnl config.m4 for extension mcrypt
-dnl don't forget to call PHP_EXTENSION(mcrypt)
-
-AC_MSG_CHECKING(for mcrypt support)
-AC_ARG_WITH(mcrypt,
-[ --with-mcrypt[=DIR] Include mcrypt support. DIR is the mcrypt
- install directory.],
-[
- if test "$withval" != "no"; then
- for i in /usr/local /usr $withval; do
- if test -f $i/include/mcrypt.h; then
- MCRYPT_DIR=$i
- fi
- done
- if test "$MCRYPT_DIR" = ""; then
- AC_MSG_ERROR(Please reinstall libmcrypt - I cannot find mcrypt.h)
- fi
- AC_ADD_INCLUDE($MCRYPT_DIR/include)
- AC_ADD_LIBRARY_WITH_PATH(mcrypt, $MCRYPT_DIR/lib)
-
- AC_DEFINE(HAVE_LIBMCRYPT)
-
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(mcrypt)
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c
deleted file mode 100644
index 3c7003dada..0000000000
--- a/ext/mcrypt/mcrypt.c
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <sascha@schumann.2ns.de> |
- +----------------------------------------------------------------------+
- */
-
-#include "php.h"
-
-#if HAVE_LIBMCRYPT
-
-#include "php_mcrypt.h"
-#include "fcntl.h"
-
-#define NON_FREE
-#define MCRYPT2
-#include "mcrypt.h"
-
-function_entry mcrypt_functions[] = {
- PHP_FE(mcrypt_ecb, NULL)
- PHP_FE(mcrypt_cbc, NULL)
- PHP_FE(mcrypt_cfb, NULL)
- PHP_FE(mcrypt_ofb, NULL)
- PHP_FE(mcrypt_get_cipher_name, NULL)
- PHP_FE(mcrypt_get_block_size, NULL)
- PHP_FE(mcrypt_get_key_size, NULL)
- PHP_FE(mcrypt_create_iv, NULL)
- {0},
-};
-
-static PHP_MINIT_FUNCTION(mcrypt);
-
-zend_module_entry mcrypt_module_entry = {
- "mcrypt",
- mcrypt_functions,
- PHP_MINIT(mcrypt), NULL,
- NULL, NULL,
- NULL,
- STANDARD_MODULE_PROPERTIES,
-};
-
-#if 0
-
-typedef struct mcrypt_global_struct {
- int le_h;
-} mcrypt_global_struct;
-
-static mcrypt_global_struct mcryptg;
-
-#define MCRYPTG(x) mcryptg.x
-
-#endif
-
-#define MCRYPT_ARGS2 \
- pval **cipher, **data, **key, **mode; \
- int td; \
- char *ndata; \
- size_t bsize; \
- size_t nr; \
- size_t nsize
-
-#define MCRYPT_ARGS \
- MCRYPT_ARGS2; \
- pval **iv
-
-#define MCRYPT_CONVERT \
- convert_to_long_ex(cipher); \
- convert_to_long_ex(mode); \
- convert_to_string_ex(data); \
- convert_to_string_ex(key)
-
-#define MCRYPT_SIZE \
- bsize = get_block_size((*cipher)->value.lval); \
- nr = ((*data)->value.str.len + bsize - 1) / bsize; \
- nsize = nr * bsize
-
-#define MCRYPT_CHECK_TD_CPY \
- if(td == -1) { \
- php_error(E_WARNING, MCRYPT_FAILED); \
- RETURN_FALSE; \
- } \
- ndata = ecalloc(nr, bsize); \
- memcpy(ndata, (*data)->value.str.val, (*data)->value.str.len)
-
-#define MCRYPT_CHECK_IV \
- convert_to_string_ex(iv); \
- if((*iv)->value.str.len != bsize) { \
- php_error(E_WARNING, MCRYPT_IV_WRONG_SIZE); \
- RETURN_FALSE; \
- }
-
-#define MCRYPT_ACTION(x) \
- if((*mode)->value.lval == 0) \
- mcrypt_##x(td, ndata, nsize); \
- else \
- mdecrypt_##x(td, ndata, nsize); \
- end_mcrypt_##x(td)
-
-#define MCRYPT_IV_WRONG_SIZE "The IV paramater must be as long as the blocksize"
-#define MCRYPT_FAILED "mcrypt initialization failed"
-
-#define MCRYPT_ENTRY(a) REGISTER_LONG_CONSTANT("MCRYPT_" #a, a, CONST_PERSISTENT)
-
-static PHP_MINIT_FUNCTION(mcrypt)
-{
- /* modes for mcrypt_??? routines */
- REGISTER_LONG_CONSTANT("MCRYPT_ENCRYPT", 0, CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("MCRYPT_DECRYPT", 1, CONST_PERSISTENT);
-
- /* sources for mcrypt_create_iv */
- REGISTER_LONG_CONSTANT("MCRYPT_DEV_RANDOM", 0, CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("MCRYPT_DEV_URANDOM", 1, CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("MCRYPT_RAND", 2, CONST_PERSISTENT);
-
- /* ciphers */
- MCRYPT_ENTRY(BLOWFISH);
- MCRYPT_ENTRY(DES);
- MCRYPT_ENTRY(TripleDES);
- MCRYPT_ENTRY(ThreeWAY);
- MCRYPT_ENTRY(GOST);
-#ifdef CRYPT
- MCRYPT_ENTRY(CRYPT);
-#endif
-#ifdef DES_COMPAT
- MCRYPT_ENTRY(DES_COMPAT);
-#endif
- MCRYPT_ENTRY(SAFER64);
- MCRYPT_ENTRY(SAFER128);
- MCRYPT_ENTRY(CAST128);
- MCRYPT_ENTRY(TEAN);
- MCRYPT_ENTRY(RC2);
-#ifdef TWOFISH
- MCRYPT_ENTRY(TWOFISH);
-#elif defined(TWOFISH128)
- MCRYPT_ENTRY(TWOFISH128);
- MCRYPT_ENTRY(TWOFISH192);
- MCRYPT_ENTRY(TWOFISH256);
-#endif
-#ifdef RC6
- MCRYPT_ENTRY(RC6);
-#endif
-#ifdef IDEA
- MCRYPT_ENTRY(IDEA);
-#endif
-
- return SUCCESS;
-}
-
-typedef enum {
- RANDOM = 0,
- URANDOM,
- RAND
-} iv_source;
-
-/* proto mcrypt_create_iv(int size, int source)
- create an initializing vector (IV) */
-PHP_FUNCTION(mcrypt_create_iv)
-{
- pval **size, **psource;
- char *iv;
- iv_source source;
- int i;
- int n = 0;
-
- if(ARG_COUNT(ht) != 2 || getParametersEx(2, &size, &psource) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long_ex(size);
- convert_to_long_ex(psource);
-
- source = (*psource)->value.lval;
- i = (*size)->value.lval;
-
- if(i <= 0) {
- php_error(E_WARNING, "illegal size input parameter");
- RETURN_FALSE;
- }
-
- iv = ecalloc(i, 1);
-
- if(source == RANDOM || source == URANDOM) {
- int fd;
-
- fd = open(source == RANDOM ? "/dev/random" : "/dev/urandom",
- O_RDONLY);
- if(fd < 0) {
- efree(iv);
- php_error(E_WARNING, "cannot open source device");
- RETURN_FALSE;
- }
- n = read(fd, iv, i);
- close(fd);
- } else {
- while(i) {
- iv[--i] = 255.0 * rand() / RAND_MAX;
- }
- n = (*size)->value.lval;
- }
- RETURN_STRINGL(iv, n, 0);
-}
-
-/* proto mcrypt_get_cipher_name(int cipher)
- get the name of cipher */
-PHP_FUNCTION(mcrypt_get_cipher_name)
-{
- pval **cipher;
- char *str, *nstr;
-
- if(ARG_COUNT(ht) != 1 || getParametersEx(1, &cipher) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long_ex(cipher);
-
- str = get_algorithms_name((*cipher)->value.lval);
- nstr = estrdup(str);
- free(str);
-
- RETURN_STRING(nstr, 0);
-}
-
-/* proto mcrypt_get_key_size(int cipher)
- get the key size of cipher */
-PHP_FUNCTION(mcrypt_get_key_size)
-{
- pval **cipher;
-
- if(ARG_COUNT(ht) != 1 || getParametersEx(1, &cipher) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long_ex(cipher);
-
- RETURN_LONG(get_key_size((*cipher)->value.lval));
-}
-
-/* proto mcrypt_get_block_size(int cipher)
- get the block size of cipher */
-PHP_FUNCTION(mcrypt_get_block_size)
-{
- pval **cipher;
-
- if(ARG_COUNT(ht) != 1 || getParametersEx(1, &cipher) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long_ex(cipher);
-
- RETURN_LONG(get_block_size((*cipher)->value.lval));
-}
-
-/* proto mcrypt_ofb(int cipher, string key, string data, int mode, string iv)
- OFB crypt/decrypt data using key key with cipher cipher starting with iv */
-PHP_FUNCTION(mcrypt_ofb)
-{
- MCRYPT_ARGS;
-
- if(ARG_COUNT(ht) != 5 ||
- getParametersEx(5, &cipher, &key, &data, &mode, &iv) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- MCRYPT_CONVERT;
- MCRYPT_SIZE;
- MCRYPT_CHECK_IV;
-
- td = init_mcrypt_ofb((*cipher)->value.lval, (*key)->value.str.val, (*key)->value.str.len, (*iv)->value.str.val);
- MCRYPT_CHECK_TD_CPY;
- MCRYPT_ACTION(ofb);
-
- RETURN_STRINGL(ndata, nsize, 0);
-}
-
-/* proto mcrypt_cfb(int cipher, string key, string data, int mode, string iv)
- CFB crypt/decrypt data using key key with cipher cipher starting with iv */
-PHP_FUNCTION(mcrypt_cfb)
-{
- MCRYPT_ARGS;
-
- if(ARG_COUNT(ht) != 5 ||
- getParametersEx(5, &cipher, &key, &data, &mode, &iv) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- MCRYPT_CONVERT;
- MCRYPT_SIZE;
- MCRYPT_CHECK_IV;
-
- td = init_mcrypt_cfb((*cipher)->value.lval, (*key)->value.str.val, (*key)->value.str.len, (*iv)->value.str.val);
- MCRYPT_CHECK_TD_CPY;
- MCRYPT_ACTION(cfb);
-
- RETURN_STRINGL(ndata, nsize, 0);
-}
-
-
-/* proto mcrypt_cbc(int cipher, string key, string data, int mode [,string iv])
- CBC crypt/decrypt data using key key with cipher cipher using optional iv */
-PHP_FUNCTION(mcrypt_cbc)
-{
- MCRYPT_ARGS;
- int ac = ARG_COUNT(ht);
-
- if(ac < 4 || ac > 5 ||
- getParametersEx(ac, &cipher, &key, &data, &mode, &iv) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- MCRYPT_CONVERT;
- MCRYPT_SIZE;
- if(ac > 4) {
- MCRYPT_CHECK_IV;
- }
-
- td = init_mcrypt_cbc((*cipher)->value.lval, (*key)->value.str.val, (*key)->value.str.len);
- MCRYPT_CHECK_TD_CPY;
-
- if(ac > 4) {
- mcrypt(td, (*iv)->value.str.val);
- }
-
- MCRYPT_ACTION(cbc);
-
- RETURN_STRINGL(ndata, nsize, 0);
-}
-
-/* proto mcrypt_ecb(int cipher, string key, string data, int mode)
- ECB crypt/decrypt data using key key with cipher cipher */
-PHP_FUNCTION(mcrypt_ecb)
-{
- MCRYPT_ARGS2;
-
- if(ARG_COUNT(ht) != 4 ||
- getParametersEx(4, &cipher, &key, &data, &mode) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- MCRYPT_CONVERT;
- MCRYPT_SIZE;
-
- td = init_mcrypt_ecb((*cipher)->value.lval, (*key)->value.str.val, (*key)->value.str.len);
- MCRYPT_CHECK_TD_CPY;
- MCRYPT_ACTION(ecb);
-
- RETURN_STRINGL(ndata, nsize, 0);
-}
-
-#endif
diff --git a/ext/mcrypt/php_mcrypt.h b/ext/mcrypt/php_mcrypt.h
deleted file mode 100644
index fbeda253c3..0000000000
--- a/ext/mcrypt/php_mcrypt.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef PHP_MCRYPT_H
-#define PHP_MCRYPT_H
-
-#if HAVE_LIBMCRYPT
-
-#if PHP_API_VERSION < 19990421
-#define zend_module_entry php3_module_entry
-#include "modules.h"
-#include "internal_functions.h"
-#endif
-
-extern zend_module_entry mcrypt_module_entry;
-#define mcrypt_module_ptr &mcrypt_module_entry
-
-PHP_FUNCTION(mcrypt_ecb);
-PHP_FUNCTION(mcrypt_cbc);
-PHP_FUNCTION(mcrypt_cfb);
-PHP_FUNCTION(mcrypt_ofb);
-PHP_FUNCTION(mcrypt_get_cipher_name);
-PHP_FUNCTION(mcrypt_get_block_size);
-PHP_FUNCTION(mcrypt_get_key_size);
-PHP_FUNCTION(mcrypt_create_iv);
-
-#else
-#define mcrypt_module_ptr NULL
-#endif
-
-#define phpext_mcrypt_ptr mcrypt_module_ptr
-
-#endif
diff --git a/ext/mcrypt/setup.stub b/ext/mcrypt/setup.stub
deleted file mode 100644
index 76d795b16e..0000000000
--- a/ext/mcrypt/setup.stub
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-mcrypt 'mcrypt support?' yesnodir no \
-' Whether to build the mcrypt extension.'
-
diff --git a/ext/mhash/Makefile.am b/ext/mhash/Makefile.am
deleted file mode 100644
index 18be9497da..0000000000
--- a/ext/mhash/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_mhash.a
-libphpext_mhash_a_SOURCES=mhash.c
-
diff --git a/ext/mhash/config.h.stub b/ext/mhash/config.h.stub
deleted file mode 100644
index 9785cc2bec..0000000000
--- a/ext/mhash/config.h.stub
+++ /dev/null
@@ -1,2 +0,0 @@
-/* define if you want to use the mhash extension */
-#undef HAVE_LIBMHASH
diff --git a/ext/mhash/config.m4 b/ext/mhash/config.m4
deleted file mode 100644
index 34077138d5..0000000000
--- a/ext/mhash/config.m4
+++ /dev/null
@@ -1,31 +0,0 @@
-dnl $Id$
-dnl config.m4 for extension mhash
-dnl don't forget to call PHP_EXTENSION(mhash)
-
-AC_MSG_CHECKING(for mhash support)
-AC_ARG_WITH(mhash,
-[ --with-mhash[=DIR] Include mhash support. DIR is the mhash
- install directory.],
-[
- if test "$withval" != "no"; then
- for i in /usr/local /usr /opt/mhash $withval; do
- if test -f $i/include/mhash.h; then
- MHASH_DIR=$i
- fi
- done
- if test "$MHASH_DIR" = ""; then
- AC_MSG_ERROR(Please reinstall libmhash - I cannot find mhash.h)
- fi
- AC_ADD_INCLUDE($MHASH_DIR/include)
- AC_ADD_LIBRARY_WITH_PATH(mhash, $MHASH_DIR/lib)
-
- AC_DEFINE(HAVE_LIBMHASH)
-
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(mhash)
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
diff --git a/ext/mhash/mhash.c b/ext/mhash/mhash.c
deleted file mode 100644
index 280c7d9758..0000000000
--- a/ext/mhash/mhash.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <sascha@schumann.2ns.de> |
- +----------------------------------------------------------------------+
- */
-
-#include "php.h"
-
-#if HAVE_LIBMHASH
-
-#include "php_mhash.h"
-
-#include "mhash.h"
-
-function_entry mhash_functions[] = {
- PHP_FE(mhash_get_block_size, NULL)
- PHP_FE(mhash_get_hash_name, NULL)
- PHP_FE(mhash_count, NULL)
- PHP_FE(mhash, NULL)
- {0},
-};
-
-static PHP_MINIT_FUNCTION(mhash);
-
-zend_module_entry mhash_module_entry = {
- "mhash",
- mhash_functions,
- PHP_MINIT(mhash), NULL,
- NULL, NULL,
- NULL,
- STANDARD_MODULE_PROPERTIES,
-};
-
-#define MHASH_FAILED_MSG "mhash initialization failed"
-
-static PHP_MINIT_FUNCTION(mhash)
-{
- int i;
- char *name;
- char buf[128];
-
- for(i = 0; i <= mhash_count(); i++) {
- name = mhash_get_hash_name(i);
- if(name) {
- snprintf(buf, 127, "MHASH_%s", name);
- REGISTER_LONG_CONSTANT(buf, i, CONST_PERSISTENT);
- free(name);
- }
- }
-
- return SUCCESS;
-}
-
-/* proto mhash_count()
- get the number of available hashes */
-PHP_FUNCTION(mhash_count)
-{
- RETURN_LONG(mhash_count());
-}
-
-/* proto mhash_get_block_size(int hash)
- get the block size of hash */
-PHP_FUNCTION(mhash_get_block_size)
-{
- pval **hash;
-
- if(ARG_COUNT(ht) != 1 || getParametersEx(1, &hash) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long_ex(hash);
-
- RETURN_LONG(mhash_get_block_size((*hash)->value.lval));
-}
-
-/* proto mhash_get_hash_name(int hash)
- get the name of hash */
-PHP_FUNCTION(mhash_get_hash_name)
-{
- pval **hash;
- char *name;
-
- if(ARG_COUNT(ht) != 1 || getParametersEx(1, &hash) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long_ex(hash);
-
- name = mhash_get_hash_name((*hash)->value.lval);
- if(name) {
- RETVAL_STRING(name, 1);
- free(name);
- } else {
- RETVAL_FALSE;
- }
-}
-
-/* proto mhash(int hash, string data)
- hash data with hash */
-PHP_FUNCTION(mhash)
-{
- pval **hash, **data;
- MHASH td;
- int bsize;
- unsigned char *hash_data;
-
- if(ARG_COUNT(ht) != 2 || getParametersEx(2, &hash, &data) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long_ex(hash);
- convert_to_string_ex(data);
-
- bsize = mhash_get_block_size((*hash)->value.lval);
- td = mhash_init((*hash)->value.lval);
- if(td == MHASH_FAILED) {
- php_error(E_WARNING, MHASH_FAILED_MSG);
- RETURN_FALSE;
- }
-
- mhash(td, (*data)->value.str.val, (*data)->value.str.len);
-
- hash_data = (unsigned char *) mhash_end(td);
-
- RETVAL_STRINGL(hash_data, bsize, 1);
-
- free(hash_data);
-}
-
-#endif
diff --git a/ext/mhash/php_mhash.h b/ext/mhash/php_mhash.h
deleted file mode 100644
index e5341151d5..0000000000
--- a/ext/mhash/php_mhash.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef PHP_MHASH_H
-#define PHP_MHASH_H
-
-#if HAVE_LIBMHASH
-
-#if PHP_API_VERSION < 19990421
-#define zend_module_entry php3_module_entry
-#include "modules.h"
-#include "internal_functions.h"
-#endif
-
-extern zend_module_entry mhash_module_entry;
-#define mhash_module_ptr &mhash_module_entry
-
-PHP_FUNCTION(mhash_get_block_size);
-PHP_FUNCTION(mhash_get_hash_name);
-PHP_FUNCTION(mhash_count);
-PHP_FUNCTION(mhash);
-
-#else
-#define mhash_module_ptr NULL
-#endif
-
-#define phpext_mhash_ptr mhash_module_ptr
-
-#endif
diff --git a/ext/mhash/setup.stub b/ext/mhash/setup.stub
deleted file mode 100644
index 1af26d8434..0000000000
--- a/ext/mhash/setup.stub
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-mhash 'mhash support?' yesnodir no \
-' Whether to build the mhash extension.'
-
diff --git a/ext/msql/Makefile.am b/ext/msql/Makefile.am
deleted file mode 100644
index 8fe82aaf76..0000000000
--- a/ext/msql/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_msql.a
-libphpext_msql_a_SOURCES=php_msql.c
-
diff --git a/ext/msql/config.h.stub b/ext/msql/config.h.stub
deleted file mode 100644
index 64a3517ae2..0000000000
--- a/ext/msql/config.h.stub
+++ /dev/null
@@ -1,2 +0,0 @@
-#define HAVE_MSQL 0
-#define MSQL1 0
diff --git a/ext/msql/config.m4 b/ext/msql/config.m4
deleted file mode 100644
index 3ed38f3e46..0000000000
--- a/ext/msql/config.m4
+++ /dev/null
@@ -1,46 +0,0 @@
-dnl $Id$
-
-dnl
-dnl Test mSQL version by checking if msql.h has "IDX_TYPE" defined.
-dnl
-AC_DEFUN(AC_MSQL_VERSION,[
- AC_MSG_CHECKING([mSQL version])
- ac_php_oldcflags=$CFLAGS
- CFLAGS="$INCLUDES $CFLAGS"
- AC_TRY_COMPILE([#include <sys/types.h>
-#include "msql.h"],[int i = IDX_TYPE],[
- AC_DEFINE(MSQL1,0)
- MSQL_VERSION="2.0 or newer"
- ],[
- AC_DEFINE(MSQL1,1)
- MSQL_VERSION="1.0"
- ])
- CFLAGS=$ac_php_oldcflags
- AC_MSG_RESULT($MSQL_VERSION)
-])
-
-AC_MSG_CHECKING(for mSQL support)
-AC_ARG_WITH(msql,
-[ --with-msql[=DIR] Include mSQL support. DIR is the mSQL base
- install directory, defaults to /usr/local/Hughes.],
-[
- if test "$withval" != "no"; then
- if test "$withval" = "yes"; then
- MSQL_INCDIR=/usr/local/Hughes/include
- MSQL_LIBDIR=/usr/local/Hughes/lib
- else
- MSQL_INCDIR=$withval/include
- MSQL_LIBDIR=$withval/lib
- fi
- AC_ADD_LIBRARY_WITH_PATH(msql, $MSQL_LIBDIR)
- AC_ADD_INCLUDE($MSQL_INCDIR)
- AC_DEFINE(HAVE_MSQL)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(msql)
- AC_MSQL_VERSION
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
diff --git a/ext/msql/php_msql.c b/ext/msql/php_msql.c
deleted file mode 100644
index d374624458..0000000000
--- a/ext/msql/php_msql.c
+++ /dev/null
@@ -1,1312 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-#if COMPILE_DL
-#include "dl/phpdl.h"
-#include "functions/dl.h"
-#endif
-#include "php_msql.h"
-#include "ext/standard/php3_standard.h"
-#include "php_globals.h"
-
-#if HAVE_MSQL
-
-#define OS_UNIX 1
-
-#if defined(WIN32) && defined(MSQL1)
-#include <msql1.h>
-#else
-#include <msql.h>
-#endif
-
-static php_msql_globals msql_globals;
-
-#define MSQL_ASSOC 1<<0
-#define MSQL_NUM 1<<1
-#define MSQL_BOTH (MSQL_ASSOC|MSQL_NUM)
-
-
-function_entry msql_functions[] = {
- PHP_FE(msql_connect, NULL)
- PHP_FE(msql_pconnect, NULL)
- PHP_FE(msql_close, NULL)
- PHP_FE(msql_select_db, NULL)
- PHP_FE(msql_create_db, NULL)
- PHP_FE(msql_drop_db, NULL)
- PHP_FE(msql_query, NULL)
- PHP_FE(msql_db_query, NULL)
- PHP_FE(msql_list_dbs, NULL)
- PHP_FE(msql_list_tables, NULL)
- PHP_FE(msql_list_fields, NULL)
- PHP_FE(msql_error, NULL)
- PHP_FE(msql_result, NULL)
- PHP_FE(msql_num_rows, NULL)
- PHP_FE(msql_num_fields, NULL)
- PHP_FE(msql_fetch_row, NULL)
- PHP_FE(msql_fetch_array, NULL)
- PHP_FE(msql_fetch_object, NULL)
- PHP_FE(msql_data_seek, NULL)
- PHP_FE(msql_fetch_field, NULL)
- PHP_FE(msql_field_seek, NULL)
- PHP_FE(msql_free_result, NULL)
- PHP_FE(msql_field_name, NULL)
- PHP_FE(msql_field_table, NULL)
- PHP_FE(msql_field_len, NULL)
- PHP_FE(msql_field_type, NULL)
- PHP_FE(msql_field_flags, NULL)
-
- PHP_FALIAS(msql_fieldname, msql_field_name, NULL)
- PHP_FALIAS(msql_fieldtable, msql_field_table, NULL)
- PHP_FALIAS(msql_fieldlen, msql_field_len, NULL)
- PHP_FALIAS(msql_fieldtype, msql_field_type, NULL)
- PHP_FALIAS(msql_fieldflags, msql_field_flags, NULL)
-
- PHP_FALIAS(msql_regcase, sql_regcase, NULL)
-
- PHP_FALIAS(msql_affected_rows, msql_affected_rows, NULL)
-
- /* for downwards compatability */
- PHP_FALIAS(msql, msql_db_query, NULL)
- PHP_FALIAS(msql_selectdb, msql_select_db, NULL)
- PHP_FALIAS(msql_createdb, msql_create_db, NULL)
- PHP_FALIAS(msql_dropdb, msql_drop_db, NULL)
- PHP_FALIAS(msql_freeresult, msql_free_result, NULL)
- PHP_FALIAS(msql_numfields, msql_num_fields, NULL)
- PHP_FALIAS(msql_numrows, msql_num_rows, NULL)
- PHP_FALIAS(msql_listdbs, msql_list_dbs, NULL)
- PHP_FALIAS(msql_listtables, msql_list_tables, NULL)
- PHP_FALIAS(msql_listfields, msql_list_fields, NULL)
- PHP_FALIAS(msql_dbname, msql_result, NULL)
- PHP_FALIAS(msql_tablename, msql_result, NULL)
- {NULL, NULL, NULL}
-};
-
-
-zend_module_entry msql_module_entry = {
- "mSQL", msql_functions, PHP_MINIT(msql), NULL, PHP_RINIT(msql), NULL,
- PHP_MINFO(msql), STANDARD_MODULE_PROPERTIES
-};
-
-
-#if COMPILE_DL
-DLEXPORT zend_module_entry *get_module(void) { return &msql_module_entry; }
-#endif
-
-typedef struct {
- m_result *result;
- int af_rows;
-} m_query;
-
-#define MSQL_GET_QUERY(res) \
- ZEND_FETCH_RESOURCE(msql_query, m_query *, res, -1, "mSQL result", msql_globals.le_query); \
- msql_result = msql_query->result
-
-static void _delete_query(void *arg)
-{
- m_query *query = (m_query *) arg;
-
- if(query->result) msqlFreeResult(query->result);
- efree(arg);
-}
-
-static m_query *php_msql_query_wrapper(m_result *res, int af_rows)
-{
- m_query *query = (m_query *) emalloc(sizeof(m_query));
-
- query->result = res;
- query->af_rows = af_rows;
-
- return query;
-}
-
-static void _close_msql_link(int link)
-{
- msqlClose(link);
- msql_globals.num_links--;
-}
-
-
-static void _close_msql_plink(int link)
-{
- msqlClose(link);
- msql_globals.num_persistent--;
- msql_globals.num_links--;
-}
-
-DLEXPORT PHP_MINIT_FUNCTION(msql)
-{
- if (cfg_get_long("msql.allow_persistent",&msql_globals.allow_persistent)==FAILURE) {
- msql_globals.allow_persistent=1;
- }
- if (cfg_get_long("msql.max_persistent",&msql_globals.max_persistent)==FAILURE) {
- msql_globals.max_persistent=-1;
- }
- if (cfg_get_long("msql.max_links",&msql_globals.max_links)==FAILURE) {
- msql_globals.max_links=-1;
- }
- msql_globals.num_persistent=0;
- msql_globals.le_query = register_list_destructors(_delete_query,NULL);
- msql_globals.le_link = register_list_destructors(_close_msql_link,NULL);
- msql_globals.le_plink = register_list_destructors(NULL,_close_msql_plink);
-
- msql_module_entry.type = type;
-
- REGISTER_LONG_CONSTANT("MSQL_ASSOC", MSQL_ASSOC, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("MSQL_NUM", MSQL_NUM, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("MSQL_BOTH", MSQL_BOTH, CONST_CS | CONST_PERSISTENT);
-
- return SUCCESS;
-}
-
-DLEXPORT PHP_RINIT_FUNCTION(msql)
-{
- msql_globals.default_link=-1;
- msql_globals.num_links = msql_globals.num_persistent;
- msqlErrMsg[0]=0;
- return SUCCESS;
-}
-
-DLEXPORT PHP_MINFO_FUNCTION(msql)
-{
- char maxp[16],maxl[16];
-
- if (msql_globals.max_persistent==-1) {
- strcpy(maxp,"Unlimited");
- } else {
- snprintf(maxp,15,"%ld",msql_globals.max_persistent);
- maxp[15]=0;
- }
- if (msql_globals.max_links==-1) {
- strcpy(maxl,"Unlimited");
- } else {
- snprintf(maxl,15,"%ld",msql_globals.max_links);
- maxl[15]=0;
- }
- php_printf("<table>"
- "<tr><td>Allow persistent links:</td><td>%s</td></tr>\n"
- "<tr><td>Persistent links:</td><td>%d/%s</td></tr>\n"
- "<tr><td>Total links:</td><td>%d/%s</td></tr>\n"
- "</table>\n",
- (msql_globals.allow_persistent?"Yes":"No"),
- msql_globals.num_persistent,maxp,
- msql_globals.num_links,maxl);
-}
-
-
-static void php_msql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
-{
- char *host;
- char *hashed_details;
- int hashed_details_length;
- int msql;
-
- switch(ARG_COUNT(ht)) {
- case 0: /* defaults */
- host=NULL;
- hashed_details=estrndup("msql_",5);
- hashed_details_length=4+1;
- break;
- case 1: {
- pval *yyhost;
-
- if (getParameters(ht, 1, &yyhost) == FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(yyhost);
- host = yyhost->value.str.val;
- hashed_details_length = yyhost->value.str.len+4+1;
- hashed_details = emalloc(hashed_details_length+1);
- sprintf(hashed_details,"msql_%s",yyhost->value.str.val); /* SAFE */
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- if (!msql_globals.allow_persistent) {
- persistent=0;
- }
- if (persistent) {
- list_entry *le;
-
- if (msql_globals.max_links!=-1 && msql_globals.num_links>=msql_globals.max_links) {
- php_error(E_WARNING,"mSQL: Too many open links (%d)",msql_globals.num_links);
- efree(hashed_details);
- RETURN_FALSE;
- }
- if (msql_globals.max_persistent!=-1 && msql_globals.num_persistent>=msql_globals.max_persistent) {
- php_error(E_WARNING,"mSQL: Too many open persistent links (%d)",msql_globals.num_persistent);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- /* try to find if we already have this link in our persistent list */
- if (zend_hash_find(plist, hashed_details, hashed_details_length+1, (void **) &le)==FAILURE) { /* we don't */
- list_entry new_le;
-
- /* create the link */
- if ((msql=msqlConnect(host))==-1) {
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- /* hash it up */
- new_le.type = msql_globals.le_plink;
- new_le.ptr = (void *) msql;
- if (zend_hash_update(plist, hashed_details, hashed_details_length+1, (void *) &new_le, sizeof(list_entry), NULL)==FAILURE) {
- efree(hashed_details);
- RETURN_FALSE;
- }
- msql_globals.num_persistent++;
- msql_globals.num_links++;
- } else { /* we do */
- if (le->type != msql_globals.le_plink) {
- efree(hashed_details);
- RETURN_FALSE;
- }
-#if 0
- /* ensure that the link did not die */
- /* still have to find a way to do this nicely with mSQL */
- if (msql_stat(le->ptr)==NULL) { /* the link died */
- if (msql_connect(le->ptr,host,user,passwd)==NULL) {
- php_error(E_WARNING,"mSQL link lost, unable to reconnect");
- zend_hash_del(plist,hashed_details,hashed_details_length+1);
- efree(hashed_details);
- RETURN_FALSE;
- }
- }
-#endif
- msql = (int) le->ptr;
- }
- ZEND_REGISTER_RESOURCE(return_value, (void *) msql, msql_globals.le_plink);
- } else {
- list_entry *index_ptr,new_index_ptr;
-
- /* first we check the hash for the hashed_details key. if it exists,
- * it should point us to the right offset where the actual msql link sits.
- * if it doesn't, open a new msql link, add it to the resource list,
- * and add a pointer to it with hashed_details as the key.
- */
- if (zend_hash_find(list,hashed_details,hashed_details_length+1,(void **) &index_ptr)==SUCCESS) {
- int type,link;
- void *ptr;
-
- if (index_ptr->type != le_index_ptr) {
- RETURN_FALSE;
- }
- link = (int) index_ptr->ptr;
- ptr = zend_list_find(link,&type); /* check if the link is still there */
- if (ptr && (type==msql_globals.le_link || type==msql_globals.le_plink)) {
- return_value->value.lval = msql_globals.default_link = link;
- return_value->type = IS_LONG;
- efree(hashed_details);
- return;
- } else {
- zend_hash_del(list,hashed_details,hashed_details_length+1);
- }
- }
- if (msql_globals.max_links!=-1 && msql_globals.num_links>=msql_globals.max_links) {
- php_error(E_WARNING,"mSQL: Too many open links (%d)",msql_globals.num_links);
- efree(hashed_details);
- RETURN_FALSE;
- }
- if ((msql=msqlConnect(host))==-1) {
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- /* add it to the list */
- ZEND_REGISTER_RESOURCE(return_value, (void *) msql, msql_globals.le_plink);
-
- /* add it to the hash */
- new_index_ptr.ptr = (void *) return_value->value.lval;
- new_index_ptr.type = le_index_ptr;
- if (zend_hash_update(list,hashed_details,hashed_details_length+1,(void *) &new_index_ptr, sizeof(list_entry), NULL)==FAILURE) {
- efree(hashed_details);
- RETURN_FALSE;
- }
- msql_globals.num_links++;
- }
- efree(hashed_details);
- msql_globals.default_link=return_value->value.lval;
-}
-
-
-static int php_msql_get_default_link(INTERNAL_FUNCTION_PARAMETERS)
-{
- if (msql_globals.default_link==-1) { /* no link opened yet, implicitly open one */
- ht = 0;
- php_msql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
- }
- return msql_globals.default_link;
-}
-
-
-/* {{{ proto int msql_connect([string hostname[:port]] [, string username] [, string password])
- Open a connection to an mSQL Server */
-DLEXPORT PHP_FUNCTION(msql_connect)
-{
- php_msql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
-}
-/* }}} */
-
-
-/* {{{ proto int msql_pconnect([string hostname[:port]] [, string username] [, string password])
- Open a persistent connection to an mSQL Server */
-DLEXPORT PHP_FUNCTION(msql_pconnect)
-{
- php_msql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
-}
-/* }}} */
-
-
-/* {{{ proto int msql_close([int link_identifier])
- Close an mSQL connection */
-DLEXPORT PHP_FUNCTION(msql_close)
-{
- pval *msql_link;
- int id;
- int msql;
-
- switch (ARG_COUNT(ht)) {
- case 0:
- id = msql_globals.default_link;
- break;
- case 1:
- if (getParameters(ht, 1, &msql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- msql = (int) zend_fetch_resource_ex(msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
-
- zend_list_delete(id);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/* {{{ proto int msql_select_db(string database_name [, int link_identifier])
- Select an mSQL database */
-DLEXPORT PHP_FUNCTION(msql_select_db)
-{
- pval *db,*msql_link;
- int id;
- int msql;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &db)==FAILURE) {
- RETURN_FALSE;
- }
- id = php_msql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- break;
- case 2:
- if (getParameters(ht, 2, &db, &msql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
-
- msql = (int) zend_fetch_resource_ex(msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
-
- convert_to_string(db);
-
- if (msqlSelectDB(msql,db->value.str.val)==-1) {
- RETURN_FALSE;
- } else {
- RETURN_TRUE;
- }
-}
-/* }}} */
-
-
-/* {{{ proto int msql_create_db(string database_name [, int link_identifier])
- Create an mSQL database */
-DLEXPORT PHP_FUNCTION(msql_create_db)
-{
- pval *db,*msql_link;
- int id;
- int msql;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &db)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- id = php_msql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- break;
- case 2:
- if (getParameters(ht, 2, &db, &msql_link)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- msql = (int) zend_fetch_resource_ex(msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
-
- convert_to_string(db);
- if (msqlCreateDB(msql,db->value.str.val)<0) {
- RETURN_FALSE;
- } else {
- RETURN_TRUE;
- }
-}
-/* }}} */
-
-
-/* {{{ proto int msql_drop_db(string database_name [, int link_identifier])
- Drop (delete) an mSQL database */
-DLEXPORT PHP_FUNCTION(msql_drop_db)
-{
- pval *db,*msql_link;
- int id;
- int msql;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &db)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- id = php_msql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- break;
- case 2:
- if (getParameters(ht, 2, &db, &msql_link)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- msql = (int) zend_fetch_resource_ex(msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
-
- convert_to_string(db);
- if (msqlDropDB(msql,db->value.str.val)<0) {
- RETURN_FALSE;
- } else {
- RETURN_TRUE;
- }
-}
-/* }}} */
-
-
-/* {{{ proto int msql_query(string query [, int link_identifier])
- Send an SQL query to mSQL */
-DLEXPORT PHP_FUNCTION(msql_query)
-{
- pval *query,*msql_link;
- int id;
- int msql;
- int af_rows;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &query)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- id = msql_globals.default_link;
- break;
- case 2:
- if (getParameters(ht, 2, &query, &msql_link)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- msql = (int) zend_fetch_resource_ex(msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
-
- convert_to_string(query);
- if ((af_rows = msqlQuery(msql,query->value.str.val))==-1) {
- RETURN_FALSE;
- }
- ZEND_REGISTER_RESOURCE(return_value, php_msql_query_wrapper(msqlStoreResult(), af_rows), msql_globals.le_query);
-}
-/* }}} */
-
-
-/* {{{ proto int msql_db_query(string database_name, string query [, int link_identifier])
- Send an SQL query to mSQL */
-DLEXPORT PHP_FUNCTION(msql_db_query)
-{
- pval *db,*query,*msql_link;
- int id;
- int msql;
- int af_rows;
-
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &db, &query)==FAILURE) {
- RETURN_FALSE;
- }
- id = php_msql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- break;
- case 3:
- if (getParameters(ht, 3, &db, &query, &msql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- msql = (int) zend_fetch_resource_ex(msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
-
- convert_to_string(db);
- if (msqlSelectDB(msql,db->value.str.val)==-1) {
- RETURN_FALSE;
- }
-
- convert_to_string(query);
- if ((af_rows = msqlQuery(msql,query->value.str.val))==-1) {
- RETURN_FALSE;
- }
- ZEND_REGISTER_RESOURCE(return_value, php_msql_query_wrapper(msqlStoreResult(), af_rows), msql_globals.le_query);
-}
-/* }}} */
-
-
-/* {{{ proto int msql_list_dbs([int link_identifier])
- List databases available on an mSQL server */
-DLEXPORT PHP_FUNCTION(msql_list_dbs)
-{
- pval *msql_link;
- int id;
- int msql;
- m_result *msql_result;
-
- switch(ARG_COUNT(ht)) {
- case 0:
- id = php_msql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- break;
- case 1:
- if (getParameters(ht, 1, &msql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- msql = (int) zend_fetch_resource_ex(msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
-
- if ((msql_result=msqlListDBs(msql))==NULL) {
- php_error(E_WARNING,"Unable to save mSQL query result");
- RETURN_FALSE;
- }
- ZEND_REGISTER_RESOURCE(return_value, php_msql_query_wrapper(msql_result, 0), msql_globals.le_query);
-}
-/* }}} */
-
-
-/* {{{ proto int msql_list_tables(string database_name [, int link_identifier])
- List tables in an mSQL database */
-DLEXPORT PHP_FUNCTION(msql_list_tables)
-{
- pval *db,*msql_link;
- int id;
- int msql;
- m_result *msql_result;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &db)==FAILURE) {
- RETURN_FALSE;
- }
- id = php_msql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- break;
- case 2:
- if (getParameters(ht, 2, &db, &msql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- msql = (int) zend_fetch_resource_ex(msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
-
- convert_to_string(db);
- if (msqlSelectDB(msql,db->value.str.val)==-1) {
- RETURN_FALSE;
- }
- if ((msql_result=msqlListTables(msql))==NULL) {
- php_error(E_WARNING,"Unable to save mSQL query result");
- RETURN_FALSE;
- }
- ZEND_REGISTER_RESOURCE(return_value, php_msql_query_wrapper(msql_result, 0), msql_globals.le_query);
-}
-/* }}} */
-
-
-/* {{{ proto int msql_list_fields(string database_name, string table_name [, int link_identifier])
- List mSQL result fields */
-DLEXPORT PHP_FUNCTION(msql_list_fields)
-{
- pval *db,*table,*msql_link;
- int id;
- int msql;
- m_result *msql_result;
-
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &db, &table)==FAILURE) {
- RETURN_FALSE;
- }
- id = php_msql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- break;
- case 3:
- if (getParameters(ht, 3, &db, &table, &msql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- msql = (int) zend_fetch_resource_ex(msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
-
- convert_to_string(db);
- if (msqlSelectDB(msql,db->value.str.val)==-1) {
- RETURN_FALSE;
- }
- convert_to_string(table);
- if ((msql_result=msqlListFields(msql,table->value.str.val))==NULL) {
- php_error(E_WARNING,"Unable to save mSQL query result");
- RETURN_FALSE;
- }
- ZEND_REGISTER_RESOURCE(return_value, php_msql_query_wrapper(msql_result, 0), msql_globals.le_query);
-}
-/* }}} */
-
-
-/* {{{ proto string msql_error([int link_identifier])
- Returns the text of the error message from previous mSQL operation */
-PHP_FUNCTION(msql_error)
-{
- if (ARG_COUNT(ht)) {
- WRONG_PARAM_COUNT;
- }
- RETURN_STRING(msqlErrMsg,1);
-}
-/* }}} */
-
-/* {{{ proto int msql_result(int query, int row [, mixed field])
- Get result data */
-DLEXPORT PHP_FUNCTION(msql_result)
-{
- pval *result, *row, *field=NULL;
- m_result *msql_result;
- m_query *msql_query;
- m_row sql_row;
- int field_offset=0;
- PLS_FETCH();
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &result, &row)==FAILURE) {
- RETURN_FALSE;
- }
- break;
- case 3:
- if (getParameters(ht, 3, &result, &row, &field)==FAILURE) {
- RETURN_FALSE;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- MSQL_GET_QUERY(result);
-
- convert_to_long(row);
- if (row->value.lval<0 || row->value.lval>=msqlNumRows(msql_result)) {
- php_error(E_WARNING,"Unable to jump to row %d on mSQL query index %d",row->value.lval,result->value.lval);
- RETURN_FALSE;
- }
- msqlDataSeek(msql_result,row->value.lval);
- if ((sql_row=msqlFetchRow(msql_result))==NULL) { /* shouldn't happen? */
- RETURN_FALSE;
- }
-
- if (field) {
- switch(field->type) {
- case IS_STRING: {
- int i=0;
- m_field *tmp_field;
- char *table_name,*field_name,*tmp;
-
- if ((tmp=strchr(field->value.str.val,'.'))) {
- *tmp = 0;
- table_name = estrdup(field->value.str.val);
- field_name = estrdup(tmp+1);
- } else {
- table_name = NULL;
- field_name = estrndup(field->value.str.val,field->value.str.len);
- }
- msqlFieldSeek(msql_result,0);
- while ((tmp_field=msqlFetchField(msql_result))) {
- if ((!table_name || !strcasecmp(tmp_field->table,table_name)) && !strcasecmp(tmp_field->name,field_name)) {
- field_offset = i;
- break;
- }
- i++;
- }
- if (!tmp_field) { /* no match found */
- php_error(E_WARNING,"%s%s%s not found in mSQL query index %d",
- (table_name?table_name:""), (table_name?".":""), field_name, result->value.lval);
- efree(field_name);
- if (table_name) {
- efree(table_name);
- }
- RETURN_FALSE;
- }
- efree(field_name);
- if (table_name) {
- efree(table_name);
- }
- }
- break;
- default:
- convert_to_long(field);
- field_offset = field->value.lval;
- if (field_offset<0 || field_offset>=msqlNumFields(msql_result)) {
- php_error(E_WARNING,"Bad column offset specified");
- RETURN_FALSE;
- }
- break;
- }
- }
-
- if (sql_row[field_offset]) {
- if (PG(magic_quotes_runtime)) {
- return_value->value.str.val = php_addslashes(sql_row[field_offset],0,&return_value->value.str.len,0);
- } else {
- return_value->value.str.len = (sql_row[field_offset]?strlen(sql_row[field_offset]):0);
- return_value->value.str.val = (char *) safe_estrndup(sql_row[field_offset],return_value->value.str.len);
- }
- } else {
- var_reset(return_value);
- }
-
- return_value->type = IS_STRING;
-}
-/* }}} */
-
-
-/* {{{ proto int msql_num_rows(int query)
- Get number of rows in a result */
-DLEXPORT PHP_FUNCTION(msql_num_rows)
-{
- pval *result;
- m_result *msql_result;
- m_query *msql_query;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- MSQL_GET_QUERY(result);
- RETVAL_LONG(msql_result ? msqlNumRows(msql_result) : 0);
-}
-/* }}} */
-
-
-/* {{{ proto int msql_num_fields(int query)
- Get number of fields in a result */
-DLEXPORT PHP_FUNCTION(msql_num_fields)
-{
- pval *result;
- m_result *msql_result;
- m_query *msql_query;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- MSQL_GET_QUERY(result);
- RETVAL_LONG(msql_result ? msqlNumFields(msql_result) : 0);
-}
-/* }}} */
-
-
-static void php_msql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
-{
- pval *result, *arg2;
- m_result *msql_result;
- m_row msql_row;
- m_field *msql_field;
- m_query *msql_query;
- int num_fields;
- int i;
- PLS_FETCH();
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &result)==FAILURE) {
- RETURN_FALSE;
- }
- if (!result_type) {
- result_type = MSQL_BOTH;
- }
- break;
- case 2:
- if (getParameters(ht, 2, &result, &arg2)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(arg2);
- result_type = arg2->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- MSQL_GET_QUERY(result);
- if (!msql_result || (msql_row=msqlFetchRow(msql_result))==NULL) {
- RETURN_FALSE;
- }
-
- num_fields = msqlNumFields(msql_result);
-
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
-
- msqlFieldSeek(msql_result,0);
- for (msql_field=msqlFetchField(msql_result),i=0; msql_field; msql_field=msqlFetchField(msql_result),i++) {
- if (msql_row[i]) {
- char *data;
- int data_len;
- int should_copy;
-
- if (PG(magic_quotes_runtime)) {
- data = php_addslashes(msql_row[i], 0, &data_len, 0);
- should_copy = 0;
- } else {
- data = msql_row[i];
- data_len = strlen(data);
- should_copy = 1;
- }
-
- if (result_type & MSQL_NUM) {
- add_index_stringl(return_value, i, data, data_len, should_copy);
- should_copy = 1;
- }
-
- if (result_type & MSQL_ASSOC) {
- add_assoc_stringl(return_value, msql_field->name, data, data_len, should_copy);
- }
- } else {
- //add_get_index_stringl(return_value, i, empty_string, 0, (void **) &pval_ptr, 1);
- }
- }
-}
-
-
-/* {{{ proto array msql_fetch_row(int query)
- Get a result row as an enumerated array */
-DLEXPORT PHP_FUNCTION(msql_fetch_row)
-{
- php_msql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MSQL_NUM);
-}
-/* }}} */
-
-
-/* {{{ proto object msql_fetch_object(int query [, int result_type])
- Fetch a result row as an object */
-DLEXPORT PHP_FUNCTION(msql_fetch_object)
-{
- php_msql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
- if (return_value->type==IS_ARRAY) {
- return_value->type=IS_OBJECT;
- return_value->value.obj.properties = return_value->value.ht;
- return_value->value.obj.ce = &zend_standard_class_def;
- }
-}
-/* }}} */
-
-/* {{{ proto array msql_fetch_array(int query [, int result_type])
- Fetch a result row as an associative array */
-DLEXPORT PHP_FUNCTION(msql_fetch_array)
-{
- php_msql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ proto int msql_data_seek(int query, int row_number)
- Move internal result pointer */
-DLEXPORT PHP_FUNCTION(msql_data_seek)
-{
- pval *result,*offset;
- m_result *msql_result;
- m_query *msql_query;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &result, &offset)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- MSQL_GET_QUERY(result);
- convert_to_long(offset);
- if (!msql_result ||
- offset->value.lval<0 ||
- offset->value.lval>=msqlNumRows(msql_result)) {
- php_error(E_WARNING,"Offset %d is invalid for mSQL query index %d",offset->value.lval,result->value.lval);
- RETURN_FALSE;
- }
- msqlDataSeek(msql_result,offset->value.lval);
- RETURN_TRUE;
-}
-/* }}} */
-
-static char *php_msql_get_field_name(int field_type)
-{
- switch (field_type) {
-#if MSQL1
- case INT_TYPE:
- return "int";
- break;
- case CHAR_TYPE:
- return "char";
- break;
- case REAL_TYPE:
- return "real";
- break;
- case IDENT_TYPE:
- return "ident";
- break;
- case NULL_TYPE:
- return "null";
- break;
-#else
- case INT_TYPE:
- case UINT_TYPE:
- case CHAR_TYPE:
- case TEXT_TYPE:
- case REAL_TYPE:
- case NULL_TYPE:
- case DATE_TYPE:
- case TIME_TYPE:
- case MONEY_TYPE:
- return msqlTypeNames[field_type];
- break;
-#endif
- default:
- return "unknown";
- break;
- }
-}
-
-/* {{{ proto object msql_fetch_field(int query [, int field_offset])
- Get column information from a result and return as an object */
-DLEXPORT PHP_FUNCTION(msql_fetch_field)
-{
- pval *result, *field=NULL;
- m_result *msql_result;
- m_field *msql_field;
- m_query *msql_query;
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &result)==FAILURE) {
- RETURN_FALSE;
- }
- break;
- case 2:
- if (getParameters(ht, 2, &result, &field)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(field);
- default:
- WRONG_PARAM_COUNT;
- }
-
- MSQL_GET_QUERY(result);
-
- if (field) {
- if (field->value.lval<0 || field->value.lval>=msqlNumRows(msql_result)) {
- php_error(E_NOTICE,"mSQL: Bad field offset specified");
- RETURN_FALSE;
- }
- msqlFieldSeek(msql_result,field->value.lval);
- }
- if (!msql_result || (msql_field=msqlFetchField(msql_result))==NULL) {
- RETURN_FALSE;
- }
- if (object_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
-
- add_property_string(return_value, "name",(msql_field->name?msql_field->name:empty_string), 1);
- add_property_string(return_value, "table",(msql_field->table?msql_field->table:empty_string), 1);
- add_property_long(return_value, "not_null",IS_NOT_NULL(msql_field->flags));
-#if MSQL1
- add_property_long(return_value, "primary_key",(msql_field->flags&PRI_KEY_FLAG?1:0));
-#else
- add_property_long(return_value, "unique",(msql_field->flags&UNIQUE_FLAG?1:0));
-#endif
-
- add_property_string(return_value, "type",php_msql_get_field_name(msql_field->type), 1);
-}
-/* }}} */
-
-/* {{{ proto int msql_field_seek(int query, int field_offset)
- Set result pointer to a specific field offset */
-DLEXPORT PHP_FUNCTION(msql_field_seek)
-{
- pval *result, *offset;
- m_result *msql_result;
- m_query *msql_query;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &result, &offset)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- MSQL_GET_QUERY(result);
- convert_to_long(offset);
- if(!msql_result) {
- RETURN_FALSE;
- }
- if (offset->value.lval<0 || offset->value.lval>=msqlNumFields(msql_result)) {
- php_error(E_WARNING,"Field %d is invalid for mSQL query index %d",
- offset->value.lval,result->value.lval);
- RETURN_FALSE;
- }
- msqlFieldSeek(msql_result,offset->value.lval);
- RETURN_TRUE;
-}
-/* }}} */
-
-#define PHP3_MSQL_FIELD_NAME 1
-#define PHP3_MSQL_FIELD_TABLE 2
-#define PHP3_MSQL_FIELD_LEN 3
-#define PHP3_MSQL_FIELD_TYPE 4
-#define PHP3_MSQL_FIELD_FLAGS 5
-
-static void php_msql_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
-{
- pval *result, *field;
- m_result *msql_result;
- m_field *msql_field;
- m_query *msql_query;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &result, &field)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- MSQL_GET_QUERY(result);
- if(!msql_result) {
- RETURN_FALSE;
- }
- convert_to_long(field);
- if (field->value.lval<0 || field->value.lval>=msqlNumFields(msql_result)) {
- php_error(E_WARNING,"Field %d is invalid for mSQL query index %d",field->value.lval,result->value.lval);
- RETURN_FALSE;
- }
- msqlFieldSeek(msql_result,field->value.lval);
- if ((msql_field=msqlFetchField(msql_result))==NULL) {
- RETURN_FALSE;
- }
-
- switch (entry_type) {
- case PHP3_MSQL_FIELD_NAME:
- return_value->value.str.len = strlen(msql_field->name);
- return_value->value.str.val = estrndup(msql_field->name,return_value->value.str.len);
- return_value->type = IS_STRING;
- break;
- case PHP3_MSQL_FIELD_TABLE:
- return_value->value.str.len = strlen(msql_field->table);
- return_value->value.str.val = estrndup(msql_field->table,return_value->value.str.len);
- return_value->type = IS_STRING;
- break;
- case PHP3_MSQL_FIELD_LEN:
- return_value->value.lval = msql_field->length;
- return_value->type = IS_LONG;
- break;
- case PHP3_MSQL_FIELD_TYPE:
- return_value->value.str.val = estrdup(php_msql_get_field_name(msql_field->type));
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
- break;
- case PHP3_MSQL_FIELD_FLAGS:
-#if MSQL1
- if ((msql_field->flags&NOT_NULL_FLAG) && (msql_field->flags&PRI_KEY_FLAG)) {
- return_value->value.str.val = estrndup("primary key not null",20);
- return_value->value.str.len = 20;
- return_value->type = IS_STRING;
- } else if (msql_field->flags&NOT_NULL_FLAG) {
- return_value->value.str.val = estrndup("not null",8);
- return_value->value.str.len = 8;
- return_value->type = IS_STRING;
- } else if (msql_field->flags&PRI_KEY_FLAG) {
- return_value->value.str.val = estrndup("primary key",11);
- return_value->value.str.len = 11;
- return_value->type = IS_STRING;
- } else {
- var_reset(return_value);
- }
-#else
- if ((msql_field->flags&NOT_NULL_FLAG) && (msql_field->flags&UNIQUE_FLAG)) {
- return_value->value.str.val = estrndup("unique not null",15);
- return_value->value.str.len = 15;
- return_value->type = IS_STRING;
- } else if (msql_field->flags&NOT_NULL_FLAG) {
- return_value->value.str.val = estrndup("not null",8);
- return_value->value.str.len = 8;
- return_value->type = IS_STRING;
- } else if (msql_field->flags&UNIQUE_FLAG) {
- return_value->value.str.val = estrndup("unique",6);
- return_value->value.str.len = 6;
- return_value->type = IS_STRING;
- } else {
- var_reset(return_value);
- }
-#endif
- break;
- default:
- RETURN_FALSE;
- }
-}
-
-/* {{{ proto string msql_field_name(int query, int field_index)
- Get the name of the specified field in a result */
-DLEXPORT PHP_FUNCTION(msql_field_name)
-{
- php_msql_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_MSQL_FIELD_NAME);
-}
-/* }}} */
-
-/* {{{ proto string msql_field_table(int query, int field_offset)
- Get name of the table the specified field is in */
-DLEXPORT PHP_FUNCTION(msql_field_table)
-{
- php_msql_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_MSQL_FIELD_TABLE);
-}
-/* }}} */
-
-/* {{{ proto int msql_field_len(int query, int field_offet)
- Returns the length of the specified field */
-DLEXPORT PHP_FUNCTION(msql_field_len)
-{
- php_msql_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_MSQL_FIELD_LEN);
-}
-/* }}} */
-
-/* {{{ proto string msql_field_type(int query, int field_offset)
- Get the type of the specified field in a result */
-DLEXPORT PHP_FUNCTION(msql_field_type)
-{
- php_msql_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_MSQL_FIELD_TYPE);
-}
-/* }}} */
-
-/* {{{ proto string msql_field_flags(int query, int field_offset)
- Get the flags associated with the specified field in a result */
-DLEXPORT PHP_FUNCTION(msql_field_flags)
-{
- php_msql_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_MSQL_FIELD_FLAGS);
-}
-/* }}} */
-
-
-/* {{{ proto int msql_free_result(int query)
- Free result memory */
-DLEXPORT PHP_FUNCTION(msql_free_result)
-{
- pval *result;
- m_result *msql_result;
- m_query *msql_query;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- MSQL_GET_QUERY(result);
- zend_list_delete(result->value.lval);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int msql_affected_rows(int query)
- Return number of affected rows */
-DLEXPORT PHP_FUNCTION(msql_affected_rows)
-{
- pval *result;
- m_result *msql_result;
- m_query *msql_query;
-
- if(ARG_COUNT(ht) != 1 || getParameters(ht, 1, &result) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- MSQL_GET_QUERY(result);
- RETVAL_LONG(msql_query->af_rows);
-}
-/* }}} */
-
-#endif
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
-
diff --git a/ext/msql/php_msql.h b/ext/msql/php_msql.h
deleted file mode 100644
index 3c2b33b33b..0000000000
--- a/ext/msql/php_msql.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _PHP_MSQL_H
-#define _PHP_MSQL_H
-
-#if COMPILE_DL
-#undef HAVE_MSQL
-#define HAVE_MSQL 1
-#endif
-
-#if HAVE_MSQL
-
-extern zend_module_entry msql_module_entry;
-#define msql_module_ptr &msql_module_entry
-
-/* mSQL functions */
-DLEXPORT PHP_MINIT_FUNCTION(msql);
-DLEXPORT PHP_RINIT_FUNCTION(msql);
-DLEXPORT PHP_MSHUTDOWN_FUNCTION(msql);
-DLEXPORT PHP_MINFO_FUNCTION(msql);
-
-DLEXPORT PHP_FUNCTION(msql_connect);
-DLEXPORT PHP_FUNCTION(msql_pconnect);
-DLEXPORT PHP_FUNCTION(msql_close);
-DLEXPORT PHP_FUNCTION(msql_select_db);
-DLEXPORT PHP_FUNCTION(msql_create_db);
-DLEXPORT PHP_FUNCTION(msql_drop_db);
-DLEXPORT PHP_FUNCTION(msql_list_dbs);
-DLEXPORT PHP_FUNCTION(msql_list_tables);
-DLEXPORT PHP_FUNCTION(msql_list_fields);
-DLEXPORT PHP_FUNCTION(msql_error);
-DLEXPORT PHP_FUNCTION(msql_affected_rows);
-DLEXPORT PHP_FUNCTION(msql_query);
-DLEXPORT PHP_FUNCTION(msql_db_query);
-DLEXPORT PHP_FUNCTION(msql_result);
-DLEXPORT PHP_FUNCTION(msql_num_rows);
-DLEXPORT PHP_FUNCTION(msql_num_fields);
-DLEXPORT PHP_FUNCTION(msql_fetch_row);
-DLEXPORT PHP_FUNCTION(msql_data_seek);
-DLEXPORT PHP_FUNCTION(msql_fetch_field);
-DLEXPORT PHP_FUNCTION(msql_field_seek);
-DLEXPORT PHP_FUNCTION(msql_free_result);
-DLEXPORT PHP_FUNCTION(msql_field_name);
-DLEXPORT PHP_FUNCTION(msql_field_table);
-DLEXPORT PHP_FUNCTION(msql_field_len);
-DLEXPORT PHP_FUNCTION(msql_field_type);
-DLEXPORT PHP_FUNCTION(msql_field_flags);
-DLEXPORT PHP_FUNCTION(msql_fetch_array);
-DLEXPORT PHP_FUNCTION(msql_fetch_object);
-
-typedef struct {
- long default_link;
- long num_links,num_persistent;
- long max_links,max_persistent;
- long allow_persistent;
- int le_query;
- int le_link;
- int le_plink;
-} php_msql_globals;
-
-#else
-
-#define msql_module_ptr NULL
-
-#endif
-
-#define phpext_msql_ptr msql_module_ptr
-
-#endif /* _PHP_MSQL_H */
diff --git a/ext/msql/setup.stub b/ext/msql/setup.stub
deleted file mode 100644
index cced055d90..0000000000
--- a/ext/msql/setup.stub
+++ /dev/null
@@ -1,11 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-msql 'mSQL support?' yesnodir \
- 'no /usr/local/Hughes mSQL install' \
-' Whether to build PHP with mSQL support. PHP supports both mSQL 1.0 and\n
- mSQL 2.0. However, if you build PHP with mSQL 1.0 libraries, you will\n
- only be able to access mSQL 1.0 databases, ditto for mSQL 2.0.\n
- More info about mSQL can be found at http://www.hughes.com.au/.'
-
-
diff --git a/ext/mysql/Makefile.am b/ext/mysql/Makefile.am
deleted file mode 100644
index f035f76af9..0000000000
--- a/ext/mysql/Makefile.am
+++ /dev/null
@@ -1,15 +0,0 @@
-# $Id$
-
-phplibdir=$(libdir)/php
-
-SRC=php_mysql.c
-INCLUDES=@INCLUDES@ @MYSQL_INCLUDE@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=@MYSQL_STATIC@
-EXTRA_LIBRARIES=libphpext_mysql.a
-libphpext_mysql_a_SOURCES=$(SRC)
-phplib_LTLIBRARIES=@MYSQL_SHARED@
-EXTRA_LTLIBRARIES=mysql.la
-mysql_la_SOURCES=$(SRC)
-mysql_la_LIBADD=@MYSQL_LFLAGS@ -lmysqlclient
-mysql_la_LDFLAGS=-avoid-version -module -rpath $(phplibdir)
-EXTRA_LIBS=
diff --git a/ext/mysql/Readme_w32.txt b/ext/mysql/Readme_w32.txt
deleted file mode 100644
index 4f4e225065..0000000000
--- a/ext/mysql/Readme_w32.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-MySQL Extension for PHP 4.0 - Win32 README
-------------------------------------------
-
-In order to compile this extension, MySQL must be installed in a parrallel directory
-to that of PHP 4.0. For example, if you have PHP 4.0's source tree set up in
-C:\Projects\php4, you must have MySQL set up in C:\Projects\MySQL. The compiler
-will look for include files in C:\Projects\MySQL\include and for the library
-files in C:\Projects\MySQL\lib.
-
-You can change this by editing the project settings, but it's not recommended, since
-you will have to do it every time you obtain a new version of the PHP 4.0 source tree.
-
-
-[4/6/1999 zeev@zend.com] \ No newline at end of file
diff --git a/ext/mysql/config.h.stub b/ext/mysql/config.h.stub
deleted file mode 100644
index bc14e05beb..0000000000
--- a/ext/mysql/config.h.stub
+++ /dev/null
@@ -1,3 +0,0 @@
-#ifndef HAVE_MYSQL
-#define HAVE_MYSQL 0
-#endif
diff --git a/ext/mysql/config.m4 b/ext/mysql/config.m4
deleted file mode 100644
index ceda6acf4b..0000000000
--- a/ext/mysql/config.m4
+++ /dev/null
@@ -1,79 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(for MySQL support)
-AC_ARG_WITH(mysql,
-[ --with-mysql[=DIR] Include MySQL support. DIR is the MySQL base
- install directory, defaults to searching through
- a number of common places for the MySQL files.
- Set DIR to "shared" to build as a dl, or "shared,DIR"
- to build as a dl and still specify DIR.],
-[
- PHP_WITH_SHARED
- if test "$withval" != "no"; then
- if test "$withval" = "yes"; then
- if test -f /usr/include/mysql/mysql.h; then
- MYSQL_INCDIR=/usr/include/mysql
- if test -d /usr/lib/mysql; then
- MYSQL_LIBDIR=/usr/lib/mysql
- else
- MYSQL_LIBDIR=/usr/lib
- fi
- elif test -f /usr/include/mysql.h; then
- MYSQL_INCDIR=/usr/include
- MYSQL_LIBDIR=/usr/lib
- elif test -f /usr/local/include/mysql/mysql.h; then
- MYSQL_INCDIR=/usr/local/include/mysql
- MYSQL_LIBDIR=/usr/local/lib/mysql
- elif test -f /usr/local/include/mysql.h; then
- MYSQL_INCDIR=/usr/local/include
- MYSQL_LIBDIR=/usr/local/lib
- elif test -f /usr/local/mysql/include/mysql/mysql.h; then
- MYSQL_INCDIR=/usr/local/mysql/include/mysql
- MYSQL_LIBDIR=/usr/local/mysql/lib/mysql
- else
- AC_MSG_RESULT(no)
- AC_MSG_ERROR(Invalid MySQL directory - unable to find mysql.h)
- fi
- else
- if test -f $withval/include/mysql/mysql.h; then
- MYSQL_INCDIR=$withval/include/mysql
- MYSQL_LIBDIR=$withval/lib/mysql
- elif test -f $withval/include/mysql.h; then
- MYSQL_INCDIR=$withval/include
- MYSQL_LIBDIR=$withval/lib
- else
- AC_MSG_RESULT(no)
- AC_MSG_ERROR(Invalid MySQL directory - unable to find mysql.h under $withval)
- fi
- fi
- MYSQL_INCLUDE=-I$MYSQL_INCDIR
-
- AC_DEFINE(HAVE_MYSQL)
- if test "$shared" = "yes"; then
- AC_MSG_RESULT(yes (shared))
- MYSQL_LFLAGS="-L$MYSQL_LIBDIR"
- MYSQL_SHARED="mysql.la"
- else
- AC_MSG_RESULT(yes (static))
- AC_ADD_LIBRARY_WITH_PATH(mysqlclient, $MYSQL_LIBDIR)
- AC_ADD_INCLUDE($MYSQL_INCDIR)
- MYSQL_STATIC="libphpext_mysql.a"
- fi
- PHP_EXTENSION(mysql, $shared)
-
- dnl check for errmsg.h, which isn't installed by some versions of 3.21
- old_CPPFLAGS="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS $MYSQL_INCLUDE"
- AC_CHECK_HEADERS(errmsg.h mysql.h)
- CPPFLAGS="$old_CPPFLAGS"
- else
- AC_MSG_RESULT(no)
- AC_DEFINE(HAVE_MYSQL, 0)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-AC_SUBST(MYSQL_STATIC)
-AC_SUBST(MYSQL_SHARED)
-AC_SUBST(MYSQL_INCLUDE)
-AC_SUBST(MYSQL_LFLAGS)
diff --git a/ext/mysql/mysql.dsp b/ext/mysql/mysql.dsp
deleted file mode 100644
index 7ea4c6e0b0..0000000000
--- a/ext/mysql/mysql.dsp
+++ /dev/null
@@ -1,171 +0,0 @@
-# Microsoft Developer Studio Project File - Name="mysql" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=mysql - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "mysql.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "mysql.mak" CFG="mysql - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "mysql - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "mysql - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "mysql - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "mysql - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "mysql - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MYSQL_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\libzend" /I "..\..\..\bindlib_w32" /I "..\..\..\MySQL\include" /I "..\..\TSRM" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MYSQL_EXPORTS" /D "COMPILE_DL" /D HAVE_MYSQL=1 /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "NDEBUG"
-# ADD RSC /l 0x40d /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libmySQL.lib php4nts.lib /nologo /dll /machine:I386 /out:"Release/php_mysql.dll" /libpath:"..\..\..\MySQL\libmysql\Release" /libpath:"..\..\Release"
-
-!ELSEIF "$(CFG)" == "mysql - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MYSQL_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\libzend" /I "..\..\..\bindlib_w32" /I "..\..\..\MySQL\include" /I "..\..\TSRM" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MYSQL_EXPORTS" /D "COMPILE_DL" /D HAVE_MYSQL=1 /D ZEND_DEBUG=1 /FR /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "_DEBUG"
-# ADD RSC /l 0x40d /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libmySQL.lib php4nts.lib /nologo /dll /debug /machine:I386 /out:"Debug/php_mysql.dll" /pdbtype:sept /libpath:"..\..\..\MySQL\libmysql\Debug" /libpath:"..\..\Debug"
-
-!ELSEIF "$(CFG)" == "mysql - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\..\libzend" /I "..\..\..\bindlib_w32" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MYSQL_EXPORTS" /D "COMPILE_DL" /D HAVE_MYSQL=1 /FR /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\libzend" /I "..\..\..\bindlib_w32" /I "..\..\..\MySQL\include" /I "..\..\TSRM" /D "_DEBUG" /D ZEND_DEBUG=1 /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MYSQL_EXPORTS" /D "COMPILE_DL" /D HAVE_MYSQL=1 /D "ZTS" /FR /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "_DEBUG"
-# ADD RSC /l 0x40d /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libmySQL.lib php4ts.lib /nologo /dll /debug /machine:I386 /out:"Debug_TS/php_mysql.dll" /pdbtype:sept /libpath:"..\..\..\MySQL\libmysql\Debug" /libpath:"..\..\Debug_TS"
-
-!ELSEIF "$(CFG)" == "mysql - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\..\libzend" /I "..\..\..\bindlib_w32" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MYSQL_EXPORTS" /D "COMPILE_DL" /D HAVE_MYSQL=1 /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\libzend" /I "..\..\..\bindlib_w32" /I "..\..\..\MySQL\include" /I "..\..\TSRM" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MYSQL_EXPORTS" /D "COMPILE_DL" /D HAVE_MYSQL=1 /D "ZTS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "NDEBUG"
-# ADD RSC /l 0x40d /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libmySQL.lib php4ts.lib /nologo /dll /machine:I386 /out:"Release_TS/php_mysql.dll" /libpath:"..\..\..\MySQL\libmysql\Release" /libpath:"..\..\Release_TS"
-
-!ENDIF
-
-# Begin Target
-
-# Name "mysql - Win32 Release"
-# Name "mysql - Win32 Debug"
-# Name "mysql - Win32 Debug_TS"
-# Name "mysql - Win32 Release_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\php_mysql.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\php_mysql.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# Begin Source File
-
-SOURCE=.\Readme_w32.txt
-# End Source File
-# End Target
-# End Project
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
deleted file mode 100644
index e3a2326fce..0000000000
--- a/ext/mysql/php_mysql.c
+++ /dev/null
@@ -1,1813 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-
-/* TODO:
- *
- * ? Safe mode implementation
- */
-
-#ifdef PIC
-# define COMPILE_DL 1
-#endif
-
-#if COMPILE_DL
-#include "dl/phpdl.h"
-#endif
-
-#include "php.h"
-#include "php_globals.h"
-#include "ext/standard/php3_standard.h"
-#include "php_mysql.h"
-#include "php_globals.h"
-
-
-#if WIN32|WINNT
-#include <winsock.h>
-#else
-#include "build-defs.h"
-
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#include <netdb.h>
-#include <netinet/in.h>
-#endif
-
-
-/* True globals, no need for thread safety */
-static int le_result,le_link,le_plink;
-
-#include "php_ini.h"
-
-#if HAVE_MYSQL
-# if HAVE_MYSQL_MYSQL_H
-# include <mysql/mysql.h>
-# else
-# include <mysql.h>
-# endif
-#ifdef HAVE_MYSQL_REAL_CONNECT
-#ifdef HAVE_ERRMSG_H
-#include <errmsg.h>
-#endif
-#endif
-
-#define SAFE_STRING(s) ((s)?(s):"")
-
-#if MYSQL_VERSION_ID > 32199
-#define mysql_row_length_type unsigned long
-#define HAVE_MYSQL_ERRNO
-#else
-#define mysql_row_length_type unsigned int
-# ifdef mysql_errno
-# define HAVE_MYSQL_ERRNO
-# endif
-#endif
-
-#define MYSQL_ASSOC 1<<0
-#define MYSQL_NUM 1<<1
-#define MYSQL_BOTH (MYSQL_ASSOC|MYSQL_NUM)
-
-#define PHP_MYSQL_VALID_RESULT(mysql) \
- (mysql_num_fields(mysql)>0)
-
-function_entry mysql_functions[] = {
- PHP_FE(mysql_connect, NULL)
- PHP_FE(mysql_pconnect, NULL)
- PHP_FE(mysql_close, NULL)
- PHP_FE(mysql_select_db, NULL)
- PHP_FE(mysql_create_db, NULL)
- PHP_FE(mysql_drop_db, NULL)
- PHP_FE(mysql_query, NULL)
- PHP_FE(mysql_db_query, NULL)
- PHP_FE(mysql_list_dbs, NULL)
- PHP_FE(mysql_list_tables, NULL)
- PHP_FE(mysql_list_fields, NULL)
- PHP_FE(mysql_error, NULL)
-#ifdef HAVE_MYSQL_ERRNO
- PHP_FE(mysql_errno, NULL)
-#endif
- PHP_FE(mysql_affected_rows, NULL)
- PHP_FE(mysql_insert_id, NULL)
- PHP_FE(mysql_result, NULL)
- PHP_FE(mysql_num_rows, NULL)
- PHP_FE(mysql_num_fields, NULL)
- PHP_FE(mysql_fetch_row, NULL)
- PHP_FE(mysql_fetch_array, NULL)
- PHP_FE(mysql_fetch_object, NULL)
- PHP_FE(mysql_data_seek, NULL)
- PHP_FE(mysql_fetch_lengths, NULL)
- PHP_FE(mysql_fetch_field, NULL)
- PHP_FE(mysql_field_seek, NULL)
- PHP_FE(mysql_free_result, NULL)
- PHP_FE(mysql_field_name, NULL)
- PHP_FE(mysql_field_table, NULL)
- PHP_FE(mysql_field_len, NULL)
- PHP_FE(mysql_field_type, NULL)
- PHP_FE(mysql_field_flags, NULL)
-
- /* for downwards compatability */
- PHP_FALIAS(mysql, mysql_db_query, NULL)
- PHP_FALIAS(mysql_fieldname, mysql_field_name, NULL)
- PHP_FALIAS(mysql_fieldtable, mysql_field_table, NULL)
- PHP_FALIAS(mysql_fieldlen, mysql_field_len, NULL)
- PHP_FALIAS(mysql_fieldtype, mysql_field_type, NULL)
- PHP_FALIAS(mysql_fieldflags, mysql_field_flags, NULL)
- PHP_FALIAS(mysql_selectdb, mysql_select_db, NULL)
- PHP_FALIAS(mysql_createdb, mysql_create_db, NULL)
- PHP_FALIAS(mysql_dropdb, mysql_drop_db, NULL)
- PHP_FALIAS(mysql_freeresult, mysql_free_result, NULL)
- PHP_FALIAS(mysql_numfields, mysql_num_fields, NULL)
- PHP_FALIAS(mysql_numrows, mysql_num_rows, NULL)
- PHP_FALIAS(mysql_listdbs, mysql_list_dbs, NULL)
- PHP_FALIAS(mysql_listtables, mysql_list_tables, NULL)
- PHP_FALIAS(mysql_listfields, mysql_list_fields, NULL)
- PHP_FALIAS(mysql_db_name, mysql_result, NULL)
- PHP_FALIAS(mysql_dbname, mysql_result, NULL)
- PHP_FALIAS(mysql_tablename, mysql_result, NULL)
- {NULL, NULL, NULL}
-};
-
-zend_module_entry mysql_module_entry = {
- "MySQL", mysql_functions, PHP_MINIT(mysql), PHP_MSHUTDOWN(mysql), PHP_RINIT(mysql), NULL,
- PHP_MINFO(mysql), STANDARD_MODULE_PROPERTIES
-};
-
-#ifdef ZTS
-int mysql_globals_id;
-#else
-PHP_MYSQL_API php_mysql_globals mysql_globals;
-#endif
-
-#ifdef COMPILE_DL
-DLEXPORT zend_module_entry *get_module(void) { return &mysql_module_entry; }
-#endif
-
-#if APACHE
-void timeout(int sig);
-#endif
-
-#define CHECK_LINK(link) { if (link==-1) { php_error(E_WARNING,"MySQL: A link to the server could not be established"); RETURN_FALSE; } }
-
-/* NOTE Don't ask me why, but soon as I made this the list
- * destructor, I stoped getting access violations in windows
- * with mysql 3.22.7a
- */
-static void _free_mysql_result(MYSQL_RES *mysql_result){
- mysql_free_result(mysql_result);
-}
-
-
-static void php_mysql_set_default_link(int id)
-{
- MySLS_FETCH();
-
- if (MySG(default_link)!=-1) {
- zend_list_delete(MySG(default_link));
- }
- MySG(default_link) = id;
- zend_list_addref(id);
-}
-
-
-static void _close_mysql_link(MYSQL *link)
-{
-#if APACHE
- void (*handler) (int);
-#endif
- MySLS_FETCH();
-
-#if APACHE
- handler = signal(SIGPIPE, SIG_IGN);
-#endif
-
- mysql_close(link);
-
-#if APACHE
- signal(SIGPIPE,handler);
-#endif
-
- efree(link);
- MySG(num_links)--;
-}
-
-static void _close_mysql_plink(MYSQL *link)
-{
-#if APACHE
- void (*handler) (int);
-#endif
- MySLS_FETCH();
-
-#if APACHE
- handler = signal(SIGPIPE, SIG_IGN);
-#endif
-
- mysql_close(link);
-
-#if APACHE
- signal(SIGPIPE,handler);
-#endif
-
- free(link);
- MySG(num_persistent)--;
- MySG(num_links)--;
-}
-
-
-static PHP_INI_MH(OnMySQLPort)
-{
- MySLS_FETCH();
-
- if (new_value==NULL) { /* default port */
-#if !(WIN32|WINNT)
- struct servent *serv_ptr;
- char *env;
-
- MySG(default_port) = MYSQL_PORT;
- if ((serv_ptr = getservbyname("mysql", "tcp"))) {
- MySG(default_port) = (uint) ntohs((ushort) serv_ptr->s_port);
- }
- if ((env = getenv("MYSQL_TCP_PORT"))) {
- MySG(default_port) = (uint) atoi(env);
- }
-#else
- MySG(default_port) = MYSQL_PORT;
-#endif
- } else {
- MySG(default_port) = atoi(new_value);
- }
- return SUCCESS;
-}
-
-
-static PHP_INI_DISP(display_link_numbers)
-{
- char *value;
-
- if (type==PHP_INI_DISPLAY_ORIG && ini_entry->modified) {
- value = ini_entry->orig_value;
- } else if (ini_entry->value) {
- value = ini_entry->value;
- } else {
- value = NULL;
- }
-
- if (value) {
- if (atoi(value)==-1) {
- PUTS("Unlimited");
- } else {
- php_printf("%s", value);
- }
- }
-}
-
-
-PHP_INI_BEGIN()
- STD_PHP_INI_BOOLEAN("mysql.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateInt, allow_persistent, php_mysql_globals, mysql_globals)
- STD_PHP_INI_ENTRY_EX("mysql.max_persistent", "-1", PHP_INI_SYSTEM, OnUpdateInt, max_persistent, php_mysql_globals, mysql_globals, display_link_numbers)
- STD_PHP_INI_ENTRY_EX("mysql.max_links", "-1", PHP_INI_SYSTEM, OnUpdateInt, max_links, php_mysql_globals, mysql_globals, display_link_numbers)
- STD_PHP_INI_ENTRY("mysql.default_host", NULL, PHP_INI_ALL, OnUpdateString, default_host, php_mysql_globals, mysql_globals)
- STD_PHP_INI_ENTRY("mysql.default_user", NULL, PHP_INI_ALL, OnUpdateString, default_user, php_mysql_globals, mysql_globals)
- STD_PHP_INI_ENTRY("mysql.default_password", NULL, PHP_INI_ALL, OnUpdateString, default_password, php_mysql_globals, mysql_globals)
- PHP_INI_ENTRY("mysql.default_port", NULL, PHP_INI_ALL, OnMySQLPort)
-PHP_INI_END()
-
-
-#ifdef ZTS
-static void php_mysql_init_globals(php_mysql_globals *mysql_globals)
-{
- MySG(num_persistent) = 0;
-}
-#endif
-
-
-PHP_MINIT_FUNCTION(mysql)
-{
- ELS_FETCH();
-
-#ifdef ZTS
- mysql_globals_id = ts_allocate_id(sizeof(php_mysql_globals), php_mysql_init_globals, NULL);
-#else
- MySG(num_persistent)=0;
-#endif
-
- REGISTER_INI_ENTRIES();
- le_result = register_list_destructors(_free_mysql_result,NULL);
- le_link = register_list_destructors(_close_mysql_link,NULL);
- le_plink = register_list_destructors(NULL,_close_mysql_plink);
- mysql_module_entry.type = type;
-
- REGISTER_LONG_CONSTANT("MYSQL_ASSOC", MYSQL_ASSOC, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("MYSQL_NUM", MYSQL_NUM, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("MYSQL_BOTH", MYSQL_BOTH, CONST_CS | CONST_PERSISTENT);
-
- return SUCCESS;
-}
-
-
-PHP_MSHUTDOWN_FUNCTION(mysql)
-{
- UNREGISTER_INI_ENTRIES();
- return SUCCESS;
-}
-
-
-PHP_RINIT_FUNCTION(mysql)
-{
- MySLS_FETCH();
-
- MySG(default_link)=-1;
- MySG(num_links) = MySG(num_persistent);
- return SUCCESS;
-}
-
-
-PHP_MINFO_FUNCTION(mysql)
-{
- char buf[32];
- MySLS_FETCH();
-
- DISPLAY_INI_ENTRIES();
-
- php_printf("<table border=5 width=\"600\">");
- php_info_print_table_header(2, "Key", "Value");
- sprintf(buf, "%ld", MySG(num_persistent));
- php_info_print_table_row(2, "Active Persistent Links", buf);
- sprintf(buf, "%ld", MySG(num_links));
- php_info_print_table_row(2, "Active Links", buf);
- php_info_print_table_row(2, "Client API version", mysql_get_client_info());
-#if !(WIN32|WINNT)
- php_info_print_table_row(2, "MYSQL_INCLUDE", PHP_MYSQL_INCLUDE);
- php_info_print_table_row(2, "MYSQL_LFLAGS", PHP_MYSQL_LFLAGS);
- php_info_print_table_row(2, "MYSQL_LIBS", PHP_MYSQL_LIBS);
-#endif
- php_printf("</table>\n");
-}
-
-
-static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
-{
-#if APACHE
- void (*handler) (int);
-#endif
- char *user,*passwd,*host,*tmp;
- char *hashed_details;
- int hashed_details_length,port;
- MYSQL *mysql;
- MySLS_FETCH();
- PLS_FETCH();
-
- if (PG(sql_safe_mode)) {
- if (ARG_COUNT(ht)>0) {
- php_error(E_NOTICE,"SQL safe mode in effect - ignoring host/user/password information");
- }
- host=passwd=NULL;
- user=_php3_get_current_user();
- hashed_details_length = strlen(user)+5+3;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details,"mysql__%s_",user);
- } else {
- host = MySG(default_host);
- user = MySG(default_user);
- passwd = MySG(default_password);
-
- switch(ARG_COUNT(ht)) {
- case 0: /* defaults */
- break;
- case 1: {
- pval *yyhost;
-
- if (getParameters(ht, 1, &yyhost)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(yyhost);
- host = yyhost->value.str.val;
- }
- break;
- case 2: {
- pval *yyhost,*yyuser;
-
- if (getParameters(ht, 2, &yyhost, &yyuser)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(yyhost);
- convert_to_string(yyuser);
- host = yyhost->value.str.val;
- user = yyuser->value.str.val;
- }
- break;
- case 3: {
- pval *yyhost,*yyuser,*yypasswd;
-
- if (getParameters(ht, 3, &yyhost, &yyuser, &yypasswd) == FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(yyhost);
- convert_to_string(yyuser);
- convert_to_string(yypasswd);
- host = yyhost->value.str.val;
- user = yyuser->value.str.val;
- passwd = yypasswd->value.str.val;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
- hashed_details_length = sizeof("mysql___")-1 + strlen(SAFE_STRING(host))+strlen(SAFE_STRING(user))+strlen(SAFE_STRING(passwd));
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details,"mysql_%s_%s_%s",SAFE_STRING(host), SAFE_STRING(user), SAFE_STRING(passwd));
- }
-
- /* We cannot use mysql_port anymore in windows, need to use
- * mysql_real_connect() to set the port.
- */
- if (host && (tmp=strchr(host,':'))) {
- *tmp=0;
- tmp++;
- port = atoi(tmp);
- } else {
- port = MySG(default_port);
- }
-
-#if MYSQL_VERSION_ID < 32200
- mysql_port = port;
-#endif
-
- if (!MySG(allow_persistent)) {
- persistent=0;
- }
- if (persistent) {
- list_entry *le;
-
- /* try to find if we already have this link in our persistent list */
- if (zend_hash_find(plist, hashed_details, hashed_details_length+1, (void **) &le)==FAILURE) { /* we don't */
- list_entry new_le;
-
- if (MySG(max_links)!=-1 && MySG(num_links)>=MySG(max_links)) {
- php_error(E_WARNING,"MySQL: Too many open links (%d)",MySG(num_links));
- efree(hashed_details);
- RETURN_FALSE;
- }
- if (MySG(max_persistent)!=-1 && MySG(num_persistent)>=MySG(max_persistent)) {
- php_error(E_WARNING,"MySQL: Too many open persistent links (%d)",MySG(num_persistent));
- efree(hashed_details);
- RETURN_FALSE;
- }
- /* create the link */
- mysql = (MYSQL *) malloc(sizeof(MYSQL));
-#if MYSQL_VERSION_ID > 32199 /* this lets us set the port number */
- mysql_init(mysql);
- if (mysql_real_connect(mysql,host,user,passwd,NULL,port,NULL,0)==NULL) {
-#else
- if (mysql_connect(mysql,host,user,passwd)==NULL) {
-#endif
- php_error(E_WARNING,mysql_error(mysql));
- free(mysql);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- /* hash it up */
- new_le.type = le_plink;
- new_le.ptr = mysql;
- if (zend_hash_update(plist, hashed_details, hashed_details_length+1, (void *) &new_le, sizeof(list_entry), NULL)==FAILURE) {
- free(mysql);
- efree(hashed_details);
- RETURN_FALSE;
- }
- MySG(num_persistent)++;
- MySG(num_links)++;
- } else { /* we do */
- if (le->type != le_plink) {
- RETURN_FALSE;
- }
- /* ensure that the link did not die */
-#if APACHE
- handler=signal(SIGPIPE,SIG_IGN);
-#endif
-#if defined(HAVE_MYSQL_ERRNO) && defined(CR_SERVER_GONE_ERROR)
- mysql_stat(le->ptr);
- if (mysql_errno((MYSQL *)le->ptr) == CR_SERVER_GONE_ERROR) {
-#else
- if (!strcasecmp(mysql_stat(le->ptr),"mysql server has gone away")) { /* the link died */
-#endif
-#if APACHE
- signal(SIGPIPE,handler);
-#endif
-#if MYSQL_VERSION_ID > 32199 /* this lets us set the port number */
- if (mysql_real_connect(le->ptr,host,user,passwd,NULL,port,NULL,0)==NULL) {
-#else
- if (mysql_connect(le->ptr,host,user,passwd)==NULL) {
-#endif
- php_error(E_WARNING,"MySQL: Link to server lost, unable to reconnect");
- zend_hash_del(plist, hashed_details, hashed_details_length+1);
- efree(hashed_details);
- RETURN_FALSE;
- }
- }
-#if APACHE
- signal(SIGPIPE,handler);
-#endif
- mysql = (MYSQL *) le->ptr;
- }
- ZEND_REGISTER_RESOURCE(return_value, mysql, le_plink);
- } else { /* non persistent */
- list_entry *index_ptr,new_index_ptr;
-
- /* first we check the hash for the hashed_details key. if it exists,
- * it should point us to the right offset where the actual mysql link sits.
- * if it doesn't, open a new mysql link, add it to the resource list,
- * and add a pointer to it with hashed_details as the key.
- */
- if (zend_hash_find(list,hashed_details,hashed_details_length+1,(void **) &index_ptr)==SUCCESS) {
- int type,link;
- void *ptr;
-
- if (index_ptr->type != le_index_ptr) {
- RETURN_FALSE;
- }
- link = (int) index_ptr->ptr;
- ptr = zend_list_find(link,&type); /* check if the link is still there */
- if (ptr && (type==le_link || type==le_plink)) {
- zend_list_addref(link);
- return_value->value.lval = link;
- php_mysql_set_default_link(link);
- return_value->type = IS_RESOURCE;
- efree(hashed_details);
- return;
- } else {
- zend_hash_del(list,hashed_details,hashed_details_length+1);
- }
- }
- if (MySG(max_links)!=-1 && MySG(num_links)>=MySG(max_links)) {
- php_error(E_WARNING,"MySQL: Too many open links (%d)",MySG(num_links));
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- mysql = (MYSQL *) emalloc(sizeof(MYSQL));
-#if MYSQL_VERSION_ID > 32199 /* this lets us set the port number */
- mysql_init(mysql);
- if (mysql_real_connect(mysql,host,user,passwd,NULL,port,NULL,0)==NULL) {
-#else
- if (mysql_connect(mysql,host,user,passwd)==NULL) {
-#endif
- php_error(E_WARNING,"MySQL Connection Failed: %s\n",mysql_error(mysql));
- efree(hashed_details);
- efree(mysql);
- RETURN_FALSE;
- }
-
- /* add it to the list */
- ZEND_REGISTER_RESOURCE(return_value, mysql, le_link);
-
- /* add it to the hash */
- new_index_ptr.ptr = (void *) return_value->value.lval;
- new_index_ptr.type = le_index_ptr;
- if (zend_hash_update(list,hashed_details,hashed_details_length+1,(void *) &new_index_ptr, sizeof(list_entry), NULL)==FAILURE) {
- efree(hashed_details);
- RETURN_FALSE;
- }
- MySG(num_links)++;
- }
-
- efree(hashed_details);
- php_mysql_set_default_link(return_value->value.lval);
-}
-
-
-static int php_mysql_get_default_link(INTERNAL_FUNCTION_PARAMETERS MySLS_DC)
-{
- if (MySG(default_link)==-1) { /* no link opened yet, implicitly open one */
- ht = 0;
- php_mysql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
- }
- return MySG(default_link);
-}
-
-
-/* {{{ proto int mysql_connect([string hostname[:port]] [, string username] [, string password])
- Open a connection to a MySQL Server */
-PHP_FUNCTION(mysql_connect)
-{
- php_mysql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_pconnect([string hostname[:port]] [, string username] [, string password])
- Open a persistent connection to a MySQL Server */
-PHP_FUNCTION(mysql_pconnect)
-{
- php_mysql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_close([int link_identifier])
- Close a MySQL connection */
-PHP_FUNCTION(mysql_close)
-{
- pval *mysql_link=NULL;
- int id;
- MYSQL *mysql;
- MySLS_FETCH();
-
- switch (ARG_COUNT(ht)) {
- case 0:
- id = MySG(default_link);
- break;
- case 1:
- if (getParameters(ht, 1, &mysql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
-
- zend_list_delete(id);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_select_db(string database_name [, int link_identifier])
- Select a MySQL database */
-PHP_FUNCTION(mysql_select_db)
-{
- pval *db,*mysql_link;
- int id;
- MYSQL *mysql;
- MySLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &db)==FAILURE) {
- RETURN_FALSE;
- }
- id = php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU MySLS_CC);
- CHECK_LINK(id);
- break;
- case 2:
- if (getParameters(ht, 2, &db, &mysql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
-
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
-
- convert_to_string(db);
-
- if (mysql_select_db(mysql,db->value.str.val)!=0) {
- RETURN_FALSE;
- } else {
- RETURN_TRUE;
- }
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_create_db(string database_name [, int link_identifier])
- Create a MySQL database */
-PHP_FUNCTION(mysql_create_db)
-{
- pval *db,*mysql_link;
- int id;
- MYSQL *mysql;
- MySLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &db)==FAILURE) {
- RETURN_FALSE;
- }
- id = php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU MySLS_CC);
- CHECK_LINK(id);
- break;
- case 2:
- if (getParameters(ht, 2, &db, &mysql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
-
- convert_to_string(db);
- if (mysql_create_db(mysql,db->value.str.val)==0) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_drop_db(string database_name [, int link_identifier])
- Drop (delete) a MySQL database */
-PHP_FUNCTION(mysql_drop_db)
-{
- pval *db,*mysql_link;
- int id;
- MYSQL *mysql;
- MySLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &db)==FAILURE) {
- RETURN_FALSE;
- }
- id = php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU MySLS_CC);
- CHECK_LINK(id);
- break;
- case 2:
- if (getParameters(ht, 2, &db, &mysql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
-
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
-
- convert_to_string(db);
- if (mysql_drop_db(mysql,db->value.str.val)==0) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_query(string query [, int link_identifier])
- Send an SQL query to MySQL */
-PHP_FUNCTION(mysql_query)
-{
- pval *query,*mysql_link;
- int id;
- MYSQL *mysql;
- MYSQL_RES *mysql_result;
- MySLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &query)==FAILURE) {
- RETURN_FALSE;
- }
- id = php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU MySLS_CC);
- CHECK_LINK(id);
- break;
- case 2:
- if (getParameters(ht, 2, &query, &mysql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
-
- convert_to_string(query);
- /* mysql_query binary unsafe, use mysql_real_query */
-#if MYSQL_VERSION_ID > 32199
- if (mysql_real_query(mysql,query->value.str.val,query->value.str.len)!=0) {
- RETURN_FALSE;
- }
-#else
- if (mysql_query(mysql,query->value.str.val)!=0) {
- RETURN_FALSE;
- }
-#endif
- if ((mysql_result=mysql_store_result(mysql))==NULL) {
- if (PHP_MYSQL_VALID_RESULT(mysql)) { /* query should have returned rows */
- php_error(E_WARNING, "MySQL: Unable to save result set");
- RETURN_FALSE;
- } else {
- RETURN_TRUE;
- }
- }
- ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_db_query(string database_name, string query [, int link_identifier])
- Send an SQL query to MySQL */
-PHP_FUNCTION(mysql_db_query)
-{
- pval *db,*query,*mysql_link;
- int id;
- MYSQL *mysql;
- MYSQL_RES *mysql_result;
- MySLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &db, &query)==FAILURE) {
- RETURN_FALSE;
- }
- id = php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU MySLS_CC);
- CHECK_LINK(id);
- break;
- case 3:
- if (getParameters(ht, 3, &db, &query, &mysql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
-
- convert_to_string(db);
- if (mysql_select_db(mysql,db->value.str.val)!=0) {
- RETURN_FALSE;
- }
-
- convert_to_string(query);
- /* mysql_query is binary unsafe, use mysql_real_query */
-#if MYSQL_VERSION_ID > 32199
- if (mysql_real_query(mysql,query->value.str.val,query->value.str.len)!=0) {
- RETURN_FALSE;
- }
-#else
- if (mysql_query(mysql,query->value.str.val)!=0) {
- RETURN_FALSE;
- }
-#endif
- if ((mysql_result=mysql_store_result(mysql))==NULL) {
- if (PHP_MYSQL_VALID_RESULT(mysql)) { /* query should have returned rows */
- php_error(E_WARNING, "MySQL: Unable to save result set");
- RETURN_FALSE;
- } else {
- RETURN_TRUE;
- }
- }
- ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_list_dbs([int link_identifier])
- List databases available on a MySQL server */
-PHP_FUNCTION(mysql_list_dbs)
-{
- pval *mysql_link;
- int id;
- MYSQL *mysql;
- MYSQL_RES *mysql_result;
- MySLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 0:
- id = php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU MySLS_CC);
- CHECK_LINK(id);
- break;
- case 1:
- if (getParameters(ht, 1, &mysql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
-
- if ((mysql_result=mysql_list_dbs(mysql,NULL))==NULL) {
- php_error(E_WARNING,"Unable to save MySQL query result");
- RETURN_FALSE;
- }
- ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_list_tables(string database_name [, int link_identifier])
- List tables in a MySQL database */
-PHP_FUNCTION(mysql_list_tables)
-{
- pval *db,*mysql_link;
- int id;
- MYSQL *mysql;
- MYSQL_RES *mysql_result;
- MySLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &db)==FAILURE) {
- RETURN_FALSE;
- }
- id = php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU MySLS_CC);
- CHECK_LINK(id);
- break;
- case 2:
- if (getParameters(ht, 2, &db, &mysql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
-
- convert_to_string(db);
- if (mysql_select_db(mysql,db->value.str.val)!=0) {
- RETURN_FALSE;
- }
- if ((mysql_result=mysql_list_tables(mysql,NULL))==NULL) {
- php_error(E_WARNING,"Unable to save MySQL query result");
- RETURN_FALSE;
- }
- ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_list_fields(string database_name, string table_name [, int link_identifier])
- List MySQL result fields */
-PHP_FUNCTION(mysql_list_fields)
-{
- pval *db,*table,*mysql_link;
- int id;
- MYSQL *mysql;
- MYSQL_RES *mysql_result;
- MySLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &db, &table)==FAILURE) {
- RETURN_FALSE;
- }
- id = php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU MySLS_CC);
- CHECK_LINK(id);
- break;
- case 3:
- if (getParameters(ht, 3, &db, &table, &mysql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
-
- convert_to_string(db);
- if (mysql_select_db(mysql,db->value.str.val)!=0) {
- RETURN_FALSE;
- }
- convert_to_string(table);
- if ((mysql_result=mysql_list_fields(mysql,table->value.str.val,NULL))==NULL) {
- php_error(E_WARNING,"Unable to save MySQL query result");
- RETURN_FALSE;
- }
- ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
-}
-/* }}} */
-
-
-/* {{{ proto string mysql_error([int link_identifier])
- Returns the text of the error message from previous MySQL operation */
-PHP_FUNCTION(mysql_error)
-{
- pval *mysql_link;
- int id;
- MYSQL *mysql;
- MySLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 0:
- id = MySG(default_link);
- if (id==-1) {
- RETURN_FALSE;
- }
- break;
- case 1:
- if (getParameters(ht, 1, &mysql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
-
- RETURN_STRING(mysql_error(mysql),1);
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_errno([int link_identifier])
- Returns the number of the error message from previous MySQL operation */
-#ifdef HAVE_MYSQL_ERRNO
-PHP_FUNCTION(mysql_errno)
-{
- pval *mysql_link;
- int id;
- MYSQL *mysql;
- MySLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 0:
- id = MySG(default_link);
- if (id==-1) {
- RETURN_FALSE;
- }
- break;
- case 1:
- if (getParameters(ht, 1, &mysql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
-
- RETURN_LONG(mysql_errno(mysql));
-}
-#endif
-/* }}} */
-
-
-/* {{{ proto int mysql_affected_rows([int link_identifier])
- Get number of affected rows in previous MySQL operation */
-PHP_FUNCTION(mysql_affected_rows)
-{
- pval *mysql_link;
- int id;
- MYSQL *mysql;
- MySLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 0:
- id = MySG(default_link);
- CHECK_LINK(id);
- break;
- case 1:
- if (getParameters(ht, 1, &mysql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
-
- /* conversion from int64 to long happing here */
- return_value->value.lval = (long)mysql_affected_rows(mysql);
- return_value->type = IS_LONG;
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_insert_id([int link_identifier])
- Get the id generated from the previous INSERT operation */
-PHP_FUNCTION(mysql_insert_id)
-{
- pval *mysql_link;
- int id;
- MYSQL *mysql;
- MySLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 0:
- id = MySG(default_link);
- CHECK_LINK(id);
- break;
- case 1:
- if (getParameters(ht, 1, &mysql_link)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
-
- /* conversion from int64 to long happing here */
- return_value->value.lval = (long)mysql_insert_id(mysql);
- return_value->type = IS_LONG;
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_result(int result, int row [, mixed field])
- Get result data */
-PHP_FUNCTION(mysql_result)
-{
- pval *result, *row, *field=NULL;
- MYSQL_RES *mysql_result;
- MYSQL_ROW sql_row;
- mysql_row_length_type *sql_row_lengths;
- int field_offset=0;
- PLS_FETCH();
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &result, &row)==FAILURE) {
- RETURN_FALSE;
- }
- break;
- case 3:
- if (getParameters(ht, 3, &result, &row, &field)==FAILURE) {
- RETURN_FALSE;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
-
- convert_to_long(row);
- if (row->value.lval<0 || row->value.lval>=(int)mysql_num_rows(mysql_result)) {
- php_error(E_WARNING,"Unable to jump to row %d on MySQL result index %d",row->value.lval,result->value.lval);
- RETURN_FALSE;
- }
- mysql_data_seek(mysql_result,row->value.lval);
- if ((sql_row=mysql_fetch_row(mysql_result))==NULL
- || (sql_row_lengths=mysql_fetch_lengths(mysql_result))==NULL) { /* shouldn't happen? */
- RETURN_FALSE;
- }
-
- if (field) {
- switch(field->type) {
- case IS_STRING: {
- int i=0;
- MYSQL_FIELD *tmp_field;
- char *table_name,*field_name,*tmp;
-
- if ((tmp=strchr(field->value.str.val,'.'))) {
- *tmp = 0;
- table_name = estrdup(field->value.str.val);
- field_name = estrdup(tmp+1);
- } else {
- table_name = NULL;
- field_name = estrndup(field->value.str.val,field->value.str.len);
- }
- mysql_field_seek(mysql_result,0);
- while ((tmp_field=mysql_fetch_field(mysql_result))) {
- if ((!table_name || !strcasecmp(tmp_field->table,table_name)) && !strcasecmp(tmp_field->name,field_name)) {
- field_offset = i;
- break;
- }
- i++;
- }
- if (!tmp_field) { /* no match found */
- php_error(E_WARNING,"%s%s%s not found in MySQL result index %d",
- (table_name?table_name:""), (table_name?".":""), field_name, result->value.lval);
- efree(field_name);
- if (table_name) {
- efree(table_name);
- }
- RETURN_FALSE;
- }
- efree(field_name);
- if (table_name) {
- efree(table_name);
- }
- }
- break;
- default:
- convert_to_long(field);
- field_offset = field->value.lval;
- if (field_offset<0 || field_offset>=(int)mysql_num_fields(mysql_result)) {
- php_error(E_WARNING,"Bad column offset specified");
- RETURN_FALSE;
- }
- break;
- }
- }
-
- if (sql_row[field_offset]) {
- if (PG(magic_quotes_runtime)) {
- return_value->value.str.val = php_addslashes(sql_row[field_offset],sql_row_lengths[field_offset],&return_value->value.str.len,0);
- } else {
- return_value->value.str.len = sql_row_lengths[field_offset];
- return_value->value.str.val = (char *) safe_estrndup(sql_row[field_offset],return_value->value.str.len);
- }
- } else {
- return_value->value.str.val = undefined_variable_string;
- return_value->value.str.len=0;
- return_value->type = IS_STRING;
- }
-
- return_value->type = IS_STRING;
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_num_rows(int result)
- Get number of rows in a result */
-PHP_FUNCTION(mysql_num_rows)
-{
- pval *result;
- MYSQL_RES *mysql_result;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
-
- /* conversion from int64 to long happing here */
- return_value->value.lval = (long)mysql_num_rows(mysql_result);
- return_value->type = IS_LONG;
-}
-/* }}} */
-
-/* {{{ proto int mysql_num_fields(int result)
- Get number of fields in a result */
-PHP_FUNCTION(mysql_num_fields)
-{
- pval *result;
- MYSQL_RES *mysql_result;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
-
- return_value->value.lval = mysql_num_fields(mysql_result);
- return_value->type = IS_LONG;
-}
-/* }}} */
-
-
-static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
-{
- pval *result, *arg2;
- MYSQL_RES *mysql_result;
- MYSQL_ROW mysql_row;
- MYSQL_FIELD *mysql_field;
- mysql_row_length_type *mysql_row_lengths;
- int num_fields;
- int i;
- PLS_FETCH();
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &result)==FAILURE) {
- RETURN_FALSE;
- }
- if (!result_type) {
- result_type = MYSQL_BOTH;
- }
- break;
- case 2:
- if (getParameters(ht, 2, &result, &arg2)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(arg2);
- result_type = arg2->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
-
- if ((mysql_row=mysql_fetch_row(mysql_result))==NULL
- || (mysql_row_lengths=mysql_fetch_lengths(mysql_result))==NULL) {
- RETURN_FALSE;
- }
-
- num_fields = mysql_num_fields(mysql_result);
-
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
-
- mysql_field_seek(mysql_result,0);
- for (mysql_field=mysql_fetch_field(mysql_result),i=0; mysql_field; mysql_field=mysql_fetch_field(mysql_result),i++) {
- if (mysql_row[i]) {
- char *data;
- int data_len;
- int should_copy;
-
- if (PG(magic_quotes_runtime)) {
- data = php_addslashes(mysql_row[i],mysql_row_lengths[i],&data_len,0);
- should_copy = 0;
- } else {
- data = mysql_row[i];
- data_len = mysql_row_lengths[i];
- should_copy = 1;
- }
-
- if (result_type & MYSQL_NUM) {
- add_index_stringl(return_value, i, data, data_len, should_copy);
- should_copy = 1;
- }
-
- if (result_type & MYSQL_ASSOC) {
- add_assoc_stringl(return_value, mysql_field->name, data, data_len, should_copy);
- }
- } else {
- /* NULL field, don't set it */
- /* add_get_index_stringl(return_value, i, empty_string, 0, (void **) &pval_ptr); */
- }
- }
-}
-
-
-/* {{{ proto array mysql_fetch_row(int result)
- Get a result row as an enumerated array */
-PHP_FUNCTION(mysql_fetch_row)
-{
- php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQL_NUM);
-}
-/* }}} */
-
-
-/* {{{ proto object mysql_fetch_object(int result [, int result_type])
- Fetch a result row as an object */
-PHP_FUNCTION(mysql_fetch_object)
-{
- php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
- if (return_value->type==IS_ARRAY) {
- return_value->type=IS_OBJECT;
- return_value->value.obj.properties = return_value->value.ht;
- return_value->value.obj.ce = &zend_standard_class_def;
- }
-}
-/* }}} */
-
-
-/* {{{ proto array mysql_fetch_array(int result [, int result_type])
- Fetch a result row as an associative array */
-PHP_FUNCTION(mysql_fetch_array)
-{
- php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_data_seek(int result, int row_number)
- Move internal result pointer */
-PHP_FUNCTION(mysql_data_seek)
-{
- pval *result,*offset;
- MYSQL_RES *mysql_result;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &result, &offset)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
-
- convert_to_long(offset);
- if (offset->value.lval<0 || offset->value.lval>=(int)mysql_num_rows(mysql_result)) {
- php_error(E_WARNING,"Offset %d is invalid for MySQL result index %d",offset->value.lval,result->value.lval);
- RETURN_FALSE;
- }
- mysql_data_seek(mysql_result,offset->value.lval);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/* {{{ proto array mysql_fetch_lengths(int result)
- Get max data size of each column in a result */
-PHP_FUNCTION(mysql_fetch_lengths)
-{
- pval *result;
- MYSQL_RES *mysql_result;
- mysql_row_length_type *lengths;
- int num_fields;
- int i;
-
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
-
- if ((lengths=mysql_fetch_lengths(mysql_result))==NULL) {
- RETURN_FALSE;
- }
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
- num_fields = mysql_num_fields(mysql_result);
-
- for (i=0; i<num_fields; i++) {
- add_index_long(return_value, i, lengths[i]);
- }
-}
-/* }}} */
-
-
-static char *php_mysql_get_field_name(int field_type)
-{
- switch(field_type) {
- case FIELD_TYPE_STRING:
- case FIELD_TYPE_VAR_STRING:
- return "string";
- break;
-#ifdef FIELD_TYPE_TINY
- case FIELD_TYPE_TINY:
-#endif
- case FIELD_TYPE_SHORT:
- case FIELD_TYPE_LONG:
- case FIELD_TYPE_LONGLONG:
- case FIELD_TYPE_INT24:
- return "int";
- break;
- case FIELD_TYPE_FLOAT:
- case FIELD_TYPE_DOUBLE:
- case FIELD_TYPE_DECIMAL:
- return "real";
- break;
- case FIELD_TYPE_TIMESTAMP:
- return "timestamp";
- break;
- case FIELD_TYPE_DATE:
- return "date";
- break;
- case FIELD_TYPE_TIME:
- return "time";
- break;
- case FIELD_TYPE_DATETIME:
- return "datetime";
- break;
- case FIELD_TYPE_TINY_BLOB:
- case FIELD_TYPE_MEDIUM_BLOB:
- case FIELD_TYPE_LONG_BLOB:
- case FIELD_TYPE_BLOB:
- return "blob";
- break;
- case FIELD_TYPE_NULL:
- return "null";
- break;
- default:
- return "unknown";
- break;
- }
-}
-
-
-/* {{{ proto object mysql_fetch_field(int result [, int field_offset])
- Get column information from a result and return as an object */
-PHP_FUNCTION(mysql_fetch_field)
-{
- pval *result,*field=NULL;
- MYSQL_RES *mysql_result;
- MYSQL_FIELD *mysql_field;
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &result)==FAILURE) {
- RETURN_FALSE;
- }
- break;
- case 2:
- if (getParameters(ht, 2, &result, &field)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(field);
- break;
- default:
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
-
- if (field) {
- if (field->value.lval<0 || field->value.lval>=(int)mysql_num_fields(mysql_result)) {
- php_error(E_WARNING,"MySQL: Bad field offset");
- RETURN_FALSE;
- }
- mysql_field_seek(mysql_result,field->value.lval);
- }
- if ((mysql_field=mysql_fetch_field(mysql_result))==NULL) {
- RETURN_FALSE;
- }
- if (object_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
-
- add_property_string(return_value, "name",(mysql_field->name?mysql_field->name:empty_string), 1);
- add_property_string(return_value, "table",(mysql_field->table?mysql_field->table:empty_string), 1);
- add_property_string(return_value, "def",(mysql_field->def?mysql_field->def:empty_string), 1);
- add_property_long(return_value, "max_length",mysql_field->max_length);
- add_property_long(return_value, "not_null",IS_NOT_NULL(mysql_field->flags)?1:0);
- add_property_long(return_value, "primary_key",IS_PRI_KEY(mysql_field->flags)?1:0);
- add_property_long(return_value, "multiple_key",(mysql_field->flags&MULTIPLE_KEY_FLAG?1:0));
- add_property_long(return_value, "unique_key",(mysql_field->flags&UNIQUE_KEY_FLAG?1:0));
- add_property_long(return_value, "numeric",IS_NUM(mysql_field->type)?1:0);
- add_property_long(return_value, "blob",IS_BLOB(mysql_field->flags)?1:0);
- add_property_string(return_value, "type",php_mysql_get_field_name(mysql_field->type), 1);
- add_property_long(return_value, "unsigned",(mysql_field->flags&UNSIGNED_FLAG?1:0));
- add_property_long(return_value, "zerofill",(mysql_field->flags&ZEROFILL_FLAG?1:0));
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_field_seek(int result, int field_offset)
- Set result pointer to a specific field offset */
-PHP_FUNCTION(mysql_field_seek)
-{
- pval *result, *offset;
- MYSQL_RES *mysql_result;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &result, &offset)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
-
- convert_to_long(offset);
- if (offset->value.lval<0 || offset->value.lval>=(int)mysql_num_fields(mysql_result)) {
- php_error(E_WARNING,"Field %d is invalid for MySQL result index %d",offset->value.lval,result->value.lval);
- RETURN_FALSE;
- }
- mysql_field_seek(mysql_result,offset->value.lval);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-#define PHP3_MYSQL_FIELD_NAME 1
-#define PHP3_MYSQL_FIELD_TABLE 2
-#define PHP3_MYSQL_FIELD_LEN 3
-#define PHP3_MYSQL_FIELD_TYPE 4
-#define PHP3_MYSQL_FIELD_FLAGS 5
-
-
-static void php_mysql_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
-{
- pval *result, *field;
- MYSQL_RES *mysql_result;
- MYSQL_FIELD *mysql_field;
- char buf[512];
- int len;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &result, &field)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
-
- convert_to_long(field);
- if (field->value.lval<0 || field->value.lval>=(int)mysql_num_fields(mysql_result)) {
- php_error(E_WARNING,"Field %d is invalid for MySQL result index %d",field->value.lval,result->value.lval);
- RETURN_FALSE;
- }
- mysql_field_seek(mysql_result,field->value.lval);
- if ((mysql_field=mysql_fetch_field(mysql_result))==NULL) {
- RETURN_FALSE;
- }
-
- switch (entry_type) {
- case PHP3_MYSQL_FIELD_NAME:
- return_value->value.str.len = strlen(mysql_field->name);
- return_value->value.str.val = estrndup(mysql_field->name,return_value->value.str.len);
- return_value->type = IS_STRING;
- break;
- case PHP3_MYSQL_FIELD_TABLE:
- return_value->value.str.len = strlen(mysql_field->table);
- return_value->value.str.val = estrndup(mysql_field->table,return_value->value.str.len);
- return_value->type = IS_STRING;
- break;
- case PHP3_MYSQL_FIELD_LEN:
- return_value->value.lval = mysql_field->length;
- return_value->type = IS_LONG;
- break;
- case PHP3_MYSQL_FIELD_TYPE:
- return_value->value.str.val = php_mysql_get_field_name(mysql_field->type);
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->value.str.val = estrndup(return_value->value.str.val, return_value->value.str.len);
- return_value->type = IS_STRING;
- break;
- case PHP3_MYSQL_FIELD_FLAGS:
- strcpy(buf, "");
-#ifdef IS_NOT_NULL
- if (IS_NOT_NULL(mysql_field->flags)) {
- strcat(buf, "not_null ");
- }
-#endif
-#ifdef IS_PRI_KEY
- if (IS_PRI_KEY(mysql_field->flags)) {
- strcat(buf, "primary_key ");
- }
-#endif
-#ifdef UNIQUE_KEY_FLAG
- if (mysql_field->flags&UNIQUE_KEY_FLAG) {
- strcat(buf, "unique_key ");
- }
-#endif
-#ifdef MULTIPLE_KEY_FLAG
- if (mysql_field->flags&MULTIPLE_KEY_FLAG) {
- strcat(buf, "multiple_key ");
- }
-#endif
-#ifdef IS_BLOB
- if (IS_BLOB(mysql_field->flags)) {
- strcat(buf, "blob ");
- }
-#endif
-#ifdef UNSIGNED_FLAG
- if (mysql_field->flags&UNSIGNED_FLAG) {
- strcat(buf, "unsigned ");
- }
-#endif
-#ifdef ZEROFILL_FLAG
- if (mysql_field->flags&ZEROFILL_FLAG) {
- strcat(buf, "zerofill ");
- }
-#endif
-#ifdef BINARY_FLAG
- if (mysql_field->flags&BINARY_FLAG) {
- strcat(buf, "binary ");
- }
-#endif
-#ifdef ENUM_FLAG
- if (mysql_field->flags&ENUM_FLAG) {
- strcat(buf, "enum ");
- }
-#endif
-#ifdef AUTO_INCREMENT_FLAG
- if (mysql_field->flags&AUTO_INCREMENT_FLAG) {
- strcat(buf, "auto_increment ");
- }
-#endif
-#ifdef TIMESTAMP_FLAG
- if (mysql_field->flags&TIMESTAMP_FLAG) {
- strcat(buf, "timestamp ");
- }
-#endif
- len = strlen(buf);
- /* remove trailing space, if present */
- if (len && buf[len-1] == ' ') {
- buf[len-1] = 0;
- len--;
- }
-
- return_value->value.str.len = len;
- return_value->value.str.val = estrndup(buf, len);
- return_value->type = IS_STRING;
- break;
-
- default:
- RETURN_FALSE;
- }
-}
-
-
-/* {{{ proto string mysql_field_name(int result, int field_index)
- Get the name of the specified field in a result */
-PHP_FUNCTION(mysql_field_name)
-{
- php_mysql_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_MYSQL_FIELD_NAME);
-}
-/* }}} */
-
-
-/* {{{ proto string mysql_field_table(int result, int field_offset)
- Get name of the table the specified field is in */
-PHP_FUNCTION(mysql_field_table)
-{
- php_mysql_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_MYSQL_FIELD_TABLE);
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_field_len(int result, int field_offet)
- Returns the length of the specified field */
-PHP_FUNCTION(mysql_field_len)
-{
- php_mysql_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_MYSQL_FIELD_LEN);
-}
-/* }}} */
-
-
-/* {{{ proto string mysql_field_type(int result, int field_offset)
- Get the type of the specified field in a result */
-PHP_FUNCTION(mysql_field_type)
-{
- php_mysql_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_MYSQL_FIELD_TYPE);
-}
-/* }}} */
-
-
-/* {{{ proto string mysql_field_flags(int result, int field_offset)
- Get the flags associated with the specified field in a result */
-PHP_FUNCTION(mysql_field_flags)
-{
- php_mysql_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_MYSQL_FIELD_FLAGS);
-}
-/* }}} */
-
-
-/* {{{ proto int mysql_free_result(int result)
- Free result memory */
-PHP_FUNCTION(mysql_free_result)
-{
- pval *result;
- MYSQL_RES *mysql_result;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (result->type==IS_RESOURCE && result->value.lval==0) {
- RETURN_FALSE;
- }
-
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
-
- zend_list_delete(result->value.lval);
- RETURN_TRUE;
-}
-/* }}} */
-#endif
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/mysql/php_mysql.h b/ext/mysql/php_mysql.h
deleted file mode 100644
index 0dc55a4076..0000000000
--- a/ext/mysql/php_mysql.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
-*/
-
-
-/* $Id$ */
-
-#ifndef _PHP_MYSQL_H
-#define _PHP_MYSQL_H
-
-#if COMPILE_DL
-#undef HAVE_MYSQL
-#define HAVE_MYSQL 1
-#endif
-
-#if WIN32||WINNT
-#define PHP_MYSQL_API __declspec(dllexport)
-#else
-#define PHP_MYSQL_API
-#endif
-
-#if HAVE_MYSQL
-#ifndef DLEXPORT
-#define DLEXPORT
-#endif
-
-#ifdef ZTS
-#include "TSRM.h"
-#endif
-
-extern zend_module_entry mysql_module_entry;
-
-#define mysql_module_ptr &mysql_module_entry
-
-extern PHP_MINIT_FUNCTION(mysql);
-extern PHP_RINIT_FUNCTION(mysql);
-extern PHP_MSHUTDOWN_FUNCTION(mysql);
-PHP_MINFO_FUNCTION(mysql);
-
-PHP_FUNCTION(mysql_connect);
-PHP_FUNCTION(mysql_pconnect);
-PHP_FUNCTION(mysql_close);
-PHP_FUNCTION(mysql_select_db);
-PHP_FUNCTION(mysql_create_db);
-PHP_FUNCTION(mysql_drop_db);
-PHP_FUNCTION(mysql_query);
-PHP_FUNCTION(mysql_db_query);
-PHP_FUNCTION(mysql_list_dbs);
-PHP_FUNCTION(mysql_list_tables);
-PHP_FUNCTION(mysql_list_fields);
-PHP_FUNCTION(mysql_error);
-PHP_FUNCTION(mysql_errno);
-PHP_FUNCTION(mysql_affected_rows);
-PHP_FUNCTION(mysql_insert_id);
-PHP_FUNCTION(mysql_result);
-PHP_FUNCTION(mysql_num_rows);
-PHP_FUNCTION(mysql_num_fields);
-PHP_FUNCTION(mysql_fetch_row);
-PHP_FUNCTION(mysql_fetch_array);
-PHP_FUNCTION(mysql_fetch_object);
-PHP_FUNCTION(mysql_data_seek);
-PHP_FUNCTION(mysql_fetch_lengths);
-PHP_FUNCTION(mysql_fetch_field);
-PHP_FUNCTION(mysql_field_seek);
-PHP_FUNCTION(mysql_free_result);
-PHP_FUNCTION(mysql_field_name);
-PHP_FUNCTION(mysql_field_table);
-PHP_FUNCTION(mysql_field_len);
-PHP_FUNCTION(mysql_field_type);
-PHP_FUNCTION(mysql_field_flags);
-
-typedef struct {
- long default_link;
- long num_links,num_persistent;
- long max_links,max_persistent;
- long allow_persistent;
- long default_port;
- char *default_host, *default_user, *default_password;
-} php_mysql_globals;
-
-
-#ifdef ZTS
-# define MySLS_D php_mysql_globals *mysql_globals
-# define MySLS_DC , MySLS_D
-# define MySLS_C mysql_globals
-# define MySLS_CC , MySLS_C
-# define MySG(v) (mysql_globals->v)
-# define MySLS_FETCH() php_mysql_globals *mysql_globals = ts_resource(mysql_globals_id)
-#else
-# define MySLS_D
-# define MySLS_DC
-# define MySLS_C
-# define MySLS_CC
-# define MySG(v) (mysql_globals.v)
-# define MySLS_FETCH()
-extern PHP_MYSQL_API php_mysql_globals mysql_globals;
-#endif
-
-
-#else
-
-#define mysql_module_ptr NULL
-
-#endif
-
-#define phpext_mysql_ptr mysql_module_ptr
-
-#endif /* _PHP_MYSQL_H */
diff --git a/ext/mysql/setup.stub b/ext/mysql/setup.stub
deleted file mode 100644
index 77b560c6cd..0000000000
--- a/ext/mysql/setup.stub
+++ /dev/null
@@ -1,7 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-mysql 'MySQL support?' yesnodir \
- 'no /usr/local MySQL install' \
-' Whether to build PHP with MySQL support.\n
- More info about MySQL can be found at http://www.mysql.com/.'
diff --git a/ext/oci8/Makefile.am b/ext/oci8/Makefile.am
deleted file mode 100644
index 8693894388..0000000000
--- a/ext/oci8/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_oci8.a
-libphpext_oci8_a_SOURCES=oci8.c
-
diff --git a/ext/oci8/config.h.stub b/ext/oci8/config.h.stub
deleted file mode 100644
index 74081b4d41..0000000000
--- a/ext/oci8/config.h.stub
+++ /dev/null
@@ -1,4 +0,0 @@
-/* define if you want to use the oci8 extension */
-/* #undef HAVE_LIBOCI8 */
-#define HAVE_OCI8 0
-
diff --git a/ext/oci8/config.m4 b/ext/oci8/config.m4
deleted file mode 100644
index 3a9451aad3..0000000000
--- a/ext/oci8/config.m4
+++ /dev/null
@@ -1,174 +0,0 @@
-dnl $Id$
-
-AC_DEFUN(AC_ORACLE_VERSION,[
- AC_MSG_CHECKING([Oracle version])
- if test -f "$ORACLEINST_TOP/orainst/unix.rgs"
- then
- changequote({,})
- ORACLE_VERSION=`grep '"ocommon"' $ORACLEINST_TOP/orainst/unix.rgs | sed 's/[ ][ ]*/:/g' | cut -d: -f 6 | cut -c 2-4`
- changequote([,])
- test -z "$ORACLE_VERSION" && ORACLE_VERSION=7.3
- else
- if test -f "$ORACLEINST_TOP/lib/libclntsh.so.8.0"
- then
- ORACLE_VERSION=8.1
- else
- ORACLE_VERSION=8.0
- fi
- fi
- AC_MSG_RESULT($ORACLE_VERSION)
-])
-
-AC_MSG_CHECKING(for Oracle-OCI8 support)
-AC_ARG_WITH(oci8,
-[ --with-oci8[=DIR] Include Oracle database support. DIR is Oracle's
- home directory, defaults to \$ORACLE_HOME.],
-[
- case "$withval" in
- yes)
- ORACLEINST_TOP=$ORACLE_HOME
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(oci8)
- ;;
- no)
- ORACLEINST_TOP=
- AC_MSG_RESULT(no)
- ;;
- *)
- ORACLEINST_TOP=$withval
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(oci8)
- ;;
- esac
-
- if test "$ORACLEINST_TOP" != ""
- then
-
- # Oracle include files
-
- if test -f "$ORACLEINST_TOP/rdbms/public/ocidfn.h"
- then
- # V8.0.5
- ORACLE_INCLUDE="$ORACLE_INCLUDE -I$ORACLEINST_TOP/rdbms/public"
- elif test -f "$ORACLEINST_TOP/rdbms/demo/ocidfn.h"
- then
- # V7.[0123]
- ORACLE_INCLUDE=-I$ORACLEINST_TOP/rdbms/demo
- fi
-
- if test -d "$ORACLEINST_TOP/network/public"
- then
- # V8
- ORACLE_INCLUDE="$ORACLE_INCLUDE -I$ORACLEINST_TOP/network/public"
- fi
-
- if test -d "$ORACLEINST_TOP/plsql/public"
- then
- # V8
- ORACLE_INCLUDE="$ORACLE_INCLUDE -I$ORACLEINST_TOP/plsql/public"
- fi
-
- # Need to know the version, otherwhise we will mixup nlsrtl
- AC_ORACLE_VERSION($ORACLEINST_TOP)
-
- # Oracle libs - nightmare :-)
-
- ORACLE_LIBDIR=lib
- ORACLE_LFLAGS="-L$ORACLEINST_TOP/$ORACLE_LIBDIR ${ld_runpath_switch}$ORACLEINST_TOP/$ORACLE_LIBDIR"
- if test -f "$ORACLEINST_TOP/rdbms/lib/sysliblist"
- then
- ORA_SYSLIB="`cat $ORACLEINST_TOP/rdbms/lib/sysliblist`"
- else
- ORA_SYSLIB="-lm"
- fi
-
- # Oracle Static libs
- case $ORACLE_VERSION in
- 7.0|7.1)
- ORACLE_STLIBS="-locic $ORACLEINST_TOP/$ORACLE_LIBDIR/osntab.o \
- -lsqlnet -lora -lsqlnet -lnlsrtl -lcv6 -lcore -lnlsrtl -lcv6 \
- -lcore $ORA_SYSLIB -lcore $ORA_SYSLIB"
- if test "`uname -s 2>/dev/null`" = "AIX"; then
- ORACLE_STLIBS="$ORACLE_STLIBS -bI:$ORACLE_HOME/lib/mili.exp"
- fi
- ;;
- 7.2)
- ORACLE_STLIBS="-locic $ORACLEINST_TOP/$ORACLE_LIBDIR/osntab.o \
- -lsqlnet -lora -lsqlnet -lora -lnlsrtl3 -lc3v6 -lcore3 -lnlsrtl3 \
- -lcore3 $ORA_SYSLIB -lcore3 $ORA_SYSLIB"
- ;;
- 7.3)
- ORACLE_STLIBS="-lclient -lsqlnet -lncr -lsqlnet -lclient -lcommon \
- -lgeneric -lsqlnet -lncr -lsqlnet -lclient -lcommon -lgeneric \
- -lepc -lnlsrtl3 -lc3v6 -lcore3 -lnlsrtl3 -lcore3 -lnlsrtl3 \
- $ORA_SYSLIB -lcore3 $ORA_SYSLIB"
- ;;
- 8.0)
- ORACLE_STLIBS="-lclient -lsqlnet -lncr -lsqlnet -lclient -lcommon \
- -lgeneric -lsqlnet -lncr -lsqlnet -lclient -lcommon -lgeneric \
- -lepc -lnlsrtl3 -lc3v6 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 \
- $ORA_SYSLIB -lcore3 $ORA_SYSLIB"
- ;;
- *)
- ORACLE_STLIBS=
- ;;
- esac
-
- # Oracle shared libs
- case $ORACLE_VERSION in
- 7.0)
- # shared libs not supported
- ORACLE_SHLIBS="$ORACLE_STLIBS"
- ;;
- 7.1)
- if test -f $ORACLEINST_TOP/$ORACLE_LIBDIR/liboracle.s?
- then
- ORACLE_SHLIBS="-loracle $ORA_SYSLIB"
- else
- ORACLE_SHLIBS="$ORACLE_STLIBS"
- fi
- ;;
- 7.2|7.3)
- if test -f $ORACLEINST_TOP/$ORACLE_LIBDIR/libclntsh.s?
- then
- ORACLE_SHLIBS="-lclntsh $ORA_SYSLIB"
- else
- ORACLE_SHLIBS="$ORACLE_STLIBS"
- fi
- ;;
- 8.0)
- if test -f $ORACLEINST_TOP/$ORACLE_LIBDIR/libclntsh.s? -o \
- -f $ORACLEINST_TOP/$ORACLE_LIBDIR/libclntsh.a # AIX
- then
- if test "$CC" = "gcc" -a "`uname -sv`" = "AIX 4"; then
- # for Oracle 8 on AIX 4
- ORA_SYSLIB="$ORA_SYSLIB -nostdlib /lib/crt0_r.o /usr/lib/libpthreads.a /usr/lib/libc_r.a -lgcc"
- fi
- ORACLE_SHLIBS="-lclntsh -lpsa -lcore4 -lnlsrtl3 -lclntsh $ORA_SYSLIB"
- else
- ORACLE_SHLIBS="$ORACLE_STLIBS"
- fi
- AC_DEFINE(HAVE_OCI8)
- ;;
- 8.1)
- ORACLE_SHLIBS="-lclntsh $ORA_SYSLIB"
- AC_DEFINE(HAVE_OCI8)
- ;;
- *)
- ORACLE_SHLIBS=
- ;;
- esac
-
- # only using shared libs right now
- ORACLE_LIBS=$ORACLE_SHLIBS
-
- AC_DEFINE(HAVE_ORACLE)
-
- fi
-
-],[AC_MSG_RESULT(no)])
-#EXTRA_LIBS="$EXTRA_LIBS $ORACLE_SHLIBS $ORACLE_STLIBS $ORACLE_LIBS $ORACLE_LFLAGS"
-EXTRA_LIBS="$EXTRA_LIBS $ORACLE_LIBS $ORACLE_LFLAGS"
-INCLUDES="$INCLUDES $ORACLE_INCLUDE"
-AC_SUBST(ORACLE_HOME)
-AC_SUBST(ORACLE_VERSION)
diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c
deleted file mode 100644
index 18ec63eb5f..0000000000
--- a/ext/oci8/oci8.c
+++ /dev/null
@@ -1,3620 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Stig Sæther Bakken <ssb@fast.no> |
- | Thies C. Arntzen <thies@digicol.de> |
- | |
- | Initial work sponsored by |
- | Digital Collections, http://www.digicol.de/ |
- +----------------------------------------------------------------------+
- */
-
-#define OCI_USE_EMALLOC 0 /* set this to 1 if you want to use the php memory manager! */
-
-/* $Id$ */
-
-/* TODO list:
- *
- * - php.ini flags
- * - Error mode (print or shut up?)
- * - OCIPasswordChange()
- * - Prefetching control
- * - binding of arrays
- * - Truncate input values to the bind size
- * - Character sets for NCLOBS
- * - split the module into an upper (php-callable) and lower (c-callable) layer!
- * - make_pval needs some cleanup....
- * - NULLS (retcode/indicator) needs some more work for describing & binding
- * - remove all XXXs
- * - clean up and documentation
- * - there seems to be a bug in OCI where it returns ORA-01406 (value truncated) - whereby it isn't (search for 01406 in the source)
- * this seems to happen for NUMBER values only...
- * - make OCIInternalDebug accept a mask of flags....
- * - better NULL handling
- * - add some flags to OCIFetchStatement (maxrows etc...)
- */
-
-/* {{{ includes & stuff */
-
-#if defined(COMPILE_DL)
-# include "dl/phpdl.h"
-#endif
-
-#include "php.h"
-
-#include "ext/standard/head.h"
-
-#if HAVE_OCI8
-
-#include "php3_oci8.h"
-
-/* True globals, no need for thread safety */
-static int le_conn; /* active connections */
-static int le_stmt; /* active statements */
-static zend_class_entry *oci_lob_class_entry_ptr;
-
-#ifndef SQLT_BFILEE
- #define SQLT_BFILEE 114
-#endif
-#ifndef SQLT_CFILEE
- #define SQLT_CFILEE 115
-#endif
-
-#define SAFE_STRING(s) ((s)?(s):"")
-
-#if !(WIN32|WINNT)
-#include "build-defs.h"
-#endif
-
-#include <fcntl.h>
-
-#include "snprintf.h"
-
-/* }}} */
-/* {{{ thread safety stuff */
-
-#ifdef ZTS
-int oci_globals_id;
-#else
-PHP_OCI_API php_oci_globals oci_globals;
-#endif
-
-/* }}} */
-/* {{{ dynamically loadable module stuff */
-
-#if COMPILE_DL
-DLEXPORT php3_module_entry *get_module() { return &oci_module_entry; };
-#endif /* COMPILE_DL */
-
-/* }}} */
-/* {{{ startup/shutdown/info/internal function prototypes */
-
-PHP_MINIT_FUNCTION(oci);
-PHP_RINIT_FUNCTION(oci);
-PHP_MSHUTDOWN_FUNCTION(oci);
-PHP_RSHUTDOWN_FUNCTION(oci);
-PHP_MINFO_FUNCTION(oci);
-
-static ub4 oci_error(OCIError *err_p, char *what, sword status);
-/* static int oci_ping(oci_connection *conn); XXX NYI */
-static void oci_debug(const char *format,...);
-
-static void _oci_close_conn(oci_connection *connection);
-static void _oci_free_stmt(oci_statement *statement);
-
-static int _oci_column_dtor(void *data);
-static int _oci_descr_dtor(void *data);
-static int _oci_define_dtor(void *data);
-
-static oci_connection *oci_get_conn(int, const char *, HashTable *);
-static oci_statement *oci_get_stmt(int, const char *, HashTable *);
-static oci_out_column *oci_get_col(oci_statement *, int, pval *, char *);
-
-static int oci_make_pval(pval *,oci_statement *,oci_out_column *, char *, int mode);
-static int oci_parse(oci_connection *, char *, int, HashTable *);
-static int oci_execute(oci_statement *, char *,ub4 mode,HashTable *);
-static int oci_fetch(oci_statement *, ub4, char *);
-static ub4 oci_loadlob(oci_connection *, oci_descriptor *, char **);
-static int oci_setprefetch(oci_statement *statement,int size);
-
-static void oci_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent,int exclusive);
-
-/* ServerAttach/Detach */
-static oci_server *oci_open_server(char *dbname,int persistent);
-static void _oci_close_server(oci_server *server);
-
-/* SessionBegin/End */
-static oci_session *oci_open_user(oci_server* server,char *username,char *password,int persistent,int exclusive);
-static void _oci_close_user(oci_session *session);
-
-/* bind callback functions */
-static sb4 oci_bind_in_callback(dvoid *, OCIBind *, ub4, ub4, dvoid **, ub4 *, ub1 *, dvoid **);
-static sb4 oci_bind_out_callback(dvoid *, OCIBind *, ub4, ub4, dvoid **, ub4 **, ub1 *, dvoid **, ub2 **);
-
-#if 0
-/* failover callback function */
-static sb4 oci_failover_callback(dvoid *svchp,dvoid* envhp,dvoid *fo_ctx,ub4 fo_type, ub4 fo_event);
-#endif
-
-/* }}} */
-/* {{{ extension function prototypes */
-
-PHP_FUNCTION(ocibindbyname);
-PHP_FUNCTION(ocidefinebyname);
-PHP_FUNCTION(ocicolumnisnull);
-PHP_FUNCTION(ocicolumnname);
-PHP_FUNCTION(ocicolumnsize);
-PHP_FUNCTION(ocicolumntype);
-PHP_FUNCTION(ociexecute);
-PHP_FUNCTION(ocifetch);
-PHP_FUNCTION(ocicancel);
-PHP_FUNCTION(ocifetchinto);
-PHP_FUNCTION(ocifetchstatement);
-PHP_FUNCTION(ocifreestatement);
-PHP_FUNCTION(ociinternaldebug);
-PHP_FUNCTION(ocilogoff);
-PHP_FUNCTION(ocilogon);
-PHP_FUNCTION(ocinlogon);
-PHP_FUNCTION(ociplogon);
-PHP_FUNCTION(ocierror);
-PHP_FUNCTION(ocifreedesc);
-PHP_FUNCTION(ocisavelob);
-PHP_FUNCTION(ocisavelobfile);
-PHP_FUNCTION(ociloadlob);
-PHP_FUNCTION(ocicommit);
-PHP_FUNCTION(ocirollback);
-PHP_FUNCTION(ocinewdescriptor);
-PHP_FUNCTION(ocinumcols);
-PHP_FUNCTION(ociparse);
-PHP_FUNCTION(ocinewcursor);
-PHP_FUNCTION(ociresult);
-PHP_FUNCTION(ociserverversion);
-PHP_FUNCTION(ocistatementtype);
-PHP_FUNCTION(ocirowcount);
-PHP_FUNCTION(ocisetprefetch);
-
-/* }}} */
-/* {{{ extension definition structures */
-
-#define OCI_ASSOC 1<<0
-#define OCI_NUM 1<<1
-#define OCI_BOTH (OCI_ASSOC|OCI_NUM)
-
-#define OCI_RETURN_NULLS 1<<2
-#define OCI_RETURN_LOBS 1<<3
-
-static unsigned char a3_arg_force_ref[] = { 3, BYREF_NONE, BYREF_NONE, BYREF_FORCE };
-static unsigned char a2_arg_force_ref[] = { 2, BYREF_NONE, BYREF_FORCE };
-
-static zend_function_entry php_oci_functions[] = {
- PHP_FE(ocidefinebyname, a3_arg_force_ref)
- PHP_FE(ocibindbyname, a3_arg_force_ref)
- PHP_FE(ocicolumnisnull, NULL)
- PHP_FE(ocicolumnname, NULL)
- PHP_FE(ocicolumnsize, NULL)
- PHP_FE(ocicolumntype, NULL)
- PHP_FE(ociexecute, NULL)
- PHP_FE(ocicancel, NULL)
- PHP_FE(ocifetch, NULL)
- PHP_FE(ocifetchinto, a2_arg_force_ref)
- PHP_FE(ocifetchstatement,a2_arg_force_ref)
- PHP_FE(ocifreestatement, NULL)
- PHP_FE(ociinternaldebug, NULL)
- PHP_FE(ocinumcols, NULL)
- PHP_FE(ociparse, NULL)
- PHP_FE(ocinewcursor, NULL)
- PHP_FE(ociresult, NULL)
- PHP_FE(ociserverversion, NULL)
- PHP_FE(ocistatementtype, NULL)
- PHP_FE(ocirowcount, NULL)
- PHP_FE(ocilogoff, NULL)
- PHP_FE(ocilogon, NULL)
- PHP_FE(ocinlogon, NULL)
- PHP_FE(ociplogon, NULL)
- PHP_FE(ocierror, NULL)
- PHP_FE(ocifreedesc, NULL)
- PHP_FE(ocisavelob, NULL)
- PHP_FE(ocisavelobfile, NULL)
- PHP_FE(ociloadlob, NULL)
- PHP_FE(ocicommit, NULL)
- PHP_FE(ocirollback, NULL)
- PHP_FE(ocinewdescriptor, NULL)
- PHP_FE(ocisetprefetch, NULL)
- {NULL,NULL,NULL}
-};
-
-static zend_function_entry php_oci_lob_class_functions[] = {
- PHP_FALIAS(load, ociloadlob, NULL)
- PHP_FALIAS(save, ocisavelob, NULL)
- PHP_FALIAS(savefile,ocisavelobfile, NULL)
- PHP_FALIAS(free, ocifreedesc, NULL)
- {NULL,NULL,NULL}
-};
-
-php3_module_entry oci8_module_entry = {
- "Oracle-OCI8", /* extension name */
- php_oci_functions, /* extension function list */
- PHP_MINIT(oci), /* extension-wide startup function */
- PHP_MSHUTDOWN(oci), /* extension-wide shutdown function */
- PHP_RINIT(oci), /* per-request startup function */
- PHP_RSHUTDOWN(oci), /* per-request shutdown function */
- PHP_MINFO(oci), /* information function */
- STANDARD_MODULE_PROPERTIES
-};
-
-/* }}} */
-/* {{{ debug malloc/realloc/free */
-
-#if OCI_USE_EMALLOC
-CONST dvoid *ocimalloc(dvoid *ctx, size_t size)
-{
- dvoid *ret;
- ret = (dvoid *)malloc(size);
- oci_debug("ocimalloc(%d) = %08x", size,ret);
- return ret;
-}
-
-CONST dvoid *ocirealloc(dvoid *ctx, dvoid *ptr, size_t size)
-{
- dvoid *ret;
- oci_debug("ocirealloc(%08x, %d)", ptr, size);
- ret = (dvoid *)realloc(ptr, size);
- return ptr;
-}
-
-CONST void ocifree(dvoid *ctx, dvoid *ptr)
-{
- oci_debug("ocifree(%08x)", ptr);
- free(ptr);
-}
-#endif
-
-/* }}} */
-/* {{{ startup, shutdown and info functions */
-
-
-#ifdef ZTS
-static void php_oci_init_globals(php_oci_globals *oci_globals)
-{
- OCI(user_num) = 1000;
- OCI(server_num) = 2000;
-
- OCI(user) = malloc(sizeof(HashTable));
- zend_hash_init(OCI(user), 13, NULL, NULL, 1);
-
- OCI(server) = malloc(sizeof(HashTable));
- zend_hash_init(OCI(server), 13, NULL, NULL, 1);
-
- OCIEnvInit(&OCI(pEnv), OCI_DEFAULT, 0, NULL);
- OCIHandleAlloc(OCI(pEnv),
- (dvoid **)&OCI(pError),
- OCI_HTYPE_ERROR,
- 0,
- NULL);
-
-}
-#endif
-
-PHP_MINIT_FUNCTION(oci)
-{
- zend_class_entry oci_lob_class_entry;
- ELS_FETCH();
-
-#ifdef ZTS
- oci_globals_id = ts_allocate_id(sizeof(php_oci_globals), php_oci_init_globals, NULL);
-#else
- OCI(user_num) = 1000;
- OCI(server_num) = 2000;
-
- OCI(user) = malloc(sizeof(HashTable));
- zend_hash_init(OCI(user), 13, NULL, NULL, 1);
-
- OCI(server) = malloc(sizeof(HashTable));
- zend_hash_init(OCI(server), 13, NULL, NULL, 1);
-
- OCIEnvInit(&OCI(pEnv), OCI_DEFAULT, 0, NULL);
- OCIHandleAlloc(OCI(pEnv),
- (dvoid **)&OCI(pError),
- OCI_HTYPE_ERROR,
- 0,
- NULL);
-
-#endif
-
- le_conn = register_list_destructors(_oci_close_conn, NULL);
- le_stmt = register_list_destructors(_oci_free_stmt, NULL);
-
- INIT_CLASS_ENTRY(oci_lob_class_entry, "OCI-Lob", php_oci_lob_class_functions);
-
- oci_lob_class_entry_ptr = register_internal_class(&oci_lob_class_entry);
-
-/* thies@digicol.de 990203 i do not think that we will need all of them - just in here for completeness for now! */
- REGISTER_LONG_CONSTANT("OCI_DEFAULT",OCI_DEFAULT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("OCI_DESCRIBE_ONLY",OCI_DESCRIBE_ONLY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("OCI_COMMIT_ON_SUCCESS",OCI_COMMIT_ON_SUCCESS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("OCI_EXACT_FETCH",OCI_EXACT_FETCH, CONST_CS | CONST_PERSISTENT);
-
-/* for OCIBindByName (real "oci" names + short "php" names*/
- REGISTER_LONG_CONSTANT("SQLT_BFILEE",SQLT_BFILEE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SQLT_CFILEE",SQLT_CFILEE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SQLT_CLOB",SQLT_CLOB, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SQLT_BLOB",SQLT_BLOB, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SQLT_RDD",SQLT_RDD, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("OCI_B_BFILE",SQLT_BFILEE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("OCI_B_CFILEE",SQLT_CFILEE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("OCI_B_CLOB",SQLT_CLOB, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("OCI_B_BLOB",SQLT_BLOB, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("OCI_B_ROWID",SQLT_RDD, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("OCI_B_CURSOR",SQLT_RSET, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("OCI_B_BIN",SQLT_BIN, CONST_CS | CONST_PERSISTENT);
-
-/* for OCIFetchInto & OCIResult */
- REGISTER_LONG_CONSTANT("OCI_ASSOC",OCI_ASSOC, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("OCI_NUM",OCI_NUM, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("OCI_BOTH",OCI_BOTH, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("OCI_RETURN_NULLS",OCI_RETURN_NULLS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("OCI_RETURN_LOBS",OCI_RETURN_LOBS, CONST_CS | CONST_PERSISTENT);
-
-/* for OCINewDescriptor (real "oci" names + short "php" names*/
- REGISTER_LONG_CONSTANT("OCI_DTYPE_FILE",OCI_DTYPE_FILE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("OCI_DTYPE_LOB",OCI_DTYPE_LOB, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("OCI_DTYPE_ROWID",OCI_DTYPE_ROWID, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("OCI_D_FILE",OCI_DTYPE_FILE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("OCI_D_LOB",OCI_DTYPE_LOB, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("OCI_D_ROWID",OCI_DTYPE_ROWID, CONST_CS | CONST_PERSISTENT);
-
-#if OCI_USE_EMALLOC
- OCIInitialize(OCI_DEFAULT, NULL, ocimalloc, ocirealloc, ocifree);
-#else
- OCIInitialize(OCI_DEFAULT, NULL, NULL, NULL, NULL);
-#endif
-
- return SUCCESS;
-}
-
-/* ----------------------------------------------------------------- */
-
-
-PHP_RINIT_FUNCTION(oci)
-{
- OCILS_FETCH();
-
- /* XXX NYI
- OCI(num_links) =
- OCI(num_persistent);
- */
-
- OCI(debug_mode) = 0; /* start "fresh" */
-
- oci_debug("php3_rinit_oci8");
-
- return SUCCESS;
-}
-
-static int _user_pcleanup(oci_session *session)
-{
- _oci_close_user(session);
-
- return 1;
-}
-
-static int _server_pcleanup(oci_server *server)
-{
- _oci_close_server(server);
-
- return 1;
-}
-
-PHP_MSHUTDOWN_FUNCTION(oci)
-{
- OCILS_FETCH();
-
- oci_debug("php3_mshutdown_oci8");
-
- zend_hash_apply(OCI(user),(int (*)(void *))_user_pcleanup);
- zend_hash_apply(OCI(server),(int (*)(void *))_server_pcleanup);
-
- zend_hash_destroy(OCI(user));
- zend_hash_destroy(OCI(server));
-
- free(OCI(user));
- free(OCI(server));
-
- OCIHandleFree((dvoid *)OCI(pEnv), OCI_HTYPE_ENV);
-
- return SUCCESS;
-}
-
-static int _stmt_cleanup(list_entry *le)
-{
- oci_statement *statement;
-
- if (le->type == le_stmt) {
- statement = (oci_statement *) le->ptr;
-
- if (!statement->conn->open) {
- return 1;
- }
- }
-
- return 0;
-}
-
-static int _user_cleanup(oci_session *session)
-{
- if (session->persistent)
- return 0;
-
- _oci_close_user(session);
-
- return 1;
-}
-
-static int _server_cleanup(oci_server *server)
-{
- if (server->persistent)
- return 0;
-
- _oci_close_server(server);
-
- return 1;
-}
-
-PHP_RSHUTDOWN_FUNCTION(oci)
-{
- OCILS_FETCH();
-
- oci_debug("php3_rshutdown_oci8");
-
- zend_hash_apply(OCI(user),(int (*)(void *))_user_cleanup);
- zend_hash_apply(OCI(server),(int (*)(void *))_server_cleanup);
-
- /* XXX free all statements, rollback all outstanding transactions */
-
- return SUCCESS;
-}
-
-
-PHP_MINFO_FUNCTION(oci)
-{
-#if !(WIN32|WINNT)
- php_printf("Oracle version: %s<br>\n"
- "Compile-time ORACLE_HOME: %s<br>\n"
- "Libraries used: %s",
- PHP_ORACLE_VERSION, PHP_ORACLE_HOME, PHP_ORACLE_LIBS);
-#endif
-}
-
-/* }}} */
-/* {{{ _oci_define_dtor() */
-
-static int
-_oci_define_dtor(void *data)
-{
- oci_define *define = (oci_define *) data;
-
- oci_debug("_oci_define_dtor: %s",define->name);
-
- if (define->name) {
- efree(define->name);
- define->name = 0;
- }
- return 1;
-}
-
-/* }}} */
-/* {{{ _oci_column_dtor() */
-
-static int
-_oci_column_dtor(void *data)
-{
- oci_out_column *column = (oci_out_column *) data;
-
- /*
- oci_debug("_oci_column_dtor: %s",column->name);
- */
-
- if (column->data) {
- if (column->is_descr) {
- zend_hash_index_del(column->statement->conn->descriptors,(int) column->data);
- } else {
- if (column->data) {
- efree(column->data);
- }
- }
- }
-
- if (column->name) {
- efree(column->name);
- }
-
- return 1;
-}
-
-/* }}} */
-/* {{{ _oci_free_stmt() */
-
-static void
-_oci_free_stmt(oci_statement *statement)
-{
- if (! statement) {
- return;
- }
-
- oci_debug("_oci_free_stmt: id=%d last_query=\"%s\"",statement->id,SAFE_STRING(statement->last_query));
-
- if (statement->pStmt) {
- OCIHandleFree(statement->pStmt, OCI_HTYPE_STMT);
- statement->pStmt = 0;
- }
-
- if (statement->pError) {
- OCIHandleFree(statement->pError, OCI_HTYPE_ERROR);
- statement->pError = 0;
- }
-
- if (statement->last_query) {
- efree(statement->last_query);
- }
-
- if (statement->columns) {
- zend_hash_destroy(statement->columns);
- efree(statement->columns);
- }
-
- if (statement->binds) {
- zend_hash_destroy(statement->binds);
- efree(statement->binds);
- }
-
- if (statement->defines) {
- zend_hash_destroy(statement->defines);
- efree(statement->defines);
- }
-
- efree(statement);
-}
-
-/* }}} */
-/* {{{ _oci_close_conn() */
-
-static void
-_oci_close_conn(oci_connection *connection)
-{
- if (! connection) {
- return;
- }
-
- /*
- as the connection is "only" a in memory service context we do not disconnect from oracle.
- */
-
- oci_debug("_oci_close_conn: id=%d",connection->id);
-
- if (connection->descriptors) {
- zend_hash_destroy(connection->descriptors);
- efree(connection->descriptors);
- }
-
- if (connection->pServiceContext) {
- OCIHandleFree((dvoid *) connection->pServiceContext, (ub4) OCI_HTYPE_SVCCTX);
- }
-
- if (connection->pError) {
- OCIHandleFree((dvoid *) connection->pError, (ub4) OCI_HTYPE_ERROR);
- }
-
- efree(connection);
-}
-
-/* }}} */
-/* {{{ oci_error() */
-
-static ub4
-oci_error(OCIError *err_p, char *what, sword status)
-{
- text errbuf[512];
- sb4 errcode = 0;
-
- switch (status) {
- case OCI_SUCCESS:
- break;
- case OCI_SUCCESS_WITH_INFO:
- php_error(E_WARNING, "%s: OCI_SUCCESS_WITH_INFO", what);
- break;
- case OCI_NEED_DATA:
- php_error(E_WARNING, "%s: OCI_NEED_DATA", what);
- break;
- case OCI_NO_DATA:
- php_error(E_WARNING, "%s: OCI_NO_DATA", what);
- break;
- case OCI_ERROR:
- OCIErrorGet(err_p, (ub4)1, NULL, &errcode, errbuf,
- (ub4)sizeof(errbuf), (ub4)OCI_HTYPE_ERROR);
- php_error(E_WARNING, "%s: %s", what, errbuf);
- break;
- case OCI_INVALID_HANDLE:
- php_error(E_WARNING, "%s: OCI_INVALID_HANDLE", what);
- break;
- case OCI_STILL_EXECUTING:
- php_error(E_WARNING, "%s: OCI_STILL_EXECUTING", what);
- break;
- case OCI_CONTINUE:
- php_error(E_WARNING, "%s: OCI_CONTINUE", what);
- break;
- default:
- break;
- }
- return errcode;
-}
-
-/* }}} */
-/* {{{ NYI oci_ping() */
-
-#if 0 /* XXX NYI */
-/* test if a connection is still alive and return 1 if it is */
-static int oci_ping(oci_connection *conn)
-{
- /* XXX FIXME not yet implemented */
- return 1;
-}
-#endif
-
-/* }}} */
-
-/************************* INTERNAL FUNCTIONS *************************/
-
-/* {{{ oci_debug() */
-
-static void oci_debug(const char *format,...)
-{
- OCILS_FETCH();
-
- if (OCI(debug_mode)) {
- char buffer[1024];
- va_list args;
-
- va_start(args, format);
- vsnprintf(buffer, sizeof(buffer)-1, format, args);
- va_end(args);
- buffer[sizeof(buffer)-1] = '\0';
- if (php3_header()) {
- php_printf("OCIDebug: %s<br>\n", buffer);
- }
- }
-}
-
-/* }}} */
-/* {{{ oci_get_conn() */
-
-static oci_connection *
-oci_get_conn(int conn_ind, const char *func, HashTable *list)
-{
- int type;
- oci_connection *connection;
-
- connection = (oci_connection *)php3_list_find(conn_ind, &type);
- if (!connection || !OCI_CONN_TYPE(type)) {
- php_error(E_WARNING, "%s: invalid connection %d", func, conn_ind);
- return (oci_connection *)NULL;
- }
-
- if (connection->open) {
- return connection;
- } else {
- /* _oci_close_conn(connection); be careful with this!! */
- return (oci_connection *)NULL;
- }
-}
-
-/* }}} */
-/* {{{ oci_get_stmt() */
-
-static oci_statement *
-oci_get_stmt(int stmt_ind, const char *func, HashTable *list)
-{
- int type;
- oci_statement *statement;
-
- statement = (oci_statement *)php3_list_find(stmt_ind, &type);
- if (!statement || !OCI_STMT_TYPE(type)) {
- php_error(E_WARNING, "%s: invalid statement %d", func, stmt_ind);
- return (oci_statement *)NULL;
- }
-
- if (statement->conn->open) {
- return statement;
- } else {
- /* _oci_free_stmt(statement); be careful with this!! */
- return (oci_statement *)NULL;
- }
-}
-
-/* }}} */
-/* {{{ oci_get_col() */
-
-static oci_out_column *
-oci_get_col(oci_statement *statement, int col, pval *pval, char *func)
-{
- oci_out_column *outcol = NULL;
- int i;
-
- if (statement->columns == 0) { /* we release the columns at the end of a fetch */
- return NULL;
- }
-
- if (pval) {
- if (pval->type == IS_STRING) {
- for (i = 0; i < statement->ncolumns; i++) {
- outcol = oci_get_col(statement, i + 1, 0, func);
- if (outcol == NULL) {
- continue;
- } else if (((int) outcol->name_len == pval->value.str.len)
- && (! strncmp(outcol->name,pval->value.str.val,pval->value.str.len))) {
- return outcol;
- }
- }
- } else {
- convert_to_long(pval);
- return oci_get_col(statement,pval->value.lval,0,func);
- }
- } else if (col != -1) {
- if (zend_hash_index_find(statement->columns, col, (void **)&outcol) == FAILURE) {
- php_error(E_WARNING, "%s: invalid column %d", func, col);
- return NULL;
- }
- return outcol;
- }
-
- return NULL;
-}
-
-/* }}} */
-/* {{{ oci_make_pval() */
-
-static int
-oci_make_pval(pval *value,oci_statement *statement,oci_out_column *column, char *func, int mode)
-{
- size_t size;
- oci_descriptor *descr;
- ub4 loblen;
- char *buffer;
-
- if (column->indicator || column->retcode)
- if ((column->indicator != -1) && (column->retcode != 1405))
- oci_debug("oci_make_pval: %16s,retlen = %4d,retlen4 = %d,storage_size4 = %4d,indicator %4d, retcode = %4d",
- column->name,column->retlen,column->retlen4,column->storage_size4,column->indicator,column->retcode);
-
- if (column->indicator == -1) { /* column is NULL */
- var_reset(value); /* XXX we NEED to make sure that there's no data attached to this yet!!! */
- return 0;
- }
-
- if (column->is_cursor) { /* REFCURSOR -> simply return the statement id */
- value->type = IS_LONG;
- value->value.lval = column->stmtid;
- } else if (column->is_descr) {
- if ((column->data_type != SQLT_RDD) && (mode & OCI_RETURN_LOBS)) {
- /* OCI_RETURN_LOBS means that we want the content of the LOB back instead of the locator */
-
- if (zend_hash_index_find(statement->conn->descriptors,(int) column->data, (void **)&descr) == FAILURE) {
- php_error(E_WARNING, "unable to find my descriptor %d",column->data);
- return -1;
- }
-
- loblen = oci_loadlob(statement->conn,descr,&buffer);
-
- if (loblen >= 0) {
- value->type = IS_STRING;
- value->value.str.len = loblen;
- value->value.str.val = buffer;
- } else {
- var_reset(value);
- }
- } else { /* return the locator */
- object_init_ex(value, oci_lob_class_entry_ptr);
- add_property_long(value, "connection", statement->conn->id);
- add_property_long(value, "descriptor", (long) column->data);
- }
- } else {
- switch (column->retcode) {
- case 0: /* intact value */
- /*
- oci_debugcol(column,"OK");
- */
- if (column->piecewise) {
- size = column->retlen4;
- } else {
- size = column->retlen;
- }
- break;
-
- default: /* XXX we SHOULD maybe have a different behaviour for unknown results! */
- var_reset(value);
- return 0;
- }
-
- value->type = IS_STRING;
- value->value.str.len = size;
- value->value.str.val = estrndup(column->data,size);
- }
-
- return 0;
-}
-
-/* }}} */
-/* {{{ oci_setprefetch() */
-
-static int
-oci_setprefetch(oci_statement *statement,int size)
-{
- ub4 prefetch;
-
- prefetch = size * 1024;
- statement->error =
- oci_error(statement->pError,
- "OCIAttrSet OCI_ATTR_PREFETCH_MEMORY",
- OCIAttrSet(statement->pStmt,
- OCI_HTYPE_STMT,
- &prefetch,
- 0,
- OCI_ATTR_PREFETCH_MEMORY,
- statement->pError));
- prefetch = size;
- statement->error =
- oci_error(statement->pError,
- "OCIAttrSet OCI_ATTR_PREFETCH_MEMORY",
- OCIAttrSet(statement->pStmt,
- OCI_HTYPE_STMT,
- &prefetch,
- 0,
- OCI_ATTR_PREFETCH_ROWS,
- statement->pError));
-
- return 1;
-}
-
-/* }}} */
-/* {{{ oci_parse() */
-
-static int
-oci_parse(oci_connection *connection, char *query, int len, HashTable *list)
-{
- oci_statement *statement;
- OCILS_FETCH();
-
- statement = ecalloc(1,sizeof(oci_statement));
- OCIHandleAlloc(OCI(pEnv),
- (dvoid **)&statement->pStmt,
- OCI_HTYPE_STMT,
- 0,
- NULL);
- OCIHandleAlloc(OCI(pEnv),
- (dvoid **)&statement->pError,
- OCI_HTYPE_ERROR,
- 0,
- NULL);
-
- if (len > 0) {
- connection->error =
- oci_error(connection->pError,
- "OCIParse",
- OCIStmtPrepare(statement->pStmt,
- connection->pError,
- (text*)query,
- len,
- OCI_NTV_SYNTAX,
- OCI_DEFAULT));
- if (connection->error) {
- /* XXX loose memory */
- return 0;
- }
- }
-
- if (query) {
- statement->last_query = estrdup(query);
- }
- statement->conn = connection;
- statement->id = php3_list_insert(statement,le_stmt);
-
- oci_debug("oci_parse \"%s\" id=%d conn=%d",
- SAFE_STRING(query),
- statement->id,
- statement->conn->id);
-
- return statement->id;
-}
-
-/* }}} */
-/* {{{ oci_execute() */
-
-static int
-oci_execute(oci_statement *statement, char *func,ub4 mode, HashTable *list)
-{
- oci_out_column *outcol;
- oci_out_column column;
- OCIParam *param = 0;
- text *colname;
- ub4 counter;
- ub2 define_type;
- ub2 stmttype;
- ub4 iters;
- ub4 colcount;
- ub2 dynamic;
- dvoid *buf;
- oci_descriptor *pdescr, descr;
- OCILS_FETCH();
-
- statement->error =
- oci_error(statement->pError,
- "OCIAttrGet OCI_HTYPE_STMT/OCI_ATTR_STMT_TYPE",
- OCIAttrGet((dvoid *)statement->pStmt,
- OCI_HTYPE_STMT,
- (ub2 *)&stmttype,
- (ub4 *)0,
- OCI_ATTR_STMT_TYPE,
- statement->pError));
-
- if (statement->error) {
- return 0;
- }
-
- if (stmttype == OCI_STMT_SELECT) {
- iters = 0;
- } else {
- iters = 1;
- }
-
- if (statement->last_query) { /* if we execute refcursors we don't have a query and we don't want to execute!!! */
- statement->error =
- oci_error(statement->pError,
- "OCIStmtExecute",
- OCIStmtExecute(statement->conn->pServiceContext,
- statement->pStmt,
- statement->pError,
- iters,
- 0,
- NULL,
- NULL,
- mode));
-
- switch (statement->error) {
- case 0:
- break;
-
- case 3113: /* ORA-03113: end-of-file on communication channel */
- statement->conn->open = 0;
- statement->conn->session->open = 0;
- statement->conn->session->server->open = 0;
- return 0;
- break;
-
- default:
- return 0;
- break;
- }
- }
-
- if (stmttype == OCI_STMT_SELECT && (statement->executed == 0)) {
- /* we only need to do the define step is this very statement is executed the first time! */
- statement->executed++;
-
- statement->columns = emalloc(sizeof(HashTable));
- if (!statement->columns ||
- zend_hash_init(statement->columns, 13, NULL,_oci_column_dtor, 0) == FAILURE) {
- /* out of memory */
- return 0;
- }
-
- OCIHandleAlloc(
- OCI(pEnv),
- (dvoid **)&param,
- OCI_DTYPE_PARAM,
- 0,
- NULL);
-
-
- counter = 1;
-
- statement->error =
- oci_error(statement->pError,
- "OCIAttrGet OCI_HTYPE_STMT/OCI_ATTR_PARAM_COUNT",
- OCIAttrGet((dvoid *)statement->pStmt,
- OCI_HTYPE_STMT,
- (dvoid *)&colcount,
- (ub4 *)0,
- OCI_ATTR_PARAM_COUNT,
- statement->pError));
- if (statement->error) {
- return 0; /* XXX we loose memory!!! */
- }
-
- statement->ncolumns = colcount;
-
- for (counter = 1; counter <= colcount; counter++) {
- memset(&column,0,sizeof(oci_out_column));
-
- if (zend_hash_index_update(statement->columns, counter, &column,
- sizeof(oci_out_column), (void**) &outcol) == FAILURE) {
- efree(statement->columns);
- /* out of memory */
- return 0;
- }
-
- outcol->statement = statement;
-
- statement->error =
- oci_error(statement->pError,
- "OCIParamGet OCI_HTYPE_STMT",
- OCIParamGet(
- (dvoid *)statement->pStmt,
- OCI_HTYPE_STMT,
- statement->pError,
- (dvoid*)&param,
- counter));
- if (statement->error) {
- return 0; /* XXX we loose memory!!! */
- }
-
- statement->error =
- oci_error(statement->pError,
- "OCIAttrGet OCI_DTYPE_PARAM/OCI_ATTR_DATA_TYPE",
- OCIAttrGet((dvoid *)param,
- OCI_DTYPE_PARAM,
- (dvoid *)&outcol->data_type,
- (ub4 *)0,
- OCI_ATTR_DATA_TYPE,
- statement->pError));
- if (statement->error) {
- return 0; /* XXX we loose memory!!! */
- }
-
-
- statement->error =
- oci_error(statement->pError,
- "OCIAttrGet OCI_DTYPE_PARAM/OCI_ATTR_DATA_SIZE",
- OCIAttrGet((dvoid *)param,
- OCI_DTYPE_PARAM,
- (dvoid *)&outcol->data_size,
- (dvoid *)0,
- OCI_ATTR_DATA_SIZE,
- statement->pError));
- if (statement->error) {
- return 0; /* XXX we loose memory!!! */
- }
-
- outcol->storage_size4 = outcol->data_size;
- outcol->retlen = outcol->data_size;
-
- statement->error =
- oci_error(statement->pError,
- "OCIAttrGet OCI_DTYPE_PARAM/OCI_ATTR_NAME",
- OCIAttrGet((dvoid *)param,
- OCI_DTYPE_PARAM,
- (dvoid **)&colname, /* XXX this string is NOT zero terminated!!!! */
- (ub4 *)&outcol->name_len,
- (ub4)OCI_ATTR_NAME,
- statement->pError));
- if (statement->error) {
- return 0; /* XXX we loose memory!!! */
- }
-
- outcol->name = estrndup((char*) colname,outcol->name_len);
-
- /* find a user-setted define */
- if (statement->defines) {
- zend_hash_find(statement->defines,outcol->name,outcol->name_len,(void **) &outcol->define);
- }
-
- buf = 0;
- switch (outcol->data_type) {
- case SQLT_RSET:
- outcol->stmtid = oci_parse(statement->conn,0,0,list);
- outcol->pstmt = oci_get_stmt(outcol->stmtid, "OCIExecute",list);
-
- define_type = outcol->data_type;
- outcol->is_cursor = 1;
- outcol->storage_size4 = -1;
- outcol->retlen = -1;
- dynamic = OCI_DEFAULT;
- buf = &(outcol->pstmt->pStmt);
- break;
-
- case SQLT_RDD: /* ROWID */
- case SQLT_BLOB: /* binary LOB */
- case SQLT_CLOB: /* character LOB */
- case SQLT_BFILE: /* binary file LOB */
- define_type = outcol->data_type;
- outcol->is_descr = 1;
- outcol->storage_size4 = -1;
- dynamic = OCI_DEFAULT;
-
- if (outcol->data_type == SQLT_BFILE) {
- descr.type = OCI_DTYPE_FILE;
- } else if (outcol->data_type == SQLT_RDD ) {
- descr.type = OCI_DTYPE_ROWID;
- } else {
- descr.type = OCI_DTYPE_LOB;
- }
-
- OCIDescriptorAlloc(OCI(pEnv),
- (dvoid *)&(descr.ocidescr),
- descr.type,
- (size_t) 0,
- (dvoid **) 0);
-
- zend_hash_index_update(statement->conn->descriptors,
- statement->conn->descriptors_count,
- &descr,
- sizeof(oci_descriptor),
- (void **)&pdescr);
-
- outcol->data = (void *) outcol->statement->conn->descriptors_count++;
- buf = outcol->pdescr = pdescr;
- oci_debug("OCIExecute: new descriptor for %s",outcol->name);
- break;
-
- case SQLT_LNG:
- case SQLT_LBI:
- if (outcol->data_type == SQLT_LBI) {
- define_type = SQLT_BIN;
- } else {
- define_type = SQLT_STR;
- }
- outcol->storage_size4 = OCI_MAX_DATA_SIZE;
- outcol->piecewise = 1;
- dynamic = OCI_DYNAMIC_FETCH;
- break;
-
- case SQLT_BIN:
- default:
- define_type = SQLT_STR;
- if ((outcol->data_type == SQLT_DAT) || (outcol->data_type == SQLT_NUM)) {
- outcol->storage_size4 = 512; /* XXX this should fit "most" NLS date-formats and Numbers */
- } else {
- outcol->storage_size4++; /* add one for string terminator */
- }
- if (outcol->data_type == SQLT_BIN) {
- outcol->storage_size4 *= 3;
- }
- dynamic = OCI_DEFAULT;
- buf = outcol->data = (text *) emalloc(outcol->storage_size4);
- break;
- }
-
- if (dynamic == OCI_DYNAMIC_FETCH) {
- statement->error =
- oci_error(statement->pError,
- "OCIDefineByPos",
- OCIDefineByPos(statement->pStmt, /* IN/OUT handle to the requested SQL query */
- (OCIDefine **)&outcol->pDefine,/* IN/OUT pointer to a pointer to a define handle */
- statement->pError, /* IN/OUT An error handle */
- counter, /* IN position in the select list */
- (dvoid *)NULL, /* IN/OUT pointer to a buffer */
- outcol->storage_size4, /* IN The size of each valuep buffer in bytes */
- define_type, /* IN The data type */
- (dvoid *)&outcol->indicator, /* IN pointer to an indicator variable or arr */
- (ub2 *)NULL, /* IN/OUT Pointer to array of length of data fetched */
- (ub2 *)NULL, /* OUT Pointer to array of column-level return codes */
- OCI_DYNAMIC_FETCH)); /* IN mode (OCI_DEFAULT, OCI_DYNAMIC_FETCH) */
- } else {
- statement->error =
- oci_error(statement->pError,
- "OCIDefineByPos",
- OCIDefineByPos(statement->pStmt, /* IN/OUT handle to the requested SQL query */
- (OCIDefine **)&outcol->pDefine,/* IN/OUT pointer to a pointer to a define handle */
- statement->pError, /* IN/OUT An error handle */
- counter, /* IN position in the select list */
- (dvoid *)buf, /* IN/OUT pointer to a buffer */
- outcol->storage_size4, /* IN The size of each valuep buffer in bytes */
- define_type, /* IN The data type */
- (dvoid *)&outcol->indicator, /* IN pointer to an indicator variable or arr */
- (ub2 *)&outcol->retlen, /* IN/OUT Pointer to array of length of data fetched */
- (ub2 *)&outcol->retcode, /* OUT Pointer to array of column-level return codes */
- OCI_DEFAULT)); /* IN mode (OCI_DEFAULT, OCI_DYNAMIC_FETCH) */
- }
- if (statement->error) {
- return 0; /* XXX we loose memory!!! */
- }
- }
- }
-
- return 1;
-}
-
-/* }}} */
-/* {{{ oci_fetch() */
-
-static int
-oci_fetch(oci_statement *statement, ub4 nrows, char *func)
-{
- int i;
- oci_out_column *column;
-
- /* first we need to reset our piecewise fetch-infos */
- for (i = 0; i < statement->ncolumns; i++) {
- column = oci_get_col(statement, i + 1, 0, "OCIFetch");
- if (column == NULL) { /* should not happen... */
- continue;
- }
-
- if (column->piecewise) {
- column->retlen4 = 0;
- }
- }
-
- statement->error =
- OCIStmtFetch(statement->pStmt,
- statement->pError, nrows,
- OCI_FETCH_NEXT,
- OCI_DEFAULT);
-
- if ((statement->error == OCI_NO_DATA) || (nrows == 0)) {
- /* XXX this is needed for REFCURSORS! */
- if (statement->columns) {
- zend_hash_destroy(statement->columns);
- efree(statement->columns);
- statement->columns = 0;
- }
- statement->executed = 0;
-
- statement->error = 0; /* OCI_NO_DATA is NO error for us!!! */
-
- return 0;
- }
-
- while (statement->error == OCI_NEED_DATA) {
- for (i = 0; i < statement->ncolumns; i++) {
- column = oci_get_col(statement, i + 1, 0, "OCIFetch");
- if (column->piecewise) {
- if (! column->data) {
- column->data = (text *) emalloc(OCI_PIECE_SIZE);
- } else {
- column->data = erealloc(column->data,column->retlen4 + OCI_PIECE_SIZE);
- }
-
- column->cb_retlen = OCI_PIECE_SIZE;
-
- OCIStmtSetPieceInfo((void *) column->pDefine,
- OCI_HTYPE_DEFINE,
- statement->pError,
- ((char*)column->data) + column->retlen4,
- &(column->cb_retlen),
- OCI_NEXT_PIECE,
- NULL,
- NULL);
- }
- }
-
- statement->error =
- OCIStmtFetch(statement->pStmt,
- statement->pError, nrows,
- OCI_FETCH_NEXT,
- OCI_DEFAULT);
-
- for (i = 0; i < statement->ncolumns; i++) {
- column = oci_get_col(statement, i + 1, 0, "OCIFetch");
- if (column->piecewise) {
- column->retlen4 += column->cb_retlen;
- }
- }
- }
-
- if (statement->error == OCI_SUCCESS_WITH_INFO || statement->error == OCI_SUCCESS) {
- /* do the stuff needed for OCIDefineByName */
- for (i = 0; i < statement->ncolumns; i++) {
- column = oci_get_col(statement, i + 1, 0, "OCIFetch");
- if (column == NULL) { /* should not happen... */
- continue;
- }
-
- if (! column->define) {
- continue;
- }
-
- pval_destructor(column->define->pval);
-
- oci_make_pval(column->define->pval,statement,column,"OCIFetch",0);
- }
-
- return 1;
- }
-
- oci_error(statement->pError, func, statement->error);
-
- return 0;
-}
-
-/* }}} */
-/* {{{ oci_loadlob() */
-static ub4
-oci_loadlob(oci_connection *connection, oci_descriptor *mydescr, char **buffer)
-{
- ub4 loblen;
-
- connection->error =
- OCILobGetLength(connection->pServiceContext,
- connection->pError,
- mydescr->ocidescr,
- &loblen);
-
- if (connection->error) {
- oci_error(connection->pError, "OCILobGetLength", connection->error);
- return -1;
- }
-
- *buffer = emalloc(loblen + 1);
-
- if (! buffer) {
- return -1;
- }
-
- if (loblen == 0) {
- (*buffer)[ 0 ] = 0;
- return 0;
- }
-
- if (mydescr->type == OCI_DTYPE_FILE) {
- connection->error =
- OCILobFileOpen(connection->pServiceContext,
- connection->pError,
- mydescr->ocidescr,
- OCI_FILE_READONLY);
- if (connection->error) {
- oci_error(connection->pError, "OCILobFileOpen",connection->error);
- efree(buffer);
- return -1;
- }
- }
-
- connection->error =
- OCILobRead(connection->pServiceContext,
- connection->pError,
- mydescr->ocidescr,
- &loblen, /* IN/OUT bytes toread/read */
- 1, /* offset (starts with 1) */
- (dvoid *) *buffer,
- loblen, /* size of buffer */
- (dvoid *)0,
- (OCICallbackLobRead) 0, /* callback... */
- (ub2) 0, /* The character set ID of the buffer data. */
- (ub1) SQLCS_IMPLICIT); /* The character set form of the buffer data. */
-
- if (connection->error) {
- oci_error(connection->pError, "OCILobRead", connection->error);
- efree(buffer);
- return -1;
- }
-
- if (mydescr->type == OCI_DTYPE_FILE) {
- connection->error =
- OCILobFileClose(connection->pServiceContext,
- connection->pError,
- mydescr->ocidescr);
- if (connection->error) {
- oci_error(connection->pError, "OCILobFileClose", connection->error);
- efree(buffer);
- return -1;
- }
- }
-
- (*buffer)[ loblen ] = 0;
-
- oci_debug("OCIloadlob: size=%d",loblen);
-
- return loblen;
-}
-
-/* }}} */
-/* {{{ oci_failover_callback() */
-#if 0 /* not needed yet ! */
-static sb4
-oci_failover_callback(dvoid *svchp,
- dvoid* envhp,
- dvoid *fo_ctx,
- ub4 fo_type,
- ub4 fo_event)
-{
- /*
- this stuff is from an oci sample - it will get cleaned up as soon as i understand it!!! (thies@digicol.de 990420)
- right now i cant get oracle to even call it;-(((((((((((
- */
-
- switch (fo_event)
- {
- case OCI_FO_BEGIN:
- {
- printf(" Failing Over ... Please stand by \n");
- printf(" Failover type was found to be %s \n",
- ((fo_type==OCI_FO_NONE) ? "NONE"
- :(fo_type==OCI_FO_SESSION) ? "SESSION"
- :(fo_type==OCI_FO_SELECT) ? "SELECT"
- : "UNKNOWN!"));
- printf(" Failover Context is :%s\n",
- (fo_ctx?(char *)fo_ctx:"NULL POINTER!"));
- break;
- }
-
- case OCI_FO_ABORT:
- {
- printf(" Failover aborted. Failover will not take place.\n");
- break;
- }
-
- case OCI_FO_END:
- {
- printf(" Failover ended ...resuming services\n");
- break;
- }
-
- case OCI_FO_REAUTH:
- {
- printf(" Failed over user. Resuming services\n");
-
- /* Application can check the OCI_ATTR_SESSION attribute of
- the service handle to find out the user being
- re-authenticated.
-
- After this, the application can replay any ALTER SESSION
- commands associated with this session. These must have
- been saved by the application in the fo_ctx
- */
- break;
- }
-
-
- case OCI_FO_ERROR:
- {
- printf(" Failover error gotten. Sleeping...\n");
- sleep(3);
- /* cannot find this blody define !!! return OCI_FO_RETRY; */
- break;
- }
-
- default:
- {
- printf("Bad Failover Event: %ld.\n", fo_event);
- break;
- }
- }
-
- return 0;
-}
-#endif
-/* }}} */
-/* {{{ oci_bind_in_callback() */
-
-static sb4
-oci_bind_in_callback(dvoid *ictxp, /* context pointer */
- OCIBind *bindp, /* bind handle */
- ub4 iter, /* 0-based execute iteration value */
- ub4 index, /* index of current array for PL/SQL or
- row index for SQL */
- dvoid **bufpp, /* pointer to data */
- ub4 *alenp, /* size after value/piece has been read */
- ub1 *piecep, /* which piece */
- dvoid **indpp) /* indicator value */
-{
- oci_bind *phpbind;
- pval *val;
-
- phpbind = (oci_bind *)ictxp;
-
- if (!phpbind || !(val = phpbind->value)) {
- php_error(E_WARNING, "!phpbind || !phpbind->val");
- return OCI_ERROR;
- }
-
- if ((phpbind->descr == 0) && (phpbind->pStmt == 0)) { /* "normal string bind */
- convert_to_string(val);
-
- *bufpp = val->value.str.val;
- *alenp = phpbind->maxsize;
- *indpp = (dvoid *)&phpbind->indicator;
- } else if (phpbind->pStmt != 0) {
- *bufpp = phpbind->pStmt;
- *alenp = -1; /* seems to be allright */
- *indpp = (dvoid *)&phpbind->indicator;
- } else { /* descriptor bind */
- *bufpp = phpbind->descr;
- *alenp = -1; /* seems to be allright */
- *indpp = (dvoid *)&phpbind->indicator;
- }
-
- *piecep = OCI_ONE_PIECE; /* pass all data in one go */
-
- return OCI_CONTINUE;
-}
-
-/* }}} */
-/* {{{ oci_bind_out_callback() */
-
-static sb4
-oci_bind_out_callback(dvoid *ctxp, /* context pointer */
- OCIBind *bindp, /* bind handle */
- ub4 iter, /* 0-based execute iteration value */
- ub4 index, /* index of current array for PL/SQL or
- row index for SQL */
- dvoid **bufpp, /* pointer to data */
- ub4 **alenpp, /* size after value/piece has been read */
- ub1 *piecep, /* which piece */
- dvoid **indpp, /* indicator value */
- ub2 **rcodepp) /* return code */
-{
- oci_bind *phpbind;
- pval *val;
-
- phpbind = (oci_bind *)ctxp;
- if (!phpbind) {
- oci_debug("oci_bind_out_callback: phpbind = NULL");
- return OCI_ERROR;
- }
-
- val = phpbind->value;
- if (val == NULL) {
- oci_debug("oci_bind_out_callback: phpbind->value = NULL");
- return OCI_ERROR;
- }
-
- /* XXX risky, if the variable has been freed, nasty things
- * could happen here.
- */
-
- if (val->type == IS_OBJECT) {
-
- } else if (val->type == IS_STRING) {
- STR_FREE(val->value.str.val);
-
- phpbind->value->value.str.len = phpbind->maxsize;
- phpbind->value->value.str.val = emalloc(phpbind->maxsize);
-
- oci_debug("oci_bind_out_callback: maxlen=%d",phpbind->maxsize);
-
- *alenpp = (ub4*) &phpbind->value->value.str.len; /* XXX we assume that php-pval len has 4 bytes */
- *bufpp = phpbind->value->value.str.val;
- *piecep = OCI_ONE_PIECE;
- *rcodepp = &phpbind->retcode;
- *indpp = &phpbind->indicator;
- }
-
- return OCI_CONTINUE;
-}
-
-/* }}} */
-/* {{{ oci_open_user()
- */
-
-static oci_session *oci_open_user(oci_server* server,char *username,char *password,int persistent,int exclusive)
-{
- oci_session *session = 0;
- OCISvcCtx *svchp = 0;
- char *hashed_details;
- int hashed_details_length;
- OCILS_FETCH();
-
- /*
- check if we already have this user authenticated
-
- we will reuse authenticated users within a request no matter if the user requested a persistent
- connections or not!
-
- but only as pesistent requested connections will be kept between requests!
- */
-
- hashed_details_length = strlen(SAFE_STRING(username))+
- strlen(SAFE_STRING(password))+
- strlen(SAFE_STRING(server->dbname));
-
- hashed_details = (char *) emalloc(hashed_details_length+1);
-
- sprintf(hashed_details,"%s%s%s",
- SAFE_STRING(username),
- SAFE_STRING(password),
- SAFE_STRING(server->dbname));
-
- if (! exclusive) {
- zend_hash_find(OCI(user), hashed_details, hashed_details_length+1, (void **) &session);
-
- if (session) {
- if (session->open) {
- if (persistent) {
- session->persistent = 1;
- }
- efree(hashed_details);
- return session;
- } else {
- _oci_close_user(session);
- /* breakthru to open */
- }
- }
- }
-
- session = calloc(1,sizeof(oci_session));
-
- if (! session) {
- goto CLEANUP;
- }
-
- session->persistent = persistent;
- session->server = server;
-
- /* allocate temporary Service Context */
- OCI(error) =
- OCIHandleAlloc(OCI(pEnv),
- (dvoid **)&svchp,
- OCI_HTYPE_SVCCTX,
- 0,
- NULL);
- if (OCI(error) != OCI_SUCCESS) {
- oci_error(OCI(pError), "oci_open_user: OCIHandleAlloc OCI_HTYPE_SVCCTX", OCI(error));
- goto CLEANUP;
- }
-
- /* allocate private session-handle */
- OCI(error) =
- OCIHandleAlloc(OCI(pEnv),
- (dvoid **)&session->pSession,
- OCI_HTYPE_SESSION,
- 0,
- NULL);
- if (OCI(error) != OCI_SUCCESS) {
- oci_error(OCI(pError), "oci_open_user: OCIHandleAlloc OCI_HTYPE_SESSION", OCI(error));
- goto CLEANUP;
- }
-
- /* Set the server handle in service handle */
- OCI(error) =
- OCIAttrSet(svchp,
- OCI_HTYPE_SVCCTX,
- server->pServer,
- 0,
- OCI_ATTR_SERVER,
- OCI(pError));
- if (OCI(error) != OCI_SUCCESS) {
- oci_error(OCI(pError), "oci_open_user: OCIAttrSet OCI_ATTR_SERVER", OCI(error));
- goto CLEANUP;
- }
-
- /* set the username in user handle */
- OCI(error) =
- OCIAttrSet((dvoid *) session->pSession,
- (ub4) OCI_HTYPE_SESSION,
- (dvoid *) username,
- (ub4) strlen(username),
- (ub4) OCI_ATTR_USERNAME,
- OCI(pError));
- if (OCI(error) != OCI_SUCCESS) {
- oci_error(OCI(pError), "OCIAttrSet OCI_ATTR_USERNAME", OCI(error));
- goto CLEANUP;
- }
-
- /* set the password in user handle */
- OCI(error) =
- OCIAttrSet((dvoid *) session->pSession,
- (ub4) OCI_HTYPE_SESSION,
- (dvoid *) password,
- (ub4) strlen(password),
- (ub4) OCI_ATTR_PASSWORD,
- OCI(pError));
- if (OCI(error) != OCI_SUCCESS) {
- oci_error(OCI(pError), "OCIAttrSet OCI_ATTR_PASSWORD", OCI(error));
- goto CLEANUP;
- }
-
- OCI(error) =
- OCISessionBegin(svchp,
- OCI(pError),
- session->pSession,
- (ub4) OCI_CRED_RDBMS,
- (ub4) OCI_DEFAULT);
- if (OCI(error) != OCI_SUCCESS) {
- oci_error(OCI(pError), "OCISessionBegin", OCI(error));
- goto CLEANUP;
- }
-
- /* Free Temporary Service Context */
- OCIHandleFree((dvoid *) svchp, (ub4) OCI_HTYPE_SVCCTX);
-
- session->num = OCI(user_num)++;
-
- session->open = 1;
-
- oci_debug("oci_open_user new sess=%d user=%s",session->num,username);
-
- if (exclusive) {
- zend_hash_next_index_pointer_insert(OCI(user),
- (void *) session);
- } else {
- zend_hash_pointer_update(OCI(user),
- hashed_details,
- hashed_details_length+1,
- (void *) session);
- }
-
- efree(hashed_details);
-
- return session;
-
- CLEANUP:
- oci_debug("oci_open_user: FAILURE -> CLEANUP called");
-
- if (hashed_details) {
- efree(hashed_details);
- }
-
- _oci_close_user(session);
-
- return 0;
-}
-
-/* }}} */
-/* {{{ _oci_close_user()
- */
-
-static void
-_oci_close_user(oci_session *session)
-{
- OCISvcCtx *svchp;
- OCILS_FETCH();
-
- if (! session) {
- return;
- }
-
- oci_debug("_oci_close_user: logging-off sess=%d",session->num);
-
- if (session->open) {
- /* Temporary Service Context */
- OCI(error) =
- OCIHandleAlloc(OCI(pEnv),
- (dvoid **) &svchp,
- (ub4) OCI_HTYPE_SVCCTX,
- (size_t) 0,
- (dvoid **) 0);
-
- if (OCI(error) != OCI_SUCCESS) {
- oci_error(OCI(pError), "_oci_close_user OCIHandleAlloc OCI_HTYPE_SVCCTX", OCI(error));
- }
-
- /* Set the server handle in service handle */
- OCI(error) =
- OCIAttrSet(svchp,
- OCI_HTYPE_SVCCTX,
- session->server->pServer,
- 0,
- OCI_ATTR_SERVER,
- OCI(pError));
- if (OCI(error) != OCI_SUCCESS) {
- oci_error(OCI(pError), "_oci_close_user: OCIAttrSet OCI_ATTR_SERVER", OCI(error));
- }
-
- /* Set the Authentication handle in the service handle */
- OCI(error) =
- OCIAttrSet(svchp,
- OCI_HTYPE_SVCCTX,
- session->pSession,
- 0,
- OCI_ATTR_SESSION,
- OCI(pError));
- if (OCI(error) != OCI_SUCCESS) {
- oci_error(OCI(pError), "_oci_close_user: OCIAttrSet OCI_ATTR_SESSION", OCI(error));
- }
-
- OCI(error) =
- OCISessionEnd(svchp,
- OCI(pError),
- session->pSession,
- (ub4) 0);
- if (OCI(error) != OCI_SUCCESS) {
- oci_error(OCI(pError), "_oci_close_user: OCISessionEnd", OCI(error));
- }
- } else {
- oci_debug("_oci_close_user: logging-off DEAD session");
- }
-
- OCIHandleFree((dvoid *) svchp, (ub4) OCI_HTYPE_SVCCTX);
-
- if (session->pSession) {
- OCIHandleFree((dvoid *) session->pSession, (ub4) OCI_HTYPE_SESSION);
- }
-
- free(session);
-}
-
-/* }}} */
-/* {{{ _oci_descr_dtor()
- */
-
-static int
-_oci_descr_dtor(void *data)
-{
- oci_descriptor *descr = (oci_descriptor *) data;
-
- oci_debug("oci_free_descr: %x",descr->ocidescr);
-
- OCIDescriptorFree(descr->ocidescr, descr->type);
-
- return 1;
-}
-/* }}} */
-/* {{{ oci_open_server()
- */
-static oci_server *oci_open_server(char *dbname,int persistent)
-{
- oci_server *server = 0;
- char *hashed_details;
- int hashed_details_length;
- OCILS_FETCH();
-
- /*
- check if we already have this server open
-
- we will reuse servers within a request no matter if the usere requested persistent
- connections or not!
-
- but only as pesistent requested connections will be kept between requests!
- */
-
- hashed_details_length = strlen(SAFE_STRING((char *)dbname));
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details,"%s",SAFE_STRING((char *)dbname));
-
- zend_hash_find(OCI(server), hashed_details, hashed_details_length+1, (void **) &server);
-
- if (server) {
- if (server->open) {
- /* if our new users uses this connection persistent, we're keeping it! */
- if (persistent) {
- server->persistent = persistent;
- }
-
- efree(hashed_details);
- return server;
- } else { /* server "died" in the meantime - try to reconnect! */
- _oci_close_server(server);
- /* breakthru to open */
- }
- }
-
- server = calloc(1,sizeof(oci_server));
-
- if (! server) {
- goto CLEANUP;
- }
-
- server->persistent = persistent;
-
- server->dbname = strdup(SAFE_STRING(dbname));
-
- OCIHandleAlloc(OCI(pEnv),
- (dvoid **)&server->pServer,
- OCI_HTYPE_SERVER,
- 0,
- NULL);
-
- OCI(error) =
- OCIServerAttach(server->pServer,
- OCI(pError),
- (text*)dbname,
- strlen(dbname),
- (ub4) OCI_DEFAULT);
-
- if (OCI(error)) {
- oci_error(OCI(pError), "oci_open_server", OCI(error));
- goto CLEANUP;
- }
-
- server->num = OCI(server_num)++;
-
- server->open = 1;
-
-
-#if 0
- server->failover.fo_ctx = (dvoid *) server;
- server->failover.callback_function = oci_failover_callback;
-
- error = OCIAttrSet((dvoid *)server->pServer,
- (ub4) OCI_HTYPE_SERVER,
- (dvoid *) &server->failover,
- (ub4) 0,
- (ub4) OCI_ATTR_FOCBK,
- OCI(pError));
-
- if (error) {
- oci_error(OCI(pError), "oci_open_server OCIAttrSet OCI_ATTR_FOCBK", error);
- goto CLEANUP;
- }
-#endif
-
- oci_debug("oci_open_server new conn=%d dname=%s",server->num,server->dbname);
-
- zend_hash_pointer_update(OCI(server),
- hashed_details,
- hashed_details_length+1,
- (void *) server);
-
- efree(hashed_details);
-
- return server;
-
- CLEANUP:
- oci_debug("oci_open_server: FAILURE -> CLEANUP called");
-
- if (hashed_details) {
- efree(hashed_details);
- }
-
- _oci_close_server(server);
-
- return 0;
-}
-
-/* }}} */
-/* {{{ _oci_close_server()
- */
-
-static void
-_oci_close_server(oci_server *server)
-{
- OCILS_FETCH();
-
- if (! server) {
- return;
- }
-
- oci_debug("_oci_close_server: detaching conn=%d dbname=%s",server->num,server->dbname);
-
- /* XXX close server here */
-
- if (server->open) {
- if (server->pServer && OCI(pError)) {
- OCI(error) =
- OCIServerDetach(server->pServer,
- OCI(pError),
- OCI_DEFAULT);
-
- if (OCI(error)) {
- oci_error(OCI(pError), "oci_close_server OCIServerDetach", OCI(error));
- }
- }
- } else {
- oci_debug("_oci_close_server: closing DEAD server");
- }
-
- if (server->pServer) {
- OCIHandleFree((dvoid *) server->pServer, (ub4) OCI_HTYPE_SERVER);
- }
-
- if (server->dbname) {
- free(server->dbname);
- }
-
- free(server);
-}
-
-/* }}} */
-/* {{{ oci_do_connect()
- Connect to an Oracle database and log on. returns a new session.
- */
-static void oci_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent,int exclusive)
-{
- char *username, *password, *dbname;
- pval *userParam, *passParam, *dbParam;
- oci_server *server = 0;
- oci_session *session = 0;
- oci_connection *connection = 0;
- OCILS_FETCH();
-
- if (getParameters(ht, 3, &userParam, &passParam, &dbParam) == SUCCESS) {
- convert_to_string(userParam);
- convert_to_string(passParam);
- convert_to_string(dbParam);
-
- username = userParam->value.str.val;
- password = passParam->value.str.val;
- dbname = dbParam->value.str.val;
- } else if (getParameters(ht, 2, &userParam, &passParam) == SUCCESS) {
- convert_to_string(userParam);
- convert_to_string(passParam);
-
- username = userParam->value.str.val;
- password = passParam->value.str.val;
- dbname = "";
- } else {
- WRONG_PARAM_COUNT;
- }
-
- connection = (oci_connection *) ecalloc(1,sizeof(oci_connection));
-
- if (! connection) {
- goto CLEANUP;
- }
-
- server = oci_open_server(dbname,persistent);
-
- if (! server) {
- goto CLEANUP;
- }
-
- persistent = server->persistent; /* if our server-context is not persistent we can't */
-
- session = oci_open_user(server,username,password,persistent,exclusive);
-
- if (! session) {
- goto CLEANUP;
- }
-
- /* set our session */
- connection->session = session;
-
- /* allocate our private error-handle */
- OCI(error) =
- OCIHandleAlloc(OCI(pEnv),
- (dvoid **)&connection->pError,
- OCI_HTYPE_ERROR,
- 0,
- NULL);
- if (OCI(error) != OCI_SUCCESS) {
- oci_error(OCI(pError), "oci_do_connect: OCIHandleAlloc OCI_HTYPE_ERROR",OCI(error));
- goto CLEANUP;
- }
-
- /* allocate our service-context */
- OCI(error) =
- OCIHandleAlloc(OCI(pEnv),
- (dvoid **)&connection->pServiceContext,
- OCI_HTYPE_SVCCTX,
- 0,
- NULL);
- if (OCI(error) != OCI_SUCCESS) {
- oci_error(OCI(pError), "oci_do_connect: OCIHandleAlloc OCI_HTYPE_SVCCTX",OCI(error));
- goto CLEANUP;
- }
-
- /* Set the server handle in service handle */
- connection->error =
- OCIAttrSet(connection->pServiceContext,
- OCI_HTYPE_SVCCTX,
- server->pServer,
- 0,
- OCI_ATTR_SERVER,
- connection->pError);
- if (connection->error != OCI_SUCCESS) {
- oci_error(connection->pError, "oci_do_connect: OCIAttrSet OCI_ATTR_SERVER", connection->error);
- goto CLEANUP;
- }
-
- /* Set the Authentication handle in the service handle */
- connection->error =
- OCIAttrSet(connection->pServiceContext,
- OCI_HTYPE_SVCCTX,
- session->pSession,
- 0,
- OCI_ATTR_SESSION,
- connection->pError);
- if (connection->error != OCI_SUCCESS) {
- oci_error(connection->pError, "oci_do_connect: OCIAttrSet OCI_ATTR_SESSION", connection->error);
- goto CLEANUP;
- }
-
- /*
- OCIAttrSet((dvoid *)session->server->pServer,
- OCI_HTYPE_SERVER,
- (dvoid *) "demo",
- 0,
- OCI_ATTR_EXTERNAL_NAME,
- connection->pError);
-
- OCIAttrSet((dvoid *)session->server->pServer,
- OCI_HTYPE_SERVER,
- (dvoid *) "txn demo2",
- 0,
- OCI_ATTR_INTERNAL_NAME,
- connection->pError);
- */
-
-
- connection->id = php3_list_insert(connection, le_conn);
-
- connection->descriptors = emalloc(sizeof(HashTable));
- if (!connection->descriptors ||
- zend_hash_init(connection->descriptors, 13, NULL, _oci_descr_dtor, 0) == FAILURE) {
- goto CLEANUP;
- }
-
- connection->open = 1;
-
- oci_debug("oci_do_connect: id=%d",connection->id);
-
- RETURN_RESOURCE(connection->id);
-
- CLEANUP:
- oci_debug("oci_do_connect: FAILURE -> CLEANUP called");
-
- if (connection->id) {
- php3_list_delete(connection->id);
- } else {
- _oci_close_conn(connection);
- }
-
- RETURN_FALSE;
-}
-
-/* }}} */
-
-/************************* EXTENSION FUNCTIONS *************************/
-
-/* {{{ proto int OCIDefineByName(int stmt, string name, mixed &var [,int type])
- Define a PHP variable to an Oracle column by name.
- if you want to define a LOB/CLOB etc make sure you allocate it via OCINewDescriptor BEFORE defining!!!
- */
-
-PHP_FUNCTION(ocidefinebyname)
-{
- pval *stmt, *name, *var, *type;
- oci_statement *statement;
- oci_define *define, *tmp_define;
- ub2 ocitype;
-
- ocitype = SQLT_STR; /* zero terminated string */
-
- if (getParameters(ht, 4, &stmt, &name, &var, &type) == SUCCESS) {
- convert_to_long(type);
- ocitype = (ub2) type->value.lval;
- } else if (getParameters(ht, 3, &stmt, &name, &var) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(stmt);
- statement = oci_get_stmt(stmt->value.lval, "OCIDefineByName", list);
- if (statement == NULL) {
- RETURN_FALSE;
- }
-
- convert_to_string(name);
-
- define = ecalloc(1,sizeof(oci_define));
- if (!define) {
- /* out of memory */
- RETURN_FALSE;
- }
- if (statement->defines == NULL) {
- statement->defines = emalloc(sizeof(HashTable));
- if (statement->defines == NULL ||
- zend_hash_init(statement->defines, 13, NULL, _oci_define_dtor, 0) == FAILURE) {
- /* out of memory */
- RETURN_FALSE;
- }
- }
- if (zend_hash_add(statement->defines,
- name->value.str.val,
- name->value.str.len,
- define,
- sizeof(oci_define),
- (void **)&tmp_define) == SUCCESS) {
- efree(define);
- define = tmp_define;
- } else {
- RETURN_FALSE;
- }
-
- define->name = (text*) estrndup(name->value.str.val,name->value.str.len);
- define->name_len = name->value.str.len;
- define->type = ocitype;
- define->pval = var;
-
- RETURN_TRUE;
-}
-
-/* }}} */
-/* {{{ proto int OCIBindByName(int stmt, string name, mixed &var, int maxlength [,int type])
- Bind a PHP variable to an Oracle placeholder by name.
- if you want to bind a LOB/CLOB etc make sure you allocate it via OCINewDescriptor BEFORE binding!!!
- */
-
-PHP_FUNCTION(ocibindbyname)
-{
- pval *stmt, *name, *var, *maxlen, **tmp,*type;
- oci_statement *statement;
- oci_statement *bindstmt;
- oci_bind *bind, *tmp_bind;
- oci_descriptor *descr;
- ub2 ocitype;
- sb4 ocimaxlen;
- OCIStmt *mystmt = 0;
- dvoid *mydescr = 0;
-
- ocitype = SQLT_STR; /* zero terminated string */
-
- if (getParameters(ht, 5, &stmt, &name, &var, &maxlen,&type) == SUCCESS) {
- convert_to_long(type);
- ocitype = (ub2) type->value.lval;
- convert_to_long(maxlen);
- ocimaxlen = maxlen->value.lval;
- } else if (getParameters(ht, 4, &stmt, &name, &var, &maxlen) == SUCCESS) {
- convert_to_long(maxlen); ocimaxlen = maxlen->value.lval;
- } else {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(stmt);
- statement = oci_get_stmt(stmt->value.lval, "OCIBindByName", list);
- if (statement == NULL) {
- RETURN_FALSE;
- }
-
- switch (var->type) {
- case IS_OBJECT :
- if (zend_hash_find(var->value.obj.properties, "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
- php_error(E_WARNING, "unable to find my descriptor property");
- RETURN_FALSE;
- }
-
- if (zend_hash_index_find(statement->conn->descriptors, (*tmp)->value.lval, (void **)&descr) == FAILURE) {
- php_error(E_WARNING, "unable to find my descriptor");
- RETURN_FALSE;
- }
-
- mydescr = (dvoid *) descr->ocidescr;
-
- if (! mydescr) {
- RETURN_FALSE;
- }
- break;
-
- default:
- if (ocitype == SQLT_RSET) { /* refcursor binding */
- convert_to_long(var);
-
- bindstmt = oci_get_stmt(var->value.lval, "OCIBindByName", list);
- if (! bindstmt) {
- RETURN_FALSE;
- }
- ocimaxlen = 0;
- mystmt = bindstmt->pStmt;
- } else { /* everything else is now handled as a string */
- convert_to_string(var);
- if (ocimaxlen == -1) {
- if (var->value.str.len == 0) {
- php_error(E_WARNING, "OCIBindByName bindlength is 0");
- }
-
- if (ocitype == SQLT_BIN) {
- ocimaxlen = var->value.str.len;
- } else {
- ocimaxlen = var->value.str.len + 1;
- /* SQLT_STR needs a trailing 0 - maybe we need to resize the var buffers????? */
- }
- }
- }
- break;
- }
-
- convert_to_string(name);
-
- bind = ecalloc(1,sizeof(oci_bind));
- if (!bind) {
- /* out of memory */
- RETURN_FALSE;
- }
- if (statement->binds == NULL) {
- statement->binds = emalloc(sizeof(HashTable));
- if (statement->binds == NULL ||
- zend_hash_init(statement->binds, 13, NULL, NULL, 0) == FAILURE) {
- /* out of memory */
- RETURN_FALSE;
- }
- }
- if (zend_hash_next_index_insert(statement->binds, bind,
- sizeof(oci_bind),
- (void **)&tmp_bind) == SUCCESS) {
- efree(bind);
- bind = tmp_bind;
- }
-
- bind->value = var;
- bind->descr = mydescr;
- bind->pStmt = mystmt;
- bind->maxsize = ocimaxlen;
-
- statement->error =
- OCIBindByName(statement->pStmt, /* statement handle */
- (OCIBind **)&bind->pBind, /* bind hdl (will alloc) */
- statement->pError, /* error handle */
- (text*) name->value.str.val, /* placeholder name */
- name->value.str.len, /* placeholder length */
- (dvoid *)0, /* in/out data */
- ocimaxlen, /* max size of input/output data */
- (ub2)ocitype, /* in/out data type */
- (dvoid *)&bind->indicator, /* indicator (ignored) */
- (ub2 *)0, /* size array (ignored) */
- (ub2 *)&bind->retcode, /* return code (ignored) */
- (ub4)0, /* maxarr_len (PL/SQL only?) */
- (ub4 *)0, /* actual array size (PL/SQL only?) */
- OCI_DATA_AT_EXEC /* mode */);
- if (statement->error != OCI_SUCCESS) {
- oci_error(statement->pError, "OCIBindByName", statement->error);
- RETURN_FALSE;
- }
- statement->error =
- OCIBindDynamic(bind->pBind,
- statement->pError,
- (dvoid *)bind,
- oci_bind_in_callback,
- (dvoid *)bind,
- oci_bind_out_callback);
- if (statement->error != OCI_SUCCESS) {
- oci_error(statement->pError, "OCIBindDynamic", statement->error);
- RETURN_FALSE;
- }
-
- RETURN_TRUE;
-}
-
-/* }}} */
-/* {{{ proto string ocifreedesc(object lob)
- */
-
-PHP_FUNCTION(ocifreedesc)
-{
- pval *id, **conn, **desc;
- oci_connection *connection;
-
- if ((id = getThis()) != 0) {
- if (zend_hash_find(id->value.obj.properties, "connection", sizeof("connection"), (void **)&conn) == FAILURE) {
- php_error(E_WARNING, "unable to find my statement property");
- RETURN_FALSE;
- }
-
- connection = oci_get_conn((*conn)->value.lval, "OCIfreedesc", list);
- if (connection == NULL) {
- RETURN_FALSE;
- }
-
- if (zend_hash_find(id->value.obj.properties, "descriptor", sizeof("descriptor"), (void **)&desc) == FAILURE) {
- php_error(E_WARNING, "unable to find my locator property");
- RETURN_FALSE;
- }
-
- oci_debug("OCOfreedesc: descr=%d",(*desc)->value.lval);
-
- zend_hash_index_del(connection->descriptors,(*desc)->value.lval);
-
- RETURN_TRUE;
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-/* {{{ proto string ocisavelob(object lob)
- */
-
-PHP_FUNCTION(ocisavelob)
-{
- pval *id, **tmp, **conn, *arg,*oarg;
- OCILobLocator *mylob;
- oci_connection *connection;
- oci_descriptor *descr;
- int offparam;
- ub4 loblen;
- ub4 curloblen;
- ub4 offset;
-
- if ((id = getThis()) != 0) {
- if (zend_hash_find(id->value.obj.properties, "connection", sizeof("connection"), (void **)&conn) == FAILURE) {
- php_error(E_WARNING, "unable to find my statement property");
- RETURN_FALSE;
- }
-
- connection = oci_get_conn((*conn)->value.lval, "OCIsavelob", list);
- if (connection == NULL) {
- RETURN_FALSE;
- }
-
- if (zend_hash_find(id->value.obj.properties, "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
- php_error(E_WARNING, "unable to find my locator property");
- RETURN_FALSE;
- }
-
- if (zend_hash_index_find(connection->descriptors, (*tmp)->value.lval, (void **)&descr) == FAILURE) {
- php_error(E_WARNING, "unable to find my descriptor %d",(*tmp)->value.lval);
- RETURN_FALSE;
- }
-
- mylob = (OCILobLocator *) descr->ocidescr;
-
- if (! mylob) {
- RETURN_FALSE;
- }
-
- offset = 0;
- if (getParameters(ht, 2, &arg, &oarg) == SUCCESS) {
- convert_to_long(oarg);
- offparam = oarg->value.lval;
-
- connection->error =
- OCILobGetLength(connection->pServiceContext,
- connection->pError,
- mylob,
- &curloblen);
-
- oci_debug("OCIsavedesc: curloblen=%d",curloblen);
-
- if (offparam == -1) {
- offset = curloblen;
- } else if (offparam >= curloblen) {
- php3_error(E_WARNING, "Offset smaller than current LOB-Size - appending");
- offset = curloblen;
- } else {
- offset = offparam;
- }
- } else if (getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- offset++;
- loblen = arg->value.str.len;
-
- if (loblen < 1) {
- php3_error(E_WARNING, "Cannot save a lob wich size is less than 1 byte");
- RETURN_FALSE;
- }
-
- connection->error =
- OCILobWrite(connection->pServiceContext,
- connection->pError,
- mylob,
- &loblen,
- (ub4) offset,
- (dvoid *) arg->value.str.val,
- (ub4) loblen,
- OCI_ONE_PIECE,
- (dvoid *)0,
- (OCICallbackLobWrite) 0,
- (ub2) 0,
- (ub1) SQLCS_IMPLICIT );
-
- oci_debug("OCIsavedesc: size=%d offset=%d",loblen,offset);
-
- if (connection->error) {
- oci_error(connection->pError, "OCILobWrite", connection->error);
- RETURN_FALSE;
- }
-
- RETURN_TRUE;
- }
-
- RETURN_FALSE;
-}
-
-/* }}} */
-/* {{{ proto string ocisavelobfile(object lob)
- */
-
-PHP_FUNCTION(ocisavelobfile)
-{
- pval *id, **tmp, **conn, *arg;
- OCILobLocator *mylob;
- oci_connection *connection;
- oci_descriptor *descr;
- char *filename;
- int fp;
- char buf[8192];
- ub4 offset = 1;
- ub4 loblen;
-
- if ((id = getThis()) != 0) {
- if (zend_hash_find(id->value.obj.properties, "connection", sizeof("connection"), (void **)&conn) == FAILURE) {
- php_error(E_WARNING, "unable to find my statement property");
- RETURN_FALSE;
- }
-
- connection = oci_get_conn((*conn)->value.lval, "OCIsavelob", list);
- if (connection == NULL) {
- RETURN_FALSE;
- }
-
- if (zend_hash_find(id->value.obj.properties, "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
- php_error(E_WARNING, "unable to find my locator property");
- RETURN_FALSE;
- }
-
- if (zend_hash_index_find(connection->descriptors, (*tmp)->value.lval, (void **)&descr) == FAILURE) {
- php_error(E_WARNING, "unable to find my descriptor %d",(*tmp)->value.lval);
- RETURN_FALSE;
- }
-
- mylob = (OCILobLocator *) descr->ocidescr;
-
- if (! mylob) {
- RETURN_FALSE;
- }
-
- if (getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(arg);
-
- if (_php3_check_open_basedir(arg->value.str.val)) {
- RETURN_FALSE;
- }
-
- filename = arg->value.str.val;
-
- if ((fp = open(filename, O_RDONLY)) == -1) {
- php_error(E_WARNING, "Can't open file %s", filename);
- RETURN_FALSE;
- }
-
- while ((loblen = read(fp, &buf, sizeof(buf))) > 0) {
- connection->error =
- OCILobWrite(connection->pServiceContext,
- connection->pError,
- mylob,
- &loblen,
- (ub4) offset,
- (dvoid *) &buf,
- (ub4) loblen,
- OCI_ONE_PIECE,
- (dvoid *)0,
- (OCICallbackLobWrite) 0,
- (ub2) 0,
- (ub1) SQLCS_IMPLICIT);
-
- oci_debug("OCIsavelob: size=%d",loblen);
-
- if (connection->error) {
- oci_error(connection->pError, "OCILobWrite", connection->error);
- close(fp);
- RETURN_FALSE;
- }
-
- offset += loblen;
- }
- close(fp);
-
- RETURN_TRUE;
- }
-
- RETURN_FALSE;
-}
-
-/* }}} */
-/* {{{ proto string ociloadlob(object lob)
- */
-
-PHP_FUNCTION(ociloadlob)
-{
- pval *id, **tmp, **conn;
- oci_connection *connection;
- oci_descriptor *descr;
- char *buffer;
- ub4 loblen;
-
- if ((id = getThis()) != 0) {
- if (zend_hash_find(id->value.obj.properties, "connection", sizeof("connection"), (void **)&conn) == FAILURE) {
- php_error(E_WARNING, "unable to find my statement property");
- RETURN_FALSE;
- }
-
- connection = oci_get_conn((*conn)->value.lval, "OCIsavelob", list);
- if (connection == NULL) {
- RETURN_FALSE;
- }
-
- if (zend_hash_find(id->value.obj.properties, "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
- php_error(E_WARNING, "unable to find my locator property");
- RETURN_FALSE;
- }
-
- if (zend_hash_index_find(connection->descriptors, (*tmp)->value.lval, (void **)&descr) == FAILURE) {
- php_error(E_WARNING, "unable to find my descriptor %d",(*tmp)->value.lval);
- RETURN_FALSE;
- }
-
- loblen = oci_loadlob(connection,descr,&buffer);
-
- if (loblen >= 0) {
- RETURN_STRINGL(buffer,loblen,0);
- }
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-/* {{{ proto string OCINewDescriptor(int connection [,int type ])
- initialize a new empty descriptor LOB/FILE (LOB is default)
- */
-
-PHP_FUNCTION(ocinewdescriptor)
-{
- pval *conn, *type;
- oci_connection *connection;
- oci_descriptor descr;
- int mylob;
-
- OCILS_FETCH();
-
- descr.type = OCI_DTYPE_LOB;
-
- if (getParameters(ht, 2, &conn, &type) == SUCCESS) {
- descr.type = type->value.lval;
- } else if (getParameters(ht, 1, &conn) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- switch (descr.type) {
- case OCI_DTYPE_FILE:
- case OCI_DTYPE_LOB:
- case OCI_DTYPE_ROWID:
- break;
-
- default:
- php_error(E_WARNING, "Unknown descriptor type %d.",descr.type);
- RETURN_FALSE;
- }
-
- convert_to_long(conn);
-
- connection = oci_get_conn(conn->value.lval, "OCINewDescriptor", list);
- if (connection == NULL) {
- RETURN_FALSE;
- }
-
- OCI(error) =
- OCIDescriptorAlloc(OCI(pEnv),
- (dvoid*)&(descr.ocidescr),
- descr.type,
- (size_t) 0,
- (dvoid **) 0);
-
- if (OCI(error)) {
- oci_error(OCI(pError),"OCIDescriptorAlloc %d",OCI(error));
- RETURN_FALSE;
- }
-
- zend_hash_index_update(connection->descriptors, connection->descriptors_count,&descr,sizeof(oci_descriptor),NULL);
-
- mylob = connection->descriptors_count++;
-
- oci_debug("OCINewDescriptor: new descriptor for %d -> %x",mylob,descr.ocidescr);
-
- object_init_ex(return_value, oci_lob_class_entry_ptr);
- add_property_long(return_value, "descriptor", (long) mylob);
- add_property_long(return_value, "connection", conn->value.lval);
-}
-
-/* }}} */
-/* {{{ proto string OCIRollback(int conn)
- rollback the current context
- */
-
-PHP_FUNCTION(ocirollback)
-{
- pval *conn;
- oci_connection *connection;
-
- if (getParameters(ht, 1, &conn) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(conn);
-
- connection = oci_get_conn(conn->value.lval, "OCIRollback", list);
- if (connection == NULL) {
- RETURN_FALSE;
- }
-
- connection->error =
- OCITransRollback(connection->pServiceContext,
- connection->pError,
- (ub4)0);
-
- if (connection->error) {
- oci_error(connection->pError, "OCIRollback", connection->error);
- RETURN_FALSE;
- }
-
- RETURN_TRUE;
-}
-
-/* }}} */
-/* {{{ proto string OCICommit(int conn)
- commit the current context
- */
-
-PHP_FUNCTION(ocicommit)
-{
- pval *conn;
- oci_connection *connection;
-
- if (getParameters(ht, 1, &conn) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(conn);
-
- connection = oci_get_conn(conn->value.lval, "OCICommit", list);
- if (connection == NULL) {
- RETURN_FALSE;
- }
-
- connection->error =
- OCITransCommit(connection->pServiceContext,
- connection->pError,
- (ub4)0);
-
- if (connection->error) {
- oci_error(connection->pError, "OCICommit", connection->error);
- RETURN_FALSE;
- }
-
- RETURN_TRUE;
-}
-
-/* }}} */
-/* {{{ proto string OCIColumnName(int stmt, int col)
- Tell the name of a column.
- */
-
-PHP_FUNCTION(ocicolumnname)
-{
- pval *stmt, *col;
- oci_statement *statement;
- oci_out_column *outcol;
-
- if (getParameters(ht, 2, &stmt, &col) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(stmt);
- statement = oci_get_stmt(stmt->value.lval, "OCIColumnName", list);
- if (statement == NULL) {
- RETURN_FALSE;
- }
- outcol = oci_get_col(statement, -1, col, "OCIColumnName");
- if (outcol == NULL) {
- RETURN_FALSE;
- }
-
- RETURN_STRINGL(outcol->name, outcol->name_len, 1);
-}
-
-/* }}} */
-/* {{{ proto int OCIColumnSize(int stmt, int col)
- Tell the maximum data size of a column.
- */
-
-PHP_FUNCTION(ocicolumnsize)
-{
- pval *stmt, *col;
- oci_statement *statement;
- oci_out_column *outcol;
-
- if (getParameters(ht, 2, &stmt, &col) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(stmt);
- statement = oci_get_stmt(stmt->value.lval, "OCIColumnSize", list);
- if (statement == NULL) {
- RETURN_FALSE;
- }
- outcol = oci_get_col(statement, -1, col, "OCIColumnSize");
- if (outcol == NULL) {
- RETURN_FALSE;
- }
- RETURN_LONG(outcol->data_size);
-}
-
-/* }}} */
-/* {{{ proto mixed OCIColumnType(int stmt, int col)
- Tell the data type of a column.
- */
-
-PHP_FUNCTION(ocicolumntype)
-{
- pval *stmt, *col;
- oci_statement *statement;
- oci_out_column *outcol;
-
- if (getParameters(ht, 2, &stmt, &col) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(stmt);
- statement = oci_get_stmt(stmt->value.lval, "OCIColumnType", list);
- if (statement == NULL) {
- RETURN_FALSE;
- }
- outcol = oci_get_col(statement, -1, col, "OCIColumnType");
- if (outcol == NULL) {
- RETURN_FALSE;
- }
- switch (outcol->data_type) {
- case SQLT_DAT:
- RETVAL_STRING("DATE",1);
- break;
- case SQLT_NUM:
- RETVAL_STRING("NUMBER",1);
- break;
- case SQLT_LNG:
- RETVAL_STRING("LONG",1);
- break;
- case SQLT_BIN:
- RETVAL_STRING("RAW",1);
- break;
- case SQLT_LBI:
- RETVAL_STRING("LONG RAW",1);
- break;
- case SQLT_CHR:
- RETVAL_STRING("VARCHAR",1);
- break;
- case SQLT_RSET:
- RETVAL_STRING("REFCURSOR",1);
- break;
- case SQLT_AFC:
- RETVAL_STRING("CHAR",1);
- break;
- case SQLT_BLOB:
- RETVAL_STRING("BLOB",1);
- break;
- case SQLT_CLOB:
- RETVAL_STRING("CLOB",1);
- break;
- case SQLT_BFILE:
- RETVAL_STRING("BFILE",1);
- break;
- case SQLT_RDD:
- RETVAL_STRING("ROWID",1);
- break;
- default:
- RETVAL_LONG(outcol->data_type);
- }
-}
-
-/* }}} */
-/* {{{ proto int OCIColumnIsNULL(int stmt, int col)
- Tell whether a column is NULL.
- */
-
-PHP_FUNCTION(ocicolumnisnull)
-{
- pval *stmt, *col;
- oci_statement *statement;
- oci_out_column *outcol;
-
- if (getParameters(ht, 2, &stmt, &col) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(stmt);
- statement = oci_get_stmt(stmt->value.lval, "OCIColumnIsNULL", list);
- if (statement == NULL) {
- RETURN_FALSE;
- }
- outcol = oci_get_col(statement, -1, col, "OCIColumnIsNULL");
- if (outcol == NULL) {
- RETURN_FALSE;
- }
- if (outcol->indicator == -1) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-
-/* }}} */
-/* {{{ Proto void OCIDebug(int onoff)
- Toggle internal debugging output for the OCI extension.
- */
-
-/* Disables or enables the internal debug output.
- * By default it is disabled.
- */
-PHP_FUNCTION(ociinternaldebug)
-{
- pval *arg;
- OCILS_FETCH();
-
- if (getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg);
- OCI(debug_mode) = arg->value.lval;
-}
-
-
-/* }}} */
-/* {{{ proto int OCIExecute(int stmt [,int mode])
- Execute a parsed statement.
- */
-
-PHP_FUNCTION(ociexecute)
-{
- pval *stmt,*mode;
- oci_statement *statement;
- ub4 execmode;
-
- if (getParameters(ht, 2, &stmt, &mode) == SUCCESS) {
- convert_to_long(mode);
- execmode = mode->value.lval;
- } else if (getParameters(ht, 1, &stmt) == SUCCESS) {
- execmode = OCI_COMMIT_ON_SUCCESS;
- } else {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(stmt);
- statement = oci_get_stmt(stmt->value.lval, "OCIExecute", list);
- if (statement == NULL) {
- RETURN_FALSE;
- }
-
- if (oci_execute(statement, "OCIExecute",execmode,list)) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-
-/* }}} */
-/* {{{ proto int OCICancel(int stmt)
- Prepare a new row of data for reading.
- */
-
-PHP_FUNCTION(ocicancel)
-{
- pval *stmt;
- oci_statement *statement;
-
- if (getParameters(ht, 1, &stmt) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(stmt);
-
- statement = oci_get_stmt(stmt->value.lval, "OCICancel", list);
- if (statement == NULL) {
- RETURN_FALSE;
- }
- if (oci_fetch(statement, 0, "OCICancel")) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-
-/* }}} */
-/* {{{ proto int OCIFetch(int stmt)
- Prepare a new row of data for reading.
- */
-
-PHP_FUNCTION(ocifetch)
-{
- pval *stmt;
- oci_statement *statement;
- ub4 nrows = 1; /* only one row at a time is supported for now */
-
- if (getParameters(ht, 1, &stmt) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(stmt);
-
- statement = oci_get_stmt(stmt->value.lval, "OCIFetch", list);
- if (statement == NULL) {
- RETURN_FALSE;
- }
- if (oci_fetch(statement, nrows, "OCIFetch")) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-
-/* }}} */
-/* {{{ proto int OCIFetchInto(int stmt, array &output [, int mode])
- Fetch a row of result data into an array.
- */
-
-PHP_FUNCTION(ocifetchinto)
-{
- pval *stmt, *array, *element, *fmode;
- oci_statement *statement;
- oci_out_column *column;
- ub4 nrows = 1;
- int i;
- int mode = OCI_NUM;
-
- if (getParameters(ht, 3, &stmt, &array, &fmode) == SUCCESS) {
- convert_to_long(fmode);
- mode = fmode->value.lval;
- } else if (getParameters(ht, 2, &stmt, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(stmt);
- statement = oci_get_stmt(stmt->value.lval, "OCIFetchInto", list);
- if (statement == NULL) {
- RETURN_FALSE;
- }
-
- if (!oci_fetch(statement, nrows, "OCIFetchInto")) {
- RETURN_FALSE;
- }
-
- /*
- if we don't want NULL columns back, we need to recreate the array
- as it could have a different number of enties for each fetched row
- */
-
- if (! (mode & OCI_RETURN_NULLS)) {
- if (array->type == IS_ARRAY) {
- /* XXX is that right?? */
- zend_hash_destroy(array->value.ht);
- efree(array->value.ht);
- var_reset(array);
- }
- }
-
- if (array->type != IS_ARRAY) {
- pval_destructor(array);
- if (array_init(array) == FAILURE) {
- php_error(E_WARNING, "OCIFetchInto: unable to convert arg 2 to array");
- RETURN_FALSE;
- }
- }
-
- zend_hash_internal_pointer_reset(array->value.ht);
-
- for (i = 0; i < statement->ncolumns; i++) {
- column = oci_get_col(statement, i + 1, 0, "OCIFetchInto");
- if (column == NULL) { /* should not happen... */
- continue;
- }
-
- if ((column->indicator == -1) && ((mode & OCI_RETURN_NULLS) == 0)) {
- continue;
- }
-
- if ((mode & OCI_NUM) || (! (mode & OCI_ASSOC))) { /* OCI_NUM is default */
- MAKE_STD_ZVAL(element);
-
- oci_make_pval(element,statement,column, "OCIFetchInto",mode);
-
- zend_hash_index_update(array->value.ht, i, (void *)&element, sizeof(pval*), NULL);
- }
-
- if (mode & OCI_ASSOC) {
- MAKE_STD_ZVAL(element);
-
- oci_make_pval(element,statement,column, "OCIFetchInto",mode);
-
- zend_hash_update(array->value.ht, column->name, column->name_len+1, (void *)&element, sizeof(pval*), NULL);
- }
- }
-
- RETURN_LONG(statement->ncolumns);
-}
-
-/* }}} */
-/* {{{ proto int OCIFetchStatement(int stmt, array &output)
- Fetch all rows of result data into an array.
- */
-
-PHP_FUNCTION(ocifetchstatement)
-{
- pval *stmt, *array, *element, *fmode, *tmp;
- oci_statement *statement;
- oci_out_column **columns;
- pval ***outarrs;
- ub4 nrows = 1;
- int i;
- int mode = OCI_NUM;
- int rows = 0;
- char namebuf[ 128 ];
-
- if (getParameters(ht, 3, &stmt, &array, &fmode) == SUCCESS) {
- convert_to_long(fmode);
- mode = fmode->value.lval;
- } else if (getParameters(ht, 2, &stmt, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(stmt);
- statement = oci_get_stmt(stmt->value.lval, "OCIFetchStatement", list);
- if (statement == NULL) {
- RETURN_FALSE;
- }
-
- if (array->type != IS_ARRAY) {
- pval_destructor(array);
- if (array_init(array) == FAILURE) {
- php_error(E_WARNING, "OCIFetchStatement: unable to convert arg 2 to array");
- RETURN_FALSE;
- }
- }
-
- columns = emalloc(statement->ncolumns * sizeof(oci_out_column *));
- outarrs = emalloc(statement->ncolumns * sizeof(pval*));
-
- for (i = 0; i < statement->ncolumns; i++) {
- columns[ i ] = oci_get_col(statement, i + 1, 0, "OCIFetchStatement");
-
- MAKE_STD_ZVAL(tmp);
-
- array_init(tmp);
-
- memcpy(namebuf,columns[ i ]->name, columns[ i ]->name_len);
- namebuf[ columns[ i ]->name_len ] = 0;
-
- zend_hash_update(array->value.ht, namebuf, columns[ i ]->name_len+1, (void *) &tmp, sizeof(pval*), (void **) &(outarrs[ i ]));
- }
-
- while (oci_fetch(statement, nrows, "OCIFetchStatement")) {
- for (i = 0; i < statement->ncolumns; i++) {
- MAKE_STD_ZVAL(element);
-
- oci_make_pval(element,statement,columns[ i ], "OCIFetchStatement",OCI_RETURN_LOBS);
-
- zend_hash_index_update((*(outarrs[ i ]))->value.ht, rows, (void *)&element, sizeof(pval*), NULL);
- }
- rows++;
- }
-
- efree(columns);
- efree(outarrs);
-
- RETURN_LONG(rows);
-}
-
-/* }}} */
-/* {{{ proto int OCIFreeStatement(int stmt)
- Free all resources associated with a statement.
- */
-
-PHP_FUNCTION(ocifreestatement)
-{
- pval *stmt;
- oci_statement *statement;
-
- if (getParameters(ht, 1, &stmt) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(stmt);
- statement = oci_get_stmt(stmt->value.lval, "OCIFreeStatement", list);
- if (statement == NULL) {
- RETURN_FALSE;
- }
-
- php3_list_delete(stmt->value.lval);
-
- RETURN_TRUE;
-}
-
-/* }}} */
-/* {{{ proto int OCILogoff(int conn)
- Disconnect from database.
- */
-
-/* Logs off and disconnects.
- */
-PHP_FUNCTION(ocilogoff)
-{
- oci_connection *connection;
- pval *arg;
- int index, index_t;
-
- if (getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg);
- index = arg->value.lval;
- connection = (oci_connection *)php3_list_find(index, &index_t);
-
- if (!connection) {
- oci_debug("OCILogoff: connection == NULL.");
- RETURN_FALSE;
- }
-
- if (! OCI_CONN_TYPE(index_t)) {
- oci_debug("OCILogoff: connection not found...");
- RETURN_FALSE;
- }
-
- connection->open = 0;
-
- zend_hash_apply(list,(int (*)(void *))_stmt_cleanup);
-
- if (php3_list_delete(index) == SUCCESS) {
- RETURN_TRUE;
- } else {
- oci_debug("OCILogoff: php3_list_delete failed.");
- RETURN_FALSE;
- }
-}
-
-/* }}} */
-/* {{{ proto int OCILogon(string user, string pass[, string db])
- Connect to an Oracle database and log on. returns a new session.
- */
-
-/* Connects to an Oracle 8 database and logs on. If the
- * optional third parameter is not specified, PHP uses the environment
- * variable ORACLE_SID to determine which database to connect to.
- */
-PHP_FUNCTION(ocinlogon)
-{
- oci_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0,1);
-}
-
-/* }}} */
-/* {{{ proto int OCILogon(string user, string pass[, string db])
- Connect to an Oracle database and log on. returns a new session.
- */
-
-/* Connects to an Oracle 8 database and logs on. If the
- * optional third parameter is not specified, PHP uses the environment
- * variable ORACLE_SID to determine which database to connect to.
- */
-PHP_FUNCTION(ocilogon)
-{
- oci_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0,0);
-}
-
-/* }}} */
-/* {{{ proto int OCIPLogon(string user, string pass[, string db])
- Connect to an Oracle database and log on. returns a new session.
- */
-
-/* Connects to an Oracle 8 database and logs on. If the
- * optional third parameter is not specified, PHP uses the environment
- * variable ORACLE_SID to determine which database to connect to.
- */
-PHP_FUNCTION(ociplogon)
-{
- oci_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,1,0);
-}
-
-/* }}} */
-/* {{{ proto int OCIError([int stmt|conn])
- Return the last error of stmt|conn|global. If no error happened returns false.
- */
-
-PHP_FUNCTION(ocierror)
-{
- pval *mixed;
- oci_statement *statement;
- oci_connection *connection;
- text errbuf[512];
- sb4 errcode = 0;
- int type;
- sword error = 0;
- dvoid *errh = NULL;
-
- OCILS_FETCH();
-
- if (getParameters(ht, 1, &mixed) == SUCCESS) {
- convert_to_long(mixed);
- statement = (oci_statement *)php3_list_find(mixed->value.lval, &type);
- if (statement && OCI_STMT_TYPE(type)) {
- errh = statement->pError;
- error = statement->error;
- } else {
- connection = (oci_connection *)php3_list_find(mixed->value.lval, &type);
- if (connection && OCI_CONN_TYPE(type)) {
- errh = connection->pError;
- error = connection->error;
- }
- }
- } else {
- errh = OCI(pError);
- error = OCI(error);
- }
-
- if (! error) { /* no error set in the handle */
- RETURN_FALSE;
- }
-
- if (! errh) {
- php_error(E_WARNING, "OCIError: unable to find Error handle");
- RETURN_FALSE;
- }
-
- OCIErrorGet(errh,1,NULL,&errcode,errbuf,(ub4)sizeof(errbuf),(ub4)OCI_HTYPE_ERROR);
-
- if (errcode) {
- array_init(return_value);
- add_assoc_long(return_value, "code", errcode);
- add_assoc_string(return_value, "message", (char*) errbuf, 1);
- } else {
- RETURN_FALSE;
- }
-}
-
-/* }}} */
-/* {{{ proto int OCINumCols(int stmt)
- Return the number of result columns in a statement.
- */
-
-PHP_FUNCTION(ocinumcols)
-{
- pval *stmt;
- oci_statement *statement;
-
- if (getParameters(ht, 1, &stmt) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(stmt);
- statement = oci_get_stmt(stmt->value.lval, "OCINumCols", list);
- if (statement == NULL) {
- RETURN_FALSE;
- }
- RETURN_LONG(statement->ncolumns);
-}
-
-/* }}} */
-/* {{{ proto int OCIParse(int conn, string query)
- Parse a query and return a statement.
- */
-
-PHP_FUNCTION(ociparse)
-{
- pval *conn, *query;
- oci_connection *connection;
-
- if (getParameters(ht, 2, &conn, &query) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(conn);
- convert_to_string(query);
-
- connection = oci_get_conn(conn->value.lval, "OCIParse", list);
- if (connection == NULL) {
- RETURN_FALSE;
- }
-
- RETURN_RESOURCE(oci_parse(connection,
- query->value.str.val,
- query->value.str.len,
- list));
-}
-
-/* }}} */
-/* {{{ proto int OCIParse(int conn, string query)
- Parse a query and return a statement.
- */
-
-PHP_FUNCTION(ocisetprefetch)
-{
- pval *stmt, *size;
- oci_statement *statement;
-
- if (getParameters(ht, 2, &stmt, &size) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(stmt);
- convert_to_long(size);
-
- statement = oci_get_stmt(stmt->value.lval, "OCISetPreFetch", list);
- if (statement == NULL) {
- RETURN_FALSE;
- }
-
- oci_setprefetch(statement,size->value.lval);
-
- RETURN_TRUE;
-}
-
-/* }}} */
-/* {{{ proto int OCINewCursor(int conn)
- return a new cursor (Statement-Handle) - use this to bind ref-cursors!
-
- */
-
-PHP_FUNCTION(ocinewcursor)
-{
- pval *conn;
- oci_connection *connection;
-
- if (getParameters(ht, 1, &conn) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(conn);
-
- connection = oci_get_conn(conn->value.lval, "OCINewCursor", list);
- if (connection == NULL) {
- RETURN_FALSE;
- }
-
- RETURN_RESOURCE(oci_parse(connection,
- 0,
- 0,
- list));
-}
-
-/* }}} */
-/* {{{ proto string OCIResult(int stmt, mixed column)
- Return a single column of result data.
- */
-
-PHP_FUNCTION(ociresult)
-{
- pval *stmt, *col;
- oci_statement *statement;
- oci_out_column *outcol = NULL;
-
- if (getParameters(ht, 2, &stmt, &col) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(stmt);
-
- statement = oci_get_stmt(stmt->value.lval, "OCIResult", list);
-
- if (statement == NULL) {
- RETURN_FALSE;
- }
-
- outcol = oci_get_col(statement, -1, col, "OCIResult");
-
- if (outcol == NULL) {
- RETURN_FALSE;
- }
-
- oci_make_pval(return_value,statement,outcol, "OCIResult",0);
-}
-
-/* }}} */
-/* {{{ proto string OCIServerVersion(int conn)
- Return a string containing server version information.
- */
-
-PHP_FUNCTION(ociserverversion)
-{
- oci_connection *connection;
- pval *arg;
- int index, index_t;
- char version[256];
-
- if (getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg);
- index = arg->value.lval;
- connection = (oci_connection *)php3_list_find(index, &index_t);
- if (!connection || !OCI_CONN_TYPE(index_t)) {
- RETURN_FALSE;
- }
- connection->error =
- OCIServerVersion(connection->pServiceContext,
- connection->pError,
- (text*)version,
- sizeof(version),
- OCI_HTYPE_SVCCTX);
- if (connection->error != OCI_SUCCESS) {
- oci_error(connection->pError, "OCIServerVersion", connection->error);
- RETURN_FALSE;
- }
- RETURN_STRING(version,1);
-}
-
-/* }}} */
-/* {{{ proto int OCIStatementType(int stmt)
- Return the query type of an OCI statement.
- */
-
-/* XXX it would be better with a general interface to OCIAttrGet() */
-
-PHP_FUNCTION(ocistatementtype)
-{
- pval *stmt;
- oci_statement *statement;
- ub2 stmttype;
-
- if (getParameters(ht, 1, &stmt) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(stmt);
- statement = oci_get_stmt(stmt->value.lval, "OCIStatementType", list);
- if (statement == NULL) {
- RETURN_FALSE;
- }
-
- statement->error =
- OCIAttrGet((dvoid *)statement->pStmt,
- OCI_HTYPE_STMT,
- (ub2 *)&stmttype,
- (ub4 *)0,
- OCI_ATTR_STMT_TYPE,
- statement->pError);
- if (statement->error != OCI_SUCCESS) {
- oci_error(statement->pError, "OCIStatementType", statement->error);
- RETURN_FALSE;
- }
-
- switch (stmttype) {
- case OCI_STMT_SELECT:
- RETVAL_STRING("SELECT",1);
- break;
- case OCI_STMT_UPDATE:
- RETVAL_STRING("UPDATE",1);
- break;
- case OCI_STMT_DELETE:
- RETVAL_STRING("DELETE",1);
- break;
- case OCI_STMT_INSERT:
- RETVAL_STRING("INSERT",1);
- break;
- case OCI_STMT_CREATE:
- RETVAL_STRING("CREATE",1);
- break;
- case OCI_STMT_DROP:
- RETVAL_STRING("DROP",1);
- break;
- case OCI_STMT_ALTER:
- RETVAL_STRING("ALTER",1);
- break;
- case OCI_STMT_BEGIN:
- RETVAL_STRING("BEGIN",1);
- break;
- case OCI_STMT_DECLARE:
- RETVAL_STRING("DECLARE",1);
- break;
- default:
- RETVAL_STRING("UNKNOWN",1);
- }
-}
-
-PHP_FUNCTION(ocirowcount)
-{
- pval *stmt;
- oci_statement *statement;
- ub4 rowcount;
-
- if (getParameters(ht, 1, &stmt) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(stmt);
- statement = oci_get_stmt(stmt->value.lval, "OCIStatementType", list);
- if (statement == NULL) {
- RETURN_FALSE;
- }
-
- statement->error =
- OCIAttrGet((dvoid *)statement->pStmt,
- OCI_HTYPE_STMT,
- (ub2 *)&rowcount,
- (ub4 *)0,
- OCI_ATTR_ROW_COUNT,
- statement->pError);
-
- if (statement->error != OCI_SUCCESS) {
- oci_error(statement->pError, "OCIRowCount", statement->error);
- RETURN_FALSE;
- }
-
- RETURN_LONG(rowcount);
-}
-
-/* }}} */
-
-#endif /* HAVE_OCI8 */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
-
diff --git a/ext/oci8/php3_oci8.h b/ext/oci8/php3_oci8.h
deleted file mode 100644
index 7c164c2055..0000000000
--- a/ext/oci8/php3_oci8.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundatbion; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Stig Sæther Bakken <ssb@fast.no> |
- | Thies C. Arntzen <thies@digicol.de> |
- | |
- | Initial work sponsored by Thies Arntzen <thies@digicol.de> of |
- | Digital Collections, http://www.digicol.de/ |
- +----------------------------------------------------------------------+
- */
-
-/* $Id */
-
-#if HAVE_OCI8
-# ifndef _PHP_OCI8_H
-# define _PHP_OCI8_H
-# endif
-
-# if (defined(__osf__) && defined(__alpha))
-# ifndef A_OSF
-# define A_OSF
-# endif
-# ifndef OSF1
-# define OSF1
-# endif
-# ifndef _INTRINSICS
-# define _INTRINSICS
-# endif
-# endif /* osf alpha */
-
-#if WIN32||WINNT
-#define PHP_OCI_API __declspec(dllexport)
-#else
-#define PHP_OCI_API
-#endif
-
-#include <oci.h>
-
-typedef struct {
- int num;
- int persistent;
- int open;
- char *dbname;
- OCIServer *pServer;
- OCIFocbkStruct failover;
-} oci_server;
-
-typedef struct {
- int num;
- int persistent;
- int open;
- oci_server *server;
- OCISession *pSession;
-} oci_session;
-
-typedef struct {
- int id;
- int open;
- oci_session *session;
- OCISvcCtx *pServiceContext;
- sword error;
- OCIError *pError;
- HashTable *descriptors;
- int descriptors_count;
-} oci_connection;
-
-typedef struct {
- dvoid *ocidescr;
- ub4 type;
-} oci_descriptor;
-
-typedef struct {
- pval *pval;
- text *name;
- ub4 name_len;
- ub4 type;
-} oci_define;
-
-typedef struct {
- int id;
- oci_connection *conn;
- sword error;
- OCIError *pError;
- OCIStmt *pStmt;
- char *last_query;
- HashTable *columns;
- int ncolumns;
- HashTable *binds;
- HashTable *defines;
- int executed;
-} oci_statement;
-
-typedef struct {
- OCIBind *pBind;
- pval *value;
- dvoid *descr; /* used for binding of LOBS etc */
- OCIStmt *pStmt; /* used for binding REFCURSORs */
- ub4 maxsize;
- sb2 indicator;
- ub2 retcode;
-} oci_bind;
-
-typedef struct {
- oci_statement *statement;
- OCIDefine *pDefine;
- char *name;
- ub4 name_len;
- ub2 data_type;
- ub2 data_size;
- ub4 storage_size4;
- sb2 indicator;
- ub2 retcode;
- ub2 retlen;
- ub4 retlen4;
- ub2 is_descr;
- ub2 is_cursor;
- int descr;
- oci_descriptor *pdescr;
- oci_statement *pstmt;
- int stmtid;
- void *data;
- oci_define *define;
- int piecewise;
- ub4 cb_retlen;
-} oci_out_column;
-
-typedef struct {
- sword error;
- OCIError *pError;
- char *default_username;
- char *default_password;
- char *default_dbname;
-
- long debug_mode;
-
- /* XXX NYI
- long allow_persistent;
- long max_persistent;
- long max_links;
- long num_persistent;
- long num_links;
- */
-
- int server_num;
- HashTable *server;
- int user_num;
- HashTable *user;
-
- OCIEnv *pEnv;
-} php_oci_globals;
-
-extern php3_module_entry oci8_module_entry;
-#define phpext_oci8_ptr &oci8_module_entry
-
-#define OCI_MAX_NAME_LEN 64
-#define OCI_MAX_DATA_SIZE INT_MAX
-#define OCI_PIECE_SIZE (64*1024)-1
-#define OCI_CONN_TYPE(x) ((x)==le_conn)
-#define OCI_STMT_TYPE(x) ((x)==le_stmt)
-
-#ifdef ZTS
-#define OCILS_D php_oci_globals *oci_globals
-#define OCILS_DC , PSLS_D
-#define OCILS_C oci_globals
-#define OCILS_CC , OCILS_C
-#define OCI(v) (oci_globals->v)
-#define OCILS_FETCH() php_oci_globals *oci_globals = ts_resource(oci_globals_id)
-#else
-#define OCILS_D
-#define OCILS_DC
-#define OCILS_C
-#define OCILS_CC
-#define OCI(v) (oci_globals.v)
-#define OCILS_FETCH()
-#endif
-
-#else /* !HAVE_OCI8 */
-
-# define oci8_module_ptr NULL
-
-#endif /* HAVE_OCI8 */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/oci8/setup.stub b/ext/oci8/setup.stub
deleted file mode 100644
index ee29b02f43..0000000000
--- a/ext/oci8/setup.stub
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-oci8 'oci8 support?' yesnodir no \
-' Whether to build the oci8 extension.'
-
diff --git a/ext/odbc/Makefile.am b/ext/odbc/Makefile.am
deleted file mode 100644
index 3daf4a20ec..0000000000
--- a/ext/odbc/Makefile.am
+++ /dev/null
@@ -1,4 +0,0 @@
-## Process this file with automake to produce Makefile.in
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_odbc.a
-libphpext_odbc_a_SOURCES=php_odbc.c velocis.c
diff --git a/ext/odbc/config.h.stub b/ext/odbc/config.h.stub
deleted file mode 100644
index 9bc73bdb07..0000000000
--- a/ext/odbc/config.h.stub
+++ /dev/null
@@ -1,9 +0,0 @@
-#define HAVE_SOLID 0
-#define HAVE_IODBC 0
-#define HAVE_UNIXODBC 0
-#define HAVE_OPENLINK 0
-#define HAVE_ADABAS 0
-#define HAVE_CODBC 0
-#define HAVE_UODBC 0
-#define HAVE_EMPRESS 0
-#define HAVE_VELOCIS 0
diff --git a/ext/odbc/config.m4 b/ext/odbc/config.m4
deleted file mode 100644
index 68fdd1be48..0000000000
--- a/ext/odbc/config.m4
+++ /dev/null
@@ -1,290 +0,0 @@
-dnl ODBC_INCDIR
-dnl ODBC_INCLUDE
-dnl ODBC_LIBDIR
-dnl ODBC_LIBS
-dnl ODBC_LFLAGS
-
-dnl
-dnl Figure out which library file to link with for the Solid support.
-dnl
-AC_DEFUN(AC_FIND_SOLID_LIBS,[
- AC_MSG_CHECKING([Solid library file])
- ac_solid_uname_s=`uname -s 2>/dev/null`
- case $ac_solid_uname_s in
- AIX) ac_solid_os=a3x;;
- HP-UX) ac_solid_os=h9x;;
- IRIX) ac_solid_os=irx;;
- Linux) ac_solid_os=lux;;
- SunOS) ac_solid_os=ssx;; # should we deal with SunOS 4?
- FreeBSD) ac_solid_os=fbx;;
- # "uname -s" on SCO makes no sense.
- esac
- ODBC_LIBS=`echo $1/scl${ac_solid_os}*.so | cut -d' ' -f1`
- if test ! -f $ODBC_LIBS; then
- ODBC_LIBS=`echo $1/scl${ac_solid_os}*.a | cut -d' ' -f1`
- fi
- if test ! -f $ODBC_LIBS; then
- ODBC_LIBS=`echo $1/scl2x${ac_solid_os}*.a | cut -d' ' -f1`
- fi
- if test ! -f $ODBC_LIBS; then
- ODBC_LIBS=`echo $1/scl2x${ac_solid_os}*.a | cut -d' ' -f1`
- fi
- if test ! -f $ODBC_LIBS; then
- ODBC_LIBS=`echo $1/bcl${ac_solid_os}*.so | cut -d' ' -f1`
- fi
- if test ! -f $ODBC_LIBS; then
- ODBC_LIBS=`echo $1/bcl${ac_solid_os}*.a | cut -d' ' -f1`
- fi
- AC_MSG_RESULT(`echo $ODBC_LIBS | sed -e 's!.*/!!'`)
-])
-
-dnl
-dnl Figure out which library file to link with for the Empress support.
-dnl
-AC_DEFUN(AC_FIND_EMPRESS_LIBS,[
- AC_MSG_CHECKING([Empress library file])
- ODBC_LIBS=`echo $1/empodbc.so | cut -d' ' -f1`
- if test ! -f $ODBC_LIBS; then
- ODBC_LIBS=`echo $1/empodbc.a | cut -d' ' -f1`
- fi
- AC_MSG_RESULT(`echo $ODBC_LIBS | sed -e 's!.*/!!'`)
-])
-
-if test -z "$ODBC_TYPE"; then
-AC_MSG_CHECKING(for Adabas support)
-AC_ARG_WITH(adabas,
-[ --with-adabas[=DIR] Include Adabas D support. DIR is the Adabas base
- install directory, defaults to /usr/local.],
-[
- if test "$withval" = "yes"; then
- withval=/usr/local
- fi
- if test "$withval" != "no"; then
- ODBC_INCDIR=$withval/incl
- ODBC_LIBDIR=$withval/lib
- ODBC_LFLAGS=-L$ODBC_LIBDIR
- ODBC_INCLUDE=-I$ODBC_INCDIR
- ODBC_LIBS="${ODBC_LIBDIR}/odbclib.a -lsqlrte -lsqlptc"
- ODBC_TYPE=adabas
- AC_DEFINE(HAVE_ADABAS)
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-fi
-
-if test -z "$ODBC_TYPE"; then
-AC_MSG_CHECKING(for Solid support)
-AC_ARG_WITH(solid,
-[ --with-solid[=DIR] Include Solid support. DIR is the Solid base
- install directory, defaults to /usr/local/solid],
-[
- if test "$withval" = "yes"; then
- withval=/usr/local/solid
- fi
- if test "$withval" != "no"; then
- ODBC_INCDIR=$withval/include
- ODBC_LIBDIR=$withval/lib
- ODBC_INCLUDE=-I$ODBC_INCDIR
- ODBC_TYPE=solid
- AC_DEFINE(HAVE_SOLID)
- AC_MSG_RESULT(yes)
- AC_FIND_SOLID_LIBS($ODBC_LIBDIR)
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-fi
-
-if test -z "$ODBC_TYPE"; then
-AC_MSG_CHECKING(for Empress support)
-AC_ARG_WITH(empress,
-[ --with-empress[=DIR] Include Empress support. DIR is the Empress base
- install directory, defaults to \$EMPRESSPATH],
-[
- if test "$withval" != "no"; then
- if test "$withval" = "yes"; then
- ODBC_INCDIR=$EMPRESSPATH/odbccl/include
- ODBC_LIBDIR=$EMPRESSPATH/odbccl/lib
- else
- ODBC_INCDIR=$withval/include
- ODBC_LIBDIR=$withval/lib
- fi
- ODBC_INCLUDE=-I$ODBC_INCDIR
- ODBC_TYPE=empress
- AC_DEFINE(HAVE_EMPRESS)
- AC_MSG_RESULT(yes)
- AC_FIND_EMPRESS_LIBS($ODBC_LIBDIR)
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-fi
-
-if test -z "$ODBC_TYPE"; then
-AC_MSG_CHECKING(for Velocis support)
-AC_ARG_WITH(velocis,
-[ --with-velocis[=DIR] Include Velocis support. DIR is the Velocis base
- install directory, defaults to /usr/local/velocis.],
-[
- if test "$withval" != "no"; then
- if test "$withval" = "yes"; then
- ODBC_INCDIR=/usr/local/velocis/include
- ODBC_LIBDIR=/usr/local/velocis
- else
- ODBC_INCDIR=$withval/include
- ODBC_LIBDIR=$withval
- fi
- ODBC_INCLUDE=-I$ODBC_INCDIR
- ODBC_LIBDIR="$ODBC_LIBDIR/bin"
- case `uname` in
- FreeBSD|BSD/OS)
- ODBC_LIBS="$ODBC_LIBDIR/../lib/rdscli.a -lcompat";;
- *)
- ODBC_LIBS="-l_rdbc -l_sql";;
- esac
- ODBC_TYPE=velocis
- AC_DEFINE(HAVE_VELOCIS)
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-fi
-
-if test -z "$ODBC_TYPE"; then
-AC_MSG_CHECKING(for a custom ODBC support)
-AC_ARG_WITH(custom-odbc,
-[ --with-custom-odbc[=DIR]
- Include a user defined ODBC support.
- The DIR is ODBC install base directory,
- which defaults to /usr/local.
- Make sure to define CUSTOM_ODBC_LIBS and
- have some odbc.h in your include dirs.
- E.g., you should define following for
- Sybase SQL Anywhere 5.5.00 on QNX, prior to
- run configure script:
- CFLAGS=\"-DODBC_QNX -DSQLANY_BUG\"
- LDFLAGS=-lunix
- CUSTOM_ODBC_LIBS=\"-ldblib -lodbc\".],
-[
- if test "$withval" = "yes"; then
- withval=/usr/local
- fi
- if test "$withval" != "no"; then
- ODBC_INCDIR=$withval/include
- ODBC_LIBDIR=$withval/lib
- ODBC_LFLAGS=-L$ODBC_LIBDIR
- ODBC_INCLUDE=-I$ODBC_INCDIR
- ODBC_LIBS=$CUSTOM_ODBC_LIBS
- ODBC_TYPE=custom
- AC_DEFINE(HAVE_CODBC)
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-fi
-
-if test -z "$ODBC_TYPE"; then
-AC_MSG_CHECKING(for iODBC support)
-AC_ARG_WITH(iodbc,
-[ --with-iodbc[=DIR] Include iODBC support. DIR is the iODBC base
- install directory, defaults to /usr/local.],
-[
- if test "$withval" = "yes"; then
- withval=/usr/local
- fi
- if test "$withval" != "no"; then
- ODBC_INCDIR=$withval/include
- ODBC_LIBDIR=$withval/lib
- ODBC_LFLAGS=-L$ODBC_LIBDIR
- ODBC_INCLUDE=-I$ODBC_INCDIR
- ODBC_LIBS=-liodbc
- ODBC_TYPE=iodbc
- AC_DEFINE(HAVE_IODBC)
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-fi
-
-if test -z "$ODBC_TYPE"; then
-AC_MSG_CHECKING(for unixODBC support)
-AC_ARG_WITH(unixODBC,
-[ --with-unixODBC[=DIR] Include unixODBC support. DIR is the unixODBC base
- install directory, defaults to /usr/local.],
-[
- if test "$withval" = "yes"; then
- withval=/usr/local
- fi
- if test "$withval" != "no"; then
- ODBC_INCDIR=$withval/include
- ODBC_LIBDIR=$withval/lib
- ODBC_LFLAGS=-L$ODBC_LIBDIR
- ODBC_INCLUDE=-I$ODBC_INCDIR
- ODBC_LIBS=-lodbc
- ODBC_TYPE=unixODBC
- AC_DEFINE(HAVE_UNIXODBC)
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-fi
-
-if test -z "$ODBC_TYPE"; then
-AC_MSG_CHECKING(for OpenLink ODBC support)
-AC_ARG_WITH(openlink,
-[ --with-openlink[=DIR] Include OpenLink ODBC support. DIR is the
- OpenLink base install directory, defaults to
- /usr/local/openlink.],
-[
- if test "$withval" = "yes"; then
- withval=/usr/local/openlink
- fi
- if test "$withval" != "no"; then
- ODBC_INCDIR=$withval/odbcsdk/include
- ODBC_LIBDIR=$withval/odbcsdk/lib
- ODBC_LFLAGS=-L$OPENLINK_LIBDIR
- ODBC_INCLUDE=-I$OPENLINK_INCDIR
- ODBC_LIBS=-liodbc
- ODBC_TYPE=openlink
- AC_DEFINE(HAVE_OPENLINK)
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-fi
-
-if test -n "$ODBC_TYPE"; then
- INCLUDES="$INCLUDES $ODBC_INCLUDE"
- EXTRA_LIBS="$EXTRA_LIBS $ODBC_LFLAGS $ODBC_LIBS"
- AC_DEFINE(HAVE_UODBC, 1)
- AC_SUBST(ODBC_INCDIR)
- AC_SUBST(ODBC_INCLUDE)
- AC_SUBST(ODBC_LIBDIR)
- AC_SUBST(ODBC_LIBS)
- AC_SUBST(ODBC_LFLAGS)
- AC_SUBST(ODBC_TYPE)
- PHP_EXTENSION(odbc)
-fi
diff --git a/ext/odbc/php3_velocis.h b/ext/odbc/php3_velocis.h
deleted file mode 100644
index 2edb1f2528..0000000000
--- a/ext/odbc/php3_velocis.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Nikolay P. Romanyuk <mag@redcom.ru> |
- | |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _PHP3_VELOCIS_H
-#define _PHP3_VELOCIS_H
-
-#if COMPILE_DL
-#undef HAVE_VELOCIS
-#define HAVE_VELOCIS 1
-#endif
-
-#if HAVE_VELOCIS && !HAVE_UODBC
-#define UNIX
-#include <sql.h>
-#include <sqlext.h>
-
-typedef struct VConn {
- HDBC hdbc;
- long index;
-} VConn;
-
-typedef struct {
- char name[32];
- char *value;
- long vallen;
- SDWORD valtype;
-} VResVal;
-
-typedef struct Vresult {
- HSTMT hstmt;
- VConn *conn;
- long index;
- VResVal *values;
- long numcols;
- int fetched;
-} Vresult;
-
-typedef struct {
- long num_links;
- long max_links;
- int le_link,le_result;
-} velocis_module;
-
-extern php3_module_entry velocis_module_entry;
-#define velocis_module_ptr &velocis_module_entry
-
-/* velocis.c functions */
-extern PHP_MINIT_FUNCTION(velocis);
-extern PHP_RINIT_FUNCTION(velocis);
-PHP_MINFO_FUNCTION(velocis);
-extern PHP_MSHUTDOWN_FUNCTION(velocis);
-
-PHP_FUNCTION(velocis_connect);
-PHP_FUNCTION(velocis_close);
-PHP_FUNCTION(velocis_exec);
-PHP_FUNCTION(velocis_fetch);
-PHP_FUNCTION(velocis_result);
-PHP_FUNCTION(velocis_freeresult);
-PHP_FUNCTION(velocis_autocommit);
-PHP_FUNCTION(velocis_off_autocommit);
-PHP_FUNCTION(velocis_commit);
-PHP_FUNCTION(velocis_rollback);
-PHP_FUNCTION(velocis_fieldnum);
-PHP_FUNCTION(velocis_fieldname);
-
-extern velocis_module php3_velocis_module;
-
-#else
-
-#define velocis_module_ptr NULL
-
-#endif /* HAVE_VELOCIS */
-#endif /* _PHP3_VELOCIS_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
deleted file mode 100644
index 6b46ee5307..0000000000
--- a/ext/odbc/php_odbc.c
+++ /dev/null
@@ -1,2067 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Stig Sæther Bakken <ssb@fast.no> |
- | Andreas Karajannis <Andreas.Karajannis@gmd.de> |
- | Frank M. Kromann <fmk@businessnet.dk> Support for DB/2 CLI |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#if COMPILE_DL
-#include "dl/phpdl.h"
-#endif
-
-#include "php.h"
-#include "php_globals.h"
-#include "ext/standard/php3_standard.h"
-#include "php_odbc.h"
-
-#if HAVE_UODBC
-
-#include <fcntl.h>
-#include "ext/standard/head.h"
-#include "snprintf.h"
-#include "php_ini.h"
-
-#if WIN32|WINNT
-#include <winsock.h>
-#else
-#include "build-defs.h"
-#endif
-
-void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent);
-
-static int le_result, le_conn, le_pconn;
-
-function_entry odbc_functions[] = {
- PHP_FE(odbc_setoption, NULL)
- PHP_FE(odbc_autocommit, NULL)
- PHP_FE(odbc_close, NULL)
- PHP_FE(odbc_close_all, NULL)
- PHP_FE(odbc_commit, NULL)
- PHP_FE(odbc_connect, NULL)
- PHP_FE(odbc_pconnect, NULL)
- PHP_FE(odbc_cursor, NULL)
- PHP_FE(odbc_exec, NULL)
- PHP_FE(odbc_prepare, NULL)
- PHP_FE(odbc_execute, NULL)
- PHP_FE(odbc_fetch_row, NULL)
- PHP_FE(odbc_fetch_into, NULL)
- PHP_FE(odbc_field_len, NULL)
- PHP_FE(odbc_field_name, NULL)
- PHP_FE(odbc_field_type, NULL)
- PHP_FE(odbc_field_num, NULL)
- PHP_FE(odbc_free_result, NULL)
- PHP_FE(odbc_num_fields, NULL)
- PHP_FE(odbc_num_rows, NULL)
- PHP_FE(odbc_result, NULL)
- PHP_FE(odbc_result_all, NULL)
- PHP_FE(odbc_rollback, NULL)
- PHP_FE(odbc_binmode, NULL)
- PHP_FE(odbc_longreadlen, NULL)
-/* PHP_FE(odbc_bind_param, NULL)
- PHP_FE(odbc_define, NULL)*/
- PHP_FALIAS(odbc_do, odbc_exec, NULL)
- { NULL, NULL, NULL }
-};
-
-php3_module_entry odbc_module_entry = {
- "ODBC",
- odbc_functions,
- PHP_MINIT(odbc),
- PHP_MSHUTDOWN(odbc),
- PHP_RINIT(odbc),
- NULL,
- PHP_MINFO(odbc),
- STANDARD_MODULE_PROPERTIES
-};
-
-#ifdef ZTS
-int odbc_globals_id;
-#else
-ZEND_API php_odbc_globals odbc_globals;
-#endif
-
-#if COMPILE_DL
-DLEXPORT zend_module_entry *get_module(void) { return &odbc_module_entry; };
-#endif
-
-static void _free_odbc_result(odbc_result *res)
-{
- int i;
-
- if (res){
- if (res->values) {
- for(i = 0; i < res->numcols; i++){
- if (res->values[i].value)
- efree(res->values[i].value);
- }
- efree(res->values);
- res->values = NULL;
- }
- if (res->stmt){
-#if HAVE_SOLID
- SQLTransact(ODBCG(henv), res->conn_ptr->hdbc,
- (UWORD)SQL_COMMIT);
-#endif
- SQLFreeStmt(res->stmt,SQL_DROP);
-#if !HAVE_DB2
- res->stmt = NULL;
-#endif
- }
- efree(res);
- }
-}
-
-static void _close_odbc_conn(odbc_connection *conn)
-{
- /* FIXME
- * Closing a connection will fail if there are
- * pending transactions. It is in the responsibility
- * of the user to avoid this.
- */
- ODBCLS_FETCH();
-
- SQLDisconnect(conn->hdbc);
- SQLFreeConnect(conn->hdbc);
- efree(conn);
- ODBCG(num_links)--;
-}
-
-static void _close_odbc_pconn(odbc_connection *conn)
-{
- ODBCLS_FETCH();
-
- conn->open = 0;
- SQLDisconnect(conn->hdbc);
- SQLFreeConnect(conn->hdbc);
- free(conn);
-
- ODBCG(num_links)--;
- ODBCG(num_persistent)--;
-}
-
-static PHP_INI_DISP(display_link_nums)
-{
- char *value;
-
- if(type == PHP_INI_DISPLAY_ORIG && ini_entry->modified){
- value = ini_entry->orig_value;
- }else if(ini_entry->value){
- value = ini_entry->value;
- }else{
- value = NULL;
- }
-
- if(value){
- if(atoi(value) == -1){
- PUTS("Unlimited");
- }else{
- php_printf("%s", value);
- }
- }
-}
-
-static PHP_INI_DISP(display_defPW)
-{
- char *value;
-
- if(type == PHP_INI_DISPLAY_ORIG && ini_entry->modified){
- value = ini_entry->orig_value;
- }else if(ini_entry->value){
- value = ini_entry->value;
- }else{
- value = NULL;
- }
-
- if(value){
-#if DEBUG
- php_printf("%s", value);
-#else
- PUTS("********");
-#endif
- }
-}
-
-static PHP_INI_DISP(display_binmode)
-{
- char *value;
-
- if(type == PHP_INI_DISPLAY_ORIG && ini_entry->modified){
- value = ini_entry->orig_value;
- }else if(ini_entry->value){
- value = ini_entry->value;
- }else{
- value = NULL;
- }
-
- if(value){
- switch(atoi(value)){
- case 0:
- PUTS("passthru");
- break;
- case 1:
- PUTS("return as is");
- break;
- case 2:
- PUTS("return as char");
- break;
- }
- }
-}
-
-static PHP_INI_DISP(display_lrl)
-{
- char *value;
-
- if(type == PHP_INI_DISPLAY_ORIG && ini_entry->modified){
- value = ini_entry->orig_value;
- }else if(ini_entry->value){
- value = ini_entry->value;
- }else{
- value = NULL;
- }
-
- if(value){
- if(atoi(value) <= 0){
- PUTS("Passthru");
- }else{
- php3_printf("return up to %s bytes", value);
- }
- }
-}
-
-PHP_INI_BEGIN()
- STD_PHP_INI_BOOLEAN("odbc.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateInt,
- allow_persistent, php_odbc_globals, odbc_globals)
- STD_PHP_INI_ENTRY_EX("odbc.max_persistent", "-1", PHP_INI_SYSTEM, OnUpdateInt,
- max_persistent, php_odbc_globals, odbc_globals, display_link_nums)
- STD_PHP_INI_ENTRY_EX("odbc.max_links", "-1", PHP_INI_SYSTEM, OnUpdateInt,
- max_links, php_odbc_globals, odbc_globals, display_link_nums)
- STD_PHP_INI_ENTRY("odbc.default_db", NULL, PHP_INI_ALL, OnUpdateString,
- defDB, php_odbc_globals, odbc_globals)
- STD_PHP_INI_ENTRY("odbc.default_user", NULL, PHP_INI_ALL, OnUpdateString,
- defUser, php_odbc_globals, odbc_globals)
- STD_PHP_INI_ENTRY_EX("odbc.default_pw", NULL, PHP_INI_ALL, OnUpdateString,
- defPW, php_odbc_globals, odbc_globals, display_defPW)
- STD_PHP_INI_ENTRY_EX("odbc.defaultlrl", "4096", PHP_INI_ALL, OnUpdateInt,
- defaultlrl, php_odbc_globals, odbc_globals, display_lrl)
- STD_PHP_INI_ENTRY_EX("odbc.defaultbinmode", "1", PHP_INI_ALL, OnUpdateInt,
- defaultbinmode, php_odbc_globals, odbc_globals, display_binmode)
-PHP_INI_END()
-
-#ifdef ZTS
-static void php_odbc_init_globals(php_odbc_globals *odbc_globals)
-{
- ODBCG(num_persistent) = 0;
-}
-#endif
-
-PHP_MINIT_FUNCTION(odbc)
-{
- ELS_FETCH();
-#ifdef SQLANY_BUG
- HDBC foobar;
- RETCODE rc;
-#endif
-
-#ifdef ZTS
- odbc_globals_id = ts_allocate_id(sizeof(php_odbc_globals), php_odbc_init_globals, NULL);
-#else
- ODBCG(num_persistent) = 0;
-#endif
-
- REGISTER_INI_ENTRIES();
- SQLAllocEnv(&ODBCG(henv));
- le_result = register_list_destructors(_free_odbc_result, NULL);
- le_conn = register_list_destructors(_close_odbc_conn, NULL);
- le_pconn = register_list_destructors(NULL, _close_odbc_pconn);
- odbc_module_entry.type = type;
-
- SQLAllocEnv(&ODBCG(henv));
-#ifdef SQLANY_BUG
- /* Make a dumb connection to avoid crash on SQLFreeEnv(),
- * then release it immediately.
- * This is required for SQL Anywhere 5.5.00 on QNX 4.24 at least.
- * The SQLANY_BUG should be defined in CFLAGS.
- */
- if ( SQLAllocConnect(ODBCG(henv), &foobar) != SQL_SUCCESS ) {
- ODBC_SQL_ERROR(SQL_NULL_HDBC, SQL_NULL_HSTMT, "SQLAllocConnect");
- } else {
- rc = SQLConnect(foobar, ODBCG(defDB), SQL_NTS, ODBCG(defUser),
- SQL_NTS, ODBCG(defPW), SQL_NTS);
- if(rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO)
- SQLDisconnect( foobar );
- SQLFreeConnect( foobar );
- }
-#endif
-
- REGISTER_LONG_CONSTANT("ODBC_BINMODE_PASSTHRU", 0, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("ODBC_BINMODE_RETURN", 1, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("ODBC_BINMODE_CONVERT", 2, CONST_CS | CONST_PERSISTENT);
- /* Define Constants for options
- these Constants are are defined in <sqlext.h>
- */
- REGISTER_LONG_CONSTANT("SQL_ODBC_CURSORS", SQL_ODBC_CURSORS, CONST_PERSISTENT | CONST_CS);
- REGISTER_LONG_CONSTANT("SQL_CUR_USE_DRIVER", SQL_CUR_USE_DRIVER, CONST_PERSISTENT | CONST_CS);
- REGISTER_LONG_CONSTANT("SQL_CUR_USE_IF_NEEDED", SQL_CUR_USE_IF_NEEDED, CONST_PERSISTENT | CONST_CS);
- REGISTER_LONG_CONSTANT("SQL_CUR_USE_ODBC", SQL_CUR_USE_ODBC, CONST_PERSISTENT | CONST_CS);
-
-
- REGISTER_LONG_CONSTANT("SQL_CONCURRENCY", SQL_CONCURRENCY, CONST_PERSISTENT | CONST_CS);
- REGISTER_LONG_CONSTANT("SQL_CONCUR_READ_ONLY", SQL_CONCUR_READ_ONLY, CONST_PERSISTENT | CONST_CS);
- REGISTER_LONG_CONSTANT("SQL_CONCUR_LOCK", SQL_CONCUR_LOCK, CONST_PERSISTENT | CONST_CS);
- REGISTER_LONG_CONSTANT("SQL_CONCUR_ROWVER", SQL_CONCUR_ROWVER, CONST_PERSISTENT | CONST_CS);
- REGISTER_LONG_CONSTANT("SQL_CONCUR_VALUES", SQL_CONCUR_VALUES, CONST_PERSISTENT | CONST_CS);
-
- REGISTER_LONG_CONSTANT("SQL_CURSOR_TYPE", SQL_CURSOR_TYPE, CONST_PERSISTENT | CONST_CS);
- REGISTER_LONG_CONSTANT("SQL_CURSOR_FORWARD_ONLY", SQL_CURSOR_FORWARD_ONLY, CONST_PERSISTENT | CONST_CS);
- REGISTER_LONG_CONSTANT("SQL_CURSOR_KEYSET_DRIVEN", SQL_CURSOR_KEYSET_DRIVEN, CONST_PERSISTENT | CONST_CS);
- REGISTER_LONG_CONSTANT("SQL_CURSOR_DYNAMIC", SQL_CURSOR_DYNAMIC, CONST_PERSISTENT | CONST_CS);
- REGISTER_LONG_CONSTANT("SQL_CURSOR_STATIC", SQL_CURSOR_STATIC, CONST_PERSISTENT | CONST_CS);
-
- REGISTER_LONG_CONSTANT("SQL_KEYSET_SIZE", SQL_KEYSET_SIZE, CONST_PERSISTENT | CONST_CS);
-
- return SUCCESS;
-}
-
-
-PHP_RINIT_FUNCTION(odbc)
-{
- ODBCLS_FETCH();
-
- ODBCG(defConn) = -1;
- ODBCG(num_links) = ODBCG(num_persistent);
- return SUCCESS;
-}
-
-PHP_MSHUTDOWN_FUNCTION(odbc)
-{
- ODBCLS_FETCH();
-
- UNREGISTER_INI_ENTRIES();
- SQLFreeEnv(ODBCG(henv));
- return SUCCESS;
-}
-
-PHP_MINFO_FUNCTION(odbc)
-{
- char buf[32];
- ODBCLS_FETCH();
-
- DISPLAY_INI_ENTRIES();
-
- php_printf("<table border=5 width=\"600\">");
- php_info_print_table_header(2, "Key", "Value");
- sprintf(buf, "%ld", ODBCG(num_persistent));
- php_info_print_table_row(2, "Active Persistent Links", buf);
- sprintf(buf, "%ld", ODBCG(num_links));
- php_info_print_table_row(2, "Active Links", buf);
- php_info_print_table_row(2, "ODBC library", PHP_ODBC_TYPE);
-#if !(WIN32|WINNT)
- php_info_print_table_row(2, "ODBC_INCLUDE", PHP_ODBC_INCLUDE);
- php_info_print_table_row(2, "ODBC_LFLAGS", PHP_ODBC_LFLAGS);
- php_info_print_table_row(2, "ODBC_LIBS", PHP_ODBC_LIBS);
-#endif
- php_printf("</table>\n");
-}
-
-#if HAVE_DB2
-void ODBC_SQL_ERROR(SQLHANDLE conn, SQLHANDLE stmt, char *func)
-#else
-void ODBC_SQL_ERROR(HDBC conn, HSTMT stmt, char *func)
-#endif
-{
- char state[6]; /* Not used */
- SDWORD error; /* Not used */
- char errormsg[255];
- SWORD errormsgsize; /* Not used */
- ODBC_TLS_VARS;
-
- SQLError(ODBCG(henv), conn, stmt, state,
- &error, errormsg, sizeof(errormsg)-1, &errormsgsize);
- if (func) {
- php_error(E_WARNING, "SQL error: %s, SQL state %s in %s",
- errormsg, state, func);
- } else {
- php_error(E_WARNING, "SQL error: %s, SQL state %s",
- errormsg, state);
- }
-}
-
-void php3_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAMETERS, int mode)
-{
- odbc_result *result;
- pval *pv_res, *pv_flag;
- ODBCLS_FETCH();
- PLS_FETCH();
-
- if (getParameters(ht, 2, &pv_res, &mode) == FAILURE)
- WRONG_PARAM_COUNT;
-
- convert_to_long(pv_flag);
-
- if(pv_res->value.lval){
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
- if(mode)
- result->longreadlen = pv_flag->value.lval;
- else
- result->binmode = pv_flag->value.lval;
- }else{
- if(mode)
- ODBCG(defaultlrl) = pv_flag->value.lval;
- else
- ODBCG(defaultbinmode) = pv_flag->value.lval;
- }
- RETURN_TRUE;
-}
-
-
-int odbc_bindcols(odbc_result *result)
-{
- int i;
- SWORD colnamelen; /* Not used */
- SDWORD displaysize;
-
- result->values = (odbc_result_value *)
- emalloc(sizeof(odbc_result_value)*result->numcols);
-
- if(result->values == NULL){
- php_error(E_WARNING, "Out of memory");
- SQLFreeStmt(result->stmt, SQL_DROP);
- return 0;
- }
-
- result->longreadlen = ODBCG(defaultlrl);
- result->binmode = ODBCG(defaultbinmode);
-
- for(i = 0; i < result->numcols; i++){
- SQLColAttributes(result->stmt, (UWORD)(i+1), SQL_COLUMN_NAME,
- result->values[i].name,
- sizeof(result->values[i].name),
- &colnamelen,
- 0);
- SQLColAttributes(result->stmt, (UWORD)(i+1), SQL_COLUMN_TYPE,
- NULL, 0, NULL, &result->values[i].coltype);
-
- /* Don't bind LONG / BINARY columns, so that fetch behaviour can
- be controlled by odbc_binmode() / odbc_longreadlen()
- */
-
- switch(result->values[i].coltype){
- case SQL_BINARY:
- case SQL_VARBINARY:
- case SQL_LONGVARBINARY:
- case SQL_LONGVARCHAR:
- result->values[i].value = NULL;
- break;
-
-#if HAVE_ADABAS
- case SQL_TIMESTAMP:
- result->values[i].value = (char *)emalloc(27);
- SQLBindCol(result->stmt, (UWORD)(i+1), SQL_C_CHAR, result->values[i].value,
- 27, &result->values[i].vallen);
- break;
-#endif /* HAVE_ADABAS */
- default:
- SQLColAttributes(result->stmt, (UWORD)(i+1), SQL_COLUMN_DISPLAY_SIZE,
- NULL, 0, NULL, &displaysize);
- result->values[i].value = (char *)emalloc(displaysize + 1);
- SQLBindCol(result->stmt, (UWORD)(i+1), SQL_C_CHAR, result->values[i].value,
- displaysize + 1, &result->values[i].vallen);
- break;
- }
- }
- return 1;
-}
-
-void odbc_transact(INTERNAL_FUNCTION_PARAMETERS, int type)
-{
- odbc_connection *conn;
- RETCODE rc;
- pval *pv_conn;
- ODBCLS_FETCH();
-
- if(getParameters(ht, 1, &pv_conn) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- conn = (odbc_connection *) zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
-
- rc = SQLTransact(ODBCG(henv), conn->hdbc, (UWORD)((type)?SQL_COMMIT:SQL_ROLLBACK));
- if(rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
- ODBC_SQL_ERROR(conn->hdbc, SQL_NULL_HSTMT, "SQLTransact");
- RETURN_FALSE;
- }
-
- RETURN_TRUE;
-}
-
-/* Main User Functions */
-/* {{{ proto void odbc_close_all(void)
- Close all ODBC connections */
-/* XXX Convert to new resource model */
-PHP_FUNCTION(odbc_close_all)
-{
- void *ptr;
- int type;
- int i, nument = zend_hash_next_free_element(list);
-
- for(i = 1; i < nument; i++){
- ptr = php3_list_find(i, &type);
- if(ptr && (type == le_conn || type == le_pconn)){
- php3_list_delete(i);
- }
- }
-}
-/* }}} */
-
-/* {{{ proto int odbc_binmode(int result_id, int mode)
- Handle binary column data */
-PHP_FUNCTION(odbc_binmode)
-{
- php3_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
-}
-/* }}} */
-
-/* {{{ proto int odbc_longreadlen(int result_id, int length)
- Handle LONG columns */
-PHP_FUNCTION(odbc_longreadlen)
-{
- php3_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
-}
-/* }}} */
-
-/* {{{ proto int odbc_prepare(int connection_id, string query)
- Prepares a statement for execution */
-PHP_FUNCTION(odbc_prepare)
-{
- pval *pv_conn, *pv_query;
- char *query;
- odbc_result *result = NULL;
- odbc_connection *conn;
- RETCODE rc;
-
- if(getParameters(ht, 2, &pv_conn, &pv_query) == FAILURE){
- WRONG_PARAM_COUNT;
- }
-
- conn = (odbc_connection *)zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
-
- convert_to_string(pv_query);
- query = pv_query->value.str.val;
-
- result = (odbc_result *)emalloc(sizeof(odbc_result));
- if(result == NULL){
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
-
- result->numparams = 0;
-
- rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
- if(rc == SQL_INVALID_HANDLE){
- efree(result);
- php_error(E_WARNING, "SQLAllocStmt error 'Invalid Handle' in php3_odbc_prepare");
- RETURN_FALSE;
- }
-
- if(rc == SQL_ERROR){
- ODBC_SQL_ERROR(conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
- efree(result);
- RETURN_FALSE;
- }
-
- if((rc = SQLPrepare(result->stmt, query, SQL_NTS)) != SQL_SUCCESS){
- ODBC_SQL_ERROR(conn->hdbc, result->stmt, "SQLPrepare");
- SQLFreeStmt(result->stmt, SQL_DROP);
- RETURN_FALSE;
- }
-
- SQLNumParams(result->stmt, &(result->numparams));
- SQLNumResultCols(result->stmt, &(result->numcols));
-
- if(result->numcols > 0){
- if(!odbc_bindcols(result)){
- efree(result);
- RETURN_FALSE;
- }
- }else{
- result->values = NULL;
- }
- result->conn_ptr = conn;
- result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
-}
-/* }}} */
-
-/*
- * Execute prepared SQL statement. Supports only input parameters.
- */
-/* {{{ proto int odbc_execute(int result_id [, array parameters_array])
- Execute a prepared statement */
-PHP_FUNCTION(odbc_execute)
-{
- pval *pv_res, *pv_param_arr, **tmp;
- typedef struct params_t {
- SDWORD vallen;
- int fp;
- } params_t;
- params_t *params = NULL;
- char *filename;
- SWORD sqltype, ctype, scale, nullable;
- UDWORD precision;
- odbc_result *result;
- int numArgs, i, ne;
- RETCODE rc;
-
- numArgs = ARG_COUNT(ht);
- if(numArgs == 1){
- if(getParameters(ht, 1, &pv_res) == FAILURE)
- WRONG_PARAM_COUNT;
- }else{
- if(getParameters(ht, 2, &pv_res, &pv_param_arr) == FAILURE)
- WRONG_PARAM_COUNT;
-
- if(pv_param_arr->type != IS_ARRAY){
- php_error(E_WARNING, "No array passed to odbc_execute()");
- return;
- }
- }
-
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
-
- /* XXX check for already bound parameters*/
- if(result->numparams > 0 && numArgs == 1){
- php_error(E_WARNING, "No parameters to SQL statement given");
- RETURN_FALSE;
- }
-
- if(result->numparams > 0){
- if((ne = zend_hash_num_elements(pv_param_arr->value.ht)) < result->numparams){
- php_error(E_WARNING,"Not enough parameters (%d should be %d) given",
- ne, result->numparams);
- RETURN_FALSE;
- }
-
- zend_hash_internal_pointer_reset(pv_param_arr->value.ht);
- params = (params_t *)emalloc(sizeof(params_t) * result->numparams);
-
- for(i = 1; i <= result->numparams; i++){
- if(zend_hash_get_current_data(pv_param_arr->value.ht, (void **) &tmp) == FAILURE){
- php_error(E_WARNING,"Error getting parameter");
- SQLFreeStmt(result->stmt,SQL_RESET_PARAMS);
- efree(params);
- RETURN_FALSE;
- }
- convert_to_string(*tmp);
- if((*tmp)->type != IS_STRING){
- php_error(E_WARNING,"Error converting parameter");
- SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
- efree(params);
- RETURN_FALSE;
- }
-
- SQLDescribeParam(result->stmt, (UWORD)i, &sqltype, &precision,
- &scale, &nullable);
- params[i-1].vallen = (*tmp)->value.str.len;
- params[i-1].fp = -1;
-
- if(IS_SQL_BINARY(sqltype))
- ctype = SQL_C_BINARY;
- else
- ctype = SQL_C_CHAR;
-
- if((*tmp)->value.str.val[0] == '\'' &&
- (*tmp)->value.str.val[(*tmp)->value.str.len - 1] == '\''){
- filename = &(*tmp)->value.str.val[1];
- filename[(*tmp)->value.str.len - 2] = '\0';
-
- if((params[i-1].fp = open(filename,O_RDONLY)) == -1){
- php_error(E_WARNING,"Can't open file %s", filename);
- SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
- for(i = 0; i < result->numparams; i++){
- if(params[i].fp != -1){
- close(params[i].fp);
- }
- }
- efree(params);
- RETURN_FALSE;
- }
-
- params[i-1].vallen = SQL_LEN_DATA_AT_EXEC(0);
-
- rc = SQLBindParameter(result->stmt, (UWORD)i, SQL_PARAM_INPUT,
- ctype, sqltype, precision, scale,
- (void *)params[i-1].fp, 0,
- &params[i-1].vallen);
- }else{
- rc = SQLBindParameter(result->stmt, (UWORD)i, SQL_PARAM_INPUT,
- ctype, sqltype, precision, scale,
- (*tmp)->value.str.val, 0,
- &params[i-1].vallen);
- }
- zend_hash_move_forward(pv_param_arr->value.ht);
- }
- }
- /* Close cursor, needed for doing multiple selects */
- rc = SQLFreeStmt(result->stmt, SQL_CLOSE);
-
- if(rc == SQL_ERROR){
- ODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLFreeStmt");
- }
-
- rc = SQLExecute(result->stmt);
-
- result->fetched = 0;
- if(rc == SQL_NEED_DATA){
- char buf[4096];
- int fp, nbytes;
- while(rc == SQL_NEED_DATA){
- rc = SQLParamData(result->stmt, (PTR FAR *)&fp);
- if(rc == SQL_NEED_DATA){
- while((nbytes = read(fp, &buf, 4096)) > 0)
- SQLPutData(result->stmt,(UCHAR FAR*) &buf, nbytes);
- }
- }
- }else{
- if(rc != SQL_SUCCESS){
- ODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLExecute");
- RETVAL_FALSE;
- }
- }
-
- if(result->numparams > 0){
- SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
- for(i = 0; i < result->numparams; i++){
- if(params[i].fp != -1)
- close(params[i].fp);
- }
- efree(params);
- }
-
- if(rc == SQL_SUCCESS){
- RETVAL_TRUE;
- }
-
- if(result->numcols == 0){
- SQLNumResultCols(result->stmt, &(result->numcols));
-
- if(result->numcols > 0){
- if(!odbc_bindcols(result)){
- efree(result);
- RETVAL_FALSE;
- }
- }else{
- result->values = NULL;
- }
- }
-}
-/* }}} */
-
-/* {{{ proto string odbc_cursor(int result_id)
- Get cursor name */
-PHP_FUNCTION(odbc_cursor)
-{
- pval *pv_res;
- SWORD len, max_len;
- char *cursorname;
- odbc_result *result;
- RETCODE rc;
- ODBCLS_FETCH();
-
- if(getParameters(ht, 1, &pv_res) == FAILURE){
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
-
- rc = SQLGetInfo(result->conn_ptr->hdbc,SQL_MAX_CURSOR_NAME_LEN,
- (void *)&max_len,0,&len);
- if(rc != SQL_SUCCESS){
- RETURN_FALSE;
- }
-
- if(max_len > 0){
- cursorname = emalloc(max_len + 1);
- if(cursorname == NULL){
- php_error(E_WARNING,"Out of memory");
- RETURN_FALSE;
- }
- rc = SQLGetCursorName(result->stmt,cursorname,(SWORD)max_len,&len);
- if(rc != SQL_SUCCESS){
- char state[6]; /* Not used */
- SDWORD error; /* Not used */
- char errormsg[255];
- SWORD errormsgsize; /* Not used */
- ODBC_TLS_VARS;
-
- SQLError(ODBCG(henv), result->conn_ptr->hdbc,
- result->stmt, state, &error, errormsg,
- sizeof(errormsg)-1, &errormsgsize);
- if(!strncmp(state,"S1015",5)){
- sprintf(cursorname,"php3_curs_%d", (int)result->stmt);
- if(SQLSetCursorName(result->stmt,cursorname,SQL_NTS) != SQL_SUCCESS){
- ODBC_SQL_ERROR(result->conn_ptr->hdbc,result->stmt,
- "SQLSetCursorName");
- RETVAL_FALSE;
- }else{
- RETVAL_STRING(cursorname,1);
- }
- }else{
- php_error(E_WARNING, "SQL error: %s, SQL state %s", errormsg, state);
- RETVAL_FALSE;
- }
- }else{
- RETVAL_STRING(cursorname,1);
- }
- efree(cursorname);
- }else{
- RETVAL_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int odbc_exec(int connection_id, string query [, int flags])
- Prepare and execute an SQL statement */
-PHP_FUNCTION(odbc_exec)
-{
- pval *pv_conn, *pv_query, *pv_flags;
- int numArgs;
- char *query;
- odbc_result *result = NULL;
- odbc_connection *conn;
- RETCODE rc;
-#if HAVE_SQL_EXTENDED_FETCH
- UDWORD scrollopts;
-#endif
-
- numArgs = ARG_COUNT(ht);
- if(numArgs > 2){
- if(getParameters(ht, 3, &pv_conn, &pv_query, &pv_flags) == FAILURE)
- WRONG_PARAM_COUNT;
- convert_to_long(pv_flags);
- }else{
- if(getParameters(ht, 2, &pv_conn, &pv_query) == FAILURE)
- WRONG_PARAM_COUNT;
- }
-
- conn = (odbc_connection *)zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
-
- convert_to_string(pv_query);
- query = pv_query->value.str.val;
-
- result = (odbc_result *)emalloc(sizeof(odbc_result));
- if(result == NULL){
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
-
- rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
- if(rc == SQL_INVALID_HANDLE){
- php_error(E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
- efree(result);
- RETURN_FALSE;
- }
-
- if(rc == SQL_ERROR){
- ODBC_SQL_ERROR(conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
- efree(result);
- RETURN_FALSE;
- }
-
-#if HAVE_SQL_EXTENDED_FETCH
- /* Solid doesn't have ExtendedFetch, if DriverManager is used, get Info,
- whether Driver supports ExtendedFetch */
- rc = SQLGetInfo(conn->hdbc, SQL_FETCH_DIRECTION, (void *) &scrollopts, sizeof(scrollopts), NULL);
- if(rc == SQL_SUCCESS){
- if((result->fetch_abs = (scrollopts & SQL_FD_FETCH_ABSOLUTE))){
- /* Try to set CURSOR_TYPE to dynamic. Driver will replace this with other
- type if not possible.
- */
- if(SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, SQL_CURSOR_DYNAMIC)
- == SQL_ERROR){
- ODBC_SQL_ERROR(conn->hdbc, result->stmt, " SQLSetStmtOption");
- SQLFreeStmt(result->stmt, SQL_DROP);
- efree(result);
- RETURN_FALSE;
- }
- }
- }else{
- result->fetch_abs = 0;
- }
-#endif
-
- rc = SQLExecDirect(result->stmt, query, SQL_NTS);
- if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- /* XXX FIXME we should really check out SQLSTATE with SQLError
- * in case rc is SQL_SUCCESS_WITH_INFO here.
- */
- ODBC_SQL_ERROR(conn->hdbc, result->stmt, "SQLExecDirect");
- SQLFreeStmt(result->stmt, SQL_DROP);
- efree(result);
- RETURN_FALSE;
- }
-
- SQLNumResultCols(result->stmt, &(result->numcols));
-
- /* For insert, update etc. cols == 0 */
- if(result->numcols > 0){
- if(!odbc_bindcols(result)){
- efree(result);
- RETURN_FALSE;
- }
- }else{
- result->values = NULL;
- }
- result->conn_ptr = conn;
- result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
-}
-/* }}} */
-
-/* {{{ proto int odbc_fetch_into(int result_id [, int rownumber], array result_array)
- Fetch one result row into an array */
-PHP_FUNCTION(odbc_fetch_into)
-{
- int numArgs, i;
- odbc_result *result;
- RETCODE rc;
- SWORD sql_c_type;
- char *buf = NULL;
-#if HAVE_SQL_EXTENDED_FETCH
- UDWORD crow;
- UWORD RowStatus[1];
- SDWORD rownum = -1;
- pval *pv_res, *pv_row, *pv_res_arr, *tmp;
-
- numArgs = ARG_COUNT(ht);
-
- switch(numArgs){
- case 2:
- if(getParameters(ht, 2, &pv_res, &pv_res_arr) == FAILURE)
- WRONG_PARAM_COUNT;
- break;
- case 3:
- if(getParameters(ht, 3, &pv_res, &pv_row, &pv_res_arr) == FAILURE)
- WRONG_PARAM_COUNT;
- convert_to_long(pv_row);
- rownum = pv_row->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- }
-
- if(!ParameterPassedByReference(ht, numArgs)){
- php_error(E_WARNING, "Array not passed by reference in call to odbc_fetch_into()");
- RETURN_FALSE;
- }
-#else
- pval *pv_res, *pv_res_arr, *tmp;
-
- numArgs = ARG_COUNT(ht);
-
- if(numArgs != 2 || getParameters(ht, 2, &pv_res, &pv_res_arr) == FAILURE){
- WRONG_PARAM_COUNT;
- }
-
- if(!ParameterPassedByReference(ht, numArgs)){
- php_error(E_WARNING, "Array not passed by reference in call to odbc_fetch_into()");
- RETURN_FALSE;
- }
-#endif
-
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
-
- if(result->numcols == 0){
- php_error(E_WARNING, "No tuples available at this result index");
- RETURN_FALSE;
- }
-
- if(pv_res_arr->type != IS_ARRAY){
- if(array_init(pv_res_arr) == FAILURE){
- php_error(E_WARNING, "Can't convert to type Array");
- RETURN_FALSE;
- }
- }
-
-#if HAVE_SQL_EXTENDED_FETCH
- if(result->fetch_abs){
- if(rownum > 0)
- rc = SQLExtendedFetch(result->stmt,SQL_FETCH_ABSOLUTE,rownum,&crow,RowStatus);
- else
- rc = SQLExtendedFetch(result->stmt,SQL_FETCH_NEXT,1,&crow,RowStatus);
- }else
-#endif
- rc = SQLFetch(result->stmt);
-
- if(rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
- RETURN_FALSE;
-
-#if HAVE_SQL_EXTENDED_FETCH
- if(rownum > 0 && result->fetch_abs)
- result->fetched = rownum;
- else
-#endif
- result->fetched++;
-
- for(i = 0; i < result->numcols; i++){
- tmp = (pval *) emalloc(sizeof(pval));
- tmp->refcount = 1;
- tmp->type = IS_STRING;
- tmp->value.str.len = 0;
- sql_c_type = SQL_C_CHAR;
-
- switch(result->values[i].coltype){
- case SQL_BINARY:
- case SQL_VARBINARY:
- case SQL_LONGVARBINARY:
- if(result->binmode <= 0){
- tmp->value.str.val = empty_string;
- break;
- }
- if(result->binmode == 1) sql_c_type = SQL_C_BINARY;
- case SQL_LONGVARCHAR:
- if(IS_SQL_LONG(result->values[i].coltype) &&
- result->longreadlen <= 0){
- tmp->value.str.val = empty_string;
- break;
- }
-
- if(buf == NULL) buf = emalloc(result->longreadlen + 1);
- rc = SQLGetData(result->stmt, (UWORD)(i + 1),sql_c_type,
- buf, result->longreadlen + 1, &result->values[i].vallen);
-
- if(rc == SQL_ERROR){
- ODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLGetData");
- efree(buf);
- RETURN_FALSE;
- }
- if(rc == SQL_SUCCESS_WITH_INFO){
- tmp->value.str.len = result->longreadlen;
- }else if (result->values[i].vallen == SQL_NULL_DATA){
- tmp->value.str.val = empty_string;
- break;
- }else{
- tmp->value.str.len = result->values[i].vallen;
- }
- tmp->value.str.val = estrndup(buf, tmp->value.str.len);
- break;
-
- default:
- if(result->values[i].vallen == SQL_NULL_DATA){
- tmp->value.str.val = empty_string;
- break;
- }
- tmp->value.str.len = result->values[i].vallen;
- tmp->value.str.val = estrndup(result->values[i].value,tmp->value.str.len);
- break;
- }
- zend_hash_index_update(pv_res_arr->value.ht, i, &tmp, sizeof(pval *), NULL);
- }
- if (buf) efree(buf);
- RETURN_LONG(result->numcols);
-}
-/* }}} */
-
-#if HAVE_SOLID
-PHP_FUNCTION(solid_fetch_prev)
-{
- odbc_result *result;
- RETCODE rc;
- pval *pv_res;
-
- if(getParameters(ht, 1, &pv_res) == FAILURE)
- WRONG_PARAM_COUNT;
-
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
- if(result->numcols == 0){
- php_error(E_WARNING, "No tuples available at this result index");
- RETURN_FALSE;
- }
- rc = SQLFetchPrev(result->stmt);
-
- if(rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
- RETURN_FALSE;
- }
-
- if(result->fetched > 1) result->fetched--;
-
- RETURN_TRUE;
-}
-#endif
-
-/* {{{ proto int odbc_fetch_row(int result_id [, int row_number])
- Fetch a row */
-PHP_FUNCTION(odbc_fetch_row)
-{
- int numArgs;
- SDWORD rownum = 1;
- odbc_result *result;
- RETCODE rc;
- pval *pv_res, *pv_row;
-#if HAVE_SQL_EXTENDED_FETCH
- UDWORD crow;
- UWORD RowStatus[1];
-#endif
-
- numArgs = ARG_COUNT(ht);
- if(numArgs == 1){
- if(getParameters(ht, 1, &pv_res) == FAILURE)
- WRONG_PARAM_COUNT;
- }else{
- if(getParameters(ht, 2, &pv_res, &pv_row) == FAILURE)
- WRONG_PARAM_COUNT;
- convert_to_long(pv_row);
- rownum = pv_row->value.lval;
- }
-
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
-
- if(result->numcols == 0){
- php_error(E_WARNING, "No tuples available at this result index");
- RETURN_FALSE;
- }
-
-#if HAVE_SQL_EXTENDED_FETCH
- if(result->fetch_abs){
- if(numArgs > 1)
- rc = SQLExtendedFetch(result->stmt,SQL_FETCH_ABSOLUTE,rownum,&crow,RowStatus);
- else
- rc = SQLExtendedFetch(result->stmt,SQL_FETCH_NEXT,1,&crow,RowStatus);
- }else
-#endif
- rc = SQLFetch(result->stmt);
-
- if(rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
- RETURN_FALSE;
- }
-
- if(numArgs > 1){
- result->fetched = rownum;
- }else{
- result->fetched++;
- }
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto string odbc_result(int result_id, mixed field)
- Get result data */
-PHP_FUNCTION(odbc_result)
-{
- char *field;
- int field_ind;
- SWORD sql_c_type = SQL_C_CHAR;
- odbc_result *result;
- int i = 0;
- RETCODE rc;
- SDWORD fieldsize;
- pval *pv_res, *pv_field;
-#if HAVE_SQL_EXTENDED_FETCH
- UDWORD crow;
- UWORD RowStatus[1];
-#endif
-
- field_ind = -1;
- field = NULL;
-
- if(ARG_COUNT(ht) != 2 || getParameters(ht, 2 , &pv_res, &pv_field) == FAILURE){
- WRONG_PARAM_COUNT;
- }
-
- if(pv_field->type == IS_STRING){
- field = pv_field->value.str.val;
- }else{
- convert_to_long(pv_field);
- field_ind = pv_field->value.lval - 1;
- }
-
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
-
- if((result->numcols == 0)){
- php_error(E_WARNING, "No tuples available at this result index");
- RETURN_FALSE;
- }
-
- /* get field index if the field parameter was a string */
- if(field != NULL){
- for(i = 0; i < result->numcols; i++){
- if(!strcasecmp(result->values[i].name, field)){
- field_ind = i;
- break;
- }
- }
-
- if(field_ind < 0){
- php_error(E_WARNING, "Field %s not found", field);
- RETURN_FALSE;
- }
- }else{
- /* check for limits of field_ind if the field parameter was an int */
- if (field_ind >= result->numcols || field_ind < 0){
- php_error(E_WARNING, "Field index is larger than the number of fields");
- RETURN_FALSE;
- }
- }
-
- if(result->fetched == 0){
- /* User forgot to call odbc_fetchrow(), let's do it here */
-#if HAVE_SQL_EXTENDED_FETCH
- if(result->fetch_abs)
- rc = SQLExtendedFetch(result->stmt, SQL_FETCH_NEXT, 1, &crow,RowStatus);
- else
-#endif
- rc = SQLFetch(result->stmt);
-
- if(rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
- RETURN_FALSE;
-
- result->fetched++;
- }
-
- switch(result->values[field_ind].coltype){
- case SQL_BINARY:
- case SQL_VARBINARY:
- case SQL_LONGVARBINARY:
- if(result->binmode <= 1) sql_c_type = SQL_C_BINARY;
- if(result->binmode <= 0) break;
- case SQL_LONGVARCHAR:
- if(IS_SQL_LONG(result->values[field_ind].coltype)){
- if(result->longreadlen <= 0)
- break;
- else
- fieldsize = result->longreadlen;
- }else{
- SQLColAttributes(result->stmt, (UWORD)(field_ind + 1),
- (UWORD)((sql_c_type == SQL_C_BINARY) ? SQL_COLUMN_LENGTH :
- SQL_COLUMN_DISPLAY_SIZE),
- NULL, 0, NULL, &fieldsize);
- }
- /* For char data, the length of the returned string will be longreadlen - 1 */
- fieldsize = (result->longreadlen <= 0) ? 4096 : result->longreadlen;
- field = emalloc(fieldsize);
- if(!field){
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
- /* SQLGetData will truncate CHAR data to fieldsize - 1 bytes and append \0.
- For binary data it is truncated to fieldsize bytes.
- */
- rc = SQLGetData(result->stmt, (UWORD)(field_ind + 1), sql_c_type,
- field, fieldsize, &result->values[field_ind].vallen);
-
- if(rc == SQL_ERROR){
- ODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLGetData");
- efree(field);
- RETURN_FALSE;
- }
-
- if(result->values[field_ind].vallen == SQL_NULL_DATA || rc == SQL_NO_DATA_FOUND){
- efree(field);
- RETURN_FALSE;
- }
- /* Reduce fieldlen by 1 if we have char data. One day we might
- have binary strings... */
- if(result->values[field_ind].coltype == SQL_LONGVARCHAR) fieldsize -= 1;
- /* Don't duplicate result, saves one emalloc.
- For SQL_SUCCESS, the length is in vallen.
- */
- RETURN_STRINGL(field, (rc == SQL_SUCCESS_WITH_INFO) ? fieldsize :
- result->values[field_ind].vallen, 0);
- break;
-
- default:
- if(result->values[field_ind].vallen == SQL_NULL_DATA){
- RETURN_FALSE;
- }else{
- RETURN_STRINGL(result->values[field_ind].value, result->values[field_ind].vallen, 1);
- }
- break;
- }
-
-/* If we come here, output unbound LONG and/or BINARY column data to the client */
-
- /* We emalloc 1 byte more for SQL_C_CHAR (trailing \0) */
- fieldsize = (sql_c_type == SQL_C_CHAR) ? 4096 : 4095;
- if((field = emalloc(fieldsize)) == NULL){
- php_error(E_WARNING,"Out of memory");
- RETURN_FALSE;
- }
-
- /* Call SQLGetData() until SQL_SUCCESS is returned */
- while(1){
- rc = SQLGetData(result->stmt, (UWORD)(field_ind + 1),sql_c_type,
- field, fieldsize, &result->values[field_ind].vallen);
-
- if(rc == SQL_ERROR){
- ODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLGetData");
- efree(field);
- RETURN_FALSE;
- }
-
- if(result->values[field_ind].vallen == SQL_NULL_DATA){
- efree(field);
- RETURN_FALSE;
- }
- /* chop the trailing \0 by outputing only 4095 bytes */
- PHPWRITE(field,(rc == SQL_SUCCESS_WITH_INFO) ? 4095 :
- result->values[field_ind].vallen);
-
- if(rc == SQL_SUCCESS) { /* no more data avail */
- efree(field);
- RETURN_TRUE;
- }
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int odbc_result_all(int result_id [, string format])
- Print result as HTML table */
-PHP_FUNCTION(odbc_result_all)
-{
- char *buf = NULL;
- int i, numArgs;
- odbc_result *result;
- RETCODE rc;
- pval *pv_res, *pv_format;
- SWORD sql_c_type;
-#if HAVE_SQL_EXTENDED_FETCH
- UDWORD crow;
- UWORD RowStatus[1];
-#endif
-
- numArgs = ARG_COUNT(ht);
- if(numArgs == 1){
- if(getParameters(ht, 1, &pv_res) == FAILURE)
- WRONG_PARAM_COUNT;
- }else{
- if(getParameters(ht, 2, &pv_res, &pv_format) == FAILURE)
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
-
- if(result->numcols == 0){
- php_error(E_WARNING, "No tuples available at this result index");
- RETURN_FALSE;
- }
-#if HAVE_SQL_EXTENDED_FETCH
- if(result->fetch_abs)
- rc = SQLExtendedFetch(result->stmt,SQL_FETCH_NEXT,1,&crow,RowStatus);
- else
-#endif
- rc = SQLFetch(result->stmt);
-
- if(rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
- php_printf("<h2>No rows found</h2>\n");
- RETURN_LONG(0);
- }
-
- /* Start table tag */
- if(numArgs == 1){
- php_printf("<table><tr>");
- }else{
- convert_to_string(pv_format);
- php_printf("<table %s ><tr>",pv_format->value.str.val);
- }
-
- for(i = 0; i < result->numcols; i++)
- php_printf("<th>%s</th>", result->values[i].name);
-
- php_printf("</tr>\n");
-
- while(rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO){
- result->fetched++;
- php_printf("<tr>");
- for(i = 0; i < result->numcols; i++){
- sql_c_type = SQL_C_CHAR;
- switch(result->values[i].coltype){
- case SQL_BINARY:
- case SQL_VARBINARY:
- case SQL_LONGVARBINARY:
- if(result->binmode <= 0){
- php_printf("<td>Not printable</td>");
- break;
- }
- if(result->binmode <= 1) sql_c_type = SQL_C_BINARY;
- case SQL_LONGVARCHAR:
- if(IS_SQL_LONG(result->values[i].coltype) &&
- result->longreadlen <= 0){
- php_printf("<td>Not printable</td>");
- break;
- }
-
- if(buf == NULL) buf = emalloc(result->longreadlen);
-
- rc = SQLGetData(result->stmt, (UWORD)(i + 1),sql_c_type,
- buf, result->longreadlen, &result->values[i].vallen);
-
- php_printf("<td>");
-
- if(rc == SQL_ERROR){
- ODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLGetData");
- php_printf("</td></tr></table>");
- efree(buf);
- RETURN_FALSE;
- }
- if(rc == SQL_SUCCESS_WITH_INFO)
- php_printf(buf,result->longreadlen);
- else if(result->values[i].vallen == SQL_NULL_DATA){
- php_printf("&nbsp;</td>");
- break;
- }else{
- php_printf(buf, result->values[i].vallen);
- }
- php_printf("</td>");
- break;
- default:
- if(result->values[i].vallen == SQL_NULL_DATA){
- php_printf("<td>&nbsp;</td>");
- }else{
- php_printf("<td>%s</td>", result->values[i].value);
- }
- break;
- }
- }
- php_printf("</tr>\n");
-
-#if HAVE_SQL_EXTENDED_FETCH
- if(result->fetch_abs)
- rc = SQLExtendedFetch(result->stmt,SQL_FETCH_NEXT,1,&crow,RowStatus);
- else
-#endif
- rc = SQLFetch(result->stmt);
- }
- php_printf("</table>\n");
- if (buf) efree(buf);
- RETURN_LONG(result->fetched);
-}
-/* }}} */
-
-/* {{{ proto int odbc_free_result(int result_id)
- Free resources associated with a result */
-PHP_FUNCTION(odbc_free_result)
-{
- pval *pv_res;
- odbc_result *result;
-
- if(getParameters(ht, 1, &pv_res) == FAILURE){
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
- zend_list_delete(pv_res->value.lval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int odbc_connect(string DSN, string user, string password [, int cursor_option])
- Connect to a datasource */
-PHP_FUNCTION(odbc_connect)
-{
- odbc_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ proto int odbc_pconnect(string DSN, string user, string password [, int cursor_option])
- Establish a persistant connection to a datasource */
-PHP_FUNCTION(odbc_pconnect)
-{
- odbc_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int cur_opt, int persistent ODBCLS_DC)
-{
- RETCODE rc;
-
- *conn = (odbc_connection *)pemalloc(sizeof(odbc_connection), persistent);
- (*conn)->persistent = persistent;
- SQLAllocConnect(ODBCG(henv), &((*conn)->hdbc));
-
-#if HAVE_SOLID
- SQLSetConnectOption((*conn)->hdbc, SQL_TRANSLATE_OPTION,
- SQL_SOLID_XLATOPT_NOCNV);
-#endif
-#if HAVE_OPENLINK
- {
- char dsnbuf[300];
- short dsnbuflen;
-
- rc = SQLDriverConnect((*conn)->hdbc, NULL, db, SQL_NTS,
- dsnbuf, sizeof(dsnbuf) - 1, &dsnbuflen,
- SQL_DRIVER_NOPROMPT);
- }
-#else
- if(cur_opt != SQL_CUR_DEFAULT){
- rc = SQLSetConnectOption((*conn)->hdbc, SQL_ODBC_CURSORS, cur_opt);
- if(rc != SQL_SUCCESS){ /* && rc != SQL_SUCCESS_WITH_INFO ? */
- ODBC_SQL_ERROR((*conn)->hdbc, SQL_NULL_HSTMT, "SQLSetConnectOption");
- SQLFreeConnect((*conn)->hdbc);
- pefree(*conn, persistent);
- return FALSE;
- }
- }
-#if HAVE_EMPRESS
- {
- int direct = 0;
- char dsnbuf[300];
- short dsnbuflen;
- char *ldb = 0;
-
- if(strstr((char*)db, ";")){
- direct = 1;
- if(uid && !strstr ((char*)db, "uid") &&
- !strstr((char*)db, "UID")){
- ldb = (char*)emalloc(strlen(db) + strlen(uid) + strlen(pwd) + 12);
- sprintf(ldb, "%s;UID=%s;PWD=%s", db, uid, pwd);
- }else{
- ldb = (char*)emalloc(strlen(db) + 1);
- strcat(ldb, db);
- }
- }
-
- if(direct)
- rc = SQLDriverConnect((*conn)->hdbc, NULL, ldb, strlen(ldb), dsnbuf, 300,
- &dsnbuflen, SQL_DRIVER_NOPROMPT);
- else
- rc = SQLConnect((*conn)->hdbc, db, SQL_NTS, uid, SQL_NTS, pwd, SQL_NTS);
- if(ldb)
- efree(ldb);
- }
-#else
- rc = SQLConnect((*conn)->hdbc, db, SQL_NTS, uid, SQL_NTS, pwd, SQL_NTS);
-#endif
-#endif
- if(rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
- ODBC_SQL_ERROR((*conn)->hdbc, SQL_NULL_HSTMT, "SQLConnect");
- SQLFreeConnect((*conn)->hdbc);
- pefree((*conn), persistent);
- return FALSE;
- }
- (*conn)->open = 1;
- return TRUE;
-}
-/* Persistent connections: two list-types le_pconn, le_conn and a plist
- * where hashed connection info is stored together with index pointer to
- * the actual link of type le_pconn in the list. Only persistent
- * connections get hashed up. Normal connections use existing pconnections.
- * Maybe this has to change with regard to transactions on pconnections?
- * Possibly set autocommit to on on request shutdown.
- *
- * We do have to hash non-persistent connections, and reuse connections.
- * In the case where two connects were being made, without closing the first
- * connect, access violations were occuring. This is because some of the
- * "globals" in this module should actualy be per-connection variables. I
- * simply fixed things to get them working for now. Shane
- */
-void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
-{
- char *db = NULL;
- char *uid = NULL;
- char *pwd = NULL;
- pval *pv_db, *pv_uid, *pv_pwd, *pv_opt;
- odbc_connection *db_conn;
- char *hashed_details;
- int hashed_len, len, cur_opt;
- ODBCLS_FETCH();
- PLS_FETCH();
-
- /* Now an optional 4th parameter specifying the cursor type
- * defaulting to the cursors default
- */
- switch(ARG_COUNT(ht)) {
- case 3:
- if (getParameters(ht, 3, &pv_db, &pv_uid, &pv_pwd) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- /* Use Default: Probably a better way to do this */
- cur_opt = SQL_CUR_DEFAULT;
- break;
- case 4:
- if (getParameters(ht, 4, &pv_db, &pv_uid, &pv_pwd, &pv_opt) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(pv_opt);
- cur_opt = pv_opt->value.lval;
-
- /* Confirm the cur_opt range */
- if (! (cur_opt == SQL_CUR_USE_IF_NEEDED ||
- cur_opt == SQL_CUR_USE_ODBC ||
- cur_opt == SQL_CUR_USE_DRIVER ||
- cur_opt == SQL_CUR_DEFAULT) ) {
- php_error(E_WARNING, "odbc: Invalid Cursor type (%d)", cur_opt);
- RETURN_FALSE;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- convert_to_string(pv_db);
- convert_to_string(pv_uid);
- convert_to_string(pv_pwd);
-
- db = pv_db->value.str.val;
- uid = pv_uid->value.str.val;
- pwd = pv_pwd->value.str.val;
-
- if (ODBCG(allow_persistent) <= 0) {
- persistent = 0;
- }
-
- len = strlen(db) + strlen(uid) + strlen(pwd) + sizeof(ODBC_TYPE) - 1 + 5;
- hashed_details = emalloc(len);
-
- if (hashed_details == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
-
- hashed_len = php_sprintf(hashed_details, "%s_%s_%s_%s_%d", ODBC_TYPE, db, uid, pwd, cur_opt);
-
- /* FIXME the idea of checking to see if our connection is already persistent
- is good, but it adds a lot of overhead to non-persistent connections. We
- should look and see if we can fix that somehow */
- /* try to find if we already have this link in our persistent list,
- * no matter if it is to be persistent or not
- */
-
- if(persistent){
- list_entry *le;
-
- if(zend_hash_find(plist, hashed_details, hashed_len + 1, (void **) &le)
- == FAILURE) { /* the link is not in the persistent list */
- list_entry new_le;
-
- if(ODBCG(max_links) != -1 && ODBCG(num_links) >= ODBCG(max_links)){
- php_error(E_WARNING, "odbc: Too many open links (%d)", ODBCG(num_links));
- efree(hashed_details);
- RETURN_FALSE;
- }
- if(ODBCG(max_persistent) != -1 && ODBCG(num_persistent) >= ODBCG(max_persistent)){
- php_error(E_WARNING,"odbc: Too many open persistent links (%d)", ODBCG(num_persistent));
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- if(!odbc_sqlconnect(&db_conn, db, uid, pwd, cur_opt, 1 ODBCLS_CC)){
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- new_le.type = le_pconn;
- new_le.ptr = db_conn;
- if(zend_hash_update(plist, hashed_details, hashed_len + 1, &new_le,
- sizeof(list_entry), NULL) == FAILURE){
- free(db_conn);
- efree(hashed_details);
- RETURN_FALSE;
- }
- ODBCG(num_persistent)++;
- ODBCG(num_links)++;
- }else{ /* found connection */
- if(le->type != le_pconn){
- RETURN_FALSE;
- }
- /* XXX we should ensure that the connection is still available */
- db_conn = (odbc_connection *)le->ptr;
- }
- ZEND_REGISTER_RESOURCE(return_value, db_conn, le_pconn);
- }else{ /* non persistent */
- list_entry *index_ptr, new_index_ptr;
- void *ptr;
-
- if(zend_hash_find(list, hashed_details, hashed_len + 1,
- (void **) &index_ptr) == SUCCESS){
- int type, conn_id;
- void *ptr;
- if(index_ptr->type != le_index_ptr){
- RETURN_FALSE;
- }
- conn_id = (int)index_ptr->ptr;
- ptr = zend_list_find(conn_id, &type); /* check if the connection is still there */
- if(ptr && (type == le_conn || type == le_pconn)) {
- zend_list_addref(conn_id);
- return_value->value.lval = conn_id;
- return_value->type = IS_RESOURCE;
- efree(hashed_details);
- return;
- }else{
- zend_hash_del(list, hashed_details, hashed_len + 1);
- }
- }
- if(ODBCG(max_links) != -1 && ODBCG(num_links) >= ODBCG(max_links)){
- php_error(E_WARNING,"ODBC: Too many open connections (%d)",ODBCG(num_links));
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- if(!odbc_sqlconnect(&db_conn, db, uid, pwd, cur_opt, 0 ODBCLS_CC)){
- efree(hashed_details);
- RETURN_FALSE;
- }
- ZEND_REGISTER_RESOURCE(return_value, db_conn, le_conn);
- new_index_ptr.ptr = (void *) return_value->value.lval;
- new_index_ptr.type = le_index_ptr;
- if(zend_hash_update(list, hashed_details, hashed_len + 1, (void *) &new_index_ptr,
- sizeof(list_entry), NULL) == FAILURE){
- efree(hashed_details);
- RETURN_FALSE;
- }
- ODBCG(num_links)++;
- }
- efree(hashed_details);
-}
-
-/* {{{ proto void odbc_close(int connection_id)
- Close an ODBC connection */
-PHP_FUNCTION(odbc_close)
-{
- pval *pv_conn;
- odbc_connection *conn;
- int ind;
- ODBCLS_FETCH();
-
- if (getParameters(ht, 1, &pv_conn) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- conn = (odbc_connection *) zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
-
- zend_list_delete(pv_conn->value.lval);
-}
-/* }}} */
-
-/* {{{ proto int odbc_num_rows(int result_id)
- Get number of rows in a result */
-PHP_FUNCTION(odbc_num_rows)
-{
- odbc_result *result;
- SDWORD rows;
- pval *pv_res;
-
- if(getParameters(ht, 1, &pv_res) == FAILURE){
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
- SQLRowCount(result->stmt, &rows);
- RETURN_LONG(rows);
-}
-/* }}} */
-
-/* {{{ proto int odbc_num_fields(int result_id)
- Get number of columns in a result */
-PHP_FUNCTION(odbc_num_fields)
-{
- odbc_result *result;
- pval *pv_res;
-
- if(getParameters(ht, 1, &pv_res) == FAILURE){
- WRONG_PARAM_COUNT;
- }
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
- RETURN_LONG(result->numcols);
-}
-/* }}} */
-
-/* {{{ proto string odbc_field_name(int result_id, int field_number)
- Get a column name */
-PHP_FUNCTION(odbc_field_name)
-{
- odbc_result *result;
- pval *pv_res, *pv_num;
-
- if(getParameters(ht, 2, &pv_res, &pv_num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(pv_num);
-
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
-
- if(result->numcols == 0){
- php_error(E_WARNING, "No tuples available at this result index");
- RETURN_FALSE;
- }
-
- if(pv_num->value.lval > result->numcols){
- php_error(E_WARNING, "Field index larger than number of fields");
- RETURN_FALSE;
- }
-
- if(pv_num->value.lval < 1){
- php_error(E_WARNING, "Field numbering starts at 1");
- RETURN_FALSE;
- }
-
- RETURN_STRING(result->values[pv_num->value.lval - 1].name, 1)
-}
-/* }}} */
-
-/* {{{ proto string odbc_field_type(int result_id, int field_number)
- Get the datatype of a column */
-PHP_FUNCTION(odbc_field_type)
-{
- odbc_result *result;
- char tmp[32];
- SWORD tmplen;
- pval *pv_res, *pv_num;
-
- if(getParameters(ht, 2, &pv_res, &pv_num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(pv_num);
-
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
-
- if(result->numcols == 0){
- php_error(E_WARNING, "No tuples available at this result index");
- RETURN_FALSE;
- }
-
- if(pv_num->value.lval > result->numcols){
- php_error(E_WARNING, "Field index larger than number of fields");
- RETURN_FALSE;
- }
-
- if(pv_num->value.lval < 1){
- php_error(E_WARNING, "Field numbering starts at 1");
- RETURN_FALSE;
- }
-
- SQLColAttributes(result->stmt, (UWORD)pv_num->value.lval,
- SQL_COLUMN_TYPE_NAME, tmp, 31, &tmplen, NULL);
- RETURN_STRING(tmp,1)
-}
-/* }}} */
-
-/* {{{ proto int odbc_field_len(int result_id, int field_number)
- Get the length of a column */
-PHP_FUNCTION(odbc_field_len)
-{
- odbc_result *result;
- SDWORD len;
- pval *pv_res, *pv_num;
-
- if(getParameters(ht, 2, &pv_res, &pv_num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(pv_num);
-
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
-
- if(result->numcols == 0){
- php_error(E_WARNING, "No tuples available at this result index");
- RETURN_FALSE;
- }
-
- if(pv_num->value.lval > result->numcols){
- php_error(E_WARNING, "Field index larger than number of fields");
- RETURN_FALSE;
- }
-
- if(pv_num->value.lval < 1){
- php_error(E_WARNING, "Field numbering starts at 1");
- RETURN_FALSE;
- }
-
- SQLColAttributes(result->stmt, (UWORD)pv_num->value.lval,
- SQL_COLUMN_PRECISION, NULL, 0, NULL, &len);
-
- RETURN_LONG(len);
-}
-/* }}} */
-
-/* {{{ proto int odbc_field_num(int result_id, string field_name)
- Return column number */
-PHP_FUNCTION(odbc_field_num)
-{
- int field_ind;
- char *fname;
- odbc_result *result;
- int i;
- pval *pv_res, *pv_name;
-
- if(getParameters(ht, 2, &pv_res, &pv_name) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(pv_name);
- fname = pv_name->value.str.val;
-
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
-
- if(result->numcols == 0){
- php_error(E_WARNING, "No tuples available at this result index");
- RETURN_FALSE;
- }
-
- field_ind = -1;
- for(i = 0; i < result->numcols; i++){
- if(strcasecmp(result->values[i].name, fname) == 0)
- field_ind = i + 1;
- }
-
- if(field_ind == -1)
- RETURN_FALSE;
- RETURN_LONG(field_ind);
-}
-/* }}} */
-
-/* {{{ proto int odbc_autocommit(int connection_id, [int OnOff])
- Toggle autocommit mode or get status
- There can be problems with pconnections!*/
-PHP_FUNCTION(odbc_autocommit)
-{
- odbc_connection *conn;
- RETCODE rc;
- pval *pv_conn, *pv_onoff = NULL;
- int argc;
-
- argc = ARG_COUNT(ht);
- if(argc == 2){
- if(getParameters(ht, 2, &pv_conn, &pv_onoff) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- }else if(argc == 1){
- if(getParameters(ht, 1, &pv_conn) == FAILURE){
- WRONG_PARAM_COUNT;
- }
- }else{
- WRONG_PARAM_COUNT;
- }
-
- conn = (odbc_connection *) zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
-
- if(pv_onoff){
- convert_to_long(pv_onoff);
- rc = SQLSetConnectOption(conn->hdbc, SQL_AUTOCOMMIT,
- (pv_onoff->value.lval) ?
- SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF);
- if(rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
- ODBC_SQL_ERROR(conn->hdbc, SQL_NULL_HSTMT, "Set autocommit");
- RETURN_FALSE;
- }
- RETVAL_TRUE;
- }else{
- SDWORD status;
-
- rc = SQLGetConnectOption(conn->hdbc, SQL_AUTOCOMMIT, (PTR)&status);
- if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
- ODBC_SQL_ERROR(conn->hdbc, SQL_NULL_HSTMT, "Get commit status");
- RETURN_FALSE;
- }
- RETVAL_LONG((long)status);
- }
-}
-/* }}} */
-
-/* {{{ proto int odbc_commit(int connection_id)
- Commit an ODBC transaction */
-PHP_FUNCTION(odbc_commit)
-{
- odbc_transact(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-/* {{{ proto int odbc_rollback(int connection_id)
- Rollback a transaction */
-PHP_FUNCTION(odbc_rollback)
-{
- odbc_transact(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-
-/* {{{ proto int odbc_setoption(int conn_id|result_id, int which, int option, int value)
- Sets connection or statement options */
-/* This one has to be used carefully. We can't allow to set connection options for
- persistent connections. I think that SetStmtOption is of little use, since most
- of those can only be specified before preparing/executing statements.
- On the other hand, they can be made connection wide default through SetConnectOption
- - but will be overidden by calls to SetStmtOption() in odbc_prepare/odbc_do
-*/
-PHP_FUNCTION(odbc_setoption)
-{
- odbc_connection *conn;
- odbc_result *result;
- RETCODE rc;
- pval *arg1, *arg2, *arg3, *arg4;
-
- if ( getParameters(ht, 3, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg2);
- convert_to_long(arg3);
- convert_to_long(arg4);
-
- switch (arg2->value.lval) {
- case 1: /* SQLSetConnectOption */
- conn = (odbc_connection *) zend_fetch_resource_ex(arg1, -1, "ODBC connection",
- 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
- if(conn->persistent){
- php_error(E_WARNING, "Can't set option for persistent connection");
- RETURN_FALSE;
- }
- rc = SQLSetConnectOption(conn->hdbc, (unsigned short)(arg3->value.lval), (arg4->value.lval));
- if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
- ODBC_SQL_ERROR(conn->hdbc, SQL_NULL_HSTMT, "SetConnectOption");
- RETURN_FALSE;
- }
- break;
- case 2: /* SQLSetStmtOption */
- ZEND_FETCH_RESOURCE(result, odbc_result *, arg1, -1, "ODBC result", le_result);
-
- rc = SQLSetStmtOption(result->stmt, (unsigned short)(arg3->value.lval), (arg4->value.lval));
- if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
- ODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SetStmtOption");
- RETURN_FALSE;
- }
- break;
- default:
- php_error(E_WARNING, "Unknown option type");
- RETURN_FALSE;
- break;
- }
-
- RETURN_TRUE;
-}
-/* }}} */
-
-#endif /* HAVE_UODBC */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/odbc/php_odbc.h b/ext/odbc/php_odbc.h
deleted file mode 100644
index 89bd081ec9..0000000000
--- a/ext/odbc/php_odbc.h
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Stig Sæther Bakken <ssb@guardian.no> |
- | Andreas Karajannis <Andreas.Karajannis@gmd.de> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _PHP_ODBC_H
-#define _PHP_ODBC_H
-
-#if HAVE_UODBC
-
-#ifndef MSVC5
-#define FAR
-#endif
-
-/* checking in the same order as in configure.in */
-
-#if HAVE_SOLID /* Solid Server */
-
-#define ODBC_TYPE "Solid"
-#include <cli0core.h>
-#include <cli0ext1.h>
-#define HAVE_SQL_EXTENDED_FETCH 0
-PHP_FUNCTION(solid_fetch_prev);
-
-#elif HAVE_EMPRESS /* Empress */
-
-#define ODBC_TYPE "Empress"
-#include <sql.h>
-#include <sqlext.h>
-#define HAVE_SQL_EXTENDED_FETCH 0
-
-#elif HAVE_ADABAS /* Adabas D */
-
-#define ODBC_TYPE "Adabas D"
-#include <WINDOWS.H>
-#include <sql.h>
-#include <sqlext.h>
-#define HAVE_SQL_EXTENDED_FETCH 1
-
-#elif HAVE_IODBC /* iODBC library */
-
-#define ODBC_TYPE "iODBC"
-#include <isql.h>
-#include <isqlext.h>
-#define HAVE_SQL_EXTENDED_FETCH 1
-#define SQL_FD_FETCH_ABSOLUTE 0x00000010L
-#define SQL_CURSOR_DYNAMIC 2UL
-#define SQL_NO_TOTAL (-4)
-#define SQL_SO_DYNAMIC 0x00000004L
-#define SQL_LEN_DATA_AT_EXEC_OFFSET (-100)
-#define SQL_LEN_DATA_AT_EXEC(length) (-(length)+SQL_LEN_DATA_AT_EXEC_OFFSET)
-
-#elif HAVE_UNIXODBC /* unixODBC library */
-
-#define ODBC_TYPE "unixODBC"
-#include <sql.h>
-#include <sqlext.h>
-#define HAVE_SQL_EXTENDED_FETCH 1
-
-#elif HAVE_OPENLINK /* OpenLink ODBC drivers */
-
-#define ODBC_TYPE "Openlink"
-#include <iodbc.h>
-#include <isql.h>
-#include <isqlext.h>
-#include <udbcext.h>
-#define HAVE_SQL_EXTENDED_FETCH 1
-
-#elif HAVE_VELOCIS /* Raima Velocis */
-
-#define ODBC_TYPE "Velocis"
-#define UNIX
-#define HAVE_SQL_EXTENDED_FETCH 1
-#include <sql.h>
-#include <sqlext.h>
-
-#elif HAVE_CODBC /* Custom ODBC */
-
-#define ODBC_TYPE "Custom ODBC"
-#define HAVE_SQL_EXTENDED_FETCH 1
-#include <odbc.h>
-
-#elif HAVE_DB2 /* DB2 CLI */
-
-#define ODBC_TYPE "DB2 CLI"
-#define HAVE_SQL_EXTENDED_FETCH 1
-#include <sqlcli1.h>
-#ifdef DB268K
-/* Need to include ASLM for 68K applications */
-#include <LibraryManager.h>
-#endif
-
-#else /* MS ODBC */
-
-#define HAVE_SQL_EXTENDED_FETCH 1
-#include <WINDOWS.H>
-#include <sql.h>
-#include <sqlext.h>
-#endif
-
-extern php3_module_entry odbc_module_entry;
-#define odbc_module_ptr &odbc_module_entry
-
-
-/* user functions */
-extern PHP_MINIT_FUNCTION(odbc);
-extern PHP_MSHUTDOWN_FUNCTION(odbc);
-extern PHP_RINIT_FUNCTION(odbc);
-PHP_MINFO_FUNCTION(odbc);
-
-PHP_FUNCTION(odbc_setoption);
-PHP_FUNCTION(odbc_autocommit);
-PHP_FUNCTION(odbc_close);
-PHP_FUNCTION(odbc_close_all);
-PHP_FUNCTION(odbc_commit);
-PHP_FUNCTION(odbc_connect);
-PHP_FUNCTION(odbc_pconnect);
-PHP_FUNCTION(odbc_cursor);
-PHP_FUNCTION(odbc_exec);
-PHP_FUNCTION(odbc_do);
-PHP_FUNCTION(odbc_execute);
-PHP_FUNCTION(odbc_fetch_into);
-PHP_FUNCTION(odbc_fetch_row);
-PHP_FUNCTION(odbc_field_len);
-PHP_FUNCTION(odbc_field_name);
-PHP_FUNCTION(odbc_field_type);
-PHP_FUNCTION(odbc_field_num);
-PHP_FUNCTION(odbc_free_result);
-PHP_FUNCTION(odbc_num_fields);
-PHP_FUNCTION(odbc_num_rows);
-PHP_FUNCTION(odbc_prepare);
-PHP_FUNCTION(odbc_result);
-PHP_FUNCTION(odbc_result_all);
-PHP_FUNCTION(odbc_rollback);
-PHP_FUNCTION(odbc_binmode);
-PHP_FUNCTION(odbc_longreadlen);
-/*
- * PHP_FUNCTION(odbc_bind_param);
- * PHP_FUNCTION(odbc_define);
-*/
-
-typedef struct odbc_connection {
-#if HAVE_DB2
- SQLHANDLE hdbc;
-#else
- HDBC hdbc;
-#endif
- int open;
- int persistent;
-} odbc_connection;
-
-typedef struct odbc_result_value {
- char name[32];
- char *value;
- long int vallen;
- SDWORD coltype;
-} odbc_result_value;
-
-typedef struct odbc_result {
-#if HAVE_DB2
- SQLHANDLE stmt;
-#else
- HSTMT stmt;
-#endif
- odbc_result_value *values;
- SWORD numcols;
- SWORD numparams;
-# if HAVE_SQL_EXTENDED_FETCH
- int fetch_abs;
-# endif
- long longreadlen;
- int binmode;
- int fetched;
- odbc_connection *conn_ptr;
-} odbc_result;
-
-typedef struct {
-#if HAVE_DB2
- SQLHANDLE henv;
-#else
- HENV henv;
-#endif
- char *defDB;
- char *defUser;
- char *defPW;
- long allow_persistent;
- long max_persistent;
- long max_links;
- long num_persistent;
- long num_links;
- int defConn;
- long defaultlrl;
- long defaultbinmode;
- HashTable *resource_list;
- HashTable *resource_plist;
-} php_odbc_globals;
-
-int odbc_add_result(HashTable *list, odbc_result *result);
-odbc_result *odbc_get_result(HashTable *list, int count);
-void odbc_del_result(HashTable *list, int count);
-int odbc_add_conn(HashTable *list, HDBC conn);
-odbc_connection *odbc_get_conn(HashTable *list, int count);
-void odbc_del_conn(HashTable *list, int ind);
-#if HAVE_DB2
-void odbc_sql_error(SQLHANDLE conn, SQLHANDLE stmt, char *func);
-#else
-void odbc_sql_error(HDBC conn, HSTMT stmt, char *func);
-#endif
-int odbc_bindcols(odbc_result *result);
-
-#define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR)
-#define IS_SQL_BINARY(x) (x == SQL_BINARY || x == SQL_VARBINARY || x == SQL_LONGVARBINARY)
-
-#ifdef ZTS
-# define ODBCLS_D php_odbc_globals *odbc_globals
-# define ODBCLS_DC , ODBCLS_D
-# define ODBCLS_C odbc_globals
-# define ODBCLS_CC , ODBCLS_C
-# define ODBCG(v) (odbc_globals->v)
-# define ODBCLS_FETCH() php_odbc_globals *odbc_globals = ts_resource(odbc_globals_id)
-# define ODBC_TLS_VARS char *globals; ODBCLS_FETCH(); globals = (char *)odbc_globals;
-#else
-# define ODBCLS_D
-# define ODBCLS_DC
-# define ODBCLS_C
-# define ODBCLS_CC
-# define ODBCG(v) (odbc_globals.v)
-# define ODBCLS_FETCH()
-# define ODBC_TLS_VARS char *globals = (char *)&odbc_globals
-extern ZEND_API php_odbc_globals odbc_globals;
-#endif
-
-#else
-
-# define odbc_module_ptr NULL
-
-#endif /* HAVE_UODBC */
-
-#define phpext_odbc_ptr odbc_module_ptr
-
-#endif /* _PHP_ODBC_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/odbc/setup.stub b/ext/odbc/setup.stub
deleted file mode 100644
index 5257797527..0000000000
--- a/ext/odbc/setup.stub
+++ /dev/null
@@ -1,89 +0,0 @@
-# $Id$ -*- sh -*-
-
-# Solid
-define_option with-solid 'Solid support?' yesnodir \
- 'no /usr/local/solid Solid install' \
-' Whether to build PHP with Solid support.\n
- More information about Solid can be found at http://www.solidtech.com/.'
-
-# Empress
-if test "$option_value_with_solid" = "no"; then
-define_option with-empress 'Empress support?' yesnodir \
- "no $EMPRESSPATH Empress home" \
-' Whether to build PHP with Empress support. Has been confirmed to
- work with Empress Version 8.10. If you have not set up your
- Empress environment, enter what $EMPRESSPATH is usually set to here.
- More info about Empress can be found at http://www.empress.com/.'
-fi
-
-# iODBC
-if test "$option_value_with_solid" = "no" -a \
- "$option_value_with_empress" = "no"; then
-define_option with-iodbc 'iODBC support?' yesnodir \
- 'no /usr/local iODBC install' \
-' Whether to build PHP with iODBC support. This feature was first\n
- developed for iODBC Driver Manager, a freely redistributable ODBC\n
- driver manager which runs under many flavors of UNIX.\n
- More info about iODBC can be found on the iODBC page at \n
- http://www.iodbc.org'
-fi
-
-# unixODBC
-if test "$option_value_with_solid" = "no" -a \
- "$option_value_with_empress" = "no"; then
-define_option with-unixODBC 'unixODBC support?' yesnodir \
- 'no /usr/local unixODBC install' \
-' Whether to build PHP with unixODBC support. This feature was first\n
- developed for unixODBC Driver Manager, a freely redistributable ODBC\n
- driver manager which runs under many flavors of UNIX and conforms to\n
- the ODBC 3.5 specification.\n
- More info about unixODBC can be found on the unixODBC home page at \n
- http://www.unixodbc.org'
-fi
-
-# OpenLink
-if test "$option_value_with_solid" = "no" -a \
- "$option_value_with_empress" = "no" -a \
- "$option_value_with_iodbc" = "no"; then
-define_option with-openlink 'OpenLink ODBC support?' yesnodir \
- 'no /usr/local/openlink OpenLink install' \
-' Whether to build PHP with OpenLink ODBC support. See
- http://www.openlinksw.com/ for more information.'
-fi
-
-# Adabas D
-if test "$option_value_with_solid" = "no" -a \
- "$option_value_with_empress" = "no" -a \
- "$option_value_with_iodbc" = "no" -a \
- "$option_value_with_openlink" = "no"; then
-define_option with-adabas 'Adabas D support?' yesnodir \
- 'no /usr/local Adabas D install root' \
-' Whether to build with Adabas D support.\n
- More info about Adabas D can be found at http://www.adabas.com/.'
-fi
-
-# Velocis
-if test "$option_value_with_solid" = "no" -a \
- "$option_value_with_empress" = "no" -a \
- "$option_value_with_iodbc" = "no" -a \
- "$option_value_with_openlink" = "no" -a \
- "$option_value_with_adabas" = "no"; then
-define_option with-velocis 'Velocis support?' yesnodir \
- 'no /usr/local/velocis Velocis install' \
-' Whether to build PHP with Velocis support.\n
- More information about Velocis can be found at http://www.raima.com/.'
-fi
-
-# Custom ODBC
-if test "$option_value_with_solid" = "no" -a \
- "$option_value_with_empress" = "no" -a \
- "$option_value_with_iodbc" = "no" -a \
- "$option_value_with_openlink" = "no" -a \
- "$option_value_with_adabas" = "no" -a \
- "$option_value_with_velocis" = "no"; then
-define_option with-custom-odbc 'custom ODBC support?' yesnodir \
- 'no /usr/local CODBC install' \
-' Whether to build PHP with CODBC support. This feature was first
- developed for Sybase SQL Anywhere 5.5 on QNX, but may be used for
- any unknown ODBC driver on all flavors of UNIX.'
-fi
diff --git a/ext/odbc/velocis.c b/ext/odbc/velocis.c
deleted file mode 100644
index 0bd999ab31..0000000000
--- a/ext/odbc/velocis.c
+++ /dev/null
@@ -1,648 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Nikolay P. Romanyuk <mag@redcom.ru> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/*
- * TODO:
- * velocis_fetch_into(),
- * Check all on real life apps.
- */
-
-#include "php.h"
-
-#if WIN32
-# include "config.w32.h"
-# include "win95nt.h"
-# ifdef PHP_EXPORTS
-# define PHPAPI __declspec(dllexport)
-# else
-# define PHPAPI __declspec(dllimport)
-# endif
-#else
-# include "php_config.h"
-# define PHPAPI
-# define THREAD_LS
-#endif
-
-#if HAVE_VELOCIS
-#include "php3_velocis.h"
-
-function_entry velocis_functions[] = {
- PHP_FE(velocis_connect, NULL)
- PHP_FE(velocis_close, NULL)
- PHP_FE(velocis_exec, NULL)
- PHP_FE(velocis_fetch, NULL)
- PHP_FE(velocis_result, NULL)
- PHP_FE(velocis_freeresult, NULL)
- PHP_FE(velocis_autocommit, NULL)
- PHP_FE(velocis_off_autocommit, NULL)
- PHP_FE(velocis_commit, NULL)
- PHP_FE(velocis_rollback, NULL)
- PHP_FE(velocis_fieldnum, NULL)
- PHP_FE(velocis_fieldname, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry velocis_module_entry = {
- "Velocis", velocis_functions, PHP_MINIT(velocis), PHP_MSHUTDOWN(velocis),
- PHP_RINIT(velocis), NULL, PHP_MINFO(velocis), STANDARD_MODULE_PROPERTIES
-};
-
-
-#if COMPILE_DL
-php3_module_entry *get_module() { return &velocis_module_entry; }
-#endif
-
-THREAD_LS velocis_module php3_velocis_module;
-THREAD_LS static HENV henv;
-
-static void _close_velocis_link(VConn *conn)
-{
- if ( conn ) {
- efree(conn);
- }
-}
-
-static void _free_velocis_result(Vresult *res)
-{
- if ( res && res->values ) {
- register int i;
- for ( i=0; i < res->numcols; i++ ) {
- if ( res->values[i].value )
- efree(res->values[i].value);
- }
- efree(res->values);
- }
- if ( res ) {
- efree(res);
- }
-}
-
-PHP_MINIT_FUNCTION(velocis)
-{
- SQLAllocEnv(&henv);
- if ( cfg_get_long("velocis.max_links",&php3_velocis_module.max_links) == FAILURE ) {
- php3_velocis_module.max_links = -1;
- }
- php3_velocis_module.num_links = 0;
- php3_velocis_module.le_link = register_list_destructors(_close_velocis_link,NULL);
- php3_velocis_module.le_result = register_list_destructors(_free_velocis_result,NULL);
-
- return SUCCESS;
-}
-
-PHP_RINIT_FUNCTION(velocis)
-{
- return SUCCESS;
-}
-
-
-PHP_MINFO_FUNCTION(velocis)
-{
- php_printf("RAIMA Velocis Support Active");
-}
-
-PHP_MSHUTDOWN_FUNCTION(velocis)
-{
- SQLFreeEnv(henv);
- return SUCCESS;
-}
-
-/* Some internal functions. Connections and result manupulate */
-
-static int
-velocis_add_conn(HashTable *list,VConn *conn,HDBC hdbc)
-{
- int ind;
-
- ind = php3_list_insert(conn,php3_velocis_module.le_link);
- conn->hdbc = hdbc;
- conn->index = ind;
-
- return(ind);
-}
-
-static VConn *
-velocis_find_conn(HashTable *list,int ind)
-{
- VConn *conn;
- int type;
-
- conn = php3_list_find(ind,&type);
- if ( !conn || type != php3_velocis_module.le_link ) {
- return(NULL);
- }
- return(conn);
-}
-
-static void
-velocis_del_conn(HashTable *list,int ind)
-{
- php3_list_delete(ind);
-}
-
-static int
-velocis_add_result(HashTable *list,Vresult *res,VConn *conn)
-{
- int ind;
-
- ind = php3_list_insert(res,php3_velocis_module.le_result);
- res->conn = conn;
- res->index = ind;
-
- return(ind);
-}
-
-static Vresult *
-velocis_find_result(HashTable *list,int ind)
-{
- Vresult *res;
- int type;
-
- res = php3_list_find(ind,&type);
- if ( !res || type != php3_velocis_module.le_result ) {
- return(NULL);
- }
- return(res);
-}
-
-static void
-velocis_del_result(HashTable *list,int ind)
-{
- php3_list_delete(ind);
-}
-
-/* Users functions */
-
-PHP_FUNCTION(velocis_connect)
-{
- pval *serv,*user,*pass;
- char *Serv = NULL;
- char *User = NULL;
- char *Pass = NULL;
- RETCODE stat;
- HDBC hdbc;
- VConn *new;
- long ind;
-
- if ( php3_velocis_module.max_links != -1 && php3_velocis_module.num_links == php3_velocis_module.max_links ) {
- php_error(E_WARNING,"Velocis: Too many open connections (%d)",php3_velocis_module.num_links);
- RETURN_FALSE;
- }
- if ( ARG_COUNT(ht) != 3 ||
- getParameters(ht,3,&serv,&user,&pass) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(serv);
- convert_to_string(user);
- convert_to_string(pass);
- Serv = serv->value.str.val;
- User = user->value.str.val;
- Pass = pass->value.str.val;
- stat = SQLAllocConnect(henv,&hdbc);
- if ( stat != SQL_SUCCESS ) {
- php_error(E_WARNING,"Velocis: Could not allocate connection handle");
- RETURN_FALSE;
- }
- stat = SQLConnect(hdbc,Serv,SQL_NTS,User,SQL_NTS,Pass,SQL_NTS);
- if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
- php_error(E_WARNING,"Velocis: Could not connect to server \"%s\" for %s",Serv,User);
- SQLFreeConnect(hdbc);
- RETURN_FALSE;
- }
- new = (VConn *)emalloc(sizeof(VConn));
- if ( new == NULL ) {
- php_error(E_WARNING,"Velocis: Out of memory for store connection");
- SQLFreeConnect(hdbc);
- RETURN_FALSE;
- }
- ind = velocis_add_conn(list,new,hdbc);
- php3_velocis_module.num_links++;
- RETURN_LONG(ind);
-}
-
-PHP_FUNCTION(velocis_close)
-{
- pval *id;
- VConn *conn;
-
- if ( ARG_COUNT(ht) != 1 || getParameters(ht,1,&id) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(id);
- conn = velocis_find_conn(list,id->value.lval);
- if ( !conn ) {
- php_error(E_WARNING,"Velocis: Not connection index (%d)",id->value.lval);
- RETURN_FALSE;
- }
- SQLDisconnect(conn->hdbc);
- SQLFreeConnect(conn->hdbc);
- velocis_del_conn(list,id->value.lval);
- php3_velocis_module.num_links--;
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(velocis_exec)
-{
- pval *ind,*exec_str;
- char *query = NULL;
- int indx;
- VConn *conn;
- Vresult *res;
- RETCODE stat;
- SWORD cols,i,colnamelen;
- SDWORD rows,coldesc;
-
- if ( ARG_COUNT(ht) != 2 || getParameters(ht,2,&ind,&exec_str) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(ind);
- conn = velocis_find_conn(list,ind->value.lval);
- if ( !conn ) {
- php_error(E_WARNING,"Velocis: Not connection index (%d)",ind->value.lval);
- RETURN_FALSE;
- }
- convert_to_string(exec_str);
- query = exec_str->value.str.val;
-
- res = (Vresult *)emalloc(sizeof(Vresult));
- if ( res == NULL ) {
- php_error(E_WARNING,"Velocis: Out of memory for result");
- RETURN_FALSE;
- }
- stat = SQLAllocStmt(conn->hdbc,&res->hstmt);
- if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
- php_error(E_WARNING,"Velocis: SQLAllocStmt return %d",stat);
- efree(res);
- RETURN_FALSE;
- }
- stat = SQLExecDirect(res->hstmt,query,SQL_NTS);
- if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
- php_error(E_WARNING,"Velocis: Can not execute \"%s\" query",query);
- SQLFreeStmt(res->hstmt,SQL_DROP);
- efree(res);
- RETURN_FALSE;
- }
- /* Success query */
- stat = SQLNumResultCols(res->hstmt,&cols);
- if ( stat != SQL_SUCCESS ) {
- php_error(E_WARNING,"Velocis: SQLNumResultCols return %d",stat);
- SQLFreeStmt(res->hstmt,SQL_DROP);
- efree(res);
- RETURN_FALSE;
- }
- if ( !cols ) { /* Was INSERT, UPDATE, DELETE, etc. query */
- stat = SQLRowCount(res->hstmt,&rows);
- if ( stat != SQL_SUCCESS ) {
- php_error(E_WARNING,"Velocis: SQLNumResultCols return %d",stat);
- SQLFreeStmt(res->hstmt,SQL_DROP);
- efree(res);
- RETURN_FALSE;
- }
- SQLFreeStmt(res->hstmt,SQL_DROP);
- efree(res);
- RETURN_LONG(rows);
- } else { /* Was SELECT query */
- res->values = (VResVal *)emalloc(sizeof(VResVal)*cols);
- if ( res->values == NULL ) {
- php_error(E_WARNING,"Velocis: Out of memory for result columns");
- SQLFreeStmt(res->hstmt,SQL_DROP);
- efree(res);
- RETURN_FALSE;
- }
- res->numcols = cols;
- for ( i = 0; i < cols; i++ ) {
- SQLColAttributes(res->hstmt,i+1,SQL_COLUMN_NAME,
- res->values[i].name,sizeof(res->values[i].name),
- &colnamelen,NULL);
- SQLColAttributes(res->hstmt,i+1,SQL_COLUMN_TYPE,
- NULL,0,NULL,&res->values[i].valtype);
- switch ( res->values[i].valtype ) {
- case SQL_LONGVARBINARY:
- case SQL_LONGVARCHAR:
- res->values[i].value = NULL;
- continue;
- default:
- break;
- }
- SQLColAttributes(res->hstmt,i+1,SQL_COLUMN_DISPLAY_SIZE,
- NULL,0,NULL,&coldesc);
- res->values[i].value = (char *)emalloc(coldesc+1);
- if ( res->values[i].value != NULL ) {
- SQLBindCol(res->hstmt,i+1,SQL_C_CHAR,
- res->values[i].value,coldesc+1,
- &res->values[i].vallen);
- }
- }
- }
- res->fetched = 0;
- indx = velocis_add_result(list,res,conn);
- RETURN_LONG(indx);
-}
-
-PHP_FUNCTION(velocis_fetch)
-{
- pval *ind;
- Vresult *res;
- RETCODE stat;
- UDWORD row;
- UWORD RowStat[1];
-
- if ( ARG_COUNT(ht) != 1 || getParameters(ht,1,&ind) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(ind);
- res = velocis_find_result(list,ind->value.lval);
- if ( !res ) {
- php_error(E_WARNING,"Velocis: Not result index (%d)",ind->value.lval);
- RETURN_FALSE;
- }
- stat = SQLExtendedFetch(res->hstmt,SQL_FETCH_NEXT,1,&row,RowStat);
- if ( stat == SQL_NO_DATA_FOUND ) {
- SQLFreeStmt(res->hstmt,SQL_DROP);
- velocis_del_result(list,ind->value.lval);
- RETURN_FALSE;
- }
- if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
- php_error(E_WARNING,"Velocis: SQLFetch return error");
- SQLFreeStmt(res->hstmt,SQL_DROP);
- velocis_del_result(list,ind->value.lval);
- RETURN_FALSE;
- }
- res->fetched = 1;
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(velocis_result)
-{
- pval *ind,*col;
- Vresult *res;
- RETCODE stat;
- int i,sql_c_type;
- UDWORD row;
- UWORD RowStat[1];
- SWORD indx = -1;
- char *field = NULL;
-
- if ( ARG_COUNT(ht) != 2 || getParameters(ht,2,&ind,&col) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(ind);
- res = velocis_find_result(list,ind->value.lval);
- if ( !res ) {
- php_error(E_WARNING,"Velocis: Not result index (%d),ind->value.lval");
- RETURN_FALSE;
- }
- if ( col->type == IS_STRING ) {
- field = col->value.str.val;
- } else {
- convert_to_long(col);
- indx = col->value.lval;
- }
- if ( field ) {
- for ( i = 0; i < res->numcols; i++ ) {
- if ( !strcasecmp(res->values[i].name,field)) {
- indx = i;
- break;
- }
- }
- if ( indx < 0 ) {
- php_error(E_WARNING, "Field %s not found",field);
- RETURN_FALSE;
- }
- } else {
- if ( indx < 0 || indx >= res->numcols ) {
- php_error(E_WARNING,"Velocis: Field index not in range");
- RETURN_FALSE;
- }
- }
- if ( !res->fetched ) {
- stat = SQLExtendedFetch(res->hstmt,SQL_FETCH_NEXT,1,&row,RowStat);
- if ( stat == SQL_NO_DATA_FOUND ) {
- SQLFreeStmt(res->hstmt,SQL_DROP);
- velocis_del_result(list,ind->value.lval);
- RETURN_FALSE;
- }
- if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
- php_error(E_WARNING,"Velocis: SQLFetch return error");
- SQLFreeStmt(res->hstmt,SQL_DROP);
- velocis_del_result(list,ind->value.lval);
- RETURN_FALSE;
- }
- res->fetched = 1;
- }
- switch ( res->values[indx].valtype ) {
- case SQL_LONGVARBINARY:
- sql_c_type = SQL_C_BINARY;
- goto l1;
- case SQL_LONGVARCHAR:
- sql_c_type = SQL_C_CHAR;
-l1:
- if ( !res->values[indx].value ) {
- res->values[indx].value = emalloc(4096);
- if ( !res->values[indx].value ) {
- php_error(E_WARNING,"Out of memory");
- RETURN_FALSE;
- }
- }
- stat = SQLGetData(res->hstmt,indx+1,sql_c_type,
- res->values[indx].value,4095,&res->values[indx].vallen);
- if ( stat == SQL_NO_DATA_FOUND ) {
- SQLFreeStmt(res->hstmt,SQL_DROP);
- velocis_del_result(list,ind->value.lval);
- RETURN_FALSE;
- }
- if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
- php_error(E_WARNING,"Velocis: SQLGetData return error");
- SQLFreeStmt(res->hstmt,SQL_DROP);
- velocis_del_result(list,ind->value.lval);
- RETURN_FALSE;
- }
- if ( res->values[indx].valtype == SQL_LONGVARCHAR ) {
- RETURN_STRING(res->values[indx].value,TRUE);
- } else {
- RETURN_LONG((long)res->values[indx].value);
- }
- default:
- if ( res->values[indx].value != NULL ) {
- RETURN_STRING(res->values[indx].value,TRUE);
- }
- }
-}
-
-PHP_FUNCTION(velocis_freeresult)
-{
- pval *ind;
- Vresult *res;
-
- if ( ARG_COUNT(ht) != 1 || getParameters(ht,1,&ind) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(ind);
- res = velocis_find_result(list,ind->value.lval);
- if ( !res ) {
- php_error(E_WARNING,"Velocis: Not result index (%d)",ind->value.lval);
- RETURN_FALSE;
- }
- SQLFreeStmt(res->hstmt,SQL_DROP);
- velocis_del_result(list,ind->value.lval);
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(velocis_autocommit)
-{
- pval *id;
- RETCODE stat;
- VConn *conn;
-
- if ( ARG_COUNT(ht) != 1 || getParameters(ht,1,&id) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(id);
- conn = velocis_find_conn(list,id->value.lval);
- if ( !conn ) {
- php_error(E_WARNING,"Velocis: Not connection index (%d)",id->value.lval);
- RETURN_FALSE;
- }
- stat = SQLSetConnectOption(conn->hdbc,SQL_AUTOCOMMIT,SQL_AUTOCOMMIT_ON);
- if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
- php_error(E_WARNING,"Velocis: Set autocommit_on option failure");
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(velocis_off_autocommit)
-{
- pval *id;
- RETCODE stat;
- VConn *conn;
-
- if ( ARG_COUNT(ht) != 1 || getParameters(ht,1,&id) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(id);
- conn = velocis_find_conn(list,id->value.lval);
- if ( !conn ) {
- php_error(E_WARNING,"Velocis: Not connection index (%d)",id->value.lval);
- RETURN_FALSE;
- }
- stat = SQLSetConnectOption(conn->hdbc,SQL_AUTOCOMMIT,SQL_AUTOCOMMIT_OFF);
- if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
- php_error(E_WARNING,"Velocis: Set autocommit_off option failure");
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(velocis_commit)
-{
- pval *id;
- RETCODE stat;
- VConn *conn;
-
- if ( ARG_COUNT(ht) != 1 || getParameters(ht,1,&id) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(id);
- conn = velocis_find_conn(list,id->value.lval);
- if ( !conn ) {
- php_error(E_WARNING,"Velocis: Not connection index (%d)",id->value.lval);
- RETURN_FALSE;
- }
- stat = SQLTransact(NULL,conn->hdbc,SQL_COMMIT);
- if ( stat != SQL_SUCCESS ) {
- php_error(E_WARNING,"Velocis: Commit failure");
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(velocis_rollback)
-{
- pval *id;
- RETCODE stat;
- VConn *conn;
-
- if ( ARG_COUNT(ht) != 1 || getParameters(ht,1,&id) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(id);
- conn = velocis_find_conn(list,id->value.lval);
- if ( !conn ) {
- php_error(E_WARNING,"Velocis: Not connection index (%d)",id->value.lval);
- RETURN_FALSE;
- }
- stat = SQLTransact(NULL,conn->hdbc,SQL_ROLLBACK);
- if ( stat != SQL_SUCCESS ) {
- php_error(E_WARNING,"Velocis: Rollback failure");
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(velocis_fieldname)
-{
- pval *ind,*col;
- Vresult *res;
- SWORD indx;
-
- if ( ARG_COUNT(ht) != 2 || getParameters(ht,2,&ind,&col) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(ind);
- res = velocis_find_result(list,ind->value.lval);
- if ( !res ) {
- php_error(E_WARNING,"Velocis: Not result index (%d),ind->value.lval");
- RETURN_FALSE;
- }
- convert_to_long(col);
- indx = col->value.lval;
- if ( indx < 0 || indx >= res->numcols ) {
- php_error(E_WARNING,"Velocis: Field index not in range");
- RETURN_FALSE;
- }
- RETURN_STRING(res->values[indx].name,TRUE);
-}
-
-PHP_FUNCTION(velocis_fieldnum)
-{
- pval *ind;
- Vresult *res;
-
- if ( ARG_COUNT(ht) != 1 || getParameters(ht,1,&ind) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(ind);
- res = velocis_find_result(list,ind->value.lval);
- if ( !res ) {
- php_error(E_WARNING,"Velocis: Not result index (%d),ind->value.lval");
- RETURN_FALSE;
- }
- RETURN_LONG(res->numcols);
-}
-
-#endif /* HAVE_VELOCIS */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/oracle/Makefile.am b/ext/oracle/Makefile.am
deleted file mode 100644
index 503d31a8de..0000000000
--- a/ext/oracle/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_oracle.a
-libphpext_oracle_a_SOURCES=oracle.c
diff --git a/ext/oracle/config.h.stub b/ext/oracle/config.h.stub
deleted file mode 100644
index f6f3bcd81b..0000000000
--- a/ext/oracle/config.h.stub
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Define if you have the Oracle database client libraries */
-#define HAVE_ORACLE 0
diff --git a/ext/oracle/config.m4 b/ext/oracle/config.m4
deleted file mode 100644
index 5cf465bee4..0000000000
--- a/ext/oracle/config.m4
+++ /dev/null
@@ -1,172 +0,0 @@
-dnl $Id$
-
-AC_DEFUN(AC_ORACLE_VERSION,[
- AC_MSG_CHECKING([Oracle version])
- if test -f "$ORACLEINST_TOP/orainst/unix.rgs"
- then
- ORACLE_VERSION=`grep '"ocommon"' $ORACLEINST_TOP/orainst/unix.rgs | sed 's/[ ][ ]*/:/g' | cut -d: -f 6 | cut -c 2-4`
- test -z "$ORACLE_VERSION" && ORACLE_VERSION=7.3
- else
- if test -f "$ORACLEINST_TOP/lib/libclntsh.so.8.0"
- then
- ORACLE_VERSION=8.1
- else
- ORACLE_VERSION=8.0
- fi
- fi
- AC_MSG_RESULT($ORACLE_VERSION)
-])
-
-AC_MSG_CHECKING(for Oracle support)
-AC_ARG_WITH(oracle,
-[ --with-oracle[=DIR] Include Oracle database support. DIR is Oracle's
- home directory, defaults to \$ORACLE_HOME.],
-[
- case "$withval" in
- yes)
- ORACLEINST_TOP=$ORACLE_HOME
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(oracle)
- ;;
- no)
- ORACLEINST_TOP=
- AC_MSG_RESULT(no)
- ;;
- *)
- ORACLEINST_TOP=$withval
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(oracle)
- ;;
- esac
-
- if test "$ORACLEINST_TOP" != ""
- then
-
- # Oracle include files
-
- if test -f "$ORACLEINST_TOP/rdbms/public/ocidfn.h"
- then
- # V8.0.5
- ORACLE_INCLUDE="$ORACLE_INCLUDE -I$ORACLEINST_TOP/rdbms/public"
- elif test -f "$ORACLEINST_TOP/rdbms/demo/ocidfn.h"
- then
- # V7.[0123]
- ORACLE_INCLUDE=-I$ORACLEINST_TOP/rdbms/demo
- fi
-
- if test -d "$ORACLEINST_TOP/network/public"
- then
- # V8
- ORACLE_INCLUDE="$ORACLE_INCLUDE -I$ORACLEINST_TOP/network/public"
- fi
-
- if test -d "$ORACLEINST_TOP/plsql/public"
- then
- # V8
- ORACLE_INCLUDE="$ORACLE_INCLUDE -I$ORACLEINST_TOP/plsql/public"
- fi
-
- # Need to know the version, otherwhise we will mixup nlsrtl
- AC_ORACLE_VERSION($ORACLEINST_TOP)
-
- # Oracle libs - nightmare :-)
-
- ORACLE_LIBDIR=lib
- ORACLE_LFLAGS="-L$ORACLEINST_TOP/$ORACLE_LIBDIR ${ld_runpath_switch}$ORACLEINST_TOP/$ORACLE_LIBDIR"
- if test -f "$ORACLEINST_TOP/rdbms/lib/sysliblist"
- then
- ORA_SYSLIB="`cat $ORACLEINST_TOP/rdbms/lib/sysliblist`"
- else
- ORA_SYSLIB="-lm"
- fi
-
- # Oracle Static libs
- case $ORACLE_VERSION in
- 7.0|7.1)
- ORACLE_STLIBS="-locic $ORACLEINST_TOP/$ORACLE_LIBDIR/osntab.o \
- -lsqlnet -lora -lsqlnet -lnlsrtl -lcv6 -lcore -lnlsrtl -lcv6 \
- -lcore $ORA_SYSLIB -lcore $ORA_SYSLIB"
- if test "`uname -s 2>/dev/null`" = "AIX"; then
- ORACLE_STLIBS="$ORACLE_STLIBS -bI:$ORACLE_HOME/lib/mili.exp"
- fi
- ;;
- 7.2)
- ORACLE_STLIBS="-locic $ORACLEINST_TOP/$ORACLE_LIBDIR/osntab.o \
- -lsqlnet -lora -lsqlnet -lora -lnlsrtl3 -lc3v6 -lcore3 -lnlsrtl3 \
- -lcore3 $ORA_SYSLIB -lcore3 $ORA_SYSLIB"
- ;;
- 7.3)
- ORACLE_STLIBS="-lclient -lsqlnet -lncr -lsqlnet -lclient -lcommon \
- -lgeneric -lsqlnet -lncr -lsqlnet -lclient -lcommon -lgeneric \
- -lepc -lnlsrtl3 -lc3v6 -lcore3 -lnlsrtl3 -lcore3 -lnlsrtl3 \
- $ORA_SYSLIB -lcore3 $ORA_SYSLIB"
- ;;
- 8.0)
- ORACLE_STLIBS="-lclient -lsqlnet -lncr -lsqlnet -lclient -lcommon \
- -lgeneric -lsqlnet -lncr -lsqlnet -lclient -lcommon -lgeneric \
- -lepc -lnlsrtl3 -lc3v6 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 \
- $ORA_SYSLIB -lcore3 $ORA_SYSLIB"
- ;;
- *)
- ORACLE_STLIBS=
- ;;
- esac
-
- # Oracle shared libs
- case $ORACLE_VERSION in
- 7.0)
- # shared libs not supported
- ORACLE_SHLIBS="$ORACLE_STLIBS"
- ;;
- 7.1)
- if test -f $ORACLEINST_TOP/$ORACLE_LIBDIR/liboracle.s?
- then
- ORACLE_SHLIBS="-loracle $ORA_SYSLIB"
- else
- ORACLE_SHLIBS="$ORACLE_STLIBS"
- fi
- ;;
- 7.2|7.3)
- if test -f $ORACLEINST_TOP/$ORACLE_LIBDIR/libclntsh.s?
- then
- ORACLE_SHLIBS="-lclntsh $ORA_SYSLIB"
- else
- ORACLE_SHLIBS="$ORACLE_STLIBS"
- fi
- ;;
- 8.0)
- if test -f $ORACLEINST_TOP/$ORACLE_LIBDIR/libclntsh.s? -o \
- -f $ORACLEINST_TOP/$ORACLE_LIBDIR/libclntsh.a # AIX
- then
- if test "$CC" = "gcc" -a "`uname -sv`" = "AIX 4"; then
- # for Oracle 8 on AIX 4
- ORA_SYSLIB="$ORA_SYSLIB -nostdlib /lib/crt0_r.o /usr/lib/libpthreads.a /usr/lib/libc_r.a -lgcc"
- fi
- ORACLE_SHLIBS="-lclntsh -lpsa -lcore4 -lnlsrtl3 -lclntsh $ORA_SYSLIB"
- else
- ORACLE_SHLIBS="$ORACLE_STLIBS"
- fi
- AC_DEFINE(HAVE_OCI8)
- ;;
- 8.1)
- ORACLE_SHLIBS="-lclntsh $ORA_SYSLIB"
- AC_DEFINE(HAVE_OCI8)
- ;;
- *)
- ORACLE_SHLIBS=
- ;;
- esac
-
- # only using shared libs right now
- ORACLE_LIBS=$ORACLE_SHLIBS
-
- AC_DEFINE(HAVE_ORACLE)
-
- fi
-
-],[AC_MSG_RESULT(no)])
-#EXTRA_LIBS="$EXTRA_LIBS $ORACLE_SHLIBS $ORACLE_STLIBS $ORACLE_LIBS $ORACLE_LFLAGS"
-EXTRA_LIBS="$EXTRA_LIBS $ORACLE_LIBS $ORACLE_LFLAGS"
-INCLUDES="$INCLUDES $ORACLE_INCLUDE"
-AC_SUBST(ORACLE_HOME)
-AC_SUBST(ORACLE_VERSION)
diff --git a/ext/oracle/oracle.c b/ext/oracle/oracle.c
deleted file mode 100644
index 837f70cb20..0000000000
--- a/ext/oracle/oracle.c
+++ /dev/null
@@ -1,1944 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Stig Sæther Bakken <ssb@fast.no> |
- | Mitch Golden <mgolden@interport.net> |
- | Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Andreas Karajannis <Andreas.Karajannis@gmd.de> |
- | Thies C. Arntzen <thies@digicol.de> |
- +----------------------------------------------------------------------+
- */
-
-/* comment out the next line if you're on Oracle 7.x and don't have the olog
- call. */
-
-#define HAS_OLOG 1
-
-#if defined(COMPILE_DL)
-# include "dl/phpdl.h"
-#endif
-
-#include "php.h"
-
-#if PHP_API_VERSION < 19990421
- #include "internal_functions.h"
- #include "php3_list.h"
- #include "head.h"
-#else
- #include "zend_globals.h"
-#endif
-
-#if HAVE_ORACLE
-
-#if PHP_API_VERSION < 19990421
- #include "oracle.h"
- #define HASH_DTOR (void (*)(void *))
-#else
- #include "php3_oracle.h"
- #define HASH_DTOR (int (*)(void *))
-#endif
-
-#ifndef ZEND_MODULE_INFO_FUNC_ARGS
-#define ZEND_MODULE_INFO_FUNC_ARGS void
-#endif
-
-#ifdef WIN32
-# include "variables.h"
-#else
-# include "build-defs.h"
-#endif
-
-
-#include "snprintf.h"
-
-#ifndef min
-#define min(a, b) ((a) > (b) ? (b) : (a))
-#endif
-
-#if WIN32||WINNT
-#define PHP_ORA_API __declspec(dllexport)
-#else
-#define PHP_ORA_API
-#endif
-
-#ifdef ZTS
-int ora_globals_id;
-#else
-PHP_ORA_API php_ora_globals ora_globals;
-#endif
-
-#define DB_SIZE 65536
-
-#define ORA_FETCHINTO_ASSOC (1<<0)
-#define ORA_FETCHINTO_NULLS (1<<1)
-
-static oraConnection *ora_get_conn(HashTable *,HashTable *, int);
-static int ora_add_cursor(HashTable *, oraCursor *);
-static oraCursor *ora_get_cursor(HashTable *, int);
-static void ora_del_cursor(HashTable *, int);
-static char *ora_error(Cda_Def *);
-static int ora_describe_define(oraCursor *);
-static int _close_oraconn(oraConnection *conn);
-static int _close_orapconn(oraConnection *conn);
-static int _close_oracur(oraCursor *cur);
-static int _ora_ping(oraConnection *conn);
-int ora_set_param_values(oraCursor *cursor, int isout);
-
-void php3_Ora_Do_Logon(INTERNAL_FUNCTION_PARAMETERS, int persistent);
-
-static int le_conn, le_pconn, le_cursor;
-
-PHP_FUNCTION(ora_bind);
-PHP_FUNCTION(ora_close);
-PHP_FUNCTION(ora_commit);
-PHP_FUNCTION(ora_commitoff);
-PHP_FUNCTION(ora_commiton);
-PHP_FUNCTION(ora_do);
-PHP_FUNCTION(ora_error);
-PHP_FUNCTION(ora_errorcode);
-PHP_FUNCTION(ora_exec);
-PHP_FUNCTION(ora_fetch);
-PHP_FUNCTION(ora_fetch_into);
-PHP_FUNCTION(ora_columntype);
-PHP_FUNCTION(ora_columnname);
-PHP_FUNCTION(ora_columnsize);
-PHP_FUNCTION(ora_getcolumn);
-PHP_FUNCTION(ora_numcols);
-PHP_FUNCTION(ora_numrows);
-PHP_FUNCTION(ora_logoff);
-PHP_FUNCTION(ora_logon);
-PHP_FUNCTION(ora_plogon);
-PHP_FUNCTION(ora_open);
-PHP_FUNCTION(ora_parse);
-PHP_FUNCTION(ora_rollback);
-
-PHP_MINIT_FUNCTION(oracle);
-PHP_RINIT_FUNCTION(oracle);
-PHP_MSHUTDOWN_FUNCTION(oracle);
-PHP_RSHUTDOWN_FUNCTION(oracle);
-PHP_MINFO_FUNCTION(oracle);
-
-function_entry oracle_functions[] = {
- PHP_FE(ora_bind, NULL)
- PHP_FE(ora_close, NULL)
- PHP_FE(ora_commit, NULL)
- PHP_FE(ora_commitoff, NULL)
- PHP_FE(ora_commiton, NULL)
- PHP_FE(ora_do, NULL)
- PHP_FE(ora_error, NULL)
- PHP_FE(ora_errorcode, NULL)
- PHP_FE(ora_exec, NULL)
- PHP_FE(ora_fetch, NULL)
- PHP_FE(ora_fetch_into, NULL)
- PHP_FE(ora_columntype, NULL)
- PHP_FE(ora_columnname, NULL)
- PHP_FE(ora_columnsize, NULL)
- PHP_FE(ora_getcolumn, NULL)
- PHP_FE(ora_numcols, NULL)
- PHP_FE(ora_numrows, NULL)
- PHP_FE(ora_logoff, NULL)
- PHP_FE(ora_logon, NULL)
- PHP_FE(ora_plogon, NULL)
- PHP_FE(ora_open, NULL)
- PHP_FE(ora_parse, NULL)
- PHP_FE(ora_rollback, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry oracle_module_entry = {
- "Oracle",
- oracle_functions,
- PHP_MINIT(oracle), /* extension-wide startup function */
- PHP_MSHUTDOWN(oracle), /* extension-wide shutdown function */
- PHP_RINIT(oracle), /* per-request startup function */
- PHP_RSHUTDOWN(oracle), /* per-request shutdown function */
- PHP_MINFO(oracle),
- STANDARD_MODULE_PROPERTIES
-};
-
-static const text *ora_func_tab[] =
-{(text *) "unused",
-/* 1, 2 */ (text *) "unused", (text *) "OSQL",
-/* 3, 4 */ (text *) "unused", (text *) "OEXEC/OEXN",
-/* 5, 6 */ (text *) "unused", (text *) "OBIND",
-/* 7, 8 */ (text *) "unused", (text *) "ODEFIN",
-/* 9, 10 */ (text *) "unused", (text *) "ODSRBN",
-/* 11, 12 */ (text *) "unused", (text *) "OFETCH/OFEN",
-/* 13, 14 */ (text *) "unused", (text *) "OOPEN",
-/* 15, 16 */ (text *) "unused", (text *) "OCLOSE",
-/* 17, 18 */ (text *) "unused", (text *) "unused",
-/* 19, 20 */ (text *) "unused", (text *) "unused",
-/* 21, 22 */ (text *) "unused", (text *) "ODSC",
-/* 23, 24 */ (text *) "unused", (text *) "ONAME",
-/* 25, 26 */ (text *) "unused", (text *) "OSQL3",
-/* 27, 28 */ (text *) "unused", (text *) "OBNDRV",
-/* 29, 30 */ (text *) "unused", (text *) "OBNDRN",
-/* 31, 32 */ (text *) "unused", (text *) "unused",
-/* 33, 34 */ (text *) "unused", (text *) "OOPT",
-/* 35, 36 */ (text *) "unused", (text *) "unused",
-/* 37, 38 */ (text *) "unused", (text *) "unused",
-/* 39, 40 */ (text *) "unused", (text *) "unused",
-/* 41, 42 */ (text *) "unused", (text *) "unused",
-/* 43, 44 */ (text *) "unused", (text *) "unused",
-/* 45, 46 */ (text *) "unused", (text *) "unused",
-/* 47, 48 */ (text *) "unused", (text *) "unused",
-/* 49, 50 */ (text *) "unused", (text *) "unused",
-/* 51, 52 */ (text *) "unused", (text *) "OCAN",
-/* 53, 54 */ (text *) "unused", (text *) "OPARSE",
-/* 55, 56 */ (text *) "unused", (text *) "OEXFET",
-/* 57, 58 */ (text *) "unused", (text *) "OFLNG",
-/* 59, 60 */ (text *) "unused", (text *) "ODESCR",
-/* 61, 62 */ (text *) "unused", (text *) "OBNDRA"
-};
-
-#if COMPILE_DL
-DLEXPORT php3_module_entry *get_module() { return &oracle_module_entry; };
-#endif
-
-static int _close_oraconn(oraConnection *conn)
-{
- ORALS_FETCH();
-
- conn->open = 0;
-
- ologof(&conn->lda);
- ORA(num_links)--;
- efree(conn);
-
- zend_hash_del(ORA(conns),(void*)&conn,sizeof(void*));
-
- return 1;
-}
-
-static int _close_orapconn(oraConnection *conn)
-{
- ORALS_FETCH();
-
- conn->open = 0;
-
- ologof(&conn->lda);
- free(conn);
- ORA(num_links)--;
- ORA(num_persistent)--;
-
- zend_hash_del(ORA(conns),(void*)&conn,sizeof(void*));
-
- return 1;
-}
-
-static int
-pval_ora_param_destructor(oraParam *param)
-{
- if (param->progv) {
- efree(param->progv);
- }
- return 1;
-}
-
-
-static int _close_oracur(oraCursor *cur)
-{
- int i;
- ORALS_FETCH();
-
- if (cur){
- if (cur->query){
- efree(cur->query);
- }
- if (cur->params){
- zend_hash_destroy(cur->params);
- efree(cur->params);
- cur->params = NULL;
- }
- if (cur->columns){
- for(i = 0; i < cur->ncols; i++){
- if (cur->columns[i].buf)
- efree(cur->columns[i].buf);
- }
- efree(cur->columns);
- cur->columns = NULL;
- }
-
- if (cur->open){
- oraConnection *db_conn;
-
- if (zend_hash_find(ORA(conns),(void*)&(cur->conn_ptr),sizeof(void*),(void **)&db_conn) == SUCCESS) {
- oclose(&cur->cda);
- }
- }
-
- efree(cur);
- }
-
- return 1;
-}
-
-#ifdef ZTS
-static void php_ora_init_globals(php_ora_globals *ora_globals)
-{
- ELS_FETCH();
-
- if (cfg_get_long("oracle.allow_persistent",
- &ORA(allow_persistent))
- == FAILURE) {
- ORA(allow_persistent) = -1;
- }
- if (cfg_get_long("oracle.max_persistent",
- &ORA(max_persistent))
- == FAILURE) {
- ORA(max_persistent) = -1;
- }
- if (cfg_get_long("oracle.max_links",
- &ORA(max_links))
- == FAILURE) {
- ORA(max_links) = -1;
- }
-
- ORA(num_persistent) = 0;
-
- ORA(conns) = malloc(sizeof(HashTable));
- zend_hash_init(ORA(conns), 13, NULL, NULL, 1);
-}
-#endif
-PHP_MINIT_FUNCTION(oracle)
-{
-
- ELS_FETCH();
-
-#ifdef ZTS
- ora_globals_id = ts_allocate_id(sizeof(php_ora_globals), php_ora_init_globals, NULL);
-#else
- if (cfg_get_long("oracle.allow_persistent",
- &ORA(allow_persistent))
- == FAILURE) {
- ORA(allow_persistent) = -1;
- }
- if (cfg_get_long("oracle.max_persistent",
- &ORA(max_persistent))
- == FAILURE) {
- ORA(max_persistent) = -1;
- }
- if (cfg_get_long("oracle.max_links",
- &ORA(max_links))
- == FAILURE) {
- ORA(max_links) = -1;
- }
-
- ORA(num_persistent) = 0;
-
-
- ORA(conns) = malloc(sizeof(HashTable));
- zend_hash_init(ORA(conns), 13, NULL, NULL, 1);
-#endif
-
- le_cursor = register_list_destructors(_close_oracur, NULL);
- le_conn = register_list_destructors(_close_oraconn, NULL);
- le_pconn = register_list_destructors(NULL, _close_orapconn);
-
- REGISTER_LONG_CONSTANT("ORA_BIND_INOUT", 0, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("ORA_BIND_IN", 1, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("ORA_BIND_OUT", 2, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("ORA_FETCHINTO_ASSOC",ORA_FETCHINTO_ASSOC, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("ORA_FETCHINTO_NULLS",ORA_FETCHINTO_NULLS, CONST_CS | CONST_PERSISTENT);
-
-#if NEEDED
- opinit(OCI_EV_TSF); /* initialize threaded environment - must match the threaded mode
- of the oci8 driver if both are used at the same time!! */
-#endif
-
- return SUCCESS;
-}
-
-PHP_RINIT_FUNCTION(oracle)
-{
- ORALS_FETCH();
-
- ORA(num_links) =
- ORA(num_persistent);
- /*
- ORA(defaultlrl) = 0;
- ORA(defaultbinmode) = 0;
- ORA(defaultconn) = 0;
- */
- return SUCCESS;
-}
-
-
-PHP_MSHUTDOWN_FUNCTION(oracle)
-{
- ORALS_FETCH();
-
- zend_hash_destroy(ORA(conns));
- free(ORA(conns));
-
- return SUCCESS;
-}
-
-PHP_RSHUTDOWN_FUNCTION(oracle)
-{
- return SUCCESS;
-
-}
-
-static int _ora_ping(oraConnection *conn)
-{
- Cda_Def cda;
-
- if (oopen(&cda, &conn->lda, (text *) 0, -1, -1, (text *) 0, -1)) {
- return 0;
- }
-
- if (oparse(&cda, "select sysdate from dual", (sb4) - 1, 0, VERSION_7)) {
- oclose(&cda);
- return 0;
- }
-
- oclose(&cda);
- return 1;
-
-}
-
-/*
- ** PHP functions
-*/
-
-/* {{{ proto int ora_logon(string user, string password)
- Open an Oracle connection */
-PHP_FUNCTION(ora_logon)
-{
- php3_Ora_Do_Logon(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ proto int ora_plogon(string user, string password)
- Open a persistant Oracle connection */
-PHP_FUNCTION(ora_plogon)
-{
- php3_Ora_Do_Logon(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-void php3_Ora_Do_Logon(INTERNAL_FUNCTION_PARAMETERS, int persistent)
-{
- char *user = NULL;
- char *pwd = NULL;
- pval *arg1, *arg2;
- oraConnection *db_conn;
- list_entry *index_ptr;
- char *hashed_details;
- int hashed_len, len, id;
- ORALS_FETCH();
-
- if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(arg1);
- convert_to_string(arg2);
-
- user = arg1->value.str.val;
- pwd = arg2->value.str.val;
-
- if (!ORA(allow_persistent)) {
- persistent = 0;
- }
-
- if (ORA(max_links) != -1 &&
- ORA(num_links) >=
- ORA(max_links)) {
- php_error(E_WARNING, "Oracle: Too many open links (%d)",
- ORA(num_links));
- RETURN_FALSE;
- }
-
- /* the user requested a persistent connection */
- if (persistent &&
- ORA(max_persistent) != -1 &&
- ORA(num_persistent) >=
- ORA(max_persistent)) {
- php_error(E_WARNING,"Oracle: Too many open persistent links (%d)",
- ORA(num_persistent));
- RETURN_FALSE;
- }
-
- len = strlen(user) + strlen(pwd) + 9;
- hashed_details = emalloc(len);
-
- if (hashed_details == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
-
- hashed_len = php_sprintf(hashed_details, "ora_%s_%s", user, pwd);
-
- /* try to find if we already have this link in our persistent list,
- * no matter if it is to be persistent or not
- */
-
- if (zend_hash_find(plist, hashed_details, hashed_len + 1,
- (void **) &index_ptr) == FAILURE) {
- /* the link is not in the persistent list */
- list_entry new_index_ptr;
-
- if (persistent)
- db_conn = (oraConnection *)malloc(sizeof(oraConnection));
- else
- db_conn = (oraConnection *)emalloc(sizeof(oraConnection));
-
- if (db_conn == NULL){
- efree(hashed_details);
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
-
- memset((void *) db_conn,0,sizeof(oraConnection));
-
-#if HAS_OLOG
- if (olog(&db_conn->lda, db_conn->hda, user,
- strlen(user), pwd, strlen(pwd), 0, -1, OCI_LM_DEF)) {
-#else
- if (orlon(&db_conn->lda, db_conn->hda, user,
- strlen(user), pwd, strlen(pwd), 0)) {
-#endif
- php_error(E_WARNING, "Unable to connect to ORACLE (%s)",
- ora_error(&db_conn->lda));
- if (persistent)
- free(db_conn);
- else
- efree(db_conn);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- db_conn->open = 1;
- if (persistent){
- /*new_le.type = le_pconn;
- new_le.ptr = db_conn;*/
- RETVAL_RESOURCE(php3_plist_insert(db_conn, le_pconn));
- new_index_ptr.ptr = (void *) return_value->value.lval;
-#ifdef THREAD_SAFE
- new_index_ptr.type = _php3_le_index_ptr();
-#else
- new_index_ptr.type = le_index_ptr;
-#endif
- if (zend_hash_update(plist,hashed_details,hashed_len + 1,(void *) &new_index_ptr,
- sizeof(list_entry),NULL) == FAILURE) {
- ologof(&db_conn->lda);
- free(db_conn);
- efree(hashed_details);
- php_error(E_WARNING, "Can't update hashed details list");
- RETURN_FALSE;
- }
- ORA(num_persistent)++;
- } else {
- /* non persistent, simply add to list */
- RETVAL_RESOURCE(php3_list_insert(db_conn, le_conn));
- }
-
- ORA(num_links)++;
-
- } else {
- int type;
-
- /* the link is already in the persistent list */
-#ifdef THREAD_SAFE
- if (index_ptr->type != _php3_le_index_ptr()) {
-#else
- if (index_ptr->type != le_index_ptr) {
-#endif
- efree(hashed_details);
- php_error(E_WARNING, "Oops, something went completly wrong");
- RETURN_FALSE;
- }
- id = (int) index_ptr->ptr;
- db_conn = (oraConnection *)php3_plist_find(id, &type);
-
- if (db_conn && (type == le_conn ||
- type == le_pconn)){
- if(!_ora_ping(db_conn)) {
- /* XXX Reinitialize lda, hda ? */
-#if HAS_OLOG
- if(olog(&db_conn->lda, db_conn->hda, user,
- strlen(user), pwd, strlen(pwd), 0, -1, OCI_LM_DEF)) {
-#else
- if(orlon(&db_conn->lda, db_conn->hda, user,
- strlen(user), pwd, strlen(pwd), 0)) {
-#endif
- php_error(E_WARNING, "Unable to reconnect to ORACLE (%s)",
- ora_error(&db_conn->lda));
- /* Delete list entry for this connection */
- php3_plist_delete(id);
- /* Delete hashed list entry for this dead connection */
- zend_hash_del(plist, hashed_details, hashed_len);
- efree(hashed_details);
- RETURN_FALSE;
- }
- }
- RETVAL_RESOURCE(id);
- }
- }
-
- zend_hash_add(ORA(conns),
- (void*)&db_conn,
- sizeof(void*),
- (void*)&db_conn,
- sizeof(void*),
- NULL);
-
- efree(hashed_details);
-}
-
-/* {{{ proto int ora_logoff(int connection)
- Close an Oracle connection */
-PHP_FUNCTION(ora_logoff)
-{ /* conn_index */
- int type, ind;
- oraConnection *conn;
- pval *arg;
- ORALS_FETCH();
-
- if (getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg);
- ind = (int)arg->value.lval;
-
- conn = (oraConnection *)php3_list_find(ind, &type);
- if (!conn || (type != le_conn &&
- type != le_pconn)) {
- return;
- }
- php3_list_delete(ind);
-}
-/* }}} */
-
-/* {{{ proto int ora_open(int connection)
- Open an Oracle cursor */
-PHP_FUNCTION(ora_open)
-{ /* conn_index */
- pval *arg;
- oraConnection *conn = NULL;
- oraCursor *cursor = NULL;
- int conn_ind;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg);
-
- conn_ind = arg->value.lval;
- conn = ora_get_conn(list,plist, conn_ind);
- if (conn == NULL) {
- RETURN_FALSE;
- }
-
- if ((cursor = (oraCursor *)emalloc(sizeof(oraCursor))) == NULL){
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
- memset(cursor, 0, sizeof(oraCursor));
- if (oopen(&cursor->cda, &conn->lda, (text *) 0, -1, -1, (text *) 0, -1)) {
- php_error(E_WARNING, "Unable to open new cursor (%s)",
- ora_error(&cursor->cda));
- efree(cursor);
- RETURN_FALSE;
- }
- cursor->open = 1;
- cursor->conn_ptr = conn;
- cursor->conn_id = conn_ind;
- RETURN_RESOURCE(ora_add_cursor(list, cursor));
-}
-/* }}} */
-
-/* {{{ proto int ora_close(int cursor)
- Close an Oracle cursor */
-PHP_FUNCTION(ora_close)
-{ /* conn_index */
- pval *arg;
-
- if (getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg);
-
- ora_del_cursor(list, arg->value.lval);
- RETVAL_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int ora_commitoff(int connection)
- Disable automatic commit */
-PHP_FUNCTION(ora_commitoff)
-{ /* conn_index */
- pval *arg;
- oraConnection *conn;
-
- if (getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg);
-
- conn = ora_get_conn(list,plist, arg->value.lval);
- if (conn == NULL) {
- RETURN_FALSE;
- }
- if (ocof(&conn->lda)) {
- php_error(E_WARNING, "Unable to turn off auto-commit (%s)",
- ora_error(&conn->lda));
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int ora_commiton(int connection)
- Enable automatic commit */
-PHP_FUNCTION(ora_commiton)
-{ /* conn_index */
- pval *arg;
- oraConnection *conn;
-
- if (getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg);
-
- if (!(conn = ora_get_conn(list,plist, arg->value.lval))) {
- RETURN_FALSE;
- }
-
- if (ocon(&conn->lda)) {
- php_error(E_WARNING, "Unable to turn on auto-commit (%s)",
- ora_error(&conn->lda));
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int ora_commit(int connection)
- Commit an Oracle transaction */
-PHP_FUNCTION(ora_commit)
-{ /* conn_index */
- pval *arg;
- oraConnection *conn;
-
- if (getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg);
-
- conn = ora_get_conn(list,plist, arg->value.lval);
- if (conn == NULL) {
- RETURN_FALSE;
- }
- if (ocom(&conn->lda)) {
- php_error(E_WARNING, "Unable to commit transaction (%s)",
- ora_error(&conn->lda));
- RETURN_FALSE;
- }
- RETVAL_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int ora_rollback(int connection)
- Roll back an Oracle transaction */
-PHP_FUNCTION(ora_rollback)
-{ /* conn_index */
- pval *arg;
- oraConnection *conn;
-
- if (getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg);
-
- conn = ora_get_conn(list,plist, arg->value.lval);
- if (conn == NULL) {
- RETURN_FALSE;
- }
- if (orol(&conn->lda)) {
- php_error(E_WARNING, "Unable to roll back transaction (%s)",
- ora_error(&conn->lda));
- RETURN_FALSE;
- }
- RETVAL_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int ora_parse(int cursor, string sql_statement [, int defer])
- Parse an Oracle SQL statement */
-PHP_FUNCTION(ora_parse)
-{
- /* cursor_ind, sql_statement [, defer] */
- int argc;
- pval *argv[3];
- oraCursor *cursor;
- sword defer = 0;
- text *query;
-
- argc = ARG_COUNT(ht);
- if ((argc != 2 && argc != 3) || getParametersArray(ht, argc, argv) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(argv[0]);
- convert_to_string(argv[1]);
-
- if (argc == 3) {
- convert_to_long(argv[2]);
- if (argv[2]->value.lval != 0) {
- defer = DEFER_PARSE;
- }
- }
-
- query = (text *) estrndup(argv[1]->value.str.val,argv[1]->value.str.len);
-
- if (query == NULL) {
- php_error(E_WARNING, "Invalid query");
- RETURN_FALSE;
- }
- if (!(cursor = ora_get_cursor(list, argv[0]->value.lval))){
- efree(query);
- RETURN_FALSE;
- }
-
- if (cursor->query) {
- efree(cursor->query);
- }
- cursor->query = query;
- cursor->fetched = 0;
- if(cursor->params && cursor->nparams > 0){
- zend_hash_destroy(cursor->params);
- efree(cursor->params);
- cursor->params = NULL;
- cursor->nparams = 0;
- }
-
- if (oparse(&cursor->cda, query, (sb4) - 1, defer, VERSION_7)) {
- php_error(E_WARNING, "Ora_Parse failed (%s)",
- ora_error(&cursor->cda));
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int ora_bind(int cursor, string php_variable_name, string sql_parameter_name, int length [, int type])
- Bind a PHP variable to an Oracle parameter */
-PHP_FUNCTION(ora_bind)
-{ /* cursor_ind, php_var_name, sql_var_name, data_len [, inout]*/
- /* inout: 0 = in/out, 1 = in, 2 = out */
- int argc;
- pval *argv[5];
- oraParam *newparam, *paramptr;
- oraCursor *cursor;
- char *paramname;
-
- argc = ARG_COUNT(ht);
- if (argc < 4 || argc > 5 || getParametersArray(ht, argc, argv) == FAILURE){
- WRONG_PARAM_COUNT;
- }
- convert_to_long(argv[0]);
- convert_to_string(argv[1]);
- convert_to_string(argv[2]);
- convert_to_long(argv[3]);
-
- cursor = ora_get_cursor(list, argv[0]->value.lval);
- if (cursor == NULL) {
- php_error(E_WARNING, "Invalid cursor index %d",
- argv[0]->value.lval);
- RETURN_FALSE;
- }
-
- if(cursor->params == NULL){
- cursor->params = (HashTable *)emalloc(sizeof(HashTable));
- if (!cursor->params ||
- zend_hash_init(cursor->params, 19, NULL,
- HASH_DTOR pval_ora_param_destructor, 0) == FAILURE) {
- php_error(E_ERROR, "Unable to initialize parameter list");
- RETURN_FALSE;
- }
- }
- if((newparam = (oraParam *)emalloc(sizeof(oraParam))) == NULL){
- php_error(E_WARNING, "Out of memory for parameter");
- RETURN_FALSE;
- }
-
- if((paramname = estrndup(argv[1]->value.str.val, argv[1]->value.str.len)) == NULL){
- php_error(E_WARNING, "Out of memory for parametername");
- efree(newparam);
- RETURN_FALSE;
- }
-
- if (zend_hash_add(cursor->params, paramname, argv[1]->value.str.len + 1, newparam, sizeof(oraParam), (void **)&paramptr) == FAILURE) {
- /* XXX zend_hash_destroy */
- efree(paramname);
- efree(newparam);
- php_error(E_ERROR, "Could not make parameter placeholder");
- RETURN_FALSE;
- }
-
- efree(newparam);
- efree(paramname);
-
- paramptr->progvl = argv[3]->value.lval + 1;
- if(argc > 4){
- convert_to_long(argv[4]);
- paramptr->inout = (short)argv[4]->value.lval;
- }else{
- paramptr->inout = 0;
- }
-
- if((paramptr->progv = (text *)emalloc(paramptr->progvl)) == NULL){
- php_error(E_WARNING, "Out of memory for parameter value");
- RETURN_FALSE;
- }
-
-/* XXX Maximum for progvl */
- paramptr->alen = paramptr->progvl;
-
- if (obndra(&cursor->cda,
- argv[2]->value.str.val,
- -1,
- (ub1 *)paramptr->progv,
- paramptr->progvl,
- SQLT_STR, /* ftype */
- -1, /* scale */
- 0/*&paramptr->ind*/, /* ind */
- &paramptr->alen, /* alen */
- 0 /*&paramptr->arcode*/,
- 0, /* maxsize */
- 0,
- 0,
- -1,
- -1)) {
- php_error(E_WARNING, "Ora_Bind failed (%s)",
- ora_error(&cursor->cda));
- RETURN_FALSE;
- }
-
- cursor->nparams++;
- RETURN_TRUE;
-}
-/* }}} */
-
-/*
- XXX Make return values compatible with old module ?
- */
-/* {{{ proto int ora_exec(int cursor)
- Execute a parsed statement */
-PHP_FUNCTION(ora_exec)
-{ /* cursor_index */
- pval *arg;
- oraCursor *cursor = NULL;
-
- if (getParameters(ht, 1, &arg) == FAILURE)
- WRONG_PARAM_COUNT;
-
- convert_to_long(arg);
-
- if ((cursor = ora_get_cursor(list, arg->value.lval)) == NULL) {
- RETURN_FALSE;
- }
-
- if (cursor->cda.ft == FT_SELECT) {
- if (ora_describe_define(cursor) < 0) {
- /* error message is given by ora_describe_define() */
- RETURN_FALSE;
- }
- }
-
- if(cursor->nparams > 0){
- if(!ora_set_param_values(cursor, 0)){
- RETURN_FALSE;
- }
- }
-
- if (oexec(&cursor->cda)) {
- php_error(E_WARNING, "Ora_Exec failed (%s)",
- ora_error(&cursor->cda));
- RETURN_FALSE;
- }
-
- if(cursor->nparams > 0){
- if(!ora_set_param_values(cursor, 1)){
- RETURN_FALSE;
- }
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int ora_numcols(int cursor)
- Returns the numbers of columns in a result */
-PHP_FUNCTION(ora_numcols)
-{ /* cursor_index */
- pval *arg;
- oraCursor *cursor = NULL;
-
- if (getParameters(ht, 1, &arg) == FAILURE)
- WRONG_PARAM_COUNT;
-
- convert_to_long(arg);
-
- if ((cursor = ora_get_cursor(list, arg->value.lval)) == NULL) {
- RETURN_FALSE;
- }
-
- RETURN_LONG(cursor->ncols);
-}
-/* }}} */
-
-/* {{{ proto int ora_numrows(int cursor)
- Returns the number of rows in a result */
-PHP_FUNCTION(ora_numrows)
-{ /* cursor_index */
- pval *arg;
- oraCursor *cursor = NULL;
-
- if(getParameters(ht, 1, &arg) == FAILURE)
- WRONG_PARAM_COUNT;
-
- convert_to_long(arg);
-
- if((cursor = ora_get_cursor(list, arg->value.lval)) == NULL) {
- RETURN_FALSE;
- }
-
- RETURN_LONG(cursor->cda.rpc);
-}
-/* }}} */
-
-/* prepares/executes/fetches 1st row if avail*/
-/* {{{ proto int ora_do(int connection, int cursor)
- Parse and execute a statement and fetch first result row */
-PHP_FUNCTION(ora_do)
-{
- pval *argv[2];
- oraConnection *conn = NULL;
- oraCursor *cursor = NULL;
- text *query;
-
- if (ARG_COUNT(ht) != 2 || getParametersArray(ht, 2, argv) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(argv[0]);
- convert_to_string(argv[1]);
-
- conn = ora_get_conn(list,plist, argv[0]->value.lval);
- if (conn == NULL) {
- RETURN_FALSE;
- }
-
- if ((cursor = (oraCursor *)emalloc(sizeof(oraCursor))) == NULL){
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
-
- memset(cursor, 0, sizeof(oraCursor));
-
- query = (text *) estrndup(argv[1]->value.str.val,argv[1]->value.str.len);
-
- if (query == NULL) {
- php_error(E_WARNING, "Invalid query in Ora_Do");
- RETURN_FALSE;
- }
-
- cursor->query = query;
-
- if (oopen(&cursor->cda, &conn->lda, (text *) 0, -1, -1, (text *) 0, -1)) {
- php_error(E_WARNING, "Unable to open new cursor (%s)",
- ora_error(&cursor->cda));
- efree(cursor);
- RETURN_FALSE;
- }
- cursor->open = 1;
- cursor->conn_ptr = conn;
- cursor->conn_id = argv[0]->value.lval;
-
- /* Prepare stmt */
-
- if (oparse(&cursor->cda, query, (sb4) - 1, 1, VERSION_7)){
- php_error(E_WARNING, "Ora_Do failed (%s)",
- ora_error(&cursor->cda));
- _close_oracur(cursor);
- RETURN_FALSE;
- }
-
- /* Execute stmt (and fetch 1st row for selects) */
- if (cursor->cda.ft == FT_SELECT) {
- if (ora_describe_define(cursor) < 0){
- /* error message is given by ora_describe_define() */
- _close_oracur(cursor);
- RETURN_FALSE;
- }
- if (oexfet(&cursor->cda, 1, 0, 0)) {
- php_error(E_WARNING, "Ora_Do failed (%s)",
- ora_error(&cursor->cda));
- _close_oracur(cursor);
- RETURN_FALSE;
- }
- cursor->fetched = 1;
- } else {
- if (oexec(&cursor->cda)) {
- php_error(E_WARNING, "Ora_Do failed (%s)",
- ora_error(&cursor->cda));
- _close_oracur(cursor);
- RETURN_FALSE;
- }
- }
-
- RETURN_RESOURCE(ora_add_cursor(list, cursor));
-}
-/* }}} */
-
-/* {{{ proto int ora_fetch(int cursor)
- Fetch a row of result data from a cursor */
-PHP_FUNCTION(ora_fetch)
-{ /* cursor_index */
- pval *arg;
- oraCursor *cursor;
-
- if (getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg);
-
- /* Find the cursor */
- if ((cursor = ora_get_cursor(list, arg->value.lval)) == NULL) {
- RETURN_FALSE;
- }
-
- if (cursor->ncols == 0){
- php_error(E_WARNING, "No tuples available on this cursor");
- RETURN_FALSE;
- }
-
- /* Get data from Oracle */
- if (ofetch(&cursor->cda)) {
- if (cursor->cda.rc != NO_DATA_FOUND) {
- php_error(E_WARNING, "Ora_Fetch failed (%s)",
- ora_error(&cursor->cda));
- }
- RETURN_FALSE;
- }
- cursor->fetched++;
- RETVAL_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int ora_fetch_into(int cursor, array result [ , int flags ])
- Fetch a row into the specified result array */
-PHP_FUNCTION(ora_fetch_into)
-{
- pval *arg1, *arr, *flg, *tmp;
- oraCursor *cursor;
- int i;
- int flags = 0;
-
- switch(ARG_COUNT(ht)){
- case 2:
- if (getParameters(ht, 2, &arg1, &arr) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
-
- case 3:
- if (getParameters(ht, 3, &arg1, &arr, &flg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(flg);
- flags = flg->value.lval;
- break;
-
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- if (!ParameterPassedByReference(ht, 2)){
- php_error(E_WARNING, "Array not passed by reference in call to ora_fetch_into()");
- RETURN_FALSE;
- }
-
- convert_to_long(arg1);
-
- /* Find the cursor */
- if ((cursor = ora_get_cursor(list, arg1->value.lval)) == NULL) {
- RETURN_FALSE;
- }
-
- if (cursor->ncols == 0){
- php_error(E_WARNING, "No tuples available on this cursor");
- RETURN_FALSE;
- }
-
- if (arr->type != IS_ARRAY){
- if (array_init(arr) == FAILURE){
- php_error(E_WARNING, "Can't convert to type Array");
- RETURN_FALSE;
- }
- }
-
- if (ofetch(&cursor->cda)) {
- if (cursor->cda.rc != NO_DATA_FOUND) {
- php_error(E_WARNING, "Ora_Fetch_Into failed (%s)",
- ora_error(&cursor->cda));
- }
- RETURN_FALSE;
- }
- cursor->fetched++;
-
-#if PHP_API_VERSION < 19990421
- tmp = emalloc(sizeof(pval));
-#endif
-
- for (i = 0; i < cursor->ncols; i++) {
-
- if (cursor->columns[i].col_retcode == 1405) {
- if (!(flags&ORA_FETCHINTO_NULLS)){
- continue; /* don't add anything for NULL columns, unless the calles wants it */
- } else {
- tmp->value.str.val = empty_string;
- tmp->value.str.len = 0;
- }
- } else if (cursor->columns[i].col_retcode != 0 &&
- cursor->columns[i].col_retcode != 1406) {
- /* So error fetching column. The most common is 1405, a NULL */
- /* was retreived. 1406 is ASCII or string buffer data was */
- /* truncated. The converted data from the database did not fit */
- /* into the buffer. Since we allocated the buffer to be large */
- /* enough, this should not occur. Anyway, we probably want to */
- /* return what we did get, in that case */
- RETURN_FALSE;
- } else {
-#if PHP_API_VERSION >= 19990421
- MAKE_STD_ZVAL(tmp);
-#endif
-
- tmp->type = IS_STRING;
- tmp->value.str.len = 0;
-
- switch(cursor->columns[i].dbtype) {
- case SQLT_LNG:
- case SQLT_LBI:
- {
- ub4 ret_len;
- int offset = cursor->columns[i].col_retlen;
- sb2 result;
-
- if (cursor->columns[i].col_retcode == 1406) { /* truncation -> get the rest! */
- while (1) {
- cursor->columns[i].buf = erealloc(cursor->columns[i].buf,offset + DB_SIZE + 1);
-
- if (! cursor->columns[i].buf) {
- offset = 0;
- break;
- }
-
- result = oflng(&cursor->cda,
- (sword)(i + 1),
- cursor->columns[i].buf + offset,
- DB_SIZE,
- 1,
- &ret_len,
- offset);
- if (result) {
- break;
- }
-
- if (ret_len <= 0) {
- break;
- }
-
- offset += ret_len;
- }
- }
- if (cursor->columns[i].buf && offset) {
- tmp->value.str.len = offset;
- } else {
- tmp->value.str.len = 0;
- }
- }
- break;
- default:
- tmp->value.str.len = min(cursor->columns[i].col_retlen,
- cursor->columns[i].dsize);
- break;
- }
- tmp->value.str.val = estrndup(cursor->columns[i].buf,tmp->value.str.len);
- }
-
- if (flags&ORA_FETCHINTO_ASSOC){
-#if PHP_API_VERSION >= 19990421
- zend_hash_update(arr->value.ht, cursor->columns[i].cbuf, cursor->columns[i].cbufl+1, (void *) &tmp, sizeof(pval*), NULL);
-#else
- zend_hash_update(arr->value.ht, cursor->columns[i].cbuf, cursor->columns[i].cbufl+1, (void *) tmp, sizeof(pval), NULL);
-#endif
- } else {
-#if PHP_API_VERSION >= 19990421
- zend_hash_index_update(arr->value.ht, i, (void *) &tmp, sizeof(pval*), NULL);
-#else
- zend_hash_index_update(arr->value.ht, i, (void *) tmp, sizeof(pval), NULL);
-#endif
- }
-
- }
-
-#if PHP_API_VERSION < 19990421
- efree(tmp);
-#endif
-
- RETURN_LONG(cursor->ncols);
-}
-/* }}} */
-
-/* {{{ proto string ora_columnname(int cursor, int column)
- Get the name of an Oracle result column */
-PHP_FUNCTION(ora_columnname)
-{ /* cursor_index, column_index */
- pval *argv[2];
- int cursor_ind;
- oraCursor *cursor = NULL;
-
- if (ARG_COUNT(ht) != 2 || getParametersArray(ht, 2, argv) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(argv[0]);
-
- cursor_ind = argv[0]->value.lval;
- /* Find the cursor */
- if ((cursor = ora_get_cursor(list, cursor_ind)) == NULL) {
- RETURN_FALSE;
- }
-
- convert_to_long(argv[1]);
-
- if (cursor->ncols == 0){
- php_error(E_WARNING, "No tuples available at this cursor index");
- RETURN_FALSE;
- }
-
- if (argv[1]->value.lval >= cursor->ncols){
- php_error(E_WARNING, "Column index larger than number of columns");
- RETURN_FALSE;
- }
-
- if (argv[1]->value.lval < 0){
- php_error(E_WARNING, "Column numbering starts at 0");
- RETURN_FALSE;
- }
-
- RETURN_STRINGL(cursor->columns[argv[1]->value.lval].cbuf,
- cursor->columns[argv[1]->value.lval].cbufl,1);
-}
-/* }}} */
-
-/* {{{ proto string ora_columntype(int cursor, int column)
- Get the type of an Oracle result column */
-PHP_FUNCTION(ora_columntype)
-{ /* cursor_index, column_index */
- pval *argv[2];
- int cursor_ind, colno;
- oraCursor *cursor = NULL;
-
- if (ARG_COUNT(ht) != 2 || getParametersArray(ht, 2, argv) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(argv[0]);
- /* don't convert the column index yet, it might be the column name */
-
- cursor_ind = argv[0]->value.lval;
- /* Find the cursor */
- if ((cursor = ora_get_cursor(list, cursor_ind)) == NULL) {
- RETURN_FALSE;
- }
-
- convert_to_long(argv[1]);
- colno = argv[1]->value.lval;
-
- if (cursor->ncols == 0){
- php_error(E_WARNING, "No tuples available at this cursor index");
- RETURN_FALSE;
- }
-
- if (colno >= cursor->ncols){
- php_error(E_WARNING, "Column index larger than number of columns");
- RETURN_FALSE;
- }
-
- if (colno < 0){
- php_error(E_WARNING, "Column numbering starts at 0");
- RETURN_FALSE;
- }
-
- switch (cursor->columns[colno].dbtype) {
- case SQLT_CHR:
- RETURN_STRINGL("VARCHAR2", 8, 1);
- case SQLT_VCS:
- case SQLT_AVC:
- RETURN_STRINGL("VARCHAR", 7, 1);
- case SQLT_STR:
- case SQLT_AFC:
- RETURN_STRINGL("CHAR", 4, 1);
- case SQLT_NUM: case SQLT_INT:
- case SQLT_FLT: case SQLT_UIN:
- RETURN_STRINGL("NUMBER", 6, 1);
- case SQLT_LNG:
- RETURN_STRINGL("LONG", 4, 1);
- case SQLT_LBI:
- RETURN_STRINGL("LONG RAW", 8, 1);
- case SQLT_RID:
- RETURN_STRINGL("ROWID", 5, 1);
- case SQLT_DAT:
- RETURN_STRINGL("DATE", 4, 1);
-#ifdef SQLT_CUR
- case SQLT_CUR:
- RETURN_STRINGL("CURSOR", 6, 1);
-#endif
- default:
- {
- char numbuf[21];
- snprintf(numbuf, 20, "UNKNOWN(%d)", cursor->columns[colno].dbtype);
- numbuf[20] = '\0';
- RETVAL_STRING(numbuf,1);
- }
- }
-}
-/* }}} */
-
-/* {{{ proto int ora_columnsize(int cursor, int column)
- Return the size of the column */
-PHP_FUNCTION(ora_columnsize)
-{ /* cursor_index, column_index */
- pval *argv[2];
- int cursor_ind;
- oraCursor *cursor = NULL;
-
- if (ARG_COUNT(ht) != 2 || getParametersArray(ht, 2, argv) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(argv[0]);
-
- cursor_ind = argv[0]->value.lval;
- /* Find the cursor */
- if ((cursor = ora_get_cursor(list, cursor_ind)) == NULL) {
- RETURN_FALSE;
- }
-
- convert_to_long(argv[1]);
-
- if (cursor->ncols == 0){
- php_error(E_WARNING, "No tuples available at this cursor index");
- RETURN_FALSE;
- }
-
- if (argv[1]->value.lval >= cursor->ncols){
- php_error(E_WARNING, "Column index larger than number of columns");
- RETURN_FALSE;
- }
-
- if (argv[1]->value.lval < 0){
- php_error(E_WARNING, "Column numbering starts at 0");
- RETURN_FALSE;
- }
-
- RETURN_LONG(cursor->columns[argv[1]->value.lval].dbsize);
-}
-/* }}} */
-
-/* {{{ proto mixed ora_getcolumn(int cursor, int column)
- Get data from a fetched row */
-PHP_FUNCTION(ora_getcolumn)
-{ /* cursor_index, column_index */
- pval *argv[2];
- int colno;
- oraCursor *cursor = NULL;
- oraColumn *column = NULL;
- sb2 type;
-
- if (ARG_COUNT(ht) != 2 || getParametersArray(ht, 2, argv) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(argv[0]);
-
- /* Find the cursor */
- if ((cursor = ora_get_cursor(list, argv[0]->value.lval)) == NULL) {
- RETURN_FALSE;
- }
-
- if (cursor->ncols == 0){
- php_error(E_WARNING, "No tuples available at this cursor index");
- RETURN_FALSE;
- }
-
- convert_to_long(argv[1]);
- colno = argv[1]->value.lval;
-
- if (colno >= cursor->ncols){
- php_error(E_WARNING, "Column index larger than number of columns");
- RETURN_FALSE;
- }
-
- if (colno < 0){
- php_error(E_WARNING, "Column numbering starts at 0");
- RETURN_FALSE;
- }
-
- if (cursor->fetched == 0){
- if (ofetch(&cursor->cda)) {
- if (cursor->cda.rc != NO_DATA_FOUND) {
- php_error(E_WARNING, "Ora_Fetch failed (%s)",
- ora_error(&cursor->cda));
- }
- RETURN_FALSE;
- }
- cursor->fetched++;
- }
-
- column = &cursor->columns[colno];
-
- type = column->dbtype;
-
- if (column->col_retcode != 0 && column->col_retcode != 1406) {
- /* So error fetching column. The most common is 1405, a NULL
- * was retreived. 1406 is ASCII or string buffer data was
- * truncated. The converted data from the database did not fit
- * into the buffer. Since we allocated the buffer to be large
- * enough, this should not occur. Anyway, we probably want to
- * return what we did get, in that case
- */
- RETURN_FALSE;
- } else {
- switch(type)
- {
- case SQLT_CHR:
- case SQLT_NUM:
- case SQLT_INT:
- case SQLT_FLT:
- case SQLT_STR:
- case SQLT_UIN:
- case SQLT_AFC:
- case SQLT_AVC:
- case SQLT_DAT:
- RETURN_STRINGL(column->buf, min(column->col_retlen, column->dsize), 1);
- case SQLT_LNG:
- case SQLT_LBI:
-#if 0
- {
- ub4 ret_len;
- /* XXX 64k max for LONG and LONG RAW */
- oflng(&cursor->cda, (sword)(colno + 1), column->buf, DB_SIZE, 1,
- &ret_len, 0);
- RETURN_STRINGL(column->buf, ret_len, 1);
- }
-#else
- {
- ub4 ret_len;
- int offset = column->col_retlen;
- sb2 result;
-
- if (column->col_retcode == 1406) { /* truncation -> get the rest! */
- while (1) {
- column->buf = erealloc(column->buf,offset + DB_SIZE + 1);
-
- if (! column->buf) {
- offset = 0;
- break;
- }
-
- result = oflng(&cursor->cda,
- (sword)(colno + 1),
- column->buf + offset,
- DB_SIZE,
- 1,
- &ret_len,
- offset);
- if (result) {
- break;
- }
-
- if (ret_len <= 0) {
- break;
- }
-
- offset += ret_len;
- }
- }
- if (column->buf && offset) {
- RETURN_STRINGL(column->buf, offset, 1);
- } else {
- RETURN_FALSE;
- }
- }
-#endif
- default:
- php_error(E_WARNING,
- "Ora_GetColumn found invalid type (%d)", type);
- RETURN_FALSE;
- }
- }
-}
-/* }}} */
-
-/* {{{ proto string ora_error(int cursor_or_connection)
- Get an Oracle error message */
-PHP_FUNCTION(ora_error)
-{
- pval *arg;
- oraCursor *cursor;
- oraConnection *conn;
-
- if (ARG_COUNT(ht) != 1 || getParametersArray(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg);
- if ((cursor = ora_get_cursor(list, arg->value.lval)) != NULL) {
- return_value->type = IS_STRING;
- return_value->value.str.val = estrdup(ora_error(&cursor->cda));
- return_value->value.str.len = strlen(return_value->value.str.val);
- } else if ((conn = ora_get_conn(list,plist, arg->value.lval)) != NULL) {
- return_value->type = IS_STRING;
- return_value->value.str.val = estrdup(ora_error(&conn->lda));
- return_value->value.str.len = strlen(return_value->value.str.val);
- }
-}
-/* }}} */
-
-/* {{{ proto int ora_errorcode(int cursor_or_connection)
- Get an Oracle error code */
-PHP_FUNCTION(ora_errorcode)
-{
- pval *arg;
- oraCursor *cursor;
- oraConnection *conn;
-
- if (ARG_COUNT(ht) != 1 || getParametersArray(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg);
- if ((cursor = ora_get_cursor(list, arg->value.lval)) != NULL) {
- RETURN_LONG(cursor->cda.rc);
- } else if ((conn = ora_get_conn(list,plist, arg->value.lval)) != NULL) {
- RETURN_LONG(conn->lda.rc);
- }
-}
-/* }}} */
-
-PHP_MINFO_FUNCTION(oracle)
-{
-#if !(WIN32|WINNT)
- php_printf("Oracle version: %s<br>\n"
- "Compile-time ORACLE_HOME: %s<br>\n"
- "Libraries used: %s",
- PHP_ORACLE_VERSION, PHP_ORACLE_HOME, PHP_ORACLE_LIBS);
-#endif
-}
-
-
-/*
-** Functions internal to this module.
-*/
-
-static oraConnection *
-ora_get_conn(HashTable *list,HashTable *plist,int ind)
-{
- oraConnection *conn = NULL;
- int type;
- ORALS_FETCH();
-
- conn = (oraConnection *)php3_list_find(ind, &type);
- if (conn && type == le_conn)
- return conn;
-
- conn = (oraConnection *)php3_plist_find(ind, &type);
- if (conn && type == le_pconn)
- return conn;
-
- php_error(E_WARNING,"Bad Oracle connection number (%d)", ind);
- return NULL;
-}
-
-int ora_add_cursor(HashTable *list, oraCursor *cursor)
-{
- ORALS_FETCH();
- return php3_list_insert(cursor, le_cursor);
-}
-
-static oraCursor *
-ora_get_cursor(HashTable *list, int ind)
-{
- oraCursor *cursor;
- oraConnection *db_conn;
- int type;
- ORALS_FETCH();
-
- cursor = php3_list_find(ind, &type);
- if (!cursor || type != le_cursor) {
- php_error(E_WARNING, "Invalid cursor index %d", ind);
- return NULL;
- }
-
- if (zend_hash_find(ORA(conns),(void*)&(cursor->conn_ptr),sizeof(void*),(void **)&db_conn) == FAILURE) {
- php_error(E_WARNING, "Connection already closed for cursor index %d", ind);
- return NULL;
- }
-
- return cursor;
-}
-
-void ora_del_cursor(HashTable *list, int ind)
-{
- oraCursor *cursor;
- int type;
- ORALS_FETCH();
-
- cursor = (oraCursor *) php3_list_find(ind, &type);
- if (!cursor || type != le_cursor) {
- php_error(E_WARNING,"Can't find cursor %d",ind);
- return;
- }
- php3_list_delete(ind);
-}
-
-static char *
-ora_error(Cda_Def * cda)
-{
- sword n, l;
- static text errmsg[ 512 ];
-
- n = oerhms(cda, cda->rc, errmsg, 400);
-
- /* remove the last newline */
- l = strlen(errmsg);
- if (l < 400 && errmsg[l - 1] == '\n') {
- errmsg[l - 1] = '\0';
- l--;
- }
- if (cda->fc > 0) {
- strcat(errmsg, " -- while processing OCI function ");
- strncat(errmsg, ora_func_tab[cda->fc], 75); /* 512 - 400 - 36 */
- }
- return (char *) errmsg;
-}
-
-static sword
-ora_describe_define(oraCursor * cursor)
-{
- long col = 0;
- int i;
- sb2 type;
- sb4 dbsize;
-
- if (cursor == NULL) {
- return -1;
- }
-
- if (cursor->columns) {
- for(i = 0; i < cursor->ncols; i++){
- if (cursor->columns[i].buf)
- efree(cursor->columns[i].buf);
- }
- efree(cursor->columns);
- }
-
- cursor->ncols = 0;
-
- while(1){
- if (odescr(&cursor->cda, (sword) cursor->ncols + 1, &dbsize, (sb2 *)0, (sb1 *)0,
- (sb4 *)0, (sb4 *)0, (sb2 *)0, (sb2 *)0, (sb2 *)0)){
- if (cursor->cda.rc == VAR_NOT_IN_LIST) {
- break;
- } else {
- php_error(E_WARNING, "%s", ora_error(&cursor->cda));
- cursor->ncols = 0;
- return -1;
- }
- }
- cursor->ncols++;
- }
-
- if (cursor->ncols > 0){
- cursor->columns = (oraColumn *) emalloc(sizeof(oraColumn) * cursor->ncols);
- if (cursor->columns == NULL){
- php_error(E_WARNING, "Out of memory");
- return -1;
- }
- }
-
- for(col = 0; col < cursor->ncols; col++){
- memset(&cursor->columns[col], 0, sizeof(oraColumn));
- cursor->columns[col].cbufl = ORANAMELEN;
-
- if (odescr(&cursor->cda, (sword)col + 1, &cursor->columns[col].dbsize,
- &cursor->columns[col].dbtype, &cursor->columns[col].cbuf[0],
- &cursor->columns[col].cbufl, &cursor->columns[col].dsize,
- &cursor->columns[col].prec, &cursor->columns[col].scale,
- &cursor->columns[col].nullok)) {
- if (cursor->cda.rc == VAR_NOT_IN_LIST) {
- break;
- } else {
- php_error(E_WARNING, "%s", ora_error(&cursor->cda));
- return -1;
- }
- }
-
- cursor->columns[col].cbuf[cursor->columns[col].cbufl] = '\0';
-
- switch (cursor->columns[col].dbtype) {
- case SQLT_LBI:
- cursor->columns[col].dsize = DB_SIZE;
- type = SQLT_LBI;
- break;
- case SQLT_LNG:
- cursor->columns[col].dsize = DB_SIZE;
- default:
- type = SQLT_STR;
- break;
- }
-
- if ((cursor->columns[col].buf = (ub1 *) emalloc(cursor->columns[col].dsize + 1)) == NULL){
- php_error(E_WARNING, "Out of memory");
- return -1;
- }
- /* Define an output variable for the column */
- if (odefin(&cursor->cda, (sword)col + 1, cursor->columns[col].buf,
- cursor->columns[col].dsize + 1, type, -1, &cursor->columns[col].indp,
- (text *) 0, -1, -1, &cursor->columns[col].col_retlen,
- &cursor->columns[col].col_retcode)) {
- php_error(E_WARNING, "%s", ora_error(&cursor->cda));
- return -1;
- }
- }
- return 1;
-}
-
-int ora_set_param_values(oraCursor *cursor, int isout)
-{
- char *paramname;
- oraParam *param;
-#if PHP_API_VERSION < 19990421
- pval *pdata;
-#else
- pval **pdata;
-#endif
- int i, len, plen;
-#if (WIN32|WINNT)
- /* see variables.c */
- HashTable *symbol_table=php3i_get_symbol_table();
-#endif
-
- ELS_FETCH();
-
- zend_hash_internal_pointer_reset(cursor->params);
-
- if(zend_hash_num_elements(cursor->params) != cursor->nparams){
- php_error(E_WARNING, "Mismatch in number of parameters");
- return 0;
- }
-
- for(i = 0; i < cursor->nparams; i++, zend_hash_move_forward(cursor->params)){
- if(zend_hash_get_current_key(cursor->params, &paramname, NULL) != HASH_KEY_IS_STRING){
- php_error(E_WARNING, "Can't get parameter name");
- return 0;
- }
-
- if(zend_hash_get_current_data(cursor->params, (void **)&param) == FAILURE){
- php_error(E_WARNING, "Can't get parameter data");
- efree(paramname);
- return 0;
- }
-
- if(isout){
-#if (WIN32|WINNT)
- /* see oracle_hack.c */
- {
- pval var;
- char *name=(paramname);
- var.value.str.val = estrdup(param->progv);
- var.value.str.len = strlen(param->progv);
- var.type = IS_STRING;
- zend_hash_update(symbol_table, name, strlen(name)+1, &var, sizeof(pval),NULL);
- }
-#else
- SET_VAR_STRINGL(paramname, estrdup(param->progv), strlen(param->progv));
-#endif
- efree(paramname);
- continue;
- }
-
- /* doing the in-loop */
-
- /* FIXME Globals don't work in extensions on windows, have to do something
- else here. See oracle_hack.c */
-#if (WIN32|WINNT)
- if(zend_hash_find(symbol_table, paramname, strlen(paramname) + 1, (void **)&pdata) == FAILURE){
- php_error(E_WARNING, "Can't find variable for parameter");
- efree(paramname);
- return 0;
- }
-#else
-
-#if PHP_API_VERSION < 19990421
- if(zend_hash_find(&GLOBAL(symbol_table), paramname, strlen(paramname) + 1, (void **)&pdata) == FAILURE){
-#else
- if(zend_hash_find(&EG(symbol_table), paramname, strlen(paramname) + 1, (void **)&pdata) == FAILURE){
-#endif
- php_error(E_WARNING, "Can't find variable for parameter");
- efree(paramname);
- return 0;
- }
-#endif
-
-#if PHP_API_VERSION < 19990421
- convert_to_string(pdata);
- plen = pdata->value.str.len;
-#else
- convert_to_string(*pdata);
- plen = (*pdata)->value.str.len;
-#endif
- if (param->progvl <= plen){
- php_error(E_NOTICE, "Input value will be truncated");
- }
-
- len = min(param->progvl - 1, plen);
-
-#if PHP_API_VERSION < 19990421
- strncpy(param->progv, pdata->value.str.val, len);
-#else
- strncpy(param->progv, (*pdata)->value.str.val, len);
-#endif
- param->progv[len] = '\0';
-
- efree(paramname);
- }
-
- return 1;
-}
-
-#endif /* HAVE_ORACLE */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/oracle/oracle_hack.c b/ext/oracle/oracle_hack.c
deleted file mode 100644
index b3ec71bc77..0000000000
--- a/ext/oracle/oracle_hack.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- This file needs to be compiled in with php on windows so that the
- oracle dll will work (and can be compiled). preferably, I would
- like to see if there is another way accomplish what needs to be
- done with the symbol_table in ora_set_param_values() in oracle.c.
- This is just a quick hack to get this out.
-
- Shane
-*/
-
-#include "php.h"
-
-PHPAPI HashTable *php3i_get_symbol_table(void) {
- TLS_VARS;
- return &GLOBAL(symbol_table);
-}
-
-/* This is becoming a general callback file, rather than an oracle hack
- * file. Seems we need the following now for xml. */
-
-PHPAPI HashTable *php3i_get_function_table(void) {
- TLS_VARS;
- return &GLOBAL(function_table);
-}
diff --git a/ext/oracle/php3_oracle.h b/ext/oracle/php3_oracle.h
deleted file mode 100644
index b0c113dd09..0000000000
--- a/ext/oracle/php3_oracle.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/* $Id$ */
-
-/* synced with oracle.h,v 1.40 1999/06/01 08:11:04 thies Exp $ */
-
-#ifndef _PHP3_ORACLE_H
-#define _PHP3_ORACLE_H
-
-#if HAVE_ORACLE
-
-#if (defined(__osf__) && defined(__alpha))
-# ifndef A_OSF
-# define A_OSF
-# endif
-# ifndef OSF1
-# define OSF1
-# endif
-# ifndef _INTRINSICS
-# define _INTRINSICS
-# endif
-#endif /* osf alpha */
-
-#include "oratypes.h"
-#include "ocidfn.h"
-#ifdef __STDC__
-#include "ociapr.h"
-#endif
-
-extern php3_module_entry oracle_module_entry;
-#define phpext_oracle_ptr &oracle_module_entry
-
-#ifdef ZTS
-#define ORALS_D php_ora_globals *ora_globals
-#define ORALS_DC , PSLS_D
-#define ORALS_C ora_globals
-#define ORALS_CC , ORALS_C
-#define ORA(v) (ora_globals->v)
-#define ORALS_FETCH() php_ora_globals *ora_globals = ts_resource(ora_globals_id)
-#else
-#define ORALS_D
-#define ORALS_DC
-#define ORALS_C
-#define ORALS_CC
-#define ORA(v) (ora_globals.v)
-#define ORALS_FETCH()
-#endif
-
-/* oparse flags */
-#define DEFER_PARSE 1
-#define NATIVE 1
-#define VERSION_7 2
-
-#define ORANUMWIDTH 38
-
-#if (defined(__osf__) && defined(__alpha)) || defined(CRAY) || defined(KSR)
-#define HDA_SIZE 512
-#else
-#define HDA_SIZE 256
-#endif
-
-#define ORAUIDLEN 32
-#define ORAPWLEN 32
-#define ORANAMELEN 32
-#define ORABUFLEN 2000
-
-/* Some Oracle error codes */
-#define VAR_NOT_IN_LIST 1007
-#define NO_DATA_FOUND 1403
-#define NULL_VALUE_RETURNED 1405
-
-/* Some SQL and ORA function codes */
-#define FT_INSERT 3
-#define FT_SELECT 4
-#define FT_UPDATE 5
-#define FT_DELETE 9
-
-#define FC_OOPEN 14
-
-typedef struct {
- int open;
- Lda_Def lda;
- ub1 hda[HDA_SIZE];
-} oraConnection;
-
-typedef struct oraColumn {
- sb4 dbsize;
- sb2 dbtype;
- text cbuf[ORANAMELEN+1];
- sb4 cbufl;
- sb4 dsize;
- sb2 prec;
- sb2 scale;
- sb2 nullok;
- ub1 *buf;
- sb2 indp;
- ub2 col_retlen, col_retcode;
-} oraColumn;
-
-typedef struct oraParam {
- text *progv;
- sword progvl;
- sb2 inout;
- ub2 alen;
-} oraParam;
-
-typedef struct oraCursor {
- int open;
- Cda_Def cda;
- text *query;
- HashTable *params;
- int nparams;
- oraColumn *columns;
- int ncols;
- int fetched;
- oraConnection *conn_ptr;
- int conn_id;
-} oraCursor;
-
-typedef struct {
- char *defDB;
- char *defUser;
- char *defPW;
- long allow_persistent;
- long max_persistent;
- long max_links;
- long num_persistent;
- long num_links;
- HashTable *conns;
-} php_ora_globals;
-
-#else
-
-#define oracle_module_ptr NULL
-
-#endif /* HAVE_ORACLE */
-
-#endif /* _PHP3_ORACLE_H */
-
-/*
- * Local Variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
-
-
-
-
diff --git a/ext/oracle/setup.stub b/ext/oracle/setup.stub
deleted file mode 100644
index d49e64d13a..0000000000
--- a/ext/oracle/setup.stub
+++ /dev/null
@@ -1,9 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-oracle 'Oracle support?' yesnodir \
- "no $oradir Oracle home" \
-' Whether to build PHP with Oracle support. Has been confirmed to\n
- work with Oracle versions 7.0 to 7.3. If you have not set up your\n
- Oracle environment, enter what $ORACLE_HOME is usually set to here.\n
- More info about Oracle can be found at http://www.oracle.com/.'
diff --git a/ext/pcre/Makefile.am b/ext/pcre/Makefile.am
deleted file mode 100644
index b6c926519f..0000000000
--- a/ext/pcre/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_pcre.a
-libphpext_pcre_a_SOURCES=php_pcre.c
-SUBDIRS=@PCRE_SUBDIR@
diff --git a/ext/pcre/config.h.stub b/ext/pcre/config.h.stub
deleted file mode 100644
index 149f740cc1..0000000000
--- a/ext/pcre/config.h.stub
+++ /dev/null
@@ -1,4 +0,0 @@
-/* define if you want to use the PCRE extension */
-#define HAVE_PCRE 0
-
-#define HAVE_BUNDLED_PCRE 0
diff --git a/ext/pcre/config.m4 b/ext/pcre/config.m4
deleted file mode 100644
index 9ee60a9305..0000000000
--- a/ext/pcre/config.m4
+++ /dev/null
@@ -1,58 +0,0 @@
-dnl $Id$
-dnl config.m4 for extension pcre
-
-dnl By default we'll compile and link against the bundled PCRE library
-dnl if DIR is supplied, we'll use that for linking
-
-AC_MSG_CHECKING(whether to include PCRE support)
-AC_ARG_WITH(pcre-regex,
-[ --without-pcre-regex Do not include Perl Compatible Regular Expressions
- support. Use --with-pcre-regex=DIR to specify DIR
- where PCRE's include and library files are located],
-[
- case "$withval" in
- no)
- AC_MSG_RESULT(no)
- ;;
- yes)
- EXTRA_LIBS="-L$abs_builddir/ext/pcre/pcrelib -lpcre $EXTRA_LIBS"
- PCRE_SUBDIR="pcrelib"
- AC_DEFINE(HAVE_BUNDLED_PCRE, 1)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(pcre)
- ;;
- *)
- if test -f $withval/pcre.h ; then
- changequote({,})
- pcre_major=`grep PCRE_MAJOR $withval/pcre.h | sed -e 's/[^0-9]//g'`
- pcre_minor=`grep PCRE_MINOR $withval/pcre.h | sed -e 's/[^0-9]//g'`
- changequote([,])
- pcre_version=$pcre_major$pcre_minor
- if test "$pcre_version" -ge 208; then
- AC_ADD_INCLUDE($withval)
- else
- AC_MSG_ERROR(PCRE extension requires PCRE library version >= 2.08)
- fi
- else
- AC_MSG_ERROR(Could not find pcre.h in $withval)
- fi
-
- if test -f $withval/libpcre.a ; then
- AC_ADD_LIBRARY_WITH_PATH(pcre, $withval)
- else
- AC_MSG_ERROR(Could not find libpcre.a in $withval)
- fi
-
- AC_DEFINE(HAVE_PCRE, 1)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(pcre)
- ;;
- esac
-],[
- EXTRA_LIBS="-L$abs_builddir/ext/pcre/pcrelib -lpcre $EXTRA_LIBS"
- PCRE_SUBDIR="pcrelib"
- AC_DEFINE(HAVE_BUNDLED_PCRE, 1)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(pcre)
-])
-AC_SUBST(PCRE_SUBDIR)
diff --git a/ext/pcre/config0.m4 b/ext/pcre/config0.m4
deleted file mode 100644
index 9ee60a9305..0000000000
--- a/ext/pcre/config0.m4
+++ /dev/null
@@ -1,58 +0,0 @@
-dnl $Id$
-dnl config.m4 for extension pcre
-
-dnl By default we'll compile and link against the bundled PCRE library
-dnl if DIR is supplied, we'll use that for linking
-
-AC_MSG_CHECKING(whether to include PCRE support)
-AC_ARG_WITH(pcre-regex,
-[ --without-pcre-regex Do not include Perl Compatible Regular Expressions
- support. Use --with-pcre-regex=DIR to specify DIR
- where PCRE's include and library files are located],
-[
- case "$withval" in
- no)
- AC_MSG_RESULT(no)
- ;;
- yes)
- EXTRA_LIBS="-L$abs_builddir/ext/pcre/pcrelib -lpcre $EXTRA_LIBS"
- PCRE_SUBDIR="pcrelib"
- AC_DEFINE(HAVE_BUNDLED_PCRE, 1)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(pcre)
- ;;
- *)
- if test -f $withval/pcre.h ; then
- changequote({,})
- pcre_major=`grep PCRE_MAJOR $withval/pcre.h | sed -e 's/[^0-9]//g'`
- pcre_minor=`grep PCRE_MINOR $withval/pcre.h | sed -e 's/[^0-9]//g'`
- changequote([,])
- pcre_version=$pcre_major$pcre_minor
- if test "$pcre_version" -ge 208; then
- AC_ADD_INCLUDE($withval)
- else
- AC_MSG_ERROR(PCRE extension requires PCRE library version >= 2.08)
- fi
- else
- AC_MSG_ERROR(Could not find pcre.h in $withval)
- fi
-
- if test -f $withval/libpcre.a ; then
- AC_ADD_LIBRARY_WITH_PATH(pcre, $withval)
- else
- AC_MSG_ERROR(Could not find libpcre.a in $withval)
- fi
-
- AC_DEFINE(HAVE_PCRE, 1)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(pcre)
- ;;
- esac
-],[
- EXTRA_LIBS="-L$abs_builddir/ext/pcre/pcrelib -lpcre $EXTRA_LIBS"
- PCRE_SUBDIR="pcrelib"
- AC_DEFINE(HAVE_BUNDLED_PCRE, 1)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(pcre)
-])
-AC_SUBST(PCRE_SUBDIR)
diff --git a/ext/pcre/pcrelib/ChangeLog b/ext/pcre/pcrelib/ChangeLog
deleted file mode 100644
index cad637d959..0000000000
--- a/ext/pcre/pcrelib/ChangeLog
+++ /dev/null
@@ -1,519 +0,0 @@
-ChangeLog for PCRE
-------------------
-
-
-Version 2.08 31-Aug-99
-----------------------
-
-1. When startoffset was not zero and the pattern began with ".*", PCRE was not
-trying to match at the startoffset position, but instead was moving forward to
-the next newline as if a previous match had failed.
-
-2. pcretest was not making use of PCRE_NOTEMPTY when repeating for /g and /G,
-and could get into a loop if a null string was matched other than at the start
-of the subject.
-
-3. Added definitions of PCRE_MAJOR and PCRE_MINOR to pcre.h so the version can
-be distinguished at compile time, and for completeness also added PCRE_DATE.
-
-5. Added Paul Sokolovsky's minor changes to make it easy to compile a Win32 DLL
-in GnuWin32 environments.
-
-
-Version 2.07 29-Jul-99
-----------------------
-
-1. The documentation is now supplied in plain text form and HTML as well as in
-the form of man page sources.
-
-2. C++ compilers don't like assigning (void *) values to other pointer types.
-In particular this affects malloc(). Although there is no problem in Standard
-C, I've put in casts to keep C++ compilers happy.
-
-3. Typo on pcretest.c; a cast of (unsigned char *) in the POSIX regexec() call
-should be (const char *).
-
-4. If NOPOSIX is defined, pcretest.c compiles without POSIX support. This may
-be useful for non-Unix systems who don't want to bother with the POSIX stuff.
-However, I haven't made this a standard facility. The documentation doesn't
-mention it, and the Makefile doesn't support it.
-
-5. The Makefile now contains an "install" target, with editable destinations at
-the top of the file. The pcretest program is not installed.
-
-6. pgrep -V now gives the PCRE version number and date.
-
-7. Fixed bug: a zero repetition after a literal string (e.g. /abcde{0}/) was
-causing the entire string to be ignored, instead of just the last character.
-
-8. If a pattern like /"([^\\"]+|\\.)*"/ is applied in the normal way to a
-non-matching string, it can take a very, very long time, even for strings of
-quite modest length, because of the nested recursion. PCRE now does better in
-some of these cases. It does this by remembering the last required literal
-character in the pattern, and pre-searching the subject to ensure it is present
-before running the real match. In other words, it applies a heuristic to detect
-some types of certain failure quickly, and in the above example, if presented
-with a string that has no trailing " it gives "no match" very quickly.
-
-9. A new runtime option PCRE_NOTEMPTY causes null string matches to be ignored;
-other alternatives are tried instead.
-
-
-Version 2.06 09-Jun-99
-----------------------
-
-1. Change pcretest's output for amount of store used to show just the code
-space, because the remainder (the data block) varies in size between 32-bit and
-64-bit systems.
-
-2. Added an extra argument to pcre_exec() to supply an offset in the subject to
-start matching at. This allows lookbehinds to work when searching for multiple
-occurrences in a string.
-
-3. Added additional options to pcretest for testing multiple occurrences:
-
- /+ outputs the rest of the string that follows a match
- /g loops for multiple occurrences, using the new startoffset argument
- /G loops for multiple occurrences by passing an incremented pointer
-
-4. PCRE wasn't doing the "first character" optimization for patterns starting
-with \b or \B, though it was doing it for other lookbehind assertions. That is,
-it wasn't noticing that a match for a pattern such as /\bxyz/ has to start with
-the letter 'x'. On long subject strings, this gives a significant speed-up.
-
-
-Version 2.05 21-Apr-99
-----------------------
-
-1. Changed the type of magic_number from int to long int so that it works
-properly on 16-bit systems.
-
-2. Fixed a bug which caused patterns starting with .* not to work correctly
-when the subject string contained newline characters. PCRE was assuming
-anchoring for such patterns in all cases, which is not correct because .* will
-not pass a newline unless PCRE_DOTALL is set. It now assumes anchoring only if
-DOTALL is set at top level; otherwise it knows that patterns starting with .*
-must be retried after every newline in the subject.
-
-
-Version 2.04 18-Feb-99
-----------------------
-
-1. For parenthesized subpatterns with repeats whose minimum was zero, the
-computation of the store needed to hold the pattern was incorrect (too large).
-If such patterns were nested a few deep, this could multiply and become a real
-problem.
-
-2. Added /M option to pcretest to show the memory requirement of a specific
-pattern. Made -m a synonym of -s (which does this globally) for compatibility.
-
-3. Subpatterns of the form (regex){n,m} (i.e. limited maximum) were being
-compiled in such a way that the backtracking after subsequent failure was
-pessimal. Something like (a){0,3} was compiled as (a)?(a)?(a)? instead of
-((a)((a)(a)?)?)? with disastrous performance if the maximum was of any size.
-
-
-Version 2.03 02-Feb-99
-----------------------
-
-1. Fixed typo and small mistake in man page.
-
-2. Added 4th condition (GPL supersedes if conflict) and created separate
-LICENCE file containing the conditions.
-
-3. Updated pcretest so that patterns such as /abc\/def/ work like they do in
-Perl, that is the internal \ allows the delimiter to be included in the
-pattern. Locked out the use of \ as a delimiter. If \ immediately follows
-the final delimiter, add \ to the end of the pattern (to test the error).
-
-4. Added the convenience functions for extracting substrings after a successful
-match. Updated pcretest to make it able to test these functions.
-
-
-Version 2.02 14-Jan-99
-----------------------
-
-1. Initialized the working variables associated with each extraction so that
-their saving and restoring doesn't refer to uninitialized store.
-
-2. Put dummy code into study.c in order to trick the optimizer of the IBM C
-compiler for OS/2 into generating correct code. Apparently IBM isn't going to
-fix the problem.
-
-3. Pcretest: the timing code wasn't using LOOPREPEAT for timing execution
-calls, and wasn't printing the correct value for compiling calls. Increased the
-default value of LOOPREPEAT, and the number of significant figures in the
-times.
-
-4. Changed "/bin/rm" in the Makefile to "-rm" so it works on Windows NT.
-
-5. Renamed "deftables" as "dftables" to get it down to 8 characters, to avoid
-a building problem on Windows NT with a FAT file system.
-
-
-Version 2.01 21-Oct-98
-----------------------
-
-1. Changed the API for pcre_compile() to allow for the provision of a pointer
-to character tables built by pcre_maketables() in the current locale. If NULL
-is passed, the default tables are used.
-
-
-Version 2.00 24-Sep-98
-----------------------
-
-1. Since the (>?) facility is in Perl 5.005, don't require PCRE_EXTRA to enable
-it any more.
-
-2. Allow quantification of (?>) groups, and make it work correctly.
-
-3. The first character computation wasn't working for (?>) groups.
-
-4. Correct the implementation of \Z (it is permitted to match on the \n at the
-end of the subject) and add 5.005's \z, which really does match only at the
-very end of the subject.
-
-5. Remove the \X "cut" facility; Perl doesn't have it, and (?> is neater.
-
-6. Remove the ability to specify CASELESS, MULTILINE, DOTALL, and
-DOLLAR_END_ONLY at runtime, to make it possible to implement the Perl 5.005
-localized options. All options to pcre_study() were also removed.
-
-7. Add other new features from 5.005:
-
- $(?<= positive lookbehind
- $(?<! negative lookbehind
- (?imsx-imsx) added the unsetting capability
- such a setting is global if at outer level; local otherwise
- (?imsx-imsx:) non-capturing groups with option setting
- (?(cond)re|re) conditional pattern matching
-
- A backreference to itself in a repeated group matches the previous
- captured string.
-
-8. General tidying up of studying (both automatic and via "study")
-consequential on the addition of new assertions.
-
-9. As in 5.005, unlimited repeated groups that could match an empty substring
-are no longer faulted at compile time. Instead, the loop is forcibly broken at
-runtime if any iteration does actually match an empty substring.
-
-10. Include the RunTest script in the distribution.
-
-11. Added tests from the Perl 5.005_02 distribution. This showed up a few
-discrepancies, some of which were old and were also with respect to 5.004. They
-have now been fixed.
-
-
-Version 1.09 28-Apr-98
-----------------------
-
-1. A negated single character class followed by a quantifier with a minimum
-value of one (e.g. [^x]{1,6} ) was not compiled correctly. This could lead to
-program crashes, or just wrong answers. This did not apply to negated classes
-containing more than one character, or to minima other than one.
-
-
-Version 1.08 27-Mar-98
-----------------------
-
-1. Add PCRE_UNGREEDY to invert the greediness of quantifiers.
-
-2. Add (?U) and (?X) to set PCRE_UNGREEDY and PCRE_EXTRA respectively. The
-latter must appear before anything that relies on it in the pattern.
-
-
-Version 1.07 16-Feb-98
-----------------------
-
-1. A pattern such as /((a)*)*/ was not being diagnosed as in error (unlimited
-repeat of a potentially empty string).
-
-
-Version 1.06 23-Jan-98
-----------------------
-
-1. Added Markus Oberhumer's little patches for C++.
-
-2. Literal strings longer than 255 characters were broken.
-
-
-Version 1.05 23-Dec-97
-----------------------
-
-1. Negated character classes containing more than one character were failing if
-PCRE_CASELESS was set at run time.
-
-
-Version 1.04 19-Dec-97
-----------------------
-
-1. Corrected the man page, where some "const" qualifiers had been omitted.
-
-2. Made debugging output print "{0,xxx}" instead of just "{,xxx}" to agree with
-input syntax.
-
-3. Fixed memory leak which occurred when a regex with back references was
-matched with an offsets vector that wasn't big enough. The temporary memory
-that is used in this case wasn't being freed if the match failed.
-
-4. Tidied pcretest to ensure it frees memory that it gets.
-
-5. Temporary memory was being obtained in the case where the passed offsets
-vector was exactly big enough.
-
-6. Corrected definition of offsetof() from change 5 below.
-
-7. I had screwed up change 6 below and broken the rules for the use of
-setjmp(). Now fixed.
-
-
-Version 1.03 18-Dec-97
-----------------------
-
-1. A erroneous regex with a missing opening parenthesis was correctly
-diagnosed, but PCRE attempted to access brastack[-1], which could cause crashes
-on some systems.
-
-2. Replaced offsetof(real_pcre, code) by offsetof(real_pcre, code[0]) because
-it was reported that one broken compiler failed on the former because "code" is
-also an independent variable.
-
-3. The erroneous regex a[]b caused an array overrun reference.
-
-4. A regex ending with a one-character negative class (e.g. /[^k]$/) did not
-fail on data ending with that character. (It was going on too far, and checking
-the next character, typically a binary zero.) This was specific to the
-optimized code for single-character negative classes.
-
-5. Added a contributed patch from the TIN world which does the following:
-
- + Add an undef for memmove, in case the the system defines a macro for it.
-
- + Add a definition of offsetof(), in case there isn't one. (I don't know
- the reason behind this - offsetof() is part of the ANSI standard - but
- it does no harm).
-
- + Reduce the ifdef's in pcre.c using macro DPRINTF, thereby eliminating
- most of the places where whitespace preceded '#'. I have given up and
- allowed the remaining 2 cases to be at the margin.
-
- + Rename some variables in pcre to eliminate shadowing. This seems very
- pedantic, but does no harm, of course.
-
-6. Moved the call to setjmp() into its own function, to get rid of warnings
-from gcc -Wall, and avoided calling it at all unless PCRE_EXTRA is used.
-
-7. Constructs such as \d{8,} were compiling into the equivalent of
-\d{8}\d{0,65527} instead of \d{8}\d* which didn't make much difference to the
-outcome, but in this particular case used more store than had been allocated,
-which caused the bug to be discovered because it threw up an internal error.
-
-8. The debugging code in both pcre and pcretest for outputting the compiled
-form of a regex was going wrong in the case of back references followed by
-curly-bracketed repeats.
-
-
-Version 1.02 12-Dec-97
-----------------------
-
-1. Typos in pcre.3 and comments in the source fixed.
-
-2. Applied a contributed patch to get rid of places where it used to remove
-'const' from variables, and fixed some signed/unsigned and uninitialized
-variable warnings.
-
-3. Added the "runtest" target to Makefile.
-
-4. Set default compiler flag to -O2 rather than just -O.
-
-
-Version 1.01 19-Nov-97
-----------------------
-
-1. PCRE was failing to diagnose unlimited repeat of empty string for patterns
-like /([ab]*)*/, that is, for classes with more than one character in them.
-
-2. Likewise, it wasn't diagnosing patterns with "once-only" subpatterns, such
-as /((?>a*))*/ (a PCRE_EXTRA facility).
-
-
-Version 1.00 18-Nov-97
-----------------------
-
-1. Added compile-time macros to support systems such as SunOS4 which don't have
-memmove() or strerror() but have other things that can be used instead.
-
-2. Arranged that "make clean" removes the executables.
-
-
-Version 0.99 27-Oct-97
-----------------------
-
-1. Fixed bug in code for optimizing classes with only one character. It was
-initializing a 32-byte map regardless, which could cause it to run off the end
-of the memory it had got.
-
-2. Added, conditional on PCRE_EXTRA, the proposed (?>REGEX) construction.
-
-
-Version 0.98 22-Oct-97
-----------------------
-
-1. Fixed bug in code for handling temporary memory usage when there are more
-back references than supplied space in the ovector. This could cause segfaults.
-
-
-Version 0.97 21-Oct-97
-----------------------
-
-1. Added the \X "cut" facility, conditional on PCRE_EXTRA.
-
-2. Optimized negated single characters not to use a bit map.
-
-3. Brought error texts together as macro definitions; clarified some of them;
-fixed one that was wrong - it said "range out of order" when it meant "invalid
-escape sequence".
-
-4. Changed some char * arguments to const char *.
-
-5. Added PCRE_NOTBOL and PCRE_NOTEOL (from POSIX).
-
-6. Added the POSIX-style API wrapper in pcreposix.a and testing facilities in
-pcretest.
-
-
-Version 0.96 16-Oct-97
-----------------------
-
-1. Added a simple "pgrep" utility to the distribution.
-
-2. Fixed an incompatibility with Perl: "{" is now treated as a normal character
-unless it appears in one of the precise forms "{ddd}", "{ddd,}", or "{ddd,ddd}"
-where "ddd" means "one or more decimal digits".
-
-3. Fixed serious bug. If a pattern had a back reference, but the call to
-pcre_exec() didn't supply a large enough ovector to record the related
-identifying subpattern, the match always failed. PCRE now remembers the number
-of the largest back reference, and gets some temporary memory in which to save
-the offsets during matching if necessary, in order to ensure that
-backreferences always work.
-
-4. Increased the compatibility with Perl in a number of ways:
-
- (a) . no longer matches \n by default; an option PCRE_DOTALL is provided
- to request this handling. The option can be set at compile or exec time.
-
- (b) $ matches before a terminating newline by default; an option
- PCRE_DOLLAR_ENDONLY is provided to override this (but not in multiline
- mode). The option can be set at compile or exec time.
-
- (c) The handling of \ followed by a digit other than 0 is now supposed to be
- the same as Perl's. If the decimal number it represents is less than 10
- or there aren't that many previous left capturing parentheses, an octal
- escape is read. Inside a character class, it's always an octal escape,
- even if it is a single digit.
-
- (d) An escaped but undefined alphabetic character is taken as a literal,
- unless PCRE_EXTRA is set. Currently this just reserves the remaining
- escapes.
-
- (e) {0} is now permitted. (The previous item is removed from the compiled
- pattern).
-
-5. Changed all the names of code files so that the basic parts are no longer
-than 10 characters, and abolished the teeny "globals.c" file.
-
-6. Changed the handling of character classes; they are now done with a 32-byte
-bit map always.
-
-7. Added the -d and /D options to pcretest to make it possible to look at the
-internals of compilation without having to recompile pcre.
-
-
-Version 0.95 23-Sep-97
-----------------------
-
-1. Fixed bug in pre-pass concerning escaped "normal" characters such as \x5c or
-\x20 at the start of a run of normal characters. These were being treated as
-real characters, instead of the source characters being re-checked.
-
-
-Version 0.94 18-Sep-97
-----------------------
-
-1. The functions are now thread-safe, with the caveat that the global variables
-containing pointers to malloc() and free() or alternative functions are the
-same for all threads.
-
-2. Get pcre_study() to generate a bitmap of initial characters for non-
-anchored patterns when this is possible, and use it if passed to pcre_exec().
-
-
-Version 0.93 15-Sep-97
-----------------------
-
-1. /(b)|(:+)/ was computing an incorrect first character.
-
-2. Add pcre_study() to the API and the passing of pcre_extra to pcre_exec(),
-but not actually doing anything yet.
-
-3. Treat "-" characters in classes that cannot be part of ranges as literals,
-as Perl does (e.g. [-az] or [az-]).
-
-4. Set the anchored flag if a branch starts with .* or .*? because that tests
-all possible positions.
-
-5. Split up into different modules to avoid including unneeded functions in a
-compiled binary. However, compile and exec are still in one module. The "study"
-function is split off.
-
-6. The character tables are now in a separate module whose source is generated
-by an auxiliary program - but can then be edited by hand if required. There are
-now no calls to isalnum(), isspace(), isdigit(), isxdigit(), tolower() or
-toupper() in the code.
-
-7. Turn the malloc/free funtions variables into pcre_malloc and pcre_free and
-make them global. Abolish the function for setting them, as the caller can now
-set them directly.
-
-
-Version 0.92 11-Sep-97
-----------------------
-
-1. A repeat with a fixed maximum and a minimum of 1 for an ordinary character
-(e.g. /a{1,3}/) was broken (I mis-optimized it).
-
-2. Caseless matching was not working in character classes if the characters in
-the pattern were in upper case.
-
-3. Make ranges like [W-c] work in the same way as Perl for caseless matching.
-
-4. Make PCRE_ANCHORED public and accept as a compile option.
-
-5. Add an options word to pcre_exec() and accept PCRE_ANCHORED and
-PCRE_CASELESS at run time. Add escapes \A and \I to pcretest to cause it to
-pass them.
-
-6. Give an error if bad option bits passed at compile or run time.
-
-7. Add PCRE_MULTILINE at compile and exec time, and (?m) as well. Add \M to
-pcretest to cause it to pass that flag.
-
-8. Add pcre_info(), to get the number of identifying subpatterns, the stored
-options, and the first character, if set.
-
-9. Recognize C+ or C{n,m} where n >= 1 as providing a fixed starting character.
-
-
-Version 0.91 10-Sep-97
-----------------------
-
-1. PCRE was failing to diagnose unlimited repeats of subpatterns that could
-match the empty string as in /(a*)*/. It was looping and ultimately crashing.
-
-2. PCRE was looping on encountering an indefinitely repeated back reference to
-a subpattern that had matched an empty string, e.g. /(a|)\1*/. It now does what
-Perl does - treats the match as successful.
-
-****
diff --git a/ext/pcre/pcrelib/LICENCE b/ext/pcre/pcrelib/LICENCE
deleted file mode 100644
index 246515ae75..0000000000
--- a/ext/pcre/pcrelib/LICENCE
+++ /dev/null
@@ -1,32 +0,0 @@
-PCRE LICENCE
-------------
-
-PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
-Written by: Philip Hazel <ph10@cam.ac.uk>
-
-University of Cambridge Computing Service,
-Cambridge, England. Phone: +44 1223 334714.
-
-Copyright (c) 1997-1999 University of Cambridge
-
-Permission is granted to anyone to use this software for any purpose on any
-computer system, and to redistribute it freely, subject to the following
-restrictions:
-
-1. This software 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.
-
-2. The origin of this software must not be misrepresented, either by
- explicit claim or by omission.
-
-3. Altered versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
-
-4. If PCRE is embedded in any software that is released under the GNU
- General Purpose Licence (GPL), then the terms of that licence shall
- supersede any condition above with which it is incompatible.
-
-End
diff --git a/ext/pcre/pcrelib/Makefile.am b/ext/pcre/pcrelib/Makefile.am
deleted file mode 100644
index 8f7cad1372..0000000000
--- a/ext/pcre/pcrelib/Makefile.am
+++ /dev/null
@@ -1,2 +0,0 @@
-noinst_LIBRARIES = libpcre.a
-libpcre_a_SOURCES = maketables.c get.c study.c pcre.c
diff --git a/ext/pcre/pcrelib/README b/ext/pcre/pcrelib/README
deleted file mode 100644
index c9696bab48..0000000000
--- a/ext/pcre/pcrelib/README
+++ /dev/null
@@ -1,416 +0,0 @@
-README file for PCRE (Perl-compatible regular expressions)
-----------------------------------------------------------
-
-*******************************************************************************
-* IMPORTANT FOR THOSE UPGRADING FROM VERSIONS BEFORE 2.00 *
-* *
-* Please note that there has been a change in the API such that a larger *
-* ovector is required at matching time, to provide some additional workspace. *
-* The new man page has details. This change was necessary in order to support *
-* some of the new functionality in Perl 5.005. *
-* *
-* IMPORTANT FOR THOSE UPGRADING FROM VERSION 2.00 *
-* *
-* Another (I hope this is the last!) change has been made to the API for the *
-* pcre_compile() function. An additional argument has been added to make it *
-* possible to pass over a pointer to character tables built in the current *
-* locale by pcre_maketables(). To use the default tables, this new arguement *
-* should be passed as NULL. *
-* *
-* IMPORTANT FOR THOSE UPGRADING FROM VERSION 2.05 *
-* *
-* Yet another (and again I hope this really is the last) change has been made *
-* to the API for the pcre_exec() function. An additional argument has been *
-* added to make it possible to start the match other than at the start of the *
-* subject string. This is important if there are lookbehinds. The new man *
-* page has the details, but you just want to convert existing programs, all *
-* you need to do is to stick in a new fifth argument to pcre_exec(), with a *
-* value of zero. For example, change *
-* *
-* pcre_exec(pattern, extra, subject, length, options, ovec, ovecsize) *
-* to *
-* pcre_exec(pattern, extra, subject, length, 0, options, ovec, ovecsize) *
-*******************************************************************************
-
-
-The distribution should contain the following files:
-
- ChangeLog log of changes to the code
- LICENCE conditions for the use of PCRE
- Makefile for building PCRE in Unix systems
- README this file
- RunTest a Unix shell script for running tests
- Tech.Notes notes on the encoding
- pcre.3 man page source for the functions
- pcre.3.txt plain text version
- pcre.3.html HTML version
- pcreposix.3 man page source for the POSIX wrapper API
- pcreposix.3.txt plain text version
- pcreposix.3.HTML HTML version
- dftables.c auxiliary program for building chartables.c
- get.c )
- maketables.c )
- study.c ) source of
- pcre.c ) the functions
- pcreposix.c )
- pcre.h header for the external API
- pcreposix.h header for the external POSIX wrapper API
- internal.h header for internal use
- pcretest.c test program
- pgrep.1 man page source for pgrep
- pgrep.1.txt plain text version
- pgrep.1.HTML HTML version
- pgrep.c source of a grep utility that uses PCRE
- perltest Perl test program
- testinput1 test data, compatible with Perl 5.004 and 5.005
- testinput2 test data for error messages and non-Perl things
- testinput3 test data, compatible with Perl 5.005
- testinput4 test data for locale-specific tests
- testoutput1 test results corresponding to testinput1
- testoutput2 test results corresponding to testinput2
- testoutput3 test results corresponding to testinput3
- testoutput4 test results corresponding to testinput4
- dll.mk for Win32 DLL
- pcre.def ditto
-
-To build PCRE on a Unix system, first edit Makefile for your system. It is a
-fairly simple make file, and there are some comments near the top, after the
-text "On a Unix system". Then run "make". It builds two libraries called
-libpcre.a and libpcreposix.a, a test program called pcretest, and the pgrep
-command. You can use "make install" to copy these, and the public header file
-pcre.h, to appropriate live directories on your system. These installation
-directories are defined at the top of the Makefile, and you should edit them if
-necessary.
-
-For a non-Unix system, read the comments at the top of Makefile, which give
-some hints on what needs to be done. PCRE has been compiled on Windows systems
-and on Macintoshes, but I don't know the details as I don't use those systems.
-It should be straightforward to build PCRE on any system that has a Standard C
-compiler.
-
-Some help in building a Win32 DLL of PCRE in GnuWin32 environments was
-contributed by Paul.Sokolovsky@technologist.com. These environments are
-Mingw32 (http://www.xraylith.wisc.edu/~khan/software/gnu-win32/) and
-CygWin (http://sourceware.cygnus.com/cygwin/). Paul comments:
-
- For CygWin, set CFLAGS=-mno-cygwin, and do 'make dll'. You'll get
- pcre.dll (containing pcreposix also), libpcre.dll.a, and dynamically
- linked pgrep and pcretest. If you have /bin/sh, run RunTest (three
- main test go ok, locale not supported).
-
-To test PCRE, run the RunTest script in the pcre directory. This can also be
-run by "make runtest". It runs the pcretest test program (which is documented
-below) on each of the testinput files in turn, and compares the output with the
-contents of the corresponding testoutput file. A file called testtry is used to
-hold the output from pcretest. To run pcretest on just one of the test files,
-give its number as an argument to RunTest, for example:
-
- RunTest 3
-
-The first and third test files can also be fed directly into the perltest
-script to check that Perl gives the same results. The third file requires the
-additional features of release 5.005, which is why it is kept separate from the
-main test input, which needs only Perl 5.004. In the long run, when 5.005 is
-widespread, these two test files may get amalgamated.
-
-The second set of tests check pcre_info(), pcre_study(), pcre_copy_substring(),
-pcre_get_substring(), pcre_get_substring_list(), error detection and run-time
-flags that are specific to PCRE, as well as the POSIX wrapper API.
-
-The fourth set of tests checks pcre_maketables(), the facility for building a
-set of character tables for a specific locale and using them instead of the
-default tables. The tests make use of the "fr" (French) locale. Before running
-the test, the script checks for the presence of this locale by running the
-"locale" command. If that command fails, or if it doesn't include "fr" in the
-list of available locales, the fourth test cannot be run, and a comment is
-output to say why. If running this test produces instances of the error
-
- ** Failed to set locale "fr"
-
-in the comparison output, it means that locale is not available on your system,
-despite being listed by "locale". This does not mean that PCRE is broken.
-
-PCRE has its own native API, but a set of "wrapper" functions that are based on
-the POSIX API are also supplied in the library libpcreposix.a. Note that this
-just provides a POSIX calling interface to PCRE: the regular expressions
-themselves still follow Perl syntax and semantics. The header file
-for the POSIX-style functions is called pcreposix.h. The official POSIX name is
-regex.h, but I didn't want to risk possible problems with existing files of
-that name by distributing it that way. To use it with an existing program that
-uses the POSIX API, it will have to be renamed or pointed at by a link.
-
-
-Character tables
-----------------
-
-PCRE uses four tables for manipulating and identifying characters. The final
-argument of the pcre_compile() function is a pointer to a block of memory
-containing the concatenated tables. A call to pcre_maketables() can be used to
-generate a set of tables in the current locale. If the final argument for
-pcre_compile() is passed as NULL, a set of default tables that is built into
-the binary is used.
-
-The source file called chartables.c contains the default set of tables. This is
-not supplied in the distribution, but is built by the program dftables
-(compiled from dftables.c), which uses the ANSI C character handling functions
-such as isalnum(), isalpha(), isupper(), islower(), etc. to build the table
-sources. This means that the default C locale which is set for your system will
-control the contents of these default tables. You can change the default tables
-by editing chartables.c and then re-building PCRE. If you do this, you should
-probably also edit Makefile to ensure that the file doesn't ever get
-re-generated.
-
-The first two 256-byte tables provide lower casing and case flipping functions,
-respectively. The next table consists of three 32-byte bit maps which identify
-digits, "word" characters, and white space, respectively. These are used when
-building 32-byte bit maps that represent character classes.
-
-The final 256-byte table has bits indicating various character types, as
-follows:
-
- 1 white space character
- 2 letter
- 4 decimal digit
- 8 hexadecimal digit
- 16 alphanumeric or '_'
- 128 regular expression metacharacter or binary zero
-
-You should not alter the set of characters that contain the 128 bit, as that
-will cause PCRE to malfunction.
-
-
-The pcretest program
---------------------
-
-This program is intended for testing PCRE, but it can also be used for
-experimenting with regular expressions.
-
-If it is given two filename arguments, it reads from the first and writes to
-the second. If it is given only one filename argument, it reads from that file
-and writes to stdout. Otherwise, it reads from stdin and writes to stdout, and
-prompts for each line of input.
-
-The program handles any number of sets of input on a single input file. Each
-set starts with a regular expression, and continues with any number of data
-lines to be matched against the pattern. An empty line signals the end of the
-set. The regular expressions are given enclosed in any non-alphameric
-delimiters other than backslash, for example
-
- /(a|bc)x+yz/
-
-White space before the initial delimiter is ignored. A regular expression may
-be continued over several input lines, in which case the newline characters are
-included within it. See the testinput files for many examples. It is possible
-to include the delimiter within the pattern by escaping it, for example
-
- /abc\/def/
-
-If you do so, the escape and the delimiter form part of the pattern, but since
-delimiters are always non-alphameric, this does not affect its interpretation.
-If the terminating delimiter is immediately followed by a backslash, for
-example,
-
- /abc/\
-
-then a backslash is added to the end of the pattern. This is done to provide a
-way of testing the error condition that arises if a pattern finishes with a
-backslash, because
-
- /abc\/
-
-is interpreted as the first line of a pattern that starts with "abc/", causing
-pcretest to read the next line as a continuation of the regular expression.
-
-The pattern may be followed by i, m, s, or x to set the PCRE_CASELESS,
-PCRE_MULTILINE, PCRE_DOTALL, or PCRE_EXTENDED options, respectively. For
-example:
-
- /caseless/i
-
-These modifier letters have the same effect as they do in Perl. There are
-others which set PCRE options that do not correspond to anything in Perl: /A,
-/E, and /X set PCRE_ANCHORED, PCRE_DOLLAR_ENDONLY, and PCRE_EXTRA respectively.
-
-Searching for all possible matches within each subject string can be requested
-by the /g or /G modifier. After finding a match, PCRE is called again to search
-the remainder of the subject string. The difference between /g and /G is that
-the former uses the startoffset argument to pcre_exec() to start searching at
-a new point within the entire string (which is in effect what Perl does),
-whereas the latter passes over a shortened substring. This makes a difference
-to the matching process if the pattern begins with a lookbehind assertion
-(including \b or \B).
-
-If any call to pcre_exec() in a /g or /G sequence matches an empty string, the
-next call is done with the PCRE_NOTEMPTY flag set so that it cannot match an
-empty string again. This imitates the way Perl handles such cases when using
-the /g modifier or the split() function.
-
-There are a number of other modifiers for controlling the way pcretest
-operates.
-
-The /+ modifier requests that as well as outputting the substring that matched
-the entire pattern, pcretest should in addition output the remainder of the
-subject string. This is useful for tests where the subject contains multiple
-copies of the same substring.
-
-The /L modifier must be followed directly by the name of a locale, for example,
-
- /pattern/Lfr
-
-For this reason, it must be the last modifier letter. The given locale is set,
-pcre_maketables() is called to build a set of character tables for the locale,
-and this is then passed to pcre_compile() when compiling the regular
-expression. Without an /L modifier, NULL is passed as the tables pointer; that
-is, /L applies only to the expression on which it appears.
-
-The /I modifier requests that pcretest output information about the compiled
-expression (whether it is anchored, has a fixed first character, and so on). It
-does this by calling pcre_info() after compiling an expression, and outputting
-the information it gets back. If the pattern is studied, the results of that
-are also output.
-
-The /D modifier is a PCRE debugging feature, which also assumes /I. It causes
-the internal form of compiled regular expressions to be output after
-compilation.
-
-The /S modifier causes pcre_study() to be called after the expression has been
-compiled, and the results used when the expression is matched.
-
-The /M modifier causes the size of memory block used to hold the compiled
-pattern to be output.
-
-Finally, the /P modifier causes pcretest to call PCRE via the POSIX wrapper API
-rather than its native API. When this is done, all other modifiers except /i,
-/m, and /+ are ignored. REG_ICASE is set if /i is present, and REG_NEWLINE is
-set if /m is present. The wrapper functions force PCRE_DOLLAR_ENDONLY always,
-and PCRE_DOTALL unless REG_NEWLINE is set.
-
-Before each data line is passed to pcre_exec(), leading and trailing whitespace
-is removed, and it is then scanned for \ escapes. The following are recognized:
-
- \a alarm (= BEL)
- \b backspace
- \e escape
- \f formfeed
- \n newline
- \r carriage return
- \t tab
- \v vertical tab
- \nnn octal character (up to 3 octal digits)
- \xhh hexadecimal character (up to 2 hex digits)
-
- \A pass the PCRE_ANCHORED option to pcre_exec()
- \B pass the PCRE_NOTBOL option to pcre_exec()
- \Cdd call pcre_copy_substring() for substring dd after a successful match
- (any decimal number less than 32)
- \Gdd call pcre_get_substring() for substring dd after a successful match
- (any decimal number less than 32)
- \L call pcre_get_substringlist() after a successful match
- \N pass the PCRE_NOTEMPTY option to pcre_exec()
- \Odd set the size of the output vector passed to pcre_exec() to dd
- (any number of decimal digits)
- \Z pass the PCRE_NOTEOL option to pcre_exec()
-
-A backslash followed by anything else just escapes the anything else. If the
-very last character is a backslash, it is ignored. This gives a way of passing
-an empty line as data, since a real empty line terminates the data input.
-
-If /P was present on the regex, causing the POSIX wrapper API to be used, only
-\B, and \Z have any effect, causing REG_NOTBOL and REG_NOTEOL to be passed to
-regexec() respectively.
-
-When a match succeeds, pcretest outputs the list of captured substrings that
-pcre_exec() returns, starting with number 0 for the string that matched the
-whole pattern. Here is an example of an interactive pcretest run.
-
- $ pcretest
- PCRE version 2.06 08-Jun-1999
-
- re> /^abc(\d+)/
- data> abc123
- 0: abc123
- 1: 123
- data> xyz
- No match
-
-If the strings contain any non-printing characters, they are output as \0x
-escapes. If the pattern has the /+ modifier, then the output for substring 0 is
-followed by the the rest of the subject string, identified by "0+" like this:
-
- re> /cat/+
- data> cataract
- 0: cat
- 0+ aract
-
-If the pattern has the /g or /G modifier, the results of successive matching
-attempts are output in sequence, like this:
-
- re> /\Bi(\w\w)/g
- data> Mississippi
- 0: iss
- 1: ss
- 0: iss
- 1: ss
- 0: ipp
- 1: pp
-
-"No match" is output only if the first match attempt fails.
-
-If any of \C, \G, or \L are present in a data line that is successfully
-matched, the substrings extracted by the convenience functions are output with
-C, G, or L after the string number instead of a colon. This is in addition to
-the normal full list. The string length (that is, the return from the
-extraction function) is given in parentheses after each string for \C and \G.
-
-Note that while patterns can be continued over several lines (a plain ">"
-prompt is used for continuations), data lines may not. However newlines can be
-included in data by means of the \n escape.
-
-If the -p option is given to pcretest, it is equivalent to adding /P to each
-regular expression: the POSIX wrapper API is used to call PCRE. None of the
-following flags has any effect in this case.
-
-If the option -d is given to pcretest, it is equivalent to adding /D to each
-regular expression: the internal form is output after compilation.
-
-If the option -i is given to pcretest, it is equivalent to adding /I to each
-regular expression: information about the compiled pattern is given after
-compilation.
-
-If the option -m is given to pcretest, it outputs the size of each compiled
-pattern after it has been compiled. It is equivalent to adding /M to each
-regular expression. For compatibility with earlier versions of pcretest, -s is
-a synonym for -m.
-
-If the -t option is given, each compile, study, and match is run 20000 times
-while being timed, and the resulting time per compile or match is output in
-milliseconds. Do not set -t with -s, because you will then get the size output
-20000 times and the timing will be distorted. If you want to change the number
-of repetitions used for timing, edit the definition of LOOPREPEAT at the top of
-pcretest.c
-
-
-
-The perltest program
---------------------
-
-The perltest program tests Perl's regular expressions; it has the same
-specification as pcretest, and so can be given identical input, except that
-input patterns can be followed only by Perl's lower case modifiers. The
-contents of testinput1 and testinput3 meet this condition.
-
-The data lines are processed as Perl double-quoted strings, so if they contain
-" \ $ or @ characters, these have to be escaped. For this reason, all such
-characters in testinput1 and testinput3 are escaped so that they can be used
-for perltest as well as for pcretest, and the special upper case modifiers such
-as /A that pcretest recognizes are not used in these files. The output should
-be identical, apart from the initial identifying banner.
-
-The testinput2 and testinput4 files are not suitable for feeding to perltest,
-since they do make use of the special upper case modifiers and escapes that
-pcretest uses to test some features of PCRE. The first of these files also
-contains malformed regular expressions, in order to check that PCRE diagnoses
-them correctly.
-
-Philip Hazel <ph10@cam.ac.uk>
-July 1999
diff --git a/ext/pcre/pcrelib/RunTest b/ext/pcre/pcrelib/RunTest
deleted file mode 100755
index a23c51108f..0000000000
--- a/ext/pcre/pcrelib/RunTest
+++ /dev/null
@@ -1,94 +0,0 @@
-#! /bin/sh
-
-# Run PCRE tests
-
-cf=diff
-
-# Select which tests to run; if no selection, run all
-
-do1=no
-do2=no
-do3=no
-do4=no
-
-while [ $# -gt 0 ] ; do
- case $1 in
- 1) do1=yes;;
- 2) do2=yes;;
- 3) do3=yes;;
- 4) do4=yes;;
- *) echo "Unknown test number $1"; exit 1;;
- esac
- shift
-done
-
-if [ $do1 = no -a $do2 = no -a $do3 = no -a $do4 = no ] ; then
- do1=yes
- do2=yes
- do3=yes
- do4=yes
-fi
-
-# Primary test, Perl-compatible
-
-if [ $do1 = yes ] ; then
- echo "Testing main functionality (Perl compatible)"
- ./pcretest testinput1 testtry
- if [ $? = 0 ] ; then
- $cf testtry testoutput1
- if [ $? != 0 ] ; then exit 1; fi
- else exit 1
- fi
-fi
-
-# PCRE tests that are not Perl-compatible - API & error tests, mostly
-
-if [ $do2 = yes ] ; then
- echo "Testing API and error handling (not Perl compatible)"
- ./pcretest -i testinput2 testtry
- if [ $? = 0 ] ; then
- $cf testtry testoutput2
- if [ $? != 0 ] ; then exit 1; fi
- else exit 1
- fi
-fi
-
-# Additional Perl-compatible tests for Perl 5.005's new features
-
-if [ $do3 = yes ] ; then
- echo "Testing Perl 5.005 features (Perl 5.005 compatible)"
- ./pcretest testinput3 testtry
- if [ $? = 0 ] ; then
- $cf testtry testoutput3
- if [ $? != 0 ] ; then exit 1; fi
- else exit 1
- fi
-fi
-
-if [ $do1 = yes -a $do2 = yes -a $do3 = yes ] ; then
- echo "The three main tests all ran OK"
- echo " "
-fi
-
-# Locale-specific tests, provided the "fr" locale is available
-
-if [ $do4 = yes ] ; then
- locale -a | grep '^fr$' >/dev/null
- if [ $? -eq 0 ] ; then
- echo "Testing locale-specific features (using 'fr' locale)"
- ./pcretest testinput4 testtry
- if [ $? = 0 ] ; then
- $cf testtry testoutput4
- if [ $? != 0 ] ; then exit 1; fi
- echo "Locale test ran OK"
- echo " "
- else exit 1
- fi
- else
- echo "Cannot test locale-specific features - 'fr' locale not found,"
- echo "or the \"locale\" command is not available to check for it."
- echo " "
- fi
-fi
-
-# End
diff --git a/ext/pcre/pcrelib/Tech.Notes b/ext/pcre/pcrelib/Tech.Notes
deleted file mode 100644
index d485a4ec59..0000000000
--- a/ext/pcre/pcrelib/Tech.Notes
+++ /dev/null
@@ -1,239 +0,0 @@
-Technical Notes about PCRE
---------------------------
-
-Many years ago I implemented some regular expression functions to an algorithm
-suggested by Martin Richards. These were not Unix-like in form, and were quite
-restricted in what they could do by comparison with Perl. The interesting part
-about the algorithm was that the amount of space required to hold the compiled
-form of an expression was known in advance. The code to apply an expression did
-not operate by backtracking, as the Henry Spencer and Perl code does, but
-instead checked all possibilities simultaneously by keeping a list of current
-states and checking all of them as it advanced through the subject string. (In
-the terminology of Jeffrey Friedl's book, it was a "DFA algorithm".) When the
-pattern was all used up, all remaining states were possible matches, and the
-one matching the longest subset of the subject string was chosen. This did not
-necessarily maximize the individual wild portions of the pattern, as is
-expected in Unix and Perl-style regular expressions.
-
-By contrast, the code originally written by Henry Spencer and subsequently
-heavily modified for Perl actually compiles the expression twice: once in a
-dummy mode in order to find out how much store will be needed, and then for
-real. The execution function operates by backtracking and maximizing (or,
-optionally, minimizing in Perl) the amount of the subject that matches
-individual wild portions of the pattern. This is an "NFA algorithm" in Friedl's
-terminology.
-
-For this set of functions that forms PCRE, I tried at first to invent an
-algorithm that used an amount of store bounded by a multiple of the number of
-characters in the pattern, to save on compiling time. However, because of the
-greater complexity in Perl regular expressions, I couldn't do this. In any
-case, a first pass through the pattern is needed, in order to find internal
-flag settings like (?i) at top level. So it works by running a very degenerate
-first pass to calculate a maximum store size, and then a second pass to do the
-real compile - which may use a bit less than the predicted amount of store. The
-idea is that this is going to turn out faster because the first pass is
-degenerate and the second can just store stuff straight into the vector. It
-does make the compiling functions bigger, of course, but they have got quite
-big anyway to handle all the Perl stuff.
-
-The compiled form of a pattern is a vector of bytes, containing items of
-variable length. The first byte in an item is an opcode, and the length of the
-item is either implicit in the opcode or contained in the data bytes which
-follow it. A list of all the opcodes follows:
-
-Opcodes with no following data
-------------------------------
-
-These items are all just one byte long
-
- OP_END end of pattern
- OP_ANY match any character
- OP_SOD match start of data: \A
- OP_CIRC ^ (start of data, or after \n in multiline)
- OP_NOT_WORD_BOUNDARY \W
- OP_WORD_BOUNDARY \w
- OP_NOT_DIGIT \D
- OP_DIGIT \d
- OP_NOT_WHITESPACE \S
- OP_WHITESPACE \s
- OP_NOT_WORDCHAR \W
- OP_WORDCHAR \w
- OP_EODN match end of data or \n at end: \Z
- OP_EOD match end of data: \z
- OP_DOLL $ (end of data, or before \n in multiline)
-
-
-Repeating single characters
----------------------------
-
-The common repeats (*, +, ?) when applied to a single character appear as
-two-byte items using the following opcodes:
-
- OP_STAR
- OP_MINSTAR
- OP_PLUS
- OP_MINPLUS
- OP_QUERY
- OP_MINQUERY
-
-Those with "MIN" in their name are the minimizing versions. Each is followed by
-the character that is to be repeated. Other repeats make use of
-
- OP_UPTO
- OP_MINUPTO
- OP_EXACT
-
-which are followed by a two-byte count (most significant first) and the
-repeated character. OP_UPTO matches from 0 to the given number. A repeat with a
-non-zero minimum and a fixed maximum is coded as an OP_EXACT followed by an
-OP_UPTO (or OP_MINUPTO).
-
-
-Repeating character types
--------------------------
-
-Repeats of things like \d are done exactly as for single characters, except
-that instead of a character, the opcode for the type is stored in the data
-byte. The opcodes are:
-
- OP_TYPESTAR
- OP_TYPEMINSTAR
- OP_TYPEPLUS
- OP_TYPEMINPLUS
- OP_TYPEQUERY
- OP_TYPEMINQUERY
- OP_TYPEUPTO
- OP_TYPEMINUPTO
- OP_TYPEEXACT
-
-
-Matching a character string
----------------------------
-
-The OP_CHARS opcode is followed by a one-byte count and then that number of
-characters. If there are more than 255 characters in sequence, successive
-instances of OP_CHARS are used.
-
-
-Character classes
------------------
-
-OP_CLASS is used for a character class, provided there are at least two
-characters in the class. If there is only one character, OP_CHARS is used for a
-positive class, and OP_NOT for a negative one (that is, for something like
-[^a]). Another set of repeating opcodes (OP_NOTSTAR etc.) are used for a
-repeated, negated, single-character class. The normal ones (OP_STAR etc.) are
-used for a repeated positive single-character class.
-
-OP_CLASS is followed by a 32-byte bit map containing a 1
-bit for every character that is acceptable. The bits are counted from the least
-significant end of each byte.
-
-
-Back references
----------------
-
-OP_REF is followed by a single byte containing the reference number.
-
-
-Repeating character classes and back references
------------------------------------------------
-
-Single-character classes are handled specially (see above). This applies to
-OP_CLASS and OP_REF. In both cases, the repeat information follows the base
-item. The matching code looks at the following opcode to see if it is one of
-
- OP_CRSTAR
- OP_CRMINSTAR
- OP_CRPLUS
- OP_CRMINPLUS
- OP_CRQUERY
- OP_CRMINQUERY
- OP_CRRANGE
- OP_CRMINRANGE
-
-All but the last two are just single-byte items. The others are followed by
-four bytes of data, comprising the minimum and maximum repeat counts.
-
-
-Brackets and alternation
-------------------------
-
-A pair of non-identifying (round) brackets is wrapped round each expression at
-compile time, so alternation always happens in the context of brackets.
-Non-identifying brackets use the opcode OP_BRA, while identifying brackets use
-OP_BRA+1, OP_BRA+2, etc. [Note for North Americans: "bracket" to some English
-speakers, including myself, can be round, square, or curly. Hence this usage.]
-
-A bracket opcode is followed by two bytes which give the offset to the next
-alternative OP_ALT or, if there aren't any branches, to the matching KET
-opcode. Each OP_ALT is followed by two bytes giving the offset to the next one,
-or to the KET opcode.
-
-OP_KET is used for subpatterns that do not repeat indefinitely, while
-OP_KETRMIN and OP_KETRMAX are used for indefinite repetitions, minimally or
-maximally respectively. All three are followed by two bytes giving (as a
-positive number) the offset back to the matching BRA opcode.
-
-If a subpattern is quantified such that it is permitted to match zero times, it
-is preceded by one of OP_BRAZERO or OP_BRAMINZERO. These are single-byte
-opcodes which tell the matcher that skipping this subpattern entirely is a
-valid branch.
-
-A subpattern with an indefinite maximum repetition is replicated in the
-compiled data its minimum number of times (or once with a BRAZERO if the
-minimum is zero), with the final copy terminating with a KETRMIN or KETRMAX as
-appropriate.
-
-A subpattern with a bounded maximum repetition is replicated in a nested
-fashion up to the maximum number of times, with BRAZERO or BRAMINZERO before
-each replication after the minimum, so that, for example, (abc){2,5} is
-compiled as (abc)(abc)((abc)((abc)(abc)?)?)?. The 200-bracket limit does not
-apply to these internally generated brackets.
-
-
-Assertions
-----------
-
-Forward assertions are just like other subpatterns, but starting with one of
-the opcodes OP_ASSERT or OP_ASSERT_NOT. Backward assertions use the opcodes
-OP_ASSERTBACK and OP_ASSERTBACK_NOT, and the first opcode inside the assertion
-is OP_REVERSE, followed by a two byte count of the number of characters to move
-back the pointer in the subject string. A separate count is present in each
-alternative of a lookbehind assertion, allowing them to have different fixed
-lengths.
-
-
-Once-only subpatterns
----------------------
-
-These are also just like other subpatterns, but they start with the opcode
-OP_ONCE.
-
-
-Conditional subpatterns
------------------------
-
-These are like other subpatterns, but they start with the opcode OP_COND. If
-the condition is a back reference, this is stored at the start of the
-subpattern using the opcode OP_CREF followed by one byte containing the
-reference number. Otherwise, a conditional subpattern will always start with
-one of the assertions.
-
-
-Changing options
-----------------
-
-If any of the /i, /m, or /s options are changed within a parenthesized group,
-an OP_OPT opcode is compiled, followed by one byte containing the new settings
-of these flags. If there are several alternatives in a group, there is an
-occurrence of OP_OPT at the start of all those following the first options
-change, to set appropriate options for the start of the alternative.
-Immediately after the end of the group there is another such item to reset the
-flags to their previous values. Other changes of flag within the pattern can be
-handled entirely at compile time, and so do not cause anything to be put into
-the compiled data.
-
-
-Philip Hazel
-January 1999
diff --git a/ext/pcre/pcrelib/chartables.c b/ext/pcre/pcrelib/chartables.c
deleted file mode 100644
index 5ef8089a93..0000000000
--- a/ext/pcre/pcrelib/chartables.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* This file is automatically written by the dftables auxiliary
-program. If you edit it by hand, you might like to edit the Makefile to
-prevent its ever being regenerated.
-
-This file is #included in the compilation of pcre.c to build the default
-character tables which are used when no tables are passed to the compile
-function. */
-
-static unsigned char pcre_default_tables[] = {
-
-/* This table is a lower casing table. */
-
- 0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55,
- 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 97, 98, 99,100,101,102,103,
- 104,105,106,107,108,109,110,111,
- 112,113,114,115,116,117,118,119,
- 120,121,122, 91, 92, 93, 94, 95,
- 96, 97, 98, 99,100,101,102,103,
- 104,105,106,107,108,109,110,111,
- 112,113,114,115,116,117,118,119,
- 120,121,122,123,124,125,126,127,
- 128,129,130,131,132,133,134,135,
- 136,137,138,139,140,141,142,143,
- 144,145,146,147,148,149,150,151,
- 152,153,154,155,156,157,158,159,
- 160,161,162,163,164,165,166,167,
- 168,169,170,171,172,173,174,175,
- 176,177,178,179,180,181,182,183,
- 184,185,186,187,188,189,190,191,
- 192,193,194,195,196,197,198,199,
- 200,201,202,203,204,205,206,207,
- 208,209,210,211,212,213,214,215,
- 216,217,218,219,220,221,222,223,
- 224,225,226,227,228,229,230,231,
- 232,233,234,235,236,237,238,239,
- 240,241,242,243,244,245,246,247,
- 248,249,250,251,252,253,254,255,
-
-/* This table is a case flipping table. */
-
- 0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55,
- 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 97, 98, 99,100,101,102,103,
- 104,105,106,107,108,109,110,111,
- 112,113,114,115,116,117,118,119,
- 120,121,122, 91, 92, 93, 94, 95,
- 96, 65, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, 85, 86, 87,
- 88, 89, 90,123,124,125,126,127,
- 128,129,130,131,132,133,134,135,
- 136,137,138,139,140,141,142,143,
- 144,145,146,147,148,149,150,151,
- 152,153,154,155,156,157,158,159,
- 160,161,162,163,164,165,166,167,
- 168,169,170,171,172,173,174,175,
- 176,177,178,179,180,181,182,183,
- 184,185,186,187,188,189,190,191,
- 192,193,194,195,196,197,198,199,
- 200,201,202,203,204,205,206,207,
- 208,209,210,211,212,213,214,215,
- 216,217,218,219,220,221,222,223,
- 224,225,226,227,228,229,230,231,
- 232,233,234,235,236,237,238,239,
- 240,241,242,243,244,245,246,247,
- 248,249,250,251,252,253,254,255,
-
-/* This table contains bit maps for digits, 'word' chars, and white
-space. Each map is 32 bytes long and the bits run from the least
-significant end of each byte. */
-
- 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-
- 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
- 0xfe,0xff,0xff,0x87,0xfe,0xff,0xff,0x07,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-
- 0x00,0x3e,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,
-
-/* This table identifies various classes of character by individual bits:
- 0x01 white space character
- 0x02 letter
- 0x04 decimal digit
- 0x08 hexadecimal digit
- 0x10 alphanumeric or '_'
- 0x80 regular expression metacharacter or binary zero
-*/
-
- 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0- 7 */
- 0x00,0x01,0x01,0x01,0x01,0x01,0x00,0x00, /* 8- 15 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 16- 23 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 24- 31 */
- 0x01,0x00,0x00,0x00,0x80,0x00,0x00,0x00, /* - ' */
- 0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x00, /* ( - / */
- 0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c, /* 0 - 7 */
- 0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x80, /* 8 - ? */
- 0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* @ - G */
- 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* H - O */
- 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* P - W */
- 0x12,0x12,0x12,0x80,0x00,0x00,0x80,0x10, /* X - _ */
- 0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* ` - g */
- 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* h - o */
- 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* p - w */
- 0x12,0x12,0x12,0x80,0x80,0x00,0x00,0x00, /* x -127 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 128-135 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 136-143 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144-151 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 152-159 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160-167 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 168-175 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 176-183 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 192-199 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 200-207 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 208-215 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 216-223 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 224-231 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 232-239 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */
-
-/* End of chartables.c */
diff --git a/ext/pcre/pcrelib/dftables.c b/ext/pcre/pcrelib/dftables.c
deleted file mode 100644
index 7b336e6f1e..0000000000
--- a/ext/pcre/pcrelib/dftables.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/*
-PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
-Written by: Philip Hazel <ph10@cam.ac.uk>
-
- Copyright (c) 1997-1999 University of Cambridge
-
------------------------------------------------------------------------------
-Permission is granted to anyone to use this software for any purpose on any
-computer system, and to redistribute it freely, subject to the following
-restrictions:
-
-1. This software 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.
-
-2. The origin of this software must not be misrepresented, either by
- explicit claim or by omission.
-
-3. Altered versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
-
-4. If PCRE is embedded in any software that is released under the GNU
- General Purpose Licence (GPL), then the terms of that licence shall
- supersede any condition above with which it is incompatible.
------------------------------------------------------------------------------
-
-See the file Tech.Notes for some information on the internals.
-*/
-
-
-/* This is a support program to generate the file chartables.c, containing
-character tables of various kinds. They are built according to the default C
-locale and used as the default tables by PCRE. Now that pcre_maketables is
-a function visible to the outside world, we make use of its code from here in
-order to be consistent. */
-
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "internal.h"
-
-#define DFTABLES /* maketables.c notices this */
-#include "maketables.c"
-
-
-int main(void)
-{
-int i;
-unsigned const char *tables = pcre_maketables();
-
-printf(
- "/*************************************************\n"
- "* Perl-Compatible Regular Expressions *\n"
- "*************************************************/\n\n"
- "/* This file is automatically written by the dftables auxiliary \n"
- "program. If you edit it by hand, you might like to edit the Makefile to \n"
- "prevent its ever being regenerated.\n\n"
- "This file is #included in the compilation of pcre.c to build the default\n"
- "character tables which are used when no tables are passed to the compile\n"
- "function. */\n\n"
- "static unsigned char pcre_default_tables[] = {\n\n"
- "/* This table is a lower casing table. */\n\n");
-
-printf(" ");
-for (i = 0; i < 256; i++)
- {
- if ((i & 7) == 0 && i != 0) printf("\n ");
- printf("%3d", *tables++);
- if (i != 255) printf(",");
- }
-printf(",\n\n");
-
-printf("/* This table is a case flipping table. */\n\n");
-
-printf(" ");
-for (i = 0; i < 256; i++)
- {
- if ((i & 7) == 0 && i != 0) printf("\n ");
- printf("%3d", *tables++);
- if (i != 255) printf(",");
- }
-printf(",\n\n");
-
-printf(
- "/* This table contains bit maps for digits, 'word' chars, and white\n"
- "space. Each map is 32 bytes long and the bits run from the least\n"
- "significant end of each byte. */\n\n");
-
-printf(" ");
-for (i = 0; i < cbit_length; i++)
- {
- if ((i & 7) == 0 && i != 0)
- {
- if ((i & 31) == 0) printf("\n");
- printf("\n ");
- }
- printf("0x%02x", *tables++);
- if (i != cbit_length - 1) printf(",");
- }
-printf(" ,\n\n");
-
-printf(
- "/* This table identifies various classes of character by individual bits:\n"
- " 0x%02x white space character\n"
- " 0x%02x letter\n"
- " 0x%02x decimal digit\n"
- " 0x%02x hexadecimal digit\n"
- " 0x%02x alphanumeric or '_'\n"
- " 0x%02x regular expression metacharacter or binary zero\n*/\n\n",
- ctype_space, ctype_letter, ctype_digit, ctype_xdigit, ctype_word,
- ctype_meta);
-
-printf(" ");
-for (i = 0; i < 256; i++)
- {
- if ((i & 7) == 0 && i != 0)
- {
- printf(" /* ");
- if (isprint(i-8)) printf(" %c -", i-8);
- else printf("%3d-", i-8);
- if (isprint(i-1)) printf(" %c ", i-1);
- else printf("%3d", i-1);
- printf(" */\n ");
- }
- printf("0x%02x", *tables++);
- if (i != 255) printf(",");
- }
-
-printf("};/* ");
-if (isprint(i-8)) printf(" %c -", i-8);
- else printf("%3d-", i-8);
-if (isprint(i-1)) printf(" %c ", i-1);
- else printf("%3d", i-1);
-printf(" */\n\n/* End of chartables.c */\n");
-
-return 0;
-}
-
-/* End of dftables.c */
diff --git a/ext/pcre/pcrelib/dll.mk b/ext/pcre/pcrelib/dll.mk
deleted file mode 100644
index d8b728e57e..0000000000
--- a/ext/pcre/pcrelib/dll.mk
+++ /dev/null
@@ -1,60 +0,0 @@
-# dll.mk - auxilary Makefile to easy build dll's for mingw32 target
-# ver. 0.6 of 1999-03-25
-#
-# Homepage of this makefile - http://www.is.lg.ua/~paul/devel/
-# Homepage of original mingw32 project -
-# http://www.fu.is.saga-u.ac.jp/~colin/gcc.html
-#
-# How to use:
-# This makefile can:
-# 1. Create automatical .def file from list of objects
-# 2. Create .dll from objects and .def file, either automatical, or your
-# hand-written (maybe) file, which must have same basename as dll
-# WARNING! There MUST be object, which name match dll's name. Make sux.
-# 3. Create import library from .def (as for .dll, only its name required,
-# not dll itself)
-# By convention implibs for dll have .dll.a suffix, e.g. libstuff.dll.a
-# Why not just libstuff.a? 'Cos that's name for static lib, ok?
-# Process divided into 3 phases because:
-# 1. Pre-existent .def possible
-# 2. Generating implib is enough time-consuming
-#
-# Variables:
-# DLL_LDLIBS - libs for linking dll
-# DLL_LDFLAGS - flags for linking dll
-#
-# By using $(DLL_SUFFIX) instead of 'dll', e.g. stuff.$(DLL_SUFFIX)
-# you may help porting makefiles to other platforms
-#
-# Put this file in your make's include path (e.g. main include dir, for
-# more information see include section in make doc). Put in the beginning
-# of your own Makefile line "include dll.mk". Specify dependences, e.g.:
-#
-# Do all stuff in one step
-# libstuff.dll.a: $(OBJECTS) stuff.def
-# stuff.def: $(OBJECTS)
-#
-# Steps separated, pre-provided .def, link with user32
-#
-# DLL_LDLIBS=-luser32
-# stuff.dll: $(OBJECTS)
-# libstuff.dll.a: $(OBJECTS)
-
-
-DLLWRAP=dllwrap
-DLLTOOL=dlltool
-
-DLL_SUFFIX=dll
-
-.SUFFIXES: .o .$(DLL_SUFFIX)
-
-_%.def: %.o
- $(DLLTOOL) --export-all --output-def $@ $^
-
-%.$(DLL_SUFFIX): %.o
- $(DLLWRAP) --dllname $(notdir $@) --driver-name $(CC) --def $*.def -o $@ $(filter %.o,$^) $(DLL_LDFLAGS) $(DLL_LDLIBS)
-
-lib%.$(DLL_SUFFIX).a:%.def
- $(DLLTOOL) --dllname $(notdir $*.dll) --def $< --output-lib $@
-
-# End
diff --git a/ext/pcre/pcrelib/get.c b/ext/pcre/pcrelib/get.c
deleted file mode 100644
index 035668e301..0000000000
--- a/ext/pcre/pcrelib/get.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/*
-This is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language. See
-the file Tech.Notes for some information on the internals.
-
-Written by: Philip Hazel <ph10@cam.ac.uk>
-
- Copyright (c) 1997-1999 University of Cambridge
-
------------------------------------------------------------------------------
-Permission is granted to anyone to use this software for any purpose on any
-computer system, and to redistribute it freely, subject to the following
-restrictions:
-
-1. This software 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.
-
-2. The origin of this software must not be misrepresented, either by
- explicit claim or by omission.
-
-3. Altered versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
-
-4. If PCRE is embedded in any software that is released under the GNU
- General Purpose Licence (GPL), then the terms of that licence shall
- supersede any condition above with which it is incompatible.
------------------------------------------------------------------------------
-*/
-
-/* This module contains some convenience functions for extracting substrings
-from the subject string after a regex match has succeeded. The original idea
-for these functions came from Scott Wimer <scottw@cgibuilder.com>. */
-
-
-/* Include the internals header, which itself includes Standard C headers plus
-the external pcre header. */
-
-#include "internal.h"
-
-
-
-/*************************************************
-* Copy captured string to given buffer *
-*************************************************/
-
-/* This function copies a single captured substring into a given buffer.
-Note that we use memcpy() rather than strncpy() in case there are binary zeros
-in the string.
-
-Arguments:
- subject the subject string that was matched
- ovector pointer to the offsets table
- stringcount the number of substrings that were captured
- (i.e. the yield of the pcre_exec call, unless
- that was zero, in which case it should be 1/3
- of the offset table size)
- stringnumber the number of the required substring
- buffer where to put the substring
- size the size of the buffer
-
-Returns: if successful:
- the length of the copied string, not including the zero
- that is put on the end; can be zero
- if not successful:
- PCRE_ERROR_NOMEMORY (-6) buffer too small
- PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
-*/
-
-int
-pcre_copy_substring(const char *subject, int *ovector, int stringcount,
- int stringnumber, char *buffer, int size)
-{
-int yield;
-if (stringnumber < 0 || stringnumber >= stringcount)
- return PCRE_ERROR_NOSUBSTRING;
-stringnumber *= 2;
-yield = ovector[stringnumber+1] - ovector[stringnumber];
-if (size < yield + 1) return PCRE_ERROR_NOMEMORY;
-memcpy(buffer, subject + ovector[stringnumber], yield);
-buffer[yield] = 0;
-return yield;
-}
-
-
-
-/*************************************************
-* Copy all captured strings to new store *
-*************************************************/
-
-/* This function gets one chunk of store and builds a list of pointers and all
-of the captured substrings in it. A NULL pointer is put on the end of the list.
-
-Arguments:
- subject the subject string that was matched
- ovector pointer to the offsets table
- stringcount the number of substrings that were captured
- (i.e. the yield of the pcre_exec call, unless
- that was zero, in which case it should be 1/3
- of the offset table size)
- listptr set to point to the list of pointers
-
-Returns: if successful: 0
- if not successful:
- PCRE_ERROR_NOMEMORY (-6) failed to get store
-*/
-
-int
-pcre_get_substring_list(const char *subject, int *ovector, int stringcount,
- const char ***listptr)
-{
-int i;
-int size = sizeof(char *);
-int double_count = stringcount * 2;
-char **stringlist;
-char *p;
-
-for (i = 0; i < double_count; i += 2)
- size += sizeof(char *) + ovector[i+1] - ovector[i] + 1;
-
-stringlist = (char **)(pcre_malloc)(size);
-if (stringlist == NULL) return PCRE_ERROR_NOMEMORY;
-
-*listptr = (const char **)stringlist;
-p = (char *)(stringlist + stringcount + 1);
-
-for (i = 0; i < double_count; i += 2)
- {
- int len = ovector[i+1] - ovector[i];
- memcpy(p, subject + ovector[i], len);
- *stringlist++ = p;
- p += len;
- *p++ = 0;
- }
-
-*stringlist = NULL;
-return 0;
-}
-
-
-
-/*************************************************
-* Copy captured string to new store *
-*************************************************/
-
-/* This function copies a single captured substring into a piece of new
-store
-
-Arguments:
- subject the subject string that was matched
- ovector pointer to the offsets table
- stringcount the number of substrings that were captured
- (i.e. the yield of the pcre_exec call, unless
- that was zero, in which case it should be 1/3
- of the offset table size)
- stringnumber the number of the required substring
- stringptr where to put a pointer to the substring
-
-Returns: if successful:
- the length of the string, not including the zero that
- is put on the end; can be zero
- if not successful:
- PCRE_ERROR_NOMEMORY (-6) failed to get store
- PCRE_ERROR_NOSUBSTRING (-7) substring not present
-*/
-
-int
-pcre_get_substring(const char *subject, int *ovector, int stringcount,
- int stringnumber, const char **stringptr)
-{
-int yield;
-char *substring;
-if (stringnumber < 0 || stringnumber >= stringcount)
- return PCRE_ERROR_NOSUBSTRING;
-stringnumber *= 2;
-yield = ovector[stringnumber+1] - ovector[stringnumber];
-substring = (char *)(pcre_malloc)(yield + 1);
-if (substring == NULL) return PCRE_ERROR_NOMEMORY;
-memcpy(substring, subject + ovector[stringnumber], yield);
-substring[yield] = 0;
-*stringptr = substring;
-return yield;
-}
-
-/* End of get.c */
diff --git a/ext/pcre/pcrelib/internal.h b/ext/pcre/pcrelib/internal.h
deleted file mode 100644
index 13df1d60f1..0000000000
--- a/ext/pcre/pcrelib/internal.h
+++ /dev/null
@@ -1,343 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-
-/* This is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language. See
-the file Tech.Notes for some information on the internals.
-
-Written by: Philip Hazel <ph10@cam.ac.uk>
-
- Copyright (c) 1997-1999 University of Cambridge
-
------------------------------------------------------------------------------
-Permission is granted to anyone to use this software for any purpose on any
-computer system, and to redistribute it freely, subject to the following
-restrictions:
-
-1. This software 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.
-
-2. The origin of this software must not be misrepresented, either by
- explicit claim or by omission.
-
-3. Altered versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
-
-4. If PCRE is embedded in any software that is released under the GNU
- General Purpose Licence (GPL), then the terms of that licence shall
- supersede any condition above with which it is incompatible.
------------------------------------------------------------------------------
-*/
-
-/* This header contains definitions that are shared between the different
-modules, but which are not relevant to the outside. */
-
-/* To cope with SunOS4 and other systems that lack memmove() but have bcopy(),
-define a macro for memmove() if USE_BCOPY is defined. */
-
-#ifdef USE_BCOPY
-#undef memmove /* some systems may have a macro */
-#define memmove(a, b, c) bcopy(b, a, c)
-#endif
-
-/* Standard C headers plus the external interface definition */
-
-#include <ctype.h>
-#include <limits.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "pcre.h"
-
-/* In case there is no definition of offsetof() provided - though any proper
-Standard C system should have one. */
-
-#ifndef offsetof
-#define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))
-#endif
-
-/* These are the public options that can change during matching. */
-
-#define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL)
-
-/* Private options flags start at the most significant end of the four bytes,
-but skip the top bit so we can use ints for convenience without getting tangled
-with negative values. The public options defined in pcre.h start at the least
-significant end. Make sure they don't overlap, though now that we have expanded
-to four bytes there is plenty of space. */
-
-#define PCRE_FIRSTSET 0x40000000 /* first_char is set */
-#define PCRE_REQCHSET 0x20000000 /* req_char is set */
-#define PCRE_STARTLINE 0x10000000 /* start after \n for multiline */
-#define PCRE_INGROUP 0x08000000 /* compiling inside a group */
-#define PCRE_ICHANGED 0x04000000 /* i option changes within regex */
-
-/* Options for the "extra" block produced by pcre_study(). */
-
-#define PCRE_STUDY_MAPPED 0x01 /* a map of starting chars exists */
-
-/* Masks for identifying the public options which are permitted at compile
-time, run time or study time, respectively. */
-
-#define PUBLIC_OPTIONS \
- (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \
- PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY)
-
-#define PUBLIC_EXEC_OPTIONS \
- (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY)
-
-#define PUBLIC_STUDY_OPTIONS 0 /* None defined */
-
-/* Magic number to provide a small check against being handed junk. */
-
-#define MAGIC_NUMBER 0x50435245UL /* 'PCRE' */
-
-/* Miscellaneous definitions */
-
-typedef int BOOL;
-
-#define FALSE 0
-#define TRUE 1
-
-/* These are escaped items that aren't just an encoding of a particular data
-value such as \n. They must have non-zero values, as check_escape() returns
-their negation. Also, they must appear in the same order as in the opcode
-definitions below, up to ESC_z. The final one must be ESC_REF as subsequent
-values are used for \1, \2, \3, etc. There is a test in the code for an escape
-greater than ESC_b and less than ESC_X to detect the types that may be
-repeated. If any new escapes are put in-between that don't consume a character,
-that code will have to change. */
-
-enum { ESC_A = 1, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W, ESC_w,
- ESC_Z, ESC_z, ESC_REF };
-
-/* Opcode table: OP_BRA must be last, as all values >= it are used for brackets
-that extract substrings. Starting from 1 (i.e. after OP_END), the values up to
-OP_EOD must correspond in order to the list of escapes immediately above. */
-
-enum {
- OP_END, /* End of pattern */
-
- /* Values corresponding to backslashed metacharacters */
-
- OP_SOD, /* Start of data: \A */
- OP_NOT_WORD_BOUNDARY, /* \B */
- OP_WORD_BOUNDARY, /* \b */
- OP_NOT_DIGIT, /* \D */
- OP_DIGIT, /* \d */
- OP_NOT_WHITESPACE, /* \S */
- OP_WHITESPACE, /* \s */
- OP_NOT_WORDCHAR, /* \W */
- OP_WORDCHAR, /* \w */
- OP_EODN, /* End of data or \n at end of data: \Z. */
- OP_EOD, /* End of data: \z */
-
- OP_OPT, /* Set runtime options */
- OP_CIRC, /* Start of line - varies with multiline switch */
- OP_DOLL, /* End of line - varies with multiline switch */
- OP_ANY, /* Match any character */
- OP_CHARS, /* Match string of characters */
- OP_NOT, /* Match anything but the following char */
-
- OP_STAR, /* The maximizing and minimizing versions of */
- OP_MINSTAR, /* all these opcodes must come in pairs, with */
- OP_PLUS, /* the minimizing one second. */
- OP_MINPLUS, /* This first set applies to single characters */
- OP_QUERY,
- OP_MINQUERY,
- OP_UPTO, /* From 0 to n matches */
- OP_MINUPTO,
- OP_EXACT, /* Exactly n matches */
-
- OP_NOTSTAR, /* The maximizing and minimizing versions of */
- OP_NOTMINSTAR, /* all these opcodes must come in pairs, with */
- OP_NOTPLUS, /* the minimizing one second. */
- OP_NOTMINPLUS, /* This first set applies to "not" single characters */
- OP_NOTQUERY,
- OP_NOTMINQUERY,
- OP_NOTUPTO, /* From 0 to n matches */
- OP_NOTMINUPTO,
- OP_NOTEXACT, /* Exactly n matches */
-
- OP_TYPESTAR, /* The maximizing and minimizing versions of */
- OP_TYPEMINSTAR, /* all these opcodes must come in pairs, with */
- OP_TYPEPLUS, /* the minimizing one second. These codes must */
- OP_TYPEMINPLUS, /* be in exactly the same order as those above. */
- OP_TYPEQUERY, /* This set applies to character types such as \d */
- OP_TYPEMINQUERY,
- OP_TYPEUPTO, /* From 0 to n matches */
- OP_TYPEMINUPTO,
- OP_TYPEEXACT, /* Exactly n matches */
-
- OP_CRSTAR, /* The maximizing and minimizing versions of */
- OP_CRMINSTAR, /* all these opcodes must come in pairs, with */
- OP_CRPLUS, /* the minimizing one second. These codes must */
- OP_CRMINPLUS, /* be in exactly the same order as those above. */
- OP_CRQUERY, /* These are for character classes and back refs */
- OP_CRMINQUERY,
- OP_CRRANGE, /* These are different to the three seta above. */
- OP_CRMINRANGE,
-
- OP_CLASS, /* Match a character class */
- OP_REF, /* Match a back reference */
-
- OP_ALT, /* Start of alternation */
- OP_KET, /* End of group that doesn't have an unbounded repeat */
- OP_KETRMAX, /* These two must remain together and in this */
- OP_KETRMIN, /* order. They are for groups the repeat for ever. */
-
- /* The assertions must come before ONCE and COND */
-
- OP_ASSERT, /* Positive lookahead */
- OP_ASSERT_NOT, /* Negative lookahead */
- OP_ASSERTBACK, /* Positive lookbehind */
- OP_ASSERTBACK_NOT, /* Negative lookbehind */
- OP_REVERSE, /* Move pointer back - used in lookbehind assertions */
-
- /* ONCE and COND must come after the assertions, with ONCE first, as there's
- a test for >= ONCE for a subpattern that isn't an assertion. */
-
- OP_ONCE, /* Once matched, don't back up into the subpattern */
- OP_COND, /* Conditional group */
- OP_CREF, /* Used to hold an extraction string number */
-
- OP_BRAZERO, /* These two must remain together and in this */
- OP_BRAMINZERO, /* order. */
-
- OP_BRA /* This and greater values are used for brackets that
- extract substrings. */
-};
-
-/* The highest extraction number. This is limited by the number of opcodes
-left after OP_BRA, i.e. 255 - OP_BRA. We actually set it somewhat lower. */
-
-#define EXTRACT_MAX 99
-
-/* The texts of compile-time error messages are defined as macros here so that
-they can be accessed by the POSIX wrapper and converted into error codes. Yes,
-I could have used error codes in the first place, but didn't feel like changing
-just to accommodate the POSIX wrapper. */
-
-#define ERR1 "\\ at end of pattern"
-#define ERR2 "\\c at end of pattern"
-#define ERR3 "unrecognized character follows \\"
-#define ERR4 "numbers out of order in {} quantifier"
-#define ERR5 "number too big in {} quantifier"
-#define ERR6 "missing terminating ] for character class"
-#define ERR7 "invalid escape sequence in character class"
-#define ERR8 "range out of order in character class"
-#define ERR9 "nothing to repeat"
-#define ERR10 "operand of unlimited repeat could match the empty string"
-#define ERR11 "internal error: unexpected repeat"
-#define ERR12 "unrecognized character after (?"
-#define ERR13 "too many capturing parenthesized sub-patterns"
-#define ERR14 "missing )"
-#define ERR15 "back reference to non-existent subpattern"
-#define ERR16 "erroffset passed as NULL"
-#define ERR17 "unknown option bit(s) set"
-#define ERR18 "missing ) after comment"
-#define ERR19 "too many sets of parentheses"
-#define ERR20 "regular expression too large"
-#define ERR21 "failed to get memory"
-#define ERR22 "unmatched parentheses"
-#define ERR23 "internal error: code overflow"
-#define ERR24 "unrecognized character after (?<"
-#define ERR25 "lookbehind assertion is not fixed length"
-#define ERR26 "malformed number after (?("
-#define ERR27 "conditional group contains more than two branches"
-#define ERR28 "assertion expected after (?("
-
-/* All character handling must be done as unsigned characters. Otherwise there
-are problems with top-bit-set characters and functions such as isspace().
-However, we leave the interface to the outside world as char *, because that
-should make things easier for callers. We define a short type for unsigned char
-to save lots of typing. I tried "uchar", but it causes problems on Digital
-Unix, where it is defined in sys/types, so use "uschar" instead. */
-
-typedef unsigned char uschar;
-
-/* The real format of the start of the pcre block; the actual code vector
-runs on as long as necessary after the end. */
-
-typedef struct real_pcre {
- unsigned long int magic_number;
- const unsigned char *tables;
- unsigned long int options;
- uschar top_bracket;
- uschar top_backref;
- uschar first_char;
- uschar req_char;
- uschar code[1];
-} real_pcre;
-
-/* The real format of the extra block returned by pcre_study(). */
-
-typedef struct real_pcre_extra {
- uschar options;
- uschar start_bits[32];
-} real_pcre_extra;
-
-
-/* Structure for passing "static" information around between the functions
-doing the compiling, so that they are thread-safe. */
-
-typedef struct compile_data {
- const uschar *lcc; /* Points to lower casing table */
- const uschar *fcc; /* Points to case-flipping table */
- const uschar *cbits; /* Points to character type table */
- const uschar *ctypes; /* Points to table of type maps */
-} compile_data;
-
-/* Structure for passing "static" information around between the functions
-doing the matching, so that they are thread-safe. */
-
-typedef struct match_data {
- int errorcode; /* As it says */
- int *offset_vector; /* Offset vector */
- int offset_end; /* One past the end */
- int offset_max; /* The maximum usable for return data */
- const uschar *lcc; /* Points to lower casing table */
- const uschar *ctypes; /* Points to table of type maps */
- BOOL offset_overflow; /* Set if too many extractions */
- BOOL notbol; /* NOTBOL flag */
- BOOL noteol; /* NOTEOL flag */
- BOOL endonly; /* Dollar not before final \n */
- BOOL notempty; /* Empty string match not wanted */
- const uschar *start_subject; /* Start of the subject string */
- const uschar *end_subject; /* End of the subject string */
- const uschar *start_match; /* Start of this match attempt */
- const uschar *end_match_ptr; /* Subject position at end match */
- int end_offset_top; /* Highwater mark at end of match */
-} match_data;
-
-/* Bit definitions for entries in the pcre_ctypes table. */
-
-#define ctype_space 0x01
-#define ctype_letter 0x02
-#define ctype_digit 0x04
-#define ctype_xdigit 0x08
-#define ctype_word 0x10 /* alphameric or '_' */
-#define ctype_meta 0x80 /* regexp meta char or zero (end pattern) */
-
-/* Offsets for the bitmap tables in pcre_cbits. Each table contains a set
-of bits for a class map. */
-
-#define cbit_digit 0 /* for \d */
-#define cbit_word 32 /* for \w */
-#define cbit_space 64 /* for \s */
-#define cbit_length 96 /* Length of the cbits table */
-
-/* Offsets of the various tables from the base tables pointer, and
-total length. */
-
-#define lcc_offset 0
-#define fcc_offset 256
-#define cbits_offset 512
-#define ctypes_offset (cbits_offset + cbit_length)
-#define tables_length (ctypes_offset + 256)
-
-/* End of internal.h */
diff --git a/ext/pcre/pcrelib/maketables.c b/ext/pcre/pcrelib/maketables.c
deleted file mode 100644
index eb5fcd107e..0000000000
--- a/ext/pcre/pcrelib/maketables.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/*
-PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
-Written by: Philip Hazel <ph10@cam.ac.uk>
-
- Copyright (c) 1997-1999 University of Cambridge
-
------------------------------------------------------------------------------
-Permission is granted to anyone to use this software for any purpose on any
-computer system, and to redistribute it freely, subject to the following
-restrictions:
-
-1. This software 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.
-
-2. The origin of this software must not be misrepresented, either by
- explicit claim or by omission.
-
-3. Altered versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
-
-4. If PCRE is embedded in any software that is released under the GNU
- General Purpose Licence (GPL), then the terms of that licence shall
- supersede any condition above with which it is incompatible.
------------------------------------------------------------------------------
-
-See the file Tech.Notes for some information on the internals.
-*/
-
-
-/* This file is compiled on its own as part of the PCRE library. However,
-it is also included in the compilation of dftables.c, in which case the macro
-DFTABLES is defined. */
-
-#ifndef DFTABLES
-#include "internal.h"
-#endif
-
-
-
-/*************************************************
-* Create PCRE character tables *
-*************************************************/
-
-/* This function builds a set of character tables for use by PCRE and returns
-a pointer to them. They are build using the ctype functions, and consequently
-their contents will depend upon the current locale setting. When compiled as
-part of the library, the store is obtained via pcre_malloc(), but when compiled
-inside dftables, use malloc().
-
-Arguments: none
-Returns: pointer to the contiguous block of data
-*/
-
-unsigned const char *
-pcre_maketables(void)
-{
-unsigned char *yield, *p;
-int i;
-
-#ifndef DFTABLES
-yield = (unsigned char*)(pcre_malloc)(tables_length);
-#else
-yield = (unsigned char*)malloc(tables_length);
-#endif
-
-if (yield == NULL) return NULL;
-p = yield;
-
-/* First comes the lower casing table */
-
-for (i = 0; i < 256; i++) *p++ = tolower(i);
-
-/* Next the case-flipping table */
-
-for (i = 0; i < 256; i++) *p++ = islower(i)? toupper(i) : tolower(i);
-
-/* Then the character class tables */
-
-memset(p, 0, cbit_length);
-for (i = 0; i < 256; i++)
- {
- if (isdigit(i)) p[cbit_digit + i/8] |= 1 << (i&7);
- if (isalnum(i) || i == '_')
- p[cbit_word + i/8] |= 1 << (i&7);
- if (isspace(i)) p[cbit_space + i/8] |= 1 << (i&7);
- }
-p += cbit_length;
-
-/* Finally, the character type table */
-
-for (i = 0; i < 256; i++)
- {
- int x = 0;
- if (isspace(i)) x += ctype_space;
- if (isalpha(i)) x += ctype_letter;
- if (isdigit(i)) x += ctype_digit;
- if (isxdigit(i)) x += ctype_xdigit;
- if (isalnum(i) || i == '_') x += ctype_word;
- if (strchr("*+?{^.$|()[", i) != 0) x += ctype_meta;
- *p++ = x;
- }
-
-return yield;
-}
-
-/* End of maketables.c */
diff --git a/ext/pcre/pcrelib/pcre.3 b/ext/pcre/pcrelib/pcre.3
deleted file mode 100644
index 3f4ad4f659..0000000000
--- a/ext/pcre/pcrelib/pcre.3
+++ /dev/null
@@ -1,1499 +0,0 @@
-.TH PCRE 3
-.SH NAME
-pcre - Perl-compatible regular expressions.
-.SH SYNOPSIS
-.B #include <pcre.h>
-.PP
-.SM
-.br
-.B pcre *pcre_compile(const char *\fIpattern\fR, int \fIoptions\fR,
-.ti +5n
-.B const char **\fIerrptr\fR, int *\fIerroffset\fR,
-.ti +5n
-.B const unsigned char *\fItableptr\fR);
-.PP
-.br
-.B pcre_extra *pcre_study(const pcre *\fIcode\fR, int \fIoptions\fR,
-.ti +5n
-.B const char **\fIerrptr\fR);
-.PP
-.br
-.B int pcre_exec(const pcre *\fIcode\fR, "const pcre_extra *\fIextra\fR,"
-.ti +5n
-.B "const char *\fIsubject\fR," int \fIlength\fR, int \fIstartoffset\fR,
-.ti +5n
-.B int \fIoptions\fR, int *\fIovector\fR, int \fIovecsize\fR);
-.PP
-.br
-.B int pcre_copy_substring(const char *\fIsubject\fR, int *\fIovector\fR,
-.ti +5n
-.B int \fIstringcount\fR, int \fIstringnumber\fR, char *\fIbuffer\fR,
-.ti +5n
-.B int \fIbuffersize\fR);
-.PP
-.br
-.B int pcre_get_substring(const char *\fIsubject\fR, int *\fIovector\fR,
-.ti +5n
-.B int \fIstringcount\fR, int \fIstringnumber\fR,
-.ti +5n
-.B const char **\fIstringptr\fR);
-.PP
-.br
-.B int pcre_get_substring_list(const char *\fIsubject\fR,
-.ti +5n
-.B int *\fIovector\fR, int \fIstringcount\fR, "const char ***\fIlistptr\fR);"
-.PP
-.br
-.B const unsigned char *pcre_maketables(void);
-.PP
-.br
-.B int pcre_info(const pcre *\fIcode\fR, int *\fIoptptr\fR, int
-.B *\fIfirstcharptr\fR);
-.PP
-.br
-.B char *pcre_version(void);
-.PP
-.br
-.B void *(*pcre_malloc)(size_t);
-.PP
-.br
-.B void (*pcre_free)(void *);
-
-
-
-.SH DESCRIPTION
-The PCRE library is a set of functions that implement regular expression
-pattern matching using the same syntax and semantics as Perl 5, with just a few
-differences (see below). The current implementation corresponds to Perl 5.005.
-
-PCRE has its own native API, which is described in this document. There is also
-a set of wrapper functions that correspond to the POSIX API. These are
-described in the \fBpcreposix\fR documentation.
-
-The native API function prototypes are defined in the header file \fBpcre.h\fR,
-and on Unix systems the library itself is called \fBlibpcre.a\fR, so can be
-accessed by adding \fB-lpcre\fR to the command for linking an application which
-calls it.
-
-The functions \fBpcre_compile()\fR, \fBpcre_study()\fR, and \fBpcre_exec()\fR
-are used for compiling and matching regular expressions, while
-\fBpcre_copy_substring()\fR, \fBpcre_get_substring()\fR, and
-\fBpcre_get_substring_list()\fR are convenience functions for extracting
-captured substrings from a matched subject string. The function
-\fBpcre_maketables()\fR is used (optionally) to build a set of character tables
-in the current locale for passing to \fBpcre_compile()\fR.
-
-The function \fBpcre_info()\fR is used to find out information about a compiled
-pattern, while the function \fBpcre_version()\fR returns a pointer to a string
-containing the version of PCRE and its date of release.
-
-The global variables \fBpcre_malloc\fR and \fBpcre_free\fR initially contain
-the entry points of the standard \fBmalloc()\fR and \fBfree()\fR functions
-respectively. PCRE calls the memory management functions via these variables,
-so a calling program can replace them if it wishes to intercept the calls. This
-should be done before calling any PCRE functions.
-
-
-.SH MULTI-THREADING
-The PCRE functions can be used in multi-threading applications, with the
-proviso that the memory management functions pointed to by \fBpcre_malloc\fR
-and \fBpcre_free\fR are shared by all threads.
-
-The compiled form of a regular expression is not altered during matching, so
-the same compiled pattern can safely be used by several threads at once.
-
-
-.SH COMPILING A PATTERN
-The function \fBpcre_compile()\fR is called to compile a pattern into an
-internal form. The pattern is a C string terminated by a binary zero, and
-is passed in the argument \fIpattern\fR. A pointer to a single block of memory
-that is obtained via \fBpcre_malloc\fR is returned. This contains the
-compiled code and related data. The \fBpcre\fR type is defined for this for
-convenience, but in fact \fBpcre\fR is just a typedef for \fBvoid\fR, since the
-contents of the block are not externally defined. It is up to the caller to
-free the memory when it is no longer required.
-.PP
-The size of a compiled pattern is roughly proportional to the length of the
-pattern string, except that each character class (other than those containing
-just a single character, negated or not) requires 33 bytes, and repeat
-quantifiers with a minimum greater than one or a bounded maximum cause the
-relevant portions of the compiled pattern to be replicated.
-.PP
-The \fIoptions\fR argument contains independent bits that affect the
-compilation. It should be zero if no options are required. Some of the options,
-in particular, those that are compatible with Perl, can also be set and unset
-from within the pattern (see the detailed description of regular expressions
-below). For these options, the contents of the \fIoptions\fR argument specifies
-their initial settings at the start of compilation and execution. The
-PCRE_ANCHORED option can be set at the time of matching as well as at compile
-time.
-.PP
-If \fIerrptr\fR is NULL, \fBpcre_compile()\fR returns NULL immediately.
-Otherwise, if compilation of a pattern fails, \fBpcre_compile()\fR returns
-NULL, and sets the variable pointed to by \fIerrptr\fR to point to a textual
-error message. The offset from the start of the pattern to the character where
-the error was discovered is placed in the variable pointed to by
-\fIerroffset\fR, which must not be NULL. If it is, an immediate error is given.
-.PP
-If the final argument, \fItableptr\fR, is NULL, PCRE uses a default set of
-character tables which are built when it is compiled, using the default C
-locale. Otherwise, \fItableptr\fR must be the result of a call to
-\fBpcre_maketables()\fR. See the section on locale support below.
-.PP
-The following option bits are defined in the header file:
-
- PCRE_ANCHORED
-
-If this bit is set, the pattern is forced to be "anchored", that is, it is
-constrained to match only at the start of the string which is being searched
-(the "subject string"). This effect can also be achieved by appropriate
-constructs in the pattern itself, which is the only way to do it in Perl.
-
- PCRE_CASELESS
-
-If this bit is set, letters in the pattern match both upper and lower case
-letters. It is equivalent to Perl's /i option.
-
- PCRE_DOLLAR_ENDONLY
-
-If this bit is set, a dollar metacharacter in the pattern matches only at the
-end of the subject string. Without this option, a dollar also matches
-immediately before the final character if it is a newline (but not before any
-other newlines). The PCRE_DOLLAR_ENDONLY option is ignored if PCRE_MULTILINE is
-set. There is no equivalent to this option in Perl.
-
- PCRE_DOTALL
-
-If this bit is set, a dot metacharater in the pattern matches all characters,
-including newlines. Without it, newlines are excluded. This option is
-equivalent to Perl's /s option. A negative class such as [^a] always matches a
-newline character, independent of the setting of this option.
-
- PCRE_EXTENDED
-
-If this bit is set, whitespace data characters in the pattern are totally
-ignored except when escaped or inside a character class, and characters between
-an unescaped # outside a character class and the next newline character,
-inclusive, are also ignored. This is equivalent to Perl's /x option, and makes
-it possible to include comments inside complicated patterns. Note, however,
-that this applies only to data characters. Whitespace characters may never
-appear within special character sequences in a pattern, for example within the
-sequence (?( which introduces a conditional subpattern.
-
- PCRE_EXTRA
-
-This option turns on additional functionality of PCRE that is incompatible with
-Perl. Any backslash in a pattern that is followed by a letter that has no
-special meaning causes an error, thus reserving these combinations for future
-expansion. By default, as in Perl, a backslash followed by a letter with no
-special meaning is treated as a literal. There are at present no other features
-controlled by this option.
-
- PCRE_MULTILINE
-
-By default, PCRE treats the subject string as consisting of a single "line" of
-characters (even if it actually contains several newlines). The "start of line"
-metacharacter (^) matches only at the start of the string, while the "end of
-line" metacharacter ($) matches only at the end of the string, or before a
-terminating newline (unless PCRE_DOLLAR_ENDONLY is set). This is the same as
-Perl.
-
-When PCRE_MULTILINE it is set, the "start of line" and "end of line" constructs
-match immediately following or immediately before any newline in the subject
-string, respectively, as well as at the very start and end. This is equivalent
-to Perl's /m option. If there are no "\\n" characters in a subject string, or
-no occurrences of ^ or $ in a pattern, setting PCRE_MULTILINE has no
-effect.
-
- PCRE_UNGREEDY
-
-This option inverts the "greediness" of the quantifiers so that they are not
-greedy by default, but become greedy if followed by "?". It is not compatible
-with Perl. It can also be set by a (?U) option setting within the pattern.
-
-
-.SH STUDYING A PATTERN
-When a pattern is going to be used several times, it is worth spending more
-time analyzing it in order to speed up the time taken for matching. The
-function \fBpcre_study()\fR takes a pointer to a compiled pattern as its first
-argument, and returns a pointer to a \fBpcre_extra\fR block (another \fBvoid\fR
-typedef) containing additional information about the pattern; this can be
-passed to \fBpcre_exec()\fR. If no additional information is available, NULL
-is returned.
-
-The second argument contains option bits. At present, no options are defined
-for \fBpcre_study()\fR, and this argument should always be zero.
-
-The third argument for \fBpcre_study()\fR is a pointer to an error message. If
-studying succeeds (even if no data is returned), the variable it points to is
-set to NULL. Otherwise it points to a textual error message.
-
-At present, studying a pattern is useful only for non-anchored patterns that do
-not have a single fixed starting character. A bitmap of possible starting
-characters is created.
-
-
-.SH LOCALE SUPPORT
-PCRE handles caseless matching, and determines whether characters are letters,
-digits, or whatever, by reference to a set of tables. The library contains a
-default set of tables which is created in the default C locale when PCRE is
-compiled. This is used when the final argument of \fBpcre_compile()\fR is NULL,
-and is sufficient for many applications.
-
-An alternative set of tables can, however, be supplied. Such tables are built
-by calling the \fBpcre_maketables()\fR function, which has no arguments, in the
-relevant locale. The result can then be passed to \fBpcre_compile()\fR as often
-as necessary. For example, to build and use tables that are appropriate for the
-French locale (where accented characters with codes greater than 128 are
-treated as letters), the following code could be used:
-
- setlocale(LC_CTYPE, "fr");
- tables = pcre_maketables();
- re = pcre_compile(..., tables);
-
-The tables are built in memory that is obtained via \fBpcre_malloc\fR. The
-pointer that is passed to \fBpcre_compile\fR is saved with the compiled
-pattern, and the same tables are used via this pointer by \fBpcre_study()\fR
-and \fBpcre_exec()\fR. Thus for any single pattern, compilation, studying and
-matching all happen in the same locale, but different patterns can be compiled
-in different locales. It is the caller's responsibility to ensure that the
-memory containing the tables remains available for as long as it is needed.
-
-
-.SH INFORMATION ABOUT A PATTERN
-The \fBpcre_info()\fR function returns information about a compiled pattern.
-Its yield is the number of capturing subpatterns, or one of the following
-negative numbers:
-
- PCRE_ERROR_NULL the argument \fIcode\fR was NULL
- PCRE_ERROR_BADMAGIC the "magic number" was not found
-
-If the \fIoptptr\fR argument is not NULL, a copy of the options with which the
-pattern was compiled is placed in the integer it points to. These option bits
-are those specified in the call to \fBpcre_compile()\fR, modified by any
-top-level option settings within the pattern itself, and with the PCRE_ANCHORED
-bit set if the form of the pattern implies that it can match only at the start
-of a subject string.
-
-If the pattern is not anchored and the \fIfirstcharptr\fR argument is not NULL,
-it is used to pass back information about the first character of any matched
-string. If there is a fixed first character, e.g. from a pattern such as
-(cat|cow|coyote), then it is returned in the integer pointed to by
-\fIfirstcharptr\fR. Otherwise, if either
-
-(a) the pattern was compiled with the PCRE_MULTILINE option, and every branch
-starts with "^", or
-
-(b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not set
-(if it were set, the pattern would be anchored),
-
-then -1 is returned, indicating that the pattern matches only at the
-start of a subject string or after any "\\n" within the string. Otherwise -2 is
-returned.
-
-
-.SH MATCHING A PATTERN
-The function \fBpcre_exec()\fR is called to match a subject string against a
-pre-compiled pattern, which is passed in the \fIcode\fR argument. If the
-pattern has been studied, the result of the study should be passed in the
-\fIextra\fR argument. Otherwise this must be NULL.
-
-The PCRE_ANCHORED option can be passed in the \fIoptions\fR argument, whose
-unused bits must be zero. However, if a pattern was compiled with
-PCRE_ANCHORED, or turned out to be anchored by virtue of its contents, it
-cannot be made unachored at matching time.
-
-There are also three further options that can be set only at matching time:
-
- PCRE_NOTBOL
-
-The first character of the string is not the beginning of a line, so the
-circumflex metacharacter should not match before it. Setting this without
-PCRE_MULTILINE (at compile time) causes circumflex never to match.
-
- PCRE_NOTEOL
-
-The end of the string is not the end of a line, so the dollar metacharacter
-should not match it nor (except in multiline mode) a newline immediately before
-it. Setting this without PCRE_MULTILINE (at compile time) causes dollar never
-to match.
-
- PCRE_NOTEMPTY
-
-An empty string is not considered to be a valid match if this option is set. If
-there are alternatives in the pattern, they are tried. If all the alternatives
-match the empty string, the entire match fails. For example, if the pattern
-
- a?b?
-
-is applied to a string not beginning with "a" or "b", it matches the empty
-string at the start of the subject. With PCRE_NOTEMPTY set, this match is not
-valid, so PCRE searches further into the string for occurrences of "a" or "b".
-Perl has no direct equivalent of this option, but it makes a special case of
-a pattern match of the empty string within its \fBsplit()\fR function, or when
-using the /g modifier. Using PCRE_NOTEMPTY it is possible to emulate this
-behaviour.
-
-The subject string is passed as a pointer in \fIsubject\fR, a length in
-\fIlength\fR, and a starting offset in \fIstartoffset\fR. Unlike the pattern
-string, it may contain binary zero characters. When the starting offset is
-zero, the search for a match starts at the beginning of the subject, and this
-is by far the most common case.
-
-A non-zero starting offset is useful when searching for another match in the
-same subject by calling \fBpcre_exec()\fR again after a previous success.
-Setting \fIstartoffset\fR differs from just passing over a shortened string and
-setting PCRE_NOTBOL in the case of a pattern that begins with any kind of
-lookbehind. For example, consider the pattern
-
- \\Biss\\B
-
-which finds occurrences of "iss" in the middle of words. (\\B matches only if
-the current position in the subject is not a word boundary.) When applied to
-the string "Mississipi" the first call to \fBpcre_exec()\fR finds the first
-occurrence. If \fBpcre_exec()\fR is called again with just the remainder of the
-subject, namely "issipi", it does not match, because \\B is always false at the
-start of the subject, which is deemed to be a word boundary. However, if
-\fBpcre_exec()\fR is passed the entire string again, but with \fIstartoffset\fR
-set to 4, it finds the second occurrence of "iss" because it is able to look
-behind the starting point to discover that it is preceded by a letter.
-
-If a non-zero starting offset is passed when the pattern is anchored, one
-attempt to match at the given offset is tried. This can only succeed if the
-pattern does not require the match to be at the start of the subject.
-
-In general, a pattern matches a certain portion of the subject, and in
-addition, further substrings from the subject may be picked out by parts of the
-pattern. Following the usage in Jeffrey Friedl's book, this is called
-"capturing" in what follows, and the phrase "capturing subpattern" is used for
-a fragment of a pattern that picks out a substring. PCRE supports several other
-kinds of parenthesized subpattern that do not cause substrings to be captured.
-
-Captured substrings are returned to the caller via a vector of integer offsets
-whose address is passed in \fIovector\fR. The number of elements in the vector
-is passed in \fIovecsize\fR. The first two-thirds of the vector is used to pass
-back captured substrings, each substring using a pair of integers. The
-remaining third of the vector is used as workspace by \fBpcre_exec()\fR while
-matching capturing subpatterns, and is not available for passing back
-information. The length passed in \fIovecsize\fR should always be a multiple of
-three. If it is not, it is rounded down.
-
-When a match has been successful, information about captured substrings is
-returned in pairs of integers, starting at the beginning of \fIovector\fR, and
-continuing up to two-thirds of its length at the most. The first element of a
-pair is set to the offset of the first character in a substring, and the second
-is set to the offset of the first character after the end of a substring. The
-first pair, \fIovector[0]\fR and \fIovector[1]\fR, identify the portion of the
-subject string matched by the entire pattern. The next pair is used for the
-first capturing subpattern, and so on. The value returned by \fBpcre_exec()\fR
-is the number of pairs that have been set. If there are no capturing
-subpatterns, the return value from a successful match is 1, indicating that
-just the first pair of offsets has been set.
-
-Some convenience functions are provided for extracting the captured substrings
-as separate strings. These are described in the following section.
-
-It is possible for an capturing subpattern number \fIn+1\fR to match some
-part of the subject when subpattern \fIn\fR has not been used at all. For
-example, if the string "abc" is matched against the pattern (a|(z))(bc)
-subpatterns 1 and 3 are matched, but 2 is not. When this happens, both offset
-values corresponding to the unused subpattern are set to -1.
-
-If a capturing subpattern is matched repeatedly, it is the last portion of the
-string that it matched that gets returned.
-
-If the vector is too small to hold all the captured substrings, it is used as
-far as possible (up to two-thirds of its length), and the function returns a
-value of zero. In particular, if the substring offsets are not of interest,
-\fBpcre_exec()\fR may be called with \fIovector\fR passed as NULL and
-\fIovecsize\fR as zero. However, if the pattern contains back references and
-the \fIovector\fR isn't big enough to remember the related substrings, PCRE has
-to get additional memory for use during matching. Thus it is usually advisable
-to supply an \fIovector\fR.
-
-Note that \fBpcre_info()\fR can be used to find out how many capturing
-subpatterns there are in a compiled pattern. The smallest size for
-\fIovector\fR that will allow for \fIn\fR captured substrings in addition to
-the offsets of the substring matched by the whole pattern is (\fIn\fR+1)*3.
-
-If \fBpcre_exec()\fR fails, it returns a negative number. The following are
-defined in the header file:
-
- PCRE_ERROR_NOMATCH (-1)
-
-The subject string did not match the pattern.
-
- PCRE_ERROR_NULL (-2)
-
-Either \fIcode\fR or \fIsubject\fR was passed as NULL, or \fIovector\fR was
-NULL and \fIovecsize\fR was not zero.
-
- PCRE_ERROR_BADOPTION (-3)
-
-An unrecognized bit was set in the \fIoptions\fR argument.
-
- PCRE_ERROR_BADMAGIC (-4)
-
-PCRE stores a 4-byte "magic number" at the start of the compiled code, to catch
-the case when it is passed a junk pointer. This is the error it gives when the
-magic number isn't present.
-
- PCRE_ERROR_UNKNOWN_NODE (-5)
-
-While running the pattern match, an unknown item was encountered in the
-compiled pattern. This error could be caused by a bug in PCRE or by overwriting
-of the compiled pattern.
-
- PCRE_ERROR_NOMEMORY (-6)
-
-If a pattern contains back references, but the \fIovector\fR that is passed to
-\fBpcre_exec()\fR is not big enough to remember the referenced substrings, PCRE
-gets a block of memory at the start of matching to use for this purpose. If the
-call via \fBpcre_malloc()\fR fails, this error is given. The memory is freed at
-the end of matching.
-
-
-.SH EXTRACTING CAPTURED SUBSTRINGS
-Captured substrings can be accessed directly by using the offsets returned by
-\fBpcre_exec()\fR in \fIovector\fR. For convenience, the functions
-\fBpcre_copy_substring()\fR, \fBpcre_get_substring()\fR, and
-\fBpcre_get_substring_list()\fR are provided for extracting captured substrings
-as new, separate, zero-terminated strings. A substring that contains a binary
-zero is correctly extracted and has a further zero added on the end, but the
-result does not, of course, function as a C string.
-
-The first three arguments are the same for all three functions: \fIsubject\fR
-is the subject string which has just been successfully matched, \fIovector\fR
-is a pointer to the vector of integer offsets that was passed to
-\fBpcre_exec()\fR, and \fIstringcount\fR is the number of substrings that
-were captured by the match, including the substring that matched the entire
-regular expression. This is the value returned by \fBpcre_exec\fR if it
-is greater than zero. If \fBpcre_exec()\fR returned zero, indicating that it
-ran out of space in \fIovector\fR, then the value passed as
-\fIstringcount\fR should be the size of the vector divided by three.
-
-The functions \fBpcre_copy_substring()\fR and \fBpcre_get_substring()\fR
-extract a single substring, whose number is given as \fIstringnumber\fR. A
-value of zero extracts the substring that matched the entire pattern, while
-higher values extract the captured substrings. For \fBpcre_copy_substring()\fR,
-the string is placed in \fIbuffer\fR, whose length is given by
-\fIbuffersize\fR, while for \fBpcre_get_substring()\fR a new block of store is
-obtained via \fBpcre_malloc\fR, and its address is returned via
-\fIstringptr\fR. The yield of the function is the length of the string, not
-including the terminating zero, or one of
-
- PCRE_ERROR_NOMEMORY (-6)
-
-The buffer was too small for \fBpcre_copy_substring()\fR, or the attempt to get
-memory failed for \fBpcre_get_substring()\fR.
-
- PCRE_ERROR_NOSUBSTRING (-7)
-
-There is no substring whose number is \fIstringnumber\fR.
-
-The \fBpcre_get_substring_list()\fR function extracts all available substrings
-and builds a list of pointers to them. All this is done in a single block of
-memory which is obtained via \fBpcre_malloc\fR. The address of the memory block
-is returned via \fIlistptr\fR, which is also the start of the list of string
-pointers. The end of the list is marked by a NULL pointer. The yield of the
-function is zero if all went well, or
-
- PCRE_ERROR_NOMEMORY (-6)
-
-if the attempt to get the memory block failed.
-
-When any of these functions encounter a substring that is unset, which can
-happen when capturing subpattern number \fIn+1\fR matches some part of the
-subject, but subpattern \fIn\fR has not been used at all, they return an empty
-string. This can be distinguished from a genuine zero-length substring by
-inspecting the appropriate offset in \fIovector\fR, which is negative for unset
-substrings.
-
-
-
-.SH LIMITATIONS
-There are some size limitations in PCRE but it is hoped that they will never in
-practice be relevant.
-The maximum length of a compiled pattern is 65539 (sic) bytes.
-All values in repeating quantifiers must be less than 65536.
-The maximum number of capturing subpatterns is 99.
-The maximum number of all parenthesized subpatterns, including capturing
-subpatterns, assertions, and other types of subpattern, is 200.
-
-The maximum length of a subject string is the largest positive number that an
-integer variable can hold. However, PCRE uses recursion to handle subpatterns
-and indefinite repetition. This means that the available stack space may limit
-the size of a subject string that can be processed by certain patterns.
-
-
-.SH DIFFERENCES FROM PERL
-The differences described here are with respect to Perl 5.005.
-
-1. By default, a whitespace character is any character that the C library
-function \fBisspace()\fR recognizes, though it is possible to compile PCRE with
-alternative character type tables. Normally \fBisspace()\fR matches space,
-formfeed, newline, carriage return, horizontal tab, and vertical tab. Perl 5
-no longer includes vertical tab in its set of whitespace characters. The \\v
-escape that was in the Perl documentation for a long time was never in fact
-recognized. However, the character itself was treated as whitespace at least
-up to 5.002. In 5.004 and 5.005 it does not match \\s.
-
-2. PCRE does not allow repeat quantifiers on lookahead assertions. Perl permits
-them, but they do not mean what you might think. For example, (?!a){3} does
-not assert that the next three characters are not "a". It just asserts that the
-next character is not "a" three times.
-
-3. Capturing subpatterns that occur inside negative lookahead assertions are
-counted, but their entries in the offsets vector are never set. Perl sets its
-numerical variables from any such patterns that are matched before the
-assertion fails to match something (thereby succeeding), but only if the
-negative lookahead assertion contains just one branch.
-
-4. Though binary zero characters are supported in the subject string, they are
-not allowed in a pattern string because it is passed as a normal C string,
-terminated by zero. The escape sequence "\\0" can be used in the pattern to
-represent a binary zero.
-
-5. The following Perl escape sequences are not supported: \\l, \\u, \\L, \\U,
-\\E, \\Q. In fact these are implemented by Perl's general string-handling and
-are not part of its pattern matching engine.
-
-6. The Perl \\G assertion is not supported as it is not relevant to single
-pattern matches.
-
-7. Fairly obviously, PCRE does not support the (?{code}) construction.
-
-8. There are at the time of writing some oddities in Perl 5.005_02 concerned
-with the settings of captured strings when part of a pattern is repeated. For
-example, matching "aba" against the pattern /^(a(b)?)+$/ sets $2 to the value
-"b", but matching "aabbaa" against /^(aa(bb)?)+$/ leaves $2 unset. However, if
-the pattern is changed to /^(aa(b(b))?)+$/ then $2 (and $3) get set.
-
-In Perl 5.004 $2 is set in both cases, and that is also true of PCRE. If in the
-future Perl changes to a consistent state that is different, PCRE may change to
-follow.
-
-9. Another as yet unresolved discrepancy is that in Perl 5.005_02 the pattern
-/^(a)?(?(1)a|b)+$/ matches the string "a", whereas in PCRE it does not.
-However, in both Perl and PCRE /^(a)?a/ matched against "a" leaves $1 unset.
-
-10. PCRE provides some extensions to the Perl regular expression facilities:
-
-(a) Although lookbehind assertions must match fixed length strings, each
-alternative branch of a lookbehind assertion can match a different length of
-string. Perl 5.005 requires them all to have the same length.
-
-(b) If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not set, the $ meta-
-character matches only at the very end of the string.
-
-(c) If PCRE_EXTRA is set, a backslash followed by a letter with no special
-meaning is faulted.
-
-(d) If PCRE_UNGREEDY is set, the greediness of the repetition quantifiers is
-inverted, that is, by default they are not greedy, but if followed by a
-question mark they are.
-
-(e) PCRE_ANCHORED can be used to force a pattern to be tried only at the start
-of the subject.
-
-(f) The PCRE_NOTBOL, PCRE_NOTEOL, and PCRE_NOTEMPTY options for
-\fBpcre_exec()\fR have no Perl equivalents.
-
-
-.SH REGULAR EXPRESSION DETAILS
-The syntax and semantics of the regular expressions supported by PCRE are
-described below. Regular expressions are also described in the Perl
-documentation and in a number of other books, some of which have copious
-examples. Jeffrey Friedl's "Mastering Regular Expressions", published by
-O'Reilly (ISBN 1-56592-257-3), covers them in great detail. The description
-here is intended as reference documentation.
-
-A regular expression is a pattern that is matched against a subject string from
-left to right. Most characters stand for themselves in a pattern, and match the
-corresponding characters in the subject. As a trivial example, the pattern
-
- The quick brown fox
-
-matches a portion of a subject string that is identical to itself. The power of
-regular expressions comes from the ability to include alternatives and
-repetitions in the pattern. These are encoded in the pattern by the use of
-\fImeta-characters\fR, which do not stand for themselves but instead are
-interpreted in some special way.
-
-There are two different sets of meta-characters: those that are recognized
-anywhere in the pattern except within square brackets, and those that are
-recognized in square brackets. Outside square brackets, the meta-characters are
-as follows:
-
- \\ general escape character with several uses
- ^ assert start of subject (or line, in multiline mode)
- $ assert end of subject (or line, in multiline mode)
- . match any character except newline (by default)
- [ start character class definition
- | start of alternative branch
- ( start subpattern
- ) end subpattern
- ? extends the meaning of (
- also 0 or 1 quantifier
- also quantifier minimizer
- * 0 or more quantifier
- + 1 or more quantifier
- { start min/max quantifier
-
-Part of a pattern that is in square brackets is called a "character class". In
-a character class the only meta-characters are:
-
- \\ general escape character
- ^ negate the class, but only if the first character
- - indicates character range
- ] terminates the character class
-
-The following sections describe the use of each of the meta-characters.
-
-
-.SH BACKSLASH
-The backslash character has several uses. Firstly, if it is followed by a
-non-alphameric character, it takes away any special meaning that character may
-have. This use of backslash as an escape character applies both inside and
-outside character classes.
-
-For example, if you want to match a "*" character, you write "\\*" in the
-pattern. This applies whether or not the following character would otherwise be
-interpreted as a meta-character, so it is always safe to precede a
-non-alphameric with "\\" to specify that it stands for itself. In particular,
-if you want to match a backslash, you write "\\\\".
-
-If a pattern is compiled with the PCRE_EXTENDED option, whitespace in the
-pattern (other than in a character class) and characters between a "#" outside
-a character class and the next newline character are ignored. An escaping
-backslash can be used to include a whitespace or "#" character as part of the
-pattern.
-
-A second use of backslash provides a way of encoding non-printing characters
-in patterns in a visible manner. There is no restriction on the appearance of
-non-printing characters, apart from the binary zero that terminates a pattern,
-but when a pattern is being prepared by text editing, it is usually easier to
-use one of the following escape sequences than the binary character it
-represents:
-
- \\a alarm, that is, the BEL character (hex 07)
- \\cx "control-x", where x is any character
- \\e escape (hex 1B)
- \\f formfeed (hex 0C)
- \\n newline (hex 0A)
- \\r carriage return (hex 0D)
- \\t tab (hex 09)
- \\xhh character with hex code hh
- \\ddd character with octal code ddd, or backreference
-
-The precise effect of "\\cx" is as follows: if "x" is a lower case letter, it
-is converted to upper case. Then bit 6 of the character (hex 40) is inverted.
-Thus "\\cz" becomes hex 1A, but "\\c{" becomes hex 3B, while "\\c;" becomes hex
-7B.
-
-After "\\x", up to two hexadecimal digits are read (letters can be in upper or
-lower case).
-
-After "\\0" up to two further octal digits are read. In both cases, if there
-are fewer than two digits, just those that are present are used. Thus the
-sequence "\\0\\x\\07" specifies two binary zeros followed by a BEL character.
-Make sure you supply two digits after the initial zero if the character that
-follows is itself an octal digit.
-
-The handling of a backslash followed by a digit other than 0 is complicated.
-Outside a character class, PCRE reads it and any following digits as a decimal
-number. If the number is less than 10, or if there have been at least that many
-previous capturing left parentheses in the expression, the entire sequence is
-taken as a \fIback reference\fR. A description of how this works is given
-later, following the discussion of parenthesized subpatterns.
-
-Inside a character class, or if the decimal number is greater than 9 and there
-have not been that many capturing subpatterns, PCRE re-reads up to three octal
-digits following the backslash, and generates a single byte from the least
-significant 8 bits of the value. Any subsequent digits stand for themselves.
-For example:
-
- \\040 is another way of writing a space
- \\40 is the same, provided there are fewer than 40
- previous capturing subpatterns
- \\7 is always a back reference
- \\11 might be a back reference, or another way of
- writing a tab
- \\011 is always a tab
- \\0113 is a tab followed by the character "3"
- \\113 is the character with octal code 113 (since there
- can be no more than 99 back references)
- \\377 is a byte consisting entirely of 1 bits
- \\81 is either a back reference, or a binary zero
- followed by the two characters "8" and "1"
-
-Note that octal values of 100 or greater must not be introduced by a leading
-zero, because no more than three octal digits are ever read.
-
-All the sequences that define a single byte value can be used both inside and
-outside character classes. In addition, inside a character class, the sequence
-"\\b" is interpreted as the backspace character (hex 08). Outside a character
-class it has a different meaning (see below).
-
-The third use of backslash is for specifying generic character types:
-
- \\d any decimal digit
- \\D any character that is not a decimal digit
- \\s any whitespace character
- \\S any character that is not a whitespace character
- \\w any "word" character
- \\W any "non-word" character
-
-Each pair of escape sequences partitions the complete set of characters into
-two disjoint sets. Any given character matches one, and only one, of each pair.
-
-A "word" character is any letter or digit or the underscore character, that is,
-any character which can be part of a Perl "word". The definition of letters and
-digits is controlled by PCRE's character tables, and may vary if locale-
-specific matching is taking place (see "Locale support" above). For example, in
-the "fr" (French) locale, some character codes greater than 128 are used for
-accented letters, and these are matched by \\w.
-
-These character type sequences can appear both inside and outside character
-classes. They each match one character of the appropriate type. If the current
-matching point is at the end of the subject string, all of them fail, since
-there is no character to match.
-
-The fourth use of backslash is for certain simple assertions. An assertion
-specifies a condition that has to be met at a particular point in a match,
-without consuming any characters from the subject string. The use of
-subpatterns for more complicated assertions is described below. The backslashed
-assertions are
-
- \\b word boundary
- \\B not a word boundary
- \\A start of subject (independent of multiline mode)
- \\Z end of subject or newline at end (independent of multiline mode)
- \\z end of subject (independent of multiline mode)
-
-These assertions may not appear in character classes (but note that "\\b" has a
-different meaning, namely the backspace character, inside a character class).
-
-A word boundary is a position in the subject string where the current character
-and the previous character do not both match \\w or \\W (i.e. one matches
-\\w and the other matches \\W), or the start or end of the string if the
-first or last character matches \\w, respectively.
-
-The \\A, \\Z, and \\z assertions differ from the traditional circumflex and
-dollar (described below) in that they only ever match at the very start and end
-of the subject string, whatever options are set. They are not affected by the
-PCRE_NOTBOL or PCRE_NOTEOL options. If the \fIstartoffset\fR argument of
-\fBpcre_exec()\fR is non-zero, \\A can never match. The difference between \\Z
-and \\z is that \\Z matches before a newline that is the last character of the
-string as well as at the end of the string, whereas \\z matches only at the
-end.
-
-
-.SH CIRCUMFLEX AND DOLLAR
-Outside a character class, in the default matching mode, the circumflex
-character is an assertion which is true only if the current matching point is
-at the start of the subject string. If the \fIstartoffset\fR argument of
-\fBpcre_exec()\fR is non-zero, circumflex can never match. Inside a character
-class, circumflex has an entirely different meaning (see below).
-
-Circumflex need not be the first character of the pattern if a number of
-alternatives are involved, but it should be the first thing in each alternative
-in which it appears if the pattern is ever to match that branch. If all
-possible alternatives start with a circumflex, that is, if the pattern is
-constrained to match only at the start of the subject, it is said to be an
-"anchored" pattern. (There are also other constructs that can cause a pattern
-to be anchored.)
-
-A dollar character is an assertion which is true only if the current matching
-point is at the end of the subject string, or immediately before a newline
-character that is the last character in the string (by default). Dollar need
-not be the last character of the pattern if a number of alternatives are
-involved, but it should be the last item in any branch in which it appears.
-Dollar has no special meaning in a character class.
-
-The meaning of dollar can be changed so that it matches only at the very end of
-the string, by setting the PCRE_DOLLAR_ENDONLY option at compile or matching
-time. This does not affect the \\Z assertion.
-
-The meanings of the circumflex and dollar characters are changed if the
-PCRE_MULTILINE option is set. When this is the case, they match immediately
-after and immediately before an internal "\\n" character, respectively, in
-addition to matching at the start and end of the subject string. For example,
-the pattern /^abc$/ matches the subject string "def\\nabc" in multiline mode,
-but not otherwise. Consequently, patterns that are anchored in single line mode
-because all branches start with "^" are not anchored in multiline mode, and a
-match for circumflex is possible when the \fIstartoffset\fR argument of
-\fBpcre_exec()\fR is non-zero. The PCRE_DOLLAR_ENDONLY option is ignored if
-PCRE_MULTILINE is set.
-
-Note that the sequences \\A, \\Z, and \\z can be used to match the start and
-end of the subject in both modes, and if all branches of a pattern start with
-\\A is it always anchored, whether PCRE_MULTILINE is set or not.
-
-
-.SH FULL STOP (PERIOD, DOT)
-Outside a character class, a dot in the pattern matches any one character in
-the subject, including a non-printing character, but not (by default) newline.
-If the PCRE_DOTALL option is set, then dots match newlines as well. The
-handling of dot is entirely independent of the handling of circumflex and
-dollar, the only relationship being that they both involve newline characters.
-Dot has no special meaning in a character class.
-
-
-.SH SQUARE BRACKETS
-An opening square bracket introduces a character class, terminated by a closing
-square bracket. A closing square bracket on its own is not special. If a
-closing square bracket is required as a member of the class, it should be the
-first data character in the class (after an initial circumflex, if present) or
-escaped with a backslash.
-
-A character class matches a single character in the subject; the character must
-be in the set of characters defined by the class, unless the first character in
-the class is a circumflex, in which case the subject character must not be in
-the set defined by the class. If a circumflex is actually required as a member
-of the class, ensure it is not the first character, or escape it with a
-backslash.
-
-For example, the character class [aeiou] matches any lower case vowel, while
-[^aeiou] matches any character that is not a lower case vowel. Note that a
-circumflex is just a convenient notation for specifying the characters which
-are in the class by enumerating those that are not. It is not an assertion: it
-still consumes a character from the subject string, and fails if the current
-pointer is at the end of the string.
-
-When caseless matching is set, any letters in a class represent both their
-upper case and lower case versions, so for example, a caseless [aeiou] matches
-"A" as well as "a", and a caseless [^aeiou] does not match "A", whereas a
-caseful version would.
-
-The newline character is never treated in any special way in character classes,
-whatever the setting of the PCRE_DOTALL or PCRE_MULTILINE options is. A class
-such as [^a] will always match a newline.
-
-The minus (hyphen) character can be used to specify a range of characters in a
-character class. For example, [d-m] matches any letter between d and m,
-inclusive. If a minus character is required in a class, it must be escaped with
-a backslash or appear in a position where it cannot be interpreted as
-indicating a range, typically as the first or last character in the class.
-
-It is not possible to have the literal character "]" as the end character of a
-range. A pattern such as [W-]46] is interpreted as a class of two characters
-("W" and "-") followed by a literal string "46]", so it would match "W46]" or
-"-46]". However, if the "]" is escaped with a backslash it is interpreted as
-the end of range, so [W-\\]46] is interpreted as a single class containing a
-range followed by two separate characters. The octal or hexadecimal
-representation of "]" can also be used to end a range.
-
-Ranges operate in ASCII collating sequence. They can also be used for
-characters specified numerically, for example [\\000-\\037]. If a range that
-includes letters is used when caseless matching is set, it matches the letters
-in either case. For example, [W-c] is equivalent to [][\\^_`wxyzabc], matched
-caselessly, and if character tables for the "fr" locale are in use,
-[\\xc8-\\xcb] matches accented E characters in both cases.
-
-The character types \\d, \\D, \\s, \\S, \\w, and \\W may also appear in a
-character class, and add the characters that they match to the class. For
-example, [\\dABCDEF] matches any hexadecimal digit. A circumflex can
-conveniently be used with the upper case character types to specify a more
-restricted set of characters than the matching lower case type. For example,
-the class [^\\W_] matches any letter or digit, but not underscore.
-
-All non-alphameric characters other than \\, -, ^ (at the start) and the
-terminating ] are non-special in character classes, but it does no harm if they
-are escaped.
-
-
-.SH VERTICAL BAR
-Vertical bar characters are used to separate alternative patterns. For example,
-the pattern
-
- gilbert|sullivan
-
-matches either "gilbert" or "sullivan". Any number of alternatives may appear,
-and an empty alternative is permitted (matching the empty string).
-The matching process tries each alternative in turn, from left to right,
-and the first one that succeeds is used. If the alternatives are within a
-subpattern (defined below), "succeeds" means matching the rest of the main
-pattern as well as the alternative in the subpattern.
-
-
-.SH INTERNAL OPTION SETTING
-The settings of PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, and PCRE_EXTENDED
-can be changed from within the pattern by a sequence of Perl option letters
-enclosed between "(?" and ")". The option letters are
-
- i for PCRE_CASELESS
- m for PCRE_MULTILINE
- s for PCRE_DOTALL
- x for PCRE_EXTENDED
-
-For example, (?im) sets caseless, multiline matching. It is also possible to
-unset these options by preceding the letter with a hyphen, and a combined
-setting and unsetting such as (?im-sx), which sets PCRE_CASELESS and
-PCRE_MULTILINE while unsetting PCRE_DOTALL and PCRE_EXTENDED, is also
-permitted. If a letter appears both before and after the hyphen, the option is
-unset.
-
-The scope of these option changes depends on where in the pattern the setting
-occurs. For settings that are outside any subpattern (defined below), the
-effect is the same as if the options were set or unset at the start of
-matching. The following patterns all behave in exactly the same way:
-
- (?i)abc
- a(?i)bc
- ab(?i)c
- abc(?i)
-
-which in turn is the same as compiling the pattern abc with PCRE_CASELESS set.
-In other words, such "top level" settings apply to the whole pattern (unless
-there are other changes inside subpatterns). If there is more than one setting
-of the same option at top level, the rightmost setting is used.
-
-If an option change occurs inside a subpattern, the effect is different. This
-is a change of behaviour in Perl 5.005. An option change inside a subpattern
-affects only that part of the subpattern that follows it, so
-
- (a(?i)b)c
-
-matches abc and aBc and no other strings (assuming PCRE_CASELESS is not used).
-By this means, options can be made to have different settings in different
-parts of the pattern. Any changes made in one alternative do carry on
-into subsequent branches within the same subpattern. For example,
-
- (a(?i)b|c)
-
-matches "ab", "aB", "c", and "C", even though when matching "C" the first
-branch is abandoned before the option setting. This is because the effects of
-option settings happen at compile time. There would be some very weird
-behaviour otherwise.
-
-The PCRE-specific options PCRE_UNGREEDY and PCRE_EXTRA can be changed in the
-same way as the Perl-compatible options by using the characters U and X
-respectively. The (?X) flag setting is special in that it must always occur
-earlier in the pattern than any of the additional features it turns on, even
-when it is at top level. It is best put at the start.
-
-
-.SH SUBPATTERNS
-Subpatterns are delimited by parentheses (round brackets), which can be nested.
-Marking part of a pattern as a subpattern does two things:
-
-1. It localizes a set of alternatives. For example, the pattern
-
- cat(aract|erpillar|)
-
-matches one of the words "cat", "cataract", or "caterpillar". Without the
-parentheses, it would match "cataract", "erpillar" or the empty string.
-
-2. It sets up the subpattern as a capturing subpattern (as defined above).
-When the whole pattern matches, that portion of the subject string that matched
-the subpattern is passed back to the caller via the \fIovector\fR argument of
-\fBpcre_exec()\fR. Opening parentheses are counted from left to right (starting
-from 1) to obtain the numbers of the capturing subpatterns.
-
-For example, if the string "the red king" is matched against the pattern
-
- the ((red|white) (king|queen))
-
-the captured substrings are "red king", "red", and "king", and are numbered 1,
-2, and 3.
-
-The fact that plain parentheses fulfil two functions is not always helpful.
-There are often times when a grouping subpattern is required without a
-capturing requirement. If an opening parenthesis is followed by "?:", the
-subpattern does not do any capturing, and is not counted when computing the
-number of any subsequent capturing subpatterns. For example, if the string "the
-white queen" is matched against the pattern
-
- the ((?:red|white) (king|queen))
-
-the captured substrings are "white queen" and "queen", and are numbered 1 and
-2. The maximum number of captured substrings is 99, and the maximum number of
-all subpatterns, both capturing and non-capturing, is 200.
-
-As a convenient shorthand, if any option settings are required at the start of
-a non-capturing subpattern, the option letters may appear between the "?" and
-the ":". Thus the two patterns
-
- (?i:saturday|sunday)
- (?:(?i)saturday|sunday)
-
-match exactly the same set of strings. Because alternative branches are tried
-from left to right, and options are not reset until the end of the subpattern
-is reached, an option setting in one branch does affect subsequent branches, so
-the above patterns match "SUNDAY" as well as "Saturday".
-
-
-.SH REPETITION
-Repetition is specified by quantifiers, which can follow any of the following
-items:
-
- a single character, possibly escaped
- the . metacharacter
- a character class
- a back reference (see next section)
- a parenthesized subpattern (unless it is an assertion - see below)
-
-The general repetition quantifier specifies a minimum and maximum number of
-permitted matches, by giving the two numbers in curly brackets (braces),
-separated by a comma. The numbers must be less than 65536, and the first must
-be less than or equal to the second. For example:
-
- z{2,4}
-
-matches "zz", "zzz", or "zzzz". A closing brace on its own is not a special
-character. If the second number is omitted, but the comma is present, there is
-no upper limit; if the second number and the comma are both omitted, the
-quantifier specifies an exact number of required matches. Thus
-
- [aeiou]{3,}
-
-matches at least 3 successive vowels, but may match many more, while
-
- \\d{8}
-
-matches exactly 8 digits. An opening curly bracket that appears in a position
-where a quantifier is not allowed, or one that does not match the syntax of a
-quantifier, is taken as a literal character. For example, {,6} is not a
-quantifier, but a literal string of four characters.
-
-The quantifier {0} is permitted, causing the expression to behave as if the
-previous item and the quantifier were not present.
-
-For convenience (and historical compatibility) the three most common
-quantifiers have single-character abbreviations:
-
- * is equivalent to {0,}
- + is equivalent to {1,}
- ? is equivalent to {0,1}
-
-It is possible to construct infinite loops by following a subpattern that can
-match no characters with a quantifier that has no upper limit, for example:
-
- (a?)*
-
-Earlier versions of Perl and PCRE used to give an error at compile time for
-such patterns. However, because there are cases where this can be useful, such
-patterns are now accepted, but if any repetition of the subpattern does in fact
-match no characters, the loop is forcibly broken.
-
-By default, the quantifiers are "greedy", that is, they match as much as
-possible (up to the maximum number of permitted times), without causing the
-rest of the pattern to fail. The classic example of where this gives problems
-is in trying to match comments in C programs. These appear between the
-sequences /* and */ and within the sequence, individual * and / characters may
-appear. An attempt to match C comments by applying the pattern
-
- /\\*.*\\*/
-
-to the string
-
- /* first command */ not comment /* second comment */
-
-fails, because it matches the entire string due to the greediness of the .*
-item.
-
-However, if a quantifier is followed by a question mark, then it ceases to be
-greedy, and instead matches the minimum number of times possible, so the
-pattern
-
- /\\*.*?\\*/
-
-does the right thing with the C comments. The meaning of the various
-quantifiers is not otherwise changed, just the preferred number of matches.
-Do not confuse this use of question mark with its use as a quantifier in its
-own right. Because it has two uses, it can sometimes appear doubled, as in
-
- \\d??\\d
-
-which matches one digit by preference, but can match two if that is the only
-way the rest of the pattern matches.
-
-If the PCRE_UNGREEDY option is set (an option which is not available in Perl)
-then the quantifiers are not greedy by default, but individual ones can be made
-greedy by following them with a question mark. In other words, it inverts the
-default behaviour.
-
-When a parenthesized subpattern is quantified with a minimum repeat count that
-is greater than 1 or with a limited maximum, more store is required for the
-compiled pattern, in proportion to the size of the minimum or maximum.
-
-If a pattern starts with .* or .{0,} and the PCRE_DOTALL option (equivalent
-to Perl's /s) is set, thus allowing the . to match newlines, then the pattern
-is implicitly anchored, because whatever follows will be tried against every
-character position in the subject string, so there is no point in retrying the
-overall match at any position after the first. PCRE treats such a pattern as
-though it were preceded by \\A. In cases where it is known that the subject
-string contains no newlines, it is worth setting PCRE_DOTALL when the pattern
-begins with .* in order to obtain this optimization, or alternatively using ^
-to indicate anchoring explicitly.
-
-When a capturing subpattern is repeated, the value captured is the substring
-that matched the final iteration. For example, after
-
- (tweedle[dume]{3}\\s*)+
-
-has matched "tweedledum tweedledee" the value of the captured substring is
-"tweedledee". However, if there are nested capturing subpatterns, the
-corresponding captured values may have been set in previous iterations. For
-example, after
-
- /(a|(b))+/
-
-matches "aba" the value of the second captured substring is "b".
-
-
-.SH BACK REFERENCES
-Outside a character class, a backslash followed by a digit greater than 0 (and
-possibly further digits) is a back reference to a capturing subpattern earlier
-(i.e. to its left) in the pattern, provided there have been that many previous
-capturing left parentheses.
-
-However, if the decimal number following the backslash is less than 10, it is
-always taken as a back reference, and causes an error only if there are not
-that many capturing left parentheses in the entire pattern. In other words, the
-parentheses that are referenced need not be to the left of the reference for
-numbers less than 10. See the section entitled "Backslash" above for further
-details of the handling of digits following a backslash.
-
-A back reference matches whatever actually matched the capturing subpattern in
-the current subject string, rather than anything matching the subpattern
-itself. So the pattern
-
- (sens|respons)e and \\1ibility
-
-matches "sense and sensibility" and "response and responsibility", but not
-"sense and responsibility". If caseful matching is in force at the time of the
-back reference, then the case of letters is relevant. For example,
-
- ((?i)rah)\\s+\\1
-
-matches "rah rah" and "RAH RAH", but not "RAH rah", even though the original
-capturing subpattern is matched caselessly.
-
-There may be more than one back reference to the same subpattern. If a
-subpattern has not actually been used in a particular match, then any back
-references to it always fail. For example, the pattern
-
- (a|(bc))\\2
-
-always fails if it starts to match "a" rather than "bc". Because there may be
-up to 99 back references, all digits following the backslash are taken
-as part of a potential back reference number. If the pattern continues with a
-digit character, then some delimiter must be used to terminate the back
-reference. If the PCRE_EXTENDED option is set, this can be whitespace.
-Otherwise an empty comment can be used.
-
-A back reference that occurs inside the parentheses to which it refers fails
-when the subpattern is first used, so, for example, (a\\1) never matches.
-However, such references can be useful inside repeated subpatterns. For
-example, the pattern
-
- (a|b\\1)+
-
-matches any number of "a"s and also "aba", "ababaa" etc. At each iteration of
-the subpattern, the back reference matches the character string corresponding
-to the previous iteration. In order for this to work, the pattern must be such
-that the first iteration does not need to match the back reference. This can be
-done using alternation, as in the example above, or by a quantifier with a
-minimum of zero.
-
-
-.SH ASSERTIONS
-An assertion is a test on the characters following or preceding the current
-matching point that does not actually consume any characters. The simple
-assertions coded as \\b, \\B, \\A, \\Z, \\z, ^ and $ are described above. More
-complicated assertions are coded as subpatterns. There are two kinds: those
-that look ahead of the current position in the subject string, and those that
-look behind it.
-
-An assertion subpattern is matched in the normal way, except that it does not
-cause the current matching position to be changed. Lookahead assertions start
-with (?= for positive assertions and (?! for negative assertions. For example,
-
- \\w+(?=;)
-
-matches a word followed by a semicolon, but does not include the semicolon in
-the match, and
-
- foo(?!bar)
-
-matches any occurrence of "foo" that is not followed by "bar". Note that the
-apparently similar pattern
-
- (?!foo)bar
-
-does not find an occurrence of "bar" that is preceded by something other than
-"foo"; it finds any occurrence of "bar" whatsoever, because the assertion
-(?!foo) is always true when the next three characters are "bar". A
-lookbehind assertion is needed to achieve this effect.
-
-Lookbehind assertions start with (?<= for positive assertions and (?<! for
-negative assertions. For example,
-
- (?<!foo)bar
-
-does find an occurrence of "bar" that is not preceded by "foo". The contents of
-a lookbehind assertion are restricted such that all the strings it matches must
-have a fixed length. However, if there are several alternatives, they do not
-all have to have the same fixed length. Thus
-
- (?<=bullock|donkey)
-
-is permitted, but
-
- (?<!dogs?|cats?)
-
-causes an error at compile time. Branches that match different length strings
-are permitted only at the top level of a lookbehind assertion. This is an
-extension compared with Perl 5.005, which requires all branches to match the
-same length of string. An assertion such as
-
- (?<=ab(c|de))
-
-is not permitted, because its single top-level branch can match two different
-lengths, but it is acceptable if rewritten to use two top-level branches:
-
- (?<=abc|abde)
-
-The implementation of lookbehind assertions is, for each alternative, to
-temporarily move the current position back by the fixed width and then try to
-match. If there are insufficient characters before the current position, the
-match is deemed to fail. Lookbehinds in conjunction with once-only subpatterns
-can be particularly useful for matching at the ends of strings; an example is
-given at the end of the section on once-only subpatterns.
-
-Several assertions (of any sort) may occur in succession. For example,
-
- (?<=\\d{3})(?<!999)foo
-
-matches "foo" preceded by three digits that are not "999". Notice that each of
-the assertions is applied independently at the same point in the subject
-string. First there is a check that the previous three characters are all
-digits, then there is a check that the same three characters are not "999".
-This pattern does \fInot\fR match "foo" preceded by six characters, the first
-of which are digits and the last three of which are not "999". For example, it
-doesn't match "123abcfoo". A pattern to do that is
-
- (?<=\\d{3}...)(?<!999)foo
-
-This time the first assertion looks at the preceding six characters, checking
-that the first three are digits, and then the second assertion checks that the
-preceding three characters are not "999".
-
-Assertions can be nested in any combination. For example,
-
- (?<=(?<!foo)bar)baz
-
-matches an occurrence of "baz" that is preceded by "bar" which in turn is not
-preceded by "foo", while
-
- (?<=\\d{3}(?!999)...)foo
-
-is another pattern which matches "foo" preceded by three digits and any three
-characters that are not "999".
-
-Assertion subpatterns are not capturing subpatterns, and may not be repeated,
-because it makes no sense to assert the same thing several times. If any kind
-of assertion contains capturing subpatterns within it, these are counted for
-the purposes of numbering the capturing subpatterns in the whole pattern.
-However, substring capturing is carried out only for positive assertions,
-because it does not make sense for negative assertions.
-
-Assertions count towards the maximum of 200 parenthesized subpatterns.
-
-
-.SH ONCE-ONLY SUBPATTERNS
-With both maximizing and minimizing repetition, failure of what follows
-normally causes the repeated item to be re-evaluated to see if a different
-number of repeats allows the rest of the pattern to match. Sometimes it is
-useful to prevent this, either to change the nature of the match, or to cause
-it fail earlier than it otherwise might, when the author of the pattern knows
-there is no point in carrying on.
-
-Consider, for example, the pattern \\d+foo when applied to the subject line
-
- 123456bar
-
-After matching all 6 digits and then failing to match "foo", the normal
-action of the matcher is to try again with only 5 digits matching the \\d+
-item, and then with 4, and so on, before ultimately failing. Once-only
-subpatterns provide the means for specifying that once a portion of the pattern
-has matched, it is not to be re-evaluated in this way, so the matcher would
-give up immediately on failing to match "foo" the first time. The notation is
-another kind of special parenthesis, starting with (?> as in this example:
-
- (?>\\d+)bar
-
-This kind of parenthesis "locks up" the part of the pattern it contains once
-it has matched, and a failure further into the pattern is prevented from
-backtracking into it. Backtracking past it to previous items, however, works as
-normal.
-
-An alternative description is that a subpattern of this type matches the string
-of characters that an identical standalone pattern would match, if anchored at
-the current point in the subject string.
-
-Once-only subpatterns are not capturing subpatterns. Simple cases such as the
-above example can be thought of as a maximizing repeat that must swallow
-everything it can. So, while both \\d+ and \\d+? are prepared to adjust the
-number of digits they match in order to make the rest of the pattern match,
-(?>\\d+) can only match an entire sequence of digits.
-
-This construction can of course contain arbitrarily complicated subpatterns,
-and it can be nested.
-
-Once-only subpatterns can be used in conjunction with lookbehind assertions to
-specify efficient matching at the end of the subject string. Consider a simple
-pattern such as
-
- abcd$
-
-when applied to a long string which does not match it. Because matching
-proceeds from left to right, PCRE will look for each "a" in the subject and
-then see if what follows matches the rest of the pattern. If the pattern is
-specified as
-
- ^.*abcd$
-
-then the initial .* matches the entire string at first, but when this fails, it
-backtracks to match all but the last character, then all but the last two
-characters, and so on. Once again the search for "a" covers the entire string,
-from right to left, so we are no better off. However, if the pattern is written
-as
-
- ^(?>.*)(?<=abcd)
-
-then there can be no backtracking for the .* item; it can match only the entire
-string. The subsequent lookbehind assertion does a single test on the last four
-characters. If it fails, the match fails immediately. For long strings, this
-approach makes a significant difference to the processing time.
-
-
-.SH CONDITIONAL SUBPATTERNS
-It is possible to cause the matching process to obey a subpattern
-conditionally or to choose between two alternative subpatterns, depending on
-the result of an assertion, or whether a previous capturing subpattern matched
-or not. The two possible forms of conditional subpattern are
-
- (?(condition)yes-pattern)
- (?(condition)yes-pattern|no-pattern)
-
-If the condition is satisfied, the yes-pattern is used; otherwise the
-no-pattern (if present) is used. If there are more than two alternatives in the
-subpattern, a compile-time error occurs.
-
-There are two kinds of condition. If the text between the parentheses consists
-of a sequence of digits, then the condition is satisfied if the capturing
-subpattern of that number has previously matched. Consider the following
-pattern, which contains non-significant white space to make it more readable
-(assume the PCRE_EXTENDED option) and to divide it into three parts for ease
-of discussion:
-
- ( \\( )? [^()]+ (?(1) \\) )
-
-The first part matches an optional opening parenthesis, and if that
-character is present, sets it as the first captured substring. The second part
-matches one or more characters that are not parentheses. The third part is a
-conditional subpattern that tests whether the first set of parentheses matched
-or not. If they did, that is, if subject started with an opening parenthesis,
-the condition is true, and so the yes-pattern is executed and a closing
-parenthesis is required. Otherwise, since no-pattern is not present, the
-subpattern matches nothing. In other words, this pattern matches a sequence of
-non-parentheses, optionally enclosed in parentheses.
-
-If the condition is not a sequence of digits, it must be an assertion. This may
-be a positive or negative lookahead or lookbehind assertion. Consider this
-pattern, again containing non-significant white space, and with the two
-alternatives on the second line:
-
- (?(?=[^a-z]*[a-z])
- \\d{2}[a-z]{3}-\\d{2} | \\d{2}-\\d{2}-\\d{2} )
-
-The condition is a positive lookahead assertion that matches an optional
-sequence of non-letters followed by a letter. In other words, it tests for the
-presence of at least one letter in the subject. If a letter is found, the
-subject is matched against the first alternative; otherwise it is matched
-against the second. This pattern matches strings in one of the two forms
-dd-aaa-dd or dd-dd-dd, where aaa are letters and dd are digits.
-
-
-.SH COMMENTS
-The sequence (?# marks the start of a comment which continues up to the next
-closing parenthesis. Nested parentheses are not permitted. The characters
-that make up a comment play no part in the pattern matching at all.
-
-If the PCRE_EXTENDED option is set, an unescaped # character outside a
-character class introduces a comment that continues up to the next newline
-character in the pattern.
-
-
-.SH PERFORMANCE
-Certain items that may appear in patterns are more efficient than others. It is
-more efficient to use a character class like [aeiou] than a set of alternatives
-such as (a|e|i|o|u). In general, the simplest construction that provides the
-required behaviour is usually the most efficient. Jeffrey Friedl's book
-contains a lot of discussion about optimizing regular expressions for efficient
-performance.
-
-When a pattern begins with .* and the PCRE_DOTALL option is set, the pattern is
-implicitly anchored by PCRE, since it can match only at the start of a subject
-string. However, if PCRE_DOTALL is not set, PCRE cannot make this optimization,
-because the . metacharacter does not then match a newline, and if the subject
-string contains newlines, the pattern may match from the character immediately
-following one of them instead of from the very start. For example, the pattern
-
- (.*) second
-
-matches the subject "first\\nand second" (where \\n stands for a newline
-character) with the first captured substring being "and". In order to do this,
-PCRE has to retry the match starting after every newline in the subject.
-
-If you are using such a pattern with subject strings that do not contain
-newlines, the best performance is obtained by setting PCRE_DOTALL, or starting
-the pattern with ^.* to indicate explicit anchoring. That saves PCRE from
-having to scan along the subject looking for a newline to restart at.
-
-Beware of patterns that contain nested indefinite repeats. These can take a
-long time to run when applied to a string that does not match. Consider the
-pattern fragment
-
- (a+)*
-
-This can match "aaaa" in 33 different ways, and this number increases very
-rapidly as the string gets longer. (The * repeat can match 0, 1, 2, 3, or 4
-times, and for each of those cases other than 0, the + repeats can match
-different numbers of times.) When the remainder of the pattern is such that the
-entire match is going to fail, PCRE has in principle to try every possible
-variation, and this can take an extremely long time.
-
-An optimization catches some of the more simple cases such as
-
- (a+)*b
-
-where a literal character follows. Before embarking on the standard matching
-procedure, PCRE checks that there is a "b" later in the subject string, and if
-there is not, it fails the match immediately. However, when there is no
-following literal this optimization cannot be used. You can see the difference
-by comparing the behaviour of
-
- (a+)*\\d
-
-with the pattern above. The former gives a failure almost instantly when
-applied to a whole line of "a" characters, whereas the latter takes an
-appreciable time with strings longer than about 20 characters.
-
-.SH AUTHOR
-Philip Hazel <ph10@cam.ac.uk>
-.br
-University Computing Service,
-.br
-New Museums Site,
-.br
-Cambridge CB2 3QG, England.
-.br
-Phone: +44 1223 334714
-
-Last updated: 29 July 1999
-.br
-Copyright (c) 1997-1999 University of Cambridge.
diff --git a/ext/pcre/pcrelib/pcre.3.html b/ext/pcre/pcrelib/pcre.3.html
deleted file mode 100644
index 3417579904..0000000000
--- a/ext/pcre/pcrelib/pcre.3.html
+++ /dev/null
@@ -1,1973 +0,0 @@
-<HTML>
-<HEAD>
-<TITLE>pcre specification</TITLE>
-</HEAD>
-<body bgcolor="#FFFFFF" text="#00005A">
-<H1>pcre specification</H1>
-This HTML document has been generated automatically from the original man page.
-If there is any nonsense in it, please consult the man page in case the
-conversion went wrong.
-<UL>
-<LI><A NAME="TOC1" HREF="#SEC1">NAME</A>
-<LI><A NAME="TOC2" HREF="#SEC2">SYNOPSIS</A>
-<LI><A NAME="TOC3" HREF="#SEC3">DESCRIPTION</A>
-<LI><A NAME="TOC4" HREF="#SEC4">MULTI-THREADING</A>
-<LI><A NAME="TOC5" HREF="#SEC5">COMPILING A PATTERN</A>
-<LI><A NAME="TOC6" HREF="#SEC6">STUDYING A PATTERN</A>
-<LI><A NAME="TOC7" HREF="#SEC7">LOCALE SUPPORT</A>
-<LI><A NAME="TOC8" HREF="#SEC8">INFORMATION ABOUT A PATTERN</A>
-<LI><A NAME="TOC9" HREF="#SEC9">MATCHING A PATTERN</A>
-<LI><A NAME="TOC10" HREF="#SEC10">EXTRACTING CAPTURED SUBSTRINGS</A>
-<LI><A NAME="TOC11" HREF="#SEC11">LIMITATIONS</A>
-<LI><A NAME="TOC12" HREF="#SEC12">DIFFERENCES FROM PERL</A>
-<LI><A NAME="TOC13" HREF="#SEC13">REGULAR EXPRESSION DETAILS</A>
-<LI><A NAME="TOC14" HREF="#SEC14">BACKSLASH</A>
-<LI><A NAME="TOC15" HREF="#SEC15">CIRCUMFLEX AND DOLLAR</A>
-<LI><A NAME="TOC16" HREF="#SEC16">FULL STOP (PERIOD, DOT)</A>
-<LI><A NAME="TOC17" HREF="#SEC17">SQUARE BRACKETS</A>
-<LI><A NAME="TOC18" HREF="#SEC18">VERTICAL BAR</A>
-<LI><A NAME="TOC19" HREF="#SEC19">INTERNAL OPTION SETTING</A>
-<LI><A NAME="TOC20" HREF="#SEC20">SUBPATTERNS</A>
-<LI><A NAME="TOC21" HREF="#SEC21">REPETITION</A>
-<LI><A NAME="TOC22" HREF="#SEC22">BACK REFERENCES</A>
-<LI><A NAME="TOC23" HREF="#SEC23">ASSERTIONS</A>
-<LI><A NAME="TOC24" HREF="#SEC24">ONCE-ONLY SUBPATTERNS</A>
-<LI><A NAME="TOC25" HREF="#SEC25">CONDITIONAL SUBPATTERNS</A>
-<LI><A NAME="TOC26" HREF="#SEC26">COMMENTS</A>
-<LI><A NAME="TOC27" HREF="#SEC27">PERFORMANCE</A>
-<LI><A NAME="TOC28" HREF="#SEC28">AUTHOR</A>
-</UL>
-<LI><A NAME="SEC1" HREF="#TOC1">NAME</A>
-<P>
-pcre - Perl-compatible regular expressions.
-</P>
-<LI><A NAME="SEC2" HREF="#TOC1">SYNOPSIS</A>
-<P>
-<B>#include &#60;pcre.h&#62;</B>
-</P>
-<P>
-<B>pcre *pcre_compile(const char *<I>pattern</I>, int <I>options</I>,</B>
-<B>const char **<I>errptr</I>, int *<I>erroffset</I>,</B>
-<B>const unsigned char *<I>tableptr</I>);</B>
-</P>
-<P>
-<B>pcre_extra *pcre_study(const pcre *<I>code</I>, int <I>options</I>,</B>
-<B>const char **<I>errptr</I>);</B>
-</P>
-<P>
-<B>int pcre_exec(const pcre *<I>code</I>, const pcre_extra *<I>extra</I>,</B>
-<B>const char *<I>subject</I>, int <I>length</I>, int <I>startoffset</I>,</B>
-<B>int <I>options</I>, int *<I>ovector</I>, int <I>ovecsize</I>);</B>
-</P>
-<P>
-<B>int pcre_copy_substring(const char *<I>subject</I>, int *<I>ovector</I>,</B>
-<B>int <I>stringcount</I>, int <I>stringnumber</I>, char *<I>buffer</I>,</B>
-<B>int <I>buffersize</I>);</B>
-</P>
-<P>
-<B>int pcre_get_substring(const char *<I>subject</I>, int *<I>ovector</I>,</B>
-<B>int <I>stringcount</I>, int <I>stringnumber</I>,</B>
-<B>const char **<I>stringptr</I>);</B>
-</P>
-<P>
-<B>int pcre_get_substring_list(const char *<I>subject</I>,</B>
-<B>int *<I>ovector</I>, int <I>stringcount</I>, const char ***<I>listptr</I>);</B>
-</P>
-<P>
-<B>const unsigned char *pcre_maketables(void);</B>
-</P>
-<P>
-<B>int pcre_info(const pcre *<I>code</I>, int *<I>optptr</I>, int</B>
-<B>*<I>firstcharptr</I>);</B>
-</P>
-<P>
-<B>char *pcre_version(void);</B>
-</P>
-<P>
-<B>void *(*pcre_malloc)(size_t);</B>
-</P>
-<P>
-<B>void (*pcre_free)(void *);</B>
-</P>
-<LI><A NAME="SEC3" HREF="#TOC1">DESCRIPTION</A>
-<P>
-The PCRE library is a set of functions that implement regular expression
-pattern matching using the same syntax and semantics as Perl 5, with just a few
-differences (see below). The current implementation corresponds to Perl 5.005.
-</P>
-<P>
-PCRE has its own native API, which is described in this document. There is also
-a set of wrapper functions that correspond to the POSIX API. These are
-described in the <B>pcreposix</B> documentation.
-</P>
-<P>
-The native API function prototypes are defined in the header file <B>pcre.h</B>,
-and on Unix systems the library itself is called <B>libpcre.a</B>, so can be
-accessed by adding <B>-lpcre</B> to the command for linking an application which
-calls it.
-</P>
-<P>
-The functions <B>pcre_compile()</B>, <B>pcre_study()</B>, and <B>pcre_exec()</B>
-are used for compiling and matching regular expressions, while
-<B>pcre_copy_substring()</B>, <B>pcre_get_substring()</B>, and
-<B>pcre_get_substring_list()</B> are convenience functions for extracting
-captured substrings from a matched subject string. The function
-<B>pcre_maketables()</B> is used (optionally) to build a set of character tables
-in the current locale for passing to <B>pcre_compile()</B>.
-</P>
-<P>
-The function <B>pcre_info()</B> is used to find out information about a compiled
-pattern, while the function <B>pcre_version()</B> returns a pointer to a string
-containing the version of PCRE and its date of release.
-</P>
-<P>
-The global variables <B>pcre_malloc</B> and <B>pcre_free</B> initially contain
-the entry points of the standard <B>malloc()</B> and <B>free()</B> functions
-respectively. PCRE calls the memory management functions via these variables,
-so a calling program can replace them if it wishes to intercept the calls. This
-should be done before calling any PCRE functions.
-</P>
-<LI><A NAME="SEC4" HREF="#TOC1">MULTI-THREADING</A>
-<P>
-The PCRE functions can be used in multi-threading applications, with the
-proviso that the memory management functions pointed to by <B>pcre_malloc</B>
-and <B>pcre_free</B> are shared by all threads.
-</P>
-<P>
-The compiled form of a regular expression is not altered during matching, so
-the same compiled pattern can safely be used by several threads at once.
-</P>
-<LI><A NAME="SEC5" HREF="#TOC1">COMPILING A PATTERN</A>
-<P>
-The function <B>pcre_compile()</B> is called to compile a pattern into an
-internal form. The pattern is a C string terminated by a binary zero, and
-is passed in the argument <I>pattern</I>. A pointer to a single block of memory
-that is obtained via <B>pcre_malloc</B> is returned. This contains the
-compiled code and related data. The <B>pcre</B> type is defined for this for
-convenience, but in fact <B>pcre</B> is just a typedef for <B>void</B>, since the
-contents of the block are not externally defined. It is up to the caller to
-free the memory when it is no longer required.
-</P>
-<P>
-The size of a compiled pattern is roughly proportional to the length of the
-pattern string, except that each character class (other than those containing
-just a single character, negated or not) requires 33 bytes, and repeat
-quantifiers with a minimum greater than one or a bounded maximum cause the
-relevant portions of the compiled pattern to be replicated.
-</P>
-<P>
-The <I>options</I> argument contains independent bits that affect the
-compilation. It should be zero if no options are required. Some of the options,
-in particular, those that are compatible with Perl, can also be set and unset
-from within the pattern (see the detailed description of regular expressions
-below). For these options, the contents of the <I>options</I> argument specifies
-their initial settings at the start of compilation and execution. The
-PCRE_ANCHORED option can be set at the time of matching as well as at compile
-time.
-</P>
-<P>
-If <I>errptr</I> is NULL, <B>pcre_compile()</B> returns NULL immediately.
-Otherwise, if compilation of a pattern fails, <B>pcre_compile()</B> returns
-NULL, and sets the variable pointed to by <I>errptr</I> to point to a textual
-error message. The offset from the start of the pattern to the character where
-the error was discovered is placed in the variable pointed to by
-<I>erroffset</I>, which must not be NULL. If it is, an immediate error is given.
-</P>
-<P>
-If the final argument, <I>tableptr</I>, is NULL, PCRE uses a default set of
-character tables which are built when it is compiled, using the default C
-locale. Otherwise, <I>tableptr</I> must be the result of a call to
-<B>pcre_maketables()</B>. See the section on locale support below.
-</P>
-<P>
-The following option bits are defined in the header file:
-</P>
-<P>
-<PRE>
- PCRE_ANCHORED
-</PRE>
-</P>
-<P>
-If this bit is set, the pattern is forced to be "anchored", that is, it is
-constrained to match only at the start of the string which is being searched
-(the "subject string"). This effect can also be achieved by appropriate
-constructs in the pattern itself, which is the only way to do it in Perl.
-</P>
-<P>
-<PRE>
- PCRE_CASELESS
-</PRE>
-</P>
-<P>
-If this bit is set, letters in the pattern match both upper and lower case
-letters. It is equivalent to Perl's /i option.
-</P>
-<P>
-<PRE>
- PCRE_DOLLAR_ENDONLY
-</PRE>
-</P>
-<P>
-If this bit is set, a dollar metacharacter in the pattern matches only at the
-end of the subject string. Without this option, a dollar also matches
-immediately before the final character if it is a newline (but not before any
-other newlines). The PCRE_DOLLAR_ENDONLY option is ignored if PCRE_MULTILINE is
-set. There is no equivalent to this option in Perl.
-</P>
-<P>
-<PRE>
- PCRE_DOTALL
-</PRE>
-</P>
-<P>
-If this bit is set, a dot metacharater in the pattern matches all characters,
-including newlines. Without it, newlines are excluded. This option is
-equivalent to Perl's /s option. A negative class such as [^a] always matches a
-newline character, independent of the setting of this option.
-</P>
-<P>
-<PRE>
- PCRE_EXTENDED
-</PRE>
-</P>
-<P>
-If this bit is set, whitespace data characters in the pattern are totally
-ignored except when escaped or inside a character class, and characters between
-an unescaped # outside a character class and the next newline character,
-inclusive, are also ignored. This is equivalent to Perl's /x option, and makes
-it possible to include comments inside complicated patterns. Note, however,
-that this applies only to data characters. Whitespace characters may never
-appear within special character sequences in a pattern, for example within the
-sequence (?( which introduces a conditional subpattern.
-</P>
-<P>
-<PRE>
- PCRE_EXTRA
-</PRE>
-</P>
-<P>
-This option turns on additional functionality of PCRE that is incompatible with
-Perl. Any backslash in a pattern that is followed by a letter that has no
-special meaning causes an error, thus reserving these combinations for future
-expansion. By default, as in Perl, a backslash followed by a letter with no
-special meaning is treated as a literal. There are at present no other features
-controlled by this option.
-</P>
-<P>
-<PRE>
- PCRE_MULTILINE
-</PRE>
-</P>
-<P>
-By default, PCRE treats the subject string as consisting of a single "line" of
-characters (even if it actually contains several newlines). The "start of line"
-metacharacter (^) matches only at the start of the string, while the "end of
-line" metacharacter ($) matches only at the end of the string, or before a
-terminating newline (unless PCRE_DOLLAR_ENDONLY is set). This is the same as
-Perl.
-</P>
-<P>
-When PCRE_MULTILINE it is set, the "start of line" and "end of line" constructs
-match immediately following or immediately before any newline in the subject
-string, respectively, as well as at the very start and end. This is equivalent
-to Perl's /m option. If there are no "\n" characters in a subject string, or
-no occurrences of ^ or $ in a pattern, setting PCRE_MULTILINE has no
-effect.
-</P>
-<P>
-<PRE>
- PCRE_UNGREEDY
-</PRE>
-</P>
-<P>
-This option inverts the "greediness" of the quantifiers so that they are not
-greedy by default, but become greedy if followed by "?". It is not compatible
-with Perl. It can also be set by a (?U) option setting within the pattern.
-</P>
-<LI><A NAME="SEC6" HREF="#TOC1">STUDYING A PATTERN</A>
-<P>
-When a pattern is going to be used several times, it is worth spending more
-time analyzing it in order to speed up the time taken for matching. The
-function <B>pcre_study()</B> takes a pointer to a compiled pattern as its first
-argument, and returns a pointer to a <B>pcre_extra</B> block (another <B>void</B>
-typedef) containing additional information about the pattern; this can be
-passed to <B>pcre_exec()</B>. If no additional information is available, NULL
-is returned.
-</P>
-<P>
-The second argument contains option bits. At present, no options are defined
-for <B>pcre_study()</B>, and this argument should always be zero.
-</P>
-<P>
-The third argument for <B>pcre_study()</B> is a pointer to an error message. If
-studying succeeds (even if no data is returned), the variable it points to is
-set to NULL. Otherwise it points to a textual error message.
-</P>
-<P>
-At present, studying a pattern is useful only for non-anchored patterns that do
-not have a single fixed starting character. A bitmap of possible starting
-characters is created.
-</P>
-<LI><A NAME="SEC7" HREF="#TOC1">LOCALE SUPPORT</A>
-<P>
-PCRE handles caseless matching, and determines whether characters are letters,
-digits, or whatever, by reference to a set of tables. The library contains a
-default set of tables which is created in the default C locale when PCRE is
-compiled. This is used when the final argument of <B>pcre_compile()</B> is NULL,
-and is sufficient for many applications.
-</P>
-<P>
-An alternative set of tables can, however, be supplied. Such tables are built
-by calling the <B>pcre_maketables()</B> function, which has no arguments, in the
-relevant locale. The result can then be passed to <B>pcre_compile()</B> as often
-as necessary. For example, to build and use tables that are appropriate for the
-French locale (where accented characters with codes greater than 128 are
-treated as letters), the following code could be used:
-</P>
-<P>
-<PRE>
- setlocale(LC_CTYPE, "fr");
- tables = pcre_maketables();
- re = pcre_compile(..., tables);
-</PRE>
-</P>
-<P>
-The tables are built in memory that is obtained via <B>pcre_malloc</B>. The
-pointer that is passed to <B>pcre_compile</B> is saved with the compiled
-pattern, and the same tables are used via this pointer by <B>pcre_study()</B>
-and <B>pcre_exec()</B>. Thus for any single pattern, compilation, studying and
-matching all happen in the same locale, but different patterns can be compiled
-in different locales. It is the caller's responsibility to ensure that the
-memory containing the tables remains available for as long as it is needed.
-</P>
-<LI><A NAME="SEC8" HREF="#TOC1">INFORMATION ABOUT A PATTERN</A>
-<P>
-The <B>pcre_info()</B> function returns information about a compiled pattern.
-Its yield is the number of capturing subpatterns, or one of the following
-negative numbers:
-</P>
-<P>
-<PRE>
- PCRE_ERROR_NULL the argument <I>code</I> was NULL
- PCRE_ERROR_BADMAGIC the "magic number" was not found
-</PRE>
-</P>
-<P>
-If the <I>optptr</I> argument is not NULL, a copy of the options with which the
-pattern was compiled is placed in the integer it points to. These option bits
-are those specified in the call to <B>pcre_compile()</B>, modified by any
-top-level option settings within the pattern itself, and with the PCRE_ANCHORED
-bit set if the form of the pattern implies that it can match only at the start
-of a subject string.
-</P>
-<P>
-If the pattern is not anchored and the <I>firstcharptr</I> argument is not NULL,
-it is used to pass back information about the first character of any matched
-string. If there is a fixed first character, e.g. from a pattern such as
-(cat|cow|coyote), then it is returned in the integer pointed to by
-<I>firstcharptr</I>. Otherwise, if either
-</P>
-<P>
-(a) the pattern was compiled with the PCRE_MULTILINE option, and every branch
-starts with "^", or
-</P>
-<P>
-(b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not set
-(if it were set, the pattern would be anchored),
-</P>
-<P>
-then -1 is returned, indicating that the pattern matches only at the
-start of a subject string or after any "\n" within the string. Otherwise -2 is
-returned.
-</P>
-<LI><A NAME="SEC9" HREF="#TOC1">MATCHING A PATTERN</A>
-<P>
-The function <B>pcre_exec()</B> is called to match a subject string against a
-pre-compiled pattern, which is passed in the <I>code</I> argument. If the
-pattern has been studied, the result of the study should be passed in the
-<I>extra</I> argument. Otherwise this must be NULL.
-</P>
-<P>
-The PCRE_ANCHORED option can be passed in the <I>options</I> argument, whose
-unused bits must be zero. However, if a pattern was compiled with
-PCRE_ANCHORED, or turned out to be anchored by virtue of its contents, it
-cannot be made unachored at matching time.
-</P>
-<P>
-There are also three further options that can be set only at matching time:
-</P>
-<P>
-<PRE>
- PCRE_NOTBOL
-</PRE>
-</P>
-<P>
-The first character of the string is not the beginning of a line, so the
-circumflex metacharacter should not match before it. Setting this without
-PCRE_MULTILINE (at compile time) causes circumflex never to match.
-</P>
-<P>
-<PRE>
- PCRE_NOTEOL
-</PRE>
-</P>
-<P>
-The end of the string is not the end of a line, so the dollar metacharacter
-should not match it nor (except in multiline mode) a newline immediately before
-it. Setting this without PCRE_MULTILINE (at compile time) causes dollar never
-to match.
-</P>
-<P>
-<PRE>
- PCRE_NOTEMPTY
-</PRE>
-</P>
-<P>
-An empty string is not considered to be a valid match if this option is set. If
-there are alternatives in the pattern, they are tried. If all the alternatives
-match the empty string, the entire match fails. For example, if the pattern
-</P>
-<P>
-<PRE>
- a?b?
-</PRE>
-</P>
-<P>
-is applied to a string not beginning with "a" or "b", it matches the empty
-string at the start of the subject. With PCRE_NOTEMPTY set, this match is not
-valid, so PCRE searches further into the string for occurrences of "a" or "b".
-Perl has no direct equivalent of this option, but it makes a special case of
-a pattern match of the empty string within its <B>split()</B> function, or when
-using the /g modifier. Using PCRE_NOTEMPTY it is possible to emulate this
-behaviour.
-</P>
-<P>
-The subject string is passed as a pointer in <I>subject</I>, a length in
-<I>length</I>, and a starting offset in <I>startoffset</I>. Unlike the pattern
-string, it may contain binary zero characters. When the starting offset is
-zero, the search for a match starts at the beginning of the subject, and this
-is by far the most common case.
-</P>
-<P>
-A non-zero starting offset is useful when searching for another match in the
-same subject by calling <B>pcre_exec()</B> again after a previous success.
-Setting <I>startoffset</I> differs from just passing over a shortened string and
-setting PCRE_NOTBOL in the case of a pattern that begins with any kind of
-lookbehind. For example, consider the pattern
-</P>
-<P>
-<PRE>
- \Biss\B
-</PRE>
-</P>
-<P>
-which finds occurrences of "iss" in the middle of words. (\B matches only if
-the current position in the subject is not a word boundary.) When applied to
-the string "Mississipi" the first call to <B>pcre_exec()</B> finds the first
-occurrence. If <B>pcre_exec()</B> is called again with just the remainder of the
-subject, namely "issipi", it does not match, because \B is always false at the
-start of the subject, which is deemed to be a word boundary. However, if
-<B>pcre_exec()</B> is passed the entire string again, but with <I>startoffset</I>
-set to 4, it finds the second occurrence of "iss" because it is able to look
-behind the starting point to discover that it is preceded by a letter.
-</P>
-<P>
-If a non-zero starting offset is passed when the pattern is anchored, one
-attempt to match at the given offset is tried. This can only succeed if the
-pattern does not require the match to be at the start of the subject.
-</P>
-<P>
-In general, a pattern matches a certain portion of the subject, and in
-addition, further substrings from the subject may be picked out by parts of the
-pattern. Following the usage in Jeffrey Friedl's book, this is called
-"capturing" in what follows, and the phrase "capturing subpattern" is used for
-a fragment of a pattern that picks out a substring. PCRE supports several other
-kinds of parenthesized subpattern that do not cause substrings to be captured.
-</P>
-<P>
-Captured substrings are returned to the caller via a vector of integer offsets
-whose address is passed in <I>ovector</I>. The number of elements in the vector
-is passed in <I>ovecsize</I>. The first two-thirds of the vector is used to pass
-back captured substrings, each substring using a pair of integers. The
-remaining third of the vector is used as workspace by <B>pcre_exec()</B> while
-matching capturing subpatterns, and is not available for passing back
-information. The length passed in <I>ovecsize</I> should always be a multiple of
-three. If it is not, it is rounded down.
-</P>
-<P>
-When a match has been successful, information about captured substrings is
-returned in pairs of integers, starting at the beginning of <I>ovector</I>, and
-continuing up to two-thirds of its length at the most. The first element of a
-pair is set to the offset of the first character in a substring, and the second
-is set to the offset of the first character after the end of a substring. The
-first pair, <I>ovector[0]</I> and <I>ovector[1]</I>, identify the portion of the
-subject string matched by the entire pattern. The next pair is used for the
-first capturing subpattern, and so on. The value returned by <B>pcre_exec()</B>
-is the number of pairs that have been set. If there are no capturing
-subpatterns, the return value from a successful match is 1, indicating that
-just the first pair of offsets has been set.
-</P>
-<P>
-Some convenience functions are provided for extracting the captured substrings
-as separate strings. These are described in the following section.
-</P>
-<P>
-It is possible for an capturing subpattern number <I>n+1</I> to match some
-part of the subject when subpattern <I>n</I> has not been used at all. For
-example, if the string "abc" is matched against the pattern (a|(z))(bc)
-subpatterns 1 and 3 are matched, but 2 is not. When this happens, both offset
-values corresponding to the unused subpattern are set to -1.
-</P>
-<P>
-If a capturing subpattern is matched repeatedly, it is the last portion of the
-string that it matched that gets returned.
-</P>
-<P>
-If the vector is too small to hold all the captured substrings, it is used as
-far as possible (up to two-thirds of its length), and the function returns a
-value of zero. In particular, if the substring offsets are not of interest,
-<B>pcre_exec()</B> may be called with <I>ovector</I> passed as NULL and
-<I>ovecsize</I> as zero. However, if the pattern contains back references and
-the <I>ovector</I> isn't big enough to remember the related substrings, PCRE has
-to get additional memory for use during matching. Thus it is usually advisable
-to supply an <I>ovector</I>.
-</P>
-<P>
-Note that <B>pcre_info()</B> can be used to find out how many capturing
-subpatterns there are in a compiled pattern. The smallest size for
-<I>ovector</I> that will allow for <I>n</I> captured substrings in addition to
-the offsets of the substring matched by the whole pattern is (<I>n</I>+1)*3.
-</P>
-<P>
-If <B>pcre_exec()</B> fails, it returns a negative number. The following are
-defined in the header file:
-</P>
-<P>
-<PRE>
- PCRE_ERROR_NOMATCH (-1)
-</PRE>
-</P>
-<P>
-The subject string did not match the pattern.
-</P>
-<P>
-<PRE>
- PCRE_ERROR_NULL (-2)
-</PRE>
-</P>
-<P>
-Either <I>code</I> or <I>subject</I> was passed as NULL, or <I>ovector</I> was
-NULL and <I>ovecsize</I> was not zero.
-</P>
-<P>
-<PRE>
- PCRE_ERROR_BADOPTION (-3)
-</PRE>
-</P>
-<P>
-An unrecognized bit was set in the <I>options</I> argument.
-</P>
-<P>
-<PRE>
- PCRE_ERROR_BADMAGIC (-4)
-</PRE>
-</P>
-<P>
-PCRE stores a 4-byte "magic number" at the start of the compiled code, to catch
-the case when it is passed a junk pointer. This is the error it gives when the
-magic number isn't present.
-</P>
-<P>
-<PRE>
- PCRE_ERROR_UNKNOWN_NODE (-5)
-</PRE>
-</P>
-<P>
-While running the pattern match, an unknown item was encountered in the
-compiled pattern. This error could be caused by a bug in PCRE or by overwriting
-of the compiled pattern.
-</P>
-<P>
-<PRE>
- PCRE_ERROR_NOMEMORY (-6)
-</PRE>
-</P>
-<P>
-If a pattern contains back references, but the <I>ovector</I> that is passed to
-<B>pcre_exec()</B> is not big enough to remember the referenced substrings, PCRE
-gets a block of memory at the start of matching to use for this purpose. If the
-call via <B>pcre_malloc()</B> fails, this error is given. The memory is freed at
-the end of matching.
-</P>
-<LI><A NAME="SEC10" HREF="#TOC1">EXTRACTING CAPTURED SUBSTRINGS</A>
-<P>
-Captured substrings can be accessed directly by using the offsets returned by
-<B>pcre_exec()</B> in <I>ovector</I>. For convenience, the functions
-<B>pcre_copy_substring()</B>, <B>pcre_get_substring()</B>, and
-<B>pcre_get_substring_list()</B> are provided for extracting captured substrings
-as new, separate, zero-terminated strings. A substring that contains a binary
-zero is correctly extracted and has a further zero added on the end, but the
-result does not, of course, function as a C string.
-</P>
-<P>
-The first three arguments are the same for all three functions: <I>subject</I>
-is the subject string which has just been successfully matched, <I>ovector</I>
-is a pointer to the vector of integer offsets that was passed to
-<B>pcre_exec()</B>, and <I>stringcount</I> is the number of substrings that
-were captured by the match, including the substring that matched the entire
-regular expression. This is the value returned by <B>pcre_exec</B> if it
-is greater than zero. If <B>pcre_exec()</B> returned zero, indicating that it
-ran out of space in <I>ovector</I>, then the value passed as
-<I>stringcount</I> should be the size of the vector divided by three.
-</P>
-<P>
-The functions <B>pcre_copy_substring()</B> and <B>pcre_get_substring()</B>
-extract a single substring, whose number is given as <I>stringnumber</I>. A
-value of zero extracts the substring that matched the entire pattern, while
-higher values extract the captured substrings. For <B>pcre_copy_substring()</B>,
-the string is placed in <I>buffer</I>, whose length is given by
-<I>buffersize</I>, while for <B>pcre_get_substring()</B> a new block of store is
-obtained via <B>pcre_malloc</B>, and its address is returned via
-<I>stringptr</I>. The yield of the function is the length of the string, not
-including the terminating zero, or one of
-</P>
-<P>
-<PRE>
- PCRE_ERROR_NOMEMORY (-6)
-</PRE>
-</P>
-<P>
-The buffer was too small for <B>pcre_copy_substring()</B>, or the attempt to get
-memory failed for <B>pcre_get_substring()</B>.
-</P>
-<P>
-<PRE>
- PCRE_ERROR_NOSUBSTRING (-7)
-</PRE>
-</P>
-<P>
-There is no substring whose number is <I>stringnumber</I>.
-</P>
-<P>
-The <B>pcre_get_substring_list()</B> function extracts all available substrings
-and builds a list of pointers to them. All this is done in a single block of
-memory which is obtained via <B>pcre_malloc</B>. The address of the memory block
-is returned via <I>listptr</I>, which is also the start of the list of string
-pointers. The end of the list is marked by a NULL pointer. The yield of the
-function is zero if all went well, or
-</P>
-<P>
-<PRE>
- PCRE_ERROR_NOMEMORY (-6)
-</PRE>
-</P>
-<P>
-if the attempt to get the memory block failed.
-</P>
-<P>
-When any of these functions encounter a substring that is unset, which can
-happen when capturing subpattern number <I>n+1</I> matches some part of the
-subject, but subpattern <I>n</I> has not been used at all, they return an empty
-string. This can be distinguished from a genuine zero-length substring by
-inspecting the appropriate offset in <I>ovector</I>, which is negative for unset
-substrings.
-</P>
-<LI><A NAME="SEC11" HREF="#TOC1">LIMITATIONS</A>
-<P>
-There are some size limitations in PCRE but it is hoped that they will never in
-practice be relevant.
-The maximum length of a compiled pattern is 65539 (sic) bytes.
-All values in repeating quantifiers must be less than 65536.
-The maximum number of capturing subpatterns is 99.
-The maximum number of all parenthesized subpatterns, including capturing
-subpatterns, assertions, and other types of subpattern, is 200.
-</P>
-<P>
-The maximum length of a subject string is the largest positive number that an
-integer variable can hold. However, PCRE uses recursion to handle subpatterns
-and indefinite repetition. This means that the available stack space may limit
-the size of a subject string that can be processed by certain patterns.
-</P>
-<LI><A NAME="SEC12" HREF="#TOC1">DIFFERENCES FROM PERL</A>
-<P>
-The differences described here are with respect to Perl 5.005.
-</P>
-<P>
-1. By default, a whitespace character is any character that the C library
-function <B>isspace()</B> recognizes, though it is possible to compile PCRE with
-alternative character type tables. Normally <B>isspace()</B> matches space,
-formfeed, newline, carriage return, horizontal tab, and vertical tab. Perl 5
-no longer includes vertical tab in its set of whitespace characters. The \v
-escape that was in the Perl documentation for a long time was never in fact
-recognized. However, the character itself was treated as whitespace at least
-up to 5.002. In 5.004 and 5.005 it does not match \s.
-</P>
-<P>
-2. PCRE does not allow repeat quantifiers on lookahead assertions. Perl permits
-them, but they do not mean what you might think. For example, (?!a){3} does
-not assert that the next three characters are not "a". It just asserts that the
-next character is not "a" three times.
-</P>
-<P>
-3. Capturing subpatterns that occur inside negative lookahead assertions are
-counted, but their entries in the offsets vector are never set. Perl sets its
-numerical variables from any such patterns that are matched before the
-assertion fails to match something (thereby succeeding), but only if the
-negative lookahead assertion contains just one branch.
-</P>
-<P>
-4. Though binary zero characters are supported in the subject string, they are
-not allowed in a pattern string because it is passed as a normal C string,
-terminated by zero. The escape sequence "\0" can be used in the pattern to
-represent a binary zero.
-</P>
-<P>
-5. The following Perl escape sequences are not supported: \l, \u, \L, \U,
-\E, \Q. In fact these are implemented by Perl's general string-handling and
-are not part of its pattern matching engine.
-</P>
-<P>
-6. The Perl \G assertion is not supported as it is not relevant to single
-pattern matches.
-</P>
-<P>
-7. Fairly obviously, PCRE does not support the (?{code}) construction.
-</P>
-<P>
-8. There are at the time of writing some oddities in Perl 5.005_02 concerned
-with the settings of captured strings when part of a pattern is repeated. For
-example, matching "aba" against the pattern /^(a(b)?)+$/ sets $2 to the value
-"b", but matching "aabbaa" against /^(aa(bb)?)+$/ leaves $2 unset. However, if
-the pattern is changed to /^(aa(b(b))?)+$/ then $2 (and $3) get set.
-</P>
-<P>
-In Perl 5.004 $2 is set in both cases, and that is also true of PCRE. If in the
-future Perl changes to a consistent state that is different, PCRE may change to
-follow.
-</P>
-<P>
-9. Another as yet unresolved discrepancy is that in Perl 5.005_02 the pattern
-/^(a)?(?(1)a|b)+$/ matches the string "a", whereas in PCRE it does not.
-However, in both Perl and PCRE /^(a)?a/ matched against "a" leaves $1 unset.
-</P>
-<P>
-10. PCRE provides some extensions to the Perl regular expression facilities:
-</P>
-<P>
-(a) Although lookbehind assertions must match fixed length strings, each
-alternative branch of a lookbehind assertion can match a different length of
-string. Perl 5.005 requires them all to have the same length.
-</P>
-<P>
-(b) If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not set, the $ meta-
-character matches only at the very end of the string.
-</P>
-<P>
-(c) If PCRE_EXTRA is set, a backslash followed by a letter with no special
-meaning is faulted.
-</P>
-<P>
-(d) If PCRE_UNGREEDY is set, the greediness of the repetition quantifiers is
-inverted, that is, by default they are not greedy, but if followed by a
-question mark they are.
-</P>
-<P>
-(e) PCRE_ANCHORED can be used to force a pattern to be tried only at the start
-of the subject.
-</P>
-<P>
-(f) The PCRE_NOTBOL, PCRE_NOTEOL, and PCRE_NOTEMPTY options for
-<B>pcre_exec()</B> have no Perl equivalents.
-</P>
-<LI><A NAME="SEC13" HREF="#TOC1">REGULAR EXPRESSION DETAILS</A>
-<P>
-The syntax and semantics of the regular expressions supported by PCRE are
-described below. Regular expressions are also described in the Perl
-documentation and in a number of other books, some of which have copious
-examples. Jeffrey Friedl's "Mastering Regular Expressions", published by
-O'Reilly (ISBN 1-56592-257-3), covers them in great detail. The description
-here is intended as reference documentation.
-</P>
-<P>
-A regular expression is a pattern that is matched against a subject string from
-left to right. Most characters stand for themselves in a pattern, and match the
-corresponding characters in the subject. As a trivial example, the pattern
-</P>
-<P>
-<PRE>
- The quick brown fox
-</PRE>
-</P>
-<P>
-matches a portion of a subject string that is identical to itself. The power of
-regular expressions comes from the ability to include alternatives and
-repetitions in the pattern. These are encoded in the pattern by the use of
-<I>meta-characters</I>, which do not stand for themselves but instead are
-interpreted in some special way.
-</P>
-<P>
-There are two different sets of meta-characters: those that are recognized
-anywhere in the pattern except within square brackets, and those that are
-recognized in square brackets. Outside square brackets, the meta-characters are
-as follows:
-</P>
-<P>
-<PRE>
- \ general escape character with several uses
- ^ assert start of subject (or line, in multiline mode)
- $ assert end of subject (or line, in multiline mode)
- . match any character except newline (by default)
- [ start character class definition
- | start of alternative branch
- ( start subpattern
- ) end subpattern
- ? extends the meaning of (
- also 0 or 1 quantifier
- also quantifier minimizer
- * 0 or more quantifier
- + 1 or more quantifier
- { start min/max quantifier
-</PRE>
-</P>
-<P>
-Part of a pattern that is in square brackets is called a "character class". In
-a character class the only meta-characters are:
-</P>
-<P>
-<PRE>
- \ general escape character
- ^ negate the class, but only if the first character
- - indicates character range
- ] terminates the character class
-</PRE>
-</P>
-<P>
-The following sections describe the use of each of the meta-characters.
-</P>
-<LI><A NAME="SEC14" HREF="#TOC1">BACKSLASH</A>
-<P>
-The backslash character has several uses. Firstly, if it is followed by a
-non-alphameric character, it takes away any special meaning that character may
-have. This use of backslash as an escape character applies both inside and
-outside character classes.
-</P>
-<P>
-For example, if you want to match a "*" character, you write "\*" in the
-pattern. This applies whether or not the following character would otherwise be
-interpreted as a meta-character, so it is always safe to precede a
-non-alphameric with "\" to specify that it stands for itself. In particular,
-if you want to match a backslash, you write "\\".
-</P>
-<P>
-If a pattern is compiled with the PCRE_EXTENDED option, whitespace in the
-pattern (other than in a character class) and characters between a "#" outside
-a character class and the next newline character are ignored. An escaping
-backslash can be used to include a whitespace or "#" character as part of the
-pattern.
-</P>
-<P>
-A second use of backslash provides a way of encoding non-printing characters
-in patterns in a visible manner. There is no restriction on the appearance of
-non-printing characters, apart from the binary zero that terminates a pattern,
-but when a pattern is being prepared by text editing, it is usually easier to
-use one of the following escape sequences than the binary character it
-represents:
-</P>
-<P>
-<PRE>
- \a alarm, that is, the BEL character (hex 07)
- \cx "control-x", where x is any character
- \e escape (hex 1B)
- \f formfeed (hex 0C)
- \n newline (hex 0A)
- \r carriage return (hex 0D)
- \t tab (hex 09)
- \xhh character with hex code hh
- \ddd character with octal code ddd, or backreference
-</PRE>
-</P>
-<P>
-The precise effect of "\cx" is as follows: if "x" is a lower case letter, it
-is converted to upper case. Then bit 6 of the character (hex 40) is inverted.
-Thus "\cz" becomes hex 1A, but "\c{" becomes hex 3B, while "\c;" becomes hex
-7B.
-</P>
-<P>
-After "\x", up to two hexadecimal digits are read (letters can be in upper or
-lower case).
-</P>
-<P>
-After "\0" up to two further octal digits are read. In both cases, if there
-are fewer than two digits, just those that are present are used. Thus the
-sequence "\0\x\07" specifies two binary zeros followed by a BEL character.
-Make sure you supply two digits after the initial zero if the character that
-follows is itself an octal digit.
-</P>
-<P>
-The handling of a backslash followed by a digit other than 0 is complicated.
-Outside a character class, PCRE reads it and any following digits as a decimal
-number. If the number is less than 10, or if there have been at least that many
-previous capturing left parentheses in the expression, the entire sequence is
-taken as a <I>back reference</I>. A description of how this works is given
-later, following the discussion of parenthesized subpatterns.
-</P>
-<P>
-Inside a character class, or if the decimal number is greater than 9 and there
-have not been that many capturing subpatterns, PCRE re-reads up to three octal
-digits following the backslash, and generates a single byte from the least
-significant 8 bits of the value. Any subsequent digits stand for themselves.
-For example:
-</P>
-<P>
-<PRE>
- \040 is another way of writing a space
- \40 is the same, provided there are fewer than 40
- previous capturing subpatterns
- \7 is always a back reference
- \11 might be a back reference, or another way of
- writing a tab
- \011 is always a tab
- \0113 is a tab followed by the character "3"
- \113 is the character with octal code 113 (since there
- can be no more than 99 back references)
- \377 is a byte consisting entirely of 1 bits
- \81 is either a back reference, or a binary zero
- followed by the two characters "8" and "1"
-</PRE>
-</P>
-<P>
-Note that octal values of 100 or greater must not be introduced by a leading
-zero, because no more than three octal digits are ever read.
-</P>
-<P>
-All the sequences that define a single byte value can be used both inside and
-outside character classes. In addition, inside a character class, the sequence
-"\b" is interpreted as the backspace character (hex 08). Outside a character
-class it has a different meaning (see below).
-</P>
-<P>
-The third use of backslash is for specifying generic character types:
-</P>
-<P>
-<PRE>
- \d any decimal digit
- \D any character that is not a decimal digit
- \s any whitespace character
- \S any character that is not a whitespace character
- \w any "word" character
- \W any "non-word" character
-</PRE>
-</P>
-<P>
-Each pair of escape sequences partitions the complete set of characters into
-two disjoint sets. Any given character matches one, and only one, of each pair.
-</P>
-<P>
-A "word" character is any letter or digit or the underscore character, that is,
-any character which can be part of a Perl "word". The definition of letters and
-digits is controlled by PCRE's character tables, and may vary if locale-
-specific matching is taking place (see "Locale support" above). For example, in
-the "fr" (French) locale, some character codes greater than 128 are used for
-accented letters, and these are matched by \w.
-</P>
-<P>
-These character type sequences can appear both inside and outside character
-classes. They each match one character of the appropriate type. If the current
-matching point is at the end of the subject string, all of them fail, since
-there is no character to match.
-</P>
-<P>
-The fourth use of backslash is for certain simple assertions. An assertion
-specifies a condition that has to be met at a particular point in a match,
-without consuming any characters from the subject string. The use of
-subpatterns for more complicated assertions is described below. The backslashed
-assertions are
-</P>
-<P>
-<PRE>
- \b word boundary
- \B not a word boundary
- \A start of subject (independent of multiline mode)
- \Z end of subject or newline at end (independent of multiline mode)
- \z end of subject (independent of multiline mode)
-</PRE>
-</P>
-<P>
-These assertions may not appear in character classes (but note that "\b" has a
-different meaning, namely the backspace character, inside a character class).
-</P>
-<P>
-A word boundary is a position in the subject string where the current character
-and the previous character do not both match \w or \W (i.e. one matches
-\w and the other matches \W), or the start or end of the string if the
-first or last character matches \w, respectively.
-</P>
-<P>
-The \A, \Z, and \z assertions differ from the traditional circumflex and
-dollar (described below) in that they only ever match at the very start and end
-of the subject string, whatever options are set. They are not affected by the
-PCRE_NOTBOL or PCRE_NOTEOL options. If the <I>startoffset</I> argument of
-<B>pcre_exec()</B> is non-zero, \A can never match. The difference between \Z
-and \z is that \Z matches before a newline that is the last character of the
-string as well as at the end of the string, whereas \z matches only at the
-end.
-</P>
-<LI><A NAME="SEC15" HREF="#TOC1">CIRCUMFLEX AND DOLLAR</A>
-<P>
-Outside a character class, in the default matching mode, the circumflex
-character is an assertion which is true only if the current matching point is
-at the start of the subject string. If the <I>startoffset</I> argument of
-<B>pcre_exec()</B> is non-zero, circumflex can never match. Inside a character
-class, circumflex has an entirely different meaning (see below).
-</P>
-<P>
-Circumflex need not be the first character of the pattern if a number of
-alternatives are involved, but it should be the first thing in each alternative
-in which it appears if the pattern is ever to match that branch. If all
-possible alternatives start with a circumflex, that is, if the pattern is
-constrained to match only at the start of the subject, it is said to be an
-"anchored" pattern. (There are also other constructs that can cause a pattern
-to be anchored.)
-</P>
-<P>
-A dollar character is an assertion which is true only if the current matching
-point is at the end of the subject string, or immediately before a newline
-character that is the last character in the string (by default). Dollar need
-not be the last character of the pattern if a number of alternatives are
-involved, but it should be the last item in any branch in which it appears.
-Dollar has no special meaning in a character class.
-</P>
-<P>
-The meaning of dollar can be changed so that it matches only at the very end of
-the string, by setting the PCRE_DOLLAR_ENDONLY option at compile or matching
-time. This does not affect the \Z assertion.
-</P>
-<P>
-The meanings of the circumflex and dollar characters are changed if the
-PCRE_MULTILINE option is set. When this is the case, they match immediately
-after and immediately before an internal "\n" character, respectively, in
-addition to matching at the start and end of the subject string. For example,
-the pattern /^abc$/ matches the subject string "def\nabc" in multiline mode,
-but not otherwise. Consequently, patterns that are anchored in single line mode
-because all branches start with "^" are not anchored in multiline mode, and a
-match for circumflex is possible when the <I>startoffset</I> argument of
-<B>pcre_exec()</B> is non-zero. The PCRE_DOLLAR_ENDONLY option is ignored if
-PCRE_MULTILINE is set.
-</P>
-<P>
-Note that the sequences \A, \Z, and \z can be used to match the start and
-end of the subject in both modes, and if all branches of a pattern start with
-\A is it always anchored, whether PCRE_MULTILINE is set or not.
-</P>
-<LI><A NAME="SEC16" HREF="#TOC1">FULL STOP (PERIOD, DOT)</A>
-<P>
-Outside a character class, a dot in the pattern matches any one character in
-the subject, including a non-printing character, but not (by default) newline.
-If the PCRE_DOTALL option is set, then dots match newlines as well. The
-handling of dot is entirely independent of the handling of circumflex and
-dollar, the only relationship being that they both involve newline characters.
-Dot has no special meaning in a character class.
-</P>
-<LI><A NAME="SEC17" HREF="#TOC1">SQUARE BRACKETS</A>
-<P>
-An opening square bracket introduces a character class, terminated by a closing
-square bracket. A closing square bracket on its own is not special. If a
-closing square bracket is required as a member of the class, it should be the
-first data character in the class (after an initial circumflex, if present) or
-escaped with a backslash.
-</P>
-<P>
-A character class matches a single character in the subject; the character must
-be in the set of characters defined by the class, unless the first character in
-the class is a circumflex, in which case the subject character must not be in
-the set defined by the class. If a circumflex is actually required as a member
-of the class, ensure it is not the first character, or escape it with a
-backslash.
-</P>
-<P>
-For example, the character class [aeiou] matches any lower case vowel, while
-[^aeiou] matches any character that is not a lower case vowel. Note that a
-circumflex is just a convenient notation for specifying the characters which
-are in the class by enumerating those that are not. It is not an assertion: it
-still consumes a character from the subject string, and fails if the current
-pointer is at the end of the string.
-</P>
-<P>
-When caseless matching is set, any letters in a class represent both their
-upper case and lower case versions, so for example, a caseless [aeiou] matches
-"A" as well as "a", and a caseless [^aeiou] does not match "A", whereas a
-caseful version would.
-</P>
-<P>
-The newline character is never treated in any special way in character classes,
-whatever the setting of the PCRE_DOTALL or PCRE_MULTILINE options is. A class
-such as [^a] will always match a newline.
-</P>
-<P>
-The minus (hyphen) character can be used to specify a range of characters in a
-character class. For example, [d-m] matches any letter between d and m,
-inclusive. If a minus character is required in a class, it must be escaped with
-a backslash or appear in a position where it cannot be interpreted as
-indicating a range, typically as the first or last character in the class.
-</P>
-<P>
-It is not possible to have the literal character "]" as the end character of a
-range. A pattern such as [W-]46] is interpreted as a class of two characters
-("W" and "-") followed by a literal string "46]", so it would match "W46]" or
-"-46]". However, if the "]" is escaped with a backslash it is interpreted as
-the end of range, so [W-\]46] is interpreted as a single class containing a
-range followed by two separate characters. The octal or hexadecimal
-representation of "]" can also be used to end a range.
-</P>
-<P>
-Ranges operate in ASCII collating sequence. They can also be used for
-characters specified numerically, for example [\000-\037]. If a range that
-includes letters is used when caseless matching is set, it matches the letters
-in either case. For example, [W-c] is equivalent to [][\^_`wxyzabc], matched
-caselessly, and if character tables for the "fr" locale are in use,
-[\xc8-\xcb] matches accented E characters in both cases.
-</P>
-<P>
-The character types \d, \D, \s, \S, \w, and \W may also appear in a
-character class, and add the characters that they match to the class. For
-example, [\dABCDEF] matches any hexadecimal digit. A circumflex can
-conveniently be used with the upper case character types to specify a more
-restricted set of characters than the matching lower case type. For example,
-the class [^\W_] matches any letter or digit, but not underscore.
-</P>
-<P>
-All non-alphameric characters other than \, -, ^ (at the start) and the
-terminating ] are non-special in character classes, but it does no harm if they
-are escaped.
-</P>
-<LI><A NAME="SEC18" HREF="#TOC1">VERTICAL BAR</A>
-<P>
-Vertical bar characters are used to separate alternative patterns. For example,
-the pattern
-</P>
-<P>
-<PRE>
- gilbert|sullivan
-</PRE>
-</P>
-<P>
-matches either "gilbert" or "sullivan". Any number of alternatives may appear,
-and an empty alternative is permitted (matching the empty string).
-The matching process tries each alternative in turn, from left to right,
-and the first one that succeeds is used. If the alternatives are within a
-subpattern (defined below), "succeeds" means matching the rest of the main
-pattern as well as the alternative in the subpattern.
-</P>
-<LI><A NAME="SEC19" HREF="#TOC1">INTERNAL OPTION SETTING</A>
-<P>
-The settings of PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, and PCRE_EXTENDED
-can be changed from within the pattern by a sequence of Perl option letters
-enclosed between "(?" and ")". The option letters are
-</P>
-<P>
-<PRE>
- i for PCRE_CASELESS
- m for PCRE_MULTILINE
- s for PCRE_DOTALL
- x for PCRE_EXTENDED
-</PRE>
-</P>
-<P>
-For example, (?im) sets caseless, multiline matching. It is also possible to
-unset these options by preceding the letter with a hyphen, and a combined
-setting and unsetting such as (?im-sx), which sets PCRE_CASELESS and
-PCRE_MULTILINE while unsetting PCRE_DOTALL and PCRE_EXTENDED, is also
-permitted. If a letter appears both before and after the hyphen, the option is
-unset.
-</P>
-<P>
-The scope of these option changes depends on where in the pattern the setting
-occurs. For settings that are outside any subpattern (defined below), the
-effect is the same as if the options were set or unset at the start of
-matching. The following patterns all behave in exactly the same way:
-</P>
-<P>
-<PRE>
- (?i)abc
- a(?i)bc
- ab(?i)c
- abc(?i)
-</PRE>
-</P>
-<P>
-which in turn is the same as compiling the pattern abc with PCRE_CASELESS set.
-In other words, such "top level" settings apply to the whole pattern (unless
-there are other changes inside subpatterns). If there is more than one setting
-of the same option at top level, the rightmost setting is used.
-</P>
-<P>
-If an option change occurs inside a subpattern, the effect is different. This
-is a change of behaviour in Perl 5.005. An option change inside a subpattern
-affects only that part of the subpattern that follows it, so
-</P>
-<P>
-<PRE>
- (a(?i)b)c
-</PRE>
-</P>
-<P>
-matches abc and aBc and no other strings (assuming PCRE_CASELESS is not used).
-By this means, options can be made to have different settings in different
-parts of the pattern. Any changes made in one alternative do carry on
-into subsequent branches within the same subpattern. For example,
-</P>
-<P>
-<PRE>
- (a(?i)b|c)
-</PRE>
-</P>
-<P>
-matches "ab", "aB", "c", and "C", even though when matching "C" the first
-branch is abandoned before the option setting. This is because the effects of
-option settings happen at compile time. There would be some very weird
-behaviour otherwise.
-</P>
-<P>
-The PCRE-specific options PCRE_UNGREEDY and PCRE_EXTRA can be changed in the
-same way as the Perl-compatible options by using the characters U and X
-respectively. The (?X) flag setting is special in that it must always occur
-earlier in the pattern than any of the additional features it turns on, even
-when it is at top level. It is best put at the start.
-</P>
-<LI><A NAME="SEC20" HREF="#TOC1">SUBPATTERNS</A>
-<P>
-Subpatterns are delimited by parentheses (round brackets), which can be nested.
-Marking part of a pattern as a subpattern does two things:
-</P>
-<P>
-1. It localizes a set of alternatives. For example, the pattern
-</P>
-<P>
-<PRE>
- cat(aract|erpillar|)
-</PRE>
-</P>
-<P>
-matches one of the words "cat", "cataract", or "caterpillar". Without the
-parentheses, it would match "cataract", "erpillar" or the empty string.
-</P>
-<P>
-2. It sets up the subpattern as a capturing subpattern (as defined above).
-When the whole pattern matches, that portion of the subject string that matched
-the subpattern is passed back to the caller via the <I>ovector</I> argument of
-<B>pcre_exec()</B>. Opening parentheses are counted from left to right (starting
-from 1) to obtain the numbers of the capturing subpatterns.
-</P>
-<P>
-For example, if the string "the red king" is matched against the pattern
-</P>
-<P>
-<PRE>
- the ((red|white) (king|queen))
-</PRE>
-</P>
-<P>
-the captured substrings are "red king", "red", and "king", and are numbered 1,
-2, and 3.
-</P>
-<P>
-The fact that plain parentheses fulfil two functions is not always helpful.
-There are often times when a grouping subpattern is required without a
-capturing requirement. If an opening parenthesis is followed by "?:", the
-subpattern does not do any capturing, and is not counted when computing the
-number of any subsequent capturing subpatterns. For example, if the string "the
-white queen" is matched against the pattern
-</P>
-<P>
-<PRE>
- the ((?:red|white) (king|queen))
-</PRE>
-</P>
-<P>
-the captured substrings are "white queen" and "queen", and are numbered 1 and
-2. The maximum number of captured substrings is 99, and the maximum number of
-all subpatterns, both capturing and non-capturing, is 200.
-</P>
-<P>
-As a convenient shorthand, if any option settings are required at the start of
-a non-capturing subpattern, the option letters may appear between the "?" and
-the ":". Thus the two patterns
-</P>
-<P>
-<PRE>
- (?i:saturday|sunday)
- (?:(?i)saturday|sunday)
-</PRE>
-</P>
-<P>
-match exactly the same set of strings. Because alternative branches are tried
-from left to right, and options are not reset until the end of the subpattern
-is reached, an option setting in one branch does affect subsequent branches, so
-the above patterns match "SUNDAY" as well as "Saturday".
-</P>
-<LI><A NAME="SEC21" HREF="#TOC1">REPETITION</A>
-<P>
-Repetition is specified by quantifiers, which can follow any of the following
-items:
-</P>
-<P>
-<PRE>
- a single character, possibly escaped
- the . metacharacter
- a character class
- a back reference (see next section)
- a parenthesized subpattern (unless it is an assertion - see below)
-</PRE>
-</P>
-<P>
-The general repetition quantifier specifies a minimum and maximum number of
-permitted matches, by giving the two numbers in curly brackets (braces),
-separated by a comma. The numbers must be less than 65536, and the first must
-be less than or equal to the second. For example:
-</P>
-<P>
-<PRE>
- z{2,4}
-</PRE>
-</P>
-<P>
-matches "zz", "zzz", or "zzzz". A closing brace on its own is not a special
-character. If the second number is omitted, but the comma is present, there is
-no upper limit; if the second number and the comma are both omitted, the
-quantifier specifies an exact number of required matches. Thus
-</P>
-<P>
-<PRE>
- [aeiou]{3,}
-</PRE>
-</P>
-<P>
-matches at least 3 successive vowels, but may match many more, while
-</P>
-<P>
-<PRE>
- \d{8}
-</PRE>
-</P>
-<P>
-matches exactly 8 digits. An opening curly bracket that appears in a position
-where a quantifier is not allowed, or one that does not match the syntax of a
-quantifier, is taken as a literal character. For example, {,6} is not a
-quantifier, but a literal string of four characters.
-</P>
-<P>
-The quantifier {0} is permitted, causing the expression to behave as if the
-previous item and the quantifier were not present.
-</P>
-<P>
-For convenience (and historical compatibility) the three most common
-quantifiers have single-character abbreviations:
-</P>
-<P>
-<PRE>
- * is equivalent to {0,}
- + is equivalent to {1,}
- ? is equivalent to {0,1}
-</PRE>
-</P>
-<P>
-It is possible to construct infinite loops by following a subpattern that can
-match no characters with a quantifier that has no upper limit, for example:
-</P>
-<P>
-<PRE>
- (a?)*
-</PRE>
-</P>
-<P>
-Earlier versions of Perl and PCRE used to give an error at compile time for
-such patterns. However, because there are cases where this can be useful, such
-patterns are now accepted, but if any repetition of the subpattern does in fact
-match no characters, the loop is forcibly broken.
-</P>
-<P>
-By default, the quantifiers are "greedy", that is, they match as much as
-possible (up to the maximum number of permitted times), without causing the
-rest of the pattern to fail. The classic example of where this gives problems
-is in trying to match comments in C programs. These appear between the
-sequences /* and */ and within the sequence, individual * and / characters may
-appear. An attempt to match C comments by applying the pattern
-</P>
-<P>
-<PRE>
- /\*.*\*/
-</PRE>
-</P>
-<P>
-to the string
-</P>
-<P>
-<PRE>
- /* first command */ not comment /* second comment */
-</PRE>
-</P>
-<P>
-fails, because it matches the entire string due to the greediness of the .*
-item.
-</P>
-<P>
-However, if a quantifier is followed by a question mark, then it ceases to be
-greedy, and instead matches the minimum number of times possible, so the
-pattern
-</P>
-<P>
-<PRE>
- /\*.*?\*/
-</PRE>
-</P>
-<P>
-does the right thing with the C comments. The meaning of the various
-quantifiers is not otherwise changed, just the preferred number of matches.
-Do not confuse this use of question mark with its use as a quantifier in its
-own right. Because it has two uses, it can sometimes appear doubled, as in
-</P>
-<P>
-<PRE>
- \d??\d
-</PRE>
-</P>
-<P>
-which matches one digit by preference, but can match two if that is the only
-way the rest of the pattern matches.
-</P>
-<P>
-If the PCRE_UNGREEDY option is set (an option which is not available in Perl)
-then the quantifiers are not greedy by default, but individual ones can be made
-greedy by following them with a question mark. In other words, it inverts the
-default behaviour.
-</P>
-<P>
-When a parenthesized subpattern is quantified with a minimum repeat count that
-is greater than 1 or with a limited maximum, more store is required for the
-compiled pattern, in proportion to the size of the minimum or maximum.
-</P>
-<P>
-If a pattern starts with .* or .{0,} and the PCRE_DOTALL option (equivalent
-to Perl's /s) is set, thus allowing the . to match newlines, then the pattern
-is implicitly anchored, because whatever follows will be tried against every
-character position in the subject string, so there is no point in retrying the
-overall match at any position after the first. PCRE treats such a pattern as
-though it were preceded by \A. In cases where it is known that the subject
-string contains no newlines, it is worth setting PCRE_DOTALL when the pattern
-begins with .* in order to obtain this optimization, or alternatively using ^
-to indicate anchoring explicitly.
-</P>
-<P>
-When a capturing subpattern is repeated, the value captured is the substring
-that matched the final iteration. For example, after
-</P>
-<P>
-<PRE>
- (tweedle[dume]{3}\s*)+
-</PRE>
-</P>
-<P>
-has matched "tweedledum tweedledee" the value of the captured substring is
-"tweedledee". However, if there are nested capturing subpatterns, the
-corresponding captured values may have been set in previous iterations. For
-example, after
-</P>
-<P>
-<PRE>
- /(a|(b))+/
-</PRE>
-</P>
-<P>
-matches "aba" the value of the second captured substring is "b".
-</P>
-<LI><A NAME="SEC22" HREF="#TOC1">BACK REFERENCES</A>
-<P>
-Outside a character class, a backslash followed by a digit greater than 0 (and
-possibly further digits) is a back reference to a capturing subpattern earlier
-(i.e. to its left) in the pattern, provided there have been that many previous
-capturing left parentheses.
-</P>
-<P>
-However, if the decimal number following the backslash is less than 10, it is
-always taken as a back reference, and causes an error only if there are not
-that many capturing left parentheses in the entire pattern. In other words, the
-parentheses that are referenced need not be to the left of the reference for
-numbers less than 10. See the section entitled "Backslash" above for further
-details of the handling of digits following a backslash.
-</P>
-<P>
-A back reference matches whatever actually matched the capturing subpattern in
-the current subject string, rather than anything matching the subpattern
-itself. So the pattern
-</P>
-<P>
-<PRE>
- (sens|respons)e and \1ibility
-</PRE>
-</P>
-<P>
-matches "sense and sensibility" and "response and responsibility", but not
-"sense and responsibility". If caseful matching is in force at the time of the
-back reference, then the case of letters is relevant. For example,
-</P>
-<P>
-<PRE>
- ((?i)rah)\s+\1
-</PRE>
-</P>
-<P>
-matches "rah rah" and "RAH RAH", but not "RAH rah", even though the original
-capturing subpattern is matched caselessly.
-</P>
-<P>
-There may be more than one back reference to the same subpattern. If a
-subpattern has not actually been used in a particular match, then any back
-references to it always fail. For example, the pattern
-</P>
-<P>
-<PRE>
- (a|(bc))\2
-</PRE>
-</P>
-<P>
-always fails if it starts to match "a" rather than "bc". Because there may be
-up to 99 back references, all digits following the backslash are taken
-as part of a potential back reference number. If the pattern continues with a
-digit character, then some delimiter must be used to terminate the back
-reference. If the PCRE_EXTENDED option is set, this can be whitespace.
-Otherwise an empty comment can be used.
-</P>
-<P>
-A back reference that occurs inside the parentheses to which it refers fails
-when the subpattern is first used, so, for example, (a\1) never matches.
-However, such references can be useful inside repeated subpatterns. For
-example, the pattern
-</P>
-<P>
-<PRE>
- (a|b\1)+
-</PRE>
-</P>
-<P>
-matches any number of "a"s and also "aba", "ababaa" etc. At each iteration of
-the subpattern, the back reference matches the character string corresponding
-to the previous iteration. In order for this to work, the pattern must be such
-that the first iteration does not need to match the back reference. This can be
-done using alternation, as in the example above, or by a quantifier with a
-minimum of zero.
-</P>
-<LI><A NAME="SEC23" HREF="#TOC1">ASSERTIONS</A>
-<P>
-An assertion is a test on the characters following or preceding the current
-matching point that does not actually consume any characters. The simple
-assertions coded as \b, \B, \A, \Z, \z, ^ and $ are described above. More
-complicated assertions are coded as subpatterns. There are two kinds: those
-that look ahead of the current position in the subject string, and those that
-look behind it.
-</P>
-<P>
-An assertion subpattern is matched in the normal way, except that it does not
-cause the current matching position to be changed. Lookahead assertions start
-with (?= for positive assertions and (?! for negative assertions. For example,
-</P>
-<P>
-<PRE>
- \w+(?=;)
-</PRE>
-</P>
-<P>
-matches a word followed by a semicolon, but does not include the semicolon in
-the match, and
-</P>
-<P>
-<PRE>
- foo(?!bar)
-</PRE>
-</P>
-<P>
-matches any occurrence of "foo" that is not followed by "bar". Note that the
-apparently similar pattern
-</P>
-<P>
-<PRE>
- (?!foo)bar
-</PRE>
-</P>
-<P>
-does not find an occurrence of "bar" that is preceded by something other than
-"foo"; it finds any occurrence of "bar" whatsoever, because the assertion
-(?!foo) is always true when the next three characters are "bar". A
-lookbehind assertion is needed to achieve this effect.
-</P>
-<P>
-Lookbehind assertions start with (?&#60;= for positive assertions and (?&#60;! for
-negative assertions. For example,
-</P>
-<P>
-<PRE>
- (?&#60;!foo)bar
-</PRE>
-</P>
-<P>
-does find an occurrence of "bar" that is not preceded by "foo". The contents of
-a lookbehind assertion are restricted such that all the strings it matches must
-have a fixed length. However, if there are several alternatives, they do not
-all have to have the same fixed length. Thus
-</P>
-<P>
-<PRE>
- (?&#60;=bullock|donkey)
-</PRE>
-</P>
-<P>
-is permitted, but
-</P>
-<P>
-<PRE>
- (?&#60;!dogs?|cats?)
-</PRE>
-</P>
-<P>
-causes an error at compile time. Branches that match different length strings
-are permitted only at the top level of a lookbehind assertion. This is an
-extension compared with Perl 5.005, which requires all branches to match the
-same length of string. An assertion such as
-</P>
-<P>
-<PRE>
- (?&#60;=ab(c|de))
-</PRE>
-</P>
-<P>
-is not permitted, because its single top-level branch can match two different
-lengths, but it is acceptable if rewritten to use two top-level branches:
-</P>
-<P>
-<PRE>
- (?&#60;=abc|abde)
-</PRE>
-</P>
-<P>
-The implementation of lookbehind assertions is, for each alternative, to
-temporarily move the current position back by the fixed width and then try to
-match. If there are insufficient characters before the current position, the
-match is deemed to fail. Lookbehinds in conjunction with once-only subpatterns
-can be particularly useful for matching at the ends of strings; an example is
-given at the end of the section on once-only subpatterns.
-</P>
-<P>
-Several assertions (of any sort) may occur in succession. For example,
-</P>
-<P>
-<PRE>
- (?&#60;=\d{3})(?&#60;!999)foo
-</PRE>
-</P>
-<P>
-matches "foo" preceded by three digits that are not "999". Notice that each of
-the assertions is applied independently at the same point in the subject
-string. First there is a check that the previous three characters are all
-digits, then there is a check that the same three characters are not "999".
-This pattern does <I>not</I> match "foo" preceded by six characters, the first
-of which are digits and the last three of which are not "999". For example, it
-doesn't match "123abcfoo". A pattern to do that is
-</P>
-<P>
-<PRE>
- (?&#60;=\d{3}...)(?&#60;!999)foo
-</PRE>
-</P>
-<P>
-This time the first assertion looks at the preceding six characters, checking
-that the first three are digits, and then the second assertion checks that the
-preceding three characters are not "999".
-</P>
-<P>
-Assertions can be nested in any combination. For example,
-</P>
-<P>
-<PRE>
- (?&#60;=(?&#60;!foo)bar)baz
-</PRE>
-</P>
-<P>
-matches an occurrence of "baz" that is preceded by "bar" which in turn is not
-preceded by "foo", while
-</P>
-<P>
-<PRE>
- (?&#60;=\d{3}(?!999)...)foo
-</PRE>
-</P>
-<P>
-is another pattern which matches "foo" preceded by three digits and any three
-characters that are not "999".
-</P>
-<P>
-Assertion subpatterns are not capturing subpatterns, and may not be repeated,
-because it makes no sense to assert the same thing several times. If any kind
-of assertion contains capturing subpatterns within it, these are counted for
-the purposes of numbering the capturing subpatterns in the whole pattern.
-However, substring capturing is carried out only for positive assertions,
-because it does not make sense for negative assertions.
-</P>
-<P>
-Assertions count towards the maximum of 200 parenthesized subpatterns.
-</P>
-<LI><A NAME="SEC24" HREF="#TOC1">ONCE-ONLY SUBPATTERNS</A>
-<P>
-With both maximizing and minimizing repetition, failure of what follows
-normally causes the repeated item to be re-evaluated to see if a different
-number of repeats allows the rest of the pattern to match. Sometimes it is
-useful to prevent this, either to change the nature of the match, or to cause
-it fail earlier than it otherwise might, when the author of the pattern knows
-there is no point in carrying on.
-</P>
-<P>
-Consider, for example, the pattern \d+foo when applied to the subject line
-</P>
-<P>
-<PRE>
- 123456bar
-</PRE>
-</P>
-<P>
-After matching all 6 digits and then failing to match "foo", the normal
-action of the matcher is to try again with only 5 digits matching the \d+
-item, and then with 4, and so on, before ultimately failing. Once-only
-subpatterns provide the means for specifying that once a portion of the pattern
-has matched, it is not to be re-evaluated in this way, so the matcher would
-give up immediately on failing to match "foo" the first time. The notation is
-another kind of special parenthesis, starting with (?&#62; as in this example:
-</P>
-<P>
-<PRE>
- (?&#62;\d+)bar
-</PRE>
-</P>
-<P>
-This kind of parenthesis "locks up" the part of the pattern it contains once
-it has matched, and a failure further into the pattern is prevented from
-backtracking into it. Backtracking past it to previous items, however, works as
-normal.
-</P>
-<P>
-An alternative description is that a subpattern of this type matches the string
-of characters that an identical standalone pattern would match, if anchored at
-the current point in the subject string.
-</P>
-<P>
-Once-only subpatterns are not capturing subpatterns. Simple cases such as the
-above example can be thought of as a maximizing repeat that must swallow
-everything it can. So, while both \d+ and \d+? are prepared to adjust the
-number of digits they match in order to make the rest of the pattern match,
-(?&#62;\d+) can only match an entire sequence of digits.
-</P>
-<P>
-This construction can of course contain arbitrarily complicated subpatterns,
-and it can be nested.
-</P>
-<P>
-Once-only subpatterns can be used in conjunction with lookbehind assertions to
-specify efficient matching at the end of the subject string. Consider a simple
-pattern such as
-</P>
-<P>
-<PRE>
- abcd$
-</PRE>
-</P>
-<P>
-when applied to a long string which does not match it. Because matching
-proceeds from left to right, PCRE will look for each "a" in the subject and
-then see if what follows matches the rest of the pattern. If the pattern is
-specified as
-</P>
-<P>
-<PRE>
- ^.*abcd$
-</PRE>
-</P>
-<P>
-then the initial .* matches the entire string at first, but when this fails, it
-backtracks to match all but the last character, then all but the last two
-characters, and so on. Once again the search for "a" covers the entire string,
-from right to left, so we are no better off. However, if the pattern is written
-as
-</P>
-<P>
-<PRE>
- ^(?&#62;.*)(?&#60;=abcd)
-</PRE>
-</P>
-<P>
-then there can be no backtracking for the .* item; it can match only the entire
-string. The subsequent lookbehind assertion does a single test on the last four
-characters. If it fails, the match fails immediately. For long strings, this
-approach makes a significant difference to the processing time.
-</P>
-<LI><A NAME="SEC25" HREF="#TOC1">CONDITIONAL SUBPATTERNS</A>
-<P>
-It is possible to cause the matching process to obey a subpattern
-conditionally or to choose between two alternative subpatterns, depending on
-the result of an assertion, or whether a previous capturing subpattern matched
-or not. The two possible forms of conditional subpattern are
-</P>
-<P>
-<PRE>
- (?(condition)yes-pattern)
- (?(condition)yes-pattern|no-pattern)
-</PRE>
-</P>
-<P>
-If the condition is satisfied, the yes-pattern is used; otherwise the
-no-pattern (if present) is used. If there are more than two alternatives in the
-subpattern, a compile-time error occurs.
-</P>
-<P>
-There are two kinds of condition. If the text between the parentheses consists
-of a sequence of digits, then the condition is satisfied if the capturing
-subpattern of that number has previously matched. Consider the following
-pattern, which contains non-significant white space to make it more readable
-(assume the PCRE_EXTENDED option) and to divide it into three parts for ease
-of discussion:
-</P>
-<P>
-<PRE>
- ( \( )? [^()]+ (?(1) \) )
-</PRE>
-</P>
-<P>
-The first part matches an optional opening parenthesis, and if that
-character is present, sets it as the first captured substring. The second part
-matches one or more characters that are not parentheses. The third part is a
-conditional subpattern that tests whether the first set of parentheses matched
-or not. If they did, that is, if subject started with an opening parenthesis,
-the condition is true, and so the yes-pattern is executed and a closing
-parenthesis is required. Otherwise, since no-pattern is not present, the
-subpattern matches nothing. In other words, this pattern matches a sequence of
-non-parentheses, optionally enclosed in parentheses.
-</P>
-<P>
-If the condition is not a sequence of digits, it must be an assertion. This may
-be a positive or negative lookahead or lookbehind assertion. Consider this
-pattern, again containing non-significant white space, and with the two
-alternatives on the second line:
-</P>
-<P>
-<PRE>
- (?(?=[^a-z]*[a-z])
- \d{2}[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} )
-</PRE>
-</P>
-<P>
-The condition is a positive lookahead assertion that matches an optional
-sequence of non-letters followed by a letter. In other words, it tests for the
-presence of at least one letter in the subject. If a letter is found, the
-subject is matched against the first alternative; otherwise it is matched
-against the second. This pattern matches strings in one of the two forms
-dd-aaa-dd or dd-dd-dd, where aaa are letters and dd are digits.
-</P>
-<LI><A NAME="SEC26" HREF="#TOC1">COMMENTS</A>
-<P>
-The sequence (?# marks the start of a comment which continues up to the next
-closing parenthesis. Nested parentheses are not permitted. The characters
-that make up a comment play no part in the pattern matching at all.
-</P>
-<P>
-If the PCRE_EXTENDED option is set, an unescaped # character outside a
-character class introduces a comment that continues up to the next newline
-character in the pattern.
-</P>
-<LI><A NAME="SEC27" HREF="#TOC1">PERFORMANCE</A>
-<P>
-Certain items that may appear in patterns are more efficient than others. It is
-more efficient to use a character class like [aeiou] than a set of alternatives
-such as (a|e|i|o|u). In general, the simplest construction that provides the
-required behaviour is usually the most efficient. Jeffrey Friedl's book
-contains a lot of discussion about optimizing regular expressions for efficient
-performance.
-</P>
-<P>
-When a pattern begins with .* and the PCRE_DOTALL option is set, the pattern is
-implicitly anchored by PCRE, since it can match only at the start of a subject
-string. However, if PCRE_DOTALL is not set, PCRE cannot make this optimization,
-because the . metacharacter does not then match a newline, and if the subject
-string contains newlines, the pattern may match from the character immediately
-following one of them instead of from the very start. For example, the pattern
-</P>
-<P>
-<PRE>
- (.*) second
-</PRE>
-</P>
-<P>
-matches the subject "first\nand second" (where \n stands for a newline
-character) with the first captured substring being "and". In order to do this,
-PCRE has to retry the match starting after every newline in the subject.
-</P>
-<P>
-If you are using such a pattern with subject strings that do not contain
-newlines, the best performance is obtained by setting PCRE_DOTALL, or starting
-the pattern with ^.* to indicate explicit anchoring. That saves PCRE from
-having to scan along the subject looking for a newline to restart at.
-</P>
-<P>
-Beware of patterns that contain nested indefinite repeats. These can take a
-long time to run when applied to a string that does not match. Consider the
-pattern fragment
-</P>
-<P>
-<PRE>
- (a+)*
-</PRE>
-</P>
-<P>
-This can match "aaaa" in 33 different ways, and this number increases very
-rapidly as the string gets longer. (The * repeat can match 0, 1, 2, 3, or 4
-times, and for each of those cases other than 0, the + repeats can match
-different numbers of times.) When the remainder of the pattern is such that the
-entire match is going to fail, PCRE has in principle to try every possible
-variation, and this can take an extremely long time.
-</P>
-<P>
-An optimization catches some of the more simple cases such as
-</P>
-<P>
-<PRE>
- (a+)*b
-</PRE>
-</P>
-<P>
-where a literal character follows. Before embarking on the standard matching
-procedure, PCRE checks that there is a "b" later in the subject string, and if
-there is not, it fails the match immediately. However, when there is no
-following literal this optimization cannot be used. You can see the difference
-by comparing the behaviour of
-</P>
-<P>
-<PRE>
- (a+)*\d
-</PRE>
-</P>
-<P>
-with the pattern above. The former gives a failure almost instantly when
-applied to a whole line of "a" characters, whereas the latter takes an
-appreciable time with strings longer than about 20 characters.
-</P>
-<LI><A NAME="SEC28" HREF="#TOC1">AUTHOR</A>
-<P>
-Philip Hazel &#60;ph10@cam.ac.uk&#62;
-<BR>
-University Computing Service,
-<BR>
-New Museums Site,
-<BR>
-Cambridge CB2 3QG, England.
-<BR>
-Phone: +44 1223 334714
-</P>
-<P>
-Last updated: 29 July 1999
-<BR>
-Copyright (c) 1997-1999 University of Cambridge.
diff --git a/ext/pcre/pcrelib/pcre.3.txt b/ext/pcre/pcrelib/pcre.3.txt
deleted file mode 100644
index 8bd367c215..0000000000
--- a/ext/pcre/pcrelib/pcre.3.txt
+++ /dev/null
@@ -1,1739 +0,0 @@
-NAME
- pcre - Perl-compatible regular expressions.
-
-
-
-SYNOPSIS
- #include <pcre.h>
-
- pcre *pcre_compile(const char *pattern, int options,
- const char **errptr, int *erroffset,
- const unsigned char *tableptr);
-
- pcre_extra *pcre_study(const pcre *code, int options,
- const char **errptr);
-
- int pcre_exec(const pcre *code, const pcre_extra *extra,
- const char *subject, int length, int startoffset,
- int options, int *ovector, int ovecsize);
-
- int pcre_copy_substring(const char *subject, int *ovector,
- int stringcount, int stringnumber, char *buffer,
- int buffersize);
-
- int pcre_get_substring(const char *subject, int *ovector,
- int stringcount, int stringnumber,
- const char **stringptr);
-
- int pcre_get_substring_list(const char *subject,
- int *ovector, int stringcount, const char ***listptr);
-
- const unsigned char *pcre_maketables(void);
-
- int pcre_info(const pcre *code, int *optptr, *firstcharptr);
-
- char *pcre_version(void);
-
- void *(*pcre_malloc)(size_t);
-
- void (*pcre_free)(void *);
-
-
-
-
-DESCRIPTION
- The PCRE library is a set of functions that implement regu-
- lar expression pattern matching using the same syntax and
- semantics as Perl 5, with just a few differences (see
- below). The current implementation corresponds to Perl
- 5.005.
-
- PCRE has its own native API, which is described in this
- document. There is also a set of wrapper functions that
- correspond to the POSIX API. These are described in the
- pcreposix documentation.
- The native API function prototypes are defined in the header
- file pcre.h, and on Unix systems the library itself is
- called libpcre.a, so can be accessed by adding -lpcre to the
- command for linking an application which calls it.
-
- The functions pcre_compile(), pcre_study(), and pcre_exec()
- are used for compiling and matching regular expressions,
- while pcre_copy_substring(), pcre_get_substring(), and
- pcre_get_substring_list() are convenience functions for
- extracting captured substrings from a matched subject
- string. The function pcre_maketables() is used (optionally)
- to build a set of character tables in the current locale for
- passing to pcre_compile().
-
- The function pcre_info() is used to find out information
- about a compiled pattern, while the function pcre_version()
- returns a pointer to a string containing the version of PCRE
- and its date of release.
-
- The global variables pcre_malloc and pcre_free initially
- contain the entry points of the standard malloc() and free()
- functions respectively. PCRE calls the memory management
- functions via these variables, so a calling program can
- replace them if it wishes to intercept the calls. This
- should be done before calling any PCRE functions.
-
-
-
-MULTI-THREADING
- The PCRE functions can be used in multi-threading applica-
- tions, with the proviso that the memory management functions
- pointed to by pcre_malloc and pcre_free are shared by all
- threads.
-
- The compiled form of a regular expression is not altered
- during matching, so the same compiled pattern can safely be
- used by several threads at once.
-
-
-
-COMPILING A PATTERN
- The function pcre_compile() is called to compile a pattern
- into an internal form. The pattern is a C string terminated
- by a binary zero, and is passed in the argument pattern. A
- pointer to a single block of memory that is obtained via
- pcre_malloc is returned. This contains the compiled code and
- related data. The pcre type is defined for this for conveni-
- ence, but in fact pcre is just a typedef for void, since the
- contents of the block are not externally defined. It is up
- to the caller to free the memory when it is no longer
- required.
-
- The size of a compiled pattern is roughly proportional to
- the length of the pattern string, except that each character
- class (other than those containing just a single character,
- negated or not) requires 33 bytes, and repeat quantifiers
- with a minimum greater than one or a bounded maximum cause
- the relevant portions of the compiled pattern to be repli-
- cated.
-
- The options argument contains independent bits that affect
- the compilation. It should be zero if no options are
- required. Some of the options, in particular, those that are
- compatible with Perl, can also be set and unset from within
- the pattern (see the detailed description of regular expres-
- sions below). For these options, the contents of the options
- argument specifies their initial settings at the start of
- compilation and execution. The PCRE_ANCHORED option can be
- set at the time of matching as well as at compile time.
-
- If errptr is NULL, pcre_compile() returns NULL immediately.
- Otherwise, if compilation of a pattern fails, pcre_compile()
- returns NULL, and sets the variable pointed to by errptr to
- point to a textual error message. The offset from the start
- of the pattern to the character where the error was
- discovered is placed in the variable pointed to by
- erroffset, which must not be NULL. If it is, an immediate
- error is given.
-
- If the final argument, tableptr, is NULL, PCRE uses a
- default set of character tables which are built when it is
- compiled, using the default C locale. Otherwise, tableptr
- must be the result of a call to pcre_maketables(). See the
- section on locale support below.
-
- The following option bits are defined in the header file:
-
- PCRE_ANCHORED
-
- If this bit is set, the pattern is forced to be "anchored",
- that is, it is constrained to match only at the start of the
- string which is being searched (the "subject string"). This
- effect can also be achieved by appropriate constructs in the
- pattern itself, which is the only way to do it in Perl.
-
- PCRE_CASELESS
-
- If this bit is set, letters in the pattern match both upper
- and lower case letters. It is equivalent to Perl's /i
- option.
-
- PCRE_DOLLAR_ENDONLY
-
- If this bit is set, a dollar metacharacter in the pattern
- matches only at the end of the subject string. Without this
- option, a dollar also matches immediately before the final
- character if it is a newline (but not before any other new-
- lines). The PCRE_DOLLAR_ENDONLY option is ignored if
- PCRE_MULTILINE is set. There is no equivalent to this option
- in Perl.
-
- PCRE_DOTALL
-
- If this bit is set, a dot metacharater in the pattern
- matches all characters, including newlines. Without it, new-
- lines are excluded. This option is equivalent to Perl's /s
- option. A negative class such as [^a] always matches a new-
- line character, independent of the setting of this option.
-
- PCRE_EXTENDED
-
- If this bit is set, whitespace data characters in the pat-
- tern are totally ignored except when escaped or inside a
- character class, and characters between an unescaped # out-
- side a character class and the next newline character,
- inclusive, are also ignored. This is equivalent to Perl's /x
- option, and makes it possible to include comments inside
- complicated patterns. Note, however, that this applies only
- to data characters. Whitespace characters may never appear
- within special character sequences in a pattern, for example
- within the sequence (?( which introduces a conditional sub-
- pattern.
-
- PCRE_EXTRA
-
- This option turns on additional functionality of PCRE that
- is incompatible with Perl. Any backslash in a pattern that
- is followed by a letter that has no special meaning causes
- an error, thus reserving these combinations for future
- expansion. By default, as in Perl, a backslash followed by a
- letter with no special meaning is treated as a literal.
- There are at present no other features controlled by this
- option.
-
- PCRE_MULTILINE
-
- By default, PCRE treats the subject string as consisting of
- a single "line" of characters (even if it actually contains
- several newlines). The "start of line" metacharacter (^)
- matches only at the start of the string, while the "end of
- line" metacharacter ($) matches only at the end of the
- string, or before a terminating newline (unless
- PCRE_DOLLAR_ENDONLY is set). This is the same as Perl.
-
- When PCRE_MULTILINE it is set, the "start of line" and "end
- of line" constructs match immediately following or
- immediately before any newline in the subject string,
- respectively, as well as at the very start and end. This is
- equivalent to Perl's /m option. If there are no "\n" charac-
- ters in a subject string, or no occurrences of ^ or $ in a
- pattern, setting PCRE_MULTILINE has no effect.
-
- PCRE_UNGREEDY
-
- This option inverts the "greediness" of the quantifiers so
- that they are not greedy by default, but become greedy if
- followed by "?". It is not compatible with Perl. It can also
- be set by a (?U) option setting within the pattern.
-
-
-
-STUDYING A PATTERN
- When a pattern is going to be used several times, it is
- worth spending more time analyzing it in order to speed up
- the time taken for matching. The function pcre_study() takes
- a pointer to a compiled pattern as its first argument, and
- returns a pointer to a pcre_extra block (another void
- typedef) containing additional information about the pat-
- tern; this can be passed to pcre_exec(). If no additional
- information is available, NULL is returned.
-
- The second argument contains option bits. At present, no
- options are defined for pcre_study(), and this argument
- should always be zero.
-
- The third argument for pcre_study() is a pointer to an error
- message. If studying succeeds (even if no data is returned),
- the variable it points to is set to NULL. Otherwise it
- points to a textual error message.
-
- At present, studying a pattern is useful only for non-
- anchored patterns that do not have a single fixed starting
- character. A bitmap of possible starting characters is
- created.
-
-
-
-LOCALE SUPPORT
- PCRE handles caseless matching, and determines whether char-
- acters are letters, digits, or whatever, by reference to a
- set of tables. The library contains a default set of tables
- which is created in the default C locale when PCRE is com-
- piled. This is used when the final argument of
- pcre_compile() is NULL, and is sufficient for many applica-
- tions.
-
- An alternative set of tables can, however, be supplied. Such
- tables are built by calling the pcre_maketables() function,
- which has no arguments, in the relevant locale. The result
- can then be passed to pcre_compile() as often as necessary.
- For example, to build and use tables that are appropriate
- for the French locale (where accented characters with codes
- greater than 128 are treated as letters), the following code
- could be used:
-
- setlocale(LC_CTYPE, "fr");
- tables = pcre_maketables();
- re = pcre_compile(..., tables);
-
- The tables are built in memory that is obtained via
- pcre_malloc. The pointer that is passed to pcre_compile is
- saved with the compiled pattern, and the same tables are
- used via this pointer by pcre_study() and pcre_exec(). Thus
- for any single pattern, compilation, studying and matching
- all happen in the same locale, but different patterns can be
- compiled in different locales. It is the caller's responsi-
- bility to ensure that the memory containing the tables
- remains available for as long as it is needed.
-
-
-
-INFORMATION ABOUT A PATTERN
- The pcre_info() function returns information about a com-
- piled pattern. Its yield is the number of capturing subpat-
- terns, or one of the following negative numbers:
-
- PCRE_ERROR_NULL the argument code was NULL
- PCRE_ERROR_BADMAGIC the "magic number" was not found
-
- If the optptr argument is not NULL, a copy of the options
- with which the pattern was compiled is placed in the integer
- it points to. These option bits are those specified in the
- call to pcre_compile(), modified by any top-level option
- settings within the pattern itself, and with the
- PCRE_ANCHORED bit set if the form of the pattern implies
- that it can match only at the start of a subject string.
-
- If the pattern is not anchored and the firstcharptr argument
- is not NULL, it is used to pass back information about the
- first character of any matched string. If there is a fixed
- first character, e.g. from a pattern such as
- (cat|cow|coyote), then it is returned in the integer pointed
- to by firstcharptr. Otherwise, if either
-
- (a) the pattern was compiled with the PCRE_MULTILINE option,
- and every branch starts with "^", or
-
- (b) every branch of the pattern starts with ".*" and
- PCRE_DOTALL is not set (if it were set, the pattern would be
- anchored),
- then -1 is returned, indicating that the pattern matches
- only at the start of a subject string or after any "\n"
- within the string. Otherwise -2 is returned.
-
-
-
-MATCHING A PATTERN
- The function pcre_exec() is called to match a subject string
- against a pre-compiled pattern, which is passed in the code
- argument. If the pattern has been studied, the result of the
- study should be passed in the extra argument. Otherwise this
- must be NULL.
-
- The PCRE_ANCHORED option can be passed in the options argu-
- ment, whose unused bits must be zero. However, if a pattern
- was compiled with PCRE_ANCHORED, or turned out to be
- anchored by virtue of its contents, it cannot be made
- unachored at matching time.
-
- There are also three further options that can be set only at
- matching time:
-
- PCRE_NOTBOL
-
- The first character of the string is not the beginning of a
- line, so the circumflex metacharacter should not match
- before it. Setting this without PCRE_MULTILINE (at compile
- time) causes circumflex never to match.
-
- PCRE_NOTEOL
-
- The end of the string is not the end of a line, so the dol-
- lar metacharacter should not match it nor (except in multi-
- line mode) a newline immediately before it. Setting this
- without PCRE_MULTILINE (at compile time) causes dollar never
- to match.
-
- PCRE_NOTEMPTY
-
- An empty string is not considered to be a valid match if
- this option is set. If there are alternatives in the pat-
- tern, they are tried. If all the alternatives match the
- empty string, the entire match fails. For example, if the
- pattern
-
- a?b?
-
- is applied to a string not beginning with "a" or "b", it
- matches the empty string at the start of the subject. With
- PCRE_NOTEMPTY set, this match is not valid, so PCRE searches
- further into the string for occurrences of "a" or "b". Perl
- has no direct equivalent of this option, but it makes a
- special case of a pattern match of the empty string within
- its split() function, or when using the /g modifier. Using
- PCRE_NOTEMPTY it is possible to emulate this behaviour.
-
- The subject string is passed as a pointer in subject, a
- length in length, and a starting offset in startoffset.
- Unlike the pattern string, it may contain binary zero char-
- acters. When the starting offset is zero, the search for a
- match starts at the beginning of the subject, and this is by
- far the most common case.
-
- A non-zero starting offset is useful when searching for
- another match in the same subject by calling pcre_exec()
- again after a previous success. Setting startoffset differs
- from just passing over a shortened string and setting
- PCRE_NOTBOL in the case of a pattern that begins with any
- kind of lookbehind. For example, consider the pattern
-
- \Biss\B
-
- which finds occurrences of "iss" in the middle of words. (\B
- matches only if the current position in the subject is not a
- word boundary.) When applied to the string "Mississipi" the
- first call to pcre_exec() finds the first occurrence. If
- pcre_exec() is called again with just the remainder of the
- subject, namely "issipi", it does not match, because \B is
- always false at the start of the subject, which is deemed to
- be a word boundary. However, if pcre_exec() is passed the
- entire string again, but with startoffset set to 4, it finds
- the second occurrence of "iss" because it is able to look
- behind the starting point to discover that it is preceded by
- a letter.
-
- If a non-zero starting offset is passed when the pattern is
- anchored, one attempt to match at the given offset is tried.
- This can only succeed if the pattern does not require the
- match to be at the start of the subject.
-
- In general, a pattern matches a certain portion of the sub-
- ject, and in addition, further substrings from the subject
- may be picked out by parts of the pattern. Following the
- usage in Jeffrey Friedl's book, this is called "capturing"
- in what follows, and the phrase "capturing subpattern" is
- used for a fragment of a pattern that picks out a substring.
- PCRE supports several other kinds of parenthesized subpat-
- tern that do not cause substrings to be captured.
-
- Captured substrings are returned to the caller via a vector
- of integer offsets whose address is passed in ovector. The
- number of elements in the vector is passed in ovecsize. The
- first two-thirds of the vector is used to pass back captured
- substrings, each substring using a pair of integers. The
- remaining third of the vector is used as workspace by
- pcre_exec() while matching capturing subpatterns, and is not
- available for passing back information. The length passed in
- ovecsize should always be a multiple of three. If it is not,
- it is rounded down.
-
- When a match has been successful, information about captured
- substrings is returned in pairs of integers, starting at the
- beginning of ovector, and continuing up to two-thirds of its
- length at the most. The first element of a pair is set to
- the offset of the first character in a substring, and the
- second is set to the offset of the first character after the
- end of a substring. The first pair, ovector[0] and ovec-
- tor[1], identify the portion of the subject string matched
- by the entire pattern. The next pair is used for the first
- capturing subpattern, and so on. The value returned by
- pcre_exec() is the number of pairs that have been set. If
- there are no capturing subpatterns, the return value from a
- successful match is 1, indicating that just the first pair
- of offsets has been set.
-
- Some convenience functions are provided for extracting the
- captured substrings as separate strings. These are described
- in the following section.
-
- It is possible for an capturing subpattern number n+1 to
- match some part of the subject when subpattern n has not
- been used at all. For example, if the string "abc" is
- matched against the pattern (a|(z))(bc) subpatterns 1 and 3
- are matched, but 2 is not. When this happens, both offset
- values corresponding to the unused subpattern are set to -1.
-
- If a capturing subpattern is matched repeatedly, it is the
- last portion of the string that it matched that gets
- returned.
-
- If the vector is too small to hold all the captured sub-
- strings, it is used as far as possible (up to two-thirds of
- its length), and the function returns a value of zero. In
- particular, if the substring offsets are not of interest,
- pcre_exec() may be called with ovector passed as NULL and
- ovecsize as zero. However, if the pattern contains back
- references and the ovector isn't big enough to remember the
- related substrings, PCRE has to get additional memory for
- use during matching. Thus it is usually advisable to supply
- an ovector.
-
- Note that pcre_info() can be used to find out how many cap-
- turing subpatterns there are in a compiled pattern. The
- smallest size for ovector that will allow for n captured
- substrings in addition to the offsets of the substring
- matched by the whole pattern is (n+1)*3.
- If pcre_exec() fails, it returns a negative number. The fol-
- lowing are defined in the header file:
-
- PCRE_ERROR_NOMATCH (-1)
-
- The subject string did not match the pattern.
-
- PCRE_ERROR_NULL (-2)
-
- Either code or subject was passed as NULL, or ovector was
- NULL and ovecsize was not zero.
-
- PCRE_ERROR_BADOPTION (-3)
-
- An unrecognized bit was set in the options argument.
-
- PCRE_ERROR_BADMAGIC (-4)
-
- PCRE stores a 4-byte "magic number" at the start of the com-
- piled code, to catch the case when it is passed a junk
- pointer. This is the error it gives when the magic number
- isn't present.
-
- PCRE_ERROR_UNKNOWN_NODE (-5)
-
- While running the pattern match, an unknown item was encoun-
- tered in the compiled pattern. This error could be caused by
- a bug in PCRE or by overwriting of the compiled pattern.
-
- PCRE_ERROR_NOMEMORY (-6)
-
- If a pattern contains back references, but the ovector that
- is passed to pcre_exec() is not big enough to remember the
- referenced substrings, PCRE gets a block of memory at the
- start of matching to use for this purpose. If the call via
- pcre_malloc() fails, this error is given. The memory is
- freed at the end of matching.
-
-
-
-EXTRACTING CAPTURED SUBSTRINGS
- Captured substrings can be accessed directly by using the
- offsets returned by pcre_exec() in ovector. For convenience,
- the functions pcre_copy_substring(), pcre_get_substring(),
- and pcre_get_substring_list() are provided for extracting
- captured substrings as new, separate, zero-terminated
- strings. A substring that contains a binary zero is
- correctly extracted and has a further zero added on the end,
- but the result does not, of course, function as a C string.
-
- The first three arguments are the same for all three func-
- tions: subject is the subject string which has just been
- successfully matched, ovector is a pointer to the vector of
- integer offsets that was passed to pcre_exec(), and
- stringcount is the number of substrings that were captured
- by the match, including the substring that matched the
- entire regular expression. This is the value returned by
- pcre_exec if it is greater than zero. If pcre_exec()
- returned zero, indicating that it ran out of space in ovec-
- tor, then the value passed as stringcount should be the size
- of the vector divided by three.
-
- The functions pcre_copy_substring() and pcre_get_substring()
- extract a single substring, whose number is given as string-
- number. A value of zero extracts the substring that matched
- the entire pattern, while higher values extract the captured
- substrings. For pcre_copy_substring(), the string is placed
- in buffer, whose length is given by buffersize, while for
- pcre_get_substring() a new block of store is obtained via
- pcre_malloc, and its address is returned via stringptr. The
- yield of the function is the length of the string, not
- including the terminating zero, or one of
-
- PCRE_ERROR_NOMEMORY (-6)
-
- The buffer was too small for pcre_copy_substring(), or the
- attempt to get memory failed for pcre_get_substring().
-
- PCRE_ERROR_NOSUBSTRING (-7)
-
- There is no substring whose number is stringnumber.
-
- The pcre_get_substring_list() function extracts all avail-
- able substrings and builds a list of pointers to them. All
- this is done in a single block of memory which is obtained
- via pcre_malloc. The address of the memory block is returned
- via listptr, which is also the start of the list of string
- pointers. The end of the list is marked by a NULL pointer.
- The yield of the function is zero if all went well, or
-
- PCRE_ERROR_NOMEMORY (-6)
-
- if the attempt to get the memory block failed.
-
- When any of these functions encounter a substring that is
- unset, which can happen when capturing subpattern number n+1
- matches some part of the subject, but subpattern n has not
- been used at all, they return an empty string. This can be
- distinguished from a genuine zero-length substring by
- inspecting the appropriate offset in ovector, which is nega-
- tive for unset substrings.
-
-
-
-LIMITATIONS
- There are some size limitations in PCRE but it is hoped that
- they will never in practice be relevant. The maximum length
- of a compiled pattern is 65539 (sic) bytes. All values in
- repeating quantifiers must be less than 65536. The maximum
- number of capturing subpatterns is 99. The maximum number
- of all parenthesized subpatterns, including capturing sub-
- patterns, assertions, and other types of subpattern, is 200.
-
- The maximum length of a subject string is the largest posi-
- tive number that an integer variable can hold. However, PCRE
- uses recursion to handle subpatterns and indefinite repeti-
- tion. This means that the available stack space may limit
- the size of a subject string that can be processed by cer-
- tain patterns.
-
-
-
-DIFFERENCES FROM PERL
- The differences described here are with respect to Perl
- 5.005.
-
- 1. By default, a whitespace character is any character that
- the C library function isspace() recognizes, though it is
- possible to compile PCRE with alternative character type
- tables. Normally isspace() matches space, formfeed, newline,
- carriage return, horizontal tab, and vertical tab. Perl 5 no
- longer includes vertical tab in its set of whitespace char-
- acters. The \v escape that was in the Perl documentation for
- a long time was never in fact recognized. However, the char-
- acter itself was treated as whitespace at least up to 5.002.
- In 5.004 and 5.005 it does not match \s.
-
- 2. PCRE does not allow repeat quantifiers on lookahead
- assertions. Perl permits them, but they do not mean what you
- might think. For example, (?!a){3} does not assert that the
- next three characters are not "a". It just asserts that the
- next character is not "a" three times.
-
- 3. Capturing subpatterns that occur inside negative looka-
- head assertions are counted, but their entries in the
- offsets vector are never set. Perl sets its numerical vari-
- ables from any such patterns that are matched before the
- assertion fails to match something (thereby succeeding), but
- only if the negative lookahead assertion contains just one
- branch.
-
- 4. Though binary zero characters are supported in the sub-
- ject string, they are not allowed in a pattern string
- because it is passed as a normal C string, terminated by
- zero. The escape sequence "\0" can be used in the pattern to
- represent a binary zero.
- 5. The following Perl escape sequences are not supported:
- \l, \u, \L, \U, \E, \Q. In fact these are implemented by
- Perl's general string-handling and are not part of its pat-
- tern matching engine.
-
- 6. The Perl \G assertion is not supported as it is not
- relevant to single pattern matches.
-
- 7. Fairly obviously, PCRE does not support the (?{code})
- construction.
-
- 8. There are at the time of writing some oddities in Perl
- 5.005_02 concerned with the settings of captured strings
- when part of a pattern is repeated. For example, matching
- "aba" against the pattern /^(a(b)?)+$/ sets $2 to the value
- "b", but matching "aabbaa" against /^(aa(bb)?)+$/ leaves $2
- unset. However, if the pattern is changed to
- /^(aa(b(b))?)+$/ then $2 (and $3) get set.
-
- In Perl 5.004 $2 is set in both cases, and that is also true
- of PCRE. If in the future Perl changes to a consistent state
- that is different, PCRE may change to follow.
-
- 9. Another as yet unresolved discrepancy is that in Perl
- 5.005_02 the pattern /^(a)?(?(1)a|b)+$/ matches the string
- "a", whereas in PCRE it does not. However, in both Perl and
- PCRE /^(a)?a/ matched against "a" leaves $1 unset.
-
- 10. PCRE provides some extensions to the Perl regular
- expression facilities:
-
- (a) Although lookbehind assertions must match fixed length
- strings, each alternative branch of a lookbehind assertion
- can match a different length of string. Perl 5.005 requires
- them all to have the same length.
-
- (b) If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not
- set, the $ meta- character matches only at the very end of
- the string.
-
- (c) If PCRE_EXTRA is set, a backslash followed by a letter
- with no special meaning is faulted.
-
- (d) If PCRE_UNGREEDY is set, the greediness of the repeti-
- tion quantifiers is inverted, that is, by default they are
- not greedy, but if followed by a question mark they are.
-
- (e) PCRE_ANCHORED can be used to force a pattern to be tried
- only at the start of the subject.
-
- (f) The PCRE_NOTBOL, PCRE_NOTEOL, and PCRE_NOTEMPTY options
- for pcre_exec() have no Perl equivalents.
-
-
-
-REGULAR EXPRESSION DETAILS
- The syntax and semantics of the regular expressions sup-
- ported by PCRE are described below. Regular expressions are
- also described in the Perl documentation and in a number of
- other books, some of which have copious examples. Jeffrey
- Friedl's "Mastering Regular Expressions", published by
- O'Reilly (ISBN 1-56592-257-3), covers them in great detail.
- The description here is intended as reference documentation.
-
- A regular expression is a pattern that is matched against a
- subject string from left to right. Most characters stand for
- themselves in a pattern, and match the corresponding charac-
- ters in the subject. As a trivial example, the pattern
-
- The quick brown fox
-
- matches a portion of a subject string that is identical to
- itself. The power of regular expressions comes from the
- ability to include alternatives and repetitions in the pat-
- tern. These are encoded in the pattern by the use of meta-
- characters, which do not stand for themselves but instead
- are interpreted in some special way.
-
- There are two different sets of meta-characters: those that
- are recognized anywhere in the pattern except within square
- brackets, and those that are recognized in square brackets.
- Outside square brackets, the meta-characters are as follows:
-
- \ general escape character with several uses
- ^ assert start of subject (or line, in multiline
- mode)
- $ assert end of subject (or line, in multiline mode)
- . match any character except newline (by default)
- [ start character class definition
- | start of alternative branch
- ( start subpattern
- ) end subpattern
- ? extends the meaning of (
- also 0 or 1 quantifier
- also quantifier minimizer
- * 0 or more quantifier
- + 1 or more quantifier
- { start min/max quantifier
-
- Part of a pattern that is in square brackets is called a
- "character class". In a character class the only meta-
- characters are:
-
- \ general escape character
- ^ negate the class, but only if the first character
- - indicates character range
- ] terminates the character class
-
- The following sections describe the use of each of the
- meta-characters.
-
-
-
-BACKSLASH
- The backslash character has several uses. Firstly, if it is
- followed by a non-alphameric character, it takes away any
- special meaning that character may have. This use of
- backslash as an escape character applies both inside and
- outside character classes.
-
- For example, if you want to match a "*" character, you write
- "\*" in the pattern. This applies whether or not the follow-
- ing character would otherwise be interpreted as a meta-
- character, so it is always safe to precede a non-alphameric
- with "\" to specify that it stands for itself. In particu-
- lar, if you want to match a backslash, you write "\\".
-
- If a pattern is compiled with the PCRE_EXTENDED option, whi-
- tespace in the pattern (other than in a character class) and
- characters between a "#" outside a character class and the
- next newline character are ignored. An escaping backslash
- can be used to include a whitespace or "#" character as part
- of the pattern.
-
- A second use of backslash provides a way of encoding non-
- printing characters in patterns in a visible manner. There
- is no restriction on the appearance of non-printing charac-
- ters, apart from the binary zero that terminates a pattern,
- but when a pattern is being prepared by text editing, it is
- usually easier to use one of the following escape sequences
- than the binary character it represents:
-
- \a alarm, that is, the BEL character (hex 07)
- \cx "control-x", where x is any character
- \e escape (hex 1B)
- \f formfeed (hex 0C)
- \n newline (hex 0A)
- \r carriage return (hex 0D)
- \t tab (hex 09)
- \xhh character with hex code hh
- \ddd character with octal code ddd, or backreference
-
- The precise effect of "\cx" is as follows: if "x" is a lower
- case letter, it is converted to upper case. Then bit 6 of
- the character (hex 40) is inverted. Thus "\cz" becomes hex
- 1A, but "\c{" becomes hex 3B, while "\c;" becomes hex 7B.
-
- After "\x", up to two hexadecimal digits are read (letters
- can be in upper or lower case).
-
- After "\0" up to two further octal digits are read. In both
- cases, if there are fewer than two digits, just those that
- are present are used. Thus the sequence "\0\x\07" specifies
- two binary zeros followed by a BEL character. Make sure you
- supply two digits after the initial zero if the character
- that follows is itself an octal digit.
-
- The handling of a backslash followed by a digit other than 0
- is complicated. Outside a character class, PCRE reads it
- and any following digits as a decimal number. If the number
- is less than 10, or if there have been at least that many
- previous capturing left parentheses in the expression, the
- entire sequence is taken as a back reference. A description
- of how this works is given later, following the discussion
- of parenthesized subpatterns.
-
- Inside a character class, or if the decimal number is
- greater than 9 and there have not been that many capturing
- subpatterns, PCRE re-reads up to three octal digits follow-
- ing the backslash, and generates a single byte from the
- least significant 8 bits of the value. Any subsequent digits
- stand for themselves. For example:
-
- \040 is another way of writing a space
- \40 is the same, provided there are fewer than 40
- previous capturing subpatterns
- \7 is always a back reference
- \11 might be a back reference, or another way of
- writing a tab
- \011 is always a tab
- \0113 is a tab followed by the character "3"
- \113 is the character with octal code 113 (since there
- can be no more than 99 back references)
- \377 is a byte consisting entirely of 1 bits
- \81 is either a back reference, or a binary zero
- followed by the two characters "8" and "1"
-
- Note that octal values of 100 or greater must not be intro-
- duced by a leading zero, because no more than three octal
- digits are ever read.
-
- All the sequences that define a single byte value can be
- used both inside and outside character classes. In addition,
- inside a character class, the sequence "\b" is interpreted
- as the backspace character (hex 08). Outside a character
- class it has a different meaning (see below).
-
- The third use of backslash is for specifying generic charac-
- ter types:
-
- \d any decimal digit
- \D any character that is not a decimal digit
- any whitespace character
- \S any character that is not a whitespace character
- \w any "word" character
- \W any "non-word" character
-
- Each pair of escape sequences partitions the complete set of
- characters into two disjoint sets. Any given character
- matches one, and only one, of each pair.
-
- A "word" character is any letter or digit or the underscore
- character, that is, any character which can be part of a
- Perl "word". The definition of letters and digits is con-
- trolled by PCRE's character tables, and may vary if locale-
- specific matching is taking place (see "Locale support"
- above). For example, in the "fr" (French) locale, some char-
- acter codes greater than 128 are used for accented letters,
- and these are matched by \w.
-
- These character type sequences can appear both inside and
- outside character classes. They each match one character of
- the appropriate type. If the current matching point is at
- the end of the subject string, all of them fail, since there
- is no character to match.
-
- The fourth use of backslash is for certain simple asser-
- tions. An assertion specifies a condition that has to be met
- at a particular point in a match, without consuming any
- characters from the subject string. The use of subpatterns
- for more complicated assertions is described below. The
- backslashed assertions are
-
- \b word boundary
- \B not a word boundary
- \A start of subject (independent of multiline mode)
- \Z end of subject or newline at end (independent of
- multiline mode)
- \z end of subject (independent of multiline mode)
-
- These assertions may not appear in character classes (but
- note that "\b" has a different meaning, namely the backspace
- character, inside a character class).
-
- A word boundary is a position in the subject string where
- the current character and the previous character do not both
- match \w or \W (i.e. one matches \w and the other matches
- \W), or the start or end of the string if the first or last
- character matches \w, respectively.
-
- The \A, \Z, and \z assertions differ from the traditional
- circumflex and dollar (described below) in that they only
- ever match at the very start and end of the subject string,
- whatever options are set. They are not affected by the
- PCRE_NOTBOL or PCRE_NOTEOL options. If the startoffset argu-
- ment of pcre_exec() is non-zero, \A can never match. The
- difference between \Z and \z is that \Z matches before a
- newline that is the last character of the string as well as
- at the end of the string, whereas \z matches only at the
- end.
-
-
-
-CIRCUMFLEX AND DOLLAR
- Outside a character class, in the default matching mode, the
- circumflex character is an assertion which is true only if
- the current matching point is at the start of the subject
- string. If the startoffset argument of pcre_exec() is non-
- zero, circumflex can never match. Inside a character class,
- circumflex has an entirely different meaning (see below).
-
- Circumflex need not be the first character of the pattern if
- a number of alternatives are involved, but it should be the
- first thing in each alternative in which it appears if the
- pattern is ever to match that branch. If all possible alter-
- natives start with a circumflex, that is, if the pattern is
- constrained to match only at the start of the subject, it is
- said to be an "anchored" pattern. (There are also other con-
- structs that can cause a pattern to be anchored.)
-
- A dollar character is an assertion which is true only if the
- current matching point is at the end of the subject string,
- or immediately before a newline character that is the last
- character in the string (by default). Dollar need not be the
- last character of the pattern if a number of alternatives
- are involved, but it should be the last item in any branch
- in which it appears. Dollar has no special meaning in a
- character class.
-
- The meaning of dollar can be changed so that it matches only
- at the very end of the string, by setting the
- PCRE_DOLLAR_ENDONLY option at compile or matching time. This
- does not affect the \Z assertion.
-
- The meanings of the circumflex and dollar characters are
- changed if the PCRE_MULTILINE option is set. When this is
- the case, they match immediately after and immediately
- before an internal "\n" character, respectively, in addition
- to matching at the start and end of the subject string. For
- example, the pattern /^abc$/ matches the subject string
- "def\nabc" in multiline mode, but not otherwise. Conse-
- quently, patterns that are anchored in single line mode
- because all branches start with "^" are not anchored in mul-
- tiline mode, and a match for circumflex is possible when the
- startoffset argument of pcre_exec() is non-zero. The
- PCRE_DOLLAR_ENDONLY option is ignored if PCRE_MULTILINE is
- set.
-
- Note that the sequences \A, \Z, and \z can be used to match
- the start and end of the subject in both modes, and if all
- branches of a pattern start with \A is it always anchored,
- whether PCRE_MULTILINE is set or not.
-
-
-
-FULL STOP (PERIOD, DOT)
- Outside a character class, a dot in the pattern matches any
- one character in the subject, including a non-printing char-
- acter, but not (by default) newline. If the PCRE_DOTALL
- option is set, then dots match newlines as well. The han-
- dling of dot is entirely independent of the handling of cir-
- cumflex and dollar, the only relationship being that they
- both involve newline characters. Dot has no special meaning
- in a character class.
-
-
-
-SQUARE BRACKETS
- An opening square bracket introduces a character class, ter-
- minated by a closing square bracket. A closing square
- bracket on its own is not special. If a closing square
- bracket is required as a member of the class, it should be
- the first data character in the class (after an initial cir-
- cumflex, if present) or escaped with a backslash.
-
- A character class matches a single character in the subject;
- the character must be in the set of characters defined by
- the class, unless the first character in the class is a cir-
- cumflex, in which case the subject character must not be in
- the set defined by the class. If a circumflex is actually
- required as a member of the class, ensure it is not the
- first character, or escape it with a backslash.
-
- For example, the character class [aeiou] matches any lower
- case vowel, while [^aeiou] matches any character that is not
- a lower case vowel. Note that a circumflex is just a con-
- venient notation for specifying the characters which are in
- the class by enumerating those that are not. It is not an
- assertion: it still consumes a character from the subject
- string, and fails if the current pointer is at the end of
- the string.
-
- When caseless matching is set, any letters in a class
- represent both their upper case and lower case versions, so
- for example, a caseless [aeiou] matches "A" as well as "a",
- and a caseless [^aeiou] does not match "A", whereas a case-
- ful version would.
-
- The newline character is never treated in any special way in
- character classes, whatever the setting of the PCRE_DOTALL
- or PCRE_MULTILINE options is. A class such as [^a] will
- always match a newline.
-
- The minus (hyphen) character can be used to specify a range
- of characters in a character class. For example, [d-m]
- matches any letter between d and m, inclusive. If a minus
- character is required in a class, it must be escaped with a
- backslash or appear in a position where it cannot be inter-
- preted as indicating a range, typically as the first or last
- character in the class.
-
- It is not possible to have the literal character "]" as the
- end character of a range. A pattern such as [W-]46] is
- interpreted as a class of two characters ("W" and "-") fol-
- lowed by a literal string "46]", so it would match "W46]" or
- "-46]". However, if the "]" is escaped with a backslash it
- is interpreted as the end of range, so [W-\]46] is inter-
- preted as a single class containing a range followed by two
- separate characters. The octal or hexadecimal representation
- of "]" can also be used to end a range.
-
- Ranges operate in ASCII collating sequence. They can also be
- used for characters specified numerically, for example
- [\000-\037]. If a range that includes letters is used when
- caseless matching is set, it matches the letters in either
- case. For example, [W-c] is equivalent to [][\^_`wxyzabc],
- matched caselessly, and if character tables for the "fr"
- locale are in use, [\xc8-\xcb] matches accented E characters
- in both cases.
-
- The character types \d, \D, \s, \S, \w, and \W may also
- appear in a character class, and add the characters that
- they match to the class. For example, [\dABCDEF] matches any
- hexadecimal digit. A circumflex can conveniently be used
- with the upper case character types to specify a more res-
- tricted set of characters than the matching lower case type.
- For example, the class [^\W_] matches any letter or digit,
- but not underscore.
-
- All non-alphameric characters other than \, -, ^ (at the
- start) and the terminating ] are non-special in character
- classes, but it does no harm if they are escaped.
-
-
-
-VERTICAL BAR
- Vertical bar characters are used to separate alternative
- patterns. For example, the pattern
-
- gilbert|sullivan
-
- matches either "gilbert" or "sullivan". Any number of alter-
- natives may appear, and an empty alternative is permitted
- (matching the empty string). The matching process tries
- each alternative in turn, from left to right, and the first
- one that succeeds is used. If the alternatives are within a
- subpattern (defined below), "succeeds" means matching the
- rest of the main pattern as well as the alternative in the
- subpattern.
-
-
-
-INTERNAL OPTION SETTING
- The settings of PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL,
- and PCRE_EXTENDED can be changed from within the pattern by
- a sequence of Perl option letters enclosed between "(?" and
- ")". The option letters are
-
- i for PCRE_CASELESS
- m for PCRE_MULTILINE
- s for PCRE_DOTALL
- x for PCRE_EXTENDED
-
- For example, (?im) sets caseless, multiline matching. It is
- also possible to unset these options by preceding the letter
- with a hyphen, and a combined setting and unsetting such as
- (?im-sx), which sets PCRE_CASELESS and PCRE_MULTILINE while
- unsetting PCRE_DOTALL and PCRE_EXTENDED, is also permitted.
- If a letter appears both before and after the hyphen, the
- option is unset.
-
- The scope of these option changes depends on where in the
- pattern the setting occurs. For settings that are outside
- any subpattern (defined below), the effect is the same as if
- the options were set or unset at the start of matching. The
- following patterns all behave in exactly the same way:
-
- (?i)abc
- a(?i)bc
- ab(?i)c
- abc(?i)
-
- which in turn is the same as compiling the pattern abc with
- PCRE_CASELESS set. In other words, such "top level" set-
- tings apply to the whole pattern (unless there are other
- changes inside subpatterns). If there is more than one set-
- ting of the same option at top level, the rightmost setting
- is used.
-
- If an option change occurs inside a subpattern, the effect
- is different. This is a change of behaviour in Perl 5.005.
- An option change inside a subpattern affects only that part
- of the subpattern that follows it, so
-
- (a(?i)b)c
-
- matches abc and aBc and no other strings (assuming
- PCRE_CASELESS is not used). By this means, options can be
- made to have different settings in different parts of the
- pattern. Any changes made in one alternative do carry on
- into subsequent branches within the same subpattern. For
- example,
-
- (a(?i)b|c)
-
- matches "ab", "aB", "c", and "C", even though when matching
- "C" the first branch is abandoned before the option setting.
- This is because the effects of option settings happen at
- compile time. There would be some very weird behaviour oth-
- erwise.
-
- The PCRE-specific options PCRE_UNGREEDY and PCRE_EXTRA can
- be changed in the same way as the Perl-compatible options by
- using the characters U and X respectively. The (?X) flag
- setting is special in that it must always occur earlier in
- the pattern than any of the additional features it turns on,
- even when it is at top level. It is best put at the start.
-
-
-
-SUBPATTERNS
- Subpatterns are delimited by parentheses (round brackets),
- which can be nested. Marking part of a pattern as a subpat-
- tern does two things:
-
- 1. It localizes a set of alternatives. For example, the pat-
- tern
-
- cat(aract|erpillar|)
-
- matches one of the words "cat", "cataract", or "caterpil-
- lar". Without the parentheses, it would match "cataract",
- "erpillar" or the empty string.
-
- 2. It sets up the subpattern as a capturing subpattern (as
- defined above). When the whole pattern matches, that por-
- tion of the subject string that matched the subpattern is
- passed back to the caller via the ovector argument of
- pcre_exec(). Opening parentheses are counted from left to
- right (starting from 1) to obtain the numbers of the captur-
- ing subpatterns.
-
- For example, if the string "the red king" is matched against
- the pattern
-
- the ((red|white) (king|queen))
-
- the captured substrings are "red king", "red", and "king",
- and are numbered 1, 2, and 3.
-
- The fact that plain parentheses fulfil two functions is not
- always helpful. There are often times when a grouping sub-
- pattern is required without a capturing requirement. If an
- opening parenthesis is followed by "?:", the subpattern does
- not do any capturing, and is not counted when computing the
- number of any subsequent capturing subpatterns. For example,
- if the string "the white queen" is matched against the pat-
- tern
-
- the ((?:red|white) (king|queen))
-
- the captured substrings are "white queen" and "queen", and
- are numbered 1 and 2. The maximum number of captured sub-
- strings is 99, and the maximum number of all subpatterns,
- both capturing and non-capturing, is 200.
-
- As a convenient shorthand, if any option settings are
- required at the start of a non-capturing subpattern, the
- option letters may appear between the "?" and the ":". Thus
- the two patterns
-
- (?i:saturday|sunday)
- (?:(?i)saturday|sunday)
-
- match exactly the same set of strings. Because alternative
- branches are tried from left to right, and options are not
- reset until the end of the subpattern is reached, an option
- setting in one branch does affect subsequent branches, so
- the above patterns match "SUNDAY" as well as "Saturday".
-
-
-
-REPETITION
- Repetition is specified by quantifiers, which can follow any
- of the following items:
-
- a single character, possibly escaped
- the . metacharacter
- a character class
- a back reference (see next section)
- a parenthesized subpattern (unless it is an assertion -
- see below)
-
- The general repetition quantifier specifies a minimum and
- maximum number of permitted matches, by giving the two
- numbers in curly brackets (braces), separated by a comma.
- The numbers must be less than 65536, and the first must be
- less than or equal to the second. For example:
-
- z{2,4}
-
- matches "zz", "zzz", or "zzzz". A closing brace on its own
- is not a special character. If the second number is omitted,
- but the comma is present, there is no upper limit; if the
- second number and the comma are both omitted, the quantifier
- specifies an exact number of required matches. Thus
-
- [aeiou]{3,}
-
- matches at least 3 successive vowels, but may match many
- more, while
-
- \d{8}
-
- matches exactly 8 digits. An opening curly bracket that
- appears in a position where a quantifier is not allowed, or
- one that does not match the syntax of a quantifier, is taken
- as a literal character. For example, {,6} is not a quantif-
- ier, but a literal string of four characters.
-
- The quantifier {0} is permitted, causing the expression to
- behave as if the previous item and the quantifier were not
- present.
-
- For convenience (and historical compatibility) the three
- most common quantifiers have single-character abbreviations:
-
- * is equivalent to {0,}
- + is equivalent to {1,}
- ? is equivalent to {0,1}
-
- It is possible to construct infinite loops by following a
- subpattern that can match no characters with a quantifier
- that has no upper limit, for example:
-
- (a?)*
-
- Earlier versions of Perl and PCRE used to give an error at
- compile time for such patterns. However, because there are
- cases where this can be useful, such patterns are now
- accepted, but if any repetition of the subpattern does in
- fact match no characters, the loop is forcibly broken.
-
- By default, the quantifiers are "greedy", that is, they
- match as much as possible (up to the maximum number of per-
- mitted times), without causing the rest of the pattern to
- fail. The classic example of where this gives problems is in
- trying to match comments in C programs. These appear between
- the sequences /* and */ and within the sequence, individual
- * and / characters may appear. An attempt to match C com-
- ments by applying the pattern
-
- /\*.*\*/
-
- to the string
-
- /* first command */ not comment /* second comment */
-
- fails, because it matches the entire string due to the
- greediness of the .* item.
-
- However, if a quantifier is followed by a question mark,
- then it ceases to be greedy, and instead matches the minimum
- number of times possible, so the pattern
-
- /\*.*?\*/
-
- does the right thing with the C comments. The meaning of the
- various quantifiers is not otherwise changed, just the pre-
- ferred number of matches. Do not confuse this use of ques-
- tion mark with its use as a quantifier in its own right.
- Because it has two uses, it can sometimes appear doubled, as
- in
-
- \d??\d
-
- which matches one digit by preference, but can match two if
- that is the only way the rest of the pattern matches.
-
- If the PCRE_UNGREEDY option is set (an option which is not
- available in Perl) then the quantifiers are not greedy by
- default, but individual ones can be made greedy by following
- them with a question mark. In other words, it inverts the
- default behaviour.
-
- When a parenthesized subpattern is quantified with a minimum
- repeat count that is greater than 1 or with a limited max-
- imum, more store is required for the compiled pattern, in
- proportion to the size of the minimum or maximum.
-
- If a pattern starts with .* or .{0,} and the PCRE_DOTALL
- option (equivalent to Perl's /s) is set, thus allowing the .
- to match newlines, then the pattern is implicitly anchored,
- because whatever follows will be tried against every charac-
- ter position in the subject string, so there is no point in
- retrying the overall match at any position after the first.
- PCRE treats such a pattern as though it were preceded by \A.
- In cases where it is known that the subject string contains
- no newlines, it is worth setting PCRE_DOTALL when the pat-
- tern begins with .* in order to obtain this optimization, or
- alternatively using ^ to indicate anchoring explicitly.
-
- When a capturing subpattern is repeated, the value captured
- is the substring that matched the final iteration. For
- example, after
-
- (tweedle[dume]{3}\s*)+
-
- has matched "tweedledum tweedledee" the value of the cap-
- tured substring is "tweedledee". However, if there are
- nested capturing subpatterns, the corresponding captured
- values may have been set in previous iterations. For exam-
- ple, after
-
- /(a|(b))+/
-
- matches "aba" the value of the second captured substring is
- "b".
-
-
-
-BACK REFERENCES
- Outside a character class, a backslash followed by a digit
- greater than 0 (and possibly further digits) is a back
- reference to a capturing subpattern earlier (i.e. to its
- left) in the pattern, provided there have been that many
- previous capturing left parentheses.
-
- However, if the decimal number following the backslash is
- less than 10, it is always taken as a back reference, and
- causes an error only if there are not that many capturing
- left parentheses in the entire pattern. In other words, the
- parentheses that are referenced need not be to the left of
- the reference for numbers less than 10. See the section
- entitled "Backslash" above for further details of the han-
- dling of digits following a backslash.
-
- A back reference matches whatever actually matched the cap-
- turing subpattern in the current subject string, rather than
- anything matching the subpattern itself. So the pattern
-
- (sens|respons)e and \1ibility
-
- matches "sense and sensibility" and "response and responsi-
- bility", but not "sense and responsibility". If caseful
- matching is in force at the time of the back reference, then
- the case of letters is relevant. For example,
-
- ((?i)rah)\s+\1
-
- matches "rah rah" and "RAH RAH", but not "RAH rah", even
- though the original capturing subpattern is matched case-
- lessly.
-
- There may be more than one back reference to the same sub-
- pattern. If a subpattern has not actually been used in a
- particular match, then any back references to it always
- fail. For example, the pattern
-
- (a|(bc))\2
-
- always fails if it starts to match "a" rather than "bc".
- Because there may be up to 99 back references, all digits
- following the backslash are taken as part of a potential
- back reference number. If the pattern continues with a digit
- character, then some delimiter must be used to terminate the
- back reference. If the PCRE_EXTENDED option is set, this can
- be whitespace. Otherwise an empty comment can be used.
-
- A back reference that occurs inside the parentheses to which
- it refers fails when the subpattern is first used, so, for
- example, (a\1) never matches. However, such references can
- be useful inside repeated subpatterns. For example, the pat-
- tern
-
- (a|b\1)+
-
- matches any number of "a"s and also "aba", "ababaa" etc. At
- each iteration of the subpattern, the back reference matches
- the character string corresponding to the previous itera-
- tion. In order for this to work, the pattern must be such
- that the first iteration does not need to match the back
- reference. This can be done using alternation, as in the
- example above, or by a quantifier with a minimum of zero.
-
-
-
-ASSERTIONS
- An assertion is a test on the characters following or
- preceding the current matching point that does not actually
- consume any characters. The simple assertions coded as \b,
- \B, \A, \Z, \z, ^ and $ are described above. More compli-
- cated assertions are coded as subpatterns. There are two
- kinds: those that look ahead of the current position in the
- subject string, and those that look behind it.
-
- An assertion subpattern is matched in the normal way, except
- that it does not cause the current matching position to be
- changed. Lookahead assertions start with (?= for positive
- assertions and (?! for negative assertions. For example,
-
- \w+(?=;)
-
- matches a word followed by a semicolon, but does not include
- the semicolon in the match, and
-
- foo(?!bar)
-
- matches any occurrence of "foo" that is not followed by
- "bar". Note that the apparently similar pattern
-
- (?!foo)bar
-
- does not find an occurrence of "bar" that is preceded by
- something other than "foo"; it finds any occurrence of "bar"
- whatsoever, because the assertion (?!foo) is always true
- when the next three characters are "bar". A lookbehind
- assertion is needed to achieve this effect.
-
- Lookbehind assertions start with (?<= for positive asser-
- tions and (?<! for negative assertions. For example,
-
- (?<!foo)bar
-
- does find an occurrence of "bar" that is not preceded by
- "foo". The contents of a lookbehind assertion are restricted
- such that all the strings it matches must have a fixed
- length. However, if there are several alternatives, they do
- not all have to have the same fixed length. Thus
-
- (?<=bullock|donkey)
-
- is permitted, but
-
- (?<!dogs?|cats?)
-
- causes an error at compile time. Branches that match dif-
- ferent length strings are permitted only at the top level of
- a lookbehind assertion. This is an extension compared with
- Perl 5.005, which requires all branches to match the same
- length of string. An assertion such as
-
- (?<=ab(c|de))
-
- is not permitted, because its single top-level branch can
- match two different lengths, but it is acceptable if rewrit-
- ten to use two top-level branches:
-
- (?<=abc|abde)
-
- The implementation of lookbehind assertions is, for each
- alternative, to temporarily move the current position back
- by the fixed width and then try to match. If there are
- insufficient characters before the current position, the
- match is deemed to fail. Lookbehinds in conjunction with
- once-only subpatterns can be particularly useful for match-
- ing at the ends of strings; an example is given at the end
- of the section on once-only subpatterns.
-
- Several assertions (of any sort) may occur in succession.
- For example,
-
- (?<=\d{3})(?<!999)foo
-
- matches "foo" preceded by three digits that are not "999".
- Notice that each of the assertions is applied independently
- at the same point in the subject string. First there is a
- check that the previous three characters are all digits,
- then there is a check that the same three characters are not
- "999". This pattern does not match "foo" preceded by six
- characters, the first of which are digits and the last three
- of which are not "999". For example, it doesn't match
- "123abcfoo". A pattern to do that is
-
- (?<=\d{3}...)(?<!999)foo
-
- This time the first assertion looks at the preceding six
- characters, checking that the first three are digits, and
- then the second assertion checks that the preceding three
- characters are not "999".
-
- Assertions can be nested in any combination. For example,
-
- (?<=(?<!foo)bar)baz
-
- matches an occurrence of "baz" that is preceded by "bar"
- which in turn is not preceded by "foo", while
-
- (?<=\d{3}(?!999)...)foo
-
- is another pattern which matches "foo" preceded by three
- digits and any three characters that are not "999".
-
- Assertion subpatterns are not capturing subpatterns, and may
- not be repeated, because it makes no sense to assert the
- same thing several times. If any kind of assertion contains
- capturing subpatterns within it, these are counted for the
- purposes of numbering the capturing subpatterns in the whole
- pattern. However, substring capturing is carried out only
- for positive assertions, because it does not make sense for
- negative assertions.
-
- Assertions count towards the maximum of 200 parenthesized
- subpatterns.
-
-
-
-ONCE-ONLY SUBPATTERNS
- With both maximizing and minimizing repetition, failure of
- what follows normally causes the repeated item to be re-
- evaluated to see if a different number of repeats allows the
- rest of the pattern to match. Sometimes it is useful to
- prevent this, either to change the nature of the match, or
- to cause it fail earlier than it otherwise might, when the
- author of the pattern knows there is no point in carrying
- on.
-
- Consider, for example, the pattern \d+foo when applied to
- the subject line
-
- 123456bar
-
- After matching all 6 digits and then failing to match "foo",
- the normal action of the matcher is to try again with only 5
- digits matching the \d+ item, and then with 4, and so on,
- before ultimately failing. Once-only subpatterns provide the
- means for specifying that once a portion of the pattern has
- matched, it is not to be re-evaluated in this way, so the
- matcher would give up immediately on failing to match "foo"
- the first time. The notation is another kind of special
- parenthesis, starting with (?> as in this example:
-
- (?>\d+)bar
-
- This kind of parenthesis "locks up" the part of the pattern
- it contains once it has matched, and a failure further into
- the pattern is prevented from backtracking into it. Back-
- tracking past it to previous items, however, works as nor-
- mal.
-
- An alternative description is that a subpattern of this type
- matches the string of characters that an identical stan-
- dalone pattern would match, if anchored at the current point
- in the subject string.
-
- Once-only subpatterns are not capturing subpatterns. Simple
- cases such as the above example can be thought of as a max-
- imizing repeat that must swallow everything it can. So,
- while both \d+ and \d+? are prepared to adjust the number of
- digits they match in order to make the rest of the pattern
- match, (?>\d+) can only match an entire sequence of digits.
-
- This construction can of course contain arbitrarily compli-
- cated subpatterns, and it can be nested.
-
- Once-only subpatterns can be used in conjunction with look-
- behind assertions to specify efficient matching at the end
- of the subject string. Consider a simple pattern such as
-
- abcd$
-
- when applied to a long string which does not match it.
- Because matching proceeds from left to right, PCRE will look
- for each "a" in the subject and then see if what follows
- matches the rest of the pattern. If the pattern is specified
- as
-
- ^.*abcd$
-
- then the initial .* matches the entire string at first, but
- when this fails, it backtracks to match all but the last
- character, then all but the last two characters, and so on.
- Once again the search for "a" covers the entire string, from
- right to left, so we are no better off. However, if the pat-
- tern is written as
-
- ^(?>.*)(?<=abcd)
-
- then there can be no backtracking for the .* item; it can
- match only the entire string. The subsequent lookbehind
- assertion does a single test on the last four characters. If
- it fails, the match fails immediately. For long strings,
- this approach makes a significant difference to the process-
- ing time.
-
-
-
-CONDITIONAL SUBPATTERNS
- It is possible to cause the matching process to obey a sub-
- pattern conditionally or to choose between two alternative
- subpatterns, depending on the result of an assertion, or
- whether a previous capturing subpattern matched or not. The
- two possible forms of conditional subpattern are
-
- (?(condition)yes-pattern)
- (?(condition)yes-pattern|no-pattern)
-
- If the condition is satisfied, the yes-pattern is used; oth-
- erwise the no-pattern (if present) is used. If there are
- more than two alternatives in the subpattern, a compile-time
- error occurs.
-
- There are two kinds of condition. If the text between the
- parentheses consists of a sequence of digits, then the con-
- dition is satisfied if the capturing subpattern of that
- number has previously matched. Consider the following pat-
- tern, which contains non-significant white space to make it
- more readable (assume the PCRE_EXTENDED option) and to
- divide it into three parts for ease of discussion:
-
- ( \( )? [^()]+ (?(1) \) )
-
- The first part matches an optional opening parenthesis, and
- if that character is present, sets it as the first captured
- substring. The second part matches one or more characters
- that are not parentheses. The third part is a conditional
- subpattern that tests whether the first set of parentheses
- matched or not. If they did, that is, if subject started
- with an opening parenthesis, the condition is true, and so
- the yes-pattern is executed and a closing parenthesis is
- required. Otherwise, since no-pattern is not present, the
- subpattern matches nothing. In other words, this pattern
- matches a sequence of non-parentheses, optionally enclosed
- in parentheses.
-
- If the condition is not a sequence of digits, it must be an
- assertion. This may be a positive or negative lookahead or
- lookbehind assertion. Consider this pattern, again contain-
- ing non-significant white space, and with the two alterna-
- tives on the second line:
-
- (?(?=[^a-z]*[a-z])
- \d{2}[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} )
-
- The condition is a positive lookahead assertion that matches
- an optional sequence of non-letters followed by a letter. In
- other words, it tests for the presence of at least one
- letter in the subject. If a letter is found, the subject is
- matched against the first alternative; otherwise it is
- matched against the second. This pattern matches strings in
- one of the two forms dd-aaa-dd or dd-dd-dd, where aaa are
- letters and dd are digits.
-
-
-
-COMMENTS
- The sequence (?# marks the start of a comment which contin-
- ues up to the next closing parenthesis. Nested parentheses
- are not permitted. The characters that make up a comment
- play no part in the pattern matching at all.
-
- If the PCRE_EXTENDED option is set, an unescaped # character
- outside a character class introduces a comment that contin-
- ues up to the next newline character in the pattern.
-
-
-
-PERFORMANCE
- Certain items that may appear in patterns are more efficient
- than others. It is more efficient to use a character class
- like [aeiou] than a set of alternatives such as (a|e|i|o|u).
- In general, the simplest construction that provides the
- required behaviour is usually the most efficient. Jeffrey
- Friedl's book contains a lot of discussion about optimizing
- regular expressions for efficient performance.
-
- When a pattern begins with .* and the PCRE_DOTALL option is
- set, the pattern is implicitly anchored by PCRE, since it
- can match only at the start of a subject string. However, if
- PCRE_DOTALL is not set, PCRE cannot make this optimization,
- because the . metacharacter does not then match a newline,
- and if the subject string contains newlines, the pattern may
- match from the character immediately following one of them
- instead of from the very start. For example, the pattern
-
- (.*) second
-
- matches the subject "first\nand second" (where \n stands for
- a newline character) with the first captured substring being
- "and". In order to do this, PCRE has to retry the match
- starting after every newline in the subject.
-
- If you are using such a pattern with subject strings that do
- not contain newlines, the best performance is obtained by
- setting PCRE_DOTALL, or starting the pattern with ^.* to
- indicate explicit anchoring. That saves PCRE from having to
- scan along the subject looking for a newline to restart at.
-
- Beware of patterns that contain nested indefinite repeats.
- These can take a long time to run when applied to a string
- that does not match. Consider the pattern fragment
-
- (a+)*
-
- This can match "aaaa" in 33 different ways, and this number
- increases very rapidly as the string gets longer. (The *
- repeat can match 0, 1, 2, 3, or 4 times, and for each of
- those cases other than 0, the + repeats can match different
- numbers of times.) When the remainder of the pattern is such
- that the entire match is going to fail, PCRE has in princi-
- ple to try every possible variation, and this can take an
- extremely long time.
-
- An optimization catches some of the more simple cases such
- as
-
- (a+)*b
-
- where a literal character follows. Before embarking on the
- standard matching procedure, PCRE checks that there is a "b"
- later in the subject string, and if there is not, it fails
- the match immediately. However, when there is no following
- literal this optimization cannot be used. You can see the
- difference by comparing the behaviour of
-
- (a+)*\d
-
- with the pattern above. The former gives a failure almost
- instantly when applied to a whole line of "a" characters,
- whereas the latter takes an appreciable time with strings
- longer than about 20 characters.
-
-
-
-AUTHOR
- Philip Hazel <ph10@cam.ac.uk>
- University Computing Service,
- New Museums Site,
- Cambridge CB2 3QG, England.
- Phone: +44 1223 334714
-
- Last updated: 29 July 1999
- Copyright (c) 1997-1999 University of Cambridge.
diff --git a/ext/pcre/pcrelib/pcre.c b/ext/pcre/pcrelib/pcre.c
deleted file mode 100644
index 6735b823d4..0000000000
--- a/ext/pcre/pcrelib/pcre.c
+++ /dev/null
@@ -1,4477 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/*
-This is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language. See
-the file Tech.Notes for some information on the internals.
-
-Written by: Philip Hazel <ph10@cam.ac.uk>
-
- Copyright (c) 1997-1999 University of Cambridge
-
------------------------------------------------------------------------------
-Permission is granted to anyone to use this software for any purpose on any
-computer system, and to redistribute it freely, subject to the following
-restrictions:
-
-1. This software 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.
-
-2. The origin of this software must not be misrepresented, either by
- explicit claim or by omission.
-
-3. Altered versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
-
-4. If PCRE is embedded in any software that is released under the GNU
- General Purpose Licence (GPL), then the terms of that licence shall
- supersede any condition above with which it is incompatible.
------------------------------------------------------------------------------
-*/
-
-
-/* Define DEBUG to get debugging output on stdout. */
-
-/* #define DEBUG */
-
-/* Use a macro for debugging printing, 'cause that eliminates the use of #ifdef
-inline, and there are *still* stupid compilers about that don't like indented
-pre-processor statements. I suppose it's only been 10 years... */
-
-#ifdef DEBUG
-#define DPRINTF(p) printf p
-#else
-#define DPRINTF(p) /*nothing*/
-#endif
-
-/* Include the internals header, which itself includes Standard C headers plus
-the external pcre header. */
-
-#include "internal.h"
-
-
-/* Allow compilation as C++ source code, should anybody want to do that. */
-
-#ifdef __cplusplus
-#define class pcre_class
-#endif
-
-
-/* Number of items on the nested bracket stacks at compile time. This should
-not be set greater than 200. */
-
-#define BRASTACK_SIZE 200
-
-
-/* Min and max values for the common repeats; for the maxima, 0 => infinity */
-
-static const char rep_min[] = { 0, 0, 1, 1, 0, 0 };
-static const char rep_max[] = { 0, 0, 0, 0, 1, 1 };
-
-/* Text forms of OP_ values and things, for debugging (not all used) */
-
-#ifdef DEBUG
-static const char *OP_names[] = {
- "End", "\\A", "\\B", "\\b", "\\D", "\\d",
- "\\S", "\\s", "\\W", "\\w", "\\Z", "\\z",
- "Opt", "^", "$", "Any", "chars", "not",
- "*", "*?", "+", "+?", "?", "??", "{", "{", "{",
- "*", "*?", "+", "+?", "?", "??", "{", "{", "{",
- "*", "*?", "+", "+?", "?", "??", "{", "{", "{",
- "*", "*?", "+", "+?", "?", "??", "{", "{",
- "class", "Ref",
- "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not",
- "AssertB", "AssertB not", "Reverse", "Once", "Cond", "Cref",
- "Brazero", "Braminzero", "Bra"
-};
-#endif
-
-/* Table for handling escaped characters in the range '0'-'z'. Positive returns
-are simple data values; negative values are for special things like \d and so
-on. Zero means further processing is needed (for things like \x), or the escape
-is invalid. */
-
-static const short int escapes[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0 - 7 */
- 0, 0, ':', ';', '<', '=', '>', '?', /* 8 - ? */
- '@', -ESC_A, -ESC_B, 0, -ESC_D, 0, 0, 0, /* @ - G */
- 0, 0, 0, 0, 0, 0, 0, 0, /* H - O */
- 0, 0, 0, -ESC_S, 0, 0, 0, -ESC_W, /* P - W */
- 0, 0, -ESC_Z, '[', '\\', ']', '^', '_', /* X - _ */
- '`', 7, -ESC_b, 0, -ESC_d, 27, '\f', 0, /* ` - g */
- 0, 0, 0, 0, 0, 0, '\n', 0, /* h - o */
- 0, 0, '\r', -ESC_s, '\t', 0, 0, -ESC_w, /* p - w */
- 0, 0, -ESC_z /* x - z */
-};
-
-/* Definition to allow mutual recursion */
-
-static BOOL
- compile_regex(int, int, int *, uschar **, const uschar **, const char **,
- BOOL, int, int *, int *, compile_data *);
-
-
-
-/*************************************************
-* Global variables *
-*************************************************/
-
-/* PCRE is thread-clean and doesn't use any global variables in the normal
-sense. However, it calls memory allocation and free functions via the two
-indirections below, which are can be changed by the caller, but are shared
-between all threads. */
-
-void *(*pcre_malloc)(size_t) = malloc;
-void (*pcre_free)(void *) = free;
-
-
-
-
-/*************************************************
-* Default character tables *
-*************************************************/
-
-/* A default set of character tables is included in the PCRE binary. Its source
-is built by the maketables auxiliary program, which uses the default C ctypes
-functions, and put in the file chartables.c. These tables are used by PCRE
-whenever the caller of pcre_compile() does not provide an alternate set of
-tables. */
-
-#include "chartables.c"
-
-
-
-/*************************************************
-* Return version string *
-*************************************************/
-
-#define STRING(a) # a
-#define XSTRING(s) STRING(s)
-
-const char *
-pcre_version(void)
-{
-return XSTRING(PCRE_MAJOR) "." XSTRING(PCRE_MINOR) " " XSTRING(PCRE_DATE);
-}
-
-
-
-
-/*************************************************
-* Return info about a compiled pattern *
-*************************************************/
-
-/* This function picks potentially useful data out of the private
-structure. The public options are passed back in an int - though the
-re->options field has been expanded to a long int, all the public options
-at the low end of it, and so even on 16-bit systems this will still be OK.
-Therefore, I haven't changed the API for pcre_info().
-
-Arguments:
- external_re points to compiled code
- optptr where to pass back the options
- first_char where to pass back the first character,
- or -1 if multiline and all branches start ^,
- or -2 otherwise
-
-Returns: number of identifying extraction brackets
- or negative values on error
-*/
-
-int
-pcre_info(const pcre *external_re, int *optptr, int *first_char)
-{
-const real_pcre *re = (const real_pcre *)external_re;
-if (re == NULL) return PCRE_ERROR_NULL;
-if (re->magic_number != MAGIC_NUMBER) return PCRE_ERROR_BADMAGIC;
-if (optptr != NULL) *optptr = (int)(re->options & PUBLIC_OPTIONS);
-if (first_char != NULL)
- *first_char = ((re->options & PCRE_FIRSTSET) != 0)? re->first_char :
- ((re->options & PCRE_STARTLINE) != 0)? -1 : -2;
-return re->top_bracket;
-}
-
-
-
-
-#ifdef DEBUG
-/*************************************************
-* Debugging function to print chars *
-*************************************************/
-
-/* Print a sequence of chars in printable format, stopping at the end of the
-subject if the requested.
-
-Arguments:
- p points to characters
- length number to print
- is_subject TRUE if printing from within md->start_subject
- md pointer to matching data block, if is_subject is TRUE
-
-Returns: nothing
-*/
-
-static void
-pchars(const uschar *p, int length, BOOL is_subject, match_data *md)
-{
-int c;
-if (is_subject && length > md->end_subject - p) length = md->end_subject - p;
-while (length-- > 0)
- if (isprint(c = *(p++))) printf("%c", c); else printf("\\x%02x", c);
-}
-#endif
-
-
-
-
-/*************************************************
-* Handle escapes *
-*************************************************/
-
-/* This function is called when a \ has been encountered. It either returns a
-positive value for a simple escape such as \n, or a negative value which
-encodes one of the more complicated things such as \d. On entry, ptr is
-pointing at the \. On exit, it is on the final character of the escape
-sequence.
-
-Arguments:
- ptrptr points to the pattern position pointer
- errorptr points to the pointer to the error message
- bracount number of previous extracting brackets
- options the options bits
- isclass TRUE if inside a character class
- cd pointer to char tables block
-
-Returns: zero or positive => a data character
- negative => a special escape sequence
- on error, errorptr is set
-*/
-
-static int
-check_escape(const uschar **ptrptr, const char **errorptr, int bracount,
- int options, BOOL isclass, compile_data *cd)
-{
-const uschar *ptr = *ptrptr;
-int c = *(++ptr) & 255; /* Ensure > 0 on signed-char systems */
-int i;
-
-if (c == 0) *errorptr = ERR1;
-
-/* Digits or letters may have special meaning; all others are literals. */
-
-else if (c < '0' || c > 'z') {}
-
-/* Do an initial lookup in a table. A non-zero result is something that can be
-returned immediately. Otherwise further processing may be required. */
-
-else if ((i = escapes[c - '0']) != 0) c = i;
-
-/* Escapes that need further processing, or are illegal. */
-
-else
- {
- const uschar *oldptr;
- switch (c)
- {
- /* The handling of escape sequences consisting of a string of digits
- starting with one that is not zero is not straightforward. By experiment,
- the way Perl works seems to be as follows:
-
- Outside a character class, the digits are read as a decimal number. If the
- number is less than 10, or if there are that many previous extracting
- left brackets, then it is a back reference. Otherwise, up to three octal
- digits are read to form an escaped byte. Thus \123 is likely to be octal
- 123 (cf \0123, which is octal 012 followed by the literal 3). If the octal
- value is greater than 377, the least significant 8 bits are taken. Inside a
- character class, \ followed by a digit is always an octal number. */
-
- case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9':
-
- if (!isclass)
- {
- oldptr = ptr;
- c -= '0';
- while ((cd->ctypes[ptr[1]] & ctype_digit) != 0)
- c = c * 10 + *(++ptr) - '0';
- if (c < 10 || c <= bracount)
- {
- c = -(ESC_REF + c);
- break;
- }
- ptr = oldptr; /* Put the pointer back and fall through */
- }
-
- /* Handle an octal number following \. If the first digit is 8 or 9, Perl
- generates a binary zero byte and treats the digit as a following literal.
- Thus we have to pull back the pointer by one. */
-
- if ((c = *ptr) >= '8')
- {
- ptr--;
- c = 0;
- break;
- }
-
- /* \0 always starts an octal number, but we may drop through to here with a
- larger first octal digit */
-
- case '0':
- c -= '0';
- while(i++ < 2 && (cd->ctypes[ptr[1]] & ctype_digit) != 0 &&
- ptr[1] != '8' && ptr[1] != '9')
- c = c * 8 + *(++ptr) - '0';
- break;
-
- /* Special escapes not starting with a digit are straightforward */
-
- case 'x':
- c = 0;
- while (i++ < 2 && (cd->ctypes[ptr[1]] & ctype_xdigit) != 0)
- {
- ptr++;
- c = c * 16 + cd->lcc[*ptr] -
- (((cd->ctypes[*ptr] & ctype_digit) != 0)? '0' : 'W');
- }
- break;
-
- case 'c':
- c = *(++ptr);
- if (c == 0)
- {
- *errorptr = ERR2;
- return 0;
- }
-
- /* A letter is upper-cased; then the 0x40 bit is flipped */
-
- if (c >= 'a' && c <= 'z') c = cd->fcc[c];
- c ^= 0x40;
- break;
-
- /* PCRE_EXTRA enables extensions to Perl in the matter of escapes. Any
- other alphameric following \ is an error if PCRE_EXTRA was set; otherwise,
- for Perl compatibility, it is a literal. This code looks a bit odd, but
- there used to be some cases other than the default, and there may be again
- in future, so I haven't "optimized" it. */
-
- default:
- if ((options & PCRE_EXTRA) != 0) switch(c)
- {
- default:
- *errorptr = ERR3;
- break;
- }
- break;
- }
- }
-
-*ptrptr = ptr;
-return c;
-}
-
-
-
-/*************************************************
-* Check for counted repeat *
-*************************************************/
-
-/* This function is called when a '{' is encountered in a place where it might
-start a quantifier. It looks ahead to see if it really is a quantifier or not.
-It is only a quantifier if it is one of the forms {ddd} {ddd,} or {ddd,ddd}
-where the ddds are digits.
-
-Arguments:
- p pointer to the first char after '{'
- cd pointer to char tables block
-
-Returns: TRUE or FALSE
-*/
-
-static BOOL
-is_counted_repeat(const uschar *p, compile_data *cd)
-{
-if ((cd->ctypes[*p++] & ctype_digit) == 0) return FALSE;
-while ((cd->ctypes[*p] & ctype_digit) != 0) p++;
-if (*p == '}') return TRUE;
-
-if (*p++ != ',') return FALSE;
-if (*p == '}') return TRUE;
-
-if ((cd->ctypes[*p++] & ctype_digit) == 0) return FALSE;
-while ((cd->ctypes[*p] & ctype_digit) != 0) p++;
-return (*p == '}');
-}
-
-
-
-/*************************************************
-* Read repeat counts *
-*************************************************/
-
-/* Read an item of the form {n,m} and return the values. This is called only
-after is_counted_repeat() has confirmed that a repeat-count quantifier exists,
-so the syntax is guaranteed to be correct, but we need to check the values.
-
-Arguments:
- p pointer to first char after '{'
- minp pointer to int for min
- maxp pointer to int for max
- returned as -1 if no max
- errorptr points to pointer to error message
- cd pointer to character tables clock
-
-Returns: pointer to '}' on success;
- current ptr on error, with errorptr set
-*/
-
-static const uschar *
-read_repeat_counts(const uschar *p, int *minp, int *maxp,
- const char **errorptr, compile_data *cd)
-{
-int min = 0;
-int max = -1;
-
-while ((cd->ctypes[*p] & ctype_digit) != 0) min = min * 10 + *p++ - '0';
-
-if (*p == '}') max = min; else
- {
- if (*(++p) != '}')
- {
- max = 0;
- while((cd->ctypes[*p] & ctype_digit) != 0) max = max * 10 + *p++ - '0';
- if (max < min)
- {
- *errorptr = ERR4;
- return p;
- }
- }
- }
-
-/* Do paranoid checks, then fill in the required variables, and pass back the
-pointer to the terminating '}'. */
-
-if (min > 65535 || max > 65535)
- *errorptr = ERR5;
-else
- {
- *minp = min;
- *maxp = max;
- }
-return p;
-}
-
-
-
-/*************************************************
-* Find the fixed length of a pattern *
-*************************************************/
-
-/* Scan a pattern and compute the fixed length of subject that will match it,
-if the length is fixed. This is needed for dealing with backward assertions.
-
-Arguments:
- code points to the start of the pattern (the bracket)
-
-Returns: the fixed length, or -1 if there is no fixed length
-*/
-
-static int
-find_fixedlength(uschar *code)
-{
-int length = -1;
-
-register int branchlength = 0;
-register uschar *cc = code + 3;
-
-/* Scan along the opcodes for this branch. If we get to the end of the
-branch, check the length against that of the other branches. */
-
-for (;;)
- {
- int d;
- register int op = *cc;
- if (op >= OP_BRA) op = OP_BRA;
-
- switch (op)
- {
- case OP_BRA:
- case OP_ONCE:
- case OP_COND:
- d = find_fixedlength(cc);
- if (d < 0) return -1;
- branchlength += d;
- do cc += (cc[1] << 8) + cc[2]; while (*cc == OP_ALT);
- cc += 3;
- break;
-
- /* Reached end of a branch; if it's a ket it is the end of a nested
- call. If it's ALT it is an alternation in a nested call. If it is
- END it's the end of the outer call. All can be handled by the same code. */
-
- case OP_ALT:
- case OP_KET:
- case OP_KETRMAX:
- case OP_KETRMIN:
- case OP_END:
- if (length < 0) length = branchlength;
- else if (length != branchlength) return -1;
- if (*cc != OP_ALT) return length;
- cc += 3;
- branchlength = 0;
- break;
-
- /* Skip over assertive subpatterns */
-
- case OP_ASSERT:
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- do cc += (cc[1] << 8) + cc[2]; while (*cc == OP_ALT);
- cc += 3;
- break;
-
- /* Skip over things that don't match chars */
-
- case OP_REVERSE:
- cc++;
- /* Fall through */
-
- case OP_CREF:
- case OP_OPT:
- cc++;
- /* Fall through */
-
- case OP_SOD:
- case OP_EOD:
- case OP_EODN:
- case OP_CIRC:
- case OP_DOLL:
- case OP_NOT_WORD_BOUNDARY:
- case OP_WORD_BOUNDARY:
- cc++;
- break;
-
- /* Handle char strings */
-
- case OP_CHARS:
- branchlength += *(++cc);
- cc += *cc + 1;
- break;
-
- /* Handle exact repetitions */
-
- case OP_EXACT:
- case OP_TYPEEXACT:
- branchlength += (cc[1] << 8) + cc[2];
- cc += 4;
- break;
-
- /* Handle single-char matchers */
-
- case OP_NOT_DIGIT:
- case OP_DIGIT:
- case OP_NOT_WHITESPACE:
- case OP_WHITESPACE:
- case OP_NOT_WORDCHAR:
- case OP_WORDCHAR:
- case OP_ANY:
- branchlength++;
- cc++;
- break;
-
-
- /* Check a class for variable quantification */
-
- case OP_CLASS:
- cc += (*cc == OP_REF)? 2 : 33;
-
- switch (*cc)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- return -1;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- if ((cc[1] << 8) + cc[2] != (cc[3] << 8) + cc[4]) return -1;
- branchlength += (cc[1] << 8) + cc[2];
- cc += 5;
- break;
-
- default:
- branchlength++;
- }
- break;
-
- /* Anything else is variable length */
-
- default:
- return -1;
- }
- }
-/* Control never gets here */
-}
-
-
-
-
-/*************************************************
-* Compile one branch *
-*************************************************/
-
-/* Scan the pattern, compiling it into the code vector.
-
-Arguments:
- options the option bits
- brackets points to number of brackets used
- code points to the pointer to the current code point
- ptrptr points to the current pattern pointer
- errorptr points to pointer to error message
- optchanged set to the value of the last OP_OPT item compiled
- reqchar set to the last literal character required, else -1
- countlits set to count of mandatory literal characters
- cd contains pointers to tables
-
-Returns: TRUE on success
- FALSE, with *errorptr set on error
-*/
-
-static BOOL
-compile_branch(int options, int *brackets, uschar **codeptr,
- const uschar **ptrptr, const char **errorptr, int *optchanged,
- int *reqchar, int *countlits, compile_data *cd)
-{
-int repeat_type, op_type;
-int repeat_min, repeat_max;
-int bravalue, length;
-int greedy_default, greedy_non_default;
-int prevreqchar;
-int condcount = 0;
-int subcountlits = 0;
-register int c;
-register uschar *code = *codeptr;
-uschar *tempcode;
-const uschar *ptr = *ptrptr;
-const uschar *tempptr;
-uschar *previous = NULL;
-uschar class[32];
-
-/* Set up the default and non-default settings for greediness */
-
-greedy_default = ((options & PCRE_UNGREEDY) != 0);
-greedy_non_default = greedy_default ^ 1;
-
-/* Initialize no required char, and count of literals */
-
-*reqchar = prevreqchar = -1;
-*countlits = 0;
-
-/* Switch on next character until the end of the branch */
-
-for (;; ptr++)
- {
- BOOL negate_class;
- int class_charcount;
- int class_lastchar;
- int newoptions;
- int condref;
- int subreqchar;
-
- c = *ptr;
- if ((options & PCRE_EXTENDED) != 0)
- {
- if ((cd->ctypes[c] & ctype_space) != 0) continue;
- if (c == '#')
- {
- while ((c = *(++ptr)) != 0 && c != '\n');
- continue;
- }
- }
-
- switch(c)
- {
- /* The branch terminates at end of string, |, or ). */
-
- case 0:
- case '|':
- case ')':
- *codeptr = code;
- *ptrptr = ptr;
- return TRUE;
-
- /* Handle single-character metacharacters */
-
- case '^':
- previous = NULL;
- *code++ = OP_CIRC;
- break;
-
- case '$':
- previous = NULL;
- *code++ = OP_DOLL;
- break;
-
- case '.':
- previous = code;
- *code++ = OP_ANY;
- break;
-
- /* Character classes. These always build a 32-byte bitmap of the permitted
- characters, except in the special case where there is only one character.
- For negated classes, we build the map as usual, then invert it at the end.
- */
-
- case '[':
- previous = code;
- *code++ = OP_CLASS;
-
- /* If the first character is '^', set the negation flag and skip it. */
-
- if ((c = *(++ptr)) == '^')
- {
- negate_class = TRUE;
- c = *(++ptr);
- }
- else negate_class = FALSE;
-
- /* Keep a count of chars so that we can optimize the case of just a single
- character. */
-
- class_charcount = 0;
- class_lastchar = -1;
-
- /* Initialize the 32-char bit map to all zeros. We have to build the
- map in a temporary bit of store, in case the class contains only 1
- character, because in that case the compiled code doesn't use the
- bit map. */
-
- memset(class, 0, 32 * sizeof(uschar));
-
- /* Process characters until ] is reached. By writing this as a "do" it
- means that an initial ] is taken as a data character. */
-
- do
- {
- if (c == 0)
- {
- *errorptr = ERR6;
- goto FAILED;
- }
-
- /* Backslash may introduce a single character, or it may introduce one
- of the specials, which just set a flag. Escaped items are checked for
- validity in the pre-compiling pass. The sequence \b is a special case.
- Inside a class (and only there) it is treated as backspace. Elsewhere
- it marks a word boundary. Other escapes have preset maps ready to
- or into the one we are building. We assume they have more than one
- character in them, so set class_count bigger than one. */
-
- if (c == '\\')
- {
- c = check_escape(&ptr, errorptr, *brackets, options, TRUE, cd);
- if (-c == ESC_b) c = '\b';
- else if (c < 0)
- {
- register const uschar *cbits = cd->cbits;
- class_charcount = 10;
- switch (-c)
- {
- case ESC_d:
- for (c = 0; c < 32; c++) class[c] |= cbits[c+cbit_digit];
- continue;
-
- case ESC_D:
- for (c = 0; c < 32; c++) class[c] |= ~cbits[c+cbit_digit];
- continue;
-
- case ESC_w:
- for (c = 0; c < 32; c++)
- class[c] |= (cbits[c+cbit_digit] | cbits[c+cbit_word]);
- continue;
-
- case ESC_W:
- for (c = 0; c < 32; c++)
- class[c] |= ~(cbits[c+cbit_digit] | cbits[c+cbit_word]);
- continue;
-
- case ESC_s:
- for (c = 0; c < 32; c++) class[c] |= cbits[c+cbit_space];
- continue;
-
- case ESC_S:
- for (c = 0; c < 32; c++) class[c] |= ~cbits[c+cbit_space];
- continue;
-
- default:
- *errorptr = ERR7;
- goto FAILED;
- }
- }
- /* Fall through if single character */
- }
-
- /* A single character may be followed by '-' to form a range. However,
- Perl does not permit ']' to be the end of the range. A '-' character
- here is treated as a literal. */
-
- if (ptr[1] == '-' && ptr[2] != ']')
- {
- int d;
- ptr += 2;
- d = *ptr;
-
- if (d == 0)
- {
- *errorptr = ERR6;
- goto FAILED;
- }
-
- /* The second part of a range can be a single-character escape, but
- not any of the other escapes. */
-
- if (d == '\\')
- {
- d = check_escape(&ptr, errorptr, *brackets, options, TRUE, cd);
- if (d < 0)
- {
- if (d == -ESC_b) d = '\b'; else
- {
- *errorptr = ERR7;
- goto FAILED;
- }
- }
- }
-
- if (d < c)
- {
- *errorptr = ERR8;
- goto FAILED;
- }
-
- for (; c <= d; c++)
- {
- class[c/8] |= (1 << (c&7));
- if ((options & PCRE_CASELESS) != 0)
- {
- int uc = cd->fcc[c]; /* flip case */
- class[uc/8] |= (1 << (uc&7));
- }
- class_charcount++; /* in case a one-char range */
- class_lastchar = c;
- }
- continue; /* Go get the next char in the class */
- }
-
- /* Handle a lone single character - we can get here for a normal
- non-escape char, or after \ that introduces a single character. */
-
- class [c/8] |= (1 << (c&7));
- if ((options & PCRE_CASELESS) != 0)
- {
- c = cd->fcc[c]; /* flip case */
- class[c/8] |= (1 << (c&7));
- }
- class_charcount++;
- class_lastchar = c;
- }
-
- /* Loop until ']' reached; the check for end of string happens inside the
- loop. This "while" is the end of the "do" above. */
-
- while ((c = *(++ptr)) != ']');
-
- /* If class_charcount is 1 and class_lastchar is not negative, we saw
- precisely one character. This doesn't need the whole 32-byte bit map.
- We turn it into a 1-character OP_CHAR if it's positive, or OP_NOT if
- it's negative. */
-
- if (class_charcount == 1 && class_lastchar >= 0)
- {
- if (negate_class)
- {
- code[-1] = OP_NOT;
- }
- else
- {
- code[-1] = OP_CHARS;
- *code++ = 1;
- }
- *code++ = class_lastchar;
- }
-
- /* Otherwise, negate the 32-byte map if necessary, and copy it into
- the code vector. */
-
- else
- {
- if (negate_class)
- for (c = 0; c < 32; c++) code[c] = ~class[c];
- else
- memcpy(code, class, 32);
- code += 32;
- }
- break;
-
- /* Various kinds of repeat */
-
- case '{':
- if (!is_counted_repeat(ptr+1, cd)) goto NORMAL_CHAR;
- ptr = read_repeat_counts(ptr+1, &repeat_min, &repeat_max, errorptr, cd);
- if (*errorptr != NULL) goto FAILED;
- goto REPEAT;
-
- case '*':
- repeat_min = 0;
- repeat_max = -1;
- goto REPEAT;
-
- case '+':
- repeat_min = 1;
- repeat_max = -1;
- goto REPEAT;
-
- case '?':
- repeat_min = 0;
- repeat_max = 1;
-
- REPEAT:
- if (previous == NULL)
- {
- *errorptr = ERR9;
- goto FAILED;
- }
-
- /* If the next character is '?' this is a minimizing repeat, by default,
- but if PCRE_UNGREEDY is set, it works the other way round. Advance to the
- next character. */
-
- if (ptr[1] == '?')
- { repeat_type = greedy_non_default; ptr++; }
- else repeat_type = greedy_default;
-
- /* If previous was a string of characters, chop off the last one and use it
- as the subject of the repeat. If there was only one character, we can
- abolish the previous item altogether. A repeat with a zero minimum wipes
- out any reqchar setting, backing up to the previous value. We must also
- adjust the countlits value. */
-
- if (*previous == OP_CHARS)
- {
- int len = previous[1];
-
- if (repeat_min == 0) *reqchar = prevreqchar;
- *countlits += repeat_min - 1;
-
- if (len == 1)
- {
- c = previous[2];
- code = previous;
- }
- else
- {
- c = previous[len+1];
- previous[1]--;
- code--;
- }
- op_type = 0; /* Use single-char op codes */
- goto OUTPUT_SINGLE_REPEAT; /* Code shared with single character types */
- }
-
- /* If previous was a single negated character ([^a] or similar), we use
- one of the special opcodes, replacing it. The code is shared with single-
- character repeats by adding a suitable offset into repeat_type. */
-
- else if ((int)*previous == OP_NOT)
- {
- op_type = OP_NOTSTAR - OP_STAR; /* Use "not" opcodes */
- c = previous[1];
- code = previous;
- goto OUTPUT_SINGLE_REPEAT;
- }
-
- /* If previous was a character type match (\d or similar), abolish it and
- create a suitable repeat item. The code is shared with single-character
- repeats by adding a suitable offset into repeat_type. */
-
- else if ((int)*previous < OP_EODN || *previous == OP_ANY)
- {
- op_type = OP_TYPESTAR - OP_STAR; /* Use type opcodes */
- c = *previous;
- code = previous;
-
- OUTPUT_SINGLE_REPEAT:
-
- /* If the maximum is zero then the minimum must also be zero; Perl allows
- this case, so we do too - by simply omitting the item altogether. */
-
- if (repeat_max == 0) goto END_REPEAT;
-
- /* Combine the op_type with the repeat_type */
-
- repeat_type += op_type;
-
- /* A minimum of zero is handled either as the special case * or ?, or as
- an UPTO, with the maximum given. */
-
- if (repeat_min == 0)
- {
- if (repeat_max == -1) *code++ = OP_STAR + repeat_type;
- else if (repeat_max == 1) *code++ = OP_QUERY + repeat_type;
- else
- {
- *code++ = OP_UPTO + repeat_type;
- *code++ = repeat_max >> 8;
- *code++ = (repeat_max & 255);
- }
- }
-
- /* The case {1,} is handled as the special case + */
-
- else if (repeat_min == 1 && repeat_max == -1)
- *code++ = OP_PLUS + repeat_type;
-
- /* The case {n,n} is just an EXACT, while the general case {n,m} is
- handled as an EXACT followed by an UPTO. An EXACT of 1 is optimized. */
-
- else
- {
- if (repeat_min != 1)
- {
- *code++ = OP_EXACT + op_type; /* NB EXACT doesn't have repeat_type */
- *code++ = repeat_min >> 8;
- *code++ = (repeat_min & 255);
- }
-
- /* If the mininum is 1 and the previous item was a character string,
- we either have to put back the item that got cancelled if the string
- length was 1, or add the character back onto the end of a longer
- string. For a character type nothing need be done; it will just get
- put back naturally. Note that the final character is always going to
- get added below. */
-
- else if (*previous == OP_CHARS)
- {
- if (code == previous) code += 2; else previous[1]++;
- }
-
- /* For a single negated character we also have to put back the
- item that got cancelled. */
-
- else if (*previous == OP_NOT) code++;
-
- /* If the maximum is unlimited, insert an OP_STAR. */
-
- if (repeat_max < 0)
- {
- *code++ = c;
- *code++ = OP_STAR + repeat_type;
- }
-
- /* Else insert an UPTO if the max is greater than the min. */
-
- else if (repeat_max != repeat_min)
- {
- *code++ = c;
- repeat_max -= repeat_min;
- *code++ = OP_UPTO + repeat_type;
- *code++ = repeat_max >> 8;
- *code++ = (repeat_max & 255);
- }
- }
-
- /* The character or character type itself comes last in all cases. */
-
- *code++ = c;
- }
-
- /* If previous was a character class or a back reference, we put the repeat
- stuff after it, but just skip the item if the repeat was {0,0}. */
-
- else if (*previous == OP_CLASS || *previous == OP_REF)
- {
- if (repeat_max == 0)
- {
- code = previous;
- goto END_REPEAT;
- }
- if (repeat_min == 0 && repeat_max == -1)
- *code++ = OP_CRSTAR + repeat_type;
- else if (repeat_min == 1 && repeat_max == -1)
- *code++ = OP_CRPLUS + repeat_type;
- else if (repeat_min == 0 && repeat_max == 1)
- *code++ = OP_CRQUERY + repeat_type;
- else
- {
- *code++ = OP_CRRANGE + repeat_type;
- *code++ = repeat_min >> 8;
- *code++ = repeat_min & 255;
- if (repeat_max == -1) repeat_max = 0; /* 2-byte encoding for max */
- *code++ = repeat_max >> 8;
- *code++ = repeat_max & 255;
- }
- }
-
- /* If previous was a bracket group, we may have to replicate it in certain
- cases. */
-
- else if ((int)*previous >= OP_BRA || (int)*previous == OP_ONCE ||
- (int)*previous == OP_COND)
- {
- register int i;
- int ketoffset = 0;
- int len = code - previous;
- uschar *bralink = NULL;
-
- /* If the maximum repeat count is unlimited, find the end of the bracket
- by scanning through from the start, and compute the offset back to it
- from the current code pointer. There may be an OP_OPT setting following
- the final KET, so we can't find the end just by going back from the code
- pointer. */
-
- if (repeat_max == -1)
- {
- register uschar *ket = previous;
- do ket += (ket[1] << 8) + ket[2]; while (*ket != OP_KET);
- ketoffset = code - ket;
- }
-
- /* The case of a zero minimum is special because of the need to stick
- OP_BRAZERO in front of it, and because the group appears once in the
- data, whereas in other cases it appears the minimum number of times. For
- this reason, it is simplest to treat this case separately, as otherwise
- the code gets far too mess. There are several special subcases when the
- minimum is zero. */
-
- if (repeat_min == 0)
- {
- /* If we set up a required char from the bracket, we must back off
- to the previous value and reset the countlits value too. */
-
- if (subcountlits > 0)
- {
- *reqchar = prevreqchar;
- *countlits -= subcountlits;
- }
-
- /* If the maximum is also zero, we just omit the group from the output
- altogether. */
-
- if (repeat_max == 0)
- {
- code = previous;
- goto END_REPEAT;
- }
-
- /* If the maximum is 1 or unlimited, we just have to stick in the
- BRAZERO and do no more at this point. */
-
- if (repeat_max <= 1)
- {
- memmove(previous+1, previous, len);
- code++;
- *previous++ = OP_BRAZERO + repeat_type;
- }
-
- /* If the maximum is greater than 1 and limited, we have to replicate
- in a nested fashion, sticking OP_BRAZERO before each set of brackets.
- The first one has to be handled carefully because it's the original
- copy, which has to be moved up. The remainder can be handled by code
- that is common with the non-zero minimum case below. We just have to
- adjust the value or repeat_max, since one less copy is required. */
-
- else
- {
- int offset;
- memmove(previous+4, previous, len);
- code += 4;
- *previous++ = OP_BRAZERO + repeat_type;
- *previous++ = OP_BRA;
-
- /* We chain together the bracket offset fields that have to be
- filled in later when the ends of the brackets are reached. */
-
- offset = (bralink == NULL)? 0 : previous - bralink;
- bralink = previous;
- *previous++ = offset >> 8;
- *previous++ = offset & 255;
- }
-
- repeat_max--;
- }
-
- /* If the minimum is greater than zero, replicate the group as many
- times as necessary, and adjust the maximum to the number of subsequent
- copies that we need. */
-
- else
- {
- for (i = 1; i < repeat_min; i++)
- {
- memcpy(code, previous, len);
- code += len;
- }
- if (repeat_max > 0) repeat_max -= repeat_min;
- }
-
- /* This code is common to both the zero and non-zero minimum cases. If
- the maximum is limited, it replicates the group in a nested fashion,
- remembering the bracket starts on a stack. In the case of a zero minimum,
- the first one was set up above. In all cases the repeat_max now specifies
- the number of additional copies needed. */
-
- if (repeat_max >= 0)
- {
- for (i = repeat_max - 1; i >= 0; i--)
- {
- *code++ = OP_BRAZERO + repeat_type;
-
- /* All but the final copy start a new nesting, maintaining the
- chain of brackets outstanding. */
-
- if (i != 0)
- {
- int offset;
- *code++ = OP_BRA;
- offset = (bralink == NULL)? 0 : code - bralink;
- bralink = code;
- *code++ = offset >> 8;
- *code++ = offset & 255;
- }
-
- memcpy(code, previous, len);
- code += len;
- }
-
- /* Now chain through the pending brackets, and fill in their length
- fields (which are holding the chain links pro tem). */
-
- while (bralink != NULL)
- {
- int oldlinkoffset;
- int offset = code - bralink + 1;
- uschar *bra = code - offset;
- oldlinkoffset = (bra[1] << 8) + bra[2];
- bralink = (oldlinkoffset == 0)? NULL : bralink - oldlinkoffset;
- *code++ = OP_KET;
- *code++ = bra[1] = offset >> 8;
- *code++ = bra[2] = (offset & 255);
- }
- }
-
- /* If the maximum is unlimited, set a repeater in the final copy. We
- can't just offset backwards from the current code point, because we
- don't know if there's been an options resetting after the ket. The
- correct offset was computed above. */
-
- else code[-ketoffset] = OP_KETRMAX + repeat_type;
- }
-
- /* Else there's some kind of shambles */
-
- else
- {
- *errorptr = ERR11;
- goto FAILED;
- }
-
- /* In all case we no longer have a previous item. */
-
- END_REPEAT:
- previous = NULL;
- break;
-
-
- /* Start of nested bracket sub-expression, or comment or lookahead or
- lookbehind or option setting or condition. First deal with special things
- that can come after a bracket; all are introduced by ?, and the appearance
- of any of them means that this is not a referencing group. They were
- checked for validity in the first pass over the string, so we don't have to
- check for syntax errors here. */
-
- case '(':
- newoptions = options;
- condref = -1;
-
- if (*(++ptr) == '?')
- {
- int set, unset;
- int *optset;
-
- switch (*(++ptr))
- {
- case '#': /* Comment; skip to ket */
- ptr++;
- while (*ptr != ')') ptr++;
- continue;
-
- case ':': /* Non-extracting bracket */
- bravalue = OP_BRA;
- ptr++;
- break;
-
- case '(':
- bravalue = OP_COND; /* Conditional group */
- if ((cd->ctypes[*(++ptr)] & ctype_digit) != 0)
- {
- condref = *ptr - '0';
- while (*(++ptr) != ')') condref = condref*10 + *ptr - '0';
- ptr++;
- }
- else ptr--;
- break;
-
- case '=': /* Positive lookahead */
- bravalue = OP_ASSERT;
- ptr++;
- break;
-
- case '!': /* Negative lookahead */
- bravalue = OP_ASSERT_NOT;
- ptr++;
- break;
-
- case '<': /* Lookbehinds */
- switch (*(++ptr))
- {
- case '=': /* Positive lookbehind */
- bravalue = OP_ASSERTBACK;
- ptr++;
- break;
-
- case '!': /* Negative lookbehind */
- bravalue = OP_ASSERTBACK_NOT;
- ptr++;
- break;
-
- default: /* Syntax error */
- *errorptr = ERR24;
- goto FAILED;
- }
- break;
-
- case '>': /* One-time brackets */
- bravalue = OP_ONCE;
- ptr++;
- break;
-
- default: /* Option setting */
- set = unset = 0;
- optset = &set;
-
- while (*ptr != ')' && *ptr != ':')
- {
- switch (*ptr++)
- {
- case '-': optset = &unset; break;
-
- case 'i': *optset |= PCRE_CASELESS; break;
- case 'm': *optset |= PCRE_MULTILINE; break;
- case 's': *optset |= PCRE_DOTALL; break;
- case 'x': *optset |= PCRE_EXTENDED; break;
- case 'U': *optset |= PCRE_UNGREEDY; break;
- case 'X': *optset |= PCRE_EXTRA; break;
-
- default:
- *errorptr = ERR12;
- goto FAILED;
- }
- }
-
- /* Set up the changed option bits, but don't change anything yet. */
-
- newoptions = (options | set) & (~unset);
-
- /* If the options ended with ')' this is not the start of a nested
- group with option changes, so the options change at this level. At top
- level there is nothing else to be done (the options will in fact have
- been set from the start of compiling as a result of the first pass) but
- at an inner level we must compile code to change the ims options if
- necessary, and pass the new setting back so that it can be put at the
- start of any following branches, and when this group ends, a resetting
- item can be compiled. */
-
- if (*ptr == ')')
- {
- if ((options & PCRE_INGROUP) != 0 &&
- (options & PCRE_IMS) != (newoptions & PCRE_IMS))
- {
- *code++ = OP_OPT;
- *code++ = *optchanged = newoptions & PCRE_IMS;
- }
- options = newoptions; /* Change options at this level */
- previous = NULL; /* This item can't be repeated */
- continue; /* It is complete */
- }
-
- /* If the options ended with ':' we are heading into a nested group
- with possible change of options. Such groups are non-capturing and are
- not assertions of any kind. All we need to do is skip over the ':';
- the newoptions value is handled below. */
-
- bravalue = OP_BRA;
- ptr++;
- }
- }
-
- /* Else we have a referencing group; adjust the opcode. */
-
- else
- {
- if (++(*brackets) > EXTRACT_MAX)
- {
- *errorptr = ERR13;
- goto FAILED;
- }
- bravalue = OP_BRA + *brackets;
- }
-
- /* Process nested bracketed re. Assertions may not be repeated, but other
- kinds can be. We copy code into a non-register variable in order to be able
- to pass its address because some compilers complain otherwise. Pass in a
- new setting for the ims options if they have changed. */
-
- previous = (bravalue >= OP_ONCE)? code : NULL;
- *code = bravalue;
- tempcode = code;
-
- if (!compile_regex(
- options | PCRE_INGROUP, /* Set for all nested groups */
- ((options & PCRE_IMS) != (newoptions & PCRE_IMS))?
- newoptions & PCRE_IMS : -1, /* Pass ims options if changed */
- brackets, /* Bracket level */
- &tempcode, /* Where to put code (updated) */
- &ptr, /* Input pointer (updated) */
- errorptr, /* Where to put an error message */
- (bravalue == OP_ASSERTBACK ||
- bravalue == OP_ASSERTBACK_NOT), /* TRUE if back assert */
- condref, /* Condition reference number */
- &subreqchar, /* For possible last char */
- &subcountlits, /* For literal count */
- cd)) /* Tables block */
- goto FAILED;
-
- /* At the end of compiling, code is still pointing to the start of the
- group, while tempcode has been updated to point past the end of the group
- and any option resetting that may follow it. The pattern pointer (ptr)
- is on the bracket. */
-
- /* If this is a conditional bracket, check that there are no more than
- two branches in the group. */
-
- if (bravalue == OP_COND)
- {
- uschar *tc = code;
- condcount = 0;
-
- do {
- condcount++;
- tc += (tc[1] << 8) | tc[2];
- }
- while (*tc != OP_KET);
-
- if (condcount > 2)
- {
- *errorptr = ERR27;
- goto FAILED;
- }
- }
-
- /* Handle updating of the required character. If the subpattern didn't
- set one, leave it as it was. Otherwise, update it for normal brackets of
- all kinds, forward assertions, and conditions with two branches. Don't
- update the literal count for forward assertions, however. If the bracket
- is followed by a quantifier with zero repeat, we have to back off. Hence
- the definition of prevreqchar and subcountlits outside the main loop so
- that they can be accessed for the back off. */
-
- if (subreqchar > 0 &&
- (bravalue >= OP_BRA || bravalue == OP_ONCE || bravalue == OP_ASSERT ||
- (bravalue == OP_COND && condcount == 2)))
- {
- prevreqchar = *reqchar;
- *reqchar = subreqchar;
- if (bravalue != OP_ASSERT) *countlits += subcountlits;
- }
-
- /* Now update the main code pointer to the end of the group. */
-
- code = tempcode;
-
- /* Error if hit end of pattern */
-
- if (*ptr != ')')
- {
- *errorptr = ERR14;
- goto FAILED;
- }
- break;
-
- /* Check \ for being a real metacharacter; if not, fall through and handle
- it as a data character at the start of a string. Escape items are checked
- for validity in the pre-compiling pass. */
-
- case '\\':
- tempptr = ptr;
- c = check_escape(&ptr, errorptr, *brackets, options, FALSE, cd);
-
- /* Handle metacharacters introduced by \. For ones like \d, the ESC_ values
- are arranged to be the negation of the corresponding OP_values. For the
- back references, the values are ESC_REF plus the reference number. Only
- back references and those types that consume a character may be repeated.
- We can test for values between ESC_b and ESC_Z for the latter; this may
- have to change if any new ones are ever created. */
-
- if (c < 0)
- {
- if (-c >= ESC_REF)
- {
- previous = code;
- *code++ = OP_REF;
- *code++ = -c - ESC_REF;
- }
- else
- {
- previous = (-c > ESC_b && -c < ESC_Z)? code : NULL;
- *code++ = -c;
- }
- continue;
- }
-
- /* Data character: reset and fall through */
-
- ptr = tempptr;
- c = '\\';
-
- /* Handle a run of data characters until a metacharacter is encountered.
- The first character is guaranteed not to be whitespace or # when the
- extended flag is set. */
-
- NORMAL_CHAR:
- default:
- previous = code;
- *code = OP_CHARS;
- code += 2;
- length = 0;
-
- do
- {
- if ((options & PCRE_EXTENDED) != 0)
- {
- if ((cd->ctypes[c] & ctype_space) != 0) continue;
- if (c == '#')
- {
- while ((c = *(++ptr)) != 0 && c != '\n');
- if (c == 0) break;
- continue;
- }
- }
-
- /* Backslash may introduce a data char or a metacharacter. Escaped items
- are checked for validity in the pre-compiling pass. Stop the string
- before a metaitem. */
-
- if (c == '\\')
- {
- tempptr = ptr;
- c = check_escape(&ptr, errorptr, *brackets, options, FALSE, cd);
- if (c < 0) { ptr = tempptr; break; }
- }
-
- /* Ordinary character or single-char escape */
-
- *code++ = c;
- length++;
- }
-
- /* This "while" is the end of the "do" above. */
-
- while (length < 255 && (cd->ctypes[c = *(++ptr)] & ctype_meta) == 0);
-
- /* Update the last character and the count of literals */
-
- prevreqchar = (length > 1)? code[-2] : *reqchar;
- *reqchar = code[-1];
- *countlits += length;
-
- /* Compute the length and set it in the data vector, and advance to
- the next state. */
-
- previous[1] = length;
- if (length < 255) ptr--;
- break;
- }
- } /* end of big loop */
-
-/* Control never reaches here by falling through, only by a goto for all the
-error states. Pass back the position in the pattern so that it can be displayed
-to the user for diagnosing the error. */
-
-FAILED:
-*ptrptr = ptr;
-return FALSE;
-}
-
-
-
-
-/*************************************************
-* Compile sequence of alternatives *
-*************************************************/
-
-/* On entry, ptr is pointing past the bracket character, but on return
-it points to the closing bracket, or vertical bar, or end of string.
-The code variable is pointing at the byte into which the BRA operator has been
-stored. If the ims options are changed at the start (for a (?ims: group) or
-during any branch, we need to insert an OP_OPT item at the start of every
-following branch to ensure they get set correctly at run time, and also pass
-the new options into every subsequent branch compile.
-
-Argument:
- options the option bits
- optchanged new ims options to set as if (?ims) were at the start, or -1
- for no change
- brackets -> int containing the number of extracting brackets used
- codeptr -> the address of the current code pointer
- ptrptr -> the address of the current pattern pointer
- errorptr -> pointer to error message
- lookbehind TRUE if this is a lookbehind assertion
- condref > 0 for OPT_CREF setting at start of conditional group
- reqchar -> place to put the last required character, or a negative number
- countlits -> place to put the shortest literal count of any branch
- cd points to the data block with tables pointers
-
-Returns: TRUE on success
-*/
-
-static BOOL
-compile_regex(int options, int optchanged, int *brackets, uschar **codeptr,
- const uschar **ptrptr, const char **errorptr, BOOL lookbehind, int condref,
- int *reqchar, int *countlits, compile_data *cd)
-{
-const uschar *ptr = *ptrptr;
-uschar *code = *codeptr;
-uschar *last_branch = code;
-uschar *start_bracket = code;
-uschar *reverse_count = NULL;
-int oldoptions = options & PCRE_IMS;
-int branchreqchar, branchcountlits;
-
-*reqchar = -1;
-*countlits = INT_MAX;
-code += 3;
-
-/* At the start of a reference-based conditional group, insert the reference
-number as an OP_CREF item. */
-
-if (condref > 0)
- {
- *code++ = OP_CREF;
- *code++ = condref;
- }
-
-/* Loop for each alternative branch */
-
-for (;;)
- {
- int length;
-
- /* Handle change of options */
-
- if (optchanged >= 0)
- {
- *code++ = OP_OPT;
- *code++ = optchanged;
- options = (options & ~PCRE_IMS) | optchanged;
- }
-
- /* Set up dummy OP_REVERSE if lookbehind assertion */
-
- if (lookbehind)
- {
- *code++ = OP_REVERSE;
- reverse_count = code;
- *code++ = 0;
- *code++ = 0;
- }
-
- /* Now compile the branch */
-
- if (!compile_branch(options, brackets, &code, &ptr, errorptr, &optchanged,
- &branchreqchar, &branchcountlits, cd))
- {
- *ptrptr = ptr;
- return FALSE;
- }
-
- /* Fill in the length of the last branch */
-
- length = code - last_branch;
- last_branch[1] = length >> 8;
- last_branch[2] = length & 255;
-
- /* Save the last required character if all branches have the same; a current
- value of -1 means unset, while -2 means "previous branch had no last required
- char". */
-
- if (*reqchar != -2)
- {
- if (branchreqchar >= 0)
- {
- if (*reqchar == -1) *reqchar = branchreqchar;
- else if (*reqchar != branchreqchar) *reqchar = -2;
- }
- else *reqchar = -2;
- }
-
- /* Keep the shortest literal count */
-
- if (branchcountlits < *countlits) *countlits = branchcountlits;
- DPRINTF(("literal count = %d min=%d\n", branchcountlits, *countlits));
-
- /* If lookbehind, check that this branch matches a fixed-length string,
- and put the length into the OP_REVERSE item. Temporarily mark the end of
- the branch with OP_END. */
-
- if (lookbehind)
- {
- *code = OP_END;
- length = find_fixedlength(last_branch);
- DPRINTF(("fixed length = %d\n", length));
- if (length < 0)
- {
- *errorptr = ERR25;
- *ptrptr = ptr;
- return FALSE;
- }
- reverse_count[0] = (length >> 8);
- reverse_count[1] = length & 255;
- }
-
- /* Reached end of expression, either ')' or end of pattern. Insert a
- terminating ket and the length of the whole bracketed item, and return,
- leaving the pointer at the terminating char. If any of the ims options
- were changed inside the group, compile a resetting op-code following. */
-
- if (*ptr != '|')
- {
- length = code - start_bracket;
- *code++ = OP_KET;
- *code++ = length >> 8;
- *code++ = length & 255;
- if (optchanged >= 0)
- {
- *code++ = OP_OPT;
- *code++ = oldoptions;
- }
- *codeptr = code;
- *ptrptr = ptr;
- return TRUE;
- }
-
- /* Another branch follows; insert an "or" node and advance the pointer. */
-
- *code = OP_ALT;
- last_branch = code;
- code += 3;
- ptr++;
- }
-/* Control never reaches here */
-}
-
-
-
-
-/*************************************************
-* Find first significant op code *
-*************************************************/
-
-/* This is called by several functions that scan a compiled expression looking
-for a fixed first character, or an anchoring op code etc. It skips over things
-that do not influence this. For one application, a change of caseless option is
-important.
-
-Arguments:
- code pointer to the start of the group
- options pointer to external options
- optbit the option bit whose changing is significant, or
- zero if none are
- optstop TRUE to return on option change, otherwise change the options
- value and continue
-
-Returns: pointer to the first significant opcode
-*/
-
-static const uschar*
-first_significant_code(const uschar *code, int *options, int optbit,
- BOOL optstop)
-{
-for (;;)
- {
- switch ((int)*code)
- {
- case OP_OPT:
- if (optbit > 0 && ((int)code[1] & optbit) != (*options & optbit))
- {
- if (optstop) return code;
- *options = (int)code[1];
- }
- code += 2;
- break;
-
- case OP_CREF:
- code += 2;
- break;
-
- case OP_WORD_BOUNDARY:
- case OP_NOT_WORD_BOUNDARY:
- code++;
- break;
-
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- do code += (code[1] << 8) + code[2]; while (*code == OP_ALT);
- code += 3;
- break;
-
- default:
- return code;
- }
- }
-/* Control never reaches here */
-}
-
-
-
-
-/*************************************************
-* Check for anchored expression *
-*************************************************/
-
-/* Try to find out if this is an anchored regular expression. Consider each
-alternative branch. If they all start with OP_SOD or OP_CIRC, or with a bracket
-all of whose alternatives start with OP_SOD or OP_CIRC (recurse ad lib), then
-it's anchored. However, if this is a multiline pattern, then only OP_SOD
-counts, since OP_CIRC can match in the middle.
-
-A branch is also implicitly anchored if it starts with .* and DOTALL is set,
-because that will try the rest of the pattern at all possible matching points,
-so there is no point trying them again.
-
-Arguments:
- code points to start of expression (the bracket)
- options points to the options setting
-
-Returns: TRUE or FALSE
-*/
-
-static BOOL
-is_anchored(register const uschar *code, int *options)
-{
-do {
- const uschar *scode = first_significant_code(code + 3, options,
- PCRE_MULTILINE, FALSE);
- register int op = *scode;
- if (op >= OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND)
- { if (!is_anchored(scode, options)) return FALSE; }
- else if ((op == OP_TYPESTAR || op == OP_TYPEMINSTAR) &&
- (*options & PCRE_DOTALL) != 0)
- { if (scode[1] != OP_ANY) return FALSE; }
- else if (op != OP_SOD &&
- ((*options & PCRE_MULTILINE) != 0 || op != OP_CIRC))
- return FALSE;
- code += (code[1] << 8) + code[2];
- }
-while (*code == OP_ALT);
-return TRUE;
-}
-
-
-
-/*************************************************
-* Check for starting with ^ or .* *
-*************************************************/
-
-/* This is called to find out if every branch starts with ^ or .* so that
-"first char" processing can be done to speed things up in multiline
-matching and for non-DOTALL patterns that start with .* (which must start at
-the beginning or after \n).
-
-Argument: points to start of expression (the bracket)
-Returns: TRUE or FALSE
-*/
-
-static BOOL
-is_startline(const uschar *code)
-{
-do {
- const uschar *scode = first_significant_code(code + 3, NULL, 0, FALSE);
- register int op = *scode;
- if (op >= OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND)
- { if (!is_startline(scode)) return FALSE; }
- else if (op == OP_TYPESTAR || op == OP_TYPEMINSTAR)
- { if (scode[1] != OP_ANY) return FALSE; }
- else if (op != OP_CIRC) return FALSE;
- code += (code[1] << 8) + code[2];
- }
-while (*code == OP_ALT);
-return TRUE;
-}
-
-
-
-/*************************************************
-* Check for fixed first char *
-*************************************************/
-
-/* Try to find out if there is a fixed first character. This is called for
-unanchored expressions, as it speeds up their processing quite considerably.
-Consider each alternative branch. If they all start with the same char, or with
-a bracket all of whose alternatives start with the same char (recurse ad lib),
-then we return that char, otherwise -1.
-
-Arguments:
- code points to start of expression (the bracket)
- options pointer to the options (used to check casing changes)
-
-Returns: -1 or the fixed first char
-*/
-
-static int
-find_firstchar(const uschar *code, int *options)
-{
-register int c = -1;
-do {
- int d;
- const uschar *scode = first_significant_code(code + 3, options,
- PCRE_CASELESS, TRUE);
- register int op = *scode;
-
- if (op >= OP_BRA) op = OP_BRA;
-
- switch(op)
- {
- default:
- return -1;
-
- case OP_BRA:
- case OP_ASSERT:
- case OP_ONCE:
- case OP_COND:
- if ((d = find_firstchar(scode, options)) < 0) return -1;
- if (c < 0) c = d; else if (c != d) return -1;
- break;
-
- case OP_EXACT: /* Fall through */
- scode++;
-
- case OP_CHARS: /* Fall through */
- scode++;
-
- case OP_PLUS:
- case OP_MINPLUS:
- if (c < 0) c = scode[1]; else if (c != scode[1]) return -1;
- break;
- }
-
- code += (code[1] << 8) + code[2];
- }
-while (*code == OP_ALT);
-return c;
-}
-
-
-
-
-
-/*************************************************
-* Compile a Regular Expression *
-*************************************************/
-
-/* This function takes a string and returns a pointer to a block of store
-holding a compiled version of the expression.
-
-Arguments:
- pattern the regular expression
- options various option bits
- errorptr pointer to pointer to error text
- erroroffset ptr offset in pattern where error was detected
- tables pointer to character tables or NULL
-
-Returns: pointer to compiled data block, or NULL on error,
- with errorptr and erroroffset set
-*/
-
-pcre *
-pcre_compile(const char *pattern, int options, const char **errorptr,
- int *erroroffset, const unsigned char *tables)
-{
-real_pcre *re;
-int length = 3; /* For initial BRA plus length */
-int runlength;
-int c, size, reqchar, countlits;
-int bracount = 0;
-int top_backref = 0;
-int branch_extra = 0;
-int branch_newextra;
-unsigned int brastackptr = 0;
-uschar *code;
-const uschar *ptr;
-compile_data compile_block;
-int brastack[BRASTACK_SIZE];
-uschar bralenstack[BRASTACK_SIZE];
-
-#ifdef DEBUG
-uschar *code_base, *code_end;
-#endif
-
-/* We can't pass back an error message if errorptr is NULL; I guess the best we
-can do is just return NULL. */
-
-if (errorptr == NULL) return NULL;
-*errorptr = NULL;
-
-/* However, we can give a message for this error */
-
-if (erroroffset == NULL)
- {
- *errorptr = ERR16;
- return NULL;
- }
-*erroroffset = 0;
-
-if ((options & ~PUBLIC_OPTIONS) != 0)
- {
- *errorptr = ERR17;
- return NULL;
- }
-
-/* Set up pointers to the individual character tables */
-
-if (tables == NULL) tables = pcre_default_tables;
-compile_block.lcc = tables + lcc_offset;
-compile_block.fcc = tables + fcc_offset;
-compile_block.cbits = tables + cbits_offset;
-compile_block.ctypes = tables + ctypes_offset;
-
-/* Reflect pattern for debugging output */
-
-DPRINTF(("------------------------------------------------------------------\n"));
-DPRINTF(("%s\n", pattern));
-
-/* The first thing to do is to make a pass over the pattern to compute the
-amount of store required to hold the compiled code. This does not have to be
-perfect as long as errors are overestimates. At the same time we can detect any
-internal flag settings. Make an attempt to correct for any counted white space
-if an "extended" flag setting appears late in the pattern. We can't be so
-clever for #-comments. */
-
-ptr = (const uschar *)(pattern - 1);
-while ((c = *(++ptr)) != 0)
- {
- int min, max;
- int class_charcount;
-
- if ((options & PCRE_EXTENDED) != 0)
- {
- if ((compile_block.ctypes[c] & ctype_space) != 0) continue;
- if (c == '#')
- {
- while ((c = *(++ptr)) != 0 && c != '\n');
- continue;
- }
- }
-
- switch(c)
- {
- /* A backslashed item may be an escaped "normal" character or a
- character type. For a "normal" character, put the pointers and
- character back so that tests for whitespace etc. in the input
- are done correctly. */
-
- case '\\':
- {
- const uschar *save_ptr = ptr;
- c = check_escape(&ptr, errorptr, bracount, options, FALSE, &compile_block);
- if (*errorptr != NULL) goto PCRE_ERROR_RETURN;
- if (c >= 0)
- {
- ptr = save_ptr;
- c = '\\';
- goto NORMAL_CHAR;
- }
- }
- length++;
-
- /* A back reference needs an additional char, plus either one or 5
- bytes for a repeat. We also need to keep the value of the highest
- back reference. */
-
- if (c <= -ESC_REF)
- {
- int refnum = -c - ESC_REF;
- if (refnum > top_backref) top_backref = refnum;
- length++; /* For single back reference */
- if (ptr[1] == '{' && is_counted_repeat(ptr+2, &compile_block))
- {
- ptr = read_repeat_counts(ptr+2, &min, &max, errorptr, &compile_block);
- if (*errorptr != NULL) goto PCRE_ERROR_RETURN;
- if ((min == 0 && (max == 1 || max == -1)) ||
- (min == 1 && max == -1))
- length++;
- else length += 5;
- if (ptr[1] == '?') ptr++;
- }
- }
- continue;
-
- case '^':
- case '.':
- case '$':
- case '*': /* These repeats won't be after brackets; */
- case '+': /* those are handled separately */
- case '?':
- length++;
- continue;
-
- /* This covers the cases of repeats after a single char, metachar, class,
- or back reference. */
-
- case '{':
- if (!is_counted_repeat(ptr+1, &compile_block)) goto NORMAL_CHAR;
- ptr = read_repeat_counts(ptr+1, &min, &max, errorptr, &compile_block);
- if (*errorptr != NULL) goto PCRE_ERROR_RETURN;
- if ((min == 0 && (max == 1 || max == -1)) ||
- (min == 1 && max == -1))
- length++;
- else
- {
- length--; /* Uncount the original char or metachar */
- if (min == 1) length++; else if (min > 0) length += 4;
- if (max > 0) length += 4; else length += 2;
- }
- if (ptr[1] == '?') ptr++;
- continue;
-
- /* An alternation contains an offset to the next branch or ket. If any ims
- options changed in the previous branch(es), and/or if we are in a
- lookbehind assertion, extra space will be needed at the start of the
- branch. This is handled by branch_extra. */
-
- case '|':
- length += 3 + branch_extra;
- continue;
-
- /* A character class uses 33 characters. Don't worry about character types
- that aren't allowed in classes - they'll get picked up during the compile.
- A character class that contains only one character uses 2 or 3 bytes,
- depending on whether it is negated or not. Notice this where we can. */
-
- case '[':
- class_charcount = 0;
- if (*(++ptr) == '^') ptr++;
- do
- {
- if (*ptr == '\\')
- {
- int ch = check_escape(&ptr, errorptr, bracount, options, TRUE,
- &compile_block);
- if (*errorptr != NULL) goto PCRE_ERROR_RETURN;
- if (-ch == ESC_b) class_charcount++; else class_charcount = 10;
- }
- else class_charcount++;
- ptr++;
- }
- while (*ptr != 0 && *ptr != ']');
-
- /* Repeats for negated single chars are handled by the general code */
-
- if (class_charcount == 1) length += 3; else
- {
- length += 33;
-
- /* A repeat needs either 1 or 5 bytes. */
-
- if (*ptr != 0 && ptr[1] == '{' && is_counted_repeat(ptr+2, &compile_block))
- {
- ptr = read_repeat_counts(ptr+2, &min, &max, errorptr, &compile_block);
- if (*errorptr != NULL) goto PCRE_ERROR_RETURN;
- if ((min == 0 && (max == 1 || max == -1)) ||
- (min == 1 && max == -1))
- length++;
- else length += 5;
- if (ptr[1] == '?') ptr++;
- }
- }
- continue;
-
- /* Brackets may be genuine groups or special things */
-
- case '(':
- branch_newextra = 0;
-
- /* Handle special forms of bracket, which all start (? */
-
- if (ptr[1] == '?')
- {
- int set, unset;
- int *optset;
-
- switch (c = ptr[2])
- {
- /* Skip over comments entirely */
- case '#':
- ptr += 3;
- while (*ptr != 0 && *ptr != ')') ptr++;
- if (*ptr == 0)
- {
- *errorptr = ERR18;
- goto PCRE_ERROR_RETURN;
- }
- continue;
-
- /* Non-referencing groups and lookaheads just move the pointer on, and
- then behave like a non-special bracket, except that they don't increment
- the count of extracting brackets. Ditto for the "once only" bracket,
- which is in Perl from version 5.005. */
-
- case ':':
- case '=':
- case '!':
- case '>':
- ptr += 2;
- break;
-
- /* Lookbehinds are in Perl from version 5.005 */
-
- case '<':
- if (ptr[3] == '=' || ptr[3] == '!')
- {
- ptr += 3;
- branch_newextra = 3;
- length += 3; /* For the first branch */
- break;
- }
- *errorptr = ERR24;
- goto PCRE_ERROR_RETURN;
-
- /* Conditionals are in Perl from version 5.005. The bracket must either
- be followed by a number (for bracket reference) or by an assertion
- group. */
-
- case '(':
- if ((compile_block.ctypes[ptr[3]] & ctype_digit) != 0)
- {
- ptr += 4;
- length += 2;
- while ((compile_block.ctypes[*ptr] & ctype_digit) != 0) ptr++;
- if (*ptr != ')')
- {
- *errorptr = ERR26;
- goto PCRE_ERROR_RETURN;
- }
- }
- else /* An assertion must follow */
- {
- ptr++; /* Can treat like ':' as far as spacing is concerned */
-
- if (ptr[2] != '?' || strchr("=!<", ptr[3]) == NULL)
- {
- ptr += 2; /* To get right offset in message */
- *errorptr = ERR28;
- goto PCRE_ERROR_RETURN;
- }
- }
- break;
-
- /* Else loop checking valid options until ) is met. Anything else is an
- error. If we are without any brackets, i.e. at top level, the settings
- act as if specified in the options, so massage the options immediately.
- This is for backward compatibility with Perl 5.004. */
-
- default:
- set = unset = 0;
- optset = &set;
- ptr += 2;
-
- for (;; ptr++)
- {
- c = *ptr;
- switch (c)
- {
- case 'i':
- *optset |= PCRE_CASELESS;
- continue;
-
- case 'm':
- *optset |= PCRE_MULTILINE;
- continue;
-
- case 's':
- *optset |= PCRE_DOTALL;
- continue;
-
- case 'x':
- *optset |= PCRE_EXTENDED;
- continue;
-
- case 'X':
- *optset |= PCRE_EXTRA;
- continue;
-
- case 'U':
- *optset |= PCRE_UNGREEDY;
- continue;
-
- case '-':
- optset = &unset;
- continue;
-
- /* A termination by ')' indicates an options-setting-only item;
- this is global at top level; otherwise nothing is done here and
- it is handled during the compiling process on a per-bracket-group
- basis. */
-
- case ')':
- if (brastackptr == 0)
- {
- options = (options | set) & (~unset);
- set = unset = 0; /* To save length */
- }
- /* Fall through */
-
- /* A termination by ':' indicates the start of a nested group with
- the given options set. This is again handled at compile time, but
- we must allow for compiled space if any of the ims options are
- set. We also have to allow for resetting space at the end of
- the group, which is why 4 is added to the length and not just 2.
- If there are several changes of options within the same group, this
- will lead to an over-estimate on the length, but this shouldn't
- matter very much. We also have to allow for resetting options at
- the start of any alternations, which we do by setting
- branch_newextra to 2. Finally, we record whether the case-dependent
- flag ever changes within the regex. This is used by the "required
- character" code. */
-
- case ':':
- if (((set|unset) & PCRE_IMS) != 0)
- {
- length += 4;
- branch_newextra = 2;
- if (((set|unset) & PCRE_CASELESS) != 0) options |= PCRE_ICHANGED;
- }
- goto END_OPTIONS;
-
- /* Unrecognized option character */
-
- default:
- *errorptr = ERR12;
- goto PCRE_ERROR_RETURN;
- }
- }
-
- /* If we hit a closing bracket, that's it - this is a freestanding
- option-setting. We need to ensure that branch_extra is updated if
- necessary. The only values branch_newextra can have here are 0 or 2.
- If the value is 2, then branch_extra must either be 2 or 5, depending
- on whether this is a lookbehind group or not. */
-
- END_OPTIONS:
- if (c == ')')
- {
- if (branch_newextra == 2 && (branch_extra == 0 || branch_extra == 3))
- branch_extra += branch_newextra;
- continue;
- }
-
- /* If options were terminated by ':' control comes here. Fall through
- to handle the group below. */
- }
- }
-
- /* Extracting brackets must be counted so we can process escapes in a
- Perlish way. */
-
- else bracount++;
-
- /* Non-special forms of bracket. Save length for computing whole length
- at end if there's a repeat that requires duplication of the group. Also
- save the current value of branch_extra, and start the new group with
- the new value. If non-zero, this will either be 2 for a (?imsx: group, or 3
- for a lookbehind assertion. */
-
- if (brastackptr >= sizeof(brastack)/sizeof(int))
- {
- *errorptr = ERR19;
- goto PCRE_ERROR_RETURN;
- }
-
- bralenstack[brastackptr] = branch_extra;
- branch_extra = branch_newextra;
-
- brastack[brastackptr++] = length;
- length += 3;
- continue;
-
- /* Handle ket. Look for subsequent max/min; for certain sets of values we
- have to replicate this bracket up to that many times. If brastackptr is
- 0 this is an unmatched bracket which will generate an error, but take care
- not to try to access brastack[-1] when computing the length and restoring
- the branch_extra value. */
-
- case ')':
- length += 3;
- {
- int minval = 1;
- int maxval = 1;
- int duplength;
-
- if (brastackptr > 0)
- {
- duplength = length - brastack[--brastackptr];
- branch_extra = bralenstack[brastackptr];
- }
- else duplength = 0;
-
- /* Leave ptr at the final char; for read_repeat_counts this happens
- automatically; for the others we need an increment. */
-
- if ((c = ptr[1]) == '{' && is_counted_repeat(ptr+2, &compile_block))
- {
- ptr = read_repeat_counts(ptr+2, &minval, &maxval, errorptr,
- &compile_block);
- if (*errorptr != NULL) goto PCRE_ERROR_RETURN;
- }
- else if (c == '*') { minval = 0; maxval = -1; ptr++; }
- else if (c == '+') { maxval = -1; ptr++; }
- else if (c == '?') { minval = 0; ptr++; }
-
- /* If the minimum is zero, we have to allow for an OP_BRAZERO before the
- group, and if the maximum is greater than zero, we have to replicate
- maxval-1 times; each replication acquires an OP_BRAZERO plus a nesting
- bracket set - hence the 7. */
-
- if (minval == 0)
- {
- length++;
- if (maxval > 0) length += (maxval - 1) * (duplength + 7);
- }
-
- /* When the minimum is greater than zero, 1 we have to replicate up to
- minval-1 times, with no additions required in the copies. Then, if
- there is a limited maximum we have to replicate up to maxval-1 times
- allowing for a BRAZERO item before each optional copy and nesting
- brackets for all but one of the optional copies. */
-
- else
- {
- length += (minval - 1) * duplength;
- if (maxval > minval) /* Need this test as maxval=-1 means no limit */
- length += (maxval - minval) * (duplength + 7) - 6;
- }
- }
- continue;
-
- /* Non-special character. For a run of such characters the length required
- is the number of characters + 2, except that the maximum run length is 255.
- We won't get a skipped space or a non-data escape or the start of a #
- comment as the first character, so the length can't be zero. */
-
- NORMAL_CHAR:
- default:
- length += 2;
- runlength = 0;
- do
- {
- if ((options & PCRE_EXTENDED) != 0)
- {
- if ((compile_block.ctypes[c] & ctype_space) != 0) continue;
- if (c == '#')
- {
- while ((c = *(++ptr)) != 0 && c != '\n');
- continue;
- }
- }
-
- /* Backslash may introduce a data char or a metacharacter; stop the
- string before the latter. */
-
- if (c == '\\')
- {
- const uschar *saveptr = ptr;
- c = check_escape(&ptr, errorptr, bracount, options, FALSE,
- &compile_block);
- if (*errorptr != NULL) goto PCRE_ERROR_RETURN;
- if (c < 0) { ptr = saveptr; break; }
- }
-
- /* Ordinary character or single-char escape */
-
- runlength++;
- }
-
- /* This "while" is the end of the "do" above. */
-
- while (runlength < 255 &&
- (compile_block.ctypes[c = *(++ptr)] & ctype_meta) == 0);
-
- ptr--;
- length += runlength;
- continue;
- }
- }
-
-length += 4; /* For final KET and END */
-
-if (length > 65539)
- {
- *errorptr = ERR20;
- return NULL;
- }
-
-/* Compute the size of data block needed and get it, either from malloc or
-externally provided function. We specify "code[0]" in the offsetof() expression
-rather than just "code", because it has been reported that one broken compiler
-fails on "code" because it is also an independent variable. It should make no
-difference to the value of the offsetof(). */
-
-size = length + offsetof(real_pcre, code[0]);
-re = (real_pcre *)(pcre_malloc)(size);
-
-if (re == NULL)
- {
- *errorptr = ERR21;
- return NULL;
- }
-
-/* Put in the magic number and the options. */
-
-re->magic_number = MAGIC_NUMBER;
-re->options = options;
-re->tables = tables;
-
-/* Set up a starting, non-extracting bracket, then compile the expression. On
-error, *errorptr will be set non-NULL, so we don't need to look at the result
-of the function here. */
-
-ptr = (const uschar *)pattern;
-code = re->code;
-*code = OP_BRA;
-bracount = 0;
-(void)compile_regex(options, -1, &bracount, &code, &ptr, errorptr, FALSE, -1,
- &reqchar, &countlits, &compile_block);
-re->top_bracket = bracount;
-re->top_backref = top_backref;
-
-/* If not reached end of pattern on success, there's an excess bracket. */
-
-if (*errorptr == NULL && *ptr != 0) *errorptr = ERR22;
-
-/* Fill in the terminating state and check for disastrous overflow, but
-if debugging, leave the test till after things are printed out. */
-
-*code++ = OP_END;
-
-#ifndef DEBUG
-if (code - re->code > length) *errorptr = ERR23;
-#endif
-
-/* Give an error if there's back reference to a non-existent capturing
-subpattern. */
-
-if (top_backref > re->top_bracket) *errorptr = ERR15;
-
-/* Failed to compile */
-
-if (*errorptr != NULL)
- {
- (pcre_free)(re);
- PCRE_ERROR_RETURN:
- *erroroffset = ptr - (const uschar *)pattern;
- return NULL;
- }
-
-/* If the anchored option was not passed, set flag if we can determine that the
-pattern is anchored by virtue of ^ characters or \A or anything else (such as
-starting with .* when DOTALL is set).
-
-Otherwise, see if we can determine what the first character has to be, because
-that speeds up unanchored matches no end. If not, see if we can set the
-PCRE_STARTLINE flag. This is helpful for multiline matches when all branches
-start with ^. and also when all branches start with .* for non-DOTALL matches.
-*/
-
-if ((options & PCRE_ANCHORED) == 0)
- {
- int temp_options = options;
- if (is_anchored(re->code, &temp_options))
- re->options |= PCRE_ANCHORED;
- else
- {
- int ch = find_firstchar(re->code, &temp_options);
- if (ch >= 0)
- {
- re->first_char = ch;
- re->options |= PCRE_FIRSTSET;
- }
- else if (is_startline(re->code))
- re->options |= PCRE_STARTLINE;
- }
- }
-
-/* Save the last required character if there are at least two literal
-characters on all paths, or if there is no first character setting. */
-
-if (reqchar >= 0 && (countlits > 1 || (re->options & PCRE_FIRSTSET) == 0))
- {
- re->req_char = reqchar;
- re->options |= PCRE_REQCHSET;
- }
-
-/* Print out the compiled data for debugging */
-
-#ifdef DEBUG
-
-printf("Length = %d top_bracket = %d top_backref = %d\n",
- length, re->top_bracket, re->top_backref);
-
-if (re->options != 0)
- {
- printf("%s%s%s%s%s%s%s%s%s\n",
- ((re->options & PCRE_ANCHORED) != 0)? "anchored " : "",
- ((re->options & PCRE_CASELESS) != 0)? "caseless " : "",
- ((re->options & PCRE_ICHANGED) != 0)? "case state changed " : "",
- ((re->options & PCRE_EXTENDED) != 0)? "extended " : "",
- ((re->options & PCRE_MULTILINE) != 0)? "multiline " : "",
- ((re->options & PCRE_DOTALL) != 0)? "dotall " : "",
- ((re->options & PCRE_DOLLAR_ENDONLY) != 0)? "endonly " : "",
- ((re->options & PCRE_EXTRA) != 0)? "extra " : "",
- ((re->options & PCRE_UNGREEDY) != 0)? "ungreedy " : "");
- }
-
-if ((re->options & PCRE_FIRSTSET) != 0)
- {
- if (isprint(re->first_char)) printf("First char = %c\n", re->first_char);
- else printf("First char = \\x%02x\n", re->first_char);
- }
-
-if ((re->options & PCRE_REQCHSET) != 0)
- {
- if (isprint(re->req_char)) printf("Req char = %c\n", re->req_char);
- else printf("Req char = \\x%02x\n", re->req_char);
- }
-
-code_end = code;
-code_base = code = re->code;
-
-while (code < code_end)
- {
- int charlength;
-
- printf("%3d ", code - code_base);
-
- if (*code >= OP_BRA)
- {
- printf("%3d Bra %d", (code[1] << 8) + code[2], *code - OP_BRA);
- code += 2;
- }
-
- else switch(*code)
- {
- case OP_OPT:
- printf(" %.2x %s", code[1], OP_names[*code]);
- code++;
- break;
-
- case OP_COND:
- printf("%3d Cond", (code[1] << 8) + code[2]);
- code += 2;
- break;
-
- case OP_CREF:
- printf(" %.2d %s", code[1], OP_names[*code]);
- code++;
- break;
-
- case OP_CHARS:
- charlength = *(++code);
- printf("%3d ", charlength);
- while (charlength-- > 0)
- if (isprint(c = *(++code))) printf("%c", c); else printf("\\x%02x", c);
- break;
-
- case OP_KETRMAX:
- case OP_KETRMIN:
- case OP_ALT:
- case OP_KET:
- case OP_ASSERT:
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- case OP_ONCE:
- printf("%3d %s", (code[1] << 8) + code[2], OP_names[*code]);
- code += 2;
- break;
-
- case OP_REVERSE:
- printf("%3d %s", (code[1] << 8) + code[2], OP_names[*code]);
- code += 2;
- break;
-
- case OP_STAR:
- case OP_MINSTAR:
- case OP_PLUS:
- case OP_MINPLUS:
- case OP_QUERY:
- case OP_MINQUERY:
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- if (*code >= OP_TYPESTAR)
- printf(" %s", OP_names[code[1]]);
- else if (isprint(c = code[1])) printf(" %c", c);
- else printf(" \\x%02x", c);
- printf("%s", OP_names[*code++]);
- break;
-
- case OP_EXACT:
- case OP_UPTO:
- case OP_MINUPTO:
- if (isprint(c = code[3])) printf(" %c{", c);
- else printf(" \\x%02x{", c);
- if (*code != OP_EXACT) printf("0,");
- printf("%d}", (code[1] << 8) + code[2]);
- if (*code == OP_MINUPTO) printf("?");
- code += 3;
- break;
-
- case OP_TYPEEXACT:
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- printf(" %s{", OP_names[code[3]]);
- if (*code != OP_TYPEEXACT) printf(",");
- printf("%d}", (code[1] << 8) + code[2]);
- if (*code == OP_TYPEMINUPTO) printf("?");
- code += 3;
- break;
-
- case OP_NOT:
- if (isprint(c = *(++code))) printf(" [^%c]", c);
- else printf(" [^\\x%02x]", c);
- break;
-
- case OP_NOTSTAR:
- case OP_NOTMINSTAR:
- case OP_NOTPLUS:
- case OP_NOTMINPLUS:
- case OP_NOTQUERY:
- case OP_NOTMINQUERY:
- if (isprint(c = code[1])) printf(" [^%c]", c);
- else printf(" [^\\x%02x]", c);
- printf("%s", OP_names[*code++]);
- break;
-
- case OP_NOTEXACT:
- case OP_NOTUPTO:
- case OP_NOTMINUPTO:
- if (isprint(c = code[3])) printf(" [^%c]{", c);
- else printf(" [^\\x%02x]{", c);
- if (*code != OP_NOTEXACT) printf(",");
- printf("%d}", (code[1] << 8) + code[2]);
- if (*code == OP_NOTMINUPTO) printf("?");
- code += 3;
- break;
-
- case OP_REF:
- printf(" \\%d", *(++code));
- code ++;
- goto CLASS_REF_REPEAT;
-
- case OP_CLASS:
- {
- int i, min, max;
- code++;
- printf(" [");
-
- for (i = 0; i < 256; i++)
- {
- if ((code[i/8] & (1 << (i&7))) != 0)
- {
- int j;
- for (j = i+1; j < 256; j++)
- if ((code[j/8] & (1 << (j&7))) == 0) break;
- if (i == '-' || i == ']') printf("\\");
- if (isprint(i)) printf("%c", i); else printf("\\x%02x", i);
- if (--j > i)
- {
- printf("-");
- if (j == '-' || j == ']') printf("\\");
- if (isprint(j)) printf("%c", j); else printf("\\x%02x", j);
- }
- i = j;
- }
- }
- printf("]");
- code += 32;
-
- CLASS_REF_REPEAT:
-
- switch(*code)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- printf("%s", OP_names[*code]);
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- min = (code[1] << 8) + code[2];
- max = (code[3] << 8) + code[4];
- if (max == 0) printf("{%d,}", min);
- else printf("{%d,%d}", min, max);
- if (*code == OP_CRMINRANGE) printf("?");
- code += 4;
- break;
-
- default:
- code--;
- }
- }
- break;
-
- /* Anything else is just a one-node item */
-
- default:
- printf(" %s", OP_names[*code]);
- break;
- }
-
- code++;
- printf("\n");
- }
-printf("------------------------------------------------------------------\n");
-
-/* This check is done here in the debugging case so that the code that
-was compiled can be seen. */
-
-if (code - re->code > length)
- {
- *errorptr = ERR23;
- (pcre_free)(re);
- *erroroffset = ptr - (uschar *)pattern;
- return NULL;
- }
-#endif
-
-return (pcre *)re;
-}
-
-
-
-/*************************************************
-* Match a back-reference *
-*************************************************/
-
-/* If a back reference hasn't been set, the length that is passed is greater
-than the number of characters left in the string, so the match fails.
-
-Arguments:
- offset index into the offset vector
- eptr points into the subject
- length length to be matched
- md points to match data block
- ims the ims flags
-
-Returns: TRUE if matched
-*/
-
-static BOOL
-match_ref(int offset, register const uschar *eptr, int length, match_data *md,
- unsigned long int ims)
-{
-const uschar *p = md->start_subject + md->offset_vector[offset];
-
-#ifdef DEBUG
-if (eptr >= md->end_subject)
- printf("matching subject <null>");
-else
- {
- printf("matching subject ");
- pchars(eptr, length, TRUE, md);
- }
-printf(" against backref ");
-pchars(p, length, FALSE, md);
-printf("\n");
-#endif
-
-/* Always fail if not enough characters left */
-
-if (length > md->end_subject - eptr) return FALSE;
-
-/* Separate the caselesss case for speed */
-
-if ((ims & PCRE_CASELESS) != 0)
- {
- while (length-- > 0)
- if (md->lcc[*p++] != md->lcc[*eptr++]) return FALSE;
- }
-else
- { while (length-- > 0) if (*p++ != *eptr++) return FALSE; }
-
-return TRUE;
-}
-
-
-
-/*************************************************
-* Match from current position *
-*************************************************/
-
-/* On entry ecode points to the first opcode, and eptr to the first character
-in the subject string, while eptrb holds the value of eptr at the start of the
-last bracketed group - used for breaking infinite loops matching zero-length
-strings.
-
-Arguments:
- eptr pointer in subject
- ecode position in code
- offset_top current top pointer
- md pointer to "static" info for the match
- ims current /i, /m, and /s options
- condassert TRUE if called to check a condition assertion
- eptrb eptr at start of last bracket
-
-Returns: TRUE if matched
-*/
-
-static BOOL
-match(register const uschar *eptr, register const uschar *ecode,
- int offset_top, match_data *md, unsigned long int ims, BOOL condassert,
- const uschar *eptrb)
-{
-unsigned long int original_ims = ims; /* Save for resetting on ')' */
-
-for (;;)
- {
- int op = (int)*ecode;
- int min, max, ctype;
- register int i;
- register int c;
- BOOL minimize = FALSE;
-
- /* Opening capturing bracket. If there is space in the offset vector, save
- the current subject position in the working slot at the top of the vector. We
- mustn't change the current values of the data slot, because they may be set
- from a previous iteration of this group, and be referred to by a reference
- inside the group.
-
- If the bracket fails to match, we need to restore this value and also the
- values of the final offsets, in case they were set by a previous iteration of
- the same bracket.
-
- If there isn't enough space in the offset vector, treat this as if it were a
- non-capturing bracket. Don't worry about setting the flag for the error case
- here; that is handled in the code for KET. */
-
- if (op > OP_BRA)
- {
- int number = op - OP_BRA;
- int offset = number << 1;
-
-#ifdef DEBUG
- printf("start bracket %d subject=", number);
- pchars(eptr, 16, TRUE, md);
- printf("\n");
-#endif
-
- if (offset < md->offset_max)
- {
- int save_offset1 = md->offset_vector[offset];
- int save_offset2 = md->offset_vector[offset+1];
- int save_offset3 = md->offset_vector[md->offset_end - number];
-
- DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
- md->offset_vector[md->offset_end - number] = eptr - md->start_subject;
-
- do
- {
- if (match(eptr, ecode+3, offset_top, md, ims, FALSE, eptr)) return TRUE;
- ecode += (ecode[1] << 8) + ecode[2];
- }
- while (*ecode == OP_ALT);
-
- DPRINTF(("bracket %d failed\n", number));
-
- md->offset_vector[offset] = save_offset1;
- md->offset_vector[offset+1] = save_offset2;
- md->offset_vector[md->offset_end - number] = save_offset3;
- return FALSE;
- }
-
- /* Insufficient room for saving captured contents */
-
- else op = OP_BRA;
- }
-
- /* Other types of node can be handled by a switch */
-
- switch(op)
- {
- case OP_BRA: /* Non-capturing bracket: optimized */
- DPRINTF(("start bracket 0\n"));
- do
- {
- if (match(eptr, ecode+3, offset_top, md, ims, FALSE, eptr)) return TRUE;
- ecode += (ecode[1] << 8) + ecode[2];
- }
- while (*ecode == OP_ALT);
- DPRINTF(("bracket 0 failed\n"));
- return FALSE;
-
- /* Conditional group: compilation checked that there are no more than
- two branches. If the condition is false, skipping the first branch takes us
- past the end if there is only one branch, but that's OK because that is
- exactly what going to the ket would do. */
-
- case OP_COND:
- if (ecode[3] == OP_CREF) /* Condition is extraction test */
- {
- int offset = ecode[4] << 1; /* Doubled reference number */
- return match(eptr,
- ecode + ((offset < offset_top && md->offset_vector[offset] >= 0)?
- 5 : 3 + (ecode[1] << 8) + ecode[2]),
- offset_top, md, ims, FALSE, eptr);
- }
-
- /* The condition is an assertion. Call match() to evaluate it - setting
- the final argument TRUE causes it to stop at the end of an assertion. */
-
- else
- {
- if (match(eptr, ecode+3, offset_top, md, ims, TRUE, NULL))
- {
- ecode += 3 + (ecode[4] << 8) + ecode[5];
- while (*ecode == OP_ALT) ecode += (ecode[1] << 8) + ecode[2];
- }
- else ecode += (ecode[1] << 8) + ecode[2];
- return match(eptr, ecode+3, offset_top, md, ims, FALSE, eptr);
- }
- /* Control never reaches here */
-
- /* Skip over conditional reference data if encountered (should not be) */
-
- case OP_CREF:
- ecode += 2;
- break;
-
- /* End of the pattern. If PCRE_NOTEMPTY is set, fail if we have matched
- an empty string - recursion will then try other alternatives, if any. */
-
- case OP_END:
- if (md->notempty && eptr == md->start_match) return FALSE;
- md->end_match_ptr = eptr; /* Record where we ended */
- md->end_offset_top = offset_top; /* and how many extracts were taken */
- return TRUE;
-
- /* Change option settings */
-
- case OP_OPT:
- ims = ecode[1];
- ecode += 2;
- DPRINTF(("ims set to %02lx\n", ims));
- break;
-
- /* Assertion brackets. Check the alternative branches in turn - the
- matching won't pass the KET for an assertion. If any one branch matches,
- the assertion is true. Lookbehind assertions have an OP_REVERSE item at the
- start of each branch to move the current point backwards, so the code at
- this level is identical to the lookahead case. */
-
- case OP_ASSERT:
- case OP_ASSERTBACK:
- do
- {
- if (match(eptr, ecode+3, offset_top, md, ims, FALSE, NULL)) break;
- ecode += (ecode[1] << 8) + ecode[2];
- }
- while (*ecode == OP_ALT);
- if (*ecode == OP_KET) return FALSE;
-
- /* If checking an assertion for a condition, return TRUE. */
-
- if (condassert) return TRUE;
-
- /* Continue from after the assertion, updating the offsets high water
- mark, since extracts may have been taken during the assertion. */
-
- do ecode += (ecode[1] << 8) + ecode[2]; while (*ecode == OP_ALT);
- ecode += 3;
- offset_top = md->end_offset_top;
- continue;
-
- /* Negative assertion: all branches must fail to match */
-
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK_NOT:
- do
- {
- if (match(eptr, ecode+3, offset_top, md, ims, FALSE, NULL)) return FALSE;
- ecode += (ecode[1] << 8) + ecode[2];
- }
- while (*ecode == OP_ALT);
-
- if (condassert) return TRUE;
- ecode += 3;
- continue;
-
- /* Move the subject pointer back. This occurs only at the start of
- each branch of a lookbehind assertion. If we are too close to the start to
- move back, this match function fails. */
-
- case OP_REVERSE:
- eptr -= (ecode[1] << 8) + ecode[2];
- if (eptr < md->start_subject) return FALSE;
- ecode += 3;
- break;
-
-
- /* "Once" brackets are like assertion brackets except that after a match,
- the point in the subject string is not moved back. Thus there can never be
- a move back into the brackets. Check the alternative branches in turn - the
- matching won't pass the KET for this kind of subpattern. If any one branch
- matches, we carry on as at the end of a normal bracket, leaving the subject
- pointer. */
-
- case OP_ONCE:
- {
- const uschar *prev = ecode;
-
- do
- {
- if (match(eptr, ecode+3, offset_top, md, ims, FALSE, eptr)) break;
- ecode += (ecode[1] << 8) + ecode[2];
- }
- while (*ecode == OP_ALT);
-
- /* If hit the end of the group (which could be repeated), fail */
-
- if (*ecode != OP_ONCE && *ecode != OP_ALT) return FALSE;
-
- /* Continue as from after the assertion, updating the offsets high water
- mark, since extracts may have been taken. */
-
- do ecode += (ecode[1] << 8) + ecode[2]; while (*ecode == OP_ALT);
-
- offset_top = md->end_offset_top;
- eptr = md->end_match_ptr;
-
- /* For a non-repeating ket, just continue at this level. This also
- happens for a repeating ket if no characters were matched in the group.
- This is the forcible breaking of infinite loops as implemented in Perl
- 5.005. If there is an options reset, it will get obeyed in the normal
- course of events. */
-
- if (*ecode == OP_KET || eptr == eptrb)
- {
- ecode += 3;
- break;
- }
-
- /* The repeating kets try the rest of the pattern or restart from the
- preceding bracket, in the appropriate order. We need to reset any options
- that changed within the bracket before re-running it, so check the next
- opcode. */
-
- if (ecode[3] == OP_OPT)
- {
- ims = (ims & ~PCRE_IMS) | ecode[4];
- DPRINTF(("ims set to %02lx at group repeat\n", ims));
- }
-
- if (*ecode == OP_KETRMIN)
- {
- if (match(eptr, ecode+3, offset_top, md, ims, FALSE, eptr) ||
- match(eptr, prev, offset_top, md, ims, FALSE, eptr)) return TRUE;
- }
- else /* OP_KETRMAX */
- {
- if (match(eptr, prev, offset_top, md, ims, FALSE, eptr) ||
- match(eptr, ecode+3, offset_top, md, ims, FALSE, eptr)) return TRUE;
- }
- }
- return FALSE;
-
- /* An alternation is the end of a branch; scan along to find the end of the
- bracketed group and go to there. */
-
- case OP_ALT:
- do ecode += (ecode[1] << 8) + ecode[2]; while (*ecode == OP_ALT);
- break;
-
- /* BRAZERO and BRAMINZERO occur just before a bracket group, indicating
- that it may occur zero times. It may repeat infinitely, or not at all -
- i.e. it could be ()* or ()? in the pattern. Brackets with fixed upper
- repeat limits are compiled as a number of copies, with the optional ones
- preceded by BRAZERO or BRAMINZERO. */
-
- case OP_BRAZERO:
- {
- const uschar *next = ecode+1;
- if (match(eptr, next, offset_top, md, ims, FALSE, eptr)) return TRUE;
- do next += (next[1] << 8) + next[2]; while (*next == OP_ALT);
- ecode = next + 3;
- }
- break;
-
- case OP_BRAMINZERO:
- {
- const uschar *next = ecode+1;
- do next += (next[1] << 8) + next[2]; while (*next == OP_ALT);
- if (match(eptr, next+3, offset_top, md, ims, FALSE, eptr)) return TRUE;
- ecode++;
- }
- break;
-
- /* End of a group, repeated or non-repeating. If we are at the end of
- an assertion "group", stop matching and return TRUE, but record the
- current high water mark for use by positive assertions. Do this also
- for the "once" (not-backup up) groups. */
-
- case OP_KET:
- case OP_KETRMIN:
- case OP_KETRMAX:
- {
- const uschar *prev = ecode - (ecode[1] << 8) - ecode[2];
-
- if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT ||
- *prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT ||
- *prev == OP_ONCE)
- {
- md->end_match_ptr = eptr; /* For ONCE */
- md->end_offset_top = offset_top;
- return TRUE;
- }
-
- /* In all other cases except a conditional group we have to check the
- group number back at the start and if necessary complete handling an
- extraction by setting the offsets and bumping the high water mark. */
-
- if (*prev != OP_COND)
- {
- int number = *prev - OP_BRA;
- int offset = number << 1;
-
- DPRINTF(("end bracket %d\n", number));
-
- if (number > 0)
- {
- if (offset >= md->offset_max) md->offset_overflow = TRUE; else
- {
- md->offset_vector[offset] =
- md->offset_vector[md->offset_end - number];
- md->offset_vector[offset+1] = eptr - md->start_subject;
- if (offset_top <= offset) offset_top = offset + 2;
- }
- }
- }
-
- /* Reset the value of the ims flags, in case they got changed during
- the group. */
-
- ims = original_ims;
- DPRINTF(("ims reset to %02lx\n", ims));
-
- /* For a non-repeating ket, just continue at this level. This also
- happens for a repeating ket if no characters were matched in the group.
- This is the forcible breaking of infinite loops as implemented in Perl
- 5.005. If there is an options reset, it will get obeyed in the normal
- course of events. */
-
- if (*ecode == OP_KET || eptr == eptrb)
- {
- ecode += 3;
- break;
- }
-
- /* The repeating kets try the rest of the pattern or restart from the
- preceding bracket, in the appropriate order. */
-
- if (*ecode == OP_KETRMIN)
- {
- if (match(eptr, ecode+3, offset_top, md, ims, FALSE, eptr) ||
- match(eptr, prev, offset_top, md, ims, FALSE, eptr)) return TRUE;
- }
- else /* OP_KETRMAX */
- {
- if (match(eptr, prev, offset_top, md, ims, FALSE, eptr) ||
- match(eptr, ecode+3, offset_top, md, ims, FALSE, eptr)) return TRUE;
- }
- }
- return FALSE;
-
- /* Start of subject unless notbol, or after internal newline if multiline */
-
- case OP_CIRC:
- if (md->notbol && eptr == md->start_subject) return FALSE;
- if ((ims & PCRE_MULTILINE) != 0)
- {
- if (eptr != md->start_subject && eptr[-1] != '\n') return FALSE;
- ecode++;
- break;
- }
- /* ... else fall through */
-
- /* Start of subject assertion */
-
- case OP_SOD:
- if (eptr != md->start_subject) return FALSE;
- ecode++;
- break;
-
- /* Assert before internal newline if multiline, or before a terminating
- newline unless endonly is set, else end of subject unless noteol is set. */
-
- case OP_DOLL:
- if ((ims & PCRE_MULTILINE) != 0)
- {
- if (eptr < md->end_subject) { if (*eptr != '\n') return FALSE; }
- else { if (md->noteol) return FALSE; }
- ecode++;
- break;
- }
- else
- {
- if (md->noteol) return FALSE;
- if (!md->endonly)
- {
- if (eptr < md->end_subject - 1 ||
- (eptr == md->end_subject - 1 && *eptr != '\n')) return FALSE;
-
- ecode++;
- break;
- }
- }
- /* ... else fall through */
-
- /* End of subject assertion (\z) */
-
- case OP_EOD:
- if (eptr < md->end_subject) return FALSE;
- ecode++;
- break;
-
- /* End of subject or ending \n assertion (\Z) */
-
- case OP_EODN:
- if (eptr < md->end_subject - 1 ||
- (eptr == md->end_subject - 1 && *eptr != '\n')) return FALSE;
- ecode++;
- break;
-
- /* Word boundary assertions */
-
- case OP_NOT_WORD_BOUNDARY:
- case OP_WORD_BOUNDARY:
- {
- BOOL prev_is_word = (eptr != md->start_subject) &&
- ((md->ctypes[eptr[-1]] & ctype_word) != 0);
- BOOL cur_is_word = (eptr < md->end_subject) &&
- ((md->ctypes[*eptr] & ctype_word) != 0);
- if ((*ecode++ == OP_WORD_BOUNDARY)?
- cur_is_word == prev_is_word : cur_is_word != prev_is_word)
- return FALSE;
- }
- break;
-
- /* Match a single character type; inline for speed */
-
- case OP_ANY:
- if ((ims & PCRE_DOTALL) == 0 && eptr < md->end_subject && *eptr == '\n')
- return FALSE;
- if (eptr++ >= md->end_subject) return FALSE;
- ecode++;
- break;
-
- case OP_NOT_DIGIT:
- if (eptr >= md->end_subject ||
- (md->ctypes[*eptr++] & ctype_digit) != 0)
- return FALSE;
- ecode++;
- break;
-
- case OP_DIGIT:
- if (eptr >= md->end_subject ||
- (md->ctypes[*eptr++] & ctype_digit) == 0)
- return FALSE;
- ecode++;
- break;
-
- case OP_NOT_WHITESPACE:
- if (eptr >= md->end_subject ||
- (md->ctypes[*eptr++] & ctype_space) != 0)
- return FALSE;
- ecode++;
- break;
-
- case OP_WHITESPACE:
- if (eptr >= md->end_subject ||
- (md->ctypes[*eptr++] & ctype_space) == 0)
- return FALSE;
- ecode++;
- break;
-
- case OP_NOT_WORDCHAR:
- if (eptr >= md->end_subject ||
- (md->ctypes[*eptr++] & ctype_word) != 0)
- return FALSE;
- ecode++;
- break;
-
- case OP_WORDCHAR:
- if (eptr >= md->end_subject ||
- (md->ctypes[*eptr++] & ctype_word) == 0)
- return FALSE;
- ecode++;
- break;
-
- /* Match a back reference, possibly repeatedly. Look past the end of the
- item to see if there is repeat information following. The code is similar
- to that for character classes, but repeated for efficiency. Then obey
- similar code to character type repeats - written out again for speed.
- However, if the referenced string is the empty string, always treat
- it as matched, any number of times (otherwise there could be infinite
- loops). */
-
- case OP_REF:
- {
- int length;
- int offset = ecode[1] << 1; /* Doubled reference number */
- ecode += 2; /* Advance past the item */
-
- /* If the reference is unset, set the length to be longer than the amount
- of subject left; this ensures that every attempt at a match fails. We
- can't just fail here, because of the possibility of quantifiers with zero
- minima. */
-
- length = (offset >= offset_top || md->offset_vector[offset] < 0)?
- md->end_subject - eptr + 1 :
- md->offset_vector[offset+1] - md->offset_vector[offset];
-
- /* Set up for repetition, or handle the non-repeated case */
-
- switch (*ecode)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- c = *ecode++ - OP_CRSTAR;
- minimize = (c & 1) != 0;
- min = rep_min[c]; /* Pick up values from tables; */
- max = rep_max[c]; /* zero for max => infinity */
- if (max == 0) max = INT_MAX;
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- minimize = (*ecode == OP_CRMINRANGE);
- min = (ecode[1] << 8) + ecode[2];
- max = (ecode[3] << 8) + ecode[4];
- if (max == 0) max = INT_MAX;
- ecode += 5;
- break;
-
- default: /* No repeat follows */
- if (!match_ref(offset, eptr, length, md, ims)) return FALSE;
- eptr += length;
- continue; /* With the main loop */
- }
-
- /* If the length of the reference is zero, just continue with the
- main loop. */
-
- if (length == 0) continue;
-
- /* First, ensure the minimum number of matches are present. We get back
- the length of the reference string explicitly rather than passing the
- address of eptr, so that eptr can be a register variable. */
-
- for (i = 1; i <= min; i++)
- {
- if (!match_ref(offset, eptr, length, md, ims)) return FALSE;
- eptr += length;
- }
-
- /* If min = max, continue at the same level without recursion.
- They are not both allowed to be zero. */
-
- if (min == max) continue;
-
- /* If minimizing, keep trying and advancing the pointer */
-
- if (minimize)
- {
- for (i = min;; i++)
- {
- if (match(eptr, ecode, offset_top, md, ims, FALSE, eptrb))
- return TRUE;
- if (i >= max || !match_ref(offset, eptr, length, md, ims))
- return FALSE;
- eptr += length;
- }
- /* Control never gets here */
- }
-
- /* If maximizing, find the longest string and work backwards */
-
- else
- {
- const uschar *pp = eptr;
- for (i = min; i < max; i++)
- {
- if (!match_ref(offset, eptr, length, md, ims)) break;
- eptr += length;
- }
- while (eptr >= pp)
- {
- if (match(eptr, ecode, offset_top, md, ims, FALSE, eptrb))
- return TRUE;
- eptr -= length;
- }
- return FALSE;
- }
- }
- /* Control never gets here */
-
-
-
- /* Match a character class, possibly repeatedly. Look past the end of the
- item to see if there is repeat information following. Then obey similar
- code to character type repeats - written out again for speed. */
-
- case OP_CLASS:
- {
- const uschar *data = ecode + 1; /* Save for matching */
- ecode += 33; /* Advance past the item */
-
- switch (*ecode)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- c = *ecode++ - OP_CRSTAR;
- minimize = (c & 1) != 0;
- min = rep_min[c]; /* Pick up values from tables; */
- max = rep_max[c]; /* zero for max => infinity */
- if (max == 0) max = INT_MAX;
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- minimize = (*ecode == OP_CRMINRANGE);
- min = (ecode[1] << 8) + ecode[2];
- max = (ecode[3] << 8) + ecode[4];
- if (max == 0) max = INT_MAX;
- ecode += 5;
- break;
-
- default: /* No repeat follows */
- min = max = 1;
- break;
- }
-
- /* First, ensure the minimum number of matches are present. */
-
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject) return FALSE;
- c = *eptr++;
- if ((data[c/8] & (1 << (c&7))) != 0) continue;
- return FALSE;
- }
-
- /* If max == min we can continue with the main loop without the
- need to recurse. */
-
- if (min == max) continue;
-
- /* If minimizing, keep testing the rest of the expression and advancing
- the pointer while it matches the class. */
-
- if (minimize)
- {
- for (i = min;; i++)
- {
- if (match(eptr, ecode, offset_top, md, ims, FALSE, eptrb))
- return TRUE;
- if (i >= max || eptr >= md->end_subject) return FALSE;
- c = *eptr++;
- if ((data[c/8] & (1 << (c&7))) != 0) continue;
- return FALSE;
- }
- /* Control never gets here */
- }
-
- /* If maximizing, find the longest possible run, then work backwards. */
-
- else
- {
- const uschar *pp = eptr;
- for (i = min; i < max; eptr++, i++)
- {
- if (eptr >= md->end_subject) break;
- c = *eptr;
- if ((data[c/8] & (1 << (c&7))) != 0) continue;
- break;
- }
-
- while (eptr >= pp)
- if (match(eptr--, ecode, offset_top, md, ims, FALSE, eptrb))
- return TRUE;
- return FALSE;
- }
- }
- /* Control never gets here */
-
- /* Match a run of characters */
-
- case OP_CHARS:
- {
- register int length = ecode[1];
- ecode += 2;
-
-#ifdef DEBUG /* Sigh. Some compilers never learn. */
- if (eptr >= md->end_subject)
- printf("matching subject <null> against pattern ");
- else
- {
- printf("matching subject ");
- pchars(eptr, length, TRUE, md);
- printf(" against pattern ");
- }
- pchars(ecode, length, FALSE, md);
- printf("\n");
-#endif
-
- if (length > md->end_subject - eptr) return FALSE;
- if ((ims & PCRE_CASELESS) != 0)
- {
- while (length-- > 0)
- if (md->lcc[*ecode++] != md->lcc[*eptr++])
- return FALSE;
- }
- else
- {
- while (length-- > 0) if (*ecode++ != *eptr++) return FALSE;
- }
- }
- break;
-
- /* Match a single character repeatedly; different opcodes share code. */
-
- case OP_EXACT:
- min = max = (ecode[1] << 8) + ecode[2];
- ecode += 3;
- goto REPEATCHAR;
-
- case OP_UPTO:
- case OP_MINUPTO:
- min = 0;
- max = (ecode[1] << 8) + ecode[2];
- minimize = *ecode == OP_MINUPTO;
- ecode += 3;
- goto REPEATCHAR;
-
- case OP_STAR:
- case OP_MINSTAR:
- case OP_PLUS:
- case OP_MINPLUS:
- case OP_QUERY:
- case OP_MINQUERY:
- c = *ecode++ - OP_STAR;
- minimize = (c & 1) != 0;
- min = rep_min[c]; /* Pick up values from tables; */
- max = rep_max[c]; /* zero for max => infinity */
- if (max == 0) max = INT_MAX;
-
- /* Common code for all repeated single-character matches. We can give
- up quickly if there are fewer than the minimum number of characters left in
- the subject. */
-
- REPEATCHAR:
- if (min > md->end_subject - eptr) return FALSE;
- c = *ecode++;
-
- /* The code is duplicated for the caseless and caseful cases, for speed,
- since matching characters is likely to be quite common. First, ensure the
- minimum number of matches are present. If min = max, continue at the same
- level without recursing. Otherwise, if minimizing, keep trying the rest of
- the expression and advancing one matching character if failing, up to the
- maximum. Alternatively, if maximizing, find the maximum number of
- characters and work backwards. */
-
- DPRINTF(("matching %c{%d,%d} against subject %.*s\n", c, min, max,
- max, eptr));
-
- if ((ims & PCRE_CASELESS) != 0)
- {
- c = md->lcc[c];
- for (i = 1; i <= min; i++)
- if (c != md->lcc[*eptr++]) return FALSE;
- if (min == max) continue;
- if (minimize)
- {
- for (i = min;; i++)
- {
- if (match(eptr, ecode, offset_top, md, ims, FALSE, eptrb))
- return TRUE;
- if (i >= max || eptr >= md->end_subject ||
- c != md->lcc[*eptr++])
- return FALSE;
- }
- /* Control never gets here */
- }
- else
- {
- const uschar *pp = eptr;
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject || c != md->lcc[*eptr]) break;
- eptr++;
- }
- while (eptr >= pp)
- if (match(eptr--, ecode, offset_top, md, ims, FALSE, eptrb))
- return TRUE;
- return FALSE;
- }
- /* Control never gets here */
- }
-
- /* Caseful comparisons */
-
- else
- {
- for (i = 1; i <= min; i++) if (c != *eptr++) return FALSE;
- if (min == max) continue;
- if (minimize)
- {
- for (i = min;; i++)
- {
- if (match(eptr, ecode, offset_top, md, ims, FALSE, eptrb))
- return TRUE;
- if (i >= max || eptr >= md->end_subject || c != *eptr++) return FALSE;
- }
- /* Control never gets here */
- }
- else
- {
- const uschar *pp = eptr;
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject || c != *eptr) break;
- eptr++;
- }
- while (eptr >= pp)
- if (match(eptr--, ecode, offset_top, md, ims, FALSE, eptrb))
- return TRUE;
- return FALSE;
- }
- }
- /* Control never gets here */
-
- /* Match a negated single character */
-
- case OP_NOT:
- if (eptr >= md->end_subject) return FALSE;
- ecode++;
- if ((ims & PCRE_CASELESS) != 0)
- {
- if (md->lcc[*ecode++] == md->lcc[*eptr++]) return FALSE;
- }
- else
- {
- if (*ecode++ == *eptr++) return FALSE;
- }
- break;
-
- /* Match a negated single character repeatedly. This is almost a repeat of
- the code for a repeated single character, but I haven't found a nice way of
- commoning these up that doesn't require a test of the positive/negative
- option for each character match. Maybe that wouldn't add very much to the
- time taken, but character matching *is* what this is all about... */
-
- case OP_NOTEXACT:
- min = max = (ecode[1] << 8) + ecode[2];
- ecode += 3;
- goto REPEATNOTCHAR;
-
- case OP_NOTUPTO:
- case OP_NOTMINUPTO:
- min = 0;
- max = (ecode[1] << 8) + ecode[2];
- minimize = *ecode == OP_NOTMINUPTO;
- ecode += 3;
- goto REPEATNOTCHAR;
-
- case OP_NOTSTAR:
- case OP_NOTMINSTAR:
- case OP_NOTPLUS:
- case OP_NOTMINPLUS:
- case OP_NOTQUERY:
- case OP_NOTMINQUERY:
- c = *ecode++ - OP_NOTSTAR;
- minimize = (c & 1) != 0;
- min = rep_min[c]; /* Pick up values from tables; */
- max = rep_max[c]; /* zero for max => infinity */
- if (max == 0) max = INT_MAX;
-
- /* Common code for all repeated single-character matches. We can give
- up quickly if there are fewer than the minimum number of characters left in
- the subject. */
-
- REPEATNOTCHAR:
- if (min > md->end_subject - eptr) return FALSE;
- c = *ecode++;
-
- /* The code is duplicated for the caseless and caseful cases, for speed,
- since matching characters is likely to be quite common. First, ensure the
- minimum number of matches are present. If min = max, continue at the same
- level without recursing. Otherwise, if minimizing, keep trying the rest of
- the expression and advancing one matching character if failing, up to the
- maximum. Alternatively, if maximizing, find the maximum number of
- characters and work backwards. */
-
- DPRINTF(("negative matching %c{%d,%d} against subject %.*s\n", c, min, max,
- max, eptr));
-
- if ((ims & PCRE_CASELESS) != 0)
- {
- c = md->lcc[c];
- for (i = 1; i <= min; i++)
- if (c == md->lcc[*eptr++]) return FALSE;
- if (min == max) continue;
- if (minimize)
- {
- for (i = min;; i++)
- {
- if (match(eptr, ecode, offset_top, md, ims, FALSE, eptrb))
- return TRUE;
- if (i >= max || eptr >= md->end_subject ||
- c == md->lcc[*eptr++])
- return FALSE;
- }
- /* Control never gets here */
- }
- else
- {
- const uschar *pp = eptr;
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject || c == md->lcc[*eptr]) break;
- eptr++;
- }
- while (eptr >= pp)
- if (match(eptr--, ecode, offset_top, md, ims, FALSE, eptrb))
- return TRUE;
- return FALSE;
- }
- /* Control never gets here */
- }
-
- /* Caseful comparisons */
-
- else
- {
- for (i = 1; i <= min; i++) if (c == *eptr++) return FALSE;
- if (min == max) continue;
- if (minimize)
- {
- for (i = min;; i++)
- {
- if (match(eptr, ecode, offset_top, md, ims, FALSE, eptrb))
- return TRUE;
- if (i >= max || eptr >= md->end_subject || c == *eptr++) return FALSE;
- }
- /* Control never gets here */
- }
- else
- {
- const uschar *pp = eptr;
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject || c == *eptr) break;
- eptr++;
- }
- while (eptr >= pp)
- if (match(eptr--, ecode, offset_top, md, ims, FALSE, eptrb))
- return TRUE;
- return FALSE;
- }
- }
- /* Control never gets here */
-
- /* Match a single character type repeatedly; several different opcodes
- share code. This is very similar to the code for single characters, but we
- repeat it in the interests of efficiency. */
-
- case OP_TYPEEXACT:
- min = max = (ecode[1] << 8) + ecode[2];
- minimize = TRUE;
- ecode += 3;
- goto REPEATTYPE;
-
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- min = 0;
- max = (ecode[1] << 8) + ecode[2];
- minimize = *ecode == OP_TYPEMINUPTO;
- ecode += 3;
- goto REPEATTYPE;
-
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- c = *ecode++ - OP_TYPESTAR;
- minimize = (c & 1) != 0;
- min = rep_min[c]; /* Pick up values from tables; */
- max = rep_max[c]; /* zero for max => infinity */
- if (max == 0) max = INT_MAX;
-
- /* Common code for all repeated single character type matches */
-
- REPEATTYPE:
- ctype = *ecode++; /* Code for the character type */
-
- /* First, ensure the minimum number of matches are present. Use inline
- code for maximizing the speed, and do the type test once at the start
- (i.e. keep it out of the loop). Also test that there are at least the
- minimum number of characters before we start. */
-
- if (min > md->end_subject - eptr) return FALSE;
- if (min > 0) switch(ctype)
- {
- case OP_ANY:
- if ((ims & PCRE_DOTALL) == 0)
- { for (i = 1; i <= min; i++) if (*eptr++ == '\n') return FALSE; }
- else eptr += min;
- break;
-
- case OP_NOT_DIGIT:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_digit) != 0) return FALSE;
- break;
-
- case OP_DIGIT:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_digit) == 0) return FALSE;
- break;
-
- case OP_NOT_WHITESPACE:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_space) != 0) return FALSE;
- break;
-
- case OP_WHITESPACE:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_space) == 0) return FALSE;
- break;
-
- case OP_NOT_WORDCHAR:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_word) != 0)
- return FALSE;
- break;
-
- case OP_WORDCHAR:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_word) == 0)
- return FALSE;
- break;
- }
-
- /* If min = max, continue at the same level without recursing */
-
- if (min == max) continue;
-
- /* If minimizing, we have to test the rest of the pattern before each
- subsequent match. */
-
- if (minimize)
- {
- for (i = min;; i++)
- {
- if (match(eptr, ecode, offset_top, md, ims, FALSE, eptrb)) return TRUE;
- if (i >= max || eptr >= md->end_subject) return FALSE;
-
- c = *eptr++;
- switch(ctype)
- {
- case OP_ANY:
- if ((ims & PCRE_DOTALL) == 0 && c == '\n') return FALSE;
- break;
-
- case OP_NOT_DIGIT:
- if ((md->ctypes[c] & ctype_digit) != 0) return FALSE;
- break;
-
- case OP_DIGIT:
- if ((md->ctypes[c] & ctype_digit) == 0) return FALSE;
- break;
-
- case OP_NOT_WHITESPACE:
- if ((md->ctypes[c] & ctype_space) != 0) return FALSE;
- break;
-
- case OP_WHITESPACE:
- if ((md->ctypes[c] & ctype_space) == 0) return FALSE;
- break;
-
- case OP_NOT_WORDCHAR:
- if ((md->ctypes[c] & ctype_word) != 0) return FALSE;
- break;
-
- case OP_WORDCHAR:
- if ((md->ctypes[c] & ctype_word) == 0) return FALSE;
- break;
- }
- }
- /* Control never gets here */
- }
-
- /* If maximizing it is worth using inline code for speed, doing the type
- test once at the start (i.e. keep it out of the loop). */
-
- else
- {
- const uschar *pp = eptr;
- switch(ctype)
- {
- case OP_ANY:
- if ((ims & PCRE_DOTALL) == 0)
- {
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject || *eptr == '\n') break;
- eptr++;
- }
- }
- else
- {
- c = max - min;
- if (c > md->end_subject - eptr) c = md->end_subject - eptr;
- eptr += c;
- }
- break;
-
- case OP_NOT_DIGIT:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) != 0)
- break;
- eptr++;
- }
- break;
-
- case OP_DIGIT:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) == 0)
- break;
- eptr++;
- }
- break;
-
- case OP_NOT_WHITESPACE:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) != 0)
- break;
- eptr++;
- }
- break;
-
- case OP_WHITESPACE:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) == 0)
- break;
- eptr++;
- }
- break;
-
- case OP_NOT_WORDCHAR:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) != 0)
- break;
- eptr++;
- }
- break;
-
- case OP_WORDCHAR:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) == 0)
- break;
- eptr++;
- }
- break;
- }
-
- while (eptr >= pp)
- if (match(eptr--, ecode, offset_top, md, ims, FALSE, eptrb))
- return TRUE;
- return FALSE;
- }
- /* Control never gets here */
-
- /* There's been some horrible disaster. */
-
- default:
- DPRINTF(("Unknown opcode %d\n", *ecode));
- md->errorcode = PCRE_ERROR_UNKNOWN_NODE;
- return FALSE;
- }
-
- /* Do not stick any code in here without much thought; it is assumed
- that "continue" in the code above comes out to here to repeat the main
- loop. */
-
- } /* End of main loop */
-/* Control never reaches here */
-}
-
-
-
-
-/*************************************************
-* Execute a Regular Expression *
-*************************************************/
-
-/* This function applies a compiled re to a subject string and picks out
-portions of the string if it matches. Two elements in the vector are set for
-each substring: the offsets to the start and end of the substring.
-
-Arguments:
- external_re points to the compiled expression
- external_extra points to "hints" from pcre_study() or is NULL
- subject points to the subject string
- length length of subject string (may contain binary zeros)
- start_offset where to start in the subject string
- options option bits
- offsets points to a vector of ints to be filled in with offsets
- offsetcount the number of elements in the vector
-
-Returns: > 0 => success; value is the number of elements filled in
- = 0 => success, but offsets is not big enough
- -1 => failed to match
- < -1 => some kind of unexpected problem
-*/
-
-int
-pcre_exec(const pcre *external_re, const pcre_extra *external_extra,
- const char *subject, int length, int start_offset, int options, int *offsets,
- int offsetcount)
-{
-int resetcount, ocount;
-int first_char = -1;
-int req_char = -1;
-int req_char2 = -1;
-unsigned long int ims = 0;
-match_data match_block;
-const uschar *start_bits = NULL;
-const uschar *start_match = (const uschar *)subject + start_offset;
-const uschar *end_subject;
-const uschar *req_char_ptr = start_match - 1;
-const real_pcre *re = (const real_pcre *)external_re;
-const real_pcre_extra *extra = (const real_pcre_extra *)external_extra;
-BOOL using_temporary_offsets = FALSE;
-BOOL anchored = ((re->options | options) & PCRE_ANCHORED) != 0;
-BOOL startline = (re->options & PCRE_STARTLINE) != 0;
-
-if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;
-
-if (re == NULL || subject == NULL ||
- (offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL;
-if (re->magic_number != MAGIC_NUMBER) return PCRE_ERROR_BADMAGIC;
-
-match_block.start_subject = (const uschar *)subject;
-match_block.end_subject = match_block.start_subject + length;
-end_subject = match_block.end_subject;
-
-match_block.endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;
-
-match_block.notbol = (options & PCRE_NOTBOL) != 0;
-match_block.noteol = (options & PCRE_NOTEOL) != 0;
-match_block.notempty = (options & PCRE_NOTEMPTY) != 0;
-
-match_block.errorcode = PCRE_ERROR_NOMATCH; /* Default error */
-
-match_block.lcc = re->tables + lcc_offset;
-match_block.ctypes = re->tables + ctypes_offset;
-
-/* The ims options can vary during the matching as a result of the presence
-of (?ims) items in the pattern. They are kept in a local variable so that
-restoring at the exit of a group is easy. */
-
-ims = re->options & (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL);
-
-/* If the expression has got more back references than the offsets supplied can
-hold, we get a temporary bit of working store to use during the matching.
-Otherwise, we can use the vector supplied, rounding down its size to a multiple
-of 3. */
-
-ocount = offsetcount - (offsetcount % 3);
-
-if (re->top_backref > 0 && re->top_backref >= ocount/3)
- {
- ocount = re->top_backref * 3 + 3;
- match_block.offset_vector = (int *)(pcre_malloc)(ocount * sizeof(int));
- if (match_block.offset_vector == NULL) return PCRE_ERROR_NOMEMORY;
- using_temporary_offsets = TRUE;
- DPRINTF(("Got memory to hold back references\n"));
- }
-else match_block.offset_vector = offsets;
-
-match_block.offset_end = ocount;
-match_block.offset_max = (2*ocount)/3;
-match_block.offset_overflow = FALSE;
-
-/* Compute the minimum number of offsets that we need to reset each time. Doing
-this makes a huge difference to execution time when there aren't many brackets
-in the pattern. */
-
-resetcount = 2 + re->top_bracket * 2;
-if (resetcount > offsetcount) resetcount = ocount;
-
-/* Reset the working variable associated with each extraction. These should
-never be used unless previously set, but they get saved and restored, and so we
-initialize them to avoid reading uninitialized locations. */
-
-if (match_block.offset_vector != NULL)
- {
- register int *iptr = match_block.offset_vector + ocount;
- register int *iend = iptr - resetcount/2 + 1;
- while (--iptr >= iend) *iptr = -1;
- }
-
-/* Set up the first character to match, if available. The first_char value is
-never set for an anchored regular expression, but the anchoring may be forced
-at run time, so we have to test for anchoring. The first char may be unset for
-an unanchored pattern, of course. If there's no first char and the pattern was
-studied, there may be a bitmap of possible first characters. */
-
-if (!anchored)
- {
- if ((re->options & PCRE_FIRSTSET) != 0)
- {
- first_char = re->first_char;
- if ((ims & PCRE_CASELESS) != 0) first_char = match_block.lcc[first_char];
- }
- else
- if (!startline && extra != NULL &&
- (extra->options & PCRE_STUDY_MAPPED) != 0)
- start_bits = extra->start_bits;
- }
-
-/* For anchored or unanchored matches, there may be a "last known required
-character" set. If the PCRE_CASELESS is set, implying that the match starts
-caselessly, or if there are any changes of this flag within the regex, set up
-both cases of the character. Otherwise set the two values the same, which will
-avoid duplicate testing (which takes significant time). This covers the vast
-majority of cases. It will be suboptimal when the case flag changes in a regex
-and the required character in fact is caseful. */
-
-if ((re->options & PCRE_REQCHSET) != 0)
- {
- req_char = re->req_char;
- req_char2 = ((re->options & (PCRE_CASELESS | PCRE_ICHANGED)) != 0)?
- (re->tables + fcc_offset)[req_char] : req_char;
- }
-
-/* Loop for handling unanchored repeated matching attempts; for anchored regexs
-the loop runs just once. */
-
-do
- {
- int rc;
- register int *iptr = match_block.offset_vector;
- register int *iend = iptr + resetcount;
-
- /* Reset the maximum number of extractions we might see. */
-
- while (iptr < iend) *iptr++ = -1;
-
- /* Advance to a unique first char if possible */
-
- if (first_char >= 0)
- {
- if ((ims & PCRE_CASELESS) != 0)
- while (start_match < end_subject &&
- match_block.lcc[*start_match] != first_char)
- start_match++;
- else
- while (start_match < end_subject && *start_match != first_char)
- start_match++;
- }
-
- /* Or to just after \n for a multiline match if possible */
-
- else if (startline)
- {
- if (start_match > match_block.start_subject + start_offset)
- {
- while (start_match < end_subject && start_match[-1] != '\n')
- start_match++;
- }
- }
-
- /* Or to a non-unique first char after study */
-
- else if (start_bits != NULL)
- {
- while (start_match < end_subject)
- {
- register int c = *start_match;
- if ((start_bits[c/8] & (1 << (c&7))) == 0) start_match++; else break;
- }
- }
-
-#ifdef DEBUG /* Sigh. Some compilers never learn. */
- printf(">>>> Match against: ");
- pchars(start_match, end_subject - start_match, TRUE, &match_block);
- printf("\n");
-#endif
-
- /* If req_char is set, we know that that character must appear in the subject
- for the match to succeed. If the first character is set, req_char must be
- later in the subject; otherwise the test starts at the match point. This
- optimization can save a huge amount of backtracking in patterns with nested
- unlimited repeats that aren't going to match. We don't know what the state of
- case matching may be when this character is hit, so test for it in both its
- cases if necessary. However, the different cased versions will not be set up
- unless PCRE_CASELESS was given or the casing state changes within the regex.
- Writing separate code makes it go faster, as does using an autoincrement and
- backing off on a match. */
-
- if (req_char >= 0)
- {
- register const uschar *p = start_match + ((first_char >= 0)? 1 : 0);
-
- /* We don't need to repeat the search if we haven't yet reached the
- place we found it at last time. */
-
- if (p > req_char_ptr)
- {
- /* Do a single test if no case difference is set up */
-
- if (req_char == req_char2)
- {
- while (p < end_subject)
- {
- if (*p++ == req_char) { p--; break; }
- }
- }
-
- /* Otherwise test for either case */
-
- else
- {
- while (p < end_subject)
- {
- register int pp = *p++;
- if (pp == req_char || pp == req_char2) { p--; break; }
- }
- }
-
- /* If we can't find the required character, break the matching loop */
-
- if (p >= end_subject) break;
-
- /* If we have found the required character, save the point where we
- found it, so that we don't search again next time round the loop if
- the start hasn't passed this character yet. */
-
- req_char_ptr = p;
- }
- }
-
- /* When a match occurs, substrings will be set for all internal extractions;
- we just need to set up the whole thing as substring 0 before returning. If
- there were too many extractions, set the return code to zero. In the case
- where we had to get some local store to hold offsets for backreferences, copy
- those back references that we can. In this case there need not be overflow
- if certain parts of the pattern were not used. */
-
- match_block.start_match = start_match;
- if (!match(start_match, re->code, 2, &match_block, ims, FALSE, start_match))
- continue;
-
- /* Copy the offset information from temporary store if necessary */
-
- if (using_temporary_offsets)
- {
- if (offsetcount >= 4)
- {
- memcpy(offsets + 2, match_block.offset_vector + 2,
- (offsetcount - 2) * sizeof(int));
- DPRINTF(("Copied offsets from temporary memory\n"));
- }
- if (match_block.end_offset_top > offsetcount)
- match_block.offset_overflow = TRUE;
-
- DPRINTF(("Freeing temporary memory\n"));
- (pcre_free)(match_block.offset_vector);
- }
-
- rc = match_block.offset_overflow? 0 : match_block.end_offset_top/2;
-
- if (match_block.offset_end < 2) rc = 0; else
- {
- offsets[0] = start_match - match_block.start_subject;
- offsets[1] = match_block.end_match_ptr - match_block.start_subject;
- }
-
- DPRINTF((">>>> returning %d\n", rc));
- return rc;
- }
-
-/* This "while" is the end of the "do" above */
-
-while (!anchored &&
- match_block.errorcode == PCRE_ERROR_NOMATCH &&
- start_match++ < end_subject);
-
-if (using_temporary_offsets)
- {
- DPRINTF(("Freeing temporary memory\n"));
- (pcre_free)(match_block.offset_vector);
- }
-
-DPRINTF((">>>> returning %d\n", match_block.errorcode));
-
-return match_block.errorcode;
-}
-
-/* End of pcre.c */
diff --git a/ext/pcre/pcrelib/pcre.def b/ext/pcre/pcrelib/pcre.def
deleted file mode 100644
index 0e8cf3f442..0000000000
--- a/ext/pcre/pcrelib/pcre.def
+++ /dev/null
@@ -1,19 +0,0 @@
-EXPORTS
-
-pcre_malloc DATA
-pcre_free DATA
-
-pcre_compile
-pcre_copy_substring
-pcre_exec
-pcre_get_substring
-pcre_get_substring_list
-pcre_info
-pcre_maketables
-pcre_study
-pcre_version
-
-regcomp
-regexec
-regerror
-regfree
diff --git a/ext/pcre/pcrelib/pcre.h b/ext/pcre/pcrelib/pcre.h
deleted file mode 100644
index 4888b45257..0000000000
--- a/ext/pcre/pcrelib/pcre.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* Copyright (c) 1997-1999 University of Cambridge */
-
-#ifndef _PCRE_H
-#define _PCRE_H
-
-#define PCRE_MAJOR 2
-#define PCRE_MINOR 08
-#define PCRE_DATE 31-Aug-1999
-
-/* Win32 uses DLL by default */
-
-#ifdef _WIN32
-# ifdef STATIC
-# define PCRE_DL_IMPORT
-# else
-# define PCRE_DL_IMPORT __declspec(dllimport)
-# endif
-#else
-# define PCRE_DL_IMPORT
-#endif
-
-/* Have to include stdlib.h in order to ensure that size_t is defined;
-it is needed here for malloc. */
-
-#include <sys/types.h>
-#include <stdlib.h>
-
-/* Allow for C++ users */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Options */
-
-#define PCRE_CASELESS 0x0001
-#define PCRE_MULTILINE 0x0002
-#define PCRE_DOTALL 0x0004
-#define PCRE_EXTENDED 0x0008
-#define PCRE_ANCHORED 0x0010
-#define PCRE_DOLLAR_ENDONLY 0x0020
-#define PCRE_EXTRA 0x0040
-#define PCRE_NOTBOL 0x0080
-#define PCRE_NOTEOL 0x0100
-#define PCRE_UNGREEDY 0x0200
-#define PCRE_NOTEMPTY 0x0400
-
-/* Exec-time and get-time error codes */
-
-#define PCRE_ERROR_NOMATCH (-1)
-#define PCRE_ERROR_NULL (-2)
-#define PCRE_ERROR_BADOPTION (-3)
-#define PCRE_ERROR_BADMAGIC (-4)
-#define PCRE_ERROR_UNKNOWN_NODE (-5)
-#define PCRE_ERROR_NOMEMORY (-6)
-#define PCRE_ERROR_NOSUBSTRING (-7)
-
-/* Types */
-
-typedef void pcre;
-typedef void pcre_extra;
-
-/* Store get and free functions. These can be set to alternative malloc/free
-functions if required. Some magic is required for Win32 DLL; it is null on
-other OS. */
-
-PCRE_DL_IMPORT extern void *(*pcre_malloc)(size_t);
-PCRE_DL_IMPORT extern void (*pcre_free)(void *);
-
-#undef PCRE_DL_IMPORT
-
-/* Functions */
-
-extern pcre *pcre_compile(const char *, int, const char **, int *,
- const unsigned char *);
-extern int pcre_copy_substring(const char *, int *, int, int, char *, int);
-extern int pcre_exec(const pcre *, const pcre_extra *, const char *,
- int, int, int, int *, int);
-extern int pcre_get_substring(const char *, int *, int, int, const char **);
-extern int pcre_get_substring_list(const char *, int *, int, const char ***);
-extern int pcre_info(const pcre *, int *, int *);
-extern unsigned const char *pcre_maketables(void);
-extern pcre_extra *pcre_study(const pcre *, int, const char **);
-extern const char *pcre_version(void);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* End of pcre.h */
diff --git a/ext/pcre/pcrelib/pcreposix.3 b/ext/pcre/pcrelib/pcreposix.3
deleted file mode 100644
index 0a40369bdd..0000000000
--- a/ext/pcre/pcrelib/pcreposix.3
+++ /dev/null
@@ -1,141 +0,0 @@
-.TH PCRE 3
-.SH NAME
-pcreposix - POSIX API for Perl-compatible regular expressions.
-.SH SYNOPSIS
-.B #include <pcreposix.h>
-.PP
-.SM
-.br
-.B int regcomp(regex_t *\fIpreg\fR, const char *\fIpattern\fR,
-.ti +5n
-.B int \fIcflags\fR);
-.PP
-.br
-.B int regexec(regex_t *\fIpreg\fR, const char *\fIstring\fR,
-.ti +5n
-.B size_t \fInmatch\fR, regmatch_t \fIpmatch\fR[], int \fIeflags\fR);
-.PP
-.br
-.B size_t regerror(int \fIerrcode\fR, const regex_t *\fIpreg\fR,
-.ti +5n
-.B char *\fIerrbuf\fR, size_t \fIerrbuf_size\fR);
-.PP
-.br
-.B void regfree(regex_t *\fIpreg\fR);
-
-
-.SH DESCRIPTION
-This set of functions provides a POSIX-style API to the PCRE regular expression
-package. See the \fBpcre\fR documentation for a description of the native API,
-which contains additional functionality.
-
-The functions described here are just wrapper functions that ultimately call
-the native API. Their prototypes are defined in the \fBpcreposix.h\fR header
-file, and on Unix systems the library itself is called \fBpcreposix.a\fR, so
-can be accessed by adding \fB-lpcreposix\fR to the command for linking an
-application which uses them. Because the POSIX functions call the native ones,
-it is also necessary to add \fR-lpcre\fR.
-
-As I am pretty ignorant about POSIX, these functions must be considered as
-experimental. I have implemented only those option bits that can be reasonably
-mapped to PCRE native options. Other POSIX options are not even defined. It may
-be that it is useful to define, but ignore, other options. Feedback from more
-knowledgeable folk may cause this kind of detail to change.
-
-When PCRE is called via these functions, it is only the API that is POSIX-like
-in style. The syntax and semantics of the regular expressions themselves are
-still those of Perl, subject to the setting of various PCRE options, as
-described below.
-
-The header for these functions is supplied as \fBpcreposix.h\fR to avoid any
-potential clash with other POSIX libraries. It can, of course, be renamed or
-aliased as \fBregex.h\fR, which is the "correct" name. It provides two
-structure types, \fIregex_t\fR for compiled internal forms, and
-\fIregmatch_t\fR for returning captured substrings. It also defines some
-constants whose names start with "REG_"; these are used for setting options and
-identifying error codes.
-
-
-.SH COMPILING A PATTERN
-
-The function \fBregcomp()\fR is called to compile a pattern into an
-internal form. The pattern is a C string terminated by a binary zero, and
-is passed in the argument \fIpattern\fR. The \fIpreg\fR argument is a pointer
-to a regex_t structure which is used as a base for storing information about
-the compiled expression.
-
-The argument \fIcflags\fR is either zero, or contains one or more of the bits
-defined by the following macros:
-
- REG_ICASE
-
-The PCRE_CASELESS option is set when the expression is passed for compilation
-to the native function.
-
- REG_NEWLINE
-
-The PCRE_MULTILINE option is set when the expression is passed for compilation
-to the native function.
-
-The yield of \fBregcomp()\fR is zero on success, and non-zero otherwise. The
-\fIpreg\fR structure is filled in on success, and one member of the structure
-is publicized: \fIre_nsub\fR contains the number of capturing subpatterns in
-the regular expression. Various error codes are defined in the header file.
-
-
-.SH MATCHING A PATTERN
-The function \fBregexec()\fR is called to match a pre-compiled pattern
-\fIpreg\fR against a given \fIstring\fR, which is terminated by a zero byte,
-subject to the options in \fIeflags\fR. These can be:
-
- REG_NOTBOL
-
-The PCRE_NOTBOL option is set when calling the underlying PCRE matching
-function.
-
- REG_NOTEOL
-
-The PCRE_NOTEOL option is set when calling the underlying PCRE matching
-function.
-
-The portion of the string that was matched, and also any captured substrings,
-are returned via the \fIpmatch\fR argument, which points to an array of
-\fInmatch\fR structures of type \fIregmatch_t\fR, containing the members
-\fIrm_so\fR and \fIrm_eo\fR. These contain the offset to the first character of
-each substring and the offset to the first character after the end of each
-substring, respectively. The 0th element of the vector relates to the entire
-portion of \fIstring\fR that was matched; subsequent elements relate to the
-capturing subpatterns of the regular expression. Unused entries in the array
-have both structure members set to -1.
-
-A successful match yields a zero return; various error codes are defined in the
-header file, of which REG_NOMATCH is the "expected" failure code.
-
-
-.SH ERROR MESSAGES
-The \fBregerror()\fR function maps a non-zero errorcode from either
-\fBregcomp\fR or \fBregexec\fR to a printable message. If \fIpreg\fR is not
-NULL, the error should have arisen from the use of that structure. A message
-terminated by a binary zero is placed in \fIerrbuf\fR. The length of the
-message, including the zero, is limited to \fIerrbuf_size\fR. The yield of the
-function is the size of buffer needed to hold the whole message.
-
-
-.SH STORAGE
-Compiling a regular expression causes memory to be allocated and associated
-with the \fIpreg\fR structure. The function \fBregfree()\fR frees all such
-memory, after which \fIpreg\fR may no longer be used as a compiled expression.
-
-
-.SH AUTHOR
-Philip Hazel <ph10@cam.ac.uk>
-.br
-University Computing Service,
-.br
-New Museums Site,
-.br
-Cambridge CB2 3QG, England.
-.br
-Phone: +44 1223 334714
-
-Copyright (c) 1997-1999 University of Cambridge.
diff --git a/ext/pcre/pcrelib/pcreposix.3.html b/ext/pcre/pcrelib/pcreposix.3.html
deleted file mode 100644
index 2c764b6776..0000000000
--- a/ext/pcre/pcrelib/pcreposix.3.html
+++ /dev/null
@@ -1,182 +0,0 @@
-<HTML>
-<HEAD>
-<TITLE>pcreposix specification</TITLE>
-</HEAD>
-<body bgcolor="#FFFFFF" text="#00005A">
-<H1>pcreposix specification</H1>
-This HTML document has been generated automatically from the original man page.
-If there is any nonsense in it, please consult the man page in case the
-conversion went wrong.
-<UL>
-<LI><A NAME="TOC1" HREF="#SEC1">NAME</A>
-<LI><A NAME="TOC2" HREF="#SEC2">SYNOPSIS</A>
-<LI><A NAME="TOC3" HREF="#SEC3">DESCRIPTION</A>
-<LI><A NAME="TOC4" HREF="#SEC4">COMPILING A PATTERN</A>
-<LI><A NAME="TOC5" HREF="#SEC5">MATCHING A PATTERN</A>
-<LI><A NAME="TOC6" HREF="#SEC6">ERROR MESSAGES</A>
-<LI><A NAME="TOC7" HREF="#SEC7">STORAGE</A>
-<LI><A NAME="TOC8" HREF="#SEC8">AUTHOR</A>
-</UL>
-<LI><A NAME="SEC1" HREF="#TOC1">NAME</A>
-<P>
-pcreposix - POSIX API for Perl-compatible regular expressions.
-</P>
-<LI><A NAME="SEC2" HREF="#TOC1">SYNOPSIS</A>
-<P>
-<B>#include &#60;pcreposix.h&#62;</B>
-</P>
-<P>
-<B>int regcomp(regex_t *<I>preg</I>, const char *<I>pattern</I>,</B>
-<B>int <I>cflags</I>);</B>
-</P>
-<P>
-<B>int regexec(regex_t *<I>preg</I>, const char *<I>string</I>,</B>
-<B>size_t <I>nmatch</I>, regmatch_t <I>pmatch</I>[], int <I>eflags</I>);</B>
-</P>
-<P>
-<B>size_t regerror(int <I>errcode</I>, const regex_t *<I>preg</I>,</B>
-<B>char *<I>errbuf</I>, size_t <I>errbuf_size</I>);</B>
-</P>
-<P>
-<B>void regfree(regex_t *<I>preg</I>);</B>
-</P>
-<LI><A NAME="SEC3" HREF="#TOC1">DESCRIPTION</A>
-<P>
-This set of functions provides a POSIX-style API to the PCRE regular expression
-package. See the <B>pcre</B> documentation for a description of the native API,
-which contains additional functionality.
-</P>
-<P>
-The functions described here are just wrapper functions that ultimately call
-the native API. Their prototypes are defined in the <B>pcreposix.h</B> header
-file, and on Unix systems the library itself is called <B>pcreposix.a</B>, so
-can be accessed by adding <B>-lpcreposix</B> to the command for linking an
-application which uses them. Because the POSIX functions call the native ones,
-it is also necessary to add \fR-lpcre\fR.
-</P>
-<P>
-As I am pretty ignorant about POSIX, these functions must be considered as
-experimental. I have implemented only those option bits that can be reasonably
-mapped to PCRE native options. Other POSIX options are not even defined. It may
-be that it is useful to define, but ignore, other options. Feedback from more
-knowledgeable folk may cause this kind of detail to change.
-</P>
-<P>
-When PCRE is called via these functions, it is only the API that is POSIX-like
-in style. The syntax and semantics of the regular expressions themselves are
-still those of Perl, subject to the setting of various PCRE options, as
-described below.
-</P>
-<P>
-The header for these functions is supplied as <B>pcreposix.h</B> to avoid any
-potential clash with other POSIX libraries. It can, of course, be renamed or
-aliased as <B>regex.h</B>, which is the "correct" name. It provides two
-structure types, <I>regex_t</I> for compiled internal forms, and
-<I>regmatch_t</I> for returning captured substrings. It also defines some
-constants whose names start with "REG_"; these are used for setting options and
-identifying error codes.
-</P>
-<LI><A NAME="SEC4" HREF="#TOC1">COMPILING A PATTERN</A>
-<P>
-The function <B>regcomp()</B> is called to compile a pattern into an
-internal form. The pattern is a C string terminated by a binary zero, and
-is passed in the argument <I>pattern</I>. The <I>preg</I> argument is a pointer
-to a regex_t structure which is used as a base for storing information about
-the compiled expression.
-</P>
-<P>
-The argument <I>cflags</I> is either zero, or contains one or more of the bits
-defined by the following macros:
-</P>
-<P>
-<PRE>
- REG_ICASE
-</PRE>
-</P>
-<P>
-The PCRE_CASELESS option is set when the expression is passed for compilation
-to the native function.
-</P>
-<P>
-<PRE>
- REG_NEWLINE
-</PRE>
-</P>
-<P>
-The PCRE_MULTILINE option is set when the expression is passed for compilation
-to the native function.
-</P>
-<P>
-The yield of <B>regcomp()</B> is zero on success, and non-zero otherwise. The
-<I>preg</I> structure is filled in on success, and one member of the structure
-is publicized: <I>re_nsub</I> contains the number of capturing subpatterns in
-the regular expression. Various error codes are defined in the header file.
-</P>
-<LI><A NAME="SEC5" HREF="#TOC1">MATCHING A PATTERN</A>
-<P>
-The function <B>regexec()</B> is called to match a pre-compiled pattern
-<I>preg</I> against a given <I>string</I>, which is terminated by a zero byte,
-subject to the options in <I>eflags</I>. These can be:
-</P>
-<P>
-<PRE>
- REG_NOTBOL
-</PRE>
-</P>
-<P>
-The PCRE_NOTBOL option is set when calling the underlying PCRE matching
-function.
-</P>
-<P>
-<PRE>
- REG_NOTEOL
-</PRE>
-</P>
-<P>
-The PCRE_NOTEOL option is set when calling the underlying PCRE matching
-function.
-</P>
-<P>
-The portion of the string that was matched, and also any captured substrings,
-are returned via the <I>pmatch</I> argument, which points to an array of
-<I>nmatch</I> structures of type <I>regmatch_t</I>, containing the members
-<I>rm_so</I> and <I>rm_eo</I>. These contain the offset to the first character of
-each substring and the offset to the first character after the end of each
-substring, respectively. The 0th element of the vector relates to the entire
-portion of <I>string</I> that was matched; subsequent elements relate to the
-capturing subpatterns of the regular expression. Unused entries in the array
-have both structure members set to -1.
-</P>
-<P>
-A successful match yields a zero return; various error codes are defined in the
-header file, of which REG_NOMATCH is the "expected" failure code.
-</P>
-<LI><A NAME="SEC6" HREF="#TOC1">ERROR MESSAGES</A>
-<P>
-The <B>regerror()</B> function maps a non-zero errorcode from either
-<B>regcomp</B> or <B>regexec</B> to a printable message. If <I>preg</I> is not
-NULL, the error should have arisen from the use of that structure. A message
-terminated by a binary zero is placed in <I>errbuf</I>. The length of the
-message, including the zero, is limited to <I>errbuf_size</I>. The yield of the
-function is the size of buffer needed to hold the whole message.
-</P>
-<LI><A NAME="SEC7" HREF="#TOC1">STORAGE</A>
-<P>
-Compiling a regular expression causes memory to be allocated and associated
-with the <I>preg</I> structure. The function <B>regfree()</B> frees all such
-memory, after which <I>preg</I> may no longer be used as a compiled expression.
-</P>
-<LI><A NAME="SEC8" HREF="#TOC1">AUTHOR</A>
-<P>
-Philip Hazel &#60;ph10@cam.ac.uk&#62;
-<BR>
-University Computing Service,
-<BR>
-New Museums Site,
-<BR>
-Cambridge CB2 3QG, England.
-<BR>
-Phone: +44 1223 334714
-</P>
-<P>
-Copyright (c) 1997-1999 University of Cambridge.
diff --git a/ext/pcre/pcrelib/pcreposix.3.txt b/ext/pcre/pcrelib/pcreposix.3.txt
deleted file mode 100644
index c85fb8438c..0000000000
--- a/ext/pcre/pcrelib/pcreposix.3.txt
+++ /dev/null
@@ -1,150 +0,0 @@
-NAME
- pcreposix - POSIX API for Perl-compatible regular expres-
- sions.
-
-
-
-SYNOPSIS
- #include <pcreposix.h>
-
- int regcomp(regex_t *preg, const char *pattern,
- int cflags);
-
- int regexec(regex_t *preg, const char *string,
- size_t nmatch, regmatch_t pmatch[], int eflags);
-
- size_t regerror(int errcode, const regex_t *preg,
- char *errbuf, size_t errbuf_size);
-
- void regfree(regex_t *preg);
-
-
-
-DESCRIPTION
- This set of functions provides a POSIX-style API to the PCRE
- regular expression package. See the pcre documentation for a
- description of the native API, which contains additional
- functionality.
-
- The functions described here are just wrapper functions that
- ultimately call the native API. Their prototypes are defined
- in the pcreposix.h header file, and on Unix systems the
- library itself is called pcreposix.a, so can be accessed by
- adding -lpcreposix to the command for linking an application
- which uses them. Because the POSIX functions call the native
- ones, it is also necessary to add -lpcre.
-
- As I am pretty ignorant about POSIX, these functions must be
- considered as experimental. I have implemented only those
- option bits that can be reasonably mapped to PCRE native
- options. Other POSIX options are not even defined. It may be
- that it is useful to define, but ignore, other options.
- Feedback from more knowledgeable folk may cause this kind of
- detail to change.
-
- When PCRE is called via these functions, it is only the API
- that is POSIX-like in style. The syntax and semantics of the
- regular expressions themselves are still those of Perl, sub-
- ject to the setting of various PCRE options, as described
- below.
-
- The header for these functions is supplied as pcreposix.h to
- avoid any potential clash with other POSIX libraries. It
- can, of course, be renamed or aliased as regex.h, which is
- the "correct" name. It provides two structure types, regex_t
- for compiled internal forms, and regmatch_t for returning
- captured substrings. It also defines some constants whose
- names start with "REG_"; these are used for setting options
- and identifying error codes.
-
-
-
-COMPILING A PATTERN
- The function regcomp() is called to compile a pattern into
- an internal form. The pattern is a C string terminated by a
- binary zero, and is passed in the argument pattern. The preg
- argument is a pointer to a regex_t structure which is used
- as a base for storing information about the compiled expres-
- sion.
-
- The argument cflags is either zero, or contains one or more
- of the bits defined by the following macros:
-
- REG_ICASE
-
- The PCRE_CASELESS option is set when the expression is
- passed for compilation to the native function.
-
- REG_NEWLINE
-
- The PCRE_MULTILINE option is set when the expression is
- passed for compilation to the native function.
-
- The yield of regcomp() is zero on success, and non-zero oth-
- erwise. The preg structure is filled in on success, and one
- member of the structure is publicized: re_nsub contains the
- number of capturing subpatterns in the regular expression.
- Various error codes are defined in the header file.
-
-
-
-MATCHING A PATTERN
- The function regexec() is called to match a pre-compiled
- pattern preg against a given string, which is terminated by
- a zero byte, subject to the options in eflags. These can be:
-
- REG_NOTBOL
-
- The PCRE_NOTBOL option is set when calling the underlying
- PCRE matching function.
-
- REG_NOTEOL
-
- The PCRE_NOTEOL option is set when calling the underlying
- PCRE matching function.
-
- The portion of the string that was matched, and also any
- captured substrings, are returned via the pmatch argument,
- which points to an array of nmatch structures of type
- regmatch_t, containing the members rm_so and rm_eo. These
- contain the offset to the first character of each substring
- and the offset to the first character after the end of each
- substring, respectively. The 0th element of the vector
- relates to the entire portion of string that was matched;
- subsequent elements relate to the capturing subpatterns of
- the regular expression. Unused entries in the array have
- both structure members set to -1.
-
- A successful match yields a zero return; various error codes
- are defined in the header file, of which REG_NOMATCH is the
- "expected" failure code.
-
-
-
-ERROR MESSAGES
- The regerror() function maps a non-zero errorcode from
- either regcomp or regexec to a printable message. If preg is
- not NULL, the error should have arisen from the use of that
- structure. A message terminated by a binary zero is placed
- in errbuf. The length of the message, including the zero, is
- limited to errbuf_size. The yield of the function is the
- size of buffer needed to hold the whole message.
-
-
-
-STORAGE
- Compiling a regular expression causes memory to be allocated
- and associated with the preg structure. The function reg-
- free() frees all such memory, after which preg may no longer
- be used as a compiled expression.
-
-
-
-AUTHOR
- Philip Hazel <ph10@cam.ac.uk>
- University Computing Service,
- New Museums Site,
- Cambridge CB2 3QG, England.
- Phone: +44 1223 334714
-
- Copyright (c) 1997-1999 University of Cambridge.
diff --git a/ext/pcre/pcrelib/pcreposix.c b/ext/pcre/pcrelib/pcreposix.c
deleted file mode 100644
index 9672be4fd6..0000000000
--- a/ext/pcre/pcrelib/pcreposix.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/*
-This is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language. See
-the file Tech.Notes for some information on the internals.
-
-This module is a wrapper that provides a POSIX API to the underlying PCRE
-functions.
-
-Written by: Philip Hazel <ph10@cam.ac.uk>
-
- Copyright (c) 1997-1999 University of Cambridge
-
------------------------------------------------------------------------------
-Permission is granted to anyone to use this software for any purpose on any
-computer system, and to redistribute it freely, subject to the following
-restrictions:
-
-1. This software 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.
-
-2. The origin of this software must not be misrepresented, either by
- explicit claim or by omission.
-
-3. Altered versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
-
-4. If PCRE is embedded in any software that is released under the GNU
- General Purpose Licence (GPL), then the terms of that licence shall
- supersede any condition above with which it is incompatible.
------------------------------------------------------------------------------
-*/
-
-#include "internal.h"
-#include "pcreposix.h"
-#include "stdlib.h"
-
-
-
-/* Corresponding tables of PCRE error messages and POSIX error codes. */
-
-static const char *estring[] = {
- ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9, ERR10,
- ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19, ERR20,
- ERR21, ERR22, ERR23, ERR24, ERR25 };
-
-static int eint[] = {
- REG_EESCAPE, /* "\\ at end of pattern" */
- REG_EESCAPE, /* "\\c at end of pattern" */
- REG_EESCAPE, /* "unrecognized character follows \\" */
- REG_BADBR, /* "numbers out of order in {} quantifier" */
- REG_BADBR, /* "number too big in {} quantifier" */
- REG_EBRACK, /* "missing terminating ] for character class" */
- REG_ECTYPE, /* "invalid escape sequence in character class" */
- REG_ERANGE, /* "range out of order in character class" */
- REG_BADRPT, /* "nothing to repeat" */
- REG_BADRPT, /* "operand of unlimited repeat could match the empty string" */
- REG_ASSERT, /* "internal error: unexpected repeat" */
- REG_BADPAT, /* "unrecognized character after (?" */
- REG_ESIZE, /* "too many capturing parenthesized sub-patterns" */
- REG_EPAREN, /* "missing )" */
- REG_ESUBREG, /* "back reference to non-existent subpattern" */
- REG_INVARG, /* "erroffset passed as NULL" */
- REG_INVARG, /* "unknown option bit(s) set" */
- REG_EPAREN, /* "missing ) after comment" */
- REG_ESIZE, /* "too many sets of parentheses" */
- REG_ESIZE, /* "regular expression too large" */
- REG_ESPACE, /* "failed to get memory" */
- REG_EPAREN, /* "unmatched brackets" */
- REG_ASSERT, /* "internal error: code overflow" */
- REG_BADPAT, /* "unrecognized character after (?<" */
- REG_BADPAT, /* "lookbehind assertion is not fixed length" */
- REG_BADPAT, /* "malformed number after (?(" */
- REG_BADPAT, /* "conditional group containe more than two branches" */
- REG_BADPAT /* "assertion expected after (?(" */
-};
-
-/* Table of texts corresponding to POSIX error codes */
-
-static const char *pstring[] = {
- "", /* Dummy for value 0 */
- "internal error", /* REG_ASSERT */
- "invalid repeat counts in {}", /* BADBR */
- "pattern error", /* BADPAT */
- "? * + invalid", /* BADRPT */
- "unbalanced {}", /* EBRACE */
- "unbalanced []", /* EBRACK */
- "collation error - not relevant", /* ECOLLATE */
- "bad class", /* ECTYPE */
- "bad escape sequence", /* EESCAPE */
- "empty expression", /* EMPTY */
- "unbalanced ()", /* EPAREN */
- "bad range inside []", /* ERANGE */
- "expression too big", /* ESIZE */
- "failed to get memory", /* ESPACE */
- "bad back reference", /* ESUBREG */
- "bad argument", /* INVARG */
- "match failed" /* NOMATCH */
-};
-
-
-
-
-/*************************************************
-* Translate PCRE text code to int *
-*************************************************/
-
-/* PCRE compile-time errors are given as strings defined as macros. We can just
-look them up in a table to turn them into POSIX-style error codes. */
-
-static int
-pcre_posix_error_code(const char *s)
-{
-size_t i;
-for (i = 0; i < sizeof(estring)/sizeof(char *); i++)
- if (strcmp(s, estring[i]) == 0) return eint[i];
-return REG_ASSERT;
-}
-
-
-
-/*************************************************
-* Translate error code to string *
-*************************************************/
-
-size_t
-regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
-{
-const char *message, *addmessage;
-size_t length, addlength;
-
-message = (errcode >= (int)(sizeof(pstring)/sizeof(char *)))?
- "unknown error code" : pstring[errcode];
-length = strlen(message) + 1;
-
-addmessage = " at offset ";
-addlength = (preg != NULL && (int)preg->re_erroffset != -1)?
- strlen(addmessage) + 6 : 0;
-
-if (errbuf_size > 0)
- {
- if (addlength > 0 && errbuf_size >= length + addlength)
- sprintf(errbuf, "%s%s%-6d", message, addmessage, (int)preg->re_erroffset);
- else
- {
- strncpy(errbuf, message, errbuf_size - 1);
- errbuf[errbuf_size-1] = 0;
- }
- }
-
-return length + addlength;
-}
-
-
-
-
-/*************************************************
-* Free store held by a regex *
-*************************************************/
-
-void
-regfree(regex_t *preg)
-{
-(pcre_free)(preg->re_pcre);
-}
-
-
-
-
-/*************************************************
-* Compile a regular expression *
-*************************************************/
-
-/*
-Arguments:
- preg points to a structure for recording the compiled expression
- pattern the pattern to compile
- cflags compilation flags
-
-Returns: 0 on success
- various non-zero codes on failure
-*/
-
-int
-regcomp(regex_t *preg, const char *pattern, int cflags)
-{
-const char *errorptr;
-int erroffset;
-int options = 0;
-
-if ((cflags & REG_ICASE) != 0) options |= PCRE_CASELESS;
-if ((cflags & REG_NEWLINE) != 0) options |= PCRE_MULTILINE;
-
-preg->re_pcre = pcre_compile(pattern, options, &errorptr, &erroffset, NULL);
-preg->re_erroffset = erroffset;
-
-if (preg->re_pcre == NULL) return pcre_posix_error_code(errorptr);
-
-preg->re_nsub = pcre_info(preg->re_pcre, NULL, NULL);
-return 0;
-}
-
-
-
-
-/*************************************************
-* Match a regular expression *
-*************************************************/
-
-int
-regexec(regex_t *preg, const char *string, size_t nmatch,
- regmatch_t pmatch[], int eflags)
-{
-int rc;
-int options = 0;
-
-if ((eflags & REG_NOTBOL) != 0) options |= PCRE_NOTBOL;
-if ((eflags & REG_NOTEOL) != 0) options |= PCRE_NOTEOL;
-
-preg->re_erroffset = (size_t)(-1); /* Only has meaning after compile */
-
-rc = pcre_exec(preg->re_pcre, NULL, string, (int)strlen(string), 0, options,
- (int *)pmatch, nmatch * 2);
-
-if (rc == 0) return 0; /* All pmatch were filled in */
-
-if (rc > 0)
- {
- size_t i;
- for (i = rc; i < nmatch; i++) pmatch[i].rm_so = pmatch[i].rm_eo = -1;
- return 0;
- }
-
-else switch(rc)
- {
- case PCRE_ERROR_NOMATCH: return REG_NOMATCH;
- case PCRE_ERROR_NULL: return REG_INVARG;
- case PCRE_ERROR_BADOPTION: return REG_INVARG;
- case PCRE_ERROR_BADMAGIC: return REG_INVARG;
- case PCRE_ERROR_UNKNOWN_NODE: return REG_ASSERT;
- case PCRE_ERROR_NOMEMORY: return REG_ESPACE;
- default: return REG_ASSERT;
- }
-}
-
-/* End of pcreposix.c */
diff --git a/ext/pcre/pcrelib/pcreposix.h b/ext/pcre/pcrelib/pcreposix.h
deleted file mode 100644
index 208db354b0..0000000000
--- a/ext/pcre/pcrelib/pcreposix.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* Copyright (c) 1997-1999 University of Cambridge */
-
-#ifndef _PCREPOSIX_H
-#define _PCREPOSIX_H
-
-/* This is the header for the POSIX wrapper interface to the PCRE Perl-
-Compatible Regular Expression library. It defines the things POSIX says should
-be there. I hope. */
-
-/* Have to include stdlib.h in order to ensure that size_t is defined. */
-
-#include <stdlib.h>
-
-/* Allow for C++ users */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Options defined by POSIX. */
-
-#define REG_ICASE 0x01
-#define REG_NEWLINE 0x02
-#define REG_NOTBOL 0x04
-#define REG_NOTEOL 0x08
-
-/* Error values. Not all these are relevant or used by the wrapper. */
-
-enum {
- REG_ASSERT = 1, /* internal error ? */
- REG_BADBR, /* invalid repeat counts in {} */
- REG_BADPAT, /* pattern error */
- REG_BADRPT, /* ? * + invalid */
- REG_EBRACE, /* unbalanced {} */
- REG_EBRACK, /* unbalanced [] */
- REG_ECOLLATE, /* collation error - not relevant */
- REG_ECTYPE, /* bad class */
- REG_EESCAPE, /* bad escape sequence */
- REG_EMPTY, /* empty expression */
- REG_EPAREN, /* unbalanced () */
- REG_ERANGE, /* bad range inside [] */
- REG_ESIZE, /* expression too big */
- REG_ESPACE, /* failed to get memory */
- REG_ESUBREG, /* bad back reference */
- REG_INVARG, /* bad argument */
- REG_NOMATCH /* match failed */
-};
-
-
-/* The structure representing a compiled regular expression. */
-
-typedef struct {
- void *re_pcre;
- size_t re_nsub;
- size_t re_erroffset;
-} regex_t;
-
-/* The structure in which a captured offset is returned. */
-
-typedef int regoff_t;
-
-typedef struct {
- regoff_t rm_so;
- regoff_t rm_eo;
-} regmatch_t;
-
-/* The functions */
-
-extern int regcomp(regex_t *, const char *, int);
-extern int regexec(regex_t *, const char *, size_t, regmatch_t *, int);
-extern size_t regerror(int, const regex_t *, char *, size_t);
-extern void regfree(regex_t *);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* End of pcreposix.h */
diff --git a/ext/pcre/pcrelib/pcretest.c b/ext/pcre/pcrelib/pcretest.c
deleted file mode 100644
index b2fe20eafc..0000000000
--- a/ext/pcre/pcrelib/pcretest.c
+++ /dev/null
@@ -1,1010 +0,0 @@
-/*************************************************
-* PCRE testing program *
-*************************************************/
-
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <time.h>
-#include <locale.h>
-
-/* Use the internal info for displaying the results of pcre_study(). */
-
-#include "internal.h"
-
-/* It is possible to compile this test program without including support for
-testing the POSIX interface, though this is not available via the standard
-Makefile. */
-
-#if !defined NOPOSIX
-#include "pcreposix.h"
-#endif
-
-#ifndef CLOCKS_PER_SEC
-#ifdef CLK_TCK
-#define CLOCKS_PER_SEC CLK_TCK
-#else
-#define CLOCKS_PER_SEC 100
-#endif
-#endif
-
-#define LOOPREPEAT 20000
-
-
-static FILE *outfile;
-static int log_store = 0;
-
-
-
-/* Debugging function to print the internal form of the regex. This is the same
-code as contained in pcre.c under the DEBUG macro. */
-
-static const char *OP_names[] = {
- "End", "\\A", "\\B", "\\b", "\\D", "\\d",
- "\\S", "\\s", "\\W", "\\w", "\\Z", "\\z",
- "Opt", "^", "$", "Any", "chars", "not",
- "*", "*?", "+", "+?", "?", "??", "{", "{", "{",
- "*", "*?", "+", "+?", "?", "??", "{", "{", "{",
- "*", "*?", "+", "+?", "?", "??", "{", "{", "{",
- "*", "*?", "+", "+?", "?", "??", "{", "{",
- "class", "Ref",
- "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not",
- "AssertB", "AssertB not", "Reverse", "Once", "Cond", "Cref",
- "Brazero", "Braminzero", "Bra"
-};
-
-
-static void print_internals(pcre *re)
-{
-unsigned char *code = ((real_pcre *)re)->code;
-
-fprintf(outfile, "------------------------------------------------------------------\n");
-
-for(;;)
- {
- int c;
- int charlength;
-
- fprintf(outfile, "%3d ", (int)(code - ((real_pcre *)re)->code));
-
- if (*code >= OP_BRA)
- {
- fprintf(outfile, "%3d Bra %d", (code[1] << 8) + code[2], *code - OP_BRA);
- code += 2;
- }
-
- else switch(*code)
- {
- case OP_END:
- fprintf(outfile, " %s\n", OP_names[*code]);
- fprintf(outfile, "------------------------------------------------------------------\n");
- return;
-
- case OP_OPT:
- fprintf(outfile, " %.2x %s", code[1], OP_names[*code]);
- code++;
- break;
-
- case OP_COND:
- fprintf(outfile, "%3d Cond", (code[1] << 8) + code[2]);
- code += 2;
- break;
-
- case OP_CREF:
- fprintf(outfile, " %.2d %s", code[1], OP_names[*code]);
- code++;
- break;
-
- case OP_CHARS:
- charlength = *(++code);
- fprintf(outfile, "%3d ", charlength);
- while (charlength-- > 0)
- if (isprint(c = *(++code))) fprintf(outfile, "%c", c);
- else fprintf(outfile, "\\x%02x", c);
- break;
-
- case OP_KETRMAX:
- case OP_KETRMIN:
- case OP_ALT:
- case OP_KET:
- case OP_ASSERT:
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- case OP_ONCE:
- fprintf(outfile, "%3d %s", (code[1] << 8) + code[2], OP_names[*code]);
- code += 2;
- break;
-
- case OP_REVERSE:
- fprintf(outfile, "%3d %s", (code[1] << 8) + code[2], OP_names[*code]);
- code += 2;
- break;
-
- case OP_STAR:
- case OP_MINSTAR:
- case OP_PLUS:
- case OP_MINPLUS:
- case OP_QUERY:
- case OP_MINQUERY:
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- if (*code >= OP_TYPESTAR)
- fprintf(outfile, " %s", OP_names[code[1]]);
- else if (isprint(c = code[1])) fprintf(outfile, " %c", c);
- else fprintf(outfile, " \\x%02x", c);
- fprintf(outfile, "%s", OP_names[*code++]);
- break;
-
- case OP_EXACT:
- case OP_UPTO:
- case OP_MINUPTO:
- if (isprint(c = code[3])) fprintf(outfile, " %c{", c);
- else fprintf(outfile, " \\x%02x{", c);
- if (*code != OP_EXACT) fprintf(outfile, ",");
- fprintf(outfile, "%d}", (code[1] << 8) + code[2]);
- if (*code == OP_MINUPTO) fprintf(outfile, "?");
- code += 3;
- break;
-
- case OP_TYPEEXACT:
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- fprintf(outfile, " %s{", OP_names[code[3]]);
- if (*code != OP_TYPEEXACT) fprintf(outfile, "0,");
- fprintf(outfile, "%d}", (code[1] << 8) + code[2]);
- if (*code == OP_TYPEMINUPTO) fprintf(outfile, "?");
- code += 3;
- break;
-
- case OP_NOT:
- if (isprint(c = *(++code))) fprintf(outfile, " [^%c]", c);
- else fprintf(outfile, " [^\\x%02x]", c);
- break;
-
- case OP_NOTSTAR:
- case OP_NOTMINSTAR:
- case OP_NOTPLUS:
- case OP_NOTMINPLUS:
- case OP_NOTQUERY:
- case OP_NOTMINQUERY:
- if (isprint(c = code[1])) fprintf(outfile, " [^%c]", c);
- else fprintf(outfile, " [^\\x%02x]", c);
- fprintf(outfile, "%s", OP_names[*code++]);
- break;
-
- case OP_NOTEXACT:
- case OP_NOTUPTO:
- case OP_NOTMINUPTO:
- if (isprint(c = code[3])) fprintf(outfile, " [^%c]{", c);
- else fprintf(outfile, " [^\\x%02x]{", c);
- if (*code != OP_NOTEXACT) fprintf(outfile, ",");
- fprintf(outfile, "%d}", (code[1] << 8) + code[2]);
- if (*code == OP_NOTMINUPTO) fprintf(outfile, "?");
- code += 3;
- break;
-
- case OP_REF:
- fprintf(outfile, " \\%d", *(++code));
- code++;
- goto CLASS_REF_REPEAT;
-
- case OP_CLASS:
- {
- int i, min, max;
- code++;
- fprintf(outfile, " [");
-
- for (i = 0; i < 256; i++)
- {
- if ((code[i/8] & (1 << (i&7))) != 0)
- {
- int j;
- for (j = i+1; j < 256; j++)
- if ((code[j/8] & (1 << (j&7))) == 0) break;
- if (i == '-' || i == ']') fprintf(outfile, "\\");
- if (isprint(i)) fprintf(outfile, "%c", i); else fprintf(outfile, "\\x%02x", i);
- if (--j > i)
- {
- fprintf(outfile, "-");
- if (j == '-' || j == ']') fprintf(outfile, "\\");
- if (isprint(j)) fprintf(outfile, "%c", j); else fprintf(outfile, "\\x%02x", j);
- }
- i = j;
- }
- }
- fprintf(outfile, "]");
- code += 32;
-
- CLASS_REF_REPEAT:
-
- switch(*code)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- fprintf(outfile, "%s", OP_names[*code]);
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- min = (code[1] << 8) + code[2];
- max = (code[3] << 8) + code[4];
- if (max == 0) fprintf(outfile, "{%d,}", min);
- else fprintf(outfile, "{%d,%d}", min, max);
- if (*code == OP_CRMINRANGE) fprintf(outfile, "?");
- code += 4;
- break;
-
- default:
- code--;
- }
- }
- break;
-
- /* Anything else is just a one-node item */
-
- default:
- fprintf(outfile, " %s", OP_names[*code]);
- break;
- }
-
- code++;
- fprintf(outfile, "\n");
- }
-}
-
-
-
-/* Character string printing function. */
-
-static void pchars(unsigned char *p, int length)
-{
-int c;
-while (length-- > 0)
- if (isprint(c = *(p++))) fprintf(outfile, "%c", c);
- else fprintf(outfile, "\\x%02x", c);
-}
-
-
-
-/* Alternative malloc function, to test functionality and show the size of the
-compiled re. */
-
-static void *new_malloc(size_t size)
-{
-if (log_store)
- fprintf(outfile, "Memory allocation (code space): %d\n",
- (int)((int)size - offsetof(real_pcre, code[0])));
-return malloc(size);
-}
-
-
-
-/* Read lines from named file or stdin and write to named file or stdout; lines
-consist of a regular expression, in delimiters and optionally followed by
-options, followed by a set of test data, terminated by an empty line. */
-
-int main(int argc, char **argv)
-{
-FILE *infile = stdin;
-int options = 0;
-int study_options = 0;
-int op = 1;
-int timeit = 0;
-int showinfo = 0;
-int showstore = 0;
-int posix = 0;
-int debug = 0;
-int done = 0;
-unsigned char buffer[30000];
-unsigned char dbuffer[1024];
-
-/* Static so that new_malloc can use it. */
-
-outfile = stdout;
-
-/* Scan options */
-
-while (argc > 1 && argv[op][0] == '-')
- {
- if (strcmp(argv[op], "-s") == 0 || strcmp(argv[op], "-m") == 0)
- showstore = 1;
- else if (strcmp(argv[op], "-t") == 0) timeit = 1;
- else if (strcmp(argv[op], "-i") == 0) showinfo = 1;
- else if (strcmp(argv[op], "-d") == 0) showinfo = debug = 1;
- else if (strcmp(argv[op], "-p") == 0) posix = 1;
- else
- {
- printf("*** Unknown option %s\n", argv[op]);
- printf("Usage: pcretest [-d] [-i] [-p] [-s] [-t] [<input> [<output>]]\n");
- printf(" -d debug: show compiled code; implies -i\n"
- " -i show information about compiled pattern\n"
- " -p use POSIX interface\n"
- " -s output store information\n"
- " -t time compilation and execution\n");
- return 1;
- }
- op++;
- argc--;
- }
-
-/* Sort out the input and output files */
-
-if (argc > 1)
- {
- infile = fopen(argv[op], "r");
- if (infile == NULL)
- {
- printf("** Failed to open %s\n", argv[op]);
- return 1;
- }
- }
-
-if (argc > 2)
- {
- outfile = fopen(argv[op+1], "w");
- if (outfile == NULL)
- {
- printf("** Failed to open %s\n", argv[op+1]);
- return 1;
- }
- }
-
-/* Set alternative malloc function */
-
-pcre_malloc = new_malloc;
-
-/* Heading line, then prompt for first regex if stdin */
-
-fprintf(outfile, "PCRE version %s\n\n", pcre_version());
-
-/* Main loop */
-
-while (!done)
- {
- pcre *re = NULL;
- pcre_extra *extra = NULL;
-
-#if !defined NOPOSIX /* There are still compilers that require no indent */
- regex_t preg;
-#endif
-
- const char *error;
- unsigned char *p, *pp, *ppp;
- unsigned const char *tables = NULL;
- int do_study = 0;
- int do_debug = debug;
- int do_G = 0;
- int do_g = 0;
- int do_showinfo = showinfo;
- int do_showrest = 0;
- int do_posix = 0;
- int erroroffset, len, delimiter;
-
- if (infile == stdin) printf(" re> ");
- if (fgets((char *)buffer, sizeof(buffer), infile) == NULL) break;
- if (infile != stdin) fprintf(outfile, "%s", (char *)buffer);
-
- p = buffer;
- while (isspace(*p)) p++;
- if (*p == 0) continue;
-
- /* Get the delimiter and seek the end of the pattern; if is isn't
- complete, read more. */
-
- delimiter = *p++;
-
- if (isalnum(delimiter) || delimiter == '\\')
- {
- fprintf(outfile, "** Delimiter must not be alphameric or \\\n");
- goto SKIP_DATA;
- }
-
- pp = p;
-
- for(;;)
- {
- while (*pp != 0)
- {
- if (*pp == '\\' && pp[1] != 0) pp++;
- else if (*pp == delimiter) break;
- pp++;
- }
- if (*pp != 0) break;
-
- len = sizeof(buffer) - (pp - buffer);
- if (len < 256)
- {
- fprintf(outfile, "** Expression too long - missing delimiter?\n");
- goto SKIP_DATA;
- }
-
- if (infile == stdin) printf(" > ");
- if (fgets((char *)pp, len, infile) == NULL)
- {
- fprintf(outfile, "** Unexpected EOF\n");
- done = 1;
- goto CONTINUE;
- }
- if (infile != stdin) fprintf(outfile, "%s", (char *)pp);
- }
-
- /* If the first character after the delimiter is backslash, make
- the pattern end with backslash. This is purely to provide a way
- of testing for the error message when a pattern ends with backslash. */
-
- if (pp[1] == '\\') *pp++ = '\\';
-
- /* Terminate the pattern at the delimiter */
-
- *pp++ = 0;
-
- /* Look for options after final delimiter */
-
- options = 0;
- study_options = 0;
- log_store = showstore; /* default from command line */
-
- while (*pp != 0)
- {
- switch (*pp++)
- {
- case 'g': do_g = 1; break;
- case 'i': options |= PCRE_CASELESS; break;
- case 'm': options |= PCRE_MULTILINE; break;
- case 's': options |= PCRE_DOTALL; break;
- case 'x': options |= PCRE_EXTENDED; break;
-
- case '+': do_showrest = 1; break;
- case 'A': options |= PCRE_ANCHORED; break;
- case 'D': do_debug = do_showinfo = 1; break;
- case 'E': options |= PCRE_DOLLAR_ENDONLY; break;
- case 'G': do_G = 1; break;
- case 'I': do_showinfo = 1; break;
- case 'M': log_store = 1; break;
-
-#if !defined NOPOSIX
- case 'P': do_posix = 1; break;
-#endif
-
- case 'S': do_study = 1; break;
- case 'U': options |= PCRE_UNGREEDY; break;
- case 'X': options |= PCRE_EXTRA; break;
-
- case 'L':
- ppp = pp;
- while (*ppp != '\n' && *ppp != ' ') ppp++;
- *ppp = 0;
- if (setlocale(LC_CTYPE, (const char *)pp) == NULL)
- {
- fprintf(outfile, "** Failed to set locale \"%s\"\n", pp);
- goto SKIP_DATA;
- }
- tables = pcre_maketables();
- pp = ppp;
- break;
-
- case '\n': case ' ': break;
- default:
- fprintf(outfile, "** Unknown option '%c'\n", pp[-1]);
- goto SKIP_DATA;
- }
- }
-
- /* Handle compiling via the POSIX interface, which doesn't support the
- timing, showing, or debugging options, nor the ability to pass over
- local character tables. */
-
-#if !defined NOPOSIX
- if (posix || do_posix)
- {
- int rc;
- int cflags = 0;
- if ((options & PCRE_CASELESS) != 0) cflags |= REG_ICASE;
- if ((options & PCRE_MULTILINE) != 0) cflags |= REG_NEWLINE;
- rc = regcomp(&preg, (char *)p, cflags);
-
- /* Compilation failed; go back for another re, skipping to blank line
- if non-interactive. */
-
- if (rc != 0)
- {
- (void)regerror(rc, &preg, (char *)buffer, sizeof(buffer));
- fprintf(outfile, "Failed: POSIX code %d: %s\n", rc, buffer);
- goto SKIP_DATA;
- }
- }
-
- /* Handle compiling via the native interface */
-
- else
-#endif /* !defined NOPOSIX */
-
- {
- if (timeit)
- {
- register int i;
- clock_t time_taken;
- clock_t start_time = clock();
- for (i = 0; i < LOOPREPEAT; i++)
- {
- re = pcre_compile((char *)p, options, &error, &erroroffset, tables);
- if (re != NULL) free(re);
- }
- time_taken = clock() - start_time;
- fprintf(outfile, "Compile time %.3f milliseconds\n",
- ((double)time_taken * 1000.0) /
- ((double)LOOPREPEAT * (double)CLOCKS_PER_SEC));
- }
-
- re = pcre_compile((char *)p, options, &error, &erroroffset, tables);
-
- /* Compilation failed; go back for another re, skipping to blank line
- if non-interactive. */
-
- if (re == NULL)
- {
- fprintf(outfile, "Failed: %s at offset %d\n", error, erroroffset);
- SKIP_DATA:
- if (infile != stdin)
- {
- for (;;)
- {
- if (fgets((char *)buffer, sizeof(buffer), infile) == NULL)
- {
- done = 1;
- goto CONTINUE;
- }
- len = (int)strlen((char *)buffer);
- while (len > 0 && isspace(buffer[len-1])) len--;
- if (len == 0) break;
- }
- fprintf(outfile, "\n");
- }
- goto CONTINUE;
- }
-
- /* Compilation succeeded; print data if required */
-
- if (do_showinfo)
- {
- int first_char, count;
-
- if (do_debug) print_internals(re);
-
- count = pcre_info(re, &options, &first_char);
- if (count < 0) fprintf(outfile,
- "Error %d while reading info\n", count);
- else
- {
- fprintf(outfile, "Identifying subpattern count = %d\n", count);
- if (options == 0) fprintf(outfile, "No options\n");
- else fprintf(outfile, "Options:%s%s%s%s%s%s%s%s\n",
- ((options & PCRE_ANCHORED) != 0)? " anchored" : "",
- ((options & PCRE_CASELESS) != 0)? " caseless" : "",
- ((options & PCRE_EXTENDED) != 0)? " extended" : "",
- ((options & PCRE_MULTILINE) != 0)? " multiline" : "",
- ((options & PCRE_DOTALL) != 0)? " dotall" : "",
- ((options & PCRE_DOLLAR_ENDONLY) != 0)? " dollar_endonly" : "",
- ((options & PCRE_EXTRA) != 0)? " extra" : "",
- ((options & PCRE_UNGREEDY) != 0)? " ungreedy" : "");
-
- if (((((real_pcre *)re)->options) & PCRE_ICHANGED) != 0)
- fprintf(outfile, "Case state changes\n");
-
- if (first_char == -1)
- {
- fprintf(outfile, "First char at start or follows \\n\n");
- }
- else if (first_char < 0)
- {
- fprintf(outfile, "No first char\n");
- }
- else
- {
- if (isprint(first_char))
- fprintf(outfile, "First char = \'%c\'\n", first_char);
- else
- fprintf(outfile, "First char = %d\n", first_char);
- }
-
- if (((((real_pcre *)re)->options) & PCRE_REQCHSET) != 0)
- {
- int req_char = ((real_pcre *)re)->req_char;
- if (isprint(req_char))
- fprintf(outfile, "Req char = \'%c\'\n", req_char);
- else
- fprintf(outfile, "Req char = %d\n", req_char);
- }
- else fprintf(outfile, "No req char\n");
- }
- }
-
- /* If /S was present, study the regexp to generate additional info to
- help with the matching. */
-
- if (do_study)
- {
- if (timeit)
- {
- register int i;
- clock_t time_taken;
- clock_t start_time = clock();
- for (i = 0; i < LOOPREPEAT; i++)
- extra = pcre_study(re, study_options, &error);
- time_taken = clock() - start_time;
- if (extra != NULL) free(extra);
- fprintf(outfile, " Study time %.3f milliseconds\n",
- ((double)time_taken * 1000.0)/
- ((double)LOOPREPEAT * (double)CLOCKS_PER_SEC));
- }
-
- extra = pcre_study(re, study_options, &error);
- if (error != NULL)
- fprintf(outfile, "Failed to study: %s\n", error);
- else if (extra == NULL)
- fprintf(outfile, "Study returned NULL\n");
-
- /* This looks at internal information. A bit kludgy to do it this
- way, but it is useful for testing. */
-
- else if (do_showinfo)
- {
- real_pcre_extra *xx = (real_pcre_extra *)extra;
- if ((xx->options & PCRE_STUDY_MAPPED) == 0)
- fprintf(outfile, "No starting character set\n");
- else
- {
- int i;
- int c = 24;
- fprintf(outfile, "Starting character set: ");
- for (i = 0; i < 256; i++)
- {
- if ((xx->start_bits[i/8] & (1<<(i%8))) != 0)
- {
- if (c > 75)
- {
- fprintf(outfile, "\n ");
- c = 2;
- }
- if (isprint(i) && i != ' ')
- {
- fprintf(outfile, "%c ", i);
- c += 2;
- }
- else
- {
- fprintf(outfile, "\\x%02x ", i);
- c += 5;
- }
- }
- }
- fprintf(outfile, "\n");
- }
- }
- }
- }
-
- /* Read data lines and test them */
-
- for (;;)
- {
- unsigned char *q;
- unsigned char *bptr = dbuffer;
- int count, c;
- int copystrings = 0;
- int getstrings = 0;
- int getlist = 0;
- int gmatched = 0;
- int start_offset = 0;
- int offsets[45];
- int size_offsets = sizeof(offsets)/sizeof(int);
-
- options = 0;
-
- if (infile == stdin) printf("data> ");
- if (fgets((char *)buffer, sizeof(buffer), infile) == NULL)
- {
- done = 1;
- goto CONTINUE;
- }
- if (infile != stdin) fprintf(outfile, "%s", (char *)buffer);
-
- len = (int)strlen((char *)buffer);
- while (len > 0 && isspace(buffer[len-1])) len--;
- buffer[len] = 0;
- if (len == 0) break;
-
- p = buffer;
- while (isspace(*p)) p++;
-
- q = dbuffer;
- while ((c = *p++) != 0)
- {
- int i = 0;
- int n = 0;
- if (c == '\\') switch ((c = *p++))
- {
- case 'a': c = 7; break;
- case 'b': c = '\b'; break;
- case 'e': c = 27; break;
- case 'f': c = '\f'; break;
- case 'n': c = '\n'; break;
- case 'r': c = '\r'; break;
- case 't': c = '\t'; break;
- case 'v': c = '\v'; break;
-
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- c -= '0';
- while (i++ < 2 && isdigit(*p) && *p != '8' && *p != '9')
- c = c * 8 + *p++ - '0';
- break;
-
- case 'x':
- c = 0;
- while (i++ < 2 && isxdigit(*p))
- {
- c = c * 16 + tolower(*p) - ((isdigit(*p))? '0' : 'W');
- p++;
- }
- break;
-
- case 0: /* Allows for an empty line */
- p--;
- continue;
-
- case 'A': /* Option setting */
- options |= PCRE_ANCHORED;
- continue;
-
- case 'B':
- options |= PCRE_NOTBOL;
- continue;
-
- case 'C':
- while(isdigit(*p)) n = n * 10 + *p++ - '0';
- copystrings |= 1 << n;
- continue;
-
- case 'G':
- while(isdigit(*p)) n = n * 10 + *p++ - '0';
- getstrings |= 1 << n;
- continue;
-
- case 'L':
- getlist = 1;
- continue;
-
- case 'N':
- options |= PCRE_NOTEMPTY;
- continue;
-
- case 'O':
- while(isdigit(*p)) n = n * 10 + *p++ - '0';
- if (n <= (int)(sizeof(offsets)/sizeof(int))) size_offsets = n;
- continue;
-
- case 'Z':
- options |= PCRE_NOTEOL;
- continue;
- }
- *q++ = c;
- }
- *q = 0;
- len = q - dbuffer;
-
- /* Handle matching via the POSIX interface, which does not
- support timing. */
-
-#if !defined NOPOSIX
- if (posix || do_posix)
- {
- int rc;
- int eflags = 0;
- regmatch_t pmatch[30];
- if ((options & PCRE_NOTBOL) != 0) eflags |= REG_NOTBOL;
- if ((options & PCRE_NOTEOL) != 0) eflags |= REG_NOTEOL;
-
- rc = regexec(&preg, (const char *)bptr,
- sizeof(pmatch)/sizeof(regmatch_t), pmatch, eflags);
-
- if (rc != 0)
- {
- (void)regerror(rc, &preg, (char *)buffer, sizeof(buffer));
- fprintf(outfile, "No match: POSIX code %d: %s\n", rc, buffer);
- }
- else
- {
- size_t i;
- for (i = 0; i < sizeof(pmatch)/sizeof(regmatch_t); i++)
- {
- if (pmatch[i].rm_so >= 0)
- {
- fprintf(outfile, "%2d: ", (int)i);
- pchars(dbuffer + pmatch[i].rm_so,
- pmatch[i].rm_eo - pmatch[i].rm_so);
- fprintf(outfile, "\n");
- if (i == 0 && do_showrest)
- {
- fprintf(outfile, " 0+ ");
- pchars(dbuffer + pmatch[i].rm_eo, len - pmatch[i].rm_eo);
- fprintf(outfile, "\n");
- }
- }
- }
- }
- }
-
- /* Handle matching via the native interface - repeats for /g and /G */
-
- else
-#endif /* !defined NOPOSIX */
-
- for (;; gmatched++) /* Loop for /g or /G */
- {
- if (timeit)
- {
- register int i;
- clock_t time_taken;
- clock_t start_time = clock();
- for (i = 0; i < LOOPREPEAT; i++)
- count = pcre_exec(re, extra, (char *)bptr, len,
- start_offset, options, offsets, size_offsets);
- time_taken = clock() - start_time;
- fprintf(outfile, "Execute time %.3f milliseconds\n",
- ((double)time_taken * 1000.0)/
- ((double)LOOPREPEAT * (double)CLOCKS_PER_SEC));
- }
-
- count = pcre_exec(re, extra, (char *)bptr, len,
- start_offset, options, offsets, size_offsets);
-
- if (count == 0)
- {
- fprintf(outfile, "Matched, but too many substrings\n");
- count = size_offsets/3;
- }
-
- /* Matched */
-
- if (count >= 0)
- {
- int i;
- for (i = 0; i < count * 2; i += 2)
- {
- if (offsets[i] < 0)
- fprintf(outfile, "%2d: <unset>\n", i/2);
- else
- {
- fprintf(outfile, "%2d: ", i/2);
- pchars(bptr + offsets[i], offsets[i+1] - offsets[i]);
- fprintf(outfile, "\n");
- if (i == 0)
- {
- if (do_showrest)
- {
- fprintf(outfile, " 0+ ");
- pchars(bptr + offsets[i+1], len - offsets[i+1]);
- fprintf(outfile, "\n");
- }
- }
- }
- }
-
- for (i = 0; i < 32; i++)
- {
- if ((copystrings & (1 << i)) != 0)
- {
- char copybuffer[16];
- int rc = pcre_copy_substring((char *)bptr, offsets, count,
- i, copybuffer, sizeof(copybuffer));
- if (rc < 0)
- fprintf(outfile, "copy substring %d failed %d\n", i, rc);
- else
- fprintf(outfile, "%2dC %s (%d)\n", i, copybuffer, rc);
- }
- }
-
- for (i = 0; i < 32; i++)
- {
- if ((getstrings & (1 << i)) != 0)
- {
- const char *substring;
- int rc = pcre_get_substring((char *)bptr, offsets, count,
- i, &substring);
- if (rc < 0)
- fprintf(outfile, "get substring %d failed %d\n", i, rc);
- else
- {
- fprintf(outfile, "%2dG %s (%d)\n", i, substring, rc);
- free((void *)substring);
- }
- }
- }
-
- if (getlist)
- {
- const char **stringlist;
- int rc = pcre_get_substring_list((char *)bptr, offsets, count,
- &stringlist);
- if (rc < 0)
- fprintf(outfile, "get substring list failed %d\n", rc);
- else
- {
- for (i = 0; i < count; i++)
- fprintf(outfile, "%2dL %s\n", i, stringlist[i]);
- if (stringlist[i] != NULL)
- fprintf(outfile, "string list not terminated by NULL\n");
- free((void *)stringlist);
- }
- }
- }
-
- /* Failed to match */
-
- else
- {
- if (gmatched == 0)
- {
- if (count == -1) fprintf(outfile, "No match\n");
- else fprintf(outfile, "Error %d\n", count);
- }
- break; /* Out of the /g loop */
- }
-
- /* If not /g or /G we are done */
-
- if (!do_g && !do_G) break;
-
- /* If we have matched an empty string, set PCRE_NOTEMPTY for the next
- match. This mimics what Perl's /g option does. */
-
- if (offsets[1] == offsets[0])
- options |= PCRE_NOTEMPTY;
- else
- options &= ~PCRE_NOTEMPTY;
-
- /* For /g, update the start offset, leaving the rest alone */
-
- if (do_g) start_offset = offsets[1];
-
- /* For /G, update the pointer and length */
-
- else
- {
- bptr += offsets[1];
- len -= offsets[1];
- }
- } /* End of loop for /g and /G */
- } /* End of loop for data lines */
-
- CONTINUE:
-
-#if !defined NOPOSIX
- if (posix || do_posix) regfree(&preg);
-#endif
-
- if (re != NULL) free(re);
- if (extra != NULL) free(extra);
- if (tables != NULL)
- {
- free((void *)tables);
- setlocale(LC_CTYPE, "C");
- }
- }
-
-fprintf(outfile, "\n");
-return 0;
-}
-
-/* End */
diff --git a/ext/pcre/pcrelib/perltest b/ext/pcre/pcrelib/perltest
deleted file mode 100755
index c6faedafaf..0000000000
--- a/ext/pcre/pcrelib/perltest
+++ /dev/null
@@ -1,143 +0,0 @@
-#! /usr/bin/perl
-
-# Program for testing regular expressions with perl to check that PCRE handles
-# them the same.
-
-
-# Function for turning a string into a string of printing chars
-
-sub pchars {
-my($t) = "";
-
-foreach $c (split(//, @_[0]))
- {
- if (ord $c >= 32 && ord $c < 127) { $t .= $c; }
- else { $t .= sprintf("\\x%02x", ord $c); }
- }
-$t;
-}
-
-
-
-# Read lines from named file or stdin and write to named file or stdout; lines
-# consist of a regular expression, in delimiters and optionally followed by
-# options, followed by a set of test data, terminated by an empty line.
-
-# Sort out the input and output files
-
-if (@ARGV > 0)
- {
- open(INFILE, "<$ARGV[0]") || die "Failed to open $ARGV[0]\n";
- $infile = "INFILE";
- }
-else { $infile = "STDIN"; }
-
-if (@ARGV > 1)
- {
- open(OUTFILE, ">$ARGV[1]") || die "Failed to open $ARGV[1]\n";
- $outfile = "OUTFILE";
- }
-else { $outfile = "STDOUT"; }
-
-printf($outfile "Perl $] Regular Expressions\n\n");
-
-# Main loop
-
-NEXT_RE:
-for (;;)
- {
- printf " re> " if $infile eq "STDIN";
- last if ! ($_ = <$infile>);
- printf $outfile "$_" if $infile ne "STDIN";
- next if ($_ eq "");
-
- $pattern = $_;
-
- $delimiter = substr($_, 0, 1);
- while ($pattern !~ /^\s*(.).*\1/s)
- {
- printf " > " if $infile eq "STDIN";
- last if ! ($_ = <$infile>);
- printf $outfile "$_" if $infile ne "STDIN";
- $pattern .= $_;
- }
-
- chomp($pattern);
- $pattern =~ s/\s+$//;
-
- # Check that the pattern is valid
-
- eval "\$_ =~ ${pattern}";
- if ($@)
- {
- printf $outfile "Error: $@";
- next NEXT_RE;
- }
-
- # Read data lines and test them
-
- for (;;)
- {
- printf "data> " if $infile eq "STDIN";
- last NEXT_RE if ! ($_ = <$infile>);
- chomp;
- printf $outfile "$_\n" if $infile ne "STDIN";
-
- s/\s+$//;
- s/^\s+//;
-
- last if ($_ eq "");
-
- $_ = eval "\"$_\""; # To get escapes processed
-
- $ok = 0;
- eval "if (\$_ =~ ${pattern}) {" .
- "\$z = \$&;" .
- "\$a = \$1;" .
- "\$b = \$2;" .
- "\$c = \$3;" .
- "\$d = \$4;" .
- "\$e = \$5;" .
- "\$f = \$6;" .
- "\$g = \$7;" .
- "\$h = \$8;" .
- "\$i = \$9;" .
- "\$j = \$10;" .
- "\$k = \$11;" .
- "\$l = \$12;" .
- "\$m = \$13;" .
- "\$n = \$14;" .
- "\$o = \$15;" .
- "\$p = \$16;" .
- "\$ok = 1; }";
-
- if ($@)
- {
- printf $outfile "Error: $@\n";
- next NEXT_RE;
- }
- elsif (!$ok)
- {
- printf $outfile "No match\n";
- }
- else
- {
- @subs = ($z,$a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k,$l,$m,$n,$o,$p);
- $last_printed = 0;
- for ($i = 0; $i <= 17; $i++)
- {
- if ($i == 0 || defined $subs[$i])
- {
- while ($last_printed++ < $i-1)
- { printf $outfile ("%2d: <unset>\n", $last_printed); }
- printf $outfile ("%2d: %s\n", $i, &pchars($subs[$i]));
- $last_printed = $i;
- }
- }
- }
- }
- }
-
-printf $outfile "\n";
-
-# End
diff --git a/ext/pcre/pcrelib/pgrep.1 b/ext/pcre/pcrelib/pgrep.1
deleted file mode 100644
index d9e9b575e0..0000000000
--- a/ext/pcre/pcrelib/pgrep.1
+++ /dev/null
@@ -1,76 +0,0 @@
-.TH PGREP 1
-.SH NAME
-pgrep - a grep with Perl-compatible regular expressions.
-.SH SYNOPSIS
-.B pgrep [-Vchilnsvx] pattern [file] ...
-
-
-.SH DESCRIPTION
-\fBpgrep\fR searches files for character patterns, in the same way as other
-grep commands do, but it uses the PCRE regular expression library to support
-patterns that are compatible with the regular expressions of Perl 5. See
-\fBpcre(3)\fR for a full description of syntax and semantics.
-
-If no files are specified, \fBpgrep\fR reads the standard input. By default,
-each line that matches the pattern is copied to the standard output, and if
-there is more than one file, the file name is printed before each line of
-output. However, there are options that can change how \fBpgrep\fR behaves.
-
-Lines are limited to BUFSIZ characters. BUFSIZ is defined in \fB<stdio.h>\fR.
-The newline character is removed from the end of each line before it is matched
-against the pattern.
-
-
-.SH OPTIONS
-.TP 10
-\fB-V\fR
-Write the version number of the PCRE library being used to the standard error
-stream.
-.TP
-\fB-c\fR
-Do not print individual lines; instead just print a count of the number of
-lines that would otherwise have been printed. If several files are given, a
-count is printed for each of them.
-.TP
-\fB-h\fR
-Suppress printing of filenames when searching multiple files.
-.TP
-\fB-i\fR
-Ignore upper/lower case distinctions during comparisons.
-.TP
-\fB-l\fR
-Instead of printing lines from the files, just print the names of the files
-containing lines that would have been printed. Each file name is printed
-once, on a separate line.
-.TP
-\fB-n\fR
-Precede each line by its line number in the file.
-.TP
-\fB-s\fR
-Work silently, that is, display nothing except error messages.
-The exit status indicates whether any matches were found.
-.TP
-\fB-v\fR
-Invert the sense of the match, so that lines which do \fInot\fR match the
-pattern are now the ones that are found.
-.TP
-\fB-x\fR
-Force the pattern to be anchored (it must start matching at the beginning of
-the line) and in addition, require it to match the entire line. This is
-equivalent to having ^ and $ characters at the start and end of each
-alternative branch in the regular expression.
-
-
-.SH SEE ALSO
-\fBpcre(3)\fR, Perl 5 documentation
-
-
-.SH DIAGNOSTICS
-Exit status is 0 if any matches were found, 1 if no matches were found, and 2
-for syntax errors or inacessible files (even if matches were found).
-
-
-.SH AUTHOR
-Philip Hazel <ph10@cam.ac.uk>
-.br
-Copyright (c) 1997-1999 University of Cambridge.
diff --git a/ext/pcre/pcrelib/pgrep.1.html b/ext/pcre/pcrelib/pgrep.1.html
deleted file mode 100644
index 54efed6785..0000000000
--- a/ext/pcre/pcrelib/pgrep.1.html
+++ /dev/null
@@ -1,105 +0,0 @@
-<HTML>
-<HEAD>
-<TITLE>pgrep specification</TITLE>
-</HEAD>
-<body bgcolor="#FFFFFF" text="#00005A">
-<H1>pgrep specification</H1>
-This HTML document has been generated automatically from the original man page.
-If there is any nonsense in it, please consult the man page in case the
-conversion went wrong.
-<UL>
-<LI><A NAME="TOC1" HREF="#SEC1">NAME</A>
-<LI><A NAME="TOC2" HREF="#SEC2">SYNOPSIS</A>
-<LI><A NAME="TOC3" HREF="#SEC3">DESCRIPTION</A>
-<LI><A NAME="TOC4" HREF="#SEC4">OPTIONS</A>
-<LI><A NAME="TOC5" HREF="#SEC5">SEE ALSO</A>
-<LI><A NAME="TOC6" HREF="#SEC6">DIAGNOSTICS</A>
-<LI><A NAME="TOC7" HREF="#SEC7">AUTHOR</A>
-</UL>
-<LI><A NAME="SEC1" HREF="#TOC1">NAME</A>
-<P>
-pgrep - a grep with Perl-compatible regular expressions.
-</P>
-<LI><A NAME="SEC2" HREF="#TOC1">SYNOPSIS</A>
-<P>
-<B>pgrep [-Vchilnsvx] pattern [file] ...</B>
-</P>
-<LI><A NAME="SEC3" HREF="#TOC1">DESCRIPTION</A>
-<P>
-<B>pgrep</B> searches files for character patterns, in the same way as other
-grep commands do, but it uses the PCRE regular expression library to support
-patterns that are compatible with the regular expressions of Perl 5. See
-<B>pcre(3)</B> for a full description of syntax and semantics.
-</P>
-<P>
-If no files are specified, <B>pgrep</B> reads the standard input. By default,
-each line that matches the pattern is copied to the standard output, and if
-there is more than one file, the file name is printed before each line of
-output. However, there are options that can change how <B>pgrep</B> behaves.
-</P>
-<P>
-Lines are limited to BUFSIZ characters. BUFSIZ is defined in <B>&#60;stdio.h&#62;</B>.
-The newline character is removed from the end of each line before it is matched
-against the pattern.
-</P>
-<LI><A NAME="SEC4" HREF="#TOC1">OPTIONS</A>
-<P>
-<B>-V</B>
-Write the version number of the PCRE library being used to the standard error
-stream.
-</P>
-<P>
-<B>-c</B>
-Do not print individual lines; instead just print a count of the number of
-lines that would otherwise have been printed. If several files are given, a
-count is printed for each of them.
-</P>
-<P>
-<B>-h</B>
-Suppress printing of filenames when searching multiple files.
-</P>
-<P>
-<B>-i</B>
-Ignore upper/lower case distinctions during comparisons.
-</P>
-<P>
-<B>-l</B>
-Instead of printing lines from the files, just print the names of the files
-containing lines that would have been printed. Each file name is printed
-once, on a separate line.
-</P>
-<P>
-<B>-n</B>
-Precede each line by its line number in the file.
-</P>
-<P>
-<B>-s</B>
-Work silently, that is, display nothing except error messages.
-The exit status indicates whether any matches were found.
-</P>
-<P>
-<B>-v</B>
-Invert the sense of the match, so that lines which do <I>not</I> match the
-pattern are now the ones that are found.
-</P>
-<P>
-<B>-x</B>
-Force the pattern to be anchored (it must start matching at the beginning of
-the line) and in addition, require it to match the entire line. This is
-equivalent to having ^ and $ characters at the start and end of each
-alternative branch in the regular expression.
-</P>
-<LI><A NAME="SEC5" HREF="#TOC1">SEE ALSO</A>
-<P>
-<B>pcre(3)</B>, Perl 5 documentation
-</P>
-<LI><A NAME="SEC6" HREF="#TOC1">DIAGNOSTICS</A>
-<P>
-Exit status is 0 if any matches were found, 1 if no matches were found, and 2
-for syntax errors or inacessible files (even if matches were found).
-</P>
-<LI><A NAME="SEC7" HREF="#TOC1">AUTHOR</A>
-<P>
-Philip Hazel &#60;ph10@cam.ac.uk&#62;
-<BR>
-Copyright (c) 1997-1999 University of Cambridge.
diff --git a/ext/pcre/pcrelib/pgrep.1.txt b/ext/pcre/pcrelib/pgrep.1.txt
deleted file mode 100644
index bcd08c0aab..0000000000
--- a/ext/pcre/pcrelib/pgrep.1.txt
+++ /dev/null
@@ -1,86 +0,0 @@
-NAME
- pgrep - a grep with Perl-compatible regular expressions.
-
-
-
-SYNOPSIS
- pgrep [-Vchilnsvx] pattern [file] ...
-
-
-
-DESCRIPTION
- pgrep searches files for character patterns, in the same way
- as other grep commands do, but it uses the PCRE regular
- expression library to support patterns that are compatible
- with the regular expressions of Perl 5. See pcre(3) for a
- full description of syntax and semantics.
-
- If no files are specified, pgrep reads the standard input.
- By default, each line that matches the pattern is copied to
- the standard output, and if there is more than one file, the
- file name is printed before each line of output. However,
- there are options that can change how pgrep behaves.
-
- Lines are limited to BUFSIZ characters. BUFSIZ is defined in
- <stdio.h>. The newline character is removed from the end of
- each line before it is matched against the pattern.
-
-
-
-OPTIONS
- -V Write the version number of the PCRE library being
- used to the standard error stream.
-
- -c Do not print individual lines; instead just print
- a count of the number of lines that would other-
- wise have been printed. If several files are
- given, a count is printed for each of them.
-
- -h Suppress printing of filenames when searching mul-
- tiple files.
-
- -i Ignore upper/lower case distinctions during com-
- parisons.
-
- -l Instead of printing lines from the files, just
- print the names of the files containing lines that
- would have been printed. Each file name is printed
- once, on a separate line.
-
- -n Precede each line by its line number in the file.
-
- -s Work silently, that is, display nothing except
- error messages. The exit status indicates whether
- any matches were found.
-
- -v Invert the sense of the match, so that lines which
- do not match the pattern are now the ones that are
- found.
-
- -x Force the pattern to be anchored (it must start
- matching at the beginning of the line) and in
- addition, require it to match the entire line.
- This is equivalent to having ^ and $ characters at
- the start and end of each alternative branch in
- the regular expression.
-
-
-
-SEE ALSO
- pcre(3), Perl 5 documentation
-
-
-
-
-
-DIAGNOSTICS
- Exit status is 0 if any matches were found, 1 if no matches
- were found, and 2 for syntax errors or inacessible files
- (even if matches were found).
-
-
-
-AUTHOR
- Philip Hazel <ph10@cam.ac.uk>
- Copyright (c) 1997-1999 University of Cambridge.
-
diff --git a/ext/pcre/pcrelib/pgrep.c b/ext/pcre/pcrelib/pgrep.c
deleted file mode 100644
index 5bc48ee84a..0000000000
--- a/ext/pcre/pcrelib/pgrep.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/*************************************************
-* PCRE grep program *
-*************************************************/
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include "pcre.h"
-
-
-#define FALSE 0
-#define TRUE 1
-
-typedef int BOOL;
-
-
-
-/*************************************************
-* Global variables *
-*************************************************/
-
-static pcre *pattern;
-static pcre_extra *hints;
-
-static BOOL count_only = FALSE;
-static BOOL filenames_only = FALSE;
-static BOOL invert = FALSE;
-static BOOL number = FALSE;
-static BOOL silent = FALSE;
-static BOOL whole_lines = FALSE;
-
-
-
-#ifdef STRERROR_FROM_ERRLIST
-/*************************************************
-* Provide strerror() for non-ANSI libraries *
-*************************************************/
-
-/* Some old-fashioned systems still around (e.g. SunOS4) don't have strerror()
-in their libraries, but can provide the same facility by this simple
-alternative function. */
-
-extern int sys_nerr;
-extern char *sys_errlist[];
-
-char *
-strerror(int n)
-{
-if (n < 0 || n >= sys_nerr) return "unknown error number";
-return sys_errlist[n];
-}
-#endif /* STRERROR_FROM_ERRLIST */
-
-
-
-/*************************************************
-* Grep an individual file *
-*************************************************/
-
-static int
-pgrep(FILE *in, char *name)
-{
-int rc = 1;
-int linenumber = 0;
-int count = 0;
-int offsets[99];
-char buffer[BUFSIZ];
-
-while (fgets(buffer, sizeof(buffer), in) != NULL)
- {
- BOOL match;
- int length = (int)strlen(buffer);
- if (length > 0 && buffer[length-1] == '\n') buffer[--length] = 0;
- linenumber++;
-
- match = pcre_exec(pattern, hints, buffer, length, 0, 0, offsets, 99) >= 0;
- if (match && whole_lines && offsets[1] != length) match = FALSE;
-
- if (match != invert)
- {
- if (count_only) count++;
-
- else if (filenames_only)
- {
- fprintf(stdout, "%s\n", (name == NULL)? "<stdin>" : name);
- return 0;
- }
-
- else if (silent) return 0;
-
- else
- {
- if (name != NULL) fprintf(stdout, "%s:", name);
- if (number) fprintf(stdout, "%d:", linenumber);
- fprintf(stdout, "%s\n", buffer);
- }
-
- rc = 0;
- }
- }
-
-if (count_only)
- {
- if (name != NULL) fprintf(stdout, "%s:", name);
- fprintf(stdout, "%d\n", count);
- }
-
-return rc;
-}
-
-
-
-
-/*************************************************
-* Usage function *
-*************************************************/
-
-static int
-usage(int rc)
-{
-fprintf(stderr, "Usage: pgrep [-Vchilnsvx] pattern [file] ...\n");
-return rc;
-}
-
-
-
-
-/*************************************************
-* Main program *
-*************************************************/
-
-int
-main(int argc, char **argv)
-{
-int i;
-int rc = 1;
-int options = 0;
-int errptr;
-const char *error;
-BOOL filenames = TRUE;
-
-/* Process the options */
-
-for (i = 1; i < argc; i++)
- {
- char *s;
- if (argv[i][0] != '-') break;
- s = argv[i] + 1;
- while (*s != 0)
- {
- switch (*s++)
- {
- case 'c': count_only = TRUE; break;
- case 'h': filenames = FALSE; break;
- case 'i': options |= PCRE_CASELESS; break;
- case 'l': filenames_only = TRUE;
- case 'n': number = TRUE; break;
- case 's': silent = TRUE; break;
- case 'v': invert = TRUE; break;
- case 'x': whole_lines = TRUE; options |= PCRE_ANCHORED; break;
-
- case 'V':
- fprintf(stderr, "PCRE version %s\n", pcre_version());
- break;
-
- default:
- fprintf(stderr, "pgrep: unknown option %c\n", s[-1]);
- return usage(2);
- }
- }
- }
-
-/* There must be at least a regexp argument */
-
-if (i >= argc) return usage(0);
-
-/* Compile the regular expression. */
-
-pattern = pcre_compile(argv[i++], options, &error, &errptr, NULL);
-if (pattern == NULL)
- {
- fprintf(stderr, "pgrep: error in regex at offset %d: %s\n", errptr, error);
- return 2;
- }
-
-/* Study the regular expression, as we will be running it may times */
-
-hints = pcre_study(pattern, 0, &error);
-if (error != NULL)
- {
- fprintf(stderr, "pgrep: error while studing regex: %s\n", error);
- return 2;
- }
-
-/* If there are no further arguments, do the business on stdin and exit */
-
-if (i >= argc) return pgrep(stdin, NULL);
-
-/* Otherwise, work through the remaining arguments as files. If there is only
-one, don't give its name on the output. */
-
-if (i == argc - 1) filenames = FALSE;
-if (filenames_only) filenames = TRUE;
-
-for (; i < argc; i++)
- {
- FILE *in = fopen(argv[i], "r");
- if (in == NULL)
- {
- fprintf(stderr, "%s: failed to open: %s\n", argv[i], strerror(errno));
- rc = 2;
- }
- else
- {
- int frc = pgrep(in, filenames? argv[i] : NULL);
- if (frc == 0 && rc == 1) rc = 0;
- fclose(in);
- }
- }
-
-return rc;
-}
-
-/* End */
diff --git a/ext/pcre/pcrelib/study.c b/ext/pcre/pcrelib/study.c
deleted file mode 100644
index 284833ba04..0000000000
--- a/ext/pcre/pcrelib/study.c
+++ /dev/null
@@ -1,397 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/*
-This is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language. See
-the file Tech.Notes for some information on the internals.
-
-Written by: Philip Hazel <ph10@cam.ac.uk>
-
- Copyright (c) 1997-1999 University of Cambridge
-
------------------------------------------------------------------------------
-Permission is granted to anyone to use this software for any purpose on any
-computer system, and to redistribute it freely, subject to the following
-restrictions:
-
-1. This software 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.
-
-2. The origin of this software must not be misrepresented, either by
- explicit claim or by omission.
-
-3. Altered versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
-
-4. If PCRE is embedded in any software that is released under the GNU
- General Purpose Licence (GPL), then the terms of that licence shall
- supersede any condition above with which it is incompatible.
------------------------------------------------------------------------------
-*/
-
-
-/* Include the internals header, which itself includes Standard C headers plus
-the external pcre header. */
-
-#include "internal.h"
-
-
-
-/*************************************************
-* Set a bit and maybe its alternate case *
-*************************************************/
-
-/* Given a character, set its bit in the table, and also the bit for the other
-version of a letter if we are caseless.
-
-Arguments:
- start_bits points to the bit map
- c is the character
- caseless the caseless flag
- cd the block with char table pointers
-
-Returns: nothing
-*/
-
-static void
-set_bit(uschar *start_bits, int c, BOOL caseless, compile_data *cd)
-{
-start_bits[c/8] |= (1 << (c&7));
-if (caseless && (cd->ctypes[c] & ctype_letter) != 0)
- start_bits[cd->fcc[c]/8] |= (1 << (cd->fcc[c]&7));
-}
-
-
-
-/*************************************************
-* Create bitmap of starting chars *
-*************************************************/
-
-/* This function scans a compiled unanchored expression and attempts to build a
-bitmap of the set of initial characters. If it can't, it returns FALSE. As time
-goes by, we may be able to get more clever at doing this.
-
-Arguments:
- code points to an expression
- start_bits points to a 32-byte table, initialized to 0
- caseless the current state of the caseless flag
- cd the block with char table pointers
-
-Returns: TRUE if table built, FALSE otherwise
-*/
-
-static BOOL
-set_start_bits(const uschar *code, uschar *start_bits, BOOL caseless,
- compile_data *cd)
-{
-register int c;
-
-/* This next statement and the later reference to dummy are here in order to
-trick the optimizer of the IBM C compiler for OS/2 into generating correct
-code. Apparently IBM isn't going to fix the problem, and we would rather not
-disable optimization (in this module it actually makes a big difference, and
-the pcre module can use all the optimization it can get). */
-
-volatile int dummy;
-
-do
- {
- const uschar *tcode = code + 3;
- BOOL try_next = TRUE;
-
- while (try_next)
- {
- try_next = FALSE;
-
- /* If a branch starts with a bracket or a positive lookahead assertion,
- recurse to set bits from within them. That's all for this branch. */
-
- if ((int)*tcode >= OP_BRA || *tcode == OP_ASSERT)
- {
- if (!set_start_bits(tcode, start_bits, caseless, cd))
- return FALSE;
- }
-
- else switch(*tcode)
- {
- default:
- return FALSE;
-
- /* Skip over lookbehind and negative lookahead assertions */
-
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- try_next = TRUE;
- do tcode += (tcode[1] << 8) + tcode[2]; while (*tcode == OP_ALT);
- tcode += 3;
- break;
-
- /* Skip over an option setting, changing the caseless flag */
-
- case OP_OPT:
- caseless = (tcode[1] & PCRE_CASELESS) != 0;
- tcode += 2;
- try_next = TRUE;
- break;
-
- /* BRAZERO does the bracket, but carries on. */
-
- case OP_BRAZERO:
- case OP_BRAMINZERO:
- if (!set_start_bits(++tcode, start_bits, caseless, cd))
- return FALSE;
- dummy = 1;
- do tcode += (tcode[1] << 8) + tcode[2]; while (*tcode == OP_ALT);
- tcode += 3;
- try_next = TRUE;
- break;
-
- /* Single-char * or ? sets the bit and tries the next item */
-
- case OP_STAR:
- case OP_MINSTAR:
- case OP_QUERY:
- case OP_MINQUERY:
- set_bit(start_bits, tcode[1], caseless, cd);
- tcode += 2;
- try_next = TRUE;
- break;
-
- /* Single-char upto sets the bit and tries the next */
-
- case OP_UPTO:
- case OP_MINUPTO:
- set_bit(start_bits, tcode[3], caseless, cd);
- tcode += 4;
- try_next = TRUE;
- break;
-
- /* At least one single char sets the bit and stops */
-
- case OP_EXACT: /* Fall through */
- tcode++;
-
- case OP_CHARS: /* Fall through */
- tcode++;
-
- case OP_PLUS:
- case OP_MINPLUS:
- set_bit(start_bits, tcode[1], caseless, cd);
- break;
-
- /* Single character type sets the bits and stops */
-
- case OP_NOT_DIGIT:
- for (c = 0; c < 32; c++)
- start_bits[c] |= ~cd->cbits[c+cbit_digit];
- break;
-
- case OP_DIGIT:
- for (c = 0; c < 32; c++)
- start_bits[c] |= cd->cbits[c+cbit_digit];
- break;
-
- case OP_NOT_WHITESPACE:
- for (c = 0; c < 32; c++)
- start_bits[c] |= ~cd->cbits[c+cbit_space];
- break;
-
- case OP_WHITESPACE:
- for (c = 0; c < 32; c++)
- start_bits[c] |= cd->cbits[c+cbit_space];
- break;
-
- case OP_NOT_WORDCHAR:
- for (c = 0; c < 32; c++)
- start_bits[c] |= ~(cd->cbits[c] | cd->cbits[c+cbit_word]);
- break;
-
- case OP_WORDCHAR:
- for (c = 0; c < 32; c++)
- start_bits[c] |= (cd->cbits[c] | cd->cbits[c+cbit_word]);
- break;
-
- /* One or more character type fudges the pointer and restarts, knowing
- it will hit a single character type and stop there. */
-
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- tcode++;
- try_next = TRUE;
- break;
-
- case OP_TYPEEXACT:
- tcode += 3;
- try_next = TRUE;
- break;
-
- /* Zero or more repeats of character types set the bits and then
- try again. */
-
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- tcode += 2; /* Fall through */
-
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- switch(tcode[1])
- {
- case OP_NOT_DIGIT:
- for (c = 0; c < 32; c++)
- start_bits[c] |= ~cd->cbits[c+cbit_digit];
- break;
-
- case OP_DIGIT:
- for (c = 0; c < 32; c++)
- start_bits[c] |= cd->cbits[c+cbit_digit];
- break;
-
- case OP_NOT_WHITESPACE:
- for (c = 0; c < 32; c++)
- start_bits[c] |= ~cd->cbits[c+cbit_space];
- break;
-
- case OP_WHITESPACE:
- for (c = 0; c < 32; c++)
- start_bits[c] |= cd->cbits[c+cbit_space];
- break;
-
- case OP_NOT_WORDCHAR:
- for (c = 0; c < 32; c++)
- start_bits[c] |= ~(cd->cbits[c] | cd->cbits[c+cbit_word]);
- break;
-
- case OP_WORDCHAR:
- for (c = 0; c < 32; c++)
- start_bits[c] |= (cd->cbits[c] | cd->cbits[c+cbit_word]);
- break;
- }
-
- tcode += 2;
- try_next = TRUE;
- break;
-
- /* Character class: set the bits and either carry on or not,
- according to the repeat count. */
-
- case OP_CLASS:
- {
- tcode++;
- for (c = 0; c < 32; c++) start_bits[c] |= tcode[c];
- tcode += 32;
- switch (*tcode)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- tcode++;
- try_next = TRUE;
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- if (((tcode[1] << 8) + tcode[2]) == 0)
- {
- tcode += 5;
- try_next = TRUE;
- }
- break;
- }
- }
- break; /* End of class handling */
-
- } /* End of switch */
- } /* End of try_next loop */
-
- code += (code[1] << 8) + code[2]; /* Advance to next branch */
- }
-while (*code == OP_ALT);
-return TRUE;
-}
-
-
-
-/*************************************************
-* Study a compiled expression *
-*************************************************/
-
-/* This function is handed a compiled expression that it must study to produce
-information that will speed up the matching. It returns a pcre_extra block
-which then gets handed back to pcre_exec().
-
-Arguments:
- re points to the compiled expression
- options contains option bits
- errorptr points to where to place error messages;
- set NULL unless error
-
-Returns: pointer to a pcre_extra block,
- NULL on error or if no optimization possible
-*/
-
-pcre_extra *
-pcre_study(const pcre *external_re, int options, const char **errorptr)
-{
-uschar start_bits[32];
-real_pcre_extra *extra;
-const real_pcre *re = (const real_pcre *)external_re;
-compile_data compile_block;
-
-*errorptr = NULL;
-
-if (re == NULL || re->magic_number != MAGIC_NUMBER)
- {
- *errorptr = "argument is not a compiled regular expression";
- return NULL;
- }
-
-if ((options & ~PUBLIC_STUDY_OPTIONS) != 0)
- {
- *errorptr = "unknown or incorrect option bit(s) set";
- return NULL;
- }
-
-/* For an anchored pattern, or an unchored pattern that has a first char, or a
-multiline pattern that matches only at "line starts", no further processing at
-present. */
-
-if ((re->options & (PCRE_ANCHORED|PCRE_FIRSTSET|PCRE_STARTLINE)) != 0)
- return NULL;
-
-/* Set the character tables in the block which is passed around */
-
-compile_block.lcc = re->tables + lcc_offset;
-compile_block.fcc = re->tables + fcc_offset;
-compile_block.cbits = re->tables + cbits_offset;
-compile_block.ctypes = re->tables + ctypes_offset;
-
-/* See if we can find a fixed set of initial characters for the pattern. */
-
-memset(start_bits, 0, 32 * sizeof(uschar));
-if (!set_start_bits(re->code, start_bits, (re->options & PCRE_CASELESS) != 0,
- &compile_block)) return NULL;
-
-/* Get an "extra" block and put the information therein. */
-
-extra = (real_pcre_extra *)(pcre_malloc)(sizeof(real_pcre_extra));
-
-if (extra == NULL)
- {
- *errorptr = "failed to get memory";
- return NULL;
- }
-
-extra->options = PCRE_STUDY_MAPPED;
-memcpy(extra->start_bits, start_bits, sizeof(start_bits));
-
-return (pcre_extra *)extra;
-}
-
-/* End of study.c */
diff --git a/ext/pcre/pcrelib/testinput1 b/ext/pcre/pcrelib/testinput1
deleted file mode 100644
index 3adb635289..0000000000
--- a/ext/pcre/pcrelib/testinput1
+++ /dev/null
@@ -1,1890 +0,0 @@
-/the quick brown fox/
- the quick brown fox
- The quick brown FOX
- What do you know about the quick brown fox?
- What do you know about THE QUICK BROWN FOX?
-
-/The quick brown fox/i
- the quick brown fox
- The quick brown FOX
- What do you know about the quick brown fox?
- What do you know about THE QUICK BROWN FOX?
-
-/abcd\t\n\r\f\a\e\071\x3b\$\\\?caxyz/
- abcd\t\n\r\f\a\e9;\$\\?caxyz
-
-/a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/
- abxyzpqrrrabbxyyyypqAzz
- abxyzpqrrrabbxyyyypqAzz
- aabxyzpqrrrabbxyyyypqAzz
- aaabxyzpqrrrabbxyyyypqAzz
- aaaabxyzpqrrrabbxyyyypqAzz
- abcxyzpqrrrabbxyyyypqAzz
- aabcxyzpqrrrabbxyyyypqAzz
- aaabcxyzpqrrrabbxyyyypAzz
- aaabcxyzpqrrrabbxyyyypqAzz
- aaabcxyzpqrrrabbxyyyypqqAzz
- aaabcxyzpqrrrabbxyyyypqqqAzz
- aaabcxyzpqrrrabbxyyyypqqqqAzz
- aaabcxyzpqrrrabbxyyyypqqqqqAzz
- aaabcxyzpqrrrabbxyyyypqqqqqqAzz
- aaaabcxyzpqrrrabbxyyyypqAzz
- abxyzzpqrrrabbxyyyypqAzz
- aabxyzzzpqrrrabbxyyyypqAzz
- aaabxyzzzzpqrrrabbxyyyypqAzz
- aaaabxyzzzzpqrrrabbxyyyypqAzz
- abcxyzzpqrrrabbxyyyypqAzz
- aabcxyzzzpqrrrabbxyyyypqAzz
- aaabcxyzzzzpqrrrabbxyyyypqAzz
- aaaabcxyzzzzpqrrrabbxyyyypqAzz
- aaaabcxyzzzzpqrrrabbbxyyyypqAzz
- aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
- aaabcxyzpqrrrabbxyyyypABzz
- aaabcxyzpqrrrabbxyyyypABBzz
- >>>aaabxyzpqrrrabbxyyyypqAzz
- >aaaabxyzpqrrrabbxyyyypqAzz
- >>>>abcxyzpqrrrabbxyyyypqAzz
- *** Failers
- abxyzpqrrabbxyyyypqAzz
- abxyzpqrrrrabbxyyyypqAzz
- abxyzpqrrrabxyyyypqAzz
- aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz
- aaaabcxyzzzzpqrrrabbbxyyypqAzz
- aaabcxyzpqrrrabbxyyyypqqqqqqqAzz
-
-/^(abc){1,2}zz/
- abczz
- abcabczz
- *** Failers
- zz
- abcabcabczz
- >>abczz
-
-/^(b+?|a){1,2}?c/
- bc
- bbc
- bbbc
- bac
- bbac
- aac
- abbbbbbbbbbbc
- bbbbbbbbbbbac
- *** Failers
- aaac
- abbbbbbbbbbbac
-
-/^(b+|a){1,2}c/
- bc
- bbc
- bbbc
- bac
- bbac
- aac
- abbbbbbbbbbbc
- bbbbbbbbbbbac
- *** Failers
- aaac
- abbbbbbbbbbbac
-
-/^(b+|a){1,2}?bc/
- bbc
-
-/^(b*|ba){1,2}?bc/
- babc
- bbabc
- bababc
- *** Failers
- bababbc
- babababc
-
-/^(ba|b*){1,2}?bc/
- babc
- bbabc
- bababc
- *** Failers
- bababbc
- babababc
-
-/^\ca\cA\c[\c{\c:/
- \x01\x01\e;z
-
-/^[ab\]cde]/
- athing
- bthing
- ]thing
- cthing
- dthing
- ething
- *** Failers
- fthing
- [thing
- \\thing
-
-/^[]cde]/
- ]thing
- cthing
- dthing
- ething
- *** Failers
- athing
- fthing
-
-/^[^ab\]cde]/
- fthing
- [thing
- \\thing
- *** Failers
- athing
- bthing
- ]thing
- cthing
- dthing
- ething
-
-/^[^]cde]/
- athing
- fthing
- *** Failers
- ]thing
- cthing
- dthing
- ething
-
-/^\/
-
-
-/^ÿ/
- ÿ
-
-/^[0-9]+$/
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 100
- *** Failers
- abc
-
-/^.*nter/
- enter
- inter
- uponter
-
-/^xxx[0-9]+$/
- xxx0
- xxx1234
- *** Failers
- xxx
-
-/^.+[0-9][0-9][0-9]$/
- x123
- xx123
- 123456
- *** Failers
- 123
- x1234
-
-/^.+?[0-9][0-9][0-9]$/
- x123
- xx123
- 123456
- *** Failers
- 123
- x1234
-
-/^([^!]+)!(.+)=apquxz\.ixr\.zzz\.ac\.uk$/
- abc!pqr=apquxz.ixr.zzz.ac.uk
- *** Failers
- !pqr=apquxz.ixr.zzz.ac.uk
- abc!=apquxz.ixr.zzz.ac.uk
- abc!pqr=apquxz:ixr.zzz.ac.uk
- abc!pqr=apquxz.ixr.zzz.ac.ukk
-
-/:/
- Well, we need a colon: somewhere
- *** Fail if we don't
-
-/([\da-f:]+)$/i
- 0abc
- abc
- fed
- E
- ::
- 5f03:12C0::932e
- fed def
- Any old stuff
- *** Failers
- 0zzz
- gzzz
- fed\x20
- Any old rubbish
-
-/^.*\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/
- .1.2.3
- A.12.123.0
- *** Failers
- .1.2.3333
- 1.2.3
- 1234.2.3
-
-/^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
- 1 IN SOA non-sp1 non-sp2(
- 1 IN SOA non-sp1 non-sp2 (
- *** Failers
- 1IN SOA non-sp1 non-sp2(
-
-/^[a-zA-Z\d][a-zA-Z\d\-]*(\.[a-zA-Z\d][a-zA-z\d\-]*)*\.$/
- a.
- Z.
- 2.
- ab-c.pq-r.
- sxk.zzz.ac.uk.
- x-.y-.
- *** Failers
- -abc.peq.
-
-/^\*\.[a-z]([a-z\-\d]*[a-z\d]+)?(\.[a-z]([a-z\-\d]*[a-z\d]+)?)*$/
- *.a
- *.b0-a
- *.c3-b.c
- *.c-a.b-c
- *** Failers
- *.0
- *.a-
- *.a-b.c-
- *.c-a.0-c
-
-/^(?=ab(de))(abd)(e)/
- abde
-
-/^(?!(ab)de|x)(abd)(f)/
- abdf
-
-/^(?=(ab(cd)))(ab)/
- abcd
-
-/^[\da-f](\.[\da-f])*$/i
- a.b.c.d
- A.B.C.D
- a.b.c.1.2.3.C
-
-/^\".*\"\s*(;.*)?$/
- \"1234\"
- \"abcd\" ;
- \"\" ; rhubarb
- *** Failers
- \"1234\" : things
-
-/^$/
- \
- *** Failers
-
-/ ^ a (?# begins with a) b\sc (?# then b c) $ (?# then end)/x
- ab c
- *** Failers
- abc
- ab cde
-
-/(?x) ^ a (?# begins with a) b\sc (?# then b c) $ (?# then end)/
- ab c
- *** Failers
- abc
- ab cde
-
-/^ a\ b[c ]d $/x
- a bcd
- a b d
- *** Failers
- abcd
- ab d
-
-/^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$/
- abcdefhijklm
-
-/^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$/
- abcdefhijklm
-
-/^[\w][\W][\s][\S][\d][\D][\b][\n][\c]][\022]/
- a+ Z0+\x08\n\x1d\x12
-
-/^[.^$|()*+?{,}]+/
- .^\$(*+)|{?,?}
-
-/^a*\w/
- z
- az
- aaaz
- a
- aa
- aaaa
- a+
- aa+
-
-/^a*?\w/
- z
- az
- aaaz
- a
- aa
- aaaa
- a+
- aa+
-
-/^a+\w/
- az
- aaaz
- aa
- aaaa
- aa+
-
-/^a+?\w/
- az
- aaaz
- aa
- aaaa
- aa+
-
-/^\d{8}\w{2,}/
- 1234567890
- 12345678ab
- 12345678__
- *** Failers
- 1234567
-
-/^[aeiou\d]{4,5}$/
- uoie
- 1234
- 12345
- aaaaa
- *** Failers
- 123456
-
-/^[aeiou\d]{4,5}?/
- uoie
- 1234
- 12345
- aaaaa
- 123456
-
-/\A(abc|def)=(\1){2,3}\Z/
- abc=abcabc
- def=defdefdef
- *** Failers
- abc=defdef
-
-/^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\11*(\3\4)\1(?#)2$/
- abcdefghijkcda2
- abcdefghijkkkkcda2
-
-/(cat(a(ract|tonic)|erpillar)) \1()2(3)/
- cataract cataract23
- catatonic catatonic23
- caterpillar caterpillar23
-
-
-/^From +([^ ]+) +[a-zA-Z][a-zA-Z][a-zA-Z] +[a-zA-Z][a-zA-Z][a-zA-Z] +[0-9]?[0-9] +[0-9][0-9]:[0-9][0-9]/
- From abcd Mon Sep 01 12:33:02 1997
-
-/^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/
- From abcd Mon Sep 01 12:33:02 1997
- From abcd Mon Sep 1 12:33:02 1997
- *** Failers
- From abcd Sep 01 12:33:02 1997
-
-/^12.34/s
- 12\n34
- 12\r34
-
-/\w+(?=\t)/
- the quick brown\t fox
-
-/foo(?!bar)(.*)/
- foobar is foolish see?
-
-/(?:(?!foo)...|^.{0,2})bar(.*)/
- foobar crowbar etc
- barrel
- 2barrel
- A barrel
-
-/^(\D*)(?=\d)(?!123)/
- abc456
- *** Failers
- abc123
-
-/^1234(?# test newlines
- inside)/
- 1234
-
-/^1234 #comment in extended re
- /x
- 1234
-
-/#rhubarb
- abcd/x
- abcd
-
-/^abcd#rhubarb/x
- abcd
-
-/^(a)\1{2,3}(.)/
- aaab
- aaaab
- aaaaab
- aaaaaab
-
-/(?!^)abc/
- the abc
- *** Failers
- abc
-
-/(?=^)abc/
- abc
- *** Failers
- the abc
-
-/^[ab]{1,3}(ab*|b)/
- aabbbbb
-
-/^[ab]{1,3}?(ab*|b)/
- aabbbbb
-
-/^[ab]{1,3}?(ab*?|b)/
- aabbbbb
-
-/^[ab]{1,3}(ab*?|b)/
- aabbbbb
-
-/ (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* # optional leading comment
-(?: (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-" (?: # opening quote...
-[^\\\x80-\xff\n\015"] # Anything except backslash and quote
-| # or
-\\ [^\x80-\xff] # Escaped something (something != CR)
-)* " # closing quote
-) # initial word
-(?: (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* \. (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-" (?: # opening quote...
-[^\\\x80-\xff\n\015"] # Anything except backslash and quote
-| # or
-\\ [^\x80-\xff] # Escaped something (something != CR)
-)* " # closing quote
-) )* # further okay, if led by a period
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* @ (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-| \[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-) # initial subdomain
-(?: #
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* \. # if led by a period...
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-| \[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-) # ...further okay
-)*
-# address
-| # or
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-" (?: # opening quote...
-[^\\\x80-\xff\n\015"] # Anything except backslash and quote
-| # or
-\\ [^\x80-\xff] # Escaped something (something != CR)
-)* " # closing quote
-) # one word, optionally followed by....
-(?:
-[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] | # atom and space parts, or...
-\(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) | # comments, or...
-
-" (?: # opening quote...
-[^\\\x80-\xff\n\015"] # Anything except backslash and quote
-| # or
-\\ [^\x80-\xff] # Escaped something (something != CR)
-)* " # closing quote
-# quoted strings
-)*
-< (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* # leading <
-(?: @ (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-| \[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-) # initial subdomain
-(?: #
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* \. # if led by a period...
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-| \[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-) # ...further okay
-)*
-
-(?: (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* , (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* @ (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-| \[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-) # initial subdomain
-(?: #
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* \. # if led by a period...
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-| \[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-) # ...further okay
-)*
-)* # further okay, if led by comma
-: # closing colon
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* )? # optional route
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-" (?: # opening quote...
-[^\\\x80-\xff\n\015"] # Anything except backslash and quote
-| # or
-\\ [^\x80-\xff] # Escaped something (something != CR)
-)* " # closing quote
-) # initial word
-(?: (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* \. (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-" (?: # opening quote...
-[^\\\x80-\xff\n\015"] # Anything except backslash and quote
-| # or
-\\ [^\x80-\xff] # Escaped something (something != CR)
-)* " # closing quote
-) )* # further okay, if led by a period
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* @ (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-| \[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-) # initial subdomain
-(?: #
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* \. # if led by a period...
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-| \[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-) # ...further okay
-)*
-# address spec
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* > # trailing >
-# name and address
-) (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* # optional trailing comment
-/x
- Alan Other <user\@dom.ain>
- <user\@dom.ain>
- user\@dom.ain
- \"A. Other\" <user.1234\@dom.ain> (a comment)
- A. Other <user.1234\@dom.ain> (a comment)
- \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
- A missing angle <user\@some.where
- *** Failers
- The quick brown fox
-
-/[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional leading comment
-(?:
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-# Atom
-| # or
-" # "
-[^\\\x80-\xff\n\015"] * # normal
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
-" # "
-# Quoted string
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-\.
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-# Atom
-| # or
-" # "
-[^\\\x80-\xff\n\015"] * # normal
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
-" # "
-# Quoted string
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# additional words
-)*
-@
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-\[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-(?:
-\.
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-\[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-)*
-# address
-| # or
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-# Atom
-| # or
-" # "
-[^\\\x80-\xff\n\015"] * # normal
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
-" # "
-# Quoted string
-)
-# leading word
-[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] * # "normal" atoms and or spaces
-(?:
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-|
-" # "
-[^\\\x80-\xff\n\015"] * # normal
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
-" # "
-) # "special" comment or quoted string
-[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] * # more "normal"
-)*
-<
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# <
-(?:
-@
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-\[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-(?:
-\.
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-\[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-)*
-(?: ,
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-@
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-\[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-(?:
-\.
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-\[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-)*
-)* # additional domains
-:
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-)? # optional route
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-# Atom
-| # or
-" # "
-[^\\\x80-\xff\n\015"] * # normal
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
-" # "
-# Quoted string
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-\.
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-# Atom
-| # or
-" # "
-[^\\\x80-\xff\n\015"] * # normal
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
-" # "
-# Quoted string
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# additional words
-)*
-@
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-\[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-(?:
-\.
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-\[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-)*
-# address spec
-> # >
-# name and address
-)
-/x
- Alan Other <user\@dom.ain>
- <user\@dom.ain>
- user\@dom.ain
- \"A. Other\" <user.1234\@dom.ain> (a comment)
- A. Other <user.1234\@dom.ain> (a comment)
- \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
- A missing angle <user\@some.where
- *** Failers
- The quick brown fox
-
-/abc\0def\00pqr\000xyz\0000AB/
- abc\0def\00pqr\000xyz\0000AB
- abc456 abc\0def\00pqr\000xyz\0000ABCDE
-
-/abc\x0def\x00pqr\x000xyz\x0000AB/
- abc\x0def\x00pqr\x000xyz\x0000AB
- abc456 abc\x0def\x00pqr\x000xyz\x0000ABCDE
-
-/^[\000-\037]/
- \0A
- \01B
- \037C
-
-/\0*/
- \0\0\0\0
-
-/A\x0{2,3}Z/
- The A\x0\x0Z
- An A\0\x0\0Z
- *** Failers
- A\0Z
- A\0\x0\0\x0Z
-
-/^(cow|)\1(bell)/
- cowcowbell
- bell
- *** Failers
- cowbell
-
-/^\s/
- \040abc
- \x0cabc
- \nabc
- \rabc
- \tabc
- *** Failers
- abc
-
-/^a b
-
- c/x
- abc
-
-/^(a|)\1*b/
- ab
- aaaab
- b
- *** Failers
- acb
-
-/^(a|)\1+b/
- aab
- aaaab
- b
- *** Failers
- ab
-
-/^(a|)\1?b/
- ab
- aab
- b
- *** Failers
- acb
-
-/^(a|)\1{2}b/
- aaab
- b
- *** Failers
- ab
- aab
- aaaab
-
-/^(a|)\1{2,3}b/
- aaab
- aaaab
- b
- *** Failers
- ab
- aab
- aaaaab
-
-/ab{1,3}bc/
- abbbbc
- abbbc
- abbc
- *** Failers
- abc
- abbbbbc
-
-/([^.]*)\.([^:]*):[T ]+(.*)/
- track1.title:TBlah blah blah
-
-/([^.]*)\.([^:]*):[T ]+(.*)/i
- track1.title:TBlah blah blah
-
-/([^.]*)\.([^:]*):[t ]+(.*)/i
- track1.title:TBlah blah blah
-
-/^[W-c]+$/
- WXY_^abc
- ***Failers
- wxy
-
-/^[W-c]+$/i
- WXY_^abc
- wxy_^ABC
-
-/^[\x3f-\x5F]+$/i
- WXY_^abc
- wxy_^ABC
-
-/^abc$/m
- abc
- qqq\nabc
- abc\nzzz
- qqq\nabc\nzzz
-
-/^abc$/
- abc
- *** Failers
- qqq\nabc
- abc\nzzz
- qqq\nabc\nzzz
-
-/\Aabc\Z/m
- abc
- abc\n
- *** Failers
- qqq\nabc
- abc\nzzz
- qqq\nabc\nzzz
-
-/\A(.)*\Z/s
- abc\ndef
-
-/\A(.)*\Z/m
- *** Failers
- abc\ndef
-
-/(?:b)|(?::+)/
- b::c
- c::b
-
-/[-az]+/
- az-
- *** Failers
- b
-
-/[az-]+/
- za-
- *** Failers
- b
-
-/[a\-z]+/
- a-z
- *** Failers
- b
-
-/[a-z]+/
- abcdxyz
-
-/[\d-]+/
- 12-34
- *** Failers
- aaa
-
-/[\d-z]+/
- 12-34z
- *** Failers
- aaa
-
-/\x5c/
- \\
-
-/\x20Z/
- the Zoo
- *** Failers
- Zulu
-
-/(abc)\1/i
- abcabc
- ABCabc
- abcABC
-
-/(main(O)?)+/
- mainmain
- mainOmain
-
-/ab{3cd/
- ab{3cd
-
-/ab{3,cd/
- ab{3,cd
-
-/ab{3,4a}cd/
- ab{3,4a}cd
-
-/{4,5a}bc/
- {4,5a}bc
-
-/^a.b/
- a\rb
- *** Failers
- a\nb
-
-/abc$/
- abc
- abc\n
- *** Failers
- abc\ndef
-
-/(abc)\123/
- abc\x53
-
-/(abc)\223/
- abc\x93
-
-/(abc)\323/
- abc\xd3
-
-/(abc)\500/
- abc\x40
- abc\100
-
-/(abc)\5000/
- abc\x400
- abc\x40\x30
- abc\1000
- abc\100\x30
- abc\100\060
- abc\100\60
-
-/abc\81/
- abc\081
- abc\0\x38\x31
-
-/abc\91/
- abc\091
- abc\0\x39\x31
-
-/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\12\123/
- abcdefghijkllS
-
-/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123/
- abcdefghijk\12S
-
-/ab\gdef/
- abgdef
-
-/a{0}bc/
- bc
-
-/(a|(bc)){0,0}?xyz/
- xyz
-
-/abc[\10]de/
- abc\010de
-
-/abc[\1]de/
- abc\1de
-
-/(abc)[\1]de/
- abc\1de
-
-/a.b(?s)/
- a\nb
-
-/^([^a])([^\b])([^c]*)([^d]{3,4})/
- baNOTccccd
- baNOTcccd
- baNOTccd
- bacccd
- *** Failers
- anything
- b\bc
- baccd
-
-/[^a]/
- Abc
-
-/[^a]/i
- Abc
-
-/[^a]+/
- AAAaAbc
-
-/[^a]+/i
- AAAaAbc
-
-/[^a]+/
- bbb\nccc
-
-/[^k]$/
- abc
- *** Failers
- abk
-
-/[^k]{2,3}$/
- abc
- kbc
- kabc
- *** Failers
- abk
- akb
- akk
-
-/^\d{8,}\@.+[^k]$/
- 12345678\@a.b.c.d
- 123456789\@x.y.z
- *** Failers
- 12345678\@x.y.uk
- 1234567\@a.b.c.d
-
-/(a)\1{8,}/
- aaaaaaaaa
- aaaaaaaaaa
- *** Failers
- aaaaaaa
-
-/[^a]/
- aaaabcd
- aaAabcd
-
-/[^a]/i
- aaaabcd
- aaAabcd
-
-/[^az]/
- aaaabcd
- aaAabcd
-
-/[^az]/i
- aaaabcd
- aaAabcd
-
-/\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377/
- \000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377
-
-/P[^*]TAIRE[^*]{1,6}?LL/
- xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
-
-/P[^*]TAIRE[^*]{1,}?LL/
- xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
-
-/(\.\d\d[1-9]?)\d+/
- 1.230003938
- 1.875000282
- 1.235
-
-/(\.\d\d((?=0)|\d(?=\d)))/
- 1.230003938
- 1.875000282
- *** Failers
- 1.235
-
-/a(?)b/
- ab
-
-/\b(foo)\s+(\w+)/i
- Food is on the foo table
-
-/foo(.*)bar/
- The food is under the bar in the barn.
-
-/foo(.*?)bar/
- The food is under the bar in the barn.
-
-/(.*)(\d*)/
- I have 2 numbers: 53147
-
-/(.*)(\d+)/
- I have 2 numbers: 53147
-
-/(.*?)(\d*)/
- I have 2 numbers: 53147
-
-/(.*?)(\d+)/
- I have 2 numbers: 53147
-
-/(.*)(\d+)$/
- I have 2 numbers: 53147
-
-/(.*?)(\d+)$/
- I have 2 numbers: 53147
-
-/(.*)\b(\d+)$/
- I have 2 numbers: 53147
-
-/(.*\D)(\d+)$/
- I have 2 numbers: 53147
-
-/^\D*(?!123)/
- ABC123
-
-/^(\D*)(?=\d)(?!123)/
- ABC445
- *** Failers
- ABC123
-
-/^[W-]46]/
- W46]789
- -46]789
- *** Failers
- Wall
- Zebra
- 42
- [abcd]
- ]abcd[
-
-/^[W-\]46]/
- W46]789
- Wall
- Zebra
- Xylophone
- 42
- [abcd]
- ]abcd[
- \\backslash
- *** Failers
- -46]789
- well
-
-/\d\d\/\d\d\/\d\d\d\d/
- 01/01/2000
-
-/word (?:[a-zA-Z0-9]+ ){0,10}otherword/
- word cat dog elephant mussel cow horse canary baboon snake shark otherword
- word cat dog elephant mussel cow horse canary baboon snake shark
-
-/word (?:[a-zA-Z0-9]+ ){0,300}otherword/
- word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
-
-/^(a){0,0}/
- bcd
- abc
- aab
-
-/^(a){0,1}/
- bcd
- abc
- aab
-
-/^(a){0,2}/
- bcd
- abc
- aab
-
-/^(a){0,3}/
- bcd
- abc
- aab
- aaa
-
-/^(a){0,}/
- bcd
- abc
- aab
- aaa
- aaaaaaaa
-
-/^(a){1,1}/
- bcd
- abc
- aab
-
-/^(a){1,2}/
- bcd
- abc
- aab
-
-/^(a){1,3}/
- bcd
- abc
- aab
- aaa
-
-/^(a){1,}/
- bcd
- abc
- aab
- aaa
- aaaaaaaa
-
-/.*\.gif/
- borfle\nbib.gif\nno
-
-/.{0,}\.gif/
- borfle\nbib.gif\nno
-
-/.*\.gif/m
- borfle\nbib.gif\nno
-
-/.*\.gif/s
- borfle\nbib.gif\nno
-
-/.*\.gif/ms
- borfle\nbib.gif\nno
-
-/.*$/
- borfle\nbib.gif\nno
-
-/.*$/m
- borfle\nbib.gif\nno
-
-/.*$/s
- borfle\nbib.gif\nno
-
-/.*$/ms
- borfle\nbib.gif\nno
-
-/.*$/
- borfle\nbib.gif\nno\n
-
-/.*$/m
- borfle\nbib.gif\nno\n
-
-/.*$/s
- borfle\nbib.gif\nno\n
-
-/.*$/ms
- borfle\nbib.gif\nno\n
-
-/(.*X|^B)/
- abcde\n1234Xyz
- BarFoo
- *** Failers
- abcde\nBar
-
-/(.*X|^B)/m
- abcde\n1234Xyz
- BarFoo
- abcde\nBar
-
-/(.*X|^B)/s
- abcde\n1234Xyz
- BarFoo
- *** Failers
- abcde\nBar
-
-/(.*X|^B)/ms
- abcde\n1234Xyz
- BarFoo
- abcde\nBar
-
-/(?s)(.*X|^B)/
- abcde\n1234Xyz
- BarFoo
- *** Failers
- abcde\nBar
-
-/(?s:.*X|^B)/
- abcde\n1234Xyz
- BarFoo
- *** Failers
- abcde\nBar
-
-/^.*B/
- **** Failers
- abc\nB
-
-/(?s)^.*B/
- abc\nB
-
-/(?m)^.*B/
- abc\nB
-
-/(?ms)^.*B/
- abc\nB
-
-/(?ms)^B/
- abc\nB
-
-/(?s)B$/
- B\n
-
-/^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/
- 123456654321
-
-/^\d\d\d\d\d\d\d\d\d\d\d\d/
- 123456654321
-
-/^[\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d]/
- 123456654321
-
-/^[abc]{12}/
- abcabcabcabc
-
-/^[a-c]{12}/
- abcabcabcabc
-
-/^(a|b|c){12}/
- abcabcabcabc
-
-/^[abcdefghijklmnopqrstuvwxy0123456789]/
- n
- *** Failers
- z
-
-/abcde{0,0}/
- abcd
- *** Failers
- abce
-
-/ab[cd]{0,0}e/
- abe
- *** Failers
- abcde
-
-/ab(c){0,0}d/
- abd
- *** Failers
- abcd
-
-/a(b*)/
- a
- ab
- abbbb
- *** Failers
- bbbbb
-
-/ab\d{0}e/
- abe
- *** Failers
- ab1e
-
-/"([^\\"]+|\\.)*"/
- the \"quick\" brown fox
- \"the \\\"quick\\\" brown fox\"
-
-/ End of test input /
diff --git a/ext/pcre/pcrelib/testinput2 b/ext/pcre/pcrelib/testinput2
deleted file mode 100644
index a1a3cd4e2c..0000000000
--- a/ext/pcre/pcrelib/testinput2
+++ /dev/null
@@ -1,589 +0,0 @@
-/(a)b|/
-
-/abc/
- abc
- defabc
- \Aabc
- *** Failers
- \Adefabc
- ABC
-
-/^abc/
- abc
- \Aabc
- *** Failers
- defabc
- \Adefabc
-
-/a+bc/
-
-/a*bc/
-
-/a{3}bc/
-
-/(abc|a+z)/
-
-/^abc$/
- abc
- *** Failers
- def\nabc
-
-/ab\gdef/X
-
-/(?X)ab\gdef/X
-
-/x{5,4}/
-
-/z{65536}/
-
-/[abcd/
-
-/[\B]/
-
-/[a-\w]/
-
-/[z-a]/
-
-/^*/
-
-/(abc/
-
-/(?# abc/
-
-/(?z)abc/
-
-/.*b/
-
-/.*?b/
-
-/cat|dog|elephant/
- this sentence eventually mentions a cat
- this sentences rambles on and on for a while and then reaches elephant
-
-/cat|dog|elephant/S
- this sentence eventually mentions a cat
- this sentences rambles on and on for a while and then reaches elephant
-
-/cat|dog|elephant/iS
- this sentence eventually mentions a CAT cat
- this sentences rambles on and on for a while to elephant ElePhant
-
-/a|[bcd]/S
-
-/(a|[^\dZ])/S
-
-/(a|b)*[\s]/S
-
-/(ab\2)/
-
-/{4,5}abc/
-
-/(a)(b)(c)\2/
- abcb
- \O0abcb
- \O3abcb
- \O6abcb
- \O9abcb
- \O12abcb
-
-/(a)bc|(a)(b)\2/
- abc
- \O0abc
- \O3abc
- \O6abc
- aba
- \O0aba
- \O3aba
- \O6aba
- \O9aba
- \O12aba
-
-/abc$/E
- abc
- *** Failers
- abc\n
- abc\ndef
-
-/(a)(b)(c)(d)(e)\6/
-
-/the quick brown fox/
- the quick brown fox
- this is a line with the quick brown fox
-
-/the quick brown fox/A
- the quick brown fox
- *** Failers
- this is a line with the quick brown fox
-
-/ab(?z)cd/
-
-/^abc|def/
- abcdef
- abcdef\B
-
-/.*((abc)$|(def))/
- defabc
- \Zdefabc
-
-/abc/P
- abc
- *** Failers
-
-/^abc|def/P
- abcdef
- abcdef\B
-
-/.*((abc)$|(def))/P
- defabc
- \Zdefabc
-
-/the quick brown fox/P
- the quick brown fox
- *** Failers
- The Quick Brown Fox
-
-/the quick brown fox/Pi
- the quick brown fox
- The Quick Brown Fox
-
-/abc.def/P
- *** Failers
- abc\ndef
-
-/abc$/P
- abc
- abc\n
-
-/(abc)\2/P
-
-/(abc\1)/P
- abc
-
-/)/
-
-/a[]b/
-
-/[^aeiou ]{3,}/
- co-processors, and for
-
-/<.*>/
- abc<def>ghi<klm>nop
-
-/<.*?>/
- abc<def>ghi<klm>nop
-
-/<.*>/U
- abc<def>ghi<klm>nop
-
-/<.*>(?U)/
- abc<def>ghi<klm>nop
-
-/<.*?>/U
- abc<def>ghi<klm>nop
-
-/={3,}/U
- abc========def
-
-/(?U)={3,}?/
- abc========def
-
-/(?<!bar|cattle)foo/
- foo
- catfoo
- *** Failers
- the barfoo
- and cattlefoo
-
-/(?<=a+)b/
-
-/(?<=aaa|b{0,3})b/
-
-/(?<!(foo)a\1)bar/
-
-/(?i)abc/
-
-/(a|(?m)a)/
-
-/(?i)^1234/
-
-/(^b|(?i)^d)/
-
-/(?s).*/
-
-/[abcd]/S
-
-/(?i)[abcd]/S
-
-/(?m)[xy]|(b|c)/S
-
-/(^a|^b)/m
-
-/(?i)(^a|^b)/m
-
-/(a)(?(1)a|b|c)/
-
-/(?(?=a)a|b|c)/
-
-/(?(1a)/
-
-/(?(?i))/
-
-/(?(abc))/
-
-/(?(?<ab))/
-
-/((?s)blah)\s+\1/
-
-/((?i)blah)\s+\1/
-
-/((?i)b)/DS
-
-/(a*b|(?i:c*(?-i)d))/S
-
-/a$/
- a
- a\n
- *** Failers
- \Za
- \Za\n
-
-/a$/m
- a
- a\n
- \Za\n
- *** Failers
- \Za
-
-/\Aabc/m
-
-/^abc/m
-
-/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/
- aaaaabbbbbcccccdef
-
-/(?<=foo)[ab]/S
-
-/(?<!foo)(alpha|omega)/S
-
-/(?!alphabet)[ab]/S
-
-/(?<=foo\n)^bar/m
-
-/(?>^abc)/m
- abc
- def\nabc
- *** Failers
- defabc
-
-/(?<=ab(c+)d)ef/
-
-/(?<=ab(?<=c+)d)ef/
-
-/(?<=ab(c|de)f)g/
-
-/The next three are in testinput2 because they have variable length branches/
-
-/(?<=bullock|donkey)-cart/
- the bullock-cart
- a donkey-cart race
- *** Failers
- cart
- horse-and-cart
-
-/(?<=ab(?i)x|y|z)/
-
-/(?>.*)(?<=(abcd)|(xyz))/
- alphabetabcd
- endingxyz
-
-/(?<=ab(?i)x(?-i)y|(?i)z|b)ZZ/
- abxyZZ
- abXyZZ
- ZZZ
- zZZ
- bZZ
- BZZ
- *** Failers
- ZZ
- abXYZZ
- zzz
- bzz
-
-/(?<!(foo)a)bar/
- bar
- foobbar
- *** Failers
- fooabar
-
-/This one is here because Perl 5.005_02 doesn't fail it/
-
-/^(a)?(?(1)a|b)+$/
- *** Failers
- a
-
-/This one is here because I think Perl 5.005_02 gets the setting of $1 wrong/
-
-/^(a\1?){4}$/
- aaaaaa
-
-/These are syntax tests from Perl 5.005/
-
-/a[b-a]/
-
-/a[]b/
-
-/a[/
-
-/*a/
-
-/(*)b/
-
-/abc)/
-
-/(abc/
-
-/a**/
-
-/)(/
-
-/\1/
-
-/\2/
-
-/(a)|\2/
-
-/a[b-a]/i
-
-/a[]b/i
-
-/a[/i
-
-/*a/i
-
-/(*)b/i
-
-/abc)/i
-
-/(abc/i
-
-/a**/i
-
-/)(/i
-
-/:(?:/
-
-/(?<%)b/
-
-/a(?{)b/
-
-/a(?{{})b/
-
-/a(?{}})b/
-
-/a(?{"{"})b/
-
-/a(?{"{"}})b/
-
-/(?(1?)a|b)/
-
-/(?(1)a|b|c)/
-
-/[a[:xyz:/
-
-/(?<=x+)y/
-
-/a{37,17}/
-
-/abc/\
-
-/abc/\P
-
-/abc/\i
-
-/(a)bc(d)/
- abcd
- abcd\C2
- abcd\C5
-
-/(.{20})/
- abcdefghijklmnopqrstuvwxyz
- abcdefghijklmnopqrstuvwxyz\C1
- abcdefghijklmnopqrstuvwxyz\G1
-
-/(.{15})/
- abcdefghijklmnopqrstuvwxyz
- abcdefghijklmnopqrstuvwxyz\C1\G1
-
-/(.{16})/
- abcdefghijklmnopqrstuvwxyz
- abcdefghijklmnopqrstuvwxyz\C1\G1\L
-
-/^(a|(bc))de(f)/
- adef\G1\G2\G3\G4\L
- bcdef\G1\G2\G3\G4\L
- adefghijk\C0
-
-/^abc\00def/
- abc\00def\L\C0
-
-/word ((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
-)((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
-)?)?)?)?)?)?)?)?)?otherword/M
-
-/.*X/D
-
-/.*X/Ds
-
-/(.*X|^B)/D
-
-/(.*X|^B)/Ds
-
-/(?s)(.*X|^B)/D
-
-/(?s:.*X|^B)/D
-
-/\Biss\B/+
- Mississippi
-
-/\Biss\B/+P
- Mississippi
-
-/iss/G+
- Mississippi
-
-/\Biss\B/G+
- Mississippi
-
-/\Biss\B/g+
- Mississippi
- *** Failers
- Mississippi\A
-
-/(?<=[Ms])iss/g+
- Mississippi
-
-/(?<=[Ms])iss/G+
- Mississippi
-
-/^iss/g+
- ississippi
-
-/.*iss/g+
- abciss\nxyzisspqr
-
-/.i./+g
- Mississippi
- Mississippi\A
- Missouri river
- Missouri river\A
-
-/^.is/+g
- Mississippi
-
-/^ab\n/g+
- ab\nab\ncd
-
-/^ab\n/mg+
- ab\nab\ncd
-
-/abc/
-
-/abc|bac/
-
-/(abc|bac)/
-
-/(abc|(c|dc))/
-
-/(abc|(d|de)c)/
-
-/a*/
-
-/a+/
-
-/(baa|a+)/
-
-/a{0,3}/
-
-/baa{3,}/
-
-/"([^\\"]+|\\.)*"/
-
-/(abc|ab[cd])/
-
-/(a|.)/
-
-/a|ba|\w/
-
-/abc(?=pqr)/
-
-/...(?<=abc)/
-
-/abc(?!pqr)/
-
-/ab./
-
-/ab[xyz]/
-
-/abc*/
-
-/ab.c*/
-
-/a.c*/
-
-/.c*/
-
-/ac*/
-
-/(a.c*|b.c*)/
-
-/a.c*|aba/
-
-/.+a/
-
-/(?=abcda)a.*/
-
-/(?=a)a.*/
-
-/a(b)*/
-
-/a\d*/
-
-/ab\d*/
-
-/a(\d)*/
-
-/abcde{0,0}/
-
-/ab\d+/
-
-/a(?(1)b)/
-
-/a(?(1)bag|big)/
-
-/a(?(1)bag|big)*/
-
-/a(?(1)bag|big)+/
-
-/a(?(1)b..|b..)/
-
-/ab\d{0}e/
-
-/a?b?/
- a
- b
- ab
- \
- *** Failers
- \N
-
-/|-/
- abcd
- -abc
- \Nab-c
- *** Failers
- \Nabc
-
-/.*?/g+
- abc
-
-/ End of test input /
diff --git a/ext/pcre/pcrelib/testinput3 b/ext/pcre/pcrelib/testinput3
deleted file mode 100644
index 0c884d3b7c..0000000000
--- a/ext/pcre/pcrelib/testinput3
+++ /dev/null
@@ -1,1692 +0,0 @@
-/(?<!bar)foo/
- foo
- catfood
- arfootle
- rfoosh
- *** Failers
- barfoo
- towbarfoo
-
-/\w{3}(?<!bar)foo/
- catfood
- *** Failers
- foo
- barfoo
- towbarfoo
-
-/(?<=(foo)a)bar/
- fooabar
- *** Failers
- bar
- foobbar
-
-/\Aabc\z/m
- abc
- *** Failers
- abc\n
- qqq\nabc
- abc\nzzz
- qqq\nabc\nzzz
-
-"(?>.*/)foo"
- /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/
-
-"(?>.*/)foo"
- /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
-
-/(?>(\.\d\d[1-9]?))\d+/
- 1.230003938
- 1.875000282
- *** Failers
- 1.235
-
-/^((?>\w+)|(?>\s+))*$/
- now is the time for all good men to come to the aid of the party
- *** Failers
- this is not a line with only words and spaces!
-
-/(\d+)(\w)/
- 12345a
- 12345+
-
-/((?>\d+))(\w)/
- 12345a
- *** Failers
- 12345+
-
-/(?>a+)b/
- aaab
-
-/((?>a+)b)/
- aaab
-
-/(?>(a+))b/
- aaab
-
-/(?>b)+/
- aaabbbccc
-
-/(?>a+|b+|c+)*c/
- aaabbbbccccd
-
-/((?>[^()]+)|\([^()]*\))+/
- ((abc(ade)ufh()()x
-
-/\(((?>[^()]+)|\([^()]+\))+\)/
- (abc)
- (abc(def)xyz)
- *** Failers
- ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-
-/a(?-i)b/i
- ab
- *** Failers
- Ab
- aB
- AB
-
-/(a (?x)b c)d e/
- a bcd e
- *** Failers
- a b cd e
- abcd e
- a bcde
-
-/(a b(?x)c d (?-x)e f)/
- a bcde f
- *** Failers
- abcdef
-
-/(a(?i)b)c/
- abc
- aBc
- *** Failers
- abC
- aBC
- Abc
- ABc
- ABC
- AbC
-
-/a(?i:b)c/
- abc
- aBc
- *** Failers
- ABC
- abC
- aBC
-
-/a(?i:b)*c/
- aBc
- aBBc
- *** Failers
- aBC
- aBBC
-
-/a(?=b(?i)c)\w\wd/
- abcd
- abCd
- *** Failers
- aBCd
- abcD
-
-/(?s-i:more.*than).*million/i
- more than million
- more than MILLION
- more \n than Million
- *** Failers
- MORE THAN MILLION
- more \n than \n million
-
-/(?:(?s-i)more.*than).*million/i
- more than million
- more than MILLION
- more \n than Million
- *** Failers
- MORE THAN MILLION
- more \n than \n million
-
-/(?>a(?i)b+)+c/
- abc
- aBbc
- aBBc
- *** Failers
- Abc
- abAb
- abbC
-
-/(?=a(?i)b)\w\wc/
- abc
- aBc
- *** Failers
- Ab
- abC
- aBC
-
-/(?<=a(?i)b)(\w\w)c/
- abxxc
- aBxxc
- *** Failers
- Abxxc
- ABxxc
- abxxC
-
-/(?:(a)|b)(?(1)A|B)/
- aA
- bB
- *** Failers
- aB
- bA
-
-/^(a)?(?(1)a|b)+$/
- aa
- b
- bb
- *** Failers
- ab
-
-/^(?(?=abc)\w{3}:|\d\d)$/
- abc:
- 12
- *** Failers
- 123
- xyz
-
-/^(?(?!abc)\d\d|\w{3}:)$/
- abc:
- 12
- *** Failers
- 123
- xyz
-
-/(?(?<=foo)bar|cat)/
- foobar
- cat
- fcat
- focat
- *** Failers
- foocat
-
-/(?(?<!foo)cat|bar)/
- foobar
- cat
- fcat
- focat
- *** Failers
- foocat
-
-/( \( )? [^()]+ (?(1) \) |) /x
- abcd
- (abcd)
- the quick (abcd) fox
- (abcd
-
-/( \( )? [^()]+ (?(1) \) ) /x
- abcd
- (abcd)
- the quick (abcd) fox
- (abcd
-
-/^(?(2)a|(1)(2))+$/
- 12
- 12a
- 12aa
- *** Failers
- 1234
-
-/((?i)blah)\s+\1/
- blah blah
- BLAH BLAH
- Blah Blah
- blaH blaH
- *** Failers
- blah BLAH
- Blah blah
- blaH blah
-
-/((?i)blah)\s+(?i:\1)/
- blah blah
- BLAH BLAH
- Blah Blah
- blaH blaH
- blah BLAH
- Blah blah
- blaH blah
-
-/(?>a*)*/
- a
- aa
- aaaa
-
-/(abc|)+/
- abc
- abcabc
- abcabcabc
- xyz
-
-/([a]*)*/
- a
- aaaaa
-
-/([ab]*)*/
- a
- b
- ababab
- aaaabcde
- bbbb
-
-/([^a]*)*/
- b
- bbbb
- aaa
-
-/([^ab]*)*/
- cccc
- abab
-
-/([a]*?)*/
- a
- aaaa
-
-/([ab]*?)*/
- a
- b
- abab
- baba
-
-/([^a]*?)*/
- b
- bbbb
- aaa
-
-/([^ab]*?)*/
- c
- cccc
- baba
-
-/(?>a*)*/
- a
- aaabcde
-
-/((?>a*))*/
- aaaaa
- aabbaa
-
-/((?>a*?))*/
- aaaaa
- aabbaa
-
-/(?(?=[^a-z]+[a-z]) \d{2}-[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} ) /x
- 12-sep-98
- 12-09-98
- *** Failers
- sep-12-98
-
-/(?<=(foo))bar\1/
- foobarfoo
- foobarfootling
- *** Failers
- foobar
- barfoo
-
-/(?i:saturday|sunday)/
- saturday
- sunday
- Saturday
- Sunday
- SATURDAY
- SUNDAY
- SunDay
-
-/(a(?i)bc|BB)x/
- abcx
- aBCx
- bbx
- BBx
- *** Failers
- abcX
- aBCX
- bbX
- BBX
-
-/^([ab](?i)[cd]|[ef])/
- ac
- aC
- bD
- elephant
- Europe
- frog
- France
- *** Failers
- Africa
-
-/^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/
- ab
- aBd
- xy
- xY
- zebra
- Zambesi
- *** Failers
- aCD
- XY
-
-/(?<=foo\n)^bar/m
- foo\nbar
- *** Failers
- bar
- baz\nbar
-
-/(?<=(?<!foo)bar)baz/
- barbaz
- barbarbaz
- koobarbaz
- *** Failers
- baz
- foobarbaz
-
-/The case of aaaaaa is missed out below because I think Perl 5.005_02 gets/
-/it wrong; it sets $1 to aaa rather than aa. Compare the following test,/
-/where it does set $1 to aa when matching aaaaaa./
-
-/^(a\1?){4}$/
- a
- aa
- aaa
- aaaa
- aaaaa
- aaaaaaa
- aaaaaaaa
- aaaaaaaaa
- aaaaaaaaaa
- aaaaaaaaaaa
- aaaaaaaaaaaa
- aaaaaaaaaaaaa
- aaaaaaaaaaaaaa
- aaaaaaaaaaaaaaa
- aaaaaaaaaaaaaaaa
-
-/^(a\1?)(a\1?)(a\2?)(a\3?)$/
- a
- aa
- aaa
- aaaa
- aaaaa
- aaaaaa
- aaaaaaa
- aaaaaaaa
- aaaaaaaaa
- aaaaaaaaaa
- aaaaaaaaaaa
- aaaaaaaaaaaa
- aaaaaaaaaaaaa
- aaaaaaaaaaaaaa
- aaaaaaaaaaaaaaa
- aaaaaaaaaaaaaaaa
-
-/The following tests are taken from the Perl 5.005 test suite; some of them/
-/are compatible with 5.004, but I'd rather not have to sort them out./
-
-/abc/
- abc
- xabcy
- ababc
- *** Failers
- xbc
- axc
- abx
-
-/ab*c/
- abc
-
-/ab*bc/
- abc
- abbc
- abbbbc
-
-/.{1}/
- abbbbc
-
-/.{3,4}/
- abbbbc
-
-/ab{0,}bc/
- abbbbc
-
-/ab+bc/
- abbc
- *** Failers
- abc
- abq
-
-/ab{1,}bc/
-
-/ab+bc/
- abbbbc
-
-/ab{1,}bc/
- abbbbc
-
-/ab{1,3}bc/
- abbbbc
-
-/ab{3,4}bc/
- abbbbc
-
-/ab{4,5}bc/
- *** Failers
- abq
- abbbbc
-
-/ab?bc/
- abbc
- abc
-
-/ab{0,1}bc/
- abc
-
-/ab?bc/
-
-/ab?c/
- abc
-
-/ab{0,1}c/
- abc
-
-/^abc$/
- abc
- *** Failers
- abbbbc
- abcc
-
-/^abc/
- abcc
-
-/^abc$/
-
-/abc$/
- aabc
- *** Failers
- aabc
- aabcd
-
-/^/
- abc
-
-/$/
- abc
-
-/a.c/
- abc
- axc
-
-/a.*c/
- axyzc
-
-/a[bc]d/
- abd
- *** Failers
- axyzd
- abc
-
-/a[b-d]e/
- ace
-
-/a[b-d]/
- aac
-
-/a[-b]/
- a-
-
-/a[b-]/
- a-
-
-/a]/
- a]
-
-/a[]]b/
- a]b
-
-/a[^bc]d/
- aed
- *** Failers
- abd
- abd
-
-/a[^-b]c/
- adc
-
-/a[^]b]c/
- adc
- *** Failers
- a-c
- a]c
-
-/\ba\b/
- a-
- -a
- -a-
-
-/\by\b/
- *** Failers
- xy
- yz
- xyz
-
-/\Ba\B/
- *** Failers
- a-
- -a
- -a-
-
-/\By\b/
- xy
-
-/\by\B/
- yz
-
-/\By\B/
- xyz
-
-/\w/
- a
-
-/\W/
- -
- *** Failers
- -
- a
-
-/a\sb/
- a b
-
-/a\Sb/
- a-b
- *** Failers
- a-b
- a b
-
-/\d/
- 1
-
-/\D/
- -
- *** Failers
- -
- 1
-
-/[\w]/
- a
-
-/[\W]/
- -
- *** Failers
- -
- a
-
-/a[\s]b/
- a b
-
-/a[\S]b/
- a-b
- *** Failers
- a-b
- a b
-
-/[\d]/
- 1
-
-/[\D]/
- -
- *** Failers
- -
- 1
-
-/ab|cd/
- abc
- abcd
-
-/()ef/
- def
-
-/$b/
-
-/a\(b/
- a(b
-
-/a\(*b/
- ab
- a((b
-
-/a\\b/
- a\b
-
-/((a))/
- abc
-
-/(a)b(c)/
- abc
-
-/a+b+c/
- aabbabc
-
-/a{1,}b{1,}c/
- aabbabc
-
-/a.+?c/
- abcabc
-
-/(a+|b)*/
- ab
-
-/(a+|b){0,}/
- ab
-
-/(a+|b)+/
- ab
-
-/(a+|b){1,}/
- ab
-
-/(a+|b)?/
- ab
-
-/(a+|b){0,1}/
- ab
-
-/[^ab]*/
- cde
-
-/abc/
- *** Failers
- b
-
-
-/a*/
-
-
-/([abc])*d/
- abbbcd
-
-/([abc])*bcd/
- abcd
-
-/a|b|c|d|e/
- e
-
-/(a|b|c|d|e)f/
- ef
-
-/abcd*efg/
- abcdefg
-
-/ab*/
- xabyabbbz
- xayabbbz
-
-/(ab|cd)e/
- abcde
-
-/[abhgefdc]ij/
- hij
-
-/^(ab|cd)e/
-
-/(abc|)ef/
- abcdef
-
-/(a|b)c*d/
- abcd
-
-/(ab|ab*)bc/
- abc
-
-/a([bc]*)c*/
- abc
-
-/a([bc]*)(c*d)/
- abcd
-
-/a([bc]+)(c*d)/
- abcd
-
-/a([bc]*)(c+d)/
- abcd
-
-/a[bcd]*dcdcde/
- adcdcde
-
-/a[bcd]+dcdcde/
- *** Failers
- abcde
- adcdcde
-
-/(ab|a)b*c/
- abc
-
-/((a)(b)c)(d)/
- abcd
-
-/[a-zA-Z_][a-zA-Z0-9_]*/
- alpha
-
-/^a(bc+|b[eh])g|.h$/
- abh
-
-/(bc+d$|ef*g.|h?i(j|k))/
- effgz
- ij
- reffgz
- *** Failers
- effg
- bcdd
-
-/((((((((((a))))))))))/
- a
-
-/((((((((((a))))))))))\10/
- aa
-
-/(((((((((a)))))))))/
- a
-
-/multiple words of text/
- *** Failers
- aa
- uh-uh
-
-/multiple words/
- multiple words, yeah
-
-/(.*)c(.*)/
- abcde
-
-/\((.*), (.*)\)/
- (a, b)
-
-/[k]/
-
-/abcd/
- abcd
-
-/a(bc)d/
- abcd
-
-/a[-]?c/
- ac
-
-/(abc)\1/
- abcabc
-
-/([a-c]*)\1/
- abcabc
-
-/(a)|\1/
- a
- *** Failers
- ab
- x
-
-/(([a-c])b*?\2)*/
- ababbbcbc
-
-/(([a-c])b*?\2){3}/
- ababbbcbc
-
-/((\3|b)\2(a)x)+/
- aaaxabaxbaaxbbax
-
-/((\3|b)\2(a)){2,}/
- bbaababbabaaaaabbaaaabba
-
-/abc/i
- ABC
- XABCY
- ABABC
- *** Failers
- aaxabxbaxbbx
- XBC
- AXC
- ABX
-
-/ab*c/i
- ABC
-
-/ab*bc/i
- ABC
- ABBC
-
-/ab*?bc/i
- ABBBBC
-
-/ab{0,}?bc/i
- ABBBBC
-
-/ab+?bc/i
- ABBC
-
-/ab+bc/i
- *** Failers
- ABC
- ABQ
-
-/ab{1,}bc/i
-
-/ab+bc/i
- ABBBBC
-
-/ab{1,}?bc/i
- ABBBBC
-
-/ab{1,3}?bc/i
- ABBBBC
-
-/ab{3,4}?bc/i
- ABBBBC
-
-/ab{4,5}?bc/i
- *** Failers
- ABQ
- ABBBBC
-
-/ab??bc/i
- ABBC
- ABC
-
-/ab{0,1}?bc/i
- ABC
-
-/ab??bc/i
-
-/ab??c/i
- ABC
-
-/ab{0,1}?c/i
- ABC
-
-/^abc$/i
- ABC
- *** Failers
- ABBBBC
- ABCC
-
-/^abc/i
- ABCC
-
-/^abc$/i
-
-/abc$/i
- AABC
-
-/^/i
- ABC
-
-/$/i
- ABC
-
-/a.c/i
- ABC
- AXC
-
-/a.*?c/i
- AXYZC
-
-/a.*c/i
- *** Failers
- AABC
- AXYZD
-
-/a[bc]d/i
- ABD
-
-/a[b-d]e/i
- ACE
- *** Failers
- ABC
- ABD
-
-/a[b-d]/i
- AAC
-
-/a[-b]/i
- A-
-
-/a[b-]/i
- A-
-
-/a]/i
- A]
-
-/a[]]b/i
- A]B
-
-/a[^bc]d/i
- AED
-
-/a[^-b]c/i
- ADC
- *** Failers
- ABD
- A-C
-
-/a[^]b]c/i
- ADC
-
-/ab|cd/i
- ABC
- ABCD
-
-/()ef/i
- DEF
-
-/$b/i
- *** Failers
- A]C
- B
-
-/a\(b/i
- A(B
-
-/a\(*b/i
- AB
- A((B
-
-/a\\b/i
- A\B
-
-/((a))/i
- ABC
-
-/(a)b(c)/i
- ABC
-
-/a+b+c/i
- AABBABC
-
-/a{1,}b{1,}c/i
- AABBABC
-
-/a.+?c/i
- ABCABC
-
-/a.*?c/i
- ABCABC
-
-/a.{0,5}?c/i
- ABCABC
-
-/(a+|b)*/i
- AB
-
-/(a+|b){0,}/i
- AB
-
-/(a+|b)+/i
- AB
-
-/(a+|b){1,}/i
- AB
-
-/(a+|b)?/i
- AB
-
-/(a+|b){0,1}/i
- AB
-
-/(a+|b){0,1}?/i
- AB
-
-/[^ab]*/i
- CDE
-
-/abc/i
-
-/a*/i
-
-
-/([abc])*d/i
- ABBBCD
-
-/([abc])*bcd/i
- ABCD
-
-/a|b|c|d|e/i
- E
-
-/(a|b|c|d|e)f/i
- EF
-
-/abcd*efg/i
- ABCDEFG
-
-/ab*/i
- XABYABBBZ
- XAYABBBZ
-
-/(ab|cd)e/i
- ABCDE
-
-/[abhgefdc]ij/i
- HIJ
-
-/^(ab|cd)e/i
- ABCDE
-
-/(abc|)ef/i
- ABCDEF
-
-/(a|b)c*d/i
- ABCD
-
-/(ab|ab*)bc/i
- ABC
-
-/a([bc]*)c*/i
- ABC
-
-/a([bc]*)(c*d)/i
- ABCD
-
-/a([bc]+)(c*d)/i
- ABCD
-
-/a([bc]*)(c+d)/i
- ABCD
-
-/a[bcd]*dcdcde/i
- ADCDCDE
-
-/a[bcd]+dcdcde/i
-
-/(ab|a)b*c/i
- ABC
-
-/((a)(b)c)(d)/i
- ABCD
-
-/[a-zA-Z_][a-zA-Z0-9_]*/i
- ALPHA
-
-/^a(bc+|b[eh])g|.h$/i
- ABH
-
-/(bc+d$|ef*g.|h?i(j|k))/i
- EFFGZ
- IJ
- REFFGZ
- *** Failers
- ADCDCDE
- EFFG
- BCDD
-
-/((((((((((a))))))))))/i
- A
-
-/((((((((((a))))))))))\10/i
- AA
-
-/(((((((((a)))))))))/i
- A
-
-/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i
- A
-
-/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i
- C
-
-/multiple words of text/i
- *** Failers
- AA
- UH-UH
-
-/multiple words/i
- MULTIPLE WORDS, YEAH
-
-/(.*)c(.*)/i
- ABCDE
-
-/\((.*), (.*)\)/i
- (A, B)
-
-/[k]/i
-
-/abcd/i
- ABCD
-
-/a(bc)d/i
- ABCD
-
-/a[-]?c/i
- AC
-
-/(abc)\1/i
- ABCABC
-
-/([a-c]*)\1/i
- ABCABC
-
-/a(?!b)./
- abad
-
-/a(?=d)./
- abad
-
-/a(?=c|d)./
- abad
-
-/a(?:b|c|d)(.)/
- ace
-
-/a(?:b|c|d)*(.)/
- ace
-
-/a(?:b|c|d)+?(.)/
- ace
- acdbcdbe
-
-/a(?:b|c|d)+(.)/
- acdbcdbe
-
-/a(?:b|c|d){2}(.)/
- acdbcdbe
-
-/a(?:b|c|d){4,5}(.)/
- acdbcdbe
-
-/a(?:b|c|d){4,5}?(.)/
- acdbcdbe
-
-/((foo)|(bar))*/
- foobar
-
-/a(?:b|c|d){6,7}(.)/
- acdbcdbe
-
-/a(?:b|c|d){6,7}?(.)/
- acdbcdbe
-
-/a(?:b|c|d){5,6}(.)/
- acdbcdbe
-
-/a(?:b|c|d){5,6}?(.)/
- acdbcdbe
-
-/a(?:b|c|d){5,7}(.)/
- acdbcdbe
-
-/a(?:b|c|d){5,7}?(.)/
- acdbcdbe
-
-/a(?:b|(c|e){1,2}?|d)+?(.)/
- ace
-
-/^(.+)?B/
- AB
-
-/^([^a-z])|(\^)$/
- .
-
-/^[<>]&/
- <&OUT
-
-/^(a\1?){4}$/
- aaaaaaaaaa
- *** Failers
- AB
- aaaaaaaaa
- aaaaaaaaaaa
-
-/^(a(?(1)\1)){4}$/
- aaaaaaaaaa
- *** Failers
- aaaaaaaaa
- aaaaaaaaaaa
-
-/(?:(f)(o)(o)|(b)(a)(r))*/
- foobar
-
-/(?<=a)b/
- ab
- *** Failers
- cb
- b
-
-/(?<!c)b/
- ab
- b
- b
-
-/(?:..)*a/
- aba
-
-/(?:..)*?a/
- aba
-
-/^(?:b|a(?=(.)))*\1/
- abc
-
-/^(){3,5}/
- abc
-
-/^(a+)*ax/
- aax
-
-/^((a|b)+)*ax/
- aax
-
-/^((a|bc)+)*ax/
- aax
-
-/(a|x)*ab/
- cab
-
-/(a)*ab/
- cab
-
-/(?:(?i)a)b/
- ab
-
-/((?i)a)b/
- ab
-
-/(?:(?i)a)b/
- Ab
-
-/((?i)a)b/
- Ab
-
-/(?:(?i)a)b/
- *** Failers
- cb
- aB
-
-/((?i)a)b/
-
-/(?i:a)b/
- ab
-
-/((?i:a))b/
- ab
-
-/(?i:a)b/
- Ab
-
-/((?i:a))b/
- Ab
-
-/(?i:a)b/
- *** Failers
- aB
- aB
-
-/((?i:a))b/
-
-/(?:(?-i)a)b/i
- ab
-
-/((?-i)a)b/i
- ab
-
-/(?:(?-i)a)b/i
- aB
-
-/((?-i)a)b/i
- aB
-
-/(?:(?-i)a)b/i
- *** Failers
- aB
- Ab
-
-/((?-i)a)b/i
-
-/(?:(?-i)a)b/i
- aB
-
-/((?-i)a)b/i
- aB
-
-/(?:(?-i)a)b/i
- *** Failers
- Ab
- AB
-
-/((?-i)a)b/i
-
-/(?-i:a)b/i
- ab
-
-/((?-i:a))b/i
- ab
-
-/(?-i:a)b/i
- aB
-
-/((?-i:a))b/i
- aB
-
-/(?-i:a)b/i
- *** Failers
- AB
- Ab
-
-/((?-i:a))b/i
-
-/(?-i:a)b/i
- aB
-
-/((?-i:a))b/i
- aB
-
-/(?-i:a)b/i
- *** Failers
- Ab
- AB
-
-/((?-i:a))b/i
-
-/((?-i:a.))b/i
- *** Failers
- AB
- a\nB
-
-/((?s-i:a.))b/i
- a\nB
-
-/(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
- cabbbb
-
-/(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
- caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
-
-/(ab)\d\1/i
- Ab4ab
- ab4Ab
-
-/foo\w*\d{4}baz/
- foobar1234baz
-
-/x(~~)*(?:(?:F)?)?/
- x~~
-
-/^a(?#xxx){3}c/
- aaac
-
-/^a (?#xxx) (?#yyy) {3}c/x
- aaac
-
-/(?<![cd])b/
- *** Failers
- B\nB
- dbcb
-
-/(?<![cd])[ab]/
- dbaacb
-
-/(?<!(c|d))b/
-
-/(?<!(c|d))[ab]/
- dbaacb
-
-/(?<!cd)[ab]/
- cdaccb
-
-/^(?:a?b?)*$/
- *** Failers
- dbcb
- a--
-
-/((?s)^a(.))((?m)^b$)/
- a\nb\nc\n
-
-/((?m)^b$)/
- a\nb\nc\n
-
-/(?m)^b/
- a\nb\n
-
-/(?m)^(b)/
- a\nb\n
-
-/((?m)^b)/
- a\nb\n
-
-/\n((?m)^b)/
- a\nb\n
-
-/((?s).)c(?!.)/
- a\nb\nc\n
- a\nb\nc\n
-
-/((?s)b.)c(?!.)/
- a\nb\nc\n
- a\nb\nc\n
-
-/^b/
-
-/()^b/
- *** Failers
- a\nb\nc\n
- a\nb\nc\n
-
-/((?m)^b)/
- a\nb\nc\n
-
-/(?(1)a|b)/
-
-/(?(1)b|a)/
- a
-
-/(x)?(?(1)a|b)/
- *** Failers
- a
- a
-
-/(x)?(?(1)b|a)/
- a
-
-/()?(?(1)b|a)/
- a
-
-/()(?(1)b|a)/
-
-/()?(?(1)a|b)/
- a
-
-/^(\()?blah(?(1)(\)))$/
- (blah)
- blah
- *** Failers
- a
- blah)
- (blah
-
-/^(\(+)?blah(?(1)(\)))$/
- (blah)
- blah
- *** Failers
- blah)
- (blah
-
-/(?(?!a)a|b)/
-
-/(?(?!a)b|a)/
- a
-
-/(?(?=a)b|a)/
- *** Failers
- a
- a
-
-/(?(?=a)a|b)/
- a
-
-/(?=(a+?))(\1ab)/
- aaab
-
-/^(?=(a+?))\1ab/
-
-/(\w+:)+/
- one:
-
-/$(?<=^(a))/
- a
-
-/(?=(a+?))(\1ab)/
- aaab
-
-/^(?=(a+?))\1ab/
- *** Failers
- aaab
- aaab
-
-/([\w:]+::)?(\w+)$/
- abcd
- xy:z:::abcd
-
-/^[^bcd]*(c+)/
- aexycd
-
-/(a*)b+/
- caab
-
-/([\w:]+::)?(\w+)$/
- abcd
- xy:z:::abcd
- *** Failers
- abcd:
- abcd:
-
-/^[^bcd]*(c+)/
- aexycd
-
-/(>a+)ab/
-
-/(?>a+)b/
- aaab
-
-/([[:]+)/
- a:[b]:
-
-/([[=]+)/
- a=[b]=
-
-/([[.]+)/
- a.[b].
-
-/((?>a+)b)/
- aaab
-
-/(?>(a+))b/
- aaab
-
-/((?>[^()]+)|\([^()]*\))+/
- ((abc(ade)ufh()()x
-
-/a\Z/
- *** Failers
- aaab
- a\nb\n
-
-/b\Z/
- a\nb\n
-
-/b\z/
-
-/b\Z/
- a\nb
-
-/b\z/
- a\nb
- *** Failers
-
-/^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$/
- a
- abc
- a-b
- 0-9
- a.b
- 5.6.7
- the.quick.brown.fox
- a100.b200.300c
- 12-ab.1245
- ***Failers
- \
- .a
- -a
- a-
- a.
- a_b
- a.-
- a..
- ab..bc
- the.quick.brown.fox-
- the.quick.brown.fox.
- the.quick.brown.fox_
- the.quick.brown.fox+
-
-/(?>.*)(?<=(abcd|wxyz))/
- alphabetabcd
- endingwxyz
- *** Failers
- a rather long string that doesn't end with one of them
-
-/word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/
- word cat dog elephant mussel cow horse canary baboon snake shark otherword
- word cat dog elephant mussel cow horse canary baboon snake shark
-
-/word (?>[a-zA-Z0-9]+ ){0,30}otherword/
- word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
-
-/(?<=\d{3}(?!999))foo/
- 999foo
- 123999foo
- *** Failers
- 123abcfoo
-
-/(?<=(?!...999)\d{3})foo/
- 999foo
- 123999foo
- *** Failers
- 123abcfoo
-
-/(?<=\d{3}(?!999)...)foo/
- 123abcfoo
- 123456foo
- *** Failers
- 123999foo
-
-/(?<=\d{3}...)(?<!999)foo/
- 123abcfoo
- 123456foo
- *** Failers
- 123999foo
-
-/<a[\s]+href[\s]*=[\s]* # find <a href=
- ([\"\'])? # find single or double quote
- (?(1) (.*?)\1 | ([^\s]+)) # if quote found, match up to next matching
- # quote, otherwise match up to next space
-/isx
- <a href=abcd xyz
- <a href=\"abcd xyz pqr\" cats
- <a href=\'abcd xyz pqr\' cats
-
-/<a\s+href\s*=\s* # find <a href=
- (["'])? # find single or double quote
- (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
- # quote, otherwise match up to next space
-/isx
- <a href=abcd xyz
- <a href=\"abcd xyz pqr\" cats
- <a href = \'abcd xyz pqr\' cats
-
-/<a\s+href(?>\s*)=(?>\s*) # find <a href=
- (["'])? # find single or double quote
- (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
- # quote, otherwise match up to next space
-/isx
- <a href=abcd xyz
- <a href=\"abcd xyz pqr\" cats
- <a href = \'abcd xyz pqr\' cats
-
-/ End of test input /
diff --git a/ext/pcre/pcrelib/testinput4 b/ext/pcre/pcrelib/testinput4
deleted file mode 100644
index c23b52aceb..0000000000
--- a/ext/pcre/pcrelib/testinput4
+++ /dev/null
@@ -1,64 +0,0 @@
-/^[\w]+/
- *** Failers
- École
-
-/^[\w]+/Lfr
- École
-
-/^[\w]+/
- *** Failers
- École
-
-/^[\W]+/
- École
-
-/^[\W]+/Lfr
- *** Failers
- École
-
-/[\b]/
- \b
- *** Failers
- a
-
-/[\b]/Lfr
- \b
- *** Failers
- a
-
-/^\w+/
- *** Failers
- École
-
-/^\w+/Lfr
- École
-
-/(.+)\b(.+)/
- École
-
-/(.+)\b(.+)/Lfr
- *** Failers
- École
-
-/École/i
- École
- *** Failers
- école
-
-/École/iLfr
- École
- école
-
-/\w/IS
-
-/\w/ISLfr
-
-/^[\xc8-\xc9]/iLfr
- École
- école
-
-/^[\xc8-\xc9]/Lfr
- École
- *** Failers
- école
-
diff --git a/ext/pcre/pcrelib/testoutput1 b/ext/pcre/pcrelib/testoutput1
deleted file mode 100644
index 952317fdc9..0000000000
--- a/ext/pcre/pcrelib/testoutput1
+++ /dev/null
@@ -1,2887 +0,0 @@
-PCRE version 2.08 31-Aug-1999
-
-/the quick brown fox/
- the quick brown fox
- 0: the quick brown fox
- The quick brown FOX
-No match
- What do you know about the quick brown fox?
- 0: the quick brown fox
- What do you know about THE QUICK BROWN FOX?
-No match
-
-/The quick brown fox/i
- the quick brown fox
- 0: the quick brown fox
- The quick brown FOX
- 0: The quick brown FOX
- What do you know about the quick brown fox?
- 0: the quick brown fox
- What do you know about THE QUICK BROWN FOX?
- 0: THE QUICK BROWN FOX
-
-/abcd\t\n\r\f\a\e\071\x3b\$\\\?caxyz/
- abcd\t\n\r\f\a\e9;\$\\?caxyz
- 0: abcd\x09\x0a\x0d\x0c\x07\x1b9;$\?caxyz
-
-/a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/
- abxyzpqrrrabbxyyyypqAzz
- 0: abxyzpqrrrabbxyyyypqAzz
- abxyzpqrrrabbxyyyypqAzz
- 0: abxyzpqrrrabbxyyyypqAzz
- aabxyzpqrrrabbxyyyypqAzz
- 0: aabxyzpqrrrabbxyyyypqAzz
- aaabxyzpqrrrabbxyyyypqAzz
- 0: aaabxyzpqrrrabbxyyyypqAzz
- aaaabxyzpqrrrabbxyyyypqAzz
- 0: aaaabxyzpqrrrabbxyyyypqAzz
- abcxyzpqrrrabbxyyyypqAzz
- 0: abcxyzpqrrrabbxyyyypqAzz
- aabcxyzpqrrrabbxyyyypqAzz
- 0: aabcxyzpqrrrabbxyyyypqAzz
- aaabcxyzpqrrrabbxyyyypAzz
- 0: aaabcxyzpqrrrabbxyyyypAzz
- aaabcxyzpqrrrabbxyyyypqAzz
- 0: aaabcxyzpqrrrabbxyyyypqAzz
- aaabcxyzpqrrrabbxyyyypqqAzz
- 0: aaabcxyzpqrrrabbxyyyypqqAzz
- aaabcxyzpqrrrabbxyyyypqqqAzz
- 0: aaabcxyzpqrrrabbxyyyypqqqAzz
- aaabcxyzpqrrrabbxyyyypqqqqAzz
- 0: aaabcxyzpqrrrabbxyyyypqqqqAzz
- aaabcxyzpqrrrabbxyyyypqqqqqAzz
- 0: aaabcxyzpqrrrabbxyyyypqqqqqAzz
- aaabcxyzpqrrrabbxyyyypqqqqqqAzz
- 0: aaabcxyzpqrrrabbxyyyypqqqqqqAzz
- aaaabcxyzpqrrrabbxyyyypqAzz
- 0: aaaabcxyzpqrrrabbxyyyypqAzz
- abxyzzpqrrrabbxyyyypqAzz
- 0: abxyzzpqrrrabbxyyyypqAzz
- aabxyzzzpqrrrabbxyyyypqAzz
- 0: aabxyzzzpqrrrabbxyyyypqAzz
- aaabxyzzzzpqrrrabbxyyyypqAzz
- 0: aaabxyzzzzpqrrrabbxyyyypqAzz
- aaaabxyzzzzpqrrrabbxyyyypqAzz
- 0: aaaabxyzzzzpqrrrabbxyyyypqAzz
- abcxyzzpqrrrabbxyyyypqAzz
- 0: abcxyzzpqrrrabbxyyyypqAzz
- aabcxyzzzpqrrrabbxyyyypqAzz
- 0: aabcxyzzzpqrrrabbxyyyypqAzz
- aaabcxyzzzzpqrrrabbxyyyypqAzz
- 0: aaabcxyzzzzpqrrrabbxyyyypqAzz
- aaaabcxyzzzzpqrrrabbxyyyypqAzz
- 0: aaaabcxyzzzzpqrrrabbxyyyypqAzz
- aaaabcxyzzzzpqrrrabbbxyyyypqAzz
- 0: aaaabcxyzzzzpqrrrabbbxyyyypqAzz
- aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
- 0: aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
- aaabcxyzpqrrrabbxyyyypABzz
- 0: aaabcxyzpqrrrabbxyyyypABzz
- aaabcxyzpqrrrabbxyyyypABBzz
- 0: aaabcxyzpqrrrabbxyyyypABBzz
- >>>aaabxyzpqrrrabbxyyyypqAzz
- 0: aaabxyzpqrrrabbxyyyypqAzz
- >aaaabxyzpqrrrabbxyyyypqAzz
- 0: aaaabxyzpqrrrabbxyyyypqAzz
- >>>>abcxyzpqrrrabbxyyyypqAzz
- 0: abcxyzpqrrrabbxyyyypqAzz
- *** Failers
-No match
- abxyzpqrrabbxyyyypqAzz
-No match
- abxyzpqrrrrabbxyyyypqAzz
-No match
- abxyzpqrrrabxyyyypqAzz
-No match
- aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz
-No match
- aaaabcxyzzzzpqrrrabbbxyyypqAzz
-No match
- aaabcxyzpqrrrabbxyyyypqqqqqqqAzz
-No match
-
-/^(abc){1,2}zz/
- abczz
- 0: abczz
- 1: abc
- abcabczz
- 0: abcabczz
- 1: abc
- *** Failers
-No match
- zz
-No match
- abcabcabczz
-No match
- >>abczz
-No match
-
-/^(b+?|a){1,2}?c/
- bc
- 0: bc
- 1: b
- bbc
- 0: bbc
- 1: b
- bbbc
- 0: bbbc
- 1: bb
- bac
- 0: bac
- 1: a
- bbac
- 0: bbac
- 1: a
- aac
- 0: aac
- 1: a
- abbbbbbbbbbbc
- 0: abbbbbbbbbbbc
- 1: bbbbbbbbbbb
- bbbbbbbbbbbac
- 0: bbbbbbbbbbbac
- 1: a
- *** Failers
-No match
- aaac
-No match
- abbbbbbbbbbbac
-No match
-
-/^(b+|a){1,2}c/
- bc
- 0: bc
- 1: b
- bbc
- 0: bbc
- 1: bb
- bbbc
- 0: bbbc
- 1: bbb
- bac
- 0: bac
- 1: a
- bbac
- 0: bbac
- 1: a
- aac
- 0: aac
- 1: a
- abbbbbbbbbbbc
- 0: abbbbbbbbbbbc
- 1: bbbbbbbbbbb
- bbbbbbbbbbbac
- 0: bbbbbbbbbbbac
- 1: a
- *** Failers
-No match
- aaac
-No match
- abbbbbbbbbbbac
-No match
-
-/^(b+|a){1,2}?bc/
- bbc
- 0: bbc
- 1: b
-
-/^(b*|ba){1,2}?bc/
- babc
- 0: babc
- 1: ba
- bbabc
- 0: bbabc
- 1: ba
- bababc
- 0: bababc
- 1: ba
- *** Failers
-No match
- bababbc
-No match
- babababc
-No match
-
-/^(ba|b*){1,2}?bc/
- babc
- 0: babc
- 1: ba
- bbabc
- 0: bbabc
- 1: ba
- bababc
- 0: bababc
- 1: ba
- *** Failers
-No match
- bababbc
-No match
- babababc
-No match
-
-/^\ca\cA\c[\c{\c:/
- \x01\x01\e;z
- 0: \x01\x01\x1b;z
-
-/^[ab\]cde]/
- athing
- 0: a
- bthing
- 0: b
- ]thing
- 0: ]
- cthing
- 0: c
- dthing
- 0: d
- ething
- 0: e
- *** Failers
-No match
- fthing
-No match
- [thing
-No match
- \\thing
-No match
-
-/^[]cde]/
- ]thing
- 0: ]
- cthing
- 0: c
- dthing
- 0: d
- ething
- 0: e
- *** Failers
-No match
- athing
-No match
- fthing
-No match
-
-/^[^ab\]cde]/
- fthing
- 0: f
- [thing
- 0: [
- \\thing
- 0: \
- *** Failers
- 0: *
- athing
-No match
- bthing
-No match
- ]thing
-No match
- cthing
-No match
- dthing
-No match
- ething
-No match
-
-/^[^]cde]/
- athing
- 0: a
- fthing
- 0: f
- *** Failers
- 0: *
- ]thing
-No match
- cthing
-No match
- dthing
-No match
- ething
-No match
-
-/^\/
-
- 0: \x81
-
-/^ÿ/
- ÿ
- 0: \xff
-
-/^[0-9]+$/
- 0
- 0: 0
- 1
- 0: 1
- 2
- 0: 2
- 3
- 0: 3
- 4
- 0: 4
- 5
- 0: 5
- 6
- 0: 6
- 7
- 0: 7
- 8
- 0: 8
- 9
- 0: 9
- 10
- 0: 10
- 100
- 0: 100
- *** Failers
-No match
- abc
-No match
-
-/^.*nter/
- enter
- 0: enter
- inter
- 0: inter
- uponter
- 0: uponter
-
-/^xxx[0-9]+$/
- xxx0
- 0: xxx0
- xxx1234
- 0: xxx1234
- *** Failers
-No match
- xxx
-No match
-
-/^.+[0-9][0-9][0-9]$/
- x123
- 0: x123
- xx123
- 0: xx123
- 123456
- 0: 123456
- *** Failers
-No match
- 123
-No match
- x1234
- 0: x1234
-
-/^.+?[0-9][0-9][0-9]$/
- x123
- 0: x123
- xx123
- 0: xx123
- 123456
- 0: 123456
- *** Failers
-No match
- 123
-No match
- x1234
- 0: x1234
-
-/^([^!]+)!(.+)=apquxz\.ixr\.zzz\.ac\.uk$/
- abc!pqr=apquxz.ixr.zzz.ac.uk
- 0: abc!pqr=apquxz.ixr.zzz.ac.uk
- 1: abc
- 2: pqr
- *** Failers
-No match
- !pqr=apquxz.ixr.zzz.ac.uk
-No match
- abc!=apquxz.ixr.zzz.ac.uk
-No match
- abc!pqr=apquxz:ixr.zzz.ac.uk
-No match
- abc!pqr=apquxz.ixr.zzz.ac.ukk
-No match
-
-/:/
- Well, we need a colon: somewhere
- 0: :
- *** Fail if we don't
-No match
-
-/([\da-f:]+)$/i
- 0abc
- 0: 0abc
- 1: 0abc
- abc
- 0: abc
- 1: abc
- fed
- 0: fed
- 1: fed
- E
- 0: E
- 1: E
- ::
- 0: ::
- 1: ::
- 5f03:12C0::932e
- 0: 5f03:12C0::932e
- 1: 5f03:12C0::932e
- fed def
- 0: def
- 1: def
- Any old stuff
- 0: ff
- 1: ff
- *** Failers
-No match
- 0zzz
-No match
- gzzz
-No match
- fed\x20
-No match
- Any old rubbish
-No match
-
-/^.*\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/
- .1.2.3
- 0: .1.2.3
- 1: 1
- 2: 2
- 3: 3
- A.12.123.0
- 0: A.12.123.0
- 1: 12
- 2: 123
- 3: 0
- *** Failers
-No match
- .1.2.3333
-No match
- 1.2.3
-No match
- 1234.2.3
-No match
-
-/^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
- 1 IN SOA non-sp1 non-sp2(
- 0: 1 IN SOA non-sp1 non-sp2(
- 1: 1
- 2: non-sp1
- 3: non-sp2
- 1 IN SOA non-sp1 non-sp2 (
- 0: 1 IN SOA non-sp1 non-sp2 (
- 1: 1
- 2: non-sp1
- 3: non-sp2
- *** Failers
-No match
- 1IN SOA non-sp1 non-sp2(
-No match
-
-/^[a-zA-Z\d][a-zA-Z\d\-]*(\.[a-zA-Z\d][a-zA-z\d\-]*)*\.$/
- a.
- 0: a.
- Z.
- 0: Z.
- 2.
- 0: 2.
- ab-c.pq-r.
- 0: ab-c.pq-r.
- 1: .pq-r
- sxk.zzz.ac.uk.
- 0: sxk.zzz.ac.uk.
- 1: .uk
- x-.y-.
- 0: x-.y-.
- 1: .y-
- *** Failers
-No match
- -abc.peq.
-No match
-
-/^\*\.[a-z]([a-z\-\d]*[a-z\d]+)?(\.[a-z]([a-z\-\d]*[a-z\d]+)?)*$/
- *.a
- 0: *.a
- *.b0-a
- 0: *.b0-a
- 1: 0-a
- *.c3-b.c
- 0: *.c3-b.c
- 1: 3-b
- 2: .c
- *.c-a.b-c
- 0: *.c-a.b-c
- 1: -a
- 2: .b-c
- 3: -c
- *** Failers
-No match
- *.0
-No match
- *.a-
-No match
- *.a-b.c-
-No match
- *.c-a.0-c
-No match
-
-/^(?=ab(de))(abd)(e)/
- abde
- 0: abde
- 1: de
- 2: abd
- 3: e
-
-/^(?!(ab)de|x)(abd)(f)/
- abdf
- 0: abdf
- 1: <unset>
- 2: abd
- 3: f
-
-/^(?=(ab(cd)))(ab)/
- abcd
- 0: ab
- 1: abcd
- 2: cd
- 3: ab
-
-/^[\da-f](\.[\da-f])*$/i
- a.b.c.d
- 0: a.b.c.d
- 1: .d
- A.B.C.D
- 0: A.B.C.D
- 1: .D
- a.b.c.1.2.3.C
- 0: a.b.c.1.2.3.C
- 1: .C
-
-/^\".*\"\s*(;.*)?$/
- \"1234\"
- 0: "1234"
- \"abcd\" ;
- 0: "abcd" ;
- 1: ;
- \"\" ; rhubarb
- 0: "" ; rhubarb
- 1: ; rhubarb
- *** Failers
-No match
- \"1234\" : things
-No match
-
-/^$/
- \
- 0:
- *** Failers
-No match
-
-/ ^ a (?# begins with a) b\sc (?# then b c) $ (?# then end)/x
- ab c
- 0: ab c
- *** Failers
-No match
- abc
-No match
- ab cde
-No match
-
-/(?x) ^ a (?# begins with a) b\sc (?# then b c) $ (?# then end)/
- ab c
- 0: ab c
- *** Failers
-No match
- abc
-No match
- ab cde
-No match
-
-/^ a\ b[c ]d $/x
- a bcd
- 0: a bcd
- a b d
- 0: a b d
- *** Failers
-No match
- abcd
-No match
- ab d
-No match
-
-/^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$/
- abcdefhijklm
- 0: abcdefhijklm
- 1: abc
- 2: bc
- 3: c
- 4: def
- 5: ef
- 6: f
- 7: hij
- 8: ij
- 9: j
-10: klm
-11: lm
-12: m
-
-/^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$/
- abcdefhijklm
- 0: abcdefhijklm
- 1: bc
- 2: c
- 3: ef
- 4: f
- 5: ij
- 6: j
- 7: lm
- 8: m
-
-/^[\w][\W][\s][\S][\d][\D][\b][\n][\c]][\022]/
- a+ Z0+\x08\n\x1d\x12
- 0: a+ Z0+\x08\x0a\x1d\x12
-
-/^[.^$|()*+?{,}]+/
- .^\$(*+)|{?,?}
- 0: .^$(*+)|{?,?}
-
-/^a*\w/
- z
- 0: z
- az
- 0: az
- aaaz
- 0: aaaz
- a
- 0: a
- aa
- 0: aa
- aaaa
- 0: aaaa
- a+
- 0: a
- aa+
- 0: aa
-
-/^a*?\w/
- z
- 0: z
- az
- 0: a
- aaaz
- 0: a
- a
- 0: a
- aa
- 0: a
- aaaa
- 0: a
- a+
- 0: a
- aa+
- 0: a
-
-/^a+\w/
- az
- 0: az
- aaaz
- 0: aaaz
- aa
- 0: aa
- aaaa
- 0: aaaa
- aa+
- 0: aa
-
-/^a+?\w/
- az
- 0: az
- aaaz
- 0: aa
- aa
- 0: aa
- aaaa
- 0: aa
- aa+
- 0: aa
-
-/^\d{8}\w{2,}/
- 1234567890
- 0: 1234567890
- 12345678ab
- 0: 12345678ab
- 12345678__
- 0: 12345678__
- *** Failers
-No match
- 1234567
-No match
-
-/^[aeiou\d]{4,5}$/
- uoie
- 0: uoie
- 1234
- 0: 1234
- 12345
- 0: 12345
- aaaaa
- 0: aaaaa
- *** Failers
-No match
- 123456
-No match
-
-/^[aeiou\d]{4,5}?/
- uoie
- 0: uoie
- 1234
- 0: 1234
- 12345
- 0: 1234
- aaaaa
- 0: aaaa
- 123456
- 0: 1234
-
-/\A(abc|def)=(\1){2,3}\Z/
- abc=abcabc
- 0: abc=abcabc
- 1: abc
- 2: abc
- def=defdefdef
- 0: def=defdefdef
- 1: def
- 2: def
- *** Failers
-No match
- abc=defdef
-No match
-
-/^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\11*(\3\4)\1(?#)2$/
- abcdefghijkcda2
- 0: abcdefghijkcda2
- 1: a
- 2: b
- 3: c
- 4: d
- 5: e
- 6: f
- 7: g
- 8: h
- 9: i
-10: j
-11: k
-12: cd
- abcdefghijkkkkcda2
- 0: abcdefghijkkkkcda2
- 1: a
- 2: b
- 3: c
- 4: d
- 5: e
- 6: f
- 7: g
- 8: h
- 9: i
-10: j
-11: k
-12: cd
-
-/(cat(a(ract|tonic)|erpillar)) \1()2(3)/
- cataract cataract23
- 0: cataract cataract23
- 1: cataract
- 2: aract
- 3: ract
- 4:
- 5: 3
- catatonic catatonic23
- 0: catatonic catatonic23
- 1: catatonic
- 2: atonic
- 3: tonic
- 4:
- 5: 3
- caterpillar caterpillar23
- 0: caterpillar caterpillar23
- 1: caterpillar
- 2: erpillar
- 3: <unset>
- 4:
- 5: 3
-
-
-/^From +([^ ]+) +[a-zA-Z][a-zA-Z][a-zA-Z] +[a-zA-Z][a-zA-Z][a-zA-Z] +[0-9]?[0-9] +[0-9][0-9]:[0-9][0-9]/
- From abcd Mon Sep 01 12:33:02 1997
- 0: From abcd Mon Sep 01 12:33
- 1: abcd
-
-/^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/
- From abcd Mon Sep 01 12:33:02 1997
- 0: From abcd Mon Sep 01 12:33
- 1: Sep
- From abcd Mon Sep 1 12:33:02 1997
- 0: From abcd Mon Sep 1 12:33
- 1: Sep
- *** Failers
-No match
- From abcd Sep 01 12:33:02 1997
-No match
-
-/^12.34/s
- 12\n34
- 0: 12\x0a34
- 12\r34
- 0: 12\x0d34
-
-/\w+(?=\t)/
- the quick brown\t fox
- 0: brown
-
-/foo(?!bar)(.*)/
- foobar is foolish see?
- 0: foolish see?
- 1: lish see?
-
-/(?:(?!foo)...|^.{0,2})bar(.*)/
- foobar crowbar etc
- 0: rowbar etc
- 1: etc
- barrel
- 0: barrel
- 1: rel
- 2barrel
- 0: 2barrel
- 1: rel
- A barrel
- 0: A barrel
- 1: rel
-
-/^(\D*)(?=\d)(?!123)/
- abc456
- 0: abc
- 1: abc
- *** Failers
-No match
- abc123
-No match
-
-/^1234(?# test newlines
- inside)/
- 1234
- 0: 1234
-
-/^1234 #comment in extended re
- /x
- 1234
- 0: 1234
-
-/#rhubarb
- abcd/x
- abcd
- 0: abcd
-
-/^abcd#rhubarb/x
- abcd
- 0: abcd
-
-/^(a)\1{2,3}(.)/
- aaab
- 0: aaab
- 1: a
- 2: b
- aaaab
- 0: aaaab
- 1: a
- 2: b
- aaaaab
- 0: aaaaa
- 1: a
- 2: a
- aaaaaab
- 0: aaaaa
- 1: a
- 2: a
-
-/(?!^)abc/
- the abc
- 0: abc
- *** Failers
-No match
- abc
-No match
-
-/(?=^)abc/
- abc
- 0: abc
- *** Failers
-No match
- the abc
-No match
-
-/^[ab]{1,3}(ab*|b)/
- aabbbbb
- 0: aabb
- 1: b
-
-/^[ab]{1,3}?(ab*|b)/
- aabbbbb
- 0: aabbbbb
- 1: abbbbb
-
-/^[ab]{1,3}?(ab*?|b)/
- aabbbbb
- 0: aa
- 1: a
-
-/^[ab]{1,3}(ab*?|b)/
- aabbbbb
- 0: aabb
- 1: b
-
-/ (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* # optional leading comment
-(?: (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-" (?: # opening quote...
-[^\\\x80-\xff\n\015"] # Anything except backslash and quote
-| # or
-\\ [^\x80-\xff] # Escaped something (something != CR)
-)* " # closing quote
-) # initial word
-(?: (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* \. (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-" (?: # opening quote...
-[^\\\x80-\xff\n\015"] # Anything except backslash and quote
-| # or
-\\ [^\x80-\xff] # Escaped something (something != CR)
-)* " # closing quote
-) )* # further okay, if led by a period
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* @ (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-| \[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-) # initial subdomain
-(?: #
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* \. # if led by a period...
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-| \[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-) # ...further okay
-)*
-# address
-| # or
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-" (?: # opening quote...
-[^\\\x80-\xff\n\015"] # Anything except backslash and quote
-| # or
-\\ [^\x80-\xff] # Escaped something (something != CR)
-)* " # closing quote
-) # one word, optionally followed by....
-(?:
-[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] | # atom and space parts, or...
-\(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) | # comments, or...
-
-" (?: # opening quote...
-[^\\\x80-\xff\n\015"] # Anything except backslash and quote
-| # or
-\\ [^\x80-\xff] # Escaped something (something != CR)
-)* " # closing quote
-# quoted strings
-)*
-< (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* # leading <
-(?: @ (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-| \[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-) # initial subdomain
-(?: #
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* \. # if led by a period...
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-| \[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-) # ...further okay
-)*
-
-(?: (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* , (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* @ (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-| \[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-) # initial subdomain
-(?: #
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* \. # if led by a period...
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-| \[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-) # ...further okay
-)*
-)* # further okay, if led by comma
-: # closing colon
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* )? # optional route
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-" (?: # opening quote...
-[^\\\x80-\xff\n\015"] # Anything except backslash and quote
-| # or
-\\ [^\x80-\xff] # Escaped something (something != CR)
-)* " # closing quote
-) # initial word
-(?: (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* \. (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-" (?: # opening quote...
-[^\\\x80-\xff\n\015"] # Anything except backslash and quote
-| # or
-\\ [^\x80-\xff] # Escaped something (something != CR)
-)* " # closing quote
-) )* # further okay, if led by a period
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* @ (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-| \[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-) # initial subdomain
-(?: #
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* \. # if led by a period...
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* (?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-| \[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-) # ...further okay
-)*
-# address spec
-(?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* > # trailing >
-# name and address
-) (?: [\040\t] | \(
-(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
-\) )* # optional trailing comment
-/x
- Alan Other <user\@dom.ain>
- 0: Alan Other <user@dom.ain>
- <user\@dom.ain>
- 0: user@dom.ain
- user\@dom.ain
- 0: user@dom.ain
- \"A. Other\" <user.1234\@dom.ain> (a comment)
- 0: "A. Other" <user.1234@dom.ain> (a comment)
- A. Other <user.1234\@dom.ain> (a comment)
- 0: Other <user.1234@dom.ain> (a comment)
- \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
- 0: "/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/"@x400-re.lay
- A missing angle <user\@some.where
- 0: user@some.where
- *** Failers
-No match
- The quick brown fox
-No match
-
-/[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional leading comment
-(?:
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-# Atom
-| # or
-" # "
-[^\\\x80-\xff\n\015"] * # normal
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
-" # "
-# Quoted string
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-\.
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-# Atom
-| # or
-" # "
-[^\\\x80-\xff\n\015"] * # normal
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
-" # "
-# Quoted string
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# additional words
-)*
-@
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-\[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-(?:
-\.
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-\[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-)*
-# address
-| # or
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-# Atom
-| # or
-" # "
-[^\\\x80-\xff\n\015"] * # normal
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
-" # "
-# Quoted string
-)
-# leading word
-[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] * # "normal" atoms and or spaces
-(?:
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-|
-" # "
-[^\\\x80-\xff\n\015"] * # normal
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
-" # "
-) # "special" comment or quoted string
-[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] * # more "normal"
-)*
-<
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# <
-(?:
-@
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-\[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-(?:
-\.
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-\[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-)*
-(?: ,
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-@
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-\[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-(?:
-\.
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-\[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-)*
-)* # additional domains
-:
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-)? # optional route
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-# Atom
-| # or
-" # "
-[^\\\x80-\xff\n\015"] * # normal
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
-" # "
-# Quoted string
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-\.
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-# Atom
-| # or
-" # "
-[^\\\x80-\xff\n\015"] * # normal
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
-" # "
-# Quoted string
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# additional words
-)*
-@
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-\[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-(?:
-\.
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-(?:
-[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
-(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
-|
-\[ # [
-(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
-\] # ]
-)
-[\040\t]* # Nab whitespace.
-(?:
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: # (
-(?: \\ [^\x80-\xff] |
-\( # (
-[^\\\x80-\xff\n\015()] * # normal*
-(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
-\) # )
-) # special
-[^\\\x80-\xff\n\015()] * # normal*
-)* # )*
-\) # )
-[\040\t]* )* # If comment found, allow more spaces.
-# optional trailing comments
-)*
-# address spec
-> # >
-# name and address
-)
-/x
- Alan Other <user\@dom.ain>
- 0: Alan Other <user@dom.ain>
- <user\@dom.ain>
- 0: user@dom.ain
- user\@dom.ain
- 0: user@dom.ain
- \"A. Other\" <user.1234\@dom.ain> (a comment)
- 0: "A. Other" <user.1234@dom.ain>
- A. Other <user.1234\@dom.ain> (a comment)
- 0: Other <user.1234@dom.ain>
- \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
- 0: "/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/"@x400-re.lay
- A missing angle <user\@some.where
- 0: user@some.where
- *** Failers
-No match
- The quick brown fox
-No match
-
-/abc\0def\00pqr\000xyz\0000AB/
- abc\0def\00pqr\000xyz\0000AB
- 0: abc\x00def\x00pqr\x00xyz\x000AB
- abc456 abc\0def\00pqr\000xyz\0000ABCDE
- 0: abc\x00def\x00pqr\x00xyz\x000AB
-
-/abc\x0def\x00pqr\x000xyz\x0000AB/
- abc\x0def\x00pqr\x000xyz\x0000AB
- 0: abc\x0def\x00pqr\x000xyz\x0000AB
- abc456 abc\x0def\x00pqr\x000xyz\x0000ABCDE
- 0: abc\x0def\x00pqr\x000xyz\x0000AB
-
-/^[\000-\037]/
- \0A
- 0: \x00
- \01B
- 0: \x01
- \037C
- 0: \x1f
-
-/\0*/
- \0\0\0\0
- 0: \x00\x00\x00\x00
-
-/A\x0{2,3}Z/
- The A\x0\x0Z
- 0: A\x00\x00Z
- An A\0\x0\0Z
- 0: A\x00\x00\x00Z
- *** Failers
-No match
- A\0Z
-No match
- A\0\x0\0\x0Z
-No match
-
-/^(cow|)\1(bell)/
- cowcowbell
- 0: cowcowbell
- 1: cow
- 2: bell
- bell
- 0: bell
- 1:
- 2: bell
- *** Failers
-No match
- cowbell
-No match
-
-/^\s/
- \040abc
- 0:
- \x0cabc
- 0: \x0c
- \nabc
- 0: \x0a
- \rabc
- 0: \x0d
- \tabc
- 0: \x09
- *** Failers
-No match
- abc
-No match
-
-/^a b
-
- c/x
- abc
- 0: abc
-
-/^(a|)\1*b/
- ab
- 0: ab
- 1: a
- aaaab
- 0: aaaab
- 1: a
- b
- 0: b
- 1:
- *** Failers
-No match
- acb
-No match
-
-/^(a|)\1+b/
- aab
- 0: aab
- 1: a
- aaaab
- 0: aaaab
- 1: a
- b
- 0: b
- 1:
- *** Failers
-No match
- ab
-No match
-
-/^(a|)\1?b/
- ab
- 0: ab
- 1: a
- aab
- 0: aab
- 1: a
- b
- 0: b
- 1:
- *** Failers
-No match
- acb
-No match
-
-/^(a|)\1{2}b/
- aaab
- 0: aaab
- 1: a
- b
- 0: b
- 1:
- *** Failers
-No match
- ab
-No match
- aab
-No match
- aaaab
-No match
-
-/^(a|)\1{2,3}b/
- aaab
- 0: aaab
- 1: a
- aaaab
- 0: aaaab
- 1: a
- b
- 0: b
- 1:
- *** Failers
-No match
- ab
-No match
- aab
-No match
- aaaaab
-No match
-
-/ab{1,3}bc/
- abbbbc
- 0: abbbbc
- abbbc
- 0: abbbc
- abbc
- 0: abbc
- *** Failers
-No match
- abc
-No match
- abbbbbc
-No match
-
-/([^.]*)\.([^:]*):[T ]+(.*)/
- track1.title:TBlah blah blah
- 0: track1.title:TBlah blah blah
- 1: track1
- 2: title
- 3: Blah blah blah
-
-/([^.]*)\.([^:]*):[T ]+(.*)/i
- track1.title:TBlah blah blah
- 0: track1.title:TBlah blah blah
- 1: track1
- 2: title
- 3: Blah blah blah
-
-/([^.]*)\.([^:]*):[t ]+(.*)/i
- track1.title:TBlah blah blah
- 0: track1.title:TBlah blah blah
- 1: track1
- 2: title
- 3: Blah blah blah
-
-/^[W-c]+$/
- WXY_^abc
- 0: WXY_^abc
- ***Failers
-No match
- wxy
-No match
-
-/^[W-c]+$/i
- WXY_^abc
- 0: WXY_^abc
- wxy_^ABC
- 0: wxy_^ABC
-
-/^[\x3f-\x5F]+$/i
- WXY_^abc
- 0: WXY_^abc
- wxy_^ABC
- 0: wxy_^ABC
-
-/^abc$/m
- abc
- 0: abc
- qqq\nabc
- 0: abc
- abc\nzzz
- 0: abc
- qqq\nabc\nzzz
- 0: abc
-
-/^abc$/
- abc
- 0: abc
- *** Failers
-No match
- qqq\nabc
-No match
- abc\nzzz
-No match
- qqq\nabc\nzzz
-No match
-
-/\Aabc\Z/m
- abc
- 0: abc
- abc\n
- 0: abc
- *** Failers
-No match
- qqq\nabc
-No match
- abc\nzzz
-No match
- qqq\nabc\nzzz
-No match
-
-/\A(.)*\Z/s
- abc\ndef
- 0: abc\x0adef
- 1: f
-
-/\A(.)*\Z/m
- *** Failers
- 0: *** Failers
- 1: s
- abc\ndef
-No match
-
-/(?:b)|(?::+)/
- b::c
- 0: b
- c::b
- 0: ::
-
-/[-az]+/
- az-
- 0: az-
- *** Failers
- 0: a
- b
-No match
-
-/[az-]+/
- za-
- 0: za-
- *** Failers
- 0: a
- b
-No match
-
-/[a\-z]+/
- a-z
- 0: a-z
- *** Failers
- 0: a
- b
-No match
-
-/[a-z]+/
- abcdxyz
- 0: abcdxyz
-
-/[\d-]+/
- 12-34
- 0: 12-34
- *** Failers
-No match
- aaa
-No match
-
-/[\d-z]+/
- 12-34z
- 0: 12-34z
- *** Failers
-No match
- aaa
-No match
-
-/\x5c/
- \\
- 0: \
-
-/\x20Z/
- the Zoo
- 0: Z
- *** Failers
-No match
- Zulu
-No match
-
-/(abc)\1/i
- abcabc
- 0: abcabc
- 1: abc
- ABCabc
- 0: ABCabc
- 1: ABC
- abcABC
- 0: abcABC
- 1: abc
-
-/(main(O)?)+/
- mainmain
- 0: mainmain
- 1: main
- mainOmain
- 0: mainOmain
- 1: main
- 2: O
-
-/ab{3cd/
- ab{3cd
- 0: ab{3cd
-
-/ab{3,cd/
- ab{3,cd
- 0: ab{3,cd
-
-/ab{3,4a}cd/
- ab{3,4a}cd
- 0: ab{3,4a}cd
-
-/{4,5a}bc/
- {4,5a}bc
- 0: {4,5a}bc
-
-/^a.b/
- a\rb
- 0: a\x0db
- *** Failers
-No match
- a\nb
-No match
-
-/abc$/
- abc
- 0: abc
- abc\n
- 0: abc
- *** Failers
-No match
- abc\ndef
-No match
-
-/(abc)\123/
- abc\x53
- 0: abcS
- 1: abc
-
-/(abc)\223/
- abc\x93
- 0: abc\x93
- 1: abc
-
-/(abc)\323/
- abc\xd3
- 0: abc\xd3
- 1: abc
-
-/(abc)\500/
- abc\x40
- 0: abc@
- 1: abc
- abc\100
- 0: abc@
- 1: abc
-
-/(abc)\5000/
- abc\x400
- 0: abc@0
- 1: abc
- abc\x40\x30
- 0: abc@0
- 1: abc
- abc\1000
- 0: abc@0
- 1: abc
- abc\100\x30
- 0: abc@0
- 1: abc
- abc\100\060
- 0: abc@0
- 1: abc
- abc\100\60
- 0: abc@0
- 1: abc
-
-/abc\81/
- abc\081
- 0: abc\x0081
- abc\0\x38\x31
- 0: abc\x0081
-
-/abc\91/
- abc\091
- 0: abc\x0091
- abc\0\x39\x31
- 0: abc\x0091
-
-/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\12\123/
- abcdefghijkllS
- 0: abcdefghijkllS
- 1: a
- 2: b
- 3: c
- 4: d
- 5: e
- 6: f
- 7: g
- 8: h
- 9: i
-10: j
-11: k
-12: l
-
-/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123/
- abcdefghijk\12S
- 0: abcdefghijk\x0aS
- 1: a
- 2: b
- 3: c
- 4: d
- 5: e
- 6: f
- 7: g
- 8: h
- 9: i
-10: j
-11: k
-
-/ab\gdef/
- abgdef
- 0: abgdef
-
-/a{0}bc/
- bc
- 0: bc
-
-/(a|(bc)){0,0}?xyz/
- xyz
- 0: xyz
-
-/abc[\10]de/
- abc\010de
- 0: abc\x08de
-
-/abc[\1]de/
- abc\1de
- 0: abc\x01de
-
-/(abc)[\1]de/
- abc\1de
- 0: abc\x01de
- 1: abc
-
-/a.b(?s)/
- a\nb
- 0: a\x0ab
-
-/^([^a])([^\b])([^c]*)([^d]{3,4})/
- baNOTccccd
- 0: baNOTcccc
- 1: b
- 2: a
- 3: NOT
- 4: cccc
- baNOTcccd
- 0: baNOTccc
- 1: b
- 2: a
- 3: NOT
- 4: ccc
- baNOTccd
- 0: baNOTcc
- 1: b
- 2: a
- 3: NO
- 4: Tcc
- bacccd
- 0: baccc
- 1: b
- 2: a
- 3:
- 4: ccc
- *** Failers
- 0: *** Failers
- 1: *
- 2: *
- 3: * Fail
- 4: ers
- anything
-No match
- b\bc
-No match
- baccd
-No match
-
-/[^a]/
- Abc
- 0: A
-
-/[^a]/i
- Abc
- 0: b
-
-/[^a]+/
- AAAaAbc
- 0: AAA
-
-/[^a]+/i
- AAAaAbc
- 0: bc
-
-/[^a]+/
- bbb\nccc
- 0: bbb\x0accc
-
-/[^k]$/
- abc
- 0: c
- *** Failers
- 0: s
- abk
-No match
-
-/[^k]{2,3}$/
- abc
- 0: abc
- kbc
- 0: bc
- kabc
- 0: abc
- *** Failers
- 0: ers
- abk
-No match
- akb
-No match
- akk
-No match
-
-/^\d{8,}\@.+[^k]$/
- 12345678\@a.b.c.d
- 0: 12345678@a.b.c.d
- 123456789\@x.y.z
- 0: 123456789@x.y.z
- *** Failers
-No match
- 12345678\@x.y.uk
-No match
- 1234567\@a.b.c.d
-No match
-
-/(a)\1{8,}/
- aaaaaaaaa
- 0: aaaaaaaaa
- 1: a
- aaaaaaaaaa
- 0: aaaaaaaaaa
- 1: a
- *** Failers
-No match
- aaaaaaa
-No match
-
-/[^a]/
- aaaabcd
- 0: b
- aaAabcd
- 0: A
-
-/[^a]/i
- aaaabcd
- 0: b
- aaAabcd
- 0: b
-
-/[^az]/
- aaaabcd
- 0: b
- aaAabcd
- 0: A
-
-/[^az]/i
- aaaabcd
- 0: b
- aaAabcd
- 0: b
-
-/\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377/
- \000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377
- 0: \x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff
-
-/P[^*]TAIRE[^*]{1,6}?LL/
- xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
- 0: PSTAIREISLL
-
-/P[^*]TAIRE[^*]{1,}?LL/
- xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
- 0: PSTAIREISLL
-
-/(\.\d\d[1-9]?)\d+/
- 1.230003938
- 0: .230003938
- 1: .23
- 1.875000282
- 0: .875000282
- 1: .875
- 1.235
- 0: .235
- 1: .23
-
-/(\.\d\d((?=0)|\d(?=\d)))/
- 1.230003938
- 0: .23
- 1: .23
- 2:
- 1.875000282
- 0: .875
- 1: .875
- 2: 5
- *** Failers
-No match
- 1.235
-No match
-
-/a(?)b/
- ab
- 0: ab
-
-/\b(foo)\s+(\w+)/i
- Food is on the foo table
- 0: foo table
- 1: foo
- 2: table
-
-/foo(.*)bar/
- The food is under the bar in the barn.
- 0: food is under the bar in the bar
- 1: d is under the bar in the
-
-/foo(.*?)bar/
- The food is under the bar in the barn.
- 0: food is under the bar
- 1: d is under the
-
-/(.*)(\d*)/
- I have 2 numbers: 53147
- 0: I have 2 numbers: 53147
- 1: I have 2 numbers: 53147
- 2:
-
-/(.*)(\d+)/
- I have 2 numbers: 53147
- 0: I have 2 numbers: 53147
- 1: I have 2 numbers: 5314
- 2: 7
-
-/(.*?)(\d*)/
- I have 2 numbers: 53147
- 0:
- 1:
- 2:
-
-/(.*?)(\d+)/
- I have 2 numbers: 53147
- 0: I have 2
- 1: I have
- 2: 2
-
-/(.*)(\d+)$/
- I have 2 numbers: 53147
- 0: I have 2 numbers: 53147
- 1: I have 2 numbers: 5314
- 2: 7
-
-/(.*?)(\d+)$/
- I have 2 numbers: 53147
- 0: I have 2 numbers: 53147
- 1: I have 2 numbers:
- 2: 53147
-
-/(.*)\b(\d+)$/
- I have 2 numbers: 53147
- 0: I have 2 numbers: 53147
- 1: I have 2 numbers:
- 2: 53147
-
-/(.*\D)(\d+)$/
- I have 2 numbers: 53147
- 0: I have 2 numbers: 53147
- 1: I have 2 numbers:
- 2: 53147
-
-/^\D*(?!123)/
- ABC123
- 0: AB
-
-/^(\D*)(?=\d)(?!123)/
- ABC445
- 0: ABC
- 1: ABC
- *** Failers
-No match
- ABC123
-No match
-
-/^[W-]46]/
- W46]789
- 0: W46]
- -46]789
- 0: -46]
- *** Failers
-No match
- Wall
-No match
- Zebra
-No match
- 42
-No match
- [abcd]
-No match
- ]abcd[
-No match
-
-/^[W-\]46]/
- W46]789
- 0: W
- Wall
- 0: W
- Zebra
- 0: Z
- Xylophone
- 0: X
- 42
- 0: 4
- [abcd]
- 0: [
- ]abcd[
- 0: ]
- \\backslash
- 0: \
- *** Failers
-No match
- -46]789
-No match
- well
-No match
-
-/\d\d\/\d\d\/\d\d\d\d/
- 01/01/2000
- 0: 01/01/2000
-
-/word (?:[a-zA-Z0-9]+ ){0,10}otherword/
- word cat dog elephant mussel cow horse canary baboon snake shark otherword
- 0: word cat dog elephant mussel cow horse canary baboon snake shark otherword
- word cat dog elephant mussel cow horse canary baboon snake shark
-No match
-
-/word (?:[a-zA-Z0-9]+ ){0,300}otherword/
- word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
-No match
-
-/^(a){0,0}/
- bcd
- 0:
- abc
- 0:
- aab
- 0:
-
-/^(a){0,1}/
- bcd
- 0:
- abc
- 0: a
- 1: a
- aab
- 0: a
- 1: a
-
-/^(a){0,2}/
- bcd
- 0:
- abc
- 0: a
- 1: a
- aab
- 0: aa
- 1: a
-
-/^(a){0,3}/
- bcd
- 0:
- abc
- 0: a
- 1: a
- aab
- 0: aa
- 1: a
- aaa
- 0: aaa
- 1: a
-
-/^(a){0,}/
- bcd
- 0:
- abc
- 0: a
- 1: a
- aab
- 0: aa
- 1: a
- aaa
- 0: aaa
- 1: a
- aaaaaaaa
- 0: aaaaaaaa
- 1: a
-
-/^(a){1,1}/
- bcd
-No match
- abc
- 0: a
- 1: a
- aab
- 0: a
- 1: a
-
-/^(a){1,2}/
- bcd
-No match
- abc
- 0: a
- 1: a
- aab
- 0: aa
- 1: a
-
-/^(a){1,3}/
- bcd
-No match
- abc
- 0: a
- 1: a
- aab
- 0: aa
- 1: a
- aaa
- 0: aaa
- 1: a
-
-/^(a){1,}/
- bcd
-No match
- abc
- 0: a
- 1: a
- aab
- 0: aa
- 1: a
- aaa
- 0: aaa
- 1: a
- aaaaaaaa
- 0: aaaaaaaa
- 1: a
-
-/.*\.gif/
- borfle\nbib.gif\nno
- 0: bib.gif
-
-/.{0,}\.gif/
- borfle\nbib.gif\nno
- 0: bib.gif
-
-/.*\.gif/m
- borfle\nbib.gif\nno
- 0: bib.gif
-
-/.*\.gif/s
- borfle\nbib.gif\nno
- 0: borfle\x0abib.gif
-
-/.*\.gif/ms
- borfle\nbib.gif\nno
- 0: borfle\x0abib.gif
-
-/.*$/
- borfle\nbib.gif\nno
- 0: no
-
-/.*$/m
- borfle\nbib.gif\nno
- 0: borfle
-
-/.*$/s
- borfle\nbib.gif\nno
- 0: borfle\x0abib.gif\x0ano
-
-/.*$/ms
- borfle\nbib.gif\nno
- 0: borfle\x0abib.gif\x0ano
-
-/.*$/
- borfle\nbib.gif\nno\n
- 0: no
-
-/.*$/m
- borfle\nbib.gif\nno\n
- 0: borfle
-
-/.*$/s
- borfle\nbib.gif\nno\n
- 0: borfle\x0abib.gif\x0ano\x0a
-
-/.*$/ms
- borfle\nbib.gif\nno\n
- 0: borfle\x0abib.gif\x0ano\x0a
-
-/(.*X|^B)/
- abcde\n1234Xyz
- 0: 1234X
- 1: 1234X
- BarFoo
- 0: B
- 1: B
- *** Failers
-No match
- abcde\nBar
-No match
-
-/(.*X|^B)/m
- abcde\n1234Xyz
- 0: 1234X
- 1: 1234X
- BarFoo
- 0: B
- 1: B
- abcde\nBar
- 0: B
- 1: B
-
-/(.*X|^B)/s
- abcde\n1234Xyz
- 0: abcde\x0a1234X
- 1: abcde\x0a1234X
- BarFoo
- 0: B
- 1: B
- *** Failers
-No match
- abcde\nBar
-No match
-
-/(.*X|^B)/ms
- abcde\n1234Xyz
- 0: abcde\x0a1234X
- 1: abcde\x0a1234X
- BarFoo
- 0: B
- 1: B
- abcde\nBar
- 0: B
- 1: B
-
-/(?s)(.*X|^B)/
- abcde\n1234Xyz
- 0: abcde\x0a1234X
- 1: abcde\x0a1234X
- BarFoo
- 0: B
- 1: B
- *** Failers
-No match
- abcde\nBar
-No match
-
-/(?s:.*X|^B)/
- abcde\n1234Xyz
- 0: abcde\x0a1234X
- BarFoo
- 0: B
- *** Failers
-No match
- abcde\nBar
-No match
-
-/^.*B/
- **** Failers
-No match
- abc\nB
-No match
-
-/(?s)^.*B/
- abc\nB
- 0: abc\x0aB
-
-/(?m)^.*B/
- abc\nB
- 0: B
-
-/(?ms)^.*B/
- abc\nB
- 0: abc\x0aB
-
-/(?ms)^B/
- abc\nB
- 0: B
-
-/(?s)B$/
- B\n
- 0: B
-
-/^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/
- 123456654321
- 0: 123456654321
-
-/^\d\d\d\d\d\d\d\d\d\d\d\d/
- 123456654321
- 0: 123456654321
-
-/^[\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d]/
- 123456654321
- 0: 123456654321
-
-/^[abc]{12}/
- abcabcabcabc
- 0: abcabcabcabc
-
-/^[a-c]{12}/
- abcabcabcabc
- 0: abcabcabcabc
-
-/^(a|b|c){12}/
- abcabcabcabc
- 0: abcabcabcabc
- 1: c
-
-/^[abcdefghijklmnopqrstuvwxy0123456789]/
- n
- 0: n
- *** Failers
-No match
- z
-No match
-
-/abcde{0,0}/
- abcd
- 0: abcd
- *** Failers
-No match
- abce
-No match
-
-/ab[cd]{0,0}e/
- abe
- 0: abe
- *** Failers
-No match
- abcde
-No match
-
-/ab(c){0,0}d/
- abd
- 0: abd
- *** Failers
-No match
- abcd
-No match
-
-/a(b*)/
- a
- 0: a
- 1:
- ab
- 0: ab
- 1: b
- abbbb
- 0: abbbb
- 1: bbbb
- *** Failers
- 0: a
- 1:
- bbbbb
-No match
-
-/ab\d{0}e/
- abe
- 0: abe
- *** Failers
-No match
- ab1e
-No match
-
-/"([^\\"]+|\\.)*"/
- the \"quick\" brown fox
- 0: "quick"
- 1: quick
- \"the \\\"quick\\\" brown fox\"
- 0: "the \"quick\" brown fox"
- 1: brown fox
-
-/ End of test input /
-
diff --git a/ext/pcre/pcrelib/testoutput2 b/ext/pcre/pcrelib/testoutput2
deleted file mode 100644
index 5950a913e3..0000000000
--- a/ext/pcre/pcrelib/testoutput2
+++ /dev/null
@@ -1,1624 +0,0 @@
-PCRE version 2.08 31-Aug-1999
-
-/(a)b|/
-Identifying subpattern count = 1
-No options
-No first char
-No req char
-
-/abc/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-Req char = 'c'
- abc
- 0: abc
- defabc
- 0: abc
- \Aabc
- 0: abc
- *** Failers
-No match
- \Adefabc
-No match
- ABC
-No match
-
-/^abc/
-Identifying subpattern count = 0
-Options: anchored
-No first char
-Req char = 'c'
- abc
- 0: abc
- \Aabc
- 0: abc
- *** Failers
-No match
- defabc
-No match
- \Adefabc
-No match
-
-/a+bc/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-Req char = 'c'
-
-/a*bc/
-Identifying subpattern count = 0
-No options
-No first char
-Req char = 'c'
-
-/a{3}bc/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-Req char = 'c'
-
-/(abc|a+z)/
-Identifying subpattern count = 1
-No options
-First char = 'a'
-No req char
-
-/^abc$/
-Identifying subpattern count = 0
-Options: anchored
-No first char
-Req char = 'c'
- abc
- 0: abc
- *** Failers
-No match
- def\nabc
-No match
-
-/ab\gdef/X
-Failed: unrecognized character follows \ at offset 3
-
-/(?X)ab\gdef/X
-Failed: unrecognized character follows \ at offset 7
-
-/x{5,4}/
-Failed: numbers out of order in {} quantifier at offset 5
-
-/z{65536}/
-Failed: number too big in {} quantifier at offset 7
-
-/[abcd/
-Failed: missing terminating ] for character class at offset 5
-
-/[\B]/
-Failed: invalid escape sequence in character class at offset 2
-
-/[a-\w]/
-Failed: invalid escape sequence in character class at offset 4
-
-/[z-a]/
-Failed: range out of order in character class at offset 3
-
-/^*/
-Failed: nothing to repeat at offset 1
-
-/(abc/
-Failed: missing ) at offset 4
-
-/(?# abc/
-Failed: missing ) after comment at offset 7
-
-/(?z)abc/
-Failed: unrecognized character after (? at offset 2
-
-/.*b/
-Identifying subpattern count = 0
-No options
-First char at start or follows \n
-Req char = 'b'
-
-/.*?b/
-Identifying subpattern count = 0
-No options
-First char at start or follows \n
-Req char = 'b'
-
-/cat|dog|elephant/
-Identifying subpattern count = 0
-No options
-No first char
-No req char
- this sentence eventually mentions a cat
- 0: cat
- this sentences rambles on and on for a while and then reaches elephant
- 0: elephant
-
-/cat|dog|elephant/S
-Identifying subpattern count = 0
-No options
-No first char
-No req char
-Starting character set: c d e
- this sentence eventually mentions a cat
- 0: cat
- this sentences rambles on and on for a while and then reaches elephant
- 0: elephant
-
-/cat|dog|elephant/iS
-Identifying subpattern count = 0
-Options: caseless
-No first char
-No req char
-Starting character set: C D E c d e
- this sentence eventually mentions a CAT cat
- 0: CAT
- this sentences rambles on and on for a while to elephant ElePhant
- 0: elephant
-
-/a|[bcd]/S
-Identifying subpattern count = 0
-No options
-No first char
-No req char
-Starting character set: a b c d
-
-/(a|[^\dZ])/S
-Identifying subpattern count = 1
-No options
-No first char
-No req char
-Starting character set: \x00 \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0a
- \x0b \x0c \x0d \x0e \x0f \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19
- \x1a \x1b \x1c \x1d \x1e \x1f \x20 ! " # $ % & ' ( ) * + , - . / : ; < = >
- ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y [ \ ] ^ _ ` a b c d
- e f g h i j k l m n o p q r s t u v w x y z { | } ~ \x7f \x80 \x81 \x82 \x83
- \x84 \x85 \x86 \x87 \x88 \x89 \x8a \x8b \x8c \x8d \x8e \x8f \x90 \x91 \x92
- \x93 \x94 \x95 \x96 \x97 \x98 \x99 \x9a \x9b \x9c \x9d \x9e \x9f \xa0 \xa1
- \xa2 \xa3 \xa4 \xa5 \xa6 \xa7 \xa8 \xa9 \xaa \xab \xac \xad \xae \xaf \xb0
- \xb1 \xb2 \xb3 \xb4 \xb5 \xb6 \xb7 \xb8 \xb9 \xba \xbb \xbc \xbd \xbe \xbf
- \xc0 \xc1 \xc2 \xc3 \xc4 \xc5 \xc6 \xc7 \xc8 \xc9 \xca \xcb \xcc \xcd \xce
- \xcf \xd0 \xd1 \xd2 \xd3 \xd4 \xd5 \xd6 \xd7 \xd8 \xd9 \xda \xdb \xdc \xdd
- \xde \xdf \xe0 \xe1 \xe2 \xe3 \xe4 \xe5 \xe6 \xe7 \xe8 \xe9 \xea \xeb \xec
- \xed \xee \xef \xf0 \xf1 \xf2 \xf3 \xf4 \xf5 \xf6 \xf7 \xf8 \xf9 \xfa \xfb
- \xfc \xfd \xfe \xff
-
-/(a|b)*[\s]/S
-Identifying subpattern count = 1
-No options
-No first char
-No req char
-Starting character set: \x09 \x0a \x0b \x0c \x0d \x20 a b
-
-/(ab\2)/
-Failed: back reference to non-existent subpattern at offset 6
-
-/{4,5}abc/
-Failed: nothing to repeat at offset 4
-
-/(a)(b)(c)\2/
-Identifying subpattern count = 3
-No options
-First char = 'a'
-Req char = 'c'
- abcb
- 0: abcb
- 1: a
- 2: b
- 3: c
- \O0abcb
-Matched, but too many substrings
- \O3abcb
-Matched, but too many substrings
- 0: abcb
- \O6abcb
-Matched, but too many substrings
- 0: abcb
- 1: a
- \O9abcb
-Matched, but too many substrings
- 0: abcb
- 1: a
- 2: b
- \O12abcb
- 0: abcb
- 1: a
- 2: b
- 3: c
-
-/(a)bc|(a)(b)\2/
-Identifying subpattern count = 3
-No options
-First char = 'a'
-No req char
- abc
- 0: abc
- 1: a
- \O0abc
-Matched, but too many substrings
- \O3abc
-Matched, but too many substrings
- 0: abc
- \O6abc
- 0: abc
- 1: a
- aba
- 0: aba
- 1: <unset>
- 2: a
- 3: b
- \O0aba
-Matched, but too many substrings
- \O3aba
-Matched, but too many substrings
- 0: aba
- \O6aba
-Matched, but too many substrings
- 0: aba
- 1: <unset>
- \O9aba
-Matched, but too many substrings
- 0: aba
- 1: <unset>
- 2: a
- \O12aba
- 0: aba
- 1: <unset>
- 2: a
- 3: b
-
-/abc$/E
-Identifying subpattern count = 0
-Options: dollar_endonly
-First char = 'a'
-Req char = 'c'
- abc
- 0: abc
- *** Failers
-No match
- abc\n
-No match
- abc\ndef
-No match
-
-/(a)(b)(c)(d)(e)\6/
-Failed: back reference to non-existent subpattern at offset 17
-
-/the quick brown fox/
-Identifying subpattern count = 0
-No options
-First char = 't'
-Req char = 'x'
- the quick brown fox
- 0: the quick brown fox
- this is a line with the quick brown fox
- 0: the quick brown fox
-
-/the quick brown fox/A
-Identifying subpattern count = 0
-Options: anchored
-No first char
-Req char = 'x'
- the quick brown fox
- 0: the quick brown fox
- *** Failers
-No match
- this is a line with the quick brown fox
-No match
-
-/ab(?z)cd/
-Failed: unrecognized character after (? at offset 4
-
-/^abc|def/
-Identifying subpattern count = 0
-No options
-No first char
-No req char
- abcdef
- 0: abc
- abcdef\B
- 0: def
-
-/.*((abc)$|(def))/
-Identifying subpattern count = 3
-No options
-First char at start or follows \n
-No req char
- defabc
- 0: defabc
- 1: abc
- 2: abc
- \Zdefabc
- 0: def
- 1: def
- 2: <unset>
- 3: def
-
-/abc/P
- abc
- 0: abc
- *** Failers
-No match: POSIX code 17: match failed
-
-/^abc|def/P
- abcdef
- 0: abc
- abcdef\B
- 0: def
-
-/.*((abc)$|(def))/P
- defabc
- 0: defabc
- 1: abc
- 2: abc
- \Zdefabc
- 0: def
- 1: def
- 3: def
-
-/the quick brown fox/P
- the quick brown fox
- 0: the quick brown fox
- *** Failers
-No match: POSIX code 17: match failed
- The Quick Brown Fox
-No match: POSIX code 17: match failed
-
-/the quick brown fox/Pi
- the quick brown fox
- 0: the quick brown fox
- The Quick Brown Fox
- 0: The Quick Brown Fox
-
-/abc.def/P
- *** Failers
-No match: POSIX code 17: match failed
- abc\ndef
-No match: POSIX code 17: match failed
-
-/abc$/P
- abc
- 0: abc
- abc\n
- 0: abc
-
-/(abc)\2/P
-Failed: POSIX code 15: bad back reference at offset 7
-
-/(abc\1)/P
- abc
-No match: POSIX code 17: match failed
-
-/)/
-Failed: unmatched parentheses at offset 0
-
-/a[]b/
-Failed: missing terminating ] for character class at offset 4
-
-/[^aeiou ]{3,}/
-Identifying subpattern count = 0
-No options
-No first char
-No req char
- co-processors, and for
- 0: -pr
-
-/<.*>/
-Identifying subpattern count = 0
-No options
-First char = '<'
-Req char = '>'
- abc<def>ghi<klm>nop
- 0: <def>ghi<klm>
-
-/<.*?>/
-Identifying subpattern count = 0
-No options
-First char = '<'
-Req char = '>'
- abc<def>ghi<klm>nop
- 0: <def>
-
-/<.*>/U
-Identifying subpattern count = 0
-Options: ungreedy
-First char = '<'
-Req char = '>'
- abc<def>ghi<klm>nop
- 0: <def>
-
-/<.*>(?U)/
-Identifying subpattern count = 0
-Options: ungreedy
-First char = '<'
-Req char = '>'
- abc<def>ghi<klm>nop
- 0: <def>
-
-/<.*?>/U
-Identifying subpattern count = 0
-Options: ungreedy
-First char = '<'
-Req char = '>'
- abc<def>ghi<klm>nop
- 0: <def>ghi<klm>
-
-/={3,}/U
-Identifying subpattern count = 0
-Options: ungreedy
-First char = '='
-Req char = '='
- abc========def
- 0: ===
-
-/(?U)={3,}?/
-Identifying subpattern count = 0
-Options: ungreedy
-First char = '='
-Req char = '='
- abc========def
- 0: ========
-
-/(?<!bar|cattle)foo/
-Identifying subpattern count = 0
-No options
-First char = 'f'
-Req char = 'o'
- foo
- 0: foo
- catfoo
- 0: foo
- *** Failers
-No match
- the barfoo
-No match
- and cattlefoo
-No match
-
-/(?<=a+)b/
-Failed: lookbehind assertion is not fixed length at offset 6
-
-/(?<=aaa|b{0,3})b/
-Failed: lookbehind assertion is not fixed length at offset 14
-
-/(?<!(foo)a\1)bar/
-Failed: lookbehind assertion is not fixed length at offset 12
-
-/(?i)abc/
-Identifying subpattern count = 0
-Options: caseless
-First char = 'a'
-Req char = 'c'
-
-/(a|(?m)a)/
-Identifying subpattern count = 1
-No options
-First char = 'a'
-No req char
-
-/(?i)^1234/
-Identifying subpattern count = 0
-Options: anchored caseless
-No first char
-Req char = '4'
-
-/(^b|(?i)^d)/
-Identifying subpattern count = 1
-Options: anchored
-Case state changes
-No first char
-No req char
-
-/(?s).*/
-Identifying subpattern count = 0
-Options: anchored dotall
-No first char
-No req char
-
-/[abcd]/S
-Identifying subpattern count = 0
-No options
-No first char
-No req char
-Starting character set: a b c d
-
-/(?i)[abcd]/S
-Identifying subpattern count = 0
-Options: caseless
-No first char
-No req char
-Starting character set: A B C D a b c d
-
-/(?m)[xy]|(b|c)/S
-Identifying subpattern count = 1
-Options: multiline
-No first char
-No req char
-Starting character set: b c x y
-
-/(^a|^b)/m
-Identifying subpattern count = 1
-Options: multiline
-First char at start or follows \n
-No req char
-
-/(?i)(^a|^b)/m
-Identifying subpattern count = 1
-Options: caseless multiline
-First char at start or follows \n
-No req char
-
-/(a)(?(1)a|b|c)/
-Failed: conditional group contains more than two branches at offset 13
-
-/(?(?=a)a|b|c)/
-Failed: conditional group contains more than two branches at offset 12
-
-/(?(1a)/
-Failed: malformed number after (?( at offset 4
-
-/(?(?i))/
-Failed: assertion expected after (?( at offset 3
-
-/(?(abc))/
-Failed: assertion expected after (?( at offset 3
-
-/(?(?<ab))/
-Failed: unrecognized character after (?< at offset 2
-
-/((?s)blah)\s+\1/
-Identifying subpattern count = 1
-No options
-First char = 'b'
-Req char = 'h'
-
-/((?i)blah)\s+\1/
-Identifying subpattern count = 1
-No options
-Case state changes
-No first char
-Req char = 'h'
-
-/((?i)b)/DS
-------------------------------------------------------------------
- 0 16 Bra 0
- 3 8 Bra 1
- 6 01 Opt
- 8 1 b
- 11 8 Ket
- 14 00 Opt
- 16 16 Ket
- 19 End
-------------------------------------------------------------------
-Identifying subpattern count = 1
-No options
-Case state changes
-No first char
-Req char = 'b'
-Starting character set: B b
-
-/(a*b|(?i:c*(?-i)d))/S
-Identifying subpattern count = 1
-No options
-Case state changes
-No first char
-No req char
-Starting character set: C a b c d
-
-/a$/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-No req char
- a
- 0: a
- a\n
- 0: a
- *** Failers
-No match
- \Za
-No match
- \Za\n
-No match
-
-/a$/m
-Identifying subpattern count = 0
-Options: multiline
-First char = 'a'
-No req char
- a
- 0: a
- a\n
- 0: a
- \Za\n
- 0: a
- *** Failers
-No match
- \Za
-No match
-
-/\Aabc/m
-Identifying subpattern count = 0
-Options: anchored multiline
-No first char
-Req char = 'c'
-
-/^abc/m
-Identifying subpattern count = 0
-Options: multiline
-First char at start or follows \n
-Req char = 'c'
-
-/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/
-Identifying subpattern count = 5
-Options: anchored
-No first char
-Req char = 'a'
- aaaaabbbbbcccccdef
- 0: aaaaabbbbbcccccdef
- 1: aaaaabbbbbcccccdef
- 2: aaaaa
- 3: b
- 4: bbbbccccc
- 5: def
-
-/(?<=foo)[ab]/S
-Identifying subpattern count = 0
-No options
-No first char
-No req char
-Starting character set: a b
-
-/(?<!foo)(alpha|omega)/S
-Identifying subpattern count = 1
-No options
-No first char
-Req char = 'a'
-Starting character set: a o
-
-/(?!alphabet)[ab]/S
-Identifying subpattern count = 0
-No options
-No first char
-No req char
-Starting character set: a b
-
-/(?<=foo\n)^bar/m
-Identifying subpattern count = 0
-Options: multiline
-First char at start or follows \n
-Req char = 'r'
-
-/(?>^abc)/m
-Identifying subpattern count = 0
-Options: multiline
-First char at start or follows \n
-Req char = 'c'
- abc
- 0: abc
- def\nabc
- 0: abc
- *** Failers
-No match
- defabc
-No match
-
-/(?<=ab(c+)d)ef/
-Failed: lookbehind assertion is not fixed length at offset 11
-
-/(?<=ab(?<=c+)d)ef/
-Failed: lookbehind assertion is not fixed length at offset 12
-
-/(?<=ab(c|de)f)g/
-Failed: lookbehind assertion is not fixed length at offset 13
-
-/The next three are in testinput2 because they have variable length branches/
-Identifying subpattern count = 0
-No options
-First char = 'T'
-Req char = 's'
-
-/(?<=bullock|donkey)-cart/
-Identifying subpattern count = 0
-No options
-First char = '-'
-Req char = 't'
- the bullock-cart
- 0: -cart
- a donkey-cart race
- 0: -cart
- *** Failers
-No match
- cart
-No match
- horse-and-cart
-No match
-
-/(?<=ab(?i)x|y|z)/
-Identifying subpattern count = 0
-No options
-Case state changes
-No first char
-No req char
-
-/(?>.*)(?<=(abcd)|(xyz))/
-Identifying subpattern count = 2
-No options
-First char at start or follows \n
-No req char
- alphabetabcd
- 0: alphabetabcd
- 1: abcd
- endingxyz
- 0: endingxyz
- 1: <unset>
- 2: xyz
-
-/(?<=ab(?i)x(?-i)y|(?i)z|b)ZZ/
-Identifying subpattern count = 0
-No options
-Case state changes
-First char = 'Z'
-Req char = 'Z'
- abxyZZ
- 0: ZZ
- abXyZZ
- 0: ZZ
- ZZZ
- 0: ZZ
- zZZ
- 0: ZZ
- bZZ
- 0: ZZ
- BZZ
- 0: ZZ
- *** Failers
-No match
- ZZ
-No match
- abXYZZ
-No match
- zzz
-No match
- bzz
-No match
-
-/(?<!(foo)a)bar/
-Identifying subpattern count = 1
-No options
-First char = 'b'
-Req char = 'r'
- bar
- 0: bar
- foobbar
- 0: bar
- *** Failers
-No match
- fooabar
-No match
-
-/This one is here because Perl 5.005_02 doesn't fail it/
-Identifying subpattern count = 0
-No options
-First char = 'T'
-Req char = 't'
-
-/^(a)?(?(1)a|b)+$/
-Identifying subpattern count = 1
-Options: anchored
-No first char
-No req char
- *** Failers
-No match
- a
-No match
-
-/This one is here because I think Perl 5.005_02 gets the setting of $1 wrong/
-Identifying subpattern count = 0
-No options
-First char = 'T'
-Req char = 'g'
-
-/^(a\1?){4}$/
-Identifying subpattern count = 1
-Options: anchored
-No first char
-Req char = 'a'
- aaaaaa
- 0: aaaaaa
- 1: aa
-
-/These are syntax tests from Perl 5.005/
-Identifying subpattern count = 0
-No options
-First char = 'T'
-Req char = '5'
-
-/a[b-a]/
-Failed: range out of order in character class at offset 4
-
-/a[]b/
-Failed: missing terminating ] for character class at offset 4
-
-/a[/
-Failed: missing terminating ] for character class at offset 2
-
-/*a/
-Failed: nothing to repeat at offset 0
-
-/(*)b/
-Failed: nothing to repeat at offset 1
-
-/abc)/
-Failed: unmatched parentheses at offset 3
-
-/(abc/
-Failed: missing ) at offset 4
-
-/a**/
-Failed: nothing to repeat at offset 2
-
-/)(/
-Failed: unmatched parentheses at offset 0
-
-/\1/
-Failed: back reference to non-existent subpattern at offset 2
-
-/\2/
-Failed: back reference to non-existent subpattern at offset 2
-
-/(a)|\2/
-Failed: back reference to non-existent subpattern at offset 6
-
-/a[b-a]/i
-Failed: range out of order in character class at offset 4
-
-/a[]b/i
-Failed: missing terminating ] for character class at offset 4
-
-/a[/i
-Failed: missing terminating ] for character class at offset 2
-
-/*a/i
-Failed: nothing to repeat at offset 0
-
-/(*)b/i
-Failed: nothing to repeat at offset 1
-
-/abc)/i
-Failed: unmatched parentheses at offset 3
-
-/(abc/i
-Failed: missing ) at offset 4
-
-/a**/i
-Failed: nothing to repeat at offset 2
-
-/)(/i
-Failed: unmatched parentheses at offset 0
-
-/:(?:/
-Failed: missing ) at offset 4
-
-/(?<%)b/
-Failed: unrecognized character after (?< at offset 0
-
-/a(?{)b/
-Failed: unrecognized character after (? at offset 3
-
-/a(?{{})b/
-Failed: unrecognized character after (? at offset 3
-
-/a(?{}})b/
-Failed: unrecognized character after (? at offset 3
-
-/a(?{"{"})b/
-Failed: unrecognized character after (? at offset 3
-
-/a(?{"{"}})b/
-Failed: unrecognized character after (? at offset 3
-
-/(?(1?)a|b)/
-Failed: malformed number after (?( at offset 4
-
-/(?(1)a|b|c)/
-Failed: conditional group contains more than two branches at offset 10
-
-/[a[:xyz:/
-Failed: missing terminating ] for character class at offset 8
-
-/(?<=x+)y/
-Failed: lookbehind assertion is not fixed length at offset 6
-
-/a{37,17}/
-Failed: numbers out of order in {} quantifier at offset 7
-
-/abc/\
-Failed: \ at end of pattern at offset 4
-
-/abc/\P
-Failed: POSIX code 9: bad escape sequence at offset 4
-
-/abc/\i
-Failed: \ at end of pattern at offset 4
-
-/(a)bc(d)/
-Identifying subpattern count = 2
-No options
-First char = 'a'
-Req char = 'd'
- abcd
- 0: abcd
- 1: a
- 2: d
- abcd\C2
- 0: abcd
- 1: a
- 2: d
- 2C d (1)
- abcd\C5
- 0: abcd
- 1: a
- 2: d
-copy substring 5 failed -7
-
-/(.{20})/
-Identifying subpattern count = 1
-No options
-No first char
-No req char
- abcdefghijklmnopqrstuvwxyz
- 0: abcdefghijklmnopqrst
- 1: abcdefghijklmnopqrst
- abcdefghijklmnopqrstuvwxyz\C1
- 0: abcdefghijklmnopqrst
- 1: abcdefghijklmnopqrst
-copy substring 1 failed -6
- abcdefghijklmnopqrstuvwxyz\G1
- 0: abcdefghijklmnopqrst
- 1: abcdefghijklmnopqrst
- 1G abcdefghijklmnopqrst (20)
-
-/(.{15})/
-Identifying subpattern count = 1
-No options
-No first char
-No req char
- abcdefghijklmnopqrstuvwxyz
- 0: abcdefghijklmno
- 1: abcdefghijklmno
- abcdefghijklmnopqrstuvwxyz\C1\G1
- 0: abcdefghijklmno
- 1: abcdefghijklmno
- 1C abcdefghijklmno (15)
- 1G abcdefghijklmno (15)
-
-/(.{16})/
-Identifying subpattern count = 1
-No options
-No first char
-No req char
- abcdefghijklmnopqrstuvwxyz
- 0: abcdefghijklmnop
- 1: abcdefghijklmnop
- abcdefghijklmnopqrstuvwxyz\C1\G1\L
- 0: abcdefghijklmnop
- 1: abcdefghijklmnop
-copy substring 1 failed -6
- 1G abcdefghijklmnop (16)
- 0L abcdefghijklmnop
- 1L abcdefghijklmnop
-
-/^(a|(bc))de(f)/
-Identifying subpattern count = 3
-Options: anchored
-No first char
-Req char = 'f'
- adef\G1\G2\G3\G4\L
- 0: adef
- 1: a
- 2: <unset>
- 3: f
- 1G a (1)
- 2G (0)
- 3G f (1)
-get substring 4 failed -7
- 0L adef
- 1L a
- 2L
- 3L f
- bcdef\G1\G2\G3\G4\L
- 0: bcdef
- 1: bc
- 2: bc
- 3: f
- 1G bc (2)
- 2G bc (2)
- 3G f (1)
-get substring 4 failed -7
- 0L bcdef
- 1L bc
- 2L bc
- 3L f
- adefghijk\C0
- 0: adef
- 1: a
- 2: <unset>
- 3: f
- 0C adef (4)
-
-/^abc\00def/
-Identifying subpattern count = 0
-Options: anchored
-No first char
-Req char = 'f'
- abc\00def\L\C0
- 0: abc\x00def
- 0C abc (7)
- 0L abc
-
-/word ((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
-)((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
-)?)?)?)?)?)?)?)?)?otherword/M
-Memory allocation (code space): 428
-Identifying subpattern count = 8
-No options
-First char = 'w'
-Req char = 'd'
-
-/.*X/D
-------------------------------------------------------------------
- 0 8 Bra 0
- 3 Any*
- 5 1 X
- 8 8 Ket
- 11 End
-------------------------------------------------------------------
-Identifying subpattern count = 0
-No options
-First char at start or follows \n
-Req char = 'X'
-
-/.*X/Ds
-------------------------------------------------------------------
- 0 8 Bra 0
- 3 Any*
- 5 1 X
- 8 8 Ket
- 11 End
-------------------------------------------------------------------
-Identifying subpattern count = 0
-Options: anchored dotall
-No first char
-Req char = 'X'
-
-/(.*X|^B)/D
-------------------------------------------------------------------
- 0 21 Bra 0
- 3 8 Bra 1
- 6 Any*
- 8 1 X
- 11 7 Alt
- 14 ^
- 15 1 B
- 18 15 Ket
- 21 21 Ket
- 24 End
-------------------------------------------------------------------
-Identifying subpattern count = 1
-No options
-First char at start or follows \n
-No req char
-
-/(.*X|^B)/Ds
-------------------------------------------------------------------
- 0 21 Bra 0
- 3 8 Bra 1
- 6 Any*
- 8 1 X
- 11 7 Alt
- 14 ^
- 15 1 B
- 18 15 Ket
- 21 21 Ket
- 24 End
-------------------------------------------------------------------
-Identifying subpattern count = 1
-Options: anchored dotall
-No first char
-No req char
-
-/(?s)(.*X|^B)/D
-------------------------------------------------------------------
- 0 21 Bra 0
- 3 8 Bra 1
- 6 Any*
- 8 1 X
- 11 7 Alt
- 14 ^
- 15 1 B
- 18 15 Ket
- 21 21 Ket
- 24 End
-------------------------------------------------------------------
-Identifying subpattern count = 1
-Options: anchored dotall
-No first char
-No req char
-
-/(?s:.*X|^B)/D
-------------------------------------------------------------------
- 0 27 Bra 0
- 3 10 Bra 0
- 6 04 Opt
- 8 Any*
- 10 1 X
- 13 9 Alt
- 16 04 Opt
- 18 ^
- 19 1 B
- 22 19 Ket
- 25 00 Opt
- 27 27 Ket
- 30 End
-------------------------------------------------------------------
-Identifying subpattern count = 0
-No options
-First char at start or follows \n
-No req char
-
-/\Biss\B/+
-Identifying subpattern count = 0
-No options
-First char = 'i'
-Req char = 's'
- Mississippi
- 0: iss
- 0+ issippi
-
-/\Biss\B/+P
- Mississippi
- 0: iss
- 0+ issippi
-
-/iss/G+
-Identifying subpattern count = 0
-No options
-First char = 'i'
-Req char = 's'
- Mississippi
- 0: iss
- 0+ issippi
- 0: iss
- 0+ ippi
-
-/\Biss\B/G+
-Identifying subpattern count = 0
-No options
-First char = 'i'
-Req char = 's'
- Mississippi
- 0: iss
- 0+ issippi
-
-/\Biss\B/g+
-Identifying subpattern count = 0
-No options
-First char = 'i'
-Req char = 's'
- Mississippi
- 0: iss
- 0+ issippi
- 0: iss
- 0+ ippi
- *** Failers
-No match
- Mississippi\A
-No match
-
-/(?<=[Ms])iss/g+
-Identifying subpattern count = 0
-No options
-First char = 'i'
-Req char = 's'
- Mississippi
- 0: iss
- 0+ issippi
- 0: iss
- 0+ ippi
-
-/(?<=[Ms])iss/G+
-Identifying subpattern count = 0
-No options
-First char = 'i'
-Req char = 's'
- Mississippi
- 0: iss
- 0+ issippi
-
-/^iss/g+
-Identifying subpattern count = 0
-Options: anchored
-No first char
-Req char = 's'
- ississippi
- 0: iss
- 0+ issippi
-
-/.*iss/g+
-Identifying subpattern count = 0
-No options
-First char at start or follows \n
-Req char = 's'
- abciss\nxyzisspqr
- 0: abciss
- 0+ \x0axyzisspqr
- 0: xyziss
- 0+ pqr
-
-/.i./+g
-Identifying subpattern count = 0
-No options
-No first char
-Req char = 'i'
- Mississippi
- 0: Mis
- 0+ sissippi
- 0: sis
- 0+ sippi
- 0: sip
- 0+ pi
- Mississippi\A
- 0: Mis
- 0+ sissippi
- 0: sis
- 0+ sippi
- 0: sip
- 0+ pi
- Missouri river
- 0: Mis
- 0+ souri river
- 0: ri
- 0+ river
- 0: riv
- 0+ er
- Missouri river\A
- 0: Mis
- 0+ souri river
-
-/^.is/+g
-Identifying subpattern count = 0
-Options: anchored
-No first char
-Req char = 's'
- Mississippi
- 0: Mis
- 0+ sissippi
-
-/^ab\n/g+
-Identifying subpattern count = 0
-Options: anchored
-No first char
-Req char = 10
- ab\nab\ncd
- 0: ab\x0a
- 0+ ab\x0acd
-
-/^ab\n/mg+
-Identifying subpattern count = 0
-Options: multiline
-First char at start or follows \n
-Req char = 10
- ab\nab\ncd
- 0: ab\x0a
- 0+ ab\x0acd
- 0: ab\x0a
- 0+ cd
-
-/abc/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-Req char = 'c'
-
-/abc|bac/
-Identifying subpattern count = 0
-No options
-No first char
-Req char = 'c'
-
-/(abc|bac)/
-Identifying subpattern count = 1
-No options
-No first char
-Req char = 'c'
-
-/(abc|(c|dc))/
-Identifying subpattern count = 2
-No options
-No first char
-Req char = 'c'
-
-/(abc|(d|de)c)/
-Identifying subpattern count = 2
-No options
-No first char
-Req char = 'c'
-
-/a*/
-Identifying subpattern count = 0
-No options
-No first char
-No req char
-
-/a+/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-No req char
-
-/(baa|a+)/
-Identifying subpattern count = 1
-No options
-No first char
-Req char = 'a'
-
-/a{0,3}/
-Identifying subpattern count = 0
-No options
-No first char
-No req char
-
-/baa{3,}/
-Identifying subpattern count = 0
-No options
-First char = 'b'
-Req char = 'a'
-
-/"([^\\"]+|\\.)*"/
-Identifying subpattern count = 1
-No options
-First char = '"'
-Req char = '"'
-
-/(abc|ab[cd])/
-Identifying subpattern count = 1
-No options
-First char = 'a'
-No req char
-
-/(a|.)/
-Identifying subpattern count = 1
-No options
-No first char
-No req char
-
-/a|ba|\w/
-Identifying subpattern count = 0
-No options
-No first char
-No req char
-
-/abc(?=pqr)/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-Req char = 'r'
-
-/...(?<=abc)/
-Identifying subpattern count = 0
-No options
-No first char
-No req char
-
-/abc(?!pqr)/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-Req char = 'c'
-
-/ab./
-Identifying subpattern count = 0
-No options
-First char = 'a'
-Req char = 'b'
-
-/ab[xyz]/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-Req char = 'b'
-
-/abc*/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-Req char = 'b'
-
-/ab.c*/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-Req char = 'b'
-
-/a.c*/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-No req char
-
-/.c*/
-Identifying subpattern count = 0
-No options
-No first char
-No req char
-
-/ac*/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-No req char
-
-/(a.c*|b.c*)/
-Identifying subpattern count = 1
-No options
-No first char
-No req char
-
-/a.c*|aba/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-No req char
-
-/.+a/
-Identifying subpattern count = 0
-No options
-No first char
-Req char = 'a'
-
-/(?=abcda)a.*/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-No req char
-
-/(?=a)a.*/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-No req char
-
-/a(b)*/
-Identifying subpattern count = 1
-No options
-First char = 'a'
-No req char
-
-/a\d*/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-No req char
-
-/ab\d*/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-Req char = 'b'
-
-/a(\d)*/
-Identifying subpattern count = 1
-No options
-First char = 'a'
-No req char
-
-/abcde{0,0}/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-Req char = 'd'
-
-/ab\d+/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-Req char = 'b'
-
-/a(?(1)b)/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-No req char
-
-/a(?(1)bag|big)/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-Req char = 'g'
-
-/a(?(1)bag|big)*/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-No req char
-
-/a(?(1)bag|big)+/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-Req char = 'g'
-
-/a(?(1)b..|b..)/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-Req char = 'b'
-
-/ab\d{0}e/
-Identifying subpattern count = 0
-No options
-First char = 'a'
-Req char = 'e'
-
-/a?b?/
-Identifying subpattern count = 0
-No options
-No first char
-No req char
- a
- 0: a
- b
- 0: b
- ab
- 0: ab
- \
- 0:
- *** Failers
- 0:
- \N
-No match
-
-/|-/
-Identifying subpattern count = 0
-No options
-No first char
-No req char
- abcd
- 0:
- -abc
- 0:
- \Nab-c
- 0: -
- *** Failers
- 0:
- \Nabc
-No match
-
-/.*?/g+
-Identifying subpattern count = 0
-No options
-First char at start or follows \n
-No req char
- abc
- 0:
- 0+ abc
- 0: a
- 0+ bc
- 0:
- 0+ bc
- 0: b
- 0+ c
- 0:
- 0+ c
- 0: c
- 0+
- 0:
- 0+
-
-/ End of test input /
-Identifying subpattern count = 0
-No options
-First char = ' '
-Req char = ' '
-
diff --git a/ext/pcre/pcrelib/testoutput3 b/ext/pcre/pcrelib/testoutput3
deleted file mode 100644
index d9976598f2..0000000000
--- a/ext/pcre/pcrelib/testoutput3
+++ /dev/null
@@ -1,2929 +0,0 @@
-PCRE version 2.08 31-Aug-1999
-
-/(?<!bar)foo/
- foo
- 0: foo
- catfood
- 0: foo
- arfootle
- 0: foo
- rfoosh
- 0: foo
- *** Failers
-No match
- barfoo
-No match
- towbarfoo
-No match
-
-/\w{3}(?<!bar)foo/
- catfood
- 0: catfoo
- *** Failers
-No match
- foo
-No match
- barfoo
-No match
- towbarfoo
-No match
-
-/(?<=(foo)a)bar/
- fooabar
- 0: bar
- 1: foo
- *** Failers
-No match
- bar
-No match
- foobbar
-No match
-
-/\Aabc\z/m
- abc
- 0: abc
- *** Failers
-No match
- abc\n
-No match
- qqq\nabc
-No match
- abc\nzzz
-No match
- qqq\nabc\nzzz
-No match
-
-"(?>.*/)foo"
- /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/
-No match
-
-"(?>.*/)foo"
- /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
- 0: /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
-
-/(?>(\.\d\d[1-9]?))\d+/
- 1.230003938
- 0: .230003938
- 1: .23
- 1.875000282
- 0: .875000282
- 1: .875
- *** Failers
-No match
- 1.235
-No match
-
-/^((?>\w+)|(?>\s+))*$/
- now is the time for all good men to come to the aid of the party
- 0: now is the time for all good men to come to the aid of the party
- 1: party
- *** Failers
-No match
- this is not a line with only words and spaces!
-No match
-
-/(\d+)(\w)/
- 12345a
- 0: 12345a
- 1: 12345
- 2: a
- 12345+
- 0: 12345
- 1: 1234
- 2: 5
-
-/((?>\d+))(\w)/
- 12345a
- 0: 12345a
- 1: 12345
- 2: a
- *** Failers
-No match
- 12345+
-No match
-
-/(?>a+)b/
- aaab
- 0: aaab
-
-/((?>a+)b)/
- aaab
- 0: aaab
- 1: aaab
-
-/(?>(a+))b/
- aaab
- 0: aaab
- 1: aaa
-
-/(?>b)+/
- aaabbbccc
- 0: bbb
-
-/(?>a+|b+|c+)*c/
- aaabbbbccccd
- 0: aaabbbbc
-
-/((?>[^()]+)|\([^()]*\))+/
- ((abc(ade)ufh()()x
- 0: abc(ade)ufh()()x
- 1: x
-
-/\(((?>[^()]+)|\([^()]+\))+\)/
- (abc)
- 0: (abc)
- 1: abc
- (abc(def)xyz)
- 0: (abc(def)xyz)
- 1: xyz
- *** Failers
-No match
- ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-No match
-
-/a(?-i)b/i
- ab
- 0: ab
- *** Failers
-No match
- Ab
-No match
- aB
-No match
- AB
-No match
-
-/(a (?x)b c)d e/
- a bcd e
- 0: a bcd e
- 1: a bc
- *** Failers
-No match
- a b cd e
-No match
- abcd e
-No match
- a bcde
-No match
-
-/(a b(?x)c d (?-x)e f)/
- a bcde f
- 0: a bcde f
- 1: a bcde f
- *** Failers
-No match
- abcdef
-No match
-
-/(a(?i)b)c/
- abc
- 0: abc
- 1: ab
- aBc
- 0: aBc
- 1: aB
- *** Failers
-No match
- abC
-No match
- aBC
-No match
- Abc
-No match
- ABc
-No match
- ABC
-No match
- AbC
-No match
-
-/a(?i:b)c/
- abc
- 0: abc
- aBc
- 0: aBc
- *** Failers
-No match
- ABC
-No match
- abC
-No match
- aBC
-No match
-
-/a(?i:b)*c/
- aBc
- 0: aBc
- aBBc
- 0: aBBc
- *** Failers
-No match
- aBC
-No match
- aBBC
-No match
-
-/a(?=b(?i)c)\w\wd/
- abcd
- 0: abcd
- abCd
- 0: abCd
- *** Failers
-No match
- aBCd
-No match
- abcD
-No match
-
-/(?s-i:more.*than).*million/i
- more than million
- 0: more than million
- more than MILLION
- 0: more than MILLION
- more \n than Million
- 0: more \x0a than Million
- *** Failers
-No match
- MORE THAN MILLION
-No match
- more \n than \n million
-No match
-
-/(?:(?s-i)more.*than).*million/i
- more than million
- 0: more than million
- more than MILLION
- 0: more than MILLION
- more \n than Million
- 0: more \x0a than Million
- *** Failers
-No match
- MORE THAN MILLION
-No match
- more \n than \n million
-No match
-
-/(?>a(?i)b+)+c/
- abc
- 0: abc
- aBbc
- 0: aBbc
- aBBc
- 0: aBBc
- *** Failers
-No match
- Abc
-No match
- abAb
-No match
- abbC
-No match
-
-/(?=a(?i)b)\w\wc/
- abc
- 0: abc
- aBc
- 0: aBc
- *** Failers
-No match
- Ab
-No match
- abC
-No match
- aBC
-No match
-
-/(?<=a(?i)b)(\w\w)c/
- abxxc
- 0: xxc
- 1: xx
- aBxxc
- 0: xxc
- 1: xx
- *** Failers
-No match
- Abxxc
-No match
- ABxxc
-No match
- abxxC
-No match
-
-/(?:(a)|b)(?(1)A|B)/
- aA
- 0: aA
- 1: a
- bB
- 0: bB
- *** Failers
-No match
- aB
-No match
- bA
-No match
-
-/^(a)?(?(1)a|b)+$/
- aa
- 0: aa
- 1: a
- b
- 0: b
- bb
- 0: bb
- *** Failers
-No match
- ab
-No match
-
-/^(?(?=abc)\w{3}:|\d\d)$/
- abc:
- 0: abc:
- 12
- 0: 12
- *** Failers
-No match
- 123
-No match
- xyz
-No match
-
-/^(?(?!abc)\d\d|\w{3}:)$/
- abc:
- 0: abc:
- 12
- 0: 12
- *** Failers
-No match
- 123
-No match
- xyz
-No match
-
-/(?(?<=foo)bar|cat)/
- foobar
- 0: bar
- cat
- 0: cat
- fcat
- 0: cat
- focat
- 0: cat
- *** Failers
-No match
- foocat
-No match
-
-/(?(?<!foo)cat|bar)/
- foobar
- 0: bar
- cat
- 0: cat
- fcat
- 0: cat
- focat
- 0: cat
- *** Failers
-No match
- foocat
-No match
-
-/( \( )? [^()]+ (?(1) \) |) /x
- abcd
- 0: abcd
- (abcd)
- 0: (abcd)
- 1: (
- the quick (abcd) fox
- 0: the quick
- (abcd
- 0: abcd
-
-/( \( )? [^()]+ (?(1) \) ) /x
- abcd
- 0: abcd
- (abcd)
- 0: (abcd)
- 1: (
- the quick (abcd) fox
- 0: the quick
- (abcd
- 0: abcd
-
-/^(?(2)a|(1)(2))+$/
- 12
- 0: 12
- 1: 1
- 2: 2
- 12a
- 0: 12a
- 1: 1
- 2: 2
- 12aa
- 0: 12aa
- 1: 1
- 2: 2
- *** Failers
-No match
- 1234
-No match
-
-/((?i)blah)\s+\1/
- blah blah
- 0: blah blah
- 1: blah
- BLAH BLAH
- 0: BLAH BLAH
- 1: BLAH
- Blah Blah
- 0: Blah Blah
- 1: Blah
- blaH blaH
- 0: blaH blaH
- 1: blaH
- *** Failers
-No match
- blah BLAH
-No match
- Blah blah
-No match
- blaH blah
-No match
-
-/((?i)blah)\s+(?i:\1)/
- blah blah
- 0: blah blah
- 1: blah
- BLAH BLAH
- 0: BLAH BLAH
- 1: BLAH
- Blah Blah
- 0: Blah Blah
- 1: Blah
- blaH blaH
- 0: blaH blaH
- 1: blaH
- blah BLAH
- 0: blah BLAH
- 1: blah
- Blah blah
- 0: Blah blah
- 1: Blah
- blaH blah
- 0: blaH blah
- 1: blaH
-
-/(?>a*)*/
- a
- 0: a
- aa
- 0: aa
- aaaa
- 0: aaaa
-
-/(abc|)+/
- abc
- 0: abc
- 1:
- abcabc
- 0: abcabc
- 1:
- abcabcabc
- 0: abcabcabc
- 1:
- xyz
- 0:
- 1:
-
-/([a]*)*/
- a
- 0: a
- 1:
- aaaaa
- 0: aaaaa
- 1:
-
-/([ab]*)*/
- a
- 0: a
- 1:
- b
- 0: b
- 1:
- ababab
- 0: ababab
- 1:
- aaaabcde
- 0: aaaab
- 1:
- bbbb
- 0: bbbb
- 1:
-
-/([^a]*)*/
- b
- 0: b
- 1:
- bbbb
- 0: bbbb
- 1:
- aaa
- 0:
- 1:
-
-/([^ab]*)*/
- cccc
- 0: cccc
- 1:
- abab
- 0:
- 1:
-
-/([a]*?)*/
- a
- 0:
- 1:
- aaaa
- 0:
- 1:
-
-/([ab]*?)*/
- a
- 0:
- 1:
- b
- 0:
- 1:
- abab
- 0:
- 1:
- baba
- 0:
- 1:
-
-/([^a]*?)*/
- b
- 0:
- 1:
- bbbb
- 0:
- 1:
- aaa
- 0:
- 1:
-
-/([^ab]*?)*/
- c
- 0:
- 1:
- cccc
- 0:
- 1:
- baba
- 0:
- 1:
-
-/(?>a*)*/
- a
- 0: a
- aaabcde
- 0: aaa
-
-/((?>a*))*/
- aaaaa
- 0: aaaaa
- 1:
- aabbaa
- 0: aa
- 1:
-
-/((?>a*?))*/
- aaaaa
- 0:
- 1:
- aabbaa
- 0:
- 1:
-
-/(?(?=[^a-z]+[a-z]) \d{2}-[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} ) /x
- 12-sep-98
- 0: 12-sep-98
- 12-09-98
- 0: 12-09-98
- *** Failers
-No match
- sep-12-98
-No match
-
-/(?<=(foo))bar\1/
- foobarfoo
- 0: barfoo
- 1: foo
- foobarfootling
- 0: barfoo
- 1: foo
- *** Failers
-No match
- foobar
-No match
- barfoo
-No match
-
-/(?i:saturday|sunday)/
- saturday
- 0: saturday
- sunday
- 0: sunday
- Saturday
- 0: Saturday
- Sunday
- 0: Sunday
- SATURDAY
- 0: SATURDAY
- SUNDAY
- 0: SUNDAY
- SunDay
- 0: SunDay
-
-/(a(?i)bc|BB)x/
- abcx
- 0: abcx
- 1: abc
- aBCx
- 0: aBCx
- 1: aBC
- bbx
- 0: bbx
- 1: bb
- BBx
- 0: BBx
- 1: BB
- *** Failers
-No match
- abcX
-No match
- aBCX
-No match
- bbX
-No match
- BBX
-No match
-
-/^([ab](?i)[cd]|[ef])/
- ac
- 0: ac
- 1: ac
- aC
- 0: aC
- 1: aC
- bD
- 0: bD
- 1: bD
- elephant
- 0: e
- 1: e
- Europe
- 0: E
- 1: E
- frog
- 0: f
- 1: f
- France
- 0: F
- 1: F
- *** Failers
-No match
- Africa
-No match
-
-/^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/
- ab
- 0: ab
- 1: ab
- aBd
- 0: aBd
- 1: aBd
- xy
- 0: xy
- 1: xy
- xY
- 0: xY
- 1: xY
- zebra
- 0: z
- 1: z
- Zambesi
- 0: Z
- 1: Z
- *** Failers
-No match
- aCD
-No match
- XY
-No match
-
-/(?<=foo\n)^bar/m
- foo\nbar
- 0: bar
- *** Failers
-No match
- bar
-No match
- baz\nbar
-No match
-
-/(?<=(?<!foo)bar)baz/
- barbaz
- 0: baz
- barbarbaz
- 0: baz
- koobarbaz
- 0: baz
- *** Failers
-No match
- baz
-No match
- foobarbaz
-No match
-
-/The case of aaaaaa is missed out below because I think Perl 5.005_02 gets/
-/it wrong; it sets $1 to aaa rather than aa. Compare the following test,/
-No match
-/where it does set $1 to aa when matching aaaaaa./
-No match
-
-/^(a\1?){4}$/
- a
-No match
- aa
-No match
- aaa
-No match
- aaaa
- 0: aaaa
- 1: a
- aaaaa
- 0: aaaaa
- 1: a
- aaaaaaa
- 0: aaaaaaa
- 1: a
- aaaaaaaa
-No match
- aaaaaaaaa
-No match
- aaaaaaaaaa
- 0: aaaaaaaaaa
- 1: aaaa
- aaaaaaaaaaa
-No match
- aaaaaaaaaaaa
-No match
- aaaaaaaaaaaaa
-No match
- aaaaaaaaaaaaaa
-No match
- aaaaaaaaaaaaaaa
-No match
- aaaaaaaaaaaaaaaa
-No match
-
-/^(a\1?)(a\1?)(a\2?)(a\3?)$/
- a
-No match
- aa
-No match
- aaa
-No match
- aaaa
- 0: aaaa
- 1: a
- 2: a
- 3: a
- 4: a
- aaaaa
- 0: aaaaa
- 1: a
- 2: aa
- 3: a
- 4: a
- aaaaaa
- 0: aaaaaa
- 1: a
- 2: aa
- 3: a
- 4: aa
- aaaaaaa
- 0: aaaaaaa
- 1: a
- 2: aa
- 3: aaa
- 4: a
- aaaaaaaa
-No match
- aaaaaaaaa
-No match
- aaaaaaaaaa
- 0: aaaaaaaaaa
- 1: a
- 2: aa
- 3: aaa
- 4: aaaa
- aaaaaaaaaaa
-No match
- aaaaaaaaaaaa
-No match
- aaaaaaaaaaaaa
-No match
- aaaaaaaaaaaaaa
-No match
- aaaaaaaaaaaaaaa
-No match
- aaaaaaaaaaaaaaaa
-No match
-
-/The following tests are taken from the Perl 5.005 test suite; some of them/
-/are compatible with 5.004, but I'd rather not have to sort them out./
-No match
-
-/abc/
- abc
- 0: abc
- xabcy
- 0: abc
- ababc
- 0: abc
- *** Failers
-No match
- xbc
-No match
- axc
-No match
- abx
-No match
-
-/ab*c/
- abc
- 0: abc
-
-/ab*bc/
- abc
- 0: abc
- abbc
- 0: abbc
- abbbbc
- 0: abbbbc
-
-/.{1}/
- abbbbc
- 0: a
-
-/.{3,4}/
- abbbbc
- 0: abbb
-
-/ab{0,}bc/
- abbbbc
- 0: abbbbc
-
-/ab+bc/
- abbc
- 0: abbc
- *** Failers
-No match
- abc
-No match
- abq
-No match
-
-/ab{1,}bc/
-
-/ab+bc/
- abbbbc
- 0: abbbbc
-
-/ab{1,}bc/
- abbbbc
- 0: abbbbc
-
-/ab{1,3}bc/
- abbbbc
- 0: abbbbc
-
-/ab{3,4}bc/
- abbbbc
- 0: abbbbc
-
-/ab{4,5}bc/
- *** Failers
-No match
- abq
-No match
- abbbbc
-No match
-
-/ab?bc/
- abbc
- 0: abbc
- abc
- 0: abc
-
-/ab{0,1}bc/
- abc
- 0: abc
-
-/ab?bc/
-
-/ab?c/
- abc
- 0: abc
-
-/ab{0,1}c/
- abc
- 0: abc
-
-/^abc$/
- abc
- 0: abc
- *** Failers
-No match
- abbbbc
-No match
- abcc
-No match
-
-/^abc/
- abcc
- 0: abc
-
-/^abc$/
-
-/abc$/
- aabc
- 0: abc
- *** Failers
-No match
- aabc
- 0: abc
- aabcd
-No match
-
-/^/
- abc
- 0:
-
-/$/
- abc
- 0:
-
-/a.c/
- abc
- 0: abc
- axc
- 0: axc
-
-/a.*c/
- axyzc
- 0: axyzc
-
-/a[bc]d/
- abd
- 0: abd
- *** Failers
-No match
- axyzd
-No match
- abc
-No match
-
-/a[b-d]e/
- ace
- 0: ace
-
-/a[b-d]/
- aac
- 0: ac
-
-/a[-b]/
- a-
- 0: a-
-
-/a[b-]/
- a-
- 0: a-
-
-/a]/
- a]
- 0: a]
-
-/a[]]b/
- a]b
- 0: a]b
-
-/a[^bc]d/
- aed
- 0: aed
- *** Failers
-No match
- abd
-No match
- abd
-No match
-
-/a[^-b]c/
- adc
- 0: adc
-
-/a[^]b]c/
- adc
- 0: adc
- *** Failers
-No match
- a-c
- 0: a-c
- a]c
-No match
-
-/\ba\b/
- a-
- 0: a
- -a
- 0: a
- -a-
- 0: a
-
-/\by\b/
- *** Failers
-No match
- xy
-No match
- yz
-No match
- xyz
-No match
-
-/\Ba\B/
- *** Failers
- 0: a
- a-
-No match
- -a
-No match
- -a-
-No match
-
-/\By\b/
- xy
- 0: y
-
-/\by\B/
- yz
- 0: y
-
-/\By\B/
- xyz
- 0: y
-
-/\w/
- a
- 0: a
-
-/\W/
- -
- 0: -
- *** Failers
- 0: *
- -
- 0: -
- a
-No match
-
-/a\sb/
- a b
- 0: a b
-
-/a\Sb/
- a-b
- 0: a-b
- *** Failers
-No match
- a-b
- 0: a-b
- a b
-No match
-
-/\d/
- 1
- 0: 1
-
-/\D/
- -
- 0: -
- *** Failers
- 0: *
- -
- 0: -
- 1
-No match
-
-/[\w]/
- a
- 0: a
-
-/[\W]/
- -
- 0: -
- *** Failers
- 0: *
- -
- 0: -
- a
-No match
-
-/a[\s]b/
- a b
- 0: a b
-
-/a[\S]b/
- a-b
- 0: a-b
- *** Failers
-No match
- a-b
- 0: a-b
- a b
-No match
-
-/[\d]/
- 1
- 0: 1
-
-/[\D]/
- -
- 0: -
- *** Failers
- 0: *
- -
- 0: -
- 1
-No match
-
-/ab|cd/
- abc
- 0: ab
- abcd
- 0: ab
-
-/()ef/
- def
- 0: ef
- 1:
-
-/$b/
-
-/a\(b/
- a(b
- 0: a(b
-
-/a\(*b/
- ab
- 0: ab
- a((b
- 0: a((b
-
-/a\\b/
- a\b
-No match
-
-/((a))/
- abc
- 0: a
- 1: a
- 2: a
-
-/(a)b(c)/
- abc
- 0: abc
- 1: a
- 2: c
-
-/a+b+c/
- aabbabc
- 0: abc
-
-/a{1,}b{1,}c/
- aabbabc
- 0: abc
-
-/a.+?c/
- abcabc
- 0: abc
-
-/(a+|b)*/
- ab
- 0: ab
- 1: b
-
-/(a+|b){0,}/
- ab
- 0: ab
- 1: b
-
-/(a+|b)+/
- ab
- 0: ab
- 1: b
-
-/(a+|b){1,}/
- ab
- 0: ab
- 1: b
-
-/(a+|b)?/
- ab
- 0: a
- 1: a
-
-/(a+|b){0,1}/
- ab
- 0: a
- 1: a
-
-/[^ab]*/
- cde
- 0: cde
-
-/abc/
- *** Failers
-No match
- b
-No match
-
-
-/a*/
-
-
-/([abc])*d/
- abbbcd
- 0: abbbcd
- 1: c
-
-/([abc])*bcd/
- abcd
- 0: abcd
- 1: a
-
-/a|b|c|d|e/
- e
- 0: e
-
-/(a|b|c|d|e)f/
- ef
- 0: ef
- 1: e
-
-/abcd*efg/
- abcdefg
- 0: abcdefg
-
-/ab*/
- xabyabbbz
- 0: ab
- xayabbbz
- 0: a
-
-/(ab|cd)e/
- abcde
- 0: cde
- 1: cd
-
-/[abhgefdc]ij/
- hij
- 0: hij
-
-/^(ab|cd)e/
-
-/(abc|)ef/
- abcdef
- 0: ef
- 1:
-
-/(a|b)c*d/
- abcd
- 0: bcd
- 1: b
-
-/(ab|ab*)bc/
- abc
- 0: abc
- 1: a
-
-/a([bc]*)c*/
- abc
- 0: abc
- 1: bc
-
-/a([bc]*)(c*d)/
- abcd
- 0: abcd
- 1: bc
- 2: d
-
-/a([bc]+)(c*d)/
- abcd
- 0: abcd
- 1: bc
- 2: d
-
-/a([bc]*)(c+d)/
- abcd
- 0: abcd
- 1: b
- 2: cd
-
-/a[bcd]*dcdcde/
- adcdcde
- 0: adcdcde
-
-/a[bcd]+dcdcde/
- *** Failers
-No match
- abcde
-No match
- adcdcde
-No match
-
-/(ab|a)b*c/
- abc
- 0: abc
- 1: ab
-
-/((a)(b)c)(d)/
- abcd
- 0: abcd
- 1: abc
- 2: a
- 3: b
- 4: d
-
-/[a-zA-Z_][a-zA-Z0-9_]*/
- alpha
- 0: alpha
-
-/^a(bc+|b[eh])g|.h$/
- abh
- 0: bh
-
-/(bc+d$|ef*g.|h?i(j|k))/
- effgz
- 0: effgz
- 1: effgz
- ij
- 0: ij
- 1: ij
- 2: j
- reffgz
- 0: effgz
- 1: effgz
- *** Failers
-No match
- effg
-No match
- bcdd
-No match
-
-/((((((((((a))))))))))/
- a
- 0: a
- 1: a
- 2: a
- 3: a
- 4: a
- 5: a
- 6: a
- 7: a
- 8: a
- 9: a
-10: a
-
-/((((((((((a))))))))))\10/
- aa
- 0: aa
- 1: a
- 2: a
- 3: a
- 4: a
- 5: a
- 6: a
- 7: a
- 8: a
- 9: a
-10: a
-
-/(((((((((a)))))))))/
- a
- 0: a
- 1: a
- 2: a
- 3: a
- 4: a
- 5: a
- 6: a
- 7: a
- 8: a
- 9: a
-
-/multiple words of text/
- *** Failers
-No match
- aa
-No match
- uh-uh
-No match
-
-/multiple words/
- multiple words, yeah
- 0: multiple words
-
-/(.*)c(.*)/
- abcde
- 0: abcde
- 1: ab
- 2: de
-
-/\((.*), (.*)\)/
- (a, b)
- 0: (a, b)
- 1: a
- 2: b
-
-/[k]/
-
-/abcd/
- abcd
- 0: abcd
-
-/a(bc)d/
- abcd
- 0: abcd
- 1: bc
-
-/a[-]?c/
- ac
- 0: ac
-
-/(abc)\1/
- abcabc
- 0: abcabc
- 1: abc
-
-/([a-c]*)\1/
- abcabc
- 0: abcabc
- 1: abc
-
-/(a)|\1/
- a
- 0: a
- 1: a
- *** Failers
- 0: a
- 1: a
- ab
- 0: a
- 1: a
- x
-No match
-
-/(([a-c])b*?\2)*/
- ababbbcbc
- 0: ababb
- 1: bb
- 2: b
-
-/(([a-c])b*?\2){3}/
- ababbbcbc
- 0: ababbbcbc
- 1: cbc
- 2: c
-
-/((\3|b)\2(a)x)+/
- aaaxabaxbaaxbbax
- 0: bbax
- 1: bbax
- 2: b
- 3: a
-
-/((\3|b)\2(a)){2,}/
- bbaababbabaaaaabbaaaabba
- 0: bbaaaabba
- 1: bba
- 2: b
- 3: a
-
-/abc/i
- ABC
- 0: ABC
- XABCY
- 0: ABC
- ABABC
- 0: ABC
- *** Failers
-No match
- aaxabxbaxbbx
-No match
- XBC
-No match
- AXC
-No match
- ABX
-No match
-
-/ab*c/i
- ABC
- 0: ABC
-
-/ab*bc/i
- ABC
- 0: ABC
- ABBC
- 0: ABBC
-
-/ab*?bc/i
- ABBBBC
- 0: ABBBBC
-
-/ab{0,}?bc/i
- ABBBBC
- 0: ABBBBC
-
-/ab+?bc/i
- ABBC
- 0: ABBC
-
-/ab+bc/i
- *** Failers
-No match
- ABC
-No match
- ABQ
-No match
-
-/ab{1,}bc/i
-
-/ab+bc/i
- ABBBBC
- 0: ABBBBC
-
-/ab{1,}?bc/i
- ABBBBC
- 0: ABBBBC
-
-/ab{1,3}?bc/i
- ABBBBC
- 0: ABBBBC
-
-/ab{3,4}?bc/i
- ABBBBC
- 0: ABBBBC
-
-/ab{4,5}?bc/i
- *** Failers
-No match
- ABQ
-No match
- ABBBBC
-No match
-
-/ab??bc/i
- ABBC
- 0: ABBC
- ABC
- 0: ABC
-
-/ab{0,1}?bc/i
- ABC
- 0: ABC
-
-/ab??bc/i
-
-/ab??c/i
- ABC
- 0: ABC
-
-/ab{0,1}?c/i
- ABC
- 0: ABC
-
-/^abc$/i
- ABC
- 0: ABC
- *** Failers
-No match
- ABBBBC
-No match
- ABCC
-No match
-
-/^abc/i
- ABCC
- 0: ABC
-
-/^abc$/i
-
-/abc$/i
- AABC
- 0: ABC
-
-/^/i
- ABC
- 0:
-
-/$/i
- ABC
- 0:
-
-/a.c/i
- ABC
- 0: ABC
- AXC
- 0: AXC
-
-/a.*?c/i
- AXYZC
- 0: AXYZC
-
-/a.*c/i
- *** Failers
-No match
- AABC
- 0: AABC
- AXYZD
-No match
-
-/a[bc]d/i
- ABD
- 0: ABD
-
-/a[b-d]e/i
- ACE
- 0: ACE
- *** Failers
-No match
- ABC
-No match
- ABD
-No match
-
-/a[b-d]/i
- AAC
- 0: AC
-
-/a[-b]/i
- A-
- 0: A-
-
-/a[b-]/i
- A-
- 0: A-
-
-/a]/i
- A]
- 0: A]
-
-/a[]]b/i
- A]B
- 0: A]B
-
-/a[^bc]d/i
- AED
- 0: AED
-
-/a[^-b]c/i
- ADC
- 0: ADC
- *** Failers
-No match
- ABD
-No match
- A-C
-No match
-
-/a[^]b]c/i
- ADC
- 0: ADC
-
-/ab|cd/i
- ABC
- 0: AB
- ABCD
- 0: AB
-
-/()ef/i
- DEF
- 0: EF
- 1:
-
-/$b/i
- *** Failers
-No match
- A]C
-No match
- B
-No match
-
-/a\(b/i
- A(B
- 0: A(B
-
-/a\(*b/i
- AB
- 0: AB
- A((B
- 0: A((B
-
-/a\\b/i
- A\B
-No match
-
-/((a))/i
- ABC
- 0: A
- 1: A
- 2: A
-
-/(a)b(c)/i
- ABC
- 0: ABC
- 1: A
- 2: C
-
-/a+b+c/i
- AABBABC
- 0: ABC
-
-/a{1,}b{1,}c/i
- AABBABC
- 0: ABC
-
-/a.+?c/i
- ABCABC
- 0: ABC
-
-/a.*?c/i
- ABCABC
- 0: ABC
-
-/a.{0,5}?c/i
- ABCABC
- 0: ABC
-
-/(a+|b)*/i
- AB
- 0: AB
- 1: B
-
-/(a+|b){0,}/i
- AB
- 0: AB
- 1: B
-
-/(a+|b)+/i
- AB
- 0: AB
- 1: B
-
-/(a+|b){1,}/i
- AB
- 0: AB
- 1: B
-
-/(a+|b)?/i
- AB
- 0: A
- 1: A
-
-/(a+|b){0,1}/i
- AB
- 0: A
- 1: A
-
-/(a+|b){0,1}?/i
- AB
- 0:
-
-/[^ab]*/i
- CDE
- 0: CDE
-
-/abc/i
-
-/a*/i
-
-
-/([abc])*d/i
- ABBBCD
- 0: ABBBCD
- 1: C
-
-/([abc])*bcd/i
- ABCD
- 0: ABCD
- 1: A
-
-/a|b|c|d|e/i
- E
- 0: E
-
-/(a|b|c|d|e)f/i
- EF
- 0: EF
- 1: E
-
-/abcd*efg/i
- ABCDEFG
- 0: ABCDEFG
-
-/ab*/i
- XABYABBBZ
- 0: AB
- XAYABBBZ
- 0: A
-
-/(ab|cd)e/i
- ABCDE
- 0: CDE
- 1: CD
-
-/[abhgefdc]ij/i
- HIJ
- 0: HIJ
-
-/^(ab|cd)e/i
- ABCDE
-No match
-
-/(abc|)ef/i
- ABCDEF
- 0: EF
- 1:
-
-/(a|b)c*d/i
- ABCD
- 0: BCD
- 1: B
-
-/(ab|ab*)bc/i
- ABC
- 0: ABC
- 1: A
-
-/a([bc]*)c*/i
- ABC
- 0: ABC
- 1: BC
-
-/a([bc]*)(c*d)/i
- ABCD
- 0: ABCD
- 1: BC
- 2: D
-
-/a([bc]+)(c*d)/i
- ABCD
- 0: ABCD
- 1: BC
- 2: D
-
-/a([bc]*)(c+d)/i
- ABCD
- 0: ABCD
- 1: B
- 2: CD
-
-/a[bcd]*dcdcde/i
- ADCDCDE
- 0: ADCDCDE
-
-/a[bcd]+dcdcde/i
-
-/(ab|a)b*c/i
- ABC
- 0: ABC
- 1: AB
-
-/((a)(b)c)(d)/i
- ABCD
- 0: ABCD
- 1: ABC
- 2: A
- 3: B
- 4: D
-
-/[a-zA-Z_][a-zA-Z0-9_]*/i
- ALPHA
- 0: ALPHA
-
-/^a(bc+|b[eh])g|.h$/i
- ABH
- 0: BH
-
-/(bc+d$|ef*g.|h?i(j|k))/i
- EFFGZ
- 0: EFFGZ
- 1: EFFGZ
- IJ
- 0: IJ
- 1: IJ
- 2: J
- REFFGZ
- 0: EFFGZ
- 1: EFFGZ
- *** Failers
-No match
- ADCDCDE
-No match
- EFFG
-No match
- BCDD
-No match
-
-/((((((((((a))))))))))/i
- A
- 0: A
- 1: A
- 2: A
- 3: A
- 4: A
- 5: A
- 6: A
- 7: A
- 8: A
- 9: A
-10: A
-
-/((((((((((a))))))))))\10/i
- AA
- 0: AA
- 1: A
- 2: A
- 3: A
- 4: A
- 5: A
- 6: A
- 7: A
- 8: A
- 9: A
-10: A
-
-/(((((((((a)))))))))/i
- A
- 0: A
- 1: A
- 2: A
- 3: A
- 4: A
- 5: A
- 6: A
- 7: A
- 8: A
- 9: A
-
-/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i
- A
- 0: A
- 1: A
-
-/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i
- C
- 0: C
- 1: C
-
-/multiple words of text/i
- *** Failers
-No match
- AA
-No match
- UH-UH
-No match
-
-/multiple words/i
- MULTIPLE WORDS, YEAH
- 0: MULTIPLE WORDS
-
-/(.*)c(.*)/i
- ABCDE
- 0: ABCDE
- 1: AB
- 2: DE
-
-/\((.*), (.*)\)/i
- (A, B)
- 0: (A, B)
- 1: A
- 2: B
-
-/[k]/i
-
-/abcd/i
- ABCD
- 0: ABCD
-
-/a(bc)d/i
- ABCD
- 0: ABCD
- 1: BC
-
-/a[-]?c/i
- AC
- 0: AC
-
-/(abc)\1/i
- ABCABC
- 0: ABCABC
- 1: ABC
-
-/([a-c]*)\1/i
- ABCABC
- 0: ABCABC
- 1: ABC
-
-/a(?!b)./
- abad
- 0: ad
-
-/a(?=d)./
- abad
- 0: ad
-
-/a(?=c|d)./
- abad
- 0: ad
-
-/a(?:b|c|d)(.)/
- ace
- 0: ace
- 1: e
-
-/a(?:b|c|d)*(.)/
- ace
- 0: ace
- 1: e
-
-/a(?:b|c|d)+?(.)/
- ace
- 0: ace
- 1: e
- acdbcdbe
- 0: acd
- 1: d
-
-/a(?:b|c|d)+(.)/
- acdbcdbe
- 0: acdbcdbe
- 1: e
-
-/a(?:b|c|d){2}(.)/
- acdbcdbe
- 0: acdb
- 1: b
-
-/a(?:b|c|d){4,5}(.)/
- acdbcdbe
- 0: acdbcdb
- 1: b
-
-/a(?:b|c|d){4,5}?(.)/
- acdbcdbe
- 0: acdbcd
- 1: d
-
-/((foo)|(bar))*/
- foobar
- 0: foobar
- 1: bar
- 2: foo
- 3: bar
-
-/a(?:b|c|d){6,7}(.)/
- acdbcdbe
- 0: acdbcdbe
- 1: e
-
-/a(?:b|c|d){6,7}?(.)/
- acdbcdbe
- 0: acdbcdbe
- 1: e
-
-/a(?:b|c|d){5,6}(.)/
- acdbcdbe
- 0: acdbcdbe
- 1: e
-
-/a(?:b|c|d){5,6}?(.)/
- acdbcdbe
- 0: acdbcdb
- 1: b
-
-/a(?:b|c|d){5,7}(.)/
- acdbcdbe
- 0: acdbcdbe
- 1: e
-
-/a(?:b|c|d){5,7}?(.)/
- acdbcdbe
- 0: acdbcdb
- 1: b
-
-/a(?:b|(c|e){1,2}?|d)+?(.)/
- ace
- 0: ace
- 1: c
- 2: e
-
-/^(.+)?B/
- AB
- 0: AB
- 1: A
-
-/^([^a-z])|(\^)$/
- .
- 0: .
- 1: .
-
-/^[<>]&/
- <&OUT
- 0: <&
-
-/^(a\1?){4}$/
- aaaaaaaaaa
- 0: aaaaaaaaaa
- 1: aaaa
- *** Failers
-No match
- AB
-No match
- aaaaaaaaa
-No match
- aaaaaaaaaaa
-No match
-
-/^(a(?(1)\1)){4}$/
- aaaaaaaaaa
- 0: aaaaaaaaaa
- 1: aaaa
- *** Failers
-No match
- aaaaaaaaa
-No match
- aaaaaaaaaaa
-No match
-
-/(?:(f)(o)(o)|(b)(a)(r))*/
- foobar
- 0: foobar
- 1: f
- 2: o
- 3: o
- 4: b
- 5: a
- 6: r
-
-/(?<=a)b/
- ab
- 0: b
- *** Failers
-No match
- cb
-No match
- b
-No match
-
-/(?<!c)b/
- ab
- 0: b
- b
- 0: b
- b
- 0: b
-
-/(?:..)*a/
- aba
- 0: aba
-
-/(?:..)*?a/
- aba
- 0: a
-
-/^(?:b|a(?=(.)))*\1/
- abc
- 0: ab
- 1: b
-
-/^(){3,5}/
- abc
- 0:
- 1:
-
-/^(a+)*ax/
- aax
- 0: aax
- 1: a
-
-/^((a|b)+)*ax/
- aax
- 0: aax
- 1: a
- 2: a
-
-/^((a|bc)+)*ax/
- aax
- 0: aax
- 1: a
- 2: a
-
-/(a|x)*ab/
- cab
- 0: ab
-
-/(a)*ab/
- cab
- 0: ab
-
-/(?:(?i)a)b/
- ab
- 0: ab
-
-/((?i)a)b/
- ab
- 0: ab
- 1: a
-
-/(?:(?i)a)b/
- Ab
- 0: Ab
-
-/((?i)a)b/
- Ab
- 0: Ab
- 1: A
-
-/(?:(?i)a)b/
- *** Failers
-No match
- cb
-No match
- aB
-No match
-
-/((?i)a)b/
-
-/(?i:a)b/
- ab
- 0: ab
-
-/((?i:a))b/
- ab
- 0: ab
- 1: a
-
-/(?i:a)b/
- Ab
- 0: Ab
-
-/((?i:a))b/
- Ab
- 0: Ab
- 1: A
-
-/(?i:a)b/
- *** Failers
-No match
- aB
-No match
- aB
-No match
-
-/((?i:a))b/
-
-/(?:(?-i)a)b/i
- ab
- 0: ab
-
-/((?-i)a)b/i
- ab
- 0: ab
- 1: a
-
-/(?:(?-i)a)b/i
- aB
- 0: aB
-
-/((?-i)a)b/i
- aB
- 0: aB
- 1: a
-
-/(?:(?-i)a)b/i
- *** Failers
-No match
- aB
- 0: aB
- Ab
-No match
-
-/((?-i)a)b/i
-
-/(?:(?-i)a)b/i
- aB
- 0: aB
-
-/((?-i)a)b/i
- aB
- 0: aB
- 1: a
-
-/(?:(?-i)a)b/i
- *** Failers
-No match
- Ab
-No match
- AB
-No match
-
-/((?-i)a)b/i
-
-/(?-i:a)b/i
- ab
- 0: ab
-
-/((?-i:a))b/i
- ab
- 0: ab
- 1: a
-
-/(?-i:a)b/i
- aB
- 0: aB
-
-/((?-i:a))b/i
- aB
- 0: aB
- 1: a
-
-/(?-i:a)b/i
- *** Failers
-No match
- AB
-No match
- Ab
-No match
-
-/((?-i:a))b/i
-
-/(?-i:a)b/i
- aB
- 0: aB
-
-/((?-i:a))b/i
- aB
- 0: aB
- 1: a
-
-/(?-i:a)b/i
- *** Failers
-No match
- Ab
-No match
- AB
-No match
-
-/((?-i:a))b/i
-
-/((?-i:a.))b/i
- *** Failers
-No match
- AB
-No match
- a\nB
-No match
-
-/((?s-i:a.))b/i
- a\nB
- 0: a\x0aB
- 1: a\x0a
-
-/(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
- cabbbb
- 0: cabbbb
-
-/(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
- caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
- 0: caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
-
-/(ab)\d\1/i
- Ab4ab
- 0: Ab4ab
- 1: Ab
- ab4Ab
- 0: ab4Ab
- 1: ab
-
-/foo\w*\d{4}baz/
- foobar1234baz
- 0: foobar1234baz
-
-/x(~~)*(?:(?:F)?)?/
- x~~
- 0: x~~
- 1: ~~
-
-/^a(?#xxx){3}c/
- aaac
- 0: aaac
-
-/^a (?#xxx) (?#yyy) {3}c/x
- aaac
- 0: aaac
-
-/(?<![cd])b/
- *** Failers
-No match
- B\nB
-No match
- dbcb
-No match
-
-/(?<![cd])[ab]/
- dbaacb
- 0: a
-
-/(?<!(c|d))b/
-
-/(?<!(c|d))[ab]/
- dbaacb
- 0: a
-
-/(?<!cd)[ab]/
- cdaccb
- 0: b
-
-/^(?:a?b?)*$/
- *** Failers
-No match
- dbcb
-No match
- a--
-No match
-
-/((?s)^a(.))((?m)^b$)/
- a\nb\nc\n
- 0: a\x0ab
- 1: a\x0a
- 2: \x0a
- 3: b
-
-/((?m)^b$)/
- a\nb\nc\n
- 0: b
- 1: b
-
-/(?m)^b/
- a\nb\n
- 0: b
-
-/(?m)^(b)/
- a\nb\n
- 0: b
- 1: b
-
-/((?m)^b)/
- a\nb\n
- 0: b
- 1: b
-
-/\n((?m)^b)/
- a\nb\n
- 0: \x0ab
- 1: b
-
-/((?s).)c(?!.)/
- a\nb\nc\n
- 0: \x0ac
- 1: \x0a
- a\nb\nc\n
- 0: \x0ac
- 1: \x0a
-
-/((?s)b.)c(?!.)/
- a\nb\nc\n
- 0: b\x0ac
- 1: b\x0a
- a\nb\nc\n
- 0: b\x0ac
- 1: b\x0a
-
-/^b/
-
-/()^b/
- *** Failers
-No match
- a\nb\nc\n
-No match
- a\nb\nc\n
-No match
-
-/((?m)^b)/
- a\nb\nc\n
- 0: b
- 1: b
-
-/(?(1)a|b)/
-
-/(?(1)b|a)/
- a
- 0: a
-
-/(x)?(?(1)a|b)/
- *** Failers
-No match
- a
-No match
- a
-No match
-
-/(x)?(?(1)b|a)/
- a
- 0: a
-
-/()?(?(1)b|a)/
- a
- 0: a
-
-/()(?(1)b|a)/
-
-/()?(?(1)a|b)/
- a
- 0: a
- 1:
-
-/^(\()?blah(?(1)(\)))$/
- (blah)
- 0: (blah)
- 1: (
- 2: )
- blah
- 0: blah
- *** Failers
-No match
- a
-No match
- blah)
-No match
- (blah
-No match
-
-/^(\(+)?blah(?(1)(\)))$/
- (blah)
- 0: (blah)
- 1: (
- 2: )
- blah
- 0: blah
- *** Failers
-No match
- blah)
-No match
- (blah
-No match
-
-/(?(?!a)a|b)/
-
-/(?(?!a)b|a)/
- a
- 0: a
-
-/(?(?=a)b|a)/
- *** Failers
-No match
- a
-No match
- a
-No match
-
-/(?(?=a)a|b)/
- a
- 0: a
-
-/(?=(a+?))(\1ab)/
- aaab
- 0: aab
- 1: a
- 2: aab
-
-/^(?=(a+?))\1ab/
-
-/(\w+:)+/
- one:
- 0: one:
- 1: one:
-
-/$(?<=^(a))/
- a
- 0:
- 1: a
-
-/(?=(a+?))(\1ab)/
- aaab
- 0: aab
- 1: a
- 2: aab
-
-/^(?=(a+?))\1ab/
- *** Failers
-No match
- aaab
-No match
- aaab
-No match
-
-/([\w:]+::)?(\w+)$/
- abcd
- 0: abcd
- 1: <unset>
- 2: abcd
- xy:z:::abcd
- 0: xy:z:::abcd
- 1: xy:z:::
- 2: abcd
-
-/^[^bcd]*(c+)/
- aexycd
- 0: aexyc
- 1: c
-
-/(a*)b+/
- caab
- 0: aab
- 1: aa
-
-/([\w:]+::)?(\w+)$/
- abcd
- 0: abcd
- 1: <unset>
- 2: abcd
- xy:z:::abcd
- 0: xy:z:::abcd
- 1: xy:z:::
- 2: abcd
- *** Failers
- 0: Failers
- 1: <unset>
- 2: Failers
- abcd:
-No match
- abcd:
-No match
-
-/^[^bcd]*(c+)/
- aexycd
- 0: aexyc
- 1: c
-
-/(>a+)ab/
-
-/(?>a+)b/
- aaab
- 0: aaab
-
-/([[:]+)/
- a:[b]:
- 0: :[
- 1: :[
-
-/([[=]+)/
- a=[b]=
- 0: =[
- 1: =[
-
-/([[.]+)/
- a.[b].
- 0: .[
- 1: .[
-
-/((?>a+)b)/
- aaab
- 0: aaab
- 1: aaab
-
-/(?>(a+))b/
- aaab
- 0: aaab
- 1: aaa
-
-/((?>[^()]+)|\([^()]*\))+/
- ((abc(ade)ufh()()x
- 0: abc(ade)ufh()()x
- 1: x
-
-/a\Z/
- *** Failers
-No match
- aaab
-No match
- a\nb\n
-No match
-
-/b\Z/
- a\nb\n
- 0: b
-
-/b\z/
-
-/b\Z/
- a\nb
- 0: b
-
-/b\z/
- a\nb
- 0: b
- *** Failers
-No match
-
-/^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$/
- a
- 0: a
- 1:
- abc
- 0: abc
- 1:
- a-b
- 0: a-b
- 1:
- 0-9
- 0: 0-9
- 1:
- a.b
- 0: a.b
- 1:
- 5.6.7
- 0: 5.6.7
- 1:
- the.quick.brown.fox
- 0: the.quick.brown.fox
- 1:
- a100.b200.300c
- 0: a100.b200.300c
- 1:
- 12-ab.1245
- 0: 12-ab.1245
- 1:
- ***Failers
-No match
- \
-No match
- .a
-No match
- -a
-No match
- a-
-No match
- a.
-No match
- a_b
-No match
- a.-
-No match
- a..
-No match
- ab..bc
-No match
- the.quick.brown.fox-
-No match
- the.quick.brown.fox.
-No match
- the.quick.brown.fox_
-No match
- the.quick.brown.fox+
-No match
-
-/(?>.*)(?<=(abcd|wxyz))/
- alphabetabcd
- 0: alphabetabcd
- 1: abcd
- endingwxyz
- 0: endingwxyz
- 1: wxyz
- *** Failers
-No match
- a rather long string that doesn't end with one of them
-No match
-
-/word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/
- word cat dog elephant mussel cow horse canary baboon snake shark otherword
- 0: word cat dog elephant mussel cow horse canary baboon snake shark otherword
- word cat dog elephant mussel cow horse canary baboon snake shark
-No match
-
-/word (?>[a-zA-Z0-9]+ ){0,30}otherword/
- word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
-No match
-
-/(?<=\d{3}(?!999))foo/
- 999foo
- 0: foo
- 123999foo
- 0: foo
- *** Failers
-No match
- 123abcfoo
-No match
-
-/(?<=(?!...999)\d{3})foo/
- 999foo
- 0: foo
- 123999foo
- 0: foo
- *** Failers
-No match
- 123abcfoo
-No match
-
-/(?<=\d{3}(?!999)...)foo/
- 123abcfoo
- 0: foo
- 123456foo
- 0: foo
- *** Failers
-No match
- 123999foo
-No match
-
-/(?<=\d{3}...)(?<!999)foo/
- 123abcfoo
- 0: foo
- 123456foo
- 0: foo
- *** Failers
-No match
- 123999foo
-No match
-
-/<a[\s]+href[\s]*=[\s]* # find <a href=
- ([\"\'])? # find single or double quote
- (?(1) (.*?)\1 | ([^\s]+)) # if quote found, match up to next matching
- # quote, otherwise match up to next space
-/isx
- <a href=abcd xyz
- 0: <a href=abcd
- 1: <unset>
- 2: <unset>
- 3: abcd
- <a href=\"abcd xyz pqr\" cats
- 0: <a href="abcd xyz pqr"
- 1: "
- 2: abcd xyz pqr
- <a href=\'abcd xyz pqr\' cats
- 0: <a href='abcd xyz pqr'
- 1: '
- 2: abcd xyz pqr
-
-/<a\s+href\s*=\s* # find <a href=
- (["'])? # find single or double quote
- (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
- # quote, otherwise match up to next space
-/isx
- <a href=abcd xyz
- 0: <a href=abcd
- 1: <unset>
- 2: <unset>
- 3: abcd
- <a href=\"abcd xyz pqr\" cats
- 0: <a href="abcd xyz pqr"
- 1: "
- 2: abcd xyz pqr
- <a href = \'abcd xyz pqr\' cats
- 0: <a href = 'abcd xyz pqr'
- 1: '
- 2: abcd xyz pqr
-
-/<a\s+href(?>\s*)=(?>\s*) # find <a href=
- (["'])? # find single or double quote
- (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
- # quote, otherwise match up to next space
-/isx
- <a href=abcd xyz
- 0: <a href=abcd
- 1: <unset>
- 2: <unset>
- 3: abcd
- <a href=\"abcd xyz pqr\" cats
- 0: <a href="abcd xyz pqr"
- 1: "
- 2: abcd xyz pqr
- <a href = \'abcd xyz pqr\' cats
- 0: <a href = 'abcd xyz pqr'
- 1: '
- 2: abcd xyz pqr
-
-/ End of test input /
-
diff --git a/ext/pcre/pcrelib/testoutput4 b/ext/pcre/pcrelib/testoutput4
deleted file mode 100644
index c8af6cf5c3..0000000000
--- a/ext/pcre/pcrelib/testoutput4
+++ /dev/null
@@ -1,115 +0,0 @@
-PCRE version 2.08 31-Aug-1999
-
-/^[\w]+/
- *** Failers
-No match
- École
-No match
-
-/^[\w]+/Lfr
- École
- 0: École
-
-/^[\w]+/
- *** Failers
-No match
- École
-No match
-
-/^[\W]+/
- École
- 0: \xc9
-
-/^[\W]+/Lfr
- *** Failers
- 0: ***
- École
-No match
-
-/[\b]/
- \b
- 0: \x08
- *** Failers
-No match
- a
-No match
-
-/[\b]/Lfr
- \b
- 0: \x08
- *** Failers
-No match
- a
-No match
-
-/^\w+/
- *** Failers
-No match
- École
-No match
-
-/^\w+/Lfr
- École
- 0: École
-
-/(.+)\b(.+)/
- École
- 0: \xc9cole
- 1: \xc9
- 2: cole
-
-/(.+)\b(.+)/Lfr
- *** Failers
- 0: *** Failers
- 1: ***
- 2: Failers
- École
-No match
-
-/École/i
- École
- 0: \xc9cole
- *** Failers
-No match
- école
-No match
-
-/École/iLfr
- École
- 0: École
- école
- 0: école
-
-/\w/IS
-Identifying subpattern count = 0
-No options
-No first char
-No req char
-Starting character set: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P
- Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z
-
-/\w/ISLfr
-Identifying subpattern count = 0
-No options
-No first char
-No req char
-Starting character set: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P
- Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z
- À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å
- æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ø ù ú û ü ý þ ÿ
-
-/^[\xc8-\xc9]/iLfr
- École
- 0: É
- école
- 0: é
-
-/^[\xc8-\xc9]/Lfr
- École
- 0: É
- *** Failers
-No match
- école
-No match
-
-
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
deleted file mode 100644
index d80c174ae3..0000000000
--- a/ext/pcre/php_pcre.c
+++ /dev/null
@@ -1,1197 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Andrey Zmievski <andrey@ispi.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/*
- TODO:
- - Allow user to set PCRE_NOTEMPTY, PCRE_ANCHORED at execution time
- - Have an option for preg_split() to not return empty strings
-*/
-
-#include "php.h"
-#include "php_globals.h"
-#include "php_pcre.h"
-
-#if HAVE_PCRE || HAVE_BUNDLED_PCRE
-
-#include "ext/standard/php3_string.h"
-
-#define PREG_PATTERN_ORDER 0
-#define PREG_SET_ORDER 1
-
-#define PREG_REPLACE_EVAL (1<<0)
-
-#ifdef ZTS
-int pcre_globals_id;
-#else
-php_pcre_globals pcre_globals;
-#endif
-
-
-static void *php_pcre_malloc(size_t size)
-{
- return pemalloc(size, 1);
-}
-
-
-static void php_pcre_free(void *ptr)
-{
- pefree(ptr, 1);
-}
-
-
-static int _php_free_pcre_cache(void *data)
-{
- pcre_cache_entry *pce = (pcre_cache_entry *) data;
- pefree(pce->re, 1);
-#if HAVE_SETLOCALE
- pefree((void*)pce->tables, 1);
-#endif
- return 1;
-}
-
-
-#ifdef ZTS
-static void _php_pcre_init_globals(php_pcre_globals *pcre_globals)
-{
- zend_hash_init(&PCRE_G(pcre_cache), 0, NULL, _php_free_pcre_cache, 1);
-}
-
-
-static void _php_pcre_shutdown_globals(php_pcre_globals *pcre_globals)
-{
- zend_hash_destroy(&PCRE_G(pcre_cache));
-}
-#endif
-
-
-static /* {{{ PHP_MINFO_FUNCTION(pcre) */
-PHP_MINFO_FUNCTION(pcre)
-{
- php_printf("Perl Compatible Regular Expressions");
- php_printf("<table cellpadding=5>"
- "<tr><td>PCRE library version:</td>"
- "<td>%s</td></tr>"
- "</table>", pcre_version());
-}
-/* }}} */
-
-
-/* {{{ PHP_MINIT_FUNCTION(pcre) */
-static PHP_MINIT_FUNCTION(pcre)
-{
- ELS_FETCH();
-
-#ifdef ZTS
- pcre_globals_id = ts_allocate_id(
- sizeof(php_pcre_globals),
- _php_pcre_init_globals,
- _php_pcre_shutdown_globals);
-#else
- zend_hash_init(&PCRE_G(pcre_cache), 0, NULL, _php_free_pcre_cache, 1);
-#endif
-
- REGISTER_LONG_CONSTANT("PREG_PATTERN_ORDER", PREG_PATTERN_ORDER, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("PREG_SET_ORDER", PREG_SET_ORDER, CONST_CS | CONST_PERSISTENT);
- return SUCCESS;
-}
-/* }}} */
-
-
-/* {{{ PHP_MSHUTDOWN_FUNCTION(pcre) */
-static PHP_MSHUTDOWN_FUNCTION(pcre)
-{
-#ifndef ZTS
- zend_hash_destroy(&PCRE_G(pcre_cache));
-#else
- ts_free_id(pcre_globals_id);
-#endif
- return SUCCESS;
-}
-/* }}} */
-
-
-/* {{{ PHP_RINIT_FUNCTION(pcre) */
-static PHP_RINIT_FUNCTION(pcre)
-{
- pcre_malloc = php_pcre_malloc;
- pcre_free = php_pcre_free;
-
- return SUCCESS;
-}
-/* }}} */
-
-
-/* {{{ static pcre* _pcre_get_compiled_regex(char *regex, pcre_extra *extra) */
-static pcre* _pcre_get_compiled_regex(char *regex, pcre_extra *extra, int *preg_options) {
- pcre *re = NULL;
- int coptions = 0;
- int soptions = 0;
- const char *error;
- int erroffset;
- char delimiter;
- char *p, *pp;
- char *pattern;
- int regex_len;
- int do_study = 0;
- int poptions = 0;
- unsigned const char *tables = NULL;
-#if HAVE_SETLOCALE
- char *locale = setlocale(LC_CTYPE, NULL);
-#endif
- pcre_cache_entry *pce;
- pcre_cache_entry new_entry;
- PCRE_LS_FETCH();
-
- /* Try to lookup the cached regex entry, and if successful, just pass
- back the compiled pattern, otherwise go on and compile it. */
- regex_len = strlen(regex);
- if (zend_hash_find(&PCRE_G(pcre_cache), regex, regex_len+1, (void **)&pce) == SUCCESS) {
-#if HAVE_SETLOCALE
- if (!strcmp(pce->locale, locale)) {
-#endif
- extra = pce->extra;
- *preg_options = pce->preg_options;
- return pce->re;
-#if HAVE_SETLOCALE
- }
-#endif
- }
-
- p = regex;
-
- /* Parse through the leading whitespace, and display a warning if we
- get to the end without encountering a delimiter. */
- while (isspace((int)*p)) p++;
- if (*p == 0) {
- zend_error(E_WARNING, "Empty regular expression");
- return NULL;
- }
-
- /* Get the delimiter and display a warning if it is alphanumeric
- or a backslash. */
- delimiter = *p++;
- if (isalnum((int)delimiter) || delimiter == '\\') {
- zend_error(E_WARNING, "Delimiter must not be alphanumeric or backslash");
- return NULL;
- }
-
- /* We need to iterate through the pattern, searching for the ending delimiter,
- but skipping the backslashed delimiters. If the ending delimiter is not
- found, display a warning. */
- pp = p;
- while (*pp != 0) {
- if (*pp == delimiter && pp[-1] != '\\')
- break;
- pp++;
- }
- if (*pp == 0) {
- zend_error(E_WARNING, "No ending delimiter found");
- return NULL;
- }
-
- /* Make a copy of the actual pattern. */
- pattern = estrndup(p, pp-p);
-
- /* Move on to the options */
- pp++;
-
- /* Clear out preg options */
- *preg_options = 0;
-
- /* Parse through the options, setting appropriate flags. Display
- a warning if we encounter an unknown modifier. */
- while (*pp != 0) {
- switch (*pp++) {
- /* Perl compatible options */
- case 'i': coptions |= PCRE_CASELESS; break;
- case 'm': coptions |= PCRE_MULTILINE; break;
- case 's': coptions |= PCRE_DOTALL; break;
- case 'x': coptions |= PCRE_EXTENDED; break;
-
- /* PCRE specific options */
- case 'A': coptions |= PCRE_ANCHORED; break;
- case 'D': coptions |= PCRE_DOLLAR_ENDONLY;break;
- case 'S': do_study = 1; break;
- case 'U': coptions |= PCRE_UNGREEDY; break;
- case 'X': coptions |= PCRE_EXTRA; break;
-
- /* Custom preg options */
- case 'e': poptions |= PREG_REPLACE_EVAL; break;
-
- case ' ':
- case '\n':
- break;
-
- default:
- zend_error(E_WARNING, "Unknown modifier '%c'", pp[-1]);
- efree(pattern);
- return NULL;
- }
- }
-
-#if HAVE_SETLOCALE
- if (strcmp(locale, "C"))
- tables = pcre_maketables();
-#endif
-
- /* Compile pattern and display a warning if compilation failed. */
- re = pcre_compile(pattern,
- coptions,
- &error,
- &erroffset,
- tables);
-
- if (re == NULL) {
- zend_error(E_WARNING, "Compilation failed: %s at offset %d\n", error, erroffset);
- efree(pattern);
- return NULL;
- }
-
- /* If study option was specified, study the pattern and
- store the result in extra for passing to pcre_exec. */
- if (do_study) {
- extra = pcre_study(re, soptions, &error);
- if (error != NULL) {
- zend_error(E_WARNING, "Error while studying pattern");
- }
- }
-
- *preg_options = poptions;
-
- efree(pattern);
-
- /* Store the compiled pattern and extra info in the cache. */
- new_entry.re = re;
- new_entry.extra = extra;
- new_entry.preg_options = poptions;
-#if HAVE_SETLOCALE
- new_entry.locale = locale;
- new_entry.tables = tables;
-#endif
- zend_hash_update(&PCRE_G(pcre_cache), regex, regex_len+1, (void *)&new_entry,
- sizeof(pcre_cache_entry), NULL);
-
- return re;
-}
-/* }}} */
-
-
-/* {{{ void _pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) */
-static void _pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global)
-{
- zval *regex, /* Regular expression */
- *subject, /* String to match against */
- *subpats = NULL, /* Array for subpatterns */
- *subpats_order, /* Order of the results in the subpatterns
- array for global match */
- *result_set, /* Holds a set of subpatterns after
- a global match */
- **match_sets = NULL; /* An array of sets of matches for each
- subpattern after a global match */
- pcre *re = NULL; /* Compiled regular expression */
- pcre_extra *extra = NULL; /* Holds results of studying */
- int exoptions = 0; /* Execution options */
- int preg_options = 0; /* Custom preg options */
- int count = 0; /* Count of matched subpatterns */
- int *offsets; /* Array of subpattern offsets */
- int num_subpats; /* Number of captured subpatterns */
- int size_offsets; /* Size of the offsets array */
- int start_offset; /* Where the new search starts */
- int matched; /* Has anything matched */
- int i;
- int subpats_order_val = 0; /* Integer value of subpats_order */
- int g_notempty = 0; /* If the match should not be empty */
- const char **stringlist; /* Used to hold list of subpatterns */
- char *match; /* The current match */
-
-
- /* Get function parameters and do error-checking. */
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &regex, &subject) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
-
- case 3:
- if (getParameters(ht, 3, &regex, &subject, &subpats) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- if (global)
- subpats_order_val = PREG_PATTERN_ORDER;
- if (!ParameterPassedByReference(ht, 3)) {
- zend_error(E_WARNING, "Array to be filled with matches must be passed by reference.");
- RETURN_FALSE;
- }
- break;
-
- case 4:
- if (getParameters(ht, 4, &regex, &subject, &subpats, &subpats_order) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- if (!ParameterPassedByReference(ht, 3)) {
- zend_error(E_WARNING, "Array to be filled with matches must be passed by reference.");
- RETURN_FALSE;
- }
-
- /* Make sure subpats_order is a number */
- convert_to_long(subpats_order);
- subpats_order_val = subpats_order->value.lval;
- if (subpats_order_val < PREG_PATTERN_ORDER ||
- subpats_order_val > PREG_SET_ORDER) {
- zend_error(E_WARNING, "Wrong value for parameter 4 in call to preg_match_all()");
- }
- break;
-
- default:
- WRONG_PARAM_COUNT;
- }
-
- /* Make sure we're dealing with strings. */
- convert_to_string(regex);
- convert_to_string(subject);
-
- /* Make sure to clean up the passed array and initialize it. */
- if (subpats != NULL) {
- zval_dtor(subpats);
- array_init(subpats);
- }
-
- /* Compile regex or get it from cache. */
- if ((re = _pcre_get_compiled_regex(regex->value.str.val, extra, &preg_options)) == NULL) {
- RETURN_FALSE;
- }
-
- /* Calculate the size of the offsets array, and allocate memory for it. */
- num_subpats = pcre_info(re, NULL, NULL) + 1;
- size_offsets = num_subpats * 3;
- offsets = (int *)emalloc(size_offsets * sizeof(int));
-
- /* Allocate match sets array and initialize the values */
- if (global && subpats_order_val == PREG_PATTERN_ORDER) {
- match_sets = (zval **)emalloc(num_subpats * sizeof(zval *));
- for (i=0; i<num_subpats; i++) {
- match_sets[i] = (zval *)emalloc(sizeof(zval));
- array_init(match_sets[i]);
- INIT_PZVAL(match_sets[i]);
- }
- }
-
- /* Start from the beginning of the string */
- start_offset = 0;
- match = NULL;
- matched = 0;
-
- do {
- /* Execute the regular expression. */
- count = pcre_exec(re, extra, subject->value.str.val,
- subject->value.str.len, start_offset,
- exoptions|g_notempty, offsets, size_offsets);
-
- /* Check for too many substrings condition. */
- if (count == 0) {
- zend_error(E_NOTICE, "Matched, but too many substrings\n");
- count = size_offsets/3;
- }
-
- /* If something has matched */
- if (count >= 0) {
- matched++;
- match = subject->value.str.val + offsets[0];
-
- /* If subpatters array has been passed, fill it in with values. */
- if (subpats != NULL) {
- /* Try to get the list of substrings and display a warning if failed. */
- if (pcre_get_substring_list(subject->value.str.val,
- offsets, count, &stringlist) < 0) {
- efree(offsets);
- efree(re);
- zend_error(E_WARNING, "Get subpatterns list failed");
- return;
- }
-
- if (global) { /* global pattern matching */
- if (subpats_order_val == PREG_PATTERN_ORDER) {
- /* For each subpattern, insert it into the appropriate array */
- for (i=0; i<count; i++) {
- add_next_index_string(match_sets[i], (char *)stringlist[i], 1);
- }
- }
- else {
- /* Allocate the result set array */
- result_set = emalloc(sizeof(zval));
- array_init(result_set);
- INIT_PZVAL(result_set);
-
- /* Add all the subpatterns to it */
- for (i=0; i<count; i++) {
- add_next_index_string(result_set, (char *)stringlist[i], 1);
- }
- /* And add it to the output array */
- zend_hash_next_index_insert(subpats->value.ht, &result_set,
- sizeof(zval *), NULL);
- }
- }
- else { /* single pattern matching */
- /* For each subpattern, insert it into the subpatterns array. */
- for (i=0; i<count; i++) {
- add_next_index_string(subpats, (char *)stringlist[i], 1);
- }
- }
-
- php_pcre_free((void *) stringlist);
- }
- }
- else { /* Failed to match */
- /* If we previously set PCRE_NOTEMPTY after a null match,
- this is not necessarily the end. We need to advance
- the start offset, and continue. Fudge the offset values
- to achieve this, unless we're already at the end of the string. */
- if (g_notempty != 0 && start_offset < subject->value.str.len) {
- offsets[0] = start_offset;
- offsets[1] = start_offset + 1;
- } else
- break;
- }
-
- /* If we have matched an empty string, mimic what Perl's /g options does.
- This turns out to be rather cunning. First we set PCRE_NOTEMPTY and try
- the match again at the same point. If this fails (picked up above) we
- advance to the next character. */
- g_notempty = (offsets[1] == offsets[0])? PCRE_NOTEMPTY : 0;
-
- /* Advance to the position right after the last full match */
- start_offset = offsets[1];
- } while (global);
-
- /* Add the match sets to the output array and clean up */
- if (global && subpats_order_val == PREG_PATTERN_ORDER) {
- for (i=0; i<num_subpats; i++) {
- zend_hash_next_index_insert(subpats->value.ht, &match_sets[i], sizeof(zval *), NULL);
- }
- efree(match_sets);
- }
-
- efree(offsets);
-
- RETVAL_LONG(matched);
-}
-/* }}} */
-
-
-/* {{{ proto int preg_match(string pattern, string subject [, array subpatterns ])
- Perform a Perl-style regular expression match */
-PHP_FUNCTION(preg_match)
-{
- _pcre_match(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-
-/* {{{ proto int preg_match_all(string pattern, string subject, array subpatterns [, int order ])
- Perform a Perl-style global regular expression match */
-PHP_FUNCTION(preg_match_all)
-{
- _pcre_match(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-
-/* {{{ int _preg_get_backref(const char *walk, int *backref) */
-static int _preg_get_backref(const char *walk, int *backref)
-{
- if (*walk && *walk >= '0' && *walk <= '9')
- *backref = *walk - '0';
- else
- return 0;
-
- if (walk[1] && walk[1] >= '0' && walk[1] <= '9')
- *backref = *backref * 10 + walk[1] - '0';
-
- return 1;
-}
-/* }}} */
-
-
-/* {{{ int _preg_do_eval(char *eval_str, char *subject, int *offsets,
- int count, char **result) */
-static int _preg_do_eval(char *eval_str, char *subject, int *offsets,
- int count, char **result)
-{
- zval retval; /* Return value from evaluation */
- char backref_buf[4], /* Buffer for string version of backref */
- *code, /* PHP code string */
- *new_code, /* Code as result of substitution */
- *match, /* Current match for a backref */
- *walk; /* Used to walk the code string */
- int code_len; /* Length of the code string */
- int new_code_len; /* Length of the substituted code string */
- int match_len; /* Length of the match */
- int result_len; /* Length of the result of the evaluation */
- int backref; /* Current backref */
- CLS_FETCH();
- ELS_FETCH();
-
- /* Save string to be evaluated, since we will be modifying it */
- code = estrdup(eval_str);
- walk = code;
- new_code_len = code_len = strlen(code);
-
- while (*walk) {
- /* If found a backreference.. */
- if ('\\' == *walk &&
- _preg_get_backref(walk+1, &backref) &&
- backref < count) {
- /* Find the corresponding string match and substitute it
- in instead of the backref */
- match = subject + offsets[backref<<1];
- match_len = offsets[(backref<<1)+1] - offsets[backref<<1];
- sprintf(backref_buf, "\\%d", backref);
- new_code = _php3_str_to_str(code, code_len,
- backref_buf, (backref > 9) ? 3 : 2,
- match, match_len, &new_code_len);
-
- /* Adjust the walk pointer */
- walk = new_code + (walk - code) + match_len;
-
- /* Clean up and reassign */
- efree(code);
- code = new_code;
- code_len = new_code_len;
- } else {
- walk++;
- }
- }
-
- /* Run the code */
- zend_eval_string(code, &retval CLS_CC ELS_CC);
- convert_to_string(&retval);
-
- /* Save the return value and its length */
- *result = estrdup(retval.value.str.val);
- result_len = retval.value.str.len;
-
- /* Clean up */
- zval_dtor(&retval);
- efree(code);
-
- return result_len;
-}
-/* }}} */
-
-
-/* {{{ char *_php_pcre_replace(char *regex, char *subject, char *replace) */
-char *_php_pcre_replace(char *regex, char *subject, char *replace)
-{
- pcre *re = NULL; /* Compiled regular expression */
- pcre_extra *extra = NULL; /* Holds results of studying */
- int exoptions = 0; /* Execution options */
- int preg_options = 0; /* Custom preg options */
- int count = 0; /* Count of matched subpatterns */
- int *offsets; /* Array of subpattern offsets */
- int size_offsets; /* Size of the offsets array */
- int new_len; /* Length of needed storage */
- int alloc_len; /* Actual allocated length */
- int subject_len; /* Length of the subject string */
- int eval_result_len=0; /* Length of the eval'ed string */
- int result_len; /* Current length of the result */
- int match_len; /* Length of the current match */
- int backref; /* Backreference number */
- int eval; /* If the replacement string should be eval'ed */
- int start_offset; /* Where the new search starts */
- int g_notempty = 0; /* If the match should not be empty */
- char *result, /* Result of replacement */
- *new_buf, /* Temporary buffer for re-allocation */
- *walkbuf, /* Location of current replacement in the result */
- *walk, /* Used to walk the replacement string */
- *match, /* The current match */
- *piece, /* The current piece of subject */
- *eval_result; /* Result of eval */
-
- /* Compile regex or get it from cache. */
- if ((re = _pcre_get_compiled_regex(regex, extra, &preg_options)) == NULL) {
- return NULL;
- }
-
- /* Calculate the size of the offsets array, and allocate memory for it. */
- size_offsets = (pcre_info(re, NULL, NULL) + 1) * 3;
- offsets = (int *)emalloc(size_offsets * sizeof(int));
-
- subject_len = strlen(subject);
-
- alloc_len = 2 * subject_len + 1;
- result = emalloc(alloc_len * sizeof(char));
- if (!result) {
- zend_error(E_WARNING, "Unable to allocate memory in pcre_replace");
- efree(re);
- efree(offsets);
- return NULL;
- }
-
- /* Initialize */
- match = NULL;
- result[0] = '\0';
- start_offset = 0;
- eval = preg_options & PREG_REPLACE_EVAL;
-
- while (1) {
- /* Execute the regular expression. */
- count = pcre_exec(re, extra, subject, subject_len, start_offset,
- exoptions|g_notempty, offsets, size_offsets);
-
- /* Check for too many substrings condition. */
- if (count == 0) {
- zend_error(E_NOTICE, "Matched, but too many substrings\n");
- count = size_offsets/3;
- }
-
- piece = &subject[start_offset];
-
- if (count > 0) {
- /* Set the match location in subject */
- match = subject + offsets[0];
-
- new_len = strlen(result) + offsets[0] - start_offset; /* part before the match */
-
- /* If evaluating, do it and add the return string's length */
- if (eval) {
- eval_result_len = _preg_do_eval(replace, piece, offsets,
- count, &eval_result);
- new_len += eval_result_len;
- } else { /* do regular substitution */
- walk = replace;
- while (*walk)
- if ('\\' == *walk &&
- _preg_get_backref(walk+1, &backref) &&
- backref < count) {
- new_len += offsets[(backref<<1)+1] - offsets[backref<<1];
- walk += (backref > 9) ? 3 : 2;
- } else {
- new_len++;
- walk++;
- }
- }
-
- if (new_len + 1 > alloc_len) {
- alloc_len = 1 + alloc_len + 2 * new_len;
- new_buf = emalloc(alloc_len);
- strcpy(new_buf, result);
- efree(result);
- result = new_buf;
- }
- result_len = strlen(result);
- /* copy the part of the string before the match */
- strncat(result, piece, match-piece);
-
- /* copy replacement and backrefs */
- walkbuf = &result[result_len + offsets[0] - start_offset];
-
- /* If evaluating, copy result to the buffer and clean up */
- if (eval) {
- memcpy(walkbuf, eval_result, eval_result_len);
- walkbuf += eval_result_len;
- efree(eval_result);
- } else { /* do regular backreference copying */
- walk = replace;
- while (*walk)
- if ('\\' == *walk &&
- _preg_get_backref(walk+1, &backref) &&
- backref < count) {
- match_len = offsets[(backref<<1)+1] - offsets[backref<<1];
- memcpy (walkbuf,
- piece + offsets[backref<<1],
- match_len);
- walkbuf += match_len;
- walk += (backref > 9) ? 3 : 2;
- } else
- *walkbuf++ = *walk++;
- }
- *walkbuf = '\0';
- } else { /* Failed to match */
- /* If we previously set PCRE_NOTEMPTY after a null match,
- this is not necessarily the end. We need to advance
- the start offset, and continue. Fudge the offset values
- to achieve this, unless we're already at the end of the string. */
- if (g_notempty != 0 && start_offset < subject_len) {
- offsets[0] = start_offset;
- offsets[1] = start_offset + 1;
- strncat(result, piece, 1);
- }
- else {
- new_len = strlen(result) + subject_len - start_offset;
- if (new_len + 1 > alloc_len) {
- alloc_len = new_len + 1; /* now we know exactly how long it is */
- new_buf = emalloc(alloc_len * sizeof(char));
- strcpy(new_buf, result);
- efree(result);
- result = new_buf;
- }
- /* stick that last bit of string on our output */
- strcat(result, piece);
- break;
- }
- }
-
- /* If we have matched an empty string, mimic what Perl's /g options does.
- This turns out to be rather cunning. First we set PCRE_NOTEMPTY and try
- the match again at the same point. If this fails (picked up above) we
- advance to the next character. */
- g_notempty = (offsets[1] == offsets[0])? PCRE_NOTEMPTY : 0;
-
- /* Advance to the next piece */
- start_offset = offsets[1];
- }
-
- efree(offsets);
-
- return result;
-}
-/* }}} */
-
-
-static char *_php_replace_in_subject(zval *regex, zval *replace, zval *subject)
-{
- zval **regex_entry_ptr,
- *regex_entry,
- **replace_entry_ptr,
- *replace_entry;
- char *replace_value = NULL,
- *subject_value,
- *result;
-
- /* Make sure we're dealing with strings. */
- convert_to_string(subject);
-
- /* If regex is an array */
- if (regex->type == IS_ARRAY) {
- /* Duplicating subject string for repeated replacement */
- subject_value = estrdup(subject->value.str.val);
-
- zend_hash_internal_pointer_reset(regex->value.ht);
-
- if (replace->type == IS_ARRAY)
- zend_hash_internal_pointer_reset(replace->value.ht);
- else
- /* Set replacement value to the passed one */
- replace_value = replace->value.str.val;
-
- /* For each entry in the regex array, get the entry */
- while (zend_hash_get_current_data(regex->value.ht, (void **)&regex_entry_ptr) == SUCCESS) {
- regex_entry = *regex_entry_ptr;
-
- /* Make sure we're dealing with strings. */
- convert_to_string(regex_entry);
-
- /* If replace is an array */
- if (replace->type == IS_ARRAY) {
- /* Get current entry */
- if (zend_hash_get_current_data(replace->value.ht, (void **)&replace_entry_ptr) == SUCCESS) {
- replace_entry = *replace_entry_ptr;
-
- /* Make sure we're dealing with strings. */
- convert_to_string(replace_entry);
-
- /* Set replacement value to the one we got from array */
- replace_value = replace_entry->value.str.val;
-
- zend_hash_move_forward(replace->value.ht);
- }
- else
- /* We've run out of replacement strings, so use an empty one */
- replace_value = empty_string;
- }
-
- /* Do the actual replacement and put the result back into subject_value
- for further replacements. */
- if ((result = _php_pcre_replace(regex_entry->value.str.val,
- subject_value,
- replace_value)) != NULL) {
- efree(subject_value);
- subject_value = result;
- }
-
- zend_hash_move_forward(regex->value.ht);
- }
-
- return subject_value;
- }
- else {
- /* Make sure we're dealing with strings and do the replacement */
- convert_to_string(regex);
- convert_to_string(replace);
- result = _php_pcre_replace(regex->value.str.val,
- subject->value.str.val,
- replace->value.str.val);
- return result;
- }
-}
-
-
-/* {{{ proto string preg_replace(string|array regex, string|array replace, string|array subject)
- Perform Perl-style regular expression replacement */
-PHP_FUNCTION(preg_replace)
-{
- zval *regex,
- *replace,
- *subject,
- **subject_entry_ptr,
- *subject_entry;
- char *result;
-
- /* Get function parameters and do error-checking. */
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &regex, &replace, &subject) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- /* if subject is an array */
- if (subject->type == IS_ARRAY) {
- array_init(return_value);
- zend_hash_internal_pointer_reset(subject->value.ht);
-
- /* For each subject entry, convert it to string, then perform replacement
- and add the result to the return_value array. */
- while (zend_hash_get_current_data(subject->value.ht, (void **)&subject_entry_ptr) == SUCCESS) {
- subject_entry = *subject_entry_ptr;
-
- if ((result = _php_replace_in_subject(regex, replace, subject_entry)) != NULL)
- add_next_index_string(return_value, result, 0);
-
- zend_hash_move_forward(subject->value.ht);
- }
- }
- else { /* if subject is not an array */
- if ((result = _php_replace_in_subject(regex, replace, subject)) != NULL) {
- RETVAL_STRING(result, 1);
- efree(result);
- }
- }
-}
-/* }}} */
-
-
-/* {{{ proto array preg_split(string pattern, string subject [, int limit ])
- split string into an array using a perl-style regular expression as a delimiter */
-PHP_FUNCTION(preg_split)
-{
- zval *regex, /* Regular expression to split by */
- *subject, /* Subject string to split */
- *limit; /* Number of pieces to return */
- pcre *re = NULL; /* Compiled regular expression */
- pcre_extra *extra = NULL; /* Holds results of studying */
- int *offsets; /* Array of subpattern offsets */
- int size_offsets; /* Size of the offsets array */
- int exoptions = 0; /* Execution options */
- int preg_options = 0; /* Custom preg options */
- int argc; /* Argument count */
- int limit_val; /* Integer value of limit */
- int count = 0; /* Count of matched subpatterns */
- int start_offset; /* Where the new search starts */
- int g_notempty = 0; /* If the match should not be empty */
- char *match, /* The current match */
- *last_match; /* Location of last match */
-
- /* Get function parameters and do error checking */
- argc = ARG_COUNT(ht);
- if (argc < 1 || argc > 3 || getParameters(ht, argc, &regex, &subject, &limit) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (argc == 3) {
- convert_to_long(limit);
- limit_val = limit->value.lval;
- }
- else
- limit_val = -1;
-
- /* Make sure we're dealing with strings */
- convert_to_string(regex);
- convert_to_string(subject);
-
- /* Compile regex or get it from cache. */
- if ((re = _pcre_get_compiled_regex(regex->value.str.val, extra, &preg_options)) == NULL) {
- RETURN_FALSE;
- }
-
- /* Initialize return value */
- array_init(return_value);
-
- /* Calculate the size of the offsets array, and allocate memory for it. */
- size_offsets = (pcre_info(re, NULL, NULL) + 1) * 3;
- offsets = (int *)emalloc(size_offsets * sizeof(int));
-
- /* Start at the beginning of the string */
- start_offset = 0;
- last_match = subject->value.str.val;
- match = NULL;
-
- /* Get next piece if no limit or limit not yet reached and something matched*/
- while ((limit_val == -1 || limit_val > 1)) {
- count = pcre_exec(re, extra, subject->value.str.val,
- subject->value.str.len, start_offset,
- exoptions|g_notempty, offsets, size_offsets);
-
- /* Check for too many substrings condition. */
- if (count == 0) {
- zend_error(E_NOTICE, "Matched, but too many substrings\n");
- count = size_offsets/3;
- }
-
- /* If something matched */
- if (count > 0) {
- match = subject->value.str.val + offsets[0];
-
- /* Add the piece to the return value */
- add_next_index_stringl(return_value, last_match,
- &subject->value.str.val[offsets[0]]-last_match, 1);
-
- last_match = &subject->value.str.val[offsets[1]];
-
- /* One less left to do */
- if (limit_val != -1)
- limit_val--;
- } else { /* Failed to match */
- /* If we previously set PCRE_NOTEMPTY after a null match,
- this is not necessarily the end. We need to advance
- the start offset, and continue. Fudge the offset values
- to achieve this, unless we're already at the end of the string. */
- if (g_notempty != 0 && start_offset < subject->value.str.len) {
- offsets[0] = start_offset;
- offsets[1] = start_offset + 1;
- } else
- break;
- }
-
- /* If we have matched an empty string, mimic what Perl's /g options does.
- This turns out to be rather cunning. First we set PCRE_NOTEMPTY and try
- the match again at the same point. If this fails (picked up above) we
- advance to the next character. */
- g_notempty = (offsets[1] == offsets[0])? PCRE_NOTEMPTY : 0;
-
- /* Advance to the position right after the last full match */
- start_offset = offsets[1];
- }
-
- /* Add the last piece to the return value */
- add_next_index_string(return_value,
- &subject->value.str.val[start_offset], 1);
-
- /* Clean up */
- efree(offsets);
-}
-/* }}} */
-
-
-/* {{{ proto string preg_quote(string str)
- Quote regular expression characters */
-PHP_FUNCTION(preg_quote)
-{
- zval *in_str_arg; /* Input string argument */
- char *in_str, /* Input string */
- *out_str, /* Output string with quoted characters */
- *p, /* Iterator for input string */
- *q, /* Iterator for output string */
- c; /* Current character */
-
- /* Get the arguments and check for errors */
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &in_str_arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- /* Make sure we're working with strings */
- convert_to_string(in_str_arg);
- in_str = in_str_arg->value.str.val;
-
- /* Nothing to do if we got an empty string */
- if (!*in_str) {
- RETVAL_STRING(empty_string, 0);
- }
-
- /* Allocate enough memory so that even if each character
- is quoted, we won't run out of room */
- out_str = emalloc(2 * in_str_arg->value.str.len + 1);
-
- /* Go through the string and quote necessary characters */
- for(p = in_str, q = out_str; (c = *p); p++) {
- switch(c) {
- case '.':
- case '\\':
- case '+':
- case '*':
- case '?':
- case '[':
- case '^':
- case ']':
- case '$':
- case '(':
- case ')':
- case '{':
- case '}':
- case '=':
- case '!':
- case '>':
- case '<':
- case '|':
- case ':':
- *q++ = '\\';
- /* break is missing _intentionally_ */
- default:
- *q++ = c;
- }
- }
- *q = '\0';
-
- /* Reallocate string and return it */
- RETVAL_STRING(erealloc(out_str, q - out_str + 1), 0);
-}
-/* }}} */
-
-
-/* {{{ proto array preg_grep(string regex, array input)
- Searches array and returns entries which match regex */
-PHP_FUNCTION(preg_grep)
-{
- zval *regex, /* Regular expression */
- *input, /* Input array */
- *entry, /* A copy of the entry in the input array */
- **entry_ptr; /* An entry in the input array */
- pcre *re = NULL; /* Compiled regular expression */
- pcre_extra *extra = NULL; /* Holds results of studying */
- int preg_options = 0; /* Custom preg options */
- int *offsets; /* Array of subpattern offsets */
- int size_offsets; /* Size of the offsets array */
- int count = 0; /* Count of matched subpatterns */
- char *string_key;
- ulong num_key;
-
- /* Get arguments and do error checking */
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, ARG_COUNT(ht), &regex, &input) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (input->type != IS_ARRAY) {
- zend_error(E_WARNING, "Secong argument to preg_grep() should be an array");
- return;
- }
-
- /* Make sure regex is a string */
- convert_to_string(regex);
-
- /* Compile regex or get it from cache. */
- if ((re = _pcre_get_compiled_regex(regex->value.str.val, extra, &preg_options)) == NULL) {
- RETURN_FALSE;
- }
-
- /* Calculate the size of the offsets array, and allocate memory for it. */
- size_offsets = (pcre_info(re, NULL, NULL) + 1) * 3;
- offsets = (int *)emalloc(size_offsets * sizeof(int));
-
- /* Initialize return array */
- array_init(return_value);
-
- /* Allocate entry storage */
- entry = (zval *)emalloc(sizeof(zval));
-
- /* Go through the input array */
- zend_hash_internal_pointer_reset(input->value.ht);
- while(zend_hash_get_current_data(input->value.ht, (void **)&entry_ptr) == SUCCESS) {
-
- /* Copy entry and convert to string */
- *entry = **entry_ptr;
- zval_copy_ctor(entry);
- convert_to_string(entry);
-
- /* Perform the match */
- count = pcre_exec(re, extra, entry->value.str.val,
- entry->value.str.len, 0,
- 0, offsets, size_offsets);
-
- /* Check for too many substrings condition. */
- if (count == 0) {
- zend_error(E_NOTICE, "Matched, but too many substrings\n");
- count = size_offsets/3;
- }
-
- /* If something matched */
- if (count > 0) {
- (*entry_ptr)->refcount++;
-
- /* Add to return array */
- switch(zend_hash_get_current_key(input->value.ht, &string_key, &num_key))
- {
- case HASH_KEY_IS_STRING:
- zend_hash_update(return_value->value.ht, string_key,
- strlen(string_key)+1, entry_ptr, sizeof(zval *), NULL);
- efree(string_key);
- break;
-
- case HASH_KEY_IS_LONG:
- zend_hash_next_index_insert(return_value->value.ht, entry_ptr,
- sizeof(zval *), NULL);
- break;
- }
- }
-
- zval_dtor(entry);
- zend_hash_move_forward(input->value.ht);
- }
-
- /* Clean up */
- efree(entry);
- efree(offsets);
-}
-/* }}} */
-
-
-/* {{{ module definition structures */
-
-unsigned char third_arg_force_ref[] = { 3, BYREF_NONE, BYREF_NONE, BYREF_FORCE };
-
-function_entry pcre_functions[] = {
- PHP_FE(preg_match, third_arg_force_ref)
- PHP_FE(preg_match_all, third_arg_force_ref)
- PHP_FE(preg_replace, NULL)
- PHP_FE(preg_split, NULL)
- PHP_FE(preg_quote, NULL)
- PHP_FE(preg_grep, NULL)
- {NULL, NULL, NULL}
-};
-
-zend_module_entry pcre_module_entry = {
- "PCRE", pcre_functions,
- PHP_MINIT(pcre),
- PHP_MSHUTDOWN(pcre),
- PHP_RINIT(pcre),
- NULL,
- PHP_MINFO(pcre),
- STANDARD_MODULE_PROPERTIES
-};
-
-/* }}} */
-
-
-#endif /* HAVE_PCRE || HAVE_BUNDLED_PCRE */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/pcre/php_pcre.h b/ext/pcre/php_pcre.h
deleted file mode 100644
index 4809b32a2c..0000000000
--- a/ext/pcre/php_pcre.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Andrey Zmievski <andrey@ispi.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _PHP_PCRE_H
-#define _PHP_PCRE_H
-
-#if HAVE_PCRE || HAVE_BUNDLED_PCRE
-
-#if HAVE_BUNDLED_PCRE
-#include "pcrelib/pcre.h"
-#else
-#include "pcre.h"
-#endif
-
-#if HAVE_LOCALE_H
-#include <locale.h>
-#endif
-
-PHP_FUNCTION(preg_match);
-PHP_FUNCTION(preg_match_all);
-PHP_FUNCTION(preg_replace);
-PHP_FUNCTION(preg_split);
-PHP_FUNCTION(preg_quote);
-PHP_FUNCTION(preg_grep);
-
-extern zend_module_entry pcre_module_entry;
-#define pcre_module_ptr &pcre_module_entry
-
-typedef struct {
- pcre *re;
- pcre_extra *extra;
- int preg_options;
-#if HAVE_SETLOCALE
- char *locale;
- unsigned const char *tables;
-#endif
-} pcre_cache_entry;
-
-typedef struct {
- HashTable pcre_cache;
-} php_pcre_globals;
-
-#ifdef ZTS
-# define PCRE_LS_D php_pcre_globals *pcre_globals
-# define PCRE_LS_DC , PCRE_LS_D
-# define PCRE_LS_C pcre_globals
-# define PCRE_LS_CC , PCRE_LS_C
-# define PCRE_G(v) (pcre_globals->v)
-# define PCRE_LS_FETCH() php_pcre_globals *pcre_globals = ts_resource(pcre_globals_id);
-#else
-# define PCRE_LS_D
-# define PCRE_LS_DC
-# define PCRE_LS_C
-# define PCRE_LS_CC
-# define PCRE_G(v) (pcre_globals.v)
-# define PCRE_LS_FETCH()
-extern ZEND_API php_pcre_globals pcre_globals;
-#endif
-
-#else
-
-#define pcre_module_ptr NULL
-
-#endif /* HAVE_PCRE || HAVE_BUNDLED_PCRE */
-
-#define phpext_pcre_ptr pcre_module_ptr
-
-#endif /* _PHP_PCRE_H */
diff --git a/ext/pcre/setup.stub b/ext/pcre/setup.stub
deleted file mode 100644
index 67d4fd7a1c..0000000000
--- a/ext/pcre/setup.stub
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-pcre-regex 'pcre support?' yesnodir no \
-' Whether to build the pcre extension.'
-
diff --git a/ext/pdf/Makefile.am b/ext/pdf/Makefile.am
deleted file mode 100644
index 6b4304d337..0000000000
--- a/ext/pdf/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_pdf.a
-libphpext_pdf_a_SOURCES=pdf.c
-
diff --git a/ext/pdf/config.h.stub b/ext/pdf/config.h.stub
deleted file mode 100644
index fa9fed71eb..0000000000
--- a/ext/pdf/config.h.stub
+++ /dev/null
@@ -1,3 +0,0 @@
-/* Define if you have the pdflib library */
-#define HAVE_PDFLIB 0
-
diff --git a/ext/pdf/config.m4 b/ext/pdf/config.m4
deleted file mode 100644
index 635912ccf1..0000000000
--- a/ext/pdf/config.m4
+++ /dev/null
@@ -1,90 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(whether to include Pdflib 2.x support)
-AC_ARG_WITH(pdflib,
-[ --with-pdflib[=DIR] Include pdflib 2.x support.
- DIR is the pdflib install directory,
- defaults to /usr/local.],
-[
-echo $withval
- case "$withval" in
- no)
- AC_MSG_RESULT(no) ;;
- yes)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(pdf)
- AC_CHECK_LIB(pdf, PDF_close, [AC_DEFINE(HAVE_PDFLIB) PDFLIB_LIBS="-L/usr/local -lpdf -lz"],
- [AC_MSG_ERROR(pdflib extension requires pdflib 2.x. You may as well need libtiff and libjpeg. In such a case use the options --with-tiff-dir=<DIR> and --with-jpeg-dir=<DIR>)])
- EXTRA_LIBS="$EXTRA_LIBS $PDFLIB_LIBS"
- ;;
- *)
- test -f $withval/include/pdflib.h && PDFLIB_INCLUDE="-I$withval/include"
- if test -n "$PDFLIB_INCLUDE" ; then
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(pdf)
- old_LIBS=$LIBS
- old_withval=$withval
-
- if test $HAVE_ZLIB; then
- AC_MSG_CHECKING([for zlib (needed by pdflib 2.x)])
- AC_ARG_WITH(zlib-dir,
- [ --with-zlib-dir[=DIR] zlib dir for pdflib 2.x or include zlib support],[
- AC_MSG_RESULT( )
- if test -z $withval; then
- withval="/usr/local"
- fi
- AC_CHECK_LIB(z,deflate, [PDFLIB_LIBS="-L$withval/lib -lz"],[AC_MSG_RESULT(no)],)
- LIBS="$LIBS -L$withval/lib -lz"
- ],[
- AC_MSG_RESULT(no)
- AC_MSG_WARN(If configure fails try --with-zlib=<DIR>)
- ])
- else
- echo "checking for libz needed by pdflib 2.x... already zlib support"
- PDFLIB_LIBS="$ZLIB_LIBS"
- LIBS="$LIBS -lz"
- fi
-
- AC_MSG_CHECKING([for libjpeg (needed by pdflib 2.x)])
- AC_ARG_WITH(jpeg-dir,
- [ --with-jpeg-dir[=DIR] jpeg dir for pdflib 2.x],[
- AC_MSG_RESULT(yes)
- if test -z $withval; then
- withval="/usr/local"
- fi
- LIBS="$LIBS -L$withval/lib -ljpeg"
- AC_CHECK_LIB(jpeg,jpeg_read_header, [PDFLIB_LIBS="$PDFLIB_LIBS -L$withval/lib -ljpeg"],[AC_MSG_RESULT(no)],)
- LIBS="$LIBS -L$withval/lib -ljpeg"
- ],[
- AC_MSG_RESULT(no)
- AC_MSG_WARN(If configure fails try --with-jpeg-dir=<DIR>)
- ])
-
- AC_MSG_CHECKING([for libtiff (needed by pdflib 2.x)])
- AC_ARG_WITH(tiff-dir,
- [ --with-tiff-dir[=DIR] tiff dir for pdflib 2.x],[
- AC_MSG_RESULT(yes)
- if test -z $withval; then
- withval="/usr/local"
- fi
- LIBS="$LIBS -L$withval/lib -ltiff -ljpeg"
- AC_CHECK_LIB(tiff,TIFFOpen, [PDFLIB_LIBS="$PDFLIB_LIBS -L$withval/lib -ltiff"],[AC_MSG_RESULT(no)],)
- ],[
- AC_MSG_RESULT(no)
- AC_MSG_WARN(If configure fails try --with-tiff-dir=<DIR>)
- ])
- withval=$old_withval
-
- LIBS="$LIBS -L$withval/lib"
- AC_CHECK_LIB(pdf, PDF_close, [AC_DEFINE(HAVE_PDFLIB) PDFLIB_LIBS="$PDFLIB_LIBS -L$withval/lib -lpdf"],
- [AC_MSG_ERROR(pdflib extension requires pdflib 2.x.)])
- LIBS=$old_LIBS
- EXTRA_LIBS="$EXTRA_LIBS $PDFLIB_LIBS"
- INCLUDES="$INCLUDES $PDFLIB_INCLUDE"
- else
- AC_MSG_RESULT(no)
- fi ;;
- esac
-],[
- AC_MSG_RESULT(no)
-])
diff --git a/ext/pdf/pdf.c b/ext/pdf/pdf.c
deleted file mode 100644
index 3d6d65afad..0000000000
--- a/ext/pdf/pdf.c
+++ /dev/null
@@ -1,2452 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Uwe Steinmann <Uwe.Steinmann@fernuni-hagen.de> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/* pdflib 2.01 is subject to the ALADDIN FREE PUBLIC LICENSE.
- Copyright (C) 1997 Thomas Merz. */
-
-/* Note that there is no code from the pdflib package in this file */
-
-#if !PHP_31 && defined(THREAD_SAFE)
-#undef THREAD_SAFE
-#endif
-
-#include "php.h"
-#include "php_globals.h"
-
-#include <math.h>
-
-#if HAVE_LIBGD13
-#include "gd.h"
-#endif
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#if WIN32|WINNT
-# include <io.h>
-# include <fcntl.h>
-#endif
-
-#if HAVE_PDFLIB
-
-#include "php3_pdf.h"
-
-#ifdef THREAD_SAFE
-DWORD PDFlibTls;
-static int numthreads=0;
-
-typedef struct pdflib_global_struct{
- int le_pdf_image;
- int le_outline;
- int le_pdf;
-} pdflib_global_struct;
-
-# define PDF_GLOBAL(a) pdflib_globals->a
-# define PDF_TLS_VARS pdflib_global_struct *pdflib_globals=TlsGetValue(PDFlibTls)
-
-#else
-# define PDF_GLOBAL(a) a
-# define PDF_TLS_VARS
-static int le_pdf_image;
-static int le_outline;
-static int le_pdf;
-#endif
-
-function_entry pdf_functions[] = {
- PHP_FE(pdf_set_info_creator, NULL)
- PHP_FE(pdf_set_info_title, NULL)
- PHP_FE(pdf_set_info_subject, NULL)
- PHP_FE(pdf_set_info_author, NULL)
- PHP_FE(pdf_set_info_keywords, NULL)
- PHP_FE(pdf_open, NULL)
- PHP_FE(pdf_close, NULL)
- PHP_FE(pdf_begin_page, NULL)
- PHP_FE(pdf_end_page, NULL)
- PHP_FE(pdf_show, NULL)
- PHP_FE(pdf_show_xy, NULL)
- PHP_FE(pdf_set_font, NULL)
- PHP_FE(pdf_set_leading, NULL)
- PHP_FE(pdf_set_text_rendering, NULL)
- PHP_FE(pdf_set_horiz_scaling, NULL)
- PHP_FE(pdf_set_text_rise, NULL)
- PHP_FE(pdf_set_text_matrix, NULL)
- PHP_FE(pdf_set_text_pos, NULL)
- PHP_FE(pdf_set_char_spacing, NULL)
- PHP_FE(pdf_set_word_spacing, NULL)
- PHP_FE(pdf_continue_text, NULL)
- PHP_FE(pdf_stringwidth, NULL)
- PHP_FE(pdf_save, NULL)
- PHP_FE(pdf_restore, NULL)
- PHP_FE(pdf_translate, NULL)
- PHP_FE(pdf_scale, NULL)
- PHP_FE(pdf_rotate, NULL)
- PHP_FE(pdf_setflat, NULL)
- PHP_FE(pdf_setlinejoin, NULL)
- PHP_FE(pdf_setlinecap, NULL)
- PHP_FE(pdf_setmiterlimit, NULL)
- PHP_FE(pdf_setlinewidth, NULL)
- PHP_FE(pdf_setdash, NULL)
- PHP_FE(pdf_moveto, NULL)
- PHP_FE(pdf_lineto, NULL)
- PHP_FE(pdf_curveto, NULL)
- PHP_FE(pdf_circle, NULL)
- PHP_FE(pdf_arc, NULL)
- PHP_FE(pdf_rect, NULL)
- PHP_FE(pdf_closepath, NULL)
- PHP_FE(pdf_stroke, NULL)
- PHP_FE(pdf_closepath_stroke, NULL)
- PHP_FE(pdf_fill, NULL)
- PHP_FE(pdf_fill_stroke, NULL)
- PHP_FE(pdf_closepath_fill_stroke, NULL)
- PHP_FE(pdf_endpath, NULL)
- PHP_FE(pdf_clip, NULL)
- PHP_FE(pdf_setgray_fill, NULL)
- PHP_FE(pdf_setgray_stroke, NULL)
- PHP_FE(pdf_setgray, NULL)
- PHP_FE(pdf_setrgbcolor_fill, NULL)
- PHP_FE(pdf_setrgbcolor_stroke, NULL)
- PHP_FE(pdf_setrgbcolor, NULL)
- PHP_FE(pdf_add_outline, NULL)
- PHP_FE(pdf_set_transition, NULL)
- PHP_FE(pdf_set_duration, NULL)
- PHP_FE(pdf_open_jpeg, NULL)
-#if HAVE_LIBGD13
- PHP_FE(pdf_open_memory_image, NULL)
-#endif
- PHP_FE(pdf_open_gif, NULL)
- PHP_FE(pdf_close_image, NULL)
- PHP_FE(pdf_place_image, NULL)
- PHP_FE(pdf_put_image, NULL)
- PHP_FE(pdf_execute_image, NULL)
- PHP_FE(pdf_add_weblink, NULL)
- PHP_FE(pdf_add_pdflink, NULL)
- PHP_FE(pdf_add_annotation, NULL)
- PHP_FE(pdf_set_border_style, NULL)
- PHP_FE(pdf_set_border_color, NULL)
- PHP_FE(pdf_get_image_height, NULL)
- PHP_FE(pdf_get_image_width, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry pdf_module_entry = {
- "pdf", pdf_functions, PHP_MINIT(pdf), PHP_MSHUTDOWN(pdf), NULL, NULL, PHP_MINFO(pdf), STANDARD_MODULE_PROPERTIES
-};
-
-#if COMPILE_DL
-#include "dl/phpdl.h"
-DLEXPORT php3_module_entry *get_module(void) { return &pdf_module_entry; }
-#endif
-
-static void _free_pdf_image(int image)
-{
-}
-
-static void _free_pdf_doc(PDF *pdf)
-{
- PDF_close(pdf);
- PDF_delete(pdf);
-}
-
-static void _free_outline(int *outline)
-{
- if(outline) efree(outline);
-}
-
-PHP_MINIT_FUNCTION(pdf)
-{
- PDF_GLOBAL(le_pdf_image) = register_list_destructors(_free_pdf_image, NULL);
- PDF_GLOBAL(le_outline) = register_list_destructors(_free_outline, NULL);
- PDF_GLOBAL(le_pdf) = register_list_destructors(_free_pdf_doc, NULL);
- return SUCCESS;
-}
-
-PHP_MINFO_FUNCTION(pdf) {
- /* need to use a PHPAPI function here because it is external module in windows */
- php3_printf("pdflib %d.%02d<BR>", PDF_get_majorversion(), PDF_get_minorversion());
-#if PDFLIB_MINORVERSION > 0
- php3_printf("The function pdf_put_image() and pdf_execute_image() are <B>not</B> available");
-#else
- php3_printf("The function pdf_put_image() and pdf_execute_image() are available");
-#endif
-}
-
-PHP_MSHUTDOWN_FUNCTION(pdf){
- return SUCCESS;
-}
-
-/* {{{ proto bool pdf_set_info_creator(int info, string creator)
- Fills the creator field of the info structure */
-PHP_FUNCTION(pdf_set_info_creator) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if (!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d (type=%d)",id, type);
- RETURN_FALSE;
- }
-
- PDF_set_info(pdf, "Creator", arg2->value.str.val);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool pdf_set_info_title(int info, string title)
- Fills the title field of the info structure */
-PHP_FUNCTION(pdf_set_info_title) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if (!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d (type=%d)",id, type);
- RETURN_FALSE;
- }
-
- PDF_set_info(pdf, "Title", arg2->value.str.val);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool pdf_set_info_subject(int info, string subject)
- Fills the subject field of the info structure */
-PHP_FUNCTION(pdf_set_info_subject) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if (!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d (type=%d)",id, type);
- RETURN_FALSE;
- }
-
- PDF_set_info(pdf, "Subject", arg2->value.str.val);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool pdf_set_info_author(int info, string author)
- Fills the author field of the info structure */
-PHP_FUNCTION(pdf_set_info_author) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if (!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d (type=%d)",id, type);
- RETURN_FALSE;
- }
-
- PDF_set_info(pdf, "Author", arg2->value.str.val);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool pdf_set_info_keywords(int info, string keywords)
- Fills the keywords field of the info structure */
-PHP_FUNCTION(pdf_set_info_keywords) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if (!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d (type=%d)",id, type);
- RETURN_FALSE;
- }
-
- PDF_set_info(pdf, "Keywords", arg2->value.str.val);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int pdf_open(int filedesc)
- Opens a new pdf document */
-PHP_FUNCTION(pdf_open) {
- pval *file;
- pval *info;
- int id, type;
- FILE *fp;
- PDF *pdf;
- PDF_TLS_VARS;
-
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &file) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(file);
- id=file->value.lval;
- fp = php3_list_find(id,&type);
- if (!fp || type!=php3i_get_le_fp()) {
- php3_error(E_WARNING,"Unable to find file identifier %d (type=%d)",id, type);
- RETURN_FALSE;
- }
-
- pdf = PDF_new();
- if (0 > PDF_open_fp(pdf, fp)) {
- RETURN_FALSE;
- }
- id = php3_list_insert(pdf,PDF_GLOBAL(le_pdf));
- RETURN_LONG(id);
-}
-/* }}} */
-
-/* {{{ proto void pdf_close(int pdfdoc)
- Closes the pdf document */
-PHP_FUNCTION(pdf_close) {
- pval *arg1;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- php3_list_delete(id);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_begin_page(int pdfdoc, double height, double width)
- Starts page */
-PHP_FUNCTION(pdf_begin_page) {
- pval *arg1, *arg2, *arg3;
- int id, type;
- double height, width;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- convert_to_double(arg3);
- id=arg1->value.lval;
- height = arg2->value.dval;
- width = arg3->value.dval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_begin_page(pdf, (float) height, (float) width);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_end_page(int pdfdoc)
- Ends page */
-PHP_FUNCTION(pdf_end_page) {
- pval *arg1;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_end_page(pdf);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_show(int pdfdoc, string text)
- Output text at current position */
-PHP_FUNCTION(pdf_show) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_show(pdf, arg2->value.str.val);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_show_xy(int pdfdoc, string text, double x-koor, double y-koor)
- Output text at position */
-PHP_FUNCTION(pdf_show_xy) {
- pval *arg1, *arg2, *arg3, *arg4;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- convert_to_double(arg3);
- convert_to_double(arg4);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_show_xy(pdf, arg2->value.str.val, (float) arg3->value.dval, (float) arg4->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_set_font(int pdfdoc, string font, double size, int encoding, [int embed])
- Select the current font face, size and encoding */
-PHP_FUNCTION(pdf_set_font) {
- pval *arg1, *arg2, *arg3, *arg4, *arg5;
- int id, type, font, embed;
- PDF *pdf;
- PDF_TLS_VARS;
-
- switch (ARG_COUNT(ht)) {
- case 4:
- if (getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- embed = 0;
- break;
- case 5:
- if (getParameters(ht, 5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg5);
- embed = arg5->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- convert_to_double(arg3);
- convert_to_long(arg4);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- if((arg4->value.lval > 5) || (arg4->value.lval < 0)) {
- php3_error(E_WARNING,"Font encoding set to 4");
- arg4->value.lval = 4;
- }
-
- switch(arg4->value.lval) {
- case 0:
- font = PDF_findfont(pdf, arg2->value.str.val, "builtin", embed);
- break;
- case 1:
- font = PDF_findfont(pdf, arg2->value.str.val, "pdfdoc", embed);
- break;
- case 2:
- font = PDF_findfont(pdf, arg2->value.str.val, "macroman", embed);
- break;
- case 3:
- font = PDF_findfont(pdf, arg2->value.str.val, "macexpert", embed);
- break;
- case 4:
- font = PDF_findfont(pdf, arg2->value.str.val, "winansi", embed);
- break;
- default:
- php3_error(E_WARNING,"Encoding out of range, using 0");
- font = PDF_findfont(pdf, arg2->value.str.val, "builtin", embed);
- }
-
- if (font < 0) {
- php3_error(E_WARNING,"Font %s not found", arg2->value.str.val);
- RETURN_FALSE;
- }
-
- PDF_setfont(pdf, font, (float) arg3->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_set_leading(int pdfdoc, double distance)
- Sets distance between text lines */
-PHP_FUNCTION(pdf_set_leading) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_set_leading(pdf, (float) arg2->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_set_text_rendering(int pdfdoc, int mode)
- Determines how text is rendered */
-PHP_FUNCTION(pdf_set_text_rendering) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_long(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_set_text_rendering(pdf, arg2->value.lval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_set_horiz_scaling(int pdfdoc, double scale)
- Sets horizontal scaling of text */
-PHP_FUNCTION(pdf_set_horiz_scaling) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_set_horiz_scaling(pdf, (float) arg2->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_set_text_rise(int pdfdoc, double value)
- Sets the text rise */
-PHP_FUNCTION(pdf_set_text_rise) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_set_text_rise(pdf, (float) arg2->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_set_text_matrix(int pdfdoc, arry matrix)
- Sets the text matrix */
-PHP_FUNCTION(pdf_set_text_matrix) {
- pval *arg1, *arg2, *data;
- int id, type, i;
- HashTable *matrix;
- PDF *pdf;
- float pdfmatrix[6];
- float *pdfmatrixptr;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_array(arg2);
- id=arg1->value.lval;
- matrix=arg2->value.ht;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- if(_php3_hash_num_elements(matrix) != 6) {
- php3_error(E_WARNING,"Text matrix must have 6 elements");
- RETURN_FALSE;
- }
-
- pdfmatrixptr = (float *) &pdfmatrix;
- _php3_hash_internal_pointer_reset(matrix);
- for(i=0; i<_php3_hash_num_elements(matrix); i++) {
- _php3_hash_get_current_data(matrix, (void *) &data);
- switch(data->type) {
- case IS_DOUBLE:
- *pdfmatrixptr++ = (float) data->value.dval;
- break;
- default:
- *pdfmatrixptr++ = 0.0;
- break;
- }
- _php3_hash_move_forward(matrix);
- }
-
- PDF_set_text_matrix(pdf, pdfmatrix[0], pdfmatrix[1], pdfmatrix[2],
- pdfmatrix[3], pdfmatrix[4], pdfmatrix[5]);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_set_text_pos(int pdfdoc, double x, double y)
- Set the position of text for the next pdf_show call */
-PHP_FUNCTION(pdf_set_text_pos) {
- pval *arg1, *arg2, *arg3;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- convert_to_double(arg3);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_set_text_pos(pdf, (float) arg2->value.dval, (float) arg3->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_set_char_spacing(int pdfdoc, double space)
- Sets character spacing */
-PHP_FUNCTION(pdf_set_char_spacing) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_set_char_spacing(pdf, (float) arg2->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_set_word_spacing(int pdfdoc, double space)
- Sets spacing between words */
-PHP_FUNCTION(pdf_set_word_spacing) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_set_word_spacing(pdf, (float) arg2->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_continue_text(int pdfdoc, string text)
- Output text in next line */
-PHP_FUNCTION(pdf_continue_text) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_continue_text(pdf, arg2->value.str.val);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto double pdf_stringwidth(int pdfdoc, string text)
- Returns width of text in current font*/
-PHP_FUNCTION(pdf_stringwidth) {
- pval *arg1, *arg2;
- int id, type;
- double width;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- width = (double) PDF_stringwidth(pdf, arg2->value.str.val, PDF_get_font(pdf), PDF_get_fontsize(pdf));
-
- RETURN_DOUBLE((double)width);
-}
-/* }}} */
-
-/* {{{ proto void pdf_save(int pdfdoc)
- Saves current enviroment */
-PHP_FUNCTION(pdf_save) {
- pval *arg1;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_save(pdf);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_restore(int pdfdoc)
- Restores formerly saved enviroment */
-PHP_FUNCTION(pdf_restore) {
- pval *arg1;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_restore(pdf);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_translate(int pdfdoc, double x, double y)
- Sets origin of coordinate system */
-PHP_FUNCTION(pdf_translate) {
- pval *arg1, *arg2, *arg3;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- convert_to_double(arg3);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_translate(pdf, (float) arg2->value.dval, (float) arg3->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_scale(int pdfdoc, double x-scale, double y-scale)
- Sets scaling */
-PHP_FUNCTION(pdf_scale) {
- pval *arg1, *arg2, *arg3;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- convert_to_double(arg3);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_scale(pdf, (float) arg2->value.dval, (float) arg3->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_rotate(int pdfdoc, double angle)
- Sets rotation */
-PHP_FUNCTION(pdf_rotate) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_rotate(pdf, (float) arg2->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_setflat(int pdfdoc, double value)
- Sets flatness */
-PHP_FUNCTION(pdf_setflat) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- if((arg2->value.lval > 100) && (arg2->value.lval < 0)) {
- php3_error(E_WARNING,"Parameter of pdf_setflat() has to between 0 and 100");
- RETURN_FALSE;
- }
-
- PDF_setflat(pdf, (float) arg2->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_setlinejoin(int pdfdoc, int value)
- Sets linejoin parameter */
-PHP_FUNCTION(pdf_setlinejoin) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_long(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- if((arg2->value.lval > 2) && (arg2->value.lval < 0)) {
- php3_error(E_WARNING,"Parameter of pdf_setlinejoin() has to between 0 and 2");
- RETURN_FALSE;
- }
-
- PDF_setlinejoin(pdf, arg2->value.lval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_setlinecap(int pdfdoc, int value)
- Sets linecap parameter */
-PHP_FUNCTION(pdf_setlinecap) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_long(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- if((arg2->value.lval > 2) && (arg2->value.lval < 0)) {
- php3_error(E_WARNING,"Parameter of pdf_setlinecap() has to be > 0 and =< 2");
- RETURN_FALSE;
- }
-
- PDF_setlinecap(pdf, arg2->value.lval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_setmiterlimit(int pdfdoc, double value)
- Sets miter limit */
-PHP_FUNCTION(pdf_setmiterlimit) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- if(arg2->value.dval < 1) {
- php3_error(E_WARNING,"Parameter of pdf_setmiterlimit() has to be >= 1");
- RETURN_FALSE;
- }
-
- PDF_setmiterlimit(pdf, (float) arg2->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_setlinewidth(int pdfdoc, double width)
- Sets line width */
-PHP_FUNCTION(pdf_setlinewidth) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_setlinewidth(pdf, (float) arg2->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_setdash(int pdfdoc, double white, double black)
- Sets dash pattern */
-PHP_FUNCTION(pdf_setdash) {
- pval *arg1, *arg2, *arg3;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- convert_to_double(arg3);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_setdash(pdf, (float) arg2->value.dval, (float) arg3->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_moveto(int pdfdoc, double x, double y)
- Sets current point */
-PHP_FUNCTION(pdf_moveto) {
- pval *arg1, *arg2, *arg3;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- convert_to_double(arg3);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_moveto(pdf, (float) arg2->value.dval, (float) arg3->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_curveto(int pdfdoc, double x1, double y1, double x2, double y2, double x3, double y3)
- Draws a curve */
-PHP_FUNCTION(pdf_curveto) {
- pval *arg1, *arg2, *arg3, *arg4, *arg5, *arg6, *arg7;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 7 || getParameters(ht, 7, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- convert_to_double(arg3);
- convert_to_double(arg4);
- convert_to_double(arg5);
- convert_to_double(arg6);
- convert_to_double(arg7);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_curveto(pdf, (float) arg2->value.dval,
- (float) arg3->value.dval,
- (float) arg4->value.dval,
- (float) arg5->value.dval,
- (float) arg6->value.dval,
- (float) arg7->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_lineto(int pdfdoc, double x, double y)
- Draws a line */
-PHP_FUNCTION(pdf_lineto) {
- pval *arg1, *arg2, *arg3;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- convert_to_double(arg3);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_lineto(pdf, (float) arg2->value.dval, (float) arg3->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_circle(int pdfdoc, double x, double y, double radius)
- Draws a circle */
-PHP_FUNCTION(pdf_circle) {
- pval *arg1, *arg2, *arg3, *arg4;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- convert_to_double(arg3);
- convert_to_double(arg4);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_circle(pdf, (float) arg2->value.dval, (float) arg3->value.dval, (float) arg4->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_arc(int pdfdoc, double x, double y, double radius, double start, double end)
- Draws an arc */
-PHP_FUNCTION(pdf_arc) {
- pval *arg1, *arg2, *arg3, *arg4, *arg5, *arg6;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 6 || getParameters(ht, 6, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- convert_to_double(arg3);
- convert_to_double(arg4);
- convert_to_double(arg5);
- convert_to_double(arg6);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_arc(pdf, (float) arg2->value.dval, (float) arg3->value.dval, (float) arg4->value.dval, (float) arg5->value.dval, (float) arg6->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_rect(int pdfdoc, double x, double y, double width, double height)
- Draws a rectangle */
-PHP_FUNCTION(pdf_rect) {
- pval *arg1, *arg2, *arg3, *arg4, *arg5;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 5 || getParameters(ht, 5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- convert_to_double(arg3);
- convert_to_double(arg4);
- convert_to_double(arg5);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_rect(pdf, (float) arg2->value.dval,
- (float) arg3->value.dval,
- (float) arg4->value.dval,
- (float) arg5->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_closepath(int pdfdoc)
- Close path */
-PHP_FUNCTION(pdf_closepath) {
- pval *arg1;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_closepath(pdf);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_closepath_stroke(int pdfdoc)
- Close path and draw line along path */
-PHP_FUNCTION(pdf_closepath_stroke) {
- pval *arg1;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_closepath_stroke(pdf);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_stroke(int pdfdoc)
- Draw line along path path */
-PHP_FUNCTION(pdf_stroke) {
- pval *arg1;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_stroke(pdf);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_fill(int pdfdoc)
- Fill current path */
-PHP_FUNCTION(pdf_fill) {
- pval *arg1;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_fill(pdf);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_fill_stroke(int pdfdoc)
- Fill and stroke current path */
-PHP_FUNCTION(pdf_fill_stroke) {
- pval *arg1;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_fill_stroke(pdf);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_closepath_fill_stroke(int pdfdoc)
- Close, fill and stroke current path */
-PHP_FUNCTION(pdf_closepath_fill_stroke) {
- pval *arg1;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_closepath_fill_stroke(pdf);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_endpath(int pdfdoc)
- Ends current path */
-PHP_FUNCTION(pdf_endpath) {
- pval *arg1;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_endpath(pdf);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_clip(int pdfdoc)
- Clips to current path */
-PHP_FUNCTION(pdf_clip) {
- pval *arg1;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_clip(pdf);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_setgray_fill(int pdfdoc, double value)
- Sets filling color to gray value */
-PHP_FUNCTION(pdf_setgray_fill) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_setgray_fill(pdf, (float) arg2->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_setgray_stroke(int pdfdoc, double value)
- Sets drawing color to gray value */
-PHP_FUNCTION(pdf_setgray_stroke) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_setgray_stroke(pdf, (float) arg2->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_setgray(int pdfdoc, double value)
- Sets drawing and filling color to gray value */
-PHP_FUNCTION(pdf_setgray) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_setgray(pdf, (float) arg2->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_setrgbcolor_fill(int pdfdoc, double red, double green, double blue)
- Sets filling color to rgb color value */
-PHP_FUNCTION(pdf_setrgbcolor_fill) {
- pval *arg1, *arg2, *arg3, *arg4;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- convert_to_double(arg3);
- convert_to_double(arg4);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_setrgbcolor_fill(pdf, (float) arg2->value.dval, (float) arg3->value.dval, (float) arg4->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_setrgbcolor_stroke(int pdfdoc, double red, double green, double blue)
- Sets drawing color to rgb color value */
-PHP_FUNCTION(pdf_setrgbcolor_stroke) {
- pval *arg1, *arg2, *arg3, *arg4;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- convert_to_double(arg3);
- convert_to_double(arg4);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_setrgbcolor_stroke(pdf, (float) arg2->value.dval, (float) arg3->value.dval, (float) arg4->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_setrgbcolor(int pdfdoc, double red, double green, double blue)
- Sets drawing and filling color to rgb color value */
-PHP_FUNCTION(pdf_setrgbcolor) {
- pval *arg1, *arg2, *arg3, *arg4;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- convert_to_double(arg3);
- convert_to_double(arg4);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_setrgbcolor(pdf, (float) arg2->value.dval, (float) arg3->value.dval, (float) arg4->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int pdf_add_outline(int pdfdoc, string text [, int parent, int open]);
- Add bookmark for current page */
-PHP_FUNCTION(pdf_add_outline) {
- pval *arg1, *arg2, *arg3, *arg4;
- int id, type;
- int *outline, *parent, parentid, open;
- PDF *pdf;
- PDF_TLS_VARS;
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 3:
- if (getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 4:
- if (getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_string(arg2);
-
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find document identifier %d",id);
- RETURN_FALSE;
- }
-
- if (ARG_COUNT(ht) > 2) {
- convert_to_long(arg3);
- id = arg3->value.lval;
-
- if (id > 0) {
- parent = php3_list_find(id, &type);
- if (!parent || (type != PDF_GLOBAL(le_outline))) {
- php3_error(E_WARNING,"Unable to find identifier %d",id);
- RETURN_FALSE;
- } else {
- parentid = *parent;
- }
- } else {
- parentid = 0;
- }
-
- if (ARG_COUNT(ht) > 3) {
- convert_to_long(arg4);
- open = arg4->value.lval;
- } else {
- open = 0;
- }
- } else {
- parentid = 0;
- open = 0;
- }
-
- outline=emalloc(sizeof(int));
- *outline = PDF_add_bookmark(pdf, arg2->value.str.val, parentid, open);
- id = php3_list_insert(outline,PDF_GLOBAL(le_outline));
- RETURN_LONG(id);
-}
-/* }}} */
-
-/* {{{ proto void pdf_set_transition(int pdfdoc, int transition)
- Sets transition between pages */
-PHP_FUNCTION(pdf_set_transition) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_long(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- switch(arg2->value.lval) {
- case 0:
- PDF_set_transition(pdf, "none");
- break;
- case 1:
- PDF_set_transition(pdf, "split");
- break;
- case 2:
- PDF_set_transition(pdf, "blinds");
- break;
- case 3:
- PDF_set_transition(pdf, "box");
- break;
- case 4:
- PDF_set_transition(pdf, "wipe");
- break;
- case 5:
- PDF_set_transition(pdf, "dissolve");
- break;
- case 6:
- PDF_set_transition(pdf, "glitter");
- break;
- case 7:
- PDF_set_transition(pdf, "replace");
- break;
- default:
- PDF_set_transition(pdf, "none");
-
- }
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_set_duration(int pdfdoc, double duration)
- Sets duration between pages */
-PHP_FUNCTION(pdf_set_duration) {
- pval *arg1, *arg2;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_set_duration(pdf, (float) arg2->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int pdf_open_gif(int pdf, string giffile)
- Opens a gif file and returns an image for placement in a pdf document */
-PHP_FUNCTION(pdf_open_gif) {
- pval *arg1, *arg2;
- int id, type;
- int pdf_image;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- pdf_image = PDF_open_GIF(pdf, arg2->value.str.val);
-
- if(pdf_image < 0) {
- php3_error(E_WARNING, "Could not open image");
- RETURN_FALSE;
- }
-
- id = php3_list_insert((void *) pdf_image,PDF_GLOBAL(le_pdf_image));
- RETURN_LONG(id);
-}
-/* }}} */
-
-/* {{{ proto int pdf_open_jpeg(int pdf, string jpegfile)
- Opens a jpeg file and returns an image for placement in a pdf document */
-PHP_FUNCTION(pdf_open_jpeg) {
- pval *arg1, *arg2;
- int id, type;
- int pdf_image;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- pdf_image = PDF_open_JPEG(pdf, arg2->value.str.val);
-
- if(pdf_image < 0) {
- php3_error(E_WARNING, "Could not open image");
- RETURN_FALSE;
- }
-
- id = php3_list_insert((void *) pdf_image,PDF_GLOBAL(le_pdf_image));
- RETURN_LONG(id);
-}
-/* }}} */
-
-#if HAVE_LIBGD13
-/* {{{ proto int pdf_open_memory_image(int pdf, int image)
- Takes an gd image and returns an image for placement in a pdf document */
-PHP_FUNCTION(pdf_open_memory_image) {
- pval *argv[2];
- int argc;
- int i, j, id, gid, type, color, count;
- int pdf_image;
- gdImagePtr im;
- unsigned char *buffer, *ptr;
- PDF *pdf;
- PDF_TLS_VARS;
-
- argc = ARG_COUNT(ht);
- if (getParametersArray(ht, argc, argv) == FAILURE)
- WRONG_PARAM_COUNT;
-
- convert_to_long(argv[0]);
- id=argv[0]->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- convert_to_long(argv[1]);
- gid=argv[1]->value.lval;
- im = php3_list_find(gid, &type);
- if (!im || type != phpi_get_le_gd()) {
- php3_error(E_WARNING, "pdf: Unable to find image pointer");
- RETURN_FALSE;
- }
-
- count = 3 * im->sx * im->sy;
- if(NULL == (buffer = (unsigned char *) emalloc(count)))
- RETURN_FALSE;
-
- ptr = buffer;
- for(i=0; i<im->sy; i++) {
- for(j=0; j<im->sx; j++) {
- color = im->pixels[i][j];
- *ptr++ = im->red[color];
- *ptr++ = im->green[color];
- *ptr++ = im->blue[color];
- }
- }
-
-
-#if PDFLIB_MINORVERSION == 0
- pdf_image = PDF_open_memory_image(pdf, buffer, im->sx, im->sy, 3, 8);
-#else
- pdf_image = PDF_open_image(pdf, "raw", "memory", buffer, im->sx*im->sy*3, im->sx, im->sy, 3, 8, NULL);
-#endif
- efree(buffer);
-
- if(-1 == pdf_image) {
- php3_error(E_WARNING, "Could not open image");
- efree(buffer);
- RETURN_FALSE;
- }
-
- id = php3_list_insert((void *) pdf_image,PDF_GLOBAL(le_pdf_image));
- RETURN_LONG(id);
-}
-/* }}} */
-#endif /* HAVE_LIBGD13 */
-
-/* {{{ proto void pdf_close_image(int pdfimage)
- Closes the pdf image */
-PHP_FUNCTION(pdf_close_image) {
- pval *arg1, *arg2;
- int id, type;
- int pdf_image;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- convert_to_long(arg2);
- id=arg2->value.lval;
- pdf_image = (int) php3_list_find(id,&type);
- if(pdf_image < 0 || type!=PDF_GLOBAL(le_pdf_image)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_close_image(pdf, pdf_image);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_place_image(int pdf, int pdfimage, int x, int y, int scale)
- Places image in the pdf document */
-PHP_FUNCTION(pdf_place_image) {
- pval *arg1, *arg2, *arg3, *arg4, *arg5;
- int id, type;
- int pdf_image;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 5 || getParameters(ht, 5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- convert_to_long(arg2);
- id=arg2->value.lval;
- pdf_image = (int) php3_list_find(id,&type);
- if(pdf_image < 0 || type!=PDF_GLOBAL(le_pdf_image)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- convert_to_double(arg3);
- convert_to_double(arg4);
- convert_to_double(arg5);
-
- PDF_place_image(pdf, pdf_image, (float) arg3->value.dval, (float) arg4->value.dval, arg5->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_put_image(int pdf, int pdfimage)
- Stores image in the pdf document for later use */
-PHP_FUNCTION(pdf_put_image) {
- pval *arg1, *arg2;
- int id, type;
- int pdf_image;
- PDF *pdf;
- PDF_TLS_VARS;
-
-#if PDFLIB_MINORVERSION > 0
- php_error(E_WARNING, "Version 2.01 of pdflib does not need the pdf_put_image() anymore, check the docs!");
-#else
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- convert_to_long(arg2);
- id=arg2->value.lval;
- pdf_image = (int) php3_list_find(id,&type);
- if(pdf_image < 0 || type!=PDF_GLOBAL(le_pdf_image)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_put_image(pdf, pdf_image);
-#endif
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_execute_image(int pdf, int pdfimage, int x, int y, int scale)
- Places stored image in the pdf document */
-PHP_FUNCTION(pdf_execute_image) {
- pval *arg1, *arg2, *arg3, *arg4, *arg5;
- int id, type;
- int pdf_image;
- PDF *pdf;
- PDF_TLS_VARS;
-
-#if PDFLIB_MINORVERSION >= 01
- php_error(E_WARNING, "Version 2.01 of pdflib does not need the pdf_execute_image() anymore, check the docs!");
-#else
- if (ARG_COUNT(ht) != 5 || getParameters(ht, 5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- convert_to_long(arg2);
- id=arg2->value.lval;
- pdf_image = (int) php3_list_find(id,&type);
- if(pdf_image < 0 || type!=PDF_GLOBAL(le_pdf_image)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- convert_to_double(arg3);
- convert_to_double(arg4);
- convert_to_double(arg5);
-
- PDF_execute_image(pdf, pdf_image, (float) arg3->value.dval, (float) arg4->value.dval, arg5->value.dval);
-#endif
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_get_image_width(int pdf, int pdfimage)
- Returns the width of an image */
-PHP_FUNCTION(pdf_get_image_width) {
- pval *arg1, *arg2;
- int id, type;
- int width;
- int pdf_image;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find identifier %d",id);
- RETURN_FALSE;
- }
-
- convert_to_long(arg2);
- id=arg2->value.lval;
- pdf_image = (int) php3_list_find(id,&type);
- if(pdf_image < 0 || type!=PDF_GLOBAL(le_pdf_image)) {
- php3_error(E_WARNING,"Unable to find identifier %d",id);
- RETURN_FALSE;
- }
-
- width = PDF_get_image_width(pdf, pdf_image);
-
- RETURN_LONG(width);
-}
-/* }}} */
-
-/* {{{ proto void pdf_get_image_height(int pdf, int pdfimage)
- Returns the height of an image */
-PHP_FUNCTION(pdf_get_image_height) {
- pval *arg1, *arg2;
- int id, type;
- int height;
- int pdf_image;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find identifier %d",id);
- RETURN_FALSE;
- }
-
- convert_to_long(arg2);
- id=arg2->value.lval;
- pdf_image = (int) php3_list_find(id,&type);
- if(pdf_image < 0 || type!=PDF_GLOBAL(le_pdf_image)) {
- php3_error(E_WARNING,"Unable to find identifier %d",id);
- RETURN_FALSE;
- }
-
- height = PDF_get_image_height(pdf, pdf_image);
-
- RETURN_LONG(height);
-}
-/* }}} */
-
-/* {{{ proto void pdf_add_weblink(int pdfdoc, double llx, double lly, double urx, double ury, string url)
- Adds link to web resource */
-PHP_FUNCTION(pdf_add_weblink) {
- pval *arg1, *arg2, *arg3, *arg4, *arg5, *arg6;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 6 || getParameters(ht, 6, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- convert_to_double(arg3);
- convert_to_double(arg4);
- convert_to_double(arg5);
- convert_to_string(arg6);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_add_weblink(pdf, (float) arg2->value.dval, (float) arg3->value.dval, (float) arg4->value.dval, (float) arg5->value.dval, arg6->value.str.val);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_add_pdflink(int pdfdoc, double llx, double lly, double urx, double ury, string filename, int page, string dest)
- Adds link to pdf document */
-PHP_FUNCTION(pdf_add_pdflink) {
- pval *arg1, *arg2, *arg3, *arg4, *arg5, *arg6, *arg7, *arg8;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 8 || getParameters(ht, 8, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7, &arg8) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- convert_to_double(arg3);
- convert_to_double(arg4);
- convert_to_double(arg5);
- convert_to_string(arg6);
- convert_to_long(arg7);
- convert_to_string(arg8);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_add_pdflink(pdf, (float) arg2->value.dval, (float) arg3->value.dval, (float) arg4->value.dval, (float) arg5->value.dval, arg6->value.str.val, arg7->value.lval, arg8->value.str.val);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_set_border_style(int pdfdoc, string style, double width)
- Set style of box surounded weblinks */
-PHP_FUNCTION(pdf_set_border_style) {
- pval *arg1, *arg2, *arg3;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_string(arg2);
- convert_to_double(arg3);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_set_border_style(pdf, arg2->value.str.val, (float) arg3->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_set_border_color(int pdfdoc, double red, double green, double blue)
- Set color of box surounded weblinks */
-PHP_FUNCTION(pdf_set_border_color) {
- pval *arg1, *arg2, *arg3, *arg4;
- int id, type;
- PDF *pdf;
- PDF_TLS_VARS;
-
- if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_double(arg2);
- convert_to_double(arg3);
- convert_to_double(arg4);
- id=arg1->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_set_border_color(pdf, (float) arg2->value.dval, (float) arg3->value.dval, (float) arg4->value.dval);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_add_annotation(int pdfdoc, double xll, double yll, double xur, double xur, string title, string text)
- Sets annotation */
-PHP_FUNCTION(pdf_add_annotation) {
- pval *argv[11];
- int id, type, argc;
- PDF *pdf;
- PDF_TLS_VARS;
-
- argc = ARG_COUNT(ht);
- if(argc != 7)
- WRONG_PARAM_COUNT;
- if (getParametersArray(ht, argc, argv) == FAILURE)
- WRONG_PARAM_COUNT;
-
- convert_to_long(argv[0]);
- convert_to_double(argv[1]);
- convert_to_double(argv[2]);
- convert_to_double(argv[3]);
- convert_to_double(argv[4]);
- convert_to_string(argv[5]);
- convert_to_string(argv[6]);
- id=argv[0]->value.lval;
- pdf = php3_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php3_error(E_WARNING,"Unable to find identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_add_note(pdf,
- (float) argv[1]->value.dval,
- (float) argv[2]->value.dval,
- (float) argv[3]->value.dval,
- (float) argv[4]->value.dval,
- argv[6]->value.str.val,
- argv[5]->value.str.val,
- "note", 1);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/pdf/php3_pdf.h b/ext/pdf/php3_pdf.h
deleted file mode 100644
index f7393c3f15..0000000000
--- a/ext/pdf/php3_pdf.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Uwe Steinmann |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#ifndef _PHP3_PDF_H
-#define _PHP3_PDF_H
-
-#if HAVE_PDFLIB
-
-#include <pdflib.h>
-
-extern int le_fp;
-
-extern php3_module_entry pdf_module_entry;
-#define pdf_module_ptr &pdf_module_entry
-
-extern PHP_MINFO_FUNCTION(pdf);
-extern PHP_MINIT_FUNCTION(pdf);
-extern PHP_MSHUTDOWN_FUNCTION(pdf);
-PHP_FUNCTION(pdf_set_info_creator);
-PHP_FUNCTION(pdf_set_info_title);
-PHP_FUNCTION(pdf_set_info_subject);
-PHP_FUNCTION(pdf_set_info_author);
-PHP_FUNCTION(pdf_set_info_keywords);
-PHP_FUNCTION(pdf_open);
-PHP_FUNCTION(pdf_close);
-PHP_FUNCTION(pdf_begin_page);
-PHP_FUNCTION(pdf_end_page);
-PHP_FUNCTION(pdf_show);
-PHP_FUNCTION(pdf_show_xy);
-PHP_FUNCTION(pdf_set_font);
-PHP_FUNCTION(pdf_set_leading);
-PHP_FUNCTION(pdf_set_text_rendering);
-PHP_FUNCTION(pdf_set_horiz_scaling);
-PHP_FUNCTION(pdf_set_text_rise);
-PHP_FUNCTION(pdf_set_text_matrix);
-PHP_FUNCTION(pdf_set_text_pos);
-PHP_FUNCTION(pdf_set_char_spacing);
-PHP_FUNCTION(pdf_set_word_spacing);
-PHP_FUNCTION(pdf_continue_text);
-PHP_FUNCTION(pdf_stringwidth);
-PHP_FUNCTION(pdf_save);
-PHP_FUNCTION(pdf_restore);
-PHP_FUNCTION(pdf_translate);
-PHP_FUNCTION(pdf_scale);
-PHP_FUNCTION(pdf_rotate);
-PHP_FUNCTION(pdf_setflat);
-PHP_FUNCTION(pdf_setlinejoin);
-PHP_FUNCTION(pdf_setlinecap);
-PHP_FUNCTION(pdf_setmiterlimit);
-PHP_FUNCTION(pdf_setlinewidth);
-PHP_FUNCTION(pdf_setdash);
-PHP_FUNCTION(pdf_moveto);
-PHP_FUNCTION(pdf_curveto);
-PHP_FUNCTION(pdf_lineto);
-PHP_FUNCTION(pdf_circle);
-PHP_FUNCTION(pdf_arc);
-PHP_FUNCTION(pdf_rect);
-PHP_FUNCTION(pdf_closepath);
-PHP_FUNCTION(pdf_closepath_stroke);
-PHP_FUNCTION(pdf_stroke);
-PHP_FUNCTION(pdf_fill);
-PHP_FUNCTION(pdf_fill_stroke);
-PHP_FUNCTION(pdf_closepath_fill_stroke);
-PHP_FUNCTION(pdf_endpath);
-PHP_FUNCTION(pdf_clip);
-PHP_FUNCTION(pdf_setgray_fill);
-PHP_FUNCTION(pdf_setgray_stroke);
-PHP_FUNCTION(pdf_setgray);
-PHP_FUNCTION(pdf_setrgbcolor_fill);
-PHP_FUNCTION(pdf_setrgbcolor_stroke);
-PHP_FUNCTION(pdf_setrgbcolor);
-PHP_FUNCTION(pdf_add_outline);
-PHP_FUNCTION(pdf_set_transition);
-PHP_FUNCTION(pdf_set_duration);
-PHP_FUNCTION(pdf_open_jpeg);
-#if HAVE_LIBGD13
-PHP_FUNCTION(pdf_open_memory_image);
-#endif
-PHP_FUNCTION(pdf_open_gif);
-PHP_FUNCTION(pdf_close_image);
-PHP_FUNCTION(pdf_place_image);
-PHP_FUNCTION(pdf_put_image);
-PHP_FUNCTION(pdf_execute_image);
-PHP_FUNCTION(pdf_add_weblink);
-PHP_FUNCTION(pdf_add_pdflink);
-PHP_FUNCTION(pdf_add_annotation);
-PHP_FUNCTION(pdf_set_border_style);
-PHP_FUNCTION(pdf_set_border_color);
-PHP_FUNCTION(pdf_get_image_width);
-PHP_FUNCTION(pdf_get_image_height);
-#else
-#define pdf_module_ptr NULL
-#endif
-#define phpext_pdf_ptr pdf_module_ptr
-#endif /* _PHP3_PDF_H */
diff --git a/ext/pdf/setup.stub b/ext/pdf/setup.stub
deleted file mode 100644
index a6df9c669c..0000000000
--- a/ext/pdf/setup.stub
+++ /dev/null
@@ -1,7 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-pdflib 'pdflib 0.6 support? ' yesnodir \
- 'no /usr/local pdflib install' \
-' Whether to use the pdflib support to write .pdf-files.\n
- Tested for version 0.6!'
diff --git a/ext/pgsql/Makefile.am b/ext/pgsql/Makefile.am
deleted file mode 100644
index 5a4a3e8605..0000000000
--- a/ext/pgsql/Makefile.am
+++ /dev/null
@@ -1,16 +0,0 @@
-# $Id$
-
-phplibdir=$(libdir)/php
-
-SRC=pgsql.c
-INCLUDES=@INCLUDES@ @PGSQL_INCLUDE@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=@PGSQL_STATIC@
-EXTRA_LIBRARIES=libphpext_pgsql.a
-libphpext_pgsql_a_SOURCES=$(SRC)
-phplib_LTLIBRARIES=@PGSQL_SHARED@
-EXTRA_LTLIBRARIES=pgsql.la
-pgsql_la_SOURCES=$(SRC)
-pgsql_la_LIBADD=@PGSQL_LFLAGS@ @PGSQL_LIBS@
-pgsql_la_LDFLAGS=-avoid-version -module -rpath $(phplibdir)
-EXTRA_LIBS=
-
diff --git a/ext/pgsql/config.h.stub b/ext/pgsql/config.h.stub
deleted file mode 100644
index fa21acc568..0000000000
--- a/ext/pgsql/config.h.stub
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef HAVE_PGSQL
-#define HAVE_PGSQL 0
-#endif
-
-#ifndef HAVE_PQCMDTUPLES
-#define HAVE_PQCMDTUPLES 0
-#endif
-
diff --git a/ext/pgsql/config.m4 b/ext/pgsql/config.m4
deleted file mode 100644
index a64dc47824..0000000000
--- a/ext/pgsql/config.m4
+++ /dev/null
@@ -1,65 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(for PostgresSQL support)
-AC_ARG_WITH(pgsql,
-[ --with-pgsql[=DIR] Include PostgresSQL support. DIR is the PostgresSQL
- base install directory, defaults to /usr/local/pgsql.
- Set DIR to "shared" to build as a dl, or "shared,DIR"
- to build as a dl and still specify DIR.],
-[
- case $withval in
- shared)
- shared=yes
- withval=yes
- ;;
- shared,*)
- shared=yes
- withval=`echo $withval | sed -e 's/^shared,//'`
- ;;
- *)
- shared=no
- ;;
- esac
- if test "$withval" != "no"; then
- if test "$withval" = "yes"; then
- PGSQL_INCDIR=/usr/local/pgsql/include
- PGSQL_LIBDIR=/usr/local/pgsql/lib
- else
- PGSQL_INCDIR=$withval/include
- test -d $withval/include/pgsql && PGSQL_INCDIR=$withval/include/pgsql
- test -d $withval/include/postgresql && PGSQL_INCDIR=$withval/include/postgresql
- PGSQL_LIBDIR=$withval/lib
- test -d $withval/lib/pgsql && PGSQL_LIBDIR=$withval/lib/pgsql
- fi
- PGSQL_INCLUDE=-I$PGSQL_INCDIR
- PGSQL_LFLAGS=-L$PGSQL_LIBDIR
- PGSQL_LIBS=-lpq
-
- old_CFLAGS=$CFLAGS; old_LDFLAGS=$LDFLAGS; old_LIBS=$LIBS
- CFLAGS="$CFLAGS $PGSQL_INCLUDE"
- LDFLAGS="$LDFLAGS $PGSQL_LFLAGS"
- LIBS="$LIBS $PGSQL_LIBS"
- AC_DEFINE(HAVE_PGSQL)
- if test "$shared" = "yes"; then
- AC_MSG_RESULT(yes (shared))
- PGSQL_SHARED="pgsql.la"
- else
- AC_MSG_RESULT(yes (static))
- AC_ADD_LIBRARY_WITH_PATH(pq, $PGSQL_LIBDIR)
- AC_ADD_INCLUDE($PGSQL_INCDIR)
- PGSQL_STATIC="libphpext_pgsql.a"
- fi
- AC_CHECK_FUNC(PQcmdTuples,AC_DEFINE(HAVE_PQCMDTUPLES))
- CFLAGS=$old_CFLAGS; LDFLAGS=$old_LDFLAGS; LIBS=$old_LIBS
- PHP_EXTENSION(pgsql,$shared)
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-AC_SUBST(PGSQL_LIBS)
-AC_SUBST(PGSQL_LFLAGS)
-AC_SUBST(PGSQL_INCLUDE)
-AC_SUBST(PGSQL_STATIC)
-AC_SUBST(PGSQL_SHARED)
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
deleted file mode 100644
index 089afd8f37..0000000000
--- a/ext/pgsql/pgsql.c
+++ /dev/null
@@ -1,1473 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- | Jouni Ahto <jah@cultnet.fi> (large object interface) |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include <stdlib.h>
-
-#ifdef PIC
-# define COMPILE_DL 1
-#endif
-
-#include "php.h"
-#include "php3_pgsql.h"
-#include "ext/standard/php3_standard.h"
-#include "php_globals.h"
-
-#if HAVE_PGSQL
-
-
-#define PGSQL_ASSOC 1<<0
-#define PGSQL_NUM 1<<1
-#define PGSQL_BOTH (PGSQL_ASSOC|PGSQL_NUM)
-
-
-function_entry pgsql_functions[] = {
- {"pg_connect", php3_pgsql_connect, NULL},
- {"pg_pconnect", php3_pgsql_pconnect, NULL},
- {"pg_close", php3_pgsql_close, NULL},
- {"pg_cmdtuples", php3_pgsql_cmdtuples, NULL},
- {"pg_dbname", php3_pgsql_dbname, NULL},
- {"pg_errormessage", php3_pgsql_error_message, NULL},
- {"pg_options", php3_pgsql_options, NULL},
- {"pg_port", php3_pgsql_port, NULL},
- {"pg_tty", php3_pgsql_tty, NULL},
- {"pg_host", php3_pgsql_host, NULL},
- {"pg_exec", php3_pgsql_exec, NULL},
- {"pg_numrows", php3_pgsql_num_rows, NULL},
- {"pg_numfields", php3_pgsql_num_fields, NULL},
- {"pg_fieldname", php3_pgsql_field_name, NULL},
- {"pg_fieldsize", php3_pgsql_field_size, NULL},
- {"pg_fieldtype", php3_pgsql_field_type, NULL},
- {"pg_fieldnum", php3_pgsql_field_number, NULL},
- {"pg_result", php3_pgsql_result, NULL},
- {"pg_fetch_row", php3_pgsql_fetch_row, NULL},
- {"pg_fetch_array", php3_pgsql_fetch_array, NULL},
- {"pg_fetch_object", php3_pgsql_fetch_object, NULL},
- {"pg_fieldprtlen", php3_pgsql_data_length, NULL},
- {"pg_fieldisnull", php3_pgsql_data_isnull, NULL},
- {"pg_freeresult", php3_pgsql_free_result, NULL},
- {"pg_getlastoid", php3_pgsql_last_oid, NULL},
- {"pg_locreate", php3_pgsql_lo_create, NULL},
- {"pg_lounlink", php3_pgsql_lo_unlink, NULL},
- {"pg_loopen", php3_pgsql_lo_open, NULL},
- {"pg_loclose", php3_pgsql_lo_close, NULL},
- {"pg_loread", php3_pgsql_lo_read, NULL},
- {"pg_lowrite", php3_pgsql_lo_write, NULL},
- {"pg_loreadall", php3_pgsql_lo_readall, NULL},
- {NULL, NULL, NULL}
-};
-
-php3_module_entry pgsql_module_entry = {
- "PostgreSQL", pgsql_functions, php3_minit_pgsql, NULL, php3_rinit_pgsql, NULL, NULL, STANDARD_MODULE_PROPERTIES
-};
-
-#if COMPILE_DL
-php3_module_entry *get_module() { return &pgsql_module_entry; }
-#endif
-
-THREAD_LS pgsql_module php3_pgsql_module;
-
-static void _close_pgsql_link(PGconn *link)
-{
- PQfinish(link);
- php3_pgsql_module.num_links--;
-}
-
-
-static void _close_pgsql_plink(PGconn *link)
-{
- PQfinish(link);
- php3_pgsql_module.num_persistent--;
- php3_pgsql_module.num_links--;
-}
-
-
-static void _free_ptr(pgLofp *lofp)
-{
- efree(lofp);
-}
-
-
-static void _free_result(pgsql_result_handle *pg_result)
-{
- PQclear(pg_result->result);
- efree(pg_result);
-}
-
-
-int php3_minit_pgsql(INIT_FUNC_ARGS)
-{
- if (cfg_get_long("pgsql.allow_persistent",&php3_pgsql_module.allow_persistent)==FAILURE) {
- php3_pgsql_module.allow_persistent=1;
- }
- if (cfg_get_long("pgsql.max_persistent",&php3_pgsql_module.max_persistent)==FAILURE) {
- php3_pgsql_module.max_persistent=-1;
- }
- if (cfg_get_long("pgsql.max_links",&php3_pgsql_module.max_links)==FAILURE) {
- php3_pgsql_module.max_links=-1;
- }
- php3_pgsql_module.num_persistent=0;
- php3_pgsql_module.le_link = register_list_destructors(_close_pgsql_link,NULL);
- php3_pgsql_module.le_plink = register_list_destructors(NULL,_close_pgsql_plink);
- /* php3_pgsql_module.le_result = register_list_destructors(PQclear,NULL); */
- php3_pgsql_module.le_result = register_list_destructors(_free_result,NULL);
- php3_pgsql_module.le_lofp = register_list_destructors(_free_ptr,NULL);
- php3_pgsql_module.le_string = register_list_destructors(_free_ptr,NULL);
-
- REGISTER_LONG_CONSTANT("PGSQL_ASSOC", PGSQL_ASSOC, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("PGSQL_NUM", PGSQL_NUM, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("PGSQL_BOTH", PGSQL_BOTH, CONST_CS | CONST_PERSISTENT);
-
- return SUCCESS;
-}
-
-
-int php3_rinit_pgsql(INIT_FUNC_ARGS)
-{
- php3_pgsql_module.default_link=-1;
- php3_pgsql_module.num_links = php3_pgsql_module.num_persistent;
- return SUCCESS;
-}
-
-
-void php3_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
-{
- char *host=NULL,*port=NULL,*options=NULL,*tty=NULL,*dbname=NULL,*connstring=NULL;
- char *hashed_details;
- int hashed_details_length;
- PGconn *pgsql;
-
- switch(ARG_COUNT(ht)) {
- case 1: { /* new style, using connection string */
- pval *yyconnstring;
- if (getParameters(ht, 1, &yyconnstring) == FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(yyconnstring);
- connstring = yyconnstring->value.str.val;
- hashed_details_length = yyconnstring->value.str.len+5+1;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details,"pgsql_%s",connstring); /* SAFE */
- }
- break;
- case 3: { /* host, port, dbname */
- pval *yyhost, *yyport, *yydbname;
-
- if (getParameters(ht, 3, &yyhost, &yyport, &yydbname) == FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(yyhost);
- convert_to_string(yyport);
- convert_to_string(yydbname);
- host = yyhost->value.str.val;
- port = yyport->value.str.val;
- dbname = yydbname->value.str.val;
- options=tty=NULL;
- hashed_details_length = yyhost->value.str.len+yyport->value.str.len+yydbname->value.str.len+5+5;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details,"pgsql_%s_%s___%s",host,port,dbname); /* SAFE */
- }
- break;
- case 4: { /* host, port, options, dbname */
- pval *yyhost, *yyport, *yyoptions, *yydbname;
-
- if (getParameters(ht, 4, &yyhost, &yyport, &yyoptions, &yydbname) == FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(yyhost);
- convert_to_string(yyport);
- convert_to_string(yyoptions);
- convert_to_string(yydbname);
- host = yyhost->value.str.val;
- port = yyport->value.str.val;
- options = yyoptions->value.str.val;
- dbname = yydbname->value.str.val;
- tty=NULL;
- hashed_details_length = yyhost->value.str.len+yyport->value.str.len+yyoptions->value.str.len+yydbname->value.str.len+5+5;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details,"pgsql_%s_%s_%s__%s",host,port,options,dbname); /* SAFE */
- }
- break;
- case 5: { /* host, port, options, tty, dbname */
- pval *yyhost, *yyport, *yyoptions, *yytty, *yydbname;
-
- if (getParameters(ht, 5, &yyhost, &yyport, &yyoptions, &yytty, &yydbname) == FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(yyhost);
- convert_to_string(yyport);
- convert_to_string(yyoptions);
- convert_to_string(yytty);
- convert_to_string(yydbname);
- host = yyhost->value.str.val;
- port = yyport->value.str.val;
- options = yyoptions->value.str.val;
- tty = yytty->value.str.val;
- dbname = yydbname->value.str.val;
- hashed_details_length = yyhost->value.str.len+yyport->value.str.len+yyoptions->value.str.len+yytty->value.str.len+yydbname->value.str.len+5+5;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details,"pgsql_%s_%s_%s_%s_%s",host,port,options,tty,dbname); /* SAFE */
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- if (persistent) {
- list_entry *le;
-
- /* try to find if we already have this link in our persistent list */
- if (zend_hash_find(plist, hashed_details, hashed_details_length+1, (void **) &le)==FAILURE) { /* we don't */
- list_entry new_le;
-
- if (php3_pgsql_module.max_links!=-1 && php3_pgsql_module.num_links>=php3_pgsql_module.max_links) {
- php_error(E_WARNING,"PostgresSQL: Too many open links (%d)",php3_pgsql_module.num_links);
- efree(hashed_details);
- RETURN_FALSE;
- }
- if (php3_pgsql_module.max_persistent!=-1 && php3_pgsql_module.num_persistent>=php3_pgsql_module.max_persistent) {
- php_error(E_WARNING,"PostgresSQL: Too many open persistent links (%d)",php3_pgsql_module.num_persistent);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- /* create the link */
- if (connstring) {
- pgsql=PQconnectdb(connstring);
- } else {
- pgsql=PQsetdb(host,port,options,tty,dbname);
- }
- if (pgsql==NULL || PQstatus(pgsql)==CONNECTION_BAD) {
- php_error(E_WARNING,"Unable to connect to PostgresSQL server: %s",PQerrorMessage(pgsql));
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- /* hash it up */
- new_le.type = php3_pgsql_module.le_plink;
- new_le.ptr = pgsql;
- if (zend_hash_update(plist, hashed_details, hashed_details_length+1, (void *) &new_le, sizeof(list_entry), NULL)==FAILURE) {
- efree(hashed_details);
- RETURN_FALSE;
- }
- php3_pgsql_module.num_links++;
- php3_pgsql_module.num_persistent++;
- } else { /* we do */
- if (le->type != php3_pgsql_module.le_plink) {
- RETURN_FALSE;
- }
- /* ensure that the link did not die */
- if (PQstatus(le->ptr)==CONNECTION_BAD) { /* the link died */
- if (connstring) {
- le->ptr=PQconnectdb(connstring);
- } else {
- le->ptr=PQsetdb(host,port,options,tty,dbname);
- }
- if (le->ptr==NULL || PQstatus(le->ptr)==CONNECTION_BAD) {
- php_error(E_WARNING,"PostgresSQL link lost, unable to reconnect");
- zend_hash_del(plist,hashed_details,hashed_details_length+1);
- efree(hashed_details);
- RETURN_FALSE;
- }
- }
- pgsql = (PGconn *) le->ptr;
- }
- return_value->value.lval = php3_list_insert(pgsql,php3_pgsql_module.le_plink);
- return_value->type = IS_LONG;
- } else {
- list_entry *index_ptr,new_index_ptr;
-
- /* first we check the hash for the hashed_details key. if it exists,
- * it should point us to the right offset where the actual pgsql link sits.
- * if it doesn't, open a new pgsql link, add it to the resource list,
- * and add a pointer to it with hashed_details as the key.
- */
- if (zend_hash_find(list,hashed_details,hashed_details_length+1,(void **) &index_ptr)==SUCCESS) {
- int type,link;
- void *ptr;
-
- if (index_ptr->type != le_index_ptr) {
- RETURN_FALSE;
- }
- link = (int) index_ptr->ptr;
- ptr = php3_list_find(link,&type); /* check if the link is still there */
- if (ptr && (type==php3_pgsql_module.le_link || type==php3_pgsql_module.le_plink)) {
- return_value->value.lval = php3_pgsql_module.default_link = link;
- return_value->type = IS_LONG;
- efree(hashed_details);
- return;
- } else {
- zend_hash_del(list,hashed_details,hashed_details_length+1);
- }
- }
- if (php3_pgsql_module.max_links!=-1 && php3_pgsql_module.num_links>=php3_pgsql_module.max_links) {
- php_error(E_WARNING,"PostgresSQL: Too many open links (%d)",php3_pgsql_module.num_links);
- efree(hashed_details);
- RETURN_FALSE;
- }
- if (connstring) {
- pgsql=PQconnectdb(connstring);
- } else {
- pgsql=PQsetdb(host,port,options,tty,dbname);
- }
- if (pgsql==NULL || PQstatus(pgsql)==CONNECTION_BAD) {
- php_error(E_WARNING,"Unable to connect to PostgresSQL server: %s",PQerrorMessage(pgsql));
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- /* add it to the list */
- return_value->value.lval = php3_list_insert(pgsql,php3_pgsql_module.le_link);
- return_value->type = IS_LONG;
-
- /* add it to the hash */
- new_index_ptr.ptr = (void *) return_value->value.lval;
- new_index_ptr.type = le_index_ptr;
- if (zend_hash_update(list,hashed_details,hashed_details_length+1,(void *) &new_index_ptr, sizeof(list_entry), NULL)==FAILURE) {
- efree(hashed_details);
- RETURN_FALSE;
- }
- php3_pgsql_module.num_links++;
- }
- efree(hashed_details);
- php3_pgsql_module.default_link=return_value->value.lval;
-}
-
-
-int php3_pgsql_get_default_link(INTERNAL_FUNCTION_PARAMETERS)
-{
- if (php3_pgsql_module.default_link==-1) { /* no link opened yet, implicitly open one */
- ht = 0;
- php3_pgsql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
- }
- return php3_pgsql_module.default_link;
-}
-
-
-/* {{{ proto int pg_connect([string connection_string] | [string host, string port, [string options, [string tty,]] string database)
- Open a PostgreSQL connection */
-PHP_FUNCTION(pgsql_connect)
-{
- php3_pgsql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
-}
-/* }}} */
-
-/* {{{ proto int pg_pconnect([string connection_string] | [string host, string port, [string options, [string tty,]] string database)
- Open a persistent PostgreSQL connection */
-PHP_FUNCTION(pgsql_pconnect)
-{
- php3_pgsql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
-}
-/* }}} */
-
-/* {{{ proto bool pg_close([int connection])
- Close a PostgreSQL connection */
-PHP_FUNCTION(pgsql_close)
-{
- pval *pgsql_link;
- int id,type;
- PGconn *pgsql;
-
- switch (ARG_COUNT(ht)) {
- case 0:
- id = php3_pgsql_module.default_link;
- break;
- case 1:
- if (getParameters(ht, 1, &pgsql_link)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(pgsql_link);
- id = pgsql_link->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=php3_pgsql_module.le_link && type!=php3_pgsql_module.le_plink) {
- php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
- RETURN_FALSE;
- }
-
- php3_list_delete(pgsql_link->value.lval);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-#define PHP3_PG_DBNAME 1
-#define PHP3_PG_ERROR_MESSAGE 2
-#define PHP3_PG_OPTIONS 3
-#define PHP3_PG_PORT 4
-#define PHP3_PG_TTY 5
-#define PHP3_PG_HOST 6
-
-void php3_pgsql_get_link_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
-{
- pval *pgsql_link;
- int id,type;
- PGconn *pgsql;
-
- switch(ARG_COUNT(ht)) {
- case 0:
- id = php3_pgsql_module.default_link;
- break;
- case 1:
- if (getParameters(ht, 1, &pgsql_link)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(pgsql_link);
- id = pgsql_link->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=php3_pgsql_module.le_link && type!=php3_pgsql_module.le_plink) {
- php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
- RETURN_FALSE;
- }
-
- switch(entry_type) {
- case PHP3_PG_DBNAME:
- return_value->value.str.val = PQdb(pgsql);
- break;
- case PHP3_PG_ERROR_MESSAGE:
- return_value->value.str.val = PQerrorMessage(pgsql);
- break;
- case PHP3_PG_OPTIONS:
- return_value->value.str.val = PQoptions(pgsql);
- break;
- case PHP3_PG_PORT:
- return_value->value.str.val = PQport(pgsql);
- break;
- case PHP3_PG_TTY:
- return_value->value.str.val = PQtty(pgsql);
- break;
- case PHP3_PG_HOST:
- return_value->value.str.val = PQhost(pgsql);
- break;
- default:
- RETURN_FALSE;
- }
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->value.str.val = (char *) estrdup(return_value->value.str.val);
- return_value->type = IS_STRING;
-}
-
-/* {{{ proto string pg_dbname([int connection])
- Get the database name */
-PHP_FUNCTION(pgsql_dbname)
-{
- php3_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_PG_DBNAME);
-}
-/* }}} */
-
-/* {{{ proto string pg_errormessage([int connection])
- Get the error message string */
-PHP_FUNCTION(pgsql_error_message)
-{
- php3_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_PG_ERROR_MESSAGE);
-}
-/* }}} */
-
-/* {{{ proto string pg_options([int connection])
- Get the options associated with the connection */
-PHP_FUNCTION(pgsql_options)
-{
- php3_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_PG_OPTIONS);
-}
-/* }}} */
-
-/* {{{ proto int pg_port([int connection])
- Return the port number associated with the connection */
-PHP_FUNCTION(pgsql_port)
-{
- php3_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_PG_PORT);
-}
-/* }}} */
-
-/* {{{ proto string pg_tty([int connection])
- Return the tty name associated with the connection */
-PHP_FUNCTION(pgsql_tty)
-{
- php3_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_PG_TTY);
-}
-/* }}} */
-
-/* {{{ proto string pg_host([int connection])
- Returns the host name associated with the connection */
-PHP_FUNCTION(pgsql_host)
-{
- php3_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_PG_HOST);
-}
-/* }}} */
-
-/* {{{ proto int pg_exec([int connection,] string query)
- Execute a query */
-PHP_FUNCTION(pgsql_exec)
-{
- pval *query,*pgsql_link;
- int id,type;
- PGconn *pgsql;
- PGresult *pgsql_result;
- ExecStatusType status;
- pgsql_result_handle *pg_result;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &query)==FAILURE) {
- RETURN_FALSE;
- }
- id = php3_pgsql_module.default_link;
- break;
- case 2:
- if (getParameters(ht, 2, &pgsql_link, &query)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(pgsql_link);
- id = pgsql_link->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=php3_pgsql_module.le_link && type!=php3_pgsql_module.le_plink) {
- php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
- RETURN_FALSE;
- }
-
- convert_to_string(query);
- pgsql_result=PQexec(pgsql,query->value.str.val);
-
- if (pgsql_result) {
- status = PQresultStatus(pgsql_result);
- } else {
- status = (ExecStatusType) PQstatus(pgsql);
- }
-
-
- switch (status) {
- case PGRES_EMPTY_QUERY:
- case PGRES_BAD_RESPONSE:
- case PGRES_NONFATAL_ERROR:
- case PGRES_FATAL_ERROR:
- php_error(E_WARNING,"PostgresSQL query failed: %s",PQerrorMessage(pgsql));
- RETURN_FALSE;
- break;
- case PGRES_COMMAND_OK: /* successful command that did not return rows */
- default:
- if (pgsql_result) {
- pg_result = (pgsql_result_handle *) emalloc(sizeof(pgsql_result_handle));
- pg_result->conn = pgsql;
- pg_result->result = pgsql_result;
- return_value->value.lval = php3_list_insert(pg_result,php3_pgsql_module.le_result);
- return_value->type = IS_LONG;
- } else {
- RETURN_FALSE;
- }
- break;
- }
-}
-/* }}} */
-
-#define PHP3_PG_NUM_ROWS 1
-#define PHP3_PG_NUM_FIELDS 2
-#define PHP3_PG_CMD_TUPLES 3
-
-void php3_pgsql_get_result_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
-{
- pval *result;
- PGresult *pgsql_result;
- pgsql_result_handle *pg_result;
- int type;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(result);
- pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
-
- if (type!=php3_pgsql_module.le_result) {
- php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
- RETURN_FALSE;
- }
-
- pgsql_result = pg_result->result;
-
- switch (entry_type) {
- case PHP3_PG_NUM_ROWS:
- return_value->value.lval = PQntuples(pgsql_result);
- break;
- case PHP3_PG_NUM_FIELDS:
- return_value->value.lval = PQnfields(pgsql_result);
- break;
- case PHP3_PG_CMD_TUPLES:
-#if HAVE_PQCMDTUPLES
- return_value->value.lval = atoi(PQcmdTuples(pgsql_result));
-#else
- php_error(E_WARNING,"This compilation does not support pg_cmdtuples()");
- return_value->value.lval = 0;
-#endif
- break;
- default:
- RETURN_FALSE;
- }
- return_value->type = IS_LONG;
-}
-
-/* {{{ proto int pg_numrows(int result)
- Return the number of rows in the result */
-PHP_FUNCTION(pgsql_num_rows)
-{
- php3_pgsql_get_result_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_PG_NUM_ROWS);
-}
-/* }}} */
-
-/* {{{ proto int pg_numfields(int result)
- Return the number of fields in the result */
-PHP_FUNCTION(pgsql_num_fields)
-{
- php3_pgsql_get_result_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_PG_NUM_FIELDS);
-}
-/* }}} */
-
-/* {{{ proto int pg_cmdtuples(int result)
- Returns the number of affected tuples */
-PHP_FUNCTION(pgsql_cmdtuples)
-{
- php3_pgsql_get_result_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_PG_CMD_TUPLES);
-}
-/* }}} */
-
-
-char *get_field_name(PGconn *pgsql, Oid oid, HashTable *list)
-{
- PGresult *result;
- char hashed_oid_key[32];
- list_entry *field_type;
- char *ret=NULL;
-
- /* try to lookup the type in the resource list */
- snprintf(hashed_oid_key,31,"pgsql_oid_%d",(int) oid);
- hashed_oid_key[31]=0;
-
- if (zend_hash_find(list,hashed_oid_key,strlen(hashed_oid_key)+1,(void **) &field_type)==SUCCESS) {
- ret = estrdup((char *)field_type->ptr);
- } else { /* hash all oid's */
- int i,num_rows;
- int oid_offset,name_offset;
- char *tmp_oid, *tmp_name;
- list_entry new_oid_entry;
-
- if ((result=PQexec(pgsql,"select oid,typname from pg_type"))==NULL) {
- return empty_string;
- }
- num_rows=PQntuples(result);
- oid_offset = PQfnumber(result,"oid");
- name_offset = PQfnumber(result,"typname");
-
- for (i=0; i<num_rows; i++) {
- if ((tmp_oid=PQgetvalue(result,i,oid_offset))==NULL) {
- continue;
- }
- snprintf(hashed_oid_key,31,"pgsql_oid_%s",tmp_oid);
- if ((tmp_name=PQgetvalue(result,i,name_offset))==NULL) {
- continue;
- }
- new_oid_entry.type = php3_pgsql_module.le_string;
- new_oid_entry.ptr = estrdup(tmp_name);
- zend_hash_update(list,hashed_oid_key,strlen(hashed_oid_key)+1,(void *) &new_oid_entry, sizeof(list_entry), NULL);
- if (!ret && atoi(tmp_oid)==oid) {
- ret = estrdup(tmp_name);
- }
- }
- }
- return ret;
-}
-
-
-#define PHP3_PG_FIELD_NAME 1
-#define PHP3_PG_FIELD_SIZE 2
-#define PHP3_PG_FIELD_TYPE 3
-
-void php3_pgsql_get_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
-{
- pval *result,*field;
- PGresult *pgsql_result;
- pgsql_result_handle *pg_result;
- int type;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &result, &field)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(result);
- pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
-
- if (type!=php3_pgsql_module.le_result) {
- php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
- RETURN_FALSE;
- }
-
- pgsql_result = pg_result->result;
- convert_to_long(field);
-
- if (field->value.lval<0 || field->value.lval>=PQnfields(pgsql_result)) {
- php_error(E_WARNING,"Bad field offset specified");
- RETURN_FALSE;
- }
-
- switch (entry_type) {
- case PHP3_PG_FIELD_NAME:
- return_value->value.str.val = PQfname(pgsql_result,field->value.lval);
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->value.str.val = estrndup(return_value->value.str.val,return_value->value.str.len);
- return_value->type = IS_STRING;
- break;
- case PHP3_PG_FIELD_SIZE:
- return_value->value.lval = PQfsize(pgsql_result,field->value.lval);
- return_value->type = IS_LONG;
- break;
- case PHP3_PG_FIELD_TYPE:
- return_value->value.str.val = get_field_name(pg_result->conn,PQftype(pgsql_result,field->value.lval),list);
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
- break;
- default:
- RETURN_FALSE;
- }
-}
-
-/* {{{ proto string pg_fieldname(int result, int field_number)
- Returns the name of the field */
-PHP_FUNCTION(pgsql_field_name)
-{
- php3_pgsql_get_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_PG_FIELD_NAME);
-}
-/* }}} */
-
-/* {{{ proto int pg_fieldsize(int result, int field_number)
- Returns the internal size of the field */
-PHP_FUNCTION(pgsql_field_size)
-{
- php3_pgsql_get_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_PG_FIELD_SIZE);
-}
-/* }}} */
-
-/* {{{ proto string pg_fieldtype(int result, int field_number)
- Returns the type name for the given field */
-PHP_FUNCTION(pgsql_field_type)
-{
- php3_pgsql_get_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP3_PG_FIELD_TYPE);
-}
-/* }}} */
-
-/* {{{ proto int pg_fieldnum(int result, string field_name)
- Returns the field number of the named field */
-PHP_FUNCTION(pgsql_field_number)
-{
- pval *result,*field;
- PGresult *pgsql_result;
- pgsql_result_handle *pg_result;
- int type;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &result, &field)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(result);
- pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
-
- if (type!=php3_pgsql_module.le_result) {
- php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
- RETURN_FALSE;
- }
- pgsql_result = pg_result->result;
-
- convert_to_string(field);
- return_value->value.lval = PQfnumber(pgsql_result,field->value.str.val);
- return_value->type = IS_LONG;
-}
-/* }}} */
-
-/* {{{ proto mixed pg_result(int result, int row_number, mixed field_name)
- Returns values from a result identifier */
-PHP_FUNCTION(pgsql_result)
-{
- pval *result, *row, *field=NULL;
- PGresult *pgsql_result;
- pgsql_result_handle *pg_result;
- int type,field_offset;
-
-
- if (ARG_COUNT(ht)!=3 || getParameters(ht, 3, &result, &row, &field)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(result);
- pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
-
- if (type!=php3_pgsql_module.le_result) {
- php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
- RETURN_FALSE;
- }
- pgsql_result = pg_result->result;
-
- convert_to_long(row);
- if (row->value.lval<0 || row->value.lval>=PQntuples(pgsql_result)) {
- php_error(E_WARNING,"Unable to jump to row %d on PostgresSQL result index %d",row->value.lval,result->value.lval);
- RETURN_FALSE;
- }
- switch(field->type) {
- case IS_STRING:
- field_offset = PQfnumber(pgsql_result,field->value.str.val);
- break;
- default:
- convert_to_long(field);
- field_offset = field->value.lval;
- break;
- }
- if (field_offset<0 || field_offset>=PQnfields(pgsql_result)) {
- php_error(E_WARNING,"Bad column offset specified");
- RETURN_FALSE;
- }
-
- return_value->value.str.val = PQgetvalue(pgsql_result,row->value.lval,field_offset);
- return_value->value.str.len = (return_value->value.str.val ? strlen(return_value->value.str.val) : 0);
- return_value->value.str.val = safe_estrndup(return_value->value.str.val,return_value->value.str.len);
- return_value->type = IS_STRING;
-}
-/* }}} */
-
-
-static void php3_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
-{
- pval *result, *row, *arg3;
- PGresult *pgsql_result;
- pgsql_result_handle *pg_result;
- int type;
- int i,num_fields;
- char *element,*field_name;
- uint element_len;
- PLS_FETCH();
-
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &result, &row)==FAILURE) {
- RETURN_FALSE;
- }
- if (!result_type) {
- result_type = PGSQL_BOTH;
- }
- break;
- case 3:
- if (getParameters(ht, 2, &result, &row, &arg3)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(arg3);
- result_type = arg3->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- convert_to_long(result);
- pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
-
- if (type!=php3_pgsql_module.le_result) {
- php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
- RETURN_FALSE;
- }
- pgsql_result = pg_result->result;
-
- convert_to_long(row);
- if (row->value.lval<0 || row->value.lval>=PQntuples(pgsql_result)) {
- php_error(E_WARNING,"Unable to jump to row %d on PostgresSQL result index %d",row->value.lval,result->value.lval);
- RETURN_FALSE;
- }
- array_init(return_value);
- for (i=0,num_fields=PQnfields(pgsql_result); i<num_fields; i++) {
- element = PQgetvalue(pgsql_result,row->value.lval,i);
- element_len = (element ? strlen(element) : 0);
- if (element) {
- char *data;
- int data_len;
- int should_copy=0;
-
- if (PG(magic_quotes_runtime)) {
- data = php_addslashes(element,element_len,&data_len,0);
- } else {
- data = safe_estrndup(element,element_len);
- data_len = element_len;
- }
-
- if (result_type & PGSQL_NUM) {
- add_index_stringl(return_value, i, data, data_len, should_copy);
- should_copy=1;
- }
-
- if (result_type & PGSQL_ASSOC) {
- field_name = PQfname(pgsql_result,i);
- add_assoc_stringl(return_value, field_name, data, data_len, should_copy);
- }
- } else {
- /* NULL field, don't set it */
- /* add_get_index_stringl(return_value, i, empty_string, 0, (void **) &pval_ptr); */
- }
- }
-}
-
-
-/* {{{ proto array pg_fetchrow(int result, int row)
- Get a row as an enumerated array */
-PHP_FUNCTION(pgsql_fetch_row)
-{
- php3_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, PGSQL_NUM);
-}
-/* }}} */
-
-/* ?? This is a rather odd function - why not just point pg_fetcharray() directly at fetch_hash ? -RL */
-/* {{{ proto array pg_fetch_array(int result, int row [, int result_type])
- Fetch a row as an array */
-PHP_FUNCTION(pgsql_fetch_array)
-{
- php3_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ proto object pg_fetch_object(int result, int row [, int result_type])
- Fetch a row as an object */
-PHP_FUNCTION(pgsql_fetch_object)
-{
- php3_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
- if (return_value->type==IS_ARRAY) {
- return_value->type=IS_OBJECT;
- return_value->value.obj.properties = return_value->value.ht;
- return_value->value.obj.ce = &zend_standard_class_def;
- }
-}
-/* }}} */
-
-#define PHP3_PG_DATA_LENGTH 1
-#define PHP3_PG_DATA_ISNULL 2
-
-void php3_pgsql_data_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
-{
- pval *result,*row,*field;
- PGresult *pgsql_result;
- pgsql_result_handle *pg_result;
- int type,field_offset;
-
- if (ARG_COUNT(ht)!=3 || getParameters(ht, 3, &result, &row, &field)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(result);
- pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
-
- if (type!=php3_pgsql_module.le_result) {
- php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
- RETURN_FALSE;
- }
- pgsql_result = pg_result->result;
-
- convert_to_long(row);
- if (row->value.lval<0 || row->value.lval>=PQntuples(pgsql_result)) {
- php_error(E_WARNING,"Unable to jump to row %d on PostgresSQL result index %d",row->value.lval,result->value.lval);
- RETURN_FALSE;
- }
- switch(field->type) {
- case IS_STRING:
- field_offset = PQfnumber(pgsql_result,field->value.str.val);
- break;
- default:
- convert_to_long(field);
- field_offset = field->value.lval;
- break;
- }
- if (field_offset<0 || field_offset>=PQnfields(pgsql_result)) {
- php_error(E_WARNING,"Bad column offset specified");
- RETURN_FALSE;
- }
-
- switch (entry_type) {
- case PHP3_PG_DATA_LENGTH:
- return_value->value.lval = PQgetlength(pgsql_result,row->value.lval,field_offset);
- break;
- case PHP3_PG_DATA_ISNULL:
- return_value->value.lval = PQgetisnull(pgsql_result,row->value.lval,field_offset);
- break;
- }
- return_value->type = IS_LONG;
-}
-
-/* {{{ proto int pg_fieldprtlen(int result, int row, mixed field_name_or_number)
- Returns the printed length */
-PHP_FUNCTION(pgsql_data_length)
-{
- php3_pgsql_data_info(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP3_PG_DATA_LENGTH);
-}
-/* }}} */
-
-/* {{{ proto int pg_fieldisnull(int result, int row, mixed field_name_or_number)
- Test if a field is NULL */
-PHP_FUNCTION(pgsql_data_isnull)
-{
- php3_pgsql_data_info(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP3_PG_DATA_ISNULL);
-}
-/* }}} */
-
-/* {{{ proto int pg_freeresult(int result)
- Free result memory */
-PHP_FUNCTION(pgsql_free_result)
-{
- pval *result;
- pgsql_result_handle *pg_result;
- int type;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(result);
- if (result->value.lval==0) {
- RETURN_FALSE;
- }
- pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
-
- if (type!=php3_pgsql_module.le_result) {
- php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
- RETURN_FALSE;
- }
- php3_list_delete(result->value.lval);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int pg_getlastoid(int result)
- Returns the last object identifier */
-PHP_FUNCTION(pgsql_last_oid)
-{
- pval *result;
- PGresult *pgsql_result;
- pgsql_result_handle *pg_result;
- int type;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(result);
- pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
-
- if (type!=php3_pgsql_module.le_result) {
- php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
- RETURN_FALSE;
- }
- pgsql_result = pg_result->result;
- return_value->value.str.val = (char *) PQoidStatus(pgsql_result);
- if (return_value->value.str.val) {
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->value.str.val = estrndup(return_value->value.str.val, return_value->value.str.len);
- return_value->type = IS_STRING;
- } else {
- return_value->value.str.val = empty_string;
- }
-}
-/* }}} */
-
-/* {{{ proto int pg_locreate(int connection)
- Create a large object */
-PHP_FUNCTION(pgsql_lo_create)
-{
- pval *pgsql_link;
- PGconn *pgsql;
- Oid pgsql_oid;
- int id, type;
-
- switch(ARG_COUNT(ht)) {
- case 0:
- id = php3_pgsql_module.default_link;
- break;
- case 1:
- if (getParameters(ht, 1, &pgsql_link)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(pgsql_link);
- id = pgsql_link->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=php3_pgsql_module.le_link && type!=php3_pgsql_module.le_plink) {
- php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
- RETURN_FALSE;
- }
-
- /* XXX: Archive modes not supported until I get some more data. Don't think anybody's
- using it anyway. I believe it's also somehow related to the 'time travel' feature of
- PostgreSQL, that's on the list of features to be removed... Create modes not supported.
- What's the use of an object that can be only written to, but not read from, and vice
- versa? Beats me... And the access type (r/w) must be specified again when opening
- the object, probably (?) overrides this. (Jouni)
- */
-
- if ((pgsql_oid=lo_creat(pgsql, INV_READ|INV_WRITE))==0) {
- php_error(E_WARNING,"Unable to create PostgresSQL large object");
- RETURN_FALSE;
- }
-
- return_value->value.lval = pgsql_oid;
- return_value->type = IS_LONG;
-}
-/* }}} */
-
-/* {{{ proto void pg_lounlink([int connection, ] int large_obj_id)
- Delete a large object */
-PHP_FUNCTION(pgsql_lo_unlink)
-{
- pval *pgsql_link, *oid;
- PGconn *pgsql;
- Oid pgsql_oid;
- int id, type;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &oid)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(oid);
- pgsql_oid = oid->value.lval;
- id = php3_pgsql_module.default_link;
- break;
- case 2:
- if (getParameters(ht, 2, &pgsql_link, &oid)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(pgsql_link);
- id = pgsql_link->value.lval;
- convert_to_long(oid);
- pgsql_oid = oid->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=php3_pgsql_module.le_link && type!=php3_pgsql_module.le_plink) {
- php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
- RETURN_FALSE;
- }
-
- if (lo_unlink(pgsql, pgsql_oid)==-1) {
- php_error(E_WARNING,"Unable to delete PostgresSQL large object %d", (int) pgsql_oid);
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int pg_loopen([int connection,] int objoid, string mode)
- Open a large object and return fd */
-PHP_FUNCTION(pgsql_lo_open)
-{
- pval *pgsql_link, *oid, *mode;
- PGconn *pgsql;
- Oid pgsql_oid;
- int id, type, pgsql_mode=0, pgsql_lofd;
- int create=0;
- char *mode_string=NULL;
- pgLofp *pgsql_lofp;
-
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &oid, &mode)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(oid);
- pgsql_oid = oid->value.lval;
- convert_to_string(mode);
- mode_string = mode->value.str.val;
- id = php3_pgsql_module.default_link;
- break;
- case 3:
- if (getParameters(ht, 3, &pgsql_link, &oid, &mode)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(pgsql_link);
- id = pgsql_link->value.lval;
- convert_to_long(oid);
- pgsql_oid = oid->value.lval;
- convert_to_string(mode);
- mode_string = mode->value.str.val;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=php3_pgsql_module.le_link && type!=php3_pgsql_module.le_plink) {
- php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
- RETURN_FALSE;
- }
-
- /* r/w/+ is little bit more PHP-like than INV_READ/INV_WRITE and a lot of
- faster to type. Unfortunately, doesn't behave the same way as fopen()...
- (Jouni)
- */
-
- if (strchr(mode_string, 'r')==mode_string) {
- pgsql_mode |= INV_READ;
- if (strchr(mode_string, '+')==mode_string+1) {
- pgsql_mode |= INV_WRITE;
- }
- }
- if (strchr(mode_string, 'w')==mode_string) {
- pgsql_mode |= INV_WRITE;
- create = 1;
- if (strchr(mode_string, '+')==mode_string+1) {
- pgsql_mode |= INV_READ;
- }
- }
-
-
- pgsql_lofp = (pgLofp *) emalloc(sizeof(pgLofp));
-
- if ((pgsql_lofd=lo_open(pgsql, pgsql_oid, pgsql_mode))==-1) {
- if (create) {
- if ((pgsql_oid=lo_creat(pgsql, INV_READ|INV_WRITE))==0) {
- efree(pgsql_lofp);
- php_error(E_WARNING,"Unable to create PostgresSQL large object");
- RETURN_FALSE;
- } else {
- if ((pgsql_lofd=lo_open(pgsql, pgsql_oid, pgsql_mode))==-1) {
- if (lo_unlink(pgsql, pgsql_oid)==-1) {
- efree(pgsql_lofp);
- php_error(E_WARNING,"Something's really messed up!!! Your database is badly corrupted in a way NOT related to PHP.");
- RETURN_FALSE;
- }
- efree(pgsql_lofp);
- php_error(E_WARNING,"Unable to open PostgresSQL large object");
- RETURN_FALSE;
- } else {
- pgsql_lofp->conn = pgsql;
- pgsql_lofp->lofd = pgsql_lofd;
- return_value->value.lval = php3_list_insert(pgsql_lofp, php3_pgsql_module.le_lofp);
- return_value->type = IS_LONG;
- }
- }
- } else {
- efree(pgsql_lofp);
- php_error(E_WARNING,"Unable to open PostgresSQL large object");
- RETURN_FALSE;
- }
- } else {
- pgsql_lofp->conn = pgsql;
- pgsql_lofp->lofd = pgsql_lofd;
- return_value->value.lval = php3_list_insert(pgsql_lofp, php3_pgsql_module.le_lofp);
- return_value->type = IS_LONG;
- }
-}
-/* }}} */
-
-/* {{{ proto void pg_loclose(int fd)
- Close a large object */
-PHP_FUNCTION(pgsql_lo_close)
-{
- pval *pgsql_lofp;
- int id, type;
- pgLofp *pgsql;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &pgsql_lofp)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(pgsql_lofp);
- id = pgsql_lofp->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- pgsql = (pgLofp *) php3_list_find(id,&type);
- if (type!=php3_pgsql_module.le_lofp) {
- php_error(E_WARNING,"%d is not a PostgresSQL large object index",id);
- RETURN_FALSE;
- }
-
- if (lo_close((PGconn *)pgsql->conn, pgsql->lofd)<0) {
- php_error(E_WARNING,"Unable to close PostgresSQL large object descriptor %d", pgsql->lofd);
- RETVAL_FALSE;
- } else {
- RETVAL_TRUE;
- }
- php3_list_delete(id);
- return;
-}
-/* }}} */
-
-/* {{{ proto string pg_loread(int fd, int len)
- Read a large object */
-PHP_FUNCTION(pgsql_lo_read)
-{
- pval *pgsql_id, *len;
- int id, buf_len, type, nbytes;
- char *buf;
- pgLofp *pgsql;
-
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &pgsql_id, &len)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(pgsql_id);
- id = pgsql_id->value.lval;
- convert_to_long(len);
- buf_len = len->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- pgsql = (pgLofp *) php3_list_find(id,&type);
- if (type!=php3_pgsql_module.le_lofp) {
- php_error(E_WARNING,"%d is not a PostgresSQL large object index",id);
- RETURN_FALSE;
- }
-
- buf = (char *) emalloc(sizeof(char)*(buf_len+1));
- if ((nbytes = lo_read((PGconn *)pgsql->conn, pgsql->lofd, buf, buf_len))<0) {
- efree(buf);
- RETURN_FALSE;
- }
- return_value->value.str.val = buf;
- return_value->value.str.len = nbytes;
- return_value->value.str.val[nbytes] = 0;
- return_value->type = IS_STRING;
-}
-/* }}} */
-
-/* {{{ proto int pg_lowrite(int fd, string buf)
- Write a large object */
-PHP_FUNCTION(pgsql_lo_write)
-{
- pval *pgsql_id, *str;
- int id, buf_len, nbytes, type;
- char *buf;
- pgLofp *pgsql;
-
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &pgsql_id, &str)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(pgsql_id);
- id = pgsql_id->value.lval;
- convert_to_string(str);
- buf = str->value.str.val;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- pgsql = (pgLofp *) php3_list_find(id,&type);
- if (type!=php3_pgsql_module.le_lofp) {
- php_error(E_WARNING,"%d is not a PostgresSQL large object index",id);
- RETURN_FALSE;
- }
-
- buf_len = str->value.str.len;
- if ((nbytes = lo_write((PGconn *)pgsql->conn, pgsql->lofd, buf, buf_len))==-1) {
- RETURN_FALSE;
- }
- return_value->value.lval = nbytes;
- return_value->type = IS_LONG;
-}
-/* }}} */
-
-/* {{{ proto void pg_loreadall(int fd)
- Read a large object and send straight to browser */
-PHP_FUNCTION(pgsql_lo_readall)
-{
- pval *pgsql_id;
- int i, id, tbytes, type;
- volatile int nbytes;
- char buf[8192];
- pgLofp *pgsql;
- int output=1;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &pgsql_id)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(pgsql_id);
- id = pgsql_id->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- pgsql = (pgLofp *) php3_list_find(id,&type);
- if (type!=php3_pgsql_module.le_lofp) {
- php_error(E_WARNING,"%d is not a PostgresSQL large object index",id);
- RETURN_FALSE;
- }
-
- tbytes = 0;
- while ((nbytes = lo_read((PGconn *)pgsql->conn, pgsql->lofd, buf, 8192))>0) {
- for(i=0; i<nbytes; i++) {
- if (output) { (void) PUTC(buf[i]); }
- }
- tbytes += i;
- }
- return_value->value.lval = tbytes;
- return_value->type = IS_LONG;
-}
-/* }}} */
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/pgsql/php3_pgsql.h b/ext/pgsql/php3_pgsql.h
deleted file mode 100644
index c996969f2b..0000000000
--- a/ext/pgsql/php3_pgsql.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Jouni Ahto |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _PHP3_PGSQL_H
-#define _PHP3_PGSQL_H
-
-#if COMPILE_DL
-#undef HAVE_PGSQL
-#define HAVE_PGSQL 1
-#endif
-
-#if HAVE_PGSQL
-
-extern php3_module_entry pgsql_module_entry;
-#define pgsql_module_ptr &pgsql_module_entry
-
-
-#include <libpq-fe.h>
-#include <libpq/libpq-fs.h>
-
-extern int php3_minit_pgsql(INIT_FUNC_ARGS);
-extern int php3_rinit_pgsql(INIT_FUNC_ARGS);
-PHP_FUNCTION(pgsql_connect);
-PHP_FUNCTION(pgsql_pconnect);
-PHP_FUNCTION(pgsql_close);
-PHP_FUNCTION(pgsql_dbname);
-PHP_FUNCTION(pgsql_error_message);
-PHP_FUNCTION(pgsql_options);
-PHP_FUNCTION(pgsql_port);
-PHP_FUNCTION(pgsql_tty);
-PHP_FUNCTION(pgsql_host);
-PHP_FUNCTION(pgsql_exec);
-PHP_FUNCTION(pgsql_num_rows);
-PHP_FUNCTION(pgsql_num_fields);
-PHP_FUNCTION(pgsql_cmdtuples);
-PHP_FUNCTION(pgsql_field_name);
-PHP_FUNCTION(pgsql_field_size);
-PHP_FUNCTION(pgsql_field_type);
-PHP_FUNCTION(pgsql_field_number);
-PHP_FUNCTION(pgsql_result);
-PHP_FUNCTION(pgsql_fetch_row);
-PHP_FUNCTION(pgsql_fetch_array);
-PHP_FUNCTION(pgsql_fetch_object);
-PHP_FUNCTION(pgsql_data_length);
-PHP_FUNCTION(pgsql_data_isnull);
-PHP_FUNCTION(pgsql_free_result);
-PHP_FUNCTION(pgsql_last_oid);
-PHP_FUNCTION(pgsql_lo_create);
-PHP_FUNCTION(pgsql_lo_unlink);
-PHP_FUNCTION(pgsql_lo_open);
-PHP_FUNCTION(pgsql_lo_close);
-PHP_FUNCTION(pgsql_lo_read);
-PHP_FUNCTION(pgsql_lo_write);
-PHP_FUNCTION(pgsql_lo_readall);
-
-void php3_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent);
-int php3_pgsql_get_default_link(INTERNAL_FUNCTION_PARAMETERS);
-void php3_pgsql_get_link_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type);
-void php3_pgsql_get_result_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type);
-char *get_field_name(PGconn *pgsql, Oid oid, HashTable *list);
-void php3_pgsql_get_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type);
-void php3_pgsql_data_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type);
-
-
-typedef struct pgLofp {
- PGconn *conn;
- int lofd;
-} pgLofp;
-
-typedef struct _php3_pgsql_result_handle {
- PGconn *conn;
- PGresult *result;
-} pgsql_result_handle;
-
-typedef struct {
- long default_link;
- long num_links,num_persistent;
- long max_links,max_persistent;
- long allow_persistent;
- int le_link,le_plink,le_result,le_lofp,le_string;
-} pgsql_module;
-
-extern pgsql_module php3_pgsql_module;
-
-#else
-
-#define pgsql_module_ptr NULL
-
-#endif
-
-#define phpext_pgsql_ptr pgsql_module_ptr
-
-#endif /* _PHP3_PGSQL_H */
diff --git a/ext/pgsql/setup.stub b/ext/pgsql/setup.stub
deleted file mode 100644
index e4019461bc..0000000000
--- a/ext/pgsql/setup.stub
+++ /dev/null
@@ -1,8 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-pgsql 'PostgreSQL support?' yesnodir \
- 'no /usr/local/pgsql PostgreSQL base install' \
-' Whether to build PHP with PostgreSQL support.\n
- More info about PostgreSQL can be found at\n
- http://www.postgreSQL.org/.'
diff --git a/ext/rpc/com/COM.c b/ext/rpc/com/COM.c
deleted file mode 100644
index 9fc392a697..0000000000
--- a/ext/rpc/com/COM.c
+++ /dev/null
@@ -1,949 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-
-/*
- * This module implements support for COM components that support the IDispatch
- * interface. Both local (COM) and remote (DCOM) components can be accessed.
- *
- * Type libraries can be loaded (in order for PHP to recognize automation constants)
- * by specifying a typelib_file in the PHP .ini file. That file should contain
- * paths to type libraries, one in every line. By default, constants are registered
- * as case-sensitive. If you want them to be defined as case-insensitive, add
- * #case_insensitive or #cis at the end of the type library path.
- *
- * This is also the first module to demonstrate Zend's OO syntax overloading
- * capabilities. CORBA coders are invited to write a CORBA module as well!
- *
- * Zeev
- */
-
-#if WIN32|WINNT
-
-#define _WIN32_DCOM
-
-#include "php.h"
-#include "php3_COM.h"
-#include "zend_compile.h"
-#include "php_ini.h"
-
-#include "objbase.h"
-#include "olestd.h"
-#include <ctype.h>
-
-
-static int le_idispatch;
-
-function_entry COM_functions[] = {
- PHP_FE(COM_load, NULL)
- PHP_FE(COM_invoke, NULL)
-
- PHP_FE(com_propget, NULL)
- PHP_FE(com_propput, NULL)
-
- PHP_FALIAS(com_get, com_propget, NULL)
- PHP_FALIAS(com_propset, com_propput, NULL)
- PHP_FALIAS(com_set, com_propput, NULL)
-
- {NULL, NULL, NULL}
-};
-
-
-static PHP_MINFO_FUNCTION(COM)
-{
- DISPLAY_INI_ENTRIES();
-}
-
-
-php3_module_entry COM_module_entry = {
- "Win32 COM", COM_functions, PHP_MINIT(COM), PHP_MSHUTDOWN(COM), NULL, NULL, PHP_MINFO(COM), STANDARD_MODULE_PROPERTIES
-};
-
-void php_register_COM_class();
-
-static int php_COM_load_typelib(char *typelib_name, int mode);
-
-static char *_php3_COM_error_message(HRESULT hr)
-{
- void *pMsgBuf;
-
- if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL,
- hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &pMsgBuf, 0, NULL)) {
- char error_string[] = "No description available";
-
- pMsgBuf = LocalAlloc(LMEM_FIXED, sizeof(error_string));
- memcpy(pMsgBuf, error_string, sizeof(error_string));
- }
-
- return pMsgBuf;
-}
-
-
-static OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen)
-{
- OLECHAR *unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR)*(strlen+1));
- OLECHAR *unicode_ptr = unicode_str;
-
- while (*C_str) {
- *unicode_ptr++ = (unsigned short) *C_str++;
- }
- *unicode_ptr = 0;
-
- return unicode_str;
-}
-
-
-char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int persistent)
-{
- uint length = OLESTRLEN(unicode_str);
- char *C_str = (char *) pemalloc(length+1, persistent), *p = C_str;
-
- while (*unicode_str) {
- *p++ = (char) *unicode_str++;
- }
- *p = 0;
-
- if (out_length) {
- *out_length = length;
- }
-
- return C_str;
-}
-
-
-static char *_php3_string_from_clsid(CLSID *clsid)
-{
- LPOLESTR ole_clsid;
- char *clsid_str;
-
- StringFromCLSID(clsid, &ole_clsid);
- //s_clsid = OLE2A(ole_clsid);
- clsid_str = php_OLECHAR_to_char(ole_clsid, NULL, 0);
- LocalFree(ole_clsid);
-
- return clsid_str;
-}
-
-
-static void _php3_idispatch_destructor(IDispatch *i_dispatch)
-{
- i_dispatch->lpVtbl->Release(i_dispatch);
-}
-
-
-static PHP_INI_MH(OnTypelibFileChange)
-{
- FILE *typelib_file;
- char *typelib_name_buffer;
-#if SUPPORT_INTERACTIVE
- int interactive;
- ELS_FETCH();
-
- interactive = EG(interactive);
-#endif
-
-
- if (!new_value || (typelib_file=fopen(new_value, "r"))==NULL) {
- return FAILURE;
- }
-
-#if SUPPORT_INTERACTIVE
- if (interactive) {
- printf("Loading type libraries...");
- fflush(stdout);
- }
-#endif
-
- typelib_name_buffer = (char *) malloc(sizeof(char)*1024);
-
- while (fgets(typelib_name_buffer, 1024, typelib_file)) {
- char *typelib_name;
- char *modifier;
- int mode = CONST_PERSISTENT|CONST_CS;
-
- if (typelib_name_buffer[0]==';') {
- continue;
- }
- typelib_name = strtok(typelib_name_buffer, "\r\n"); /* get rid of newlines */
- typelib_name = strtok(typelib_name, "#");
- modifier = strtok(NULL, "#");
- if (modifier) {
- if (!strcmp(modifier, "cis") || !strcmp(modifier, "case_insensitive")) {
- mode &= ~CONST_CS;
- }
- }
-#if SUPPORT_INTERACTIVE
- if (interactive) {
- printf("\rLoading %-60s\r", typelib_name);
- }
-#endif
- php_COM_load_typelib(typelib_name, mode);
- }
-
- free(typelib_name_buffer);
- fclose(typelib_file);
-
-#if SUPPORT_INTERACTIVE
- if (interactive) {
- printf("\r%70s\r", "");
- }
-#endif
-
- return SUCCESS;
-}
-
-
-PHP_INI_BEGIN()
- PHP_INI_ENTRY1_EX("allow_dcom", "0", PHP_INI_SYSTEM, NULL, NULL, php_ini_boolean_displayer_cb)
- PHP_INI_ENTRY1("typelib_file", NULL, PHP_INI_SYSTEM, OnTypelibFileChange, NULL)
-PHP_INI_END()
-
-
-PHP_MINIT_FUNCTION(COM)
-{
- CoInitialize(NULL);
- le_idispatch = register_list_destructors(_php3_idispatch_destructor,NULL);
- php_register_COM_class();
- REGISTER_INI_ENTRIES();
- return SUCCESS;
-}
-
-
-PHP_MSHUTDOWN_FUNCTION(COM)
-{
- CoUninitialize();
- UNREGISTER_INI_ENTRIES();
- return SUCCESS;
-}
-
-
-PHP_FUNCTION(COM_load)
-{
- pval *module_name, *server_name=NULL;
- CLSID clsid;
- HRESULT hr;
- OLECHAR *ProgID;
- IDispatch FAR *i_dispatch = NULL;
- char *error_message;
- char *clsid_str;
-
- switch (ARG_COUNT(ht)) {
- case 1:
- getParameters(ht, 1, &module_name);
- break;
- case 2:
- if (!INI_INT("allow_dcom")) {
- php_error(E_WARNING, "DCOM is disabled");
- RETURN_FALSE;
- }
- getParameters(ht, 2, &module_name, &server_name);
- convert_to_string(server_name);
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- convert_to_string(module_name);
- ProgID = php_char_to_OLECHAR(module_name->value.str.val, module_name->value.str.len);
- hr=CLSIDFromProgID(ProgID, &clsid);
- efree(ProgID);
-
- // obtain CLSID
- if (FAILED(hr)) {
- error_message = _php3_COM_error_message(hr);
- php_error(E_WARNING,"Invalid ProgID: %s\n", error_message);
- LocalFree(error_message);
- RETURN_FALSE;
- }
-
- // obtain IDispatch
- if (!server_name) {
- hr=CoCreateInstance(&clsid, NULL, CLSCTX_SERVER, &IID_IDispatch, (void **) &i_dispatch);
- } else {
- COSERVERINFO server_info;
- MULTI_QI pResults;
-
- server_info.dwReserved1=0;
- server_info.dwReserved2=0;
- server_info.pwszName = php_char_to_OLECHAR(server_name->value.str.val, server_name->value.str.len);
- server_info.pAuthInfo=NULL;
-
- pResults.pIID = &IID_IDispatch;
- pResults.pItf = NULL;
- pResults.hr = S_OK;
- hr=CoCreateInstanceEx(&clsid, NULL, CLSCTX_SERVER, &server_info, 1, &pResults);
- if (SUCCEEDED(hr)) {
- hr = pResults.hr;
- i_dispatch = (IDispatch *) pResults.pItf;
- }
- efree(server_info.pwszName);
- }
- if (FAILED(hr)) {
- error_message = _php3_COM_error_message(hr);
- clsid_str = _php3_string_from_clsid(&clsid);
- php_error(E_WARNING,"Unable to obtain IDispatch interface for CLSID %s: %s",clsid_str,error_message);
- LocalFree(error_message);
- efree(clsid_str);
- RETURN_FALSE;
- }
-
- RETURN_LONG(php3_list_insert(i_dispatch,le_idispatch));
-}
-
-
-static void php_variant_to_pval(VARIANTARG *var_arg, pval *pval_arg, int persistent)
-{
- switch (var_arg->vt) {
- case VT_EMPTY:
- var_uninit(pval_arg);
- break;
- case VT_UI1:
- pval_arg->value.lval = (long) var_arg->bVal;
- pval_arg->type = IS_LONG;
- break;
- case VT_I2:
- pval_arg->value.lval = (long) var_arg->iVal;
- pval_arg->type = IS_LONG;
- break;
- case VT_I4:
- pval_arg->value.lval = var_arg->lVal;
- pval_arg->type = IS_LONG;
- break;
- case VT_R4:
- pval_arg->value.dval = (double) var_arg->fltVal;
- pval_arg->type = IS_DOUBLE;
- break;
- case VT_R8:
- pval_arg->value.dval = var_arg->dblVal;
- pval_arg->type = IS_DOUBLE;
- break;
- case VT_BOOL:
-
- if (var_arg->boolVal & 0xFFFF) {
- pval_arg->value.lval = 1;
- } else {
-
- pval_arg->value.lval = 0;
- }
-
- pval_arg->type = IS_BOOL;
- break;
- case VT_BSTR:
- pval_arg->value.str.val = php_OLECHAR_to_char(var_arg->bstrVal, &pval_arg->value.str.len, persistent);
- pval_arg->type = IS_STRING;
- break;
- case VT_UNKNOWN:
- case VT_DISPATCH:
- /* possibly, return IDispatch as a new COM object. right now - just get rid of it */
- var_arg->pdispVal->lpVtbl->Release(var_arg->pdispVal);
- var_reset(pval_arg);
- break;
- default:
- php_error(E_WARNING,"Unsupported variant type");
- var_reset(pval_arg);
- break;
- }
-}
-
-
-static void _php3_pval_to_variant(pval *pval_arg, VARIANTARG *var_arg)
-{
- OLECHAR *unicode_str;
-
- switch (pval_arg->type) {
- case IS_OBJECT:
- case IS_ARRAY:
- var_arg->vt = VT_EMPTY;
- break;
- case IS_LONG:
- case IS_BOOL:
- var_arg->vt = VT_I4; // assuming 32-bit platform
- var_arg->lVal = pval_arg->value.lval;
- break;
- case IS_DOUBLE:
- var_arg->vt = VT_R8; // assuming 64-bit double precision
- var_arg->dblVal = pval_arg->value.dval;
- break;
- case IS_STRING:
- unicode_str = php_char_to_OLECHAR(pval_arg->value.str.val, pval_arg->value.str.len);
- var_arg->bstrVal = SysAllocString(unicode_str);
- var_arg->vt = VT_BSTR;
- efree(unicode_str);
- break;
- }
-}
-
-
-
-int do_COM_invoke(IDispatch *i_dispatch, pval *function_name, VARIANTARG *var_result, pval **arguments, int arg_count)
-{
- DISPID dispid;
- HRESULT hr;
- OLECHAR *funcname;
- char *error_message;
- VARIANTARG *variant_args;
- int current_arg, current_variant;
- DISPPARAMS dispparams;
-
- funcname = php_char_to_OLECHAR(function_name->value.str.val, function_name->value.str.len);
-
- hr = i_dispatch->lpVtbl->GetIDsOfNames(i_dispatch, &IID_NULL, &funcname,
- 1, LOCALE_SYSTEM_DEFAULT, &dispid);
-
- if (FAILED(hr)) {
- error_message = _php3_COM_error_message(hr);
- php_error(E_WARNING,"Unable to lookup %s: %s\n", function_name->value.str.val, error_message);
- LocalFree(error_message);
- efree(funcname);
- return FAILURE;
- }
-
- variant_args = (VARIANTARG *) emalloc(sizeof(VARIANTARG)*arg_count);
-
- for (current_arg=0; current_arg<arg_count; current_arg++) {
- current_variant = arg_count - current_arg - 1;
- _php3_pval_to_variant(arguments[current_arg], &variant_args[current_variant]);
- }
-
-
- dispparams.rgvarg = variant_args;
- dispparams.rgdispidNamedArgs = NULL;
- dispparams.cArgs = arg_count;
- dispparams.cNamedArgs = 0;
-
- hr = i_dispatch->lpVtbl->Invoke(i_dispatch, dispid, &IID_NULL,
- LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD,
- &dispparams, var_result, NULL, 0);
-
- if (FAILED(hr)) {
- error_message = _php3_COM_error_message(hr);
- php_error(E_WARNING,"Invoke() failed: %s\n", error_message);
- LocalFree(error_message);
- efree(funcname);
- efree(variant_args);
- return FAILURE;
- }
-
- efree(variant_args);
- efree(funcname);
- return SUCCESS;
-}
-
-
-PHP_FUNCTION(COM_invoke)
-{
- pval **arguments;
- pval *object, *function_name;
- IDispatch *i_dispatch;
- int type;
- int arg_count = ARG_COUNT(ht);
- VARIANTARG var_result;
-
- if (arg_count<2) {
- WRONG_PARAM_COUNT;
- }
- arguments = (pval **) emalloc(sizeof(pval *)*arg_count);
- if (getParametersArray(ht, arg_count, arguments)==FAILURE) {
- RETURN_FALSE;
- }
-
- object = arguments[0];
- function_name = arguments[1];
-
- /* obtain i_dispatch interface */
- convert_to_long(object);
- i_dispatch = php3_list_find(object->value.lval, &type);
- if (!i_dispatch || (type!=le_idispatch)) {
- php_error(E_WARNING,"%d is not a COM object handler", function_name->value.str.val);
- RETURN_FALSE;
- }
-
- /* obtain property/method handler */
- convert_to_string(function_name);
-
- if (do_COM_invoke(i_dispatch, function_name, &var_result, arguments+2, arg_count-2)==FAILURE) {
- RETURN_FALSE;
- }
- efree(arguments);
-
- php_variant_to_pval(&var_result, return_value, 0);
-}
-
-
-
-static int do_COM_offget(VARIANTARG *var_result, VARIANTARG *array, pval *arg_property, int cleanup)
-{
- switch (array->vt) {
- case VT_DISPATCH: { /* a Collection, possibly */
- pval function_name;
- IDispatch *i_dispatch = array->pdispVal;
- int retval;
-
- function_name.value.str.val = "Item";
- function_name.value.str.len = 4;
- function_name.type = IS_STRING;
- retval = do_COM_invoke(i_dispatch, &function_name, var_result, &arg_property, 1);
- if (cleanup) {
- i_dispatch->lpVtbl->Release(i_dispatch);
- }
- return retval;
- }
- }
- return FAILURE;
-}
-
-
-static int do_COM_propget(VARIANTARG *var_result, IDispatch *i_dispatch, pval *arg_property, int cleanup)
-{
- DISPID dispid;
- HRESULT hr;
- OLECHAR *propname;
- char *error_message;
- DISPPARAMS dispparams;
-
-
- /* obtain property handler */
- propname = php_char_to_OLECHAR(arg_property->value.str.val, arg_property->value.str.len);
-
- hr = i_dispatch->lpVtbl->GetIDsOfNames(i_dispatch, &IID_NULL, &propname,
- 1, LOCALE_SYSTEM_DEFAULT, &dispid);
-
- if (FAILED(hr)) {
- error_message = _php3_COM_error_message(hr);
- php_error(E_WARNING,"Unable to lookup %s: %s\n", arg_property->value.str.val, error_message);
- LocalFree(error_message);
- efree(propname);
- if (cleanup) {
- i_dispatch->lpVtbl->Release(i_dispatch);
- }
- return FAILURE;
- }
-
- dispparams.cArgs = 0;
- dispparams.cNamedArgs = 0;
-
- hr = i_dispatch->lpVtbl->Invoke(i_dispatch, dispid, &IID_NULL,
- LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET,
- &dispparams, var_result, NULL, 0);
-
- if (FAILED(hr)) {
- error_message = _php3_COM_error_message(hr);
- php_error(E_WARNING,"PropGet() failed: %s\n", error_message);
- LocalFree(error_message);
- efree(propname);
- if (cleanup) {
- i_dispatch->lpVtbl->Release(i_dispatch);
- }
- return FAILURE;
- }
-
- efree(propname);
- if (cleanup) {
- i_dispatch->lpVtbl->Release(i_dispatch);
- }
- return SUCCESS;
-}
-
-
-
-static void do_COM_propput(pval *return_value, IDispatch *i_dispatch, pval *arg_property, pval *value)
-{
- DISPID dispid;
- HRESULT hr;
- OLECHAR *propname;
- char *error_message;
- VARIANTARG var_result;
- DISPPARAMS dispparams;
- VARIANTARG new_value;
- DISPID mydispid = DISPID_PROPERTYPUT;
-
-
- /* obtain property handler */
- propname = php_char_to_OLECHAR(arg_property->value.str.val, arg_property->value.str.len);
-
- hr = i_dispatch->lpVtbl->GetIDsOfNames(i_dispatch, &IID_NULL, &propname,
- 1, LOCALE_SYSTEM_DEFAULT, &dispid);
-
- if (FAILED(hr)) {
- error_message = _php3_COM_error_message(hr);
- php_error(E_WARNING,"Unable to lookup %s: %s\n", arg_property->value.str.val, error_message);
- LocalFree(error_message);
- efree(propname);
- RETURN_FALSE;
- }
-
-
- _php3_pval_to_variant(value, &new_value);
- dispparams.rgvarg = &new_value;
- dispparams.rgdispidNamedArgs = &mydispid;
- dispparams.cArgs = 1;
- dispparams.cNamedArgs = 1;
-
- hr = i_dispatch->lpVtbl->Invoke(i_dispatch, dispid, &IID_NULL,
- LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT,
- &dispparams, NULL, NULL, 0);
-
- dispparams.cArgs = 0;
- dispparams.cNamedArgs = 0;
-
- hr = i_dispatch->lpVtbl->Invoke(i_dispatch, dispid, &IID_NULL,
- LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET,
- &dispparams, &var_result, NULL, 0);
-
- if (FAILED(hr)) {
- error_message = _php3_COM_error_message(hr);
- php_error(E_WARNING,"PropPut() failed: %s\n", error_message);
- LocalFree(error_message);
- efree(propname);
- RETURN_FALSE;
- }
-
- php_variant_to_pval(&var_result, return_value, 0);
-
- efree(propname);
-}
-
-
-PHP_FUNCTION(com_propget)
-{
- pval *arg_idispatch, *arg_property;
- int type;
- IDispatch *i_dispatch;
- VARIANTARG var_result;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &arg_idispatch, &arg_property)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- /* obtain i_dispatch interface */
- convert_to_long(arg_idispatch);
- /* obtain i_dispatch interface */
- i_dispatch = php3_list_find(arg_idispatch->value.lval,&type);
- if (!i_dispatch || (type!=le_idispatch)) {
- php_error(E_WARNING,"%d is not a COM object handler", arg_idispatch->value.lval);
- }
- convert_to_string(arg_property);
-
- if (do_COM_propget(&var_result, i_dispatch, arg_property, 0)==FAILURE) {
- RETURN_FALSE;
- }
- php_variant_to_pval(&var_result, return_value, 0);
-}
-
-
-PHP_FUNCTION(com_propput)
-{
- pval *arg_idispatch, *arg_property, *arg_value;
- int type;
- IDispatch *i_dispatch;
-
- if (ARG_COUNT(ht)!=3 || getParameters(ht, 3, &arg_idispatch, &arg_property, &arg_value)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- /* obtain i_dispatch interface */
- convert_to_long(arg_idispatch);
- /* obtain i_dispatch interface */
- i_dispatch = php3_list_find(arg_idispatch->value.lval,&type);
- if (!i_dispatch || (type!=le_idispatch)) {
- php_error(E_WARNING,"%d is not a COM object handler", arg_idispatch->value.lval);
- }
- convert_to_string(arg_property);
-
- do_COM_propput(return_value, i_dispatch, arg_property, arg_value);
-}
-
-
-VARIANTARG _php_COM_get_property_handler(zend_property_reference *property_reference)
-{
- zend_overloaded_element *overloaded_property;
- zend_llist_element *element;
- pval **idispatch_handle;
- pval *object = property_reference->object;
- IDispatch *i_dispatch;
- int type;
- VARIANTARG var_result;
-
-
- /* fetch the IDispatch interface */
- zend_hash_index_find(object->value.obj.properties, 0, (void **) &idispatch_handle);
- i_dispatch = php3_list_find((*idispatch_handle)->value.lval,&type);
- if (!i_dispatch || (type!=le_idispatch)) {
- /* bail out */
- }
-
- var_result.vt = VT_DISPATCH;
- var_result.pdispVal = i_dispatch;
-
- for (element=property_reference->elements_list.head; element; element=element->next) {
- overloaded_property = (zend_overloaded_element *) element->data;
- switch (overloaded_property->type) {
- case IS_ARRAY:
- if (do_COM_offget(&var_result, &var_result, &overloaded_property->element, element!=property_reference->elements_list.head)==FAILURE) {
- /* bail out */
- }
- /*printf("Array offset: ");*/
- break;
- case IS_OBJECT:
- if (var_result.vt != VT_DISPATCH) {
- /* bail out */
- } else {
- if (do_COM_propget(&var_result, var_result.pdispVal, &overloaded_property->element, element!=property_reference->elements_list.head)==FAILURE) {
- /* bail out */
- }
- /*printf("Object property: ");*/
- }
- break;
- case IS_METHOD:
- return var_result;
- break;
- }
- /*
- switch (overloaded_property->element.type) {
- case IS_LONG:
- printf("%d (numeric)\n", overloaded_property->element.value.lval);
- break;
- case IS_STRING:
- printf("'%s'\n", overloaded_property->element.value.str.val);
- break;
- }
- */
- pval_destructor(&overloaded_property->element);
- }
- return var_result;
-}
-
-
-pval php_COM_get_property_handler(zend_property_reference *property_reference)
-{
- pval result;
- VARIANTARG var_result = _php_COM_get_property_handler(property_reference);
-
- php_variant_to_pval(&var_result, &result, 0);
- return result;
-}
-
-
-int php_COM_set_property_handler(zend_property_reference *property_reference, pval *value)
-{
- pval result;
- zend_overloaded_element *overloaded_property;
- zend_llist_element *element;
- pval **idispatch_handle;
- pval *object = property_reference->object;
- IDispatch *i_dispatch;
- int type;
- VARIANTARG var_result;
-
-
- /* fetch the IDispatch interface */
- zend_hash_index_find(object->value.obj.properties, 0, (void **) &idispatch_handle);
- i_dispatch = php3_list_find((*idispatch_handle)->value.lval,&type);
- if (!i_dispatch || (type!=le_idispatch)) {
- /* bail out */
- }
- var_result.vt = VT_DISPATCH;
- var_result.pdispVal = i_dispatch;
-
- for (element=property_reference->elements_list.head; element && element!=property_reference->elements_list.tail; element=element->next) {
- overloaded_property = (zend_overloaded_element *) element->data;
- switch (overloaded_property->type) {
- case IS_ARRAY:
- /*printf("Array offset: ");*/
- break;
- case IS_OBJECT:
- if (var_result.vt != VT_DISPATCH) {
- /* bail out */
- } else {
- do_COM_propget(&var_result, i_dispatch, &overloaded_property->element, element!=property_reference->elements_list.head);
- /*printf("Object property: ");*/
- }
- break;
- case IS_METHOD:
- /* this shouldn't happen */
- return FAILURE;
- }
- /*
- switch (overloaded_property->element.type) {
- case IS_LONG:
- printf("%d (numeric)\n", overloaded_property->element.value.lval);
- break;
- case IS_STRING:
- printf("'%s'\n", overloaded_property->element.value.str.val);
- break;
- }
- */
- pval_destructor(&overloaded_property->element);
- }
-
- if (var_result.vt != VT_DISPATCH) {
- return FAILURE;
- }
- overloaded_property = (zend_overloaded_element *) element->data;
- do_COM_propput(&result, var_result.pdispVal, &overloaded_property->element, value);
- pval_destructor(&overloaded_property->element);
- return SUCCESS;
-}
-
-
-
-void php_COM_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference)
-{
- zend_overloaded_element *overloaded_property;
- pval *object = property_reference->object;
- zend_overloaded_element *function_name = (zend_overloaded_element *) property_reference->elements_list.tail->data;
-
- if (zend_llist_count(&property_reference->elements_list)==1
- && !strcmp(function_name->element.value.str.val, "com")) { /* constructor */
- pval *object_handle;
-
- PHP_FN(COM_load)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- if (!zend_is_true(return_value)) {
- var_reset(object);
- return;
- }
- object_handle = (pval *) emalloc(sizeof(pval));
- *object_handle = *return_value;
- pval_copy_constructor(object_handle);
- INIT_PZVAL(object_handle);
- zend_hash_index_update(object->value.obj.properties, 0, &object_handle, sizeof(pval *), NULL);
- pval_destructor(&function_name->element);
- } else {
- VARIANTARG object_handle = _php_COM_get_property_handler(property_reference);
- pval **arguments;
- int arg_count = ARG_COUNT(ht);
- VARIANTARG var_result;
-
- if (object_handle.vt != VT_DISPATCH) {
- /* that shouldn't happen */
- return;
- }
- arguments = (pval **) emalloc(sizeof(pval *)*arg_count);
- getParametersArray(ht, arg_count, arguments);
-
- if (do_COM_invoke((IDispatch *) object_handle.pdispVal, &function_name->element, &var_result, arguments, arg_count)==FAILURE) {
- RETVAL_FALSE;
- }
- pval_destructor(&function_name->element);
- efree(arguments);
- php_variant_to_pval(&var_result, return_value, 0);
- }
-
- for (overloaded_property = (zend_overloaded_element *) zend_llist_get_first(&property_reference->elements_list);
- overloaded_property;
- overloaded_property = (zend_overloaded_element *) zend_llist_get_next(&property_reference->elements_list)) {
- switch (overloaded_property->type) {
- case IS_ARRAY:
- break;
- case IS_OBJECT:
- break;
- case IS_METHOD:
-
- break;
- }
- }
-}
-
-
-void php_register_COM_class()
-{
- zend_class_entry com_class_entry;
-
- INIT_OVERLOADED_CLASS_ENTRY(com_class_entry, "COM", NULL,
- php_COM_call_function_handler,
- php_COM_get_property_handler,
- php_COM_set_property_handler);
-
- register_internal_class(&com_class_entry);
-}
-
-
-static int php_COM_load_typelib(char *typelib_name, int mode)
-{
- ITypeLib *TypeLib;
- ITypeComp *TypeComp;
- OLECHAR *p;
- int i;
- int interfaces;
- ELS_FETCH();
-
- p = php_char_to_OLECHAR(typelib_name, strlen(typelib_name));
-
- if (FAILED(LoadTypeLib(p, &TypeLib))) {
- efree(p);
- return FAILURE;
- }
-
- interfaces = TypeLib->lpVtbl->GetTypeInfoCount(TypeLib);
-
- TypeLib->lpVtbl->GetTypeComp(TypeLib, &TypeComp);
- for (i=0; i<interfaces; i++) {
- TYPEKIND pTKind;
-
- TypeLib->lpVtbl->GetTypeInfoType(TypeLib, i, &pTKind);
- if (pTKind==TKIND_ENUM) {
- ITypeInfo *TypeInfo;
- VARDESC *pVarDesc;
- UINT NameCount;
- int j;
-#if 0
- BSTR bstr_EnumId;
- char *EnumId;
-
- TypeLib->lpVtbl->GetDocumentation(TypeLib, i, &bstr_EnumId, NULL, NULL, NULL);
- EnumId = php_OLECHAR_to_char(bstr_EnumId, NULL, 0);
- printf("Enumeration %d - %s:\n", i, EnumId);
- efree(EnumId);
-#endif
-
- TypeLib->lpVtbl->GetTypeInfo(TypeLib, i, &TypeInfo);
-
- j=0;
- while (TypeInfo->lpVtbl->GetVarDesc(TypeInfo, j, &pVarDesc)==S_OK) {
- BSTR bstr_ids;
- char *ids;
- zend_constant c;
-
- TypeInfo->lpVtbl->GetNames(TypeInfo, pVarDesc->memid, &bstr_ids, 1, &NameCount);
- if (NameCount!=1) {
- j++;
- continue;
- }
- LocalFree(bstr_ids);
- ids = php_OLECHAR_to_char(bstr_ids, NULL, 1);
- c.name_len = strlen(ids)+1;
- c.name = ids;
- php_variant_to_pval(pVarDesc->lpvarValue, &c.value, 1);
- c.flags = mode;
-
- zend_register_constant(&c ELS_CC);
- //printf("%s -> %ld\n", ids, pVarDesc->lpvarValue->lVal);
- j++;
- }
- TypeInfo->lpVtbl->Release(TypeInfo);
- }
- }
-
-
- TypeLib->lpVtbl->Release(TypeLib);
- efree(p);
- return SUCCESS;
-}
-
-#endif
diff --git a/ext/rpc/com/php3_COM.h b/ext/rpc/com/php3_COM.h
deleted file mode 100644
index 60b7e06e97..0000000000
--- a/ext/rpc/com/php3_COM.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef _PHP3_COM_H
-#define _PHP3_COM_H
-
-#if WIN32|WINNT
-
-extern PHP_MINIT_FUNCTION(COM);
-extern PHP_MSHUTDOWN_FUNCTION(COM);
-PHP_FUNCTION(COM_load);
-PHP_FUNCTION(COM_invoke);
-
-PHP_FUNCTION(com_propget);
-PHP_FUNCTION(com_propput);
-extern php3_module_entry COM_module_entry;
-#define COM_module_ptr &COM_module_entry
-
-#else
-
-#define COM_module_ptr NULL
-
-#endif /* Win32|WINNT */
-
-#define phpext_COM_ptr COM_module_ptr
-
-#endif /* _PHP3_COM_H */
diff --git a/ext/session/Makefile.am b/ext/session/Makefile.am
deleted file mode 100644
index b9fd66bd67..0000000000
--- a/ext/session/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_session.a
-libphpext_session_a_SOURCES=session.c mod_files.c mod_mm.c mod_user.c
-
diff --git a/ext/session/config.h.stub b/ext/session/config.h.stub
deleted file mode 100644
index 24abf8b280..0000000000
--- a/ext/session/config.h.stub
+++ /dev/null
@@ -1,4 +0,0 @@
-/* define if you want to use the session extension */
-
-#undef TRANS_SID
-#undef HAVE_LIBMM
diff --git a/ext/session/config.m4 b/ext/session/config.m4
deleted file mode 100644
index 8db20b3324..0000000000
--- a/ext/session/config.m4
+++ /dev/null
@@ -1,42 +0,0 @@
-dnl $Id$
-dnl config.m4 for extension session
-dnl don't forget to call PHP_EXTENSION(session)
-
-RESULT=no
-AC_MSG_CHECKING(for mm support)
-AC_ARG_WITH(mm,
-[ --with-mm[=DIR] Include mm support],
-[
- if test "$withval" != "no"; then
- for i in /usr/local /usr $withval; do
- if test -f "$i/include/mm.h"; then
- MM_DIR="$i"
- fi
- done
-
- if test -z "$MM_DIR" ; then
- AC_MSG_ERROR(cannot find mm library)
- fi
-
- AC_ADD_LIBRARY_WITH_PATH(mm, $MM_DIR/lib)
- AC_ADD_INCLUDE($MM_DIR/include)
- AC_DEFINE(HAVE_LIBMM, 1)
- RESULT=yes
- PHP_EXTENSION(ps_mm)
- fi
-])
-AC_MSG_RESULT($RESULT)
-
-RESULT=no
-AC_MSG_CHECKING(whether to enable transparent session id propagation)
-AC_ARG_ENABLE(trans-sid,
-[ --enable-trans-sid Enable transparent session id propagation],
-[
- if test "$enableval" = "yes" ; then
- AC_DEFINE(TRANS_SID, 1)
- RESULT=yes
- fi
-])
-AC_MSG_RESULT($RESULT)
-
-PHP_EXTENSION(session)
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c
deleted file mode 100644
index 5fa71295b7..0000000000
--- a/ext/session/mod_files.c
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <ss@2ns.de> |
- +----------------------------------------------------------------------+
- */
-
-
-#include "php.h"
-
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-
-#if HAVE_DIRENT_H
-#include <dirent.h>
-#endif
-
-#if WIN32||WINNT
-#define NEEDRDH 1
-#include "win32/readdir.h"
-#endif
-#include <time.h>
-
-#include <fcntl.h>
-
-#include "php_session.h"
-#include "mod_files.h"
-#include "ext/standard/flock_compat.h"
-
-#define FILE_PREFIX "sess_"
-
-typedef struct {
- int fd;
- char *lastkey;
- char *basedir;
- int dirdepth;
-} ps_files;
-
-ps_module ps_mod_files = {
- PS_MOD(files)
-};
-
-#if WIN32|WINNT
-#define DIR_DELIMITER '\\'
-#else
-#define DIR_DELIMITER '/'
-#endif
-
-static char *_ps_files_path_create(char *buf, size_t buflen, ps_files *data, const char *key)
-{
- int keylen;
- const char *p;
- int i;
- int n;
-
- keylen = strlen(key);
- if(keylen <= data->dirdepth || buflen <
- (strlen(data->basedir) + 2 * data->dirdepth + keylen + 5 + sizeof(FILE_PREFIX)))
- return NULL;
- p = key;
- n = sprintf(buf, "%s/", data->basedir);
- for(i = 0; i < data->dirdepth; i++) {
- buf[n++] = *p++;
- buf[n++] = DIR_DELIMITER;
- }
- strcat(buf, FILE_PREFIX);
- strcat(buf, p);
-
- return buf;
-}
-
-static void _ps_files_open(ps_files *data, const char *key)
-{
- char buf[MAXPATHLEN];
-
- if(data->fd < 0 || !data->lastkey || strcmp(key, data->lastkey)) {
- if(data->lastkey) {
- efree(data->lastkey);
- data->lastkey = NULL;
- }
- if(data->fd != -1) {
- close(data->fd);
- data->fd = -1;
- }
-
- if(!_ps_files_path_create(buf, sizeof(buf), data, key))
- return;
-
- data->lastkey = estrdup(key);
-
-#ifdef O_EXCL
- /* in the common case, the file already exists */
- data->fd = open(buf, O_EXCL | O_RDWR);
- if(data->fd == -1) {
- /* create it, if necessary */
- data->fd = open(buf, O_EXCL | O_RDWR | O_CREAT, 0600);
- }
-#else
- data->fd = open(buf, O_CREAT | O_RDWR, 0600);
- if(data->fd != -1) {
- flock(data->fd, LOCK_EX);
- }
-#endif
- }
-}
-
-static void _ps_files_cleanup_dir(const char *dirname, int maxlifetime)
-{
- DIR *dir;
- struct dirent *entry;
- struct stat sbuf;
- char buf[MAXPATHLEN];
- time_t now;
-
- dir = opendir(dirname);
- if(!dir) return;
-
- time(&now);
-
- while((entry = readdir(dir))) {
- /* does the file start with our prefix? */
- if(!strncmp(entry->d_name, FILE_PREFIX, sizeof(FILE_PREFIX) - 1) &&
- /* create full path */
- snprintf(buf, MAXPATHLEN, "%s%c%s", dirname, DIR_DELIMITER,
- entry->d_name) > 0 &&
- /* stat the directory entry */
- stat(buf, &sbuf) == 0 &&
- /* is it expired? */
- (now - sbuf.st_atime) > maxlifetime) {
- unlink(buf);
- }
- }
-
- closedir(dir);
-}
-
-#define PS_FILES_DATA ps_files *data = PS_GET_MOD_DATA()
-
-PS_OPEN_FUNC(files)
-{
- ps_files *data;
- char *p;
-
- data = ecalloc(sizeof(*data), 1);
- PS_SET_MOD_DATA(data);
-
- data->fd = -1;
- if((p = strchr(save_path, ':'))) {
- data->dirdepth = strtol(save_path, NULL, 10);
- save_path = p + 1;
- }
- data->basedir = estrdup(save_path);
-
- return SUCCESS;
-}
-
-PS_CLOSE_FUNC(files)
-{
- PS_FILES_DATA;
-
- if(data->fd > -1) close(data->fd);
- if(data->lastkey) efree(data->lastkey);
- efree(data->basedir);
- efree(data);
- *mod_data = NULL;
-
- return SUCCESS;
-}
-
-PS_READ_FUNC(files)
-{
- int n;
- struct stat sbuf;
- PS_FILES_DATA;
-
- _ps_files_open(data, key);
- if(data->fd < 0) {
- return FAILURE;
- }
-
- if(fstat(data->fd, &sbuf)) {
- return FAILURE;
- }
-
- lseek(data->fd, 0, SEEK_SET);
-
- *vallen = sbuf.st_size;
- *val = emalloc(sbuf.st_size);
-
- n = read(data->fd, *val, sbuf.st_size);
- if(n != sbuf.st_size) {
- efree(*val);
- return FAILURE;
- }
-
- return SUCCESS;
-}
-
-PS_WRITE_FUNC(files)
-{
- PS_FILES_DATA;
-
- _ps_files_open(data, key);
- if(data->fd < 0) {
- return FAILURE;
- }
-
- ftruncate(data->fd, 0);
- lseek(data->fd, 0, SEEK_SET);
- write(data->fd, val, vallen);
-
- return SUCCESS;
-}
-
-PS_DESTROY_FUNC(files)
-{
- char buf[MAXPATHLEN];
- PS_FILES_DATA;
-
- if(!_ps_files_path_create(buf, sizeof(buf), data, key))
- return FAILURE;
-
- unlink(buf);
-
- return SUCCESS;
-}
-
-PS_GC_FUNC(files)
-{
- PS_FILES_DATA;
-
- /* we don't perform any cleanup, if dirdepth is larger than 0.
- we return SUCCESS, since all cleanup should be handled by
- an external entity (i.e. find -ctime x | xargs rm) */
-
- if(data->dirdepth > 0) {
- return SUCCESS;
- }
-
- _ps_files_cleanup_dir(data->basedir, maxlifetime);
-
- return SUCCESS;
-}
diff --git a/ext/session/mod_files.h b/ext/session/mod_files.h
deleted file mode 100644
index 9f40704a42..0000000000
--- a/ext/session/mod_files.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <ss@2ns.de> |
- +----------------------------------------------------------------------+
- */
-
-#ifndef MOD_FILES_H
-#define MOD_FILES_H
-
-extern ps_module ps_mod_files;
-#define ps_files_ptr &ps_mod_files
-
-PS_FUNCS(files);
-
-#endif
diff --git a/ext/session/mod_files.sh b/ext/session/mod_files.sh
deleted file mode 100644
index 4d6a681d9c..0000000000
--- a/ext/session/mod_files.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#! /bin/sh
-
-if test "$2" = ""; then
- echo "usage: $0 basedir depth"
- exit 1
-fi
-
-if test "$2" = "0"; then
- exit 0
-fi
-
-for i in a b c d e f 0 1 2 3 4 5 6 7 8 9; do
- newpath="$1/$i"
- mkdir $newpath || exit 1
- sh $0 $newpath `expr $2 - 1`
-done
diff --git a/ext/session/mod_mm.c b/ext/session/mod_mm.c
deleted file mode 100644
index 26f5789350..0000000000
--- a/ext/session/mod_mm.c
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <ss@2ns.de> |
- +----------------------------------------------------------------------+
- */
-
-
-#include "php.h"
-
-#ifdef HAVE_LIBMM
-
-#include <mm.h>
-#include <time.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
-
-#include "php_session.h"
-#include "mod_mm.h"
-
-#define PS_MM_PATH "/tmp/session_mm"
-
-/*
- * this list holds all data associated with one session
- */
-
-typedef struct ps_sd {
- struct ps_sd *next, *prev;
- time_t ctime;
- char *key;
- void *data;
- size_t datalen;
-} ps_sd;
-
-typedef struct {
- MM *mm;
- ps_sd **hash;
-} ps_mm;
-
-static ps_mm *ps_mm_instance = NULL;
-
-/* should be a prime */
-#define HASH_SIZE 577
-
-#if 0
-#define ps_mm_debug(a...) fprintf(stderr, a)
-#else
-#define ps_mm_debug(a...)
-#endif
-
-#define BITS_IN_int (sizeof(int) * CHAR_BIT)
-#define THREE_QUARTERS ((int) ((BITS_IN_int * 3) / 4))
-#define ONE_EIGTH ((int) (BITS_IN_int / 8))
-#define HIGH_BITS (~((unsigned int)(~0) >> ONE_EIGTH))
-
-/*
- * Weinberger's generic hash algorithm, adapted by Holub
- * (published in [Holub 1990])
- */
-
-static unsigned int ps_sd_hash(const char *data)
-{
- unsigned int val, i;
-
- for(val = 0; *data; data++) {
- val = (val << ONE_EIGTH) + *data;
- if((i = val & HIGH_BITS) != 0) {
- val = (val ^ (i >> THREE_QUARTERS)) & -HIGH_BITS;
- }
- }
-
- return val;
-}
-
-
-static ps_sd *ps_sd_new(ps_mm *data, const char *key, const void *sdata, size_t sdatalen)
-{
- unsigned int h;
- ps_sd *sd;
-
- h = ps_sd_hash(key) % HASH_SIZE;
-
- sd = mm_malloc(data->mm, sizeof(*sd));
- if(!sd) {
- return NULL;
- }
- sd->ctime = 0;
-
- sd->data = mm_malloc(data->mm, sdatalen);
- if(!sd->data) {
- mm_free(data->mm, sd);
- return NULL;
- }
-
- sd->datalen = sdatalen;
-
- sd->key = mm_strdup(data->mm, key);
- if(!sd->key) {
- mm_free(data->mm, sd->data);
- mm_free(data->mm, sd);
- return NULL;
- }
-
- memcpy(sd->data, sdata, sdatalen);
-
- if((sd->next = data->hash[h]))
- sd->next->prev = sd;
- sd->prev = NULL;
-
- ps_mm_debug("inserting %s(%x) into %d\n", key, sd, h);
-
- data->hash[h] = sd;
-
- return sd;
-}
-
-static void ps_sd_destroy(ps_mm *data, ps_sd *sd)
-{
- unsigned int h;
-
- h = ps_sd_hash(sd->key) % HASH_SIZE;
-
- if(sd->next)
- sd->next->prev = sd->prev;
- if(sd->prev)
- sd->prev->next = sd->next;
-
- if(data->hash[h] == sd)
- data->hash[h] = sd->next;
-
- mm_free(data->mm, sd->key);
- if(sd->data) mm_free(data->mm, sd->data);
- mm_free(data->mm, sd);
-}
-
-static ps_sd *ps_sd_lookup(ps_mm *data, const char *key, int rw)
-{
- unsigned int h;
- ps_sd *ret;
-
- h = ps_sd_hash(key) % HASH_SIZE;
-
- for(ret = data->hash[h]; ret; ret = ret->next)
- if(!strcmp(ret->key, key)) break;
-
- if(ret && rw && ret != data->hash[h]) {
- data->hash[h]->prev = ret;
- ret->next = data->hash[h];
- data->hash[h] = ret;
- ps_mm_debug("optimizing\n");
- }
-
- ps_mm_debug(stderr, "lookup(%s): ret=%x,h=%d\n", key, ret, h);
-
- return ret;
-}
-
-ps_module ps_mod_mm = {
- PS_MOD(mm)
-};
-
-#define PS_MM_DATA ps_mm *data = PS_GET_MOD_DATA()
-
-static int ps_mm_initialize(ps_mm *data, const char *path)
-{
- data->mm = mm_create(0, path);
-
- data->hash = mm_calloc(data->mm, HASH_SIZE, sizeof(*data->hash));
-
- return SUCCESS;
-}
-
-static void ps_mm_destroy(ps_mm *data)
-{
- int h;
- ps_sd *sd, *next;
-
- for(h = 0; h < HASH_SIZE; h++) {
- for(sd = data->hash[h]; sd; sd = next) {
- next = sd->next;
- ps_sd_destroy(data, sd);
- }
- }
-
- mm_free(data->mm, data->hash);
- mm_destroy(data->mm);
-}
-
-PHP_GINIT_FUNCTION(ps_mm)
-{
- ps_mm_instance = calloc(sizeof(*ps_mm_instance), 1);
- ps_mm_initialize(ps_mm_instance, PS_MM_PATH);
- return SUCCESS;
-}
-
-PHP_GSHUTDOWN_FUNCTION(ps_mm)
-{
- ps_mm_destroy(ps_mm_instance);
- free(ps_mm_instance);
- return SUCCESS;
-}
-
-PS_OPEN_FUNC(mm)
-{
- ps_mm_debug("open: ps_mm_instance=%x\n", ps_mm_instance);
-
- if(!ps_mm_instance) {
- return FAILURE;
- }
-
- PS_SET_MOD_DATA(ps_mm_instance);
-
- return SUCCESS;
-}
-
-PS_CLOSE_FUNC(mm)
-{
- PS_SET_MOD_DATA(NULL);
-
- return SUCCESS;
-}
-
-PS_READ_FUNC(mm)
-{
- PS_MM_DATA;
- ps_sd *sd;
- int ret = FAILURE;
-
- mm_lock(data->mm, MM_LOCK_RD);
-
- sd = ps_sd_lookup(data, key, 0);
- if(sd) {
- *vallen = sd->datalen;
- *val = emalloc(sd->datalen);
- memcpy(*val, sd->data, sd->datalen);
- ret = SUCCESS;
- }
-
- mm_unlock(data->mm);
-
- return ret;
-}
-
-PS_WRITE_FUNC(mm)
-{
- PS_MM_DATA;
- ps_sd *sd;
-
- mm_lock(data->mm, MM_LOCK_RW);
-
- sd = ps_sd_lookup(data, key, 1);
- if(!sd) {
- sd = ps_sd_new(data, key, val, vallen);
- ps_mm_debug(stderr, "new one for %s\n", key);
- } else {
- ps_mm_debug(stderr, "found existing one for %s\n", key);
- mm_free(data->mm, sd->data);
- sd->datalen = vallen;
- sd->data = mm_malloc(data->mm, vallen);
- if(!sd->data) {
- ps_sd_destroy(data, sd);
- sd = NULL;
- } else {
- memcpy(sd->data, val, vallen);
- }
- }
-
- if(sd) time(&sd->ctime);
-
- mm_unlock(data->mm);
-
- return sd ? SUCCESS : FAILURE;
-}
-
-PS_DESTROY_FUNC(mm)
-{
- PS_MM_DATA;
- ps_sd *sd;
-
- mm_lock(data->mm, MM_LOCK_RW);
-
- sd = ps_sd_lookup(data, key, 0);
- if(sd) {
- ps_sd_destroy(data, sd);
- }
-
- mm_unlock(data->mm);
-
- return SUCCESS;
-}
-
-PS_GC_FUNC(mm)
-{
- PS_MM_DATA;
- int h;
- time_t now;
- ps_sd *sd, *next;
-
- ps_mm_debug("gc\n");
-
- mm_lock(data->mm, MM_LOCK_RW);
-
- time(&now);
-
- for(h = 0; h < HASH_SIZE; h++) {
- for(sd = data->hash[h]; sd; sd = next) {
- next = sd->next;
- ps_mm_debug("looking at %s\n", sd->key);
- if((now - sd->ctime) > maxlifetime) {
- ps_sd_destroy(data, sd);
- }
- }
- }
-
- mm_unlock(data->mm);
-
- return SUCCESS;
-}
-
-zend_module_entry php_session_mm_module = {
- "Session MM",
- NULL,
- NULL, NULL,
- NULL, NULL,
- NULL,
- PHP_GINIT(ps_mm), PHP_GSHUTDOWN(ps_mm),
- STANDARD_MODULE_PROPERTIES_EX
-};
-
-#endif
diff --git a/ext/session/mod_mm.h b/ext/session/mod_mm.h
deleted file mode 100644
index 69d9a7d3e1..0000000000
--- a/ext/session/mod_mm.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <ss@2ns.de> |
- +----------------------------------------------------------------------+
- */
-
-#ifndef MOD_MM_H
-#define MOD_MM_H
-
-#ifdef HAVE_LIBMM
-
-#include "php_session.h"
-
-extern ps_module ps_mod_mm;
-#define ps_mm_ptr &ps_mod_mm
-
-extern zend_module_entry php_session_mm_module;
-#define phpext_ps_mm_ptr &php_session_mm_module
-
-PS_FUNCS(mm);
-
-#else
-
-#define ps_mm_ptr NULL
-#define phpext_ps_mm_ptr NULL
-
-#endif
-
-#endif
diff --git a/ext/session/mod_user.c b/ext/session/mod_user.c
deleted file mode 100644
index 62c5c7759a..0000000000
--- a/ext/session/mod_user.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <ss@2ns.de> |
- +----------------------------------------------------------------------+
- */
-
-#include "php.h"
-#include "php_session.h"
-#include "mod_user.h"
-
-ps_module ps_mod_user = {
- PS_MOD(user)
-};
-
-#define ZVAL_LONG(val, a) \
-{ \
- MAKE_STD_ZVAL(a); \
- a->type = IS_LONG; \
- a->value.lval = val; \
-}
-
-#define ZVAL_STRING(vl, a) \
-{ \
- int len = strlen(vl); \
- MAKE_STD_ZVAL(a); \
- a->type = IS_STRING; \
- a->value.str.len = len; \
- a->value.str.val = estrndup(vl, len); \
-}
-
-#define ZVAL_STRINGN(vl, ln, a) \
-{ \
- MAKE_STD_ZVAL(a); \
- a->type = IS_STRING; \
- a->value.str.len = ln; \
- a->value.str.val = estrndup(vl, ln); \
-}
-
-
-static zval *ps_call_handler(char *name, int argc, zval **argv)
-{
- int i;
- zval *retval = NULL;
- ELS_FETCH();
-
- if(name && name[0] != '\0') {
- zval *func;
-
- ZVAL_STRING(name, func);
- MAKE_STD_ZVAL(retval);
-
- if(call_user_function(EG(function_table), NULL, func, retval,
- argc, argv) == FAILURE) {
- zval_dtor(retval);
- efree(retval);
- retval = NULL;
- }
- zval_dtor(func);
- efree(func);
- }
-
- for(i = 0; i < argc; i++) {
- zval_dtor(argv[i]);
- efree(argv[i]);
- }
-
- return retval;
-}
-
-#define STDVARS \
- zval *retval; \
- int ret = FAILURE; \
- ps_user *mdata = PS_GET_MOD_DATA(); \
- if(!mdata) return FAILURE
-
-#define PSF(a) mdata->name.ps_##a
-
-#define FINISH \
- if(retval) { \
- convert_to_long(retval); \
- ret = retval->value.lval; \
- zval_dtor(retval); \
- efree(retval); \
- } \
- return ret
-
-PS_OPEN_FUNC(user)
-{
- zval *args[2];
- STDVARS;
-
- ZVAL_STRING(save_path, args[0]);
- ZVAL_STRING(session_name, args[1]);
-
- retval = ps_call_handler(PSF(open), 2, args);
-
- FINISH;
-}
-
-PS_CLOSE_FUNC(user)
-{
- int i;
- STDVARS;
-
- retval = ps_call_handler(PSF(close), 0, NULL);
-
- for(i = 0; i < 6; i++) {
- efree(mdata->names[i]);
- }
- efree(mdata);
-
- PS_SET_MOD_DATA(NULL);
-
- FINISH;
-}
-
-PS_READ_FUNC(user)
-{
- zval *args[1];
- STDVARS;
-
- ZVAL_STRING(key, args[0]);
-
- retval = ps_call_handler(PSF(read), 1, args);
-
- if(retval) {
- if(retval->type == IS_STRING) {
- *val = estrndup(retval->value.str.val, retval->value.str.len);
- *vallen = retval->value.str.len;
- ret = SUCCESS;
- }
- zval_dtor(retval);
- efree(retval);
- }
-
- return ret;
-}
-
-PS_WRITE_FUNC(user)
-{
- zval *args[2];
- STDVARS;
-
- ZVAL_STRING(key, args[0]);
- ZVAL_STRINGN(val, vallen, args[1]);
-
- retval = ps_call_handler(PSF(write), 2, args);
-
- FINISH;
-}
-
-PS_DESTROY_FUNC(user)
-{
- zval *args[1];
- STDVARS;
-
- ZVAL_STRING(key, args[0]);
-
- retval = ps_call_handler(PSF(destroy), 1, args);
-
- FINISH;
-}
-
-PS_GC_FUNC(user)
-{
- zval *args[1];
- STDVARS;
-
- ZVAL_LONG(maxlifetime, args[0]);
-
- retval = ps_call_handler(PSF(gc), 1, args);
-
- FINISH;
-}
diff --git a/ext/session/mod_user.h b/ext/session/mod_user.h
deleted file mode 100644
index 3d91050ab7..0000000000
--- a/ext/session/mod_user.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <ss@2ns.de> |
- +----------------------------------------------------------------------+
- */
-
-#ifndef MOD_USER_H
-#define MOD_USER_H
-
-typedef union {
- char *names[6];
- struct {
- char *ps_open;
- char *ps_close;
- char *ps_read;
- char *ps_write;
- char *ps_destroy;
- char *ps_gc;
- } name;
-} ps_user;
-
-extern ps_module ps_mod_user;
-#define ps_user_ptr &ps_mod_user
-
-PS_FUNCS(user);
-
-#endif
diff --git a/ext/session/modules.c b/ext/session/modules.c
deleted file mode 100644
index f866a42333..0000000000
--- a/ext/session/modules.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * To add a PHP session module, #include its header file and
- * add a ps_xxx_ptr in the struct...
- */
-
-#include "mod_files.h"
-#include "mod_mm.h"
-#include "mod_user.h"
-
-static ps_module *ps_modules[] = {
- ps_files_ptr,
- ps_mm_ptr,
- ps_user_ptr,
-};
-
diff --git a/ext/session/php_session.h b/ext/session/php_session.h
deleted file mode 100644
index 10fd555b54..0000000000
--- a/ext/session/php_session.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <ss@2ns.de> |
- +----------------------------------------------------------------------+
- */
-
-#ifndef PHP_SESSION_H
-#define PHP_SESSION_H
-
-#define PS_OPEN_ARGS void **mod_data, const char *save_path, const char *session_name
-#define PS_CLOSE_ARGS void **mod_data
-#define PS_READ_ARGS void **mod_data, const char *key, char **val, int *vallen
-#define PS_WRITE_ARGS void **mod_data, const char *key, const char *val, const int vallen
-#define PS_DESTROY_ARGS void **mod_data, const char *key
-#define PS_GC_ARGS void **mod_data, int maxlifetime
-
-typedef struct ps_module_struct {
- const char *name;
- int (*open)(PS_OPEN_ARGS);
- int (*close)(PS_CLOSE_ARGS);
- int (*read)(PS_READ_ARGS);
- int (*write)(PS_WRITE_ARGS);
- int (*destroy)(PS_DESTROY_ARGS);
- int (*gc)(PS_GC_ARGS);
-} ps_module;
-
-#define PS_GET_MOD_DATA() *mod_data
-#define PS_SET_MOD_DATA(a) *mod_data = (a)
-
-#define PS_OPEN_FUNC(x) int _ps_open_##x(PS_OPEN_ARGS)
-#define PS_CLOSE_FUNC(x) int _ps_close_##x(PS_CLOSE_ARGS)
-#define PS_READ_FUNC(x) int _ps_read_##x(PS_READ_ARGS)
-#define PS_WRITE_FUNC(x) int _ps_write_##x(PS_WRITE_ARGS)
-#define PS_DESTROY_FUNC(x) int _ps_delete_##x(PS_DESTROY_ARGS)
-#define PS_GC_FUNC(x) int _ps_gc_##x(PS_GC_ARGS)
-
-#define PS_FUNCS(x) \
- PS_OPEN_FUNC(x); \
- PS_CLOSE_FUNC(x); \
- PS_READ_FUNC(x); \
- PS_WRITE_FUNC(x); \
- PS_DESTROY_FUNC(x); \
- PS_GC_FUNC(x)
-
-
-#define PS_MOD(x) \
- #x, _ps_open_##x, _ps_close_##x, _ps_read_##x, _ps_write_##x, \
- _ps_delete_##x, _ps_gc_##x
-
-typedef struct {
- char *save_path;
- char *session_name;
- char *id;
- char *extern_referer_chk;
- char *entropy_file;
- int entropy_length;
- int lifetime;
- zend_bool define_sid;
- ps_module *mod;
- void *mod_data;
- HashTable vars;
- int nr_open_sessions;
- int gc_probability;
- int gc_maxlifetime;
- int module_number;
- const struct ps_serializer_struct *serializer;
-} php_ps_globals;
-
-extern zend_module_entry session_module_entry;
-#define phpext_session_ptr &session_module_entry
-
-PHP_FUNCTION(session_name);
-PHP_FUNCTION(session_module_name);
-PHP_FUNCTION(session_save_path);
-PHP_FUNCTION(session_id);
-PHP_FUNCTION(session_decode);
-PHP_FUNCTION(session_register);
-PHP_FUNCTION(session_unregister);
-PHP_FUNCTION(session_is_registered);
-PHP_FUNCTION(session_encode);
-PHP_FUNCTION(session_start);
-PHP_FUNCTION(session_destroy);
-PHP_FUNCTION(session_unset);
-PHP_FUNCTION(session_set_save_handler);
-
-#ifdef ZTS
-#define PSLS_D php_ps_globals *ps_globals
-#define PSLS_DC , PSLS_D
-#define PSLS_C ps_globals
-#define PSLS_CC , PSLS_C
-#define PS(v) (ps_globals->v)
-#define PSLS_FETCH() php_ps_globals *ps_globals = ts_resource(ps_globals_id)
-#else
-#define PSLS_D
-#define PSLS_DC
-#define PSLS_C
-#define PSLS_CC
-#define PS(v) (ps_globals.v)
-#define PSLS_FETCH()
-#endif
-
-#define PS_SERIALIZER_ENCODE_ARGS char **newstr, int *newlen PSLS_DC
-#define PS_SERIALIZER_DECODE_ARGS const char *val, int vallen PSLS_DC
-
-typedef struct ps_serializer_struct {
- const char *name;
- int (*encode)(PS_SERIALIZER_ENCODE_ARGS);
- int (*decode)(PS_SERIALIZER_DECODE_ARGS);
-} ps_serializer;
-
-#define PS_SERIALIZER_ENCODE_FUNC(x) \
- int _ps_srlzr_encode_##x(PS_SERIALIZER_ENCODE_ARGS)
-#define PS_SERIALIZER_DECODE_FUNC(x) \
- int _ps_srlzr_decode_##x(PS_SERIALIZER_DECODE_ARGS)
-
-#define PS_SERIALIZER_FUNCS(x) \
- PS_SERIALIZER_ENCODE_FUNC(x); \
- PS_SERIALIZER_DECODE_FUNC(x)
-
-#define PS_SERIALIZER_ENTRY(x) \
- { #x, _ps_srlzr_encode_##x, _ps_srlzr_decode_##x }
-
-#ifdef TRANS_SID
-void session_adapt_uris(const char *, uint, char **, uint *);
-#else
-#define session_adapt_uris(a,b,c,d) do { } while(0)
-#endif
-
-#if HAVE_WDDX
-#define WDDX_SERIALIZER
-#include "ext/wddx/php_wddx_api.h"
-#endif
-
-#endif
diff --git a/ext/session/session.c b/ext/session/session.c
deleted file mode 100644
index 9d9c498892..0000000000
--- a/ext/session/session.c
+++ /dev/null
@@ -1,937 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <ss@2ns.de> |
- | Andrey Zmievski <andrey@ispi.net> |
- +----------------------------------------------------------------------+
- */
-
-#if !(WIN32|WINNT)
-#include <sys/time.h>
-#else
-#include "win32/time.h"
-#endif
-
-#include <fcntl.h>
-
-#include "php.h"
-#include "php_ini.h"
-#include "SAPI.h"
-
-#include "php_session.h"
-#include "ext/standard/md5.h"
-#include "ext/standard/php3_var.h"
-#include "ext/standard/datetime.h"
-#include "ext/standard/php_lcg.h"
-#include "ext/standard/url_scanner.h"
-
-#ifdef ZTS
-int ps_globals_id;
-#else
-static php_ps_globals ps_globals;
-#endif
-
-#include "modules.c"
-
-function_entry session_functions[] = {
- PHP_FE(session_name, NULL)
- PHP_FE(session_module_name, NULL)
- PHP_FE(session_save_path, NULL)
- PHP_FE(session_id, NULL)
- PHP_FE(session_decode, NULL)
- PHP_FE(session_register, NULL)
- PHP_FE(session_unregister, NULL)
- PHP_FE(session_is_registered, NULL)
- PHP_FE(session_encode, NULL)
- PHP_FE(session_start, NULL)
- PHP_FE(session_destroy, NULL)
- PHP_FE(session_unset, NULL)
- PHP_FE(session_set_save_handler, NULL)
- {0}
-};
-
-PHP_INI_BEGIN()
- PHP_INI_ENTRY("session.save_path", "/tmp", PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("session.name", "PHPSESSID", PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("session.save_handler", "files", PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("session.auto_start", "0", PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("session.gc_probability", "1", PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("session.gc_maxlifetime", "1440", PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("session.lifetime", "0", PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("session.serialize_handler", "php", PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("session.extern_referer_check", "", PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("session.entropy_file", "", PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("session.entropy_length", "0", PHP_INI_ALL, NULL)
-PHP_INI_END()
-
-PS_SERIALIZER_FUNCS(php);
-#ifdef WDDX_SERIALIZER
-PS_SERIALIZER_FUNCS(wddx);
-#endif
-
-
-const static ps_serializer ps_serializers[] = {
-#ifdef WDDX_SERIALIZER
- PS_SERIALIZER_ENTRY(wddx),
-#endif
- PS_SERIALIZER_ENTRY(php),
- {0}
-};
-
-PHP_MINIT_FUNCTION(session);
-PHP_RINIT_FUNCTION(session);
-PHP_MSHUTDOWN_FUNCTION(session);
-PHP_RSHUTDOWN_FUNCTION(session);
-PHP_MINFO_FUNCTION(session);
-
-static void php_rinit_session_globals(PSLS_D);
-static void php_rshutdown_session_globals(PSLS_D);
-
-zend_module_entry session_module_entry = {
- "session",
- session_functions,
- PHP_MINIT(session), PHP_MSHUTDOWN(session),
- PHP_RINIT(session), PHP_RSHUTDOWN(session),
- PHP_MINFO(session),
- STANDARD_MODULE_PROPERTIES,
-};
-
-#define STR_CAT(P,S,I) {\
- pval *__p = (P);\
- ulong __i = __p->value.str.len;\
- __p->value.str.len += (I);\
- if (__p->value.str.val) {\
- __p->value.str.val = (char *)erealloc(__p->value.str.val, __p->value.str.len + 1);\
- } else {\
- __p->value.str.val = emalloc(__p->value.str.len + 1);\
- *__p->value.str.val = 0;\
- }\
- strcat(__p->value.str.val + __i, (S));\
-}
-
-#define MAX_STR 512
-#define STD_FMT "%s|"
-#define NOTFOUND_FMT "!%s|"
-
-#define PS_ADD_VARL(name,namelen) \
- zend_hash_update(&PS(vars), name, namelen + 1, 0, 0, NULL)
-
-#define PS_ADD_VAR(name) PS_ADD_VARL(name, strlen(name))
-
-#define PS_DEL_VARL(name,namelen) \
- zend_hash_del(&PS(vars), name, namelen + 1);
-
-#define PS_DEL_VAR(name) PS_DEL_VARL(name, strlen(name))
-
-PS_SERIALIZER_ENCODE_FUNC(php)
-{
- pval *buf;
- pval **struc;
- char *key;
- char strbuf[MAX_STR + 1];
- ELS_FETCH();
-
- buf = ecalloc(sizeof(*buf), 1);
- buf->type = IS_STRING;
- buf->refcount++;
-
- for(zend_hash_internal_pointer_reset(&PS(vars));
- zend_hash_get_current_key(&PS(vars), &key, NULL) == HASH_KEY_IS_STRING;
- zend_hash_move_forward(&PS(vars))) {
- if(zend_hash_find(&EG(symbol_table), key, strlen(key) + 1, (void **) &struc)
- == SUCCESS) {
- snprintf(strbuf, MAX_STR, STD_FMT, key);
- STR_CAT(buf, strbuf, strlen(strbuf));
- php_var_serialize(buf, struc);
- } else {
- snprintf(strbuf, MAX_STR, NOTFOUND_FMT, key);
- STR_CAT(buf, strbuf, strlen(strbuf));
- }
- efree(key);
- }
-
- if(newlen) *newlen = buf->value.str.len;
- *newstr = buf->value.str.val;
- efree(buf);
-
- return SUCCESS;
-}
-
-PS_SERIALIZER_DECODE_FUNC(php)
-{
- const char *p, *q;
- char *name;
- const char *endptr = val + vallen;
- pval *current;
- int namelen;
- int has_value;
- ELS_FETCH();
-
- for(p = q = val; (p < endptr) && (q = strchr(p, '|')); p = q) {
- if(p[0] == '!') {
- p++;
- has_value = 0;
- } else {
- has_value = 1;
- }
-
- namelen = q - p;
- name = estrndup(p, namelen);
- q++;
-
- if(has_value) {
- current = (pval *) ecalloc(sizeof(pval), 1);
-
- if(php_var_unserialize(&current, &q, endptr)) {
- zend_hash_update(&EG(symbol_table), name, namelen + 1,
- &current, sizeof(current), NULL);
- } else {
- efree(current);
- }
- }
- PS_ADD_VAR(name);
- efree(name);
- }
-
- return SUCCESS;
-}
-
-#ifdef WDDX_SERIALIZER
-
-PS_SERIALIZER_ENCODE_FUNC(wddx)
-{
- wddx_packet *packet;
- char *key;
- zval **struc;
- ELS_FETCH();
-
- packet = _php_wddx_constructor();
- if(!packet) return FAILURE;
-
- _php_wddx_packet_start(packet, NULL);
- _php_wddx_add_chunk(packet, WDDX_STRUCT_S);
-
- for(zend_hash_internal_pointer_reset(&PS(vars));
- zend_hash_get_current_key(&PS(vars), &key, NULL) == HASH_KEY_IS_STRING;
- zend_hash_move_forward(&PS(vars))) {
- if(zend_hash_find(&EG(symbol_table), key, strlen(key) + 1, (void **) &struc) == SUCCESS) {
- _php_wddx_serialize_var(packet, *struc, key);
- }
- efree(key);
- }
-
- _php_wddx_add_chunk(packet, WDDX_STRUCT_E);
- _php_wddx_packet_end(packet);
- *newstr = _php_wddx_gather(packet);
- _php_wddx_destructor(packet);
-
- if(newlen) *newlen = strlen(*newstr);
-
- return SUCCESS;
-}
-
-PS_SERIALIZER_DECODE_FUNC(wddx)
-{
- zval *retval;
- zval **ent;
- char *key;
- char tmp[128];
- ulong idx;
- int hash_type;
- int dofree = 1;
- ELS_FETCH();
-
- if(vallen == 0) return FAILURE;
-
- MAKE_STD_ZVAL(retval);
-
- _php_wddx_deserialize_ex(val, vallen, retval);
-
- for(zend_hash_internal_pointer_reset(retval->value.ht);
- zend_hash_get_current_data(retval->value.ht, (void **) &ent) == SUCCESS;
- zend_hash_move_forward(retval->value.ht)) {
- hash_type = zend_hash_get_current_key(retval->value.ht, &key, &idx);
-
- switch(hash_type) {
- case HASH_KEY_IS_LONG:
- sprintf(tmp, "%ld", idx);
- key = tmp;
- dofree = 0;
- case HASH_KEY_IS_STRING:
- zval_add_ref(ent);
- zend_hash_update(&EG(symbol_table), key, strlen(key) + 1,
- ent, sizeof(ent), NULL);
- PS_ADD_VAR(key);
- if(dofree) efree(key);
- dofree = 1;
- }
- }
-
- zval_dtor(retval);
- efree(retval);
-
- return SUCCESS;
-}
-
-#endif
-
-static char *_php_session_encode(int *newlen PSLS_DC)
-{
- char *ret = NULL;
-
- if(PS(serializer)->encode(&ret, newlen PSLS_CC) == FAILURE) {
- ret = NULL;
- }
-
- return ret;
-}
-
-static void _php_session_decode(const char *val, int vallen PSLS_DC)
-{
- PS(serializer)->decode(val, vallen PSLS_CC);
-}
-
-static char *_php_create_id(int *newlen PSLS_DC)
-{
- PHP3_MD5_CTX context;
- unsigned char digest[16];
- char buf[256];
- struct timeval tv;
- int i;
-
- gettimeofday(&tv, NULL);
- PHP3_MD5Init(&context);
-
- sprintf(buf, "%ld%ld%0.8f", tv.tv_sec, tv.tv_usec, php_combined_lcg() * 10);
- PHP3_MD5Update(&context, buf, strlen(buf));
-
- if(PS(entropy_length) > 0) {
- int fd;
-
- fd = open(PS(entropy_file), O_RDONLY);
- if(fd >= 0) {
- char *p;
- int n;
-
- p = emalloc(PS(entropy_length));
- n = read(fd, p, PS(entropy_length));
- if(n > 0) {
- PHP3_MD5Update(&context, p, n);
- }
- efree(p);
- close(fd);
- }
- }
-
- PHP3_MD5Final(digest, &context);
-
- for(i = 0; i < 16; i++)
- sprintf(buf + (i << 1), "%02x", digest[i]);
- buf[i << 1] = '\0';
-
- if(newlen) *newlen = i << 1;
- return estrdup(buf);
-}
-
-static void _php_session_initialize(PSLS_D)
-{
- char *val;
- int vallen;
-
- if(PS(mod)->open(&PS(mod_data), PS(save_path), PS(session_name)) == FAILURE) {
- php_error(E_ERROR, "failed to initialize session module");
- return;
- }
- if(PS(mod)->read(&PS(mod_data), PS(id), &val, &vallen) == SUCCESS) {
- _php_session_decode(val, vallen PSLS_CC);
- efree(val);
- }
-}
-
-static void _php_session_save_current_state(PSLS_D)
-{
- char *val;
- int vallen;
-
- val = _php_session_encode(&vallen PSLS_CC);
- if(val) {
- PS(mod)->write(&PS(mod_data), PS(id), val, vallen);
- efree(val);
- } else {
- PS(mod)->write(&PS(mod_data), PS(id), "", 0);
- }
- PS(mod)->close(&PS(mod_data));
-}
-
-#define COOKIE_FMT "Set-cookie: %s=%s"
-#define COOKIE_EXPIRES "; expires="
-
-static void _php_session_send_cookie(PSLS_D)
-{
- int len;
- char *cookie;
- char *date_fmt = NULL;
-
- len = strlen(PS(session_name)) + strlen(PS(id)) + sizeof(COOKIE_FMT);
- if (PS(lifetime) > 0) {
- date_fmt = php3_std_date(time(NULL) + PS(lifetime));
- len += sizeof(COOKIE_EXPIRES) + strlen(date_fmt);
- }
- cookie = ecalloc(len + 1, 1);
-
- len = snprintf(cookie, len, COOKIE_FMT, PS(session_name), PS(id));
- if (PS(lifetime) > 0) {
- strcat(cookie, COOKIE_EXPIRES);
- strcat(cookie, date_fmt);
- len += strlen(COOKIE_EXPIRES) + strlen(date_fmt);
- efree(date_fmt);
- }
-
- sapi_add_header(cookie, len);
-}
-
-static ps_module *_php_find_ps_module(char *name PSLS_DC)
-{
- ps_module *ret = NULL;
- ps_module **mod;
- ps_module **end = ps_modules + (sizeof(ps_modules)/sizeof(ps_module*));
-
- for(mod = ps_modules; mod < end; mod++) {
- if(*mod && !strcasecmp(name, (*mod)->name)) {
- ret = *mod;
- break;
- }
- }
-
- return ret;
-}
-
-static const ps_serializer *_php_find_ps_serializer(char *name PSLS_DC)
-{
- const ps_serializer *ret = NULL;
- const ps_serializer *mod;
-
- for(mod = ps_serializers; mod->name; mod++) {
- if(!strcasecmp(name, mod->name)) {
- ret = mod;
- break;
- }
- }
-
- return ret;
-}
-
-static void _php_session_start(PSLS_D)
-{
- pval **ppid;
- pval **data;
- char *p;
- int send_cookie = 1;
- int define_sid = 1;
- int module_number = PS(module_number);
- int nrand;
- int lensess;
- ELS_FETCH();
-
- if (PS(nr_open_sessions) != 0) return;
-
- lensess = strlen(PS(session_name));
-
- /* check whether a symbol with the name of the session exists
- in the global symbol table */
-
- if(!PS(id) &&
- zend_hash_find(&EG(symbol_table), PS(session_name),
- lensess + 1, (void **) &ppid) == SUCCESS) {
- convert_to_string((*ppid));
- PS(id) = estrndup((*ppid)->value.str.val, (*ppid)->value.str.len);
- send_cookie = 0;
- }
-
- /* if the previous section was successful, we check whether
- a symbol with the name of the session exists in the global
- HTTP_COOKIE_VARS array */
-
- if(!send_cookie &&
- zend_hash_find(&EG(symbol_table), "HTTP_COOKIE_VARS",
- sizeof("HTTP_COOKIE_VARS"), (void **) &data) == SUCCESS &&
- (*data)->type == IS_ARRAY &&
- zend_hash_find((*data)->value.ht, PS(session_name),
- lensess + 1, (void **) &ppid) == SUCCESS) {
- define_sid = 0;
- }
-
- /* check the REQUEST_URI symbol for a string of the form
- '<session-name>=<session-id>' to allow URLs of the form
- http://yoursite/<session-name>=<session-id>/script.php */
-
- if(!PS(id) &&
- zend_hash_find(&EG(symbol_table), "REQUEST_URI",
- sizeof("REQUEST_URI"), (void **) &data) == SUCCESS &&
- (*data)->type == IS_STRING &&
- (p = strstr((*data)->value.str.val, PS(session_name))) &&
- p[lensess] == '=') {
- char *q;
-
- p += lensess + 1;
- if((q = strpbrk(p, "/?\\")))
- PS(id) = estrndup(p, q - p);
- }
-
- /* check whether the current request was referred to by
- an external site which invalidates the previously found id */
-
- if(PS(id) &&
- PS(extern_referer_chk)[0] != '\0' &&
- zend_hash_find(&EG(symbol_table), "HTTP_REFERER",
- sizeof("HTTP_REFERER"), (void **) &data) == SUCCESS &&
- (*data)->type == IS_STRING &&
- (*data)->value.str.len != 0 &&
- strstr((*data)->value.str.val, PS(extern_referer_chk)) == NULL) {
- efree(PS(id));
- PS(id) = NULL;
- send_cookie = 1;
- define_sid = 1;
- }
-
- if(!PS(id)) {
- PS(id) = _php_create_id(NULL PSLS_CC);
- }
-
- if(send_cookie) {
- _php_session_send_cookie(PSLS_C);
- }
-
- if(define_sid) {
- char *buf;
-
- buf = emalloc(strlen(PS(session_name)) + strlen(PS(id)) + 5);
- sprintf(buf, "%s=%s", PS(session_name), PS(id));
- REGISTER_STRING_CONSTANT("SID", buf, 0);
- } else {
- REGISTER_STRING_CONSTANT("SID", empty_string, 0);
- }
- PS(define_sid) = define_sid;
-
- PS(nr_open_sessions)++;
-
- _php_session_initialize(PSLS_C);
-
- if(PS(mod_data) && PS(gc_probability) > 0) {
- srand(time(NULL));
- nrand = (int) (100.0*rand()/RAND_MAX);
- if(nrand < PS(gc_probability))
- PS(mod)->gc(&PS(mod_data), PS(gc_maxlifetime));
- }
-}
-
-static void _php_session_destroy(PSLS_D)
-{
- if(PS(nr_open_sessions) == 0)
- {
- php_error(E_WARNING, "Trying to destroy uninitialized session");
- return;
- }
-
- PS(mod)->destroy(&PS(mod_data), PS(id));
- php_rshutdown_session_globals(PSLS_C);
- php_rinit_session_globals(PSLS_C);
-}
-
-/* {{{ proto string session_name([string newname])
- return the current session name. if newname is given, the session name is replaced with newname */
-PHP_FUNCTION(session_name)
-{
- pval **p_name;
- int ac = ARG_COUNT(ht);
- char *old;
- PSLS_FETCH();
-
- old = estrdup(PS(session_name));
-
- if(ac < 0 || ac > 1 || getParametersEx(ac, &p_name) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if(ac == 1) {
- convert_to_string_ex(p_name);
- efree(PS(session_name));
- PS(session_name) = estrndup((*p_name)->value.str.val, (*p_name)->value.str.len);
- }
-
- RETVAL_STRING(old, 0);
-}
-/* }}} */
-
-/* {{{ proto string session_module_name([string newname])
- return the current module name used for accessing session data. if newname is given, the module name is replaced with newname */
-PHP_FUNCTION(session_module_name)
-{
- pval **p_name;
- int ac = ARG_COUNT(ht);
- char *old;
- PSLS_FETCH();
-
- old = estrdup(PS(mod)->name);
-
- if(ac < 0 || ac > 1 || getParametersEx(ac, &p_name) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if(ac == 1) {
- ps_module *tempmod;
-
- convert_to_string_ex(p_name);
- tempmod = _php_find_ps_module((*p_name)->value.str.val PSLS_CC);
- if(tempmod) {
- if(PS(mod_data))
- PS(mod)->close(&PS(mod_data));
- PS(mod_data) = tempmod;
- } else {
- efree(old);
- php_error(E_ERROR, "Cannot find named PHP session module (%s)",
- (*p_name)->value.str.val);
- RETURN_FALSE;
- }
- }
-
- RETVAL_STRING(old, 0);
-}
-/* }}} */
-
-/* {{{ proto void session_set_save_handler(string open, string close, string read, string write, string destroy, string gc)
- sets user-level functions */
-PHP_FUNCTION(session_set_save_handler)
-{
- zval **args[6];
- int i;
- ps_user *mdata;
- PSLS_FETCH();
-
- if(ARG_COUNT(ht) != 6 || getParametersArrayEx(6, args) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if(PS(nr_open_sessions) > 0) {
- RETURN_FALSE;
- }
-
- PS(mod) = _php_find_ps_module("user" PSLS_CC);
-
- mdata = emalloc(sizeof *mdata);
-
- for(i = 0; i < 6; i++) {
- convert_to_string_ex(args[i]);
- mdata->names[i] = estrdup((*args[i])->value.str.val);
- }
-
- PS(mod_data) = (void *) mdata;
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto string session_save_path([string newname])
- return the current save path passed to module_name. if newname is given, the save path is replaced with newname */
-PHP_FUNCTION(session_save_path)
-{
- pval **p_name;
- int ac = ARG_COUNT(ht);
- char *old;
- PSLS_FETCH();
-
- old = estrdup(PS(save_path));
-
- if(ac < 0 || ac > 1 || getParametersEx(ac, &p_name) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if(ac == 1) {
- convert_to_string_ex(p_name);
- efree(PS(save_path));
- PS(save_path) = estrndup((*p_name)->value.str.val, (*p_name)->value.str.len);
- }
-
- RETVAL_STRING(old, 0);
-}
-/* }}} */
-
-/* {{{ proto string session_id([string newid])
- return the current session id. if newid is given, the session id is replaced with newid */
-PHP_FUNCTION(session_id)
-{
- pval **p_name;
- int ac = ARG_COUNT(ht);
- char *old = empty_string;
- PSLS_FETCH();
-
- if(PS(id))
- old = estrdup(PS(id));
-
- if(ac < 0 || ac > 1 || getParametersEx(ac, &p_name) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if(ac == 1) {
- convert_to_string_ex(p_name);
- if(PS(id)) efree(PS(id));
- PS(id) = estrndup((*p_name)->value.str.val, (*p_name)->value.str.len);
- }
-
- RETVAL_STRING(old, 0);
-}
-/* }}} */
-
-/* {{{ proto session_register(string varname)
- adds varname to the list of variables which are freezed at the session end */
-PHP_FUNCTION(session_register)
-{
- pval **p_name;
- int ac = ARG_COUNT(ht);
- PSLS_FETCH();
-
- if(ac != 1 || getParametersEx(ac, &p_name) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string_ex(p_name);
-
- if(!PS(nr_open_sessions)) _php_session_start(PSLS_C);
- PS_ADD_VAR((*p_name)->value.str.val);
-}
-/* }}} */
-
-/* {{{ proto session_unregister(string varname)
- removes varname from the list of variables which are freezed at the session end */
-PHP_FUNCTION(session_unregister)
-{
- pval **p_name;
- int ac = ARG_COUNT(ht);
- PSLS_FETCH();
-
- if(ac != 1 || getParametersEx(ac, &p_name) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string_ex(p_name);
-
- PS_DEL_VAR((*p_name)->value.str.val);
-}
-/* }}} */
-
-
-/* {{{ proto bool session_is_registered(string varname)
- checks if a variable is registered in session */
-PHP_FUNCTION(session_is_registered)
-{
- pval **p_name;
- pval *p_var;
- int ac = ARG_COUNT(ht);
- PSLS_FETCH();
-
- if(ac != 1 || getParametersEx(ac, &p_name) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string_ex(p_name);
-
- if (zend_hash_find(&PS(vars), (*p_name)->value.str.val, (*p_name)->value.str.len+1,
- (void **)&p_var) == SUCCESS) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-
-/* {{{ proto string session_encode()
- serializes the current setup and returns the serialized representation */
-PHP_FUNCTION(session_encode)
-{
- int len;
- char *enc;
- PSLS_FETCH();
-
- enc = _php_session_encode(&len PSLS_CC);
- RETVAL_STRINGL(enc, len, 0);
-}
-/* }}} */
-
-/* {{{ proto session_decode(string data)
- deserializes data and reinitializes the variables */
-PHP_FUNCTION(session_decode)
-{
- pval **str;
- PSLS_FETCH();
-
- if(ARG_COUNT(ht) != 1 || getParametersEx(1, &str) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string_ex(str);
-
- _php_session_decode((*str)->value.str.val, (*str)->value.str.len PSLS_CC);
-}
-/* }}} */
-
-/* {{{ proto session_start()
- Begin session - reinitializes freezed variables, registers browsers etc */
-PHP_FUNCTION(session_start)
-{
- PSLS_FETCH();
-
- _php_session_start(PSLS_C);
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto session_destroy()
- Destroy the current session and all data associated with it */
-PHP_FUNCTION(session_destroy)
-{
- PSLS_FETCH();
-
- _php_session_destroy(PSLS_C);
-}
-/* }}} */
-
-#ifdef TRANS_SID
-void session_adapt_uris(const char *src, uint srclen, char **new, uint *newlen)
-{
- char *data;
- size_t len;
- char buf[512];
- PSLS_FETCH();
-
- if(PS(define_sid) && PS(nr_open_sessions) > 0) {
- snprintf(buf, sizeof(buf), "%s=%s", PS(session_name), PS(id));
- data = url_adapt(src, srclen, buf, &len);
- *new = data;
- *newlen = len;
- }
-}
-#endif
-
-/* {{{ proto session_unset()
- Unset all registered variables */
-PHP_FUNCTION(session_unset)
-{
- zval **tmp;
- char *variable;
- ELS_FETCH();
- PSLS_FETCH();
-
- for(zend_hash_internal_pointer_reset(&PS(vars));
- zend_hash_get_current_key(&PS(vars), &variable, NULL) == HASH_KEY_IS_STRING;
- zend_hash_move_forward(&PS(vars))) {
- if(zend_hash_find(&EG(symbol_table), variable, strlen(variable) + 1, (void **) &tmp)
- == SUCCESS) {
- zend_hash_del(&EG(symbol_table), variable, strlen(variable) + 1);
- }
- efree(variable);
- }
-}
-/* }}} */
-
-static void php_rinit_session_globals(PSLS_D)
-{
- PS(mod) = _php_find_ps_module(INI_STR("session.save_handler") PSLS_CC);
- PS(serializer) = \
- _php_find_ps_serializer(INI_STR("session.serialize_handler") PSLS_CC);
-
- zend_hash_init(&PS(vars), 0, NULL, NULL, 0);
- PS(define_sid) = 0;
- PS(save_path) = estrdup(INI_STR("session.save_path"));
- PS(session_name) = estrdup(INI_STR("session.name"));
- PS(entropy_file) = estrdup(INI_STR("session.entropy_file"));
- PS(entropy_length) = INI_INT("session.entropy_length");
- PS(gc_probability) = INI_INT("session.gc_probability");
- PS(gc_maxlifetime) = INI_INT("session.gc_maxlifetime");
- PS(extern_referer_chk) = estrdup(INI_STR("session.extern_referer_check"));
- PS(id) = NULL;
- PS(lifetime) = INI_INT("session.lifetime");
- PS(nr_open_sessions) = 0;
- PS(mod_data) = NULL;
-}
-
-static void php_rshutdown_session_globals(PSLS_D)
-{
- if(PS(mod_data))
- PS(mod)->close(&PS(mod_data));
- efree(PS(entropy_file));
- efree(PS(extern_referer_chk));
- efree(PS(save_path));
- efree(PS(session_name));
- if(PS(id)) efree(PS(id));
- zend_hash_destroy(&PS(vars));
-}
-
-PHP_RINIT_FUNCTION(session)
-{
- PSLS_FETCH();
-
- php_rinit_session_globals(PSLS_C);
-
- if(PS(mod) == NULL) {
- /* current status is unusable */
- PS(nr_open_sessions) = -1;
- return FAILURE;
- }
-
- if(INI_INT("session.auto_start")) {
- _php_session_start(PSLS_C);
- }
-
- return SUCCESS;
-}
-
-PHP_RSHUTDOWN_FUNCTION(session)
-{
- PSLS_FETCH();
-
- if(PS(nr_open_sessions) > 0) {
- _php_session_save_current_state(PSLS_C);
- PS(nr_open_sessions)--;
- }
- php_rshutdown_session_globals(PSLS_C);
- return SUCCESS;
-}
-
-PHP_MINIT_FUNCTION(session)
-{
-#ifdef ZTS
- php_ps_globals *ps_globals;
-
- ps_globals_id = ts_allocate_id(sizeof(php_ps_globals), NULL, NULL);
- ps_globals = ts_resource(ps_globals_id);
-#endif
-
- PS(module_number) = module_number;
- REGISTER_INI_ENTRIES();
- return SUCCESS;
-}
-
-PHP_MSHUTDOWN_FUNCTION(session)
-{
- UNREGISTER_INI_ENTRIES();
- return SUCCESS;
-}
-
-
-PHP_MINFO_FUNCTION(session)
-{
- DISPLAY_INI_ENTRIES();
-}
diff --git a/ext/session/setup.stub b/ext/session/setup.stub
deleted file mode 100644
index 33ca6e8664..0000000000
--- a/ext/session/setup.stub
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-session 'session support?' yesnodir no \
-' Whether to build the session extension.'
-
diff --git a/ext/snmp/Makefile.am b/ext/snmp/Makefile.am
deleted file mode 100644
index badfe55541..0000000000
--- a/ext/snmp/Makefile.am
+++ /dev/null
@@ -1,15 +0,0 @@
-# $Id$
-
-phplibdir=$(libdir)/php
-
-SRC=snmp.c
-INCLUDES=@INCLUDES@ @SNMP_INCLUDE@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=@SNMP_STATIC@
-EXTRA_LIBRARIES=libphpext_snmp.a
-libphpext_snmp_a_SOURCES=$(SRC)
-phplib_LTLIBRARIES=@SNMP_SHARED@
-EXTRA_LTLIBRARIES=snmp.la
-snmp_la_SOURCES=$(SRC)
-snmp_la_LIBADD=@SNMP_LIBDIR@ -lsnmp @KSTAT_LIBS@
-snmp_la_LDFLAGS=-avoid-version -module -rpath $(phplibdir)
-EXTRA_LIBS=
diff --git a/ext/snmp/config.h.stub b/ext/snmp/config.h.stub
deleted file mode 100644
index 2e837eac70..0000000000
--- a/ext/snmp/config.h.stub
+++ /dev/null
@@ -1,4 +0,0 @@
-/* Define if you want the SNMP interface */
-#define HAVE_SNMP 0
-
-#undef UCD_SNMP_HACK
diff --git a/ext/snmp/config.m4 b/ext/snmp/config.m4
deleted file mode 100644
index f19ed7cb6d..0000000000
--- a/ext/snmp/config.m4
+++ /dev/null
@@ -1,80 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(for SNMP support)
-AC_ARG_WITH(snmp,
-[ --with-snmp[=DIR] Include SNMP support. DIR is the SNMP base
- install directory, defaults to searching through
- a number of common locations for the snmp install.
- Set DIR to "shared" to build as a dl, or "shared,DIR"
- to build as a dl and still specify DIR.],
-[
- case $withval in
- shared)
- shared=yes
- withval=yes
- ;;
- shared,*)
- shared=yes
- withval=`echo $withval | sed -e 's/^shared,//'`
- ;;
- *)
- shared=no
- ;;
- esac
- if test "$withval" != "no"; then
- if test "$withval" = "yes"; then
- SNMP_INCDIR=/usr/local/include
- SNMP_LIBDIR=/usr/local/lib
- test -d /usr/local/include/ucd-snmp && SNMP_INCDIR=/usr/local/include/ucd-snmp
- test -d /usr/include/ucd-snmp && SNMP_INCDIR=/usr/include/ucd-snmp
- test -d /usr/include/snmp && SNMP_INCDIR=/usr/include/snmp
- test -f /usr/lib/libsnmp.a && SNMP_LIBDIR=/usr/lib
- test -f /usr/lib/libsnmp.so && SNMP_LIBDIR=/usr/lib
- else
- SNMP_INCDIR=$withval/include
- test -d $withval/include/ucd-snmp && SNMP_INCDIR=$withval/include/ucd-snmp
- SNMP_LIBDIR=$withval/lib
- fi
- AC_DEFINE(HAVE_SNMP)
- if test "$shared" = "yes"; then
- AC_MSG_RESULT(yes (shared))
- SNMP_INCLUDE="-I$SNMP_INCDIR"
- SNMP_SHARED="snmp.la"
- else
- AC_MSG_RESULT(yes (static))
- AC_ADD_LIBRARY_WITH_PATH(snmp, $SNMP_LIBDIR)
- AC_ADD_INCLUDE($SNMP_INCDIR)
- SNMP_STATIC="libphpext_snmp.a"
- fi
- PHP_EXTENSION(snmp,$shared)
- AC_CHECK_LIB(kstat, kstat_read, [
- if test "$shared" = yes; then
- KSTAT_LIBS="-lkstat"
- else
- AC_ADD_LIBRARY(kstat)
- fi
- ])
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-AC_SUBST(SNMP_LIBDIR)
-AC_SUBST(SNMP_INCLUDE)
-AC_SUBST(SNMP_SHARED)
-AC_SUBST(SNMP_STATIC)
-AC_SUBST(KSTAT_LIBS)
-
-AC_MSG_CHECKING(whether to enable UCD SNMP hack)
-AC_ARG_ENABLE(ucd-snmp-hack,
-[ --enable-ucd-snmp-hack Enable UCD SNMP hack],[
- if test "$enableval" = "yes" ; then
- AC_DEFINE(UCD_SNMP_HACK, 1)
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
diff --git a/ext/snmp/php3_snmp.h b/ext/snmp/php3_snmp.h
deleted file mode 100644
index 047d3ebf1a..0000000000
--- a/ext/snmp/php3_snmp.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-+----------------------------------------------------------------------+
-| PHP version 4.0 |
-+----------------------------------------------------------------------+
-| Copyright (c) 1997, 1998, 1999 The PHP Group |
-+----------------------------------------------------------------------+
-| This source file is subject to version 2.0 of the PHP license, |
-| that is bundled with this package in the file LICENSE, and is |
-| available at through the world-wide-web at |
-| http://www.php.net/license/2_0.txt. |
-| If you did not receive a copy of the PHP license and are unable to |
-| obtain it through the world-wide-web, please send a note to |
-| license@php.net so we can mail you a copy immediately. |
-+----------------------------------------------------------------------+
-| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
-| Mike Jackson <mhjack@tscnet.com> |
-| Steven Lawrance <slawrance@technologist.com> |
-+----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-#ifndef _PHP3_SNMP_H
-#define _PHP3_SNMP_H
-
-#if COMPILE_DL
-#undef HAVE_SNMP
-#define HAVE_SNMP 1
-#endif
-#if HAVE_SNMP
-#ifndef DLEXPORT
-#define DLEXPORT
-#endif
-
-extern php3_module_entry snmp_module_entry;
-#define snmp_module_ptr &snmp_module_entry
-
-extern int php3i_snmp_init(INIT_FUNC_ARGS);
-PHP_FUNCTION(snmpget);
-PHP_FUNCTION(snmpwalk);
-PHP_FUNCTION(snmprealwalk);
-PHP_FUNCTION(snmpwalkoid);
-PHP_FUNCTION(snmp_get_quick_print);
-PHP_FUNCTION(snmp_set_quick_print);
-PHP_FUNCTION(snmpset);
-void php3_info_snmp(ZEND_MODULE_INFO_FUNC_ARGS);
-#else
-
-#define snmp_module_ptr NULL
-
-#endif /* HAVE_SNMP */
-
-#define phpext_snmp_ptr snmp_module_ptr
-
-#endif /* _PHP3_SNMP_H */
diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c
deleted file mode 100644
index 8127468071..0000000000
--- a/ext/snmp/snmp.c
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
-+----------------------------------------------------------------------+
-| PHP version 4.0 |
-+----------------------------------------------------------------------+
-| Copyright (c) 1997, 1998, 1999 The PHP Group |
-+----------------------------------------------------------------------+
-| This source file is subject to version 2.0 of the PHP license, |
-| that is bundled with this package in the file LICENSE, and is |
-| available at through the world-wide-web at |
-| http://www.php.net/license/2_0.txt. |
-| If you did not receive a copy of the PHP license and are unable to |
-| obtain it through the world-wide-web, please send a note to |
-| license@php.net so we can mail you a copy immediately. |
-+----------------------------------------------------------------------+
-| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
-| Mike Jackson <mhjack@tscnet.com> |
-| Steven Lawrance <slawrance@technologist.com> |
-+----------------------------------------------------------------------+
-*/
-/* $Id$ */
-
-#ifdef PIC
-# define COMPILE_DL 1
-#endif
-
-#include "php.h"
-#if defined(COMPILE_DL)
-#include "dl/phpdl.h"
-#endif
-#include "php3_snmp.h"
-#include <sys/types.h>
-#if MSVC5
-#include <winsock.h>
-#include <errno.h>
-#include <process.h>
-#include "win32/time.h"
-#else
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#ifndef _OSD_POSIX
-#include <sys/errno.h>
-#else
-#include <errno.h> /* BS2000/OSD uses <errno.h>, not <sys/errno.h> */
-#endif
-#include <netdb.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#if HAVE_SNMP
-
-#ifndef __P
-#ifdef __GNUC__
-#define __P(args) args
-#else
-#define __P(args) ()
-#endif
-#endif
-
-#include "asn1.h"
-#include "snmp_api.h"
-#include "snmp_client.h"
-#include "snmp_impl.h"
-#include "snmp.h"
-#include "parse.h"
-#include "mib.h"
-
-/* ucd-snmp 3.3.1 changed the name of a few #defines... They've been changed back to the original ones in 3.5.3! */
-#ifndef SNMP_MSG_GET
-#define SNMP_MSG_GET GET_REQ_MSG
-#define SNMP_MSG_GETNEXT GETNEXT_REQ_MSG
-#endif
-
-void _php3_snmp(INTERNAL_FUNCTION_PARAMETERS, int st);
-
-/* constant - can be shared among threads */
-static oid objid_mib[] = {1, 3, 6, 1, 2, 1};
-
-/* Add missing prototype */
-void sprint_variable(char *, oid *, int, struct variable_list *);
-
-function_entry snmp_functions[] = {
- PHP_FE(snmpget, NULL)
- PHP_FE(snmpwalk, NULL)
- PHP_FE(snmprealwalk, NULL)
- PHP_FE(snmpwalkoid, NULL)
- PHP_FE(snmp_get_quick_print, NULL)
- PHP_FE(snmp_set_quick_print, NULL)
- PHP_FE(snmpset, NULL)
- {NULL,NULL,NULL}
-};
-
-php3_module_entry snmp_module_entry = {
- "SNMP",snmp_functions,php3i_snmp_init,NULL,NULL,NULL,php3_info_snmp,STANDARD_MODULE_PROPERTIES
-};
-
-#if COMPILE_DL
-DLEXPORT php3_module_entry *get_module() { return &snmp_module_entry; };
-#endif
-
-/* THREAD_LS snmp_module php3_snmp_module; - may need one of these at some point */
-
-int php3i_snmp_init(INIT_FUNC_ARGS) {
- init_mib();
- return SUCCESS;
-}
-
-void php3_info_snmp(ZEND_MODULE_INFO_FUNC_ARGS) {
- php_printf("ucd-snmp");
-}
-
-
-/*
-* Generic SNMP object fetcher
-*
-* st=1 snmpget() - query an agent and return a single value.
-* st=2 snmpwalk() - walk the mib and return a single dimensional array
-* containing the values.
-* st=3,4 snmprealwalk() and snmpwalkoid() - walk the mib and return an
-* array of oid,value pairs.
-* st=5-8 ** Reserved **
-* st=9 snmp_get_quick_print() - Return the current value for quickprint
-* (default setting is 0 (false)).
-* st=10 snmp_set_quick_print() - Set the current value for quickprint
-* st=11 snmpset() - query an agent and set a single value
-*
-*/
-void _php3_snmp(INTERNAL_FUNCTION_PARAMETERS, int st) {
- pval *a1, *a2, *a3, *a4, *a5, *a6, *a7;
- struct snmp_session session, *ss;
- struct snmp_pdu *pdu=NULL, *response;
- struct variable_list *vars;
- char *objid;
- oid name[MAX_NAME_LEN];
- int name_length;
- int status, count,rootlen=0,gotroot=0;
- oid root[MAX_NAME_LEN];
- char buf[2048];
- char buf2[2048];
- int keepwalking=1;
- long timeout=SNMP_DEFAULT_TIMEOUT;
- long retries=SNMP_DEFAULT_RETRIES;
- int myargc = ARG_COUNT(ht);
- char type;
- char *value;
-
- switch(st) {
- case 4:
- st = 3; /* This is temporary until snmprealwalk() is removed */
- break;
- case 9:
- RETURN_LONG(snmp_get_quick_print()?1:0);
- case 10:
- if(myargc != 1 || getParameters(ht, myargc, &a1)) WRONG_PARAM_COUNT;
- convert_to_long(a1);
- snmp_set_quick_print((int) a1->value.lval);
- RETURN_TRUE;
- }
-
- if (myargc<3 || myargc>7 || getParameters(ht, myargc, &a1, &a2, &a3, &a4, &a5, &a6, &a7) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(a1);
- convert_to_string(a2);
- convert_to_string(a3);
- if (st==11) {
- if (myargc<5) WRONG_PARAM_COUNT;
- convert_to_string(a4);
- convert_to_string(a5);
- if(myargc>5) {
- convert_to_long(a6);
- timeout=a6->value.lval;
- }
- if(myargc>6) {
- convert_to_long(a7);
- retries=a7->value.lval;
- }
- type = a4->value.str.val[0];
- value = a5->value.str.val;
- } else {
- if(myargc>3) {
- convert_to_long(a4);
- timeout=a4->value.lval;
- }
- if(myargc>4) {
- convert_to_long(a5);
- retries=a5->value.lval;
- }
- }
- objid=a3->value.str.val;
-
- if (st>=2) { /* walk */
- rootlen = MAX_NAME_LEN;
- if (strlen(objid)) { /* on a walk, an empty string means top of tree - no error */
- if (read_objid(objid, root, &rootlen)) {
- gotroot = 1;
- } else {
- php_error(E_WARNING,"Invalid object identifier: %s\n", objid);
- }
- }
- if (gotroot == 0) {
- memmove((char *)root, (char *)objid_mib, sizeof(objid_mib));
- rootlen = sizeof(objid_mib) / sizeof(oid);
- gotroot = 1;
- }
- }
-
- memset(&session, 0, sizeof(struct snmp_session));
- session.peername = a1->value.str.val;
-
- session.version = SNMP_VERSION_1;
- /*
- * FIXME: potential memory leak
- * This is a workaround for an "artifact" (Mike Slifcak)
- * in (at least) ucd-snmp 3.6.1 which frees
- * memory it did not allocate
- */
-#ifdef UCD_SNMP_HACK
- session.community = (u_char *) strdup(a2->value.str.val);
-#else
- session.community = (u_char *) a2->value.str.val;
-#endif
- session.community_len = a2->value.str.len;
- session.retries = retries;
- session.timeout = timeout;
-
- session.authenticator = NULL;
- snmp_synch_setup(&session);
- ss = snmp_open(&session);
- if (ss == NULL){
- php_error(E_WARNING,"Couldn't open snmp\n");
- RETURN_FALSE;
- }
- if (st>=2) {
- memmove((char *)name, (char *)root, rootlen * sizeof(oid));
- name_length = rootlen;
- /* prepare result array */
- array_init(return_value);
- }
-
- while(keepwalking) {
- keepwalking=0;
- if (st==1) pdu = snmp_pdu_create(SNMP_MSG_GET);
- else if (st==11) pdu = snmp_pdu_create(SNMP_MSG_SET);
- else if (st>=2) pdu = snmp_pdu_create(SNMP_MSG_GETNEXT);
-
- if (st==1) {
- name_length = MAX_NAME_LEN;
- if (!read_objid(objid, name, &name_length)) {
- php_error(E_WARNING,"Invalid object identifier: %s\n", objid);
- RETURN_FALSE;
- }
- }
- if (st!=11)
- snmp_add_null_var(pdu, name, name_length);
- else {
- if (snmp_add_var(pdu, name, name_length, type, value)) {
- php_error(E_WARNING,"Could not add variable: %s\n", name);
- RETURN_FALSE;
- }
- }
-
-retry:
- status = snmp_synch_response(ss, pdu, &response);
- if (status == STAT_SUCCESS) {
- if (response->errstat == SNMP_ERR_NOERROR) {
- for(vars = response->variables; vars; vars = vars->next_variable) {
- if (st>=2 && st!=11 && (vars->name_length < rootlen || memcmp(root, vars->name, rootlen * sizeof(oid))))
- continue; /* not part of this subtree */
-
- if (st!=11)
- sprint_value(buf,vars->name, vars->name_length, vars);
-#if 0
- Debug("snmp response is: %s\n",buf);
-#endif
- if (st==1) {
- RETVAL_STRING(buf,1);
- } else if (st==2) {
- /* Add to returned array */
- add_next_index_string(return_value,buf,1);
- } else if (st==3) {
- sprint_objid(buf2, vars->name, vars->name_length);
- add_assoc_string(return_value,buf2,buf,1);
- }
- if (st>=2 && st!=11) {
- if (vars->type != SNMP_ENDOFMIBVIEW && vars->type != SNMP_NOSUCHOBJECT && vars->type != SNMP_NOSUCHINSTANCE) {
- memmove((char *)name, (char *)vars->name,vars->name_length * sizeof(oid));
- name_length = vars->name_length;
- keepwalking = 1;
- }
- }
- }
- } else {
- if (st!=2 || response->errstat != SNMP_ERR_NOSUCHNAME) {
- php_error(E_WARNING,"Error in packet.\nReason: %s\n", snmp_errstring(response->errstat));
- if (response->errstat == SNMP_ERR_NOSUCHNAME) {
- for(count=1, vars = response->variables; vars && count != response->errindex;
- vars = vars->next_variable, count++);
- if (vars) sprint_objid(buf,vars->name, vars->name_length);
- php_error(E_WARNING,"This name does not exist: %s\n",buf);
- }
- if (st==1) {
- if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GET)) != NULL) goto retry;
- } else if (st==11) {
- if ((pdu = snmp_fix_pdu(response, SNMP_MSG_SET)) != NULL) goto retry;
- } else if (st>=2) {
- if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GETNEXT)) != NULL) goto retry;
- }
- RETURN_FALSE;
- }
- }
- } else if (status == STAT_TIMEOUT) {
- php_error(E_WARNING,"No Response from %s\n", a1->value.str.val);
- RETURN_FALSE;
- } else { /* status == STAT_ERROR */
- php_error(E_WARNING,"An error occurred, Quitting\n");
- RETURN_FALSE;
- }
- if (response) snmp_free_pdu(response);
- } /* keepwalking */
- snmp_close(ss);
-}
-
-/* {{{ proto string snmpget(string host, string community, string object_id [, int timeout [, int retries]])
-Fetch an SNMP object */
-PHP_FUNCTION(snmpget) {
- _php3_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
-}
-/* }}} */
-
-/* {{{ proto string snmpwalk(string host, string community, string object_id [, int timeout [, int retries]])
-Return all objects under the specified object id */
-PHP_FUNCTION(snmpwalk) {
- return _php3_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,2);
-}
-/* }}} */
-
-/* {{{ proto string snmprealwalk(string host, string community, string object_id [, int timeout [, int retries]])
-Return all objects including their respective object id withing the specified one */
-PHP_FUNCTION(snmprealwalk)
-{
- return _php3_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,3);
-}
-/* }}} */
-
-/* {{{ proto string snmprealoid(string host, string community, string object_id [, int timeout [, int retries]])
-Return all objects including their respective object id withing the specified one */
-PHP_FUNCTION(snmpwalkoid)
-{
- _php3_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,4);
-}
-/* }}} */
-
-/* {{{ proto int snmp_get_quick_print(void)
-Return the current status of quick_print */
-PHP_FUNCTION(snmp_get_quick_print)
-{
- _php3_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,9);
-}
-/* }}} */
-
-/* {{{ proto void snmp_set_quick_print(int quick_print)
-Return all objects including their respective object id withing the specified one */
-PHP_FUNCTION(snmp_set_quick_print)
-{
- _php3_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,10);
-}
-/* }}} */
-
-/* {{{ proto int snmpset(string host, string community, string object_id, string type, mixed value [, int timeout [, int retries]])
-Set the value of a SNMP object */
-PHP_FUNCTION(snmpset) {
- _php3_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,11);
-}
-/* }}} */
-
-#endif
-
-/*
-* Local variables:
-* tab-width: 4
-* c-basic-offset: 4
-* End:
-*/
diff --git a/ext/snmp/winsnmp.c b/ext/snmp/winsnmp.c
deleted file mode 100644
index fd6c5932ec..0000000000
--- a/ext/snmp/winsnmp.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
-Created from the snmputil sample in the Microsoft SDK for NT
-*/
-
-#include "php.h"
-#if COMPILE_DL
-#include "../phpdl.h"
-#include "functions/dl.h"
-#endif
-#include "php3_snmp.h"
-#include <sys/types.h>
-
-#include <windows.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <malloc.h>
-
-#if HAVE_SNMP
-
-#include <snmp.h>
-#include <mgmtapi.h>
-
-
-function_entry snmp_functions[] = {
- {"snmpget", php3_snmpget, NULL},
- {"snmpwalk", php3_snmpwalk, NULL},
- {NULL,NULL,NULL}
-};
-
-php3_module_entry snmp_module_entry = {
- "SNMP",snmp_functions,NULL,NULL,NULL,NULL,NULL,0,0,0,NULL
-};
-
-#if COMPILE_DL
-DLEXPORT php3_module_entry *get_module() { return &snmp_module_entry; }
-#endif
-
-#define GET 1
-#define WALK 2
-#define GETNEXT 3
-
-#define TIMEOUT 6000 /* milliseconds */
-#define RETRIES 3
-
-
-void _php3_snmp(INTERNAL_FUNCTION_PARAMETERS, int st) {
- pval *a1, *a2, *a3;
- INT operation;
- LPSTR agent;
- LPSTR community;
- RFC1157VarBindList variableBindings;
- LPSNMP_MGR_SESSION session;
-
- INT timeout = TIMEOUT;
- INT retries = RETRIES;
-
- BYTE requestType;
- AsnInteger errorStatus;
- AsnInteger errorIndex;
- AsnObjectIdentifier oid;
- char *chkPtr = NULL;
-
- if (getParameters(ht, 3, &a1, &a2, &a3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(a1);
- convert_to_string(a2);
- convert_to_string(a3);
-
- agent=a1->value.str.val;
- community=a2->value.str.val;
- operation=st;
- SnmpMgrStrToOid(a3->value.str.val, &oid);
-
-/*
- I've limited this to only one oid, but we can create a
- list of oid's here, and expand the function to take multiple
- oid's
-*/
- variableBindings.list->name = oid;
- variableBindings.list->value.asnType = ASN_NULL;
- variableBindings.len = 1;
-
-/* Establish a SNMP session to communicate with the remote agent. The
- community, communications timeout, and communications retry count
- for the session are also required.
-*/
- if ((session = SnmpMgrOpen(agent, community, timeout, retries)) == NULL){
- php_error(E_WARNING,"error on SnmpMgrOpen %d\n", GetLastError());
- }
-
- /* Determine and perform the requested operation.*/
- if (operation == GET || operation == GETNEXT){
- /* Get and GetNext are relatively simple operations to perform.
- Simply initiate the request and process the result and/or
- possible error conditions. */
-
- if (operation == GET){
- requestType = ASN_RFC1157_GETREQUEST;
- } else {
- requestType = ASN_RFC1157_GETNEXTREQUEST;
- }
-
- /* Request that the API carry out the desired operation.*/
- if (!SnmpMgrRequest(session, requestType, &variableBindings,
- &errorStatus, &errorIndex)){
- /* The API is indicating an error. */
- php_error(E_WARNING,"error on SnmpMgrRequest %d\n", GetLastError());
- } else {
- /* The API succeeded, errors may be indicated from the remote
- agent. */
- if (errorStatus > 0){
- php_error(E_WARNING,"Error: errorStatus=%d, errorIndex=%d\n",
- errorStatus, errorIndex);
- } else {
- /* Display the resulting variable bindings.*/
- UINT i;
- char *string = NULL;
-
- for(i=0; i < variableBindings.len; i++)
- {
- SnmpMgrOidToStr(&variableBindings.list[i].name, &string);
- php_printf("Variable = %s\n", string);
- if (string) SNMP_free(string);
-
- php_printf("Value = ");
- SnmpUtilPrintAsnAny(&variableBindings.list[i].value);
-
- php_printf("\n");
- } /* end for() */
- }
- }
-
- /* Free the variable bindings that have been allocated.*/
- SnmpUtilVarBindListFree(&variableBindings);
- }
- else if (operation == WALK)
- {
- /* Walk is a common term used to indicate that all MIB variables
- under a given OID are to be traversed and displayed. This is
- a more complex operation requiring tests and looping in addition
- to the steps for get/getnext above. */
- AsnObjectIdentifier root;
- AsnObjectIdentifier tempOid;
-
- SnmpUtilOidCpy(&root, &variableBindings.list[0].name);
- requestType = ASN_RFC1157_GETNEXTREQUEST;
-
- while(1)
- {
- if (!SnmpMgrRequest(session, requestType, &variableBindings,
- &errorStatus, &errorIndex)){
- /* The API is indicating an error.*/
- php_error(E_WARNING,"error on SnmpMgrRequest %d\n", GetLastError());
- break;
- }
- else
- {
- /* The API succeeded, errors may be indicated from the remote
- agent.
- Test for end of subtree or end of MIB. */
- if (errorStatus == SNMP_ERRORSTATUS_NOSUCHNAME ||
- SnmpUtilOidNCmp(&variableBindings.list[0].name,
- &root, root.idLength))
- {
- PUTS("End of MIB subtree.\n\n");
- break;
- }
-
- /* Test for general error conditions or sucesss. */
- if (errorStatus > 0){
- php_error(E_ERROR,"Error: errorStatus=%d, errorIndex=%d \n",
- errorStatus, errorIndex);
- break;
- }
- else
- {
- /* Display resulting variable binding for this iteration. */
- char *string = NULL;
-
- SnmpMgrOidToStr(&variableBindings.list[0].name, &string);
- php_printf("Variable = %s\n", string);
- if (string) SNMP_free(string);
-
- php_printf("Value = ");
- SnmpUtilPrintAsnAny(&variableBindings.list[0].value);
-
- php_printf("\n");
- }
- } /* end if () */
- /* Prepare for the next iteration. Make sure returned oid is
- preserved and the returned value is freed.
- */
- SnmpUtilOidCpy(&tempOid, &variableBindings.list[0].name);
- SnmpUtilVarBindFree(&variableBindings.list[0]);
- SnmpUtilOidCpy(&variableBindings.list[0].name, &tempOid);
- variableBindings.list[0].value.asnType = ASN_NULL;
- SnmpUtilOidFree(&tempOid);
- } /* end while() */
- /* Free the variable bindings that have been allocated.*/
- SnmpUtilVarBindListFree(&variableBindings);
- SnmpUtilOidFree(&root);
- } // end if (operation)
-
-
- /* Close SNMP session with the remote agent.*/
- if (!SnmpMgrClose(session)){
- php_error(E_WARNING,"error on SnmpMgrClose %d\n", GetLastError());
- }
-}
-
-DLEXPORT void php3_snmpget(INTERNAL_FUNCTION_PARAMETERS) {
- _php3_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
-}
-
-DLEXPORT void php3_snmpwalk(INTERNAL_FUNCTION_PARAMETERS) {
- _php3_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU,2);
-}
-
-
-#endif
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/Makefile.am b/ext/standard/Makefile.am
deleted file mode 100644
index f166405b91..0000000000
--- a/ext/standard/Makefile.am
+++ /dev/null
@@ -1,17 +0,0 @@
-## Process this file with automake to produce Makefile.in
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_standard.a
-libphpext_standard_a_SOURCES=\
- base64.c basic_functions.c browscap.c datetime.c dir.c \
- dns.c exec.c file.c filestat.c formatted_print.c fsock.c \
- html.c image.c info.c link.c mail.c math.c md5.c microtime.c \
- pack.c pageinfo.c rand.c reg.c soundex.c string.c \
- syslog.c type.c uniqid.c url.c iptc.c var.c quot_print.c \
- cyr_convert.c flock_compat.c crypt.c dl.c head.c post.c \
- parsedate.y lcg.c url_scanner.c metaphone.c
-
-$(srcdir)/url_scanner.c: $(srcdir)/url_scanner.re
- re2c -b $< > $@
-
-#number.o: number.c
-# $(CC) $(CFLAGS) -w@WARNING_LEVEL@ -c $< -o $@
diff --git a/ext/standard/base64.c b/ext/standard/base64.c
deleted file mode 100644
index d0a565fde4..0000000000
--- a/ext/standard/base64.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Jim Winstead (jimw@php.net) |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include <string.h>
-
-#include "php.h"
-#include "base64.h"
-
-static char base64_table[] =
- { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
- 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
- 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '\0'
- };
-static char base64_pad = '=';
-
-unsigned char *_php3_base64_encode(const unsigned char *string, int length, int *ret_length) {
- const unsigned char *current = string;
- int i = 0;
- unsigned char *result = (unsigned char *)emalloc(((length + 3 - length % 3) * 4 / 3 + 1) * sizeof(char));
-
- while (length > 2) { /* keep going until we have less than 24 bits */
- result[i++] = base64_table[current[0] >> 2];
- result[i++] = base64_table[((current[0] & 0x03) << 4) + (current[1] >> 4)];
- result[i++] = base64_table[((current[1] & 0x0f) << 2) + (current[2] >> 6)];
- result[i++] = base64_table[current[2] & 0x3f];
-
- current += 3;
- length -= 3; /* we just handle 3 octets of data */
- }
-
- /* now deal with the tail end of things */
- if (length != 0) {
- result[i++] = base64_table[current[0] >> 2];
- if (length > 1) {
- result[i++] = base64_table[((current[0] & 0x03) << 4) + (current[1] >> 4)];
- result[i++] = base64_table[(current[1] & 0x0f) << 2];
- result[i++] = base64_pad;
- }
- else {
- result[i++] = base64_table[(current[0] & 0x03) << 4];
- result[i++] = base64_pad;
- result[i++] = base64_pad;
- }
- }
- if(ret_length) {
- *ret_length = i;
- }
- result[i] = '\0';
- return result;
-}
-
-/* as above, but backwards. :) */
-unsigned char *_php3_base64_decode(const unsigned char *string, int length, int *ret_length) {
- const unsigned char *current = string;
- int ch, i = 0, j = 0, k;
- /* this sucks for threaded environments */
- static short reverse_table[256];
- static int table_built;
- unsigned char *result;
-
- if (++table_built == 1) {
- char *chp;
- for(ch = 0; ch < 256; ch++) {
- chp = strchr(base64_table, ch);
- if(chp) {
- reverse_table[ch] = chp - base64_table;
- } else {
- reverse_table[ch] = -1;
- }
- }
- }
-
- result = (unsigned char *)emalloc((length / 4 * 3 + 1) * sizeof(char));
- if (result == NULL) {
- return NULL;
- }
-
- /* run through the whole string, converting as we go */
- while ((ch = *current++) != '\0') {
- if (ch == base64_pad) break;
- ch = reverse_table[ch];
- if (ch < 0) continue;
-
- switch(i % 4) {
- case 0:
- result[j] = ch << 2;
- break;
- case 1:
- result[j++] |= ch >> 4;
- result[j] = (ch & 0x0f) << 4;
- break;
- case 2:
- result[j++] |= ch >>2;
- result[j] = (ch & 0x03) << 6;
- break;
- case 3:
- result[j++] |= ch;
- break;
- }
- i++;
- }
-
- k = j;
- /* mop things up if we ended on a boundary */
- if (ch == base64_pad) {
- switch(i % 4) {
- case 0:
- case 1:
- efree(result);
- return NULL;
- case 2:
- k++;
- case 3:
- result[k++] = 0;
- }
- }
- if(ret_length) {
- *ret_length = j;
- }
- result[k] = '\0';
- return result;
-}
-
-/* {{{ proto string base64_encode(string str)
- Encodes string using MIME base64 algorithm */
-PHP_FUNCTION(base64_encode) {
- pval *string;
- unsigned char *result;
- int ret_length;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht,1,&string) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(string);
- result = _php3_base64_encode(string->value.str.val, string->value.str.len, &ret_length);
- if (result != NULL) {
- return_value->value.str.val = result;
- return_value->value.str.len = ret_length;
- return_value->type = IS_STRING;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-
-/* {{{ proto string base64_decode(string str)
- Decodes string using MIME base64 algorithm */
-PHP_FUNCTION(base64_decode) {
- pval *string;
- unsigned char *result;
- int ret_length;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht,1,&string) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(string);
- result = _php3_base64_decode(string->value.str.val, string->value.str.len, &ret_length);
- if (result != NULL) {
- return_value->value.str.val = result;
- return_value->value.str.len = ret_length;
- return_value->type = IS_STRING;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/base64.h b/ext/standard/base64.h
deleted file mode 100644
index b71898dac3..0000000000
--- a/ext/standard/base64.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Author: Jim Winstead (jimw@php.net) |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#ifndef _BASE64_h
-#define _BASE64_h
-
-PHP_FUNCTION(base64_decode);
-PHP_FUNCTION(base64_encode);
-
-extern unsigned char *_php3_base64_encode(const unsigned char *, int, int *);
-extern unsigned char *_php3_base64_decode(const unsigned char *, int, int *);
-
-#endif /* _BASE64_h */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
deleted file mode 100644
index e75f0f4ff4..0000000000
--- a/ext/standard/basic_functions.c
+++ /dev/null
@@ -1,3313 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Andi Gutmans <andi@zend.com> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-
-#include "php.h"
-#include "php_ini.h"
-#include "internal_functions_registry.h"
-#include "php3_standard.h"
-#include "zend_operators.h"
-#include <stdarg.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include <stdio.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#if HAVE_STRING_H
-#include <string.h>
-#else
-#include <strings.h>
-#endif
-#include "safe_mode.h"
-#if WIN32|WINNT
-#include "win32/unistd.h"
-#endif
-#include "zend_globals.h"
-
-#include "php_globals.h"
-#include "SAPI.h"
-
-#if APACHE
-/*
- ap_compat.h does a
- #define md5 ap_md5
- which "kills" out md5 function.
-*/
-#ifdef md5
-#undef md5
-#endif
-#endif
-
-static unsigned char second_and_third_args_force_ref[] = { 3, BYREF_NONE, BYREF_FORCE, BYREF_FORCE };
-/* uncomment this if/when we actually need it - tired of seeing the warning
-static unsigned char third_and_fourth_args_force_ref[] = { 4, BYREF_NONE, BYREF_NONE, BYREF_FORCE, BYREF_FORCE };
-*/
-static pval *user_compare_func_name;
-static HashTable *user_shutdown_function_names;
-
-typedef struct _php_shutdown_function_entry {
- zval **arguments;
- int arg_count;
-} php_shutdown_function_entry;
-
-/* some prototypes for local functions */
-int user_shutdown_function_dtor(php_shutdown_function_entry *shutdown_function_entry);
-void php3_call_shutdown_functions(void);
-
-function_entry basic_functions[] = {
- PHP_FE(intval, NULL)
- PHP_FE(doubleval, NULL)
- PHP_FE(strval, NULL)
- PHP_FE(define, NULL)
- PHP_FE(defined, NULL)
- PHP_FE(bin2hex, NULL)
- PHP_FE(toggle_short_open_tag, NULL)
- PHP_FE(sleep, NULL)
- PHP_FE(usleep, NULL)
-
- PHP_FE(ksort, first_arg_force_ref)
- PHP_FE(asort, first_arg_force_ref)
- PHP_FE(arsort, first_arg_force_ref)
- PHP_FE(sort, first_arg_force_ref)
- PHP_FE(rsort, first_arg_force_ref)
- PHP_FE(usort, first_arg_force_ref)
- PHP_FE(uasort, first_arg_force_ref)
- PHP_FE(uksort, first_arg_force_ref)
- PHP_FE(array_walk, first_arg_force_ref)
- PHP_FALIAS(sizeof, count, first_arg_allow_ref)
- PHP_FE(count, first_arg_allow_ref)
- PHP_FE(end, first_arg_force_ref)
- PHP_FE(prev, first_arg_force_ref)
- PHP_FE(next, first_arg_force_ref)
- PHP_FE(reset, first_arg_force_ref)
- PHP_FE(current, first_arg_force_ref)
- PHP_FE(key, first_arg_force_ref)
- PHP_FE(each, first_arg_force_ref)
- PHP_FALIAS(pos, current, first_arg_force_ref)
-
- PHP_FE(time, NULL)
- PHP_FE(mktime, NULL)
- PHP_FE(gmmktime, NULL)
-#if HAVE_STRFTIME
- PHP_FE(strftime, NULL)
-#endif
- PHP_FE(strtotime, NULL)
- PHP_FE(date, NULL)
- PHP_FE(gmdate, NULL)
- PHP_FE(getdate, NULL)
- PHP_FE(checkdate, NULL)
-
- PHP_FE(flush, NULL)
-
- PHP_FE(gettype, NULL)
- PHP_FE(settype, first_arg_force_ref)
-
- PHP_FE(min, NULL)
- PHP_FE(max, NULL)
-
- PHP_FE(getimagesize, NULL)
-
- PHP_FE(htmlspecialchars, NULL)
- PHP_FE(htmlentities, NULL)
-
- PHP_FE(md5, NULL)
-
- PHP_FE(iptcparse, NULL)
- PHP_FE(iptcembed, NULL)
-
- PHP_FE(phpinfo, NULL)
- PHP_FE(phpversion, NULL)
- PHP_FE(phpcredits, NULL)
-
- PHP_FE(strlen, NULL)
- PHP_FE(strcmp, NULL)
- PHP_FE(strspn, NULL)
- PHP_FE(strcspn, NULL)
- PHP_FE(strcasecmp, NULL)
- PHP_FE(strtok, NULL)
- PHP_FE(strtoupper, NULL)
- PHP_FE(strtolower, NULL)
- PHP_FE(strpos, NULL)
- PHP_FE(strrpos, NULL)
- PHP_FE(strrev, NULL)
- PHP_FE(hebrev, NULL)
- PHP_FE(hebrevc, NULL)
- PHP_FE(nl2br, NULL)
- PHP_FE(basename, NULL)
- PHP_FE(dirname, NULL)
- PHP_FE(stripslashes, NULL)
- PHP_FE(stripcslashes, NULL)
- PHP_FE(strstr, NULL)
- PHP_FE(stristr, NULL)
- PHP_FE(strrchr, NULL)
- PHP_FE(substr, NULL)
- PHP_FE(quotemeta, NULL)
- PHP_FE(ucfirst, NULL)
- PHP_FE(ucwords, NULL)
- PHP_FE(strtr, NULL)
- PHP_FE(addslashes, NULL)
- PHP_FE(addcslashes, NULL)
- PHP_FE(chop, NULL)
- PHP_FE(str_replace, NULL)
- PHP_FE(chunk_split, NULL)
- PHP_FE(trim, NULL)
- PHP_FE(ltrim, NULL)
- PHP_FE(strip_tags, NULL)
- PHP_FE(similar_text, NULL)
- PHP_FE(explode, NULL)
- PHP_FE(implode, NULL)
- PHP_FE(setlocale, NULL)
- PHP_FE(soundex, NULL)
- PHP_FE(chr, NULL)
- PHP_FE(ord, NULL)
- PHP_FE(parse_str, NULL)
- PHP_FALIAS(rtrim, chop, NULL)
- PHP_FALIAS(strchr, strstr, NULL)
- PHP_NAMED_FE(sprintf, php3_user_sprintf, NULL)
- PHP_NAMED_FE(printf, php3_user_printf, NULL)
-
- PHP_FE(parse_url, NULL)
- PHP_FE(urlencode, NULL)
- PHP_FE(urldecode, NULL)
- PHP_FE(rawurlencode, NULL)
- PHP_FE(rawurldecode, NULL)
-
- PHP_FE(readlink, NULL)
- PHP_FE(linkinfo, NULL)
- PHP_FE(symlink, NULL)
- PHP_FE(link, NULL)
- PHP_FE(unlink, NULL)
-
- PHP_FE(exec, second_and_third_args_force_ref)
- PHP_FE(system, second_arg_force_ref)
- PHP_FE(escapeshellcmd, NULL)
- PHP_FE(passthru, second_arg_force_ref)
- PHP_FE(shell_exec, NULL)
-
- PHP_FE(rand, NULL)
- PHP_FE(srand, NULL)
- PHP_FE(getrandmax, NULL)
- PHP_FE(mt_rand, NULL)
- PHP_FE(mt_srand, NULL)
- PHP_FE(mt_getrandmax, NULL)
-
- PHP_FE(gethostbyaddr, NULL)
- PHP_FE(gethostbyname, NULL)
- PHP_FE(gethostbynamel, NULL)
-#if !(WIN32|WINNT)||HAVE_BINDLIB
- PHP_FE(checkdnsrr, NULL)
- PHP_FE(getmxrr, second_and_third_args_force_ref)
-#endif
-
- PHP_FE(error_reporting, NULL)
-
- PHP_FE(getmyuid, NULL)
- PHP_FE(getmypid, NULL)
- PHP_FE(getmyinode, NULL)
- PHP_FE(getlastmod, NULL)
- /*getmyiid is here for forward compatibility with 3.1
- See pageinfo.c in 3.1 for more information*/
- /* {"getmyiid", php3_getmypid, NULL}, */
-
- PHP_FE(base64_decode, NULL)
- PHP_FE(base64_encode, NULL)
-
- PHP_FE(abs, NULL)
- PHP_FE(ceil, NULL)
- PHP_FE(floor, NULL)
- PHP_FE(round, NULL)
- PHP_FE(sin, NULL)
- PHP_FE(cos, NULL)
- PHP_FE(tan, NULL)
- PHP_FE(asin, NULL)
- PHP_FE(acos, NULL)
- PHP_FE(atan, NULL)
- PHP_FE(atan2, NULL)
- PHP_FE(pi, NULL)
- PHP_FE(pow, NULL)
- PHP_FE(exp, NULL)
- PHP_FE(log, NULL)
- PHP_FE(log10, NULL)
- PHP_FE(sqrt, NULL)
- PHP_FE(deg2rad, NULL)
- PHP_FE(rad2deg, NULL)
- PHP_FE(bindec, NULL)
- PHP_FE(hexdec, NULL)
- PHP_FE(octdec, NULL)
- PHP_FE(decbin, NULL)
- PHP_FE(decoct, NULL)
- PHP_FE(dechex, NULL)
- PHP_FE(base_convert, NULL)
- PHP_FE(number_format, NULL)
-
- PHP_FE(getenv, NULL)
-#ifdef HAVE_PUTENV
- PHP_FE(putenv, NULL)
-#endif
-
- PHP_FE(microtime, NULL)
- PHP_FE(gettimeofday, NULL)
- PHP_FE(getrusage, NULL)
-
- PHP_FE(uniqid, NULL)
-
- PHP_FE(quoted_printable_decode, NULL)
-
- PHP_FE(convert_cyr_string, NULL)
- PHP_FE(get_current_user, NULL)
- PHP_FE(set_time_limit, NULL)
-
- PHP_FE(get_cfg_var, NULL)
- PHP_FALIAS(magic_quotes_runtime, set_magic_quotes_runtime, NULL)
- PHP_FE(set_magic_quotes_runtime, NULL)
- PHP_FE(get_magic_quotes_gpc, NULL)
- PHP_FE(get_magic_quotes_runtime, NULL)
-
- PHP_FE(is_long, first_arg_allow_ref)
- PHP_FALIAS(is_int, is_long, first_arg_allow_ref)
- PHP_FALIAS(is_integer, is_long, first_arg_allow_ref)
- PHP_FALIAS(is_float, is_double, first_arg_allow_ref)
- PHP_FE(is_double, first_arg_allow_ref)
- PHP_FALIAS(is_real, is_double, first_arg_allow_ref)
- PHP_FE(is_string, first_arg_allow_ref)
- PHP_FE(is_array, first_arg_allow_ref)
- PHP_FE(is_object, first_arg_allow_ref)
- PHP_FE(get_class, NULL)
- PHP_FE(get_parent_class, NULL)
- PHP_FE(method_exists, NULL)
-
- PHP_FE(leak, NULL)
- PHP_FE(error_log, NULL)
- PHP_FE(call_user_func, NULL)
- PHP_FE(call_user_method, NULL)
-
- PHP_FE(var_dump, NULL)
- PHP_FE(serialize, first_arg_allow_ref)
- PHP_FE(unserialize, first_arg_allow_ref)
-
- PHP_FE(register_shutdown_function, NULL)
-
- PHP_FE(highlight_file, NULL)
- PHP_NAMED_FE(show_source, php3_highlight_file, NULL)
- PHP_FE(highlight_string, NULL)
-
- PHP_FE(ob_start, NULL)
- PHP_FE(ob_end_flush, NULL)
- PHP_FE(ob_end_clean, NULL)
- PHP_FE(ob_get_contents, NULL)
-
- PHP_FE(ini_get, NULL)
- PHP_FE(ini_alter, NULL)
- PHP_FE(ini_restore, NULL)
-
- PHP_FE(print_r, NULL)
-
- PHP_FE(setcookie, NULL)
- PHP_NAMED_FE(header, PHP_FN(Header), NULL)
- PHP_FE(headers_sent, NULL)
-
- PHP_FE(function_exists, NULL)
- PHP_FE(in_array, NULL)
- PHP_FE(extract, NULL)
- PHP_FE(compact, NULL)
- PHP_FE(array_push, first_arg_force_ref)
- PHP_FE(array_pop, first_arg_force_ref)
- PHP_FE(array_shift, first_arg_force_ref)
- PHP_FE(array_unshift, first_arg_force_ref)
- PHP_FE(array_splice, first_arg_force_ref)
- PHP_FE(array_slice, NULL)
- PHP_FE(array_merge, NULL)
- PHP_FE(array_keys, NULL)
- PHP_FE(array_values, NULL)
- PHP_FE(array_count_values, NULL)
-
- PHP_FE(connection_aborted, NULL)
- PHP_FE(connection_timeout, NULL)
- PHP_FE(connection_status, NULL)
- PHP_FE(ignore_user_abort, NULL)
-
- {NULL, NULL, NULL}
-};
-
-
-PHP_INI_BEGIN()
- PHP_INI_ENTRY1("highlight.string", "#foobar", PHP_INI_ALL, NULL, NULL)
- PHP_INI_ENTRY1("test2", "testing", PHP_INI_SYSTEM, NULL, NULL)
-PHP_INI_END()
-
-
-php3_module_entry basic_functions_module = {
- "Basic Functions", /* extension name */
- basic_functions, /* function list */
- PHP_MINIT(basic), /* process startup */
- PHP_MSHUTDOWN(basic), /* process shutdown */
- PHP_RINIT(basic), /* request startup */
- PHP_RSHUTDOWN(basic), /* request shutdown */
- NULL, /* extension info */
- STANDARD_MODULE_PROPERTIES
-};
-
-#ifdef HAVE_PUTENV
-static HashTable putenv_ht;
-
-static int _php3_putenv_destructor(putenv_entry *pe)
-{
- if (pe->previous_value) {
- putenv(pe->previous_value);
- } else {
-# if HAVE_UNSETENV
- unsetenv(pe->key);
-# else
- char **env;
-
- for (env = environ; env != NULL && *env != NULL; env++) {
- if (!strncmp(*env,pe->key,pe->key_len) && (*env)[pe->key_len]=='=') { /* found it */
- *env = "";
- break;
- }
- }
-# endif
- }
- efree(pe->putenv_string);
- efree(pe->key);
- return 1;
-}
-#endif
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-#define EXTR_OVERWRITE 0
-#define EXTR_SKIP 1
-#define EXTR_PREFIX_SAME 2
-#define EXTR_PREFIX_ALL 3
-
-void test_class_startup();
-
-PHP_MINIT_FUNCTION(basic)
-{
- ELS_FETCH();
-
- REGISTER_DOUBLE_CONSTANT("M_PI", M_PI, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("EXTR_OVERWRITE", EXTR_OVERWRITE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("EXTR_SKIP", EXTR_SKIP, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("EXTR_PREFIX_SAME", EXTR_PREFIX_SAME, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("EXTR_PREFIX_ALL", EXTR_PREFIX_ALL, CONST_CS | CONST_PERSISTENT);
-
- test_class_startup();
- REGISTER_INI_ENTRIES();
-
- register_phpinfo_constants(INIT_FUNC_ARGS_PASSTHRU);
- return SUCCESS;
-}
-
-
-PHP_MSHUTDOWN_FUNCTION(basic)
-{
- UNREGISTER_INI_ENTRIES();
- return SUCCESS;
-}
-
-
-PHP_RINIT_FUNCTION(basic)
-{
- strtok_string = NULL;
-#ifdef HAVE_PUTENV
- if (zend_hash_init(&putenv_ht, 1, NULL, (int (*)(void *)) _php3_putenv_destructor, 0) == FAILURE) {
- return FAILURE;
- }
-#endif
- user_compare_func_name=NULL;
- user_shutdown_function_names=NULL;
- return SUCCESS;
-}
-
-
-PHP_RSHUTDOWN_FUNCTION(basic)
-{
- STR_FREE(strtok_string);
-#ifdef HAVE_PUTENV
- zend_hash_destroy(&putenv_ht);
-#endif
-
- return SUCCESS;
-}
-
-/********************
- * System Functions *
- ********************/
-
-PHP_FUNCTION(getenv)
-{
-#if FHTTPD
- int i;
-#endif
- pval *str;
- char *ptr;
- SLS_FETCH();
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str);
-
-#if FHTTPD
- ptr=NULL;
- if (str->type == IS_STRING && req){
- for(i=0;i<req->nlines;i++){
- if (req->lines[i].paramc>1){
- if (req->lines[i].params[0]){
- if (!strcmp(req->lines[i].params[0],
- str->value.str.val)){
- ptr=req->lines[i].params[1];
- i=req->nlines;
- }
- }
- }
- }
- }
- if (!ptr) ptr = getenv(str->value.str.val);
- if (ptr
-#else
-
- if (str->type == IS_STRING &&
-#if APACHE
- ((ptr = (char *)table_get(((request_rec *) SG(server_context))->subprocess_env, str->value.str.val)) || (ptr = getenv(str->value.str.val)))
-#endif
-#if CGI_BINARY
- (ptr = getenv(str->value.str.val))
-#endif
-
-#if USE_SAPI
- (ptr = sapi_rqst->getenv(sapi_rqst->scid,str->value.str.val))
-#endif
-#endif
- ) {
- RETURN_STRING(ptr,1);
- }
- RETURN_FALSE;
-}
-
-
-#ifdef HAVE_PUTENV
-PHP_FUNCTION(putenv)
-{
-
- pval *str;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str);
-
- if (str->value.str.val && *(str->value.str.val)) {
- int ret;
- char *p,**env;
- putenv_entry pe;
-
- pe.putenv_string = estrndup(str->value.str.val,str->value.str.len);
- pe.key = str->value.str.val;
- if ((p=strchr(pe.key,'='))) { /* nullify the '=' if there is one */
- *p='\0';
- }
- pe.key_len = strlen(pe.key);
- pe.key = estrndup(pe.key,pe.key_len);
-
- zend_hash_del(&putenv_ht,pe.key,pe.key_len+1);
-
- /* find previous value */
- pe.previous_value = NULL;
- for (env = environ; env != NULL && *env != NULL; env++) {
- if (!strncmp(*env,pe.key,pe.key_len) && (*env)[pe.key_len]=='=') { /* found it */
- pe.previous_value = *env;
- break;
- }
- }
-
- if ((ret=putenv(pe.putenv_string))==0) { /* success */
- zend_hash_add(&putenv_ht,pe.key,pe.key_len+1,(void **) &pe,sizeof(putenv_entry),NULL);
- RETURN_TRUE;
- } else {
- efree(pe.putenv_string);
- efree(pe.key);
- RETURN_FALSE;
- }
- }
-}
-#endif
-
-
-PHP_FUNCTION(error_reporting)
-{
- pval *arg;
- int old_error_reporting;
- ELS_FETCH();
-
- old_error_reporting = EG(error_reporting);
- switch (ARG_COUNT(ht)) {
- case 0:
- break;
- case 1:
- if (getParameters(ht,1,&arg) == FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(arg);
- EG(error_reporting)=arg->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- RETVAL_LONG(old_error_reporting);
-}
-
-PHP_FUNCTION(toggle_short_open_tag)
-{
- /* has to be implemented within Zend */
-#if 0
- pval *value;
- int ret;
-
- ret = php3_ini.short_open_tag;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht,1,&value) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(value);
- php3_ini.short_open_tag = value->value.lval;
- RETURN_LONG(ret);
-#endif
-}
-
-/*******************
- * Basic Functions *
- *******************/
-
-PHP_FUNCTION(intval)
-{
- pval *num, *arg_base;
- int base;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- base = 10;
- break;
- case 2:
- if (getParameters(ht, 2, &num, &arg_base) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg_base);
- base = arg_base->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long_base(num, base);
- *return_value = *num;
-}
-
-
-PHP_FUNCTION(doubleval)
-{
- pval *num;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_double(num);
- *return_value = *num;
-}
-
-
-PHP_FUNCTION(strval)
-{
- pval *num;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(num);
- *return_value = *num;
- pval_copy_constructor(return_value);
-}
-
-static int array_key_compare(const void *a, const void *b)
-{
- Bucket *first;
- Bucket *second;
- int min, r;
-
- first = *((Bucket **) a);
- second = *((Bucket **) b);
-
- if (first->nKeyLength == 0 && second->nKeyLength == 0) {
- return (first->h - second->h);
- } else if (first->nKeyLength == 0) {
- return -1;
- } else if (second->nKeyLength == 0) {
- return 1;
- }
- min = MIN(first->nKeyLength, second->nKeyLength);
- if ((r = memcmp(first->arKey, second->arKey, min)) == 0) {
- return (first->nKeyLength - second->nKeyLength);
- } else {
- return r;
- }
-}
-
-
-PHP_FUNCTION(ksort)
-{
- pval *array;
- HashTable *target_hash;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- target_hash = HASH_OF(array);
- if (!target_hash) {
- php_error(E_WARNING, "Wrong datatype in ksort() call");
- return;
- }
- if (!ParameterPassedByReference(ht,1)) {
- php_error(E_WARNING, "Array not passed by reference in call to ksort()");
- return;
- }
- if (zend_hash_sort(target_hash, array_key_compare,0) == FAILURE) {
- return;
- }
- RETURN_TRUE;
-}
-
-
-PHP_FUNCTION(count)
-{
- pval **array;
- HashTable *target_hash;
-
- if (ARG_COUNT(ht) != 1 || getParametersEx(1, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- target_hash = HASH_OF(*array);
- if (!target_hash) {
- if ((*array)->type == IS_STRING && (*array)->value.str.val==undefined_variable_string) {
- RETURN_LONG(0);
- } else {
- RETURN_LONG(1);
- }
- }
-
- RETURN_LONG(zend_hash_num_elements(target_hash));
-}
-
-
-/* Numbers are always smaller than strings int this function as it
- * anyway doesn't make much sense to compare two different data types.
- * This keeps it consistant and simple.
- */
-static int array_data_compare(const void *a, const void *b)
-{
- Bucket *f;
- Bucket *s;
- pval *first;
- pval *second;
- double dfirst, dsecond;
-
- f = *((Bucket **) a);
- s = *((Bucket **) b);
-
- first = *((pval **) f->pData);
- second = *((pval **) s->pData);
-
- if ((first->type == IS_LONG || first->type == IS_DOUBLE) &&
- (second->type == IS_LONG || second->type == IS_DOUBLE)) {
- if (first->type == IS_LONG) {
- dfirst = (double) first->value.lval;
- } else {
- dfirst = first->value.dval;
- }
- if (second->type == IS_LONG) {
- dsecond = (double) second->value.lval;
- } else {
- dsecond = second->value.dval;
- }
- if (dfirst < dsecond) {
- return -1;
- } else if (dfirst == dsecond) {
- return 0;
- } else {
- return 1;
- }
- }
- if ((first->type == IS_LONG || first->type == IS_DOUBLE) &&
- second->type == IS_STRING) {
- return -1;
- } else if ((first->type == IS_STRING) &&
- (second->type == IS_LONG || second->type == IS_DOUBLE)) {
- return 1;
- }
- if (first->type == IS_STRING && second->type == IS_STRING) {
- return strcmp(first->value.str.val, second->value.str.val);
- }
- return 0; /* Anything else is equal as it can't be compared */
-}
-
-static int array_reverse_data_compare(const void *a, const void *b)
-{
- return array_data_compare(a,b)*-1;
-}
-
-PHP_FUNCTION(asort)
-{
- pval *array;
- HashTable *target_hash;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- target_hash = HASH_OF(array);
- if (!target_hash) {
- php_error(E_WARNING, "Wrong datatype in asort() call");
- return;
- }
- if (!ParameterPassedByReference(ht,1)) {
- php_error(E_WARNING, "Array not passed by reference in call to asort()");
- return;
- }
- if (zend_hash_sort(target_hash, array_data_compare,0) == FAILURE) {
- return;
- }
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(arsort)
-{
- pval *array;
- HashTable *target_hash;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- target_hash = HASH_OF(array);
- if (!target_hash) {
- php_error(E_WARNING, "Wrong datatype in arsort() call");
- return;
- }
- if (!ParameterPassedByReference(ht,1)) {
- php_error(E_WARNING, "Array not passed by reference in call to arsort()");
- return;
- }
- if (zend_hash_sort(target_hash, array_reverse_data_compare,0) == FAILURE) {
- return;
- }
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(sort)
-{
- pval *array;
- HashTable *target_hash;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- target_hash = HASH_OF(array);
- if (!target_hash) {
- php_error(E_WARNING, "Wrong datatype in sort() call");
- return;
- }
- if (!ParameterPassedByReference(ht,1)) {
- php_error(E_WARNING, "Array not passed by reference in call to sort()");
- return;
- }
- if (zend_hash_sort(target_hash, array_data_compare,1) == FAILURE) {
- return;
- }
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(rsort)
-{
- pval *array;
- HashTable *target_hash;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- target_hash = HASH_OF(array);
- if (!target_hash) {
- php_error(E_WARNING, "Wrong datatype in rsort() call");
- return;
- }
- if (!ParameterPassedByReference(ht,1)) {
- php_error(E_WARNING, "Array not passed by reference in call to rsort()");
- return;
- }
- if (zend_hash_sort(target_hash, array_reverse_data_compare,1) == FAILURE) {
- return;
- }
- RETURN_TRUE;
-}
-
-
-static int array_user_compare(const void *a, const void *b)
-{
- Bucket *f;
- Bucket *s;
- pval **args[2];
- pval retval;
- CLS_FETCH();
-
- f = *((Bucket **) a);
- s = *((Bucket **) b);
-
- args[0] = (pval **) f->pData;
- args[1] = (pval **) s->pData;
-
- if (call_user_function_ex(CG(function_table), NULL, user_compare_func_name, &retval, 2, args, 0)==SUCCESS) {
- convert_to_long(&retval);
- return retval.value.lval;
- } else {
- return 0;
- }
-}
-
-
-PHP_FUNCTION(usort)
-{
- pval *array;
- pval *old_compare_func;
- HashTable *target_hash;
-
- old_compare_func = user_compare_func_name;
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &array, &user_compare_func_name) == FAILURE) {
- user_compare_func_name = old_compare_func;
- WRONG_PARAM_COUNT;
- }
- target_hash = HASH_OF(array);
- if (!target_hash) {
- php_error(E_WARNING, "Wrong datatype in usort() call");
- user_compare_func_name = old_compare_func;
- return;
- }
- convert_to_string(user_compare_func_name);
- if (zend_hash_sort(target_hash, array_user_compare, 1) == FAILURE) {
- user_compare_func_name = old_compare_func;
- return;
- }
- user_compare_func_name = old_compare_func;
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(uasort)
-{
- pval *array;
- pval *old_compare_func;
- HashTable *target_hash;
-
- old_compare_func = user_compare_func_name;
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &array, &user_compare_func_name) == FAILURE) {
- user_compare_func_name = old_compare_func;
- WRONG_PARAM_COUNT;
- }
- target_hash = HASH_OF(array);
- if (!target_hash) {
- php_error(E_WARNING, "Wrong datatype in uasort() call");
- user_compare_func_name = old_compare_func;
- return;
- }
- convert_to_string(user_compare_func_name);
- if (zend_hash_sort(target_hash, array_user_compare, 0) == FAILURE) {
- user_compare_func_name = old_compare_func;
- return;
- }
- user_compare_func_name = old_compare_func;
- RETURN_TRUE;
-}
-
-
-static int array_user_key_compare(const void *a, const void *b)
-{
- Bucket *f;
- Bucket *s;
- pval key1, key2;
- pval *args[2];
- pval retval;
- int status;
- CLS_FETCH();
-
- args[0] = &key1;
- args[1] = &key2;
- INIT_PZVAL(&key1);
- INIT_PZVAL(&key2);
-
- f = *((Bucket **) a);
- s = *((Bucket **) b);
-
- if (f->nKeyLength) {
- key1.value.str.val = estrndup(f->arKey, f->nKeyLength);
- key1.value.str.len = f->nKeyLength;
- key1.type = IS_STRING;
- } else {
- key1.value.lval = f->h;
- key1.type = IS_LONG;
- }
- if (s->nKeyLength) {
- key2.value.str.val = estrndup(s->arKey, s->nKeyLength);
- key2.value.str.len = s->nKeyLength;
- key2.type = IS_STRING;
- } else {
- key2.value.lval = s->h;
- key2.type = IS_LONG;
- }
-
- status = call_user_function(CG(function_table), NULL, user_compare_func_name, &retval, 2, args);
-
- pval_destructor(&key1);
- pval_destructor(&key2);
-
- if (status==SUCCESS) {
- convert_to_long(&retval);
- return retval.value.lval;
- } else {
- return 0;
- }
-}
-
-
-PHP_FUNCTION(uksort)
-{
- pval *array;
- pval *old_compare_func;
- HashTable *target_hash;
-
- old_compare_func = user_compare_func_name;
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &array, &user_compare_func_name) == FAILURE) {
- user_compare_func_name = old_compare_func;
- WRONG_PARAM_COUNT;
- }
- target_hash = HASH_OF(array);
- if (!target_hash) {
- php_error(E_WARNING, "Wrong datatype in uksort() call");
- user_compare_func_name = old_compare_func;
- return;
- }
- convert_to_string(user_compare_func_name);
- if (zend_hash_sort(target_hash, array_user_key_compare, 0) == FAILURE) {
- user_compare_func_name = old_compare_func;
- return;
- }
- user_compare_func_name = old_compare_func;
- RETURN_TRUE;
-}
-
-
-PHP_FUNCTION(end)
-{
- pval *array, **entry;
- HashTable *target_hash;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- target_hash = HASH_OF(array);
- if (!target_hash) {
- php_error(E_WARNING, "Variable passed to end() is not an array or object");
- return;
- }
- if (!ParameterPassedByReference(ht,1)) {
- php_error(E_WARNING, "Array not passed by reference in call to end()");
- }
- zend_hash_internal_pointer_end(target_hash);
- if (zend_hash_get_current_data(target_hash, (void **) &entry) == FAILURE) {
- RETURN_FALSE;
- }
- *return_value = **entry;
- pval_copy_constructor(return_value);
-}
-
-
-PHP_FUNCTION(prev)
-{
- pval *array, **entry;
- HashTable *target_hash;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- target_hash = HASH_OF(array);
- if (!target_hash) {
- php_error(E_WARNING, "Variable passed to prev() is not an array or object");
- RETURN_FALSE;
- }
- zend_hash_move_backwards(target_hash);
- if (zend_hash_get_current_data(target_hash, (void **) &entry) == FAILURE) {
- RETURN_FALSE;
- }
-
- *return_value = **entry;
- pval_copy_constructor(return_value);
-}
-
-
-PHP_FUNCTION(next)
-{
- pval *array, **entry;
- HashTable *target_hash;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- target_hash = HASH_OF(array);
- if (!target_hash) {
- php_error(E_WARNING, "Variable passed to next() is not an array or object");
- RETURN_FALSE;
- }
- zend_hash_move_forward(target_hash);
- if (zend_hash_get_current_data(target_hash, (void **) &entry) == FAILURE) {
- RETURN_FALSE;
- }
-
- *return_value = **entry;
- pval_copy_constructor(return_value);
-}
-
-
-PHP_FUNCTION(each)
-{
- pval *array,*entry,**entry_ptr, *tmp;
- char *string_key;
- ulong num_key;
- pval **inserted_pointer;
- HashTable *target_hash;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- target_hash = HASH_OF(array);
- if (!target_hash) {
- php_error(E_WARNING,"Variable passed to each() is not an array or object");
- return;
- }
- if (zend_hash_get_current_data(target_hash, (void **) &entry_ptr)==FAILURE) {
- RETURN_FALSE;
- }
- array_init(return_value);
- entry = *entry_ptr;
-
- /* add value elements */
- if (entry->EA.is_ref) {
- tmp = (pval *)emalloc(sizeof(pval));
- *tmp = *entry;
- pval_copy_constructor(tmp);
- tmp->EA.is_ref=0;
- tmp->EA.locks = 0;
- tmp->refcount=0;
- entry=tmp;
- }
- zend_hash_index_update(return_value->value.ht, 1, &entry, sizeof(pval *), NULL);
- entry->refcount++;
- zend_hash_update_ptr(return_value->value.ht, "value", sizeof("value"), entry, sizeof(pval *), NULL);
- entry->refcount++;
-
- /* add the key elements */
- switch (zend_hash_get_current_key(target_hash, &string_key, &num_key)) {
- case HASH_KEY_IS_STRING:
- add_get_index_string(return_value,0,string_key,(void **) &inserted_pointer,0);
- break;
- case HASH_KEY_IS_LONG:
- add_get_index_long(return_value,0,num_key, (void **) &inserted_pointer);
- break;
- }
- zend_hash_update(return_value->value.ht, "key", sizeof("key"), inserted_pointer, sizeof(pval *), NULL);
- (*inserted_pointer)->refcount++;
- zend_hash_move_forward(target_hash);
-}
-
-
-PHP_FUNCTION(reset)
-{
- pval *array, **entry;
- HashTable *target_hash;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- target_hash = HASH_OF(array);
- if (!target_hash) {
- php_error(E_WARNING, "Variable passed to reset() is not an array or object");
- return;
- }
- zend_hash_internal_pointer_reset(target_hash);
- if (zend_hash_get_current_data(target_hash, (void **) &entry) == FAILURE) {
- return;
- }
-
- *return_value = **entry;
- pval_copy_constructor(return_value);
- INIT_PZVAL(return_value);
-}
-
-PHP_FUNCTION(current)
-{
- pval *array, **entry;
- HashTable *target_hash;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- target_hash = HASH_OF(array);
- if (!target_hash) {
- php_error(E_WARNING, "Variable passed to current() is not an array or object");
- return;
- }
- if (zend_hash_get_current_data(target_hash, (void **) &entry) == FAILURE) {
- return;
- }
- *return_value = **entry;
- pval_copy_constructor(return_value);
-}
-
-
-PHP_FUNCTION(key)
-{
- pval *array;
- char *string_key;
- ulong num_key;
- HashTable *target_hash;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- target_hash = HASH_OF(array);
- if (!target_hash) {
- php_error(E_WARNING, "Variable passed to key() is not an array or object");
- return;
- }
- if (!ParameterPassedByReference(ht,1)) {
- php_error(E_WARNING, "Array not passed by reference in call to key()");
- }
- switch (zend_hash_get_current_key(target_hash, &string_key, &num_key)) {
- case HASH_KEY_IS_STRING:
- return_value->value.str.val = string_key;
- return_value->value.str.len = strlen(string_key);
- return_value->type = IS_STRING;
- break;
- case HASH_KEY_IS_LONG:
- return_value->type = IS_LONG;
- return_value->value.lval = num_key;
- break;
- case HASH_KEY_NON_EXISTANT:
- return;
- }
-}
-
-#ifdef __cplusplus
-void php3_flush(HashTable *)
-#else
-PHP_FUNCTION(flush)
-#endif
-{
- SLS_FETCH();
-
-#if APACHE
-# if MODULE_MAGIC_NUMBER > 19970110
- rflush(((request_rec *) SG(server_context)));
-# else
- bflush(((request_rec *) SG(server_context))->connection->client);
-# endif
-#endif
-#if FHTTPD
- /*FIXME -- what does it flush really? the whole response?*/
-#endif
-#if CGI_BINARY
- fflush(stdout);
-#endif
-#if USE_SAPI
- sapi_rqst->flush(sapi_rqst->scid);
-#endif
-}
-
-
-PHP_FUNCTION(sleep)
-{
- pval *num;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(num);
- sleep(num->value.lval);
-}
-
-PHP_FUNCTION(usleep)
-{
-#if HAVE_USLEEP
- pval *num;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(num);
- usleep(num->value.lval);
-#endif
-}
-
-PHP_FUNCTION(gettype)
-{
- pval *arg;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- switch (arg->type) {
- case IS_BOOL:
- RETVAL_STRING("boolean",1);
- break;
- case IS_LONG:
- RETVAL_STRING("integer",1);
- break;
- case IS_RESOURCE:
- RETVAL_STRING("resource",1);
- break;
- case IS_DOUBLE:
- RETVAL_STRING("double",1);
- break;
- case IS_STRING:
- RETVAL_STRING("string",1);
- break;
- case IS_ARRAY:
- RETVAL_STRING("array",1);
- break;
- case IS_OBJECT:
- RETVAL_STRING("object",1);
- break;
- /*
- {
- char *result;
- int res_len;
-
- res_len = sizeof("object of type ")-1 + arg->value.obj.ce->name_length;
- result = (char *) emalloc(res_len+1);
- sprintf(result, "object of type %s", arg->value.obj.ce->name);
- RETVAL_STRINGL(result, res_len, 0);
- }
- */
- break;
- default:
- RETVAL_STRING("unknown type",1);
- }
-}
-
-
-PHP_FUNCTION(settype)
-{
- pval *var, *type;
- char *new_type;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &var, &type) ==
- FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(type);
- new_type = type->value.str.val;
-
- if (!strcasecmp(new_type, "integer")) {
- convert_to_long(var);
- } else if (!strcasecmp(new_type, "double")) {
- convert_to_double(var);
- } else if (!strcasecmp(new_type, "string")) {
- convert_to_string(var);
- } else if (!strcasecmp(new_type, "array")) {
- convert_to_array(var);
- } else if (!strcasecmp(new_type, "object")) {
- convert_to_object(var);
- } else if (!strcasecmp(new_type, "boolean")) {
- convert_to_boolean(var);
- } else if (!strcasecmp(new_type, "resource")) {
- php_error(E_WARNING, "settype: cannot convert to resource type");
- RETURN_FALSE;
- } else {
- php_error(E_WARNING, "settype: invalid type");
- RETURN_FALSE;
- }
- RETVAL_TRUE;
-}
-
-
-PHP_FUNCTION(min)
-{
- int argc=ARG_COUNT(ht);
- pval **result;
-
- if (argc<=0) {
- php_error(E_WARNING, "min: must be passed at least 1 value");
- var_uninit(return_value);
- return;
- }
- if (argc == 1) {
- pval *arr;
-
- if (getParameters(ht, 1, &arr) == FAILURE ||
- arr->type != IS_ARRAY) {
- WRONG_PARAM_COUNT;
- }
- if (zend_hash_minmax(arr->value.ht, array_data_compare, 0, (void **) &result)==SUCCESS) {
- *return_value = **result;
- pval_copy_constructor(return_value);
- } else {
- php_error(E_WARNING, "min: array must contain at least 1 element");
- var_uninit(return_value);
- }
- } else {
- pval **args = (pval **) emalloc(sizeof(pval *)*ARG_COUNT(ht));
- pval *min, result;
- int i;
-
- if (getParametersArray(ht, ARG_COUNT(ht), args)==FAILURE) {
- efree(args);
- WRONG_PARAM_COUNT;
- }
-
- min = args[0];
-
- for (i=1; i<ARG_COUNT(ht); i++) {
- is_smaller_function(&result, args[i], min);
- if (result.value.lval == 1) {
- min = args[i];
- }
- }
-
- *return_value = *min;
- pval_copy_constructor(return_value);
-
- efree(args);
- }
-}
-
-
-PHP_FUNCTION(max)
-{
- int argc=ARG_COUNT(ht);
- pval **result;
-
- if (argc<=0) {
- php_error(E_WARNING, "max: must be passed at least 1 value");
- var_uninit(return_value);
- return;
- }
- if (argc == 1) {
- pval *arr;
-
- if (getParameters(ht, 1, &arr) == FAILURE ||
- arr->type != IS_ARRAY) {
- WRONG_PARAM_COUNT;
- }
- if (zend_hash_minmax(arr->value.ht, array_data_compare, 1, (void **) &result)==SUCCESS) {
- *return_value = **result;
- pval_copy_constructor(return_value);
- } else {
- php_error(E_WARNING, "max: array must contain at least 1 element");
- var_uninit(return_value);
- }
- } else {
- pval **args = (pval **) emalloc(sizeof(pval *)*ARG_COUNT(ht));
- pval *max, result;
- int i;
-
- if (getParametersArray(ht, ARG_COUNT(ht), args)==FAILURE) {
- efree(args);
- WRONG_PARAM_COUNT;
- }
-
- max = args[0];
-
- for (i=1; i<ARG_COUNT(ht); i++) {
- is_smaller_or_equal_function(&result, args[i], max);
- if (result.value.lval == 0) {
- max = args[i];
- }
- }
-
- *return_value = *max;
- pval_copy_constructor(return_value);
-
- efree(args);
- }
-}
-
-static pval *php_array_walk_func_name;
-
-static int php_array_walk(HashTable *target_hash, zval **userdata)
-{
- zval **args[3], /* Arguments to userland function */
- retval, /* Return value - unused */
- *key; /* Entry key */
- char *string_key;
- ulong num_key;
- CLS_FETCH();
-
- /* Allocate space for key */
- MAKE_STD_ZVAL(key);
-
- /* Set up known arguments */
- args[1] = &key;
- args[2] = userdata;
-
- /* Iterate through hash */
- while(zend_hash_get_current_data(target_hash, (void **)&args[0]) == SUCCESS) {
- /* Set up the key */
- if (zend_hash_get_current_key(target_hash, &string_key, &num_key) == HASH_KEY_IS_LONG) {
- key->type = IS_LONG;
- key->value.lval = num_key;
- } else {
- key->type = IS_STRING;
- key->value.str.val = string_key;
- key->value.str.len = strlen(string_key);
- }
-
- /* Call the userland function */
- call_user_function_ex(CG(function_table), NULL, php_array_walk_func_name,
- &retval, (*userdata) ? 3 : 2, args, 0);
-
- /* Clean up the key */
- if (zend_hash_get_current_key_type(target_hash) == HASH_KEY_IS_STRING)
- efree(key->value.str.val);
-
- zend_hash_move_forward(target_hash);
- }
- efree(key);
-
- return 0;
-}
-
-/* {{{ proto array_walk(array input, string funcname [, mixed userdata])
- Apply a user function to every member of an array */
-PHP_FUNCTION(array_walk) {
- int argc;
- zval *array,
- *userdata = NULL,
- *old_walk_func_name;
- HashTable *target_hash;
-
- argc = ARG_COUNT(ht);
- old_walk_func_name = php_array_walk_func_name;
- if (argc < 2 || argc > 3 ||
- getParameters(ht, argc, &array, &php_array_walk_func_name, &userdata) == FAILURE) {
- php_array_walk_func_name = old_walk_func_name;
- WRONG_PARAM_COUNT;
- }
- target_hash = HASH_OF(array);
- if (!target_hash) {
- php_error(E_WARNING, "Wrong datatype in array_walk() call");
- php_array_walk_func_name = old_walk_func_name;
- return;
- }
- convert_to_string(php_array_walk_func_name);
- php_array_walk(target_hash, &userdata);
- php_array_walk_func_name = old_walk_func_name;
- RETURN_TRUE;
-}
-
-#if 0
-PHP_FUNCTION(max)
-{
- pval **argv;
- int argc, i;
- unsigned short max_type = IS_LONG;
-
- argc = ARG_COUNT(ht);
- /* if there is one parameter and this parameter is an array of
- * 2 or more elements, use that array
- */
- if (argc == 1) {
- argv = (pval **)emalloc(sizeof(pval *) * argc);
- if (getParametersArray(ht, argc, argv) == FAILURE ||
- argv[0]->type != IS_ARRAY) {
- WRONG_PARAM_COUNT;
- }
- if (argv[0]->value.ht->nNumOfElements < 2) {
- php_error(E_WARNING,
- "min: array must contain at least 2 elements");
- RETURN_FALSE;
- }
- /* replace the function parameters with the array */
- ht = argv[0]->value.ht;
- argc = zend_hash_num_elements(ht);
- efree(argv);
- } else if (argc < 2) {
- WRONG_PARAM_COUNT;
- }
- argv = (pval **)emalloc(sizeof(pval *) * argc);
- if (getParametersArray(ht, argc, argv) == FAILURE) {
- efree(argv);
- WRONG_PARAM_COUNT;
- }
- /* figure out what types to compare
- * if the arguments contain a double, convert all of them to a double
- * else convert all of them to long
- */
- for (i = 0; i < argc; i++) {
- if (argv[i]->type == IS_DOUBLE) {
- max_type = IS_DOUBLE;
- break;
- }
- }
- if (max_type == IS_LONG) {
- convert_to_long(argv[0]);
- return_value->value.lval = argv[0]->value.lval;
- for (i = 1; i < argc; i++) {
- convert_to_long(argv[i]);
- if (argv[i]->value.lval > return_value->value.lval) {
- return_value->value.lval = argv[i]->value.lval;
- }
- }
- } else {
- convert_to_double(argv[0]);
- return_value->value.dval = argv[0]->value.dval;
- for (i = 1; i < argc; i++) {
- convert_to_double(argv[i]);
- if (argv[i]->value.dval > return_value->value.dval) {
- return_value->value.dval = argv[i]->value.dval;
- }
- }
- }
- efree(argv);
- return_value->type = max_type;
-}
-#endif
-
-PHP_FUNCTION(get_current_user)
-{
- RETURN_STRING(_php3_get_current_user(),1);
-}
-
-
-PHP_FUNCTION(get_cfg_var)
-{
- pval *varname;
- char *value;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &varname)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(varname);
-
- if (cfg_get_string(varname->value.str.val,&value)==FAILURE) {
- RETURN_FALSE;
- }
- RETURN_STRING(value,1);
-}
-
-PHP_FUNCTION(set_magic_quotes_runtime)
-{
- pval *new_setting;
- PLS_FETCH();
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &new_setting)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_boolean(new_setting);
-
- PG(magic_quotes_runtime) = (zend_bool) new_setting->value.lval;
- RETURN_TRUE;
-}
-
-PHP_FUNCTION(get_magic_quotes_runtime)
-{
- PLS_FETCH();
-
- RETURN_LONG(PG(magic_quotes_runtime));
-}
-
-PHP_FUNCTION(get_magic_quotes_gpc)
-{
- PLS_FETCH();
-
- RETURN_LONG(PG(magic_quotes_gpc));
-}
-
-
-void php3_is_type(INTERNAL_FUNCTION_PARAMETERS,int type)
-{
- pval **arg;
-
- if (ARG_COUNT(ht)!=1 || getParametersEx(1, &arg)==FAILURE) {
- RETURN_FALSE;
- }
- if ((*arg)->type == type) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-
-
-PHP_FUNCTION(is_long)
-{
- php3_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_LONG);
-}
-
-PHP_FUNCTION(is_double)
-{
- php3_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_DOUBLE);
-}
-
-PHP_FUNCTION(is_string)
-{
- php3_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_STRING);
-}
-
-PHP_FUNCTION(is_array)
-{
- php3_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_ARRAY);
-}
-
-PHP_FUNCTION(is_object)
-{
- php3_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_OBJECT);
-}
-
-/* {{{ proto string get_class(object object)
- Retrieves the class name ...
-*/
-PHP_FUNCTION(get_class)
-{
- pval *arg;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &arg)==FAILURE) {
- RETURN_FALSE;
- }
- if (arg->type != IS_OBJECT) {
- RETURN_FALSE;
- }
- RETURN_STRINGL(arg->value.obj.ce->name, arg->value.obj.ce->name_length, 1);
-}
-/* }}} */
-
-/* {{{ proto string get_parent_class(object object)
- Retrieves the parent class name ...
-*/
-PHP_FUNCTION(get_parent_class)
-{
- pval *arg;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &arg)==FAILURE) {
- RETURN_FALSE;
- }
- if ((arg->type != IS_OBJECT) || !arg->value.obj.ce->parent) {
- RETURN_FALSE;
- }
- RETURN_STRINGL(arg->value.obj.ce->parent->name, arg->value.obj.ce->parent->name_length, 1);
-}
-/* }}} */
-
-/* {{{ proto bool method_exists(object object, string method)
- Checks if the class method exists ...
-*/
-PHP_FUNCTION(method_exists)
-{
- pval *arg1, *arg2;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &arg1, &arg2)==FAILURE) {
- RETURN_FALSE;
- }
- if (arg1->type != IS_OBJECT) {
- RETURN_FALSE;
- }
- convert_to_string(arg2);
- if(zend_hash_exists(&arg1->value.obj.ce->function_table, arg2->value.str.val, arg2->value.str.len+1)) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-PHP_FUNCTION(leak)
-{
- int leakbytes=3;
- pval *leak;
-
- if (ARG_COUNT(ht)>=1) {
- if (getParameters(ht, 1, &leak)==SUCCESS) {
- convert_to_long(leak);
- leakbytes = leak->value.lval;
- }
- }
-
- emalloc(leakbytes);
-}
-
-/*
- 1st arg = error message
- 2nd arg = error option
- 3rd arg = optional parameters (email address or tcp address)
- 4th arg = used for additional headers if email
-
- error options
- 0 = send to php_error_log (uses syslog or file depending on ini setting)
- 1 = send via email to 3rd parameter 4th option = additional headers
- 2 = send via tcp/ip to 3rd parameter (name or ip:port)
- 3 = save to file in 3rd parameter
-*/
-
-PHP_FUNCTION(error_log)
-{
- pval *string, *erropt = NULL, *option = NULL, *emailhead = NULL;
- int opt_err = 0;
- char *message, *opt=NULL, *headers=NULL;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht,1,&string) == FAILURE) {
- php_error(E_WARNING,"Invalid argument 1 in error_log");
- RETURN_FALSE;
- }
- break;
- case 2:
- if (getParameters(ht,2,&string,&erropt) == FAILURE) {
- php_error(E_WARNING,"Invalid arguments in error_log");
- RETURN_FALSE;
- }
- convert_to_long(erropt);
- opt_err=erropt->value.lval;
- break;
- case 3:
- if (getParameters(ht,3,&string,&erropt,&option) == FAILURE){
- php_error(E_WARNING,"Invalid arguments in error_log");
- RETURN_FALSE;
- }
- convert_to_long(erropt);
- opt_err=erropt->value.lval;
- convert_to_string(option);
- opt=option->value.str.val;
- break;
- case 4:
- if (getParameters(ht,4,&string,&erropt,&option,&emailhead) == FAILURE){
- php_error(E_WARNING,"Invalid arguments in error_log");
- RETURN_FALSE;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(string);
- message=string->value.str.val;
- if (erropt != NULL) {
- convert_to_long(erropt);
- opt_err=erropt->value.lval;
- }
- if (option != NULL) {
- convert_to_string(option);
- opt=option->value.str.val;
- }
- if (emailhead != NULL) {
- convert_to_string(emailhead);
- headers=emailhead->value.str.val;
- }
-
- if (_php_error_log(opt_err,message,opt,headers)==FAILURE) {
- RETURN_FALSE;
- }
-
- RETURN_TRUE;
-}
-
-PHPAPI int _php_error_log(int opt_err,char *message,char *opt,char *headers){
- FILE *logfile;
- int issock=0, socketd=0;;
-
- switch(opt_err){
- case 1: /*send an email*/
- {
-#if HAVE_SENDMAIL
- if (!_php3_mail(opt,"PHP3 error_log message",message,headers)){
- return FAILURE;
- }
-#else
- php_error(E_WARNING,"Mail option not available!");
- return FAILURE;
-#endif
- }
- break;
- case 2: /*send to an address */
- php_error(E_WARNING,"TCP/IP option not available!");
- return FAILURE;
- break;
- case 3: /*save to a file*/
- logfile=php3_fopen_wrapper(opt,"a", (IGNORE_URL|ENFORCE_SAFE_MODE), &issock, &socketd);
- if(!logfile) {
- php_error(E_WARNING,"error_log: Unable to write to %s",opt);
- return FAILURE;
- }
- fwrite(message,strlen(message),1,logfile);
- fclose(logfile);
- break;
- default:
- php3_log_err(message);
- break;
- }
- return SUCCESS;
-}
-
-
-PHP_FUNCTION(call_user_func)
-{
- pval ***params;
- pval retval;
- int arg_count=ARG_COUNT(ht);
- CLS_FETCH();
-
- if (arg_count<1) {
- WRONG_PARAM_COUNT;
- }
- params = (pval ***) emalloc(sizeof(pval **)*arg_count);
-
- if (getParametersArrayEx(arg_count, params)==FAILURE) {
- efree(params);
- RETURN_FALSE;
- }
- SEPARATE_ZVAL(params[0]);
- convert_to_string(*params[0]);
- if (call_user_function_ex(CG(function_table), NULL, *params[0], &retval, arg_count-1, params+1, 1)==SUCCESS) {
- *return_value = retval;
- } else {
- php_error(E_WARNING,"Unable to call %s() - function does not exist", (*params[0])->value.str.val);
- }
- efree(params);
-}
-
-
-PHP_FUNCTION(call_user_method)
-{
- pval ***params;
- pval retval;
- int arg_count=ARG_COUNT(ht);
- CLS_FETCH();
-
- if (arg_count<2) {
- WRONG_PARAM_COUNT;
- }
- params = (pval ***) emalloc(sizeof(pval **)*arg_count);
-
- if (getParametersArrayEx(arg_count, params)==FAILURE) {
- efree(params);
- RETURN_FALSE;
- }
- if ((*params[1])->type != IS_OBJECT) {
- php_error(E_WARNING,"2nd argument is not an object\n");
- efree(params);
- RETURN_FALSE;
- }
- SEPARATE_ZVAL(params[0]);
- SEPARATE_ZVAL(params[1]);
- convert_to_string(*params[0]);
- if (call_user_function_ex(CG(function_table), *params[1], *params[0], &retval, arg_count-2, params+2, 1)==SUCCESS) {
- *return_value = retval;
- } else {
- php_error(E_WARNING,"Unable to call %s() - function does not exist", (*params[0])->value.str.val);
- }
- efree(params);
-}
-
-
-int user_shutdown_function_dtor(php_shutdown_function_entry *shutdown_function_entry)
-{
- pval retval;
- int i;
- CLS_FETCH();
-
- if (call_user_function(CG(function_table), NULL, shutdown_function_entry->arguments[0], &retval, shutdown_function_entry->arg_count-1, shutdown_function_entry->arguments+1)==SUCCESS) {
- pval_destructor(&retval);
- }
- for (i=0; i<shutdown_function_entry->arg_count; i++) {
- zval_ptr_dtor(&shutdown_function_entry->arguments[i]);
- }
- efree(shutdown_function_entry->arguments);
- return 1;
-}
-
-
-void php3_call_shutdown_functions(void)
-{
- if (user_shutdown_function_names) {
- zend_hash_destroy(user_shutdown_function_names);
- efree(user_shutdown_function_names);
- }
-}
-
-/* {{{ proto void register_shutdown_function(string function_name)
- Register a user-level function to be called on request termination */
-PHP_FUNCTION(register_shutdown_function)
-{
- php_shutdown_function_entry shutdown_function_entry;
- int i;
-
- shutdown_function_entry.arg_count = ARG_COUNT(ht);
-
- if (shutdown_function_entry.arg_count<1) {
- WRONG_PARAM_COUNT;
- }
- shutdown_function_entry.arguments = (pval **) emalloc(sizeof(pval *)*shutdown_function_entry.arg_count);
-
- if (getParametersArray(ht, shutdown_function_entry.arg_count, shutdown_function_entry.arguments)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(shutdown_function_entry.arguments[0]);
- if (!user_shutdown_function_names) {
- user_shutdown_function_names = (HashTable *) emalloc(sizeof(HashTable));
- zend_hash_init(user_shutdown_function_names, 0, NULL, (int (*)(void *))user_shutdown_function_dtor, 0);
- }
-
- for (i=0; i<shutdown_function_entry.arg_count; i++) {
- shutdown_function_entry.arguments[i]->refcount++;
- }
- zend_hash_next_index_insert(user_shutdown_function_names, &shutdown_function_entry, sizeof(php_shutdown_function_entry), NULL);
-}
-/* }}} */
-
-
-ZEND_API void php_get_highlight_struct(zend_syntax_highlighter_ini *syntax_highlighter_ini)
-{
- syntax_highlighter_ini->highlight_comment = INI_STR("highlight.comment");
- syntax_highlighter_ini->highlight_default = INI_STR("highlight.default");
- syntax_highlighter_ini->highlight_html = INI_STR("highlight.html");
- syntax_highlighter_ini->highlight_keyword = INI_STR("highlight.keyword");
- syntax_highlighter_ini->highlight_string = INI_STR("highlight.string");
-}
-
-
-/* {{{ proto void highlight_file(string file_name)
- Syntax highlight a source file */
-PHP_FUNCTION(highlight_file)
-{
- pval *filename;
- zend_syntax_highlighter_ini syntax_highlighter_ini;
-
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &filename)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(filename);
-
- php_get_highlight_struct(&syntax_highlighter_ini);
-
- if (highlight_file(filename->value.str.val, &syntax_highlighter_ini)==FAILURE) {
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/* {{{ proto void highlight_string(string string)
- Syntax highlight a string */
-PHP_FUNCTION(highlight_string)
-{
- pval *expr;
- zend_syntax_highlighter_ini syntax_highlighter_ini;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &expr)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(expr);
-
- php_get_highlight_struct(&syntax_highlighter_ini);
-
- if (highlight_string(expr, &syntax_highlighter_ini)==FAILURE) {
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-
-pval test_class_get_property(zend_property_reference *property_reference)
-{
- pval result;
- zend_overloaded_element *overloaded_property;
- zend_llist_element *element;
-
-
- printf("Reading a property from a TestClass object:\n");
-
- for (element=property_reference->elements_list.head; element; element=element->next) {
- overloaded_property = (zend_overloaded_element *) element->data;
- switch (overloaded_property->type) {
- case IS_ARRAY:
- printf("Array offset: ");
- break;
- case IS_OBJECT:
- printf("Object property: ");
- break;
- }
- switch (overloaded_property->element.type) {
- case IS_LONG:
- printf("%ld (numeric)\n", overloaded_property->element.value.lval);
- break;
- case IS_STRING:
- printf("'%s'\n", overloaded_property->element.value.str.val);
- break;
- }
- pval_destructor(&overloaded_property->element);
- }
-
- result.value.str.val = estrndup("testing", 7);
- result.value.str.len = 7;
- result.type = IS_STRING;
- return result;
-}
-
-
-int test_class_set_property(zend_property_reference *property_reference, pval *value)
-{
- zend_overloaded_element *overloaded_property;
- zend_llist_element *element;
-
- printf("Writing to a property from a TestClass object:\n");
- printf("Writing '");
- zend_print_variable(value);
- printf("'\n");
-
- for (element=property_reference->elements_list.head; element; element=element->next) {
- overloaded_property = (zend_overloaded_element *) element->data;
- switch (overloaded_property->type) {
- case IS_ARRAY:
- printf("Array offset: ");
- break;
- case IS_OBJECT:
- printf("Object property: ");
- break;
- }
- switch (overloaded_property->element.type) {
- case IS_LONG:
- printf("%ld (numeric)\n", overloaded_property->element.value.lval);
- break;
- case IS_STRING:
- printf("'%s'\n", overloaded_property->element.value.str.val);
- break;
- }
- pval_destructor(&overloaded_property->element);
- }
-
- return 0;
-}
-
-
-
-void test_class_call_function(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference)
-{
- zend_overloaded_element *overloaded_property;
- zend_llist_element *element;
-
-
- printf("Reading a property from a TestClass object:\n");
-
- for (element=property_reference->elements_list.head; element; element=element->next) {
- overloaded_property = (zend_overloaded_element *) element->data;
- switch (overloaded_property->type) {
- case IS_ARRAY:
- printf("Array offset: ");
- break;
- case IS_OBJECT:
- printf("Object property: ");
- break;
- case IS_METHOD:
- printf("Overloaded method: ");
- }
- switch (overloaded_property->element.type) {
- case IS_LONG:
- printf("%ld (numeric)\n", overloaded_property->element.value.lval);
- break;
- case IS_STRING:
- printf("'%s'\n", overloaded_property->element.value.str.val);
- break;
- }
- pval_destructor(&overloaded_property->element);
- }
-
- printf("%d arguments\n", ARG_COUNT(ht));
- return_value->value.str.val = estrndup("testing", 7);
- return_value->value.str.len = 7;
- return_value->type = IS_STRING;
-}
-
-
-void test_class_startup()
-{
- zend_class_entry test_class_entry;
-
- INIT_OVERLOADED_CLASS_ENTRY(test_class_entry, "OverloadedTestClass", NULL,
- test_class_call_function,
- test_class_get_property,
- test_class_set_property);
-
- register_internal_class(&test_class_entry);
-}
-
-
-PHP_FUNCTION(ob_start)
-{
- php_start_ob_buffering();
-}
-
-
-PHP_FUNCTION(ob_end_flush)
-{
- php_end_ob_buffering(1);
-}
-
-
-PHP_FUNCTION(ob_end_clean)
-{
- php_end_ob_buffering(0);
-}
-
-
-PHP_FUNCTION(ob_get_contents)
-{
- if (php_ob_get_buffer(return_value)==FAILURE) {
- RETURN_FALSE;
- }
-}
-
-
-PHP_FUNCTION(ini_get)
-{
- pval *varname;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &varname)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- return_value->value.str.val = php_ini_string(varname->value.str.val, varname->value.str.len+1, 0);
-
- if (!return_value->value.str.val) {
- RETURN_FALSE;
- }
-
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
- pval_copy_constructor(return_value);
-}
-
-
-PHP_FUNCTION(ini_alter)
-{
- pval *varname, *new_value;
- char *old_value;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &varname, &new_value)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- old_value = php_ini_string(varname->value.str.val, varname->value.str.len+1, 0);
-
-
- convert_to_string(new_value);
-
- if (php_alter_ini_entry(varname->value.str.val, varname->value.str.len+1, new_value->value.str.val, new_value->value.str.len, PHP_INI_USER)==FAILURE) {
- RETURN_FALSE;
- }
- if (old_value) {
- RETURN_STRING(old_value, 1);
- } else {
- RETURN_FALSE;
- }
-}
-
-
-
-PHP_FUNCTION(ini_restore)
-{
- pval *varname;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &varname)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(varname);
-
- php_restore_ini_entry(varname->value.str.val, varname->value.str.len);
-}
-
-
-PHP_FUNCTION(print_r)
-{
- pval *expr;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &expr)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- zend_print_pval_r(expr, 0);
- RETURN_TRUE;
-}
-
-
-/* This should go back to PHP */
-PHP_FUNCTION(define)
-{
- pval *var, *val, *non_cs;
- int case_sensitive;
- zend_constant c;
- ELS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &var, &val)==FAILURE) {
- RETURN_FALSE;
- }
- case_sensitive = CONST_CS;
- break;
- case 3:
- if (getParameters(ht, 3, &var, &val, &non_cs)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(non_cs);
- if (non_cs->value.lval) {
- case_sensitive = 0;
- } else {
- case_sensitive = CONST_CS;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
- switch(val->type) {
- case IS_LONG:
- case IS_DOUBLE:
- case IS_STRING:
- case IS_BOOL:
- case IS_RESOURCE:
- break;
- default:
- php_error(E_WARNING,"Constants may only evaluate to scalar values");
- RETURN_FALSE;
- break;
- }
- convert_to_string(var);
-
- c.value = *val;
- pval_copy_constructor(&c.value);
- c.flags = case_sensitive | ~CONST_PERSISTENT; /* non persistent */
- c.name = php3_strndup(var->value.str.val, var->value.str.len);
- c.name_len = var->value.str.len+1;
- zend_register_constant(&c ELS_CC);
- RETURN_TRUE;
-}
-
-
-PHP_FUNCTION(defined)
-{
- pval *var;
- pval c;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &var)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(var);
- if (zend_get_constant(var->value.str.val, var->value.str.len, &c)) {
- pval_destructor(&c);
- RETURN_LONG(1);
- } else {
- RETURN_LONG(0);
- }
-}
-
-/* {{{ proto int connection_aborted(void)
- Returns true if client disconnected */
-PHP_FUNCTION(connection_aborted)
-{
- PLS_FETCH();
-
- RETURN_LONG(PG(connection_status)&PHP_CONNECTION_ABORTED);
-}
-/* }}} */
-
-/* {{{ proto int connection_timeout(void)
- Returns true if script timed out */
-PHP_FUNCTION(connection_timeout)
-{
- PLS_FETCH();
-
- RETURN_LONG(PG(connection_status)&PHP_CONNECTION_TIMEOUT);
-}
-/* }}} */
-
-/* {{{ proto int connection_status(void)
- Returns the connection status bitfield */
-PHP_FUNCTION(connection_status)
-{
- PLS_FETCH();
-
- RETURN_LONG(PG(connection_status));
-}
-/* }}} */
-
-/* {{{ proto int ignore_user_abort(boolean value)
- Set whether we want to ignore a user abort event or not */
-PHP_FUNCTION(ignore_user_abort)
-{
- pval *arg;
- int old_setting;
- PLS_FETCH();
-
- old_setting = PG(ignore_user_abort);
- switch (ARG_COUNT(ht)) {
- case 0:
- break;
- case 1:
- if (getParameters(ht,1,&arg) == FAILURE) {
- RETURN_FALSE;
- }
- convert_to_boolean(arg);
- PG(ignore_user_abort) = (zend_bool) arg->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
- RETURN_LONG(old_setting);
-}
-/* }}} */
-
-/* {{{ proto bool function_exists(string function_name)
- Checks if a given function has been defined */
-PHP_FUNCTION(function_exists)
-{
- pval *fname;
- pval *tmp;
- char *lcname;
- CLS_FETCH();
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &fname)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- lcname = estrdup(fname->value.str.val);
- zend_str_tolower(lcname, fname->value.str.len);
- if (zend_hash_find(CG(function_table), lcname,
- fname->value.str.len+1, (void**)&tmp) == FAILURE) {
- efree(lcname);
- RETURN_FALSE;
- } else {
- efree(lcname);
- RETURN_TRUE;
- }
-}
-
-/* }}} */
-
-
-/* {{{ proto bool in_array(mixed needle, array haystack)
- Checks if the given value exists in the array */
-PHP_FUNCTION(in_array)
-{
- zval *value, /* value to check for */
- *array, /* array to check in */
- **entry_ptr, /* pointer to array entry */
- *entry, /* actual array entry */
- res; /* comparison result */
- HashTable *target_hash; /* array hashtable */
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &value, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (value->type == IS_ARRAY || value->type == IS_OBJECT) {
- zend_error(E_WARNING, "Wrong datatype for first argument in call to in_array()");
- return;
- }
-
- if (array->type != IS_ARRAY) {
- zend_error(E_WARNING, "Wrong datatype for second argument in call to in_array()");
- return;
- }
-
- target_hash = HASH_OF(array);
- zend_hash_internal_pointer_reset(target_hash);
- while(zend_hash_get_current_data(target_hash, (void **)&entry_ptr) == SUCCESS) {
- entry = *entry_ptr;
- is_equal_function(&res, value, entry);
- if (zval_is_true(&res)) {
- RETURN_TRUE;
- }
-
- zend_hash_move_forward(target_hash);
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-
-/* {{{ int _valid_var_name(char *varname) */
-static int _valid_var_name(char *varname)
-{
- int len, i;
-
- if (!varname)
- return 0;
-
- len = strlen(varname);
-
- if (!isalpha((int)varname[0]) && varname[0] != '_')
- return 0;
-
- if (len > 1) {
- for(i=1; i<len; i++) {
- if (!isalnum((int)varname[i]) && varname[i] != '_') {
- return 0;
- }
- }
- }
-
- return 1;
-}
-/* }}} */
-
-
-/* {{{ proto void extract(array var_array, int extract_type [, string prefix])
- Imports variables into symbol table from an array */
-PHP_FUNCTION(extract)
-{
- zval *var_array, *etype, *prefix;
- zval **entry_ptr, *entry, *exist;
- zval *data;
- char *varname, *finalname;
- ulong lkey;
- int res, extype;
- ELS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &var_array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- extype = EXTR_OVERWRITE;
- break;
-
- case 2:
- if (getParameters(ht, 2, &var_array, &etype) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(etype);
- extype = etype->value.lval;
- if (extype > EXTR_SKIP && extype <= EXTR_PREFIX_ALL) {
- WRONG_PARAM_COUNT;
- }
- break;
-
- case 3:
- if (getParameters(ht, 3, &var_array, &etype, &prefix) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(etype);
- extype = etype->value.lval;
- break;
-
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- if (extype < EXTR_OVERWRITE || extype > EXTR_PREFIX_ALL) {
- zend_error(E_WARNING, "Wrong argument in call to extract()");
- return;
- }
-
- if (var_array->type != IS_ARRAY) {
- zend_error(E_WARNING, "Wrong datatype in call to extract()");
- return;
- }
-
- zend_hash_internal_pointer_reset(var_array->value.ht);
- while(zend_hash_get_current_data(var_array->value.ht, (void **)&entry_ptr) == SUCCESS) {
- entry = *entry_ptr;
-
- if (zend_hash_get_current_key(var_array->value.ht, &varname, &lkey) ==
- HASH_KEY_IS_STRING) {
-
- if (_valid_var_name(varname)) {
- finalname = NULL;
-
- res = zend_hash_find(EG(active_symbol_table),
- varname, strlen(varname)+1, (void**)&exist);
- switch (extype) {
- case EXTR_OVERWRITE:
- finalname = estrdup(varname);
- break;
-
- case EXTR_PREFIX_SAME:
- if (res != SUCCESS)
- finalname = estrdup(varname);
- /* break omitted intentionally */
-
- case EXTR_PREFIX_ALL:
- if (!finalname) {
- finalname = emalloc(strlen(varname) + prefix->value.str.len + 2);
- strcpy(finalname, prefix->value.str.val);
- strcat(finalname, "_");
- strcat(finalname, varname);
- }
- break;
-
- default:
- if (res != SUCCESS)
- finalname = estrdup(varname);
- break;
- }
-
- if (finalname) {
- data = (zval *)emalloc(sizeof(zval));
- *data = *entry;
- zval_copy_ctor(data);
- INIT_PZVAL(data);
-
- zend_hash_update(EG(active_symbol_table), finalname,
- strlen(finalname)+1, &data, sizeof(zval *), NULL);
- efree(finalname);
- }
- }
-
- efree(varname);
- }
-
- zend_hash_move_forward(var_array->value.ht);
- }
-}
-/* }}} */
-
-
-/* {{{ void _compact_var(HashTable *eg_active_symbol_table, zval *return_value, zval *entry) */
-static void _compact_var(HashTable *eg_active_symbol_table, zval *return_value, zval *entry)
-{
- zval **value_ptr, *value, *data;
-
- if (entry->type == IS_STRING) {
- if (zend_hash_find(eg_active_symbol_table, entry->value.str.val,
- entry->value.str.len+1, (void **)&value_ptr) != FAILURE) {
- value = *value_ptr;
- data = (zval *)emalloc(sizeof(zval));
- *data = *value;
- zval_copy_ctor(data);
- INIT_PZVAL(data);
-
- zend_hash_update(return_value->value.ht, entry->value.str.val,
- entry->value.str.len+1, &data, sizeof(zval *), NULL);
- }
- }
- else if (entry->type == IS_ARRAY) {
- zend_hash_internal_pointer_reset(entry->value.ht);
-
- while(zend_hash_get_current_data(entry->value.ht, (void**)&value_ptr) == SUCCESS) {
- value = *value_ptr;
-
- _compact_var(eg_active_symbol_table, return_value, value);
- zend_hash_move_forward(entry->value.ht);
- }
- }
-}
-/* }}} */
-
-
-/* {{{ proto array compact(string var_name | array var_names [, ... ])
- Creates a hash containing variables and their values */
-PHP_FUNCTION(compact)
-{
- zval **args; /* function arguments array */
- int i;
- ELS_FETCH();
-
- args = (zval **)emalloc(ARG_COUNT(ht) * sizeof(zval *));
-
- if (getParametersArray(ht, ARG_COUNT(ht), args) == FAILURE) {
- efree(args);
- WRONG_PARAM_COUNT;
- }
-
- array_init(return_value);
-
- for (i=0; i<ARG_COUNT(ht); i++)
- {
- _compact_var(EG(active_symbol_table), return_value, args[i]);
- }
-
- efree(args);
-}
-/* }}} */
-
-
-/* HashTable* _phpi_splice(HashTable *in_hash, int offset, int length,
- zval **list, int list_count, HashTable **removed) */
-HashTable* _phpi_splice(HashTable *in_hash, int offset, int length,
- zval **list, int list_count, HashTable **removed)
-{
- HashTable *out_hash = NULL; /* Output hashtable */
- int num_in, /* Number of entries in the input hashtable */
- pos, /* Current position in the hashtable */
- i; /* Loop counter */
- Bucket *p; /* Pointer to hash bucket */
- zval *entry; /* Hash entry */
-
- /* If input hash doesn't exist, we have nothing to do */
- if (!in_hash)
- return NULL;
-
- /* Get number of entries in the input hash */
- num_in = zend_hash_num_elements(in_hash);
-
- /* Clamp the offset.. */
- if (offset > num_in)
- offset = num_in;
- else if (offset < 0 && (offset=num_in+offset) < 0)
- offset = 0;
-
- /* ..and the length */
- if (length < 0)
- length = num_in-offset+length;
- else if(offset+length > num_in)
- length = num_in-offset;
-
- /* Create and initialize output hash */
- out_hash = (HashTable *)emalloc(sizeof(HashTable));
- zend_hash_init(out_hash, 0, NULL, PVAL_PTR_DTOR, 0);
-
- /* Start at the beginning of the input hash and copy
- entries to output hash until offset is reached */
- for (pos=0, p=in_hash->pListHead; pos<offset && p ; pos++, p=p->pListNext) {
- /* Get entry and increase reference count */
- entry = *((zval **)p->pData);
- entry->refcount++;
-
- /* Update output hash depending on key type */
- if (p->nKeyLength)
- zend_hash_update(out_hash, p->arKey, p->nKeyLength, &entry, sizeof(zval *), NULL);
- else
- zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL);
- }
-
- /* If hash for removed entries exists, go until offset+length
- and copy the entries to it */
- if (removed != NULL) {
- for( ; pos<offset+length && p; pos++, p=p->pListNext) {
- entry = *((zval **)p->pData);
- entry->refcount++;
- if (p->nKeyLength)
- zend_hash_update(*removed, p->arKey, p->nKeyLength, &entry, sizeof(zval *), NULL);
- else
- zend_hash_next_index_insert(*removed, &entry, sizeof(zval *), NULL);
- }
- } else /* otherwise just skip those entries */
- for( ; pos<offset+length && p; pos++, p=p->pListNext);
-
- /* If there are entries to insert.. */
- if (list != NULL) {
- /* ..for each one, create a new zval, copy entry into it
- and copy it into the output hash */
- for (i=0; i<list_count; i++) {
- entry = list[i];
- entry->refcount++;
- zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL);
- }
- }
-
- /* Copy the remaining input hash entries to the output hash */
- for ( ; p ; p=p->pListNext) {
- entry = *((zval **)p->pData);
- entry->refcount++;
- if (p->nKeyLength)
- zend_hash_update(out_hash, p->arKey, p->nKeyLength, &entry, sizeof(zval *), NULL);
- else
- zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL);
- }
-
- zend_hash_internal_pointer_reset(out_hash);
- return out_hash;
-}
-/* }}} */
-
-
-/* {{{ proto int array_push(array stack, mixed var [, ...])
- Pushes elements onto the end of the array */
-PHP_FUNCTION(array_push)
-{
- zval **args, /* Function arguments array */
- *stack, /* Input array */
- *new_var; /* Variable to be pushed */
- int i, /* Loop counter */
- argc; /* Number of function arguments */
-
- /* Get the argument count and check it */
- argc = ARG_COUNT(ht);
- if (argc < 2) {
- WRONG_PARAM_COUNT;
- }
-
- /* Allocate arguments array and get the arguments, checking for errors. */
- args = (zval **)emalloc(argc * sizeof(zval *));
- if (getParametersArray(ht, argc, args) == FAILURE) {
- efree(args);
- WRONG_PARAM_COUNT;
- }
-
- /* Get first argument and check that it's an array */
- stack = args[0];
- if (stack->type != IS_ARRAY) {
- zend_error(E_WARNING, "First argument to push() needs to be an array");
- RETURN_FALSE;
- }
-
- /* For each subsequent argument, make it a reference, increase refcount,
- and add it to the end of the array */
- for (i=1; i<argc; i++) {
- new_var = args[i];
- new_var->refcount++;
-
- zend_hash_next_index_insert(stack->value.ht, &new_var, sizeof(zval *), NULL);
- }
-
- /* Clean up and return the number of values in the stack */
- efree(args);
- RETVAL_LONG(zend_hash_num_elements(stack->value.ht));
-}
-/* }}} */
-
-
-/* {{{ void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int which_end) */
-static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
-{
- zval *stack, /* Input stack */
- **val; /* Value to be popped */
- HashTable *new_hash; /* New stack */
-
- /* Get the arguments and do error-checking */
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &stack) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (stack->type != IS_ARRAY) {
- zend_error(E_WARNING, "The argument needs to be an array");
- return;
- }
-
- if (zend_hash_num_elements(stack->value.ht) == 0) {
- return;
- }
-
- /* Get the first or last value and copy it into the return value */
- if (off_the_end)
- zend_hash_internal_pointer_end(stack->value.ht);
- else
- zend_hash_internal_pointer_reset(stack->value.ht);
- zend_hash_get_current_data(stack->value.ht, (void **)&val);
- *return_value = **val;
- zval_copy_ctor(return_value);
- INIT_PZVAL(return_value);
-
- /* Delete the first or last value */
- new_hash = _phpi_splice(stack->value.ht, (off_the_end) ? -1 : 0, 1, NULL, 0, NULL);
- zend_hash_destroy(stack->value.ht);
- efree(stack->value.ht);
- stack->value.ht = new_hash;
-}
-/* }}} */
-
-
-/* {{{ proto mixed array_pop(array stack)
- Pops an element off the end of the array */
-PHP_FUNCTION(array_pop)
-{
- _phpi_pop(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-
-/* {{{ proto mixed array_shift(array stack)
- Pops an element off the beginning of the array */
-PHP_FUNCTION(array_shift)
-{
- _phpi_pop(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-
-/* {{{ proto int array_unshift(array stack, mixed var [, ...])
- Pushes elements onto the beginning of the array */
-PHP_FUNCTION(array_unshift)
-{
- zval **args, /* Function arguments array */
- *stack; /* Input stack */
- HashTable *new_hash; /* New hashtable for the stack */
- int argc; /* Number of function arguments */
-
-
- /* Get the argument count and check it */
- argc = ARG_COUNT(ht);
- if (argc < 2) {
- WRONG_PARAM_COUNT;
- }
-
- /* Allocate arguments array and get the arguments, checking for errors. */
- args = (zval **)emalloc(argc * sizeof(zval *));
- if (getParametersArray(ht, argc, args) == FAILURE) {
- efree(args);
- WRONG_PARAM_COUNT;
- }
-
- /* Get first argument and check that it's an array */
- stack = args[0];
- if (stack->type != IS_ARRAY) {
- zend_error(E_WARNING, "First argument to push() needs to be an array");
- RETURN_FALSE;
- }
-
- /* Use splice to insert the elements at the beginning. Destroy old
- hashtable and replace it with new one */
- new_hash = _phpi_splice(stack->value.ht, 0, 0, &args[1], argc-1, NULL);
- zend_hash_destroy(stack->value.ht);
- efree(stack->value.ht);
- stack->value.ht = new_hash;
-
- /* Clean up and return the number of elements in the stack */
- efree(args);
- RETVAL_LONG(zend_hash_num_elements(stack->value.ht));
-}
-/* }}} */
-
-
-/* {{{ proto array array_splice(array input, int offset [, int length, mixed var [, ...] ])
- Removes the elements designated by offset and length and replace them with
- var's if supplied */
-PHP_FUNCTION(array_splice)
-{
- zval **args, /* Function arguments array */
- *array, /* Input array */
- **repl = NULL; /* Replacement elements */
- HashTable *new_hash = NULL; /* Output array's hash */
- Bucket *p; /* Bucket used for traversing hash */
- int argc, /* Number of function arguments */
- i,
- offset,
- length,
- repl_num = 0; /* Number of replacement elements */
-
- /* Get the argument count and check it */
- argc = ARG_COUNT(ht);
- if (argc < 2 || argc > 4) {
- WRONG_PARAM_COUNT;
- }
-
- /* Allocate arguments array and get the arguments, checking for errors. */
- args = (zval **)emalloc(argc * sizeof(zval *));
- if (getParametersArray(ht, argc, args) == FAILURE) {
- efree(args);
- WRONG_PARAM_COUNT;
- }
-
- /* Get first argument and check that it's an array */
- array = args[0];
- if (array->type != IS_ARRAY) {
- zend_error(E_WARNING, "First argument to splice() should be an array");
- efree(args);
- return;
- }
-
- /* Get the next two arguments. If length is omitted,
- it's assumed to be until the end of the array */
- convert_to_long(args[1]);
- offset = args[1]->value.lval;
- if (argc > 2) {
- convert_to_long(args[2]);
- length = args[2]->value.lval;
- } else
- length = zend_hash_num_elements(array->value.ht);
-
- if (argc == 4) {
- /* Make sure the last argument, if passed, is an array */
- convert_to_array(args[3]);
-
- /* Create the array of replacement elements */
- repl_num = zend_hash_num_elements(args[3]->value.ht);
- repl = (zval **)emalloc(repl_num * sizeof(zval *));
- for (p=args[3]->value.ht->pListHead, i=0; p; p=p->pListNext, i++) {
- repl[i] = *((zval **)p->pData);
- }
- }
-
- /* Initialize return value */
- array_init(return_value);
-
- /* Perform splice */
- new_hash = _phpi_splice(array->value.ht, offset, length,
- repl, repl_num,
- &return_value->value.ht);
-
- /* Replace input array's hashtable with the new one */
- zend_hash_destroy(array->value.ht);
- efree(array->value.ht);
- array->value.ht = new_hash;
-
- /* Clean up */
- if (argc == 4)
- efree(repl);
- efree(args);
-}
-/* }}} */
-
-
-/* {{{ proto array array_slice(array input, int offset [, int length])
- Returns elements specified by offset and length */
-PHP_FUNCTION(array_slice)
-{
- zval *input, /* Input array */
- *offset, /* Offset to get elements from */
- *length, /* How many elements to get */
- **entry; /* An array entry */
- int offset_val, /* Value of the offset argument */
- length_val, /* Value of the length argument */
- num_in, /* Number of elements in the input array */
- pos, /* Current position in the array */
- argc; /* Number of function arguments */
-
- char *string_key;
- ulong num_key;
-
-
- /* Get the arguments and do error-checking */
- argc = ARG_COUNT(ht);
- if (argc < 2 || argc > 3 || getParameters(ht, argc, &input, &offset, &length)) {
- WRONG_PARAM_COUNT;
- }
-
- if (input->type != IS_ARRAY) {
- zend_error(E_WARNING, "First argument to slice() should be an array");
- return;
- }
-
- /* Make sure offset and length are integers and assume
- we want all entries from offset to the end if length
- is not passed */
- convert_to_long(offset);
- offset_val = offset->value.lval;
- if (argc == 3) {
- convert_to_long(length);
- length_val = length->value.lval;
- } else
- length_val = zend_hash_num_elements(input->value.ht);
-
- /* Initialize returned array */
- array_init(return_value);
-
- /* Get number of entries in the input hash */
- num_in = zend_hash_num_elements(input->value.ht);
-
- /* Clamp the offset.. */
- if (offset_val > num_in)
- return;
- else if (offset_val < 0 && (offset_val=num_in+offset_val) < 0)
- offset_val = 0;
-
- /* ..and the length */
- if (length_val < 0)
- length_val = num_in-offset_val+length_val;
- else if(offset_val+length_val > num_in)
- length_val = num_in-offset_val;
-
- if (length_val == 0)
- return;
-
- /* Start at the beginning and go until we hit offset */
- pos = 0;
- zend_hash_internal_pointer_reset(input->value.ht);
- while(pos < offset_val &&
- zend_hash_get_current_data(input->value.ht, (void **)&entry) == SUCCESS) {
- pos++;
- zend_hash_move_forward(input->value.ht);
- }
-
- /* Copy elements from input array to the one that's returned */
- while(pos < offset_val+length_val &&
- zend_hash_get_current_data(input->value.ht, (void **)&entry) == SUCCESS) {
-
- (*entry)->refcount++;
-
- switch (zend_hash_get_current_key(input->value.ht, &string_key, &num_key)) {
- case HASH_KEY_IS_STRING:
- zend_hash_update(return_value->value.ht, string_key, strlen(string_key)+1,
- entry, sizeof(zval *), NULL);
- efree(string_key);
- break;
-
- case HASH_KEY_IS_LONG:
- zend_hash_next_index_insert(return_value->value.ht,
- entry, sizeof(zval *), NULL);
- break;
- }
- pos++;
- zend_hash_move_forward(input->value.ht);
- }
-}
-/* }}} */
-
-
-/* {{{ proto array array_merge(array arr1, array arr2 [, ...])
- Merges elements from passed arrays into one array */
-PHP_FUNCTION(array_merge)
-{
- zval **args = NULL,
- **entry;
- HashTable *hash;
- int argc,
- i;
- char *string_key;
- ulong num_key;
-
- /* Get the argument count and check it */
- argc = ARG_COUNT(ht);
- if (argc < 2) {
- WRONG_PARAM_COUNT;
- }
-
- /* Allocate arguments array and get the arguments, checking for errors. */
- args = (zval **)emalloc(argc * sizeof(zval *));
- if (getParametersArray(ht, argc, args) == FAILURE) {
- efree(args);
- WRONG_PARAM_COUNT;
- }
-
- array_init(return_value);
-
- for (i=0; i<argc; i++) {
- if (args[i]->type != IS_ARRAY) {
- zend_error(E_WARNING, "Skipping argument #%d to array_merge(), since it's not an array", i+1);
- continue;
- }
- hash = args[i]->value.ht;
-
- zend_hash_internal_pointer_reset(hash);
- while(zend_hash_get_current_data(hash, (void **)&entry) == SUCCESS) {
- (*entry)->refcount++;
-
- switch (zend_hash_get_current_key(hash, &string_key, &num_key)) {
- case HASH_KEY_IS_STRING:
- zend_hash_update(return_value->value.ht, string_key, strlen(string_key)+1,
- entry, sizeof(zval *), NULL);
- efree(string_key);
- break;
-
- case HASH_KEY_IS_LONG:
- zend_hash_next_index_insert(return_value->value.ht,
- entry, sizeof(zval *), NULL);
- break;
- }
-
- zend_hash_move_forward(hash);
- }
- }
-
- efree(args);
-}
-/* }}} */
-
-
-/* {{{ proto array array_keys(array input [, mixed search_value])
- Return just the keys from the input array, optionally only
- for the specified search_value */
-PHP_FUNCTION(array_keys)
-{
- zval *input, /* Input array */
- *search_value, /* Value to search for */
- **entry, /* An entry in the input array */
- res, /* Result of comparison */
- *new_val; /* New value */
- int add_key; /* Flag to indicate whether a key should be added */
- char *string_key; /* String key */
- ulong num_key; /* Numeric key */
-
- search_value = NULL;
-
- /* Get arguments and do error-checking */
- if (ARG_COUNT(ht) < 1 || ARG_COUNT(ht) > 2 ||
- getParameters(ht, ARG_COUNT(ht), &input, &search_value) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (input->type != IS_ARRAY) {
- zend_error(E_WARNING, "First argument to array_keys() should be an array");
- return;
- }
-
- /* Initialize return array */
- array_init(return_value);
- add_key = 1;
-
- /* Go through input array and add keys to the return array */
- zend_hash_internal_pointer_reset(input->value.ht);
- while(zend_hash_get_current_data(input->value.ht, (void **)&entry) == SUCCESS) {
- if (search_value != NULL) {
- is_equal_function(&res, search_value, *entry);
- add_key = zval_is_true(&res);
- }
-
- if (add_key) {
- new_val = (zval *)emalloc(sizeof(zval));
- INIT_PZVAL(new_val);
-
- switch (zend_hash_get_current_key(input->value.ht, &string_key, &num_key)) {
- case HASH_KEY_IS_STRING:
- new_val->type = IS_STRING;
- new_val->value.str.val = string_key;
- new_val->value.str.len = strlen(string_key);
- zend_hash_next_index_insert(return_value->value.ht, &new_val,
- sizeof(zval *), NULL);
- break;
-
- case HASH_KEY_IS_LONG:
- new_val->type = IS_LONG;
- new_val->value.lval = num_key;
- zend_hash_next_index_insert(return_value->value.ht, &new_val,
- sizeof(zval *), NULL);
- break;
- }
- }
-
- zend_hash_move_forward(input->value.ht);
- }
-}
-/* }}} */
-
-
-/* {{{ proto array array_values(array input)
- Return just the values from the input array */
-PHP_FUNCTION(array_values)
-{
- zval *input, /* Input array */
- **entry; /* An entry in the input array */
-
- /* Get arguments and do error-checking */
- if (ARG_COUNT(ht) != 1 || getParameters(ht, ARG_COUNT(ht), &input) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (input->type != IS_ARRAY) {
- zend_error(E_WARNING, "Argument to array_values() should be an array");
- return;
- }
-
- /* Initialize return array */
- array_init(return_value);
-
- /* Go through input array and add values to the return array */
- zend_hash_internal_pointer_reset(input->value.ht);
- while(zend_hash_get_current_data(input->value.ht, (void **)&entry) == SUCCESS) {
-
- (*entry)->refcount++;
- zend_hash_next_index_insert(return_value->value.ht, entry,
- sizeof(zval *), NULL);
-
- zend_hash_move_forward(input->value.ht);
- }
-}
-/* }}} */
-
-/* {{{ proto array array_count_values(array input)
- Return the value as key and the frequency of that value in <input> as value */
-PHP_FUNCTION(array_count_values)
-{
- zval **input, /* Input array */
- **entry; /* An entry in the input array */
- zval **tmp;
- HashTable *myht;
-
- /* Get arguments and do error-checking */
- if (ARG_COUNT(ht) != 1 || getParametersEx(1, &input) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if ((*input)->type != IS_ARRAY) {
- zend_error(E_WARNING, "Argument to array_count_values() should be an array");
- return;
- }
-
- /* Initialize return array */
- array_init(return_value);
-
- /* Go through input array and add values to the return array */
- myht = (*input)->value.ht;
- zend_hash_internal_pointer_reset(myht);
- while (zend_hash_get_current_data(myht, (void **)&entry) == SUCCESS) {
- if ((*entry)->type == IS_LONG) {
- if (zend_hash_index_find(return_value->value.ht,
- (*entry)->value.lval,
- (void**)&tmp) == FAILURE) {
- zval *data;
- MAKE_STD_ZVAL(data);
- data->type = IS_LONG;
- data->value.lval = 1;
- zend_hash_index_update(return_value->value.ht,(*entry)->value.lval, &data, sizeof(data), NULL);
- } else {
- (*tmp)->value.lval++;
- }
- } else if ((*entry)->type == IS_STRING) {
- if (zend_hash_find(return_value->value.ht,
- (*entry)->value.str.val,
- (*entry)->value.str.len+1,
- (void**)&tmp) == FAILURE) {
- zval *data;
- MAKE_STD_ZVAL(data);
- data->type = IS_LONG;
- data->value.lval = 1;
- zend_hash_update(return_value->value.ht,(*entry)->value.str.val,(*entry)->value.str.len + 1, &data, sizeof(data), NULL);
- } else {
- (*tmp)->value.lval++;
- }
- } else {
- zend_error(E_WARNING, "Can only count STRING and INTEGER values!");
- }
-
- zend_hash_move_forward(myht);
- }
-}
-/* }}} */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h
deleted file mode 100644
index d33a5559c8..0000000000
--- a/ext/standard/basic_functions.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Andi Gutmans <andi@zend.com> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _BASIC_FUNCTIONS_H
-#define _BASIC_FUNCTIONS_H
-
-#include "zend_highlight.h"
-
-extern php3_module_entry basic_functions_module;
-#define basic_functions_module_ptr &basic_functions_module
-
-PHP_MINIT_FUNCTION(basic);
-PHP_MSHUTDOWN_FUNCTION(basic);
-PHP_RINIT_FUNCTION(basic);
-PHP_RSHUTDOWN_FUNCTION(basic);
-
-PHP_FUNCTION(intval);
-PHP_FUNCTION(doubleval);
-PHP_FUNCTION(strval);
-PHP_FUNCTION(toggle_short_open_tag);
-PHP_FUNCTION(sleep);
-PHP_FUNCTION(usleep);
-PHP_FUNCTION(ksort);
-PHP_FUNCTION(asort);
-PHP_FUNCTION(arsort);
-PHP_FUNCTION(sort);
-PHP_FUNCTION(rsort);
-PHP_FUNCTION(usort);
-PHP_FUNCTION(uasort);
-PHP_FUNCTION(uksort);
-PHP_FUNCTION(array_walk);
-PHP_FUNCTION(count);
-PHP_FUNCTION(flush);
-PHP_FUNCTION(end);
-PHP_FUNCTION(prev);
-PHP_FUNCTION(next);
-PHP_FUNCTION(each);
-PHP_FUNCTION(reset);
-PHP_FUNCTION(current);
-PHP_FUNCTION(key);
-PHP_FUNCTION(gettype);
-PHP_FUNCTION(settype);
-PHP_FUNCTION(min);
-PHP_FUNCTION(max);
-
-/* system functions */
-PHP_FUNCTION(getenv);
-PHP_FUNCTION(putenv);
-PHP_FUNCTION(error_reporting);
-
-PHP_FUNCTION(get_current_user);
-PHP_FUNCTION(set_time_limit);
-
-PHP_FUNCTION(get_cfg_var);
-PHP_FUNCTION(set_magic_quotes_runtime);
-PHP_FUNCTION(get_magic_quotes_runtime);
-PHP_FUNCTION(get_magic_quotes_gpc);
-
-void php3_is_type(INTERNAL_FUNCTION_PARAMETERS, int type);
-PHP_FUNCTION(is_long);
-PHP_FUNCTION(is_double);
-PHP_FUNCTION(is_string);
-PHP_FUNCTION(is_array);
-PHP_FUNCTION(is_object);
-
-PHP_FUNCTION(get_class);
-PHP_FUNCTION(get_parent_class);
-PHP_FUNCTION(method_exists);
-
-PHP_FUNCTION(leak);
-
-PHP_FUNCTION(error_log);
-
-PHP_FUNCTION(call_user_func);
-PHP_FUNCTION(call_user_method);
-
-PHP_FUNCTION(register_shutdown_function);
-PHP_FUNCTION(highlight_file);
-PHP_FUNCTION(highlight_string);
-ZEND_API void php_get_highlight_struct(zend_syntax_highlighter_ini *syntax_highlighter_ini);
-
-PHP_FUNCTION(ob_start);
-PHP_FUNCTION(ob_end_flush);
-PHP_FUNCTION(ob_end_clean);
-PHP_FUNCTION(ob_get_contents);
-
-PHP_FUNCTION(ini_get);
-PHP_FUNCTION(ini_alter);
-PHP_FUNCTION(ini_restore);
-
-PHP_FUNCTION(print_r);
-
-PHP_FUNCTION(define);
-PHP_FUNCTION(defined);
-
-PHP_FUNCTION(connection_aborted);
-PHP_FUNCTION(connection_timeout);
-PHP_FUNCTION(connection_status);
-PHP_FUNCTION(ignore_user_abort);
-
-PHP_FUNCTION(function_exists);
-PHP_FUNCTION(in_array);
-PHP_FUNCTION(extract);
-PHP_FUNCTION(compact);
-PHP_FUNCTION(array_push);
-PHP_FUNCTION(array_pop);
-PHP_FUNCTION(array_shift);
-PHP_FUNCTION(array_unshift);
-PHP_FUNCTION(array_splice);
-PHP_FUNCTION(array_slice);
-PHP_FUNCTION(array_merge);
-PHP_FUNCTION(array_keys);
-PHP_FUNCTION(array_values);
-PHP_FUNCTION(array_count_values);
-
-#if HAVE_PUTENV
-typedef struct {
- char *putenv_string;
- char *previous_value;
- char *key;
- int key_len;
-} putenv_entry;
-#endif
-
-#endif /* _BASIC_FUNCTIONS_H */
diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c
deleted file mode 100644
index e9ba30f530..0000000000
--- a/ext/standard/browscap.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-#include "php.h"
-#include "php3_browscap.h"
-#include "php_ini.h"
-#include "php_regex.h"
-
-#include "zend_globals.h"
-
-#ifndef THREAD_SAFE
-HashTable browser_hash;
-static char *lookup_browser_name;
-static pval *found_browser_entry;
-#endif
-
-function_entry browscap_functions[] = {
- PHP_FE(get_browser, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry browscap_module_entry = {
- "browscap", browscap_functions, PHP_MINIT(browscap), PHP_MSHUTDOWN(browscap),
- NULL, NULL, NULL, STANDARD_MODULE_PROPERTIES
-};
-
-
-static int browser_reg_compare(pval *browser)
-{
- pval *browser_name;
- regex_t r;
-
- if (found_browser_entry) { /* already found */
- return 0;
- }
- zend_hash_find(browser->value.ht,"browser_name_pattern",sizeof("browser_name_pattern"),(void **) &browser_name);
- if (!strchr(browser_name->value.str.val,'*')) {
- return 0;
- }
- if (regcomp(&r,browser_name->value.str.val,REG_NOSUB)!=0) {
- return 0;
- }
- if (regexec(&r,lookup_browser_name,0,NULL,0)==0) {
- found_browser_entry = browser;
- }
- regfree(&r);
- return 0;
-}
-
-PHP_FUNCTION(get_browser)
-{
- pval *agent_name,*agent,tmp;
- ELS_FETCH();
-
- if (!INI_STR("browscap")) {
- RETURN_FALSE;
- }
-
- switch(ARG_COUNT(ht)) {
- case 0:
- if (zend_hash_find(&EG(symbol_table), "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT"), (void **) &agent_name)==FAILURE) {
- agent_name = &tmp;
- var_reset(agent_name);
- }
- break;
- case 1:
- if (getParameters(ht, 1, &agent_name)==FAILURE) {
- RETURN_FALSE;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- convert_to_string(agent_name);
-
- if (zend_hash_find(&browser_hash, agent_name->value.str.val, agent_name->value.str.len+1, (void **) &agent)==FAILURE) {
- lookup_browser_name = agent_name->value.str.val;
- found_browser_entry = NULL;
- zend_hash_apply(&browser_hash,(int (*)(void *)) browser_reg_compare);
-
- if (found_browser_entry) {
- agent = found_browser_entry;
- } else if (zend_hash_find(&browser_hash, "Default Browser", sizeof("Default Browser"), (void **) &agent)==FAILURE) {
- RETURN_FALSE;
- }
- }
-
- *return_value = *agent;
- return_value->type = IS_OBJECT;
- pval_copy_constructor(return_value);
- return_value->value.ht->pDestructor = PVAL_DESTRUCTOR;
-
- while (zend_hash_find(agent->value.ht, "parent", sizeof("parent"), (void **) &agent_name)==SUCCESS) {
- if (zend_hash_find(&browser_hash, agent_name->value.str.val, agent_name->value.str.len+1, (void **) &agent)==FAILURE) {
- break;
- }
- zend_hash_merge(return_value->value.ht, agent->value.ht, PVAL_COPY_CTOR, (void *) &tmp, sizeof(pval), 0);
- }
-}
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/config.h.stub b/ext/standard/config.h.stub
deleted file mode 100644
index 69ee82467f..0000000000
--- a/ext/standard/config.h.stub
+++ /dev/null
@@ -1,14 +0,0 @@
-/* Define if you have the crypt() function */
-#define HAVE_CRYPT 1
-
-/* Define if you have and want to use libcrypt */
-#define HAVE_LIBCRYPT 0
-
-/* crypt capability checks */
-#undef PHP3_STD_DES_CRYPT
-#undef PHP3_EXT_DES_CRYPT
-#undef PHP3_MD5_CRYPT
-#undef PHP3_BLOWFISH_CRYPT
-
-/* Define if you have libdl (used for dynamic linking) */
-#define HAVE_LIBDL 0
diff --git a/ext/standard/config.m4 b/ext/standard/config.m4
deleted file mode 100644
index 9796b201da..0000000000
--- a/ext/standard/config.m4
+++ /dev/null
@@ -1,123 +0,0 @@
-dnl $Id$ -*- sh -*-
-
-divert(1)
-
-dnl
-dnl Check for crypt() capabilities
-dnl
-AC_DEFUN(AC_CRYPT_CAP,[
-
- AC_MSG_CHECKING([for standard DES crypt])
- AC_TRY_RUN([
-main() {
-#if HAVE_CRYPT
- exit (strcmp((char *)crypt("rasmuslerdorf","rl"),"rl.3StKT.4T8M"));
-#else
- exit(0);
-#endif
-}],[
- AC_DEFINE(PHP3_STD_DES_CRYPT,1)
- AC_MSG_RESULT(yes)
- ],[
- AC_DEFINE(PHP3_STD_DES_CRYPT,0)
- AC_MSG_RESULT(no)
- ],[
- AC_DEFINE(PHP3_STD_DES_CRYPT,1)
- AC_MSG_RESULT(cannot check, guessing yes)
- ])
-
- AC_MSG_CHECKING([for extended DES crypt])
- AC_TRY_RUN([
-main() {
-#if HAVE_CRYPT
- exit (strcmp((char *)crypt("rasmuslerdorf","_J9..rasm"),"_J9..rasmBYk8r9AiWNc"));
-#else
- exit(0);
-#endif
-}],[
- AC_DEFINE(PHP3_EXT_DES_CRYPT,1)
- AC_MSG_RESULT(yes)
- ],[
- AC_DEFINE(PHP3_EXT_DES_CRYPT,0)
- AC_MSG_RESULT(no)
- ],[
- AC_DEFINE(PHP3_EXT_DES_CRYPT,0)
- AC_MSG_RESULT(cannot check, guessing no)
- ])
-
- AC_MSG_CHECKING([for MD5 crypt])
- AC_TRY_RUN([
-main() {
-#if HAVE_CRYPT
- char salt[15], answer[40];
-
- salt[0]='$'; salt[1]='1'; salt[2]='$';
- salt[3]='r'; salt[4]='a'; salt[5]='s';
- salt[6]='m'; salt[7]='u'; salt[8]='s';
- salt[9]='l'; salt[10]='e'; salt[11]='$';
- salt[12]='\0';
- strcpy(answer,salt);
- strcat(answer,"rISCgZzpwk3UhDidwXvin0");
- exit (strcmp((char *)crypt("rasmuslerdorf",salt),answer));
-#else
- exit(0);
-#endif
-}],[
- AC_DEFINE(PHP3_MD5_CRYPT,1)
- AC_MSG_RESULT(yes)
- ],[
- AC_DEFINE(PHP3_MD5_CRYPT,0)
- AC_MSG_RESULT(no)
- ],[
- AC_DEFINE(PHP3_MD5_CRYPT,0)
- AC_MSG_RESULT(cannot check, guessing no)
- ])
-
- AC_MSG_CHECKING([for Blowfish crypt])
- AC_TRY_RUN([
-main() {
-#if HAVE_CRYPT
- char salt[25], answer[70];
-
- salt[0]='$'; salt[1]='2'; salt[2]='a'; salt[3]='$'; salt[4]='0'; salt[5]='7'; salt[6]='$'; salt[7]='\0';
- strcat(salt,"rasmuslerd");
- strcpy(answer,salt);
- strcpy(&answer[16],"O............gl95GkTKn53Of.H4YchXl5PwvvW.5ri");
- exit (strcmp((char *)crypt("rasmuslerdorf",salt),answer));
-#else
- exit(0);
-#endif
-}],[
- AC_DEFINE(PHP3_BLOWFISH_CRYPT,1)
- AC_MSG_RESULT(yes)
- ],[
- AC_DEFINE(PHP3_BLOWFISH_CRYPT,0)
- AC_MSG_RESULT(no)
- ],[
- AC_DEFINE(PHP3_BLOWFISH_CRYPT,0)
- AC_MSG_RESULT(cannot check, guessing no)
- ])
-])
-
-AC_CHECK_LIB(c, dlopen, [
- # fake it
- AC_DEFINE(HAVE_LIBDL) ], [
- AC_CHECK_LIB(dl, dlopen, [
- LIBS="-ldl $LIBS"
- AC_DEFINE(HAVE_LIBDL) ], []) ])
-
-AC_CHECK_LIB(pam, pam_start, [
- EXTRA_LIBS="$EXTRA_LIBS -lpam"
- AC_DEFINE(HAVE_LIBPAM) ], [])
-
-AC_CHECK_LIB(bind, inet_aton, [
- EXTRA_LIBS="$EXTRA_LIBS -lbind"
- AC_DEFINE(HAVE_LIBBIND) ], [])
-
-
-AC_CRYPT_CAP
-
-divert(3)
-
-PHP_EXTENSION(standard)
-
diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c
deleted file mode 100644
index aa71099382..0000000000
--- a/ext/standard/crypt.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Stig Bakken <ssb@gaurdian.no> |
- | Zeev Suraski <zeev@zend.com> |
- | Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-#include <stdlib.h>
-
-#include "php.h"
-
-#if HAVE_CRYPT
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#if HAVE_CRYPT_H
-#include <crypt.h>
-#endif
-#if TM_IN_SYS_TIME
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-#if HAVE_STRING_H
-#include <string.h>
-#else
-#include <strings.h>
-#endif
-
-#if MSVC5
-#include <process.h>
-extern char *crypt(char *__key,char *__salt);
-#endif
-
-#include "php3_crypt.h"
-
-function_entry crypt_functions[] = {
- PHP_FE(crypt, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry crypt_module_entry = {
- "Crypt", crypt_functions, PHP_MINIT(crypt), NULL, NULL, NULL, NULL, STANDARD_MODULE_PROPERTIES
-};
-
-
-/*
- The capabilities of the crypt() function is determined by the test programs
- run by configure from aclocal.m4. They will set PHP3_STD_DES_CRYPT,
- PHP3_EXT_DES_CRYPT, PHP3_MD5_CRYPT and PHP3_BLOWFISH_CRYPT as appropriate
- for the target platform
-*/
-#if PHP3_STD_DES_CRYPT
-#define PHP3_MAX_SALT_LEN 2
-#endif
-#if PHP3_EXT_DES_CRYPT
-#undef PHP3_MAX_SALT_LEN
-#define PHP3_MAX_SALT_LEN 9
-#endif
-#if PHP3_MD5_CRYPT
-#undef PHP3_MAX_SALT_LEN
-#define PHP3_MAX_SALT_LEN 12
-#endif
-#if PHP3_BLOWFISH_CRYPT
-#undef PHP3_MAX_SALT_LEN
-#define PHP3_MAX_SALT_LEN 17
-#endif
-
-#if HAVE_LRAND48
-#define PHP3_CRYPT_RAND lrand48()
-#else
-#if HAVE_RANDOM
-#define PHP3_CRYPT_RAND random()
-#else
-#define PHP3_CRYPT_RAND rand()
-#endif
-#endif
-
-PHP_MINIT_FUNCTION(crypt)
-{
- ELS_FETCH();
-
-#if PHP3_STD_DES_CRYPT
- REGISTER_LONG_CONSTANT("CRYPT_SALT_LENGTH", 2, CONST_CS | CONST_PERSISTENT);
-#else
-#if PHP3_MD5_CRYPT
- REGISTER_LONG_CONSTANT("CRYPT_SALT_LENGTH", 12, CONST_CS | CONST_PERSISTENT);
-#endif
-#endif
- REGISTER_LONG_CONSTANT("CRYPT_STD_DES", PHP3_STD_DES_CRYPT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("CRYPT_EXT_DES", PHP3_EXT_DES_CRYPT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("CRYPT_MD5", PHP3_MD5_CRYPT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("CRYPT_BLOWFISH", PHP3_BLOWFISH_CRYPT, CONST_CS | CONST_PERSISTENT);
- return SUCCESS;
-}
-
-static unsigned char itoa64[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-
-static void php3i_to64(char *s, long v, int n) {
- while (--n >= 0) {
- *s++ = itoa64[v&0x3f];
- v >>= 6;
- }
-}
-
-PHP_FUNCTION(crypt)
-{
- char salt[PHP3_MAX_SALT_LEN+1];
- pval *arg1, *arg2;
-
- salt[0]=salt[PHP3_MAX_SALT_LEN]='\0';
- /* This will produce suitable results if people depend on DES-encryption
- available (passing always 2-character salt). At least for glibc6.1 */
- memset(&salt[1], '$', PHP3_MAX_SALT_LEN-1);
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &arg1)==FAILURE) {
- RETURN_FALSE;
- }
- break;
- case 2:
- if (getParameters(ht, 2, &arg1, &arg2)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(arg2);
- memcpy(salt, arg2->value.str.val, MIN(PHP3_MAX_SALT_LEN,arg2->value.str.len));
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
- convert_to_string(arg1);
-
- /* The automatic salt generation only covers standard DES and md5-crypt */
- if(!*salt) {
-#if HAVE_SRAND48
- srand48((unsigned int) time(0) * getpid());
-#else
-#if HAVE_SRANDOM
- srandom((unsigned int) time(0) * getpid());
-#else
- srand((unsigned int) time(0) * getpid());
-#endif
-#endif
-
-#if PHP3_STD_DES_CRYPT
- php3i_to64(&salt[0], PHP3_CRYPT_RAND, 2);
- salt[2] = '\0';
-#else
-#if PHP3_MD5_CRYPT
- strcpy(salt, "$1$");
- php3i_to64(&salt[3], PHP3_CRYPT_RAND, 4);
- php3i_to64(&salt[7], PHP3_CRYPT_RAND, 4);
- strcpy(&salt[11], "$");
-#endif
-#endif
- }
-
- return_value->value.str.val = (char *) crypt(arg1->value.str.val, salt);
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
- pval_copy_constructor(return_value);
-}
-
-#endif
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/cyr_convert.c b/ext/standard/cyr_convert.c
deleted file mode 100644
index f99ec4a254..0000000000
--- a/ext/standard/cyr_convert.c
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Kirill Maximov <kir@rus.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include <stdlib.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <string.h>
-#include <errno.h>
-
-#include "php.h"
-#include "cyr_convert.h"
-
-#include <stdio.h>
-
-
-
-
-/*****************************************************************************
-* This is codetables for different Cyrillic charsets (relative to koi8-r).
-* Each table contains data for 128-255 symbols from ASCII table.
-* First 256 symbols are for conversion from koi8-r to corresponding charset,
-* second 256 symbols are for reverse conversion, from charset to koi8-r.
-*
-* Here we have the following tables:
-* _cyr_win1251 - for windows-1251 charset
-* _cyr_iso88595 - for iso8859-5 charset
-* _cyr_cp866 - for x-cp866 charset
-* _cyr_mac - for x-mac-cyrillic charset
-*
-*****************************************************************************/
-
-typedef unsigned char _cyr_charset_table[512];
-
-const static _cyr_charset_table _cyr_win1251 = {
-0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
-16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
-32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
-48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
-64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
-80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
-96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
-112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
-46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,
-46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,
-46,46,46,46,46,46,46,46,179,46,32,46,46,46,46,32,
-46,46,46,46,46,46,46,46,163,46,32,46,46,46,46,32,
-225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,
-242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,
-193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,
-210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,209,
-0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
-16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
-32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
-48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
-64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
-80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
-96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
-112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
-32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
-32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
-32,32,32,184,32,32,32,32,32,32,32,32,32,32,32,32,
-32,32,32,168,32,32,32,32,32,32,32,32,32,32,32,32,
-254,224,225,246,228,229,244,227,245,232,233,234,235,236,237,238,
-239,255,240,241,242,243,230,226,252,251,231,248,253,249,247,250,
-222,192,193,214,196,197,212,195,213,200,201,202,203,204,205,206,
-207,223,208,209,210,211,198,194,220,219,199,216,221,217,215,218,
-},
-_cyr_cp866 = {
-0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
-16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
-32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
-48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
-64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
-80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
-96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
-112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
-225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,
-242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,
-193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,
-35,35,35,124,124,124,124,43,43,124,124,43,43,43,43,43,
-43,45,45,124,45,43,124,124,43,43,45,45,124,45,43,45,
-45,45,45,43,43,43,43,43,43,43,43,35,35,124,124,35,
-210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,209,
-179,163,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
-0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
-16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
-32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
-48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
-64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
-80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
-96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
-112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
-32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
-32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
-32,32,32,241,32,32,32,32,32,32,32,32,32,32,32,32,
-32,32,32,240,32,32,32,32,32,32,32,32,32,32,32,32,
-238,160,161,230,164,165,228,163,229,168,169,170,171,172,173,174,
-175,239,224,225,226,227,166,162,236,235,167,232,237,233,231,234,
-158,128,129,150,132,133,148,131,149,136,137,138,139,140,141,142,
-143,159,144,145,146,147,134,130,156,155,135,152,157,153,151,154,
-},
-_cyr_iso88595 = {
-0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
-16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
-32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
-48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
-64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
-80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
-96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
-112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
-32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
-32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
-32,179,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
-225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,
-242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,
-193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,
-210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,209,
-32,163,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
-0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
-16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
-32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
-48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
-64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
-80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
-96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
-112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
-32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
-32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
-32,32,32,241,32,32,32,32,32,32,32,32,32,32,32,32,
-32,32,32,161,32,32,32,32,32,32,32,32,32,32,32,32,
-238,208,209,230,212,213,228,211,229,216,217,218,219,220,221,222,
-223,239,224,225,226,227,214,210,236,235,215,232,237,233,231,234,
-206,176,177,198,180,181,196,179,197,184,185,186,187,188,189,190,
-191,207,192,193,194,195,182,178,204,203,183,200,205,201,199,202,
-},
-_cyr_mac = {
-0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
-16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
-32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
-48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
-64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
-80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
-96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
-112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
-225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,
-242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,
-160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
-176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
-128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
-144,145,146,147,148,149,150,151,152,153,154,155,156,179,163,209,
-193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,
-210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,255,
-0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
-16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
-32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
-48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
-64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
-80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
-96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
-112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
-192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
-208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
-160,161,162,222,164,165,166,167,168,169,170,171,172,173,174,175,
-176,177,178,221,180,181,182,183,184,185,186,187,188,189,190,191,
-254,224,225,246,228,229,244,227,245,232,233,234,235,236,237,238,
-239,223,240,241,242,243,230,226,252,251,231,248,253,249,247,250,
-158,128,129,150,132,133,148,131,149,136,137,138,139,140,141,142,
-143,159,144,145,146,147,134,130,156,155,135,152,157,153,151,154,
-};
-
-
-/*****************************************************************************
-* This is the function that performs real in-place conversion of the string
-* between charsets.
-* Parameters:
-* str - string to be converted
-* from,to - one-symbol label of source and destination charset
-* The following symbols are used as labels:
-* k - koi8-r
-* w - windows-1251
-* i - iso8859-5
-* a - x-cp866
-* d - x-cp866
-* m - x-mac-cyrillic
-*****************************************************************************/
-static char * _php3_convert_cyr_string(unsigned char *str, char from, char to)
-{
- const unsigned char *from_table, *to_table;
- unsigned char tmp;
- int i;
-
- from_table = NULL;
- to_table = NULL;
-
- switch (toupper(from))
- {
- case 'W':
- from_table = _cyr_win1251;
- break;
- case 'A':
- case 'D':
- from_table = _cyr_cp866;
- break;
- case 'I':
- from_table = _cyr_iso88595;
- break;
- case 'M':
- from_table = _cyr_mac;
- break;
- case 'K':
- break;
- default:
- php_error(E_WARNING, "Unknown source charset: %c", from);
- break;
- }
-
- switch (toupper(to))
- {
- case 'W':
- to_table = _cyr_win1251;
- break;
- case 'A':
- case 'D':
- to_table = _cyr_cp866;
- break;
- case 'I':
- to_table = _cyr_iso88595;
- break;
- case 'M':
- to_table = _cyr_mac;
- break;
- case 'K':
- break;
- default:
- php_error(E_WARNING, "Unknown destination charset: %c", to);
- break;
- }
-
-
- if (!str)
- return (char *)str;
-
- for( i = 0; str[i]; i++)
- {
- tmp = (from_table == NULL)? str[i] : from_table[ str[i] ];
- str[i] = (to_table == NULL) ? tmp : to_table[tmp + 256];
- }
- return (char *)str;
-}
-
-/* {{{ proto string convert_cyr_string(string str, string from, string to)
- Convert from one Cyrillic character set to another */
-PHP_FUNCTION(convert_cyr_string)
-{
- pval *str_arg, *fr_cs, *to_cs;
- unsigned char *str;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht,3,&str_arg, &fr_cs, &to_cs)==FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str_arg);
- convert_to_string(fr_cs);
- convert_to_string(to_cs);
-
- str = (unsigned char*) str_arg->value.str.val;
-
- _php3_convert_cyr_string(str, fr_cs->value.str.val[0], to_cs->value.str.val[0]);
- RETVAL_STRING((char *)str, 1)
-}
-/* }}} */
diff --git a/ext/standard/cyr_convert.h b/ext/standard/cyr_convert.h
deleted file mode 100644
index 91eb2346ec..0000000000
--- a/ext/standard/cyr_convert.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Kirill Maximov (kir@rus.net) |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _CYR_CONVERT_H
-#define _CYR_CONVERT_H
-
-PHP_FUNCTION(convert_cyr_string);
-
-#endif /* _CYR_CONVERT_H */
-
-
-
diff --git a/ext/standard/datetime.c b/ext/standard/datetime.c
deleted file mode 100644
index 0cb3aacbdb..0000000000
--- a/ext/standard/datetime.c
+++ /dev/null
@@ -1,658 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Andi Gutmans <andi@zend.com> |
- | Zeev Suraski <zeev@zend.com> |
- | Rasmus Lerdorf <rasmus@php.net> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-
-#include "php.h"
-#include "zend_operators.h"
-#include "datetime.h"
-#include "snprintf.h"
-#include "php_globals.h"
-
-#include <time.h>
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#include <stdio.h>
-
-char *mon_full_names[] =
-{
- "January", "February", "March", "April",
- "May", "June", "July", "August",
- "September", "October", "November", "December"
-};
-char *mon_short_names[] =
-{
- "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
-};
-char *day_full_names[] =
-{
- "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
-};
-char *day_short_names[] =
-{
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
-};
-
-#if !defined(HAVE_TM_ZONE) && !defined(_TIMEZONE) && !(WIN32||WINNT)
-extern time_t timezone;
-#endif
-
-static int phpday_tab[2][12] =
-{
- {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
- {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
-};
-
-#define isleap(year) (((year%4) == 0 && (year%100)!=0) || (year%400)==0)
-
-extern PHPAPI time_t parsedate(char *p, struct timeval *now);
-
-
-PHP_FUNCTION(time)
-{
- return_value->value.lval = (long) time(NULL);
- return_value->type = IS_LONG;
-}
-
-void _php3_mktime(INTERNAL_FUNCTION_PARAMETERS, int gm)
-{
- pval *arguments[7];
- struct tm ta, *tn;
- time_t t;
- int i, gmadjust=0,arg_count = ARG_COUNT(ht);
-
- if (arg_count > 7 || getParametersArray(ht, arg_count, arguments) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- /* convert supplied arguments to longs */
- for (i = 0; i < arg_count; i++) {
- convert_to_long(arguments[i]);
- }
- t = time(NULL);
-#ifdef HAVE_TZSET
- tzset();
-#endif
- /*
- ** Set default time parameters with local time values,
- ** EVEN when some GMT time parameters are specified!
- ** This may give strange result, with PHP gmmktime(0,0,0),
- ** which is assumed to return GMT midnight time
- ** for today (in localtime), so that the result time may be
- ** AFTER or BEFORE the current time.
- ** May be we should initialize tn using gmtime(), so that
- ** default parameters for PHP gmmktime would be the current
- ** GMT time values...
- */
- tn = localtime(&t);
- memcpy(&ta, tn, sizeof(struct tm));
- if (gm) {
- ta.tm_isdst = 0; /* force winter time if UTC flag is true */
- /* unless the UTC flag is specified after GMT date parameters. */
- }
- else {
- ta.tm_isdst = -1; /* let DST unknown */
- /* this will recompute the DST status for the */
- /* given date, based on localtime rules. */
- /* Most often, this will return the same value */
- }
-
- /*
- ** Now change date values with supplied parameters.
- */
- switch(arg_count) {
- case 7:
- ta.tm_isdst = arguments[6]->value.lval;
- /* fall-through */
- case 6:
- /*
- ** Accept parameter in range 0..1000 interpreted as 1900..2900
- ** (if 100 is given, it means year 2000)
- ** or in range 1001..9999 interpreted as is (this will store
- ** negative tm_year for years in range 1001..1899)
- ** This function is then Y2K ready, and accepts a wide range of
- ** dates including the whole gregorian calendar.
- ** But it cannot represent ancestral dates prior to year 1001.
- */
- ta.tm_year = arguments[5]->value.lval
- - ((arguments[5]->value.lval > 1000) ? 1900 : 0);
- /* fall-through */
- case 5:
- ta.tm_mday = arguments[4]->value.lval;
- /* fall-through */
- case 4:
- ta.tm_mon = arguments[3]->value.lval - 1;
- /* fall-through */
- case 3:
- ta.tm_sec = arguments[2]->value.lval;
- /* fall-through */
- case 2:
- ta.tm_min = arguments[1]->value.lval;
- /* fall-through */
- case 1:
- ta.tm_hour = arguments[0]->value.lval;
- /* fall-through */
- case 0:
- break;
- }
-
- if (gm) {
-#if HAVE_TM_GMTOFF
- /*
- ** If GMT parameters were given, mktime() will
- ** use the forced winter time local convention
- ** and the structure will be adjusted to compute
- ** the effective localtime GMT offset in seconds.
- ** This value depends on date parameters in ta.
- ** So this compute the Winter GMT offset.
- */
- t = mktime(&ta); /* Need to do this because of Daylight savings */
- tn = localtime(&t);
- /*
- ** Note: despite locatime() returns a global structure,
- ** structure, this structure is supposed to be thread-unique,
- ** (this is true with MS Visual compiler for Windows)
- ** so the localtime() function will be MT-safe.
- ** On other systems, localtime() may not return thread-unique
- ** structure, and won't be MT-safe. For now MT is supported
- ** only on Windows for the DLL versions of PHP.
- */
- gmadjust = tn->tm_gmtoff;
-#else
- /*
- ** Without tm_gmtoff, the non-ANSI C run-time global 'timezone'
- ** variable simply returns the current Winter GMT offset
- ** in the current locale (defined in DOS/Windows compilers).
- */
- gmadjust = timezone;
-#endif
- /*
- ** Adjust parameters, to void the GMT offset in seconds
- ** in the supplied parameters, because mktime() below
- ** computes a local time instead of GMT time.
- */
- ta.tm_hour += gmadjust / 3600;
- /* bug here: gmadjust % 3600 gives seconds, not minutes!!! */
- ta.tm_min += (gmadjust % 3600) / 60;
- /* is there any timezone with seconds ? */
- ta.tm_sec += gmadjust % 60;
- }
-
- RETURN_LONG(mktime(&ta));
-}
-
-PHP_FUNCTION(mktime)
-{
- _php3_mktime(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-
-PHP_FUNCTION(gmmktime)
-{
- _php3_mktime(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-
-static void
-_php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
-{
- pval *format, *timestamp;
- time_t the_time;
- struct tm *ta;
- int i, size = 0, length, h, beat;
- char tmp_buff[16];
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &format) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- the_time = time(NULL);
- break;
- case 2:
- if (getParameters(ht, 2, &format, &timestamp) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(timestamp);
- the_time = timestamp->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- }
- convert_to_string(format);
-
- if (gm) {
- ta = gmtime(&the_time);
- } else {
- ta = localtime(&the_time);
- }
-
- if (!ta) { /* that really shouldn't happen... */
- php_error(E_WARNING, "unexpected error in date()");
- RETURN_FALSE;
- }
- for (i = 0; i < format->value.str.len; i++) {
- switch (format->value.str.val[i]) {
- case 'U': /* seconds since the epoch */
- size += 10;
- break;
- case 'F': /* month, textual, full */
- case 'l': /* day (of the week), textual */
- case 'T': /* timezone name */
- size += 9;
- break;
- case 'Z': /* timezone offset in seconds */
- size += 6;
- break;
- case 'Y': /* year, numeric, 4 digits */
- size += 4;
- break;
- case 'M': /* month, textual, 3 letters */
- case 'D': /* day, textual, 3 letters */
- case 'z': /* day of the year, 1 to 366 */
- size += 3;
- break;
- case 'y': /* year, numeric, 2 digits */
- case 'm': /* month, numeric */
- case 'n': /* month, numeric, no leading zeroes */
- case 'd': /* day of the month, numeric */
- case 'j': /* day of the month, numeric, no leading zeros */
- case 'H': /* hour, numeric, 24 hour format */
- case 'h': /* hour, numeric, 12 hour format */
- case 'G': /* hour, numeric, 24 hour format, no leading zeroes */
- case 'g': /* hour, numeric, 12 hour format, no leading zeroes */
- case 'i': /* minutes, numeric */
- case 's': /* seconds, numeric */
- case 'A': /* AM/PM */
- case 'a': /* am/pm */
- case 'S': /* standard english suffix for the day of the month (e.g. 3rd, 2nd, etc) */
- case 't': /* days in current month */
- size += 2;
- break;
- case '\\':
- if(i < format->value.str.len-1) {
- i++;
- }
- case 'L': /* boolean for leap year */
- case 'B': /* Swatch Beat, 3 digits */
- size += 3;
- break;
- case 'w': /* day of the week, numeric */
- default:
- size++;
- break;
- }
- }
-
- return_value->value.str.val = (char *) emalloc(size + 1);
- return_value->value.str.val[0] = '\0';
-
- for (i = 0; i < format->value.str.len; i++) {
- switch (format->value.str.val[i]) {
- case '\\':
- if(i < format->value.str.len-1) {
- char ch[2];
- ch[0]=format->value.str.val[i+1];
- ch[1]='\0';
- strcat(return_value->value.str.val, ch);
- i++;
- }
- break;
- case 'U': /* seconds since the epoch */
- sprintf(tmp_buff, "%ld", (long)the_time); /* SAFE */
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 'F': /* month, textual, full */
- strcat(return_value->value.str.val, mon_full_names[ta->tm_mon]);
- break;
- case 'l': /* day (of the week), textual, full */
- strcat(return_value->value.str.val, day_full_names[ta->tm_wday]);
- break;
- case 'Y': /* year, numeric, 4 digits */
- sprintf(tmp_buff, "%d", ta->tm_year + 1900); /* SAFE */
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 'M': /* month, textual, 3 letters */
- strcat(return_value->value.str.val, mon_short_names[ta->tm_mon]);
- break;
- case 'D': /* day (of the week), textual, 3 letters */
- strcat(return_value->value.str.val, day_short_names[ta->tm_wday]);
- break;
- case 'z': /* day (of the year) */
- sprintf(tmp_buff, "%d", ta->tm_yday); /* SAFE */
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 'y': /* year, numeric, 2 digits */
- sprintf(tmp_buff, "%02d", ((ta->tm_year)%100)); /* SAFE */
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 'm': /* month, numeric */
- sprintf(tmp_buff, "%02d", ta->tm_mon + 1); /* SAFE */
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 'n': /* month, numeric, no leading zeros */
- sprintf(tmp_buff, "%d", ta->tm_mon + 1); /* SAFE */
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 'd': /* day of the month, numeric */
- sprintf(tmp_buff, "%02d", ta->tm_mday); /* SAFE */
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 'j':
- sprintf(tmp_buff, "%d", ta->tm_mday); /* SAFE */
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 'H': /* hour, numeric, 24 hour format */
- sprintf(tmp_buff, "%02d", ta->tm_hour); /* SAFE */
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 'h': /* hour, numeric, 12 hour format */
- h = ta->tm_hour % 12; if (h==0) h = 12;
- sprintf(tmp_buff, "%02d", h); /* SAFE */
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 'G': /* hour, numeric, 24 hour format, no leading zeros */
- sprintf(tmp_buff, "%d", ta->tm_hour); /* SAFE */
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 'g': /* hour, numeric, 12 hour format, no leading zeros */
- h = ta->tm_hour % 12; if (h==0) h = 12;
- sprintf(tmp_buff, "%d", h); /* SAFE */
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 'i': /* minutes, numeric */
- sprintf(tmp_buff, "%02d", ta->tm_min); /* SAFE */
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 's': /* seconds, numeric */
- sprintf(tmp_buff, "%02d", ta->tm_sec); /* SAFE */
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 'A': /* AM/PM */
- strcat(return_value->value.str.val, (ta->tm_hour >= 12 ? "PM" : "AM"));
- break;
- case 'a': /* am/pm */
- strcat(return_value->value.str.val, (ta->tm_hour >= 12 ? "pm" : "am"));
- break;
- case 'S': /* standard english suffix, e.g. 2nd/3rd for the day of the month */
- if (ta->tm_mday >= 10 && ta->tm_mday <= 19) {
- strcat(return_value->value.str.val, "th");
- } else {
- switch (ta->tm_mday % 10) {
- case 1:
- strcat(return_value->value.str.val, "st");
- break;
- case 2:
- strcat(return_value->value.str.val, "nd");
- break;
- case 3:
- strcat(return_value->value.str.val, "rd");
- break;
- default:
- strcat(return_value->value.str.val, "th");
- break;
- }
- }
- break;
- case 't': /* days in current month */
- sprintf(tmp_buff, "%2d", phpday_tab[isleap((ta->tm_year+1900))][ta->tm_mon] );
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 'w': /* day of the week, numeric EXTENSION */
- sprintf(tmp_buff, "%01d", ta->tm_wday); /* SAFE */
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 'Z': /* timezone offset in seconds */
-#if HAVE_TM_GMTOFF
- sprintf(tmp_buff, "%ld", ta->tm_gmtoff );
-#else
- sprintf(tmp_buff, "%ld", timezone);
-#endif
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 'L': /* boolean for leapyear */
- sprintf(tmp_buff, "%d", (isleap((ta->tm_year+1900)) ? 1 : 0 ) );
- strcat(return_value->value.str.val, tmp_buff);
- break;
- case 'T': /* timezone name */
-#if HAVE_TM_ZONE
- strcat(return_value->value.str.val, ta->tm_zone);
-#else
- strcat(return_value->value.str.val, tzname[0]);
-#endif
- break;
- case 'B': /* Swatch Beat a.k.a. Internet Time */
- beat = (((((long)the_time)-(((long)the_time) -
- ((((long)the_time) % 86400) + 3600))) * 10) / 864);
- if (beat > 999) beat = 0;
- sprintf(tmp_buff, "%03d", beat); /* SAFE */
- strcat(return_value->value.str.val, tmp_buff);
- break;
- default:
- length = strlen(return_value->value.str.val);
- return_value->value.str.val[length] = format->value.str.val[i];
- return_value->value.str.val[length + 1] = '\0';
- break;
- }
- }
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
-}
-
-PHP_FUNCTION(date)
-{
- _php3_date(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-
-PHP_FUNCTION(gmdate)
-{
- _php3_date(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-
-PHP_FUNCTION(getdate)
-{
- pval *timestamp_arg;
- struct tm *ta;
- time_t timestamp;
-
- if (ARG_COUNT(ht) == 0) {
- timestamp = time(NULL);
- } else if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &timestamp_arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- } else {
- convert_to_long(timestamp_arg);
- timestamp = timestamp_arg->value.lval;
- }
-
- ta = localtime(&timestamp);
- if (!ta) {
- php_error(E_WARNING, "Cannot perform date calculation");
- return;
- }
- if (array_init(return_value) == FAILURE) {
- php_error(E_ERROR, "Unable to initialize array");
- return;
- }
- add_assoc_long(return_value, "seconds", ta->tm_sec);
- add_assoc_long(return_value, "minutes", ta->tm_min);
- add_assoc_long(return_value, "hours", ta->tm_hour);
- add_assoc_long(return_value, "mday", ta->tm_mday);
- add_assoc_long(return_value, "wday", ta->tm_wday);
- add_assoc_long(return_value, "mon", ta->tm_mon + 1);
- add_assoc_long(return_value, "year", ta->tm_year + 1900);
- add_assoc_long(return_value, "yday", ta->tm_yday);
- add_assoc_string(return_value, "weekday", day_full_names[ta->tm_wday], 1);
- add_assoc_string(return_value, "month", mon_full_names[ta->tm_mon], 1);
- add_index_long(return_value, 0, timestamp);
-}
-
-/* Return date string in standard format for http headers */
-char *php3_std_date(time_t t)
-{
- struct tm *tm1;
- char *str;
- PLS_FETCH();
-
- tm1 = gmtime(&t);
- str = emalloc(81);
- if (PG(y2k_compliance)) {
- snprintf(str, 80, "%s, %02d-%s-%04d %02d:%02d:%02d GMT",
- day_full_names[tm1->tm_wday],
- tm1->tm_mday,
- mon_short_names[tm1->tm_mon],
- tm1->tm_year+1900,
- tm1->tm_hour, tm1->tm_min, tm1->tm_sec);
- } else {
- snprintf(str, 80, "%s, %02d-%s-%02d %02d:%02d:%02d GMT",
- day_full_names[tm1->tm_wday],
- tm1->tm_mday,
- mon_short_names[tm1->tm_mon],
- ((tm1->tm_year)%100),
- tm1->tm_hour, tm1->tm_min, tm1->tm_sec);
- }
-
- str[79]=0;
- return (str);
-}
-
-/*
- * CheckDate(month, day, year);
- * returns True(1) if it is valid date
- *
- */
-#define isleap(year) (((year%4) == 0 && (year%100)!=0) || (year%400)==0)
-PHP_FUNCTION(checkdate)
-{
- pval *month, *day, *year;
- int m, d, y;
-
- if (ARG_COUNT(ht) != 3 ||
- getParameters(ht, 3, &month, &day, &year) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(day);
- convert_to_long(month);
- convert_to_long(year);
- y = year->value.lval;
- m = month->value.lval;
- d = day->value.lval;
-
- if (y < 100)
- y += 1900;
-
- if (y < 0 || y > 32767) {
- RETURN_FALSE;
- }
- if (m < 1 || m > 12) {
- RETURN_FALSE;
- }
- if (d < 1 || d > phpday_tab[isleap(y)][m - 1]) {
- RETURN_FALSE;
- }
- RETURN_TRUE; /* True : This month,day,year arguments are valid */
-}
-
-
-#if HAVE_STRFTIME
-
-PHP_FUNCTION(strftime)
-{
- pval *format_arg, *timestamp_arg;
- char *format,*buf;
- time_t timestamp;
- struct tm *ta;
- int max_reallocs = 5;
- size_t buf_len=64, real_len;
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &format_arg)==FAILURE) {
- RETURN_FALSE;
- }
- time(&timestamp);
- break;
- case 2:
- if (getParameters(ht, 2, &format_arg, &timestamp_arg)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(timestamp_arg);
- timestamp = timestamp_arg->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- convert_to_string(format_arg);
- if (format_arg->value.str.len==0) {
- RETURN_FALSE;
- }
- format = format_arg->value.str.val;
- ta = localtime(&timestamp);
-
- buf = (char *) emalloc(buf_len);
- while ((real_len=strftime(buf,buf_len,format,ta))==buf_len || real_len==0) {
- buf_len *= 2;
- buf = (char *) erealloc(buf, buf_len);
- if(!--max_reallocs) break;
- }
-
- if(real_len && real_len != buf_len) {
- buf = (char *) erealloc(buf,real_len+1);
- RETURN_STRINGL(buf, real_len, 0);
- }
- efree(buf);
- RETURN_FALSE;
-}
-#endif
-
-/* {{{ proto int strtotime(string time, int now)
- Convert string representation of date and time to a timestamp */
-PHP_FUNCTION(strtotime)
-{
- pval *timep, *nowp;
- int ac;
- struct timeval tv;
-
- ac = ARG_COUNT(ht);
-
- if (ac < 1 || ac > 2 || getParameters(ht, ac, &timep, &nowp)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(timep);
- if (ac == 2) {
- convert_to_long(nowp);
- tv.tv_sec = nowp->value.lval;
- tv.tv_usec = 0;
- RETURN_LONG(parsedate(timep->value.str.val, &tv));
- } else {
- RETURN_LONG(parsedate(timep->value.str.val, NULL));
- }
-}
-
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/datetime.h b/ext/standard/datetime.h
deleted file mode 100644
index bf518fcd7f..0000000000
--- a/ext/standard/datetime.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Andi Gutmans <andi@zend.com> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _DATETIME_H
-#define _DATETIME_H
-
-PHP_FUNCTION(time);
-PHP_FUNCTION(mktime);
-PHP_FUNCTION(gmmktime);
-PHP_FUNCTION(date);
-PHP_FUNCTION(gmdate);
-PHP_FUNCTION(getdate);
-PHP_FUNCTION(checkdate);
-#if HAVE_STRFTIME
-PHP_FUNCTION(strftime);
-#endif
-PHP_FUNCTION(strtotime);
-
-extern char *php3_std_date(time_t t);
-void _php3_mktime(INTERNAL_FUNCTION_PARAMETERS, int gm);
-
-#endif /* _DATETIME_H */
diff --git a/ext/standard/dir.c b/ext/standard/dir.c
deleted file mode 100644
index 21880d8220..0000000000
--- a/ext/standard/dir.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-#include "fopen-wrappers.h"
-
-#include "php3_dir.h"
-
-#ifdef HAVE_DIRENT_H
-# include <dirent.h>
-#endif
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#include <errno.h>
-
-#if WIN32||WINNT
-#define NEEDRDH 1
-#include "win32/readdir.h"
-#endif
-
-static int dirp_id = 0;
-static int le_dirp;
-static zend_class_entry *dir_class_entry_ptr;
-
-static zend_function_entry php_dir_functions[] = {
- PHP_FE(opendir, NULL)
- PHP_FE(closedir, NULL)
- PHP_FE(chdir, NULL)
- PHP_FE(rewinddir, NULL)
- PHP_FE(readdir, NULL)
- PHP_FALIAS(dir, getdir, NULL)
- {NULL, NULL, NULL}
-};
-
-
-static zend_function_entry php_dir_class_functions[] = {
- PHP_FALIAS(close, closedir, NULL)
- PHP_FALIAS(rewind, rewinddir, NULL)
- PHP_FALIAS(read, readdir, NULL)
- {NULL, NULL, NULL}
-};
-
-
-php3_module_entry php3_dir_module_entry = {
- "PHP_dir", php_dir_functions, PHP_MINIT(dir), NULL, NULL, NULL, NULL, STANDARD_MODULE_PROPERTIES
-};
-
-
-PHP_MINIT_FUNCTION(dir)
-{
- zend_class_entry dir_class_entry;
-
- le_dirp = register_list_destructors(closedir,NULL);
-
- INIT_CLASS_ENTRY(dir_class_entry, "Directory", php_dir_class_functions);
- dir_class_entry_ptr = register_internal_class(&dir_class_entry);
- return SUCCESS;
-}
-
-/* {{{ proto int opendir(string path)
- Open a directory and return a dir_handle */
-PHP_FUNCTION(opendir)
-{
- pval *arg;
- DIR *dirp;
- int ret;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
-
- /* Check open_basedir */
- if (_php3_check_open_basedir(arg->value.str.val)) RETURN_FALSE;
-
- dirp = opendir(arg->value.str.val);
- if (!dirp) {
- php_error(E_WARNING, "OpenDir: %s (errno %d)", strerror(errno),errno);
- RETURN_FALSE;
- }
- ret = php3_list_insert(dirp, le_dirp);
- dirp_id = ret;
- RETURN_LONG(ret);
-}
-/* }}} */
-
-/* {{{ proto void closedir([int dir_handle])
-Close directory connection identified by the dir_handle */
-PHP_FUNCTION(closedir)
-{
- pval *id, **tmp;
- int id_to_find;
- DIR *dirp;
- int dirp_type;
-
- if (ARG_COUNT(ht) == 0) {
- id = getThis();
- if (id) {
- if (zend_hash_find(id->value.obj.properties, "handle", sizeof("handle"), (void **)&tmp) == FAILURE) {
- php_error(E_WARNING, "unable to find my handle property");
- RETURN_FALSE;
- }
- id_to_find = (*tmp)->value.lval;
- } else {
- id_to_find = dirp_id;
- }
- } else if ((ARG_COUNT(ht) != 1) || getParameters(ht, 1, &id) == FAILURE) {
- WRONG_PARAM_COUNT;
- } else {
- convert_to_long(id);
- id_to_find = id->value.lval;
- }
-
- dirp = (DIR *)php3_list_find(id_to_find, &dirp_type);
- if (!dirp || dirp_type != le_dirp) {
- php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
- RETURN_FALSE;
- }
- php3_list_delete(id_to_find);
-}
-/* }}} */
-
-/* {{{ proto int chdir(string directory)
-Change the current directory */
-PHP_FUNCTION(chdir)
-{
- pval *arg;
- int ret;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
- ret = chdir(arg->value.str.val);
-
- if (ret < 0) {
- php_error(E_WARNING, "ChDir: %s (errno %d)", strerror(errno), errno);
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void rewinddir([int dir_handle])
-Rewind dir_handle back to the start */
-PHP_FUNCTION(rewinddir)
-{
- pval *id, **tmp;
- int id_to_find;
- DIR *dirp;
- int dirp_type;
-
- if (ARG_COUNT(ht) == 0) {
- id = getThis();
- if (id) {
- if (zend_hash_find(id->value.obj.properties, "handle", sizeof("handle"), (void **)&tmp) == FAILURE) {
- php_error(E_WARNING, "unable to find my handle property");
- RETURN_FALSE;
- }
- id_to_find = (*tmp)->value.lval;
- } else {
- id_to_find = dirp_id;
- }
- } else if ((ARG_COUNT(ht) != 1) || getParameters(ht, 1, &id) == FAILURE) {
- WRONG_PARAM_COUNT;
- } else {
- convert_to_long(id);
- id_to_find = id->value.lval;
- }
-
- dirp = (DIR *)php3_list_find(id_to_find, &dirp_type);
- if (!dirp || dirp_type != le_dirp) {
- php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
- RETURN_FALSE;
- }
- rewinddir(dirp);
-}
-/* }}} */
-
-/* {{{ proto string readdir([int dir_handle])
-Read directory entry from dir_handle */
-PHP_FUNCTION(readdir)
-{
- pval *id, **tmp;
- int id_to_find;
- DIR *dirp;
- int dirp_type;
- struct dirent *direntp;
-
- if (ARG_COUNT(ht) == 0) {
- id = getThis();
- if (id) {
- if (zend_hash_find(id->value.obj.properties, "handle", sizeof("handle"), (void **)&tmp) == FAILURE) {
- php_error(E_WARNING, "unable to find my handle property");
- RETURN_FALSE;
- }
- id_to_find = (*tmp)->value.lval;
- } else {
- id_to_find = dirp_id;
- }
- } else if ((ARG_COUNT(ht) != 1) || getParameters(ht, 1, &id) == FAILURE) {
- WRONG_PARAM_COUNT;
- } else {
- convert_to_long(id);
- id_to_find = id->value.lval;
- }
-
- dirp = (DIR *)php3_list_find(id_to_find, &dirp_type);
- if (!dirp || dirp_type != le_dirp) {
- php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
- RETURN_FALSE;
- }
- direntp = readdir(dirp);
- if (direntp) {
- RETURN_STRINGL(direntp->d_name, strlen(direntp->d_name), 1);
- }
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto class dir(string directory)
-Directory class with properties, handle and class and methods read, rewind and close */
-PHP_FUNCTION(getdir)
-{
- pval *arg;
- DIR *dirp;
- int ret;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
-
- /* Check open_basedir */
- if (_php3_check_open_basedir(arg->value.str.val)) RETURN_FALSE;
-
- dirp = opendir(arg->value.str.val);
- if (!dirp) {
- php_error(E_WARNING, "OpenDir: %s (errno %d)", strerror(errno), errno);
- RETURN_FALSE;
- }
- ret = php3_list_insert(dirp, le_dirp);
- dirp_id = ret;
-
- /* construct an object with some methods */
- object_init_ex(return_value, dir_class_entry_ptr);
- add_property_long(return_value, "handle", ret);
- add_property_stringl(return_value, "path", arg->value.str.val, arg->value.str.len, 1);
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/dl.c b/ext/standard/dl.c
deleted file mode 100644
index 3920cd4493..0000000000
--- a/ext/standard/dl.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Brian Schaffner <brian@tool.net> |
- | Shane Caraveo <shane@caraveo.com> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-#include "php.h"
-#include "dl.h"
-#include "php_globals.h"
-
-#if HAVE_LIBDL
-#include <stdlib.h>
-#include <stdio.h>
-#ifndef RTLD_LAZY
-# define RTLD_LAZY 1 /* Solaris 1, FreeBSD's (2.1.7.1 and older) */
-#endif
-#if HAVE_STRING_H
-#include <string.h>
-#else
-#include <strings.h>
-#endif
-#if MSVC5
-#include "win32/param.h"
-#include "win32/winutil.h"
-#else
-#include <sys/param.h>
-#endif
-
-function_entry dl_functions[] = {
- {"dl", dl, NULL},
- {NULL, NULL, NULL}
-};
-
-
-php3_module_entry dl_module_entry = {
- "PHP_DL", dl_functions, NULL, NULL, NULL, NULL, PHP_MINFO(dl), STANDARD_MODULE_PROPERTIES
-};
-
-#endif
-
-/* {{{ proto int dl(string extension_filename)
- Load a PHP extension at runtime */
-void dl(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *file;
- PLS_FETCH();
-
- /* obtain arguments */
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &file) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(file);
-
- if (!PG(enable_dl)) {
- php_error(E_ERROR, "Dynamically loaded extentions aren't enabled.");
- } else if (PG(safe_mode)) {
- php_error(E_ERROR, "Dynamically loaded extensions aren't allowed when running in SAFE MODE.");
- } else {
- php3_dl(file,MODULE_TEMPORARY,return_value);
- }
-}
-/* }}} */
-
-
-#if HAVE_LIBDL
-
-void php3_dl(pval *file,int type,pval *return_value)
-{
- void *handle;
- char libpath[MAXPATHLEN + 1];
- php3_module_entry *module_entry,*tmp;
- php3_module_entry *(*get_module)(void);
- PLS_FETCH();
-
- if (cfg_get_string("extension_dir",&PG(extension_dir))==SUCCESS
- && PG(extension_dir)
- && PG(extension_dir)[0]){
- int extension_dir_len = strlen(PG(extension_dir));
-
- if (PG(extension_dir)[extension_dir_len-1]=='/' || PG(extension_dir)[extension_dir_len-1]=='\\') {
- sprintf(libpath,"%s%s",PG(extension_dir),file->value.str.val); /* SAFE */
- } else {
- sprintf(libpath,"%s/%s",PG(extension_dir),file->value.str.val); /* SAFE */
- }
- } else {
- sprintf(libpath,"%s",file->value.str.val); /* SAFE */
- }
-
- /* load dynamic symbol */
- handle = dlopen(libpath, RTLD_LAZY);
- if (!handle) {
- int error_type;
-
- if (type==MODULE_TEMPORARY) {
- error_type = E_ERROR;
- } else {
- error_type = E_CORE_ERROR;
- }
-#if MSVC5
- php_error(error_type,"Unable to load dynamic library '%s'<br>\n%s",libpath,php3_win_err());
-#else
- php_error(error_type,"Unable to load dynamic library '%s' - %s",libpath,dlerror());
-#endif
- RETURN_FALSE;
- }
- get_module = (php3_module_entry *(*)(void)) dlsym(handle, "get_module");
-
- if (!get_module) {
- dlclose(handle);
- php_error(E_CORE_WARNING,"Invalid library (maybe not a PHP3 library) '%s' ",file->value.str.val);
- RETURN_FALSE;
- }
- module_entry = get_module();
- module_entry->type = type;
- module_entry->module_number = zend_next_free_module();
- if (module_entry->module_startup_func) {
- if (module_entry->module_startup_func(type, module_entry->module_number)==FAILURE) {
- php_error(E_CORE_WARNING,"%s: Unable to initialize module",module_entry->name);
- dlclose(handle);
- RETURN_FALSE;
- }
- }
- zend_register_module(module_entry);
-
-
- if (module_entry->request_startup_func) {
- if (module_entry->request_startup_func(type, module_entry->module_number)) {
- php_error(E_CORE_WARNING,"%s: Unable to initialize module",module_entry->name);
- dlclose(handle);
- RETURN_FALSE;
- }
- }
-
- /* update the .request_started property... */
- if (zend_hash_find(&module_registry,module_entry->name,strlen(module_entry->name)+1,(void **) &tmp)==FAILURE) {
- php_error(E_ERROR,"%s: Loaded module got lost",module_entry->name);
- RETURN_FALSE;
- }
- tmp->request_started=1;
- tmp->handle = handle;
-
- RETURN_TRUE;
-}
-
-
-PHP_MINFO_FUNCTION(dl)
-{
- PUTS("Dynamic Library support enabled.\n");
-}
-
-#else
-
-void php3_dl(pval *file,int type,pval *return_value)
-{
- php_error(E_WARNING,"Cannot dynamically load %s - dynamic modules are not supported",file->value.str.val);
- RETURN_FALSE;
-}
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/dl.h b/ext/standard/dl.h
deleted file mode 100644
index 9489723e4b..0000000000
--- a/ext/standard/dl.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Brian Schaffner <brian@tool.net> |
- | Shane Caraveo <shane@caraveo.com> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _DL_H
-#define _DL_H
-
-void php3_dl(pval *file,int type,pval *return_value);
-
-
-#if HAVE_LIBDL
-
-extern php3_module_entry dl_module_entry;
-#define dl_module_ptr &dl_module_entry
-
-/* dynamic loading functions */
-void dl(INTERNAL_FUNCTION_PARAMETERS);
-extern PHP_MINIT_FUNCTION(dl);
-extern PHP_MSHUTDOWN_FUNCTION(dl);
-extern PHP_RSHUTDOWN_FUNCTION(dl);
-PHP_MINFO_FUNCTION(dl);
-
-#else
-
-#define dl_module_ptr NULL
-
-#endif
-
-#define phpext_dl_ptr dl_module_ptr
-
-#endif /* _DL_H */
diff --git a/ext/standard/dns.c b/ext/standard/dns.c
deleted file mode 100644
index cbd30dc963..0000000000
--- a/ext/standard/dns.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-#if HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#if WIN32|WINNT
-#if HAVE_BINDLIB
-#ifndef WINNT
-#define WINNT 1
-#endif
-/* located in www.php.net/extra/bindlib.zip */
-#include "arpa/inet.h"
-#include "netdb.h"
-#include "arpa/nameser.h"
-#include "resolv.h"
-#endif
-#include <winsock.h>
-#else
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#ifdef _OSD_POSIX
-#undef STATUS
-#undef T_UNSPEC
-#endif
-#include <arpa/nameser.h>
-#include <resolv.h>
-#endif
-
-#include "dns.h"
-
-char *_php3_gethostbyaddr(char *ip);
-char *_php3_gethostbyname(char *name);
-
-/* {{{ proto string gethostbyaddr(string ip_address)
- Get the Internet host name corresponding to a given IP address */
-PHP_FUNCTION(gethostbyaddr)
-{
- pval *arg;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
-
- return_value->value.str.val = _php3_gethostbyaddr(arg->value.str.val);
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
-}
-/* }}} */
-
-
-char *_php3_gethostbyaddr(char *ip)
-{
- unsigned long addr;
- struct hostent *hp;
-
- if ((int) (addr = inet_addr(ip)) == -1) {
-#if DEBUG
- php_error(E_WARNING, "address not in a.b.c.d form");
-#endif
- return estrdup(ip);
- }
- hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET);
- if (!hp) {
-#if DEBUG
- php_error(E_WARNING, "Unable to resolve %s\n", ip);
-#endif
- return estrdup(ip);
- }
- return estrdup(hp->h_name);
-}
-
-/* {{{ proto string gethostbyname(string hostname)
- Get the IP address corresponding to a given Internet host name */
-PHP_FUNCTION(gethostbyname)
-{
- pval *arg;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
-
- return_value->value.str.val = _php3_gethostbyname(arg->value.str.val);
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
-}
-/* }}} */
-
-/* {{{ proto array gethostbynamel(string hostname)
- Return a list of IP addresses that a given hostname resolves to. */
-PHP_FUNCTION(gethostbynamel)
-{
- pval *arg;
- struct hostent *hp;
- struct in_addr in;
- int i;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
-
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
-
- hp = gethostbyname(arg->value.str.val);
- if (hp == NULL || hp->h_addr_list == NULL) {
-#if DEBUG
- php_error(E_WARNING, "Unable to resolve %s\n", arg->value.str.val);
-#endif
- return;
- }
-
- for (i = 0 ; hp->h_addr_list[i] != 0 ; i++) {
- memcpy(&in.s_addr, hp->h_addr_list[i], sizeof(in.s_addr));
- add_next_index_string(return_value, inet_ntoa(in), 1);
- }
-
- return;
-}
-/* }}} */
-
-char *_php3_gethostbyname(char *name)
-{
- struct hostent *hp;
- struct in_addr in;
-
- hp = gethostbyname(name);
- if (!hp || !hp->h_addr_list) {
-#if DEBUG
- php_error(E_WARNING, "Unable to resolve %s\n", name);
-#endif
- return estrdup(name);
- }
- memcpy(&in.s_addr, *(hp->h_addr_list), sizeof(in.s_addr));
- return estrdup(inet_ntoa(in));
-}
-
-#if !(WIN32|WINNT)||HAVE_BINDLIB
-
-/* {{{ proto int checkdnsrr(string host [, string type])
- Check DNS records corresponding to a given Internet host name or IP address */
-PHP_FUNCTION(checkdnsrr)
-{
- pval *arg1,*arg2;
- int type,i;
-#ifndef MAXPACKET
-#define MAXPACKET 8192 /* max packet size used internally by BIND */
-#endif
- u_char ans[MAXPACKET];
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- type = T_MX;
- convert_to_string(arg1);
- break;
- case 2:
- if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg1);
- convert_to_string(arg2);
- if ( !strcasecmp("A",arg2->value.str.val) ) type = T_A;
- else if ( !strcasecmp("NS",arg2->value.str.val) ) type = T_NS;
- else if ( !strcasecmp("MX",arg2->value.str.val) ) type = T_MX;
- else if ( !strcasecmp("PTR",arg2->value.str.val) ) type = T_PTR;
- else if ( !strcasecmp("ANY",arg2->value.str.val) ) type = T_ANY;
- else if ( !strcasecmp("SOA",arg2->value.str.val) ) type = T_SOA;
- else if ( !strcasecmp("CNAME",arg2->value.str.val) ) type = T_CNAME;
- else {
- php_error(E_WARNING,"Type '%s' not supported",arg2->value.str.val);
- RETURN_FALSE;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- }
- i = res_search(arg1->value.str.val,C_IN,type,ans,sizeof(ans));
- if ( i < 0 ) {
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-#ifndef HFIXEDSZ
-#define HFIXEDSZ 12 /* fixed data in header <arpa/nameser.h> */
-#endif /* HFIXEDSZ */
-
-#ifndef QFIXEDSZ
-#define QFIXEDSZ 4 /* fixed data in query <arpa/nameser.h> */
-#endif /* QFIXEDSZ */
-
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 256
-#endif /* MAXHOSTNAMELEN */
-
-/* {{{ proto int getmxrr(string hostname, array mxhosts [, array weight])
- Get MX records corresponding to a given Internet host name */
-PHP_FUNCTION(getmxrr)
-{
- pval *host, *mx_list, *weight_list;
- int need_weight = 0;
- int count,qdc;
- u_short type,weight;
- u_char ans[MAXPACKET];
- char buf[MAXHOSTNAMELEN];
- HEADER *hp;
- u_char *cp,*end;
- int i;
-
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &host, &mx_list) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- if (!ParameterPassedByReference(ht, 2)) {
- php_error(E_WARNING, "Array to be filled with values must be passed by reference.");
- RETURN_FALSE;
- }
- break;
- case 3:
- if (getParameters(ht, 3, &host, &mx_list, &weight_list) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- if (!ParameterPassedByReference(ht, 2) || !ParameterPassedByReference(ht, 3)) {
- php_error(E_WARNING, "Array to be filled with values must be passed by reference.");
- RETURN_FALSE;
- }
- need_weight = 1;
- pval_destructor(weight_list); /* start with clean array */
- if ( array_init(weight_list) == FAILURE ) {
- RETURN_FALSE;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string( host );
- pval_destructor(mx_list); /* start with clean array */
- if ( array_init(mx_list) == FAILURE ) {
- RETURN_FALSE;
- }
-
- /* Go! */
- i = res_search(host->value.str.val,C_IN,T_MX,(u_char *)&ans,sizeof(ans));
- if ( i < 0 ) {
- RETURN_FALSE;
- }
- if ( i > sizeof(ans) ) i = sizeof(ans);
- hp = (HEADER *)&ans;
- cp = (u_char *)&ans + HFIXEDSZ;
- end = (u_char *)&ans +i;
- for ( qdc = ntohs((unsigned short)hp->qdcount); qdc--; cp += i + QFIXEDSZ) {
- if ( (i = dn_skipname(cp,end)) < 0 ) {
- RETURN_FALSE;
- }
- }
- count = ntohs((unsigned short)hp->ancount);
- while ( --count >= 0 && cp < end ) {
- if ( (i = dn_skipname(cp,end)) < 0 ) {
- RETURN_FALSE;
- }
- cp += i;
- GETSHORT(type,cp);
- cp += INT16SZ + INT32SZ;
- GETSHORT(i,cp);
- if ( type != T_MX ) {
- cp += i;
- continue;
- }
- GETSHORT(weight,cp);
- if ( (i = dn_expand(ans,end,cp,buf,sizeof(buf)-1)) < 0 ) {
- RETURN_FALSE;
- }
- cp += i;
- add_next_index_string(mx_list, buf, 1);
- if ( need_weight ) {
- add_next_index_long(weight_list, weight);
- }
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-#endif
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/dns.h b/ext/standard/dns.h
deleted file mode 100644
index 9d2c6cec0b..0000000000
--- a/ext/standard/dns.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: |
- | |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _DNS_H
-#define _DNS_H
-
-PHP_FUNCTION(gethostbyaddr);
-PHP_FUNCTION(gethostbyname);
-PHP_FUNCTION(gethostbynamel);
-#if !(WIN32|WINNT)||(HAVE_BINDLIB)
-PHP_FUNCTION(checkdnsrr);
-PHP_FUNCTION(getmxrr);
-#endif
-
-#ifndef INT16SZ
-#define INT16SZ 2
-#endif
-
-#ifndef INT32SZ
-#define INT32SZ 4
-#endif
-
-#endif /* _DNS_H */
diff --git a/ext/standard/exec.c b/ext/standard/exec.c
deleted file mode 100644
index bdaa883bc9..0000000000
--- a/ext/standard/exec.c
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Rasmus Lerdorf |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include <stdio.h>
-#include "php.h"
-#include <ctype.h>
-#include "php3_string.h"
-#include "safe_mode.h"
-#include "ext/standard/head.h"
-#include "exec.h"
-#include "php_globals.h"
-#include "SAPI.h"
-
-#if HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-/*
- * If type==0, only last line of output is returned (exec)
- * If type==1, all lines will be printed and last lined returned (system)
- * If type==2, all lines will be saved to given array (exec with &$array)
- * If type==3, output will be printed binary, no lines will be saved or returned (passthru)
- *
- */
-static int _Exec(int type, char *cmd, pval *array, pval *return_value)
-{
- FILE *fp;
- char *buf, *tmp=NULL;
- int buflen = 0;
- int t, l, ret, output=1;
- int overflow_limit, lcmd, ldir;
- char *b, *c, *d=NULL;
- PLS_FETCH();
-
- buf = (char*) emalloc(EXEC_INPUT_BUF);
- if (!buf) {
- php_error(E_WARNING, "Unable to emalloc %d bytes for exec buffer", EXEC_INPUT_BUF);
- return -1;
- }
- buflen = EXEC_INPUT_BUF;
-
- if (PG(safe_mode)) {
- lcmd = strlen(cmd);
- ldir = strlen(PG(safe_mode_exec_dir));
- l = lcmd + ldir + 2;
- overflow_limit = l;
- c = strchr(cmd, ' ');
- if (c) *c = '\0';
- if (strstr(cmd, "..")) {
- php_error(E_WARNING, "No '..' components allowed in path");
- efree(buf);
- return -1;
- }
- d = emalloc(l);
- strcpy(d, PG(safe_mode_exec_dir));
- overflow_limit -= ldir;
- b = strrchr(cmd, '/');
- if (b) {
- strcat(d, b);
- overflow_limit -= strlen(b);
- } else {
- strcat(d, "/");
- strcat(d, cmd);
- overflow_limit-=(strlen(cmd)+1);
- }
- if (c) {
- *c = ' ';
- strncat(d, c, overflow_limit);
- }
- tmp = _php3_escapeshellcmd(d);
- efree(d);
- d = tmp;
-#if WIN32|WINNT
- fp = popen(d, "rb");
-#else
- fp = popen(d, "r");
-#endif
- if (!fp) {
- php_error(E_WARNING, "Unable to fork [%s]", d);
- efree(d);
- efree(buf);
- return -1;
- }
- } else { /* not safe_mode */
-#if WIN32|WINNT
- fp = popen(cmd, "rb");
-#else
- fp = popen(cmd, "r");
-#endif
- if (!fp) {
- php_error(E_WARNING, "Unable to fork [%s]", cmd);
- efree(buf);
- return -1;
- }
- }
- buf[0] = '\0';
- if (type==2) {
- if (array->type != IS_ARRAY) {
- pval_destructor(array);
- array_init(array);
- }
- }
- if (type != 3) {
- l=0;
- while ( !feof(fp) || l != 0 ) {
- l = 0;
- /* Read a line or fill the buffer, whichever comes first */
- do {
- if ( buflen <= (l+1) ) {
- buf = erealloc(buf, buflen + EXEC_INPUT_BUF);
- if ( buf == NULL ) {
- php_error(E_WARNING, "Unable to erealloc %d bytes for exec buffer",
- buflen + EXEC_INPUT_BUF);
- return -1;
- }
- buflen += EXEC_INPUT_BUF;
- }
-
- if ( fgets(&(buf[l]), buflen - l, fp) == NULL ) {
- /* eof */
- break;
- }
- l += strlen(&(buf[l]));
- } while ( (l > 0) && (buf[l-1] != '\n') );
-
- if ( feof(fp) && (l == 0) ) {
- break;
- }
-
-
- if (type == 1) {
- SLS_FETCH();
-
- if (output) PUTS(buf);
-#if APACHE
-# if MODULE_MAGIC_NUMBER > 19970110
- if (output) rflush(((request_rec *) SG(server_context)));
-# else
- if (output) bflush(((request_rec *) SG(server_context))->connection->client);
-# endif
-#endif
-#if CGI_BINARY
- fflush(stdout);
-#endif
-#if FHTTPD
- /* fhttpd doesn't flush */
-#endif
-#if USE_SAPI
- sapi_rqst->flush(sapi_rqst->scid);
-#endif
- }
- else if (type == 2) {
- /* strip trailing whitespaces */
- l = strlen(buf);
- t = l;
- while (l-- && isspace((int)buf[l]));
- if (l < t) {
- buf[l + 1] = '\0';
- }
- add_next_index_string(array, buf, 1);
- }
- }
-
- /* strip trailing spaces */
- l = strlen(buf);
- t = l;
- while (l && isspace((int)buf[--l]));
- if (l < t) buf[l + 1] = '\0';
-
- } else {
- int b, i;
-
- while ((b = fread(buf, 1, sizeof(buf), fp)) > 0) {
- for (i = 0; i < b; i++)
- if (output) (void)PUTC(buf[i]);
- }
- }
-
- /* Return last line from the shell command */
- if (PG(magic_quotes_runtime) && type!=3) {
- int len;
-
- tmp = php_addslashes(buf, 0, &len, 0);
- RETVAL_STRINGL(tmp,len,0);
- } else {
- RETVAL_STRING(buf,1);
- }
-
- ret = pclose(fp);
-#if HAVE_SYS_WAIT_H
- if (WIFEXITED(ret)) {
- ret = WEXITSTATUS(ret);
- }
-#endif
-
- if (d) efree(d);
- efree(buf);
- return ret;
-}
-
-/* {{{ proto int exec(string command [, array output [, int return_value]])
- Execute an external program */
-PHP_FUNCTION(exec)
-{
- pval *arg1, *arg2, *arg3;
- int arg_count = ARG_COUNT(ht);
- int ret;
-
- if (arg_count > 3 || getParameters(ht, arg_count, &arg1, &arg2, &arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- switch (arg_count) {
- case 1:
- ret = _Exec(0, arg1->value.str.val, NULL, return_value);
- break;
- case 2:
- if (!ParameterPassedByReference(ht,2)) {
- php_error(E_WARNING,"Array argument to exec() not passed by reference");
- }
- ret = _Exec(2, arg1->value.str.val, arg2, return_value);
- break;
- case 3:
- if (!ParameterPassedByReference(ht,2)) {
- php_error(E_WARNING,"Array argument to exec() not passed by reference");
- }
- if (!ParameterPassedByReference(ht,3)) {
- php_error(E_WARNING,"return_status argument to exec() not passed by reference");
- }
- ret = _Exec(2, arg1->value.str.val, arg2, return_value);
- arg3->type = IS_LONG;
- arg3->value.lval=ret;
- break;
- }
-}
-/* }}} */
-
-/* {{{ proto int system(string command [, int return_value])
- Execute an external program and display output */
-PHP_FUNCTION(system)
-{
- pval *arg1, *arg2;
- int arg_count = ARG_COUNT(ht);
- int ret;
-
- if (arg_count > 2 || getParameters(ht, arg_count, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- switch (arg_count) {
- case 1:
- ret = _Exec(1, arg1->value.str.val, NULL, return_value);
- break;
- case 2:
- if (!ParameterPassedByReference(ht,2)) {
- php_error(E_WARNING,"return_status argument to system() not passed by reference");
- }
- ret = _Exec(1, arg1->value.str.val, NULL, return_value);
- arg2->type = IS_LONG;
- arg2->value.lval=ret;
- break;
- }
-}
-/* }}} */
-
-/* {{{ proto int passthru(string command [, int return_value])
- Execute an external program and display raw output */
-PHP_FUNCTION(passthru)
-{
- pval *arg1, *arg2;
- int arg_count = ARG_COUNT(ht);
- int ret;
-
- if (arg_count > 2 || getParameters(ht, arg_count, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- switch (arg_count) {
- case 1:
- ret = _Exec(3, arg1->value.str.val, NULL, return_value);
- break;
- case 2:
- if (!ParameterPassedByReference(ht,2)) {
- php_error(E_WARNING,"return_status argument to system() not passed by reference");
- }
- ret = _Exec(3, arg1->value.str.val, NULL, return_value);
- arg2->type = IS_LONG;
- arg2->value.lval=ret;
- break;
- }
-}
-/* }}} */
-
-static int php3_ind(char *s, char c)
-{
- register int x;
-
- for (x = 0; s[x]; x++)
- if (s[x] == c)
- return x;
-
- return -1;
-}
-
-/* Escape all chars that could possibly be used to
- break out of a shell command
-
- This function emalloc's a string and returns the pointer.
- Remember to efree it when done with it.
-
- *NOT* safe for binary strings
-*/
-char * _php3_escapeshellcmd(char *str) {
- register int x, y, l;
- char *cmd;
-
- l = strlen(str);
- cmd = emalloc(2 * l + 1);
- strcpy(cmd, str);
- for (x = 0; cmd[x]; x++) {
- if (php3_ind("&;`'\"|*?~<>^()[]{}$\\\x0A\xFF", cmd[x]) != -1) {
- for (y = l + 1; y > x; y--)
- cmd[y] = cmd[y - 1];
- l++; /* length has been increased */
- cmd[x] = '\\';
- x++; /* skip the character */
- }
- }
- return cmd;
-}
-
-/* {{{ proto escapeshellcmd(string command)
- escape shell metacharacters */
-PHP_FUNCTION(escapeshellcmd)
-{
- pval *arg1;
- char *cmd = NULL;
-
- if (getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(arg1);
- if (arg1->value.str.len) {
- cmd = _php3_escapeshellcmd(arg1->value.str.val);
- RETVAL_STRING(cmd, 1);
- efree(cmd);
- }
-}
-/* }}} */
-
-
-PHP_FUNCTION(shell_exec)
-{
- FILE *in;
- int readbytes,total_readbytes=0,allocated_space;
- pval *cmd;
- PLS_FETCH();
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &cmd)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (PG(safe_mode)) {
- php_error(E_WARNING,"Cannot execute using backquotes in safe mode");
- RETURN_FALSE;
- }
-
- convert_to_string(cmd);
-#if WIN32|WINNT
- if ((in=popen(cmd->value.str.val,"rt"))==NULL) {
-#else
- if ((in=popen(cmd->value.str.val,"r"))==NULL) {
-#endif
- php_error(E_WARNING,"Unable to execute '%s'",cmd->value.str.val);
- }
- allocated_space = EXEC_INPUT_BUF;
- return_value->value.str.val = (char *) emalloc(allocated_space);
- while (1) {
- readbytes = fread(return_value->value.str.val+total_readbytes,1,EXEC_INPUT_BUF,in);
- if (readbytes<=0) {
- break;
- }
- total_readbytes += readbytes;
- allocated_space = total_readbytes+EXEC_INPUT_BUF;
- return_value->value.str.val = (char *) erealloc(return_value->value.str.val,allocated_space);
- }
- fclose(in);
-
- return_value->value.str.val = erealloc(return_value->value.str.val,total_readbytes+1);
- return_value->value.str.val[total_readbytes]=0;
- return_value->value.str.len = total_readbytes;
- return_value->type = IS_STRING;
-}
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/exec.h b/ext/standard/exec.h
deleted file mode 100644
index a9e6a1e32d..0000000000
--- a/ext/standard/exec.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _EXEC_H
-#define _EXEC_H
-
-PHP_FUNCTION(system);
-PHP_FUNCTION(exec);
-PHP_FUNCTION(escapeshellcmd);
-PHP_FUNCTION(passthru);
-PHP_FUNCTION(shell_exec);
-
-char *_php3_escapeshellcmd(char *);
-#endif /* _EXEC_H */
diff --git a/ext/standard/file.c b/ext/standard/file.c
deleted file mode 100644
index ecd913856d..0000000000
--- a/ext/standard/file.c
+++ /dev/null
@@ -1,1669 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/* Synced with php3 revision 1.218 1999-06-16 [ssb] */
-
-#include "php.h"
-#include "php_globals.h"
-#include "ext/standard/flock_compat.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#if MSVC5
-#include <windows.h>
-#include <winsock.h>
-#define O_RDONLY _O_RDONLY
-#include "win32/param.h"
-#include "win32/winutil.h"
-#else
-#include <sys/param.h>
-#include <sys/socket.h>
-/* #include <sys/uio.h> */
-#endif
-#include "ext/standard/head.h"
-#include "safe_mode.h"
-#include "php3_string.h"
-#include "file.h"
-#if HAVE_PWD_H
-#if MSVC5
-#include "win32/pwd.h"
-#else
-#include <pwd.h>
-#endif
-#endif
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#if WIN32|WINNT
-#include <winsock.h>
-#else
-#include <netinet/in.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-#endif
-#include "snprintf.h"
-#include "fsock.h"
-#include "fopen-wrappers.h"
-#include "php_globals.h"
-
-#ifdef HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-
-#if MISSING_FCLOSE_DECL
-extern int fclose();
-#endif
-
-#ifdef HAVE_SYS_MMAN_H
-#include <sys/mman.h>
-#endif
-
-#ifndef MAP_FAILED
-#define MAP_FAILED ((void *) -1)
-#endif
-
-static void _php3_closesocket(int *);
-
-#ifndef THREAD_SAFE
-static int fgetss_state = 0;
-int le_fp,le_pp;
-int wsa_fp; /*to handle reading and writing to windows sockets*/
-static int pclose_ret;
-extern int le_uploads;
-#endif
-
-#ifndef HAVE_TEMPNAM
-/*
- * Copyright (c) 1988, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. 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.
- */
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#ifndef MAXPATHLEN
-# ifdef PATH_MAX
-# define MAXPATHLEN PATH_MAX
-# else
-# define MAXPATHLEN 255
-# endif
-#endif
-
-
-char *tempnam(const char *dir, const char *pfx)
-{
- int save_errno;
- char *f, *name;
- static char path_tmp[] = "/tmp";
-
- if (!(name = emalloc(MAXPATHLEN))) {
- return(NULL);
- }
-
- if (!pfx) {
- pfx = "tmp.";
- }
-
- if (f = getenv("TMPDIR")) {
- (void)snprintf(name, MAXPATHLEN, "%s%s%sXXXXXX", f,
- *(f + strlen(f) - 1) == '/'? "": "/", pfx);
- if (f = mktemp(name))
- return(f);
- }
-
- if (f = (char *)dir) {
- (void)snprintf(name, MAXPATHLEN, "%s%s%sXXXXXX", f,
- *(f + strlen(f) - 1) == '/'? "": "/", pfx);
- if (f = mktemp(name))
- return(f);
- }
-
- f = P_tmpdir;
- (void)snprintf(name, MAXPATHLEN, "%s%sXXXXXX", f, pfx);
- if (f = mktemp(name))
- return(f);
-
- f = path_tmp;
- (void)snprintf(name, MAXPATHLEN, "%s%sXXXXXX", f, pfx);
- if (f = mktemp(name))
- return(f);
-
- save_errno = errno;
- efree(name);
- errno = save_errno;
- return(NULL);
-}
-#endif
-
-
-function_entry php3_file_functions[] = {
- PHP_FE(pclose, NULL)
- PHP_FE(popen, NULL)
- PHP_FE(readfile, NULL)
- PHP_FE(rewind, NULL)
- PHP_FE(rmdir, NULL)
- PHP_FE(umask, NULL)
- PHP_FE(fclose, NULL)
- PHP_FE(feof, NULL)
- PHP_FE(fgetc, NULL)
- PHP_FE(fgets, NULL)
- PHP_FE(fgetss, NULL)
- PHP_FE(fread, NULL)
- PHP_FE(fopen, NULL)
- PHP_FE(fpassthru, NULL)
- PHP_FE(fseek, NULL)
- PHP_FE(ftell, NULL)
- PHP_FE(fwrite, NULL)
- PHP_FALIAS(fputs, fwrite, NULL)
- PHP_FE(mkdir, NULL)
- PHP_FE(rename, NULL)
- PHP_FE(copy, NULL)
- PHP_FE(tempnam, NULL)
- PHP_FE(file, NULL)
- PHP_FE(fgetcsv, NULL)
- PHP_FE(flock, NULL)
- PHP_FE(get_meta_tags, NULL)
- PHP_FE(set_socket_blocking, NULL)
-#if (0 && defined(HAVE_SYS_TIME_H) && HAVE_SETSOCKOPT && defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO))
- PHP_FE(set_socket_timeout, NULL)
-#endif
- {NULL, NULL, NULL}
-};
-
-php3_module_entry php3_file_module_entry = {
- "File functions",
- php3_file_functions,
- PHP_MINIT(file),
- NULL,
- NULL,
- NULL,
- NULL,
- STANDARD_MODULE_PROPERTIES
-};
-
-
-static int flock_values[] = { LOCK_SH, LOCK_EX, LOCK_UN };
-
-/* {{{ proto bool flock(int fp, int operation)
- portable file locking */
-PHP_FUNCTION(flock)
-{
- pval *arg1, *arg2;
- FILE *fp;
- int type;
- int issock=0;
- int *sock, fd=0;
- int act = 0;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- convert_to_long(arg2);
-
- fp = php3_list_find(arg1->value.lval, &type);
- if (type == wsa_fp){
- issock = 1;
- sock = php3_list_find(arg1->value.lval, &type);
- fd = *sock;
- }
-
- if ((!fp || (type!=le_fp && type!=le_pp)) && (!fd || type!=wsa_fp)) {
- php_error(E_WARNING,"Unable to find file identifier %d",arg1->value.lval);
- RETURN_FALSE;
- }
-
- if (!issock) {
- fd = fileno(fp);
- }
-
- act = arg2->value.lval & 3;
- if(act < 1 || act > 3) {
- php_error(E_WARNING, "illegal value for second argument");
- RETURN_FALSE;
- }
- /* flock_values contains all possible actions
- if (arg2 & 4) we won't block on the lock */
- act = flock_values[act - 1] | (arg2->value.lval & 4 ? LOCK_NB : 0);
- if (flock(fd, act) == -1) {
- RETURN_FALSE;
- }
-
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/* {{{ proto array get_meta_tags(string filename [, int use_include_path])
- Extracts all meta tag content attributes from a file and returns an array */
-PHP_FUNCTION(get_meta_tags)
-{
- pval *filename, *arg2;
- FILE *fp;
- char buf[8192];
- int use_include_path = 0;
- int issock=0, socketd=0;
- int len, var_namelen;
- char var_name[50],*val=NULL,*tmp,*end,*slashed;
- PLS_FETCH();
-
- /* check args */
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht,1,&filename) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 2:
- if (getParameters(ht,2,&filename,&arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg2);
- use_include_path = arg2->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- }
- convert_to_string(filename);
-
- fp = php3_fopen_wrapper(filename->value.str.val,"r", use_include_path|ENFORCE_SAFE_MODE, &issock, &socketd);
- if (!fp && !socketd) {
- if (issock != BAD_URL) {
- php3_strip_url_passwd(filename->value.str.val);
- php_error(E_WARNING,"File(\"%s\") - %s",filename->value.str.val,strerror(errno));
- }
- RETURN_FALSE;
- }
-
- if (array_init(return_value)==FAILURE) {
- if (issock) {
- SOCK_FCLOSE(socketd);
- } else {
- fclose(fp);
- }
- RETURN_FALSE;
- }
- /* Now loop through the file and do the magic quotes thing if needed */
- memset(buf, 0, 8191);
- while((FP_FGETS(buf,8191,socketd,fp,issock) != NULL)
- && !php3i_stristr(buf,"</head>")) {
- if(php3i_stristr(buf,"<meta")) {
-
- memset(var_name,0,50);
- /* get the variable name from the name attribute of the meta tag */
- tmp=php3i_stristr(buf,"name=\"");
- if(tmp) {
- tmp+=6;
- end=strstr(tmp,"\"");
- if(end) {
- unsigned char *c;
- *end='\0';
- snprintf(var_name,50,"%s",tmp);
- *end='"';
-
- c = (unsigned char*)var_name;
- while (*c) {
- switch(*c) {
- case '.':
- case '\\':
- case '+':
- case '*':
- case '?':
- case '[':
- case '^':
- case ']':
- case '$':
- case '(':
- case ')':
- case ' ':
- *c++ ='_';
- break;
- default:
- *c++ = tolower((unsigned char)*c);
- }
- }
- var_namelen=strlen(var_name);
- }
-
- /* get the variable value from the content attribute of the meta tag */
- tmp=php3i_stristr(buf,"content=\"");
- if(tmp) {
- tmp+=9;
- end=strstr(tmp,"\"");
- if(end) {
- *end='\0';
- val=estrdup(tmp);
- *end='"';
- }
- }
- }
- if(*var_name && val) {
- if (PG(magic_quotes_runtime)) {
- slashed = php_addslashes(val,0,&len,0);
- } else {
- slashed = estrndup(val,strlen(val));
- }
- add_assoc_string(return_value, var_name, slashed, 0);
- efree(val);
- }
- }
- }
- if (issock) {
- SOCK_FCLOSE(socketd);
- } else {
- fclose(fp);
- }
-}
-/* }}} */
-
-
-/* {{{ proto array file(string filename)
-Read entire file into an array */
-PHP_FUNCTION(file)
-{
- pval *filename, *arg2;
- FILE *fp;
- char *slashed, buf[8192];
- register int i=0;
- int use_include_path = 0;
- int issock=0, socketd=0;
- PLS_FETCH();
-
- /* check args */
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht,1,&filename) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 2:
- if (getParameters(ht,2,&filename,&arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg2);
- use_include_path = arg2->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- }
- convert_to_string(filename);
-
- fp = php3_fopen_wrapper(filename->value.str.val,"r", use_include_path|ENFORCE_SAFE_MODE, &issock, &socketd);
- if (!fp && !socketd) {
- if (issock != BAD_URL) {
- php3_strip_url_passwd(filename->value.str.val);
- php_error(E_WARNING,"File(\"%s\") - %s",filename->value.str.val,strerror(errno));
- }
- RETURN_FALSE;
- }
-
- /* Initialize return array */
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
-
- /* Now loop through the file and do the magic quotes thing if needed */
- memset(buf,0,8191);
- while (FP_FGETS(buf,8191,socketd,fp,issock) != NULL) {
- if (PG(magic_quotes_runtime)) {
- int len;
-
- slashed = php_addslashes(buf,0,&len,0); /* 0 = don't free source string */
- add_index_stringl(return_value, i++, slashed, len, 0);
- } else {
- add_index_string(return_value, i++, buf, 1);
- }
- }
- if (issock) {
- SOCK_FCLOSE(socketd);
- } else {
- fclose(fp);
- }
-}
-/* }}} */
-
-
-static void __pclose(FILE *pipe)
-{
- pclose_ret = pclose(pipe);
-}
-
-
-static void _php3_closesocket(int *sock) {
- if (sock) {
- SOCK_FCLOSE(*sock);
-#if HAVE_SHUTDOWN
- shutdown(*sock, 0);
-#endif
- efree(sock);
- }
-}
-
-
-static void _php3_unlink_uploaded_file(char *file)
-{
- if(file) {
- unlink(file);
- }
-}
-
-
-static void php3i_destructor_fclose(FILE *fp) {
- (void)fclose(fp);
-}
-
-PHP_MINIT_FUNCTION(file)
-{
- le_fp = register_list_destructors(php3i_destructor_fclose, NULL);
- le_pp = register_list_destructors(__pclose, NULL);
- wsa_fp = register_list_destructors(_php3_closesocket, NULL);
- le_uploads = register_list_destructors(_php3_unlink_uploaded_file, NULL);
- return SUCCESS;
-}
-
-
-/* {{{ proto string tempnam(string dir, string prefix)
-Create a unique filename in a directory */
-PHP_FUNCTION(tempnam)
-{
- pval *arg1, *arg2;
- char *d;
- char *t;
- char p[64];
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg1);
- convert_to_string(arg2);
- d = estrndup(arg1->value.str.val,arg1->value.str.len);
- strlcpy(p,arg2->value.str.val,sizeof(p));
-
- t = tempnam(d,p);
- efree(d);
- if(!t) {
- RETURN_FALSE;
- }
- RETURN_STRING(t,1);
-}
-/* }}} */
-
-
-/* {{{ proto int fopen(string filename, string mode [, int use_include_path])
-Open a file or a URL and return a file pointer */
-PHP_FUNCTION(fopen)
-{
- pval *arg1, *arg2, *arg3;
- FILE *fp;
- char *p;
- int *sock;
- int id;
- int use_include_path = 0;
- int issock=0, socketd=0;
-
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht,2,&arg1,&arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 3:
- if (getParameters(ht,3,&arg1,&arg2,&arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg3);
- use_include_path = arg3->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg1);
- convert_to_string(arg2);
- p = estrndup(arg2->value.str.val,arg2->value.str.len);
-
- /*
- * We need a better way of returning error messages from
- * php3_fopen__wrapper().
- */
- fp = php3_fopen_wrapper(arg1->value.str.val, p, use_include_path|ENFORCE_SAFE_MODE, &issock, &socketd);
- if (!fp && !socketd) {
- if (issock != BAD_URL) {
- php3_strip_url_passwd(arg1->value.str.val);
- php_error(E_WARNING,"fopen(\"%s\",\"%s\") - %s",
- arg1->value.str.val, p, strerror(errno));
- }
- efree(p);
- RETURN_FALSE;
- }
- fgetss_state=0;
- if (issock) {
- sock=emalloc(sizeof(int));
- *sock=socketd;
- id = php3_list_insert(sock,wsa_fp);
- } else {
- id = php3_list_insert(fp,le_fp);
- }
- efree(p);
- RETURN_LONG(id);
-}
-/* }}} */
-
-
-/* {{{ proto int fclose(int fp)
-Close an open file pointer */
-PHP_FUNCTION(fclose)
-{
- pval *arg1;
- int id, type;
- FILE *fp;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- id=arg1->value.lval;
- fp = php3_list_find(id,&type);
- if (!fp || (type!=le_fp && type!=wsa_fp)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
- php3_list_delete(id);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/* {{{ proto int popen(string command, string mode)
-Execute a command and open either a read or a write pipe to it */
-PHP_FUNCTION(popen)
-{
- pval *arg1, *arg2;
- FILE *fp;
- int id;
- char *p;
- char *b, buf[1024];
- PLS_FETCH();
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg1);
- convert_to_string(arg2);
- p = estrndup(arg2->value.str.val,arg2->value.str.len);
- if (PG(safe_mode)){
- b = strchr(arg1->value.str.val,' ');
- if (!b) {
- b = strrchr(arg1->value.str.val,'/');
- } else {
- char *c;
- c = arg1->value.str.val;
- while((*b!='/')&&(b!=c)) {
- b--;
- }
- if (b==c) {
- b=NULL;
- }
- }
- if (b) {
- snprintf(buf,sizeof(buf),"%s%s",PG(safe_mode_exec_dir),b);
- } else {
- snprintf(buf,sizeof(buf),"%s/%s",PG(safe_mode_exec_dir),arg1->value.str.val);
- }
- fp = popen(buf,p);
- if (!fp) {
- php_error(E_WARNING,"popen(\"%s\",\"%s\") - %s",buf,p,strerror(errno));
- RETURN_FALSE;
- }
- } else {
- fp = popen(arg1->value.str.val,p);
- if (!fp) {
- php_error(E_WARNING,"popen(\"%s\",\"%s\") - %s",arg1->value.str.val,p,strerror(errno));
- efree(p);
- RETURN_FALSE;
- }
- }
- id = php3_list_insert(fp,le_pp);
- efree(p);
- RETURN_LONG(id);
-}
-/* }}} */
-
-
-/* {{{ proto int pclose(int fp)
-Close a file pointer opened by popen() */
-PHP_FUNCTION(pclose)
-{
- pval *arg1;
- int id,type;
- FILE *fp;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- id = arg1->value.lval;
-
- fp = php3_list_find(id,&type);
- if (!fp || type!=le_pp) {
- php_error(E_WARNING,"Unable to find pipe identifier %d",id);
- RETURN_FALSE;
- }
- php3_list_delete(id);
- RETURN_LONG(pclose_ret);
-}
-/* }}} */
-
-
-/* {{{ proto int feof(int fp)
-Test for end-of-file on a file pointer */
-PHP_FUNCTION(feof)
-{
- pval *arg1;
- FILE *fp;
- int id, type;
- int issock=0;
- int socketd=0, *sock;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- id = arg1->value.lval;
- fp = php3_list_find(id,&type);
- if (type==wsa_fp){
- issock=1;
- sock = php3_list_find(id,&type);
- socketd=*sock;
- }
- if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- /* we're at the eof if the file doesn't exist */
- RETURN_TRUE;
- }
- if (FP_FEOF(socketd, fp, issock)) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-
-PHPAPI int _php3_set_sock_blocking(int socketd, int block)
-{
- int ret = SUCCESS;
- int flags;
- int myflag = 0;
-
-#if WIN32|WINNT
- /* with ioctlsocket, a non-zero sets nonblocking, a zero sets blocking */
- flags = block;
- if (ioctlsocket(socketd,FIONBIO,&flags)==SOCKET_ERROR){
- php_error(E_WARNING,"%s",WSAGetLastError());
- ret = FALSE;
- }
-#else
- flags = fcntl(socketd, F_GETFL);
-#ifdef O_NONBLOCK
- myflag = O_NONBLOCK; /* POSIX version */
-#elif defined(O_NDELAY)
- myflag = O_NDELAY; /* old non-POSIX version */
-#endif
- if (!block) {
- flags |= myflag;
- } else {
- flags &= ~myflag;
- }
- fcntl(socketd, F_SETFL, flags);
-#endif
- return ret;
-}
-
-/* {{{ proto int set_socket_blocking(int socket descriptor, int mode)
-Set blocking/non-blocking mode on a socket */
-PHP_FUNCTION(set_socket_blocking)
-{
- pval *arg1, *arg2;
- int id, type, block;
- int socketd = 0, *sock;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- id = arg1->value.lval;
- block = arg2->value.lval;
-
- sock = php3_list_find(id,&type);
- if (type != wsa_fp) {
- php_error(E_WARNING,"%d is not a socket id",id);
- RETURN_FALSE;
- }
- socketd = *sock;
- if(_php3_set_sock_blocking(socketd, block) == FAILURE)
- RETURN_FALSE;
- _php3_sock_set_blocking(socketd, block == 0 ? 0 : 1);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-#if (0 && defined(HAVE_SYS_TIME_H) && HAVE_SETSOCKOPT && defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO))
-/* this doesn't work, as it appears those properties are read-only :( */
-PHP_FUNCTION(set_socket_timeout)
-{
- pval *socket,*timeout;
- int type, *sock;
- struct timeval t;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &socket, &timeout)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(socket);
- convert_to_long(timeout);
-
- sock = php3_list_find(socket->value.lval, &type);
- if (type!=wsa_fp) {
- php_error(E_WARNING,"%d is not a socket id",socket->value.lval);
- RETURN_FALSE;
- }
- t.tv_sec = timeout->value.lval;
- t.tv_usec = 0;
- setsockopt(*sock,SOL_SOCKET,SO_SNDTIMEO,(void *) &t,sizeof(struct timeval));
- setsockopt(*sock,SOL_SOCKET,SO_RCVTIMEO,(void *) &t,sizeof(struct timeval));
- RETURN_TRUE;
-}
-#endif
-
-
-/* {{{ proto string fgets(int fp, int length)
-Get a line from file pointer */
-PHP_FUNCTION(fgets)
-{
- pval *arg1, *arg2;
- FILE *fp;
- int id, len, type;
- char *buf;
- int issock=0;
- int *sock, socketd=0;
- PLS_FETCH();
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- id = arg1->value.lval;
- len = arg2->value.lval;
-
- fp = php3_list_find(id,&type);
- if (type==wsa_fp){
- issock=1;
- sock = php3_list_find(id,&type);
- socketd=*sock;
- }
- if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
- buf = emalloc(sizeof(char) * (len + 1));
- /* needed because recv doesnt put a null at the end*/
- memset(buf,0,len+1);
- if (FP_FGETS(buf, len, socketd, fp, issock) == NULL) {
- efree(buf);
- RETVAL_FALSE;
- } else {
- if (PG(magic_quotes_runtime)) {
- return_value->value.str.val = php_addslashes(buf,0,&return_value->value.str.len,1);
- } else {
- return_value->value.str.val = buf;
- return_value->value.str.len = strlen(return_value->value.str.val);
- }
- return_value->type = IS_STRING;
- }
- return;
-}
-/* }}} */
-
-
-/* {{{ proto string fgetc(int fp)
-Get a character from file pointer */
-PHP_FUNCTION(fgetc) {
- pval *arg1;
- FILE *fp;
- int id, type;
- char *buf;
- int issock=0;
- int *sock, socketd=0;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- id = arg1->value.lval;
-
- fp = php3_list_find(id,&type);
- if (type==wsa_fp){
- issock=1;
- sock = php3_list_find(id,&type);
- socketd = *sock;
- }
- if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
- buf = emalloc(sizeof(char) * 2);
- if (!(*buf = FP_FGETC(socketd, fp, issock))) {
- efree(buf);
- RETVAL_FALSE;
- } else {
- buf[1]='\0';
- return_value->value.str.val = buf;
- return_value->value.str.len = 1;
- return_value->type = IS_STRING;
- }
-}
-/* }}} */
-
-
-/* Strip any HTML tags while reading */
-/* {{{ proto string fgetss(int fp, int length)
-Get a line from file pointer and strip HTML tags */
-PHP_FUNCTION(fgetss)
-{
- pval *fd, *bytes;
- FILE *fp;
- int id, len, type;
- char *buf;
- int issock=0;
- int *sock,socketd=0;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &fd, &bytes) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(fd);
- convert_to_long(bytes);
-
- id = fd->value.lval;
- len = bytes->value.lval;
-
- fp = php3_list_find(id,&type);
- if (type == wsa_fp){
- issock = 1;
- sock = php3_list_find(id, &type);
- socketd=*sock;
- }
- if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
- php_error(E_WARNING, "Unable to find file identifier %d", id);
- RETURN_FALSE;
- }
-
- buf = emalloc(sizeof(char) * (len + 1));
- /*needed because recv doesnt set null char at end*/
- memset(buf, 0, len + 1);
- if (FP_FGETS(buf, len, socketd, fp, issock) == NULL) {
- efree(buf);
- RETURN_FALSE;
- }
-
- _php3_strip_tags(buf, fgetss_state);
- RETURN_STRING(buf, 0);
-}
-/* }}} */
-
-/* {{{ proto int fputs(int fp, string str [, int length])
- An alias for fwrite */
-/* }}} */
-
-/* {{{ proto int fwrite(int fp, string str [, int length])
-Binary-safe file write */
-PHP_FUNCTION(fwrite)
-{
- pval *arg1, *arg2, *arg3=NULL;
- FILE *fp;
- int ret,id,type;
- int num_bytes;
- int issock=0;
- int *sock, socketd=0;
- PLS_FETCH();
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &arg1, &arg2)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(arg2);
- num_bytes = arg2->value.str.len;
- break;
- case 3:
- if (getParameters(ht, 3, &arg1, &arg2, &arg3)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(arg2);
- convert_to_long(arg3);
- num_bytes = MIN(arg3->value.lval, arg2->value.str.len);
- break;
- default:
- WRONG_PARAM_COUNT;
- /* NOTREACHED */
- break;
- }
- convert_to_long(arg1);
- id = arg1->value.lval;
-
- fp = php3_list_find(id,&type);
- if (type==wsa_fp){
- issock=1;
- sock = php3_list_find(id,&type);
- socketd=*sock;
- }
- if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- /* strip slashes only if the length wasn't specified explicitly */
- if (!arg3 && PG(magic_quotes_runtime)) {
- php_stripslashes(arg2->value.str.val,&num_bytes);
- }
-
- if (issock){
- ret = SOCK_WRITEL(arg2->value.str.val,num_bytes,socketd);
- } else {
- ret = fwrite(arg2->value.str.val,1,num_bytes,fp);
- }
- RETURN_LONG(ret);
-}
-/* }}} */
-
-
-/* {{{ proto int set_file_buffer(int fp, int buffer)
- Set file write buffer */
-/*
- wrapper for setvbuf()
-*/
-PHP_FUNCTION(set_file_buffer)
-{
- pval *arg1, *arg2;
- FILE *fp;
- int ret,id,type,buff;
- int issock=0;
- int *sock, socketd=0;
- PLS_FETCH();
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &arg1, &arg2)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- break;
- default:
- WRONG_PARAM_COUNT;
- /* NOTREACHED */
- break;
- }
-
- id = arg1->value.lval;
- buff = arg2->value.lval;
- fp = php3_list_find(id,&type);
- if (type == wsa_fp){
- issock = 1;
- sock = php3_list_find(id,&type);
- socketd = *sock;
- }
- if ((!fp || (type != le_fp && type != le_pp)) &&
- (!socketd || type != wsa_fp)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- /* if buff is 0 then set to non-buffered */
- if (buff == 0){
- ret = setvbuf(fp, NULL, _IONBF, 0);
- } else {
- ret = setvbuf(fp, NULL, _IOFBF, buff);
- }
-
- RETURN_LONG(ret);
-}
-/* }}} */
-
-/* {{{ proto int rewind(int fp)
-Rewind the position of a file pointer */
-PHP_FUNCTION(rewind)
-{
- pval *arg1;
- int id,type;
- FILE *fp;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- id = arg1->value.lval;
- fp = php3_list_find(id,&type);
- if (!fp || (type!=le_fp && type!=le_pp)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
- rewind(fp);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/* {{{ proto int ftell(int fp)
-Get file pointer's read/write position */
-PHP_FUNCTION(ftell)
-{
- pval *arg1;
- int id, type;
- long pos;
- FILE *fp;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- id = arg1->value.lval;
- fp = php3_list_find(id,&type);
- if (!fp || (type!=le_fp && type!=le_pp)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
- pos = ftell(fp);
- RETURN_LONG(pos);
-}
-/* }}} */
-
-
-/* {{{ proto int fseek(int fp, int offset)
-Seek on a file pointer */
-PHP_FUNCTION(fseek)
-{
- pval *arg1, *arg2;
- int ret,id,type;
- long pos;
- FILE *fp;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- pos = arg2->value.lval;
- id = arg1->value.lval;
- fp = php3_list_find(id,&type);
- if (!fp || (type!=le_fp && type!=le_pp)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-/*fseek is flaky on windows, use setfilepointer, but we have to live with
- it until we use win32 api for all the file functions in 3.1 */
-#if 0
- ret = SetFilePointer (fp, pos, NULL, FILE_BEGIN);
- if (ret == 0xFFFFFFFF){
- php_error(E_WARNING,"Unable to move file postition: %s",php3_win_err());
- RETURN_FALSE;
- }
-#else
- ret = fseek(fp,pos,SEEK_SET);
-#endif
- RETURN_LONG(ret);
-}
-/* }}} */
-
-
-/* {{{ proto int mkdir(string pathname, int mode)
-Create a directory */
-PHP_FUNCTION(mkdir)
-{
- pval *arg1, *arg2;
- int ret,mode;
- PLS_FETCH();
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg1);
- convert_to_long(arg2);
- mode = arg2->value.lval;
- if (PG(safe_mode) &&(!_php3_checkuid(arg1->value.str.val,3))) {
- RETURN_FALSE;
- }
- ret = mkdir(arg1->value.str.val,mode);
- if (ret < 0) {
- php_error(E_WARNING,"MkDir failed (%s)", strerror(errno));
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/* {{{ proto int rmdir(string dirname)
-Remove a directory */
-PHP_FUNCTION(rmdir)
-{
- pval *arg1;
- int ret;
- PLS_FETCH();
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg1);
- if (PG(safe_mode) &&(!_php3_checkuid(arg1->value.str.val,1))) {
- RETURN_FALSE;
- }
- ret = rmdir(arg1->value.str.val);
- if (ret < 0) {
- php_error(E_WARNING,"RmDir failed (%s)", strerror(errno));
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-static size_t php_passthru_fd(int socketd, FILE *fp, int issock)
-{
- size_t bcount = 0;
- int ready = 0;
- char buf[8192];
-
-#ifdef HAVE_MMAP
- if(!issock) {
- int fd;
- struct stat sbuf;
- off_t off;
- void *p;
- size_t len;
-
- fd = fileno(fp);
- fstat(fd, &sbuf);
-
- if(sbuf.st_size > sizeof(buf)) {
- off = ftell(fp);
- len = sbuf.st_size - off;
- p = mmap(0, len, PROT_READ, MAP_PRIVATE, fd, off);
- if(p!=MAP_FAILED) {
- PHPWRITE(p, len);
- munmap(p, len);
- bcount += len;
- ready = 1;
- }
- }
- }
-#endif
-
- if(!ready) {
- int b;
-
- while ((b = FP_FREAD(buf, sizeof(buf), socketd, fp, issock)) > 0) {
- PHPWRITE(buf, b);
- bcount += b;
- }
- }
-
- return bcount;
-}
-
-/* {{{ proto int readfile(string filename [, int use_include_path])
-Output a file or a URL */
-PHP_FUNCTION(readfile)
-{
- pval *arg1, *arg2;
- FILE *fp;
- int size=0;
- int use_include_path=0;
- int issock=0, socketd=0;
-
- /* check args */
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht,1,&arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 2:
- if (getParameters(ht,2,&arg1,&arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg2);
- use_include_path = arg2->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg1);
-
- /*
- * We need a better way of returning error messages from
- * php3_fopen_wrapper().
- */
- fp = php3_fopen_wrapper(arg1->value.str.val,"r", use_include_path|ENFORCE_SAFE_MODE, &issock, &socketd);
- if (!fp && !socketd){
- if (issock != BAD_URL) {
- php3_strip_url_passwd(arg1->value.str.val);
- php_error(E_WARNING,"ReadFile(\"%s\") - %s",arg1->value.str.val,strerror(errno));
- }
- RETURN_FALSE;
- }
- if(php3_header()) {
- size = php_passthru_fd(socketd, fp, issock);
- }
- if (issock) {
- SOCK_FCLOSE(socketd);
- } else {
- fclose(fp);
- }
- RETURN_LONG(size);
-}
-/* }}} */
-
-
-/* {{{ proto int umask([int mask])
-Return or change the umask */
-PHP_FUNCTION(umask)
-{
- pval *arg1;
- int oldumask;
- int arg_count = ARG_COUNT(ht);
-
- oldumask = umask(077);
-
- if (arg_count == 0) {
- umask(oldumask);
- }
- else {
- if (arg_count > 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- umask(arg1->value.lval);
- }
- RETURN_LONG(oldumask);
-}
-/* }}} */
-
-
-/*
- * Read to EOF on a file descriptor and write the output to stdout.
- */
-/* {{{ proto int fpassthru(int fp)
-Output all remaining data from a file pointer */
-PHP_FUNCTION(fpassthru)
-{
- pval *arg1;
- FILE *fp;
- int id, size, type;
- int issock=0;
- int socketd=0, *sock;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- id = arg1->value.lval;
- fp = php3_list_find(id,&type);
- if (type==wsa_fp){
- issock=1;
- sock = php3_list_find(id,&type);
- socketd=*sock;
- }
- if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
- size = 0;
- if (php3_header()) { /* force headers if not already sent */
- size = php_passthru_fd(socketd, fp, issock);
- }
- php3_list_delete(id);
- RETURN_LONG(size);
-}
-/* }}} */
-
-
-/* {{{ proto int rename(string old_name, string new_name)
-Rename a file */
-PHP_FUNCTION(rename)
-{
- pval *old_arg, *new_arg;
- char *old_name, *new_name;
- int ret;
- PLS_FETCH();
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &old_arg, &new_arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(old_arg);
- convert_to_string(new_arg);
-
- old_name = old_arg->value.str.val;
- new_name = new_arg->value.str.val;
-
- if (PG(safe_mode) &&(!_php3_checkuid(old_name, 2))) {
- RETURN_FALSE;
- }
- ret = rename(old_name, new_name);
-
- if (ret == -1) {
- php_error(E_WARNING,
- "Rename failed (%s)", strerror(errno));
- RETURN_FALSE;
- }
-
- RETVAL_TRUE;
-}
-/* }}} */
-
-
-/* {{{ proto int copy(string source_file, string destination_file)
-Copy a file */
-PHP_FUNCTION(copy)
-{
- pval *source, *target;
- char buffer[8192];
- int fd_s,fd_t,read_bytes;
- PLS_FETCH();
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &source, &target) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(source);
- convert_to_string(target);
-
- if (PG(safe_mode) &&(!_php3_checkuid(source->value.str.val,2))) {
- RETURN_FALSE;
- }
-
-#if WIN32|WINNT
- if ((fd_s=open(source->value.str.val,O_RDONLY|_O_BINARY))==-1) {
-#else
- if ((fd_s=open(source->value.str.val,O_RDONLY))==-1) {
-#endif
- php_error(E_WARNING,"Unable to open '%s' for reading: %s",source->value.str.val,strerror(errno));
- RETURN_FALSE;
- }
-#if WIN32|WINNT
- if ((fd_t=open(target->value.str.val,_O_WRONLY|_O_CREAT|_O_TRUNC|_O_BINARY,_S_IREAD|_S_IWRITE))==-1){
-#else
- if ((fd_t=creat(target->value.str.val,0777))==-1) {
-#endif
- php_error(E_WARNING,"Unable to create '%s': %s", target->value.str.val,strerror(errno));
- close(fd_s);
- RETURN_FALSE;
- }
-
- while ((read_bytes=read(fd_s,buffer,8192))!=-1 && read_bytes!=0) {
- if (write(fd_t,buffer,read_bytes)==-1) {
- php_error(E_WARNING,"Unable to write to '%s': %s",target->value.str.val,strerror(errno));
- close(fd_s);
- close(fd_t);
- RETURN_FALSE;
- }
- }
-
- close(fd_s);
- close(fd_t);
-
- RETVAL_TRUE;
-}
-/* }}} */
-
-
-/* {{{ proto int fread(int fp, int length)
-Binary-safe file read */
-PHP_FUNCTION(fread)
-{
- pval *arg1, *arg2;
- FILE *fp;
- int id, len, type;
- int issock=0;
- int *sock, socketd=0;
- PLS_FETCH();
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg1);
- convert_to_long(arg2);
- id = arg1->value.lval;
- len = arg2->value.lval;
-
- fp = php3_list_find(id,&type);
- if (type==wsa_fp){
- issock=1;
- sock = php3_list_find(id,&type);
- socketd=*sock;
- }
- if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
- return_value->value.str.val = emalloc(sizeof(char) * (len + 1));
- /* needed because recv doesnt put a null at the end*/
-
- if (!issock) {
- return_value->value.str.len = fread(return_value->value.str.val, 1, len, fp);
- return_value->value.str.val[return_value->value.str.len] = 0;
- } else {
- return_value->value.str.len = SOCK_FREAD(return_value->value.str.val, len, socketd);
- }
- if (PG(magic_quotes_runtime)) {
- return_value->value.str.val = php_addslashes(return_value->value.str.val,return_value->value.str.len,&return_value->value.str.len,1);
- }
- return_value->type = IS_STRING;
-}
-/* }}} */
-
-
-/* aparently needed for pdf to be compiled as a module under windows */
-PHPAPI int php3i_get_le_fp(void)
-{
- return le_fp;
-}
-
-/* {{{ proto array fgetcsv(int fp, int length)
- get line from file pointer and parse for CSV fields */
-PHP_FUNCTION(fgetcsv) {
- char *temp, *tptr, *bptr;
- char delimiter = ','; /* allow this to be set as parameter */
-
- /* first section exactly as php3_fgetss */
-
- pval *fd, *bytes, *p_delim;
- FILE *fp;
- int id, len, type;
- char *buf;
- int issock=0;
- int *sock,socketd=0;
- PLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &fd, &bytes) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
-
- case 3:
- if (getParameters(ht, 3, &fd, &bytes, &p_delim) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(p_delim);
- /* Make sure that there is at least one character in string */
- if (p_delim->value.str.len < 1) {
- WRONG_PARAM_COUNT;
- }
- /* use first character from string */
- delimiter = p_delim->value.str.val[0];
- break;
-
- default:
- WRONG_PARAM_COUNT;
- /* NOTREACHED */
- break;
- }
-
- convert_to_long(fd);
- convert_to_long(bytes);
-
- id = fd->value.lval;
- len = bytes->value.lval;
-
- fp = php3_list_find(id, &type);
- if (type == wsa_fp){
- issock = 1;
- sock = php3_list_find(id,&type);
- socketd = *sock;
- }
- if ((!fp || (type != le_fp && type != le_pp)) &&
- (!socketd || type != wsa_fp)) {
- php_error(E_WARNING, "Unable to find file identifier %d", id);
- RETURN_FALSE;
- }
-
- buf = emalloc(sizeof(char) * (len + 1));
- /*needed because recv doesnt set null char at end*/
- memset(buf, 0, len + 1);
- if (FP_FGETS(buf, len, socketd, fp, issock) == NULL) {
- efree(buf);
- RETURN_FALSE;
- }
-
- /* Now into new section that parses buf for comma/quote delimited fields */
-
- /* Strip trailing space from buf */
-
- bptr = buf;
- tptr = buf + strlen(buf) -1;
- while ( isspace((int)*tptr) && (tptr > bptr) ) *tptr--=0;
-
- /* add single space - makes it easier to parse trailing null field */
- *++tptr = ' ';
- *++tptr = 0;
-
- /* reserve workspace for building each individual field */
-
- temp = emalloc(sizeof(char) * len); /* unlikely but possible! */
- tptr = temp;
-
- /* Initialize return array */
- if (array_init(return_value) == FAILURE) {
- efree(temp);
- efree(buf);
- RETURN_FALSE;
- }
-
- /* Main loop to read CSV fields */
- /* NB this routine will return a single null entry for a blank line */
-
- do {
- /* 1. Strip any leading space */
- while(isspace((int)*bptr)) bptr++;
- /* 2. Read field, leaving bptr pointing at start of next field */
- if (*bptr == '"') {
- /* 2A. handle quote delimited field */
- bptr++; /* move on to first character in field */
- while (*bptr) {
- if (*bptr == '"') {
- /* handle the double-quote */
- if ( *(bptr+1) == '"') {
- /* embedded double quotes */
- *tptr++ = *bptr; bptr +=2;
- } else {
- /* must be end of string - skip to start of next field or end */
- while ( (*bptr != delimiter) && *bptr ) bptr++;
- if (*bptr == delimiter) bptr++;
- *tptr=0; /* terminate temporary string */
- break; /* .. from handling this field - resumes at 3. */
- }
- } else {
- /* normal character */
- *tptr++ = *bptr++;
- }
- }
- } else {
- /* 2B. Handle non-quoted field */
- while ( (*bptr != delimiter) && *bptr ) *tptr++ = *bptr++;
- *tptr=0; /* terminate temporary string */
- if (strlen(temp)) {
- tptr--;
- while (isspace((int)*tptr)) *tptr-- = 0; /* strip any trailing spaces */
- }
- if (*bptr == delimiter) bptr++;
- }
- /* 3. Now pass our field back to php */
- add_next_index_string(return_value, temp, 1);
- tptr=temp;
- } while (*bptr);
- efree(temp);
- efree(buf);
-}
-
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * End:
- */
diff --git a/ext/standard/file.h b/ext/standard/file.h
deleted file mode 100644
index 3d2bc05289..0000000000
--- a/ext/standard/file.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/* Synced with php3 revision 1.30 1999-06-16 [ssb] */
-
-#ifndef _FILE_H
-#define _FILE_H
-
-extern php3_module_entry php3_file_module_entry;
-#define php3_file_module_ptr &php3_file_module_entry
-
-extern PHP_MINIT_FUNCTION(file);
-
-PHP_FUNCTION(tempnam);
-PHP_FUNCTION(fopen);
-PHP_FUNCTION(fclose);
-PHP_FUNCTION(popen);
-PHP_FUNCTION(pclose);
-PHP_FUNCTION(feof);
-PHP_FUNCTION(fread);
-PHP_FUNCTION(fgetc);
-PHP_FUNCTION(fgets);
-PHP_FUNCTION(fgetss);
-PHP_FUNCTION(fgetcsv);
-PHP_FUNCTION(fwrite);
-PHP_FUNCTION(rewind);
-PHP_FUNCTION(ftell);
-PHP_FUNCTION(fseek);
-PHP_FUNCTION(mkdir);
-PHP_FUNCTION(rmdir);
-PHP_FUNCTION(fpassthru);
-PHP_FUNCTION(readfile);
-PHP_FUNCTION(umask);
-PHP_FUNCTION(rename);
-PHP_FUNCTION(copy);
-PHP_FUNCTION(file);
-PHP_FUNCTION(set_socket_blocking);
-PHP_FUNCTION(set_socket_timeout);
-PHP_FUNCTION(set_file_buffer);
-PHP_FUNCTION(get_meta_tags);
-PHP_FUNCTION(flock);
-
-PHPAPI int _php3_set_sock_blocking(int socketd, int block);
-
-#define phpext_file_ptr php3_file_module_ptr
-#endif /* _FILE_H */
diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c
deleted file mode 100644
index 61685741a2..0000000000
--- a/ext/standard/filestat.c
+++ /dev/null
@@ -1,606 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Jim Winstead <jimw@php.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-#include "safe_mode.h"
-#include "fopen-wrappers.h"
-#include "php_globals.h"
-
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <errno.h>
-#include <ctype.h>
-#include <time.h>
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#ifdef OS2
-# define INCL_DOS
-# include <os2.h>
-#endif
-
-#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS)
-# include <sys/statvfs.h>
-#elif defined(HAVE_SYS_STATFS_H) && defined(HAVE_STATFS)
-# include <sys/statfs.h>
-#endif
-
-#if HAVE_PWD_H
-# if MSVC5
-# include "win32/pwd.h"
-# else
-# include <pwd.h>
-# endif
-#endif
-
-#if HAVE_GRP_H
-# if MSVC5
-# include "win32/grp.h"
-# else
-# include <grp.h>
-# endif
-#endif
-
-#if HAVE_UTIME
-# if MSVC5
-# include <sys/utime.h>
-# else
-# include <utime.h>
-# endif
-#endif
-
-#include "php3_filestat.h"
-
-#ifndef THREAD_SAFE
-static char *CurrentStatFile=NULL;
-# if MSVC5
-static unsigned int CurrentStatLength=0;
-# else
-static int CurrentStatLength=0;
-# endif
-static struct stat sb;
-#if HAVE_SYMLINK
-static struct stat lsb;
-#endif
-#endif
-
-#ifndef S_ISDIR
-#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
-#endif
-#ifndef S_ISREG
-#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
-#endif
-#ifndef S_ISLNK
-#define S_ISLNK(mode) (((mode)&S_IFMT) == S_IFLNK)
-#endif
-
-
-PHP_RINIT_FUNCTION(filestat)
-{
- CurrentStatFile=NULL;
- CurrentStatLength=0;
- return SUCCESS;
-}
-
-
-PHP_RSHUTDOWN_FUNCTION(filestat)
-{
- if (CurrentStatFile) {
- efree (CurrentStatFile);
- }
- return SUCCESS;
-}
-
-PHP_FUNCTION(diskfreespace)
-{
-#ifdef WINDOWS
- pval *path;
- double bytesfree;
-
- HINSTANCE kernel32;
- FARPROC gdfse;
- typedef BOOL (WINAPI *gdfse_func)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
- gdfse_func func;
-
- /* These are used by GetDiskFreeSpaceEx, if available. */
- ULARGE_INTEGER FreeBytesAvailableToCaller;
- ULARGE_INTEGER TotalNumberOfBytes;
- ULARGE_INTEGER TotalNumberOfFreeBytes;
-
- /* These are used by GetDiskFreeSpace otherwise. */
- DWORD SectorsPerCluster;
- DWORD BytesPerSector;
- DWORD NumberOfFreeClusters;
- DWORD TotalNumberOfClusters;
-
-#else /* not - WINDOWS */
- pval *path;
-#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS)
- struct statvfs buf;
-#elif defined(HAVE_SYS_STATFS_H) && defined(HAVE_STATFS)
- struct statfs buf;
-#endif
- double bytesfree = 0;
-#endif /* WINDOWS */
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht,1,&path)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(path);
-
- if (_php3_check_open_basedir(path->value.str.val)) RETURN_FALSE;
-
-#ifdef WINDOWS
- /* GetDiskFreeSpaceEx is only available in NT and Win95 post-OSR2,
- so we have to jump through some hoops to see if the function
- exists. */
- kernel32 = LoadLibrary("kernel32.dll");
- if (kernel32) {
- gdfse = GetProcAddress(kernel32, "GetDiskFreeSpaceExA");
- /* It's available, so we can call it. */
- if (gdfse) {
- func = (gdfse_func)gdfse;
- if (func(path->value.str.val,
- &FreeBytesAvailableToCaller,
- &TotalNumberOfBytes,
- &TotalNumberOfFreeBytes) == 0) RETURN_FALSE;
-
- /* i know - this is ugly, but i works (thies@digicol.de) */
- bytesfree = FreeBytesAvailableToCaller.HighPart *
- (double) (((unsigned long)1) << 31) * 2.0 +
- FreeBytesAvailableToCaller.LowPart;
- }
- /* If it's not available, we just use GetDiskFreeSpace */
- else {
- if (GetDiskFreeSpace(path->value.str.val,
- &SectorsPerCluster, &BytesPerSector,
- &NumberOfFreeClusters, &TotalNumberOfClusters) == 0) RETURN_FALSE;
- bytesfree = (double)NumberOfFreeClusters * (double)SectorsPerCluster * (double)BytesPerSector;
- }
- }
- else {
- php3_error(E_WARNING, "Unable to load kernel32.dll");
- RETURN_FALSE;
- }
-
-#elif defined(OS2)
- {
- FSALLOCATE fsinfo;
- char drive = path->value.str.val[0] & 95;
-
- if (DosQueryFSInfo( drive ? drive - 64 : 0, FSIL_ALLOC, &fsinfo, sizeof( fsinfo ) ) == 0)
- bytesfree = (double)fsinfo.cbSector * fsinfo.cSectorUnit * fsinfo.cUnitAvail;
- }
-#else /* WINDOWS, OS/2 */
-#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS)
- if (statvfs(path->value.str.val,&buf)) RETURN_FALSE;
- if (buf.f_frsize) {
- bytesfree = (((double)buf.f_bavail) * ((double)buf.f_frsize));
- } else {
- bytesfree = (((double)buf.f_bavail) * ((double)buf.f_bsize));
- }
-#elif defined(HAVE_SYS_STATFS_H) && defined(HAVE_STATFS)
- if (statfs(path->value.str.val,&buf)) RETURN_FALSE;
- bytesfree = (((double)buf.f_bsize) * ((double)buf.f_bavail));
-#endif
-#endif /* WINDOWS */
-
- RETURN_DOUBLE(bytesfree);
-}
-
-PHP_FUNCTION(chgrp)
-{
-#ifndef WINDOWS
- pval *filename, *group;
- gid_t gid;
- struct group *gr=NULL;
- int ret;
- PLS_FETCH();
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht,2,&filename,&group)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(filename);
- if (group->type == IS_STRING) {
- gr = getgrnam(group->value.str.val);
- if (!gr) {
- php_error(E_WARNING, "unable to find gid for %s",
- group->value.str.val);
- RETURN_FALSE;
- }
- gid = gr->gr_gid;
- } else {
- convert_to_long(group);
- gid = group->value.lval;
- }
-
- if (PG(safe_mode) &&(!_php3_checkuid(filename->value.str.val, 1))) {
- RETURN_FALSE;
- }
-
- /* Check the basedir */
- if (_php3_check_open_basedir(filename->value.str.val)) RETURN_FALSE;
-
- ret = chown(filename->value.str.val, -1, gid);
- if (ret == -1) {
- php_error(E_WARNING, "chgrp failed: %s", strerror(errno));
- RETURN_FALSE;
- }
- RETURN_TRUE;
-#else
- RETURN_FALSE;
-#endif
-}
-
-
-PHP_FUNCTION(chown)
-{
-#ifndef WINDOWS
- pval *filename, *user;
- int ret;
- uid_t uid;
- struct passwd *pw = NULL;
- PLS_FETCH();
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht,2,&filename,&user)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(filename);
- if (user->type == IS_STRING) {
- pw = getpwnam(user->value.str.val);
- if (!pw) {
- php_error(E_WARNING, "unable to find uid for %s",
- user->value.str.val);
- RETURN_FALSE;
- }
- uid = pw->pw_uid;
- } else {
- convert_to_long(user);
- uid = user->value.lval;
- }
-
- if (PG(safe_mode) &&(!_php3_checkuid(filename->value.str.val, 1))) {
- RETURN_FALSE;
- }
-
- /* Check the basedir */
- if (_php3_check_open_basedir(filename->value.str.val)) RETURN_FALSE;
-
- ret = chown(filename->value.str.val, uid, -1);
- if (ret == -1) {
- php_error(E_WARNING, "chown failed: %s", strerror(errno));
- RETURN_FALSE;
- }
-#endif
- RETURN_TRUE;
-}
-
-
-PHP_FUNCTION(chmod)
-{
- pval *filename, *mode;
- int ret;
- PLS_FETCH();
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht,2,&filename,&mode)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(filename);
- convert_to_long(mode);
-
- if (PG(safe_mode) &&(!_php3_checkuid(filename->value.str.val, 1))) {
- RETURN_FALSE;
- }
-
- /* Check the basedir */
- if (_php3_check_open_basedir(filename->value.str.val)) RETURN_FALSE;
-
- ret = chmod(filename->value.str.val, mode->value.lval);
- if (ret == -1) {
- php_error(E_WARNING, "chmod failed: %s", strerror(errno));
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-
-
-PHP_FUNCTION(touch)
-{
-#if HAVE_UTIME
- pval *filename, *filetime;
- int ret;
- struct stat sb;
- FILE *file;
- struct utimbuf *newtime = NULL;
- int ac = ARG_COUNT(ht);
- PLS_FETCH();
-
- if (ac == 1 && getParameters(ht,1,&filename) != FAILURE) {
-#ifndef HAVE_UTIME_NULL
- newtime = (struct utimbuf *)emalloc(sizeof(struct utimbuf));
- if (!newtime) {
- php_error(E_WARNING, "unable to emalloc memory for changing time");
- return;
- }
- newtime->actime = time(NULL);
- newtime->modtime = newtime->actime;
-#endif
- } else if (ac == 2 && getParameters(ht,2,&filename,&filetime) != FAILURE) {
- newtime = (struct utimbuf *)emalloc(sizeof(struct utimbuf));
- if (!newtime) {
- php_error(E_WARNING, "unable to emalloc memory for changing time");
- return;
- }
- convert_to_long(filetime);
- newtime->actime = filetime->value.lval;
- newtime->modtime = filetime->value.lval;
- } else {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(filename);
-
- if (PG(safe_mode) &&(!_php3_checkuid(filename->value.str.val, 1))) {
- if (newtime) efree(newtime);
- RETURN_FALSE;
- }
-
- /* Check the basedir */
- if (_php3_check_open_basedir(filename->value.str.val)) RETURN_FALSE;
-
- /* create the file if it doesn't exist already */
- ret = stat(filename->value.str.val, &sb);
- if (ret == -1) {
- file = fopen(filename->value.str.val, "w");
- if (file == NULL) {
- php_error(E_WARNING, "unable to create file %s because %s", filename->value.str.val, strerror(errno));
- if (newtime) efree(newtime);
- RETURN_FALSE;
- }
- fclose(file);
- }
-
- ret = utime(filename->value.str.val, newtime);
- if (newtime) efree(newtime);
- if (ret == -1) {
- php_error(E_WARNING, "utime failed: %s", strerror(errno));
- RETURN_FALSE;
- } else {
- RETURN_TRUE;
- }
-#endif
-}
-
-
-PHP_FUNCTION(clearstatcache)
-{
- if (CurrentStatFile) {
- efree(CurrentStatFile);
- CurrentStatFile = NULL;
- }
-}
-
-
-static void _php3_stat(const char *filename, int type, pval *return_value)
-{
- struct stat *stat_sb = &sb;
-
- if (!CurrentStatFile || strcmp(filename,CurrentStatFile)) {
- if (!CurrentStatFile
- || strlen(filename) > CurrentStatLength) {
- if (CurrentStatFile) efree(CurrentStatFile);
- CurrentStatLength = strlen(filename);
- CurrentStatFile = estrndup(filename,CurrentStatLength);
- } else {
- strcpy(CurrentStatFile,filename);
- }
-#if HAVE_SYMLINK
- lsb.st_mode = 0; /* mark lstat buf invalid */
-#endif
- if (stat(CurrentStatFile,&sb)==-1) {
- if (type != 15 || errno != ENOENT) { /* fileexists() test must print no error */
- php_error(E_NOTICE,"stat failed for %s (errno=%d - %s)",CurrentStatFile,errno,strerror(errno));
- }
- efree(CurrentStatFile);
- CurrentStatFile=NULL;
- RETURN_FALSE;
- }
- }
-
-#if HAVE_SYMLINK
- if (8 == type /* filetype */
- || 14 == type /* is link */
- || 16 == type) { /* lstat */
-
- /* do lstat if the buffer is empty */
-
- if (!lsb.st_mode) {
- if (lstat(CurrentStatFile,&lsb) == -1) {
- php_error(E_NOTICE,"lstat failed for %s (errno=%d - %s)",CurrentStatFile,errno,strerror(errno));
- RETURN_FALSE;
- }
- }
- }
-#endif
-
- switch(type) {
- case 0: /* fileperms */
- RETURN_LONG((long)sb.st_mode);
- case 1: /* fileinode */
- RETURN_LONG((long)sb.st_ino);
- case 2: /* filesize */
- RETURN_LONG((long)sb.st_size);
- case 3: /* fileowner */
- RETURN_LONG((long)sb.st_uid);
- case 4: /* filegroup */
- RETURN_LONG((long)sb.st_gid);
- case 5: /* fileatime */
- RETURN_LONG((long)sb.st_atime);
- case 6: /* filemtime */
- RETURN_LONG((long)sb.st_mtime);
- case 7: /* filectime */
- RETURN_LONG((long)sb.st_ctime);
- case 8: /* filetype */
-#if HAVE_SYMLINK
- if (S_ISLNK(lsb.st_mode)) {
- RETURN_STRING("link",1);
- }
-#endif
- switch(sb.st_mode&S_IFMT) {
- case S_IFIFO: RETURN_STRING("fifo",1);
- case S_IFCHR: RETURN_STRING("char",1);
- case S_IFDIR: RETURN_STRING("dir",1);
- case S_IFBLK: RETURN_STRING("block",1);
- case S_IFREG: RETURN_STRING("file",1);
- }
- php_error(E_WARNING,"Unknown file type (%d)",sb.st_mode&S_IFMT);
- RETURN_STRING("unknown",1);
- case 9: /*is writable*/
- RETURN_LONG((sb.st_mode&S_IWRITE)!=0);
- case 10: /*is readable*/
- RETURN_LONG((sb.st_mode&S_IREAD)!=0);
- case 11: /*is executable*/
- RETURN_LONG((sb.st_mode&S_IEXEC)!=0 && !S_ISDIR(sb.st_mode));
- case 12: /*is file*/
- RETURN_LONG(S_ISREG(sb.st_mode));
- case 13: /*is dir*/
- RETURN_LONG(S_ISDIR(sb.st_mode));
- case 14: /*is link*/
-#if HAVE_SYMLINK
- RETURN_LONG(S_ISLNK(lsb.st_mode));
-#else
- RETURN_FALSE;
-#endif
- case 15: /*file exists*/
- RETURN_TRUE; /* the false case was done earlier */
- case 16: /* lstat */
-#if HAVE_SYMLINK
- stat_sb = &lsb;
-#endif
- /* FALLTHROUGH */
- case 17: /* stat */
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
- add_next_index_long(return_value, stat_sb->st_dev);
- add_next_index_long(return_value, stat_sb->st_ino);
- add_next_index_long(return_value, stat_sb->st_mode);
- add_next_index_long(return_value, stat_sb->st_nlink);
- add_next_index_long(return_value, stat_sb->st_uid);
- add_next_index_long(return_value, stat_sb->st_gid);
-#ifdef HAVE_ST_BLKSIZE
- add_next_index_long(return_value, stat_sb->st_rdev);
-#else
- add_next_index_long(return_value, -1);
-#endif
- add_next_index_long(return_value, stat_sb->st_size);
- add_next_index_long(return_value, stat_sb->st_atime);
- add_next_index_long(return_value, stat_sb->st_mtime);
- add_next_index_long(return_value, stat_sb->st_ctime);
-#ifdef HAVE_ST_BLKSIZE
- add_next_index_long(return_value, stat_sb->st_blksize);
-#else
- add_next_index_long(return_value, -1);
-#endif
-#ifdef HAVE_ST_BLOCKS
- add_next_index_long(return_value, stat_sb->st_blocks);
-#else
- add_next_index_long(return_value, -1);
-#endif
- return;
- }
- php_error(E_WARNING, "didn't understand stat call");
- RETURN_FALSE;
-}
-
-/* another quickie macro to make defining similar functions easier */
-#define FileFunction(name, funcnum) \
-void name(INTERNAL_FUNCTION_PARAMETERS) { \
- pval *filename; \
- if (ARG_COUNT(ht)!=1 || getParameters(ht,1,&filename) == FAILURE) { \
- WRONG_PARAM_COUNT; \
- } \
- convert_to_string(filename); \
- _php3_stat(filename->value.str.val, funcnum, return_value); \
-}
-
-FileFunction(PHP_FN(fileperms),0)
-FileFunction(PHP_FN(fileinode),1)
-FileFunction(PHP_FN(filesize), 2)
-FileFunction(PHP_FN(fileowner),3)
-FileFunction(PHP_FN(filegroup),4)
-FileFunction(PHP_FN(fileatime),5)
-FileFunction(PHP_FN(filemtime),6)
-FileFunction(PHP_FN(filectime),7)
-FileFunction(PHP_FN(filetype), 8)
-FileFunction(PHP_FN(is_writable), 9)
-FileFunction(PHP_FN(is_readable),10)
-FileFunction(PHP_FN(is_executable),11)
-FileFunction(PHP_FN(is_file),12)
-FileFunction(PHP_FN(is_dir),13)
-FileFunction(PHP_FN(is_link),14)
-FileFunction(PHP_FN(file_exists),15)
-FileFunction(PHP_FN(lstat),16)
-FileFunction(PHP_FN(stat),17)
-
-function_entry php3_filestat_functions[] = {
- PHP_FE(fileatime, NULL)
- PHP_FE(filectime, NULL)
- PHP_FE(filegroup, NULL)
- PHP_FE(fileinode, NULL)
- PHP_FE(filemtime, NULL)
- PHP_FE(fileowner, NULL)
- PHP_FE(fileperms, NULL)
- PHP_FE(filesize, NULL)
- PHP_FE(filetype, NULL)
- PHP_FE(file_exists, NULL)
- PHP_FE(is_writable, NULL)
- PHP_FALIAS(is_writeable, is_writable, NULL)
- PHP_FE(is_readable, NULL)
- PHP_FE(is_executable, NULL)
- PHP_FE(is_file, NULL)
- PHP_FE(is_dir, NULL)
- PHP_FE(is_link, NULL)
- PHP_FE(stat, NULL)
- PHP_FE(lstat, NULL)
- PHP_FE(chown, NULL)
- PHP_FE(chgrp, NULL)
- PHP_FE(chmod, NULL)
- PHP_FE(touch, NULL)
- PHP_FE(clearstatcache, NULL)
- PHP_FE(diskfreespace, NULL)
- {NULL, NULL, NULL}
-};
-
-
-php3_module_entry php3_filestat_module_entry = {
- "PHP_filestat", php3_filestat_functions, NULL, NULL, PHP_RINIT(filestat),
- PHP_RSHUTDOWN(filestat), NULL, STANDARD_MODULE_PROPERTIES
-};
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/flock_compat.c b/ext/standard/flock_compat.c
deleted file mode 100644
index de6571cd48..0000000000
--- a/ext/standard/flock_compat.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <sas@schell.de> |
- +----------------------------------------------------------------------+
-
- $Id$
- */
-
-
-#include <php.h>
-#include <errno.h>
-#include "ext/standard/flock_compat.h"
-
-#if HAVE_STRUCT_FLOCK
-#include <unistd.h>
-#include <fcntl.h>
-#endif
-
-#if WIN32|WINNT
-#include <windows.h>
-#include <io.h>
-#endif
-
-#ifndef HAVE_FLOCK
-int flock(int fd, int operation)
-#if HAVE_STRUCT_FLOCK
-{
- struct flock flck;
- int ret;
-
- flck.l_start = flck.l_len = 0;
- flck.l_whence = SEEK_SET;
-
- if (operation & LOCK_SH)
- flck.l_type = F_RDLCK;
- else if (operation & LOCK_EX)
- flck.l_type = F_WRLCK;
- else if (operation & LOCK_UN)
- flck.l_type = F_UNLCK;
- else {
- errno = EINVAL;
- return -1;
- }
-
- ret = fcntl(fd, operation & LOCK_NB ? F_SETLK : F_SETLKW, &flck);
-
- if (operation & LOCK_NB && ret == -1 &&
- (errno == EACCES || errno == EAGAIN))
- errno = EWOULDBLOCK;
-
- if (ret != -1) ret = 0;
-
- return ret;
-}
-#elif WIN32|WINNT
-/*
- * Program: Unix compatibility routines
- *
- * Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
- *
- * Date: 14 September 1996
- * Last Edited: 14 August 1997
- *
- * Copyright 1997 by the University of Washington
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appears in all copies and that both the
- * above copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the University of Washington not be
- * used in advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission. This software is made available
- * "as is", and
- * THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
- * WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION ALL IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND IN
- * NO EVENT SHALL THE UNIVERSITY OF WASHINGTON BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT
- * (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-/* DEDICATION
-
- * This file is dedicated to my dog, Unix, also known as Yun-chan and
- * Unix J. Terwilliker Jehosophat Aloysius Monstrosity Animal Beast. Unix
- * passed away at the age of 11 1/2 on September 14, 1996, 12:18 PM PDT, after
- * a two-month bout with cirrhosis of the liver.
- *
- * He was a dear friend, and I miss him terribly.
- *
- * Lift a leg, Yunie. Luv ya forever!!!!
- */
-{
- HANDLE hdl = (HANDLE) _get_osfhandle(fd);
- DWORD low = 1, high = 0;
- OVERLAPPED offset =
- {0, 0, 0, 0, NULL};
- if (hdl < 0)
- return -1; /* error in file descriptor */
- /* bug for bug compatible with Unix */
- UnlockFileEx(hdl, 0, low, high, &offset);
- switch (operation & ~LOCK_NB) { /* translate to LockFileEx() op */
- case LOCK_EX: /* exclusive */
- if (LockFileEx(hdl, LOCKFILE_EXCLUSIVE_LOCK +
- ((operation & LOCK_NB) ? LOCKFILE_FAIL_IMMEDIATELY : 0),
- 0, low, high, &offset))
- return 0;
- break;
- case LOCK_SH: /* shared */
- if (LockFileEx(hdl, ((operation & LOCK_NB) ? LOCKFILE_FAIL_IMMEDIATELY : 0),
- 0, low, high, &offset))
- return 0;
- break;
- case LOCK_UN: /* unlock */
- return 0; /* always succeeds */
- default: /* default */
- break;
- }
- /* Under Win32 MT library, errno is not a variable but a function call,
- * which cannot be assigned to.
- */
-#if !(WIN32|WINNT)
- errno = EINVAL; /* bad call */
-#endif
- return -1;
-}
-#else
-#warning no proper flock support for your site
-{
- errno = 0;
- return 0;
-}
-#endif
-#endif /* !defined(HAVE_FLOCK) */
-
-#if !(HAVE_INET_ATON)
-
-/*
- * Check whether "cp" is a valid ascii representation
- * of an Internet address and convert to a binary address.
- * Returns 1 if the address is valid, 0 if not.
- * This replaces inet_addr, the return value from which
- * cannot distinguish between failure and a local broadcast address.
- */
-
-int inet_aton(const char *cp, struct in_addr *ap)
-{
- int dots = 0;
- register unsigned long acc = 0, addr = 0;
-
- do {
- register char cc = *cp;
-
- switch (cc) {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- acc = acc * 10 + (cc - '0');
- break;
-
- case '.':
- if (++dots > 3) {
- return 0;
- }
- /* Fall through */
-
- case '\0':
- if (acc > 255) {
- return 0;
- }
- addr = addr << 8 | acc;
- acc = 0;
- break;
-
- default:
- return 0;
- }
- } while (*cp++) ;
-
- /* Normalize the address */
- if (dots < 3) {
- addr <<= 8 * (3 - dots) ;
- }
-
- /* Store it if requested */
- if (ap) {
- ap->s_addr = htonl(addr);
- }
-
- return 1;
-}
-
-#endif /* !HAVE_INET_ATON */
diff --git a/ext/standard/flock_compat.h b/ext/standard/flock_compat.h
deleted file mode 100644
index 59c8e3bea4..0000000000
--- a/ext/standard/flock_compat.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef _FLOCK_COMPAT_H
-#define _FLOCK_COMPAT_H
-
-#ifndef HAVE_FLOCK
-# define LOCK_SH 1
-# define LOCK_EX 2
-# define LOCK_NB 4
-# define LOCK_UN 8
-int flock(int fd, int operation);
-#endif
-
-#if WIN32|WINNT
-# define fsync _commit
-# define ftruncate chsize
-#endif /* WIN32|WINNT */
-
-#if !HAVE_INET_ATON
-#if HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#if HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-
-extern int inet_aton(const char *, struct in_addr *);
-#endif
-
-#endif /* _FLOCK_COMPAT_H */
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c
deleted file mode 100644
index 1d6f223da4..0000000000
--- a/ext/standard/formatted_print.c
+++ /dev/null
@@ -1,589 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Stig Sæther Bakken <ssb@guardian.no> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include <math.h> /* modf() */
-#include "php.h"
-#include "ext/standard/head.h"
-#include "php3_string.h"
-#include "zend_execute.h"
-#include <stdio.h>
-
-#define ALIGN_LEFT 0
-#define ALIGN_RIGHT 1
-#define ADJ_WIDTH 1
-#define ADJ_PRECISION 2
-#define NUM_BUF_SIZE 500
-#define NDIG 80
-#define FLOAT_DIGITS 6
-#define FLOAT_PRECISION 6
-#define MAX_FLOAT_DIGITS 38
-#define MAX_FLOAT_PRECISION 40
-
-#if 0
-/* trick to control varargs functions through cpp */
-# define PRINTF_DEBUG(arg) php_printf arg
-#else
-# define PRINTF_DEBUG(arg)
-#endif
-
-static char hexchars[] = "0123456789abcdef";
-static char HEXCHARS[] = "0123456789ABCDEF";
-
-
-/*
- * cvt.c - IEEE floating point formatting routines for FreeBSD
- * from GNU libc-4.6.27
- */
-
-/*
- * _php3_cvt converts to decimal
- * the number of digits is specified by ndigit
- * decpt is set to the position of the decimal point
- * sign is set to 0 for positive, 1 for negative
- */
-static char *
-_php3_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag)
-{
- register int r2;
- double fi, fj;
- register char *p, *p1;
- /*THREADX*/
-#ifndef THREAD_SAFE
- static char cvt_buf[NDIG];
-#endif
-
- if (ndigits >= NDIG - 1)
- ndigits = NDIG - 2;
- r2 = 0;
- *sign = 0;
- p = &cvt_buf[0];
- if (arg < 0) {
- *sign = 1;
- arg = -arg;
- }
- arg = modf(arg, &fi);
- p1 = &cvt_buf[NDIG];
- /*
- * Do integer part
- */
- if (fi != 0) {
- p1 = &cvt_buf[NDIG];
- while (fi != 0) {
- fj = modf(fi / 10, &fi);
- *--p1 = (int) ((fj + .03) * 10) + '0';
- r2++;
- }
- while (p1 < &cvt_buf[NDIG])
- *p++ = *p1++;
- } else if (arg > 0) {
- while ((fj = arg * 10) < 1) {
- arg = fj;
- r2--;
- }
- }
- p1 = &cvt_buf[ndigits];
- if (eflag == 0)
- p1 += r2;
- *decpt = r2;
- if (p1 < &cvt_buf[0]) {
- cvt_buf[0] = '\0';
- return (cvt_buf);
- }
- while (p <= p1 && p < &cvt_buf[NDIG]) {
- arg *= 10;
- arg = modf(arg, &fj);
- *p++ = (int) fj + '0';
- }
- if (p1 >= &cvt_buf[NDIG]) {
- cvt_buf[NDIG - 1] = '\0';
- return (cvt_buf);
- }
- p = p1;
- *p1 += 5;
- while (*p1 > '9') {
- *p1 = '0';
- if (p1 > cvt_buf)
- ++ * --p1;
- else {
- *p1 = '1';
- (*decpt)++;
- if (eflag == 0) {
- if (p > cvt_buf)
- *p = '0';
- p++;
- }
- }
- }
- *p = '\0';
- return (cvt_buf);
-}
-
-
-inline static void
-php_sprintf_appendchar(char **buffer, int *pos, int *size, char add)
-{
- if ((*pos + 1) >= *size) {
- *size <<= 1;
- PRINTF_DEBUG(("%s: ereallocing buffer to %d bytes\n", get_active_function_name(), *size));
- *buffer = erealloc(*buffer, *size);
- }
- PRINTF_DEBUG(("sprintf: appending '%c', pos=\n", add, *pos));
- (*buffer)[(*pos)++] = add;
-}
-
-
-inline static void
-php_sprintf_appendstring(char **buffer, int *pos, int *size, char *add,
- int min_width, int max_width, char padding,
- int alignment, int len, int sign)
-{
- register int npad = min_width - MIN(len,(max_width?max_width:len));
-
- if (npad<0) {
- npad=0;
- }
-
- PRINTF_DEBUG(("sprintf: appendstring(%x, %d, %d, \"%s\", %d, '%c', %d)\n",
- *buffer, *pos, *size, add, min_width, padding, alignment));
- if (max_width == 0) {
- max_width = MAX(min_width,len);
- }
- if ((*pos + max_width) >= *size) {
- while ((*pos + max_width) >= *size) {
- *size <<= 1;
- }
- PRINTF_DEBUG(("sprintf ereallocing buffer to %d bytes\n", *size));
- *buffer = erealloc(*buffer, *size);
- }
- if (alignment == ALIGN_RIGHT) {
- if (sign && padding=='0') { (*buffer)[(*pos)++] = '-'; add++; }
- while (npad-- > 0) {
- (*buffer)[(*pos)++] = padding;
- }
- }
- PRINTF_DEBUG(("sprintf: appending \"%s\"\n", add));
- strncpy(&(*buffer)[*pos], add, max_width);
- *pos += MIN(max_width,len);
- if (alignment == ALIGN_LEFT) {
- while (npad--) {
- (*buffer)[(*pos)++] = padding;
- }
- }
-}
-
-
-inline static void
-php_sprintf_appendint(char **buffer, int *pos, int *size, int number,
- int width, char padding, int alignment)
-{
- char numbuf[NUM_BUF_SIZE];
- register unsigned int magn, nmagn, i = NUM_BUF_SIZE - 1, neg = 0;
-
- PRINTF_DEBUG(("sprintf: appendint(%x, %x, %x, %d, %d, '%c', %d)\n",
- *buffer, pos, size, number, width, padding, alignment));
- if (number < 0) {
- neg = 1;
- magn = ((unsigned int) -(number + 1)) + 1;
- } else {
- magn = (unsigned int) number;
- }
-
- /* Can't right-pad 0's on integers */
- if(alignment==0 && padding=='0') padding=' ';
-
- numbuf[i] = '\0';
-
- do {
- nmagn = magn / 10;
-
- numbuf[--i] = (magn - (nmagn * 10)) + '0';
- magn = nmagn;
- }
- while (magn > 0 && i > 0);
- if (neg) {
- numbuf[--i] = '-';
- }
- PRINTF_DEBUG(("sprintf: appending %d as \"%s\", i=%d\n",
- number, &numbuf[i], i));
- php_sprintf_appendstring(buffer, pos, size, &numbuf[i], width, 0,
- padding, alignment, (NUM_BUF_SIZE - 1) - i, neg);
-}
-
-
-inline static void
-php_sprintf_appenddouble(char **buffer, int *pos,
- int *size, double number,
- int width, char padding,
- int alignment, int precision,
- int adjust, char fmt)
-{
- char numbuf[NUM_BUF_SIZE];
- char *cvt;
- register int i = 0, j = 0;
- int sign, decpt;
-
- PRINTF_DEBUG(("sprintf: appenddouble(%x, %x, %x, %f, %d, '%c', %d, %c)\n",
- *buffer, pos, size, number, width, padding, alignment, fmt));
- if ((adjust & ADJ_PRECISION) == 0) {
- precision = FLOAT_PRECISION;
- } else if (precision > MAX_FLOAT_PRECISION) {
- precision = MAX_FLOAT_PRECISION;
- }
- cvt = _php3_cvt(number, precision, &decpt, &sign, (fmt == 'e'));
-
- if (sign) {
- numbuf[i++] = '-';
- }
-
- if (fmt == 'f') {
- if (decpt <= 0) {
- numbuf[i++] = '0';
- if (precision > 0) {
- int k = precision;
- numbuf[i++] = '.';
- while ((decpt++ < 0) && k--) {
- numbuf[i++] = '0';
- }
- }
- } else {
- while (decpt-- > 0)
- numbuf[i++] = cvt[j++];
- if (precision > 0)
- numbuf[i++] = '.';
- }
- } else {
- numbuf[i++] = cvt[j++];
- if (precision > 0)
- numbuf[i++] = '.';
- }
-
- while (cvt[j]) {
- numbuf[i++] = cvt[j++];
- }
-
- numbuf[i] = '\0';
-
- if (precision > 0) {
- width += (precision + 1);
- }
- php_sprintf_appendstring(buffer, pos, size, numbuf, width, 0, padding,
- alignment, i, sign);
-}
-
-
-inline static void
-php_sprintf_append2n(char **buffer, int *pos, int *size, int number,
- int width, char padding, int alignment, int n,
- char *chartable)
-{
- char numbuf[NUM_BUF_SIZE];
- register unsigned int num, i = NUM_BUF_SIZE - 1, neg = 0;
- register int andbits = (1 << n) - 1;
-
- PRINTF_DEBUG(("sprintf: append2n(%x, %x, %x, %d, %d, '%c', %d, %d, %x)\n",
- *buffer, pos, size, number, width, padding, alignment, n,
- chartable));
- PRINTF_DEBUG(("sprintf: append2n 2^%d andbits=%x\n", n, andbits));
-
- if (number < 0) {
- neg = 1;
- num = ((unsigned int) -(number + 1)) + 1;
- } else {
- num = (unsigned int) number;
- }
-
- numbuf[i] = '\0';
-
- do {
- numbuf[--i] = chartable[(num & andbits)];
- num >>= n;
- }
- while (num > 0);
-
- if (neg) {
- numbuf[--i] = '-';
- }
- php_sprintf_appendstring(buffer, pos, size, &numbuf[i], width, 0,
- padding, alignment, (NUM_BUF_SIZE - 1) - i, neg);
-}
-
-
-inline static int
-php_sprintf_getnumber(char *buffer, int *pos)
-{
- char *endptr;
- register int num = strtol(&buffer[*pos], &endptr, 10);
- register int i = 0;
-
- if (endptr != NULL) {
- i = (endptr - &buffer[*pos]);
- }
- PRINTF_DEBUG(("sprintf_getnumber: number was %d bytes long\n", i));
- *pos += i;
- return num;
-}
-
-
-/*
- * New sprintf implementation for PHP.
- *
- * Modifiers:
- *
- * " " pad integers with spaces
- * "-" left adjusted field
- * n field size
- * "."n precision (floats only)
- *
- * Type specifiers:
- *
- * "%" literal "%", modifiers are ignored.
- * "b" integer argument is printed as binary
- * "c" integer argument is printed as a single character
- * "d" argument is an integer
- * "f" the argument is a float
- * "o" integer argument is printed as octal
- * "s" argument is a string
- * "x" integer argument is printed as lowercase hexadecimal
- * "X" integer argument is printed as uppercase hexadecimal
- *
- */
-static char *
-php3_formatted_print(int ht, int *len)
-{
- pval **args;
- int argc, size = 240, inpos = 0, outpos = 0;
- int alignment, width, precision, currarg, adjusting;
- char *format, *result, padding;
-
- argc = ARG_COUNT(ht);
-
- if (argc < 1) {
- WRONG_PARAM_COUNT_WITH_RETVAL(NULL);
- }
- args = emalloc(argc * sizeof(pval *));
-
- if (getParametersArray(ht, argc, args) == FAILURE) {
- efree(args);
- WRONG_PARAM_COUNT_WITH_RETVAL(NULL);
- }
- convert_to_string(args[0]);
- format = args[0]->value.str.val;
- result = emalloc(size);
-
- currarg = 1;
-
- while (format[inpos]) {
- PRINTF_DEBUG(("sprintf: format[%d]='%c'\n", inpos, format[inpos]));
- PRINTF_DEBUG(("sprintf: outpos=%d\n", outpos));
- if (format[inpos] != '%') {
- php_sprintf_appendchar(&result, &outpos, &size, format[inpos++]);
- } else if (format[inpos + 1] == '%') {
- php_sprintf_appendchar(&result, &outpos, &size, '%');
- inpos += 2;
- } else {
- if (currarg >= argc && format[inpos + 1] != '%') {
- efree(result);
- efree(args);
- php_error(E_WARNING, "%s(): too few arguments",get_active_function_name());
- return NULL;
- }
- /* starting a new format specifier, reset variables */
- alignment = ALIGN_RIGHT;
- adjusting = 0;
- padding = ' ';
- inpos++; /* skip the '%' */
-
- PRINTF_DEBUG(("sprintf: first looking at '%c', inpos=%d\n",
- format[inpos], inpos));
- if (isascii((int)format[inpos]) && !isalpha((int)format[inpos])) {
- /* first look for modifiers */
- PRINTF_DEBUG(("sprintf: looking for modifiers\n"
- "sprintf: now looking at '%c', inpos=%d\n",
- format[inpos], inpos));
- for (;; inpos++) {
- if (format[inpos] == ' ' || format[inpos] == '0') {
- padding = format[inpos];
- } else if (format[inpos] == '-') {
- alignment = ALIGN_LEFT;
- /* space padding, the default */
- } else if (format[inpos] == '\'') {
- padding = format[++inpos];
- } else {
- PRINTF_DEBUG(("sprintf: end of modifiers\n"));
- break;
- }
- }
- PRINTF_DEBUG(("sprintf: padding='%c'\n", padding));
- PRINTF_DEBUG(("sprintf: alignment=%s\n",
- (alignment == ALIGN_LEFT) ? "left" : "right"));
-
-
- /* after modifiers comes width */
- if (isdigit((int)format[inpos])) {
- PRINTF_DEBUG(("sprintf: getting width\n"));
- width = php_sprintf_getnumber(format, &inpos);
- adjusting |= ADJ_WIDTH;
- } else {
- width = 0;
- }
- PRINTF_DEBUG(("sprintf: width=%d\n", width));
-
- /* after width comes precision */
- if (format[inpos] == '.') {
- inpos++;
- PRINTF_DEBUG(("sprintf: getting precision\n"));
- if (isdigit((int)format[inpos])) {
- precision = php_sprintf_getnumber(format, &inpos);
- adjusting |= ADJ_PRECISION;
- } else {
- precision = 0;
- }
- } else {
- precision = 0;
- }
- PRINTF_DEBUG(("sprintf: precision=%d\n", precision));
- } else {
- width = precision = 0;
- }
-
- if (format[inpos] == 'l') {
- inpos++;
- }
- PRINTF_DEBUG(("sprintf: format character='%c'\n", format[inpos]));
- /* now we expect to find a type specifier */
- switch (format[inpos]) {
- case 's':
- convert_to_string(args[currarg]);
- php_sprintf_appendstring(&result, &outpos, &size,
- args[currarg]->value.str.val,
- width, precision, padding,
- alignment,
- args[currarg]->value.str.len,0);
- break;
-
- case 'd':
- convert_to_long(args[currarg]);
- php_sprintf_appendint(&result, &outpos, &size,
- args[currarg]->value.lval,
- width, padding, alignment);
- break;
-
- case 'e':
- case 'f':
- /* XXX not done */
- convert_to_double(args[currarg]);
- php_sprintf_appenddouble(&result, &outpos, &size,
- args[currarg]->value.dval,
- width, padding, alignment,
- precision, adjusting,
- format[inpos]);
- break;
-
- case 'c':
- convert_to_long(args[currarg]);
- php_sprintf_appendchar(&result, &outpos, &size,
- (char) args[currarg]->value.lval);
- break;
-
- case 'o':
- convert_to_long(args[currarg]);
- php_sprintf_append2n(&result, &outpos, &size,
- args[currarg]->value.lval,
- width, padding, alignment, 3,
- hexchars);
- break;
-
- case 'x':
- convert_to_long(args[currarg]);
- php_sprintf_append2n(&result, &outpos, &size,
- args[currarg]->value.lval,
- width, padding, alignment, 4,
- hexchars);
- break;
-
- case 'X':
- convert_to_long(args[currarg]);
- php_sprintf_append2n(&result, &outpos, &size,
- args[currarg]->value.lval,
- width, padding, alignment, 4,
- HEXCHARS);
- break;
-
- case 'b':
- convert_to_long(args[currarg]);
- php_sprintf_append2n(&result, &outpos, &size,
- args[currarg]->value.lval,
- width, padding, alignment, 1,
- hexchars);
- break;
-
- case '%':
- php_sprintf_appendchar(&result, &outpos, &size, '%');
-
- break;
- default:
- break;
- }
- currarg++;
- inpos++;
- }
- }
-
- efree(args);
-
- /* possibly, we have to make sure we have room for the terminating null? */
- result[outpos]=0;
- *len = outpos;
- return result;
-}
-
-
-PHP_FUNCTION(user_sprintf)
-{
- char *result;
- int len;
-
- if ((result=php3_formatted_print(ht,&len))==NULL) {
- RETURN_FALSE;
- }
- RETVAL_STRINGL(result,len,1);
- efree(result);
-}
-
-
-PHP_FUNCTION(user_printf)
-{
- char *result;
- int len;
-
- if ((result=php3_formatted_print(ht,&len))==NULL) {
- RETURN_FALSE;
- }
- PHPWRITE(result,len);
- efree(result);
-}
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/fsock.c b/ext/standard/fsock.c
deleted file mode 100644
index dd353a3ce2..0000000000
--- a/ext/standard/fsock.c
+++ /dev/null
@@ -1,749 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Paul Panotzki - Bunyip Information Systems |
- | Jim Winstead (jimw@php.net) |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-/* Synced with php3 revision 1.121 1999-06-18 [ssb] */
-/* Synced with php3 revision 1.133 1999-07-21 [sas] */
-
-#include "php.h"
-#include "php_globals.h"
-#include <stdlib.h>
-#include <stddef.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-
-#include <sys/types.h>
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef WIN32
-#include <winsock.h>
-#else
-#include <netinet/in.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-#endif
-#ifdef WIN32
-#undef AF_UNIX
-#endif
-#if defined(AF_UNIX)
-#include <sys/un.h>
-#endif
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-
-#include <string.h>
-#include <errno.h>
-
-#include "base64.h"
-#include "file.h"
-#include "post.h"
-#include "url.h"
-#include "fsock.h"
-
-#ifndef ZTS
-extern int le_fp;
-#endif
-
-#define FREE_SOCK if(socketd >= 0) close(socketd); efree(sock); if (key) efree(key)
-
-#define SEARCHCR() \
- p = memchr(READPTR(sock), '\n', MIN(TOREAD(sock), maxlen));
-
-#if WIN32|WINNT
-#define EWOULDBLOCK WSAEWOULDBLOCK
-#else
-#include "build-defs.h"
-#endif
-
-static unsigned char third_and_fourth_args_force_ref[] = { 4, BYREF_NONE, BYREF_NONE, BYREF_FORCE, BYREF_FORCE };
-
-function_entry fsock_functions[] = {
- PHP_FE(fsockopen, third_and_fourth_args_force_ref)
- PHP_FE(pfsockopen, third_and_fourth_args_force_ref)
- {NULL, NULL, NULL}
-};
-
-struct php3i_sockbuf {
- int socket;
- unsigned char *readbuf;
- size_t readbuflen;
- size_t readpos;
- size_t writepos;
- struct php3i_sockbuf *next;
- struct php3i_sockbuf *prev;
- char eof;
- char persistent;
- char is_blocked;
- size_t chunk_size;
-};
-
-static struct php3i_sockbuf *phpsockbuf;
-
-typedef struct php3i_sockbuf php3i_sockbuf;
-
-php3_module_entry fsock_module_entry = {
- "Socket functions",
- fsock_functions,
- PHP_MINIT(fsock),
- PHP_MSHUTDOWN(fsock),
- NULL,
- PHP_RSHUTDOWN(fsock),
- NULL,
- STANDARD_MODULE_PROPERTIES
-};
-
-
-/* {{{ lookup_hostname */
-
-/*
- * Converts a host name to an IP address.
- */
-int lookup_hostname(const char *addr, struct in_addr *in)
-{
- struct hostent *host_info;
-
- if (!inet_aton(addr, in)) {
- /* XXX NOT THREAD SAFE */
- host_info = gethostbyname(addr);
- if (host_info == 0) {
- /* Error: unknown host */
- return -1;
- }
- *in = *((struct in_addr *) host_info->h_addr);
- }
- return 0;
-}
-/* }}} */
-/* {{{ _php3_is_persistent_sock */
-
-int _php3_is_persistent_sock(int sock)
-{
- char *key;
- PLS_FETCH();
-
- if (zend_hash_find(&PG(ht_fsock_socks), (char *) &sock, sizeof(sock),
- (void **) &key) == SUCCESS) {
- return 1;
- }
- return 0;
-}
-/* }}} */
-/* {{{ connect_nonb */
-PHPAPI int connect_nonb(int sockfd,
- struct sockaddr *addr,
- int addrlen,
- struct timeval *timeout)
-{
-/* probably won't work on Win32, someone else might try it (read: fix it ;) */
-#if !defined(WIN32) && (defined(O_NONBLOCK) || defined(O_NDELAY))
-
-#ifndef O_NONBLOCK
-#define O_NONBLOCK O_NDELAY
-#endif
-
- int flags;
- int n;
- int error = 0;
- int len;
- int ret = 0;
- fd_set rset;
- fd_set wset;
-
- flags = fcntl(sockfd, F_GETFL, 0);
- fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
-
- if ((n = connect(sockfd, addr, addrlen)) < 0) {
- if (errno != EINPROGRESS) {
- return -1;
- }
- }
-
- if (n == 0) {
- goto ok;
- }
-
- FD_ZERO(&rset);
- FD_SET(sockfd, &rset);
-
- wset = rset;
-
- if ((n = select(sockfd + 1, &rset, &wset, NULL, timeout)) == 0) {
- error = ETIMEDOUT;
- }
-
- if(FD_ISSET(sockfd, &rset) || FD_ISSET(sockfd, &wset)) {
- len = sizeof(error);
- /*
- BSD-derived systems set errno correctly
- Solaris returns -1 from getsockopt in case of error
- */
- if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
- ret = -1;
- }
- } else {
- /* whoops: sockfd has disappeared */
- ret = -1;
- }
-
- ok:
- fcntl(sockfd, F_SETFL, flags);
-
- if(error) {
- errno = error;
- ret = -1;
- }
- return ret;
-#else /* !defined(WIN32) && ... */
- return connect(sockfd, addr, addrlen);
-#endif
-}
-/* }}} */
-/* {{{ _php3_fsockopen() */
-
-/*
- This function takes an optional third argument which should be
- passed by reference. The error code from the connect call is written
- to this variable.
-*/
-static void _php3_fsockopen(INTERNAL_FUNCTION_PARAMETERS, int persistent) {
- pval *args[5];
- int *sock=emalloc(sizeof(int));
- int *sockp;
- int id, arg_count=ARG_COUNT(ht);
- int socketd = -1;
- struct timeval timeout = { 60, 0 };
- unsigned short portno;
- unsigned long conv;
- char *key = NULL;
- PLS_FETCH();
-
- if (arg_count > 5 || arg_count < 2 || getParametersArray(ht,arg_count,args)==FAILURE) {
- FREE_SOCK;
- WRONG_PARAM_COUNT;
- }
- switch(arg_count) {
- case 5:
- convert_to_double(args[4]);
- conv = (unsigned long) (args[4]->value.dval * 1000000.0);
- timeout.tv_sec = conv / 1000000;
- timeout.tv_usec = conv % 1000000;
- /* fall-through */
- case 4:
- if(!ParameterPassedByReference(ht,4)) {
- php_error(E_WARNING,"error string argument to fsockopen not passed by reference");
- }
- pval_copy_constructor(args[3]);
- args[3]->value.str.val = empty_string;
- args[3]->value.str.len = 0;
- args[3]->type = IS_STRING;
- /* fall-through */
- case 3:
- if(!ParameterPassedByReference(ht,3)) {
- php_error(E_WARNING,"error argument to fsockopen not passed by reference");
- }
- args[2]->type = IS_LONG;
- args[2]->value.lval = 0;
- break;
- }
- convert_to_string(args[0]);
- convert_to_long(args[1]);
- portno = (unsigned short) args[1]->value.lval;
-
- key = emalloc(args[0]->value.str.len + 10);
- sprintf(key, "%s:%d", args[0]->value.str.val, portno);
-
- if (persistent && zend_hash_find(&PG(ht_fsock_keys), key, strlen(key) + 1,
- (void *) &sockp) == SUCCESS) {
- FREE_SOCK;
- *sock = *sockp;
- RETURN_LONG(php3_list_insert(sock, wsa_fp));
- }
-
- if (portno) {
- struct sockaddr_in server;
-
- memset(&server, 0, sizeof(server));
- socketd = socket(AF_INET, SOCK_STREAM, 0);
- if (socketd == SOCK_ERR) {
- FREE_SOCK;
- RETURN_FALSE;
- }
-
- server.sin_family = AF_INET;
-
- if (lookup_hostname(args[0]->value.str.val, &server.sin_addr)) {
- FREE_SOCK;
- RETURN_FALSE;
- }
-
- server.sin_port = htons(portno);
-
- if (connect_nonb(socketd, (struct sockaddr *)&server, sizeof(server), &timeout) == SOCK_CONN_ERR) {
- FREE_SOCK;
- if(arg_count>2) args[2]->value.lval = errno;
- if(arg_count>3) {
- args[3]->value.str.val = estrdup(strerror(errno));
- args[3]->value.str.len = strlen(args[3]->value.str.val);
- }
- RETURN_FALSE;
- }
-#if defined(AF_UNIX)
- } else {
- /* Unix domain socket. s->strval is socket name. */
- struct sockaddr_un unix_addr;
- socketd = socket(AF_UNIX,SOCK_STREAM,0);
- if (socketd == SOCK_ERR) {
- FREE_SOCK;
- RETURN_FALSE;
- }
-
- memset(&unix_addr,(char)0,sizeof(unix_addr));
- unix_addr.sun_family = AF_UNIX;
- strcpy(unix_addr.sun_path, args[0]->value.str.val);
-
- if (connect_nonb(socketd, (struct sockaddr *) &unix_addr, sizeof(unix_addr), &timeout) == SOCK_CONN_ERR) {
- FREE_SOCK;
- if(arg_count>2) args[2]->value.lval = errno;
- if(arg_count>3) {
- args[3]->value.str.val = estrdup(strerror(errno));
- args[3]->value.str.len = strlen(args[3]->value.str.val);
- }
- RETURN_FALSE;
- }
-#endif /* AF_UNIX */
- }
-
-#if 0
- if ((fp = fdopen (socketd, "r+")) == NULL){
- RETURN_LONG(-6); /* FIXME */
- }
-
-#ifdef HAVE_SETVBUF
- if ((setvbuf(fp, NULL, _IONBF, 0)) != 0){
- RETURN_LONG(-7); /* FIXME */
- }
-#endif
-#endif
-
- *sock=socketd;
- if (persistent) {
- zend_hash_update(&PG(ht_fsock_keys), key, strlen(key) + 1,
- sock, sizeof(*sock), NULL);
- zend_hash_update(&PG(ht_fsock_socks), (char *) sock, sizeof(*sock),
- key, strlen(key) + 1, NULL);
- }
- if(key) efree(key);
- id = php3_list_insert(sock,wsa_fp);
- RETURN_LONG(id);
-}
-/* }}} */
-
-/* {{{ proto int fsockopen(string hostname, int port [, int errno [, string errstr [, double timeout]]])
- Open Internet or Unix domain socket connection */
-PHP_FUNCTION(fsockopen)
-{
- _php3_fsockopen(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-/* {{{ proto int pfsockopen(string hostname, int port [, int errno [, string errstr [, double timeout]]])
- Open persistent Internet or Unix domain socket connection */
-PHP_FUNCTION(pfsockopen)
-{
- _php3_fsockopen(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-#define CHUNK_SIZE 8192
-#define SOCK_DESTROY(sock) \
- if(sock->readbuf) pefree(sock->readbuf, sock->persistent); \
- if(sock->prev) sock->prev->next = sock->next; \
- if(sock->next) sock->next->prev = sock->prev; \
- if(sock == phpsockbuf) \
- phpsockbuf = sock->next; \
- pefree(sock, sock->persistent)
-
-static size_t def_chunk_size = CHUNK_SIZE;
-
-static void php_cleanup_sockbuf(int persistent)
-{
- php3i_sockbuf *now, *next;
-
- for(now = phpsockbuf; now; now = next) {
- next = now->next;
- if(now->persistent == persistent) {
- SOCK_DESTROY(now);
- }
- }
-}
-
-#define TOREAD(sock) ((sock)->writepos - (sock)->readpos)
-#define READPTR(sock) ((sock)->readbuf + (sock)->readpos)
-#define WRITEPTR(sock) ((sock)->readbuf + (sock)->writepos)
-#define SOCK_FIND(sock,socket) \
- php3i_sockbuf *sock; \
- sock = _php3_sock_find(socket); \
- if(!sock) sock = _php3_sock_create(socket)
-
-static php3i_sockbuf *_php3_sock_find(int socket)
-{
- php3i_sockbuf *buf = NULL, *tmp;
-
- for(tmp = phpsockbuf; tmp; tmp = tmp->next)
- if(tmp->socket == socket) {
- buf = tmp;
- break;
- }
-
- return buf;
-}
-
-static php3i_sockbuf *_php3_sock_create(int socket)
-{
- php3i_sockbuf *sock;
- int persistent = _php3_is_persistent_sock(socket);
-
- sock = pecalloc(sizeof(*sock), 1, persistent);
- sock->socket = socket;
- if((sock->next = phpsockbuf))
- phpsockbuf->prev = sock;
- sock->persistent = persistent;
- sock->is_blocked = 1;
- sock->chunk_size = def_chunk_size;
- phpsockbuf = sock;
-
- return sock;
-}
-
-size_t _php3_sock_set_def_chunk_size(size_t size)
-{
- size_t old;
-
- old = def_chunk_size;
-
- if(size <= CHUNK_SIZE || size > 0)
- def_chunk_size = size;
-
- return old;
-}
-
-int _php3_sock_destroy(int socket)
-{
- int ret = 0;
- php3i_sockbuf *sock;
-
- sock = _php3_sock_find(socket);
- if(sock) {
- ret = 1;
- SOCK_DESTROY(sock);
- }
-
- return ret;
-}
-
-#if !defined(WIN32) && !defined(WINNT)
-#undef closesocket
-#define closesocket close
-#endif
-
-#ifndef HAVE_SHUTDOWN
-#undef shutdown
-#define shutdown
-#endif
-
-#define SOCK_CLOSE(s) shutdown(s, 0); closesocket(s)
-
-int _php3_sock_close(int socket)
-{
- int ret = 0;
- php3i_sockbuf *sock;
-
- sock = _php3_sock_find(socket);
- if(sock) {
- if(!sock->persistent) {
- SOCK_CLOSE(sock->socket);
- SOCK_DESTROY(sock);
- }
- } else {
- SOCK_CLOSE(socket);
- }
-
- return ret;
-}
-
-#define MAX_CHUNKS_PER_READ 10
-
-static void _php3_sock_wait_for_data(php3i_sockbuf *sock)
-{
- fd_set fdr, tfdr;
-
- FD_ZERO(&fdr);
- FD_SET(sock->socket, &fdr);
-
- while(1) {
- tfdr = fdr;
- if(select(sock->socket + 1, &tfdr, NULL, NULL, NULL) == 1)
- break;
- }
-}
-
-static size_t _php3_sock_read_internal(php3i_sockbuf *sock)
-{
- char buf[CHUNK_SIZE];
- int nr_bytes;
- size_t nr_read = 0;
-
- /* For blocking sockets, we wait until there is some
- data to read (real data or EOF)
-
- Otherwise, recv() may time out and return 0 and
- therefore sock->eof would be set errornously.
- */
-
-
- if(sock->is_blocked) {
- _php3_sock_wait_for_data(sock);
- }
-
- /* read at a maximum sock->chunk_size */
- nr_bytes = recv(sock->socket, buf, sock->chunk_size, 0);
- if(nr_bytes > 0) {
- if(sock->writepos + nr_bytes > sock->readbuflen) {
- sock->readbuflen += sock->chunk_size;
- sock->readbuf = perealloc(sock->readbuf, sock->readbuflen,
- sock->persistent);
- }
- memcpy(WRITEPTR(sock), buf, nr_bytes);
- sock->writepos += nr_bytes;
- nr_read = nr_bytes;
- } else if(nr_bytes == 0 || (nr_bytes < 0 && errno != EWOULDBLOCK)) {
- sock->eof = 1;
- }
-
- return nr_read;
-}
-
-static void _php3_sock_read_total(php3i_sockbuf *sock, size_t maxread)
-{
- while(!sock->eof && TOREAD(sock) < maxread) {
- _php3_sock_read_internal(sock);
- }
-}
-
-static size_t _php3_sock_read(php3i_sockbuf *sock)
-{
- size_t nr_bytes;
- size_t nr_read = 0;
- int i;
-
- for(i = 0; !sock->eof && i < MAX_CHUNKS_PER_READ; i++) {
- nr_bytes = _php3_sock_read_internal(sock);
- if(nr_bytes == 0) break;
- nr_read += nr_bytes;
- }
-
- return nr_read;
-}
-
-int _php3_sock_set_blocking(int socket, int mode)
-{
- int old;
- SOCK_FIND(sock, socket);
-
- old = sock->is_blocked;
-
- sock->is_blocked = mode;
-
- return old;
-}
-
-#define SOCK_FIND_AND_READ_MAX(max) \
- SOCK_FIND(sock, socket); \
- if(sock->is_blocked) _php3_sock_read_total(sock, max); else _php3_sock_read(sock)
-
-/* {{{ _php3_sock_fgets() */
-/*
- * FIXME: fgets depends on '\n' as line delimiter
- */
-char *_php3_sock_fgets(char *buf, size_t maxlen, int socket)
-{
- char *p = NULL;
- char *ret = NULL;
- size_t amount = 0;
- SOCK_FIND(sock, socket);
-
- if (maxlen==0) {
- buf[0] = 0;
- return buf;
- }
-
- SEARCHCR();
-
- if(!p) {
- if(sock->is_blocked) {
- while(!p && !sock->eof && TOREAD(sock) < maxlen) {
- _php3_sock_read_internal(sock);
- SEARCHCR();
- }
- } else {
- _php3_sock_read(sock);
- SEARCHCR();
- }
- }
-
-
- if(p) {
- amount = (ptrdiff_t) p - (ptrdiff_t) READPTR(sock) + 1;
- } else {
- amount = TOREAD(sock);
- }
-
- amount = MIN(amount, maxlen);
-
- if(amount > 0) {
- memcpy(buf, READPTR(sock), amount);
- sock->readpos += amount;
- }
- buf[amount] = '\0';
-
- /* signal error only, if we don't return data from this call and
- if there is no data to read and if the eof flag is set */
- if(amount || TOREAD(sock) || !sock->eof)
- ret = buf;
-
- return ret;
-}
-
-/* }}} */
-
-/*
- * FIXME: fgetc returns EOF, if no data is available on a nonblocking socket.
- * I don't have any documentation on the semantics of fgetc in this case.
- *
- * ss@2ns.de 19990528
- */
-
-int _php3_sock_fgetc(int socket)
-{
- int ret = EOF;
- SOCK_FIND_AND_READ_MAX(1);
-
- if(TOREAD(sock) > 0) {
- ret = *READPTR(sock);
- sock->readpos++;
- }
-
- return ret;
-}
-
-int _php3_sock_feof(int socket)
-{
- int ret = 0;
- SOCK_FIND(sock, socket);
-
- if(!sock->is_blocked)
- _php3_sock_read(sock);
-
- if(!TOREAD(sock) && sock->eof)
- ret = 1;
-
- return ret;
-}
-
-/* {{{ _php3_sock_fread() */
-
-size_t _php3_sock_fread(char *ptr, size_t size, int socket)
-{
- size_t ret = 0;
- SOCK_FIND_AND_READ_MAX(size);
-
- if(size < 0)
- return ret;
-
- ret = MIN(TOREAD(sock), size);
- if(ret) {
- memcpy(ptr, READPTR(sock), ret);
- sock->readpos += ret;
- }
-
- return ret;
-}
-
-/* }}} */
-/* {{{ module start/shutdown functions */
-
- /* {{{ php_msock_destroy */
-int php_msock_destroy(int *data)
-{
- close(*data);
- return 1;
-}
-/* }}} */
- /* {{{ php3_minit_fsock */
-
-PHP_MINIT_FUNCTION(fsock)
-{
-#ifndef ZTS
- zend_hash_init(&PG(ht_fsock_keys), 0, NULL, NULL, 1);
- zend_hash_init(&PG(ht_fsock_socks), 0, NULL, (int (*)(void *))php_msock_destroy, 1);
-#endif
- return SUCCESS;
-}
-/* }}} */
- /* {{{ php3_mshutdown_fsock */
-
-PHP_MSHUTDOWN_FUNCTION(fsock)
-{
-#ifndef ZTS
- zend_hash_destroy(&PG(ht_fsock_socks));
- zend_hash_destroy(&PG(ht_fsock_keys));
-#endif
- php_cleanup_sockbuf(1);
- return SUCCESS;
-}
-/* }}} */
- /* {{{ php3_rshutdown_fsock() */
-
-PHP_RSHUTDOWN_FUNCTION(fsock)
-{
- php_cleanup_sockbuf(0);
- return SUCCESS;
-}
-
-/* }}} */
-
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/fsock.h b/ext/standard/fsock.h
deleted file mode 100644
index aaa8be6a21..0000000000
--- a/ext/standard/fsock.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Paul Panotzki - Bunyip Information Systems |
- | Jim Winstead (jimw@php.net) |
- +----------------------------------------------------------------------+
-*/
-/* $Id$ */
-
-/* Synced with php3 revision 1.24 1999-06-18 [ssb] */
-
-#ifndef _FSOCK_H
-#define _FSOCK_H
-
-#if WIN32|WINNT
-# ifndef WINNT
-# define WINNT 1
-# endif
-# undef FD_SETSIZE
-# include "arpa/inet.h"
-#endif
-
-#ifdef HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-
-extern php3_module_entry fsock_module_entry;
-#define phpext_fsock_ptr &fsock_module_entry
-
-PHP_FUNCTION(fsockopen);
-PHP_FUNCTION(pfsockopen);
-int lookup_hostname(const char *addr, struct in_addr *in);
-char *_php3_sock_fgets(char *buf, size_t maxlen, int socket);
-size_t _php3_sock_fread(char *buf, size_t maxlen, int socket);
-int _php3_sock_feof(int socket);
-int _php3_sock_fgetc(int socket);
-int _php3_is_persistent_sock(int);
-int _php3_sock_set_blocking(int socket, int mode);
-int _php3_sock_destroy(int socket);
-int _php3_sock_close(int socket);
-size_t _php3_sock_set_def_chunk_size(size_t size);
-int php_msock_destroy(int *data);
-
-PHPAPI int connect_nonb(int sockfd, struct sockaddr *addr, int addrlen, struct timeval *timeout);
-
-PHP_MINIT_FUNCTION(fsock);
-PHP_MSHUTDOWN_FUNCTION(fsock);
-PHP_RSHUTDOWN_FUNCTION(fsock);
-
-#endif /* _FSOCK_H */
diff --git a/ext/standard/global.h b/ext/standard/global.h
deleted file mode 100644
index 3b52173897..0000000000
--- a/ext/standard/global.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-/* GLOBAL.H - RSAREF types and constants
- */
-
-/* PROTOTYPES should be set to one if and only if the compiler supports
- function argument prototyping.
- The following makes PROTOTYPES default to 0 if it has not already
- been defined with C compiler flags.
- */
-#ifndef PROTOTYPES
-#define PROTOTYPES 1 /* php3 has prototypes everywhere */
-#endif
-
-/* _POINTER defines a generic pointer type */
-typedef unsigned char *_POINTER;
-
-/* UINT2 defines a two byte word */
-typedef unsigned short int UINT2;
-
-/* UINT4 defines a four byte word */
-#if SIZEOF_INT == 4
-typedef unsigned int UINT4;
-#elif SIZEOF_LONG == 4
-typedef unsigned long UINT4;
-#endif
-
-/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
- If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
- returns an empty list.
- */
-#if PROTOTYPES
-#define PROTO_LIST(list) list
-#else
-#define PROTO_LIST(list) ()
-#endif
diff --git a/ext/standard/head.c b/ext/standard/head.c
deleted file mode 100644
index 4e18f36392..0000000000
--- a/ext/standard/head.c
+++ /dev/null
@@ -1,585 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include <stdio.h>
-#include "php.h"
-#include "ext/standard/php3_standard.h"
-#include "SAPI.h"
-#include "main.h"
-#include "head.h"
-#include "post.h"
-#include "SAPI.h"
-#ifdef TM_IN_SYS_TIME
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-
-#include "php_globals.h"
-#include "safe_mode.h"
-
-
-/* need to figure out some nice way to get rid of these */
-#ifndef THREAD_SAFE
-static int php3_HeaderPrinted = 0;
-static int php3_PrintHeader = 1;
-static CookieList *top = NULL;
-static char *cont_type = NULL;
-static int header_called = 0;
-#endif
-
-void php3_PushCookieList(char *, char *, time_t, char *, char *, int);
-CookieList *php3_PopCookieList(void);
-
-PHP_RINIT_FUNCTION(head)
-{
- php3_HeaderPrinted = 0;
- if (header_called == 0)
- php3_PrintHeader = 1;
- top = NULL;
- cont_type = NULL;
-
- return SUCCESS;
-}
-
-
-#if 0
-/* Adds header information */
-void php4i_add_header_information(char *header_information, uint header_length)
-{
- char *r;
-#if APACHE
- char *rr = NULL;
- char *temp = NULL;
- long myuid = 0L;
- char temp2[32];
- request_rec *req;
- SLS_FETCH();
-
- req = ((request_rec *) SG(server_context));
-#endif
-
- if (php3_HeaderPrinted == 1) {
-#if DEBUG
- php_error(E_WARNING, "Cannot add more header information - the header was already sent "
- "(header information may be added only before any output is generated from the script - "
- "check for text or whitespace outside PHP tags, or calls to functions that output text)");
-#endif
- return; /* too late, already sent */
- }
-#if APACHE
- /*
- * Not entirely sure this is the right way to support the header
- * command in the Apache module. Comments?
- */
- r = strchr(header_information, ':');
- if (r) {
- *r = '\0';
- if (!strcasecmp(header_information, "Content-type")) {
- if (*(r + 1) == ' ')
- req->content_type = pstrdup(req->pool,r + 2);
- else
- req->content_type = pstrdup(req->pool,r + 1);
- cont_type = (char *) req->content_type;
- } else {
- if (*(r + 1) == ' ') {
- rr = r + 2;
- } else {
- rr = r + 1;
- }
- if (PG(safe_mode) && (!strcasecmp(header_information, "WWW-authenticate"))) {
- myuid = _php3_getuid();
- sprintf(temp2, "realm=\"%ld ", myuid); /* SAFE */
- temp = _php3_regreplace("realm=\"", temp2, rr, 1, 0);
- if (!strcmp(temp, rr)) {
- sprintf(temp2, "realm=%ld", myuid); /* SAFE */
- temp = _php3_regreplace("realm=", temp2, rr, 1, 0);
- if (!strcmp(temp, rr)) {
- sprintf(temp2, " realm=%ld", myuid); /* SAFE */
- temp = _php3_regreplace("$", temp2, rr, 0, 0);
- }
- }
- table_set(req->headers_out, header_information, temp);
- } else
- table_set(req->headers_out, header_information, rr);
- }
- if (!strcasecmp(header_information, "location")) {
- req->status = REDIRECT;
- }
- *r = ':';
- php3_HeaderPrinted = 2;
- }
- if (!strncasecmp(header_information, "http/", 5)) {
- if (strlen(header_information) > 9) {
- req->status = atoi(&((header_information)[9]));
- }
- /* Use a pstrdup here to get the memory straight from Apache's per-request pool to
- * avoid having our own memory manager complain about this memory not being freed
- * because it really shouldn't be freed until the end of the request and it isn't
- * easy for us to figure out when we allocated it vs. when something else might have.
- */
- req->status_line = pstrdup(req->pool,&((header_information)[9]));
- }
-#else
- r = strchr(header_information, ':');
- if (r) {
- *r = '\0';
- if (!strcasecmp(header_information, "Content-type")) {
- if (cont_type) efree(cont_type);
- cont_type = estrdup(r + 1);
-#if 0 /*WIN32|WINNT / *M$ does us again*/
- if (!strcmp(cont_type," text/html")){
- *r=':';
- PUTS_H(header_information);
- PUTS_H("\015\012");
- }
-#endif
- } else {
- *r = ':';
-#if USE_SAPI
- {
- char *tempstr=emalloc(strlen(header_information)+2);
-
- sprintf(tempstr,"%s\015\012",tempstr);
- sapi_rqst->header(sapi_rqst->scid,tempstr);
- efree(tempstr);
- }
-#elif FHTTPD
- php3_fhttpd_puts_header(header_information);
- php3_fhttpd_puts_header("\r\n");
-#else
- PUTS_H(header_information);
- PUTS_H("\015\012");
-#endif
- }
- } else {
-#if USE_SAPI
- {
- char *tempstr=emalloc(strlen(header_information)+2);
- sprintf(tempstr,"%s\015\012",tempstr);
- sapi_rqst->header(sapi_rqst->scid,tempstr);
- efree(tempstr);
- }
-#elif FHTTPD
- php3_fhttpd_puts_header(header_information);
- php3_fhttpd_puts_header("\r\n");
-#else
- PUTS_H(header_information);
- PUTS_H("\015\012");
-#endif
- }
-#endif
-}
-#else
-void php4i_add_header_information(char *header_information, uint header_length)
-{
- sapi_add_header(header_information, header_length);
-}
-#endif
-
-
-/* Implementation of the language Header() function */
-PHP_FUNCTION(Header)
-{
- pval *arg1;
-
- if (getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg1);
- php4i_add_header_information(arg1->value.str.val, arg1->value.str.len);
- arg1->type = IS_LONG; /* change arg1's type so that it doesn't get freed */
- arg1->value.lval = 0;
-}
-
-
-
-
-
-#if 0
-/*
- * php3_header() flushes the header info built up using calls to
- * the Header() function. If type is 1, a redirect to str is done.
- * Otherwise type should be 0 and str NULL.
- *
- * The function returns non-zero if output is allowed after the
- * call, and zero otherwise. Any call to php3_header() must check
- * the return status and if false, no output must be sent. This
- * is in order to correctly handle HEAD requests.
- */
-PHPAPI int php3_header(void)
-{
-#if APACHE
- CookieList *cookie;
- int len = 0;
- time_t t;
- char *dt, *cookievalue = NULL;
-#endif
-#if APACHE || defined(USE_SAPI) || FHTTPD
- char *tempstr;
-#endif
- PLS_FETCH();
- SLS_FETCH();
-
- if (PG(header_is_being_sent)) {
- return 0;
- } else {
- PG(header_is_being_sent) = 1;
- }
-
-#if APACHE
- if (!((request_rec *) SG(server_context))) { /* we're not in a request, allow output */
- PG(header_is_being_sent) = 0;
- return 1;
- }
- if ((php3_PrintHeader && !php3_HeaderPrinted) || (php3_PrintHeader && php3_HeaderPrinted == 2)) {
- cookie = php3_PopCookieList();
- while (cookie) {
- if (cookie->name)
- len += strlen(cookie->name);
- if (cookie->value) {
- cookievalue = _php3_urlencode(cookie->value, strlen (cookie->value));
- len += strlen(cookievalue);
- }
- if (cookie->path)
- len += strlen(cookie->path);
- if (cookie->domain)
- len += strlen(cookie->domain);
- tempstr = emalloc(len + 100);
- if (!cookie->value || (cookie->value && !*cookie->value)) {
- /*
- * MSIE doesn't delete a cookie when you set it to a null value
- * so in order to force cookies to be deleted, even on MSIE, we
- * pick an expiry date 1 year and 1 second in the past
- */
- sprintf(tempstr, "%s=deleted", cookie->name);
- t = time(NULL) - 31536001;
- strcat(tempstr, "; expires=");
- dt = php3_std_date(t);
- strcat(tempstr, dt);
- efree(dt);
- } else {
- /* FIXME: XXX: this is not binary data safe */
- sprintf(tempstr, "%s=%s", cookie->name, cookie->value ? cookievalue : "");
- if (cookie->name) efree(cookie->name);
- if (cookie->value) efree(cookie->value);
- if (cookievalue) efree(cookievalue);
- cookie->name=NULL;
- cookie->value=NULL;
- cookievalue=NULL;
- if (cookie->expires > 0) {
- strcat(tempstr, "; expires=");
- dt = php3_std_date(cookie->expires);
- strcat(tempstr, dt);
- efree(dt);
- }
- }
- if (cookie->path && strlen(cookie->path)) {
- strcat(tempstr, "; path=");
- strcat(tempstr, cookie->path);
- efree(cookie->path);
- cookie->path=NULL;
- }
- if (cookie->domain && strlen(cookie->domain)) {
- strcat(tempstr, "; domain=");
- strcat(tempstr, cookie->domain);
- efree(cookie->domain);
- cookie->domain=NULL;
- }
- if (cookie->secure) {
- strcat(tempstr, "; secure");
- }
- table_add(((request_rec *) SG(server_context))->headers_out, "Set-Cookie", tempstr);
- if (cookie->domain) efree(cookie->domain);
- if (cookie->path) efree(cookie->path);
- if (cookie->name) efree(cookie->name);
- if (cookie->value) efree(cookie->value);
- if (cookievalue) efree(cookievalue);
- efree(cookie);
- cookie = php3_PopCookieList();
- efree(tempstr);
- }
- php3_HeaderPrinted = 1;
- header_called = 1;
- send_http_header(((request_rec *) SG(server_context)));
- if (((request_rec *) SG(server_context))->header_only) {
- set_header_request(1);
- PG(header_is_being_sent) = 0;
- return(0);
- }
- }
-#else
- if (php3_PrintHeader && !php3_HeaderPrinted) {
- if (!cont_type) {
-#if USE_SAPI
- sapi_rqst->header(sapi_rqst->scid,"Content-type: text/html\015\012\015\012");
-#elif FHTTPD
- php3_fhttpd_puts_header("Content-type: text/html\r\n");
-#else
- PUTS_H("Content-type: text/html\015\012\015\012");
-#endif
- } else {
-#if 0 /*WIN32|WINNT / *M$ does us again*/
- if (!strcmp(cont_type,"text/html")){
-#endif
-#if USE_SAPI
- tempstr=emalloc(strlen(cont_type)+18);
- sprintf(tempstr,"Content-type: %s\015\012\015\012",cont_type);
- sapi_rqst->header(sapi_rqst->scid,tempstr);
- efree(tempstr);
-#elif FHTTPD
- tempstr = emalloc(strlen(cont_type)
- + sizeof("Content-type:") + 2);
- if(tempstr) {
- strcpy(tempstr, "Content-type:");
- strcpy(tempstr + sizeof("Content-type:") - 1,
- cont_type);
- strcat(tempstr, "\r\n");
- php3_fhttpd_puts_header(tempstr);
- efree(tempstr);
- }
-#else
- PUTS_H("Content-type:");
- PUTS_H(cont_type);
- PUTS_H("\015\012\015\012");
-#endif
- efree(cont_type);
-#if 0 /*WIN32|WINNT / *M$ does us again*/
- } else {
- PUTS_H("\015\012");
- }/*end excluding output of text/html*/
-#endif
- }
-#if USE_SAPI
- sapi_rqst->flush(sapi_rqst->scid);
-#else
- fflush(stdout);
-#endif
- php3_HeaderPrinted = 1;
- header_called = 1;
- }
-#endif
- PG(header_is_being_sent) = 0;
- return(1);
-}
-#else
-PHPAPI int php3_header()
-{
- SLS_FETCH();
-
- if (sapi_send_headers()==FAILURE || SG(request_info).headers_only) {
- return 0; /* don't allow output */
- } else {
- return 1; /* allow output */
- }
-}
-#endif
-
-
-
-void php3_PushCookieList(char *name, char *value, time_t expires, char *path, char *domain, int secure)
-{
- CookieList *new;
-
- new = emalloc(sizeof(CookieList));
- new->next = top;
- new->name = name;
- new->value = value;
- new->expires = expires;
- new->path = path;
- new->domain = domain;
- new->secure = secure;
- top = new;
-}
-
-CookieList *php3_PopCookieList(void)
-{
- CookieList *ret;
-
- ret = top;
- if (top)
- top = top->next;
- return (ret);
-}
-
-/* php3_setcookie(name,value,expires,path,domain,secure) */
-PHP_FUNCTION(setcookie)
-{
- char *cookie;
- int len=sizeof("Set-Cookie: ");
- time_t t;
- char *r, *dt;
- char *name = NULL, *value = NULL, *path = NULL, *domain = NULL;
- time_t expires = 0;
- int secure = 0;
- pval *arg[6];
- int arg_count;
-
- arg_count = ARG_COUNT(ht);
- if (arg_count < 1 || arg_count > 6 || getParametersArray(ht, arg_count, arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- if (php3_HeaderPrinted == 1) {
- php_error(E_WARNING, "Oops, php3_SetCookie called after header has been sent\n");
- return;
- }
- switch (arg_count) {
- case 6:
- convert_to_boolean(arg[5]);
- secure = arg[5]->value.lval;
- /* break missing intentionally */
- case 5:
- convert_to_string(arg[4]);
- domain = estrndup(arg[4]->value.str.val,arg[4]->value.str.len);
- /* break missing intentionally */
- case 4:
- convert_to_string(arg[3]);
- path = estrndup(arg[3]->value.str.val,arg[3]->value.str.len);
- /* break missing intentionally */
- case 3:
- convert_to_long(arg[2]);
- expires = arg[2]->value.lval;
- /* break missing intentionally */
- case 2:
- convert_to_string(arg[1]);
- value = estrndup(arg[1]->value.str.val,arg[1]->value.str.len);
- /* break missing intentionally */
- case 1:
- convert_to_string(arg[0]);
- name = estrndup(arg[0]->value.str.val,arg[0]->value.str.len);
- break;
- }
-#if 0
- php3_PushCookieList(name, value, expires, path, domain, secure);
-#else
- if (name) {
- len += strlen(name);
- }
- if (value) {
- len += strlen(value);
- }
- if (path) {
- len += strlen(path);
- }
- if (domain) {
- len += strlen(domain);
- }
- cookie = emalloc(len + 100);
- if (!value || (value && !*value)) {
- /*
- * MSIE doesn't delete a cookie when you set it to a null value
- * so in order to force cookies to be deleted, even on MSIE, we
- * pick an expiry date 1 year and 1 second in the past
- */
- sprintf(cookie, "Set-Cookie: %s=deleted", name);
- strcat(cookie, "; expires=");
- t = time(NULL) - 31536001;
- dt = php3_std_date(t);
- strcat(cookie, dt);
- efree(dt);
- } else {
- /* FIXME: XXX: this is not binary data safe */
- r = _php3_urlencode(value, strlen (value));
- sprintf(cookie, "Set-Cookie: %s=%s", name, value ? r : "");
- if (r) efree(r);
- if (value) efree(value);
- value=NULL;
- if (name) efree(name);
- name=NULL;
- if (expires > 0) {
- strcat(cookie, "; expires=");
- dt = php3_std_date(expires);
- strcat(cookie, dt);
- efree(dt);
- }
- }
- if (path && strlen(path)) {
- strcat(cookie, "; path=");
- strcat(cookie, path);
- efree(path);
- path=NULL;
- }
- if (domain && strlen(domain)) {
- strcat(cookie, "; domain=");
- strcat(cookie, domain);
- efree(domain);
- domain=NULL;
- }
- if (secure) {
- strcat(cookie, "; secure");
- }
-
-
- if (sapi_add_header(cookie, strlen(cookie))==SUCCESS) {
- RETVAL_TRUE;
- } else {
- RETVAL_FALSE;
- }
-
- if (domain) {
- efree(domain);
- }
- if (path) {
- efree(path);
- }
- if (name) {
- efree(name);
- }
- if (value) {
- efree(value);
- }
-#endif
-}
-
-
-int php3_headers_unsent(void)
-{
- if (php3_HeaderPrinted!=1 || !php3_PrintHeader) {
- return 1;
- } else {
- return 0;
- }
-}
-
-PHP_FUNCTION(headers_sent)
-{
- SLS_FETCH();
-
- if (SG(headers_sent)) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-
-function_entry php3_header_functions[] = {
- {NULL, NULL, NULL}
-};
-
-
-php3_module_entry php3_header_module_entry = {
- "PHP_head", php3_header_functions, NULL, NULL, PHP_RINIT(head), NULL, NULL, STANDARD_MODULE_PROPERTIES
-};
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/head.h b/ext/standard/head.h
deleted file mode 100644
index 51208a606e..0000000000
--- a/ext/standard/head.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-#ifndef _HEAD_H
-#define _HEAD_H
-
-
-/*
- We are still using a PHP2-style Push/Pop list here as opposed
- to the PHP3 built-in list functionality because of the nature
- of this particular list. It is just used as a structured
- buffer. Doing this with the built-in list code would require
- some changes to allow a search for the first item with a
- certain type. This type of search would not be optimal.
- Private list management makes more sense here
-*/
-typedef struct CookieList {
- char *name;
- char *value;
- time_t expires;
- char *path;
- char *domain;
- int secure;
- struct CookieList *next;
-} CookieList;
-
-extern php3_module_entry php3_header_module_entry;
-#define php3_header_module_ptr &php3_header_module_entry
-
-extern PHP_RINIT_FUNCTION(head);
-PHP_FUNCTION(Header);
-PHP_FUNCTION(setcookie);
-PHP_FUNCTION(headers_sent);
-
-void php4i_add_header_information(char *header_information, uint header_length);
-
-PHPAPI int php3_header(void);
-int php3_headers_unsent(void);
-
-#define phpext_head_ptr php3_header_module_ptr
-
-#endif
diff --git a/ext/standard/html.c b/ext/standard/html.c
deleted file mode 100644
index 8f2cb68788..0000000000
--- a/ext/standard/html.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Jaakko Hyvätti <jaakko.hyvatti@iki.fi> |
- +----------------------------------------------------------------------+
- */
-
-#include "php.h"
-#include "reg.h"
-#include "html.h"
-
-/* This must be fixed to handle the input string according to LC_CTYPE.
- Defaults to ISO-8859-1 for now. */
-
-static char EntTable[][7] =
-{
- "nbsp","iexcl","cent","pound","curren","yen","brvbar",
- "sect","uml","copy","ordf","laquo","not","shy","reg",
- "macr","deg","plusmn","sup2","sup3","acute","micro",
- "para","middot","cedil","sup1","ordm","raquo","frac14",
- "frac12","frac34","iquest","Agrave","Aacute","Acirc",
- "Atilde","Auml","Aring","AElig","Ccedil","Egrave",
- "Eacute","Ecirc","Euml","Igrave","Iacute","Icirc",
- "Iuml","ETH","Ntilde","Ograve","Oacute","Ocirc","Otilde",
- "Ouml","times","Oslash","Ugrave","Uacute","Ucirc","Uuml",
- "Yacute","THORN","szlig","agrave","aacute","acirc",
- "atilde","auml","aring","aelig","ccedil","egrave",
- "eacute","ecirc","euml","igrave","iacute","icirc",
- "iuml","eth","ntilde","ograve","oacute","ocirc","otilde",
- "ouml","divide","oslash","ugrave","uacute","ucirc",
- "uuml","yacute","thorn","yuml"
-};
-
-static void _php3_htmlentities(INTERNAL_FUNCTION_PARAMETERS, int all)
-{
- pval *arg;
- int i, len, maxlen;
- unsigned char *old;
- char *new;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(arg);
-
- maxlen = 2 * arg->value.str.len;
- if (maxlen < 128)
- maxlen = 128;
- new = emalloc (maxlen);
- len = 0;
-
- old = (unsigned char *)arg->value.str.val;
- i = arg->value.str.len;
- while (i--) {
- if (len + 9 > maxlen)
- new = erealloc (new, maxlen += 128);
- if (38 == *old) {
- memcpy (new + len, "&amp;", 5);
- len += 5;
- } else if (34 == *old) {
- memcpy (new + len, "&quot;", 6);
- len += 6;
- } else if (60 == *old) {
- memcpy (new + len, "&lt;", 4);
- len += 4;
- } else if (62 == *old) {
- memcpy (new + len, "&gt;", 4);
- len += 4;
- } else if (all && 160 <= *old) {
- new [len++] = '&';
- strcpy (new + len, EntTable [*old - 160]);
- len += strlen (EntTable [*old - 160]);
- new [len++] = ';';
- } else {
- new [len++] = *old;
- }
- old++;
- }
- new [len] = '\0';
-
- RETVAL_STRINGL(new,len,1);
- efree(new);
-}
-
-/* {{{ proto string htmlspecialchars(string string)
- Convert special characters to HTML entities */
-PHP_FUNCTION(htmlspecialchars)
-{
- _php3_htmlentities(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
-}
-/* }}} */
-
-/* {{{ proto string htmlentities(string string)
- Convert all applicable characters to HTML entities */
-PHP_FUNCTION(htmlentities)
-{
- _php3_htmlentities(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/html.h b/ext/standard/html.h
deleted file mode 100644
index 3baddaf46e..0000000000
--- a/ext/standard/html.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _HTML_H
-#define _HTML_H
-
-PHP_FUNCTION(htmlspecialchars);
-PHP_FUNCTION(htmlentities);
-
-#endif /* _HTML_H */
diff --git a/ext/standard/image.c b/ext/standard/image.c
deleted file mode 100644
index cdcdf84ada..0000000000
--- a/ext/standard/image.c
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-/*
- * Based on Daniel Schmitt's imageinfo.c which carried the following
- * Copyright notice.
- */
-
-/*
- * imageinfo.c
- *
- * Simple routines to extract image width/height data from GIF/JPEG files.
- *
- * Copyright (c) 1997 Daniel Schmitt, opal online publishing, Bonn, Germany.
- *
- * Includes code snippets from rdjpgcom.c,
- * Copyright (c) 1994-1995 Thomas G. Lane
- * from release 6a of the Independent JPEG Group's software.
- *
- * Legal status: see GNU General Public License version 2 or later.
- *
- */
-
-#include "php.h"
-#include <stdio.h>
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#include "fopen-wrappers.h"
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include "php_image.h"
-
-/* file type markers */
-const char php3_sig_gif[3] =
-{'G', 'I', 'F'};
-const char php3_sig_jpg[3] =
-{(char) 0xff, (char) 0xd8, (char) 0xff};
-const char php3_sig_png[8] =
-{(char) 0x89, (char) 0x50, (char) 0x4e,
- (char) 0x47, (char) 0x0d, (char) 0x0a,
- (char) 0x1a, (char) 0x0a};
-
-/* return info as a struct, to make expansion easier */
-
-struct gfxinfo {
- unsigned int width;
- unsigned int height;
- unsigned int bits;
- unsigned int channels;
-};
-
-/* routine to handle GIF files. If only everything were that easy... ;} */
-static struct gfxinfo *php3_handle_gif (FILE *fp)
-{
- struct gfxinfo *result = NULL;
- unsigned char a[2];
-
- result = (struct gfxinfo *) ecalloc(1,sizeof(struct gfxinfo));
- fseek(fp, 6L, SEEK_SET);
- fread(a,sizeof(a),1,fp);
- result->width = (unsigned short)a[0] | (((unsigned short)a[1])<<8);
- fread(a,sizeof(a),1,fp);
- result->height = (unsigned short)a[0] | (((unsigned short)a[1])<<8);
- return result;
-}
-
-static unsigned long php3_read4(FILE *fp)
-{
- unsigned char a[ 4 ];
-
- /* just return 0 if we hit the end-of-file */
- if (fread(a,sizeof(a),1,fp) != 1) return 0;
-
- return (((unsigned long) a[ 0 ]) << 24) + (((unsigned long) a[ 1 ]) << 16) + (((unsigned long) a[ 2 ]) << 8) + ((unsigned long) a[ 3 ]);
-
-}
-
-/* routine to handle PNG files. - even easier */
-static struct gfxinfo *php3_handle_png(FILE *fp)
-{
- struct gfxinfo *result = NULL;
- unsigned long in_width, in_height;
-
- result = (struct gfxinfo *) ecalloc(1,sizeof(struct gfxinfo));
- fseek(fp, 16L, SEEK_SET);
- in_width = php3_read4(fp);
- in_height = php3_read4(fp);
- result->width = (unsigned int) in_width;
- result->height = (unsigned int) in_height;
- return result;
-}
-
-/* routines to handle JPEG data */
-
-/* some defines for the different JPEG block types */
-#define M_SOF0 0xC0 /* Start Of Frame N */
-#define M_SOF1 0xC1 /* N indicates which compression process */
-#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */
-#define M_SOF3 0xC3
-#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */
-#define M_SOF6 0xC6
-#define M_SOF7 0xC7
-#define M_SOF9 0xC9
-#define M_SOF10 0xCA
-#define M_SOF11 0xCB
-#define M_SOF13 0xCD
-#define M_SOF14 0xCE
-#define M_SOF15 0xCF
-#define M_SOI 0xD8
-#define M_EOI 0xD9 /* End Of Image (end of datastream) */
-#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */
-#define M_APP0 0xe0
-#define M_APP1 0xe1
-#define M_APP2 0xe2
-#define M_APP3 0xe3
-#define M_APP4 0xe4
-#define M_APP5 0xe5
-#define M_APP6 0xe6
-#define M_APP7 0xe7
-#define M_APP8 0xe8
-#define M_APP9 0xe9
-#define M_APP10 0xea
-#define M_APP11 0xeb
-#define M_APP12 0xec
-#define M_APP13 0xed
-#define M_APP14 0xee
-#define M_APP15 0xef
-
-static unsigned short php3_read2(FILE *fp)
-{
- unsigned char a[ 2 ];
-
- /* just return 0 if we hit the end-of-file */
- if (fread(a,sizeof(a),1,fp) != 1) return 0;
-
- return (((unsigned short) a[ 0 ]) << 8) + ((unsigned short) a[ 1 ]);
-}
-
-static unsigned int php3_next_marker(FILE *fp)
- /* get next marker byte from file */
-{
- int c;
-
- /* skip unimportant stuff */
-
- c = getc(fp);
-
- while (c != 0xff) {
- if ((c = getc(fp)) == EOF)
- return M_EOI; /* we hit EOF */
- }
-
- /* get marker byte, swallowing possible padding */
- do {
- if ((c = getc(fp)) == EOF)
- return M_EOI; /* we hit EOF */
- } while (c == 0xff);
-
- return (unsigned int) c;
-}
-
-static void php3_skip_variable(FILE *fp)
- /* skip over a variable-length block; assumes proper length marker */
-{
- unsigned short length;
-
- length = php3_read2(fp);
- length -= 2; /* length includes itself */
- fseek(fp, (long) length, SEEK_CUR); /* skip the header */
-}
-
-static void php3_read_APP(FILE *fp,unsigned int marker,pval *info)
-{
- unsigned short length;
- unsigned char *buffer;
- unsigned char markername[ 16 ];
-
- length = php3_read2(fp);
- length -= 2; /* length includes itself */
-
- buffer = emalloc(length);
-
- if (fread(buffer,length,1,fp) != 1) {
- return;
- }
-
- sprintf(markername,"APP%d",marker - M_APP0);
-
- add_assoc_stringl(info,markername,buffer,length,1);
-
- efree(buffer);
-}
-
-static struct gfxinfo *php3_handle_jpeg(FILE *fp,pval *info)
- /* main loop to parse JPEG structure */
-{
- struct gfxinfo *result = NULL;
- unsigned int marker;
-
- fseek(fp, 0L, SEEK_SET); /* position file pointer on SOF */
-
- if (getc(fp) != 0xFF) /* JPEG header... */
- return NULL;
-
- if (getc(fp) != M_SOI) /* JPEG header... */
- return NULL;
-
- for (;;) {
- marker = php3_next_marker(fp);
- switch (marker) {
- case M_SOF0:
- case M_SOF1:
- case M_SOF2:
- case M_SOF3:
- case M_SOF5:
- case M_SOF6:
- case M_SOF7:
- case M_SOF9:
- case M_SOF10:
- case M_SOF11:
- case M_SOF13:
- case M_SOF14:
- case M_SOF15:
- if (result == NULL) {
- /* handle SOFn block */
- result = (struct gfxinfo *) ecalloc(1,sizeof(struct gfxinfo));
-
- fseek(fp, 2, SEEK_CUR);
-
- result->bits = fgetc(fp);
- result->height = php3_read2(fp);
- result->width = php3_read2(fp);
- result->channels = fgetc(fp);
-
- if (! info) /* if we don't want an extanded info -> return */
- return result;
- } else {
- php3_skip_variable(fp);
- }
- break;
-
- case M_APP0:
- case M_APP1:
- case M_APP2:
- case M_APP3:
- case M_APP4:
- case M_APP5:
- case M_APP6:
- case M_APP7:
- case M_APP8:
- case M_APP9:
- case M_APP10:
- case M_APP11:
- case M_APP12:
- case M_APP13:
- case M_APP14:
- case M_APP15:
- if (info) {
- php3_read_APP(fp,marker,info); /* read all the app markes... */
- } else {
- php3_skip_variable(fp);
- }
- break;
-
- case M_SOS:
- case M_EOI:
- return result; /* we're about to hit image data, or are at EOF. stop processing. */
- break;
-
- default:
- php3_skip_variable(fp); /* anything else isn't interesting */
- break;
- }
- }
-
- return NULL;
-}
-
-/* main function */
-PHP_FUNCTION(getimagesize)
-{
- pval *arg1,*info = 0;
- FILE *fp;
- int itype = 0;
- char filetype[3];
- char pngtype[8];
- char temp[64];
- struct gfxinfo *result = NULL;
-
- switch(ARG_COUNT(ht)){
- case 1:
- if (getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg1);
- break;
-
- case 2:
- if (getParameters(ht, 2, &arg1, &info) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- if (!ParameterPassedByReference(ht, 2)) {
- php_error(E_WARNING, "Array to be filled with values must be passed by reference.");
- RETURN_FALSE;
- }
-
- pval_destructor(info);
-
- if (array_init(info) == FAILURE) {
- return;
- }
-
- convert_to_string(arg1);
- break;
-
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- /* Check open_basedir */
- if (_php3_check_open_basedir(arg1->value.str.val)) return;
-
- if ((fp = fopen(arg1->value.str.val,"rb")) == 0) {
- php_error(E_WARNING, "Unable to open %s", arg1->value.str.val);
- return;
- }
- fread(filetype,sizeof(filetype),1,fp);
- if (!memcmp(filetype, php3_sig_gif, 3)) {
- result = php3_handle_gif (fp);
- itype = 1;
- } else if (!memcmp(filetype, php3_sig_jpg, 3)) {
- result = php3_handle_jpeg(fp,info);
- itype = 2;
- } else if (!memcmp(filetype, php3_sig_png, 3)) {
- fseek(fp, 0L, SEEK_SET);
- fread(pngtype, sizeof(pngtype), 1, fp);
- if (!memcmp(pngtype, php3_sig_png, 8)) {
- result = php3_handle_png(fp);
- itype = 3;
- } else {
- php_error(E_WARNING, "PNG file corrupted by ASCII conversion");
- }
- }
- fclose(fp);
- if (result) {
- if (array_init(return_value) == FAILURE) {
- php_error(E_ERROR, "Unable to initialize array");
- if (result) efree(result);
- return;
- }
- add_index_long(return_value, 0, result->width);
- add_index_long(return_value, 1, result->height);
- add_index_long(return_value, 2, itype);
- sprintf(temp, "width=\"%d\" height=\"%d\"", result->width, result->height); /* safe */
- add_index_string(return_value, 3, temp, 1);
-
- if (result->bits != 0) {
- add_assoc_long(return_value,"bits",result->bits);
- }
- if (result->channels != 0) {
- add_assoc_long(return_value,"channels",result->channels);
- }
-
- efree(result);
- }
-}
diff --git a/ext/standard/info.c b/ext/standard/info.c
deleted file mode 100644
index e2f4a8d20f..0000000000
--- a/ext/standard/info.c
+++ /dev/null
@@ -1,504 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-#include "php.h"
-#include "php_ini.h"
-#include "php_globals.h"
-#include "ext/standard/head.h"
-#include "info.h"
-#include "SAPI.h"
-#ifndef MSVC5
-#include "build-defs.h"
-#endif
-#include "zend_globals.h" /* needs ELS */
-
-
-#define PHP3_CONF_LONG(directive,value1,value2) \
- php_printf("<tr><td bgcolor=\"" PHP_ENTRY_NAME_COLOR "\">%s</td><td bgcolor=\"" PHP_CONTENTS_COLOR "\">%ld</td><td bgcolor=\"" PHP_CONTENTS_COLOR "\">%ld</td></tr>\n",directive,value1,value2);
-
-#define SECTION(name) PUTS("<hr><h2>" name "</h2>\n")
-
-#define CREDIT_LINE(module, authors) php_info_print_table_row(2, module, authors)
-
-
-static int _display_module_info(zend_module_entry *module, void *arg)
-{
- int show_info_func = *((int *) arg);
-
- if (show_info_func && module->info_func) {
- php_printf("<hr><h2>%s</h2>\n", module->name);
- module->info_func(module);
- } else if (!show_info_func && !module->info_func) {
- php_printf("<tr><td bgcolor=\"" PHP_CONTENTS_COLOR "\">");
- php_printf(module->name);
- php_printf("</td><tr>\n");
- }
- return 0;
-}
-
-
-PHPAPI void php_print_info(int flag)
-{
- char **env,*tmp1,*tmp2;
- char *php3_uname;
- int expose_php = INI_INT("expose_php");
-#if WIN32|WINNT
- char php3_windows_uname[256];
- DWORD dwBuild=0;
- DWORD dwVersion = GetVersion();
- DWORD dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
- DWORD dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
-#endif
- ELS_FETCH();
- PLS_FETCH();
- SLS_FETCH();
-
-
- if (flag & PHP_INFO_GENERAL) {
-#if WIN32|WINNT
- // Get build numbers for Windows NT or Win95
- if (dwVersion < 0x80000000){
- dwBuild = (DWORD)(HIWORD(dwVersion));
- snprintf(php3_windows_uname,255,"%s %d.%d build %d","Windows NT",dwWindowsMajorVersion,dwWindowsMinorVersion,dwBuild);
- } else {
- snprintf(php3_windows_uname,255,"%s %d.%d","Windows 95/98",dwWindowsMajorVersion,dwWindowsMinorVersion);
- }
- php3_uname = php3_windows_uname;
-#else
- php3_uname=PHP_UNAME;
-#endif
-
-
- php_printf("<center><h1>PHP Version %s</h1></center>\n", PHP_VERSION);
-
- PUTS("<hr>");
- if (expose_php) {
- PUTS("<a href=\"http://www.php.net/\"><img src=\"");
- if (SG(request_info).request_uri) {
- PUTS(SG(request_info).request_uri);
- }
- PUTS("?=PHPE9568F34-D428-11d2-A769-00AA001ACF42\" border=\"0\" align=\"right\"></a>\n");
- }
- php_printf("System: %s<br>Build Date: %s\n<br>", php3_uname, __DATE__);
- php_printf("php.ini path: %s<br>\n", CONFIGURATION_FILE_PATH);
-
- php_printf("ZEND_DEBUG=%d<br>\n", ZEND_DEBUG);
-#ifdef ZTS
- php_printf("ZTS is defined");
-#else
- php_printf("ZTS is undefined");
-#endif
- /* Zend Engine */
- PUTS("<hr>");
- if (expose_php) {
- PUTS("<a href=\"http://www.zend.com/\"><img src=\"");
- if (SG(request_info).request_uri) {
- PUTS(SG(request_info).request_uri);
- }
- PUTS("?=PHPE9568F35-D428-11d2-A769-00AA001ACF42\" border=\"0\" align=\"right\"></a>\n");
- }
- php_printf("This program makes use of the Zend scripting language engine:<br><pre>%s</pre>", get_zend_version());
- }
-
- PUTS("<center>");
-
- if ((flag & PHP_INFO_CREDITS) && expose_php) {
- PUTS("<hr>");
- PUTS("<a href=\"");
- if (SG(request_info).request_uri) {
- PUTS(SG(request_info).request_uri);
- }
- PUTS("?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000\">");
- PUTS("<h1>PHP 4.0 Credits</h1>\n");
- PUTS("</a>\n");
- }
-
-
- if (flag & PHP_INFO_CONFIGURATION) {
- PUTS("<hr><h1>Configuration</h1>\n");
- PUTS("<h2>PHP Core</h2>\n");
- display_ini_entries(NULL);
- }
-
- if (flag & PHP_INFO_MODULES) {
- int show_info_func;
-
- show_info_func = 1;
- zend_hash_apply_with_argument(&module_registry, (int (*)(void *, void *)) _display_module_info, &show_info_func);
-
- SECTION("Additional Modules");
- PUTS("<table border=5 width=\"600\">\n");
- show_info_func = 0;
- zend_hash_apply_with_argument(&module_registry, (int (*)(void *, void *)) _display_module_info, &show_info_func);
- PUTS("</table>\n");
- }
-
- if (flag & PHP_INFO_ENVIRONMENT) {
- SECTION("Environment");
- PUTS("<table border=5 width=\"600\">\n");
- php_info_print_table_header(2, "Variable", "Value");
- for (env=environ; env!=NULL && *env !=NULL; env++) {
- tmp1 = estrdup(*env);
- if (!(tmp2=strchr(tmp1,'='))) { /* malformed entry? */
- efree(tmp1);
- continue;
- }
- *tmp2 = 0;
- tmp2++;
- php_info_print_table_row(2, tmp1, tmp2);
- efree(tmp1);
- }
- PUTS("</table>\n");
- }
-
- if (flag & PHP_INFO_VARIABLES) {
- pval **data, **tmp;
- char *string_key;
- ulong num_key;
-
- SECTION("PHP Variables");
-
- PUTS("<table border=5 width=\"600\">\n");
- php_info_print_table_header(2, "Variable", "Value");
- if (zend_hash_find(&EG(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void **) &data) != FAILURE) {
- php_info_print_table_row(2, "PHP_SELF", (*data)->value.str.val);
- }
- if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_TYPE", sizeof("PHP_AUTH_TYPE"), (void **) &data) != FAILURE) {
- php_info_print_table_row(2, "PHP_AUTH_TYPE", (*data)->value.str.val);
- }
- if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_USER", sizeof("PHP_AUTH_USER"), (void **) &data) != FAILURE) {
- php_info_print_table_row(2, "PHP_AUTH_USER", (*data)->value.str.val);
- }
- if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_PW", sizeof("PHP_AUTH_PW"), (void **) &data) != FAILURE) {
- php_info_print_table_row(2, "PHP_AUTH_PW", (*data)->value.str.val);
- }
- if (zend_hash_find(&EG(symbol_table), "HTTP_GET_VARS", sizeof("HTTP_GET_VARS"), (void **) &data) != FAILURE) {
- zend_hash_internal_pointer_reset((*data)->value.ht);
- while (zend_hash_get_current_data((*data)->value.ht, (void **) &tmp) == SUCCESS) {
- zval tmp2, *value_ptr;
-
- if ((*tmp)->type != IS_STRING) {
- tmp2 = **tmp;
- zval_copy_ctor(&tmp2);
- convert_to_string(&tmp2);
- value_ptr = &tmp2;
- } else {
- value_ptr = *tmp;
- }
- PUTS("<tr><td bgcolor=\"" PHP_ENTRY_NAME_COLOR "\"><b>HTTP_GET_VARS[\"");
- switch (zend_hash_get_current_key((*data)->value.ht, &string_key, &num_key)) {
- case HASH_KEY_IS_STRING:
- PUTS(string_key);
- efree(string_key);
- break;
- case HASH_KEY_IS_LONG:
- php_printf("%ld",num_key);
- break;
- }
- PUTS("\"]</b></td><td bgcolor=\"" PHP_CONTENTS_COLOR "\">");
- if ((*tmp)->type == IS_ARRAY) {
- PUTS("<pre>");
- zend_print_zval_r(*tmp, 0);
- PUTS("</pre>");
- } else {
- PUTS(value_ptr->value.str.val);
- }
- PUTS("</td></tr>\n");
- zend_hash_move_forward((*data)->value.ht);
- if (value_ptr==&tmp2) {
- zval_dtor(value_ptr);
- }
- }
- }
- if (zend_hash_find(&EG(symbol_table), "HTTP_POST_VARS", sizeof("HTTP_POST_VARS"), (void **) &data) != FAILURE) {
- zend_hash_internal_pointer_reset((*data)->value.ht);
- while (zend_hash_get_current_data((*data)->value.ht, (void **) &tmp) == SUCCESS) {
- convert_to_string(*tmp);
- PUTS("<tr><td bgcolor=\"" PHP_ENTRY_NAME_COLOR "\"><b>HTTP_POST_VARS[\"");
- switch (zend_hash_get_current_key((*data)->value.ht, &string_key, &num_key)) {
- case HASH_KEY_IS_STRING:
- PUTS(string_key);
- efree(string_key);
- break;
- case HASH_KEY_IS_LONG:
- php_printf("%ld",num_key);
- break;
- }
- PUTS("\"]</b></td><td bgcolor=\"" PHP_CONTENTS_COLOR "\">");
- PUTS((*tmp)->value.str.val);
- PUTS("</td></tr>\n");
- zend_hash_move_forward((*data)->value.ht);
- }
- }
- if (zend_hash_find(&EG(symbol_table), "HTTP_COOKIE_VARS", sizeof("HTTP_COOKIE_VARS"), (void **) &data) != FAILURE) {
- zend_hash_internal_pointer_reset((*data)->value.ht);
- while (zend_hash_get_current_data((*data)->value.ht, (void **) &tmp) == SUCCESS) {
- convert_to_string(*tmp);
- PUTS("<tr><td bgcolor=\"" PHP_ENTRY_NAME_COLOR "\"><b>HTTP_COOKIE_VARS[\"");
- switch (zend_hash_get_current_key((*data)->value.ht, &string_key, &num_key)) {
- case HASH_KEY_IS_STRING:
- PUTS(string_key);
- efree(string_key);
- break;
- case HASH_KEY_IS_LONG:
- php_printf("%ld",num_key);
- break;
- }
- PUTS("\"]</b></td><td bgcolor=\"" PHP_CONTENTS_COLOR "\">");
- PUTS((*tmp)->value.str.val);
- PUTS("</td></tr>\n");
- zend_hash_move_forward((*data)->value.ht);
- }
- }
- PUTS("</table>\n");
- }
-
- PUTS("</center>");
-
-
- if (flag & PHP_INFO_LICENSE) {
- SECTION("PHP License");
- PUTS("<PRE>This program is free software; you can redistribute it and/or modify\n");
- PUTS("it under the terms of the PHP License as published by the PHP Group\n");
- PUTS("and included in the distribution in the file: LICENSE\n");
- PUTS("\n");
- PUTS("This program is distributed in the hope that it will be useful,\n");
- PUTS("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
- PUTS("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
- PUTS("\n");
- PUTS("If you did not receive a copy of the PHP license, or have any questions about\n");
- PUTS("PHP licensing, please contact license@php.net.</PRE>\n");
- }
-}
-
-
-void php_print_credits(int flag)
-{
- if (flag & PHP_CREDITS_FULLPAGE) {
- PUTS("<html><head><title>PHP Credits</title></head><body><center>\n");
- }
-
- PUTS("<h1>PHP 4.0 Credits</h1>\n");
-
- if (flag & PHP_CREDITS_GENERAL) {
- /* Language */
- PUTS("<table border=5 width=\"600\">\n");
- PUTS("<tr><th colspan=\"2\" bgcolor=\"" PHP_HEADER_COLOR "\">PHP 4.0 Authors</th></tr>\n");
- php_info_print_table_header(2, "Contribution", "Authors");
- CREDIT_LINE("Zend Scripting Language Engine", "Andi Gutmans, Zeev Suraski");
- CREDIT_LINE("Extension Module API", "Andi Gutmans, Zeev Suraski");
- CREDIT_LINE("UNIX Build and Modularization", "Stig Bakken");
- CREDIT_LINE("Win32 Port", "Shane Caraveo, Zeev Suraski");
- CREDIT_LINE("Server API (SAPI) Abstraction Layer", "Andi Gutmans, Shane Caraveo, Zeev Suraski");
- CREDIT_LINE("Apache SAPI Module", "Rasmus Lerdorf, Zeev Suraski");
- CREDIT_LINE("ISAPI SAPI Module", "Andi Gutmans, Zeev Suraski");
- CREDIT_LINE("CGI SAPI Module", "Rasmus Lerdorf, Stig Bakken");
- CREDIT_LINE("Overall Work", "Thies C. Arntzen, Stig Bakken, Shane Caraveo, \
- Rasmus Lerdorf, Sascha Schumann, Zeev Suraski, Andrey Zmievski, \
- and others");
- PUTS("</table>\n");
- }
-
- if (flag & PHP_CREDITS_MODULES) {
- /* Modules */
- PUTS("<table border=5 width=\"600\">\n");
- PUTS("<tr><th colspan=\"2\" bgcolor=\"" PHP_HEADER_COLOR "\">Module Authors</th></tr>\n");
- php_info_print_table_header(2, "Module", "Authors");
- CREDIT_LINE("Apache", "Rasmus Lerdorf, Stig Bakken, David Sklar");
- CREDIT_LINE("BC Math", "Andi Gutmans");
- CREDIT_LINE("Win32 COM", "Zeev Suraski");
- CREDIT_LINE("DAV", "Stig Bakken");
- CREDIT_LINE("DBA", "Sascha Schumann");
- CREDIT_LINE("DBM", "Rasmus Lerdorf, Jim Winstead");
- CREDIT_LINE("dBase", "Jim Winstead");
- CREDIT_LINE("FDF", "Uwe Steinmann");
- CREDIT_LINE("FilePro", "Chad Robinson");
- CREDIT_LINE("GD imaging", "Rasmus Lerdorf, Stig Bakken, Jim Winstead");
- CREDIT_LINE("GetText", "Alex Plotnick");
- CREDIT_LINE("HyperWave", "Uwe Steinmann");
- CREDIT_LINE("IMAP", "Rex Logan, Mark Musone, Brian Wang, Kaj-Michael Lang, Antoni Pamies Olive, Rasmus Lerdorf");
- CREDIT_LINE("Informix", "Danny Heijl, Christian Cartus, Jouni Ahto");
- CREDIT_LINE("Interbase", "Jouni Ahto");
- CREDIT_LINE("LDAP", "Amitay Isaacs, Eric Warnke, Rasmus Lerdorf, Gerrit Thomson");
- CREDIT_LINE("mcrypt", "Sascha Schumann");
- CREDIT_LINE("mhash", "Sascha Schumann");
- CREDIT_LINE("mSQL", "Zeev Suraski");
- CREDIT_LINE("MySQL", "Zeev Suraski");
- CREDIT_LINE("OCI8", "Stig Bakken, Thies C. Arntzen");
- CREDIT_LINE("ODBC", "Stig Bakken, Andreas Karajannis, Frank M. Kromann");
- CREDIT_LINE("Oracle", "Stig Bakken, Mitch Golden, Rasmus Lerdorf, Andreas Karajannis, Thies C. Arntzen");
- CREDIT_LINE("Perl Compatible Regexps", "Andrey Zmievski");
- CREDIT_LINE("PDF", "Uwe Steinmann");
- CREDIT_LINE("PostgreSQL", "Jouni Ahto, Zeev Suraski");
- CREDIT_LINE("Sessions", "Sascha Schumann, Andrey Zmievski");
- CREDIT_LINE("SNMP", "Rasmus Lerdorf");
- CREDIT_LINE("Sybase", "Zeev Suraski");
- CREDIT_LINE("System V Shared Memory", "Christian Cartus");
- CREDIT_LINE("System V Semaphores", "Tom May");
- CREDIT_LINE("WDDX", "Andrey Zmievski");
- CREDIT_LINE("XML", "Stig Bakken");
- CREDIT_LINE("Yellow Pages", "Stephanie Wehner");
- CREDIT_LINE("Zlib", "Rasmus Lerdorf, Stefan Roehrich");
- PUTS("</table>\n");
- }
-
- if (flag & PHP_CREDITS_DOCS) {
- /* Documentation */
- }
-
- if (flag & PHP_CREDITS_FULLPAGE) {
- PUTS("</center></body></html>\n");
- }
-}
-
-
-PHPAPI void php_info_print_table_header(int num_cols, ...)
-{
- int i;
- va_list row_elements;
- char *row_element;
-
- va_start(row_elements, num_cols);
-
- php_printf("<tr>");
- for (i=0; i<num_cols; i++) {
- row_element = va_arg(row_elements, char *);
- if (!row_element || !*row_element) {
- row_element = "&nbsp;";
- }
- php_printf("<th bgcolor=\"" PHP_HEADER_COLOR "\" valign=\"top\">%s</th>", row_element);
- }
- php_printf("</tr>\n");
-
- va_end(row_elements);
-}
-
-
-PHPAPI void php_info_print_table_row(int num_cols, ...)
-{
- int i;
- va_list row_elements;
- char *color = PHP_ENTRY_NAME_COLOR;
- char *row_element;
-
- va_start(row_elements, num_cols);
-
- php_printf("<tr>");
- for (i=0; i<num_cols; i++) {
- row_element = va_arg(row_elements, char *);
- if (!row_element || !*row_element) {
- row_element = "&nbsp;";
- }
- php_printf("<td bgcolor=\"%s\" valign=\"top\">%s%s%s</td>",
- color, (i==0?"<b>":""), row_element, (i==0?"</b>":""));
- color = PHP_CONTENTS_COLOR;
- }
- php_printf("</tr>\n");
-
- va_end(row_elements);
-}
-
-
-
-void register_phpinfo_constants(INIT_FUNC_ARGS)
-{
- ELS_FETCH();
-
- REGISTER_LONG_CONSTANT("INFO_GENERAL", PHP_INFO_GENERAL, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("INFO_CREDITS", PHP_INFO_CREDITS, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("INFO_CONFIGURATION", PHP_INFO_CONFIGURATION, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("INFO_MODULES", PHP_INFO_MODULES, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("INFO_ENVIRONMENT", PHP_INFO_ENVIRONMENT, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("INFO_VARIABLES", PHP_INFO_VARIABLES, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("INFO_LICENSE", PHP_INFO_LICENSE, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("INFO_ALL", PHP_INFO_ALL, CONST_PERSISTENT|CONST_CS);
-}
-
-
-/* {{{ proto void phpinfo(void)
- Output a page of useful information about PHP and the current request */
-PHP_FUNCTION(phpinfo)
-{
- int flag;
- zval *flag_arg;
-
-
- switch (ARG_COUNT(ht)) {
- case 0:
- flag = 0xFFFFFFFF;
- break;
- case 1:
- if (getParameters(ht, 1, &flag_arg)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(flag_arg);
- flag = flag_arg->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
- php_print_info(flag);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto string phpversion(void)
- Return the current PHP version */
-PHP_FUNCTION(phpversion)
-{
- RETURN_STRING(PHP_VERSION,1);
-}
-/* }}} */
-
-
-/* {{{ proto void phpcredits(int)
- Prints the list of people who've contributed to the PHP project */
-PHP_FUNCTION(phpcredits)
-{
- int flag;
- zval *flag_arg;
-
-
- switch (ARG_COUNT(ht)) {
- case 0:
- flag = 0xFFFFFFFF;
- break;
- case 1:
- if (getParameters(ht, 1, &flag_arg)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(flag_arg);
- flag = flag_arg->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
- php_print_credits(flag);
- RETURN_TRUE;
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/info.h b/ext/standard/info.h
deleted file mode 100644
index 627accf213..0000000000
--- a/ext/standard/info.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#ifndef _INFO_H
-#define _INFO_H
-
-#define PHP_ENTRY_NAME_COLOR "#FFFFFF"
-#define PHP_CONTENTS_COLOR "#DDDDDD"
-#define PHP_HEADER_COLOR "#FFFF99"
-
-#define PHP_INFO_GENERAL (1<<0)
-#define PHP_INFO_CREDITS (1<<1)
-#define PHP_INFO_CONFIGURATION (1<<2)
-#define PHP_INFO_MODULES (1<<3)
-#define PHP_INFO_ENVIRONMENT (1<<4)
-#define PHP_INFO_VARIABLES (1<<5)
-#define PHP_INFO_LICENSE (1<<6)
-#define PHP_INFO_ALL 0xFFFFFFFF
-
-
-#define PHP_CREDITS_GENERAL (1<<0)
-#define PHP_CREDITS_MODULES (1<<1)
-#define PHP_CREDITS_DOCS (1<<2)
-#define PHP_CREDITS_FULLPAGE (1<<3)
-#define PHP_CREDITS_ALL 0xFFFFFFFF
-
-PHP_FUNCTION(phpversion);
-PHP_FUNCTION(phpinfo);
-PHP_FUNCTION(phpcredits);
-PHPAPI void php_print_info(int flag);
-PHPAPI void php_print_credits(int flag);
-
-
-PHPAPI void php_info_print_table_header(int num_cols, ...);
-PHPAPI void php_info_print_table_row(int num_cols, ...);
-
-void register_phpinfo_constants(INIT_FUNC_ARGS);
-
-#endif /* _INFO_H */
diff --git a/ext/standard/iptc.c b/ext/standard/iptc.c
deleted file mode 100644
index c5718207bb..0000000000
--- a/ext/standard/iptc.c
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Thies C. Arntzen (thies@digicol.de) |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/*
- * Functions to parse & compse IPTC data.
- * PhotoShop >= 3.0 can read and write textual data to JPEG files.
- * ... more to come .....
- *
- * i know, parts of this is now duplicated in image.c
- * but in this case i think it's okay!
- */
-
-/*
- * TODO:
- * - add IPTC translation table
- */
-
-#include "php.h"
-#include "php3_iptc.h"
-#include "ext/standard/head.h"
-
-#include <sys/stat.h>
-
-
-/* some defines for the different JPEG block types */
-#define M_SOF0 0xC0 /* Start Of Frame N */
-#define M_SOF1 0xC1 /* N indicates which compression process */
-#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */
-#define M_SOF3 0xC3
-#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */
-#define M_SOF6 0xC6
-#define M_SOF7 0xC7
-#define M_SOF9 0xC9
-#define M_SOF10 0xCA
-#define M_SOF11 0xCB
-#define M_SOF13 0xCD
-#define M_SOF14 0xCE
-#define M_SOF15 0xCF
-#define M_SOI 0xD8
-#define M_EOI 0xD9 /* End Of Image (end of datastream) */
-#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */
-#define M_APP0 0xe0
-#define M_APP1 0xe1
-#define M_APP2 0xe2
-#define M_APP3 0xe3
-#define M_APP4 0xe4
-#define M_APP5 0xe5
-#define M_APP6 0xe6
-#define M_APP7 0xe7
-#define M_APP8 0xe8
-#define M_APP9 0xe9
-#define M_APP10 0xea
-#define M_APP11 0xeb
-#define M_APP12 0xec
-#define M_APP13 0xed
-#define M_APP14 0xee
-#define M_APP15 0xef
-
-static int php3_iptc_put1(FILE *fp,int spool,unsigned char c,unsigned char **spoolbuf)
-{
- if (spool > 0)
- PUTC(c);
-
- if (spoolbuf) *(*spoolbuf)++ = c;
-
- return c;
-}
-
-static int php3_iptc_get1(FILE *fp,int spool,unsigned char **spoolbuf)
-{
- int c;
- char cc;
-
- c = getc(fp);
-
- if (c == EOF) return EOF;
-
- if (spool > 0) {
- cc = c;
- PUTC(cc);
- }
-
- if (spoolbuf) *(*spoolbuf)++ = c;
-
- return c;
-}
-
-static int php3_iptc_read_remaining(FILE *fp,int spool,unsigned char **spoolbuf)
-{
- int c;
-
- while ((c = php3_iptc_get1(fp,spool,spoolbuf)) != EOF) continue;
-
- return M_EOI;
-}
-
-static int php3_iptc_skip_variable(FILE *fp,int spool,unsigned char **spoolbuf)
-{
- unsigned int length;
- int c1,c2;
-
- if ((c1 = php3_iptc_get1(fp,spool,spoolbuf)) == EOF) return M_EOI;
-
- if ((c2 = php3_iptc_get1(fp,spool,spoolbuf)) == EOF) return M_EOI;
-
- length = (((unsigned char) c1) << 8) + ((unsigned char) c2);
-
- length -= 2;
-
- while (length--)
- if (php3_iptc_get1(fp,spool,spoolbuf) == EOF) return M_EOI;
-
- return 0;
-}
-
-static int php3_iptc_nextmarker(FILE *fp,int spool,unsigned char **spoolbuf)
-{
- int c;
-
- /* skip unimportant stuff */
-
- c = php3_iptc_get1(fp,spool,spoolbuf);
-
- if (c == EOF) return M_EOI;
-
- while (c != 0xff) {
- if ((c = php3_iptc_get1(fp,spool,spoolbuf)) == EOF)
- return M_EOI; /* we hit EOF */
- }
-
- /* get marker byte, swallowing possible padding */
- do {
- c = php3_iptc_get1(fp,0,0);
- if (c == EOF)
- return M_EOI; /* we hit EOF */
- else
- if (c == 0xff)
- php3_iptc_put1(fp,spool,(unsigned char)c,spoolbuf);
- } while (c == 0xff);
-
- return (unsigned int) c;
-}
-
-static char psheader[] = "\xFF\xED\0\0Photoshop 3.0\08BIM\x04\x04\0\0\0\0";
-
-/* {{{ proto array iptcembed(string iptcdata, string jpeg_file_name [ , int spool ])
- Embed binary IPTC data into a JPEG image. */
-PHP_FUNCTION(iptcembed)
-{
- pval *iptcdata, *jpeg_file, *spool_flag;
- FILE *fp;
- unsigned int marker;
- unsigned int spool = 0, done = 0, inx, len;
- unsigned char *spoolbuf=0,*poi=0;
- struct stat sb;
-
- switch(ARG_COUNT(ht)){
- case 3:
- if (getParameters(ht, 3, &iptcdata, &jpeg_file, &spool_flag) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(iptcdata);
- convert_to_string(jpeg_file);
- convert_to_long(spool_flag);
- spool = spool_flag->value.lval;
- break;
-
- case 2:
- if (getParameters(ht, 2, &iptcdata, &jpeg_file) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(iptcdata);
- convert_to_string(jpeg_file);
- break;
-
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- if (_php3_check_open_basedir(jpeg_file->value.str.val))
- RETURN_FALSE;
-
- if ((fp = fopen(jpeg_file->value.str.val,"rb")) == 0) {
- php_error(E_WARNING, "Unable to open %s", jpeg_file->value.str.val);
- RETURN_FALSE;
- }
-
- if (spool > 0)
- if (!php3_header()){ /* we got a HEAD request. */
- if (spool == 2){
- RETURN_TRUE; /* we only wanted to spool - report success. */
- } else
- if (spool == 1) {
- spool = 0; /* we wanted the file to be spooled/returned, just return it */
- }
- }
-
- len = iptcdata->value.str.len;
-
- if (spool < 2) {
- fstat(fileno(fp),&sb);
-
- poi = spoolbuf = emalloc(len + 30 + sb.st_size);
-
- if (! spoolbuf) {
- fclose(fp);
- RETURN_FALSE;
- }
- }
-
- if (php3_iptc_get1(fp,spool,poi?&poi:0) != 0xFF) {
- fclose(fp);
- RETURN_FALSE;
- }
-
- if (php3_iptc_get1(fp,spool,poi?&poi:0) != 0xD8) {
- fclose(fp);
- RETURN_FALSE;
- }
-
- while (!done) {
- marker = php3_iptc_nextmarker(fp,spool,poi?&poi:0);
-
- if (marker == M_EOI) { /* EOF */
- break;
- } else if (marker != M_APP13) {
- php3_iptc_put1(fp,spool,(unsigned char)marker,poi?&poi:0);
- }
-
- switch (marker) {
- case M_APP13:
- /* we are going to write a new APP13 marker, so don't output the old one */
- php3_iptc_skip_variable(fp,0,0);
- php3_iptc_read_remaining(fp,spool,poi?&poi:0);
- done = 1;
- break;
-
- case M_APP0:
- /* APP0 is in each and every JPEG, so when we hit APP0 we insert our new APP13! */
- php3_iptc_skip_variable(fp,spool,poi?&poi:0);
-
- if (len & 1) len++; /* make the length even */
-
- psheader[ 2 ] = (len+28)>>8;
- psheader[ 3 ] = (len+28)&0xff;
-
- for (inx = 0; inx < 28; inx++)
- php3_iptc_put1(fp,spool,psheader[inx],poi?&poi:0);
-
- php3_iptc_put1(fp,spool,(unsigned char)(len>>8),poi?&poi:0);
- php3_iptc_put1(fp,spool,(unsigned char)(len&0xff),poi?&poi:0);
-
- for (inx = 0; inx < len; inx++)
- php3_iptc_put1(fp,spool,iptcdata->value.str.val[inx],poi?&poi:0);
- break;
-
- case M_SOS:
- /* we hit data, no more marker-inserting can be done! */
- php3_iptc_read_remaining(fp,spool,poi?&poi:0);
- done = 1;
- break;
-
- default:
- php3_iptc_skip_variable(fp,spool,poi?&poi:0);
- break;
- }
- }
-
- fclose(fp);
-
- if (spool < 2) {
- RETVAL_STRINGL(spoolbuf,poi - spoolbuf,0);
- } else {
- RETURN_TRUE;
- }
-}
-
-/* {{{ proto array iptcparse(string iptcdata)
- Parse binary IPTC-data into associative array. */
-PHP_FUNCTION(iptcparse)
-{
- unsigned int length, inx, len, inheader, tagsfound;
- unsigned char *buffer;
- unsigned char recnum, dataset;
- unsigned char key[ 16 ];
- pval *values, *str, **element;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str);
-
- inx = 0;
- length = str->value.str.len;
- buffer = str->value.str.val;
-
- inheader = 0; /* have we already found the IPTC-Header??? */
- tagsfound = 0; /* number of tags already found */
-
- while (inx < length) { /* find 1st tag */
- if ((buffer[inx] == 0x1c) && (buffer[inx+1] == 0x02)){
- break;
- } else {
- inx++;
- }
- }
-
- while (inx < length) {
- if (buffer[ inx++ ] != 0x1c) {
- break; /* we ran against some data which does not conform to IPTC - stop parsing! */
- }
-
- if ((inx + 4) >= length)
- break;
-
- dataset = buffer[ inx++ ];
- recnum = buffer[ inx++ ];
-
- if (buffer[ inx ] & (unsigned char) 0x80) { /* long tag */
- len = (((long) buffer[ inx + 2 ]) << 24) + (((long) buffer[ inx + 3 ]) << 16) +
- (((long) buffer[ inx + 4 ]) << 8) + (((long) buffer[ inx + 5 ]));
- inx += 6;
- } else { /* short tag */
- len = (((unsigned short) buffer[ inx ])<<8) | (unsigned short)buffer[ inx+1 ];
- inx += 2;
- }
-
- sprintf(key,"%d#%03d",(unsigned int) dataset,(unsigned int) recnum);
-
- if ((inx + len) > length)
- break;
-
- if (tagsfound == 0) { /* found the 1st tag - initialize the return array */
- if (array_init(return_value) == FAILURE) {
- php_error(E_ERROR, "Unable to initialize array");
- RETURN_FALSE;
- }
- }
-
- if (zend_hash_find(return_value->value.ht,key,strlen(key) + 1,(void **) &element) == FAILURE) {
- values = emalloc(sizeof(pval));
- INIT_PZVAL(values);
- if (array_init(values) == FAILURE) {
- php_error(E_ERROR, "Unable to initialize array");
- RETURN_FALSE;
- }
-
- zend_hash_update(return_value->value.ht, key, strlen(key)+1, (void *) &values, sizeof(pval*), (void **) &element);
- }
-
- add_next_index_stringl(*element,buffer+inx,len,1);
-
- inx += len;
-
- tagsfound++;
- }
-
- if (! tagsfound) {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/lcg.c b/ext/standard/lcg.c
deleted file mode 100644
index 8fe4950aa0..0000000000
--- a/ext/standard/lcg.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <ss@2ns.de> |
- +----------------------------------------------------------------------+
- */
-
-#include "php.h"
-#include "php_lcg.h"
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef ZTS
-int lcg_globals_id;
-#else
-static php_lcg_globals lcg_globals;
-#endif
-
-/*
- * combinedLCG() returns a pseudo random number in the range of (0,1).
- * The function combines two CGs with periods of
- * 2^31 - 85 and 2^31 - 249. The period of this function
- * is equal to the product of both primes.
- */
-
-#define MODMULT(a,b,c,m,s) q = s/a;s=b*(s-a*q)-c*q;if(s<0)s+=m
-
-double php_combined_lcg(void)
-{
- long q;
- long z;
- LCGLS_FETCH();
-
- MODMULT(53668,40014,12211,2147483563L, LCG(s1));
- MODMULT(52774,40692,3791, 2147483399L, LCG(s2));
-
- z = LCG(s1) - LCG(s2);
- if(z < 1) {
- z += 2147483562;
- }
-
- return z * 4.656613e-10;
-}
-
-static void init_globals(LCGLS_D)
-{
- LCG(s1) = 1;
-#ifdef ZTS
- LCG(s2) = (long) tsrm_thread_id();
-#else
- LCG(s2) = (long) getpid();
-#endif
-}
-
-static int php_minit_lcg(INIT_FUNC_ARGS)
-{
-#ifdef ZTS
- lcg_globals_id = ts_allocate_id(sizeof(php_lcg_globals), init_globals, NULL);
-#else
- init_globals();
-#endif
- return SUCCESS;
-}
-
-/* {{{ proto double lcg_value()
- returns a value from the combined linear congruential generator */
-PHP_FUNCTION(lcg_value)
-{
- RETURN_DOUBLE(php_combined_lcg());
-}
-/* }}} */
-
-static function_entry lcg_functions[] = {
- PHP_FE(lcg_value, NULL)
- {0}
-};
-
-zend_module_entry lcg_module_entry = {
- "LCG",
- lcg_functions,
- php_minit_lcg, NULL,
- NULL, NULL,
- NULL,
- STANDARD_MODULE_PROPERTIES
-};
diff --git a/ext/standard/link.c b/ext/standard/link.c
deleted file mode 100644
index 75e9bb297f..0000000000
--- a/ext/standard/link.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-#include "php3_filestat.h"
-#include "php_globals.h"
-
-#include <stdlib.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <sys/stat.h>
-#include <string.h>
-#if HAVE_PWD_H
-#if MSVC5
-#include "win32/pwd.h"
-#else
-#include <pwd.h>
-#endif
-#endif
-#if HAVE_GRP_H
-#if MSVC5
-#include "win32/grp.h"
-#else
-#include <grp.h>
-#endif
-#endif
-#include <errno.h>
-#include <ctype.h>
-
-#include "safe_mode.h"
-#include "php3_link.h"
-
-/* {{{ proto string readlink(string filename)
- Return the target of a symbolic link */
-PHP_FUNCTION(readlink)
-{
-#if HAVE_SYMLINK
- pval *filename;
- char buff[256];
- int ret;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &filename) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(filename);
-
- ret = readlink(filename->value.str.val, buff, 255);
- if (ret == -1) {
- php_error(E_WARNING, "readlink failed (%s)", strerror(errno));
- RETURN_FALSE;
- }
- /* Append NULL to the end of the string */
- buff[ret] = '\0';
- RETURN_STRING(buff,1);
-#endif
-}
-/* }}} */
-
-/* {{{ proto int linkinfo(string filename)
- Returns the st_dev field of the UNIX C stat structure describing the link */
-PHP_FUNCTION(linkinfo)
-{
-#if HAVE_SYMLINK
- pval *filename;
- struct stat sb;
- int ret;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &filename) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(filename);
-
- ret = lstat(filename->value.str.val, &sb);
- if (ret == -1) {
- php_error(E_WARNING, "LinkInfo failed (%s)", strerror(errno));
- RETURN_LONG(-1L);
- }
- RETURN_LONG((long) sb.st_dev);
-#endif
-}
-/* }}} */
-
-/* {{{ proto int symlink(string target, string link)
- Create a symbolic link */
-PHP_FUNCTION(symlink)
-{
-#if HAVE_SYMLINK
- pval *topath, *frompath;
- int ret;
- PLS_FETCH();
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &topath, &frompath) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(topath);
- convert_to_string(frompath);
-
- if (PG(safe_mode) && !_php3_checkuid(topath->value.str.val, 2)) {
- RETURN_FALSE;
- }
-
- ret = symlink(topath->value.str.val, frompath->value.str.val);
- if (ret == -1) {
- php_error(E_WARNING, "SymLink failed (%s)", strerror(errno));
- RETURN_FALSE;
- }
- RETURN_TRUE;
-#endif
-}
-/* }}} */
-
-/* {{{ proto int link(string target, string link)
- Create a hard link */
-PHP_FUNCTION(link)
-{
-#if HAVE_LINK
- pval *topath, *frompath;
- int ret;
- PLS_FETCH();
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &topath, &frompath) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(topath);
- convert_to_string(frompath);
-
- if (PG(safe_mode) && !_php3_checkuid(topath->value.str.val, 2)) {
- RETURN_FALSE;
- }
-
- ret = link(topath->value.str.val, frompath->value.str.val);
- if (ret == -1) {
- php_error(E_WARNING, "Link failed (%s)", strerror(errno));
- RETURN_FALSE;
- }
- RETURN_TRUE;
-#endif
-}
-/* }}} */
-
-/* {{{ proto int unlink(string filename)
- Delete a file */
-PHP_FUNCTION(unlink)
-{
- pval *filename;
- int ret;
- PLS_FETCH();
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &filename) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(filename);
-
- if (PG(safe_mode) && !_php3_checkuid(filename->value.str.val, 2)) {
- RETURN_FALSE;
- }
-
- ret = unlink(filename->value.str.val);
- if (ret == -1) {
- php_error(E_WARNING, "Unlink failed (%s)", strerror(errno));
- RETURN_FALSE;
- }
- /* Clear stat cache */
- php3_clearstatcache(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/mail.c b/ext/standard/mail.c
deleted file mode 100644
index 73ba38aa6c..0000000000
--- a/ext/standard/mail.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include <stdlib.h>
-#include <ctype.h>
-#include <stdio.h>
-#include "php.h"
-#ifndef MSVC5
-#include "build-defs.h"
-#endif
-#include "php3_mail.h"
-#include "php_ini.h"
-
-#if APACHE
-# ifndef DEBUG
-# undef palloc
-# endif
-#endif
-
-#if HAVE_SENDMAIL
-#if MSVC5
-#include "win32/sendmail.h"
-#endif
-
-function_entry mail_functions[] = {
- PHP_FE(mail, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry mail_module_entry = {
- "Sendmail", mail_functions, NULL, NULL, NULL, NULL, PHP_MINFO(mail), STANDARD_MODULE_PROPERTIES
-};
-
-
-#if COMPILE_DL
-DLEXPORT php3_module_entry *get_module(void) { return &odbc_module_entry; }
-#endif
-
-/* {{{ proto int mail(string to, string subject, string message [, string additional_headers])
- Send an email message */
-PHP_FUNCTION(mail)
-{
- pval *argv[4];
- char *to=NULL, *message=NULL, *headers=NULL, *subject=NULL;
- int argc;
-
- argc = ARG_COUNT(ht);
- if (argc < 3 || argc > 4 || getParametersArray(ht, argc, argv) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- /* To: */
- convert_to_string(argv[0]);
- if (argv[0]->value.str.val) {
- to = argv[0]->value.str.val;
- } else {
- php_error(E_WARNING, "No to field in mail command");
- RETURN_FALSE;
- }
-
- /* Subject: */
- convert_to_string(argv[1]);
- if (argv[1]->value.str.val) {
- subject = argv[1]->value.str.val;
- } else {
- php_error(E_WARNING, "No subject field in mail command");
- RETURN_FALSE;
- }
-
- /* message body */
- convert_to_string(argv[2]);
- if (argv[2]->value.str.val) {
- message = argv[2]->value.str.val;
- } else {
- /* this is not really an error, so it is allowed. */
- php_error(E_WARNING, "No message string in mail command");
- message = NULL;
- }
-
- if (argc == 4) { /* other headers */
- convert_to_string(argv[3]);
- headers = argv[3]->value.str.val;
- }
-
- if (_php3_mail(to, subject, message, headers)){
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-int _php3_mail(char *to, char *subject, char *message, char *headers)
-{
-#if MSVC5
- int tsm_err;
-#else
- FILE *sendmail;
- int ret;
- char *sendmail_path = INI_STR("sendmail_path");
-#endif
-
-#if MSVC5
- if (TSendMail(INI_STR("SMTP"), &tsm_err, headers, subject, to, message) != SUCCESS){
- php_error(E_WARNING, GetSMErrorText(tsm_err));
- return 0;
- }
-#else
- if (!sendmail_path) {
- return 0;
- }
- sendmail = popen(sendmail_path, "w");
-
- if (sendmail) {
- fprintf(sendmail, "To: %s\n", to);
- fprintf(sendmail, "Subject: %s\n", subject);
- if (headers != NULL) {
- fprintf(sendmail, "%s\n", headers);
- }
- fprintf(sendmail, "\n%s\n", message);
- ret = pclose(sendmail);
- if (ret == -1) {
- return 0;
- } else {
- return 1;
- }
- } else {
- php_error(E_WARNING, "Could not execute mail delivery program");
- return 0;
- }
-#endif
- return 1;
-}
-
-PHP_MINFO_FUNCTION(mail)
-{
-#if MSVC5
- PUTS("Internal Sendmail support for Windows 4");
-#else
- php_printf("Path to sendmail: <tt>%s</tt>", INI_STR("sendmail_path"));
-#endif
-}
-
-#else
-
-PHP_FUNCTION(mail) {}
-PHP_MINFO_FUNCTION(mail) {}
-
-#endif
-
-
-/*
- * Local variables:
- * tab-width: 4
- * End:
- */
diff --git a/ext/standard/math.c b/ext/standard/math.c
deleted file mode 100644
index 2febcaeffd..0000000000
--- a/ext/standard/math.c
+++ /dev/null
@@ -1,700 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Jim Winstead (jimw@php.net) |
- | Stig Sæther Bakken <ssb@guardian.no> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-#include "php.h"
-#include "phpmath.h"
-#include "snprintf.h"
-
-#include <math.h>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-char *_php3_number_format(double, int, char ,char);
-
-/* {{{ proto int abs(int number)
- Return the absolute value of the number */
-PHP_FUNCTION(abs) {
- pval *value;
-
- if (ARG_COUNT(ht)!=1||getParameters(ht,1,&value)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (value->type == IS_STRING) {
- convert_scalar_to_number(value);
- }
-
- if (value->type == IS_DOUBLE) {
- RETURN_DOUBLE(fabs(value->value.dval));
- }
- else if (value->type == IS_LONG) {
- RETURN_LONG(labs(value->value.lval));
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto int ceil(double number)
- Returns the next highest integer value of the number */
-PHP_FUNCTION(ceil) {
- pval *value;
-
- if (ARG_COUNT(ht)!=1||getParameters(ht,1,&value)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (value->type == IS_STRING) {
- convert_scalar_to_number(value);
- }
-
- if (value->type == IS_DOUBLE) {
- RETURN_LONG((long)ceil(value->value.dval));
- }
- else if (value->type == IS_LONG) {
- RETURN_LONG(value->value.lval);
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto int floor(double number)
- Returns the next lowest integer value from the number */
-PHP_FUNCTION(floor) {
- pval *value;
-
- if (ARG_COUNT(ht)!=1||getParameters(ht,1,&value)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (value->type == IS_STRING) {
- convert_scalar_to_number(value);
- }
-
- if (value->type == IS_DOUBLE) {
- RETURN_LONG((long)floor(value->value.dval));
- }
- else if (value->type == IS_LONG) {
- RETURN_LONG(value->value.lval);
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-#ifndef HAVE_RINT
-/* emulate rint */
-inline double rint(double n)
-{
- double i, f;
- f = modf(n, &i);
- if (f > .5)
- i++;
- else if (f < -.5)
- i--;
- return i;
-}
-#endif
-
-/* {{{ proto int round(double number)
- Returns the rounded value of the number */
-PHP_FUNCTION(round)
-{
- pval *value;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &value) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- if (value->type == IS_STRING) {
- convert_scalar_to_number(value);
- }
- if (value->type == IS_DOUBLE) {
- RETURN_DOUBLE(rint(value->value.dval));
- }
- if (value->type == IS_LONG) {
- RETURN_DOUBLE((double)value->value.lval);
- }
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto double sin(double number)
- Returns the sine of the number in radians */
-PHP_FUNCTION(sin)
-{
- pval *num;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_double(num);
- return_value->value.dval = sin(num->value.dval);
- return_value->type = IS_DOUBLE;
-}
-/* }}} */
-
-/* {{{ proto double cos(double number)
- Returns the cosine of the number in radians */
-PHP_FUNCTION(cos)
-{
- pval *num;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_double(num);
- return_value->value.dval = cos(num->value.dval);
- return_value->type = IS_DOUBLE;
-}
-/* }}} */
-
-/* {{{ proto double tan(double number)
- Returns the tangent of the number in radians */
-PHP_FUNCTION(tan)
-{
- pval *num;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_double(num);
- return_value->value.dval = tan(num->value.dval);
- return_value->type = IS_DOUBLE;
-}
-/* }}} */
-
-/* {{{ proto double asin(double number)
- Returns the arc sine of the number in radians */
-PHP_FUNCTION(asin)
-{
- pval *num;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_double(num);
- return_value->value.dval = asin(num->value.dval);
- return_value->type = IS_DOUBLE;
-}
-/* }}} */
-
-/* {{{ proto double acos(double number)
- Return the arc cosine of the number in radians */
-PHP_FUNCTION(acos)
-{
- pval *num;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_double(num);
- return_value->value.dval = acos(num->value.dval);
- return_value->type = IS_DOUBLE;
-}
-/* }}} */
-
-/* {{{ proto double atan(double number)
- Returns the arc tangent of the number in radians */
-PHP_FUNCTION(atan)
-{
- pval *num;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_double(num);
- return_value->value.dval = atan(num->value.dval);
- return_value->type = IS_DOUBLE;
-}
-/* }}} */
-
-/* {{{ proto double atan2(double y, double x)
- Returns the arc tangent of y/x, with the resulting quadrant determined by the signs of y and x */
-PHP_FUNCTION(atan2)
-{
- pval *num1, *num2;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &num1, &num2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_double(num1);
- convert_to_double(num2);
- return_value->value.dval = atan2(num1->value.dval,num2->value.dval);
- return_value->type = IS_DOUBLE;
-}
-/* }}} */
-
-/* {{{ proto double pi(void)
- Returns an approximation of pi */
-PHP_FUNCTION(pi)
-{
- return_value->value.dval = M_PI;
- return_value->type = IS_DOUBLE;
-}
-/* }}} */
-
-/* {{{ proto double pow(double base, double exponent)
- Returns base raised to the power of expopent */
-PHP_FUNCTION(pow)
-{
- pval *num1, *num2;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&num1,&num2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_double(num1);
- convert_to_double(num2);
- RETURN_DOUBLE(pow(num1->value.dval, num2->value.dval));
-}
-/* }}} */
-
-/* {{{ proto double exp(double number)
- Returns e raised to the power of the number */
-PHP_FUNCTION(exp)
-{
- pval *num;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_double(num);
- return_value->value.dval = exp(num->value.dval);
- return_value->type = IS_DOUBLE;
-}
-/* }}} */
-
-/* {{{ proto double log(double number)
- Returns the natural logarithm of the number */
-PHP_FUNCTION(log)
-{
- pval *num;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_double(num);
- return_value->value.dval = log(num->value.dval);
- return_value->type = IS_DOUBLE;
-}
-/* }}} */
-
-/* {{{ proto double log10(double number)
- Returns the base-10 logarithm of the number */
-PHP_FUNCTION(log10)
-{
- pval *num;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_double(num);
- return_value->value.dval = log10(num->value.dval);
- return_value->type = IS_DOUBLE;
-}
-/* }}} */
-
-/* {{{ proto double sqrt(double number)
- Returns the square root of the number */
-PHP_FUNCTION(sqrt)
-{
- pval *num;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_double(num);
- return_value->value.dval = sqrt(num->value.dval);
- return_value->type = IS_DOUBLE;
-}
-/* }}} */
-
-/* {{{ proto double deg2rad(double number)
- Converts the number in degrees to the radian equivalent */
-PHP_FUNCTION(deg2rad)
-{
- pval *deg;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &deg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_double(deg);
- RETVAL_DOUBLE((deg->value.dval / 180.0) * M_PI);
-}
-/* }}} */
-
-/* {{{ proto double rad2deg(double number)
- Converts the radian number to the equivalent number in degrees */
-PHP_FUNCTION(rad2deg)
-{
- pval *rad;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &rad) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_double(rad);
- RETVAL_DOUBLE((rad->value.dval / M_PI) * 180);
-}
-/* }}} */
-
-
-/*
- * Convert a string representation of a base(2-36) number to a long.
- */
-static long
-_php3_basetolong(pval *arg, int base) {
- long mult = 1, num = 0, digit;
- int i;
- char c, *s;
-
- if (arg->type != IS_STRING || base < 2 || base > 36) {
- return 0;
- }
-
- s = arg->value.str.val;
-
- for (i = arg->value.str.len - 1; i >= 0; i--, mult *= base) {
- c = toupper(s[i]);
- if (c >= '0' && c <= '9') {
- digit = (c - '0');
- } else if (c >= 'A' && c <= 'Z') {
- digit = (c - 'A' + 10);
- } else {
- continue;
- }
- if (digit >= base) {
- continue;
- }
- num += mult * digit;
- }
-
- return num;
-}
-
-
-/*
- * Convert a long to a string containing a base(2-36) representation of
- * the number.
- */
-static char *
-_php3_longtobase(pval *arg, int base)
-{
- static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
- char *result, *ptr, *ret;
- int len, digit;
- long value;
-
- if (arg->type != IS_LONG || base < 2 || base > 36) {
- return empty_string;
- }
-
- value = arg->value.lval;
-
- /* allocates space for the longest possible result with the lowest base */
- len = (sizeof(arg->value.lval) * 8) + 1;
- result = emalloc((sizeof(arg->value.lval) * 8) + 1);
-
- ptr = result + len - 1;
- *ptr-- = '\0';
-
- do {
- digit = value % base;
- *ptr = digits[digit];
- value /= base;
- }
- while (ptr-- > result && value);
- ptr++;
- ret = estrdup(ptr);
- efree(result);
-
- return ret;
-}
-
-/* {{{ proto int bindec(string binary_number)
- Returns the decimal equivalent of the binary number */
-PHP_FUNCTION(bindec)
-{
- pval *arg;
- long ret;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(arg);
- ret = _php3_basetolong(arg, 2);
-
- RETVAL_LONG(ret);
-}
-/* }}} */
-
-/* {{{ proto int hexdec(string hexadimal_number)
- Returns the decimal equivalent of the hexadecimal number */
-PHP_FUNCTION(hexdec)
-{
- pval *arg;
- long ret;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(arg);
-
- ret = _php3_basetolong(arg, 16);
- RETVAL_LONG(ret);
-}
-/* }}} */
-
-/* {{{ proto int octdec(string octal_number)
- Returns the decimal equivalent of an octal string */
-PHP_FUNCTION(octdec)
-{
- pval *arg;
- long ret;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(arg);
-
- ret = _php3_basetolong(arg, 8);
- RETVAL_LONG(ret);
-}
-/* }}} */
-
-/* {{{ proto string decbin(int decimal_number)
- Returns a string containing a binary representation of the number */
-PHP_FUNCTION(decbin)
-{
- pval *arg;
- char *result;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg);
-
- result = _php3_longtobase(arg, 2);
- return_value->type = IS_STRING;
- return_value->value.str.len = strlen(result);
- return_value->value.str.val = result;
-}
-/* }}} */
-
-/* {{{ proto string decoct(int decimal_number)
- Returns a string containing an octal representation of the given number */
-PHP_FUNCTION(decoct)
-{
- pval *arg;
- char *result;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg);
-
- result = _php3_longtobase(arg, 8);
- return_value->type = IS_STRING;
- return_value->value.str.len = strlen(result);
- return_value->value.str.val = result;
-}
-/* }}} */
-
-/* {{{ proto string dechex(int decimal_number)
- Returns a string containing a hexadecimal representation of the given number */
-PHP_FUNCTION(dechex)
-{
- pval *arg;
- char *result;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg);
-
- result = _php3_longtobase(arg, 16);
- return_value->type = IS_STRING;
- return_value->value.str.len = strlen(result);
- return_value->value.str.val = result;
-}
-/* }}} */
-
-
-/* {{{ proto string base_convert(string number, int frombase, int tobase)
- Converts a number in a string from any base <= 36 to any base <= 36.
-*/
-PHP_FUNCTION(base_convert)
-{
- pval *number, *frombase, *tobase, temp;
- char *result;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &number, &frombase, &tobase)
- == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(number);
- convert_to_long(frombase);
- convert_to_long(tobase);
- if (frombase->value.lval < 2 || frombase->value.lval > 36) {
- php_error(E_WARNING, "base_convert: invalid `from base' (%d)",
- frombase->value.lval);
- RETURN_FALSE;
- }
- if (tobase->value.lval < 2 || tobase->value.lval > 36) {
- php_error(E_WARNING, "base_convert: invalid `to base' (%d)",
- tobase->value.lval);
- RETURN_FALSE;
- }
- temp.type = IS_LONG;
- temp.value.lval = _php3_basetolong(number, frombase->value.lval);
- result = _php3_longtobase(&temp, tobase->value.lval);
- RETVAL_STRING(result, 0);
-} /* }}} */
-
-
-char *_php3_number_format(double d,int dec,char dec_point,char thousand_sep)
-{
- char *tmpbuf,*resbuf;
- char *s,*t; /* source, target */
- int tmplen,reslen=0;
- int count=0;
- int is_negative=0;
-
- if (d<0) {
- is_negative=1;
- d = -d;
- }
- dec = MAX(0,dec);
- tmpbuf = (char *) emalloc(32+dec);
-
- tmplen=php_sprintf(tmpbuf,"%.*f",dec,d);
-
- if (!isdigit((int)tmpbuf[0])) {
- return tmpbuf;
- }
-
- for (t=tmpbuf; *t; t++) {
- if (*t=='.') {
- *t = dec_point;
- }
- }
- if (dec) {
- reslen = dec+1 + (tmplen-dec-1) + (tmplen-1-dec-1)/3;
- } else {
- reslen = tmplen+(tmplen-1)/3;
- }
- if (is_negative) {
- reslen++;
- }
- resbuf = (char *) emalloc(reslen+1);
-
- s = tmpbuf+tmplen-1;
- t = resbuf+reslen;
- *t-- = 0;
-
- if (dec) {
- while (*s!=dec_point) {
- *t-- = *s--;
- }
- *t-- = *s--; /* copy that dot */
- }
-
- while(s>=tmpbuf) {
- *t-- = *s--;
- if ((++count%3)==0 && s>=tmpbuf) {
- *t-- = thousand_sep;
- }
- }
- if (is_negative) {
- *t-- = '-';
- }
- efree(tmpbuf);
- return resbuf;
-}
-
-/* {{{ proto string number_format(double number, [,int num_decimal_places [, string dec_seperator, string thousands_seperator)]])
- Formats a number with grouped thousands */
-PHP_FUNCTION(number_format)
-{
- pval *num,*dec,*t_s,*d_p;
- char thousand_sep=',', dec_point='.';
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &num)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_double(num);
- RETURN_STRING(_php3_number_format(num->value.dval,0,dec_point,thousand_sep),0);
- break;
- case 2:
- if (getParameters(ht, 2, &num, &dec)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_double(num);
- convert_to_long(dec);
- RETURN_STRING(_php3_number_format(num->value.dval,dec->value.lval,dec_point,thousand_sep),0);
- break;
- case 4:
- if (getParameters(ht, 4, &num, &dec, &d_p, &t_s)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_double(num);
- convert_to_long(dec);
- convert_to_string(d_p);
- convert_to_string(t_s);
- if (d_p->value.str.len==1) {
- dec_point=d_p->value.str.val[0];
- }
- if (t_s->value.str.len==1) {
- thousand_sep=t_s->value.str.val[0];
- }
- RETURN_STRING(_php3_number_format(num->value.dval,dec->value.lval,dec_point,thousand_sep),0);
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-}
-/* }}} */
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/md5.c b/ext/standard/md5.c
deleted file mode 100644
index e26c010e45..0000000000
--- a/ext/standard/md5.c
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Lachlan Roche |
- +----------------------------------------------------------------------+
- */
-
-/*
- * md5.c - Copyright 1997 Lachlan Roche
- */
-
-#include <stdio.h>
-#include "php.h"
-
-#include "md5.h"
-
-/* {{{ proto string md5(string str)
- Calculate the md5 hash of a string */
-PHP_FUNCTION(md5)
-{
- pval *arg;
- char md5str[33];
- PHP3_MD5_CTX context;
- unsigned char digest[16];
- int i;
- char *r;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
-
- md5str[0] = '\0';
- PHP3_MD5Init(&context);
- PHP3_MD5Update(&context, arg->value.str.val, arg->value.str.len);
- PHP3_MD5Final(digest, &context);
- for (i = 0, r = md5str; i < 16; i++, r += 2) {
- sprintf(r, "%02x", digest[i]);
- }
- *r = '\0';
- RETVAL_STRING(md5str,1);
-}
-/* }}} */
-
-/*
- * The remaining code is the reference MD5 code (md5c.c) from rfc1321
- */
-/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
- */
-
-/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
- rights reserved.
-
- License to copy and use this software is granted provided that it
- is identified as the "RSA Data Security, Inc. MD5 Message-Digest
- Algorithm" in all material mentioning or referencing this software
- or this function.
-
- License is also granted to make and use derivative works provided
- that such works are identified as "derived from the RSA Data
- Security, Inc. MD5 Message-Digest Algorithm" in all material
- mentioning or referencing the derived work.
-
- RSA Data Security, Inc. makes no representations concerning either
- the merchantability of this software or the suitability of this
- software for any particular purpose. It is provided "as is"
- without express or implied warranty of any kind.
-
- These notices must be retained in any copies of any part of this
- documentation and/or software.
- */
-
-/* Constants for MD5Transform routine.
- */
-
-
-#define S11 7
-#define S12 12
-#define S13 17
-#define S14 22
-#define S21 5
-#define S22 9
-#define S23 14
-#define S24 20
-#define S31 4
-#define S32 11
-#define S33 16
-#define S34 23
-#define S41 6
-#define S42 10
-#define S43 15
-#define S44 21
-
-static void MD5Transform PROTO_LIST((UINT4[4], const unsigned char[64]));
-static void Encode PROTO_LIST
- ((unsigned char *, UINT4 *, unsigned int));
-static void Decode PROTO_LIST
- ((UINT4 *, const unsigned char *, unsigned int));
-static void MD5_memcpy PROTO_LIST((_POINTER, _POINTER, unsigned int));
-static void MD5_memset PROTO_LIST((_POINTER, int, unsigned int));
-
-static unsigned char PADDING[64] =
-{
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-/* F, G, H and I are basic MD5 functions.
- */
-#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
-#define H(x, y, z) ((x) ^ (y) ^ (z))
-#define I(x, y, z) ((y) ^ ((x) | (~z)))
-
-/* ROTATE_LEFT rotates x left n bits.
- */
-#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
-
-/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
- Rotation is separate from addition to prevent recomputation.
- */
-#define FF(a, b, c, d, x, s, ac) { \
- (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define GG(a, b, c, d, x, s, ac) { \
- (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define HH(a, b, c, d, x, s, ac) { \
- (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define II(a, b, c, d, x, s, ac) { \
- (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-
-/* MD5 initialization. Begins an MD5 operation, writing a new context.
- */
-void PHP3_MD5Init(PHP3_MD5_CTX * context)
-{
- context->count[0] = context->count[1] = 0;
- /* Load magic initialization constants.
- */
- context->state[0] = 0x67452301;
- context->state[1] = 0xefcdab89;
- context->state[2] = 0x98badcfe;
- context->state[3] = 0x10325476;
-}
-
-/* MD5 block update operation. Continues an MD5 message-digest
- operation, processing another message block, and updating the
- context.
- */
-void PHP3_MD5Update(PHP3_MD5_CTX * context, const unsigned char *input,
- unsigned int inputLen)
-{
- unsigned int i, index, partLen;
-
- /* Compute number of bytes mod 64 */
- index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
-
- /* Update number of bits */
- if ((context->count[0] += ((UINT4) inputLen << 3))
- < ((UINT4) inputLen << 3))
- context->count[1]++;
- context->count[1] += ((UINT4) inputLen >> 29);
-
- partLen = 64 - index;
-
- /* Transform as many times as possible.
- */
- if (inputLen >= partLen) {
- MD5_memcpy
- ((_POINTER) & context->buffer[index], (_POINTER) input, partLen);
- MD5Transform(context->state, context->buffer);
-
- for (i = partLen; i + 63 < inputLen; i += 64)
- MD5Transform(context->state, &input[i]);
-
- index = 0;
- } else
- i = 0;
-
- /* Buffer remaining input */
- MD5_memcpy
- ((_POINTER) & context->buffer[index], (_POINTER) & input[i],
- inputLen - i);
-}
-
-/* MD5 finalization. Ends an MD5 message-digest operation, writing the
- the message digest and zeroizing the context.
- */
-void PHP3_MD5Final(unsigned char digest[16], PHP3_MD5_CTX * context)
-{
- unsigned char bits[8];
- unsigned int index, padLen;
-
- /* Save number of bits */
- Encode(bits, context->count, 8);
-
- /* Pad out to 56 mod 64.
- */
- index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
- padLen = (index < 56) ? (56 - index) : (120 - index);
- PHP3_MD5Update(context, PADDING, padLen);
-
- /* Append length (before padding) */
- PHP3_MD5Update(context, bits, 8);
-
- /* Store state in digest */
- Encode(digest, context->state, 16);
-
- /* Zeroize sensitive information.
- */
- MD5_memset((_POINTER) context, 0, sizeof(*context));
-}
-
-/* MD5 basic transformation. Transforms state based on block.
- */
-static void MD5Transform(state, block)
-UINT4 state[4];
-const unsigned char block[64];
-{
- UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
-
- Decode(x, block, 64);
-
- /* Round 1 */
- FF(a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */
- FF(d, a, b, c, x[1], S12, 0xe8c7b756); /* 2 */
- FF(c, d, a, b, x[2], S13, 0x242070db); /* 3 */
- FF(b, c, d, a, x[3], S14, 0xc1bdceee); /* 4 */
- FF(a, b, c, d, x[4], S11, 0xf57c0faf); /* 5 */
- FF(d, a, b, c, x[5], S12, 0x4787c62a); /* 6 */
- FF(c, d, a, b, x[6], S13, 0xa8304613); /* 7 */
- FF(b, c, d, a, x[7], S14, 0xfd469501); /* 8 */
- FF(a, b, c, d, x[8], S11, 0x698098d8); /* 9 */
- FF(d, a, b, c, x[9], S12, 0x8b44f7af); /* 10 */
- FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
- FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
- FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
- FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
- FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
- FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
-
- /* Round 2 */
- GG(a, b, c, d, x[1], S21, 0xf61e2562); /* 17 */
- GG(d, a, b, c, x[6], S22, 0xc040b340); /* 18 */
- GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
- GG(b, c, d, a, x[0], S24, 0xe9b6c7aa); /* 20 */
- GG(a, b, c, d, x[5], S21, 0xd62f105d); /* 21 */
- GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */
- GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
- GG(b, c, d, a, x[4], S24, 0xe7d3fbc8); /* 24 */
- GG(a, b, c, d, x[9], S21, 0x21e1cde6); /* 25 */
- GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
- GG(c, d, a, b, x[3], S23, 0xf4d50d87); /* 27 */
- GG(b, c, d, a, x[8], S24, 0x455a14ed); /* 28 */
- GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
- GG(d, a, b, c, x[2], S22, 0xfcefa3f8); /* 30 */
- GG(c, d, a, b, x[7], S23, 0x676f02d9); /* 31 */
- GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
-
- /* Round 3 */
- HH(a, b, c, d, x[5], S31, 0xfffa3942); /* 33 */
- HH(d, a, b, c, x[8], S32, 0x8771f681); /* 34 */
- HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
- HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
- HH(a, b, c, d, x[1], S31, 0xa4beea44); /* 37 */
- HH(d, a, b, c, x[4], S32, 0x4bdecfa9); /* 38 */
- HH(c, d, a, b, x[7], S33, 0xf6bb4b60); /* 39 */
- HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
- HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
- HH(d, a, b, c, x[0], S32, 0xeaa127fa); /* 42 */
- HH(c, d, a, b, x[3], S33, 0xd4ef3085); /* 43 */
- HH(b, c, d, a, x[6], S34, 0x4881d05); /* 44 */
- HH(a, b, c, d, x[9], S31, 0xd9d4d039); /* 45 */
- HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
- HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
- HH(b, c, d, a, x[2], S34, 0xc4ac5665); /* 48 */
-
- /* Round 4 */
- II(a, b, c, d, x[0], S41, 0xf4292244); /* 49 */
- II(d, a, b, c, x[7], S42, 0x432aff97); /* 50 */
- II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
- II(b, c, d, a, x[5], S44, 0xfc93a039); /* 52 */
- II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
- II(d, a, b, c, x[3], S42, 0x8f0ccc92); /* 54 */
- II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
- II(b, c, d, a, x[1], S44, 0x85845dd1); /* 56 */
- II(a, b, c, d, x[8], S41, 0x6fa87e4f); /* 57 */
- II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
- II(c, d, a, b, x[6], S43, 0xa3014314); /* 59 */
- II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
- II(a, b, c, d, x[4], S41, 0xf7537e82); /* 61 */
- II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
- II(c, d, a, b, x[2], S43, 0x2ad7d2bb); /* 63 */
- II(b, c, d, a, x[9], S44, 0xeb86d391); /* 64 */
-
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
-
- /* Zeroize sensitive information. */
- MD5_memset((_POINTER) x, 0, sizeof(x));
-}
-
-/* Encodes input (UINT4) into output (unsigned char). Assumes len is
- a multiple of 4.
- */
-static void Encode(output, input, len)
-unsigned char *output;
-UINT4 *input;
-unsigned int len;
-{
- unsigned int i, j;
-
- for (i = 0, j = 0; j < len; i++, j += 4) {
- output[j] = (unsigned char) (input[i] & 0xff);
- output[j + 1] = (unsigned char) ((input[i] >> 8) & 0xff);
- output[j + 2] = (unsigned char) ((input[i] >> 16) & 0xff);
- output[j + 3] = (unsigned char) ((input[i] >> 24) & 0xff);
- }
-}
-
-/* Decodes input (unsigned char) into output (UINT4). Assumes len is
- a multiple of 4.
- */
-static void Decode(output, input, len)
-UINT4 *output;
-const unsigned char *input;
-unsigned int len;
-{
- unsigned int i, j;
-
- for (i = 0, j = 0; j < len; i++, j += 4)
- output[i] = ((UINT4) input[j]) | (((UINT4) input[j + 1]) << 8) |
- (((UINT4) input[j + 2]) << 16) | (((UINT4) input[j + 3]) << 24);
-}
-
-/* Note: Replace "for loop" with standard memcpy if possible.
- */
-
-static void MD5_memcpy(output, input, len)
-_POINTER output;
-_POINTER input;
-unsigned int len;
-{
- unsigned int i;
-
- for (i = 0; i < len; i++)
- output[i] = input[i];
-}
-
-/* Note: Replace "for loop" with standard memset if possible.
- */
-static void MD5_memset(output, value, len)
-_POINTER output;
-int value;
-unsigned int len;
-{
- unsigned int i;
-
- for (i = 0; i < len; i++)
- ((char *) output)[i] = (char) value;
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/md5.h b/ext/standard/md5.h
deleted file mode 100644
index 47ce03682e..0000000000
--- a/ext/standard/md5.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-#ifndef _md5_h
-#define _md5_h
-/* MD5.H - header file for MD5C.C
- */
-
-/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
- rights reserved.
-
- License to copy and use this software is granted provided that it
- is identified as the "RSA Data Security, Inc. MD5 Message-Digest
- Algorithm" in all material mentioning or referencing this software
- or this function.
-
- License is also granted to make and use derivative works provided
- that such works are identified as "derived from the RSA Data
- Security, Inc. MD5 Message-Digest Algorithm" in all material
- mentioning or referencing the derived work.
-
- RSA Data Security, Inc. makes no representations concerning either
- the merchantability of this software or the suitability of this
- software for any particular purpose. It is provided "as is"
- without express or implied warranty of any kind.
-
- These notices must be retained in any copies of any part of this
- documentation and/or software.
- */
-
-#include "global.h"
-
-/* MD5 context. */
-typedef struct {
- UINT4 state[4]; /* state (ABCD) */
- UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
- unsigned char buffer[64]; /* input buffer */
-} PHP3_MD5_CTX;
-
-void PHP3_MD5Init PROTO_LIST((PHP3_MD5_CTX *));
-void PHP3_MD5Update PROTO_LIST((PHP3_MD5_CTX *, const unsigned char *, unsigned int));
-void PHP3_MD5Final PROTO_LIST((unsigned char[16], PHP3_MD5_CTX *));
-
-PHP_FUNCTION(md5);
-
-#endif
diff --git a/ext/standard/metaphone.c b/ext/standard/metaphone.c
deleted file mode 100644
index 7c6832ef5d..0000000000
--- a/ext/standard/metaphone.c
+++ /dev/null
@@ -1,475 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Thies C. Arntzen <thies@digicol.de> |
- +----------------------------------------------------------------------+
-*/
-/*
- Based on CPANs "Text-Metaphone-1.96" by Michael G Schwern <schwern@pobox.com>
-*/
-
-#include "php.h"
-#include "php_metaphone.h"
-
-static int metaphone(char *word, int max_phonemes, char **phoned_word, int traditional);
-
-PHP_FUNCTION(metaphone);
-
-function_entry metaphone_functions[] =
-{
- PHP_FE(metaphone, NULL)
- {0},
-};
-
-zend_module_entry metaphone_module_entry =
-{
- "Metaphone",
- metaphone_functions,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- STANDARD_MODULE_PROPERTIES,
-};
-
-/* metaphone -- Breaks english phrases down into their phonemes. */
-PHP_FUNCTION(metaphone)
-{
- pval *pstr, *pphones;
- char *result = 0;
- int phones = 0;
-
- if (getParameters(ht, 2, &pstr, &pphones) == SUCCESS) {
- convert_to_long(pphones);
- phones = pphones->value.lval;
- } else if (getParameters(ht, 1, &pstr) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(pstr);
-
- if (metaphone(pstr->value.str.val, phones, &result, 1) == 0) {
- RETVAL_STRING(result, 0);
- } else {
- if (result) {
- efree(result);
- }
- RETURN_FALSE;
- }
-}
-
-/*
- this is now the original code by Michael G Schwern:
- i've changed it just a slightly bit (use emalloc,
- get rid of includes etc)
- - thies - 13.09.1999
-*/
-
-/*----------------------------- */
-/* this used to be "metaphone.h" */
-/*----------------------------- */
-
-/* Special encodings */
-#define SH 'X'
-#define TH '0'
-
-/*----------------------------- */
-/* end of "metaphone.h" */
-/*----------------------------- */
-
-/*----------------------------- */
-/* this used to be "metachar.h" */
-/*----------------------------- */
-
-/* Metachar.h ... little bits about characters for metaphone */
-/*-- Character encoding array & accessing macros --*/
-/* Stolen directly out of the book... */
-char _codes[26] =
-{
- 1, 16, 4, 16, 9, 2, 4, 16, 9, 2, 0, 2, 2, 2, 1, 4, 0, 2, 4, 4, 1, 0, 0, 0, 8, 0
-/* a b c d e f g h i j k l m n o p q r s t u v w x y z */
-};
-
-
-#define ENCODE(c) (isalpha(c) ? _codes[((toupper(c)) - 'A')] : 0)
-
-#define isvowel(c) (ENCODE(c) & 1) /* AEIOU */
-
-/* These letters are passed through unchanged */
-#define NOCHANGE(c) (ENCODE(c) & 2) /* FJMNR */
-
-/* These form dipthongs when preceding H */
-#define AFFECTH(c) (ENCODE(c) & 4) /* CGPST */
-
-/* These make C and G soft */
-#define MAKESOFT(c) (ENCODE(c) & 8) /* EIY */
-
-/* These prevent GH from becoming F */
-#define NOGHTOF(c) (ENCODE(c) & 16) /* BDH */
-
-/*----------------------------- */
-/* end of "metachar.h" */
-/*----------------------------- */
-
-/* I suppose I could have been using a character pointer instead of
- * accesssing the array directly... */
-
-/* Look at the next letter in the word */
-#define Next_Letter (toupper(word[w_idx+1]))
-/* Look at the current letter in the word */
-#define Curr_Letter (toupper(word[w_idx]))
-/* Go N letters back. */
-#define Look_Back_Letter(n) (w_idx >= n ? toupper(word[w_idx-n]) : '\0')
-/* Previous letter. I dunno, should this return null on failure? */
-#define Prev_Letter (Look_Back_Letter(1))
-/* Look two letters down. It makes sure you don't walk off the string. */
-#define After_Next_Letter (Next_Letter != '\0' ? toupper(word[w_idx+2]) \
- : '\0')
-#define Look_Ahead_Letter(n) (toupper(Lookahead(word+w_idx, n)))
-
-
-/* Allows us to safely look ahead an arbitrary # of letters */
-/* I probably could have just used strlen... */
-char Lookahead(char *word, int how_far)
-{
- char letter_ahead = '\0'; /* null by default */
- int idx;
- for (idx = 0; word[idx] != '\0' && idx < how_far; idx++);
- /* Edge forward in the string... */
-
- letter_ahead = word[idx]; /* idx will be either == to how_far or
- * at the end of the string
- */
- return letter_ahead;
-}
-
-
-/* phonize one letter */
-#define Phonize(c) {(*phoned_word)[p_idx++] = c;}
-/* Slap a null character on the end of the phoned word */
-#define End_Phoned_Word {(*phoned_word)[p_idx] = '\0';}
-/* How long is the phoned word? */
-#define Phone_Len (p_idx)
-
-/* Note is a letter is a 'break' in the word */
-#define Isbreak(c) (!isalpha(c))
-
-
-static int metaphone(char *word, int max_phonemes, char **phoned_word, int traditional)
-{
- int w_idx = 0; /* point in the phonization we're at. */
- int p_idx = 0; /* end of the phoned phrase */
-
-/*-- Parameter checks --*/
- /* Negative phoneme length is meaningless */
-
- if (max_phonemes < 0)
- return -1;
-
- /* Empty/null string is meaningless */
- /* Overly paranoid */
- /* assert(word != NULL && word[0] != '\0'); */
-
- if (word == NULL)
- return -1;
-
-/*-- Allocate memory for our phoned_phrase --*/
- if (max_phonemes == 0) { /* Assume largest possible */
- *phoned_word = emalloc(sizeof(char) * strlen(word) + 1);
- if (!*phoned_word)
- return -1;
- } else {
- *phoned_word = emalloc(sizeof(char) * max_phonemes + 1);
- if (!*phoned_word)
- return -1;
- }
-
-
-/*-- The first phoneme has to be processed specially. --*/
- /* Find our first letter */
- for (; !isalpha(Curr_Letter); w_idx++) {
- /* On the off chance we were given nothing but crap... */
- if (Curr_Letter == '\0') {
- End_Phoned_Word
- return SUCCESS; /* For testing */
- }
- }
-
- switch (Curr_Letter) {
- /* AE becomes E */
- case 'A':
- if (Next_Letter == 'E') {
- Phonize('E');
- w_idx += 2;
- }
- /* Remember, preserve vowels at the beginning */
- else {
- Phonize('A');
- w_idx++;
- }
- break;
- /* [GKP]N becomes N */
- case 'G':
- case 'K':
- case 'P':
- if (Next_Letter == 'N') {
- Phonize('N');
- w_idx += 2;
- }
- break;
- /* WH becomes H,
- WR becomes R
- W if followed by a vowel */
- case 'W':
- if (Next_Letter == 'H' ||
- Next_Letter == 'R') {
- Phonize(Next_Letter);
- w_idx += 2;
- } else if (isvowel(Next_Letter)) {
- Phonize('W');
- w_idx += 2;
- }
- /* else ignore */
- break;
- /* X becomes S */
- case 'X':
- Phonize('S');
- w_idx++;
- break;
- /* Vowels are kept */
- /* We did A already
- case 'A':
- case 'a':
- */
- case 'E':
- case 'I':
- case 'O':
- case 'U':
- Phonize(Curr_Letter);
- w_idx++;
- break;
- default:
- /* do nothing */
- break;
- }
-
-
-
- /* On to the metaphoning */
- for (; Curr_Letter != '\0' &&
- (max_phonemes == 0 || Phone_Len < max_phonemes);
- w_idx++) {
- /* How many letters to skip because an eariler encoding handled
- * multiple letters */
- unsigned short int skip_letter = 0;
-
-
- /* THOUGHT: It would be nice if, rather than having things like...
- * well, SCI. For SCI you encode the S, then have to remember
- * to skip the C. So the phonome SCI invades both S and C. It would
- * be better, IMHO, to skip the C from the S part of the encoding.
- * Hell, I'm trying it.
- */
-
- /* Ignore non-alphas */
- if (!isalpha(Curr_Letter))
- continue;
-
- /* Drop duplicates, except CC */
- if (Curr_Letter == Prev_Letter &&
- Curr_Letter != 'C')
- continue;
-
- switch (Curr_Letter) {
- /* B -> B unless in MB */
- case 'B':
- if (Prev_Letter != 'M')
- Phonize('B');
- break;
- /* 'sh' if -CIA- or -CH, but not SCH, except SCHW.
- * (SCHW is handled in S)
- * S if -CI-, -CE- or -CY-
- * dropped if -SCI-, SCE-, -SCY- (handed in S)
- * else K
- */
- case 'C':
- if (MAKESOFT(Next_Letter)) { /* C[IEY] */
- if (After_Next_Letter == 'A' &&
- Next_Letter == 'I') { /* CIA */
- Phonize(SH);
- }
- /* SC[IEY] */
- else if (Prev_Letter == 'S') {
- /* Dropped */
- } else {
- Phonize('S');
- }
- } else if (Next_Letter == 'H') {
- if ((!traditional) && (After_Next_Letter == 'R' || Prev_Letter == 'S')) { /* Christ, School */
- Phonize('K');
- } else {
- Phonize(SH);
- }
- skip_letter++;
- } else {
- Phonize('K');
- }
- break;
- /* J if in -DGE-, -DGI- or -DGY-
- * else T
- */
- case 'D':
- if (Next_Letter == 'G' &&
- MAKESOFT(After_Next_Letter)) {
- Phonize('J');
- skip_letter++;
- } else
- Phonize('T');
- break;
- /* F if in -GH and not B--GH, D--GH, -H--GH, -H---GH
- * else dropped if -GNED, -GN,
- * else dropped if -DGE-, -DGI- or -DGY- (handled in D)
- * else J if in -GE-, -GI, -GY and not GG
- * else K
- */
- case 'G':
- if (Next_Letter == 'H') {
- if (!(NOGHTOF(Look_Back_Letter(3)) ||
- Look_Back_Letter(4) == 'H')) {
- Phonize('F');
- skip_letter++;
- } else {
- /* silent */
- }
- } else if (Next_Letter == 'N') {
- if (Isbreak(After_Next_Letter) ||
- (After_Next_Letter == 'E' &&
- Look_Ahead_Letter(3) == 'D')) {
- /* dropped */
- } else
- Phonize('K');
- } else if (MAKESOFT(Next_Letter) &&
- Prev_Letter != 'G') {
- Phonize('J');
- } else {
- Phonize('K');
- }
- break;
- /* H if before a vowel and not after C,G,P,S,T */
- case 'H':
- if (isvowel(Next_Letter) &&
- !AFFECTH(Prev_Letter))
- Phonize('H');
- break;
- /* dropped if after C
- * else K
- */
- case 'K':
- if (Prev_Letter != 'C')
- Phonize('K');
- break;
- /* F if before H
- * else P
- */
- case 'P':
- if (Next_Letter == 'H') {
- Phonize('F');
- } else {
- Phonize('P');
- }
- break;
- /* K
- */
- case 'Q':
- Phonize('K');
- break;
- /* 'sh' in -SH-, -SIO- or -SIA- or -SCHW-
- * else S
- */
- case 'S':
- if (Next_Letter == 'I' &&
- (After_Next_Letter == 'O' ||
- After_Next_Letter == 'A')) {
- Phonize(SH);
- } else if (Next_Letter == 'H') {
- Phonize(SH);
- skip_letter++;
- } else if ((!traditional) && (Next_Letter == 'C' && Look_Ahead_Letter(2) == 'H' && Look_Ahead_Letter(3) == 'W')) {
- Phonize(SH);
- skip_letter += 2;
- } else {
- Phonize('S');
- }
- break;
- /* 'sh' in -TIA- or -TIO-
- * else 'th' before H
- * else T
- */
- case 'T':
- if (Next_Letter == 'I' &&
- (After_Next_Letter == 'O' ||
- After_Next_Letter == 'A')) {
- Phonize(SH);
- } else if (Next_Letter == 'H') {
- Phonize(TH);
- skip_letter++;
- } else {
- Phonize('T');
- }
- break;
- /* F */
- case 'V':
- Phonize('F');
- break;
- /* W before a vowel, else dropped */
- case 'W':
- if (isvowel(Next_Letter))
- Phonize('W');
- break;
- /* KS */
- case 'X':
- Phonize('K');
- Phonize('S');
- break;
- /* Y if followed by a vowel */
- case 'Y':
- if (isvowel(Next_Letter))
- Phonize('Y');
- break;
- /* S */
- case 'Z':
- Phonize('S');
- break;
- /* No transformation */
- case 'F':
- case 'J':
- case 'L':
- case 'M':
- case 'N':
- case 'R':
- Phonize(Curr_Letter);
- break;
- default:
- /* nothing */
- break;
- } /* END SWITCH */
-
- w_idx += skip_letter;
- } /* END FOR */
-
- End_Phoned_Word;
-
- return 0;
-} /* END metaphone */
diff --git a/ext/standard/microtime.c b/ext/standard/microtime.c
deleted file mode 100644
index 0ab88704ac..0000000000
--- a/ext/standard/microtime.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Paul Panotzki - Bunyip Information Systems |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include <stdlib.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <string.h>
-#include <errno.h>
-
-#include "php.h"
-#include "microtime.h"
-#include "snprintf.h"
-
-#include <stdio.h>
-#ifdef HAVE_GETTIMEOFDAY
-#if MSVC5
-#include "win32/time.h"
-#else
-#include <sys/time.h>
-#endif
-#endif
-
-#define NUL '\0'
-#define MICRO_IN_SEC 1000000.00
-
-/* {{{ proto string microtime(void)
- Returns a string containing the current time in seconds and microseconds */
-PHP_FUNCTION(microtime)
-{
-#ifdef HAVE_GETTIMEOFDAY
- struct timeval tp;
- long sec = 0L;
- double msec = 0.0;
- char ret[100];
-
- if (gettimeofday((struct timeval *) &tp, (NUL)) == 0) {
- msec = (double) (tp.tv_usec / MICRO_IN_SEC);
- sec = tp.tv_sec;
- }
- snprintf(ret, 100, "%.8f %ld", msec, sec);
- RETVAL_STRING(ret,1);
-#endif
-}
-/* }}} */
-
-
-/* {{{ proto array gettimeofday(void)
- returns the current time as array */
-PHP_FUNCTION(gettimeofday)
-{
-#ifdef HAVE_GETTIMEOFDAY
- struct timeval tp;
- struct timezone tz;
-
- memset(&tp, 0, sizeof(tp));
- memset(&tz, 0, sizeof(tz));
- if(gettimeofday(&tp, &tz) == 0) {
- array_init(return_value);
- add_assoc_long(return_value, "sec", tp.tv_sec);
- add_assoc_long(return_value, "usec", tp.tv_usec);
- add_assoc_long(return_value, "minuteswest", tz.tz_minuteswest);
- add_assoc_long(return_value, "dsttime", tz.tz_dsttime);
- return;
- } else
-#endif
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto array getrusage([ int who ])
- returns an array of usage statistics */
-PHP_FUNCTION(getrusage)
-{
-#if HAVE_GETRUSAGE
- struct rusage usg;
- int ac = ARG_COUNT(ht);
- pval *pwho;
- int who = RUSAGE_SELF;
-
- if(ac == 1 &&
- getParameters(ht, ac, &pwho) != FAILURE) {
- convert_to_long(pwho);
- if(pwho->value.lval == 1)
- who = RUSAGE_CHILDREN;
- }
-
- memset(&usg, 0, sizeof(usg));
- if(getrusage(who, &usg) == -1) {
- RETURN_FALSE;
- }
-
- array_init(return_value);
-#define PHP3_RUSAGE_PARA(a) \
- add_assoc_long(return_value, #a, usg.a)
-#ifndef _OSD_POSIX /* BS2000 has only a few fields in the rusage struct */
- PHP3_RUSAGE_PARA(ru_oublock);
- PHP3_RUSAGE_PARA(ru_inblock);
- PHP3_RUSAGE_PARA(ru_msgsnd);
- PHP3_RUSAGE_PARA(ru_msgrcv);
- PHP3_RUSAGE_PARA(ru_maxrss);
- PHP3_RUSAGE_PARA(ru_ixrss);
- PHP3_RUSAGE_PARA(ru_idrss);
- PHP3_RUSAGE_PARA(ru_minflt);
- PHP3_RUSAGE_PARA(ru_majflt);
- PHP3_RUSAGE_PARA(ru_nsignals);
- PHP3_RUSAGE_PARA(ru_nvcsw);
- PHP3_RUSAGE_PARA(ru_nivcsw);
-#endif /*_OSD_POSIX*/
- PHP3_RUSAGE_PARA(ru_utime.tv_usec);
- PHP3_RUSAGE_PARA(ru_utime.tv_sec);
- PHP3_RUSAGE_PARA(ru_stime.tv_usec);
- PHP3_RUSAGE_PARA(ru_stime.tv_sec);
-#undef PHP3_RUSAGE_PARA
-#endif /* HAVE_GETRUSAGE */
-}
-/* }}} */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/microtime.h b/ext/standard/microtime.h
deleted file mode 100644
index c815bfca82..0000000000
--- a/ext/standard/microtime.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Paul Panotzki - Bunyip Information Systems |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _MICROTIME_H
-#define _MICROTIME_H
-
-PHP_FUNCTION(microtime);
-PHP_FUNCTION(gettimeofday);
-PHP_FUNCTION(getrusage);
-
-#endif /* _MICROTIME_H */
diff --git a/ext/standard/pack.c b/ext/standard/pack.c
deleted file mode 100644
index 60e8648713..0000000000
--- a/ext/standard/pack.c
+++ /dev/null
@@ -1,874 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Chris Schneider <cschneid@relog.ch> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include "php.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#if MSVC5
-#include <windows.h>
-#include <winsock.h>
-#define O_RDONLY _O_RDONLY
-#include "win32/param.h"
-#else
-#include <sys/param.h>
-#endif
-#include "ext/standard/head.h"
-#include "safe_mode.h"
-#include "php3_string.h"
-#include "pack.h"
-#if HAVE_PWD_H
-#if MSVC5
-#include "win32/pwd.h"
-#else
-#include <pwd.h>
-#endif
-#endif
-#include "snprintf.h"
-#include "fsock.h"
-#if HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-
-function_entry pack_functions[] = {
- PHP_FE(pack, NULL)
- PHP_FE(unpack, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry pack_module_entry = {
- "PHP_pack", pack_functions, PHP_MINIT(pack), NULL, NULL, NULL, NULL, STANDARD_MODULE_PROPERTIES
-};
-
-/* Whether machine is little endian */
-char machine_little_endian;
-
-/* Mapping of byte from char (8bit) to long for machine endian */
-static int byte_map[1];
-
-/* Mappings of bytes from int (machine dependant) to int for machine endian */
-static int int_map[sizeof(int)];
-
-/* Mappings of bytes from shorts (16bit) for all endian environments */
-static int machine_endian_short_map[2];
-static int big_endian_short_map[2];
-static int little_endian_short_map[2];
-
-/* Mappings of bytes from longs (32bit) for all endian environments */
-static int machine_endian_long_map[4];
-static int big_endian_long_map[4];
-static int little_endian_long_map[4];
-
-
-static void _php3_pack(pval *val, int size, int *map, char *output)
-{
- int i;
- char *v;
-
- convert_to_long(val);
- v = (char *)&val->value.lval;
-
- for (i = 0; i < size; i++) {
- *(output++) = v[map[i]];
- }
-}
-
-
-/* pack() idea stolen from Perl (implemented formats behave the same as there)
- * Implemented formats are A,a,h,H,c,C,s,S,i,I,l,L,n,N,f,d,x,X,@.
- */
-/* {{{ proto string pack(string format, mixed arg1, mixed arg2, ...)
- Takes 1 or more arguments and packs them into a binary string according to the format argument */
-PHP_FUNCTION(pack)
-{
- pval **argv;
- int argc, i;
- int currentarg;
- char *format;
- int formatlen;
- char *formatcodes;
- int *formatargs;
- int formatcount = 0;
- int outputpos = 0, outputsize = 0;
- char *output;
-
- argc = ARG_COUNT(ht);
-
- if (argc < 1) {
- WRONG_PARAM_COUNT;
- }
-
- argv = emalloc(argc * sizeof(pval *));
-
- if (getParametersArray(ht, argc, argv) == FAILURE) {
- efree(argv);
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(argv[0]);
- format = argv[0]->value.str.val;
- formatlen = argv[0]->value.str.len;
-
- /* We have a maximum of <formatlen> format codes to deal with */
- formatcodes = emalloc(formatlen * sizeof(*formatcodes));
- formatargs = emalloc(formatlen * sizeof(*formatargs));
- currentarg = 1;
-
- /* Preprocess format into formatcodes and formatargs */
- for (i = 0; i < formatlen; formatcount++) {
- char code = format[i++];
- int arg = 1;
-
- /* Handle format arguments if any */
- if (i < formatlen) {
- char c = format[i];
-
- if (c == '*') {
- arg = -1;
- i++;
- }
- else if ((c >= '0') && (c <= '9')) {
- arg = atoi(&format[i]);
-
- while (format[i] >= '0' && format[i] <= '9' && i < formatlen) {
- i++;
- }
- }
- }
-
- /* Handle special arg '*' for all codes and check argv overflows */
- switch ((int)code) {
- /* Never uses any args */
- case 'x': case 'X': case '@': {
- if (arg < 0) {
- php_error(E_WARNING, "pack type %c: '*' ignored", code);
- arg = 1;
- }
- break;
- }
-
- /* Always uses one arg */
- case 'a': case 'A': case 'h': case 'H': {
- if (currentarg >= argc) {
- efree(argv);
- efree(formatcodes);
- efree(formatargs);
- php_error(E_ERROR, "pack type %c: not enough arguments", code);
- RETURN_FALSE;
- }
-
- if (arg < 0) {
- arg = argv[currentarg]->value.str.len;
- }
-
- currentarg++;
- break;
- }
-
- /* Use as many args as specified */
- case 'c': case 'C': case 's': case 'S': case 'i': case 'I':
- case 'l': case 'L': case 'n': case 'N': case 'v': case 'V':
- case 'f': case 'd': {
- if (arg < 0) {
- arg = argc - currentarg;
- }
-
- currentarg += arg;
-
- if (currentarg > argc) {
- efree(argv);
- efree(formatcodes);
- efree(formatargs);
- php_error(E_ERROR, "pack type %c: too few arguments", code);
- RETURN_FALSE;
- }
- break;
- }
-
- default: {
- php_error(E_ERROR, "pack type %c: unknown format code", code);
- RETURN_FALSE;
- }
- }
-
- formatcodes[formatcount] = code;
- formatargs[formatcount] = arg;
- }
-
- if (currentarg < argc) {
- php_error(E_WARNING, "pack %d arguments unused", (argc - currentarg));
- }
-
- /* Calculate output length and upper bound while processing*/
- for (i = 0; i < formatcount; i++) {
- int code = (int)formatcodes[i];
- int arg = formatargs[i];
-
- switch ((int)code) {
- case 'h': case 'H': {
- outputpos += (arg + 1) / 2; /* 4 bit per arg */
- break;
- }
-
- case 'a': case 'A':
- case 'c': case 'C':
- case 'x': {
- outputpos += arg; /* 8 bit per arg */
- break;
- }
-
- case 's': case 'S': case 'n': case 'v': {
- outputpos += arg * 2; /* 16 bit per arg */
- break;
- }
-
- case 'i': case 'I': {
- outputpos += arg * sizeof(int);
- break;
- }
-
- case 'l': case 'L': case 'N': case 'V': {
- outputpos += arg * 4; /* 32 bit per arg */
- break;
- }
-
- case 'f': {
- outputpos += arg * sizeof(float);
- break;
- }
-
- case 'd': {
- outputpos += arg * sizeof(double);
- break;
- }
-
- case 'X': {
- outputpos -= arg;
-
- if (outputpos < 0) {
- php_error(E_WARNING, "pack type %c: outside of string", code);
- outputpos = 0;
- }
- break;
- }
-
- case '@': {
- outputpos = arg;
- break;
- }
- }
-
- if (outputsize < outputpos) {
- outputsize = outputpos;
- }
- }
-
- output = emalloc(outputsize + 1);
- outputpos = 0;
- currentarg = 1;
-
- /* Do actual packing */
- for (i = 0; i < formatcount; i++) {
- int code = (int)formatcodes[i];
- int arg = formatargs[i];
- pval *val;
-
- switch ((int)code) {
- case 'a': case 'A': {
- memset(&output[outputpos], (code == 'a') ? '\0' : ' ', arg);
- val = argv[currentarg++];
- convert_to_string(val);
- memcpy(&output[outputpos], val->value.str.val,
- (val->value.str.len < arg) ? val->value.str.len : arg);
- outputpos += arg;
- break;
- }
-
- case 'h': case 'H': {
- int nibbleshift = (code == 'h') ? 0 : 4;
- int first = 1;
- char *v;
-
- val = argv[currentarg++];
- convert_to_string(val);
- v = val->value.str.val;
- outputpos--;
-
- while (arg-- > 0) {
- char n = *(v++);
-
- if ((n >= '0') && (n <= '9')) {
- n -= '0';
- } else if ((n >= 'A') && (n <= 'F')) {
- n -= ('A' - 10);
- } else if ((n >= 'a') && (n <= 'f')) {
- n -= ('a' - 10);
- } else {
- php_error(E_WARNING, "pack type %c: illegal hex digit %c", code, n);
- n = 0;
- }
-
- if (first--) {
- output[++outputpos] = 0;
- } else {
- first = 1;
- }
-
- output[outputpos] |= (n << nibbleshift);
- nibbleshift = (nibbleshift + 4) & 7;
- }
-
- outputpos++;
- break;
- }
-
- case 'c': case 'C': {
- while (arg-- > 0) {
- _php3_pack(argv[currentarg++], 1, byte_map, &output[outputpos]);
- outputpos++;
- }
- break;
- }
-
- case 's': case 'S': case 'n': case 'v': {
- int *map = machine_endian_short_map;
-
- if (code == 'n') {
- map = big_endian_short_map;
- } else if (code == 'v') {
- map = little_endian_short_map;
- }
-
- while (arg-- > 0) {
- _php3_pack(argv[currentarg++], 2, map, &output[outputpos]);
- outputpos += 2;
- }
- break;
- }
-
- case 'i': case 'I': {
- while (arg-- > 0) {
- _php3_pack(argv[currentarg++], sizeof(int), int_map, &output[outputpos]);
- outputpos += sizeof(int);
- }
- break;
- }
-
- case 'l': case 'L': case 'N': case 'V': {
- int *map = machine_endian_long_map;
-
- if (code == 'N') {
- map = big_endian_long_map;
- } else if (code == 'V') {
- map = little_endian_long_map;
- }
-
- while (arg-- > 0) {
- _php3_pack(argv[currentarg++], 4, map, &output[outputpos]);
- outputpos += 4;
- }
- break;
- }
-
- case 'f': {
- float v;
-
- while (arg-- > 0) {
- val = argv[currentarg++];
- convert_to_double(val);
- v = (float)val->value.dval;
- memcpy(&output[outputpos], &v, sizeof(v));
- outputpos += sizeof(v);
- }
- break;
- }
-
- case 'd': {
- double v;
-
- while (arg-- > 0) {
- val = argv[currentarg++];
- convert_to_double(val);
- v = (double)val->value.dval;
- memcpy(&output[outputpos], &v, sizeof(v));
- outputpos += sizeof(v);
- }
- break;
- }
-
- case 'x': {
- memset(&output[outputpos], '\0', arg);
- outputpos += arg;
- break;
- }
-
- case 'X': {
- outputpos -= arg;
-
- if (outputpos < 0) {
- outputpos = 0;
- }
- break;
- }
-
- case '@': {
- if (arg > outputpos) {
- memset(&output[outputpos], '\0', arg - outputpos);
- }
- outputpos = arg;
- break;
- }
- }
- }
-
- efree(argv);
- efree(formatcodes);
- efree(formatargs);
- output[outputpos] = '\0';
- RETVAL_STRINGL(output, outputpos, 1);
- efree(output);
-}
-/* }}} */
-
-
-static long _php3_unpack(char *data, int size, int issigned, int *map)
-{
- long result;
- char *cresult = (char *)&result;
- int i;
-
- result = issigned ? -1 : 0;
-
- for (i = 0; i < size; i++) {
- cresult[map[i]] = *(data++);
- }
-
- return result;
-}
-
-
-/* unpack() is based on Perl's unpack(), but is modified a bit from there.
- * Rather than depending on error-prone ordered lists or syntactically
- * unpleasant pass-by-reference, we return an object with named paramters
- * (like *_fetch_object()). Syntax is "f[repeat]name/...", where "f" is the
- * formatter char (like pack()), "[repeatt]" is the optional repeater argument,
- * and "name" is the name of the variable to use.
- * Example: "c2chars/nints" will return an object with fields
- * chars1, chars2, and ints.
- * Numeric pack types will return numbers, a and A will return strings,
- * f and d will return doubles.
- * Implemented formats are A,a,h,H,c,C,s,S,i,I,l,L,n,N,f,d,x,X,@.
- */
-/* {{{ proto array unpack(string format, string input)
- Unpack binary string into named array elements according to format argument */
-PHP_FUNCTION(unpack)
-{
- pval *formatarg;
- pval *inputarg;
- char *format;
- char *input;
- int formatlen;
- int inputpos, inputlen;
- int i;
-
- if ((ARG_COUNT(ht) != 2) || getParameters(ht, 2, &formatarg, &inputarg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(formatarg);
- convert_to_string(inputarg);
-
- format = formatarg->value.str.val;
- formatlen = formatarg->value.str.len;
- input = inputarg->value.str.val;
- inputlen = inputarg->value.str.len;
- inputpos = 0;
-
- if (array_init(return_value) == FAILURE)
- return;
-
- while (formatlen-- > 0) {
- char type = *(format++);
- char c;
- int arg = 1;
- char *name;
- int namelen;
- int size=0;
-
- /* Handle format arguments if any */
- if (formatlen > 0) {
- c = *format;
-
- if ((c >= '0') && (c <= '9')) {
- arg = atoi(format);
-
- while ((formatlen > 0) && (*format >= '0') && (*format <= '9')) {
- format++;
- formatlen--;
- }
- } else if (c == '*') {
- arg = -1;
- format++;
- formatlen--;
- }
- }
-
- /* Get of new value in array */
- name = format;
-
- while ((formatlen > 0) && (*format != '/')) {
- formatlen--;
- format++;
- }
-
- namelen = format - name;
-
- if (namelen > 200)
- namelen = 200;
-
- switch ((int)type) {
- /* Never use any input */
- case 'X': {
- size = -1;
- break;
- }
-
- case '@': {
- size = 0;
- break;
- }
-
- case 'a': case 'A': case 'h': case 'H': {
- size = arg;
- arg = 1;
- break;
- }
-
- /* Use 1 byte of input */
- case 'c': case 'C': case 'x': {
- size = 1;
- break;
- }
-
- /* Use 2 bytes of input */
- case 's': case 'S': case 'n': case 'v': {
- size = 2;
- break;
- }
-
- /* Use sizeof(int) bytes of input */
- case 'i': case 'I': {
- size = sizeof(int);
- break;
- }
-
- /* Use 4 bytes of input */
- case 'l': case 'L': case 'N': case 'V': {
- size = 4;
- break;
- }
-
- /* Use sizeof(float) bytes of input */
- case 'f': {
- size = sizeof(float);
- break;
- }
-
- /* Use sizeof(double) bytes of input */
- case 'd': {
- size = sizeof(double);
- break;
- }
- }
-
- /* Do actual unpacking */
- for (i = 0; (i != arg); i++ ) {
- /* Space for name + number, safe as namelen is ensured <= 200 */
- char n[256];
-
- if (arg != 1) {
- /* Need to add element number to name */
- sprintf(n, "%.*s%d", namelen, name, i + 1);
- } else {
- /* Truncate name to next format code or end of string */
- sprintf(n, "%.*s", namelen, name);
- }
-
- if ((inputpos + size) <= inputlen) {
- switch ((int)type) {
- case 'a': case 'A': {
- char pad = (type == 'a') ? '\0' : ' ';
- int len = inputlen - inputpos; /* Remaining string */
-
- /* If size was given take minimum of len and size */
- if ((size >= 0) && (len > size)) {
- len = size;
- }
-
- size = len;
-
- /* Remove padding chars from unpacked data */
- while (--len >= 0) {
- if (input[inputpos + len] != pad)
- break;
- }
-
- add_assoc_stringl(return_value, n, &input[inputpos], len + 1, 1);
- break;
- }
-
- case 'h': case 'H': {
- int len = (inputlen - inputpos) * 2; /* Remaining */
- int nibbleshift = (type == 'h') ? 0 : 4;
- int first = 1;
- char *buf;
- int ipos, opos;
-
- /* If size was given take minimum of len and size */
- if ((size >= 0) && (len > size)) {
- len = size;
- }
-
- size = (len + 1) / 2;
- buf = emalloc(len + 1);
-
- for (ipos = opos = 0; opos < len; opos++) {
- char c = (input[inputpos + ipos] >> nibbleshift) & 0xf;
-
- if (c < 10) {
- c += '0';
- } else {
- c += 'a' - 10;
- }
-
- buf[opos] = c;
- nibbleshift = (nibbleshift + 4) & 7;
-
- if (first-- == 0) {
- ipos++;
- first = 1;
- }
- }
-
- buf[len] = '\0';
- add_assoc_stringl(return_value, n, buf, len, 1);
- efree(buf);
- break;
- }
-
- case 'c': case 'C': {
- int issigned = (type == 'c') ? (input[inputpos] & 0x80) : 0;
- long v = _php3_unpack(&input[inputpos], 1, issigned, byte_map);
- add_assoc_long(return_value, n, v);
- break;
- }
-
- case 's': case 'S': case 'n': case 'v': {
- long v;
- int issigned = 0;
- int *map = machine_endian_short_map;
-
- if (type == 's') {
- issigned = input[inputpos + (machine_little_endian ? 1 : 0)] & 0x80;
- } else if (type == 'n') {
- map = big_endian_short_map;
- } else if (type == 'v') {
- map = little_endian_short_map;
- }
-
- v = _php3_unpack(&input[inputpos], 2, issigned, map);
- add_assoc_long(return_value, n, v);
- break;
- }
-
- case 'i': case 'I': {
- long v;
- int issigned = 0;
-
- if (type == 'i') {
- issigned = input[inputpos + (machine_little_endian ? (sizeof(int) - 1) : 0)] & 0x80;
- }
-
- v = _php3_unpack(&input[inputpos], sizeof(int), issigned, int_map);
- add_assoc_long(return_value, n, v);
- break;
- }
-
- case 'l': case 'L': case 'N': case 'V': {
- int issigned = 0;
- int *map = machine_endian_long_map;
- long v;
-
- if (type == 'l') {
- issigned = input[inputpos + (machine_little_endian ? 3 : 0)] & 0x80;
- } else if (type == 'N') {
- map = big_endian_long_map;
- } else if (type == 'V') {
- map = little_endian_long_map;
- }
-
- v = _php3_unpack(&input[inputpos], 4, issigned, map);
- add_assoc_long(return_value, n, v);
- break;
- }
-
- case 'f': {
- float v;
-
- memcpy(&v, &input[inputpos], sizeof(float));
- add_assoc_double(return_value, n, (double)v);
- break;
- }
-
- case 'd': {
- double v;
-
- memcpy(&v, &input[inputpos], sizeof(float));
- add_assoc_double(return_value, n, v);
- break;
- }
-
- case 'x': {
- /* Do nothing with input, just skip it */
- break;
- }
-
- case 'X': {
- if (inputpos < size) {
- inputpos = -size;
- i = arg - 1; /* Break out of for loop */
-
- if (arg >= 0) {
- php_error(E_WARNING, "pack type %c: outside of string", type);
- }
- }
- break;
- }
-
- case '@': {
- if (arg <= inputlen) {
- inputpos = arg;
- } else {
- php_error(E_WARNING, "pack type %c: outside of string", type);
- }
-
- i = arg - 1; /* Done, break out of for loop */
- break;
- }
- }
-
- inputpos += size;
- } else if (arg < 0) {
- /* Reached end of input for '*' repeater */
- break;
- } else {
- php_error(E_ERROR, "pack type %c: not enough input, need %d, have %d", type, size, inputlen - inputpos);
- RETURN_FALSE;
- }
- }
-
- formatlen--; /* Skip '/' separator, does no harm if inputlen == 0 */
- format++;
- }
-}
-/* }}} */
-
-
-PHP_MINIT_FUNCTION(pack)
-{
- int machine_endian_check = 1;
- int i;
-
- machine_little_endian = ((char *)&machine_endian_check)[0];
-
- if (machine_little_endian) {
- /* Where to get lo to hi bytes from */
- byte_map[0] = 0;
-
- for (i = 0; i < sizeof(int); i++) {
- int_map[i] = i;
- }
-
- machine_endian_short_map[0] = 0;
- machine_endian_short_map[1] = 1;
- big_endian_short_map[0] = 1;
- big_endian_short_map[1] = 0;
- little_endian_short_map[0] = 0;
- little_endian_short_map[1] = 1;
-
- machine_endian_long_map[0] = 0;
- machine_endian_long_map[1] = 1;
- machine_endian_long_map[2] = 2;
- machine_endian_long_map[3] = 3;
- big_endian_long_map[0] = 3;
- big_endian_long_map[1] = 2;
- big_endian_long_map[2] = 1;
- big_endian_long_map[3] = 0;
- little_endian_long_map[0] = 0;
- little_endian_long_map[1] = 1;
- little_endian_long_map[2] = 2;
- little_endian_long_map[3] = 3;
- }
- else {
- pval val;
- int size = sizeof(val.value.lval);
- val.value.lval=0; /*silence a warning*/
-
- /* Where to get hi to lo bytes from */
- byte_map[0] = size - 1;
-
- for (i = 0; i < sizeof(int); i++) {
- int_map[i] = size - (sizeof(int) - i);
- }
-
- machine_endian_short_map[0] = size - 2;
- machine_endian_short_map[1] = size - 1;
- big_endian_short_map[0] = size - 2;
- big_endian_short_map[1] = size - 1;
- little_endian_short_map[0] = size - 1;
- little_endian_short_map[1] = size - 2;
-
- machine_endian_long_map[0] = size - 4;
- machine_endian_long_map[1] = size - 3;
- machine_endian_long_map[2] = size - 2;
- machine_endian_long_map[3] = size - 1;
- big_endian_long_map[0] = size - 4;
- big_endian_long_map[1] = size - 3;
- big_endian_long_map[2] = size - 2;
- big_endian_long_map[3] = size - 1;
- little_endian_long_map[0] = size - 1;
- little_endian_long_map[1] = size - 2;
- little_endian_long_map[2] = size - 3;
- little_endian_long_map[3] = size - 4;
- }
-
- return SUCCESS;
-}
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * End:
- */
diff --git a/ext/standard/pack.h b/ext/standard/pack.h
deleted file mode 100644
index bad1af9cfe..0000000000
--- a/ext/standard/pack.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _PACK_H
-#define _PACK_H
-
-extern php3_module_entry pack_module_entry;
-#define pack_module_ptr &pack_module_entry
-
-extern PHP_MINIT_FUNCTION(pack);
-PHP_FUNCTION(pack);
-PHP_FUNCTION(unpack);
-
-#define phpext_pack_ptr pack_module_ptr
-
-#endif /* _PACK_H */
diff --git a/ext/standard/pageinfo.c b/ext/standard/pageinfo.c
deleted file mode 100644
index 464d2a0bed..0000000000
--- a/ext/standard/pageinfo.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Jim Winstead <jimw@php.net> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include "php.h"
-#include "pageinfo.h"
-#include "SAPI.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#if HAVE_PWD_H
-#if MSVC5
-#include "win32/pwd.h"
-#else
-#include <pwd.h>
-#endif
-#endif
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <sys/stat.h>
-#if MSVC5
-#include <process.h>
-#endif
-
-#ifndef THREAD_SAFE
-static long page_uid = -1;
-static long page_inode = -1;
-static long page_mtime = -1;
-#endif
-
-static void _php3_statpage(void)
-{
-#if !APACHE
- char *path;
- struct stat sb;
-#else
- request_rec *r;
- SLS_FETCH();
-
- r = ((request_rec *) SG(server_context));
-#endif
-
-#if APACHE
- /* Apache has already gone through the trouble of doing
- the stat(), so the only real overhead is copying three
- values. We can afford it, and it means we don't have to
- worry about resetting the static variables after every
- hit. */
- page_uid = r ->finfo.st_uid;
- page_inode = r->finfo.st_ino;
- page_mtime = r->finfo.st_mtime;
-#else
- if (page_uid == -1) {
- SLS_FETCH();
-
- path = SG(request_info).path_translated;
- if (path != NULL) {
- if (stat(path, &sb) == -1) {
- php_error(E_WARNING, "Unable to find file: '%s'", path);
- return;
- }
- page_uid = sb.st_uid;
- page_inode = sb.st_ino;
- page_mtime = sb.st_mtime;
- }
- }
-#endif
-}
-
-long _php3_getuid(void)
-{
- _php3_statpage();
- return (page_uid);
-}
-
-/* {{{ proto int getmyuid(void)
- Get PHP script owner's UID */
-PHP_FUNCTION(getmyuid)
-{
- long uid;
-
- uid = _php3_getuid();
- if (uid < 0) {
- RETURN_FALSE;
- } else {
- RETURN_LONG(uid);
- }
-}
-/* }}} */
-
-/* {{{ proto int getmypid(void)
- Get current process ID */
-PHP_FUNCTION(getmypid)
-{
- int pid;
-
- pid = getpid();
- if (pid < 0) {
- RETURN_FALSE;
- } else {
- RETURN_LONG((long) pid);
- }
-}
-/* }}} */
-
-/* {{{ proto int getmyinode(void)
- Get the inode of the current script being parsed */
-PHP_FUNCTION(getmyinode)
-{
- _php3_statpage();
- if (page_inode < 0) {
- RETURN_FALSE;
- } else {
- RETURN_LONG(page_inode);
- }
-}
-/* }}} */
-
-/* {{{ proto int getlastmod(void)
- Get time of last page modification */
-PHP_FUNCTION(getlastmod)
-{
- _php3_statpage();
- if (page_mtime < 0) {
- RETURN_FALSE;
- } else {
- RETURN_LONG(page_mtime);
- }
-}
-/* }}} */
diff --git a/ext/standard/pageinfo.h b/ext/standard/pageinfo.h
deleted file mode 100644
index d593ade004..0000000000
--- a/ext/standard/pageinfo.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef _PROCESS_H
-#define _PROCESS_H
-
-PHP_FUNCTION(getmyuid);
-PHP_FUNCTION(getmypid);
-PHP_FUNCTION(getmyinode);
-PHP_FUNCTION(getlastmod);
-
-extern long _php3_getuid(void);
-
-#endif
diff --git a/ext/standard/parsedate.y b/ext/standard/parsedate.y
deleted file mode 100644
index 6552c517a2..0000000000
--- a/ext/standard/parsedate.y
+++ /dev/null
@@ -1,919 +0,0 @@
-%{
-/* $Revision$
-**
-** Originally written by Steven M. Bellovin <smb@research.att.com> while
-** at the University of North Carolina at Chapel Hill. Later tweaked by
-** a couple of people on Usenet. Completely overhauled by Rich $alz
-** <rsalz@osf.org> and Jim Berets <jberets@bbn.com> in August, 1990.
-** Further revised (removed obsolete constructs and cleaned up timezone
-** names) in August, 1991, by Rich. Paul Eggert <eggert@twinsun.com>
-** helped in September, 1992.
-**
-** This grammar has six shift/reduce conflicts.
-**
-** This code is in the public domain and has no copyright.
-*/
-/* SUPPRESS 530 *//* Empty body for statement */
-/* SUPPRESS 593 on yyerrlab *//* Label was not used */
-/* SUPPRESS 593 on yynewstate *//* Label was not used */
-/* SUPPRESS 595 on yypvt *//* Automatic variable may be used before set */
-
-#ifdef WIN32
-# include "config.w32.h"
-#else
-# include "php_config.h"
-#endif
-
-#if WIN32||WINNT
-#include <malloc.h>
-#endif
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <time.h>
-
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#ifdef WIN32
-# include "win32/time.h"
-#endif
-
-#include <ctype.h>
-
-#if defined(_HPUX_SOURCE)
-#include <alloca.h>
-#endif
-
-#if WIN32||WINNT
-#include <time.h>
-#else
-# if !defined(HAVE_TM_ZONE) && !defined(_TIMEZONE)
-extern time_t timezone;
-# endif
-#endif
-
-#define yylhs date_yylhs
-#define yylen date_yylen
-#define yydefred date_yydefred
-#define yydgoto date_yydgoto
-#define yysindex date_yysindex
-#define yyrindex date_yyrindex
-#define yygindex date_yygindex
-#define yytable date_yytable
-#define yycheck date_yycheck
-#define yyparse date_parse
-#define yylex date_lex
-#define yyerror date_error
-
-static int date_lex(void);
-
- /* See the LeapYears table in Convert. */
-#define EPOCH 1970
-#define END_OF_TIME 2038
- /* Constants for general time calculations. */
-#define DST_OFFSET 1
-#define SECSPERDAY (24L * 60L * 60L)
- /* Readability for TABLE stuff. */
-#define HOUR(x) (x * 60)
-
-#define LPAREN '('
-#define RPAREN ')'
-#define IS7BIT(x) ((unsigned int)(x) < 0200)
-
-/*
-** Get the number of elements in a fixed-size array, or a pointer just
-** past the end of it.
-*/
-#define SIZEOF(array) ((int)(sizeof array / sizeof array[0]))
-#define ENDOF(array) (&array[SIZEOF(array)])
-#define CTYPE(isXXXXX, c) ((isascii((c)) && isXXXXX((c))))
-
-typedef struct _TIMEINFO {
- time_t time;
- long usec;
- long tzone;
-} TIMEINFO;
-
-typedef char const *STRING;
-typedef char * const CSTRING;
-
-/*
-** An entry in the lexical lookup table.
-*/
-typedef struct _TABLE {
- STRING name;
- int type;
- time_t value;
-} TABLE;
-
-/*
-** Daylight-savings mode: on, off, or not yet known.
-*/
-typedef enum _DSTMODE {
- DSTon, DSToff, DSTmaybe
-} DSTMODE;
-
-/*
-** Meridian: am, pm, or 24-hour style.
-*/
-typedef enum _MERIDIAN {
- MERam, MERpm, MER24
-} MERIDIAN;
-
-
-/*
-** Global variables. We could get rid of most of them by using a yacc
-** union, but this is more efficient. (This routine predates the
-** yacc %union construct.)
-*/
-static char *yyInput;
-static DSTMODE yyDSTmode;
-static int yyHaveDate;
-static int yyHaveRel;
-static int yyHaveTime;
-static time_t yyTimezone;
-static time_t yyDay;
-static time_t yyHour;
-static time_t yyMinutes;
-static time_t yyMonth;
-static time_t yySeconds;
-static time_t yyYear;
-static MERIDIAN yyMeridian;
-static time_t yyRelMonth;
-static time_t yyRelSeconds;
-
-
-extern struct tm *localtime();
-
-static void date_error();
-%}
-
-%expect 6
-
-%union {
- time_t Number;
- enum _MERIDIAN Meridian;
-}
-
-%token tDAY tDAYZONE tMERIDIAN tMONTH tMONTH_UNIT tSEC_UNIT tSNUMBER
-%token tUNUMBER tZONE
-
-%type <Number> tDAYZONE tMONTH tMONTH_UNIT tSEC_UNIT
-%type <Number> tSNUMBER tUNUMBER tZONE numzone zone
-%type <Meridian> tMERIDIAN o_merid
-
-%%
-
-spec : /* NULL */
- | spec item
- ;
-
-item : time {
- yyHaveTime++;
-#if defined(lint)
- /* I am compulsive about lint natterings... */
- if (yyHaveTime == -1) {
- YYERROR;
- }
-#endif /* defined(lint) */
- }
- | time zone {
- yyHaveTime++;
- yyTimezone = $2;
- }
- | date {
- yyHaveDate++;
- }
- | rel {
- yyHaveRel = 1;
- }
- ;
-
-time : tUNUMBER o_merid {
- if ($1 < 100) {
- yyHour = $1;
- yyMinutes = 0;
- }
- else {
- yyHour = $1 / 100;
- yyMinutes = $1 % 100;
- }
- yySeconds = 0;
- yyMeridian = $2;
- }
- | tUNUMBER ':' tUNUMBER o_merid {
- yyHour = $1;
- yyMinutes = $3;
- yySeconds = 0;
- yyMeridian = $4;
- }
- | tUNUMBER ':' tUNUMBER numzone {
- yyHour = $1;
- yyMinutes = $3;
- yyTimezone = $4;
- yyMeridian = MER24;
- yyDSTmode = DSToff;
- }
- | tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid {
- yyHour = $1;
- yyMinutes = $3;
- yySeconds = $5;
- yyMeridian = $6;
- }
- | tUNUMBER ':' tUNUMBER ':' tUNUMBER numzone {
- yyHour = $1;
- yyMinutes = $3;
- yySeconds = $5;
- yyTimezone = $6;
- yyMeridian = MER24;
- yyDSTmode = DSToff;
- }
- ;
-
-zone : tZONE {
- $$ = $1;
- yyDSTmode = DSToff;
- }
- | tDAYZONE {
- $$ = $1;
- yyDSTmode = DSTon;
- }
- | tZONE numzone {
- /* Only allow "GMT+300" and "GMT-0800" */
- if ($1 != 0) {
- YYABORT;
- }
- $$ = $2;
- yyDSTmode = DSToff;
- }
- | numzone {
- $$ = $1;
- yyDSTmode = DSToff;
- }
- ;
-
-numzone : tSNUMBER {
- int i;
-
- /* Unix and GMT and numeric timezones -- a little confusing. */
- if ($1 < 0) {
- /* Don't work with negative modulus. */
- $1 = -$1;
- if ($1 > 9999 || (i = $1 % 100) >= 60) {
- YYABORT;
- }
- $$ = ($1 / 100) * 60 + i;
- }
- else {
- if ($1 > 9999 || (i = $1 % 100) >= 60) {
- YYABORT;
- }
- $$ = -(($1 / 100) * 60 + i);
- }
- }
- ;
-
-date : tUNUMBER '/' tUNUMBER {
- yyMonth = $1;
- yyDay = $3;
- }
- | tUNUMBER '/' tUNUMBER '/' tUNUMBER {
- if ($1 > 100) {
- /* assume YYYY/MM/DD format, so need not to add 1900 */
- yyYear = $1;
- yyMonth = $3;
- yyDay = $5;
- }
- else {
- /* assume MM/DD/YY* format */
- yyMonth = $1;
- yyDay = $3;
- if ($5 > 100) {
- /* assume year is YYYY format, so need not to add 1900 */
- yyYear = $5;
- } else {
- /* assume year is YY format, so need to add 1900 */
- yyYear = $5 + 1900;
- }
- }
- }
- | tMONTH tUNUMBER {
- yyMonth = $1;
- yyDay = $2;
- }
- | tMONTH tUNUMBER ',' tUNUMBER {
- yyMonth = $1;
- yyDay = $2;
- if ($4 > 100) {
- /* assume year is YYYY format, so need not to add 1900 */
- yyYear = $4;
- } else {
- /* assume year is YY format, so need to add 1900 */
- yyYear = $4 + 1900;
- }
- }
- | tUNUMBER tMONTH {
- yyDay = $1;
- yyMonth = $2;
- }
- | tUNUMBER tMONTH tUNUMBER {
- yyDay = $1;
- yyMonth = $2;
- if ($3 > 100) {
- /* assume year is YYYY format, so need not to add 1900 */
- yyYear = $3;
- } else {
- /* assume year is YY format, so need to add 1900 */
- yyYear = $3 + 1900;
- }
- }
- | tDAY ',' tUNUMBER tMONTH tUNUMBER {
- yyDay = $3;
- yyMonth = $4;
- if ($5 > 100) {
- /* assume year is YYYY format, so need not to add 1900 */
- yyYear = $5;
- } else {
- /* assume year is YY format, so need to add 1900 */
- yyYear = $5 + 1900;
- }
- }
- ;
-
-rel : tSNUMBER tSEC_UNIT {
- yyRelSeconds += $1 * $2;
- }
- | tUNUMBER tSEC_UNIT {
- yyRelSeconds += $1 * $2;
- }
- | tSNUMBER tMONTH_UNIT {
- yyRelMonth += $1 * $2;
- }
- | tUNUMBER tMONTH_UNIT {
- yyRelMonth += $1 * $2;
- }
- ;
-
-o_merid : /* NULL */ {
- $$ = MER24;
- }
- | tMERIDIAN {
- $$ = $1;
- }
- ;
-
-%%
-
-/* Month and day table. */
-static TABLE MonthDayTable[] = {
- { "january", tMONTH, 1 },
- { "february", tMONTH, 2 },
- { "march", tMONTH, 3 },
- { "april", tMONTH, 4 },
- { "may", tMONTH, 5 },
- { "june", tMONTH, 6 },
- { "july", tMONTH, 7 },
- { "august", tMONTH, 8 },
- { "september", tMONTH, 9 },
- { "october", tMONTH, 10 },
- { "november", tMONTH, 11 },
- { "december", tMONTH, 12 },
- /* The value of the day isn't used... */
- { "sunday", tDAY, 0 },
- { "monday", tDAY, 0 },
- { "tuesday", tDAY, 0 },
- { "wednesday", tDAY, 0 },
- { "thursday", tDAY, 0 },
- { "friday", tDAY, 0 },
- { "saturday", tDAY, 0 },
-};
-
-/* Time units table. */
-static TABLE UnitsTable[] = {
- { "year", tMONTH_UNIT, 12 },
- { "month", tMONTH_UNIT, 1 },
- { "week", tSEC_UNIT, 7 * 24 * 60 * 60 },
- { "day", tSEC_UNIT, 1 * 24 * 60 * 60 },
- { "hour", tSEC_UNIT, 60 * 60 },
- { "minute", tSEC_UNIT, 60 },
- { "min", tSEC_UNIT, 60 },
- { "second", tSEC_UNIT, 1 },
- { "sec", tSEC_UNIT, 1 },
-};
-
-/* Timezone table. */
-static TABLE TimezoneTable[] = {
- { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */
- { "ut", tZONE, HOUR( 0) }, /* Universal */
- { "utc", tZONE, HOUR( 0) }, /* Universal Coordinated */
- { "cut", tZONE, HOUR( 0) }, /* Coordinated Universal */
- { "z", tZONE, HOUR( 0) }, /* Greenwich Mean */
- { "wet", tZONE, HOUR( 0) }, /* Western European */
- { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */
- { "nst", tZONE, HOUR(3)+30 }, /* Newfoundland Standard */
- { "ndt", tDAYZONE, HOUR(3)+30 }, /* Newfoundland Daylight */
- { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */
- { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */
- { "est", tZONE, HOUR( 5) }, /* Eastern Standard */
- { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */
- { "cst", tZONE, HOUR( 6) }, /* Central Standard */
- { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */
- { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */
- { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */
- { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */
- { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */
- { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */
- { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */
- { "akst", tZONE, HOUR( 9) }, /* Alaska Standard */
- { "akdt", tDAYZONE, HOUR( 9) }, /* Alaska Daylight */
- { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */
- { "hast", tZONE, HOUR(10) }, /* Hawaii-Aleutian Standard */
- { "hadt", tDAYZONE, HOUR(10) }, /* Hawaii-Aleutian Daylight */
- { "ces", tDAYZONE, -HOUR(1) }, /* Central European Summer */
- { "cest", tDAYZONE, -HOUR(1) }, /* Central European Summer */
- { "mez", tZONE, -HOUR(1) }, /* Middle European */
- { "mezt", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
- { "cet", tZONE, -HOUR(1) }, /* Central European */
- { "met", tZONE, -HOUR(1) }, /* Middle European */
- { "eet", tZONE, -HOUR(2) }, /* Eastern Europe */
- { "msk", tZONE, -HOUR(3) }, /* Moscow Winter */
- { "msd", tDAYZONE, -HOUR(3) }, /* Moscow Summer */
- { "wast", tZONE, -HOUR(8) }, /* West Australian Standard */
- { "wadt", tDAYZONE, -HOUR(8) }, /* West Australian Daylight */
- { "hkt", tZONE, -HOUR(8) }, /* Hong Kong */
- { "cct", tZONE, -HOUR(8) }, /* China Coast */
- { "jst", tZONE, -HOUR(9) }, /* Japan Standard */
- { "kst", tZONE, -HOUR(9) }, /* Korean Standard */
- { "kdt", tZONE, -HOUR(9) }, /* Korean Daylight */
- { "cast", tZONE, -(HOUR(9)+30) }, /* Central Australian Standard */
- { "cadt", tDAYZONE, -(HOUR(9)+30) }, /* Central Australian Daylight */
- { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */
- { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */
- { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */
- { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */
-
- /* For completeness we include the following entries. */
-#if 0
-
- /* Duplicate names. Either they conflict with a zone listed above
- * (which is either more likely to be seen or just been in circulation
- * longer), or they conflict with another zone in this section and
- * we could not reasonably choose one over the other. */
- { "fst", tZONE, HOUR( 2) }, /* Fernando De Noronha Standard */
- { "fdt", tDAYZONE, HOUR( 2) }, /* Fernando De Noronha Daylight */
- { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */
- { "est", tZONE, HOUR( 3) }, /* Eastern Standard (Brazil) */
- { "edt", tDAYZONE, HOUR( 3) }, /* Eastern Daylight (Brazil) */
- { "wst", tZONE, HOUR( 4) }, /* Western Standard (Brazil) */
- { "wdt", tDAYZONE, HOUR( 4) }, /* Western Daylight (Brazil) */
- { "cst", tZONE, HOUR( 5) }, /* Chile Standard */
- { "cdt", tDAYZONE, HOUR( 5) }, /* Chile Daylight */
- { "ast", tZONE, HOUR( 5) }, /* Acre Standard */
- { "adt", tDAYZONE, HOUR( 5) }, /* Acre Daylight */
- { "cst", tZONE, HOUR( 5) }, /* Cuba Standard */
- { "cdt", tDAYZONE, HOUR( 5) }, /* Cuba Daylight */
- { "est", tZONE, HOUR( 6) }, /* Easter Island Standard */
- { "edt", tDAYZONE, HOUR( 6) }, /* Easter Island Daylight */
- { "sst", tZONE, HOUR(11) }, /* Samoa Standard */
- { "ist", tZONE, -HOUR(2) }, /* Israel Standard */
- { "idt", tDAYZONE, -HOUR(2) }, /* Israel Daylight */
- { "idt", tDAYZONE, -(HOUR(3)+30) }, /* Iran Daylight */
- { "ist", tZONE, -(HOUR(3)+30) }, /* Iran Standard */
- { "cst", tZONE, -HOUR(8) }, /* China Standard */
- { "cdt", tDAYZONE, -HOUR(8) }, /* China Daylight */
- { "sst", tZONE, -HOUR(8) }, /* Singapore Standard */
-
- /* Dubious (e.g., not in Olson's TIMEZONE package) or obsolete. */
- { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */
- { "wat", tZONE, -HOUR(1) }, /* West Africa */
- { "at", tZONE, HOUR( 2) }, /* Azores */
- { "gst", tZONE, -HOUR(10) }, /* Guam Standard */
- { "nft", tZONE, HOUR(3)+30 }, /* Newfoundland */
- { "idlw", tZONE, HOUR(12) }, /* International Date Line West */
- { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */
- { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
- { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */
- { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */
- { "fwt", tZONE, -HOUR(1) }, /* French Winter */
- { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */
- { "bt", tZONE, -HOUR(3) }, /* Baghdad */
- { "it", tZONE, -(HOUR(3)+30) }, /* Iran */
- { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */
- { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */
- { "ist", tZONE, -(HOUR(5)+30) }, /* Indian Standard */
- { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */
- { "nst", tZONE, -HOUR(7) }, /* North Sumatra */
- { "sst", tZONE, -HOUR(7) }, /* South Sumatra */
- { "jt", tZONE, -(HOUR(7)+30) }, /* Java (3pm in Cronusland!) */
- { "nzt", tZONE, -HOUR(12) }, /* New Zealand */
- { "idle", tZONE, -HOUR(12) }, /* International Date Line East */
- { "cat", tZONE, HOUR(10) }, /* -- expired 1967 */
- { "nt", tZONE, HOUR(11) }, /* -- expired 1967 */
- { "ahst", tZONE, HOUR(10) }, /* -- expired 1983 */
- { "hdt", tDAYZONE, HOUR(10) }, /* -- expired 1986 */
-#endif /* 0 */
-};
-
-
-
-/* ARGSUSED */
-static void
-date_error(s)
- char *s;
-{
- /* NOTREACHED */
-}
-
-int GetTimeInfo(TIMEINFO *Now)
-{
- static time_t NextHour;
- static long LastTzone;
- struct tm *tm;
- int secondsUntilNextHour;
-#if defined(HAVE_GETTIMEOFDAY)
- struct timeval tv;
-#endif /* defined(HAVE_GETTIMEOFDAY) */
-#if !defined(HAVE_TM_GMTOFF)
- struct tm local;
- struct tm gmt;
-#endif /* !defined(HAVE_TM_GMTOFF) */
-
- /* Get the basic time. */
-#if defined(HAVE_GETTIMEOFDAY)
- if (gettimeofday(&tv, (struct timezone *)NULL) == -1)
- return -1;
- Now->time = tv.tv_sec;
- Now->usec = tv.tv_usec;
-#else
- /* Can't check for -1 since that might be a time, I guess. */
- (void)time(&Now->time);
- Now->usec = 0;
-#endif /* defined(HAVE_GETTIMEOFDAY) */
-
- /* Now get the timezone if the last time < HH:00:00 <= now for some HH. */
- if (NextHour <= Now->time) {
- if ((tm = localtime(&Now->time)) == NULL)
- return -1;
- secondsUntilNextHour = 60 * (60 - tm->tm_min) - tm->tm_sec;
-#if !defined(HAVE_TM_GMTOFF)
- /* To get the timezone, compare localtime with GMT. */
- local = *tm;
- if ((tm = gmtime(&Now->time)) == NULL)
- return -1;
- gmt = *tm;
-
- /* Assume we are never more than 24 hours away. */
- LastTzone = gmt.tm_yday - local.tm_yday;
- if (LastTzone > 1)
- LastTzone = -24;
- else if (LastTzone < -1)
- LastTzone = 24;
- else
- LastTzone *= 24;
-
- /* Scale in the hours and minutes; ignore seconds. */
- LastTzone += gmt.tm_hour - local.tm_hour;
- LastTzone *= 60;
- LastTzone += gmt.tm_min - local.tm_min;
-#else
- LastTzone = (0 - tm->tm_gmtoff) / 60;
-#endif /* defined(HAVE_TM_GMTOFF) */
- NextHour = Now->time + secondsUntilNextHour;
- }
- Now->tzone = LastTzone;
- return 0;
-}
-
-
-static time_t
-ToSeconds(Hours, Minutes, Seconds, Meridian)
- time_t Hours;
- time_t Minutes;
- time_t Seconds;
- MERIDIAN Meridian;
-{
- if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 61)
- return -1;
- if (Meridian == MER24) {
- if (Hours < 0 || Hours > 23)
- return -1;
- }
- else {
- if (Hours < 1 || Hours > 12)
- return -1;
- if (Hours == 12)
- Hours = 0;
- if (Meridian == MERpm)
- Hours += 12;
- }
- return (Hours * 60L + Minutes) * 60L + Seconds;
-}
-
-
-static time_t
-Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, dst)
- time_t Month;
- time_t Day;
- time_t Year;
- time_t Hours;
- time_t Minutes;
- time_t Seconds;
- MERIDIAN Meridian;
- DSTMODE dst;
-{
- static int DaysNormal[13] = {
- 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
- };
- static int DaysLeap[13] = {
- 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
- };
- static int LeapYears[] = {
- 1972, 1976, 1980, 1984, 1988, 1992, 1996,
- 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036
- };
- int *yp;
- int *mp;
- time_t Julian;
- int i;
- time_t tod;
-
- /* Year should not be passed as a relative value, but absolute one.
- so this should not happen, but just ensure it */
- if (Year < 0)
- Year = -Year;
- if (Year < 100)
- Year += 1900;
- if (Year < EPOCH)
- Year += 100;
- for (mp = DaysNormal, yp = LeapYears; yp < ENDOF(LeapYears); yp++)
- if (Year == *yp) {
- mp = DaysLeap;
- break;
- }
- if (Year < EPOCH || Year > END_OF_TIME
- || Month < 1 || Month > 12
- /* NOSTRICT *//* conversion from long may lose accuracy */
- || Day < 1 || Day > mp[(int)Month])
- return -1;
-
- Julian = Day - 1 + (Year - EPOCH) * 365;
- for (yp = LeapYears; yp < ENDOF(LeapYears); yp++, Julian++)
- if (Year <= *yp)
- break;
- for (i = 1; i < Month; i++)
- Julian += *++mp;
- Julian *= SECSPERDAY;
- Julian += yyTimezone * 60L;
- if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
- return -1;
- Julian += tod;
- tod = Julian;
- if (dst == DSTon || (dst == DSTmaybe && localtime(&tod)->tm_isdst))
- Julian -= DST_OFFSET * 60 * 60;
- return Julian;
-}
-
-
-static time_t
-DSTcorrect(Start, Future)
- time_t Start;
- time_t Future;
-{
- time_t StartDay;
- time_t FutureDay;
-
- StartDay = (localtime(&Start)->tm_hour + 1) % 24;
- FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
- return (Future - Start) + (StartDay - FutureDay) * DST_OFFSET * 60 * 60;
-}
-
-
-static time_t
-RelativeMonth(Start, RelMonth)
- time_t Start;
- time_t RelMonth;
-{
- struct tm *tm;
- time_t Month;
- time_t Year;
-
- tm = localtime(&Start);
- Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
- Year = Month / 12;
- Year += 1900;
- Month = Month % 12 + 1;
- return DSTcorrect(Start,
- Convert(Month, (time_t)tm->tm_mday, Year,
- (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
- MER24, DSTmaybe));
-}
-
-
-static int LookupWord(char *buff, int length)
-{
- char *p;
- STRING q;
- TABLE *tp;
- int c;
-
- p = buff;
- c = p[0];
-
- /* See if we have an abbreviation for a month. */
- if (length == 3 || (length == 4 && p[3] == '.'))
- for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++) {
- q = tp->name;
- if (c == q[0] && p[1] == q[1] && p[2] == q[2]) {
- yylval.Number = tp->value;
- return tp->type;
- }
- }
- else
- for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++)
- if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
-
- /* Try for a timezone. */
- for (tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
- if (c == tp->name[0] && p[1] == tp->name[1]
- && strcmp(p, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
-
- /* Try the units table. */
- for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
- if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
-
- /* Strip off any plural and try the units table again. */
- if (--length > 0 && p[length] == 's') {
- p[length] = '\0';
- for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
- if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
- p[length] = 's';
- yylval.Number = tp->value;
- return tp->type;
- }
- p[length] = 's';
- }
- length++;
-
- /* Drop out any periods. */
- for (p = buff, q = (STRING)buff; *q; q++)
- if (*q != '.')
- *p++ = *q;
- *p = '\0';
-
- /* Try the meridians. */
- if (buff[1] == 'm' && buff[2] == '\0') {
- if (buff[0] == 'a') {
- yylval.Meridian = MERam;
- return tMERIDIAN;
- }
- if (buff[0] == 'p') {
- yylval.Meridian = MERpm;
- return tMERIDIAN;
- }
- }
-
- /* If we saw any periods, try the timezones again. */
- if (p - buff != length) {
- c = buff[0];
- for (p = buff, tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
- if (c == tp->name[0] && p[1] == tp->name[1]
- && strcmp(p, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
- }
-
- /* Unknown word -- assume GMT timezone. */
- yylval.Number = 0;
- return tZONE;
-}
-
-
-static int date_lex(void)
-{
- char c;
- char *p;
- char buff[20];
- int sign;
- int i;
- int nesting;
-
- for ( ; ; ) {
- /* Get first character after the whitespace. */
- for ( ; ; ) {
- while (CTYPE(isspace, (int)*yyInput))
- yyInput++;
- c = *yyInput;
-
- /* Ignore RFC 822 comments, typically time zone names. */
- if (c != LPAREN)
- break;
- for (nesting = 1; (c = *++yyInput) != RPAREN || --nesting; )
- if (c == LPAREN)
- nesting++;
- else if (!IS7BIT(c) || c == '\0' || c == '\r'
- || (c == '\\' && ((c = *++yyInput) == '\0' || !IS7BIT(c))))
- /* Lexical error: bad comment. */
- return '?';
- yyInput++;
- }
-
- /* A number? */
- if (CTYPE(isdigit, (int)c) || c == '-' || c == '+') {
- if (c == '-' || c == '+') {
- sign = c == '-' ? -1 : 1;
- yyInput++;
- if (!CTYPE(isdigit, (int)*yyInput))
- /* Skip the plus or minus sign. */
- continue;
- }
- else
- sign = 0;
- for (i = 0; (c = *yyInput++) != '\0' && CTYPE(isdigit, (int)c); )
- i = 10 * i + c - '0';
- yyInput--;
- yylval.Number = sign < 0 ? -i : i;
- return sign ? tSNUMBER : tUNUMBER;
- }
-
- /* A word? */
- if (CTYPE(isalpha, (int)c)) {
- for (p = buff; (c = *yyInput++) == '.' || CTYPE(isalpha, (int)c); )
- if (p < &buff[sizeof buff - 1])
- *p++ = CTYPE(isupper, (int)c) ? tolower(c) : c;
- *p = '\0';
- yyInput--;
- return LookupWord(buff, p - buff);
- }
-
- return *yyInput++;
- }
-}
-
-
-time_t parsedate(char *p, TIMEINFO *now)
-{
- extern int date_parse();
- struct tm *tm;
- TIMEINFO ti;
- time_t Start;
-
- yyInput = p;
- if (now == NULL) {
- now = &ti;
- (void)GetTimeInfo(&ti);
- }
-
- tm = localtime(&now->time);
- yyYear = tm->tm_year + 1900;
- yyMonth = tm->tm_mon + 1;
- yyDay = tm->tm_mday;
-#ifdef HAVE_TM_GMTOFF
- yyTimezone = tm->tm_gmtoff/60;
-#else
- yyTimezone = timezone/60;
-#endif
- yyDSTmode = DSTmaybe;
- yyHour = 0;
- yyMinutes = 0;
- yySeconds = 0;
- yyMeridian = MER24;
- yyRelSeconds = 0;
- yyRelMonth = 0;
- yyHaveDate = 0;
- yyHaveRel = 0;
- yyHaveTime = 0;
-
- if (date_parse() || yyHaveTime > 1 || yyHaveDate > 1)
- return -1;
-
- if (yyHaveDate || yyHaveTime) {
- Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds,
- yyMeridian, yyDSTmode);
- if (Start < 0)
- return -1;
- }
- else {
- Start = now->time;
- if (!yyHaveRel)
- Start -= (tm->tm_hour * 60L + tm->tm_min) * 60L + tm->tm_sec;
- }
-
- Start += yyRelSeconds;
- if (yyRelMonth)
- Start += RelativeMonth(Start, yyRelMonth);
-
- /* Have to do *something* with a legitimate -1 so it's distinguishable
- * from the error return value. (Alternately could set errno on error.) */
- return Start == -1 ? 0 : Start;
-}
diff --git a/ext/standard/php3_browscap.h b/ext/standard/php3_browscap.h
deleted file mode 100644
index 2a61016e47..0000000000
--- a/ext/standard/php3_browscap.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-
-#ifndef _PHP3_BROWSCAP_H
-#define _PHP3_BROWSCAP_H
-
-extern php3_module_entry browscap_module_entry;
-#define browscap_module_ptr &browscap_module_entry
-
-extern PHP_MINIT_FUNCTION(browscap);
-extern PHP_MSHUTDOWN_FUNCTION(browscap);
-
-PHP_FUNCTION(get_browser);
-
-
-#define phpext_browscap_ptr browscap_module_ptr
-
-#endif /* _PHP3_BROWSCAP_H */
diff --git a/ext/standard/php3_crypt.h b/ext/standard/php3_crypt.h
deleted file mode 100644
index 1ae1d5f84b..0000000000
--- a/ext/standard/php3_crypt.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef PHP3_CRYPT_H
-#define PHP3_CRYPT_H
-
-#if HAVE_CRYPT
-extern php3_module_entry crypt_module_entry;
-#define crypt_module_ptr &crypt_module_entry
-PHP_FUNCTION(crypt);
-extern PHP_MINIT_FUNCTION(crypt);
-#else
-#define crypt_module_ptr NULL
-#endif
-
-#define phpext_crypt_ptr crypt_module_ptr
-
-#endif
diff --git a/ext/standard/php3_dir.h b/ext/standard/php3_dir.h
deleted file mode 100644
index 29e00716e8..0000000000
--- a/ext/standard/php3_dir.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: |
- | |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _PHP3_DIR_H
-#define _PHP3_DIR_H
-extern php3_module_entry php3_dir_module_entry;
-#define php3_dir_module_ptr &php3_dir_module_entry
-
-/* directory functions */
-extern PHP_MINIT_FUNCTION(dir);
-PHP_FUNCTION(opendir);
-PHP_FUNCTION(closedir);
-PHP_FUNCTION(chdir);
-PHP_FUNCTION(rewinddir);
-PHP_FUNCTION(readdir);
-PHP_FUNCTION(getdir);
-
-#define phpext_dir_ptr php3_dir_module_ptr
-
-#endif /* _PHP3_DIR_H */
diff --git a/ext/standard/php3_filestat.h b/ext/standard/php3_filestat.h
deleted file mode 100644
index bc6cc9d232..0000000000
--- a/ext/standard/php3_filestat.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Author: Jim Winstead <jimw@php.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _FILESTAT_H
-#define _FILESTAT_H
-
-PHP_RINIT_FUNCTION(filestat);
-PHP_RSHUTDOWN_FUNCTION(filestat);
-
-PHP_FUNCTION(clearstatcache);
-PHP_FUNCTION(fileatime);
-PHP_FUNCTION(filectime);
-PHP_FUNCTION(filegroup);
-PHP_FUNCTION(fileinode);
-PHP_FUNCTION(filemtime);
-PHP_FUNCTION(fileowner);
-PHP_FUNCTION(fileperms);
-PHP_FUNCTION(filesize);
-PHP_FUNCTION(filetype);
-PHP_FUNCTION(is_writable);
-PHP_FUNCTION(is_readable);
-PHP_FUNCTION(is_executable);
-PHP_FUNCTION(is_file);
-PHP_FUNCTION(is_dir);
-PHP_FUNCTION(is_link);
-PHP_FUNCTION(file_exists);
-PHP_FUNCTION(stat);
-PHP_FUNCTION(lstat);
-PHP_FUNCTION(chown);
-PHP_FUNCTION(chgrp);
-PHP_FUNCTION(chmod);
-PHP_FUNCTION(touch);
-PHP_FUNCTION(clearstatcache);
-
-extern php3_module_entry php3_filestat_module_entry;
-#define php3_filestat_module_ptr &php3_filestat_module_entry
-
-#define phpext_filestat_ptr php3_filestat_module_ptr
-
-#endif /* _FILESTAT_H */
diff --git a/ext/standard/php3_iptc.h b/ext/standard/php3_iptc.h
deleted file mode 100644
index 2abc43dae1..0000000000
--- a/ext/standard/php3_iptc.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Thies C. Arntzen <thies@digicol.de> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _PHPIPTC_H
-#define _PHPIPTC_H
-
-PHP_FUNCTION(iptcparse);
-PHP_FUNCTION(iptcembed);
-
-#endif /* _PHPIPTC_H */
diff --git a/ext/standard/php3_link.h b/ext/standard/php3_link.h
deleted file mode 100644
index 8ffc61e646..0000000000
--- a/ext/standard/php3_link.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: |
- | |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-#ifndef _PHP3_LINK_H
-#define _PHP3_LINK_H
-
-PHP_FUNCTION(link);
-PHP_FUNCTION(unlink);
-PHP_FUNCTION(readlink);
-PHP_FUNCTION(linkinfo);
-PHP_FUNCTION(symlink);
-
-#endif /* _PHP3_LINK_H */
diff --git a/ext/standard/php3_mail.h b/ext/standard/php3_mail.h
deleted file mode 100644
index 918bcbdf1c..0000000000
--- a/ext/standard/php3_mail.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _MAIL_H
-#define _MAIL_H
-#if HAVE_SENDMAIL
-extern php3_module_entry mail_module_entry;
-#define mail_module_ptr &mail_module_entry
-
-PHP_FUNCTION(mail);
-PHP_MINFO_FUNCTION(mail);
-extern int _php3_mail(char *to, char *subject, char *message, char *headers);
-
-#else
-#define mail_module_ptr NULL
-#endif
-
-#define phpext_mail_ptr mail_module_ptr
-
-#endif /* _MAIL_H */
diff --git a/ext/standard/php3_standard.h b/ext/standard/php3_standard.h
deleted file mode 100644
index c6a80cde65..0000000000
--- a/ext/standard/php3_standard.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: |
- | |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "basic_functions.h"
-#include "phpmath.h"
-#include "php3_string.h"
-#include "base64.h"
-#include "php3_dir.h"
-#include "dns.h"
-#include "reg.h"
-#include "php3_mail.h"
-#include "md5.h"
-#include "html.h"
-#include "exec.h"
-#include "file.h"
-#include "php3_syslog.h"
-#include "php3_filestat.h"
-#include "php3_browscap.h"
-#include "pack.h"
-#include "datetime.h"
-#include "microtime.h"
-#include "url.h"
-#include "pageinfo.h"
-#include "cyr_convert.h"
-#include "php3_link.h"
-#include "fsock.h"
-#include "php_image.h"
-#include "php3_iptc.h"
-#include "info.h"
-#include "uniqid.h"
-#include "php3_var.h"
-#include "quot_print.h"
-#include "type.h"
-#include "dl.h"
-#include "php3_crypt.h"
-#include "head.h"
-#include "post.h"
-
-#define phpext_standard_ptr basic_functions_module_ptr
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/php3_string.h b/ext/standard/php3_string.h
deleted file mode 100644
index 448a49daac..0000000000
--- a/ext/standard/php3_string.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Stig Sæther Bakken <ssb@guardian.no> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-/* Synced with php3 revision 1.43 1999-06-16 [ssb] */
-
-#ifndef _PHPSTRING_H
-#define _PHPSTRING_H
-
-#ifndef THREAD_SAFE
-extern char *strtok_string;
-#endif
-
-PHP_FUNCTION(strlen);
-PHP_FUNCTION(strcmp);
-PHP_FUNCTION(strspn);
-PHP_FUNCTION(strcspn);
-PHP_FUNCTION(strcasecmp);
-PHP_FUNCTION(str_replace);
-PHP_FUNCTION(chop);
-PHP_FUNCTION(trim);
-PHP_FUNCTION(ltrim);
-PHP_FUNCTION(soundex);
-
-PHP_FUNCTION(explode);
-PHP_FUNCTION(implode);
-PHP_FUNCTION(strtok);
-PHP_FUNCTION(strtoupper);
-PHP_FUNCTION(strtolower);
-PHP_FUNCTION(basename);
-PHP_FUNCTION(dirname);
-PHP_FUNCTION(strstr);
-PHP_FUNCTION(strpos);
-PHP_FUNCTION(strrpos);
-PHP_FUNCTION(strrchr);
-PHP_FUNCTION(substr);
-PHP_FUNCTION(quotemeta);
-PHP_FUNCTION(ucfirst);
-PHP_FUNCTION(ucwords);
-PHP_FUNCTION(strtr);
-PHP_FUNCTION(strrev);
-PHP_FUNCTION(hebrev);
-PHP_FUNCTION(hebrevc);
-PHP_FUNCTION(user_sprintf);
-PHP_FUNCTION(user_printf);
-PHP_FUNCTION(addcslashes);
-PHP_FUNCTION(addslashes);
-PHP_FUNCTION(stripcslashes);
-PHP_FUNCTION(stripslashes);
-PHP_FUNCTION(chr);
-PHP_FUNCTION(ord);
-PHP_FUNCTION(nl2br);
-PHP_FUNCTION(setlocale);
-PHP_FUNCTION(stristr);
-PHP_FUNCTION(chunk_split);
-PHP_FUNCTION(parse_str);
-PHP_FUNCTION(bin2hex);
-PHP_FUNCTION(similar_text);
-PHP_FUNCTION(strip_tags);
-
-extern PHPAPI char *_php3_strtoupper(char *s);
-extern PHPAPI char *_php3_strtolower(char *s);
-extern PHPAPI char *_php3_strtr(char *string, int len, char *str_from, char *str_to, int trlen);
-extern PHPAPI char *php_addslashes(char *string, int length, int *new_length, int freeit);
-extern PHPAPI char *php_addcslashes(char *string, int length, int *new_length, int freeit, char *what, int wlength);
-extern PHPAPI void php_stripslashes(char *string, int *len);
-extern PHPAPI void php_stripcslashes(char *string, int *len);
-extern PHPAPI void _php3_dirname(char *str, int len);
-extern PHPAPI char *php3i_stristr(unsigned char *s, unsigned char *t);
-extern PHPAPI char *_php3_str_to_str(char *haystack, int length, char *needle,
- int needle_len, char *str, int str_len, int *_new_length);
-extern PHPAPI void _php3_trim(pval *str, pval *return_value, int mode);
-extern PHPAPI void _php3_strip_tags(char *rbuf, int state);
-
-extern PHPAPI void _php3_char_to_str(char *str, uint len, char from, char *to, int to_len, pval *result);
-
-extern PHPAPI void _php3_implode(pval *delim, pval *arr, pval *return_value);
-extern PHPAPI void _php3_explode(pval *delim, pval *str, pval *return_value);
-
-#endif /* _PHPSTRING_H */
diff --git a/ext/standard/php3_syslog.h b/ext/standard/php3_syslog.h
deleted file mode 100644
index 69dd4abb80..0000000000
--- a/ext/standard/php3_syslog.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: |
- | |
- +----------------------------------------------------------------------+
- */
-
-#ifndef _PHP_SYSLOG_H
-#define _PHP_SYSLOG_H
-
-#if HAVE_SYSLOG_H
-extern php3_module_entry syslog_module_entry;
-#define syslog_module_ptr &syslog_module_entry
-
-extern PHP_MINIT_FUNCTION(syslog);
-extern PHP_RINIT_FUNCTION(syslog);
-extern PHP_RSHUTDOWN_FUNCTION(syslog);
-
-PHP_FUNCTION(openlog);
-PHP_FUNCTION(syslog);
-PHP_FUNCTION(closelog);
-PHP_FUNCTION(define_syslog_variables);
-
-#else
-#define syslog_module_ptr NULL
-#endif
-
-#define phpext_syslog_ptr syslog_module_ptr
-
-#endif /* _PHP_SYSLOG_H */
diff --git a/ext/standard/php3_var.h b/ext/standard/php3_var.h
deleted file mode 100644
index 850baac254..0000000000
--- a/ext/standard/php3_var.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Jani Lehtimäki <jkl@njet.net> |
- +----------------------------------------------------------------------+
- */
-
-
-#ifndef _PHPVAR_H
-#define _PHPVAR_H
-
-PHP_FUNCTION(var_dump);
-PHP_FUNCTION(serialize);
-PHP_FUNCTION(unserialize);
-
-void php_var_dump(pval **struc, int level);
-void php_var_serialize(pval *buf, pval **struc);
-int php_var_unserialize(pval **rval, const char **p, const char *max);
-
-#endif /* _PHPVAR_H */
diff --git a/ext/standard/php_image.h b/ext/standard/php_image.h
deleted file mode 100644
index 39dd9fa2fd..0000000000
--- a/ext/standard/php_image.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef _IMAGE_H
-#define _IMAGE_H
-
-PHP_FUNCTION(getimagesize);
-
-#endif /* _IMAGE_H */
diff --git a/ext/standard/php_lcg.h b/ext/standard/php_lcg.h
deleted file mode 100644
index 3476460dfa..0000000000
--- a/ext/standard/php_lcg.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Sascha Schumann <ss@2ns.de> |
- +----------------------------------------------------------------------+
- */
-
-#ifndef PHP_LCG_H
-#define PHP_LCG_H
-
-typedef struct {
- long s1;
- long s2;
-} php_lcg_globals;
-
-double php_combined_lcg(void);
-PHP_FUNCTION(lcg_value);
-
-#ifdef ZTS
-#define LCGLS_D php_lcg_globals *lcg_globals
-#define LCG(v) (lcg_globals->v)
-#define LCGLS_FETCH() php_lcg_globals *lcg_globals = ts_resource(lcg_globals_id)
-#else
-#define LCGLS_D
-#define LCG(v) (lcg_globals.v)
-#define LCGLS_FETCH()
-#endif
-
-extern zend_module_entry lcg_module_entry;
-#define phpext_lcg_ptr &lcg_module_entry
-
-#endif
diff --git a/ext/standard/php_metaphone.h b/ext/standard/php_metaphone.h
deleted file mode 100644
index 7001e3316e..0000000000
--- a/ext/standard/php_metaphone.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Thies C. Arntzen <thies@digicol.de> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _php_metaphone_h
-#define _php_metaphone_h
-
-extern zend_module_entry metaphone_module_entry;
-#define phpext_metaphone_ptr &metaphone_module_entry
-
-#endif
diff --git a/ext/standard/phpdir.h b/ext/standard/phpdir.h
deleted file mode 100644
index 7d7bc985cb..0000000000
--- a/ext/standard/phpdir.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _PHPDIR_H
-#define _PHPDIR_H
-
-/* directory functions */
-PHP_FUNCTION(opendir);
-PHP_FUNCTION(closedir);
-PHP_FUNCTION(chdir);
-PHP_FUNCTION(rewinddir);
-PHP_FUNCTION(readdir);
-PHP_FUNCTION(getdir);
-
-#endif /* _PHPDIR_H */
diff --git a/ext/standard/phpmath.h b/ext/standard/phpmath.h
deleted file mode 100644
index f9d56abd5b..0000000000
--- a/ext/standard/phpmath.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Jim Winstead (jimw@php.net) |
- | Stig Sæther Bakken <ssb@guardian.no> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _PHPMATH_H
-#define _PHPMATH_H
-PHP_FUNCTION(sin);
-PHP_FUNCTION(cos);
-PHP_FUNCTION(tan);
-PHP_FUNCTION(asin);
-PHP_FUNCTION(acos);
-PHP_FUNCTION(atan);
-PHP_FUNCTION(atan2);
-PHP_FUNCTION(pi);
-PHP_FUNCTION(exp);
-PHP_FUNCTION(log);
-PHP_FUNCTION(log10);
-PHP_FUNCTION(pow);
-PHP_FUNCTION(sqrt);
-PHP_FUNCTION(srand);
-PHP_FUNCTION(rand);
-PHP_FUNCTION(getrandmax);
-PHP_FUNCTION(mt_srand);
-PHP_FUNCTION(mt_rand);
-PHP_FUNCTION(mt_getrandmax);
-PHP_FUNCTION(abs);
-PHP_FUNCTION(ceil);
-PHP_FUNCTION(floor);
-PHP_FUNCTION(round);
-PHP_FUNCTION(decbin);
-PHP_FUNCTION(dechex);
-PHP_FUNCTION(decoct);
-PHP_FUNCTION(bindec);
-PHP_FUNCTION(hexdec);
-PHP_FUNCTION(octdec);
-PHP_FUNCTION(base_convert);
-PHP_FUNCTION(number_format);
-PHP_FUNCTION(deg2rad);
-PHP_FUNCTION(rad2deg);
-
-#endif /* _PHPMATH_H */
diff --git a/ext/standard/post.c b/ext/standard/post.c
deleted file mode 100644
index 8b37dc8ed2..0000000000
--- a/ext/standard/post.c
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-/* $Id: */
-
-#include <stdio.h>
-#include "php.h"
-#include "php3_standard.h"
-#include "php_globals.h"
-#include "SAPI.h"
-
-#include "zend_globals.h"
-
-
-/*
- * parse Get/Post/Cookie string and create appropriate variable
- *
- * This is a tad ugly because it was yanked out of the middle of
- * the old TreatData function. This is a temporary measure filling
- * the gap until a more flexible parser can be built to do this.
- */
-void php_parse_gpc_data(char *val, char *var, pval *track_vars_array ELS_DC PLS_DC)
-{
- int var_type;
- char *ind, *tmp = NULL, *array_index = NULL;
- int var_len, val_len;
- pval *gpc_element;
- zend_bool do_insert;
-
- if (!PG(gpc_globals) && !track_vars_array) {
- /* we don't need track_vars, and we're not setting GPC globals either. */
- return;
- }
-
- var_type = php3_check_ident_type(var);
- if (var_type == GPC_INDEXED_ARRAY) {
- ind = php3_get_ident_index(var);
- if (PG(magic_quotes_gpc)) {
- array_index = php_addslashes(ind, 0, NULL, 1);
- } else {
- array_index = ind;
- }
- }
- if (var_type & GPC_ARRAY) { /* array (indexed or not) */
- tmp = strchr(var, '[');
- if (tmp) {
- *tmp = '\0';
- }
- }
- /* ignore leading spaces in the variable name */
- while (*var && *var==' ') {
- var++;
- }
- var_len = strlen(var);
- if (var_len==0) { /* empty variable name, or variable name with a space in it */
- return;
- }
-
- /* ensure that we don't have spaces or dots in the variable name (not binary safe) */
- for (tmp=var; *tmp; tmp++) {
- switch(*tmp) {
- case ' ':
- case '.':
- *tmp='_';
- break;
- }
- }
-
- val_len = strlen(val);
- if (PG(magic_quotes_gpc)) {
- val = php_addslashes(val, val_len, &val_len, 0);
- } else {
- val = estrndup(val, val_len);
- }
-
- if (var_type & GPC_ARRAY) {
- pval *gpc_element;
- pval **arr_ptr_ptr;
- pval *array_element;
-
- if (zend_hash_find(EG(active_symbol_table), var, var_len+1, (void **) &arr_ptr_ptr) == FAILURE) {
- /* If the array doesn't exist, create it */
- MAKE_STD_ZVAL(gpc_element);
- array_init(gpc_element);
- do_insert=1;
- } else {
- if ((*arr_ptr_ptr)->type!=IS_ARRAY) {
- if (--(*arr_ptr_ptr)->refcount > 0) {
- MAKE_STD_ZVAL(*arr_ptr_ptr);
- } else {
- zval_dtor(*arr_ptr_ptr);
- }
- array_init(*arr_ptr_ptr);
- }
- gpc_element = *arr_ptr_ptr;
- do_insert=0;
- }
-
- /* Create the element */
- array_element = (pval *) emalloc(sizeof(pval));
- INIT_PZVAL(array_element);
- array_element->value.str.val = val;
- array_element->value.str.len = val_len;
- array_element->type = IS_STRING;
-
- /* Insert it */
- if (array_index) {
- /* indexed array */
- if (php3_check_type(array_index) == IS_LONG) {
- /* numeric index */
- zend_hash_index_update(gpc_element->value.ht, atol(array_index), &array_element, sizeof(pval *), NULL); /* s[array_index]=tmp */
- } else {
- /* associative index */
- zend_hash_update(gpc_element->value.ht, array_index, strlen(array_index)+1, &array_element, sizeof(pval *), NULL); /* s["ret"]=tmp */
- }
- efree(array_index);
- } else {
- /* non-indexed array */
- zend_hash_next_index_insert(gpc_element->value.ht, &array_element, sizeof(pval *), NULL);
- }
- } else { /* we have a normal variable */
- MAKE_STD_ZVAL(gpc_element);
- gpc_element->type = IS_STRING;
- gpc_element->refcount = 0;
- gpc_element->value.str.val = val;
- gpc_element->value.str.len = val_len;
- do_insert=1;
- }
-
- if (do_insert) {
- gpc_element->refcount = 0;
- if (PG(gpc_globals)) {
- zend_hash_update(EG(active_symbol_table), var, var_len+1, &gpc_element, sizeof(pval *), NULL);
- gpc_element->refcount++;
- }
- if (track_vars_array) {
- zend_hash_update(track_vars_array->value.ht, var, var_len+1, &gpc_element, sizeof(pval *), NULL);
- gpc_element->refcount++;
- }
- }
-}
-
-
-void php_parse_gpc_data2(char *val, char *var, pval *track_vars_array ELS_DC PLS_DC)
-{
- char *p = NULL;
- char *ip; /* index pointer */
- char *index;
- int var_len, val_len, index_len;
- zval *gpc_element, **gpc_element_p, **top_gpc_p=NULL;
- zend_bool is_array;
- zend_bool free_index;
- HashTable *symtable1=NULL;
- HashTable *symtable2=NULL;
-
- if (PG(gpc_globals)) {
- symtable1 = EG(active_symbol_table);
- }
- if (track_vars_array) {
- if (symtable1) {
- symtable2 = track_vars_array->value.ht;
- } else {
- symtable1 = track_vars_array->value.ht;
- }
- }
- if (!symtable1) {
- /* we don't need track_vars, and we're not setting GPC globals either. */
- return;
- }
-
- /*
- * Prepare variable name
- */
- ip = strchr(var, '[');
- if (ip) {
- is_array = 1;
- *ip = 0;
- } else {
- is_array = 0;
- }
- /* ignore leading spaces in the variable name */
- while (*var && *var==' ') {
- var++;
- }
- var_len = strlen(var);
- if (var_len==0) { /* empty variable name, or variable name with a space in it */
- return;
- }
- /* ensure that we don't have spaces or dots in the variable name (not binary safe) */
- for (p=var; *p; p++) {
- switch(*p) {
- case ' ':
- case '.':
- *p='_';
- break;
- }
- }
-
- /* Prepare value */
- val_len = strlen(val);
- if (PG(magic_quotes_gpc)) {
- val = php_addslashes(val, val_len, &val_len, 0);
- } else {
- val = estrndup(val, val_len);
- }
-
- index = var;
- index_len = var_len;
- free_index = 0;
-
- while (1) {
- if (is_array) {
- char *escaped_index;
-
- if (!index) {
- MAKE_STD_ZVAL(gpc_element);
- array_init(gpc_element);
- zend_hash_next_index_insert(symtable1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
- } else {
- if (PG(magic_quotes_gpc) && (index!=var)) {
- /* no need to addslashes() the index if it's the main variable name */
- escaped_index = php_addslashes(index, index_len, &index_len, 0);
- } else {
- escaped_index = index;
- }
- if (zend_hash_find(symtable1, escaped_index, index_len+1, (void **) &gpc_element_p)==FAILURE
- || (*gpc_element_p)->type != IS_ARRAY) {
- MAKE_STD_ZVAL(gpc_element);
- array_init(gpc_element);
- zend_hash_update(symtable1, escaped_index, index_len+1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
- }
- if (index!=escaped_index) {
- efree(escaped_index);
- }
- }
- if (!top_gpc_p) {
- top_gpc_p = gpc_element_p;
- }
- symtable1 = (*gpc_element_p)->value.ht;
- /* ip pointed to the '[' character, now obtain the key */
- index = ++ip;
- index_len = 0;
- if (*ip=='\n' || *ip=='\r' || *ip=='\t' || *ip==' ') {
- ip++;
- }
- if (*ip==']') {
- index = NULL;
- } else {
- ip = strchr(ip, ']');
- if (!ip) {
- php_error(E_WARNING, "Missing ] in %s variable", var);
- return;
- }
- *ip = 0;
- index_len = strlen(index);
- }
- ip++;
- if (*ip=='[') {
- is_array = 1;
- *ip = 0;
- } else {
- is_array = 0;
- }
- } else {
- MAKE_STD_ZVAL(gpc_element);
- gpc_element->value.str.val = val;
- gpc_element->value.str.len = val_len;
- gpc_element->type = IS_STRING;
- if (!index) {
- zend_hash_next_index_insert(symtable1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
- } else {
- zend_hash_update(symtable1, index, index_len+1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
- }
- if (!top_gpc_p) {
- top_gpc_p = gpc_element_p;
- }
- break;
- }
- }
-
- if (symtable2 && top_gpc_p) {
- zend_hash_update(symtable2, var, var_len+1, top_gpc_p, sizeof(zval *), NULL);
- (*top_gpc_p)->refcount++;
- }
-}
-
-
-void php_treat_data(int arg, char *str ELS_DC PLS_DC SLS_DC)
-{
- char *res = NULL, *var, *val;
- pval *array_ptr;
- int free_buffer=0;
-
- switch (arg) {
- case PARSE_POST:
- case PARSE_GET:
- case PARSE_COOKIE:
- if (PG(track_vars)) {
- array_ptr = (pval *) emalloc(sizeof(pval));
- array_init(array_ptr);
- INIT_PZVAL(array_ptr);
- switch (arg) {
- case PARSE_POST:
- zend_hash_add(&EG(symbol_table), "HTTP_POST_VARS", sizeof("HTTP_POST_VARS"), &array_ptr, sizeof(pval *),NULL);
- break;
- case PARSE_GET:
- zend_hash_add(&EG(symbol_table), "HTTP_GET_VARS", sizeof("HTTP_GET_VARS"), &array_ptr, sizeof(pval *),NULL);
- break;
- case PARSE_COOKIE:
- zend_hash_add(&EG(symbol_table), "HTTP_COOKIE_VARS", sizeof("HTTP_COOKIE_VARS"), &array_ptr, sizeof(pval *),NULL);
- break;
- }
- } else {
- array_ptr=NULL;
- }
- break;
- default:
- array_ptr=NULL;
- break;
- }
-
- if (arg == PARSE_POST) { /* POST data */
- res = SG(request_info).post_data;
- free_buffer = 0;
- } else if (arg == PARSE_GET) { /* GET data */
- var = SG(request_info).query_string;
- if (var && *var) {
- res = (char *) estrdup(var);
- free_buffer = 1;
- } else {
- free_buffer = 0;
- }
- } else if (arg == PARSE_COOKIE) { /* Cookie data */
- var = SG(request_info).cookie_data;
- if (var && *var) {
- res = (char *) estrdup(var);
- free_buffer = 1;
- } else {
- free_buffer = 0;
- }
- } else if (arg == PARSE_STRING) { /* String data */
- res = str;
- free_buffer = 1;
- }
- if (!res) {
- return;
- }
-
- if (arg == PARSE_COOKIE) {
- var = strtok(res, ";");
- } else if (arg == PARSE_POST) {
- var = strtok(res, "&");
- } else {
- var = strtok(res, PG(arg_separator));
- }
-
- while (var) {
- val = strchr(var, '=');
- if (val) { /* have a value */
- *val++ = '\0';
- /* FIXME: XXX: not binary safe, discards returned length */
- _php3_urldecode(var, strlen(var));
- _php3_urldecode(val, strlen(val));
- php_parse_gpc_data2(val,var,array_ptr ELS_CC PLS_CC);
- }
- if (arg == PARSE_COOKIE) {
- var = strtok(NULL, ";");
- } else if (arg == PARSE_POST) {
- var = strtok(NULL, "&");
- } else {
- var = strtok(NULL, PG(arg_separator));
- }
- }
- if (free_buffer) {
- efree(res);
- }
-}
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/post.h b/ext/standard/post.h
deleted file mode 100644
index 243bac6fc2..0000000000
--- a/ext/standard/post.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#ifndef _POST_H
-#define _POST_H
-
-#include "SAPI.h"
-
-#define PARSE_POST 0
-#define PARSE_GET 1
-#define PARSE_COOKIE 2
-#define PARSE_STRING 3
-
-void php_treat_data(int arg, char *str ELS_DC PLS_DC SLS_DC);
-void php_parse_gpc_data(char *val, char *var, pval *track_vars_array ELS_DC PLS_DC);
-void php_parse_gpc_data2(char *val, char *var, pval *track_vars_array ELS_DC PLS_DC);
-
-#endif
diff --git a/ext/standard/quot_print.c b/ext/standard/quot_print.c
deleted file mode 100644
index 9f8e46b969..0000000000
--- a/ext/standard/quot_print.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Kirill Maximov <kir@rus.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include <stdlib.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <string.h>
-#include <errno.h>
-
-#include "php.h"
-#include "quot_print.h"
-
-#include <stdio.h>
-
-/*
-* Converting HEX char to INT value
-*/
-static char _php3_hex2int(int c)
-{
- if ( isdigit(c) )
- {
- return c - '0';
- }
- else if ( c >= 'A' && c <= 'F' )
- {
- return c - 'A' + 10;
- }
- else
- {
- return -1;
- }
-}
-
-/*
-*
-* Decoding Quoted-printable string.
-*
-*/
-/* {{{ proto string quoted_printable_decode(string str)
- Convert a quoted-printable string to an 8 bit string */
-PHP_FUNCTION(quoted_printable_decode)
-{
- pval *arg1;
- char *str;
- int i = 0, j = 0;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&arg1)==FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg1);
-
- str = arg1->value.str.val;
- while ( str[i] )
- {
- if ( (str[i] == '=') && str[i+1] && str[i+2] &&
- ( isdigit((int)str[i+1]) || (str[i+1]<='F' && str[i+1]>='A'))
- &&
- ( isdigit((int)str[i+2]) || (str[i+2]<='F' && str[i+2]>='A'))
- )
- {
- str[j++] = (_php3_hex2int((int)str[i+1]) << 4 )
- + _php3_hex2int((int)str[i+2]);
- i += 3;
- }
- else if ( str[i] == 13 )
- {
- i++;
- }
- else
- {
- str[j++] = str[i++];
- }
- }
- str[j] = '\0';
-
- RETVAL_STRINGL(str, j, 1)
-}
-/* }}} */
diff --git a/ext/standard/quot_print.h b/ext/standard/quot_print.h
deleted file mode 100644
index c8a826a6f5..0000000000
--- a/ext/standard/quot_print.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Kirill Maximov (kir@rus.net) |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _QUOT_PRINT_H
-#define _QUOT_PRINT_H
-
-PHP_FUNCTION(quoted_printable_decode);
-
-#endif /* _QUOT_PRINT_H */
diff --git a/ext/standard/rand.c b/ext/standard/rand.c
deleted file mode 100644
index c8128f0675..0000000000
--- a/ext/standard/rand.c
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Zeev Suraski <zeev@zend.com> |
- | Pedro Melo <melo@ip.pt> |
- | |
- | Based on code from: Shawn Cokus <Cokus@math.washington.edu> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include <stdlib.h>
-
-#include "php.h"
-#include "phpmath.h"
-
-#ifndef RAND_MAX
-#define RAND_MAX (1<<15)
-
-#endif
-
-/*
- This is the ``Mersenne Twister'' random number generator MT19937, which
- generates pseudorandom integers uniformly distributed in 0..(2^32 - 1)
- starting from any odd seed in 0..(2^32 - 1). This version is a recode
- by Shawn Cokus (Cokus@math.washington.edu) on March 8, 1998 of a version by
- Takuji Nishimura (who had suggestions from Topher Cooper and Marc Rieffel in
- July-August 1997).
-
- Effectiveness of the recoding (on Goedel2.math.washington.edu, a DEC Alpha
- running OSF/1) using GCC -O3 as a compiler: before recoding: 51.6 sec. to
- generate 300 million random numbers; after recoding: 24.0 sec. for the same
- (i.e., 46.5% of original time), so speed is now about 12.5 million random
- number generations per second on this machine.
-
- According to the URL <http://www.math.keio.ac.jp/~matumoto/emt.html>
- (and paraphrasing a bit in places), the Mersenne Twister is ``designed
- with consideration of the flaws of various existing generators,'' has
- a period of 2^19937 - 1, gives a sequence that is 623-dimensionally
- equidistributed, and ``has passed many stringent tests, including the
- die-hard test of G. Marsaglia and the load test of P. Hellekalek and
- S. Wegenkittl.'' It is efficient in memory usage (typically using 2506
- to 5012 bytes of static data, depending on data type sizes, and the code
- is quite short as well). It generates random numbers in batches of 624
- at a time, so the caching and pipelining of modern systems is exploited.
- It is also divide- and mod-free.
-
- This 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). This library is distributed in the hope that
- it will be useful, but WITHOUT ANY WARRANTY, without even the implied
- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
- the GNU Library General Public License for more details. You should have
- received a copy of the GNU Library General Public License along with this
- library; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place, Suite 330, Boston, MA 02111-1307, USA.
-
- The code as Shawn received it included the following notice:
-
- Copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura. When
- you use this, send an e-mail to <matumoto@math.keio.ac.jp> with
- an appropriate reference to your work.
-
- It would be nice to CC: <Cokus@math.washington.edu> when you write.
-
-
-
- uint32 must be an unsigned integer type capable of holding at least 32
- bits; exactly 32 should be fastest, but 64 is better on an Alpha with
- GCC at -O3 optimization so try your options and see what's best for you
-
- Melo: we should put some ifdefs here to catch those alphas...
-*/
-
-typedef unsigned int uint32;
-
-#define N (624) /* length of state vector */
-#define M (397) /* a period parameter */
-#define K (0x9908B0DFU) /* a magic constant */
-#define hiBit(u) ((u) & 0x80000000U) /* mask all but highest bit of u */
-#define loBit(u) ((u) & 0x00000001U) /* mask all but lowest bit of u */
-#define loBits(u) ((u) & 0x7FFFFFFFU) /* mask the highest bit of u */
-#define mixBits(u, v) (hiBit(u)|loBits(v)) /* move hi bit of u to hi bit of v */
-
-static uint32 state[N+1]; /* state vector + 1 extra to not violate ANSI C */
-static uint32 *next; /* next random value is computed from here */
-static int left = -1; /* can *next++ this many times before reloading */
-
-
-static void seedMT(uint32 seed)
-{
- /*
- We initialize state[0..(N-1)] via the generator
-
- x_new = (69069 * x_old) mod 2^32
-
- from Line 15 of Table 1, p. 106, Sec. 3.3.4 of Knuth's
- _The Art of Computer Programming_, Volume 2, 3rd ed.
-
- Notes (SJC): I do not know what the initial state requirements
- of the Mersenne Twister are, but it seems this seeding generator
- could be better. It achieves the maximum period for its modulus
- (2^30) iff x_initial is odd (p. 20-21, Sec. 3.2.1.2, Knuth); if
- x_initial can be even, you have sequences like 0, 0, 0, ...;
- 2^31, 2^31, 2^31, ...; 2^30, 2^30, 2^30, ...; 2^29, 2^29 + 2^31,
- 2^29, 2^29 + 2^31, ..., etc. so I force seed to be odd below.
-
- Even if x_initial is odd, if x_initial is 1 mod 4 then
-
- the lowest bit of x is always 1,
- the next-to-lowest bit of x is always 0,
- the 2nd-from-lowest bit of x alternates ... 0 1 0 1 0 1 0 1 ... ,
- the 3rd-from-lowest bit of x 4-cycles ... 0 1 1 0 0 1 1 0 ... ,
- the 4th-from-lowest bit of x has the 8-cycle ... 0 0 0 1 1 1 1 0 ... ,
- ...
-
- and if x_initial is 3 mod 4 then
-
- the lowest bit of x is always 1,
- the next-to-lowest bit of x is always 1,
- the 2nd-from-lowest bit of x alternates ... 0 1 0 1 0 1 0 1 ... ,
- the 3rd-from-lowest bit of x 4-cycles ... 0 0 1 1 0 0 1 1 ... ,
- the 4th-from-lowest bit of x has the 8-cycle ... 0 0 1 1 1 1 0 0 ... ,
- ...
-
- The generator's potency (min. s>=0 with (69069-1)^s = 0 mod 2^32) is
- 16, which seems to be alright by p. 25, Sec. 3.2.1.3 of Knuth. It
- also does well in the dimension 2..5 spectral tests, but it could be
- better in dimension 6 (Line 15, Table 1, p. 106, Sec. 3.3.4, Knuth).
-
- Note that the random number user does not see the values generated
- here directly since reloadMT() will always munge them first, so maybe
- none of all of this matters. In fact, the seed values made here could
- even be extra-special desirable if the Mersenne Twister theory says
- so-- that's why the only change I made is to restrict to odd seeds.
- */
-
- register uint32 x = (seed | 1U) & 0xFFFFFFFFU, *s = state;
- register int j;
-
- for(left=0, *s++=x, j=N; --j;
- *s++ = (x*=69069U) & 0xFFFFFFFFU);
-}
-
-
-static uint32 reloadMT(void)
-{
- register uint32 *p0=state, *p2=state+2, *pM=state+M, s0, s1;
- register int j;
-
- if(left < -1)
- seedMT(4357U);
-
- left=N-1, next=state+1;
-
- for(s0=state[0], s1=state[1], j=N-M+1; --j; s0=s1, s1=*p2++)
- *p0++ = *pM++ ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
-
- for(pM=state, j=M; --j; s0=s1, s1=*p2++)
- *p0++ = *pM++ ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
-
- s1=state[0], *p0 = *pM ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
- s1 ^= (s1 >> 11);
- s1 ^= (s1 << 7) & 0x9D2C5680U;
- s1 ^= (s1 << 15) & 0xEFC60000U;
- return(s1 ^ (s1 >> 18));
-}
-
-
-static inline uint32 randomMT(void)
-{
- uint32 y;
-
- if(--left < 0)
- return(reloadMT());
-
- y = *next++;
- y ^= (y >> 11);
- y ^= (y << 7) & 0x9D2C5680U;
- y ^= (y << 15) & 0xEFC60000U;
- return(y ^ (y >> 18));
-}
-
-
-#if HAVE_LRAND48
-#define PHP_RAND_MAX 2147483647
-#else
-#define PHP_RAND_MAX RAND_MAX
-#endif
-
-/* {{{ proto void srand(int seed)
- Seeds random number generator */
-PHP_FUNCTION(srand)
-{
- pval *arg;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg);
-#ifdef HAVE_SRAND48
- srand48((unsigned int) arg->value.lval);
-#else
-#ifdef HAVE_SRANDOM
- srandom((unsigned int) arg->value.lval);
-#else
- srand((unsigned int) arg->value.lval);
-#endif
-#endif
-}
-/* }}} */
-
-/* {{{ proto void mt_srand(int seed)
- Seeds Mersenne Twister random number generator */
-PHP_FUNCTION(mt_srand)
-{
- pval *arg;
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg);
- seedMT(arg->value.lval);
-}
-/* }}} */
-
-/* {{{ proto int rand([int min, int max])
- Returns a random number */
-PHP_FUNCTION(rand)
-{
- pval *p_min=NULL, *p_max=NULL;
-
- switch (ARG_COUNT(ht)) {
- case 0:
- break;
- case 2:
- if (getParameters(ht, 2, &p_min, &p_max)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(p_min);
- convert_to_long(p_max);
- if (p_max->value.lval-p_min->value.lval <= 0) {
- php_error(E_WARNING,"rand(): Invalid range: %ld..%ld", p_min->value.lval, p_max->value.lval);
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- return_value->type = IS_LONG;
-#ifdef HAVE_LRAND48
- return_value->value.lval = lrand48();
-#else
-#ifdef HAVE_RANDOM
- return_value->value.lval = random();
-#else
- return_value->value.lval = rand();
-#endif
-#endif
- /*
- * A bit of tricky math here. We want to avoid using a modulus because
- * that simply tosses the high-order bits and might skew the distribution
- * of random values over the range. Instead we map the range directly.
- *
- * We need to map the range from 0...M evenly to the range a...b
- * Let n = the random number and n' = the mapped random number
- *
- * Then we have: n' = a + n(b-a)/M
- *
- * We have a problem here in that only n==M will get mapped to b which
- # means the chances of getting b is much much less than getting any of
- # the other values in the range. We can fix this by increasing our range
- # artifically and using:
- #
- # n' = a + n(b-a+1)/M
- *
- # Now we only have a problem if n==M which would cause us to produce a
- # number of b+1 which would be bad. So we bump M up by one to make sure
- # this will never happen, and the final algorithm looks like this:
- #
- # n' = a + n(b-a+1)/(M+1)
- *
- * -RL
- */
- if (p_min && p_max) { /* implement range */
- return_value->value.lval = p_min->value.lval +
- (int)((double)(p_max->value.lval - p_min->value.lval + 1) * return_value->value.lval/(PHP_RAND_MAX+1.0));
- }
-}
-/* }}} */
-
-/* {{{ proto int mt_rand([int min, int max])
- Returns a random number from Mersenne Twister */
-PHP_FUNCTION(mt_rand)
-{
- pval *p_min=NULL, *p_max=NULL;
-
- switch (ARG_COUNT(ht)) {
- case 0:
- break;
- case 2:
- if (getParameters(ht, 2, &p_min, &p_max)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(p_min);
- convert_to_long(p_max);
- if (p_max->value.lval-p_min->value.lval <= 0) {
- php_error(E_WARNING,"mtrand(): Invalid range: %ld..%ld", p_min->value.lval, p_max->value.lval);
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- return_value->type = IS_LONG;
- /*
- * Melo: hmms.. randomMT() returns 32 random bits...
- * Yet, the previous php3_rand only returns 31 at most.
- * So I put a right shift to loose the lsb. It *seems*
- * better than clearing the msb.
- * Update:
- * I talked with Cokus via email and it won't ruin the algorithm
- */
- return_value->value.lval = (long)(randomMT() >> 1);
-
- if (p_min && p_max) { /* implement range */
- return_value->value.lval = p_min->value.lval +
- (int)((double)(p_max->value.lval - p_min->value.lval + 1) * return_value->value.lval/(PHP_RAND_MAX+1.0));
- }
-}
-/* }}} */
-
-/* {{{ proto int getrandmax(void)
- Returns the maximum value a random number can have */
-PHP_FUNCTION(getrandmax)
-{
- return_value->type = IS_LONG;
- return_value->value.lval = PHP_RAND_MAX;
-}
-/* }}} */
-
-
-/* {{{ proto int mt_getrandmax(void)
- Returns the maximum value a random number from Mersenne Twister can have */
-PHP_FUNCTION(mt_getrandmax)
-{
- return_value->type = IS_LONG;
- /*
- * Melo: it could be 2^^32 but we only use 2^^31 to maintain
- * compatibility with the previous php3_rand
- */
- return_value->value.lval = 2147483647; /* 2^^31 */
-}
-/* }}} */
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/reg.c b/ext/standard/reg.c
deleted file mode 100644
index 6382cfd739..0000000000
--- a/ext/standard/reg.c
+++ /dev/null
@@ -1,650 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Jim Winstead <jimw@php.net> |
- | Jaakko Hyvätti <jaakko@hyvatti.iki.fi> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include <stdio.h>
-#include "php.h"
-#include "php3_string.h"
-#include "php_regex.h"
-#include "reg.h"
-
-unsigned char third_argument_force_ref[] = { 3, BYREF_NONE, BYREF_NONE, BYREF_FORCE };
-
-function_entry reg_functions[] = {
- PHP_FE(ereg, third_argument_force_ref)
- PHP_FE(ereg_replace, NULL)
- PHP_FE(eregi, third_argument_force_ref)
- PHP_FE(eregi_replace, NULL)
- PHP_FE(split, NULL)
- PHP_FALIAS(join, implode, NULL)
- PHP_FE(sql_regcase, NULL)
- {NULL, NULL, NULL}
-};
-
-
-static PHP_MINIT_FUNCTION(regex);
-static PHP_MSHUTDOWN_FUNCTION(regex);
-static PHP_MINFO_FUNCTION(regex);
-
-zend_module_entry regexp_module_entry = {
- "Regular Expressions",
- reg_functions,
- PHP_MINIT(regex), PHP_MSHUTDOWN(regex),
- NULL, NULL, PHP_MINFO(regex),
- STANDARD_MODULE_PROPERTIES
-};
-
-#ifdef ZTS
-int reg_globals_id;
-#else
-static php_reg_globals reg_globals;
-#endif
-
-typedef struct {
- regex_t preg;
- int cflags;
-} reg_cache;
-
-static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
-{
- int r = 0;
- int patlen = strlen(pattern);
- reg_cache *rc = NULL;
- REGLS_FETCH();
-
- if(zend_hash_find(&REG(ht_rc), (char *) pattern, patlen+1, (void **) &rc) == FAILURE ||
- rc->cflags != cflags) {
- r = regcomp(preg, pattern, cflags);
- if(!r) {
- reg_cache rcp;
-
- rcp.cflags = cflags;
- memcpy(&rcp.preg, preg, sizeof(*preg));
- zend_hash_update(&REG(ht_rc), (char *) pattern, patlen+1,
- (void *) &rcp, sizeof(rcp), NULL);
- }
- } else {
- memcpy(preg, &rc->preg, sizeof(*preg));
- }
-
- return r;
-}
-
-static int _free_reg_cache(reg_cache *rc)
-{
- regfree(&rc->preg);
- return 1;
-}
-
-#define regfree(a);
-#define regcomp(a,b,c) _php_regcomp(a,b,c)
-
-static void php_reg_init_globals(php_reg_globals *reg_globals)
-{
- zend_hash_init(&reg_globals->ht_rc, 0, NULL, (int (*)(void *)) _free_reg_cache, 1);
-}
-
-static PHP_MINIT_FUNCTION(regex)
-{
-#ifdef ZTS
- reg_globals_id = ts_allocate_id(sizeof(php_reg_globals), php_reg_init_globals, NULL);
-#else
- php_reg_init_globals(&reg_globals);
-#endif
-
- return SUCCESS;
-}
-
-static PHP_MSHUTDOWN_FUNCTION(regex)
-{
- REGLS_FETCH();
-
- zend_hash_destroy(&REG(ht_rc));
- return SUCCESS;
-}
-
-static PHP_MINFO_FUNCTION(regex)
-{
-#if HSREGEX
- PUTS("Bundled regex library enabled\n");
-#else
- PUTS("System regex library enabled\n");
-#endif
-}
-
-
-/* This is the maximum number of (..) constructs we'll generate from a
- call to ereg() or eregi() with the optional third argument. */
-#define NS 10
-
-/*
- * _php3_reg_eprint - convert error number to name
- */
-static void _php3_reg_eprint(int err, regex_t *re) {
- char *buf = NULL, *message = NULL;
- size_t len;
- size_t buf_len;
-
-#ifdef REG_ITOA
- /* get the length of the message */
- buf_len = regerror(REG_ITOA | err, re, NULL, 0);
- if (buf_len) {
- buf = (char *)emalloc(buf_len * sizeof(char));
- if (!buf) return; /* fail silently */
- /* finally, get the error message */
- regerror(REG_ITOA | err, re, buf, buf_len);
- }
-#else
- buf_len = 0;
-#endif
- len = regerror(err, re, NULL, 0);
- if (len) {
- message = (char *)emalloc((buf_len + len + 2) * sizeof(char));
- if (!message) {
- return; /* fail silently */
- }
- if (buf_len) {
- snprintf(message, buf_len, "%s: ", buf);
- buf_len += 1; /* so pointer math below works */
- }
- /* drop the message into place */
- regerror(err, re, message + buf_len, len);
-
- php_error(E_WARNING, "%s", message);
- }
-
- STR_FREE(buf);
- STR_FREE(message);
-}
-
-static void _php3_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
-{
- pval *regex, /* Regular expression */
- *findin, /* String to apply expression to */
- *array = NULL; /* Optional register array */
- regex_t re;
- regmatch_t subs[NS];
- int err, i, match_len, string_len;
- int copts = 0;
- off_t start, end;
- char *buf = NULL;
- char *string = NULL;
-
- if (icase)
- copts |= REG_ICASE;
-
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &regex, &findin) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- /* don't bother doing substring matching if we're not going
- to make use of the information */
- copts |= REG_NOSUB;
- break;
- case 3:
- if (getParameters(ht, 3, &regex, &findin, &array) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- if (!ParameterPassedByReference(ht, 3)) {
- php_error(E_WARNING, "Array to be filled with values must be passed by reference.");
- RETURN_FALSE;
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- }
-
-
- /* compile the regular expression from the supplied regex */
- if (regex->type == IS_STRING) {
- err = regcomp(&re, regex->value.str.val, REG_EXTENDED | copts);
- } else {
- /* we convert numbers to integers and treat them as a string */
- if (regex->type == IS_DOUBLE)
- convert_to_long(regex); /* get rid of decimal places */
- convert_to_string(regex);
- /* don't bother doing an extended regex with just a number */
- err = regcomp(&re, regex->value.str.val, copts);
- }
-
- if (err) {
- _php3_reg_eprint(err, &re);
- RETURN_FALSE;
- }
-
- /* make a copy of the string we're looking in */
- convert_to_string(findin);
- string = estrndup(findin->value.str.val, findin->value.str.len);
-
- /* actually execute the regular expression */
- err = regexec(&re, string, (size_t) NS, subs, 0);
- if (err && err != REG_NOMATCH) {
- _php3_reg_eprint(err, &re);
- regfree(&re);
- RETURN_FALSE;
- }
- match_len = 1;
-
- if (array && err != REG_NOMATCH) {
- match_len = (int) (subs[0].rm_eo - subs[0].rm_so);
- string_len = strlen(string) + 1;
-
- buf = emalloc(string_len);
- if (!buf) {
- php_error(E_WARNING, "Unable to allocate memory in _php3_ereg");
- RETURN_FALSE;
- }
-
- pval_destructor(array); /* start with clean array */
- array_init(array);
-
- for (i = 0; i < NS; i++) {
- start = subs[i].rm_so;
- end = subs[i].rm_eo;
- if (start != -1 && end > 0 && start < string_len && end < string_len && start < end) {
- add_index_stringl(array, i, string+start, end-start, 1);
- }
- }
- efree(buf);
- }
-
- efree(string);
- if (err == REG_NOMATCH) {
- RETVAL_FALSE;
- } else {
- if (match_len == 0)
- match_len = 1;
- RETVAL_LONG(match_len);
- }
- regfree(&re);
-}
-
-/* {{{ proto int ereg(string pattern, string string [, array registers])
- Regular expression match */
-PHP_FUNCTION(ereg)
-{
- _php3_ereg(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ proto int eregi(string pattern, string string [, array registers])
- Case-insensitive regular expression match */
-PHP_FUNCTION(eregi)
-{
- _php3_ereg(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-/* this is the meat and potatoes of regex replacement! */
-char *_php3_regreplace(const char *pattern, const char *replace, const char *string, int icase, int extended)
-{
- regex_t re;
- regmatch_t subs[NS];
-
- char *buf, /* buf is where we build the replaced string */
- *nbuf, /* nbuf is used when we grow the buffer */
- *walkbuf; /* used to walk buf when replacing backrefs */
- const char *walk; /* used to walk replacement string for backrefs */
- int buf_len;
- int pos, tmp, string_len, new_l;
- int err, copts = 0;
-
- string_len = strlen(string);
-
- if (icase)
- copts = REG_ICASE;
- if (extended)
- copts |= REG_EXTENDED;
- err = regcomp(&re, pattern, copts);
- if (err) {
- _php3_reg_eprint(err, &re);
- return ((char *) -1);
- }
-
- /* start with a buffer that is twice the size of the stringo
- we're doing replacements in */
- buf_len = 2 * string_len + 1;
- buf = emalloc(buf_len * sizeof(char));
- if (!buf) {
- php_error(E_WARNING, "Unable to allocate memory in _php3_regreplace");
- regfree(&re);
- return ((char *) -1);
- }
-
- err = pos = 0;
- buf[0] = '\0';
-
- while (!err) {
- err = regexec(&re, &string[pos], (size_t) NS, subs, (pos ? REG_NOTBOL : 0));
-
- if (err && err != REG_NOMATCH) {
- _php3_reg_eprint(err, &re);
- regfree(&re);
- return ((char *) -1);
- }
- if (!err) {
- /* backref replacement is done in two passes:
- 1) find out how long the string will be, and allocate buf
- 2) copy the part before match, replacement and backrefs to buf
-
- Jaakko Hyvätti <Jaakko.Hyvatti@iki.fi>
- */
-
- new_l = strlen(buf) + subs[0].rm_so; /* part before the match */
- walk = replace;
- while (*walk)
- if ('\\' == *walk
- && '0' <= walk[1] && '9' >= walk[1]
- && subs[walk[1] - '0'].rm_so > -1
- && subs[walk[1] - '0'].rm_eo > -1) {
- new_l += subs[walk[1] - '0'].rm_eo
- - subs[walk[1] - '0'].rm_so;
- walk += 2;
- } else {
- new_l++;
- walk++;
- }
-
- if (new_l + 1 > buf_len) {
- buf_len = 1 + buf_len + 2 * new_l;
- nbuf = emalloc(buf_len);
- strcpy(nbuf, buf);
- efree(buf);
- buf = nbuf;
- }
- tmp = strlen(buf);
- /* copy the part of the string before the match */
- strncat(buf, &string[pos], subs[0].rm_so);
-
- /* copy replacement and backrefs */
- walkbuf = &buf[tmp + subs[0].rm_so];
- walk = replace;
- while (*walk)
- if ('\\' == *walk
- && '0' <= walk[1] && '9' >= walk[1]
- && subs[walk[1] - '0'].rm_so > -1
- && subs[walk[1] - '0'].rm_eo > -1) {
- tmp = subs[walk[1] - '0'].rm_eo
- - subs[walk[1] - '0'].rm_so;
- memcpy (walkbuf,
- &string[pos + subs[walk[1] - '0'].rm_so],
- tmp);
- walkbuf += tmp;
- walk += 2;
- } else
- *walkbuf++ = *walk++;
- *walkbuf = '\0';
-
- /* and get ready to keep looking for replacements */
- if (subs[0].rm_so == subs[0].rm_eo) {
- if (subs[0].rm_so + pos >= string_len)
- break;
- new_l = strlen (buf) + 1;
- if (new_l + 1 > buf_len) {
- buf_len = 1 + buf_len + 2 * new_l;
- nbuf = emalloc(buf_len * sizeof(char));
- strcpy(nbuf, buf);
- efree(buf);
- buf = nbuf;
- }
- pos += subs[0].rm_eo + 1;
- buf [new_l-1] = string [pos-1];
- buf [new_l] = '\0';
- } else {
- pos += subs[0].rm_eo;
- }
- } else { /* REG_NOMATCH */
- new_l = strlen(buf) + strlen(&string[pos]);
- if (new_l + 1 > buf_len) {
- buf_len = new_l + 1; /* now we know exactly how long it is */
- nbuf = emalloc(buf_len * sizeof(char));
- strcpy(nbuf, buf);
- efree(buf);
- buf = nbuf;
- }
- /* stick that last bit of string on our output */
- strcat(buf, &string[pos]);
- }
- }
-
- /* don't want to leak memory .. */
- regfree(&re);
-
- /* whew. */
- return (buf);
-}
-
-static void _php3_eregreplace(INTERNAL_FUNCTION_PARAMETERS, int icase)
-{
- pval *arg_pattern,
- *arg_replace,
- *arg_string;
- char *pattern;
- char *string;
- char *replace;
- char *ret;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg_pattern, &arg_replace, &arg_string) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (arg_pattern->type == IS_STRING) {
- if (arg_pattern->value.str.val && arg_pattern->value.str.len)
- pattern = estrndup(arg_pattern->value.str.val,arg_pattern->value.str.len);
- else
- pattern = empty_string;
- } else {
- convert_to_long(arg_pattern);
- pattern = emalloc(2);
- pattern[0] = (char) arg_pattern->value.lval;
- pattern[1] = '\0';
- }
-
- if (arg_replace->type == IS_STRING) {
- if (arg_replace->value.str.val && arg_replace->value.str.len)
- replace = estrndup(arg_replace->value.str.val, arg_replace->value.str.len);
- else
- replace = empty_string;
- } else {
- convert_to_long(arg_replace);
- replace = emalloc(2);
- replace[0] = (char) arg_replace->value.lval;
- replace[1] = '\0';
- }
-
- convert_to_string(arg_string);
- if (arg_string->value.str.val && arg_string->value.str.len)
- string = estrndup(arg_string->value.str.val, arg_string->value.str.len);
- else
- string = empty_string;
-
- /* do the actual work */
- ret = _php3_regreplace(pattern, replace, string, icase, 1);
- if (ret == (char *) -1) {
- RETVAL_FALSE;
- } else {
- RETVAL_STRING(ret,1);
- STR_FREE(ret);
- }
- STR_FREE(string);
- STR_FREE(replace);
- STR_FREE(pattern);
-}
-
-/* {{{ proto string ereg_replace(string pattern, string string [, array registers])
- Replace regular expression */
-PHP_FUNCTION(ereg_replace)
-{
- _php3_eregreplace(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ proto string eregi_replace(string pattern, string string [, array registers])
- Case insensitive replace regular expression */
-PHP_FUNCTION(eregi_replace)
-{
- _php3_eregreplace(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-/* ("root", "passwd", "uid", "gid", "other:stuff:like:/bin/sh")
- = split(":", $passwd_file, 5); */
-/* {{{ proto array split(string pattern, string string [, int limit])
- split string into array by regular expression */
-PHP_FUNCTION(split)
-{
- pval *spliton, *str, *arg_count = NULL;
- regex_t re;
- regmatch_t subs[1];
- char *strp, *endp;
- int err, size, count;
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &spliton, &str) == FAILURE)
- WRONG_PARAM_COUNT;
- count = -1;
- break;
- case 3:
- if (getParameters(ht, 3, &spliton, &str, &arg_count) == FAILURE)
- WRONG_PARAM_COUNT;
- convert_to_long(arg_count);
- count = arg_count->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(spliton);
- convert_to_string(str);
-
- strp = str->value.str.val;
- endp = str->value.str.val + strlen(str->value.str.val);
-
- err = regcomp(&re, spliton->value.str.val, REG_EXTENDED);
- if (err) {
- php_error(E_WARNING, "unexpected regex error (%d)", err);
- RETURN_FALSE;
- }
-
- if (array_init(return_value) == FAILURE) {
- regfree(&re);
- RETURN_FALSE;
- }
-
- /* churn through str, generating array entries as we go */
- while ((count == -1 || count > 1) && !(err = regexec(&re, strp, 1, subs, 0))) {
- if (subs[0].rm_so == 0 && subs[0].rm_eo) {
- /* match is at start of string, return empty string */
- add_next_index_stringl(return_value, empty_string, 0, 1);
- /* skip ahead the length of the regex match */
- strp+=subs[0].rm_eo;
- } else if (subs[0].rm_so==0 && subs[0].rm_eo==0) {
- /* No more matches */
- regfree(&re);
- php_error(E_WARNING, "bad regular expression for split()");
- zend_hash_destroy(return_value->value.ht);
- efree(return_value->value.ht);
- RETURN_FALSE;
- } else {
- /* On a real match */
-
- /* make a copy of the substring */
- size = subs[0].rm_so;
-
- /* add it to the array */
- add_next_index_stringl(return_value, strp, size, 1);
-
- /* point at our new starting point */
- strp = strp + subs[0].rm_eo;
- }
-
- /* if we're only looking for a certain number of points,
- stop looking once we hit it */
- if (count != -1) {
- count--;
- }
- }
-
- /* see if we encountered an error */
- if (err && err != REG_NOMATCH) {
- php_error(E_WARNING, "unexpected regex error (%d)", err);
- regfree(&re);
- zend_hash_destroy(return_value->value.ht);
- efree(return_value->value.ht);
- RETURN_FALSE;
- }
-
- /* otherwise we just have one last element to add to the array */
- size = endp - strp;
-
- add_next_index_stringl(return_value, strp, size, 1);
-
- regfree(&re);
-
- return;
-}
-/* }}} */
-
-/* {{{ proto string sql_regcase(string string)
- Make regular expression for case insensitive match */
-PHPAPI PHP_FUNCTION(sql_regcase)
-{
- pval *string;
- char *tmp;
- unsigned char c;
- register int i, j;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &string)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(string);
-
- tmp = (char *) emalloc(string->value.str.len*4+1);
-
- for (i=j=0; i<string->value.str.len; i++) {
- c = (unsigned char) string->value.str.val[i];
- if(isalpha(c)) {
- tmp[j++] = '[';
- tmp[j++] = toupper(c);
- tmp[j++] = tolower(c);
- tmp[j++] = ']';
- } else {
- tmp[j++] = c;
- }
- }
- tmp[j]=0;
-
- tmp = erealloc(tmp, j + 1);
-
- RETVAL_STRINGL(tmp, j, 0);
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/reg.h b/ext/standard/reg.h
deleted file mode 100644
index c261abf4d2..0000000000
--- a/ext/standard/reg.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _REG_H
-#define _REG_H
-
-extern php3_module_entry regexp_module_entry;
-#define regexp_module_ptr &regexp_module_entry
-
-char *_php3_regreplace(const char *pattern, const char *replace, const char *string, int icase, int extended);
-
-PHP_FUNCTION(ereg);
-PHP_FUNCTION(eregi);
-PHP_FUNCTION(eregi_replace);
-PHP_FUNCTION(ereg_replace);
-PHP_FUNCTION(split);
-PHPAPI PHP_FUNCTION(sql_regcase);
-
-typedef struct {
- HashTable ht_rc;
-} php_reg_globals;
-
-
-#ifdef ZTS
-#define REGLS_D php_reg_globals *reg_globals
-#define REGLS_DC , REGLS_D
-#define REGLS_C reg_globals
-#define REGLS_CC , REGLS_C
-#define REG(v) (reg_globals->v)
-#define REGLS_FETCH() php_reg_globals *reg_globals = ts_resource(reg_globals_id)
-#else
-#define REGLS_D
-#define REGLS_DC
-#define REGLS_C
-#define REGLS_CC
-#define REG(v) (reg_globals.v)
-#define REGLS_FETCH()
-#endif
-
-#define phpext_regex_ptr regexp_module_ptr
-
-#endif /* _REG_H */
diff --git a/ext/standard/soundex.c b/ext/standard/soundex.c
deleted file mode 100644
index 1d855b412b..0000000000
--- a/ext/standard/soundex.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Bjørn Borud - Guardian Networks AS <borud@guardian.no> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include "php.h"
-#include <stdlib.h>
-#include <errno.h>
-#include <ctype.h>
-#include "php3_string.h"
-
-/* Simple soundex algorithm as described by Knuth in TAOCP, vol 3 */
-/* {{{ proto string soundex(string str)
- Calculate the soundex key of a string */
-PHP_FUNCTION(soundex)
-{
- char *somestring;
- int i, _small, len, code, last;
- pval *arg;
- char soundex[4 + 1];
-
- static char soundex_table[26] =
- {0, /* A */
- '1', /* B */
- '2', /* C */
- '3', /* D */
- 0, /* E */
- '1', /* F */
- '2', /* G */
- 0, /* H */
- 0, /* I */
- '2', /* J */
- '2', /* K */
- '4', /* L */
- '5', /* M */
- '5', /* N */
- 0, /* O */
- '1', /* P */
- '2', /* Q */
- '6', /* R */
- '2', /* S */
- '3', /* T */
- 0, /* U */
- '1', /* V */
- 0, /* W */
- '2', /* X */
- 0, /* Y */
- '2'}; /* Z */
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
- if (arg->value.str.len==0) {
- RETURN_FALSE;
- }
- somestring = arg->value.str.val;
- len = arg->value.str.len;
-
- /* build soundex string */
- last = -1;
- for (i = 0, _small = 0; i < len && _small < 4; i++) {
- /* convert chars to upper case and strip non-letter chars */
- /* BUG: should also map here accented letters used in non */
- /* English words or names (also found in English text!): */
- /* esstsett, thorn, n-tilde, c-cedilla, s-caron, ... */
- code = toupper(somestring[i]);
- if (code >= 'A' && code <= 'Z') {
- if (_small == 0) {
- /* remember first valid char */
- soundex[_small++] = code;
- last = soundex_table[code - 'A'];
- }
- else {
- /* ignore sequences of consonants with same soundex */
- /* code in trail, and vowels unless they separate */
- /* consonant letters */
- code = soundex_table[code - 'A'];
- if (code != last) {
- if (code != 0) {
- soundex[_small++] = code;
- }
- last = code;
- }
- }
- }
- }
- /* pad with '0' and terminate with 0 ;-) */
- while (_small < 4) {
- soundex[_small++] = '0';
- }
- soundex[_small] = '\0';
-
- return_value->value.str.val = estrndup(soundex, _small);
- return_value->value.str.len = _small;
- return_value->type = IS_STRING;
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/string.c b/ext/standard/string.c
deleted file mode 100644
index 2e26fa46fd..0000000000
--- a/ext/standard/string.c
+++ /dev/null
@@ -1,1992 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Stig Sæther Bakken <ssb@fast.no> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/* Synced with php3 revision 1.193 1999-06-16 [ssb] */
-
-#include <stdio.h>
-#include "php.h"
-#include "reg.h"
-#include "post.h"
-#include "php3_string.h"
-#ifdef HAVE_LOCALE_H
-# include <locale.h>
-#endif
-#include "zend_execute.h"
-#include "php_globals.h"
-
-static char hexconvtab[] = "0123456789abcdef";
-
-static char *php_bin2hex(const unsigned char *old, const size_t oldlen, size_t *newlen)
-{
- unsigned char *new = NULL;
- size_t i, j;
-
- new = (char *) emalloc(oldlen * 2 * sizeof(char));
- if(!new) {
- return new;
- }
-
- for(i = j = 0; i < oldlen; i++) {
- new[j++] = hexconvtab[old[i] >> 4];
- new[j++] = hexconvtab[old[i] & 15];
- }
-
- if(newlen) *newlen = oldlen * 2 * sizeof(char);
-
- return new;
-}
-
-/* proto bin2hex(string data)
- converts the binary representation of data to hex */
-PHP_FUNCTION(bin2hex)
-{
- pval *data;
- char *new;
- size_t newlen;
-
- if(ARG_COUNT(ht) != 1 || getParameters(ht, 1, &data) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(data);
-
- new = php_bin2hex(data->value.str.val, data->value.str.len, &newlen);
-
- if(!new) {
- RETURN_FALSE;
- }
-
- RETURN_STRINGL(new, newlen, 0);
-}
-
-/* {{{ proto int strlen(string str)
- Get string length */
-PHP_FUNCTION(strlen)
-{
- pval **str;
-
- if (ARG_COUNT(ht) != 1 || getParametersEx(1, &str) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string_ex(str);
- RETVAL_LONG((*str)->value.str.len);
-}
-/* }}} */
-
-/* {{{ proto int strcmp(string str1, string str2)
- Binary safe string comparison */
-PHP_FUNCTION(strcmp)
-{
- pval *s1,*s2;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &s1, &s2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(s1);
- convert_to_string(s2);
- RETURN_LONG(php3_binary_strcmp(s1,s2));
-}
-/* }}} */
-
-/* {{{ proto int strcasecmp(string str1, string str2)
- Binary safe case-insensitive string comparison */
-PHP_FUNCTION(strcasecmp)
-{
- pval *s1,*s2;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &s1, &s2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(s1);
- convert_to_string(s2);
- RETURN_LONG(zend_binary_strcasecmp(s1, s2));
-}
-/* }}} */
-
-/* {{{ proto int strspn(string str, string mask)
- Find length of initial segment consisting entirely of characters found in mask */
-PHP_FUNCTION(strspn)
-{
- pval *s1,*s2;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &s1, &s2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(s1);
- convert_to_string(s2);
- RETURN_LONG(strspn(s1->value.str.val,s2->value.str.val));
-}
-/* }}} */
-
-/* {{{ proto int strcspn(string str, string mask)
- Find length of initial segment consisting entirely of characters not found in mask */
-PHP_FUNCTION(strcspn)
-{
- pval *s1,*s2;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &s1, &s2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(s1);
- convert_to_string(s2);
- RETURN_LONG(strcspn(s1->value.str.val,s2->value.str.val));
-}
-/* }}} */
-
-PHPAPI void _php3_trim(pval *str, pval * return_value, int mode)
-/* mode 1 : trim left
- mode 2 : trim right
- mode 3 : trim left and right
-*/
-{
- register int i;
- int len = str->value.str.len;
- int trimmed = 0;
- char *c = str->value.str.val;
-
- if (mode & 1) {
- for (i = 0; i < len; i++) {
- if (c[i] == ' ' || c[i] == '\n' || c[i] == '\r' ||
- c[i] == '\t' || c[i] == '\v') {
- trimmed++;
- } else {
- break;
- }
- }
- len -= trimmed;
- c += trimmed;
- }
- if (mode & 2) {
- for (i = len - 1; i >= 0; i--) {
- if (c[i] == ' ' || c[i] == '\n' || c[i] == '\r' ||
- c[i] == '\t' || c[i] == '\v') {
- len--;
- } else {
- break;
- }
- }
- }
- RETVAL_STRINGL(c, len, 1);
-}
-
-/* {{{ proto string rtrim(string str)
- An alias for chop */
-/* }}} */
-
-/* {{{ proto string chop(string str)
- Remove trailing whitespace */
-PHP_FUNCTION(chop)
-{
- pval *str;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str);
-
- if (str->type == IS_STRING) {
- _php3_trim(str, return_value, 2);
- return;
- }
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto string trim(string str)
- Strip whitespace from the beginning and end of a string */
-PHP_FUNCTION(trim)
-{
- pval *str;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str);
-
- if (str->type == IS_STRING) {
- _php3_trim(str, return_value, 3);
- return;
- }
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto string ltrim(string str)
- Strip whitespace from the beginning of a string */
-PHP_FUNCTION(ltrim)
-{
- pval *str;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str);
- if (str->type == IS_STRING) {
- _php3_trim(str, return_value, 1);
- return;
- }
- RETURN_FALSE;
-}
-/* }}} */
-
-void _php3_explode(pval *delim, pval *str, pval *return_value)
-{
- char *work_str, *p1, *p2;
- int i = 0;
-
- work_str = p1 = estrndup(str->value.str.val,str->value.str.len);
- p2 = strstr(p1, delim->value.str.val);
- if (p2 == NULL) {
- add_index_string(return_value, i++, p1, 1);
- } else do {
- p2[0] = 0;
- add_index_string(return_value, i++, p1, 1);
- p1 = p2 + delim->value.str.len;
- } while ((p2 = strstr(p1, delim->value.str.val)) && p2 != work_str);
- if (p1 != work_str) {
- add_index_string(return_value, i++, p1, 1);
- }
- efree(work_str);
-}
-
-/* {{{ proto array explode(string separator, string str)
- Split a string on string separator and return array of components */
-PHP_FUNCTION(explode)
-{
- pval *str, *delim;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &delim, &str) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str);
- convert_to_string(delim);
-
- if (strlen(delim->value.str.val)==0) {
- /* the delimiter must be a valid C string that's at least 1 character long */
- php_error(E_WARNING,"Empty delimiter");
- RETURN_FALSE;
- }
- if (array_init(return_value) == FAILURE) {
- return;
- }
- _php3_explode(delim, str, return_value);
-}
-/* }}} */
-
-/* {{{ proto string join(array src, string glue)
- An alias for implode */
-/* }}} */
-
-void _php3_implode(pval *delim, pval *arr, pval *return_value)
-{
- pval **tmp;
- int len = 0, count = 0;
-
- /* convert everything to strings, and calculate length */
- zend_hash_internal_pointer_reset(arr->value.ht);
- while (zend_hash_get_current_data(arr->value.ht, (void **) &tmp) == SUCCESS) {
- SEPARATE_ZVAL(tmp);
- convert_to_string(*tmp);
- if ((*tmp)->type == IS_STRING && (*tmp)->value.str.val != undefined_variable_string) {
- len += (*tmp)->value.str.len;
- if (count>0) {
- len += delim->value.str.len;
- }
- count++;
- }
- zend_hash_move_forward(arr->value.ht);
- }
-
- /* do it */
- return_value->value.str.val = (char *) emalloc(len + 1);
- return_value->value.str.val[0] = '\0';
- return_value->value.str.val[len] = '\0';
- zend_hash_internal_pointer_reset(arr->value.ht);
- while (zend_hash_get_current_data(arr->value.ht, (void **) &tmp) == SUCCESS) {
- if ((*tmp)->type == IS_STRING && (*tmp)->value.str.val != undefined_variable_string) {
- count--;
- strcat(return_value->value.str.val, (*tmp)->value.str.val);
- if (count > 0) {
- strcat(return_value->value.str.val, delim->value.str.val);
- }
- }
- zend_hash_move_forward(arr->value.ht);
- }
- return_value->type = IS_STRING;
- return_value->value.str.len = len;
-}
-
-
-/* {{{ proto string implode(array src, string glue)
- Join array elements placing glue string between items and return one string */
-PHP_FUNCTION(implode)
-{
- pval *arg1, *arg2, *delim, *arr;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (arg1->type == IS_ARRAY && arg2->type == IS_STRING) {
- arr = arg1;
- delim = arg2;
- } else if (arg2->type == IS_ARRAY) {
- convert_to_string(arg1);
- arr = arg2;
- delim = arg1;
- } else {
- php_error(E_WARNING, "Bad arguments to %s()",
- get_active_function_name());
- return;
- }
- _php3_implode(delim, arr, return_value);
-}
-/* }}} */
-
-
-#ifndef THREAD_SAFE
-char *strtok_string;
-#endif
-
-/* {{{ proto string strtok([string str,] string token)
- Tokenize a string */
-PHP_FUNCTION(strtok)
-{
- pval *str, *tok;
-#ifndef THREAD_SAFE
- static char *strtok_pos1 = NULL;
- static char *strtok_pos2 = NULL;
-#endif
- char *token = NULL, *tokp=NULL;
- char *first = NULL;
- int argc;
-
- argc = ARG_COUNT(ht);
-
- if ((argc == 1 && getParameters(ht, 1, &tok) == FAILURE) ||
- (argc == 2 && getParameters(ht, 2, &str, &tok) == FAILURE) ||
- argc < 1 || argc > 2) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(tok);
- tokp = token = tok->value.str.val;
-
- if (argc == 2) {
- convert_to_string(str);
-
- STR_FREE(strtok_string);
- strtok_string = estrndup(str->value.str.val,str->value.str.len);
- strtok_pos1 = strtok_string;
- strtok_pos2 = NULL;
- }
- if (strtok_pos1 && *strtok_pos1) {
- for ( /* NOP */ ; token && *token; token++) {
- strtok_pos2 = strchr(strtok_pos1, (int) *token);
- if (!first || (strtok_pos2 && strtok_pos2 < first)) {
- first = strtok_pos2;
- }
- } /* NB: token is unusable now */
-
- strtok_pos2 = first;
- if (strtok_pos2) {
- *strtok_pos2 = '\0';
- }
- RETVAL_STRING(strtok_pos1,1);
-#if 0
- /* skip 'token' white space for next call to strtok */
- while (strtok_pos2 &&
- strchr(tokp, *(strtok_pos2+1))) {
- strtok_pos2++;
- }
-#endif
- if (strtok_pos2)
- strtok_pos1 = strtok_pos2 + 1;
- else
- strtok_pos1 = NULL;
- } else {
- RETVAL_FALSE;
- }
-}
-/* }}} */
-
-PHPAPI char *_php3_strtoupper(char *s)
-{
- char *c;
- int ch;
-
- c = s;
- while (*c) {
- ch = toupper((unsigned char)*c);
- *c++ = ch;
- }
- return (s);
-}
-
-/* {{{ proto string strtoupper(string str)
- Make a string uppercase */
-PHP_FUNCTION(strtoupper)
-{
- pval *arg;
- char *ret;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg)) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
-
- ret = _php3_strtoupper(arg->value.str.val);
- RETVAL_STRING(ret,1);
-}
-/* }}} */
-
-
-PHPAPI char *_php3_strtolower(char *s)
-{
- register int ch;
- char *c;
-
- c = s;
- while (*c) {
- ch = tolower((unsigned char)*c);
- *c++ = ch;
- }
- return (s);
-}
-
-/* {{{ proto string strtolower(string str)
- Make a string lowercase */
-PHP_FUNCTION(strtolower)
-{
- pval *str;
- char *ret;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str)) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str);
-
- ret = _php3_strtolower(str->value.str.val);
- RETVAL_STRING(ret,1);
-}
-/* }}} */
-
-/* {{{ proto string basename(string path)
- Return the filename component of the path */
-PHP_FUNCTION(basename)
-{
- pval *str;
- char *ret, *c;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str)) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str);
- ret = estrdup(str->value.str.val);
- c = ret + str->value.str.len -1;
- while (*c == '/'
-#ifdef MSVC5
- || *c == '\\'
-#endif
- )
- c--;
- *(c + 1) = '\0';
- if ((c = strrchr(ret, '/'))
-#ifdef MSVC5
- || (c = strrchr(ret, '\\'))
-#endif
- ) {
- RETVAL_STRING(c + 1,1);
- } else {
- RETVAL_STRING(str->value.str.val,1);
- }
- efree(ret);
-}
-/* }}} */
-
-PHPAPI void _php3_dirname(char *str, int len) {
- register char *c;
-
- c = str + len - 1;
- while (*c == '/'
-#ifdef MSVC5
- || *c == '\\'
-#endif
- )
- c--; /* strip trailing slashes */
- *(c + 1) = '\0';
- if ((c = strrchr(str, '/'))
-#ifdef MSVC5
- || (c = strrchr(str, '\\'))
-#endif
- )
- *c='\0';
-}
-
-/* {{{ proto string dirname(string path)
- Return the directory name component of the path */
-PHP_FUNCTION(dirname)
-{
- pval *str;
- char *ret;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str)) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str);
- ret = estrdup(str->value.str.val);
- _php3_dirname(ret,str->value.str.len);
- RETVAL_STRING(ret,1);
- efree(ret);
-}
-/* }}} */
-
-
-/* case insensitve strstr */
-PHPAPI char *php3i_stristr(unsigned char *s, unsigned char *t)
-{
- int i, j, k, l;
-
- for (i = 0; s[i]; i++) {
- for (j = 0, l = k = i; s[k] && t[j] &&
- tolower(s[k]) == tolower(t[j]); j++, k++)
- ;
- if (t[j] == '\0')
- return s + l;
- }
- return NULL;
-}
-
-/* {{{ proto string stristr(string haystack, string needle)
- Find first occurrence of a string within another, case insensitive */
-PHP_FUNCTION(stristr)
-{
- pval *haystack, *needle;
- char *found = NULL;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &haystack, &needle) ==
- FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(haystack);
- convert_to_string(needle);
-
- if (strlen(needle->value.str.val)==0) {
- php_error(E_WARNING,"Empty delimiter");
- RETURN_FALSE;
- }
- found = php3i_stristr(haystack->value.str.val, needle->value.str.val);
-
- if (found) {
- RETVAL_STRING(found,1);
- } else {
- RETVAL_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto string strstr(string haystack, string needle)
- Find first occurrence of a string within another */
-PHP_FUNCTION(strstr)
-{
- pval *haystack, *needle;
- char *found = NULL;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &haystack, &needle) ==
- FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(haystack);
-
- if (needle->type == IS_STRING) {
- if (strlen(needle->value.str.val)==0) {
- php_error(E_WARNING,"Empty delimiter");
- RETURN_FALSE;
- }
- found = strstr(haystack->value.str.val, needle->value.str.val);
- } else {
- convert_to_long(needle);
- found = strchr(haystack->value.str.val, (char) needle->value.lval);
- }
-
-
- if (found) {
- RETVAL_STRING(found,1);
- } else {
- RETVAL_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto string strchr(string haystack, string needle)
- An alias for strstr */
-/* }}} */
-
-/* {{{ proto int strpos(string haystack, string needle [, int offset])
- Find position of first occurrence of a string within another */
-PHP_FUNCTION(strpos)
-{
- pval *haystack, *needle, *OFFSET;
- int offset = 0;
- char *found = NULL;
-
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &haystack, &needle) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 3:
- if (getParameters(ht, 3, &haystack, &needle, &OFFSET) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(OFFSET);
- offset = OFFSET->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- }
- convert_to_string(haystack);
- if (offset > haystack->value.str.len) {
- php_error(E_WARNING,"offset not contained in string");
- RETURN_FALSE;
- }
-
- if (needle->type == IS_STRING) {
- if (needle->value.str.len==0) {
- php_error(E_WARNING,"Empty delimiter");
- RETURN_FALSE;
- }
- found = strstr(haystack->value.str.val+offset, needle->value.str.val);
- } else {
- convert_to_long(needle);
- found = strchr(haystack->value.str.val+offset, (char) needle->value.lval);
- }
-
- if (found) {
- RETVAL_LONG(found - haystack->value.str.val);
- } else {
- RETVAL_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int strrpos(string haystack, string needle)
- Find the last occurrence of a character in a string within another */
-PHP_FUNCTION(strrpos)
-{
- pval *haystack, *needle;
- char *found = NULL;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &haystack, &needle) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(haystack);
-
- if (needle->type == IS_STRING) {
- found = strrchr(haystack->value.str.val, *needle->value.str.val);
- } else {
- convert_to_long(needle);
- found = strrchr(haystack->value.str.val, (char) needle->value.lval);
- }
-
- if (found) {
- RETVAL_LONG(haystack->value.str.len - strlen(found));
- } else {
- RETVAL_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto string strrchr(string haystack, string needle)
- Find the last occurrence of a character in a string within another */
-PHP_FUNCTION(strrchr)
-{
- pval *haystack, *needle;
- char *found = NULL;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &haystack, &needle) ==
- FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(haystack);
-
- if (needle->type == IS_STRING) {
- found = strrchr(haystack->value.str.val, *needle->value.str.val);
- } else {
-
- convert_to_long(needle);
- found = strrchr(haystack->value.str.val, needle->value.lval);
- }
-
-
- if (found) {
- RETVAL_STRING(found,1);
- } else {
- RETVAL_FALSE;
- }
-}
-/* }}} */
-
-static char *
-_php3_chunk_split(char *src, int srclen, char *end, int endlen,
- int chunklen, int *destlen)
-{
- char *dest;
- char *p, *q;
- int chunks; /* complete chunks! */
- int restlen;
-
- chunks = srclen / chunklen;
- restlen = srclen - chunks * chunklen; /* srclen % chunklen */
-
- dest = emalloc((srclen + (chunks + 1) * endlen + 1) * sizeof(char));
-
- for(p = src, q = dest; p < (src + srclen - chunklen + 1); ) {
- memcpy(q, p, chunklen);
- q += chunklen;
- memcpy(q, end, endlen);
- q += endlen;
- p += chunklen;
- }
-
- if(restlen) {
- memcpy(q, p, restlen);
- q += restlen;
- memcpy(q, end, endlen);
- q += endlen;
- }
-
- *q = '\0';
- if (destlen) {
- *destlen = q - dest;
- }
-
- return(dest);
-}
-
-/* {{{ proto string chunk_split(string str [, int chunklen [, string ending]])
- Return split line */
-PHP_FUNCTION(chunk_split)
-{
- pval *p_str, *p_chunklen, *p_ending;
- int argc;
- char *result;
- char *end = "\r\n";
- int endlen = 2;
- int chunklen = 76;
- int result_len;
-
- argc = ARG_COUNT(ht);
-
- if (argc < 1 || argc > 3 ||
- getParameters(ht, argc, &p_str, &p_chunklen, &p_ending) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- switch(argc) {
- case 3:
- convert_to_string(p_ending);
- end = p_ending->value.str.val;
- endlen = p_ending->value.str.len;
- case 2:
- convert_to_long(p_chunklen);
- chunklen = p_chunklen->value.lval;
- case 1:
- convert_to_string(p_str);
- }
-
- if(chunklen == 0) {
- php_error(E_WARNING, "chunk length is 0");
- RETURN_FALSE;
- }
-
- result = _php3_chunk_split(p_str->value.str.val, p_str->value.str.len,
- end, endlen, chunklen, &result_len);
-
- if(result) {
- RETVAL_STRINGL(result, result_len, 0);
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto string substr(string str, int start [, int length])
- Return part of a string */
-PHP_FUNCTION(substr)
-{
- pval *string, *from, *len;
- int argc, l;
- int f;
-
- argc = ARG_COUNT(ht);
-
- if ((argc == 2 && getParameters(ht, 2, &string, &from) == FAILURE) ||
- (argc == 3 && getParameters(ht, 3, &string, &from, &len) == FAILURE) ||
- argc < 2 || argc > 3) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(string);
- convert_to_long(from);
- f = from->value.lval;
-
- if (argc == 2) {
- l = string->value.str.len;
- } else {
- convert_to_long(len);
- l = len->value.lval;
- }
-
- /* if "from" position is negative, count start position from the end
- * of the string
- */
- if (f < 0) {
- f = string->value.str.len + f;
- if (f < 0) {
- f = 0;
- }
- }
-
- /* if "length" position is negative, set it to the length
- * needed to stop that many chars from the end of the string
- */
- if (l < 0) {
- l = (string->value.str.len - f) + l;
- if (l < 0) {
- l = 0;
- }
- }
-
- if (f >= (int)string->value.str.len) {
- RETURN_FALSE;
- }
-
- if((f+l) > (int)string->value.str.len) {
- l = (int)string->value.str.len - f;
- }
-
- RETVAL_STRINGL(string->value.str.val + f, l, 1);
-}
-/* }}} */
-
-/* {{{ proto string quotemeta(string str)
- Quote meta characters */
-PHP_FUNCTION(quotemeta)
-{
- pval *arg;
- char *str, *old;
- char *p, *q;
- char c;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
-
- old = arg->value.str.val;
-
- if (!*old) {
- RETURN_FALSE;
- }
-
- str = emalloc(2 * arg->value.str.len + 1);
-
- for(p = old, q = str; (c = *p); p++) {
- switch(c) {
- case '.':
- case '\\':
- case '+':
- case '*':
- case '?':
- case '[':
- case '^':
- case ']':
- case '$':
- case '(':
- case ')':
- *q++ = '\\';
- /* break is missing _intentionally_ */
- default:
- *q++ = c;
- }
- }
- *q = 0;
- RETVAL_STRING(erealloc(str, q - str + 1), 0);
-}
-/* }}} */
-
-/* {{{ proto int ord(string character)
- Return ASCII value of character */
-PHP_FUNCTION(ord)
-{
- pval *str;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str);
- RETVAL_LONG((unsigned char)str->value.str.val[0]);
-}
-/* }}} */
-
-/* {{{ proto string chr(int ascii)
- Convert ASCII code to a character */
-PHP_FUNCTION(chr)
-{
- pval *num;
- char temp[2];
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &num) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(num);
- temp[0] = (char) num->value.lval;
- temp[1] = '\0';
- RETVAL_STRINGL(temp, 1,1);
-}
-/* }}} */
-
-/* {{{ proto string ucfirst(string str)
- Make a string's first character uppercase */
-PHP_FUNCTION(ucfirst)
-{
- pval *arg;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
-
- if (!*arg->value.str.val) {
- RETURN_FALSE;
- }
- *arg->value.str.val = toupper((unsigned char)*arg->value.str.val);
- RETVAL_STRING(arg->value.str.val,1);
-}
-/* }}} */
-
-/* {{{ proto string ucwords(string str)
- Uppercase the first character of every word in a string */
-PHP_FUNCTION(ucwords)
-{
- pval *arg;
- char *r;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
-
- if (!*arg->value.str.val) {
- RETURN_FALSE;
- }
- *arg->value.str.val = toupper((unsigned char)*arg->value.str.val);
- r=arg->value.str.val;
- while((r=strstr(r," "))){
- if(*(r+1)){
- r++;
- *r=toupper((unsigned char)*r);
- } else {
- break;
- }
- }
- RETVAL_STRING(arg->value.str.val,1);
-}
-/* }}} */
-
-PHPAPI char *_php3_strtr(char *string, int len, char *str_from,
- char *str_to, int trlen)
-{
- int i;
- unsigned char xlat[256];
-
- if ((trlen < 1) || (len < 1)) {
- return string;
- }
-
- for (i = 0; i < 256; xlat[i] = i, i++);
-
- for (i = 0; i < trlen; i++) {
- xlat[(unsigned char) str_from[i]] = str_to[i];
- }
-
- for (i = 0; i < len; i++) {
- string[i] = xlat[(unsigned char) string[i]];
- }
-
- return string;
-}
-
-/* {{{ proto string strtr(string str, string from, string to)
- Translate characters in str using given translation tables */
-PHP_FUNCTION(strtr)
-{ /* strtr(STRING,FROM,TO) */
- pval *str, *from, *to;
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &str, &from, &to) ==
- FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str);
- convert_to_string(from);
- convert_to_string(to);
-
- RETVAL_STRING(_php3_strtr(str->value.str.val,
- str->value.str.len,
- from->value.str.val,
- to->value.str.val,
- MIN(from->value.str.len,to->value.str.len)),
- 1);
-}
-/* }}} */
-
-
-/* {{{ proto string strrev(string str)
- Reverse a string */
-PHP_FUNCTION(strrev)
-{
- pval *str;
- int i,len;
- char c;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &str)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(str);
-
- len = str->value.str.len;
-
- for (i=0; i<len-1-i; i++) {
- c=str->value.str.val[i];
- str->value.str.val[i] = str->value.str.val[len-1-i];
- str->value.str.val[len-1-i]=c;
- }
-
- *return_value = *str;
- pval_copy_constructor(return_value);
-}
-/* }}} */
-
-static void _php3_similar_str(const char *txt1, int len1, const char *txt2,
- int len2, int *pos1, int *pos2, int *max)
-{
- char *p, *q;
- char *end1 = (char *) txt1 + len1;
- char *end2 = (char *) txt2 + len2;
- int l;
-
- *max = 0;
- for (p = (char *) txt1; p < end1; p++) {
- for (q = (char *) txt2; q < end2; q++) {
- for (l = 0; (p + l < end1) && (q + l < end2) && (p[l] == q[l]);
- l++);
- if (l > *max) {
- *max = l;
- *pos1 = p - txt1;
- *pos2 = q - txt2;
- }
- }
- }
-}
-
-static int _php3_similar_char(const char *txt1, int len1,
- const char *txt2, int len2)
-{
- int sum;
- int pos1, pos2, max;
-
- _php3_similar_str(txt1, len1, txt2, len2, &pos1, &pos2, &max);
- if ((sum = max)) {
- if (pos1 && pos2)
- sum += _php3_similar_char(txt1, pos1, txt2, pos2);
- if ((pos1 + max < len1) && (pos2 + max < len2))
- sum += _php3_similar_char(txt1 + pos1 + max, len1 - pos1 - max,
- txt2 + pos2 + max, len2 - pos2 -max);
- }
- return sum;
-}
-
-/* {{{ proto int similar_text(string str1, string str2 [, double percent])
- Calculates the similarity between two strings */
-PHP_FUNCTION(similar_text)
-{
- pval *t1, *t2, *percent;
- int ac = ARG_COUNT(ht);
- int sim;
-
- if (ac < 2 || ac > 3 ||
- getParameters(ht, ac, &t1, &t2, &percent) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(t1);
- convert_to_string(t2);
- if (ac > 2) {
- convert_to_double(percent);
- }
-
- if ((t1->value.str.len + t2->value.str.len) == 0) {
- if(ac > 2) {
- percent->value.dval = 0;
- }
- RETURN_LONG(0);
- }
-
- sim = _php3_similar_char(t1->value.str.val, t1->value.str.len,
- t2->value.str.val, t2->value.str.len);
-
- if (ac > 2) {
- percent->value.dval = sim * 200.0 / (t1->value.str.len + t2->value.str.len);
- }
-
- RETURN_LONG(sim);
-}
-/* }}} */
-
-
-/* be careful, this edits the string in-place */
-PHPAPI void php_stripslashes(char *string, int *len)
-{
- char *s, *t;
- int l;
- char escape_char='\\';
- PLS_FETCH();
-
- if (PG(magic_quotes_sybase)) {
- escape_char='\'';
- }
-
- if (len != NULL) {
- l = *len;
- } else {
- l = strlen(string);
- }
- s = string;
- t = string;
- while (l > 0) {
- if (*t == escape_char) {
- t++; /* skip the slash */
- if (len != NULL)
- (*len)--;
- l--;
- if (l > 0) {
- if(*t=='0') {
- *s++='\0';
- t++;
- } else {
- *s++ = *t++; /* preserve the next character */
- }
- l--;
- }
- } else {
- if (s != t)
- *s++ = *t++;
- else {
- s++;
- t++;
- }
- l--;
- }
- }
- if (s != t) {
- *s = '\0';
- }
-}
-
-/* {{{ proto string addcslashes(string str, string charlist)
- Escape all chars mentioned in charlist with backslash. It creates
- octal representations if asked to backslash characters with 8th bit set
- or with ASCII<32 (except '\n', '\r', '\t' etc...) */
-PHP_FUNCTION(addcslashes)
-{
- pval *str, *what;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &str, &what) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str);
- convert_to_string(what);
- return_value->value.str.val = php_addcslashes(str->value.str.val,str->value.str.len,&return_value->value.str.len,0,what->value.str.val,what->value.str.len);
- return_value->type = IS_STRING;
-}
-/* }}} */
-
-/* {{{ proto string addslashes(string str)
- Escape single quote, double quotes and backslash characters in a string with backslashes */
-PHP_FUNCTION(addslashes)
-{
- pval *str;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str);
- return_value->value.str.val = php_addslashes(str->value.str.val,str->value.str.len,&return_value->value.str.len,0);
- return_value->type = IS_STRING;
-}
-/* }}} */
-
-/* {{{ proto string stripcslashes(string str)
- Strip backslashes from a string. Uses C-style conventions*/
-PHP_FUNCTION(stripcslashes)
-{
- pval *str;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str);
-
- /* let RETVAL do the estrdup() */
- RETVAL_STRING(str->value.str.val,1);
- php_stripcslashes(return_value->value.str.val,&return_value->value.str.len);
-}
-/* }}} */
-
-/* {{{ proto string stripslashes(string str)
- Strip backslashes from a string */
-PHP_FUNCTION(stripslashes)
-{
- pval *str;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str);
-
- /* let RETVAL do the estrdup() */
- RETVAL_STRING(str->value.str.val,1);
- php_stripslashes(return_value->value.str.val,&return_value->value.str.len);
-}
-/* }}} */
-
-#ifndef HAVE_STRERROR
-#if !APACHE
-char *strerror(int errnum)
-{
- extern int sys_nerr;
- extern char *sys_errlist[];
-#ifndef THREAD_SAFE
- static char str_ebuf[40];
-#endif
-
- if ((unsigned int)errnum < sys_nerr) return(sys_errlist[errnum]);
- (void)sprintf(str_ebuf, "Unknown error: %d", errnum);
- return(str_ebuf);
-}
-#endif
-#endif
-
-PHPAPI void php_stripcslashes(char *str, int *len)
-{
- char *source,*target,*end;
- int nlen = *len, i;
- char numtmp[4];
-
- for (source=str,end=str+nlen,target=str; source<end; source++) {
- if (*source == '\\' && source+1<end) {
- source++;
- switch (*source) {
- case 'n': *target++='\n'; nlen--; break;
- case 'r': *target++='\r'; nlen--; break;
- case 'a': *target++='\a'; nlen--; break;
- case 't': *target++='\t'; nlen--; break;
- case 'v': *target++='\v'; nlen--; break;
- case 'b': *target++='\b'; nlen--; break;
- case 'f': *target++='\f'; nlen--; break;
- case '\\': *target++='\\'; nlen--; break;
- case 'x': if (source+1<end && isxdigit((int)(*(source+1)))) {
- numtmp[0] = *++source;
- if (source+1<end && isxdigit((int)(*(source+1)))) {
- numtmp[1] = *++source;
- numtmp[2] = '\0';
- nlen-=3;
- } else {
- numtmp[1] = '\0';
- nlen-=2;
- }
- *target++=(char)strtol(numtmp, NULL, 16);
- break;
- }
- /* break is left intentionally */
- default: i=0;
- while (source<end && *source>='0' && *source<='7' && i<3) {
- numtmp[i++] = *source++;
- }
- if (i) {
- numtmp[i]='\0';
- *target++=(char)strtol(numtmp, NULL, 8);
- nlen-=i;
- source--;
- } else {
- *target++='\\';
- *target++=*source;
- }
- }
- } else {
- *target++=*source;
- }
- }
- *target='\0';
-
- *len = nlen;
-}
-
-
-PHPAPI char *php_addcslashes(char *str, int length, int *new_length, int should_free, char *what, int wlength)
-{
- char flags[256];
- char *new_str = emalloc((length?length:(length=strlen(str)))*4+1);
- char *source,*target;
- char *end;
- char c;
- int newlen;
-
- if (!wlength) {
- wlength = strlen(what);
- }
-
- if (!length) {
- length = strlen(str);
- }
-
- memset(flags, '\0', sizeof(flags));
- for (source=what,end=source+wlength; (c=*source) || source<end; source++) {
- if (source+3<end && *(source+1) == '.' && *(source+2) == '.' && (unsigned char)*(source+3)>=(unsigned char)c) {
- memset(flags+c, 1, (unsigned char)*(source+3)-(unsigned char)c+1);
- source+=3;
- } else
- flags[(unsigned char)c]=1;
- }
-
- for (source=str,end=source+length,target=new_str; (c=*source) || source<end; source++) {
- if (flags[(unsigned char)c]) {
- if ((unsigned char)c<32 || (unsigned char)c>126) {
- *target++ = '\\';
- switch (c) {
- case '\n': *target++ = 'n'; break;
- case '\t': *target++ = 't'; break;
- case '\r': *target++ = 'r'; break;
- case '\a': *target++ = 'a'; break;
- case '\v': *target++ = 'v'; break;
- case '\b': *target++ = 'b'; break;
- case '\f': *target++ = 'f'; break;
- default: target += sprintf(target, "%03o", (unsigned char)c);
- }
- continue;
- }
- *target++ = '\\';
- }
- *target++ = c;
- }
- *target = 0;
- newlen = target-new_str;
- if (target-new_str<length*4) {
- new_str = erealloc(new_str, newlen+1);
- }
- if (new_length) {
- *new_length = newlen;
- }
- if (should_free) {
- STR_FREE(str);
- }
- return new_str;
-}
-
-PHPAPI char *php_addslashes(char *str, int length, int *new_length, int should_free)
-{
- /* maximum string length, worst case situation */
- char *new_str = (char *) emalloc((length?length:(length=strlen(str)))*2+1);
- char *source,*target;
- char *end;
- char c;
- PLS_FETCH();
-
- for (source=str,end=source+length,target=new_str; (c = *source) || source<end; source++) {
- switch(c) {
- case '\0':
- *target++ = '\\';
- *target++ = '0';
- break;
- case '\'':
- if (PG(magic_quotes_sybase)) {
- *target++ = '\'';
- *target++ = '\'';
- break;
- }
- /* break is missing *intentionally* */
- case '\"':
- case '\\':
- if (!PG(magic_quotes_sybase)) {
- *target++ = '\\';
- }
- /* break is missing *intentionally* */
- default:
- *target++ = c;
- break;
- }
- }
- *target = 0;
- if (new_length) {
- *new_length = target - new_str;
- }
- if (should_free) {
- STR_FREE(str);
- }
- return new_str;
-}
-
-
-#define _HEB_BLOCK_TYPE_ENG 1
-#define _HEB_BLOCK_TYPE_HEB 2
-#define isheb(c) (((((unsigned char) c)>=224) && (((unsigned char) c)<=250)) ? 1 : 0)
-#define _isblank(c) (((((unsigned char) c)==' ' || ((unsigned char) c)=='\t')) ? 1 : 0)
-#define _isnewline(c) (((((unsigned char) c)=='\n' || ((unsigned char) c)=='\r')) ? 1 : 0)
-
-PHPAPI void _php3_char_to_str(char *str,uint len,char from,char *to,int to_len,pval *result)
-{
- int char_count=0;
- char *source,*target,*tmp,*source_end=str+len, *tmp_end=NULL;
-
- for (source=str; source<source_end; source++) {
- if (*source==from) {
- char_count++;
- }
- }
-
- result->type = IS_STRING;
-
- if (char_count==0) {
- result->value.str.val = estrndup(str,len);
- result->value.str.len = len;
- return;
- }
-
- result->value.str.len = len+char_count*(to_len-1);
- result->value.str.val = target = (char *) emalloc(result->value.str.len+1);
-
- for (source=str; source<source_end; source++) {
- if (*source==from) {
- for (tmp=to,tmp_end=tmp+to_len; tmp<tmp_end; tmp++) {
- *target = *tmp;
- target++;
- }
- } else {
- *target = *source;
- target++;
- }
- }
- *target = 0;
-}
-
-
-static inline char *
-_php3_memnstr(char *haystack, char *needle, int needle_len, char *end)
-{
- char *p = haystack;
- char *s = NULL;
-
- for(; p <= end - needle_len &&
- (s = memchr(p, *needle, end - p - needle_len + 1)); p = s + 1) {
- if(memcmp(s, needle, needle_len) == 0)
- return s;
- }
- return NULL;
-}
-
-PHPAPI char *_php3_str_to_str(char *haystack, int length,
- char *needle, int needle_len, char *str, int str_len, int *_new_length)
-{
- char *p, *q;
- char *r, *s;
- char *end = haystack + length;
- char *new;
- char *off;
-
- new = emalloc(length);
- /* we jump through haystack searching for the needle. hurray! */
- for(p = haystack, q = new;
- (r = _php3_memnstr(p, needle, needle_len, end));) {
- /* this ain't optimal. you could call it `efficient memory usage' */
- off = erealloc(new, (q - new) + (r - p) + (str_len) + 1);
- if(off != new) {
- if(!off) {
- goto finish;
- }
- q += off - new;
- new = off;
- }
- memcpy(q, p, r - p);
- q += r - p;
- memcpy(q, str, str_len);
- q += str_len;
- p = r + needle_len;
- }
-
- /* if there is a rest, copy it */
- if((end - p) > 0) {
- s = (q) + (end - p);
- off = erealloc(new, s - new + 1);
- if(off != new) {
- if(!off) {
- goto finish;
- }
- q += off - new;
- new = off;
- s = q + (end - p);
- }
- memcpy(q, p, end - p);
- q = s;
- }
-finish:
- *q = '\0';
- if(_new_length) *_new_length = q - new;
- return new;
-}
-
-
-/* {{{ proto string str_replace(string needle, string str, string haystack)
- Replace all occurrences of needle in haystack with str */
-PHP_FUNCTION(str_replace)
-{
- pval *haystack, *needle, *str;
- char *new;
- int len = 0;
-
- if(ARG_COUNT(ht) != 3 ||
- getParameters(ht, 3, &needle, &str, &haystack) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(haystack);
- convert_to_string(needle);
- convert_to_string(str);
-
- if(haystack->value.str.len == 0) {
- RETURN_STRING(empty_string,1);
- }
-
- if(needle->value.str.len == 1) {
- _php3_char_to_str(haystack->value.str.val,
- haystack->value.str.len,
- needle->value.str.val[0],
- str->value.str.val,
- str->value.str.len,
- return_value);
- return;
- }
-
- if(needle->value.str.len == 0) {
- php_error(E_WARNING, "The length of the needle must not be 0");
- RETURN_FALSE;
- }
-
- new = _php3_str_to_str(haystack->value.str.val, haystack->value.str.len,
- needle->value.str.val, needle->value.str.len,
- str->value.str.val, str->value.str.len, &len);
- RETURN_STRINGL(new, len, 0);
-}
-/* }}} */
-
-/* Converts Logical Hebrew text (Hebrew Windows style) to Visual text
- * Cheers/complaints/flames - Zeev Suraski <zeev@php.net>
- */
-static void _php3_hebrev(INTERNAL_FUNCTION_PARAMETERS,int convert_newlines)
-{
- pval *str,*max_chars_per_line;
- char *heb_str,*tmp,*target,*opposite_target,*broken_str;
- int block_start, block_end, block_type, block_length, i;
- int block_ended;
- long max_chars=0;
- int begin,end,char_count,orig_begin;
-
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &str)==FAILURE) {
- RETURN_FALSE;
- }
- break;
- case 2:
- if (getParameters(ht, 2, &str, &max_chars_per_line)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(max_chars_per_line);
- max_chars = max_chars_per_line->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- convert_to_string(str);
-
- if (str->value.str.len==0) {
- RETURN_FALSE;
- }
-
- tmp = str->value.str.val;
- block_start=block_end=0;
- block_ended=0;
-
- heb_str = (char *) emalloc(str->value.str.len+1);
- target = heb_str+str->value.str.len;
- opposite_target = heb_str;
- *target = 0;
- target--;
-
- block_length=0;
-
- if (isheb(*tmp)) {
- block_type = _HEB_BLOCK_TYPE_HEB;
- } else {
- block_type = _HEB_BLOCK_TYPE_ENG;
- }
-
- do {
- if (block_type==_HEB_BLOCK_TYPE_HEB) {
- while((isheb((int)*(tmp+1)) || _isblank((int)*(tmp+1)) || ispunct((int)*(tmp+1)) || (int)*(tmp+1)=='\n' ) && block_end<str->value.str.len-1) {
- tmp++;
- block_end++;
- block_length++;
- }
- for (i=block_start; i<=block_end; i++) {
- *target = str->value.str.val[i];
- switch (*target) {
- case '(':
- *target = ')';
- break;
- case ')':
- *target = '(';
- break;
- default:
- break;
- }
- target--;
- }
- block_type = _HEB_BLOCK_TYPE_ENG;
- } else {
- while(!isheb(*(tmp+1)) && (int)*(tmp+1)!='\n' && block_end<str->value.str.len-1) {
- tmp++;
- block_end++;
- block_length++;
- }
- while ((_isblank((int)*tmp) || ispunct((int)*tmp)) && *tmp!='/' && *tmp!='-' && block_end>block_start) {
- tmp--;
- block_end--;
- }
- for (i=block_end; i>=block_start; i--) {
- *target = str->value.str.val[i];
- target--;
- }
- block_type = _HEB_BLOCK_TYPE_HEB;
- }
- block_start=block_end+1;
- } while(block_end<str->value.str.len-1);
-
-
- broken_str = (char *) emalloc(str->value.str.len+1);
- begin=end=str->value.str.len-1;
- target = broken_str;
-
- while (1) {
- char_count=0;
- while ((!max_chars || char_count<max_chars) && begin>0) {
- char_count++;
- begin--;
- if (begin<=0 || _isnewline(heb_str[begin])) {
- while(begin>0 && _isnewline(heb_str[begin-1])) {
- begin--;
- char_count++;
- }
- break;
- }
- }
- if (char_count==max_chars) { /* try to avoid breaking words */
- int new_char_count=char_count, new_begin=begin;
-
- while (new_char_count>0) {
- if (_isblank(heb_str[new_begin]) || _isnewline(heb_str[new_begin])) {
- break;
- }
- new_begin++;
- new_char_count--;
- }
- if (new_char_count>0) {
- char_count=new_char_count;
- begin=new_begin;
- }
- }
- orig_begin=begin;
-
- if (_isblank(heb_str[begin])) {
- heb_str[begin]='\n';
- }
- while (begin<=end && _isnewline(heb_str[begin])) { /* skip leading newlines */
- begin++;
- }
- for (i=begin; i<=end; i++) { /* copy content */
- *target = heb_str[i];
- target++;
- }
- for (i=orig_begin; i<=end && _isnewline(heb_str[i]); i++) {
- *target = heb_str[i];
- target++;
- }
- begin=orig_begin;
-
- if (begin<=0) {
- *target = 0;
- break;
- }
- begin--;
- end=begin;
- }
- efree(heb_str);
-
- if (convert_newlines) {
- _php3_char_to_str(broken_str,str->value.str.len,'\n',"<br>\n",5,return_value);
- efree(broken_str);
- } else {
- return_value->value.str.val = broken_str;
- return_value->value.str.len = str->value.str.len;
- return_value->type = IS_STRING;
- }
-}
-
-
-/* {{{ proto string hebrev(string str [, int max_chars_per_line])
- Convert logical Hebrew text to visual text */
-PHP_FUNCTION(hebrev)
-{
- _php3_hebrev(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
-}
-/* }}} */
-
-/* {{{ proto string hebrevc(string str [, int max_chars_per_line])
- Convert logical Hebrew text to visual text with newline conversion */
-PHP_FUNCTION(hebrevc)
-{
- _php3_hebrev(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
-}
-/* }}} */
-
-/* {{{ proto string nl2br(string str)
- Converts newlines to HTML line breaks */
-PHP_FUNCTION(nl2br)
-{
- pval *str;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &str)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(str);
-
- _php3_char_to_str(str->value.str.val,str->value.str.len,'\n',"<br>\n",5,return_value);
-}
-/* }}} */
-
-/* {{{ proto string strip_tags(string str)
- Strips HTML and PHP tags from a string */
-PHP_FUNCTION(strip_tags)
-{
- char *buf;
- pval *str;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(str);
- buf = estrdup(str->value.str.val);
- _php3_strip_tags(buf, 0);
- RETURN_STRING(buf, 0);
-}
-/* }}} */
-
-/* {{{ proto string setlocale(string category, string locale)
- Set locale information */
-PHP_FUNCTION(setlocale)
-{
- pval *category, *locale;
- int cat;
- char *loc, *retval;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &category, &locale)==FAILURE)
- WRONG_PARAM_COUNT;
-#ifdef HAVE_SETLOCALE
- convert_to_string(category);
- convert_to_string(locale);
- if (!strcasecmp ("LC_ALL", category->value.str.val))
- cat = LC_ALL;
- else if (!strcasecmp ("LC_COLLATE", category->value.str.val))
- cat = LC_COLLATE;
- else if (!strcasecmp ("LC_CTYPE", category->value.str.val))
- cat = LC_CTYPE;
- else if (!strcasecmp ("LC_MONETARY", category->value.str.val))
- cat = LC_MONETARY;
- else if (!strcasecmp ("LC_NUMERIC", category->value.str.val))
- cat = LC_NUMERIC;
- else if (!strcasecmp ("LC_TIME", category->value.str.val))
- cat = LC_TIME;
- else {
- php_error(E_WARNING,"Invalid locale category name %s, must be one of LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC or LC_TIME", category->value.str.val);
- RETURN_FALSE;
- }
- if (!strcmp ("0", locale->value.str.val))
- loc = NULL;
- else
- loc = locale->value.str.val;
- retval = setlocale (cat, loc);
- if (retval) {
- RETVAL_STRING(retval,1);
- return;
- }
-#endif
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto void parse_str(string encoded_string)
- Parses GET/POST/COOKIE data and sets global variables. */
-PHP_FUNCTION(parse_str)
-{
- pval *arg;
- char *res = NULL;
- ELS_FETCH();
- PLS_FETCH();
- SLS_FETCH();
-
- if (getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
- if (arg->value.str.val && *arg->value.str.val) {
- res = estrndup(arg->value.str.val,arg->value.str.len);
- }
- php_treat_data(PARSE_STRING, res ELS_CC PLS_CC SLS_CC);
-}
-/* }}} */
-
-/* A simple little state-machine to strip out html and php tags
-
- State 0 is the output state, State 1 means we are inside a
- normal html tag and state 2 means we are inside a php tag.
-
- The state variable is passed in to allow a function like fgetss
- to maintain state across calls to the function.
-
- lc holds the last significant character read and br is a bracket
- counter.
-*/
-void _php3_strip_tags(char *rbuf, int state) {
- char *buf, *p, *rp, c, lc;
- int br;
-
- buf = estrdup(rbuf);
- c = *buf;
- lc = '\0';
- p = buf;
- rp = rbuf;
- br = 0;
-
- while (c) { /* This is not binary-safe. Don't see why it should be */
- switch (c) {
- case '<':
- if (state == 0) {
- lc = '<';
- state = 1;
- }
- break;
-
- case '(':
- if (state == 2) {
- if (lc != '\"') {
- lc = '(';
- br++;
- }
- } else if (state == 0) {
- *(rp++) = c;
- }
- break;
-
- case ')':
- if (state == 2) {
- if (lc != '\"') {
- lc = ')';
- br--;
- }
- } else if (state == 0) {
- *(rp++) = c;
- }
- break;
-
- case '>':
- if (state == 1) {
- lc = '>';
- state = 0;
- } else if (state == 2) {
- if (!br && lc != '\"' && *(p-1)=='?') {
- state = 0;
- }
- }
- break;
-
- case '\"':
- if (state == 2) {
- if (lc == '\"') {
- lc = '\0';
- } else if (lc != '\\') {
- lc = '\"';
- }
- } else if (state == 0) {
- *(rp++) = c;
- }
- break;
-
- case '?':
- if (state==1 && *(p-1)=='<') {
- br=0;
- state=2;
- break;
- }
- /* fall-through */
-
- default:
- if (state == 0) {
- *(rp++) = c;
- }
- break;
- }
- c = *(++p);
- }
- *rp = '\0';
- efree(buf);
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/syslog.c b/ext/standard/syslog.c
deleted file mode 100644
index d4792b2856..0000000000
--- a/ext/standard/syslog.c
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Stig Sæther Bakken <ssb@guardian.no> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-#include "php_ini.h"
-#include "zend_globals.h"
-
-#include <stdlib.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#if MSVC5
-#include "win32/syslog.h"
-#else
-#include <syslog.h>
-#endif
-
-#include <string.h>
-#include <errno.h>
-
-#include <stdio.h>
-#include "php3_syslog.h"
-
-static int syslog_started;
-static char *syslog_device;
-static void start_syslog(void);
-
-PHP_MINIT_FUNCTION(syslog)
-{
- ELS_FETCH();
-
- /* error levels */
- REGISTER_LONG_CONSTANT("LOG_EMERG", LOG_EMERG, CONST_CS | CONST_PERSISTENT); /* system unusable */
- REGISTER_LONG_CONSTANT("LOG_ALERT", LOG_ALERT, CONST_CS | CONST_PERSISTENT); /* immediate action required */
- REGISTER_LONG_CONSTANT("LOG_CRIT", LOG_CRIT, CONST_CS | CONST_PERSISTENT); /* critical conditions */
- REGISTER_LONG_CONSTANT("LOG_ERR", LOG_ERR, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_WARNING", LOG_WARNING, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_NOTICE", LOG_NOTICE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_INFO", LOG_INFO, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_DEBUG", LOG_DEBUG, CONST_CS | CONST_PERSISTENT);
- /* facility: type of program logging the message */
- REGISTER_LONG_CONSTANT("LOG_KERN", LOG_KERN, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_USER", LOG_USER, CONST_CS | CONST_PERSISTENT); /* generic user level */
- REGISTER_LONG_CONSTANT("LOG_MAIL", LOG_MAIL, CONST_CS | CONST_PERSISTENT); /* log to email */
- REGISTER_LONG_CONSTANT("LOG_DAEMON", LOG_DAEMON, CONST_CS | CONST_PERSISTENT); /* other system daemons */
- REGISTER_LONG_CONSTANT("LOG_AUTH", LOG_AUTH, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_SYSLOG", LOG_SYSLOG, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_LPR", LOG_LPR, CONST_CS | CONST_PERSISTENT);
-#ifdef LOG_NEWS
- /* No LOG_NEWS on HP-UX */
- REGISTER_LONG_CONSTANT("LOG_NEWS", LOG_NEWS, CONST_CS | CONST_PERSISTENT); /* usenet new */
-#endif
-#ifdef LOG_UUCP
- /* No LOG_UUCP on HP-UX */
- REGISTER_LONG_CONSTANT("LOG_UUCP", LOG_UUCP, CONST_CS | CONST_PERSISTENT);
-#endif
-#ifdef LOG_CRON
- /* apparently some systems don't have this one */
- REGISTER_LONG_CONSTANT("LOG_CRON", LOG_CRON, CONST_CS | CONST_PERSISTENT);
-#endif
-#ifdef LOG_AUTHPRIV
- /* AIX doesn't have LOG_AUTHPRIV */
- REGISTER_LONG_CONSTANT("LOG_AUTHPRIV", LOG_AUTHPRIV, CONST_CS | CONST_PERSISTENT);
-#endif
-#ifndef MSVC5
- REGISTER_LONG_CONSTANT("LOG_LOCAL0", LOG_LOCAL0, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_LOCAL1", LOG_LOCAL1, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_LOCAL2", LOG_LOCAL2, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_LOCAL3", LOG_LOCAL3, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_LOCAL4", LOG_LOCAL4, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_LOCAL5", LOG_LOCAL5, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_LOCAL6", LOG_LOCAL6, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_LOCAL7", LOG_LOCAL7, CONST_CS | CONST_PERSISTENT);
-#endif
- /* options */
- REGISTER_LONG_CONSTANT("LOG_PID", LOG_PID, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_CONS", LOG_CONS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_ODELAY", LOG_ODELAY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_NDELAY", LOG_NDELAY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("LOG_NOWAIT", LOG_NOWAIT, CONST_CS | CONST_PERSISTENT);
-#ifdef LOG_PERROR
- /* AIX doesn't have LOG_PERROR */
- REGISTER_LONG_CONSTANT("LOG_PERROR", LOG_PERROR, CONST_CS | CONST_PERSISTENT); /*log to stderr*/
-#endif
-
- return SUCCESS;
-}
-
-
-PHP_RINIT_FUNCTION(syslog)
-{
- if (INI_INT("define_syslog_variables")) {
- start_syslog();
- } else {
- syslog_started=0;
- }
- syslog_device=NULL;
- return SUCCESS;
-}
-
-
-PHP_RSHUTDOWN_FUNCTION(syslog)
-{
- if (syslog_device) {
- efree(syslog_device);
- }
- return SUCCESS;
-}
-
-
-static void start_syslog(void)
-{
- ELS_FETCH();
-
- /* error levels */
- SET_VAR_LONG("LOG_EMERG", LOG_EMERG); /* system unusable */
- SET_VAR_LONG("LOG_ALERT", LOG_ALERT); /* immediate action required */
- SET_VAR_LONG("LOG_CRIT", LOG_CRIT); /* critical conditions */
- SET_VAR_LONG("LOG_ERR", LOG_ERR);
- SET_VAR_LONG("LOG_WARNING", LOG_WARNING);
- SET_VAR_LONG("LOG_NOTICE", LOG_NOTICE);
- SET_VAR_LONG("LOG_INFO", LOG_INFO);
- SET_VAR_LONG("LOG_DEBUG", LOG_DEBUG);
- /* facility: type of program logging the message */
- SET_VAR_LONG("LOG_KERN", LOG_KERN);
- SET_VAR_LONG("LOG_USER", LOG_USER); /* generic user level */
- SET_VAR_LONG("LOG_MAIL", LOG_MAIL); /* log to email */
- SET_VAR_LONG("LOG_DAEMON", LOG_DAEMON); /* other system daemons */
- SET_VAR_LONG("LOG_AUTH", LOG_AUTH);
- SET_VAR_LONG("LOG_SYSLOG", LOG_SYSLOG);
- SET_VAR_LONG("LOG_LPR", LOG_LPR);
-#ifdef LOG_NEWS
- /* No LOG_NEWS on HP-UX */
- SET_VAR_LONG("LOG_NEWS", LOG_NEWS); /* usenet new */
-#endif
-#ifdef LOG_UUCP
- /* No LOG_UUCP on HP-UX */
- SET_VAR_LONG("LOG_UUCP", LOG_UUCP);
-#endif
-#ifdef LOG_CRON
- /* apparently some systems don't have this one */
- SET_VAR_LONG("LOG_CRON", LOG_CRON);
-#endif
-#ifdef LOG_AUTHPRIV
- /* AIX doesn't have LOG_AUTHPRIV */
- SET_VAR_LONG("LOG_AUTHPRIV", LOG_AUTHPRIV);
-#endif
-#ifndef MSVC5
- SET_VAR_LONG("LOG_LOCAL0", LOG_LOCAL0);
- SET_VAR_LONG("LOG_LOCAL1", LOG_LOCAL1);
- SET_VAR_LONG("LOG_LOCAL2", LOG_LOCAL2);
- SET_VAR_LONG("LOG_LOCAL3", LOG_LOCAL3);
- SET_VAR_LONG("LOG_LOCAL4", LOG_LOCAL4);
- SET_VAR_LONG("LOG_LOCAL5", LOG_LOCAL5);
- SET_VAR_LONG("LOG_LOCAL6", LOG_LOCAL6);
- SET_VAR_LONG("LOG_LOCAL7", LOG_LOCAL7);
-#endif
- /* options */
- SET_VAR_LONG("LOG_PID", LOG_PID);
- SET_VAR_LONG("LOG_CONS", LOG_CONS);
- SET_VAR_LONG("LOG_ODELAY", LOG_ODELAY);
- SET_VAR_LONG("LOG_NDELAY", LOG_NDELAY);
- SET_VAR_LONG("LOG_NOWAIT", LOG_NOWAIT);
-#ifdef LOG_PERROR
- /* AIX doesn't have LOG_PERROR */
- SET_VAR_LONG("LOG_PERROR", LOG_PERROR); /*log to stderr*/
-#endif
-
- syslog_started=1;
-}
-
-/* {{{ proto void define_syslog_variables(void)
- Initializes all syslog-related variables */
-PHP_FUNCTION(define_syslog_variables)
-{
- if (!syslog_started) {
- start_syslog();
- }
-}
-
-/* {{{ proto int openlog(string ident, int option, int facility)
- Open connection to system logger */
-/*
- ** OpenLog("nettopp", $LOG_PID, $LOG_LOCAL1);
- ** Syslog($LOG_EMERG, "help me!")
- ** CloseLog();
- */
-PHP_FUNCTION(openlog)
-{
- pval *ident, *option, *facility;
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &ident, &option, &facility) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(ident);
- convert_to_long(option);
- convert_to_long(facility);
- if (syslog_device) {
- efree(syslog_device);
- }
- syslog_device = estrndup(ident->value.str.val,ident->value.str.len);
- openlog(syslog_device, option->value.lval, facility->value.lval);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int closelog(void)
- Close connection to system logger */
-PHP_FUNCTION(closelog)
-{
- closelog();
- if (syslog_device) {
- efree(syslog_device);
- syslog_device=NULL;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int syslog(int priority, string message)
- Generate a system log message */
-PHP_FUNCTION(syslog)
-{
- pval *priority, *message;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &priority, &message) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(priority);
- convert_to_string(message);
-
- /*
- * CAVEAT: if the message contains patterns such as "%s",
- * this will cause problems.
- */
-
- syslog(priority->value.lval, message->value.str.val);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-function_entry syslog_functions[] = {
- PHP_FE(openlog, NULL)
- PHP_FE(syslog, NULL)
- PHP_FE(closelog, NULL)
- PHP_FE(define_syslog_variables, NULL)
- {NULL, NULL, NULL}
-};
-
-
-php3_module_entry syslog_module_entry = {
- "Syslog", syslog_functions, PHP_MINIT(syslog), NULL, PHP_RINIT(syslog), PHP_RSHUTDOWN(syslog), NULL, STANDARD_MODULE_PROPERTIES
-};
-
-
-#if COMPILE_DL
-DLEXPORT php3_module_entry *get_module(void) { return &syslog_module_entry; }
-#endif
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/type.c b/ext/standard/type.c
deleted file mode 100644
index ee6ab91049..0000000000
--- a/ext/standard/type.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-#include "php.h"
-#include "type.h"
-
-/*
- * Determines if 'str' is an integer (long), real number or a string
- *
- * Note that leading zeroes automatically force a STRING type
- */
-int php3_check_type(char *str)
-{
- char *s;
- int type = IS_LONG;
-
- s = str;
- if (*s == '0' && *(s + 1) && *(s + 1) != '.')
- return (IS_STRING);
- if (*s == '+' || *s == '-' || (*s >= '0' && *s <= '9') || *s == '.') {
- if (*s == '.')
- type = IS_DOUBLE;
- s++;
- while (*s) {
- if (*s >= '0' && *s <= '9') {
- s++;
- continue;
- } else if (*s == '.' && type == IS_LONG) {
- type = IS_DOUBLE;
- s++;
- continue;
- } else
- return (IS_STRING);
- }
- } else
- return (IS_STRING);
-
- return (type);
-} /* php3_check_type */
-
-/*
- * 0 - simple variable
- * 1 - non-index array
- * 2 - index array
- */
-int php3_check_ident_type(char *str)
-{
- char *s;
-
- if (!(s = (char *) strchr(str, '[')))
- return (GPC_REGULAR);
- s++;
- while (*s == ' ' || *s == '\t' || *s == '\n') {
- s++;
- }
- if (*s == ']') {
- return (GPC_NON_INDEXED_ARRAY);
- }
- return (GPC_INDEXED_ARRAY);
-}
-
-char *php3_get_ident_index(char *str)
-{
- char *temp;
- char *s, *t;
- char o;
-
- temp = emalloc(strlen(str));
- temp[0] = '\0';
- s = (char *) strchr(str, '[');
- if (s) {
- t = (char *) strrchr(str, ']');
- if (t) {
- o = *t;
- *t = '\0';
- strcpy(temp, s + 1);
- *t = o;
- }
- }
- return (temp);
-}
diff --git a/ext/standard/type.h b/ext/standard/type.h
deleted file mode 100644
index 62f98bea7a..0000000000
--- a/ext/standard/type.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-#ifndef _TYPE_H
-#define _TYPE_H
-
-extern int php3_check_type(char *str);
-extern int php3_check_ident_type(char *str);
-extern char *php3_get_ident_index(char *str);
-
-#define GPC_REGULAR 0x1
-#define GPC_INDEXED_ARRAY 0x2
-#define GPC_NON_INDEXED_ARRAY 0x4
-#define GPC_ARRAY (GPC_INDEXED_ARRAY | GPC_NON_INDEXED_ARRAY)
-
-#endif
diff --git a/ext/standard/uniqid.c b/ext/standard/uniqid.c
deleted file mode 100644
index 25fdd8fb36..0000000000
--- a/ext/standard/uniqid.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Stig Sæther Bakken <ssb@guardian.no> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-
-#include <stdlib.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#include <string.h>
-#include <errno.h>
-
-#include <stdio.h>
-#if MSVC5
-#include "win32/time.h"
-#else
-#include <sys/time.h>
-#endif
-
-#include "php_lcg.h"
-#include "uniqid.h"
-
-/* {{{ proto string uniqid(string prefix, [bool more_entropy])
- Generate a unique id */
-PHP_FUNCTION(uniqid)
-{
-#ifdef HAVE_GETTIMEOFDAY
- pval *prefix, *flags;
- char uniqid[138];
- int sec, usec, argc;
- struct timeval tv;
-
- argc = ARG_COUNT(ht);
- if (argc < 1 || argc > 2 || getParameters(ht, argc, &prefix, &flags)) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(prefix);
- if (argc == 2) {
- convert_to_boolean(flags);
- }
-
- /* Do some bounds checking since we are using a char array. */
- if (prefix->value.str.len > 114) {
- php_error(E_WARNING, "The prefix to uniqid should not be more than 114 characters.");
- return;
- }
-#if HAVE_USLEEP && !(WIN32|WINNT)
- if (argc < 2 || !flags->value.lval) {
- usleep(1);
- }
-#endif
- gettimeofday((struct timeval *) &tv, (struct timezone *) NULL);
- sec = (int) tv.tv_sec;
- usec = (int) (tv.tv_usec % 1000000);
-
- /* The max value usec can have is 0xF423F, so we use only five hex
- * digits for usecs.
- */
- if (argc == 2 && flags->value.lval) {
- sprintf(uniqid, "%s%08x%05x%.8f", prefix->value.str.val, sec, usec, php_combined_lcg() * 10);
- } else {
- sprintf(uniqid, "%s%08x%05x", prefix->value.str.val, sec, usec);
- }
-
- RETURN_STRING(uniqid,1);
-#endif
-}
-/* }}} */
-
-function_entry uniqid_functions[] = {
- PHP_FE(uniqid, NULL)
- {NULL, NULL, NULL}
-};
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/uniqid.h b/ext/standard/uniqid.h
deleted file mode 100644
index 3666e0a8c2..0000000000
--- a/ext/standard/uniqid.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Author: Stig Sæther Bakken <ssb@guardian.no> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _UNIQID_H
-#define _UNIQID_H
-
-PHP_FUNCTION(uniqid);
-
-#endif /* _UNIQID_H */
diff --git a/ext/standard/url.c b/ext/standard/url.c
deleted file mode 100644
index 96a6ee2c4e..0000000000
--- a/ext/standard/url.c
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Jim Winstead (jimw@php.net) |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/types.h>
-
-#include "php.h"
-#include "php_regex.h"
-
-#include "url.h"
-#ifdef _OSD_POSIX
-#ifndef APACHE
-#error On this EBCDIC platform, PHP3 is only supported as an Apache module.
-#else /*APACHE*/
-#ifndef CHARSET_EBCDIC
-#define CHARSET_EBCDIC /* this machine uses EBCDIC, not ASCII! */
-#endif
-#include "ebcdic.h"
-#endif /*APACHE*/
-#endif /*_OSD_POSIX*/
-
-
-void free_url(url * theurl)
-{
- if (theurl->scheme)
- efree(theurl->scheme);
- if (theurl->user)
- efree(theurl->user);
- if (theurl->pass)
- efree(theurl->pass);
- if (theurl->host)
- efree(theurl->host);
- if (theurl->path)
- efree(theurl->path);
- if (theurl->query)
- efree(theurl->query);
- if (theurl->fragment)
- efree(theurl->fragment);
- efree(theurl);
-}
-
-url *url_parse(char *string)
-{
- regex_t re;
- regmatch_t subs[10];
- int err;
- int length = strlen(string);
- char *result;
-
- url *ret = (url *) emalloc(sizeof(url));
- if (!ret) {
- /*php_error(E_WARNING,"Unable to allocate memory\n");*/
- return NULL;
- }
- memset(ret, 0, sizeof(url));
-
- /* from Appendix B of draft-fielding-url-syntax-09,
- http://www.ics.uci.edu/~fielding/url/url.txt */
- err = regcomp(&re, "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?", REG_EXTENDED);
- if (err) {
- /*php_error(E_WARNING,"Unable to compile regex: %d\n", err);*/
- efree(ret);
- return NULL;
- }
- err = regexec(&re, string, 10, subs, 0);
- if (err) {
- /*php_error(E_WARNING,"Error with regex\n");*/
- efree(ret);
- return NULL;
- }
- /* no processing necessary on the scheme */
- if (subs[2].rm_so != -1 && subs[2].rm_so < length) {
- ret->scheme = estrndup(string + subs[2].rm_so, subs[2].rm_eo - subs[2].rm_so);
- }
-
- /* the path to the resource */
- if (subs[5].rm_so != -1 && subs[5].rm_so < length) {
- ret->path = estrndup(string + subs[5].rm_so, subs[5].rm_eo - subs[5].rm_so);
- }
-
- /* the query part */
- if (subs[7].rm_so != -1 && subs[7].rm_so < length) {
- ret->query = estrndup(string + subs[7].rm_so, subs[7].rm_eo - subs[7].rm_so);
- }
-
- /* the fragment */
- if (subs[9].rm_so != -1 && subs[9].rm_so < length) {
- ret->fragment = estrndup(string + subs[9].rm_so, subs[9].rm_eo - subs[9].rm_so);
- }
-
- /* extract the username, pass, and port from the hostname */
- if (subs[4].rm_so != -1 && subs[4].rm_so < length) {
- /* extract username:pass@host:port from regex results */
- result = estrndup(string + subs[4].rm_so, subs[4].rm_eo - subs[4].rm_so);
- length = strlen(result);
-
- regfree(&re); /* free the old regex */
-
- if ((err=regcomp(&re, "^(([^@:]+)(:([^@:]+))?@)?([^:@]+)(:([^:@]+))?", REG_EXTENDED))
- || (err=regexec(&re, result, 10, subs, 0))) {
- STR_FREE(ret->scheme);
- STR_FREE(ret->path);
- STR_FREE(ret->query);
- STR_FREE(ret->fragment);
- efree(ret);
- efree(result);
- /*php_error(E_WARNING,"Unable to compile regex: %d\n", err);*/
- return NULL;
- }
- /* now deal with all of the results */
- if (subs[2].rm_so != -1 && subs[2].rm_so < length) {
- ret->user = estrndup(result + subs[2].rm_so, subs[2].rm_eo - subs[2].rm_so);
- }
- if (subs[4].rm_so != -1 && subs[4].rm_so < length) {
- ret->pass = estrndup(result + subs[4].rm_so, subs[4].rm_eo - subs[4].rm_so);
- }
- if (subs[5].rm_so != -1 && subs[5].rm_so < length) {
- ret->host = estrndup(result + subs[5].rm_so, subs[5].rm_eo - subs[5].rm_so);
- }
- if (subs[7].rm_so != -1 && subs[7].rm_so < length) {
- ret->port = (unsigned short) strtol(result + subs[7].rm_so, NULL, 10);
- }
- efree(result);
- }
- regfree(&re);
- return ret;
-}
-
-/* {{{ proto array parse_url(string url)
- Parse a URL and return its components */
-PHP_FUNCTION(parse_url)
-{
- pval *string;
- url *resource;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &string) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(string);
-
- resource = url_parse(string->value.str.val);
-
- if (resource == NULL) {
- php_error(E_WARNING, "unable to parse url (%s)", string->value.str.val);
- RETURN_FALSE;
- }
- /* allocate an array for return */
- if (array_init(return_value) == FAILURE) {
- free_url(resource);
- RETURN_FALSE;
- }
- /* add the various elements to the array */
- if (resource->scheme != NULL)
- add_assoc_string(return_value, "scheme", resource->scheme, 1);
- if (resource->host != NULL)
- add_assoc_string(return_value, "host", resource->host, 1);
- if (resource->port != 0)
- add_assoc_long(return_value, "port", resource->port);
- if (resource->user != NULL)
- add_assoc_string(return_value, "user", resource->user, 1);
- if (resource->pass != NULL)
- add_assoc_string(return_value, "pass", resource->pass, 1);
- if (resource->path != NULL)
- add_assoc_string(return_value, "path", resource->path, 1);
- if (resource->query != NULL)
- add_assoc_string(return_value, "query", resource->query, 1);
- if (resource->fragment != NULL)
- add_assoc_string(return_value, "fragment", resource->fragment, 1);
- free_url(resource);
-}
-/* }}} */
-
-static int php3_htoi(char *s)
-{
- int value;
- int c;
-
- c = s[0];
- if (isupper(c))
- c = tolower(c);
- value = (c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10) * 16;
-
- c = s[1];
- if (isupper(c))
- c = tolower(c);
- value += c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10;
-
- return (value);
-}
-
-/* rfc1738:
-
- ...The characters ";",
- "/", "?", ":", "@", "=" and "&" are the characters which may be
- reserved for special meaning within a scheme...
-
- ...Thus, only alphanumerics, the special characters "$-_.+!*'(),", and
- reserved characters used for their reserved purposes may be used
- unencoded within a URL...
-
- For added safety, we only leave -_. unencoded.
- */
-
-static unsigned char hexchars[] = "0123456789ABCDEF";
-
-char *_php3_urlencode(char *s, int len)
-{
- register int x, y;
- unsigned char *str;
-
- str = (unsigned char *) emalloc(3 * strlen(s) + 1);
- for (x = 0, y = 0; len--; x++, y++) {
- str[y] = (unsigned char) s[x];
- if (str[y] == ' ') {
- str[y] = '+';
-#ifndef CHARSET_EBCDIC
- } else if ((str[y] < '0' && str[y] != '-' && str[y] != '.') ||
- (str[y] < 'A' && str[y] > '9') ||
- (str[y] > 'Z' && str[y] < 'a' && str[y] != '_') ||
- (str[y] > 'z')) {
- str[y++] = '%';
- str[y++] = hexchars[(unsigned char) s[x] >> 4];
- str[y] = hexchars[(unsigned char) s[x] & 15];
- }
-#else /*CHARSET_EBCDIC*/
- } else if (!isalnum(str[y]) && strchr("_-.", str[y]) != NULL) {
- str[y++] = '%';
- str[y++] = hexchars[os_toascii[(unsigned char) s[x]] >> 4];
- str[y] = hexchars[os_toascii[(unsigned char) s[x]] & 0x0F];
- }
-#endif /*CHARSET_EBCDIC*/
- }
- str[y] = '\0';
- return ((char *) str);
-}
-
-/* {{{ proto string urlencode(string str)
- URL-encodes string */
-PHP_FUNCTION(urlencode)
-{
- pval *arg;
- char *str;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
-
- if (!arg->value.str.len) {
- var_reset(return_value);
- return;
- }
- str = _php3_urlencode(arg->value.str.val, arg->value.str.len);
- RETVAL_STRING(str, 1);
- efree(str);
-}
-/* }}} */
-
-/* {{{ proto string urldecode(string str)
- Decodes URL-encoded string */
-PHP_FUNCTION(urldecode)
-{
- pval *arg;
- int len;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
-
- if (!arg->value.str.len) {
- var_reset(return_value);
- return;
- }
- len = _php3_urldecode(arg->value.str.val, arg->value.str.len);
-
- RETVAL_STRINGL(arg->value.str.val, len, 1);
-}
-/* }}} */
-
-int _php3_urldecode(char *str, int len)
-{
- char *dest = str;
- char *data = str;
-
- while (len--) {
- if (*data == '+')
- *dest = ' ';
- else if (*data == '%' && len >= 2 && isxdigit((int) *(data + 1)) && isxdigit((int) *(data + 2))) {
-#ifndef CHARSET_EBCDIC
- *dest = (char) php3_htoi(data + 1);
-#else
- *dest = os_toebcdic[(char) php3_htoi(data + 1)];
-#endif
- data += 2;
- len -= 2;
- } else
- *dest = *data;
- data++;
- dest++;
- }
- *dest = '\0';
- return dest - str;
-}
-
-char *_php3_rawurlencode(char *s, int len)
-{
- register int x, y;
- unsigned char *str;
-
- str = (unsigned char *) emalloc(3 * len + 1);
- for (x = 0, y = 0; len--; x++, y++) {
- str[y] = (unsigned char) s[x];
-#ifndef CHARSET_EBCDIC
- if ((str[y] < '0' && str[y] != '-' && str[y] != '.') ||
- (str[y] < 'A' && str[y] > '9') ||
- (str[y] > 'Z' && str[y] < 'a' && str[y] != '_') ||
- (str[y] > 'z')) {
- str[y++] = '%';
- str[y++] = hexchars[(unsigned char) s[x] >> 4];
- str[y] = hexchars[(unsigned char) s[x] & 15];
-#else /*CHARSET_EBCDIC*/
- if (!isalnum(str[y]) && strchr("_-.", str[y]) != NULL) {
- str[y++] = '%';
- str[y++] = hexchars[os_toascii[(unsigned char) s[x]] >> 4];
- str[y] = hexchars[os_toascii[(unsigned char) s[x]] & 15];
-#endif /*CHARSET_EBCDIC*/
- }
- }
- str[y] = '\0';
- return ((char *) str);
-}
-
-/* {{{ proto string rawurlencode(string str)
- URL-encodes string */
-PHP_FUNCTION(rawurlencode)
-{
- pval *arg;
- char *str;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
-
- if (!arg->value.str.len) {
- RETURN_FALSE;
- }
- str = _php3_rawurlencode(arg->value.str.val, arg->value.str.len);
- RETVAL_STRING(str, 1);
- efree(str);
-}
-/* }}} */
-
-/* {{{ proto string rawurldecode(string str)
- Decodes URL-encodes string */
-PHP_FUNCTION(rawurldecode)
-{
- pval *arg;
- int len;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
-
- if (!arg->value.str.len) {
- RETURN_FALSE;
- }
- len = _php3_rawurldecode(arg->value.str.val, arg->value.str.len);
-
- RETVAL_STRINGL(arg->value.str.val, len, 1);
-}
-/* }}} */
-
-int _php3_rawurldecode(char *str, int len)
-{
- char *dest = str;
- char *data = str;
-
- while (len--) {
- if (*data == '%' && len >= 2 && isxdigit((int) *(data + 1)) && isxdigit((int) *(data + 2))) {
-#ifndef CHARSET_EBCDIC
- *dest = (char) php3_htoi(data + 1);
-#else
- *dest = os_toebcdic[(char) php3_htoi(data + 1)];
-#endif
- data += 2;
- len -= 2;
- } else
- *dest = *data;
- data++;
- dest++;
- }
- *dest = '\0';
- return dest - str;
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/url.h b/ext/standard/url.h
deleted file mode 100644
index eaf5c32f77..0000000000
--- a/ext/standard/url.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Jim Winstead (jimw@php.net) |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-typedef struct url {
- char *scheme;
- char *user;
- char *pass;
- char *host;
- unsigned short port;
- char *path;
- char *query;
- char *fragment;
-} url;
-
-void free_url(url *);
-extern url *url_parse(char *);
-extern int _php3_urldecode(char *, int); /* return value: length of decoded string */
-extern char *_php3_urlencode(char *, int);
-extern int _php3_rawurldecode(char *, int); /* return value: length of decoded string */
-extern char *_php3_rawurlencode(char *, int);
-
-PHP_FUNCTION(parse_url);
-PHP_FUNCTION(urlencode);
-PHP_FUNCTION(urldecode);
-PHP_FUNCTION(rawurlencode);
-PHP_FUNCTION(rawurldecode);
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/standard/url_scanner.c b/ext/standard/url_scanner.c
deleted file mode 100644
index 959a62387f..0000000000
--- a/ext/standard/url_scanner.c
+++ /dev/null
@@ -1,470 +0,0 @@
-/* Generated by re2c 0.5 on Fri Sep 17 20:08:27 1999 */
-#line 1 "../../../php4/ext/standard/url_scanner.re"
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Sascha Schumann <sascha@schumann.cx> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#undef MIN
-#define MIN(a,b) (a)<(b)?(a):(b)
-
-#define YYCTYPE char
-#define YYCURSOR state->crs
-#define YYLIMIT state->end
-#define YYMARKER state->ptr
-#define YYFILL(n)
-
-typedef enum {
- INITIAL,
- REF
-} state;
-
-typedef struct {
- state state;
- const char *crs;
- const char *end;
- const char *ptr;
- const char *start;
- char *target;
- size_t targetsize;
- const char *data;
-} lexdata;
-
-#define FINISH { catchup(state); goto finish; }
-
-#define BEGIN(x) \
- switch(state->state) { \
- case INITIAL: \
- catchup(state); \
- break; \
- case REF: \
- screw_url(state); \
- break; \
- } \
- state->state = x; \
- state->start = state->crs; \
- goto nextiter
-
-#define ATTACH(s, n) \
-{ \
- size_t _newlen = state->targetsize + n; \
- state->target = realloc(state->target, _newlen + 1); \
- memcpy(state->target + state->targetsize, s, n); \
- state->targetsize = _newlen; \
- state->target[_newlen] = '\0'; \
-}
-
-#define URLLEN 512
-
-static void screw_url(lexdata *state)
-{
- int len;
- char buf[URLLEN];
- char url[URLLEN];
- const char *p, *q;
- char c;
-
- /* search outer limits for URI */
- for(p = state->start; p < state->crs && (c = *p); p++)
- if(c != '"' && c != ' ') break;
-
- /*
- * we look at q-1, because q points to the character behind the last
- * character we are going to copy and the decision is based on that last
- * character
- */
-
- for(q = state->crs; q > state->start && (c = *(q-1)); q--)
- if(c != '"' && c != ' ') break;
-
- /* attach beginning */
-
- ATTACH(state->start, p-state->start);
-
- /* copy old URI */
- len = MIN(q - p, sizeof(buf) - 1);
- memcpy(url, p, len);
- url[len] = '\0';
-
- /* construct new URI */
- len = snprintf(buf, sizeof(buf), "%s%c%s", url,
- memchr(state->start, '?', len) ? '&' : '?',
- state->data);
-
- /* attach new URI */
- ATTACH(buf, len);
-
- /* attach rest */
- ATTACH(q, state->crs - q);
-}
-
-static void catchup(lexdata *state)
-{
- ATTACH(state->start, (state->crs - state->start));
-}
-
-#line 135
-
-
-static void url_scanner(lexdata *state)
-{
- while(state->crs < state->end) {
-
- switch(state->state) {
- case INITIAL:
-{
- YYCTYPE yych;
- unsigned int yyaccept;
- static unsigned char yybm[] = {
- 0, 64, 64, 64, 64, 64, 64, 64,
- 64, 192, 64, 192, 192, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 192, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 0, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64,
- };
- goto yy0;
-yy1: ++YYCURSOR;
-yy0:
- if((YYLIMIT - YYCURSOR) < 7) YYFILL(7);
- yych = *YYCURSOR;
- if(yybm[0+yych] & 64) goto yy4;
- if(yych <= '\000') goto yy7;
-yy2: yych = *++YYCURSOR;
- if(yych <= 'F'){
- if(yych == 'A') goto yy9;
- if(yych >= 'F') goto yy10;
- } else {
- if(yych <= 'a'){
- if(yych >= 'a') goto yy9;
- } else {
- if(yych == 'f') goto yy10;
- }
- }
-yy3:yy4: ++YYCURSOR;
- if(YYLIMIT == YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
-yy5: if(yybm[0+yych] & 64) goto yy4;
-yy6:
-#line 146
- { BEGIN(INITIAL); }
-yy7: yych = *++YYCURSOR;
-yy8:
-#line 147
- { FINISH; }
-yy9: yych = *++YYCURSOR;
- if(yych == 'H') goto yy3;
- if(yych == 'h') goto yy3;
- goto yy25;
-yy10: yych = *++YYCURSOR;
- if(yych == 'R') goto yy11;
- if(yych != 'r') goto yy3;
-yy11: yych = *++YYCURSOR;
- if(yych == 'A') goto yy12;
- if(yych != 'a') goto yy3;
-yy12: yych = *++YYCURSOR;
- if(yych == 'M') goto yy13;
- if(yych != 'm') goto yy3;
-yy13: yych = *++YYCURSOR;
- if(yych == 'E') goto yy14;
- if(yych != 'e') goto yy3;
-yy14: yych = *++YYCURSOR;
- if(yych == 'S') goto yy3;
- if(yych == 's') goto yy3;
- goto yy16;
-yy15: ++YYCURSOR;
- if(YYLIMIT == YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
-yy16: if(yybm[0+yych] & 128) goto yy15;
- if(yych == 'S') goto yy17;
- if(yych != 's') goto yy3;
-yy17: yych = *++YYCURSOR;
- if(yych == 'R') goto yy18;
- if(yych != 'r') goto yy3;
-yy18: yych = *++YYCURSOR;
- if(yych == 'C') goto yy19;
- if(yych != 'c') goto yy3;
-yy19: ++YYCURSOR;
- if(YYLIMIT == YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
-yy20: if(yych <= '\f'){
- if(yych == '\t') goto yy19;
- if(yych <= '\n') goto yy3;
- goto yy19;
- } else {
- if(yych <= ' '){
- if(yych <= '\037') goto yy3;
- goto yy19;
- } else {
- if(yych != '=') goto yy3;
- }
- }
-yy21: ++YYCURSOR;
- if(YYLIMIT == YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
-yy22: if(yych <= '\n'){
- if(yych == '\t') goto yy21;
- } else {
- if(yych <= '\f') goto yy21;
- if(yych == ' ') goto yy21;
- }
-yy23:
-#line 144
- { BEGIN(REF); }
-yy24: ++YYCURSOR;
- if(YYLIMIT == YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
-yy25: if(yych <= '\037'){
- if(yych <= '\t'){
- if(yych <= '\b') goto yy3;
- goto yy24;
- } else {
- if(yych <= '\n') goto yy3;
- if(yych <= '\f') goto yy24;
- goto yy3;
- }
- } else {
- if(yych <= 'H'){
- if(yych <= ' ') goto yy24;
- if(yych <= 'G') goto yy3;
- } else {
- if(yych != 'h') goto yy3;
- }
- }
-yy26: yych = *++YYCURSOR;
- if(yych == 'R') goto yy27;
- if(yych != 'r') goto yy3;
-yy27: yych = *++YYCURSOR;
- if(yych == 'E') goto yy28;
- if(yych != 'e') goto yy3;
-yy28: yych = *++YYCURSOR;
- if(yych == 'F') goto yy29;
- if(yych != 'f') goto yy3;
-yy29: ++YYCURSOR;
- if(YYLIMIT == YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
-yy30: if(yych <= '\f'){
- if(yych == '\t') goto yy29;
- if(yych <= '\n') goto yy3;
- goto yy29;
- } else {
- if(yych <= ' '){
- if(yych <= '\037') goto yy3;
- goto yy29;
- } else {
- if(yych != '=') goto yy3;
- }
- }
-yy31: ++YYCURSOR;
- if(YYLIMIT == YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
-yy32: if(yych <= '\n'){
- if(yych == '\t') goto yy31;
- } else {
- if(yych <= '\f') goto yy31;
- if(yych == ' ') goto yy31;
- }
-yy33:
-#line 145
- { BEGIN(REF); }
-}
-#line 148
-
- break;
- case REF:
-{
- YYCTYPE yych;
- unsigned int yyaccept;
- static unsigned char yybm[] = {
- 0, 192, 192, 192, 192, 192, 192, 192,
- 192, 32, 192, 32, 32, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 32, 192, 0, 0, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 128, 192, 192, 192, 0, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192,
- };
- goto yy34;
-yy35: ++YYCURSOR;
-yy34:
- if(YYLIMIT == YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- if(yybm[0+yych] & 64) goto yy39;
- if(yych <= '\000') goto yy36;
- if(yych <= '"') goto yy37;
- if(yych <= '#') goto yy36;
- if(yych <= '=') goto yy42;
-yy36:yy37: ++YYCURSOR;
- if(YYLIMIT == YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
-yy38: if(yybm[0+yych] & 64) goto yy39;
- if(yych <= '\000') goto yy36;
- if(yych <= '!') goto yy37;
- if(yych == ':') goto yy42;
- goto yy36;
-yy39: ++YYCURSOR;
- if(YYLIMIT == YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
-yy40: if(yybm[0+yych] & 64) goto yy39;
- if(yych <= '"'){
- if(yych <= '\000') goto yy41;
- if(yych <= '!') goto yy48;
- goto yy50;
- } else {
- if(yych <= '#') goto yy51;
- if(yych <= '=') goto yy42;
- }
-yy41:
-#line 152
- { BEGIN(INITIAL); }
-yy42: ++YYCURSOR;
- if(YYLIMIT == YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
-yy43: if(yybm[0+yych] & 128) goto yy42;
- if(yych <= '\000') goto yy44;
- if(yych <= '!') goto yy45;
- if(yych <= '"') goto yy47;
-yy44:
-#line 154
- {
- /* don't modify absolute links */
- state->state = INITIAL; BEGIN(INITIAL);
- }
-yy45: ++YYCURSOR;
- if(YYLIMIT == YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
-yy46: if(yych <= '\f'){
- if(yych == '\t') goto yy45;
- if(yych <= '\n') goto yy44;
- goto yy45;
- } else {
- if(yych <= ' '){
- if(yych <= '\037') goto yy44;
- goto yy45;
- } else {
- if(yych != '"') goto yy44;
- }
- }
-yy47: yych = *++YYCURSOR;
- goto yy44;
-yy48: ++YYCURSOR;
- if(YYLIMIT == YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
-yy49: if(yych <= '\f'){
- if(yych == '\t') goto yy48;
- if(yych <= '\n') goto yy41;
- goto yy48;
- } else {
- if(yych <= ' '){
- if(yych <= '\037') goto yy41;
- goto yy48;
- } else {
- if(yych != '"') goto yy41;
- }
- }
-yy50: yych = *++YYCURSOR;
- goto yy41;
-yy51: yych = *++YYCURSOR;
-yy52: YYCURSOR -= 1;
-#line 153
- { BEGIN(INITIAL); }
-}
-#line 158
-
- break;
- }
-nextiter:
- ;
- }
-finish:
- ;
-}
-
-char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen)
-{
- lexdata state;
-
- state.state = INITIAL;
- state.start = state.crs = src;
- state.end = src + srclen;
- state.ptr = NULL;
- state.target = NULL;
- state.targetsize = 0;
- state.data = data;
-
- url_scanner(&state);
-
- if(newlen) *newlen = state.targetsize;
-
- return state.target;
-}
diff --git a/ext/standard/url_scanner.h b/ext/standard/url_scanner.h
deleted file mode 100644
index 7651f77d8e..0000000000
--- a/ext/standard/url_scanner.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Sascha Schumann <sascha@schumann.cx> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#ifndef URI_SCANNER_H
-#define URI_SCANNER_H
-
-char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen);
-
-#endif
diff --git a/ext/standard/url_scanner.re b/ext/standard/url_scanner.re
deleted file mode 100644
index d0dc3a2ec4..0000000000
--- a/ext/standard/url_scanner.re
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Sascha Schumann <sascha@schumann.cx> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#undef MIN
-#define MIN(a,b) (a)<(b)?(a):(b)
-
-#define YYCTYPE char
-#define YYCURSOR state->crs
-#define YYLIMIT state->end
-#define YYMARKER state->ptr
-#define YYFILL(n)
-
-typedef enum {
- INITIAL,
- REF
-} state;
-
-typedef struct {
- state state;
- const char *crs;
- const char *end;
- const char *ptr;
- const char *start;
- char *target;
- size_t targetsize;
- const char *data;
-} lexdata;
-
-#define FINISH { catchup(state); goto finish; }
-
-#define BEGIN(x) \
- switch(state->state) { \
- case INITIAL: \
- catchup(state); \
- break; \
- case REF: \
- screw_url(state); \
- break; \
- } \
- state->state = x; \
- state->start = state->crs; \
- goto nextiter
-
-#define ATTACH(s, n) \
-{ \
- size_t _newlen = state->targetsize + n; \
- state->target = realloc(state->target, _newlen + 1); \
- memcpy(state->target + state->targetsize, s, n); \
- state->targetsize = _newlen; \
- state->target[_newlen] = '\0'; \
-}
-
-#define URLLEN 512
-
-static void screw_url(lexdata *state)
-{
- int len;
- char buf[URLLEN];
- char url[URLLEN];
- const char *p, *q;
- char c;
-
- /* search outer limits for URI */
- for(p = state->start; p < state->crs && (c = *p); p++)
- if(c != '"' && c != ' ') break;
-
- /*
- * we look at q-1, because q points to the character behind the last
- * character we are going to copy and the decision is based on that last
- * character
- */
-
- for(q = state->crs; q > state->start && (c = *(q-1)); q--)
- if(c != '"' && c != ' ') break;
-
- /* attach beginning */
-
- ATTACH(state->start, p-state->start);
-
- /* copy old URI */
- len = MIN(q - p, sizeof(buf) - 1);
- memcpy(url, p, len);
- url[len] = '\0';
-
- /* construct new URI */
- len = snprintf(buf, sizeof(buf), "%s%c%s", url,
- memchr(state->start, '?', len) ? '&' : '?',
- state->data);
-
- /* attach new URI */
- ATTACH(buf, len);
-
- /* attach rest */
- ATTACH(q, state->crs - q);
-}
-
-static void catchup(lexdata *state)
-{
- ATTACH(state->start, (state->crs - state->start));
-}
-
-/*!re2c
-all = [\001-\377];
-eof = [\000];
-ws = [ \t\v\f];
-A = [aA];
-C = [cC];
-E = [eE];
-F = [fF];
-H = [hH];
-M = [mM];
-R = [rR];
-S = [sS];
-*/
-
-static void url_scanner(lexdata *state)
-{
- while(state->crs < state->end) {
-
- switch(state->state) {
- case INITIAL:
-/*!re2c
- "<" F R A M E ws+ S R C ws* "=" ws* { BEGIN(REF); }
- "<" A ws+ H R E F ws* "=" ws* { BEGIN(REF); }
- (all\[<])+ { BEGIN(INITIAL); }
- eof { FINISH; }
-*/
- break;
- case REF:
-/*!re2c
- ["]? ws* (all\[> \t\v\f":#])+ ws* ["]? { BEGIN(INITIAL); }
- ["]? ws* (all\[> \t\v\f":#])+/[#] { BEGIN(INITIAL); }
- ["]? ws* (all\[> \t\v\f"#])+ ws* ["]? {
- /* don't modify absolute links */
- state->state = INITIAL; BEGIN(INITIAL);
- }
-*/
- break;
- }
-nextiter:
- ;
- }
-finish:
- ;
-}
-
-char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen)
-{
- lexdata state;
-
- state.state = INITIAL;
- state.start = state.crs = src;
- state.end = src + srclen;
- state.ptr = NULL;
- state.target = NULL;
- state.targetsize = 0;
- state.data = data;
-
- url_scanner(&state);
-
- if(newlen) *newlen = state.targetsize;
-
- return state.target;
-}
diff --git a/ext/standard/var.c b/ext/standard/var.c
deleted file mode 100644
index 9f1a21a523..0000000000
--- a/ext/standard/var.c
+++ /dev/null
@@ -1,494 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Jani Lehtimäki <jkl@njet.net> |
- |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-
-/* {{{ includes
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include "php.h"
-#include "php3_string.h"
-#include "php3_var.h"
-
-/* }}} */
-/* {{{ php_var_dump */
-
-void php_var_dump(pval **struc, int level)
-{
- ulong index;
- char *key;
- int i, c = 0;
- pval **data;
- char buf[512];
- HashTable *myht;
-
- switch ((*struc)->type) {
- case IS_BOOL:
- i = sprintf(buf, "%*cbool(%s)\n", level, ' ', ((*struc)->value.lval?"true":"false"));
- PHPWRITE(&buf[1], i - 1);
- break;
-
- case IS_LONG:
- i = sprintf(buf, "%*cint(%ld)\n", level, ' ', (*struc)->value.lval);
- PHPWRITE(&buf[1], i - 1);
- break;
-
- case IS_DOUBLE:
- i = sprintf(buf, "%*cfloat(%g)\n", level, ' ', (*struc)->value.dval);
- PHPWRITE(&buf[1], i - 1);
- break;
-
- case IS_STRING:
- i = sprintf(buf, "%*cstring(%d) \"", level, ' ', (*struc)->value.str.len);
- PHPWRITE(&buf[1], i - 1);
- PHPWRITE((*struc)->value.str.val, (*struc)->value.str.len);
- strcpy(buf, "\"\n");
- PHPWRITE(buf, strlen(buf));
- break;
-
- case IS_ARRAY:
- myht = HASH_OF(*struc);
- i = sprintf(buf, "%*carray(%d) {\n", level, ' ', zend_hash_num_elements(myht));
- PHPWRITE(&buf[1], i - 1);
- goto head_done;
-
- case IS_OBJECT:
- myht = HASH_OF(*struc);
- i = sprintf(buf, "%*cobject of %s (%d) {\n", level, ' ', (*struc)->value.obj.ce->name, zend_hash_num_elements(myht));
- PHPWRITE(&buf[1], i - 1);
- head_done:
-
- zend_hash_internal_pointer_reset(myht);
- for (;; zend_hash_move_forward(myht)) {
- if ((i = zend_hash_get_current_key(myht, &key, &index)) == HASH_KEY_NON_EXISTANT)
- break;
- if (c > 0) {
- strcpy(buf, "\n");
- PHPWRITE(buf, strlen(buf));
- }
- c++;
- if (zend_hash_get_current_data(myht, (void **) (&data)) != SUCCESS || !data || (data == struc))
- continue;
- switch (i) {
- case HASH_KEY_IS_LONG:{
- pval *d = emalloc(sizeof(pval));
-
- d->type = IS_LONG;
- d->value.lval = index;
- php_var_dump(&d, level + 2);
- efree(d);
- }
- break;
-
- case HASH_KEY_IS_STRING:{
- pval *d = emalloc(sizeof(pval));
-
- d->type = IS_STRING;
- d->value.str.val = key;
- d->value.str.len = strlen(key);
- php_var_dump(&d, level + 2);
- efree(key);
- efree(d);
- }
- break;
- }
- php_var_dump(data, level + 2);
- }
- i = sprintf(buf, "%*c}\n", level, ' ');
- PHPWRITE(&buf[1], i - 1);
- break;
-
- default:
- i = sprintf(buf, "%*ci:0\n", level, ' ');
- PHPWRITE(&buf[1], i - 1);
- }
-}
-
-/* }}} */
-
-
-/* {{{ php_var_dump */
-PHP_FUNCTION(var_dump)
-{
- zval ***args;
- int argc;
- int i;
-
- argc = ARG_COUNT(ht);
-
- args = (zval ***)emalloc(argc * sizeof(zval **));
- if (ARG_COUNT(ht) == 0 || getParametersArrayEx(argc, args) == FAILURE) {
- efree(args);
- WRONG_PARAM_COUNT;
- }
-
- for (i=0; i<argc; i++)
- php_var_dump(args[i], 1);
-
- efree(args);
-}
-/* }}} */
-
-
-/* {{{ php_var_dump */
-
-
-#define STR_CAT(P,S,I) {\
- pval *__p = (P);\
- ulong __i = __p->value.str.len;\
- __p->value.str.len += (I);\
- if (__p->value.str.val) {\
- __p->value.str.val = (char *)erealloc(__p->value.str.val, __p->value.str.len + 1);\
- } else {\
- __p->value.str.val = emalloc(__p->value.str.len + 1);\
- *__p->value.str.val = 0;\
- }\
- strcat(__p->value.str.val + __i, (S));\
-}
-
-/* }}} */
-/* {{{ php_var_serialize */
-
-void php_var_serialize(pval *buf, pval **struc)
-{
- char s[256];
- ulong slen;
- int i;
- HashTable *myht;
-
- switch ((*struc)->type) {
- case IS_BOOL:
- slen = sprintf(s, "b:%ld;", (*struc)->value.lval);
- STR_CAT(buf, s, slen);
- return;
-
- case IS_LONG:
- slen = sprintf(s, "i:%ld;", (*struc)->value.lval);
- STR_CAT(buf, s, slen);
- return;
-
- case IS_DOUBLE:
- slen = sprintf(s, "d:%g;", (*struc)->value.dval);
- STR_CAT(buf, s, slen);
- return;
-
- case IS_STRING:{
- char *p;
-
- i = buf->value.str.len;
- slen = sprintf(s, "s:%d:\"", (*struc)->value.str.len);
- STR_CAT(buf, s, slen + (*struc)->value.str.len + 2);
- p = buf->value.str.val + i + slen;
- if ((*struc)->value.str.len > 0) {
- memcpy(p, (*struc)->value.str.val, (*struc)->value.str.len);
- p += (*struc)->value.str.len;
- }
- *p++ = '\"';
- *p++ = ';';
- *p = 0;
- }
- return;
-
- case IS_ARRAY:
- case IS_OBJECT:
- myht = HASH_OF(*struc);
- i = zend_hash_num_elements(myht);
- if ((*struc)->type == IS_ARRAY) {
- slen = sprintf(s, "a:%d:{", i);
- } else {
- slen = sprintf(s, "O:%d:\"%s\":%d:{",(*struc)->value.obj.ce->name_length,(*struc)->value.obj.ce->name, i);
- }
- STR_CAT(buf, s, slen);
- if (i > 0) {
- char *key;
- pval **data,*d;
- ulong index;
-
- zend_hash_internal_pointer_reset(myht);
- for (;; zend_hash_move_forward(myht)) {
- if ((i = zend_hash_get_current_key(myht, &key, &index)) == HASH_KEY_NON_EXISTANT) {
- break;
- }
- if (zend_hash_get_current_data(myht, (void **) (&data)) !=
- SUCCESS || !data || ((*data) == (*struc))) {
- continue;
- }
-
- switch (i) {
- case HASH_KEY_IS_LONG:
- d = emalloc(sizeof(pval));
- d->type = IS_LONG;
- d->value.lval = index;
- php_var_serialize(buf, &d);
- efree(d);
- break;
- case HASH_KEY_IS_STRING:
- d = emalloc(sizeof(pval));
- d->type = IS_STRING;
- d->value.str.val = key;
- d->value.str.len = strlen(key);
- php_var_serialize(buf, &d);
- efree(key);
- efree(d);
- break;
- }
- php_var_serialize(buf, data);
- }
- }
- STR_CAT(buf, "}", 1);
- return;
-
- default:
- STR_CAT(buf, "i:0;", 4);
- return;
- }
-}
-
-/* }}} */
-/* {{{ php_var_dump */
-
-int php_var_unserialize(pval **rval, const char **p, const char *max)
-{
- const char *q;
- char *str;
- int i;
- char cur;
- HashTable *myht;
- ELS_FETCH();
-
- switch (cur = **p) {
- case 'b': /* bool */
- case 'i':
- if (*((*p) + 1) != ':') {
- return 0;
- }
- q = *p;
- while (**p && **p != ';') {
- (*p)++;
- }
- if (**p != ';') {
- return 0;
- }
- (*p)++;
- if (cur == 'b') {
- (*rval)->type = IS_BOOL;
- } else {
- (*rval)->type = IS_LONG;
- }
- INIT_PZVAL(*rval);
- (*rval)->value.lval = atol(q + 2);
- return 1;
-
- case 'd':
- if (*((*p) + 1) != ':') {
- return 0;
- }
- q = *p;
- while (**p && **p != ';') {
- (*p)++;
- }
- if (**p != ';') {
- return 0;
- }
- (*p)++;
- (*rval)->type = IS_DOUBLE;
- INIT_PZVAL(*rval);
- (*rval)->value.dval = atof(q + 2);
- return 1;
-
- case 's':
- if (*((*p) + 1) != ':') {
- return 0;
- }
- (*p) += 2;
- q = *p;
- while (**p && **p != ':') {
- (*p)++;
- }
- if (**p != ':') {
- return 0;
- }
- i = atoi(q);
- if (i < 0 || (*p + 3 + i) > max || *((*p) + 1) != '\"' ||
- *((*p) + 2 + i) != '\"' || *((*p) + 3 + i) != ';') {
- return 0;
- }
- (*p) += 2;
- str = emalloc(i + 1);
- if (i > 0) {
- memcpy(str, *p, i);
- }
- str[i] = 0;
- (*p) += i + 2;
- (*rval)->type = IS_STRING;
- (*rval)->value.str.val = str;
- (*rval)->value.str.len = i;
- INIT_PZVAL(*rval);
- return 1;
-
- case 'a':
- case 'o':
- case 'O':
- INIT_PZVAL(*rval);
-
- if (cur == 'a') {
- (*rval)->type = IS_ARRAY;
- (*rval)->value.ht = (HashTable *) emalloc(sizeof(HashTable));
- myht = (*rval)->value.ht;
- } else {
- zend_class_entry *ce;
-
- if (cur == 'O') { /* php4 serialized - we get the class-name */
- char *class_name;
-
- if (*((*p) + 1) != ':') {
- return 0;
- }
- (*p) += 2;
- q = *p;
- while (**p && **p != ':') {
- (*p)++;
- }
- if (**p != ':') {
- return 0;
- }
- i = atoi(q);
- if (i < 0 || (*p + 3 + i) > max || *((*p) + 1) != '\"' ||
- *((*p) + 2 + i) != '\"' || *((*p) + 3 + i) != ':') {
- return 0;
- }
- (*p) += 2;
- class_name = emalloc(i + 1);
- if (i > 0) {
- memcpy(class_name, *p, i);
- }
- class_name[i] = 0;
- (*p) += i;
-
- if (zend_hash_find(EG(class_table), class_name, i+1, (void **) &ce)==FAILURE) {
- php_error(E_NOTICE, "Unserializing non-existant class: %s! No methods will be available!", class_name);
- ce = &zend_standard_class_def;
- }
-
- efree(class_name);
- } else { /* old php3 data 'o' */
- ce = &zend_standard_class_def;
- }
-
- object_init_ex(*rval,ce);
- myht = (*rval)->value.obj.properties;
- }
-
- (*p) += 2;
- i = atoi(*p);
-
- if (cur == 'a') { /* object_init_ex will init the HashTable for objects! */
- zend_hash_init(myht, i + 1, NULL, PVAL_PTR_DTOR, 0);
- }
-
- while (**p && **p != ':') {
- (*p)++;
- }
- if (**p != ':' || *((*p) + 1) != '{') {
- return 0;
- }
- for ((*p) += 2; **p && **p != '}' && i > 0; i--) {
- pval *key = emalloc(sizeof(pval));
- pval *data = emalloc(sizeof(pval));
-
- if (!php_var_unserialize(&key, p, max)) {
- efree(key);
- efree(data);
- return 0;
- }
- if (!php_var_unserialize(&data, p, max)) {
- pval_destructor(key);
- efree(key);
- efree(data);
- return 0;
- }
- switch (key->type) {
- case IS_LONG:
- zend_hash_index_update(myht, key->value.lval, &data, sizeof(data), NULL);
- break;
- case IS_STRING:
- zend_hash_update(myht, key->value.str.val, key->value.str.len + 1, &data, sizeof(data), NULL);
- break;
- }
- pval_destructor(key);
- efree(key);
- }
- return *((*p)++) == '}';
-
- default:
- return 0;
- }
-}
-
-/* }}} */
-/* {{{ proto string serialize(mixed variable)
- Returns a string representation of variable (which can later be unserialized) */
-PHP_FUNCTION(serialize)
-{
- pval **struc;
-
- if (ARG_COUNT(ht) != 1 || getParametersEx(1, &struc) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- return_value->type = IS_STRING;
- return_value->value.str.val = NULL;
- return_value->value.str.len = 0;
- php_var_serialize(return_value, struc);
-}
-
-/* }}} */
-/* {{{ proto mixed unserialize(string variable_representation)
- Takes a string representation of variable and recreates it */
-
-
-PHP_FUNCTION(unserialize)
-{
- pval **buf;
-
- if (ARG_COUNT(ht) != 1 || getParametersEx(1, &buf) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- if ((*buf)->type == IS_STRING) {
- const char *p = (*buf)->value.str.val;
-
- if (!php_var_unserialize(&return_value, &p, p + (*buf)->value.str.len)) {
- RETURN_FALSE;
- }
- } else {
- RETURN_FALSE;
- }
-}
-
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/sybase/Makefile.am b/ext/sybase/Makefile.am
deleted file mode 100644
index 1f75a648f2..0000000000
--- a/ext/sybase/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_sybase.a
-libphpext_sybase_a_SOURCES=sybase.c
-
diff --git a/ext/sybase/config.h.stub b/ext/sybase/config.h.stub
deleted file mode 100644
index 85202aa97d..0000000000
--- a/ext/sybase/config.h.stub
+++ /dev/null
@@ -1,4 +0,0 @@
-/* Define if you have libdnet_stub (used for Sybase support) */
-#define HAVE_LIBDNET_STUB 0
-
-#define HAVE_SYBASE 0
diff --git a/ext/sybase/config.m4 b/ext/sybase/config.m4
deleted file mode 100644
index 8de191127f..0000000000
--- a/ext/sybase/config.m4
+++ /dev/null
@@ -1,31 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(for Sybase support)
-AC_ARG_WITH(sybase,
-[ --with-sybase[=DIR] Include Sybase-DB support. DIR is the Sybase home
- directory, defaults to /home/sybase.],
-[
- if test "$withval" != "no"; then
- if test "$withval" = "yes"; then
- SYBASE_INCDIR=/home/sybase/include
- SYBASE_LIBDIR=/home/sybase/lib
- else
- SYBASE_INCDIR=$withval/include
- SYBASE_LIBDIR=$withval/lib
- fi
- AC_ADD_INCLUDE($SYBASE_INCDIR)
- AC_ADD_LIBPATH($SYBASE_LIBDIR)
- AC_ADD_LIBRARY(sybdb)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(sybase)
- AC_CHECK_LIB(dnet_stub, dnet_addr,
- [ AC_ADD_LIBRARY(dnet_stub)
- AC_DEFINE(HAVE_LIBDNET_STUB)
- ])
- AC_DEFINE(HAVE_SYBASE)
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
diff --git a/ext/sybase/php3_sybase.h b/ext/sybase/php3_sybase.h
deleted file mode 100644
index 9c175c8e88..0000000000
--- a/ext/sybase/php3_sybase.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _PHP3_SYBASE_H
-#define _PHP3_SYBASE_H
-
-#if COMPILE_DL
-#undef HAVE_SYBASE
-#define HAVE_SYBASE 1
-#endif
-
-#if HAVE_SYBASE
-
-extern php3_module_entry sybase_module_entry;
-#define sybase_module_ptr &sybase_module_entry
-
-extern int php3_minit_sybase(INIT_FUNC_ARGS);
-extern int php3_rinit_sybase(INIT_FUNC_ARGS);
-extern int php3_mshutdown_sybase(SHUTDOWN_FUNC_ARGS);
-extern int php3_rshutdown_sybase(SHUTDOWN_FUNC_ARGS);
-void php3_info_sybase(ZEND_MODULE_INFO_FUNC_ARGS);
-PHP_FUNCTION(sybase_connect);
-PHP_FUNCTION(sybase_pconnect);
-PHP_FUNCTION(sybase_close);
-PHP_FUNCTION(sybase_select_db);
-PHP_FUNCTION(sybase_query);
-PHP_FUNCTION(sybase_free_result);
-PHP_FUNCTION(sybase_get_last_message);
-PHP_FUNCTION(sybase_num_rows);
-PHP_FUNCTION(sybase_num_fields);
-PHP_FUNCTION(sybase_fetch_row);
-PHP_FUNCTION(sybase_fetch_array);
-PHP_FUNCTION(sybase_fetch_object);
-PHP_FUNCTION(sybase_data_seek);
-PHP_FUNCTION(sybase_result);
-PHP_FUNCTION(sybase_field_seek);
-PHP_FUNCTION(sybase_min_error_severity);
-PHP_FUNCTION(sybase_min_message_severity);
-
-PHP_FUNCTION(sybase_db_query);
-PHP_FUNCTION(sybase_list_fields);
-PHP_FUNCTION(sybase_fetch_lengths);
-PHP_FUNCTION(sybase_fetch_field);
-PHP_FUNCTION(sybase_field_seek);
-PHP_FUNCTION(sybase_free_result);
-PHP_FUNCTION(sybase_field_name);
-PHP_FUNCTION(sybase_field_table);
-PHP_FUNCTION(sybase_field_len);
-PHP_FUNCTION(sybase_field_type);
-PHP_FUNCTION(sybase_field_flags);
-
-
-
-#include <sybfront.h>
-#include <sybdb.h>
-#include <syberror.h>
-
-#define coltype(j) dbcoltype(sybase_ptr->link,j)
-#define intcol(i) ((int) *(DBINT *) dbdata(sybase_ptr->link,i))
-#define smallintcol(i) ((int) *(DBSMALLINT *) dbdata(sybase_ptr->link,i))
-#define tinyintcol(i) ((int) *(DBTINYINT *) dbdata(sybase_ptr->link,i))
-#define anyintcol(j) (coltype(j)==SYBINT4?intcol(j):(coltype(j)==SYBINT2?smallintcol(j):tinyintcol(j)))
-#define charcol(i) ((DBCHAR *) dbdata(sybase_ptr->link,i))
-#define floatcol(i) ((float) *(DBFLT8 *) dbdata(sybase_ptr->link,i))
-
-typedef struct sybase_link_struct sybase_link;
-
-typedef struct {
- long default_link;
- long num_links,num_persistent;
- long max_links,max_persistent;
- long allow_persistent;
- char *appname;
- char *server_message;
- int le_link,le_plink,le_result;
- long min_error_severity,min_message_severity;
- long cfg_min_error_severity,cfg_min_message_severity;
- long compatability_mode;
-} sybase_module;
-
-struct sybase_link_struct {
- LOGINREC *login;
- DBPROCESS *link;
- int valid;
-};
-
-#define SYBASE_ROWS_BLOCK 128
-
-typedef struct {
- char *name,*column_source;
- int max_length, numeric;
- int type;
-} sybase_field;
-
-typedef struct {
- pval **data;
- sybase_field *fields;
- sybase_link *sybase_ptr;
- int cur_row,cur_field;
- int num_rows,num_fields;
-} sybase_result;
-
-
-extern sybase_module php3_sybase_module;
-
-#else
-
-#define sybase_module_ptr NULL
-
-#endif
-
-#define phpext_sybase_ptr sybase_module_ptr
-
-#endif /* _PHP3_SYBASE_H */
diff --git a/ext/sybase/setup.stub b/ext/sybase/setup.stub
deleted file mode 100644
index 58e0b789c6..0000000000
--- a/ext/sybase/setup.stub
+++ /dev/null
@@ -1,11 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-sybase 'Sybase support?' yesnodir \
- 'no /home/sybase Sybase install' \
-' Whether to build PHP with Sybase support (DBLib only).\n
- More info about Sybase can be found at http://www.sybase.com/.'
-
-define_option with-sybase-ct 'Sybase-CT support?' yesnodir \
- 'no /home/sybase Sybase-CT install' \
-' Whether to build PHP with Sybase-CT support.'
diff --git a/ext/sybase/sybase.c b/ext/sybase/sybase.c
deleted file mode 100644
index 95a48562b7..0000000000
--- a/ext/sybase/sybase.c
+++ /dev/null
@@ -1,1231 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- | php3_sybase_get_column_content_with_type() based on code by: |
- | Muhammad A Muquit <MA_Muquit@fccc.edu> |
- | Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-
-#include "php.h"
-#include "php3_sybase.h"
-#include "ext/standard/php3_standard.h"
-#include "php_globals.h"
-
-#if HAVE_SYBASE
-
-#include <sybfront.h>
-#include <sybdb.h>
-#include <syberror.h>
-
-#if BROKEN_SYBASE_PCONNECTS
-#include "http_log.h"
-#endif
-
-function_entry sybase_functions[] = {
- {"sybase_connect", php3_sybase_connect, NULL},
- {"sybase_pconnect", php3_sybase_pconnect, NULL},
- {"sybase_close", php3_sybase_close, NULL},
- {"sybase_select_db", php3_sybase_select_db, NULL},
- {"sybase_query", php3_sybase_query, NULL},
- {"sybase_free_result", php3_sybase_free_result, NULL},
- {"sybase_get_last_message", php3_sybase_get_last_message, NULL},
- {"sybase_num_rows", php3_sybase_num_rows, NULL},
- {"sybase_num_fields", php3_sybase_num_fields, NULL},
- {"sybase_fetch_row", php3_sybase_fetch_row, NULL},
- {"sybase_fetch_array", php3_sybase_fetch_array, NULL},
- {"sybase_fetch_object", php3_sybase_fetch_object, NULL},
- {"sybase_data_seek", php3_sybase_data_seek, NULL},
- {"sybase_fetch_field", php3_sybase_fetch_field, NULL},
- {"sybase_field_seek", php3_sybase_field_seek, NULL},
- {"sybase_result", php3_sybase_result, NULL},
- {"sybase_min_error_severity", php3_sybase_min_error_severity, NULL},
- {"sybase_min_message_severity", php3_sybase_min_message_severity, NULL},
- {"mssql_connect", php3_sybase_connect, NULL},
- {"mssql_pconnect", php3_sybase_pconnect, NULL},
- {"mssql_close", php3_sybase_close, NULL},
- {"mssql_select_db", php3_sybase_select_db, NULL},
- {"mssql_query", php3_sybase_query, NULL},
- {"mssql_free_result", php3_sybase_free_result, NULL},
- {"mssql_get_last_message", php3_sybase_get_last_message, NULL},
- {"mssql_num_rows", php3_sybase_num_rows, NULL},
- {"mssql_num_fields", php3_sybase_num_fields, NULL},
- {"mssql_fetch_row", php3_sybase_fetch_row, NULL},
- {"mssql_fetch_array", php3_sybase_fetch_array, NULL},
- {"mssql_fetch_object", php3_sybase_fetch_object, NULL},
- {"mssql_data_seek", php3_sybase_data_seek, NULL},
- {"mssql_fetch_field", php3_sybase_fetch_field, NULL},
- {"mssql_field_seek", php3_sybase_field_seek, NULL},
- {"mssql_result", php3_sybase_result, NULL},
- {"mssql_min_error_severity", php3_sybase_min_error_severity, NULL},
- {"mssql_min_message_severity", php3_sybase_min_message_severity, NULL},
- {NULL, NULL, NULL}
-};
-
-php3_module_entry sybase_module_entry = {
- "Sybase SQL", sybase_functions, php3_minit_sybase, php3_mshutdown_sybase, php3_rinit_sybase, php3_rshutdown_sybase, php3_info_sybase, STANDARD_MODULE_PROPERTIES
-};
-
-#if COMPILE_DL
-php3_module_entry *get_module() { return &sybase_module_entry; }
-#endif
-
-THREAD_LS sybase_module php3_sybase_module;
-THREAD_LS static HashTable *resource_list, *resource_plist;
-
-
-#define CHECK_LINK(link) { if (link==-1) { php_error(E_WARNING,"Sybase: A link to the server could not be established"); RETURN_FALSE; } }
-
-
-static void php3_sybase_get_column_content(sybase_link *sybase_ptr,int offset,pval *result, int column_type);
-
-/* error handler */
-static int php3_sybase_error_handler(DBPROCESS *dbproc,int severity,int dberr,
- int oserr,char *dberrstr,char *oserrstr)
-{
- if (severity >= php3_sybase_module.min_error_severity) {
- php_error(E_WARNING,"Sybase error: %s (severity %d)",dberrstr,severity);
- }
- return INT_CANCEL;
-}
-
-/* message handler */
-static int php3_sybase_message_handler(DBPROCESS *dbproc,DBINT msgno,int msgstate,
- int severity,char *msgtext,char *srvname,
- char *procname,DBUSMALLINT line)
-{
- if (severity >= php3_sybase_module.min_message_severity) {
- php_error(E_WARNING,"Sybase message: %s (severity %d)",msgtext,severity);
- }
- STR_FREE(php3_sybase_module.server_message);
- php3_sybase_module.server_message = estrdup(msgtext);
- return 0;
-}
-
-
-static int _clean_invalid_results(list_entry *le)
-{
- if (le->type == php3_sybase_module.le_result) {
- sybase_link *sybase_ptr = ((sybase_result *) le->ptr)->sybase_ptr;
-
- if (!sybase_ptr->valid) {
- return 1;
- }
- }
- return 0;
-}
-
-
-static void _free_sybase_result(sybase_result *result)
-{
- int i,j;
-
- if (result->data) {
- for (i=0; i<result->num_rows; i++) {
- for (j=0; j<result->num_fields; j++) {
- pval_destructor(&result->data[i][j]);
- }
- efree(result->data[i]);
- }
- efree(result->data);
- }
-
- if (result->fields) {
- for (i=0; i<result->num_fields; i++) {
- STR_FREE(result->fields[i].name);
- STR_FREE(result->fields[i].column_source);
- }
- efree(result->fields);
- }
- efree(result);
-}
-
-
-static void _close_sybase_link(sybase_link *sybase_ptr)
-{
- sybase_ptr->valid = 0;
- zend_hash_apply(resource_list,(int (*)(void *))_clean_invalid_results);
- dbclose(sybase_ptr->link);
- dbloginfree(sybase_ptr->login);
- efree(sybase_ptr);
- php3_sybase_module.num_links--;
-}
-
-
-static void _close_sybase_plink(sybase_link *sybase_ptr)
-{
- dbclose(sybase_ptr->link);
- dbloginfree(sybase_ptr->login);
- free(sybase_ptr);
- php3_sybase_module.num_persistent--;
- php3_sybase_module.num_links--;
-}
-
-
-int php3_minit_sybase(INIT_FUNC_ARGS)
-{
- char *interface_file;
-
- if (dbinit()==FAIL) {
- return FAILURE;
- }
- dberrhandle((EHANDLEFUNC) php3_sybase_error_handler);
- dbmsghandle((MHANDLEFUNC) php3_sybase_message_handler);
-
- if (cfg_get_string("sybase.interface_file",&interface_file)==SUCCESS) {
- dbsetifile(interface_file);
- }
- if (cfg_get_long("sybase.allow_persistent",&php3_sybase_module.allow_persistent)==FAILURE) {
- php3_sybase_module.allow_persistent=1;
- }
- if (cfg_get_long("sybase.max_persistent",&php3_sybase_module.max_persistent)==FAILURE) {
- php3_sybase_module.max_persistent=-1;
- }
- if (cfg_get_long("sybase.max_links",&php3_sybase_module.max_links)==FAILURE) {
- php3_sybase_module.max_links=-1;
- }
- if (cfg_get_long("sybase.min_error_severity",&php3_sybase_module.cfg_min_error_severity)==FAILURE) {
- php3_sybase_module.cfg_min_error_severity=10;
- }
- if (cfg_get_long("sybase.min_message_severity",&php3_sybase_module.cfg_min_message_severity)==FAILURE) {
- php3_sybase_module.cfg_min_message_severity=10;
- }
- if (cfg_get_long("sybase.compatability_mode",&php3_sybase_module.compatability_mode)==FAILURE) {
- php3_sybase_module.compatability_mode = 0;
- }
-
- php3_sybase_module.num_persistent=0;
- php3_sybase_module.le_link = register_list_destructors(_close_sybase_link,NULL);
- php3_sybase_module.le_plink = register_list_destructors(NULL,_close_sybase_plink);
- php3_sybase_module.le_result = register_list_destructors(_free_sybase_result,NULL);
-
- return SUCCESS;
-}
-
-
-int php3_rinit_sybase(INIT_FUNC_ARGS)
-{
- php3_sybase_module.default_link=-1;
- php3_sybase_module.num_links = php3_sybase_module.num_persistent;
- php3_sybase_module.appname = estrndup("PHP 3.0",7);
- php3_sybase_module.server_message = empty_string;
- php3_sybase_module.min_error_severity = php3_sybase_module.cfg_min_error_severity;
- php3_sybase_module.min_message_severity = php3_sybase_module.cfg_min_message_severity;
- return SUCCESS;
-}
-
-int php3_mshutdown_sybase(SHUTDOWN_FUNC_ARGS)
-{
- dbexit();
- return SUCCESS;
-}
-
-int php3_rshutdown_sybase(SHUTDOWN_FUNC_ARGS)
-{
- efree(php3_sybase_module.appname);
- STR_FREE(php3_sybase_module.server_message);
- return SUCCESS;
-}
-
-static void php3_sybase_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
-{
- char *user,*passwd,*host;
- char *hashed_details;
- int hashed_details_length;
- sybase_link sybase,*sybase_ptr;
-
- resource_list = list;
- resource_plist = plist;
-
- switch(ARG_COUNT(ht)) {
- case 0: /* defaults */
- host=user=passwd=NULL;
- hashed_details_length=6+3;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- strcpy(hashed_details,"sybase___");
- break;
- case 1: {
- pval *yyhost;
-
- if (getParameters(ht, 1, &yyhost)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(yyhost);
- host = yyhost->value.str.val;
- user=passwd=NULL;
- hashed_details_length = yyhost->value.str.len+6+3;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details,"sybase_%s__",yyhost->value.str.val);
- }
- break;
- case 2: {
- pval *yyhost,*yyuser;
-
- if (getParameters(ht, 2, &yyhost, &yyuser)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(yyhost);
- convert_to_string(yyuser);
- host = yyhost->value.str.val;
- user = yyuser->value.str.val;
- passwd=NULL;
- hashed_details_length = yyhost->value.str.len+yyuser->value.str.len+6+3;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details,"sybase_%s_%s_",yyhost->value.str.val,yyuser->value.str.val);
- }
- break;
- case 3: {
- pval *yyhost,*yyuser,*yypasswd;
-
- if (getParameters(ht, 3, &yyhost, &yyuser, &yypasswd) == FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(yyhost);
- convert_to_string(yyuser);
- convert_to_string(yypasswd);
- host = yyhost->value.str.val;
- user = yyuser->value.str.val;
- passwd = yypasswd->value.str.val;
- hashed_details_length = yyhost->value.str.len+yyuser->value.str.len+yypasswd->value.str.len+6+3;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details,"sybase_%s_%s_%s",yyhost->value.str.val,yyuser->value.str.val,yypasswd->value.str.val); /* SAFE */
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
-
- /* set a DBLOGIN record */
- if ((sybase.login=dblogin())==NULL) {
- php_error(E_WARNING,"Sybase: Unable to allocate login record");
- RETURN_FALSE;
- }
-
- if (user) {
- DBSETLUSER(sybase.login,user);
- }
- if (passwd) {
- DBSETLPWD(sybase.login,passwd);
- }
- DBSETLAPP(sybase.login,php3_sybase_module.appname);
- sybase.valid = 1;
-
- if (!php3_sybase_module.allow_persistent) {
- persistent=0;
- }
- if (persistent) {
- list_entry *le;
-
- /* try to find if we already have this link in our persistent list */
- if (zend_hash_find(plist, hashed_details, hashed_details_length+1, (void **) &le)==FAILURE) { /* we don't */
- list_entry new_le;
-
- if (php3_sybase_module.max_links!=-1 && php3_sybase_module.num_links>=php3_sybase_module.max_links) {
- php_error(E_WARNING,"Sybase: Too many open links (%d)",php3_sybase_module.num_links);
- efree(hashed_details);
- dbloginfree(sybase.login);
- RETURN_FALSE;
- }
- if (php3_sybase_module.max_persistent!=-1 && php3_sybase_module.num_persistent>=php3_sybase_module.max_persistent) {
- php_error(E_WARNING,"Sybase: Too many open persistent links (%d)",php3_sybase_module.num_persistent);
- efree(hashed_details);
- dbloginfree(sybase.login);
- RETURN_FALSE;
- }
- /* create the link */
- if ((sybase.link=dbopen(sybase.login,host))==FAIL) {
- /*php_error(E_WARNING,"Sybase: Unable to connect to server: %s",sybase_error(sybase));*/
- efree(hashed_details);
- dbloginfree(sybase.login);
- RETURN_FALSE;
- }
-
- if (dbsetopt(sybase.link,DBBUFFER,"2",-1)==FAIL) {
- efree(hashed_details);
- dbloginfree(sybase.login);
- dbclose(sybase.link);
- RETURN_FALSE;
- }
-
- /* hash it up */
- sybase_ptr = (sybase_link *) malloc(sizeof(sybase_link));
- memcpy(sybase_ptr,&sybase,sizeof(sybase_link));
- new_le.type = php3_sybase_module.le_plink;
- new_le.ptr = sybase_ptr;
- if (zend_hash_update(plist, hashed_details, hashed_details_length+1, (void *) &new_le, sizeof(list_entry),NULL)==FAILURE) {
- free(sybase_ptr);
- efree(hashed_details);
- dbloginfree(sybase.login);
- RETURN_FALSE;
- }
- php3_sybase_module.num_persistent++;
- php3_sybase_module.num_links++;
- } else { /* we do */
- if (le->type != php3_sybase_module.le_plink) {
- php_error(E_WARNING,"Sybase: Hashed persistent link is not a Sybase link!");
- RETURN_FALSE;
- }
-
- sybase_ptr = (sybase_link *) le->ptr;
- /* test that the link hasn't died */
- if (DBDEAD(sybase_ptr->link)==TRUE) {
- if ((sybase_ptr->link=dbopen(sybase_ptr->login,host))==FAIL) {
- /*php_error(E_WARNING,"Sybase: Link to server lost, unable to reconnect");*/
- zend_hash_del(plist, hashed_details, hashed_details_length+1);
- efree(hashed_details);
- RETURN_FALSE;
- }
- if (dbsetopt(sybase_ptr->link,DBBUFFER,"2",-1)==FAIL) {
- zend_hash_del(plist, hashed_details, hashed_details_length+1);
- efree(hashed_details);
- RETURN_FALSE;
- }
- }
- }
- return_value->value.lval = php3_list_insert(sybase_ptr,php3_sybase_module.le_plink);
- return_value->type = IS_LONG;
- } else { /* non persistent */
- list_entry *index_ptr,new_index_ptr;
-
- /* first we check the hash for the hashed_details key. if it exists,
- * it should point us to the right offset where the actual sybase link sits.
- * if it doesn't, open a new sybase link, add it to the resource list,
- * and add a pointer to it with hashed_details as the key.
- */
- if (zend_hash_find(list,hashed_details,hashed_details_length+1,(void **) &index_ptr)==SUCCESS) {
- int type,link;
- void *ptr;
-
- if (index_ptr->type != le_index_ptr) {
- RETURN_FALSE;
- }
- link = (int) index_ptr->ptr;
- ptr = php3_list_find(link,&type); /* check if the link is still there */
- if (ptr && (type==php3_sybase_module.le_link || type==php3_sybase_module.le_plink)) {
- return_value->value.lval = php3_sybase_module.default_link = link;
- return_value->type = IS_LONG;
- efree(hashed_details);
- return;
- } else {
- zend_hash_del(list,hashed_details,hashed_details_length+1);
- }
- }
- if (php3_sybase_module.max_links!=-1 && php3_sybase_module.num_links>=php3_sybase_module.max_links) {
- php_error(E_WARNING,"Sybase: Too many open links (%d)",php3_sybase_module.num_links);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- if ((sybase.link=dbopen(sybase.login,host))==NULL) {
- /*php_error(E_WARNING,"Sybase: Unable to connect to server: %s",sybase_error(sybase));*/
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- if (dbsetopt(sybase.link,DBBUFFER,"2",-1)==FAIL) {
- efree(hashed_details);
- dbloginfree(sybase.login);
- dbclose(sybase.link);
- RETURN_FALSE;
- }
-
- /* add it to the list */
- sybase_ptr = (sybase_link *) emalloc(sizeof(sybase_link));
- memcpy(sybase_ptr,&sybase,sizeof(sybase_link));
- return_value->value.lval = php3_list_insert(sybase_ptr,php3_sybase_module.le_link);
- return_value->type = IS_LONG;
-
- /* add it to the hash */
- new_index_ptr.ptr = (void *) return_value->value.lval;
- new_index_ptr.type = le_index_ptr;
- if (zend_hash_update(list,hashed_details,hashed_details_length+1,(void *) &new_index_ptr, sizeof(list_entry),NULL)==FAILURE) {
- efree(hashed_details);
- RETURN_FALSE;
- }
- php3_sybase_module.num_links++;
- }
- efree(hashed_details);
- php3_sybase_module.default_link=return_value->value.lval;
-}
-
-
-static int php3_sybase_get_default_link(INTERNAL_FUNCTION_PARAMETERS)
-{
- if (php3_sybase_module.default_link==-1) { /* no link opened yet, implicitly open one */
- ht = 0;
- php3_sybase_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
- }
- return php3_sybase_module.default_link;
-}
-
-
-PHP_FUNCTION(sybase_connect)
-{
- php3_sybase_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
-}
-
-PHP_FUNCTION(sybase_pconnect)
-{
- php3_sybase_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
-}
-
-
-PHP_FUNCTION(sybase_close)
-{
- pval *sybase_link_index;
- int id,type;
-
- switch (ARG_COUNT(ht)) {
- case 0:
- id = php3_sybase_module.default_link;
- break;
- case 1:
- if (getParameters(ht, 1, &sybase_link_index)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(sybase_link_index);
- id = sybase_link_index->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- php3_list_find(id,&type);
- if (type!=php3_sybase_module.le_link && type!=php3_sybase_module.le_plink) {
- php_error(E_WARNING,"%d is not a Sybase link index",id);
- RETURN_FALSE;
- }
-
- php3_list_delete(id);
- RETURN_TRUE;
-}
-
-
-PHP_FUNCTION(sybase_select_db)
-{
- pval *db,*sybase_link_index;
- int id,type;
- sybase_link *sybase_ptr;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &db)==FAILURE) {
- RETURN_FALSE;
- }
- id = php3_sybase_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- break;
- case 2:
- if (getParameters(ht, 2, &db, &sybase_link_index)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(sybase_link_index);
- id = sybase_link_index->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- CHECK_LINK(id);
-
- sybase_ptr = (sybase_link *) php3_list_find(id,&type);
- if (type!=php3_sybase_module.le_link && type!=php3_sybase_module.le_plink) {
- php_error(E_WARNING,"%d is not a Sybase link index",id);
- RETURN_FALSE;
- }
-
- convert_to_string(db);
-
- if (dbuse(sybase_ptr->link,db->value.str.val)==FAIL) {
- /*php_error(E_WARNING,"Sybase: Unable to select database: %s",sybase_error(sybase));*/
- RETURN_FALSE;
- } else {
- RETURN_TRUE;
- }
-}
-
-
-static void php3_sybase_get_column_content(sybase_link *sybase_ptr,int offset,pval *result, int column_type)
-{
- if (dbdatlen(sybase_ptr->link,offset) == 0) {
- var_reset(result);
- return;
- }
-
- switch (column_type)
- {
- case SYBINT2:
- case SYBINT4: {
- result->value.lval = (long) anyintcol(offset);
- result->type = IS_LONG;
- break;
- }
- case SYBCHAR:
- case SYBTEXT: {
- int length;
- char *data = charcol(offset);
-
- length=dbdatlen(sybase_ptr->link,offset);
- while (length>0 && charcol(offset)[length-1] == ' ') { /* nuke trailing whitespace */
- length--;
- }
- result->value.str.val = estrndup(data,length);
- result->value.str.len = length;
- result->type = IS_STRING;
- break;
- }
- /*case SYBFLT8:*/
- case SYBREAL: {
- result->value.dval = (double) floatcol(offset);
- result->type = IS_DOUBLE;
- break;
- }
- default: {
- if (dbwillconvert(coltype(offset),SYBCHAR)) {
- char *res_buf;
- int res_length = dbdatlen(sybase_ptr->link,offset);
- register char *p;
-
- switch (coltype(offset)) {
- case SYBBINARY:
- case SYBVARBINARY:
- case SYBCHAR:
- case SYBVARCHAR:
- case SYBTEXT:
- case SYBIMAGE:
- break;
- default:
- /* take no chances, no telling how big the result would really be */
- res_length += 20;
- break;
- }
-
- res_buf = (char *) emalloc(res_length+1);
- dbconvert(NULL,coltype(offset),dbdata(sybase_ptr->link,offset), res_length,SYBCHAR,res_buf,-1);
-
- /* get rid of trailing spaces */
- p = res_buf + res_length;
- while (*p == ' ') {
- p--;
- res_length--;
- }
- *(++p) = 0; /* put a trailing NULL */
-
- result->value.str.len = res_length;
- result->value.str.val = res_buf;
- result->type = IS_STRING;
- } else {
- php_error(E_WARNING,"Sybase: column %d has unknown data type (%d)", offset, coltype(offset));
- var_reset(result);
- }
- }
- }
-}
-
-
-PHP_FUNCTION(sybase_query)
-{
- pval *query,*sybase_link_index;
- int id,type,retvalue;
- sybase_link *sybase_ptr;
- sybase_result *result;
- int num_fields;
- int blocks_initialized=1;
- int i,j;
- int *column_types;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &query)==FAILURE) {
- RETURN_FALSE;
- }
- id = php3_sybase_module.default_link;
- break;
- case 2:
- if (getParameters(ht, 2, &query, &sybase_link_index)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(sybase_link_index);
- id = sybase_link_index->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- sybase_ptr = (sybase_link *) php3_list_find(id,&type);
- if (type!=php3_sybase_module.le_link && type!=php3_sybase_module.le_plink) {
- php_error(E_WARNING,"%d is not a Sybase link index",id);
- RETURN_FALSE;
- }
-
- convert_to_string(query);
- if (dbcmd(sybase_ptr->link,query->value.str.val)==FAIL) {
- /*php_error(E_WARNING,"Sybase: Unable to set query");*/
- RETURN_FALSE;
- }
- if (dbsqlexec(sybase_ptr->link)==FAIL || dbresults(sybase_ptr->link)==FAIL) {
- /*php_error(E_WARNING,"Sybase: Query failed");*/
- RETURN_FALSE;
- }
-
- /* The following is more or less the equivalent of mysql_store_result().
- * fetch all rows from the server into the row buffer, thus:
- * 1) Being able to fire up another query without explicitly reading all rows
- * 2) Having numrows accessible
- */
-
- retvalue=dbnextrow(sybase_ptr->link);
-
- if (retvalue==FAIL) {
- RETURN_FALSE;
- }
-
- num_fields = dbnumcols(sybase_ptr->link);
- if (num_fields<=0) {
- RETURN_TRUE;
- }
-
- column_types = (int *) emalloc(sizeof(int) * num_fields);
- for (i=0; i<num_fields; i++) {
- column_types[i] = coltype(i+1);
- }
-
- result = (sybase_result *) emalloc(sizeof(sybase_result));
- result->data = (pval **) emalloc(sizeof(pval *)*SYBASE_ROWS_BLOCK);
- result->sybase_ptr = sybase_ptr;
- result->cur_field=result->cur_row=result->num_rows=0;
- result->num_fields = num_fields;
-
- i=0;
- while (retvalue!=FAIL && retvalue!=NO_MORE_ROWS) {
- result->num_rows++;
- if (result->num_rows > blocks_initialized*SYBASE_ROWS_BLOCK) {
- result->data = (pval **) erealloc(result->data,sizeof(pval *)*SYBASE_ROWS_BLOCK*(++blocks_initialized));
- }
- result->data[i] = (pval *) emalloc(sizeof(pval)*num_fields);
- for (j=1; j<=num_fields; j++) {
- php3_sybase_get_column_content(sybase_ptr, j, &result->data[i][j-1], column_types[j-1]);
- if (!php3_sybase_module.compatability_mode) {
- convert_to_string(&result->data[i][j-1]);
- }
- }
- retvalue=dbnextrow(sybase_ptr->link);
- dbclrbuf(sybase_ptr->link,DBLASTROW(sybase_ptr->link)-1);
- i++;
- }
- result->num_rows = DBCOUNT(sybase_ptr->link);
-
- result->fields = (sybase_field *) emalloc(sizeof(sybase_field)*num_fields);
- j=0;
- for (i=0; i<num_fields; i++) {
- char *fname = dbcolname(sybase_ptr->link,i+1);
- char computed_buf[16];
-
- if (*fname) {
- result->fields[i].name = estrdup(fname);
- } else {
- if (j>0) {
- snprintf(computed_buf,16,"computed%d",j);
- } else {
- strcpy(computed_buf,"computed");
- }
- result->fields[i].name = estrdup(computed_buf);
- j++;
- }
- result->fields[i].max_length = dbcollen(sybase_ptr->link,i+1);
- result->fields[i].column_source = estrdup(dbcolsource(sybase_ptr->link,i+1));
- if (!result->fields[i].column_source) {
- result->fields[i].column_source = empty_string;
- }
- result->fields[i].type = column_types[i];
- /* set numeric flag */
- switch (column_types[i]) {
- case SYBINT2:
- case SYBINT4:
- case SYBFLT8:
- case SYBREAL:
- result->fields[i].numeric = 1;
- break;
- case SYBCHAR:
- case SYBTEXT:
- default:
- result->fields[i].numeric = 0;
- break;
- }
- }
- efree(column_types);
- return_value->value.lval = php3_list_insert(result,php3_sybase_module.le_result);
- return_value->type = IS_LONG;
-}
-
-
-PHP_FUNCTION(sybase_free_result)
-{
- pval *sybase_result_index;
- sybase_result *result;
- int type;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &sybase_result_index)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(sybase_result_index);
- if (sybase_result_index->value.lval==0) {
- RETURN_FALSE;
- }
- result = (sybase_result *) php3_list_find(sybase_result_index->value.lval,&type);
-
- if (type!=php3_sybase_module.le_result) {
- php_error(E_WARNING,"%d is not a Sybase result index",sybase_result_index->value.lval);
- RETURN_FALSE;
- }
- php3_list_delete(sybase_result_index->value.lval);
- RETURN_TRUE;
-}
-
-
-PHP_FUNCTION(sybase_get_last_message)
-{
- RETURN_STRING(php3_sybase_module.server_message,1);
-}
-
-
-PHP_FUNCTION(sybase_num_rows)
-{
- pval *result_index;
- int type,id;
- sybase_result *result;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result_index)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(result_index);
- id = result_index->value.lval;
-
- result = (sybase_result *) php3_list_find(id,&type);
- if (type!=php3_sybase_module.le_result) {
- php_error(E_WARNING,"%d is not a Sybase result index",id);
- RETURN_FALSE;
- }
-
- return_value->value.lval = result->num_rows;
- return_value->type = IS_LONG;
-}
-
-
-PHP_FUNCTION(sybase_num_fields)
-{
- pval *result_index;
- int type,id;
- sybase_result *result;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result_index)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(result_index);
- id = result_index->value.lval;
-
- result = (sybase_result *) php3_list_find(id,&type);
- if (type!=php3_sybase_module.le_result) {
- php_error(E_WARNING,"%d is not a Sybase result index",id);
- RETURN_FALSE;
- }
-
- return_value->value.lval = result->num_fields;
- return_value->type = IS_LONG;
-}
-
-
-PHP_FUNCTION(sybase_fetch_row)
-{
- pval *sybase_result_index;
- int type,i,id;
- sybase_result *result;
- pval *field_content;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &sybase_result_index)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(sybase_result_index);
- id = sybase_result_index->value.lval;
-
- result = (sybase_result *) php3_list_find(id,&type);
- if (type!=php3_sybase_module.le_result) {
- php_error(E_WARNING,"%d is not a Sybase result index",id);
- RETURN_FALSE;
- }
-
- if (result->cur_row >= result->num_rows) {
- RETURN_FALSE;
- }
-
- array_init(return_value);
- for (i=0; i<result->num_fields; i++) {
- MAKE_STD_ZVAL(field_content);
- *field_content = result->data[result->cur_row][i];
- pval_copy_constructor(field_content);
- zend_hash_index_update(return_value->value.ht, i, (void *) &field_content, sizeof(pval *), NULL);
- }
- result->cur_row++;
-}
-
-
-static PHP_FUNCTION(sybase_fetch_hash)
-{
- pval *sybase_result_index;
- sybase_result *result;
- int type;
- int i;
- pval *tmp;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &sybase_result_index)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(sybase_result_index);
- result = (sybase_result *) php3_list_find(sybase_result_index->value.lval,&type);
-
- if (type!=php3_sybase_module.le_result) {
- php_error(E_WARNING,"%d is not a Sybase result index",sybase_result_index->value.lval);
- RETURN_FALSE;
- }
-
- if (result->cur_row >= result->num_rows) {
- RETURN_FALSE;
- }
-
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
-
- for (i=0; i<result->num_fields; i++) {
- MAKE_STD_ZVAL(tmp);
- *tmp = result->data[result->cur_row][i];
- pval_copy_constructor(tmp);
- if (PG(magic_quotes_runtime) && tmp->type == IS_STRING) {
- tmp->value.str.val = php_addslashes(tmp->value.str.val,tmp->value.str.len,&tmp->value.str.len,1);
- }
- zend_hash_index_update(return_value->value.ht, i, (void *) &tmp, sizeof(pval *), NULL);
- tmp->refcount++;
- zend_hash_update(return_value->value.ht, result->fields[i].name, strlen(result->fields[i].name)+1, (void *) &tmp, sizeof(pval *), NULL);
- }
- result->cur_row++;
-}
-
-
-PHP_FUNCTION(sybase_fetch_object)
-{
- php3_sybase_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- if (return_value->type==IS_ARRAY) {
- return_value->type=IS_OBJECT;
- return_value->value.obj.properties = return_value->value.ht;
- return_value->value.obj.ce = &zend_standard_class_def;
- }
-}
-
-
-PHP_FUNCTION(sybase_fetch_array)
-{
- php3_sybase_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-
-PHP_FUNCTION(sybase_data_seek)
-{
- pval *sybase_result_index,*offset;
- int type,id;
- sybase_result *result;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &sybase_result_index, &offset)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(sybase_result_index);
- id = sybase_result_index->value.lval;
-
- result = (sybase_result *) php3_list_find(id,&type);
- if (type!=php3_sybase_module.le_result) {
- php_error(E_WARNING,"%d is not a Sybase result index",id);
- RETURN_FALSE;
- }
-
- convert_to_long(offset);
- if (offset->value.lval<0 || offset->value.lval>=result->num_rows) {
- php_error(E_WARNING,"Sybase: Bad row offset");
- RETURN_FALSE;
- }
-
- result->cur_row = offset->value.lval;
- RETURN_TRUE;
-}
-
-
-static char *php3_sybase_get_field_name(int type)
-{
- switch (type) {
- case SYBBINARY:
- case SYBVARBINARY:
- return "blob";
- break;
- case SYBCHAR:
- case SYBVARCHAR:
- case SYBTEXT:
- return "string";
- case SYBDATETIME:
- case SYBDATETIME4:
- case SYBDATETIMN:
- return "datetime";
- break;
- case SYBDECIMAL:
- case SYBFLT8:
- case SYBFLTN:
- case SYBREAL:
- case SYBNUMERIC:
- return "real";
- break;
- case SYBINT1:
- case SYBINT2:
- case SYBINT4:
- case SYBINTN:
- return "int";
- break;
- case SYBMONEY:
- case SYBMONEY4:
- case SYBMONEYN:
- return "money";
- break;
- case SYBBIT:
- return "bit";
- break;
- case SYBIMAGE:
- return "image";
- break;
- default:
- return "unknown";
- break;
- }
-}
-
-
-PHP_FUNCTION(sybase_fetch_field)
-{
- pval *sybase_result_index,*offset;
- int type,id,field_offset;
- sybase_result *result;
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &sybase_result_index)==FAILURE) {
- RETURN_FALSE;
- }
- field_offset=-1;
- break;
- case 2:
- if (getParameters(ht, 2, &sybase_result_index, &offset)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(offset);
- field_offset = offset->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- convert_to_long(sybase_result_index);
- id = sybase_result_index->value.lval;
-
- result = (sybase_result *) php3_list_find(id,&type);
- if (type!=php3_sybase_module.le_result) {
- php_error(E_WARNING,"%d is not a Sybase result index",id);
- RETURN_FALSE;
- }
-
- if (field_offset==-1) {
- field_offset = result->cur_field;
- result->cur_field++;
- }
-
- if (field_offset<0 || field_offset >= result->num_fields) {
- if (ARG_COUNT(ht)==2) { /* field specified explicitly */
- php_error(E_WARNING,"Sybase: Bad column offset");
- }
- RETURN_FALSE;
- }
-
- if (object_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
- add_property_string(return_value, "name",result->fields[field_offset].name, 1);
- add_property_long(return_value, "max_length",result->fields[field_offset].max_length);
- add_property_string(return_value, "column_source",result->fields[field_offset].column_source, 1);
- add_property_long(return_value, "numeric", result->fields[field_offset].numeric);
- add_property_string(return_value, "type", php3_sybase_get_field_name(result->fields[field_offset].type), 1);
-}
-
-PHP_FUNCTION(sybase_field_seek)
-{
- pval *sybase_result_index,*offset;
- int type,id,field_offset;
- sybase_result *result;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &sybase_result_index, &offset)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(sybase_result_index);
- id = sybase_result_index->value.lval;
-
- result = (sybase_result *) php3_list_find(id,&type);
- if (type!=php3_sybase_module.le_result) {
- php_error(E_WARNING,"%d is not a Sybase result index",id);
- RETURN_FALSE;
- }
-
- convert_to_long(offset);
- field_offset = offset->value.lval;
-
- if (field_offset<0 || field_offset >= result->num_fields) {
- php_error(E_WARNING,"Sybase: Bad column offset");
- RETURN_FALSE;
- }
-
- result->cur_field = field_offset;
- RETURN_TRUE;
-}
-
-
-PHP_FUNCTION(sybase_result)
-{
- pval *row, *field, *sybase_result_index;
- int id,type,field_offset=0;
- sybase_result *result;
-
-
- if (ARG_COUNT(ht)!=3 || getParameters(ht, 3, &sybase_result_index, &row, &field)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(sybase_result_index);
- id = sybase_result_index->value.lval;
-
- result = (sybase_result *) php3_list_find(id,&type);
- if (type!=php3_sybase_module.le_result) {
- php_error(E_WARNING,"%d is not a Sybase result index",id);
- RETURN_FALSE;
- }
-
- convert_to_long(row);
- if (row->value.lval<0 || row->value.lval>=result->num_rows) {
- php_error(E_WARNING,"Sybase: Bad row offset (%d)",row->value.lval);
- RETURN_FALSE;
- }
-
- switch(field->type) {
- case IS_STRING: {
- int i;
-
- for (i=0; i<result->num_fields; i++) {
- if (!strcasecmp(result->fields[i].name,field->value.str.val)) {
- field_offset = i;
- break;
- }
- }
- if (i>=result->num_fields) { /* no match found */
- php_error(E_WARNING,"Sybase: %s field not found in result",field->value.str.val);
- RETURN_FALSE;
- }
- break;
- }
- default:
- convert_to_long(field);
- field_offset = field->value.lval;
- if (field_offset<0 || field_offset>=result->num_fields) {
- php_error(E_WARNING,"Sybase: Bad column offset specified");
- RETURN_FALSE;
- }
- break;
- }
-
- *return_value = result->data[row->value.lval][field_offset];
- pval_copy_constructor(return_value);
-}
-
-
-void php3_info_sybase(ZEND_MODULE_INFO_FUNC_ARGS)
-{
- char maxp[16],maxl[16];
-
- if (php3_sybase_module.max_persistent==-1) {
- strcpy(maxp,"Unlimited");
- } else {
- snprintf(maxp,15,"%ld",php3_sybase_module.max_persistent);
- maxp[15]=0;
- }
- if (php3_sybase_module.max_links==-1) {
- strcpy(maxl,"Unlimited");
- } else {
- snprintf(maxl,15,"%ld",php3_sybase_module.max_links);
- maxl[15]=0;
- }
- php_printf("<table cellpadding=5>"
- "<tr><td>Allow persistent links:</td><td>%s</td></tr>\n"
- "<tr><td>Persistent links:</td><td>%d/%s</td></tr>\n"
- "<tr><td>Total links:</td><td>%d/%s</td></tr>\n"
- "<tr><td>Application name:</td><td>%s</td></tr>\n"
- "<tr><td valign=\"top\" width=\"20%%\">Client API information:</td><td><pre>%s</pre></td></tr>\n"
- "</table>\n",
- (php3_sybase_module.allow_persistent?"Yes":"No"),
- php3_sybase_module.num_persistent,maxp,
- php3_sybase_module.num_links,maxl,
- php3_sybase_module.appname,
- dbversion());
-}
-
-
-PHP_FUNCTION(sybase_min_error_severity)
-{
- pval *severity;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &severity)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(severity);
- php3_sybase_module.min_error_severity = severity->value.lval;
-}
-
-
-PHP_FUNCTION(sybase_min_message_severity)
-{
- pval *severity;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &severity)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(severity);
- php3_sybase_module.min_message_severity = severity->value.lval;
-}
-
-#endif
diff --git a/ext/sybase_ct/Makefile.am b/ext/sybase_ct/Makefile.am
deleted file mode 100644
index 7b32991c10..0000000000
--- a/ext/sybase_ct/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_sybase_ct.a
-libphpext_sybase_ct_a_SOURCES=php_sybase_ct.c
-
diff --git a/ext/sybase_ct/config.h.stub b/ext/sybase_ct/config.h.stub
deleted file mode 100644
index 7edaee454c..0000000000
--- a/ext/sybase_ct/config.h.stub
+++ /dev/null
@@ -1,4 +0,0 @@
-/* Define if you have libdnet_stub (used for Sybase support) */
-#define HAVE_LIBDNET_STUB 0
-
-#define HAVE_SYBASE_CT 0
diff --git a/ext/sybase_ct/config.m4 b/ext/sybase_ct/config.m4
deleted file mode 100644
index d2cde0d9ca..0000000000
--- a/ext/sybase_ct/config.m4
+++ /dev/null
@@ -1,42 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(for Sybase-CT support)
-AC_ARG_WITH(sybase-ct,
-[ --with-sybase-ct[=DIR] Include Sybase-CT support. DIR is the Sybase home
- directory, defaults to /home/sybase.],
-[
- if test "$withval" != "no"; then
- AC_MSG_RESULT(yes)
- if test -z "$SYBASE_LIBS"; then
- PHP_EXTENSION(sybase_ct)
- fi
- AC_DEFINE(HAVE_SYBASE_CT)
- if test "$withval" = "yes"; then
- SYBASE_CT_INCDIR=/home/sybase/include
- SYBASE_CT_LIBDIR=/home/sybase/lib
- else
- SYBASE_CT_INCDIR=$withval/include
- SYBASE_CT_LIBDIR=$withval/lib
- fi
- AC_ADD_INCLUDE($SYBASE_CT_INCDIR)
- AC_ADD_LIBPATH($SYBASE_CT_LIBDIR)
- AC_ADD_LIBRARY(cs)
- AC_ADD_LIBRARY(ct)
- AC_ADD_LIBRARY(comn)
- AC_ADD_LIBRARY(intl)
- SYBASE_CT_LIBS="-lcs -lct -lcomn -lintl"
- old_LDFLAGS=$LDFLAGS
- LDFLAGS="$LDFLAGS -L$SYBASE_CT_LIBDIR"
- AC_CHECK_LIB(tcl, netg_errstr,
- [ AC_ADD_LIBRARY(tcl) ],
- [ AC_ADD_LIBRARY(sybtcl) ],
- [ $SYBASE_CT_LIBS ])
- AC_CHECK_LIB(insck, insck__getVdate,
- [ AC_ADD_LIBRARY(insck) ])
- LDFLAGS=$old_LDFLAGS
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
diff --git a/ext/sybase_ct/php_sybase_ct.c b/ext/sybase_ct/php_sybase_ct.c
deleted file mode 100644
index 8580896932..0000000000
--- a/ext/sybase_ct/php_sybase_ct.c
+++ /dev/null
@@ -1,1566 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- | Tom May <tom@go2net.com> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-
-#include "php.h"
-#include "php_sybase_ct.h"
-#include "ext/standard/php3_standard.h"
-#include "php_globals.h"
-
-#if HAVE_SYBASE_CT
-
-
-
-function_entry sybase_functions[] = {
- PHP_FE(sybase_connect, NULL)
- PHP_FE(sybase_pconnect, NULL)
- PHP_FE(sybase_close, NULL)
- PHP_FE(sybase_select_db, NULL)
- PHP_FE(sybase_query, NULL)
- PHP_FE(sybase_free_result, NULL)
- PHP_FE(sybase_num_rows, NULL)
- PHP_FE(sybase_num_fields, NULL)
- PHP_FE(sybase_fetch_row, NULL)
- PHP_FE(sybase_fetch_array, NULL)
- PHP_FE(sybase_fetch_object, NULL)
- PHP_FE(sybase_data_seek, NULL)
- PHP_FE(sybase_fetch_field, NULL)
- PHP_FE(sybase_result, NULL)
- PHP_FE(sybase_affected_rows, NULL)
- PHP_FE(sybase_min_client_severity, NULL)
- PHP_FE(sybase_min_server_severity, NULL)
-
- PHP_FALIAS(mssql_connect, sybase_connect, NULL)
- PHP_FALIAS(mssql_pconnect, sybase_pconnect, NULL)
- PHP_FALIAS(mssql_close, sybase_close, NULL)
- PHP_FALIAS(mssql_select_db, sybase_select_db, NULL)
- PHP_FALIAS(mssql_query, sybase_query, NULL)
- PHP_FALIAS(mssql_free_result, sybase_free_result, NULL)
- PHP_FALIAS(mssql_num_rows, sybase_num_rows, NULL)
- PHP_FALIAS(mssql_num_fields, sybase_num_fields, NULL)
- PHP_FALIAS(mssql_fetch_row, sybase_fetch_row, NULL)
- PHP_FALIAS(mssql_fetch_array, sybase_fetch_array, NULL)
- PHP_FALIAS(mssql_fetch_object, sybase_fetch_object, NULL)
- PHP_FALIAS(mssql_data_seek, sybase_data_seek, NULL)
- PHP_FALIAS(mssql_fetch_field, sybase_fetch_field, NULL)
- PHP_FALIAS(mssql_result, sybase_result, NULL)
- PHP_FALIAS(mssql_affected_rows, sybase_affected_rows, NULL)
- PHP_FALIAS(mssql_min_client_severity, sybase_min_client_severity, NULL)
- PHP_FALIAS(mssql_min_server_severity, sybase_min_server_severity, NULL)
- {NULL, NULL, NULL}
-};
-
-zend_module_entry sybase_module_entry = {
- "Sybase SQL - CT", sybase_functions, PHP_MINIT(sybase), PHP_MSHUTDOWN(sybase), PHP_RINIT(sybase), PHP_RSHUTDOWN(sybase), PHP_MINFO(sybase), STANDARD_MODULE_PROPERTIES
-};
-
-#if COMPILE_DL
-zend_module_entry *get_module() { return &sybase_module_entry; }
-#endif
-
-php_sybase_globals sybase_globals;
-static CS_CONTEXT *context;
-static HashTable *resource_list,*resource_plist;
-
-#define CHECK_LINK(link) { if (link==-1) { php_error(E_WARNING,"Sybase: A link to the server could not be established"); RETURN_FALSE; } }
-
-
-static int _clean_invalid_results(list_entry *le)
-{
- if (le->type == sybase_globals.le_result) {
- sybase_link *sybase_ptr = ((sybase_result *) le->ptr)->sybase_ptr;
-
- if (!sybase_ptr->valid) {
- return 1;
- }
- }
- return 0;
-}
-
-
-static void _free_sybase_result(sybase_result *result)
-{
- int i,j;
-
- if (result->data) {
- for (i=0; i<result->num_rows; i++) {
- for (j=0; j<result->num_fields; j++) {
- pval_destructor(&result->data[i][j]);
- }
- efree(result->data[i]);
- }
- efree(result->data);
- }
-
- if (result->fields) {
- for (i=0; i<result->num_fields; i++) {
- STR_FREE(result->fields[i].name);
- STR_FREE(result->fields[i].column_source);
- }
- efree(result->fields);
- }
-
- efree(result);
-}
-
-
-static void _close_sybase_link(sybase_link *sybase_ptr)
-{
- CS_INT con_status;
-
- sybase_ptr->valid = 0;
- zend_hash_apply(resource_list,(int (*)(void *))_clean_invalid_results);
-
- /* Non-persistent connections will always be connected or we wouldn't
- * get here, but since we want to check the death status anyway
- * we might as well double-check the connect status.
- */
- if (ct_con_props(sybase_ptr->connection, CS_GET, CS_CON_STATUS,
- &con_status, CS_UNUSED, NULL)!=CS_SUCCEED) {
- php_error(E_WARNING,"Sybase: Unable to get connection status on close");
- /* Assume the worst. */
- con_status = CS_CONSTAT_CONNECTED | CS_CONSTAT_DEAD;
- }
- if (con_status & CS_CONSTAT_CONNECTED) {
- if ((con_status & CS_CONSTAT_DEAD) || ct_close(sybase_ptr->connection, CS_UNUSED)!=CS_SUCCEED) {
- ct_close(sybase_ptr->connection, CS_FORCE_CLOSE);
- }
- }
-
- ct_con_drop(sybase_ptr->connection);
- efree(sybase_ptr);
- sybase_globals.num_links--;
-}
-
-
-static void _close_sybase_plink(sybase_link *sybase_ptr)
-{
- CS_INT con_status;
-
- /* Persistent connections may have been closed before a failed
- * reopen attempt.
- */
- if (ct_con_props(sybase_ptr->connection, CS_GET, CS_CON_STATUS,
- &con_status, CS_UNUSED, NULL)!=CS_SUCCEED) {
- php_error(E_WARNING,"Sybase: Unable to get connection status on close");
- /* Assume the worst. */
- con_status = CS_CONSTAT_CONNECTED | CS_CONSTAT_DEAD;
- }
- if (con_status & CS_CONSTAT_CONNECTED) {
- if ((con_status & CS_CONSTAT_DEAD) || ct_close(sybase_ptr->connection, CS_UNUSED)!=CS_SUCCEED) {
- ct_close(sybase_ptr->connection, CS_FORCE_CLOSE);
- }
- }
-
- ct_con_drop(sybase_ptr->connection);
- free(sybase_ptr);
- sybase_globals.num_persistent--;
- sybase_globals.num_links--;
-}
-
-
-static CS_RETCODE _client_message_handler(CS_CONTEXT *context, CS_CONNECTION *connection, CS_CLIENTMSG *errmsg)
-{
- if (CS_SEVERITY(errmsg->msgnumber) >= sybase_globals.min_client_severity) {
- php_error(E_WARNING,"Sybase: Client message: %s (severity %d)",errmsg->msgstring, CS_SEVERITY(errmsg->msgnumber));
- }
-
- /* If this is a timeout message, return CS_FAIL to cancel the
- * operation and mark the connection as dead.
- */
- if (CS_SEVERITY(errmsg->msgnumber) == CS_SV_RETRY_FAIL &&
- CS_NUMBER(errmsg->msgnumber) == 63 &&
- CS_ORIGIN(errmsg->msgnumber) == 2 &&
- CS_LAYER(errmsg->msgnumber) == 1)
- {
- return CS_FAIL;
- }
-
- return CS_SUCCEED;
-}
-
-
-static CS_RETCODE _server_message_handler(CS_CONTEXT *context, CS_CONNECTION *connection, CS_SERVERMSG *srvmsg)
-{
- if (srvmsg->severity >= sybase_globals.min_server_severity) {
- php_error(E_WARNING,"Sybase: Server message: %s (severity %d, procedure %s)",
- srvmsg->text, srvmsg->severity, ((srvmsg->proclen>0) ? srvmsg->proc : "N/A"));
- }
-
- /* If this is a deadlock message, set the connection's deadlock flag
- * so we will retry the request. Sorry about the bare constant here,
- * but it's not defined anywhere and it's a "well-known" number.
- */
- if (srvmsg->msgnumber == 1205) {
- sybase_link *sybase;
-
- if (ct_con_props(connection, CS_GET, CS_USERDATA, &sybase, CS_SIZEOF(sybase), NULL)==CS_SUCCEED) {
- sybase->deadlock = 1;
- }
- else {
- /* oh well */
- }
- }
-
- return CS_SUCCEED;
-}
-
-
-PHP_MINIT_FUNCTION(sybase)
-{
- long timeout;
-
- if (cs_ctx_alloc(CTLIB_VERSION, &context)!=CS_SUCCEED || ct_init(context,CTLIB_VERSION)!=CS_SUCCEED) {
- return FAILURE;
- }
- /* Initialize message handlers */
-
- if (ct_callback(context, NULL, CS_SET, CS_SERVERMSG_CB, (CS_VOID *)_server_message_handler)!=CS_SUCCEED) {
- php_error(E_WARNING,"Sybase: Unable to set server message handler");
- }
- if (ct_callback(context, NULL, CS_SET, CS_CLIENTMSG_CB, (CS_VOID *)_client_message_handler)!=CS_SUCCEED) {
- php_error(E_WARNING,"Sybase: Unable to set client message handler");
- }
-
- /* Set datetime conversion format to "Nov 3 1998 8:06PM".
- * This is the default format for the ct-lib that comes with
- * Sybase ASE 11.5.1 for Solaris, but the Linux libraries that
- * come with 11.0.3.3 default to "03/11/98" which is singularly
- * useless. This levels the playing field for all platforms.
- */
- {
- CS_INT dt_convfmt = CS_DATES_SHORT;
- if (cs_dt_info(context, CS_SET, NULL, CS_DT_CONVFMT, CS_UNUSED, &dt_convfmt, sizeof(dt_convfmt), NULL)!=CS_SUCCEED) {
- php_error(E_WARNING,"Sybase: Unable to set datetime conversion format");
- }
- }
-
- /* Set the login and command timeouts. These are per-context and
- * can't be set with ct_con_props(), so set them globally from
- * their config values if requested. The defaults are 1 minute
- * for CS_LOGIN_TIMEOUT and CS_NO_LIMIT for CS_TIMEOUT. The latter
- * especially is fairly useless for web applications.
- * Note that depite some noise in the documentation about using
- * signals to implement timeouts, they are actually implemented
- * by using poll() or select() on Solaris and Linux.
- */
- if (cfg_get_long("sybase.login_timeout",&timeout)==SUCCESS) {
- CS_INT cs_login_timeout = timeout;
- if (ct_config(context, CS_SET, CS_LOGIN_TIMEOUT, &cs_login_timeout, CS_UNUSED, NULL)!=CS_SUCCEED) {
- php_error(E_WARNING,"Sybase: Unable to set login timeoutt");
- }
- }
- if (cfg_get_long("sybase.timeout",&timeout)==SUCCESS) {
- CS_INT cs_timeout = timeout;
- if (ct_config(context, CS_SET, CS_TIMEOUT, &cs_timeout, CS_UNUSED, NULL)!=CS_SUCCEED) {
- php_error(E_WARNING,"Sybase: Unable to set timeout");
- }
- }
-
- if (cfg_get_long("sybase.allow_persistent",&sybase_globals.allow_persistent)==FAILURE) {
- sybase_globals.allow_persistent=1;
- }
- if (cfg_get_long("sybase.max_persistent",&sybase_globals.max_persistent)==FAILURE) {
- sybase_globals.max_persistent=-1;
- }
- if (cfg_get_long("sybase.max_links",&sybase_globals.max_links)==FAILURE) {
- sybase_globals.max_links=-1;
- }
- if (cfg_get_long("sybase.min_server_severity",&sybase_globals.cfg_min_server_severity)==FAILURE) {
- sybase_globals.cfg_min_server_severity=10;
- }
- if (cfg_get_long("sybase.min_client_severity",&sybase_globals.cfg_min_client_severity)==FAILURE) {
- sybase_globals.cfg_min_client_severity=10;
- }
-
- if (cfg_get_string("sybase.hostname",&sybase_globals.hostname)==FAILURE
- || sybase_globals.hostname[0]==0) {
- sybase_globals.hostname=NULL;
- }
-
- sybase_globals.num_persistent=0;
- sybase_globals.le_link = register_list_destructors(_close_sybase_link,NULL);
- sybase_globals.le_plink = register_list_destructors(NULL,_close_sybase_plink);
- sybase_globals.le_result = register_list_destructors(_free_sybase_result,NULL);
-
- return SUCCESS;
-}
-
-
-
-PHP_RINIT_FUNCTION(sybase)
-{
- sybase_globals.default_link=-1;
- sybase_globals.num_links = sybase_globals.num_persistent;
- sybase_globals.appname = estrndup("PHP 3.0",7);
- sybase_globals.server_message = NULL;
- sybase_globals.min_server_severity = sybase_globals.cfg_min_server_severity;
- sybase_globals.min_client_severity = sybase_globals.cfg_min_client_severity;
- return SUCCESS;
-}
-
-
-
-PHP_MSHUTDOWN_FUNCTION(sybase)
-{
-/* ct_exit(context,CS_UNUSED);
- cs_ctx_drop(context); */
- return SUCCESS;
-}
-
-
-PHP_RSHUTDOWN_FUNCTION(sybase)
-{
- efree(sybase_globals.appname);
- if (sybase_globals.server_message) {
- efree(sybase_globals.server_message);
- }
- return SUCCESS;
-}
-
-
-static int php_sybase_do_connect_internal(sybase_link *sybase, char *host, char *user, char *passwd)
-{
- /* set a CS_CONNECTION record */
- if (ct_con_alloc(context, &sybase->connection)!=CS_SUCCEED) {
- php_error(E_WARNING,"Sybase: Unable to allocate connection record");
- return 0;
- }
-
- /* Note - this saves a copy of sybase, not a pointer to it. */
- if (ct_con_props(sybase->connection, CS_SET, CS_USERDATA, &sybase, CS_SIZEOF(sybase), NULL)!=CS_SUCCEED) {
- php_error(E_WARNING,"Sybase: Unable to set userdata");
- ct_con_drop(sybase->connection);
- return 0;
- }
-
- if (user) {
- ct_con_props(sybase->connection, CS_SET, CS_USERNAME, user, CS_NULLTERM, NULL);
- }
- if (passwd) {
- ct_con_props(sybase->connection, CS_SET, CS_PASSWORD, passwd, CS_NULLTERM, NULL);
- }
- ct_con_props(sybase->connection, CS_SET, CS_APPNAME, sybase_globals.appname, CS_NULLTERM, NULL);
-
- if (sybase_globals.hostname) {
- ct_con_props(sybase->connection, CS_SET, CS_HOSTNAME, sybase_globals.hostname, CS_NULLTERM, NULL);
- }
-
- sybase->valid = 1;
- sybase->dead = 0;
-
- /* create the link */
- if (ct_connect(sybase->connection, host, CS_NULLTERM)!=CS_SUCCEED) {
- php_error(E_WARNING,"Sybase: Unable to connect");
- ct_con_drop(sybase->connection);
- return 0;
- }
-
- if (ct_cmd_alloc(sybase->connection,&sybase->cmd)!=CS_SUCCEED) {
- php_error(E_WARNING,"Sybase: Unable to allocate command record");
- ct_close(sybase->connection,CS_UNUSED);
- ct_con_drop(sybase->connection);
- return 0;
- }
-
- return 1;
-}
-
-
-static void php_sybase_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
-{
- char *user,*passwd,*host;
- char *hashed_details;
- int hashed_details_length;
- sybase_link *sybase_ptr;
-
- resource_list = list;
- resource_plist = plist;
-
- switch(ARG_COUNT(ht)) {
- case 0: /* defaults */
- host=user=passwd=NULL;
- hashed_details_length=5+3;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- strcpy(hashed_details,"sybase___");
- break;
- case 1: {
- pval *yyhost;
-
- if (getParameters(ht, 1, &yyhost)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(yyhost);
- host = yyhost->value.str.val;
- user=passwd=NULL;
- hashed_details_length = yyhost->value.str.len+5+3;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details,"sybase_%s__",yyhost->value.str.val);
- }
- break;
- case 2: {
- pval *yyhost,*yyuser;
-
- if (getParameters(ht, 2, &yyhost, &yyuser)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(yyhost);
- convert_to_string(yyuser);
- host = yyhost->value.str.val;
- user = yyuser->value.str.val;
- passwd=NULL;
- hashed_details_length = yyhost->value.str.len+yyuser->value.str.len+5+3;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details,"sybase_%s_%s_",yyhost->value.str.val,yyuser->value.str.val);
- }
- break;
- case 3: {
- pval *yyhost,*yyuser,*yypasswd;
-
- if (getParameters(ht, 3, &yyhost, &yyuser, &yypasswd) == FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(yyhost);
- convert_to_string(yyuser);
- convert_to_string(yypasswd);
- host = yyhost->value.str.val;
- user = yyuser->value.str.val;
- passwd = yypasswd->value.str.val;
- hashed_details_length = yyhost->value.str.len+yyuser->value.str.len+yypasswd->value.str.len+5+3;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details,"sybase_%s_%s_%s",yyhost->value.str.val,yyuser->value.str.val,yypasswd->value.str.val); /* SAFE */
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
-
- if (!sybase_globals.allow_persistent) {
- persistent=0;
- }
- if (persistent) {
- list_entry *le;
-
- /* try to find if we already have this link in our persistent list */
- if (zend_hash_find(plist, hashed_details, hashed_details_length+1, (void **) &le)==FAILURE) { /* we don't */
- list_entry new_le;
-
- if (sybase_globals.max_links!=-1 && sybase_globals.num_links>=sybase_globals.max_links) {
- php_error(E_WARNING,"Sybase: Too many open links (%d)",sybase_globals.num_links);
- efree(hashed_details);
- RETURN_FALSE;
- }
- if (sybase_globals.max_persistent!=-1 && sybase_globals.num_persistent>=sybase_globals.max_persistent) {
- php_error(E_WARNING,"Sybase: Too many open persistent links (%d)",sybase_globals.num_persistent);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- sybase_ptr = (sybase_link *) malloc(sizeof(sybase_link));
- if (!php_sybase_do_connect_internal(sybase_ptr, host, user, passwd)) {
- free(sybase_ptr);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- /* hash it up */
- new_le.type = sybase_globals.le_plink;
- new_le.ptr = sybase_ptr;
- if (zend_hash_update(plist, hashed_details, hashed_details_length+1, (void *) &new_le, sizeof(list_entry),NULL)==FAILURE) {
- ct_close(sybase_ptr->connection, CS_UNUSED);
- ct_con_drop(sybase_ptr->connection);
- free(sybase_ptr);
- efree(hashed_details);
- RETURN_FALSE;
- }
- sybase_globals.num_persistent++;
- sybase_globals.num_links++;
- } else { /* we do */
- CS_INT con_status;
-
- if (le->type != sybase_globals.le_plink) {
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- sybase_ptr = (sybase_link *) le->ptr;
-
- /* If the link has died, close it and overwrite it with a new one. */
-
- if (ct_con_props(sybase_ptr->connection, CS_GET, CS_CON_STATUS,
- &con_status, CS_UNUSED, NULL)!=CS_SUCCEED) {
- php_error(E_WARNING,"Sybase: Unable to get connection status");
- efree(hashed_details);
- RETURN_FALSE;
- }
- if (!(con_status & CS_CONSTAT_CONNECTED) || (con_status & CS_CONSTAT_DEAD) || sybase_ptr->dead) {
- sybase_link sybase;
-
- if (con_status & CS_CONSTAT_CONNECTED) {
- ct_close(sybase_ptr->connection, CS_FORCE_CLOSE);
- }
- /* Create a new connection, then replace the old
- * connection. If we fail to create a new connection,
- * put the old one back so there will be a connection,
- * even if it is a non-functional one. This is because
- * code may still be holding an id for this connection
- * so we can't free the CS_CONNECTION.
- * (This is actually totally hokey, it would be better
- * to just ct_con_drop() the connection and set
- * sybase_ptr->connection to NULL, then test it for
- * NULL before trying to use it elsewhere . . .)
- */
- memcpy(&sybase,sybase_ptr,sizeof(sybase_link));
- if (!php_sybase_do_connect_internal(sybase_ptr, host, user, passwd)) {
- memcpy(sybase_ptr,&sybase,sizeof(sybase_link));
- efree(hashed_details);
- RETURN_FALSE;
- }
- ct_con_drop(sybase.connection); /* drop old connection */
- }
- }
- ZEND_REGISTER_RESOURCE(return_value, sybase_ptr, sybase_globals.le_plink);
- } else { /* non persistent */
- list_entry *index_ptr,new_index_ptr;
-
- /* first we check the hash for the hashed_details key. if it exists,
- * it should point us to the right offset where the actual sybase link sits.
- * if it doesn't, open a new sybase link, add it to the resource list,
- * and add a pointer to it with hashed_details as the key.
- */
- if (zend_hash_find(list,hashed_details,hashed_details_length+1,(void **) &index_ptr)==SUCCESS) {
- int type,link;
- void *ptr;
-
- if (index_ptr->type != le_index_ptr) {
- efree(hashed_details);
- RETURN_FALSE;
- }
- link = (int) index_ptr->ptr;
- ptr = zend_list_find(link,&type); /* check if the link is still there */
- if (ptr && (type==sybase_globals.le_link || type==sybase_globals.le_plink)) {
- return_value->value.lval = sybase_globals.default_link = link;
- return_value->type = IS_LONG;
- efree(hashed_details);
- return;
- } else {
- zend_hash_del(list,hashed_details,hashed_details_length+1);
- }
- }
- if (sybase_globals.max_links!=-1 && sybase_globals.num_links>=sybase_globals.max_links) {
- php_error(E_WARNING,"Sybase: Too many open links (%d)",sybase_globals.num_links);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- sybase_ptr = (sybase_link *) emalloc(sizeof(sybase_link));
- if (!php_sybase_do_connect_internal(sybase_ptr, host, user, passwd)) {
- efree(sybase_ptr);
- efree(hashed_details);
- RETURN_FALSE;
- }
-
- /* add it to the list */
- ZEND_REGISTER_RESOURCE(return_value, sybase_ptr, sybase_globals.le_link);
-
- /* add it to the hash */
- new_index_ptr.ptr = (void *) return_value->value.lval;
- new_index_ptr.type = le_index_ptr;
- if (zend_hash_update(list,hashed_details,hashed_details_length+1,(void *) &new_index_ptr, sizeof(list_entry),NULL)==FAILURE) {
- ct_close(sybase_ptr->connection, CS_UNUSED);
- ct_con_drop(sybase_ptr->connection);
- efree(sybase_ptr);
- efree(hashed_details);
- RETURN_FALSE;
- }
- sybase_globals.num_links++;
- }
- efree(hashed_details);
- sybase_globals.default_link=return_value->value.lval;
-}
-
-
-static int php_sybase_get_default_link(INTERNAL_FUNCTION_PARAMETERS)
-{
- if (sybase_globals.default_link==-1) { /* no link opened yet, implicitly open one */
- ht = 0;
- php_sybase_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
- }
- return sybase_globals.default_link;
-}
-
-
-PHP_FUNCTION(sybase_connect)
-{
- php_sybase_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
-}
-
-PHP_FUNCTION(sybase_pconnect)
-{
- php_sybase_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
-}
-
-
-PHP_FUNCTION(sybase_close)
-{
- pval *sybase_link_index;
- int id;
- sybase_link *sybase_ptr;
-
- switch (ARG_COUNT(ht)) {
- case 0:
- id = sybase_globals.default_link;
- break;
- case 1:
- if (getParameters(ht, 1, &sybase_link_index)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- sybase_ptr = (sybase_link *) zend_fetch_resource_ex(sybase_link_index, id, "Sybase link", 2, sybase_globals.le_link, sybase_globals.le_plink);
- ZEND_VERIFY_RESOURCE(sybase_ptr);
-
- zend_list_delete(id);
-
- RETURN_TRUE;
-}
-
-
-static int exec_cmd(sybase_link *sybase_ptr,char *cmdbuf)
-{
- CS_RETCODE retcode;
- CS_INT restype;
- int failure=0;
-
- /* Fail if we already marked this connection dead. */
-
- if (sybase_ptr->dead) {
- return FAILURE;
- }
-
- /*
- ** Get a command handle, store the command string in it, and
- ** send it to the server.
- */
-
- if (ct_command(sybase_ptr->cmd, CS_LANG_CMD, cmdbuf, CS_NULLTERM, CS_UNUSED)!=CS_SUCCEED) {
- sybase_ptr->dead = 1;
- return FAILURE;
- }
- if (ct_send(sybase_ptr->cmd)!=CS_SUCCEED) {
- sybase_ptr->dead = 1;
- return FAILURE;
- }
-
- while ((retcode = ct_results(sybase_ptr->cmd, &restype))==CS_SUCCEED) {
- switch ((int) restype) {
- case CS_CMD_SUCCEED:
- case CS_CMD_DONE:
- break;
-
- case CS_CMD_FAIL:
- failure=1;
- break;
-
- case CS_STATUS_RESULT:
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_CURRENT);
- break;
-
- default:
- failure=1;
- break;
- }
- if (failure) {
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
- return FAILURE;
- }
- }
-
- switch (retcode) {
- case CS_END_RESULTS:
- return SUCCESS;
- break;
-
- case CS_FAIL:
- /* Hopefully this either cleans up the connection, or the
- * connection ends up marked dead so it will be reopened
- * if it is persistent. We may want to do
- * ct_close(CS_FORCE_CLOSE) if ct_cancel() fails; see the
- * doc for ct_results()==CS_FAIL.
- */
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
- /* Don't take chances with the vagaries of ct-lib. Mark it
- * dead ourselves.
- */
- sybase_ptr->dead = 1;
- return FAILURE;
-
- default:
- return FAILURE;
- }
-}
-
-
-PHP_FUNCTION(sybase_select_db)
-{
- pval *db,*sybase_link_index;
- int id;
- char *cmdbuf;
- sybase_link *sybase_ptr;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &db)==FAILURE) {
- RETURN_FALSE;
- }
- id = php_sybase_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- CHECK_LINK(id);
- break;
- case 2:
- if (getParameters(ht, 2, &db, &sybase_link_index)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- sybase_ptr = (sybase_link *) zend_fetch_resource_ex(sybase_link_index, id, "Sybase link", 2, sybase_globals.le_link, sybase_globals.le_plink);
- ZEND_VERIFY_RESOURCE(sybase_ptr);
-
- convert_to_string(db);
- cmdbuf = (char *) emalloc(sizeof("use ")+db->value.str.len+1);
- sprintf(cmdbuf,"use %s",db->value.str.val); /* SAFE */
-
- if (exec_cmd(sybase_ptr,cmdbuf)==FAILURE) {
- efree(cmdbuf);
- RETURN_FALSE;
- } else {
- efree(cmdbuf);
- RETURN_TRUE;
- }
-}
-
-
-static sybase_result * php_sybase_fetch_result_set (sybase_link *sybase_ptr)
-{
- int num_fields;
- sybase_result *result;
- char **tmp_buffer;
- CS_INT *lengths;
- CS_SMALLINT *indicators;
- unsigned char *numerics;
- CS_INT *types;
- CS_DATAFMT *datafmt;
- int i,j,retcode;
- int blocks_initialized=1;
-
- /* The following is more or less the equivalent of mysql_store_result().
- * fetch all rows from the server into the row buffer, thus:
- * 1) Being able to fire up another query without explicitly reading all rows
- * 2) Having numrows accessible
- */
-
- if (ct_res_info(sybase_ptr->cmd, CS_NUMDATA, &num_fields, CS_UNUSED, NULL)!=CS_SUCCEED) {
- return NULL;
- }
-
- result = (sybase_result *) emalloc(sizeof(sybase_result));
- result->data = (pval **) emalloc(sizeof(pval *)*SYBASE_ROWS_BLOCK);
- result->fields = NULL;
- result->sybase_ptr = sybase_ptr;
- result->cur_field=result->cur_row=result->num_rows=0;
- result->num_fields = num_fields;
-
- tmp_buffer = (char **) emalloc(sizeof(char *)*num_fields);
- lengths = (CS_INT *) emalloc(sizeof(CS_INT)*num_fields);
- indicators = (CS_SMALLINT *) emalloc(sizeof(CS_INT)*num_fields);
- datafmt = (CS_DATAFMT *) emalloc(sizeof(CS_DATAFMT)*num_fields);
- numerics = (unsigned char *) emalloc(sizeof(unsigned char)*num_fields);
- types = (CS_INT *) emalloc(sizeof(CS_INT)*num_fields);
-
-
- for (i=0; i<num_fields; i++) {
- ct_describe(sybase_ptr->cmd,i+1,&datafmt[i]);
- types[i] = datafmt[i].datatype;
- switch (datafmt[i].datatype) {
- case CS_CHAR_TYPE:
- case CS_VARCHAR_TYPE:
- case CS_TEXT_TYPE:
- case CS_IMAGE_TYPE:
- datafmt[i].maxlength++;
- numerics[i] = 0;
- break;
- case CS_BINARY_TYPE:
- case CS_VARBINARY_TYPE:
- datafmt[i].maxlength *= 2;
- datafmt[i].maxlength++;
- numerics[i] = 0;
- break;
- case CS_BIT_TYPE:
- case CS_TINYINT_TYPE:
- datafmt[i].maxlength = 4;
- numerics[i] = 1;
- break;
- case CS_SMALLINT_TYPE:
- datafmt[i].maxlength = 7;
- numerics[i] = 1;
- break;
- case CS_INT_TYPE:
- datafmt[i].maxlength = 12;
- numerics[i] = 1;
- break;
- case CS_REAL_TYPE:
- case CS_FLOAT_TYPE:
- datafmt[i].maxlength = 24;
- numerics[i] = 1;
- break;
- case CS_MONEY_TYPE:
- case CS_MONEY4_TYPE:
- datafmt[i].maxlength = 24;
- numerics[i] = 0;
- break;
- case CS_DATETIME_TYPE:
- case CS_DATETIME4_TYPE:
- datafmt[i].maxlength = 30;
- numerics[i] = 0;
- break;
- case CS_NUMERIC_TYPE:
- case CS_DECIMAL_TYPE:
- datafmt[i].maxlength = datafmt[i].precision + 3;
- numerics[i] = 1;
- break;
- default:
- datafmt[i].maxlength++;
- numerics[i] = 0;
- break;
- }
- tmp_buffer[i] = (char *)emalloc(datafmt[i].maxlength);
- datafmt[i].datatype = CS_CHAR_TYPE;
- datafmt[i].format = CS_FMT_NULLTERM;
- ct_bind(sybase_ptr->cmd,i+1,&datafmt[i],tmp_buffer[i],&lengths[i],&indicators[i]);
- }
-
- while ((retcode=ct_fetch(sybase_ptr->cmd,CS_UNUSED,CS_UNUSED,CS_UNUSED,NULL))==CS_SUCCEED
- || retcode==CS_ROW_FAIL) {
- /*
- if (retcode==CS_ROW_FAIL) {
- php_error(E_WARNING,"Sybase: Error reading row %d",result->num_rows);
- }
- */
- i = result->num_rows++;
- if (result->num_rows > blocks_initialized*SYBASE_ROWS_BLOCK) {
- result->data = (pval **) erealloc(result->data,sizeof(pval *)*SYBASE_ROWS_BLOCK*(++blocks_initialized));
- }
- result->data[i] = (pval *) emalloc(sizeof(pval)*num_fields);
- for (j=0; j<num_fields; j++) {
- if (indicators[j] == -1) { /* null value */
- var_reset(&result->data[i][j]);
- } else {
- result->data[i][j].value.str.len = lengths[j]-1; /* we don't need the NULL in the length */
- result->data[i][j].value.str.val = estrndup(tmp_buffer[j],lengths[j]);
- result->data[i][j].type = IS_STRING;
- }
- }
- }
-
- if (retcode != CS_END_DATA) {
- _free_sybase_result(result);
- result = NULL;
- } else {
- result->fields = (sybase_field *) emalloc(sizeof(sybase_field)*num_fields);
- j=0;
- for (i=0; i<num_fields; i++) {
- char computed_buf[16];
-
- if (datafmt[i].namelen>0) {
- result->fields[i].name = estrndup(datafmt[i].name,datafmt[i].namelen);
- } else {
- if (j>0) {
- snprintf(computed_buf,16,"computed%d",j);
- } else {
- strcpy(computed_buf,"computed");
- }
- result->fields[i].name = estrdup(computed_buf);
- j++;
- }
- result->fields[i].column_source = empty_string;
- result->fields[i].max_length = datafmt[i].maxlength-1;
- result->fields[i].numeric = numerics[i];
- result->fields[i].type = types[i];
- }
- }
-
- efree(datafmt);
- efree(lengths);
- efree(indicators);
- efree(numerics);
- efree(types);
- for (i=0; i<num_fields; i++) {
- efree(tmp_buffer[i]);
- }
- efree(tmp_buffer);
-
- return result;
-}
-
-
-PHP_FUNCTION(sybase_query)
-{
- pval *query,*sybase_link_index;
- int id;
- sybase_link *sybase_ptr;
- sybase_result *result;
- CS_INT restype;
- CS_RETCODE retcode;
- enum {
- Q_RESULT, /* Success with results. */
- Q_SUCCESS, /* Success but no results. */
- Q_FAILURE, /* Failure, no results. */
- } status;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &query)==FAILURE) {
- RETURN_FALSE;
- }
- id = sybase_globals.default_link;
- break;
- case 2:
- if (getParameters(ht, 2, &query, &sybase_link_index)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- sybase_ptr = (sybase_link *) zend_fetch_resource_ex(sybase_link_index, id, "Sybase link", 2, sybase_globals.le_link, sybase_globals.le_plink);
- ZEND_VERIFY_RESOURCE(sybase_ptr);
-
- convert_to_string(query);
-
- /* Fail if we already marked this connection dead. */
-
- if (sybase_ptr->dead) {
- RETURN_FALSE;
- }
-
- /* Repeat until we don't deadlock. */
-
- for (;;) {
- result = NULL;
- sybase_ptr->deadlock = 0;
- sybase_ptr->affected_rows = 0;
-
- /* On Solaris 11.5, ct_command() can be moved outside the
- * loop, but not on Linux 11.0.
- */
- if (ct_command(sybase_ptr->cmd, CS_LANG_CMD, query->value.str.val, CS_NULLTERM, CS_UNUSED)!=CS_SUCCEED) {
- /* If this didn't work, the connection is screwed but
- * ct-lib might not set CS_CONSTAT_DEAD. So set our own
- * flag. This happens sometimes when the database is restarted
- * and/or its machine is rebooted, and ct_command() returns
- * CS_BUSY for some reason.
- */
- sybase_ptr->dead = 1;
- RETURN_FALSE;
- }
-
- if (ct_send(sybase_ptr->cmd)!=CS_SUCCEED) {
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
- sybase_ptr->dead = 1;
- RETURN_FALSE;
- }
-
- /* Use the first result set or succeed/fail status and discard the
- * others. Applications really shouldn't be making calls that
- * return multiple result sets, but if they do then we need to
- * properly read or cancel them or the connection will become
- * unusable.
- */
- if (ct_results(sybase_ptr->cmd, &restype)!=CS_SUCCEED) {
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
- sybase_ptr->dead = 1;
- RETURN_FALSE;
- }
-
- switch ((int) restype) {
- case CS_CMD_FAIL:
- default:
- status = Q_FAILURE;
- break;
- case CS_CMD_SUCCEED:
- case CS_CMD_DONE: {
- CS_INT row_count;
- if (ct_res_info(sybase_ptr->cmd, CS_ROW_COUNT, &row_count, CS_UNUSED, NULL)==CS_SUCCEED) {
- sybase_ptr->affected_rows = (long)row_count;
- }
- }
- /* Fall through */
- case CS_COMPUTEFMT_RESULT:
- case CS_ROWFMT_RESULT:
- case CS_DESCRIBE_RESULT:
- case CS_MSG_RESULT:
- status = Q_SUCCESS;
- break;
- case CS_COMPUTE_RESULT:
- case CS_CURSOR_RESULT:
- case CS_PARAM_RESULT:
- case CS_ROW_RESULT:
- case CS_STATUS_RESULT:
- result = php_sybase_fetch_result_set(sybase_ptr);
- if (result == NULL) {
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
- sybase_ptr->dead = 1;
- RETURN_FALSE;
- }
- status = Q_RESULT;
- break;
- }
-
- /* The only restype we should get now is CS_CMD_DONE, possibly
- * followed by a CS_STATUS_RESULT/CS_CMD_SUCCEED/CS_CMD_DONE
- * sequence if the command was a stored procedure call. But we
- * still need to read and discard unexpected results. We might
- * want to return a failure in this case because the application
- * won't be getting all the results it asked for.
- */
- while ((retcode = ct_results(sybase_ptr->cmd, &restype))==CS_SUCCEED) {
- switch ((int) restype) {
- case CS_CMD_SUCCEED:
- case CS_CMD_DONE:
- break;
-
- case CS_CMD_FAIL:
- status = Q_FAILURE;
- break;
-
- case CS_COMPUTE_RESULT:
- case CS_CURSOR_RESULT:
- case CS_PARAM_RESULT:
- case CS_ROW_RESULT:
- /* Unexpected results, cancel them. */
- case CS_STATUS_RESULT:
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_CURRENT);
- break;
-
- default:
- status = Q_FAILURE;
- break;
- }
- if (status == Q_FAILURE) {
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
- }
- }
-
- switch (retcode) {
- case CS_END_RESULTS:
- /* Normal. */
- break;
-
- case CS_FAIL:
- /* Hopefully this either cleans up the connection, or the
- * connection ends up marked dead so it will be reopened
- * if it is persistent. We may want to do
- * ct_close(CS_FORCE_CLOSE) if ct_cancel() fails; see the
- * doc for ct_results()==CS_FAIL.
- */
- ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
- /* Don't take chances with the vagaries of ct-lib. Mark it
- * dead ourselves.
- */
- sybase_ptr->dead = 1;
- case CS_CANCELED:
- default:
- status = Q_FAILURE;
- break;
- }
-
- /* If query completed without deadlock, break out of the loop.
- * Sometimes deadlock results in failures and sometimes not,
- * it seems to depend on the server flavor. But we want to
- * retry all deadlocks.
- */
- if (sybase_ptr->dead || sybase_ptr->deadlock == 0) {
- break;
- }
-
- /* Get rid of any results we may have fetched. This happens:
- * e.g., our result set may be a stored procedure status which
- * is returned even if the stored procedure deadlocks. As an
- * optimization, we could try not to fetch results in known
- * deadlock conditions, but deadlock is (should be) rare.
- */
- if (result != NULL) {
- _free_sybase_result(result);
- }
- }
-
- if (status == Q_SUCCESS) {
- RETURN_TRUE;
- }
-
- if (status == Q_FAILURE) {
- if (result != NULL) {
- _free_sybase_result(result);
- }
- RETURN_FALSE;
- }
-
- ZEND_REGISTER_RESOURCE(return_value, result, sybase_globals.le_result);
-}
-
-
-PHP_FUNCTION(sybase_free_result)
-{
- pval *sybase_result_index;
- sybase_result *result;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &sybase_result_index)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (sybase_result_index->type==IS_RESOURCE
- && sybase_result_index->value.lval==0) {
- RETURN_FALSE;
- }
-
- ZEND_FETCH_RESOURCE(result, sybase_result *, sybase_result_index, -1, "Sybase result", sybase_globals.le_result);
-
- zend_list_delete(sybase_result_index->value.lval);
- RETURN_TRUE;
-}
-
-
-#if 0
-PHP_FUNCTION(sybase_get_last_message)
-{
- if (sybase_globals.server_message) {
- RETURN_STRING(sybase_globals.server_message,1);
- }
-}
-#endif
-
-
-PHP_FUNCTION(sybase_num_rows)
-{
- pval *sybase_result_index;
- sybase_result *result;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &sybase_result_index)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(result, sybase_result *, sybase_result_index, -1, "Sybase result", sybase_globals.le_result);
-
- return_value->value.lval = result->num_rows;
- return_value->type = IS_LONG;
-}
-
-
-PHP_FUNCTION(sybase_num_fields)
-{
- pval *sybase_result_index;
- sybase_result *result;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &sybase_result_index)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(result, sybase_result *, sybase_result_index, -1, "Sybase result", sybase_globals.le_result);
-
- return_value->value.lval = result->num_fields;
- return_value->type = IS_LONG;
-}
-
-
-PHP_FUNCTION(sybase_fetch_row)
-{
- pval *sybase_result_index;
- int i;
- sybase_result *result;
- pval *field_content;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &sybase_result_index)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(result, sybase_result *, sybase_result_index, -1, "Sybase result", sybase_globals.le_result);
-
- if (result->cur_row >= result->num_rows) {
- RETURN_FALSE;
- }
-
- array_init(return_value);
- for (i=0; i<result->num_fields; i++) {
- field_content = (pval *) emalloc(sizeof(pval));
- *field_content = result->data[result->cur_row][i];
- INIT_PZVAL(field_content);
- pval_copy_constructor(field_content);
- zend_hash_index_update(return_value->value.ht, i, (void *) &field_content, sizeof(pval* ), NULL);
- }
- result->cur_row++;
-}
-
-
-static void php_sybase_fetch_hash(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *sybase_result_index;
- sybase_result *result;
- int i;
- pval *tmp;
- PLS_FETCH();
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &sybase_result_index)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(result, sybase_result *, sybase_result_index, -1, "Sybase result", sybase_globals.le_result);
-
- if (result->cur_row >= result->num_rows) {
- RETURN_FALSE;
- }
-
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
-
- for (i=0; i<result->num_fields; i++) {
- tmp = (pval *) emalloc(sizeof(pval));
- *tmp = result->data[result->cur_row][i];
- INIT_PZVAL(tmp);
- pval_copy_constructor(tmp);
- if (PG(magic_quotes_runtime) && tmp->type == IS_STRING) {
- tmp->value.str.val = php_addslashes(tmp->value.str.val,tmp->value.str.len,&tmp->value.str.len,1);
- }
- zend_hash_index_update(return_value->value.ht, i, (void *) &tmp, sizeof(pval *), NULL);
- zend_hash_update(return_value->value.ht, result->fields[i].name, strlen(result->fields[i].name)+1, (void *) &tmp, sizeof(pval *), NULL);
- }
- result->cur_row++;
-}
-
-
-PHP_FUNCTION(sybase_fetch_object)
-{
- php_sybase_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- if (return_value->type==IS_ARRAY) {
- return_value->type=IS_OBJECT;
- return_value->value.obj.properties = return_value->value.ht;
- return_value->value.obj.ce = &zend_standard_class_def;
- }
-}
-
-
-PHP_FUNCTION(sybase_fetch_array)
-{
- php_sybase_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-
-PHP_FUNCTION(sybase_data_seek)
-{
- pval *sybase_result_index,*offset;
- sybase_result *result;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &sybase_result_index, &offset)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
-
- ZEND_FETCH_RESOURCE(result, sybase_result *, sybase_result_index, -1, "Sybase result", sybase_globals.le_result);
-
- convert_to_long(offset);
- if (offset->value.lval<0 || offset->value.lval>=result->num_rows) {
- php_error(E_WARNING,"Sybase: Bad row offset");
- RETURN_FALSE;
- }
-
- result->cur_row = offset->value.lval;
- RETURN_TRUE;
-}
-
-
-static char *php_sybase_get_field_name(CS_INT type)
-{
- switch (type) {
- case CS_CHAR_TYPE:
- case CS_VARCHAR_TYPE:
- case CS_TEXT_TYPE:
- return "string";
- break;
- case CS_IMAGE_TYPE:
- return "image";
- break;
- case CS_BINARY_TYPE:
- case CS_VARBINARY_TYPE:
- return "blob";
- break;
- case CS_BIT_TYPE:
- return "bit";
- break;
- case CS_TINYINT_TYPE:
- case CS_SMALLINT_TYPE:
- case CS_INT_TYPE:
- return "int";
- break;
- case CS_REAL_TYPE:
- case CS_FLOAT_TYPE:
- case CS_NUMERIC_TYPE:
- case CS_DECIMAL_TYPE:
- return "real";
- break;
- case CS_MONEY_TYPE:
- case CS_MONEY4_TYPE:
- return "money";
- break;
- case CS_DATETIME_TYPE:
- case CS_DATETIME4_TYPE:
- return "datetime";
- break;
- default:
- return "unknown";
- break;
- }
-}
-
-
-PHP_FUNCTION(sybase_fetch_field)
-{
- pval *sybase_result_index,*offset;
- int field_offset;
- sybase_result *result;
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &sybase_result_index)==FAILURE) {
- RETURN_FALSE;
- }
- field_offset=-1;
- break;
- case 2:
- if (getParameters(ht, 2, &sybase_result_index, &offset)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(offset);
- field_offset = offset->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- ZEND_FETCH_RESOURCE(result, sybase_result *, sybase_result_index, -1, "Sybase result", sybase_globals.le_result);
-
- if (field_offset==-1) {
- field_offset = result->cur_field;
- result->cur_field++;
- }
-
- if (field_offset<0 || field_offset >= result->num_fields) {
- if (ARG_COUNT(ht)==2) { /* field specified explicitly */
- php_error(E_WARNING,"Sybase: Bad column offset");
- }
- RETURN_FALSE;
- }
-
- if (object_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
- add_property_string(return_value, "name",result->fields[field_offset].name, 1);
- add_property_long(return_value, "max_length",result->fields[field_offset].max_length);
- add_property_string(return_value, "column_source",result->fields[field_offset].column_source, 1);
- add_property_long(return_value, "numeric", result->fields[field_offset].numeric);
- add_property_string(return_value, "type", php_sybase_get_field_name(result->fields[field_offset].type), 1);
-}
-
-
-PHP_FUNCTION(sybase_field_seek)
-{
- pval *sybase_result_index,*offset;
- int field_offset;
- sybase_result *result;
-
- if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &sybase_result_index, &offset)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(result, sybase_result *, sybase_result_index, -1, "Sybase result", sybase_globals.le_result);
-
- convert_to_long(offset);
- field_offset = offset->value.lval;
-
- if (field_offset<0 || field_offset >= result->num_fields) {
- php_error(E_WARNING,"Sybase: Bad column offset");
- RETURN_FALSE;
- }
-
- result->cur_field = field_offset;
- RETURN_TRUE;
-}
-
-
-PHP_FUNCTION(sybase_result)
-{
- pval *row, *field, *sybase_result_index;
- int field_offset=0;
- sybase_result *result;
-
-
- if (ARG_COUNT(ht)!=3 || getParameters(ht, 3, &sybase_result_index, &row, &field)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
-
- ZEND_FETCH_RESOURCE(result, sybase_result *, sybase_result_index, -1, "Sybase result", sybase_globals.le_result);
-
- convert_to_long(row);
- if (row->value.lval<0 || row->value.lval>=result->num_rows) {
- php_error(E_WARNING,"Sybase: Bad row offset (%d)",row->value.lval);
- RETURN_FALSE;
- }
-
- switch(field->type) {
- case IS_STRING: {
- int i;
-
- for (i=0; i<result->num_fields; i++) {
- if (!strcasecmp(result->fields[i].name,field->value.str.val)) {
- field_offset = i;
- break;
- }
- }
- if (i>=result->num_fields) { /* no match found */
- php_error(E_WARNING,"Sybase: %s field not found in result",field->value.str.val);
- RETURN_FALSE;
- }
- break;
- }
- default:
- convert_to_long(field);
- field_offset = field->value.lval;
- if (field_offset<0 || field_offset>=result->num_fields) {
- php_error(E_WARNING,"Sybase: Bad column offset specified");
- RETURN_FALSE;
- }
- break;
- }
-
- *return_value = result->data[row->value.lval][field_offset];
- pval_copy_constructor(return_value);
-}
-
-
-PHP_FUNCTION(sybase_affected_rows)
-{
- pval *sybase_link_index;
- sybase_link *sybase_ptr;
- int id;
-
- switch(ARG_COUNT(ht)) {
- case 0:
- id = php_sybase_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- break;
- case 1:
- if (getParameters(ht, 1, &sybase_link_index)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
-
-
- sybase_ptr = (sybase_link *) zend_fetch_resource_ex(sybase_link_index, id, "Sybase link", 2, sybase_globals.le_link, sybase_globals.le_plink);
- ZEND_VERIFY_RESOURCE(sybase_ptr);
-
- return_value->value.lval = sybase_ptr->affected_rows;
- return_value->type = IS_LONG;
-}
-
-
-PHP_MINFO_FUNCTION(sybase)
-{
- char maxp[16],maxl[16];
-
- if (sybase_globals.max_persistent==-1) {
- strcpy(maxp,"Unlimited");
- } else {
- snprintf(maxp,15,"%ld",sybase_globals.max_persistent);
- maxp[15]=0;
- }
- if (sybase_globals.max_links==-1) {
- strcpy(maxl,"Unlimited");
- } else {
- snprintf(maxl,15,"%ld",sybase_globals.max_links);
- maxl[15]=0;
- }
- php_printf("<table cellpadding=5>"
- "<tr><td>Allow persistent links:</td><td>%s</td></tr>\n"
- "<tr><td>Persistent links:</td><td>%d/%s</td></tr>\n"
- "<tr><td>Total links:</td><td>%d/%s</td></tr>\n"
- "<tr><td>Application name:</td><td>%s</td></tr>\n"
- "</table>\n",
- (sybase_globals.allow_persistent?"Yes":"No"),
- sybase_globals.num_persistent,maxp,
- sybase_globals.num_links,maxl,
- sybase_globals.appname);
-}
-
-
-PHP_FUNCTION(sybase_min_client_severity)
-{
- pval *severity;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &severity)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(severity);
- sybase_globals.min_client_severity = severity->value.lval;
-}
-
-
-PHP_FUNCTION(sybase_min_server_severity)
-{
- pval *severity;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &severity)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(severity);
- sybase_globals.min_server_severity = severity->value.lval;
-}
-
-
-#endif
diff --git a/ext/sybase_ct/php_sybase_ct.h b/ext/sybase_ct/php_sybase_ct.h
deleted file mode 100644
index 5388062e8f..0000000000
--- a/ext/sybase_ct/php_sybase_ct.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _PHP3_SYBASE_CT_H
-#define _PHP3_SYBASE_CT_H
-
-#if COMPILE_DL
-#undef HAVE_SYBASE_CT
-#define HAVE_SYBASE_CT 1
-#endif
-
-#if HAVE_SYBASE_CT
-
-#define CTLIB_VERSION CS_VERSION_100
-
-extern zend_module_entry sybase_module_entry;
-#define sybase_module_ptr &sybase_module_entry
-
-PHP_MINIT_FUNCTION(sybase);
-PHP_MSHUTDOWN_FUNCTION(sybase);
-PHP_RINIT_FUNCTION(sybase);
-PHP_RSHUTDOWN_FUNCTION(sybase);
-PHP_MINFO_FUNCTION(sybase);
-
-PHP_FUNCTION(sybase_connect);
-PHP_FUNCTION(sybase_pconnect);
-PHP_FUNCTION(sybase_close);
-PHP_FUNCTION(sybase_select_db);
-PHP_FUNCTION(sybase_query);
-PHP_FUNCTION(sybase_free_result);
-PHP_FUNCTION(sybase_get_last_message);
-PHP_FUNCTION(sybase_num_rows);
-PHP_FUNCTION(sybase_num_fields);
-PHP_FUNCTION(sybase_fetch_row);
-PHP_FUNCTION(sybase_fetch_array);
-PHP_FUNCTION(sybase_fetch_object);
-PHP_FUNCTION(sybase_data_seek);
-PHP_FUNCTION(sybase_result);
-PHP_FUNCTION(sybase_affected_rows);
-PHP_FUNCTION(sybase_field_seek);
-PHP_FUNCTION(sybase_min_client_severity);
-PHP_FUNCTION(sybase_min_server_severity);
-PHP_FUNCTION(sybase_fetch_field);
-
-
-#include <ctpublic.h>
-
-typedef struct {
- long default_link;
- long num_links,num_persistent;
- long max_links,max_persistent;
- long allow_persistent;
- char *appname;
- char *hostname;
- char *server_message;
- int le_link,le_plink,le_result;
- long min_server_severity, min_client_severity;
- long cfg_min_server_severity, cfg_min_client_severity;
-} php_sybase_globals;
-
-typedef struct {
- CS_CONNECTION *connection;
- CS_COMMAND *cmd;
- int valid;
- int deadlock;
- int dead;
- long affected_rows;
-} sybase_link;
-
-#define SYBASE_ROWS_BLOCK 128
-
-typedef struct {
- char *name,*column_source;
- int max_length, numeric;
- CS_INT type;
-} sybase_field;
-
-typedef struct {
- pval **data;
- sybase_field *fields;
- sybase_link *sybase_ptr;
- int cur_row,cur_field;
- int num_rows,num_fields;
-} sybase_result;
-
-
-#else
-
-#define sybase_module_ptr NULL
-
-#endif
-
-#define phpext_sybase_ct_ptr sybase_module_ptr
-
-#endif /* _PHP3_SYBASE_CT_H */
diff --git a/ext/sybase_ct/setup.stub b/ext/sybase_ct/setup.stub
deleted file mode 100644
index 8d549cdd29..0000000000
--- a/ext/sybase_ct/setup.stub
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-sybase-ct 'Sybase-CT support?' yesnodir \
- 'no /home/sybase Sybase-CT install' \
-' Whether to build PHP with Sybase-CT support.'
diff --git a/ext/sysvsem/Makefile.am b/ext/sysvsem/Makefile.am
deleted file mode 100644
index 7ed09a0337..0000000000
--- a/ext/sysvsem/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_sysvsem.a
-libphpext_sysvsem_a_SOURCES=sysvsem.c
-
diff --git a/ext/sysvsem/config.h.stub b/ext/sysvsem/config.h.stub
deleted file mode 100644
index 09634a8cfd..0000000000
--- a/ext/sysvsem/config.h.stub
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Define if you want System V semaphore support.
- */
-#define HAVE_SYSVSEM 0
-
-/* Define if you have union semun.
- */
-#define HAVE_SEMUN 0
diff --git a/ext/sysvsem/config.m4 b/ext/sysvsem/config.m4
deleted file mode 100644
index afdd602e30..0000000000
--- a/ext/sysvsem/config.m4
+++ /dev/null
@@ -1,37 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(whether to enable System V semaphore support)
-AC_ARG_ENABLE(sysvsem,
-[ --enable-sysvsem Enable System V semaphore support.],
-[
- if test "$enableval" = "yes"; then
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(sysvsem)
- AC_DEFINE(HAVE_SYSVSEM, 1)
- AC_CACHE_CHECK(for union semun,php_cv_semun,
- AC_TRY_COMPILE([
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
- ],
- [union semun x;],
- [
- php_cv_semun=yes
- ],[
- php_cv_semun=no
- ])
- )
- if test $php_cv_semun = "yes"; then
- AC_DEFINE(HAVE_SEMUN, 1)
- else
- AC_DEFINE(HAVE_SEMUN, 0)
- fi
- else
- AC_MSG_RESULT(no)
- AC_DEFINE(HAVE_SYSVSEM, 0)
- fi
-],[
- AC_MSG_RESULT(no)
- AC_DEFINE(HAVE_SYSVSEM, 0)
-])
-
diff --git a/ext/sysvsem/php3_sysvsem.h b/ext/sysvsem/php3_sysvsem.h
deleted file mode 100644
index 1a12baab80..0000000000
--- a/ext/sysvsem/php3_sysvsem.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Tom May <tom@go2net.com> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _PHP3_SYSVSEM_H
-#define _PHP3_SYSVSEM_H
-
-#if COMPILE_DL
-#undef HAVE_SYSVSEM
-#define HAVE_SYSVSEM 1
-#endif
-
-#if HAVE_SYSVSEM
-
-extern php3_module_entry sysvsem_module_entry;
-#define sysvsem_module_ptr &sysvsem_module_entry
-
-extern int php3_minit_sysvsem(INIT_FUNC_ARGS);
-extern int php3_rinit_sysvsem(INIT_FUNC_ARGS);
-extern int php3_mshutdown_sysvsem(SHUTDOWN_FUNC_ARGS);
-extern int php3_rshutdown_sysvsem(SHUTDOWN_FUNC_ARGS);
-void php3_info_sysvsem(void);
-PHP_FUNCTION(sysvsem_get);
-PHP_FUNCTION(sysvsem_acquire);
-PHP_FUNCTION(sysvsem_release);
-
-typedef struct {
- int le_sem;
-} sysvsem_module;
-
-typedef struct {
- int id; /* For error reporting. */
- int key; /* For error reporting. */
- int semid; /* Returned by semget(). */
- int count; /* Acquire count for auto-release. */
-} sysvsem_sem;
-
-extern sysvsem_module php3_sysvsem_module;
-
-#else
-
-#define sysvsem_module_ptr NULL
-
-#endif
-
-#define phpext_sysvsem_ptr sysvsem_module_ptr
-
-#endif /* _PHP3_SYSVSEM_H */
diff --git a/ext/sysvsem/setup.stub b/ext/sysvsem/setup.stub
deleted file mode 100644
index cad1279592..0000000000
--- a/ext/sysvsem/setup.stub
+++ /dev/null
@@ -1,5 +0,0 @@
-# $Source$
-# $Id$
-
-define_option enable-sysvsem 'System V semaphores support? ' yesno no \
-' Whether to use the System V semaphores (currently only solaris and linux).'
diff --git a/ext/sysvsem/sysvsem.c b/ext/sysvsem/sysvsem.c
deleted file mode 100644
index a15bf6bcdb..0000000000
--- a/ext/sysvsem/sysvsem.c
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Tom May <tom@go2net.com> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/* This has been built and tested on Solaris 2.6 and Linux 2.1.122.
- * It may not compile or execute correctly on other systems.
- *
- * sas: Works for me on Linux 2.0.36 and FreeBSD 3.0-current
- */
-
-#include "php.h"
-
-#if HAVE_SYSVSEM
-
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
-#include <errno.h>
-
-#include "php3_sysvsem.h"
-
-#if !HAVE_SEMUN && defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ == 6
-
-union semun {
- int val; /* value for SETVAL */
- struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */
- unsigned short int *array; /* array for GETALL, SETALL */
- struct seminfo *__buf; /* buffer for IPC_INFO */
-};
-
-#undef HAVE_SEMUN
-#define HAVE_SEMUN 1
-
-#endif
-
-function_entry sysvsem_functions[] = {
- {"sem_get", php3_sysvsem_get, NULL},
- {"sem_acquire", php3_sysvsem_acquire, NULL},
- {"sem_release", php3_sysvsem_release, NULL},
- {NULL, NULL, NULL}
-};
-
-zend_module_entry sysvsem_module_entry = {
- "System V semaphores", sysvsem_functions, php3_minit_sysvsem, NULL, NULL, NULL, NULL, STANDARD_MODULE_PROPERTIES
-};
-
-#if COMPILE_DL
-php3_module_entry *get_module() { return &sysvsem_module_entry; }
-#endif
-
-
-THREAD_LS sysvsem_module php3_sysvsem_module;
-
-/* Semaphore functions using System V semaphores. Each semaphore
- * actually consists of three semaphores allocated as a unit under the
- * same key. Semaphore 0 (SYSVSEM_SEM) is the actual semaphore, it is
- * initialized to max_acquire and decremented as processes acquire it.
- * The value of semaphore 1 (SYSVSEM_USAGE) is a count of the number
- * of processes using the semaphore. After calling semget(), if a
- * process finds that the usage count is 1, it will set the value of
- * SYSVSEM_SEM to max_acquire. This allows max_acquire to be set and
- * track the PHP code without having a global init routine or external
- * semaphore init code. Except see the bug regarding a race condition
- * php3_sysvsem_get(). Semaphore 2 (SYSVSEM_SETVAL) serializes the
- * calls to GETVAL SYSVSEM_USAGE and SETVAL SYSVSEM_SEM. It can be
- * acquired only when it is zero.
- */
-
-#define SYSVSEM_SEM 0
-#define SYSVSEM_USAGE 1
-#define SYSVSEM_SETVAL 2
-
-
-static void release_sysvsem_sem(sysvsem_sem *sem_ptr)
-{
- struct sembuf sop[2];
-
- /* Decrement the usage count. */
-
- sop[0].sem_num = SYSVSEM_USAGE;
- sop[0].sem_op = -1;
- sop[0].sem_flg = SEM_UNDO;
-
- /* Release the semaphore if it has been acquired but not released. */
-
- if (sem_ptr->count) {
- php_error(E_WARNING, "Releasing SysV semaphore id %d key 0x%x in request cleanup", sem_ptr->id, sem_ptr->key);
-
- sop[1].sem_num = SYSVSEM_SEM;
- sop[1].sem_op = sem_ptr->count;
- sop[1].sem_flg = SEM_UNDO;
- }
- if (semop(sem_ptr->semid, sop, sem_ptr->count ? 2 : 1) == -1) {
- php_error(E_WARNING, "semop() failed in release_sysvsem_sem for key 0x%x: %s", sem_ptr->key, strerror(errno));
- }
-
- efree(sem_ptr);
-}
-
-
-int php3_minit_sysvsem(INIT_FUNC_ARGS)
-{
- php3_sysvsem_module.le_sem = register_list_destructors(release_sysvsem_sem, NULL);
-
- return SUCCESS;
-}
-
-#define SETVAL_WANTS_PTR
-
-#if defined(_AIX)
-#undef SETVAL_WANTS_PTR
-#endif
-
-/* {{{ proto int sem_get(int key [, int max_acquire [, int perm]])
- Return an id for the semaphore with the given key, and allow max_acquire (default 1) processes to acquire it simultaneously. */
-PHP_FUNCTION(sysvsem_get)
-{
- pval *arg_key, *arg_max_acquire, *arg_perm;
- int key, max_acquire, perm;
- int semid;
- struct sembuf sop[3];
- int count;
- sysvsem_sem *sem_ptr;
-#if HAVE_SEMUN
- union semun un;
-#endif
-
- max_acquire = 1;
- perm = 0666;
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &arg_key)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(arg_key);
- key = (int)arg_key->value.lval;
- break;
- case 2:
- if (getParameters(ht, 2, &arg_key, &arg_max_acquire)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(arg_key);
- key = (int)arg_key->value.lval;
- convert_to_long(arg_max_acquire);
- max_acquire = (int)arg_max_acquire->value.lval;
- break;
- case 3:
- if (getParameters(ht, 3, &arg_key, &arg_max_acquire, &arg_perm)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(arg_key);
- key = (int)arg_key->value.lval;
- convert_to_long(arg_max_acquire);
- max_acquire = (int)arg_max_acquire->value.lval;
- convert_to_long(arg_perm);
- perm = (int)arg_perm->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- /* Get/create the semaphore. Note that we rely on the semaphores
- * being zeroed when they are created. Despite the fact that
- * the(?) Linux semget() man page says they are not initialized,
- * the kernel versions 2.0.x and 2.1.z do in fact zero them.
- */
-
- semid = semget(key, 3, perm|IPC_CREAT);
- if (semid == -1) {
- php_error(E_WARNING, "semget() failed for key 0x%x: %s", key, strerror(errno));
- RETURN_FALSE;
- }
-
- /* Find out how many processes are using this semaphore. Note
- * that on Linux (at least) there is a race condition here because
- * semaphore undo on process exit is not atomic, so we could
- * acquire SYSVSEM_SETVAL before a crashed process has decremented
- * SYSVSEM_USAGE in which case count will be greater than it
- * should be and we won't set max_acquire. Fortunately this
- * doesn't actually matter in practice.
- */
-
- /* Wait for sem 1 to be zero . . . */
-
- sop[0].sem_num = SYSVSEM_SETVAL;
- sop[0].sem_op = 0;
- sop[0].sem_flg = 0;
-
- /* . . . and increment it so it becomes non-zero . . . */
-
- sop[1].sem_num = SYSVSEM_SETVAL;
- sop[1].sem_op = 1;
- sop[1].sem_flg = SEM_UNDO;
-
- /* . . . and increment the usage count. */
-
- sop[2].sem_num = SYSVSEM_USAGE;
- sop[2].sem_op = 1;
- sop[2].sem_flg = SEM_UNDO;
- while (semop(semid, sop, 3) == -1) {
- if (errno != EINTR) {
- php_error(E_WARNING, "semop() failed acquiring SYSVSEM_SETVAL for key 0x%x: %s", key, strerror(errno));
- break;
- }
- }
-
- /* Get the usage count. */
-#if HAVE_SEMUN
- count = semctl(semid, SYSVSEM_USAGE, GETVAL, un);
-#else
- count = semctl(semid, SYSVSEM_USAGE, GETVAL, NULL);
-#endif
- if (count == -1) {
- php_error(E_WARNING, "semctl(GETVAL) failed for key 0x%x: %s", key, strerror(errno));
- }
-
- /* If we are the only user, then take this opportunity to set the max. */
-
- if (count == 1) {
-#if HAVE_SEMUN
- /* This is correct for Linux which has union semun. */
- union semun semarg;
- semarg.val = max_acquire;
- if (semctl(semid, SYSVSEM_SEM, SETVAL, semarg) == -1) {
- php_error(E_WARNING, "semctl(SETVAL) failed for key 0x%x: %s", key, strerror(errno));
- }
-#elif defined(SETVAL_WANTS_PTR)
- /* This is correct for Solaris 2.6 which does not have union semun. */
- if (semctl(semid, SYSVSEM_SEM, SETVAL, &max_acquire) == -1) {
- php_error(E_WARNING, "semctl(SETVAL) failed for key 0x%x: %s", key, strerror(errno));
- }
-#else
- /* This works for i.e. AIX */
- if (semctl(semid, SYSVSEM_SEM, SETVAL, max_acquire) == -1) {
- php_error(E_WARNING, "semctl(SETVAL) failed for key 0x%x: %s", key, strerror(errno));
- }
-#endif
- }
-
- /* Set semaphore 1 back to zero. */
-
- sop[0].sem_num = SYSVSEM_SETVAL;
- sop[0].sem_op = -1;
- sop[0].sem_flg = SEM_UNDO;
- while (semop(semid, sop, 1) == -1) {
- if (errno != EINTR) {
- php_error(E_WARNING, "semop() failed releasing SYSVSEM_SETVAL for key 0x%x: %s", key, strerror(errno));
- break;
- }
- }
-
- sem_ptr = (sysvsem_sem *) emalloc(sizeof(sysvsem_sem));
- sem_ptr->key = key;
- sem_ptr->semid = semid;
- sem_ptr->count = 0;
-
- return_value->value.lval = php3_list_insert(sem_ptr, php3_sysvsem_module.le_sem);
- return_value->type = IS_LONG;
-
- sem_ptr->id = (int)return_value->value.lval;
-}
-/* }}} */
-
-static void _php3_sysvsem_semop(INTERNAL_FUNCTION_PARAMETERS, int acquire)
-{
- pval *arg_id;
- int id, type;
- sysvsem_sem *sem_ptr;
- struct sembuf sop;
-
- switch(ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &arg_id)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(arg_id);
- id = (int)arg_id->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- sem_ptr = (sysvsem_sem *) php3_list_find(id, &type);
- if (type!=php3_sysvsem_module.le_sem) {
- php_error(E_WARNING, "%d is not a SysV semaphore index", id);
- RETURN_FALSE;
- }
-
- if (!acquire && sem_ptr->count == 0) {
- php_error(E_WARNING, "SysV semaphore index %d (key 0x%x) is not currently acquired", id, sem_ptr->key);
- RETURN_FALSE;
- }
-
- sop.sem_num = SYSVSEM_SEM;
- sop.sem_op = acquire ? -1 : 1;
- sop.sem_flg = SEM_UNDO;
-
- while (semop(sem_ptr->semid, &sop, 1) == -1) {
- if (errno != EINTR) {
- php_error(E_WARNING, "semop(%s) failed for key 0x%x: %s",
- acquire ? "acquire" : "release", sem_ptr->key, strerror(errno));
- RETURN_FALSE;
- }
- }
-
- sem_ptr->count -= acquire ? -1 : 1;
- RETURN_TRUE;
-}
-
-
-/* {{{ proto int sem_acquire(int id)
- Acquires the semaphore with the given id, blocking if necessary. */
-PHP_FUNCTION(sysvsem_acquire)
-{
- _php3_sysvsem_semop(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-/* {{{ proto int sem_release(int id)
- Releases the semaphore with the given id. */
-PHP_FUNCTION(sysvsem_release)
-{
- _php3_sysvsem_semop(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-#endif /* HAVE_SYSVSEM */
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/sysvshm/Makefile.am b/ext/sysvshm/Makefile.am
deleted file mode 100644
index 9c759a02bb..0000000000
--- a/ext/sysvshm/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_sysvshm.a
-libphpext_sysvshm_a_SOURCES=sysvshm.c
-
diff --git a/ext/sysvshm/config.h.stub b/ext/sysvshm/config.h.stub
deleted file mode 100644
index 9b5f5e35cb..0000000000
--- a/ext/sysvshm/config.h.stub
+++ /dev/null
@@ -1,3 +0,0 @@
-/* Define if you want System V shared memory support.
- */
-#define HAVE_SYSVSHM 0
diff --git a/ext/sysvshm/config.m4 b/ext/sysvshm/config.m4
deleted file mode 100644
index 287841f26d..0000000000
--- a/ext/sysvshm/config.m4
+++ /dev/null
@@ -1,17 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(whether to enable System V shared memory support)
-AC_ARG_ENABLE(sysvshm,
-[ --enable-sysvshm Enable the System V shared memory support],[
- if test "$enableval" = "yes"; then
- AC_DEFINE(HAVE_SYSVSHM, 1)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(sysvshm)
- else
- AC_DEFINE(HAVE_SYSVSHM, 0)
- AC_MSG_RESULT(no)
- fi
-],[
- AC_DEFINE(HAVE_SYSVSHM, 0)
- AC_MSG_RESULT(no)
-])
diff --git a/ext/sysvshm/php3_sysvshm.h b/ext/sysvshm/php3_sysvshm.h
deleted file mode 100644
index 53f9492a6c..0000000000
--- a/ext/sysvshm/php3_sysvshm.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Christian Cartus <chc@idgruppe.de> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _PHP3_SYSVSHM_H
-#define _PHP3_SYSVSHM_H
-
-#if COMPILE_DL
-#undef HAVE_SYSVSHM
-#define HAVE_SYSVSHM 1
-#endif
-
-
-#if HAVE_SYSVSHM
-
-extern php3_module_entry sysvshm_module_entry;
-#define sysvshm_module_ptr &sysvshm_module_entry
-
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-
-typedef struct {
- int le_shm;
- long init_mem;
-} sysvshm_module;
-
-
-typedef struct {
- long key;
- long length;
- long next;
- char mem;
-} sysvshm_chunk;
-
-
-typedef struct {
- char magic[8];
- long start;
- long end;
- long free;
- long total;
-} sysvshm_chunk_head;
-
-
-typedef struct {
- key_t key; /* Key set by user */
- long id; /* Returned by shmget. */
- sysvshm_chunk_head *ptr; /* memoryaddress of shared memory */
-} sysvshm_shm;
-
-
-
-extern int php3_minit_sysvshm(INIT_FUNC_ARGS);
-PHP_FUNCTION(sysvshm_attach);
-PHP_FUNCTION(sysvshm_detach);
-PHP_FUNCTION(sysvshm_remove);
-PHP_FUNCTION(sysvshm_put_var);
-PHP_FUNCTION(sysvshm_get_var);
-PHP_FUNCTION(sysvshm_remove_var);
-extern int php3int_put_shmdata(sysvshm_chunk_head *ptr,long key,char *data, long len);
-extern long php3int_check_shmdata(sysvshm_chunk_head *ptr, long key);
-extern int php3int_remove_shmdata(sysvshm_chunk_head *ptr, long shm_varpos);
-
-extern sysvshm_module php3_sysvshm_module;
-
-#else
-
-#define sysvshm_module_ptr NULL
-
-#endif
-
-#define phpext_sysvshm_ptr sysvshm_module_ptr
-
-#endif /* _PHP3_SYSVSHM_H */
diff --git a/ext/sysvshm/setup.stub b/ext/sysvshm/setup.stub
deleted file mode 100644
index 4a9e894b4e..0000000000
--- a/ext/sysvshm/setup.stub
+++ /dev/null
@@ -1,5 +0,0 @@
-# $Source$
-# $Id$
-
-define_option enable-sysvshm 'System V shared memory support? ' yesno no \
-' Whether to use the System V shared memory (currently only Solaris and Linux).'
diff --git a/ext/sysvshm/sysvshm.c b/ext/sysvshm/sysvshm.c
deleted file mode 100644
index 755edfb75d..0000000000
--- a/ext/sysvshm/sysvshm.c
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Christian Cartus <chc@idgruppe.de> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/* This has been built and tested on Solaris 2.6.
- * It may not compile or execute correctly on other systems.
- */
-
-#include "php.h"
-
-#if HAVE_SYSVSHM
-
-#include <errno.h>
-
-#include "php3_sysvshm.h"
-#include "../standard/php3_var.h"
-
-function_entry sysvshm_functions[] = {
- {"shm_attach", php3_sysvshm_attach, NULL},
- {"shm_detach", php3_sysvshm_detach, NULL},
- {"shm_remove", php3_sysvshm_remove, NULL},
- {"shm_put_var", php3_sysvshm_put_var, NULL},
- {"shm_get_var", php3_sysvshm_get_var, NULL},
- {"shm_remove_var", php3_sysvshm_remove_var, NULL},
- {NULL, NULL, NULL}
-};
-
-php3_module_entry sysvshm_module_entry = {
- "System V Shared-Memory", sysvshm_functions, php3_minit_sysvshm, NULL, NULL, NULL, NULL, STANDARD_MODULE_PROPERTIES
-};
-
-
-#if COMPILE_DL
-php3_module_entry *get_module() { return &sysvshm_module_entry; }
-#endif
-
-
-THREAD_LS sysvshm_module php3_sysvshm_module;
-
-static void php3i_release_sysvshm(sysvshm_shm *shm_ptr)
-{
- shmdt((void*)shm_ptr->ptr);
- efree(shm_ptr);
-}
-
-
-int php3_minit_sysvshm(INIT_FUNC_ARGS)
-{
- php3_sysvshm_module.le_shm = register_list_destructors(php3i_release_sysvshm, NULL);
- if (cfg_get_long("sysvshm.init_mem",
- &php3_sysvshm_module.init_mem)==FAILURE) {
- php3_sysvshm_module.init_mem=10000;
- }
- return SUCCESS;
-}
-
-
-/* {{{ proto int shm_attach(int key, int size, int flag)
- Return an id for the shared memory with the given key. */
-PHP_FUNCTION(sysvshm_attach)
-{
- pval *arg_key,*arg_size,*arg_flag;
- long shm_size,shm_flag;
- sysvshm_shm *shm_list_ptr;
- char *shm_ptr;
- sysvshm_chunk_head *chunk_ptr;
- key_t shm_key;
- long shm_id,list_id;
-
- shm_flag = 0666;
- shm_size = php3_sysvshm_module.init_mem;
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &arg_key)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(arg_key);
- shm_key = arg_key->value.lval;
- break;
- case 2:
- if (getParameters(ht, 2, &arg_key, &arg_size)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(arg_key);
- shm_key = arg_key->value.lval;
- convert_to_long(arg_size);
- shm_size=arg_size->value.lval;
- break;
- case 3:
- if (getParameters(ht, 3, &arg_key, &arg_size, &arg_flag)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(arg_key);
- shm_key = arg_key->value.lval;
- convert_to_long(arg_size);
- shm_size=arg_size->value.lval;
- convert_to_long(arg_flag);
- shm_flag = arg_flag->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
-
- if((shm_list_ptr = (sysvshm_shm *) emalloc(sizeof(sysvshm_shm)))==NULL) {
- php_error(E_WARNING, "shm_attach() failed for key 0x%x: cannot allocate internal listelement", shm_key);
- RETURN_FALSE;
- }
-
- /* get the id from a specified key or create new shared memory */
- if((shm_id=shmget(shm_key,0,0))<0) {
- if(shm_size<sizeof(sysvshm_chunk_head)) {
- php_error(E_WARNING, "shm_attach() failed for key 0x%x: memorysize too small", shm_key);
- RETURN_FALSE;
- }
- if((shm_id=shmget(shm_key,shm_size,shm_flag|IPC_CREAT|IPC_EXCL))<0) {
- php_error(E_WARNING, "shmget() failed for key 0x%x: %s", shm_key, strerror(errno));
- RETURN_FALSE;
- }
- }
-
- if((shm_ptr = shmat(shm_id,NULL,0))==NULL) {
- php_error(E_WARNING, "shmget() failed for key 0x%x: %s", shm_key, strerror(errno));
- RETURN_FALSE;
- }
-
- /* check if shm is already initialized */
- chunk_ptr= (sysvshm_chunk_head*) shm_ptr;
- if(strcmp((char*)&(chunk_ptr->magic),"PHP3SM")!=0) {
- strcpy((char*)&(chunk_ptr->magic),"PHP3SM");
- chunk_ptr->start=sizeof(sysvshm_chunk_head);
- chunk_ptr->end=chunk_ptr->start;
- chunk_ptr->total=shm_size;
- chunk_ptr->free=shm_size-chunk_ptr->end;
- }
-
-
- shm_list_ptr->key = shm_key;
- shm_list_ptr->id = shm_id;
- shm_list_ptr->ptr = chunk_ptr;
- list_id = php3_list_insert(shm_list_ptr, php3_sysvshm_module.le_shm);
- RETURN_LONG(list_id);
-}
-/* }}} */
-
-
-
-/* {{{ proto int shm_detach(int id)
- releases the shared memory attachment with the given id. */
-PHP_FUNCTION(sysvshm_detach)
-{
- pval *arg_id;
- long id;
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &arg_id)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(arg_id);
- id = arg_id->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- php3_list_delete(id);
-}
-/* }}} */
-/* {{{ proto int shm_remove(int key)
- removes the shared memory with the given key. */
-PHP_FUNCTION(sysvshm_remove)
-{
- pval *arg_key;
- long id;
- key_t key;
-
-
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht, 1, &arg_key)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(arg_key);
- key = arg_key->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- if((id=shmget(key,0,0))<0) {
- php_error(E_WARNING, "%d is not a existing SysV shared memory key", key);
- RETURN_FALSE;
- }
- if(shmctl(id,IPC_RMID,NULL)<0) {
- php_error(E_WARNING, "shm_remove() failed for key 0x%x: %s", key, strerror(errno));
- RETURN_FALSE;
- }
-
- RETURN_TRUE;
-}
-/* }}} */
-
-
-
-/* {{{ proto int shm_put(int id, int key, object *variable)
- insert a variable into shared memory. */
-PHP_FUNCTION(sysvshm_put_var)
-{
- pval *arg_id, *arg_key, *arg_var;
- long key, id;
- sysvshm_shm *shm_list_ptr;
- int type;
- pval shm_var;
- int ret;
-
- switch (ARG_COUNT(ht)) {
- case 3:
- if (getParameters(ht, 3, &arg_id, &arg_key,&arg_var)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(arg_id);
- id = arg_id->value.lval;
- convert_to_long(arg_key);
- key = arg_key->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- shm_list_ptr = (sysvshm_shm *) php3_list_find(id, &type);
- if (type!=php3_sysvshm_module.le_shm) {
- php_error(E_WARNING, "%d is not a SysV shared memory index", id);
- RETURN_FALSE;
- }
-
- /* setup string-variable and serialize */
-
- shm_var.type=IS_STRING;
- shm_var.value.str.len=0;
- shm_var.value.str.val=0;
- php_var_serialize(&shm_var,&arg_var);
- /* insert serialized variable into shared memory */
- ret=php3int_put_shmdata(shm_list_ptr->ptr,key,shm_var.value.str.val,shm_var.value.str.len);
-
- /* free string */
- efree(shm_var.value.str.val);
-
- if(ret==-1) {
- php_error(E_WARNING, "not enough shared memory left");
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-
-
-
-/* {{{ proto string/float/int/array shm_get_var(int id, int key)
- returns a variable into shared memory. */
-PHP_FUNCTION(sysvshm_get_var)
-{
- pval *arg_id, *arg_key;
- long key, id;
- sysvshm_shm *shm_list_ptr;
- int type;
- char *shm_data;
- long shm_varpos;
- sysvshm_chunk *shm_var;
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &arg_id, &arg_key)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(arg_id);
- id = arg_id->value.lval;
- convert_to_long(arg_key);
- key = arg_key->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- shm_list_ptr = (sysvshm_shm *) php3_list_find(id, &type);
- if (type!=php3_sysvshm_module.le_shm) {
- php_error(E_WARNING, "%d is not a SysV shared memory index", id);
- RETURN_FALSE;
- }
-
- /* setup string-variable and serialize */
- /* get serialized variable from shared memory */
- shm_varpos=php3int_check_shmdata((shm_list_ptr->ptr),key);
-
- if(shm_varpos<0) {
- php_error(E_WARNING, "variable key %d doesn't exist", key);
- RETURN_FALSE;
- }
- shm_var=(sysvshm_chunk*)((char*)shm_list_ptr->ptr+shm_varpos);
- shm_data=&shm_var->mem;
-
- if(php_var_unserialize(&return_value, (const char **) &shm_data, shm_data+shm_var->length)!=1) {
- php_error(E_WARNING, "variable data in shared memory is corruped");
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int shm_remove_var(int id, int key)
- removes variable from shared memory. */
-PHP_FUNCTION(sysvshm_remove_var)
-{
- pval *arg_id, *arg_key;
- long key, id;
- sysvshm_shm *shm_list_ptr;
- int type;
- long shm_varpos;
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &arg_id, &arg_key)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_long(arg_id);
- id = arg_id->value.lval;
- convert_to_long(arg_key);
- key = arg_key->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
- }
-
- shm_list_ptr = (sysvshm_shm *) php3_list_find(id, &type);
- if (type!=php3_sysvshm_module.le_shm) {
- php_error(E_WARNING, "%d is not a SysV shared memory index", id);
- RETURN_FALSE;
- }
-
- shm_varpos=php3int_check_shmdata((shm_list_ptr->ptr),key);
-
- if(shm_varpos<0) {
- php_error(E_WARNING, "variable key %d doesn't exist", key);
- RETURN_FALSE;
- }
- php3int_remove_shmdata((shm_list_ptr->ptr),shm_varpos);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-
-
-
-
-
-/* inserts an ascii-string into shared memory */
-int php3int_put_shmdata(sysvshm_chunk_head *ptr,long key,char *data, long len) {
- sysvshm_chunk* shm_var;
- long total_size;
- long shm_varpos;
-
- total_size=((long)(len+sizeof(sysvshm_chunk)-1)/4)*4+4; /* 4-byte alligment */
-
- if(ptr->free<total_size) {
- return -1; /* not enough memeory */
- }
-
- if((shm_varpos=php3int_check_shmdata(ptr,key))>0) {
- php3int_remove_shmdata(ptr, shm_varpos);
- }
- shm_var=(sysvshm_chunk*)((char *)ptr+ptr->end);
- shm_var->key=key;
- shm_var->length=len;
- shm_var->next=total_size;
- memcpy(&(shm_var->mem),data,len);
- ptr->end+=total_size;
- ptr->free-=total_size;
- return 0;
-}
-
-
-long php3int_check_shmdata(sysvshm_chunk_head *ptr, long key) {
- long pos;
- sysvshm_chunk *shm_var;
-
- pos=ptr->start;
-
- for(;;) {
- if(pos>=ptr->end) {
- return -1;
- }
- shm_var=(sysvshm_chunk*)((char*)ptr+pos);
- if(shm_var->key==key) {
- return pos;
- }
- pos+=shm_var->next;
- }
- return -1;
-}
-
-
-int php3int_remove_shmdata(sysvshm_chunk_head *ptr, long shm_varpos) {
- sysvshm_chunk *chunk_ptr, *next_chunk_ptr;
- long memcpy_len;
-
- chunk_ptr=(sysvshm_chunk*)((char*)ptr+shm_varpos);
- next_chunk_ptr=(sysvshm_chunk*)((char*)ptr+shm_varpos+chunk_ptr->next);
-
- memcpy_len=ptr->end-shm_varpos-chunk_ptr->next;
- ptr->free+=chunk_ptr->next;
- ptr->end-=chunk_ptr->next;
- if(memcpy_len>0)
- memcpy(chunk_ptr,next_chunk_ptr,memcpy_len);
- return 0;
-}
-
-
-
-#endif /* HAVE_SYSVSHM */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/wddx/Makefile.am b/ext/wddx/Makefile.am
deleted file mode 100644
index 435d1604b1..0000000000
--- a/ext/wddx/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_wddx.a
-libphpext_wddx_a_SOURCES=wddx.c
-
diff --git a/ext/wddx/config.h.stub b/ext/wddx/config.h.stub
deleted file mode 100644
index 9dedf15dff..0000000000
--- a/ext/wddx/config.h.stub
+++ /dev/null
@@ -1,2 +0,0 @@
-/* define if you want to use the wddx extension */
-#define HAVE_WDDX 0
diff --git a/ext/wddx/config.m4 b/ext/wddx/config.m4
deleted file mode 100644
index 2b8078f596..0000000000
--- a/ext/wddx/config.m4
+++ /dev/null
@@ -1,20 +0,0 @@
-dnl $Id$
-dnl config.m4 for extension wddx
-
-AC_MSG_CHECKING(whether to include WDDX support)
-AC_ARG_WITH(wddx,
-[ --with-wddx Include WDDX support],[
- if test "$withval" = "yes"; then
- if test "${with_xml+set}" != "set" -o "$with_xml" = "no"; then
- AC_MSG_ERROR(WDDX requires --with-xml)
- else
- AC_DEFINE(HAVE_WDDX, 1)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(wddx)
- fi
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
diff --git a/ext/wddx/php_wddx.h b/ext/wddx/php_wddx.h
deleted file mode 100644
index d2c0c9c74f..0000000000
--- a/ext/wddx/php_wddx.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Andrey Zmievski <andrey@ispi.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _WDDX_H
-#define _WDDX_H
-
-#if HAVE_WDDX
-
-#include "xmlparse.h"
-
-extern int php_minit_wddx(INIT_FUNC_ARGS);
-
-extern zend_module_entry wddx_module_entry;
-#define wddx_module_ptr &wddx_module_entry
-
-PHP_FUNCTION(wddx_serialize_value);
-PHP_FUNCTION(wddx_serialize_vars);
-PHP_FUNCTION(wddx_packet_start);
-PHP_FUNCTION(wddx_packet_end);
-PHP_FUNCTION(wddx_add_vars);
-PHP_FUNCTION(wddx_deserialize);
-
-#else
-
-#define wddx_module_ptr NULL
-
-#endif /* HAVE_WDDX */
-
-#define phpext_wddx_ptr wddx_module_ptr
-
-#endif /* !_WDDX_H */
diff --git a/ext/wddx/php_wddx_api.h b/ext/wddx/php_wddx_api.h
deleted file mode 100644
index 1444464b67..0000000000
--- a/ext/wddx/php_wddx_api.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Andrey Zmievski <andrey@ispi.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef PHP_WDDX_API_H
-#define PHP_WDDX_API_H
-
-#define WDDX_PACKET_S "<wddxPacket version='0.9'>"
-#define WDDX_PACKET_E "</wddxPacket>"
-#define WDDX_HEADER "<header/>"
-#define WDDX_HEADER_COMMENT "<header comment='%s'/>"
-#define WDDX_DATA_S "<data>"
-#define WDDX_DATA_E "</data>"
-#define WDDX_STRING_S "<string>"
-#define WDDX_STRING_E "</string>"
-#define WDDX_CHAR "<char code='%02X'/>"
-#define WDDX_NUMBER "<number>%s</number>"
-#define WDDX_ARRAY_S "<array length='%d'>"
-#define WDDX_ARRAY_E "</array>"
-#define WDDX_VAR_S "<var name='%s'>"
-#define WDDX_VAR_E "</var>"
-#define WDDX_STRUCT_S "<struct>"
-#define WDDX_STRUCT_E "</struct>"
-
-typedef struct _wddx_packet wddx_packet;
-
-wddx_packet *_php_wddx_constructor(void);
-void _php_wddx_destructor(wddx_packet *packet);
-
-void _php_wddx_packet_start(wddx_packet *packet, char *comment);
-void _php_wddx_packet_end(wddx_packet *packet);
-
-void _php_wddx_serialize_var(wddx_packet *packet, zval *var, char *name);
-void _php_wddx_add_chunk(wddx_packet *packet, char *str);
-void _php_wddx_deserialize_ex(char *, int, zval *return_value);
-char *_php_wddx_gather(wddx_packet *packet);
-
-#endif /* PHP_WDDX_API_H */
diff --git a/ext/wddx/setup.stub b/ext/wddx/setup.stub
deleted file mode 100644
index 30500bf406..0000000000
--- a/ext/wddx/setup.stub
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-wddx 'wddx support?' yesnodir no \
-' Whether to build the wddx extension.'
-
diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c
deleted file mode 100644
index 20cc3c590a..0000000000
--- a/ext/wddx/wddx.c
+++ /dev/null
@@ -1,848 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Andrey Zmievski <andrey@ispi.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-#include "php_wddx.h"
-
-#if HAVE_WDDX
-#include "dlist.h"
-
-#include "php_wddx_api.h"
-
-#define WDDX_BUF_LEN 256
-
-#define EL_STRING "string"
-#define EL_CHAR "char"
-#define EL_CHAR_CODE "code"
-#define EL_NUMBER "number"
-#define EL_ARRAY "array"
-#define EL_STRUCT "struct"
-#define EL_VAR "var"
-#define EL_VAR_NAME "name"
-#define EL_PACKET "wddxPacket"
-#define EL_VERSION "version"
-
-#define _php_wddx_deserialize(a,b) \
- _php_wddx_deserialize_ex((a)->value.str.val, (a)->value.str.len, (b))
-
-static int le_wddx;
-
-struct _wddx_packet {
- DLIST *packet_head;
- int packet_length;
-};
-
-typedef struct {
- zval *data;
- enum {
- ST_STRING,
- ST_NUMBER,
- ST_ARRAY,
- ST_STRUCT
- } type;
- char *varname;
-} st_entry;
-
-typedef struct {
- int top, max;
- char *varname;
- void **elements;
-} wddx_stack;
-
-
-/* {{{ function prototypes */
-static void _php_wddx_process_data(void *user_data, const char *s, int len);
-/* }}} */
-
-
-/* {{{ module definition structures */
-
-function_entry wddx_functions[] = {
- PHP_FE(wddx_serialize_value, NULL)
- PHP_FE(wddx_serialize_vars, NULL)
- PHP_FE(wddx_packet_start, NULL)
- PHP_FE(wddx_packet_end, NULL)
- PHP_FE(wddx_add_vars, NULL)
- PHP_FE(wddx_deserialize, NULL)
- {NULL, NULL, NULL}
-};
-
-zend_module_entry wddx_module_entry = {
- "WDDX_A", wddx_functions, php_minit_wddx, NULL, NULL, NULL, NULL, STANDARD_MODULE_PROPERTIES
-};
-
-/* }}} */
-
-
-/* {{{ int wddx_stack_init(wddx_stack *stack) */
-static int wddx_stack_init(wddx_stack *stack)
-{
- stack->top = 0;
- stack->elements = (void **) emalloc(sizeof(void **) * STACK_BLOCK_SIZE);
- if (!stack->elements) {
- return FAILURE;
- } else {
- stack->max = STACK_BLOCK_SIZE;
- stack->varname = NULL;
- return SUCCESS;
- }
-}
-/* }}} */
-
-
-/* {{{ int wddx_stack_push(wddx_stack *stack, void *element, int size) */
-static int wddx_stack_push(wddx_stack *stack, void *element, int size)
-{
- if (stack->top >= stack->max) { /* we need to allocate more memory */
- stack->elements = (void **) erealloc(stack->elements,
- (sizeof(void **) * (stack->max += STACK_BLOCK_SIZE)));
- if (!stack->elements) {
- return FAILURE;
- }
- }
- stack->elements[stack->top] = (void *) emalloc(size);
- memcpy(stack->elements[stack->top], element, size);
- return stack->top++;
-}
-/* }}} */
-
-
-/* {{{ int wddx_stack_top(wddx_stack *stack, void **element) */
-static int wddx_stack_top(wddx_stack *stack, void **element)
-{
- if (stack->top > 0) {
- *element = stack->elements[stack->top - 1];
- return SUCCESS;
- } else {
- *element = NULL;
- return FAILURE;
- }
-}
-/* }}} */
-
-
-/* {{{ int wddx_stack_is_empty(wddx_stack *stack) */
-static int wddx_stack_is_empty(wddx_stack *stack)
-{
- if (stack->top == 0) {
- return 1;
- } else {
- return 0;
- }
-}
-/* }}} */
-
-
-/* {{{ int wddx_stack_destroy(wddx_stack *stack) */
-static int wddx_stack_destroy(wddx_stack *stack)
-{
- register int i;
-
- if (stack->elements) {
- for (i = 0; i < stack->top; i++) {
- if (((st_entry *)stack->elements[i])->data)
- {
- zval_dtor(((st_entry *)stack->elements[i])->data);
- efree(((st_entry *)stack->elements[i])->data);
- }
- efree(stack->elements[i]);
- }
- efree(stack->elements);
- }
- return SUCCESS;
-}
-/* }}} */
-
-
-/* {{{ _php_free_packet_chunk */
-static void _php_free_packet_chunk(char **chunk_ptr)
-{
- if ((*chunk_ptr))
- efree((*chunk_ptr));
-}
-/* }}} */
-
-
-/* {{{ _php_wddx_destructor */
-void _php_wddx_destructor(wddx_packet *packet)
-{
- dlst_kill(packet->packet_head, (void (*)(void *))_php_free_packet_chunk);
- efree(packet);
-}
-/* }}} */
-
-
-/* {{{ php_minit_wddx */
-int php_minit_wddx(INIT_FUNC_ARGS)
-{
- le_wddx = register_list_destructors(_php_wddx_destructor, NULL);
-
- return SUCCESS;
-}
-/* }}} */
-
-
-/* {{{ _php_wddx_add_chunk */
-void _php_wddx_add_chunk(wddx_packet *packet, char *str)
-{
- char **chunk_ptr;
-
- chunk_ptr = (char**)dlst_newnode(sizeof(char *));
- (*chunk_ptr) = estrdup(str);
- dlst_insertafter(packet->packet_head, chunk_ptr, PHP_DLST_TAIL(packet->packet_head));
- packet->packet_length += strlen(str);
-}
-/* }}} */
-
-
-/* {{{ _php_wddx_gather */
-char* _php_wddx_gather(wddx_packet *packet)
-{
- char **chunk;
- char *buf;
-
- buf = (char *)emalloc(packet->packet_length+1);
- buf[0] = '\0';
- for(chunk=dlst_first(packet->packet_head);
- chunk!=NULL;
- chunk = dlst_next(chunk)) {
- strcat(buf, *chunk);
- }
-
- return buf;
-}
-/* }}} */
-
-
-/* {{{ void _php_wddx_packet_start */
-void _php_wddx_packet_start(wddx_packet *packet, char *comment)
-{
- char tmp_buf[WDDX_BUF_LEN];
-
- _php_wddx_add_chunk(packet, WDDX_PACKET_S);
- if (comment)
- {
- sprintf(tmp_buf, WDDX_HEADER_COMMENT, comment);
- _php_wddx_add_chunk(packet, tmp_buf);
- }
- else
- _php_wddx_add_chunk(packet, WDDX_HEADER);
- _php_wddx_add_chunk(packet, WDDX_DATA_S);
-}
-/* }}} */
-
-
-/* {{{ int _php_wddx_packet_end */
-void _php_wddx_packet_end(wddx_packet *packet)
-{
- _php_wddx_add_chunk(packet, WDDX_DATA_E);
- _php_wddx_add_chunk(packet, WDDX_PACKET_E);
-}
-/* }}} */
-
-
-/* {{{ void _php_wddx_serialize_var(wddx_packet *packet, zval *var) */
-static void _php_wddx_serialize_string(wddx_packet *packet, zval *var)
-{
- char *buf,
- *c,
- control_buf[WDDX_BUF_LEN];
- int i;
-
- _php_wddx_add_chunk(packet, WDDX_STRING_S);
-
- if (var->value.str.len > 0) {
- i = 0;
- buf = (char *)emalloc(var->value.str.len);
- for(c=var->value.str.val; *c!='\0'; c++)
- {
- if (iscntrl((int)*c))
- {
- if (*buf)
- {
- buf[i] = '\0';
- _php_wddx_add_chunk(packet, buf);
- i = 0;
- buf[i] = '\0';
- }
- sprintf(control_buf, WDDX_CHAR, *c);
- _php_wddx_add_chunk(packet, control_buf);
- }
- else
- buf[i++] = *c;
- }
- buf[i] = '\0';
- if (*buf)
- _php_wddx_add_chunk(packet, buf);
- efree(buf);
- }
-
- _php_wddx_add_chunk(packet, WDDX_STRING_E);
-}
-/* }}} */
-
-
-/* {{{ void _php_wddx_serialize_number(wddx_packet *packet, zval *var) */
-static void _php_wddx_serialize_number(wddx_packet *packet, zval *var)
-{
- char tmp_buf[WDDX_BUF_LEN];
-
- convert_to_string(var);
- sprintf(tmp_buf, WDDX_NUMBER, var->value.str.val);
- _php_wddx_add_chunk(packet, tmp_buf);
-}
-/* }}} */
-
-
-/* {{{ void _php_wddx_serialize_hash(wddx_packet *packet, zval *var) */
-static void _php_wddx_serialize_hash(wddx_packet *packet, zval *var)
-{
- zval **ent;
- char *key;
- int hash_type, ent_type;
- ulong idx;
- HashTable *target_hash;
- char tmp_buf[WDDX_BUF_LEN];
-
- target_hash = HASH_OF(var);
-
- zend_hash_internal_pointer_reset(target_hash);
-
- hash_type = zend_hash_get_current_key(target_hash, &key, &idx);
-
- if (hash_type == HASH_KEY_IS_STRING) {
- _php_wddx_add_chunk(packet, WDDX_STRUCT_S);
- efree(key);
- } else {
- sprintf(tmp_buf, WDDX_ARRAY_S, zend_hash_num_elements(target_hash));
- _php_wddx_add_chunk(packet, tmp_buf);
- }
-
- while(zend_hash_get_current_data(target_hash, (void**)&ent) == SUCCESS) {
- if (hash_type == HASH_KEY_IS_STRING) {
- ent_type = zend_hash_get_current_key(target_hash, &key, &idx);
-
- if (ent_type == HASH_KEY_IS_STRING) {
- _php_wddx_serialize_var(packet, *ent, key);
- efree(key);
- } else {
- sprintf(tmp_buf, "%ld", idx);
- _php_wddx_serialize_var(packet, *ent, tmp_buf);
- }
- } else
- _php_wddx_serialize_var(packet, *ent, NULL);
-
- zend_hash_move_forward(target_hash);
- }
-
- if (hash_type == HASH_KEY_IS_STRING)
- _php_wddx_add_chunk(packet, WDDX_STRUCT_E);
- else
- _php_wddx_add_chunk(packet, WDDX_ARRAY_E);
-}
-/* }}} */
-
-
-/* {{{ void _php_wddx_serialize_var(wddx_packet *packet, zval *var, char *name) */
-void _php_wddx_serialize_var(wddx_packet *packet, zval *var, char *name)
-{
- char tmp_buf[WDDX_BUF_LEN];
-
- if (name) {
- sprintf(tmp_buf, WDDX_VAR_S, name);
- _php_wddx_add_chunk(packet, tmp_buf);
- }
-
- switch(var->type) {
- case IS_STRING:
- _php_wddx_serialize_string(packet, var);
- break;
-
- case IS_LONG:
- case IS_DOUBLE:
- _php_wddx_serialize_number(packet, var);
- break;
-
- case IS_ARRAY:
- case IS_OBJECT:
- _php_wddx_serialize_hash(packet, var);
- break;
- }
-
- if (name) {
- _php_wddx_add_chunk(packet, WDDX_VAR_E);
- }
-}
-/* }}} */
-
-
-/* {{{ void _php_wddx_add_var(wddx_packet *packet, zval *name_var) */
-static void _php_wddx_add_var(wddx_packet *packet, zval *name_var)
-{
- zval **val;
- HashTable *target_hash;
- ELS_FETCH();
-
- if (name_var->type & IS_STRING)
- {
- if (zend_hash_find(EG(active_symbol_table), name_var->value.str.val,
- name_var->value.str.len+1, (void**)&val) != FAILURE) {
- _php_wddx_serialize_var(packet, *val, name_var->value.str.val);
- }
- }
- else if (name_var->type == IS_ARRAY || name_var->type == IS_OBJECT)
- {
- target_hash = HASH_OF(name_var);
-
- zend_hash_internal_pointer_reset(target_hash);
-
- while(zend_hash_get_current_data(target_hash, (void**)&val) == SUCCESS) {
- _php_wddx_add_var(packet, *val);
-
- zend_hash_move_forward(target_hash);
- }
- }
-}
-/* }}} */
-
-
-/* {{{ void _php_wddx_push_element(void *user_data, const char *name, const char **atts) */
-static void _php_wddx_push_element(void *user_data, const char *name, const char **atts)
-{
- st_entry ent;
- wddx_stack *stack = (wddx_stack *)user_data;
-
- if (!strcmp(name, EL_PACKET)) {
- int i;
-
- for (i=0; atts[i]; i++) {
- if (!strcmp(atts[i], EL_VERSION)) {
- }
- }
- } else if (!strcmp(name, EL_STRING)) {
- ent.type = ST_STRING;
- if (stack->varname) {
- ent.varname = estrdup(stack->varname);
- efree(stack->varname);
- stack->varname = NULL;
- } else
- ent.varname = NULL;
-
- ent.data = (zval *)emalloc(sizeof(zval));
- ent.data->value.str.val = NULL;
- ent.data->value.str.len = 0;
- INIT_PZVAL(ent.data);
- wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));
- } else if (!strcmp(name, EL_CHAR)) {
- int i;
- char tmp_buf[2];
-
- for (i=0; atts[i]; i++) {
- if (!strcmp(atts[i], EL_CHAR_CODE) && atts[i+1]) {
- sprintf(tmp_buf, "%c", (char)strtol(atts[i+1], NULL, 16));
- _php_wddx_process_data(user_data, tmp_buf, strlen(tmp_buf));
- }
- }
- } else if (!strcmp(name, EL_NUMBER)) {
- ent.type = ST_NUMBER;
- if (stack->varname) {
- ent.varname = estrdup(stack->varname);
- efree(stack->varname);
- stack->varname = NULL;
- } else
- ent.varname = NULL;
-
- ent.data = (zval *)emalloc(sizeof(zval));
- INIT_PZVAL(ent.data);
- wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));
- } else if (!strcmp(name, EL_ARRAY)) {
- ent.type = ST_ARRAY;
- if (stack->varname) {
- ent.varname = estrdup(stack->varname);
- efree(stack->varname);
- stack->varname = NULL;
- } else
- ent.varname = NULL;
-
- ent.data = (zval *)emalloc(sizeof(zval));
- array_init(ent.data);
- INIT_PZVAL(ent.data);
- wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));
- } else if (!strcmp(name, EL_STRUCT)) {
- ent.type = ST_STRUCT;
- if (stack->varname) {
- ent.varname = estrdup(stack->varname);
- efree(stack->varname);
- stack->varname = NULL;
- } else
- ent.varname = NULL;
-
- ent.data = (zval *)emalloc(sizeof(zval));
- array_init(ent.data);
- INIT_PZVAL(ent.data);
- wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));
- } else if (!strcmp(name, EL_VAR)) {
- int i;
-
- for (i=0; atts[i]; i++) {
- if (!strcmp(atts[i], EL_VAR_NAME) && atts[i+1]) {
- stack->varname = estrdup(atts[i+1]);
- }
- }
- }
-
-}
-/* }}} */
-
-
-/* {{{ void _php_wddx_pop_element(void *user_data, const char *name) */
-static void _php_wddx_pop_element(void *user_data, const char *name)
-{
- st_entry *ent1, *ent2;
- wddx_stack *stack = (wddx_stack *)user_data;
-
- if (!strcmp(name, EL_STRING) || !strcmp(name, EL_NUMBER) ||
- !strcmp(name, EL_ARRAY) || !strcmp(name, EL_STRUCT)) {
- if (stack->top > 1) {
- wddx_stack_top(stack, (void**)&ent1);
- stack->top--;
- wddx_stack_top(stack, (void**)&ent2);
- if (ent2->data->type == IS_ARRAY) {
- if (ent1->varname) {
- zend_hash_update(ent2->data->value.ht,
- ent1->varname, strlen(ent1->varname)+1,
- &ent1->data, sizeof(zval *), NULL);
- efree(ent1->varname);
- } else {
- zend_hash_next_index_insert(ent2->data->value.ht,
- &ent1->data,
- sizeof(zval *), NULL);
- }
- }
- efree(ent1);
- }
- }
- else if (!strcmp(name, EL_VAR) && stack->varname)
- efree(stack->varname);
-}
-/* }}} */
-
-
-/* {{{ void _php_wddx_process_data(void *user_data, const char *s, int len) */
-static void _php_wddx_process_data(void *user_data, const char *s, int len)
-{
- st_entry *ent;
- wddx_stack *stack = (wddx_stack *)user_data;
-
- if (!wddx_stack_is_empty(stack)) {
- wddx_stack_top(stack, (void**)&ent);
- switch (ent->type) {
- case ST_STRING:
- ent->data->type = IS_STRING;
- if (ent->data->value.str.len == 0) {
- ent->data->value.str.val = estrndup(s, len);
- ent->data->value.str.len = len;
- } else {
- ent->data->value.str.val = erealloc(ent->data->value.str.val,
- ent->data->value.str.len + len + 1);
- strncpy(ent->data->value.str.val+ent->data->value.str.len, s, len);
- ent->data->value.str.len += len;
- ent->data->value.str.val[ent->data->value.str.len] = '\0';
- }
- break;
-
- case ST_NUMBER:
- ent->data->type = IS_STRING;
- ent->data->value.str.len = len;
- ent->data->value.str.val = estrndup(s, len);
- convert_scalar_to_number(ent->data);
- break;
-
- default:
- break;
- }
- }
-}
-/* }}} */
-
-
-/* {{{ void _php_wddx_deserialize_ex(char *value, int vallen, zval *return_value) */
-void _php_wddx_deserialize_ex(char *value, int vallen, zval *return_value)
-{
- wddx_stack stack;
- XML_Parser parser;
- st_entry *ent;
-
- wddx_stack_init(&stack);
- parser = XML_ParserCreate(NULL);
-
- XML_SetUserData(parser, &stack);
- XML_SetElementHandler(parser, _php_wddx_push_element, _php_wddx_pop_element);
- XML_SetCharacterDataHandler(parser, _php_wddx_process_data);
-
- XML_Parse(parser, value, vallen, 1);
-
- XML_ParserFree(parser);
-
- if (!wddx_stack_is_empty(&stack)) {
- wddx_stack_top(&stack, (void**)&ent);
- *return_value = *(ent->data);
- zval_copy_ctor(return_value);
- }
-
- wddx_stack_destroy(&stack);
-}
-/* }}} */
-
-
-/* {{{ proto string wddx_serialize_value(mixed var [, string comment ])
- Creates a new packet and serializes the given value */
-PHP_FUNCTION(wddx_serialize_value)
-{
- int argc;
- zval *var,
- *comment;
- wddx_packet *packet;
- char *buf;
-
- argc = ARG_COUNT(ht);
- if(argc < 1 || argc > 2 || getParameters(ht, argc, &var, &comment) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- packet = emalloc(sizeof(wddx_packet));
- if (!packet) {
- zend_error(E_WARNING, "Unable to allocate memory in php_wddx_packet_start");
- RETURN_FALSE;
- }
-
- packet->packet_head = dlst_init();
- packet->packet_length = 0;
-
- if (argc == 2)
- {
- convert_to_string(comment);
- _php_wddx_packet_start(packet, comment->value.str.val);
- }
- else
- _php_wddx_packet_start(packet, NULL);
-
- _php_wddx_serialize_var(packet, var, NULL);
- _php_wddx_packet_end(packet);
- buf = _php_wddx_gather(packet);
- _php_wddx_destructor(packet);
-
- RETURN_STRING(buf, 0);
-}
-/* }}} */
-
-
-/* {{{ proto string wddx_serialize_vars(. . .)
- Creates a new packet and serializes given variables into a struct */
-PHP_FUNCTION(wddx_serialize_vars)
-{
- int argc, i;
- wddx_packet *packet;
- zval **args;
- char *buf;
-
- argc = ARG_COUNT(ht);
- /* Allocate arguments array and get the arguments, checking for errors. */
- args = (zval **)emalloc(argc * sizeof(zval *));
- if (getParametersArray(ht, argc, args) == FAILURE) {
- efree(args);
- WRONG_PARAM_COUNT;
- }
-
- packet = emalloc(sizeof(wddx_packet));
- if (!packet) {
- zend_error(E_WARNING, "Unable to allocate memory in php_wddx_packet_start");
- RETURN_FALSE;
- }
-
- packet->packet_head = dlst_init();
- packet->packet_length = 0;
-
- _php_wddx_packet_start(packet, NULL);
- _php_wddx_add_chunk(packet, WDDX_STRUCT_S);
-
- for (i=0; i<argc; i++) {
- convert_to_string(args[i]);
- _php_wddx_add_var(packet, args[i]);
- }
-
- _php_wddx_add_chunk(packet, WDDX_STRUCT_E);
- _php_wddx_packet_end(packet);
- buf = _php_wddx_gather(packet);
- _php_wddx_destructor(packet);
-
- efree(args);
-
- RETURN_STRING(buf, 0);
-}
-/* }}} */
-
-wddx_packet *_php_wddx_constructor(void)
-{
- wddx_packet *packet;
-
- packet = emalloc(sizeof(wddx_packet));
- if(!packet) return NULL;
-
- packet->packet_head = dlst_init();
- packet->packet_length = 0;
-
- return packet;
-}
-
-/* {{{ proto int wddx_packet_start([ string comment ])
- Starts a WDDX packet with optional comment and returns the packet id */
-PHP_FUNCTION(wddx_packet_start)
-{
- int argc;
- zval *comment;
- wddx_packet *packet;
-
- comment = NULL;
- argc = ARG_COUNT(ht);
-
- if (argc>1 || (argc==1 && getParameters(ht, 1, &comment)==FAILURE)) {
- WRONG_PARAM_COUNT;
- }
-
- packet = _php_wddx_constructor();
- if (!packet) {
- zend_error(E_WARNING, "Unable to allocate memory in wddx_packet_start");
- RETURN_FALSE;
- }
-
- if (argc == 1) {
- convert_to_string(comment);
- _php_wddx_packet_start(packet, comment->value.str.val);
- }
- else
- _php_wddx_packet_start(packet, NULL);
-
- _php_wddx_add_chunk(packet, WDDX_STRUCT_S);
-
- ZEND_REGISTER_RESOURCE(return_value, packet, le_wddx);
-}
-/* }}} */
-
-
-/* {{{ proto string wddx_packet_end(int packet_id)
- Ends specified WDDX packet and returns the string containing the packet */
-PHP_FUNCTION(wddx_packet_end)
-{
- zval *packet_id;
- char *buf;
- wddx_packet *packet = NULL;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &packet_id)==FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(packet, wddx_packet *, packet_id, -1, "WDDX packet ID", le_wddx);
-
- _php_wddx_add_chunk(packet, WDDX_STRUCT_E);
-
- _php_wddx_packet_end(packet);
-
- buf = _php_wddx_gather(packet);
-
- zend_list_delete(packet_id->value.lval);
-
- RETURN_STRING(buf, 0);
-}
-/* }}} */
-
-
-/* {{{ proto int wddx_add_vars(int packet_id, . . .)
- Serializes given variables and adds them to packet given by packet_id */
-PHP_FUNCTION(wddx_add_vars)
-{
- int argc, i;
- zval **args;
- zval *packet_id;
- wddx_packet *packet = NULL;
-
- argc = ARG_COUNT(ht);
- if (argc < 2) {
- WRONG_PARAM_COUNT;
- }
-
- /* Allocate arguments array and get the arguments, checking for errors. */
- args = (zval **)emalloc(argc * sizeof(zval *));
- if (getParametersArray(ht, argc, args) == FAILURE) {
- efree(args);
- WRONG_PARAM_COUNT;
- }
-
- packet_id = args[0];
-
- packet = (wddx_packet *)zend_fetch_resource(packet_id, -1, "WDDX packet ID", le_wddx);
- if (!packet)
- {
- efree(args);
- RETURN_FALSE;
- }
-
- for (i=1; i<argc; i++) {
- convert_to_string(args[i]);
- _php_wddx_add_var(packet, args[i]);
- }
-
- efree(args);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/* {{{ proto mixed wddx_deserialized(string packet)
- Deserializes given packet and returns a PHP value */
-PHP_FUNCTION(wddx_deserialize)
-{
- zval *packet;
-
- if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &packet) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(packet);
- if (packet->value.str.len == 0)
- return;
-
- _php_wddx_deserialize(packet, return_value);
-}
-/* }}} */
-
-
-#endif /* HAVE_LIBEXPAT */
diff --git a/ext/xml/Makefile.am b/ext/xml/Makefile.am
deleted file mode 100644
index 072ef1c64e..0000000000
--- a/ext/xml/Makefile.am
+++ /dev/null
@@ -1,15 +0,0 @@
-# $Id$
-
-phplibdir=$(libdir)/php
-
-SRC=xml.c
-INCLUDES=@INCLUDES@ @XML_INCLUDE@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=@XML_STATIC@
-EXTRA_LIBRARIES=libphpext_xml.a
-libphpext_xml_a_SOURCES=$(SRC)
-phplib_LTLIBRARIES=@XML_SHARED@
-EXTRA_LTLIBRARIES=xml.la
-xml_la_SOURCES=$(SRC)
-xml_la_LIBADD=@XML_LIBS@
-xml_la_LDFLAGS=-avoid-version -module -rpath $(phplibdir)
-EXTRA_LIBS=
diff --git a/ext/xml/config.h.stub b/ext/xml/config.h.stub
deleted file mode 100644
index a4abe9b584..0000000000
--- a/ext/xml/config.h.stub
+++ /dev/null
@@ -1,4 +0,0 @@
-/* define if you want to use the xml extension */
-
-/* Define if you have the expat (XML Parser Toolkit) library */
-#define HAVE_LIBEXPAT 0
diff --git a/ext/xml/config.m4 b/ext/xml/config.m4
deleted file mode 100644
index 61f70ff606..0000000000
--- a/ext/xml/config.m4
+++ /dev/null
@@ -1,70 +0,0 @@
-# $Source$
-# $Id$
-
-AC_MSG_CHECKING(for XML support)
-AC_ARG_WITH(xml,
-[ --with-xml[=DIR] Include XML support. Will look for expat
- in DIR if specified. Set DIR to "shared" to
- build as a dl, or "shared,DIR" to build as a dl
- and still specify DIR.],[
- case $withval in
- shared)
- shared=yes
- withval=yes
- ;;
- shared,*)
- shared=yes
- withval=`echo $withval | sed -e 's/^shared,//'`
- ;;
- *)
- shared=no
- ;;
- esac
- if test "$withval" != "no"; then
- if test "$shared" = "yes"; then
- AC_MSG_RESULT([yes (shared)])
- else
- AC_MSG_RESULT([yes (static)])
- fi
-
- if test -z "$XML_INCLUDE" ; then
- if test "$withval" = "yes"; then
- test -d /usr/include/xml && XML_INCLUDE="/usr/include/xml"
- test -d /usr/local/include/xml && XML_INCLUDE="/usr/local/include/xml"
- test -d /usr/include/xmltok && XML_INCLUDE="/usr/include/xmltok"
- AC_CHECK_LIB(expat, main, XML_LIBS="-lexpat",
- AC_CHECK_LIB(xmltok, main,
- AC_CHECK_LIB(xmlparse, main, XML_LIBS="-lxmlparse -lxmltok",
- AC_MSG_ERROR(No expat library found for the xml module),"-lxmltok"),
- AC_MSG_ERROR(No expart library found for the xml module))
- )
- else
- XML_LIBS="-L$withval/lib -lexpat"
- if test -d $withval/include/xml; then
- XML_INCLUDE="$withval/include/xml"
- else
- XML_INCLUDE="$withval/include"
- fi
- fi
- fi
- AC_DEFINE(HAVE_LIBEXPAT, 1)
- PHP_EXTENSION(xml, $shared)
- if test "$shared" != "yes"; then
- EXTRA_LIBS="$EXTRA_LIBS $XML_LIBS"
- AC_ADD_INCLUDE($XML_INCLUDE)
- XML_INCLUDE=""
- XML_STATIC="libphpext_xml.a"
- else
- XML_INCLUDE="-I$XML_INCLUDE"
- XML_SHARED="xml.la"
- fi
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-AC_SUBST(XML_LIBS)
-AC_SUBST(XML_INCLUDE)
-AC_SUBST(XML_STATIC)
-AC_SUBST(XML_SHARED)
diff --git a/ext/xml/php3_xml.h b/ext/xml/php3_xml.h
deleted file mode 100644
index 23d89c0fd2..0000000000
--- a/ext/xml/php3_xml.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Stig Sæther Bakken <ssb@guardian.no> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _PHP_XML_H
-# define _PHP_XML_H
-
-# if HAVE_LIBEXPAT
-
-#include <xmltok.h>
-#include <xmlparse.h>
-
-#if WIN32||WINNT
-#define PHP_XML_API __declspec(dllexport)
-#else
-#define PHP_XML_API
-#endif
-
-
-#ifdef XML_UNICODE
-# error "UTF-16 Unicode support not implemented!"
-#endif
-
-typedef struct {
- XML_Char *default_encoding;
-} php_xml_globals;
-
-typedef struct {
- int index;
- int case_folding;
- XML_Parser parser;
- XML_Char *target_encoding;
- char *startElementHandler;
- char *endElementHandler;
- char *characterDataHandler;
- char *processingInstructionHandler;
- char *defaultHandler;
- char *unparsedEntityDeclHandler;
- char *notationDeclHandler;
- char *externalEntityRefHandler;
- char *unknownEncodingHandler;
-
- pval *data;
- pval *info;
- int level;
- int toffset;
- int curtag;
- pval **ctag;
- char **ltags;
- int lastwasopen;
- int skipwhite;
-
- XML_Char *baseURI;
-} xml_parser;
-
-
-typedef struct {
- XML_Char *name;
- char (*decoding_function)(unsigned short);
- unsigned short (*encoding_function)(unsigned char);
-} xml_encoding;
-
-
-extern php3_module_entry xml_module_entry;
-# define xml_module_ptr &xml_module_entry
-
-enum php3_xml_option {
- PHP3_XML_OPTION_CASE_FOLDING = 1,
- PHP3_XML_OPTION_TARGET_ENCODING,
- PHP3_XML_OPTION_SKIP_TAGSTART,
- PHP3_XML_OPTION_SKIP_WHITE
-};
-
-# define RETURN_OUT_OF_MEMORY \
- php_error(E_WARNING, "Out of memory");\
- RETURN_FALSE
-
-/* for xml_parse_into_struct */
-
-#define XML_MAXLEVEL 255 /* XXX this should be dynamic */
-
-PHP_FUNCTION(xml_parser_create);
-PHP_FUNCTION(xml_set_element_handler);
-PHP_FUNCTION(xml_set_character_data_handler);
-PHP_FUNCTION(xml_set_processing_instruction_handler);
-PHP_FUNCTION(xml_set_default_handler);
-PHP_FUNCTION(xml_set_unparsed_entity_decl_handler);
-PHP_FUNCTION(xml_set_notation_decl_handler);
-PHP_FUNCTION(xml_set_external_entity_ref_handler);
-PHP_FUNCTION(xml_parse);
-PHP_FUNCTION(xml_get_error_code);
-PHP_FUNCTION(xml_error_string);
-PHP_FUNCTION(xml_get_current_line_number);
-PHP_FUNCTION(xml_get_current_column_number);
-PHP_FUNCTION(xml_get_current_byte_index);
-PHP_FUNCTION(xml_parser_free);
-PHP_FUNCTION(xml_parser_set_option);
-PHP_FUNCTION(xml_parser_get_option);
-PHP_FUNCTION(utf8_encode);
-PHP_FUNCTION(utf8_decode);
-PHP_FUNCTION(xml_parse_into_struct);
-
-#else /* !HAVE_LIBEXPAT */
-
-# define xml_module_ptr NULL
-
-#endif /* HAVE_LIBEXPAT */
-
-#define phpext_xml_ptr xml_module_ptr
-
-#ifdef ZTS
-#define XMLLS_D php_xml_globals *xml_globals
-#define XMLLS_DC , PSLS_D
-#define XMLLS_C xml_globals
-#define XMLLS_CC , XMLLS_C
-#define XML(v) (xml_globals->v)
-#define XMLLS_FETCH() php_xml_globals *xml_globals = ts_resource(xml_globals_id)
-#else
-#define XMLLS_D
-#define XMLLS_DC
-#define XMLLS_C
-#define XMLLS_CC
-#define XML(v) (xml_globals.v)
-#define XMLLS_FETCH()
-#endif
-
-# endif /* _PHP_XML_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/xml/xml.c b/ext/xml/xml.c
deleted file mode 100644
index 8dcc4f9d96..0000000000
--- a/ext/xml/xml.c
+++ /dev/null
@@ -1,1485 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Stig Sæther Bakken <ssb@fast.no> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-#define IS_EXT_MODULE
-
-/* boldly assume that if PIC is defined, we are being compiled dynamically */
-#ifdef PIC
-# define COMPILE_DL 1
-#endif
-
-#if COMPILE_DL
-# include "dl/phpdl.h"
-#endif
-#include "php.h"
-#include "php3_xml.h"
-#include "zend_variables.h"
-#include "ext/standard/php3_string.h"
-
-
-#if HAVE_LIBEXPAT
-
-# if !(WIN32|WINNT)
-# include "build-defs.h"
-# endif
-# include "snprintf.h"
-# include "ext/standard/head.h"
-
-/* Short-term TODO list:
- * - Implement XML_ExternalEntityParserCreate()
- */
-
-/* Long-term TODO list:
- * - Fix the expat library so you can install your own memory manager
- * functions
- */
-
-/* Known bugs:
- * - Weird things happen with <![CDATA[]]> sections.
- */
-
-
-#ifdef ZTS
-int xml_globals_id;
-#else
-PHP_XML_API php_xml_globals xml_globals;
-#endif
-
-/* {{{ dynamically loadable module stuff */
-
-# if COMPILE_DL
-DLEXPORT zend_module_entry *get_module(void) { return &xml_module_entry; }
-# endif /* COMPILE_DL */
-
-/* }}} */
-/* {{{ function prototypes */
-
-/* {{{ php3i_long_pval() */
-
-PHPAPI pval *php3i_long_pval(long value)
-{
- pval *ret;
- MAKE_STD_ZVAL(ret);
-
- ret->type = IS_LONG;
- ret->value.lval = value;
- return ret;
-}
-
-/* }}} */
-/* {{{ php3i_double_pval() */
-
-PHPAPI pval *php3i_double_pval(double value)
-{
- pval *ret;
- MAKE_STD_ZVAL(ret);
-
- ret->type = IS_DOUBLE;
- ret->value.dval = value;
- return ret;
-}
-
-/* }}} */
-/* {{{ php3i_string_pval() */
-
-PHPAPI pval *php3i_string_pval(const char *str)
-{
- pval *ret;
- int len = strlen(str);
- MAKE_STD_ZVAL(ret);
-
- ret->type = IS_STRING;
- ret->value.str.len = len;
- ret->value.str.val = estrndup(str, len);
- return ret;
-}
-
-/* }}} */
-
-PHP_MINIT_FUNCTION(xml);
-PHP_RINIT_FUNCTION(xml);
-PHP_MSHUTDOWN_FUNCTION(xml);
-PHP_RSHUTDOWN_FUNCTION(xml);
-PHP_MINFO_FUNCTION(xml);
-
-static void xml_destroy_parser(xml_parser *);
-static void xml_set_handler(char **, pval *);
-inline static unsigned short xml_encode_iso_8859_1(unsigned char);
-inline static char xml_decode_iso_8859_1(unsigned short);
-inline static unsigned short xml_encode_us_ascii(unsigned char);
-inline static char xml_decode_us_ascii(unsigned short);
-static XML_Char *xml_utf8_encode(const char *, int, int *, const XML_Char *);
-static char *xml_utf8_decode(const XML_Char *, int, int *, const XML_Char *);
-static pval *xml_call_handler(xml_parser *, char *, int, pval **);
-static pval *php3i_xmlcharpval(const XML_Char *, int, const XML_Char *);
-static int php3i_xmlcharlen(const XML_Char *);
-static void php3i_add_to_info(xml_parser *parser,char *name);
-
-
-void php3i_xml_startElementHandler(void *, const char *, const char **);
-void php3i_xml_endElementHandler(void *, const char *);
-void php3i_xml_characterDataHandler(void *, const XML_Char *, int);
-void php3i_xml_processingInstructionHandler(void *, const XML_Char *, const XML_Char *);
-void php3i_xml_defaultHandler(void *, const XML_Char *, int);
-void php3i_xml_unparsedEntityDeclHandler(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
-void php3i_xml_notationDeclHandler(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
-int php3i_xml_externalEntityRefHandler(XML_Parser, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
-
-/* }}} */
-/* {{{ extension definition structures */
-
-function_entry xml_functions[] = {
- PHP_FE(xml_parser_create, NULL)
- PHP_FE(xml_set_element_handler, NULL)
- PHP_FE(xml_set_character_data_handler, NULL)
- PHP_FE(xml_set_processing_instruction_handler, NULL)
- PHP_FE(xml_set_default_handler, NULL)
- PHP_FE(xml_set_unparsed_entity_decl_handler, NULL)
- PHP_FE(xml_set_notation_decl_handler, NULL)
- PHP_FE(xml_set_external_entity_ref_handler, NULL)
- PHP_FE(xml_parse, NULL)
- PHP_FE(xml_parse_into_struct, NULL)
- PHP_FE(xml_get_error_code, NULL)
- PHP_FE(xml_error_string, NULL)
- PHP_FE(xml_get_current_line_number, NULL)
- PHP_FE(xml_get_current_column_number, NULL)
- PHP_FE(xml_get_current_byte_index, NULL)
- PHP_FE(xml_parser_free, NULL)
- PHP_FE(xml_parser_set_option, NULL)
- PHP_FE(xml_parser_get_option, NULL)
- PHP_FE(utf8_encode, NULL)
- PHP_FE(utf8_decode, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry xml_module_entry = {
- "XML", /* extension name */
- xml_functions, /* extension function list */
- PHP_MINIT(xml), /* extension-wide startup function */
- PHP_MSHUTDOWN(xml), /* extension-wide shutdown function */
- PHP_RINIT(xml), /* per-request startup function */
- PHP_RSHUTDOWN(xml), /* per-request shutdown function */
- PHP_MINFO(xml), /* information function */
- STANDARD_MODULE_PROPERTIES
-};
-
-/* All the encoding functions are set to NULL right now, since all
- * the encoding is currently done internally by expat/xmltok.
- */
-xml_encoding xml_encodings[] = {
- { "ISO-8859-1", xml_decode_iso_8859_1, xml_encode_iso_8859_1 },
- { "US-ASCII", xml_decode_us_ascii, xml_encode_us_ascii },
- { "UTF-8", NULL, NULL },
- { NULL, NULL, NULL }
-};
-
-/* True globals, no need for thread safety */
-static int le_xml_parser;
-
-/* }}} */
-/* {{{ startup, shutdown and info functions */
-
-/* {{{ php3_minit_xml */
-
-#ifdef ZTS
-static void php_xml_init_globals(php_xml_globals *xml_globals)
-{
- XML(default_encoding) = "ISO-8859-1";
-}
-#endif
-
-PHP_MINIT_FUNCTION(xml)
-{
-
- ELS_FETCH();
-
- le_xml_parser = register_list_destructors(xml_destroy_parser, NULL);
-
-#ifdef ZTS
- xml_globals_id = ts_allocate_id(sizeof(php_xml_globals), php_xml_init_globals, NULL);
-#else
- XML(default_encoding) = "ISO-8859-1";
-#endif
-
- REGISTER_LONG_CONSTANT("XML_ERROR_NONE", XML_ERROR_NONE, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_NO_MEMORY", XML_ERROR_NO_MEMORY, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_SYNTAX", XML_ERROR_SYNTAX, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_NO_ELEMENTS", XML_ERROR_NO_ELEMENTS, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_INVALID_TOKEN", XML_ERROR_INVALID_TOKEN, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_UNCLOSED_TOKEN", XML_ERROR_UNCLOSED_TOKEN, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_PARTIAL_CHAR", XML_ERROR_PARTIAL_CHAR, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_TAG_MISMATCH", XML_ERROR_TAG_MISMATCH, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_DUPLICATE_ATTRIBUTE", XML_ERROR_DUPLICATE_ATTRIBUTE, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_JUNK_AFTER_DOC_ELEMENT", XML_ERROR_JUNK_AFTER_DOC_ELEMENT, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_PARAM_ENTITY_REF", XML_ERROR_PARAM_ENTITY_REF, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_UNDEFINED_ENTITY", XML_ERROR_UNDEFINED_ENTITY, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_RECURSIVE_ENTITY_REF", XML_ERROR_RECURSIVE_ENTITY_REF, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_ASYNC_ENTITY", XML_ERROR_ASYNC_ENTITY, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_BAD_CHAR_REF", XML_ERROR_BAD_CHAR_REF, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_BINARY_ENTITY_REF", XML_ERROR_BINARY_ENTITY_REF, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF", XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_MISPLACED_XML_PI", XML_ERROR_MISPLACED_XML_PI, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_UNKNOWN_ENCODING", XML_ERROR_UNKNOWN_ENCODING, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_INCORRECT_ENCODING", XML_ERROR_INCORRECT_ENCODING, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_UNCLOSED_CDATA_SECTION", XML_ERROR_UNCLOSED_CDATA_SECTION, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_ERROR_EXTERNAL_ENTITY_HANDLING", XML_ERROR_EXTERNAL_ENTITY_HANDLING, CONST_CS|CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("XML_OPTION_CASE_FOLDING", PHP3_XML_OPTION_CASE_FOLDING, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_OPTION_TARGET_ENCODING", PHP3_XML_OPTION_TARGET_ENCODING, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_OPTION_SKIP_TAGSTART", PHP3_XML_OPTION_SKIP_TAGSTART, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("XML_OPTION_SKIP_WHITE", PHP3_XML_OPTION_SKIP_WHITE, CONST_CS|CONST_PERSISTENT);
-
-
- return SUCCESS;
-}
-
-/* }}} */
-/* {{{ php3_rinit_xml */
-
-PHP_RINIT_FUNCTION(xml)
-{
- return SUCCESS;
-}
-
-/* }}} */
-/* {{{ php3_mshutdown_xml() */
-
-PHP_MSHUTDOWN_FUNCTION(xml)
-{
- return SUCCESS;
-}
-
-/* }}} */
-/* {{{ php3_rshutdown_xml() */
-
-PHP_RSHUTDOWN_FUNCTION(xml)
-{
- return SUCCESS;
-}
-
-/* }}} */
-/* {{{ php3_info_xml() */
-
-PHP_MINFO_FUNCTION(xml)
-{
- PUTS("XML support active");
-}
-
-/* }}} */
-
-/* }}} */
-/* {{{ extension-internal functions */
-
-/* {{{ xml_destroy_parser() */
-
-static void
-xml_destroy_parser(xml_parser *parser)
-{
- if (parser->parser) {
- XML_ParserFree(parser->parser);
- }
- if (parser->ltags) {
- efree(parser->ltags);
- }
- if (parser->startElementHandler) {
- efree(parser->startElementHandler);
- }
- if (parser->endElementHandler) {
- efree(parser->endElementHandler);
- }
- if (parser->characterDataHandler) {
- efree(parser->characterDataHandler);
- }
- if (parser->processingInstructionHandler) {
- efree(parser->processingInstructionHandler);
- }
- if (parser->defaultHandler) {
- efree(parser->defaultHandler);
- }
- if (parser->unparsedEntityDeclHandler) {
- efree(parser->unparsedEntityDeclHandler);
- }
- if (parser->notationDeclHandler) {
- efree(parser->notationDeclHandler);
- }
- if (parser->externalEntityRefHandler) {
- efree(parser->externalEntityRefHandler);
- }
- if (parser->unknownEncodingHandler) {
- efree(parser->unknownEncodingHandler);
- }
- if (parser->baseURI) {
- efree(parser->baseURI);
- }
-
- efree(parser);
-}
-
-/* }}} */
- /* {{{ xml_set_handler() */
-
-static void
-xml_set_handler(char **nameBufp, pval *data)
-{
- if (data->value.str.len > 0) {
- if (*nameBufp != NULL) {
- efree(*nameBufp);
- }
- convert_to_string(data);
- *nameBufp = estrndup(data->value.str.val, data->value.str.len);
- } else {
- if (*nameBufp != NULL) {
- efree(*nameBufp);
- }
- *nameBufp = NULL;
- }
-}
-
-/* }}} */
- /* {{{ xml_call_handler() */
-
-static pval *
-xml_call_handler(xml_parser *parser, char *funcName, int argc, pval **argv)
-{
- ELS_FETCH();
-
- if (parser && funcName) {
- pval *retval, *func;
- int i;
-
- func = php3i_string_pval(funcName);
- retval = emalloc(sizeof(pval));
- /* We cannot call internal variables from a function module as
- it breaks any chance of compiling it as a module on windows.
- Instead, we create a callback function. */
- if (call_user_function(EG(function_table), NULL, func, retval, argc, argv) == FAILURE) {
- zval_dtor(retval);
- efree(retval);
- return NULL;
- }
- zval_dtor(func);
- efree(func);
- for (i = 0; i < argc; i++) {
- zval_dtor(argv[i]);
- efree(argv[i]);
- }
- return retval;
- }
- return NULL;
-}
-
-/* }}} */
- /* {{{ xml_encode_iso_8859_1() */
-
-inline static unsigned short
-xml_encode_iso_8859_1(unsigned char c)
-{
- return (unsigned short)c;
-}
-
-/* }}} */
- /* {{{ xml_decode_iso_8859_1() */
-
-inline static char
-xml_decode_iso_8859_1(unsigned short c)
-{
- return (char)(c > 0xff ? '?' : c);
-}
-
-/* }}} */
- /* {{{ xml_encode_us_ascii() */
-
-inline static unsigned short
-xml_encode_us_ascii(unsigned char c)
-{
- return (unsigned short)c;
-}
-
-/* }}} */
- /* {{{ xml_decode_us_ascii() */
-
-inline static char
-xml_decode_us_ascii(unsigned short c)
-{
- return (char)(c > 0x7f ? '?' : c);
-}
-
-/* }}} */
- /* {{{ xml_get_encoding() */
-
-static xml_encoding *
-xml_get_encoding(const XML_Char *name)
-{
- xml_encoding *enc = &xml_encodings[0];
-
- while (enc && enc->name) {
- if (strcasecmp(name, enc->name) == 0) {
- return enc;
- }
- enc++;
- }
- return NULL;
-}
-
-/* }}} */
- /* {{{ xml_utf8_encode */
-static XML_Char *
-xml_utf8_encode(const char *s, int len, int *newlen, const XML_Char *encoding)
-{
- int pos = len;
- char *newbuf;
- unsigned short c;
- unsigned short (*encoder)(unsigned char) = NULL;
- xml_encoding *enc = xml_get_encoding(encoding);
-
- *newlen = 0;
- if (enc) {
- encoder = enc->encoding_function;
- } else {
- /* If the target encoding was unknown, fail */
- return NULL;
- }
- if (encoder == NULL) {
- /* If no encoder function was specified, return the data as-is.
- */
- newbuf = emalloc(len);
- memcpy(newbuf, s, len);
- *newlen = len;
- return newbuf;
- }
- /* This is the theoretical max (will never get beyond len * 2 as long
- * as we are converting from single-byte characters, though) */
- newbuf = emalloc(len * 4);
- while (pos > 0) {
- c = encoder ? encoder((unsigned char)(*s)) : (unsigned short)(*s);
- if (c < 0x80) {
- newbuf[(*newlen)++] = c;
- } else if (c < 0x800) {
- newbuf[(*newlen)++] = (0xc0 | (c >> 6));
- newbuf[(*newlen)++] = (0x80 | (c & 0x3f));
- } else if (c < 0x10000) {
- newbuf[(*newlen)++] = (0xe0 | (c >> 12));
- newbuf[(*newlen)++] = (0xc0 | ((c >> 6) & 0x3f));
- newbuf[(*newlen)++] = (0x80 | (c & 0x3f));
- } else if (c < 0x200000) {
- newbuf[(*newlen)++] = (0xf0 | (c >> 18));
- newbuf[(*newlen)++] = (0xe0 | ((c >> 12) & 0x3f));
- newbuf[(*newlen)++] = (0xc0 | ((c >> 6) & 0x3f));
- newbuf[(*newlen)++] = (0x80 | (c & 0x3f));
- }
- pos--;
- s++;
- }
- if (*newlen < len * 4) {
- newbuf = erealloc(newbuf, *newlen);
- }
- return newbuf;
-}
-/* }}} */
- /* {{{ xml_utf8_decode */
-static char *
-xml_utf8_decode(const XML_Char *s, int len, int *newlen, const XML_Char *encoding)
-{
- int pos = len;
- char *newbuf = emalloc(len + 1);
- unsigned short c;
- char (*decoder)(unsigned short) = NULL;
- xml_encoding *enc = xml_get_encoding(encoding);
-
- *newlen = 0;
- if (enc) {
- decoder = enc->decoding_function;
- }
- if (decoder == NULL) {
- /* If the target encoding was unknown, or no decoder function
- * was specified, return the UTF-8-encoded data as-is.
- */
- memcpy(newbuf, s, len);
- *newlen = len;
- newbuf[*newlen] = '\0';
- return newbuf;
- }
- while (pos > 0) {
- c = (unsigned char)(*s);
- if (c >= 0xf0) { /* four bytes encoded, 21 bits */
- c = ((s[0]&7)<<18) | ((s[1]&63)<<12) | ((s[2]&63)<<6) | (s[3]&63);
- s += 4;
- pos -= 4;
- } else if (c >= 0xe0) { /* three bytes encoded, 16 bits */
- c = ((s[0]&63)<<12) | ((s[1]&63)<<6) | (s[2]&63);
- s += 3;
- pos -= 3;
- } else if (c >= 0xc0) { /* two bytes encoded, 11 bits */
- c = ((s[0]&63)<<6) | (s[1]&63);
- s += 2;
- pos -= 2;
- } else {
- s++;
- pos--;
- }
- newbuf[*newlen] = decoder ? decoder(c) : c;
- ++*newlen;
- }
- if (*newlen < len) {
- newbuf = erealloc(newbuf, *newlen + 1);
- }
- newbuf[*newlen] = '\0';
- return newbuf;
-}
-/* }}} */
- /* {{{ php3i_xmlcharpval() */
-
-static pval *php3i_xmlcharpval(const XML_Char *s, int len, const XML_Char *encoding)
-{
- pval *ret = emalloc(sizeof(pval));
-
- if (s == NULL) {
- var_reset(ret);
- return ret;
- }
- if (len == 0) {
- len = php3i_xmlcharlen(s);
- }
- ret->type = IS_STRING;
- ret->value.str.val = xml_utf8_decode(s, len, &ret->value.str.len, encoding);
- return ret;
-}
-
-/* }}} */
- /* {{{ php3i_xmlcharlen() */
-
-static int php3i_xmlcharlen(const XML_Char *s)
-{
- int len = 0;
-
- while (*s) {
- len++;
- s++;
- }
- return len;
-}
-
-/* }}} */
- /* {{{ php3i_pval_strdup() */
-
-PHPAPI char *php3i_pval_strdup(pval *val)
-{
- if (val->type == IS_STRING) {
- char *buf = emalloc(val->value.str.len + 1);
- memcpy(buf, val->value.str.val, val->value.str.len);
- buf[val->value.str.len] = '\0';
- return buf;
- }
- return NULL;
-}
-
-/* }}} */
- /* {{{ php3i_add_to_info */
-static void php3i_add_to_info(xml_parser *parser,char *name)
-{
- pval **element, *values;
-
- if (! parser->info) {
- return;
- }
-
- if (zend_hash_find(parser->info->value.ht,name,strlen(name) + 1,(void **) &element) == FAILURE) {
- values = emalloc(sizeof(pval));
- if (array_init(values) == FAILURE) {
- php_error(E_ERROR, "Unable to initialize array");
- return;
- }
-
- INIT_PZVAL(values);
-
- zend_hash_update(parser->info->value.ht, name, strlen(name)+1, (void *) &values, sizeof(pval*), (void **) &element);
- }
-
- add_next_index_long(*element,parser->curtag);
-
- parser->curtag++;
-}
-
-/* }}} */
- /* {{{ php3i_xml_startElementHandler() */
-
-void php3i_xml_startElementHandler(void *userData, const char *name,
- const char **attributes)
-{
- xml_parser *parser = (xml_parser *)userData;
- const char **attrs = attributes;
-
- if (parser) {
- pval *retval, *args[3];
-
- parser->level++;
-
- if (parser->case_folding) {
- name = _php3_strtoupper(estrdup(name));
- }
-
- if (parser->startElementHandler) {
- args[0] = php3i_long_pval(parser->index);
- args[1] = php3i_string_pval(name);
- MAKE_STD_ZVAL(args[2]);
- array_init(args[2]);
- while (attributes && *attributes) {
- char *key = (char *)attributes[0];
- char *value = (char *)attributes[1];
- char *decoded_value;
- int decoded_len;
- if (parser->case_folding) {
- key = _php3_strtoupper(estrdup(key));
- }
- decoded_value = xml_utf8_decode(value, strlen(value),
- &decoded_len,
- parser->target_encoding);
-
- add_assoc_stringl(args[2], key, decoded_value, decoded_len, 0);
- if (parser->case_folding) {
- efree(key);
- }
- attributes += 2;
- }
-
- if ((retval = xml_call_handler(parser, parser->startElementHandler, 3, args))) {
- zval_dtor(retval);
- efree(retval);
- }
- }
-
- if (parser->data) {
- pval *tag, *atr;
- int atcnt = 0;
-
- tag = emalloc(sizeof(pval));
- INIT_PZVAL(tag);
-
- atr = emalloc(sizeof(pval));
- INIT_PZVAL(atr);
-
- array_init(tag);
- array_init(atr);
-
- php3i_add_to_info(parser,((char *) name) + parser->toffset);
-
- add_assoc_string(tag,"tag",((char *) name) + parser->toffset,1); /* cast to avoid gcc-warning */
- add_assoc_string(tag,"type","open",1);
- add_assoc_long(tag,"level",parser->level);
-
- parser->ltags[parser->level-1] = estrdup(name);
- parser->lastwasopen = 1;
-
- attributes = attrs;
- while (attributes && *attributes) {
- char *key = (char *)attributes[0];
- char *value = (char *)attributes[1];
- char *decoded_value;
- int decoded_len;
- if (parser->case_folding) {
- key = _php3_strtoupper(estrdup(key));
- }
- decoded_value = xml_utf8_decode(value, strlen(value),
- &decoded_len,
- parser->target_encoding);
-
- add_assoc_stringl(atr,key,decoded_value,decoded_len,0);
- atcnt++;
- if (parser->case_folding) {
- efree(key);
- }
- attributes += 2;
- }
-
- if (atcnt) {
- zend_hash_add(tag->value.ht,"attributes",sizeof("attributes"),&atr,sizeof(pval*),NULL);
- } else {
- zval_dtor(atr);
- efree(atr);
- }
-
- zend_hash_next_index_insert(parser->data->value.ht,&tag,sizeof(pval*),(void *) &parser->ctag);
- }
-
- if (parser->case_folding) {
- efree((char *)name);
- }
- }
-}
-
-/* }}} */
- /* {{{ php3i_xml_endElementHandler() */
-
-void php3i_xml_endElementHandler(void *userData, const char *name)
-{
- xml_parser *parser = (xml_parser *)userData;
-
- if (parser) {
- pval *retval, *args[2];
-
- if (parser->case_folding) {
- name = _php3_strtoupper(estrdup(name));
- }
-
- if (parser->endElementHandler) {
- args[0] = php3i_long_pval(parser->index);
- args[1] = php3i_string_pval(name);
-
- if ((retval = xml_call_handler(parser, parser->endElementHandler, 2, args))) {
- zval_dtor(retval);
- efree(retval);
- }
- }
-
- if (parser->data) {
- pval *tag;
-
- if (parser->lastwasopen) {
- add_assoc_string(*(parser->ctag),"type","complete",1);
- } else {
- tag = emalloc(sizeof(pval));
-
- array_init(tag);
- INIT_PZVAL(tag);
-
- php3i_add_to_info(parser,((char *) name) + parser->toffset);
-
- add_assoc_string(tag,"tag",((char *) name) + parser->toffset,1); /* cast to avoid gcc-warning */
- add_assoc_string(tag,"type","close",1);
- add_assoc_long(tag,"level",parser->level);
-
- zend_hash_next_index_insert(parser->data->value.ht,&tag,sizeof(pval*),NULL);
- }
-
- parser->lastwasopen = 0;
- }
-
- if (parser->case_folding) {
- efree((char *)name);
- }
- if (parser->ltags) {
- efree(parser->ltags[parser->level-1]);
- }
- parser->level--;
- }
-}
-
-/* }}} */
- /* {{{ php3i_xml_characterDataHandler() */
-
-void php3i_xml_characterDataHandler(void *userData, const XML_Char *s, int len)
-{
- xml_parser *parser = (xml_parser *)userData;
-
- if (parser) {
- pval *retval, *args[2];
-
- if (parser->characterDataHandler) {
- args[0] = php3i_long_pval(parser->index);
- args[1] = php3i_xmlcharpval(s, len, parser->target_encoding);
- if ((retval = xml_call_handler(parser, parser->characterDataHandler, 2, args))) {
- zval_dtor(retval);
- efree(retval);
- }
- }
-
- if (parser->data) {
- int i;
- int doprint = 0;
-
- char *decoded_value;
- int decoded_len;
-
- decoded_value = xml_utf8_decode(s,len,&decoded_len,parser->target_encoding);
- for (i = 0; i < decoded_len; i++) {
- switch (decoded_value[i]) {
- case ' ':
- case '\t':
- case '\n':
- continue;
- default:
- doprint = 1;
- break;
- }
- if (doprint) {
- break;
- }
- }
- if (doprint || (! parser->skipwhite)) {
- if (parser->lastwasopen) {
- add_assoc_string(*(parser->ctag),"value",decoded_value,0);
- } else {
- pval *tag;
-
- tag = emalloc(sizeof(pval));
-
- array_init(tag);
-
- php3i_add_to_info(parser,parser->ltags[parser->level-1] + parser->toffset);
-
- add_assoc_string(tag,"tag",parser->ltags[parser->level-1] + parser->toffset,1);
- add_assoc_string(tag,"value",decoded_value,0);
- add_assoc_string(tag,"type","cdata",1);
- add_assoc_long(tag,"level",parser->level);
-
- zend_hash_next_index_insert(parser->data->value.ht,&tag,sizeof(pval*),NULL);
- }
- } else {
- efree(decoded_value);
- }
- }
- }
-}
-
-/* }}} */
- /* {{{ php3i_xml_processingInstructionHandler() */
-
-void php3i_xml_processingInstructionHandler(void *userData,
- const XML_Char *target,
- const XML_Char *data)
-{
- xml_parser *parser = (xml_parser *)userData;
-
- if (parser && parser->processingInstructionHandler) {
- pval *retval, *args[3];
-
- args[0] = php3i_long_pval(parser->index);
- args[1] = php3i_xmlcharpval(target, 0, parser->target_encoding);
- args[2] = php3i_xmlcharpval(data, 0, parser->target_encoding);
- if ((retval = xml_call_handler(parser, parser->processingInstructionHandler, 3, args))) {
- zval_dtor(retval);
- efree(retval);
- }
- }
-}
-
-/* }}} */
- /* {{{ php3i_xml_defaultHandler() */
-
-void php3i_xml_defaultHandler(void *userData, const XML_Char *s, int len)
-{
- xml_parser *parser = (xml_parser *)userData;
-
- if (parser && parser->defaultHandler) {
- pval *retval, *args[2];
-
- args[0] = php3i_long_pval(parser->index);
- args[1] = php3i_xmlcharpval(s, len, parser->target_encoding);
- if ((retval = xml_call_handler(parser, parser->defaultHandler, 2, args))) {
- zval_dtor(retval);
- efree(retval);
- }
- }
-}
-
-/* }}} */
- /* {{{ php3i_xml_unparsedEntityDeclHandler() */
-
-void php3i_xml_unparsedEntityDeclHandler(void *userData,
- const XML_Char *entityName,
- const XML_Char *base,
- const XML_Char *systemId,
- const XML_Char *publicId,
- const XML_Char *notationName)
-{
- xml_parser *parser = (xml_parser *)userData;
-
- if (parser && parser->unparsedEntityDeclHandler) {
- pval *retval, *args[5];
-
- args[0] = php3i_long_pval(parser->index);
- args[1] = php3i_xmlcharpval(entityName, 0, parser->target_encoding);
- args[2] = php3i_xmlcharpval(base, 0, parser->target_encoding);
- args[3] = php3i_xmlcharpval(systemId, 0, parser->target_encoding);
- args[4] = php3i_xmlcharpval(publicId, 0, parser->target_encoding);
- args[5] = php3i_xmlcharpval(notationName, 0, parser->target_encoding);
- if ((retval = xml_call_handler(parser, parser->unparsedEntityDeclHandler, 6, args))) {
- zval_dtor(retval);
- efree(retval);
- }
- }
-}
-
-/* }}} */
- /* {{{ php3i_xml_notationDeclHandler() */
-
-void
-php3i_xml_notationDeclHandler(void *userData,
- const XML_Char *notationName,
- const XML_Char *base,
- const XML_Char *systemId,
- const XML_Char *publicId)
-{
- xml_parser *parser = (xml_parser *)userData;
-
- if (parser && parser->notationDeclHandler) {
- pval *retval, *args[5];
-
- args[0] = php3i_long_pval(parser->index);
- args[1] = php3i_xmlcharpval(notationName, 0, parser->target_encoding);
- args[2] = php3i_xmlcharpval(base, 0, parser->target_encoding);
- args[3] = php3i_xmlcharpval(systemId, 0, parser->target_encoding);
- args[4] = php3i_xmlcharpval(publicId, 0, parser->target_encoding);
- if ((retval = xml_call_handler(parser, parser->notationDeclHandler, 5, args))) {
- zval_dtor(retval);
- efree(retval);
- }
- }
-}
-
-/* }}} */
- /* {{{ php3i_xml_externalEntityRefHandler() */
-
-int
-php3i_xml_externalEntityRefHandler(XML_Parser parserPtr,
- const XML_Char *openEntityNames,
- const XML_Char *base,
- const XML_Char *systemId,
- const XML_Char *publicId)
-{
- xml_parser *parser = XML_GetUserData(parserPtr);
- int ret = 0; /* abort if no handler is set (should be configurable?) */
-
- if (parser && parser->externalEntityRefHandler) {
- pval *retval, *args[5];
-
- args[0] = php3i_long_pval(parser->index);
- args[1] = php3i_xmlcharpval(openEntityNames, 0, parser->target_encoding);
- args[2] = php3i_xmlcharpval(base, 0, parser->target_encoding);
- args[3] = php3i_xmlcharpval(systemId, 0, parser->target_encoding);
- args[4] = php3i_xmlcharpval(publicId, 0, parser->target_encoding);
- if ((retval = xml_call_handler(parser, parser->externalEntityRefHandler, 5, args))) {
- convert_to_long(retval);
- ret = retval->value.lval;
- efree(retval);
- } else {
- ret = 0;
- }
- }
- return ret;
-}
-
-/* }}} */
-
-/* }}} */
-
-/************************* EXTENSION FUNCTIONS *************************/
-
-/* {{{ proto int xml_parser_create()
- Create an XML parser */
-PHP_FUNCTION(xml_parser_create)
-{
- xml_parser *parser;
- int id, argc;
- pval *encodingArg = NULL;
- XML_Char *encoding;
- char thisfunc[] = "xml_parser_create";
- XMLLS_FETCH();
-
- argc = ARG_COUNT(ht);
-
- if (argc > 1 || getParameters(ht, argc, &encodingArg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (argc == 1) {
- convert_to_string(encodingArg);
- /* The supported encoding types are hardcoded here because
- * we are limited to the encodings supported by expat/xmltok.
- */
- if (strncasecmp(encodingArg->value.str.val, "ISO-8859-1",
- encodingArg->value.str.len) == 0) {
- encoding = "ISO-8859-1";
- } else if (strncasecmp(encodingArg->value.str.val, "UTF-8",
- encodingArg->value.str.len) == 0) {
- encoding = "UTF-8";
- } else if (strncasecmp(encodingArg->value.str.val, "US-ASCII",
- encodingArg->value.str.len) == 0) {
- encoding = "US-ASCII";
- } else { /* UTF-16 not supported */
- php_error(E_WARNING, "%s: unsupported source encoding \"%s\"",
- thisfunc, encodingArg->value.str.val);
- RETURN_FALSE;
- }
- } else {
- encoding = XML(default_encoding);
- }
-
- parser = ecalloc(sizeof(xml_parser), 1);
- parser->parser = XML_ParserCreate(encoding);
- parser->target_encoding = encoding;
- parser->index = id;
- parser->case_folding = 1;
- XML_SetUserData(parser->parser, parser);
-
- ZEND_REGISTER_RESOURCE(return_value,parser,le_xml_parser);
- parser->index = return_value->value.lval;
-}
-/* }}} */
-
-/* {{{ proto int xml_set_element_handler(int pind, string shdl, string ehdl)
- Set up start and end element handlers */
-PHP_FUNCTION(xml_set_element_handler)
-{
- xml_parser *parser;
- pval *pind, *shdl, *ehdl;
-
- if (ARG_COUNT(ht) != 3 ||
- getParameters(ht, 3, &pind, &shdl, &ehdl) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- convert_to_string(shdl);
- convert_to_string(ehdl);
-
- xml_set_handler(&parser->startElementHandler, shdl);
- xml_set_handler(&parser->endElementHandler, ehdl);
- XML_SetElementHandler(parser->parser, php3i_xml_startElementHandler, php3i_xml_endElementHandler);
- RETVAL_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int xml_set_character_data_handler(int pind, string hdl)
- Set up character data handler */
-PHP_FUNCTION(xml_set_character_data_handler)
-{
- xml_parser *parser;
- pval *pind, *hdl;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &pind, &hdl) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- convert_to_string(hdl);
-
- xml_set_handler(&parser->characterDataHandler, hdl);
- XML_SetCharacterDataHandler(parser->parser, php3i_xml_characterDataHandler);
- RETVAL_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int xml_set_processing_instruction_handler(int pind, string hdl)
- Set up processing instruction (PI) handler */
-PHP_FUNCTION(xml_set_processing_instruction_handler)
-{
- xml_parser *parser;
- pval *pind, *hdl;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &pind, &hdl) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- convert_to_string(hdl);
-
- xml_set_handler(&parser->processingInstructionHandler, hdl);
- XML_SetProcessingInstructionHandler(parser->parser, php3i_xml_processingInstructionHandler);
- RETVAL_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int xml_set_default_handler(int pind, string hdl)
- Set up default handler */
-PHP_FUNCTION(xml_set_default_handler)
-{
- xml_parser *parser;
- pval *pind, *hdl;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &pind, &hdl) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- convert_to_string(hdl);
-
- xml_set_handler(&parser->defaultHandler, hdl);
- XML_SetDefaultHandler(parser->parser, php3i_xml_defaultHandler);
- RETVAL_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int xml_set_unparsed_entity_decl_handler(int pind, string hdl)
- Set up unparsed entity declaration handler */
-PHP_FUNCTION(xml_set_unparsed_entity_decl_handler)
-{
- xml_parser *parser;
- pval *pind, *hdl;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &pind, &hdl) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- convert_to_string(hdl);
-
- xml_set_handler(&parser->unparsedEntityDeclHandler, hdl);
- XML_SetUnparsedEntityDeclHandler(parser->parser, php3i_xml_unparsedEntityDeclHandler);
- RETVAL_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int xml_set_notation_decl_handler(int pind, string hdl)
- Set up notation declaration handler */
-PHP_FUNCTION(xml_set_notation_decl_handler)
-{
- xml_parser *parser;
- pval *pind, *hdl;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &pind, &hdl) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- convert_to_string(hdl);
-
- xml_set_handler(&parser->notationDeclHandler, hdl);
- XML_SetNotationDeclHandler(parser->parser, php3i_xml_notationDeclHandler);
- RETVAL_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int xml_set_external_entity_ref_handler(int pind, string hdl)
- Set up external entity reference handler */
-PHP_FUNCTION(xml_set_external_entity_ref_handler)
-{
- xml_parser *parser;
- pval *pind, *hdl;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &pind, &hdl) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- convert_to_string(hdl);
-
- xml_set_handler(&parser->externalEntityRefHandler, hdl);
- XML_SetExternalEntityRefHandler(parser->parser, php3i_xml_externalEntityRefHandler);
- RETVAL_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int xml_parse(int pind, string data[, int isFinal])
- Start parsing an XML document */
-PHP_FUNCTION(xml_parse)
-{
- xml_parser *parser;
- pval *pind, *data, *final;
- int argc, isFinal, ret;
-
- argc = ARG_COUNT(ht);
- if (argc < 2 || argc > 3 || getParameters(ht, argc, &pind, &data, &final) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- convert_to_string(data);
-
- if (argc == 3) {
- convert_to_long(final);
- isFinal = final->value.lval;
- } else {
- isFinal = 0;
- }
-
- ret = XML_Parse(parser->parser, data->value.str.val, data->value.str.len, isFinal);
- RETVAL_LONG(ret);
-}
-
-/* }}} */
-/* {{{ proto int xml_parse_into_struct(int pind, string data,array &struct,array &index)
- Parsing a XML document */
-
-PHP_FUNCTION(xml_parse_into_struct)
-{
- xml_parser *parser;
- pval *pind, *data, *xdata,*info = 0;
- int argc, ret;
-
- argc = ARG_COUNT(ht);
- if (getParameters(ht, 4, &pind, &data, &xdata,&info) == SUCCESS) {
- if (!ParameterPassedByReference(ht, 4)) {
- php_error(E_WARNING, "Array to be filled with values must be passed by reference.");
- RETURN_FALSE;
- }
- array_init(info);
- } else if (getParameters(ht, 3, &pind, &data, &xdata) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (!ParameterPassedByReference(ht, 3)) {
- php_error(E_WARNING, "Array to be filled with values must be passed by reference.");
- RETURN_FALSE;
- }
-
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- convert_to_string(data);
- array_init(xdata);
-
- parser->data = xdata;
- parser->info = info;
- parser->level = 0;
- parser->ltags = emalloc(XML_MAXLEVEL * sizeof(char *));
-
- XML_SetDefaultHandler(parser->parser, php3i_xml_defaultHandler);
- XML_SetElementHandler(parser->parser, php3i_xml_startElementHandler, php3i_xml_endElementHandler);
- XML_SetCharacterDataHandler(parser->parser, php3i_xml_characterDataHandler);
-
- ret = XML_Parse(parser->parser, data->value.str.val, data->value.str.len, 1);
-
- RETVAL_LONG(ret);
-}
-/* }}} */
-
-/* {{{ proto int xml_get_error_code(int pind)
- Get XML parser error code */
-PHP_FUNCTION(xml_get_error_code)
-{
- xml_parser *parser;
- pval *pind;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &pind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- RETVAL_LONG((long)XML_GetErrorCode(parser->parser));
-}
-/* }}} */
-
-/* {{{ proto string xml_error_string(int code)
- Get XML parser error string */
-PHP_FUNCTION(xml_error_string)
-{
- pval *code;
- char *str;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &code) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(code);
- str = (char *)XML_ErrorString((int)code->value.lval);
- if (str) {
- RETVAL_STRING(str, 1);
- }
-}
-/* }}} */
-
-/* {{{ proto int xml_get_current_line_number(int pind)
- Get current line number for an XML parser */
-PHP_FUNCTION(xml_get_current_line_number)
-{
- xml_parser *parser;
- pval *pind;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &pind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- RETVAL_LONG(XML_GetCurrentLineNumber(parser->parser));
-}
-/* }}} */
-
-/* {{{ proto int xml_get_current_column_number(int pind)
- Get current column number for an XML parser
-*/
-PHP_FUNCTION(xml_get_current_column_number)
-{
- xml_parser *parser;
- pval *pind;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &pind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- RETVAL_LONG(XML_GetCurrentColumnNumber(parser->parser));
-}
-/* }}} */
-
-/* {{{ proto int xml_get_current_byte_index(int pind)
- Get current byte index for an XML parser */
-PHP_FUNCTION(xml_get_current_byte_index)
-{
- xml_parser *parser;
- pval *pind;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &pind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- RETVAL_LONG(XML_GetCurrentByteIndex(parser->parser));
-}
-/* }}} */
-
-/* {{{ proto int xml_parser_free(int pind)
- Free an XML parser */
-PHP_FUNCTION(xml_parser_free)
-{
- pval *pind;
- xml_parser *parser;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &pind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- if (php3_list_delete(parser->index) == FAILURE) {
- RETURN_FALSE;
- }
-
- RETVAL_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int xml_parser_set_option(int pind, int option, mixed value)
- Set options in an XML parser */
-PHP_FUNCTION(xml_parser_set_option)
-{
- xml_parser *parser;
- pval *pind, *opt, *val;
- char thisfunc[] = "xml_parser_set_option";
-
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &pind, &opt, &val) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- convert_to_long(opt);
-
- switch (opt->value.lval) {
- case PHP3_XML_OPTION_CASE_FOLDING:
- convert_to_long(val);
- parser->case_folding = val->value.lval;
- break;
- case PHP3_XML_OPTION_SKIP_TAGSTART:
- convert_to_long(val);
- parser->toffset = val->value.lval;
- break;
- case PHP3_XML_OPTION_SKIP_WHITE:
- convert_to_long(val);
- parser->skipwhite = val->value.lval;
- break;
- case PHP3_XML_OPTION_TARGET_ENCODING: {
- xml_encoding *enc = xml_get_encoding(val->value.str.val);
- if (enc == NULL) {
- php_error(E_WARNING, "%s: unsupported target encoding \"%s\"",
- thisfunc, val->value.str.val);
- RETURN_FALSE;
- }
- parser->target_encoding = enc->name;
- break;
- }
- default:
- php_error(E_WARNING, "%s: unknown option", thisfunc);
- RETURN_FALSE;
- break;
- }
- RETVAL_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int xml_parser_get_option(int pind, int option)
- Get options from an XML parser */
-PHP_FUNCTION(xml_parser_get_option)
-{
- xml_parser *parser;
- pval *pind, *opt;
- char thisfunc[] = "xml_parser_get_option";
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &pind, &opt) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- convert_to_long(opt);
-
- switch (opt->value.lval) {
- case PHP3_XML_OPTION_CASE_FOLDING:
- RETURN_LONG(parser->case_folding);
- break;
- case PHP3_XML_OPTION_TARGET_ENCODING:
- RETURN_STRING(parser->target_encoding, 1);
- break;
- default:
- php_error(E_WARNING, "%s: unknown option", thisfunc);
- RETURN_FALSE;
- break;
- }
- RETVAL_FALSE;
-}
-/* }}} */
-
-/* {{{ proto string utf8_encode(string data)
- Encodes an ISO-8859-1 string to UTF-8 */
-PHP_FUNCTION(utf8_encode)
-{
- pval *arg;
- XML_Char *encoded;
- int len;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
- encoded = xml_utf8_encode(arg->value.str.val, arg->value.str.len, &len, "ISO-8859-1");
- if (encoded == NULL) {
- RETURN_FALSE;
- }
- RETVAL_STRINGL(encoded, len, 0);
-}
-/* }}} */
-
-/* {{{ proto string utf8_decode(string data)
- Converts a UTF-8 encoded string to ISO-8859-1 */
-PHP_FUNCTION(utf8_decode)
-{
- pval *arg;
- XML_Char *decoded;
- int len;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg);
- decoded = xml_utf8_decode(arg->value.str.val, arg->value.str.len, &len, "ISO-8859-1");
- if (decoded == NULL) {
- RETURN_FALSE;
- }
- RETVAL_STRINGL(decoded, len, 0);
-}
-/* }}} */
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/yp/Makefile.am b/ext/yp/Makefile.am
deleted file mode 100644
index c3701cf6ba..0000000000
--- a/ext/yp/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_yp.a
-libphpext_yp_a_SOURCES=yp.c
-
diff --git a/ext/yp/config.h.stub b/ext/yp/config.h.stub
deleted file mode 100644
index 768e64e5a9..0000000000
--- a/ext/yp/config.h.stub
+++ /dev/null
@@ -1,5 +0,0 @@
-/* define if you want to use the yp extension */
-/* #undef HAVE_LIBYP */
-
-#undef HAVE_YP
-#undef SOLARIS_YP
diff --git a/ext/yp/config.m4 b/ext/yp/config.m4
deleted file mode 100644
index 981be1b589..0000000000
--- a/ext/yp/config.m4
+++ /dev/null
@@ -1,29 +0,0 @@
-dnl $Id$
-dnl config.m4 for extension yp
-dnl don't forget to call PHP_EXTENSION(yp)
-
-AC_MSG_CHECKING(whether to include YP support)
-AC_ARG_WITH(yp,
-[ --with-yp Include YP support],
-[
- if test "$withval" = "yes"; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_YP)
- PHP_EXTENSION(yp)
- if test `uname` = "SunOS";then
- release=`uname -r`
- case "$release" in
- 5*)
- AC_DEFINE(SOLARIS_YP)
- ;;
- *)
- ;;
- esac
- fi
- else
- AC_MSG_RESULT(no)
- fi
-],[
- AC_MSG_RESULT(no)
-])
-
diff --git a/ext/yp/php3_yp.h b/ext/yp/php3_yp.h
deleted file mode 100644
index 1059314293..0000000000
--- a/ext/yp/php3_yp.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Stephanie Wehner <_@r4k.net> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#ifndef _PHP3_YP_H
-#define _PHP3_YP_H
-
-#if COMPILE_DL
-#undef HAVE_YP
-#define HAVE_YP 1
-#endif
-
-#if HAVE_YP
-
-extern php3_module_entry yp_module_entry;
-#define yp_module_ptr &yp_module_entry
-
-/* yp.c functions */
-int php3_minit_yp(INIT_FUNC_ARGS);
-PHP_FUNCTION(yp_get_default_domain);
-PHP_FUNCTION(yp_order);
-PHP_FUNCTION(yp_master);
-PHP_FUNCTION(yp_match);
-PHP_FUNCTION(yp_first);
-PHP_FUNCTION(yp_next);
-void php3_info_yp(ZEND_MODULE_INFO_FUNC_ARGS);
-
-#else
-
-#define yp_module_ptr NULL
-
-#endif /* HAVE_YP */
-
-#define phpext_yp_ptr yp_module_ptr
-
-#endif /* _PHP3_YP_H */
diff --git a/ext/yp/setup.stub b/ext/yp/setup.stub
deleted file mode 100644
index f91adef610..0000000000
--- a/ext/yp/setup.stub
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-yp 'yp support?' yesnodir no \
-' Whether to build the yp extension.'
-
diff --git a/ext/yp/yp.c b/ext/yp/yp.c
deleted file mode 100644
index c48fa971dd..0000000000
--- a/ext/yp/yp.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Stephanie Wehner <_@r4k.net> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include "php.h"
-
-#if HAVE_YP
-
-#include "php3_yp.h"
-
-#include <rpcsvc/ypclnt.h>
-
-function_entry yp_functions[] = {
- PHP_FE(yp_get_default_domain, NULL)
- PHP_FE(yp_order, NULL)
- PHP_FE(yp_master, NULL)
- PHP_FE(yp_match, NULL)
- PHP_FE(yp_first, NULL)
- PHP_FE(yp_next, NULL)
- {NULL, NULL, NULL}
-};
-
-zend_module_entry yp_module_entry = {
- "YP",
- yp_functions,
- NULL,
- NULL,
- NULL,
- NULL,
- php3_info_yp,
- STANDARD_MODULE_PROPERTIES
-};
-
-/* {{{ proto string yp_get_default_domain(void)
- Returns the domain or false */
-PHP_FUNCTION(yp_get_default_domain) {
- char *outdomain;
-
- if(yp_get_default_domain(&outdomain)) {
- RETURN_FALSE;
- }
- RETVAL_STRING(outdomain,1);
-}
-/* }}} */
-
-/* {{{ proto int yp_order(string domain, string map)
- Returns the order number or false */
-PHP_FUNCTION(yp_order) {
- pval *domain, *map;
-
-#if SOLARIS_YP
- unsigned long outval;
-#else
- int outval;
-#endif
-
- if((ARG_COUNT(ht) != 2) || (getParameters(ht,2,&domain,&map) == FAILURE)) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(domain);
- convert_to_string(map);
-
- if(yp_order(domain->value.str.val,map->value.str.val,&outval)) {
- RETURN_FALSE;
- }
-
- RETVAL_LONG(outval);
-}
-/* }}} */
-
-/* {{{ proto string yp_master(string domain, string map)
- Returns the machine name of the master */
-PHP_FUNCTION(yp_master) {
- pval *domain, *map;
- char *outname;
-
- if((ARG_COUNT(ht) != 2) || (getParameters(ht,2,&domain,&map) == FAILURE)) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(domain);
- convert_to_string(map);
-
- if(yp_master(domain->value.str.val,map->value.str.val,&outname)) {
- RETURN_FALSE;
- }
-
- RETVAL_STRING(outname,1);
-}
-/* }}} */
-
-/* {{{ proto string yp_match(string domain, string map, string key)
- Returns the matched line or false */
-PHP_FUNCTION(yp_match) {
- pval *domain, *map, *key;
- char *outval;
- int outvallen;
-
- if((ARG_COUNT(ht) != 3) || (getParameters(ht,3,&domain,&map,&key) == FAILURE)) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(domain);
- convert_to_string(map);
- convert_to_string(key);
-
- if(yp_match(domain->value.str.val,map->value.str.val,key->value.str.val,key->value.str.len,&outval,&outvallen)) {
- RETURN_FALSE;
- }
-
- RETVAL_STRING(outval,1);
-}
-/* }}} */
-
-/* {{{ proto array yp_first(string domain, string map)
- Returns the first key as $var["key"] and the first line as $var["value"] */
-PHP_FUNCTION(yp_first) {
- pval *domain, *map;
- char *outval, *outkey;
- int outvallen, outkeylen;
-
- if((ARG_COUNT(ht) != 2) || (getParameters(ht,2,&domain,&map) == FAILURE)) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(domain);
- convert_to_string(map);
-
- if(yp_first(domain->value.str.val,map->value.str.val,&outkey,&outkeylen,&outval,&outvallen)) {
- RETURN_FALSE;
- }
- array_init(return_value);
- add_assoc_string(return_value,"key",outkey,1);
- add_assoc_string(return_value,"value",outval,1);
-}
-/* }}} */
-
-/* {{{ proto array yp_next(string domain, string map, string key)
- Returns an array with $var[$key] and the the line as the value */
-PHP_FUNCTION(yp_next) {
- pval *domain, *map, *key;
- char *outval, *outkey;
- int outvallen, outkeylen;
-
- if((ARG_COUNT(ht) != 3) || (getParameters(ht,3,&domain,&map, &key) == FAILURE)) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string(domain);
- convert_to_string(map);
- convert_to_string(key);
-
- if(yp_next(domain->value.str.val,map->value.str.val,key->value.str.val,key->value.str.len,&outkey,&outkeylen,&outval,&outvallen)) {
- RETURN_FALSE;
- }
- array_init(return_value);
- add_assoc_string(return_value,outkey,outval,1);
-}
-/* }}} */
-
-void php3_info_yp(ZEND_MODULE_INFO_FUNC_ARGS) {
- PUTS("Compiled with YP Support.");
-}
-#endif /* HAVE_YP */
diff --git a/ext/zlib/Makefile.am b/ext/zlib/Makefile.am
deleted file mode 100644
index ef7d3ea49c..0000000000
--- a/ext/zlib/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
-noinst_LIBRARIES=libphpext_zlib.a
-libphpext_zlib_a_SOURCES=zlib.c
-
diff --git a/ext/zlib/config.h.stub b/ext/zlib/config.h.stub
deleted file mode 100644
index 5d6dcad205..0000000000
--- a/ext/zlib/config.h.stub
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Define if you have the zlib library */
-#define HAVE_ZLIB 0
diff --git a/ext/zlib/config.m4 b/ext/zlib/config.m4
deleted file mode 100644
index d6537c7b86..0000000000
--- a/ext/zlib/config.m4
+++ /dev/null
@@ -1,38 +0,0 @@
-dnl $Id$
-
-AC_MSG_CHECKING(whether to include zlib support)
-AC_ARG_WITH(zlib,
-[ --with-zlib[=DIR] Include zlib support (requires zlib >= 1.0.9).
- DIR is the zlib install directory,
- defaults to /usr.],
-[
- case "$withval" in
- no)
- AC_MSG_RESULT(no) ;;
- yes)
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(zlib)
- AC_CHECK_LIB(z, gzgets, [AC_DEFINE(HAVE_ZLIB)],
- [AC_MSG_ERROR(Zlib module requires zlib >= 1.0.9.)])
- AC_ADD_LIBRARY(z)
- ;;
- *)
- test -f $withval/include/zlib/zlib.h && ZLIB_INCLUDE="$withval/include/zlib"
- test -f $withval/include/zlib.h && ZLIB_INCLUDE="$withval/include"
- if test -n "$ZLIB_INCLUDE" ; then
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(zlib)
- old_LIBS=$LIBS
- LIBS="$LIBS -L$withval/lib"
- AC_CHECK_LIB(z, gzgets, [AC_DEFINE(HAVE_ZLIB)],
- [AC_MSG_ERROR(Zlib module requires zlib >= 1.0.9.)])
- LIBS=$old_LIBS
- AC_ADD_LIBRARY_WITH_PATH(z, $withval/lib)
- AC_ADD_INCLUDE($ZLIB_INCLUDE)
- else
- AC_MSG_RESULT(no)
- fi ;;
- esac
-],[
- AC_MSG_RESULT(no)
-])
diff --git a/ext/zlib/php3_zlib.h b/ext/zlib/php3_zlib.h
deleted file mode 100644
index 4b9ece5ff9..0000000000
--- a/ext/zlib/php3_zlib.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of the GNU General Public License as published by |
- | the Free Software Foundation; either version 2 of the License, or |
- | (at your option) any later version. |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with this program; if not, write to the Free Software |
- | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Stefan Röhrich <sr@linux.de> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _PHP3_ZLIB_H
-#define _PHP3_ZLIB_H
-
-#if COMPILE_DL
-#undef HAVE_ZLIB
-#define HAVE_ZLIB 1
-#endif
-
-#if HAVE_ZLIB
-
-typedef struct {
- int gzgetss_state;
-} php_zlib_globals;
-
-extern php3_module_entry php3_zlib_module_entry;
-#define zlib_module_ptr &php3_zlib_module_entry
-
-extern PHP_MINIT_FUNCTION(zlib);
-extern PHP_MSHUTDOWN_FUNCTION(zlib);
-PHP_MINFO_FUNCTION(zlib);
-PHP_FUNCTION(gzopen);
-PHP_FUNCTION(gzclose);
-PHP_FUNCTION(gzeof);
-PHP_FUNCTION(gzread);
-PHP_FUNCTION(gzgetc);
-PHP_FUNCTION(gzgets);
-PHP_FUNCTION(gzgetss);
-PHP_FUNCTION(gzwrite);
-PHP_FUNCTION(gzrewind);
-PHP_FUNCTION(gztell);
-PHP_FUNCTION(gzseek);
-PHP_FUNCTION(gzpassthru);
-PHP_FUNCTION(readgzfile);
-PHP_FUNCTION(gzfile);
-
-#ifdef ZTS
-#define ZLIBLS_D php_zlib_globals *zlib_globals
-#define ZLIBG(v) (zlib_globals->v)
-#define ZLIBLS_FETCH() php_zlib_globals *zlib_globals = ts_resource(zlib_globals_id)
-#else
-#define ZLIBLS_D
-#define ZLIBG(v) (zlib_globals.v)
-#define ZLIBLS_FETCH()
-#endif
-
-#else
-#define zlib_module_ptr NULL
-#endif /* HAVE_ZLIB */
-
-#define phpext_zlib_ptr zlib_module_ptr
-
-#endif /* _PHP3_ZLIB_H */
diff --git a/ext/zlib/setup.stub b/ext/zlib/setup.stub
deleted file mode 100644
index 158978766c..0000000000
--- a/ext/zlib/setup.stub
+++ /dev/null
@@ -1,7 +0,0 @@
-# $Source$
-# $Id$
-
-define_option with-zlib 'zlib (>= 1.0.9) support? ' yesnodir \
- 'no /usr zlib install' \
-' Whether to use the zlib support to read/write .gz-files.\n
- Requires zlib version >= 1.0.9!'
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
deleted file mode 100644
index d1ac269b78..0000000000
--- a/ext/zlib/zlib.c
+++ /dev/null
@@ -1,730 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Stefan Röhrich <sr@linux.de> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-#define IS_EXT_MODULE
-
-#include "php.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#if (WIN32|WINNT)
-#include <windows.h>
-#include <winsock.h>
-#define O_RDONLY _O_RDONLY
-#include "win32/param.h"
-#else
-#include <sys/param.h>
-/* #include <sys/uio.h> */
-#endif
-#include "ext/standard/head.h"
-#include "safe_mode.h"
-#include "ext/standard/php3_standard.h"
-#include "php3_zlib.h"
-#include "fopen-wrappers.h"
-#if HAVE_PWD_H
-#if WIN32|WINNT
-#include "win32/pwd.h"
-#else
-#include <pwd.h>
-#endif
-#endif
-#include "snprintf.h"
-#if HAVE_ZLIB
-#if defined(HAVE_UNISTD_H) && (WIN32|WINNT)
-#undef HAVE_UNISTD_H
-#endif
-
-#include <zlib.h>
-
-#if COMPILE_DL
-#include "dl/phpdl.h"
-#ifndef PUTS
-#define PUTS(a) php_printf("%s",a)
-#endif
-#ifndef PUTC
-#define PUTC(a) PUTS(a)
-#endif
-#ifndef PHPWRITE
-#define PHPWRITE(a,n) php3_write((a),(n))
-#endif
-#endif
-
-#ifdef ZTS
-int zlib_globals_id;
-#else
-static php_zlib_globals zlib_globals;
-#endif
-
-
-/* True globals, no need for thread safety */
-static int le_zp;
-
-function_entry php3_zlib_functions[] = {
- PHP_FE(readgzfile, NULL)
- PHP_FE(gzrewind, NULL)
- PHP_FE(gzclose, NULL)
- PHP_FE(gzeof, NULL)
- PHP_FE(gzgetc, NULL)
- PHP_FE(gzgets, NULL)
- PHP_FE(gzgetss, NULL)
- PHP_FE(gzread, NULL)
- PHP_FE(gzopen, NULL)
- PHP_FE(gzpassthru, NULL)
- PHP_FE(gzseek, NULL)
- PHP_FE(gztell, NULL)
- PHP_FE(gzwrite, NULL)
- PHP_FALIAS(gzputs, gzwrite, NULL)
- PHP_FE(gzfile, NULL)
- {NULL, NULL, NULL}
-};
-
-php3_module_entry php3_zlib_module_entry = {
- "zlib",
- php3_zlib_functions,
- PHP_MINIT(zlib),
- PHP_MSHUTDOWN(zlib),
- NULL,
- NULL,
- PHP_MINFO(zlib),
- STANDARD_MODULE_PROPERTIES
-};
-
-#if defined(COMPILE_DL)
-DLEXPORT php3_module_entry *get_module(void) { return &php_zlib_module_entry; }
-#endif
-
-static void phpi_destructor_gzclose(gzFile *zp) {
- (void)gzclose(zp);
-}
-
-#ifdef ZTS
-static void php_zlib_init_globals(ZLIBLS_D)
-{
- ZLIBG(gzgetss_state) = 0;
-}
-#endif
-
-PHP_MINIT_FUNCTION(zlib)
-{
-#ifdef ZTS
- zlib_globals_id = ts_allocate_id(sizeof(php_zlib_globals), php_zlib_init_globals, NULL);
-#else
- ZLIBG(gzgetss_state)=0;
-#endif
- le_zp = register_list_destructors(phpi_destructor_gzclose,NULL);
- return SUCCESS;
-}
-
-PHP_MSHUTDOWN_FUNCTION(zlib)
-{
- return SUCCESS;
-}
-
-PHP_MINFO_FUNCTION(zlib)
-{
- PUTS("Zlib support active (compiled with ");
- PUTS(ZLIB_VERSION);
- PUTS(", linked with ");
- PUTS((char *)zlibVersion());
- PUTS(").");
-}
-
-static gzFile *php3_gzopen_with_path(char *filename, char *mode, char *path, char **opened_path);
-
-static gzFile php3_gzopen_wrapper(char *path, char *mode, int options)
-{
- PLS_FETCH();
-
- if (options & USE_PATH && PG(include_path) != NULL) {
- return php3_gzopen_with_path(path, mode, PG(include_path), NULL);
- }
- else {
- if (options & ENFORCE_SAFE_MODE && PG(safe_mode) && (!_php3_checkuid(path,1))) {
- return NULL;
- }
- if (_php3_check_open_basedir(path)) return NULL;
- return gzopen(path, mode);
- }
-}
-
-/*
- * Tries to open a .gz-file with a PATH-style list of directories.
- * If the filename starts with "." or "/", the path is ignored.
- */
-static gzFile *php3_gzopen_with_path(char *filename, char *mode, char *path, char **opened_path)
-{
- char *pathbuf, *ptr, *end;
- char trypath[MAXPATHLEN + 1];
- struct stat sb;
- gzFile *zp;
- PLS_FETCH();
-
- if (opened_path) {
- *opened_path = NULL;
- }
-
- /* Relative path open */
- if (*filename == '.') {
- if (PG(safe_mode) &&(!_php3_checkuid(filename,2))) {
- return(NULL);
- }
- if (_php3_check_open_basedir(filename)) return NULL;
- zp = gzopen(filename, mode);
- if (zp && opened_path) {
- *opened_path = expand_filepath(filename);
- }
- return zp;
- }
-
- /* Absolute path open - prepend document_root in safe mode */
-#if WIN32|WINNT
- if ((*filename == '\\')||(*filename == '/')||(filename[1] == ':')) {
-#else
- if (*filename == '/') {
-#endif
- if (PG(safe_mode)) {
- if(PG(doc_root)) {
- snprintf(trypath, MAXPATHLEN, "%s%s", PG(doc_root), filename);
- } else {
- strlcpy(trypath,filename,sizeof(trypath));
- }
- if (!_php3_checkuid(trypath,2)) {
- return(NULL);
- }
- if (_php3_check_open_basedir(trypath)) return NULL;
- zp = gzopen(trypath, mode);
- if (zp && opened_path) {
- *opened_path = expand_filepath(trypath);
- }
- return zp;
- } else {
- if (_php3_check_open_basedir(filename)) return NULL;
- return gzopen(filename, mode);
- }
- }
-
- if (!path || (path && !*path)) {
- if (PG(safe_mode) &&(!_php3_checkuid(filename,2))) {
- return(NULL);
- }
- if (_php3_check_open_basedir(filename)) return NULL;
- zp = gzopen(filename, mode);
- if (zp && opened_path) {
- *opened_path = strdup(filename);
- }
- return zp;
- }
-
- pathbuf = estrdup(path);
-
- ptr = pathbuf;
-
- while (ptr && *ptr) {
-#if WIN32|WINNT
- end = strchr(ptr, ';');
-#else
- end = strchr(ptr, ':');
-#endif
- if (end != NULL) {
- *end = '\0';
- end++;
- }
- snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename);
- if (PG(safe_mode)) {
- if (stat(trypath,&sb) == 0 &&(!_php3_checkuid(trypath,2))) {
- efree(pathbuf);
- return(NULL);
- }
- }
- if ((zp = gzopen(trypath, mode)) != NULL) {
- if (_php3_check_open_basedir(trypath)) {
- gzclose(zp);
- efree(pathbuf);
- return NULL;
- }
- if (opened_path) {
- *opened_path = expand_filepath(trypath);
- }
- efree(pathbuf);
- return zp;
- }
- ptr = end;
- }
- efree(pathbuf);
- return NULL;
-}
-
-/* {{{ proto array gzfile(string filename [, int use_include_path])
-Read und uncompress entire .gz-file into an array */
-PHP_FUNCTION(gzfile) {
- pval *filename, *arg2;
- gzFile zp;
- char *slashed, buf[8192];
- register int i=0;
- int use_include_path = 0;
- PLS_FETCH();
-
- /* check args */
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht,1,&filename) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 2:
- if (getParameters(ht,2,&filename,&arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg2);
- use_include_path = arg2->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- }
- convert_to_string(filename);
-
- zp = php3_gzopen_wrapper(filename->value.str.val,"r", use_include_path|ENFORCE_SAFE_MODE);
- if (!zp) {
- php_error(E_WARNING,"gzFile(\"%s\") - %s",filename->value.str.val,strerror(errno));
- RETURN_FALSE;
- }
-
- /* Initialize return array */
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
-
- /* Now loop through the file and do the magic quotes thing if needed */
- memset(buf,0,8191);
- while(gzgets(zp, buf, 8191) != NULL) {
- if (PG(magic_quotes_runtime)) {
- int len;
-
- slashed = php_addslashes(buf,0,&len,0); /* 0 = don't free source string */
- add_index_stringl(return_value, i++, slashed, len, 0);
- } else {
- add_index_string(return_value, i++, buf, 1);
- }
- }
- gzclose(zp);
-}
-/* }}} */
-
-/* {{{ proto int gzopen(string filename, string mode [, int use_include_path])
-Open a .gz-file and return a .gz-file pointer */
-PHP_FUNCTION(gzopen) {
- pval *arg1, *arg2, *arg3;
- gzFile *zp;
- char *p;
- int use_include_path = 0;
- ZLIBLS_FETCH();
-
- switch(ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht,2,&arg1,&arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 3:
- if (getParameters(ht,3,&arg1,&arg2,&arg3) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg3);
- use_include_path = arg3->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg1);
- convert_to_string(arg2);
- p = estrndup(arg2->value.str.val,arg2->value.str.len);
-
- /*
- * We need a better way of returning error messages from
- * php3_gzopen_wrapper().
- */
- zp = php3_gzopen_wrapper(arg1->value.str.val, p, use_include_path|ENFORCE_SAFE_MODE);
- if (!zp) {
- php_error(E_WARNING,"gzopen(\"%s\",\"%s\") - %s",
- arg1->value.str.val, p, strerror(errno));
- efree(p);
- RETURN_FALSE;
- }
- ZLIBG(gzgetss_state)=0;
- efree(p);
- ZEND_REGISTER_RESOURCE(return_value, zp, le_zp);
-}
-/* }}} */
-
-/* {{{ proto int gzclose(int zp)
-Close an open .gz-file pointer */
-PHP_FUNCTION(gzclose) {
- pval *arg1;
- gzFile *zp;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- ZEND_FETCH_RESOURCE(zp, gzFile *, arg1, -1, "Zlib file", le_zp);
- zend_list_delete(arg1->value.lval);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int gzeof(int zp)
-Test for end-of-file on a .gz-file pointer */
-PHP_FUNCTION(gzeof) {
- pval *arg1;
- gzFile *zp;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- ZEND_FETCH_RESOURCE(zp, gzFile *, arg1, -1, "Zlib file", le_zp);
-
- if ((gzeof(zp))) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto string gzgets(int zp, int length)
-Get a line from .gz-file pointer */
-PHP_FUNCTION(gzgets) {
- pval *arg1, *arg2;
- gzFile *zp;
- int len;
- char *buf;
- PLS_FETCH();
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg2);
- len = arg2->value.lval;
-
- ZEND_FETCH_RESOURCE(zp, gzFile *, arg1, -1, "Zlib file", le_zp);
-
- buf = emalloc(sizeof(char) * (len + 1));
- /* needed because recv doesnt put a null at the end*/
- memset(buf,0,len+1);
- if (!(gzgets(zp, buf, len) != NULL)) {
- efree(buf);
- RETVAL_FALSE;
- } else {
- if (PG(magic_quotes_runtime)) {
- return_value->value.str.val = php_addslashes(buf,0,&return_value->value.str.len,1);
- } else {
- return_value->value.str.val = buf;
- return_value->value.str.len = strlen(return_value->value.str.val);
- }
- return_value->type = IS_STRING;
- }
- return;
-}
-/* }}} */
-
-/* {{{ proto string gzgetc(int zp)
-Get a character from .gz-file pointer */
-PHP_FUNCTION(gzgetc) {
- pval *arg1;
- gzFile *zp;
- int c;
- char *buf;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(zp, gzFile *, arg1, -1, "Zlib file", le_zp);
-
- buf = emalloc(sizeof(char) * 2);
- if ((c=gzgetc(zp)) == (-1)) {
- efree(buf);
- RETVAL_FALSE;
- } else {
- buf[0]=(char)c;
- buf[1]='\0';
- return_value->value.str.val = buf;
- return_value->value.str.len = 1;
- return_value->type = IS_STRING;
- }
- return;
-}
-/* }}} */
-
-/* Strip any HTML tags while reading */
-/* {{{ proto string gzgetss(int zp, int length)
-Get a line from file pointer and strip HTML tags */
-PHP_FUNCTION(gzgetss)
-{
- pval *fd, *bytes;
- gzFile *zp;
- int len;
- char *buf;
- ZLIBLS_FETCH();
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &fd, &bytes) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(bytes);
-
- len = bytes->value.lval;
-
- ZEND_FETCH_RESOURCE(zp, gzFile *, fd, -1, "Zlib file", le_zp);
-
- buf = emalloc(sizeof(char) * (len + 1));
- /*needed because recv doesnt set null char at end*/
- memset(buf,0,len+1);
- if (!(gzgets(zp, buf, len) != NULL)) {
- efree(buf);
- RETURN_FALSE;
- }
-
- _php3_strip_tags(buf, ZLIBG(gzgetss_state));
- RETURN_STRING(buf, 0);
-
-}
-/* }}} */
-
-/* {{{ proto int gzwrite(int zp, string str [, int length])
-Binary-safe .gz-file write */
-PHP_FUNCTION(gzwrite) {
- pval *arg1, *arg2, *arg3=NULL;
- gzFile *zp;
- int ret;
- int num_bytes;
- PLS_FETCH();
-
- switch (ARG_COUNT(ht)) {
- case 2:
- if (getParameters(ht, 2, &arg1, &arg2)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(arg2);
- num_bytes = arg2->value.str.len;
- break;
- case 3:
- if (getParameters(ht, 3, &arg1, &arg2, &arg3)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string(arg2);
- convert_to_long(arg3);
- num_bytes = MIN(arg3->value.lval, arg2->value.str.len);
- break;
- default:
- WRONG_PARAM_COUNT;
- /* NOTREACHED */
- break;
- }
- ZEND_FETCH_RESOURCE(zp, gzFile *, arg1, -1, "Zlib file", le_zp);
-
- /* strip slashes only if the length wasn't specified explicitly */
- if (!arg3 && PG(magic_quotes_runtime)) {
- php_stripslashes(arg2->value.str.val,&num_bytes);
- }
-
- ret = gzwrite(zp, arg2->value.str.val,num_bytes);
- RETURN_LONG(ret);
-}
-/* }}} */
-
-/* {{{ proto int gzputs(int zp, string str [, int length])
- An alias for gzwrite */
-/* }}} */
-
-/* {{{ proto int gzrewind(int zp)
-Rewind the position of a .gz-file pointer */
-PHP_FUNCTION(gzrewind) {
- pval *arg1;
- gzFile *zp;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(zp, gzFile *, arg1, -1, "Zlib file", le_zp);
-
- gzrewind(zp);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int gztell(int zp)
-Get .gz-file pointer's read/write position */
-PHP_FUNCTION(gztell) {
- pval *arg1;
- long pos;
- gzFile *zp;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(zp, gzFile *, arg1, -1, "Zlib file", le_zp);
-
- pos = gztell(zp);
- RETURN_LONG(pos);
-}
-/* }}} */
-
-/* {{{ proto int gzseek(int zp, int offset)
-Seek on a file pointer */
-PHP_FUNCTION(gzseek) {
- pval *arg1, *arg2;
- int ret;
- long pos;
- gzFile *zp;
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg2);
- pos = arg2->value.lval;
-
- ZEND_FETCH_RESOURCE(zp, gzFile *, arg1, -1, "Zlib file", le_zp);
-
- ret = gzseek(zp,pos,SEEK_SET);
- RETURN_LONG(ret);
-}
-/* }}} */
-
-/*
- * Read a file and write the ouput to stdout
- */
-/* {{{ proto int readgzfile(string filename [, int use_include_path])
-Output a .gz-file */
-PHP_FUNCTION(readgzfile) {
- pval *arg1, *arg2;
- char buf[8192];
- gzFile *zp;
- int b, size;
- int use_include_path = 0;
-
-
- /* check args */
- switch (ARG_COUNT(ht)) {
- case 1:
- if (getParameters(ht,1,&arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- break;
- case 2:
- if (getParameters(ht,2,&arg1,&arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg2);
- use_include_path = arg2->value.lval;
- break;
- default:
- WRONG_PARAM_COUNT;
- }
- convert_to_string(arg1);
-
- /*
- * We need a better way of returning error messages from
- * php3_gzopen_wrapper().
- */
- zp = php3_gzopen_wrapper(arg1->value.str.val,"r", use_include_path|ENFORCE_SAFE_MODE);
- if (!zp){
- php_error(E_WARNING,"ReadGzFile(\"%s\") - %s",arg1->value.str.val,strerror(errno));
- RETURN_FALSE;
- }
- size= 0;
- while((b = gzread(zp, buf, sizeof(buf))) > 0) {
- PHPWRITE(buf,b);
- size += b ;
- }
- gzclose(zp);
- RETURN_LONG(size);
-}
-/* }}} */
-
-/*
- * Read to EOF on a file descriptor and write the output to stdout.
- */
-/* {{{ proto int gzpassthru(int zp)
-Output all remaining data from a .gz-file pointer */
-PHP_FUNCTION(gzpassthru) {
- pval *arg1;
- gzFile *zp;
- char buf[8192];
- int size, b;
-
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(zp, gzFile *, arg1, -1, "Zlib file", le_zp);
-
- size = 0;
- while((b = gzread(zp, buf, sizeof(buf))) > 0) {
- PHPWRITE(buf,b);
- size += b ;
- }
-/* gzclose(zp); */
- zend_list_delete(arg1->value.lval);
- RETURN_LONG(size);
-}
-/* }}} */
-
-/* {{{ proto string gzread(int zp, int length)
-Binary-safe file read */
-PHP_FUNCTION(gzread)
-{
- pval *arg1, *arg2;
- gzFile *zp;
- int len;
- PLS_FETCH();
-
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(arg2);
- len = arg2->value.lval;
-
- ZEND_FETCH_RESOURCE(zp, gzFile *, arg1, -1, "Zlib file", le_zp);
-
- return_value->value.str.val = emalloc(sizeof(char) * (len + 1));
- /* needed because recv doesnt put a null at the end*/
-
- return_value->value.str.len = gzread(zp, return_value->value.str.val, len);
- return_value->value.str.val[return_value->value.str.len] = 0;
-
- if (PG(magic_quotes_runtime)) {
- return_value->value.str.val = php_addslashes(return_value->value.str.val,return_value->value.str.len,&return_value->value.str.len,1);
- }
- return_value->type = IS_STRING;
-}
-/* }}} */
-
-#endif /* HAVE_ZLIB */
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/fhttpd.c b/fhttpd.c
deleted file mode 100644
index 5e105351cb..0000000000
--- a/fhttpd.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Alex Belits <abelits@phobos.illtel.denver.co.us> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-#include "php.h"
-
-#include <stdlib.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <string.h>
-#include <errno.h>
-#include <ctype.h>
-
-#if FHTTPD
-#include <servproc.h>
-#include <signal.h>
-
-struct http_server *server = NULL;
-struct request *req = NULL;
-struct httpresponse *response = NULL;
-int headermade = 0;
-int global_alarmflag = 0;
-int idle_timeout = IDLE_TIMEOUT;
-int exit_status = 0;
-char **currentheader = NULL;
-char *headerfirstline = NULL;
-int headerlines = 0;
-static int headerlinesallocated = 0;
-
-void alarmhandler(SIGACTARGS)
-{
- global_alarmflag = 1;
-}
-
-void setalarm(int t)
-{
- struct sigaction tmpsigaction;
- global_alarmflag = 0;
- if (t){
- bzero((char *) &tmpsigaction, sizeof(struct sigaction));
- tmpsigaction.sa_handler = alarmhandler;
- sigaddset(&tmpsigaction.sa_mask, SIGALRM);
- tmpsigaction.sa_flags = 0;
- sigaction(SIGALRM, &tmpsigaction, NULL);
- alarm(t);
- }
-}
-
-int checkinput(int h)
-{
- fd_set readfd;
- FD_ZERO(&readfd);
- FD_SET(h, &readfd);
- return select(h + 1, &readfd, NULL, NULL, NULL) > 0;
-}
-
-
-PHPAPI void php3_fhttpd_free_header(void)
-{
- int i;
-
- if (headerfirstline) {
- free(headerfirstline);
- headerfirstline = NULL;
- }
- if (currentheader) {
- for (i = 0; i < headerlines; i++) {
- free(currentheader[i]);
- }
- free(currentheader);
- currentheader = NULL;
- }
- headerlines = 0;
- headerlinesallocated = 0;
- headermade = 0;
-}
-
-
-PHPAPI void php3_fhttpd_puts_header(char *s)
-{
- char *p0, *p1, *p2, *p3, **p;
- int l;
-
- if (!s || !*s || *s == '\r' || *s == '\n')
- return;
- l = strlen(s);
- p2 = strchr(s, '\r');
- p3 = strchr(s, '\n');
- p0 = strchr(s, ':');
- p1 = strchr(s, ' ');
- if (p0 && (!p1 || p1 > p0)) {
- if (!headerlinesallocated) {
- currentheader = (char **) malloc(10 * sizeof(char *));
- if (currentheader)
- headerlinesallocated = 10;
- } else {
- if (headerlinesallocated <= headerlines) {
- p = (char **) realloc(currentheader, (headerlinesallocated + 10) * sizeof(char *));
- if (p) {
- currentheader = p;
- headerlinesallocated += 10;
- }
- }
- }
-
- if (headerlinesallocated > headerlines) {
- currentheader[headerlines] = malloc(l + 3);
- if (currentheader[headerlines]) {
- strcpy(currentheader[headerlines], s);
- if (!p3) {
- if (p2) {
- (currentheader[headerlines] + (p2 - s))[1] = '\n';
- (currentheader[headerlines] + (p2 - s))[2] = 0;
- } else {
- currentheader[headerlines][l] = '\r';
- currentheader[headerlines][l + 1] = '\n';
- currentheader[headerlines][l + 2] = 0;
- }
- }
- headerlines++;
- headermade = 1;
- }
- }
- } else {
- if (headerfirstline)
- free(headerfirstline);
- headerfirstline = malloc(l + 3);
- if (headerfirstline) {
- strcpy(headerfirstline, s);
- if (!p3) {
- if (p2) {
- (headerfirstline + (p2 - s))[1] = '\n';
- (headerfirstline + (p2 - s))[2] = 0;
- } else {
- headerfirstline[l] = '\r';
- headerfirstline[l + 1] = '\n';
- headerfirstline[l + 2] = 0;
- }
- }
- }
- headermade = 1;
- }
-}
-
-void fhttpd_flush(void)
-{
-}
-
-PHPAPI void php3_fhttpd_puts(char *s)
-{
- putlinetoresponse(response, s);
-}
-
-PHPAPI void php3_fhttpd_putc(char c)
-{
- writetoresponse(response, &c, 1);
-}
-
-PHPAPI int php3_fhttpd_write(char *a, int n)
-{
- return writetoresponse(response, a, n);
-}
-#endif
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/filepro.mak b/filepro.mak
deleted file mode 100644
index a45c42d807..0000000000
--- a/filepro.mak
+++ /dev/null
@@ -1,194 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on filepro.dsp
-!IF "$(CFG)" == ""
-CFG=filepro - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to filepro - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "filepro - Win32 Release" && "$(CFG)" != "filepro - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "filepro.mak" CFG="filepro - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "filepro - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "filepro - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-!IF "$(CFG)" == "filepro - Win32 Release"
-
-OUTDIR=.\module_release
-INTDIR=.\module_release
-# Begin Custom Macros
-OutDir=.\module_release
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_filepro.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\filepro.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(OUTDIR)\php3_filepro.dll"
- -@erase "$(OUTDIR)\php3_filepro.exp"
- -@erase "$(OUTDIR)\php3_filepro.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "./" /I "../" /I "../../include" /D HAVE_FILEPRO=1 /D "NDEBUG" /D "THREAD_SAFE" /D "MSVC5" /D "COMPILE_DL" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\filepro.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\filepro.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:1.0 /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\php3_filepro.pdb" /machine:I386 /out:"$(OUTDIR)\php3_filepro.dll" /implib:"$(OUTDIR)\php3_filepro.lib" /libpath:"..\..\lib" /libpath:"cgi_release"
-LINK32_OBJS= \
- "$(INTDIR)\filepro.obj"
-
-"$(OUTDIR)\php3_filepro.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "filepro - Win32 Debug"
-
-OUTDIR=.\module_debug
-INTDIR=.\module_debug
-# Begin Custom Macros
-OutDir=.\module_debug
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_filepro.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\filepro.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(INTDIR)\vc60.pdb"
- -@erase "$(OUTDIR)\php3_filepro.dll"
- -@erase "$(OUTDIR)\php3_filepro.exp"
- -@erase "$(OUTDIR)\php3_filepro.ilk"
- -@erase "$(OUTDIR)\php3_filepro.lib"
- -@erase "$(OUTDIR)\php3_filepro.pdb"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "./" /I "../" /I "../../include" /D HAVE_FILEPRO=1 /D "DEBUG" /D "_DEBUG" /D "THREAD_SAFE" /D "MSVC5" /D "COMPILE_DL" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\filepro.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\filepro.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:1.0 /subsystem:windows /dll /incremental:yes /pdb:"$(OUTDIR)\php3_filepro.pdb" /debug /machine:I386 /out:"$(OUTDIR)\php3_filepro.dll" /implib:"$(OUTDIR)\php3_filepro.lib" /pdbtype:sept /libpath:"..\..\lib" /libpath:"cgi_debug"
-LINK32_OBJS= \
- "$(INTDIR)\filepro.obj"
-
-"$(OUTDIR)\php3_filepro.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF
-
-
-!IF "$(NO_EXTERNAL_DEPS)" != "1"
-!IF EXISTS("filepro.dep")
-!INCLUDE "filepro.dep"
-!ELSE
-!MESSAGE Warning: cannot find "filepro.dep"
-!ENDIF
-!ENDIF
-
-
-!IF "$(CFG)" == "filepro - Win32 Release" || "$(CFG)" == "filepro - Win32 Debug"
-SOURCE=.\functions\filepro.c
-
-"$(INTDIR)\filepro.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-
-!ENDIF
-
diff --git a/footer b/footer
deleted file mode 100644
index c217e2be43..0000000000
--- a/footer
+++ /dev/null
@@ -1,7 +0,0 @@
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/gd.mak b/gd.mak
deleted file mode 100644
index 6bd0db1376..0000000000
--- a/gd.mak
+++ /dev/null
@@ -1,214 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on gd.dsp
-!IF "$(CFG)" == ""
-CFG=gd - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to gd - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "gd - Win32 Release" && "$(CFG)" != "gd - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "gd.mak" CFG="gd - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "gd - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "gd - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-!IF "$(CFG)" == "gd - Win32 Release"
-
-OUTDIR=.\module_Release
-INTDIR=.\module_Release
-# Begin Custom Macros
-OutDir=.\module_Release
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_gd.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\gd.obj"
- -@erase "$(INTDIR)\gdcache.obj"
- -@erase "$(INTDIR)\gdttf.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(OUTDIR)\php3_gd.dll"
- -@erase "$(OUTDIR)\php3_gd.exp"
- -@erase "$(OUTDIR)\php3_gd.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "./" /I "../" /I "../../include" /D HAVE_LIBGD=1 /D HAVE_LIBGD13=1 /D HAVE_LIBTTF=1 /D "NDEBUG" /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\gd.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\gd.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=freetype.lib php.lib libgd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\php3_gd.pdb" /machine:I386 /out:"$(OUTDIR)\php3_gd.dll" /implib:"$(OUTDIR)\php3_gd.lib" /libpath:"..\..\lib" /libpath:"cgi_release"
-LINK32_OBJS= \
- "$(INTDIR)\gd.obj" \
- "$(INTDIR)\gdcache.obj" \
- "$(INTDIR)\gdttf.obj"
-
-"$(OUTDIR)\php3_gd.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "gd - Win32 Debug"
-
-OUTDIR=.\module_Debug
-INTDIR=.\module_Debug
-# Begin Custom Macros
-OutDir=.\module_Debug
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_gd.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\gd.obj"
- -@erase "$(INTDIR)\gdcache.obj"
- -@erase "$(INTDIR)\gdttf.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(INTDIR)\vc60.pdb"
- -@erase "$(OUTDIR)\php3_gd.dll"
- -@erase "$(OUTDIR)\php3_gd.exp"
- -@erase "$(OUTDIR)\php3_gd.ilk"
- -@erase "$(OUTDIR)\php3_gd.lib"
- -@erase "$(OUTDIR)\php3_gd.pdb"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "./" /I "../" /I "../../include" /D HAVE_LIBGD=1 /D HAVE_LIBGD13=1 /D HAVE_LIBTTF=1 /D "DEBUG" /D "_DEBUG" /D "HAVE_GDTTF" /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\gd.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\gd.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=freetype.lib php.lib libgd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:yes /pdb:"$(OUTDIR)\php3_gd.pdb" /debug /machine:I386 /out:"$(OUTDIR)\php3_gd.dll" /implib:"$(OUTDIR)\php3_gd.lib" /pdbtype:sept /libpath:"..\..\lib" /libpath:"cgi_debug"
-LINK32_OBJS= \
- "$(INTDIR)\gd.obj" \
- "$(INTDIR)\gdcache.obj" \
- "$(INTDIR)\gdttf.obj"
-
-"$(OUTDIR)\php3_gd.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF
-
-
-!IF "$(NO_EXTERNAL_DEPS)" != "1"
-!IF EXISTS("gd.dep")
-!INCLUDE "gd.dep"
-!ELSE
-!MESSAGE Warning: cannot find "gd.dep"
-!ENDIF
-!ENDIF
-
-
-!IF "$(CFG)" == "gd - Win32 Release" || "$(CFG)" == "gd - Win32 Debug"
-SOURCE=.\functions\gd.c
-
-"$(INTDIR)\gd.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\functions\gdcache.c
-
-"$(INTDIR)\gdcache.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\functions\gdttf.c
-
-"$(INTDIR)\gdttf.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-
-!ENDIF
-
diff --git a/genif.pl b/genif.pl
deleted file mode 100644
index dbbfd80e65..0000000000
--- a/genif.pl
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/perl
-
-$in_file = shift || die "Give .in file as first parameter";
-$srcdir = shift || die "Give source dir as second parameter";
-@extensions = @ARGV;
-
-open(IN, $in_file) or die "Could not open .in file $in_file";
-while (<IN>) {
- if (/\@EXT_INCLUDE_CODE\@/) {
- foreach $ext (@extensions) {
- $hdr_file = "ext/$ext/php3_${ext}.h";
- if (-f "$srcdir/$hdr_file") {
- print "#include \"ext/${ext}/php3_${ext}.h\"\n";
- }
- }
- } elsif (/\@EXT_MODULE_PTRS\@/) {
- foreach $ext (@extensions) {
- print " phpext_${ext}_ptr,\n";
- }
- } else {
- print;
- }
-}
-close(IN);
diff --git a/genif.sh b/genif.sh
deleted file mode 100644
index 4c182ec67e..0000000000
--- a/genif.sh
+++ /dev/null
@@ -1,40 +0,0 @@
-#! /bin/sh
-
-# $Id: genif.sh,v 1.7 1999-09-03 17:46:39 sas Exp $
-# replacement for genif.pl
-
-infile="$1"
-shift
-srcdir="$1"
-shift
-
-if test "$infile" = "" -o "$srcdir" = ""; then
- echo "please supply infile and srcdir"
- exit 1
-fi
-
-module_ptrs=""
-includes=""
-
-olddir=`pwd`
-cd $srcdir
-
-for ext in ${1+"$@"} ; do
- module_ptrs=" phpext_${ext}_ptr,\\\n$module_ptrs"
- for header in ext/$ext/*.h ; do
- if grep phpext_ $header >/dev/null 2>&1 ; then
- includes="#include \"$header\"\\\n$includes"
- fi
- done
-done
-
-cd $olddir
-
-cat $infile | \
- sed \
- -e "s'@EXT_INCLUDE_CODE@'$includes'" \
- -e "s'@EXT_MODULE_PTRS@'$module_ptrs'" \
- -e 's/\\n/\
-/g'
-
-
diff --git a/getopt.c b/getopt.c
deleted file mode 100644
index 3b431f4408..0000000000
--- a/getopt.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/* Borrowed from Apache NT Port */
-
-#if !APACHE
-
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <stdlib.h>
-#include "php_getopt.h"
-#define OPTERRCOLON (1)
-#define OPTERRNF (2)
-#define OPTERRARG (3)
-
-
-PHPAPI char *optarg;
-PHPAPI int optind = 1;
-static int opterr = 1;
-static int optopt;
-
-static int
-optiserr(int argc, char * const *argv, int oint, const char *optstr,
- int optchr, int err)
-{
- if (opterr)
- {
- fprintf(stderr, "Error in argument %d, char %d: ", oint, optchr+1);
- switch(err)
- {
- case OPTERRCOLON:
- fprintf(stderr, ": in flags\n");
- break;
- case OPTERRNF:
- fprintf(stderr, "option not found %c\n", argv[oint][optchr]);
- break;
- case OPTERRARG:
- fprintf(stderr, "no argument for option %c\n", argv[oint][optchr]);
- break;
- default:
- fprintf(stderr, "unknown\n");
- break;
- }
- }
- optopt = argv[oint][optchr];
- return('?');
-}
-
-PHPAPI int getopt(int argc, char* const *argv, const char *optstr)
-{
- static int optchr = 0;
- static int dash = 0; /* have already seen the - */
-
- char *cp;
-
- if (optind >= argc)
- return(EOF);
- if (!dash && (argv[optind][0] != '-'))
- return(EOF);
- if (!dash && (argv[optind][0] == '-') && !argv[optind][1])
- {
- /*
- * use to specify stdin. Need to let pgm process this and
- * the following args
- */
- return(EOF);
- }
- if ((argv[optind][0] == '-') && (argv[optind][1] == '-'))
- {
- /* -- indicates end of args */
- optind++;
- return(EOF);
- }
- if (!dash)
- {
- assert((argv[optind][0] == '-') && argv[optind][1]);
- dash = 1;
- optchr = 1;
- }
-
- /* Check if the guy tries to do a -: kind of flag */
- assert(dash);
- if (argv[optind][optchr] == ':')
- {
- dash = 0;
- optind++;
- return(optiserr(argc, argv, optind-1, optstr, optchr, OPTERRCOLON));
- }
- if (!(cp = strchr(optstr, argv[optind][optchr])))
- {
- int errind = optind;
- int errchr = optchr;
-
- if (!argv[optind][optchr+1])
- {
- dash = 0;
- optind++;
- }
- else
- optchr++;
- return(optiserr(argc, argv, errind, optstr, errchr, OPTERRNF));
- }
- if (cp[1] == ':')
- {
- dash = 0;
- optind++;
- if (optind == argc)
- return(optiserr(argc, argv, optind-1, optstr, optchr, OPTERRARG));
- optarg = argv[optind++];
- return(*cp);
- }
- else
- {
- if (!argv[optind][optchr+1])
- {
- dash = 0;
- optind++;
- }
- else
- optchr++;
- return(*cp);
- }
- assert(0);
- return(0);
-}
-
-#endif /* !APACHE */
-
-#ifdef TESTGETOPT
-int
- main (int argc, char **argv)
- {
- int c;
- extern char *optarg;
- extern int optind;
- int aflg = 0;
- int bflg = 0;
- int errflg = 0;
- char *ofile = NULL;
-
- while ((c = getopt(argc, argv, "abo:")) != EOF)
- switch (c) {
- case 'a':
- if (bflg)
- errflg++;
- else
- aflg++;
- break;
- case 'b':
- if (aflg)
- errflg++;
- else
- bflg++;
- break;
- case 'o':
- ofile = optarg;
- (void)printf("ofile = %s\n", ofile);
- break;
- case '?':
- errflg++;
- }
- if (errflg) {
- (void)fprintf(stderr,
- "usage: cmd [-a|-b] [-o <filename>] files...\n");
- exit (2);
- }
- for ( ; optind < argc; optind++)
- (void)printf("%s\n", argv[optind]);
- return 0;
- }
-
-#endif /* TESTGETOPT */
diff --git a/header b/header
deleted file mode 100644
index 707e5f2593..0000000000
--- a/header
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: |
- | |
- +----------------------------------------------------------------------+
- */
diff --git a/hyperwave.mak b/hyperwave.mak
deleted file mode 100644
index fc01b8d973..0000000000
--- a/hyperwave.mak
+++ /dev/null
@@ -1,214 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on hyperwave.dsp
-!IF "$(CFG)" == ""
-CFG=hyperwave - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to hyperwave - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "hyperwave - Win32 Release" && "$(CFG)" != "hyperwave - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "hyperwave.mak" CFG="hyperwave - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "hyperwave - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "hyperwave - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-!IF "$(CFG)" == "hyperwave - Win32 Release"
-
-OUTDIR=.\module_Release
-INTDIR=.\module_Release
-# Begin Custom Macros
-OutDir=.\module_Release
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_hyperwave.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\dlist.obj"
- -@erase "$(INTDIR)\hg_comm.obj"
- -@erase "$(INTDIR)\hw.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(OUTDIR)\php3_hyperwave.dll"
- -@erase "$(OUTDIR)\php3_hyperwave.exp"
- -@erase "$(OUTDIR)\php3_hyperwave.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "./" /I "../" /I "../../include" /D "HYPERWAVE" /D "NDEBUG" /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\hyperwave.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\hyperwave.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\php3_hyperwave.pdb" /machine:I386 /out:"$(OUTDIR)\php3_hyperwave.dll" /implib:"$(OUTDIR)\php3_hyperwave.lib" /libpath:"..\..\lib" /libpath:"cgi_release"
-LINK32_OBJS= \
- "$(INTDIR)\dlist.obj" \
- "$(INTDIR)\hg_comm.obj" \
- "$(INTDIR)\hw.obj"
-
-"$(OUTDIR)\php3_hyperwave.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "hyperwave - Win32 Debug"
-
-OUTDIR=.\module_Debug
-INTDIR=.\module_Debug
-# Begin Custom Macros
-OutDir=.\module_Debug
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_hyperwave.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\dlist.obj"
- -@erase "$(INTDIR)\hg_comm.obj"
- -@erase "$(INTDIR)\hw.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(INTDIR)\vc60.pdb"
- -@erase "$(OUTDIR)\php3_hyperwave.dll"
- -@erase "$(OUTDIR)\php3_hyperwave.exp"
- -@erase "$(OUTDIR)\php3_hyperwave.ilk"
- -@erase "$(OUTDIR)\php3_hyperwave.lib"
- -@erase "$(OUTDIR)\php3_hyperwave.pdb"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "./" /I "../" /I "../../include" /D "HYPERWAVE" /D "DEBUG" /D "_DEBUG" /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\hyperwave.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\hyperwave.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:yes /pdb:"$(OUTDIR)\php3_hyperwave.pdb" /debug /machine:I386 /out:"$(OUTDIR)\php3_hyperwave.dll" /implib:"$(OUTDIR)\php3_hyperwave.lib" /pdbtype:sept /libpath:"..\..\lib" /libpath:"cgi_debug"
-LINK32_OBJS= \
- "$(INTDIR)\dlist.obj" \
- "$(INTDIR)\hg_comm.obj" \
- "$(INTDIR)\hw.obj"
-
-"$(OUTDIR)\php3_hyperwave.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF
-
-
-!IF "$(NO_EXTERNAL_DEPS)" != "1"
-!IF EXISTS("hyperwave.dep")
-!INCLUDE "hyperwave.dep"
-!ELSE
-!MESSAGE Warning: cannot find "hyperwave.dep"
-!ENDIF
-!ENDIF
-
-
-!IF "$(CFG)" == "hyperwave - Win32 Release" || "$(CFG)" == "hyperwave - Win32 Debug"
-SOURCE=.\functions\dlist.c
-
-"$(INTDIR)\dlist.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\functions\hg_comm.c
-
-"$(INTDIR)\hg_comm.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\functions\hw.c
-
-"$(INTDIR)\hw.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-
-!ENDIF
-
diff --git a/imap4.mak b/imap4.mak
deleted file mode 100644
index f7df9624ae..0000000000
--- a/imap4.mak
+++ /dev/null
@@ -1,194 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on imap4.dsp
-!IF "$(CFG)" == ""
-CFG=imap4 - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to imap4 - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "imap4 - Win32 Release" && "$(CFG)" != "imap4 - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "imap4.mak" CFG="imap4 - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "imap4 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "imap4 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-!IF "$(CFG)" == "imap4 - Win32 Release"
-
-OUTDIR=.\module_release
-INTDIR=.\module_release
-# Begin Custom Macros
-OutDir=.\module_release
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_imap4r2.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\imap.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(OUTDIR)\php3_imap4r2.dll"
- -@erase "$(OUTDIR)\php3_imap4r2.exp"
- -@erase "$(OUTDIR)\php3_imap4r2.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "./" /I "../" /I "../../include" /D HAVE_IMAP=1 /D "NDEBUG" /D "MSVC5" /D "THREAD_SAFE" /D "COMPILE_DL" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\imap4.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\imap4.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=cclient.lib php.lib wsock32.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\php3_imap4r2.pdb" /machine:I386 /out:"$(OUTDIR)\php3_imap4r2.dll" /implib:"$(OUTDIR)\php3_imap4r2.lib" /libpath:"..\..\lib" /libpath:"cgi_release"
-LINK32_OBJS= \
- "$(INTDIR)\imap.obj"
-
-"$(OUTDIR)\php3_imap4r2.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "imap4 - Win32 Debug"
-
-OUTDIR=.\module_Debug
-INTDIR=.\module_Debug
-# Begin Custom Macros
-OutDir=.\module_Debug
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_imap4r1.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\imap.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(INTDIR)\vc60.pdb"
- -@erase "$(OUTDIR)\php3_imap4r1.dll"
- -@erase "$(OUTDIR)\php3_imap4r1.exp"
- -@erase "$(OUTDIR)\php3_imap4r1.ilk"
- -@erase "$(OUTDIR)\php3_imap4r1.lib"
- -@erase "$(OUTDIR)\php3_imap4r1.pdb"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "./" /I "../" /I "../../include" /D HAVE_IMAP=1 /D "DEBUG" /D "_DEBUG" /D "MSVC5" /D "THREAD_SAFE" /D "COMPILE_DL" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\imap4.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\imap4.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=cclient.lib php.lib wsock32.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:yes /pdb:"$(OUTDIR)\php3_imap4r1.pdb" /debug /machine:I386 /out:"$(OUTDIR)\php3_imap4r1.dll" /implib:"$(OUTDIR)\php3_imap4r1.lib" /pdbtype:sept /libpath:"..\..\lib" /libpath:"cgi_debug"
-LINK32_OBJS= \
- "$(INTDIR)\imap.obj"
-
-"$(OUTDIR)\php3_imap4r1.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF
-
-
-!IF "$(NO_EXTERNAL_DEPS)" != "1"
-!IF EXISTS("imap4.dep")
-!INCLUDE "imap4.dep"
-!ELSE
-!MESSAGE Warning: cannot find "imap4.dep"
-!ENDIF
-!ENDIF
-
-
-!IF "$(CFG)" == "imap4 - Win32 Release" || "$(CFG)" == "imap4 - Win32 Debug"
-SOURCE=.\functions\imap.c
-
-"$(INTDIR)\imap.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-
-!ENDIF
-
diff --git a/install-sh b/install-sh
deleted file mode 100644
index 89fc9b098b..0000000000
--- a/install-sh
+++ /dev/null
@@ -1,238 +0,0 @@
-#! /bin/sh
-#
-# install - install a program, script, or datafile
-# This comes from X11R5.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-#
-
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-tranformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd="$stripprog"
- shift
- continue;;
-
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
-
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
-
- *) if [ x"$src" = x ]
- then
- src=$1
- else
- # this colon is to work around a 386BSD /bin/sh bug
- :
- dst=$1
- fi
- shift
- continue;;
- esac
-done
-
-if [ x"$src" = x ]
-then
- echo "install: no input file specified"
- exit 1
-else
- true
-fi
-
-if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- else
- instcmd=mkdir
- fi
-else
-
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
-# if $src (and thus $dsttmp) contains '*'.
-
- if [ -f $src -o -d $src ]
- then
- true
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- true
- fi
-
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
-
- if [ -d $dst ]
- then
- dst="$dst"/`basename $src`
- else
- true
- fi
-fi
-
-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
-
-# Make sure that the destination directory exists.
-# this part is taken from Noah Friedman's mkinstalldirs script
-
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='
-'
-IFS="${IFS-${defaultIFS}}"
-
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
-
-pathcomp=''
-
-while [ $# -ne 0 ] ; do
- pathcomp="${pathcomp}${1}"
- shift
-
- if [ ! -d "${pathcomp}" ] ;
- then
- $mkdirprog "${pathcomp}"
- else
- true
- fi
-
- pathcomp="${pathcomp}/"
-done
-fi
-
-if [ x"$dir_arg" != x ]
-then
- $doit $instcmd $dst &&
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
-else
-
-# If we're going to rename the final executable, determine the name now.
-
- if [ x"$transformarg" = x ]
- then
- dstfile=`basename $dst`
- else
- dstfile=`basename $dst $transformbasename |
- sed $transformarg`$transformbasename
- fi
-
-# don't allow the sed command to completely eliminate the filename
-
- if [ x"$dstfile" = x ]
- then
- dstfile=`basename $dst`
- else
- true
- fi
-
-# Make a temp file name in the proper directory.
-
- dsttmp=$dstdir/#inst.$$#
-
-# Move or copy the file name to the temp name
-
- $doit $instcmd $src $dsttmp &&
-
- trap "rm -f ${dsttmp}" 0 &&
-
-# and set any options; do chmod last to preserve setuid bits
-
-# If any of these fail, we abort the whole thing. If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
-
-# Now rename the file to the real destination.
-
- $doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
-
-fi &&
-
-
-exit 0
diff --git a/ldap.mak b/ldap.mak
deleted file mode 100644
index 5fd1e85e17..0000000000
--- a/ldap.mak
+++ /dev/null
@@ -1,194 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on ldap.dsp
-!IF "$(CFG)" == ""
-CFG=ldap - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to ldap - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "ldap - Win32 Release" && "$(CFG)" != "ldap - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "ldap.mak" CFG="ldap - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "ldap - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "ldap - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-!IF "$(CFG)" == "ldap - Win32 Release"
-
-OUTDIR=.\module_Release
-INTDIR=.\module_Release
-# Begin Custom Macros
-OutDir=.\module_Release
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_ldap.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\ldap.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(OUTDIR)\php3_ldap.dll"
- -@erase "$(OUTDIR)\php3_ldap.exp"
- -@erase "$(OUTDIR)\php3_ldap.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "./" /I "../" /I "../../include" /D HAVE_LDAP=1 /D HAVE_NSLDAP=1 /D "NDEBUG" /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\ldap.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\ldap.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib nsldap32v30.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\php3_ldap.pdb" /machine:I386 /out:"$(OUTDIR)\php3_ldap.dll" /implib:"$(OUTDIR)\php3_ldap.lib" /libpath:"..\..\lib" /libpath:"cgi_release"
-LINK32_OBJS= \
- "$(INTDIR)\ldap.obj"
-
-"$(OUTDIR)\php3_ldap.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "ldap - Win32 Debug"
-
-OUTDIR=.\module_Debug
-INTDIR=.\module_Debug
-# Begin Custom Macros
-OutDir=.\module_Debug
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_ldap.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\ldap.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(INTDIR)\vc60.pdb"
- -@erase "$(OUTDIR)\php3_ldap.dll"
- -@erase "$(OUTDIR)\php3_ldap.exp"
- -@erase "$(OUTDIR)\php3_ldap.ilk"
- -@erase "$(OUTDIR)\php3_ldap.lib"
- -@erase "$(OUTDIR)\php3_ldap.pdb"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "./" /I "../" /I "../../include" /D HAVE_LDAP=1 /D HAVE_NSLDAP=1 /D "_DEBUG" /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\ldap.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\ldap.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib nsldap32v30.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:yes /pdb:"$(OUTDIR)\php3_ldap.pdb" /debug /machine:I386 /out:"$(OUTDIR)\php3_ldap.dll" /implib:"$(OUTDIR)\php3_ldap.lib" /pdbtype:sept /libpath:"..\..\lib" /libpath:"cgi_debug"
-LINK32_OBJS= \
- "$(INTDIR)\ldap.obj"
-
-"$(OUTDIR)\php3_ldap.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF
-
-
-!IF "$(NO_EXTERNAL_DEPS)" != "1"
-!IF EXISTS("ldap.dep")
-!INCLUDE "ldap.dep"
-!ELSE
-!MESSAGE Warning: cannot find "ldap.dep"
-!ENDIF
-!ENDIF
-
-
-!IF "$(CFG)" == "ldap - Win32 Release" || "$(CFG)" == "ldap - Win32 Debug"
-SOURCE=.\functions\ldap.c
-
-"$(INTDIR)\ldap.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-
-!ENDIF
-
diff --git a/libphp4.module.in b/libphp4.module.in
deleted file mode 100644
index 9b80f6c742..0000000000
--- a/libphp4.module.in
+++ /dev/null
@@ -1,7 +0,0 @@
-Name: php4_module
-ConfigStart
- RULE_WANTHSREGEX=@HSREGEX@
- LIBS="@RPATHS@ @PHP_LIBS@ @EXTRA_LIBS@ @LIBS@ @RDYNAMIC_LFLAGS@ $LIBS"
- RULE_HIDE=yes
- CFLAGS="$CFLAGS -I@abs_srcdir@ -I@abs_srcdir@/libzend -I@abs_builddir@/libzend -I@abs_builddir@"
-ConfigEnd
diff --git a/main.h b/main.h
deleted file mode 100644
index 8ed815edbc..0000000000
--- a/main.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Andi Gutmans <andi@zend.com> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-
-#ifndef _MAIN_H
-#define _MAIN_H
-
-#include "zend_globals.h"
-#include "php_globals.h"
-#include "SAPI.h"
-
-PHPAPI int php_request_startup(CLS_D ELS_DC PLS_DC SLS_DC);
-PHPAPI void php_request_shutdown(void *dummy);
-PHPAPI void php_request_shutdown_for_exec(void *dummy);
-PHPAPI int php_module_startup(sapi_module_struct *sf);
-PHPAPI void php_module_shutdown();
-PHPAPI void php_module_shutdown_for_exec();
-PHPAPI int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals);
-
-PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_DC);
-
-extern void php3_call_shutdown_functions(void);
-
-
-/* configuration module */
-extern int php3_init_config(void);
-extern int php3_shutdown_config(void);
-
-/* environment module */
-extern int php3_init_environ(void);
-extern int php3_shutdown_environ(void);
-
-#endif
diff --git a/main/SAPI.c b/main/SAPI.c
deleted file mode 100644
index 3b94176b87..0000000000
--- a/main/SAPI.c
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Design: Shane Caraveo <shane@caraveo.com> |
- | Authors: Andi Gutmans <andi@zend.com> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
-*/
-
-#include <ctype.h>
-
-#include "php.h"
-#include "SAPI.h"
-#ifdef ZTS
-#include "TSRM.h"
-#endif
-
-#include "rfc1867.h"
-
-#if WIN32||WINNT
-#define STRCASECMP stricmp
-#else
-#define STRCASECMP strcasecmp
-#endif
-
-
-SAPI_POST_READER_FUNC(sapi_read_standard_form_data);
-
-#define DEFAULT_POST_CONTENT_TYPE "application/x-www-form-urlencoded"
-
-static sapi_post_content_type_reader supported_post_content_types[] = {
- { DEFAULT_POST_CONTENT_TYPE, sizeof(DEFAULT_POST_CONTENT_TYPE)-1, sapi_read_standard_form_data },
- { NULL, 0, NULL }
-};
-
-
-static HashTable known_post_content_types;
-
-SAPI_API void (*sapi_error)(int error_type, const char *message, ...);
-
-
-#ifdef ZTS
-SAPI_API int sapi_globals_id;
-#else
-sapi_globals_struct sapi_globals;
-#endif
-
-
-/* True globals (no need for thread safety) */
-sapi_module_struct sapi_module;
-SAPI_API void (*sapi_error)(int error_type, const char *message, ...);
-
-
-SAPI_API void sapi_startup(sapi_module_struct *sf)
-{
- sapi_module = *sf;
- zend_hash_init(&known_post_content_types, 5, NULL, NULL, 1);
-
- sapi_register_post_reader(supported_post_content_types);
-
-#ifdef ZTS
- sapi_globals_id = ts_allocate_id(sizeof(sapi_globals_struct), NULL, NULL);
-#endif
-
- module_global_startup_modules();
-}
-
-SAPI_API void sapi_shutdown()
-{
- module_global_shutdown_modules();
- zend_hash_destroy(&known_post_content_types);
-}
-
-
-static void sapi_free_header(sapi_header_struct *sapi_header)
-{
- efree(sapi_header->header);
-}
-
-
-static void sapi_read_post_data(SLS_D)
-{
- sapi_post_content_type_reader *post_content_type_reader;
- uint content_type_length = strlen(SG(request_info).content_type);
- char *content_type = estrndup(SG(request_info).content_type, content_type_length);
- char *p;
- char oldchar=0;
- void (*post_reader_func)(char *content_type_dup SLS_DC);
-
-
- /* dedicated implementation for increased performance:
- * - Make the content type lowercase
- * - Trim descriptive data, stay with the content-type only
- */
- for (p=content_type; p<content_type+content_type_length; p++) {
- switch (*p) {
- case ';':
- case ',':
- case ' ':
- content_type_length = p-content_type;
- oldchar = *p;
- *p = 0;
- break;
- default:
- *p = tolower(*p);
- break;
- }
- }
-
- if (zend_hash_find(&known_post_content_types, content_type, content_type_length+1, (void **) &post_content_type_reader)==SUCCESS) {
- post_reader_func = post_content_type_reader->post_reader;
- } else {
- if (!sapi_module.default_post_reader) {
- sapi_module.sapi_error(E_COMPILE_ERROR, "Unsupported content type: '%s'", content_type);
- return;
- }
- post_reader_func = sapi_module.default_post_reader;
- }
- if (oldchar) {
- *(p-1) = oldchar;
- }
- post_reader_func(content_type SLS_CC);
- efree(content_type);
-}
-
-
-SAPI_POST_READER_FUNC(sapi_read_standard_form_data)
-{
- int read_bytes, total_read_bytes=0;
- int allocated_bytes=SAPI_POST_BLOCK_SIZE+1;
-
- SG(request_info).post_data = emalloc(allocated_bytes);
-
- for (;;) {
- read_bytes = sapi_module.read_post(SG(request_info).post_data+total_read_bytes, SAPI_POST_BLOCK_SIZE SLS_CC);
- if (read_bytes<=0) {
- break;
- }
- total_read_bytes += read_bytes;
- if (read_bytes < SAPI_POST_BLOCK_SIZE) {
- break;
- }
- if (total_read_bytes+SAPI_POST_BLOCK_SIZE >= allocated_bytes) {
- allocated_bytes = total_read_bytes+SAPI_POST_BLOCK_SIZE+1;
- SG(request_info).post_data = erealloc(SG(request_info).post_data, allocated_bytes);
- }
- }
- SG(request_info).post_data[total_read_bytes] = 0; /* terminating NULL */
- SG(request_info).post_data_length = total_read_bytes;
-}
-
-
-SAPI_API void sapi_activate(SLS_D)
-{
- zend_llist_init(&SG(sapi_headers).headers, sizeof(sapi_header_struct), (void (*)(void *)) sapi_free_header, 0);
- SG(sapi_headers).send_default_content_type = 1;
- SG(sapi_headers).http_response_code = 200;
- SG(sapi_headers).http_status_line = NULL;
- SG(headers_sent) = 0;
- SG(read_post_bytes) = 0;
- SG(request_info).post_data = NULL;
-
- if (SG(request_info).request_method && !strcmp(SG(request_info).request_method, "HEAD")) {
- SG(request_info).headers_only = 1;
- } else {
- SG(request_info).headers_only = 0;
- }
-
- if (SG(server_context)) {
- if (SG(request_info).request_method
- && !strcmp(SG(request_info).request_method, "POST")) {
- if (!SG(request_info).content_type) {
- sapi_module.sapi_error(E_COMPILE_ERROR, "No content-type in POST request");
- }
- sapi_read_post_data(SLS_C);
- }
- SG(request_info).cookie_data = sapi_module.read_cookies(SLS_C);
- }
-}
-
-
-SAPI_API void sapi_deactivate(SLS_D)
-{
- zend_llist_destroy(&SG(sapi_headers).headers);
- if (SG(request_info).post_data) {
- efree(SG(request_info).post_data);
- }
-}
-
-
-/* This function expects a *duplicated* string, that was previously emalloc()'d.
- * Pointers sent to this functions will be automatically freed by the framework.
- */
-SAPI_API int sapi_add_header(char *header_line, uint header_line_len)
-{
- int retval;
- sapi_header_struct sapi_header;
- char *colon_offset;
- SLS_FETCH();
-
- if (SG(headers_sent)) {
- sapi_module.sapi_error(E_WARNING, "Cannot add header information - headers already sent");
- efree(header_line);
- return FAILURE;
- }
-
- sapi_header.header = header_line;
- sapi_header.header_len = header_line_len;
-
- /* Check the header for a few cases that we have special support for in SAPI */
- if (header_line_len>=5
- && !memcmp(header_line, "HTTP/", 5)) {
- SG(sapi_headers).http_status_line = header_line;
- return SUCCESS;
- } else {
- colon_offset = strchr(header_line, ':');
- if (colon_offset) {
- *colon_offset = 0;
- if (!STRCASECMP(header_line, "Content-Type")) {
- SG(sapi_headers).send_default_content_type = 0;
- } else if (!STRCASECMP(header_line, "Location")) {
- SG(sapi_headers).http_response_code = 302; /* redirect */
- } else if (!STRCASECMP(header_line, "WWW-Authenticate")) { /* HTTP Authentication */
- SG(sapi_headers).http_response_code = 401; /* authentication-required */
- }
- *colon_offset = ':';
- }
- }
-
- if (sapi_module.header_handler) {
- retval = sapi_module.header_handler(&sapi_header, &SG(sapi_headers) SLS_CC);
- } else {
- retval = SAPI_HEADER_ADD;
- }
- if (retval & SAPI_HEADER_DELETE_ALL) {
- zend_llist_clean(&SG(sapi_headers).headers);
- }
- if (retval & SAPI_HEADER_ADD) {
- zend_llist_add_element(&SG(sapi_headers).headers, (void *) &sapi_header);
- }
- return SUCCESS;
-}
-
-
-SAPI_API int sapi_send_headers()
-{
- int retval;
- sapi_header_struct default_header = { SAPI_DEFAULT_CONTENT_TYPE, sizeof(SAPI_DEFAULT_CONTENT_TYPE)-1 };
- SLS_FETCH();
-
- if (SG(headers_sent)) {
- return SUCCESS;
- }
-
- if (sapi_module.send_headers) {
- retval = sapi_module.send_headers(&SG(sapi_headers) SLS_CC);
- } else {
- retval = SAPI_HEADER_DO_SEND;
- }
-
- switch (retval) {
- case SAPI_HEADER_SENT_SUCCESSFULLY:
- SG(headers_sent) = 1;
- return SUCCESS;
- break;
- case SAPI_HEADER_DO_SEND:
- if (SG(sapi_headers).http_status_line) {
- sapi_header_struct http_status_line;
-
- http_status_line.header = SG(sapi_headers).http_status_line;
- http_status_line.header_len = strlen(SG(sapi_headers).http_status_line);
- sapi_module.send_header(&http_status_line, SG(server_context));
- efree(SG(sapi_headers).http_status_line);
- }
- if (SG(sapi_headers).send_default_content_type) {
- sapi_module.send_header(&default_header, SG(server_context));
- }
- zend_llist_apply_with_argument(&SG(sapi_headers).headers, (void (*)(void *, void *)) sapi_module.send_header, SG(server_context));
- sapi_module.send_header(NULL, SG(server_context));
- SG(headers_sent) = 1;
- return SUCCESS;
- break;
- case SAPI_HEADER_SEND_FAILED:
- return FAILURE;
- break;
- }
- return FAILURE;
-}
-
-
-SAPI_API int sapi_register_post_readers(sapi_post_content_type_reader *post_content_type_readers)
-{
- sapi_post_content_type_reader *p=post_content_type_readers;
-
- while (p->content_type) {
- if (sapi_register_post_reader(p)==FAILURE) {
- return FAILURE;
- }
- p++;
- }
- return SUCCESS;
-}
-
-
-SAPI_API int sapi_register_post_reader(sapi_post_content_type_reader *post_content_type_reader)
-{
- return zend_hash_add(&known_post_content_types, post_content_type_reader->content_type, post_content_type_reader->content_type_len+1, (void *) post_content_type_reader, sizeof(sapi_post_content_type_reader), NULL);
-}
-
-
-SAPI_API void sapi_unregister_post_reader(sapi_post_content_type_reader *post_content_type_reader)
-{
- zend_hash_del(&known_post_content_types, post_content_type_reader->content_type, post_content_type_reader->content_type_len+1);
-}
-
-
-SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(char *content_type_dup SLS_DC))
-{
- sapi_module.default_post_reader = default_post_reader;
- return SUCCESS;
-}
-
diff --git a/main/SAPI.h b/main/SAPI.h
deleted file mode 100644
index 0433cca55b..0000000000
--- a/main/SAPI.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
-*/
-
-
-#ifndef _NEW_SAPI_H
-#define _NEW_SAPI_H
-
-#include "zend.h"
-#include "zend_llist.h"
-#include "zend_operators.h"
-
-#define SAPI_POST_BLOCK_SIZE 4000
-
-#if WIN32||WINNT
-# ifdef SAPI_EXPORTS
-# define SAPI_API __declspec(dllexport)
-# else
-# define SAPI_API __declspec(dllimport)
-# endif
-#else
-#define SAPI_API
-#endif
-
-
-typedef struct {
- char *header;
- uint header_len;
-} sapi_header_struct;
-
-
-typedef struct {
- zend_llist headers;
- int http_response_code;
- unsigned char send_default_content_type;
- char *http_status_line;
-} sapi_headers_struct;
-
-
-typedef struct _sapi_module_struct sapi_module_struct;
-
-
-extern sapi_module_struct sapi_module; /* true global */
-
-
-typedef struct {
- char *request_method;
- char *query_string;
- char *post_data;
- char *cookie_data;
- uint content_length;
- uint post_data_length;
-
- char *path_translated;
- char *request_uri;
-
- char *content_type;
-
- unsigned char headers_only;
-
- /* for HTTP authentication */
- char *auth_user;
- char *auth_password;
-} sapi_request_info;
-
-
-typedef struct {
- void *server_context;
- sapi_request_info request_info;
- sapi_headers_struct sapi_headers;
- uint read_post_bytes;
- unsigned char headers_sent;
-} sapi_globals_struct;
-
-
-#ifdef ZTS
-# define SLS_D sapi_globals_struct *sapi_globals
-# define SLS_DC , SLS_D
-# define SLS_C sapi_globals
-# define SLS_CC , SLS_C
-# define SG(v) (sapi_globals->v)
-# define SLS_FETCH() sapi_globals_struct *sapi_globals = ts_resource(sapi_globals_id)
-SAPI_API extern int sapi_globals_id;
-#else
-# define SLS_D
-# define SLS_DC
-# define SLS_C
-# define SLS_CC
-# define SG(v) (sapi_globals.v)
-# define SLS_FETCH()
-extern SAPI_API sapi_globals_struct sapi_globals;
-#endif
-
-typedef struct _sapi_post_content_type_reader {
- char *content_type;
- uint content_type_len;
- void (*post_reader)(char *content_type_dup SLS_DC);
-} sapi_post_content_type_reader;
-
-
-SAPI_API void sapi_startup(sapi_module_struct *sf);
-SAPI_API void sapi_activate(SLS_D);
-SAPI_API void sapi_deactivate(SLS_D);
-
-SAPI_API int sapi_add_header(char *header_line, uint header_line_len);
-SAPI_API int sapi_send_headers();
-
-SAPI_API int sapi_register_post_readers(sapi_post_content_type_reader *post_content_type_readers);
-SAPI_API int sapi_register_post_reader(sapi_post_content_type_reader *post_content_type_reader);
-SAPI_API void sapi_unregister_post_reader(sapi_post_content_type_reader *post_content_type_reader);
-SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(char *content_type_dup SLS_DC));
-
-struct _sapi_module_struct {
- char *name;
-
- int (*startup)(struct _sapi_module_struct *sapi_module);
- int (*shutdown)(struct _sapi_module_struct *sapi_module);
-
- int (*ub_write)(const char *str, unsigned int str_length);
-
- void (*sapi_error)(int type, const char *error_msg, ...);
-
- int (*header_handler)(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC);
- int (*send_headers)(sapi_headers_struct *sapi_headers SLS_DC);
- void (*send_header)(sapi_header_struct *sapi_header, void *server_context);
-
- int (*read_post)(char *buffer, uint count_bytes SLS_DC);
- char *(*read_cookies)(SLS_D);
-
- void (*default_post_reader)(char *content_type_dup SLS_DC);
-};
-
-
-/* header_handler() constants */
-#define SAPI_HEADER_ADD (1<<0)
-#define SAPI_HEADER_DELETE_ALL (1<<1)
-#define SAPI_HEADER_SEND_NOW (1<<2)
-
-
-#define SAPI_HEADER_SENT_SUCCESSFULLY 1
-#define SAPI_HEADER_DO_SEND 2
-#define SAPI_HEADER_SEND_FAILED 3
-
-#define SAPI_DEFAULT_CONTENT_TYPE "Content-Type: text/html"
-#define SAPI_PHP_VERSION_HEADER "X-Powered-By: PHP/" PHP_VERSION
-
-#define SAPI_POST_READER_FUNC(post_reader) void post_reader(char *content_type_dup SLS_DC)
-
-SAPI_POST_READER_FUNC(sapi_read_standard_form_data);
-
-#define STANDARD_SAPI_MODULE_PROPERTIES NULL
-
-#endif /* _NEW_SAPI_H */
diff --git a/main/alloca.c b/main/alloca.c
deleted file mode 100644
index 7c6cd4f192..0000000000
--- a/main/alloca.c
+++ /dev/null
@@ -1,490 +0,0 @@
-/* alloca.c -- allocate automatically reclaimed memory
- (Mostly) portable public-domain implementation -- D A Gwyn
-
- This implementation of the PWB library alloca function,
- which is used to allocate space off the run-time stack so
- that it is automatically reclaimed upon procedure exit,
- was inspired by discussions with J. Q. Johnson of Cornell.
- J.Otto Tennant <jot@cray.com> contributed the Cray support.
-
- There are some preprocessor constants that can
- be defined when compiling for your specific system, for
- improved efficiency; however, the defaults should be okay.
-
- The general concept of this implementation is to keep
- track of all alloca-allocated blocks, and reclaim any
- that are found to be deeper in the stack than the current
- invocation. This heuristic does not reclaim storage as
- soon as it becomes invalid, but it will do so eventually.
-
- As a special case, alloca(0) reclaims storage without
- allocating any. It is a good idea to use alloca(0) in
- your main control loop, etc. to force garbage collection. */
-
-#include "php_config.h"
-
-#if !HAVE_ALLOCA
-
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
-#ifdef emacs
-#include "blockinput.h"
-#endif
-
-/* If compiling with GCC 2, this file's not needed. */
-#if !defined (__GNUC__) || __GNUC__ < 2
-
-/* If someone has defined alloca as a macro,
- there must be some other way alloca is supposed to work. */
-#ifndef alloca
-
-#ifdef emacs
-#ifdef static
-/* actually, only want this if static is defined as ""
- -- this is for usg, in which emacs must undefine static
- in order to make unexec workable
- */
-#ifndef STACK_DIRECTION
-you
-lose
--- must know STACK_DIRECTION at compile-time
-#endif /* STACK_DIRECTION undefined */
-#endif /* static */
-#endif /* emacs */
-
-/* If your stack is a linked list of frames, you have to
- provide an "address metric" ADDRESS_FUNCTION macro. */
-
-#if defined (CRAY) && defined (CRAY_STACKSEG_END)
-long i00afunc ();
-#define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
-#else
-#define ADDRESS_FUNCTION(arg) &(arg)
-#endif
-
-#if __STDC__
-typedef void *pointer;
-#else
-typedef char *pointer;
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-/* Define STACK_DIRECTION if you know the direction of stack
- growth for your system; otherwise it will be automatically
- deduced at run-time.
-
- STACK_DIRECTION > 0 => grows toward higher addresses
- STACK_DIRECTION < 0 => grows toward lower addresses
- STACK_DIRECTION = 0 => direction of growth unknown */
-
-#ifndef STACK_DIRECTION
-#define STACK_DIRECTION 0 /* Direction unknown. */
-#endif
-
-#if STACK_DIRECTION != 0
-
-#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */
-
-#else /* STACK_DIRECTION == 0; need run-time code. */
-
-static int stack_dir; /* 1 or -1 once known. */
-#define STACK_DIR stack_dir
-
-static void
-find_stack_direction ()
-{
- static char *addr = NULL; /* Address of first `dummy', once known. */
- auto char dummy; /* To get stack address. */
-
- if (addr == NULL)
- { /* Initial entry. */
- addr = ADDRESS_FUNCTION (dummy);
-
- find_stack_direction (); /* Recurse once. */
- }
- else
- {
- /* Second entry. */
- if (ADDRESS_FUNCTION (dummy) > addr)
- stack_dir = 1; /* Stack grew upward. */
- else
- stack_dir = -1; /* Stack grew downward. */
- }
-}
-
-#endif /* STACK_DIRECTION == 0 */
-
-/* An "alloca header" is used to:
- (a) chain together all alloca'ed blocks;
- (b) keep track of stack depth.
-
- It is very important that sizeof(header) agree with malloc
- alignment chunk size. The following default should work okay. */
-
-#ifndef ALIGN_SIZE
-#define ALIGN_SIZE sizeof(double)
-#endif
-
-typedef union hdr
-{
- char align[ALIGN_SIZE]; /* To force sizeof(header). */
- struct
- {
- union hdr *next; /* For chaining headers. */
- char *deep; /* For stack depth measure. */
- } h;
-} header;
-
-static header *last_alloca_header = NULL; /* -> last alloca header. */
-
-/* Return a pointer to at least SIZE bytes of storage,
- which will be automatically reclaimed upon exit from
- the procedure that called alloca. Originally, this space
- was supposed to be taken from the current stack frame of the
- caller, but that method cannot be made to work for some
- implementations of C, for example under Gould's UTX/32. */
-
-pointer
-alloca (size)
- size_t size;
-{
- auto char probe; /* Probes stack depth: */
- register char *depth = ADDRESS_FUNCTION (probe);
-
-#if STACK_DIRECTION == 0
- if (STACK_DIR == 0) /* Unknown growth direction. */
- find_stack_direction ();
-#endif
-
- /* Reclaim garbage, defined as all alloca'd storage that
- was allocated from deeper in the stack than currently. */
-
- {
- register header *hp; /* Traverses linked list. */
-
-#ifdef emacs
- BLOCK_INPUT;
-#endif
-
- for (hp = last_alloca_header; hp != NULL;)
- if ((STACK_DIR > 0 && hp->h.deep > depth)
- || (STACK_DIR < 0 && hp->h.deep < depth))
- {
- register header *np = hp->h.next;
-
- free ((pointer) hp); /* Collect garbage. */
-
- hp = np; /* -> next header. */
- }
- else
- break; /* Rest are not deeper. */
-
- last_alloca_header = hp; /* -> last valid storage. */
-
-#ifdef emacs
- UNBLOCK_INPUT;
-#endif
- }
-
- if (size == 0)
- return NULL; /* No allocation required. */
-
- /* Allocate combined header + user data storage. */
-
- {
- register pointer new = malloc (sizeof (header) + size);
- /* Address of header. */
-
- if (new == 0)
- abort();
-
- ((header *) new)->h.next = last_alloca_header;
- ((header *) new)->h.deep = depth;
-
- last_alloca_header = (header *) new;
-
- /* User storage begins just after header. */
-
- return (pointer) ((char *) new + sizeof (header));
- }
-}
-
-#if defined (CRAY) && defined (CRAY_STACKSEG_END)
-
-#ifdef DEBUG_I00AFUNC
-#include <stdio.h>
-#endif
-
-#ifndef CRAY_STACK
-#define CRAY_STACK
-#ifndef CRAY2
-/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */
-struct stack_control_header
- {
- long shgrow:32; /* Number of times stack has grown. */
- long shaseg:32; /* Size of increments to stack. */
- long shhwm:32; /* High water mark of stack. */
- long shsize:32; /* Current size of stack (all segments). */
- };
-
-/* The stack segment linkage control information occurs at
- the high-address end of a stack segment. (The stack
- grows from low addresses to high addresses.) The initial
- part of the stack segment linkage control information is
- 0200 (octal) words. This provides for register storage
- for the routine which overflows the stack. */
-
-struct stack_segment_linkage
- {
- long ss[0200]; /* 0200 overflow words. */
- long sssize:32; /* Number of words in this segment. */
- long ssbase:32; /* Offset to stack base. */
- long:32;
- long sspseg:32; /* Offset to linkage control of previous
- segment of stack. */
- long:32;
- long sstcpt:32; /* Pointer to task common address block. */
- long sscsnm; /* Private control structure number for
- microtasking. */
- long ssusr1; /* Reserved for user. */
- long ssusr2; /* Reserved for user. */
- long sstpid; /* Process ID for pid based multi-tasking. */
- long ssgvup; /* Pointer to multitasking thread giveup. */
- long sscray[7]; /* Reserved for Cray Research. */
- long ssa0;
- long ssa1;
- long ssa2;
- long ssa3;
- long ssa4;
- long ssa5;
- long ssa6;
- long ssa7;
- long sss0;
- long sss1;
- long sss2;
- long sss3;
- long sss4;
- long sss5;
- long sss6;
- long sss7;
- };
-
-#else /* CRAY2 */
-/* The following structure defines the vector of words
- returned by the STKSTAT library routine. */
-struct stk_stat
- {
- long now; /* Current total stack size. */
- long maxc; /* Amount of contiguous space which would
- be required to satisfy the maximum
- stack demand to date. */
- long high_water; /* Stack high-water mark. */
- long overflows; /* Number of stack overflow ($STKOFEN) calls. */
- long hits; /* Number of internal buffer hits. */
- long extends; /* Number of block extensions. */
- long stko_mallocs; /* Block allocations by $STKOFEN. */
- long underflows; /* Number of stack underflow calls ($STKRETN). */
- long stko_free; /* Number of deallocations by $STKRETN. */
- long stkm_free; /* Number of deallocations by $STKMRET. */
- long segments; /* Current number of stack segments. */
- long maxs; /* Maximum number of stack segments so far. */
- long pad_size; /* Stack pad size. */
- long current_address; /* Current stack segment address. */
- long current_size; /* Current stack segment size. This
- number is actually corrupted by STKSTAT to
- include the fifteen word trailer area. */
- long initial_address; /* Address of initial segment. */
- long initial_size; /* Size of initial segment. */
- };
-
-/* The following structure describes the data structure which trails
- any stack segment. I think that the description in 'asdef' is
- out of date. I only describe the parts that I am sure about. */
-
-struct stk_trailer
- {
- long this_address; /* Address of this block. */
- long this_size; /* Size of this block (does not include
- this trailer). */
- long unknown2;
- long unknown3;
- long link; /* Address of trailer block of previous
- segment. */
- long unknown5;
- long unknown6;
- long unknown7;
- long unknown8;
- long unknown9;
- long unknown10;
- long unknown11;
- long unknown12;
- long unknown13;
- long unknown14;
- };
-
-#endif /* CRAY2 */
-#endif /* not CRAY_STACK */
-
-#ifdef CRAY2
-/* Determine a "stack measure" for an arbitrary ADDRESS.
- I doubt that "lint" will like this much. */
-
-static long
-i00afunc (long *address)
-{
- struct stk_stat status;
- struct stk_trailer *trailer;
- long *block, size;
- long result = 0;
-
- /* We want to iterate through all of the segments. The first
- step is to get the stack status structure. We could do this
- more quickly and more directly, perhaps, by referencing the
- $LM00 common block, but I know that this works. */
-
- STKSTAT (&status);
-
- /* Set up the iteration. */
-
- trailer = (struct stk_trailer *) (status.current_address
- + status.current_size
- - 15);
-
- /* There must be at least one stack segment. Therefore it is
- a fatal error if "trailer" is null. */
-
- if (trailer == 0)
- abort ();
-
- /* Discard segments that do not contain our argument address. */
-
- while (trailer != 0)
- {
- block = (long *) trailer->this_address;
- size = trailer->this_size;
- if (block == 0 || size == 0)
- abort ();
- trailer = (struct stk_trailer *) trailer->link;
- if ((block <= address) && (address < (block + size)))
- break;
- }
-
- /* Set the result to the offset in this segment and add the sizes
- of all predecessor segments. */
-
- result = address - block;
-
- if (trailer == 0)
- {
- return result;
- }
-
- do
- {
- if (trailer->this_size <= 0)
- abort ();
- result += trailer->this_size;
- trailer = (struct stk_trailer *) trailer->link;
- }
- while (trailer != 0);
-
- /* We are done. Note that if you present a bogus address (one
- not in any segment), you will get a different number back, formed
- from subtracting the address of the first block. This is probably
- not what you want. */
-
- return (result);
-}
-
-#else /* not CRAY2 */
-/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
- Determine the number of the cell within the stack,
- given the address of the cell. The purpose of this
- routine is to linearize, in some sense, stack addresses
- for alloca. */
-
-static long
-i00afunc (long address)
-{
- long stkl = 0;
-
- long size, pseg, this_segment, stack;
- long result = 0;
-
- struct stack_segment_linkage *ssptr;
-
- /* Register B67 contains the address of the end of the
- current stack segment. If you (as a subprogram) store
- your registers on the stack and find that you are past
- the contents of B67, you have overflowed the segment.
-
- B67 also points to the stack segment linkage control
- area, which is what we are really interested in. */
-
- stkl = CRAY_STACKSEG_END ();
- ssptr = (struct stack_segment_linkage *) stkl;
-
- /* If one subtracts 'size' from the end of the segment,
- one has the address of the first word of the segment.
-
- If this is not the first segment, 'pseg' will be
- nonzero. */
-
- pseg = ssptr->sspseg;
- size = ssptr->sssize;
-
- this_segment = stkl - size;
-
- /* It is possible that calling this routine itself caused
- a stack overflow. Discard stack segments which do not
- contain the target address. */
-
- while (!(this_segment <= address && address <= stkl))
- {
-#ifdef DEBUG_I00AFUNC
- fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl);
-#endif
- if (pseg == 0)
- break;
- stkl = stkl - pseg;
- ssptr = (struct stack_segment_linkage *) stkl;
- size = ssptr->sssize;
- pseg = ssptr->sspseg;
- this_segment = stkl - size;
- }
-
- result = address - this_segment;
-
- /* If you subtract pseg from the current end of the stack,
- you get the address of the previous stack segment's end.
- This seems a little convoluted to me, but I'll bet you save
- a cycle somewhere. */
-
- while (pseg != 0)
- {
-#ifdef DEBUG_I00AFUNC
- fprintf (stderr, "%011o %011o\n", pseg, size);
-#endif
- stkl = stkl - pseg;
- ssptr = (struct stack_segment_linkage *) stkl;
- size = ssptr->sssize;
- pseg = ssptr->sspseg;
- result += size;
- }
- return (result);
-}
-
-#endif /* not CRAY2 */
-#endif /* CRAY */
-
-#endif /* no alloca */
-#endif /* not GCC version 2 */
-#endif /* HAVE_ALLOCA */
diff --git a/main/config.w32.h b/main/config.w32.h
deleted file mode 100644
index 4160aa6c65..0000000000
--- a/main/config.w32.h
+++ /dev/null
@@ -1,313 +0,0 @@
-/* config.w32.h. Configure file for win32 platforms */
-/* tested only with MS Visual C++ V5 */
-
-
-/* if you have resolv.lib and lib44bsd95.lib you can compile the extra
- dns functions located in dns.c. Set this to 1. add resolv.lib and
- lib33bsd95.lib to the project settings, and add the path to the
- bind include directory to the preprocessor settings. These libs
- are availabe in the ntbind distribution */
-#define HAVE_BINDLIB 1
-
-/* set to enable bcmath */
-#define WITH_BCMATH 1
-
-/* set to enable bundled PCRE library */
-#define HAVE_BUNDLED_PCRE 1
-
-/* should be added to runtime config*/
-#define PHP3_URL_FOPEN 1
-
-#define STDIN_FILENO 0
-#define STDOUT_FILENO 1
-#define STDERR_FILENO 2
-
-/* ----------------------------------------------------------------
- The following are defaults for run-time configuration
- ---------------------------------------------------------------*/
-
-#define PHP_SAFE_MODE 0
-#define MAGIC_QUOTES 0
-/* This is the default configuration file to read */
-#define CONFIGURATION_FILE_PATH "php.ini"
-#define USE_CONFIG_FILE 1
-
-/* Undefine if you want stricter XML/SGML compliance by default */
-/* this disables "<?expression?>" and "<?=expression?>" */
-#define DEFAULT_SHORT_OPEN_TAG 1
-
-#define PHP_TRACK_VARS 1
-
-/* ----------------------------------------------------------------
- The following defines are for those modules which require
- external libraries to compile. These will be removed from
- here in a future beta, as these modules will be moved out to dll's
- ---------------------------------------------------------------*/
-#if !defined(COMPILE_DL)
-#define HAVE_SNMP 0
-# define HAVE_ERRMSG_H 0 /*needed for mysql 3.21.17 and up*/
-#define HAVE_LDAP 0
-#define DBASE 0
-#define NDBM 0
-#define GDBM 0
-#define BSD2 0
-#define HAVE_CRYPT 0
-#define HAVE_ORACLE 0
-#define HAVE_ADABAS 0
-#define HAVE_SOLID 0
-#define HAVE_MSQL 0
-#define HAVE_PGSQL 0
-#define HAVE_SYBASE 0
-#define HAVE_LIBGD 0
-#define HAVE_FILEPRO 0
-#define HAVE_ZLIB 0
-#endif
-/* ----------------------------------------------------------------
- The following may or may not be (or need to be) ported to the
- windows environment.
- ---------------------------------------------------------------*/
-
-/* Define if you have the link function. */
-#undef HAVE_LINK
-
-/* Define if you have the lockf function. */
-/* #undef HAVE_LOCKF */
-
-/* Define if you have the lrand48 function. */
-/* #undef HAVE_LRAND48 */
-
-/* Define if you have the srand48 function. */
-/* #undef HAVE_SRAND48 */
-
-/* Define if you have the symlink function. */
-#undef HAVE_SYMLINK
-
-/* Define if you have the usleep function. */
-#undef HAVE_USLEEP
-
-#define NEED_ISBLANK 1
-/* ----------------------------------------------------------------
- The following may be changed and played with right now, but
- will move to the "don't touch" list below eventualy.
- ---------------------------------------------------------------*/
-
-/*#define APACHE 0 defined in preprocessor section*/
-
-
-/* ----------------------------------------------------------------
- The following should never need to be played with
- Functions defined to 0 or remarked out are either already
- handled by the standard VC libraries, or are no longer needed, or
- simply will/can not be ported.
-
- DONT TOUCH!!!!! Unless you realy know what your messing with!
- ---------------------------------------------------------------*/
-
-#define DISCARD_PATH 1
-#undef HAVE_SETITIMER
-#define HAVE_IODBC 0 /*getting rid of old odbc*/
-#define HAVE_UODBC 0
-#define HAVE_LIBDL 1
-#define HAVE_SENDMAIL 1
-#define HAVE_GETTIMEOFDAY 1
-#define HAVE_PUTENV 1
-#define HAVE_LIMITS_H 1
-
-#define HAVE_TZSET 1
-/* Define if you have the flock function. */
-#undef HAVE_FLOCK
-
-/* Define if using alloca.c. */
-/* #undef C_ALLOCA */
-
-/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
- This function is required for alloca.c support on those systems. */
-/* #undef CRAY_STACKSEG_END */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef gid_t */
-
-/* Define if you have alloca, as a function or macro. */
-#define HAVE_ALLOCA 1
-
-/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
-/* #undef HAVE_ALLOCA_H */
-
-/* Define if you have <sys/time.h> */
-#undef HAVE_SYS_TIME_H
-
-/* Define if you have <signal.h> */
-#define HAVE_SIGNAL_H 1
-
-/* Define if you don't have vprintf but do have _doprnt. */
-/* #undef HAVE_DOPRNT */
-
-/* Define if your struct stat has st_blksize. */
-#undef HAVE_ST_BLKSIZE
-
-/* Define if your struct stat has st_blocks. */
-#undef HAVE_ST_BLOCKS
-
-/* Define if your struct stat has st_rdev. */
-#define HAVE_ST_RDEV 1
-
-/* Define if utime(file, NULL) sets file's timestamp to the present. */
-#define HAVE_UTIME_NULL 1
-
-/* Define if you have the vprintf function. */
-#define HAVE_VPRINTF 1
-
-/* Define to `unsigned' if <sys/types.h> doesn't define. */
-/* #undef size_t */
-
-/* If using the C implementation of alloca, define if you know the
- direction of stack growth for your system; otherwise it will be
- automatically deduced at run-time.
- STACK_DIRECTION > 0 => grows toward higher addresses
- STACK_DIRECTION < 0 => grows toward lower addresses
- STACK_DIRECTION = 0 => direction of growth unknown
- */
-/* #undef STACK_DIRECTION */
-
-/* Define if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define if your <sys/time.h> declares struct tm. */
-/* #undef TM_IN_SYS_TIME */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef uid_t */
-
-/* Define both of these if you want the bundled REGEX library */
-#define REGEX 1
-#define HSREGEX 1
-
-#define HAVE_PCRE 1
-
-/* Define if you have the gcvt function. */
-#define HAVE_GCVT 1
-
-/* Define if you have the getlogin function. */
-#define HAVE_GETLOGIN 1
-
-/* Define if you have the gettimeofday function. */
-#define HAVE_GETTIMEOFDAY 1
-
-/* Define if you have the memcpy function. */
-#define HAVE_MEMCPY 1
-
-/* Define if you have the strlcat function. */
-/* #undef HAVE_STRLCAT */
-
-/* Define if you have the strlcpy function. */
-/* #undef HAVE_STRLCPY */
-
-/* Define if you have the memmove function. */
-#define HAVE_MEMMOVE 1
-
-/* Define if you have the putenv function. */
-#define HAVE_PUTENV 1
-
-/* Define if you have the regcomp function. */
-#define HAVE_REGCOMP 1
-
-/* Define if you have the setlocale function. */
-#define HAVE_SETLOCALE 1
-
-#define HAVE_LOCALE_H 1
-
-/* Define if you have the setvbuf function. */
-#ifndef HAVE_BINDLIB
-#define HAVE_SETVBUF 1
-#endif
-
-/* Define if you have the snprintf function. */
-#define HAVE_SNPRINTF 1
-#define HAVE_VSNPRINTF 1
-/* Define if you have the strcasecmp function. */
-#define HAVE_STRCASECMP 1
-
-/* Define if you have the strdup function. */
-#define HAVE_STRDUP 1
-
-/* Define if you have the strerror function. */
-#define HAVE_STRERROR 1
-
-/* Define if you have the strstr function. */
-#define HAVE_STRSTR 1
-
-/* Define if you have the tempnam function. */
-#define HAVE_TEMPNAM 1
-
-/* Define if you have the utime function. */
-#define HAVE_UTIME 1
-
-/* Define if you have the <crypt.h> header file. */
-/* #undef HAVE_CRYPT_H */
-
-/* Define if you have the <dirent.h> header file. */
-#undef HAVE_DIRENT_H
-
-/* Define if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define if you have the <grp.h> header file. */
-#define HAVE_GRP_H 0
-
-/* Define if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define if you have the <ndir.h> header file. */
-/* #undef HAVE_NDIR_H */
-
-/* Define if you have the <pwd.h> header file. */
-#define HAVE_PWD_H 1
-
-/* Define if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define if you have the <sys/dir.h> header file. */
-/* #undef HAVE_SYS_DIR_H */
-
-/* Define if you have the <sys/file.h> header file. */
-#undef HAVE_SYS_FILE_H
-
-/* Define if you have the <sys/ndir.h> header file. */
-/* #undef HAVE_SYS_NDIR_H */
-
-/* Define if you have the <sys/socket.h> header file. */
-#undef HAVE_SYS_SOCKET_H
-
-/* Define if you have the <sys/wait.h> header file. */
-#undef HAVE_SYS_WAIT_H
-
-/* Define if you have the <syslog.h> header file. */
-#define HAVE_SYSLOG_H 1
-
-/* Define if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define if you have the crypt library (-lcrypt). */
-/* #undef HAVE_LIBCRYPT 0 */
-
-/* Define if you have the dl library (-ldl). */
-#define HAVE_LIBDL 1
-
-/* Define if you have the m library (-lm). */
-#define HAVE_LIBM 1
-
-/* Define if you have the nsl library (-lnsl). */
-/* #undef HAVE_LIBNSL */
-
-/* Define if you have the socket library (-lsocket). */
-/* #undef HAVE_LIBSOCKET */
-
-/* Define if you have the cuserid function. */
-#define HAVE_CUSERID 0
-
-/* Define if you have the rint function. */
-#undef HAVE_RINT
-
-#define HAVE_STRFTIME 1
-
-#define SIZEOF_INT 4
diff --git a/main/configuration-parser.y b/main/configuration-parser.y
deleted file mode 100644
index 4c41f7e10f..0000000000
--- a/main/configuration-parser.y
+++ /dev/null
@@ -1,438 +0,0 @@
-%{
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-
-
-/* $Id$ */
-
-#define DEBUG_CFG_PARSER 1
-#include "php.h"
-#include "php_globals.h"
-#include "php_ini.h"
-#include "ext/standard/dl.h"
-#include "ext/standard/file.h"
-#include "ext/standard/php3_browscap.h"
-#include "zend_extensions.h"
-
-#undef YYPARSE_PARAM
-#undef YYLEX_PARAM
-
-#if WIN32
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <winbase.h>
-#include "win32/wfile.h"
-#endif
-
-#undef YYSTYPE
-#define YYSTYPE pval
-
-#define PARSING_MODE_CFG 0
-#define PARSING_MODE_BROWSCAP 1
-
-static HashTable configuration_hash;
-#ifndef THREAD_SAFE
-extern HashTable browser_hash;
-PHPAPI extern char *php3_ini_path;
-#endif
-static HashTable *active_zend_hash_table;
-static pval *current_section;
-static char *currently_parsed_filename;
-
-static int parsing_mode;
-
-pval yylval;
-
-extern int cfglex(pval *cfglval);
-extern FILE *cfgin;
-extern int cfglineno;
-extern void init_cfg_scanner(void);
-
-pval *cfg_get_entry(char *name, uint name_length)
-{
- pval *tmp;
-
- if (zend_hash_find(&configuration_hash, name, name_length, (void **) &tmp)==SUCCESS) {
- return tmp;
- } else {
- return NULL;
- }
-}
-
-
-PHPAPI int cfg_get_long(char *varname,long *result)
-{
- pval *tmp,var;
-
- if (zend_hash_find(&configuration_hash,varname,strlen(varname)+1,(void **) &tmp)==FAILURE) {
- *result=(long)NULL;
- return FAILURE;
- }
- var = *tmp;
- pval_copy_constructor(&var);
- convert_to_long(&var);
- *result = var.value.lval;
- return SUCCESS;
-}
-
-
-PHPAPI int cfg_get_double(char *varname,double *result)
-{
- pval *tmp,var;
-
- if (zend_hash_find(&configuration_hash,varname,strlen(varname)+1,(void **) &tmp)==FAILURE) {
- *result=(double)0;
- return FAILURE;
- }
- var = *tmp;
- pval_copy_constructor(&var);
- convert_to_double(&var);
- *result = var.value.dval;
- return SUCCESS;
-}
-
-
-PHPAPI int cfg_get_string(char *varname, char **result)
-{
- pval *tmp;
-
- if (zend_hash_find(&configuration_hash,varname,strlen(varname)+1,(void **) &tmp)==FAILURE) {
- *result=NULL;
- return FAILURE;
- }
- *result = tmp->value.str.val;
- return SUCCESS;
-}
-
-
-static void yyerror(char *str)
-{
- fprintf(stderr,"PHP: Error parsing %s on line %d\n",currently_parsed_filename,cfglineno);
-}
-
-
-static int pvalue_config_destructor(pval *pvalue)
-{
- if (pvalue->type == IS_STRING && pvalue->value.str.val != empty_string) {
- free(pvalue->value.str.val);
- }
- return 1;
-}
-
-
-static int pvalue_browscap_destructor(pval *pvalue)
-{
- if (pvalue->type == IS_OBJECT || pvalue->type == IS_ARRAY) {
- zend_hash_destroy(pvalue->value.ht);
- free(pvalue->value.ht);
- }
- return 1;
-}
-
-
-int php3_init_config(void)
-{
- PLS_FETCH();
-
- if (zend_hash_init(&configuration_hash, 0, NULL, (int (*)(void *))pvalue_config_destructor, 1)==FAILURE) {
- return FAILURE;
- }
-
-#if USE_CONFIG_FILE
- {
- char *env_location,*default_location,*php_ini_path;
- int safe_mode_state = PG(safe_mode);
- char *open_basedir = PG(open_basedir);
- char *opened_path;
- int free_default_location=0;
-
- env_location = getenv("PHPRC");
- if (!env_location) {
- env_location="";
- }
-#if WIN32|WINNT
- {
- if (php3_ini_path) {
- default_location = php3_ini_path;
- } else {
- default_location = (char *) malloc(512);
-
- if (!GetWindowsDirectory(default_location,255)) {
- default_location[0]=0;
- }
- free_default_location=1;
- }
- }
-#else
- if (!php3_ini_path) {
- default_location = CONFIGURATION_FILE_PATH;
- } else {
- default_location = php3_ini_path;
- }
-#endif
-
-/* build a path */
- php_ini_path = (char *) malloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1);
-
- if (!php3_ini_path) {
-#if WIN32|WINNT
- sprintf(php_ini_path,".;%s;%s",env_location,default_location);
-#else
- sprintf(php_ini_path,".:%s:%s",env_location,default_location);
-#endif
- } else {
- /* if path was set via -c flag, only look there */
- strcpy(php_ini_path,default_location);
- }
- PG(safe_mode) = 0;
- PG(open_basedir) = NULL;
- cfgin = php3_fopen_with_path("php.ini","r",php_ini_path,&opened_path);
- free(php_ini_path);
- if (free_default_location) {
- free(default_location);
- }
- PG(safe_mode) = safe_mode_state;
- PG(open_basedir) = open_basedir;
-
- if (!cfgin) {
-# if WIN32|WINNT
- return FAILURE;
-# else
- return SUCCESS; /* having no configuration file is ok */
-# endif
- }
-
- if (opened_path) {
- pval tmp;
-
- tmp.value.str.val = opened_path;
- tmp.value.str.len = strlen(opened_path);
- tmp.type = IS_STRING;
- zend_hash_update(&configuration_hash,"cfg_file_path",sizeof("cfg_file_path"),(void *) &tmp,sizeof(pval),NULL);
-#if 0
- php_printf("INI file opened at '%s'\n",opened_path);
-#endif
- }
-
- init_cfg_scanner();
- active_zend_hash_table = &configuration_hash;
- parsing_mode = PARSING_MODE_CFG;
- currently_parsed_filename = "php.ini";
- yyparse();
- fclose(cfgin);
- }
-
-#endif
-
- return SUCCESS;
-}
-
-
-PHP_MINIT_FUNCTION(browscap)
-{
- char *browscap = INI_STR("browscap");
-
- if (browscap) {
- if (zend_hash_init(&browser_hash, 0, NULL, (int (*)(void *))pvalue_browscap_destructor, 1)==FAILURE) {
- return FAILURE;
- }
-
- cfgin = fopen(browscap, "r");
- if (!cfgin) {
- php_error(E_WARNING,"Cannot open '%s' for reading", browscap);
- return FAILURE;
- }
- init_cfg_scanner();
- active_zend_hash_table = &browser_hash;
- parsing_mode = PARSING_MODE_BROWSCAP;
- currently_parsed_filename = browscap;
- yyparse();
- fclose(cfgin);
- }
-
- return SUCCESS;
-}
-
-
-int php3_shutdown_config(void)
-{
- zend_hash_destroy(&configuration_hash);
- return SUCCESS;
-}
-
-
-PHP_MSHUTDOWN_FUNCTION(browscap)
-{
- if (INI_STR("browscap")) {
- zend_hash_destroy(&browser_hash);
- }
- return SUCCESS;
-}
-
-
-static void convert_browscap_pattern(pval *pattern)
-{
- register int i,j;
- char *t;
-
- for (i=0; i<pattern->value.str.len; i++) {
- if (pattern->value.str.val[i]=='*' || pattern->value.str.val[i]=='?') {
- break;
- }
- }
-
- if (i==pattern->value.str.len) { /* no wildcards */
- return;
- }
-
- t = (char *) malloc(pattern->value.str.len*2);
-
- for (i=0,j=0; i<pattern->value.str.len; i++,j++) {
- switch (pattern->value.str.val[i]) {
- case '?':
- t[j] = '.';
- break;
- case '*':
- t[j++] = '.';
- t[j] = '*';
- break;
- case '.':
- t[j++] = '\\';
- t[j] = '.';
- break;
- default:
- t[j] = pattern->value.str.val[i];
- break;
- }
- }
- t[j]=0;
- free(pattern->value.str.val);
- pattern->value.str.val = t;
- pattern->value.str.len = j;
- return;
-}
-
-%}
-
-%pure_parser
-%token TC_STRING
-%token TC_ENCAPSULATED_STRING
-%token SECTION
-%token CFG_TRUE
-%token CFG_FALSE
-%token EXTENSION
-%token T_ZEND_EXTENSION
-%token T_ZEND_EXTENSION_TS
-%token T_ZEND_EXTENSION_DEBUG
-%token T_ZEND_EXTENSION_DEBUG_TS
-
-%%
-
-statement_list:
- statement_list statement
- | /* empty */
-;
-
-statement:
- string '=' string_or_value {
-#if 0
- printf("'%s' = '%s'\n",$1.value.str.val,$3.value.str.val);
-#endif
- $3.type = IS_STRING;
- if (parsing_mode==PARSING_MODE_CFG) {
- zend_hash_update(active_zend_hash_table, $1.value.str.val, $1.value.str.len+1, &$3, sizeof(pval), NULL);
- } else if (parsing_mode==PARSING_MODE_BROWSCAP) {
- php3_str_tolower($1.value.str.val,$1.value.str.len);
- zend_hash_update(current_section->value.ht, $1.value.str.val, $1.value.str.len+1, &$3, sizeof(pval), NULL);
- }
- free($1.value.str.val);
- }
- | string { free($1.value.str.val); }
- | EXTENSION '=' string {
- pval dummy;
-#if 0
- printf("Loading '%s'\n",$3.value.str.val);
-#endif
-
- php3_dl(&$3,MODULE_PERSISTENT,&dummy);
- }
- | T_ZEND_EXTENSION '=' string {
-#if !defined(ZTS) && !ZEND_DEBUG
- zend_load_extension($3.value.str.val);
-#endif
- free($3.value.str.val);
- }
- | T_ZEND_EXTENSION_TS '=' string {
-#if defined(ZTS) && !ZEND_DEBUG
- zend_load_extension($3.value.str.val);
-#endif
- free($3.value.str.val);
- }
- | T_ZEND_EXTENSION_DEBUG '=' string {
-#if !defined(ZTS) && ZEND_DEBUG
- zend_load_extension($3.value.str.val);
-#endif
- free($3.value.str.val);
- }
- | T_ZEND_EXTENSION_DEBUG_TS '=' string {
-#if defined(ZTS) && ZEND_DEBUG
- zend_load_extension($3.value.str.val);
-#endif
- free($3.value.str.val);
- }
- | SECTION {
- if (parsing_mode==PARSING_MODE_BROWSCAP) {
- pval tmp;
-
- /*printf("'%s' (%d)\n",$1.value.str.val,$1.value.str.len+1);*/
- tmp.value.ht = (HashTable *) malloc(sizeof(HashTable));
- zend_hash_init(tmp.value.ht, 0, NULL, (int (*)(void *))pvalue_config_destructor, 1);
- tmp.type = IS_OBJECT;
- zend_hash_update(active_zend_hash_table, $1.value.str.val, $1.value.str.len+1, (void *) &tmp, sizeof(pval), (void **) &current_section);
- tmp.value.str.val = php3_strndup($1.value.str.val,$1.value.str.len);
- tmp.value.str.len = $1.value.str.len;
- tmp.type = IS_STRING;
- convert_browscap_pattern(&tmp);
- zend_hash_update(current_section->value.ht,"browser_name_pattern",sizeof("browser_name_pattern"),(void *) &tmp, sizeof(pval), NULL);
- }
- free($1.value.str.val);
- }
- | '\n'
-;
-
-
-string:
- TC_STRING { $$ = $1; }
- | TC_ENCAPSULATED_STRING { $$ = $1; }
-;
-
-string_or_value:
- string { $$ = $1; }
- | CFG_TRUE { $$ = $1; }
- | CFG_FALSE { $$ = $1; }
- | '\n' { $$.value.str.val = strdup(""); $$.value.str.len=0; $$.type = IS_STRING; }
-;
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/main/configuration-scanner.l b/main/configuration-scanner.l
deleted file mode 100644
index 91d5f3d6f2..0000000000
--- a/main/configuration-scanner.l
+++ /dev/null
@@ -1,179 +0,0 @@
-%{
-
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
-*/
-
-
-#include "php.h"
-#include "configuration-parser.h"
-
-#undef YYSTYPE
-#define YYSTYPE pval
-
-#define YY_DECL cfglex(pval *cfglval)
-
-
-void init_cfg_scanner()
-{
- cfglineno=1;
-}
-
-
-%}
-
-%option noyywrap
-%option yylineno
-
-%%
-
-<INITIAL>"extension" {
-#if 0
- printf("found extension\n");
-#endif
- return EXTENSION;
-}
-
-
-<INITIAL>"zend_extension" {
- return T_ZEND_EXTENSION;
-}
-
-
-<INITIAL>"zend_extension_ts" {
- return T_ZEND_EXTENSION_TS;
-}
-
-
-<INITIAL>"zend_extension_debug" {
- return T_ZEND_EXTENSION_DEBUG;
-}
-
-
-<INITIAL>"zend_extension_debug_ts" {
- return T_ZEND_EXTENSION_DEBUG_TS;
-}
-
-
-<INITIAL>[ ]*("true"|"on"|"yes")[ ]* {
- cfglval->value.str.val = php3_strndup("1",1);
- cfglval->value.str.len = 1;
- cfglval->type = IS_STRING;
- return CFG_TRUE;
-}
-
-
-<INITIAL>[ ]*("false"|"off"|"no")[ ]* {
- cfglval->value.str.val = php3_strndup("",0);
- cfglval->value.str.len = 0;
- cfglval->type = IS_STRING;
- return CFG_FALSE;
-}
-
-
-<INITIAL>[[][^[]+[\]]([\n]?|"\r\n"?) {
- /* SECTION */
-
- /* eat trailng ] */
- while (yyleng>0 && (yytext[yyleng-1]=='\n' || yytext[yyleng-1]=='\r' || yytext[yyleng-1]==']')) {
- yyleng--;
- yytext[yyleng]=0;
- }
-
- /* eat leading [ */
- yytext++;
- yyleng--;
-
- cfglval->value.str.val = php3_strndup(yytext,yyleng);
- cfglval->value.str.len = yyleng;
- cfglval->type = IS_STRING;
- return SECTION;
-}
-
-
-<INITIAL>["][^\n\r"]*["] {
- /* ENCAPSULATED TC_STRING */
-
- /* eat trailing " */
- yytext[yyleng-1]=0;
-
- /* eat leading " */
- yytext++;
-
- cfglval->value.str.val = php3_strndup(yytext,yyleng);
- cfglval->value.str.len = yyleng;
- cfglval->type = IS_STRING;
- return TC_ENCAPSULATED_STRING;
-}
-
-
-<INITIAL>[^=\n\r\t;"]+ {
- /* STRING */
- register int i;
-
- /* eat trailing whitespace */
- for (i=yyleng-1; i>=0; i--) {
- if (yytext[i]==' ' || yytext[i]=='\t') {
- yytext[i]=0;
- yyleng--;
- } else {
- break;
- }
- }
- /* eat leading whitespace */
- while (yytext[0]) {
- if (yytext[0]==' ' || yytext[0]=='\t') {
- yytext++;
- yyleng--;
- } else {
- break;
- }
- }
- if (yyleng!=0) {
- cfglval->value.str.val = php3_strndup(yytext,yyleng);
- cfglval->value.str.len = yyleng;
- cfglval->type = IS_STRING;
- return TC_STRING;
- } else {
- /* whitespace */
- }
-}
-
-
-
-<INITIAL>[=\n] {
- return yytext[0];
-}
-
-<INITIAL>"\r\n" {
- return '\n';
-}
-
-<INITIAL>[;][^\r\n]*[\r\n]? {
- /* comment */
- return '\n';
-}
-
-<INITIAL>[ \t] {
- /* eat whitespace */
-}
-
-<INITIAL>. {
-#if DEBUG
- php_error(E_NOTICE,"Unexpected character on line %d: '%s' (ASCII %d)\n",yylineno,yytext,yytext[0]);
-#endif
-}
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
deleted file mode 100644
index 09970821ee..0000000000
--- a/main/fopen_wrappers.c
+++ /dev/null
@@ -1,1003 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Jim Winstead <jimw@php.net> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-/* Synced with php3 revision 1.66 1999-06-18 [ssb] */
-
-#include "php.h"
-#include "php_globals.h"
-#include "SAPI.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#if MSVC5
-#include <windows.h>
-#include <winsock.h>
-#define O_RDONLY _O_RDONLY
-#include "win32/param.h"
-#else
-#include <sys/param.h>
-#endif
-
-#include "safe_mode.h"
-#include "php3_realpath.h"
-#include "ext/standard/head.h"
-#include "ext/standard/php3_standard.h"
-#include "zend_compile.h"
-
-#if HAVE_PWD_H
-#if MSVC5
-#include "win32/pwd.h"
-#else
-#include <pwd.h>
-#endif
-#endif
-
-#include <sys/types.h>
-#if HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
-#ifndef S_ISREG
-#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
-#endif
-
-#if MSVC5
-#include <winsock.h>
-#else
-#include <netinet/in.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-#endif
-
-#if MSVC5
-#undef AF_UNIX
-#endif
-
-#if defined(AF_UNIX)
-#include <sys/un.h>
-#endif
-
-static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, int *issock, int *socketd);
-
-int _php3_getftpresult(int socketd);
-
-/*
- When open_basedir is not NULL, check if the given filename is located in
- open_basedir. Returns -1 if error or not in the open_basedir, else 0
-
- When open_basedir is NULL, always return 0
-*/
-PHPAPI int _php3_check_specific_open_basedir(char *basedir, char *path PLS_DC)
-{
- char resolved_name[MAXPATHLEN];
- char resolved_basedir[MAXPATHLEN];
- char local_open_basedir[MAXPATHLEN];
- int local_open_basedir_pos;
- SLS_FETCH();
-
- /* Special case basedir==".": Use script-directory */
- if ((strcmp(PG(open_basedir), ".") == 0) &&
- SG(request_info).path_translated &&
- *SG(request_info).path_translated
- ) {
- strcpy(local_open_basedir, SG(request_info).path_translated);
- local_open_basedir_pos = strlen(local_open_basedir) - 1;
-
- /* Strip filename */
- while ((
-#if WIN32|WINNT
- (local_open_basedir[local_open_basedir_pos] != '\\') ||
-#endif
- (local_open_basedir[local_open_basedir_pos] != '/')
- ) &&
- (local_open_basedir_pos >= 0)
- ) {
- local_open_basedir[local_open_basedir_pos--] = 0;
- }
- } else {
- /* Else use the unmodified path */
- strcpy(local_open_basedir, basedir);
- }
-
- /* Resolve the real path into resolved_name */
- if ((_php3_realpath(path, resolved_name) != NULL) && (_php3_realpath(local_open_basedir, resolved_basedir) != NULL)) {
- /* Check the path */
-#if WIN32|WINNT
- if (strncasecmp(resolved_basedir, resolved_name, strlen(resolved_basedir)) == 0) {
-#else
- if (strncmp(resolved_basedir, resolved_name, strlen(resolved_basedir)) == 0) {
-#endif
- /* File is in the right directory */
- return 0;
- } else {
- return -1;
- }
- } else {
- /* Unable to resolve the real path, return -1 */
- return -1;
- }
-}
-
-PHPAPI int _php3_check_open_basedir(char *path)
-{
- PLS_FETCH();
-
- /* Only check when open_basedir is available */
- if (PG(open_basedir) && *PG(open_basedir)) {
- char *pathbuf;
- char *ptr;
- char *end;
-
- pathbuf = estrdup(PG(open_basedir));
-
- ptr = pathbuf;
-
- while (ptr && *ptr) {
-#if WIN32|WINNT
- end = strchr(ptr, ';');
-#else
- end = strchr(ptr, ':');
-#endif
- if (end != NULL) {
- *end = '\0';
- end++;
- }
-
- if (_php3_check_specific_open_basedir(ptr, path PLS_CC) == 0) {
- efree(pathbuf);
- return 0;
- }
-
- ptr = end;
- }
- php_error(E_WARNING, "open_basedir restriction in effect. File is in wrong directory.");
- efree(pathbuf);
- return -1;
- }
-
- /* Nothing to check... */
- return 0;
-}
-
-PHPAPI FILE *php3_fopen_wrapper(char *path, char *mode, int options, int *issock, int *socketd)
-{
- int cm=2; /* checkuid mode: 2 = if file does not exist, check directory */
- PLS_FETCH();
-
- /* FIXME Lets not get in the habit of doing stuff like this. This should
- be runtime enabled, NOT compile time. */
-#if PHP3_URL_FOPEN
- if (!(options & IGNORE_URL)) {
- return php3_fopen_url_wrapper(path, mode, options, issock, socketd);
- }
-#endif
-
- if (options & USE_PATH && PG(include_path) != NULL) {
- return php3_fopen_with_path(path, mode, PG(include_path), NULL);
- } else {
- if(!strcmp(mode,"r") || !strcmp(mode,"r+")) cm=0;
- if (options & ENFORCE_SAFE_MODE && PG(safe_mode) && (!_php3_checkuid(path, cm))) {
- return NULL;
- }
- if (_php3_check_open_basedir(path)) return NULL;
- return fopen(path, mode);
- }
-}
-
-#if CGI_BINARY || FHTTPD || USE_SAPI
-
-PHPAPI FILE *php3_fopen_for_parser(void)
-{
- FILE *fp;
- struct stat st;
- char *temp, *path_info, *fn;
- int l;
- PLS_FETCH();
- SLS_FETCH();
-
- fn = SG(request_info).path_translated;
- path_info = SG(request_info).request_uri;
-#if HAVE_PWD_H
- if (PG(user_dir) && *PG(user_dir)
- && path_info && '/' == path_info[0] && '~' == path_info[1]) {
-
- char user[32];
- struct passwd *pw;
- char *s = strchr(path_info + 2, '/');
-
- fn = NULL; /* discard the original filename, it must not be used */
- if (s) { /* if there is no path name after the file, do not bother
- to try open the directory */
- l = s - (path_info + 2);
- if (l > sizeof(user) - 1)
- l = sizeof(user) - 1;
- memcpy(user, path_info + 2, l);
- user[l] = '\0';
-
- pw = getpwnam(user);
- if (pw && pw->pw_dir) {
- fn = emalloc(strlen(PG(user_dir)) + strlen(path_info) + strlen(pw->pw_dir) + 4);
- if (fn) {
- strcpy(fn, pw->pw_dir); /* safe */
- strcat(fn, "/"); /* safe */
- strcat(fn, PG(user_dir)); /* safe */
- strcat(fn, "/"); /* safe */
- strcat(fn, s + 1); /* safe (shorter than path_info) */
- STR_FREE(SG(request_info).path_translated);
- SG(request_info).path_translated = fn;
- }
- }
- }
- } else
-#endif
-#if WIN32
- if (PG(doc_root) && path_info && ('/' == *PG(doc_root) ||
- '\\' == *PG(doc_root) || strstr(PG(doc_root),":\\") ||
- strstr(PG(doc_root),":/"))) {
-#else
- if (PG(doc_root) && '/' == *PG(doc_root) && path_info) {
-#endif
- l = strlen(PG(doc_root));
- fn = emalloc(l + strlen(path_info) + 2);
- if (fn) {
- memcpy(fn, PG(doc_root), l);
- if ('/' != fn[l - 1] || '\\' != fn[l - 1]) /* l is never 0 */
- fn[l++] = '/';
- if ('/' == path_info[0])
- l--;
- strcpy(fn + l, path_info);
- STR_FREE(SG(request_info).path_translated);
- SG(request_info).path_translated = fn;
- }
- } /* if doc_root && path_info */
- if (!fn) {
- /* we have to free SG(request_info).path_translated here because
- php3_destroy_request_info assumes that it will get
- freed when the include_names hash is emptied, but
- we're not adding it in this case */
- STR_FREE(SG(request_info).path_translated);
- SG(request_info).path_translated = NULL;
- return NULL;
- }
- fp = fopen(fn, "r");
-
- /* refuse to open anything that is not a regular file */
- if (fp && (0 > fstat(fileno(fp), &st) || !S_ISREG(st.st_mode))) {
- fclose(fp);
- fp = NULL;
- }
- if (!fp) {
- php_error(E_CORE_ERROR, "Unable to open %s", fn);
- STR_FREE(SG(request_info).path_translated); /* for same reason as above */
- return NULL;
- }
-
- temp = estrdup(fn);
- _php3_dirname(temp, strlen(temp));
- if (*temp) {
- chdir(temp);
- }
- efree(temp);
- SG(request_info).path_translated = fn;
-
- return fp;
-}
-
-#endif /* CGI_BINARY || USE_SAPI */
-
-/*
- * Tries to open a file with a PATH-style list of directories.
- * If the filename starts with "." or "/", the path is ignored.
- */
-PHPAPI FILE *php3_fopen_with_path(char *filename, char *mode, char *path, char **opened_path)
-{
- char *pathbuf, *ptr, *end;
- char trypath[MAXPATHLEN + 1];
- struct stat sb;
- FILE *fp;
- int cm=2;
- PLS_FETCH();
-
- if(!strcmp(mode,"r") || !strcmp(mode,"r+")) cm=0;
- if (opened_path) {
- *opened_path = NULL;
- }
- /* Relative path open */
- if (*filename == '.') {
- if (PG(safe_mode) && (!_php3_checkuid(filename, cm))) {
- return NULL;
- }
- if (_php3_check_open_basedir(filename)) return NULL;
- fp = fopen(filename, mode);
- if (fp && opened_path) {
- *opened_path = expand_filepath(filename);
- }
- return fp;
- }
- /* Absolute path open - prepend document_root in safe mode */
-#if WIN32|WINNT
- if ((*filename == '\\') || (*filename == '/') || (filename[1] == ':')) {
-#else
- if (*filename == '/') {
-#endif
- if (PG(safe_mode)) {
- if(PG(doc_root)) {
- snprintf(trypath, MAXPATHLEN, "%s%s", PG(doc_root), filename);
- } else {
- strlcpy(trypath,filename,sizeof(trypath));
- }
- if (!_php3_checkuid(trypath, cm)) {
- return NULL;
- }
- if (_php3_check_open_basedir(trypath)) return NULL;
- fp = fopen(trypath, mode);
- if (fp && opened_path) {
- *opened_path = expand_filepath(trypath);
- }
- return fp;
- } else {
- if (_php3_check_open_basedir(filename)) return NULL;
- return fopen(filename, mode);
- }
- }
- if (!path || (path && !*path)) {
- if (PG(safe_mode) && (!_php3_checkuid(filename, cm))) {
- return NULL;
- }
- if (_php3_check_open_basedir(filename)) return NULL;
- fp = fopen(filename, mode);
- if (fp && opened_path) {
- *opened_path = strdup(filename);
- }
- return fp;
- }
- pathbuf = estrdup(path);
-
- ptr = pathbuf;
-
- while (ptr && *ptr) {
-#if WIN32|WINNT
- end = strchr(ptr, ';');
-#else
- end = strchr(ptr, ':');
-#endif
- if (end != NULL) {
- *end = '\0';
- end++;
- }
- snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename);
- if (PG(safe_mode)) {
- if (stat(trypath, &sb) == 0 && (!_php3_checkuid(trypath, cm))) {
- efree(pathbuf);
- return NULL;
- }
- }
- if ((fp = fopen(trypath, mode)) != NULL) {
- if (_php3_check_open_basedir(trypath)) {
- fclose(fp);
- efree(pathbuf);
- return NULL;
- }
- if (opened_path) {
- *opened_path = expand_filepath(trypath);
- }
- efree(pathbuf);
- return fp;
- }
- ptr = end;
- }
- efree(pathbuf);
- return NULL;
-}
-
-/*
- * If the specified path starts with "http://" (insensitive to case),
- * a socket is opened to the specified web server and a file pointer is
- * position at the start of the body of the response (past any headers).
- * This makes a HTTP/1.0 request, and knows how to pass on the username
- * and password for basic authentication.
- *
- * If the specified path starts with "ftp://" (insensitive to case),
- * a pair of sockets are used to request the specified file and a file
- * pointer to the requested file is returned. Passive mode ftp is used,
- * so if the server doesn't support this, it will fail!
- *
- * Otherwise, fopen is called as usual and the file pointer is returned.
- */
-
-static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, int *issock, int *socketd)
-{
- url *resource;
- int result;
- char *scratch;
- unsigned char *tmp;
-
- char tmp_line[512];
- char location[512];
- char hdr_line[8192];
- char *tpath, *ttpath;
- int body = 0;
- int reqok = 0;
- int i, len;
-
- FILE *fp = NULL;
- struct sockaddr_in server;
- unsigned short portno;
-
- if (!strncasecmp(path, "http://", 7)) {
- resource = url_parse((char *) path);
- if (resource == NULL) {
- php_error(E_WARNING, "Invalid URL specified, %s", path);
- *issock = BAD_URL;
- return NULL;
- }
- /* use port 80 if one wasn't specified */
- if (resource->port == 0)
- resource->port = 80;
-
- *socketd = socket(AF_INET, SOCK_STREAM, 0);
- if (*socketd == SOCK_ERR) {
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- free_url(resource);
- return NULL;
- }
- server.sin_family = AF_INET;
-
- if (lookup_hostname(resource->host, &server.sin_addr)) {
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- free_url(resource);
- return NULL;
- }
- server.sin_port = htons(resource->port);
-
- if (connect(*socketd, (struct sockaddr *) &server, sizeof(server)) == SOCK_CONN_ERR) {
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- free_url(resource);
- return NULL;
- }
-#if 0
- if ((fp = fdopen(*socketd, "r+")) == NULL) {
- free_url(resource);
- return NULL;
- }
-#ifdef HAVE_SETVBUF
- if ((setvbuf(fp, NULL, _IONBF, 0)) != 0) {
- free_url(resource);
- return NULL;
- }
-#endif
-#endif /*win32 */
-
- strcpy(hdr_line, "GET ");
-
- /* tell remote http which file to get */
- if (resource->path != NULL) {
- strlcat(hdr_line, resource->path, sizeof(hdr_line));
- } else {
- strlcat(hdr_line, "/", sizeof(hdr_line));
- }
- /* append the query string, if any */
- if (resource->query != NULL) {
- strlcat(hdr_line, "?", sizeof(hdr_line));
- strlcat(hdr_line, resource->query, sizeof(hdr_line));
- }
- strlcat(hdr_line, " HTTP/1.0\r\n", sizeof(hdr_line));
- SOCK_WRITE(hdr_line, *socketd);
-
- /* send authorization header if we have user/pass */
- if (resource->user != NULL && resource->pass != NULL) {
- scratch = (char *) emalloc(strlen(resource->user) + strlen(resource->pass) + 2);
- if (!scratch) {
- free_url(resource);
- return NULL;
- }
- strcpy(scratch, resource->user);
- strcat(scratch, ":");
- strcat(scratch, resource->pass);
- tmp = _php3_base64_encode((unsigned char *)scratch, strlen(scratch), NULL);
-
- if (snprintf(hdr_line, sizeof(hdr_line),
- "Authorization: Basic %s\r\n", tmp) > 0) {
- SOCK_WRITE(hdr_line, *socketd);
- }
-
- efree(scratch);
- efree(tmp);
- }
- /* if the user has configured who they are, send a From: line */
- if (cfg_get_string("from", &scratch) == SUCCESS) {
- if (snprintf(hdr_line, sizeof(hdr_line),
- "From: %s\r\n", scratch) > 0) {
- SOCK_WRITE(hdr_line, *socketd);
- }
-
- }
- /* send a Host: header so name-based virtual hosts work */
- if (resource->port != 80) {
- len = snprintf(hdr_line, sizeof(hdr_line),
- "Host: %s:%i\r\n", resource->host, resource->port);
- } else {
- len = snprintf(hdr_line, sizeof(hdr_line),
- "Host: %s\r\n", resource->host);
- }
- if (len > 0) {
- SOCK_WRITE(hdr_line, *socketd);
- }
-
- /* identify ourselves and end the headers */
- SOCK_WRITE("User-Agent: PHP/" PHP_VERSION "\r\n\r\n", *socketd);
-
- body = 0;
- location[0] = '\0';
- if (!SOCK_FEOF(*socketd)) {
- /* get response header */
- if (SOCK_FGETS(tmp_line, sizeof(tmp_line)-1, *socketd) != NULL) {
- if (strncmp(tmp_line + 8, " 200 ", 5) == 0) {
- reqok = 1;
- }
- }
- }
- /* Read past HTTP headers */
- while (!body && !SOCK_FEOF(*socketd)) {
- if (SOCK_FGETS(tmp_line, sizeof(tmp_line)-1, *socketd) != NULL) {
- char *p = tmp_line;
-
- tmp_line[sizeof(tmp_line)-1] = '\0';
-
- while (*p) {
- if (*p == '\n' || *p == '\r') {
- *p = '\0';
- }
- p++;
- }
-
- if (!strncasecmp(tmp_line, "Location: ", 10)) {
- strcpy(location, tmp_line + 10);
- }
-
- if (tmp_line[0] == '\0') {
- body = 1;
- }
- }
- }
- if (!reqok) {
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- free_url(resource);
- if (location[0] != '\0') {
- return php3_fopen_url_wrapper(location, mode, options, issock, socketd);
- } else {
- return NULL;
- }
- }
- free_url(resource);
- *issock = 1;
- return (fp);
- } else if (!strncasecmp(path, "php://", 6)) {
- const char *res = path + 6;
-
- if (!strcasecmp(res, "stdin")) {
- return fdopen(STDIN_FILENO, mode);
- } else if (!strcasecmp(res, "stdout")) {
- return fdopen(STDOUT_FILENO, mode);
- } else if (!strcasecmp(res, "stderr")) {
- return fdopen(STDERR_FILENO, mode);
- }
- } else if (!strncasecmp(path, "ftp://", 6)) {
- resource = url_parse((char *) path);
- if (resource == NULL) {
- php_error(E_WARNING, "Invalid URL specified, %s", path);
- *issock = BAD_URL;
- return NULL;
- } else if (resource->path == NULL) {
- php_error(E_WARNING, "No file-path specified");
- free_url(resource);
- *issock = BAD_URL;
- return NULL;
- }
- /* use port 21 if one wasn't specified */
- if (resource->port == 0)
- resource->port = 21;
-
- *socketd = socket(AF_INET, SOCK_STREAM, 0);
- if (*socketd == SOCK_ERR) {
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- free_url(resource);
- return NULL;
- }
- server.sin_family = AF_INET;
-
- if (lookup_hostname(resource->host, &server.sin_addr)) {
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- free_url(resource);
- return NULL;
- }
- server.sin_port = htons(resource->port);
-
- if (connect(*socketd, (struct sockaddr *) &server, sizeof(server)) == SOCK_CONN_ERR) {
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- free_url(resource);
- return NULL;
- }
-#if 0
- if ((fpc = fdopen(*socketd, "r+")) == NULL) {
- free_url(resource);
- return NULL;
- }
-#ifdef HAVE_SETVBUF
- if ((setvbuf(fpc, NULL, _IONBF, 0)) != 0) {
- free_url(resource);
- fclose(fpc);
- return NULL;
- }
-#endif
-#endif
-
- /* Start talking to ftp server */
- result = _php3_getftpresult(*socketd);
- if (result > 299 || result < 200) {
- free_url(resource);
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- return NULL;
- }
- /* send the user name */
- SOCK_WRITE("USER ", *socketd);
- if (resource->user != NULL) {
- _php3_rawurldecode(resource->user, strlen(resource->user));
- SOCK_WRITE(resource->user, *socketd);
- } else {
- SOCK_WRITE("anonymous", *socketd);
- }
- SOCK_WRITE("\n", *socketd);
-
- /* get the response */
- result = _php3_getftpresult(*socketd);
-
- /* if a password is required, send it */
- if (result >= 300 && result <= 399) {
- SOCK_WRITE("PASS ", *socketd);
- if (resource->pass != NULL) {
- _php3_rawurldecode(resource->pass, strlen(resource->pass));
- SOCK_WRITE(resource->pass, *socketd);
- } else {
- /* if the user has configured who they are,
- send that as the password */
- if (cfg_get_string("from", &scratch) == SUCCESS) {
- SOCK_WRITE(scratch, *socketd);
- } else {
- SOCK_WRITE("anonymous", *socketd);
- }
- }
- SOCK_WRITE("\n", *socketd);
-
- /* read the response */
- result = _php3_getftpresult(*socketd);
- if (result > 299 || result < 200) {
- free_url(resource);
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- return NULL;
- }
- } else if (result > 299 || result < 200) {
- free_url(resource);
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- return NULL;
- }
-
- /* set the connection to be binary */
- SOCK_WRITE("TYPE I\n", *socketd);
- result = _php3_getftpresult(*socketd);
- if (result > 299 || result < 200) {
- free_url(resource);
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- return NULL;
- }
-
- /* find out the size of the file (verifying it exists) */
- SOCK_WRITE("SIZE ", *socketd);
- SOCK_WRITE(resource->path, *socketd);
- SOCK_WRITE("\n", *socketd);
-
- /* read the response */
- result = _php3_getftpresult(*socketd);
- if (mode[0] == 'r') {
- /* when reading file, it must exist */
- if (result > 299 || result < 200) {
- php_error(E_WARNING, "File not found");
- free_url(resource);
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- errno = ENOENT;
- return NULL;
- }
- } else {
- /* when writing file, it must NOT exist */
- if (result <= 299 && result >= 200) {
- php_error(E_WARNING, "File already exists");
- free_url(resource);
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- errno = EEXIST;
- return NULL;
- }
- }
-
- /* set up the passive connection */
- SOCK_WRITE("PASV\n", *socketd);
- while (SOCK_FGETS(tmp_line, sizeof(tmp_line)-1, *socketd) &&
- !(isdigit((int) tmp_line[0]) && isdigit((int) tmp_line[1]) &&
- isdigit((int) tmp_line[2]) && tmp_line[3] == ' '));
-
- /* make sure we got a 227 response */
- if (strncmp(tmp_line, "227", 3)) {
- free_url(resource);
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- return NULL;
- }
- /* parse pasv command (129,80,95,25,13,221) */
- tpath = tmp_line;
-
- /* skip over the "227 Some message " part */
- for (tpath += 4; *tpath && !isdigit((int) *tpath); tpath++);
- if (!*tpath) {
- free_url(resource);
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- return NULL;
- }
- /* skip over the host ip, we just assume it's the same */
- for (i = 0; i < 4; i++) {
- for (; isdigit((int) *tpath); tpath++);
- if (*tpath == ',') {
- tpath++;
- } else {
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- return NULL;
- }
- }
-
- /* pull out the MSB of the port */
- portno = (unsigned short) strtol(tpath, &ttpath, 10) * 256;
- if (ttpath == NULL) {
- /* didn't get correct response from PASV */
- free_url(resource);
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- return NULL;
- }
- tpath = ttpath;
- if (*tpath == ',') {
- tpath++;
- } else {
- free_url(resource);
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- return NULL;
- }
-
- /* pull out the LSB of the port */
- portno += (unsigned short) strtol(tpath, &ttpath, 10);
-
- if (ttpath == NULL) {
- /* didn't get correct response from PASV */
- free_url(resource);
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- return NULL;
- }
-
- if (mode[0] == 'r') {
- /* retrieve file */
- SOCK_WRITE("RETR ", *socketd);
- } else {
- /* store file */
- SOCK_WRITE("STOR ", *socketd);
- }
- if (resource->path != NULL) {
- SOCK_WRITE(resource->path, *socketd);
- } else {
- SOCK_WRITE("/", *socketd);
- }
-
- /* close control connection */
- SOCK_WRITE("\nQUIT\n", *socketd);
- SOCK_FCLOSE(*socketd);
-
- /* open the data channel */
- *socketd = socket(AF_INET, SOCK_STREAM, 0);
- if (*socketd == SOCK_ERR) {
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- free_url(resource);
- return NULL;
- }
- server.sin_family = AF_INET;
-
- if (lookup_hostname(resource->host, &server.sin_addr)) {
- free_url(resource);
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- return NULL;
- }
- server.sin_port = htons(portno);
-
- if (connect(*socketd, (struct sockaddr *) &server, sizeof(server)) == SOCK_CONN_ERR) {
- free_url(resource);
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- return NULL;
- }
-#if 0
- if (mode[0] == 'r') {
- if ((fp = fdopen(*socketd, "r+")) == NULL) {
- free_url(resource);
- return NULL;
- }
- } else {
- if ((fp = fdopen(*socketd, "w+")) == NULL) {
- free_url(resource);
- return NULL;
- }
- }
-#ifdef HAVE_SETVBUF
- if ((setvbuf(fp, NULL, _IONBF, 0)) != 0) {
- free_url(resource);
- fclose(fp);
- return NULL;
- }
-#endif
-#endif
- free_url(resource);
- *issock = 1;
- return (fp);
-
- } else {
- PLS_FETCH();
-
- if (options & USE_PATH) {
- fp = php3_fopen_with_path((char *) path, mode, PG(include_path), NULL);
- } else {
- int cm=2;
- if(!strcmp(mode,"r") || !strcmp(mode,"r+")) cm=0;
- if (options & ENFORCE_SAFE_MODE && PG(safe_mode) && (!_php3_checkuid(path, cm))) {
- fp = NULL;
- } else {
- if (_php3_check_open_basedir((char *) path)) {
- fp = NULL;
- } else {
- fp = fopen(path, mode);
- }
- }
- }
-
- *issock = 0;
-
- return (fp);
- }
-
- /* NOTREACHED */
- SOCK_FCLOSE(*socketd);
- *socketd = 0;
- return NULL;
-}
-
-int _php3_getftpresult(int socketd)
-{
- char tmp_line[513];
-
- while (SOCK_FGETS(tmp_line, sizeof(tmp_line)-1, socketd) &&
- !(isdigit((int) tmp_line[0]) && isdigit((int) tmp_line[1]) &&
- isdigit((int) tmp_line[2]) && tmp_line[3] == ' '));
-
- return strtol(tmp_line, NULL, 10);
-}
-
-PHPAPI int php3_isurl(char *path)
-{
- return (!strncasecmp(path, "http://", 7) || !strncasecmp(path, "ftp://", 6));
-}
-
-
-PHPAPI char *php3_strip_url_passwd(char *url)
-{
- register char *p = url, *url_start;
-
- while (*p) {
- if (*p==':' && *(p+1)=='/' && *(p+2)=='/') {
- /* found protocol */
- url_start = p = p+3;
-
- while (*p) {
- if (*p=='@') {
- int i;
-
- for (i=0; i<3 && url_start<p; i++, url_start++) {
- *url_start = '.';
- }
- for (; *p; p++) {
- *url_start++ = *p;
- }
- *url_start=0;
- break;
- }
- p++;
- }
- return url;
- }
- p++;
- }
- return url;
-}
-
-
-PHPAPI char *expand_filepath(char *filepath)
-{
- char *retval = NULL;
-
- if (filepath[0] == '.') {
- char *cwd = malloc(MAXPATHLEN + 1);
-
- if (getcwd(cwd, MAXPATHLEN)) {
- char *cwd_end = cwd + strlen(cwd);
-
- if (filepath[1] == '.') { /* parent directory - .. */
- /* erase the last directory name from the path */
- while (*cwd_end != '/') {
- *cwd_end-- = 0;
- }
- filepath++; /* make filepath appear as a current directory path */
- }
- if (cwd_end > cwd && *cwd_end == '/') { /* remove trailing slashes */
- *cwd_end-- = 0;
- }
- retval = (char *) malloc(strlen(cwd) + strlen(filepath) - 1 + 1);
- strcpy(retval, cwd);
- strcat(retval, filepath + 1);
- free(cwd);
- }
- }
- if (!retval) {
- retval = strdup(filepath);
- }
- return retval;
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/main/fopen_wrappers.h b/main/fopen_wrappers.h
deleted file mode 100644
index a0ef79bf80..0000000000
--- a/main/fopen_wrappers.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Jim Winstead <jimw@php.net> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-/* Synced with php3 revision 1.25 1999-06-16 [ssb] */
-
-#ifndef _FOPEN_WRAPPERS_H
-#define _FOPEN_WRAPPERS_H
-
-#include "php_globals.h"
-
-#define IGNORE_PATH 0
-#define USE_PATH 1
-#define IGNORE_URL 2
-/* There's no USE_URL. */
-#if WIN32|WINNT
-# define IGNORE_URL_WIN 2
-#else
-# define IGNORE_URL_WIN 0
-#endif
-#define ENFORCE_SAFE_MODE 4
-
-#if WIN32|WINNT
-# define SOCK_ERR INVALID_SOCKET
-# define SOCK_CONN_ERR SOCKET_ERROR
-# define SOCK_RECV_ERR SOCKET_ERROR
-#else
-# define SOCK_ERR -1
-# define SOCK_CONN_ERR -1
-# define SOCK_RECV_ERR -1
-#endif
-#define SOCK_WRITE(d,s) send(s,d,strlen(d),0)
-#define SOCK_WRITEL(d,l,s) send(s,d,l,0)
-#define SOCK_FGETC(s) _php3_sock_fgetc((s))
-#define SOCK_FGETS(b,l,s) _php3_sock_fgets((b),(l),(s))
-#define SOCK_FEOF(sock) _php3_sock_feof((sock))
-#define SOCK_FREAD(ptr,size,sock) _php3_sock_fread((ptr),(size),(sock))
-#define SOCK_FCLOSE(s) _php3_sock_close(s)
-
-#define FP_FGETS(buf,len,sock,fp,issock) \
- ((issock)?SOCK_FGETS(buf,len,sock):fgets(buf,len,fp))
-#define FP_FREAD(buf,len,sock,fp,issock) \
- ((issock)?SOCK_FREAD(buf,len,sock):fread(buf,1,len,fp))
-#define FP_FEOF(sock,fp,issock) \
- ((issock)?SOCK_FEOF(sock):feof(fp))
-#define FP_FGETC(sock,fp,issock) \
- ((issock)?SOCK_FGETC(sock):fgetc(fp))
-
-/* values for issock */
-#define IS_NOT_SOCKET 0
-#define IS_SOCKET 1
-#define BAD_URL 2
-
-#ifndef THREAD_SAFE
-extern int wsa_fp; /* a list for open sockets */
-#endif
-
-extern PHPAPI FILE *php3_fopen_wrapper(char *filename, char *mode, int options, int *issock, int *socketd);
-
-PHPAPI FILE *php3_fopen_for_parser(void);
-
-extern PHPAPI int _php3_check_open_basedir(char *path);
-extern PHPAPI int _php3_check_specific_open_basedir(char *basedir, char *path PLS_DC);
-
-extern PHPAPI FILE *php3_fopen_with_path(char *filename, char *mode, char *path, char **opened_path);
-
-extern PHPAPI int php3_isurl(char *path);
-extern PHPAPI char *php3_strip_url_passwd(char *path);
-
-extern PHPAPI char *expand_filepath(char *filepath);
-
-#endif
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/main/internal_functions.c.in b/main/internal_functions.c.in
deleted file mode 100644
index 8ac4f47862..0000000000
--- a/main/internal_functions.c.in
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Andi Gutmans <andi@zend.com> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-
-#include "php.h"
-#include "modules.h"
-#include "internal_functions_registry.h"
-#include "zend_compile.h"
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "ext/standard/reg.h"
-#include "ext/standard/dl.h"
-#include "ext/standard/file.h"
-#include "ext/standard/fsock.h"
-#include "ext/standard/head.h"
-#include "ext/standard/pack.h"
-#include "ext/standard/php3_browscap.h"
-#include "ext/standard/php3_crypt.h"
-#include "ext/standard/php3_dir.h"
-#include "ext/standard/php3_filestat.h"
-#include "ext/standard/php3_mail.h"
-#include "ext/standard/php3_syslog.h"
-#include "ext/standard/php_lcg.h"
-#include "ext/standard/php_metaphone.h"
-@EXT_INCLUDE_CODE@
-
-/* SNMP has to be moved to ext */
-/* #include "dl/snmp/php3_snmp.h" */
-
-unsigned char first_arg_force_ref[] = { 1, BYREF_FORCE };
-unsigned char first_arg_allow_ref[] = { 1, BYREF_ALLOW };
-unsigned char second_arg_force_ref[] = { 2, BYREF_NONE, BYREF_FORCE };
-unsigned char second_arg_allow_ref[] = { 2, BYREF_NONE, BYREF_ALLOW };
-
-zend_module_entry *php3_builtin_modules[] = {
- phpext_regex_ptr,
- phpext_dl_ptr,
- phpext_file_ptr,
- phpext_fsock_ptr,
- phpext_head_ptr,
- phpext_pack_ptr,
- phpext_browscap_ptr,
- phpext_crypt_ptr,
- phpext_dir_ptr,
- phpext_filestat_ptr,
- phpext_mail_ptr,
- phpext_syslog_ptr,
- phpext_lcg_ptr,
- phpext_metaphone_ptr,
-@EXT_MODULE_PTRS@
-};
-
-
-int module_startup_modules(void)
-{
- zend_module_entry **ptr = php3_builtin_modules, **end = ptr+(sizeof(php3_builtin_modules)/sizeof(zend_module_entry *));
-
- while (ptr < end) {
- if (*ptr) {
- if (zend_startup_module(*ptr)==FAILURE) {
- return FAILURE;
- }
- }
- ptr++;
- }
- return SUCCESS;
-}
-
-int module_global_startup_modules(void)
-{
- zend_module_entry **ptr = php3_builtin_modules, **end = ptr+(sizeof(php3_builtin_modules)/sizeof(zend_module_entry *));
-
- while (ptr < end) {
- if (*ptr) {
- if ((*ptr)->global_startup_func &&
- (*ptr)->global_startup_func()==FAILURE) {
- return FAILURE;
- }
- }
- ptr++;
- }
- return SUCCESS;
-}
-
-int module_global_shutdown_modules(void)
-{
- zend_module_entry **ptr = php3_builtin_modules, **end = ptr+(sizeof(php3_builtin_modules)/sizeof(zend_module_entry *));
-
- while (ptr < end) {
- if (*ptr) {
- if ((*ptr)->global_shutdown_func &&
- (*ptr)->global_shutdown_func()==FAILURE) {
- return FAILURE;
- }
- }
- ptr++;
- }
- return SUCCESS;
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/main/internal_functions_registry.h b/main/internal_functions_registry.h
deleted file mode 100644
index b7d2a16129..0000000000
--- a/main/internal_functions_registry.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Andi Gutmans <andi@zend.com> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-#ifndef _INTERNAL_FUNCTIONS_REGISTRY_H
-#define _INTERNAL_FUNCTIONS_REGISTRY_H
-
-extern int php3_init_mime(INIT_FUNC_ARGS);
-
-#if APACHE
-extern php3_module_entry apache_module_entry;
-#define phpext_apache_ptr &apache_module_entry
-extern void php3_virtual(INTERNAL_FUNCTION_PARAMETERS);
-#else
-#define phpext_apache_ptr NULL
-#endif
-
-/* environment functions */
-extern int php3_init_environment(void);
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/main/internal_functions_win32.c b/main/internal_functions_win32.c
deleted file mode 100644
index 92b2c215ae..0000000000
--- a/main/internal_functions_win32.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Andi Gutmans <andi@zend.com> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-
-/* $Id$ */
-
-
-#include "php.h"
-#include "modules.h"
-#include "internal_functions_registry.h"
-#include "zend_compile.h"
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "ext/bcmath/php3_bcmath.h"
-#include "ext/db/php3_db.h"
-#include "ext/gd/php3_gd.h"
-#include "ext/standard/dl.h"
-#include "ext/standard/file.h"
-#include "ext/standard/fsock.h"
-#include "ext/standard/head.h"
-#include "ext/standard/pack.h"
-#include "ext/standard/php3_browscap.h"
-#include "ext/standard/php3_crypt.h"
-#include "ext/standard/php3_dir.h"
-#include "ext/standard/php3_filestat.h"
-#include "ext/standard/php3_mail.h"
-#include "ext/standard/php3_syslog.h"
-#include "ext/standard/php3_standard.h"
-#include "ext/standard/php_lcg.h"
-#include "ext/COM/php3_COM.h"
-#include "ext/standard/reg.h"
-#include "ext/pcre/php_pcre.h"
-#include "ext/odbc/php_odbc.h"
-#include "ext/session/php_session.h"
-
-/* SNMP has to be moved to ext */
-/* #include "dl/snmp/php3_snmp.h" */
-
-unsigned char first_arg_force_ref[] = { 1, BYREF_FORCE };
-unsigned char first_arg_allow_ref[] = { 1, BYREF_ALLOW };
-unsigned char second_arg_force_ref[] = { 2, BYREF_NONE, BYREF_FORCE };
-unsigned char second_arg_allow_ref[] = { 2, BYREF_NONE, BYREF_ALLOW };
-
-zend_module_entry *php3_builtin_modules[] = {
- phpext_dl_ptr,
- phpext_file_ptr,
- phpext_fsock_ptr,
- phpext_head_ptr,
- phpext_pack_ptr,
- phpext_browscap_ptr,
- phpext_crypt_ptr,
- phpext_dir_ptr,
- phpext_filestat_ptr,
- phpext_mail_ptr,
- phpext_syslog_ptr,
-#if WITH_BCMATH
- phpext_bcmath_ptr,
-#endif
- phpext_standard_ptr,
- COM_module_ptr,
- phpext_regex_ptr,
- phpext_pcre_ptr,
- phpext_odbc_ptr,
- phpext_lcg_ptr,
- phpext_session_ptr
-};
-
-
-int module_startup_modules(void)
-{
- zend_module_entry **ptr = php3_builtin_modules, **end = ptr+(sizeof(php3_builtin_modules)/sizeof(zend_module_entry *));
-
- while (ptr < end) {
- if (*ptr) {
- if (zend_startup_module(*ptr)==FAILURE) {
- return FAILURE;
- }
- }
- ptr++;
- }
- return SUCCESS;
-}
-
-int module_global_startup_modules(void)
-{
- zend_module_entry **ptr = php3_builtin_modules, **end = ptr+(sizeof(php3_builtin_modules)/sizeof(zend_module_entry *));
-
- while (ptr < end) {
- if (*ptr) {
- if ((*ptr)->global_startup_func &&
- (*ptr)->global_startup_func()==FAILURE) {
- return FAILURE;
- }
- }
- ptr++;
- }
- return SUCCESS;
-}
-
-int module_global_shutdown_modules(void)
-{
- zend_module_entry **ptr = php3_builtin_modules, **end = ptr+(sizeof(php3_builtin_modules)/sizeof(zend_module_entry *));
-
- while (ptr < end) {
- if (*ptr) {
- if ((*ptr)->global_shutdown_func &&
- (*ptr)->global_shutdown_func()==FAILURE) {
- return FAILURE;
- }
- }
- ptr++;
- }
- return SUCCESS;
-}
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/main/logos.h b/main/logos.h
deleted file mode 100644
index 348172eae3..0000000000
--- a/main/logos.h
+++ /dev/null
@@ -1,942 +0,0 @@
-#define CONTEXT_TYPE_IMAGE_GIF "Content-Type: image/gif"
-
-unsigned char php4_logo[] = {
- 71, 73, 70, 56, 57, 97, 143, 0, 65, 0,
- 247, 255, 0, 255, 255, 255, 8, 8, 8, 16,
- 16, 16, 24, 24, 24, 33, 33, 33, 41, 41,
- 41, 49, 49, 49, 66, 66, 66, 74, 74, 74,
- 82, 82, 82, 90, 90, 90, 99, 99, 99, 107,
- 107, 107, 115, 115, 115, 123, 123, 123, 132, 132,
- 132, 140, 140, 140, 148, 148, 148, 156, 156, 156,
- 165, 165, 165, 173, 173, 173, 181, 181, 181, 189,
- 189, 189, 198, 198, 198, 206, 206, 206, 214, 214,
- 214, 222, 222, 222, 231, 231, 231, 239, 239, 239,
- 247, 247, 247, 165, 156, 156, 90, 82, 82, 231,
- 222, 206, 255, 255, 247, 214, 214, 206, 189, 189,
- 173, 165, 165, 148, 123, 123, 107, 41, 41, 33,
- 115, 115, 90, 189, 189, 140, 156, 156, 107, 148,
- 148, 99, 173, 173, 115, 198, 198, 132, 165, 165,
- 107, 173, 173, 99, 198, 198, 107, 165, 165, 82,
- 189, 189, 90, 214, 214, 99, 198, 198, 90, 181,
- 181, 82, 198, 198, 82, 222, 222, 90, 41, 41,
- 16, 231, 231, 90, 107, 107, 41, 173, 173, 66,
- 66, 66, 24, 156, 156, 57, 231, 231, 82, 214,
- 214, 74, 239, 239, 82, 24, 24, 8, 99, 99,
- 33, 198, 198, 66, 148, 148, 49, 132, 132, 41,
- 16, 16, 0, 214, 222, 90, 165, 173, 90, 140,
- 148, 82, 156, 165, 99, 132, 140, 82, 173, 181,
- 140, 156, 165, 123, 99, 107, 82, 90, 99, 82,
- 99, 107, 99, 231, 239, 239, 148, 156, 156, 66,
- 74, 74, 90, 99, 107, 231, 239, 247, 239, 247,
- 255, 132, 140, 148, 90, 107, 132, 90, 99, 115,
- 57, 66, 82, 66, 82, 115, 181, 189, 206, 148,
- 156, 173, 140, 148, 165, 82, 90, 107, 74, 82,
- 99, 8, 16, 33, 189, 206, 247, 132, 148, 189,
- 66, 82, 123, 57, 74, 115, 74, 99, 165, 222,
- 231, 255, 189, 198, 222, 90, 99, 123, 123, 140,
- 189, 198, 206, 231, 165, 173, 198, 99, 107, 132,
- 82, 90, 115, 181, 198, 255, 74, 82, 107, 156,
- 173, 231, 107, 123, 173, 49, 57, 82, 41, 49,
- 74, 90, 107, 165, 74, 90, 140, 82, 99, 156,
- 33, 41, 66, 189, 198, 231, 123, 132, 165, 165,
- 181, 239, 90, 99, 132, 140, 156, 214, 107, 123,
- 181, 57, 66, 99, 99, 115, 173, 90, 107, 173,
- 82, 99, 165, 99, 123, 214, 49, 66, 132, 24,
- 33, 66, 33, 49, 107, 214, 222, 255, 206, 214,
- 247, 181, 189, 222, 173, 181, 214, 165, 173, 206,
- 148, 156, 189, 140, 148, 181, 132, 140, 173, 156,
- 165, 206, 115, 123, 156, 107, 115, 148, 90, 99,
- 140, 156, 173, 247, 115, 132, 206, 49, 57, 90,
- 57, 66, 107, 41, 49, 82, 90, 107, 181, 82,
- 99, 173, 41, 57, 123, 24, 33, 74, 57, 82,
- 189, 206, 214, 255, 165, 173, 214, 148, 156, 198,
- 115, 123, 165, 82, 90, 132, 148, 165, 255, 66,
- 74, 115, 99, 115, 198, 41, 49, 90, 90, 107,
- 198, 82, 99, 181, 33, 41, 82, 57, 74, 156,
- 57, 74, 165, 74, 99, 214, 49, 66, 148, 66,
- 90, 206, 41, 57, 132, 66, 90, 214, 41, 66,
- 189, 24, 41, 123, 189, 198, 247, 173, 181, 231,
- 156, 165, 214, 123, 132, 181, 90, 99, 148, 90,
- 99, 156, 140, 156, 247, 74, 82, 132, 66, 74,
- 123, 99, 115, 206, 107, 123, 222, 49, 57, 107,
- 82, 99, 206, 66, 82, 173, 33, 41, 90, 57,
- 74, 173, 74, 99, 239, 49, 66, 165, 49, 66,
- 173, 57, 82, 231, 181, 189, 247, 148, 156, 214,
- 140, 148, 206, 115, 123, 181, 107, 115, 173, 99,
- 107, 165, 82, 90, 148, 66, 74, 132, 107, 123,
- 239, 90, 107, 222, 74, 90, 198, 66, 82, 198,
- 57, 74, 206, 148, 156, 222, 99, 107, 173, 107,
- 115, 189, 123, 132, 222, 99, 107, 181, 99, 107,
- 189, 74, 82, 148, 49, 57, 123, 33, 41, 115,
- 57, 74, 214, 24, 33, 123, 16, 24, 107, 140,
- 148, 239, 132, 140, 231, 115, 123, 214, 132, 140,
- 247, 99, 107, 198, 41, 49, 140, 33, 41, 140,
- 231, 231, 239, 247, 247, 255, 206, 206, 214, 181,
- 181, 189, 156, 156, 165, 107, 107, 115, 123, 123,
- 132, 214, 214, 231, 222, 222, 239, 90, 90, 99,
- 115, 115, 132, 222, 222, 255, 99, 99, 115, 90,
- 90, 107, 74, 74, 90, 148, 148, 181, 189, 189,
- 239, 115, 115, 148, 198, 198, 255, 41, 41, 57,
- 156, 156, 231, 156, 156, 239, 148, 148, 247, 33,
- 33, 57, 24, 24, 57, 8, 8, 49, 0, 0,
- 0, 44, 0, 0, 0, 0, 143, 0, 65, 0,
- 0, 8, 255, 0, 1, 8, 28, 72, 176, 160,
- 193, 131, 8, 19, 42, 92, 200, 176, 161, 67,
- 135, 237, 182, 48, 138, 3, 201, 86, 45, 72,
- 141, 214, 112, 120, 200, 177, 163, 67, 115, 28,
- 216, 157, 75, 180, 198, 209, 34, 70, 141, 26,
- 229, 201, 243, 169, 165, 203, 149, 41, 25, 45,
- 90, 180, 102, 203, 25, 13, 84, 60, 122, 52,
- 183, 37, 143, 45, 58, 182, 150, 213, 193, 85,
- 103, 153, 29, 161, 144, 214, 228, 212, 201, 148,
- 97, 135, 114, 231, 206, 40, 90, 68, 113, 153,
- 85, 161, 145, 132, 94, 21, 90, 167, 171, 215,
- 175, 68, 191, 214, 169, 245, 137, 94, 205, 12,
- 229, 204, 53, 53, 168, 70, 204, 52, 59, 117,
- 198, 120, 105, 114, 162, 238, 19, 47, 184, 172,
- 214, 97, 179, 101, 173, 95, 129, 229, 212, 40,
- 162, 165, 204, 150, 29, 59, 181, 150, 37, 190,
- 26, 73, 108, 157, 172, 142, 29, 131, 194, 69,
- 153, 104, 101, 202, 93, 35, 229, 89, 115, 110,
- 41, 211, 68, 113, 108, 141, 153, 135, 100, 198,
- 143, 211, 168, 127, 212, 40, 161, 165, 142, 45,
- 102, 86, 202, 253, 229, 104, 142, 93, 34, 170,
- 133, 109, 233, 182, 184, 213, 168, 81, 59, 186,
- 233, 0, 21, 46, 92, 25, 29, 227, 198, 129,
- 254, 52, 172, 251, 170, 215, 203, 149, 153, 213,
- 193, 184, 70, 3, 199, 14, 157, 254, 212, 241,
- 131, 4, 71, 234, 239, 167, 109, 168, 255, 24,
- 83, 171, 14, 154, 12, 106, 103, 39, 12, 172,
- 40, 78, 50, 101, 127, 114, 55, 55, 26, 156,
- 184, 253, 251, 248, 243, 231, 55, 110, 88, 239,
- 80, 232, 184, 48, 3, 201, 34, 231, 200, 166,
- 144, 57, 142, 36, 195, 76, 2, 53, 128, 231,
- 224, 105, 49, 180, 33, 20, 27, 34, 116, 160,
- 94, 65, 84, 156, 33, 6, 50, 113, 116, 168,
- 76, 110, 181, 0, 247, 147, 126, 36, 150, 104,
- 162, 126, 71, 253, 55, 6, 51, 184, 140, 145,
- 11, 40, 121, 108, 225, 89, 65, 138, 104, 231,
- 132, 119, 15, 226, 160, 131, 15, 223, 205, 208,
- 134, 29, 99, 188, 131, 129, 133, 234, 117, 112,
- 134, 35, 27, 34, 131, 204, 123, 187, 141, 120,
- 98, 137, 128, 8, 23, 37, 29, 83, 86, 41,
- 229, 147, 196, 29, 21, 9, 101, 43, 186, 8,
- 227, 22, 68, 10, 196, 142, 50, 203, 204, 99,
- 196, 131, 63, 12, 17, 192, 63, 1, 240, 152,
- 154, 143, 203, 136, 98, 197, 144, 127, 181, 131,
- 200, 49, 98, 28, 147, 6, 50, 133, 29, 166,
- 223, 148, 88, 6, 42, 40, 138, 203, 112, 153,
- 139, 151, 244, 88, 7, 128, 39, 116, 84, 2,
- 3, 154, 53, 172, 249, 207, 63, 58, 128, 231,
- 130, 80, 111, 76, 176, 193, 90, 237, 116, 194,
- 199, 49, 124, 164, 145, 12, 115, 131, 146, 56,
- 141, 26, 84, 148, 147, 234, 170, 106, 76, 83,
- 106, 160, 65, 181, 255, 56, 198, 172, 204, 228,
- 1, 26, 46, 77, 160, 137, 3, 16, 147, 78,
- 90, 41, 120, 108, 216, 34, 202, 59, 23, 132,
- 201, 209, 33, 178, 192, 1, 199, 49, 75, 26,
- 246, 106, 137, 98, 136, 80, 192, 180, 211, 154,
- 96, 128, 6, 200, 60, 155, 31, 160, 247, 217,
- 50, 212, 161, 99, 80, 70, 9, 13, 104, 238,
- 208, 235, 164, 228, 130, 151, 132, 80, 94, 76,
- 160, 232, 71, 134, 20, 35, 175, 49, 217, 58,
- 171, 45, 137, 137, 72, 112, 238, 164, 5, 148,
- 243, 199, 189, 131, 10, 53, 134, 40, 148, 72,
- 129, 35, 120, 57, 76, 122, 67, 194, 148, 58,
- 40, 67, 81, 111, 64, 80, 172, 67, 84, 112,
- 18, 70, 24, 178, 164, 97, 47, 192, 36, 170,
- 177, 192, 190, 255, 44, 192, 14, 199, 131, 146,
- 73, 201, 29, 39, 60, 56, 196, 164, 69, 8,
- 65, 132, 175, 14, 226, 112, 133, 45, 111, 60,
- 80, 193, 166, 11, 153, 99, 136, 33, 22, 31,
- 227, 231, 125, 86, 82, 121, 165, 208, 68, 7,
- 109, 229, 52, 28, 24, 0, 114, 4, 137, 144,
- 44, 40, 32, 203, 200, 113, 7, 18, 14, 70,
- 58, 41, 15, 63, 188, 220, 176, 131, 14, 216,
- 33, 202, 3, 238, 46, 68, 133, 25, 85, 24,
- 50, 203, 31, 118, 56, 109, 34, 50, 27, 8,
- 0, 242, 5, 98, 168, 29, 104, 212, 115, 80,
- 253, 157, 16, 69, 76, 26, 132, 14, 58, 4,
- 255, 49, 41, 17, 110, 126, 215, 181, 40, 14,
- 72, 144, 65, 66, 230, 80, 97, 142, 57, 135,
- 164, 177, 140, 147, 196, 113, 171, 182, 35, 232,
- 128, 60, 0, 182, 114, 99, 185, 12, 37, 115,
- 40, 1, 222, 13, 32, 239, 75, 4, 120, 239,
- 120, 253, 64, 4, 135, 31, 100, 78, 21, 0,
- 152, 131, 200, 198, 153, 235, 183, 197, 3, 32,
- 31, 208, 78, 228, 67, 27, 157, 251, 238, 69,
- 243, 14, 136, 29, 148, 88, 146, 242, 119, 230,
- 134, 222, 43, 214, 169, 225, 80, 75, 45, 95,
- 71, 128, 193, 65, 85, 168, 85, 133, 39, 118,
- 4, 98, 98, 50, 137, 156, 145, 253, 246, 218,
- 119, 207, 125, 34, 138, 28, 147, 12, 137, 237,
- 36, 0, 178, 3, 84, 36, 98, 211, 246, 91,
- 36, 130, 228, 248, 248, 33, 243, 253, 250, 244,
- 107, 191, 190, 34, 98, 192, 79, 92, 37, 150,
- 100, 97, 3, 120, 62, 224, 155, 0, 253, 246,
- 15, 192, 129, 231, 5, 112, 249, 66, 225, 82,
- 71, 16, 214, 1, 192, 12, 105, 72, 219, 137,
- 18, 97, 1, 6, 48, 160, 1, 23, 204, 32,
- 6, 55, 120, 193, 211, 81, 32, 3, 182, 209,
- 159, 112, 146, 193, 129, 2, 212, 174, 1, 40,
- 220, 96, 3, 28, 0, 1, 9, 84, 0, 132,
- 142, 112, 21, 113, 206, 224, 1, 11, 166, 240,
- 134, 56, 108, 192, 3, 36, 96, 1, 13, 176,
- 67, 17, 240, 195, 133, 28, 255, 40, 145, 4,
- 52, 161, 70, 107, 191, 250, 14, 19, 68, 35,
- 15, 176, 189, 75, 32, 209, 3, 64, 59, 148,
- 33, 193, 19, 177, 67, 1, 198, 203, 226, 164,
- 16, 96, 1, 14, 28, 227, 74, 98, 56, 135,
- 164, 180, 8, 178, 0, 40, 64, 4, 236, 200,
- 150, 112, 218, 161, 52, 50, 150, 49, 1, 23,
- 104, 7, 45, 160, 230, 7, 74, 40, 224, 96,
- 15, 66, 34, 120, 112, 240, 8, 59, 248, 65,
- 135, 20, 216, 200, 64, 168, 16, 61, 53, 208,
- 161, 138, 215, 43, 71, 27, 221, 24, 58, 41,
- 100, 128, 81, 194, 81, 132, 7, 24, 153, 197,
- 7, 248, 139, 14, 108, 27, 0, 37, 203, 232,
- 0, 14, 196, 45, 23, 148, 160, 132, 10, 140,
- 248, 3, 30, 76, 42, 112, 168, 89, 194, 31,
- 114, 241, 133, 7, 204, 41, 76, 230, 32, 155,
- 33, 226, 128, 72, 19, 137, 33, 3, 99, 220,
- 228, 185, 12, 224, 69, 225, 156, 129, 1, 186,
- 12, 93, 5, 28, 65, 7, 49, 96, 32, 152,
- 32, 83, 0, 21, 196, 96, 135, 74, 80, 194,
- 15, 49, 32, 165, 16, 26, 244, 29, 22, 244,
- 161, 14, 243, 208, 97, 216, 6, 114, 136, 157,
- 209, 2, 145, 186, 35, 154, 35, 40, 16, 186,
- 53, 5, 192, 156, 100, 252, 64, 57, 198, 199,
- 142, 69, 34, 115, 82, 31, 56, 3, 29, 18,
- 17, 1, 227, 157, 147, 77, 110, 100, 192, 20,
- 235, 80, 255, 9, 94, 188, 225, 5, 164, 4,
- 15, 11, 34, 232, 135, 120, 172, 67, 98, 97,
- 106, 71, 49, 194, 192, 204, 161, 157, 232, 12,
- 14, 0, 153, 1, 50, 64, 209, 115, 100, 0,
- 3, 23, 152, 192, 2, 114, 121, 46, 116, 40,
- 130, 14, 25, 112, 219, 190, 22, 112, 129, 10,
- 152, 212, 164, 20, 120, 128, 38, 37, 58, 50,
- 143, 129, 44, 1, 26, 200, 192, 57, 44, 122,
- 14, 11, 72, 32, 1, 28, 157, 84, 0, 48,
- 192, 40, 92, 84, 194, 15, 162, 72, 65, 64,
- 81, 131, 2, 100, 52, 179, 137, 15, 160, 0,
- 206, 4, 210, 9, 61, 24, 163, 150, 39, 154,
- 70, 57, 14, 0, 178, 5, 156, 225, 15, 113,
- 224, 16, 50, 210, 224, 137, 155, 32, 32, 116,
- 11, 80, 3, 50, 42, 16, 58, 116, 28, 131,
- 22, 105, 64, 171, 24, 196, 160, 136, 11, 136,
- 116, 151, 236, 144, 170, 59, 39, 21, 1, 68,
- 96, 85, 171, 141, 240, 132, 26, 50, 96, 66,
- 144, 61, 96, 11, 81, 170, 131, 40, 42, 65,
- 6, 117, 0, 212, 136, 44, 232, 130, 53, 176,
- 225, 7, 119, 56, 224, 1, 30, 200, 64, 152,
- 212, 192, 7, 99, 20, 102, 80, 153, 244, 43,
- 36, 241, 227, 9, 13, 188, 181, 87, 215, 114,
- 4, 237, 246, 37, 128, 12, 36, 231, 62, 103,
- 152, 235, 63, 14, 160, 6, 90, 120, 246, 109,
- 98, 56, 173, 56, 245, 149, 204, 145, 255, 9,
- 39, 46, 162, 16, 69, 46, 28, 192, 132, 23,
- 200, 0, 7, 192, 149, 193, 11, 152, 240, 8,
- 160, 48, 99, 30, 83, 120, 0, 216, 206, 97,
- 44, 79, 236, 9, 170, 39, 18, 195, 5, 66,
- 71, 1, 90, 252, 169, 29, 95, 221, 23, 1,
- 216, 113, 134, 143, 237, 203, 0, 182, 197, 143,
- 26, 84, 155, 128, 45, 120, 130, 172, 251, 26,
- 0, 7, 212, 136, 159, 63, 136, 17, 100, 82,
- 8, 239, 33, 91, 4, 46, 162, 100, 101, 49,
- 70, 193, 133, 31, 20, 248, 0, 8, 124, 208,
- 88, 236, 136, 67, 31, 100, 27, 40, 122, 150,
- 241, 28, 255, 210, 207, 21, 45, 183, 129, 118,
- 80, 117, 95, 13, 144, 39, 126, 0, 113, 142,
- 149, 158, 203, 1, 142, 72, 196, 104, 207, 133,
- 128, 219, 145, 232, 28, 159, 221, 162, 124, 133,
- 3, 151, 203, 60, 71, 20, 126, 64, 110, 3,
- 14, 234, 194, 165, 14, 36, 17, 182, 80, 70,
- 45, 94, 245, 75, 137, 26, 146, 124, 15, 222,
- 101, 170, 8, 0, 50, 9, 124, 52, 126, 232,
- 221, 215, 4, 60, 193, 14, 243, 237, 203, 1,
- 18, 206, 207, 52, 46, 144, 211, 4, 140, 248,
- 56, 36, 246, 207, 50, 198, 192, 185, 199, 182,
- 240, 133, 130, 44, 8, 35, 44, 2, 221, 19,
- 97, 183, 170, 77, 211, 79, 102, 247, 133, 0,
- 42, 224, 18, 100, 24, 136, 27, 103, 33, 112,
- 96, 49, 108, 128, 255, 199, 251, 162, 0, 49,
- 245, 67, 11, 114, 130, 140, 1, 73, 38, 81,
- 114, 198, 96, 137, 57, 168, 3, 2, 21, 208,
- 128, 177, 10, 242, 9, 171, 64, 14, 75, 127,
- 40, 71, 95, 207, 21, 129, 205, 114, 118, 186,
- 126, 237, 128, 157, 207, 69, 128, 117, 230, 39,
- 17, 222, 61, 87, 1, 52, 224, 137, 99, 238,
- 43, 0, 26, 176, 174, 126, 58, 17, 209, 30,
- 135, 249, 73, 66, 156, 195, 20, 32, 96, 129,
- 65, 23, 36, 49, 174, 41, 149, 107, 67, 252,
- 15, 184, 145, 15, 152, 111, 163, 66, 169, 207,
- 149, 0, 15, 227, 135, 29, 57, 238, 149, 147,
- 59, 65, 91, 74, 95, 50, 63, 127, 112, 48,
- 200, 4, 160, 1, 53, 71, 181, 14, 156, 147,
- 7, 171, 179, 124, 144, 242, 196, 122, 80, 142,
- 8, 114, 175, 46, 215, 7, 253, 40, 2, 3,
- 121, 35, 115, 170, 130, 61, 169, 191, 74, 142,
- 14, 82, 133, 243, 185, 32, 160, 62, 92, 115,
- 248, 201, 196, 161, 32, 88, 125, 253, 164, 168,
- 221, 193, 11, 54, 163, 182, 65, 202, 131, 139,
- 180, 133, 83, 119, 179, 131, 111, 57, 244, 115,
- 12, 13, 168, 246, 31, 22, 184, 137, 133, 123,
- 133, 142, 57, 223, 39, 13, 103, 222, 151, 5,
- 244, 170, 218, 5, 156, 250, 62, 137, 208, 192,
- 162, 123, 181, 83, 135, 159, 8, 16, 184, 152,
- 195, 29, 154, 88, 1, 125, 23, 36, 15, 148,
- 255, 153, 241, 160, 202, 119, 62, 121, 2, 66,
- 25, 211, 72, 6, 45, 186, 154, 129, 236, 238,
- 171, 215, 158, 128, 244, 185, 152, 45, 234, 251,
- 100, 123, 217, 26, 72, 67, 133, 65, 6, 1,
- 98, 194, 60, 230, 92, 173, 233, 198, 123, 245,
- 128, 49, 9, 106, 12, 34, 143, 71, 82, 77,
- 78, 16, 122, 80, 102, 25, 131, 74, 70, 57,
- 212, 221, 171, 8, 104, 224, 28, 23, 56, 7,
- 6, 48, 128, 142, 155, 230, 244, 31, 5, 200,
- 128, 252, 216, 252, 221, 114, 200, 16, 181, 13,
- 168, 157, 28, 39, 125, 174, 9, 100, 32, 236,
- 98, 47, 105, 4, 14, 254, 15, 119, 116, 128,
- 189, 88, 170, 196, 29, 238, 208, 128, 105, 43,
- 228, 28, 204, 24, 67, 29, 6, 101, 204, 114,
- 162, 243, 236, 148, 214, 192, 71, 23, 188, 47,
- 6, 192, 123, 26, 202, 134, 240, 25, 60, 177,
- 225, 115, 157, 83, 82, 144, 239, 213, 1, 58,
- 224, 108, 205, 201, 1, 31, 89, 56, 232, 196,
- 18, 210, 129, 45, 141, 225, 208, 38, 82, 68,
- 177, 223, 249, 143, 4, 108, 224, 163, 152, 95,
- 250, 63, 36, 208, 137, 252, 196, 97, 3, 11,
- 159, 212, 4, 28, 161, 8, 35, 211, 254, 31,
- 10, 40, 135, 199, 159, 52, 141, 92, 204, 129,
- 31, 243, 56, 157, 8, 210, 147, 144, 69, 184,
- 104, 241, 129, 82, 131, 187, 145, 25, 128, 6,
- 244, 146, 14, 174, 205, 105, 255, 154, 243, 115,
- 12, 157, 115, 92, 4, 98, 56, 3, 215, 131,
- 73, 128, 8, 44, 243, 85, 148, 224, 199, 29,
- 164, 174, 84, 134, 112, 0, 20, 185, 200, 5,
- 236, 245, 35, 215, 119, 14, 160, 1, 27, 32,
- 86, 196, 225, 8, 19, 192, 96, 128, 23, 111,
- 108, 119, 46, 38, 32, 71, 24, 16, 122, 90,
- 212, 126, 70, 34, 66, 88, 2, 114, 119, 192,
- 15, 89, 208, 95, 93, 212, 16, 107, 144, 91,
- 204, 128, 37, 179, 38, 81, 8, 128, 0, 7,
- 32, 130, 33, 152, 0, 12, 176, 67, 113, 212,
- 22, 247, 177, 5, 19, 112, 0, 35, 248, 130,
- 250, 164, 31, 103, 176, 119, 36, 232, 130, 77,
- 151, 6, 149, 83, 59, 36, 248, 5, 35, 136,
- 0, 10, 192, 0, 16, 48, 1, 24, 208, 14,
- 173, 37, 28, 151, 96, 34, 128, 2, 8, 80,
- 35, 7, 252, 224, 103, 235, 144, 14, 79, 180,
- 16, 144, 144, 91, 184, 240, 36, 231, 197, 96,
- 237, 192, 14, 90, 184, 133, 220, 181, 5, 142,
- 64, 24, 19, 38, 6, 92, 184, 133, 237, 240,
- 69, 249, 65, 100, 89, 56, 134, 98, 224, 8,
- 245, 180, 47, 5, 64, 5, 89, 88, 15, 245,
- 176, 133, 106, 160, 61, 158, 192, 39, 82, 114,
- 9, 231, 6, 52, 145, 19, 8, 130, 199, 15,
- 173, 100, 5, 23, 48, 35, 11, 145, 1, 90,
- 64, 6, 162, 128, 117, 80, 18, 112, 223, 117,
- 59, 214, 255, 67, 28, 143, 184, 135, 36, 242,
- 136, 38, 66, 137, 246, 113, 6, 113, 183, 47,
- 31, 16, 94, 226, 96, 10, 37, 98, 10, 226,
- 240, 113, 246, 49, 8, 191, 96, 129, 14, 96,
- 15, 92, 16, 133, 12, 177, 129, 149, 144, 136,
- 38, 82, 100, 47, 117, 99, 177, 19, 40, 128,
- 48, 85, 32, 99, 5, 137, 128, 9, 82, 82,
- 13, 186, 160, 135, 190, 168, 132, 74, 168, 11,
- 158, 40, 138, 116, 144, 11, 164, 80, 8, 150,
- 208, 0, 246, 64, 11, 23, 160, 19, 92, 64,
- 88, 174, 168, 31, 90, 167, 123, 13, 240, 99,
- 179, 136, 37, 200, 160, 1, 193, 247, 15, 107,
- 96, 12, 215, 32, 14, 122, 88, 10, 197, 160,
- 15, 187, 80, 142, 187, 224, 12, 186, 80, 10,
- 224, 80, 10, 152, 176, 135, 220, 18, 37, 185,
- 96, 9, 133, 128, 10, 202, 240, 9, 56, 72,
- 136, 15, 209, 5, 149, 176, 143, 216, 135, 31,
- 198, 148, 83, 19, 80, 122, 215, 104, 34, 158,
- 96, 1, 64, 103, 93, 215, 80, 13, 130, 224,
- 11, 117, 0, 1, 246, 192, 6, 246, 240, 14,
- 108, 128, 13, 181, 48, 10, 215, 208, 11, 165,
- 112, 9, 26, 9, 140, 192, 40, 52, 152, 144,
- 13, 115, 96, 9, 131, 128, 10, 184, 128, 13,
- 198, 112, 8, 22, 178, 58, 14, 244, 16, 86,
- 240, 83, 126, 80, 133, 146, 163, 8, 5, 248,
- 54, 18, 56, 144, 248, 146, 128, 160, 255, 69,
- 5, 174, 18, 8, 215, 160, 15, 89, 128, 1,
- 27, 192, 1, 66, 185, 1, 27, 0, 2, 7,
- 112, 9, 187, 32, 8, 24, 121, 13, 26, 105,
- 10, 215, 96, 10, 26, 121, 9, 111, 145, 13,
- 131, 160, 13, 131, 112, 13, 94, 0, 2, 8,
- 240, 13, 146, 192, 9, 240, 96, 6, 240, 64,
- 125, 31, 241, 140, 63, 21, 141, 51, 180, 125,
- 147, 66, 0, 231, 96, 147, 88, 66, 121, 231,
- 194, 0, 178, 8, 8, 165, 32, 7, 29, 128,
- 1, 43, 196, 0, 35, 0, 0, 15, 144, 9,
- 165, 80, 10, 170, 192, 10, 208, 240, 12, 24,
- 217, 11, 170, 240, 151, 207, 112, 13, 129, 144,
- 13, 217, 48, 12, 190, 96, 10, 155, 240, 6,
- 33, 48, 15, 223, 224, 6, 110, 96, 8, 100,
- 35, 150, 14, 209, 1, 232, 160, 5, 126, 224,
- 7, 149, 80, 133, 196, 81, 14, 11, 64, 0,
- 212, 82, 0, 4, 208, 0, 136, 192, 150, 81,
- 85, 14, 9, 64, 154, 212, 66, 0, 20, 112,
- 106, 151, 240, 13, 162, 144, 0, 6, 240, 8,
- 86, 80, 0, 27, 160, 1, 148, 80, 10, 186,
- 160, 10, 131, 224, 5, 86, 176, 14, 126, 48,
- 14, 193, 67, 9, 235, 240, 0, 126, 80, 8,
- 169, 224, 11, 198, 153, 156, 16, 16, 153, 183,
- 224, 6, 247, 0, 15, 81, 196, 20, 26, 192,
- 6, 207, 4, 84, 88, 7, 8, 50, 66, 5,
- 224, 185, 42, 229, 255, 32, 144, 170, 153, 31,
- 103, 16, 158, 171, 2, 135, 162, 6, 8, 215,
- 80, 12, 223, 96, 10, 200, 224, 6, 89, 80,
- 1, 0, 144, 0, 166, 32, 8, 206, 192, 11,
- 13, 0, 0, 33, 0, 0, 29, 96, 2, 19,
- 32, 2, 214, 209, 159, 37, 160, 13, 195, 144,
- 0, 27, 65, 36, 8, 48, 157, 247, 96, 8,
- 85, 112, 157, 58, 177, 1, 93, 64, 48, 207,
- 148, 11, 138, 88, 158, 215, 104, 10, 186, 80,
- 13, 213, 112, 11, 104, 80, 2, 122, 41, 15,
- 146, 176, 11, 168, 240, 1, 0, 16, 119, 3,
- 176, 0, 154, 144, 5, 0, 128, 1, 252, 208,
- 15, 19, 0, 0, 7, 128, 15, 33, 112, 1,
- 248, 208, 15, 14, 0, 0, 243, 224, 13, 148,
- 105, 157, 43, 201, 20, 117, 201, 6, 206, 68,
- 9, 159, 121, 161, 19, 230, 59, 72, 218, 59,
- 74, 250, 111, 14, 245, 113, 186, 160, 15, 199,
- 176, 0, 0, 80, 1, 115, 160, 15, 225, 224,
- 11, 8, 176, 1, 230, 32, 1, 19, 144, 0,
- 221, 64, 12, 119, 192, 1, 16, 160, 13, 209,
- 48, 7, 39, 170, 0, 29, 192, 15, 175, 176,
- 13, 144, 57, 15, 12, 234, 160, 139, 227, 23,
- 29, 176, 1, 19, 208, 6, 117, 244, 76, 162,
- 208, 143, 24, 74, 50, 128 ,
- 32, 14, 213, 160, 15, 223, 160, 9, 23, 192,
- 1, 7, 144, 8, 179, 240, 14, 115, 32, 165,
- 29, 32, 2, 27, 255, 240, 4, 228, 16, 12,
- 154, 192, 1, 17, 0, 11, 193, 112, 7, 33,
- 240, 0, 11, 192, 1, 253, 64, 12, 196, 160,
- 5, 145, 169, 15, 212, 105, 157, 113, 250, 23,
- 29, 160, 1, 92, 224, 5, 161, 20, 74, 159,
- 233, 111, 68, 179, 167, 131, 210, 167, 249, 240,
- 13, 183, 144, 13, 57, 186, 0, 6, 96, 5,
- 82, 80, 1, 14, 0, 6, 32, 138, 83, 3,
- 128, 0, 227, 16, 166, 17, 192, 13, 96, 26,
- 2, 16, 80, 0, 0, 16, 1, 242, 168, 14,
- 245, 169, 7, 150, 57, 170, 23, 194, 1, 25,
- 208, 5, 88, 144, 170, 120, 26, 107, 146, 232,
- 170, 80, 50, 10, 213, 144, 12, 38, 234, 159,
- 28, 16, 148, 201, 186, 12, 191, 64, 2, 0,
- 192, 1, 29, 16, 2, 7, 0, 6, 146, 58,
- 8, 149, 26, 2, 81, 224, 15, 15, 224, 159,
- 155, 50, 2, 150, 112, 15, 63, 122, 33, 3,
- 33, 173, 20, 192, 6, 117, 52, 68, 21, 122,
- 109, 217, 170, 173, 248, 161, 11, 149, 112, 0,
- 42, 148, 66, 6, 128, 13, 168, 80, 8, 142,
- 229, 0, 243, 128, 13, 164, 208, 4, 6, 128,
- 12, 161, 80, 9, 10, 112, 0, 163, 128, 9,
- 217, 132, 169, 117, 224, 13, 247, 128, 153, 250,
- 186, 175, 26, 80, 1, 15, 240, 6, 148, 32,
- 7, 150, 0, 176, 162, 144, 23, 63, 49, 176,
- 174, 202, 158, 186, 176, 142, 215, 176, 6, 232,
- 255, 176, 6, 56, 187, 8, 129, 112, 149, 214,
- 96, 7, 190, 128, 13, 182, 128, 12, 199, 32,
- 13, 198, 32, 11, 156, 224, 6, 146, 32, 13,
- 178, 16, 6, 110, 224, 13, 147, 112, 12, 178,
- 192, 51, 247, 96, 6, 34, 59, 178, 2, 49,
- 167, 24, 144, 14, 239, 128, 170, 42, 187, 178,
- 68, 218, 178, 143, 35, 37, 174, 18, 37, 76,
- 186, 164, 73, 170, 59, 128, 48, 13, 151, 192,
- 148, 152, 208, 21, 222, 96, 8, 250, 144, 15,
- 114, 155, 15, 216, 240, 6, 241, 16, 7, 123,
- 34, 6, 53, 161, 6, 13, 106, 6, 102, 112,
- 180, 94, 105, 8, 247, 208, 163, 209, 179, 58,
- 95, 105, 181, 172, 39, 173, 23, 208, 5, 234,
- 224, 5, 89, 32, 7, 93, 203, 178, 185, 64,
- 20, 192, 193, 59, 218, 242, 142, 196, 17, 20,
- 216, 192, 12, 160, 36, 7, 115, 144, 13, 105,
- 192, 12, 188, 144, 13, 210, 81, 11, 246, 208,
- 95, 18, 224, 8, 210, 128, 7, 132, 84, 5,
- 126, 27, 61, 96, 105, 157, 84, 0, 15, 59,
- 163, 56, 3, 17, 75, 249, 138, 184, 5, 209,
- 1, 138, 75, 1, 86, 16, 15, 95, 0, 185,
- 33, 25, 146, 0, 235, 153, 45, 91, 20, 97,
- 203, 135, 47, 23, 37, 99, 171, 12, 231, 54,
- 31, 117, 144, 11, 40, 150, 178, 125, 54, 120,
- 119, 112, 10, 181, 64, 9, 243, 128, 5, 58,
- 4, 1, 17, 48, 1, 20, 255, 128, 1, 62,
- 52, 181, 13, 1, 173, 4, 177, 58, 186, 155,
- 51, 225, 138, 1, 22, 48, 1, 235, 160, 14,
- 88, 224, 7, 42, 59, 7, 244, 27, 146, 43,
- 59, 68, 157, 185, 143, 185, 165, 91, 0, 82,
- 25, 210, 155, 91, 251, 120, 167, 158, 43, 114,
- 214, 107, 189, 115, 48, 15, 95, 192, 6, 143,
- 160, 92, 223, 75, 1, 23, 144, 1, 27, 16,
- 38, 133, 203, 16, 85, 123, 187, 233, 219, 16,
- 79, 161, 1, 236, 75, 1, 81, 176, 14, 104,
- 32, 15, 95, 48, 15, 194, 91, 191, 36, 92,
- 194, 38, 44, 114, 244, 91, 192, 42, 60, 7,
- 89, 144, 5, 8, 60, 5, 221, 27, 1, 92,
- 90, 1, 15, 172, 1, 232, 122, 193, 56, 156,
- 153, 225, 122, 81, 22, 64, 1, 19, 32, 1,
- 16, 240, 190, 88, 224, 5, 95, 16, 194, 243,
- 208, 194, 143, 59, 192, 36, 236, 185, 114, 144,
- 5, 218, 139, 192, 95, 224, 5, 242, 160, 14,
- 43, 212, 95, 50, 236, 1, 20, 80, 1, 22,
- 32, 190, 65, 233, 106, 57, 252, 197, 13, 17,
- 2, 169, 18, 83, 24, 101, 1, 21, 224, 195,
- 233, 32, 1, 81, 16, 1, 108, 12, 1, 110,
- 252, 198, 112, 236, 198, 108, 44, 195, 92, 74,
- 1, 20, 96, 1, 91, 44, 160, 54, 220, 1,
- 94, 12, 198, 126, 172, 19, 124, 204, 187, 68,
- 169, 1, 49, 117, 81, 99, 119, 1, 136, 156,
- 200, 136, 16, 60, 118, 24, 64, 81, 132, 76,
- 148, 232, 202, 199, 127, 172, 19, 1, 1, 0,
- 59 };
-
-unsigned char zend_logo[] = {
- 71, 73, 70, 56, 57, 97, 100, 0, 58, 0,
- 247, 255, 0, 255, 255, 255, 8, 8, 8, 24,
- 24, 24, 57, 57, 57, 74, 74, 74, 90, 90,
- 90, 99, 99, 99, 123, 123, 123, 132, 132, 132,
- 140, 140, 140, 148, 148, 148, 189, 189, 189, 214,
- 214, 214, 231, 231, 231, 239, 239, 239, 90, 99,
- 99, 222, 231, 239, 57, 66, 74, 165, 173, 181,
- 0, 8, 16, 214, 222, 231, 57, 66, 82, 16,
- 33, 66, 0, 8, 24, 24, 41, 82, 222, 231,
- 255, 57, 66, 90, 198, 206, 231, 181, 189, 214,
- 99, 107, 132, 0, 8, 33, 189, 198, 231, 123,
- 132, 165, 148, 165, 231, 123, 140, 206, 123, 148,
- 239, 49, 66, 132, 24, 33, 66, 49, 74, 165,
- 214, 222, 255, 206, 214, 247, 181, 189, 222, 148,
- 156, 189, 123, 132, 173, 156, 173, 247, 132, 148,
- 214, 99, 115, 181, 49, 57, 90, 41, 49, 82,
- 90, 107, 181, 82, 99, 173, 24, 33, 74, 57,
- 82, 189, 49, 74, 173, 16, 24, 57, 8, 16,
- 49, 198, 206, 247, 181, 189, 231, 165, 173, 214,
- 99, 107, 148, 74, 82, 123, 140, 156, 239, 66,
- 74, 115, 115, 132, 222, 41, 49, 90, 57, 74,
- 165, 49, 66, 148, 49, 66, 156, 41, 57, 140,
- 57, 82, 206, 33, 49, 123, 57, 82, 214, 16,
- 24, 66, 198, 206, 255, 181, 189, 239, 189, 198,
- 255, 156, 165, 214, 140, 148, 198, 132, 140, 189,
- 115, 123, 173, 90, 99, 148, 132, 148, 247, 123,
- 140, 239, 107, 123, 214, 115, 132, 231, 57, 66,
- 115, 107, 123, 222, 115, 132, 239, 57, 66, 123,
- 99, 115, 214, 90, 107, 214, 74, 90, 181, 74,
- 90, 189, 66, 82, 173, 57, 74, 173, 49, 66,
- 165, 66, 90, 231, 49, 66, 173, 24, 33, 90,
- 41, 57, 156, 33, 49, 140, 8, 16, 66, 181,
- 189, 247, 165, 173, 231, 148, 156, 214, 132, 140,
- 198, 115, 123, 181, 82, 90, 148, 49, 57, 115,
- 99, 115, 231, 90, 107, 231, 82, 99, 214, 82,
- 99, 222, 74, 90, 206, 82, 99, 231, 66, 82,
- 189, 33, 41, 99, 57, 74, 189, 57, 74, 198,
- 57, 74, 206, 49, 66, 181, 41, 57, 165, 24,
- 33, 99, 16, 24, 82, 8, 16, 74, 173, 181,
- 247, 173, 181, 255, 165, 173, 247, 140, 148, 214,
- 156, 165, 239, 165, 173, 255, 156, 165, 247, 132,
- 140, 214, 140, 148, 231, 99, 107, 173, 107, 115,
- 189, 115, 123, 206, 123, 132, 222, 99, 107, 189,
- 82, 90, 165, 90, 99, 181, 74, 82, 156, 82,
- 90, 173, 90, 99, 189, 66, 74, 140, 57, 66,
- 140, 57, 66, 148, 41, 49, 115, 74, 90, 222,
- 74, 90, 231, 41, 49, 132, 66, 82, 222, 33,
- 41, 115, 33, 41, 123, 24, 33, 107, 24, 33,
- 123, 16, 24, 90, 148, 156, 247, 140, 148, 239,
- 132, 140, 231, 140, 148, 247, 132, 140, 239, 123,
- 132, 231, 107, 115, 206, 123, 132, 239, 123, 132,
- 247, 99, 107, 206, 99, 107, 214, 82, 90, 181,
- 90, 99, 206, 49, 57, 148, 41, 49, 148, 33,
- 41, 140, 239, 239, 247, 247, 247, 255, 198, 198,
- 206, 214, 214, 222, 173, 173, 181, 189, 189, 198,
- 148, 148, 156, 156, 156, 165, 231, 231, 247, 239,
- 239, 255, 173, 173, 189, 90, 90, 99, 231, 231,
- 255, 222, 222, 247, 140, 140, 156, 66, 66, 74,
- 132, 132, 148, 198, 198, 222, 123, 123, 140, 173,
- 173, 198, 107, 107, 123, 222, 222, 255, 57, 57,
- 66, 49, 49, 57, 156, 156, 181, 198, 198, 231,
- 140, 140, 165, 181, 181, 214, 90, 90, 107, 214,
- 214, 255, 165, 165, 198, 82, 82, 99, 123, 123,
- 148, 74, 74, 90, 115, 115, 140, 33, 33, 41,
- 99, 99, 123, 156, 156, 198, 90, 90, 115, 132,
- 132, 173, 173, 173, 231, 165, 165, 222, 24, 24,
- 33, 82, 82, 115, 156, 156, 222, 115, 115, 165,
- 57, 57, 82, 107, 107, 156, 123, 123, 181, 33,
- 33, 49, 156, 156, 231, 82, 82, 123, 49, 49,
- 74, 107, 107, 165, 74, 74, 115, 148, 148, 231,
- 57, 57, 90, 41, 41, 66, 82, 82, 132, 66,
- 66, 107, 132, 132, 214, 140, 140, 231, 99, 99,
- 165, 123, 123, 206, 66, 66, 115, 82, 82, 148,
- 123, 123, 222, 66, 66, 123, 8, 8, 16, 41,
- 41, 82, 49, 49, 99, 24, 24, 49, 41, 41,
- 90, 24, 24, 66, 8, 8, 24, 16, 16, 57,
- 8, 8, 41, 8, 8, 49, 8, 8, 57, 0,
- 0, 8, 0, 0, 16, 0, 0, 24, 0, 0,
- 0, 44, 0, 0, 0, 0, 100, 0, 58, 0,
- 0, 8, 255, 0, 255, 9, 28, 72, 176, 160,
- 193, 131, 8, 19, 42, 92, 200, 176, 161, 195,
- 135, 188, 146, 37, 131, 246, 176, 226, 193, 94,
- 188, 10, 6, 203, 104, 177, 99, 67, 99, 31,
- 140, 25, 75, 230, 177, 227, 200, 130, 39, 75,
- 170, 60, 104, 12, 87, 128, 103, 198, 40, 174,
- 108, 248, 1, 87, 193, 154, 51, 115, 10, 52,
- 198, 236, 31, 175, 15, 196, 124, 246, 58, 150,
- 17, 227, 203, 0, 2, 122, 9, 240, 121, 140,
- 232, 191, 94, 201, 130, 57, 229, 213, 148, 227,
- 63, 103, 199, 96, 218, 36, 104, 172, 89, 47,
- 140, 2, 159, 57, 19, 232, 236, 153, 206, 143,
- 199, 130, 33, 43, 118, 213, 216, 50, 96, 31,
- 4, 24, 139, 230, 204, 152, 179, 100, 198, 4,
- 240, 50, 166, 2, 88, 76, 144, 200, 144, 17,
- 53, 86, 12, 46, 69, 188, 133, 113, 114, 229,
- 11, 55, 104, 49, 14, 1, 226, 113, 56, 118,
- 150, 33, 72, 99, 207, 2, 252, 3, 70, 249,
- 222, 200, 98, 199, 122, 141, 236, 165, 226, 159,
- 138, 98, 206, 150, 113, 240, 92, 44, 192, 215,
- 211, 169, 145, 45, 93, 214, 235, 95, 128, 148,
- 3, 63, 4, 179, 13, 172, 54, 177, 145, 184,
- 140, 5, 173, 172, 176, 37, 87, 146, 255, 70,
- 23, 251, 0, 90, 119, 114, 99, 28, 158, 45,
- 197, 45, 50, 250, 210, 228, 200, 21, 15, 52,
- 254, 175, 169, 192, 99, 129, 41, 19, 255, 231,
- 103, 142, 31, 203, 158, 3, 139, 45, 227, 5,
- 19, 26, 94, 96, 204, 66, 82, 124, 187, 173,
- 236, 94, 244, 255, 150, 173, 103, 159, 177, 24,
- 178, 8, 120, 225, 183, 211, 49, 196, 224, 149,
- 76, 63, 252, 252, 6, 212, 66, 252, 152, 87,
- 145, 57, 30, 176, 132, 156, 64, 208, 112, 0,
- 82, 52, 255, 64, 163, 155, 0, 31, 44, 67,
- 33, 50, 74, 228, 128, 12, 52, 184, 85, 8,
- 24, 69, 208, 32, 35, 18, 78, 14, 254, 19,
- 82, 72, 102, 245, 211, 207, 63, 130, 49, 56,
- 163, 69, 48, 208, 115, 16, 52, 154, 17, 20,
- 0, 49, 215, 253, 131, 75, 60, 255, 108, 227,
- 141, 64, 252, 208, 163, 193, 112, 60, 22, 68,
- 204, 112, 3, 17, 3, 141, 0, 68, 182, 56,
- 37, 49, 247, 8, 116, 207, 5, 117, 89, 117,
- 80, 63, 19, 180, 248, 144, 61, 230, 204, 196,
- 15, 130, 252, 120, 83, 130, 152, 30, 177, 57,
- 80, 63, 30, 168, 224, 97, 66, 112, 186, 217,
- 208, 61, 224, 220, 168, 210, 4, 253, 204, 80,
- 142, 78, 13, 30, 196, 143, 7, 214, 96, 67,
- 103, 62, 122, 90, 196, 79, 59, 24, 204, 212,
- 79, 60, 232, 228, 3, 168, 157, 255, 240, 147,
- 143, 62, 148, 122, 224, 1, 165, 13, 149, 160,
- 205, 13, 156, 50, 228, 79, 62, 80, 72, 170,
- 83, 162, 5, 121, 80, 70, 62, 108, 242, 51,
- 65, 62, 155, 170, 255, 212, 15, 15, 226, 220,
- 224, 15, 159, 97, 226, 10, 230, 174, 97, 54,
- 24, 232, 160, 85, 156, 147, 37, 160, 168, 34,
- 233, 1, 31, 248, 120, 208, 107, 131, 23, 232,
- 147, 44, 167, 215, 228, 115, 77, 177, 72, 222,
- 144, 134, 19, 24, 224, 3, 171, 7, 247, 116,
- 219, 45, 183, 223, 198, 19, 79, 0, 174, 246,
- 67, 135, 33, 166, 2, 122, 129, 160, 249, 240,
- 177, 71, 62, 247, 140, 27, 192, 61, 250, 240,
- 161, 15, 181, 3, 221, 67, 79, 56, 229, 192,
- 96, 14, 168, 3, 241, 19, 128, 7, 108, 4,
- 98, 141, 59, 24, 216, 99, 195, 194, 12, 51,
- 76, 15, 61, 210, 114, 235, 129, 61, 46, 208,
- 17, 79, 168, 22, 249, 211, 42, 63, 55, 136,
- 161, 7, 18, 55, 72, 124, 195, 30, 72, 196,
- 202, 96, 60, 54, 148, 179, 195, 57, 155, 186,
- 26, 207, 61, 54, 72, 130, 130, 25, 138, 68,
- 194, 198, 36, 56, 231, 140, 51, 29, 98, 204,
- 96, 129, 13, 244, 76, 130, 134, 17, 218, 226,
- 235, 209, 5, 254, 20, 196, 207, 61, 248, 232,
- 145, 137, 30, 51, 148, 64, 143, 13, 30, 235,
- 67, 228, 67, 150, 142, 115, 142, 61, 19, 220,
- 35, 173, 13, 108, 120, 146, 203, 18, 158, 88,
- 49, 69, 22, 103, 79, 113, 202, 217, 169, 116,
- 65, 2, 29, 116, 44, 242, 13, 36, 249, 228,
- 179, 79, 62, 73, 43, 250, 101, 132, 72, 242,
- 255, 19, 143, 7, 72, 104, 194, 10, 17, 152,
- 96, 48, 131, 38, 152, 204, 224, 193, 197, 21,
- 45, 61, 79, 19, 240, 212, 51, 3, 6, 24,
- 24, 241, 67, 18, 174, 228, 146, 196, 18, 156,
- 115, 190, 249, 18, 130, 128, 194, 69, 23, 228,
- 152, 33, 9, 61, 209, 210, 83, 198, 13, 23,
- 152, 23, 232, 5, 30, 92, 19, 175, 140, 247,
- 132, 121, 177, 157, 253, 232, 179, 110, 131, 127,
- 95, 51, 3, 38, 171, 124, 177, 138, 17, 70,
- 168, 66, 7, 62, 215, 244, 26, 112, 131, 50,
- 226, 126, 13, 36, 213, 144, 19, 131, 36, 108,
- 64, 50, 133, 31, 185, 0, 0, 128, 43, 220,
- 111, 207, 125, 230, 126, 72, 177, 4, 14, 93,
- 248, 140, 4, 29, 152, 32, 206, 70, 21, 243,
- 200, 83, 78, 57, 219, 208, 115, 65, 60, 176,
- 75, 235, 79, 188, 189, 146, 75, 16, 63, 251,
- 232, 115, 143, 223, 250, 154, 129, 24, 44, 49,
- 4, 46, 60, 162, 17, 142, 24, 67, 61, 44,
- 128, 4, 120, 45, 235, 76, 19, 208, 212, 176,
- 12, 210, 143, 124, 96, 33, 16, 56, 240, 132,
- 41, 136, 113, 13, 1, 64, 163, 131, 83, 10,
- 161, 7, 71, 8, 141, 10, 173, 65, 18, 139,
- 64, 68, 54, 190, 145, 142, 67, 24, 129, 14,
- 51, 136, 161, 13, 22, 39, 174, 111, 105, 10,
- 92, 241, 242, 155, 175, 252, 182, 15, 36, 220,
- 205, 3, 55, 176, 128, 24, 255, 38, 65, 132,
- 24, 112, 224, 131, 196, 88, 132, 17, 48, 161,
- 135, 61, 36, 235, 30, 254, 64, 218, 61, 36,
- 72, 169, 165, 221, 192, 29, 223, 80, 70, 18,
- 130, 212, 144, 3, 228, 226, 15, 102, 248, 195,
- 33, 26, 177, 10, 34, 104, 98, 6, 72, 128,
- 88, 180, 174, 113, 13, 77, 229, 227, 6, 55,
- 88, 216, 195, 110, 208, 70, 111, 141, 235, 101,
- 251, 224, 4, 39, 98, 136, 129, 122, 16, 81,
- 8, 136, 128, 133, 102, 4, 16, 131, 49, 172,
- 34, 19, 154, 216, 195, 221, 46, 85, 55, 88,
- 5, 74, 80, 241, 200, 135, 5, 136, 48, 133,
- 36, 200, 164, 33, 3, 112, 133, 45, 146, 48,
- 10, 35, 120, 12, 19, 155, 96, 162, 24, 12,
- 103, 1, 123, 32, 97, 97, 37, 40, 193, 228,
- 48, 48, 202, 61, 76, 78, 106, 106, 236, 86,
- 62, 108, 160, 7, 77, 100, 2, 19, 153, 176,
- 4, 17, 134, 16, 132, 64, 106, 230, 26, 169,
- 192, 195, 42, 44, 161, 9, 78, 32, 161, 12,
- 251, 184, 193, 182, 254, 87, 197, 8, 218, 0,
- 3, 68, 24, 197, 53, 4, 114, 0, 90, 40,
- 64, 1, 214, 196, 102, 2, 122, 244, 143, 5,
- 0, 224, 15, 93, 152, 68, 61, 244, 64, 7,
- 75, 144, 161, 140, 150, 120, 33, 220, 198, 57,
- 78, 244, 101, 194, 8, 233, 92, 34, 220, 48,
- 144, 74, 160, 77, 13, 3, 182, 36, 3, 17,
- 86, 49, 255, 134, 47, 212, 160, 14, 63, 16,
- 228, 63, 4, 144, 5, 47, 172, 130, 137, 122,
- 68, 22, 188, 186, 165, 49, 133, 136, 139, 30,
- 208, 252, 196, 117, 24, 160, 73, 87, 120, 15,
- 0, 10, 24, 72, 1, 0, 224, 135, 57, 168,
- 179, 156, 252, 12, 131, 72, 195, 96, 130, 49,
- 8, 65, 8, 68, 72, 233, 42, 134, 240, 133,
- 48, 124, 1, 15, 97, 168, 193, 23, 136, 96,
- 137, 121, 174, 18, 19, 68, 24, 67, 30, 90,
- 234, 133, 158, 210, 32, 160, 154, 129, 70, 22,
- 194, 64, 4, 158, 113, 130, 100, 250, 192, 155,
- 140, 16, 148, 16, 129, 121, 109, 18, 159, 176,
- 69, 1, 8, 64, 0, 6, 36, 193, 15, 75,
- 224, 158, 50, 100, 209, 35, 1, 52, 64, 25,
- 169, 136, 196, 11, 49, 161, 203, 49, 132, 1,
- 15, 115, 136, 195, 35, 82, 193, 5, 60, 224,
- 161, 167, 117, 240, 66, 29, 236, 96, 135, 59,
- 164, 53, 21, 143, 216, 66, 35, 134, 64, 4,
- 156, 97, 2, 158, 121, 16, 41, 30, 234, 192,
- 133, 84, 164, 226, 13, 63, 104, 192, 32, 181,
- 16, 6, 98, 138, 225, 168, 253, 83, 214, 163,
- 152, 218, 212, 123, 148, 128, 17, 202, 88, 2,
- 10, 114, 193, 89, 63, 68, 97, 9, 0, 56,
- 65, 18, 134, 49, 16, 90, 184, 226, 10, 38,
- 176, 4, 206, 140, 144, 83, 19, 112, 225, 16,
- 211, 136, 192, 147, 152, 241, 4, 45, 255, 20,
- 225, 8, 69, 200, 130, 26, 180, 112, 132, 31,
- 104, 195, 25, 79, 170, 64, 52, 92, 224, 5,
- 33, 68, 66, 8, 47, 29, 108, 29, 70, 225,
- 4, 102, 12, 131, 24, 195, 152, 70, 44, 130,
- 154, 133, 47, 212, 84, 12, 123, 80, 100, 200,
- 226, 209, 60, 78, 249, 45, 31, 116, 168, 6,
- 14, 78, 225, 136, 69, 40, 34, 11, 109, 16,
- 196, 38, 205, 48, 139, 129, 16, 0, 0, 102,
- 224, 66, 95, 233, 48, 9, 18, 32, 247, 17,
- 29, 224, 162, 64, 152, 33, 2, 74, 180, 161,
- 25, 241, 56, 70, 19, 6, 96, 16, 1, 116,
- 96, 11, 255, 164, 171, 29, 226, 192, 4, 3,
- 112, 83, 32, 93, 29, 170, 37, 244, 128, 93,
- 146, 193, 138, 187, 143, 106, 230, 196, 214, 144,
- 132, 63, 160, 226, 164, 65, 208, 130, 25, 132,
- 225, 7, 65, 80, 96, 154, 3, 109, 64, 46,
- 74, 225, 5, 44, 76, 130, 172, 95, 152, 67,
- 58, 182, 114, 16, 98, 84, 163, 52, 182, 185,
- 218, 65, 162, 17, 135, 34, 220, 246, 13, 41,
- 240, 146, 65, 160, 97, 138, 26, 212, 116, 15,
- 144, 213, 135, 7, 118, 69, 89, 131, 44, 45,
- 31, 51, 88, 135, 25, 112, 80, 8, 68, 168,
- 227, 15, 73, 232, 195, 21, 212, 107, 128, 129,
- 40, 0, 0, 75, 40, 69, 28, 186, 16, 132,
- 71, 152, 226, 19, 228, 216, 141, 64, 226, 97,
- 128, 4, 32, 32, 255, 40, 1, 136, 5, 10,
- 40, 64, 128, 130, 16, 32, 1, 9, 192, 15,
- 63, 156, 112, 132, 75, 196, 161, 15, 248, 129,
- 70, 48, 20, 16, 140, 32, 9, 64, 11, 214,
- 213, 68, 133, 241, 161, 100, 127, 112, 247, 145,
- 78, 134, 147, 13, 230, 97, 8, 52, 152, 193,
- 12, 125, 72, 135, 35, 226, 224, 7, 87, 112,
- 85, 32, 196, 216, 222, 85, 253, 208, 135, 68,
- 252, 128, 173, 77, 232, 17, 47, 24, 144, 1,
- 205, 66, 160, 154, 56, 176, 130, 39, 40, 64,
- 96, 219, 208, 98, 108, 56, 104, 197, 116, 5,
- 130, 11, 55, 92, 34, 20, 18, 24, 136, 1,
- 40, 176, 1, 28, 216, 162, 1, 5, 160, 144,
- 41, 172, 107, 84, 69, 42, 25, 195, 77, 118,
- 114, 0, 250, 225, 53, 123, 204, 67, 156, 154,
- 216, 130, 25, 92, 161, 139, 225, 4, 224, 21,
- 218, 115, 69, 6, 250, 112, 138, 26, 212, 128,
- 6, 90, 232, 242, 63, 136, 225, 128, 64, 248,
- 186, 18, 159, 64, 1, 14, 220, 0, 6, 48,
- 4, 130, 22, 2, 33, 192, 18, 172, 64, 137,
- 74, 80, 1, 5, 25, 29, 168, 40, 42, 145,
- 3, 153, 48, 99, 3, 87, 168, 4, 37, 172,
- 128, 3, 197, 14, 84, 194, 154, 192, 64, 118,
- 35, 203, 221, 71, 51, 200, 101, 23, 160, 135,
- 17, 216, 161, 12, 205, 97, 72, 32, 193, 8,
- 119, 18, 72, 81, 4, 185, 114, 193, 20, 104,
- 255, 144, 137, 2, 62, 144, 182, 44, 200, 65,
- 14, 112, 0, 195, 37, 46, 209, 134, 93, 228,
- 91, 20, 245, 190, 4, 37, 164, 0, 129, 171,
- 165, 193, 10, 183, 128, 48, 7, 124, 61, 243,
- 75, 80, 129, 2, 65, 77, 69, 99, 233, 128,
- 100, 39, 42, 121, 169, 209, 174, 108, 61, 92,
- 96, 134, 19, 152, 161, 19, 77, 24, 136, 0,
- 28, 224, 10, 18, 183, 129, 176, 113, 240, 47,
- 1, 184, 25, 128, 178, 151, 29, 26, 33, 184,
- 132, 204, 213, 238, 6, 155, 255, 131, 0, 35,
- 152, 121, 191, 229, 128, 130, 90, 175, 96, 4,
- 1, 231, 69, 40, 212, 206, 247, 43, 8, 84,
- 0, 203, 46, 234, 99, 157, 173, 172, 71, 99,
- 140, 31, 54, 192, 130, 33, 206, 144, 229, 40,
- 148, 34, 10, 164, 21, 72, 44, 92, 177, 132,
- 78, 148, 66, 10, 140, 95, 66, 20, 164, 32,
- 100, 130, 8, 160, 26, 107, 151, 121, 27, 18,
- 144, 111, 82, 168, 93, 230, 149, 88, 66, 157,
- 255, 177, 130, 30, 32, 64, 32, 5, 104, 131,
- 204, 103, 47, 10, 129, 10, 245, 11, 47, 60,
- 234, 30, 86, 181, 56, 4, 69, 189, 32, 253,
- 192, 64, 19, 86, 152, 142, 31, 156, 162, 13,
- 109, 216, 129, 123, 1, 96, 11, 206, 157, 64,
- 24, 202, 16, 134, 43, 146, 16, 138, 206, 107,
- 253, 12, 106, 127, 185, 27, 174, 224, 118, 2,
- 72, 129, 18, 148, 224, 187, 255, 18, 86, 223,
- 122, 210, 251, 196, 215, 179, 55, 250, 223, 171,
- 251, 194, 236, 42, 116, 201, 221, 69, 72, 60,
- 110, 0, 133, 38, 184, 163, 10, 144, 112, 196,
- 90, 219, 160, 142, 235, 4, 128, 1, 218, 195,
- 124, 87, 245, 7, 125, 80, 11, 40, 16, 10,
- 178, 16, 11, 215, 129, 0, 177, 208, 128, 177,
- 176, 0, 125, 32, 7, 200, 87, 9, 96, 208,
- 118, 55, 151, 126, 151, 96, 6, 228, 23, 10,
- 177, 32, 16, 2, 240, 3, 51, 71, 123, 72,
- 55, 80, 169, 48, 4, 158, 52, 3, 72, 197,
- 45, 59, 36, 40, 212, 118, 14, 58, 208, 14,
- 51, 80, 5, 141, 176, 127, 165, 128, 31, 8,
- 176, 61, 2, 120, 2, 182, 80, 104, 2, 32,
- 1, 161, 48, 2, 102, 160, 110, 5, 96, 117,
- 75, 96, 6, 75, 48, 8, 161, 112, 5, 107,
- 87, 115, 249, 38, 5, 124, 167, 118, 26, 40,
- 16, 43, 112, 116, 87, 19, 13, 49, 199, 119,
- 84, 0, 1, 65, 245, 8, 145, 64, 7, 24,
- 128, 4, 72, 160, 100, 247, 64, 89, 110, 194,
- 60, 215, 112, 14, 213, 176, 14, 238, 112, 8,
- 234, 224, 9, 81, 48, 8, 108, 145, 111, 1,
- 200, 124, 39, 160, 61, 201, 246, 15, 180, 48,
- 8, 143, 183, 0, 3, 17, 12, 74, 112, 5,
- 110, 208, 6, 82, 64, 13, 221, 32, 7, 106,
- 55, 122, 55, 87, 116, 50, 55, 126, 2, 65,
- 13, 116, 255, 103, 126, 252, 176, 3, 68, 39,
- 7, 103, 96, 126, 132, 100, 4, 245, 128, 4,
- 140, 54, 134, 190, 98, 35, 55, 240, 4, 214,
- 128, 3, 40, 160, 12, 186, 32, 12, 181, 112,
- 73, 4, 16, 12, 6, 160, 138, 170, 184, 138,
- 50, 113, 107, 202, 208, 113, 119, 248, 15, 222,
- 16, 12, 218, 192, 13, 117, 22, 15, 210, 0,
- 7, 151, 96, 129, 111, 39, 10, 69, 167, 118,
- 125, 176, 122, 212, 112, 9, 61, 208, 10, 80,
- 18, 1, 59, 0, 2, 191, 16, 121, 235, 22,
- 3, 147, 48, 3, 16, 83, 59, 24, 179, 63,
- 150, 50, 3, 88, 224, 8, 136, 64, 8, 133,
- 208, 1, 21, 65, 11, 39, 240, 7, 161, 240,
- 9, 27, 0, 37, 67, 150, 13, 148, 160, 5,
- 110, 199, 11, 137, 64, 87, 113, 112, 4, 71,
- 16, 133, 255, 0, 2, 151, 0, 7, 31, 240,
- 10, 250, 69, 16, 241, 80, 12, 93, 128, 9,
- 22, 32, 59, 58, 134, 53, 93, 51, 75, 208,
- 164, 6, 22, 65, 11, 61, 64, 3, 65, 16,
- 4, 34, 192, 0, 2, 18, 37, 177, 240, 1,
- 71, 160, 5, 181, 241, 15, 3, 128, 8, 38,
- 240, 79, 62, 86, 13, 28, 1, 2, 240, 152,
- 5, 186, 240, 10, 181, 86, 16, 188, 32, 11,
- 136, 144, 7, 116, 80, 2, 139, 83, 141, 144,
- 228, 1, 244, 64, 2, 128, 48, 11, 5, 96,
- 0, 52, 89, 147, 54, 121, 147, 6, 255, 240,
- 10, 202, 176, 5, 186, 20, 4, 236, 0, 1,
- 177, 96, 0, 3, 80, 66, 5, 64, 11, 13,
- 144, 3, 169, 96, 7, 169, 112, 11, 52, 169,
- 0, 79, 112, 92, 95, 48, 87, 57, 160, 0,
- 52, 169, 2, 115, 32, 87, 89, 176, 1, 174,
- 64, 11, 5, 80, 66, 196, 96, 0, 177, 224,
- 11, 46, 96, 72, 116, 64, 15, 226, 194, 146,
- 210, 70, 15, 144, 208, 7, 228, 160, 3, 27,
- 176, 89, 22, 53, 135, 114, 201, 124, 40, 96,
- 12, 56, 96, 6, 142, 64, 7, 36, 176, 10,
- 143, 144, 13, 40, 160, 11, 181, 80, 11, 20,
- 128, 12, 135, 16, 4, 66, 96, 2, 142, 160,
- 3, 190, 224, 11, 28, 176, 6, 116, 0, 79,
- 253, 36, 2, 34, 97, 12, 78, 32, 4, 67,
- 160, 10, 95, 208, 5, 45, 240, 1, 186, 208,
- 10, 181, 0, 1, 41, 224, 4, 144, 128, 9,
- 100, 165, 7, 55, 240, 63, 109, 130, 50, 139,
- 96, 6, 139, 128, 1, 147, 224, 8, 160, 160,
- 12, 182, 240, 61, 180, 201, 61, 182, 144, 1,
- 127, 224, 8, 70, 32, 4, 132, 240, 7, 144,
- 128, 62, 171, 144, 7, 93, 32, 3, 50, 208,
- 8, 238, 96, 4, 171, 69, 60, 150, 224, 98,
- 243, 64, 7, 64, 0, 55, 172, 69, 4, 40,
- 133, 5, 99, 5, 79, 252, 20, 4, 142, 32,
- 3, 139, 224, 14, 108, 0, 55, 64, 32, 6,
- 233, 211, 64, 97, 255, 98, 17, 55, 48, 15,
- 238, 128, 6, 235, 80, 15, 11, 83, 15, 143,
- 96, 6, 185, 96, 11, 39, 16, 139, 242, 41,
- 159, 89, 150, 8, 150, 16, 53, 24, 192, 8,
- 103, 208, 8, 191, 179, 10, 100, 80, 83, 60,
- 83, 15, 125, 36, 6, 236, 100, 56, 62, 19,
- 67, 98, 0, 55, 152, 96, 83, 148, 163, 160,
- 240, 4, 160, 134, 83, 2, 63, 3, 134, 217,
- 85, 50, 104, 249, 15, 254, 160, 50, 220, 32,
- 14, 24, 112, 49, 94, 35, 6, 138, 176, 4,
- 154, 131, 105, 127, 80, 162, 38, 90, 162, 234,
- 208, 8, 245, 0, 49, 249, 80, 2, 144, 32,
- 2, 104, 132, 75, 122, 64, 74, 11, 99, 1,
- 22, 16, 67, 104, 36, 71, 83, 131, 4, 172,
- 68, 97, 72, 160, 48, 54, 96, 74, 24, 64,
- 78, 154, 64, 97, 51, 0, 52, 209, 178, 45,
- 30, 160, 15, 145, 197, 146, 23, 80, 14, 47,
- 176, 80, 174, 243, 55, 245, 128, 8, 162, 24,
- 8, 228, 64, 8, 234, 176, 165, 92, 170, 14,
- 233, 192, 8, 147, 176, 15, 220, 34, 46, 30,
- 0, 15, 80, 128, 15, 72, 160, 7, 31, 3,
- 71, 215, 160, 76, 55, 128, 15, 101, 112, 74,
- 110, 250, 166, 72, 224, 46, 21, 10, 71, 116,
- 138, 100, 106, 42, 6, 167,
- 4, 43, 221, 34, 47, 211, 6, 68, 254, 131,
- 49, 247, 16, 14, 124, 179, 63, 3, 83, 15,
- 104, 128, 2, 214, 255, 192, 14, 134, 96, 8,
- 235, 16, 169, 146, 186, 14, 80, 128, 14, 42,
- 121, 150, 126, 131, 15, 162, 89, 167, 198, 164,
- 76, 117, 3, 71, 61, 84, 6, 248, 0, 71,
- 111, 116, 3, 117, 154, 93, 36, 163, 45, 111,
- 234, 46, 122, 164, 71, 32, 67, 67, 191, 34,
- 16, 21, 148, 44, 191, 151, 47, 244, 80, 69,
- 247, 0, 5, 74, 144, 6, 231, 208, 14, 47,
- 80, 15, 47, 48, 15, 47, 16, 172, 243, 32,
- 172, 51, 112, 154, 14, 226, 58, 248, 0, 5,
- 108, 80, 161, 154, 114, 1, 223, 114, 41, 73,
- 245, 172, 83, 84, 55, 76, 250, 67, 83, 228,
- 1, 118, 83, 167, 238, 210, 64, 204, 116, 16,
- 23, 208, 72, 173, 243, 37, 183, 218, 84, 51,
- 224, 4, 91, 211, 72, 55, 36, 65, 235, 106,
- 113, 4, 209, 15, 123, 224, 14, 98, 128, 55,
- 227, 178, 67, 13, 18, 38, 228, 66, 46, 190,
- 18, 15, 19, 96, 120, 2, 243, 40, 110, 196,
- 45, 70, 83, 41, 174, 114, 63, 13, 165, 143,
- 215, 16, 42, 30, 176, 3, 232, 176, 146, 249,
- 154, 175, 13, 82, 118, 2, 3, 105, 111, 178,
- 15, 108, 208, 14, 172, 210, 56, 149, 34, 40,
- 145, 193, 93, 88, 179, 52, 209, 54, 176, 2,
- 33, 15, 207, 224, 1, 250, 170, 52, 27, 203,
- 32, 118, 99, 3, 225, 144, 46, 57, 225, 58,
- 23, 138, 36, 227, 137, 53, 227, 240, 2, 140,
- 61, 163, 18, 131, 146, 15, 220, 229, 13, 19,
- 100, 38, 20, 139, 53, 34, 171, 52, 224, 80,
- 14, 181, 90, 17, 21, 212, 58, 253, 48, 45,
- 47, 187, 130, 29, 241, 179, 10, 193, 15, 225,
- 16, 14, 183, 131, 36, 109, 2, 173, 14, 114,
- 179, 12, 225, 58, 78, 102, 175, 109, 226, 32,
- 1, 1, 0, 59 };
diff --git a/main/main.c b/main/main.c
deleted file mode 100644
index ca5ea920a5..0000000000
--- a/main/main.c
+++ /dev/null
@@ -1,1235 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Andi Gutmans <andi@zend.com> |
- | Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
-*/
-
-
-/* $Id$ */
-
-
-#include <stdio.h>
-#include "php.h"
-#ifdef MSVC5
-#include "win32/time.h"
-#include "win32/signal.h"
-#include <process.h>
-#else
-#include "build-defs.h"
-#endif
-#if HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#if HAVE_SIGNAL_H
-#include <signal.h>
-#endif
-#if HAVE_SETLOCALE
-#include <locale.h>
-#endif
-#include "zend.h"
-#include "php_ini.h"
-#include "php_globals.h"
-#include "main.h"
-#include "fopen-wrappers.h"
-#include "ext/standard/php3_standard.h"
-#include "snprintf.h"
-#if WIN32|WINNT
-#include <io.h>
-#include <fcntl.h>
-#include "win32/syslog.h"
-#include "win32/php_registry.h"
-#else
-#include <syslog.h>
-#endif
-
-#include "zend_compile.h"
-#include "zend_execute.h"
-#include "zend_highlight.h"
-#include "zend_indent.h"
-
-#include "php_content_types.h"
-
-#if USE_SAPI
-#include "serverapi/sapi.h"
-void *gLock;
-#ifndef THREAD_SAFE
-struct sapi_request_info *sapi_rqst;
-#endif
-#endif
-
-
-#include "SAPI.h"
-
-#if MSVC5 || !defined(HAVE_GETOPT)
-#include "php_getopt.h"
-#endif
-
-
-#ifndef ZTS
-php_core_globals core_globals;
-#else
-PHPAPI int core_globals_id;
-#endif
-
-void _php3_build_argv(char * ELS_DC);
-static void php3_timeout(int dummy);
-static void php3_set_timeout(long seconds);
-
-void *gLock; /*mutex variable */
-
-
-/* True globals (no need for thread safety) */
-HashTable configuration_hash;
-PHPAPI char *php3_ini_path = NULL;
-
-
-#define SAFE_FILENAME(f) ((f)?(f):"-")
-
-static PHP_INI_MH(OnSetPrecision)
-{
- ELS_FETCH();
-
- EG(precision) = atoi(new_value);
- return SUCCESS;
-}
-
-
-static PHP_INI_MH(OnChangeMaxExecutionTime)
-{
- int new_timeout;
-
- if (new_value) {
- new_timeout = atoi(new_value);
- } else {
- new_timeout = 0;
- }
- php3_set_timeout(new_timeout);
- return SUCCESS;
-}
-
-
-static PHP_INI_MH(OnChangeMemoryLimit)
-{
- int new_limit;
-
- if (new_value) {
- new_limit = atoi(new_value);
- } else {
- new_limit = 2<<30; /* effectively, no limit */
- }
- return zend_set_memory_limit(new_limit);
-}
-
-
-static PHP_INI_MH(OnUpdateErrorReporting)
-{
- ELS_FETCH();
-
- if (!new_value) {
- EG(error_reporting) = E_ALL & ~E_NOTICE;
- } else {
- EG(error_reporting) = atoi(new_value);
- }
- return SUCCESS;
-}
-
-
-/* Need to convert to strings and make use of:
- * DEFAULT_SHORT_OPEN_TAG
- * PHP_SAFE_MODE
- *
- * Need to be read from the environment (?):
- * PHP_AUTO_PREPEND_FILE
- * PHP_AUTO_APPEND_FILE
- * PHP_DOCUMENT_ROOT
- * PHP_USER_DIR
- * PHP_INCLUDE_PATH
- */
-
-#ifndef SAFE_MODE_EXEC_DIR
-# define SAFE_MODE_EXEC_DIR "/"
-#endif
-
-#ifdef PHP_PROG_SENDMAIL
-# define DEFAULT_SENDMAIL_PATH PHP_PROG_SENDMAIL " -t"
-#else
-# define DEFAULT_SENDMAIL_PATH NULL
-#endif
-PHP_INI_BEGIN()
- STD_PHP_INI_BOOLEAN("short_open_tag", "1", PHP_INI_ALL, OnUpdateBool, short_tags, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("asp_tags", "0", PHP_INI_ALL, OnUpdateBool, asp_tags, php_core_globals, core_globals)
- PHP_INI_ENTRY("precision", "14", PHP_INI_ALL, OnSetPrecision)
- STD_PHP_INI_BOOLEAN("output_buffering", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, output_buffering, php_core_globals, core_globals)
-
- PHP_INI_ENTRY_EX("highlight.comment", HL_COMMENT_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
- PHP_INI_ENTRY_EX("highlight.default", HL_DEFAULT_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
- PHP_INI_ENTRY_EX("highlight.html", HL_HTML_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
- PHP_INI_ENTRY_EX("highlight.string", HL_STRING_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
- PHP_INI_ENTRY_EX("highlight.bg", HL_BG_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
- PHP_INI_ENTRY_EX("highlight.keyword", HL_KEYWORD_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
-
- STD_PHP_INI_BOOLEAN("magic_quotes_gpc", "1", PHP_INI_ALL, OnUpdateBool, magic_quotes_gpc, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("magic_quotes_runtime", "0", PHP_INI_ALL, OnUpdateBool, magic_quotes_runtime, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("magic_quotes_sybase", "0", PHP_INI_ALL, OnUpdateBool, magic_quotes_sybase, php_core_globals, core_globals)
-
- STD_PHP_INI_BOOLEAN("safe_mode", "0", PHP_INI_SYSTEM, OnUpdateBool, safe_mode, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("sql.safe_mode", "0", PHP_INI_SYSTEM, OnUpdateBool, sql_safe_mode, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("safe_mode_exec_dir", "1", PHP_INI_SYSTEM, OnUpdateString, safe_mode_exec_dir, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("enable_dl", "1", PHP_INI_SYSTEM, OnUpdateBool, enable_dl, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("expose_php", "1", PHP_INI_SYSTEM, OnUpdateBool, expose_php, php_core_globals, core_globals)
-
- PHP_INI_ENTRY("SMTP", "localhost", PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("sendmail_path", DEFAULT_SENDMAIL_PATH, PHP_INI_SYSTEM, NULL)
- PHP_INI_ENTRY("sendmail_from", NULL, PHP_INI_ALL, NULL)
-
- PHP_INI_ENTRY("error_reporting", NULL, PHP_INI_ALL, OnUpdateErrorReporting)
- STD_PHP_INI_BOOLEAN("display_errors", "1", PHP_INI_ALL, OnUpdateBool, display_errors, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("track_errors", "0", PHP_INI_ALL, OnUpdateBool, track_errors, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("log_errors", "0", PHP_INI_ALL, OnUpdateBool, log_errors, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("error_log", NULL, PHP_INI_ALL, OnUpdateString, error_log, php_core_globals, core_globals)
-
-
- STD_PHP_INI_ENTRY("auto_prepend_file", NULL, PHP_INI_ALL, OnUpdateString, auto_prepend_file, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("auto_append_file", NULL, PHP_INI_ALL, OnUpdateString, auto_append_file, php_core_globals, core_globals)
-
- STD_PHP_INI_BOOLEAN("y2k_compliance", "0", PHP_INI_ALL, OnUpdateBool, y2k_compliance, php_core_globals, core_globals)
-
- STD_PHP_INI_ENTRY("doc_root", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, doc_root, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("user_dir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, user_dir, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("include_path", NULL, PHP_INI_ALL, OnUpdateStringUnempty, include_path, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("open_basedir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, open_basedir, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("extension_dir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, extension_dir, php_core_globals, core_globals)
-
- STD_PHP_INI_ENTRY("upload_tmp_dir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, upload_tmp_dir, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("upload_max_filesize", "2097152", PHP_INI_ALL, OnUpdateInt, upload_max_filesize, php_core_globals, core_globals)
-
- PHP_INI_ENTRY("browscap", NULL, PHP_INI_SYSTEM, NULL)
-
- PHP_INI_ENTRY_EX("define_syslog_variables", "0", PHP_INI_ALL, NULL, php_ini_boolean_displayer_cb)
-
- PHP_INI_ENTRY("max_execution_time", "30", PHP_INI_ALL, OnChangeMaxExecutionTime)
- PHP_INI_ENTRY("memory_limit", "8388608", PHP_INI_ALL, OnChangeMemoryLimit)
-
- STD_PHP_INI_BOOLEAN("track_vars", (PHP_TRACK_VARS?"1":"0"), PHP_INI_ALL, OnUpdateBool, track_vars, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("gpc_globals", "1", PHP_INI_ALL, OnUpdateBool, gpc_globals, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("gpc_order", "GPC", PHP_INI_ALL, OnUpdateStringUnempty, gpc_order, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("arg_separator", "&", PHP_INI_ALL, OnUpdateStringUnempty, arg_separator, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("ignore_user_abort", "1", PHP_INI_ALL, OnUpdateBool, ignore_user_abort, php_core_globals, core_globals)
-PHP_INI_END()
-
-
-
-/* True global (no need for thread safety */
-static int module_initialized = 0;
-
-#if 0
-#if APACHE
-void php3_apache_puts(const char *s)
-{
- SLS_FETCH();
-
- if (SG(server_context)) {
- if(rputs(s, (request_rec *) SG(server_context))==-1) {
- PG(connection_status) |= PHP_CONNECTION_ABORTED;
- }
- } else {
- fputs(s, stdout);
- }
-}
-
-void php3_apache_putc(char c)
-{
- SLS_FETCH();
-
- if (SG(server_context)) {
- if(rputc(c, (request_rec *) SG(server_context))!=c) {
- PG(connection_status) |= PHP_CONNECTION_ABORTED;
- }
- } else {
- fputc(c, stdout);
- }
-}
-#endif
-#endif
-
-void php3_log_err(char *log_message)
-{
- FILE *log_file;
- PLS_FETCH();
- SLS_FETCH();
-
- /* Try to use the specified logging location. */
- if (PG(error_log) != NULL) {
-#if HAVE_SYSLOG_H
- if (!strcmp(PG(error_log), "syslog")) {
- syslog(LOG_NOTICE, log_message);
- return;
- } else {
-#endif
- log_file = fopen(PG(error_log), "a");
- if (log_file != NULL) {
- fprintf(log_file, log_message);
- fprintf(log_file, "\n");
- fclose(log_file);
- return;
- }
-#if HAVE_SYSLOG_H
- }
-#endif
- }
- /* Otherwise fall back to the default logging location. */
-#if APACHE
- if (SG(server_context)) {
-#if MODULE_MAGIC_NUMBER >= 19970831
- aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, ((request_rec *) SG(server_context))->server, log_message);
-#else
- log_error(log_message, ((requset_rec *) SG(server_context))->server);
-#endif
- } else {
- fprintf(stderr, log_message);
- fprintf(stderr, "\n");
- }
-#endif /*APACHE */
-
-#if CGI_BINARY
- if (php3_header()) {
- fprintf(stderr, log_message);
- fprintf(stderr, "\n");
- }
-#endif
-}
-
-
-/* is 4K big enough? */
-#define PRINTF_BUFFER_SIZE 1024*4
-
-/* wrapper for modules to use PHPWRITE */
-PHPAPI int php3_write(void *buf, int size)
-{
- return PHPWRITE(buf, size);
-}
-
-PHPAPI int php_printf(const char *format,...)
-{
- va_list args;
- int ret;
- char buffer[PRINTF_BUFFER_SIZE];
- int size;
-
- va_start(args, format);
- size = vsnprintf(buffer, sizeof(buffer), format, args);
- ret = PHPWRITE(buffer, size);
- va_end(args);
-
- return ret;
-}
-
-
-/* extended error handling function */
-PHPAPI void php_error(int type, const char *format,...)
-{
- va_list args;
- char *error_filename = NULL;
- uint error_lineno;
- char buffer[1024];
- int size = 0;
- ELS_FETCH();
- PLS_FETCH();
-
-
- switch (type) {
- case E_CORE_ERROR:
- case E_CORE_WARNING:
- error_filename = NULL;
- error_lineno = 0;
- break;
- case E_PARSE:
- case E_COMPILE_ERROR:
- case E_COMPILE_WARNING: {
- CLS_FETCH();
-
- error_filename = zend_get_compiled_filename();
- error_lineno = CG(zend_lineno);
- if (!error_filename) {
- error_filename = zend_get_executed_filename(ELS_C);
- }
- }
- break;
- case E_ERROR:
- case E_NOTICE:
- case E_WARNING:
- error_filename = zend_get_executed_filename(ELS_C);
- error_lineno = zend_get_executed_lineno(ELS_C);
- break;
- default:
- error_filename = NULL;
- error_lineno = 0;
- break;
- }
-
- if (!error_filename) {
- error_filename = "Unknown";
- }
-
- if (EG(error_reporting) & type || (type & E_CORE)) {
- char *error_type_str;
-
- switch (type) {
- case E_ERROR:
- case E_CORE_ERROR:
- case E_COMPILE_ERROR:
- error_type_str = "Fatal error";
- break;
- case E_WARNING:
- case E_CORE_WARNING:
- case E_COMPILE_WARNING:
- error_type_str = "Warning";
- break;
- case E_PARSE:
- error_type_str = "Parse error";
- break;
- case E_NOTICE:
- error_type_str = "Warning";
- break;
- default:
- error_type_str = "Unknown error";
- break;
- }
-
- /* get include file name */
- if (PG(log_errors) || PG(display_errors)) {
- va_start(args, format);
- size = vsnprintf(buffer, sizeof(buffer) - 1, format, args);
- va_end(args);
- buffer[sizeof(buffer) - 1] = 0;
-
- if (PG(log_errors)) {
- char log_buffer[1024];
-
- snprintf(log_buffer, 1024, "PHP %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno);
- php3_log_err(log_buffer);
- }
- if (PG(display_errors)) {
- char *prepend_string = INI_STR("error_prepend_string");
- char *append_string = INI_STR("error_append_string");
-
- if (prepend_string) {
- PUTS(prepend_string);
- }
- php_printf("<br>\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br>\n", error_type_str, buffer, error_filename, error_lineno);
- if (append_string) {
- PUTS(append_string);
- }
- }
- }
- }
- if (PG(track_errors)) {
- pval *tmp;
-
- va_start(args, format);
- size = vsnprintf(buffer, sizeof(buffer) - 1, format, args);
- va_end(args);
- buffer[sizeof(buffer) - 1] = 0;
-
- tmp = (pval *)emalloc(sizeof(pval));
- INIT_PZVAL(tmp);
- tmp->value.str.val = (char *) estrndup(buffer, size);
- tmp->value.str.len = size;
- tmp->type = IS_STRING;
-
- zend_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) & tmp, sizeof(pval *), NULL);
- }
-
- switch (type) {
- case E_ERROR:
- case E_CORE_ERROR:
- /*case E_PARSE: the parser would return 1 (failure), we can bail out nicely */
- case E_COMPILE_ERROR:
- zend_bailout();
- break;
- }
-}
-
-
-static long php_timeout_seconds;
-
-#ifdef HAVE_SETITIMER
-static void php3_timeout(int dummy)
-{
- PLS_FETCH();
-
- PG(connection_status) |= PHP_CONNECTION_TIMEOUT;
- php_error(E_ERROR, "Maximum execution time of %d second%s exceeded",
- php_timeout_seconds, php_timeout_seconds == 1 ? "" : "s");
-}
-#endif
-
-/* This one doesn't exists on QNX */
-#ifndef SIGPROF
-#define SIGPROF 27
-#endif
-
-static void php3_set_timeout(long seconds)
-{
-#if WIN32|WINNT
-#else
-# ifdef HAVE_SETITIMER
- struct itimerval t_r; /* timeout requested */
-
- t_r.it_value.tv_sec = seconds;
- t_r.it_value.tv_usec = t_r.it_interval.tv_sec = t_r.it_interval.tv_usec = 0;
-
- php_timeout_seconds = seconds;
- setitimer(ITIMER_PROF, &t_r, NULL);
- signal(SIGPROF, php3_timeout);
-# endif
-#endif
-}
-
-
-static void php3_unset_timeout()
-{
-#if WIN32|WINNT
-#else
-# ifdef HAVE_SETITIMER
- struct itimerval no_timeout;
-
- no_timeout.it_value.tv_sec = no_timeout.it_value.tv_usec = no_timeout.it_interval.tv_sec = no_timeout.it_interval.tv_usec = 0;
-
- setitimer(ITIMER_PROF, &no_timeout, NULL);
-# endif
-#endif
-}
-
-
-PHP_FUNCTION(set_time_limit)
-{
- pval *new_timeout;
- PLS_FETCH();
-
- if (PG(safe_mode)) {
- php_error(E_WARNING, "Cannot set time limit in safe mode");
- RETURN_FALSE;
- }
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &new_timeout) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(new_timeout);
- /* FIXME ** This is BAD...in a threaded situation, any user
- can set the timeout for php on a server wide basis.
- INI variables should not be reset via a user script
-
- Fix what? At least on Unix, timers like these are
- per-thread timers. Well, with a little work they will
- be. If we use a bound thread and proper masking it
- should work fine. Is this FIXME a WIN32 problem? Is
- there no way to do per-thread timers on WIN32?
- */
- php3_unset_timeout();
- php3_set_timeout(new_timeout->value.lval);
-}
-
-
-static FILE *php_fopen_wrapper_for_zend(const char *filename)
-{
- int issock=0, socketd=0;
- int old_chunk_size;
- FILE *retval;
-
- old_chunk_size = _php3_sock_set_def_chunk_size(1);
- retval=php3_fopen_wrapper((char *) filename, "r", USE_PATH|IGNORE_URL_WIN, &issock, &socketd);
- _php3_sock_set_def_chunk_size(old_chunk_size);
-
- if (issock) {
- retval = fdopen(socketd, "r");
- }
- return retval;
-}
-
-
-static int php_get_ini_entry_for_zend(char *name, uint name_length, zval *contents)
-{
- zval *retval = cfg_get_entry(name, name_length);
-
- if (retval) {
- *contents = *retval;
- return SUCCESS;
- } else {
- return FAILURE;
- }
-}
-
-
-static void php_message_handler_for_zend(long message, void *data)
-{
- switch (message) {
- case ZMSG_ENABLE_TRACK_VARS: {
- PLS_FETCH();
-
- PG(track_vars) = 1;
- }
- break;
- case ZMSG_FAILED_INCLUDE_FOPEN: {
- PLS_FETCH();
-
- php_error(E_WARNING, "Failed opening '%s' for inclusion (include_path='%s')", php3_strip_url_passwd((char *) data), STR_PRINT(PG(include_path)));
- }
- break;
- case ZMSG_FAILED_REQUIRE_FOPEN: {
- PLS_FETCH();
-
- php_error(E_COMPILE_ERROR, "Failed opening required '%s' (include_path='%s')", php3_strip_url_passwd((char *) data), STR_PRINT(PG(include_path)));
- }
- break;
- case ZMSG_FAILED_HIGHLIGHT_FOPEN:
- php_error(E_WARNING, "Failed opening '%s' for highlighting", php3_strip_url_passwd((char *) data));
- break;
- case ZMSG_MEMORY_LEAK_DETECTED:
- case ZMSG_MEMORY_LEAK_REPEATED: {
- ELS_FETCH();
- SLS_FETCH();
-
- if (EG(error_reporting)&E_WARNING) {
-#if ZEND_DEBUG
- char memory_leak_buf[512];
- SLS_FETCH();
-
- if (message==ZMSG_MEMORY_LEAK_DETECTED) {
- mem_header *t = (mem_header *) data;
- void *ptr = (void *)((char *)t+sizeof(mem_header)+PLATFORM_PADDING);
-
- snprintf(memory_leak_buf, 512, "%s(%d) : Freeing 0x%.8lX (%d bytes), script=%s\n", t->filename, t->lineno, (unsigned long)ptr, t->size, SAFE_FILENAME(SG(request_info).path_translated));
- if (t->orig_filename) {
- char relay_buf[512];
-
- snprintf(relay_buf, 512, "%s(%d) : Actual location (location was relayed)\n", t->orig_filename, t->orig_lineno);
- strcat(memory_leak_buf, relay_buf);
- }
- } else {
- unsigned long leak_count = (unsigned long) data;
-
- snprintf(memory_leak_buf, 512, "Last leak repeated %ld time%s\n", leak_count, (leak_count>1?"s":""));
- }
-# if WIN32||WINNT
- OutputDebugString(memory_leak_buf);
-# else
- fprintf(stderr, memory_leak_buf);
-# endif
-#endif
- }
- }
- break;
- case ZMSG_LOG_SCRIPT_NAME: {
- struct tm *ta;
- time_t curtime;
- char *datetime_str;
- SLS_FETCH();
-
- time(&curtime);
- ta = localtime(&curtime);
- datetime_str = asctime(ta);
- datetime_str[strlen(datetime_str)-1]=0; /* get rid of the trailing newline */
- fprintf(stderr, "[%s] Script: '%s'\n", datetime_str, SAFE_FILENAME(SG(request_info).path_translated));
- }
- break;
- }
-}
-
-
-
-int php_request_startup(CLS_D ELS_DC PLS_DC SLS_DC)
-{
- php_output_startup();
-
- if (PG(output_buffering)) {
- php_start_ob_buffering();
- }
-#if APACHE
- /*
- * For the Apache module version, this bit of code registers a cleanup
- * function that gets triggered when our request pool is destroyed.
- * We need this because at any point in our code we can be interrupted
- * and that may happen before we have had time to free our memory.
- * The php3_shutdown function needs to free all outstanding allocated
- * memory.
- */
- block_alarms();
- register_cleanup(((request_rec *) SG(server_context))->pool, NULL, php_request_shutdown, php_request_shutdown_for_exec);
- unblock_alarms();
-#endif
-
- /* initialize global variables */
- {
- PG(header_is_being_sent)=0;
- }
-
- if (php3_init_request_info(NULL)) {
- php_printf("Unable to initialize request info.\n");
- return FAILURE;
- }
-
- zend_activate(CLS_C ELS_CC);
- sapi_activate(SLS_C);
-
- if (SG(request_info).auth_user) {
- zval *auth_user;
-
- MAKE_STD_ZVAL(auth_user);
- auth_user->type = IS_STRING;
- auth_user->value.str.val = SG(request_info).auth_user;
- auth_user->value.str.len = strlen(auth_user->value.str.val);
-
- zend_hash_update(&EG(symbol_table), "PHP_AUTH_USER", sizeof("PHP_AUTH_USER"), &auth_user, sizeof(zval *), NULL);
- }
- if (SG(request_info).auth_password) {
- zval *auth_password;
-
- MAKE_STD_ZVAL(auth_password);
- auth_password->type = IS_STRING;
- auth_password->value.str.val = SG(request_info).auth_password;
- auth_password->value.str.len = strlen(auth_password->value.str.val);
-
- zend_hash_update(&EG(symbol_table), "PHP_AUTH_PW", sizeof("PHP_AUTH_PW"), &auth_password, sizeof(zval *), NULL);
- }
- return SUCCESS;
-}
-
-
-void php_request_shutdown_for_exec(void *dummy)
-{
- /* used to close fd's in the 3..255 range here, but it's problematic
- */
- shutdown_memory_manager(1, 1);
-}
-
-
-int return_one(void *p)
-{
- return 1;
-}
-
-
-void php_request_shutdown(void *dummy)
-{
- CLS_FETCH();
- ELS_FETCH();
- PLS_FETCH();
- SLS_FETCH();
-
- sapi_send_headers();
- php_end_ob_buffering(SG(request_info).headers_only?0:1);
-
- php3_call_shutdown_functions();
-
- php_ini_rshutdown();
-
- zend_deactivate(CLS_C ELS_CC);
- sapi_deactivate(SLS_C);
-
- php3_destroy_request_info(NULL);
- shutdown_memory_manager(CG(unclean_shutdown), 0);
- php3_unset_timeout();
-
-
-#if CGI_BINARY
- fflush(stdout);
- if(request_info.php_argv0) {
- free(request_info.php_argv0);
- request_info.php_argv0 = NULL;
- }
-#endif
-}
-
-
-static int php3_config_ini_startup()
-{
- if (php3_init_config() == FAILURE) {
- php_printf("PHP: Unable to parse configuration file.\n");
- return FAILURE;
- }
- return SUCCESS;
-}
-
-static void php3_config_ini_shutdown()
-{
- php3_shutdown_config();
-}
-
-
-static int php_body_write_wrapper(const char *str, uint str_length)
-{
- return php_body_write(str, str_length);
-}
-
-#ifdef ZTS
-static void php_new_thread_end_handler(THREAD_T thread_id)
-{
- php_ini_refresh_caches();
-}
-#endif
-
-
-#ifdef ZTS
-static void core_globals_ctor(php_core_globals *core_globals)
-{
- zend_hash_init(&core_globals->ht_fsock_keys, 0, NULL, NULL, 1);
- zend_hash_init(&core_globals->ht_fsock_socks, 0, NULL, (int (*)(void *))php_msock_destroy, 1);
-}
-
-
-static void core_globals_dtor(php_core_globals *core_globals)
-{
- zend_hash_destroy(&core_globals->ht_fsock_keys);
- zend_hash_destroy(&core_globals->ht_fsock_socks);
-}
-#endif
-
-
-int php_module_startup(sapi_module_struct *sf)
-{
- zend_utility_functions zuf;
- zend_utility_values zuv;
- int module_number=0; /* for REGISTER_INI_ENTRIES() */
-#ifdef ZTS
- zend_executor_globals *executor_globals;
- php_core_globals *core_globals;
- sapi_globals_struct *sapi_globals = ts_resource(sapi_globals_id);
-#endif
-#if (WIN32|WINNT) && !(USE_SAPI)
- WORD wVersionRequested = MAKEWORD(2, 0);
- WSADATA wsaData;
-#endif
-
- SG(server_context) = NULL;
- SG(request_info).request_method = NULL;
- sapi_activate(SLS_C);
-
- if (module_initialized) {
- return SUCCESS;
- }
-
- sapi_module = *sf;
-
- php_output_startup();
-
- zuf.error_function = php_error;
- zuf.printf_function = php_printf;
- zuf.write_function = php_body_write_wrapper;
- zuf.fopen_function = php_fopen_wrapper_for_zend;
- zuf.message_handler = php_message_handler_for_zend;
- zuf.block_interruptions = BLOCK_INTERRUPTIONS;
- zuf.unblock_interruptions = UNBLOCK_INTERRUPTIONS;
- zuf.get_ini_entry = php_get_ini_entry_for_zend;
- zend_startup(&zuf, NULL);
-
-#ifdef ZTS
- tsrm_set_new_thread_end_handler(php_new_thread_end_handler);
- executor_globals = ts_resource(executor_globals_id);
- core_globals_id = ts_allocate_id(sizeof(php_core_globals), core_globals_ctor, core_globals_dtor);
- core_globals = ts_resource(core_globals_id);
-#endif
- EG(error_reporting) = E_ALL & ~E_NOTICE;
-
- PG(header_is_being_sent) = 0;
- SG(request_info).headers_only = 0;
- PG(connection_status) = PHP_CONNECTION_NORMAL;
-
-#if HAVE_SETLOCALE
- setlocale(LC_CTYPE, "");
-#endif
-
-#if (WIN32|WINNT) && !(USE_SAPI)
- /* start up winsock services */
- if (WSAStartup(wVersionRequested, &wsaData) != 0) {
- php_printf("\nwinsock.dll unusable. %d\n", WSAGetLastError());
- return FAILURE;
- }
-#endif
-
- SET_MUTEX(gLock);
- le_index_ptr = _register_list_destructors(NULL, NULL, 0);
- FREE_MUTEX(gLock);
-
- php_ini_mstartup();
-
- if (php3_config_ini_startup() == FAILURE) {
- return FAILURE;
- }
-
- REGISTER_INI_ENTRIES();
-
- zuv.short_tags = (unsigned char) PG(short_tags);
- zuv.asp_tags = (unsigned char) PG(asp_tags);
- zend_set_utility_values(&zuv);
- php_startup_SAPI_content_types();
-
- if (module_startup_modules() == FAILURE) {
- php_printf("Unable to start modules\n");
- return FAILURE;
- }
- module_initialized = 1;
- sapi_deactivate(SLS_C);
- return SUCCESS;
-}
-
-
-
-void php_module_shutdown_for_exec()
-{
- /* used to close fd's in the range 3.255 here, but it's problematic */
-}
-
-
-int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals)
-{
- php_module_shutdown();
- return SUCCESS;
-}
-
-
-void php_module_shutdown()
-{
- int module_number=0; /* for UNREGISTER_INI_ENTRIES() */
- CLS_FETCH();
- ELS_FETCH();
-
- if (!module_initialized) {
- return;
- }
-#if !USE_SAPI
- /* close down the ini config */
- php3_config_ini_shutdown();
-#endif
-
-#if (WIN32|WINNT) && !(USE_SAPI)
- /*close winsock */
- WSACleanup();
-#endif
-
-#if CGI_BINARY
- fflush(stdout);
-#endif
-#if 0 /* SAPI */
- sapi_rqst->flush(sapi_rqst->scid);
-#endif
-
- zend_shutdown();
- UNREGISTER_INI_ENTRIES();
- php_ini_mshutdown();
- shutdown_memory_manager(0, 1);
- module_initialized = 0;
-}
-
-
-/* in 3.1 some of this should move into sapi */
-static int zend_hash_environment(PLS_D ELS_DC SLS_DC)
-{
- char **env, *p, *t;
- unsigned char _gpc_flags[3] = {0,0,0};
- pval *tmp;
-
- p = PG(gpc_order);
- while(*p) {
- switch(*p++) {
- case 'p':
- case 'P':
- if (!_gpc_flags[0] && !SG(headers_sent) && SG(request_info).request_method && !strcasecmp(SG(request_info).request_method, "POST")) {
- php_treat_data(PARSE_POST, NULL ELS_CC PLS_CC SLS_CC); /* POST Data */
- _gpc_flags[0]=1;
- }
- break;
- case 'c':
- case 'C':
- if (!_gpc_flags[1]) {
- php_treat_data(PARSE_COOKIE, NULL ELS_CC PLS_CC SLS_CC); /* Cookie Data */
- _gpc_flags[1]=1;
- }
- break;
- case 'g':
- case 'G':
- if (!_gpc_flags[2]) {
- php_treat_data(PARSE_GET, NULL ELS_CC PLS_CC SLS_CC); /* GET Data */
- _gpc_flags[2]=1;
- }
- break;
- }
- }
-
-
- for (env = environ; env != NULL && *env != NULL; env++) {
- p = strchr(*env, '=');
- if (!p) { /* malformed entry? */
- continue;
- }
- t = estrndup(*env, p - *env);
- tmp = (pval *) emalloc(sizeof(pval));
- tmp->value.str.len = strlen(p + 1);
- tmp->value.str.val = estrndup(p + 1, tmp->value.str.len);
- tmp->type = IS_STRING;
- INIT_PZVAL(tmp);
- /* environmental variables never take precedence over get/post/cookie variables */
- zend_hash_add(&EG(symbol_table), t, p - *env + 1, &tmp, sizeof(pval *), NULL);
- efree(t);
- }
-
-#if APACHE
- {
- pval **tmp_ptr;
- register int i;
- array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env);
- table_entry *elts = (table_entry *) arr->elts;
- int len;
-
- for (i = 0; i < arr->nelts; i++) {
- len = strlen(elts[i].key);
- t = elts[i].key;
- tmp = (pval *) emalloc(sizeof(pval));
- if (elts[i].val) {
- tmp->value.str.len = strlen(elts[i].val);
- tmp->value.str.val = estrndup(elts[i].val, tmp->value.str.len);
- } else {
- tmp->value.str.len = 0;
- tmp->value.str.val = empty_string;
- }
- INIT_PZVAL(tmp);
- tmp->type = IS_STRING;
- zend_hash_update(&EG(symbol_table), t, strlen(t)+1, &tmp, sizeof(pval *), NULL);
- }
- /* insert special variables */
- if (zend_hash_find(&EG(symbol_table), "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &tmp_ptr) == SUCCESS) {
- (*tmp_ptr)->refcount++;
- zend_hash_update(&EG(symbol_table), "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), tmp_ptr, sizeof(pval *), NULL);
- }
- tmp = (pval *) emalloc(sizeof(pval));
- tmp->value.str.len = strlen(((request_rec *) SG(server_context))->uri);
- tmp->value.str.val = estrndup(((request_rec *) SG(server_context))->uri, tmp->value.str.len);
- INIT_PZVAL(tmp);
- tmp->type = IS_STRING;
- zend_hash_update(&EG(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void *) &tmp, sizeof(pval *), NULL);
- }
-#else
- {
- /* Build the special-case PHP_SELF variable for the CGI version */
- char *pi;
-#if FORCE_CGI_REDIRECT
- pi = SG(request_info).request_uri;
- tmp = (pval *) emalloc(sizeof(pval));
- tmp->value.str.val = emalloc(((pi)?strlen(pi):0) + 1);
- tmp->value.str.len = php_sprintf(tmp->value.str.val, "%s", (pi ? pi : "")); /* SAFE */
- tmp->type = IS_STRING;
- INIT_PZVAL(tmp);
-#else
- int l = 0;
- char *sn;
- sn = request_info.script_name;
- pi = SG(request_info).request_uri;
- if (sn)
- l += strlen(sn);
- if (pi)
- l += strlen(pi);
- if (pi && sn && !strcmp(pi, sn)) {
- l -= strlen(pi);
- pi = NULL;
- }
- tmp = (pval *) emalloc(sizeof(pval));
- tmp->value.str.val = emalloc(l + 1);
- tmp->value.str.len = php_sprintf(tmp->value.str.val, "%s%s", (sn ? sn : ""), (pi ? pi : "")); /* SAFE */
- tmp->type = IS_STRING;
- INIT_PZVAL(tmp);
-#endif
- zend_hash_update(&EG(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void *) & tmp, sizeof(pval *), NULL);
- }
-#endif
-
-
- /* need argc/argv support as well */
- _php3_build_argv(SG(request_info).query_string ELS_CC);
-
- return SUCCESS;
-}
-
-void _php3_build_argv(char *s ELS_DC)
-{
- pval *arr, *tmp;
- int count = 0;
- char *ss, *space;
-
- arr = (pval *) emalloc(sizeof(pval));
- arr->value.ht = (HashTable *) emalloc(sizeof(HashTable));
- if (zend_hash_init(arr->value.ht, 0, NULL, PVAL_PTR_DTOR, 0) == FAILURE) {
- php_error(E_WARNING, "Unable to create argv array");
- } else {
- arr->type = IS_ARRAY;
- INIT_PZVAL(arr);
- zend_hash_update(&EG(symbol_table), "argv", sizeof("argv"), &arr, sizeof(pval *), NULL);
- }
- /* now pick out individual entries */
- ss = s;
- while (ss) {
- space = strchr(ss, '+');
- if (space) {
- *space = '\0';
- }
- /* auto-type */
- tmp = (pval *) emalloc(sizeof(pval));
- tmp->type = IS_STRING;
- tmp->value.str.len = strlen(ss);
- tmp->value.str.val = estrndup(ss, tmp->value.str.len);
- INIT_PZVAL(tmp);
- count++;
- if (zend_hash_next_index_insert(arr->value.ht, &tmp, sizeof(pval *), NULL)==FAILURE) {
- if (tmp->type == IS_STRING) {
- efree(tmp->value.str.val);
- }
- }
- if (space) {
- *space = '+';
- ss = space + 1;
- } else {
- ss = space;
- }
- }
- tmp = (pval *) emalloc(sizeof(pval));
- tmp->value.lval = count;
- tmp->type = IS_LONG;
- INIT_PZVAL(tmp);
- zend_hash_add(&EG(symbol_table), "argc", sizeof("argc"), &tmp, sizeof(pval *), NULL);
-}
-
-
-#include "logos.h"
-
-PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_DC)
-{
- zend_file_handle *prepend_file_p, *append_file_p;
- zend_file_handle prepend_file, append_file;
- SLS_FETCH();
-
- if (SG(request_info).query_string && SG(request_info).query_string[0]=='='
- && PG(expose_php)) {
- if (!strcmp(SG(request_info).query_string+1, "PHPE9568F34-D428-11d2-A769-00AA001ACF42")) {
- char *header_line = estrndup(CONTEXT_TYPE_IMAGE_GIF, sizeof(CONTEXT_TYPE_IMAGE_GIF));
-
- php4i_add_header_information(header_line, sizeof(CONTEXT_TYPE_IMAGE_GIF)-1);
- PHPWRITE(php4_logo, sizeof(php4_logo));
- return;
- } else if (!strcmp(SG(request_info).query_string+1, "PHPE9568F35-D428-11d2-A769-00AA001ACF42")) {
- char *header_line = estrndup(CONTEXT_TYPE_IMAGE_GIF, sizeof(CONTEXT_TYPE_IMAGE_GIF));
-
- php4i_add_header_information(header_line, sizeof(CONTEXT_TYPE_IMAGE_GIF)-1);
- PHPWRITE(zend_logo, sizeof(zend_logo));
- return;
- } else if (!strcmp(SG(request_info).query_string+1, "PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000")) {
- php_print_credits(PHP_CREDITS_ALL);
- return;
- }
- }
-
- if (setjmp(EG(bailout))!=0) {
- return;
- }
-
-#if WIN32||WINNT
- UpdateIniFromRegistry(primary_file->filename);
-#endif
-
- if (PG(auto_prepend_file) && PG(auto_prepend_file)[0]) {
- prepend_file.filename = PG(auto_prepend_file);
- prepend_file.type = ZEND_HANDLE_FILENAME;
- prepend_file_p = &prepend_file;
- } else {
- prepend_file_p = NULL;
- }
- if (PG(auto_append_file) && PG(auto_append_file)[0]) {
- append_file.filename = PG(auto_append_file);
- append_file.type = ZEND_HANDLE_FILENAME;
- append_file_p = &append_file;
- } else {
- append_file_p = NULL;
- }
- EG(main_op_array) = zend_compile_files(0 CLS_CC, 3, prepend_file_p, primary_file, append_file_p);
- if (EG(main_op_array)) {
- zend_hash_environment(PLS_C ELS_CC SLS_CC);
- EG(active_op_array) = EG(main_op_array);
- zend_execute(EG(main_op_array) ELS_CC);
- }
-}
-
-
-
-/* some systems are missing these from their header files */
-
-#if APACHE
-PHPAPI int apache_php_module_main(request_rec *r, int fd, int display_source_mode SLS_DC)
-{
- zend_file_handle file_handle;
-#ifdef ZTS
- zend_compiler_globals cg;
- zend_executor_globals eg;
- php_core_globals pcg;
- zend_compiler_globals *compiler_globals=&cg;
- zend_executor_globals *executor_globals=&eg;
- php_core_globals *core_globals=&pcg;
-#endif
- SLS_FETCH();
-
- if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC) == FAILURE) {
- return FAILURE;
- }
- file_handle.type = ZEND_HANDLE_FD;
- file_handle.handle.fd = fd;
- file_handle.filename = SG(request_info).path_translated;
-
- if (display_source_mode) {
- zend_syntax_highlighter_ini syntax_highlighter_ini;
-
- if (open_file_for_scanning(&file_handle CLS_CC)==SUCCESS) {
- php_get_highlight_struct(&syntax_highlighter_ini);
- zend_highlight(&syntax_highlighter_ini);
- fclose(file_handle.handle.fp);
- return OK;
- } else {
- return NOT_FOUND;
- }
- } else {
- (void) php_execute_script(&file_handle CLS_CC ELS_CC);
- }
-
- php3_header(); /* Make sure headers have been sent */
- php_end_ob_buffering(1);
- return (OK);
-}
-#endif /* APACHE */
-
-
-#if WIN32||WINNT
-/* just so that this symbol gets exported... */
-PHPAPI void dummy_indent()
-{
- zend_indent();
-}
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/main/php.h b/main/php.h
deleted file mode 100644
index 2207dbce8d..0000000000
--- a/main/php.h
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Andi Gutmans <andi@zend.com> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef _PHP_H
-#define _PHP_H
-
-#ifdef HAVE_DMALLOC
-#include <dmalloc.h>
-#endif
-
-#define PHP_API_VERSION 19990421
-
-#define YYDEBUG 0
-
-#define CGI_BINARY (!APACHE && !USE_SAPI && !FHTTPD)
-
-#include "php_version.h"
-#include "zend.h"
-
-/* automake defines PACKAGE and VERSION for Zend too */
-#ifdef PACKAGE
-# undef PACKAGE
-#endif
-#ifdef VERSION
-# undef VERSION
-#endif
-
-#include "zend_API.h"
-
-
-extern unsigned char first_arg_force_ref[];
-extern unsigned char first_arg_allow_ref[];
-extern unsigned char second_arg_force_ref[];
-extern unsigned char second_arg_allow_ref[];
-
-
-/* somebody stealing BOOL from windows. pick something else!
-#ifndef BOOL
-#define BOOL MYBOOL
-#endif
-*/
-
-
-#if WIN32
-#include "config.w32.h"
-#include "win95nt.h"
-# ifdef PHP_EXPORTS
-# define PHPAPI __declspec(dllexport)
-# else
-# define PHPAPI __declspec(dllimport)
-# endif
-#else
-#include "php_config.h"
-#define PHPAPI
-#define THREAD_LS
-#endif
-
-
-/* PHP's DEBUG value must match Zend's ZEND_DEBUG value */
-#undef DEBUG
-#define DEBUG ZEND_DEBUG
-
-
-#if DEBUG || !(defined(__GNUC__)||defined(WIN32))
-#ifdef inline
-#undef inline
-#endif
-#define inline
-#endif
-
-
-#if HAVE_UNIX_H
-#include <unix.h>
-#endif
-
-#if HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
-
-#ifndef HAVE_STRLCPY
-size_t strlcpy(char *dst, const char *src, size_t siz);
-#endif
-
-#ifndef HAVE_STRLCAT
-size_t strlcat(char *dst, const char *src, size_t siz);
-#endif
-
-#include "request_info.h"
-
-#if HAVE_LIBDL
-# if MSVC5
-# include <windows.h>
-# define dlclose FreeLibrary
-# define dlopen(a,b) LoadLibrary(a)
-# define dlsym GetProcAddress
-# else
-#if HAVE_DLFCN_H && !((defined(_AIX) || defined(AIX)) && APACHE)
-# include <dlfcn.h>
-#endif
-# endif
-#endif
-
-#define CREATE_MUTEX(a,b)
-#define SET_MUTEX(a)
-#define FREE_MUTEX(a)
-
-/*
- * Then the ODBC support can use both iodbc and Solid,
- * uncomment this.
- * #define HAVE_ODBC (HAVE_IODBC|HAVE_SOLID)
- */
-
-#include <stdlib.h>
-#include <ctype.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#if HAVE_STDARG_H
-#include <stdarg.h>
-#else
-# if HAVE_SYS_VARARGS_H
-# include <sys/varargs.h>
-# endif
-#endif
-
-
-#include "zend_hash.h"
-#include "php3_compat.h"
-#include "zend_alloc.h"
-#include "zend_stack.h"
-
-typedef zval pval;
-
-#define pval_copy_constructor zval_copy_ctor
-#define pval_destructor zval_dtor
-
-#if STDC_HEADERS
-# include <string.h>
-#else
-# ifndef HAVE_MEMCPY
-# define memcpy(d, s, n) bcopy((s), (d), (n))
-# define memmove(d, s, n) bcopy ((s), (d), (n))
-# endif
-#endif
-
-#include "safe_mode.h"
-
-#ifndef HAVE_STRERROR
-extern char *strerror(int);
-#endif
-
-#include "fopen-wrappers.h"
-
-#if APACHE /* apache httpd */
-# if HAVE_AP_CONFIG_H
-#include "ap_config_auto.h"
-#ifdef RHAPSODY
-#undef HAVE_SNPRINTF
-#endif
-#include "ap_config.h"
-#ifdef RHAPSODY
-#undef HAVE_SNPRINTF
-#define HAVE_SNPRINTF 1
-#endif
-# endif
-# if HAVE_OLD_COMPAT_H
-#include "compat.h"
-# endif
-# if HAVE_AP_COMPAT_H
-#include "ap_compat.h"
-# endif
-#include "httpd.h"
-#include "http_main.h"
-#include "http_core.h"
-#include "http_request.h"
-#include "http_protocol.h"
-#include "http_config.h"
-#include "http_log.h"
-#define BLOCK_INTERRUPTIONS block_alarms
-#define UNBLOCK_INTERRUPTIONS unblock_alarms
-#endif
-
-#if HAVE_PWD_H
-# if WIN32||WINNT
-#include "win32/pwd.h"
-#include "win32/param.h"
-# else
-#include <pwd.h>
-#include <sys/param.h>
-# endif
-#endif
-#if CGI_BINARY /* CGI version */
-#define BLOCK_INTERRUPTIONS NULL
-#define UNBLOCK_INTERRUPTIONS NULL
-#endif
-
-#if HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-#ifndef LONG_MAX
-#define LONG_MAX 2147483647L
-#endif
-
-#ifndef LONG_MIN
-#define LONG_MIN (- LONG_MAX - 1)
-#endif
-
-#if (!HAVE_SNPRINTF)
-#define snprintf ap_snprintf
-#define vsnprintf ap_vsnprintf
-extern int ap_snprintf(char *, size_t, const char *, ...);
-extern int ap_vsnprintf(char *, size_t, const char *, va_list);
-#endif
-
-#define EXEC_INPUT_BUF 4096
-
-
-#define DONT_FREE 0
-#define DO_FREE 1
-
-#define PHP3_MIME_TYPE "application/x-httpd-php3"
-
-/* macros */
-#undef MIN
-#undef MAX
-#undef COPY_STRING
-#define DO_OR_DIE(retvalue) if (retvalue==FAILURE) { return FAILURE; }
-#define MAX(a,b) (((a)>(b))?(a):(b))
-#define MIN(a,b) (((a)<(b))?(a):(b))
-#define STR_FREE(ptr) if (ptr && ptr!=empty_string && ptr!=undefined_variable_string) { efree(ptr); }
-#define COPY_STRING(yy) (yy).value.str.val = (char *) estrndup((yy).value.str.val,(yy).value.str.len)
-#define STR_PRINT(str) ((str)?(str):"")
-#define HASH_OF(p) ((p)->type==IS_ARRAY ? (p)->value.ht : (((p)->type==IS_OBJECT ? (p)->value.obj.properties : NULL)))
-
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 256 /* Should be safe for any weird systems that do not define it */
-#endif
-
-#define PHP_FN(name) php3_##name
-#define PHP_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS)
-#define PHP_FUNCTION(name) PHP_NAMED_FUNCTION(php3_##name)
-
-#define PHP_NAMED_FE(php_name, name, arg_types) { #php_name, name, arg_types },
-#define PHP_FE(name, arg_types) PHP_NAMED_FE(name, php3_##name, arg_types)
-#define PHP_FALIAS(name, alias, arg_types) PHP_NAMED_FE(name, php3_##alias, arg_types)
-
-#define PHP_MINIT(module) php3_minit_##module
-#define PHP_MSHUTDOWN(module) php3_mshutdown_##module
-#define PHP_RINIT(module) php3_rinit_##module
-#define PHP_RSHUTDOWN(module) php3_rshutdown_##module
-#define PHP_MINFO(module) php3_info_##module
-#define PHP_GINIT(module) php3_ginit_##module
-#define PHP_GSHUTDOWN(module) php3_gshutdown_##module
-
-#define PHP_MINIT_FUNCTION(module) int PHP_MINIT(module)(INIT_FUNC_ARGS)
-#define PHP_MSHUTDOWN_FUNCTION(module) int PHP_MSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS)
-#define PHP_RINIT_FUNCTION(module) int PHP_RINIT(module)(INIT_FUNC_ARGS)
-#define PHP_RSHUTDOWN_FUNCTION(module) int PHP_RSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS)
-#define PHP_MINFO_FUNCTION(module) void PHP_MINFO(module)(ZEND_MODULE_INFO_FUNC_ARGS)
-#define PHP_GINIT_FUNCTION(module) static int PHP_GINIT(module)(void)
-#define PHP_GSHUTDOWN_FUNCTION(module) static int PHP_GSHUTDOWN(module)(void)
-
-
-/* global variables */
-extern pval *data;
-#if !(WIN32||WINNT)
-extern char **environ;
-#endif
-
-extern void phperror(char *error);
-extern PHPAPI void php_error(int type, const char *format,...);
-extern PHPAPI int php3_write(void *buf, int size);
-extern PHPAPI int php_printf(const char *format,...);
-extern void php3_log_err(char *log_message);
-extern int Debug(char *format,...);
-extern int cfgparse(void);
-
-extern void html_putc(char c);
-
-#define zenderror phperror
-#define zendlex phplex
-
-#define phpparse zendparse
-#define phprestart zendrestart
-#define phpin zendin
-
-/* functions */
-int module_startup_modules(void);
-int module_global_startup_modules(void);
-int module_global_shutdown_modules(void);
-
-/* needed for modules only */
-extern PHPAPI int php3i_get_le_fp(void);
-
-/*from basic functions*/
-extern PHPAPI int _php_error_log(int opt_err,char *message,char *opt,char *headers);
-
-PHPAPI int cfg_get_long(char *varname, long *result);
-PHPAPI int cfg_get_double(char *varname, double *result);
-PHPAPI int cfg_get_string(char *varname, char **result);
-
-
-/* Output support */
-#include "output.h"
-#define PHPWRITE(str, str_len) php_body_write((str), (str_len))
-#define PUTS(str) php_body_write((str), strlen((str)))
-#define PUTC(c) (php_body_write(&(c), 1), (c))
-#define PHPWRITE_H(str, str_len) php_header_write((str), (str_len))
-#define PUTS_H(str) php_header_write((str), strlen((str)))
-#define PUTC_H(c) (php_header_write(&(c), 1), (c))
-
-
-#include "zend_operators.h"
-#include "zend_variables.h"
-#include "zend_constants.h"
-
-/* connection status states */
-#define PHP_CONNECTION_NORMAL 0
-#define PHP_CONNECTION_ABORTED 1
-#define PHP_CONNECTION_TIMEOUT 2
-
-
-/* Finding offsets of elements within structures.
- * Taken from the Apache code, which in turn, was taken from X code...
- */
-
-#if defined(CRAY) || (defined(__arm) && !defined(LINUX))
-#ifdef __STDC__
-#define XtOffset(p_type,field) _Offsetof(p_type,field)
-#else
-#ifdef CRAY2
-#define XtOffset(p_type,field) \
- (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
-
-#else /* !CRAY2 */
-
-#define XtOffset(p_type,field) ((unsigned int)&(((p_type)NULL)->field))
-
-#endif /* !CRAY2 */
-#endif /* __STDC__ */
-#else /* ! (CRAY || __arm) */
-
-#define XtOffset(p_type,field) \
- ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
-
-#endif /* !CRAY */
-
-#ifdef offsetof
-#define XtOffsetOf(s_type,field) offsetof(s_type,field)
-#else
-#define XtOffsetOf(s_type,field) XtOffset(s_type*,field)
-#endif
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/main/php3_compat.h b/main/php3_compat.h
deleted file mode 100644
index 1b8db14617..0000000000
--- a/main/php3_compat.h
+++ /dev/null
@@ -1,92 +0,0 @@
-#ifndef _PHP3_COMPAT_H
-#define _PHP3_COMPAT_H
-
-#define _php3_hash_init zend_hash_init
-#define _php3_hash_destroy zend_hash_destroy
-
-#define _php3_hash_clean zend_hash_clean
-
-#define _php3_hash_add_or_update zend_hash_add_or_update
-#define _php3_hash_add zend_hash_add
-#define _php3_hash_update zend_hash_update
-#define _php3_hash_update_ptr zend_hash_update_ptr
-
-#define _php3_hash_quick_add_or_update zend_hash_quick_add_or_update
-#define _php3_hash_quick_add zend_hash_quick_add
-#define _php3_hash_quick_update zend_hash_quick_update
-
-#define _php3_hash_index_update_or_next_insert zend_hash_index_update_or_next_insert
-#define _php3_hash_index_update zend_hash_index_update
-#define _php3_hash_next_index_insert zend_hash_next_index_insert
-
-#define _php3_hash_pointer_update zend_hash_pointer_update
-
-#define _php3_hash_pointer_index_update_or_next_insert zend_hash_pointer_index_update_or_next_insert
-#define _php3_hash_pointer_index_update zend_hash_pointer_index_update
-#define _php3_hash_next_index_pointer_update zend_hash_next_index_pointer_update
-#define _php3_hash_next_index_pointer_insert zend_hash_next_index_pointer_insert
-
-#define _php3_hash_del_key_or_index zend_hash_del_key_or_index
-#define _php3_hash_del zend_hash_del
-#define _php3_hash_index_del zend_hash_index_del
-
-#define _php3_hash_find zend_hash_find
-#define _php3_hash_quick_find zend_hash_quick_find
-#define _php3_hash_index_find zend_hash_index_find
-
-#define _php3_hash_exists zend_hash_exists
-#define _php3_hash_index_exists zend_hash_index_exists
-#define _php3_hash_is_pointer zend_hash_is_pointer
-#define _php3_hash_index_is_pointer zend_hash_index_is_pointer
-#define _php3_hash_next_free_element zend_hash_next_free_element
-
-#define _php3_hash_move_forward zend_hash_move_forward
-#define _php3_hash_move_backwards zend_hash_move_backwards
-#define _php3_hash_get_current_key zend_hash_get_current_key
-#define _php3_hash_get_current_data zend_hash_get_current_data
-#define _php3_hash_internal_pointer_reset zend_hash_internal_pointer_reset
-#define _php3_hash_internal_pointer_end zend_hash_internal_pointer_end
-
-#define _php3_hash_copy zend_hash_copy
-#define _php3_hash_merge zend_hash_merge
-#define _php3_hash_sort zend_hash_sort
-#define _php3_hash_minmax zend_hash_minmax
-
-#define _php3_hash_num_elements zend_hash_num_elements
-
-#define _php3_hash_apply zend_hash_apply
-#define _php3_hash_apply_with_argument zend_hash_apply_with_argument
-
-
-#define php3_error php_error
-
-#define php3_printf php_printf
-#define _php3_sprintf php_sprintf
-
-
-
-#define php3_module_entry zend_module_entry
-
-#define php3_strndup zend_strndup
-#define php3_str_tolower zend_str_tolower
-#define php3_binary_strcmp zend_binary_strcmp
-
-
-#define php3_list_insert zend_list_insert
-#define php3_list_find zend_list_find
-#define php3_list_delete zend_list_delete
-
-#define php3_plist_insert zend_plist_insert
-#define php3_plist_find zend_plist_find
-#define php3_plist_delete zend_plist_delete
-
-#define zend_print_pval zend_print_zval
-#define zend_print_pval_r zend_print_zval_r
-
-
-#define function_entry zend_function_entry
-
-#define _php3_addslashes php_addslashes
-#define _php3_stripslashes php_stripslashes
-
-#endif /* _PHP3_COMPAT_H */
diff --git a/main/php_content_types.c b/main/php_content_types.c
deleted file mode 100644
index 40787b5b65..0000000000
--- a/main/php_content_types.c
+++ /dev/null
@@ -1,25 +0,0 @@
-#include "php.h"
-#include "SAPI.h"
-#include "rfc1867.h"
-
-static sapi_post_content_type_reader php_post_content_types[] = {
- { MULTIPART_CONTENT_TYPE, sizeof(MULTIPART_CONTENT_TYPE)-1, rfc1867_post_reader },
- { NULL, 0, NULL }
-};
-
-
-SAPI_POST_READER_FUNC(php_default_post_reader)
-{
- ELS_FETCH();
-
- sapi_read_standard_form_data(content_type_dup SLS_CC);
- SET_VAR_STRINGL("HTTP_RAW_POST_DATA", SG(request_info).post_data, SG(request_info).post_data_length);
-}
-
-
-int php_startup_SAPI_content_types()
-{
- sapi_register_post_readers(php_post_content_types);
- sapi_register_default_post_reader(php_default_post_reader);
- return SUCCESS;
-}
diff --git a/main/php_content_types.h b/main/php_content_types.h
deleted file mode 100644
index 59ccbf93f7..0000000000
--- a/main/php_content_types.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _PHP_CONTENT_TYPES_H
-#define _PHP_CONTENT_TYPES_H
-
-int php_startup_SAPI_content_types();
-
-#endif /* _PHP_CONTENT_TYPES_H */
diff --git a/main/php_globals.h b/main/php_globals.h
deleted file mode 100644
index ab2ba8ac32..0000000000
--- a/main/php_globals.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
-*/
-
-
-#ifndef _PHP_GLOBALS_H
-#define _PHP_GLOBALS_H
-
-#include "zend_globals.h"
-
-typedef struct _php_core_globals php_core_globals;
-
-#ifdef ZTS
-# define PLS_D php_core_globals *core_globals
-# define PLS_DC , PLS_D
-# define PLS_C core_globals
-# define PLS_CC , PLS_C
-# define PG(v) (core_globals->v)
-# define PLS_FETCH() php_core_globals *core_globals = ts_resource(core_globals_id)
-extern PHPAPI int core_globals_id;
-#else
-# define PLS_D
-# define PLS_DC
-# define PLS_C
-# define PLS_CC
-# define PG(v) (core_globals.v)
-# define PLS_FETCH()
-extern ZEND_API struct _php_core_globals core_globals;
-#endif
-
-
-struct _php_core_globals {
- zend_bool magic_quotes_gpc;
- zend_bool magic_quotes_runtime;
- zend_bool magic_quotes_sybase;
-
- zend_bool asp_tags;
- zend_bool short_tags;
- zend_bool output_buffering;
-
- zend_bool safe_mode;
- zend_bool sql_safe_mode;
- char *safe_mode_exec_dir;
- zend_bool enable_dl;
-
- long memory_limit;
-
- zend_bool track_errors;
- zend_bool display_errors;
- zend_bool log_errors;
- char *error_log;
-
- char *doc_root;
- char *user_dir;
- char *include_path;
- char *open_basedir;
- char *extension_dir;
-
- char *upload_tmp_dir;
- long upload_max_filesize;
-
- char *auto_prepend_file;
- char *auto_append_file;
-
- char *arg_separator;
- char *gpc_order;
-
- zend_bool expose_php;
-
- zend_bool track_vars;
- zend_bool gpc_globals;
-
- zend_bool y2k_compliance;
-
- short connection_status;
- short ignore_user_abort;
-
- unsigned char header_is_being_sent;
-
- /* for fsock */
- HashTable ht_fsock_keys;
- HashTable ht_fsock_socks;
-};
-
-
-#endif /* _PHP_GLOBALS_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/main/php_ini.c b/main/php_ini.c
deleted file mode 100644
index 7848008652..0000000000
--- a/main/php_ini.c
+++ /dev/null
@@ -1,460 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-
-
-#include <stdlib.h>
-
-#include "php.h"
-#include "php_ini.h"
-#include "zend_alloc.h"
-#include "php_globals.h"
-#include "ext/standard/info.h"
-
-static HashTable known_directives;
-
-
-/*
- * hash_apply functions
- */
-static int php_remove_ini_entries(php_ini_entry *ini_entry, int *module_number)
-{
- if (ini_entry->module_number == *module_number) {
- return 1;
- } else {
- return 0;
- }
-}
-
-
-static int php_restore_ini_entry_cb(php_ini_entry *ini_entry)
-{
- if (ini_entry->modified) {
- if (ini_entry->on_modify) {
- ini_entry->on_modify(ini_entry, ini_entry->orig_value, ini_entry->orig_value_length, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3);
- }
- efree(ini_entry->value);
- ini_entry->value = ini_entry->orig_value;
- ini_entry->value_length = ini_entry->orig_value_length;
- ini_entry->modified = 0;
- ini_entry->orig_value = NULL;
- ini_entry->orig_value_length = 0;
- }
- return 0;
-}
-
-/*
- * Startup / shutdown
- */
-int php_ini_mstartup()
-{
- if (zend_hash_init(&known_directives, 100, NULL, NULL, 1)==FAILURE) {
- return FAILURE;
- }
- return SUCCESS;
-}
-
-
-int php_ini_mshutdown()
-{
- zend_hash_destroy(&known_directives);
- return SUCCESS;
-}
-
-
-int php_ini_rshutdown()
-{
- zend_hash_apply(&known_directives, (int (*)(void *)) php_restore_ini_entry_cb);
- return SUCCESS;
-}
-
-/*
- * Registration / unregistration
- */
-
-PHPAPI int php_register_ini_entries(php_ini_entry *ini_entry, int module_number)
-{
- php_ini_entry *p = ini_entry;
- php_ini_entry *hashed_ini_entry;
- pval *default_value;
-
- while (p->name) {
- p->module_number = module_number;
- if (zend_hash_add(&known_directives, p->name, p->name_length, p, sizeof(php_ini_entry), (void **) &hashed_ini_entry)==FAILURE) {
- php_unregister_ini_entries(module_number);
- return FAILURE;
- }
- if (hashed_ini_entry->on_modify) {
- hashed_ini_entry->on_modify(hashed_ini_entry, hashed_ini_entry->value, hashed_ini_entry->value_length, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3);
- }
- if ((default_value=cfg_get_entry(p->name, p->name_length))) {
- if (!hashed_ini_entry->on_modify
- || hashed_ini_entry->on_modify(hashed_ini_entry, default_value->value.str.val, default_value->value.str.len, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3)==SUCCESS) {
- hashed_ini_entry->value = default_value->value.str.val;
- hashed_ini_entry->value_length = default_value->value.str.len;
- }
- } else {
- if (hashed_ini_entry->on_modify) {
- hashed_ini_entry->on_modify(hashed_ini_entry, hashed_ini_entry->value, hashed_ini_entry->value_length, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3);
- }
- }
- hashed_ini_entry->modified = 0;
- p++;
- }
- return SUCCESS;
-}
-
-
-PHPAPI void php_unregister_ini_entries(int module_number)
-{
- zend_hash_apply_with_argument(&known_directives, (int (*)(void *, void *)) php_remove_ini_entries, (void *) &module_number);
-}
-
-
-static int php_ini_refresh_cache(php_ini_entry *p)
-{
- if (p->on_modify) {
- p->on_modify(p, p->value, p->value_length, p->mh_arg1, p->mh_arg2, p->mh_arg3);
- }
- return 0;
-}
-
-
-PHPAPI void php_ini_refresh_caches()
-{
- zend_hash_apply(&known_directives, (int (*)(void *)) php_ini_refresh_cache);
-}
-
-
-PHPAPI int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type)
-{
- php_ini_entry *ini_entry;
- char *duplicate;
-
- if (zend_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==FAILURE) {
- return FAILURE;
- }
-
- if (!(ini_entry->modifyable & modify_type)) {
- return FAILURE;
- }
-
- duplicate = estrndup(new_value, new_value_length);
-
- if (!ini_entry->on_modify
- || ini_entry->on_modify(ini_entry, duplicate, new_value_length, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3)==SUCCESS) {
- if (!ini_entry->modified) {
- ini_entry->orig_value = ini_entry->value;
- ini_entry->orig_value_length = ini_entry->value_length;
- } else { /* we already changed the value, free the changed value */
- efree(ini_entry->value);
- }
- ini_entry->value = duplicate;
- ini_entry->value_length = new_value_length;
- ini_entry->modified = 1;
- } else {
- efree(duplicate);
- }
-
- return SUCCESS;
-}
-
-
-PHPAPI int php_restore_ini_entry(char *name, uint name_length)
-{
- php_ini_entry *ini_entry;
-
- if (zend_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==FAILURE) {
- return FAILURE;
- }
-
- php_restore_ini_entry_cb(ini_entry);
- return SUCCESS;
-}
-
-
-PHPAPI int php_ini_register_displayer(char *name, uint name_length, void (*displayer)(php_ini_entry *ini_entry, int type))
-{
- php_ini_entry *ini_entry;
-
- if (zend_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==FAILURE) {
- return FAILURE;
- }
-
- ini_entry->displayer = displayer;
- return SUCCESS;
-}
-
-
-
-/*
- * Data retrieval
- */
-
-PHPAPI long php_ini_long(char *name, uint name_length, int orig)
-{
- php_ini_entry *ini_entry;
-
- if (zend_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==SUCCESS) {
- if (orig && ini_entry->modified) {
- return (ini_entry->orig_value ? strtol(ini_entry->orig_value, NULL, 0) : 0);
- } else if (ini_entry->value) {
- return strtol(ini_entry->value, NULL, 0);
- }
- }
-
- return 0;
-}
-
-
-PHPAPI double php_ini_double(char *name, uint name_length, int orig)
-{
- php_ini_entry *ini_entry;
-
- if (zend_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==SUCCESS) {
- if (orig && ini_entry->modified) {
- return (double) (ini_entry->orig_value ? strtod(ini_entry->orig_value, NULL) : 0.0);
- } else if (ini_entry->value) {
- return (double) strtod(ini_entry->value, NULL);
- }
- }
-
- return 0.0;
-}
-
-
-PHPAPI char *php_ini_string(char *name, uint name_length, int orig)
-{
- php_ini_entry *ini_entry;
-
- if (zend_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==SUCCESS) {
- if (orig && ini_entry->modified) {
- return ini_entry->orig_value;
- } else {
- return ini_entry->value;
- }
- }
-
- return "";
-}
-
-
-php_ini_entry *get_ini_entry(char *name, uint name_length)
-{
- php_ini_entry *ini_entry;
-
- if (zend_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==SUCCESS) {
- return ini_entry;
- } else {
- return NULL;
- }
-}
-
-
-static void php_ini_displayer_cb(php_ini_entry *ini_entry, int type)
-{
- if (ini_entry->displayer) {
- ini_entry->displayer(ini_entry, type);
- } else {
- char *display_string;
- uint display_string_length;
-
- if (type==PHP_INI_DISPLAY_ORIG && ini_entry->modified) {
- if (ini_entry->orig_value) {
- display_string = ini_entry->orig_value;
- display_string_length = ini_entry->orig_value_length;
- } else {
- display_string = "<i>no value</i>";
- display_string_length = sizeof("<i>no value</i>")-1;
- }
- } else if (ini_entry->value && ini_entry->value[0]) {
- display_string = ini_entry->value;
- display_string_length = ini_entry->value_length;
- } else {
- display_string = "<i>no value</i>";
- display_string_length = sizeof("<i>no value</i>")-1;
- }
- PHPWRITE(display_string, display_string_length);
- }
-}
-
-
-PHP_INI_DISP(php_ini_boolean_displayer_cb)
-{
- int value;
-
- if (type==PHP_INI_DISPLAY_ORIG && ini_entry->modified) {
- value = (ini_entry->orig_value ? atoi(ini_entry->orig_value) : 0);
- } else if (ini_entry->value) {
- value = atoi(ini_entry->value);
- } else {
- value = 0;
- }
- if (value) {
- PUTS("On");
- } else {
- PUTS("Off");
- }
-}
-
-
-PHP_INI_DISP(php_ini_color_displayer_cb)
-{
- char *value;
-
- if (type==PHP_INI_DISPLAY_ORIG && ini_entry->modified) {
- value = ini_entry->orig_value;
- } else if (ini_entry->value) {
- value = ini_entry->value;
- } else {
- value = NULL;
- }
- if (value) {
- php_printf("<font color=\"%s\">%s</font>", value, value);
- } else {
- PUTS("<i>no value</i>;");
- }
-}
-
-
-static int php_ini_displayer(php_ini_entry *ini_entry, int module_number)
-{
- if (ini_entry->module_number != module_number) {
- return 0;
- }
-
- PUTS("<tr><td align=\"center\" bgcolor=\"" PHP_ENTRY_NAME_COLOR "\"><b>");
- PHPWRITE(ini_entry->name, ini_entry->name_length-1);
- PUTS("</b></td><td align=\"center\" bgcolor=\"" PHP_CONTENTS_COLOR "\">");
- php_ini_displayer_cb(ini_entry, PHP_INI_DISPLAY_ACTIVE);
- PUTS("</td><td align=\"center\" bgcolor=\"" PHP_CONTENTS_COLOR "\">");
- php_ini_displayer_cb(ini_entry, PHP_INI_DISPLAY_ORIG);
- PUTS("</td></tr>\n");
- return 0;
-}
-
-
-PHPAPI void display_ini_entries(zend_module_entry *module)
-{
- int module_number;
-
- if (module) {
- module_number = module->module_number;
- } else {
- module_number = 0;
- }
- PUTS("<table border=5 width=\"600\">\n");
- php_info_print_table_header(3, "Directive", "Local Value", "Master Value");
- zend_hash_apply_with_argument(&known_directives, (int (*)(void *, void *)) php_ini_displayer, (void *) (long) module_number);
- PUTS("</table>\n");
-}
-
-
-/* Standard message handlers */
-
-PHPAPI PHP_INI_MH(OnUpdateBool)
-{
- zend_bool *p;
-#ifndef ZTS
- char *base = (char *) mh_arg2;
-#else
- char *base;
-
- base = (char *) ts_resource(*((int *) mh_arg2));
-#endif
-
- p = (zend_bool *) (base+(size_t) mh_arg1);
-
- *p = (zend_bool) atoi(new_value);
- return SUCCESS;
-}
-
-
-PHPAPI PHP_INI_MH(OnUpdateInt)
-{
- long *p;
-#ifndef ZTS
- char *base = (char *) mh_arg2;
-#else
- char *base;
-
- base = (char *) ts_resource(*((int *) mh_arg2));
-#endif
-
- p = (long *) (base+(size_t) mh_arg1);
-
- *p = atoi(new_value);
- return SUCCESS;
-}
-
-
-PHPAPI PHP_INI_MH(OnUpdateReal)
-{
- double *p;
-#ifndef ZTS
- char *base = (char *) mh_arg2;
-#else
- char *base;
-
- base = (char *) ts_resource(*((int *) mh_arg2));
-#endif
-
- p = (double *) (base+(size_t) mh_arg1);
-
- *p = strtod(new_value, NULL);
- return SUCCESS;
-}
-
-
-PHPAPI PHP_INI_MH(OnUpdateString)
-{
- char **p;
-#ifndef ZTS
- char *base = (char *) mh_arg2;
-#else
- char *base;
-
- base = (char *) ts_resource(*((int *) mh_arg2));
-#endif
-
- p = (char **) (base+(size_t) mh_arg1);
-
- *p = new_value;
- return SUCCESS;
-}
-
-
-PHPAPI PHP_INI_MH(OnUpdateStringUnempty)
-{
- char **p;
-#ifndef ZTS
- char *base = (char *) mh_arg2;
-#else
- char *base;
-
- base = (char *) ts_resource(*((int *) mh_arg2));
-#endif
-
- if (new_value && !new_value[0]) {
- return FAILURE;
- }
-
- p = (char **) (base+(size_t) mh_arg1);
-
- *p = new_value;
- return SUCCESS;
-}
diff --git a/main/php_ini.h b/main/php_ini.h
deleted file mode 100644
index 339c4aa7ac..0000000000
--- a/main/php_ini.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
-*/
-
-#ifndef _PHP_INI_H
-#define _PHP_INI_H
-
-#define PHP_INI_USER (1<<0)
-#define PHP_INI_PERDIR (1<<1)
-#define PHP_INI_SYSTEM (1<<2)
-
-#define PHP_INI_ALL (PHP_INI_USER|PHP_INI_PERDIR|PHP_INI_SYSTEM)
-
-typedef struct _php_ini_entry php_ini_entry;
-
-#define PHP_INI_MH(name) int name(php_ini_entry *entry, char *new_value, uint new_value_length, void *mh_arg1, void *mh_arg2, void *mh_arg3)
-#define PHP_INI_DISP(name) void name(php_ini_entry *ini_entry, int type)
-
-struct _php_ini_entry {
- int module_number;
- int modifyable;
- char *name;
- uint name_length;
- PHP_INI_MH((*on_modify));
- void *mh_arg1;
- void *mh_arg2;
- void *mh_arg3;
-
- char *value;
- uint value_length;
-
- char *orig_value;
- uint orig_value_length;
- int modified;
-
- void (*displayer)(php_ini_entry *ini_entry, int type);
-};
-
-
-int php_ini_mstartup();
-int php_ini_mshutdown();
-int php_ini_rshutdown();
-
-PHPAPI int php_register_ini_entries(php_ini_entry *ini_entry, int module_number);
-PHPAPI void php_unregister_ini_entries(int module_number);
-PHPAPI void php_ini_refresh_caches();
-PHPAPI int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type);
-PHPAPI int php_restore_ini_entry(char *name, uint name_length);
-PHPAPI void display_ini_entries(zend_module_entry *module);
-
-PHPAPI long php_ini_long(char *name, uint name_length, int orig);
-PHPAPI double php_ini_double(char *name, uint name_length, int orig);
-PHPAPI char *php_ini_string(char *name, uint name_length, int orig);
-php_ini_entry *get_ini_entry(char *name, uint name_length);
-
-PHPAPI int php_ini_register_displayer(char *name, uint name_length, void (*displayer)(php_ini_entry *ini_entry, int type));
-PHPAPI PHP_INI_DISP(php_ini_boolean_displayer_cb);
-PHPAPI PHP_INI_DISP(php_ini_color_displayer_cb);
-
-#define PHP_INI_BEGIN() static php_ini_entry ini_entries[] = {
-#define PHP_INI_END() { 0, 0, NULL, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, NULL } };
-
-#define PHP_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, arg1, arg2, arg3, displayer) \
- { 0, modifyable, name, sizeof(name), on_modify, arg1, arg2, arg3, default_value, sizeof(default_value)-1, NULL, 0, 0, displayer },
-
-#define PHP_INI_ENTRY3(name, default_value, modifyable, on_modify, arg1, arg2, arg3) \
- PHP_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, arg1, arg2, arg3, NULL)
-
-#define PHP_INI_ENTRY2_EX(name, default_value, modifyable, on_modify, arg1, arg2, displayer) \
- PHP_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, arg1, arg2, NULL, displayer)
-
-#define PHP_INI_ENTRY2(name, default_value, modifyable, on_modify, arg1, arg2) \
- PHP_INI_ENTRY2_EX(name, default_value, modifyable, on_modify, arg1, arg2, NULL)
-
-#define PHP_INI_ENTRY1_EX(name, default_value, modifyable, on_modify, arg1, displayer) \
- PHP_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, arg1, NULL, NULL, displayer)
-
-#define PHP_INI_ENTRY1(name, default_value, modifyable, on_modify, arg1) \
- PHP_INI_ENTRY1_EX(name, default_value, modifyable, on_modify, arg1, NULL)
-
-#define PHP_INI_ENTRY_EX(name, default_value, modifyable, on_modify, displayer) \
- PHP_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, NULL, NULL, NULL, displayer)
-
-#define PHP_INI_ENTRY(name, default_value, modifyable, on_modify) \
- PHP_INI_ENTRY_EX(name, default_value, modifyable, on_modify, NULL)
-
-#ifdef ZTS
-#define STD_PHP_INI_ENTRY(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
- PHP_INI_ENTRY2(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id)
-#define STD_PHP_INI_ENTRY_EX(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr, displayer) \
- PHP_INI_ENTRY2_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id, displayer)
-#define STD_PHP_INI_BOOLEAN(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
- PHP_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id, NULL, php_ini_boolean_displayer_cb)
-#else
-#define STD_PHP_INI_ENTRY(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
- PHP_INI_ENTRY2(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr)
-#define STD_PHP_INI_ENTRY_EX(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr, displayer) \
- PHP_INI_ENTRY2_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, displayer)
-#define STD_PHP_INI_BOOLEAN(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
- PHP_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, NULL, php_ini_boolean_displayer_cb)
-#endif
-
-#define INI_INT(name) php_ini_long((name), sizeof(name), 0)
-#define INI_FLT(name) php_ini_double((name), sizeof(name), 0)
-#define INI_STR(name) php_ini_string((name), sizeof(name), 0)
-
-
-#define INI_ORIG_INT(name) php_ini_long((name), sizeof(name), 1)
-#define INI_ORIG_FLT(name) php_ini_double((name), sizeof(name), 1)
-#define INI_ORIG_STR(name) php_ini_string((name), sizeof(name), 1)
-
-
-#define REGISTER_INI_ENTRIES() php_register_ini_entries(ini_entries, module_number)
-#define UNREGISTER_INI_ENTRIES() php_unregister_ini_entries(module_number)
-#define DISPLAY_INI_ENTRIES() display_ini_entries(zend_module)
-
-#define REGISTER_INI_DISPLAYER(name, displayer) php_ini_register_displayer((name), sizeof(name), displayer)
-#define REGISTER_INI_BOOLEAN(name) REGISTER_INI_DISPLAYER(name, php_ini_boolean_displayer_cb)
-
-pval *cfg_get_entry(char *name, uint name_length);
-
-
-/* Standard message handlers */
-PHPAPI PHP_INI_MH(OnUpdateBool);
-PHPAPI PHP_INI_MH(OnUpdateInt);
-PHPAPI PHP_INI_MH(OnUpdateReal);
-PHPAPI PHP_INI_MH(OnUpdateString);
-PHPAPI PHP_INI_MH(OnUpdateStringUnempty);
-
-
-#define PHP_INI_DISPLAY_ORIG 1
-#define PHP_INI_DISPLAY_ACTIVE 2
-
-#endif /* _PHP_INI_H */
diff --git a/main/php_regex.h b/main/php_regex.h
deleted file mode 100644
index 9ed80d84b8..0000000000
--- a/main/php_regex.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef _PHP_REGEX_H
-#define _PHP_REGEX_H
-
-#if REGEX
-#include "regex/regex.h"
-#define _REGEX_H 1 /* this should stop Apache from loading the system version of regex.h */
-#define _RX_H 1 /* Try defining these for Linux to */
-#define __REGEXP_LIBRARY_H__ 1 /* avoid Apache including regex.h */
-#define _H_REGEX 1 /* This one is for AIX */
-#else
-#include <regex.h>
-#endif
-
-#endif /* _PHP_REGEX_H */
diff --git a/main/php_version.h b/main/php_version.h
deleted file mode 100644
index 689fd183ba..0000000000
--- a/main/php_version.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/* automatically generated by configure */
-/* edit configure.in.in to change version number */
-#define PHP_VERSION "4.0B3-dev"
diff --git a/main/rfc1867.c b/main/rfc1867.c
deleted file mode 100644
index d210d091a9..0000000000
--- a/main/rfc1867.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include <stdio.h>
-#include "php.h"
-#include "ext/standard/php3_standard.h"
-#include "zend_globals.h"
-#include "php_globals.h"
-#include "rfc1867.h"
-
-#ifndef THREAD_SAFE
-int le_uploads;
-extern HashTable list;
-#endif
-
-#define NEW_BOUNDARY_CHECK 1
-#define SAFE_RETURN { if (namebuf) efree(namebuf); if (filenamebuf) efree(filenamebuf); if (lbuf) efree(lbuf); return; }
-
-/*
- * Split raw mime stream up into appropriate components
- */
-void php_mime_split(char *buf, int cnt, char *boundary)
-{
- char *ptr, *loc, *loc2, *s, *name, *filename, *u, *fn;
- int len, state = 0, Done = 0, rem, urem;
- long bytes, max_file_size = 0;
- char *namebuf=NULL, *filenamebuf=NULL, *lbuf=NULL;
- FILE *fp;
- int itype;
- zval *http_post_vars=NULL;
- ELS_FETCH();
- PLS_FETCH();
-
- if (PG(track_vars)) {
- http_post_vars = (pval *) emalloc(sizeof(pval));
- array_init(http_post_vars);
- INIT_PZVAL(http_post_vars);
-
- zend_hash_add(&EG(symbol_table), "HTTP_POST_VARS", sizeof("HTTP_POST_VARS"), &http_post_vars, sizeof(pval *), NULL);
- }
-
- ptr = buf;
- rem = cnt;
- len = strlen(boundary);
- while ((ptr - buf < cnt) && !Done) {
- switch (state) {
- case 0: /* Looking for mime boundary */
- loc = memchr(ptr, *boundary, cnt);
- if (loc) {
- if (!strncmp(loc, boundary, len)) {
-
- state = 1;
- rem -= (loc - ptr) + len + 2;
- ptr = loc + len + 2;
- } else {
- rem -= (loc - ptr) + 1;
- ptr = loc + 1;
- }
- } else {
- Done = 1;
- }
- break;
- case 1: /* Check content-disposition */
- if (strncasecmp(ptr, "Content-Disposition: form-data;", 31)) {
- if (rem < 31) {
- SAFE_RETURN;
- }
- php_error(E_WARNING, "File Upload Mime headers garbled [%c%c%c%c%c]", *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3), *(ptr + 4));
- SAFE_RETURN;
- }
- loc = memchr(ptr, '\n', rem);
- name = strstr(ptr, " name=\"");
- if (name && name < loc) {
- name += 7;
- s = memchr(name, '\"', loc - name);
- if (!s) {
- php_error(E_WARNING, "File Upload Mime headers garbled [%c%c%c%c%c]", *name, *(name + 1), *(name + 2), *(name + 3), *(name + 4));
- SAFE_RETURN;
- }
- if (namebuf) {
- efree(namebuf);
- }
- namebuf = estrndup(name, s-name);
- if (lbuf) {
- efree(lbuf);
- }
- lbuf = emalloc(s-name + MAX(MAX(sizeof("_name"),sizeof("_size")),sizeof("_type")));
- state = 2;
- loc2 = memchr(loc + 1, '\n', rem);
- rem -= (loc2 - ptr) + 1;
- ptr = loc2 + 1;
- } else {
- php_error(E_WARNING, "File upload error - no name component in content disposition");
- SAFE_RETURN;
- }
- filename = strstr(s, " filename=\"");
- if (filename && filename < loc) {
- filename += 11;
- s = memchr(filename, '\"', loc - filename);
- if (!s) {
- php_error(E_WARNING, "File Upload Mime headers garbled [%c%c%c%c%c]", *filename, *(filename + 1), *(filename + 2), *(filename + 3), *(filename + 4));
- SAFE_RETURN;
- }
- if (filenamebuf) {
- efree(filenamebuf);
- }
- filenamebuf = estrndup(filename, s-filename);
- sprintf(lbuf, "%s_name", namebuf);
- s = strrchr(filenamebuf, '\\');
- if (s && s > filenamebuf) {
- SET_VAR_STRING(lbuf, estrdup(s + 1));
- } else {
- SET_VAR_STRING(lbuf, estrdup(filenamebuf));
- }
- state = 3;
- if ((loc2 - loc) > 2) {
- if (!strncasecmp(loc + 1, "Content-Type:", 13)) {
- *(loc2 - 1) = '\0';
- sprintf(lbuf, "%s_type", namebuf);
- SET_VAR_STRING(lbuf, estrdup(loc + 15));
- *(loc2 - 1) = '\n';
- }
- rem -= 2;
- ptr += 2;
- }
- }
- break;
-
- case 2: /* handle form-data fields */
- loc = memchr(ptr, *boundary, rem);
- u = ptr;
- while (loc) {
- if (!strncmp(loc, boundary, len))
- break;
- u = loc + 1;
- urem = rem - (loc - ptr) - 1;
- loc = memchr(u, *boundary, urem);
- }
- if (!loc) {
- php_error(E_WARNING, "File Upload Field Data garbled");
- SAFE_RETURN;
- }
- *(loc - 4) = '\0';
-
- /* Magic function that figures everything out */
- php_parse_gpc_data2(ptr,namebuf,http_post_vars ELS_CC PLS_CC);
-
- /* And a little kludge to pick out special MAX_FILE_SIZE */
- itype = php3_check_ident_type(namebuf);
- if (itype) {
- u = strchr(namebuf, '[');
- if (u)
- *u = '\0';
- }
- if (!strcmp(namebuf, "MAX_FILE_SIZE")) {
- max_file_size = atol(ptr);
- }
- if (itype) {
- if (u)
- *u = '[';
- }
- rem -= (loc - ptr);
- ptr = loc;
- state = 0;
- break;
-
- case 3: /* Handle file */
- loc = memchr(ptr, *boundary, rem);
- u = ptr;
- while (loc) {
- if (!strncmp(loc, boundary, len)
-#if NEW_BOUNDARY_CHECK
- && (loc-2>buf && *(loc-2)=='-' && *(loc-1)=='-') /* ensure boundary is prefixed with -- */
- && (loc-2==buf || *(loc-3)=='\n') /* ensure beginning of line */
-#endif
- ) {
- break;
- }
- u = loc + 1;
- urem = rem - (loc - ptr) - 1;
- loc = memchr(u, *boundary, urem);
- }
- if (!loc) {
- php_error(E_WARNING, "File Upload Error - No Mime boundary found after start of file header");
- SAFE_RETURN;
- }
- fn = tempnam(PG(upload_tmp_dir), "php");
- if ((loc - ptr - 4) > PG(upload_max_filesize)) {
- php_error(E_WARNING, "Max file size of %ld bytes exceeded - file [%s] not saved", PG(upload_max_filesize),namebuf);
- bytes=0;
- SET_VAR_STRING(namebuf, estrdup("none"));
- } else if (max_file_size && ((loc - ptr - 4) > max_file_size)) {
- php_error(E_WARNING, "Max file size exceeded - file [%s] not saved", namebuf);
- bytes = 0;
- SET_VAR_STRING(namebuf, estrdup("none"));
- } else if ((loc - ptr - 4) <= 0) {
- bytes = 0;
- SET_VAR_STRING(namebuf, estrdup("none"));
- } else {
- fp = fopen(fn, "w");
- if (!fp) {
- php_error(E_WARNING, "File Upload Error - Unable to open temporary file [%s]", fn);
- SAFE_RETURN;
- }
- bytes = fwrite(ptr, 1, loc - ptr - 4, fp);
- fclose(fp);
- php3_list_insert(fn,le_uploads); /* Tell PHP about the file so the destructor can unlink it later */
- if (bytes < (loc - ptr - 4)) {
- php_error(E_WARNING, "Only %d bytes were written, expected to write %ld", bytes, loc - ptr - 4);
- }
- SET_VAR_STRING(namebuf, estrdup(fn));
- }
- sprintf(lbuf, "%s_size", namebuf);
- SET_VAR_LONG(lbuf, bytes);
- state = 0;
- rem -= (loc - ptr);
- ptr = loc;
- break;
- }
- }
- SAFE_RETURN;
-}
-
-
-SAPI_POST_READER_FUNC(rfc1867_post_reader)
-{
- char *boundary;
- uint boundary_len;
-
- boundary = strstr(content_type_dup, "boundary");
- if (!boundary || !(boundary=strchr(boundary, '='))) {
- sapi_module.sapi_error(E_COMPILE_ERROR, "Missing boundary in multipart/form-data POST data");
- return;
- }
- boundary++;
- boundary_len = strlen(boundary);
-
- sapi_read_standard_form_data(content_type_dup SLS_CC);
- if (SG(request_info).post_data) {
- php_mime_split(SG(request_info).post_data, SG(request_info).post_data_length, boundary);
- efree(SG(request_info).post_data);
- SG(request_info).post_data = NULL;
- }
-}
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/main/rfc1867.h b/main/rfc1867.h
deleted file mode 100644
index 97c1475e80..0000000000
--- a/main/rfc1867.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _RFC1867_H
-#define _RFC1867_H
-
-#include "SAPI.h"
-
-#define MULTIPART_CONTENT_TYPE "multipart/form-data"
-
-SAPI_POST_READER_FUNC(rfc1867_post_reader);
-
-#define FILE_UPLOAD_INPUT_BUFFER_SIZE 8192
-
-#endif /* _RFC1867_H */
diff --git a/main/safe_mode.c b/main/safe_mode.c
deleted file mode 100644
index 02bd31b9bf..0000000000
--- a/main/safe_mode.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include "php.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <sys/stat.h>
-#include "ext/standard/pageinfo.h"
-#include "safe_mode.h"
-#include "SAPI.h"
-
-/*
- * _php3_checkuid
- *
- * This function has four modes:
- *
- * 0 - return invalid (0) if file does not exist
- * 1 - return valid (1) if file does not exist
- * 2 - if file does not exist, check directory
- * 3 - only check directory (needed for mkdir)
- */
-PHPAPI int _php3_checkuid(const char *fn, int mode) {
- struct stat sb;
- int ret;
- long uid=0L, duid=0L;
- char *s;
-
- if (!fn) return(0); /* path must be provided */
-
- /*
- * If given filepath is a URL, allow - safe mode stuff
- * related to URL's is checked in individual functions
- */
- if (!strncasecmp(fn,"http://",7) || !strncasecmp(fn,"ftp://",6)) {
- return(1);
- }
-
- if (mode<3) {
- ret = stat(fn,&sb);
- if (ret<0 && mode < 2) {
- php_error(E_WARNING,"Unable to access %s",fn);
- return(mode);
- }
- if (ret>-1) {
- uid=sb.st_uid;
- if (uid==_php3_getuid()) return(1);
- }
- }
- s = strrchr(fn,'/');
-
- /* This loop gets rid of trailing slashes which could otherwise be
- * used to confuse the function.
- */
- while(s && *(s+1)=='\0' && s>fn) {
- s='\0';
- s = strrchr(fn,'/');
- }
-
- if (s) {
- *s='\0';
- ret = stat(fn,&sb);
- *s='/';
- if (ret<0) {
- php_error(E_WARNING, "Unable to access %s",fn);
- return(0);
- }
- duid = sb.st_uid;
- } else {
- s = emalloc(MAXPATHLEN+1);
- if (!getcwd(s,MAXPATHLEN)) {
- php_error(E_WARNING, "Unable to access current working directory");
- return(0);
- }
- ret = stat(s,&sb);
- efree(s);
- if (ret<0) {
- php_error(E_WARNING, "Unable to access %s",s);
- return(0);
- }
- duid = sb.st_uid;
- }
- if (duid == (uid=_php3_getuid())) return(1);
- else {
- php_error(E_WARNING, "SAFE MODE Restriction in effect. The script whose uid is %ld is not allowed to access %s owned by uid %ld",uid,fn,duid);
- return(0);
- }
-}
-
-
-PHPAPI char *_php3_get_current_user()
-{
-#if CGI_BINARY || USE_SAPI || FHTTPD
- struct stat statbuf;
-#endif
- struct passwd *pwd;
- int uid;
- SLS_FETCH();
-
- if (request_info.current_user) {
- return request_info.current_user;
- }
-
- /* FIXME: I need to have this somehow handled if
- USE_SAPI is defined, because cgi will also be
- interfaced in USE_SAPI */
-#if CGI_BINARY || USE_SAPI || FHTTPD
- if (!SG(request_info).path_translated || (stat(SG(request_info).path_translated,&statbuf)==-1)) {
- return empty_string;
- }
- uid = statbuf.st_uid;
-#endif
-#if APACHE
- uid = ((request_rec *) SG(server_context))->finfo.st_uid;
-#endif
-
- if ((pwd=getpwuid(uid))==NULL) {
- return empty_string;
- }
- request_info.current_user_length = strlen(pwd->pw_name);
- request_info.current_user = estrndup(pwd->pw_name,request_info.current_user_length);
-
- return request_info.current_user;
-}
diff --git a/main/safe_mode.h b/main/safe_mode.h
deleted file mode 100644
index 3ae320b46d..0000000000
--- a/main/safe_mode.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _SAFE_MODE_H_
-#define _SAFE_MODE_H_
-
-extern PHPAPI int _php3_checkuid(const char *filename, int mode);
-extern PHPAPI char *_php3_get_current_user(void);
-
-#endif
diff --git a/main/snprintf.c b/main/snprintf.c
deleted file mode 100644
index 4437dee003..0000000000
--- a/main/snprintf.c
+++ /dev/null
@@ -1,934 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1998 The Apache Group. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. All advertising materials mentioning features or use of this
- * software must display the following acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission.
- *
- * 5. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- * This code is based on, and used with the permission of, the
- * SIO stdio-replacement strx_* functions by Panos Tsirigotis
- * <panos@alumni.cs.colorado.edu> for xinetd.
- */
-
-#include "php.h"
-
-#if !defined(APACHE) || (!APACHE)
-#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
-
-#include <stdio.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <stdarg.h>
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-
-
-#ifdef HAVE_GCVT
-
-#define ap_ecvt ecvt
-#define ap_fcvt fcvt
-#define ap_gcvt gcvt
-
-#else
-
-/*
- * cvt.c - IEEE floating point formatting routines for FreeBSD
- * from GNU libc-4.6.27
- */
-
-/*
- * ap_ecvt converts to decimal
- * the number of digits is specified by ndigit
- * decpt is set to the position of the decimal point
- * sign is set to 0 for positive, 1 for negative
- */
-
-#define NDIG 80
-
-static char *
- ap_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag)
-{
- register int r2;
- double fi, fj;
- register char *p, *p1;
- static char buf[NDIG];
-
- if (ndigits >= NDIG - 1)
- ndigits = NDIG - 2;
- r2 = 0;
- *sign = 0;
- p = &buf[0];
- if (arg < 0) {
- *sign = 1;
- arg = -arg;
- }
- arg = modf(arg, &fi);
- p1 = &buf[NDIG];
- /*
- * Do integer part
- */
- if (fi != 0) {
- p1 = &buf[NDIG];
- while (fi != 0) {
- fj = modf(fi / 10, &fi);
- *--p1 = (int) ((fj + .03) * 10) + '0';
- r2++;
- }
- while (p1 < &buf[NDIG])
- *p++ = *p1++;
- } else if (arg > 0) {
- while ((fj = arg * 10) < 1) {
- arg = fj;
- r2--;
- }
- }
- p1 = &buf[ndigits];
- if (eflag == 0)
- p1 += r2;
- *decpt = r2;
- if (p1 < &buf[0]) {
- buf[0] = '\0';
- return (buf);
- }
- while (p <= p1 && p < &buf[NDIG]) {
- arg *= 10;
- arg = modf(arg, &fj);
- *p++ = (int) fj + '0';
- }
- if (p1 >= &buf[NDIG]) {
- buf[NDIG - 1] = '\0';
- return (buf);
- }
- p = p1;
- *p1 += 5;
- while (*p1 > '9') {
- *p1 = '0';
- if (p1 > buf)
- ++ * --p1;
- else {
- *p1 = '1';
- (*decpt)++;
- if (eflag == 0) {
- if (p > buf)
- *p = '0';
- p++;
- }
- }
- }
- *p = '\0';
- return (buf);
-}
-
-static char *
- ap_ecvt(double arg, int ndigits, int *decpt, int *sign)
-{
- return (ap_cvt(arg, ndigits, decpt, sign, 1));
-}
-
-static char *
- ap_fcvt(double arg, int ndigits, int *decpt, int *sign)
-{
- return (ap_cvt(arg, ndigits, decpt, sign, 0));
-}
-
-/*
- * ap_gcvt - Floating output conversion to
- * minimal length string
- */
-
-static char *
- ap_gcvt(double number, int ndigit, char *buf)
-{
- int sign, decpt;
- register char *p1, *p2;
- register i;
-
- p1 = ap_ecvt(number, ndigit, &decpt, &sign);
- p2 = buf;
- if (sign)
- *p2++ = '-';
- for (i = ndigit - 1; i > 0 && p1[i] == '0'; i--)
- ndigit--;
- if ((decpt >= 0 && decpt - ndigit > 4)
- || (decpt < 0 && decpt < -3)) { /* use E-style */
- decpt--;
- *p2++ = *p1++;
- *p2++ = '.';
- for (i = 1; i < ndigit; i++)
- *p2++ = *p1++;
- *p2++ = 'e';
- if (decpt < 0) {
- decpt = -decpt;
- *p2++ = '-';
- } else
- *p2++ = '+';
- if (decpt / 100 > 0)
- *p2++ = decpt / 100 + '0';
- if (decpt / 10 > 0)
- *p2++ = (decpt % 100) / 10 + '0';
- *p2++ = decpt % 10 + '0';
- } else {
- if (decpt <= 0) {
- if (*p1 != '0')
- *p2++ = '.';
- while (decpt < 0) {
- decpt++;
- *p2++ = '0';
- }
- }
- for (i = 1; i <= ndigit; i++) {
- *p2++ = *p1++;
- if (i == decpt)
- *p2++ = '.';
- }
- if (ndigit < decpt) {
- while (ndigit++ < decpt)
- *p2++ = '0';
- *p2++ = '.';
- }
- }
- if (p2[-1] == '.')
- p2--;
- *p2 = '\0';
- return (buf);
-}
-
-#endif /* HAVE_CVT */
-
-typedef enum {
- NO = 0, YES = 1
-} boolean_e;
-
-#define FALSE 0
-#define TRUE 1
-#define NUL '\0'
-#define INT_NULL ((int *)0)
-#define WIDE_INT long
-
-typedef WIDE_INT wide_int;
-typedef unsigned WIDE_INT u_wide_int;
-typedef int bool_int;
-
-#define S_NULL "(null)"
-#define S_NULL_LEN 6
-
-#define FLOAT_DIGITS 6
-#define EXPONENT_LENGTH 10
-
-/*
- * NUM_BUF_SIZE is the size of the buffer used for arithmetic conversions
- *
- * XXX: this is a magic number; do not decrease it
- */
-#define NUM_BUF_SIZE 512
-
-
-/*
- * Descriptor for buffer area
- */
-struct buf_area {
- char *buf_end;
- char *nextb; /* pointer to next byte to read/write */
-};
-
-typedef struct buf_area buffy;
-
-/*
- * The INS_CHAR macro inserts a character in the buffer and writes
- * the buffer back to disk if necessary
- * It uses the char pointers sp and bep:
- * sp points to the next available character in the buffer
- * bep points to the end-of-buffer+1
- * While using this macro, note that the nextb pointer is NOT updated.
- *
- * NOTE: Evaluation of the c argument should not have any side-effects
- */
-#define INS_CHAR( c, sp, bep, cc ) \
- { \
- if ( sp < bep ) \
- { \
- *sp++ = c ; \
- cc++ ; \
- } \
- }
-
-#define NUM( c ) ( c - '0' )
-
-#define STR_TO_DEC( str, num ) \
- num = NUM( *str++ ) ; \
- while ( isdigit((int)*str ) ) \
- { \
- num *= 10 ; \
- num += NUM( *str++ ) ; \
- }
-
-/*
- * This macro does zero padding so that the precision
- * requirement is satisfied. The padding is done by
- * adding '0's to the left of the string that is going
- * to be printed.
- */
-#define FIX_PRECISION( adjust, precision, s, s_len ) \
- if ( adjust ) \
- while ( s_len < precision ) \
- { \
- *--s = '0' ; \
- s_len++ ; \
- }
-
-/*
- * Macro that does padding. The padding is done by printing
- * the character ch.
- */
-#define PAD( width, len, ch ) do \
- { \
- INS_CHAR( ch, sp, bep, cc ) ; \
- width-- ; \
- } \
- while ( width > len )
-
-/*
- * Prefix the character ch to the string str
- * Increase length
- * Set the has_prefix flag
- */
-#define PREFIX( str, length, ch ) *--str = ch ; length++ ; has_prefix = YES
-
-
-/*
- * Convert num to its decimal format.
- * Return value:
- * - a pointer to a string containing the number (no sign)
- * - len contains the length of the string
- * - is_negative is set to TRUE or FALSE depending on the sign
- * of the number (always set to FALSE if is_unsigned is TRUE)
- *
- * The caller provides a buffer for the string: that is the buf_end argument
- * which is a pointer to the END of the buffer + 1 (i.e. if the buffer
- * is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
- */
-static char *
- conv_10(register wide_int num, register bool_int is_unsigned,
- register bool_int * is_negative, char *buf_end, register int *len)
-{
- register char *p = buf_end;
- register u_wide_int magnitude;
-
- if (is_unsigned) {
- magnitude = (u_wide_int) num;
- *is_negative = FALSE;
- } else {
- *is_negative = (num < 0);
-
- /*
- * On a 2's complement machine, negating the most negative integer
- * results in a number that cannot be represented as a signed integer.
- * Here is what we do to obtain the number's magnitude:
- * a. add 1 to the number
- * b. negate it (becomes positive)
- * c. convert it to unsigned
- * d. add 1
- */
- if (*is_negative) {
- wide_int t = num + 1;
-
- magnitude = ((u_wide_int) - t) + 1;
- } else
- magnitude = (u_wide_int) num;
- }
-
- /*
- * We use a do-while loop so that we write at least 1 digit
- */
- do {
- register u_wide_int new_magnitude = magnitude / 10;
-
- *--p = magnitude - new_magnitude * 10 + '0';
- magnitude = new_magnitude;
- }
- while (magnitude);
-
- *len = buf_end - p;
- return (p);
-}
-
-
-
-/*
- * Convert a floating point number to a string formats 'f', 'e' or 'E'.
- * The result is placed in buf, and len denotes the length of the string
- * The sign is returned in the is_negative argument (and is not placed
- * in buf).
- */
-static char *
- conv_fp(register char format, register double num,
- boolean_e add_dp, int precision, bool_int * is_negative, char *buf, int *len)
-{
- register char *s = buf;
- register char *p;
- int decimal_point;
-
- if (format == 'f')
- p = ap_fcvt(num, precision, &decimal_point, is_negative);
- else /* either e or E format */
- p = ap_ecvt(num, precision + 1, &decimal_point, is_negative);
-
- /*
- * Check for Infinity and NaN
- */
- if (isalpha((int)*p)) {
- *len = strlen(strcpy(buf, p));
- *is_negative = FALSE;
- return (buf);
- }
- if (format == 'f') {
- if (decimal_point <= 0) {
- *s++ = '0';
- if (precision > 0) {
- *s++ = '.';
- while (decimal_point++ < 0)
- *s++ = '0';
- } else if (add_dp) {
- *s++ = '.';
- }
- } else {
- while (decimal_point-- > 0) {
- *s++ = *p++;
- }
- if (precision > 0 || add_dp) {
- *s++ = '.';
- }
- }
- } else {
- *s++ = *p++;
- if (precision > 0 || add_dp)
- *s++ = '.';
- }
-
- /*
- * copy the rest of p, the NUL is NOT copied
- */
- while (*p)
- *s++ = *p++;
-
- if (format != 'f') {
- char temp[EXPONENT_LENGTH]; /* for exponent conversion */
- int t_len;
- bool_int exponent_is_negative;
-
- *s++ = format; /* either e or E */
- decimal_point--;
- if (decimal_point != 0) {
- p = conv_10((wide_int) decimal_point, FALSE, &exponent_is_negative,
- &temp[EXPONENT_LENGTH], &t_len);
- *s++ = exponent_is_negative ? '-' : '+';
-
- /*
- * Make sure the exponent has at least 2 digits
- */
- if (t_len == 1)
- *s++ = '0';
- while (t_len--)
- *s++ = *p++;
- } else {
- *s++ = '+';
- *s++ = '0';
- *s++ = '0';
- }
- }
- *len = s - buf;
- return (buf);
-}
-
-
-/*
- * Convert num to a base X number where X is a power of 2. nbits determines X.
- * For example, if nbits is 3, we do base 8 conversion
- * Return value:
- * a pointer to a string containing the number
- *
- * The caller provides a buffer for the string: that is the buf_end argument
- * which is a pointer to the END of the buffer + 1 (i.e. if the buffer
- * is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
- */
-static char *
- conv_p2(register u_wide_int num, register int nbits,
- char format, char *buf_end, register int *len)
-{
- register int mask = (1 << nbits) - 1;
- register char *p = buf_end;
- static char low_digits[] = "0123456789abcdef";
- static char upper_digits[] = "0123456789ABCDEF";
- register char *digits = (format == 'X') ? upper_digits : low_digits;
-
- do {
- *--p = digits[num & mask];
- num >>= nbits;
- }
- while (num);
-
- *len = buf_end - p;
- return (p);
-}
-
-
-/*
- * Do format conversion placing the output in buffer
- */
-static int format_converter(register buffy * odp, const char *fmt,
- va_list ap)
-{
- register char *sp;
- register char *bep;
- register int cc = 0;
- register int i;
-
- register char *s = NULL;
- char *q;
- int s_len;
-
- register int min_width = 0;
- int precision = 0;
- enum {
- LEFT, RIGHT
- } adjust;
- char pad_char;
- char prefix_char;
-
- double fp_num;
- wide_int i_num = (wide_int) 0;
- u_wide_int ui_num;
-
- char num_buf[NUM_BUF_SIZE];
- char char_buf[2]; /* for printing %% and %<unknown> */
-
- /*
- * Flag variables
- */
- boolean_e is_long;
- boolean_e alternate_form;
- boolean_e print_sign;
- boolean_e print_blank;
- boolean_e adjust_precision;
- boolean_e adjust_width;
- bool_int is_negative;
-
- sp = odp->nextb;
- bep = odp->buf_end;
-
- while (*fmt) {
- if (*fmt != '%') {
- INS_CHAR(*fmt, sp, bep, cc);
- } else {
- /*
- * Default variable settings
- */
- adjust = RIGHT;
- alternate_form = print_sign = print_blank = NO;
- pad_char = ' ';
- prefix_char = NUL;
-
- fmt++;
-
- /*
- * Try to avoid checking for flags, width or precision
- */
- if (isascii((int)*fmt) && !islower((int)*fmt)) {
- /*
- * Recognize flags: -, #, BLANK, +
- */
- for (;; fmt++) {
- if (*fmt == '-')
- adjust = LEFT;
- else if (*fmt == '+')
- print_sign = YES;
- else if (*fmt == '#')
- alternate_form = YES;
- else if (*fmt == ' ')
- print_blank = YES;
- else if (*fmt == '0')
- pad_char = '0';
- else
- break;
- }
-
- /*
- * Check if a width was specified
- */
- if (isdigit((int)*fmt)) {
- STR_TO_DEC(fmt, min_width);
- adjust_width = YES;
- } else if (*fmt == '*') {
- min_width = va_arg(ap, int);
- fmt++;
- adjust_width = YES;
- if (min_width < 0) {
- adjust = LEFT;
- min_width = -min_width;
- }
- } else
- adjust_width = NO;
-
- /*
- * Check if a precision was specified
- *
- * XXX: an unreasonable amount of precision may be specified
- * resulting in overflow of num_buf. Currently we
- * ignore this possibility.
- */
- if (*fmt == '.') {
- adjust_precision = YES;
- fmt++;
- if (isdigit((int)*fmt)) {
- STR_TO_DEC(fmt, precision);
- } else if (*fmt == '*') {
- precision = va_arg(ap, int);
- fmt++;
- if (precision < 0)
- precision = 0;
- } else
- precision = 0;
- } else
- adjust_precision = NO;
- } else
- adjust_precision = adjust_width = NO;
-
- /*
- * Modifier check
- */
- if (*fmt == 'l') {
- is_long = YES;
- fmt++;
- } else
- is_long = NO;
-
- /*
- * Argument extraction and printing.
- * First we determine the argument type.
- * Then, we convert the argument to a string.
- * On exit from the switch, s points to the string that
- * must be printed, s_len has the length of the string
- * The precision requirements, if any, are reflected in s_len.
- *
- * NOTE: pad_char may be set to '0' because of the 0 flag.
- * It is reset to ' ' by non-numeric formats
- */
- switch (*fmt) {
- case 'u':
- if (is_long)
- i_num = va_arg(ap, u_wide_int);
- else
- i_num = (wide_int) va_arg(ap, unsigned int);
- /*
- * The rest also applies to other integer formats, so fall
- * into that case.
- */
- case 'd':
- case 'i':
- /*
- * Get the arg if we haven't already.
- */
- if ((*fmt) != 'u') {
- if (is_long)
- i_num = va_arg(ap, wide_int);
- else
- i_num = (wide_int) va_arg(ap, int);
- };
- s = conv_10(i_num, (*fmt) == 'u', &is_negative,
- &num_buf[NUM_BUF_SIZE], &s_len);
- FIX_PRECISION(adjust_precision, precision, s, s_len);
-
- if (*fmt != 'u') {
- if (is_negative)
- prefix_char = '-';
- else if (print_sign)
- prefix_char = '+';
- else if (print_blank)
- prefix_char = ' ';
- }
- break;
-
-
- case 'o':
- if (is_long)
- ui_num = va_arg(ap, u_wide_int);
- else
- ui_num = (u_wide_int) va_arg(ap, unsigned int);
- s = conv_p2(ui_num, 3, *fmt,
- &num_buf[NUM_BUF_SIZE], &s_len);
- FIX_PRECISION(adjust_precision, precision, s, s_len);
- if (alternate_form && *s != '0') {
- *--s = '0';
- s_len++;
- }
- break;
-
-
- case 'x':
- case 'X':
- if (is_long)
- ui_num = (u_wide_int) va_arg(ap, u_wide_int);
- else
- ui_num = (u_wide_int) va_arg(ap, unsigned int);
- s = conv_p2(ui_num, 4, *fmt,
- &num_buf[NUM_BUF_SIZE], &s_len);
- FIX_PRECISION(adjust_precision, precision, s, s_len);
- if (alternate_form && i_num != 0) {
- *--s = *fmt; /* 'x' or 'X' */
- *--s = '0';
- s_len += 2;
- }
- break;
-
-
- case 's':
- s = va_arg(ap, char *);
- if (s != NULL) {
- s_len = strlen(s);
- if (adjust_precision && precision < s_len)
- s_len = precision;
- } else {
- s = S_NULL;
- s_len = S_NULL_LEN;
- }
- pad_char = ' ';
- break;
-
-
- case 'f':
- case 'e':
- case 'E':
- fp_num = va_arg(ap, double);
-
- s = conv_fp(*fmt, fp_num, alternate_form,
- (adjust_precision == NO) ? FLOAT_DIGITS : precision,
- &is_negative, &num_buf[1], &s_len);
- if (is_negative)
- prefix_char = '-';
- else if (print_sign)
- prefix_char = '+';
- else if (print_blank)
- prefix_char = ' ';
- break;
-
-
- case 'g':
- case 'G':
- if (adjust_precision == NO)
- precision = FLOAT_DIGITS;
- else if (precision == 0)
- precision = 1;
- /*
- * * We use &num_buf[ 1 ], so that we have room for the sign
- */
- s = ap_gcvt(va_arg(ap, double), precision, &num_buf[1]);
- if (*s == '-')
- prefix_char = *s++;
- else if (print_sign)
- prefix_char = '+';
- else if (print_blank)
- prefix_char = ' ';
-
- s_len = strlen(s);
-
- if (alternate_form && (q = strchr(s, '.')) == NULL)
- s[s_len++] = '.';
- if (*fmt == 'G' && (q = strchr(s, 'e')) != NULL)
- *q = 'E';
- break;
-
-
- case 'c':
- char_buf[0] = (char) (va_arg(ap, int));
- s = &char_buf[0];
- s_len = 1;
- pad_char = ' ';
- break;
-
-
- case '%':
- char_buf[0] = '%';
- s = &char_buf[0];
- s_len = 1;
- pad_char = ' ';
- break;
-
-
- case 'n':
- *(va_arg(ap, int *)) = cc;
- break;
-
- /*
- * Always extract the argument as a "char *" pointer. We
- * should be using "void *" but there are still machines
- * that don't understand it.
- * If the pointer size is equal to the size of an unsigned
- * integer we convert the pointer to a hex number, otherwise
- * we print "%p" to indicate that we don't handle "%p".
- */
- case 'p':
- ui_num = (u_wide_int) va_arg(ap, char *);
-
- if (sizeof(char *) <= sizeof(u_wide_int))
- s = conv_p2(ui_num, 4, 'x',
- &num_buf[NUM_BUF_SIZE], &s_len);
- else {
- s = "%p";
- s_len = 2;
- }
- pad_char = ' ';
- break;
-
-
- case NUL:
- /*
- * The last character of the format string was %.
- * We ignore it.
- */
- continue;
-
-
- /*
- * The default case is for unrecognized %'s.
- * We print %<char> to help the user identify what
- * option is not understood.
- * This is also useful in case the user wants to pass
- * the output of format_converter to another function
- * that understands some other %<char> (like syslog).
- * Note that we can't point s inside fmt because the
- * unknown <char> could be preceded by width etc.
- */
- default:
- char_buf[0] = '%';
- char_buf[1] = *fmt;
- s = char_buf;
- s_len = 2;
- pad_char = ' ';
- break;
- }
-
- if (prefix_char != NUL) {
- *--s = prefix_char;
- s_len++;
- }
- if (adjust_width && adjust == RIGHT && min_width > s_len) {
- if (pad_char == '0' && prefix_char != NUL) {
- INS_CHAR(*s, sp, bep, cc)
- s++;
- s_len--;
- min_width--;
- }
- PAD(min_width, s_len, pad_char);
- }
- /*
- * Print the string s.
- */
- for (i = s_len; i != 0; i--) {
- INS_CHAR(*s, sp, bep, cc);
- s++;
- }
-
- if (adjust_width && adjust == LEFT && min_width > s_len)
- PAD(min_width, s_len, pad_char);
- }
- fmt++;
- }
- odp->nextb = sp;
- return (cc);
-}
-
-
-/*
- * This is the general purpose conversion function.
- */
-static void strx_printv(int *ccp, char *buf, size_t len, const char *format,
- va_list ap)
-{
- buffy od;
- int cc;
-
- /*
- * First initialize the descriptor
- * Notice that if no length is given, we initialize buf_end to the
- * highest possible address.
- */
- od.buf_end = len ? &buf[len] : (char *) ~0;
- od.nextb = buf;
-
- /*
- * Do the conversion
- */
- cc = format_converter(&od, format, ap);
- if (len == 0 || od.nextb <= od.buf_end)
- *(od.nextb) = '\0';
- if (ccp)
- *ccp = cc;
-}
-
-
-int ap_snprintf(char *buf, size_t len, const char *format,...)
-{
- int cc;
- va_list ap;
-
- va_start(ap, format);
- strx_printv(&cc, buf, (len - 1), format, ap);
- va_end(ap);
- return (cc);
-}
-
-
-int ap_vsnprintf(char *buf, size_t len, const char *format, va_list ap)
-{
- int cc;
-
- strx_printv(&cc, buf, (len - 1), format, ap);
- return (cc);
-}
-
-#endif /* HAVE_SNPRINTF */
-#endif /* APACHE */
diff --git a/main/snprintf.h b/main/snprintf.h
deleted file mode 100644
index 4a453b2693..0000000000
--- a/main/snprintf.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Stig Sæther Bakken <ssb@guardian.no> |
- +----------------------------------------------------------------------+
- */
-
-#ifndef _PHP3_SNPRINTF_H
-#define _PHP3_SNPRINTF_H
-
-#ifndef HAVE_SNPRINTF
-extern int ap_snprintf(char *, size_t, const char *, ...);
-#define snprintf ap_snprintf
-#endif
-
-#ifndef HAVE_VSNPRINTF
-extern int ap_vsnprintf(char *, size_t, const char *, va_list ap);
-#define vsnprintf ap_vsnprintf
-#endif
-
-#if BROKEN_SPRINTF
-int php_sprintf (char* s, const char* format, ...);
-#else
-#define php_sprintf sprintf
-#endif
-
-#endif /* _PHP3_SNPRINTF_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/main/strlcat.c b/main/strlcat.c
deleted file mode 100644
index a6f1ffe274..0000000000
--- a/main/strlcat.c
+++ /dev/null
@@ -1,75 +0,0 @@
-#if !HAVE_STRLCAT
-
-/* $OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $ */
-
-/*
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE AUTHOR 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <string.h>
-
-/*
- * Appends src to string dst of size siz (unlike strncat, siz is the
- * full size of dst, not space left). At most siz-1 characters
- * will be copied. Always NUL terminates (unless siz == 0).
- * Returns strlen(src); if retval >= siz, truncation occurred.
- */
-size_t strlcat(dst, src, siz)
- char *dst;
- const char *src;
- size_t siz;
-{
- register char *d = dst;
- register const char *s = src;
- register size_t n = siz;
- size_t dlen;
-
- /* Find the end of dst and adjust bytes left but don't go past end */
- while (*d != '\0' && n-- != 0)
- d++;
- dlen = d - dst;
- n = siz - dlen;
-
- if (n == 0)
- return(dlen + strlen(s));
- while (*s != '\0') {
- if (n != 1) {
- *d++ = *s;
- n--;
- }
- s++;
- }
- *d = '\0';
-
- return(dlen + (s - src)); /* count does not include NUL */
-}
-
-#endif /* !HAVE_STRLCAT */
diff --git a/main/strlcpy.c b/main/strlcpy.c
deleted file mode 100644
index 5989e641d6..0000000000
--- a/main/strlcpy.c
+++ /dev/null
@@ -1,72 +0,0 @@
-#if !HAVE_STRLCPY
-
-/* $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $ */
-
-/*
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE AUTHOR 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <string.h>
-
-/*
- * Copy src to string dst of size siz. At most siz-1 characters
- * will be copied. Always NUL terminates (unless siz == 0).
- * Returns strlen(src); if retval >= siz, truncation occurred.
- */
-size_t strlcpy(dst, src, siz)
- char *dst;
- const char *src;
- size_t siz;
-{
- register char *d = dst;
- register const char *s = src;
- register size_t n = siz;
-
- /* Copy as many bytes as will fit */
- if (n != 0 && --n != 0) {
- do {
- if ((*d++ = *s++) == 0)
- break;
- } while (--n != 0);
- }
-
- /* Not enough room in dst, add NUL and traverse rest of src */
- if (n == 0) {
- if (siz != 0)
- *d = '\0'; /* NUL-terminate dst */
- while (*s++)
- ;
- }
-
- return(s - src - 1); /* count does not include NUL */
-}
-
-#endif /* !HAVE_STRLCPY */
diff --git a/main/win95nt.h b/main/win95nt.h
deleted file mode 100644
index 0808a84638..0000000000
--- a/main/win95nt.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Defines and types for Windows 95/NT */
-#define WIN32_LEAN_AND_MEAN
-#include <io.h>
-#include <malloc.h>
-#include <direct.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <sys/types.h>
-typedef int uid_t;
-typedef int gid_t;
-typedef int mode_t;
-typedef char * caddr_t;
-#define lstat(x, y) stat(x, y)
-#define _IFIFO 0010000 /* fifo */
-#define _IFBLK 0060000 /* block special */
-#define _IFLNK 0120000 /* symbolic link */
-#define S_IFIFO _IFIFO
-#define S_IFBLK _IFBLK
-#define S_IFLNK _IFLNK
-#define pclose _pclose
-#define popen _popen
-#define chdir(path) SetCurrentDirectory(path)
-#define mkdir(a,b) _mkdir(a)
-#define rmdir _rmdir
-#define getpid _getpid
-#if !(APACHE)
-#define sleep(t) Sleep(t*1000)
-#endif
-#define getcwd _getcwd
-#define snprintf _snprintf
-#define off_t _off_t
-#define vsnprintf _vsnprintf
-typedef unsigned int uint;
-typedef unsigned long ulong;
-#if !NSAPI
-#define strcasecmp(s1, s2) stricmp(s1, s2)
-#define strncasecmp(s1, s2, n) strnicmp(s1, s2, n)
-typedef long pid_t;
-#endif
-
-/* missing in vc5 math.h */
-#define M_PI 3.14159265358979323846
-#define M_TWOPI (M_PI * 2.0)
-#define M_PI_2 1.57079632679489661923
-#define M_PI_4 0.78539816339744830962
-
-#if !DEBUG
-#ifdef inline
-#undef inline
-#endif
-#define inline __inline
-#endif
-
-/* General Windows stuff */
-#define WINDOWS 1
-
-/* Prevent use of VC5 OpenFile function */
-#define NOOPENFILE
-
-/* sendmail is built-in */
-#ifdef PHP_PROG_SENDMAIL
-#undef PHP_PROG_SENDMAIL
-#define PHP_PROG_SENDMAIL "Built in mailer"
-#endif
-
-#define CONVERT_TO_WIN_FS(Filename) \
-{ \
- char *stemp; \
- if (Filename) \
- for (stemp = Filename; *stemp; stemp++) \
- if ( *stemp == '/') \
- *stemp = '\\'; \
-}
diff --git a/makeall.bat b/makeall.bat
deleted file mode 100755
index 5f9b61d238..0000000000
--- a/makeall.bat
+++ /dev/null
@@ -1,13 +0,0 @@
-NMAKE /f "php3.mak" CFG="php3 - Win32 %1"
-NMAKE /f "calendar.mak" CFG="calendar - Win32 %1"
-NMAKE /f "dbase.mak" CFG="dbase - Win32 %1"
-NMAKE /f "dbm.mak" CFG="dbm - Win32 %1"
-NMAKE /f "filepro.mak" CFG="filepro - Win32 %1"
-NMAKE /f "gd.mak" CFG="gd - Win32 %1"
-NMAKE /f "imap4.mak" CFG="imap4 - Win32 %1"
-NMAKE /f "hyperwave.mak" CFG="hyperwave - Win32 %1"
-NMAKE /f "ldap.mak" CFG="ldap - Win32 %1"
-NMAKE /f "msql.mak" CFG="msql - Win32 %1"
-NMAKE /f "mysql.mak" CFG="mysql - Win32 %1"
-NMAKE /f "zlib.mak" CFG="zlib - Win32 %1"
-NMAKE /f "snmp.mak" CFG="snmp - Win32 %1"
diff --git a/makedist b/makedist
deleted file mode 100755
index 181b44d207..0000000000
--- a/makedist
+++ /dev/null
@@ -1,143 +0,0 @@
-#!/bin/sh
-#
-# Distribution generator for CVS based packages.
-# To work, this script needs a consistent tagging of all releases.
-# Each release of a package should have a tag of the form
-#
-# <package>_<version>
-#
-# where <package> is the package name and the CVS module
-# and <version> s the version number with underscores instead of dots.
-#
-# For example: cvs tag php_3_0a1
-#
-# The distribution ends up in a .tar.gz file that contains the distribution
-# in a directory called <package>-<version>. The distribution contains all
-# directories from the CVS module except the one called "nodist", but only
-# the files INSTALL, README and config* are included.
-#
-# Since you can no longer set the CVS password via an env variable, you
-# need to have previously done a cvs login for the server and user id
-# this script uses so it will have an entry in your ~/.cvspasswd file.
-#
-# Usage: makedist <package> <version>
-#
-# Written by Stig Bakken <ssb@guardian.no> 1997-05-28.
-#
-# $Id$
-#
-
-CVSROOT=:pserver:cvsread@cvs.php.net:/repository
-export CVSROOT
-ZENDROOT=:pserver:cvsread@cvs.zend.com:/repository
-export ZENDROOT
-
-if echo '\c' | grep -s c >/dev/null 2>&1
-then
- ECHO_N="echo -n"
- ECHO_C=""
-else
- ECHO_N="echo"
- ECHO_C='\c'
-fi
-
-if test "$#" != "2"; then
- echo "Usage: makedist <package> <version>" >&2
- exit 1
-fi
-
-PKG=$1 ; shift
-VER=$1 ; shift
-
-MY_OLDPWD=`pwd`
-
-# the destination .tar.gz file
-ARCHIVE=$MY_OLDPWD/$PKG-$VER.tar.gz
-
-# temporary directory used to check out files from CVS
-TMPDIR=$MY_OLDPWD/cvstmp-$PKG-$VER
-
-# version part of the CVS release tag
-CVSVER=`echo $VER | sed -e 's/\./_/g'`
-
-# CVS release tag
-CVSTAG=${PKG}_$CVSVER
-
-# should become "php4"
-CVSMOD=`cat CVS/Repository | sed -e 's!^/[^/]*/!!'`
-# should become "libzend"
-ZENDMOD=`cat libzend/CVS/Repository | sed -e 's!^/[^/]*/!!'`
-# should become "TSRM"
-TSRMMOD=`cat TSRM/CVS/Repository | sed -e 's!^/[^/]*/!!'`
-
-if test ! -d $TMPDIR; then
- mkdir -p $TMPDIR || exit 2
-fi
-
-cd $TMPDIR || exit 3
-
-$ECHO_N "makedist: exporting tag '$CVSTAG' from '$CVSMOD'...$ECHO_C"
-cvs -Q export -r $CVSTAG $CVSMOD || exit 4
-echo ""
-
-cd $CVSMOD || exit 5
-
-# Check out Zend
-$ECHO_N "makedist: exporting tag '$CVSTAG' from '$ZENDMOD'...$ECHO_C"
-cvs -d $ZENDROOT -Q export -r $CVSTAG $ZENDMOD || exit 4
-echo ""
-
-# Check out TSRM
-$ECHO_N "makedist: exporting tag '$CVSTAG' from '$TSRMMOD'...$ECHO_C"
-cvs -d $ZENDROOT -Q export -r $CVSTAG $TSRMMOD || exit 4
-echo ""
-
-INC=""
-
-# remove CVS stuff...
-find . \( \( -name CVS -type d \) -o -name .cvsignore \) -exec rm -rf {} \;
-
-for file in *; do
- case $file in
- $PKG-$VER|web_update);; # ignore these
- *) INC="$INC $file";; # include the rest
- esac
-done
-
-# generate some files so people don't need bison, flex and autoconf
-# to install
-set -x
-./buildconf --copy
-cd libzend
-bison -p zend -d zend-parser.y -o zend-parser.c
-flex -Pzend -ozend-scanner.c -i zend-scanner.l
-cd ..
-bison -p cfg -d configuration-parser.y -o configuration-parser.c
-flex -Pcfg -oconfiguration-scanner.c -i configuration-scanner.l
-echo "/* Dummy File */" > ext/bcmath/number.c
-echo "/* Dummy File */" > ext/bcmath/number.h
-
-#perl -i -p -e 's/\r\n/\n/' *.dsw *.dsp
-set +x
-
-INC="$INC \
-configuration-scanner.c \
-configuration-parser.c configuration-parser.h \
-acconfig.h aclocal.m4 configure.in missing mkinstalldirs \
-ltconfig ltmain.sh config.sub config.guess php_config.h.in \
-configure"
-
-
-mkdir $PKG-$VER || exit 6
-mv $INC $PKG-$VER || exit 7
-
-$ECHO_N "makedist: making gzipped tar archive...$ECHO_C"
-tar czf $ARCHIVE $PKG-$VER || exit 8
-echo ""
-
-$ECHO_N "makedist: cleaning up...$ECHO_C"
-cd $MY_OLDPWD
-rm -rf $TMPDIR || exit 9
-echo ""
-
-exit 0
diff --git a/makeparser.bat b/makeparser.bat
deleted file mode 100755
index 8c36f958ab..0000000000
--- a/makeparser.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-d:\mingw32\bin\bison -p php -v -d language-parser.y
-flex -Pphp -olanguage-scanner.c -i language-scanner.lex
-d:\mingw32\bin\bison -p cfg -v -d configuration-parser.y
-flex -Pcfg -oconfiguration-scanner.c -i configuration-scanner.lex
diff --git a/mod_php4.c b/mod_php4.c
deleted file mode 100644
index 579287dbf3..0000000000
--- a/mod_php4.c
+++ /dev/null
@@ -1,603 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@php.net> |
- | (with helpful hints from Dean Gaudet <dgaudet@arctic.org> |
- | PHP 4.0 patches by Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#include "httpd.h"
-#include "http_config.h"
-#if MODULE_MAGIC_NUMBER > 19980712
-#include "ap_compat.h"
-#else
-#if MODULE_MAGIC_NUMBER > 19980324
-#include "compat.h"
-#endif
-#endif
-#include "http_core.h"
-#include "http_main.h"
-#include "http_protocol.h"
-#include "http_request.h"
-#include "http_log.h"
-
-#include "php.h"
-#include "php_ini.h"
-#include "php_globals.h"
-#include "SAPI.h"
-#include "main.h"
-
-#include "util_script.h"
-
-#include "php_version.h"
-#include "mod_php4.h"
-#if HAVE_MOD_DAV
-# include "mod_dav.h"
-#endif
-
-PHPAPI int apache_php_module_main(request_rec *r, int fd, int display_source_mode SLS_DC);
-
-/* ### these should be defined in mod_php4.h or somewhere else */
-#define USE_PATH 1
-#define IGNORE_URL 2
-
-module MODULE_VAR_EXPORT php4_module;
-
-int saved_umask;
-static unsigned char apache_php_initialized=0;
-
-typedef struct _php_per_dir_entry {
- char *key;
- char *value;
- uint key_length;
- uint value_length;
- int type;
-} php_per_dir_entry;
-
-#if WIN32|WINNT
-/* popenf isn't working on Windows, use open instead*/
-# ifdef popenf
-# undef popenf
-# endif
-# define popenf(p,n,f,m) open((n),(f),(m))
-# ifdef pclosef
-# undef pclosef
-# endif
-# define pclosef(p,f) close(f)
-#else
-# define php3i_popenf(p,n,f,m) popenf((p),(n),(f),(m))
-#endif
-
-php_apache_info_struct php_apache_info; /* active config */
-
-
-
-void php_save_umask()
-{
- saved_umask = umask(077);
- umask(saved_umask);
-}
-
-
-static int zend_apache_ub_write(const char *str, uint str_length)
-{
- int ret;
- SLS_FETCH();
-
- if (SG(server_context)) {
- ret = rwrite(str, str_length, (request_rec *) SG(server_context));
- } else {
- ret = fwrite(str, 1, str_length, stdout);
- }
- if(ret != str_length) {
- PG(connection_status) = PHP_CONNECTION_ABORTED;
- if(!PG(ignore_user_abort)) zend_bailout();
- }
- return ret;
-}
-
-
-int sapi_apache_read_post(char *buffer, uint count_bytes SLS_DC)
-{
- uint total_read_bytes=0, read_bytes;
- request_rec *r = (request_rec *) SG(server_context);
- void (*handler)(int);
-
- handler = signal(SIGPIPE, SIG_IGN);
- while (total_read_bytes<count_bytes) {
- hard_timeout("Read POST information", r); /* start timeout timer */
- read_bytes = get_client_block(r, buffer+total_read_bytes, count_bytes-total_read_bytes);
- reset_timeout(r);
- if (read_bytes<=0) {
- break;
- }
- total_read_bytes += read_bytes;
- }
- signal(SIGPIPE, handler);
- return total_read_bytes;
-}
-
-
-char *sapi_apache_read_cookies(SLS_D)
-{
- return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, "HTTP_COOKIE");
-}
-
-
-int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC)
-{
- char *header_name, *header_content, *p;
- request_rec *r = (request_rec *) SG(server_context);
-
- header_name = sapi_header->header;
-
- header_content = p = strchr(header_name, ':');
- if (!p) {
- return 0;
- }
-
- *p = 0;
- do {
- header_content++;
- } while (*header_content==' ');
-
- if (!strcasecmp(header_name, "Content-Type")) {
- r->content_type = pstrdup(r->pool, header_content);
- } else if (!strcasecmp(header_name, "Set-Cookie")) {
- table_add(r->headers_out, header_name, header_content);
- } else {
- table_set(r->headers_out, header_name, header_content);
- }
-
- *p = ':'; /* a well behaved header handler shouldn't change its original arguments */
-
- efree(sapi_header->header);
-
- return 0; /* don't use the default SAPI mechanism, Apache duplicates this functionality */
-}
-
-
-int sapi_apache_send_headers(sapi_headers_struct *sapi_headers SLS_DC)
-{
- ((request_rec *) SG(server_context))->status = SG(sapi_headers).http_response_code;
- send_http_header((request_rec *) SG(server_context));
- return SAPI_HEADER_SENT_SUCCESSFULLY;
-}
-
-
-sapi_module_struct sapi_module = {
- "PHP Language", /* name */
-
- php_module_startup, /* startup */
- php_module_shutdown_wrapper, /* shutdown */
-
- zend_apache_ub_write, /* unbuffered write */
-
- php_error, /* error handler */
-
- sapi_apache_header_handler, /* header handler */
- sapi_apache_send_headers, /* send headers handler */
- NULL, /* send header handler */
-
- sapi_apache_read_post, /* read POST data */
- sapi_apache_read_cookies, /* read Cookies */
-
- STANDARD_SAPI_MODULE_PROPERTIES
-};
-
-
-void php_restore_umask()
-{
- umask(saved_umask);
-}
-
-
-static void init_request_info(SLS_D)
-{
- request_rec *r = ((request_rec *) SG(server_context));
- char *content_length = (char *) table_get(r->subprocess_env, "CONTENT_LENGTH");
- const char *authorization=NULL;
- char *tmp;
-
- SG(request_info).query_string = r->args;
- SG(request_info).path_translated = r->filename;
- SG(request_info).request_uri = r->uri;
- SG(request_info).request_method = (char *)r->method;
- SG(request_info).content_type = (char *) table_get(r->subprocess_env, "CONTENT_TYPE");
- SG(request_info).content_length = (content_length ? atoi(content_length) : 0);
-
- if (r->headers_in) {
- authorization = table_get(r->headers_in, "Authorization");
- }
- if (authorization
-/* && !auth_type(r) */
- && !strcmp(getword(r->pool, &authorization, ' '), "Basic")) {
- tmp = uudecode(r->pool, authorization);
- SG(request_info).auth_user = getword_nulls_nc(r->pool, &tmp, ':');
- if (SG(request_info).auth_user) {
- SG(request_info).auth_user = estrdup(SG(request_info).auth_user);
- }
- SG(request_info).auth_password = tmp;
- if (SG(request_info).auth_password) {
- SG(request_info).auth_password = estrdup(SG(request_info).auth_password);
- }
- } else {
- SG(request_info).auth_user = NULL;
- SG(request_info).auth_password = NULL;
- }
-}
-
-
-static int php_apache_alter_ini_entries(php_per_dir_entry *per_dir_entry)
-{
- php_alter_ini_entry(per_dir_entry->key, per_dir_entry->key_length+1, per_dir_entry->value, per_dir_entry->value_length+1, per_dir_entry->type);
- return 0;
-}
-
-
-int send_php(request_rec *r, int display_source_mode, char *filename)
-{
- int fd, retval;
- HashTable *per_dir_conf;
- SLS_FETCH();
-
- if (setjmp(EG(bailout))!=0) {
- return OK;
- }
- per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php4_module);
- zend_hash_apply((HashTable *) per_dir_conf, (int (*)(void *)) php_apache_alter_ini_entries);
-
- /* We don't accept OPTIONS requests, but take everything else */
- if (r->method_number == M_OPTIONS) {
- r->allowed |= (1 << METHODS) - 1;
- return DECLINED;
- }
-
- /* Make sure file exists */
- if (filename == NULL && r->finfo.st_mode == 0) {
- return NOT_FOUND;
- }
-
- /* If PHP parser engine has been turned off with an "engine off"
- * directive, then decline to handle this request
- */
- if (!php_apache_info.engine) {
- r->content_type = "text/html";
- r->allowed |= (1 << METHODS) - 1;
- return DECLINED;
- }
- if (filename == NULL) {
- filename = r->filename;
- }
- /* Open the file */
- if ((fd = popenf(r->pool, filename, O_RDONLY, 0)) == -1) {
- log_reason("file permissions deny server access", filename, r);
- return FORBIDDEN;
- }
-
- /* Apache 1.2 has a more complex mechanism for reading POST data */
-#if MODULE_MAGIC_NUMBER > 19961007
- if ((retval = setup_client_block(r, REQUEST_CHUNKED_ERROR)))
- return retval;
-#endif
-
- if (php_apache_info.last_modified) {
-#if MODULE_MAGIC_NUMBER < 19970912
- if ((retval = set_last_modified(r, r->finfo.st_mtime))) {
- return retval;
- }
-#else
- update_mtime (r, r->finfo.st_mtime);
- set_last_modified(r);
- set_etag(r);
-#endif
- }
- /* Assume output will be HTML. Individual scripts may change this
- further down the line */
- r->content_type = "text/html";
-
- /* Init timeout */
- hard_timeout("send", r);
-
- SG(server_context) = r;
-
- php_save_umask();
- chdir_file(filename);
- add_common_vars(r);
- add_cgi_vars(r);
-
- init_request_info(SLS_C);
- apache_php_module_main(r, fd, display_source_mode SLS_CC);
-
- /* Done, restore umask, turn off timeout, close file and return */
- php_restore_umask();
- kill_timeout(r);
- pclosef(r->pool, fd);
- return OK;
-}
-
-
-int send_parsed_php(request_rec * r)
-{
- return send_php(r, 0, NULL);
-}
-
-
-int send_parsed_php_source(request_rec * r)
-{
- return send_php(r, 1, NULL);
-}
-
-
-static int destroy_per_dir_entry(php_per_dir_entry *per_dir_entry)
-{
- free(per_dir_entry->key);
- free(per_dir_entry->value);
- return 1;
-}
-
-static void copy_per_dir_entry(php_per_dir_entry *per_dir_entry)
-{
- php_per_dir_entry tmp = *per_dir_entry;
-
- per_dir_entry->key = (char *) malloc(tmp.key_length+1);
- memcpy(per_dir_entry->key, tmp.key, tmp.key_length);
- per_dir_entry->key[per_dir_entry->key_length] = 0;
-
- per_dir_entry->value = (char *) malloc(tmp.value_length+1);
- memcpy(per_dir_entry->value, tmp.value, tmp.value_length);
- per_dir_entry->value[per_dir_entry->value_length] = 0;
-}
-
-
-static void php_destroy_per_dir_info(HashTable *per_dir_info)
-{
- zend_hash_destroy(per_dir_info);
- free(per_dir_info);
-}
-
-static void *php_create_dir(pool *p, char *dummy)
-{
- HashTable *per_dir_info;
-
- per_dir_info = (HashTable *) malloc(sizeof(HashTable));
- zend_hash_init(per_dir_info, 5, NULL, (int (*)(void *)) destroy_per_dir_entry, 1);
- register_cleanup(p, (void *) per_dir_info, (void (*)(void *)) php_destroy_per_dir_info, (void (*)(void *)) zend_hash_destroy);
-
- return per_dir_info;
-}
-
-
-static void *php_merge_dir(pool *p, void *basev, void *addv)
-{
- php_per_dir_entry tmp;
-
- zend_hash_merge((HashTable *) addv, (HashTable *) basev, (void (*)(void *)) copy_per_dir_entry, &tmp, sizeof(php_per_dir_entry), 0);
- return addv;
-}
-
-
-#if MODULE_MAGIC_NUMBER > 19961007
-#define CONST_PREFIX const
-#else
-#define CONST_PREFIX
-#endif
-
-CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode)
-{
- php_per_dir_entry per_dir_entry;
-
- if (!apache_php_initialized) {
- sapi_startup(&sapi_module);
- php_module_startup(&sapi_module);
- apache_php_initialized = 1;
- }
- per_dir_entry.type = mode;
-
- per_dir_entry.key_length = strlen(arg1);
- per_dir_entry.value_length = strlen(arg2);
-
- per_dir_entry.key = (char *) malloc(per_dir_entry.key_length+1);
- memcpy(per_dir_entry.key, arg1, per_dir_entry.key_length);
- per_dir_entry.key[per_dir_entry.key_length] = 0;
-
- per_dir_entry.value = (char *) malloc(per_dir_entry.value_length+1);
- memcpy(per_dir_entry.value, arg2, per_dir_entry.value_length);
- per_dir_entry.value[per_dir_entry.value_length] = 0;
-
- zend_hash_update((HashTable *) conf, per_dir_entry.key, per_dir_entry.key_length, &per_dir_entry, sizeof(php_per_dir_entry), NULL);
- return NULL;
-}
-
-
-CONST_PREFIX char *php_apache_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2)
-{
- return php_apache_value_handler_ex(cmd, conf, arg1, arg2, PHP_INI_PERDIR);
-}
-
-
-CONST_PREFIX char *php_apache_admin_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2)
-{
- return php_apache_value_handler_ex(cmd, conf, arg1, arg2, PHP_INI_SYSTEM);
-}
-
-
-CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode)
-{
- char bool_val[2];
-
- if (!strcasecmp(arg2, "On")) {
- bool_val[0] = '1';
- } else {
- bool_val[0] = '0';
- }
- bool_val[1] = 0;
-
- return php_apache_value_handler_ex(cmd, conf, arg1, bool_val, mode);
-}
-
-
-CONST_PREFIX char *php_apache_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2)
-{
- return php_apache_flag_handler_ex(cmd, conf, arg1, arg2, PHP_INI_PERDIR);
-}
-
-
-CONST_PREFIX char *php_apache_admin_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2)
-{
- return php_apache_flag_handler_ex(cmd, conf, arg1, arg2, PHP_INI_SYSTEM);
-}
-
-
-
-
-int php_xbithack_handler(request_rec * r)
-{
- php_apache_info_struct *conf;
-
- conf = (php_apache_info_struct *) get_module_config(r->per_dir_config, &php4_module);
- if (!(r->finfo.st_mode & S_IXUSR)) {
- r->allowed |= (1 << METHODS) - 1;
- return DECLINED;
- }
- if (conf->xbithack == 0) {
- r->allowed |= (1 << METHODS) - 1;
- return DECLINED;
- }
- return send_parsed_php(r);
-}
-
-static void apache_php_module_shutdown_wrapper(void)
-{
- apache_php_initialized = 0;
- sapi_module.shutdown(&sapi_module);
-}
-
-
-void php_init_handler(server_rec *s, pool *p)
-{
- register_cleanup(p, NULL, (void (*)(void *))apache_php_module_shutdown_wrapper, php_module_shutdown_for_exec);
- if (!apache_php_initialized) {
- sapi_startup(&sapi_module);
- php_module_startup(&sapi_module);
- apache_php_initialized = 1;
- }
-#if MODULE_MAGIC_NUMBER >= 19980527
- if (PG(expose_php)) {
- ap_add_version_component("PHP/" PHP_VERSION);
- }
-#endif
-}
-
-
-#if HAVE_MOD_DAV
-
-extern int phpdav_mkcol_test_handler(request_rec *r);
-extern int phpdav_mkcol_create_handler(request_rec *r);
-
-/* conf is being read twice (both here and in send_php()) */
-int send_parsed_php_dav_script(request_rec *r)
-{
- php_apache_info_struct *conf;
-
- conf = (php_apache_info_struct *) get_module_config(r->per_dir_config,
- &php4_module);
- return send_php(r, 0, 0, conf->dav_script);
-}
-
-static int php_type_checker(request_rec *r)
-{
- php_apache_info_struct *conf;
-
- conf = (php_apache_info_struct *)get_module_config(r->per_dir_config,
- &php4_module);
-
- /* If DAV support is enabled, use mod_dav's type checker. */
- if (conf->dav_script) {
- dav_api_set_request_handler(r, send_parsed_php_dav_script);
- dav_api_set_mkcol_handlers(r, phpdav_mkcol_test_handler,
- phpdav_mkcol_create_handler);
- /* leave the rest of the request to mod_dav */
- return dav_api_type_checker(r);
- }
-
- return DECLINED;
-}
-
-#else /* HAVE_MOD_DAV */
-
-# define php_type_checker NULL
-
-#endif /* HAVE_MOD_DAV */
-
-
-handler_rec php_handlers[] =
-{
- {"application/x-httpd-php", send_parsed_php},
- {"application/x-httpd-php-source", send_parsed_php_source},
- {"text/html", php_xbithack_handler},
- {NULL}
-};
-
-
-command_rec php_commands[] =
-{
- {"php_value", php_apache_value_handler, NULL, OR_OPTIONS, TAKE2, "PHP Value Modifier"},
- {"php_flag", php_apache_flag_handler, NULL, OR_OPTIONS, TAKE2, "PHP Flag Modifier"},
- {"php_admin_value", php_apache_admin_value_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Value Modifier (Admin)"},
- {"php_admin_flag", php_apache_admin_flag_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Flag Modifier (Admin)"},
- {NULL}
-};
-
-
-
-module MODULE_VAR_EXPORT php4_module =
-{
- STANDARD_MODULE_STUFF,
- php_init_handler, /* initializer */
- php_create_dir, /* per-directory config creator */
- php_merge_dir, /* dir merger */
- NULL, /* per-server config creator */
- NULL, /* merge server config */
- php_commands, /* command table */
- php_handlers, /* handlers */
- NULL, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- php_type_checker, /* type_checker */
- NULL, /* fixups */
- NULL /* logger */
-#if MODULE_MAGIC_NUMBER >= 19970103
- ,NULL /* header parser */
-#endif
-#if MODULE_MAGIC_NUMBER >= 19970719
- ,NULL /* child_init */
-#endif
-#if MODULE_MAGIC_NUMBER >= 19970728
- ,NULL /* child_exit */
-#endif
-#if MODULE_MAGIC_NUMBER >= 19970902
- ,NULL /* post read-request */
-#endif
-};
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/mod_php4.exp b/mod_php4.exp
deleted file mode 100644
index 2dca1256c2..0000000000
--- a/mod_php4.exp
+++ /dev/null
@@ -1 +0,0 @@
-php4_module
diff --git a/mod_php4.h b/mod_php4.h
deleted file mode 100644
index 4fe749d2d6..0000000000
--- a/mod_php4.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@php.net> |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#ifndef _MOD_PHP4_H
-#define _MOD_PHP4_H
-
-#if !defined(WIN32) && !defined(WINNT)
-#ifndef MODULE_VAR_EXPORT
-#define MODULE_VAR_EXPORT
-#endif
-#endif
-
-typedef struct {
- long engine;
- long last_modified;
- char *dav_script;
- long xbithack;
-} php_apache_info_struct;
-
-extern php_apache_info_struct php_apache_info;
-
-#if MSVC5
-#define S_IXUSR _S_IEXEC
-#endif
-
-#endif /* _MOD_PHP4_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/msql.mak b/msql.mak
deleted file mode 100644
index 6d07dd4c0d..0000000000
--- a/msql.mak
+++ /dev/null
@@ -1,194 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on msql.dsp
-!IF "$(CFG)" == ""
-CFG=msql - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to msql - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "msql - Win32 Release" && "$(CFG)" != "msql - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "msql.mak" CFG="msql - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "msql - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "msql - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-!IF "$(CFG)" == "msql - Win32 Release"
-
-OUTDIR=.\module_release
-INTDIR=.\module_release
-# Begin Custom Macros
-OutDir=.\module_release
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_msql2.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\msql.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(OUTDIR)\php3_msql2.dll"
- -@erase "$(OUTDIR)\php3_msql2.exp"
- -@erase "$(OUTDIR)\php3_msql2.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "./" /I "../" /I "../../include" /D HAVE_MSQL=1 /D "NDEBUG" /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\msql.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\msql.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib mSQL_dll.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:2.1 /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\php3_msql2.pdb" /machine:I386 /out:"$(OUTDIR)\php3_msql2.dll" /implib:"$(OUTDIR)\php3_msql2.lib" /libpath:"..\..\lib" /libpath:"cgi_release"
-LINK32_OBJS= \
- "$(INTDIR)\msql.obj"
-
-"$(OUTDIR)\php3_msql2.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "msql - Win32 Debug"
-
-OUTDIR=.\module_debug
-INTDIR=.\module_debug
-# Begin Custom Macros
-OutDir=.\module_debug
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_msql.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\msql.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(INTDIR)\vc60.pdb"
- -@erase "$(OUTDIR)\php3_msql.dll"
- -@erase "$(OUTDIR)\php3_msql.exp"
- -@erase "$(OUTDIR)\php3_msql.ilk"
- -@erase "$(OUTDIR)\php3_msql.lib"
- -@erase "$(OUTDIR)\php3_msql.pdb"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "./" /I "../" /I "../../include" /D HAVE_MSQL=1 /D "DEBUG" /D "_DEBUG" /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\msql.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\msql.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib mSQL_dll.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:2.1 /subsystem:windows /dll /incremental:yes /pdb:"$(OUTDIR)\php3_msql.pdb" /debug /machine:I386 /out:"$(OUTDIR)\php3_msql.dll" /implib:"$(OUTDIR)\php3_msql.lib" /pdbtype:sept /libpath:"..\..\lib" /libpath:"cgi_debug"
-LINK32_OBJS= \
- "$(INTDIR)\msql.obj"
-
-"$(OUTDIR)\php3_msql.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF
-
-
-!IF "$(NO_EXTERNAL_DEPS)" != "1"
-!IF EXISTS("msql.dep")
-!INCLUDE "msql.dep"
-!ELSE
-!MESSAGE Warning: cannot find "msql.dep"
-!ENDIF
-!ENDIF
-
-
-!IF "$(CFG)" == "msql - Win32 Release" || "$(CFG)" == "msql - Win32 Debug"
-SOURCE=.\functions\msql.c
-
-"$(INTDIR)\msql.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-
-!ENDIF
-
diff --git a/msql1.mak b/msql1.mak
deleted file mode 100644
index d1c5ad3915..0000000000
--- a/msql1.mak
+++ /dev/null
@@ -1,212 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on msql1.dsp
-!IF "$(CFG)" == ""
-CFG=msql1 - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to msql1 - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "msql1 - Win32 Release" && "$(CFG)" != "msql1 - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "msql1.mak" CFG="msql1 - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "msql1 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "msql1 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-!IF "$(CFG)" == "msql1 - Win32 Release"
-
-OUTDIR=.\module_release
-INTDIR=.\module_release
-# Begin Custom Macros
-OutDir=.\module_release
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_msql1.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\msql.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(OUTDIR)\php3_msql1.dll"
- -@erase "$(OUTDIR)\php3_msql1.exp"
- -@erase "$(OUTDIR)\php3_msql1.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "./" /I "../" /I "../../include" /D HAVE_MSQL=1 /D MSQL1=1 /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\msql1.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\msql1.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib libmsql1.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\php3_msql1.pdb" /machine:I386 /out:"$(OUTDIR)\php3_msql1.dll" /implib:"$(OUTDIR)\php3_msql1.lib" /libpath:"..\..\lib" /libpath:"cgi_release"
-LINK32_OBJS= \
- "$(INTDIR)\msql.obj"
-
-"$(OUTDIR)\php3_msql1.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "msql1 - Win32 Debug"
-
-OUTDIR=.\module_Debug
-INTDIR=.\module_Debug
-# Begin Custom Macros
-OutDir=.\module_Debug
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_msql1.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\msql.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(INTDIR)\vc60.pdb"
- -@erase "$(OUTDIR)\php3_msql1.dll"
- -@erase "$(OUTDIR)\php3_msql1.exp"
- -@erase "$(OUTDIR)\php3_msql1.ilk"
- -@erase "$(OUTDIR)\php3_msql1.lib"
- -@erase "$(OUTDIR)\php3_msql1.pdb"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "./" /I "../" /I "../../include" /D HAVE_MSQL=1 /D MSQL1=1 /D "COMPILE_DL" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "MSVC5" /Fp"$(INTDIR)\msql1.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\msql1.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib libmsql1.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:yes /pdb:"$(OUTDIR)\php3_msql1.pdb" /debug /machine:I386 /out:"$(OUTDIR)\php3_msql1.dll" /implib:"$(OUTDIR)\php3_msql1.lib" /pdbtype:sept /libpath:"..\..\lib" /libpath:"cgi_debug"
-LINK32_OBJS= \
- "$(INTDIR)\msql.obj"
-
-"$(OUTDIR)\php3_msql1.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF
-
-
-!IF "$(NO_EXTERNAL_DEPS)" != "1"
-!IF EXISTS("msql1.dep")
-!INCLUDE "msql1.dep"
-!ELSE
-!MESSAGE Warning: cannot find "msql1.dep"
-!ENDIF
-!ENDIF
-
-
-!IF "$(CFG)" == "msql1 - Win32 Release" || "$(CFG)" == "msql1 - Win32 Debug"
-SOURCE=.\functions\msql.c
-
-!IF "$(CFG)" == "msql1 - Win32 Release"
-
-CPP_SWITCHES=/nologo /MT /W3 /GX /O2 /I "./" /I "../" /I "../../include" /D HAVE_MSQL=1 /D MSQL1=1 /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\msql1.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-"$(INTDIR)\msql.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) @<<
- $(CPP_SWITCHES) $(SOURCE)
-<<
-
-
-!ELSEIF "$(CFG)" == "msql1 - Win32 Debug"
-
-CPP_SWITCHES=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "./" /I "../" /I "../../include" /D HAVE_MSQL=1 /D MSQL1=1 /D "COMPILE_DL" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "MSVC5" /Fp"$(INTDIR)\msql1.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-"$(INTDIR)\msql.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) @<<
- $(CPP_SWITCHES) $(SOURCE)
-<<
-
-
-!ENDIF
-
-
-!ENDIF
-
diff --git a/mtparser.bat b/mtparser.bat
deleted file mode 100755
index 715d3b5935..0000000000
--- a/mtparser.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-bison -p php -v -d language-parser.y
-plex -x -m %3 -Pphp -olanguage-scanner.c -i language-scanner.lex
-bison -p cfg -v -d configuration-parser.y
-flex -Pcfg -oconfiguration-scanner.c -i configuration-scanner.lex
diff --git a/mysql.mak b/mysql.mak
deleted file mode 100644
index edb178a90f..0000000000
--- a/mysql.mak
+++ /dev/null
@@ -1,197 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on mysql.dsp
-!IF "$(CFG)" == ""
-CFG=mysql - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to mysql - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "mysql - Win32 Release" && "$(CFG)" != "mysql - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "mysql.mak" CFG="mysql - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "mysql - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "mysql - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-!IF "$(CFG)" == "mysql - Win32 Release"
-
-OUTDIR=.\module_Release
-INTDIR=.\module_Release
-# Begin Custom Macros
-OutDir=.\module_Release
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_mysql.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\mysql.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(OUTDIR)\php3_mysql.dll"
- -@erase "$(OUTDIR)\php3_mysql.exp"
- -@erase "$(OUTDIR)\php3_mysql.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "./" /I "../" /I "../../include" /D HAVE_MYSQL=1 /D HAVE_ERRMSG_H=1 /D "MSVC5" /D "COMPILE_DL" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\mysql.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /I /usr/src/phpcvs/php3" /I /usr/src/mysql/include" " " /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\mysql.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib libmysql.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\php3_mysql.pdb" /machine:I386 /out:"$(OUTDIR)\php3_mysql.dll" /implib:"$(OUTDIR)\php3_mysql.lib" /libpath:"..\..\lib" /libpath:"cgi_release"
-LINK32_OBJS= \
- "$(INTDIR)\mysql.obj"
-
-"$(OUTDIR)\php3_mysql.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "mysql - Win32 Debug"
-
-OUTDIR=c:\php3
-INTDIR=.\module_debug
-# Begin Custom Macros
-OutDir=c:\php3
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_mysql.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\mysql.obj"
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(INTDIR)\vc60.pdb"
- -@erase "$(OUTDIR)\php3_mysql.dll"
- -@erase "$(OUTDIR)\php3_mysql.exp"
- -@erase "$(OUTDIR)\php3_mysql.ilk"
- -@erase "$(OUTDIR)\php3_mysql.lib"
- -@erase "$(OUTDIR)\php3_mysql.pdb"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-"$(INTDIR)" :
- if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "./" /I "../" /I "../../include" /D HAVE_MYSQL=1 /D HAVE_ERRMSG_H=1 /D "DEBUG" /D "MSVC5" /D "COMPILE_DL" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\mysql.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /I /usr/src/phpcvs/php3" /I /usr/src/mysql/include" " " /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\mysql.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib libmysql.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:yes /pdb:"$(OUTDIR)\php3_mysql.pdb" /debug /machine:I386 /out:"$(OUTDIR)\php3_mysql.dll" /implib:"$(OUTDIR)\php3_mysql.lib" /pdbtype:sept /libpath:"..\..\lib" /libpath:"cgi_debug"
-LINK32_OBJS= \
- "$(INTDIR)\mysql.obj"
-
-"$(OUTDIR)\php3_mysql.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF
-
-
-!IF "$(NO_EXTERNAL_DEPS)" != "1"
-!IF EXISTS("mysql.dep")
-!INCLUDE "mysql.dep"
-!ELSE
-!MESSAGE Warning: cannot find "mysql.dep"
-!ENDIF
-!ENDIF
-
-
-!IF "$(CFG)" == "mysql - Win32 Release" || "$(CFG)" == "mysql - Win32 Debug"
-SOURCE=.\functions\mysql.c
-
-"$(INTDIR)\mysql.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-
-!ENDIF
-
diff --git a/output.c b/output.c
deleted file mode 100644
index a748ed5cbb..0000000000
--- a/output.c
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Andi Gutmans <andi@zend.com> |
- | Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
-*/
-
-
-#include "php.h"
-#include "ext/standard/head.h"
-#include "ext/session/php_session.h"
-#include "SAPI.h"
-
-/* output functions */
-PHPAPI int (*php_body_write)(const char *str, uint str_length); /* string output */
-PHPAPI int (*php_header_write)(const char *str, uint str_length); /* unbuffer string output */
-static int php_ub_body_write(const char *str, uint str_length);
-static int php_ub_body_write_no_header(const char *str, uint str_length);
-static int php_b_body_write(const char *str, uint str_length);
-
-/* output buffering */
-static char *ob_buffer;
-static uint ob_buffer_size;
-static uint ob_block_size;
-static uint ob_text_length;
-static void php_ob_init(uint initial_size, uint block_size);
-static void php_ob_destroy();
-static void php_ob_append(const char *text, uint text_length);
-static void php_ob_prepend(const char *text, uint text_length);
-static inline void php_ob_send();
-
-
-/*
- * Main
- */
-
-/* Start output layer */
-PHPAPI void php_output_startup()
-{
- ob_buffer = NULL;
- php_body_write = php_ub_body_write;
- php_header_write = sapi_module.ub_write;
-}
-
-
-/* Start output buffering */
-void php_start_ob_buffering()
-{
- php_ob_init(4096, 1024);
- php_body_write = php_b_body_write;
-}
-
-
-/* End output buffering */
-void php_end_ob_buffering(int send_buffer)
-{
- SLS_FETCH();
-
- if (!ob_buffer) {
- return;
- }
- if (SG(headers_sent) && !SG(request_info).headers_only) {
- php_body_write = php_ub_body_write_no_header;
- } else {
- php_body_write = php_ub_body_write;
- }
- if (send_buffer) {
- php_ob_send();
- }
- php_ob_destroy();
-}
-
-
-/*
- * Output buffering - implementation
- */
-
-static inline void php_ob_allocate()
-{
- if (ob_buffer_size<ob_text_length) {
- while ((ob_buffer_size+=ob_block_size) < ob_text_length);
- ob_buffer = (char *) erealloc(ob_buffer, ob_buffer_size+1);
- }
-}
-
-
-static void php_ob_init(uint initial_size, uint block_size)
-{
- if (ob_buffer) {
- return;
- }
- ob_block_size = block_size;
- ob_buffer_size = initial_size;
- ob_buffer = (char *) emalloc(initial_size+1);
- ob_text_length = 0;
-}
-
-
-static void php_ob_destroy()
-{
- if (ob_buffer) {
- efree(ob_buffer);
- ob_buffer = NULL;
- }
-}
-
-
-static void php_ob_append(const char *text, uint text_length)
-{
- char *target;
- int original_ob_text_length=ob_text_length;
-
- ob_text_length += text_length;
- php_ob_allocate();
- target = ob_buffer+original_ob_text_length;
- memcpy(target, text, text_length);
- target[text_length]=0;
-}
-
-
-static void php_ob_prepend(const char *text, uint text_length)
-{
- char *p, *start;
-
- ob_text_length += text_length;
- php_ob_allocate();
-
- /* php_ob_allocate() may change ob_buffer, so we can't initialize p&start earlier */
- p = ob_buffer+ob_text_length;
- start = ob_buffer;
-
- while (--p>=start) {
- p[text_length] = *p;
- }
- memcpy(ob_buffer, text, text_length);
- ob_buffer[ob_text_length]=0;
-}
-
-
-static inline void php_ob_send()
-{
- /* header_write is a simple, unbuffered output function */
- php_body_write(ob_buffer, ob_text_length);
-}
-
-
-/* Return the current output buffer */
-int php_ob_get_buffer(pval *p)
-{
- if (!ob_buffer) {
- return FAILURE;
- }
- p->type = IS_STRING;
- p->value.str.val = estrndup(ob_buffer, ob_text_length);
- p->value.str.len = ob_text_length;
- return SUCCESS;
-}
-
-
-/*
- * Wrapper functions - implementation
- */
-
-
-/* buffered output function */
-static int php_b_body_write(const char *str, uint str_length)
-{
- php_ob_append(str, str_length);
- return str_length;
-}
-
-
-static int php_ub_body_write_no_header(const char *str, uint str_length)
-{
- char *newstr = NULL;
- uint new_length=0;
- int result;
-
- session_adapt_uris(str, str_length, &newstr, &new_length);
-
- if (newstr) {
- str = newstr;
- str_length = new_length;
- }
-
- result = php_header_write(str, str_length);
-
- if (newstr) {
- free(newstr);
- }
-
- return result;
-}
-
-
-static int php_ub_body_write(const char *str, uint str_length)
-{
- int result = 0;
- SLS_FETCH();
-
- if (SG(request_info).headers_only) {
- zend_bailout();
- }
- if (php3_header()) {
- php_body_write = php_ub_body_write_no_header;
- result = php_ub_body_write_no_header(str, str_length);
- }
-
- return result;
-}
-
-
-/*
- * HEAD support
- */
-
-void set_header_request(int value)
-{
- /* deprecated */
-}
diff --git a/output.h b/output.h
deleted file mode 100644
index 73d053e309..0000000000
--- a/output.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
-*/
-
-
-#ifndef _OUTPUT_BUFFER
-#define _OUTPUT_BUFFER
-
-#include "php.h"
-
-PHPAPI void php_output_startup();
-
-/* exported output functions */
-PHPAPI int (*php_body_write)(const char *str, uint str_length); /* string output */
-PHPAPI int (*php_header_write)(const char *str, uint str_length); /* unbuffer string output */
-void php_start_ob_buffering();
-void php_end_ob_buffering(int send_buffer);
-int php_ob_get_buffer(pval *p);
-
-/* HEAD support */
-void set_header_request(int value);
-
-#endif /* _OUTPUT_BUFFER */
diff --git a/php.ini-dist b/php.ini-dist
deleted file mode 100644
index 896e9b24bc..0000000000
--- a/php.ini-dist
+++ /dev/null
@@ -1,288 +0,0 @@
-[PHP]
-
-;;;;;;;;;;;;;;;;;;;
-; About this file ;
-;;;;;;;;;;;;;;;;;;;
-; This file controls many aspects of PHP's behavior. In order for PHP to
-; read it, it must be named 'php.ini'. PHP looks for it in the current
-; working directory, in the path designated by the environment variable
-; PHPRC, and in the path that was defined in compile time (in that order).
-; Under Windows, the compile-time path is the Windows directory. The
-; path in which the php.ini file is looked for can be overriden using
-; the -c argument in command line mode.
-;
-; The syntax of the file is extremely simple. Whitespace and Lines
-; beginning with a semicolon are silently ignored (as you probably guessed).
-; Section headers (e.g. [Foo]) are also silently ignored, even though
-; they might mean something in the future (they probably won't).
-;
-; Options are specified using the syntax key = value or key = "complex value".
-; Key names are *case sensitive*. foo = bar is different from FOO = bar.
-; 'value' can be any number, word or keyword (keywords are On, Off, True,
-; False, Yes and No, and are case insensitive).
-; 'complex value' can be just about anything, expcept for " and a newline
-; Boolean flags can be turned on using the values 1, On, True or Yes.
-; They can be turned off using the values 0, Off, False or No.
-;
-; All the values in the php.ini-dist file correspond to the builtin
-; defaults (that is, if no php.ini is used, or if you delete these lines,
-; the builtin defaults will be identical).
-
-
-;;;;;;;;;;;;;;;;;;;;
-; Language Options ;
-;;;;;;;;;;;;;;;;;;;;
-
-engine = On ; Enable the PHP scripting language engine under Apache
-short_open_tag = On ; allow the <? tag. otherwise, only <?php and <script> tags are recognized.
-asp_tags = Off ; allow ASP-style <% %> tags
-precision = 14 ; number of significant digits displayed in floating point numbers
-y2k_compliance = Off ; whether to be year 2000 compliant (will cause problems with non y2k compliant browsers)
-output_buffering = Off ; Output buffering allows you to send header lines (including cookies)
- ; even after you send body content, in the price of slowing PHP's
- ; output layer a bit.
- ; You can enable output buffering by in runtime by calling the output
- ; buffering functions, or enable output buffering for all files
- ; by setting this directive to On.
-; Safe Mode
-safe_mode = Off
-safe_mode_exec_dir =
-
-; Colors for Syntax Highlighting mode. Anything that's acceptable in <font color=???> would work.
-highlight.string = #DD0000
-highlight.comment = #FF8000
-highlight.keyword = #007700
-highlight.bg = #FFFFFF
-highlight.default = #0000BB
-highlight.html = #000000
-
-; Misc
-expose_php = On ; Decides whether PHP may expose the fact that it is installed on the
- ; server (e.g., by adding its signature to the Web server header).
- ; It is no security threat in any way, but it makes it possible
- ; to determine whether you use PHP on your server or not.
-
-
-
-;;;;;;;;;;;;;;;;;;;
-; Resource Limits ;
-;;;;;;;;;;;;;;;;;;;
-
-max_execution_time = 30 ; Maximum execution time of each script, in seconds (UNIX only)
-memory_limit = 8388608 ; Maximum amount of memory a script may consume (8MB)
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-; Error handling and logging ;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-; error_reporting is a bit-field. Add each number up to get desired error reporting level
-; 1 = Normal errors
-; 2 = Normal warnings
-; 4 = Parser errors
-; 8 = Notices - warnings you can ignore, but sometimes imply a bug (e.g., using an uninitialized variable)
-error_reporting = 7
-display_errors = On ; Print out errors (as a part of the HTML script)
-log_errors = Off ; Log errors into a log file (server-specific log, stderr, or error_log (below))
-track_errors = Off ; Store the last error/warning message in $php_errormsg (boolean)
-;error_prepend_string = "<font color=ff0000>" ; string to output before an error message
-;error_append_string = "</font>" ; string to output after an error message
-;error_log = filename ; log errors to specified file
-;error_log = syslog ; log errors to syslog (Event Log on NT, not valid in Windows 95)
-warn_plus_overloading = Off ; warn if the + operator is used with strings
-
-
-;;;;;;;;;;;;;;;;;
-; Data Handling ;
-;;;;;;;;;;;;;;;;;
-gpc_order = "GPC" ; Order of evaluation of GET/POST/Cookie data. Later values override
- ; earlier values (e.g., by default, POST variables override GET variables,
- ; and Cookie variables override both POST and GET variables).
-gpc_globals = On ; Whether or not to define GET/POST/Cookie variables in the global
- ; scope. You may want to turn this off if you don't want
- ; to clutter your scripts' global scope with user data. This makes
- ; most sense when coupled with track_vars - in which case you can
- ; access all of the GPC variables through the $HTTP_GET_VARS[],
- ; $HTTP_POST_VARS[] and $HTTP_COOKIE_VARS[] variables.
-track_vars = On ; enable $HTTP_GET_VARS[], $HTTP_POST_VARS[] and $HTTP_COOKIE_VARS[] arrays
-
-; Magic quotes
-magic_quotes_gpc = On ; magic quotes for incoming GET/POST/Cookie data
-magic_quotes_runtime= Off ; magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc.
-magic_quotes_sybase = Off ; Use Sybase-style magic quotes (escape ' with '' instead of \')
-
-; automatically add files before or after any PHP document
-auto_prepend_file =
-auto_append_file =
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;
-; Paths and Directories ;
-;;;;;;;;;;;;;;;;;;;;;;;;;
-include_path = ; UNIX: "/path1:/path2" Windows: "\path1;\path2"
-doc_root = ; the root of the php pages, used only if nonempty
-user_dir = ; the directory under which php opens the script using /~username, used only if nonempty
-;upload_tmp_dir = ; temporary directory for HTTP uploaded files (will use system default if not specified)
-upload_max_filesize = 2097152 ; 2 Meg default limit on file uploads
-extension_dir = ./ ; directory in which the loadable extensions (modules) reside
-
-
-;;;;;;;;;;;;;;;;;;;;;;
-; Dynamic Extensions ;
-;;;;;;;;;;;;;;;;;;;;;;
-; if you wish to have an extension loaded automaticly, use the
-; following syntax: extension=modulename.extension
-; for example, on windows,
-; extension=msql.dll
-; or under UNIX,
-; extension=msql.so
-; Note that it should be the name of the module only, no directory information
-; needs to go here. Specify the location of the extension with the extension_dir directive above.
-
-
-;Windows Extensions
-;extension=php_mysql.dll
-;extension=php_nsmail.dll
-;extension=php_calendar.dll
-;extension=php_dbase.dll
-;extension=php_filepro.dll
-;extension=php_gd.dll
-;extension=php_dbm.dll
-;extension=php_mssql.dll
-;extension=php_zlib.dll
-;extension=php_filepro.dll
-;extension=php_imap4r2.dll
-;extension=php_ldap.dll
-;extension=php_crypt.dll
-;extension=php_msql2.dll
-;extension=php_odbc.dll
-
-;;;;;;;;;;;;;;;;;;;
-; Module Settings ;
-;;;;;;;;;;;;;;;;;;;
-
-[Syslog]
-define_syslog_variables = Off ; Whether or not to define the various syslog variables,
- ; e.g. $LOG_PID, $LOG_CRON, etc. Turning it off is a
- ; good idea performance-wise. In runtime, you can define
- ; these variables by calling define_syslog_variables()
-
-
-[mail function]
-SMTP = localhost ;for win32 only
-sendmail_from = me@localhost.com ;for win32 only
-sendmail_path = ;for unix only, may supply arguments as well (default is sendmail -t)
-
-[Debugger]
-debugger.host = localhost
-debugger.port = 7869
-debugger.enabled = False
-
-[Logging]
-; These configuration directives are used by the example logging mechanism.
-; See examples/README.logging for more explanation.
-;logging.method = db
-;logging.directory = /path/to/log/directory
-
-[SQL]
-sql.safe_mode = Off
-
-[ODBC]
-;uodbc.default_db = Not yet implemented
-;uodbc.default_user = Not yet implemented
-;uodbc.default_pw = Not yet implemented
-uodbc.allow_persistent = On ; allow or prevent persistent links
-uodbc.max_persistent = -1 ; maximum number of persistent links. -1 means no limit
-uodbc.max_links = -1 ; maximum number of links (persistent+non persistent). -1 means no limit
-uodbc.defaultlrl = 4096 ; Handling of LONG fields. Returns number of bytes to variables, 0 means passthru
-uodbc.defaultbinmode = 1 ; Handling of binary data. 0 means passthru, 1 return as is, 2 convert to char
-; See the documentation on odbc_binmode and odbc_longreadlen for an explanation of uodbc.defaultlrl
-; and uodbc.defaultbinmode
-
-[MySQL]
-mysql.allow_persistent = On ; allow or prevent persistent link
-mysql.max_persistent = -1 ; maximum number of persistent links. -1 means no limit
-mysql.max_links = -1 ; maximum number of links (persistent+non persistent). -1 means no limit
-mysql.default_port = ; default port number for mysql_connect(). If unset,
- ; mysql_connect() will use the $MYSQL_TCP_PORT, or the mysql-tcp
- ; entry in /etc/services, or the compile-time defined MYSQL_PORT
- ; (in that order). Win32 will only look at MYSQL_PORT.
-mysql.default_host = ; default host for mysql_connect() (doesn't apply in safe mode)
-mysql.default_user = ; default user for mysql_connect() (doesn't apply in safe mode)
-mysql.default_password = ; default password for mysql_connect() (doesn't apply in safe mode)
- ; Note that this is generally a *bad* idea to store passwords
- ; in this file. *Any* user with PHP access can run
- ; 'echo cfg_get_var("mysql.default_password")' and reveal that
- ; password! And of course, any users with read access to this
- ; file will be able to reveal the password as well.
-
-[mSQL]
-msql.allow_persistent = On ; allow or prevent persistent link
-msql.max_persistent = -1 ; maximum number of persistent links. -1 means no limit
-msql.max_links = -1 ; maximum number of links (persistent+non persistent). -1 means no limit
-
-[PostgresSQL]
-pgsql.allow_persistent = On ; allow or prevent persistent link
-pgsql.max_persistent = -1 ; maximum number of persistent links. -1 means no limit
-pgsql.max_links = -1 ; maximum number of links (persistent+non persistent). -1 means no limit
-
-[Sybase]
-sybase.allow_persistent = On ; allow or prevent persistent link
-sybase.max_persistent = -1 ; maximum number of persistent links. -1 means no limit
-sybase.max_links = -1 ; maximum number of links (persistent+non persistent). -1 means no limit
-;sybase.interface_file = "/usr/sybase/interfaces"
-sybase.min_error_severity = 10 ; minimum error severity to display
-sybase.min_message_severity = 10 ; minimum message severity to display
-sybase.compatability_mode = Off ; compatability mode with old versions of PHP 3.0.
- ; If on, this will cause PHP to automatically assign types to results
- ; according to their Sybase type, instead of treating them all as
- ; strings. This compatability mode will probably not stay around
- ; forever, so try applying whatever necessary changes to your code,
- ; and turn it off.
-
-[Sybase-CT]
-sybct.allow_persistent = On ; allow or prevent persistent link
-sybct.max_persistent = -1 ; maximum number of persistent links. -1 means no limit
-sybct.max_links = -1 ; maximum number of links (persistent+non persistent). -1 means no limit
-sybct.min_server_severity = 10 ; minimum server message severity to display
-sybct.min_client_severity = 10 ; minimum client message severity to display
-
-[bcmath]
-bcmath.scale = 0 ; number of decimal digits for all bcmath functions
-
-[browscap]
-;browscap = extra/browscap.ini
-
-[Informix]
-ifx.default_host = ; default host for ifx_connect() (doesn't apply in safe mode)
-ifx.default_user = ; default user for ifx_connect() (doesn't apply in safe mode)
-ifx.default_password = ; default password for ifx_connect() (doesn't apply in safe mode)
-ifx.allow_persistent = On ; allow or prevent persistent link
-ifx.max_persistent = -1 ; maximum number of persistent links. -1 means no limit
-ifx.max_links = -1 ; maximum number of links (persistent+non persistent). -1 means no limit
-ifx.textasvarchar = 0 ; if set on, select statements return the contents of a text blob instead of it's id
-ifx.byteasvarchar = 0 ; if set on, select statements return the contents of a byte blob instead of it's id
-ifx.charasvarchar = 0 ; trailing blanks are stripped from fixed-length char columns. May help the life
- ; of Informix SE users.
-ifx.blobinfile = 0 ; if set on, the contents of text&byte blobs are dumped to a file instead of
- ; keeping them in memory
-ifx.nullformat = 0 ; NULL's are returned as empty strings, unless this is set to 1. In that case,
- ; NULL's are returned as string 'NULL'.
-
-[Session]
-session.save_handler = files ; handler used to store/retrieve data
-session.save_path = /tmp ; argument passed to save_handler
- ; in the case of files, this is the
- ; path where data files are stored
-session.name = PHPSESSID ; name of the session
- ; is used as cookie name
-session.auto_start = 0 ; initialize session on request startup
-session.lifetime = 0 ; lifetime in seconds of cookie
- ; or if 0, until browser is restarted
-session.serialize_handler = php ; handler used to serialize data
- ; php is the standard serializer of PHP
-session.gc_probability = 1 ; procentual probability that the
- ; 'garbage collection' process is started
- ; on every session initialization
-session.gc_maxlifetime = 1440 ; after this number of seconds, stored
- ; data will be seen as 'garbage' and
- ; cleaned up by the gc process
diff --git a/php.map b/php.map
deleted file mode 100644
index d08024feef..0000000000
--- a/php.map
+++ /dev/null
@@ -1,4 +0,0 @@
-PHP4 {
-global: php4_module;
-local: *;
-};
diff --git a/php3_realpath.c b/php3_realpath.c
deleted file mode 100644
index da74b25458..0000000000
--- a/php3_realpath.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Sander Steffann (sander@steffann.nl) |
- +----------------------------------------------------------------------+
- */
-
-#include "php.h"
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <sys/stat.h>
-
-#ifndef MAXSYMLINKS
-#define MAXSYMLINKS 32
-#endif
-
-#ifndef S_ISDIR
-#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
-#endif
-
-char *_php3_realpath(char *path, char resolved_path[]);
-
-char *_php3_realpath(char *path, char resolved_path []) {
- char path_construction[MAXPATHLEN]; /* We build the result in here */
- char *writepos; /* Position to write next char */
-
- char path_copy[MAXPATHLEN]; /* A work-copy of the path */
- char *workpos; /* working position in *path */
-
-#if !(WIN32|WINNT)
- char buf[MAXPATHLEN]; /* Buffer for readlink */
- int linklength; /* The result from readlink */
-#endif
- int linkcount = 0; /* Count symlinks to avoid loops */
-
- struct stat filestat; /* result from stat */
-
-#if WIN32|WINNT
- char *temppos; /* position while counting '.' */
- int dotcount; /* number of '.' */
- int t; /* counter */
-#endif
-
- /* Set the work-position to the beginning of the given path */
- strcpy(path_copy, path);
- workpos = path_copy;
-
-#if WIN32|WINNT
- /* Find out where we start - Windows version */
- if ((*workpos == '\\') || (*workpos == '/')) {
- /* We start at the root of the current drive */
- /* Get the current directory */
- if (getcwd(path_construction, MAXPATHLEN-1) == NULL) {
- /* Unable to get cwd */
- resolved_path[0] = 0;
- return NULL;
- }
- /* We only need the first three chars (for example "C:\") */
- path_construction[3] = 0;
- workpos++;
- } else if (workpos[1] == ':') {
- /* A drive-letter is specified, copy it */
- strncpy(path_construction, path, 2);
- strcat(path_construction, "\\");
- workpos++;
- workpos++;
- } else {
- /* Use the current directory */
- if (getcwd(path_construction, MAXPATHLEN-1) == NULL) {
- /* Unable to get cwd */
- resolved_path[0] = 0;
- return NULL;
- }
- strcat(path_construction, "\\");
- }
-#else
- /* Find out where we start - Unix version */
- if (*workpos == '/') {
- /* We start at the root */
- strcpy(path_construction, "/");
- workpos++;
- } else {
- /* Use the current directory */
- if (getcwd(path_construction, MAXPATHLEN-1) == NULL) {
- /* Unable to get cwd */
- resolved_path[0] = 0;
- return NULL;
- }
- strcat(path_construction, "/");
- }
-#endif
-
- /* Set the next-char-position */
- writepos = &path_construction[strlen(path_construction)];
-
- /* Go to the end, then stop */
- while(*workpos != 0) {
- /* Strip (back)slashes */
-#if WIN32|WINNT
- while(*workpos == '\\') workpos++;
-#else
- while(*workpos == '/') workpos++;
-#endif
-
-#if WIN32|WINNT
- /* reset dotcount */
- dotcount = 0;
-
- /* Look for .. */
- if ((workpos[0] == '.') && (workpos[1] != 0)) {
- /* Windows accepts \...\ as \..\..\, \....\ as \..\..\..\, etc */
- /* At least Win98 does */
-
- temppos = workpos;
- while(*temppos++ == '.') {
- dotcount++;
- if ((*temppos != '\\') && (*temppos != 0) && (*temppos != '.')) {
- /* This is not a /../ component, but a filename that starts with '.' */
- dotcount = 0;
- }
- }
-
- /* Go back dotcount-1 times */
- for (t=0 ; t<(dotcount-1) ; t++) {
- workpos++; /* move to next '.' */
-
- /* Can we still go back? */
- if ((writepos-3) <= path_construction) return NULL;
-
- /* Go back */
- writepos--; /* move to '\' */
- while(*--writepos != '\\') ; /* skip until previous '\\' */
- }
- }
-
- /* No special case */
- if (dotcount == 0) {
- /* Append */
- while((*workpos != '\\') && (*workpos != 0)) {
- *writepos++ = *workpos++;
- }
- }
-
- /* Just one '.', go to next element */
- if (dotcount == 1) {
- while((*workpos != '\\') && (*workpos != 0)) {
- *workpos++;
- }
-
- /* Avoid double \ in the result */
- writepos--;
- }
-
- /* If it was a directory, append a slash */
- if (*workpos == '\\') {
- *writepos++ = *workpos++;
- }
- *writepos = 0;
-#else /* WIN32|WINNT */
- /* Look for .. */
- if ((workpos[0] == '.') && (workpos[1] != 0)) {
- if ((workpos[1] == '.') && ((workpos[2] == '/') || (workpos[2] == 0))) {
- /* One directory back */
- /* Set pointers to right position */
- workpos++; /* move to second '.' */
- workpos++; /* move to '/' */
-
- /* Only apply .. if not in root */
- if ((writepos-1) > path_construction) {
- writepos--; /* move to '/' */
- while(*--writepos != '/') ; /* skip until previous '/' */
- }
- } else {
- if (workpos[1] == '/') {
- /* Found a /./ skip it */
- workpos++; /* move to '/' */
-
- /* Avoid double / in the result */
- writepos--;
- } else {
- /* No special case, the name just started with a . */
- /* Append */
- while((*workpos != '/') && (*workpos != 0)) {
- *writepos++ = *workpos++;
- }
- }
- }
- } else {
- /* No special case */
- /* Append */
- while((*workpos != '/') && (*workpos != 0)) {
- *writepos++ = *workpos++;
- }
- }
-
-#if HAVE_SYMLINK
- /* We are going to use path_construction, so close it */
- *writepos = 0;
-
- /* Check the current location to see if it is a symlink */
- if((linklength = readlink(path_construction, buf, MAXPATHLEN)) != -1) {
- /* Check linkcount */
- if (linkcount > MAXSYMLINKS) return NULL;
-
- /* Count this symlink */
- linkcount++;
-
- /* Set end of buf */
- buf[linklength] = 0;
-
- /* Check for overflow */
- if ((strlen(workpos) + strlen(buf) + 1) >= MAXPATHLEN) return NULL;
-
- /* Remove the symlink-component wrom path_construction */
- writepos--; /* move to '/' */
- while(*--writepos != '/') ; /* skip until previous '/' */
- *++writepos = 0; /* end of string after '/' */
-
- /* If the symlink starts with a '/', empty path_construction */
- if (*buf == '/') {
- *path_construction = 0;
- writepos = path_construction;
- }
-
- /* Insert symlink into path_copy */
- strcat(buf, workpos);
- strcpy(path_copy, buf);
- workpos = path_copy;
- }
-#endif /* HAVE_SYMLINK */
-
- /* If it was a directory, append a slash */
- if (*workpos == '/') {
- *writepos++ = *workpos++;
- }
- *writepos = 0;
-#endif /* WIN32|WINNT */
- }
-
- /* Check if the resolved path is a directory */
- if (stat(path_construction, &filestat) != 0) return NULL;
- if (S_ISDIR(filestat.st_mode)) {
- /* It's a directory, append a / if needed */
- if (*(writepos-1) != '/') {
- /* Check for overflow */
- if ((strlen(workpos) + 2) >= MAXPATHLEN) return NULL;
-
- *writepos++ = '/';
- *writepos = 0;
- }
- }
-
- strcpy(resolved_path, path_construction);
- return resolved_path;
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/php3_realpath.h b/php3_realpath.h
deleted file mode 100644
index 4dff23e5e1..0000000000
--- a/php3_realpath.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Sander Steffann (sander@steffann.nl) |
- +----------------------------------------------------------------------+
- */
-
-#ifndef _PHP3_REALPATH_H_
-#define _PHP3_REALPATH_H_
-
-extern char *_php3_realpath(const char *path, char resolved_path []);
-
-#endif
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/php3_sprintf.c b/php3_sprintf.c
deleted file mode 100644
index 24b9bf15fd..0000000000
--- a/php3_sprintf.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Jaakko Hyvätti <jaakko.hyvatti@iki.fi> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php_config.h"
-#include <stdio.h>
-#include <stdarg.h>
-
-#if BROKEN_SPRINTF
-
-int
-php_sprintf (char*s, const char* format, ...)
-{
- va_list args;
- char *ret;
-
- va_start (args, format);
- s[0] = '\0';
- ret = vsprintf (s, format, args);
- va_end (args);
- if (!ret)
- return -1;
- return strlen (s);
-}
-
-#endif /* BROKEN_SPRINTF */
diff --git a/php4.dsp b/php4.dsp
deleted file mode 100644
index 1fda5f8a6c..0000000000
--- a/php4.dsp
+++ /dev/null
@@ -1,101 +0,0 @@
-# Microsoft Developer Studio Project File - Name="php4" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=php4 - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "php4.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php4.mak" CFG="php4 - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php4 - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "php4 - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "php4 - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "libzend" /I "." /I "regex\\" /I "..\bindlib_w32" /D "NDEBUG" /D "MSVC5" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D ZEND_DEBUG=0 /Fr /FD /c
-# SUBTRACT CPP /YX /Yc /Yu
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 php4nts.lib winmm.lib wsock32.lib netapi32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:3.0 /subsystem:console /machine:I386 /nodefaultlib:"libc.lib" /out:"Release\php.exe" /libpath:"Release"
-
-!ELSEIF "$(CFG)" == "php4 - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "libzend" /I "." /I "regex\\" /I "..\bindlib_w32" /D "DEBUG" /D "_DEBUG" /D "MSVC5" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D ZEND_DEBUG=1 /FR /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /i "c:\include" /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 winmm.lib wsock32.lib netapi32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4nts.lib /nologo /version:3.0 /subsystem:console /debug /machine:I386 /nodefaultlib:"libcd" /nodefaultlib:"libcmt" /out:"Debug\php.exe" /pdbtype:sept /libpath:"Debug"
-# SUBTRACT LINK32 /pdb:none
-
-!ENDIF
-
-# Begin Target
-
-# Name "php4 - Win32 Release"
-# Name "php4 - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter ".c"
-# Begin Source File
-
-SOURCE=.\cgi_main.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter ".h"
-# End Group
-# End Target
-# End Project
diff --git a/php4.dsw b/php4.dsw
deleted file mode 100644
index c14719887c..0000000000
--- a/php4.dsw
+++ /dev/null
@@ -1,59 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "libzend"=..\libzend\libzend.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "php4"=.\php4.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name php4dll
- End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "php4dll"=.\php4dll.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name libzend
- End Project Dependency
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/php4.gif b/php4.gif
deleted file mode 100644
index e5d3c477fd..0000000000
--- a/php4.gif
+++ /dev/null
Binary files differ
diff --git a/php4.spec.in b/php4.spec.in
deleted file mode 100644
index cfcd0796c7..0000000000
--- a/php4.spec.in
+++ /dev/null
@@ -1,48 +0,0 @@
-%define version @VERSION@
-%define so_version 4
-%define release 1
-
-Name: php
-Summary: PHP: Hypertext Preprocessor
-Group: Development/Languages
-Version: %{version}
-Release: %{release}
-Copyright: The PHP license (see "LICENSE" file included in distribution)
-Source: http://www.php.net/version4/downloads/php-%{version}.tar.gz
-Icon: php4.gif
-URL: http://www.php.net/
-Packager: PHP Group <group@php.net>
-
-BuildRoot: /var/tmp/php-%{version}
-
-%description
-PHP is an HTML-embedded scripting language. Much of its syntax is
-borrowed from C, Java and Perl with a couple of unique PHP-specific
-features thrown in. The goal of the language is to allow web
-developers to write dynamically generated pages quickly.
-
-%prep
-
-%setup
-
-%build
-set -x
-./buildconf
-./configure --prefix=/usr --with-apxs \
- --enable-track-vars --disable-debug \
- --with-xml=shared \
-
-# figure out configure options options based on what packages are installed
-# to override, use the OVERRIDE_OPTIONS environment variable. To add
-# extra options, use the OPTIONS environment variable.
-
-#test rpm -q MySQL-devel >&/dev/null && OPTIONS="$OPTIONS --with-mysql=shared"
-#test rpm -q solid-devel >&/dev/null && OPTIONS="$OPTIONS --with-solid=shared,/home/solid"
-#test rpm -q postgresql-devel >&/dev/null && OPTIONS="$OPTIONS --with-pgsql=shared"
-test rpm -q expat >&/dev/null && OPTIONS="$OPTIONS --with-xml=shared"
-
-if test "x$OVERRIDE_OPTIONS" = "x"; then
- ./configure --prefix=/usr --with-apxs=$APXS $OPTIONS
-else
- ./configure $OVERRIDE_OPTIONS
-fi
diff --git a/php4dll.dsp b/php4dll.dsp
deleted file mode 100644
index 957f5cfd20..0000000000
--- a/php4dll.dsp
+++ /dev/null
@@ -1,901 +0,0 @@
-# Microsoft Developer Studio Project File - Name="php4dll" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=php4dll - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "php4dll.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php4dll.mak" CFG="php4dll - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php4dll - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php4dll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "php4dll - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP4DLLTS_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "libzend" /I "." /I "regex" /I "..\bindlib_w32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "PHP4DLLTS_EXPORTS" /D "MSVC5" /D "PHP_EXPORTS" /D "LIBZEND_EXPORTS" /D "TSRM_EXPORTS" /D "SAPI_EXPORTS" /D "WIN32" /D "_MBCS" /D ZEND_DEBUG=1 /FR /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "_DEBUG"
-# ADD RSC /l 0x40d /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libzend.lib resolv.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"libcmt" /nodefaultlib:"libc" /nodefaultlib:"libcmtd" /out:"Debug/php4nts.dll" /pdbtype:sept /libpath:"TSRM\Debug" /libpath:"libzend\Debug" /libpath:"..\bindlib_w32\Debug"
-
-!ELSEIF "$(CFG)" == "php4dll - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP4DLLTS_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "libzend" /I "." /I "regex" /I "..\bindlib_w32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "PHP4DLLTS_EXPORTS" /D "MSVC5" /D "PHP_EXPORTS" /D "LIBZEND_EXPORTS" /D "TSRM_EXPORTS" /D "SAPI_EXPORTS" /D "WIN32" /D "_MBCS" /D ZEND_DEBUG=0 /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "NDEBUG"
-# ADD RSC /l 0x40d /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libzend.lib resolv.lib /nologo /dll /machine:I386 /nodefaultlib:"libc.lib" /out:"Release/php4nts.dll" /libpath:"TSRM\Release" /libpath:"libzend\Release" /libpath:"..\bindlib_w32\Release"
-
-!ENDIF
-
-# Begin Target
-
-# Name "php4dll - Win32 Debug"
-# Name "php4dll - Win32 Release"
-# Begin Group "Core"
-
-# PROP Default_Filter ""
-# Begin Group "Source Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=".\configuration-parser.c"
-# End Source File
-# Begin Source File
-
-SOURCE=".\configuration-scanner.c"
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\cyr_convert.c
-# End Source File
-# Begin Source File
-
-SOURCE=".\fopen-wrappers.c"
-# End Source File
-# Begin Source File
-
-SOURCE=.\getopt.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\internal_functions_win32.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\output.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\php3_realpath.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_content_types.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_ini.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\quot_print.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\request_info.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\rfc1867.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\safe_mode.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\SAPI.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\strlcat.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\strlcpy.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\config.w32.h
-# End Source File
-# Begin Source File
-
-SOURCE=".\configuration-parser.h"
-# End Source File
-# Begin Source File
-
-SOURCE=".\configuration-parser.tab.h"
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\cyr_convert.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\getopt.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\internal_functions_registry.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\logos.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\main.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\output.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php3_compat.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php3_realpath.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_content_types.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_globals.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_ini.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\quot_print.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\request_info.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\rfc1867.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\safe_mode.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\SAPI.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win95nt.h
-# End Source File
-# End Group
-# End Group
-# Begin Group "Function Modules"
-
-# PROP Default_Filter ""
-# Begin Group "Source Files No. 1"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\ext\apache\apache.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\base64.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\basic_functions.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\bcmath\bcmath.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\browscap.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\datetime.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\dir.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\dl.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\dns.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\exec.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\file.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\filestat.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\flock_compat.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\formatted_print.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\fsock.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\head.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\html.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\image.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\info.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\iptc.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\lcg.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\link.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\mail.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\math.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\md5.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\microtime.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\session\mod_files.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\session\mod_user.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\bcmath\number.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\pack.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\pageinfo.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\parsedate.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\odbc\php_odbc.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\pcre\php_pcre.c
-
-!IF "$(CFG)" == "php4dll - Win32 Debug"
-
-# ADD CPP /D "STATIC"
-
-!ELSEIF "$(CFG)" == "php4dll - Win32 Release"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\post.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\rand.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\reg.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\session\session.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\soundex.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\string.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\syslog.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\type.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\uniqid.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\url.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\var.c
-# End Source File
-# End Group
-# Begin Group "Header Files No. 1"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\ext\standard\base64.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\basic_functions.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\datetime.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\dl.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\dns.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\exec.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\file.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\flock_compat.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\fsock.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\functions\global.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\head.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\html.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\md5.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\mime.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\session\mod_user.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\bcmath\number.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\pageinfo.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\bcmath\php3_bcmath.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\functions\php3_dir.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\functions\php3_filestat.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\functions\php3_ldap.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\php3_mail.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\odbc\php3_odbc.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\php3_string.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\functions\php3_string.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\functions\php3_syslog.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\pcre\php_pcre.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\functions\phpdir.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\functions\phpmath.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\post.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\reg.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\type.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\uniqid.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\url.h
-# End Source File
-# End Group
-# Begin Group "Regular Expressions"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\regex\regcomp.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\regex\regerror.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\regex\regexec.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\regex\regfree.c
-# End Source File
-# End Group
-# Begin Group "PCRE"
-
-# PROP Default_Filter ""
-# Begin Group "Source Files No. 3"
-
-# PROP Default_Filter ".c"
-# Begin Source File
-
-SOURCE=.\ext\pcre\pcrelib\chartables.c
-
-!IF "$(CFG)" == "php4dll - Win32 Debug"
-
-# ADD CPP /D "STATIC"
-
-!ELSEIF "$(CFG)" == "php4dll - Win32 Release"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\pcre\pcrelib\get.c
-
-!IF "$(CFG)" == "php4dll - Win32 Debug"
-
-# ADD CPP /D "STATIC"
-
-!ELSEIF "$(CFG)" == "php4dll - Win32 Release"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\pcre\pcrelib\maketables.c
-
-!IF "$(CFG)" == "php4dll - Win32 Debug"
-
-# ADD CPP /D "STATIC"
-
-!ELSEIF "$(CFG)" == "php4dll - Win32 Release"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\pcre\pcrelib\pcre.c
-
-!IF "$(CFG)" == "php4dll - Win32 Debug"
-
-# ADD CPP /D "STATIC"
-
-!ELSEIF "$(CFG)" == "php4dll - Win32 Release"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\pcre\pcrelib\study.c
-
-!IF "$(CFG)" == "php4dll - Win32 Debug"
-
-# ADD CPP /D "STATIC"
-
-!ELSEIF "$(CFG)" == "php4dll - Win32 Release"
-
-!ENDIF
-
-# End Source File
-# End Group
-# Begin Group "Header Files No. 3"
-
-# PROP Default_Filter ".h"
-# Begin Source File
-
-SOURCE=.\ext\pcre\pcrelib\internal.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\pcre\pcrelib\pcre.h
-# End Source File
-# End Group
-# End Group
-# End Group
-# Begin Group "Win32"
-
-# PROP Default_Filter ""
-# Begin Group "Source Files No. 2"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\ext\com\COM.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\pwd.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\readdir.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\registry.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\sendmail.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\time.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\wfile.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\dl\snmp\winsnmp.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\winutil.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\wsyslog.c
-# End Source File
-# End Group
-# Begin Group "Header Files No. 2"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\win32\grp.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\param.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\com\php3_COM.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\php_registry.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\pwd.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\readdir.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\sendmail.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\syslog.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\time.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\unistd.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\wfile.h
-# End Source File
-# End Group
-# End Group
-# Begin Group "Parsers"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=".\configuration-parser.y"
-
-!IF "$(CFG)" == "php4dll - Win32 Debug"
-
-# Begin Custom Build
-InputPath=".\configuration-parser.y"
-
-BuildCmds= \
- bison --output=configuration-parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p cfg configuration-parser.y
-
-"configuration-parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"configuration-parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "php4dll - Win32 Release"
-
-# Begin Custom Build
-InputPath=".\configuration-parser.y"
-
-BuildCmds= \
- bison --output=configuration-parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p cfg configuration-parser.y
-
-"configuration-parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"configuration-parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-# End Custom Build
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\parsedate.y
-
-!IF "$(CFG)" == "php4dll - Win32 Debug"
-
-# Begin Custom Build
-InputPath=.\ext\standard\parsedate.y
-
-"ext\standard\parsedate.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- cd ext\standard
- bison --output=parsedate.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" parsedate.y
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "php4dll - Win32 Release"
-
-!ENDIF
-
-# End Source File
-# End Group
-# Begin Group "Scanners"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=".\configuration-scanner.l"
-
-!IF "$(CFG)" == "php4dll - Win32 Debug"
-
-# Begin Custom Build
-InputPath=".\configuration-scanner.l"
-
-"configuration-scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- flex -i -Pcfg -oconfiguration-scanner.c configuration-scanner.l
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "php4dll - Win32 Release"
-
-# Begin Custom Build
-InputPath=".\configuration-scanner.l"
-
-"configuration-scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- flex -i -Pcfg -oconfiguration-scanner.c configuration-scanner.l
-
-# End Custom Build
-
-!ENDIF
-
-# End Source File
-# End Group
-# Begin Group "Text Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\ChangeLog
-# End Source File
-# Begin Source File
-
-SOURCE=.\LICENSE
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/php4dllts.dsp b/php4dllts.dsp
deleted file mode 100644
index 5ef16a9d79..0000000000
--- a/php4dllts.dsp
+++ /dev/null
@@ -1,873 +0,0 @@
-# Microsoft Developer Studio Project File - Name="php4dllts" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=php4dllts - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "php4dllts.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php4dllts.mak" CFG="php4dllts - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php4dllts - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php4dllts - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "php4dllts - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP4DLLTS_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I "regex" /I "..\bindlib_w32" /I "libzend" /I "tsrm" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "PHP4DLLTS_EXPORTS" /D "MSVC5" /D "PHP_EXPORTS" /D "LIBZEND_EXPORTS" /D "TSRM_EXPORTS" /D "SAPI_EXPORTS" /D "WIN32" /D "_MBCS" /D "ZTS" /D ZEND_DEBUG=1 /FR /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "_DEBUG"
-# ADD RSC /l 0x40d /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libzendts.lib TSRM.lib resolv.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"libcmt" /nodefaultlib:"libc" /out:"Debug_TS/php4ts.dll" /pdbtype:sept /libpath:"TSRM\Debug_TS" /libpath:"libzend\Debug_TS" /libpath:"..\bindlib_w32\Debug"
-
-!ELSEIF "$(CFG)" == "php4dllts - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP4DLLTS_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "regex" /I "..\bindlib_w32" /I "libzend" /I "tsrm" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "PHP4DLLTS_EXPORTS" /D "MSVC5" /D "PHP_EXPORTS" /D "LIBZEND_EXPORTS" /D "TSRM_EXPORTS" /D "SAPI_EXPORTS" /D "ZTS" /D "WIN32" /D "_MBCS" /D ZEND_DEBUG=0 /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "NDEBUG"
-# ADD RSC /l 0x40d /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libzendts.lib TSRM.lib resolv.lib /nologo /dll /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libcmt.lib" /out:"Release_TS/php4ts.dll" /libpath:"TSRM\Release_TS" /libpath:"libzend\Release_TS" /libpath:"..\bindlib_w32\Release"
-
-!ENDIF
-
-# Begin Target
-
-# Name "php4dllts - Win32 Debug_TS"
-# Name "php4dllts - Win32 Release_TS"
-# Begin Group "Core"
-
-# PROP Default_Filter ""
-# Begin Group "Source Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=".\configuration-parser.c"
-# End Source File
-# Begin Source File
-
-SOURCE=".\configuration-scanner.c"
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\cyr_convert.c
-# End Source File
-# Begin Source File
-
-SOURCE=".\fopen-wrappers.c"
-# End Source File
-# Begin Source File
-
-SOURCE=.\getopt.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\internal_functions_win32.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\output.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\php3_realpath.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_content_types.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_ini.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\quot_print.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\request_info.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\rfc1867.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\safe_mode.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\SAPI.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\strlcat.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\strlcpy.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\config.w32.h
-# End Source File
-# Begin Source File
-
-SOURCE=".\configuration-parser.h"
-# End Source File
-# Begin Source File
-
-SOURCE=".\configuration-parser.tab.h"
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\cyr_convert.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\getopt.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\internal_functions_registry.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\logos.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\main.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\output.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php3_compat.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php3_realpath.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_content_types.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_globals.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_ini.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_regex.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\quot_print.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\request_info.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\rfc1867.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\safe_mode.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\SAPI.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win95nt.h
-# End Source File
-# End Group
-# End Group
-# Begin Group "Function Modules"
-
-# PROP Default_Filter ""
-# Begin Group "Source Files No. 1"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\ext\apache\apache.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\base64.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\basic_functions.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\bcmath\bcmath.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\browscap.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\datetime.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\dir.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\dl.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\dns.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\exec.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\file.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\filestat.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\flock_compat.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\formatted_print.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\fsock.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\head.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\html.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\image.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\info.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\iptc.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\lcg.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\link.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\mail.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\math.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\md5.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\microtime.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\session\mod_files.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\session\mod_user.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\bcmath\number.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\pack.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\pageinfo.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\parsedate.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\mcal\php3_mcal.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\odbc\php_odbc.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\pcre\php_pcre.c
-# ADD CPP /D "STATIC"
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\post.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\rand.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\reg.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\session\session.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\soundex.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\string.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\syslog.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\type.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\uniqid.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\url.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\var.c
-# End Source File
-# End Group
-# Begin Group "Header Files No. 1"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\ext\standard\base64.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\basic_functions.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\datetime.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\dl.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\dns.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\exec.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\file.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\flock_compat.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\fsock.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\functions\global.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\head.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\html.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\info.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\md5.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\session\mod_user.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\bcmath\number.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\pageinfo.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\bcmath\php3_bcmath.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\functions\php3_dir.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\functions\php3_filestat.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\functions\php3_ldap.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\php3_mail.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\mcal\php3_mcal.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\odbc\php3_odbc.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\php3_string.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\functions\php3_syslog.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\php_lcg.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\pcre\php_pcre.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\session\php_session.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\functions\phpdir.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\functions\phpmath.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\post.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\reg.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\type.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\uniqid.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\url.h
-# End Source File
-# End Group
-# Begin Group "PCRE"
-
-# PROP Default_Filter ""
-# Begin Group "Source Files No. 3"
-
-# PROP Default_Filter ".c"
-# Begin Source File
-
-SOURCE=.\ext\pcre\pcrelib\chartables.c
-# ADD CPP /D "STATIC"
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\pcre\pcrelib\get.c
-# ADD CPP /D "STATIC"
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\pcre\pcrelib\maketables.c
-# ADD CPP /D "STATIC"
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\pcre\pcrelib\pcre.c
-# ADD CPP /D "STATIC"
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\pcre\pcrelib\study.c
-# ADD CPP /D "STATIC"
-# End Source File
-# End Group
-# Begin Group "Header Files No. 3"
-
-# PROP Default_Filter ".h"
-# Begin Source File
-
-SOURCE=.\ext\pcre\pcrelib\internal.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\pcre\pcrelib\pcre.h
-# End Source File
-# End Group
-# End Group
-# Begin Group "Regular Expressions"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\regex\regcomp.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\regex\regerror.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\regex\regexec.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\regex\regfree.c
-# End Source File
-# End Group
-# End Group
-# Begin Group "Win32"
-
-# PROP Default_Filter ""
-# Begin Group "Source Files No. 2"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\ext\com\COM.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\pwd.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\readdir.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\registry.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\sendmail.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\time.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\wfile.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\dl\snmp\winsnmp.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\winutil.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\wsyslog.c
-# End Source File
-# End Group
-# Begin Group "Header Files No. 2"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\win32\grp.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\param.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\com\php3_COM.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\php_registry.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\pwd.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\readdir.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\sendmail.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\syslog.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\time.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\unistd.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32\wfile.h
-# End Source File
-# End Group
-# End Group
-# Begin Group "Parsers"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=".\configuration-parser.y"
-
-!IF "$(CFG)" == "php4dllts - Win32 Debug_TS"
-
-# Begin Custom Build
-InputPath=".\configuration-parser.y"
-
-BuildCmds= \
- bison --output=configuration-parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p cfg configuration-parser.y
-
-"configuration-parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"configuration-parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "php4dllts - Win32 Release_TS"
-
-# Begin Custom Build
-InputPath=".\configuration-parser.y"
-
-BuildCmds= \
- bison --output=configuration-parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p cfg configuration-parser.y
-
-"configuration-parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-
-"configuration-parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- $(BuildCmds)
-# End Custom Build
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\ext\standard\parsedate.y
-
-!IF "$(CFG)" == "php4dllts - Win32 Debug_TS"
-
-# Begin Custom Build
-InputPath=.\ext\standard\parsedate.y
-
-"ext\standard\parsedate.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- cd ext\standard
- bison --output=parsedate.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" parsedate.y
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "php4dllts - Win32 Release_TS"
-
-!ENDIF
-
-# End Source File
-# End Group
-# Begin Group "Scanners"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=".\configuration-scanner.l"
-
-!IF "$(CFG)" == "php4dllts - Win32 Debug_TS"
-
-# Begin Custom Build
-InputPath=".\configuration-scanner.l"
-
-"configuration-scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- flex -i -Pcfg -oconfiguration-scanner.c configuration-scanner.l
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "php4dllts - Win32 Release_TS"
-
-# Begin Custom Build
-InputPath=".\configuration-scanner.l"
-
-"configuration-scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- flex -i -Pcfg -oconfiguration-scanner.c configuration-scanner.l
-
-# End Custom Build
-
-!ENDIF
-
-# End Source File
-# End Group
-# Begin Group "Text Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\ChangeLog
-# End Source File
-# Begin Source File
-
-SOURCE=.\LICENSE
-# End Source File
-# Begin Source File
-
-SOURCE=".\php.ini-dist"
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/php4ext.dsw b/php4ext.dsw
deleted file mode 100644
index 8cf96a86c1..0000000000
--- a/php4ext.dsw
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "mysql"=.\ext\mysql\mysql.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/php4ts.dsp b/php4ts.dsp
deleted file mode 100644
index be65824d9f..0000000000
--- a/php4ts.dsp
+++ /dev/null
@@ -1,101 +0,0 @@
-# Microsoft Developer Studio Project File - Name="php4ts" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=php4ts - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "php4ts.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php4ts.mak" CFG="php4ts - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php4ts - Win32 Release_TS" (based on "Win32 (x86) Console Application")
-!MESSAGE "php4ts - Win32 Debug_TS" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "php4ts - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "regex" /I "..\bindlib_w32" /I "libzend" /I "tsrm" /D "NDEBUG" /D "MSVC5" /D "_CONSOLE" /D "ZTS" /D "WIN32" /D "_MBCS" /D ZEND_DEBUG=0 /Fr /FD /c
-# SUBTRACT CPP /YX /Yc /Yu
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 php4ts.lib winmm.lib wsock32.lib netapi32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:3.0 /subsystem:console /machine:I386 /nodefaultlib:"libc.lib" /out:"Release_TS\php.exe" /libpath:"Release_TS"
-
-!ELSEIF "$(CFG)" == "php4ts - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I "regex" /I "..\bindlib_w32" /I "libzend" /I "tsrm" /D "DEBUG" /D "_DEBUG" /D "MSVC5" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "ZTS" /D ZEND_DEBUG=1 /FR /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /i "c:\include" /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 winmm.lib wsock32.lib netapi32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib /nologo /version:3.0 /subsystem:console /debug /machine:I386 /nodefaultlib:"libcd" /nodefaultlib:"libcmt" /out:"Debug_TS\php.exe" /pdbtype:sept /libpath:"Debug_TS"
-# SUBTRACT LINK32 /pdb:none
-
-!ENDIF
-
-# Begin Target
-
-# Name "php4ts - Win32 Release_TS"
-# Name "php4ts - Win32 Debug_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter ".c"
-# Begin Source File
-
-SOURCE=.\cgi_main.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter ".h"
-# End Group
-# End Target
-# End Project
diff --git a/php4ts.dsw b/php4ts.dsw
deleted file mode 100644
index cc2e72b1a8..0000000000
--- a/php4ts.dsw
+++ /dev/null
@@ -1,92 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "TSRM"=.\TSRM\TSRM.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "libzendts"=.\libzend\libzendts.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name TSRM
- End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "php4dllts"=.\php4dllts.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name libzendts
- End Project Dependency
- Begin Project Dependency
- Project_Dep_Name TSRM
- End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "php4isapi"=.\php4isapi\php4isapi.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name php4dllts
- End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "php4ts"=.\php4ts.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name php4dllts
- End Project Dependency
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/php_custom_build.mak b/php_custom_build.mak
deleted file mode 100644
index 5f83769018..0000000000
--- a/php_custom_build.mak
+++ /dev/null
@@ -1,269 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on php_custom_build.dsp
-!IF "$(CFG)" == ""
-CFG=php_custom_build - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to php_custom_build - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "php_custom_build - Win32 Release" && "$(CFG)" != "php_custom_build - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php_custom_build.mak" CFG="php_custom_build - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php_custom_build - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "php_custom_build - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-!IF "$(CFG)" == "php_custom_build - Win32 Release"
-
-OUTDIR=.\Release
-INTDIR=.\Release
-
-ALL : ".\language-scanner.c" ".\language-parser.c" ".\configuration-scanner.c" ".\configuration-parser.tab.c"
-
-
-CLEAN :
- -@erase
- -@erase "configuration-parser.tab.c"
- -@erase "configuration-scanner.c"
- -@erase "language-parser.c"
- -@erase "language-scanner.c"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\php_custom_build.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\php_custom_build.bsc"
-BSC32_SBRS= \
-
-LIB32=link.exe -lib
-LIB32_FLAGS=/nologo /out:"$(OUTDIR)\php_custom_build.lib"
-LIB32_OBJS= \
-
-
-!ELSEIF "$(CFG)" == "php_custom_build - Win32 Debug"
-
-OUTDIR=.\Debug
-INTDIR=.\Debug
-
-ALL : ".\language-scanner.c" ".\language-parser.tab.c" ".\configuration-scanner.c" ".\configuration-parser.tab.c"
-
-
-CLEAN :
- -@erase
- -@erase "configuration-parser.tab.c"
- -@erase "configuration-scanner.c"
- -@erase "language-parser.tab.c"
- -@erase "language-scanner.c"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MLd /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\php_custom_build.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\php_custom_build.bsc"
-BSC32_SBRS= \
-
-LIB32=link.exe -lib
-LIB32_FLAGS=/nologo /out:"$(OUTDIR)\php_custom_build.lib"
-LIB32_OBJS= \
-
-
-!ENDIF
-
-
-!IF "$(NO_EXTERNAL_DEPS)" != "1"
-!IF EXISTS("php_custom_build.dep")
-!INCLUDE "php_custom_build.dep"
-!ELSE
-!MESSAGE Warning: cannot find "php_custom_build.dep"
-!ENDIF
-!ENDIF
-
-
-!IF "$(CFG)" == "php_custom_build - Win32 Release" || "$(CFG)" == "php_custom_build - Win32 Debug"
-SOURCE=".\configuration-parser.y"
-
-!IF "$(CFG)" == "php_custom_build - Win32 Release"
-
-InputPath=".\configuration-parser.y"
-
-".\configuration-parser.tab.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- <<tempfile.bat
- @echo off
- bison.exe -p cfg -v -d configuration-parser.y
-<<
-
-
-!ELSEIF "$(CFG)" == "php_custom_build - Win32 Debug"
-
-InputPath=".\configuration-parser.y"
-
-".\configuration-parser.tab.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- <<tempfile.bat
- @echo off
- bison.exe -p cfg -v -d configuration-parser.y
-<<
-
-
-!ENDIF
-
-SOURCE=".\configuration-scanner.lex"
-
-!IF "$(CFG)" == "php_custom_build - Win32 Release"
-
-InputPath=".\configuration-scanner.lex"
-
-".\configuration-scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- <<tempfile.bat
- @echo off
- flex.exe -Pcfg -oconfiguration-scanner.c -i configuration-scanner.lex
-<<
-
-
-!ELSEIF "$(CFG)" == "php_custom_build - Win32 Debug"
-
-InputPath=".\configuration-scanner.lex"
-
-".\configuration-scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- <<tempfile.bat
- @echo off
- flex.exe -Pcfg -oconfiguration-scanner.c -i configuration-scanner.lex
-<<
-
-
-!ENDIF
-
-SOURCE=".\language-parser.y"
-
-!IF "$(CFG)" == "php_custom_build - Win32 Release"
-
-InputPath=".\language-parser.y"
-
-".\language-parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- <<tempfile.bat
- @echo off
- bison -p php -v -d language-parser.y
-<<
-
-
-!ELSEIF "$(CFG)" == "php_custom_build - Win32 Debug"
-
-InputPath=".\language-parser.y"
-
-".\language-parser.tab.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- <<tempfile.bat
- @echo off
- bison.exe -p php -v -d language-parser.y
-<<
-
-
-!ENDIF
-
-SOURCE=".\language-scanner.lex"
-
-!IF "$(CFG)" == "php_custom_build - Win32 Release"
-
-InputPath=".\language-scanner.lex"
-
-".\language-scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- <<tempfile.bat
- @echo off
- flex -Pphp -olanguage-scanner.c -i language-scanner.lex
-<<
-
-
-!ELSEIF "$(CFG)" == "php_custom_build - Win32 Debug"
-
-InputPath=".\language-scanner.lex"
-
-".\language-scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- <<tempfile.bat
- @echo off
- flex -Pphp -olanguage-scanner.c -i language-scanner.lex
-<<
-
-
-!ENDIF
-
-
-!ENDIF
-
diff --git a/php_getopt.h b/php_getopt.h
deleted file mode 100644
index e84e117527..0000000000
--- a/php_getopt.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Borrowed from Apache NT Port */
-#include "php.h"
-
-PHPAPI extern char *optarg;
-PHPAPI extern int optind;
-extern int opterr;
-extern int optopt;
-
-PHPAPI int getopt(int argc, char* const *argv, const char *optstr);
diff --git a/regex/COPYRIGHT b/regex/COPYRIGHT
deleted file mode 100644
index d43362fbfc..0000000000
--- a/regex/COPYRIGHT
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright 1992, 1993, 1994 Henry Spencer. All rights reserved.
-This software is not subject to any license of the American Telephone
-and Telegraph Company or of the Regents of the University of California.
-
-Permission is granted to anyone to use this software for any purpose on
-any computer system, and to alter it and redistribute it, subject
-to the following restrictions:
-
-1. The author is not responsible for the consequences of use of this
- software, no matter how awful, even if they arise from flaws in it.
-
-2. The origin of this software must not be misrepresented, either by
- explicit claim or by omission. Since few users ever read sources,
- credits must appear in the documentation.
-
-3. Altered versions must be plainly marked as such, and must not be
- misrepresented as being the original software. Since few users
- ever read sources, credits must appear in the documentation.
-
-4. This notice may not be removed or altered.
diff --git a/regex/Makefile.in b/regex/Makefile.in
deleted file mode 100644
index 4561974b06..0000000000
--- a/regex/Makefile.in
+++ /dev/null
@@ -1,145 +0,0 @@
-SHELL = /bin/sh
-
-srcdir=@srcdir@
-VPATH=@srcdir@
-
-CC=@CC@
-RANLIB=@RANLIB@
-
-# You probably want to take -DREDEBUG out of CFLAGS, and put something like
-# -O in, *after* testing (-DREDEBUG strengthens testing by enabling a lot of
-# internal assertion checking and some debugging facilities).
-# Put -Dconst= in for a pre-ANSI compiler.
-# Do not take -DPOSIX_MISTAKE out.
-# REGCFLAGS isn't important to you (it's for my use in some special contexts).
-CFLAGS=@CFLAGS@
-COMPILE=$(CC) $(CFLAGS) -I$(srcdir) -I. -DPOSIX_MISTAKE
-
-# If you have a pre-ANSI compiler, put -o into MKHFLAGS. If you want
-# the Berkeley __P macro, put -b in.
-MKHFLAGS=
-
-# Flags for linking but not compiling, if any.
-LDFLAGS=@LDFLAGS@
-
-# Extra libraries for linking, if any.
-LIBS=
-
-# Internal stuff, should not need changing.
-OBJPRODN=regcomp.o regexec.o regerror.o regfree.o
-OBJS=$(OBJPRODN) split.o debug.o main.o
-H=cclass.h cname.h regex2.h utils.h
-REGSRC=regcomp.c regerror.c regexec.c regfree.c
-ALLSRC=$(REGSRC) engine.c debug.c main.c split.c
-
-# Stuff that matters only if you're trying to lint the package.
-LINTFLAGS=-I. -Dstatic= -Dconst= -DREDEBUG
-LINTC=regcomp.c regexec.c regerror.c regfree.c debug.c main.c
-JUNKLINT=possible pointer alignment|null effect
-
-# arrangements to build forward-reference header files
-.SUFFIXES: .ih .h
-.c.ih:
- sh $(srcdir)/mkh $(MKHFLAGS) -p $< >$@
-
-.c.o:
- $(COMPILE) -c $<
-
-all lib: libregex.a
-
-libregex.a: $(OBJPRODN)
- rm -f libregex.a
- ar cr libregex.a $(OBJPRODN)
- $(RANLIB) libregex.a
-
-default: r
-
-purge:
- rm -f *.o
-
-# stuff to build regex.h
-REGEXH=regex.h
-REGEXHSRC=regex2.h $(REGSRC)
-$(REGEXH): $(REGEXHSRC) mkh
- sh $(srcdir)/./mkh $(MKHFLAGS) -i _REGEX_H_ $(REGEXHSRC) >regex.h
- #cmp -s regex.tmp regex.h 2>/dev/null || cp regex.tmp regex.h
- #rm -f regex.tmp
-
-# dependencies
-$(OBJPRODN) debug.o: utils.h regex.h regex2.h
-regcomp.o: cclass.h cname.h regcomp.ih
-regexec.o: engine.c engine.ih
-regerror.o: regerror.ih
-debug.o: debug.ih
-main.o: main.ih
-
-# tester
-re: $(OBJS)
- $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
-
-# regression test
-r: re tests
- ./re <tests
- ./re -el <tests
- ./re -er <tests
-
-# 57 variants, and other stuff, for development use -- not useful to you
-ra: ./re tests
- -./re <tests
- -./re -el <tests
- -./re -er <tests
-
-rx: ./re tests
- ./re -x <tests
- ./re -x -el <tests
- ./re -x -er <tests
-
-t: ./re tests
- -time ./re <tests
- -time ./re -cs <tests
- -time ./re -el <tests
- -time ./re -cs -el <tests
-
-l: $(LINTC)
- lint $(LINTFLAGS) -h $(LINTC) 2>&1 | egrep -v '$(JUNKLINT)' | tee lint
-
-fullprint:
- ti README WHATSNEW notes todo | list
- ti *.h | list
- list *.c
- list regex.3 regex.7
-
-print:
- ti README WHATSNEW notes todo | list
- ti *.h | list
- list reg*.c engine.c
-
-
-mf.tmp: Makefile
- sed '/^REGEXH=/s/=.*/=regex.h/' Makefile | sed '/#DEL$$/d' >$@
-
-DTRH=cclass.h cname.h regex2.h utils.h
-PRE=COPYRIGHT README WHATSNEW
-POST=mkh regex.3 regex.7 tests $(DTRH) $(ALLSRC) fake/*.[ch]
-FILES=$(PRE) Makefile $(POST)
-DTR=$(PRE) Makefile=mf.tmp $(POST)
-dtr: $(FILES) mf.tmp
- makedtr $(DTR) >$@
- rm mf.tmp
-
-cio: $(FILES)
- cio $(FILES)
-
-rdf: $(FILES)
- rcsdiff -c $(FILES) 2>&1 | p
-
-# various forms of cleanup
-tidy:
- rm -f junk* core core.* *.core dtr *.tmp lint
-
-clean: tidy
- rm -f *.o *.s re libregex.a
-
-# don't do this one unless you know what you're doing
-spotless: clean
- rm -f mkh regex.h
diff --git a/regex/README b/regex/README
deleted file mode 100644
index cea9b67b66..0000000000
--- a/regex/README
+++ /dev/null
@@ -1,32 +0,0 @@
-alpha3.4 release.
-Thu Mar 17 23:17:18 EST 1994
-henry@zoo.toronto.edu
-
-See WHATSNEW for change listing.
-
-installation notes:
---------
-Read the comments at the beginning of Makefile before running.
-
-Utils.h contains some things that just might have to be modified on
-some systems, as well as a nested include (ugh) of <assert.h>.
-
-The "fake" directory contains quick-and-dirty fakes for some header
-files and routines that old systems may not have. Note also that
--DUSEBCOPY will make utils.h substitute bcopy() for memmove().
-
-After that, "make r" will build regcomp.o, regexec.o, regfree.o,
-and regerror.o (the actual routines), bundle them together into a test
-program, and run regression tests on them. No output is good output.
-
-"make lib" builds just the .o files for the actual routines (when
-you're happy with testing and have adjusted CFLAGS for production),
-and puts them together into libregex.a. You can pick up either the
-library or *.o ("make lib" makes sure there are no other .o files left
-around to confuse things).
-
-Main.c, debug.c, split.c are used for regression testing but are not part
-of the RE routines themselves.
-
-Regex.h goes in /usr/include. All other .h files are internal only.
---------
diff --git a/regex/WHATSNEW b/regex/WHATSNEW
deleted file mode 100644
index 6e82e1dae0..0000000000
--- a/regex/WHATSNEW
+++ /dev/null
@@ -1,92 +0,0 @@
-New in alpha3.4: The complex bug alluded to below has been fixed (in a
-slightly kludgey temporary way that may hurt efficiency a bit; this is
-another "get it out the door for 4.4" release). The tests at the end of
-the tests file have accordingly been uncommented. The primary sign of
-the bug was that something like a?b matching ab matched b rather than ab.
-(The bug was essentially specific to this exact situation, else it would
-have shown up earlier.)
-
-New in alpha3.3: The definition of word boundaries has been altered
-slightly, to more closely match the usual programming notion that "_"
-is an alphabetic. Stuff used for pre-ANSI systems is now in a subdir,
-and the makefile no longer alludes to it in mysterious ways. The
-makefile has generally been cleaned up some. Fixes have been made
-(again!) so that the regression test will run without -DREDEBUG, at
-the cost of weaker checking. A workaround for a bug in some folks'
-<assert.h> has been added. And some more things have been added to
-tests, including a couple right at the end which are commented out
-because the code currently flunks them (complex bug; fix coming).
-Plus the usual minor cleanup.
-
-New in alpha3.2: Assorted bits of cleanup and portability improvement
-(the development base is now a BSDI system using GCC instead of an ancient
-Sun system, and the newer compiler exposed some glitches). Fix for a
-serious bug that affected REs using many [] (including REG_ICASE REs
-because of the way they are implemented), *sometimes*, depending on
-memory-allocation patterns. The header-file prototypes no longer name
-the parameters, avoiding possible name conflicts. The possibility that
-some clot has defined CHAR_MIN as (say) `-128' instead of `(-128)' is
-now handled gracefully. "uchar" is no longer used as an internal type
-name (too many people have the same idea). Still the same old lousy
-performance, alas.
-
-New in alpha3.1: Basically nothing, this release is just a bookkeeping
-convenience. Stay tuned.
-
-New in alpha3.0: Performance is no better, alas, but some fixes have been
-made and some functionality has been added. (This is basically the "get
-it out the door in time for 4.4" release.) One bug fix: regfree() didn't
-free the main internal structure (how embarrassing). It is now possible
-to put NULs in either the RE or the target string, using (resp.) a new
-REG_PEND flag and the old REG_STARTEND flag. The REG_NOSPEC flag to
-regcomp() makes all characters ordinary, so you can match a literal
-string easily (this will become more useful when performance improves!).
-There are now primitives to match beginnings and ends of words, although
-the syntax is disgusting and so is the implementation. The REG_ATOI
-debugging interface has changed a bit. And there has been considerable
-internal cleanup of various kinds.
-
-New in alpha2.3: Split change list out of README, and moved flags notes
-into Makefile. Macro-ized the name of regex(7) in regex(3), since it has
-to change for 4.4BSD. Cleanup work in engine.c, and some new regression
-tests to catch tricky cases thereof.
-
-New in alpha2.2: Out-of-date manpages updated. Regerror() acquires two
-small extensions -- REG_ITOA and REG_ATOI -- which avoid debugging kludges
-in my own test program and might be useful to others for similar purposes.
-The regression test will now compile (and run) without REDEBUG. The
-BRE \$ bug is fixed. Most uses of "uchar" are gone; it's all chars now.
-Char/uchar parameters are now written int/unsigned, to avoid possible
-portability problems with unpromoted parameters. Some unsigned casts have
-been introduced to minimize portability problems with shifting into sign
-bits.
-
-New in alpha2.1: Lots of little stuff, cleanup and fixes. The one big
-thing is that regex.h is now generated, using mkh, rather than being
-supplied in the distribution; due to circularities in dependencies,
-you have to build regex.h explicitly by "make h". The two known bugs
-have been fixed (and the regression test now checks for them), as has a
-problem with assertions not being suppressed in the absence of REDEBUG.
-No performance work yet.
-
-New in alpha2: Backslash-anything is an ordinary character, not an
-error (except, of course, for the handful of backslashed metacharacters
-in BREs), which should reduce script breakage. The regression test
-checks *where* null strings are supposed to match, and has generally
-been tightened up somewhat. Small bug fixes in parameter passing (not
-harmful, but technically errors) and some other areas. Debugging
-invoked by defining REDEBUG rather than not defining NDEBUG.
-
-New in alpha+3: full prototyping for internal routines, using a little
-helper program, mkh, which extracts prototypes given in stylized comments.
-More minor cleanup. Buglet fix: it's CHAR_BIT, not CHAR_BITS. Simple
-pre-screening of input when a literal string is known to be part of the
-RE; this does wonders for performance.
-
-New in alpha+2: minor bits of cleanup. Notably, the number "32" for the
-word width isn't hardwired into regexec.c any more, the public header
-file prototypes the functions if __STDC__ is defined, and some small typos
-in the manpages have been fixed.
-
-New in alpha+1: improvements to the manual pages, and an important
-extension, the REG_STARTEND option to regexec().
diff --git a/regex/cclass.h b/regex/cclass.h
deleted file mode 100644
index 727cbb9255..0000000000
--- a/regex/cclass.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* character-class table */
-static struct cclass {
- char *name;
- char *chars;
- char *multis;
-} cclasses[] = {
- { "alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
-0123456789", "" },
- { "alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
- "" },
- { "blank", " \t", "" },
- { "cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\
-\25\26\27\30\31\32\33\34\35\36\37\177", "" },
- { "digit", "0123456789", "" },
- { "graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
-0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
- "" },
- { "lower", "abcdefghijklmnopqrstuvwxyz",
- "" },
- { "print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
-0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ",
- "" },
- { "punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
- "" },
- { "space", "\t\n\v\f\r ", "" },
- { "upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
- "" },
- { "xdigit", "0123456789ABCDEFabcdef",
- "" },
- { NULL, 0, "" }
-};
diff --git a/regex/cname.h b/regex/cname.h
deleted file mode 100644
index ff116e55e2..0000000000
--- a/regex/cname.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* character-name table */
-static struct cname {
- char *name;
- char code;
-} cnames[] = {
- { "NUL", '\0' },
- { "SOH", '\001' },
- { "STX", '\002' },
- { "ETX", '\003' },
- { "EOT", '\004' },
- { "ENQ", '\005' },
- { "ACK", '\006' },
- { "BEL", '\007' },
- { "alert", '\007' },
- { "BS", '\010' },
- { "backspace", '\b' },
- { "HT", '\011' },
- { "tab", '\t' },
- { "LF", '\012' },
- { "newline", '\n' },
- { "VT", '\013' },
- { "vertical-tab", '\v' },
- { "FF", '\014' },
- { "form-feed", '\f' },
- { "CR", '\015' },
- { "carriage-return", '\r' },
- { "SO", '\016' },
- { "SI", '\017' },
- { "DLE", '\020' },
- { "DC1", '\021' },
- { "DC2", '\022' },
- { "DC3", '\023' },
- { "DC4", '\024' },
- { "NAK", '\025' },
- { "SYN", '\026' },
- { "ETB", '\027' },
- { "CAN", '\030' },
- { "EM", '\031' },
- { "SUB", '\032' },
- { "ESC", '\033' },
- { "IS4", '\034' },
- { "FS", '\034' },
- { "IS3", '\035' },
- { "GS", '\035' },
- { "IS2", '\036' },
- { "RS", '\036' },
- { "IS1", '\037' },
- { "US", '\037' },
- { "space", ' ' },
- { "exclamation-mark", '!' },
- { "quotation-mark", '"' },
- { "number-sign", '#' },
- { "dollar-sign", '$' },
- { "percent-sign", '%' },
- { "ampersand", '&' },
- { "apostrophe", '\'' },
- { "left-parenthesis", '(' },
- { "right-parenthesis", ')' },
- { "asterisk", '*' },
- { "plus-sign", '+' },
- { "comma", ',' },
- { "hyphen", '-' },
- { "hyphen-minus", '-' },
- { "period", '.' },
- { "full-stop", '.' },
- { "slash", '/' },
- { "solidus", '/' },
- { "zero", '0' },
- { "one", '1' },
- { "two", '2' },
- { "three", '3' },
- { "four", '4' },
- { "five", '5' },
- { "six", '6' },
- { "seven", '7' },
- { "eight", '8' },
- { "nine", '9' },
- { "colon", ':' },
- { "semicolon", ';' },
- { "less-than-sign", '<' },
- { "equals-sign", '=' },
- { "greater-than-sign", '>' },
- { "question-mark", '?' },
- { "commercial-at", '@' },
- { "left-square-bracket", '[' },
- { "backslash", '\\' },
- { "reverse-solidus", '\\' },
- { "right-square-bracket", ']' },
- { "circumflex", '^' },
- { "circumflex-accent", '^' },
- { "underscore", '_' },
- { "low-line", '_' },
- { "grave-accent", '`' },
- { "left-brace", '{' },
- { "left-curly-bracket", '{' },
- { "vertical-line", '|' },
- { "right-brace", '}' },
- { "right-curly-bracket", '}' },
- { "tilde", '~' },
- { "DEL", '\177' },
- { NULL, 0 }
-};
diff --git a/regex/debug.c b/regex/debug.c
deleted file mode 100644
index c0feaeb169..0000000000
--- a/regex/debug.c
+++ /dev/null
@@ -1,242 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <regex.h>
-
-#include "utils.h"
-#include "regex2.h"
-#include "debug.ih"
-
-/*
- - regprint - print a regexp for debugging
- == void regprint(regex_t *r, FILE *d);
- */
-void
-regprint(r, d)
-regex_t *r;
-FILE *d;
-{
- register struct re_guts *g = r->re_g;
- register int i;
- register int c;
- register int last;
- int nincat[NC];
-
- fprintf(d, "%ld states, %d categories", (long)g->nstates,
- g->ncategories);
- fprintf(d, ", first %ld last %ld", (long)g->firststate,
- (long)g->laststate);
- if (g->iflags&USEBOL)
- fprintf(d, ", USEBOL");
- if (g->iflags&USEEOL)
- fprintf(d, ", USEEOL");
- if (g->iflags&BAD)
- fprintf(d, ", BAD");
- if (g->nsub > 0)
- fprintf(d, ", nsub=%ld", (long)g->nsub);
- if (g->must != NULL)
- fprintf(d, ", must(%ld) `%*s'", (long)g->mlen, (int)g->mlen,
- g->must);
- if (g->backrefs)
- fprintf(d, ", backrefs");
- if (g->nplus > 0)
- fprintf(d, ", nplus %ld", (long)g->nplus);
- fprintf(d, "\n");
- s_print(g, d);
- for (i = 0; i < g->ncategories; i++) {
- nincat[i] = 0;
- for (c = CHAR_MIN; c <= CHAR_MAX; c++)
- if (g->categories[c] == i)
- nincat[i]++;
- }
- fprintf(d, "cc0#%d", nincat[0]);
- for (i = 1; i < g->ncategories; i++)
- if (nincat[i] == 1) {
- for (c = CHAR_MIN; c <= CHAR_MAX; c++)
- if (g->categories[c] == i)
- break;
- fprintf(d, ", %d=%s", i, regchar(c));
- }
- fprintf(d, "\n");
- for (i = 1; i < g->ncategories; i++)
- if (nincat[i] != 1) {
- fprintf(d, "cc%d\t", i);
- last = -1;
- for (c = CHAR_MIN; c <= CHAR_MAX+1; c++) /* +1 does flush */
- if (c <= CHAR_MAX && g->categories[c] == i) {
- if (last < 0) {
- fprintf(d, "%s", regchar(c));
- last = c;
- }
- } else {
- if (last >= 0) {
- if (last != c-1)
- fprintf(d, "-%s",
- regchar(c-1));
- last = -1;
- }
- }
- fprintf(d, "\n");
- }
-}
-
-/*
- - s_print - print the strip for debugging
- == static void s_print(register struct re_guts *g, FILE *d);
- */
-static void
-s_print(g, d)
-register struct re_guts *g;
-FILE *d;
-{
- register sop *s;
- register cset *cs;
- register int i;
- register int done = 0;
- register sop opnd;
- register int col = 0;
- register int last;
- register sopno offset = 2;
-# define GAP() { if (offset % 5 == 0) { \
- if (col > 40) { \
- fprintf(d, "\n\t"); \
- col = 0; \
- } else { \
- fprintf(d, " "); \
- col++; \
- } \
- } else \
- col++; \
- offset++; \
- }
-
- if (OP(g->strip[0]) != OEND)
- fprintf(d, "missing initial OEND!\n");
- for (s = &g->strip[1]; !done; s++) {
- opnd = OPND(*s);
- switch (OP(*s)) {
- case OEND:
- fprintf(d, "\n");
- done = 1;
- break;
- case OCHAR:
- if (strchr("\\|()^$.[+*?{}!<> ", (char)opnd) != NULL)
- fprintf(d, "\\%c", (char)opnd);
- else
- fprintf(d, "%s", regchar((char)opnd));
- break;
- case OBOL:
- fprintf(d, "^");
- break;
- case OEOL:
- fprintf(d, "$");
- break;
- case OBOW:
- fprintf(d, "\\{");
- break;
- case OEOW:
- fprintf(d, "\\}");
- break;
- case OANY:
- fprintf(d, ".");
- break;
- case OANYOF:
- fprintf(d, "[(%ld)", (long)opnd);
- cs = &g->sets[opnd];
- last = -1;
- for (i = 0; i < g->csetsize+1; i++) /* +1 flushes */
- if (CHIN(cs, i) && i < g->csetsize) {
- if (last < 0) {
- fprintf(d, "%s", regchar(i));
- last = i;
- }
- } else {
- if (last >= 0) {
- if (last != i-1)
- fprintf(d, "-%s",
- regchar(i-1));
- last = -1;
- }
- }
- fprintf(d, "]");
- break;
- case OBACK_:
- fprintf(d, "(\\<%ld>", (long)opnd);
- break;
- case O_BACK:
- fprintf(d, "<%ld>\\)", (long)opnd);
- break;
- case OPLUS_:
- fprintf(d, "(+");
- if (OP(*(s+opnd)) != O_PLUS)
- fprintf(d, "<%ld>", (long)opnd);
- break;
- case O_PLUS:
- if (OP(*(s-opnd)) != OPLUS_)
- fprintf(d, "<%ld>", (long)opnd);
- fprintf(d, "+)");
- break;
- case OQUEST_:
- fprintf(d, "(?");
- if (OP(*(s+opnd)) != O_QUEST)
- fprintf(d, "<%ld>", (long)opnd);
- break;
- case O_QUEST:
- if (OP(*(s-opnd)) != OQUEST_)
- fprintf(d, "<%ld>", (long)opnd);
- fprintf(d, "?)");
- break;
- case OLPAREN:
- fprintf(d, "((<%ld>", (long)opnd);
- break;
- case ORPAREN:
- fprintf(d, "<%ld>))", (long)opnd);
- break;
- case OCH_:
- fprintf(d, "<");
- if (OP(*(s+opnd)) != OOR2)
- fprintf(d, "<%ld>", (long)opnd);
- break;
- case OOR1:
- if (OP(*(s-opnd)) != OOR1 && OP(*(s-opnd)) != OCH_)
- fprintf(d, "<%ld>", (long)opnd);
- fprintf(d, "|");
- break;
- case OOR2:
- fprintf(d, "|");
- if (OP(*(s+opnd)) != OOR2 && OP(*(s+opnd)) != O_CH)
- fprintf(d, "<%ld>", (long)opnd);
- break;
- case O_CH:
- if (OP(*(s-opnd)) != OOR1)
- fprintf(d, "<%ld>", (long)opnd);
- fprintf(d, ">");
- break;
- default:
- fprintf(d, "!%ld(%ld)!", OP(*s), opnd);
- break;
- }
- if (!done)
- GAP();
- }
-}
-
-/*
- - regchar - make a character printable
- == static char *regchar(int ch);
- */
-static char * /* -> representation */
-regchar(ch)
-int ch;
-{
- static char buf[10];
-
- if (isprint(ch) || ch == ' ')
- sprintf(buf, "%c", ch);
- else
- sprintf(buf, "\\%o", ch);
- return(buf);
-}
diff --git a/regex/debug.ih b/regex/debug.ih
deleted file mode 100644
index 5f40ff7917..0000000000
--- a/regex/debug.ih
+++ /dev/null
@@ -1,14 +0,0 @@
-/* ========= begin header generated by ./mkh ========= */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* === debug.c === */
-void regprint(regex_t *r, FILE *d);
-static void s_print(register struct re_guts *g, FILE *d);
-static char *regchar(int ch);
-
-#ifdef __cplusplus
-}
-#endif
-/* ========= end header generated by ./mkh ========= */
diff --git a/regex/engine.c b/regex/engine.c
deleted file mode 100644
index 696774e1b3..0000000000
--- a/regex/engine.c
+++ /dev/null
@@ -1,1019 +0,0 @@
-/*
- * The matching engine and friends. This file is #included by regexec.c
- * after suitable #defines of a variety of macros used herein, so that
- * different state representations can be used without duplicating masses
- * of code.
- */
-
-#ifdef SNAMES
-#define matcher smatcher
-#define fast sfast
-#define slow sslow
-#define dissect sdissect
-#define backref sbackref
-#define step sstep
-#define print sprint
-#define at sat
-#define match smat
-#endif
-#ifdef LNAMES
-#define matcher lmatcher
-#define fast lfast
-#define slow lslow
-#define dissect ldissect
-#define backref lbackref
-#define step lstep
-#define print lprint
-#define at lat
-#define match lmat
-#endif
-
-/* another structure passed up and down to avoid zillions of parameters */
-struct match {
- struct re_guts *g;
- int eflags;
- regmatch_t *pmatch; /* [nsub+1] (0 element unused) */
- char *offp; /* offsets work from here */
- char *beginp; /* start of string -- virtual NUL precedes */
- char *endp; /* end of string -- virtual NUL here */
- char *coldp; /* can be no match starting before here */
- char **lastpos; /* [nplus+1] */
- STATEVARS;
- states st; /* current states */
- states fresh; /* states for a fresh start */
- states tmp; /* temporary */
- states empty; /* empty set of states */
-};
-
-#include "engine.ih"
-
-#ifdef REDEBUG
-#define SP(t, s, c) print(m, t, s, c, stdout)
-#define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2)
-#define NOTE(str) { if (m->eflags&REG_TRACE) printf("=%s\n", (str)); }
-#else
-#define SP(t, s, c) /* nothing */
-#define AT(t, p1, p2, s1, s2) /* nothing */
-#define NOTE(s) /* nothing */
-#endif
-
-/*
- - matcher - the actual matching engine
- == static int matcher(register struct re_guts *g, char *string, \
- == size_t nmatch, regmatch_t pmatch[], int eflags);
- */
-static int /* 0 success, REG_NOMATCH failure */
-matcher(g, string, nmatch, pmatch, eflags)
-register struct re_guts *g;
-char *string;
-size_t nmatch;
-regmatch_t pmatch[];
-int eflags;
-{
- register char *endp;
- register unsigned int i;
- struct match mv;
- register struct match *m = &mv;
- register char *dp;
- register const sopno gf = g->firststate+1; /* +1 for OEND */
- register const sopno gl = g->laststate;
- char *start;
- char *stop;
-
- /* simplify the situation where possible */
- if (g->cflags&REG_NOSUB)
- nmatch = 0;
- if (eflags&REG_STARTEND) {
- start = string + pmatch[0].rm_so;
- stop = string + pmatch[0].rm_eo;
- } else {
- start = string;
- stop = start + strlen(start);
- }
- if (stop < start)
- return(REG_INVARG);
-
- /* prescreening; this does wonders for this rather slow code */
- if (g->must != NULL) {
- for (dp = start; dp < stop; dp++)
- if (*dp == g->must[0] && stop - dp >= g->mlen &&
- memcmp(dp, g->must, (size_t)g->mlen) == 0)
- break;
- if (dp == stop) /* we didn't find g->must */
- return(REG_NOMATCH);
- }
-
- /* match struct setup */
- m->g = g;
- m->eflags = eflags;
- m->pmatch = NULL;
- m->lastpos = NULL;
- m->offp = string;
- m->beginp = start;
- m->endp = stop;
- STATESETUP(m, 4);
- SETUP(m->st);
- SETUP(m->fresh);
- SETUP(m->tmp);
- SETUP(m->empty);
- CLEAR(m->empty);
-
- /* this loop does only one repetition except for backrefs */
- for (;;) {
- endp = fast(m, start, stop, gf, gl);
- if (endp == NULL) { /* a miss */
- STATETEARDOWN(m);
- return(REG_NOMATCH);
- }
- if (nmatch == 0 && !g->backrefs)
- break; /* no further info needed */
-
- /* where? */
- assert(m->coldp != NULL);
- for (;;) {
- NOTE("finding start");
- endp = slow(m, m->coldp, stop, gf, gl);
- if (endp != NULL)
- break;
- assert(m->coldp < m->endp);
- m->coldp++;
- }
- if (nmatch == 1 && !g->backrefs)
- break; /* no further info needed */
-
- /* oh my, he wants the subexpressions... */
- if (m->pmatch == NULL)
- m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) *
- sizeof(regmatch_t));
- if (m->pmatch == NULL) {
- STATETEARDOWN(m);
- return(REG_ESPACE);
- }
- for (i = 1; i <= m->g->nsub; i++)
- m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1;
- if (!g->backrefs && !(m->eflags&REG_BACKR)) {
- NOTE("dissecting");
- dp = dissect(m, m->coldp, endp, gf, gl);
- } else {
- if (g->nplus > 0 && m->lastpos == NULL)
- m->lastpos = (char **)malloc((g->nplus+1) *
- sizeof(char *));
- if (g->nplus > 0 && m->lastpos == NULL) {
- free(m->pmatch);
- STATETEARDOWN(m);
- return(REG_ESPACE);
- }
- NOTE("backref dissect");
- dp = backref(m, m->coldp, endp, gf, gl, (sopno)0);
- }
- if (dp != NULL)
- break;
-
- /* uh-oh... we couldn't find a subexpression-level match */
- assert(g->backrefs); /* must be back references doing it */
- assert(g->nplus == 0 || m->lastpos != NULL);
- for (;;) {
- if (dp != NULL || endp <= m->coldp)
- break; /* defeat */
- NOTE("backoff");
- endp = slow(m, m->coldp, endp-1, gf, gl);
- if (endp == NULL)
- break; /* defeat */
- /* try it on a shorter possibility */
-#ifndef NDEBUG
- for (i = 1; i <= m->g->nsub; i++) {
- assert(m->pmatch[i].rm_so == -1);
- assert(m->pmatch[i].rm_eo == -1);
- }
-#endif
- NOTE("backoff dissect");
- dp = backref(m, m->coldp, endp, gf, gl, (sopno)0);
- }
- assert(dp == NULL || dp == endp);
- if (dp != NULL) /* found a shorter one */
- break;
-
- /* despite initial appearances, there is no match here */
- NOTE("false alarm");
- start = m->coldp + 1; /* recycle starting later */
- assert(start <= stop);
- }
-
- /* fill in the details if requested */
- if (nmatch > 0) {
- pmatch[0].rm_so = m->coldp - m->offp;
- pmatch[0].rm_eo = endp - m->offp;
- }
- if (nmatch > 1) {
- assert(m->pmatch != NULL);
- for (i = 1; i < nmatch; i++)
- if (i <= m->g->nsub)
- pmatch[i] = m->pmatch[i];
- else {
- pmatch[i].rm_so = -1;
- pmatch[i].rm_eo = -1;
- }
- }
-
- if (m->pmatch != NULL)
- free((char *)m->pmatch);
- if (m->lastpos != NULL)
- free((char *)m->lastpos);
- STATETEARDOWN(m);
- return(0);
-}
-
-/*
- - dissect - figure out what matched what, no back references
- == static char *dissect(register struct match *m, char *start, \
- == char *stop, sopno startst, sopno stopst);
- */
-static char * /* == stop (success) always */
-dissect(m, start, stop, startst, stopst)
-register struct match *m;
-char *start;
-char *stop;
-sopno startst;
-sopno stopst;
-{
- register int i;
- register sopno ss; /* start sop of current subRE */
- register sopno es; /* end sop of current subRE */
- register char *sp; /* start of string matched by it */
- register char *stp; /* string matched by it cannot pass here */
- register char *rest; /* start of rest of string */
- register char *tail; /* string unmatched by rest of RE */
- register sopno ssub; /* start sop of subsubRE */
- register sopno esub; /* end sop of subsubRE */
- register char *ssp; /* start of string matched by subsubRE */
- register char *sep; /* end of string matched by subsubRE */
- register char *oldssp; /* previous ssp */
- register char *dp;
-
- AT("diss", start, stop, startst, stopst);
- sp = start;
- for (ss = startst; ss < stopst; ss = es) {
- /* identify end of subRE */
- es = ss;
- switch (OP(m->g->strip[es])) {
- case OPLUS_:
- case OQUEST_:
- es += OPND(m->g->strip[es]);
- break;
- case OCH_:
- while (OP(m->g->strip[es]) != O_CH)
- es += OPND(m->g->strip[es]);
- break;
- }
- es++;
-
- /* figure out what it matched */
- switch (OP(m->g->strip[ss])) {
- case OEND:
- assert(nope);
- break;
- case OCHAR:
- sp++;
- break;
- case OBOL:
- case OEOL:
- case OBOW:
- case OEOW:
- break;
- case OANY:
- case OANYOF:
- sp++;
- break;
- case OBACK_:
- case O_BACK:
- assert(nope);
- break;
- /* cases where length of match is hard to find */
- case OQUEST_:
- stp = stop;
- for (;;) {
- /* how long could this one be? */
- rest = slow(m, sp, stp, ss, es);
- assert(rest != NULL); /* it did match */
- /* could the rest match the rest? */
- tail = slow(m, rest, stop, es, stopst);
- if (tail == stop)
- break; /* yes! */
- /* no -- try a shorter match for this one */
- stp = rest - 1;
- assert(stp >= sp); /* it did work */
- }
- ssub = ss + 1;
- esub = es - 1;
- /* did innards match? */
- if (slow(m, sp, rest, ssub, esub) != NULL) {
- dp = dissect(m, sp, rest, ssub, esub);
- assert(dp == rest);
- } else /* no */
- assert(sp == rest);
- sp = rest;
- break;
- case OPLUS_:
- stp = stop;
- for (;;) {
- /* how long could this one be? */
- rest = slow(m, sp, stp, ss, es);
- assert(rest != NULL); /* it did match */
- /* could the rest match the rest? */
- tail = slow(m, rest, stop, es, stopst);
- if (tail == stop)
- break; /* yes! */
- /* no -- try a shorter match for this one */
- stp = rest - 1;
- assert(stp >= sp); /* it did work */
- }
- ssub = ss + 1;
- esub = es - 1;
- ssp = sp;
- oldssp = ssp;
- for (;;) { /* find last match of innards */
- sep = slow(m, ssp, rest, ssub, esub);
- if (sep == NULL || sep == ssp)
- break; /* failed or matched null */
- oldssp = ssp; /* on to next try */
- ssp = sep;
- }
- if (sep == NULL) {
- /* last successful match */
- sep = ssp;
- ssp = oldssp;
- }
- assert(sep == rest); /* must exhaust substring */
- assert(slow(m, ssp, sep, ssub, esub) == rest);
- dp = dissect(m, ssp, sep, ssub, esub);
- assert(dp == sep);
- sp = rest;
- break;
- case OCH_:
- stp = stop;
- for (;;) {
- /* how long could this one be? */
- rest = slow(m, sp, stp, ss, es);
- assert(rest != NULL); /* it did match */
- /* could the rest match the rest? */
- tail = slow(m, rest, stop, es, stopst);
- if (tail == stop)
- break; /* yes! */
- /* no -- try a shorter match for this one */
- stp = rest - 1;
- assert(stp >= sp); /* it did work */
- }
- ssub = ss + 1;
- esub = ss + OPND(m->g->strip[ss]) - 1;
- assert(OP(m->g->strip[esub]) == OOR1);
- for (;;) { /* find first matching branch */
- if (slow(m, sp, rest, ssub, esub) == rest)
- break; /* it matched all of it */
- /* that one missed, try next one */
- assert(OP(m->g->strip[esub]) == OOR1);
- esub++;
- assert(OP(m->g->strip[esub]) == OOR2);
- ssub = esub + 1;
- esub += OPND(m->g->strip[esub]);
- if (OP(m->g->strip[esub]) == OOR2)
- esub--;
- else
- assert(OP(m->g->strip[esub]) == O_CH);
- }
- dp = dissect(m, sp, rest, ssub, esub);
- assert(dp == rest);
- sp = rest;
- break;
- case O_PLUS:
- case O_QUEST:
- case OOR1:
- case OOR2:
- case O_CH:
- assert(nope);
- break;
- case OLPAREN:
- i = OPND(m->g->strip[ss]);
- assert(0 < i && i <= m->g->nsub);
- m->pmatch[i].rm_so = sp - m->offp;
- break;
- case ORPAREN:
- i = OPND(m->g->strip[ss]);
- assert(0 < i && i <= m->g->nsub);
- m->pmatch[i].rm_eo = sp - m->offp;
- break;
- default: /* uh oh */
- assert(nope);
- break;
- }
- }
-
- assert(sp == stop);
- return(sp);
-}
-
-/*
- - backref - figure out what matched what, figuring in back references
- == static char *backref(register struct match *m, char *start, \
- == char *stop, sopno startst, sopno stopst, sopno lev);
- */
-static char * /* == stop (success) or NULL (failure) */
-backref(m, start, stop, startst, stopst, lev)
-register struct match *m;
-char *start;
-char *stop;
-sopno startst;
-sopno stopst;
-sopno lev; /* PLUS nesting level */
-{
- register int i;
- register sopno ss; /* start sop of current subRE */
- register char *sp; /* start of string matched by it */
- register sopno ssub; /* start sop of subsubRE */
- register sopno esub; /* end sop of subsubRE */
- register char *ssp; /* start of string matched by subsubRE */
- register char *dp;
- register size_t len;
- register int hard;
- register sop s;
- register regoff_t offsave;
- register cset *cs;
-
- AT("back", start, stop, startst, stopst);
- sp = start;
-
- /* get as far as we can with easy stuff */
- hard = 0;
- for (ss = startst; !hard && ss < stopst; ss++)
- switch (OP(s = m->g->strip[ss])) {
- case OCHAR:
- if (sp == stop || *sp++ != (char)OPND(s))
- return(NULL);
- break;
- case OANY:
- if (sp == stop)
- return(NULL);
- sp++;
- break;
- case OANYOF:
- cs = &m->g->sets[OPND(s)];
- if (sp == stop || !CHIN(cs, *sp++))
- return(NULL);
- break;
- case OBOL:
- if ( (sp == m->beginp && !(m->eflags&REG_NOTBOL)) ||
- (sp < m->endp && *(sp-1) == '\n' &&
- (m->g->cflags&REG_NEWLINE)) )
- { /* yes */ }
- else
- return(NULL);
- break;
- case OEOL:
- if ( (sp == m->endp && !(m->eflags&REG_NOTEOL)) ||
- (sp < m->endp && *sp == '\n' &&
- (m->g->cflags&REG_NEWLINE)) )
- { /* yes */ }
- else
- return(NULL);
- break;
- case OBOW:
- if (( (sp == m->beginp && !(m->eflags&REG_NOTBOL)) ||
- (sp < m->endp && *(sp-1) == '\n' &&
- (m->g->cflags&REG_NEWLINE)) ||
- (sp > m->beginp &&
- !ISWORD(*(sp-1))) ) &&
- (sp < m->endp && ISWORD(*sp)) )
- { /* yes */ }
- else
- return(NULL);
- break;
- case OEOW:
- if (( (sp == m->endp && !(m->eflags&REG_NOTEOL)) ||
- (sp < m->endp && *sp == '\n' &&
- (m->g->cflags&REG_NEWLINE)) ||
- (sp < m->endp && !ISWORD(*sp)) ) &&
- (sp > m->beginp && ISWORD(*(sp-1))) )
- { /* yes */ }
- else
- return(NULL);
- break;
- case O_QUEST:
- break;
- case OOR1: /* matches null but needs to skip */
- ss++;
- s = m->g->strip[ss];
- do {
- assert(OP(s) == OOR2);
- ss += OPND(s);
- } while (OP(s = m->g->strip[ss]) != O_CH);
- /* note that the ss++ gets us past the O_CH */
- break;
- default: /* have to make a choice */
- hard = 1;
- break;
- }
- if (!hard) { /* that was it! */
- if (sp != stop)
- return(NULL);
- return(sp);
- }
- ss--; /* adjust for the for's final increment */
-
- /* the hard stuff */
- AT("hard", sp, stop, ss, stopst);
- s = m->g->strip[ss];
- switch (OP(s)) {
- case OBACK_: /* the vilest depths */
- i = OPND(s);
- assert(0 < i && i <= m->g->nsub);
- if (m->pmatch[i].rm_eo == -1)
- return(NULL);
- assert(m->pmatch[i].rm_so != -1);
- len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so;
- assert(stop - m->beginp >= len);
- if (sp > stop - len)
- return(NULL); /* not enough left to match */
- ssp = m->offp + m->pmatch[i].rm_so;
- if (memcmp(sp, ssp, len) != 0)
- return(NULL);
- while (m->g->strip[ss] != SOP(O_BACK, i))
- ss++;
- return(backref(m, sp+len, stop, ss+1, stopst, lev));
- break;
- case OQUEST_: /* to null or not */
- dp = backref(m, sp, stop, ss+1, stopst, lev);
- if (dp != NULL)
- return(dp); /* not */
- return(backref(m, sp, stop, ss+OPND(s)+1, stopst, lev));
- break;
- case OPLUS_:
- assert(m->lastpos != NULL);
- assert(lev+1 <= m->g->nplus);
- m->lastpos[lev+1] = sp;
- return(backref(m, sp, stop, ss+1, stopst, lev+1));
- break;
- case O_PLUS:
- if (sp == m->lastpos[lev]) /* last pass matched null */
- return(backref(m, sp, stop, ss+1, stopst, lev-1));
- /* try another pass */
- m->lastpos[lev] = sp;
- dp = backref(m, sp, stop, ss-OPND(s)+1, stopst, lev);
- if (dp == NULL)
- return(backref(m, sp, stop, ss+1, stopst, lev-1));
- else
- return(dp);
- break;
- case OCH_: /* find the right one, if any */
- ssub = ss + 1;
- esub = ss + OPND(s) - 1;
- assert(OP(m->g->strip[esub]) == OOR1);
- for (;;) { /* find first matching branch */
- dp = backref(m, sp, stop, ssub, esub, lev);
- if (dp != NULL)
- return(dp);
- /* that one missed, try next one */
- if (OP(m->g->strip[esub]) == O_CH)
- return(NULL); /* there is none */
- esub++;
- assert(OP(m->g->strip[esub]) == OOR2);
- ssub = esub + 1;
- esub += OPND(m->g->strip[esub]);
- if (OP(m->g->strip[esub]) == OOR2)
- esub--;
- else
- assert(OP(m->g->strip[esub]) == O_CH);
- }
- break;
- case OLPAREN: /* must undo assignment if rest fails */
- i = OPND(s);
- assert(0 < i && i <= m->g->nsub);
- offsave = m->pmatch[i].rm_so;
- m->pmatch[i].rm_so = sp - m->offp;
- dp = backref(m, sp, stop, ss+1, stopst, lev);
- if (dp != NULL)
- return(dp);
- m->pmatch[i].rm_so = offsave;
- return(NULL);
- break;
- case ORPAREN: /* must undo assignment if rest fails */
- i = OPND(s);
- assert(0 < i && i <= m->g->nsub);
- offsave = m->pmatch[i].rm_eo;
- m->pmatch[i].rm_eo = sp - m->offp;
- dp = backref(m, sp, stop, ss+1, stopst, lev);
- if (dp != NULL)
- return(dp);
- m->pmatch[i].rm_eo = offsave;
- return(NULL);
- break;
- default: /* uh oh */
- assert(nope);
- break;
- }
-
- /* "can't happen" */
- assert(nope);
- /* NOTREACHED */
- return( NULL );
-}
-
-/*
- - fast - step through the string at top speed
- == static char *fast(register struct match *m, char *start, \
- == char *stop, sopno startst, sopno stopst);
- */
-static char * /* where tentative match ended, or NULL */
-fast(m, start, stop, startst, stopst)
-register struct match *m;
-char *start;
-char *stop;
-sopno startst;
-sopno stopst;
-{
- register states st = m->st;
- register states fresh = m->fresh;
- register states tmp = m->tmp;
- register char *p = start;
- register int c = (start == m->beginp) ? OUT : *(start-1);
- register int lastc; /* previous c */
- register int flagch;
- register int i;
- register char *coldp; /* last p after which no match was underway */
-
- CLEAR(st);
- SET1(st, startst);
- st = step(m->g, startst, stopst, st, NOTHING, st);
- ASSIGN(fresh, st);
- SP("start", st, *p);
- coldp = NULL;
- for (;;) {
- /* next character */
- lastc = c;
- c = (p == m->endp) ? OUT : *p;
- if (EQ(st, fresh))
- coldp = p;
-
- /* is there an EOL and/or BOL between lastc and c? */
- flagch = '\0';
- i = 0;
- if ( (lastc == '\n' && m->g->cflags&REG_NEWLINE) ||
- (lastc == OUT && !(m->eflags&REG_NOTBOL)) ) {
- flagch = BOL;
- i = m->g->nbol;
- }
- if ( (c == '\n' && m->g->cflags&REG_NEWLINE) ||
- (c == OUT && !(m->eflags&REG_NOTEOL)) ) {
- flagch = (flagch == BOL) ? BOLEOL : EOL;
- i += m->g->neol;
- }
- if (i != 0) {
- for (; i > 0; i--)
- st = step(m->g, startst, stopst, st, flagch, st);
- SP("boleol", st, c);
- }
-
- /* how about a word boundary? */
- if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) &&
- (c != OUT && ISWORD(c)) ) {
- flagch = BOW;
- }
- if ( (lastc != OUT && ISWORD(lastc)) &&
- (flagch == EOL || (c != OUT && !ISWORD(c))) ) {
- flagch = EOW;
- }
- if (flagch == BOW || flagch == EOW) {
- st = step(m->g, startst, stopst, st, flagch, st);
- SP("boweow", st, c);
- }
-
- /* are we done? */
- if (ISSET(st, stopst) || p == stop)
- break; /* NOTE BREAK OUT */
-
- /* no, we must deal with this character */
- ASSIGN(tmp, st);
- ASSIGN(st, fresh);
- assert(c != OUT);
- st = step(m->g, startst, stopst, tmp, c, st);
- SP("aft", st, c);
- assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st));
- p++;
- }
-
- assert(coldp != NULL);
- m->coldp = coldp;
- if (ISSET(st, stopst))
- return(p+1);
- else
- return(NULL);
-}
-
-/*
- - slow - step through the string more deliberately
- == static char *slow(register struct match *m, char *start, \
- == char *stop, sopno startst, sopno stopst);
- */
-static char * /* where it ended */
-slow(m, start, stop, startst, stopst)
-register struct match *m;
-char *start;
-char *stop;
-sopno startst;
-sopno stopst;
-{
- register states st = m->st;
- register states empty = m->empty;
- register states tmp = m->tmp;
- register char *p = start;
- register int c = (start == m->beginp) ? OUT : *(start-1);
- register int lastc; /* previous c */
- register int flagch;
- register int i;
- register char *matchp; /* last p at which a match ended */
-
- AT("slow", start, stop, startst, stopst);
- CLEAR(st);
- SET1(st, startst);
- SP("sstart", st, *p);
- st = step(m->g, startst, stopst, st, NOTHING, st);
- matchp = NULL;
- for (;;) {
- /* next character */
- lastc = c;
- c = (p == m->endp) ? OUT : *p;
-
- /* is there an EOL and/or BOL between lastc and c? */
- flagch = '\0';
- i = 0;
- if ( (lastc == '\n' && m->g->cflags&REG_NEWLINE) ||
- (lastc == OUT && !(m->eflags&REG_NOTBOL)) ) {
- flagch = BOL;
- i = m->g->nbol;
- }
- if ( (c == '\n' && m->g->cflags&REG_NEWLINE) ||
- (c == OUT && !(m->eflags&REG_NOTEOL)) ) {
- flagch = (flagch == BOL) ? BOLEOL : EOL;
- i += m->g->neol;
- }
- if (i != 0) {
- for (; i > 0; i--)
- st = step(m->g, startst, stopst, st, flagch, st);
- SP("sboleol", st, c);
- }
-
- /* how about a word boundary? */
- if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) &&
- (c != OUT && ISWORD(c)) ) {
- flagch = BOW;
- }
- if ( (lastc != OUT && ISWORD(lastc)) &&
- (flagch == EOL || (c != OUT && !ISWORD(c))) ) {
- flagch = EOW;
- }
- if (flagch == BOW || flagch == EOW) {
- st = step(m->g, startst, stopst, st, flagch, st);
- SP("sboweow", st, c);
- }
-
- /* are we done? */
- if (ISSET(st, stopst))
- matchp = p;
- if (EQ(st, empty) || p == stop)
- break; /* NOTE BREAK OUT */
-
- /* no, we must deal with this character */
- ASSIGN(tmp, st);
- ASSIGN(st, empty);
- assert(c != OUT);
- st = step(m->g, startst, stopst, tmp, c, st);
- SP("saft", st, c);
- assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st));
- p++;
- }
-
- return(matchp);
-}
-
-
-/*
- - step - map set of states reachable before char to set reachable after
- == static states step(register struct re_guts *g, sopno start, sopno stop, \
- == register states bef, int ch, register states aft);
- == #define BOL (OUT+1)
- == #define EOL (BOL+1)
- == #define BOLEOL (BOL+2)
- == #define NOTHING (BOL+3)
- == #define BOW (BOL+4)
- == #define EOW (BOL+5)
- == #define CODEMAX (BOL+5) // highest code used
- == #define NONCHAR(c) ((c) > CHAR_MAX)
- == #define NNONCHAR (CODEMAX-CHAR_MAX)
- */
-static states
-step(g, start, stop, bef, ch, aft)
-register struct re_guts *g;
-sopno start; /* start state within strip */
-sopno stop; /* state after stop state within strip */
-register states bef; /* states reachable before */
-int ch; /* character or NONCHAR code */
-register states aft; /* states already known reachable after */
-{
- register cset *cs;
- register sop s;
- register sopno pc;
- register onestate here; /* note, macros know this name */
- register sopno look;
- register int i;
-
- for (pc = start, INIT(here, pc); pc != stop; pc++, INC(here)) {
- s = g->strip[pc];
- switch (OP(s)) {
- case OEND:
- assert(pc == stop-1);
- break;
- case OCHAR:
- /* only characters can match */
- assert(!NONCHAR(ch) || ch != (char)OPND(s));
- if (ch == (char)OPND(s))
- FWD(aft, bef, 1);
- break;
- case OBOL:
- if (ch == BOL || ch == BOLEOL)
- FWD(aft, bef, 1);
- break;
- case OEOL:
- if (ch == EOL || ch == BOLEOL)
- FWD(aft, bef, 1);
- break;
- case OBOW:
- if (ch == BOW)
- FWD(aft, bef, 1);
- break;
- case OEOW:
- if (ch == EOW)
- FWD(aft, bef, 1);
- break;
- case OANY:
- if (!NONCHAR(ch))
- FWD(aft, bef, 1);
- break;
- case OANYOF:
- cs = &g->sets[OPND(s)];
- if (!NONCHAR(ch) && CHIN(cs, ch))
- FWD(aft, bef, 1);
- break;
- case OBACK_: /* ignored here */
- case O_BACK:
- FWD(aft, aft, 1);
- break;
- case OPLUS_: /* forward, this is just an empty */
- FWD(aft, aft, 1);
- break;
- case O_PLUS: /* both forward and back */
- FWD(aft, aft, 1);
- i = ISSETBACK(aft, OPND(s));
- BACK(aft, aft, OPND(s));
- if (!i && ISSETBACK(aft, OPND(s))) {
- /* oho, must reconsider loop body */
- pc -= OPND(s) + 1;
- INIT(here, pc);
- }
- break;
- case OQUEST_: /* two branches, both forward */
- FWD(aft, aft, 1);
- FWD(aft, aft, OPND(s));
- break;
- case O_QUEST: /* just an empty */
- FWD(aft, aft, 1);
- break;
- case OLPAREN: /* not significant here */
- case ORPAREN:
- FWD(aft, aft, 1);
- break;
- case OCH_: /* mark the first two branches */
- FWD(aft, aft, 1);
- assert(OP(g->strip[pc+OPND(s)]) == OOR2);
- FWD(aft, aft, OPND(s));
- break;
- case OOR1: /* done a branch, find the O_CH */
- if (ISSTATEIN(aft, here)) {
- for (look = 1;
- OP(s = g->strip[pc+look]) != O_CH;
- look += OPND(s))
- assert(OP(s) == OOR2);
- FWD(aft, aft, look);
- }
- break;
- case OOR2: /* propagate OCH_'s marking */
- FWD(aft, aft, 1);
- if (OP(g->strip[pc+OPND(s)]) != O_CH) {
- assert(OP(g->strip[pc+OPND(s)]) == OOR2);
- FWD(aft, aft, OPND(s));
- }
- break;
- case O_CH: /* just empty */
- FWD(aft, aft, 1);
- break;
- default: /* ooooops... */
- assert(nope);
- break;
- }
- }
-
- return(aft);
-}
-
-#ifdef REDEBUG
-/*
- - print - print a set of states
- == #ifdef REDEBUG
- == static void print(struct match *m, char *caption, states st, \
- == int ch, FILE *d);
- == #endif
- */
-static void
-print(m, caption, st, ch, d)
-struct match *m;
-char *caption;
-states st;
-int ch;
-FILE *d;
-{
- register struct re_guts *g = m->g;
- register int i;
- register int first = 1;
-
- if (!(m->eflags&REG_TRACE))
- return;
-
- fprintf(d, "%s", caption);
- if (ch != '\0')
- fprintf(d, " %s", pchar(ch));
- for (i = 0; i < g->nstates; i++)
- if (ISSET(st, i)) {
- fprintf(d, "%s%d", (first) ? "\t" : ", ", i);
- first = 0;
- }
- fprintf(d, "\n");
-}
-
-/*
- - at - print current situation
- == #ifdef REDEBUG
- == static void at(struct match *m, char *title, char *start, char *stop, \
- == sopno startst, sopno stopst);
- == #endif
- */
-static void
-at(m, title, start, stop, startst, stopst)
-struct match *m;
-char *title;
-char *start;
-char *stop;
-sopno startst;
-sopno stopst;
-{
- if (!(m->eflags&REG_TRACE))
- return;
-
- printf("%s %s-", title, pchar(*start));
- printf("%s ", pchar(*stop));
- printf("%ld-%ld\n", (long)startst, (long)stopst);
-}
-
-#ifndef PCHARDONE
-#define PCHARDONE /* never again */
-/*
- - pchar - make a character printable
- == #ifdef REDEBUG
- == static char *pchar(int ch);
- == #endif
- *
- * Is this identical to regchar() over in debug.c? Well, yes. But a
- * duplicate here avoids having a debugging-capable regexec.o tied to
- * a matching debug.o, and this is convenient. It all disappears in
- * the non-debug compilation anyway, so it doesn't matter much.
- */
-static char * /* -> representation */
-pchar(ch)
-int ch;
-{
- static char pbuf[10];
-
- if (isprint(ch) || ch == ' ')
- sprintf(pbuf, "%c", ch);
- else
- sprintf(pbuf, "\\%o", ch);
- return(pbuf);
-}
-#endif
-#endif
-
-#undef matcher
-#undef fast
-#undef slow
-#undef dissect
-#undef backref
-#undef step
-#undef print
-#undef at
-#undef match
diff --git a/regex/engine.ih b/regex/engine.ih
deleted file mode 100644
index cc98334e75..0000000000
--- a/regex/engine.ih
+++ /dev/null
@@ -1,35 +0,0 @@
-/* ========= begin header generated by ./mkh ========= */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* === engine.c === */
-static int matcher(register struct re_guts *g, char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
-static char *dissect(register struct match *m, char *start, char *stop, sopno startst, sopno stopst);
-static char *backref(register struct match *m, char *start, char *stop, sopno startst, sopno stopst, sopno lev);
-static char *fast(register struct match *m, char *start, char *stop, sopno startst, sopno stopst);
-static char *slow(register struct match *m, char *start, char *stop, sopno startst, sopno stopst);
-static states step(register struct re_guts *g, sopno start, sopno stop, register states bef, int ch, register states aft);
-#define BOL (OUT+1)
-#define EOL (BOL+1)
-#define BOLEOL (BOL+2)
-#define NOTHING (BOL+3)
-#define BOW (BOL+4)
-#define EOW (BOL+5)
-#define CODEMAX (BOL+5) /* highest code used */
-#define NONCHAR(c) ((c) > CHAR_MAX)
-#define NNONCHAR (CODEMAX-CHAR_MAX)
-#ifdef REDEBUG
-static void print(struct match *m, char *caption, states st, int ch, FILE *d);
-#endif
-#ifdef REDEBUG
-static void at(struct match *m, char *title, char *start, char *stop, sopno startst, sopno stopst);
-#endif
-#ifdef REDEBUG
-static char *pchar(int ch);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-/* ========= end header generated by ./mkh ========= */
diff --git a/regex/main.c b/regex/main.c
deleted file mode 100644
index 657338a2c1..0000000000
--- a/regex/main.c
+++ /dev/null
@@ -1,510 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <regex.h>
-#include <assert.h>
-#include <stdlib.h>
-
-#include "main.ih"
-
-char *progname;
-int debug = 0;
-int line = 0;
-int status = 0;
-
-int copts = REG_EXTENDED;
-int eopts = 0;
-regoff_t startoff = 0;
-regoff_t endoff = 0;
-
-
-extern int split();
-extern void regprint();
-
-/*
- - main - do the simple case, hand off to regress() for regression
- */
-int main(argc, argv)
-int argc;
-char *argv[];
-{
- regex_t re;
-# define NS 10
- regmatch_t subs[NS];
- char erbuf[100];
- int err;
- size_t len;
- int c;
- int errflg = 0;
- register int i;
- extern int optind;
- extern char *optarg;
-
- progname = argv[0];
-
- while ((c = getopt(argc, argv, "c:e:S:E:x")) != EOF)
- switch (c) {
- case 'c': /* compile options */
- copts = options('c', optarg);
- break;
- case 'e': /* execute options */
- eopts = options('e', optarg);
- break;
- case 'S': /* start offset */
- startoff = (regoff_t)atoi(optarg);
- break;
- case 'E': /* end offset */
- endoff = (regoff_t)atoi(optarg);
- break;
- case 'x': /* Debugging. */
- debug++;
- break;
- case '?':
- default:
- errflg++;
- break;
- }
- if (errflg) {
- fprintf(stderr, "usage: %s ", progname);
- fprintf(stderr, "[-c copt][-C][-d] [re]\n");
- exit(2);
- }
-
- if (optind >= argc) {
- regress(stdin);
- exit(status);
- }
-
- err = regcomp(&re, argv[optind++], copts);
- if (err) {
- len = regerror(err, &re, erbuf, sizeof(erbuf));
- fprintf(stderr, "error %s, %d/%d `%s'\n",
- eprint(err), len, sizeof(erbuf), erbuf);
- exit(status);
- }
- regprint(&re, stdout);
-
- if (optind >= argc) {
- regfree(&re);
- exit(status);
- }
-
- if (eopts&REG_STARTEND) {
- subs[0].rm_so = startoff;
- subs[0].rm_eo = strlen(argv[optind]) - endoff;
- }
- err = regexec(&re, argv[optind], (size_t)NS, subs, eopts);
- if (err) {
- len = regerror(err, &re, erbuf, sizeof(erbuf));
- fprintf(stderr, "error %s, %d/%d `%s'\n",
- eprint(err), len, sizeof(erbuf), erbuf);
- exit(status);
- }
- if (!(copts&REG_NOSUB)) {
- len = (int)(subs[0].rm_eo - subs[0].rm_so);
- if (subs[0].rm_so != -1) {
- if (len != 0)
- printf("match `%.*s'\n", (int)len,
- argv[optind] + subs[0].rm_so);
- else
- printf("match `'@%.1s\n",
- argv[optind] + subs[0].rm_so);
- }
- for (i = 1; i < NS; i++)
- if (subs[i].rm_so != -1)
- printf("(%d) `%.*s'\n", i,
- (int)(subs[i].rm_eo - subs[i].rm_so),
- argv[optind] + subs[i].rm_so);
- }
- exit(status);
-}
-
-/*
- - regress - main loop of regression test
- == void regress(FILE *in);
- */
-void
-regress(in)
-FILE *in;
-{
- char inbuf[1000];
-# define MAXF 10
- char *f[MAXF];
- int nf;
- int i;
- char erbuf[100];
- size_t ne;
- char *badpat = "invalid regular expression";
-# define SHORT 10
- char *bpname = "REG_BADPAT";
- regex_t re;
-
- while (fgets(inbuf, sizeof(inbuf), in) != NULL) {
- line++;
- if (inbuf[0] == '#' || inbuf[0] == '\n')
- continue; /* NOTE CONTINUE */
- inbuf[strlen(inbuf)-1] = '\0'; /* get rid of stupid \n */
- if (debug)
- fprintf(stdout, "%d:\n", line);
- nf = split(inbuf, f, MAXF, "\t\t");
- if (nf < 3) {
- fprintf(stderr, "bad input, line %d\n", line);
- exit(1);
- }
- for (i = 0; i < nf; i++)
- if (strcmp(f[i], "\"\"") == 0)
- f[i] = "";
- if (nf <= 3)
- f[3] = NULL;
- if (nf <= 4)
- f[4] = NULL;
- try(f[0], f[1], f[2], f[3], f[4], options('c', f[1]));
- if (opt('&', f[1])) /* try with either type of RE */
- try(f[0], f[1], f[2], f[3], f[4],
- options('c', f[1]) &~ REG_EXTENDED);
- }
-
- ne = regerror(REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf));
- if (strcmp(erbuf, badpat) != 0 || ne != strlen(badpat)+1) {
- fprintf(stderr, "end: regerror() test gave `%s' not `%s'\n",
- erbuf, badpat);
- status = 1;
- }
- ne = regerror(REG_BADPAT, (regex_t *)NULL, erbuf, (size_t)SHORT);
- if (strncmp(erbuf, badpat, SHORT-1) != 0 || erbuf[SHORT-1] != '\0' ||
- ne != strlen(badpat)+1) {
- fprintf(stderr, "end: regerror() short test gave `%s' not `%.*s'\n",
- erbuf, SHORT-1, badpat);
- status = 1;
- }
- ne = regerror(REG_ITOA|REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf));
- if (strcmp(erbuf, bpname) != 0 || ne != strlen(bpname)+1) {
- fprintf(stderr, "end: regerror() ITOA test gave `%s' not `%s'\n",
- erbuf, bpname);
- status = 1;
- }
- re.re_endp = bpname;
- ne = regerror(REG_ATOI, &re, erbuf, sizeof(erbuf));
- if (atoi(erbuf) != (int)REG_BADPAT) {
- fprintf(stderr, "end: regerror() ATOI test gave `%s' not `%ld'\n",
- erbuf, (long)REG_BADPAT);
- status = 1;
- } else if (ne != strlen(erbuf)+1) {
- fprintf(stderr, "end: regerror() ATOI test len(`%s') = %ld\n",
- erbuf, (long)REG_BADPAT);
- status = 1;
- }
-}
-
-/*
- - try - try it, and report on problems
- == void try(char *f0, char *f1, char *f2, char *f3, char *f4, int opts);
- */
-void
-try(f0, f1, f2, f3, f4, opts)
-char *f0;
-char *f1;
-char *f2;
-char *f3;
-char *f4;
-int opts; /* may not match f1 */
-{
- regex_t re;
-# define NSUBS 10
- regmatch_t subs[NSUBS];
-# define NSHOULD 15
- char *should[NSHOULD];
- int nshould;
- char erbuf[100];
- int err;
- int len;
- char *type = (opts & REG_EXTENDED) ? "ERE" : "BRE";
- register int i;
- char *grump;
- char f0copy[1000];
- char f2copy[1000];
-
- strcpy(f0copy, f0);
- re.re_endp = (opts&REG_PEND) ? f0copy + strlen(f0copy) : NULL;
- fixstr(f0copy);
- err = regcomp(&re, f0copy, opts);
- if (err != 0 && (!opt('C', f1) || err != efind(f2))) {
- /* unexpected error or wrong error */
- len = regerror(err, &re, erbuf, sizeof(erbuf));
- fprintf(stderr, "%d: %s error %s, %d/%d `%s'\n",
- line, type, eprint(err), len,
- sizeof(erbuf), erbuf);
- status = 1;
- } else if (err == 0 && opt('C', f1)) {
- /* unexpected success */
- fprintf(stderr, "%d: %s should have given REG_%s\n",
- line, type, f2);
- status = 1;
- err = 1; /* so we won't try regexec */
- }
-
- if (err != 0) {
- regfree(&re);
- return;
- }
-
- strcpy(f2copy, f2);
- fixstr(f2copy);
-
- if (options('e', f1)&REG_STARTEND) {
- if (strchr(f2, '(') == NULL || strchr(f2, ')') == NULL)
- fprintf(stderr, "%d: bad STARTEND syntax\n", line);
- subs[0].rm_so = strchr(f2, '(') - f2 + 1;
- subs[0].rm_eo = strchr(f2, ')') - f2;
- }
- err = regexec(&re, f2copy, NSUBS, subs, options('e', f1));
-
- if (err != 0 && (f3 != NULL || err != REG_NOMATCH)) {
- /* unexpected error or wrong error */
- len = regerror(err, &re, erbuf, sizeof(erbuf));
- fprintf(stderr, "%d: %s exec error %s, %d/%d `%s'\n",
- line, type, eprint(err), len,
- sizeof(erbuf), erbuf);
- status = 1;
- } else if (err != 0) {
- /* nothing more to check */
- } else if (f3 == NULL) {
- /* unexpected success */
- fprintf(stderr, "%d: %s exec should have failed\n",
- line, type);
- status = 1;
- err = 1; /* just on principle */
- } else if (opts&REG_NOSUB) {
- /* nothing more to check */
- } else if ((grump = check(f2, subs[0], f3)) != NULL) {
- fprintf(stderr, "%d: %s %s\n", line, type, grump);
- status = 1;
- err = 1;
- }
-
- if (err != 0 || f4 == NULL) {
- regfree(&re);
- return;
- }
-
- for (i = 1; i < NSHOULD; i++)
- should[i] = NULL;
- nshould = split(f4, should+1, NSHOULD-1, ",");
- if (nshould == 0) {
- nshould = 1;
- should[1] = "";
- }
- for (i = 1; i < NSUBS; i++) {
- grump = check(f2, subs[i], should[i]);
- if (grump != NULL) {
- fprintf(stderr, "%d: %s $%d %s\n", line,
- type, i, grump);
- status = 1;
- err = 1;
- }
- }
-
- regfree(&re);
-}
-
-/*
- - options - pick options out of a regression-test string
- == int options(int type, char *s);
- */
-int
-options(type, s)
-int type; /* 'c' compile, 'e' exec */
-char *s;
-{
- register char *p;
- register int o = (type == 'c') ? copts : eopts;
- register char *legal = (type == 'c') ? "bisnmp" : "^$#tl";
-
- for (p = s; *p != '\0'; p++)
- if (strchr(legal, *p) != NULL)
- switch (*p) {
- case 'b':
- o &= ~REG_EXTENDED;
- break;
- case 'i':
- o |= REG_ICASE;
- break;
- case 's':
- o |= REG_NOSUB;
- break;
- case 'n':
- o |= REG_NEWLINE;
- break;
- case 'm':
- o &= ~REG_EXTENDED;
- o |= REG_NOSPEC;
- break;
- case 'p':
- o |= REG_PEND;
- break;
- case '^':
- o |= REG_NOTBOL;
- break;
- case '$':
- o |= REG_NOTEOL;
- break;
- case '#':
- o |= REG_STARTEND;
- break;
- case 't': /* trace */
- o |= REG_TRACE;
- break;
- case 'l': /* force long representation */
- o |= REG_LARGE;
- break;
- case 'r': /* force backref use */
- o |= REG_BACKR;
- break;
- }
- return(o);
-}
-
-/*
- - opt - is a particular option in a regression string?
- == int opt(int c, char *s);
- */
-int /* predicate */
-opt(c, s)
-int c;
-char *s;
-{
- return(strchr(s, c) != NULL);
-}
-
-/*
- - fixstr - transform magic characters in strings
- == void fixstr(register char *p);
- */
-void
-fixstr(p)
-register char *p;
-{
- if (p == NULL)
- return;
-
- for (; *p != '\0'; p++)
- if (*p == 'N')
- *p = '\n';
- else if (*p == 'T')
- *p = '\t';
- else if (*p == 'S')
- *p = ' ';
- else if (*p == 'Z')
- *p = '\0';
-}
-
-/*
- - check - check a substring match
- == char *check(char *str, regmatch_t sub, char *should);
- */
-char * /* NULL or complaint */
-check(str, sub, should)
-char *str;
-regmatch_t sub;
-char *should;
-{
- register int len;
- register int shlen;
- register char *p;
- static char grump[500];
- register char *at = NULL;
-
- if (should != NULL && strcmp(should, "-") == 0)
- should = NULL;
- if (should != NULL && should[0] == '@') {
- at = should + 1;
- should = "";
- }
-
- /* check rm_so and rm_eo for consistency */
- if (sub.rm_so > sub.rm_eo || (sub.rm_so == -1 && sub.rm_eo != -1) ||
- (sub.rm_so != -1 && sub.rm_eo == -1) ||
- (sub.rm_so != -1 && sub.rm_so < 0) ||
- (sub.rm_eo != -1 && sub.rm_eo < 0) ) {
- sprintf(grump, "start %ld end %ld", (long)sub.rm_so,
- (long)sub.rm_eo);
- return(grump);
- }
-
- /* check for no match */
- if (sub.rm_so == -1 && should == NULL)
- return(NULL);
- if (sub.rm_so == -1)
- return("did not match");
-
- /* check for in range */
- if (sub.rm_eo > strlen(str)) {
- sprintf(grump, "start %ld end %ld, past end of string",
- (long)sub.rm_so, (long)sub.rm_eo);
- return(grump);
- }
-
- len = (int)(sub.rm_eo - sub.rm_so);
- shlen = (int)strlen(should);
- p = str + sub.rm_so;
-
- /* check for not supposed to match */
- if (should == NULL) {
- sprintf(grump, "matched `%.*s'", len, p);
- return(grump);
- }
-
- /* check for wrong match */
- if (len != shlen || strncmp(p, should, (size_t)shlen) != 0) {
- sprintf(grump, "matched `%.*s' instead", len, p);
- return(grump);
- }
- if (shlen > 0)
- return(NULL);
-
- /* check null match in right place */
- if (at == NULL)
- return(NULL);
- shlen = strlen(at);
- if (shlen == 0)
- shlen = 1; /* force check for end-of-string */
- if (strncmp(p, at, shlen) != 0) {
- sprintf(grump, "matched null at `%.20s'", p);
- return(grump);
- }
- return(NULL);
-}
-
-/*
- - eprint - convert error number to name
- == static char *eprint(int err);
- */
-static char *
-eprint(err)
-int err;
-{
- static char epbuf[100];
- size_t len;
-
- len = regerror(REG_ITOA|err, (regex_t *)NULL, epbuf, sizeof(epbuf));
- assert(len <= sizeof(epbuf));
- return(epbuf);
-}
-
-/*
- - efind - convert error name to number
- == static int efind(char *name);
- */
-static int
-efind(name)
-char *name;
-{
- static char efbuf[100];
- regex_t re;
-
- sprintf(efbuf, "REG_%s", name);
- assert(strlen(efbuf) < sizeof(efbuf));
- re.re_endp = efbuf;
- (void) regerror(REG_ATOI, &re, efbuf, sizeof(efbuf));
- return(atoi(efbuf));
-}
diff --git a/regex/main.ih b/regex/main.ih
deleted file mode 100644
index 5a0118ac44..0000000000
--- a/regex/main.ih
+++ /dev/null
@@ -1,19 +0,0 @@
-/* ========= begin header generated by ./mkh ========= */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* === main.c === */
-void regress(FILE *in);
-void try(char *f0, char *f1, char *f2, char *f3, char *f4, int opts);
-int options(int type, char *s);
-int opt(int c, char *s);
-void fixstr(register char *p);
-char *check(char *str, regmatch_t sub, char *should);
-static char *eprint(int err);
-static int efind(char *name);
-
-#ifdef __cplusplus
-}
-#endif
-/* ========= end header generated by ./mkh ========= */
diff --git a/regex/mkh b/regex/mkh
deleted file mode 100644
index 252b246c7b..0000000000
--- a/regex/mkh
+++ /dev/null
@@ -1,76 +0,0 @@
-#! /bin/sh
-# mkh - pull headers out of C source
-PATH=/bin:/usr/bin ; export PATH
-
-# egrep pattern to pick out marked lines
-egrep='^ =([ ]|$)'
-
-# Sed program to process marked lines into lines for the header file.
-# The markers have already been removed. Two things are done here: removal
-# of backslashed newlines, and some fudging of comments. The first is done
-# because -o needs to have prototypes on one line to strip them down.
-# Getting comments into the output is tricky; we turn C++-style // comments
-# into /* */ comments, after altering any existing */'s to avoid trouble.
-peel=' /\\$/N
- /\\\n[ ]*/s///g
- /\/\//s;\*/;* /;g
- /\/\//s;//\(.*\);/*\1 */;'
-
-for a
-do
- case "$a" in
- -o) # old (pre-function-prototype) compiler
- # add code to comment out argument lists
- peel="$peel
- "'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1(/*\2*/);'
- shift
- ;;
- -b) # funny Berkeley __P macro
- peel="$peel
- "'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1 __P((\2));'
- shift
- ;;
- -s) # compiler doesn't like `static foo();'
- # add code to get rid of the `static'
- peel="$peel
- "'/^static[ ][^\/]*[a-zA-Z0-9_)](.*)/s;static.;;'
- shift
- ;;
- -p) # private declarations
- egrep='^ ==([ ]|$)'
- shift
- ;;
- -i) # wrap in #ifndef, argument is name
- ifndef="$2"
- shift ; shift
- ;;
- *) break
- ;;
- esac
-done
-
-if test " $ifndef" != " "
-then
- echo "#ifndef $ifndef"
- echo "#define $ifndef /* never again */"
-fi
-echo "/* ========= begin header generated by $0 ========= */"
-echo '#ifdef __cplusplus'
-echo 'extern "C" {'
-echo '#endif'
-for f
-do
- echo
- echo "/* === $f === */"
- egrep "$egrep" $f | sed 's/^ ==*[ ]//;s/^ ==*$//' | sed "$peel"
- echo
-done
-echo '#ifdef __cplusplus'
-echo '}'
-echo '#endif'
-echo "/* ========= end header generated by $0 ========= */"
-if test " $ifndef" != " "
-then
- echo "#endif"
-fi
-exit 0
diff --git a/regex/regcomp.c b/regex/regcomp.c
deleted file mode 100644
index 7f651bf845..0000000000
--- a/regex/regcomp.c
+++ /dev/null
@@ -1,1546 +0,0 @@
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <regex.h>
-
-#include "utils.h"
-#include "regex2.h"
-
-#include "cclass.h"
-#include "cname.h"
-
-/*
- * parse structure, passed up and down to avoid global variables and
- * other clumsinesses
- */
-struct parse {
- char *next; /* next character in RE */
- char *end; /* end of string (-> NUL normally) */
- int error; /* has an error been seen? */
- sop *strip; /* malloced strip */
- sopno ssize; /* malloced strip size (allocated) */
- sopno slen; /* malloced strip length (used) */
- int ncsalloc; /* number of csets allocated */
- struct re_guts *g;
-# define NPAREN 10 /* we need to remember () 1-9 for back refs */
- sopno pbegin[NPAREN]; /* -> ( ([0] unused) */
- sopno pend[NPAREN]; /* -> ) ([0] unused) */
-};
-
-#include "regcomp.ih"
-
-static char nuls[10]; /* place to point scanner in event of error */
-
-/*
- * macros for use with parse structure
- * BEWARE: these know that the parse structure is named `p' !!!
- */
-#define PEEK() (*p->next)
-#define PEEK2() (*(p->next+1))
-#define MORE() (p->next < p->end)
-#define MORE2() (p->next+1 < p->end)
-#define SEE(c) (MORE() && PEEK() == (c))
-#define SEETWO(a, b) (MORE() && MORE2() && PEEK() == (a) && PEEK2() == (b))
-#define EAT(c) ((SEE(c)) ? (NEXT1(), 1) : 0)
-#define EATTWO(a, b) ((SEETWO(a, b)) ? (NEXT2(), 1) : 0)
-#define NEXT1() (p->next++)
-#define NEXT2() (p->next += 2)
-#define NEXTn(n) (p->next += (n))
-#define GETNEXT() (*p->next++)
-#define SETERROR(e) seterr(p, (e))
-#define REQUIRE(co, e) ((void)((co) || SETERROR(e)))
-#define MUSTSEE(c, e) (REQUIRE(MORE() && PEEK() == (c), e))
-#define MUSTEAT(c, e) (REQUIRE(MORE() && GETNEXT() == (c), e))
-#define MUSTNOTSEE(c, e) (REQUIRE(!MORE() || PEEK() != (c), e))
-#define EMIT(op, sopnd) doemit(p, (sop)(op), (size_t)(sopnd))
-#define INSERT(op, pos) doinsert(p, (sop)(op), HERE()-(pos)+1, pos)
-#define AHEAD(pos) dofwd(p, pos, HERE()-(pos))
-#define ASTERN(sop, pos) EMIT(sop, HERE()-pos)
-#define HERE() (p->slen)
-#define THERE() (p->slen - 1)
-#define THERETHERE() (p->slen - 2)
-#define DROP(n) (p->slen -= (n))
-
-#ifndef NDEBUG
-static int never = 0; /* for use in asserts; shuts lint up */
-#else
-#define never 0 /* some <assert.h>s have bugs too */
-#endif
-
-/*
- - regcomp - interface for parser and compilation
- = API_EXPORT(int) regcomp(regex_t *, const char *, int);
- = #define REG_BASIC 0000
- = #define REG_EXTENDED 0001
- = #define REG_ICASE 0002
- = #define REG_NOSUB 0004
- = #define REG_NEWLINE 0010
- = #define REG_NOSPEC 0020
- = #define REG_PEND 0040
- = #define REG_DUMP 0200
- */
-API_EXPORT(int) /* 0 success, otherwise REG_something */
-regcomp(preg, pattern, cflags)
-regex_t *preg;
-const char *pattern;
-int cflags;
-{
- struct parse pa;
- register struct re_guts *g;
- register struct parse *p = &pa;
- register int i;
- register size_t len;
-#ifdef REDEBUG
-# define GOODFLAGS(f) (f)
-#else
-# define GOODFLAGS(f) ((f)&~REG_DUMP)
-#endif
-
- cflags = GOODFLAGS(cflags);
- if ((cflags&REG_EXTENDED) && (cflags&REG_NOSPEC))
- return(REG_INVARG);
-
- if (cflags&REG_PEND) {
- if (preg->re_endp < pattern)
- return(REG_INVARG);
- len = preg->re_endp - pattern;
- } else
- len = strlen((char *)pattern);
-
- /* do the mallocs early so failure handling is easy */
- g = (struct re_guts *)malloc(sizeof(struct re_guts) +
- (NC-1)*sizeof(cat_t));
- if (g == NULL)
- return(REG_ESPACE);
- p->ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */
- p->strip = (sop *)malloc(p->ssize * sizeof(sop));
- p->slen = 0;
- if (p->strip == NULL) {
- free((char *)g);
- return(REG_ESPACE);
- }
-
- /* set things up */
- p->g = g;
- p->next = (char *)pattern; /* convenience; we do not modify it */
- p->end = p->next + len;
- p->error = 0;
- p->ncsalloc = 0;
- for (i = 0; i < NPAREN; i++) {
- p->pbegin[i] = 0;
- p->pend[i] = 0;
- }
- g->csetsize = NC;
- g->sets = NULL;
- g->setbits = NULL;
- g->ncsets = 0;
- g->cflags = cflags;
- g->iflags = 0;
- g->nbol = 0;
- g->neol = 0;
- g->must = NULL;
- g->mlen = 0;
- g->nsub = 0;
- g->ncategories = 1; /* category 0 is "everything else" */
- g->categories = &g->catspace[-(CHAR_MIN)];
- (void) memset((char *)g->catspace, 0, NC*sizeof(cat_t));
- g->backrefs = 0;
-
- /* do it */
- EMIT(OEND, 0);
- g->firststate = THERE();
- if (cflags&REG_EXTENDED)
- p_ere(p, OUT);
- else if (cflags&REG_NOSPEC)
- p_str(p);
- else
- p_bre(p, OUT, OUT);
- EMIT(OEND, 0);
- g->laststate = THERE();
-
- /* tidy up loose ends and fill things in */
- categorize(p, g);
- stripsnug(p, g);
- findmust(p, g);
- g->nplus = pluscount(p, g);
- g->magic = MAGIC2;
- preg->re_nsub = g->nsub;
- preg->re_g = g;
- preg->re_magic = MAGIC1;
-#ifndef REDEBUG
- /* not debugging, so can't rely on the assert() in regexec() */
- if (g->iflags&BAD)
- SETERROR(REG_ASSERT);
-#endif
-
- /* win or lose, we're done */
- if (p->error != 0) /* lose */
- regfree(preg);
- return(p->error);
-}
-
-/*
- - p_ere - ERE parser top level, concatenation and alternation
- == static void p_ere(register struct parse *p, int stop);
- */
-static void
-p_ere(p, stop)
-register struct parse *p;
-int stop; /* character this ERE should end at */
-{
- register char c;
- register sopno prevback = 0;
- register sopno prevfwd = 0;
- register sopno conc;
- register int first = 1; /* is this the first alternative? */
-
- for (;;) {
- /* do a bunch of concatenated expressions */
- conc = HERE();
- while (MORE() && (c = PEEK()) != '|' && c != stop)
- p_ere_exp(p);
- REQUIRE(HERE() != conc, REG_EMPTY); /* require nonempty */
-
- if (!EAT('|'))
- break; /* NOTE BREAK OUT */
-
- if (first) {
- INSERT(OCH_, conc); /* offset is wrong */
- prevfwd = conc;
- prevback = conc;
- first = 0;
- }
- ASTERN(OOR1, prevback);
- prevback = THERE();
- AHEAD(prevfwd); /* fix previous offset */
- prevfwd = HERE();
- EMIT(OOR2, 0); /* offset is very wrong */
- }
-
- if (!first) { /* tail-end fixups */
- AHEAD(prevfwd);
- ASTERN(O_CH, prevback);
- }
-
- assert(!MORE() || SEE(stop));
-}
-
-/*
- - p_ere_exp - parse one subERE, an atom possibly followed by a repetition op
- == static void p_ere_exp(register struct parse *p);
- */
-static void
-p_ere_exp(p)
-register struct parse *p;
-{
- register char c;
- register sopno pos;
- register int count;
- register int count2;
- register sopno subno;
- int wascaret = 0;
-
- assert(MORE()); /* caller should have ensured this */
- c = GETNEXT();
-
- pos = HERE();
- switch (c) {
- case '(':
- REQUIRE(MORE(), REG_EPAREN);
- p->g->nsub++;
- subno = p->g->nsub;
- if (subno < NPAREN)
- p->pbegin[subno] = HERE();
- EMIT(OLPAREN, subno);
- if (!SEE(')'))
- p_ere(p, ')');
- if (subno < NPAREN) {
- p->pend[subno] = HERE();
- assert(p->pend[subno] != 0);
- }
- EMIT(ORPAREN, subno);
- MUSTEAT(')', REG_EPAREN);
- break;
-#ifndef POSIX_MISTAKE
- case ')': /* happens only if no current unmatched ( */
- /*
- * You may ask, why the ifndef? Because I didn't notice
- * this until slightly too late for 1003.2, and none of the
- * other 1003.2 regular-expression reviewers noticed it at
- * all. So an unmatched ) is legal POSIX, at least until
- * we can get it fixed.
- */
- SETERROR(REG_EPAREN);
- break;
-#endif
- case '^':
- EMIT(OBOL, 0);
- p->g->iflags |= USEBOL;
- p->g->nbol++;
- wascaret = 1;
- break;
- case '$':
- EMIT(OEOL, 0);
- p->g->iflags |= USEEOL;
- p->g->neol++;
- break;
- case '|':
- SETERROR(REG_EMPTY);
- break;
- case '*':
- case '+':
- case '?':
- SETERROR(REG_BADRPT);
- break;
- case '.':
- if (p->g->cflags&REG_NEWLINE)
- nonnewline(p);
- else
- EMIT(OANY, 0);
- break;
- case '[':
- p_bracket(p);
- break;
- case '\\':
- REQUIRE(MORE(), REG_EESCAPE);
- c = GETNEXT();
- ordinary(p, c);
- break;
- case '{': /* okay as ordinary except if digit follows */
- REQUIRE(!MORE() || !isdigit(PEEK()), REG_BADRPT);
- /* FALLTHROUGH */
- default:
- ordinary(p, c);
- break;
- }
-
- if (!MORE())
- return;
- c = PEEK();
- /* we call { a repetition if followed by a digit */
- if (!( c == '*' || c == '+' || c == '?' ||
- (c == '{' && MORE2() && isdigit(PEEK2())) ))
- return; /* no repetition, we're done */
- NEXT1();
-
- REQUIRE(!wascaret, REG_BADRPT);
- switch (c) {
- case '*': /* implemented as +? */
- /* this case does not require the (y|) trick, noKLUDGE */
- INSERT(OPLUS_, pos);
- ASTERN(O_PLUS, pos);
- INSERT(OQUEST_, pos);
- ASTERN(O_QUEST, pos);
- break;
- case '+':
- INSERT(OPLUS_, pos);
- ASTERN(O_PLUS, pos);
- break;
- case '?':
- /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
- INSERT(OCH_, pos); /* offset slightly wrong */
- ASTERN(OOR1, pos); /* this one's right */
- AHEAD(pos); /* fix the OCH_ */
- EMIT(OOR2, 0); /* offset very wrong... */
- AHEAD(THERE()); /* ...so fix it */
- ASTERN(O_CH, THERETHERE());
- break;
- case '{':
- count = p_count(p);
- if (EAT(',')) {
- if (isdigit(PEEK())) {
- count2 = p_count(p);
- REQUIRE(count <= count2, REG_BADBR);
- } else /* single number with comma */
- count2 = INFINITY;
- } else /* just a single number */
- count2 = count;
- repeat(p, pos, count, count2);
- if (!EAT('}')) { /* error heuristics */
- while (MORE() && PEEK() != '}')
- NEXT1();
- REQUIRE(MORE(), REG_EBRACE);
- SETERROR(REG_BADBR);
- }
- break;
- }
-
- if (!MORE())
- return;
- c = PEEK();
- if (!( c == '*' || c == '+' || c == '?' ||
- (c == '{' && MORE2() && isdigit(PEEK2())) ) )
- return;
- SETERROR(REG_BADRPT);
-}
-
-/*
- - p_str - string (no metacharacters) "parser"
- == static void p_str(register struct parse *p);
- */
-static void
-p_str(p)
-register struct parse *p;
-{
- REQUIRE(MORE(), REG_EMPTY);
- while (MORE())
- ordinary(p, GETNEXT());
-}
-
-/*
- - p_bre - BRE parser top level, anchoring and concatenation
- == static void p_bre(register struct parse *p, register int end1, \
- == register int end2);
- * Giving end1 as OUT essentially eliminates the end1/end2 check.
- *
- * This implementation is a bit of a kludge, in that a trailing $ is first
- * taken as an ordinary character and then revised to be an anchor. The
- * only undesirable side effect is that '$' gets included as a character
- * category in such cases. This is fairly harmless; not worth fixing.
- * The amount of lookahead needed to avoid this kludge is excessive.
- */
-static void
-p_bre(p, end1, end2)
-register struct parse *p;
-register int end1; /* first terminating character */
-register int end2; /* second terminating character */
-{
- register sopno start = HERE();
- register int first = 1; /* first subexpression? */
- register int wasdollar = 0;
-
- if (EAT('^')) {
- EMIT(OBOL, 0);
- p->g->iflags |= USEBOL;
- p->g->nbol++;
- }
- while (MORE() && !SEETWO(end1, end2)) {
- wasdollar = p_simp_re(p, first);
- first = 0;
- }
- if (wasdollar) { /* oops, that was a trailing anchor */
- DROP(1);
- EMIT(OEOL, 0);
- p->g->iflags |= USEEOL;
- p->g->neol++;
- }
-
- REQUIRE(HERE() != start, REG_EMPTY); /* require nonempty */
-}
-
-/*
- - p_simp_re - parse a simple RE, an atom possibly followed by a repetition
- == static int p_simp_re(register struct parse *p, int starordinary);
- */
-static int /* was the simple RE an unbackslashed $? */
-p_simp_re(p, starordinary)
-register struct parse *p;
-int starordinary; /* is a leading * an ordinary character? */
-{
- register int c;
- register int count;
- register int count2;
- register sopno pos;
- register int i;
- register sopno subno;
-# define BACKSL (1<<CHAR_BIT)
-
- pos = HERE(); /* repetion op, if any, covers from here */
-
- assert(MORE()); /* caller should have ensured this */
- c = GETNEXT();
- if (c == '\\') {
- REQUIRE(MORE(), REG_EESCAPE);
- c = BACKSL | (unsigned char)GETNEXT();
- }
- switch (c) {
- case '.':
- if (p->g->cflags&REG_NEWLINE)
- nonnewline(p);
- else
- EMIT(OANY, 0);
- break;
- case '[':
- p_bracket(p);
- break;
- case BACKSL|'{':
- SETERROR(REG_BADRPT);
- break;
- case BACKSL|'(':
- p->g->nsub++;
- subno = p->g->nsub;
- if (subno < NPAREN)
- p->pbegin[subno] = HERE();
- EMIT(OLPAREN, subno);
- /* the MORE here is an error heuristic */
- if (MORE() && !SEETWO('\\', ')'))
- p_bre(p, '\\', ')');
- if (subno < NPAREN) {
- p->pend[subno] = HERE();
- assert(p->pend[subno] != 0);
- }
- EMIT(ORPAREN, subno);
- REQUIRE(EATTWO('\\', ')'), REG_EPAREN);
- break;
- case BACKSL|')': /* should not get here -- must be user */
- case BACKSL|'}':
- SETERROR(REG_EPAREN);
- break;
- case BACKSL|'1':
- case BACKSL|'2':
- case BACKSL|'3':
- case BACKSL|'4':
- case BACKSL|'5':
- case BACKSL|'6':
- case BACKSL|'7':
- case BACKSL|'8':
- case BACKSL|'9':
- i = (c&~BACKSL) - '0';
- assert(i < NPAREN);
- if (p->pend[i] != 0) {
- assert(i <= p->g->nsub);
- EMIT(OBACK_, i);
- assert(p->pbegin[i] != 0);
- assert(OP(p->strip[p->pbegin[i]]) == OLPAREN);
- assert(OP(p->strip[p->pend[i]]) == ORPAREN);
- (void) dupl(p, p->pbegin[i]+1, p->pend[i]);
- EMIT(O_BACK, i);
- } else
- SETERROR(REG_ESUBREG);
- p->g->backrefs = 1;
- break;
- case '*':
- REQUIRE(starordinary, REG_BADRPT);
- /* FALLTHROUGH */
- default:
- ordinary(p, c &~ BACKSL);
- break;
- }
-
- if (EAT('*')) { /* implemented as +? */
- /* this case does not require the (y|) trick, noKLUDGE */
- INSERT(OPLUS_, pos);
- ASTERN(O_PLUS, pos);
- INSERT(OQUEST_, pos);
- ASTERN(O_QUEST, pos);
- } else if (EATTWO('\\', '{')) {
- count = p_count(p);
- if (EAT(',')) {
- if (MORE() && isdigit(PEEK())) {
- count2 = p_count(p);
- REQUIRE(count <= count2, REG_BADBR);
- } else /* single number with comma */
- count2 = INFINITY;
- } else /* just a single number */
- count2 = count;
- repeat(p, pos, count, count2);
- if (!EATTWO('\\', '}')) { /* error heuristics */
- while (MORE() && !SEETWO('\\', '}'))
- NEXT1();
- REQUIRE(MORE(), REG_EBRACE);
- SETERROR(REG_BADBR);
- }
- } else if (c == (unsigned char)'$') /* $ (but not \$) ends it */
- return(1);
-
- return(0);
-}
-
-/*
- - p_count - parse a repetition count
- == static int p_count(register struct parse *p);
- */
-static int /* the value */
-p_count(p)
-register struct parse *p;
-{
- register int count = 0;
- register int ndigits = 0;
-
- while (MORE() && isdigit(PEEK()) && count <= DUPMAX) {
- count = count*10 + (GETNEXT() - '0');
- ndigits++;
- }
-
- REQUIRE(ndigits > 0 && count <= DUPMAX, REG_BADBR);
- return(count);
-}
-
-/*
- - p_bracket - parse a bracketed character list
- == static void p_bracket(register struct parse *p);
- *
- * Note a significant property of this code: if the allocset() did SETERROR,
- * no set operations are done.
- */
-static void
-p_bracket(p)
-register struct parse *p;
-{
- register cset *cs = allocset(p);
- register int invert = 0;
-
- /* Dept of Truly Sickening Special-Case Kludges */
- if (p->next + 5 < p->end && strncmp(p->next, "[:<:]]", 6) == 0) {
- EMIT(OBOW, 0);
- NEXTn(6);
- return;
- }
- if (p->next + 5 < p->end && strncmp(p->next, "[:>:]]", 6) == 0) {
- EMIT(OEOW, 0);
- NEXTn(6);
- return;
- }
-
- if (EAT('^'))
- invert++; /* make note to invert set at end */
- if (EAT(']'))
- CHadd(cs, ']');
- else if (EAT('-'))
- CHadd(cs, '-');
- while (MORE() && PEEK() != ']' && !SEETWO('-', ']'))
- p_b_term(p, cs);
- if (EAT('-'))
- CHadd(cs, '-');
- MUSTEAT(']', REG_EBRACK);
-
- if (p->error != 0) /* don't mess things up further */
- return;
-
- if (p->g->cflags&REG_ICASE) {
- register int i;
- register int ci;
-
- for (i = p->g->csetsize - 1; i >= 0; i--)
- if (CHIN(cs, i) && isalpha(i)) {
- ci = othercase(i);
- if (ci != i)
- CHadd(cs, ci);
- }
- if (cs->multis != NULL)
- mccase(p, cs);
- }
- if (invert) {
- register int i;
-
- for (i = p->g->csetsize - 1; i >= 0; i--)
- if (CHIN(cs, i))
- CHsub(cs, i);
- else
- CHadd(cs, i);
- if (p->g->cflags&REG_NEWLINE)
- CHsub(cs, '\n');
- if (cs->multis != NULL)
- mcinvert(p, cs);
- }
-
- assert(cs->multis == NULL); /* xxx */
-
- if (nch(p, cs) == 1) { /* optimize singleton sets */
- ordinary(p, firstch(p, cs));
- freeset(p, cs);
- } else
- EMIT(OANYOF, freezeset(p, cs));
-}
-
-/*
- - p_b_term - parse one term of a bracketed character list
- == static void p_b_term(register struct parse *p, register cset *cs);
- */
-static void
-p_b_term(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register char c;
- register char start, finish;
- register int i;
-
- /* classify what we've got */
- switch ((MORE()) ? PEEK() : '\0') {
- case '[':
- c = (MORE2()) ? PEEK2() : '\0';
- break;
- case '-':
- SETERROR(REG_ERANGE);
- return; /* NOTE RETURN */
- break;
- default:
- c = '\0';
- break;
- }
-
- switch (c) {
- case ':': /* character class */
- NEXT2();
- REQUIRE(MORE(), REG_EBRACK);
- c = PEEK();
- REQUIRE(c != '-' && c != ']', REG_ECTYPE);
- p_b_cclass(p, cs);
- REQUIRE(MORE(), REG_EBRACK);
- REQUIRE(EATTWO(':', ']'), REG_ECTYPE);
- break;
- case '=': /* equivalence class */
- NEXT2();
- REQUIRE(MORE(), REG_EBRACK);
- c = PEEK();
- REQUIRE(c != '-' && c != ']', REG_ECOLLATE);
- p_b_eclass(p, cs);
- REQUIRE(MORE(), REG_EBRACK);
- REQUIRE(EATTWO('=', ']'), REG_ECOLLATE);
- break;
- default: /* symbol, ordinary character, or range */
-/* xxx revision needed for multichar stuff */
- start = p_b_symbol(p);
- if (SEE('-') && MORE2() && PEEK2() != ']') {
- /* range */
- NEXT1();
- if (EAT('-'))
- finish = '-';
- else
- finish = p_b_symbol(p);
- } else
- finish = start;
-/* xxx what about signed chars here... */
- REQUIRE(start <= finish, REG_ERANGE);
- for (i = start; i <= finish; i++)
- CHadd(cs, i);
- break;
- }
-}
-
-/*
- - p_b_cclass - parse a character-class name and deal with it
- == static void p_b_cclass(register struct parse *p, register cset *cs);
- */
-static void
-p_b_cclass(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register char *sp = p->next;
- register struct cclass *cp;
- register size_t len;
- register char *u;
- register char c;
-
- while (MORE() && isalpha(PEEK()))
- NEXT1();
- len = p->next - sp;
- for (cp = cclasses; cp->name != NULL; cp++)
- if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0')
- break;
- if (cp->name == NULL) {
- /* oops, didn't find it */
- SETERROR(REG_ECTYPE);
- return;
- }
-
- u = cp->chars;
- while ((c = *u++) != '\0')
- CHadd(cs, c);
- for (u = cp->multis; *u != '\0'; u += strlen(u) + 1)
- MCadd(p, cs, u);
-}
-
-/*
- - p_b_eclass - parse an equivalence-class name and deal with it
- == static void p_b_eclass(register struct parse *p, register cset *cs);
- *
- * This implementation is incomplete. xxx
- */
-static void
-p_b_eclass(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register char c;
-
- c = p_b_coll_elem(p, '=');
- CHadd(cs, c);
-}
-
-/*
- - p_b_symbol - parse a character or [..]ed multicharacter collating symbol
- == static char p_b_symbol(register struct parse *p);
- */
-static char /* value of symbol */
-p_b_symbol(p)
-register struct parse *p;
-{
- register char value;
-
- REQUIRE(MORE(), REG_EBRACK);
- if (!EATTWO('[', '.'))
- return(GETNEXT());
-
- /* collating symbol */
- value = p_b_coll_elem(p, '.');
- REQUIRE(EATTWO('.', ']'), REG_ECOLLATE);
- return(value);
-}
-
-/*
- - p_b_coll_elem - parse a collating-element name and look it up
- == static char p_b_coll_elem(register struct parse *p, int endc);
- */
-static char /* value of collating element */
-p_b_coll_elem(p, endc)
-register struct parse *p;
-int endc; /* name ended by endc,']' */
-{
- register char *sp = p->next;
- register struct cname *cp;
- register int len;
-
- while (MORE() && !SEETWO(endc, ']'))
- NEXT1();
- if (!MORE()) {
- SETERROR(REG_EBRACK);
- return(0);
- }
- len = p->next - sp;
- for (cp = cnames; cp->name != NULL; cp++)
- if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0')
- return(cp->code); /* known name */
- if (len == 1)
- return(*sp); /* single character */
- SETERROR(REG_ECOLLATE); /* neither */
- return(0);
-}
-
-/*
- - othercase - return the case counterpart of an alphabetic
- == static char othercase(int ch);
- */
-static char /* if no counterpart, return ch */
-othercase(ch)
-int ch;
-{
- assert(isalpha(ch));
- if (isupper(ch))
- return(tolower(ch));
- else if (islower(ch))
- return(toupper(ch));
- else /* peculiar, but could happen */
- return(ch);
-}
-
-/*
- - bothcases - emit a dualcase version of a two-case character
- == static void bothcases(register struct parse *p, int ch);
- *
- * Boy, is this implementation ever a kludge...
- */
-static void
-bothcases(p, ch)
-register struct parse *p;
-int ch;
-{
- register char *oldnext = p->next;
- register char *oldend = p->end;
- char bracket[3];
-
- assert(othercase(ch) != ch); /* p_bracket() would recurse */
- p->next = bracket;
- p->end = bracket+2;
- bracket[0] = ch;
- bracket[1] = ']';
- bracket[2] = '\0';
- p_bracket(p);
- assert(p->next == bracket+2);
- p->next = oldnext;
- p->end = oldend;
-}
-
-/*
- - ordinary - emit an ordinary character
- == static void ordinary(register struct parse *p, register int ch);
- */
-static void
-ordinary(p, ch)
-register struct parse *p;
-register int ch;
-{
- register cat_t *cap = p->g->categories;
-
- if ((p->g->cflags&REG_ICASE) && isalpha(ch) && othercase(ch) != ch)
- bothcases(p, ch);
- else {
- EMIT(OCHAR, (unsigned char)ch);
- if (cap[ch] == 0)
- cap[ch] = p->g->ncategories++;
- }
-}
-
-/*
- - nonnewline - emit REG_NEWLINE version of OANY
- == static void nonnewline(register struct parse *p);
- *
- * Boy, is this implementation ever a kludge...
- */
-static void
-nonnewline(p)
-register struct parse *p;
-{
- register char *oldnext = p->next;
- register char *oldend = p->end;
- char bracket[4];
-
- p->next = bracket;
- p->end = bracket+3;
- bracket[0] = '^';
- bracket[1] = '\n';
- bracket[2] = ']';
- bracket[3] = '\0';
- p_bracket(p);
- assert(p->next == bracket+3);
- p->next = oldnext;
- p->end = oldend;
-}
-
-/*
- - repeat - generate code for a bounded repetition, recursively if needed
- == static void repeat(register struct parse *p, sopno start, int from, int to);
- */
-static void
-repeat(p, start, from, to)
-register struct parse *p;
-sopno start; /* operand from here to end of strip */
-int from; /* repeated from this number */
-int to; /* to this number of times (maybe INFINITY) */
-{
- register sopno finish = HERE();
-# define N 2
-# define INF 3
-# define REP(f, t) ((f)*8 + (t))
-# define MAP(n) (((n) <= 1) ? (n) : ((n) == INFINITY) ? INF : N)
- register sopno copy;
-
- if (p->error != 0) /* head off possible runaway recursion */
- return;
-
- assert(from <= to);
-
- switch (REP(MAP(from), MAP(to))) {
- case REP(0, 0): /* must be user doing this */
- DROP(finish-start); /* drop the operand */
- break;
- case REP(0, 1): /* as x{1,1}? */
- case REP(0, N): /* as x{1,n}? */
- case REP(0, INF): /* as x{1,}? */
- /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
- INSERT(OCH_, start); /* offset is wrong... */
- repeat(p, start+1, 1, to);
- ASTERN(OOR1, start);
- AHEAD(start); /* ... fix it */
- EMIT(OOR2, 0);
- AHEAD(THERE());
- ASTERN(O_CH, THERETHERE());
- break;
- case REP(1, 1): /* trivial case */
- /* done */
- break;
- case REP(1, N): /* as x?x{1,n-1} */
- /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
- INSERT(OCH_, start);
- ASTERN(OOR1, start);
- AHEAD(start);
- EMIT(OOR2, 0); /* offset very wrong... */
- AHEAD(THERE()); /* ...so fix it */
- ASTERN(O_CH, THERETHERE());
- copy = dupl(p, start+1, finish+1);
- assert(copy == finish+4);
- repeat(p, copy, 1, to-1);
- break;
- case REP(1, INF): /* as x+ */
- INSERT(OPLUS_, start);
- ASTERN(O_PLUS, start);
- break;
- case REP(N, N): /* as xx{m-1,n-1} */
- copy = dupl(p, start, finish);
- repeat(p, copy, from-1, to-1);
- break;
- case REP(N, INF): /* as xx{n-1,INF} */
- copy = dupl(p, start, finish);
- repeat(p, copy, from-1, to);
- break;
- default: /* "can't happen" */
- SETERROR(REG_ASSERT); /* just in case */
- break;
- }
-}
-
-/*
- - seterr - set an error condition
- == static int seterr(register struct parse *p, int e);
- */
-static int /* useless but makes type checking happy */
-seterr(p, e)
-register struct parse *p;
-int e;
-{
- if (p->error == 0) /* keep earliest error condition */
- p->error = e;
- p->next = nuls; /* try to bring things to a halt */
- p->end = nuls;
- return(0); /* make the return value well-defined */
-}
-
-/*
- - allocset - allocate a set of characters for []
- == static cset *allocset(register struct parse *p);
- */
-static cset *
-allocset(p)
-register struct parse *p;
-{
- register int no = p->g->ncsets++;
- register size_t nc;
- register size_t nbytes;
- register cset *cs;
- register size_t css = (size_t)p->g->csetsize;
- register int i;
-
- if (no >= p->ncsalloc) { /* need another column of space */
- p->ncsalloc += CHAR_BIT;
- nc = p->ncsalloc;
- assert(nc % CHAR_BIT == 0);
- nbytes = nc / CHAR_BIT * css;
- if (p->g->sets == NULL)
- p->g->sets = (cset *)malloc(nc * sizeof(cset));
- else
- p->g->sets = (cset *)realloc((char *)p->g->sets,
- nc * sizeof(cset));
- if (p->g->setbits == NULL)
- p->g->setbits = (uch *)malloc(nbytes);
- else {
- p->g->setbits = (uch *)realloc((char *)p->g->setbits,
- nbytes);
- /* xxx this isn't right if setbits is now NULL */
- for (i = 0; i < no; i++)
- p->g->sets[i].ptr = p->g->setbits + css*(i/CHAR_BIT);
- }
- if (p->g->sets != NULL && p->g->setbits != NULL)
- (void) memset((char *)p->g->setbits + (nbytes - css),
- 0, css);
- else {
- no = 0;
- SETERROR(REG_ESPACE);
- /* caller's responsibility not to do set ops */
- }
- }
-
- assert(p->g->sets != NULL); /* xxx */
- cs = &p->g->sets[no];
- cs->ptr = p->g->setbits + css*((no)/CHAR_BIT);
- cs->mask = 1 << ((no) % CHAR_BIT);
- cs->hash = 0;
- cs->smultis = 0;
- cs->multis = NULL;
-
- return(cs);
-}
-
-/*
- - freeset - free a now-unused set
- == static void freeset(register struct parse *p, register cset *cs);
- */
-static void
-freeset(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register unsigned int i;
- register cset *top = &p->g->sets[p->g->ncsets];
- register size_t css = (size_t)p->g->csetsize;
-
- for (i = 0; i < css; i++)
- CHsub(cs, i);
- if (cs == top-1) /* recover only the easy case */
- p->g->ncsets--;
-}
-
-/*
- - freezeset - final processing on a set of characters
- == static int freezeset(register struct parse *p, register cset *cs);
- *
- * The main task here is merging identical sets. This is usually a waste
- * of time (although the hash code minimizes the overhead), but can win
- * big if REG_ICASE is being used. REG_ICASE, by the way, is why the hash
- * is done using addition rather than xor -- all ASCII [aA] sets xor to
- * the same value!
- */
-static int /* set number */
-freezeset(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register uch h = cs->hash;
- register unsigned int i;
- register cset *top = &p->g->sets[p->g->ncsets];
- register cset *cs2;
- register size_t css = (size_t)p->g->csetsize;
-
- /* look for an earlier one which is the same */
- for (cs2 = &p->g->sets[0]; cs2 < top; cs2++)
- if (cs2->hash == h && cs2 != cs) {
- /* maybe */
- for (i = 0; i < css; i++)
- if (!!CHIN(cs2, i) != !!CHIN(cs, i))
- break; /* no */
- if (i == css)
- break; /* yes */
- }
-
- if (cs2 < top) { /* found one */
- freeset(p, cs);
- cs = cs2;
- }
-
- return((int)(cs - p->g->sets));
-}
-
-/*
- - firstch - return first character in a set (which must have at least one)
- == static int firstch(register struct parse *p, register cset *cs);
- */
-static int /* character; there is no "none" value */
-firstch(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register unsigned int i;
- register size_t css = (size_t)p->g->csetsize;
-
- for (i = 0; i < css; i++)
- if (CHIN(cs, i))
- return((char)i);
- assert(never);
- return(0); /* arbitrary */
-}
-
-/*
- - nch - number of characters in a set
- == static int nch(register struct parse *p, register cset *cs);
- */
-static int
-nch(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register unsigned int i;
- register size_t css = (size_t)p->g->csetsize;
- register int n = 0;
-
- for (i = 0; i < css; i++)
- if (CHIN(cs, i))
- n++;
- return(n);
-}
-
-/*
- - mcadd - add a collating element to a cset
- == static void mcadd(register struct parse *p, register cset *cs, \
- == register char *cp);
- */
-static void
-mcadd(p, cs, cp)
-register struct parse *p;
-register cset *cs;
-register char *cp;
-{
- register size_t oldend = cs->smultis;
-
- cs->smultis += strlen(cp) + 1;
- if (cs->multis == NULL)
- cs->multis = malloc(cs->smultis);
- else
- cs->multis = realloc(cs->multis, cs->smultis);
- if (cs->multis == NULL) {
- SETERROR(REG_ESPACE);
- return;
- }
-
- (void) strcpy(cs->multis + oldend - 1, cp);
- cs->multis[cs->smultis - 1] = '\0';
-}
-
-
-/*
- - mcinvert - invert the list of collating elements in a cset
- == static void mcinvert(register struct parse *p, register cset *cs);
- *
- * This would have to know the set of possibilities. Implementation
- * is deferred.
- */
-static void
-mcinvert(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- assert(cs->multis == NULL); /* xxx */
-}
-
-/*
- - mccase - add case counterparts of the list of collating elements in a cset
- == static void mccase(register struct parse *p, register cset *cs);
- *
- * This would have to know the set of possibilities. Implementation
- * is deferred.
- */
-static void
-mccase(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- assert(cs->multis == NULL); /* xxx */
-}
-
-/*
- - isinsets - is this character in any sets?
- == static int isinsets(register struct re_guts *g, int c);
- */
-static int /* predicate */
-isinsets(g, c)
-register struct re_guts *g;
-int c;
-{
- register uch *col;
- register int i;
- register int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT;
- register unsigned uc = (unsigned char)c;
-
- for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize)
- if (col[uc] != 0)
- return(1);
- return(0);
-}
-
-/*
- - samesets - are these two characters in exactly the same sets?
- == static int samesets(register struct re_guts *g, int c1, int c2);
- */
-static int /* predicate */
-samesets(g, c1, c2)
-register struct re_guts *g;
-int c1;
-int c2;
-{
- register uch *col;
- register int i;
- register int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT;
- register unsigned uc1 = (unsigned char)c1;
- register unsigned uc2 = (unsigned char)c2;
-
- for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize)
- if (col[uc1] != col[uc2])
- return(0);
- return(1);
-}
-
-/*
- - categorize - sort out character categories
- == static void categorize(struct parse *p, register struct re_guts *g);
- */
-static void
-categorize(p, g)
-struct parse *p;
-register struct re_guts *g;
-{
- register cat_t *cats = g->categories;
- register int c;
- register int c2;
- register cat_t cat;
-
- /* avoid making error situations worse */
- if (p->error != 0)
- return;
-
- for (c = CHAR_MIN; c <= CHAR_MAX; c++)
- if (cats[c] == 0 && isinsets(g, c)) {
- cat = g->ncategories++;
- cats[c] = cat;
- for (c2 = c+1; c2 <= CHAR_MAX; c2++)
- if (cats[c2] == 0 && samesets(g, c, c2))
- cats[c2] = cat;
- }
-}
-
-/*
- - dupl - emit a duplicate of a bunch of sops
- == static sopno dupl(register struct parse *p, sopno start, sopno finish);
- */
-static sopno /* start of duplicate */
-dupl(p, start, finish)
-register struct parse *p;
-sopno start; /* from here */
-sopno finish; /* to this less one */
-{
- register sopno ret = HERE();
- register sopno len = finish - start;
-
- assert(finish >= start);
- if (len == 0)
- return(ret);
- enlarge(p, p->ssize + len); /* this many unexpected additions */
- assert(p->ssize >= p->slen + len);
- (void) memcpy((char *)(p->strip + p->slen),
- (char *)(p->strip + start), (size_t)len*sizeof(sop));
- p->slen += len;
- return(ret);
-}
-
-/*
- - doemit - emit a strip operator
- == static void doemit(register struct parse *p, sop op, size_t opnd);
- *
- * It might seem better to implement this as a macro with a function as
- * hard-case backup, but it's just too big and messy unless there are
- * some changes to the data structures. Maybe later.
- */
-static void
-doemit(p, op, opnd)
-register struct parse *p;
-sop op;
-size_t opnd;
-{
- /* avoid making error situations worse */
- if (p->error != 0)
- return;
-
- /* deal with oversize operands ("can't happen", more or less) */
- assert(opnd < 1<<OPSHIFT);
-
- /* deal with undersized strip */
- if (p->slen >= p->ssize)
- enlarge(p, (p->ssize+1) / 2 * 3); /* +50% */
- assert(p->slen < p->ssize);
-
- /* finally, it's all reduced to the easy case */
- p->strip[p->slen++] = SOP(op, opnd);
-}
-
-/*
- - doinsert - insert a sop into the strip
- == static void doinsert(register struct parse *p, sop op, size_t opnd, sopno pos);
- */
-static void
-doinsert(p, op, opnd, pos)
-register struct parse *p;
-sop op;
-size_t opnd;
-sopno pos;
-{
- register sopno sn;
- register sop s;
- register int i;
-
- /* avoid making error situations worse */
- if (p->error != 0)
- return;
-
- sn = HERE();
- EMIT(op, opnd); /* do checks, ensure space */
- assert(HERE() == sn+1);
- s = p->strip[sn];
-
- /* adjust paren pointers */
- assert(pos > 0);
- for (i = 1; i < NPAREN; i++) {
- if (p->pbegin[i] >= pos) {
- p->pbegin[i]++;
- }
- if (p->pend[i] >= pos) {
- p->pend[i]++;
- }
- }
-
- memmove((char *)&p->strip[pos+1], (char *)&p->strip[pos],
- (HERE()-pos-1)*sizeof(sop));
- p->strip[pos] = s;
-}
-
-/*
- - dofwd - complete a forward reference
- == static void dofwd(register struct parse *p, sopno pos, sop value);
- */
-static void
-dofwd(p, pos, value)
-register struct parse *p;
-register sopno pos;
-sop value;
-{
- /* avoid making error situations worse */
- if (p->error != 0)
- return;
-
- assert(value < 1<<OPSHIFT);
- p->strip[pos] = OP(p->strip[pos]) | value;
-}
-
-/*
- - enlarge - enlarge the strip
- == static void enlarge(register struct parse *p, sopno size);
- */
-static void
-enlarge(p, size)
-register struct parse *p;
-register sopno size;
-{
- register sop *sp;
-
- if (p->ssize >= size)
- return;
-
- sp = (sop *)realloc(p->strip, size*sizeof(sop));
- if (sp == NULL) {
- SETERROR(REG_ESPACE);
- return;
- }
- p->strip = sp;
- p->ssize = size;
-}
-
-/*
- - stripsnug - compact the strip
- == static void stripsnug(register struct parse *p, register struct re_guts *g);
- */
-static void
-stripsnug(p, g)
-register struct parse *p;
-register struct re_guts *g;
-{
- g->nstates = p->slen;
- g->strip = (sop *)realloc((char *)p->strip, p->slen * sizeof(sop));
- if (g->strip == NULL) {
- SETERROR(REG_ESPACE);
- g->strip = p->strip;
- }
-}
-
-/*
- - findmust - fill in must and mlen with longest mandatory literal string
- == static void findmust(register struct parse *p, register struct re_guts *g);
- *
- * This algorithm could do fancy things like analyzing the operands of |
- * for common subsequences. Someday. This code is simple and finds most
- * of the interesting cases.
- *
- * Note that must and mlen got initialized during setup.
- */
-static void
-findmust(p, g)
-struct parse *p;
-register struct re_guts *g;
-{
- register sop *scan;
- sop *start = NULL;
- register sop *newstart = NULL;
- register sopno newlen;
- register sop s;
- register char *cp;
- register sopno i;
-
- /* avoid making error situations worse */
- if (p->error != 0)
- return;
-
- /* find the longest OCHAR sequence in strip */
- newlen = 0;
- scan = g->strip + 1;
- do {
- s = *scan++;
- switch (OP(s)) {
- case OCHAR: /* sequence member */
- if (newlen == 0) /* new sequence */
- newstart = scan - 1;
- newlen++;
- break;
- case OPLUS_: /* things that don't break one */
- case OLPAREN:
- case ORPAREN:
- break;
- case OQUEST_: /* things that must be skipped */
- case OCH_:
- scan--;
- do {
- scan += OPND(s);
- s = *scan;
- /* assert() interferes w debug printouts */
- if (OP(s) != O_QUEST && OP(s) != O_CH &&
- OP(s) != OOR2) {
- g->iflags |= BAD;
- return;
- }
- } while (OP(s) != O_QUEST && OP(s) != O_CH);
- /* fallthrough */
- default: /* things that break a sequence */
- if (newlen > g->mlen) { /* ends one */
- start = newstart;
- g->mlen = newlen;
- }
- newlen = 0;
- break;
- }
- } while (OP(s) != OEND);
-
- if (g->mlen == 0) /* there isn't one */
- return;
-
- /* turn it into a character string */
- g->must = malloc((size_t)g->mlen + 1);
- if (g->must == NULL) { /* argh; just forget it */
- g->mlen = 0;
- return;
- }
- cp = g->must;
- scan = start;
- for (i = g->mlen; i > 0; i--) {
- while (OP(s = *scan++) != OCHAR)
- continue;
- assert(cp < g->must + g->mlen);
- *cp++ = (char)OPND(s);
- }
- assert(cp == g->must + g->mlen);
- *cp++ = '\0'; /* just on general principles */
-}
-
-/*
- - pluscount - count + nesting
- == static sopno pluscount(register struct parse *p, register struct re_guts *g);
- */
-static sopno /* nesting depth */
-pluscount(p, g)
-struct parse *p;
-register struct re_guts *g;
-{
- register sop *scan;
- register sop s;
- register sopno plusnest = 0;
- register sopno maxnest = 0;
-
- if (p->error != 0)
- return(0); /* there may not be an OEND */
-
- scan = g->strip + 1;
- do {
- s = *scan++;
- switch (OP(s)) {
- case OPLUS_:
- plusnest++;
- break;
- case O_PLUS:
- if (plusnest > maxnest)
- maxnest = plusnest;
- plusnest--;
- break;
- }
- } while (OP(s) != OEND);
- if (plusnest != 0)
- g->iflags |= BAD;
- return(maxnest);
-}
diff --git a/regex/regcomp.ih b/regex/regcomp.ih
deleted file mode 100644
index f0eeb5f02d..0000000000
--- a/regex/regcomp.ih
+++ /dev/null
@@ -1,48 +0,0 @@
-/* ========= begin header generated by ./mkh ========= */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* === regcomp.c === */
-static void p_ere(register struct parse *p, int stop);
-static void p_ere_exp(register struct parse *p);
-static void p_str(register struct parse *p);
-static void p_bre(register struct parse *p, register int end1, register int end2);
-static int p_simp_re(register struct parse *p, int starordinary);
-static int p_count(register struct parse *p);
-static void p_bracket(register struct parse *p);
-static void p_b_term(register struct parse *p, register cset *cs);
-static void p_b_cclass(register struct parse *p, register cset *cs);
-static void p_b_eclass(register struct parse *p, register cset *cs);
-static char p_b_symbol(register struct parse *p);
-static char p_b_coll_elem(register struct parse *p, int endc);
-static char othercase(int ch);
-static void bothcases(register struct parse *p, int ch);
-static void ordinary(register struct parse *p, register int ch);
-static void nonnewline(register struct parse *p);
-static void repeat(register struct parse *p, sopno start, int from, int to);
-static int seterr(register struct parse *p, int e);
-static cset *allocset(register struct parse *p);
-static void freeset(register struct parse *p, register cset *cs);
-static int freezeset(register struct parse *p, register cset *cs);
-static int firstch(register struct parse *p, register cset *cs);
-static int nch(register struct parse *p, register cset *cs);
-static void mcadd(register struct parse *p, register cset *cs, register char *cp);
-static void mcinvert(register struct parse *p, register cset *cs);
-static void mccase(register struct parse *p, register cset *cs);
-static int isinsets(register struct re_guts *g, int c);
-static int samesets(register struct re_guts *g, int c1, int c2);
-static void categorize(struct parse *p, register struct re_guts *g);
-static sopno dupl(register struct parse *p, sopno start, sopno finish);
-static void doemit(register struct parse *p, sop op, size_t opnd);
-static void doinsert(register struct parse *p, sop op, size_t opnd, sopno pos);
-static void dofwd(register struct parse *p, sopno pos, sop value);
-static void enlarge(register struct parse *p, sopno size);
-static void stripsnug(register struct parse *p, register struct re_guts *g);
-static void findmust(register struct parse *p, register struct re_guts *g);
-static sopno pluscount(register struct parse *p, register struct re_guts *g);
-
-#ifdef __cplusplus
-}
-#endif
-/* ========= end header generated by ./mkh ========= */
diff --git a/regex/regerror.c b/regex/regerror.c
deleted file mode 100644
index 12edd4e164..0000000000
--- a/regex/regerror.c
+++ /dev/null
@@ -1,124 +0,0 @@
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <regex.h>
-
-#include "utils.h"
-#include "regerror.ih"
-
-/*
- = #define REG_NOMATCH 1
- = #define REG_BADPAT 2
- = #define REG_ECOLLATE 3
- = #define REG_ECTYPE 4
- = #define REG_EESCAPE 5
- = #define REG_ESUBREG 6
- = #define REG_EBRACK 7
- = #define REG_EPAREN 8
- = #define REG_EBRACE 9
- = #define REG_BADBR 10
- = #define REG_ERANGE 11
- = #define REG_ESPACE 12
- = #define REG_BADRPT 13
- = #define REG_EMPTY 14
- = #define REG_ASSERT 15
- = #define REG_INVARG 16
- = #define REG_ATOI 255 // convert name to number (!)
- = #define REG_ITOA 0400 // convert number to name (!)
- */
-static struct rerr {
- int code;
- char *name;
- char *explain;
-} rerrs[] = {
- { REG_NOMATCH, "REG_NOMATCH", "regexec() failed to match" },
- { REG_BADPAT, "REG_BADPAT", "invalid regular expression" },
- { REG_ECOLLATE, "REG_ECOLLATE", "invalid collating element" },
- { REG_ECTYPE, "REG_ECTYPE", "invalid character class" },
- { REG_EESCAPE, "REG_EESCAPE", "trailing backslash (\\)" },
- { REG_ESUBREG, "REG_ESUBREG", "invalid backreference number" },
- { REG_EBRACK, "REG_EBRACK", "brackets ([ ]) not balanced" },
- { REG_EPAREN, "REG_EPAREN", "parentheses not balanced" },
- { REG_EBRACE, "REG_EBRACE", "braces not balanced" },
- { REG_BADBR, "REG_BADBR", "invalid repetition count(s)" },
- { REG_ERANGE, "REG_ERANGE", "invalid character range" },
- { REG_ESPACE, "REG_ESPACE", "out of memory" },
- { REG_BADRPT, "REG_BADRPT", "repetition-operator operand invalid" },
- { REG_EMPTY, "REG_EMPTY", "empty (sub)expression" },
- { REG_ASSERT, "REG_ASSERT", "\"can't happen\" -- you found a bug" },
- { REG_INVARG, "REG_INVARG", "invalid argument to regex routine" },
- { 0, "", "*** unknown regexp error code ***" }
-};
-
-/*
- - regerror - the interface to error numbers
- = API_EXPORT(size_t) regerror(int, const regex_t *, char *, size_t);
- */
-/* ARGSUSED */
-API_EXPORT(size_t)
-regerror(errcode, preg, errbuf, errbuf_size)
-int errcode;
-const regex_t *preg;
-char *errbuf;
-size_t errbuf_size;
-{
- register struct rerr *r;
- register size_t len;
- register int target = errcode &~ REG_ITOA;
- register char *s;
- char convbuf[50];
-
- if (errcode == REG_ATOI)
- s = regatoi(preg, convbuf);
- else {
- for (r = rerrs; r->code != 0; r++)
- if (r->code == target)
- break;
-
- if (errcode&REG_ITOA) {
- if (r->code != 0)
- (void) strcpy(convbuf, r->name);
- else
- sprintf(convbuf, "REG_0x%x", target);
- assert(strlen(convbuf) < sizeof(convbuf));
- s = convbuf;
- } else
- s = r->explain;
- }
-
- len = strlen(s) + 1;
- if (errbuf_size > 0) {
- if (errbuf_size > len)
- (void) strcpy(errbuf, s);
- else {
- (void) strncpy(errbuf, s, errbuf_size-1);
- errbuf[errbuf_size-1] = '\0';
- }
- }
-
- return(len);
-}
-
-/*
- - regatoi - internal routine to implement REG_ATOI
- == static char *regatoi(const regex_t *preg, char *localbuf);
- */
-static char *
-regatoi(preg, localbuf)
-const regex_t *preg;
-char *localbuf;
-{
- register struct rerr *r;
-
- for (r = rerrs; r->code != 0; r++)
- if (strcmp(r->name, preg->re_endp) == 0)
- break;
- if (r->code == 0)
- return("0");
-
- sprintf(localbuf, "%d", r->code);
- return(localbuf);
-}
diff --git a/regex/regerror.ih b/regex/regerror.ih
deleted file mode 100644
index 2cb668c24f..0000000000
--- a/regex/regerror.ih
+++ /dev/null
@@ -1,12 +0,0 @@
-/* ========= begin header generated by ./mkh ========= */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* === regerror.c === */
-static char *regatoi(const regex_t *preg, char *localbuf);
-
-#ifdef __cplusplus
-}
-#endif
-/* ========= end header generated by ./mkh ========= */
diff --git a/regex/regex.3 b/regex/regex.3
deleted file mode 100644
index 100c8a7f71..0000000000
--- a/regex/regex.3
+++ /dev/null
@@ -1,502 +0,0 @@
-.TH REGEX 3 "17 May 1993"
-.BY "Henry Spencer"
-.de ZR
-.\" one other place knows this name: the SEE ALSO section
-.IR regex (7) \\$1
-..
-.SH NAME
-regcomp, regexec, regerror, regfree \- regular-expression library
-.SH SYNOPSIS
-.ft B
-.\".na
-#include <sys/types.h>
-.br
-#include <regex.h>
-.HP 10
-int regcomp(regex_t\ *preg, const\ char\ *pattern, int\ cflags);
-.HP
-int\ regexec(const\ regex_t\ *preg, const\ char\ *string,
-size_t\ nmatch, regmatch_t\ pmatch[], int\ eflags);
-.HP
-size_t\ regerror(int\ errcode, const\ regex_t\ *preg,
-char\ *errbuf, size_t\ errbuf_size);
-.HP
-void\ regfree(regex_t\ *preg);
-.\".ad
-.ft
-.SH DESCRIPTION
-These routines implement POSIX 1003.2 regular expressions (``RE''s);
-see
-.ZR .
-.I Regcomp
-compiles an RE written as a string into an internal form,
-.I regexec
-matches that internal form against a string and reports results,
-.I regerror
-transforms error codes from either into human-readable messages,
-and
-.I regfree
-frees any dynamically-allocated storage used by the internal form
-of an RE.
-.PP
-The header
-.I <regex.h>
-declares two structure types,
-.I regex_t
-and
-.IR regmatch_t ,
-the former for compiled internal forms and the latter for match reporting.
-It also declares the four functions,
-a type
-.IR regoff_t ,
-and a number of constants with names starting with ``REG_''.
-.PP
-.I Regcomp
-compiles the regular expression contained in the
-.I pattern
-string,
-subject to the flags in
-.IR cflags ,
-and places the results in the
-.I regex_t
-structure pointed to by
-.IR preg .
-.I Cflags
-is the bitwise OR of zero or more of the following flags:
-.IP REG_EXTENDED \w'REG_EXTENDED'u+2n
-Compile modern (``extended'') REs,
-rather than the obsolete (``basic'') REs that
-are the default.
-.IP REG_BASIC
-This is a synonym for 0,
-provided as a counterpart to REG_EXTENDED to improve readability.
-.IP REG_NOSPEC
-Compile with recognition of all special characters turned off.
-All characters are thus considered ordinary,
-so the ``RE'' is a literal string.
-This is an extension,
-compatible with but not specified by POSIX 1003.2,
-and should be used with
-caution in software intended to be portable to other systems.
-REG_EXTENDED and REG_NOSPEC may not be used
-in the same call to
-.IR regcomp .
-.IP REG_ICASE
-Compile for matching that ignores upper/lower case distinctions.
-See
-.ZR .
-.IP REG_NOSUB
-Compile for matching that need only report success or failure,
-not what was matched.
-.IP REG_NEWLINE
-Compile for newline-sensitive matching.
-By default, newline is a completely ordinary character with no special
-meaning in either REs or strings.
-With this flag,
-`[^' bracket expressions and `.' never match newline,
-a `^' anchor matches the null string after any newline in the string
-in addition to its normal function,
-and the `$' anchor matches the null string before any newline in the
-string in addition to its normal function.
-.IP REG_PEND
-The regular expression ends,
-not at the first NUL,
-but just before the character pointed to by the
-.I re_endp
-member of the structure pointed to by
-.IR preg .
-The
-.I re_endp
-member is of type
-.IR const\ char\ * .
-This flag permits inclusion of NULs in the RE;
-they are considered ordinary characters.
-This is an extension,
-compatible with but not specified by POSIX 1003.2,
-and should be used with
-caution in software intended to be portable to other systems.
-.PP
-When successful,
-.I regcomp
-returns 0 and fills in the structure pointed to by
-.IR preg .
-One member of that structure
-(other than
-.IR re_endp )
-is publicized:
-.IR re_nsub ,
-of type
-.IR size_t ,
-contains the number of parenthesized subexpressions within the RE
-(except that the value of this member is undefined if the
-REG_NOSUB flag was used).
-If
-.I regcomp
-fails, it returns a non-zero error code;
-see DIAGNOSTICS.
-.PP
-.I Regexec
-matches the compiled RE pointed to by
-.I preg
-against the
-.IR string ,
-subject to the flags in
-.IR eflags ,
-and reports results using
-.IR nmatch ,
-.IR pmatch ,
-and the returned value.
-The RE must have been compiled by a previous invocation of
-.IR regcomp .
-The compiled form is not altered during execution of
-.IR regexec ,
-so a single compiled RE can be used simultaneously by multiple threads.
-.PP
-By default,
-the NUL-terminated string pointed to by
-.I string
-is considered to be the text of an entire line, minus any terminating
-newline.
-The
-.I eflags
-argument is the bitwise OR of zero or more of the following flags:
-.IP REG_NOTBOL \w'REG_STARTEND'u+2n
-The first character of
-the string
-is not the beginning of a line, so the `^' anchor should not match before it.
-This does not affect the behavior of newlines under REG_NEWLINE.
-.IP REG_NOTEOL
-The NUL terminating
-the string
-does not end a line, so the `$' anchor should not match before it.
-This does not affect the behavior of newlines under REG_NEWLINE.
-.IP REG_STARTEND
-The string is considered to start at
-\fIstring\fR\ + \fIpmatch\fR[0].\fIrm_so\fR
-and to have a terminating NUL located at
-\fIstring\fR\ + \fIpmatch\fR[0].\fIrm_eo\fR
-(there need not actually be a NUL at that location),
-regardless of the value of
-.IR nmatch .
-See below for the definition of
-.IR pmatch
-and
-.IR nmatch .
-This is an extension,
-compatible with but not specified by POSIX 1003.2,
-and should be used with
-caution in software intended to be portable to other systems.
-Note that a non-zero \fIrm_so\fR does not imply REG_NOTBOL;
-REG_STARTEND affects only the location of the string,
-not how it is matched.
-.PP
-See
-.ZR
-for a discussion of what is matched in situations where an RE or a
-portion thereof could match any of several substrings of
-.IR string .
-.PP
-Normally,
-.I regexec
-returns 0 for success and the non-zero code REG_NOMATCH for failure.
-Other non-zero error codes may be returned in exceptional situations;
-see DIAGNOSTICS.
-.PP
-If REG_NOSUB was specified in the compilation of the RE,
-or if
-.I nmatch
-is 0,
-.I regexec
-ignores the
-.I pmatch
-argument (but see below for the case where REG_STARTEND is specified).
-Otherwise,
-.I pmatch
-points to an array of
-.I nmatch
-structures of type
-.IR regmatch_t .
-Such a structure has at least the members
-.I rm_so
-and
-.IR rm_eo ,
-both of type
-.I regoff_t
-(a signed arithmetic type at least as large as an
-.I off_t
-and a
-.IR ssize_t ),
-containing respectively the offset of the first character of a substring
-and the offset of the first character after the end of the substring.
-Offsets are measured from the beginning of the
-.I string
-argument given to
-.IR regexec .
-An empty substring is denoted by equal offsets,
-both indicating the character following the empty substring.
-.PP
-The 0th member of the
-.I pmatch
-array is filled in to indicate what substring of
-.I string
-was matched by the entire RE.
-Remaining members report what substring was matched by parenthesized
-subexpressions within the RE;
-member
-.I i
-reports subexpression
-.IR i ,
-with subexpressions counted (starting at 1) by the order of their opening
-parentheses in the RE, left to right.
-Unused entries in the array\(emcorresponding either to subexpressions that
-did not participate in the match at all, or to subexpressions that do not
-exist in the RE (that is, \fIi\fR\ > \fIpreg\fR\->\fIre_nsub\fR)\(emhave both
-.I rm_so
-and
-.I rm_eo
-set to \-1.
-If a subexpression participated in the match several times,
-the reported substring is the last one it matched.
-(Note, as an example in particular, that when the RE `(b*)+' matches `bbb',
-the parenthesized subexpression matches each of the three `b's and then
-an infinite number of empty strings following the last `b',
-so the reported substring is one of the empties.)
-.PP
-If REG_STARTEND is specified,
-.I pmatch
-must point to at least one
-.I regmatch_t
-(even if
-.I nmatch
-is 0 or REG_NOSUB was specified),
-to hold the input offsets for REG_STARTEND.
-Use for output is still entirely controlled by
-.IR nmatch ;
-if
-.I nmatch
-is 0 or REG_NOSUB was specified,
-the value of
-.IR pmatch [0]
-will not be changed by a successful
-.IR regexec .
-.PP
-.I Regerror
-maps a non-zero
-.I errcode
-from either
-.I regcomp
-or
-.I regexec
-to a human-readable, printable message.
-If
-.I preg
-is non-NULL,
-the error code should have arisen from use of
-the
-.I regex_t
-pointed to by
-.IR preg ,
-and if the error code came from
-.IR regcomp ,
-it should have been the result from the most recent
-.I regcomp
-using that
-.IR regex_t .
-.RI ( Regerror
-may be able to supply a more detailed message using information
-from the
-.IR regex_t .)
-.I Regerror
-places the NUL-terminated message into the buffer pointed to by
-.IR errbuf ,
-limiting the length (including the NUL) to at most
-.I errbuf_size
-bytes.
-If the whole message won't fit,
-as much of it as will fit before the terminating NUL is supplied.
-In any case,
-the returned value is the size of buffer needed to hold the whole
-message (including terminating NUL).
-If
-.I errbuf_size
-is 0,
-.I errbuf
-is ignored but the return value is still correct.
-.PP
-If the
-.I errcode
-given to
-.I regerror
-is first ORed with REG_ITOA,
-the ``message'' that results is the printable name of the error code,
-e.g. ``REG_NOMATCH'',
-rather than an explanation thereof.
-If
-.I errcode
-is REG_ATOI,
-then
-.I preg
-shall be non-NULL and the
-.I re_endp
-member of the structure it points to
-must point to the printable name of an error code;
-in this case, the result in
-.I errbuf
-is the decimal digits of
-the numeric value of the error code
-(0 if the name is not recognized).
-REG_ITOA and REG_ATOI are intended primarily as debugging facilities;
-they are extensions,
-compatible with but not specified by POSIX 1003.2,
-and should be used with
-caution in software intended to be portable to other systems.
-Be warned also that they are considered experimental and changes are possible.
-.PP
-.I Regfree
-frees any dynamically-allocated storage associated with the compiled RE
-pointed to by
-.IR preg .
-The remaining
-.I regex_t
-is no longer a valid compiled RE
-and the effect of supplying it to
-.I regexec
-or
-.I regerror
-is undefined.
-.PP
-None of these functions references global variables except for tables
-of constants;
-all are safe for use from multiple threads if the arguments are safe.
-.SH IMPLEMENTATION CHOICES
-There are a number of decisions that 1003.2 leaves up to the implementor,
-either by explicitly saying ``undefined'' or by virtue of them being
-forbidden by the RE grammar.
-This implementation treats them as follows.
-.PP
-See
-.ZR
-for a discussion of the definition of case-independent matching.
-.PP
-There is no particular limit on the length of REs,
-except insofar as memory is limited.
-Memory usage is approximately linear in RE size, and largely insensitive
-to RE complexity, except for bounded repetitions.
-See BUGS for one short RE using them
-that will run almost any system out of memory.
-.PP
-A backslashed character other than one specifically given a magic meaning
-by 1003.2 (such magic meanings occur only in obsolete [``basic''] REs)
-is taken as an ordinary character.
-.PP
-Any unmatched [ is a REG_EBRACK error.
-.PP
-Equivalence classes cannot begin or end bracket-expression ranges.
-The endpoint of one range cannot begin another.
-.PP
-RE_DUP_MAX, the limit on repetition counts in bounded repetitions, is 255.
-.PP
-A repetition operator (?, *, +, or bounds) cannot follow another
-repetition operator.
-A repetition operator cannot begin an expression or subexpression
-or follow `^' or `|'.
-.PP
-`|' cannot appear first or last in a (sub)expression or after another `|',
-i.e. an operand of `|' cannot be an empty subexpression.
-An empty parenthesized subexpression, `()', is legal and matches an
-empty (sub)string.
-An empty string is not a legal RE.
-.PP
-A `{' followed by a digit is considered the beginning of bounds for a
-bounded repetition, which must then follow the syntax for bounds.
-A `{' \fInot\fR followed by a digit is considered an ordinary character.
-.PP
-`^' and `$' beginning and ending subexpressions in obsolete (``basic'')
-REs are anchors, not ordinary characters.
-.SH SEE ALSO
-grep(1), regex(7)
-.PP
-POSIX 1003.2, sections 2.8 (Regular Expression Notation)
-and
-B.5 (C Binding for Regular Expression Matching).
-.SH DIAGNOSTICS
-Non-zero error codes from
-.I regcomp
-and
-.I regexec
-include the following:
-.PP
-.nf
-.ta \w'REG_ECOLLATE'u+3n
-REG_NOMATCH regexec() failed to match
-REG_BADPAT invalid regular expression
-REG_ECOLLATE invalid collating element
-REG_ECTYPE invalid character class
-REG_EESCAPE \e applied to unescapable character
-REG_ESUBREG invalid backreference number
-REG_EBRACK brackets [ ] not balanced
-REG_EPAREN parentheses ( ) not balanced
-REG_EBRACE braces { } not balanced
-REG_BADBR invalid repetition count(s) in { }
-REG_ERANGE invalid character range in [ ]
-REG_ESPACE ran out of memory
-REG_BADRPT ?, *, or + operand invalid
-REG_EMPTY empty (sub)expression
-REG_ASSERT ``can't happen''\(emyou found a bug
-REG_INVARG invalid argument, e.g. negative-length string
-.fi
-.SH HISTORY
-Written by Henry Spencer at University of Toronto,
-henry@zoo.toronto.edu.
-.SH BUGS
-This is an alpha release with known defects.
-Please report problems.
-.PP
-There is one known functionality bug.
-The implementation of internationalization is incomplete:
-the locale is always assumed to be the default one of 1003.2,
-and only the collating elements etc. of that locale are available.
-.PP
-The back-reference code is subtle and doubts linger about its correctness
-in complex cases.
-.PP
-.I Regexec
-performance is poor.
-This will improve with later releases.
-.I Nmatch
-exceeding 0 is expensive;
-.I nmatch
-exceeding 1 is worse.
-.I Regexec
-is largely insensitive to RE complexity \fIexcept\fR that back
-references are massively expensive.
-RE length does matter; in particular, there is a strong speed bonus
-for keeping RE length under about 30 characters,
-with most special characters counting roughly double.
-.PP
-.I Regcomp
-implements bounded repetitions by macro expansion,
-which is costly in time and space if counts are large
-or bounded repetitions are nested.
-An RE like, say,
-`((((a{1,100}){1,100}){1,100}){1,100}){1,100}'
-will (eventually) run almost any existing machine out of swap space.
-.PP
-There are suspected problems with response to obscure error conditions.
-Notably,
-certain kinds of internal overflow,
-produced only by truly enormous REs or by multiply nested bounded repetitions,
-are probably not handled well.
-.PP
-Due to a mistake in 1003.2, things like `a)b' are legal REs because `)' is
-a special character only in the presence of a previous unmatched `('.
-This can't be fixed until the spec is fixed.
-.PP
-The standard's definition of back references is vague.
-For example, does
-`a\e(\e(b\e)*\e2\e)*d' match `abbbd'?
-Until the standard is clarified,
-behavior in such cases should not be relied on.
-.PP
-The implementation of word-boundary matching is a bit of a kludge,
-and bugs may lurk in combinations of word-boundary matching and anchoring.
diff --git a/regex/regex.7 b/regex/regex.7
deleted file mode 100644
index d89012bda1..0000000000
--- a/regex/regex.7
+++ /dev/null
@@ -1,233 +0,0 @@
-.TH REGEX 7 "7 Feb 1994"
-.BY "Henry Spencer"
-.SH NAME
-regex \- POSIX 1003.2 regular expressions
-.SH DESCRIPTION
-Regular expressions (``RE''s),
-as defined in POSIX 1003.2, come in two forms:
-modern REs (roughly those of
-.IR egrep ;
-1003.2 calls these ``extended'' REs)
-and obsolete REs (roughly those of
-.IR ed ;
-1003.2 ``basic'' REs).
-Obsolete REs mostly exist for backward compatibility in some old programs;
-they will be discussed at the end.
-1003.2 leaves some aspects of RE syntax and semantics open;
-`\(dg' marks decisions on these aspects that
-may not be fully portable to other 1003.2 implementations.
-.PP
-A (modern) RE is one\(dg or more non-empty\(dg \fIbranches\fR,
-separated by `|'.
-It matches anything that matches one of the branches.
-.PP
-A branch is one\(dg or more \fIpieces\fR, concatenated.
-It matches a match for the first, followed by a match for the second, etc.
-.PP
-A piece is an \fIatom\fR possibly followed
-by a single\(dg `*', `+', `?', or \fIbound\fR.
-An atom followed by `*' matches a sequence of 0 or more matches of the atom.
-An atom followed by `+' matches a sequence of 1 or more matches of the atom.
-An atom followed by `?' matches a sequence of 0 or 1 matches of the atom.
-.PP
-A \fIbound\fR is `{' followed by an unsigned decimal integer,
-possibly followed by `,'
-possibly followed by another unsigned decimal integer,
-always followed by `}'.
-The integers must lie between 0 and RE_DUP_MAX (255\(dg) inclusive,
-and if there are two of them, the first may not exceed the second.
-An atom followed by a bound containing one integer \fIi\fR
-and no comma matches
-a sequence of exactly \fIi\fR matches of the atom.
-An atom followed by a bound
-containing one integer \fIi\fR and a comma matches
-a sequence of \fIi\fR or more matches of the atom.
-An atom followed by a bound
-containing two integers \fIi\fR and \fIj\fR matches
-a sequence of \fIi\fR through \fIj\fR (inclusive) matches of the atom.
-.PP
-An atom is a regular expression enclosed in `()' (matching a match for the
-regular expression),
-an empty set of `()' (matching the null string)\(dg,
-a \fIbracket expression\fR (see below), `.'
-(matching any single character), `^' (matching the null string at the
-beginning of a line), `$' (matching the null string at the
-end of a line), a `\e' followed by one of the characters
-`^.[$()|*+?{\e'
-(matching that character taken as an ordinary character),
-a `\e' followed by any other character\(dg
-(matching that character taken as an ordinary character,
-as if the `\e' had not been present\(dg),
-or a single character with no other significance (matching that character).
-A `{' followed by a character other than a digit is an ordinary
-character, not the beginning of a bound\(dg.
-It is illegal to end an RE with `\e'.
-.PP
-A \fIbracket expression\fR is a list of characters enclosed in `[]'.
-It normally matches any single character from the list (but see below).
-If the list begins with `^',
-it matches any single character
-(but see below) \fInot\fR from the rest of the list.
-If two characters in the list are separated by `\-', this is shorthand
-for the full \fIrange\fR of characters between those two (inclusive) in the
-collating sequence,
-e.g. `[0-9]' in ASCII matches any decimal digit.
-It is illegal\(dg for two ranges to share an
-endpoint, e.g. `a-c-e'.
-Ranges are very collating-sequence-dependent,
-and portable programs should avoid relying on them.
-.PP
-To include a literal `]' in the list, make it the first character
-(following a possible `^').
-To include a literal `\-', make it the first or last character,
-or the second endpoint of a range.
-To use a literal `\-' as the first endpoint of a range,
-enclose it in `[.' and `.]' to make it a collating element (see below).
-With the exception of these and some combinations using `[' (see next
-paragraphs), all other special characters, including `\e', lose their
-special significance within a bracket expression.
-.PP
-Within a bracket expression, a collating element (a character,
-a multi-character sequence that collates as if it were a single character,
-or a collating-sequence name for either)
-enclosed in `[.' and `.]' stands for the
-sequence of characters of that collating element.
-The sequence is a single element of the bracket expression's list.
-A bracket expression containing a multi-character collating element
-can thus match more than one character,
-e.g. if the collating sequence includes a `ch' collating element,
-then the RE `[[.ch.]]*c' matches the first five characters
-of `chchcc'.
-.PP
-Within a bracket expression, a collating element enclosed in `[=' and
-`=]' is an equivalence class, standing for the sequences of characters
-of all collating elements equivalent to that one, including itself.
-(If there are no other equivalent collating elements,
-the treatment is as if the enclosing delimiters were `[.' and `.]'.)
-For example, if o and \o'o^' are the members of an equivalence class,
-then `[[=o=]]', `[[=\o'o^'=]]', and `[o\o'o^']' are all synonymous.
-An equivalence class may not\(dg be an endpoint
-of a range.
-.PP
-Within a bracket expression, the name of a \fIcharacter class\fR enclosed
-in `[:' and `:]' stands for the list of all characters belonging to that
-class.
-Standard character class names are:
-.PP
-.RS
-.nf
-.ta 3c 6c 9c
-alnum digit punct
-alpha graph space
-blank lower upper
-cntrl print xdigit
-.fi
-.RE
-.PP
-These stand for the character classes defined in
-.IR ctype (3).
-A locale may provide others.
-A character class may not be used as an endpoint of a range.
-.PP
-There are two special cases\(dg of bracket expressions:
-the bracket expressions `[[:<:]]' and `[[:>:]]' match the null string at
-the beginning and end of a word respectively.
-A word is defined as a sequence of
-word characters
-which is neither preceded nor followed by
-word characters.
-A word character is an
-.I alnum
-character (as defined by
-.IR ctype (3))
-or an underscore.
-This is an extension,
-compatible with but not specified by POSIX 1003.2,
-and should be used with
-caution in software intended to be portable to other systems.
-.PP
-In the event that an RE could match more than one substring of a given
-string,
-the RE matches the one starting earliest in the string.
-If the RE could match more than one substring starting at that point,
-it matches the longest.
-Subexpressions also match the longest possible substrings, subject to
-the constraint that the whole match be as long as possible,
-with subexpressions starting earlier in the RE taking priority over
-ones starting later.
-Note that higher-level subexpressions thus take priority over
-their lower-level component subexpressions.
-.PP
-Match lengths are measured in characters, not collating elements.
-A null string is considered longer than no match at all.
-For example,
-`bb*' matches the three middle characters of `abbbc',
-`(wee|week)(knights|nights)' matches all ten characters of `weeknights',
-when `(.*).*' is matched against `abc' the parenthesized subexpression
-matches all three characters, and
-when `(a*)*' is matched against `bc' both the whole RE and the parenthesized
-subexpression match the null string.
-.PP
-If case-independent matching is specified,
-the effect is much as if all case distinctions had vanished from the
-alphabet.
-When an alphabetic that exists in multiple cases appears as an
-ordinary character outside a bracket expression, it is effectively
-transformed into a bracket expression containing both cases,
-e.g. `x' becomes `[xX]'.
-When it appears inside a bracket expression, all case counterparts
-of it are added to the bracket expression, so that (e.g.) `[x]'
-becomes `[xX]' and `[^x]' becomes `[^xX]'.
-.PP
-No particular limit is imposed on the length of REs\(dg.
-Programs intended to be portable should not employ REs longer
-than 256 bytes,
-as an implementation can refuse to accept such REs and remain
-POSIX-compliant.
-.PP
-Obsolete (``basic'') regular expressions differ in several respects.
-`|', `+', and `?' are ordinary characters and there is no equivalent
-for their functionality.
-The delimiters for bounds are `\e{' and `\e}',
-with `{' and `}' by themselves ordinary characters.
-The parentheses for nested subexpressions are `\e(' and `\e)',
-with `(' and `)' by themselves ordinary characters.
-`^' is an ordinary character except at the beginning of the
-RE or\(dg the beginning of a parenthesized subexpression,
-`$' is an ordinary character except at the end of the
-RE or\(dg the end of a parenthesized subexpression,
-and `*' is an ordinary character if it appears at the beginning of the
-RE or the beginning of a parenthesized subexpression
-(after a possible leading `^').
-Finally, there is one new type of atom, a \fIback reference\fR:
-`\e' followed by a non-zero decimal digit \fId\fR
-matches the same sequence of characters
-matched by the \fId\fRth parenthesized subexpression
-(numbering subexpressions by the positions of their opening parentheses,
-left to right),
-so that (e.g.) `\e([bc]\e)\e1' matches `bb' or `cc' but not `bc'.
-.SH SEE ALSO
-regex(3)
-.PP
-POSIX 1003.2, section 2.8 (Regular Expression Notation).
-.SH BUGS
-Having two kinds of REs is a botch.
-.PP
-The current 1003.2 spec says that `)' is an ordinary character in
-the absence of an unmatched `(';
-this was an unintentional result of a wording error,
-and change is likely.
-Avoid relying on it.
-.PP
-Back references are a dreadful botch,
-posing major problems for efficient implementations.
-They are also somewhat vaguely defined
-(does
-`a\e(\e(b\e)*\e2\e)*d' match `abbbd'?).
-Avoid using them.
-.PP
-1003.2's specification of case-independent matching is vague.
-The ``one case implies all cases'' definition given above
-is current consensus among implementors as to the right interpretation.
-.PP
-The syntax for word boundaries is incredibly ugly.
diff --git a/regex/regex.dsp b/regex/regex.dsp
deleted file mode 100644
index e8f1ad4299..0000000000
--- a/regex/regex.dsp
+++ /dev/null
@@ -1,106 +0,0 @@
-# Microsoft Developer Studio Project File - Name="regex" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=regex - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "regex.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "regex.mak" CFG="regex - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "regex - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "regex - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "regex - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-
-!ELSEIF "$(CFG)" == "regex - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "." /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "regex - Win32 Release"
-# Name "regex - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\regcomp.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\regerror.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\regexec.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\regfree.c
-# End Source File
-# End Target
-# End Project
diff --git a/regex/regex.dsw b/regex/regex.dsw
deleted file mode 100644
index 7b7df8126c..0000000000
--- a/regex/regex.dsw
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 5.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "regex"=.\regex.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/regex/regex.h b/regex/regex.h
deleted file mode 100644
index 5645eb6aa3..0000000000
--- a/regex/regex.h
+++ /dev/null
@@ -1,79 +0,0 @@
-#ifndef _REGEX_H_
-#define _REGEX_H_ /* never again */
-/* ========= begin header generated by ././mkh ========= */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* === regex2.h === */
-#ifdef WIN32
-#define API_EXPORT(type) __declspec(dllexport) type __stdcall
-#else
-#define API_EXPORT(type) type
-#endif
-
-typedef off_t regoff_t;
-typedef struct {
- int re_magic;
- size_t re_nsub; /* number of parenthesized subexpressions */
- const char *re_endp; /* end pointer for REG_PEND */
- struct re_guts *re_g; /* none of your business :-) */
-} regex_t;
-typedef struct {
- regoff_t rm_so; /* start of match */
- regoff_t rm_eo; /* end of match */
-} regmatch_t;
-
-
-/* === regcomp.c === */
-API_EXPORT(int) regcomp(regex_t *, const char *, int);
-#define REG_BASIC 0000
-#define REG_EXTENDED 0001
-#define REG_ICASE 0002
-#define REG_NOSUB 0004
-#define REG_NEWLINE 0010
-#define REG_NOSPEC 0020
-#define REG_PEND 0040
-#define REG_DUMP 0200
-
-
-/* === regerror.c === */
-#define REG_NOMATCH 1
-#define REG_BADPAT 2
-#define REG_ECOLLATE 3
-#define REG_ECTYPE 4
-#define REG_EESCAPE 5
-#define REG_ESUBREG 6
-#define REG_EBRACK 7
-#define REG_EPAREN 8
-#define REG_EBRACE 9
-#define REG_BADBR 10
-#define REG_ERANGE 11
-#define REG_ESPACE 12
-#define REG_BADRPT 13
-#define REG_EMPTY 14
-#define REG_ASSERT 15
-#define REG_INVARG 16
-#define REG_ATOI 255 /* convert name to number (!) */
-#define REG_ITOA 0400 /* convert number to name (!) */
-API_EXPORT(size_t) regerror(int, const regex_t *, char *, size_t);
-
-
-/* === regexec.c === */
-API_EXPORT(int) regexec(const regex_t *, const char *, size_t, regmatch_t [], int);
-#define REG_NOTBOL 00001
-#define REG_NOTEOL 00002
-#define REG_STARTEND 00004
-#define REG_TRACE 00400 /* tracing of execution */
-#define REG_LARGE 01000 /* force large representation */
-#define REG_BACKR 02000 /* force use of backref code */
-
-
-/* === regfree.c === */
-API_EXPORT(void) regfree(regex_t *);
-
-#ifdef __cplusplus
-}
-#endif
-/* ========= end header generated by ././mkh ========= */
-#endif
diff --git a/regex/regex.mak b/regex/regex.mak
deleted file mode 100644
index b87ded340b..0000000000
--- a/regex/regex.mak
+++ /dev/null
@@ -1,304 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on regex.dsp
-!IF "$(CFG)" == ""
-CFG=regex - Win32 Release
-!MESSAGE No configuration specified. Defaulting to regex - Win32 Release.
-!ENDIF
-
-!IF "$(CFG)" != "regex - Win32 Release" && "$(CFG)" != "regex - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "regex.mak" CFG="regex - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "regex - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "regex - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-CPP=cl.exe
-
-!IF "$(CFG)" == "regex - Win32 Release"
-
-OUTDIR=.\Release
-INTDIR=.\Release
-# Begin Custom Macros
-OutDir=.\.\Release
-# End Custom Macros
-
-!IF "$(RECURSE)" == "0"
-
-ALL : "$(OUTDIR)\regex.lib"
-
-!ELSE
-
-ALL : "$(OUTDIR)\regex.lib"
-
-!ENDIF
-
-CLEAN :
- -@erase "$(INTDIR)\regcomp.obj"
- -@erase "$(INTDIR)\regerror.obj"
- -@erase "$(INTDIR)\regexec.obj"
- -@erase "$(INTDIR)\regfree.obj"
- -@erase "$(INTDIR)\vc50.idb"
- -@erase "$(OUTDIR)\regex.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "." /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
- /Fp"$(INTDIR)\regex.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-CPP_OBJS=.\Release/
-CPP_SBRS=.
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\regex.bsc"
-BSC32_SBRS= \
-
-LIB32=link.exe -lib
-LIB32_FLAGS=/nologo /out:"$(OUTDIR)\regex.lib"
-LIB32_OBJS= \
- "$(INTDIR)\regcomp.obj" \
- "$(INTDIR)\regerror.obj" \
- "$(INTDIR)\regexec.obj" \
- "$(INTDIR)\regfree.obj"
-
-"$(OUTDIR)\regex.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
- $(LIB32) @<<
- $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "regex - Win32 Debug"
-
-OUTDIR=.\Debug
-INTDIR=.\Debug
-# Begin Custom Macros
-OutDir=.\.\Debug
-# End Custom Macros
-
-!IF "$(RECURSE)" == "0"
-
-ALL : "$(OUTDIR)\regex.lib" "$(OUTDIR)\regex.bsc"
-
-!ELSE
-
-ALL : "$(OUTDIR)\regex.lib" "$(OUTDIR)\regex.bsc"
-
-!ENDIF
-
-CLEAN :
- -@erase "$(INTDIR)\regcomp.obj"
- -@erase "$(INTDIR)\regcomp.sbr"
- -@erase "$(INTDIR)\regerror.obj"
- -@erase "$(INTDIR)\regerror.sbr"
- -@erase "$(INTDIR)\regexec.obj"
- -@erase "$(INTDIR)\regexec.sbr"
- -@erase "$(INTDIR)\regfree.obj"
- -@erase "$(INTDIR)\regfree.sbr"
- -@erase "$(INTDIR)\vc50.idb"
- -@erase "$(OUTDIR)\regex.bsc"
- -@erase "$(OUTDIR)\regex.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP_PROJ=/nologo /MDd /W3 /GX /Z7 /Od /I "." /D "WIN32" /D "_DEBUG" /D\
- "_WINDOWS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\regex.pch" /YX /Fo"$(INTDIR)\\"\
- /Fd"$(INTDIR)\\" /FD /c
-CPP_OBJS=.\Debug/
-CPP_SBRS=.\Debug/
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\regex.bsc"
-BSC32_SBRS= \
- "$(INTDIR)\regcomp.sbr" \
- "$(INTDIR)\regerror.sbr" \
- "$(INTDIR)\regexec.sbr" \
- "$(INTDIR)\regfree.sbr"
-
-"$(OUTDIR)\regex.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
- $(BSC32) @<<
- $(BSC32_FLAGS) $(BSC32_SBRS)
-<<
-
-LIB32=link.exe -lib
-LIB32_FLAGS=/nologo /out:"$(OUTDIR)\regex.lib"
-LIB32_OBJS= \
- "$(INTDIR)\regcomp.obj" \
- "$(INTDIR)\regerror.obj" \
- "$(INTDIR)\regexec.obj" \
- "$(INTDIR)\regfree.obj"
-
-"$(OUTDIR)\regex.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
- $(LIB32) @<<
- $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
-<<
-
-!ENDIF
-
-.c{$(CPP_OBJS)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(CPP_OBJS)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(CPP_OBJS)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(CPP_SBRS)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(CPP_SBRS)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(CPP_SBRS)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-
-!IF "$(CFG)" == "regex - Win32 Release" || "$(CFG)" == "regex - Win32 Debug"
-SOURCE=.\regcomp.c
-
-!IF "$(CFG)" == "regex - Win32 Release"
-
-DEP_CPP_REGCO=\
- ".\cclass.h"\
- ".\cname.h"\
- ".\regcomp.ih"\
- ".\regex.h"\
- ".\regex2.h"\
- ".\utils.h"\
-
-
-"$(INTDIR)\regcomp.obj" : $(SOURCE) $(DEP_CPP_REGCO) "$(INTDIR)"
-
-
-!ELSEIF "$(CFG)" == "regex - Win32 Debug"
-
-DEP_CPP_REGCO=\
- ".\cclass.h"\
- ".\cname.h"\
- ".\regcomp.ih"\
- ".\regex.h"\
- ".\regex2.h"\
- ".\utils.h"\
- {$(INCLUDE)}"sys\types.h"\
-
-
-"$(INTDIR)\regcomp.obj" "$(INTDIR)\regcomp.sbr" : $(SOURCE) $(DEP_CPP_REGCO)\
- "$(INTDIR)"
-
-
-!ENDIF
-
-SOURCE=.\regerror.c
-
-!IF "$(CFG)" == "regex - Win32 Release"
-
-DEP_CPP_REGER=\
- ".\regerror.ih"\
- ".\regex.h"\
- ".\utils.h"\
-
-
-"$(INTDIR)\regerror.obj" : $(SOURCE) $(DEP_CPP_REGER) "$(INTDIR)"
-
-
-!ELSEIF "$(CFG)" == "regex - Win32 Debug"
-
-DEP_CPP_REGER=\
- ".\regerror.ih"\
- ".\regex.h"\
- ".\utils.h"\
- {$(INCLUDE)}"sys\types.h"\
-
-
-"$(INTDIR)\regerror.obj" "$(INTDIR)\regerror.sbr" : $(SOURCE) $(DEP_CPP_REGER)\
- "$(INTDIR)"
-
-
-!ENDIF
-
-SOURCE=.\regexec.c
-
-!IF "$(CFG)" == "regex - Win32 Release"
-
-DEP_CPP_REGEX=\
- ".\engine.c"\
- ".\engine.ih"\
- ".\regex.h"\
- ".\regex2.h"\
- ".\utils.h"\
-
-
-"$(INTDIR)\regexec.obj" : $(SOURCE) $(DEP_CPP_REGEX) "$(INTDIR)"
-
-
-!ELSEIF "$(CFG)" == "regex - Win32 Debug"
-
-DEP_CPP_REGEX=\
- ".\engine.c"\
- ".\engine.ih"\
- ".\regex.h"\
- ".\regex2.h"\
- ".\utils.h"\
- {$(INCLUDE)}"sys\types.h"\
-
-
-"$(INTDIR)\regexec.obj" "$(INTDIR)\regexec.sbr" : $(SOURCE) $(DEP_CPP_REGEX)\
- "$(INTDIR)"
-
-
-!ENDIF
-
-SOURCE=.\regfree.c
-
-!IF "$(CFG)" == "regex - Win32 Release"
-
-DEP_CPP_REGFR=\
- ".\regex.h"\
- ".\regex2.h"\
- ".\utils.h"\
-
-
-"$(INTDIR)\regfree.obj" : $(SOURCE) $(DEP_CPP_REGFR) "$(INTDIR)"
-
-
-!ELSEIF "$(CFG)" == "regex - Win32 Debug"
-
-DEP_CPP_REGFR=\
- ".\regex.h"\
- ".\regex2.h"\
- ".\utils.h"\
- {$(INCLUDE)}"sys\types.h"\
-
-
-"$(INTDIR)\regfree.obj" "$(INTDIR)\regfree.sbr" : $(SOURCE) $(DEP_CPP_REGFR)\
- "$(INTDIR)"
-
-
-!ENDIF
-
-SOURCE=.\engine.c
-
-!ENDIF
-
diff --git a/regex/regex2.h b/regex/regex2.h
deleted file mode 100644
index 3e8c0d65c4..0000000000
--- a/regex/regex2.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * First, the stuff that ends up in the outside-world include file
- = #ifdef WIN32
- = #define API_EXPORT(type) __declspec(dllexport) type __stdcall
- = #else
- = #define API_EXPORT(type) type
- = #endif
- =
- = typedef off_t regoff_t;
- = typedef struct {
- = int re_magic;
- = size_t re_nsub; // number of parenthesized subexpressions
- = const char *re_endp; // end pointer for REG_PEND
- = struct re_guts *re_g; // none of your business :-)
- = } regex_t;
- = typedef struct {
- = regoff_t rm_so; // start of match
- = regoff_t rm_eo; // end of match
- = } regmatch_t;
- */
-/*
- * internals of regex_t
- */
-#define MAGIC1 ((('r'^0200)<<8) | 'e')
-
-/*
- * The internal representation is a *strip*, a sequence of
- * operators ending with an endmarker. (Some terminology etc. is a
- * historical relic of earlier versions which used multiple strips.)
- * Certain oddities in the representation are there to permit running
- * the machinery backwards; in particular, any deviation from sequential
- * flow must be marked at both its source and its destination. Some
- * fine points:
- *
- * - OPLUS_ and O_PLUS are *inside* the loop they create.
- * - OQUEST_ and O_QUEST are *outside* the bypass they create.
- * - OCH_ and O_CH are *outside* the multi-way branch they create, while
- * OOR1 and OOR2 are respectively the end and the beginning of one of
- * the branches. Note that there is an implicit OOR2 following OCH_
- * and an implicit OOR1 preceding O_CH.
- *
- * In state representations, an operator's bit is on to signify a state
- * immediately *preceding* "execution" of that operator.
- */
-typedef unsigned long sop; /* strip operator */
-typedef long sopno;
-#define OPRMASK 0xf8000000
-#define OPDMASK 0x07ffffff
-#define OPSHIFT ((unsigned)27)
-#define OP(n) ((n)&OPRMASK)
-#define OPND(n) ((n)&OPDMASK)
-#define SOP(op, opnd) ((op)|(opnd))
-/* operators meaning operand */
-/* (back, fwd are offsets) */
-#define OEND (1<<OPSHIFT) /* endmarker - */
-#define OCHAR (2<<OPSHIFT) /* character unsigned char */
-#define OBOL (3<<OPSHIFT) /* left anchor - */
-#define OEOL (4<<OPSHIFT) /* right anchor - */
-#define OANY (5<<OPSHIFT) /* . - */
-#define OANYOF (6<<OPSHIFT) /* [...] set number */
-#define OBACK_ (7<<OPSHIFT) /* begin \d paren number */
-#define O_BACK (8<<OPSHIFT) /* end \d paren number */
-#define OPLUS_ (9<<OPSHIFT) /* + prefix fwd to suffix */
-#define O_PLUS (10<<OPSHIFT) /* + suffix back to prefix */
-#define OQUEST_ (11<<OPSHIFT) /* ? prefix fwd to suffix */
-#define O_QUEST (12<<OPSHIFT) /* ? suffix back to prefix */
-#define OLPAREN (13<<OPSHIFT) /* ( fwd to ) */
-#define ORPAREN (14<<OPSHIFT) /* ) back to ( */
-#define OCH_ (15<<OPSHIFT) /* begin choice fwd to OOR2 */
-#define OOR1 (16u<<OPSHIFT) /* | pt. 1 back to OOR1 or OCH_ */
-#define OOR2 (17u<<OPSHIFT) /* | pt. 2 fwd to OOR2 or O_CH */
-#define O_CH (18u<<OPSHIFT) /* end choice back to OOR1 */
-#define OBOW (19u<<OPSHIFT) /* begin word - */
-#define OEOW (20u<<OPSHIFT) /* end word - */
-
-/*
- * Structure for [] character-set representation. Character sets are
- * done as bit vectors, grouped 8 to a byte vector for compactness.
- * The individual set therefore has both a pointer to the byte vector
- * and a mask to pick out the relevant bit of each byte. A hash code
- * simplifies testing whether two sets could be identical.
- *
- * This will get trickier for multicharacter collating elements. As
- * preliminary hooks for dealing with such things, we also carry along
- * a string of multi-character elements, and decide the size of the
- * vectors at run time.
- */
-typedef struct {
- uch *ptr; /* -> uch [csetsize] */
- uch mask; /* bit within array */
- uch hash; /* hash code */
- size_t smultis;
- char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */
-} cset;
-/* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */
-#define CHadd(cs, c) ((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c))
-#define CHsub(cs, c) ((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c))
-#define CHIN(cs, c) ((cs)->ptr[(uch)(c)] & (cs)->mask)
-#define MCadd(p, cs, cp) mcadd(p, cs, cp) /* regcomp() internal fns */
-
-/* stuff for character categories */
-typedef unsigned char cat_t;
-
-/*
- * main compiled-expression structure
- */
-struct re_guts {
- int magic;
-# define MAGIC2 ((('R'^0200)<<8)|'E')
- sop *strip; /* malloced area for strip */
- int csetsize; /* number of bits in a cset vector */
- int ncsets; /* number of csets in use */
- cset *sets; /* -> cset [ncsets] */
- uch *setbits; /* -> uch[csetsize][ncsets/CHAR_BIT] */
- int cflags; /* copy of regcomp() cflags argument */
- sopno nstates; /* = number of sops */
- sopno firststate; /* the initial OEND (normally 0) */
- sopno laststate; /* the final OEND */
- int iflags; /* internal flags */
-# define USEBOL 01 /* used ^ */
-# define USEEOL 02 /* used $ */
-# define BAD 04 /* something wrong */
- int nbol; /* number of ^ used */
- int neol; /* number of $ used */
- int ncategories; /* how many character categories */
- cat_t *categories; /* ->catspace[-CHAR_MIN] */
- char *must; /* match must contain this string */
- int mlen; /* length of must */
- size_t nsub; /* copy of re_nsub */
- int backrefs; /* does it use back references? */
- sopno nplus; /* how deep does it nest +s? */
- /* catspace must be last */
- cat_t catspace[1]; /* actually [NC] */
-};
-
-/* misc utilities */
-#define OUT (CHAR_MAX+1) /* a non-character value */
-#define ISWORD(c) (isalnum(c) || (c) == '_')
diff --git a/regex/regexec.c b/regex/regexec.c
deleted file mode 100644
index a552f5a394..0000000000
--- a/regex/regexec.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * the outer shell of regexec()
- *
- * This file includes engine.c *twice*, after muchos fiddling with the
- * macros that code uses. This lets the same code operate on two different
- * representations for state sets.
- */
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <ctype.h>
-#include <regex.h>
-
-#include "utils.h"
-#include "regex2.h"
-
-#ifndef NDEBUG
-static int nope = 0; /* for use in asserts; shuts lint up */
-#endif
-
-/* macros for manipulating states, small version */
-#define states long
-#define states1 states /* for later use in regexec() decision */
-#define CLEAR(v) ((v) = 0)
-#define SET0(v, n) ((v) &= ~(1 << (n)))
-#define SET1(v, n) ((v) |= 1 << (n))
-#define ISSET(v, n) ((v) & (1 << (n)))
-#define ASSIGN(d, s) ((d) = (s))
-#define EQ(a, b) ((a) == (b))
-#define STATEVARS int dummy /* dummy version */
-#define STATESETUP(m, n) /* nothing */
-#define STATETEARDOWN(m) /* nothing */
-#define SETUP(v) ((v) = 0)
-#define onestate int
-#define INIT(o, n) ((o) = (unsigned)1 << (n))
-#define INC(o) ((o) <<= 1)
-#define ISSTATEIN(v, o) ((v) & (o))
-/* some abbreviations; note that some of these know variable names! */
-/* do "if I'm here, I can also be there" etc without branches */
-#define FWD(dst, src, n) ((dst) |= ((unsigned)(src)&(here)) << (n))
-#define BACK(dst, src, n) ((dst) |= ((unsigned)(src)&(here)) >> (n))
-#define ISSETBACK(v, n) ((v) & ((unsigned)here >> (n)))
-/* function names */
-#define SNAMES /* engine.c looks after details */
-
-#include "engine.c"
-
-/* now undo things */
-#undef states
-#undef CLEAR
-#undef SET0
-#undef SET1
-#undef ISSET
-#undef ASSIGN
-#undef EQ
-#undef STATEVARS
-#undef STATESETUP
-#undef STATETEARDOWN
-#undef SETUP
-#undef onestate
-#undef INIT
-#undef INC
-#undef ISSTATEIN
-#undef FWD
-#undef BACK
-#undef ISSETBACK
-#undef SNAMES
-
-/* macros for manipulating states, large version */
-#define states char *
-#define CLEAR(v) memset(v, 0, m->g->nstates)
-#define SET0(v, n) ((v)[n] = 0)
-#define SET1(v, n) ((v)[n] = 1)
-#define ISSET(v, n) ((v)[n])
-#define ASSIGN(d, s) memcpy(d, s, m->g->nstates)
-#define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0)
-#define STATEVARS int vn; char *space
-#define STATESETUP(m, nv) { (m)->space = malloc((nv)*(m)->g->nstates); \
- if ((m)->space == NULL) return(REG_ESPACE); \
- (m)->vn = 0; }
-#define STATETEARDOWN(m) { free((m)->space); }
-#define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates])
-#define onestate int
-#define INIT(o, n) ((o) = (n))
-#define INC(o) ((o)++)
-#define ISSTATEIN(v, o) ((v)[o])
-/* some abbreviations; note that some of these know variable names! */
-/* do "if I'm here, I can also be there" etc without branches */
-#define FWD(dst, src, n) ((dst)[here+(n)] |= (src)[here])
-#define BACK(dst, src, n) ((dst)[here-(n)] |= (src)[here])
-#define ISSETBACK(v, n) ((v)[here - (n)])
-/* function names */
-#define LNAMES /* flag */
-
-#include "engine.c"
-
-/*
- - regexec - interface for matching
- = API_EXPORT(int) regexec(const regex_t *, const char *, size_t, \
- = regmatch_t [], int);
- = #define REG_NOTBOL 00001
- = #define REG_NOTEOL 00002
- = #define REG_STARTEND 00004
- = #define REG_TRACE 00400 // tracing of execution
- = #define REG_LARGE 01000 // force large representation
- = #define REG_BACKR 02000 // force use of backref code
- *
- * We put this here so we can exploit knowledge of the state representation
- * when choosing which matcher to call. Also, by this point the matchers
- * have been prototyped.
- */
-API_EXPORT(int) /* 0 success, REG_NOMATCH failure */
-regexec(preg, string, nmatch, pmatch, eflags)
-const regex_t *preg;
-const char *string;
-size_t nmatch;
-regmatch_t pmatch[];
-int eflags;
-{
- register struct re_guts *g = preg->re_g;
-#ifdef REDEBUG
-# define GOODFLAGS(f) (f)
-#else
-# define GOODFLAGS(f) ((f)&(REG_NOTBOL|REG_NOTEOL|REG_STARTEND))
-#endif
-
- if (preg->re_magic != MAGIC1 || g->magic != MAGIC2)
- return(REG_BADPAT);
- assert(!(g->iflags&BAD));
- if (g->iflags&BAD) /* backstop for no-debug case */
- return(REG_BADPAT);
- eflags = GOODFLAGS(eflags);
-
- if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags&REG_LARGE))
- return(smatcher(g, (char *)string, nmatch, pmatch, eflags));
- else
- return(lmatcher(g, (char *)string, nmatch, pmatch, eflags));
-}
diff --git a/regex/regfree.c b/regex/regfree.c
deleted file mode 100644
index 9fd618a13b..0000000000
--- a/regex/regfree.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <regex.h>
-
-#include "utils.h"
-#include "regex2.h"
-
-/*
- - regfree - free everything
- = API_EXPORT(void) regfree(regex_t *);
- */
-API_EXPORT(void)
-regfree(preg)
-regex_t *preg;
-{
- register struct re_guts *g;
-
- if (preg->re_magic != MAGIC1) /* oops */
- return; /* nice to complain, but hard */
-
- g = preg->re_g;
- if (g == NULL || g->magic != MAGIC2) /* oops again */
- return;
- preg->re_magic = 0; /* mark it invalid */
- g->magic = 0; /* mark it invalid */
-
- if (g->strip != NULL)
- free((char *)g->strip);
- if (g->sets != NULL)
- free((char *)g->sets);
- if (g->setbits != NULL)
- free((char *)g->setbits);
- if (g->must != NULL)
- free(g->must);
- free((char *)g);
-}
diff --git a/regex/split.c b/regex/split.c
deleted file mode 100644
index 188bdb775b..0000000000
--- a/regex/split.c
+++ /dev/null
@@ -1,316 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-
-/*
- - split - divide a string into fields, like awk split()
- = int split(char *string, char *fields[], int nfields, char *sep);
- */
-int /* number of fields, including overflow */
-split(string, fields, nfields, sep)
-char *string;
-char *fields[]; /* list is not NULL-terminated */
-int nfields; /* number of entries available in fields[] */
-char *sep; /* "" white, "c" single char, "ab" [ab]+ */
-{
- register char *p = string;
- register char c; /* latest character */
- register char sepc = sep[0];
- register char sepc2;
- register int fn;
- register char **fp = fields;
- register char *sepp;
- register int trimtrail;
-
- /* white space */
- if (sepc == '\0') {
- while ((c = *p++) == ' ' || c == '\t')
- continue;
- p--;
- trimtrail = 1;
- sep = " \t"; /* note, code below knows this is 2 long */
- sepc = ' ';
- } else
- trimtrail = 0;
- sepc2 = sep[1]; /* now we can safely pick this up */
-
- /* catch empties */
- if (*p == '\0')
- return(0);
-
- /* single separator */
- if (sepc2 == '\0') {
- fn = nfields;
- for (;;) {
- *fp++ = p;
- fn--;
- if (fn == 0)
- break;
- while ((c = *p++) != sepc)
- if (c == '\0')
- return(nfields - fn);
- *(p-1) = '\0';
- }
- /* we have overflowed the fields vector -- just count them */
- fn = nfields;
- for (;;) {
- while ((c = *p++) != sepc)
- if (c == '\0')
- return(fn);
- fn++;
- }
- /* not reached */
- }
-
- /* two separators */
- if (sep[2] == '\0') {
- fn = nfields;
- for (;;) {
- *fp++ = p;
- fn--;
- while ((c = *p++) != sepc && c != sepc2)
- if (c == '\0') {
- if (trimtrail && **(fp-1) == '\0')
- fn++;
- return(nfields - fn);
- }
- if (fn == 0)
- break;
- *(p-1) = '\0';
- while ((c = *p++) == sepc || c == sepc2)
- continue;
- p--;
- }
- /* we have overflowed the fields vector -- just count them */
- fn = nfields;
- while (c != '\0') {
- while ((c = *p++) == sepc || c == sepc2)
- continue;
- p--;
- fn++;
- while ((c = *p++) != '\0' && c != sepc && c != sepc2)
- continue;
- }
- /* might have to trim trailing white space */
- if (trimtrail) {
- p--;
- while ((c = *--p) == sepc || c == sepc2)
- continue;
- p++;
- if (*p != '\0') {
- if (fn == nfields+1)
- *p = '\0';
- fn--;
- }
- }
- return(fn);
- }
-
- /* n separators */
- fn = 0;
- for (;;) {
- if (fn < nfields)
- *fp++ = p;
- fn++;
- for (;;) {
- c = *p++;
- if (c == '\0')
- return(fn);
- sepp = sep;
- while ((sepc = *sepp++) != '\0' && sepc != c)
- continue;
- if (sepc != '\0') /* it was a separator */
- break;
- }
- if (fn < nfields)
- *(p-1) = '\0';
- for (;;) {
- c = *p++;
- sepp = sep;
- while ((sepc = *sepp++) != '\0' && sepc != c)
- continue;
- if (sepc == '\0') /* it wasn't a separator */
- break;
- }
- p--;
- }
-
- /* not reached */
-}
-
-#ifdef TEST_SPLIT
-
-
-/*
- * test program
- * pgm runs regression
- * pgm sep splits stdin lines by sep
- * pgm str sep splits str by sep
- * pgm str sep n splits str by sep n times
- */
-int
-main(argc, argv)
-int argc;
-char *argv[];
-{
- char buf[512];
- register int n;
-# define MNF 10
- char *fields[MNF];
-
- if (argc > 4)
- for (n = atoi(argv[3]); n > 0; n--) {
- (void) strcpy(buf, argv[1]);
- }
- else if (argc > 3)
- for (n = atoi(argv[3]); n > 0; n--) {
- (void) strcpy(buf, argv[1]);
- (void) split(buf, fields, MNF, argv[2]);
- }
- else if (argc > 2)
- dosplit(argv[1], argv[2]);
- else if (argc > 1)
- while (fgets(buf, sizeof(buf), stdin) != NULL) {
- buf[strlen(buf)-1] = '\0'; /* stomp newline */
- dosplit(buf, argv[1]);
- }
- else
- regress();
-
- exit(0);
-}
-
-dosplit(string, seps)
-char *string;
-char *seps;
-{
-# define NF 5
- char *fields[NF];
- register int nf;
-
- nf = split(string, fields, NF, seps);
- print(nf, NF, fields);
-}
-
-print(nf, nfp, fields)
-int nf;
-int nfp;
-char *fields[];
-{
- register int fn;
- register int bound;
-
- bound = (nf > nfp) ? nfp : nf;
- printf("%d:\t", nf);
- for (fn = 0; fn < bound; fn++)
- printf("\"%s\"%s", fields[fn], (fn+1 < nf) ? ", " : "\n");
-}
-
-#define RNF 5 /* some table entries know this */
-struct {
- char *str;
- char *seps;
- int nf;
- char *fi[RNF];
-} tests[] = {
- "", " ", 0, { "" },
- " ", " ", 2, { "", "" },
- "x", " ", 1, { "x" },
- "xy", " ", 1, { "xy" },
- "x y", " ", 2, { "x", "y" },
- "abc def g ", " ", 5, { "abc", "def", "", "g", "" },
- " a bcd", " ", 4, { "", "", "a", "bcd" },
- "a b c d e f", " ", 6, { "a", "b", "c", "d", "e f" },
- " a b c d ", " ", 6, { "", "a", "b", "c", "d " },
-
- "", " _", 0, { "" },
- " ", " _", 2, { "", "" },
- "x", " _", 1, { "x" },
- "x y", " _", 2, { "x", "y" },
- "ab _ cd", " _", 2, { "ab", "cd" },
- " a_b c ", " _", 5, { "", "a", "b", "c", "" },
- "a b c_d e f", " _", 6, { "a", "b", "c", "d", "e f" },
- " a b c d ", " _", 6, { "", "a", "b", "c", "d " },
-
- "", " _~", 0, { "" },
- " ", " _~", 2, { "", "" },
- "x", " _~", 1, { "x" },
- "x y", " _~", 2, { "x", "y" },
- "ab _~ cd", " _~", 2, { "ab", "cd" },
- " a_b c~", " _~", 5, { "", "a", "b", "c", "" },
- "a b_c d~e f", " _~", 6, { "a", "b", "c", "d", "e f" },
- "~a b c d ", " _~", 6, { "", "a", "b", "c", "d " },
-
- "", " _~-", 0, { "" },
- " ", " _~-", 2, { "", "" },
- "x", " _~-", 1, { "x" },
- "x y", " _~-", 2, { "x", "y" },
- "ab _~- cd", " _~-", 2, { "ab", "cd" },
- " a_b c~", " _~-", 5, { "", "a", "b", "c", "" },
- "a b_c-d~e f", " _~-", 6, { "a", "b", "c", "d", "e f" },
- "~a-b c d ", " _~-", 6, { "", "a", "b", "c", "d " },
-
- "", " ", 0, { "" },
- " ", " ", 2, { "", "" },
- "x", " ", 1, { "x" },
- "xy", " ", 1, { "xy" },
- "x y", " ", 2, { "x", "y" },
- "abc def g ", " ", 4, { "abc", "def", "g", "" },
- " a bcd", " ", 3, { "", "a", "bcd" },
- "a b c d e f", " ", 6, { "a", "b", "c", "d", "e f" },
- " a b c d ", " ", 6, { "", "a", "b", "c", "d " },
-
- "", "", 0, { "" },
- " ", "", 0, { "" },
- "x", "", 1, { "x" },
- "xy", "", 1, { "xy" },
- "x y", "", 2, { "x", "y" },
- "abc def g ", "", 3, { "abc", "def", "g" },
- "\t a bcd", "", 2, { "a", "bcd" },
- " a \tb\t c ", "", 3, { "a", "b", "c" },
- "a b c d e ", "", 5, { "a", "b", "c", "d", "e" },
- "a b\tc d e f", "", 6, { "a", "b", "c", "d", "e f" },
- " a b c d e f ", "", 6, { "a", "b", "c", "d", "e f " },
-
- NULL, NULL, 0, { NULL },
-};
-
-regress()
-{
- char buf[512];
- register int n;
- char *fields[RNF+1];
- register int nf;
- register int i;
- register int printit;
- register char *f;
-
- for (n = 0; tests[n].str != NULL; n++) {
- (void) strcpy(buf, tests[n].str);
- fields[RNF] = NULL;
- nf = split(buf, fields, RNF, tests[n].seps);
- printit = 0;
- if (nf != tests[n].nf) {
- printf("split `%s' by `%s' gave %d fields, not %d\n",
- tests[n].str, tests[n].seps, nf, tests[n].nf);
- printit = 1;
- } else if (fields[RNF] != NULL) {
- printf("split() went beyond array end\n");
- printit = 1;
- } else {
- for (i = 0; i < nf && i < RNF; i++) {
- f = fields[i];
- if (f == NULL)
- f = "(NULL)";
- if (strcmp(f, tests[n].fi[i]) != 0) {
- printf("split `%s' by `%s', field %d is `%s', not `%s'\n",
- tests[n].str, tests[n].seps,
- i, fields[i], tests[n].fi[i]);
- printit = 1;
- }
- }
- }
- if (printit)
- print(nf, RNF, fields);
- }
-}
-#endif
diff --git a/regex/tests b/regex/tests
deleted file mode 100644
index c05846177f..0000000000
--- a/regex/tests
+++ /dev/null
@@ -1,475 +0,0 @@
-# regular expression test set
-# Lines are at least three fields, separated by one or more tabs. "" stands
-# for an empty field. First field is an RE. Second field is flags. If
-# C flag given, regcomp() is expected to fail, and the third field is the
-# error name (minus the leading REG_).
-#
-# Otherwise it is expected to succeed, and the third field is the string to
-# try matching it against. If there is no fourth field, the match is
-# expected to fail. If there is a fourth field, it is the substring that
-# the RE is expected to match. If there is a fifth field, it is a comma-
-# separated list of what the subexpressions should match, with - indicating
-# no match for that one. In both the fourth and fifth fields, a (sub)field
-# starting with @ indicates that the (sub)expression is expected to match
-# a null string followed by the stuff after the @; this provides a way to
-# test where null strings match. The character `N' in REs and strings
-# is newline, `S' is space, `T' is tab, `Z' is NUL.
-#
-# The full list of flags:
-# - placeholder, does nothing
-# b RE is a BRE, not an ERE
-# & try it as both an ERE and a BRE
-# C regcomp() error expected, third field is error name
-# i REG_ICASE
-# m ("mundane") REG_NOSPEC
-# s REG_NOSUB (not really testable)
-# n REG_NEWLINE
-# ^ REG_NOTBOL
-# $ REG_NOTEOL
-# # REG_STARTEND (see below)
-# p REG_PEND
-#
-# For REG_STARTEND, the start/end offsets are those of the substring
-# enclosed in ().
-
-# basics
-a & a a
-abc & abc abc
-abc|de - abc abc
-a|b|c - abc a
-
-# parentheses and perversions thereof
-a(b)c - abc abc
-a\(b\)c b abc abc
-a( C EPAREN
-a( b a( a(
-a\( - a( a(
-a\( bC EPAREN
-a\(b bC EPAREN
-a(b C EPAREN
-a(b b a(b a(b
-# gag me with a right parenthesis -- 1003.2 goofed here (my fault, partly)
-a) - a) a)
-) - ) )
-# end gagging (in a just world, those *should* give EPAREN)
-a) b a) a)
-a\) bC EPAREN
-\) bC EPAREN
-a()b - ab ab
-a\(\)b b ab ab
-
-# anchoring and REG_NEWLINE
-^abc$ & abc abc
-a^b - a^b
-a^b b a^b a^b
-a$b - a$b
-a$b b a$b a$b
-^ & abc @abc
-$ & abc @
-^$ & "" @
-$^ - "" @
-\($\)\(^\) b "" @
-# stop retching, those are legitimate (although disgusting)
-^^ - "" @
-$$ - "" @
-b$ & abNc
-b$ &n abNc b
-^b$ & aNbNc
-^b$ &n aNbNc b
-^$ &n aNNb @Nb
-^$ n abc
-^$ n abcN @
-$^ n aNNb @Nb
-\($\)\(^\) bn aNNb @Nb
-^^ n^ aNNb @Nb
-$$ n aNNb @NN
-^a ^ a
-a$ $ a
-^a ^n aNb
-^b ^n aNb b
-a$ $n bNa
-b$ $n bNa b
-a*(^b$)c* - b b
-a*\(^b$\)c* b b b
-
-# certain syntax errors and non-errors
-| C EMPTY
-| b | |
-* C BADRPT
-* b * *
-+ C BADRPT
-? C BADRPT
-"" &C EMPTY
-() - abc @abc
-\(\) b abc @abc
-a||b C EMPTY
-|ab C EMPTY
-ab| C EMPTY
-(|a)b C EMPTY
-(a|)b C EMPTY
-(*a) C BADRPT
-(+a) C BADRPT
-(?a) C BADRPT
-({1}a) C BADRPT
-\(\{1\}a\) bC BADRPT
-(a|*b) C BADRPT
-(a|+b) C BADRPT
-(a|?b) C BADRPT
-(a|{1}b) C BADRPT
-^* C BADRPT
-^* b * *
-^+ C BADRPT
-^? C BADRPT
-^{1} C BADRPT
-^\{1\} bC BADRPT
-
-# metacharacters, backslashes
-a.c & abc abc
-a[bc]d & abd abd
-a\*c & a*c a*c
-a\\b & a\b a\b
-a\\\*b & a\*b a\*b
-a\bc & abc abc
-a\ &C EESCAPE
-a\\bc & a\bc a\bc
-\{ bC BADRPT
-a\[b & a[b a[b
-a[b &C EBRACK
-# trailing $ is a peculiar special case for the BRE code
-a$ & a a
-a$ & a$
-a\$ & a
-a\$ & a$ a$
-a\\$ & a
-a\\$ & a$
-a\\$ & a\$
-a\\$ & a\ a\
-
-# back references, ugh
-a\(b\)\2c bC ESUBREG
-a\(b\1\)c bC ESUBREG
-a\(b*\)c\1d b abbcbbd abbcbbd bb
-a\(b*\)c\1d b abbcbd
-a\(b*\)c\1d b abbcbbbd
-^\(.\)\1 b abc
-a\([bc]\)\1d b abcdabbd abbd b
-a\(\([bc]\)\2\)*d b abbccd abbccd
-a\(\([bc]\)\2\)*d b abbcbd
-# actually, this next one probably ought to fail, but the spec is unclear
-a\(\(b\)*\2\)*d b abbbd abbbd
-# here is a case that no NFA implementation does right
-\(ab*\)[ab]*\1 b ababaaa ababaaa a
-# check out normal matching in the presence of back refs
-\(a\)\1bcd b aabcd aabcd
-\(a\)\1bc*d b aabcd aabcd
-\(a\)\1bc*d b aabd aabd
-\(a\)\1bc*d b aabcccd aabcccd
-\(a\)\1bc*[ce]d b aabcccd aabcccd
-^\(a\)\1b\(c\)*cd$ b aabcccd aabcccd
-
-# ordinary repetitions
-ab*c & abc abc
-ab+c - abc abc
-ab?c - abc abc
-a\(*\)b b a*b a*b
-a\(**\)b b ab ab
-a\(***\)b bC BADRPT
-*a b *a *a
-**a b a a
-***a bC BADRPT
-
-# the dreaded bounded repetitions
-{ & { {
-{abc & {abc {abc
-{1 C BADRPT
-{1} C BADRPT
-a{b & a{b a{b
-a{1}b - ab ab
-a\{1\}b b ab ab
-a{1,}b - ab ab
-a\{1,\}b b ab ab
-a{1,2}b - aab aab
-a\{1,2\}b b aab aab
-a{1 C EBRACE
-a\{1 bC EBRACE
-a{1a C EBRACE
-a\{1a bC EBRACE
-a{1a} C BADBR
-a\{1a\} bC BADBR
-a{,2} - a{,2} a{,2}
-a\{,2\} bC BADBR
-a{,} - a{,} a{,}
-a\{,\} bC BADBR
-a{1,x} C BADBR
-a\{1,x\} bC BADBR
-a{1,x C EBRACE
-a\{1,x bC EBRACE
-a{300} C BADBR
-a\{300\} bC BADBR
-a{1,0} C BADBR
-a\{1,0\} bC BADBR
-ab{0,0}c - abcac ac
-ab\{0,0\}c b abcac ac
-ab{0,1}c - abcac abc
-ab\{0,1\}c b abcac abc
-ab{0,3}c - abbcac abbc
-ab\{0,3\}c b abbcac abbc
-ab{1,1}c - acabc abc
-ab\{1,1\}c b acabc abc
-ab{1,3}c - acabc abc
-ab\{1,3\}c b acabc abc
-ab{2,2}c - abcabbc abbc
-ab\{2,2\}c b abcabbc abbc
-ab{2,4}c - abcabbc abbc
-ab\{2,4\}c b abcabbc abbc
-((a{1,10}){1,10}){1,10} - a a a,a
-
-# multiple repetitions
-a** &C BADRPT
-a++ C BADRPT
-a?? C BADRPT
-a*+ C BADRPT
-a*? C BADRPT
-a+* C BADRPT
-a+? C BADRPT
-a?* C BADRPT
-a?+ C BADRPT
-a{1}{1} C BADRPT
-a*{1} C BADRPT
-a+{1} C BADRPT
-a?{1} C BADRPT
-a{1}* C BADRPT
-a{1}+ C BADRPT
-a{1}? C BADRPT
-a*{b} - a{b} a{b}
-a\{1\}\{1\} bC BADRPT
-a*\{1\} bC BADRPT
-a\{1\}* bC BADRPT
-
-# brackets, and numerous perversions thereof
-a[b]c & abc abc
-a[ab]c & abc abc
-a[^ab]c & adc adc
-a[]b]c & a]c a]c
-a[[b]c & a[c a[c
-a[-b]c & a-c a-c
-a[^]b]c & adc adc
-a[^-b]c & adc adc
-a[b-]c & a-c a-c
-a[b &C EBRACK
-a[] &C EBRACK
-a[1-3]c & a2c a2c
-a[3-1]c &C ERANGE
-a[1-3-5]c &C ERANGE
-a[[.-.]--]c & a-c a-c
-a[1- &C ERANGE
-a[[. &C EBRACK
-a[[.x &C EBRACK
-a[[.x. &C EBRACK
-a[[.x.] &C EBRACK
-a[[.x.]] & ax ax
-a[[.x,.]] &C ECOLLATE
-a[[.one.]]b & a1b a1b
-a[[.notdef.]]b &C ECOLLATE
-a[[.].]]b & a]b a]b
-a[[:alpha:]]c & abc abc
-a[[:notdef:]]c &C ECTYPE
-a[[: &C EBRACK
-a[[:alpha &C EBRACK
-a[[:alpha:] &C EBRACK
-a[[:alpha,:] &C ECTYPE
-a[[:]:]]b &C ECTYPE
-a[[:-:]]b &C ECTYPE
-a[[:alph:]] &C ECTYPE
-a[[:alphabet:]] &C ECTYPE
-[[:alnum:]]+ - -%@a0X- a0X
-[[:alpha:]]+ - -%@aX0- aX
-[[:blank:]]+ - aSSTb SST
-[[:cntrl:]]+ - aNTb NT
-[[:digit:]]+ - a019b 019
-[[:graph:]]+ - Sa%bS a%b
-[[:lower:]]+ - AabC ab
-[[:print:]]+ - NaSbN aSb
-[[:punct:]]+ - S%-&T %-&
-[[:space:]]+ - aSNTb SNT
-[[:upper:]]+ - aBCd BC
-[[:xdigit:]]+ - p0f3Cq 0f3C
-a[[=b=]]c & abc abc
-a[[= &C EBRACK
-a[[=b &C EBRACK
-a[[=b= &C EBRACK
-a[[=b=] &C EBRACK
-a[[=b,=]] &C ECOLLATE
-a[[=one=]]b & a1b a1b
-
-# complexities
-a(((b)))c - abc abc
-a(b|(c))d - abd abd
-a(b*|c)d - abbd abbd
-# just gotta have one DFA-buster, of course
-a[ab]{20} - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab
-# and an inline expansion in case somebody gets tricky
-a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab] - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab
-# and in case somebody just slips in an NFA...
-a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night) - aaaaabaaaabaaaabaaaabweeknights aaaaabaaaabaaaabaaaabweeknights
-# fish for anomalies as the number of states passes 32
-12345678901234567890123456789 - a12345678901234567890123456789b 12345678901234567890123456789
-123456789012345678901234567890 - a123456789012345678901234567890b 123456789012345678901234567890
-1234567890123456789012345678901 - a1234567890123456789012345678901b 1234567890123456789012345678901
-12345678901234567890123456789012 - a12345678901234567890123456789012b 12345678901234567890123456789012
-123456789012345678901234567890123 - a123456789012345678901234567890123b 123456789012345678901234567890123
-# and one really big one, beyond any plausible word width
-1234567890123456789012345678901234567890123456789012345678901234567890 - a1234567890123456789012345678901234567890123456789012345678901234567890b 1234567890123456789012345678901234567890123456789012345678901234567890
-# fish for problems as brackets go past 8
-[ab][cd][ef][gh][ij][kl][mn] - xacegikmoq acegikm
-[ab][cd][ef][gh][ij][kl][mn][op] - xacegikmoq acegikmo
-[ab][cd][ef][gh][ij][kl][mn][op][qr] - xacegikmoqy acegikmoq
-[ab][cd][ef][gh][ij][kl][mn][op][q] - xacegikmoqy acegikmoq
-
-# subtleties of matching
-abc & xabcy abc
-a\(b\)?c\1d b acd
-aBc i Abc Abc
-a[Bc]*d i abBCcd abBCcd
-0[[:upper:]]1 &i 0a1 0a1
-0[[:lower:]]1 &i 0A1 0A1
-a[^b]c &i abc
-a[^b]c &i aBc
-a[^b]c &i adc adc
-[a]b[c] - abc abc
-[a]b[a] - aba aba
-[abc]b[abc] - abc abc
-[abc]b[abd] - abd abd
-a(b?c)+d - accd accd
-(wee|week)(knights|night) - weeknights weeknights
-(we|wee|week|frob)(knights|night|day) - weeknights weeknights
-a[bc]d - xyzaaabcaababdacd abd
-a[ab]c - aaabc abc
-abc s abc abc
-a* & b @b
-
-# Let's have some fun -- try to match a C comment.
-# first the obvious, which looks okay at first glance...
-/\*.*\*/ - /*x*/ /*x*/
-# but...
-/\*.*\*/ - /*x*/y/*z*/ /*x*/y/*z*/
-# okay, we must not match */ inside; try to do that...
-/\*([^*]|\*[^/])*\*/ - /*x*/ /*x*/
-/\*([^*]|\*[^/])*\*/ - /*x*/y/*z*/ /*x*/
-# but...
-/\*([^*]|\*[^/])*\*/ - /*x**/y/*z*/ /*x**/y/*z*/
-# and a still fancier version, which does it right (I think)...
-/\*([^*]|\*+[^*/])*\*+/ - /*x*/ /*x*/
-/\*([^*]|\*+[^*/])*\*+/ - /*x*/y/*z*/ /*x*/
-/\*([^*]|\*+[^*/])*\*+/ - /*x**/y/*z*/ /*x**/
-/\*([^*]|\*+[^*/])*\*+/ - /*x****/y/*z*/ /*x****/
-/\*([^*]|\*+[^*/])*\*+/ - /*x**x*/y/*z*/ /*x**x*/
-/\*([^*]|\*+[^*/])*\*+/ - /*x***x/y/*z*/ /*x***x/y/*z*/
-
-# subexpressions
-a(b)(c)d - abcd abcd b,c
-a(((b)))c - abc abc b,b,b
-a(b|(c))d - abd abd b,-
-a(b*|c|e)d - abbd abbd bb
-a(b*|c|e)d - acd acd c
-a(b*|c|e)d - ad ad @d
-a(b?)c - abc abc b
-a(b?)c - ac ac @c
-a(b+)c - abc abc b
-a(b+)c - abbbc abbbc bbb
-a(b*)c - ac ac @c
-(a|ab)(bc([de]+)f|cde) - abcdef abcdef a,bcdef,de
-# the regression tester only asks for 9 subexpressions
-a(b)(c)(d)(e)(f)(g)(h)(i)(j)k - abcdefghijk abcdefghijk b,c,d,e,f,g,h,i,j
-a(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)l - abcdefghijkl abcdefghijkl b,c,d,e,f,g,h,i,j,k
-a([bc]?)c - abc abc b
-a([bc]?)c - ac ac @c
-a([bc]+)c - abc abc b
-a([bc]+)c - abcc abcc bc
-a([bc]+)bc - abcbc abcbc bc
-a(bb+|b)b - abb abb b
-a(bbb+|bb+|b)b - abb abb b
-a(bbb+|bb+|b)b - abbb abbb bb
-a(bbb+|bb+|b)bb - abbb abbb b
-(.*).* - abcdef abcdef abcdef
-(a*)* - bc @b @b
-
-# do we get the right subexpression when it is used more than once?
-a(b|c)*d - ad ad -
-a(b|c)*d - abcd abcd c
-a(b|c)+d - abd abd b
-a(b|c)+d - abcd abcd c
-a(b|c?)+d - ad ad @d
-a(b|c?)+d - abcd abcd @d
-a(b|c){0,0}d - ad ad -
-a(b|c){0,1}d - ad ad -
-a(b|c){0,1}d - abd abd b
-a(b|c){0,2}d - ad ad -
-a(b|c){0,2}d - abcd abcd c
-a(b|c){0,}d - ad ad -
-a(b|c){0,}d - abcd abcd c
-a(b|c){1,1}d - abd abd b
-a(b|c){1,1}d - acd acd c
-a(b|c){1,2}d - abd abd b
-a(b|c){1,2}d - abcd abcd c
-a(b|c){1,}d - abd abd b
-a(b|c){1,}d - abcd abcd c
-a(b|c){2,2}d - acbd acbd b
-a(b|c){2,2}d - abcd abcd c
-a(b|c){2,4}d - abcd abcd c
-a(b|c){2,4}d - abcbd abcbd b
-a(b|c){2,4}d - abcbcd abcbcd c
-a(b|c){2,}d - abcd abcd c
-a(b|c){2,}d - abcbd abcbd b
-a(b+|((c)*))+d - abd abd @d,@d,-
-a(b+|((c)*))+d - abcd abcd @d,@d,-
-
-# check out the STARTEND option
-[abc] &# a(b)c b
-[abc] &# a(d)c
-[abc] &# a(bc)d b
-[abc] &# a(dc)d c
-. &# a()c
-b.*c &# b(bc)c bc
-b.* &# b(bc)c bc
-.*c &# b(bc)c bc
-
-# plain strings, with the NOSPEC flag
-abc m abc abc
-abc m xabcy abc
-abc m xyz
-a*b m aba*b a*b
-a*b m ab
-"" mC EMPTY
-
-# cases involving NULs
-aZb & a a
-aZb &p a
-aZb &p# (aZb) aZb
-aZ*b &p# (ab) ab
-a.b &# (aZb) aZb
-a.* &# (aZb)c aZb
-
-# word boundaries (ick)
-[[:<:]]a & a a
-[[:<:]]a & ba
-[[:<:]]a & -a a
-a[[:>:]] & a a
-a[[:>:]] & ab
-a[[:>:]] & a- a
-[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc abc
-[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc-q abc
-[[:<:]]a.c[[:>:]] & axc-dayc-dazce-abc axc
-[[:<:]]b.c[[:>:]] & a_bxc-byc_d-bzc-q bzc
-[[:<:]].x..[[:>:]] & y_xa_-_xb_y-_xc_-axdc _xc_
-[[:<:]]a_b[[:>:]] & x_a_b
-
-# past problems, and suspected problems
-(A[1])|(A[2])|(A[3])|(A[4])|(A[5])|(A[6])|(A[7])|(A[8])|(A[9])|(A[A]) - A1 A1
-abcdefghijklmnop i abcdefghijklmnop abcdefghijklmnop
-abcdefghijklmnopqrstuv i abcdefghijklmnopqrstuv abcdefghijklmnopqrstuv
-(ALAK)|(ALT[AB])|(CC[123]1)|(CM[123]1)|(GAMC)|(LC[23][EO ])|(SEM[1234])|(SL[ES][12])|(SLWW)|(SLF )|(SLDT)|(VWH[12])|(WH[34][EW])|(WP1[ESN]) - CC11 CC11
-CC[13]1|a{21}[23][EO][123][Es][12]a{15}aa[34][EW]aaaaaaa[X]a - CC11 CC11
-Char \([a-z0-9_]*\)\[.* b Char xyz[k Char xyz[k xyz
-a?b - ab ab
--\{0,1\}[0-9]*$ b -5 -5
diff --git a/regex/utils.h b/regex/utils.h
deleted file mode 100644
index f271f759b1..0000000000
--- a/regex/utils.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* utility definitions */
-#ifndef _POSIX2_RE_DUP_MAX
-#define _POSIX2_RE_DUP_MAX 255
-#endif
-
-#define DUPMAX _POSIX2_RE_DUP_MAX /* xxx is this right? */
-#define INFINITY (DUPMAX + 1)
-#define NC (CHAR_MAX - CHAR_MIN + 1)
-typedef unsigned char uch;
-
-/* switch off assertions (if not already off) if no REDEBUG */
-#ifndef REDEBUG
-#ifndef NDEBUG
-#define NDEBUG /* no assertions please */
-#endif
-#endif
-#include <assert.h>
-
-/* for old systems with bcopy() but no memmove() */
-#ifdef USEBCOPY
-#define memmove(d, s, c) bcopy(s, d, c)
-#endif
diff --git a/request_info.c b/request_info.c
deleted file mode 100644
index 86f3bcc22c..0000000000
--- a/request_info.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Jim Winstead (jimw@php.net) |
- +----------------------------------------------------------------------+
- */
-
-#include "php.h"
-#include "SAPI.h"
-
-#ifndef THREAD_SAFE
-PHPAPI php3_request_info request_info;
-#endif
-
-#if CGI_BINARY
-int php3_init_request_info(void *conf)
-{
- SLS_FETCH();
-
- request_info.current_user = NULL;
- request_info.current_user_length = 0;
- request_info.script_name = getenv("SCRIPT_NAME");
- request_info.script_filename = getenv("SCRIPT_FILENAME");
- /* Hack for annoying servers that do not set SCRIPT_FILENAME for us */
- if (!request_info.script_filename) {
- request_info.script_filename = request_info.php_argv0;
- }
-#if WIN32|WINNT
- /* FIXME WHEN APACHE NT IS FIXED */
- /* a hack for apache nt because it does not appear to set argv[1] and sets
- script filename to php.exe thus makes us parse php.exe instead of file.php
- requires we get the info from path translated. This can be removed at
- such a time taht apache nt is fixed */
- else {
- request_info.script_filename = getenv("PATH_TRANSLATED");
- }
-#endif
-
- /* doc_root configuration variable is currently ignored,
- as it is with every other access method currently also. */
-
- /* We always need to emalloc() filename, since it gets placed into
- the include file hash table, and gets freed with that table.
- Notice that this means that we don't need to efree() it in
- php3_destroy_request_info()! */
-#if DISCARD_PATH
- if (request_info.script_filename) {
- SG(request_info).path_translated = estrdup(request_info.script_filename);
- } else {
- SG(request_info).path_translated = NULL;
- }
-#endif
- return SUCCESS;
-}
-
-int php3_destroy_request_info(void *conf)
-{
- STR_FREE(request_info.current_user);
- return SUCCESS;
-}
-#endif
-
-
-#if APACHE
-int php3_init_request_info(void *conf)
-{
- request_rec *r;
- SLS_FETCH();
-
- r = ((request_rec *) SG(server_context));
- request_info.current_user = NULL;
- request_info.current_user_length = 0;
-
- return SUCCESS;
-}
-
-#endif
-
-#if !CGI_BINARY
-int php3_destroy_request_info(void *conf)
-{
- /* see above for why we don't want to efree() request_info.filename */
- return SUCCESS;
-}
-#endif
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/request_info.h b/request_info.h
deleted file mode 100644
index f1354113d2..0000000000
--- a/request_info.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Jim Winstead (jimw@php.net) |
- +----------------------------------------------------------------------+
- */
-
-#ifndef _REQUEST_INFO_H_
-#define _REQUEST_INFO_H_
-
-typedef struct {
- char *script_name;
- char *current_user;
- int current_user_length;
- const char *script_filename;
- char *php_argv0;
-} php3_request_info;
-
-#ifndef THREAD_SAFE
-PHPAPI extern php3_request_info request_info;
-#endif
-
-extern int php3_init_request_info(void *conf);
-extern int php3_destroy_request_info(void *conf);
-
-#endif
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/scripts/apache/apconf-conv.sh b/scripts/apache/apconf-conv.sh
deleted file mode 100755
index 6126bdc27d..0000000000
--- a/scripts/apache/apconf-conv.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = "" ]; then
- echo "Usage: $0 /somewhere/httpd.conf"
- exit 1
-fi
-
-if [ ! -w $1 ]; then
- echo "You cannot write to $1"
- exit 1
-fi
-
-TMPFILE=tmpfile.$$
-
-awk -f conffix.awk <$1 >$TMPFILE
-
-if [ "$?" != 0 ]; then
- exit 1
-fi
-
-mv -f $1 $1.orig
-mv -f $TMPFILE $1
-exit 0
-
diff --git a/scripts/apache/aphtaccess-conv.sh b/scripts/apache/aphtaccess-conv.sh
deleted file mode 100755
index 1af59d2843..0000000000
--- a/scripts/apache/aphtaccess-conv.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = "" ]; then
- echo "Usage: $0 /somewhere/.htaccess"
- exit 1
-fi
-
-if [ ! -w $1 ]; then
- echo "You cannot write to $1"
- exit 1
-fi
-
-TMPFILE=tmpfile.$$
-
-awk -f htaccessfix.awk <$1 >$TMPFILE
-
-if [ "$?" != 0 ]; then
- exit 1
-fi
-
-mv -f $1 $1.orig
-mv -f $TMPFILE $1
-exit 0
-
diff --git a/scripts/apache/conffix.awk b/scripts/apache/conffix.awk
deleted file mode 100644
index 88be6fade7..0000000000
--- a/scripts/apache/conffix.awk
+++ /dev/null
@@ -1,23 +0,0 @@
-# $Id$
-
-/^[ \t]*php3_*/ {
- phpcommand=substr($1,6)
- phpvalue=tolower($2)
- print "<IfModule mod_php3.c>"
- print $0
- print "</IfModule>"
- print "<IfModule mod_php4.c>"
- if (phpvalue=="on") {
- print "php_admin_flag " phpcommand " on"
- } else if (phpvalue=="off") {
- print "php_admin_flag " phpcommand " off"
- } else {
- print "php_admin_value " phpcommand " " substr($0,index($0,$1)+length($1)+1)
- }
- print "</IfModule>"
-}
-
-! /^[ \t]*php3_*/ {
- print $0
-}
-
diff --git a/scripts/apache/htaccessfix.awk b/scripts/apache/htaccessfix.awk
deleted file mode 100644
index 3c784cd335..0000000000
--- a/scripts/apache/htaccessfix.awk
+++ /dev/null
@@ -1,23 +0,0 @@
-# $Id$
-
-/^[ \t]*php3_*/ {
- phpcommand=substr($1,6)
- phpvalue=tolower($2)
- print "<IfModule mod_php3.c>"
- print $0
- print "</IfModule>"
- print "<IfModule mod_php4.c>"
- if (phpvalue=="on") {
- print "php_flag " phpcommand " on"
- } else if (phpvalue=="off") {
- print "php_flag " phpcommand " off"
- } else {
- print "php_value " phpcommand " " substr($0,index($0,$1)+length($1)+1)
- }
- print "</IfModule>"
-}
-
-! /^[ \t]*php3_*/ {
- print $0
-}
-
diff --git a/scripts/armerge b/scripts/armerge
deleted file mode 100755
index 857b103434..0000000000
--- a/scripts/armerge
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/bin/sh
-#
-# +----------------------------------------------------------------------+
-# | PHP HTML Embedded Scripting Language Version 4.0 |
-# +----------------------------------------------------------------------+
-# | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
-# +----------------------------------------------------------------------+
-# | This program is free software; you can redistribute it and/or modify |
-# | it under the terms of one of the following licenses: |
-# | |
-# | A) the GNU General Public License as published by the Free Software |
-# | Foundation; either version 2 of the License, or (at your option) |
-# | any later version. |
-# | |
-# | B) the PHP License as published by the PHP Development Team and |
-# | included in the distribution in the file: LICENSE |
-# | |
-# | 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 both licenses referred to here. |
-# | If you did not, or have any questions about PHP licensing, please |
-# | contact core@php.net. |
-# +----------------------------------------------------------------------+
-# | Authors: Stig Sæther Bakken <ssb@fast.no> |
-# +----------------------------------------------------------------------+
-#
-# Archive merger. Usage: armerge libout.a dir1/libin1.a dir2/libin2.a ...
-# Creates the archive libout.a from the files in the rest of the
-# parameter list. If the input archives are in separate directories,
-# the names of the files inside them are prefixed before they are
-# merged into the output archive. The prefix used is the same as the
-# directory name with "/" replaced by "_" and a "_" at the end.
-#
-# $Id$
-#
-
-die() {
- echo $@
- exit 1
-}
-
-if test "$#" -lt "2"; then
- echo "Usage: "`basename $0`" <out-archive> <in-archives...>"
- exit 1
-fi
-
-out_archive=$1; shift
-in_archives=$@
-cwd=`pwd`
-tmpdir=/tmp/armerge$$
-
-rm -f $out_archive
-
-mkdir $tmpdir || die "can not create temporary directory $tmpdir"
-
-( cd $tmpdir;
-
-for archive in $in_archives; do
- files=`ar t $cwd/$archive | sed -e 's/__\.SYMDEF SORTED//'`
- ar x $cwd/$archive
- dir=`dirname $archive`
- if test "$dir" = "."; then
- ext_files=$files
- else
- prefix=`echo $dir | sed -e 's#^\./##' -e 's#/#_#g'`_
- prefix=`echo $prefix | sed -e 's#^\.\._##g'`
- ext_files=""
- for file in $files; do
- if test "$file" != "$prefix$file"; then
- mv "$file" "$prefix$file"
- fi
- ext_files="$ext_files $prefix$file"
- done
- fi
- ar r out.a $ext_files
-done )
-
-cmp $tmpdir/out.a $out_archive >/dev/null 2>&1 || mv $tmpdir/out.a $out_archive || die "can not create $out_archive"
-rm -rf $tmpdir
-
diff --git a/scripts/config-stubs b/scripts/config-stubs
deleted file mode 100755
index 9985066648..0000000000
--- a/scripts/config-stubs
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-#
-# $Id$
-
-for stubfile in ext/*/config.m4; do
- echo "sinclude($stubfile)"
-done
diff --git a/scripts/conv_proto b/scripts/conv_proto
deleted file mode 100755
index fad9cfaa83..0000000000
--- a/scripts/conv_proto
+++ /dev/null
@@ -1,30 +0,0 @@
-#! /bin/sh
-#
-# do some automatic conversion of prototypes
-#
-
-if test "$1" = "" ; then
- echo "usage: $0 list-of-files"
- exit 1
-fi
-
-tmpfile=`mktemp -q /tmp/asd.XXXXXX`
-
-if test "$?" != "0" ; then
- echo "$0: cannot create temporary file"
- exit 1
-fi
-
-for file in ${1+"$@"} ; do
- echo "working on $file"
- cat $file | \
- sed -e \
- 's/void php3_\(.*\)(INTERNAL_FUNCTION_PARAMETERS)/PHP_FUNCTION(\1)/' \
- -e 's/^extern void /void /' \
- -e 's/^extern PHP_FUNCTION/PHP_FUNCTION/' > $tmpfile
- cp $tmpfile $file
-done
-
-rm -f $tmpfile
-
-exit 0
diff --git a/scripts/mkextlib.in b/scripts/mkextlib.in
deleted file mode 100755
index c098ef7b5d..0000000000
--- a/scripts/mkextlib.in
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-outfile=$1; shift
-extensions=$@
-
-ext_libs=""
-for dir in $extensions; do
- archive="$dir/libphpext_$dir.a"
- if test ! -r "$archive"; then
- echo `basename $0`": could not open $archive" >&2
- exit 1
- fi
- ext_libs="$ext_libs $archive"
-done
-
-(set -x; $top_srcdir/scripts/armerge $outfile $ext_libs)
-exit 0
diff --git a/scripts/preconfig b/scripts/preconfig
deleted file mode 100755
index 59b48fe545..0000000000
--- a/scripts/preconfig
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/sh
-#
-# $Id$
-
-disclaimer="Do NOT edit - this file is generated by preconfig"
-
-# security check - simply overwriting existing files could be harmful
-if test -w configure.in.new || test -w acconfig.h.new ; then
- echo "Please remove the *.new files and rerun this command"
- exit 1
-fi
-
-makefileams=`find ext -name Makefile.am -print | sort`
-makefiles=`echo $makefileams | sed -e 's/\.am//g'`
-echo "dnl $disclaimer" > configure.in.new
-sed -e "s#@@EXT_MAKEFILES@@#$makefiles#" configure.in.in >> configure.in.new
-cmp configure.in configure.in.new > /dev/null 2>&1
-if test $? -ne 0 ; then
- mv configure.in.new configure.in
-else
- rm -f configure.in.new
-fi
-
-echo "/* $disclaimer */" > acconfig.h.new
-cat acconfig.h.in >> acconfig.h.new
-confighfiles=`echo ext/*/config.h.stub`
-if test "$confighfiles" != "ext/*/config.h.stub"; then
- for file in $confighfiles; do
- cat $file >> acconfig.h.new
- done
-fi
-cmp acconfig.h acconfig.h.new > /dev/null 2>&1
-if test $? -ne 0 ; then
- mv acconfig.h.new acconfig.h
-else
- rm -f acconfig.h.new
-fi
diff --git a/setup b/setup
deleted file mode 100644
index 2b7a333d93..0000000000
--- a/setup
+++ /dev/null
@@ -1,370 +0,0 @@
-#!/bin/sh
-#
-# +----------------------------------------------------------------------+
-# | PHP HTML Embedded Scripting Language Version 3.0 |
-# +----------------------------------------------------------------------+
-# | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
-# +----------------------------------------------------------------------+
-# | This program is free software; you can redistribute it and/or modify |
-# | it under the terms of one of the following licenses: |
-# | |
-# | A) the GNU General Public License as published by the Free Software |
-# | Foundation; either version 2 of the License, or (at your option) |
-# | any later version. |
-# | |
-# | B) the PHP License as published by the PHP Development Team and |
-# | included in the distribution in the file: LICENSE |
-# | |
-# | 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 both licenses referred to here. |
-# | If you did not, or have any questions about PHP licensing, please |
-# | contact core@php.net. |
-# +----------------------------------------------------------------------+
-# | Authors: Stig Sæther Bakken <ssb@guardian.no> |
-# | Updated By: Jim Winstead <jimw@php.net> |
-# | Ariel Shkedi <ars@ziplink.net> or <as@altavista.net> |
-# +----------------------------------------------------------------------+
-#
-# $Id$
-
-if [ "$1" = "-q" ]; then
- quiet_mode=on
- shift
-fi
-
-if [ `echo -e "\n" | wc -l` = 2 ]; then
-# bash supports echo -e for handling escape sequences
- ECHO_CMD="echo -e"
-elif test -f /bin/echo; then
- ECHO_CMD="/bin/echo"
-elif test -f /usr/bin/echo; then
- ECHO_CMD="/usr/bin/echo"
-else
-# fall back to the default echo - \n would most probably be displayed as-is
- ECHO_CMD="echo"
-fi
-
-if echo '\c' | grep -s c >/dev/null 2>&1
-then
- ECHO_N="echo -n"
- ECHO_C=""
-else
- ECHO_N="echo"
- ECHO_C='\c'
-fi
-
-echo '
- ***************************************************************************
- * *
- * Welcome to the PHP 3.0 setup script. Use this script if you do not *
- * want or know how to use the configure program. See the INSTALL file *
- * for further installation instructions. *
- * *
- * You will now be asked a series of questions for your installation. *
- * For each question, your options will be shown in parantheses, and *
- * for some a default value is listed shown in brackets. *
- * *
- ***************************************************************************
-'
-
-display_prompt()
-{
- prm=$1
- shift
- typ=$1
- shift
- def=$1
- shift
- $ECHO_N "$prm $ECHO_C"
- case $typ in
- yesno) $ECHO_N "(yes/no) $ECHO_C";;
- yesnodir) $ECHO_N "(\`yes', \`no' or dir) $ECHO_C";;
- dir) $ECHO_N "(dir) $ECHO_C";;
- esac
- if test "$typ" = "yesnodir"; then
- set $def
- def=$1
- fi
- $ECHO_N "[$def] : $ECHO_C"
-}
-
-define_option()
-{
- if test "$#" != "5"; then
- echo "wrong number of arguments to define_option" >&2
- return
- fi
- name=$1
- shift
- prompt=$1
- shift
- type=$1
- shift
- default=$1
- shift
- docstring=$1
- optname=`echo $name | sed -e 's/[^a-zA-Z0-9_]/_/g'`
- options="$options $optname"
- eval "option_name_$optname='$name'"
- eval "option_prompt_$optname='$prompt'"
- eval "option_type_$optname='$type'"
- eval "option_default_$optname='$default'"
- eval "option_docstring_$optname='$docstring'"
- answer=""
- if [ "$quiet_mode" != "on" ]; then
- show_help "$optname" "$type" "$default"
- fi
- while test "$answer" = ""; do
- display_prompt "$prompt" "$type" "$default"
- read answer
- test -t || echo $answer # Echo the answer if it did not come
- # from a terminal.
- if test "$type" = "yesnodir"; then
- set $default
- if test "$1" = "yes"; then
- if test "$answer" = ""; then
- answer=yes
- fi
- fi
- case "$answer" in
- */*) ;;
- [Yy]*) dir=$2
- shift
- shift
- $ECHO_N "Enter $@ directory [$dir] : $ECHO_C"
- read answer
- test -t || echo $answer
- if test "$answer" = ""; then
- answer=$dir
- fi
- ;;
- esac
- fi
- if test "$answer" = ""; then
- if test "$type" = "yesnodir"; then
- set $default
- answer=$1
- else
- answer=$default
- fi
- elif test "$answer" = "?"; then
- show_help "$optname" "$type" "$default"
- answer=""
- fi
- done
- if test "$type" = "yesnodir"; then
- set $default
- if test $1 = "yes"; then
- case "$answer" in
- "$2") answer=yes;;
- [Yy]*) answer=yes;;
- [Nn]*) answer=no;;
- esac
- else
- case "$answer" in
- [Yy]*) answer=$2;;
- [Nn]*) answer=no;;
- esac
- fi
- elif test "$type" = "yesno"; then
- case "$answer" in
- [Yy]*) answer=yes;;
- [Nn]*) answer=no;;
- esac
- fi
- eval "option_value_$optname='$answer'"
-}
-
-show_help()
-{
- echo ''
- ( eval "$ECHO_CMD \$option_docstring_$1" ;
- if test "$2" = "yesnodir"; then
- set $3
- echo "If you answer \`yes', the default directory is \`$2'."
- fi )
- echo ''
-}
-
-generate_config_command()
-{
- configure_options=""
- for optname in $options; do
- eval "name=\$option_name_$optname"
- eval "value=\$option_value_$optname"
- eval "default=\$option_default_$optname"
- set $default
- if test "$value" != "$1"; then
- if test "$value" != "$2"; then
- configure_options="$configure_options --$name=$value"
- else
- configure_options="$configure_options --$name"
- fi
- fi
- done
- echo "./configure$configure_options"
-}
-
-# now define all the options
-
-define_option with-apache 'Build as an Apache module?' yesnodir \
- 'no /usr/local/etc/httpd Apache base install' \
-' Whether to build PHP as an Apache module. If you are running\n
- Apache, building PHP as a module will give better performance and\n
- security. If you answer no PHP will be built as a CGI program.\n
- The CGI version also enables Apache users to run different PHP3-enabled\n
- pages under different user-ids.'
-
-if test "$option_value_with_apache" != "no"; then
- define_option with-mod_charset 'Enable transfer tables used by mod_charset?' yesno no \
-' Whether to respect transfer tables used by mod_charset when PHP compiled\n
- as Apache module. It is required to allow mod_charset (aka Russian Apache)\n
- to work properly.'
-fi
-
-if test "$option_value_with_apache" = "no"; then
- define_option with-fhttpd 'Build as an fhttpd module?' yesnodir \
- 'no /usr/local/src/fhttpd fhttpd sources' \
-' Whether to build PHP as fhttpd module. If you are running\n
- fhttpd, building PHP as a module will give better performance,\n
- more control and remote execution capability. More info about fhttpd \n
- can be found at http://phobos.illtel.denver.co.us/pub/fhttpd/.'
-fi
-
-for stub in ext/*/setup.stub; do
- test -f $stub && . $stub
-done
-
-define_option with-config-file-path 'Default config directory?' yesnodir \
- 'no /usr/local/lib Configuration file' \
-' Directory where the PHP3 configuration file (php3.ini) is\n
- located.'
-
-# systems should be system's
-define_option with-system-regex 'Use the system regex library?' yesno no \
-" Whether to use the systems regular expression library rather than\n
- the bundled one. If you are building PHP3 as a server module, you must\n
- use the same library when building PHP3 as when linking the server.\n
- Enable this if the systems library provides special features you need.\n
- It is recommended that you use the bundled library if possible."
-
-define_option enable-debug 'Compile with debug information?' yesno yes \
-' Whether to enable debug information. Answering "no" here will make\n
- PHP run faster, but it will be harder to trace bugs. You are \n
- encouraged to leave debugging on while PHP 3.0 is in alpha and \n
- beta state.'
-
-define_option enable-safe-mode 'Enable safe mode by default?' yesno no \
-" Whether to enable PHP safe mode. This imposes several\n
- restrictions on what PHP can do, such as opening only files within\n
- the document root. Read the Security chapter of the documentation\n
- for more information. CGI users should always enable secure mode.\n
- This only sets the default, it may be enabled or disabled in the\n
- configuration file later. "
-
-# broken configure.in doesn't check apache (bug?)
-#if test "$option_value_with_apache" != "no"; then
-# defexecdir="$option_value_with_apache/php-bin"
-#else
- defexecdir=/usr/local/bin
-#fi
-
-define_option with-exec-dir 'Default safe mode exec dir?' dir "$defexecdir" \
-" The directory where executables that may be run from safe mode\n
- are located."
-
-define_option enable-track-vars 'Enable variable tracking by default?' yesno \
- no \
-' Enable the HTTP_GET_VARS, HTTP_POST_VARS and HTTP_COOKIE_VARS arrays by\n
- default (can be turned on or off in the configuration file).'
-
-define_option enable-magic-quotes 'Enable magic quotes by default?' yesno no \
-' Whether to magic quotes by default. This can be changed in the\n
- configuration file.'
-
-define_option enable-debugger 'Enable PHP remote debugger?' yesno no \
-" Whether to enable PHP remote debugging support. This feature\n
- is still under development."
-
-# configure.in only checks these if it's a cgi so setup does the same
-if test "$option_value_with_apache" = "no"; then
-# outputing the bank line isn't really possible, but it would be nice
-define_option enable-force-cgi-redirect 'Enable redirect checking?' yesno no \
-' When using PHP as a CGI binary, this will make PHP always first check\n
- that it is used by redirection (for example under Apache, by using\n
- Action directives). This makes sure that the PHP binary cannot be used\n
- to bypass standard web server authentication procedures by calling it\n
- directly, like http://my.host/cgi-bin/php/secret/doc.html. This\n
- example accesses http://my.host/secret/doc.html but does not honour\n
- any security settings enforced by httpd for directory /secret.\n
- \n
- Not enabling this option disables the check and enables bypassing\n
- httpd security and authentication settings. Do this only if your server\n
- software is unable to indicate that a safe redirection was done and\n
- all your files under your document root and user directories may be\n
- accessed by anyone. (See the doc_root and user_dir options in the\n
- configuartion file).'
-
-define_option enable-discard-path 'Enable discard path?' yesno no \
-' If this is enabled, the PHP CGI binary can safely be placed outside\n
- of the web tree and people will not be able to circumvent .htaccess\n
- security.'
-fi
-
-define_option enable-memory-limit 'Enable memory limit?' yesno no \
-' Compile with memory limit support.'
-
-define_option enable-short-tags 'Allow short tag by default?' yesno yes \
-" Whether to enable the short form of the PHP HTML embed tags.\n
- The short form is \"<? code; ?>\", while the long form is\n
- \"<?php code; ?>\". If you plan on using XML on your site, you\n
- should disable the short form. This is the default and can be overridden\n
- in the configuration file."
-
-define_option enable-url-fopen-wrapper 'Enable URL fopen wrappers?' yesno yes \
-" Enable the URL-aware fopen wrapper that allows accessing files via http\n
- or ftp."
-
-# only the cgi version of PHP is installed to bindir
-if test "$option_value_with_apache" = "no"; then
-define_option bindir 'Install php in:' dir "/usr/local/bin" \
-" Directory where PHP should be installed."
-fi
-
-echo '
-
- ***************************************************************************
- * *
- * Running configure... *
- * *
- ***************************************************************************
-'
-if test ! -f configure; then
- autoconf
-fi
-
-command=`generate_config_command`
-mv do-conf do-conf.bak > /dev/null 2>&1
-echo $command > do-conf
-chmod +x do-conf
-echo $command
-eval $command
-
-echo '
- ***************************************************************************
- * *
- * Configuration options were saved in do-conf, if desired you can *
- * edit this file and then run it. Run ./configure --help for a list *
- * of options. *
- * *
- * Read the INSTALL file for more information and for help in *
- * configuring apache. See the web site at: http://www.php.net/ for *
- * documentation and more. If desired copy the php3.ini-dist file to *
- * your config directory/php3.ini and edit it. *
- * *
- ***************************************************************************
-'
diff --git a/snmp.mak b/snmp.mak
deleted file mode 100644
index 8bddefe49a..0000000000
--- a/snmp.mak
+++ /dev/null
@@ -1,194 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on snmp.dsp
-!IF "$(CFG)" == ""
-CFG=snmp - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to snmp - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "snmp - Win32 Release" && "$(CFG)" != "snmp - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "snmp.mak" CFG="snmp - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "snmp - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "snmp - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-!IF "$(CFG)" == "snmp - Win32 Release"
-
-OUTDIR=.\module_Release
-INTDIR=.\module_Release
-# Begin Custom Macros
-OutDir=.\module_Release
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_snmp.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(INTDIR)\winsnmp.obj"
- -@erase "$(OUTDIR)\php3_snmp.dll"
- -@erase "$(OUTDIR)\php3_snmp.exp"
- -@erase "$(OUTDIR)\php3_snmp.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "./" /I "../" /I "../../include" /D HAVE_SNMP=1 /D "THREAD_SAFE" /D "NDEBUG" /D "MSVC5" /D "COMPILE_DL" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\snmp.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\snmp.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib mgmtapi.lib snmpapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\php3_snmp.pdb" /machine:I386 /out:"$(OUTDIR)\php3_snmp.dll" /implib:"$(OUTDIR)\php3_snmp.lib" /libpath:"..\..\lib" /libpath:"cgi_release"
-LINK32_OBJS= \
- "$(INTDIR)\winsnmp.obj"
-
-"$(OUTDIR)\php3_snmp.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "snmp - Win32 Debug"
-
-OUTDIR=.\module_Debug
-INTDIR=.\module_Debug
-# Begin Custom Macros
-OutDir=.\module_Debug
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_snmp.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(INTDIR)\vc60.pdb"
- -@erase "$(INTDIR)\winsnmp.obj"
- -@erase "$(OUTDIR)\php3_snmp.dll"
- -@erase "$(OUTDIR)\php3_snmp.exp"
- -@erase "$(OUTDIR)\php3_snmp.ilk"
- -@erase "$(OUTDIR)\php3_snmp.lib"
- -@erase "$(OUTDIR)\php3_snmp.pdb"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "./" /I "../" /I "../../" /I "../../../" /I "../../include" /D HAVE_SNMP=1 /D "THREAD_SAFE" /D "DEBUG" /D "_DEBUG" /D "MSVC5" /D COMPILE_DL=1 /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\snmp.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\snmp.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib mgmtapi.lib snmpapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:yes /pdb:"$(OUTDIR)\php3_snmp.pdb" /debug /machine:I386 /out:"$(OUTDIR)\php3_snmp.dll" /implib:"$(OUTDIR)\php3_snmp.lib" /pdbtype:sept /libpath:"..\..\lib" /libpath:"cgi_debug"
-LINK32_OBJS= \
- "$(INTDIR)\winsnmp.obj"
-
-"$(OUTDIR)\php3_snmp.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF
-
-
-!IF "$(NO_EXTERNAL_DEPS)" != "1"
-!IF EXISTS("snmp.dep")
-!INCLUDE "snmp.dep"
-!ELSE
-!MESSAGE Warning: cannot find "snmp.dep"
-!ENDIF
-!ENDIF
-
-
-!IF "$(CFG)" == "snmp - Win32 Release" || "$(CFG)" == "snmp - Win32 Debug"
-SOURCE=.\dl\snmp\winsnmp.c
-
-"$(INTDIR)\winsnmp.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-
-!ENDIF
-
diff --git a/stamp-h.in b/stamp-h.in
deleted file mode 100644
index e69de29bb2..0000000000
--- a/stamp-h.in
+++ /dev/null
diff --git a/tests/foo b/tests/foo
deleted file mode 100644
index 125c655b0f..0000000000
--- a/tests/foo
+++ /dev/null
@@ -1,5 +0,0 @@
-a
-b
-@c@
-d
-e
diff --git a/tests/foo2 b/tests/foo2
deleted file mode 100644
index 4cdd41e3dc..0000000000
--- a/tests/foo2
+++ /dev/null
@@ -1,3 +0,0 @@
-<?
-
-print $a->b(12,13)."\n";
diff --git a/tests/foo3 b/tests/foo3
deleted file mode 100644
index 08681b98c2..0000000000
--- a/tests/foo3
+++ /dev/null
@@ -1,43 +0,0 @@
-<?
-
-class foo {
- function foo() {
- print "foo()\n";
- }
- function bar(&$blah, $foobar=7) {
- $foobar += 19;
- }
-
- function hello_world() {
- return "Hello, World!";
- }
-
- function print_string($str) {
- print "$str\n";
- return 666;
- }
- var $foo;
- var $bar="this is a test...";
-};
-
-class bar {
- function foo($a,$b) {
- $a *= 3;
- return $a+$b;
- }
- function bar(&$blah, $foobar=7) {
- $foobar += 19;
- }
-
- var $foo;
- var $bar="this is a test...";
-};
-
-
-$b = new foo;
-$a = $b;
-print $a->print_string($a->hello_world())."\n";
-print $b->print_string($b->hello_world())."\n";
-$a->foo = 5;
-print $a->foo;
-print $a->foo();
diff --git a/tests/foo4 b/tests/foo4
deleted file mode 100644
index c242debf97..0000000000
--- a/tests/foo4
+++ /dev/null
@@ -1,41 +0,0 @@
-<?
-
-class foo {
- function foo($a,$b) {
- $a *= 3;
- return $a+$b;
- }
- function bar(&$blah, $foobar=7) {
- $foobar += 19;
- }
-
- function hello_world() {
- return "Hello, World!";
- }
-
- function print_string($str) {
- print "$str\n";
- return 666;
- }
- var $foo;
- var $bar="this is a test...";
-};
-
-class bar {
- function foo($a,$b) {
- $a *= 3;
- return $a+$b;
- }
- function bar(&$blah, $foobar=7) {
- $foobar += 19;
- }
-
- var $foo;
- var $bar="this is a test...";
-};
-
-
-$b = new foo;
-$a = &$b;
-$b->asd = 5;
-print $b->asd;
diff --git a/tests/recurse b/tests/recurse
deleted file mode 100644
index 026394a9f4..0000000000
--- a/tests/recurse
+++ /dev/null
@@ -1,21 +0,0 @@
-<?
-
-function factorial($n)
-{
- if ($n==0 || $n==1) {
- return 1;
- } else {
- return $n*factorial($n-1);
- }
-}
-
-
-for ($k=0; $k<10; $k++):
-for ($i=0,$sum=0; $i<150; $i++) {
- $sum = $sum+factorial($i);
-}
-endfor;
-
-print "\$sum=$sum\n";
-
-
diff --git a/tests/test.php4 b/tests/test.php4
deleted file mode 100644
index fdcd51bdbd..0000000000
--- a/tests/test.php4
+++ /dev/null
@@ -1,16 +0,0 @@
-<?
-function blah($a)
-{
-
- return $a;
-}
-
-return "cool";
-
-
-for ($for=0; $for<=100000;$for++)
-{
-if ("andi" != blah("andi"))
-{
-print "error";}
-}
diff --git a/tests/test.pl b/tests/test.pl
deleted file mode 100644
index 2502cb1298..0000000000
--- a/tests/test.pl
+++ /dev/null
@@ -1,34 +0,0 @@
-<?
-
-$i = 0;
-$j = 1;
-
-for ($k=0; $k<1000000; $k = $k+1) {
- while ($i<10000000) {
- if (($i%"4")<1) {
- $i = $i+"1";
- if ($j%"2") {
- $i = $i * "2";
- }
- } elseif (($i%"4")<2) {
- $i = $i+"2";
- if ($j%"2") {
- $i = $i * "2";
- }
- } elseif (($i%"4")<3) {
- $i = $i+3;
- if ($j%"2") {
- $i = $i * "2";
- }
- } else {
- $i = $i+"4";
- if ($j%"2") {
- $i = $i * "2";
- }
- }
- $j = $j+1;
- }
-}
-print $i;
-print "\n";
-
diff --git a/tests/test_class_inheritance b/tests/test_class_inheritance
deleted file mode 100644
index 3f903e62d1..0000000000
--- a/tests/test_class_inheritance
+++ /dev/null
@@ -1,29 +0,0 @@
-<?
-
-class BaseClass {
- var $class_name = "BaseClass";
-
- function BaseClass($value) {
- print "value is '$value'\n";
- }
- function MyClassName() {
- return $this->class_name;
- }
-};
-
-
-class ChildClass {
- var $class_name = "ChildClass";
-
- function ChildClass($value, $new_value) {
- BaseClass::BaseClass($value);
- print "new value is '$new_value'\n";
- }
- function MyClassName($a_value) {
- return BaseClass::MyClassName()." and the value is '$a_value'";
- }
-};
-
-
-$obj = new ChildClass("Test", "Another test");
-print $obj->MyClassName("not interesting"); \ No newline at end of file
diff --git a/tests/testarray b/tests/testarray
deleted file mode 100644
index 27a2f9bc4d..0000000000
--- a/tests/testarray
+++ /dev/null
@@ -1,21 +0,0 @@
-
-This is a small test...
-
-<?
-/*
- * this is a multiline comment...
- */
-
-//for ($j=0; $j<=200; $j++) {
- for ($i[0][0]=0; $i[0][0]<10000; $i[0][0]++) {
- $i[1] += $i[0][0]; // this is a single line comment
- }
-//}
-
-/* this is another multi
-line
- comment...******
-/
-*/
-
-print $i[1]."\n";
diff --git a/tests/testarray.pl b/tests/testarray.pl
deleted file mode 100644
index 9ec83e184c..0000000000
--- a/tests/testarray.pl
+++ /dev/null
@@ -1,5 +0,0 @@
-for ($i[0][0]=0; $i[0][0]<1000000; $i[0][0]++) {
- $i[1] += $i[0][0];
-}
-
-print $i[1];
diff --git a/tests/testarray2 b/tests/testarray2
deleted file mode 100644
index 4272eedf2e..0000000000
--- a/tests/testarray2
+++ /dev/null
@@ -1,5 +0,0 @@
-<?
-
-for ($i="aaa"; $i<"bbb\nbbb"; $i++) {
- print $i;
-} \ No newline at end of file
diff --git a/tests/testarray2.pl b/tests/testarray2.pl
deleted file mode 100644
index e72c526d4f..0000000000
--- a/tests/testarray2.pl
+++ /dev/null
@@ -1,3 +0,0 @@
-for ($i="aaa"; $i lt "bbb"; $i++) {
- print "$i\n";
-}
diff --git a/tests/testclassfunc b/tests/testclassfunc
deleted file mode 100644
index 6ad5a5091c..0000000000
--- a/tests/testclassfunc
+++ /dev/null
@@ -1,10 +0,0 @@
-<?
-
-class foo {
- function bar() {
- print "Hey there!\n";
- }
-};
-
-foo::bar();
-
diff --git a/tests/testcom b/tests/testcom
deleted file mode 100644
index 3668424a29..0000000000
--- a/tests/testcom
+++ /dev/null
@@ -1,9 +0,0 @@
-<?
-$word = new COM("word.application") or die("Unable to instanciate Word");
-print "Loaded Word, version {$word->Version}\n";
-$word->Visible = 1;
-$word->Documents->Add();
-$word->Selection->TypeText("This is a test...");
-$word->Documents[1]->SaveAs("Useless test.doc");
-$word->Quit();
-?> \ No newline at end of file
diff --git a/tests/testfe b/tests/testfe
deleted file mode 100644
index 5ae85511b5..0000000000
--- a/tests/testfe
+++ /dev/null
@@ -1,21 +0,0 @@
-<?
-
-$foo = array(7,"foo",3,array(1,2),4);
-
-//print $foo[1];
-
-for ($i=0; $i<3; $i++):
-
-foreach($a, $foo ) {
- if (gettype($a)=="array") {
- print "Array:\n";
- foreach($b, $a) {
- print "\t$b\n";
- }
- print "End of array.\n";
- } else {
- print "$a\n";
- }
-// print "$a\n";
-}
-endfor;
diff --git a/tests/testfunc b/tests/testfunc
deleted file mode 100644
index 6c4775e54f..0000000000
--- a/tests/testfunc
+++ /dev/null
@@ -1,36 +0,0 @@
-<?
-function foo()
-{
- $i=0;
-
- if ($i) {
- $a = "zeev";
- } else {
- $b = "andi";
- }
-}
-
-
-function bar()
-{
- foo();
-}
-
-for ($i=0; $i<1000; $i++) {
- bar();
-}
-
-
-for ($i=0; $i<10; $i++) {
- bar();
-}
-
-print "Got here...
-
-";
-
-$a = 7;
-
-$a = 5;
-
-print "Got here...\n\n"; \ No newline at end of file
diff --git a/tests/testfunc.pl b/tests/testfunc.pl
deleted file mode 100644
index 87864866ff..0000000000
--- a/tests/testfunc.pl
+++ /dev/null
@@ -1,20 +0,0 @@
-sub foo()
-{
- my $i=0;
-
- if ($i) {
- my $a = "zeev";
- } else {
- my $b = "andi";
- }
-}
-
-
-sub bar()
-{
- foo();
-}
-
-for ($i=0; $i<1000000; $i++) {
- bar();
-}
diff --git a/tests/testfunc2 b/tests/testfunc2
deleted file mode 100644
index 9bcae0f183..0000000000
--- a/tests/testfunc2
+++ /dev/null
@@ -1,19 +0,0 @@
-<?
-function foo($i)
-{
- if ($i) {
- $a = "zeev";
- } else {
- $b = "andi";
- }
-}
-
-
-function bar($a)
-{
- foo($a);
-}
-
-for ($i=0; $i<1000000; $i=$i+1) {
- bar($i);
-}
diff --git a/tests/testfunc2.pl b/tests/testfunc2.pl
deleted file mode 100644
index 7eeaf92ffb..0000000000
--- a/tests/testfunc2.pl
+++ /dev/null
@@ -1,22 +0,0 @@
-sub foo
-{
- my $i = shift(@_);
-
- if ($i) {
- my $a = "zeev";
- } else {
- my $b = "andi";
- }
-}
-
-
-sub bar
-{
- my $i = shift(@_);
-
- foo($i);
-}
-
-for ($i=0; $i<1000000; $i=$i+1) {
- bar($i);
-}
diff --git a/tests/testfuncref b/tests/testfuncref
deleted file mode 100644
index 675c70de81..0000000000
--- a/tests/testfuncref
+++ /dev/null
@@ -1,8 +0,0 @@
-<?
-
-function foobar()
-{
- print "foobar\n";
-}
-
-$a = ${"foo"."bar"}();
diff --git a/tests/testinclude b/tests/testinclude
deleted file mode 100644
index 7539985aa7..0000000000
--- a/tests/testinclude
+++ /dev/null
@@ -1,5 +0,0 @@
-<?
-print "Before include...\n";
-$retval = include("testarray");
-print "After include, include returned $retval\n";
-?> \ No newline at end of file
diff --git a/tests/testobj b/tests/testobj
deleted file mode 100644
index 661684be91..0000000000
--- a/tests/testobj
+++ /dev/null
@@ -1,32 +0,0 @@
-<?
-
-define("endl","\n");
-
-//if (1) {
-class foobar {
- function foobar() {
- $this->initialized = 1;
- }
-};
-
-class barbara extends foobar {
-
-};
-//}
-
-$name = "foobar";
-$foo = new $name; // or die("Unable to construct foobar\n");
-//print $foo->initialized;
-
-$boo = new barbara;
-print get_class($foo).endl;
-print get_parent_class($foo).endl;
-print get_class($boo).endl;
-print get_parent_class($boo).endl;
-print method_exists($foo,"foobar").endl;
-print method_exists($boo,"foobar").endl;
-print method_exists($boo,"barbara").endl;
-//$word = new COm("word.application");
-//$word->visible = true;
-//sleep(5);
-//$word->quit();
diff --git a/win32/flock.c b/win32/flock.c
deleted file mode 100644
index cc9d409784..0000000000
--- a/win32/flock.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Program: Unix compatibility routines
- *
- * Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
- *
- * Date: 14 September 1996
- * Last Edited: 14 August 1997
- *
- * Copyright 1997 by the University of Washington
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appears in all copies and that both the
- * above copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the University of Washington not be
- * used in advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission. This software is made available
- * "as is", and
- * THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
- * WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION ALL IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND IN
- * NO EVENT SHALL THE UNIVERSITY OF WASHINGTON BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT
- * (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-
-/* DEDICATION
-
- * This file is dedicated to my dog, Unix, also known as Yun-chan and
- * Unix J. Terwilliker Jehosophat Aloysius Monstrosity Animal Beast. Unix
- * passed away at the age of 11 1/2 on September 14, 1996, 12:18 PM PDT, after
- * a two-month bout with cirrhosis of the liver.
- *
- * He was a dear friend, and I miss him terribly.
- *
- * Lift a leg, Yunie. Luv ya forever!!!!
- */
-
-#include <windows.h>
-#include <io.h>
-#include <errno.h>
-#include "flock.h"
-
-int flock(int fd, int op)
-{
- HANDLE hdl = (HANDLE) _get_osfhandle(fd);
- DWORD low = 1, high = 0;
- OVERLAPPED offset =
- {0, 0, 0, 0, NULL};
- if (hdl < 0)
- return -1; /* error in file descriptor */
- /* bug for bug compatible with Unix */
- UnlockFileEx(hdl, 0, low, high, &offset);
- switch (op & ~LOCK_NB) { /* translate to LockFileEx() op */
- case LOCK_EX: /* exclusive */
- if (LockFileEx(hdl, LOCKFILE_EXCLUSIVE_LOCK +
- ((op & LOCK_NB) ? LOCKFILE_FAIL_IMMEDIATELY : 0),
- 0, low, high, &offset))
- return 0;
- break;
- case LOCK_SH: /* shared */
- if (LockFileEx(hdl, ((op & LOCK_NB) ? LOCKFILE_FAIL_IMMEDIATELY : 0),
- 0, low, high, &offset))
- return 0;
- break;
- case LOCK_UN: /* unlock */
- return 0; /* always succeeds */
- default: /* default */
- break;
- }
- errno = EINVAL; /* bad call */
- return -1;
-}
diff --git a/win32/flock.h b/win32/flock.h
deleted file mode 100644
index fe07adf954..0000000000
--- a/win32/flock.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#define fsync _commit
-#define ftruncate chsize
-
-/* For flock() emulation */
-
-#define LOCK_SH 1
-#define LOCK_EX 2
-#define LOCK_NB 4
-#define LOCK_UN 8
-
-extern int flock(int fd, int op);
diff --git a/win32/grp.h b/win32/grp.h
deleted file mode 100644
index e7a99327e2..0000000000
--- a/win32/grp.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* pwd.h - Try to approximate UN*X's getuser...() functions under MS-DOS.
- Copyright (C) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
-
- 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 1, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- $Header$
- */
-
-/* This 'implementation' is conjectured from the use of this functions in
- the RCS and BASH distributions. Of course these functions don't do too
- much useful things under MS-DOS, but using them avoids many "#ifdef
- MSDOS" in ported UN*X code ... */
-
-struct group {
- char *gr_name; /* group name */
- char *gr_passwd; /* group password */
- int gr_gid; /* group id */
- char **gr_mem; /* group members */
-};
diff --git a/win32/param.h b/win32/param.h
deleted file mode 100644
index 3d0da1e8d3..0000000000
--- a/win32/param.h
+++ /dev/null
@@ -1,16 +0,0 @@
-
-/*****************************************************************************
- * *
- * sys/param.c *
- * *
- * Freely redistributable and modifiable. Use at your own risk. *
- * *
- * Copyright 1994 The Downhill Project *
- * *
- *****************************************************************************/
-#ifndef MAXPATHLEN
-#define MAXPATHLEN _MAX_PATH
-#endif
-#define MAXHOSTNAMELEN 64
-#define howmany(x,y) (((x)+((y)-1))/(y))
-#define roundup(x,y) ((((x)+((y)-1))/(y))*(y))
diff --git a/win32/php_modules.dsw b/win32/php_modules.dsw
deleted file mode 100644
index 9ca4b269e7..0000000000
--- a/win32/php_modules.dsw
+++ /dev/null
@@ -1,41 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "libzendts"=.\libzend\libzendts.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "mysql"=.\ext\mysql\mysql.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/win32/php_registry.h b/win32/php_registry.h
deleted file mode 100644
index ad722a5607..0000000000
--- a/win32/php_registry.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _PHP_REGISTRY_H
-#define _PHP_REGISTRY_H
-
-
-void UpdateIniFromRegistry(char *path);
-
-#endif /* _PHP_REGISTRY_H */ \ No newline at end of file
diff --git a/win32/pwd.c b/win32/pwd.c
deleted file mode 100644
index 73c4b62c95..0000000000
--- a/win32/pwd.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* pwd.c - Try to approximate UN*X's getuser...() functions under MS-DOS.
- Copyright (C) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
-
- 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 1, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- $Header$
- */
-
-/* This 'implementation' is conjectured from the use of this functions in
- the RCS and BASH distributions. Of course these functions don't do too
- much useful things under MS-DOS, but using them avoids many "#ifdef
- MSDOS" in ported UN*X code ... */
-
-#include "php.h" /*php specific */
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <lmaccess.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <lmapibuf.h>
-#include "pwd.h"
-#include "grp.h"
-
-#ifndef THREAD_SAFE
-static struct passwd pw; /* should we return a malloc()'d structure */
-#endif
-static char *home_dir = "."; /* we feel (no|every)where at home */
-static char *login_shell = "not command.com!";
-
-struct passwd *getpwnam(char *name)
-{
- return (struct passwd *) 0;
-}
-
-
-char *getlogin()
-{
- static char name[256];
- DWORD dw = 256;
- GetUserName(name, &dw);
- return name;
-}
-
-struct passwd *
- getpwuid(int uid)
-{
- pw.pw_name = getlogin();
- pw.pw_dir = home_dir;
- pw.pw_shell = login_shell;
- pw.pw_uid = 0;
-
- return &pw;
-}
-
-/*
- * Local Variables:
- * mode:C
- * ChangeLog:ChangeLog
- * compile-command:make
- * End:
- */
diff --git a/win32/pwd.h b/win32/pwd.h
deleted file mode 100644
index d0ae7ac35b..0000000000
--- a/win32/pwd.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* pwd.h - Try to approximate UN*X's getuser...() functions under MS-DOS.
- Copyright (C) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
-
- 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 1, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- $Header$
- */
-
-/* This 'implementation' is conjectured from the use of this functions in
- the RCS and BASH distributions. Of course these functions don't do too
- much useful things under MS-DOS, but using them avoids many "#ifdef
- MSDOS" in ported UN*X code ... */
-/*
- #define WIN32_LEAN_AND_MEAN
- #include <windows.h>
- */
-#ifndef _PWD_H_
-#define _PWD_H_
-#if 0
-/* This is taken care of in Windows-NT/config.h. */
-typedef int uid_t;
-#endif
-
-struct passwd {
- char *pw_name; /* user name */
- char *pw_passwd; /* encrypted password */
- int pw_uid; /* user uid */
- int pw_gid; /* user gid */
- char *pw_comment; /* comment */
- char *pw_gecos; /* Honeywell login info */
- char *pw_dir; /* home directory */
- char *pw_shell; /* default shell */
-};
-
-extern struct passwd *getpwuid(int);
-extern struct passwd *getpwnam(char *name);
-extern char *getlogin(void);
-#endif
-/*
- * Local Variables:
- * mode:C
- * ChangeLog:ChangeLog
- * compile-command:make
- * End:
- */
diff --git a/win32/readdir.c b/win32/readdir.c
deleted file mode 100644
index 5a680ff5a7..0000000000
--- a/win32/readdir.c
+++ /dev/null
@@ -1,112 +0,0 @@
-#include <malloc.h>
-#include <string.h>
-#include <errno.h>
-
-#define NEEDRDH 1
-#include "readdir.h"
-#include "php.h"
-
-/**********************************************************************
- * Implement dirent-style opendir/readdir/closedir on Window 95/NT
- *
- * Functions defined are opendir(), readdir() and closedir() with the
- * same prototypes as the normal dirent.h implementation.
- *
- * Does not implement telldir(), seekdir(), rewinddir() or scandir().
- * The dirent struct is compatible with Unix, except that d_ino is
- * always 1 and d_off is made up as we go along.
- *
- * The DIR typedef is not compatible with Unix.
- **********************************************************************/
-
-DIR *opendir(const char *dir)
-{
- DIR *dp;
- char *filespec;
- long handle;
- int index;
-
- filespec = malloc(strlen(dir) + 2 + 1);
- strcpy(filespec, dir);
- index = strlen(filespec) - 1;
- if (index >= 0 && (filespec[index] == '/' || filespec[index] == '\\'))
- filespec[index] = '\0';
- strcat(filespec, "/*");
-
- dp = (DIR *) malloc(sizeof(DIR));
- dp->offset = 0;
- dp->finished = 0;
- dp->dir = strdup(dir);
-
- if ((handle = _findfirst(filespec, &(dp->fileinfo))) < 0) {
- if (errno == ENOENT)
- dp->finished = 1;
- else
- return NULL;
- }
- dp->handle = handle;
- free(filespec);
-
- return dp;
-}
-
-struct dirent *readdir(DIR * dp)
-{
- if (!dp || dp->finished)
- return NULL;
-
- if (dp->offset != 0) {
- if (_findnext(dp->handle, &(dp->fileinfo)) < 0) {
- dp->finished = 1;
- return NULL;
- }
- }
- dp->offset++;
-
- strlcpy(dp->dent.d_name, dp->fileinfo.name, _MAX_FNAME+1);
- dp->dent.d_ino = 1;
- dp->dent.d_reclen = strlen(dp->dent.d_name);
- dp->dent.d_off = dp->offset;
-
- return &(dp->dent);
-}
-
-int closedir(DIR * dp)
-{
- if (!dp)
- return 0;
- _findclose(dp->handle);
- if (dp->dir)
- free(dp->dir);
- if (dp)
- free(dp);
-
- return 0;
-}
-
-void rewinddir(DIR *dir_Info)
-{
- /* Re-set to the beginning */
- char *filespec;
- long handle;
- int index;
-
- dir_Info->handle = 0;
- dir_Info->offset = 0;
- dir_Info->finished = 0;
-
- filespec = malloc(strlen(dir_Info->dir) + 2 + 1);
- strcpy(filespec, dir_Info->dir);
- index = strlen(filespec) - 1;
- if (index >= 0 && (filespec[index] == '/' || filespec[index] == '\\'))
- filespec[index] = '\0';
- strcat(filespec, "/*");
-
- if ((handle = _findfirst(filespec, &(dir_Info->fileinfo))) < 0) {
- if (errno == ENOENT) {
- dir_Info->finished = 1;
- }
- }
- dir_Info->handle = handle;
- free(filespec);
-}
diff --git a/win32/readdir.h b/win32/readdir.h
deleted file mode 100644
index d7edb586f5..0000000000
--- a/win32/readdir.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Structures and types used to implement opendir/readdir/closedir
- * on Windows 95/NT.
- */
-
-#include <io.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-
-
-/* struct dirent - same as Unix */
-#if NEEDRDH
-
-struct dirent {
- long d_ino; /* inode (always 1 in WIN32) */
- off_t d_off; /* offset to this dirent */
- unsigned short d_reclen; /* length of d_name */
- char d_name[_MAX_FNAME + 1]; /* filename (null terminated) */
-};
-
-/* typedef DIR - not the same as Unix */
-typedef struct {
- long handle; /* _findfirst/_findnext handle */
- short offset; /* offset into directory */
- short finished; /* 1 if there are not more files */
- struct _finddata_t fileinfo; /* from _findfirst/_findnext */
- char *dir; /* the dir we are reading */
- struct dirent dent; /* the dirent to return */
-} DIR;
-
-/* Function prototypes */
-DIR *opendir(const char *);
-struct dirent *readdir(DIR *);
-int closedir(DIR *);
-void rewinddir(DIR *);
-
-#endif
diff --git a/win32/registry.c b/win32/registry.c
deleted file mode 100644
index ec43b30596..0000000000
--- a/win32/registry.c
+++ /dev/null
@@ -1,74 +0,0 @@
-#include "php.h"
-#include "php_ini.h"
-#include "php_registry.h"
-
-void UpdateIniFromRegistry(char *path)
-{
- char *p, *orig_path;
- HKEY MainKey;
-
-
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\PHP\\Per Directory Values", 0, KEY_READ, &MainKey)!=ERROR_SUCCESS) {
- return;
- }
-
-
- orig_path = path = estrdup(path);
-
- /* Get rid of C:, if exists */
- p = strchr(path, ':');
- if (p) {
- path = p+1;
- } else {
- if (path[0] != '\\' && path[0] != '/') {
- char tmp_buf[MAXPATHLEN], *cwd;
-
- /* get current working directory and prepend it to the path */
- if (!getcwd(tmp_buf, MAXPATHLEN)) {
- efree(orig_path);
- return;
- }
- cwd = strchr(tmp_buf, ':');
- if (!cwd) {
- cwd = tmp_buf;
- } else {
- cwd++;
- }
- path = (char *) emalloc(strlen(cwd)+1+strlen(orig_path)+1);
- sprintf(path, "%s\\%s", cwd, orig_path);
- efree(orig_path);
- orig_path = path;
- }
- }
-
-
- path++; /* step over the first / */
- path = p = strtok(path, "\\/");
-
- while (p) {
- HKEY hKey;
- char namebuf[256], valuebuf[256];
- DWORD lType;
- DWORD namebuf_length=256, valuebuf_length=256;
- DWORD i=0;
-
- if (p>path) {
- *(p-1) = '\\';
- }
- if (RegOpenKeyEx(MainKey, path, 0, KEY_READ, &hKey)!=ERROR_SUCCESS) {
- break;
- }
- while (RegEnumValue(hKey, i++, namebuf, &namebuf_length, NULL, &lType, valuebuf, &valuebuf_length)==ERROR_SUCCESS) {
- if (lType != REG_SZ) {
- continue;
- }
- printf("%s -> %s\n", namebuf, valuebuf);
- php_alter_ini_entry(namebuf, namebuf_length+1, valuebuf, valuebuf_length+1, PHP_INI_PERDIR);
- }
-
- RegCloseKey(hKey);
- p = strtok(NULL, "\\/");
- }
- RegCloseKey(MainKey);
- efree(orig_path);
-}
diff --git a/win32/sendmail.c b/win32/sendmail.c
deleted file mode 100644
index 659bc134a4..0000000000
--- a/win32/sendmail.c
+++ /dev/null
@@ -1,501 +0,0 @@
-
-/*
- * PHP Sendmail for Windows.
- *
- * This file is rewriten specificly for PHPFI. Some functionality
- * has been removed (MIME and file attachments). This code was
- * modified from code based on code writen by Jarle Aase.
- *
- * This class is based on the original code by Jarle Aase, see bellow:
- * wSendmail.cpp It has been striped of some functionality to match
- * the requirements of phpfi.
- *
- * Very simple SMTP Send-mail program for sending command-line level
- * emails and CGI-BIN form response for the Windows platform.
- *
- * The complete wSendmail package with source code can be downloaded
- * from http://virtual.icr.com.au:80/jgaa/cgi-bin.htm
- *
- */
-
-#include "php.h" /*php specific */
-#include <stdio.h>
-#include <stdlib.h>
-#include <winsock.h>
-#include "time.h"
-#include <string.h>
-#include <malloc.h>
-#include <memory.h>
-#include <winbase.h>
-#include "sendmail.h"
-#include "php_ini.h"
-
-/*
- extern int _daylight;
- extern long _timezone;
- */
-/*enum
- {
- DO_CONNECT = WM_USER +1
- };
- */
-
-static char *days[] =
-{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
-static char *months[] =
-{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
-
-#ifndef THREAD_SAFE
-char Buffer[MAIL_BUFFER_SIZE];
-
-// socket related data
-SOCKET sc;
-WSADATA Data;
-struct hostent *adr;
-SOCKADDR_IN sock_in;
-int WinsockStarted;
-// values set by the constructor
-char *AppName;
-char MailHost[HOST_NAME_LEN];
-char LocalHost[HOST_NAME_LEN];
-#endif
-char seps[] = " ,\t\n";
-char *php_mailer = "PHP 3.0 WIN32";
-
-char *get_header(char *h, char *headers);
-
-// Error messages
-static char *ErrorMessages[] =
-{
- {"Success"},
- {"Bad arguments from form"},
- {"Unable to open temporary mailfile for read"},
- {"Failed to Start Sockets"},
- {"Failed to Resolve Host"},
- {"Failed to obtain socket handle"},
- {"Failed to Connect"},
- {"Failed to Send"},
- {"Failed to Receive"},
- {"Server Error"},
- {"Failed to resolve the host IP name"},
- {"Out of memory"},
- {"Unknown error"},
- {"Bad Message Contents"},
- {"Bad Message Subject"},
- {"Bad Message destination"},
- {"Bad Message Return Path"},
- {"Bad Mail Host"},
- {"Bad Message File"},
- {"PHP Internal error: php.ini sendmail from variable not set!"}
-};
-
-
-
-//********************************************************************
-// Name: TSendMail
-// Input: 1) host: Name of the mail host where the SMTP server resides
-// max accepted length of name = 256
-// 2) appname: Name of the application to use in the X-mailer
-// field of the message. if NULL is given the application
-// name is used as given by the GetCommandLine() function
-// max accespted length of name = 100
-// Output: 1) error: Returns the error code if something went wrong or
-// SUCCESS otherwise.
-//
-// See SendText() for additional args!
-//********************************************************************
-int TSendMail(char *host, int *error,
- char *headers, char *Subject, char *mailTo, char *data)
-{
- int ret;
- char *RPath = NULL;
-
- WinsockStarted = FALSE;
-
- if (host == NULL) {
- *error = BAD_MAIL_HOST;
- return BAD_MAIL_HOST;
- } else if (strlen(host) >= HOST_NAME_LEN) {
- *error = BAD_MAIL_HOST;
- return BAD_MAIL_HOST;
- } else {
- strcpy(MailHost, host);
- }
-
- if (INI_STR("sendmail_from")){
- RPath = estrdup(INI_STR("sendmail_from"));
- } else {
- return 19;
- }
-
- // attempt to connect with mail host
- *error = MailConnect();
- if (*error != 0) {
- if(RPath)efree(RPath);
- return *error;
- } else {
- ret = SendText(RPath, Subject, mailTo, data, headers);
- TSMClose();
- if (ret != SUCCESS) {
- *error = ret;
- }
- if(RPath)efree(RPath);
- return ret;
- }
-}
-
-//********************************************************************
-// Name: TSendMail::~TSendMail
-// Input:
-// Output:
-// Description: DESTRUCTOR
-// Author/Date: jcar 20/9/96
-// History:
-//********************************************************************
-void TSMClose()
-{
- Post("QUIT\n");
- Ack();
- // to guarantee that the cleanup is not made twice and
- // compomise the rest of the application if sockets are used
- // elesewhere
-}
-
-
-//********************************************************************
-// Name: char *GetSMErrorText
-// Input: Error index returned by the menber functions
-// Output: pointer to a string containing the error description
-// Description:
-// Author/Date: jcar 20/9/96
-// History:
-//********************************************************************
-char *GetSMErrorText(int index)
-{
-
- if ((index > MAX_ERROR_INDEX) || (index < MIN_ERROR_INDEX))
- return (ErrorMessages[UNKNOWN_ERROR]);
- else
- return (ErrorMessages[index]);
-}
-
-
-//********************************************************************
-// Name: TSendText
-// Input: 1) RPath: return path of the message
-// Is used to fill the "Return-Path" and the
-// "X-Sender" fields of the message.
-// 2) Subject: Subject field of the message. If NULL is given
-// the subject is set to "No Subject"
-// 3) mailTo: Destination address
-// 4) data: Null terminated string containing the data to be send.
-// Output: Error code or SUCCESS
-// Description:
-// Author/Date: jcar 20/9/96
-// History:
-//********************************************************************
-int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers)
-{
-
- int res, i;
- char *p;
-
- // check for NULL parameters
- if (data == NULL)
- return (BAD_MSG_CONTENTS);
- if (mailTo == NULL)
- return (BAD_MSG_DESTINATION);
- if (RPath == NULL)
- return (BAD_MSG_RPATH);
-
- // simple checks for the mailto address
- // have ampersand ?
- if (strchr(mailTo, '@') == NULL)
- return (BAD_MSG_DESTINATION);
-
- sprintf(Buffer, "HELO %s\n", LocalHost);
-
- // in the beggining of the dialog
- // attempt reconnect if the first Post fail
- if ((res = Post(Buffer)) != SUCCESS) {
- MailConnect();
- if ((res = Post(Buffer)) != SUCCESS)
- return (res);
- }
- if ((res = Ack()) != SUCCESS)
- return (res);
-
- sprintf(Buffer, "MAIL FROM:<%s>\n", RPath);
- if ((res = Post(Buffer)) != SUCCESS)
- return (res);
- if ((res = Ack()) != SUCCESS)
- return (res);
-
-
- sprintf(Buffer, "RCPT TO:<%s>\n", mailTo);
- if ((res = Post(Buffer)) != SUCCESS)
- return (res);
- if ((res = Ack()) != SUCCESS)
- return (res);
-
- if ((res = Post("DATA\n")) != SUCCESS)
- return (res);
- if ((res = Ack()) != SUCCESS)
- return (res);
-
-
- // send message header
- if (Subject == NULL)
- res = PostHeader(RPath, "No Subject", mailTo, headers);
- else
- res = PostHeader(RPath, Subject, mailTo, headers);
- if (res != SUCCESS)
- return (res);
-
-
- // send message contents in 1024 chunks
- if (strlen(data) <= 1024) {
- if ((res = Post(data)) != SUCCESS)
- return (res);
- } else {
- p = data;
- while (1) {
- if (*p == '\0')
- break;
- if (strlen(p) >= 1024)
- i = 1024;
- else
- i = strlen(p);
-
- // put next chunk in buffer
- strncpy(Buffer, p, i);
- Buffer[i] = '\0';
- p += i;
-
- // send chunk
- if ((res = Post(Buffer)) != SUCCESS)
- return (res);
- }
- }
-
- //send termination dot
- if ((res = Post("\r\n.\r\n")) != SUCCESS)
- return (res);
- if ((res = Ack()) != SUCCESS)
- return (res);
-
- return (SUCCESS);
-}
-
-
-
-//********************************************************************
-// Name: PostHeader
-// Input: 1) return path
-// 2) Subject
-// 3) destination address
-// 4) DoMime flag
-// Output: Error code or Success
-// Description:
-// Author/Date: jcar 20/9/96
-// History:
-//********************************************************************
-int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders)
-{
-
- // Print message header according to RFC 822
- // Return-path, Received, Date, From, Subject, Sender, To, cc
-
- time_t tNow = time(NULL);
- struct tm *tm = localtime(&tNow);
- int zoneh = abs(_timezone);
- int zonem, res;
- char *p;
-
- p = Buffer;
- zoneh /= (60 * 60);
- zonem = (abs(_timezone) / 60) - (zoneh * 60);
-
- if(!xheaders || !strstr(xheaders, "Date:")){
- p += sprintf(p, "Date: %s, %02d %s %04d %02d:%02d:%02d %s%02d%02d\r\n",
- days[tm->tm_wday],
- tm->tm_mday,
- months[tm->tm_mon],
- tm->tm_year + 1900,
- tm->tm_hour,
- tm->tm_min,
- tm->tm_sec,
- (_timezone > 0) ? "+" : (_timezone < 0) ? "-" : "",
- zoneh,
- zonem);
- }
-
- if(!xheaders || !strstr(xheaders, "From:")){
- p += sprintf(p, "From: %s\r\n", RPath);
- }
- p += sprintf(p, "Subject: %s\r\n", Subject);
- p += sprintf(p, "To: %s\r\n", mailTo);
- if(xheaders){
- p += sprintf(p, "%s\r\n", xheaders);
- }
-
- if ((res = Post(Buffer)) != SUCCESS)
- return (res);
-
- if ((res = Post("\r\n")) != SUCCESS)
- return (res);
-
- return (SUCCESS);
-}
-
-
-
-//********************************************************************
-// Name: MailConnect
-// Input: None
-// Output: None
-// Description: Connect to the mail host and receive the welcome message.
-// Author/Date: jcar 20/9/96
-// History:
-//********************************************************************
-int MailConnect()
-{
-
- int res;
-
- // Create Socket
- if ((sc = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
- return (FAILED_TO_OBTAIN_SOCKET_HANDLE);
-
- // Get our own host name
- if (gethostname(LocalHost, HOST_NAME_LEN))
- return (FAILED_TO_GET_HOSTNAME);
-
- // Resolve the servers IP
- //if (!isdigit(MailHost[0])||!gethostbyname(MailHost))
- //{
- // return (FAILED_TO_RESOLVE_HOST);
- //}
-
- // Connect to server
- sock_in.sin_family = AF_INET;
- sock_in.sin_port = htons(25);
- sock_in.sin_addr.S_un.S_addr = GetAddr(MailHost);
-
- if (connect(sc, (LPSOCKADDR) & sock_in, sizeof(sock_in)))
- return (FAILED_TO_CONNECT);
-
- // receive Server welcome message
- res = Ack();
- return (res);
-}
-
-
-
-
-
-
-//********************************************************************
-// Name: Post
-// Input:
-// Output:
-// Description:
-// Author/Date: jcar 20/9/96
-// History:
-//********************************************************************
-int Post(LPCSTR msg)
-{
- int len = strlen(msg);
- int slen;
- int index = 0;
-
- while (len > 0) {
- if ((slen = send(sc, msg + index, len, 0)) < 1)
- return (FAILED_TO_SEND);
- len -= slen;
- index += slen;
- }
- return (SUCCESS);
-}
-
-
-
-//********************************************************************
-// Name: Ack
-// Input:
-// Output:
-// Description:
-// Get the response from the server. We only want to know if the
-// last command was successful.
-// Author/Date: jcar 20/9/96
-// History:
-//********************************************************************
-int Ack()
-{
- static char *buf;
- int rlen;
- int Index = 0;
- int Received = 0;
-
- if (!buf)
- if ((buf = (char *) malloc(1024 * 4)) == NULL)
- return (OUT_OF_MEMORY);
-
- again:
-
- if ((rlen = recv(sc, buf + Index, ((1024 * 4) - 1) - Received, 0)) < 1)
- return (FAILED_TO_RECEIVE);
-
- Received += rlen;
- buf[Received] = 0;
- //err_msg fprintf(stderr,"Received: (%d bytes) %s", rlen, buf + Index);
-
- // Check for newline
- Index += rlen;
- if ((buf[Received - 2] != '\r') || (buf[Received - 1] != '\n'))
- // err_msg fprintf(stderr,"Incomplete server message. Awaiting CRLF\n");
- goto again; // Incomplete data. Line must be terminated by CRLF
-
- if (buf[0] > '3')
- return (SMTP_SERVER_ERROR);
-
- return (SUCCESS);
-}
-
-
-//********************************************************************
-// Name: unsigned long GetAddr (LPSTR szHost)
-// Input:
-// Output:
-// Description: Given a string, it will return an IP address.
-// - first it tries to convert the string directly
-// - if that fails, it tries o resolve it as a hostname
-//
-// WARNING: gethostbyname() is a blocking function
-// Author/Date: jcar 20/9/96
-// History:
-//********************************************************************
-unsigned long GetAddr(LPSTR szHost)
-{
- LPHOSTENT lpstHost;
- u_long lAddr = INADDR_ANY;
-
- /* check that we have a string */
- if (*szHost) {
-
- /* check for a dotted-IP address string */
- lAddr = inet_addr(szHost);
-
- /* If not an address, then try to resolve it as a hostname */
- if ((lAddr == INADDR_NONE) && (strcmp(szHost, "255.255.255.255"))) {
-
- lpstHost = gethostbyname(szHost);
- if (lpstHost) { /* success */
- lAddr = *((u_long FAR *) (lpstHost->h_addr));
- } else {
- lAddr = INADDR_ANY; /* failure */
- }
- }
- }
- return (lAddr);
-} /* end GetAddr() */
diff --git a/win32/sendmail.h b/win32/sendmail.h
deleted file mode 100644
index 3c426fb219..0000000000
--- a/win32/sendmail.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#if !defined(sendmail_h) // Sentry, use file only if it's not already included.
-#define sendmail_h
-#include <windows.h>
-
-#define HOST_NAME_LEN 256
-#define MAX_APPNAME_LENGHT 100
-#define MAX_ERROR_INDEX 17
-#define MIN_ERROR_INDEX 0
-#define MAIL_BUFFER_SIZE (1024*4) // 4k buffer
-// Return values
-#define SUCCESS 0
-#define FAILED_TO_PARSE_ARGUMENTS 1
-#define FAILED_TO_OPEN_MAILFILE 2
-#define FAILED_TO_START_SOCKETS 3
-#define FAILED_TO_RESOLVE_HOST 4
-#define FAILED_TO_OBTAIN_SOCKET_HANDLE 5
-#define FAILED_TO_CONNECT 6
-#define FAILED_TO_SEND 7
-#define FAILED_TO_RECEIVE 8
-#define SMTP_SERVER_ERROR 9
-#define FAILED_TO_GET_HOSTNAME 10
-#define OUT_OF_MEMORY 11
-#define UNKNOWN_ERROR 12
-#define BAD_MSG_CONTENTS 13
-#define BAD_MSG_SUBJECT 14
-#define BAD_MSG_DESTINATION 15
-#define BAD_MSG_RPATH 16
-#define BAD_MAIL_HOST 17
-#define BAD_MSG_FILE 18
-
-
-int TSendMail(char *smtpaddr, int *returnerror,
- char *RPath, char *Subject, char *mailTo, char *data);
-void TSMClose(void);
-int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers);
-char *GetSMErrorText(int index);
-
-int MailConnect();
-int PostHeader(char *, char *, char *, char *);
-int Post(LPCSTR);
-int Ack();
-unsigned long GetAddr(LPSTR szHost);
-
-
-
-#endif // sendmail_h
diff --git a/win32/signal.h b/win32/signal.h
deleted file mode 100644
index a95b15c102..0000000000
--- a/win32/signal.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
-** Change here: if you plan to use your own version of <signal.h>
-** the original "#include <signal.h>" produces an infinite reinclusion
-** of this file, instead of including the standard include-file.
-** Under MS Visual Studio, there are occurences in the source where
-** <signal.h> gets included throughout the PHP4 sources, and this should
-** include THIS file, not the standard one which does not have the
-** additional signals defined below.
-** One way to remove the infinite reinclusion of this file (which is located
-** in ../win32), is to specify the parent directory in which the standard
-** include file is located.
-*/
-#include <../include/signal.h>
-#define SIGALRM 13
-#define SIGVTALRM 26 /* virtual time alarm */
-#define SIGPROF 27 /* profiling time alarm */
diff --git a/win32/syslog.h b/win32/syslog.h
deleted file mode 100644
index 22239fb4e5..0000000000
--- a/win32/syslog.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * This header borrowed from Cygnus GNUwin32 project
- *
- * Modified for use with functions to map syslog
- * calls to EventLog calls on the windows platform
- *
- * much of this is not used, but here for the sake of
- * error free compilation. EventLogs will most likely
- * not behave as syslog does, but may be useful anyway.
- * much of what syslog does can be emulated here, but
- * that will have to be done later.
- */
-
-#ifndef _SYS_LOG_H
-#define _SYS_LOG_H
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-#define LOG_EMERG 1
-#define LOG_ALERT 1
-#define LOG_CRIT 1
-#define LOG_ERR 4
-#define LOG_WARNING 5
-#define LOG_NOTICE 6
-#define LOG_INFO 6
-#define LOG_DEBUG 6
-
-#define LOG_PRIMASK 0x07
-
-#define LOG_PRI(p) ((p) & LOG_PRIMASK)
-#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
-
-#define LOG_KERN (0<<3)
-#define LOG_USER (1<<3)
-#define LOG_MAIL (2<<3)
-#define LOG_DAEMON (3<<3)
-#define LOG_AUTH (4<<3)
-#define LOG_SYSLOG (5<<3)
-#define LOG_LPR (6<<3)
-#define LOG_NEWS (7<<3)
-#define LOG_UUCP (8<<3)
-#define LOG_CRON (9<<3)
-#define LOG_AUTHPRIV (10<<3)
-
-#define LOG_NFACILITIES 10
-#define LOG_FACMASK 0x03f8
-#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
-
-#define LOG_MASK(pri) (1 << (pri))
-#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1)
-
-/*
- * Option flags for openlog.
- *
- * LOG_ODELAY no longer does anything.
- * LOG_NDELAY is the inverse of what it used to be.
- */
-#define LOG_PID 0x01 /* log the pid with each message */
-#define LOG_CONS 0x02 /* log on the console if errors in sending */
-#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */
-#define LOG_NDELAY 0x08 /* don't delay open */
-#define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */
-#define LOG_PERROR 0x20 /* log to stderr as well */
-
-
-extern void closelog(void);
-extern void openlog(const char *, int, int);
-// setlogmask not implemented
-//extern int setlogmask (int);
-extern void syslog(int, const char *,...);
-
-
-#endif /* _SYS_LOG_H */
diff --git a/win32/time.c b/win32/time.c
deleted file mode 100644
index c1089283e3..0000000000
--- a/win32/time.c
+++ /dev/null
@@ -1,153 +0,0 @@
-
-/*****************************************************************************
- * *
- * DH_TIME.C *
- * *
- * Freely redistributable and modifiable. Use at your own risk. *
- * *
- * Copyright 1994 The Downhill Project *
- *
- * Modified by Shane Caraveo for use with PHP
- *
- *****************************************************************************/
-
-
-/* Include stuff ************************************************************ */
-
-#include "time.h"
-#include "unistd.h"
-#include "signal.h"
-#include <winbase.h>
-#include <mmsystem.h>
-#include <errno.h>
-
-int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info)
-{
- _int64 mstimer, freq;
- /* Get the time, if they want it */
- if (time_Info != NULL) {
- time_Info->tv_sec = time(NULL);
- /* get ticks-per-second of the performance counter
- Note the necessary typecast to a LARGE_INTEGER structure
- */
- if (!QueryPerformanceFrequency((LARGE_INTEGER *) & freq)) {
- time_Info->tv_usec = 0;
- } else {
- QueryPerformanceCounter((LARGE_INTEGER *) & mstimer);
- mstimer = (__int64) (mstimer * .8);
- time_Info->tv_usec = (long) (mstimer % 0x0FFFFFFF);
- }
- }
- /* Get the timezone, if they want it */
- if (timezone_Info != NULL) {
- _tzset();
- timezone_Info->tz_minuteswest = _timezone;
- timezone_Info->tz_dsttime = _daylight;
- }
- /* And return */
- return 0;
-}
-
-
-/* this usleep isnt exactly accurate but should do ok */
-void usleep(unsigned int useconds)
-{
- __int64 mstimer, freq;
- long now, then;
- if (QueryPerformanceFrequency((LARGE_INTEGER *) & freq)) {
- QueryPerformanceCounter((LARGE_INTEGER *) & mstimer);
- now = (long) (((__int64) (mstimer * .8)) % 0x0FFFFFFF);
- then = now + useconds;
- while (now < then) {
- QueryPerformanceCounter((LARGE_INTEGER *) & mstimer);
- now = (long) (((__int64) (mstimer * .8)) % 0x0FFFFFFF);
- }
- } else {
- /*workaround for systems without performance counter
- this is actualy a millisecond sleep */
- Sleep((int) (useconds / 1000));
- }
-}
-
-
-#ifdef HAVE_SETITIMER
-
-
-#ifndef THREAD_SAFE
-unsigned int proftimer, virttimer, realtimer;
-extern LPMSG phpmsg;
-#endif
-
-struct timer_msg {
- int signal;
- unsigned int threadid;
-};
-
-
-LPTIMECALLBACK setitimer_timeout(UINT uTimerID, UINT info, DWORD dwUser, DWORD dw1, DWORD dw2)
-{
- struct timer_msg *msg = (struct timer_msg *) info;
-
- if (msg) {
- raise((int) msg->signal);
- PostThreadMessage(msg->threadid,
- WM_NOTIFY, msg->signal, 0);
- free(msg);
- }
- return 0;
-}
-
-int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue)
-{
- int timeout = value->it_value.tv_sec * 1000 + value->it_value.tv_usec;
- int repeat = TIME_ONESHOT;
-
- /*make sure the message queue is initialized */
- PeekMessage(phpmsg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
- if (timeout > 0) {
- struct timer_msg *msg = malloc(sizeof(struct timer_msg));
- msg->threadid = GetCurrentThreadId();
- if (!ovalue) {
- repeat = TIME_PERIODIC;
- }
- switch (which) {
- case ITIMER_REAL:
- msg->signal = SIGALRM;
- realtimer = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat);
- break;
- case ITIMER_VIRT:
- msg->signal = SIGVTALRM;
- virttimer = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat);
- break;
- case ITIMER_PROF:
- msg->signal = SIGPROF;
- proftimer = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat);
- break;
- default:
- errno = EINVAL;
- return -1;
- break;
- }
- } else {
- switch (which) {
- case ITIMER_REAL:
- timeKillEvent(realtimer);
- break;
- case ITIMER_VIRT:
- timeKillEvent(virttimer);
- break;
- case ITIMER_PROF:
- timeKillEvent(proftimer);
- break;
- default:
- errno = EINVAL;
- return -1;
- break;
- }
- }
-
-
- return 0;
-}
-
-#endif
diff --git a/win32/time.h b/win32/time.h
deleted file mode 100644
index e5abd293c3..0000000000
--- a/win32/time.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*****************************************************************************
- * *
- * sys/time.h *
- * *
- * Freely redistributable and modifiable. Use at your own risk. *
- * *
- * Copyright 1994 The Downhill Project *
- *
- * Modified by Shane Caraveo for PHP
- *
- *****************************************************************************/
-
-
-/* Include stuff ************************************************************ */
-#include <winsock.h>
-#include <time.h>
-
-/* Struct stuff ************************************************************* */
-struct timezone {
- int tz_minuteswest;
- int tz_dsttime;
-};
-
-
-struct itimerval {
- struct timeval it_interval; /* next value */
- struct timeval it_value; /* current value */
-};
-
-#define ITIMER_REAL 0 /*generates sigalrm */
-#define ITIMER_VIRTUAL 1 /*generates sigvtalrm */
-#define ITIMER_VIRT 1 /*generates sigvtalrm */
-#define ITIMER_PROF 2 /*generates sigprof */
-
-/* Prototype stuff ********************************************************** */
-extern int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info);
-
-/* setitimer operates at 100 millisecond resolution */
-extern int setitimer(int which, const struct itimerval *value,
- struct itimerval *ovalue);
diff --git a/win32/unistd.h b/win32/unistd.h
deleted file mode 100644
index 5604103ec9..0000000000
--- a/win32/unistd.h
+++ /dev/null
@@ -1 +0,0 @@
-extern void usleep(unsigned int useconds);
diff --git a/win32/wfile.c b/win32/wfile.c
deleted file mode 100644
index 1407d6a32b..0000000000
--- a/win32/wfile.c
+++ /dev/null
@@ -1,17 +0,0 @@
-
-/* Function borrowed from the Downhill Project */
-#include "wfile.h"
-#include "direct.h"
-
-int readlink(char *file_Name, char *buf_Mem, int buf_Size)
-{
- /* See if the file exists */
- if (access(file_Name, X_OK) == -1) {
- errno = ENOENT;
- } else {
- errno = EINVAL;
- }
-
- /* Either way, it's not a link */
- return -1;
-}
diff --git a/win32/wfile.h b/win32/wfile.h
deleted file mode 100644
index 2e79406478..0000000000
--- a/win32/wfile.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <io.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#define access _access
-#define X_OK 0
-#ifndef ENOENT
-#define ENOENT 136
-#endif
-#ifndef EINVAL
-#define EINVAL 131
-#endif
-
-int readlink(char *, char *, int);
-int checkroot(char *path);
diff --git a/win32/winutil.c b/win32/winutil.c
deleted file mode 100644
index d22aa308dc..0000000000
--- a/win32/winutil.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include "winutil.h"
-
-#ifndef THREAD_SAFE
-static char Win_Error_msg[256];
-#endif
-
-char *php3_win_err(void)
-{
- FormatMessage(
- FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPTSTR) Win_Error_msg,
- 256,
- NULL);
-
- return Win_Error_msg;
-}
diff --git a/win32/winutil.h b/win32/winutil.h
deleted file mode 100644
index ca6c63a245..0000000000
--- a/win32/winutil.h
+++ /dev/null
@@ -1 +0,0 @@
-extern char *php3_win_err(void);
diff --git a/win32/wsyslog.c b/win32/wsyslog.c
deleted file mode 100644
index 616b6f8a07..0000000000
--- a/win32/wsyslog.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * This file modified from sources for imap4 for use
- * in PHP 3
- */
-/*
- * Program: Unix compatibility routines
- *
- * Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
- *
- * Date: 14 September 1996
- * Last Edited: 22 October 1996
- *
- * Copyright 1996 by the University of Washington
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appears in all copies and that both the
- * above copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the University of Washington not be
- * used in advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission. This software is made available
- * "as is", and
- * THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
- * WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION ALL IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND IN
- * NO EVENT SHALL THE UNIVERSITY OF WASHINGTON BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT
- * (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-
-/* DEDICATION
-
- * This file is dedicated to my dog, Unix, also known as Yun-chan and
- * Unix J. Terwilliker Jehosophat Aloysius Monstrosity Animal Beast. Unix
- * passed away at the age of 11 1/2 on September 14, 1996, 12:18 PM PDT, after
- * a two-month bout with cirrhosis of the liver.
- *
- * He was a dear friend, and I miss him terribly.
- *
- * Lift a leg, Yunie. Luv ya forever!!!!
- */
-
-#include "php.h" /*php specific */
-#include "syslog.h"
-#include <stdio.h>
-#include <fcntl.h>
-#include <process.h>
-
-#ifndef THREAD_SAFE
-static char *loghdr; /* log file header string */
-static HANDLE loghdl = NULL; /* handle of event source */
-#endif
-
-void closelog(void)
-{
- DeregisterEventSource(loghdl);
- efree(loghdr);
-}
-
-/* Emulator for BSD syslog() routine
- * Accepts: priority
- * message
- * parameters
- */
-
-void syslog(int priority, const char *message,...)
-{
- va_list args;
- LPTSTR strs[2];
- char tmp[1024]; /* callers must be careful not to pop this */
- unsigned short etype;
-
- /* default event source */
- if (!loghdl)
- openlog("c-client", LOG_PID, LOG_MAIL);
- switch (priority) { /* translate UNIX type into NT type */
- case LOG_ALERT:
- etype = EVENTLOG_ERROR_TYPE;
- break;
- case LOG_INFO:
- etype = EVENTLOG_INFORMATION_TYPE;
- break;
- default:
- etype = EVENTLOG_WARNING_TYPE;
- }
- va_start(args, message); /* initialize vararg mechanism */
- vsprintf(tmp, message, args); /* build message */
- strs[0] = loghdr; /* write header */
- strs[1] = tmp; /* then the message */
- /* report the event */
- ReportEvent(loghdl, etype, (unsigned short) priority, 2000, NULL, 2, 0, strs, NULL);
- va_end(args);
-}
-
-
-/* Emulator for BSD openlog() routine
- * Accepts: identity
- * options
- * facility
- */
-
-void openlog(const char *ident, int logopt, int facility)
-{
- char tmp[1024];
-
- if (loghdl) {
- closelog();
- }
- loghdl = RegisterEventSource(NULL, ident);
- sprintf(tmp, (logopt & LOG_PID) ? "%s[%d]" : "%s", ident, getpid());
- loghdr = estrdup(tmp); /* save header for later */
-}
diff --git a/zlib.mak b/zlib.mak
deleted file mode 100644
index f8523cb85a..0000000000
--- a/zlib.mak
+++ /dev/null
@@ -1,194 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on zlib.dsp
-!IF "$(CFG)" == ""
-CFG=zlib - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to zlib - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "zlib - Win32 Release" && "$(CFG)" != "zlib - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "zlib.mak" CFG="zlib - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "zlib - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "zlib - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-!IF "$(CFG)" == "zlib - Win32 Release"
-
-OUTDIR=.\module_Release
-INTDIR=.\module_Release
-# Begin Custom Macros
-OutDir=.\module_Release
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_zlib.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(INTDIR)\zlib.obj"
- -@erase "$(OUTDIR)\php3_zlib.dll"
- -@erase "$(OUTDIR)\php3_zlib.exp"
- -@erase "$(OUTDIR)\php3_zlib.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "./" /I "../" /I "../../include" /D HAVE_ZLIB=1 /D "NDEBUG" /D "MSVC5" /D "COMPILE_DL" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\zlib.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\zlib.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=zlibstat.lib php.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\php3_zlib.pdb" /machine:I386 /out:"$(OUTDIR)\php3_zlib.dll" /implib:"$(OUTDIR)\php3_zlib.lib" /libpath:"..\..\lib" /libpath:"cgi_release"
-LINK32_OBJS= \
- "$(INTDIR)\zlib.obj"
-
-"$(OUTDIR)\php3_zlib.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "zlib - Win32 Debug"
-
-OUTDIR=.\module_Debug
-INTDIR=.\module_Debug
-# Begin Custom Macros
-OutDir=.\module_Debug
-# End Custom Macros
-
-ALL : "$(OUTDIR)\php3_zlib.dll"
-
-
-CLEAN :
- -@erase "$(INTDIR)\vc60.idb"
- -@erase "$(INTDIR)\vc60.pdb"
- -@erase "$(INTDIR)\zlib.obj"
- -@erase "$(OUTDIR)\php3_zlib.dll"
- -@erase "$(OUTDIR)\php3_zlib.exp"
- -@erase "$(OUTDIR)\php3_zlib.ilk"
- -@erase "$(OUTDIR)\php3_zlib.lib"
- -@erase "$(OUTDIR)\php3_zlib.pdb"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "./" /I "../" /I "../../include" /D HAVE_ZLIB=1 /D "DEBUG" /D "_DEBUG" /D "MSVC5" /D "COMPILE_DL" /D "THREAD_SAFE" /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\zlib.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-RSC=rc.exe
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\zlib.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=php.lib zlibstat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:yes /pdb:"$(OUTDIR)\php3_zlib.pdb" /debug /machine:I386 /out:"$(OUTDIR)\php3_zlib.dll" /implib:"$(OUTDIR)\php3_zlib.lib" /pdbtype:sept /libpath:"..\..\lib" /libpath:"cgi_debug"
-LINK32_OBJS= \
- "$(INTDIR)\zlib.obj"
-
-"$(OUTDIR)\php3_zlib.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF
-
-
-!IF "$(NO_EXTERNAL_DEPS)" != "1"
-!IF EXISTS("zlib.dep")
-!INCLUDE "zlib.dep"
-!ELSE
-!MESSAGE Warning: cannot find "zlib.dep"
-!ENDIF
-!ENDIF
-
-
-!IF "$(CFG)" == "zlib - Win32 Release" || "$(CFG)" == "zlib - Win32 Debug"
-SOURCE=.\functions\zlib.c
-
-"$(INTDIR)\zlib.obj" : $(SOURCE) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-
-!ENDIF
-