Compare commits

...
Author SHA1 Message Date
SVN Migration 133d50b882 This commit was manufactured by cvs2svn to create tag
'PRE_EIGHT_BYTE_ALLOC_PATCH'.
2000-06-09 15:42:50 +00:00
932 changed files with 0 additions and 264140 deletions

No files matched your search

-149
View File
@@ -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.
-3
View File
@@ -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
-21662
View File
File diff suppressed because it is too large. Load diff
-538
View File
@@ -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
-365
View File
@@ -1,365 +0,0 @@
Installation Instructions for PHP 4.0
-------------------------------------
For the impatient here is a quick set of steps that will build PHP as
first a dynamic Apache module (DSO) for Apache 1.3.x with MySQL support
and then a static module. A more verbose explanation follows.
Note! Only install either the static module or the dynamic one. Do not
install both.
If you want both PHP 3 and 4 modules in the same Apache server, check the
bottom of this file for instructions.
INSTALLATION WITH THE ZEUS WEB SERVER:
--Please see the 'README.Zeus' file included in this distribution
QUICK INSTALL (DSO)
For this to work your Apache httpd must have mod_so enabled.
Check using httpd -l. You should see something like:
Compiled-in modules:
http_core.c
mod_so.c
Chances are you will see a lot more modules than these two. That's ok,
as long as mod_so.c shows up you can proceed with the following steps:
$ gunzip -c php-4.0.x.tar.gz | tar xf -
$ cd php-4.0.x
$ ./configure --with-mysql --with-apxs
$ make
$ make install
If you get an error telling you that the apxs script could not be found,
look for it on your system and if you find it, provide the full path to it
as: --with-apxs=/path/to/apxs
The only thing left to do is to edit your httpd.conf file and make sure the
PHP 4 mime type is there and uncommented. You need a line that looks like
this:
AddType application/x-httpd-php .php
Then restart your server (apachectl restart) and you should be able to
serve up PHP files now. Make a test file called test.php and put some
PHP tags in it. Like <?phpinfo()?>, for example.
QUICK INSTALL (Static)
$ 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
Chances are you are reading this because the quick install steps above
did not work for you. If this is the case, congratulations, you are
among the elite few that actually reads documentation. It really is
not a difficult install and once you have done it once you will fly
through it.
Installing PHP can be done in four simple steps:
1. Unpack your distribution file.
You will have downloaded a file named something like php-4.0.x.tar.gz.
Unzip this file with a command like: gunzip php-4.0.x.tar.gz
Next you have to untar it with: tar -xvf php-4.0.x.tar
This will create a php-4.0.x directory. cd into this new directory.
2a. Configure PHP (Dynamic Module) - Skip to 2b if you wish to build
a static module
You now have to choose the options you would like. There are quite
a few of them. To see a list, type: ./configure --help
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. In order to
build PHP as a dynamic module for Apache-1.3.x you have to first have
Apache installed. Assuming Apache is already installed, make sure
the shared object module is enabled. To check this, type: httpd -l
You should see something like:
Compiled-in modules:
http_core.c
mod_so.c
You will most likely have a lot more modules than what is shown here.
As long as mod_so.c shows up in the list, PHP should be happy.
Now, type: ./configure --with-mysql --with-apxs
If you get an error telling you that the apxs script could not be found,
look for it on your system and if you find it, provide the full path to it
as: --with-apxs=/path/to/apxs
You might also want other flags on this configure line. --with-mysql
is just an example.
There are a few things that can go wrong during this configure step.
The most common is that you have asked for an option and that the
configure script can not find the files required to enable this
option in PHP. Chances are you can provide the full path to the
base directory under which the related files were installed. For
example, if you have installed the GD library in /opt/gd which means
that /opt/gd/include has your GD header files and /opt/gd/lib contains
your GD library files, you would use --with-gd=/opt/gd
Skip to step 3 for compilation and installation instructions.
2b. Configure PHP (Static Module) - Skip if you performed 2a
You now have to choose the options you would like. There are quite
a few of them. To see a list, type: ./configure --help
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.
Skip to step 3b at this point.
3. Compile and install the files. Simply type: make install
3a. Dynamic Module Installation
Nothing else is needed here. Proceed to step 4a.
3b. Static Module Installation
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
Assuming it compiles without errors, proceed to step 4b.
4a. Setting up the server. (Dynamic Module)
The make install command in step 3 should have done most of your
work for you. It actually edits your httpd.conf file and tries to
enable the dynamic PHP module. To verify this, look for a line that
looks like this:
LoadModule php4_module libexec/libphp4.so
The actual path before the libphp4.so part might differ slightly. This
is likely fine. If you are paranoid you can examine the output from the
make install step to see where the libphp4.so file was actually put and
place the full path to this file on this LoadModule line.
If somewhere in your httpd.conf file you have a ClearModuleList line
then you also need this line:
AddModule mod_php4.c
And finally you need to tell Apache which file extension should trigger
PHP. You do this by creating a special mime type and associating it
with an extension. We suggest using:
AddType application/x-httpd-php .php
You are however free to use any extension you wish, including .html.
Note! If a line has a # at the beginning, then it is commented out
and you need to remove the # for that line to take effect.
Once you have made these changes you should be ready to restart your
server and try it out. Type: apachectl restart
The create a test file named test.php in your web tree somewhere and
put some test PHP tags in it. <?phpinfo()?> is a good first test.
This tag tells PHP to do a braindump and tells you all sorts of things
about itself.
4b. Setting up the server. (Static Module)
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/httpd.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 httpd.conf file, you can
start up your server. Note that on some older server setups, the
AddType lines are in the conf/srm.conf file instead of conf/httpd.conf.
Note! If a line has a # at the beginning, then it is commented out
and you need to remove the # for that line to take effect.
WHY DISABLING -fPIC WORKS ON LINUX
From: Martin v. Loewis <martin@loewis.home.cs.tu-berlin.de>
To: glibc-linux@ricardo.ecn.wfu.edu
Subject: Re: Shared library -shared vs. -fpic
[In reply to Kaz Kylheku <kaz@ashi.footprints.net>]
> PIC stands for Position-Independent Code.
Correct.
> Code isn't position-independent (or ``relocatable'') cannot be
> loaded at an arbitrary address;
Wrong.
> it requires some references to be patched at load time.
Correct.
> Shared libraries need to be relocatable because it's not known
> beforehand what address they will be loaded at
Correct, depending on the meaning of "relocatable". PIC code typically
does not contain relocations; that's why its position-independent.
> Just because you don't specify -fPIC doesn't mean that the compiler
> won't emit position-independent code; the option prevents it from
> emitting position-dependent code in situations where it otherwise
> would.
Correct. However, a non-trivial shared library typically won't be
position-independent unless explicitly compiled with
-fPIC. Linux/glibc indeed does not require a shared library to be
position-independent; instead, it will perform the relocations in the
binary, even if they refer to code pages. As a result, those relocated
pages won't be shared across processes, anymore.
Regards,
Martin
USING PHP 3 AND PHP 4 AS CONCURRENT APACHE MODULES
Recent operating systems provide the ability to perform versioning and
scoping. This features make it possible to let PHP 3 and PHP 4 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 PHP 3 and PHP 4 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
-75
View File
@@ -1,75 +0,0 @@
--------------------------------------------------------------------
The PHP License, version 2.02
Copyright (c) 1999, 2000 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. The software incorporates the Zend Engine, a product of Zend
Technologies, Ltd. ("Zend"). The Zend Engine is licensed to the
PHP Association (pursuant to a grant from Zend that can be
found at http://www.php.net/license/ZendGrant/) for
distribution to you under this license agreement, only as a
part of PHP. In the event that you separate the Zend Engine
(or any portion thereof) from the rest of the software, or
modify the Zend Engine, or any portion thereof, your use of the
separated or modified Zend Engine software shall not be governed
by this license, and instead shall be governed by the license
set forth at http://www.zend.com/license/ZendLicense/.
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 group@php.net.
For more information on the PHP Group and the PHP project,
please see <http://www.php.net>.
-129
View File
@@ -1,129 +0,0 @@
List of PHP maintainers
=======================
Status legend
-------------
Supported: Someone is actually paid to look after this.
Maintained: Someone actually looks after it.
Odd Fixes: It has a maintainer but they don't have time to do
much other than throw the odd patch in. See below..
Orphan: No current maintainer [but maybe you could take the
role as you write your new code].
Obsolete: Old code. Something tagged obsolete generally means
it has been replaced by a better system and you
should be using that.
--------------------------------------------------------------------------------
EXTENSION: apache
PRIMARY MAINTAINER: Rasmus Lerdorf <rasmus@php.net>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: cybercash
PRIMARY MAINTAINER: Evan Klinger <evan715@sirius.com>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: dba
PRIMARY MAINTAINER: Sascha Schumann <sascha@schumann.cx>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: dbase
PRIMARY MAINTAINER: Jim Winstead <jimw@php.net>
STATUS: Odd Fixes
--------------------------------------------------------------------------------
EXTENSION: fdf
PRIMARY MAINTAINER: Uwe Steinmann <steinm@php.net>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: gd
PRIMARY MAINTAINER: Rasmus Lerdorf <rasmus@php.net>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: hyperwave
PRIMARY MAINTAINER: Uwe Steinmann <steinm@php.net>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: informix
PRIMARY MAINTAINER: Danny Heijl <Danny.Heijl@cevi.be>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: interbase
PRIMARY MAINTAINER: Jouni Ahto <jah@mork.net>
STATUS: Odd Fixes
--------------------------------------------------------------------------------
EXTENSION: java
PRIMARY MAINTAINER: Sam Ruby <rubys@us.ibm.com>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: ldap
PRIMARY MAINTAINER: Rasmus Lerdorf <rasmus@php.net>
STATUS: Odd Fixes
--------------------------------------------------------------------------------
EXTENSION: mcrypt
PRIMARY MAINTAINER: Sascha Schumann <sascha@schumann.cx>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: mhash
PRIMARY MAINTAINER: Sascha Schumann <sascha@schumann.cx>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: mssql
PRIMARY MAINTAINER: Frank M. Kromann <fmk@swwwing.com>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: oci8
PRIMARY MAINTAINER: Thies C. Arntzen <thies@digicol.de>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: oracle
PRIMARY MAINTAINER: Thies C. Arntzen <thies@digicol.de>
STATUS: Maintained
COMMENT: Using the new OCI8 driver is encouraged where possible.
--------------------------------------------------------------------------------
EXTENSION: pcre
PRIMARY MAINTAINER: Andrei Zmievski <andrei@ispi.net>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: pdf
PRIMARY MAINTAINER: Uwe Steinmann <steinm@php.net>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: pgsql
PRIMARY MAINTAINER: Jouni Ahto <jah@mork.net>
STATUS: Odd fixes
--------------------------------------------------------------------------------
EXTENSION: posix
PRIMARY MAINTAINER: Kristian Köhntopp <kris@koehntopp.de>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: recode
PRIMARY MAINTAINER: Kristian Köhntopp <kris@koehntopp.de>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: session
PRIMARY MAINTAINER: Sascha Schumann <sascha@schumann.cx>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: snmp
PRIMARY MAINTAINER: Rasmus Lerdorf <rasmus@php.net>
STATUS: Odd Fixes
--------------------------------------------------------------------------------
EXTENSION: swf
PRIMARY MAINTAINER: Sterling Hughes <sterling@php.net>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: wddx
PRIMARY MAINTAINER: Andrei Zmievski <andrei@ispi.net>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: xml
PRIMARY MAINTAINER: Thies C. Arntzen <thies@digicol.de>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: yaz
PRIMARY MAINTAINER: Adam Dickmeiss <adam@indexdata.dk>
STATUS: Maintained
--------------------------------------------------------------------------------
EXTENSION: zlib
PRIMARY MAINTAINER: Stefan Roehrich <sr@linux.de>
STATUS: Maintained
--------------------------------------------------------------------------------
-27
View File
@@ -1,27 +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
oracle Working
iptc Working
informix Working
zlib Working
sysvshm Working
odbc Working (except for persistent connections)
MS SQL Working (tested on phpts and isapi versions)
snmp Working
gettext Working
mcal Working
interbase Working
posix Working
recode Working
-70
View File
@@ -1,70 +0,0 @@
ZEND_DIR = $(srcdir)/Zend
SUBDIRS = Zend ext sapi $(TSRM_DIR) $(REGEX_DIR) . $(PEAR_DIR)
LTLIBRARY_NAME = libphp4.la
LTLIBRARY_SOURCES = \
main.c internal_functions.c snprintf.c php_sprintf.c \
configuration-parser.c configuration-scanner.c \
safe_mode.c fopen-wrappers.c php_realpath.c alloca.c \
php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c php_virtual_cwd.c
LTLIBRARY_DEPENDENCIES = \
Zend/libZend.la \
sapi/$(PHP_SAPI)/libsapi.la \
$(REGEX_LIB) \
$(EXT_LTLIBS) \
$(TSRM_LIB)
LTLIBRARY_LDFLAGS = -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS)
LTLIBRARY_LIBADD = $(LTLIBRARY_DEPENDENCIES) $(EXTRA_LIBS)
PROGRAM_NAME = php
PROGRAM_SOURCES = stub.c
PROGRAM_LDADD = libphp4.la
PROGRAM_LDFLAGS = -export-dynamic
PROGRAM_DEPENDENCIES = $(PROGRAM_LDADD)
targets = $(LTLIBRARY_NAME) $(PHP_PROGRAM)
install_targets = install-sapi install-modules
include $(top_srcdir)/build/rules.mk
include $(top_srcdir)/build/library.mk
include $(top_srcdir)/build/program.mk
install-sapi:
@$(LIBTOOL) --silent --mode=install cp libphp4.la $(phptempdir)/libphp4.la >/dev/null 2>&1
-@$(mkinstalldirs) $(bindir)
-@if ! test -r $(phptempdir)/libphp4.$(SHLIB_SUFFIX_NAME); then \
for i in 0.0.0 0.0 0; do \
if test -r $(phptempdir)/libphp4.$(SHLIB_SUFFIX_NAME).$$i; then \
$(LN_S) $(phptempdir)/libphp4.$(SHLIB_SUFFIX_NAME).$$i $(phptempdir)/libphp4.$(SHLIB_SUFFIX_NAME); \
break; \
fi; \
done; \
fi
$(INSTALL_IT)
install-modules:
@test -d modules && \
$(mkinstalldirs) $(moduledir) && \
echo "installing shared modules into $(moduledir)" && \
rm -f modules/*.la && \
cp modules/* $(moduledir) >/dev/null 2>&1 || true
install-su: install-modules
(cd pear && $(MAKE) install)
configuration-parser.h configuration-parser.c: $(srcdir)/configuration-parser.y
$(YACC) -p cfg -v -d $< -o configuration-parser.c
configuration-scanner.c: $(srcdir)/configuration-scanner.l
$(LEX) -Pcfg -o$@ -i $<
internal_functions.c: internal_functions.c.in config.status
CONFIG_FILES= CONFIG_HEADERS= ./config.status
.NOEXPORT:
-750
View File
@@ -1,750 +0,0 @@
PHP 4.0 NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2000, Version 4.0.1
- Fixed a bug in rawurldecode() that would cause in rawurldecode() corrupting
its argument (Zeev)
- Parse errors (or other errors) in the php.ini files under Windows will no
longer mess up the HTTP headers in CGI mode and are now displayed in a
message box (Zeev)
- Fixed a crash in OCIFetchStatement() when trying to read after all data
has already been read. (Thies)
- fopen_wrappers() are now extensible via modules (Hartmut Holzgraefe)
- Make trim strip \0 to match php 3 (Rasmus)
- Added function imagecreatefromxbm(). (Jouni)
- Added function imagewbmp(). (Jouni, based on patch from Rune Nordbøe
Skillingstad)
- Added str_pad() for padding a string with an arbitrary string on left or
right. (Andrei)
- Made the short_tags, asp_tags and allow_call_time_pass_reference INI
directives work on a per-directory basis as well, e.g. from .htaccess
files. (Zeev)
- Added fflush() function. (Eric Huss)
- Fixed a problem with static variables, default function arguments and class
member variables, that contained array values. (Andi & Zeev, Zend Engine)
- Fix virtual() when used with output buffering (Marc Pohl)
- Clean up constants in flock() function and add optional 3rd arg which
is set to true on EWOULDBLOCK (Rasmus)
- Added functions pg_loimport(), pg_loexport(). (Jouni)
- Add SWF support to getimagesize() function (Derick Rethans)
- Add support for both indexed and non-indexed arrays of file uploads
eg. name="file[]" type="file" (Rasmus)
- Added create_function(), which gives the ability to create functions
on-the-fly (Zeev, Zend Engine)
- Added support for comparisons of arrays (with arrays) and objects (with
objects); The equality operator (==) performs an unordered comparison,
whereas the identity operator (===) performs an ordered comparison (Zeev,
Zend Engine)
- Allow all functions that receive user-defined function callbacks to accept
an array that contains an object and a method name, in place of a function
name, e.g. usort($array, array($obj, "ObjSort")) (Zeev, Zend Engine)
- Added set_error_handler() to allow custom error handling functions,
instead of the built-in error handling code (Zeev, Zend Engine)
- Renamed user_error() to trigger_error(); user_error() remains
defined for compatibility (Zeev, Zend Engine)
- Fix the global/static statements to require a trailing terminating
semi-colon ';'. (Andi, Zend Engine)
- Cleaned up PCRE extension and made it binary-safe. (Andrei)
- Added third argument to in_array(). If it's true, then in_array()
will use strict comparison instead of the default one. (Andrei)
- Added pg_trace() and pg_untrace (Dominic J. Eidson & Zeev)
- ignore_user_abort=Off is now default. (Thies)
- Added array_merge_recursive() that will recursively merge values
under the same keys. (Andrei)
- fixed crash in OCIParse when parsing invalid SQL. (Thies)
- Fixed a bug in mysql_connect() that made it ignore the socket argument, in
case of non-persistent connects (Zeev)
- Added disable_functions php.ini directive, to allow administrators to disable
certain functions for security reasons (Zeev)
- Fixed sessions on Win32. When setting the directory depth parameter in
save_path you need to now delimit it with a ';' instead of ':', e.g
"5;/tmp" instead of "5:/tmp" (Andi)
- Changed the Apache handler's return status to 'Declined' when a requested
PHP file could not be found. Returning 'Not Found' caused problems
in the ErrorDocument handler stage in that $REDIRECT_REDIRECT_ERROR_NOTES
was not getting set at all. Moving to 'Declined' should fix this and I
can't see any other side effects. (Rasmus)
- Fixed scanning decimal numbers in internationalized environments. They should
always be in standard US format e.g. 23.3. (Andi, Zend Engine)
- Added second argument to preg_quote() which allows quoting of
one additional character, usually the regex delimiter. (Andrei)
- Uncommitted outstanding OCI8 transactions are now rolled back
before the connection is closed. (Thies)
- ignore_user_abort() & friends should now work in CGI mode as well.
(Patch by daniel.braun@ercom.fr)
- Added extension YAZ (dickmeiss).
- Fixed a crash bug triggered by certain cases of class redeclarations
(Stanislav & Zeev, Zend Engine)
- Fixed min()/max() segfault. (Andrei)
- New module for reading EXIF header data from JPEG files. Most digital
cameras will embed all sorts of information about a picture inside the
jpeg images it generates. (Rasmus)
- Fixed basename() bug where "file.ext///" would not return the same
as "/path/file.ext///" (Rasmus)
- Add the swf_ortho function. (Sterling)
- Moved to virtual current working directory support. This highly improves the
functionality and stability of multi-threaded versions of PHP (Andi, Sascha)
22 May 2000, Version 4.0.0 Release
- Allow the writing of flash files to stdout.
- Fixed a crash bug in .phps syntax-highlighted files (Andi)
- Improved round() to allow specification of rounding precision.
(Andrei, Todd Kirby <kirbyt@yahoo.com>)
- Added SORT_REGULAR, SORT_NUMERIC, SORT_STRING flags that can be used with
non-user sort functions for precise sorting behavior. (Andrei)
- Fixed two 64-bit issues (startup crash, gethostbyaddr). (Sascha)
- NULL values are now preserved in the return value of mysql_fetch_array()
and mysql_fetch_object(). (Andrei)
- Ported InterBase module finally from PHP 3 to PHP 4. Full support for
InterBase 6. (Jouni)
- Added swf_definepoly for drawing polygons to the SWF functions. (Sterling)
- Ported imagegammacorrect from PHP3 to PHP4. (Sterling)
- Added array_rand() function. (Andrei)
8 May 2000, Version 4.0 Release Candidate 2
- NSAPI WIN32 Module compilable, untested (Shane)
- Apache WIN32 Module compilable and lightly tested. (Shane)
- Enabled assert() by default in php.ini-dist. (Andrei)
- Put in safeguards in case dynamic code evaluation in assert() and
preg_replace() with /e modifier fails. (Andrei)
- Fixed infinite recursion when serializing $GLOBALS[] in WDDX. (Andrei)
- Made WDDX serialization properly escape <, >, and &. Also speeded up
the serialization in general. (Andrei)
- Moved install-local to install-sapi for clarity. (Joey)
- Improved extension build framework. Refer to README.SELF-CONTAINED-EXTENSIONS
for an introduction. (Sascha)
- ImagePolygon() is no longer limited by a maximum number of polygons.
(Marc Pohl)
- Added configure time checking for bcmath package. (Joey, Sascha)
- Added get_declared_classes(). (Andrei, Zend Engine)
- Add initial NSAPI module from Jayakumar Muthukumarasamy. (Rasmus)
- Added the SWF module which allows you to create Macromedia Flash files via
libswf. (Sterling)
- Improved UNIX build system to support more vendor make tools (Sascha)
- Updated natural comparison/sorting algorithm by Martin Pool
<mbp@humbug.org.au>. (Andrei)
- Fixed a crash in array_multisort() that happened when empty arrays
were passed to it. (Andrei)
- Added substr_count() from Peter Kovacs. (Andrei)
- Add an optional third argument to fseek to indicate where to seek from.
(Andrei)
- OCIBindByName() will no longer complain about bindlength beeing zero. (Thies)
- Converted the IMAP module to the high performance API (Zeev)
- The fgetcsv() function now handles embedded end-of-line in a quoted field
(Nick Talbott)
- Added user_error(), to allow explicitly generate error messages from scripts
(Zeev, Zend Engine)
- Fixed a problem in long2ip() that occasionally returned incorrect IP address.
(Evan, Andrei)
- Fixed many memory leaks in the IMAP module (Stas, Andi, Zeev)
- Fixed bug in number_format (Jon Forsberg)
- Make error_prepend_string and error_append_string work (Rasmus)
- array_walk() now automatically resets the array. (Andrei)
- Added natural comparison/sorting routines strnatcmp(), strnatcasecmp(),
natsort(), and natcasesort(). These are useful for comparing and sorting
strings that contain numbers. Based on the code from Martin Pool
<mbp@humbug.org.au>. See http://www.linuxcare.com.au/projects/natsort/
for more info on natural sorting. (Andrei)
- Zeus Webserver support (version 3.3.6+) for ISAPI (Ben Mansell)
- Fixed several problems with the PATH_TRANSLATED and PHP_SELF under Apache
(Paul Gregg & Zeev)
- Ported ldap_get_values_len() function from PHP3 to PHP4. (Sterling)
- Fixed a problem in include_once() with non constant arguments (Andi & Zeev,
Zend Engine)
- Added php.ini-optimized (Zeev)
- Ported ldap_errno(), ldap_err2str() and ldap_error() from PHP3 to PHP4.
(Sterling)
- WDDX now defaults to ISO-8859-1. (Thies)
- Fixed crash resulting from IMAP's error handling (Stas)
- Added $HTTP_POST_FILES[filename][tmp_name] - it was previously impossible to
retrieve the temporary name of an uploaded file using $HTTP_POST_FILES[]
(Zeev)
- Made the IMAP and LDAP modules compilable under Windows and thread-safe
(Zeev)
- Fixed a problem when dealing with large POST blocks in CGI mode (Zeev)
- Added session_get_cookie_params() function. (Sterling)
- Fixed return of stristr() to no longer always be lowercased. (Andrei)
- Changed the Windows version of PHP so that a php.ini file is no
longer mandatory (Zeev)
- session_start() is now more verbose if headers cannot be send. (Thies)
- Fixed a memory leak when using assign-op bitwise operators on strings (Zeev,
Zend Engine)
- Added support for reading properties that require arguments in the COM
module - writing to them will only be supported in PHP 4.1 (Zeev)
- Fixed a very old legacy memory leak in the COM module (Zeev)
- Fixed problems with object-overloading support - noteably, COM and Java
(Zeev, Zend Engine)
- Fixed an overrun in WDDX. (Thies)
- Fixed a crash bug with modules loaded through dl() not properly freeing their
resources (Zeev, Zend Engine)
- Added localtime() function. (Sterling)
- Added the 'I' format option for the date function, this option will return
true or false depending on whether or not daylight savings time is in effect.
(Sterling)
- Added gmstrftime() function. (Sterling)
- snmp_walkoid is now an alias for snmp_realwalk. (Sterling)
- Fixed a bug that could cause a crash when using 'global' inside large include
files (Stas, Zend Engine)
- Added --enable-libgcc switch to force linking against libgcc (Sascha)
- Fixed dynamic loading where extension_dir had no trailing slash (Sascha)
- Fixed dynamic loading on OpenBSD (Sascha)
- Improved POSIX threads check. ZTS works now on at least Linux, Solaris,
FreeBSD and OpenBSD (Sascha, TSRM)
- Added !== operator support. (Torben, Zend Engine)
27 March 2000, Version 4.0 Release Candidate 1
- Added support for UCD-SNMP 4.1.x (Sascha)
- Fixed a data corruption bug in mysql_result(), if used in table.fieldname
mode (Zeev)
- Fixed a crash problem in func_num_args(), func_get_arg() and func_get_args()
when used as function arguments (Andi, Zend Engine)
- Added get_class_methods(string classname) function. (Andrei)
- Added 'I' switch to test whether or not DST is active. (Sterling)
- Fixed a data corruption bug in mysql_result(), if used in table.fieldname
mode (Zeev)
- Modified the registry INI entry reader (Win32) to work with drive letters.
For example, if you wish to wish to specify INI entries for C:\foo\bar, you
should create HKLM\PHP\Per Directory Values\C\foo\bar in the registry, and add
string values for each directive you want to override in this directory (Zeev)
- Fixed extract() for EXTR_PREFIX_SAME and EXTR_SKIP cases. (Andrei)
- stristr() no longer modifies it's arguments. (Thies)
- Don't default to iso-8859-1 since this confuses some browsers. (Rasmus)
- Make it possible to specify both a port and a socket
in mysql_[p]connect. (Rasmus)
- Added --disable-pic for disabling generating PIC for shared objects
on platforms which support it (i.e. Linux) (Sascha)
- serialize()/unserialize() now call __sleep() and __wakeup() when
working on objects. (Thies)
- renamed to_string() method to __string_value() for consistency.
(Thies, Zend Engine)
- Fixed a bug in the third argument to define()
- Added is_numeric() that returns true if the argument is a number
or a numeric string. (Andrei)
- domxml now supports libxml 2.0 Beta and drops support for older versions,
due to massive changes in libxml
- fixed possible crash in unserialize() if serialized data was
corrupted. (Thies)
- Changed $HTTP_STATE_VARS to $HTTP_SESSION_VARS. Use only the latter
version now! (Andrei)
- Added GD-JPEG Support (Rasmus)
- Prevent from loading dynamic PHP modules which were compiled with different
debug and thread safety modes than PHP, which resulted in a crash (Andi)
- connection_aborted() and friends work again (Thies)
- Upgraded to libtool 1.3.4 (Sascha)
- UNIX configure creates config.nice in the build directory now which allows
easy reuse of configuration options (Sascha)
- Added support for embedded MySQL client library. Unless you specify a path
to --with-mysql, the bundled MySQL client library will be used (Sascha)
- Added include_once() and require_once() functionality (Andi, Zend Engine)
- Removed support for pdflib < 3.0 (Uwe)
- Added auto-registration of everything in $HTTP_SESSION_VARS[] if
register_globals is turned off. (Andrei)
- Cleaned up extension namespace (Stig)
- OCINLogon() sessions are now closed again. (Thies)
- Added ip2long() and long2ip(),
courtesy of Faisal Nasim <faisal@nasim.org> (Andrei)
- Added ftruncate() and fstat(),
courtesy of Faisal Nasim <faisal@nasim.org> (Andrei)
- Added parse_ini_file(). Currently implemented in non thread safe version
of PHP, and currently lacks section support (Zeev)
- "none" is now equivalent with "" in Apache config directives (Stig)
- OCINLogon no longer crashes. (Thies)
- Fixed comparisons of (string) "nan" with (string) "nan". (Thies, Zend Engine)
- Switched back to the old $HTTP_*_VARS[] behavior - $HTTP_GET_VARS["foo"]
and $foo are no longer references to each other, but separate variables
like they were prior to PHP 4.0 Beta 4 (Zeev)
- Fixed Sybase-DB compilation (Zeev)
- Fixed a (fairly common) situation where error_reporting values would not be
properly restored after a call to error_reporting(), in between requests
(Zeev)
- The various $HTTP_*_VARS[] are now protected, and cannot be manipulated by
user input (Zeev)
- Added ini_set() as an alias to ini_alter() (Zeev)
- The string None is now recognized as a keyword by the php.ini processor, and
can be used to denote an empty string (Zeev)
- Added get_class_vars(string class_name) and get_object_vars(object obj)
functions. (Andrei, Zend Engine)
- Added pdf_set_parameter(), pdf_skew(), pdf_show_boxed() (Uwe)
- Fixed comparison of (string) "inf" with (string) "inf", which was erroneously
returning false (Zeev)
- Implemented default_charset and default_mimetype config directives (Stig)
- Ported T1lib support from PHP3. (Jouni)
- Fixed -DEAPI inheritance from APXS. (Sascha)
- Fixed possible crash in module-shutdown. (Thies)
- Fixed safe_mode_protected_env_vars INI directive (Zeev)
- Fixed getrusage() (Sascha)
- Fixed OCI8 crash when returning cursors from stored-procedures. (Thies)
21 February 2000 Version 4.0 Beta 4 patch level 1
- Fixed crash when magic_quotes were switched off. (Thies)
- Support for pdflib 2.30 (Uwe)
20 February 2000, Version 4.0 Beta 4
- Introduced $HTTP_POST_FILES[], that contains information about files uploaded
through HTTP upload (Zeev)
- Made PHP work under Microsoft Personal Web Server, under both Windows NT
workstation and Windows 95 (Zeev)
- Made multipart/form-data content obey to the variables_order directive (Zeev)
- Updated the browscap module to work with PHP 4.0 (Zeev)
- Recover gracefully in ISAPI after the client prematurely presses STOP (Andi)
- Fixed bug in unset() on array offsets which are referenced more than once
(Andi, Zend Engine)
- Improved ISAPI module - it should no longer be necessary to set PHP as
an ISAPI filter, only as an ISAPI extension, unless you wish to perform
authentication using PHP. This didn't yet get enough testing, but it
should work (Zeev)
- Fixed RFC1867 file upload under Windows (Zeev)
- Initital support for pdflib 2.20 (Uwe)
- Added PostgreSQL support for DB (Rui Hirokawa <louis@cityfujisawa.ne.jp>)
- Re-introduced "none" for disabling auto_prepend/append_file (Stig)
- Added DB/storage (Stig, PEAR)
- Introduced DB warnings (Stig, PEAR)
- Fixed overrun in strip_tags (Stas)
- Fixed crash in strip_tags() and related functions. (Thies)
- Workaround for bogus POST-Data from IE/Mac. (Thies)
Patch by Alain Malek <alain@virtua.ch>
- Finished the server abstraction layer; All of the PHP code is now shared
across different servers (Apache, CGI, IIS, etc.), except for thin
interface modules (Zeev)
- Added NULL-support in gettype(). (Thies)
- base64_decode() will decode POST data correct. (Thies)
Patch submitted by: Turadg Aleahmad <turadg@wise.berkeley.edu>
- Much more work on domxml. Build xml tree, create xml doc works (Uwe)
- Made foreach() work on objects. (Thies, Zend Engine)
- Added domxml extension based on libxml, still little functionality (Uwe)
- Fixed memory corruption in fgetss(), strip_tags() and gzgetss() (Zeev)
- Updated calendar dynamic library to work with PHP 4. (Evan)
- Added strncmp() function, courtesy of Walter. (Andrei)
- Made the output of var_dump() more informative. (Thies)
- Fixed some OCIBindByName() problems. (Thies)
- Protect the ISAPI module against exceptions. Stack overflows in scripts are
now nicely detected and handled (Zeev)
- Fixed possible buffer-overflow in base64_decode. (Thies)
- Fixed possible buffer-overflow in setcookie(). (Thies)
- Fixed signal() bug that could cause the Apache master process to
die. (Thies)
- Added session_set_cookie_params() function. (Andrei)
- If header information is sent after output has already been sent, the warning
message will now state the filename and line number at which the first output
was made (Zeev)
- Added the XML Expat library to the standard PHP source distribution thanks
to its author James Clark (Andi & Zeev)
- Added XML support to the default Win32 build (Andi & Zeev)
- Added socket_get_status() function. Renamed:
set_socket_timeout() -> socket_set_timeout()
set_socket_blocking() -> socket_set_blocking(). (Andrei)
- Added realpath() function. (Andrei)
- mktime interprets years in the range 0-70 now as 2000-2070. You can
continue to specify the complete year (i.e. 1920) (Sascha)
- Added the ability to control the environment variables the user is allowed
to change in Safe Mode, using INI directives (Zeev)
- Fixed a crash bug in strtr() working on large input strings (Zeev)
- Ora_GetColumn()/Ora_FetchInto() now return NULL for NULL-Columns. (Thies)
- OCI8 now supports binding of NULL-values. Module cleanups. (Thies)
- Added ability to set timeout on socket read operations through
set_socket_timeout() function. (Andrei)
- Added implicit_flush INI directive (Zeev)
- Added implicit_flush() to control whether flush() should be called
implicitly after any output (Zeev)
- Fixed a crash in pfsockopen() (Zeev)
- Fixed a possible crash in phpinfo() (Zeev)
- Added register_argc_argv INI directive, to allow to selectively disable
the declaration of the $argv and $argc variables for increased
performance (Zeev)
- Added $HTTP_ENV_VARS[] and $HTTP_SERVER_VARS[] support, which similarly
to $HTTP_GET_VARS[], contain environment and server variables. Setting
register_globals to Off will now also prevent registration of the
environment and server variables into the global scope (Zeev)
- Renamed gpc_globals INI directive to register_globals (Zeev)
- Introduced variables_order that deprecates gpc_order, and allows control
over the server and environment variables, in addition to GET/POST/Cookies
(Zeev)
- new function cpdf_set_document_limits() (Uwe)
- Applied safe-mode patch to popen(). (Patch by Kristian Köhntopp)
- str_repeat() now returns correct length. (Thies)
- Don't assume libz and libpng are installed for the GD checks (Rasmus)
- Implemented support for <boolean> and <null> types according
to WDDX version 1.0 (Andrei)
- Made var_dump()/serialize()/unserialize() NULL aware. (Thies)
- Added new NULL constant (Zeev, Zend Engine)
- Fixed -c support in the standalone CGI binary (Zeev)
- Increased PHP's performance by 5-15% using a new memory cache (Andi & Zeev,
Zend Engine)
- Improved the php.ini reader to support constants and bitwise operators (Zeev)
- Fixed strrev() to no longer modify arg1. (Thies)
- Fixed buffer overruns in iptcembed(). (Thies)
- Fixed a bug in ODBC error reporting (Zeev)
- Added PHP_Logo_GUID() and Zend_Logo_GUID() functions, that return the GUIDs
of the PHP and Zend logos used in phpinfo() (Zeev)
- Added GNU Pth support (Sascha, TSRM library)
- Removed select(), fd_set() and fd_isset() - will be reimplemented soon! (Thies)
- Improved Win32 performance significantly by using different mutexes (Zeev,
TSRM library)
- Made quotemeta() and preg_quote() binary-safe. (Andrei)
- Added UDP support in fsockopen(). (Evan)
- Added --disable-pear option (Andrei)
- Renamed libzend repository to Zend (Zeev)
- Added support for thttpd (Sascha)
- Added session.cache_limiter and cache_expire options (Sascha)
- Restored the PHP_VERSION and PHP_OS constants (Zeev)
- Added get_loaded_extensions(), extension_loaded(), and
get_extension_funcs() functions. (Andrei)
- Added date/time stamping to PHP error log file. (Andrei, Joey)
- Added is_subclass_of() function (Andrei, Zend Engine)
- Implemented count_chars(). (Thies)
- Added class_exists() function (Andrei, Zend Engine)
- Made strspn() and strcspn() binary-safe. (Andrei)
- Added array_multisort() function. (Andrei)
- Made pageinfo.c thread-safe (Sascha)
- Made implode() binary-safe (Andrei)
- Made strstr(), stristr(), and ucwords() binary-safe() (Andrei)
- Made strtoupper(), strtolower(), substr_replace() binary-safe. (Andrei)
- Fixed a crash in the Apache syntax highlighting mode (Zeev)
- Report all ODBC error's not just the one on the top of the stack (lurcher)
- OCI8 now returns NULL values in LONG columns correct. (Thies)
- Added support for a C-like assert() function. (Thies)
- Added CyberCash support. (Evan)
- Made explode() binary-safe. (Thies)
- Made strpos() binary-safe. (Thies)
- Added XML_Set_Object() function, now you can use the XML-Parser from
within an object. (Thies)
- Session vars are now decoded into $HTTP_STATE_VARS[] array and the
globals, depending on track_vars and gpc_globals settings (Andrei)
- Added get_used_files() function - returns a hash mapping the use()'d files
to their full path (Zeev)
- PHP 4 scripts will now obey the max_execution_time setting and actually
time out (Rasmus)
- Added configure command to phpinfo() output (Stig)
- Added optional socket path to the mysql_?connect() functions (Rasmus)
- Made mysql and gd work as shared extensions again (Stig)
- Make the global GET/POST/Cookie variables and their $HTTP_*_VARS[] counterparts
be references to each other (Zeev)
- Added support for the 'use' keyword - behaves like 'require', but will not
use the same file more than once (Andi & Zeev, Zend Engine)
- Added check to see if a persistent connection is still valid with the
ODBC interface before reusing (nick@easysoft.com)
- Added DBMaker support (patch by Pax Tsai <paxtsai@lion.syscom.com.tw>)
- Renamed "PECL" to "PEAR" (PHP Extension and Add-on Repository) (Stig)
- buildconf now uses build.mk (Stig)
- Disable symlinks to urls (Rasmus)
- Informix driver now reflects version of ESQL/C used (Danny)
- Modified session_register() to take variable number of arguments (Andrei)
- Fixed file descriptor leak in thread safe mode (Zeev, Zend Engine)
- Added select(), fd_set() and fd_isset() (Evan)
- cpdf support has been ported from php3, needs ClibPDF 2.x (Uwe)
- Fixed a leak when using automatic output buffering (Zeev)
- Introduced PECL - PHP Extension and Code Library
(prounounced "pickle") (Stig)
- Fixed inconsistencies in the implementation of here-docs (Andi & Zeev, Zend
library)
- Fixed a problem with constant class-member initializations (Andi & Zeev,
Zend Engine)
- Fixed float-compare in min(),max(),a[r]sort(),[r]sort() (Thies)
- Implemented get_html_translation_table() function (Thies)
- Implemented array_flip() function. Returns input-array with key, value
flipped (Thies)
- Added Berkeley DB3 support in DBA (Sascha)
- Implemented 2-Arg version of strtr($str,$translation_array). This can be used
to revert what htmlspecialchars() did (Thies)
- Fixed mem-overwrite in XML_Parse_Into_Struct (Thies)
- Added substr_replace() function (Andrei)
November 16 1999, Version 4.0 Beta 3
- ucfirst()/ucwords() no longer modify arg1 (Thies)
- Fixed strtr() not to modify arg1 (Thies)
- Added Win32 build files for Informix driver and make it
compile with ZTS (danny)
- Added tmpfile() function (Stig)
- Upgraded regex library to alpha3.8 (Sascha)
- Fixed selecting nested-tables in OCI8. (Thies)
- RFC-854 fix for internal FTP-Code. Commands have to end in "\r\n" (Thies)
- Fixed OpenLink ODBC support (Stig)
- min(),max(),a[r]sort(),[r]sort(),k[r]sort() now work consistent with the
language-core. (Thies)
- tempnam() now uses mkstemp() if available (Stig)
- serialize() and var_dump() now honor the precision as set in php.ini
for doubles. (Thies)
- Improved the Win32 COM module to support [out] parameters (Boris Wedl)
- Fixed garbage returned at the end of certain Sybase-Columns (Thies)
Patch submitted by: neal@wanlink.com
- Added Microsoft SQL Server module for Win32 (Frank)
- Added support for forcing a variable number of internal function arguments
by reference. (Andi & Zeev, Zend Engine)
- Implemented getprotoby{name,number} (Evan)
- Added array_pad() function. (Andrei)
- Added new getservby{name,port} functions. (Evan)
- Added session.cookie_path and session.cookie_domain (Sascha)
- Continue processing PHP_INI_SYSTEM knownDirectives after extension=
(Sam Ruby)
- Enable IBM DB2 support - Tested against DB2 6.1 UDB on Linux (Rasmus)
- Added new str_repeat() function. (Andrei)
- Output-Buffering system is now Thread-Safe. (Thies)
- implemented OCI8 $lob->WriteToFile() function - very useful for streaming
large amounts of LOB-Data without to need of a huge buffer. (Thies)
- Added session.use_cookies option (Sascha)
- Added getcwd() function. (Thies)
- XML_Parse_Into_Struct no longer eats data. (Thies)
- Fixed parse_url('-') crash. (Thies)
- added === operator support. (Andi & Thies, Zend Engine)
- unserialize() now gives a notice when passed invalid data. (Thies)
- Fixed shuffle() so that it no longer breaks on Solaris. (Andrei)
- Added is_resource(), is_bool() functions. (Thies)
- Cleaned up File-Module (Thies)
- Upgraded math-funtions to use new Zend function API (Thies)
- Fixed zombie problem in shell_exec() and $a = `some_command`
constructs. (Thies)
- Thies introduced ZEND_FETCH_RESOURCE2 (Danny).
- Added Informix driver to list of maintained extensions. (Danny).
- Informix driver : Changed ifx.ec to use the new high-performance
ZEND API. (Danny)
- IXF_LIBDIR environment variable specifies alternate Informix library
path for configure (Danny).
- Fixed gmmktime() so that the following should always be true:
gmmktime([args]) == mktime([args]) + date('Z', mktime([args])) (Jouni)
- setlocale doesn't anymore screw up things if you forgot to change it back
to the original settings. (Jouni)
- Switched to new system where ChangeLog is automagically updated from commit
messages. NEWS file is now the place for public announcements. (Andrei)
- Fixed refcount problem in XML module. (Thies)
- Fixed crash in HTTP_RAW_POST_DATA handling (Thies)
- You can use resources as array-indices again (Thies, Zend Engine)
- Fixed pg_fetch_array() with three arguments (Sascha)
Patch submitted by: brian@soda.berkeley.edu
- Upgraded a lot internal functions to use new Zend function API (Thies)
- fdf support ported; not completely tested with latest version 4.0 for
glibc (Uwe)
- OCI8 connections are now kept open as long as they are referenced (Thies)
- Cleaned up Directory-Module (Thies)
- Small fix in Ora_Close (Thies)
- Ported range() and shuffle() from PHP 3 to PHP 4 (Andrei)
- Fixed header("HTTP/..."); behaviour (Sascha)
- Improved UNIX build system. Now utilizes libtool (Sascha)
- Upgrade some more internal functions to use new Zend function API. (Thies,
Zend Engine)
- Fixed backwards incompatibility with ereg() (Thies)
- Updated Zend garbage collection with a much more thorough method.
(Andi, Zend Engine)
- Added the ability to use variable references in the array() construct.
For example, array("foo" => &$foo). (Andi, Zend Engine)
- Added array_reverse() function (Andrei)
- Some more XML fixes/cleanups (Thies)
- Updated preg_replace() so that if any argument passed in is an array
it will make a copy of each entry before converting it to string so that
the original is intact. If the subject is an array then it will preserve
the keys in the output as well (Andrei)
- Updated OCI8 to use the new high-performance Zend function API. (Thies)
- Configure speedup (Stig)
- Fixed LOB/Persistent-Connection related OCI8-Crash (Thies)
- Generalized server-API build procedure on UNIX (Stig)
- Added '--disable-rpath' option (Sascha)
- Added AOLserver SAPI module (Sascha)
- Fixed XML Callbacks. (Thies)
- Updated ODBC to use the new high-performance Zend function API (kara)
- Updated zlib to use the new high-performance Zend function API. (Stefan)
- Updated preg_split() to allow returning only non-empty pieces (Andrei)
- Updated PCRE to use the new high-performance Zend function API (Andrei)
- Updated session, dba, mhash, mcrypt, sysvshm, sysvsem, gettext modules to use
the new high-performance Zend function API (Sascha)
- Extended var_dump to handle resource type somewhat (Andrei)
- Updated WDDX to use the new high-performance Zend function API (Andrei)
- Updated XML to use the new high-performance Zend function API. (Thies)
- Updated Oracle to use the new high-performance Zend function API. (Thies)
- Improved the performance of the MySQL module significantly by using the new
high-performance Zend function API. (Zeev)
- Added support for the Easysoft ODBC-ODCB Bridge (martin@easysoft.com)
- Fixed bug in odbc_setoption, getParameter call incorrect (martin@easysoft.com)
- Ora_Fetch_Into now resets the returned array in all cases (Thies)
- Fixed NULL-Column problem in Oracle-Driver (Thies)
- Added extra metadata functions to ODBC, SQLTables etc (nick@easysoft.com)
- Fixed SEGV in mcal make_event_object() and
typo in mcal_list_alarms() (Andrew Skalski)
- Fixed Ora_PLogon (Thies)
- Resourcified Oracle (Thies)
- Implemented object serialization/deserialization in WDDX (Andrei)
- Added krsort() function (Thies)
- Added func_num_args(), func_get_arg() and func_get_args() for standard
access to variable number of arguments functions (Zeev)
- Added FTP support (Andrew Skalski)
- Added optional allowable_tags arguments to strip_tags(), gzgetss() and
fgetss() to allow you to specify a string of tags that are not to be
stripped (Rasmus)
- Upgraded var_dump() to take multiple arguments (Andrei)
- 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 (Andrei)
- Made it possible to specify external location of PCRE library (Andrei)
- Updated bundled PCRE library to version 2.08 (Andrei)
- 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 (Andrei)
- Fixed WDDX mem leak when undefined variable is passed in
for serialization (Andrei)
- Added session_unset() function (Andrei)
- Fixed double session globals shutdown crash (Andrei)
- Fixed crash related to ignore_user_abort ini entry (Andrei)
- 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 (Andrei)
- 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 (Andrei)
- Fixed a bugglet when redefining a class at run-time (Andi, Zend Engine)
- Fixed sem_get() on AIX (Sascha)
- Fixed fopen() to work with URL's in Win32 (Andi & Zeev)
- Fixed include_path for Win32 (Andi, Zend Engine)
- Fixed bug in ISAPI header sending function (Charles)
- Fixed memory leak when using undefined values (Andi & Zeev, Zend Engine)
- 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 Engine)
- 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 (Andrei)
- 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 (Andrei)
- 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 (Andrei)
- 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 Engine)
- 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 Engine)
- Fixed backwards incompatibility with the "new" operator (Andi, Zend Engine)
- Fixed bugs in uksort() and ksort() sort ordering (Andrei)
- Fixed a memory leak when using assignment-op operators with lvalue of type
string (Zeev, Zend Engine)
- Fixed a problem in inheritance from classes that are defined in include()d
files (Zeev, Zend Engine)
- 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 Engine)
- Fixed a crash problem in switch statements that had a string offset
as a conditional (Andi & Zeev, Zend Engine)
- Imported PHP 3.0 fixes for rand() and mt_rand() (Rasmus)
- Added function entries for strip_tags() and similar_text() (Andrei)
- Fixed a bug in WDDX that would cause a crash if a number was passed in
instead of a variable name (Andrei)
- Ported strtotime() function from PHP 3.0 (Andrei)
- 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 (Andrei)
- Ported all remaining date() format options from PHP 3.0 (Andrei)
- $php_errormsg now works (Andrei)
- Added locale support for Perl Compatible Regexp functions (Andrei)
- 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 Engine)
- 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
-17
View File
@@ -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
-104
View File
@@ -1,104 +0,0 @@
This is the first file you should be reading after you get your CVS account.
We'll assume you're basically familiar with CVS, but feel free to post
your questions on the mailing list.
PHP is developed through the efforts of a large number of people.
Collaboration is a Good Thing(tm), and CVS lets us do this. Thus, following
some basic rules with regards to CVS usage will:
a. Make everybody happier, especially those responsible for maintaining
the CVS itself.
b. Keep the changes consistently well documented and easily trackable.
c. Prevent some of those 'Oops' moments.
d. Increase the general level of good will on planet Earth.
Having said that, here are the organizational rules:
1. Respect other people working on the project.
2. Discuss any significant changes on the list before committing.
3. Look at MAINTANERS file to see who is the primary maintainer of
the code you want to contribute to.
4. If you "strongly disagree" about something another person did, don't
start fighting publicly - take it up in private email.
5. If you don't know how to do something, ask first!
6. Test your changes before committing them. We mean it. Really.
The next few rules are more of a technical nature.
1. DO NOT TOUCH ChangeLog! It is automagically updated from the commit
messages every day. Woe be to those who attempt to mess with it.
2. All news updates intended for public viewing, such as new features,
bug fixes, improvements, etc., should go into the NEWS file. Also see
the note below about automatically updating NEWS in your commit message.
3. Do not commit multiple file and dump all messages in one commit. If you
modified several unrelated files, commit each group separately and
provide a nice commit message for each one. See example below.
4. Do write your commit message in such a way that it makes sense even
without the corresponding diff. One should be able to look at it, and
immediately know what was modified. Definitely include the function name
in the message as shown below.
5. In your commit messages, keep each line shorter than 80 characters. And
try to align your lines vertically, if they wrap. It looks bad otherwise.
6. If you modified a function that is callable from PHP, prepend PHP to
the function name as shown below.
The format of the commit messages is pretty simple.
If a line begins with #, it is taken to be a comment and will not appear
in the ChangeLog. If the line begins with @, it will be redirected to the
NEWS file. Everything else goes into the ChangeLog.
It is important to note that if your comment or news logline spans multiple
lines, you have to put # or @ at the beginning of _every_ such line. Every
entry in NEWS has to have a name after it, so if you did it with someone's
help, put both your names there.
Example. Say you modified two files, datetime.c and string.c. In datetime.c
you added a new format option for date() function, and in string.c you fixed
a memory leak in php_trim(). Don't commit both of these at once. Commit them
separately and try to make sure your commit messages look something like the
following.
For datetime.c:
(PHP date) Added new 'K' format modifier for printing out number of
days until New Year's Eve.
@- Added new 'K' format modifier that will output the number of days
@ until New Year's Eve. (Bob)
For string.c:
(php_trim) Fixed a memory leak resulting from improper use of zval_dtor().
# Man, that thing was leaking all over the place!
@- Memory leak in trim() function has finally been fixed. (Bob)
The lines above marked with @ will go into NEWS file automagically, and the
# lines will be omitted from the ChangeLog. Alternatively, you might want
to modify NEWS file directly and not use the @ lines.
If you don't see your messages in ChangeLog and NEWS right away, don't worry!
These files are updated once a day, so your stuff will not show up until
somewhat later. Don't go adding stuff to NEWS by hand if you already put @
lines in the commit message.
You can use LXR (http://lxr.php.net/) and Bonsai (http://bonsai.php.net/)
to look at PHP CVS repository in various ways.
To receive daily updates to ChangeLog and NEWS, send an empty message to
php-cvs-daily-subscribe@lists.php.net.
Happy hacking,
PHP Team
-57
View File
@@ -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
-156
View File
@@ -1,156 +0,0 @@
$Id$
=============================================================================
HOW TO CREATE A SELF-CONTAINED PHP EXTENSION
A self-contained extension can be distributed independently of
the PHP source. To create such an extension, three things are
required:
- Makefile template (Makefile.in)
- Configuration file (config.m4)
- Source code for your module
We will describe now how to create these and how to put things
together.
CONVERTING AN EXISTING EXTENSION
Just to show you how easy it is to create a self-contained
extension, we will convert an embedded extension into a
self-contained one. Install PHP and execute the following
commands.
$ mkdir /tmp/newext
$ cd /tmp/newext
You now have an empty directory. We will copy the files from
the mysql extension:
$ cp -rp php-4.0.X/ext/mysql/* .
It is time to finish the module. Run:
$ phpize
You can now ship the contents of the directory - the extension
can live completely on its own.
The user instructions boil down to
$ ./configure \
[--with-php-config=/path/to/php-config] \
[--with-mysql=MYSQL-DIR]
$ make install
The MySQL module will either use the embedded MySQL client
library or the MySQL installation in MYSQL-DIR.
DEFINING THE NEW EXTENSION
Our demo extension is called "foobar".
It consists of two source files "foo.c" and "bar.c"
(and any arbitrary amount of header files, but that is not
important here).
The demo extension does not reference any external
libraries (that is important, because the user does not
need to specify anything).
CREATING THE MAKEFILE TEMPLATE
The Makefile Template (Makefile.in) contains three lines:
------------------------------------------------------------------------------
LTLIBRARY_SHARED_NAME = foobar.la
LTLIBRARY_SOURCES = foo.c bar.c
include $(top_srcdir)/build/dynlib.mk
------------------------------------------------------------------------------
LTLIBRARY_SHARED_NAME specifies the name of the extension.
It must be of the form `ext-name.la'.
LTLIBRARY_SOURCES specifies the names of the sources files. You can
name an arbitrary number of source files here.
The final include directive includes the build rules (you usually
don't need to care about what happens there). rules.mk and other
files are installed by phpize which we will cover later.
CREATING THE M4 CONFIGURATION FILE
The m4 configuration can perform additional checks. For a
self-contained extension, you do not need more than a few
macro calls.
------------------------------------------------------------------------------
PHP_ARG_ENABLE(foobar,whether to enable foobar,
[ --enable-foobar Enable foobar])
if test "$PHP_FOOBAR" != "no"; then
PHP_EXTENSION(foobar, $ext_shared)
fi
------------------------------------------------------------------------------
PHP_ARG_ENABLE will automatically set the correct variables, so
that the extension will be enabled by PHP_EXTENSION in shared mode.
Please use always PHP_ARG_ENABLE or PHP_ARG_WITH. Even if you do not
plan to distribute your module with PHP, these facilities allow you
to integrate your module easily into the main PHP module framework.
CREATING SOURCE FILES
[You are currently alone here. There are a lot of existing modules,
use a simply module as a starting point and add your own code.]
CREATING THE SELF-CONTAINED EXTENSION
Put Makefile.in, config.m4 and the source files into one directory.
Then run phpize (this is installed during make install by PHP 4.0).
For example, if you configured PHP with --prefix=/php, you would run
$ /php/bin/phpize
This will automatically copy the necessary build files and create
configure from your config.m4.
And that's it. You now have a self-contained extension.
INSTALLING A SELF-CONTAINED EXTENSION
An extension can be installed by running:
$ ./configure \
[--with-php-config=/path/to/php-config]
$ make install
ADDING SHARED MODULE SUPPORT TO A MODULE
In order to be useful, a self-contained extension must be loadable
as a shared module. I will explain now how you can shared module support
to an existing module called foo.
1. In config.m4, use PHP_ARG_WITH/PHP_ARG_ENABLE. Then you will
automatically be able to use --with-foo=shared or
--enable-foo=shared.
2. In config.m4, use PHP_EXTENSION(foo, $ext_shared) to enable
building the extension.
3. Add the following line to Makefile.in:
LTLIBRARY_SHARED_NAME = foo.la
4. Add the following lines to your C source file:
#ifdef COMPILE_DL_FOO
ZEND_GET_MODULE(foo)
#endif
-99
View File
@@ -1,99 +0,0 @@
Using PHP4 with the Zeus Web Server
-----------------------------------
Zeus fully supports running PHP in combination with our webserver. A
significant improvement in PHP 4 is that you can now run PHP as an
ISAPI module, giving great performance benefits over traditional CGI
code.
Note that you will need to be running at least version 3.3.6 of the
webserver. If you are running an earlier version, please see our
website (http://www.zeus.com) for upgrade instructions.
To build the ISAPI version of PHP, start the configuration with:
./configure --with-zeus=/usr/local/zeus
Obviously, replace /usr/local/zeus with the location of where you have
installed Zeus on your machine. For PHP to build successfully, you
need to have 3.3.6 already installed, because the code relies on the
presence of header files provided with the latest version.
You may have to adjust the environment variable LDFLAGS and EXTRA_LIBS
in order to link in extra libraries. This depends on the platform on
which you are building and also on the compiler used (see below). A
standard GNU/Linux install with GCC should build fine with no changes.
Configuring the webserver
-------------------------
After running 'make' and 'make install', you will have a 'libphp4.so'
file. Copy this file into a directory reserved for ISAPI
binaries. Now, perform the following steps for each virtual server
that you wish to run PHP on:
1) On the Admin server, go to 'edit server->path mapping'
2) Add an alias to the directory with libphp4.so in it, mapped to
/isapi/ (or a location of your choice). Make sure you set the alias
type to ISAPI.
3) Click 'update'
4) Add a handler for file extension 'php' to be run by /isapi/libphp4.so
5) Click 'update', then go back to the previous page.
6) Click on the 'module configuration' button, ensure that ISAPI
support is ticked.
7) Click on the ISAPI link. At the bottom of the page, click the
checkbox for running ISAPI extensions 'out of process'.
8) Click 'update'. Then restart the virtual server. Done!
Troubleshooting
---------------
*) Why does the compile fail at Zend/zend-scanner-cc.cc
or Zend/zend-parser.c ?
These source files are auto-generated from the corresponding .y files.
The default distribution of PHP contains pre-generated versions of these
files that have caused problems for some people. The simplest solution is
to delete the files. They will then be rebuilt correctly. You must have the
following GNU tools to do this:
bison 1.28 or later
flex 2.5.4 or later
*) Why does my PHP library fail to load?
After configuring Zeus, if you get a '502 Bad Gateway' error when
accessing a PHP page, there are problems loading the PHP
library. Check the error log ($ZEUSHOME/web/log/errors) for errors.
Failing to load the PHP ISAPI module is likely to be due to unresolved
symbols in the module. A way to check for this is to visit our support
page at http://support.zeus.com/faq/entries/isapi_error.html and run
the program there on your libphp4.so. It will list any unresolved
symbols.
*) My libphp4.so has unresolved symbols. How do I fix this?
You must ensure that the PHP build process links in the appropriate
libraries that contain these symbols! The libraries required will
depend on the platform you are running PHP on.
You may need to set one or two environment variables before running
the 'configure' program to set up PHP; LDFLAGS and EXTRA_LIBS. Make
sure that you also export these variables to the build process.
(Type 'export LDFLAGS EXTRA_LIBS' in the shell to do this.)
Specific examples:
Solaris + gcc:
Ensure you run ./configure with the `--enable-libgcc' parameter. You
may need to set LDFLAGS to '-L/usr/local/egcs/lib' (path depends on
your gcc installation)
For more information and help with Zeus, please visit our website:
http://www.zeus.com
-117
View File
@@ -1,117 +0,0 @@
Things to do or at least think about doing in the future. Name in
parenthesis means that person has taken on this project.
Zend
----
* allow foreach ($array as $k => &$val) syntax. right now we cannot
traverse an array without copying each element.
* look at replacing c-lib call tolower().
global
------
* make everything on the language-level independent of your locale setings.
* always build the standalone executable as well as the chosen SAPI
target.
* make sure all source files have the "right" copyright.
* the following modules still use PHP3_TLS_*() macros (and thereby don't
work in ZTS mode): ext/dav/dav.c, ext/db/db.c, ext/gd/gd.c, ext/ldap/ldap.c
* make sure that all ZTS globals get destructed. Most ts_allocate_id()
calls should have a dtor entry.
* activate all extensions by default that don't rely on external
dependices. (eg ftp)
* --enable-all in configure. (--enable-shared=max ...)
* make configure print out a summary when it's done (like XEmacs)
* replace standard functions which work on static data with
reentrancy-safe functions.
* on some platforms unimplemented function will just do nothing (e.g. symlink)
they should print a warning or not even be defined!
* implement javadoc based function docs template system.
* use thread-safe resolver functions (either require BIND 8 or adns).
* provide optional IPv6 support.
* make SAPI conform to CGI/1.1. Currently, all SAPI modules
define REMOTE_ADDR etc. themselves and reach only various level
of compliance.
* find a better way to implement script timeouts. SIGVTALRM is used
by some POSIX threads implementations (i.e. OpenBSD) and is not
available in ZTS mode.
* add aliases to functions to conform to new naming conventions, e.g.
str_to_upper().
documentation
-------------
* add remarks in the documentation which functions are not implemented on win32.
* add remarks in the documentation which functions are not binary-safe.
ext/dav
--------
* rewrite.
ext/mcrypt
----------
* port to mcrypt-2.6 or later
ext/oci8
--------
* all OCIFetch*() functions should return 0 for no more data and false on error.
* have a flag that trims trailing spaces from CHAR fields on retrieval.
ext/pcre
--------
* have a non-greedy option for preg_replace().
* have an option for preg_grep() to return keys as well.
* update the online docs from version 3.1 man page
ext/session
-----------
* implement a call to set a session read-only to overcome
the need to serialize frame-loads.
* maybe implement finer-grained session variables that could be
locked individually.
ext/standard
------------
* add a version number to data serialized via serialize().
* array_add(), array_uniq(). (Andrei)
* implement pathinfo()
$a = pathinfo("/some/file.bla");
=> array("dirname" => "/some/",
"basename" => "file.bla",
"extension" => "bla");
We could also make it return just one part as a sting if used
like this:
$a = pathinfo("/some/file.bla", PATHINFO_BASENAME);
* possibly modify parsing of GPC data to automatically create arrays if
variable name is seen more than once.
* implement regex-cache for url-functions.
* strcase_replace(). (Andrei)
* move socket related functions to fsock.c.
* get_defined_funcs(), get_defined_vars().
* NOT binary safe:
strtok()
basename()
dirname()
strrpos()
strrchr()
strip_tags()
ext/wddx
--------
* implement __sleep() and __wakeup() the way serialize()/unserialize() do.
* See if we can support the remaining datatypes:
dateTime
binary
recordset
http://www.wddx.org/WDDX_SDK_10a/7__References/WDDX_DTD.htm
(Andrei)
* implement wddx_packet_as_javascript(). (Andrei)
other cool stuff
----------------
* PVM extension
-4
View File
@@ -1,4 +0,0 @@
## process this file with automake to produce Makefile.am
AUTOMAKE_OPTIONS=foreign
noinst_LTLIBRARIES=libtsrm.la
libtsrm_la_SOURCES = TSRM.c
-455
View File
@@ -1,455 +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;
ts_allocate_ctor ctor;
ts_allocate_dtor dtor;
} 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)
{
#if defined(GNUPTH)
pth_init();
#endif
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(void)
{
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");
#if defined(GNUPTH)
pth_kill();
#endif
}
/* allocates a new thread-safe-resource id */
TSRM_API ts_rsrc_id ts_allocate_id(size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor)
{
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;
(*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;
tsrm_mutex_unlock(tsmm_mutex);
if (tsrm_new_thread_begin_handler) {
tsrm_new_thread_begin_handler(thread_id);
}
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);
return ts_resource(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);
return ts_resource(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(void)
{
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(GNUPTH)
return pth_self();
#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 = malloc(sizeof(CRITICAL_SECTION));
InitializeCriticalSection(mutexp);
#elif defined(GNUPTH)
mutexp = (MUTEX_T) malloc(sizeof(*mutexp));
pth_mutex_init(mutexp);
#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
DeleteCriticalSection(mutexp);
#elif defined(GNUPTH)
free(mutexp);
#elif defined(PTHREADS)
pthread_mutex_destroy(mutexp);
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 )
{
#if 0
tsrm_debug("Mutex locked thread: %ld\n",tsrm_thread_id());
#endif
#ifdef WIN32
EnterCriticalSection(mutexp);
return 1;
#elif defined(GNUPTH)
return pth_mutex_acquire(mutexp, 0, NULL);
#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 )
{
#if 0
tsrm_debug("Mutex unlocked thread: %ld\n",tsrm_thread_id());
#endif
#ifdef WIN32
LeaveCriticalSection(mutexp);
return 1;
#elif defined(GNUPTH)
return pth_mutex_release(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;
}
-125
View File
@@ -1,125 +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 "TSRM - Win32 Release_TS_inline" (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 "_LIB" /D "WIN32" /D "_MBCS" /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 "_LIB" /D "TSRM_EXPORTS" /D "WIN32" /D "_MBCS" /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
!ELSEIF "$(CFG)" == "TSRM - Win32 Release_TS_inline"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "TSRM___Win32_Release_TS_inline"
# PROP BASE Intermediate_Dir "TSRM___Win32_Release_TS_inline"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release_TS_inline"
# PROP Intermediate_Dir "Release_TS_inline"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "TSRM_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "_LIB" /D "TSRM_EXPORTS" /D "WIN32" /D "_MBCS" /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"
# Name "TSRM - Win32 Release_TS_inline"
# 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
-110
View File
@@ -1,110 +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
# undef PACKAGE
# undef VERSION
# include "tsrm_config.h"
# undef PACKAGE
# undef VERSION
#endif
#if WIN32||WINNT
# include <windows.h>
#elif defined(GNUPTH)
# include <pth.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 CRITICAL_SECTION *
#elif defined(GNUPTH)
# define THREAD_T pth_t
# define MUTEX_T pth_mutex_t *
#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
typedef void (*ts_allocate_ctor)(void *);
typedef void (*ts_allocate_dtor)(void *);
#define THREAD_HASH_OF(thr,ts) (unsigned long)thr%(unsigned long)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(void);
/* allocates a new thread-safe-resource id */
TSRM_API ts_rsrc_id ts_allocate_id(size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor);
/* 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(void);
/* 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 */
-1
View File
@@ -1 +0,0 @@
#undef PTHREADS
-5
View File
@@ -1,5 +0,0 @@
AC_DEFUN(AM_SET_LIBTOOL_VARIABLE,[
LIBTOOL='$(SHELL) $(top_builddir)/libtool $1'
])
-43
View File
@@ -1,43 +0,0 @@
# Makefile to generate build tools
#
# Standard usage:
# make -f build.mk
#
# Written by Sascha Schumann
#
# $Id$
LT_TARGETS = ltmain.sh ltconfig
config_h_in = tsrm_config.h.in
makefile_am_files = Makefile.am
makefile_in_files = $(makefile_am_files:.am=.in)
makefile_files = $(makefile_am_files:e.am=e)
targets = $(makefile_in_files) $(LT_TARGETS) configure $(config_h_in)
all: $(targets)
clean:
rm -f $(targets)
$(LT_TARGETS):
rm -f $(LT_TARGETS)
libtoolize --automake $(AMFLAGS) -f
$(makefile_in_files): $(makefile_am_files)
automake -a -i $(AMFLAGS) $(makefile_files)
aclocal.m4: configure.in acinclude.m4
aclocal
$(config_h_in): configure.in acconfig.h
# explicitly remove target since autoheader does not seem to work
# correctly otherwise (timestamps are not updated)
@rm -f $@
autoheader
configure: aclocal.m4 configure.in
autoconf
-33
View File
@@ -1,33 +0,0 @@
#!/bin/sh
case "$1" in
--copy)
automake_flags=--copy
shift
;;
esac
libtoolize --force --automake $automake_flags
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 $automake_flags
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
-21
View File
@@ -1,21 +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)
sinclude(tsrm.m4)
TSRM_BASIC_CHECKS
AM_PROG_LIBTOOL
if test "$enable_debug" != "yes"; then
AM_SET_LIBTOOL_VARIABLE([--silent])
fi
TSRM_PTHREAD
AC_OUTPUT(Makefile)
-147
View File
@@ -1,147 +0,0 @@
dnl Copyright (c) 1999, 2000 Sascha Schumann. All rights reserved.
dnl
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are permitted provided that the following conditions
dnl are met:
dnl
dnl 1. Redistributions of source code must retain the above copyright
dnl notice, this list of conditions and the following disclaimer.
dnl
dnl 2. Redistributions in binary form must reproduce the above copyright
dnl notice, this list of conditions and the following disclaimer in
dnl the documentation and/or other materials provided with the
dnl distribution.
dnl
dnl THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``AS IS'' AND ANY
dnl EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
dnl PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SASCHA SCHUMANN OR
dnl HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
dnl NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
dnl LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
dnl HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
dnl STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
dnl ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
dnl OF THE POSSIBILITY OF SUCH DAMAGE.
dnl
dnl PTHREADS_FLAGS
dnl
dnl Set some magic defines to achieve POSIX threads conformance
dnl
AC_DEFUN(PTHREADS_FLAGS,[
if test -z "$host_alias"; then
AC_MSG_ERROR(host_alias is not set. Make sure to run config.guess)
fi
case "$host_alias" in
*solaris*)
PTHREAD_FLAGS="-D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT";;
*freebsd*)
PTHREAD_FLAGS="-D_REENTRANT -D_THREAD_SAFE";;
*linux*)
PTHREAD_FLAGS="-D_REENTRANT";;
*aix*)
PTHREAD_FLAGS="-D_THREAD_SAFE";;
*irix*)
PTHREAD_FLAGS="-D_POSIX_THREAD_SAFE_FUNCTIONS";;
*hpux*)
PTHREAD_FLAGS="-D_REENTRANT";;
*sco*)
PTHREAD_FLAGS="-D_REENTRANT";;
dnl Solves sigwait() problem, creates problems with u_long etc.
dnl PTHREAD_FLAGS="-D_REENTRANT -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=199506 -D_XOPEN_SOURCE_EXTENDED=1";;
esac
if test -n "$PTHREAD_FLAGS"; then
CPPFLAGS="$CPPFLAGS $PTHREAD_FLAGS"
fi
])dnl
dnl
dnl PTHREADS_CHECK_COMPILE
dnl
dnl Check whether the current setup can use POSIX threads calls
dnl
AC_DEFUN(PTHREADS_CHECK_COMPILE, [
AC_TRY_RUN( [
#include <pthread.h>
#include <stddef.h>
void *thread_routine(void *data) {
return data;
}
int main() {
pthread_t thd;
pthread_mutexattr_t mattr;
int data = 1;
pthread_mutexattr_init(&mattr);
return pthread_create(&thd, NULL, thread_routine, &data);
} ], [
pthreads_working="yes"
], [
pthreads_working="no"
], pthreads_working="no" ) ] )dnl
dnl
dnl PTHREADS_CHECK()
dnl
dnl Try to find a way to enable POSIX threads
dnl
AC_DEFUN(PTHREADS_CHECK,[
save_CFLAGS="$CFLAGS"
save_LIBS="$LIBS"
PTHREADS_ASSIGN_VARS
PTHREADS_CHECK_COMPILE
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
AC_CACHE_CHECK(for pthreads_cflags,ac_cv_pthreads_cflags,[
ac_cv_pthreads_cflags=""
if test "$pthreads_working" != "yes"; then
for flag in -pthreads -pthread -mthreads -Kthread -threads; do
ac_save="$CFLAGS"
CFLAGS="$CFLAGS $flag"
PTHREADS_CHECK_COMPILE
CFLAGS="$ac_save"
if test "$pthreads_working" = "yes"; then
ac_cv_pthreads_cflags="$flag"
break
fi
done
fi
])
AC_CACHE_CHECK(for pthreads_lib, ac_cv_pthreads_lib,[
ac_cv_pthreads_lib=""
if test "$pthreads_working" != "yes"; then
for lib in pthread pthreads c_r; do
ac_save="$LIBS"
LIBS="$LIBS -l$lib"
PTHREADS_CHECK_COMPILE
LIBS="$ac_save"
if test "$pthreads_working" = "yes"; then
ac_cv_pthreads_lib="$lib"
break
fi
done
fi
])
if test "$pthreads_working" = "yes"; then
threads_result="POSIX Threads found"
else
threads_result="POSIX Threads not found"
fi
])dnl
dnl
dnl
AC_DEFUN(PTHREADS_ASSIGN_VARS,[
if test -n "$ac_cv_pthreads_lib"; then
LIBS="$LIBS -l$ac_cv_pthreads_lib"
fi
if test -n "$ac_cv_pthreads_cflags"; then
CFLAGS="$CFLAGS $ac_cv_pthreads_cflags"
fi
])dnl
-98
View File
@@ -1,98 +0,0 @@
dnl TSRM_CHECK_GCC_ARG(ARG, ACTION-IF-FOUND, ACTION-IF-NOT_FOUND)
AC_DEFUN(TSRM_CHECK_GCC_ARG,[
gcc_arg_name=[ac_cv_gcc_arg]translit($1,A-Z-,a-z_)
AC_CACHE_CHECK([whether $CC supports $1], [ac_cv_gcc_arg]translit($1,A-Z-,a-z_), [
echo 'void somefunc() { };' > conftest.c
cmd='$CC $1 -c conftest.c'
if eval $cmd 2>&1 | egrep -e $1 >/dev/null ; then
ac_result=no
else
ac_result=yes
fi
eval $gcc_arg_name=$ac_result
rm -f conftest.*
])
if eval test "\$$gcc_arg_name" = "yes"; then
$2
else
:
$3
fi
])
AC_DEFUN(TSRM_BASIC_CHECKS,[
AC_REQUIRE([AC_PROG_CC])dnl
dnl AC_REQUIRE([AM_PROG_CC_STDC])dnl
AC_REQUIRE([AC_PROG_CC_C_O])dnl
AC_REQUIRE([AC_PROG_RANLIB])dnl
AC_CHECK_HEADERS(stdarg.h)
])
AC_DEFUN(TSRM_CHECK_PTH,[
AC_MSG_CHECKING(for GNU Pth)
PTH_PREFIX="`$1 --prefix`"
if test -z "$PTH_PREFIX"; then
AC_MSG_RESULT(Please check your Pth installation)
fi
CPPFLAGS="$CPPFLAGS `$1 --cflags`"
LDFLAGS="$LDFLAGS `$1 --ldflags`"
LIBS="$LIBS `$1 --libs`"
AC_DEFINE(GNUPTH, 1, [Whether you use GNU Pth])
AC_MSG_RESULT(yes - installed in $PTH_PREFIX)
])
sinclude(threads.m4)
sinclude(TSRM/threads.m4)
AC_DEFUN(TSRM_CHECK_PTHREADS,[
PTHREADS_CHECK
if test "$pthreads_working" != "yes"; then
AC_MSG_ERROR(Your system seems to lack POSIX threads.)
fi
AC_DEFINE(PTHREADS, 1, Whether to use Pthreads)
AC_MSG_CHECKING(for POSIX threads)
AC_MSG_RESULT(yes)
])
AC_DEFUN(TSRM_OTHER_CHECKS,[
dnl For the thread implementations, we always use --with-*
dnl to maintain consistency
AC_ARG_WITH(tsrm-pth,
[ --with-tsrm-pth[=pth-config] Use GNU Pth.],[
TSRM_PTH=$withval
],[
TSRM_PTH=no
])
AC_ARG_WITH(tsrm-pthreads,
[ --with-tsrm-pthreads Use POSIX threads (default)],[
TSRM_PTHREADS=$withval
],[
TSRM_PTHREADS=yes
])
test "$TSRM_PTH" = "yes" && TSRM_PTH=pth-config
if test "$TSRM_PTH" != "no"; then
TSRM_CHECK_PTH($TSRM_PTH)
elif test "$TSRM_PTHREADS" != "no"; then
TSRM_CHECK_PTHREADS
fi
])
-1
View File
@@ -1 +0,0 @@
/* Leave this file alone */
-833
View File
@@ -1,833 +0,0 @@
dnl $Id$
dnl
dnl This file contains local autoconf functions.
sinclude(dynlib.m4)
AC_DEFUN(PHP_READDIR_R_TYPE,[
dnl HAVE_READDIR_R is also defined by libmysql
AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no)
if test "$ac_cv_func_readdir_r" = "yes"; then
AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[
AC_TRY_RUN([
#define _REENTRANT
#include <sys/types.h>
#include <dirent.h>
main() {
DIR *dir;
struct dirent entry, *pentry;
dir = opendir("/");
if (!dir)
exit(1);
if (readdir_r(dir, &entry, &pentry) == 0)
exit(0);
exit(1);
}
],[
ac_cv_what_readdir_r=POSIX
],[
AC_TRY_CPP([
#define _REENTRANT
#include <sys/types.h>
#include <dirent.h>
int readdir_r(DIR *, struct dirent *);
],[
ac_cv_what_readdir_r=old-style
],[
ac_cv_what_readdir_r=none
])
],[
ac_cv_what_readdir_r=none
])
])
case "$ac_cv_what_readdir_r" in
POSIX)
AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);;
old-style)
AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);;
esac
fi
])
AC_DEFUN(PHP_SHLIB_SUFFIX_NAME,[
PHP_SUBST(SHLIB_SUFFIX_NAME)
SHLIB_SUFFIX_NAME=so
case "$host_alias" in
*hpux*)
SHLIB_SUFFIX_NAME=sl
;;
esac
])
AC_DEFUN(PHP_DEBUG_MACRO,[
DEBUG_LOG="$1"
cat >$1 <<X
CONFIGURE: $CONFIGURE_COMMAND
CC: $CC
CFLAGS: $CFLAGS
CPPFLAGS: $CPPFLAGS
CXX: $CXX
CXXFLAGS: $CXXFLAGS
INCLUDES: $INCLUDES
LDFLAGS: $LDFLAGS
LIBS: $LIBS
DLIBS: $DLIBS
SAPI: $PHP_SAPI
PHP_RPATHS: $PHP_RPATHS
uname -a: `uname -a`
X
cat >conftest.$ac_ext <<X
main()
{
exit(0);
}
X
(eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1
rm -fr conftest*
])
AC_DEFUN(PHP_MISSING_TIME_R_DECL,[
AC_MSG_CHECKING(for missing declarations of reentrant functions)
AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[
:
],[
AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared])
])
AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = gmtime_r],[
:
],[
AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared])
])
AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = asctime_r],[
:
],[
AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared])
])
AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = ctime_r],[
:
],[
AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared])
])
AC_TRY_COMPILE([#include <string.h>],[char *(*func)() = strtok_r],[
:
],[
AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared])
])
AC_MSG_RESULT(done)
])
dnl
dnl PHP_LIBGCC_LIBPATH(gcc)
dnl Stores the location of libgcc in libgcc_libpath
dnl
AC_DEFUN(PHP_LIBGCC_LIBPATH,[
changequote({,})
libgcc_libpath="`$1 --print-libgcc-file-name|sed 's%/*[^/][^/]*$%%'`"
changequote([,])
])
AC_DEFUN(PHP_ARG_ANALYZE,[
case "[$]$1" in
shared,*)
ext_output="yes, shared"
ext_shared=yes
$1=`echo $ac_n "[$]$1$ac_c"|sed s/^shared,//`
;;
shared)
ext_output="yes, shared"
ext_shared=yes
$1=yes
;;
no)
ext_output="no"
ext_shared=no
;;
*)
ext_output="yes"
ext_shared=no
;;
esac
if test "$php_always_shared" = "yes"; then
ext_output="yes, shared"
ext_shared=yes
test "[$]$1" = "no" && $1=yes
fi
AC_MSG_RESULT($ext_output)
])
dnl
dnl PHP_ARG_WITH(arg-name, check message, help text[, default-val])
dnl Sets PHP_ARG_NAME either to the user value or to the default value.
dnl default-val defaults to no.
dnl
AC_DEFUN(PHP_ARG_WITH,[
PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z-,A-Z_))
])
AC_DEFUN(PHP_REAL_ARG_WITH,[
AC_MSG_CHECKING($2)
AC_ARG_WITH($1,[$3],$5=[$]withval,$5=ifelse($4,,no,$4))
PHP_ARG_ANALYZE($5)
])
dnl
dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val])
dnl Sets PHP_ARG_NAME either to the user value or to the default value.
dnl default-val defaults to no.
dnl
AC_DEFUN(PHP_ARG_ENABLE,[
PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z-,A-Z_))
])
AC_DEFUN(PHP_REAL_ARG_ENABLE,[
AC_MSG_CHECKING($2)
AC_ARG_ENABLE($1,[$3],$5=[$]enableval,$5=ifelse($4,,no,$4))
PHP_ARG_ANALYZE($5)
])
AC_DEFUN(PHP_MODULE_PTR,[
EXTRA_MODULE_PTRS="$EXTRA_MODULE_PTRS $1,"
])
AC_DEFUN(PHP_CONFIG_NICE,[
rm -f $1
cat >$1<<EOF
#! /bin/sh
#
# Created by configure
EOF
for arg in [$]0 "[$]@"; do
echo "\"[$]arg\" \\" >> $1
done
echo '"[$]@"' >> $1
chmod +x $1
])
AC_DEFUN(PHP_TIME_R_TYPE,[
AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[
AC_TRY_RUN([
#include <time.h>
#include <stdlib.h>
main() {
char buf[27];
struct tm t;
time_t old = 0;
int r, s;
s = gmtime_r(&old, &t);
r = (int) asctime_r(&t, buf, 26);
if (r == s && s == 0) exit(0);
exit(1);
}
],[
ac_cv_time_r_type=hpux
],[
ac_cv_time_r_type=POSIX
],[
ac_cv_time_r_type=POSIX
])
])
if test "$ac_cv_time_r_type" = "hpux"; then
AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x])
fi
])
AC_DEFUN(PHP_SUBST,[
PHP_VAR_SUBST="$PHP_VAR_SUBST $1"
AC_SUBST($1)
])
AC_DEFUN(PHP_FAST_OUTPUT,[
PHP_FAST_OUTPUT_FILES="$PHP_FAST_OUTPUT_FILES $1"
])
AC_DEFUN(PHP_MKDIR_P_CHECK,[
AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[
test -d conftestdir && rm -rf conftestdir
mkdir -p conftestdir/somedir >/dev/null 2>&1
if test -d conftestdir/somedir; then
ac_cv_mkdir_p=yes
else
ac_cv_mkdir_p=no
fi
rm -rf conftestdir
])
])
AC_DEFUN(PHP_FAST_GENERATE,[
PHP_MKDIR_P_CHECK
echo creating config_vars.mk
> config_vars.mk
for i in $PHP_VAR_SUBST; do
eval echo "$i = \$$i" >> config_vars.mk
done
$SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $PHP_FAST_OUTPUT_FILES
])
AC_DEFUN(PHP_TM_GMTOFF,[
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,1,[whether you have tm_gmtoff in struct tm])
fi
])
dnl PHP_CONFIGURE_PART(MESSAGE)
dnl Idea borrowed from mm
AC_DEFUN(PHP_CONFIGURE_PART,[
AC_MSG_RESULT()
AC_MSG_RESULT(${T_MD}$1${T_ME})
])
AC_DEFUN(PHP_PROG_SENDMAIL,[
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,1,[whether you have sendmail])
fi
])
AC_DEFUN(PHP_RUNPATH_SWITCH,[
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"
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,"
else
dnl something innocuous
ld_runpath_switch="-L"
fi
fi
])
AC_DEFUN(PHP_STRUCT_FLOCK,[
AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock,
AC_TRY_COMPILE([
#include <unistd.h>
#include <fcntl.h>
],
[struct flock x;],
[
ac_cv_struct_flock=yes
],[
ac_cv_struct_flock=no
])
)
if test "$ac_cv_struct_flock" = "yes" ; then
AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock])
fi
])
AC_DEFUN(PHP_SOCKLEN_T,[
AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t,
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>
],[
socklen_t x;
],[
ac_cv_socklen_t=yes
],[
ac_cv_socklen_t=no
]))
if test "$ac_cv_socklen_t" = "yes"; then
AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t])
fi
])
dnl
dnl PHP_SET_SYM_FILE(path)
dnl
dnl set the path of the file which contains the symbol export list
dnl
AC_DEFUN(PHP_SET_SYM_FILE,
[
PHP_SYM_FILE="$1"
])
dnl
dnl PHP_BUILD_THREAD_SAFE
dnl
AC_DEFUN(PHP_BUILD_THREAD_SAFE,[
enable_experimental_zts=yes
if test "$pthreads_working" != "yes"; then
AC_MSG_ERROR(ZTS currently requires working POSIX threads. Your system does not support this.)
fi
])
dnl
dnl PHP_BUILD_SHARED
dnl
AC_DEFUN(PHP_BUILD_SHARED,[
php_build_target=shared
])
dnl
dnl PHP_BUILD_STATIC
dnl
AC_DEFUN(PHP_BUILD_STATIC,[
php_build_target=static
])
dnl
dnl PHP_BUILD_PROGRAM
dnl
AC_DEFUN(PHP_BUILD_PROGRAM,[
php_build_target=program
])
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,[
changequote({,})
unique=`echo $2|sed 's/[^a-zA-Z0-9]/_/g'`
changequote([,])
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
changequote({,})
ep_dir="`echo $1|sed 's%/*[^/][^/]*$%%'`"
changequote([,])
ep_realdir="`(cd \"$ep_dir\" && pwd)`"
$2="$ep_realdir/`basename \"$1\"`"
fi
])
dnl
dnl AC_ADD_LIBPATH(path[, shared-libadd])
dnl
dnl add a library to linkpath/runpath
dnl
AC_DEFUN(AC_ADD_LIBPATH,[
if test "$1" != "/usr/lib"; then
AC_EXPAND_PATH($1, ai_p)
if test "$ext_shared" = "yes" && test -n "$2"; then
$2="-R$1 -L$1 [$]$2"
else
AC_PHP_ONCE(LIBPATH, $ai_p, [
test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$ai_p"
LDFLAGS="$LDFLAGS -L$ai_p"
PHP_RPATHS="$PHP_RPATHS $ai_p"
])
fi
fi
])
dnl
dnl AC_BUILD_RPATH()
dnl
dnl builds RPATH from PHP_RPATHS
dnl
AC_DEFUN(AC_BUILD_RPATH,[
if test "$PHP_RPATH" = "yes" && test -n "$PHP_RPATHS"; then
OLD_RPATHS="$PHP_RPATHS"
PHP_RPATHS=""
for i in $OLD_RPATHS; do
PHP_LDFLAGS="$PHP_LDFLAGS -L$i"
PHP_RPATHS="$PHP_RPATHS -R $i"
NATIVE_RPATHS="$NATIVE_RPATHS ${ld_runpath_switch}$i"
done
fi
])
dnl
dnl AC_ADD_INCLUDE(path)
dnl
dnl add a include path
dnl
AC_DEFUN(AC_ADD_INCLUDE,[
if test "$1" != "/usr/include"; then
AC_EXPAND_PATH($1, ai_p)
AC_PHP_ONCE(INCLUDEPATH, $ai_p, [
INCLUDES="$INCLUDES -I$ai_p"
])
fi
])
AC_DEFUN(PHP_X_ADD_LIBRARY,[
ifelse($2,,$3="-l$1 [$]$3", $3="[$]$3 -l$1")
])
dnl
dnl AC_ADD_LIBRARY(library[, append[, shared-libadd]])
dnl
dnl add a library to the link line
dnl
AC_DEFUN(AC_ADD_LIBRARY,[
if test "$1" != "c"; then
ifelse($3,,[
AC_PHP_ONCE(LIBRARY, $1, [
PHP_X_ADD_LIBRARY($1,$2,LIBS)
])
],[
if test "$ext_shared" = "yes"; then
PHP_X_ADD_LIBRARY($1,$2,$3)
else
AC_ADD_LIBRARY($1,$2)
fi
])
fi
])
dnl
dnl AC_ADD_LIBRARY_DEFER(library[, append])
dnl
dnl add a library to the link line (deferred)
AC_DEFUN(AC_ADD_LIBRARY_DEFER,[
AC_PHP_ONCE(LIBRARY, $1, [
ifelse($#, 1, DLIBS="-l$1 $DLIBS", DLIBS="$DLIBS -l$1")
])
])
dnl
dnl AC_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd])
dnl
dnl add a library to the link line and path to linkpath/runpath.
dnl if shared-libadd is not empty and $ext_shared is yes,
dnl shared-libadd will be assigned the library information
dnl
AC_DEFUN(AC_ADD_LIBRARY_WITH_PATH,[
ifelse($3,,[
if test -n "$2"; then
AC_ADD_LIBPATH($2)
fi
AC_ADD_LIBRARY($1)
],[
if test "$ext_shared" = "yes"; then
$3="-l$1 [$]$3"
if test -n "$2"; then
AC_ADD_LIBPATH($2,$3)
fi
else
AC_ADD_LIBRARY_WITH_PATH($1,$2)
fi
])
])
dnl
dnl AC_ADD_LIBRARY_DEFER_WITH_PATH(library, path)
dnl
dnl add a library to the link line (deferred)
dnl and path to linkpath/runpath (not deferred)
dnl
AC_DEFUN(AC_ADD_LIBRARY_DEFER_WITH_PATH,[
AC_ADD_LIBPATH($2)
AC_ADD_LIBRARY_DEFER($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"
changequote({,})
var=`echo $opt|sed 's/[^a-zA-Z0-9]/_/g'`
changequote([,])
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
])
AC_DEFUN(PHP_REGEX,[
if test "$REGEX_TYPE" = "php"; then
REGEX_LIB=regex/libregex.la
REGEX_DIR=regex
AC_DEFINE(HSREGEX,1,[ ])
AC_DEFINE(REGEX,1,[ ])
PHP_FAST_OUTPUT(regex/Makefile)
elif test "$REGEX_TYPE" = "system"; then
AC_DEFINE(REGEX,0,[ ])
fi
AC_MSG_CHECKING(which regex library to use)
AC_MSG_RESULT($REGEX_TYPE)
PHP_SUBST(REGEX_DIR)
PHP_SUBST(REGEX_LIB)
PHP_SUBST(HSREGEX)
])
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_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[
AC_TRY_RUN([main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }],[
ac_cv_broken_sprintf=no
],[
ac_cv_broken_sprintf=yes
],[
ac_cv_broken_sprintf=no
])
])
if test "$ac_cv_broken_sprintf" = "yes"; then
AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [ ])
else
AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [ ])
fi
])
dnl
dnl PHP_EXTENSION(extname [, shared])
dnl
dnl Includes an extension in the build.
dnl
dnl "extname" is the name of the ext/ subdir where the extension resides
dnl "shared" can be set to "shared" or "yes" to build the extension as
dnl a dynamically loadable library.
dnl
AC_DEFUN(PHP_EXTENSION,[
EXT_SUBDIRS="$EXT_SUBDIRS $1"
if test -d "$abs_srcdir/ext/$1"; then
dnl ---------------------------------------------- Internal Module
ext_builddir="ext/$1"
ext_srcdir="$abs_srcdir/ext/$1"
else
dnl ---------------------------------------------- External Module
ext_builddir="."
ext_srcdir="$abs_srcdir"
fi
if test "$2" != "shared" && test "$2" != "yes"; then
dnl ---------------------------------------------- Static module
LIB_BUILD($ext_builddir)
EXT_LTLIBS="$EXT_LTLIBS $ext_builddir/lib$1.la"
EXT_STATIC="$EXT_STATIC $1"
else
dnl ---------------------------------------------- Shared module
LIB_BUILD($ext_builddir,yes)
AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z-,A-Z_), 1, Whether to build $1 as dynamic module)
fi
PHP_FAST_OUTPUT($ext_builddir/Makefile)
])
PHP_SUBST(EXT_SUBDIRS)
PHP_SUBST(EXT_STATIC)
PHP_SUBST(EXT_SHARED)
PHP_SUBST(EXT_LIBS)
PHP_SUBST(EXT_LTLIBS)
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
if test -n "$php_always_shared"; then
shared=yes
fi
])
dnl The problem is that the default compilation flags in Solaris 2.6 won't
dnl let programs access large files; you need to tell the compiler that
dnl you actually want your programs to work on large files. For more
dnl details about this brain damage please see:
dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
dnl Written by Paul Eggert <eggert@twinsun.com>.
AC_DEFUN(AC_SYS_LFS,
[dnl
# If available, prefer support for large files unless the user specified
# one of the CPPFLAGS, LDFLAGS, or LIBS variables.
AC_MSG_CHECKING(whether large file support needs explicit enabling)
ac_getconfs=''
ac_result=yes
ac_set=''
ac_shellvars='CPPFLAGS LDFLAGS LIBS'
for ac_shellvar in $ac_shellvars; do
case $ac_shellvar in
CPPFLAGS) ac_lfsvar=LFS_CFLAGS ;;
*) ac_lfsvar=LFS_$ac_shellvar ;;
esac
eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
(getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
ac_getconf=`getconf $ac_lfsvar`
ac_getconfs=$ac_getconfs$ac_getconf
eval ac_test_$ac_shellvar=\$ac_getconf
done
case "$ac_result$ac_getconfs" in
yes) ac_result=no ;;
esac
case "$ac_result$ac_set" in
yes?*) ac_result="yes, but $ac_set is already set, so use its settings"
esac
AC_MSG_RESULT($ac_result)
case $ac_result in
yes)
for ac_shellvar in $ac_shellvars; do
eval $ac_shellvar=\$ac_test_$ac_shellvar
done ;;
esac
])
AC_DEFUN(AC_SOCKADDR_SA_LEN,[
AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>],
[struct sockaddr s; s.sa_len;],
[ac_cv_sockaddr_sa_len=yes
AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[ ])],
[ac_cv_sockaddr_sa_len=no])
])
])
dnl ## PHP_AC_OUTPUT(file)
dnl ## adds "file" to the list of files generated by AC_OUTPUT
dnl ## This macro can be used several times.
AC_DEFUN(PHP_OUTPUT,[
PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1"
])
AC_DEFUN(PHP_DECLARED_TIMEZONE,[
AC_CACHE_CHECK(for declared timezone, ac_cv_declared_timezone,[
AC_TRY_COMPILE([
#include <sys/types.h>
#include <time.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
],[
time_t foo = (time_t) timezone;
],[
ac_cv_declared_timezone=yes
],[
ac_cv_declared_timezone=no
])])
if test "$ac_cv_declared_timezone" = "yes"; then
AC_DEFINE(HAVE_DECLARED_TIMEZONE, 1, [Whether system headers declare timezone])
fi
])
AC_DEFUN(PHP_EBCDIC,[
AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
AC_TRY_RUN( [
int main(void) {
return (unsigned char)'A' != (unsigned char)0xC1;
}
],[
ac_cv_ebcdic="yes"
],[
ac_cv_ebcdic="no"
],[
ac_cv_ebcdic="no"
])])
if test "$ac_cv_ebcdic" = "yes"; then
AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC])
fi
])
-276
View File
@@ -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 = ALLOC_ZVAL();
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).
-492
View File
@@ -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
-90
View File
@@ -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@fast.no> |
+----------------------------------------------------------------------+
*/
#define CONFIGURE_COMMAND "@CONFIGURE_COMMAND@"
#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_BUILD_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_OCI8_SHARED_LIBADD "@OCI8_SHARED_LIBADD@"
#define PHP_OCI8_DIR "@OCI8_DIR@"
#define PHP_OCI8_VERSION "@OCI8_VERSION@"
#define PHP_ORACLE_SHARED_LIBADD "@ORACLE_SHARED_LIBADD@"
#define PHP_ORACLE_DIR "@ORACLE_DIR@"
#define PHP_ORACLE_VERSION "@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 ""
#define PHP_EXTENSION_DIR "@EXTENSION_DIR@"
-77
View File
@@ -1,77 +0,0 @@
# Copyright (c) 1999, 2000 Sascha Schumann. 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.
#
# THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``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.
#
##############################################################################
# $Id$
#
# Makefile to generate build tools
#
SUBDIRS = Zend TSRM
STAMP = buildmk.stamp
ALWAYS = generated_lists
all: $(STAMP) $(ALWAYS)
@$(MAKE) AMFLAGS=$(AMFLAGS) -s -f build/build2.mk
generated_lists:
@echo makefile_am_files = Zend/Makefile.am \
TSRM/Makefile.am > $@
@echo config_h_files = Zend/acconfig.h TSRM/acconfig.h >> $@
@echo config_m4_files = Zend/Zend.m4 TSRM/tsrm.m4 \
Zend/acinclude.m4 ext/*/config.m4 sapi/*/config.m4 >> $@
$(STAMP): build/buildcheck.sh
@build/buildcheck.sh && touch $(STAMP)
snapshot:
distname='$(DISTNAME)'; \
if test -z "$$distname"; then \
distname='php4-snapshot'; \
fi; \
myname=`basename \`pwd\`` ; \
cd .. && cp -rp $$myname $$distname; \
cd $$distname; \
rm -f $(SUBDIRS) 2>/dev/null || true; \
for i in $(SUBDIRS); do \
test -d $$i || (test -d ../$$i && cp -rp ../$$i $$i); \
done; \
find . -type l -exec rm {} \; ; \
$(MAKE) AMFLAGS=--copy -f build/build.mk; \
cd ..; \
tar cf $$distname.tar $$distname; \
rm -rf $$distname $$distname.tar.*; \
bzip2 -9 $$distname.tar; \
md5sum $$distname.tar.bz2; \
sync; sleep 2; \
md5sum $$distname.tar.bz2; \
bzip2 -t $$distname.tar.bz2
cvsclean:
@for i in `find . -name .cvsignore`; do \
(cd `dirname $$i` 2>/dev/null && rm -rf `cat .cvsignore` *.o *.a || true); \
done
@rm -f $(SUBDIRS) 2>/dev/null || true
.PHONY: $(ALWAYS) snapshot cvsclean
-82
View File
@@ -1,82 +0,0 @@
# Copyright (c) 1999, 2000 Sascha Schumann. 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.
#
# THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``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.
#
##############################################################################
# $Id$
include generated_lists
TOUCH_FILES = mkinstalldirs install-sh missing
LT_TARGETS = ltconfig ltmain.sh config.guess config.sub
makefile_in_files = $(makefile_am_files:.am=.in)
makefile_files = $(makefile_am_files:e.am=e)
config_h_in = php_config.h.in
acconfig_h_SOURCES = acconfig.h.in $(config_h_files)
targets = $(TOUCH_FILES) $(makefile_in_files) configure $(config_h_in)
all: Zend/Makefile.am TSRM/Makefile.am $(targets)
Zend/Makefile.am:
test -d Zend || (test -d ../Zend && ln -s ../Zend Zend)
TSRM/Makefile.am:
test -d TSRM || (test -d ../TSRM && ln -s ../TSRM TSRM)
acconfig.h: $(acconfig_h_SOURCES)
@echo rebuilding $@
cat $(acconfig_h_SOURCES) > $@
$(makefile_in_files): $(makefile_am_files) aclocal.m4 configure.in $(config_m4_files)
@echo rebuilding Makefile templates
@for i in $(LT_TARGETS); do \
if test -f "$$i"; then \
mv $$i $$i.bak; \
cp $$i.bak $$i; \
fi; \
done
@test -f want_dependencies || flag=-i; \
automake -a $$flag $(AMFLAGS) $(makefile_files) \
|| true >&2
@for i in $(LT_TARGETS); do mv $$i.bak $$i; done
aclocal.m4: configure.in acinclude.m4 dynlib.m4
aclocal
$(config_h_in): configure acconfig.h
# explicitly remove target since autoheader does not seem to work
# correctly otherwise (timestamps are not updated)
@echo rebuilding $@
@rm -f $@
@autoheader 2>&1 | (grep -v 'warning: AC_TRY_RUN called without default to allow cross compiling'||true)
$(TOUCH_FILES):
touch $(TOUCH_FILES)
configure: aclocal.m4 configure.in $(config_m4_files)
@echo rebuilding $@
@autoconf 2>&1 | (grep -v 'warning: AC_TRY_RUN called without default to allow cross compiling'||true)
-69
View File
@@ -1,69 +0,0 @@
#! /bin/sh
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 -z "$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" && (test "$3" = "c" || test "$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
am_prefix=`which automake | sed -e 's#/[^/]*/[^/]*$##'`
lt_prefix=`which libtool | sed -e 's#/[^/]*/[^/]*$##'`
if test "$am_prefix" != "$lt_prefix"; then
echo "WARNING: automake and libtool are installed in different"
echo " directories. This may cause aclocal to fail."
echo " continuing anyway"
fi
exit 0
-5
View File
@@ -1,5 +0,0 @@
all: all-recursive
include $(builddir)/libs.mk
include $(top_srcdir)/build/rules.mk
-61
View File
@@ -1,61 +0,0 @@
#! /bin/sh
#
# Copyright (c) 1999, 2000 Sascha Schumann. 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.
#
# THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``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.
#
##############################################################################
# $Id: fastgen.sh,v 1.6 2000-05-12 07:37:42 sas Exp $
#
srcdir=$1
shift
mkdir_p=$1
shift
top_srcdir=`(cd $srcdir; pwd)`
top_builddir=`pwd`
if test "$mkdir_p" = "yes"; then
mkdir_p="mkdir -p"
else
mkdir_p="$top_srcdir/helpers/mkdir.sh"
fi
for makefile in $@; do
echo "creating $makefile"
# portable dirname
dir=`echo $makefile|sed 's%/*[^/][^/]*$%%'`
$mkdir_p "$dir/"
(cat <<EOF
top_srcdir = $top_srcdir
top_builddir = $top_builddir
srcdir = $top_srcdir/$dir
builddir = $top_builddir/$dir
VPATH = $top_srcdir/$dir
EOF
)| cat - $top_srcdir/$makefile.in > $makefile
test -z "$dir" || touch $dir/.deps
done
-30
View File
@@ -1,30 +0,0 @@
# Copyright (c) 1999, 2000 Sascha Schumann. 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.
#
# THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
##############################################################################
# $Id$
#
LTLIBRARY_OBJECTS = $(LTLIBRARY_SOURCES:.c=.lo)
$(LTLIBRARY_NAME): $(LTLIBRARY_OBJECTS) $(LTLIBRARY_DEPENDENCIES)
$(LINK) $(LTLIBRARY_LDFLAGS) $(LTLIBRARY_OBJECTS) $(LTLIBRARY_LIBADD)
-31
View File
@@ -1,31 +0,0 @@
# Copyright (c) 1999 Sascha Schumann. 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.
#
# THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``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.
#
##############################################################################
# $Id$
#
targets = $(LTLIBRARY_NAME)
include $(top_srcdir)/build/rules.mk
include $(top_srcdir)/build/library.mk
-91
View File
@@ -1,91 +0,0 @@
#!/usr/bin/perl
#
# $Id$
#
# Created: Thu Aug 15 11:57:33 1996 too
# Last modified: Mon Dec 27 09:23:56 1999 too
#
# Copyright (c) 1996-1999 Tomi Ollila. 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.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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.
die "Usage: mkdep CPP-command [CPP options] file1 [file2...]\n"
if ($#ARGV < 1);
$cmdl = shift(@ARGV);
$cmdl = "$cmdl " . shift (@ARGV) while ($ARGV[0] =~ /^-[A-Z]/);
while ($file = shift(@ARGV))
{
$file =~ s/\.o$/.c/;
open(F, "$cmdl $file|");
&parseout;
close(F);
}
sub initinit
{
%used = ();
$of = $file;
$of =~ s/\.c$/.lo/;
$str = "$of:\t$file";
$len = length $str;
}
sub initstr
{
$str = "\t";
$len = length $str;
}
sub parseout
{
&initinit;
while (<F>)
{
next unless (/^# [0-9]* "(.*\.h)"/);
next if ($1 =~ /^\//);
next if $used{$1};
$used{$1} = 1;
$nlen = length($1) + 1;
if ($len + $nlen > 72)
{
print $str, "\\\n";
&initstr;
$str = $str . $1;
}
else { $str = $str . " " . $1; }
$len += $nlen;
}
print $str, "\n";
}
-30
View File
@@ -1,30 +0,0 @@
# Copyright (c) 1999, 2000 Sascha Schumann. 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.
#
# THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``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.
#
##############################################################################
# $Id$
#
PROGRAM_OBJECTS = $(PROGRAM_SOURCES:.c=.lo)
$(PROGRAM_NAME): $(PROGRAM_DEPENDENCIES) $(PROGRAM_OBJECTS)
$(LINK) $(PROGRAM_LDFLAGS) $(PROGRAM_OBJECTS) $(PROGRAM_LDADD)
-108
View File
@@ -1,108 +0,0 @@
# Copyright (c) 1999, 2000 Sascha Schumann. 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.
#
# THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``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.
#
##############################################################################
# $Id$
#
include $(top_builddir)/config_vars.mk
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@
mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p
INSTALL = $(top_srcdir)/build/shtool install -c
INSTALL_DATA = $(INSTALL) -m 644
SHARED_COMPILE = $(SHARED_LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -c $< && touch $@
DEFS = -DHAVE_CONFIG_H -I. -I$(srcdir) -I$(top_builddir)
moduledir = $(EXTENSION_DIR)
.SUFFIXES:
.SUFFIXES: .slo .c .lo .o .s .y .l
.c.o:
$(COMPILE) -c $<
.s.o:
$(COMPILE) -c $<
.c.lo:
$(PHP_COMPILE)
.s.lo:
$(PHP_COMPILE)
.c.slo:
$(SHARED_COMPILE)
.y.c:
$(YACC) $(YFLAGS) $< && mv y.tab.c $*.c
if test -f y.tab.h; then \
if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \
else :; fi
.l.c:
$(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@
all: all-recursive
install: install-recursive
distclean-recursive depend-recursive clean-recursive all-recursive install-recursive:
@otarget=`echo $@|sed s/-recursive//`; \
list='$(SUBDIRS)'; for i in $$list; do \
target="$$otarget"; \
echo "Making $$target in $$i"; \
if test "$$i" = "."; then \
ok=yes; \
target="$$target-p"; \
fi; \
(cd $$i && $(MAKE) $$target) || exit 1; \
done; \
if test "$$otarget" = "all" && test -z '$(targets)'; then ok=yes; fi; \
if test "$$ok" != "yes"; then $(MAKE) "$$otarget-p" || exit 1; fi
all-p: $(targets)
install-p: $(targets) $(install_targets)
distclean-p depend-p clean-p:
depend: depend-recursive
test "`echo *.c`" = '*.c' || perl $(top_srcdir)/build/mkdep.perl $(CPP) $(INCLUDES) $(EXTRA_INCLUDES) *.c > $(builddir)/.deps
clean: clean-recursive clean-x
clean-x:
rm -f $(targets) *.lo *.slo *.la *.o $(CLEANFILES)
rm -rf .libs
distclean: distclean-recursive clean-x
rm -f config.cache config.log config.status config_vars.mk libtool \
php_config.h stamp-h Makefile build-defs.h php4.spec libphp4.module
include $(builddir)/.deps
.PHONY: all-recursive clean-recursive install-recursive \
$(install_targets) install all clean depend depend-recursive shared \
distclean-recursive distclean clean-x all-p install-p distclean-p \
depend-p clean-p
-116
View File
@@ -1,116 +0,0 @@
# Copyright (c) 1999, 2000 Sascha Schumann. 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.
#
# THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``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.
#
##############################################################################
# $Id$
#
include $(top_builddir)/config_vars.mk
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@
mkinstalldirs = $(top_srcdir)/build/shtool mkdir -f -p
INSTALL = $(top_srcdir)/build/shtool install -c
INSTALL_DATA = $(INSTALL) -m 644
SHARED_COMPILE = $(SHARED_LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -c $< && touch $@
DEFS = -DHAVE_CONFIG_H -I. -I$(srcdir) -I$(top_builddir)
moduledir = $(EXTENSION_DIR)
.SUFFIXES:
.SUFFIXES: .slo .c .lo .o .s .y .l
.c.o:
$(COMPILE) -c $<
.s.o:
$(COMPILE) -c $<
.c.lo:
$(PHP_COMPILE)
.s.lo:
$(PHP_COMPILE)
.c.slo:
$(SHARED_COMPILE)
.y.c:
$(YACC) $(YFLAGS) $< && mv y.tab.c $*.c
if test -f y.tab.h; then \
if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \
else :; fi
.l.c:
$(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@
install_targets = install-modules
all: all-recursive
install: install-recursive
distclean-recursive depend-recursive clean-recursive all-recursive install-recursive:
@otarget=`echo $@|sed s/-recursive//`; \
list='$(SUBDIRS)'; for i in $$list; do \
target="$$otarget"; \
echo "Making $$target in $$i"; \
if test "$$i" = "."; then \
ok=yes; \
target="$$target-p"; \
fi; \
(cd $$i && $(MAKE) $$target) || exit 1; \
done; \
if test "$$otarget" = "all" && test -z '$(targets)'; then ok=yes; fi; \
if test "$$ok" != "yes"; then $(MAKE) "$$otarget-p" || exit 1; fi
all-p: $(targets)
install-p: $(targets) $(install_targets)
distclean-p depend-p clean-p:
depend: depend-recursive
test "`echo *.c`" = '*.c' || perl $(top_srcdir)/build/mkdep.perl $(CPP) $(INCLUDES) $(EXTRA_INCLUDES) *.c > $(builddir)/.deps
clean: clean-recursive clean-x
clean-x:
rm -f $(targets) *.lo *.slo *.la *.o $(CLEANFILES)
rm -rf .libs
distclean: distclean-recursive clean-x
rm -f config.cache config.log config.status config_vars.mk libtool \
php_config.h stamp-h Makefile build-defs.h php4.spec libphp4.module
install-modules:
@test -d modules && \
$(mkinstalldirs) $(moduledir) && \
echo "installing shared modules into $(moduledir)" && \
rm -f modules/*.la && \
cp modules/* $(moduledir) || true
include $(builddir)/.deps
.PHONY: all-recursive clean-recursive install-recursive \
$(install_targets) install all clean depend depend-recursive shared \
distclean-recursive distclean clean-x all-p install-p distclean-p \
depend-p clean-p
-716
View File
@@ -1,716 +0,0 @@
#!/bin/sh
##
## GNU shtool -- The GNU Portable Shell Tool
## Copyright (c) 1994-2000 Ralf S. Engelschall <rse@engelschall.com>
##
## See http://www.gnu.org/software/shtool/ for more information.
## See ftp://ftp.gnu.org/gnu/shtool/ for latest version.
##
## Version 1.4.9 (16-Apr-2000)
## Ingredients: 3/17 available modules
##
##
## 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
## USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
##
## Notice: Given that you include this file verbatim into your own
## source tree, you are justified in saying that it remains separate
## from your package, and that this way you are simply just using GNU
## shtool. So, in this situation, there is no requirement that your
## package itself is licensed under the GNU General Public License in
## order to take advantage of GNU shtool.
##
##
## Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]
##
## Available commands:
## echo Print string with optional construct expansion
## install Install a program, script or datafile
## mkdir Make one or more directories
##
## Not available commands (because module was not built-in):
## mdate Pretty-print modification time of a file or dir
## table Pretty-print a field-separated list as a table
## prop Display progress with a running propeller
## move Move files with simultaneous substitution
## mkln Make link with calculation of relative paths
## mkshadow Make a shadow tree through symbolic links
## fixperm Fix file permissions inside a source tree
## tarball Roll distribution tarballs
## guessos Simple operating system guesser
## arx Extended archive command
## slo Separate linker options by library class
## scpp Sharing C Pre-Processor
## version Generate and maintain a version information file
## path Deal with program paths
##
if [ $# -eq 0 ]; then
echo "$0:Error: invalid command line" 1>&2
echo "$0:Hint: run \`$0 -h' for usage" 1>&2
exit 1
fi
if [ ".$1" = ".-h" -o ".$1" = ".--help" ]; then
echo "This is GNU shtool, version 1.4.9 (16-Apr-2000)"
echo "Copyright (c) 1994-2000 Ralf S. Engelschall <rse@engelschall.com>"
echo "Report bugs to <bug-shtool@gnu.org>"
echo ''
echo "Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]"
echo ''
echo 'Available global <options>:'
echo ' -v, --version display shtool version information'
echo ' -h, --help display shtool usage help page (this one)'
echo ' -d, --debug display shell trace information'
echo ''
echo 'Available <cmd-name> [<cmd-options>] [<cmd-args>]:'
echo ' echo [-n] [-e] [<str> ...]'
echo ' install [-v] [-t] [-c] [-C] [-s] [-m<mode>] [-o<owner>] [-g<group>]'
echo ' [-e<ext>] <file> <path>'
echo ' mkdir [-t] [-f] [-p] [-m<mode>] <dir> [<dir> ...]'
echo ''
echo 'Not available <cmd-name> (because module was not built-in):'
echo ' mdate [-n] [-z] [-s] [-d] [-f<str>] [-o<spec>] <path>'
echo ' table [-F<sep>] [-w<width>] [-c<cols>] [-s<strip>] <str><sep><str>...'
echo ' prop [-p<str>]'
echo ' move [-v] [-t] [-e] [-p] <src-file> <dst-file>'
echo ' mkln [-t] [-f] [-s] <src-path> [<src-path> ...] <dst-path>'
echo ' mkshadow [-v] [-t] [-a] <src-dir> <dst-dir>'
echo ' fixperm [-v] [-t] <path> [<path> ...]'
echo ' tarball [-t] [-v] [-o <tarball>] [-c <prog>] [-d <dir>] [-u'
echo ' <user>] [-g <group>] [-e <pattern>] <path> [<path> ...]'
echo ' guessos '
echo ' arx [-t] [-C<cmd>] <op> <archive> [<file> ...]'
echo ' slo [-p<str>] -- -L<dir> -l<lib> [-L<dir> -l<lib> ...]'
echo ' scpp [-v] [-p] [-f<filter>] [-o<ofile>] [-t<tfile>] [-M<mark>]'
echo ' [-D<dname>] [-C<cname>] <file> [<file> ...]'
echo ' version [-l<lang>] [-n<name>] [-p<prefix>] [-s<version>] [-i<knob>]'
echo ' [-d<type>] <file>'
echo ' path [-s] [-r] [-d] [-b] [-m] [-p<path>] <str> [<str> ...]'
echo ''
exit 0
fi
if [ ".$1" = ".-v" -o ".$1" = ."--version" ]; then
echo "GNU shtool 1.4.9 (16-Apr-2000)"
exit 0
fi
if [ ".$1" = ".-d" -o ".$1" = ."--debug" ]; then
shift
set -x
fi
name=`echo "$0" | sed -e 's;.*/\([^/]*\)$;\1;' -e 's;-sh$;;' -e 's;\.sh$;;'`
case "$name" in
echo|install|mkdir )
# implicit tool command selection
tool="$name"
;;
* )
# explicit tool command selection
tool="$1"
shift
;;
esac
arg_spec=""
opt_spec=""
gen_tmpfile=no
##
## DISPATCH INTO SCRIPT PROLOG
##
case $tool in
echo )
str_tool="echo"
str_usage="[-n] [-e] [<str> ...]"
arg_spec="0+"
opt_spec="n.e."
opt_n=no
opt_e=no
;;
install )
str_tool="install"
str_usage="[-v] [-t] [-c] [-C] [-s] [-m<mode>] [-o<owner>] [-g<group>] [-e<ext>] <file> <path>"
arg_spec="2="
opt_spec="v.t.c.C.s.m:o:g:e:"
opt_v=no
opt_t=no
opt_c=no
opt_C=no
opt_s=no
opt_m=""
opt_o=""
opt_g=""
opt_e=""
;;
mkdir )
str_tool="mkdir"
str_usage="[-t] [-f] [-p] [-m<mode>] <dir> [<dir> ...]"
arg_spec="1+"
opt_spec="t.f.p.m:"
opt_t=no
opt_f=no
opt_p=no
opt_m=""
;;
-* )
echo "$0:Error: unknown option \`$tool'" 2>&1
echo "$0:Hint: run \`$0 -h' for usage" 2>&1
exit 1
;;
* )
echo "$0:Error: unknown command \`$tool'" 2>&1
echo "$0:Hint: run \`$0 -h' for usage" 2>&1
exit 1
;;
esac
##
## COMMON UTILITY CODE
##
# determine name of tool
if [ ".$tool" != . ]; then
# used inside shtool script
toolcmd="$0 $tool"
toolcmdhelp="shtool $tool"
msgprefix="shtool:$tool"
else
# used as standalone script
toolcmd="$0"
toolcmdhelp="sh $0"
msgprefix="$str_tool"
fi
# parse argument specification string
eval `echo $arg_spec |\
sed -e 's/^\([0-9]*\)\([+=]\)/arg_NUMS=\1; arg_MODE=\2/'`
# parse option specification string
eval `echo h.$opt_spec |\
sed -e 's/\([a-zA-Z0-9]\)\([.:+]\)/opt_MODE_\1=\2;/g'`
# interate over argument line
opt_PREV=''
while [ $# -gt 0 ]; do
# special option stops processing
if [ ".$1" = ".--" ]; then
shift
break
fi
# determine option and argument
opt_ARG_OK=no
if [ ".$opt_PREV" != . ]; then
# merge previous seen option with argument
opt_OPT="$opt_PREV"
opt_ARG="$1"
opt_ARG_OK=yes
opt_PREV=''
else
# split argument into option and argument
case "$1" in
-[a-zA-Z0-9]*)
eval `echo "x$1" |\
sed -e 's/^x-\([a-zA-Z0-9]\)/opt_OPT="\1";/' \
-e 's/";\(.*\)$/"; opt_ARG="\1"/'`
;;
-[a-zA-Z0-9])
opt_OPT=`echo "x$1" | cut -c3-`
opt_ARG=''
;;
*)
break
;;
esac
fi
# eat up option
shift
# determine whether option needs an argument
eval "opt_MODE=\$opt_MODE_${opt_OPT}"
if [ ".$opt_ARG" = . -a ".$opt_ARG_OK" != .yes ]; then
if [ ".$opt_MODE" = ".:" -o ".$opt_MODE" = ".+" ]; then
opt_PREV="$opt_OPT"
continue
fi
fi
# process option
case $opt_MODE in
'.' )
# boolean option
eval "opt_${opt_OPT}=yes"
;;
':' )
# option with argument (multiple occurances override)
eval "opt_${opt_OPT}=\"\$opt_ARG\""
;;
'+' )
# option with argument (multiple occurances append)
eval "opt_${opt_OPT}=\"\$opt_${opt_OPT} \$opt_ARG\""
;;
* )
echo "$msgprefix:Error: unknown option: \`-$opt_OPT'" 1>&2
echo "$msgprefix:Hint: run \`$toolcmdhelp -h' or \`man shtool' for details" 1>&2
exit 1
;;
esac
done
if [ ".$opt_PREV" != . ]; then
echo "$msgprefix:Error: missing argument to option \`-$opt_PREV'" 1>&2
echo "$msgprefix:Hint: run \`$toolcmdhelp -h' or \`man shtool' for details" 1>&2
exit 1
fi
# process help option
if [ ".$opt_h" = .yes ]; then
echo "Usage: $toolcmdhelp $str_usage"
exit 0
fi
# complain about incorrect number of arguments
case $arg_MODE in
'=' )
if [ $# -ne $arg_NUMS ]; then
echo "$msgprefix:Error: invalid number of arguments (exactly $arg_NUMS expected)" 1>&2
echo "$msgprefix:Hint: run \`$toolcmd -h' or \`man shtool' for details" 1>&2
exit 1
fi
;;
'+' )
if [ $# -lt $arg_NUMS ]; then
echo "$msgprefix:Error: invalid number of arguments (at least $arg_NUMS expected)" 1>&2
echo "$msgprefix:Hint: run \`$toolcmd -h' or \`man shtool' for details" 1>&2
exit 1
fi
;;
esac
# establish a temporary file on request
if [ ".$gen_tmpfile" = .yes ]; then
if [ ".$TMPDIR" != . ]; then
tmpdir="$TMPDIR"
elif [ ".$TEMPDIR" != . ]; then
tmpdir="$TEMPDIR"
else
tmpdir="/tmp"
fi
tmpfile="$tmpdir/.shtool.$$"
rm -f $tmpfile >/dev/null 2>&1
touch $tmpfile
fi
##
## DISPATCH INTO SCRIPT BODY
##
case $tool in
echo )
##
## echo -- Print string with optional construct expansion
## Copyright (c) 1998-2000 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for WML as buildinfo
##
text="$*"
# check for broken escape sequence expansion
seo=''
bytes=`echo '\1' | wc -c | awk '{ printf("%s", $1); }'`
if [ ".$bytes" != .3 ]; then
bytes=`echo -E '\1' | wc -c | awk '{ printf("%s", $1); }'`
if [ ".$bytes" = .3 ]; then
seo='-E'
fi
fi
# check for existing -n option (to suppress newline)
minusn=''
bytes=`echo -n 123 2>/dev/null | wc -c | awk '{ printf("%s", $1); }'`
if [ ".$bytes" = .3 ]; then
minusn='-n'
fi
# determine terminal bold sequence
term_bold=''
term_norm=''
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[Bb]'`" != . ]; then
case $TERM in
# for the most important terminal types we directly know the sequences
xterm|xterm*|vt220|vt220*)
term_bold=`awk 'BEGIN { printf("%c%c%c%c", 27, 91, 49, 109); }' </dev/null 2>/dev/null`
term_norm=`awk 'BEGIN { printf("%c%c%c", 27, 91, 109); }' </dev/null 2>/dev/null`
;;
vt100|vt100*)
term_bold=`awk 'BEGIN { printf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0); }' </dev/null 2>/dev/null`
term_norm=`awk 'BEGIN { printf("%c%c%c%c%c", 27, 91, 109, 0, 0); }' </dev/null 2>/dev/null`
;;
# for all others, we try to use a possibly existing `tput' or `tcout' utility
* )
paths=`echo $PATH | sed -e 's/:/ /g'`
for tool in tput tcout; do
for dir in $paths; do
if [ -r "$dir/$tool" ]; then
for seq in bold md smso; do # 'smso' is last
bold="`$dir/$tool $seq 2>/dev/null`"
if [ ".$bold" != . ]; then
term_bold="$bold"
break
fi
done
if [ ".$term_bold" != . ]; then
for seq in sgr0 me rmso reset; do # 'reset' is last
norm="`$dir/$tool $seq 2>/dev/null`"
if [ ".$norm" != . ]; then
term_norm="$norm"
break
fi
done
fi
break
fi
done
if [ ".$term_bold" != . -a ".$term_norm" != . ]; then
break;
fi
done
;;
esac
if [ ".$term_bold" = . -o ".$term_norm" = . ]; then
echo "$msgprefix:Warning: unable to determine terminal sequence for bold mode" 1>&2
fi
fi
# determine user name
username=''
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[uU]'`" != . ]; then
username="$LOGNAME"
if [ ".$username" = . ]; then
username="$USER"
if [ ".$username" = . ]; then
username="`(whoami) 2>/dev/null |\
awk '{ printf("%s", $1); }'`"
if [ ".$username" = . ]; then
username="`(who am i) 2>/dev/null |\
awk '{ printf("%s", $1); }'`"
if [ ".$username" = . ]; then
username='unknown'
fi
fi
fi
fi
fi
# determine user id
userid=''
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%U'`" != . ]; then
userid="`(id -u) 2>/dev/null`"
if [ ".$userid" = . ]; then
str="`(id) 2>/dev/null`"
if [ ".`echo $str | grep '^uid[ ]*=[ ]*[0-9]*('`" != . ]; then
userid=`echo $str | sed -e 's/^uid[ ]*=[ ]*//' -e 's/(.*//'`
fi
if [ ".$userid" = . ]; then
userid=`egrep "^${username}:" /etc/passwd 2>/dev/null | \
sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
if [ ".$userid" = . ]; then
userid=`(ypcat passwd) 2>/dev/null |
egrep "^${username}:" | \
sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
if [ ".$userid" = . ]; then
userid='?'
fi
fi
fi
fi
fi
# determine host name
hostname=''
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%h'`" != . ]; then
hostname="`(uname -n) 2>/dev/null |\
awk '{ printf("%s", $1); }'`"
if [ ".$hostname" = . ]; then
hostname="`(hostname) 2>/dev/null |\
awk '{ printf("%s", $1); }'`"
if [ ".$hostname" = . ]; then
hostname='unknown'
fi
fi
case $hostname in
*.* )
domainname=".`echo $hostname | cut -d. -f2-`"
hostname="`echo $hostname | cut -d. -f1`"
;;
esac
fi
# determine domain name
domainname=''
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%d'`" != . ]; then
if [ ".$domainname" = . ]; then
if [ -f /etc/resolv.conf ]; then
domainname="`egrep '^[ ]*domain' /etc/resolv.conf | head -1 |\
sed -e 's/.*domain//' \
-e 's/^[ ]*//' -e 's/^ *//' -e 's/^ *//' \
-e 's/^\.//' -e 's/^/./' |\
awk '{ printf("%s", $1); }'`"
if [ ".$domainname" = . ]; then
domainname="`egrep '^[ ]*search' /etc/resolv.conf | head -1 |\
sed -e 's/.*search//' \
-e 's/^[ ]*//' -e 's/^ *//' -e 's/^ *//' \
-e 's/ .*//' -e 's/ .*//' \
-e 's/^\.//' -e 's/^/./' |\
awk '{ printf("%s", $1); }'`"
fi
fi
fi
fi
# determine current time
time_day=''
time_month=''
time_year=''
time_monthname=''
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[DMYm]'`" != . ]; then
time_day=`date '+%d'`
time_month=`date '+%m'`
time_year=`date '+%Y' 2>/dev/null`
if [ ".$time_year" = . ]; then
time_year=`date '+%y'`
case $time_year in
[5-9][0-9]) time_year="19$time_year" ;;
[0-4][0-9]) time_year="20$time_year" ;;
esac
fi
case $time_month in
1|01) time_monthname='Jan' ;;
2|02) time_monthname='Feb' ;;
3|03) time_monthname='Mar' ;;
4|04) time_monthname='Apr' ;;
5|05) time_monthname='May' ;;
6|06) time_monthname='Jun' ;;
7|07) time_monthname='Jul' ;;
8|08) time_monthname='Aug' ;;
9|09) time_monthname='Sep' ;;
10) time_monthname='Oct' ;;
11) time_monthname='Nov' ;;
12) time_monthname='Dec' ;;
esac
fi
# expand special ``%x'' constructs
if [ ".$opt_e" = .yes ]; then
text=`echo $seo "$text" |\
sed -e "s/%B/${term_bold}/g" \
-e "s/%b/${term_norm}/g" \
-e "s/%u/${username}/g" \
-e "s/%U/${userid}/g" \
-e "s/%h/${hostname}/g" \
-e "s/%d/${domainname}/g" \
-e "s/%D/${time_day}/g" \
-e "s/%M/${time_month}/g" \
-e "s/%Y/${time_year}/g" \
-e "s/%m/${time_monthname}/g" 2>/dev/null`
fi
# create output
if [ .$opt_n = .no ]; then
echo $seo "$text"
else
# the harder part: echo -n is best, because
# awk may complain about some \xx sequences.
if [ ".$minusn" != . ]; then
echo $seo $minusn "$text"
else
echo dummy | awk '{ printf("%s", TEXT); }' TEXT="$text"
fi
fi
;;
install )
##
## install -- Install a program, script or datafile
## Copyright (c) 1997-2000 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for shtool
##
src="$1"
dst="$2"
# If destination is a directory, append the input filename
if [ -d $dst ]; then
dst=`echo "$dst" | sed -e 's:/$::'`
dstfile=`echo "$src" | sed -e 's;.*/\([^/]*\)$;\1;'`
dst="$dst/$dstfile"
fi
# Add a possible extension to src and dst
if [ ".$opt_e" != . ]; then
src="$src$opt_e"
dst="$dst$opt_e"
fi
# Check for correct arguments
if [ ".$src" = ".$dst" ]; then
echo "$msgprefix:Error: source and destination are the same" 1>&2
exit 1
fi
# Make a temp file name in the destination directory
dstdir=`echo $dst | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;' -e 's;^$;.;'`
dsttmp="$dstdir/#INST@$$#"
# Verbosity
if [ ".$opt_v" = .yes ]; then
echo "$src -> $dst" 1>&2
fi
# Copy or move the file name to the temp name
# (because we might be not allowed to change the source)
if [ ".$opt_C" = .yes ]; then
opt_c=yes
fi
if [ ".$opt_c" = .yes ]; then
if [ ".$opt_t" = .yes ]; then
echo "cp $src $dsttmp" 1>&2
fi
cp $src $dsttmp || exit $?
else
if [ ".$opt_t" = .yes ]; then
echo "mv $src $dsttmp" 1>&2
fi
mv $src $dsttmp || exit $?
fi
# Adjust the target file
# (we do chmod last to preserve setuid bits)
if [ ".$opt_s" = .yes ]; then
if [ ".$opt_t" = .yes ]; then
echo "strip $dsttmp" 1>&2
fi
strip $dsttmp || exit $?
fi
if [ ".$opt_o" != . ]; then
if [ ".$opt_t" = .yes ]; then
echo "chown $opt_o $dsttmp" 1>&2
fi
chown $opt_o $dsttmp || exit $?
fi
if [ ".$opt_g" != . ]; then
if [ ".$opt_t" = .yes ]; then
echo "chgrp $opt_g $dsttmp" 1>&2
fi
chgrp $opt_g $dsttmp || exit $?
fi
if [ ".$opt_m" != . ]; then
if [ ".$opt_t" = .yes ]; then
echo "chmod $opt_m $dsttmp" 1>&2
fi
chmod $opt_m $dsttmp || exit $?
fi
# Determine whether to do a quick install
# (has to be done _after_ the strip was already done)
quick=no
if [ ".$opt_C" = .yes ]; then
if [ -r $dst ]; then
if cmp -s $src $dst; then
quick=yes
fi
fi
fi
# Finally install the file to the real destination
if [ $quick = yes ]; then
if [ ".$opt_t" = .yes ]; then
echo "rm -f $dsttmp" 1>&2
fi
rm -f $dsttmp
else
if [ ".$opt_t" = .yes ]; then
echo "rm -f $dst && mv $dsttmp $dst" 1>&2
fi
rm -f $dst && mv $dsttmp $dst
fi
;;
mkdir )
##
## mkdir -- Make one or more directories
## Copyright (c) 1996-2000 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for public domain by Noah Friedman <friedman@prep.ai.mit.edu>
## Cleaned up and enhanced for shtool
##
errstatus=0
for p in ${1+"$@"}; do
# if the directory already exists...
if [ -d "$p" ]; then
if [ ".$opt_f" = .no ] && [ ".$opt_p" = .no ]; then
echo "$msgprefix:Error: directory already exists: $p" 1>&2
errstatus=1
break
else
continue
fi
fi
# if the directory has to be created...
if [ ".$opt_p" = .no ]; then
if [ ".$opt_t" = .yes ]; then
echo "mkdir $p" 1>&2
fi
mkdir $p || errstatus=$?
else
# the smart situation
set fnord `echo ":$p" |\
sed -e 's/^:\//%/' \
-e 's/^://' \
-e 's/\// /g' \
-e 's/^%/\//'`
shift
pathcomp=''
for d in ${1+"$@"}; do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp="./$pathcomp" ;;
esac
if [ ! -d "$pathcomp" ]; then
if [ ".$opt_t" = .yes ]; then
echo "mkdir $pathcomp" 1>&2
fi
mkdir $pathcomp || errstatus=$?
if [ ".$opt_m" != . ]; then
if [ ".$opt_t" = .yes ]; then
echo "chmod $opt_m $pathcomp" 1>&2
fi
chmod $opt_m $pathcomp || errstatus=$?
fi
fi
pathcomp="$pathcomp/"
done
fi
done
exit $errstatus
;;
esac
exit 0
##EOF##
-29
View File
@@ -1,29 +0,0 @@
#!/bin/sh
# $Id$
supplied_flag=$1
if test "$supplied_flag" = "--copy"; then
automake_flags=--copy
fi
## build.mk does not check aclocal exit status yet
##
#mv aclocal.m4 aclocal.m4.old 2>/dev/null
#aclocal
#if test "$?" != "0" -a "$am_prefix" != "$lt_prefix"; then
# echo "buildconf: ERROR: aclocal failed, probably because automake and"
# echo " libtool are installed with different prefixes;"
# echo " automake is installed in $am_prefix, but libtool in $lt_prefix."
# echo " Please re-install automake and/or libtool with a common prefix"
# echo " and try again."
# exit 1
#fi
if test "$supplied_flag" = "--local"; then
subdirs='SUBDIRS='
else
subdirs=''
fi
${MAKE:-make} -s -f build/build.mk AMFLAGS="$automake_flags"
-1121
View File
File diff suppressed because it is too large. Load diff
Vendored
-1232
View File
File diff suppressed because it is too large. Load diff
-896
View File
@@ -1,896 +0,0 @@
dnl ## $Id$ -*- sh -*-
dnl ## Process this file with autoconf to produce a configure script.
divert(1)
AC_INIT(main.c)
PHP_FAST_OUTPUT(sapi/Makefile ext/Makefile Makefile pear/Makefile)
if test "$with_shared_apache" != "no" && test -n "$with_shared_apache" ; then
AC_MSG_ERROR(--with-shared-apache is not supported. Please refer to the documentation for using APXS)
fi
if test -n "$with_apache" && test -n "$with_apxs"; then
AC_MSG_ERROR(--with-apache and --with-apxs cannot be used together)
fi
cwd=`pwd`
PHP_CONFIG_NICE(config.nice)
for arg in $0 "$@"; do
CONFIGURE_COMMAND="$CONFIGURE_COMMAND '$arg'"
done
php_shtool="$srcdir/build/shtool"
T_MD=`$php_shtool echo -n -e %B`
T_ME=`$php_shtool echo -n -e %b`
dnl Because ``make install'' is often performed by the superuser,
dnl we create the libs subdirectory as the user who configures PHP.
dnl Otherwise, the current user will not be able to delete libs
dnl or the contents of libs.
$php_shtool mkdir -p libs
rm -f libs/*
dnl ## Diversion 2 is the initial checking of OS features, programs,
dnl ## libraries and so on.
dnl ## In diversion 3 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 4 we check which extensions should be compiled.
dnl ## All of these are normally in the extension directories.
dnl ## Diversion 5 is the last one. Here we generate files and clean up.
dnl ## This is where the version number is changed from now on!
AM_INIT_AUTOMAKE(php, 4.0.1-dev)
PHP_VERSION=$VERSION
echo "/* automatically generated by configure */" > php_version.h.new
echo "/* edit configure.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
AM_CONFIG_HEADER(php_config.h)
AM_MAINTAINER_MODE
AC_CANONICAL_HOST
dnl We want this one before the checks, so the checks can modify CFLAGS.
test -z "$CFLAGS" && auto_cflags=1
dnl Checks for programs.
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
AC_PROG_CC
AC_AIX
case "$host_alias" in
*dgux*)
CPPFLAGS="$CPPFLAGS -D_BSD_TIMEOFDAY_FLAVOR";;
*rhapsody*)
CPPFLAGS="$CPPFLAGS -traditional-cpp";;
esac
AM_PROG_CC_STDC
AC_PROG_RANLIB
AC_PROG_CC_C_O
AC_PROG_LN_S
AM_PROG_LEX
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
sinclude(Zend/acinclude.m4)
sinclude(Zend/Zend.m4)
sinclude(TSRM/tsrm.m4)
divert(2)
PTHREADS_CHECK
PHP_SHLIB_SUFFIX_NAME
PHP_SAPI=cgi
PHP_BUILD_PROGRAM
dnl paths to the targets relative to the build directory
SAPI_PROGRAM=php
SAPI_SHARED=libs/libphp4.$SHLIB_SUFFIX_NAME
SAPI_STATIC=libs/libphp4.a
PHP_CONFIGURE_PART(Configuring SAPI modules)
esyscmd(./scripts/config-stubs sapi)
AC_MSG_CHECKING(for chosen SAPI module)
AC_MSG_RESULT($PHP_SAPI)
if test "$enable_experimental_zts" = "yes"; then
PTHREADS_ASSIGN_VARS
PTHREADS_FLAGS
fi
divert(3)
PHP_CONFIGURE_PART(Running system checks)
PHP_MISSING_TIME_R_DECL
dnl check for -R, etc. switch
AC_MSG_CHECKING(whether 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"
else
AC_MSG_CHECKING([whether 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,"
else
dnl something innocuous
ld_runpath_switch="-L"
fi
fi
PHP_PROG_SENDMAIL
dnl Check whether the system uses EBCDIC (not ASCII) as its native codeset
PHP_EBCDIC
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
CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
LDFLAGS="$LDFLAGS -L/usr/pkg/lib"
fi
INCLUDES="$INCLUDES -I\$(top_builddir)/Zend -I\$(top_srcdir)"
AC_CHECK_LIB(socket, socket, [
AC_ADD_LIBRARY(socket)
AC_DEFINE(HAVE_LIBSOCKET,1,[ ]) ], [
AC_CHECK_LIB(socket, htonl, [
AC_ADD_LIBRARY(socket)
])])
dnl Some systems (OpenServer 5) dislike -lsocket -lnsl, so we try
dnl to avoid -lnsl checks, if we already have the functions which
dnl are usually in libnsl
unset ac_cv_func_yp_get_default_domain
AC_CHECK_FUNC(yp_get_default_domain,
[php_no_nsl_checks=yes],[ ])
unset ac_cv_func_yp_get_default_domain
if test "$php_no_nsl_checks" != "yes"; then
AC_CHECK_LIB(nsl, gethostname, [
AC_ADD_LIBRARY(nsl)
AC_DEFINE(HAVE_LIBNSL,1,[ ]) ],[
AC_CHECK_LIB(nsl, gethostbyaddr, [
AC_ADD_LIBRARY(nsl)
AC_DEFINE(HAVE_LIBNSL,1,[ ]) ], [])
])
fi
AC_CHECK_LIB(crypt, crypt, [
AC_ADD_LIBRARY(crypt)
AC_DEFINE(HAVE_LIBCRYPT,1,[ ]) ], [])
AC_CHECK_LIB(dl, dlopen,[AC_ADD_LIBRARY(dl)])
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(m, sin)
AC_CHECK_LIB(bind, inet_aton, [
AC_ADD_LIBRARY(bind)
AC_DEFINE(HAVE_LIBBIND,1,[Whether you have bind]) ], [])
AC_CHECK_LIB(resolv, inet_aton)
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,1,[ ]) ], [
AC_CHECK_LIB(resolv, res_search, [
LIBS="$LIBS -lresolv"
AC_DEFINE(HAVE_LIBRESOLV,1,[ ])
], [
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 \
ieeefp.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 \
sys/resource.h \
syslog.h \
unistd.h \
unix.h \
)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_STRUCT_TM
AC_STRUCT_TIMEZONE
PHP_TM_GMTOFF
PHP_STRUCT_FLOCK
PHP_SOCKLEN_T
AC_CHECK_SIZEOF(long, 8)
AC_CHECK_SIZEOF(int, 4)
test -d /usr/ucblib && AC_ADD_LIBPATH(/usr/ucblib)
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
fi
AC_STRUCT_ST_RDEV
dnl Checks for types
AC_TYPE_SIZE_T
AC_TYPE_UID_T
dnl Checks for library functions.
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(
asctime_r \
crypt \
ctime_r \
cuserid \
flock \
gcvt \
getlogin \
gethostbyaddr \
getrusage \
gettimeofday \
gmtime_r \
inet_aton \
link \
localtime_r \
lockf \
lrand48 \
memcpy \
memmove \
mmap \
putenv \
random \
rand_r \
regcomp \
setitimer \
setlocale \
setsockopt \
setvbuf \
shutdown \
sin \
snprintf \
srand48 \
srandom \
statfs \
statvfs \
strcasecmp \
strdup \
strerror \
strftime \
strstr \
strtok_r \
symlink \
tempnam \
tzset \
unsetenv \
usleep \
utime \
vsnprintf \
)
AC_REPLACE_FUNCS(strlcat strlcpy getopt)
AC_FUNC_UTIME_NULL
AC_FUNC_ALLOCA
AC_BROKEN_SPRINTF
PHP_DECLARED_TIMEZONE
PHP_TIME_R_TYPE
PHP_READDIR_R_TYPE
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(4)
abs_srcdir=`(cd $srcdir; pwd)`
abs_builddir=`pwd`
PHP_ARG_WITH(config-file-path,whether to use a configuration file,
[ --with-config-file-path=PATH
Sets the path in which to look for php.ini.
defaults to /usr/local/lib], yes)
if test "$PHP_CONFIG_FILE_PATH" = "yes"; then
PHP_CONFIG_FILE_PATH="/usr/local/lib"
fi
if test "$PHP_CONFIG_FILE_PATH" != "no"; then
AC_DEFINE_UNQUOTED(CONFIGURATION_FILE_PATH, "$PHP_CONFIG_FILE_PATH",[ ])
AC_DEFINE(USE_CONFIG_FILE, 1, [ ])
else
AC_DEFINE(CONFIGURATION_FILE_PATH, 0, [ ])
AC_DEFINE(USE_CONFIG_FILE, 0, [ ])
fi
PHP_ARG_ENABLE(debug, whether to include debugging symbols,
[ --enable-debug Compile with debugging symbols.], no)
if test "$PHP_DEBUG" = "yes"; then
PHP_DEBUG=1
ZEND_DEBUG=yes
else
PHP_DEBUG=0
ZEND_DEBUG=no
fi
test -n "$DEBUG_CFLAGS" && CFLAGS="$CFLAGS $DEBUG_CFLAGS"
PHP_ARG_ENABLE(safe-mode, whether to enable safe mode by default,
[ --enable-safe-mode Enable safe mode by default.])
if test "$PHP_SAFE_MODE" = "yes"; then
AC_DEFINE(PHP_SAFE_MODE,1,[ ])
else
AC_DEFINE(PHP_SAFE_MODE,0,[ ])
fi
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)
])
PHP_ARG_ENABLE(sigchild,whether to enable PHP's own SIGCHLD handler,
[ --enable-sigchild Enable PHP's own SIGCHLD handler.],no)
if test "$PHP_SIGCHILD" = "yes"; then
AC_DEFINE(PHP_SIGCHILD, 1, [ ])
else
AC_DEFINE(PHP_SIGCHILD, 0, [ ])
fi
PHP_ARG_ENABLE(track-vars,whether to enable track_vars variables by default,
[ --enable-track-vars Enable GET/POST/Cookie track variables by default.],yes)
if test "$PHP_TRACK_VARS" = "yes"; then
AC_DEFINE(PHP_TRACK_VARS, 1, [ ])
else
AC_DEFINE(PHP_TRACK_VARS, 0, [ ])
fi
PHP_ARG_ENABLE(magic-quotes,whether to enable magic quotes by default,
[ --enable-magic-quotes Enable magic quotes by default.])
if test "$PHP_MAGIC_QUOTES" = "yes"; then
AC_DEFINE(MAGIC_QUOTES, 1, [ ])
else
AC_DEFINE(MAGIC_QUOTES, 0, [ ])
fi
PHP_ARG_ENABLE(rpath, whether to enable runpaths,
[ --disable-rpath Disable passing additional runtime library
search paths], yes)
PHP_ARG_ENABLE(libgcc, whether to explicitly link against libgcc,
[ --enable-libgcc Enable explicitly linking against libgcc])
if test "$PHP_LIBGCC" = "yes"; then
PHP_LIBGCC_LIBPATH(gcc)
if test -z "$libgcc_libpath"; then
AC_MSG_ERROR(Cannot locate libgcc. Make sure that gcc is in your path)
fi
AC_ADD_LIBPATH($libgcc_libpath)
AC_ADD_LIBRARY(gcc, yes)
fi
PHP_ARG_ENABLE(short-tags,whether to enable short tags by default,
[ --disable-short-tags Disable the short-form <? start tag by default.],yes)
if test "$PHP_SHORT_TAGS" = "yes"; then
AC_DEFINE(DEFAULT_SHORT_OPEN_TAG,1,[ ])
else
AC_DEFINE(DEFAULT_SHORT_OPEN_TAG,0,[ ])
fi
PHP_ARG_ENABLE(url-fopen-wrapper,whether to enable the URL-aware fopen wrapper,
[ --disable-url-fopen-wrapper
Disable the URL-aware fopen wrapper that allows
accessing files via http or ftp.], yes)
if test "$PHP_URL_FOPEN_WRAPPER" = "yes"; then
AC_DEFINE(PHP_URL_FOPEN, 1, [ ])
else
AC_DEFINE(PHP_URL_FOPEN, 0, [ ])
fi
PHP_ARG_ENABLE(pic,whether to enable PIC for shared objects,
[ --disable-pic Disable PIC for shared objects], yes)
PHP_ARG_ENABLE(dmalloc,whether to enable dmalloc,
[ --enable-dmalloc Enable dmalloc])
if test "$PHP_DMALLOC" = "yes"; then
AC_DEFINE(HAVE_DMALLOC,1,[Whether you have dmalloc])
AC_ADD_LIBRARY(dmalloc)
CPPFLAGS="$CPPFLAGS -DDMALLOC_FUNC_CHECK"
fi
PHP_ARG_ENABLE(pear,whether to install PEAR,
[ --disable-pear Do not install PEAR],yes)
if test "$PHP_PEAR" = "yes"; then
PEAR_DIR=pear
fi
divert(5)
PHP_CONFIGURE_PART(Configuring extensions)
# reading config stubs
esyscmd(./scripts/config-stubs ext)
PHP_FAST_OUTPUT(sapi/$PHP_SAPI/Makefile)
AC_MSG_CHECKING(whether to enable versioning)
AC_ARG_ENABLE(versioning,
[ --enable-versioning Export only required symbols.
See INSTALL for more information],[
PHP_VERSIONING=$enableval
],[
PHP_VERSIONING=no
])
AC_MSG_RESULT($PHP_VERSIONING)
if test "$PHP_VERSIONING" = "yes"; then
test -z "$PHP_SYM_FILE" && PHP_SYM_FILE="$abs_srcdir/sapi/$PHP_SAPI/php.sym"
if test -f "$PHP_SYM_FILE"; then
EXTRA_LDFLAGS="-export-symbols $PHP_SYM_FILE"
fi
fi
divert(6)
enable_shared=yes
enable_static=yes
case "$php_build_target" in
program)
enable_shared=no
;;
shared)
enable_static=no
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -avoid-version"
;;
static)
enable_shared=no
;;
esac
if test "$PHP_SAPI" = "cgi"; then
PHP_PROGRAM=php
fi
PHP_REGEX
PHP_CONFIGURE_PART(Configuring Zend)
LIBZEND_BASIC_CHECKS
LIBZEND_OTHER_CHECKS
if test "$ZEND_EXPERIMENTAL_ZTS" = "yes"; then
TSRM_LIB='TSRM/libtsrm.la'
TSRM_DIR=TSRM
AC_DEFINE(ZTS,1,[ ])
INCLUDES="$INCLUDES -I\$(top_builddir)/TSRM"
PHP_THREAD_SAFETY=yes
else
PHP_THREAD_SAFETY=no
fi
if test "$abs_srcdir" != "$abs_builddir"; then
INCLUDES="$INCLUDES -I\$(top_srcdir)/Zend"
if test "$PHP_THREAD_SAFETY" = "yes"; then
INCLUDES="$INCLUDES -I\$(top_srcdir)/TSRM"
fi
fi
EXTRA_LIBS="$EXTRA_LIBS $DLIBS $LIBS"
LIBS=""
LDFLAGS=""
if test "$PHP_THREAD_SAFETY" = "yes"; then
PHP_CONFIGURE_PART(Configuring TSRM)
TSRM_BASIC_CHECKS
TSRM_OTHER_CHECKS
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LDFLAGS"
EXTRA_LIBS="$EXTRA_LIBS $LIBS"
LDFLAGS=""
LIBS=""
PHP_OUTPUT(TSRM/Makefile)
fi
phplibdir="`pwd`/modules"
$php_shtool mkdir -p $phplibdir
phptempdir="`pwd`/libs"
test "$prefix" = "NONE" && prefix="/usr/local"
test "$exec_prefix" = "NONE" && exec_prefix='$(prefix)'
dnl Build extension directory path
if test "$PHP_DEBUG" = "1"; then
PART1=debug
else
PART1=no-debug
fi
if test "$enable_experimental_zts" = "yes"; then
PART2=zts
else
PART2=non-zts
fi
ZEND_MODULE_API_NO=`egrep '#define ZEND_MODULE_API_NO ' $srcdir/Zend/modules.h|sed 's/#define ZEND_MODULE_API_NO //'`
EXTENSION_DIR="$prefix/lib/php/extensions/$PART1-$PART2-$ZEND_MODULE_API_NO"
AC_BUILD_RPATH
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PHP_LDFLAGS"
PHP_BUILD_DATE=`date '+%Y-%m-%d'`
AC_DEFINE_UNQUOTED(PHP_BUILD_DATE,"$PHP_BUILD_DATE",[PHP build date])
PHP_UNAME=`uname -a`
AC_DEFINE_UNQUOTED(PHP_UNAME,"$PHP_UNAME",[uname -a output])
PHP_OS=`uname`
AC_DEFINE_UNQUOTED(PHP_OS,"$PHP_OS",[uname output])
PHP_SUBST(abs_builddir)
PHP_SUBST(abs_srcdir)
PHP_SUBST(bindir)
PHP_SUBST(exec_prefix)
PHP_SUBST(includedir)
PHP_SUBST(libdir)
PHP_SUBST(phplibdir)
PHP_SUBST(phptempdir)
PHP_SUBST(prefix)
PHP_SUBST(CC)
PHP_SUBST(CFLAGS)
PHP_SUBST(CONFIGURE_COMMAND)
PHP_SUBST(CPP)
PHP_SUBST(CPPFLAGS)
PHP_SUBST(CXX)
PHP_SUBST(DEBUG_CFLAGS)
PHP_SUBST(DEFS)
PHP_SUBST(EXTENSION_DIR)
PHP_SUBST(EXTRA_LDFLAGS)
PHP_SUBST(EXTRA_LIBS)
PHP_SUBST(INCLUDES)
PHP_SUBST(INSTALL_IT)
PHP_SUBST(LEX)
PHP_SUBST(LEX_OUTPUT_ROOT)
PHP_SUBST(LFLAGS)
PHP_SUBST(LIBTOOL)
PHP_SUBST(LN_S)
PHP_SUBST(NATIVE_RPATHS)
PHP_SUBST(PEAR_DIR)
PHP_SUBST(PHP_BUILD_DATE)
PHP_SUBST(PHP_COMPILE)
PHP_SUBST(PHP_LDFLAGS)
PHP_SUBST(PHP_LIBS)
PHP_SUBST(PHP_PROGRAM)
PHP_SUBST(PHP_RPATHS)
PHP_SUBST(PHP_SAPI)
PHP_SUBST(PHP_VERSION)
PHP_SUBST(PROG_SENDMAIL)
PHP_SUBST(SHELL)
PHP_SUBST(SHARED_LIBTOOL)
PHP_SUBST(TSRM_DIR)
PHP_SUBST(TSRM_LIB)
PHP_SUBST(WARNING_LEVEL)
PHP_SUBST(YACC)
PHP_CONFIGURE_PART(Configuring libtool)
old_CC="$CC"
if test "$PHP_THREAD_SAFETY" = "yes" && test -n "$ac_cv_pthreads_cflags"; then
CXXFLAGS="$CXXFLAGS $ac_cv_pthreads_cflags"
INLINE_CFLAGS="$INLINE_CFLAGS $ac_cv_pthreads_cflags"
cat >meta_ccld<<EOF
#! /bin/sh
exec $CC $ac_cv_pthreads_cflags \$@
EOF
CC="$abs_builddir/meta_ccld"
chmod +x meta_ccld
fi
dnl This will go away, if we have a facility to run per-extension code
dnl after the thread_safety decision was done
if test "$PHP_THREAD_SAFETY" = "yes" && test "$PHP_MYSQL" = "yes"; then
CPPFLAGS="$CPPFLAGS -DTHREAD=1"
fi
AM_PROG_LIBTOOL
if test "$enable_debug" != "yes"; then
AM_SET_LIBTOOL_VARIABLE([--silent])
fi
PHP_COMPILE='$(LIBTOOL) --mode=compile $(COMPILE) -c $<'
if test "$enable_shared" = "yes"; then
SHARED_LIBTOOL='$(LIBTOOL)'
else
if test "$lib_build_shared" = "yes"; then
PHP_CONFIGURE_PART(Configuring shared libtool)
$SHELL $srcdir/ltconfig --output=shlibtool --disable-static --srcdir=$srcdir --cache-file=./config.cache $srcdir/ltmain.sh
SHARED_LIBTOOL='$(SHELL) $(top_builddir)/shlibtool'
else
PHP_COMPILE='$(COMPILE) -c $< && touch $@'
fi
fi
CC="$old_CC"
changequote({,})
if test "$PHP_PIC" = "no"; then
cat >meta_cc<<EOF
#! /bin/sh
cmd="$CC \`echo \$@|sed s/-[fFD]PIC//g\`"
exec \$cmd
EOF
chmod +x meta_cc
CC="$abs_builddir/meta_cc"
fi
changequote([,])
PHP_CONFIGURE_PART(Generating files)
PHP_FAST_GENERATE
touch .deps
#libphp4.module
AC_OUTPUT([php4.spec Zend/Makefile
build-defs.h
$PHP_OUTPUT_FILES
], [], [
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
################################################################
# Create configuration headers
#
if test -d TSRM; then
echo '#include "../php_config.h"' > TSRM/tsrm_config.h
fi
cat >Zend/zend_config.h <<FEO
#include "../php_config.h"
#if defined(APACHE) && defined(PHP_API_VERSION)
#undef HAVE_DLFCN_H
#endif
FEO
# run this only when generating all the files?
if true; then
# 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 "$EXTRA_MODULE_PTRS" \$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
if test -n "$PHP_APXS_BROKEN"; then
echo "+--------------------------------------------------------------------+"
echo "| WARNING: Your $APXS script is most likely broken."
echo "| |"
echo "| Please go read http://www.php.net/FAQ.php3#6.11 and make the |"
echo "| changes described there and try again. |"
fi
# Warn about CGI version with no extra security options.
if test "$PHP_SAPI" = "cgi"; 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
if test -n "$DEBUG_LOG"; then
rm -f config.cache
cat <<X
+--------------------------------------------------------------------+
| ATTENTION! |
| Something is likely to be screwed up here, because the configure |
| script was not able to detect a simple feature on your platform. |
| This is often caused by incorrect configuration parameters. Please |
| see the file debug.log for error messages. |
| |
| If you are unable to fix this, send the file debug.log to the |
| php-install@lists.php.net mailing list and include appropiate |
| information about your setup. |
X
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 "+--------------------------------------------------------------------+"
cat<<X
Thank you for using PHP.
X
fi
])
dnl ## Local Variables:
dnl ## tab-width: 4
dnl ## End:
-3
View File
@@ -1,3 +0,0 @@
#! /bin/sh
${MAKE:-make} -f build/build.mk cvsclean
-64
View File
@@ -1,64 +0,0 @@
AC_DEFUN(LIB_SHARED_CONVENIENCE,[
lib_target="\$(LTLIBRARY_NAME)"
cat >>$1<<EOF
\$(LTLIBRARY_NAME): \$(LTLIBRARY_SHARED_OBJECTS) \$(LTLIBRARY_DEPENDENCIES)
\$(SHARED_LIBTOOL) --mode=link \$(CCLD) \$(CFLAGS) \$(EXTRA_CFLAGS) \$(LDFLAGS) -o \[$]@ \$(LTLIBRARY_LDFLAGS) \$(LTLIBRARY_OBJECTS) \$(LTLIBRARY_SHARED_LIBADD)
EOF
])
AC_DEFUN(LIB_SHARED_MODULE,[
lib_target="\$(LTLIBRARY_SHARED_NAME)"
cat >>$1<<EOF
\$(LTLIBRARY_SHARED_NAME): \$(LTLIBRARY_SHARED_OBJECTS) \$(LTLIBRARY_DEPENDENCIES)
\$(SHARED_LIBTOOL) --mode=link \$(CCLD) \$(CFLAGS) \$(EXTRA_CFLAGS) \$(LDFLAGS) -o \[$]@ -avoid-version -module -rpath \$(phplibdir) \$(LTLIBRARY_LDFLAGS) \$(LTLIBRARY_OBJECTS) \$(LTLIBRARY_SHARED_LIBADD)
\$(SHARED_LIBTOOL) --mode=install cp \[$]@ \$(phplibdir)
EOF
])
AC_DEFUN(LIB_STATIC_CONVENIENCE,[
lib_target="\$(LTLIBRARY_NAME)"
cat >>$1<<EOF
\$(LTLIBRARY_NAME): \$(LTLIBRARY_OBJECTS) \$(LTLIBRARY_DEPENDENCIES)
\$(LINK) \$(LTLIBRARY_LDFLAGS) \$(LTLIBRARY_OBJECTS) \$(LTLIBRARY_LIBADD)
EOF
])
dnl LIB_BUILD(path, shared, convenience)
dnl sets up path to build a shared/static convenience/module
AC_DEFUN(LIB_BUILD,[
lib_makefile="$1/libs.mk"
lib_target=""
$php_shtool mkdir -p $1
cat >$lib_makefile<<EOF
LTLIBRARY_OBJECTS = \$(LTLIBRARY_SOURCES:.c=.lo)
LTLIBRARY_SHARED_OBJECTS = \$(LTLIBRARY_OBJECTS:.lo=.slo)
EOF
if test "$2" = "shared" || test "$2" = "yes"; then
lib_build_shared=yes
if test -n "$3"; then
dnl ---------------------------------------- Shared Convenience
LIB_SHARED_CONVENIENCE($lib_makefile)
else
dnl ---------------------------------------- Shared Module
LIB_SHARED_MODULE($lib_makefile)
fi
else
dnl ---------------------------------------- Static Convenience = Static Module
LIB_STATIC_CONVENIENCE($lib_makefile)
fi
dnl ---------------------------------------- Generate build targets
if test -n "$lib_target"; then
cat >>$lib_makefile<<EOF
targets = $lib_target
EOF
fi
])
-4
View File
@@ -1,4 +0,0 @@
SUBDIRS = $(EXT_SUBDIRS)
include $(top_srcdir)/build/rules.mk
-5
View File
@@ -1,5 +0,0 @@
LTLIBRARY_NAME = libaspell.la
LTLIBRARY_SOURCES = aspell.c
include $(top_srcdir)/build/dynlib.mk
-204
View File
@@ -1,204 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP version 4.0 |
+----------------------------------------------------------------------+
| Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 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_02.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"
#ifdef COMPILE_DL_ASPELL
#include "phpdl.h"
#endif
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#if HAVE_ASPELL
#include "php_aspell.h"
#include <aspell-c.h>
#include "ext/standard/info.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;
zend_module_entry aspell_module_entry = {
"aspell", aspell_functions, PHP_MINIT(aspell), NULL, NULL, NULL, PHP_MINFO(aspell), STANDARD_MODULE_PROPERTIES
};
#ifdef COMPILE_DL_ASPELL
ZEND_GET_MODULE(aspell)
#endif
static void php_aspell_close(aspell *sc)
{
aspell_free(sc);
}
PHP_MINIT_FUNCTION(aspell)
{
le_aspell = register_list_destructors(php_aspell_close,NULL);
return SUCCESS;
}
/* {{{ 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 = ZEND_NUM_ARGS();
if (argc < 1 || argc > 2 || zend_get_parameters_ex(argc,&master,&personal) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(master);
if(argc==2)
{
convert_to_string_ex(personal) ;
sc=aspell_new((*master)->value.str.val,(*personal)->value.str.val);
}
else
sc=aspell_new((*master)->value.str.val,"");
ind = zend_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 = ZEND_NUM_ARGS();
if (argc != 2 || zend_get_parameters_ex(argc, &scin,&word) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(scin);
convert_to_string_ex(word);
sc = (aspell *)zend_list_find((*scin)->value.lval, &type);
if(!sc)
{
php_error(E_WARNING, "%d is not an 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 = ZEND_NUM_ARGS();
if (argc != 2 || zend_get_parameters_ex(argc, &scin,&word) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(scin);
convert_to_string_ex(word);
sc= (aspell *) zend_list_find((*scin)->value.lval, &type);
if(!sc)
{
php_error(E_WARNING, "%d is not an 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 = ZEND_NUM_ARGS();
if (argc != 2 || zend_get_parameters_ex(argc, &scin,&word) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(scin);
convert_to_string_ex(word);
sc = (aspell *)zend_list_find((*scin)->value.lval, &type);
if(!sc)
{
php_error(E_WARNING, "%d is not an 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_info_print_table_start();
php_info_print_table_row(2, "ASpell Support", "enabled");
php_info_print_table_end();
}
#endif
-28
View File
@@ -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,1,[Whether you have aspell])
AC_MSG_RESULT(yes)
PHP_EXTENSION(aspell)
else
AC_MSG_ERROR(no)
fi
],[
AC_MSG_RESULT(no)
])
-53
View File
@@ -1,53 +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 zend_module_entry aspell_module_entry;
#define aspell_module_ptr &aspell_module_entry
extern PHP_MINIT_FUNCTION(aspell);
extern PHP_MINFO_FUNCTION(aspell);
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 */
-6
View File
@@ -1,6 +0,0 @@
LTLIBRARY_NAME = libbcmath.la
LTLIBRARY_SOURCES = bcmath.c number.c
LTLIBRARY_SHARED_NAME = bcmath.la
include $(top_srcdir)/build/dynlib.mk
-434
View File
@@ -1,434 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP version 4.0 |
+----------------------------------------------------------------------+
| Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 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_02.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 "php_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}
};
zend_module_entry bcmath_module_entry = {
"bcmath", bcmath_functions, NULL, NULL, PHP_RINIT(bcmath), PHP_RSHUTDOWN(bcmath), NULL, STANDARD_MODULE_PROPERTIES
};
#ifdef COMPILE_DL_BCMATH
ZEND_GET_MODULE(bcmath)
#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 (ZEND_NUM_ARGS()) {
case 2:
if (zend_get_parameters_ex(2, &left,&right) == FAILURE) {
WRONG_PARAM_COUNT;
}
break;
case 3:
if (zend_get_parameters_ex(3, &left,&right, &scale_param) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(scale_param);
scale = (int) (*scale_param)->value.lval;
break;
default:
WRONG_PARAM_COUNT;
break;
}
convert_to_string_ex(left);
convert_to_string_ex(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 */
PHP_FUNCTION(bcsub)
{
pval **left, **right,**scale_param;
bc_num first, second, result;
int scale=bc_precision;
switch (ZEND_NUM_ARGS()) {
case 2:
if (zend_get_parameters_ex(2, &left,&right) == FAILURE) {
WRONG_PARAM_COUNT;
}
break;
case 3:
if (zend_get_parameters_ex(3, &left,&right, &scale_param) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(scale_param);
scale = (int) (*scale_param)->value.lval;
break;
default:
WRONG_PARAM_COUNT;
break;
}
convert_to_string_ex(left);
convert_to_string_ex(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 (ZEND_NUM_ARGS()) {
case 2:
if (zend_get_parameters_ex(2, &left,&right) == FAILURE) {
WRONG_PARAM_COUNT;
}
break;
case 3:
if (zend_get_parameters_ex(3, &left,&right, &scale_param) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(scale_param);
scale = (int) (*scale_param)->value.lval;
break;
default:
WRONG_PARAM_COUNT;
break;
}
convert_to_string_ex(left);
convert_to_string_ex(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 (ZEND_NUM_ARGS()) {
case 2:
if (zend_get_parameters_ex(2, &left,&right) == FAILURE) {
WRONG_PARAM_COUNT;
}
break;
case 3:
if (zend_get_parameters_ex(3, &left,&right, &scale_param) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(scale_param);
scale = (int) (*scale_param)->value.lval;
break;
default:
WRONG_PARAM_COUNT;
break;
}
convert_to_string_ex(left);
convert_to_string_ex(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 (ZEND_NUM_ARGS()) {
case 2:
if (zend_get_parameters_ex(2, &left,&right) == FAILURE) {
WRONG_PARAM_COUNT;
}
break;
default:
WRONG_PARAM_COUNT;
break;
}
convert_to_string_ex(left);
convert_to_string_ex(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 (ZEND_NUM_ARGS()) {
case 2:
if (zend_get_parameters_ex(2, &left,&right) == FAILURE) {
WRONG_PARAM_COUNT;
}
break;
case 3:
if (zend_get_parameters_ex(3, &left,&right, &scale_param) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(scale_param);
scale = (int) (*scale_param)->value.lval;
break;
default:
WRONG_PARAM_COUNT;
break;
}
convert_to_string_ex(left);
convert_to_string_ex(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 (ZEND_NUM_ARGS()) {
case 1:
if (zend_get_parameters_ex(1, &left)== FAILURE) {
WRONG_PARAM_COUNT;
}
break;
case 2:
if (zend_get_parameters_ex(2, &left,&scale_param) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(scale_param);
scale = (int) (*scale_param)->value.lval;
break;
default:
WRONG_PARAM_COUNT;
break;
}
convert_to_string_ex(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 (ZEND_NUM_ARGS()) {
case 2:
if (zend_get_parameters_ex(2, &left,&right) == FAILURE) {
WRONG_PARAM_COUNT;
}
break;
case 3:
if (zend_get_parameters_ex(3, &left,&right, &scale_param) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(scale_param);
scale = (int) (*scale_param)->value.lval;
break;
default:
WRONG_PARAM_COUNT;
break;
}
convert_to_string_ex(left);
convert_to_string_ex(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 (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1,&new_scale)==FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(new_scale);
bc_precision = (*new_scale)->value.lval;
RETURN_TRUE;
}
/* }}} */
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
*/
-18
View File
@@ -1,18 +0,0 @@
dnl $Id$
PHP_ARG_ENABLE(bcmath,whether to enable bc style precision math functions,
[ --enable-bcmath Compile with bc style precision math functions.
Read README-BCMATH for instructions on how to
get this module installed. ])
if test "$PHP_BCMATH" != "no"; then
AC_DEFINE(WITH_BCMATH, 1, [Whether you have bcmath])
PHP_EXTENSION(bcmath, $ext_shared)
if test ! -f $ext_srcdir/number.c || grep "Dummy File" $ext_srcdir/number.c >/dev/null; then
AC_MSG_ERROR(You do not have the bcmath package. Please read the README.BCMATH file.)
fi
fi
dnl ## Local Variables:
dnl ## tab-width: 4
dnl ## End:
-64
View File
@@ -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 _PHP_BCMATH_H
#define _PHP_BCMATH_H
#if COMPILE_DL
#undef WITH_BCMATH
#define WITH_BCMATH 1
#endif
#if WITH_BCMATH
extern zend_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 /* _PHP_BCMATH_H */
-6
View File
@@ -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.'
-6
View File
@@ -1,6 +0,0 @@
LTLIBRARY_NAME = libcalendar.la
LTLIBRARY_SOURCES = calendar.c dow.c french.c gregor.c jewish.c julian.c easter.c cal_unix.c
LTLIBRARY_SHARED_NAME = calendar.la
include $(top_srcdir)/build/dynlib.mk
-76
View File
@@ -1,76 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP version 4.0 |
+----------------------------------------------------------------------+
| Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 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_02.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: Shane Caraveo <shane@caraveo.com> |
| Colin Viebrock <cmv@easydns.com> |
| Hartmut Holzgraefe <hartmut@six.de> |
+----------------------------------------------------------------------+
*/
/* $Id: */
#include "php.h"
#include "php_calendar.h"
#include "sdncal.h"
#include <time.h>
/* {{{ proto int unixtojd([int timestamp])
Convert UNIX timestamp to Julian Day */
PHP_FUNCTION(unixtojd)
{
pval *timestamp;
long jdate;
time_t t;
struct tm *ta, tmbuf;
int myargc=ZEND_NUM_ARGS();
if ((myargc > 1) || (zend_get_parameters(ht,myargc, &timestamp) != SUCCESS)) {
WRONG_PARAM_COUNT;
}
if(myargc==1) {
convert_to_long(timestamp);
t = timestamp->value.lval;
} else {
t = time(NULL);
}
ta = php_localtime_r(&t, &tmbuf);
jdate = GregorianToSdn(ta->tm_year+1900, ta->tm_mon+1,ta->tm_mday);
RETURN_LONG(jdate);
}
/* }}} */
/* {{{ proto int jdtounix(int jday)
Convert Julian Day to UNIX timestamp */
PHP_FUNCTION(jdtounix)
{
pval *jday;
long uday;
if ((ZEND_NUM_ARGS()!= 1) || (zend_get_parameters(ht,1, &jday) != SUCCESS)) {
WRONG_PARAM_COUNT;
}
convert_to_long(jday);
uday = jday->value.lval - 2440588 /* J.D. of 1.1.1970 */;
if(uday<0) RETURN_FALSE; /* before beginning of unix epoch */
if(uday>24755) RETURN_FALSE; /* behind end of unix epoch */
RETURN_LONG(uday*24*3600);
}
/* }}} */
-334
View File
@@ -1,334 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP version 4.0 |
+----------------------------------------------------------------------+
| Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 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_02.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: Shane Caraveo <shane@caraveo.com> |
| Colin Viebrock <cmv@easydns.com> |
| Hartmut Holzgraefe <hartmut@six.de> |
+----------------------------------------------------------------------+
*/
/* $Id: */
#include "php.h"
#include "php_calendar.h"
#include "sdncal.h"
function_entry calendar_functions[] = {
PHP_FE(jdtogregorian, NULL)
PHP_FE(gregoriantojd, NULL)
PHP_FE(jdtojulian, NULL)
PHP_FE(juliantojd, NULL)
PHP_FE(jdtojewish, NULL)
PHP_FE(jewishtojd, NULL)
PHP_FE(jdtofrench, NULL)
PHP_FE(frenchtojd, NULL)
PHP_FE(jddayofweek, NULL)
PHP_FE(jdmonthname, NULL)
PHP_FE(easter_date, NULL)
PHP_FE(easter_days, NULL)
PHP_FE(unixtojd, NULL)
PHP_FE(jdtounix, NULL)
{NULL, NULL, NULL}
};
zend_module_entry calendar_module_entry = {
"Calendar",
calendar_functions,
NULL, /*PHP_MINIT(calendar),*/
NULL,
NULL,
NULL,
PHP_MINFO(calendar),
STANDARD_MODULE_PROPERTIES,
};
#ifdef COMPILE_DL_CALENDAR
ZEND_GET_MODULE(calendar)
#endif
PHP_MINIT_FUNCTION(calendar)
{
/*
REGISTER_INT_CONSTANT("CAL_EASTER_TO_xxx",0, CONST_CS | CONST_PERSISTENT);
*/
return SUCCESS;
}
PHP_MINFO_FUNCTION(calendar)
{
php_printf("Calendar support enabled");
}
/* {{{ proto string jdtogregorian(int juliandaycount)
Convert a julian day count to a gregorian calendar date */
PHP_FUNCTION(jdtogregorian)
{
pval **julday;
int year, month, day;
char date[10];
if (zend_get_parameters_ex(1, &julday) != SUCCESS) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(julday);
SdnToGregorian((*julday)->value.lval, &year, &month, &day);
sprintf(date, "%i/%i/%i", month, day, year);
RETURN_STRING(date,1);
}
/* }}} */
/* {{{ proto int gregoriantojd(int month, int day, int year)
Convert a gregorian calendar date to julian day count */
PHP_FUNCTION(gregoriantojd)
{
pval **year, **month, **day;
int jdate;
if (zend_get_parameters_ex(3, &month, &day, &year) != SUCCESS) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(month);
convert_to_long_ex(day);
convert_to_long_ex(year);
jdate = GregorianToSdn((*year)->value.lval, (*month)->value.lval,(*day)->value.lval);
RETURN_LONG(jdate);
}
/* }}} */
/* {{{ proto string jdtojulian(int juliandaycount)
Convert a julian day count to a julian calendar date */
PHP_FUNCTION(jdtojulian)
{
pval **julday;
int year, month, day;
char date[10];
if (zend_get_parameters_ex(1, &julday) != SUCCESS) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(julday);
SdnToJulian((*julday)->value.lval, &year, &month, &day);
sprintf(date, "%i/%i/%i", month, day, year);
RETURN_STRING(date,1);
}
/* }}} */
/* {{{ proto int juliantojd(int month, int day, int year)
Convert a julian calendar date to julian day count */
PHP_FUNCTION(juliantojd)
{
pval **year, **month, **day;
int jdate;
if (zend_get_parameters_ex(3, &month, &day, &year) != SUCCESS) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(month);
convert_to_long_ex(day);
convert_to_long_ex(year);
jdate = JulianToSdn((*year)->value.lval,(*month)->value.lval, (*day)->value.lval);
RETURN_LONG(jdate);
}
/* }}} */
/* {{{ proto string jdtojewish(int juliandaycount)
Convert a julian day count to a jewish calendar date */
PHP_FUNCTION(jdtojewish)
{
pval **julday;
int year, month, day;
char date[10];
if (zend_get_parameters_ex(1, &julday) != SUCCESS) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(julday);
SdnToJewish((*julday)->value.lval, &year, &month, &day);
sprintf(date, "%i/%i/%i", month, day, year);
RETURN_STRING(date,1);
}
/* }}} */
/* {{{ proto int jewishtojd(int month, int day, int year)
Convert a jewish calendar date to a julian day count */
PHP_FUNCTION(jewishtojd)
{
pval **year, **month, **day;
int jdate;
if (zend_get_parameters_ex(3, &month, &day, &year) != SUCCESS) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(month);
convert_to_long_ex(day);
convert_to_long_ex(year);
jdate = JewishToSdn((*year)->value.lval,(*month)->value.lval, (*day)->value.lval);
RETURN_LONG(jdate);
}
/* }}} */
/* {{{ proto string jdtofrench(int juliandaycount)
Convert a julian day count to a french republic calendar date */
PHP_FUNCTION(jdtofrench)
{
pval **julday;
int year, month, day;
char date[10];
if (zend_get_parameters_ex(1, &julday) != SUCCESS) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(julday);
SdnToFrench((*julday)->value.lval, &year, &month, &day);
sprintf(date, "%i/%i/%i", month, day, year);
RETURN_STRING(date,1);
}
/* }}} */
/* {{{ proto int frenchtojd(int month, int day, int year)
Convert a french republic calendar date to julian day count */
PHP_FUNCTION(frenchtojd)
{
pval **year, **month, **day;
int jdate;
if (zend_get_parameters_ex(3, &month, &day, &year) != SUCCESS) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(month);
convert_to_long_ex(day);
convert_to_long_ex(year);
jdate = FrenchToSdn((*year)->value.lval,(*month)->value.lval,(*day)->value.lval);
RETURN_LONG(jdate);
}
/* }}} */
/* {{{ proto mixed jddayofweek(int juliandaycount [, int mode])
Returns name or number of day of week from julian day count */
PHP_FUNCTION(jddayofweek)
{
pval *julday, *mode;
int day;
char *daynamel, *daynames;
int myargc=ZEND_NUM_ARGS(),mymode=0;
if ((myargc < 1) || (myargc > 2) || (zend_get_parameters(ht,myargc, &julday, &mode) != SUCCESS)) {
WRONG_PARAM_COUNT;
}
convert_to_long(julday);
if(myargc==2) {
convert_to_long(mode);
mymode = mode->value.lval;
}
day = DayOfWeek(julday->value.lval);
daynamel = DayNameLong[day];
daynames = DayNameShort[day];
switch (mymode) {
case 0L:
RETURN_LONG(day);
break;
case 1L:
RETURN_STRING(daynamel,1);
break;
case 2L:
RETURN_STRING(daynames,1);
break;
default:
RETURN_LONG(day);
break;
}
}
/* }}} */
/* {{{ proto string jdmonthname(int juliandaycount, int mode)
Returns name of month for julian day count */
PHP_FUNCTION(jdmonthname)
{
pval **julday, **mode;
char *monthname = NULL;
int month, day, year;
if (zend_get_parameters_ex(2, &julday, &mode) != SUCCESS) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(julday);
convert_to_long_ex(mode);
switch((*mode)->value.lval) {
case 0L: /* gregorian or julian month */
SdnToGregorian((*julday)->value.lval,&year, &month, &day);
monthname = MonthNameShort[month];
break;
case 1L: /* gregorian or julian month */
SdnToGregorian((*julday)->value.lval,&year, &month, &day);
monthname = MonthNameLong[month];
break;
case 2L: /* gregorian or julian month */
SdnToJulian((*julday)->value.lval, &year,&month, &day);
monthname = MonthNameShort[month];
break;
case 3L: /* gregorian or julian month */
SdnToJulian((*julday)->value.lval, &year,&month, &day);
monthname = MonthNameLong[month];
break;
case 4L: /* jewish month */
SdnToJewish((*julday)->value.lval, &year,&month, &day);
monthname = JewishMonthName[month];
break;
case 5L: /* french month */
SdnToFrench((*julday)->value.lval, &year,&month, &day);
monthname = FrenchMonthName[month];
break;
default: /* default gregorian */
/* FIXME - need to set monthname to something here ?? */
break;
}
RETURN_STRING(monthname,1);
}
/* }}} */
-145
View File
@@ -1,145 +0,0 @@
# Microsoft Developer Studio Project File - Name="calendar" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=calendar - Win32 Release_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 "calendar.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 "calendar.mak" CFG="calendar - Win32 Release_TS"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "calendar - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "calendar - Win32 Debug_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)" == "calendar - 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 Ignore_Export_Lib 0
# 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 "..\..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MSSQL_EXPORTS" /D "COMPILE_DL_CALENDAR" /D "DBNTWIN32" /D ZTS=1 /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CALENDAR_EXPORTS" /D "COMPILE_DL_CALENDAR" /D ZTS=1 /D ZEND_WIN32=1 /D PHP_WIN32=1 /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 0x406 /d "NDEBUG"
# ADD RSC /l 0x406 /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 php4ts.lib ntwdblib.lib /nologo /dll /machine:I386 /out:"MSSQL_65_Release/php_mssql.dll" /libpath:"..\..\Release_TS"
# 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 php4ts.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_calendar.dll" /libpath:"..\..\Release_TS"
!ELSEIF "$(CFG)" == "calendar - Win32 Debug_TS"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Debug_TS"
# PROP BASE Intermediate_Dir "Debug_TS"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Debug_TS"
# PROP Intermediate_Dir "Debug_TS"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "mssql-70" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MSSQL_EXPORTS" /D "COMPILE_DL_CALENDAR" /D "DBNTWIN32" /D ZTS=1 /D MSSQL70=1 /YX /FD /c
# ADD CPP /nologo /MDd /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CALENDAR_EXPORTS" /D "COMPILE_DL_CALENDAR" /D ZTS=1 /D ZEND_WIN32=1 /D PHP_WIN32=1 /D ZEND_DEBUG=1 /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x406 /d "NDEBUG"
# ADD RSC /l 0x406 /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 php4ts.lib ntwdblib.lib /nologo /dll /machine:I386 /out:"MSSQL_65_Release/php_mssql.dll" /libpath:"..\..\Release_TS" /libpath:"mssql-70"
# 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 php4ts_debug.lib /nologo /dll /machine:I386 /out:"..\..\Debug_TS/php_calendar.dll" /libpath:"..\..\Debug_TS"
!ENDIF
# Begin Target
# Name "calendar - Win32 Release_TS"
# Name "calendar - Win32 Debug_TS"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\cal_unix.c
# End Source File
# Begin Source File
SOURCE=.\calendar.c
# End Source File
# Begin Source File
SOURCE=.\dow.c
# End Source File
# Begin Source File
SOURCE=.\easter.c
# End Source File
# Begin Source File
SOURCE=.\french.c
# End Source File
# Begin Source File
SOURCE=.\gregor.c
# End Source File
# Begin Source File
SOURCE=.\jewish.c
# End Source File
# Begin Source File
SOURCE=.\julian.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\calendar.h
# End Source File
# Begin Source File
SOURCE=.\sdncal.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
# End Target
# End Project
-9
View File
@@ -1,9 +0,0 @@
dnl $Id$
PHP_ARG_ENABLE(calendar,whether to enable calendar conversion support,
[ --enable-calendar Enable support for calendar conversion])
if test "$PHP_CALENDAR" = "yes"; then
AC_DEFINE(HAVE_CALENDAR,1,[ ])
PHP_EXTENSION(calendar, $ext_shared)
fi
-67
View File
@@ -1,67 +0,0 @@
/* $selId: dow.c,v 2.0 1995/10/24 01:13:06 lees Exp $
* Copyright 1993-1995, Scott E. Lee, all rights reserved.
* Permission granted to use, copy, modify, distribute and sell so long as
* the above copyright and this permission statement are retained in all
* copies. THERE IS NO WARRANTY - USE AT YOUR OWN RISK.
*/
/**************************************************************************
*
* These are the externally visible components of this file:
*
* int
* DayOfWeek(
* long int sdn);
*
* Convert a SDN to a day-of-week number (0 to 6). Where 0 stands for
* Sunday, 1 for Monday, etc. and 6 stands for Saturday.
*
* char *DayNameShort[7];
*
* Convert a day-of-week number (0 to 6), as returned from DayOfWeek(), to
* the abbreviated (three character) name of the day.
*
* char *DayNameLong[7];
*
* Convert a day-of-week number (0 to 6), as returned from DayOfWeek(), to
* the name of the day.
*
**************************************************************************/
#include "sdncal.h"
int DayOfWeek(
long int sdn)
{
int dow;
dow = (sdn + 1) % 7;
if (dow >= 0) {
return (dow);
} else {
return (dow + 7);
}
}
char *DayNameShort[7] =
{
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"
};
char *DayNameLong[7] =
{
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
};
-142
View File
@@ -1,142 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP version 4.0 |
+----------------------------------------------------------------------+
| Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 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_02.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: Shane Caraveo <shane@caraveo.com> |
| Colin Viebrock <cmv@easydns.com> |
| Hartmut Holzgraefe <hartmut@six.de> |
+----------------------------------------------------------------------+
*/
/* $Id: */
#include "php.h"
#include "php_calendar.h"
#include "sdncal.h"
#include <time.h>
static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, int gm)
{
/* based on code by Simon Kershaw, <webmaster@ely.anglican.org> */
pval *year_arg;
struct tm *ta, te;
time_t the_time;
long year, golden, solar, lunar, pfm, dom, tmp, easter;
switch(ZEND_NUM_ARGS()) {
case 0:
the_time = time(NULL);
ta = localtime(&the_time);
year = ta->tm_year + 1900;
break;
case 1:
if (getParameters(ht, 1, &year_arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long(year_arg);
year = year_arg->value.lval;
break;
default:
WRONG_PARAM_COUNT;
}
if (gm && (year<1970 || year>2037)) { /* out of range for timestamps */
php3_error(E_WARNING, "easter_date() is only valid for years between 1970 and 2037 inclusive");
RETURN_FALSE;
}
golden = (year % 19) + 1; /* the Golden number */
if ( year <= 1752 ) { /* JULIAN CALENDAR */
dom = (year + (year/4) + 5) % 7; /* the "Dominical number" - finding a Sunday */
if (dom < 0) {
dom += 7;
}
pfm = (3 - (11*golden) - 7) % 30; /* uncorrected date of the Paschal full moon */
if (pfm < 0) {
pfm += 30;
}
} else { /* GREGORIAN CALENDAR */
dom = (year + (year/4) - (year/100) + (year/400)) % 7; /* the "Domincal number" */
if (dom < 0) {
dom += 7;
}
solar = (year-1600)/100 - (year-1600)/400; /* the solar and lunar corrections */
lunar = (((year-1400) / 100) * 8) / 25;
pfm = (3 - (11*golden) + solar - lunar) % 30; /* uncorrected date of the Paschal full moon */
if (pfm < 0) {
pfm += 30;
}
}
if ((pfm == 29) || (pfm == 28 && golden > 11)) { /* corrected date of the Paschal full moon */
pfm--; /* - days after 21st March */
}
tmp = (4-pfm-dom) % 7;
if (tmp < 0) {
tmp += 7;
}
easter = pfm + tmp + 1; /* Easter as the number of days after 21st March */
if (gm) { /* return a timestamp */
te.tm_isdst = -1;
te.tm_year = year-1900;
te.tm_sec = 0;
te.tm_min = 0;
te.tm_hour = 0;
if (easter < 11) {
te.tm_mon = 2; /* March */
te.tm_mday = easter+21;
} else {
te.tm_mon = 3; /* April */
te.tm_mday = easter-10;
}
return_value->value.lval = mktime(&te);
} else { /* return the days after March 21 */
return_value->value.lval = easter;
}
return_value->type = IS_LONG;
}
/* {{{ proto int easter_date([int year])
Return the timestamp of midnight on Easter of a given year (defaults to current year) */
PHP_FUNCTION(easter_date)
{
_cal_easter(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
}
/* }}} */
/* {{{ proto int easter_days([int year])
Return the number of days after March 21 that Easter falls on for a given year (defaults to current year) */
PHP_FUNCTION(easter_days)
{
_cal_easter(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
*/
-150
View File
@@ -1,150 +0,0 @@
/* $selId: french.c,v 2.0 1995/10/24 01:13:06 lees Exp $
* Copyright 1993-1995, Scott E. Lee, all rights reserved.
* Permission granted to use, copy, modify, distribute and sell so long as
* the above copyright and this permission statement are retained in all
* copies. THERE IS NO WARRANTY - USE AT YOUR OWN RISK.
*/
/**************************************************************************
*
* These are the externally visible components of this file:
*
* void
* SdnToFrench(
* long int sdn,
* int *pYear,
* int *pMonth,
* int *pDay);
*
* Convert a SDN to a French republican calendar date. If the input SDN is
* before the first day of year 1 or after the last day of year 14, the
* three output values will all be set to zero, otherwise *pYear will be in
* the range 1 to 14 inclusive; *pMonth will be in the range 1 to 13
* inclusive; *pDay will be in the range 1 to 30 inclusive. If *pMonth is
* 13, the SDN represents one of the holidays at the end of the year and
* *pDay will be in the range 1 to 6 inclusive.
*
* long int
* FrenchToSdn(
* int year,
* int month,
* int day);
*
* Convert a French republican calendar date to a SDN. Zero is returned
* when the input date is detected as invalid or out of the supported
* range. The return value will be > 0 for all valid, supported dates, but
* there are some invalid dates that will return a positive value. To
* verify that a date is valid, convert it to SDN and then back and compare
* with the original.
*
* char *FrenchMonthName[14];
*
* Convert a French republican month number (1 to 13) to the name of the
* French republican month (null terminated). An index of 13 (for the
* "extra" days at the end of the year) will return the string "Extra". An
* index of zero will return a zero length string.
*
* VALID RANGE
*
* These routines only convert dates in years 1 through 14 (Gregorian
* dates 22 September 1792 through 22 September 1806). This more than
* covers the period when the calendar was in use.
*
* I would support a wider range of dates, but I have not been able to
* find an authoritative definition of when leap years were to have
* occurred. There are suggestions that it was to skip a leap year ever
* 100 years like the Gregorian calendar.
*
* CALENDAR OVERVIEW
*
* The French republican calendar was adopted in October 1793 during
* the French Revolution and was abandoned in January 1806. The intent
* was to create a new calendar system that was based on scientific
* principals, not religious traditions.
*
* The year is divided into 12 months of 30 days each. The remaining 5
* to 6 days in the year are grouped at the end and are holidays. Each
* month is divided into three decades (instead of weeks) of 10 days
* each.
*
* The epoch (first day of the first year) is 22 September 1792 in the
* Gregorian calendar. Leap years are every fourth year (year 3, 7,
* 11, etc.)
*
* TESTING
*
* This algorithm has been tested from the year 1 to 14. The source
* code of the verification program is included in this package.
*
* REFERENCES
*
* I have found no detailed, authoritative reference on this calendar.
* The algorithms are based on a preponderance of less authoritative
* sources.
*
**************************************************************************/
#include "sdncal.h"
#define SDN_OFFSET 2375474
#define DAYS_PER_4_YEARS 1461
#define DAYS_PER_MONTH 30
#define FIRST_VALID 2375840
#define LAST_VALID 2380952
void SdnToFrench(
long int sdn,
int *pYear,
int *pMonth,
int *pDay)
{
long int temp;
int dayOfYear;
if (sdn < FIRST_VALID || sdn > LAST_VALID) {
*pYear = 0;
*pMonth = 0;
*pDay = 0;
return;
}
temp = (sdn - SDN_OFFSET) * 4 - 1;
*pYear = temp / DAYS_PER_4_YEARS;
dayOfYear = (temp % DAYS_PER_4_YEARS) / 4;
*pMonth = dayOfYear / DAYS_PER_MONTH + 1;
*pDay = dayOfYear % DAYS_PER_MONTH + 1;
}
long int FrenchToSdn(
int year,
int month,
int day)
{
/* check for invalid dates */
if (year < 1 || year > 14 ||
month < 1 || month > 13 ||
day < 1 || day > 30) {
return (0);
}
return ((year * DAYS_PER_4_YEARS) / 4
+ (month - 1) * DAYS_PER_MONTH
+ day
+ SDN_OFFSET);
}
char *FrenchMonthName[14] =
{
"",
"Vendemiaire",
"Brumaire",
"Frimaire",
"Nivose",
"Pluviose",
"Ventose",
"Germinal",
"Floreal",
"Prairial",
"Messidor",
"Thermidor",
"Fructidor",
"Extra"
};
-265
View File
@@ -1,265 +0,0 @@
/* $selId: gregor.c,v 2.0 1995/10/24 01:13:06 lees Exp $
* Copyright 1993-1995, Scott E. Lee, all rights reserved.
* Permission granted to use, copy, modify, distribute and sell so long as
* the above copyright and this permission statement are retained in all
* copies. THERE IS NO WARRANTY - USE AT YOUR OWN RISK.
*/
/**************************************************************************
*
* These are the externally visible components of this file:
*
* void
* SdnToGregorian(
* long int sdn,
* int *pYear,
* int *pMonth,
* int *pDay);
*
* Convert a SDN to a Gregorian calendar date. If the input SDN is less
* than 1, the three output values will all be set to zero, otherwise
* *pYear will be >= -4714 and != 0; *pMonth will be in the range 1 to 12
* inclusive; *pDay will be in the range 1 to 31 inclusive.
*
* long int
* GregorianToSdn(
* int inputYear,
* int inputMonth,
* int inputDay);
*
* Convert a Gregorian calendar date to a SDN. Zero is returned when the
* input date is detected as invalid or out of the supported range. The
* return value will be > 0 for all valid, supported dates, but there are
* some invalid dates that will return a positive value. To verify that a
* date is valid, convert it to SDN and then back and compare with the
* original.
*
* char *MonthNameShort[13];
*
* Convert a Gregorian month number (1 to 12) to the abbreviated (three
* character) name of the Gregorian month (null terminated). An index of
* zero will return a zero length string.
*
* char *MonthNameLong[13];
*
* Convert a Gregorian month number (1 to 12) to the name of the Gregorian
* month (null terminated). An index of zero will return a zero length
* string.
*
* VALID RANGE
*
* 4714 B.C. to at least 10000 A.D.
*
* Although this software can handle dates all the way back to 4714
* B.C., such use may not be meaningful. The Gregorian calendar was
* not instituted until October 15, 1582 (or October 5, 1582 in the
* Julian calendar). Some countries did not accept it until much
* later. For example, Britain converted in 1752, The USSR in 1918 and
* Greece in 1923. Most European countries used the Julian calendar
* prior to the Gregorian.
*
* CALENDAR OVERVIEW
*
* The Gregorian calendar is a modified version of the Julian calendar.
* The only difference being the specification of leap years. The
* Julian calendar specifies that every year that is a multiple of 4
* will be a leap year. This leads to a year that is 365.25 days long,
* but the current accepted value for the tropical year is 365.242199
* days.
*
* To correct this error in the length of the year and to bring the
* vernal equinox back to March 21, Pope Gregory XIII issued a papal
* bull declaring that Thursday October 4, 1582 would be followed by
* Friday October 15, 1582 and that centennial years would only be a
* leap year if they were a multiple of 400. This shortened the year
* by 3 days per 400 years, giving a year of 365.2425 days.
*
* Another recently proposed change in the leap year rule is to make
* years that are multiples of 4000 not a leap year, but this has never
* been officially accepted and this rule is not implemented in these
* algorithms.
*
* ALGORITHMS
*
* The calculations are based on three different cycles: a 400 year
* cycle of leap years, a 4 year cycle of leap years and a 5 month
* cycle of month lengths.
*
* The 5 month cycle is used to account for the varying lengths of
* months. You will notice that the lengths alternate between 30
* and 31 days, except for three anomalies: both July and August
* have 31 days, both December and January have 31, and February
* is less than 30. Starting with March, the lengths are in a
* cycle of 5 months (31, 30, 31, 30, 31):
*
* Mar 31 days \
* Apr 30 days |
* May 31 days > First cycle
* Jun 30 days |
* Jul 31 days /
*
* Aug 31 days \
* Sep 30 days |
* Oct 31 days > Second cycle
* Nov 30 days |
* Dec 31 days /
*
* Jan 31 days \
* Feb 28/9 days |
* > Third cycle (incomplete)
*
* For this reason the calculations (internally) assume that the
* year starts with March 1.
*
* TESTING
*
* This algorithm has been tested from the year 4714 B.C. to 10000
* A.D. The source code of the verification program is included in
* this package.
*
* REFERENCES
*
* Conversions Between Calendar Date and Julian Day Number by Robert J.
* Tantzen, Communications of the Association for Computing Machinery
* August 1963. (Also published in Collected Algorithms from CACM,
* algorithm number 199).
*
**************************************************************************/
#include "sdncal.h"
#define SDN_OFFSET 32045
#define DAYS_PER_5_MONTHS 153
#define DAYS_PER_4_YEARS 1461
#define DAYS_PER_400_YEARS 146097
void SdnToGregorian(
long int sdn,
int *pYear,
int *pMonth,
int *pDay)
{
int century;
int year;
int month;
int day;
long int temp;
int dayOfYear;
if (sdn <= 0) {
*pYear = 0;
*pMonth = 0;
*pDay = 0;
return;
}
temp = (sdn + SDN_OFFSET) * 4 - 1;
/* Calculate the century (year/100). */
century = temp / DAYS_PER_400_YEARS;
/* Calculate the year and day of year (1 <= dayOfYear <= 366). */
temp = ((temp % DAYS_PER_400_YEARS) / 4) * 4 + 3;
year = (century * 100) + (temp / DAYS_PER_4_YEARS);
dayOfYear = (temp % DAYS_PER_4_YEARS) / 4 + 1;
/* Calculate the month and day of month. */
temp = dayOfYear * 5 - 3;
month = temp / DAYS_PER_5_MONTHS;
day = (temp % DAYS_PER_5_MONTHS) / 5 + 1;
/* Convert to the normal beginning of the year. */
if (month < 10) {
month += 3;
} else {
year += 1;
month -= 9;
}
/* Adjust to the B.C./A.D. type numbering. */
year -= 4800;
if (year <= 0)
year--;
*pYear = year;
*pMonth = month;
*pDay = day;
}
long int GregorianToSdn(
int inputYear,
int inputMonth,
int inputDay)
{
int year;
int month;
/* check for invalid dates */
if (inputYear == 0 || inputYear < -4714 ||
inputMonth <= 0 || inputMonth > 12 ||
inputDay <= 0 || inputDay > 31) {
return (0);
}
/* check for dates before SDN 1 (Nov 25, 4714 B.C.) */
if (inputYear == -4714) {
if (inputMonth < 11) {
return (0);
}
if (inputMonth == 11 && inputDay < 25) {
return (0);
}
}
/* Make year always a positive number. */
if (inputYear < 0) {
year = inputYear + 4801;
} else {
year = inputYear + 4800;
}
/* Adjust the start of the year. */
if (inputMonth > 2) {
month = inputMonth - 3;
} else {
month = inputMonth + 9;
year--;
}
return (((year / 100) * DAYS_PER_400_YEARS) / 4
+ ((year % 100) * DAYS_PER_4_YEARS) / 4
+ (month * DAYS_PER_5_MONTHS + 2) / 5
+ inputDay
- SDN_OFFSET);
}
char *MonthNameShort[13] =
{
"",
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
};
char *MonthNameLong[13] =
{
"",
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
};
-732
View File
@@ -1,732 +0,0 @@
/* $selId: jewish.c,v 2.0 1995/10/24 01:13:06 lees Exp $
* Copyright 1993-1995, Scott E. Lee, all rights reserved.
* Permission granted to use, copy, modify, distribute and sell so long as
* the above copyright and this permission statement are retained in all
* copies. THERE IS NO WARRANTY - USE AT YOUR OWN RISK.
*/
/**************************************************************************
*
* These are the externally visible components of this file:
*
* void
* SdnToJewish(
* long int sdn,
* int *pYear,
* int *pMonth,
* int *pDay);
*
* Convert a SDN to a Jewish calendar date. If the input SDN is before the
* first day of year 1, the three output values will all be set to zero,
* otherwise *pYear will be > 0; *pMonth will be in the range 1 to 13
* inclusive; *pDay will be in the range 1 to 30 inclusive. Note that Adar
* II is assigned the month number 7 and Elul is always 13.
*
* long int
* JewishToSdn(
* int year,
* int month,
* int day);
*
* Convert a Jewish calendar date to a SDN. Zero is returned when the
* input date is detected as invalid or out of the supported range. The
* return value will be > 0 for all valid, supported dates, but there are
* some invalid dates that will return a positive value. To verify that a
* date is valid, convert it to SDN and then back and compare with the
* original.
*
* char *JewishMonthName[14];
*
* Convert a Jewish month number (1 to 13) to the name of the Jewish month
* (null terminated). An index of zero will return a zero length string.
*
* VALID RANGE
*
* Although this software can handle dates all the way back to the year
* 1 (3761 B.C.), such use may not be meaningful.
*
* The Jewish calendar has been in use for several thousand years, but
* in the early days there was no formula to determine the start of a
* month. A new month was started when the new moon was first
* observed.
*
* It is not clear when the current rule based calendar replaced the
* observation based calendar. According to the book "Jewish Calendar
* Mystery Dispelled" by George Zinberg, the patriarch Hillel II
* published these rules in 358 A.D. But, according to The
* Encyclopedia Judaica, Hillel II may have only published the 19 year
* rule for determining the occurrence of leap years.
*
* I have yet to find a specific date when the current set of rules
* were known to be in use.
*
* CALENDAR OVERVIEW
*
* The Jewish calendar is based on lunar as well as solar cycles. A
* month always starts on or near a new moon and has either 29 or 30
* days (a lunar cycle is about 29 1/2 days). Twelve of these
* alternating 29-30 day months gives a year of 354 days, which is
* about 11 1/4 days short of a solar year.
*
* Since a month is defined to be a lunar cycle (new moon to new moon),
* this 11 1/4 day difference cannot be overcome by adding days to a
* month as with the Gregorian calendar, so an entire month is
* periodically added to the year, making some years 13 months long.
*
* For astronomical as well as ceremonial reasons, the start of a new
* year may be delayed until a day or two after the new moon causing
* years to vary in length. Leap years can be from 383 to 385 days and
* common years can be from 353 to 355 days. These are the months of
* the year and their possible lengths:
*
* COMMON YEAR LEAP YEAR
* 1 Tishri 30 30 30 30 30 30
* 2 Heshvan 29 29 30 29 29 30 (variable)
* 3 Kislev 29 30 30 29 30 30 (variable)
* 4 Tevet 29 29 29 29 29 29
* 5 Shevat 30 30 30 30 30 30
* 6 Adar I 29 29 29 30 30 30 (variable)
* 7 Adar II -- -- -- 29 29 29 (optional)
* 8 Nisan 30 30 30 30 30 30
* 9 Iyyar 29 29 29 29 29 29
* 10 Sivan 30 30 30 30 30 30
* 11 Tammuz 29 29 29 29 29 29
* 12 Av 30 30 30 30 30 30
* 13 Elul 29 29 29 29 29 29
* --- --- --- --- --- ---
* 353 354 355 383 384 385
*
* Note that the month names and other words that appear in this file
* have multiple possible spellings in the Roman character set. I have
* chosen to use the spellings found in the Encyclopedia Judaica.
*
* Adar II, the month added for leap years, is sometimes referred to as
* the 13th month, but I have chosen to assign it the number 7 to keep
* the months in chronological order. This may not be consistent with
* other numbering schemes.
*
* Leap years occur in a fixed pattern of 19 years called the metonic
* cycle. The 3rd, 6th, 8th, 11th, 14th, 17th and 19th years of this
* cycle are leap years. The first metonic cycle starts with Jewish
* year 1, or 3761/60 B.C. This is believed to be the year of
* creation.
*
* To construct the calendar for a year, you must first find the length
* of the year by determining the first day of the year (Tishri 1, or
* Rosh Ha-Shanah) and the first day of the following year. This
* selects one of the six possible month length configurations listed
* above.
*
* Finding the first day of the year is the most difficult part.
* Finding the date and time of the new moon (or molad) is the first
* step. For this purpose, the lunar cycle is assumed to be 29 days 12
* hours and 793 halakim. A halakim is 1/1080th of an hour or 3 1/3
* seconds. (This assumed value is only about 1/2 second less than the
* value used by modern astronomers -- not bad for a number that was
* determined so long ago.) The first molad of year 1 occurred on
* Sunday at 11:20:11 P.M. This would actually be Monday, because the
* Jewish day is considered to begin at sunset.
*
* Since sunset varies, the day is assumed to begin at 6:00 P.M. for
* calendar calculation purposes. So, the first molad was 5 hours 793
* halakim after the start of Tishri 1, 0001 (which was Monday
* September 7, 4761 B.C. by the Gregorian calendar). All subsequent
* molads can be calculated from this starting point by adding the
* length of a lunar cycle.
*
* Once the molad that starts a year is determined the actual start of
* the year (Tishri 1) can be determined. Tishri 1 will be the day of
* the molad unless it is delayed by one of the following four rules
* (called dehiyyot). Each rule can delay the start of the year by one
* day, and since rule #1 can combine with one of the other rules, it
* can be delayed as much as two days.
*
* 1. Tishri 1 must never be Sunday, Wednesday or Friday. (This
* is largely to prevent certain holidays from occurring on the
* day before or after the Sabbath.)
*
* 2. If the molad occurs on or after noon, Tishri 1 must be
* delayed.
*
* 3. If it is a common (not leap) year and the molad occurs on
* Tuesday at or after 3:11:20 A.M., Tishri 1 must be delayed.
*
* 4. If it is the year following a leap year and the molad occurs
* on Monday at or after 9:32:43 and 1/3 sec, Tishri 1 must be
* delayed.
*
* GLOSSARY
*
* dehiyyot The set of 4 rules that determine when the new year
* starts relative to the molad.
*
* halakim 1/1080th of an hour or 3 1/3 seconds.
*
* lunar cycle The period of time between mean conjunctions of the
* sun and moon (new moon to new moon). This is
* assumed to be 29 days 12 hours and 793 halakim for
* calendar purposes.
*
* metonic cycle A 19 year cycle which determines which years are
* leap years and which are common years. The 3rd,
* 6th, 8th, 11th, 14th, 17th and 19th years of this
* cycle are leap years.
*
* molad The date and time of the mean conjunction of the
* sun and moon (new moon). This is the approximate
* beginning of a month.
*
* Rosh Ha-Shanah The first day of the Jewish year (Tishri 1).
*
* Tishri The first month of the Jewish year.
*
* ALGORITHMS
*
* SERIAL DAY NUMBER TO JEWISH DATE
*
* The simplest approach would be to use the rules stated above to find
* the molad of Tishri before and after the given day number. Then use
* the molads to find Tishri 1 of the current and following years.
* From this the length of the year can be determined and thus the
* length of each month. But this method is used as a last resort.
*
* The first 59 days of the year are the same regardless of the length
* of the year. As a result, only the day number of the start of the
* year is required.
*
* Similarly, the last 6 months do not change from year to year. And
* since it can be determined whether the year is a leap year by simple
* division, the lengths of Adar I and II can be easily calculated. In
* fact, all dates after the 3rd month are consistent from year to year
* (once it is known whether it is a leap year).
*
* This means that if the given day number falls in the 3rd month or on
* the 30th day of the 2nd month the length of the year must be found,
* but in no other case.
*
* So, the approach used is to take the given day number and round it
* to the closest molad of Tishri (first new moon of the year). The
* rounding is not really to the *closest* molad, but is such that if
* the day number is before the middle of the 3rd month the molad at
* the start of the year is found, otherwise the molad at the end of
* the year is found.
*
* Only if the day number is actually found to be in the ambiguous
* period of 29 to 31 days is the other molad calculated.
*
* JEWISH DATE TO SERIAL DAY NUMBER
*
* The year number is used to find which 19 year metonic cycle contains
* the date and which year within the cycle (this is a division and
* modulus). This also determines whether it is a leap year.
*
* If the month is 1 or 2, the calculation is simple addition to the
* first of the year.
*
* If the month is 8 (Nisan) or greater, the calculation is simple
* subtraction from beginning of the following year.
*
* If the month is 4 to 7, it is considered whether it is a leap year
* and then simple subtraction from the beginning of the following year
* is used.
*
* Only if it is the 3rd month is both the start and end of the year
* required.
*
* TESTING
*
* This algorithm has been tested in two ways. First, 510 dates from a
* table in "Jewish Calendar Mystery Dispelled" were calculated and
* compared to the table. Second, the calculation algorithm described
* in "Jewish Calendar Mystery Dispelled" was coded and used to verify
* all dates from the year 1 (3761 B.C.) to the year 13760 (10000
* A.D.).
*
* The source code of the verification program is included in this
* package.
*
* REFERENCES
*
* The Encyclopedia Judaica, the entry for "Calendar"
*
* The Jewish Encyclopedia
*
* Jewish Calendar Mystery Dispelled by George Zinberg, Vantage Press,
* 1963
*
* The Comprehensive Hebrew Calendar by Arthur Spier, Behrman House
*
* The Book of Calendars [note that this work contains many typos]
*
**************************************************************************/
#include "sdncal.h"
#define HALAKIM_PER_HOUR 1080
#define HALAKIM_PER_DAY 25920
#define HALAKIM_PER_LUNAR_CYCLE ((29 * HALAKIM_PER_DAY) + 13753)
#define HALAKIM_PER_METONIC_CYCLE (HALAKIM_PER_LUNAR_CYCLE * (12 * 19 + 7))
#define SDN_OFFSET 347997
#define NEW_MOON_OF_CREATION 31524
#define SUNDAY 0
#define MONDAY 1
#define TUESDAY 2
#define WEDNESDAY 3
#define THURSDAY 4
#define FRIDAY 5
#define SATURDAY 6
#define NOON (18 * HALAKIM_PER_HOUR)
#define AM3_11_20 ((9 * HALAKIM_PER_HOUR) + 204)
#define AM9_32_43 ((15 * HALAKIM_PER_HOUR) + 589)
static int monthsPerYear[19] =
{
12, 12, 13, 12, 12, 13, 12, 13, 12, 12, 13, 12, 12, 13, 12, 12, 13, 12, 13
};
static int yearOffset[19] =
{
0, 12, 24, 37, 49, 61, 74, 86, 99, 111, 123,
136, 148, 160, 173, 185, 197, 210, 222
};
char *JewishMonthName[14] =
{
"",
"Tishri",
"Heshvan",
"Kislev",
"Tevet",
"Shevat",
"AdarI",
"AdarII",
"Nisan",
"Iyyar",
"Sivan",
"Tammuz",
"Av",
"Elul"
};
/************************************************************************
* Given the year within the 19 year metonic cycle and the time of a molad
* (new moon) which starts that year, this routine will calculate what day
* will be the actual start of the year (Tishri 1 or Rosh Ha-Shanah). This
* first day of the year will be the day of the molad unless one of 4 rules
* (called dehiyyot) delays it. These 4 rules can delay the start of the
* year by as much as 2 days.
*/
static long int Tishri1(
int metonicYear,
long int moladDay,
long int moladHalakim)
{
long int tishri1;
int dow;
int leapYear;
int lastWasLeapYear;
tishri1 = moladDay;
dow = tishri1 % 7;
leapYear = metonicYear == 2 || metonicYear == 5 || metonicYear == 7
|| metonicYear == 10 || metonicYear == 13 || metonicYear == 16
|| metonicYear == 18;
lastWasLeapYear = metonicYear == 3 || metonicYear == 6
|| metonicYear == 8 || metonicYear == 11 || metonicYear == 14
|| metonicYear == 17 || metonicYear == 0;
/* Apply rules 2, 3 and 4. */
if ((moladHalakim >= NOON) ||
((!leapYear) && dow == TUESDAY && moladHalakim >= AM3_11_20) ||
(lastWasLeapYear && dow == MONDAY && moladHalakim >= AM9_32_43)) {
tishri1++;
dow++;
if (dow == 7) {
dow = 0;
}
}
/* Apply rule 1 after the others because it can cause an additional
* delay of one day. */
if (dow == WEDNESDAY || dow == FRIDAY || dow == SUNDAY) {
tishri1++;
}
return (tishri1);
}
/************************************************************************
* Given a metonic cycle number, calculate the date and time of the molad
* (new moon) that starts that cycle. Since the length of a metonic cycle
* is a constant, this is a simple calculation, except that it requires an
* intermediate value which is bigger that 32 bits. Because this
* intermediate value only needs 36 to 37 bits and the other numbers are
* constants, the process has been reduced to just a few steps.
*/
static void MoladOfMetonicCycle(
int metonicCycle,
long int *pMoladDay,
long int *pMoladHalakim)
{
register unsigned long int r1, r2, d1, d2;
/* Start with the time of the first molad after creation. */
r1 = NEW_MOON_OF_CREATION;
/* Calculate metonicCycle * HALAKIM_PER_METONIC_CYCLE. The upper 32
* bits of the result will be in r2 and the lower 16 bits will be
* in r1. */
r1 += metonicCycle * (HALAKIM_PER_METONIC_CYCLE & 0xFFFF);
r2 = r1 >> 16;
r2 += metonicCycle * ((HALAKIM_PER_METONIC_CYCLE >> 16) & 0xFFFF);
/* Calculate r2r1 / HALAKIM_PER_DAY. The remainder will be in r1, the
* upper 16 bits of the quotient will be in d2 and the lower 16 bits
* will be in d1. */
d2 = r2 / HALAKIM_PER_DAY;
r2 -= d2 * HALAKIM_PER_DAY;
r1 = (r2 << 16) | (r1 & 0xFFFF);
d1 = r1 / HALAKIM_PER_DAY;
r1 -= d1 * HALAKIM_PER_DAY;
*pMoladDay = (d2 << 16) | d1;
*pMoladHalakim = r1;
}
/************************************************************************
* Given a day number, find the molad of Tishri (the new moon at the start
* of a year) which is closest to that day number. It's not really the
* *closest* molad that we want here. If the input day is in the first two
* months, we want the molad at the start of the year. If the input day is
* in the fourth to last months, we want the molad at the end of the year.
* If the input day is in the third month, it doesn't matter which molad is
* returned, because both will be required. This type of "rounding" allows
* us to avoid calculating the length of the year in most cases.
*/
static void FindTishriMolad(
long int inputDay,
int *pMetonicCycle,
int *pMetonicYear,
long int *pMoladDay,
long int *pMoladHalakim)
{
long int moladDay;
long int moladHalakim;
int metonicCycle;
int metonicYear;
/* Estimate the metonic cycle number. Note that this may be an under
* estimate because there are 6939.6896 days in a metonic cycle not
* 6940, but it will never be an over estimate. The loop below will
* correct for any error in this estimate. */
metonicCycle = (inputDay + 310) / 6940;
/* Calculate the time of the starting molad for this metonic cycle. */
MoladOfMetonicCycle(metonicCycle, &moladDay, &moladHalakim);
/* If the above was an under estimate, increment the cycle number until
* the correct one is found. For modern dates this loop is about 98.6%
* likely to not execute, even once, because the above estimate is
* really quite close. */
while (moladDay < inputDay - 6940 + 310) {
metonicCycle++;
moladHalakim += HALAKIM_PER_METONIC_CYCLE;
moladDay += moladHalakim / HALAKIM_PER_DAY;
moladHalakim = moladHalakim % HALAKIM_PER_DAY;
}
/* Find the molad of Tishri closest to this date. */
for (metonicYear = 0; metonicYear < 18; metonicYear++) {
if (moladDay > inputDay - 74) {
break;
}
moladHalakim += HALAKIM_PER_LUNAR_CYCLE * monthsPerYear[metonicYear];
moladDay += moladHalakim / HALAKIM_PER_DAY;
moladHalakim = moladHalakim % HALAKIM_PER_DAY;
}
*pMetonicCycle = metonicCycle;
*pMetonicYear = metonicYear;
*pMoladDay = moladDay;
*pMoladHalakim = moladHalakim;
}
/************************************************************************
* Given a year, find the number of the first day of that year and the date
* and time of the starting molad.
*/
static void FindStartOfYear(
int year,
int *pMetonicCycle,
int *pMetonicYear,
long int *pMoladDay,
long int *pMoladHalakim,
int *pTishri1)
{
*pMetonicCycle = (year - 1) / 19;
*pMetonicYear = (year - 1) % 19;
MoladOfMetonicCycle(*pMetonicCycle, pMoladDay, pMoladHalakim);
*pMoladHalakim += HALAKIM_PER_LUNAR_CYCLE * yearOffset[*pMetonicYear];
*pMoladDay += *pMoladHalakim / HALAKIM_PER_DAY;
*pMoladHalakim = *pMoladHalakim % HALAKIM_PER_DAY;
*pTishri1 = Tishri1(*pMetonicYear, *pMoladDay, *pMoladHalakim);
}
/************************************************************************
* Given a serial day number (SDN), find the corresponding year, month and
* day in the Jewish calendar. The three output values will always be
* modified. If the input SDN is before the first day of year 1, they will
* all be set to zero, otherwise *pYear will be > 0; *pMonth will be in the
* range 1 to 13 inclusive; *pDay will be in the range 1 to 30 inclusive.
*/
void SdnToJewish(
long int sdn,
int *pYear,
int *pMonth,
int *pDay)
{
long int inputDay;
long int day;
long int halakim;
int metonicCycle;
int metonicYear;
int tishri1;
int tishri1After;
int yearLength;
if (sdn <= SDN_OFFSET) {
*pYear = 0;
*pMonth = 0;
*pDay = 0;
return;
}
inputDay = sdn - SDN_OFFSET;
FindTishriMolad(inputDay, &metonicCycle, &metonicYear, &day, &halakim);
tishri1 = Tishri1(metonicYear, day, halakim);
if (inputDay >= tishri1) {
/* It found Tishri 1 at the start of the year. */
*pYear = metonicCycle * 19 + metonicYear + 1;
if (inputDay < tishri1 + 59) {
if (inputDay < tishri1 + 30) {
*pMonth = 1;
*pDay = inputDay - tishri1 + 1;
} else {
*pMonth = 2;
*pDay = inputDay - tishri1 - 29;
}
return;
}
/* We need the length of the year to figure this out, so find
* Tishri 1 of the next year. */
halakim += HALAKIM_PER_LUNAR_CYCLE * monthsPerYear[metonicYear];
day += halakim / HALAKIM_PER_DAY;
halakim = halakim % HALAKIM_PER_DAY;
tishri1After = Tishri1((metonicYear + 1) % 19, day, halakim);
} else {
/* It found Tishri 1 at the end of the year. */
*pYear = metonicCycle * 19 + metonicYear;
if (inputDay >= tishri1 - 177) {
/* It is one of the last 6 months of the year. */
if (inputDay > tishri1 - 30) {
*pMonth = 13;
*pDay = inputDay - tishri1 + 30;
} else if (inputDay > tishri1 - 60) {
*pMonth = 12;
*pDay = inputDay - tishri1 + 60;
} else if (inputDay > tishri1 - 89) {
*pMonth = 11;
*pDay = inputDay - tishri1 + 89;
} else if (inputDay > tishri1 - 119) {
*pMonth = 10;
*pDay = inputDay - tishri1 + 119;
} else if (inputDay > tishri1 - 148) {
*pMonth = 9;
*pDay = inputDay - tishri1 + 148;
} else {
*pMonth = 8;
*pDay = inputDay - tishri1 + 178;
}
return;
} else {
if (monthsPerYear[(*pYear - 1) % 19] == 13) {
*pMonth = 7;
*pDay = inputDay - tishri1 + 207;
if (*pDay > 0)
return;
(*pMonth)--;
(*pDay) += 30;
if (*pDay > 0)
return;
(*pMonth)--;
(*pDay) += 30;
} else {
*pMonth = 6;
*pDay = inputDay - tishri1 + 207;
if (*pDay > 0)
return;
(*pMonth)--;
(*pDay) += 30;
}
if (*pDay > 0)
return;
(*pMonth)--;
(*pDay) += 29;
if (*pDay > 0)
return;
/* We need the length of the year to figure this out, so find
* Tishri 1 of this year. */
tishri1After = tishri1;
FindTishriMolad(day - 365,
&metonicCycle, &metonicYear, &day, &halakim);
tishri1 = Tishri1(metonicYear, day, halakim);
}
}
yearLength = tishri1After - tishri1;
day = inputDay - tishri1 - 29;
if (yearLength == 355 || yearLength == 385) {
/* Heshvan has 30 days */
if (day <= 30) {
*pMonth = 2;
*pDay = day;
return;
}
day -= 30;
} else {
/* Heshvan has 29 days */
if (day <= 29) {
*pMonth = 2;
*pDay = day;
return;
}
day -= 29;
}
/* It has to be Kislev. */
*pMonth = 3;
*pDay = day;
}
/************************************************************************
* Given a year, month and day in the Jewish calendar, find the
* corresponding serial day number (SDN). Zero is returned when the input
* date is detected as invalid. The return value will be > 0 for all valid
* dates, but there are some invalid dates that will return a positive
* value. To verify that a date is valid, convert it to SDN and then back
* and compare with the original.
*/
long int JewishToSdn(
int year,
int month,
int day)
{
long int sdn;
int metonicCycle;
int metonicYear;
int tishri1;
int tishri1After;
long int moladDay;
long int moladHalakim;
int yearLength;
int lengthOfAdarIAndII;
if (year <= 0 || day <= 0 || day > 30) {
return (0);
}
switch (month) {
case 1:
case 2:
/* It is Tishri or Heshvan - don't need the year length. */
FindStartOfYear(year, &metonicCycle, &metonicYear,
&moladDay, &moladHalakim, &tishri1);
if (month == 1) {
sdn = tishri1 + day - 1;
} else {
sdn = tishri1 + day + 29;
}
break;
case 3:
/* It is Kislev - must find the year length. */
/* Find the start of the year. */
FindStartOfYear(year, &metonicCycle, &metonicYear,
&moladDay, &moladHalakim, &tishri1);
/* Find the end of the year. */
moladHalakim += HALAKIM_PER_LUNAR_CYCLE * monthsPerYear[metonicYear];
moladDay += moladHalakim / HALAKIM_PER_DAY;
moladHalakim = moladHalakim % HALAKIM_PER_DAY;
tishri1After = Tishri1((metonicYear + 1) % 19, moladDay, moladHalakim);
yearLength = tishri1After - tishri1;
if (yearLength == 355 || yearLength == 385) {
sdn = tishri1 + day + 59;
} else {
sdn = tishri1 + day + 58;
}
break;
case 4:
case 5:
case 6:
/* It is Tevet, Shevat or Adar I - don't need the year length. */
FindStartOfYear(year + 1, &metonicCycle, &metonicYear,
&moladDay, &moladHalakim, &tishri1After);
if (monthsPerYear[(year - 1) % 19] == 12) {
lengthOfAdarIAndII = 29;
} else {
lengthOfAdarIAndII = 59;
}
if (month == 4) {
sdn = tishri1After + day - lengthOfAdarIAndII - 237;
} else if (month == 5) {
sdn = tishri1After + day - lengthOfAdarIAndII - 208;
} else {
sdn = tishri1After + day - lengthOfAdarIAndII - 178;
}
break;
default:
/* It is Adar II or later - don't need the year length. */
FindStartOfYear(year + 1, &metonicCycle, &metonicYear,
&moladDay, &moladHalakim, &tishri1After);
switch (month) {
case 7:
sdn = tishri1After + day - 207;
break;
case 8:
sdn = tishri1After + day - 178;
break;
case 9:
sdn = tishri1After + day - 148;
break;
case 10:
sdn = tishri1After + day - 119;
break;
case 11:
sdn = tishri1After + day - 89;
break;
case 12:
sdn = tishri1After + day - 60;
break;
case 13:
sdn = tishri1After + day - 30;
break;
default:
return (0);
}
}
return (sdn + SDN_OFFSET);
}
-240
View File
@@ -1,240 +0,0 @@
/* $selId: julian.c,v 2.0 1995/10/24 01:13:06 lees Exp $
* Copyright 1993-1995, Scott E. Lee, all rights reserved.
* Permission granted to use, copy, modify, distribute and sell so long as
* the above copyright and this permission statement are retained in all
* copies. THERE IS NO WARRANTY - USE AT YOUR OWN RISK.
*/
/**************************************************************************
*
* These are the externally visible components of this file:
*
* void
* SdnToJulian(
* long int sdn,
* int *pYear,
* int *pMonth,
* int *pDay);
*
* Convert a SDN to a Julian calendar date. If the input SDN is less than
* 1, the three output values will all be set to zero, otherwise *pYear
* will be >= -4713 and != 0; *pMonth will be in the range 1 to 12
* inclusive; *pDay will be in the range 1 to 31 inclusive.
*
* long int
* JulianToSdn(
* int inputYear,
* int inputMonth,
* int inputDay);
*
* Convert a Julian calendar date to a SDN. Zero is returned when the
* input date is detected as invalid or out of the supported range. The
* return value will be > 0 for all valid, supported dates, but there are
* some invalid dates that will return a positive value. To verify that a
* date is valid, convert it to SDN and then back and compare with the
* original.
*
* VALID RANGE
*
* 4713 B.C. to at least 10000 A.D.
*
* Although this software can handle dates all the way back to 4713
* B.C., such use may not be meaningful. The calendar was created in
* 46 B.C., but the details did not stabilize until at least 8 A.D.,
* and perhaps as late at the 4th century. Also, the beginning of a
* year varied from one culture to another - not all accepted January
* as the first month.
*
* CALENDAR OVERVIEW
*
* Julias Ceasar created the calendar in 46 B.C. as a modified form of
* the old Roman republican calendar which was based on lunar cycles.
* The new Julian calendar set fixed lengths for the months, abandoning
* the lunar cycle. It also specified that there would be exactly 12
* months per year and 365.25 days per year with every 4th year being a
* leap year.
*
* Note that the current accepted value for the tropical year is
* 365.242199 days, not 365.25. This lead to an 11 day shift in the
* calendar with respect to the seasons by the 16th century when the
* Gregorian calendar was created to replace the Julian calendar.
*
* The difference between the Julian and today's Gregorian calendar is
* that the Gregorian does not make centennial years leap years unless
* they are a multiple of 400, which leads to a year of 365.2425 days.
* In other words, in the Gregorian calendar, 1700, 1800 and 1900 are
* not leap years, but 2000 is. All centennial years are leap years in
* the Julian calendar.
*
* The details are unknown, but the lengths of the months were adjusted
* until they finally stablized in 8 A.D. with their current lengths:
*
* January 31
* February 28/29
* March 31
* April 30
* May 31
* June 30
* Quintilis/July 31
* Sextilis/August 31
* September 30
* October 31
* November 30
* December 31
*
* In the early days of the calendar, the days of the month were not
* numbered as we do today. The numbers ran backwards (decreasing) and
* were counted from the Ides (15th of the month - which in the old
* Roman republican lunar calendar would have been the full moon) or
* from the Nonae (9th day before the Ides) or from the beginning of
* the next month.
*
* In the early years, the beginning of the year varied, sometimes
* based on the ascension of rulers. It was not always the first of
* January.
*
* Also, today's epoch, 1 A.D. or the birth of Jesus Christ, did not
* come into use until several centuries later when Christianity became
* a dominant religion.
*
* ALGORITHMS
*
* The calculations are based on two different cycles: a 4 year cycle
* of leap years and a 5 month cycle of month lengths.
*
* The 5 month cycle is used to account for the varying lengths of
* months. You will notice that the lengths alternate between 30 and
* 31 days, except for three anomalies: both July and August have 31
* days, both December and January have 31, and February is less than
* 30. Starting with March, the lengths are in a cycle of 5 months
* (31, 30, 31, 30, 31):
*
* Mar 31 days \
* Apr 30 days |
* May 31 days > First cycle
* Jun 30 days |
* Jul 31 days /
*
* Aug 31 days \
* Sep 30 days |
* Oct 31 days > Second cycle
* Nov 30 days |
* Dec 31 days /
*
* Jan 31 days \
* Feb 28/9 days |
* > Third cycle (incomplete)
*
* For this reason the calculations (internally) assume that the year
* starts with March 1.
*
* TESTING
*
* This algorithm has been tested from the year 4713 B.C. to 10000 A.D.
* The source code of the verification program is included in this
* package.
*
* REFERENCES
*
* Conversions Between Calendar Date and Julian Day Number by Robert J.
* Tantzen, Communications of the Association for Computing Machinery
* August 1963. (Also published in Collected Algorithms from CACM,
* algorithm number 199). [Note: the published algorithm is for the
* Gregorian calendar, but was adjusted to use the Julian calendar's
* simpler leap year rule.]
*
**************************************************************************/
#include "sdncal.h"
#define SDN_OFFSET 32083
#define DAYS_PER_5_MONTHS 153
#define DAYS_PER_4_YEARS 1461
void SdnToJulian(
long int sdn,
int *pYear,
int *pMonth,
int *pDay)
{
int year;
int month;
int day;
long int temp;
int dayOfYear;
if (sdn <= 0) {
*pYear = 0;
*pMonth = 0;
*pDay = 0;
return;
}
temp = (sdn + SDN_OFFSET) * 4 - 1;
/* Calculate the year and day of year (1 <= dayOfYear <= 366). */
year = temp / DAYS_PER_4_YEARS;
dayOfYear = (temp % DAYS_PER_4_YEARS) / 4 + 1;
/* Calculate the month and day of month. */
temp = dayOfYear * 5 - 3;
month = temp / DAYS_PER_5_MONTHS;
day = (temp % DAYS_PER_5_MONTHS) / 5 + 1;
/* Convert to the normal beginning of the year. */
if (month < 10) {
month += 3;
} else {
year += 1;
month -= 9;
}
/* Adjust to the B.C./A.D. type numbering. */
year -= 4800;
if (year <= 0)
year--;
*pYear = year;
*pMonth = month;
*pDay = day;
}
long int JulianToSdn(
int inputYear,
int inputMonth,
int inputDay)
{
int year;
int month;
/* check for invalid dates */
if (inputYear == 0 || inputYear < -4713 ||
inputMonth <= 0 || inputMonth > 12 ||
inputDay <= 0 || inputDay > 31) {
return (0);
}
/* check for dates before SDN 1 (Jan 2, 4713 B.C.) */
if (inputYear == -4713) {
if (inputMonth == 1 && inputDay == 1) {
return (0);
}
}
/* Make year always a positive number. */
if (inputYear < 0) {
year = inputYear + 4801;
} else {
year = inputYear + 4800;
}
/* Adjust the start of the year. */
if (inputMonth > 2) {
month = inputMonth - 3;
} else {
month = inputMonth + 9;
year--;
}
return ((year * DAYS_PER_4_YEARS) / 4
+ (month * DAYS_PER_5_MONTHS + 2) / 5
+ inputDay
- SDN_OFFSET);
}
-36
View File
@@ -1,36 +0,0 @@
#ifndef _INCLUDED_CALENDAR_H
#define _INCLUDED_CALENDAR_H
extern zend_module_entry calendar_module_entry;
#define calendar_module_ptr & calendar_module_entry
/* Functions */
PHP_MINIT_FUNCTION(calendar);
PHP_RINIT_FUNCTION(calendar);
PHP_RSHUTDOWN_FUNCTION(calendar);
PHP_MINFO_FUNCTION(calendar);
PHP_FUNCTION(jdtogregorian);
PHP_FUNCTION(gregoriantojd);
PHP_FUNCTION(jdtojulian);
PHP_FUNCTION(juliantojd);
PHP_FUNCTION(jdtojewish);
PHP_FUNCTION(jewishtojd);
PHP_FUNCTION(jdtofrench);
PHP_FUNCTION(frenchtojd);
PHP_FUNCTION(jddayofweek);
PHP_FUNCTION(jdmonthname);
PHP_FUNCTION(easter_days);
PHP_FUNCTION(easter_date);
PHP_FUNCTION(unixtojd);
PHP_FUNCTION(jdtounix);
#define phpext_calendar_ptr calendar_module_ptr
#endif
-96
View File
@@ -1,96 +0,0 @@
#ifndef _INCLUDED_SDNCAL_H
#define _INCLUDED_SDNCAL_H
/*
* This code has been modified for use with PHP
* by Shane Caraveo shane@caraveo.com
* see below for more details
*
*/
/* $selId: sdncal.h,v 2.0 1995/10/24 01:13:06 lees Exp $
* Copyright 1993-1995, Scott E. Lee, all rights reserved.
* Permission granted to use, copy, modify, distribute and sell so long as
* the above copyright and this permission statement are retained in all
* copies. THERE IS NO WARRANTY - USE AT YOUR OWN RISK.
*/
/**************************************************************************
*
* This package defines a set of routines that convert calendar dates to
* and from a serial day number (SDN). The SDN is a serial numbering of
* days where SDN 1 is November 25, 4714 BC in the Gregorian calendar and
* SDN 2447893 is January 1, 1990. This system of day numbering is
* sometimes referred to as Julian days, but to avoid confusion with the
* Julian calendar, it is referred to as serial day numbers here. The term
* Julian days is also used to mean the number of days since the beginning
* of the current year.
*
* The SDN can be used as an intermediate step in converting from one
* calendar system to another (such as Gregorian to Jewish). It can also
* be used for date computations such as easily comparing two dates,
* determining the day of the week, finding the date of yesterday or
* calculating the number of days between two dates.
*
* When using this software on 16 bit systems, be careful to store SDNs in
* a long int, because it will not fit in the 16 bits that some systems
* allocate to an int.
*
* For each calendar, there are two routines provided. One converts dates
* in that calendar to SDN and the other converts SDN to calendar dates.
* The routines are named SdnTo<CALENDAR>() and <CALENDAR>ToSdn(), where
* <CALENDAR> is the name of the calendar system.
*
* SDN values less than one are not supported. If a conversion routine
* returns an SDN of zero, this means that the date given is either invalid
* or is outside the supported range for that calendar.
*
* At least some validity checks are performed on input dates. For
* example, a negative month number will result in the return of zero for
* the SDN. A returned SDN greater than one does not necessarily mean that
* the input date was valid. To determine if the date is valid, convert it
* to SDN, and if the SDN is greater than zero, convert it back to a date
* and compare to the original. For example:
*
* int y1, m1, d1;
* int y2, m2, d2;
* long int sdn;
* ...
* sdn = GregorianToSdn(y1, m1, d1);
* if (sdn > 0) {
* SdnToGregorian(sdn, &y2, &m2, &d2);
* if (y1 == y2 && m1 == m2 && d1 == d2) {
* ... date is valid ...
* }
* }
*
**************************************************************************/
/* Gregorian calendar conversions. */
void SdnToGregorian(long int sdn, int *pYear, int *pMonth, int *pDay);
long int GregorianToSdn(int year, int month, int day);
extern char *MonthNameShort[13];
extern char *MonthNameLong[13];
/* Julian calendar conversions. */
void SdnToJulian(long int sdn, int *pYear, int *pMonth, int *pDay);
long int JulianToSdn(int year, int month, int day);
/* Jewish calendar conversions. */
void SdnToJewish(long int sdn, int *pYear, int *pMonth, int *pDay);
long int JewishToSdn(int year, int month, int day);
extern char *JewishMonthName[14];
/* French republic calendar conversions. */
void SdnToFrench(long int sdn, int *pYear, int *pMonth, int *pDay);
long int FrenchToSdn(int inputYear, int inputMonth, int inputDay);
extern char *FrenchMonthName[14];
/* Islamic calendar conversions. */
/* Not implemented yet. */
/* Day of week conversion. 0=Sunday, 6=Saturday */
int DayOfWeek(long int sdn);
extern char *DayNameShort[7];
extern char *DayNameLong[7];
#endif /* _INCLUDED_SDNCAL_H */
-24
View File
@@ -1,24 +0,0 @@
#ifndef _PHP_COM_H
#define _PHP_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 zend_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 /* _PHP_COM_H */
-5
View File
@@ -1,5 +0,0 @@
LTLIBRARY_NAME = libcpdf.la
LTLIBRARY_SOURCES = cpdf.c
include $(top_srcdir)/build/dynlib.mk
-72
View File
@@ -1,72 +0,0 @@
dnl $Id$
AC_MSG_CHECKING(whether to include cpdflib support)
AC_ARG_WITH(cpdflib,
[ --with-cpdflib[=DIR] Include cpdflib support (requires cpdflib >= 2).
DIR is the cpdfllib install directory,
defaults to /usr.],
[
case "$withval" in
no)
AC_MSG_RESULT(no) ;;
yes)
AC_MSG_RESULT(yes)
PHP_EXTENSION(cpdf)
AC_CHECK_LIB(cpdf, cpdf_open, [AC_DEFINE(HAVE_CPDFLIB,1,[Whether you have cpdflib])],
[AC_MSG_ERROR(Cpdf module requires cpdflib >= 2.)])
AC_ADD_LIBRARY(cpdf)
AC_ADD_LIBRARY(tiff)
AC_ADD_LIBRARY(jpeg)
;;
*)
test -f $withval/include/cpdflib.h && CPDFLIB_INCLUDE="$withval/include"
if test -n "$CPDFLIB_INCLUDE" ; then
AC_MSG_RESULT(yes)
PHP_EXTENSION(cpdf)
old_LIBS=$LIBS
old_withval=$withval
AC_MSG_CHECKING([for libjpeg (needed by cpdflib 2.x)])
AC_ARG_WITH(jpeg-dir,
[ --with-jpeg-dir[=DIR] jpeg dir for cpdflib 2.x],[
AC_MSG_RESULT(yes)
if test -z $withval; then
withval="/usr/local"
fi
LIBS="$LIBS -L$withval/lib"
AC_CHECK_LIB(jpeg,jpeg_read_header, ,[AC_MSG_RESULT(no)],)
AC_ADD_LIBRARY_WITH_PATH(jpeg, $withval/lib)
],[
AC_MSG_RESULT(no)
AC_MSG_WARN(If configure fails try --with-jpeg-dir=<DIR>)
])
AC_MSG_CHECKING([for libtiff (needed by cpdflib 2.x)])
AC_ARG_WITH(tiff-dir,
[ --with-tiff-dir[=DIR] tiff dir for cpdflib 2.x],[
AC_MSG_RESULT(yes)
if test -z $withval; then
withval="/usr/local"
fi
LIBS="$LIBS -L$withval/lib"
AC_CHECK_LIB(tiff,TIFFOpen, ,[AC_MSG_RESULT(no)],)
AC_ADD_LIBRARY_WITH_PATH(tiff, $withval/lib)
],[
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(cpdf, cpdf_open, [AC_DEFINE(HAVE_CPDFLIB,1,[Whether you have cpdflib])],
[AC_MSG_ERROR(Cpdflib module requires cpdflib >= 2.)])
LIBS=$old_LIBS
AC_ADD_LIBRARY_WITH_PATH(cpdf, $withval/lib)
AC_ADD_INCLUDE($CPDFLIB_INCLUDE)
else
AC_MSG_RESULT(no)
fi ;;
esac
],[
AC_MSG_RESULT(no)
])
-2593
View File
File diff suppressed because it is too large. Load diff
-123
View File
@@ -1,123 +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 _PHP_CPDF_H
#define _PHP_CPDF_H
#if HAVE_CPDFLIB
#include <cpdflib.h>
extern zend_module_entry cpdf_module_entry;
#define cpdf_module_ptr &cpdf_module_entry
extern PHP_MINFO_FUNCTION(cpdf);
extern PHP_MINIT_FUNCTION(cpdf);
extern PHP_RINIT_FUNCTION(cpdf);
extern PHP_MSHUTDOWN_FUNCTION(cpdf);
PHP_FUNCTION(cpdf_global_set_document_limits);
PHP_FUNCTION(cpdf_set_creator);
PHP_FUNCTION(cpdf_set_title);
PHP_FUNCTION(cpdf_set_subject);
PHP_FUNCTION(cpdf_set_keywords);
PHP_FUNCTION(cpdf_set_viewer_preferences);
PHP_FUNCTION(cpdf_open);
PHP_FUNCTION(cpdf_close);
PHP_FUNCTION(cpdf_page_init);
PHP_FUNCTION(cpdf_finalize_page);
PHP_FUNCTION(cpdf_set_current_page);
PHP_FUNCTION(cpdf_begin_text);
PHP_FUNCTION(cpdf_end_text);
PHP_FUNCTION(cpdf_show);
PHP_FUNCTION(cpdf_show_xy);
PHP_FUNCTION(cpdf_continue_text);
PHP_FUNCTION(cpdf_text);
PHP_FUNCTION(cpdf_set_font);
PHP_FUNCTION(cpdf_set_leading);
PHP_FUNCTION(cpdf_set_text_rendering);
PHP_FUNCTION(cpdf_set_horiz_scaling);
PHP_FUNCTION(cpdf_set_text_rise);
PHP_FUNCTION(cpdf_set_text_matrix);
PHP_FUNCTION(cpdf_set_text_pos);
PHP_FUNCTION(cpdf_rotate_text);
PHP_FUNCTION(cpdf_set_char_spacing);
PHP_FUNCTION(cpdf_set_word_spacing);
PHP_FUNCTION(cpdf_continue_text);
PHP_FUNCTION(cpdf_stringwidth);
PHP_FUNCTION(cpdf_save);
PHP_FUNCTION(cpdf_restore);
PHP_FUNCTION(cpdf_translate);
PHP_FUNCTION(cpdf_scale);
PHP_FUNCTION(cpdf_rotate);
PHP_FUNCTION(cpdf_setflat);
PHP_FUNCTION(cpdf_setlinejoin);
PHP_FUNCTION(cpdf_setlinecap);
PHP_FUNCTION(cpdf_setmiterlimit);
PHP_FUNCTION(cpdf_setlinewidth);
PHP_FUNCTION(cpdf_setdash);
PHP_FUNCTION(cpdf_moveto);
PHP_FUNCTION(cpdf_rmoveto);
PHP_FUNCTION(cpdf_curveto);
PHP_FUNCTION(cpdf_lineto);
PHP_FUNCTION(cpdf_rlineto);
PHP_FUNCTION(cpdf_circle);
PHP_FUNCTION(cpdf_arc);
PHP_FUNCTION(cpdf_rect);
PHP_FUNCTION(cpdf_newpath);
PHP_FUNCTION(cpdf_closepath);
PHP_FUNCTION(cpdf_closepath_stroke);
PHP_FUNCTION(cpdf_stroke);
PHP_FUNCTION(cpdf_fill);
PHP_FUNCTION(cpdf_fill_stroke);
PHP_FUNCTION(cpdf_closepath_fill_stroke);
PHP_FUNCTION(cpdf_endpath);
PHP_FUNCTION(cpdf_clip);
PHP_FUNCTION(cpdf_setgray_fill);
PHP_FUNCTION(cpdf_setgray_stroke);
PHP_FUNCTION(cpdf_setgray);
PHP_FUNCTION(cpdf_setrgbcolor_fill);
PHP_FUNCTION(cpdf_setrgbcolor_stroke);
PHP_FUNCTION(cpdf_setrgbcolor);
PHP_FUNCTION(cpdf_add_outline);
PHP_FUNCTION(cpdf_set_page_animation);
PHP_FUNCTION(cpdf_finalize);
PHP_FUNCTION(cpdf_output_buffer);
PHP_FUNCTION(cpdf_save_to_file);
PHP_FUNCTION(cpdf_add_annotation);
PHP_FUNCTION(cpdf_import_jpeg);
#if HAVE_LIBGD13
PHP_FUNCTION(cpdf_place_inline_image);
#endif
PHP_FUNCTION(cpdf_set_action_url);
#else
#define cpdf_module_ptr NULL
#endif
#define phpext_cpdf_ptr cpdf_module_ptr
#endif /* _PHP_PDF_H */
-5
View File
@@ -1,5 +0,0 @@
LTLIBRARY_NAME = libcybercash.la
LTLIBRARY_SOURCES = cybercash.c
include $(top_srcdir)/build/dynlib.mk
-28
View File
@@ -1,28 +0,0 @@
dnl config.m4 for extension CyberCash
dnl don't forget to call PHP_EXTENSION(cybercash)
AC_MSG_CHECKING(for CyberCash support)
AC_ARG_WITH(cybercash,
[ --with-cybercash[=DIR] Include CyberCash support. DIR is the CyberCash MCK
install directory.],
[
if test "$withval" != "no"; then
test -f $withval/mckcrypt.h && MCK_DIR="$withval"
test -f $withval/c-api/mckcrypt.h && MCK_DIR="$withval/c-api"
if test -n "$MCK_DIR"; then
AC_MSG_RESULT(yes)
PHP_EXTENSION(cybercash)
old_LIBS="$LIBS"
LIBS="$LIBS -L$MCK_DIR/lib"
AC_CHECK_LIB(mckcrypto,base64_encode,[AC_DEFINE(HAVE_MCK,1,[ ])],
[AC_MSG_ERROR(Please reinstall the CyberCash MCK - cannot find mckcrypto lib)])
LIBS="$old_LIBS"
AC_ADD_LIBRARY_WITH_PATH(mckcrypto, $MCK_DIR/lib)
AC_ADD_INCLUDE($MCK_DIR)
else
AC_MSG_RESULT(no)
fi
fi
],[
AC_MSG_RESULT(no)
])
-198
View File
@@ -1,198 +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: Evan Klinger <evan715@sirius.com> |
| Timothy Whitfield <timothy@ametro.net> |
+----------------------------------------------------------------------+
*/
#include "php.h"
#if HAVE_MCK
#include "cybercash.h"
#include "mckcrypt.h"
#include "base64.h"
function_entry cybercash_functions[] = {
PHP_FE(cybercash_encr, NULL)
PHP_FE(cybercash_decr, NULL)
PHP_FE(cybercash_base64_encode, NULL)
PHP_FE(cybercash_base64_decode, NULL)
{0}
};
zend_module_entry cybercash_module_entry = {
"cybercash",
cybercash_functions,
NULL,NULL,
NULL,NULL,
NULL,
STANDARD_MODULE_PROPERTIES,
};
PHP_FUNCTION(cybercash_encr)
{
pval **wmk, **sk, **inbuff;
unsigned char *outbuff, *macbuff;
unsigned int outAlloc, outLth;
long errcode;
if(ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3,&wmk,&sk,&inbuff) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(wmk);
convert_to_string_ex(sk);
convert_to_string_ex(inbuff);
outAlloc = (*inbuff)->value.str.len + 10;
outbuff = (unsigned char *)emalloc(outAlloc);
macbuff = (unsigned char *)emalloc(20);
errcode = mck_encr((*wmk)->value.str.val,(*sk)->value.str.val,
(*inbuff)->value.str.len+1,
(*inbuff)->value.str.val,
outAlloc,
outbuff,
&outLth,
macbuff);
array_init(return_value);
add_assoc_long(return_value,"errcode",errcode);
if(!errcode)
{
add_assoc_stringl(return_value,"outbuff",outbuff,outLth,0);
add_assoc_long(return_value,"outLth",outLth);
add_assoc_stringl(return_value,"macbuff",macbuff,20,0);
}
else
{
efree(outbuff);
efree(macbuff);
}
}
PHP_FUNCTION(cybercash_decr)
{
pval **wmk,**sk,**inbuff;
unsigned char *outbuff, *macbuff;
unsigned int outAlloc, outLth;
long errcode;
if(ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3,&wmk,&sk,&inbuff) == FAILURE)
{
WRONG_PARAM_COUNT;
}
convert_to_string_ex(wmk);
convert_to_string_ex(sk);
convert_to_string_ex(inbuff);
outAlloc=(*inbuff)->value.str.len;
outbuff=(unsigned char *)emalloc(outAlloc);
macbuff=(unsigned char *)emalloc(20);
errcode=mck_decr((*wmk)->value.str.val,
(*sk)->value.str.val,
(*inbuff)->value.str.len,
(*inbuff)->value.str.val,
outAlloc,
outbuff,
&outLth,
macbuff);
array_init(return_value);
add_assoc_long(return_value,"errcode",errcode);
if(!errcode) {
add_assoc_stringl(return_value,"outbuff",outbuff,outLth,0);
add_assoc_long(return_value,"outLth",outLth);
add_assoc_stringl(return_value,"macbuff",macbuff,20,0);
}
else
{
efree(outbuff);
efree(macbuff);
}
}
PHP_FUNCTION(cybercash_base64_encode)
{
pval **inbuff;
char *outbuff;
long ret_length;
if(ZEND_NUM_ARGS() != 1 ||
zend_get_parameters_ex(1,&inbuff) == FAILURE)
{
WRONG_PARAM_COUNT;
}
convert_to_string_ex(inbuff);
outbuff=(char *)emalloc(
base64_enc_size((unsigned int)(*inbuff)->value.str.len));
ret_length=base64_encode(outbuff,
(*inbuff)->value.str.val,(*inbuff)->value.str.len);
return_value->value.str.val=outbuff;
return_value->value.str.len=ret_length;
return_value->type=IS_STRING;
}
PHP_FUNCTION(cybercash_base64_decode)
{
pval **inbuff;
char *outbuff;
long ret_length;
if(ZEND_NUM_ARGS() != 1 ||
zend_get_parameters_ex(1,&inbuff) == FAILURE)
{
WRONG_PARAM_COUNT;
}
convert_to_string_ex(inbuff);
outbuff=(char *)emalloc(
base64_dec_size((unsigned int)(*inbuff)->value.str.len));
ret_length=base64_decode(outbuff,
(*inbuff)->value.str.val,(*inbuff)->value.str.len);
return_value->value.str.val=outbuff;
return_value->value.str.len=ret_length;
return_value->type=IS_STRING;
}
#endif
-56
View File
@@ -1,56 +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: Evan Klinger <evan715@sirius.com> |
+----------------------------------------------------------------------+
*/
#ifndef _CYBERCASH_H
#define _CYBERCASH_H
#if HAVE_MCK
#if PHP_API_VERSION < 19990421
#define zend_module_entry cybercash_module_entry
#include "modules.h"
#include "internal_functions.h"
#endif
extern zend_module_entry cybercash_module_entry;
#define cybercash_module_ptr &cybercash_module_entry
PHP_FUNCTION(cybercash_encr);
PHP_FUNCTION(cybercash_decr);
PHP_FUNCTION(cybercash_base64_encode);
PHP_FUNCTION(cybercash_base64_decode);
#else
#define cybercash_module_ptr NULL
#endif
#define phpext_cybercash_ptr cybercash_module_ptr
#endif
-215
View File
@@ -1,215 +0,0 @@
<?php
/*********************************************************************
* Cyberlib - (C) American Metrocomm Internet Services *
* by Timothy Whitfield <timothy@ametro.net> *
* *
* PHP Cybercash API - This requires that CyberCash support be *
* compiled. *
* *
* *
* This is an attempt to duplicate the cybercash API for PHP *
* users. *
*********************************************************************
* This does not require merchant_conf for reasons that any file *
* can be accessed by the web server can be accessed by any cgi. *
*********************************************************************
*/
function SendCC2_1Server($merchant,$merchant_key,
$url,$operation,$CCNVList)
{
/* We need to make the url. */
$url=$url."cr21api.cgi/".$operation;
return SendCCServer($merchant,$merchant_key,$url,$CCNVList);
}
function SendCCServer($merchant,$merchant_key,$url,$CCNVList)
{
/* Break the url into parts. */
$url=parse_url($url);
/* Turn the name value pairs into a url encoded message. */
$pairs="";
$done=0;
$more=list($key,$val)=each($CCNVList);
while(!$done)
{
$pairs.=chop($key)."=".urlencode(chop($val));
$more=list($key,$val)=each($CCNVList);
if($more)
{
$pairs.="&";
}
else
{
$done=1;
}
}
$encrypted_pairs=CCEncrypt($merchant_key,$pairs);
$pairs_length=strlen($encrypted_pairs);
$message=sprintf("POST %s/%s HTTP/1.0\r\n",$url["path"],$merchant);
$message.=sprintf("User-Agent: CCMCK-%s\r\n","3.2.0.5");
$message.="Content-type: application/x-www-form-urlencoded\r\n";
$message.=sprintf("Content-length: %d\r\n",$pairs_length);
$message.="\r\n";
$message.=$encrypted_pairs."\r\n";
$response=CCSocketSend($merchant_key,$url["host"],isset($url["port"])?$url["port"]:"",$message);
return $response;
}
function CCEncrypt($merchant_key,$pairs)
{
$session_key=sprintf("%s #%ld",date("D M j H:i:s Y"),getmypid());
$enc_msg=cybercash_encr($merchant_key,$session_key,$pairs);
$pairs=cybercash_base64_encode($enc_msg["outbuff"]);
$mac=cybercash_base64_encode($enc_msg["macbuff"]);
/* This adds the information needed to decrypt. */
$encrypted_pairs="message=".urlencode($pairs)."&";
$encrypted_pairs.="session-key=".urlencode($session_key)."&";
$encrypted_pairs.="mac=".urlencode($mac);
return $encrypted_pairs;
}
function CCSocketSend($merchant_key,$host,$port,$message)
{
if(!$port)
{
$port="80";
}
/*This opens the port. */
$fd=fsockopen($host,$port);
/* Minor error checking. */
if(!$fd)
{
$vars["MStatus"]="failure-hard";
$vars["MErrMsg"]="Error contacting credit processor.";
return $vars;
}
/*This sends the message. */
fputs($fd,$message);
/* We read the header in and parse at the same time. */
/* Retrieve header. */
$i=0;
$response="";
while(!feof($fd) && $response != "\n")
{
$response="";
$more="";
while(!feof($fd) && $more != "\n")
{
$more=fgetc($fd);
if($more != "\n" || $response=="")
{
if($more != "\r")
{
$response.=$more;
}
}
}
$header[$i++]=$response;
}
/* We will now get the message. */
$message="";
while(!feof($fd))
{
$message.=fgets($fd,50);
}
/* It should be ok to close the socket now. */
fclose($fd);
/* This set of variables is encoded/encrypted. */
$vars=CCGetVars($message);
$vars["message"]=cybercash_base64_decode($vars["message"]);
$vars["mac"]=cybercash_base64_decode($vars["mac"]);
/* Check for errors with the request/decryption. */
/* message is base64 and encrypted. */
$dec_msg=cybercash_decr($merchant_key,$vars["session-key"],
$vars["message"]);
if($dec_msg["errcode"])
{
$vars["MStatus"]="failure-hard";
$vars["MErrMsg"]="Response non-decodable.";
return $vars;
}
if($dec_msg["macbuff"] != $vars["mac"])
{
$vars["MStatus"]="failure-hard";
$vars["MErrMsg"]="Signitures do not match.";
return $vars;
}
/* We will have to parse again to get more info. */
$vars=CCGetVars($dec_msg["outbuff"]);
return $vars;
}
function CCGetVars($message)
{
/* Retrieve variables.
This function retrieves variables in var/value key pairs.
So that $myvar["var"]==value
*/
/* Need to find these variables too. */
$cx=0;
$response="";
$more="";
$message.="\n";
$msg_len=strlen($message);
while($cx<=$msg_len)
{
$more="";
$varname="";
$varval="";
while($cx<=$msg_len && $more != "&" && $more != "\n")
{
$more=substr($message,$cx,1);
$cx++;
if($more != "&" && $more != "=" && $more != "\n")
{
$response=$response.$more;
}
if($more=="=")
{
$varname=$response;
$response="";
}
if($more=="&" || $more=="\n")
{
$varval=$response;
$response="";
}
}
if($varname != "")
{
$cybervar[$varname]=urldecode($varval);
}
}
return $cybervar;
}
?>
-26
View File
@@ -1,26 +0,0 @@
<?php
require "cyberlib.php";
$merchant=""; /* Your merchant ID goes here. */
$merchant_key=""; /* Your merchant key goes here. */
$payment_url="http://cr.cybercash.com/cgi-bin/";
$auth_type="mauthonly";
$response=SendCC2_1Server($merchant,$merchant_key,$payment_url,
$auth_type,array("Order-ID" => "2342322",
"Amount" => "usd 11.50",
"Card-Number" => "4111111111111111",
"Card-Address" => "1600 Pennsylvania Avenue",
"Card-City" => "Washington",
"Card-State" => "DC",
"Card-Zip" => "20500",
"Card-Country" => "USA",
"Card-Exp" => "12/99",
"Card-Name" => "Bill Clinton"));
while(list($key,$val)=each($response))
{
echo $key."=".$val."<br>";
}
?>
-5
View File
@@ -1,5 +0,0 @@
LTLIBRARY_NAME = libdav.la
LTLIBRARY_SOURCES = dav.c
include $(top_srcdir)/build/dynlib.mk
-29
View File
@@ -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, [Whether you have mod_dav])
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, [Whether you have mod_dav])
fi
fi
],[
AC_MSG_RESULT(no)
AC_DEFINE(HAVE_MOD_DAV, 0, [Whether you have mod_dav])
])
-271
View File
@@ -1,271 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP version 4.0 |
+----------------------------------------------------------------------+
| Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 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_02.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
#ifdef COMPILE_DL_DAV
# if PHP_31
# include "../phpdl.h"
# else
# include "dl/phpdl.h"
# endif
#endif
#include "php.h"
#include "php_dav.h"
#if defined(THREAD_SAFE) && !PHP_31
# undef THREAD_SAFE
#endif
#if HAVE_MOD_DAV
# include "mod_dav.h"
#include "ext/standard/info.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 php_dav_module;
} phpdav_global_struct;
# else /* !defined(THREAD_SAFE) */
# define DAV_GLOBAL(a) a
# define DAV_TLS_VARS
phpdav_module php_dav_module;
# endif /* defined(THREAD_SAFE) */
# define DAV_HANDLER(a) DAV_GLOBAL(php_dav_module).a##_handler
# define DAV_SET_HANDLER(a,b) \
dav_set_handler(&DAV_GLOBAL(php_dav_module).a##_handler,(b))
/* }}} */
/* {{{ dynamically loadable module stuff */
#ifdef COMPILE_DL_DAV
ZEND_GET_MODULE(phpdav)
# endif /* COMPILE_DL */
/* }}} */
/* {{{ function prototypes */
PHP_MINIT_FUNCTION(phpdav);
PHP_MSHUTDOWN_FUNCTION(phpdav);
PHP_RSHUTDOWN_FUNCTION(phpdav);
PHP_MINFO_FUNCTION(phpdav);
/* }}} */
/* {{{ extension definition structures */
function_entry phpdav_functions[] = {
PHP_FE(dav_set_mkcol_handlers, NULL)
{NULL, NULL, NULL}
};
zend_module_entry phpdav_module_entry = {
"dav", /* extension name */
phpdav_functions, /* extension function list */
PHP_MINIT(phpdav), /* extension-wide startup function */
PHP_MSHUTDOWN(phpdav), /* extension-wide shutdown function */
NULL, /* per-request startup function */
PHP_RSHUTDOWN(phpdav), /* per-request shutdown function */
PHP_MINFO(phpdav), /* information function */
STANDARD_MODULE_PROPERTIES
};
/* }}} */
/* {{{ startup, shutdown and info functions */
PHP_MINIT_FUNCTION(phpdav)
{
#if defined(THREAD_SAFE)
phpdav_global_struct *phpdav_globals;
PHP_MUTEX_ALLOC(phpdav_mutex);
PHP_MUTEX_LOCK(phpdav_mutex);
numthreads++;
if (numthreads==1){
if (!PHP3_TLS_PROC_STARTUP(PHPDAVTls)){
PHP_MUTEX_UNLOCK(phpdav_mutex);
PHP_MUTEX_FREE(phpdav_mutex);
return FAILURE;
}
}
PHP_MUTEX_UNLOCK(phdpav_mutex);
if(!PHP3_TLS_THREAD_INIT(PHPDAVTls,phpdav_globals,phpdav_global_struct)){
PHP_MUTEX_FREE(phpdav_mutex);
return FAILURE;
}
#endif
return SUCCESS;
}
PHP_MSHUTDOWN_FUNCTION(phpdav)
{
DAV_TLS_VARS;
#ifdef THREAD_SAFE
PHP3_TLS_THREAD_FREE(phpdav_globals);
PHP_MUTEX_LOCK(phpdav_mutex);
numthreads--;
if (numthreads < 1) {
PHP3_TLS_PROC_SHUTDOWN(PHPDAVTls);
PHP_MUTEX_UNLOCK(phpdav_mutex);
PHP_MUTEX_FREE(phpdav_mutex);
return SUCCESS;
}
PHP_MUTEX_UNLOCK(phpdav_mutex);
#endif
return SUCCESS;
}
PHP_RSHUTDOWN_FUNCTION(phpdav)
{
if (DAV_HANDLER(mkcol_test)) {
efree(DAV_HANDLER(mkcol_test));
}
if (DAV_HANDLER(mkcol_create)) {
efree(DAV_HANDLER(mkcol_create));
}
return SUCCESS;
}
PHP_MINFO_FUNCTION(phpdav);
{
php_info_print_table_start();
php_info_print_table_row(2, "DAV Support", "enabled");
php_info_print_table_end();
}
/* {{{ 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);
ALLOC_ZVAL(retval);
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 (ZEND_NUM_ARGS() != 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:
*/
-66
View File
@@ -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 zend_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:
*/
-2
View File
@@ -1,2 +0,0 @@
# $Id$
# This extension is still very much under construction.
-5
View File
@@ -1,5 +0,0 @@
LTLIBRARY_NAME = libdb.la
LTLIBRARY_SOURCES = db.c
include $(top_srcdir)/build/dynlib.mk
-55
View File
@@ -1,55 +0,0 @@
dnl $Id$
dnl config.m4 for extension db
dnl don't forget to call PHP_EXTENSION(db)
divert(3)dnl
AC_CHECK_HEADERS(db1/ndbm.h)
# 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,1, [Whether you have GDBM]) DBM_TYPE=gdbm; DBM_LIB=-lgdbm],
[AC_CHECK_LIB(db, dbm_open,[AC_DEFINE(NDBM,1, [Whether you have NDBM]) DBM_TYPE=ndbm; DBM_LIB=-ldb],
[AC_CHECK_LIB(c, dbm_open,[AC_DEFINE(NDBM,1,[ ]) DBM_TYPE=ndbm; DBM_LIB=],
[AC_CHECK_LIB(dbm, dbm_open,[AC_DEFINE(NDBM,1,[ ]) 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
PHP_SUBST(DBM_LIB)
PHP_SUBST(DBM_TYPE)
])
AC_PREFERRED_DB_LIB
divert(5)dnl
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)
-1186
View File
File diff suppressed because it is too large. Load diff
-92
View File
@@ -1,92 +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 _PHP_DB_H
#define _PHP_DB_H
#ifndef DLEXPORT
#define DLEXPORT
#endif
extern zend_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 *php_find_dbm(pval *id);
int php_dbm_close(dbm_info *info);
dbm_info *php_dbm_open(char *filename, char *mode);
int php_dbm_insert(dbm_info *info, char *key, char *value);
char *php_dbm_fetch(dbm_info *info, char *key);
int php_dbm_replace(dbm_info *info, char *key, char *value);
int php_dbm_exists(dbm_info *info, char *key);
int php_dbm_delete(dbm_info *info, char *key);
char *php_dbm_first_key(dbm_info *info);
char *php_dbm_nextkey(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);
#endif /* _PHP_DB_H */
-8
View File
@@ -1,8 +0,0 @@
LTLIBRARY_NAME = libdba.la
LTLIBRARY_SOURCES = dba.c dba_cdb.c dba_db2.c dba_dbm.c dba_gdbm.c \
dba_ndbm.c dba_db3.c
LTLIBRARY_SHARED_NAME = dba.la
LTLIBRARY_SHARED_LIBADD = $(DBA_SHARED_LIBADD)
include $(top_srcdir)/build/dynlib.mk
-240
View File
@@ -1,240 +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, DBA_SHARED_LIBADD)
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=""
])
PHP_ARG_ENABLE(dba,whether to enable DBA,
[ --enable-dba=shared Build DBA as a shared module])
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="db1/ndbm.h"
elif test -f "$i/include/ndbm.h" ; then
THIS_PREFIX="$i"
NDBM_EXTRA="ndbm.h"
fi
done
if test "$NDBM_EXTRA" != ""; then
AC_DEFINE_UNQUOTED(NDBM_INCLUDE_FILE, "$NDBM_EXTRA", [ ])
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 Berkeley 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/db.h"
elif test -f "$i/include/db/db2.h"; then
THIS_PREFIX="$i"
DB2_EXTRA="db/db2.h"
elif test -f "$i/include/db2.h"; then
THIS_PREFIX="$i"
DB2_EXTRA="db2.h"
elif test -f "$i/include/db.h" ; then
THIS_PREFIX="$i"
DB2_EXTRA="db.h"
fi
done
if test "$DB2_EXTRA" = "db2" ; then
DBA_INCLUDE="$DBA_INCLUDE -I$THIS_PREFIX/db2"
DB2_EXTRA="db.h"
fi
if test -n "$DB2_EXTRA"; then
AC_DEFINE_UNQUOTED(DB2_INCLUDE_FILE, "$DB2_EXTRA", [ ])
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 Berkeley DB2 support)
AC_DBA_STD_RESULT
AC_ARG_WITH(db3,
[ --with-db3[=DIR] Include Berkeley DB3 support],[
if test "$withval" != "no"; then
for i in /usr/local /usr /usr/local/BerkeleyDB.3.0 $withval; do
if test -f "$i/include/db.h" ; then
THIS_PREFIX="$i"
DB3_EXTRA="db.h"
fi
done
if test -n "$DB3_EXTRA"; then
AC_DEFINE_UNQUOTED(DB3_INCLUDE_FILE, "$DB3_EXTRA", [ ])
fi
for LIB in db db-3; do
AC_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[
AC_CHECK_LIB($LIB, db_create, [AC_DEFINE(DBA_DB3,1,[ ]) THIS_LIBS="$LIB"])
])
done
AC_DBA_STD_ASSIGN
AC_DBA_STD_CHECK
AC_DBA_STD_ATTACH
fi
])
AC_MSG_CHECKING(for Berkeley DB3 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,$ext_shared)
PHP_SUBST(DBA_SHARED_LIBADD)
else
AC_MSG_RESULT(no)
AC_DEFINE(HAVE_DBA, 0, [ ])
fi
-482
View File
@@ -1,482 +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 "php_dba.h"
#include "ext/standard/info.h"
#include "php_gdbm.h"
#include "php_ndbm.h"
#include "php_dbm.h"
#include "php_cdb.h"
#include "php_db2.h"
#include "php_db3.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);
zend_module_entry dba_module_entry = {
"dba", dba_functions,
PHP_MINIT(dba),
PHP_MSHUTDOWN(dba),
NULL, NULL,
PHP_MINFO(dba),
STANDARD_MODULE_PROPERTIES
};
#ifdef COMPILE_DL_DBA
ZEND_GET_MODULE(dba)
#endif
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 = ZEND_NUM_ARGS()
/* these are used to get the standard arguments */
#define DBA_GET1 \
if(ac != 1 || zend_get_parameters_ex(ac, &id) != SUCCESS) { \
WRONG_PARAM_COUNT; \
}
#define DBA_GET2 \
pval **key; \
if(ac != 2 || zend_get_parameters_ex(ac, &key, &id) != SUCCESS) { \
WRONG_PARAM_COUNT; \
} \
convert_to_string_ex(key)
#define DBA_IF_NOT_CORRECT_TYPE(link_id) \
info = zend_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
#if DBA_DB3
DBA_HND(db3)
#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);
}
/* }}} */
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;
}
static PHP_MSHUTDOWN_FUNCTION(dba)
{
zend_hash_destroy(&ht_keys);
return SUCCESS;
}
static PHP_MINFO_FUNCTION(dba)
{
/* could be prettier (cmv) */
dba_handler *hptr;
php_info_print_box_start(0);
PUTS("V1 ($Id$)");
for(hptr = handler; hptr->name; hptr++) {
PUTS(" ");
PUTS(hptr->name);
}
php_info_print_box_end();
}
static void php_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
DBA_ID_PARS;
pval **val, **key;
if(ac != 3 || zend_get_parameters_ex(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;
}
#define FREENOW if(args) efree(args); if(key) efree(key)
static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
{
pval ***args = (pval ***) NULL;
int ac = ZEND_NUM_ARGS();
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(zend_get_parameters_array_ex(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(zend_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 = zend_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)
{
php_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)
{
php_dba_open(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
/* }}} */
/* {{{ proto void dba_close(int handle)
Closes database */
PHP_FUNCTION(dba_close)
{
DBA_ID_GET1;
zend_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)
{
php_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)
{
php_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
-220
View File
@@ -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 "php_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 = V_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
-201
View File
@@ -1,201 +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 "php_db2.h"
#include <sys/stat.h>
#include <string.h>
#ifdef DB2_INCLUDE_FILE
#include DB2_INCLUDE_FILE
#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 :
V_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
-206
View File
@@ -1,206 +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_DB3
#include "php_db3.h"
#include <sys/stat.h>
#include <string.h>
#ifdef DB3_INCLUDE_FILE
#include DB3_INCLUDE_FILE
#endif
#define DB3_DATA dba_db3_data *dba = info->dbf
#define DB3_GKEY \
DBT gkey; \
memset(&gkey, 0, sizeof(gkey)); \
gkey.data = (char *) key; gkey.size = keylen
typedef struct {
DB *dbp;
DBC *cursor;
} dba_db3_data;
DBA_OPEN_FUNC(db3)
{
DB *dbp = NULL;
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 :
V_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_create(&dbp, NULL, 0) == 0 &&
dbp->open(dbp, info->path, NULL, type, gmode, filemode) == 0) {
dba_db3_data *data;
data = malloc(sizeof(*data));
data->dbp = dbp;
data->cursor = NULL;
info->dbf = data;
return SUCCESS;
} else if (dbp != NULL) {
dbp->close(dbp, 0);
}
return FAILURE;
}
DBA_CLOSE_FUNC(db3)
{
DB3_DATA;
if (dba->cursor) dba->cursor->c_close(dba->cursor);
dba->dbp->close(dba->dbp, 0);
free(dba);
}
DBA_FETCH_FUNC(db3)
{
DBT gval;
char *new = NULL;
DB3_DATA;
DB3_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(db3)
{
DBT gval;
DB3_DATA;
DB3_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(db3)
{
DBT gval;
DB3_DATA;
DB3_GKEY;
memset(&gval, 0, sizeof(gval));
if (!dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) {
return SUCCESS;
}
return FAILURE;
}
DBA_DELETE_FUNC(db3)
{
DB3_DATA;
DB3_GKEY;
return dba->dbp->del(dba->dbp, NULL, &gkey, 0) ? FAILURE : SUCCESS;
}
DBA_FIRSTKEY_FUNC(db3)
{
DB3_DATA;
if (dba->cursor) {
dba->cursor->c_close(dba->cursor);
}
dba->cursor = NULL;
if (dba->dbp->cursor(dba->dbp, NULL, &dba->cursor, 0) != 0) {
return NULL;
}
/* we should introduce something like PARAM_PASSTHRU... */
return dba_nextkey_db3(info, newlen);
}
DBA_NEXTKEY_FUNC(db3)
{
DB3_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) == 0) {
if (gkey.data) {
nkey = estrndup(gkey.data, gkey.size);
if (newlen) *newlen = gkey.size;
}
}
return nkey;
}
DBA_OPTIMIZE_FUNC(db3)
{
return SUCCESS;
}
DBA_SYNC_FUNC(db3)
{
DB3_DATA;
return dba->dbp->sync(dba->dbp, 0) ? FAILURE : SUCCESS;
}
#endif
-190
View File
@@ -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 "php_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 = V_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
Loaded 100 of 932 files, more files were not shown because too many files have changed in this diff. Show more